From 90864b150cb6df83979c5abbf9f6056787ddfa5c Mon Sep 17 00:00:00 2001 From: Simon Sarris Date: Mon, 30 Sep 2024 12:12:19 -0400 Subject: [PATCH] 3.0.12 --- api/index.html | 2 +- api/symbols/ActionTool.html | 2 +- api/symbols/Adornment.html | 2 +- api/symbols/Animation.html | 2 +- api/symbols/AnimationManager.html | 2 +- api/symbols/AnimationStyle.html | 2 +- api/symbols/AnimationTrigger.html | 2 +- api/symbols/AriaCommandHandler.html | 2 +- api/symbols/ArrangingLayout.html | 2 +- api/symbols/AutoScale.html | 2 +- api/symbols/AvoidsLinksRouter.html | 8 +- api/symbols/BackConversion.html | 2 +- api/symbols/BalloonLink.html | 2 +- api/symbols/Binding.html | 2 +- api/symbols/BindingMode.html | 2 +- api/symbols/Brush.html | 6 +- api/symbols/BrushLike.html | 2 +- api/symbols/BrushType.html | 2 +- api/symbols/ChangeType.html | 2 +- api/symbols/ChangedEvent.html | 2 +- api/symbols/ChangedEventHandler.html | 2 +- api/symbols/CircularArrangement.html | 2 +- api/symbols/CircularDirection.html | 2 +- api/symbols/CircularEdge.html | 2 +- api/symbols/CircularLayout.html | 2 +- api/symbols/CircularNetwork.html | 2 +- api/symbols/CircularNodeDiameterFormula.html | 2 +- api/symbols/CircularSorting.html | 2 +- api/symbols/CircularVertex.html | 2 +- api/symbols/ClickCreatingTool.html | 2 +- api/symbols/ClickSelectingTool.html | 2 +- api/symbols/ColorSpace.html | 2 +- api/symbols/ColumnResizingTool.html | 2 +- api/symbols/CommandHandler.html | 2 +- api/symbols/ContextMenuTool.html | 2 +- api/symbols/Curve.html | 2 +- api/symbols/CurvedLinkReshapingTool.html | 2 +- api/symbols/CycleMode.html | 2 +- api/symbols/Diagram.html | 2 +- api/symbols/DiagramEvent.html | 2 +- api/symbols/DiagramEventHandler.html | 2 +- api/symbols/DiagramEventName.html | 2 +- api/symbols/DiagramInitOptions.html | 2 +- api/symbols/DiagramRendererOptions.html | 2 +- api/symbols/DimensioningLink.html | 2 +- api/symbols/DoubleTreeLayout.html | 2 +- api/symbols/DragCreatingTool.html | 2 +- api/symbols/DragSelectingTool.html | 2 +- api/symbols/DragZoomingTool.html | 2 +- api/symbols/DraggingInfo.html | 2 +- api/symbols/DraggingOptions.html | 2 +- api/symbols/DraggingTool.html | 2 +- api/symbols/DrawCommandHandler.html | 2 +- api/symbols/EasingFunction.html | 2 +- api/symbols/FishboneLayout.html | 2 +- api/symbols/FishboneLink.html | 2 +- api/symbols/Flip.html | 2 +- api/symbols/ForceDirectedEdge.html | 2 +- api/symbols/ForceDirectedLayout.html | 2 +- api/symbols/ForceDirectedNetwork.html | 2 +- api/symbols/ForceDirectedVertex.html | 2 +- api/symbols/FreehandDrawingTool.html | 2 +- api/symbols/Geometry.html | 2 +- api/symbols/GeometryReshapingTool.html | 2 +- api/symbols/GeometryStretch.html | 2 +- api/symbols/GeometryType.html | 2 +- api/symbols/GestureMode.html | 2 +- api/symbols/GraphLinksModel.html | 2 +- api/symbols/GraphObject.html | 7 +- api/symbols/GridAlignment.html | 2 +- api/symbols/GridArrangement.html | 2 +- api/symbols/GridLayout.html | 2 +- api/symbols/GridSorting.html | 2 +- api/symbols/Group.html | 2 +- api/symbols/GuidedDraggingTool.html | 2 +- api/symbols/HTMLInfo.html | 2 +- api/symbols/IKeyValuePair.html | 2 +- api/symbols/IMapIterator.html | 2 +- api/symbols/ImageRendererOptions.html | 2 +- api/symbols/ImageStretch.html | 2 +- api/symbols/IncrementalData.html | 2 +- api/symbols/InputEvent.html | 2 +- api/symbols/Inspector.html | 7 +- api/symbols/Iterable.html | 2 +- api/symbols/Iterator.html | 2 +- api/symbols/Key.html | 2 +- api/symbols/Layer.html | 2 +- api/symbols/LayeredDigraphAggressive.html | 2 +- api/symbols/LayeredDigraphAlign.html | 2 +- api/symbols/LayeredDigraphCycleRemove.html | 2 +- api/symbols/LayeredDigraphEdge.html | 2 +- api/symbols/LayeredDigraphInit.html | 2 +- api/symbols/LayeredDigraphLayering.html | 2 +- api/symbols/LayeredDigraphLayout.html | 2 +- api/symbols/LayeredDigraphNetwork.html | 2 +- api/symbols/LayeredDigraphPack.html | 2 +- api/symbols/LayeredDigraphVertex.html | 2 +- api/symbols/Layout.html | 2 +- api/symbols/LayoutConditions.html | 2 +- api/symbols/LayoutEdge.html | 2 +- api/symbols/LayoutNetwork.html | 2 +- api/symbols/LayoutVertex.html | 2 +- api/symbols/Link.html | 2 +- api/symbols/LinkAdjusting.html | 2 +- api/symbols/LinkLabelDraggingTool.html | 2 +- api/symbols/LinkLabelOnPathDraggingTool.html | 2 +- api/symbols/LinkLabelRouter.html | 10 +- api/symbols/LinkReshapingTool.html | 2 +- api/symbols/LinkShiftingTool.html | 2 +- api/symbols/LinkingBaseTool.html | 2 +- api/symbols/LinkingDirection.html | 2 +- api/symbols/LinkingTool.html | 2 +- api/symbols/List.html | 2 +- api/symbols/LocalStorageCommandHandler.html | 2 +- api/symbols/Map.html | 2 +- api/symbols/Margin.html | 2 +- api/symbols/MarginLike.html | 2 +- api/symbols/Model.html | 2 +- api/symbols/Node.html | 2 +- api/symbols/NodeLabelDraggingTool.html | 2 +- api/symbols/NonRealtimeDraggingTool.html | 7 +- api/symbols/ObjectData.html | 2 +- api/symbols/Orientation.html | 2 +- api/symbols/OrthogonalLinkReshapingTool.html | 2 +- api/symbols/Overview.html | 2 +- api/symbols/OverviewResizingTool.html | 2 +- api/symbols/PackMode.html | 2 +- api/symbols/PackShape.html | 2 +- api/symbols/PackedLayout.html | 2 +- api/symbols/Palette.html | 2 +- api/symbols/Panel.html | 7 +- api/symbols/PanelLayout.html | 2 +- api/symbols/PanelLayoutFlow.html | 2 +- api/symbols/PanningTool.html | 2 +- api/symbols/ParallelLayout.html | 2 +- api/symbols/ParallelRouteLink.html | 2 +- api/symbols/Part.html | 2 +- api/symbols/PathFigure.html | 2 +- api/symbols/PathSegment.html | 2 +- api/symbols/Picture.html | 2 +- api/symbols/Placeholder.html | 2 +- api/symbols/Point.html | 2 +- api/symbols/PolygonDrawingTool.html | 2 +- api/symbols/PolylineLinkingTool.html | 2 +- api/symbols/PortShiftingTool.html | 2 +- api/symbols/PortSpreading.html | 2 +- api/symbols/Quadtree.html | 2 +- api/symbols/RadialLayout.html | 2 +- api/symbols/RadialVertex.html | 2 +- api/symbols/RealtimeDragSelectingTool.html | 2 +- api/symbols/Rect.html | 2 +- api/symbols/RelinkingTool.html | 2 +- api/symbols/RescalingTool.html | 2 +- api/symbols/ReshapingBehavior.html | 2 +- api/symbols/ResizeMultipleTool.html | 2 +- api/symbols/ResizingTool.html | 2 +- api/symbols/Robot.html | 2 +- api/symbols/RotateMultipleTool.html | 2 +- api/symbols/RotatingTool.html | 2 +- api/symbols/Router.html | 13 +- api/symbols/Routing.html | 2 +- api/symbols/RowColumnDefinition.html | 2 +- api/symbols/RowResizingTool.html | 2 +- api/symbols/ScrollMode.html | 2 +- api/symbols/SectorReshapingTool.html | 2 +- api/symbols/SegmentType.html | 2 +- api/symbols/SerpentineLayout.html | 5 +- api/symbols/Set.html | 2 +- api/symbols/Shape.html | 2 +- api/symbols/Size.html | 2 +- api/symbols/Sizing.html | 2 +- api/symbols/SnapLinkReshapingTool.html | 2 +- api/symbols/SortMode.html | 2 +- api/symbols/SortOrder.html | 2 +- api/symbols/SpiralLayout.html | 2 +- api/symbols/Spot.html | 2 +- api/symbols/SpotRotatingTool.html | 2 +- api/symbols/Stretch.html | 2 +- api/symbols/SvgRendererOptions.html | 2 +- api/symbols/SwimLaneLayout.html | 2 +- api/symbols/TableLayout.html | 2 +- api/symbols/TargetConversion.html | 2 +- api/symbols/TextBlock.html | 2 +- api/symbols/TextEditingAccept.html | 2 +- api/symbols/TextEditingStarting.html | 2 +- api/symbols/TextEditingState.html | 2 +- api/symbols/TextEditingTool.html | 2 +- api/symbols/TextFormat.html | 2 +- api/symbols/TextOverflow.html | 2 +- api/symbols/Theme.html | 2 +- api/symbols/ThemeBinding.html | 2 +- api/symbols/ThemeColors.html | 2 +- api/symbols/ThemeManager.html | 2 +- api/symbols/ThemeValues.html | 2 +- api/symbols/Themes.html | 2 +- api/symbols/Tool.html | 2 +- api/symbols/ToolManager.html | 2 +- api/symbols/Transaction.html | 2 +- api/symbols/TreeAlignment.html | 2 +- api/symbols/TreeArrangement.html | 2 +- api/symbols/TreeCompaction.html | 2 +- api/symbols/TreeEdge.html | 2 +- api/symbols/TreeLayerStyle.html | 2 +- api/symbols/TreeLayout.html | 2 +- api/symbols/TreeMapLayout.html | 2 +- api/symbols/TreeModel.html | 2 +- api/symbols/TreeNetwork.html | 2 +- api/symbols/TreePath.html | 2 +- api/symbols/TreeSorting.html | 2 +- api/symbols/TreeStyle.html | 2 +- api/symbols/TreeVertex.html | 2 +- api/symbols/TriggerStart.html | 2 +- api/symbols/UndoManager.html | 2 +- api/symbols/ViewboxStretch.html | 2 +- api/symbols/WheelMode.html | 2 +- api/symbols/Wrap.html | 2 +- api/symbols/ZoomSlider.html | 2 +- assets/css/style.css | 2 +- assets/images/fp/flow.png | Bin 0 -> 80820 bytes assets/images/fp/grouping.png | Bin 0 -> 59039 bytes assets/images/fp/network.png | Bin 0 -> 58395 bytes assets/images/fp/security.png | Bin 0 -> 170559 bytes assets/images/screenshots/panelLayout.png | Bin 0 -> 9392 bytes changelog.html | 36 +- download.html | 11 +- extensions/AriaCommandHandler.js | 2 +- extensions/AvoidsLinksRouter.js | 16 +- extensions/DataInspector.js | 8 +- extensions/Figures.js | 85 +- extensions/LinkLabelRouter.js | 32 +- extensions/NonRealtimeDraggingTool.js | 4 +- extensions/ScrollingTable.js | 23 +- extensions/SerpentineLayout.js | 2 +- extensions/SwimLaneLayout.js | 31 +- extensionsJSM/AriaCommandHandler.js | 2 +- extensionsJSM/AriaCommandHandler.ts | 2 +- extensionsJSM/AvoidsLinksRouter.js | 16 +- extensionsJSM/AvoidsLinksRouter.ts | 16 +- extensionsJSM/Buttons.ts | 16 +- extensionsJSM/DataInspector.js | 8 +- extensionsJSM/DataInspector.ts | 6 +- extensionsJSM/Figures.js | 85 +- extensionsJSM/Figures.ts | 86 +- extensionsJSM/LinkLabelRouter.js | 32 +- extensionsJSM/LinkLabelRouter.ts | 28 +- extensionsJSM/NonRealtimeDraggingTool.js | 4 +- extensionsJSM/NonRealtimeDraggingTool.ts | 6 +- extensionsJSM/ScrollingTable.js | 23 +- extensionsJSM/ScrollingTable.ts | 29 +- extensionsJSM/SerpentineLayout.js | 2 +- extensionsJSM/SerpentineLayout.ts | 2 +- extensionsJSM/SwimLaneLayout.js | 31 +- extensionsJSM/SwimLaneLayout.ts | 33 +- index.html | 139 +- intro/HTMLInteraction.html | 11 +- intro/SVGContext.html | 11 +- intro/angular.html | 11 +- intro/animation.html | 11 +- intro/brush.html | 11 +- intro/buildingObjects.html | 11 +- intro/buttons.html | 11 +- intro/changedEvents.html | 11 +- intro/collections.html | 11 +- intro/commands.html | 11 +- intro/connectionPoints.html | 11 +- intro/contextMenus.html | 11 +- intro/dataBinding.html | 11 +- intro/debugging.html | 11 +- intro/deployment.html | 11 +- intro/events.html | 11 +- intro/extensions.html | 11 +- intro/geometry.html | 11 +- intro/graduatedPanels.html | 11 +- intro/grids.html | 11 +- intro/groups.html | 11 +- intro/highlighting.html | 11 +- intro/index.html | 11 +- intro/initialView.html | 11 +- intro/itemArrays.html | 11 +- intro/layers.html | 11 +- intro/layouts.html | 11 +- intro/legends.html | 11 +- intro/linkLabels.html | 11 +- intro/links.html | 11 +- intro/makingImages.html | 11 +- intro/makingSVG.html | 11 +- intro/nodeScript.html | 11 +- intro/nodes.html | 11 +- intro/overview.html | 11 +- intro/palette.html | 11 +- intro/panels.html | 11 +- intro/performance.html | 11 +- intro/permissions.html | 11 +- intro/pictures.html | 11 +- intro/platforms.html | 11 +- intro/ports.html | 11 +- intro/printing.html | 11 +- intro/react.html | 11 +- intro/replacingDeleting.html | 11 +- intro/resizing.html | 11 +- intro/routers.html | 11 +- intro/selection.html | 11 +- intro/serverSideImages.html | 11 +- intro/shapes.html | 11 +- intro/sizedGroups.html | 11 +- intro/sizing.html | 11 +- intro/source.html | 11 +- intro/subgraphs.html | 11 +- intro/subtrees.html | 11 +- intro/svelte.html | 11 +- intro/tablePanels.html | 11 +- intro/templateMaps.html | 11 +- intro/testing.html | 11 +- intro/textBlocks.html | 11 +- intro/theming.html | 11 +- intro/tools.html | 11 +- intro/tooltips.html | 11 +- intro/transactions.html | 11 +- intro/trees.html | 11 +- intro/typings.html | 11 +- intro/usingModels.html | 11 +- intro/validation.html | 11 +- intro/viewport.html | 11 +- learn/graphobject.html | 11 +- learn/index.html | 11 +- learn/interactivity.html | 11 +- learn/video-tutorial-intro.html | 11 +- package.json | 2 +- release/go-debug-module.js | 78 +- release/go-debug.d.ts | 31 +- release/go-debug.js | 78 +- release/go-debug.mjs | 78 +- release/go-module.d.ts | 31 +- release/go-module.js | 50 +- release/go.d.ts | 31 +- release/go.js | 50 +- release/go.mjs | 50 +- samples/Accessibility.html | 8 +- samples/Arranging.html | 8 +- samples/AvoidsLinksRouter.html | 8 +- samples/BalloonLink.html | 8 +- samples/CheckBoxes.html | 8 +- samples/ColumnResizing.html | 8 +- samples/CurvedLinkReshaping.html | 8 +- samples/DOMTree.html | 8 +- samples/DataInspector.html | 8 +- samples/Dimensioning.html | 8 +- samples/DragCreating.html | 8 +- samples/DragZooming.html | 8 +- samples/DrawCommandHandler.html | 8 +- samples/Fishbone.html | 8 +- samples/FreehandDrawing.html | 8 +- samples/GeometryReshaping.html | 8 +- samples/GuidedDragging.html | 8 +- samples/Hyperlink.html | 8 +- samples/IVRtree.html | 8 +- samples/LinkLabelDragging.html | 9 +- samples/LinkLabelOnPathDragging.html | 8 +- samples/LinkLabelRouter.html | 8 +- samples/LinkShifting.html | 16 +- samples/LocalStorageCommandHandler.html | 8 +- samples/NodeLabelDragging.html | 9 +- samples/NonRealtimeDragging.html | 8 +- samples/OrthogonalLinkReshaping.html | 16 +- samples/OverviewResizing.html | 8 +- samples/PERT.html | 37 +- samples/PackedHierarchy.html | 12 +- samples/PackedLayout.html | 8 +- samples/PanelLayoutFlow.html | 8 +- samples/Parallel.html | 8 +- samples/ParallelRoute.html | 8 +- samples/PolygonDrawing.html | 8 +- samples/PolylineLinking.html | 11 +- samples/PortShifting.html | 10 +- samples/RealtimeDragSelecting.html | 8 +- samples/Rescaling.html | 8 +- samples/ResizeMultiple.html | 8 +- samples/Robot.html | 8 +- samples/RotateMultiple.html | 8 +- samples/ScrollingTable.html | 9 +- samples/SectorReshaping.html | 8 +- samples/Serpentine.html | 8 +- samples/SnapLinkReshaping.html | 9 +- samples/Spiral.html | 8 +- samples/SpotRotating.html | 8 +- samples/SwimLaneLayout.html | 8 +- samples/Table.html | 13 +- samples/TextEditor.html | 8 +- samples/TreeMap.html | 11 +- samples/VirtualizedPacked.html | 8 +- samples/ZoomSlider.html | 8 +- samples/absolute.html | 8 +- samples/addRemoveColumns.html | 16 +- samples/addToPalette.html | 8 +- samples/adornmentButtons.html | 8 +- samples/all.html | 11 +- samples/animatedFocus.html | 8 +- samples/arrowheads.html | 8 +- samples/barCharts.html | 8 +- samples/basic.html | 8 +- samples/beatPaths.html | 8 +- samples/belts.html | 8 +- samples/blockEditor.html | 71 +- samples/cLayout.html | 8 +- samples/candlestickCharts.html | 8 +- samples/canvases.html | 8 +- samples/classHierarchy.html | 8 +- samples/comments.html | 8 +- samples/conceptMap.html | 8 +- samples/connectionBoxNode.html | 8 +- samples/constantSize.html | 8 +- samples/contentAlign.html | 8 +- samples/controlGauges.html | 8 +- samples/customAnimations.html | 8 +- samples/customContextMenu.html | 8 +- samples/customExpandCollapse.html | 8 +- samples/customTextEditingTool.html | 12 +- samples/dataFlow.html | 8 +- samples/dataFlowVertical.html | 8 +- samples/dataVisualization.html | 8 +- samples/decisionTree.html | 8 +- samples/distances.html | 8 +- samples/donutCharts.html | 8 +- samples/doubleCircle.html | 8 +- samples/doubleTree.html | 8 +- samples/dragDropFields.html | 11 +- samples/dragOutFields.html | 11 +- samples/dragUnoccupied.html | 8 +- samples/draggableLink.html | 9 +- samples/dynamicPieChart.html | 8 +- samples/dynamicPorts.html | 9 +- samples/entityRelationship.html | 8 +- samples/euler.html | 18 +- samples/familyTree.html | 18 +- samples/familyTreeJP.html | 37 +- samples/faultTree.html | 32 +- samples/fdLayout.html | 13 +- samples/flowBuilder.html | 20 +- samples/flowchart.html | 35 +- samples/flowgrammer.html | 8 +- samples/fonticons.html | 8 +- samples/friendWheel.html | 13 +- samples/gLayout.html | 8 +- samples/gameOfLife.html | 8 +- samples/gantt.html | 11 +- samples/genogram.html | 1383 +++++++------ samples/gestureBehavior.html | 8 +- samples/grafcet.html | 22 +- samples/grouping.html | 8 +- samples/hoverButtons.html | 8 +- samples/htmlDragDrop.html | 8 +- samples/htmlInteraction.html | 8 +- samples/htmlLightBoxContextMenu.html | 8 +- samples/icons.html | 8 +- samples/incrementalTree.html | 8 +- samples/index.html | 1831 +++++++++--------- samples/industrialDiagram.html | 5 + samples/industrialMonitor.html | 36 +- samples/instrumentGauge.html | 8 +- samples/interactiveForce.html | 11 +- samples/kanban.html | 40 +- samples/kittenMonitor.html | 253 ++- samples/ldLayout.html | 12 +- samples/leaflet.html | 14 +- samples/linksToLinks.html | 8 +- samples/localView.html | 8 +- samples/logicCircuit.html | 8 +- samples/macros.html | 8 +- samples/magnifier.html | 8 +- samples/minimal.html | 8 +- samples/minimalBlob.html | 8 +- samples/minimalSvg.html | 8 +- samples/multiArrow.html | 13 +- samples/multiColorLinks.html | 13 +- samples/multiNodePathLinks.html | 13 +- samples/navigation.html | 8 +- samples/network.html | 15 +- samples/networkConfig.html | 8 +- samples/orgChartAssistants.html | 13 +- samples/orgChartEditor.html | 8 +- samples/orgChartExtras.html | 8 +- samples/orgChartStatic.html | 8 +- samples/pageFlow.html | 8 +- samples/panelLayout.html | 19 +- samples/parseTree.html | 13 +- samples/pathAnimation.html | 8 +- samples/pathFinder.html | 8 +- samples/pdf/minimalPDFmultiDiagram.html | 9 +- samples/pieCharts.html | 12 +- samples/pinchResizing.html | 11 +- samples/pipeTree.html | 12 +- samples/pipes.html | 13 +- samples/planogram.html | 12 +- samples/processFlow.html | 11 +- samples/productionEditor.html | 9 +- samples/productionProcess.html | 9 +- samples/radial.html | 8 +- samples/radialAdornment.html | 8 +- samples/radialPartition.html | 8 +- samples/records.html | 8 +- samples/regrouping.html | 8 +- samples/regroupingTreeView.html | 8 +- samples/relationships.html | 8 +- samples/roundedGroups.html | 8 +- samples/ruleredDiagram.html | 8 +- samples/sankey.html | 13 +- samples/scrollModes.html | 8 +- samples/seatingChart.html | 21 +- samples/security.html | 42 +- samples/selectableFields.html | 10 +- samples/selectablePorts.html | 8 +- samples/sequenceDiagram.html | 21 +- samples/sequentialFunction.html | 8 +- samples/shapes.html | 8 +- samples/sharedStates.html | 18 +- samples/singlePage.html | 57 +- samples/spacingZoom.html | 11 +- samples/sparklineGraphs.html | 8 +- samples/spreadsheet.html | 8 +- samples/stateChart.html | 14 +- samples/stateChartIncremental.html | 22 +- samples/svgDataUrl.html | 8 +- samples/swimBands.html | 13 +- samples/swimLanes.html | 18 +- samples/swimLanesVertical.html | 16 +- samples/systemDynamics.html | 8 +- samples/tLayout.html | 8 +- samples/taperedLinks.html | 13 +- samples/thermometer.html | 8 +- samples/tiger.html | 8 +- samples/timeline.html | 21 +- samples/tournament.html | 8 +- samples/treeLoadAnimation.html | 8 +- samples/treeMapper.html | 18 +- samples/treeView.html | 8 +- samples/triStateCheckBoxTree.html | 8 +- samples/twoDiagrams.html | 8 +- samples/twoHalves.html | 8 +- samples/umlClass.html | 8 +- samples/updateDemo.html | 8 +- samples/virtualized.html | 8 +- samples/virtualizedForceLayout.html | 11 +- samples/virtualizedTreeLayout.html | 11 +- samples/visualTree.html | 8 +- samples/visualTreeGrouping.html | 8 +- samples/vue.html | 8 +- samples/warehouse.html | 11 +- samples/wordcloud.html | 10 +- 548 files changed, 4753 insertions(+), 3605 deletions(-) create mode 100644 assets/images/fp/flow.png create mode 100644 assets/images/fp/grouping.png create mode 100644 assets/images/fp/network.png create mode 100644 assets/images/fp/security.png create mode 100644 assets/images/screenshots/panelLayout.png diff --git a/api/index.html b/api/index.html index faab9f3b1..85da22843 100644 --- a/api/index.html +++ b/api/index.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

GoJS API

GoJS® Diagramming Components
version 3.0.11
by Northwoods Software®

Index

Diagram Classes

Adornment + });

GoJS API

GoJS® Diagramming Components
version 3.0.12
by Northwoods Software®

Index

Diagram Classes

Adornment Animation AnimationManager AnimationTrigger diff --git a/api/symbols/ActionTool.html b/api/symbols/ActionTool.html index 31a93d0b6..eac549b58 100644 --- a/api/symbols/ActionTool.html +++ b/api/symbols/ActionTool.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

Class ActionTool

GoJS® Diagramming Components
version 3.0.11
by Northwoods Software®

Hierarchy

The ActionTool is responsible for handling and dispatching mouse events on GraphObjects + });

Class ActionTool

GoJS® Diagramming Components
version 3.0.12
by Northwoods Software®

Hierarchy

The ActionTool is responsible for handling and dispatching mouse events on GraphObjects that have GraphObject.isActionable set to true. This is how one implements "controls", such as buttons or sliders or knobs, as GraphObjects that can be inside Parts without interfering with the standard tool behaviors.

diff --git a/api/symbols/Adornment.html b/api/symbols/Adornment.html index a0ebbff4a..95fc58c12 100644 --- a/api/symbols/Adornment.html +++ b/api/symbols/Adornment.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

Class Adornment

GoJS® Diagramming Components
version 3.0.11
by Northwoods Software®

Hierarchy

An Adornment is a special kind of Part that is associated with another Part, + });

Class Adornment

GoJS® Diagramming Components
version 3.0.12
by Northwoods Software®

Hierarchy

An Adornment is a special kind of Part that is associated with another Part, the Adornment.adornedPart.

Adornments are normally associated with a particular GraphObject in the adorned Part -- that is the value of adornedObject. diff --git a/api/symbols/Animation.html b/api/symbols/Animation.html index 9287bc3d1..177f77e73 100644 --- a/api/symbols/Animation.html +++ b/api/symbols/Animation.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

Class Animation

GoJS® Diagramming Components
version 3.0.11
by Northwoods Software®

Animations are used to animate GraphObject and Diagram properties.

+ });

Class Animation

GoJS® Diagramming Components
version 3.0.12
by Northwoods Software®

Animations are used to animate GraphObject and Diagram properties.

This class is useful for creating manual animations. If you wish to animate particular properties on a GraphObject every time their value changes, you may want to use AnimationTriggers instead, which automatically create and start Animations.

diff --git a/api/symbols/AnimationManager.html b/api/symbols/AnimationManager.html index a6f42839d..652f81651 100644 --- a/api/symbols/AnimationManager.html +++ b/api/symbols/AnimationManager.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

Class AnimationManager

GoJS® Diagramming Components
version 3.0.11
by Northwoods Software®

AnimationManager handles animations in a Diagram. Each Diagram has one, Diagram.animationManager. + });

Class AnimationManager

GoJS® Diagramming Components
version 3.0.12
by Northwoods Software®

AnimationManager handles animations in a Diagram. Each Diagram has one, Diagram.animationManager. Setting the Model, performing a Layout, Group expansion and Tree expansion automatically start animations through the defaultAnimation. Animations can be manually started by creating Animations, which are associated with an AnimationManager.

diff --git a/api/symbols/AnimationStyle.html b/api/symbols/AnimationStyle.html index 3cf56262e..ba9b0ff4b 100644 --- a/api/symbols/AnimationStyle.html +++ b/api/symbols/AnimationStyle.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

Enumeration AnimationStyle

GoJS® Diagramming Components
version 3.0.11
by Northwoods Software®

This enumeration specifies possible values for AnimationManager.initialAnimationStyle.

+ });

Enumeration AnimationStyle

GoJS® Diagramming Components
version 3.0.12
by Northwoods Software®

This enumeration specifies possible values for AnimationManager.initialAnimationStyle.

To customize the initial animation, set AnimationManager.initialAnimationStyle to None and define an "InitialAnimationStarting" DiagramEvent listener with Diagram.addDiagramListener.

See AnimationManager.initialAnimationStyle for details and examples.

diff --git a/api/symbols/AnimationTrigger.html b/api/symbols/AnimationTrigger.html index 052188a53..e17a190c2 100644 --- a/api/symbols/AnimationTrigger.html +++ b/api/symbols/AnimationTrigger.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

Class AnimationTrigger

GoJS® Diagramming Components
version 3.0.11
by Northwoods Software®

An AnimationTrigger describes how to automatically animate a property on a GraphObject + });

Class AnimationTrigger

GoJS® Diagramming Components
version 3.0.12
by Northwoods Software®

An AnimationTrigger describes how to automatically animate a property on a GraphObject when it changes value. The target property name is a string, and all name matching is case-sensitive.

Triggers will be shared by all copies of the template's GraphObjects. diff --git a/api/symbols/AriaCommandHandler.html b/api/symbols/AriaCommandHandler.html index 287e24eb4..97a5772ea 100644 --- a/api/symbols/AriaCommandHandler.html +++ b/api/symbols/AriaCommandHandler.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

Class AriaCommandHandler

GoJS® Diagramming Components
version 3.0.11
by Northwoods Software®

This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

Hierarchy

This custom CommandHandler is an example of how screen reader accessibility can be added to diagrams with an aria-live DIV.

+ });

Class AriaCommandHandler

GoJS® Diagramming Components
version 3.0.12
by Northwoods Software®

This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

Hierarchy

This custom CommandHandler is an example of how screen reader accessibility can be added to diagrams with an aria-live DIV.

This CommandHandler adds more key commands for a user:

  • Arrow keys: Change selection to a new node, if possible, based on direction/tree realationship/linked nodes. This is added to an internal navigation history.
  • diff --git a/api/symbols/ArrangingLayout.html b/api/symbols/ArrangingLayout.html index 7522553cf..6c276fedd 100644 --- a/api/symbols/ArrangingLayout.html +++ b/api/symbols/ArrangingLayout.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

    Class ArrangingLayout

    GoJS® Diagramming Components
    version 3.0.11
    by Northwoods Software®

    This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

    Hierarchy

    A custom Layout that provides one way to have a layout of layouts. + });

    Class ArrangingLayout

    GoJS® Diagramming Components
    version 3.0.12
    by Northwoods Software®

    This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

    Hierarchy

    A custom Layout that provides one way to have a layout of layouts. It partitions nodes and links into separate subnetworks, applies a primary layout to each subnetwork, and then arranges those results by an arranging layout. Any disconnected nodes are laid out later by a diff --git a/api/symbols/AutoScale.html b/api/symbols/AutoScale.html index 263422f13..ec78b9ffc 100644 --- a/api/symbols/AutoScale.html +++ b/api/symbols/AutoScale.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

    Enumeration AutoScale

    GoJS® Diagramming Components
    version 3.0.11
    by Northwoods Software®

    This enumeration specifies how the Diagram should attempt to scale its Diagram.documentBounds into the view. + });

    Enumeration AutoScale

    GoJS® Diagramming Components
    version 3.0.12
    by Northwoods Software®

    This enumeration specifies how the Diagram should attempt to scale its Diagram.documentBounds into the view. Used for Diagram.autoScale.

    since

    3.0

    Index

    Enumeration Members

    None diff --git a/api/symbols/AvoidsLinksRouter.html b/api/symbols/AvoidsLinksRouter.html index ba9c5cc55..07e548e10 100644 --- a/api/symbols/AvoidsLinksRouter.html +++ b/api/symbols/AvoidsLinksRouter.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

    Class AvoidsLinksRouter

    GoJS® Diagramming Components
    version 3.0.11
    by Northwoods Software®

    This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

    Hierarchy

    A custom Router that will cause overlapping segments of Orthogonal or AvoidsNodes links to be routed in parallel, + });

    Class AvoidsLinksRouter

    GoJS® Diagramming Components
    version 3.0.12
    by Northwoods Software®

    This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

    Hierarchy

    A custom Router that will cause overlapping segments of Orthogonal or AvoidsNodes links to be routed in parallel, while minimizing resulting crossings between links.

    The maximum distance that resulting sets of links will be spread apart is given by AvoidsLinksRouter.linkSpacing.

    By default the router will reduce the space between parallel segments to prevent them from overlapping nearby Nodes, @@ -82,10 +82,10 @@ If avoidsNodes is true, this value is the maximum allowed distance between such links, but the distance could be smaller to avoid overlapping Nodes.

    The default value is 4.

    -

Methods

  • Determine whether the AvoidsLinksRouter should operate on a given collection. +

Methods

  • Adjust segments of all links in the Diagram to prevent overlap.

    +

    Parameters

    Returns void

Type alias BackConversion

GoJS® Diagramming Components
version 3.0.11
by Northwoods Software®

For bindings: The optional conversion function to convert property values back to data values. + });

Type alias BackConversion

GoJS® Diagramming Components
version 3.0.12
by Northwoods Software®

For bindings: The optional conversion function to convert property values back to data values. Specifying this function modifies a binding to set its Binding.mode to be BindingMode.TwoWay. If you want a two-way binding without a back-conversion function, specify null for a BackConversion. If you do not want a two-way binding, omit any BackConversion.

diff --git a/api/symbols/BalloonLink.html b/api/symbols/BalloonLink.html index e56118a1e..80587bb2c 100644 --- a/api/symbols/BalloonLink.html +++ b/api/symbols/BalloonLink.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

Class BalloonLink

GoJS® Diagramming Components
version 3.0.11
by Northwoods Software®

This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

Hierarchy

This custom go.Link class customizes its go.Shape to surround the comment node (the from node). + });

Class BalloonLink

GoJS® Diagramming Components
version 3.0.12
by Northwoods Software®

This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

Hierarchy

This custom go.Link class customizes its go.Shape to surround the comment node (the from node). If the Shape is filled, it will obscure the comment itself unless the Link is behind the comment node. Thus the default layer for BalloonLinks is "Background".

The "corner" property controls the radius of the curves at the corners of the rectangular area surrounding the comment node, diff --git a/api/symbols/Binding.html b/api/symbols/Binding.html index 35fa73ef5..7101a8b6f 100644 --- a/api/symbols/Binding.html +++ b/api/symbols/Binding.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

Class Binding

GoJS® Diagramming Components
version 3.0.11
by Northwoods Software®

Hierarchy

A Binding describes how to automatically set a property on a GraphObject + });

Class Binding

GoJS® Diagramming Components
version 3.0.12
by Northwoods Software®

Hierarchy

A Binding describes how to automatically set a property on a GraphObject to a value of a property of data in the model. The target property name and the data source property name are strings. All name matching is case-sensitive.

diff --git a/api/symbols/BindingMode.html b/api/symbols/BindingMode.html index 23bbb996c..713741fa6 100644 --- a/api/symbols/BindingMode.html +++ b/api/symbols/BindingMode.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

Enumeration BindingMode

GoJS® Diagramming Components
version 3.0.11
by Northwoods Software®

This enumeration specifies in which direction bindings will be evaluated. + });

Enumeration BindingMode

GoJS® Diagramming Components
version 3.0.12
by Northwoods Software®

This enumeration specifies in which direction bindings will be evaluated. Used for Binding.mode.

since

3.0

Index

Enumeration Members

OneWay diff --git a/api/symbols/Brush.html b/api/symbols/Brush.html index 1c9162b5d..245811442 100644 --- a/api/symbols/Brush.html +++ b/api/symbols/Brush.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

Class Brush

GoJS® Diagramming Components
version 3.0.11
by Northwoods Software®

A Brush holds color information and describes how to draw the inside + });

Class Brush

GoJS® Diagramming Components
version 3.0.12
by Northwoods Software®

A Brush holds color information and describes how to draw the inside of a Shape or the stroke of a shape or a TextBlock or the background of any GraphObject.

A Brush must not be modified once it has been assigned to a GraphObject, @@ -70,11 +70,11 @@ Pattern Radial Solid -

Constructors

  • Construct a Brush class that holds the given color information.

    +

Constructors

  • Construct a Brush class that holds the given color information.

    Parameters

    • Optional type: string | BrushType

      Optional, one of the values BrushType.Solid, BrushType.Linear, BrushType.Radial, BrushType.Pattern, or a well-formed CSS string describing a solid color brush. No parameter defaults to a BrushType.Solid with a color description of 'black'.

      -
    • Optional init: Partial<Partial<Brush> & Record<string | number, string>>

      Optional initialization properties. +

    • Optional init: Partial<Brush> & Record<number, string>

      Optional initialization properties. In addition to Brush properties, this object can also contain color stops in the format: { 0: "#FEC901", 0.2: "#FFFFAA", 1: "#FEA200" }

    Returns Brush

Accessors

  • Gets or sets the color of a solid Brush. diff --git a/api/symbols/BrushLike.html b/api/symbols/BrushLike.html index 0be1b2826..fb6923c16 100644 --- a/api/symbols/BrushLike.html +++ b/api/symbols/BrushLike.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

    Type alias BrushLike

    GoJS® Diagramming Components
    version 3.0.11
    by Northwoods Software®

    The BrushLike type is the same as Brush | string | null. + });

    Type alias BrushLike

    GoJS® Diagramming Components
    version 3.0.12
    by Northwoods Software®

    The BrushLike type is the same as Brush | string | null. A string in place of a Brush object is treated as a Solid Brush of that color.

    Enumeration BrushType

    GoJS® Diagramming Components
    version 3.0.11
    by Northwoods Software®

    This enumeration specifies possible values for Brush.type.

    + });

    Enumeration BrushType

    GoJS® Diagramming Components
    version 3.0.12
    by Northwoods Software®

    This enumeration specifies possible values for Brush.type.

    since

    3.0

    Index

    Enumeration Members

    Linear Pattern diff --git a/api/symbols/ChangeType.html b/api/symbols/ChangeType.html index e3f21dc75..f5984c95e 100644 --- a/api/symbols/ChangeType.html +++ b/api/symbols/ChangeType.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

    Enumeration ChangeType

    GoJS® Diagramming Components
    version 3.0.11
    by Northwoods Software®

    This enumeration specifies possible values for ChangedEvent.change.

    + });

    Enumeration ChangeType

    GoJS® Diagramming Components
    version 3.0.12
    by Northwoods Software®

    This enumeration specifies possible values for ChangedEvent.change.

    since

    3.0

    Index

    Enumeration Members

    Insert Property diff --git a/api/symbols/ChangedEvent.html b/api/symbols/ChangedEvent.html index c872283c3..fca078853 100644 --- a/api/symbols/ChangedEvent.html +++ b/api/symbols/ChangedEvent.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

    Class ChangedEvent

    GoJS® Diagramming Components
    version 3.0.11
    by Northwoods Software®

    A ChangedEvent represents a change to an object, typically a GraphObject, + });

    Class ChangedEvent

    GoJS® Diagramming Components
    version 3.0.12
    by Northwoods Software®

    A ChangedEvent represents a change to an object, typically a GraphObject, but also for model data, a Model, or a Diagram. The most common case is for remembering the name of a property and the before-and-after values for that property.

    diff --git a/api/symbols/ChangedEventHandler.html b/api/symbols/ChangedEventHandler.html index 866327164..3b55ef225 100644 --- a/api/symbols/ChangedEventHandler.html +++ b/api/symbols/ChangedEventHandler.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

    Type alias ChangedEventHandler

    GoJS® Diagramming Components
    version 3.0.11
    by Northwoods Software®

    Type declaration

      • (e: ChangedEvent): void
      • The signature for a function acting as a handler for ChangedEvents.

        + });

        Type alias ChangedEventHandler

        GoJS® Diagramming Components
        version 3.0.12
        by Northwoods Software®

        Type declaration

        Enumeration CircularArrangement

        GoJS® Diagramming Components
        version 3.0.11
        by Northwoods Software®

        This enumeration specifies how nodes should be spaced in the ring. + });

        Enumeration CircularArrangement

        GoJS® Diagramming Components
        version 3.0.12
        by Northwoods Software®

        This enumeration specifies how nodes should be spaced in the ring. Used for CircularLayout.arrangement.

        since

        3.0

        Index

        Enumeration Members

        ConstantAngle diff --git a/api/symbols/CircularDirection.html b/api/symbols/CircularDirection.html index f1d143dfc..81468065c 100644 --- a/api/symbols/CircularDirection.html +++ b/api/symbols/CircularDirection.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

        Enumeration CircularDirection

        GoJS® Diagramming Components
        version 3.0.11
        by Northwoods Software®

        This enumeration specifies the direction in which the nodes fill the ring. + });

        Enumeration CircularDirection

        GoJS® Diagramming Components
        version 3.0.12
        by Northwoods Software®

        This enumeration specifies the direction in which the nodes fill the ring. Used for CircularLayout.direction.

        since

        3.0

        Index

        Enumeration Members

        BidirectionalLeft diff --git a/api/symbols/CircularEdge.html b/api/symbols/CircularEdge.html index c3b6fa97a..c036f01f7 100644 --- a/api/symbols/CircularEdge.html +++ b/api/symbols/CircularEdge.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

        Class CircularEdgeUnindexed

        GoJS® Diagramming Components
        version 3.0.11
        by Northwoods Software®

        Hierarchy

        This holds CircularLayout-specific information about Links.

        + });

        Class CircularEdgeUnindexed

        GoJS® Diagramming Components
        version 3.0.12
        by Northwoods Software®

        Hierarchy

        This holds CircularLayout-specific information about Links.

        This class inherits from LayoutEdge.

        Index

        Constructors

        Accessors

        LayoutEdge.data diff --git a/api/symbols/CircularLayout.html b/api/symbols/CircularLayout.html index ae750a693..ba66e7b04 100644 --- a/api/symbols/CircularLayout.html +++ b/api/symbols/CircularLayout.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

        Class CircularLayout

        GoJS® Diagramming Components
        version 3.0.11
        by Northwoods Software®

        Hierarchy

        This layout positions nodes in a circular arrangement. + });

        Class CircularLayout

        GoJS® Diagramming Components
        version 3.0.12
        by Northwoods Software®

        Hierarchy

        This layout positions nodes in a circular arrangement. There are several samples that use CircularLayout. The layout cannot guarantee that it provides optimal positioning of nodes when trying to minimize link crossings.

        diff --git a/api/symbols/CircularNetwork.html b/api/symbols/CircularNetwork.html index 159beb726..371f9e576 100644 --- a/api/symbols/CircularNetwork.html +++ b/api/symbols/CircularNetwork.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

        Class CircularNetworkUnindexed

        GoJS® Diagramming Components
        version 3.0.11
        by Northwoods Software®

        Hierarchy

        This class represents an abstract graph of CircularVertexes and CircularEdges + });

        Class CircularNetworkUnindexed

        GoJS® Diagramming Components
        version 3.0.12
        by Northwoods Software®

        Hierarchy

        This class represents an abstract graph of CircularVertexes and CircularEdges that can be constructed based on the Nodes and Links of a Diagram so that the CircularLayout can operate independently of the diagram until it is time to commit any node positioning or link routing.

        diff --git a/api/symbols/CircularNodeDiameterFormula.html b/api/symbols/CircularNodeDiameterFormula.html index 166c83bf0..f8033e57a 100644 --- a/api/symbols/CircularNodeDiameterFormula.html +++ b/api/symbols/CircularNodeDiameterFormula.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

        Enumeration CircularNodeDiameterFormula

        GoJS® Diagramming Components
        version 3.0.11
        by Northwoods Software®

        This enumeration specifies a method for finding the size of a node. + });

        Enumeration CircularNodeDiameterFormula

        GoJS® Diagramming Components
        version 3.0.12
        by Northwoods Software®

        This enumeration specifies a method for finding the size of a node. Used for CircularLayout.nodeDiameterFormula.

        since

        3.0

        Index

        Enumeration Members

        Circular diff --git a/api/symbols/CircularSorting.html b/api/symbols/CircularSorting.html index a8c8d932b..13db66a18 100644 --- a/api/symbols/CircularSorting.html +++ b/api/symbols/CircularSorting.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

        Enumeration CircularSorting

        GoJS® Diagramming Components
        version 3.0.11
        by Northwoods Software®

        This enumeration specifies how to sort the nodes. + });

        Enumeration CircularSorting

        GoJS® Diagramming Components
        version 3.0.12
        by Northwoods Software®

        This enumeration specifies how to sort the nodes. Used for CircularLayout.sorting.

        since

        3.0

        Index

        Enumeration Members

        Ascending diff --git a/api/symbols/CircularVertex.html b/api/symbols/CircularVertex.html index 86d25c871..9c300de08 100644 --- a/api/symbols/CircularVertex.html +++ b/api/symbols/CircularVertex.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

        Class CircularVertexUnindexed

        GoJS® Diagramming Components
        version 3.0.11
        by Northwoods Software®

        Hierarchy

        This holds CircularLayout-specific information about Nodes.

        + });

        Class CircularVertexUnindexed

        GoJS® Diagramming Components
        version 3.0.12
        by Northwoods Software®

        Hierarchy

        This holds CircularLayout-specific information about Nodes.

        This class inherits from LayoutVertex.

        Index

        Constructors

        Accessors

        actualAngle diff --git a/api/symbols/ClickCreatingTool.html b/api/symbols/ClickCreatingTool.html index 620231351..459d2efab 100644 --- a/api/symbols/ClickCreatingTool.html +++ b/api/symbols/ClickCreatingTool.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

        Class ClickCreatingTool

        GoJS® Diagramming Components
        version 3.0.11
        by Northwoods Software®

        Hierarchy

        • Tool
          • ClickCreatingTool

        The ClickCreatingTool lets the user create a node by clicking where they want the new node to be. + });

        Class ClickCreatingTool

        GoJS® Diagramming Components
        version 3.0.12
        by Northwoods Software®

        Hierarchy

        • Tool
          • ClickCreatingTool

        The ClickCreatingTool lets the user create a node by clicking where they want the new node to be. By default a double-click is required to start this tool; set isDoubleClick to false if you want a single-click to create a node.

        This tool is a standard mouse-up tool, the ToolManager.clickCreatingTool. diff --git a/api/symbols/ClickSelectingTool.html b/api/symbols/ClickSelectingTool.html index 2c71270cd..177ee2b46 100644 --- a/api/symbols/ClickSelectingTool.html +++ b/api/symbols/ClickSelectingTool.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

        Class ClickSelectingTool

        GoJS® Diagramming Components
        version 3.0.11
        by Northwoods Software®

        Hierarchy

        • Tool
          • ClickSelectingTool

        The ClickSelectingTool selects and deselects Parts when there is a click. + });

        Class ClickSelectingTool

        GoJS® Diagramming Components
        version 3.0.12
        by Northwoods Software®

        Hierarchy

        • Tool
          • ClickSelectingTool

        The ClickSelectingTool selects and deselects Parts when there is a click. It does this by calling Tool.standardMouseSelect. It is also responsible for handling and dispatching click events on GraphObjects by calling Tool.standardMouseClick.

        diff --git a/api/symbols/ColorSpace.html b/api/symbols/ColorSpace.html index 3a1f3031f..8245f860b 100644 --- a/api/symbols/ColorSpace.html +++ b/api/symbols/ColorSpace.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

        Enumeration ColorSpace

        GoJS® Diagramming Components
        version 3.0.11
        by Northwoods Software®

        This enumeration specifies possible values used for lightening and darkening.

        + });

        Enumeration ColorSpace

        GoJS® Diagramming Components
        version 3.0.12
        by Northwoods Software®

        This enumeration specifies possible values used for lightening and darkening.

        see
        • Brush.lightenBy
        • Brush.darkenBy
        • diff --git a/api/symbols/ColumnResizingTool.html b/api/symbols/ColumnResizingTool.html index 870a24e56..bf8b5f8ff 100644 --- a/api/symbols/ColumnResizingTool.html +++ b/api/symbols/ColumnResizingTool.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class ColumnResizingTool

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          Hierarchy

          • Tool
            • ColumnResizingTool

          The ColumnResizingTool class lets the user resize each column of a named Table Panel in a selected Part.

          + });

          Class ColumnResizingTool

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          Hierarchy

          • Tool
            • ColumnResizingTool

          The ColumnResizingTool class lets the user resize each column of a named Table Panel in a selected Part.

          If you want to experiment with this extension, try the Column Resizing sample.

          Index

          Constructors

          Accessors

          adornedTable diff --git a/api/symbols/CommandHandler.html b/api/symbols/CommandHandler.html index cc1ea4a70..e84ce9275 100644 --- a/api/symbols/CommandHandler.html +++ b/api/symbols/CommandHandler.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class CommandHandler

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          Hierarchy

          The Diagram.commandHandler implements various + });

          Class CommandHandler

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          Hierarchy

          The Diagram.commandHandler implements various commands such as CommandHandler.deleteSelection or CommandHandler.redo. The CommandHandler includes keyboard event handling to interpret key presses as commands.

          diff --git a/api/symbols/ContextMenuTool.html b/api/symbols/ContextMenuTool.html index b00e81d38..960b6ee43 100644 --- a/api/symbols/ContextMenuTool.html +++ b/api/symbols/ContextMenuTool.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class ContextMenuTool

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          Hierarchy

          The ContextMenuTool is used to create and show a context menu. + });

          Class ContextMenuTool

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          Hierarchy

          The ContextMenuTool is used to create and show a context menu. It automatically disables any browser context menu.

          Define context menus on individual GraphObjects by setting GraphObject.contextMenu. Define a context menu for the diagram background by setting Diagram.contextMenu.

          diff --git a/api/symbols/Curve.html b/api/symbols/Curve.html index 59cbaae98..995b3b3db 100644 --- a/api/symbols/Curve.html +++ b/api/symbols/Curve.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration Curve

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This enumeration specifies possible values for Link.curve.

          + });

          Enumeration Curve

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This enumeration specifies possible values for Link.curve.

          since

          3.0

          Index

          Enumeration Members

          Bezier JumpGap diff --git a/api/symbols/CurvedLinkReshapingTool.html b/api/symbols/CurvedLinkReshapingTool.html index e1ed96dac..7351fca6c 100644 --- a/api/symbols/CurvedLinkReshapingTool.html +++ b/api/symbols/CurvedLinkReshapingTool.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class CurvedLinkReshapingTool

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          Hierarchy

          This CurvedLinkReshapingTool class allows for a go.Link's path to be modified by the user + });

          Class CurvedLinkReshapingTool

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          Hierarchy

          This CurvedLinkReshapingTool class allows for a go.Link's path to be modified by the user via the dragging of a single tool handle at the middle of the link. Dragging the handle changes the value of go.Link.curviness.

          If you want to experiment with this extension, try the Curved Link Reshaping sample.

          diff --git a/api/symbols/CycleMode.html b/api/symbols/CycleMode.html index b45bc4440..a8648aa91 100644 --- a/api/symbols/CycleMode.html +++ b/api/symbols/CycleMode.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration CycleMode

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This enumeration specifies how the Diagram should handle cycles in graphs. + });

          Enumeration CycleMode

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This enumeration specifies how the Diagram should handle cycles in graphs. Used for Diagram.validCycle.

          since

          3.0

          Index

          Enumeration Members

          All diff --git a/api/symbols/Diagram.html b/api/symbols/Diagram.html index eb01b751e..d49936725 100644 --- a/api/symbols/Diagram.html +++ b/api/symbols/Diagram.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class Diagram

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          Hierarchy

          A Diagram is associated with an HTML DIV element. Constructing a Diagram creates + });

          Class Diagram

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          Hierarchy

          A Diagram is associated with an HTML DIV element. Constructing a Diagram creates an HTML Canvas element which it places inside of the given DIV element, in addition to several helper DIVs. GoJS will manage the contents of this DIV -- you should not modify the contents of the DIV, although you may style the given DIV (background, border, etc) and position and size it as needed.

          diff --git a/api/symbols/DiagramEvent.html b/api/symbols/DiagramEvent.html index ce6e65588..0dc92b310 100644 --- a/api/symbols/DiagramEvent.html +++ b/api/symbols/DiagramEvent.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class DiagramEvent

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          A DiagramEvent represents a more abstract event than an InputEvent. + });

          Class DiagramEvent

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          A DiagramEvent represents a more abstract event than an InputEvent. They are raised on the Diagram class. One can receive such events by registering a DiagramEvent listener on a Diagram by calling Diagram.addDiagramListener. diff --git a/api/symbols/DiagramEventHandler.html b/api/symbols/DiagramEventHandler.html index 1ca249c1a..249a15fd3 100644 --- a/api/symbols/DiagramEventHandler.html +++ b/api/symbols/DiagramEventHandler.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Type alias DiagramEventHandler

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          Type declaration

          • This method actually positions all of the Nodes, assuming that the ordering of the nodes is given by a single link from one node to the next. This respects the spacing and wrap properties to affect the layout.

            -

            Parameters

            Returns void

          Class Set<T>

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          An unordered iterable collection that cannot contain two instances of the same value. + });

          Class Set<T>

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          An unordered iterable collection that cannot contain two instances of the same value. In TypeScript it is a generic class that enforces at compile-time the type of elements that may be added to the Set.

          An example usage:

            const set = new go.Set();  // In TypeScript: new go.Set<string>();
          set.add("orange");
          set.add("apple");
          set.add("orange");
          // now set.size === 2
          // and set.has("orange") === true
          // and set.has("banana") === false diff --git a/api/symbols/Shape.html b/api/symbols/Shape.html index ec4b6b226..88d5d6886 100644 --- a/api/symbols/Shape.html +++ b/api/symbols/Shape.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class Shape

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          Hierarchy

          A Shape is a GraphObject that shows a geometric figure. + });

          Class Shape

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          Hierarchy

          A Shape is a GraphObject that shows a geometric figure. The Geometry determines what is drawn; the properties fill and stroke (and other stroke properties) determine how it is drawn.

          diff --git a/api/symbols/Size.html b/api/symbols/Size.html index 5a5f5ab3e..3e04eed46 100644 --- a/api/symbols/Size.html +++ b/api/symbols/Size.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class Size

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          A Size describes a width and a height in two-dimensional coordinates. + });

          Class Size

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          A Size describes a width and a height in two-dimensional coordinates. The width and height must both be non-negative.

          Use the static functions Size.parse and Size.stringify to convert to and from a standard string representation that is independent of the current locale.

          diff --git a/api/symbols/Sizing.html b/api/symbols/Sizing.html index e71517ad9..a82208bd5 100644 --- a/api/symbols/Sizing.html +++ b/api/symbols/Sizing.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration Sizing

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This enumeration specifies how rows and columns deal with extra space. + });

          Enumeration Sizing

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This enumeration specifies how rows and columns deal with extra space. Used for RowColumnDefinition.sizing.

          since

          3.0

          Index

          Enumeration Members

          Default diff --git a/api/symbols/SnapLinkReshapingTool.html b/api/symbols/SnapLinkReshapingTool.html index c6ae0075e..3d3824328 100644 --- a/api/symbols/SnapLinkReshapingTool.html +++ b/api/symbols/SnapLinkReshapingTool.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class SnapLinkReshapingTool

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          Hierarchy

          The SnapLinkReshapingTool class lets the user snap link reshaping handles to the nearest grid point. + });

          Class SnapLinkReshapingTool

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          Hierarchy

          The SnapLinkReshapingTool class lets the user snap link reshaping handles to the nearest grid point. If avoidsNodes is true and the link is orthogonal, it also avoids reshaping the link so that any adjacent segments cross over any avoidable nodes.

          If you want to experiment with this extension, try the Snap Link Reshaping sample.

          diff --git a/api/symbols/SortMode.html b/api/symbols/SortMode.html index 64418dbdc..d1f5cdf33 100644 --- a/api/symbols/SortMode.html +++ b/api/symbols/SortMode.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration SortMode

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          This enumeration is used to determine an optional method by which to sort nodes before packing the PackedLayout. + });

          Enumeration SortMode

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          This enumeration is used to determine an optional method by which to sort nodes before packing the PackedLayout. Used for PackedLayout.sortMode.

          Note: this enumeration is only exists in extensionsJSM, not in extensions.

          since

          3.0

          diff --git a/api/symbols/SortOrder.html b/api/symbols/SortOrder.html index 8d12f32b0..8899c1663 100644 --- a/api/symbols/SortOrder.html +++ b/api/symbols/SortOrder.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration SortOrder

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          This enumeration is used to determine the order that nodes will be sorted, if applicable, by the PackedLayout. + });

          Enumeration SortOrder

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          This enumeration is used to determine the order that nodes will be sorted, if applicable, by the PackedLayout. Used for PackedLayout.sortOrder.

          Note: this enumeration is only exists in extensionsJSM, not in extensions.

          since

          3.0

          diff --git a/api/symbols/SpiralLayout.html b/api/symbols/SpiralLayout.html index d459a7cec..0fd6c1bb2 100644 --- a/api/symbols/SpiralLayout.html +++ b/api/symbols/SpiralLayout.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class SpiralLayout

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          Hierarchy

          A custom go.Layout that lays out a chain of nodes in a spiral.

          + });

          Class SpiralLayout

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          Hierarchy

          A custom go.Layout that lays out a chain of nodes in a spiral.

          This layout assumes the graph is a chain of go.Nodes, spacing controls the spacing between nodes.

          If you want to experiment with this extension, try the Spiral Layout sample.

          diff --git a/api/symbols/Spot.html b/api/symbols/Spot.html index 0bf3cba07..637bbc625 100644 --- a/api/symbols/Spot.html +++ b/api/symbols/Spot.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class Spot

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          A Spot represents a relative point from (0,0) to (1,1) within the bounds of + });

          Class Spot

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          A Spot represents a relative point from (0,0) to (1,1) within the bounds of a rectangular area plus an absolute offset.

          Use the static functions Spot.parse and Spot.stringify to convert to and from a standard string representation that is independent of the current locale.

          diff --git a/api/symbols/SpotRotatingTool.html b/api/symbols/SpotRotatingTool.html index ea750216e..e5bdd5f2f 100644 --- a/api/symbols/SpotRotatingTool.html +++ b/api/symbols/SpotRotatingTool.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class SpotRotatingTool

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          Hierarchy

          A custom RotatingTool that also supports the user moving the point about which the object is rotated.

          + });

          Class SpotRotatingTool

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          Hierarchy

          A custom RotatingTool that also supports the user moving the point about which the object is rotated.

          Typical usage:

            new go.Diagram(. . .,
          {
          rotatingTool: new SpotRotatingTool(),
          . . .
          })
          diff --git a/api/symbols/Stretch.html b/api/symbols/Stretch.html index 1c9275e2e..3f26c5d49 100644 --- a/api/symbols/Stretch.html +++ b/api/symbols/Stretch.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration Stretch

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This enumeration specifies possible values for GraphObject.stretch.

          + });

          Enumeration Stretch

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This enumeration specifies possible values for GraphObject.stretch.

          since

          3.0

          Index

          Enumeration Members

          Default Fill diff --git a/api/symbols/SvgRendererOptions.html b/api/symbols/SvgRendererOptions.html index 90938121f..b52528a52 100644 --- a/api/symbols/SvgRendererOptions.html +++ b/api/symbols/SvgRendererOptions.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Interface SvgRendererOptions

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          Hierarchy

          Used for the options argument to Diagram.makeSvg.

          + });

          Interface SvgRendererOptions

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          Hierarchy

          Used for the options argument to Diagram.makeSvg.

          Index

          Properties

          Properties

          DiagramRendererOptions.background DiagramRendererOptions.callback diff --git a/api/symbols/SwimLaneLayout.html b/api/symbols/SwimLaneLayout.html index 76853f5df..b8980d15c 100644 --- a/api/symbols/SwimLaneLayout.html +++ b/api/symbols/SwimLaneLayout.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class SwimLaneLayout

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          Hierarchy

          A custom LayeredDigraphLayout that knows about "lanes" + });

          Class SwimLaneLayout

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          Hierarchy

          A custom LayeredDigraphLayout that knows about "lanes" and that positions each node in its respective lane.

          This assumes that each Node.data.lane property is a string that names the lane the node should be in. You can set the laneProperty property to use a different data property name. diff --git a/api/symbols/TableLayout.html b/api/symbols/TableLayout.html index e740bead0..f84c4ee9a 100644 --- a/api/symbols/TableLayout.html +++ b/api/symbols/TableLayout.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class TableLayout

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          Hierarchy

          This go.Layout positions non-Link Parts into a table according to the values of + });

          Class TableLayout

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          Hierarchy

          This go.Layout positions non-Link Parts into a table according to the values of go.GraphObject.row, go.GraphObject.column, go.GraphObject.rowSpan, go.GraphObject.columnSpan, go.GraphObject.alignment, go.GraphObject.stretch. If the value of GraphObject.stretch is not go.Stretch.None, the Part will be sized diff --git a/api/symbols/TargetConversion.html b/api/symbols/TargetConversion.html index 7b1b4c3eb..bc9c0ccb8 100644 --- a/api/symbols/TargetConversion.html +++ b/api/symbols/TargetConversion.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Type alias TargetConversion

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          For bindings: A side-effect-free function converting the data property value to the value to set the target property. + });

          Type alias TargetConversion

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          For bindings: A side-effect-free function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place.

          Type declaration

            • (val: any, targetObj: any): any
            • Parameters

              • val: any
              • targetObj: any

              Returns any

          Class TextBlock

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          Hierarchy

          A TextBlock is a GraphObject that displays a text string in a given font.

          + });

          Class TextBlock

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          Hierarchy

          A TextBlock is a GraphObject that displays a text string in a given font.

          The size and appearance of the text is specified by font, which takes a well-formed CSS string as its value. The order of the CSS properties given is important for cross-browser compatibility, diff --git a/api/symbols/TextEditingAccept.html b/api/symbols/TextEditingAccept.html index 74270285d..b60d9807d 100644 --- a/api/symbols/TextEditingAccept.html +++ b/api/symbols/TextEditingAccept.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration TextEditingAccept

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This enumeration specifies possible values for TextEditingTool.acceptText.

          + });

          Enumeration TextEditingAccept

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This enumeration specifies possible values for TextEditingTool.acceptText.

          since

          3.0

          Index

          Enumeration Members

          Enter LostFocus diff --git a/api/symbols/TextEditingStarting.html b/api/symbols/TextEditingStarting.html index 201039428..f12df8883 100644 --- a/api/symbols/TextEditingStarting.html +++ b/api/symbols/TextEditingStarting.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration TextEditingStarting

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This enumeration specifies possible values for TextEditingTool.starting.

          + });

          Enumeration TextEditingStarting

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This enumeration specifies possible values for TextEditingTool.starting.

          since

          3.0

          Index

          Enumeration Members

          DoubleClick SingleClick diff --git a/api/symbols/TextEditingState.html b/api/symbols/TextEditingState.html index bc8ecc4e7..e1f2dd6b8 100644 --- a/api/symbols/TextEditingState.html +++ b/api/symbols/TextEditingState.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration TextEditingState

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This enumeration specifies possible values for TextEditingTool.state.

          + });

          Enumeration TextEditingState

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This enumeration specifies possible values for TextEditingTool.state.

          since

          3.0

          Index

          Enumeration Members

          Active Editing diff --git a/api/symbols/TextEditingTool.html b/api/symbols/TextEditingTool.html index 13a95c497..e191324e8 100644 --- a/api/symbols/TextEditingTool.html +++ b/api/symbols/TextEditingTool.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class TextEditingTool

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          Hierarchy

          The TextEditingTool is used to let the user interactively edit text in place. + });

          Class TextEditingTool

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          Hierarchy

          The TextEditingTool is used to let the user interactively edit text in place. This sets the TextBlock.text property; you may want to save the changed text to the model by using a TwoWay Binding on the "text" property of editable TextBlocks.

          Typically this is used by setting the TextBlock.editable property to true diff --git a/api/symbols/TextFormat.html b/api/symbols/TextFormat.html index 9b91377fa..5f6b620e5 100644 --- a/api/symbols/TextFormat.html +++ b/api/symbols/TextFormat.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration TextFormat

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This enumeration specifies possible values for TextBlock.formatting.

          + });

          Enumeration TextFormat

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This enumeration specifies possible values for TextBlock.formatting.

          since

          3.0

          Index

          Enumeration Members

          None Trim diff --git a/api/symbols/TextOverflow.html b/api/symbols/TextOverflow.html index 9a02b27da..a2e8d991a 100644 --- a/api/symbols/TextOverflow.html +++ b/api/symbols/TextOverflow.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration TextOverflow

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This enumeration specifies possible values for TextBlock.overflow.

          + });

          Enumeration TextOverflow

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This enumeration specifies possible values for TextBlock.overflow.

          since

          3.0

          Index

          Enumeration Members

          Clip Ellipsis diff --git a/api/symbols/Theme.html b/api/symbols/Theme.html index 7d0a17b16..924f14830 100644 --- a/api/symbols/Theme.html +++ b/api/symbols/Theme.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Interface Theme

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          An interface describing a theme.

          + });

          Interface Theme

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          An interface describing a theme.

          The various optional properties this interface provides are the default object names used to lookup some binding target properties. For example, Panel.padding is looked up in the margins object and diff --git a/api/symbols/ThemeBinding.html b/api/symbols/ThemeBinding.html index c11f2c1dc..4b3e8abc9 100644 --- a/api/symbols/ThemeBinding.html +++ b/api/symbols/ThemeBinding.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class ThemeBinding

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          Hierarchy

          A ThemeBinding describes how to automatically set a property on a GraphObject + });

          Class ThemeBinding

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          Hierarchy

          A ThemeBinding describes how to automatically set a property on a GraphObject to a value of a property in a Theme. The target property name and the data source property name must be strings. All name matching is case-sensitive.

          diff --git a/api/symbols/ThemeColors.html b/api/symbols/ThemeColors.html index 565c0feea..9bf14792c 100644 --- a/api/symbols/ThemeColors.html +++ b/api/symbols/ThemeColors.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Interface ThemeColors

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          An interface describing an object with string or number keys and BrushLike values.

          + });

          Interface ThemeColors

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          An interface describing an object with string or number keys and BrushLike values.

          The optional properties on this interface outline various values used by default templates.

          Setting these values allows for some customization of built in templates without providing new definitions. For example, one could use the default link template and customize the color:

          diff --git a/api/symbols/ThemeManager.html b/api/symbols/ThemeManager.html index cc3659246..84da0ce71 100644 --- a/api/symbols/ThemeManager.html +++ b/api/symbols/ThemeManager.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class ThemeManager

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This class is responsible for managing a Diagram's theming (or multiple Diagrams, if shared).

          + });

          Class ThemeManager

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This class is responsible for managing a Diagram's theming (or multiple Diagrams, if shared).

          Read more about theming at Theming.

          Your templates can make use of the values held by the current Theme by calling GraphObject.theme or GraphObject.themeData or GraphObject.themeModel methods, diff --git a/api/symbols/ThemeValues.html b/api/symbols/ThemeValues.html index 51599851d..cf704f47d 100644 --- a/api/symbols/ThemeValues.html +++ b/api/symbols/ThemeValues.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Interface ThemeValues<T>

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          An interface describing an object with string or number keys and values of a given type.

          + });

          Interface ThemeValues<T>

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          An interface describing an object with string or number keys and values of a given type.

          since

          3.0

          Type Parameters

          • T

          Indexable

          [index: string]: T

          Class Themes

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This static class specifies the built in themes.

          + });

          Class Themes

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This static class specifies the built in themes.

          Light and Dark are the default light and dark themes initialized by the ThemeManager. Note that these themes are complete, so if you update values in the light theme, you'll also need to update the dark theme since diff --git a/api/symbols/Tool.html b/api/symbols/Tool.html index 91ea9a73e..3eb6bc798 100644 --- a/api/symbols/Tool.html +++ b/api/symbols/Tool.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class ToolAbstract

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          Hierarchy

          Tools handle mouse, keyboard, and touch events. + });

          Class ToolAbstract

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          Hierarchy

          Tools handle mouse, keyboard, and touch events. The currently running tool, Diagram.currentTool, receives all input events from the Diagram via canonicalized InputEvents.

          diff --git a/api/symbols/ToolManager.html b/api/symbols/ToolManager.html index c276aa02d..2b4949076 100644 --- a/api/symbols/ToolManager.html +++ b/api/symbols/ToolManager.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class ToolManager

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          Hierarchy

          This special Tool is responsible for managing all of the Diagram's + });

          Class ToolManager

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          Hierarchy

          This special Tool is responsible for managing all of the Diagram's mode-less tools, which you can access as the Diagram.toolManager.

          Mode-less tools are tools that are present in one of the following lists: mouseDownTools, mouseMoveTools, or mouseUpTools. diff --git a/api/symbols/Transaction.html b/api/symbols/Transaction.html index e1d193b0c..50c3ef5be 100644 --- a/api/symbols/Transaction.html +++ b/api/symbols/Transaction.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class Transaction

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          A Transaction holds a list of ChangedEvents collected during a transaction, + });

          Class Transaction

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          A Transaction holds a list of ChangedEvents collected during a transaction, as the value of the read-only changes property.

          Start a transaction by calling UndoManager.startTransaction (or Model.startTransaction or Diagram.startTransaction, which call that method). diff --git a/api/symbols/TreeAlignment.html b/api/symbols/TreeAlignment.html index 1ce670fd5..3f985e5ed 100644 --- a/api/symbols/TreeAlignment.html +++ b/api/symbols/TreeAlignment.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration TreeAlignment

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This enumeration specifies how to position a parent TreeVertex relative to its children, + });

          Enumeration TreeAlignment

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This enumeration specifies how to position a parent TreeVertex relative to its children, or how to align children in a bus. Used for TreeLayout.alignment or TreeLayout.alternateAlignment.

          since

          3.0

          diff --git a/api/symbols/TreeArrangement.html b/api/symbols/TreeArrangement.html index caf810cc9..21144b9ce 100644 --- a/api/symbols/TreeArrangement.html +++ b/api/symbols/TreeArrangement.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration TreeArrangement

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This enumeration specifies how to position the resulting trees in the document. + });

          Enumeration TreeArrangement

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This enumeration specifies how to position the resulting trees in the document. Used for TreeLayout.arrangement.

          since

          3.0

          Index

          Enumeration Members

          FixedRoots diff --git a/api/symbols/TreeCompaction.html b/api/symbols/TreeCompaction.html index adf731eec..726fc6769 100644 --- a/api/symbols/TreeCompaction.html +++ b/api/symbols/TreeCompaction.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration TreeCompaction

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This enumeration specifies how closely packed the children of a node should be. + });

          Enumeration TreeCompaction

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This enumeration specifies how closely packed the children of a node should be. Used for TreeLayout.compaction or TreeLayout.alternateCompaction.

          since

          3.0

          Index

          Enumeration Members

          Block diff --git a/api/symbols/TreeEdge.html b/api/symbols/TreeEdge.html index e41726cc1..d3b9005a7 100644 --- a/api/symbols/TreeEdge.html +++ b/api/symbols/TreeEdge.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class TreeEdgeUnindexed

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          Hierarchy

          This holds TreeLayout-specific information about Links.

          + });

          Class TreeEdgeUnindexed

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          Hierarchy

          This holds TreeLayout-specific information about Links.

          This class inherits from LayoutEdge.

          Index

          Constructors

          Accessors

          fromVertex diff --git a/api/symbols/TreeLayerStyle.html b/api/symbols/TreeLayerStyle.html index e0348697c..5a6ba7338 100644 --- a/api/symbols/TreeLayerStyle.html +++ b/api/symbols/TreeLayerStyle.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration TreeLayerStyle

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This enumeration specifies the manner in which nodes are placed into layers. + });

          Enumeration TreeLayerStyle

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This enumeration specifies the manner in which nodes are placed into layers. Used for TreeLayout.layerStyle.

          since

          3.0

          Index

          Enumeration Members

          Individual diff --git a/api/symbols/TreeLayout.html b/api/symbols/TreeLayout.html index bd652354c..e8fa60e3c 100644 --- a/api/symbols/TreeLayout.html +++ b/api/symbols/TreeLayout.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class TreeLayout

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          Hierarchy

          This layout positions nodes of a tree-structured graph in layers (rows or columns).

          + });

          Class TreeLayout

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          Hierarchy

          This layout positions nodes of a tree-structured graph in layers (rows or columns).

          For a discussion and examples of the most commonly used properties, see Trees page in the Introduction. If you want to experiment interactively with most of the properties, try the Tree Layout sample. diff --git a/api/symbols/TreeMapLayout.html b/api/symbols/TreeMapLayout.html index b50780dea..bc1f94652 100644 --- a/api/symbols/TreeMapLayout.html +++ b/api/symbols/TreeMapLayout.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class TreeMapLayout

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          Hierarchy

          A custom go.Layout that lays out hierarchical data using nested rectangles.

          + });

          Class TreeMapLayout

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          Hierarchy

          A custom go.Layout that lays out hierarchical data using nested rectangles.

          If you want to experiment with this extension, try the TreeMap Layout sample.

          Index

          Constructors

          Accessors

          isTopLevelHorizontal diff --git a/api/symbols/TreeModel.html b/api/symbols/TreeModel.html index 031d6727f..f12ac88fc 100644 --- a/api/symbols/TreeModel.html +++ b/api/symbols/TreeModel.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class TreeModel

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          Hierarchy

          TreeModels support tree-structured graphs of nodes and links. + });

          Class TreeModel

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          Hierarchy

          TreeModels support tree-structured graphs of nodes and links. Each node can have at most one "tree parent"; cycles are not permitted. The reference to the parent node's key is a property of the child node data.

          TreeModels, unlike GraphLinksModels, do not support arbitrary link relationships between nodes, diff --git a/api/symbols/TreeNetwork.html b/api/symbols/TreeNetwork.html index 4dc19fa40..8ad1bed35 100644 --- a/api/symbols/TreeNetwork.html +++ b/api/symbols/TreeNetwork.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class TreeNetworkUnindexed

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          Hierarchy

          This class represents an abstract graph of TreeVertexes and TreeEdges + });

          Class TreeNetworkUnindexed

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          Hierarchy

          This class represents an abstract graph of TreeVertexes and TreeEdges that can be constructed based on the Nodes and Links of a Diagram so that the TreeLayout can operate independently of the diagram until it is time to commit any node positioning or link routing.

          diff --git a/api/symbols/TreePath.html b/api/symbols/TreePath.html index 3fc4b1fa4..5db92e92b 100644 --- a/api/symbols/TreePath.html +++ b/api/symbols/TreePath.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration TreePath

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This enumeration specifies how to build a tree from the TreeNetwork. + });

          Enumeration TreePath

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This enumeration specifies how to build a tree from the TreeNetwork. Used for TreeLayout.path.

          since

          3.0

          Index

          Enumeration Members

          Default diff --git a/api/symbols/TreeSorting.html b/api/symbols/TreeSorting.html index dfcfb388a..7612884b7 100644 --- a/api/symbols/TreeSorting.html +++ b/api/symbols/TreeSorting.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration TreeSorting

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This enumeration specifies whether to sort the children of a node, and in what order to position them. + });

          Enumeration TreeSorting

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This enumeration specifies whether to sort the children of a node, and in what order to position them. Used for TreeLayout.sorting or TreeLayout.alternateSorting.

          since

          3.0

          Index

          Enumeration Members

          Ascending diff --git a/api/symbols/TreeStyle.html b/api/symbols/TreeStyle.html index 140e97ab9..1e5bbf4ef 100644 --- a/api/symbols/TreeStyle.html +++ b/api/symbols/TreeStyle.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration TreeStyle

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This enumeration specifies the general style in which the nodes are laid out. + });

          Enumeration TreeStyle

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This enumeration specifies the general style in which the nodes are laid out. Used for TreeLayout.treeStyle.

          since

          3.0

          Index

          Enumeration Members

          Alternating diff --git a/api/symbols/TreeVertex.html b/api/symbols/TreeVertex.html index de61a9099..c43ce7f0d 100644 --- a/api/symbols/TreeVertex.html +++ b/api/symbols/TreeVertex.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class TreeVertexUnindexed

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          Hierarchy

          This holds TreeLayout-specific information about Nodes.

          + });

          Class TreeVertexUnindexed

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          Hierarchy

          This holds TreeLayout-specific information about Nodes.

          This class inherits from LayoutVertex.

          Index

          Constructors

          Accessors

          alignment diff --git a/api/symbols/TriggerStart.html b/api/symbols/TriggerStart.html index 606e2a6ca..4dad260ef 100644 --- a/api/symbols/TriggerStart.html +++ b/api/symbols/TriggerStart.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration TriggerStart

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This enumeration specifices how an animation should be triggered. + });

          Enumeration TriggerStart

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This enumeration specifices how an animation should be triggered. Used for AnimationTrigger.startCondition.

          since

          3.0

          Index

          Enumeration Members

          Bundled diff --git a/api/symbols/UndoManager.html b/api/symbols/UndoManager.html index 0e55e6953..376566905 100644 --- a/api/symbols/UndoManager.html +++ b/api/symbols/UndoManager.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class UndoManager

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          An UndoManager observes and records model and diagram changes in transactions and + });

          Class UndoManager

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          An UndoManager observes and records model and diagram changes in transactions and supports undo/redo operations. You will need to set the isEnabled property to true in order for the UndoManager to record changes and for users to perform an undo or a redo.

          diff --git a/api/symbols/ViewboxStretch.html b/api/symbols/ViewboxStretch.html index 446b7c58b..f508b0e50 100644 --- a/api/symbols/ViewboxStretch.html +++ b/api/symbols/ViewboxStretch.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration ViewboxStretch

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This enumeration specifies possible values for Panel.viewboxStretch.

          + });

          Enumeration ViewboxStretch

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This enumeration specifies possible values for Panel.viewboxStretch.

          since

          3.0

          Index

          Enumeration Members

          Uniform UniformToFill diff --git a/api/symbols/WheelMode.html b/api/symbols/WheelMode.html index 4eb26f72a..25d2fa229 100644 --- a/api/symbols/WheelMode.html +++ b/api/symbols/WheelMode.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration WheelMode

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This enumeration specifies possible values for ToolManager.mouseWheelBehavior.

          + });

          Enumeration WheelMode

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This enumeration specifies possible values for ToolManager.mouseWheelBehavior.

          since

          3.0

          Index

          Enumeration Members

          None Scroll diff --git a/api/symbols/Wrap.html b/api/symbols/Wrap.html index 3982e688c..70817f37b 100644 --- a/api/symbols/Wrap.html +++ b/api/symbols/Wrap.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Enumeration Wrap

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This enumeration specifies possible values for TextBlock.wrap.

          + });

          Enumeration Wrap

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This enumeration specifies possible values for TextBlock.wrap.

          since

          3.0

          Index

          Enumeration Members

          BreakAll DesiredSize diff --git a/api/symbols/ZoomSlider.html b/api/symbols/ZoomSlider.html index f1d810c6e..a5d766f1e 100644 --- a/api/symbols/ZoomSlider.html +++ b/api/symbols/ZoomSlider.html @@ -35,7 +35,7 @@ // set active element // done via active tag below, always API } - });

          Class ZoomSlider

          GoJS® Diagramming Components
          version 3.0.11
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          This class implements a zoom slider for GoJS diagrams. + });

          Class ZoomSlider

          GoJS® Diagramming Components
          version 3.0.12
          by Northwoods Software®

          This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

          This class implements a zoom slider for GoJS diagrams. The constructor takes two arguments:

          • diagram Diagram a reference to a GoJS Diagram
          • diff --git a/assets/css/style.css b/assets/css/style.css index ad1bceeb2..e3931435c 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -1 +1 @@ -/*! tailwindcss v3.4.0 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:InterVariable,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:initial;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:initial}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}:root{--topnav-h:72px}*{scrollbar-width:thin}.logo{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif}.box{margin:1rem;padding:1rem}.bg-danger{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity))}.bg-info{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity))}.diagramStyling{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}h1{font-size:1.875rem;line-height:2.25rem}h1,h2{margin-top:.75rem;margin-bottom:.75rem;font-weight:700;letter-spacing:-.025em}h2{font-size:1.5rem;line-height:2rem}h3{font-size:1.25rem}h3,h4{margin-top:.75rem;margin-bottom:.75rem;line-height:1.75rem;font-weight:600}h4{font-size:1.125rem}.prose a{border-bottom-width:1px;--tw-border-opacity:1;border-bottom-color:rgb(8 145 178/var(--tw-border-opacity));font-weight:600;text-decoration-line:none}.prose a:hover{border-bottom-width:2px}footer a:hover{--tw-text-opacity:1;color:rgb(8 145 178/var(--tw-text-opacity))}ol,p,ul{margin-bottom:.75rem}ol,ul{list-style-position:inside;list-style-type:disc;padding-left:1rem;padding-right:1rem}input,textarea{border-radius:.125rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(75 85 99/var(--tw-border-opacity))}textarea{padding:.5rem}select{border-radius:.125rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(75 85 99/var(--tw-border-opacity));padding:.25rem}pre{background:#272822;padding:1em;margin:.5em 0;overflow:auto;border-radius:.3em;color:#fff}code[class*=lang],pre[class*=lang],pre[class*=lang] code{background:#272822;color:#d4d4d4;font-size:13px;text-shadow:none;font-family:Menlo,Monaco,Consolas,Andale Mono,Ubuntu Mono,Courier New,monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;hyphens:none}code{border-radius:.125rem;--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}canvas:focus,pre code:focus-visible,pre div:focus-visible{outline:2px solid #0000;outline-offset:2px}.\!button,.button,[type=button],button{margin:.25rem;display:inline-block;border-radius:.25rem;--tw-bg-opacity:1;background-color:rgb(31 73 99/var(--tw-bg-opacity));padding:.25rem .5rem;--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity));--tw-shadow:0 1px 2px 0 #0000000d;--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.\!button:disabled,.button:disabled,[type=button]:disabled,button:disabled{opacity:.5}.\!button:hover:not(:disabled),.button:hover:not(:disabled),button:hover:not(:disabled){--tw-bg-opacity:1;background-color:rgb(98 127 145/var(--tw-bg-opacity));--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity));--tw-shadow:0 1px 2px 0 #0000000d;--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.bigger{margin-top:.5rem;margin-bottom:.5rem;padding:1rem;font-weight:700}#topnavList a{padding-left:.5rem;padding-right:.5rem;line-height:calc(var(--topnav-h) - 1px)}#topnavList a:hover{--tw-text-opacity:1;color:rgb(8 145 178/var(--tw-text-opacity))}@media (min-width:1024px){#topnavList a{padding-left:1rem;padding-right:1rem}}#topnavList a.active{height:var(--topnav-h);border-bottom-width:2px;--tw-border-opacity:1;border-bottom-color:rgb(8 145 178/var(--tw-border-opacity))}.samples-sidebar-nav>a,aside>nav>a{display:block;padding:.25rem .5rem;font-size:.875rem;line-height:1.25rem;font-weight:600;--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity))}.samples-sidebar-nav>a:hover,aside>nav>a:hover{--tw-text-opacity:1;color:rgb(8 145 178/var(--tw-text-opacity))}aside>nav>a.active{border-right-width:2px;--tw-border-opacity:1;border-right-color:rgb(8 145 178/var(--tw-border-opacity))}@font-face{font-family:InterVariable;font-style:normal;font-weight:100 900;font-display:swap;src:url(https://rsms.me/inter/font-files/InterVariable.woff2?v=4.0) format("woff2")}*,::backdrop,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.visible{visibility:visible}.invisible{visibility:hidden}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.-inset-2{inset:-.5rem}.-inset-2\.5{inset:-.625rem}.inset-0{inset:0}.bottom-0{bottom:0}.bottom-20{bottom:5rem}.left-0{left:0}.right-0{right:0}.start-1{inset-inline-start:.25rem}.top-0{top:0}.top-5{top:1.25rem}.z-10{z-index:10}.z-30{z-index:30}.z-50{z-index:50}.m-0{margin:0}.m-1{margin:.25rem}.m-\[-4\.5px\]{margin:-4.5px}.mx-auto{margin-left:auto;margin-right:auto}.my-0{margin-top:0;margin-bottom:0}.my-1{margin-top:.25rem;margin-bottom:.25rem}.my-12{margin-top:3rem;margin-bottom:3rem}.my-16{margin-top:4rem;margin-bottom:4rem}.my-3{margin-top:.75rem;margin-bottom:.75rem}.-ml-3{margin-left:-.75rem}.-ml-3\.5{margin-left:-.875rem}.mb-10{margin-bottom:2.5rem}.mb-2{margin-bottom:.5rem}.mb-4{margin-bottom:1rem}.ml-1{margin-left:.25rem}.ml-1\.5{margin-left:.375rem}.ml-12{margin-left:3rem}.ml-2{margin-left:.5rem}.ml-\[15px\]{margin-left:15px}.ml-\[3px\]{margin-left:3px}.ml-\[60px\]{margin-left:60px}.mr-2{margin-right:.5rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-10{margin-top:2.5rem}.mt-12{margin-top:3rem}.mt-2{margin-top:.5rem}.mt-20{margin-top:5rem}.mt-32{margin-top:8rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-8{margin-top:2rem}.mt-\[-15px\]{margin-top:-15px}.mt-\[7px\]{margin-top:7px}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.\!table{display:table!important}.table{display:table}.table-cell{display:table-cell}.grid{display:grid}.contents{display:contents}.hidden{display:none}.aspect-square{aspect-ratio:1/1}.h-1{height:.25rem}.h-10{height:2.5rem}.h-12{height:3rem}.h-16{height:4rem}.h-20{height:5rem}.h-3{height:.75rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-80{height:20rem}.h-\[calc\(var\(--topnav-h\)_-_1px\)\]{height:calc(var(--topnav-h) - 1px)}.h-\[var\(--topnav-h\)\]{height:var(--topnav-h)}.h-fit{height:-moz-fit-content;height:fit-content}.h-full{height:100%}.h-px{height:1px}.max-h-80{max-height:20rem}.max-h-96{max-height:24rem}.max-h-screen{max-height:100vh}.min-h-\[100px\]{min-height:100px}.min-h-\[200px\]{min-height:200px}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-11{width:2.75rem}.w-20{width:5rem}.w-3{width:.75rem}.w-4{width:1rem}.w-52{width:13rem}.w-6{width:1.5rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-9{width:2.25rem}.w-\[120px\]{width:120px}.w-\[500px\]{width:500px}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.w-min{width:-moz-min-content;width:min-content}.min-w-\[102px\]{min-width:102px}.min-w-\[400px\]{min-width:400px}.min-w-\[500px\]{min-width:500px}.min-w-\[600px\]{min-width:600px}.max-w-2xl{max-width:42rem}.max-w-3xl{max-width:48rem}.max-w-4xl{max-width:56rem}.max-w-5xl{max-width:64rem}.max-w-\[400px\]{max-width:400px}.max-w-\[6\.5rem\]{max-width:6.5rem}.max-w-md{max-width:28rem}.max-w-screen-lg{max-width:1024px}.max-w-screen-xl{max-width:1280px}.max-w-xl{max-width:36rem}.max-w-xs{max-width:20rem}.flex-1{flex:1 1 0%}.flex-auto{flex:1 1 auto}.flex-none{flex:none}.flex-shrink{flex-shrink:1}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.flex-grow,.grow{flex-grow:1}.border-collapse{border-collapse:collapse}.rotate-0{--tw-rotate:0deg}.rotate-0,.rotate-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-1{--tw-rotate:1deg}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize{resize:both}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-stretch{align-items:stretch}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-4{gap:1rem}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-x-8{-moz-column-gap:2rem;column-gap:2rem}.gap-y-10{row-gap:2.5rem}.gap-y-3{row-gap:.75rem}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem*var(--tw-space-y-reverse))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px*var(--tw-divide-y-reverse))}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.overflow-x-hidden{overflow-x:hidden}.truncate{overflow:hidden;text-overflow:ellipsis}.truncate,.whitespace-nowrap{white-space:nowrap}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-none{border-radius:0}.rounded-xl{border-radius:.75rem}.rounded-b-md{border-bottom-right-radius:.375rem;border-bottom-left-radius:.375rem}.rounded-e-lg{border-start-end-radius:.5rem;border-end-end-radius:.5rem}.rounded-e-none{border-start-end-radius:0;border-end-end-radius:0}.rounded-s-lg{border-start-start-radius:.5rem;border-end-start-radius:.5rem}.rounded-s-none{border-start-start-radius:0;border-end-start-radius:0}.\!border-0{border-width:0!important}.border{border-width:1px}.border-x{border-left-width:1px;border-right-width:1px}.border-b{border-bottom-width:1px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-solid{border-style:solid}.border-\[var\(--color-accent\)\]{border-color:var(--color-accent)}.border-black{--tw-border-opacity:1;border-color:rgb(0 0 0/var(--tw-border-opacity))}.border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity))}.border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity))}.border-slate-200{--tw-border-opacity:1;border-color:rgb(226 232 240/var(--tw-border-opacity))}.border-b-\[var\(--color-accent\)\]{border-bottom-color:var(--color-accent)}.border-b-gray-200{--tw-border-opacity:1;border-bottom-color:rgb(229 231 235/var(--tw-border-opacity))}.border-t-gray-200{--tw-border-opacity:1;border-top-color:rgb(229 231 235/var(--tw-border-opacity))}.bg-\[\#1f4963\]{--tw-bg-opacity:1;background-color:rgb(31 73 99/var(--tw-bg-opacity))}.bg-\[\#e1cdab\]\/90{background-color:#e1cdabe6}.bg-\[var\(--color-background-secondary\)\]{background-color:var(--color-background-secondary)}.bg-black\/10{background-color:#0000001a}.bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}.bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity))}.bg-gray-900\/90{background-color:#111827e6}.bg-inherit{background-color:inherit}.bg-nwoods-primary{--tw-bg-opacity:1;background-color:rgb(31 73 99/var(--tw-bg-opacity))}.bg-nwoods-secondary{--tw-bg-opacity:1;background-color:rgb(98 127 145/var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.bg-gradient-to-b{background-image:linear-gradient(to bottom,var(--tw-gradient-stops))}.bg-gradient-to-r{background-image:linear-gradient(to right,var(--tw-gradient-stops))}.from-transparent{--tw-gradient-from:#0000 var(--tw-gradient-from-position);--tw-gradient-to:#0000 var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.via-\[\#141e37\]\/90{--tw-gradient-to:#141e3700 var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),#141e37e6 var(--tw-gradient-via-position),var(--tw-gradient-to)}.via-\[whitesmoke\]\/90{--tw-gradient-to:#f5f5f500 var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),#f5f5f5e6 var(--tw-gradient-via-position),var(--tw-gradient-to)}.via-gray-300{--tw-gradient-to:#d1d5db00 var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),#d1d5db var(--tw-gradient-via-position),var(--tw-gradient-to)}.via-slate-50\/90{--tw-gradient-to:#f8fafc00 var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),#f8fafce6 var(--tw-gradient-via-position),var(--tw-gradient-to)}.via-white\/90{--tw-gradient-to:#fff0 var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),#ffffffe6 var(--tw-gradient-via-position),var(--tw-gradient-to)}.to-transparent{--tw-gradient-to:#0000 var(--tw-gradient-to-position)}.object-cover{-o-object-fit:cover;object-fit:cover}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-4{padding:1rem}.px-0{padding-left:0;padding-right:0}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-8{padding-left:2rem;padding-right:2rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-16{padding-bottom:4rem}.pb-24{padding-bottom:6rem}.pl-12{padding-left:3rem}.pl-16{padding-left:4rem}.pl-2{padding-left:.5rem}.pl-\[12px\]{padding-left:12px}.pl-\[2px\]{padding-left:2px}.pl-\[35px\]{padding-left:35px}.pl-\[6px\]{padding-left:6px}.pl-\[7px\]{padding-left:7px}.pr-\[11px\]{padding-right:11px}.pr-\[125px\]{padding-right:125px}.pr-\[12px\]{padding-right:12px}.pr-\[2px\]{padding-right:2px}.pr-\[7px\]{padding-right:7px}.pt-2{padding-top:.5rem}.pt-4{padding-top:1rem}.text-center{text-align:center}.align-middle{vertical-align:middle}.text-2xl{font-size:1.5rem;line-height:2rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-6xl{font-size:3.75rem;line-height:1}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.lowercase{text-transform:lowercase}.italic{font-style:italic}.\!leading-\[calc\(var\(--topnav-h\)_-_1px\)\]{line-height:calc(var(--topnav-h) - 1px)!important}.leading-6{line-height:1.5rem}.leading-7{line-height:1.75rem}.leading-8{line-height:2rem}.text-\[var\(--color-text\)\]{color:var(--color-text)}.text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity))}.text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity))}.text-nwoods-accent{--tw-text-opacity:1;color:rgb(8 145 178/var(--tw-text-opacity))}.text-nwoods-primary{--tw-text-opacity:1;color:rgb(31 73 99/var(--tw-text-opacity))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.underline{text-decoration-line:underline}.line-through{text-decoration-line:line-through}.accent-nwoods-accent{accent-color:#0891b2}.opacity-0{opacity:0}.shadow{--tw-shadow:0 1px 3px 0 #0000001a,0 1px 2px -1px #0000001a;--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.shadow,.shadow-none{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000}.shadow-sm{--tw-shadow:0 1px 2px 0 #0000000d;--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.outline-none{outline:2px solid #0000;outline-offset:2px}.outline{outline-style:solid}.ring{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color)}.ring,.ring-1{box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.ring-1{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color)}.ring-gray-900\/10{--tw-ring-color:#1118271a}.ring-white\/20{--tw-ring-color:#fff3}.blur{--tw-blur:blur(8px)}.blur,.drop-shadow{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.drop-shadow{--tw-drop-shadow:drop-shadow(0 1px 2px #0000001a) drop-shadow(0 1px 1px #0000000f)}.grayscale{--tw-grayscale:grayscale(100%)}.grayscale,.invert{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.invert{--tw-invert:invert(100%)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.marker\:\[font-size\:0px\] ::marker{font-size:0}.marker\:\[font-size\:0px\]::marker{font-size:0}.before\:absolute:before{content:var(--tw-content);position:absolute}.before\:-inset-2:before{content:var(--tw-content);inset:-.5rem}.before\:-inset-2\.5:before{content:var(--tw-content);inset:-.625rem}.before\:rounded-lg:before{content:var(--tw-content);border-radius:.5rem}.before\:bg-gray-50:before{content:var(--tw-content);--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity))}.before\:opacity-0:before{content:var(--tw-content);opacity:0}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:start-\[2px\]:after{content:var(--tw-content);inset-inline-start:2px}.after\:top-\[2px\]:after{content:var(--tw-content);top:2px}.after\:h-4:after{content:var(--tw-content);height:1rem}.after\:w-4:after{content:var(--tw-content);width:1rem}.after\:rounded-full:after{content:var(--tw-content);border-radius:9999px}.after\:border:after{content:var(--tw-content);border-width:1px}.after\:border-gray-300:after{content:var(--tw-content);--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity))}.after\:bg-white:after{content:var(--tw-content);--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.after\:transition-all:after{content:var(--tw-content);transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.after\:content-\[\'\'\]:after{--tw-content:"";content:var(--tw-content)}.hover\:\!bg-inherit:hover{background-color:inherit!important}.hover\:bg-black\/20:hover{background-color:#0003}.hover\:bg-gray-200:hover{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}.hover\:bg-white\/95:hover{background-color:#fffffff2}.hover\:\!text-nwoods-accent:hover{--tw-text-opacity:1!important;color:rgb(8 145 178/var(--tw-text-opacity))!important}.hover\:text-nwoods-accent:hover{--tw-text-opacity:1;color:rgb(8 145 178/var(--tw-text-opacity))}.hover\:text-nwoods-accentHover:hover{--tw-text-opacity:1;color:rgb(21 94 117/var(--tw-text-opacity))}.hover\:no-underline:hover{text-decoration-line:none}.hover\:\!shadow-none:hover{--tw-shadow:0 0 #0000!important;--tw-shadow-colored:0 0 #0000!important;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)!important}.hover\:ring-white\/30:hover{--tw-ring-color:#ffffff4d}.hover\:drop-shadow-md:hover{--tw-drop-shadow:drop-shadow(0 4px 3px #00000012) drop-shadow(0 2px 2px #0000000f);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.hover\:before\:opacity-100:hover:before{content:var(--tw-content);opacity:1}.focus\:border-blue-500:focus{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity))}.focus\:outline-none:focus{outline:2px solid #0000;outline-offset:2px}.focus\:ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\:ring-blue-500:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity))}.focus\:ring-gray-100:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(243 244 246/var(--tw-ring-opacity))}.group[open] .group-open\:rotate-180{--tw-rotate:180deg}.group:hover .group-hover\:-translate-y-1\/4,.group[open] .group-open\:rotate-180{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:-translate-y-1\/4{--tw-translate-y:-25%}.group:hover .group-hover\:-translate-y-8{--tw-translate-y:-2rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:text-nwoods-accent{--tw-text-opacity:1;color:rgb(8 145 178/var(--tw-text-opacity))}.group:hover .group-hover\:opacity-100{opacity:1}.peer:checked~.peer-checked\:bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity))}.peer:checked~.peer-checked\:after\:translate-x-full:after{content:var(--tw-content);--tw-translate-x:100%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.peer:checked~.peer-checked\:after\:border-white:after{content:var(--tw-content);--tw-border-opacity:1;border-color:rgb(255 255 255/var(--tw-border-opacity))}.peer:focus~.peer-focus\:outline-none{outline:2px solid #0000;outline-offset:2px}.peer:focus~.peer-focus\:ring-0{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.peer:focus~.peer-focus\:ring-blue-300{--tw-ring-opacity:1;--tw-ring-color:rgb(147 197 253/var(--tw-ring-opacity))}@media (min-width:640px){.sm\:max-w-none{max-width:none}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:text-4xl{font-size:2.25rem;line-height:2.5rem}}@media (min-width:768px){.md\:sticky{position:sticky}.md\:mb-6{margin-bottom:1.5rem}.md\:block{display:block}.md\:hidden{display:none}.md\:min-h-0{min-height:0}.md\:min-h-screen{min-height:100vh}.md\:w-52{width:13rem}.md\:w-full{width:100%}.md\:max-w-none{max-width:none}.md\:max-w-screen-md{max-width:768px}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:flex-row{flex-direction:row}.md\:items-start{align-items:flex-start}.md\:space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(1rem*var(--tw-space-x-reverse));margin-left:calc(1rem*(1 - var(--tw-space-x-reverse)))}.md\:space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem*var(--tw-space-y-reverse))}.md\:overscroll-auto{overscroll-behavior:auto}.md\:border-0{border-width:0}.md\:border-r{border-right-width:1px}.md\:border-r-gray-200{--tw-border-opacity:1;border-right-color:rgb(229 231 235/var(--tw-border-opacity))}.md\:\!bg-inherit{background-color:inherit!important}.md\:bg-inherit{background-color:inherit}.md\:p-0{padding:0}.md\:p-8{padding:2rem}.md\:shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}}@media (min-width:1024px){.lg\:order-first{order:-9999}.lg\:col-span-2{grid-column:span 2/span 2}.lg\:mx-8{margin-left:2rem;margin-right:2rem}.lg\:ml-0{margin-left:0}.lg\:mt-20{margin-top:5rem}.lg\:block{display:block}.lg\:max-h-full{max-height:100%}.lg\:min-h-\[520px\]{min-height:520px}.lg\:max-w-2xl{max-width:42rem}.lg\:max-w-screen-xl{max-width:1280px}.lg\:max-w-xl{max-width:36rem}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:flex-row{flex-direction:row}.lg\:items-start{align-items:flex-start}.lg\:p-6{padding:1.5rem}.lg\:px-0{padding-left:0;padding-right:0}.lg\:px-8{padding-left:2rem;padding-right:2rem}.lg\:text-left{text-align:left}.lg\:text-center{text-align:center}.lg\:text-5xl{font-size:3rem;line-height:1}.lg\:text-6xl{font-size:3.75rem;line-height:1}}@media (min-width:1280px){.xl\:gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}}:is(:where([dir=rtl]) .peer:checked~.rtl\:peer-checked\:after\:-translate-x-full):after{content:var(--tw-content);--tw-translate-x:-100%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@media (prefers-color-scheme:dark){.dark\:border-gray-600{--tw-border-opacity:1;border-color:rgb(75 85 99/var(--tw-border-opacity))}.dark\:bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity))}.peer:focus~.dark\:peer-focus\:ring-blue-800{--tw-ring-opacity:1;--tw-ring-color:rgb(30 64 175/var(--tw-ring-opacity))}} \ No newline at end of file +/*! tailwindcss v3.4.0 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:InterVariable,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:initial;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:initial}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}:root{--topnav-h:72px}*{scrollbar-width:thin}.logo{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif}.box{margin:1rem;padding:1rem}.bg-danger{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity))}.bg-info{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity))}.diagramStyling{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}h1{font-size:1.875rem;line-height:2.25rem}h1,h2{margin-top:.75rem;margin-bottom:.75rem;font-weight:700;letter-spacing:-.025em}h2{font-size:1.5rem;line-height:2rem}h3{font-size:1.25rem}h3,h4{margin-top:.75rem;margin-bottom:.75rem;line-height:1.75rem;font-weight:600}h4{font-size:1.125rem}.prose a{border-bottom-width:1px;--tw-border-opacity:1;border-bottom-color:rgb(8 145 178/var(--tw-border-opacity));font-weight:600;text-decoration-line:none}.prose a:hover{border-bottom-width:2px}footer a:hover{--tw-text-opacity:1;color:rgb(8 145 178/var(--tw-text-opacity))}ol,p,ul{margin-bottom:.75rem}ol,ul{list-style-position:inside;list-style-type:disc;padding-left:1rem;padding-right:1rem}input,textarea{border-radius:.125rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(75 85 99/var(--tw-border-opacity))}textarea{padding:.5rem}select{border-radius:.125rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(75 85 99/var(--tw-border-opacity));padding:.25rem}pre{background:#272822;padding:1em;margin:.5em 0;overflow:auto;border-radius:.3em;color:#fff}code[class*=lang],pre[class*=lang],pre[class*=lang] code{background:#272822;color:#d4d4d4;font-size:13px;text-shadow:none;font-family:Menlo,Monaco,Consolas,Andale Mono,Ubuntu Mono,Courier New,monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;hyphens:none}code{border-radius:.125rem;--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}canvas:focus,pre code:focus-visible,pre div:focus-visible{outline:2px solid #0000;outline-offset:2px}.\!button,.button,[type=button],button{margin:.25rem;display:inline-block;border-radius:.25rem;--tw-bg-opacity:1;background-color:rgb(31 73 99/var(--tw-bg-opacity));padding:.25rem .5rem;--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity));--tw-shadow:0 1px 2px 0 #0000000d;--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.\!button:disabled,.button:disabled,[type=button]:disabled,button:disabled{opacity:.5}.\!button:hover:not(:disabled),.button:hover:not(:disabled),button:hover:not(:disabled){--tw-bg-opacity:1;background-color:rgb(98 127 145/var(--tw-bg-opacity));--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity));--tw-shadow:0 1px 2px 0 #0000000d;--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.bigger{margin-top:.5rem;margin-bottom:.5rem;padding:1rem;font-weight:700}#topnavList a{padding-left:.5rem;padding-right:.5rem;line-height:calc(var(--topnav-h) - 1px)}#topnavList a:hover{--tw-text-opacity:1;color:rgb(8 145 178/var(--tw-text-opacity))}@media (min-width:1024px){#topnavList a{padding-left:1rem;padding-right:1rem}}#topnavList a.active{height:var(--topnav-h);border-bottom-width:2px;--tw-border-opacity:1;border-bottom-color:rgb(8 145 178/var(--tw-border-opacity))}.samples-sidebar-nav>a,aside>nav>a{display:block;padding:.25rem .5rem;font-size:.875rem;line-height:1.25rem;font-weight:600;--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity))}.samples-sidebar-nav>a:hover,aside>nav>a:hover{--tw-text-opacity:1;color:rgb(8 145 178/var(--tw-text-opacity))}aside>nav>a.active{border-right-width:2px;--tw-border-opacity:1;border-right-color:rgb(8 145 178/var(--tw-border-opacity))}@font-face{font-family:InterVariable;font-style:normal;font-weight:100 900;font-display:swap;src:url(https://rsms.me/inter/font-files/InterVariable.woff2?v=4.0) format("woff2")}*,::backdrop,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.visible{visibility:visible}.invisible{visibility:hidden}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.-inset-2{inset:-.5rem}.-inset-2\.5{inset:-.625rem}.inset-0{inset:0}.bottom-0{bottom:0}.bottom-20{bottom:5rem}.left-0{left:0}.right-0{right:0}.start-1{inset-inline-start:.25rem}.top-0{top:0}.top-5{top:1.25rem}.z-10{z-index:10}.z-30{z-index:30}.z-50{z-index:50}.m-0{margin:0}.m-1{margin:.25rem}.m-\[-4\.5px\]{margin:-4.5px}.mx-auto{margin-left:auto;margin-right:auto}.my-0{margin-top:0;margin-bottom:0}.my-1{margin-top:.25rem;margin-bottom:.25rem}.my-10{margin-top:2.5rem;margin-bottom:2.5rem}.my-12{margin-top:3rem;margin-bottom:3rem}.my-3{margin-top:.75rem;margin-bottom:.75rem}.-ml-3{margin-left:-.75rem}.-ml-3\.5{margin-left:-.875rem}.mb-10{margin-bottom:2.5rem}.mb-2{margin-bottom:.5rem}.mb-4{margin-bottom:1rem}.ml-1{margin-left:.25rem}.ml-1\.5{margin-left:.375rem}.ml-12{margin-left:3rem}.ml-2{margin-left:.5rem}.ml-\[15px\]{margin-left:15px}.ml-\[3px\]{margin-left:3px}.ml-\[60px\]{margin-left:60px}.mr-2{margin-right:.5rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-10{margin-top:2.5rem}.mt-12{margin-top:3rem}.mt-2{margin-top:.5rem}.mt-20{margin-top:5rem}.mt-32{margin-top:8rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-8{margin-top:2rem}.mt-\[-15px\]{margin-top:-15px}.mt-\[7px\]{margin-top:7px}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.\!table{display:table!important}.table{display:table}.table-cell{display:table-cell}.grid{display:grid}.contents{display:contents}.hidden{display:none}.aspect-square{aspect-ratio:1/1}.h-1{height:.25rem}.h-10{height:2.5rem}.h-12{height:3rem}.h-16{height:4rem}.h-20{height:5rem}.h-3{height:.75rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-80{height:20rem}.h-\[calc\(var\(--topnav-h\)_-_1px\)\]{height:calc(var(--topnav-h) - 1px)}.h-\[var\(--topnav-h\)\]{height:var(--topnav-h)}.h-fit{height:-moz-fit-content;height:fit-content}.h-full{height:100%}.h-px{height:1px}.max-h-80{max-height:20rem}.max-h-96{max-height:24rem}.max-h-screen{max-height:100vh}.min-h-\[100px\]{min-height:100px}.min-h-\[200px\]{min-height:200px}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-11{width:2.75rem}.w-20{width:5rem}.w-3{width:.75rem}.w-4{width:1rem}.w-52{width:13rem}.w-6{width:1.5rem}.w-64{width:16rem}.w-7{width:1.75rem}.w-9{width:2.25rem}.w-\[120px\]{width:120px}.w-\[500px\]{width:500px}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.w-min{width:-moz-min-content;width:min-content}.min-w-\[102px\]{min-width:102px}.min-w-\[400px\]{min-width:400px}.min-w-\[500px\]{min-width:500px}.min-w-\[600px\]{min-width:600px}.max-w-2xl{max-width:42rem}.max-w-3xl{max-width:48rem}.max-w-4xl{max-width:56rem}.max-w-5xl{max-width:64rem}.max-w-\[400px\]{max-width:400px}.max-w-\[6\.5rem\]{max-width:6.5rem}.max-w-md{max-width:28rem}.max-w-screen-lg{max-width:1024px}.max-w-screen-xl{max-width:1280px}.max-w-xl{max-width:36rem}.max-w-xs{max-width:20rem}.flex-1{flex:1 1 0%}.flex-auto{flex:1 1 auto}.flex-none{flex:none}.flex-shrink{flex-shrink:1}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.flex-grow,.grow{flex-grow:1}.border-collapse{border-collapse:collapse}.rotate-0{--tw-rotate:0deg}.rotate-0,.rotate-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-1{--tw-rotate:1deg}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize{resize:both}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-stretch{align-items:stretch}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-4{gap:1rem}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-x-8{-moz-column-gap:2rem;column-gap:2rem}.gap-y-10{row-gap:2.5rem}.gap-y-3{row-gap:.75rem}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem*var(--tw-space-y-reverse))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px*var(--tw-divide-y-reverse))}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.overflow-x-hidden{overflow-x:hidden}.truncate{overflow:hidden;text-overflow:ellipsis}.truncate,.whitespace-nowrap{white-space:nowrap}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-none{border-radius:0}.rounded-xl{border-radius:.75rem}.rounded-b-md{border-bottom-right-radius:.375rem;border-bottom-left-radius:.375rem}.rounded-e-lg{border-start-end-radius:.5rem;border-end-end-radius:.5rem}.rounded-e-none{border-start-end-radius:0;border-end-end-radius:0}.rounded-s-lg{border-start-start-radius:.5rem;border-end-start-radius:.5rem}.rounded-s-none{border-start-start-radius:0;border-end-start-radius:0}.\!border-0{border-width:0!important}.border{border-width:1px}.border-x{border-left-width:1px;border-right-width:1px}.border-b{border-bottom-width:1px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-solid{border-style:solid}.border-\[var\(--color-accent\)\]{border-color:var(--color-accent)}.border-black{--tw-border-opacity:1;border-color:rgb(0 0 0/var(--tw-border-opacity))}.border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity))}.border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity))}.border-slate-200{--tw-border-opacity:1;border-color:rgb(226 232 240/var(--tw-border-opacity))}.border-b-\[var\(--color-accent\)\]{border-bottom-color:var(--color-accent)}.border-b-gray-200{--tw-border-opacity:1;border-bottom-color:rgb(229 231 235/var(--tw-border-opacity))}.border-t-gray-200{--tw-border-opacity:1;border-top-color:rgb(229 231 235/var(--tw-border-opacity))}.bg-\[\#1f4963\]{--tw-bg-opacity:1;background-color:rgb(31 73 99/var(--tw-bg-opacity))}.bg-\[\#e1cdab\]{--tw-bg-opacity:1;background-color:rgb(225 205 171/var(--tw-bg-opacity))}.bg-\[var\(--color-background-secondary\)\]{background-color:var(--color-background-secondary)}.bg-black\/10{background-color:#0000001a}.bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}.bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity))}.bg-gray-900\/90{background-color:#111827e6}.bg-inherit{background-color:inherit}.bg-nwoods-primary{--tw-bg-opacity:1;background-color:rgb(31 73 99/var(--tw-bg-opacity))}.bg-nwoods-secondary{--tw-bg-opacity:1;background-color:rgb(98 127 145/var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.bg-gradient-to-b{background-image:linear-gradient(to bottom,var(--tw-gradient-stops))}.bg-gradient-to-r{background-image:linear-gradient(to right,var(--tw-gradient-stops))}.from-transparent{--tw-gradient-from:#0000 var(--tw-gradient-from-position);--tw-gradient-to:#0000 var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.via-\[\#141e37\]\/90{--tw-gradient-to:#141e3700 var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),#141e37e6 var(--tw-gradient-via-position),var(--tw-gradient-to)}.via-\[whitesmoke\]\/90{--tw-gradient-to:#f5f5f500 var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),#f5f5f5e6 var(--tw-gradient-via-position),var(--tw-gradient-to)}.via-gray-300{--tw-gradient-to:#d1d5db00 var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),#d1d5db var(--tw-gradient-via-position),var(--tw-gradient-to)}.via-slate-50\/90{--tw-gradient-to:#f8fafc00 var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),#f8fafce6 var(--tw-gradient-via-position),var(--tw-gradient-to)}.via-white\/90{--tw-gradient-to:#fff0 var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),#ffffffe6 var(--tw-gradient-via-position),var(--tw-gradient-to)}.to-transparent{--tw-gradient-to:#0000 var(--tw-gradient-to-position)}.object-cover{-o-object-fit:cover;object-fit:cover}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-4{padding:1rem}.px-0{padding-left:0;padding-right:0}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-8{padding-left:2rem;padding-right:2rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-16{padding-bottom:4rem}.pb-24{padding-bottom:6rem}.pl-12{padding-left:3rem}.pl-16{padding-left:4rem}.pl-2{padding-left:.5rem}.pl-\[12px\]{padding-left:12px}.pl-\[2px\]{padding-left:2px}.pl-\[35px\]{padding-left:35px}.pl-\[6px\]{padding-left:6px}.pl-\[7px\]{padding-left:7px}.pr-\[11px\]{padding-right:11px}.pr-\[125px\]{padding-right:125px}.pr-\[12px\]{padding-right:12px}.pr-\[2px\]{padding-right:2px}.pr-\[7px\]{padding-right:7px}.pt-2{padding-top:.5rem}.pt-4{padding-top:1rem}.text-center{text-align:center}.align-middle{vertical-align:middle}.text-2xl{font-size:1.5rem;line-height:2rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-6xl{font-size:3.75rem;line-height:1}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.lowercase{text-transform:lowercase}.italic{font-style:italic}.\!leading-\[calc\(var\(--topnav-h\)_-_1px\)\]{line-height:calc(var(--topnav-h) - 1px)!important}.leading-6{line-height:1.5rem}.leading-7{line-height:1.75rem}.leading-8{line-height:2rem}.text-\[var\(--color-text\)\]{color:var(--color-text)}.text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity))}.text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity))}.text-nwoods-accent{--tw-text-opacity:1;color:rgb(8 145 178/var(--tw-text-opacity))}.text-nwoods-primary{--tw-text-opacity:1;color:rgb(31 73 99/var(--tw-text-opacity))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.underline{text-decoration-line:underline}.line-through{text-decoration-line:line-through}.accent-nwoods-accent{accent-color:#0891b2}.opacity-90{opacity:.9}.shadow{--tw-shadow:0 1px 3px 0 #0000001a,0 1px 2px -1px #0000001a;--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.shadow,.shadow-none{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000}.shadow-sm{--tw-shadow:0 1px 2px 0 #0000000d;--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.outline-none{outline:2px solid #0000;outline-offset:2px}.outline{outline-style:solid}.ring{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color)}.ring,.ring-1{box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.ring-1{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color)}.ring-gray-900\/10{--tw-ring-color:#1118271a}.ring-white\/20{--tw-ring-color:#fff3}.blur{--tw-blur:blur(8px)}.blur,.drop-shadow{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.drop-shadow{--tw-drop-shadow:drop-shadow(0 1px 2px #0000001a) drop-shadow(0 1px 1px #0000000f)}.grayscale{--tw-grayscale:grayscale(100%)}.grayscale,.invert{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.invert{--tw-invert:invert(100%)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.marker\:\[font-size\:0px\] ::marker{font-size:0}.marker\:\[font-size\:0px\]::marker{font-size:0}.before\:absolute:before{content:var(--tw-content);position:absolute}.before\:-inset-2:before{content:var(--tw-content);inset:-.5rem}.before\:-inset-2\.5:before{content:var(--tw-content);inset:-.625rem}.before\:rounded-lg:before{content:var(--tw-content);border-radius:.5rem}.before\:bg-gray-50:before{content:var(--tw-content);--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity))}.before\:opacity-0:before{content:var(--tw-content);opacity:0}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:start-\[2px\]:after{content:var(--tw-content);inset-inline-start:2px}.after\:top-\[2px\]:after{content:var(--tw-content);top:2px}.after\:h-4:after{content:var(--tw-content);height:1rem}.after\:w-4:after{content:var(--tw-content);width:1rem}.after\:rounded-full:after{content:var(--tw-content);border-radius:9999px}.after\:border:after{content:var(--tw-content);border-width:1px}.after\:border-gray-300:after{content:var(--tw-content);--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity))}.after\:bg-white:after{content:var(--tw-content);--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.after\:transition-all:after{content:var(--tw-content);transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.after\:content-\[\'\'\]:after{--tw-content:"";content:var(--tw-content)}.hover\:\!bg-inherit:hover{background-color:inherit!important}.hover\:bg-black\/20:hover{background-color:#0003}.hover\:bg-gray-200:hover{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}.hover\:bg-white\/95:hover{background-color:#fffffff2}.hover\:\!text-nwoods-accent:hover{--tw-text-opacity:1!important;color:rgb(8 145 178/var(--tw-text-opacity))!important}.hover\:text-nwoods-accent:hover{--tw-text-opacity:1;color:rgb(8 145 178/var(--tw-text-opacity))}.hover\:text-nwoods-accentHover:hover{--tw-text-opacity:1;color:rgb(21 94 117/var(--tw-text-opacity))}.hover\:no-underline:hover{text-decoration-line:none}.hover\:\!shadow-none:hover{--tw-shadow:0 0 #0000!important;--tw-shadow-colored:0 0 #0000!important;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)!important}.hover\:ring-white\/30:hover{--tw-ring-color:#ffffff4d}.hover\:drop-shadow-md:hover{--tw-drop-shadow:drop-shadow(0 4px 3px #00000012) drop-shadow(0 2px 2px #0000000f);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.hover\:before\:opacity-100:hover:before{content:var(--tw-content);opacity:1}.focus\:border-blue-500:focus{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity))}.focus\:outline-none:focus{outline:2px solid #0000;outline-offset:2px}.focus\:ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\:ring-blue-500:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity))}.focus\:ring-gray-100:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(243 244 246/var(--tw-ring-opacity))}.group[open] .group-open\:rotate-180{--tw-rotate:180deg}.group:hover .group-hover\:-translate-y-1\/4,.group[open] .group-open\:rotate-180{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:-translate-y-1\/4{--tw-translate-y:-25%}.group:hover .group-hover\:-translate-y-8{--tw-translate-y:-2rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\:text-nwoods-accent{--tw-text-opacity:1;color:rgb(8 145 178/var(--tw-text-opacity))}.group:hover .group-hover\:opacity-100{opacity:1}.peer:checked~.peer-checked\:bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity))}.peer:checked~.peer-checked\:after\:translate-x-full:after{content:var(--tw-content);--tw-translate-x:100%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.peer:checked~.peer-checked\:after\:border-white:after{content:var(--tw-content);--tw-border-opacity:1;border-color:rgb(255 255 255/var(--tw-border-opacity))}.peer:focus~.peer-focus\:outline-none{outline:2px solid #0000;outline-offset:2px}.peer:focus~.peer-focus\:ring-0{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.peer:focus~.peer-focus\:ring-blue-300{--tw-ring-opacity:1;--tw-ring-color:rgb(147 197 253/var(--tw-ring-opacity))}@media (min-width:640px){.sm\:max-w-none{max-width:none}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:text-4xl{font-size:2.25rem;line-height:2.5rem}}@media (min-width:768px){.md\:sticky{position:sticky}.md\:mb-6{margin-bottom:1.5rem}.md\:block{display:block}.md\:hidden{display:none}.md\:min-h-0{min-height:0}.md\:min-h-screen{min-height:100vh}.md\:w-52{width:13rem}.md\:w-full{width:100%}.md\:max-w-none{max-width:none}.md\:max-w-screen-md{max-width:768px}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:flex-row{flex-direction:row}.md\:items-start{align-items:flex-start}.md\:space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(1rem*var(--tw-space-x-reverse));margin-left:calc(1rem*(1 - var(--tw-space-x-reverse)))}.md\:space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.25rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem*var(--tw-space-y-reverse))}.md\:overscroll-auto{overscroll-behavior:auto}.md\:border-0{border-width:0}.md\:border-r{border-right-width:1px}.md\:border-r-gray-200{--tw-border-opacity:1;border-right-color:rgb(229 231 235/var(--tw-border-opacity))}.md\:\!bg-inherit{background-color:inherit!important}.md\:bg-inherit{background-color:inherit}.md\:p-0{padding:0}.md\:p-8{padding:2rem}.md\:shadow-none{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}}@media (min-width:1024px){.lg\:order-first{order:-9999}.lg\:col-span-2{grid-column:span 2/span 2}.lg\:mx-8{margin-left:2rem;margin-right:2rem}.lg\:ml-0{margin-left:0}.lg\:mt-20{margin-top:5rem}.lg\:block{display:block}.lg\:max-h-full{max-height:100%}.lg\:min-h-\[520px\]{min-height:520px}.lg\:max-w-2xl{max-width:42rem}.lg\:max-w-screen-xl{max-width:1280px}.lg\:max-w-xl{max-width:36rem}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:flex-row{flex-direction:row}.lg\:items-start{align-items:flex-start}.lg\:p-6{padding:1.5rem}.lg\:px-0{padding-left:0;padding-right:0}.lg\:px-8{padding-left:2rem;padding-right:2rem}.lg\:text-left{text-align:left}.lg\:text-center{text-align:center}.lg\:text-5xl{font-size:3rem;line-height:1}.lg\:text-6xl{font-size:3.75rem;line-height:1}}@media (min-width:1280px){.xl\:gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}}:is(:where([dir=rtl]) .peer:checked~.rtl\:peer-checked\:after\:-translate-x-full):after{content:var(--tw-content);--tw-translate-x:-100%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@media (prefers-color-scheme:dark){.dark\:border-gray-600{--tw-border-opacity:1;border-color:rgb(75 85 99/var(--tw-border-opacity))}.dark\:bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity))}.peer:focus~.dark\:peer-focus\:ring-blue-800{--tw-ring-opacity:1;--tw-ring-color:rgb(30 64 175/var(--tw-ring-opacity))}} \ No newline at end of file diff --git a/assets/images/fp/flow.png b/assets/images/fp/flow.png new file mode 100644 index 0000000000000000000000000000000000000000..3874d7e797a91a08232f9711372caf190c741e8a GIT binary patch literal 80820 zcmeFZc{r5s`#(Hm-<4%72`T&7cabeh)?^rKGq#X@$ri>|+1g|)MJpkV>?A{ILkLNf zkUf-L;yI`7{r)`9_xt_*j^FVd$MetA95vI-J@(^PEI;(?iS*ybK5g zg4yu!K??+eQV@Zlh@_){cXWeeZow11-(j0T1cH&B{1=J1n!}Ai&|LMf#0FtajMbfe zy`}LkzD};vq27LQGyV zslYIwAbhBlPvG7^XE^8@=p5kT7v$mVBS=0Y-pMyONK*)g`s*IN{r;ZTC-C+AJrrOf{fSx{a{T24+-%-X}p#Wy5S{9oU2J%|r-)f6Hxo0P1Ql$^4q zoU*!tyt;y#l&qqQ;9STO{f)B#~FAsKcR(JCa z@W#U(dwAndxXSqXoDdTHJCEvmzFxioaA6po!p~8dn5Y~21P0-KoLvnMY6`(kOM7^@ zs4L35C^{*?c$H+8l%*8q6cwe^T-B7NTwPpT@Cq&pZt}{if4+av*EyKHwB+yqGIJMS zXE?_{S5;P0#VaVPDM`5~;Z>#7@QQdTRW~O$DLK57lY*?PtFnu-%Ad2D1$e+t!+ZVv ztmIL-z!~LL-Q-=tj-{NHoRy^1loj2i)ZE}2e;S24-kEIdnnKRxRd#g|`u(=Ye=#5bTUY-5{SbFoIO+ee_`j|m z=<5~~f)8-jIRSI`zqT%!|8Dew_*4J$*qxN!+?-YMYEp`LSp_M)nxe84UQtC(O3qC| z-dRaaR#{ca?a#gcd+dL$Q9)fv_K!9GAC3L@#5lX-eNMQ7^OO<#Kfjy*JVLk z{=K*UU%VR`vd{cwWHSGE`}_IXzx*pK<~&f!$BUJ!A9FNiC2EWkVn?;jFT13R3E5D!@HNsU-Qw0^qGO{vszc4G zuT6CjDOZATSDPRp-;_kGepq&F$UXLU>w+FHZgNk~;*!Ga&Lzv>V9fQ!zNt6)Gm)3# zH;)N!ufL9dvLKnO6}`1I^`>EK`Jv3?R|$+<=XdX4S@~kOb!~GZH~Prk7tueKxeCV{ zGLP<^*8j4p!t>Tf!o#OI_ zhocFGr7ya_xLUSHryW(A)_=NgeT|i0qx$rEz>tUh$>1)>l2seFZ-#WIFyn}fbI{FGTh~%%(CH$#>sbX3P(3la`vOaGq$o36 zH1Wjx%)^FG7qoU*$?AN=c56Y#ku)&eob>dTZG^Ll+l_rUsDFI_I(o=sIpDgdyyxky zO|^`3VB?-t*uCkFZdZ@FXblP7v5OB%zUZ^FTS_-^NGM)BQt)Dt^~3Rri4!g^&FO;I zRD3@OUR3=cyl2|k3sON_%M|}s;s;r@A~p(x@5?gf%M$mXc!bNEC1v0 z8l{ z3OhT&i*RWTuICCd8j%}IiQ2L~0`y}ywS5Mw{VfG)S@;ec8xNLyyn!$9@$va3aB_0` zH||n&M|_Zw@!E;|_XBf?R2%U5HssrkogbwffF6xF@v?iGu?NM z!otELR%WvgMApW}QY`vTO;5wrWf5y)fB|th?36hKEW1z2N8k(s4xp4yDYJ zBVTd;1WYZh5jRm{ws8cJyoi%)g(o@GQ?zWKNzCAm=U{s5Y;0cM-fG6{qgSw+;xC?|Ksr0rhcAOEoOpd>sM7oWaARDI zjk>zJP?kR7-w$CW65EO`^KSK}=0tWunvAL)8b^ELFt>S%oaC^4wis2KnfuxjJK|ap zM%)inYh&%7oL+}%KhcqcwB>9;Q~bwc3V}kG*Vk+66^%Z-5XaUpNrm0;74xCNPVP=> zlu)Kgb}nXkhVxGmW{Yc)%Yb=6X3#n7nC2c}E`L;7>d|$pW$Xnwg@4U2%=JeCH4B)U zCHyfrKbM-Cpm`>NWJ;tMS6zgq)0e}Jgc4zZ!uM#6_R%C$qR*E|Gf+uvz?opL&JEU- zRaUOFrtYHuk9e}i&i(ye*$EZT9`}ACUbdTnKp=L!}uF)3R%VG8B+2q@t2rb-_ z($XCR0~?vgqrR@Ji2Q383Xw+i`n?-V9O`IjXqx(;PRAjVmT^a!GI|!tYl68*59kyY??&x?)@mVBN6n0*X}!n@k}8H>KYeq`j2!9n}}P!=MBinxO#t|gkk z__7lb?2~g>TuT@+o<~w$eW1Ddpq<_R0|#y(lK=H6Ix^|`^bE7Syu7ruG%R?+Q7#&E zQe&Y`82S6KeH^ZHKL0xU4EzibPE;ku zj*X9lb<{_GU%|Bh^_=7_UBO4}zpm5CiI!|rpe&Zx#KMdR!o-g?s!Lr=Nnv7TWwo(+ zCsA*G_+RslxrR)>UF7lRUZe8U!%q=cMjCHvU@P{rS{-e5BH!GsBR*aJKX&&6YV_nF z%sDf2>dw6eB<`oO3alBba@Z@hMX0exiRngl;fvtA@7=kBwXwnMcK)~1>$N4Rhc4vZ zyC*Wq;KnVI9Yz$RnK5#JIVq-1mg~Er8F7YXx4L_$AfMU4#;8va&L9moot~bYymR+% zBMoB&e67gzb0b?~qf-#I+UYgF!-vlm78Vv2N&d$STD@!H-*qK3^LUvXv++YBZ4t%4 zh8a6HF+odB9aFk*%Y4tjzGmf3i7ptpc=4ju16z~p>YVHuNUJbsq8O{ymsfGZd~ww4 z%WsdH<)~h|e*MdrFH(|{ySTUx{l{oAw}_pRKtf<`u=aS;E$(6q4Q%ip)(j%;jCBm5 z^m1C7Fh3XzCLein7d<__;e)hu=jiP0?7Y3d4Aq5jQG=OoSWGP9=p%^SIIs-&<>}t~ zh*f13m3*Fq7Gd|T1?d}?Nc$Q$#fPnB9gZrEdm`rpHrKx9+!j&L6no$Z z0sg3Xp__DSA*w$P04R)lXDekUZy$wQ9AHc3#-6WlTrN4fRa#k4`+Rt8}5C`%leYe6D)1sLP-{dAlaXC^cC;y(Z;DV=r7qE?~`9 ze#X__`_hl!;Gik#BY=b0A0*uK_IAzFYqCs;VpD2~*qcq=HW*AWfTEye;&+ppug0alY@g-*$X=# zu^zoWzpZq#&-nQ9=ogoTJ7;BWM=Z-vzLoC8Xlo-{aE5ovAJ|pBeDQ*smiB30##ke) ziA=8yD{7)~1dNwR%b1d$nOWuDC1hBC@8Vx4Qp7}x{q&-}Jvbo1^KHrQ>cZm=q5ijjep+!@1D4KhG8K~HM==_ySm)4(YZS9efX}~p7aK~AAzN-loWvQ&HI?K6- zRCxO6BsC=^rIC>l);!B%oIHf2Fygc>KYAxCib}FT&bjq)bK*ZP1jCEd*{}D$(!ER9 z%uGf@BWLfPON;UTO$SMeabIHI9X2z|m3L*}E;@99KPD!o|JaiC`uchv5??DsD!k+M z?vcK!sZUE1r|jLkpY*hPOD`()Q`FmJZR=6}Msgh5_ddwY9&divXk$62o(9S=h>Vu@n1 zdjLBTtE!$|RTUIOeDAtIWZr9#GC5ci7#bSdWn@CY;8!vErq=6X9Y{>n)ct)3DpWQAhdfyNoeR}7jh7l5-#as}orPbgwRGZ4D z#^%~_Lvz=p)s+%Dq6AvDb+k2AL0*kF$AX>L0E@GMqNZz2?>T33yYslt>km#hz1sDB1SIhVwZw{pKW=z^QNAOv2j3P zpj_=fm~T{F$h@+wtow(@HL zT_q0twY0Rj2>?OS=kXIb30PrPtX-wo(W6Hb&z&ROEr!k4y@>n#`Ev}t{mF!C%UyEv z@)RFkPMlcGrUkUCqpPO}oS($$%zvE03}esgxt)87-#T8urX4)o8An~ltRUXnSAkI#7T4nUVIMAgSgnxpcPbgPy<`QaqbNJ^R_lcIl0pE@_1zHi*pDo zPtR$v+@YZ%d=EV_i5hMH)am$^7#fX`)X?B7do=AtoIXce^f(36%U^8aL@ZQfMJ?j+ zM>%%v=meabbT>%!H#jYwyS8<^}2S|ciA-p9zu$o952*f~E3fbE3E83{SZ|vKN|Zn zUD8_G@o^Rs6-Dj5x%DGLERy5>O}(?iMj3vI2FVmw0B!EyzwZY-I)jM2H8nFcGd<0( z9#qi(5i;nt^>rRz-h27^nLKfr;4oq#3sJVj&qNZ z=_43vc12vdawS8`P9*0=y%_FGf9cci?f}Sq2RHYT*fPq?6&V>B?S+DagHOwZBO>BE z2M77aiI6y4ZjTeDz^=*EhJG7+VP7a(-t_dT^Wu1W!QoA&yWI4F<82<@cj)`*0n)Z$ z6TXB523}M3cQW*)D3ERa)Xgk#AZI_`&hEWUnHy}%VWFO8?&6mduvrp#l6tLMMh1VS zG5eUX{TC9i=jP^KzRV_iG-l&`Vq#)yYU-$i`P3QaU3v4NC0t6kJ|roH0r()YBhXpK z++73$f`^9(R{YERDn_$2Jw2A(4f@F_9huCxan!ZbUAGUFxwR9HMQ{I5Id%_GEM-?o zl3iO{JNH;3UkuksfOH~m{$1JGx}KAL#Wr=P9$1F+P#W9TGwpnLA(@?<+ug+_o)RwJ zS7a??kG&*KYN7J0uCA6PT?TNylhl+AUNP^(>bKDgS}QYeS@lf$6bQU>q|WJkCf7VY zJvTNsM#^<|;Y>)V0ZE%mGET~15E9*dW2Ut{|50FDH?8OzZSq+SECOBd_2_K_@czFx znjtN5AreA4_U5UnZhfq#5)c%r+(M$FZx1oWNcrx)arm(|pSWpELDdEaU9-pgN-0Wo z$!O;xNLC)f?qhM?U*$98>E>1$@c9V9F*hdEl03rH#)e0WYXx_c1QC>(UxT~0&Y1MF zy?wWePtF;G+?y<>nw(dTd{hsbwrIeQ%2)Myzt6O>tYPr#y>~r}`qbl50#;dj9oK@if>`g?elodgqov(ZIT3}s#Oj(eJ~ zIGF4U)chIHR|Ov5xduLUgo93B#4V=t2)wv1W*YPGcmt|T+r9s?&rXJu23ZE&Y~MZOC>N{Y43m2*Cm z`d}!*$kqOnwJ(F-?a}22_OAxVrEPw!O)Wlp_~lyFjItMJzV=6bNdZmqI+9AlypW2> zxnsk{36lJp(xd#7`C8jyvMR4z`%v~RD|yFJ()M(hTT@0eRAf^j?JYa;8byP?4=5MG zcp@3u+QX5Ql$uH%aKE77&Ye5Ny+_e!8mD`UC@Cl^z23$8$2uK7Fu6xnm0J>tKrwv% z`W0C{YMFp!JdyA&rUGddGV5Vec>*w{Dz}s_<;_dFy1EOJr)W{k#)l7M%iK)D!)u9# z!wB%aj*u(h7UEyTN_x1u_C9hoGDfxSy>cPk`hjiw)vFA984winBjL9!a-^c@#G2EQ z7o1oLY_zz|QL{N~cM2B0KtJB*XQ39 zPcIuK8>)YN#hwj^Ur?=M+8?pShRisJ%fNTV+O&Q_8XPn*kdTl#&!a$dk2j)|`rf^J zLImMuNWdvj2NV<(>12f1ju*?J_gt&4&*!R6NS!M{{dMM{fgL^EBv_84GbikBO#p1*|3c$!v`= zNj)S6VPpvqJJrNE?egV=94srhM-hs$1wsUj3Gf??*sO-(n}C7|&e{qEPVHBf@&r09 zoScL@b~v*w-M)W6aeG7&fdbS`8RqWp?)AQs*}Ku~B{f!6PZ2fv=1JstpctJWy?^(v z^nJ0=1&%9JSa+HCtlyrZoe3>YWu4TJh_y5~_OR0uqc*=j1Io$i5kc@!D(~_unTBDr zrQPRKl9HO}A{3~u#-FIirXu#atZA+aJ3JWES-MTV0 zGbym0DD|*Q4YDzU&ftz9g}ABGwHvcD4)aL^%ZID*85(G8 z#J_vwdf>nTAZJakDk8DQS+dArJU7#BbxTLb1Io%M>Je+zG+?u1hLDEbQLe4Hbb73@ z)(KZv4-b!8dW4SLt(})7SL{Z(`)D-(=0>OA_#G;HFU0G&KqR_Ijvl}h$ z#4eqC@IcBo>4&?xbinD;8Yoe1Lk_zK-*A^`lMzL+gk>Ez3$Y!Q9izw0_u4r{4Ljs5 z+g5lc*qoi?c#@Z8l=T!FjK|ZqcNZMJ9loy{1t{=9LXz*hM|acG*vmy{OtMr^W76ko z8H0LnA7b6iVYF}~P%9wb6ViQPc9Pl0SVpavkR`R~_N&|7dL<`bSv|0cuM>Mw9|pEF zGB@`DB0_HT7LUCo1=iwq9H#qNJa@#TPY!}X=k3hoq@wo#$KJE92C{N;Q@~IrqohR4 zZlqWNK&$RoI^}GtuP+Rf?0)0iWd!5*E=5aGCM-^z$V+po2Eiz`Th589L|K}pL@Q#S z*uH&K?9A5O2|$_ecF0akI|frgM*IFl3lAB%#hLaf=0@*LC_E}-$G;%%F4MDnnA$I= z0aA1_dEG6%fG*&`JdIkg_jSF>heEa9^&l9meEa74zVbmyi8N|S_M-jSCQD!tX{e~K z@WfGbrchkJemy||85b229IW5){{8#Wh%lt&-n~!T+nF=6>MG^ryPiN$LqtDcHA*$&9DR8~HFW~;c$=BY&o(}19w*qu#Z#R`@TD~F6(=>Bwk0Tg4{WZDUg&?VsU^vRi`-n> zDLM!=>1J~8b5R@yPzMkW=A)D192SnwNXxak*1m>;($ety{N_)OcXmMULG%`ZWPWCDUgV z9A`{`-LI#d+o{InkjQdf+1qxCAD#7cJCxwk6QVm1uNoVX4V+=`%2Wx|Gp;^92k=c) zifMH{SKP1YSMOI>Z!)FyCkf%sfp1Xu?4eVQz0RizDW08;4X7JK-*EnN*vUw3dNC>^ z85$l{Qd?UJW2nq{Mo}msLH=0^&oMUKCoj3C<>h6ayG(13>+5wcjv!D2=fY!5V7u}h zIIU`0$3YrdOH^S+X_1M{WS^ZDOenM17xaPdCr>g;kzzQ4&OUy;S?xdCoFWO{g`L>H zcm!hdnONx+S@%sKpP#DVGBZko7}dhRi(_4FDFTbdT3KZ*)X}xj7K0je?dsJtXU{So z_oOJ6iRGKiIypBthpkm~@6GpEZHKAxi{BWNF~~-Mhk9I93;Udw8xmSXrU8OhiZ$T)0NR zq`;ca$Vn?8nw*@8{myZd8{MzVCIy%~3UHWW9DWOF^8NjHu zwKZ2h@~~}{&u(dIf?*OQXfNaRvwx;hp_gISnRylIX4DLdvA4wm)|8vr z%r)s#5Own8$t*)4EhD^$?vv>U0afV(@A~;=x=`j-gwg3wUmW5;13y=_UOk&K)e_BG ze$I{5`_#tpCGMO|lW$Wa2TnaZH)Q9xG+IevVQR{@=g$kAtS|p0mWv+q(m2|?B?Us4i<{yB{LpYN-sd~ z_}uWB<9VHc$2qQ;gU}5Qd^Tv5h`!#^7GO%iTt_lqzI@rq$>|YzT&zujZ;&FQVA45`4OtAS zX1_BnE$yc(pv!WuNm))`RXVw`@}$15dlLI-h&xiXw==m-%-UYv4XlkP8HOjTRxh<%+mZ zPkbr-iv^=+Wqo)6*k=}J!>+g%GydY`nYVhPmS~pvpUY5WK~VDjpfP!zqSzLJJx--o zns-~pXRx5Kur~Co)7Oc@H3D_8z>Xb=vY4;O$SkKsCefG~piHkQnGy+2ZY-SEzyg8E z`AYuCUuk4H+M9~ArMWo>wwUI%^mGg-fph0hI7$wvnNMfOV3sMd=#HV@-inPeGGldx z)~Gg&D6vTQk37?7y}tH!Z!vmF{K|a@9^mr2-kMjlQK2V)?8IHN4-TN`nz(WCqTrAQ7BI+>LgzYe3R^&|XXEPU6|Q39m>t4tZ0-H9)$(B`}b=ZlMH0jwu? z=us3Oq3Gk%;YO7ZA3l7@v4|5F6YJS~sr)bm84<6Cj`b2bQ-3(gqVp71c>Eqkr69Sb zDX{grpeZ0kWxcg;%Gj14HZU*%SfsAb+h*xVdinbG>cWD1Z(({yMn+bLEJZN`9ph69 zAtOmv)RX8Ek65csJHc%>x~pfT*NzG1QhhtC-Fa%^Gi}UcF1kE+>wD&czEt0A1@kQI zYbjzL@1QH0P>2~GII#1%bIfq;=p(Hi&m&_7+37BF{RprVx^=%p6To$05s@RptX8S) z(y@gc{Z5aCS-j*v6f(g-5)5`JRd+7aGQN^3NMQIV@GAk35Wt0nhX-Vf-ZTd#{15^2 z26+-vLy{mW9D~M{YTdjpYI3y)WH+c3S)S~2p6xG%%=V1h>({T(2At&w^nD>I>D%h6 zfJUevWNJ`sQe0HDi0MmQ zf(8HZ1?=)@tpo!$C!cDA%gX-v@dh9~w6-_P{2m{^ZIDWG)H}n3^hjKc-A#d}r$9-s zK}`yzJ1_}FR^h~hK3oj9F;i8HYPBHOhD%&z_$WOl#o7lY5gW@hC%nAuUnCp<-XoYp zNJdK+50C6?*BC#u>^~}k4w4>3XK+`AO8jURA`rTR zQo3`}duXvjDZ(R-Biuy=WRS8G%1DgjOV`@s$hkU5N=_{d|M2f|p!NQFMj7_((X}>%%ruKE1Z^vhLwOLK+>>lNHyP<9x*P z6)=^k@mzFyhOZ#==)&M9|L5 zLBs@=zq(r0&;d_TT+4_R*tchPZvQd8(+r+2ycer@q2NISIE9@gh&QO7gWlfqqQ((@ z362@zY51J1=!9*Nrxr&_GxuDU*dcPN`;H;31;|DBG_ag2xZVm4Z07=SBP=W|Y<&II zs?{Q!uU#!u!{1GQw(-6t(6u`_|3z`HenicUgO2Vk_XOUk!eyIt&Z34Nw336+G7gf4 zPa}POB7qc|$%S{jU$q62qSM|*_=12uz!*WfxHnzo={YD^BVT_&YR?{>z|Nf^?`X^s5d6;fZ$gA%hiZ|Pu(U-Yh24^vlIU~GnVj!c?F8(O@ zXPp|YdD2?cq!zyXAqUzMvfH5%6J>c+&EBhyc|6>pjDA06m zUlu++eNbEsAsD1hVP~Re2!AoC0~id3i;FAqIR2OQ`XgVpwRyFs@YGQ~@)=Us)YSa> ze(^LtwzCpw=&M(+!i>SH!Zdzf#`Rv(z(SA)p`)j>^WyWgxIc?qK}E!|<*7`7%=x1q zaxGxJfdSGEvHtKaoeC?fPwaDkb{-PiX5dE_0KP0!L5T*WgCH<`TUmjVL*37vEZU+w z+{F^@alykRWC}A_12EQw)lGjcqQpkb19TY&WP1E@@wLU*TGy^!oA~@0!xni239c3G z;4lP&r}JTw2%tVYl2b|rWVEo4XsM{onXGESt`D&GfuZVHH*9`mEDz^&aQWk(u0qnV z)Ya9c2|7w=USpn49AuH8jDMP+{|LOCYzFWJOK9>8Q}u-d;mgg9$Kyd04Pvz#dJz{q z_WTm)9+tZSZvJ}oT9RUu$}1~?;8z= zv!G9E6r-AG00)My!*{C+e1Oc$d<}9s{9#!Ue{2G+i#Ij+JE*2PK7E=W-N|{+0toqh zlWSIYxw3z&s6}Uxs1?FdOAMx>yxij0v4nXV-Nf4=2t5#6(d@=vZgWk{pq0YikSQg6lTeDer;P)o0Go&|ZR0xtzfR=C9E$XEMfll~C)b;K?8+RN>a! zhV8Azhfo$f^$?1j*H@nAzn$L>U0+${N)X6xSYMd!{hlxLQ8Q|N8#9Fl_s0l z1;!5t!q!)&ib7Op*JoC#69gQe{8-xQpG4|7%tj)_OiWFs0cweO0wA59o)#p+t|hh2LZKa$jF6Oe z?AzeA!b2`1m=6Y$tLhI*%ri*UAZT-+Mc))aFp4gM6Uxgr%9I|e@)dv*wG-%|5U70! zKHo_3_{ZY$?X87pS|1;8kLrJ-?d+~U@z7UOqWaYK`rZ9zGJ{b8pZd}s=6V&y&U5){ z)tp|PTBeop(L`5&AM1U3;$bd|1NAuS`^J~Ls*h|x-gW{3>3~m&EBmJ^W5YDB-MScy z?BE74BhG5={G?P>3YHp_e_}QwudAmg{tWd?*$H-ZNlD2ZpjZgnpvF5{FkJds3(**$LEXX}P(+o}Mq~ zn0R;Xg3aYMRLj}W^jJR?vW%v6$VWbOcKTh^CdERfk+ZZkmJ4C^w!{H+7KflSfPg!& zmo8m8J>J;#Df-9v`H$P1MR^OOX_@nLnvs!n9N^=qcD~K+#5YaV9>A?P=KB`tjzt%!kvV_6sX>Z{AwZX=+8!eEn*)I^A<>-pT8mEq0yv)1z(wZYpjzR;S@X;E2geujmHka?z`xrO(P3Y19wPNpvr667M+7VzeD zc`l8y)NNJG=K7>PPZ8NM=0Hf}~+b)3#JxEG#t3ISt> z&$w4_3GR}TlA^&9X^-7AM#kXx`Q`6HyHaE&f?p7je&C-#8HQbvCSVG1i*;p<~18ANPiX zKP_e^$T-$VZWS*0H(om=^I3vY z+hCF_9LcX1J+aoZzrpcI#Ky}Z1?%}6b*JWwar;BQ%q7f($T&7ctkb-ov#%HL_ZfT= zKH9f@t*T_GI`PZ&@-Az55wyI~BKcOv{z=r8=$0KkB zaUPJeot5CmaRQ&-+zjFTHUu5mS?DCjr_P|nLkEHCi*6+2T?mTpO-)U&UNL_BdK}#h zZl4E-zjFZW&52Pq63wj^04gK!Kor-6?M%9aDLg3Rmkv$;ylCPXJ^i=XVF{2tf9t zWD}Q^91R`+sQV1$8z>}Lg^lLzVR zURMwH1WHuOwvtya{ItQ=eaifj6S=ip%Zp>dQ>V2sPgkuk%+s1Vn6+!Fg}S z?%=_L2zxAr1fmmQ2DYR_9?2+*c&Qfl?GBU{RnuC6bfY*P2>LVoELb}bld~V{_ZQtV z%RR75*$aoc5|+HT^q`_5iOb149~9Qt=wJ1 z&69iQopl|oJ5Rd zDuwgMb3bNBm=dqcd^7xhw?<2Rez1fxpF&TF<7bhqJ4BcJ?!Qs`ZxtBYdYZC64-cEe zeuG+#{b4C~6&|mrn+NY+TYV$4>}_Meay34OC>3$`!i^Lb3fsic2md*Q!o4{EtYB!m z86L*%-FqAMWYLmU*{*Rl@2|CLH|s>G=gYG>O?Ks8yKdIz*YNz(8!nrH8u^m$-rgYq z-BbUXAadC&rXEp*?T+=J^%9pT;^T6R?tIs?vGipSQ)yDSGMGSp6xcbCYZVn0%kO+A{O6UGb`g`l^~KS$672o`{dex% z2}Bk!q&M!qe12)KCe_G`Or~ARZLO_toAHT_Cv`Jv9@w*$2h7I57#|;hd>wJ}QC(fc z)LBrP#I*$>5cSstPTW71-yC%8Pipi#L6RU9`lZQ{LW{m`t}psLJu73w|9tE8>ei3x zi=99}aeSv}FTBls;2PN)g-u8sg7o4XbP*F8xv{+OX6C|*{Gkp8YHfEQ$$E<>?AuD^ zY$#_elU{n%b8Qp&AUh}pstG*1Ez%INYMNBfbm>SMG(fN%miQ;BT_Lph5Z?SVHx z8`Y}lrcitS>40OyrHet&4@_HXRaF(FpFl`MUBGm@FaW*I&Q5O4@E~n%668xVj*rFs z$Nr#>KhK5Wt+Cjww6xLrdDdG_s!%BN3a~XK;~)mxVzHCc(-M-Bt2+*ZTLgCa*%PSt zbocOBUt2@lmeUO!Id-fJARt(X4*i-;s8KBOpW^XfuP_RT8E9q&%+6HU)7uMUtpO4Z zvLSF!gALJI`}ap2^M3>)F}QU;p1l{L9?Kp=GNh^CVj)CJQjh#h{GK17@q)^?V);A4 z@R>v1DF`r0e}mw!rkSFv6sT%XsCR-WN%La~irH{W&~6mqa7;0qy808JY;sm@GsZvw z{Ou*p+HcTOJ6S;_5_RHe!AT)K4skgl%9QIElD zIgz6PdT$~jT9*xpb5U3w63- zKv2RdJ95;ZbFJyH(XnF+d-mM4&jKdW`^1U-d-vQxLJnV=oYNc|2%ak`@W{L6?J3tI z75=7AVM6*!4Rs0qTcxrVvm+ndz6{=S8f_8xYZ*8^gmmRnb$?Dg$Lv4CQ7!LPuS(6r zH^R$bZ*Miairv;{3=)qGZj*cR$2i<*r zThCavPF z#eFhNwMt~JR@kDSa>rFIig_Y^jWdD{AVFgN004n-hKE-_%YwOdTdsGAGF z2HG^{?D-oU`P!LsZ&qCe*z!qFMNREkCF`^&y56kJy_Skf`my+Mg8Jb%7J&+0uV=E7 zYHELI7&4Fp_u2vM4HRrShLsnBqJFz*0-Ojmd4f3p?1F#*RFTL6$yeNV?F?|PrBzj{ zi;H^ekelL)t-kCpTCEcN33o5k;pi{*X+>*B_C=0~;rg=VoC}|)|Jj+CQDhO3C@U*V zgv$Zk1?ui{_yZGYnP4IU!lP*=b7GJs0qdj^G-=MmlMU$D5mb>o)7{#fg+>?+*OKV&8~at0VYSXf`+*xSf?wzPneSlJodc zZGG9bRi<2dm9!Wu@BJZ?foawjyQUS5b0|#OAGC;@n;N!vbYXHRXt7MFBJGwBdVKb< z>Unn`s8X+(&w8Jnhee7jK6?(67dt(C({zNx9j{=SLs2JLFwmcf$xDAwkELF*DCHl4 z3d=q{zGiWvoeZa>9j!mZLA_=PV*aDgxCnUtG4WWQml-r0%~=Od&>n1QcAL`*{XCEw zGT&eq{^QiAq?vw?A&&3m-tSLAGf)L3u}unH_gq}AZ&n3YVEp>SpE%8lEM8bxfLXD_ zLWN$~BZ(3Z=s@DeA=gM)a__YB5QG7sf1y1Oe4YbYn{vJx51B30_k=Hac`D zAL?$QYorx}1~d<)T&>+Z^kNo{%bb)yuwg_fJUT; z*ouu0ac5IX&X{FUGju6ddVIt{8I%6V*S{@&K+|gPBXM;0g4iQGQ(Xw{Ywk=Ss!=$^ zb4aBMKI-a2MHXcdIBG*?LoV(TG#|CJf$vv!135=NV3UOAH zuWlG|jl;Mbl8x<+nTHSrsJxaf%$Ke=geJ{9&6PO$*2nCw3rbr{)xD3%xVt>;b0qQ) z;FF-k&Q|8-GLuuNLi960TWbKRzlgW z%!=_Eo{Tn&ZRxT0w~n?A{(`*^FHF8%8ABMIxVSeDdN;qrB(wR-=a&0}>z9^)#E0|9 z?mueQPvC*op23zLtP7}q*d0nYgL}T(*oOTP?V#QF^qZkbE+$L5&Ltq8i0mo z=2e=yc?+6wlPV3bt?U+_X&w%ksBx0YO1vSMpH_l+ZyT>(x&*y{-;LJ*>IlPk|#}!(gg1;jBf{ z2-FzFN-&;wyNWlm1 z`_*@)2KQH0tb02dn3?}%_Y%xRZU+-6T_nWPw;_sn!->t%l}P|OFt`;9x;j)A9Gbaj zmU{!5wB>JSYLZ(cFuQR&(#N07j?JR^67Syf?l!YN9{ZZ@8xs~h?c2%QFEn+}nbhQ# zCV9?Z7TW)(OZf=}s!l=GXHZp}zCzI2TWJ^qC4iPkxjqi?jKc}YbjvkDr_er6y~5i_8p zQ_?W`1qEq@ecP7>{QMQS)N_q&Py`SC*&0}I{YYp0GW}^PXDRTSTEAK;3N1)ZA@tX_ zx{qL0N0PE1^%n%HQXgPMbm6X$=4xW&9Q*kM-a_B?j%4HV~5Iw2IB z_=~Ud#|1A>V`#ACpBDfS0>fZtW(HQ`T=%an2*YNkd{v^!v2RUqj~0R21k{Od7X+f* z-yA)Y`~*6;>R!EAbyFf@Sm07DNSIih<3M7#h{GTC9nl7ArpM{epOltMts z$<6)MY728k{jM(Lp>c>>!hsDX7Gft~0Y^bHcsJ+_taSL!QZ~`{KKruAsIp_yoaE0; zviK?$7V88U^=y1R!lv_f?_eCJL<6g@iRF^ER|O_8C`ggOmX#pzi>U9lA~lKchPpXH zLDI8l&)&Rw1AT*SncF~W^n4e|lboMY@EuzJ_`RYdr-7-pTPbAvW_K0nT{=2C7B`uH zU2&QP3oV7;pzxWnE8qo)Fybn4HTVtWs=6dHZSAUrTt?!C? z_UU%!+2Uv8WjH8+#9$~<_cmeEmHJTe{}??hFr(r%SYWs~{$QZe{e9^b6|Ce^AD^<5 zVnpQfh^tQB%AN6XfvA;R!(Zy=KRADV-LN%~8-ab@R;yp6yt1;g$twG6e7p!Oh!DK8 zI1*%eU#YV!_G)0$Q=ktDhUVMwgGTD(U878J&|hEtbUwk%5S)r1Jqqm4Rq-9Vq57_9 z8o{_Y^x{RLfBNOZjg9_xQPbSTt99|oS0!Apjg?J)hJ0VY{iUF^hS*ir0(Eb zw12O=utY*af;Lo&-iAgUP#XgXm>F_JyRI3r0*zG8ttq8tW&6XI#D1azt5h1adkS#W zP__~>CsB9W_3)>5)V8VD=QL?isb1KIOFe|{J`f(jxOb8}yH9KKZLI8LQ>%duxG zCghS;nw+gHllFT^7WZ2H$}Hvdl9j_Ceo(ec#X~*D*nM^p&J8_d9~`%=(a|}fYze)q&f6je{rR>lQ3zWOt+FzFk^cio1H9D zCY(*YbMGE%8K<)kBeO(f0R6*{>|ftVtG}1nY!taO-dK2k=%I%O_9@B2@Rj+Ks#Av7 z)^}v~S9?cv%lB7$KbyN4d^Cy?<+1#R#u@~V=Ohwh#=@Q7N~y;b3Jtd@Q^9Pf!(>(>KPefBbDTSPCFG<)Q3X7)J8yW@*KJEiTb&7lYg;^B{w)j5Ye`YZYl z$&KoP<4g!By=wuj3rc9$^nd5I#r{=vfdK&=oSd{wd_nV#A*|F|(O(1J^zDACVGumq zQ{$*cttu?JLs(e&(4j*GM<#b%D!dsz`8y@%h+Dpn>+OZk7y!(a@}1E+v_&N?I62ln zpe-QCkW1TwrY!hx4gGG{qJvUb6Dae!;P#QS=4{RNXpjz5e$alOTJasMF1>W=sJ6B? zu!~Vq2l{N;yySla*^GkFurO$TiUu4&U>$Fi(4;9^fnNex!6At(e5$gbJ40y>f6i|h z1(jjAw2~WJ=v=j?pbG!MO*5^x))p2}S5#Ol@~2BLQWSoKp)HcS5)n-oL7cYaN8?%h z$ag^reXD%c-tU!vyE~}zrvXWZ?bPufi@DLl!uhA$AAg<{vx)v&M8fmP?~^XH!Cj=v zx-Ak;+{X_wcmsYf05s$EKYh@bIdG-L);oM&KX@OaVQ?OPp`y_9uOuPS8mR*7Fbi=s%!Qt!zY3``U}FMcf*oR2LjQTtx^$OHg~uBaK|#XV|BJHsfTz0u z|NqZ9_TD3el)aS^2`LR(2}cm^JfJ5XVuuL%dA;c5s~`uOVyD%dX(@nL-siu3U*Ejuq&NF!x;d-a0-J9@TiwqC{lW~Etngxfx;pgvPB?Z1^Rx&~mp>yE^wB2-LfkOmoS+*lK z>t(Kk!`Eqr_f&}y_dGsxQ!*mO+ScJA?=OP$2XK8mY6xh{RYv;aW^WK=OyI_mvwqJE z=P8J4|J2*g6XUK`vzZ8SK! zCYCYag!# z1D|E%gFbIHaRx8_nINHCOgP$iq+FRt?ueP!aAm{Qt)CQfn2+zn$B*D;%HGgou8B7r zISs!`M8p9sJ&*~_-=3^xJASCUr-wu-t~JDKWm=CpAEdKhKL7jo(_sjd4SXT2VO^3& z0w=}`(iwv`O#J-lHUfI$9a1FXG7wTq&sKIDRU*`8g%q$#JOA5tg3DJ&s0N z`~zS+{n7WqQ$K~bM548|wROE!BbS;mKN0AjLv*k{(5#@-1JCTAM{fYq%7pWfdueME zbeTm(MG(Em{t_@H`B3fWv(47rma6hw@Jk3L45-i;a)Q8jLp$X}3#k6-3=5^v@NJC) zZ1IkBy?K8kjvgAE)Z{IH|CQBM>A)yuMDod7o1R2OA=v@n_m7I+JsHfetu3O%1VRqC z7_?wL3Gx>x#ew_=f`mUY6ZqPKF|VH{CK44#?znh+%S|nS>^HljWj~2EM}iIFkdV;1 zz7W9vfW!@n1Eo7S#SB>7e*F1A#S)8MY=dwRL{ltUFM@?tAQ^$JE%tUlxy$ClfdvNk zV0hiveU+^ldA!r(oq;sI5*8=1{{jP=EbdsqmRRxr(;7{)SU=8Lm)v zD~g8`K8m-6=XrKgk_l)`z=QVdp9`?p2+slPD)@wi0K0SZFTu%y5@SKb%E7VumQJN_ za8O`MA;ol=l)Uv%S&eARnWI7G84G#~G zIqgT9v(OJXa>#`Qh1)oyhcuuD=A9=U>tr2BTcL;#=9BFs_7=_$Zb-%pmnXbrD-9es z?FzwKB_TRjGYVCm??w`0xmJ2W-o1)EaHXWB()&BdH49;CG?RcIESU3rv8N~?6bsIW zluEB4{FuY1a}cQlVuYzm>igqVY_2FTOfz zYdrQF)S64bQDDt~Wm0gK)aRO)yIMe@9CTpP9-5bgbp^OE76y0t50t1ur5M&)?BmBr zR{20S{AZ`V2e~UE7X%`ItNay6)~Qu60YY7Y1GLWXOIdzm)a+GFRcqB+pqxT`U4=C>~w+5H8a{KhA*!oiGaYKLcG|z?X^XXSsri_b8PY@=OpTZnK^%Rmvi` zs>=WLY2v@(o?$G3DHC^&8<6Aez0oV2KDX8BE!T^98Y*PBFa^XdU31qdG!63B-NQAk$`Tm;*Y?BaS5&wR@ zQ`pegPG8D_X(-IchcY!bgTfghtkWd{AuN0nAZ9z^IZglf<$`$vz7_spNJB)(S@k*3 zHtU)7U35yST+^lJ!AaR3ge8!aB$X^ZBKoy%+!DAGRGI`V0sDaiS}7;?k7Lb;gbxhj zN5X63Mrb~-OghDL>z1gI69;J==&IY=F2c{j<5e%tf;jm?WL>ZbmQmrxBEcJTQA;ab ze*bECHd;51{QH_%2_ETju&g-R+h;v{hQNu;5C~lLj8qKM`m&FSA{_K_}42n zg=7_20C39u_wUj->okCy5zL5RiHVBh1Z^F}q5IKDb_3yX{QK?=5Qf*U=Rd8`fD4`) zxA~;s>w!MEoKu2=wI#511hkXLxgp{=kRbqiAa*rMI3piBJX^83IXpa^PzBGkK9`RAik?$epQ88dB^_Q+!l1^) zP0DfT5Br@?SPg%EG>{dcP!^ayg7u4|A4F_DaQxgHYc^H6zVNx(iCxy=af203JN4K1 z`m9#|oblR}>KixLci(mV8{{az|IW2UfGiwhC&Hh0k#J>x8mg;P z+t5h=Xt(gGEvX1G_x62{BQ-U(6hA*F6eG$;B;u&iNna}bMh0E%dDL@y4^{*h0u2Uk zv3&-i0WINy!3!pQ{03wYXQ)Z_sswBlo*9hJR(xI)WfYWpL2`K~EXMI|@2l+WeDhkf zB58D%A5P);t=)(B1~&@ikF_UX_H3(oFRU8xUPiUQz(rU>yg-!${evq3l2Dq1j=rs~ z?)@xwf?^yORa+Z)o(xUiV8RPQ6iAuiY&Zx;PrQrFXkr3I!)4wLCNi)Uw1TS%&8uoa(>n+C4Gbv$Ljs`(%#@lJ_&=szY|?xxEr}<| z8wiwIc)yzHGIC3Z0_Xi>z}eb*5=eIa>|$;w(2`~~W}FAt1J$giw3i$d+XL;7!v(*; zqTQ6ySq+$jDgpjrFXkR;h4wQ11*yP^hWqV_@|hpN&%?T9?h{14Cjh#4&r#5H#{IvhR|%ZHhrW)n^(PtLf0OrsyhG*A{=c~0phA5ilIpR$&&74uK)1T+8Pp^bhPqThSPy1+#=CX(mpq`w%ilBj%wC_w z+Ca8F;HmHPTkZ1-O|$YCyU!`rvd50W7WmKB{(C@6VEIv36N+_D|KcZq%rd29llA0D zKcVHq9ujKI!_7Th=3)*t^IVoQvj74zDRqdwcTa1J_TbY}r;qyTF;-#*L&&^AFAO+N ze*b+EF&A>=nJ#Y^InNQ1Q3^Xsz-SGhKm$Vp!e*W$;&++(hg+>F9Zpxj+#y=v%M-9F z!LVar{{rJeF0qM}4!nQc>U zPfSdF$u_m6A=0!EjEjz@HMH(J3h}JaqdhYlk8HWsA_Xmi5aWroB1cE*`6(Qzt2iv&V{0lTbExbVP%@0@Zrr`18 z#-^D%Y{#uh(G^qL%9l4C?Cju0t1e%&w*IMt?^1lOv9VyiBAI`lWmQJj_?cOsf*1pQ z5TD4~@G4q5s^EAJKua z#*)$C5q0>SMdlN)tM@VO4~Qh~FR&QA+5c>85a;m1YX)&9#KQ^2EKzmAA3$Jeq^k=C zQQn#;ec|5;b8X4>&NG!cv$VRphBQ=Ehkvg{KK#FzTN4p0u?H)*2b3@16pQ;D5-Pm# z^(#aspqLll%}MTlnUIiRBR=420dZpfkS`&X+}AA(pEQ3a?bMZq+;uX{ z77`VOy59Z|Hh{?IpZi#rSPZfn-~~X(ag++<_-koW6j~u5eS{?a@eM`>hC*Nhb#>`( zJ3u4=S^==m(o#~M(gQ*JnJ1upB9!Zoz$Xr3@6Vq<`#`}1PC&pp2(tpdXHL4uwr=VE zYTxsYrv-Vo`*>1=!QTwAKbOcuRt!iZ!SG~p=61y0{(HuqDV%KjS*odN>*?xfn}cz$ zkcW|H)HE^3rXq`Ue>U z%7Q`q!qVSZn*nnk(yV{(ekw@t$**3dW4(+d$_3cx{&D(0Ld6d5+zU;Z!d0}eG#YJA z0CW6~TE_`N{NI~-P8rQtMh=1JpZAc$_w3I_MT~y<6B7%?#?pUcSN`9z>)*g3hfEV- z$h3b0VF-n_f5)hVKr@d_4A>daAb^@VY)*`!V4ypKbZnTvzToZTRlVj z31qFrL_cWJf=3AIVZbVt=jXSENE|8w39I|z3gaT72=^y$GSIn#q5YMpT2E3=8CMRb8R{Ubj-tWIcI8!YDrp+QG==Lim-BP$uW$um7he!4^ryL;3 z{c~9Ce;+X#z@ht}_x^wE`A^`qukwKZ{Wo#=n?A(9ap1S+JVXK6u8PjS4SEI8kK+Gg;z1GmqF{O|Mr;<9lDssmSCoCz+p_7H$i zvhwik8Goqn(;Kfgc`ijp~3U6L{JFWoNqnx z+r|e9yheD?aT5eq?C(rToG2Fx&+RG7N+9zDNXp1aE!5+Hz5)pY`_w)-+przh<^EGK z7(!5;2Hn>^s_^85jSbofaM_Z%SZuy{@uI-E77CcszVj3!69-7X!G{)Srhs4?862#NR7T$3-ltC0L;edap0q}Akb&j_N8i@g zc6$?2LQJ$OUTE4y>OwR-svJoQtwh75kf77LmvjqW(mLvYqROk#;Z>l?)pa}B2o zih}AweL#|UTprqUyp4$@*wBfEyf+OZi@rc87X3}*)3KqAJ)k84Q)~j3-~#|dCBVFd zker-}pmz2I6W(?SpwuvNMMds#pTIf;_7ouTu_8FOxU@8hH1^q3L2xsYsO;-uV`=)$UatYBvuLqVe#XQlGdG@1UTb6p}7cr_tqT&D{@G3_KnWoM$M* z#NBj-h68va{~WD3q)0=Mlt|TeJ3kx!sp(p5>(8%z%OjElgrb0;*k6wti@^vK2%5w8A=tH!t!*OXtsDxPwjJMibG zX29&w;WVPTB36wJ4SS)am*xo;UQei1*_CLb7~a_5_|}mOLLT+2Y9XM`BXGu)cgEh5 zQM=^|n@1kf4OG~Gx|=n3M7^7o4K3^AtS?Jne{2@+o%%KI^yF-$mB7?vlw2WB#D5%1 z`R#W-0-7Z}xX6=dUKSM4HHH#35a)tGL>!Gnkc|o^3_zO+9zT>%*4fnBdO?n=oBQAa zgC{wW7}vtWLMP?vW@}qpM>{)g3w&4O|J%i?nfsd^4M*so<+q0gnYtAVODw!W)Lj!3 z6GDSN-%=#}??s%mi6R`fzl#;Qv()H%X*6FwBI+mor{HG@f|^N)wN;J_D*zDM)%kvX z0|QxQ<$o9pMf-ai1mx|=sGnUiD!b$-fOkN43N9#k5H(Q#-Ue1g6`*LS*{3O?Abr^a z$f!j7ses6D&2HMuq-jTS)ffEtCc8eTw3c zGGcdi-Zl=i9f2fc<^b+g3R}KIxVuo?1nvoW`etk{Pu8J-iPkKRnu_oG4aR z@DrIYrkBfY^El*W_9T==uBcus*Jp^1Sb)h!G@AXooF@bVROd;nzlGXO=2-WGn z`WjYpTifGJz5@3JQDZ+iC=!Q2QwED&5{*+eHBEjHS61fp<{Shr=STLdF~55VUs_Xu z8hzo79WmOA3n!(G5on4&*lI=(u9a|$<*cU^XN~v)4r?IZ64E%G4J7|%YvxsqTbV$p z%Z2(WkXwHK_^}xJ5D+yp@e~V@=2Sq*=x=xj6chgE^q3xF{HZJ)12n|0ts@DofYeXp z<{6hx5F)`)W#BB-Lk0BDzng5Z+1`AEm+UiV?}z(CI*gDOUUWYAyTkPN8v322YIoJb z*=cRZ0#0Wp)nx!>eBw1^Bux9rMpMU~bFFqoD}Nis)`12IsLQ}M?T5vud463L2(wWH z`u6^z3tFxRv+r74=YSOiC+OR^Z}lXb*ac*XfUjot@A;Z7yA#?!85ffdDDNgbtxM2#PY`p8^TS7Uc6T{{H@O21BXtw2ARV-9u=l z|M$(GH^evsy)0n&*Edk^f18>Lmb;CN67J+U7-GP36L?Y>HAo4hMX7^!hM@DFlj8_M z!Q1+J2a11#kv{< zprbqw2&hnfYC|sq>HF_7O-Kg#NqW=au7hwSSJcAT;U!rP$5b7oTpcy;HjQ-iZ-lmy z5dc*sH=f=2YbD{>R?9%8;0g=VA*j4pCnGC+4`gq=_7-2!grG7_<5Sdt%A&*v2N?~j zJ4k^O{|RW@KtS_<2ed1MfR0GZ3^xYa;uV3deuiaTJTD(>F z+r@cnEqifpt!UA{F41Ms@wKw(jnMCJFn)TAjGT1RfKYGzr34IXsBj;Xl|5sYt-ha8 z{>@H^5K)bUb{!m#b=UB&mjmfo(`dI>W>WWj_qI}9hWB>I+rtFGx_`s$#GEsaQy-1J=?E_Pf`87|*jnF@JP#&e>2d9dE6vp0v*6kxs`pPBN3*IJZwtW``H`J z)PcKmBQ7fb72u?QGDp`rgpU%dgjD=JT4I@9oA>_8&p&le7ssn--dv3wEy@J}k?YWUq zo?U{$xjU-X+C@wvxM>oUf^Fo{iqx=zw~zv%9-YBjzW_e*hk}UoapNJ8bnxY5hmB zilq6Q+2g)kK#f9)p@TqBA@u6yWJ<+DpEX0U>Av4?Q}Nr{Xsk3Z(=;z*ivMx2@`h2{ z$c2ezU78W|md>_Jwy8GrXPKG$hY1+JoR$A3@}&qIdO9}vp~KWzF`3RtTHYO}&yQr5 z?`gHa3u#RK@8V>@L`dpxILvYcM4^fUs-Jp|JMfUN=xNEBb3dx6DwjJx+G=e>J!pHsYWL?ej7#_-dYoiZ zd@I^{Fwn-accvh9tFvqU>1whiZe#6#9{*2%={2UAWplCDowe=N5HOp`(*VWZ|kjR|n1wGUsc@qR5 z1eFx{XrR9TC+Nf@hfzP5mY#~-7Y56H%88o~RiP!Q0IZ3}Qvc~y00D}U!1Dw9&**U>I{09F4fl|N`b{v%J$H^F#<~av9bHI9zyGuBp2j+ zp0VF+WMob%PO>}8`ep(+s-5dk?)$f%$&9JfNDJ{5dfD)tJ8Hn=@oSE17&~H({Le`U zMMR*UEw_t{3AQiMjd&^euQP1scBjH|>GJQ@576TOhf-J10UQn!H#6+f(=>s5wvBuC zcEvbT1zaFdf&0_bHqZyDv9y9h-?E=^Z9w%q7wP`>?}LKw2~bqB$$0l5VG2sT%qN{d zlmsnSmUNn=^U#;PJhCmDDl#JmG>ev*@m&$jP> zzj#Iq|yFRH2k9i*d$_Qjs`vE&-LII zgHL?$#G|-KLrj@*X*H3o?DX`!?yu7M`3@gGLrWCT4709~wzjqp4)5&jgvJD&Yd=-4k&$hsmRHk2S=ddh8n3wBmL^WtS}Gnf^i8oFOf`~t znWIJC3@^-oAGJ9!(*yC(t!3cJtMzIK0AbuRi^6ZpFPO6|@ zRV+mzdau@*7o@*p$Lz%WyqXn=FLSW_3dJKhel8E;Z5-!iVj36++J~%4K7Zj)T#NU) ziaXhEUxmO)m~R2Fq{Lvzd#=L>FN5=Bd|^I&EAF;GBROkuD!<4mwUUw&p+U$lcJyd5 zV7fXVvNlEkxBKRO4(7}H_2UUcwtTaCS_zhB%v46pMJuT~6Aus(t*uQp&l;JI*)bo} zscSW&#^Hhr(xP`6!!ILpvJ*|DUsZII5Y-*CeRB3xPEPjv0eL?+RVSO9Wj7xPuUXwX z09@x4HfMvfA!bBeP1YmWD=^Z8i;&~)3%d=D=xXVzk)Ztph+rHHReEsR1Nf3lY$Tu? zG$%WX+?UnMB*I(JxI>vHsUC;d`eIgJ(PCG3*Hw5<`1)>4NBGgDelo<%9FzW7?8^MY z93+!}B4EM=c>=-u{6yS&D1rd7@WG=;kVkex2v+!xp~Z*S_)+Hx2RPvm9ET~xHa0g4 zL_E9K=@@Hn3DeI@Qs7)=K{}o02WnqB{=+Qq>#ABiI$+us&ruud5)<$?yj%xqjvFEe z0@A3%kEZf;Bp0TbUi-b9Hb&tqHh+FpDP*aV`0}8nwap0+0+r5`+IQZTemiSByF|y; z=jTmK!>kX!8(WJnNl$ua+7d$gMCZw@*Yes>23eK=viIj7$}jE8E1O-uNqh<1=o|F& zeI%fzyRdUs=e?Nu_V=M?l>nu{Zs&5PSrKpbsE#CM^RcB7AY*N3iQ0u$SF8JKKq+LX z%A*tCaPjjOwWI*ZpGu|nQ-2w3W6@oWvuC5Y?nHnu*=)gY=F6L-0tXFsL6eX$^S4k} z>S%Pc_3XzQ#f{of3yLJPiy3(mTGym;mvUAV=IB5P14LTTb-RQVv(r2F8c4U0dBb$j z*a9{t5pdyjcf-YfkA1=)#roJA>d!F!DN^9*SK=l6I#+p`mI}cT~KeUFasaJobzl}+$ zdFlE~VeFCZE*VTQjHyVOO0xuIi#nmv$ebG6@je!y@RS;0@;pAD$Bu6gc$bp0(u4Z8qZDxAT>}$Dc`Is&5#S`wzrH@j4&(;=+ECRkm-c}! z*+c1U1tv;l7oZe6?DWp!IK2W4eSmy{tj#R3=NrTXgr5u4WMgT zxJ~Q~ZUz$T@o!*co9W466U~FHk-*azArd=96(k7i0Dxd)&k_(6N7d4iF?iN56r^Fn1HeW<(t)f{?5upUtoBP*F zb8}Hv9-`W$&swuC(wfGXiOx0^49(+n83S)O7=VDha2;uS9S4cLg1p6zz98J_M z0*_2>fzjhr3C)WFt$e(kmvu%~b4et!H_?a3gYF=}2FLO{J5}~_Gjl2>k8+B^WGwvS zWwrtZ#W${JvtQ-J95@dOf~i*!AF)z=;mnx`mjr zjQE0)fXNphZN0qebiU&QMY6N!5tonI%-=wyl4H^%@8&vj-FbD)_QwfQi#y>!qDu;7coHU6p(?LUYBpPd;&q^fea)T zYGM6MyKtxrkzFKecZJz=?5p5}fkHHyAU23Nla|xo!s0=EJXu~52Ig&YBMw{$&_{y~ zHX`KbGHhrNq_F6sDo*{v6Wow&Xx4y1xPKm&IL13H4Bvel2ToytDUjOoX5UMcW2y3g z0_|Ov+o>UEVXAAqxOvU3=IFkAoNmULK^QhtC4LC0rOr}rw>;HZyEj_*UC9S>7@~Q+ zj_MHwvON+iteOyU>9glqW9*NKu1?R7yHC#c)R(y|4As(^h7qZXborHCA0fr3vj98g z>D;$4Mkv$t7U~O{NMF9UROU1k=@`D$eD`3bGw2ScOS!YV6$X81miynA*t z=e6~9XC?3M58cJDOGQ17O37KP*!O0{I+b0g#`U?Pj#XAvWE_`r)g7(JP97|(L=8@i zo?d1|Pz@>eI1a%6?;{;xmxgqTh)9g|qWbrP(kI$TsRy3oZh3rREk+V`r%z3>vPqaS zAjRlABV%(4MerL>PFT<8PdvW4%vRz!Qsaqt=)$E(=MS$uDVA$=KH#u`4GA)lE=)wa z8s(30Ov!Pb6Bm@^sdD!kk3OPtjs=nXLeh++;K~ljj_e)mk$jTom4yykmyQC81A?h?MrU=|M&Bi=BOv)MyH&hXKl~iG>mN5Sw)0--<~I@QKnzpyB%e zT`u{#FGkla!iEY%Tu6F4JR$;K_{B>g03bytEG4A$_V%h4g2N?RDzOea7hvHzzzJzu>f1gi9~!u`DrqNZkrEOOGuMbUK{8AKl%C{N zE7+k37w_S-zGk&l%IMiyj^^k+-_16cwKZDY^P@H$5RFr0m%Fd}s^T*sI}cXt zW&p>K#U7}>=MQqZ)24Qnxr=*n$^}fd6tguXoZahC@_o2-`fXQH{6k7I^hJySh$5o2 z8;*BAl@*0)QS)||lTu!*`NBC5-)|k4wj1P?cj32=T}I)3B@ww&NKEVzYC;y6SZ-ze z4b1so3pJ9WTcVX!TM5Y?=Q4Ft*A6P?MxkTe>uZs$_a{G;a&}1Mw?CEVQL*?yROejd z7n8El@kEpwO$8IH?3`XNB%y*hXFm0NsFndaZL{4Rape8U1S+#;J0$IRtqVyE<&`VO z9@y2Cp@!{UCTy$#G5SluB47C8*rRU?0eehYWB!}=j?mc`5Ia${$cZU+>Y?PivsZI- z&u{mE)hx#?Y+{c3slsnYNQ}iR}%uKk9bF_iEqOONNHp=g%woPrQ5+N|OI}X)@?;OV?pwiok)&Muwy1IUbjM zi~hB~hK8Js`_7!a%Nr&e+l{OVULSiTD^nkdiT6qXfabAPO>ydi1s9)|xZB=TX_g#O z#3aN&ERsRY?HDm{EYBF>Bd>Ai3Y!f_!Esx1?ZC+$Hi@N;sk#f=LtE4RQIl$-cpXEz z5J~gepRsxYd!9dMX#{QK4S_H$2?XK|`;E<26rRI>?0spbp!V$SOqt_I00dE75noel zeVK}-^Yy+qA#yWoQ+zjAaIDh!`gI7=5x9ZZj%*bYDBIPwuP>oKrsr#`h{xJIY--8F3KvM6T9MP*}tZHG+Bn;-7s z8|7Q%-c+3Al{U`kv9OUq76dEat@+0_u05|9>`TB<29V?yZ!qaosQelWQlhiHB*Ek&(}k6a>4kz&i%%*12M)T8|2fE(!p$@0mY#{ku++mBAehDC?3&WnFT;1 zIxMdU1bSNL#}EI+%wD0rrOET`fYP=-4rE_oyC~QhCYz9)^US($ElqiPD9KuRM72LAe6fqC&vZvB8ME(bYjyze{LpL-z{98;(Qb#Gc?vU)D(k|S@I5znrrI~B?b!7Yx>p8< zjS5Cw2aCT+K3t!#bE(sD`+0Skxn^g%GcZG(_Z`d-OeE z%>x8yu8@?1LP9llB*og-iUWyHLr**DcFVzSc}?DFFnWT3h^slMbW`z|!{Mz6e;4Op zW|Z}yJ85`-KsS_iY&?_7b*Sov77^wi&6ksMQiWBiDN$dwOhiyVH;P zn-fM7?F7u06^FEm50p4p9+M(3e~aw>9JbJ59?YO>)Uj^9xYVx1wKwsrRo3xspLqQe zs`slciQk7cR0qCykkMxp>%*ghT+kr@!4^-2tI;Soubi2lz8xXu+>}celZuRjszqjI zj*%Ju6vd+#7gx>cyPlo@czwus6vGVW`b~}J4u2Oa)f&rGuK}+F$}P4e?V?|hLOibo zf0StLI3I;u+-(I##qmhBs|I>U``PTOA(|jqi9qF3FFh)ldkrVkBqJa!3=g({}XZ4^>Ijc1YG@XqKtvHJc3 zG+Oy0>_CBR?63l0QjQsb23!pF4ed! zE^rS3ACtgFC!^$h41$HF(v3|doT zS8nIm1stn2i*4E43f!afY(=vA-KVz=ZgMxf#5$3m(G$2*bX%{Lu_i!5i+*n_9NVs; zt&c!|gZu1|Ks`(N0wkOOQHY=W4u7*WqjpI{RaP$BRKQIWXMnE-Ge3&*QjSel+r(U|A4RiH|!D_H9J&Q z#KS(my^DaceQ$`mDh{dN8ASkJeDQ#&8i;lpGweqRqd49wj$g!^DTKYyN$q%YG)(g& z4sux=HP`lHlBF~U;s$`todg>Sf_2jp6n-FzRd@>t0;}`dLCmV`qDhhS#6#!F9Zz#y zOP9S2QLYb)`Nkz;T;JNbAHF^X!fr$!hpfZx)+`tloZn40B7ObaMtk7q(yIO;e1+$C zjk-i1VZU{-lT(eHOv^Z_}5wM(-=~21zr?91m?d7|U zE~`dIMmoSowCz{}{`q}_c7$dR2B)xdX&IrJQ0M@20QcvG7%*T8qdefcgUzpQ?a{)F zRj7YbnDC|2hwlDuD~uKs6H{n`;B&#;O4#GYLWERYCGez}Tc``ec&?PR+cvN`T&Y{F zNp1v3+DI?@TB1+w9(S|vW<7rn zy=?)Um3|On6rNAm$5Foga(1zN7J`77AL>+jyhD2WqYRYaB$O(+Z#QT&E>0{gq$VX% z-x!y9lNqCGrFy9ZEaQaX)S z5&9gFa~h2@0>pVHJJZH>Mml}#*idEFdk}Ydt*-3-j0yDoF7j1Aur99QJK!l{#-1U@ z*XH%NY3V7}xR17N9ZLRUnC^#5C|089=AB6gos@|4UYgg|1U=C6oENA}UxV-HUAvE4 z1R4j?x_py!T}$oOi1;a{$=%-H`MbmGzqXbr7}#usR3tA(c;wY*lRn~jN)vj{8dtTf3RAsc&rAks?JWMVoV?!igwM#Zu^S~7&#vfV zX1?K@&YySDoA^YMEtF04TOWDLgXYd)1y9bdi%TeM6>wF)N84LjrtAu zTNRtmU1fWuXr8^?zO~Ko&0#u}+{z?t+h$XBp)j{(bG!!*KoOJVbM_`#Q1bnmBA0po zQ9c6+uGgnqs^eYrY?bH}fd_HZb2NMn+AJSNg7IyQU;&BlcbV9aw`( ztpIC;=7x1AY!F^Nf^NlVv5WUCT^|hTi=2ygQP0 z#T{aa%1Wj9VSDi30*v9U$k~n91wf^NF%5=N5!M;B23o1m*kZsxkAHi~@tBmmJ{8st zbVTYN0Fo~W4*jSos*YOJ)6Ms>qC(kF#err6BJ(l{rf|IiC~N}_4bQ-KLKwGO;W-1{ z6a}~ho3k4nYQL;w@y-gi{2{zIA? z5uy%QM#gBqwm>_(mmo=vkN*s>MU%%B3@Vs|K&0B904rfvh}3s@9gUq}DDk|?E5!AJ zgOL%HtpG$YytbO!Apjy@tVd{rFCNrWe755> z=

            ZpzP&i?Tf=dMJsvF^|p6+GaNH^MpCg?Lt_yv^>hbh{!EmFjAH=R8^tDxn}X&* z!YAaM34XH zwd7mm&C8@X*ORL9TvY({(#|Vh5>4}g@ry~$kSuG;5#1qDfLbDo6<~F>0?r?M2y=L{ zC6WsxQHEYob@fO{4P@lxps4Hxl^OVJ-_{L^1Z8l^5QG#+Tsav+HdNN`z+q-#2yB*Y^jEvWAG5_XvQ2VBq9~LziIU@aUH>CQ}9V zf>NihUgf+Gz|JBFQY>BqTO%k;_lBApQfUh6;}GwH!wNo5jWc~QDCr-W85v+>=Y%U; zhG0f%-GT5XZ4idF!<;CRIWqyw&d+8ZLBJ-^zyK6}85zbVZVoO7lCzrtAmSM;bqsqI z8faSW%d!e;>dZyx;Cv0seS(dE6(nh1;|~;FkouPg?w$O2VS_khjM_~ATz~MN*b@MN zPj23Kw22SuD`Rf~cmu}LYcTBwn$GhE5q4X^JhX9k9)dU>BC3+`!cVYXf^I2%1Mvj3 zUy{&;*w9EC4CPjq3TkazQ7#n z4da7VAQLMbU{m8r0jo;U*KQ%^C~mdSX|B%`E|7^m4zc){Z6LZ*|KRZ1uCM>9@L+gz zl*d9>)}X>3dFzZG>&Hy7T4(D3o@26?+ufOwtSZ(!6H+Izq5p522UI0zbYmu8Mp44R)Aese8c}`{J7Ib6b}eRk zra&zYRGn_HQGsn#iW<-v{XgkFiSZAV)pf-%V`0!xhA5^IMv-;hAHpWsF&@5p&c%zy@v2g%^w%xBRj>8MQ5#uL^9vU!odid%fIJV|hKUE4R`vS&P~?v8 z7kFS&)lelch5?%}$)yzz1S==C(4ZukLE9Nz4tX!QrO>luVCzHB+f*iCLtniczMqwu zSq!Z}n1hNHf%;C+X~?=zeq*_dlF%gun>LQzMtFdq8ZCB&s`TwJ$jXpkLO$YCF>GCo zQ`AIapQ3+JKTCCcvt`@880IT5Rb_N7aVyHxI|RB6d8dUd7sSs}8hj%api)MQ91 zLI{%!bic3e2GqDk4;B`duA^7LKs5||>^}WK5fqC6B$ehUg>c>Jk7`1I1#aaym=g&! zh+(jarPsP@>E6)8Z$c<%$MXGD7Py@(DPBE!OpKn^H(6$}BzItIzLEJ^3ezA=uW8W2 z8qNSD{PF>~rh;Y5kh=Ox7^kOTu^oL>E08>%pgzE~B6_&cP$4 z0xV-G1LM~}3Dc}1^^O=aJ_`5q;1cYzKSQJ=T_5#Ygmpm zvgtolP2(0Q01@6TJjsK@g~#fjL~&6#Q?JsJ@KLLSBZ}?##Uq?bOk!)djb41oE*GLs zA2~z&cAUlr_4LBVIgCj+8@-x-1T%Rl(LvDl-C?2>r2Cgx+D z<|>O6^NdV?Q22v43~4q-^gLj&VdJ`t@M-J&w#tlV6V0id?;L1B95pNJ+w~51A5-@xt}{f6CE}LQ)xNU#Ngf>%5NK*{KFfs<2K@$fUD>vf7ZX0zV@c?P z9yaC5F-LQo+d#KkrJ;BRbf9HYbzg3JmR=3#CToKDXL+Q(|21+y_? zruyR?X%Ai9x)cE)YbQNl=gw-xvdO?EB`eEf3r+0}CXwf!c+2hEQ4uITC626DuP7{= ztkpy@hHjzYL+Cn4jYC|6+O$;+?PQ2gP^)+*>L9yPL)}Y75pyhe%Fmfz(PuRmw>fq4UfPE!PjwfjjZ8n;YXX%!IMo+D4Q9mdv>AJvafQBF$l|v$0eL) z^<%f;84zWZh&U?jd#x})*o{_n<{Wh~+=NskA*{8kNv?&?4Bw>K8SGRZ2pB!bXM`2% zU0Hbtd3XlfZNDcYU;fI0YU7!|$+Xer;aTV0r|*a#xuC?p;6uE=JbWoD8R|h#jnj{2mhq zm0}#xGT{EmAAcPi3$o_Bt2lp*9N|cwJGgl8uKU*}nl+EU4Nwi#{U6TWJf7-(jUG2= zOy(h}6cUA`NQhGAQem67A&N3oDrAn7p_C~^rBZC!hEOtwgi1+K=0YK4mg%>)$~otL zzu$j;_ukh%_nyP2u z^wIwJYzzCaY(Zxg|D>plYmj&FW}e49)!1fqB3Hm|@R7I681!a#0D#-=GI zhmgEL*3!)zWR#UxX>?K%4oz&7JizFB0wBXtz5@(DDt%Y0`UqjNS{dq=)VZDe2ZMf0 zEnlxetF}#Kfs;3iJ%Zxo;aC=J-T8y?7Cfbz+S)H8>Kq~8%gT?@Iv6l&<|4H&P=Uc( znW#p(+EWF#xLxLU1LkC+8YTpO3=Hg&Q}6-9R6&^U#;P|HROI1HL!|v~X}|$bNUhkt zd-w3^thGv%sDI=d+b85Ggl}9VkzGGNYijn9OO49EK6d_CW}TS%w&K7i$6rQQQY4Sp zethIRJLVzbNB`K_#bp6Tj8sm;mCeo5uoaUk;@XNCu$`mCvfNYiE2)fJU1dTX;p8ae zQvZZpP#5Tq>|}PudTzK>O?8O)_{kGv0bJRuABa|;W%av4PhYIvh;8tbN)Il#+f}3rj^+{mLbiSC~@83NENyb%=oV z!Tb0=<-K>2KFMYvuML!C`jLe)fToS!li`cd4*yD%9PA0z-njtF~NYK)Q zMu67X+dYJsy z-YP}@X;SetD2P5D^ac5Q?IIPs_N~1oiY$c8;j~>lZ^ZMmtIDE=uxjP?^1^Jwpz7mjT&UosU0Y8!~@3{vf? z@aW>?K}Bgn_;t;hgC@?8EamP9En`{|oM)pJkencD%9NIyWTAO4e7qvU!Atw8Mo1{t z8sbL*J}!CYmHG!v!BTM568DuZnD2OY{RrsyVnoku{(yNL8p)hpW9ve-HXbVdV8a_y z8K^*SQx|%u1NgJ-GX%hqcudR0QgN?NI=0Tk7ejCA)o zB>mnci@a}WpcSX4_v1$G0!{_~*+qjlFJD^kPNXHFwS*#^|BT>HH&_-wP&{fzAOS=R zrQ#*cAdje}Crl|a`}=b}DgJ8%O1BH$B8l8n8ZlIgxW~5+` z;Szv!u;Hz^$IEo`#o@5am(hIKef{mef}Ra4f@r^-qm{B3Cu(CN)<2j`5{jiI&jT(y zuxI@xG8~4P1KCbd*9vd@u8_(X>R-&(UmJ}3&aXmsv>a6Ff>JCI7D zw455}hBztezXz4H$T2~`1Gfa$2vTu)TJ7FVdyo1Gm`GJ3gLuglv(I|gSRsF|+*O22 z6WQ+{g3|2R_G}s@&z(n)B0N!$m{dd;jZ+kAz1vR|cgP_FfJhI(tX zTHL6qyD(u@esE@lXdQW~yCxdhDqslfF&m?R+?_jjLbFM+^wU#!$)1PLp3Oq}jsi>d zNfEQE*)-gLlr?-DA2-*+Y*F8wdCA)PJ}Bvzud1^l6HlW|vbMFQ0K9jmn``JusDx?b z{FeJMI1{i}e9j?f#Hiu|6rg~>j&wOO04u{$}a0t8zbtYM{R7%4_Z^3@ABzjy&nZ=XvMCTD}dVP z!R>3qih|(eK=)nxEjbr%iI{JVA+R_sFAeIHfY0Ez>q?Kr!#=>Lq|7?(IB3*pWxY}* z%2MowFxj%>>>v^-_{#V$PU6$2P;?9V#n+sKd}Krx=(QJ{{hKYa_?RdvOpP?9HUj&6 zk2P1lcT4Q4CVp}pG`b?Xi}O2?iuWqbHqMGQiIVrYOVjL5TCzSwl=oM?Fsek3RW9LT zEGCa7tr(==V!obhpNu)PyMB=MLHL~BzPo*tOsk#0VZ&U?- zXjQ&>_Ov{1v z;=)Ormjqqr!SA_uQ@?aAc<*5LPMvFXF9~QhA0aj#XE%BrzNqEFd8o-k9dOm)=1$0& zVqY!ZHVRP6`&#ktZR5~w>!!0`nH4W;oLnCIJ!kLvjf&EOGIgOCGpG-Q@f<~F3o~H- zcrhRviTJ_ey5e&nylLqOjl5(+uGeTx#`wjs@AmoR1Pdx}qlNt*Gk!i1ayW!)ivTla zkS*=IUl0e&5%@mn#7KeL+Ow&ZVlH9ym|m(Hep0h@a|!u_O}=qg>aGTDLC;r(@7-kI zbkR&b)h6Qwl#UplGUO%0q4m~^>vY*V@3L`D6#OA)yIxGpneW;v4ZGg$T50;(Idque zZnn%`&l?G`QvlIS#=2dtW%A7Juymz-@AabmS-)Y*X_`wB5yD&S7=MqDavlAob?AQ0 zG5(2B!l&k{l2M}XFH&BzMTY(4`})|(NVQBuW-{vS{X<6SIqG;PqH2o{&o1H@kPkK2 z*8b7jI>e}`sQ77z=gp|oN~Uj8Gd?-D9`8+1*#EsL>kBUIdbjb7DXR)rn)x#BQIL4D z=PTk0P|2jEq`XSjn}Y7PkmfVOG;5b;Pt9tm4<6^>JKKN2ZS(Lst5O z2`if9U3Ek4C0E2+aOa>pJo*|fkoreJeJKE+eb2RB^_IE6@DBl)R`Mvo-eL#4@t2QQ zzLiH5F+~s1Z24-HuzL&0RKdJJg^6CM^v{Vq;YV+|N{`wGQ(pGs>Dxk-y?He<^6l>8 zR7cvJRQqu!GF&Zt%QNpa)TT^i-e*iDX#F&;?@5I^iT~K`9TB-Q;fn8Uq^GU#BK?(2 zTwh!CQj=wG)VfW%LF+bM72RigRBBy@jVw!;dshXMb)9Lp9R&w~%Dxegk=4fBB~{NC z)S(Z9Km)$N>C@QbRSUk`lJfep{2y%%)^}j8Rrvsd^s5 z^*_Qk0KEsP;G1hts;;i?$x!Y{wy>%o>gd>gRRVP zyImMzK0!!803->Nuok&TIb8JYGn=}6iLh7omEQdlGf^D@a8K3Ahq{}pr!6LQ&;kAN z>8y~Ft$*iKBi&xkX3wTgCTCIUW8R8=JG{2^vsWabt;~1+7 zeOll#R*D$9I26(rsH@`Zc53Zp`NbDXQHe{|3ywB z^hhqO93$g>A2Tya_rGsFlJ)b#3X#<8Y_sY9h~>g^XCFU(x}%<=JA{0-Yivt*Sz3hb zAI0k5_q|S6Kvg;CZO5KhH1^{I_lS;P270(02UlrHiIyAwvNh6Y4#_Y3nNLGU4pv=JvFVN_ z{}nZWtN|^dT$|zk#V3!2goG#>Q~TGbe$15qjNAQ=w(oT{v7T-E!nV`RLai^zudJtz z<~0|FpLAUrw138WA)n2C+%Dl}t)|k)$bnNKwTyYqJG{sz$k&xVOI>{GIJv#-Lu#@m z+GZvz)egg7192KtV_ogbNRpIcbVJX7i8Y~fevm5tTg63z@)6+=+W>XGdGqGb8fRzc zxG=G94xvo^D<#GDpn>e82blF3A8KEn+>!)ku{%5f6ImD;33pa4$w;MLj2(2^tlx2{AD-@$pah zt$|Jf2H=CkA%XA-VHiF#!>hhtcsJ}#8KKKNe(A~;2%vv{<{?*ikhBX1UVifXFot&K zb&_(zQtbG>57X0j63`rj!{m4|l=Ys%fTaaJp(Oq-kUMzb1s?^sbywL!VCL>M_{8J5pF?q2Y%$YhY`!8Jjjc^9f5znlEsv@+0PIj8M=bW|N1GB2hq* zE_IY8@_0AP{qw-e8k)Z)O`+V0a*TgrU_a|QX=&+y#I64P=I4J&{DN|8SO ztFG{`FR4Z`a{9OS1LX<2UjC(n|NBYTcTjX`Fk$fDUGRVYt#r>tJ%fKjBIQ%kr5?jWBY%P zwJUsqrgWmUgTp=#a!tZAmOOD4mHC{zLGpV4k{G?Udr@MP?Klk7Qj7!is-i&P{nqj% z$KSuqTq^|U8`pBIwAJQ^auszN*PE|}?e}jZ>TJQ2IQ~!U*XETE%!VMrg z%q}cu43y|^c$S)_VeOVJXi$0s91`Cs4t4~juHi=bPjX=R`0sjG(h{u`zeItw4~e#{ zPuBi6U1yn3*(mPVVejCOOnQJY9>y=Lp8dx<5fq_C>3WJ3hv=%(@&XIEh+}FQh%j1u zU%q^iUG9DUJmxWj)GRlPe?a&9_2I)PlTM#Ly}rNr?-mwWIz9)fq@;MZxwJ`%i%%jr zLVEHJ8apshsfgOTZQBR9Ktelu^p}h{jG_)XI}bLGusFgeD5_v)$;f*#>7isx_$=0H z5PCOANL0RfVM_+4vdl^*4b_UHjSbDM7i;+1FVTzPsx8$l9@eXvjc7+gqTS-XwB;Ay z$=^>>G&VMdBU_#Pc?Z9s+LPbv*Xq6jNMoZJs+t1sZeLedfWPPW1mf}7X=NB(d6r^4 zp=;?ak#?|A)OyT+ANuty1Y|dGPbE;f`UR;iXTeyh1={fXB**~~qp~XlhoWTNMyx0P!xTspKJsImF|r#_fQO>I}JH^NU6c2tCF#z;_%_a=K0PRPX97Ci-BRAhU0TBN+??&(G4qxRJjT@~*O_)iLUxcqbiv?sIsQFl~n1$UrUSL-yGYH+i=%<-~@3Ez?r{m~XNuP)AAjU%drep^s z6$@ce4NHJaopZSgWq!$9j%XigF^&t4JNx$rr6Y(gYJpP3ncmSzvAVFn1^)Z_)2BSg z#>eOU`|)s#h}Lu%V2IPp``S=p@FOMyEhlb>|s5oMj#%;Fv%*sGw!BqyUQKX_3<>a z+qVNMzX$#wsgIUG-cMj4vcltfD;V;v8=@j3p|?a%xr0$S&i8>tTZQNzieXLR4 z`B!=!*PkE}gyo2p+g~G9!a`y<1{{4hmd;qd-}!GQ*lR4U5= zP=LqZg|3ts%lgfmm!AgGD`&#m{Md$?O-wWb(pTMR%5H>Biz&#? zZr`+t?FB9KJ|C{cCl`0M0J&UqR8YH$If-&^4VRUA0@_9Dl%?KLkOtUD>I}17?lr!P zr)+{QUd$=%o6^^2hm|rr2yA+JDTtm) ztQ?5S5QH_nf1SSc^`C3CbmL0O0bSht^aSWo;mQHGBF>7_Di>F1Ufwnp19zwqMMg&M zIr*=3Ze;qMW~5#6tK6&}tuM+tgI;VnI>bXQtRW#HRPxdtc+YO-I@+VIZH zvN2X^#A@q;u8ta|EHHE^d9I6#w8TFrlG^Cr(q*P4L>|5o8|!fNC?WIkLpzu|mXRkR zBi)!5P1nA(kU$%MtznYjX7r-b44_H!^SR4Uf)(D4`1q=dit|@<$-$b>Vr#kIS0}ao zRUM~V_FHxQ$aCoIT3A_?oG$Hq|B%a1_{)=#ahtuwZy&Dbp6>qutq@Wjj3EvRG#&T* z*$k+bKK<(^>7f%Ri{4zjx}T;@efUp~U@U1% zUO&%$TZY2%L#*+Q$(1=1^)G40HTM6qSUvJcDeQCXJ?7x8Rf_j_b@yx70>WZjkC1By zJk4G!q@<+e@nd&{$nS=>J=tQT=O4PY##MEc#NPHm)iJf2NP0<;&$;EBMX_uB_z+HH zO$z*5<`Y;g*uvLGTiVATvhxi;f0?|k5}w|qnioWat4ggRQSUdY<7d2F?Cfw;Q`k3d zU-teLBX1SC%P%E?pZuK&z&j`Cb_8{pfw6|#U>r9r9ka+}45YNffCVj~kiLIzra$fg zX^;JahWOnv=xNCJH7Pp!$noQKmu;?aX;)lY3aEaDhD*Bnjn1Xzx4<(yh7*y_NS0Z5 z-rM`h#bsGlSEIQ8NgLBy|GHG@nEC~E_6`gjx3h~vV2g>_27A%>?+>%KLiq$*pR4+* zwVq@)C3Bv(`RBqiY*~y^*qlbuG`ztrAbHupPP}wGH0z=?E`zusDsO4&Oc2IU(a(GK|Q+d^r`{8eZN(Kybn z+^>T8ys@;NjhXpcbaZrVtX01ADqeQZvsPL)mx7ph`1me9{EIIliNjR-Z$k;h8J1*z z9RS&Snwq7q8JB~!B?cv#c4Sp>{H-z;Q$I>Y(8WZ?3>2uFlu91N0{};wF}XFTDSyPj zR$uV%_NpvdR*SV$$e@VJgM><90Y;i@z1!H}U77mN@-JNyKdA|%ms0_;<@7t;O^gvP`tR;suQSUK9==+U)=s72aVk)eE9J z9^n_EDA<;`1gb5XB2ZFdQTkHOyo3B%6cawBGf*aI-8j5ioz-Uo5aN%LN-o`HE-pi9 zrDzbj<(fecuKyyC)-{1LdP4ROXL4l3+8F0c&u7-G(h`y35 zzQUsZ7`j@no#nCJ+@xK|Z|-GetXjEJX9={VNbdeI{cv1O?BoipsjAu=m%j1FiqI#S zFiw-zPL8sYDTflWlF#h9OG--zqHpuk63P+XF6{+#ANm7A931{@O>gL63ilY1C<9-C zZSQY{EUe1$Q?AgFr$m+jW{jKOR!ES661|Z&6ES;U5 z;B+Hmy#4sGU3`zi*+HR+`=-t615Y+=QL+iy(os;R|8h@zjlxKxs;}kPsxY1#7FwKc zyJouL%&jt7NSDLpZNi@4i2fEDM#~r6>Ur$QnXg~X^oPpQk{!t3lp#1wo^BE0&W;A9 zTMD-~L9y|Rfb@~0iHMnzG8CUhY`F>;{l5e5NlU9rq13v+WclTa45{Bpuz zywC9PFyr#&@a1T7;L7b{0(m?52BvjAVF%Rbq^7Oy2<$ z^PV{l+&KEQk>Qz7~rz#|=Yel>aZtLMB@k zJb8klHOs;?;b#?hjN(<{j$``${;-H88k+bI9@g8e;AA)R({#u_w4WS6s;dGXCd880 zEq(5v9U($wT3P=CI|AhMw=d}zLYH4@ZLg@H>lI&I6UxR&<0Ag~Vx;@aNRVHFuN?SR zz7lGO4@ZG&g8;Jh1fqSCgvMvf(x-O@R-V>)LwRZr2#3jF|D$QiF1+&`_;FobU2)65 z($$Uie`G&2n+`-1J(5acH9Ys?w_PTb#4H_(H{XsEB3>7=Xk zGXclY()S{`luIxF(ik&ko8y5U!;H!2o>Nfq<*P0~@(SRRNdfwPq?Y$B>E_}_#{w+= zEagc2^QNgoA5p&OpWXQTNXTE7B)s}5AjL1KJU9P*Y=&L9t#Co+M_b_g+!=|7lh+Qt z8*I_j)7F3D-Rs=-Ln)v0`m=2(lC~USURvtKk2A8cDC49i&v$!~M_8CoCG*+!^4N9r z?tCdxT_`HNc?GpA3F<5x*l^in7z2VM{CPc(o5Am`HK zwFQnxOA@-fc|h!hW6emQU zT5uaoad?w6!aT}+dBkd#FqNJA)zG7IC4YaauLphq71f1y>5@7Bsm@+2N!8gfg5~s~ zxBdC_qC6(__r5Di583ye+Wt_j@`Qike-@X6Tuejib`r|Gx3f4YW|gn>%xFWdw7!dS zUD4=o2sp?qcha|lvm#17Nb~xzO#ZJH!OHh9lK*U|KOfxh zRBHOPrqkwKO6}R?gWO`y6D*BlOJ{CzQ=|zKK1i;5Eq>oh(^JcxJ~F~;?<2KSFc?=xNntioQQ4Xcy=4KNr5JY_%tHr zJTjEX)vXPx+O*%16DNw!PmhS1+aaK(2i`t=bEn6_u~j7D&@dx?ZEa3($(&Y!^hdGl z9E!LFoOCrc3p~diM1$)!G@@vQ`qLf)pP)x~iqza7%$32`ramUky4&o{h3 z=0;AKjjb(AsZa+l1yb}iHQ#`SLpZhR#AN0AfzU!Oj{}^@QTN*z5C<0URwIG#ap01v<&c1&FP}?;+fe9 z%Sk1{D-Ts2ObbW#>;+v1;(NlLpaF(h_CHrfGCQnUwk96Qe%I0A{%@} zpHBVw_%1W{Iirrx*RdFyE$?G+IX>8Zl8Tbm8SbNA zW`ikFOQNEZQhHk2Qus)J?e7lt84LiejLS6t?p1EzFMBz_?b5!GUt0s87OGNmh(-zW zecc`Br95k>q|p%^8QF0;?Uy|=B=@t^ zm+`gJQvCGOQ&W2}*07eGoy|!PFbgVG#qRxovrZ0jA1}VoAZOaqqpxyCvxax-W&?Yw9=Q=@O5&ro@;8mk^-c)I${CH#J zBh!56qLba)mi>YKBAPRQ3VYPb_q$V*#y4>JjWEFh}%e*Tq@+HU8F z9e&{)yUoE=b<{~=)Tz&T{?P2ZXPr-5-*Mf))HA|E9l9M{H3m95f~l#trsny5Y6bNW zG_2}pO zA~O1=**VDt8a`Mr^#2`R#bajw1E|vA`av=t;|@Jg8}*rscVR*2(FagImlX?`ec%9d z+uLHR1if5A>!7CQFC$=6q;4N#$a1|CsD6PoONN+viOZBwTg2bHIoOUw22>8Mo_s;w<*4tn40KHusQ=v832a^nHa8&OtB#5?+q z_JnURyRnkIm&E7fD?UKnBn>NY^Y%4=FMkZ zT|pFBeJdR-h0Dd!;1rozT3Sl4N^nPH6bM|c&jYuZg#D5I`O#U9_&e!Uo(8UOS8sEx z0F&*giiZ6?-s9av^Q7?MNG?~AsZ>pM_}7IA$cY_&EkpQ`>CAP@nTznEfdM@zW`Xo$ zQj(Hh7z$R^;BjqZx*bZ2e)6{(p6ZUZB1F28WwvcY8>u8ef4lzc3vU^y)8kQ7UTE-q zZ>OnQ4demJbWebwp5f>4mbBGz{SeA^fFpAfVn4ewAH|BK+`~q?aw^zUVoTw*^<91w z-V5{I-j7e_Y~1o8B3pp-=~_7N73v@JULhqlFk9 z6T?Y%WROZ^zt!-msfpsth(<95FZ=jtm3|EF!{)gybVw!sl^e(r78nNy2Wc5}Bm|`l ztokyKc7Hy9XJX500eX4X3H9Z5bR=I|(zR=xXzSgVyiWmYrFu6y0<*!41U$^{!yqm$ zj$gTMzLDzi%j#+zIH4VJUe>va_2ScE!iS7Jw&->MwXUI zK|z(^@1yVcq?DPB4Y?;>1{&NL#U<=BY(4KYaAWDJVOvgk@B&UB*hcnutByB{7O(4Z zj*)L|xsbZ)l{W zj$WYH?XA1pj)&%6GCmZZ-H_pVnLV3Ku7etr zt@jiht2VkxG=s3i!^@jJX~03=vqFYOFHs?Ka{d-Tgo1)|nwlYuY4J-hjgG`XO}Qu` z<~_DrN;Kt|%JDo0RppQKo{tOR*d>HW)wTeA@HeE-m;}@yEwp zH10hrSxi0t6go!F=|5N{ibtjDC2UjoDUTD7JQv=0D!yT1gWRhp)SHdt`Zp?Sd*BKJ zdm}(qUbB=_lq{wjw}PL)+OKu7f=`^Q8>3Hd`oQSS z@_K~-UeN=*2<#I8+`kS+G7&^*W3sY-BIy`W>;%pN;9vA_c8-JcgtlM$wK2=~6QABg zmrTH;^3te~C~NCV(xa-^?FxHs_X2yE5`K!XzK&ea+p_Ny1aO>AoY4Dc_aRJ457uKM zWeY;K7Q^V{<9Rxe{JwQm{@r^Ww_x`x#eqnr0hw$#XZBCzUOWuxWz?ZT2(6krI_yzG zX+^|Wb_uK4{7sq|HieGAJ86p<^5cm9uYx3(GKk+Lb}%EUL}C9C5Qr(r8}|488%nxa zKhve{!!5{1eyP9k-)&bsGgt`G5#R5Z{*T{YF10xaQ=n*WORilj>yUNxHM6flagBB2 zjo8=ak7+N45p%V5b!R{P&7=ONFY*e+pIdZ{jPm*dV(!-E(k~bMQ0y+A@v@eNw=n2| z<9A#4ThWn`2IzXfx~%)}H-uz(mw)9EBj^|8<(&ck-YKl9^Z9smr=xG9XtMCTU$H}v z1(jcTkL*-3sg(GkbH`5PPn!}KjGB|1~vE^UK9gAV~ zg^Jgu`qe8ocJ^g?P)vX@Y_)UW+7S2eTZr`?2DaQ{`tf(}sNAUJShvsCdVzXDCs+o$ zBA95swGpx`zdmkW%3A&)PAtTq^sHIPPn6vIqCktx$oK*44CBuk<84oEufI97aH~E# z{Ufwrx2{>U28IqF6#oli`896!uUrXIw&T{%3ctn#CVE3-RbMB#^b8El;zJ{O{<)he z&%b-whr&;cJc$QPOs4g7shui3+YwW;SWO-n7{E;w?-==nTJnTgMqL0f z#nohr(-UOaI7m-PBs`u2rYP>XbfY8s!B%qJd!0xSDuIL_Pv-QFl%0aR@V4#S^QXC= z_?QW#^Lj^SIg!%b&KDqKIy5YsX!5n6W>oyoK|KcLiT(G6L^&IN@ty2UCE3_;Um1< z+`E3l7hy5qVC^`4DYj%3{&JdAQJ)nIpg!a=U5QIPQ zfvuaHtUiZ^m7UPu()ho~`yW!-Y}cl8CN43!U?p|X`rm*w+2uGKD zFCahM`(CZ7@T~Om1PV*^L4qsTHhFX4e{NX5NI zowW3V1s5BJF1{g|x^STa4y#C61ciltdSCx9ie{?heE06%g2F;G6BF6)hHN$C^ zP~bgt=1iwJ)ZJ87O9~1IbVn9^6HA@%%)MqRIZ4w$J@Ak!w-$3IZ6&^Mgzu=Io0-_; zWyF5_*|TR@VR`YWlQa?GKwtFq^-;VT9X|XXY6~#d$OcY?&>kize>sw+Enda@DcZLO zm&&r=o4T={(vCwnly7$<>VwjU$ahNmq-SHf3ZB}OmUjlFOEO5^msBAZb<#b0#7~9^ zSEZlf!Gkob?o8fU$>&BB5fg;r-b65Sy#bYDXn~)fztpTWCO3Bs!cF~$P3cIVn2sv4 zq-&THi@X-fJRgR`F+?!#pNJ|INzEbxdT$3#u|OI)b>|W8N(6PM26&__ZGT#nbqV(C z7?b0&3QF<6=*4AhvwG_g`;%g0C($23B7yiFE~Lo$4w3&e%qfQC%n%fpNhx~=de4ab zE8M2>5!HA=3kT`XCifGJ46N9s-cK>}HZ;aQBFb8Le`n@R;b|}gMRB>f9bBmF?UNKw z*`u#Oi~&_JLk?xT67`8~$c>S7o{Al4<&(811yujqzI5}%Zz31uLSKJBoWd%4kYmd3U)pzLOsqThJHSM{``?Q2Q?yBeH#>~C5?G|Bm^ccC&?UyiQ`{FFC@q(k{!gfJfO1op=zCNKmEJN8>f(J03W& zVlmY$L$_nE^ZOf3X=bfwha9A`POaSD>{`9y9t=2q_TARHfQD<$%a?4zJNaK^XPD*x z*;Pi$G@;5>&Jb6DSP9f;66vx-e+>kchW9fYW$X+LT2m)SIB!hmC$C6?iCj{W&&b!8 zil=%I^lhL+xiG?Uj>ag19)uFNQ=uAWffIEyX7{(YURe1;Pd3W9fhSDOYhr;g(wF}8 z)2q)hdHpI0v{qy6;VZ#mzF$ zaELwMG=IC??wp*&k%z6G)>~S>7LMj9+8yb&EK2HF&7I~XlaqN)RkOCTGU(6d?4u{h z?1KQo(V)>H2-?pwMXcF~ym5mPe}K3Np$U&K1g^;R_SkH! zC~tjVTU#6LGQ1`msmw=dmoBE*1ie%oFH5=S)Ee~Cb>U}2xm{dL(y=dOwK&#w5s92) z&u0X##Ac3ii#;a?ieGp+T$Yk5nYfMldgr6+6#VSGg44ZGF+BT|N!M``@2T%!##iQ# zv9f;7J(iN1nh%KLPhNq1>((+Io!Unhg+ z5ZGZqkBMN24&Nq`%yUvH&wZSP6E&BrQL7Rd9B%M&9Z_D3=yv0=^_Tm?%3k3Da>0Mz z&mLN-K`vt?Vr@8eSIhh=af*oYFC__&$5~@!DC-PQiH3LY&|vxqM2KVEUR=tYB)fVm0ii1PZ4Y&pn|iaXB@Q&m01EeK*mMP+64^S2Af z-ewyntfsSl)8>6ISld_r%uw@8&T76eWzX?r9RecvDB!_(v~|94(UgkhT6sJ2-Kc?T zgLu=1m`(W*h%(QAZJ=Ye+Hdevx>f(S6X<_puWp-NRS#fh@x>b!mfAdZY%iXp$Y<>x zrXy0@?OJ(tnR1|E=o_M2CQVnvh=h?_*B<}PohLCebccii(K0F5S06)XHb#h3RSnB6Lx3C=5#q)BE zWB`Xb{o|86E-d%SGbW1<)VR~1es72CM@$f)+j{558m0$#BrM9(UQALR=cjUDr95x& zIBf9Ri@eTaWD%k4z@bCyh>fb`J?3_vZ;###28IKHtR(OZbpqXX?ee>PSsUN_rjh*O zjpOKC+SOOn)+W5q?+r~l)6PJ{lA$u(FI_aDlgzw+?ie%Vm)yBiNc^+9%EWK*?E-UC zKc+_31!s*LU^h+bX6l{ z@T{y>7ybp&8=1+(`>=L~pcJ@^<<#cHEJ*?@VSw4F2urMSQFZ>@!q3?3{MDAlo(Yp9 zj|GbC4p|mmiY9soImeZZR zA6?q`q7Lt@^YEB-n{TZ_dszEf&JO5l|3fDX?-wGF0(NvA5`cBVHhg` zCB>O{Gk+E*KL|jC_hjo?US3{>r`8U*srs99QcFry|3p%}0+~`w5?ku%^rP%DCtm6h zkUHM@reuD;XYR$d%V+)G=ad@@Jds8lcK!Wc`Q*5$r0Y>hUfbuITgOPb7q6su1)jFF zkR`&2d^=b@2-s-0Q}i%;77JgaO;qWqU9o*xSy)CVCStB$Jz!{f!p7w!I~&{FVDfDU z5khLFTS>gC6V7xOrSAbS3Z^S&H84(obyZp*!iGxHN?T7)uk3Rs?v3*=OU<_~v)YpA zEy&M5d@m8L?y612QHV=lbw1#ZMrt<9BOv}5eVp?W;Avgp!t!JG=vOoA^tIbZq4(RR zbEz$8Q?HHy4^L$*CYqcBV)YGjk+F>412$R}_bPS-`PTWDm{vP#Yy14{l)6)VT-@+I zkni^x4jyK*mrh(GJmztUedXRtlTaOHxJR_3L76cMegz3TVrZx-rlU6 zO<+Ii-1g@7cZbycLDk*5&lbieie6lr6c)dy{Pbo_iv%7559`~Q3I@;Rm%f2*JImmIp=TZ0YP{aa%NU@o|W}UCW zHGGdQm@d@Zz~HCLmgAsSG^H2^GUx=aR&n1n-u(EzRQ$HFV>J!CQ>D=iVO9zIU5yqC z5LPteUIm8~EFGa0D~QmGjPk2&8Ux5w7N}8lUixA2htI5`Vb2+V#eI8ha7DxUXlc1e zKwSt&-h_Vapi0sCNeR7`m1F3omy&6fJ;xMK4<9J?G+yanv?9#AOf8C1tlmyME5fc& zR{ru3q)bO8ws?)2jUMX;wh71xI%gS>aDDq03I-qEyczoR*hz%oZek+P0-xAJsZJDh z6pW$F%puER{bY}HF{{$k8umomo*uAyZFvboWM3J5-N5bC{Od?gZ}tA z;KA>tuh8mgQ-RJxRi}02$*gRbtsz^8;Z2!7)7`PE z8p43WldoR&V?LpxF+bg#oYjYta%?lng03HTdw4`dUT!YNMvgb8HJ+upjpxUvFfTl_ z>0J0+YQ#3$?oAsuP__5xl5t>f0y17h?vs7bM~*j(?B^i3AGVu#I_y{uF@lNtIWJv} z^HaaRTv2U`ync2_#jUI2R@pVL<$EjJJh>CDsx|DD*JD>YW2CN5lS1VpX?tLPxRchZ zzkxEjtC`Q3?l_KMiKB#fe)MzRj{>(Zi8pVuV~`LT09ao@1Mmo707;|B*}C;Kg}YSf zmjV8MhUsHw<=c^MB7445NtI3BfA{AT`v-Zg_wKC%^NY>lO?ZTF$hpgMJYj4e9=6E~ zvE!~?Cu^!QsBsKBeNwI_EpnYyRZssxU2w;&>+#u3PLtpusQx^A zTxwKYaC*e_#uWv36Whx%4-@XnQ zu;+SV@5DvN$M=2xy7g%N8VQMqXbv!qUVro(mE)DGc#SH10@wI zae~GU%HD8p!Z%Y?ad0ch65C%YA=nX@kRVC3Z0ly?5eEmQ9XoIn)6vs22@@z6z8cZc z$f)b+I>pmd#n+8R-iYl>)VqId-A$2TVMSGwQ-XydzYpji zq|&J6+-#nLL5m6h{=Pnd0VQ~i(=V#3#6(5i_T56w2TyK;;kQ2Y^g)ofU}+d@I(hiv zrAthtmr43w2(IWUQ*$^t^acb#M2l2cr@L-lN|Lgd=ecu-PyIMlJ$}ckvZA66C;;RD zaIok|VoXv(qPX2pvpEcf>)mN;vYonNwsP)FPUvr5TmPYu&`^lrM#aQ@aPS?w^-Gd4 zARsjn?ZQApORRu8&<2Ved-l+INq)zsT&Y5)+qZ^+L`};;wcGfS`4h-DjI9wBZG;T# zsZ*nU9u=)4*TwgPz-X?g_XF9~07-f4*27Tb+_$ec=S@BbnSVDV_6n`|IFf zF;)OYxOyTXB3=OUaFuWK-0laJR)ylZ`=LZ5rZ3MBNw zP#rz?z;fGIF-{~RDX?*r0z}FA{;sZ*KR(Hyr<0_a8SVwY0J#Xg*^1A82akWwV^b_W z6=yR8a^+R_*e%sHFzrZSuDNjWB5>=%f&%^pjW5^$ojDu$VpKiHLJVp04aimC_=Ecm zghND>kFbH`LiiQGYowTZ>n6^yha2cW>yv0SLc_zyM@GtxG&FGKPjj;PyFYjjO>KMy zw589SK3$Pa(qdV1zZO-z`u@{Y}$BQkfZUqIvT;^ASntM?$;)w0R|M}60t<(d~8sRIV` zXNmhXStOy$B41P9dKVSbuj%RAPi}mk7;0Cwt6njYiTO5>QA|_G5^vvjX)g|!wS+}| zQP&OS`e0EiuJ@HbQG7c0^>5a^T2Nh>eghk~dLDG6i)|{I2S=b2zR4u}uD)5apQtAh zvH}r@4v#bo2%Ow#-TRVGceg^rO`1cdZRcXzTlmjE0Jl?ib@F%A~aL1;0%0GI|%(4dV#=)i=H(B2h~E}^^oIEK{YZrsq= zw=X3OopqTqNaYzYA#a@+8xw-S;aCogK(5lP&dtf`2TUR3HulY6y`Mk$y35>XNVMyL z52K~G`!Le-qfQJ`O^o^)0XQc%w4ZX11=6i~iy|C~@d~HE9T5767Q?hp>{V(OUH`1o zV)VAkwj<_D6+}jItf}-1qJvbB5Zs`>I!!<@1KRj4_;_=pbjUJa9BQG@VfXhXI666f zS%-9_$q(X)y2&ax=SFg6O4S4JxM2Ej2$W^NtmSS2w{NfAb`tn1!3&bqd3O=i{MO`& zW0Y-tS7}=7pv9Ha^0hQSBxMiV8^3S7#kGCIwj1Aaw%fAuPTGoqx zED&^;Bm@8>pkeuP*51Ac0#ed|=p9}Qk*R1;rO@)WC-i60CG84FMrL3MU9f6~)5OVg zS6zP|KN%wZ;c~Z*^fyE>*Qgypn?P2)>dRZ`)T-S>Df3(ituPH*$`0+TT zi{3hX6CmAZlM>=8b&{*SNB!c9#I}d$#?sRBeQ`NtDN%~3SKI{tU|CC>(!z5;MQDv$ zEy~KvxM|NEI8cw>3kX?oh=+u2^#cM$fZ%{IniaUNtsxvZKtA5QCKz%3w71i%Q3h}VdxAr)7DWFo-vWxzVToSLp`sw zDyK8qARFvsOgWS>1gZ@uLf6_@72A57tSkp7;oC-V$q5o6SM)_5u+bPbFz~)E_{Apl zm4|%xMWmBbgn6&7$+N*)Iq8CymuE{718PEKwOckkm$TYen{Yx%RqL~DubcI!ptDcX z+kJ#M-3r!FPND=kLP!x>{xpLiIL@}4mvIUcK4w~N-@g5YwrqopKN1W_2Zv?N!_=XZ z0#akSxL+}_xqOOZT~y@*v<*j*WReq1&9ZjWCOxqHG>NxgW48QfI~v{tpYyMb+X*S- z^D))dPfvL81Au^uen>=w{q(J9-0$RODkB>k5$>QyYTXv&iIlfsKV6{XjR%OvrAU;+ zeTU^_Cg8%x@LJ$SR`#7IkIi(Ze`dGh@_Fj)^_9@A^^1WaC(QoMmMwRVwdy^-uiyW! zDAsKFr^|_TZ(37xPqVo_rQ{g$`-s$rD0}(CFq%+DZ)9Orrmdw_R-Hy7h5anHrU@O= zNJ*yW-*i3o)|;xNWV>2Hx?}Mzae8KIVX>w!5^| zS-SfD8k?LPLaK%pn;`kJlYX1XUMxDmtW=BhiJ~g-Af9%9uG%@qy9appuN2JiKdh2ce} zQv&q3oEzKQ1+xShg+Zq$@Yd}!F(F0L){CtH?j=KIj;eo6xnI`Z z;deS$Kf}xYbH!g8Q+f^+O@JKty>h^LFd(@ZU$ZcE_8Tyo;2r|7F@G4B+(<)Hvw_|s z=VCF+thX5jO*5l7BZ{=H?G;E}%AjmX)Zl6V+0`^&|EEPf>?GPAtaOKo%gf85=TQ)X zZNzR@9o&YcoJ@G8=r?dn2CIR?F2K_vkMQh7xQ_i$3Qq7Q0FpJwh^rmyjY;XjBRAwY za|U*C30;^L)KgyoQcJDWjE%>^vGjcKOI;X=-rZq)#&%H>#wJwMVV0)+Q{xSDQh7mo zV(;m?ceqPX*ac~#d$PW1F!l>jwRalYY(NK{ExVzwjrb5rL5jRVw45;XYmpq8+h!YR zM;@-^#Iz>Y>Tu{-92H}7DCFPg{(av0fYdfUcxOW|W#DTPIfA&pX>vq4b=TN=o%9R0 z6(C>OrS29UBatS>TjuD?!5et_MSxFXu!c2I2yw!d$q=f9rNh-;PB70EWdp=1On>vlt#TEIG|4kw*x$#zpo9IyyS++nkT);$~w@g>m2=Zj0>h1wxWr z>gsDSzrmSDKUNKP4N1sIe(_@H39lMD4=Ua~Ud)v#uu{}u@*^EUn>9J#oYzJCK7S9u zXS6TGiCxB3Q#Jm+=7&aK!>mG!n|{0o46UyR#J6r8t|n}a`8Bw$9XO>Fjj`{NA~}QJ zBE3oqjvQ{zHgu2s4j*#-9*}J8=U?BS{Y3DVnU!lttI*O_IKJ-+%#`t+TLbSo;XtKVk9zj2;xN2i=PsDn+ zRg*LI;RWTxz}<7pY-SgmpZikzWr~sM+)-H9ch78Zzuif~sE>X|f}~_eN~0-YvhK}L zknW;65{{>fkB`ScAL%sWH6gP+R?#wN;-@V5zNp0T@MNZ#eo3hAgrMNH-N&=J3Sx!S zSFEg-PQ&fSt3b28!eE4B$ zwM-&P@^!UJoD&Vk*I3hMO`&DH|8UM}Qc54?vGS?iI*2l*&C2@2+-+-Md|}^lA8efF zZ8bGJ@FduAB^11T*`@gr1KCUq8%xh)RsrLH^RL$GPvsg`$4lIpxc8C*@rg*w zmNxERoN$r{*czhT;No;4d;aQGVR5mrpkT+II5QRbyREKy{bCoYxI%>wyCi4z2@!{T zoIwf&N9&i5zs^{7IKbZK7!R*wvd*G|76d*8rfXLnM%rqv!$A)sIuBOYg#&dwPo}M2(w>6_QUd!m&4BqyR?}xSBP>;FiWZyJ z+41qK0}i7d6WRmPLH7O&t1<>!Im3k>m@3)Sd5?qCs8;+}Rl6U?=`_RcyOPG0?2rIa zAP6kq0oV8*8_YmUo0*yUV`-^_81eOb7$FK)sds}S%)Y%UuK9MHlOVSyL;qHMd^X=D zyiD)@z+n9|xO97HRqpDfCs(VZ+VV>QL?W@cqutn3e{|1eV>f@pQ1nRW1%+UE_d4Kd z+rPv(IM}GzuWw(kN2gE(of_v-1krkuPm-tpC@xR?QCxp=K|3ND{%zE^bG_o!>P71F zwNEY1umMk%p}_lP(4dT?G1+< z!o&oqSlk{t85HoR5;-ZCyxhlFw8AQfWNtc+$pt6-o^tp075aH4P`<8NZf$Qfv@sjb zwD_VF^V~n0wkEJ@Pvq=vAR&15cK7yNs7!yInd8)3Zl|XwwfAIjjx_p~?c&onksa~| z<>UoSa?dgllL6fBt7F4$R>w<^AW_VjP0Han@N4J0qyzU{*U3GTtqYyEA`b z>^2W78V7m9FABPY-+GweFfzA) zi}j}3;49ae3q>Exg7*4^qcoJ;Ya_3+qdqyU`x|SvJv(>b>gOdRBq1WdS?$pyQ>MO&dGgK2DC3?XT%VW zBFR;U8LX;LLJkF;{~0V*bWS!*=hzS3`wqwk%rL|q@|*e(w6>C9?rCT&Ks5XA5x>?u z*m#m`aR8YCdg5~yXa4RynJ~Tw7HuVGaSc^pp~f$$T?Q@04C>H+aQy@<-4)Zd$cE0>s^E?R1CH@#~T} zS1X=sRbm7Jj5qcl?CzcoY$bSrp4fkQv-r*gEiu(RLyhzqziyw}{K5NcY!!~@tXD4_ zBMm$+%rE=uc~SSo!HTHe|961^v1$EiTb^m7hT}<$QcNMlFInHOOJq{SVU*>ly4Lx1 zm@w7r`Xc>a{aY(1^B$9-*_E*HgK+R=OK?U0oGtV48##`Y&*Va*!-qc|oP;zWnXC8; zGIC##7sMO;A~qWe;ZT6*ES80VeXm(q@-j0^plvoQLjADG&CWh|;esU06fhT| z_hQQq!xkRE+zmt$&3pG2do#m6eL8?YApBG4+|*P?jvRjEmA@bD66Qut`iA9j6=fDN zV?2)ZT4NiVlOrG#lq4hz6|B@MZV^oa#eR_<{#Z1;1Y7CO48BDV?l3{J(5p_ z8P(0HB0Acm#BfPtzw{;z64SeiuAQDfKDo<(U(|Z_d|Vp^vbnh3Y3%krW~n;U(-Xez zo~fQhW52|*hS-<+149+ZKZtkpUf24DFO&Igot(4WLP!N2JW5_RoeVlX<{~BKV;a0{ z!SMT0OuDqk@6=$O%_?)J&nIAv??(O&`mp5a_v`E@F_vtSj*CMjeK*L}I+SAc@d{kf zZ!G)s#Gtz$E+HFb5Cog!%eo4<%QLm1geZNV?J57R8>`T^YgKwj4vwlDY*9;0r)>0IJn*j z*0<=5=2MD`H*Vhi47icAWQ)n|yFVr$!bAp*5cK9?SaIfQxrfd4y`Fyw@L zd`JNd-m0L}Kx*m)z{bdSZ>5pDOgadr^uBX2Bvj%Jd#Mb_72VN;bGt=}fNlaoJeLf4 zOjNi*X8eP#++3x<;%*l^zOp|Rk}K-jfVQ3#ltB~3NU^b$V+{`z5~r^Sy$;NZ-G#4B z!&U+Pd42JBh4#;w9a5ccLJD`t&iuG~#go1 zjIZzSYl>iwx&ScbFpzfj%dEq6;V|!VUJvysU+XoC|5ekZl5l9hm7JJ#BVv*aVL$pR z$wh;thDD_2!Cs80;dYw1b7 zLy`|>hc7s#d#;S)`+v#4TcT!EgDG{NG%kBq>P&eSD?^o#LYbkUn|E_}FE}A%G;jk> z3^1b9)zr>(K4d~N3vX?1Qn5>Ofh0aV`zb6vDbc|nAqS9W6x=wxGx0wjz$FJeqYV!h z0D+l6+Fo)h^%@$|NFd+4q~XYBjRc+1*-t*xI{-vIm`O!1UpA9-yqKahsM)<>4+zZ) z(AgrM!EfNa<{9f{T+mt{eSONg%Y=G&_%y3qfw8~-?OWd67}nW@0Jzo(o6d^@r=TGn zSQVJ=>6H~@kYU8C|K|wL{ldjRRo-tI()ICxpVf&sznz!e>2CFX7Y%#K)5XdH-G)hHx>2t zu2)jUS~=Yvx&;UUALF)?m~n$hn3NY6+1|(nwiD{2oNYFi9tAum)=WFWC%UPWt}tC% zu?AMwvbNhc3MlS|gyMFu)sd~^y~&PPW|tLZyl+g&H6x4F_-rCJ=$kjbjgN&geH7F! zcO1W8_0h5ADdN1h{_hdFiaXrM)5c!8j=8~K*-;{Mpw#TlHeWK<)pUlj zf8c9dXS>i5L4oe#Q}I=6OCE*5uL)FlyJ3x#k|n{w8=!e)i%*OcyWc(Xv59kc5l|!f z-tI?UaxPoKb2#~m&pGCcs%;1ECBA$=ay}4Mn;)mqKsrP`5iN;|LkcHt-JRvWa)qUu zg^Il^rxp3Y!rqD<2_v8jI)7dU36L5&BLX`}UfHwe?4%=LEG46$NP7Cz5OCYgqi=rb z;Paq`Weyzd|+D5&Vj{BrSwIXJ`Fp-@vxONXYfHH?ga92;9^!p6o%L3hevwjY!h z{J!P&+xPDUczGE(IN}?SmidfE@vK819oTFkR4=Nw=r|RxC2%_z8@<)ZAq}>sELSr{ zmI{|J0bduaPh*09d`5wbHoWOoz{;WA{Bpv;&Q4*H!IYeoRO5dD0Dd`i70vY5G$|j& z-f7N@$;>o^$+ed;7g={&TD+%wW~h3}c4IvppWO4bwN>?X>L%x9q2-BMwzscE%x-`+ zpX~8Jee$;=9UiMya2y(4H#y$CVs~uWa?ve#M~sIUN$u|LG0cGI{nF%ij?WiYeWoSB z8WSqw$jhs)t+VvKTI&49Zj*}t$9<23iKt_Zr2a&1(pzm0s5urFe}%xc#jUzFUxM9U z_IXTY=AON1C~G1y-j znq=5mgERr@~00LBf2 za>qgmhCts?sQtb=0k?YXalcr~)n60}$(6=@yAjIN{C58gyZvM)zGNPZJa)@xZ<{>d zDysOv{&{Rtp&)Yjw}#n>lJlqV(V}SEr!Wh9Uu*LU8c^PEC9Ma`_Vg@D)WY-|V{H{dm1xbuEwsm>!(;NnHhBREr+Z*-eGgzRfdH*apQO$Losx=0)O=e6FUMlP2q zZF4Tyy!eUN(a?bVIZyv_$x)lK){1*L*oz2 zYzQC%Ox?0xD|#N5j2lo7i;b%Rxf}4xcyl}u)jXjh%aov7KQ`38cLptc6uS>s1^)vb z%;G>{b@i8s!8xa4*UvdUu3bz9A}ASQf1efQMkHZ4EW(IaD9lK2cTBJ+T$OO{%@9D1 z*FE)2Cq{+~8xK_DBCq=TvLuwrTD^D`Ns%8sx2S7m;CU_tzaa29`|higk`MOQ7xACn zZJEhY?R@5sr)&N#EHYu6lH&8{D(ULVx@mh$XjnH$D~83O&?vh}r3%kq|A{-$L5J`; zT+Qj^>tTFhh~~@JaF*D)b-TSiJvjM*piR>Igc8xMVxs+c$q8j8Yqm%8iRnOACcxud zh*#}fD~3ZJoPyP@G*5u-LObr9#gDv2Jqg4^C%H_l5*!^p$#WBP8EeupaIh?f4E_qM zIZ6r&uq$&RVdTK3(*g#g1=Qs-Xfk093d>+<6HW~Ct4sm~h?is_F(8We96dd~kWnS3 zIxPDpPHt+dp{gp$yiY2AlOZ77?(W;Lf3K~nxtlHOmI{2Fnp8&n_88Oj}x6nO&KR^694_ z3;iAG{`itCUQ|X_;!jv3K;?`vX?JZ}MC%OUAZ~sF5PW)J!5a+zaj29OrM7_gSRW{3 zTIeblvpHP`IWJJ5aZG_1`&(p$zE%b*`RR>@lIwhYk;!---Gl=WaAD?{L|+);?;WH- z!bY)x5<@ri5*^xJs!+gfhY>eRT3R)WZwoKxF-i2y^z^!dJKG1Y!?&sf$Xx6G>%R0U zDA-mn$mO!k`oK;C(5+C3+#{!zmGVQaD?`U$d502#t+)r{NJj8N`hx1hRt>-AvpW3q zgZnp;4zl*;2dx!%;|AEbjJ{<@%uf=mDfX(Nr zE~?y;CYZfed2DeyWUfmE3ZgaEHM3O?2?_3K>nNT;e76swl0U{)cp#u?raPs) zKg}a#8*EJTui%k~Jq6eUqR(ah2+4oHgvH1LPM<%Fqd4Ts`e+m`RWWlUK}h&U6KFrd z@FmPV8;6mMBoEpR709TyG9xcxVXlYSp-qMmmI}fx+Ph1SnC~X`0Epz}$S%YG|6_+)Pukt`mRTY+PPEenWP$4AD&48)EAEdLU%UU@D=%Pzz5Jr_Wr-XZ7*%uzr zz_x+1;V?gFh)x@#PhPbKhsP1id>tg1F)abG6k~IQB9na3m{=n7!k?{7)f$%aryKKOy(B-_E&8AoV zej_7Q(2ketJCaAe*~D4WX&x1G`58g^bakYB)K_Yc(==HoXv1~pzLWb6BE&xbYht9Z zPjK?dKL5bUCMV{0pr%okLuAnCM>+SkuNF(YXNO+wr$+nw62aa8C#HJX|8goZl2BL; z{U&#IXZL-o7sRYzyi!To6Zm=phv{pJ1KjV0^@G;$dIf&&R}6E*wpZ zi=6bawq{G0`18%#gRN>LRbP108adVsU}gKTHEHDLun-~Y0Cn5AY8N7{1mL zOzqDo!{TF3s%vXw;|)*~ z3Gs%I9v3{EIE4e|qx(It1K?P~?1vJ|-~@B|g*4nHpcYWG;@xpupHcv4a8EM|eY1|Q zk$nHWzzXc`9UL8txIl3{iZ%9K8LkhKs}c&1p;Ua!E#*xZ>FtH zUw}^pMkL!XQrYam_E}Li*Rz0@t;T6mcA0R22*qxj2XpdkxJNXvZnGzyjk@_XGg4mL zh6_|bmfP$qDk_%o6Hzlbl57hP*B%G^$>;8I`ke@%eWR(378xrsTPVuu*kr@VHo@;W zNZ?ObyB^OI@Xnnc)}Jm7)P6yRy8zbEn~|;DVH#Z@?e85zSbn{&+px4h;>(^~ESnTZ z)_WFo;%RLp3sHpFCl=3@0f(=2b_bU&>KTx4=bW;$EQlzWqr$KH{>~+XiT6ze1s2+f zd6X$LnwUV)RunsnTLIHI||gFkt($;e<_@J}`~ag0_qsZUmU`zm#_2 zQ67LcZ@P|HjRwgqdRg>NiueOqoPi=m$fQOZ7y+?C{%gAqt(Z_+Zc=Z&P9Xm^(J(=0-hc9>PPiphaA>Bfci( zdd4oSQ?{&uE_pWkeOOU1K_aoMybQk3zBE3gB)&-FP(qh{`DwGy^BD+Fm1oqx7U4sL zm<{GvGy}lG2rmd@$h_Q>c16tmGYRt&aEF)8&U)5NOA5`GoGas9;Am9=X%Il~ND0~Q z0HPR~*?5W2Cqsd;znAaRNaB=pgL&G_Ojz8{LNogGJ(hy{lfYpqUnKxCP#2!@b(Vk! zS^?osi!XV*_wVfo{i#4Ma1JxLVZKkQs>GH_0wo-**AsaVlwV~um!!Lf5RU#}?l5H3mJq!u3wZy` z#H_;<=Ehe`<@VIV&9t9&L9f4@IK5iDw8wJQ;6d^$<7E5^x8US<{DRU7`vbY)a+_N} zI_@F(0i^PDeLox;zI>H8*j(CeU?;U=qUI1uSm1Yx&)9MBb;kOmpkDTOF23H`h3KbX z4RlIeka`^>0EPJiF_QNbM>m;JFv#}^Vcj=>sjuAQes{{*k5bc{-}hZ+zUaXMB*md@ zO8nZI6Y3HYsiEEYOi{HiFk~p94u%r&MQ=nJ26*}74V>dZb^XLys>MN@oKP0{+;1&| zIzQe|tif6>unWI^Wm1Y~)MHiBEiS0b;P#}aAQn6PCq&1{$llH_M)UfG3lYFFh;@+8 z!KR`sC#4uSkWo>AwY;;7%MW};B2wV=Bj4QDxr7JT7)|7!3nLNYK4GkKu8-#q$yf*< zf!|rS{SY>=p`%Z~bd!>qjSXx;o(J%y-LoF z9KjM3ZMN)l&QqPtj)IJ=@evm{``EC|&21K0R0!(=pK4eE+Vjp`4G`&r(L@`%3OpCM zLkPKU++BWfo}S%YUP8#=LlnznTC#F7d@Lqy*tqyI6=%E$Iv||Jpkd>FY?`Vea8W<` zYyrh~T^~$UclDEaWMw(%6>s61>XPaHfcq1Vk(`XIvIoV@+d-U8SgpAZ<=lMKxhT{u z^&r|o#FIFq5RCePJc9o9JUBd_@=jJ2T1cGOuo~!VS1GP?h{PFF98!tGWFR}K{!gZI3cU}WLc<$%V$cDDQzNY}9?SrLgW=>9| z92){nfRE3J4xP?GU)%wWPsTU1rU)=r*p#V_33j0u4K{Z7@EAU$Ira~5Nsb7_QI&*_ zLwZe#5yrgcm>V)+4@1D04ZC2Q3wK@zmm7U@ed~+jR!_pa)R^`;;0F0FVVOo2aM224 zERHAkc!Ajxo`FNJ5*|*tm&J$j@)F$T(#Z{;XZ_}PGBU#uQtaAM;1@oU^c`Gr#;93BgxGo-v1u=k$wxeNClMMOnI zXHq%P+S=c>J$|wlPwIt92mG4n&c5Iryi-D}B(mV$&o3e2apzJY`SYSs;Rn>;m<$Ze zR9;`VYCn!lU>zZPu3g*2Lx=fh_$eDc-9eAFqwj1bIa@neQ^NdDIQigr)O23?3y?J@ ztkKTmk=*g1^8lV0*4rJOND7RP1!lMznx;O$)|^$(qZTK|Cv=aIn+%}*rlJRz>oPc) zc{lie2f-Aid>b+WJr{|DP}{F$1Fp851P9}s2bvVTo?NWX7B)6f_QQ9SV^_~y_y%d z!}$ypu)sh;5Mg5$4;JSogQ3~=4YzW|VJh`Z|G*d$?jUcN(Fb0&+kj?-zMYZ{%YscBo$-@*K+USt;QI$#igVsY-#Tr%gXOy>(L z%g#gI1X$jh*tYi0@Tu$79Oh*@IBzU%u1B?UUiIiJ-ziiOW4RXDRqClwJZ~59_c6p! zwqRLE4@DN;>Xo2fGozpY4-|>Y(BvmiN+FX8aGF?_*t61R%|qw-_=q2qY;E~ak|CLy z8t5rn0FZ$>bh(OZV>Lc?)@>7I&`vN@fGVXC|6Y39hV;wq#zzT;gcS?+kT>`@AJ7A%~Ay$WGP zDuN;?Zro~%s8E!Yf?x(>*~5iN$cXuh>-m$LZWdvhS2U<>8Pcm@!6ZTbDI1|0e9~KN zDrXtqV=fiq_!u)e$vO9%4xLC5K%ICa@2gHFaTXC3Li}xN>S*HQ8OpOwwloqpb>@M#TZR&OlLOHEL+AByoUzD4@NHqRfKXC2Z+IeN?R!hld>F>jm<_FtuoD z^+QOalEx*x3H^19O9}AF`rh4X!t_iWt^W9d>-@oPkjg%kE)blO;2I6SmMgScK~hhE zm|cf3Y;CSR@e089K`zA(DF}NKl(`NXq_d6n&LkGps0L>m4&~pAArQ0ay|bu8QVEQi zsTg2JA%pLng%rKp2D-WtyN%XB)s}FYxSmMfPXwDq^J&XsCCr!ML;9gX4$Xg(@FdRh z^B<(29uZ$DtDxw|K`vj7eD&(AE&(!wO4Gm7LQS5={ltKn@v7MEkQAV17ed$Mx5Ruq z^UWJ~Fc@29KzxvX_~lWL$-Cfy$nhOz-Me@1B13&K1Jkj1TQ>Aa;+J}-mu}GWL7e={ zbGWtoW2mM^UW1Y$yHfq>6E3oq@wU7c-c`^Oj^1mfOkV*C{=KZo z41?*JnGn}!W&neOE);}%gnses7;|AerOY9<9D|Scqyj(63T~EDA$E7D-Vitp>vay1 zGoc^WZl~drGb^1bK$c|5@O8eHVf)E9Mj0W?eV6{B1Q}gqczB6dstz?`w>cCjV!R=FvnpVR!7DfKH?ijw-$x4XsH3UujK=tGl?<#lIZnejX*Dun4^7UogT*Kas z?d#;PKo6-}vTDAOzquZOqpNqvjuQx^PSFE&PVB|bo`1IKUZ|3MUD$Pfk&bgSKZiorl@GdC)dEJ=H=(dl$>EPN45OgnQo3bFuB$565ZFCa|`w8{HvRtgx25r5~n)N-de&m-Z72oqDe+J~5cI74Yo% zs;JW>N=k6J$=@`9IX|Uv`VevWYg*X&R$+4!$zdM5uIKKn1mWaR37NyU89g5lr5r?@ z9&ga@3Wk`Ok-%QG4#3&hDO&op@ky4=r z-cJZxg0>Ep_f$0l96lS4KOmEW_1J*cFkKwSPSpwsc*U49A95UL*>$E%?Nl)HbBk5E%?8?qRZB1Y zALH_^)OP~pW4xAMz(EP{`ur}S0s4|xgr?LHTEo6PxSo-^P6Dn&5#N?&o0VCpAoj?3Nl z4UM&riBIE+ZR&*Pr5uJw-dX7B{P|K-Iy`Mskv}Yx|H$7rA|X)%UThba4G@pSamZ8w z2>`A@|Kh}XJV9Y$us}0b1*T{PkgmB)VCMmi$)Oo=8w=*&0YBR9qN@zv5>O0)+_CW8 zDKT6vv1K!(t)t%Ty>w5x8)w_v#i;Wie)Z~DWe!$+eB6FRJuU061Xq|Sjq{qcG-Svo ztvrAoSE{s2Rz<}gbk&gO1xj-_aDf5sGBukd)-(W{6%2I|HtN7kSPQ%TM}DQYt<>VO z59?S;Mr1B1v@98P%3ZW5zCS0tYrvT6*z}T2s@QR+_+x*)t?i8Z7SD^*caq;eP>O%> zTmkLDbu5pL7X6+)7x|$8E-=t1L8|u{7)(rTu^kO(t5Dy$)0LQ*7<7968Wck?ykanx znB4;>f*<0YO-+i*fuYe`96ENV(E}&q4y;<`N`^@}3sm4-VL|-o*Z+>d?v{aE34%3v z%+Y(Vrg(B~|L`xqTLRh_3vP`3vaOw8O|7ESH_hczB;$VV`>et?2(q#Me1l7=!ZzR4 zz?lkr0JQKJ{ZvhrbncjK#**sRJ<_cccfiw{QyP`{S!^b!fc5XhI?8+x2hBaSD}L|~ z?RBi12f(oY{OK}&jNCL}gG4Bd3$mUKUSL|^fC0<29Tu7aX_(X}YxzWoCh(CWd1?ko z&=lil?ZYkM?!yL9P9Eq6oE-V=Hc8j~04{VW%S5G%qDT`EbT@ggfua%>0hx-SO7ka` zqEb^d&!0SLd~RlBls2^|Kt@hZSfR20_9vnVjYb2uuA9z%H4_!Fyi-$yd#DN`4AWA0 zVH-HbFw*Cdvq0e|zwZso{yGXkD9*j$-la|Bwt4VC!XGPfTZMjhsCA>y-Yd3jNOodV z>&=1kbvdW7#)r`m%47ri<9{EM5GoFw`HrucVJ6K$>!HDfmCc%%1mdVe%+Y6{G3-Bq z%nv_bU#fj;c<2#a%_vsO)@lnqJHIN(wc^0kkD2QOim& zF08X$);ryQQ~$j%?0z>#CEu((_RBNf5 z?RowK)^DJ$>3&Y9avmD82}?NT(31UBBZ}o|0`nV?%D8DYUIazToEj-R`F)_Re|}DJ zvb(qUbF>jQ5+wI1o+(AtD1qnxi?A?!(^6pZLJ&wDg@m{`DxfYYcpQ+p4O0qNAeg?$ zQh%>Lpq*as9eXfPGH>``Bsb@_?x?lUXfK#C>{hS+Ib7gV3>?q&_s@0jN790g^4?^S z%3~$D?NXlXFmPD}27e74k=i51GuL9H>RNZG5D`v5R53gE#jcnn(R4~|q%-neoYz&) zx}Tr(#I$vE^acOxD){Gh;Y68Tkd*XXSf{lWV~R`r*_AamDdzw9nbho@MOVPPOTXR! z_{IJ`w%8LMfEVLOYq!wqV$k8$n&PO;e%VVb^+(Ky8g5}ui7x@65%I8#tw{d!I{bas zV7A7F9#Sd*q4$L@B$vaq#MtMUcX5ta+ufhO8#Y*-`=6FzI}`{{+73wFR9nOCv;RmX zHX-f4t6cX>B!u@vjlv~P*}ew_(>Ev9bo^TliHUoP5xY+{pQMzBn9n>CZQ*!&=UGg2w2!y9e|cuTU}2mF5*c*{`!?VE8ZkX> zUchQ?@s@`gm?hYC25@Pg^Dr?mzz1z(UQktMppR~qK9z-4AymHaCse?DOaavcs3wm7csE09m2Vp*Ro_6LaPm^3C@Uw zQnh%^l2TJMElv1s`ujz{84hWhfAqup7%E2x2bq8Fnr)h|g%CNWEyzywQFKZ59yC-fSPpCGMc$igg%5{{RXNq(*qTy0VJfXaMGqT~8_^jqzg~h_1?AbN=^mJ`=&1ubn+x zENzyN_GmdR?s&)OaH-nm9pXery@RdOHIJn`h3Fl8mtcE^^>I%jM?;>C4=gPyo(8#0 z+*_HO`woQ+uvJ%64`Y3OAGo`qY(QWOj}`E54<*D+P{1hu{N;-u40Hzvpj<9ty^p!k z4b*7WU!d~@D=k$jmeMq+&*a}>O-0!U9}+npU?1Pj-XbL=<=4xQXBlNd`U5*KQPC&I z8GoY%Aj!kL+Q-Of43(GJq+`AN-Q`z)+3R%23Jw7ztzI?d^PHN9btX!3uEIy;>BiP6Y2nucmdY&8|K)Ym_js^GV zAe?StVPUEsOdlX%_iroIg^RRT2MVL*7spzLxWU~4&tHWroiD4_JFoR^`kD$AE%8VM zC_#>nv-jz}KP3b_HK9a8G94J+)INKr>*^{>^aMngI}2YGwY0>5zAqv1y`cf?V*xGR zom;nl;N^pQ7G^+LUWU8{o-NGZ&HlS^`+^NAq+f<;KnKxy1bw)29BcR%Gdvj1D?gx3 zw=N-@jW{(hH00yuHLmj??(LOITl}k=p3Pu6e}>0;_PYPFHAgMBlBLL^fA6kb3p()!V`Xn81%*s_#Lypkxw(aT z!z=<@RJe~JTJ$kT`fYXfbO}2~4J>bH-U7o4>U%IHPQ>|6PQ))LNX;%S0zV)p@cVaw z--?{?DJv7nQb~e79F%eYyb!_VzpN2JirhbwFMk`r*n%X=S!jBP8sTV~H&tT34GaYC zuXCIJYk4w{gScPtR{74&Y57? zN)d>Z{I2)i5qNkW+=5{$0$I2)?h-T(7=1WTXc^U>0oZDg9F_C{NP~xLWjE{){cD5Y zMT0c5xD}fseg8Gz%XbRDZo4LZv*xt_L(?RL^feNIQ9yM=*@bf%-gN79^BxQAnSl5I zDIf6aiHM0UUgU8g(GZPDI}e#PLtWP%f=1+AWHFxLwQGKWA;Oyq+SNoD;MYbV48Yvn z{9k9FnCcGGPp(!qS>NQZF#H;3Qg8?105YQ zlmLqAa)`igm%;=lfJhCr&}R5FVdGrq&NYpW`a#Ov zKGQBSQ2{g?P>O(DmXw^Vpac&N8a!YqGRu~_{k#hwWdUB0IU9UyU=P;^Cc<14`Z`;Q z*M7Ia(S)~$7oI7sO2t`Z1A%}tB@7Ns2mkT2oQzNS;h)#F$(@~)G+&Tyr@FJFeHiuf z?l%ja%kd=H*tP0;|LR3_7%ES&M?VYHux-`MX@WR-;VxM8(cV3g(g)|M|K;;gBCgNHAU2 zlgE!kLe}}+e}jk;D44qfh}}j)bhK4RumqU3Ko<)O2_DMNWnlkRP=NT@!=5a|1cHfR&1~(?cHMg&zOkVS&3_NuQdvlCb*5IuM7!HrQW>6@ zV|Qa^mIC{)S>dInt`d_h=l>Rxy7CEG|NY?I8@i#?7A}1#YK4U93sc8=?DiNq)sHiX zB!anXo}77s7oPX;SYaR19BYMj$@5_AwpiQ#-gq_P*n^$n0~0tTsX3kbYiC;37OPs@}Q< zqagj#NEhnlTXf9F$C0*&jmb|#Kl(tO1tt^Uk)qzeJ?3BQ3D(PKq&FNj_zE-XvSi56OKK6F5WnjPY|1-XZPpLqe0x_YcUuaOlBCD%2>MK@T|GuT;(6+j@ z$0J?REfD+nBygI}kpHj0M+#l367koiFy(TG^W4YBTQ$E7`lXD@zj?hX^%l!cPD>lB zuW|nSW&Qg&^7(OM{QNNs*$_zR!3?)_ne$!=q=M2K%ek{y7rC+r0Kc(W& zd6J+-xg^k~JFvvAftCR59$1D!rG;y(+&RgBwykVKA;6z5HxJWa27@Mz~_8{?{0*YeI! zUE_iql;|ZL2!%R5Ve$NTQ2P5wLC0OAk^sj4KvjnY0~le;-t_|L0@9Pk@+cn1;9Fg*iT`Enz**OiK&)143S2Uf`6zb(I_%67Z16X24eK zAPhdVzQT&hVgCRYDd{j-?(*wef)o3n)BB$@IZufATD%8f0pRvo!meTX|J&d8k7W>0 zu{GTOS_bKkj2V2Ydjt%Aa0JChNy7L8Wq4<(on+_UEL3QCKbBBg!lFd=@NR%(o@6@D zAlT-7hySD-x05xMC1+pimjtBHg8tCLqw(}|T3J`Ty9B574j5K5{Ijj3EHenXaTB4TcCzo0d9X$0 xf1Kd|_tXETsQrtb{EwRT-_PnhPVmktu8+>LdCo~M84moorF8dZ(G67S{{fk&j4S{E literal 0 HcmV?d00001 diff --git a/assets/images/fp/grouping.png b/assets/images/fp/grouping.png new file mode 100644 index 0000000000000000000000000000000000000000..e72bb05ea7779f998ff6556427c0a30ecf3057bc GIT binary patch literal 59039 zcmdSA1yoe+_b`gDq9P*F0us_8F{HFe!_eIl15!gXG%706N_R7KmoS9VL(9e)B1|dh$`1grfjAjay4qMn9r;~_sBYo%1NS#yvr$pr4so&)q7uDXkWx!tiBing z0Yb^g3Su!~X9rR80(V?I9IyEJUQ%+fb8xb;^RRJnvv9EUvxE4#xhentqXL$5Fg4>> z5tsaXG2lsv>YbC59X}fz3(7$8t-q||YI=-|0zX1L3>;KaN0Bz;v|6SvMii?fS zze_keNw@&p_?saA)6tG|8lUY3BQ@GgN+feVGA20a|oLq z)SQa)Uo!HG*;?B=01E@yao%DfFV8Onb#yXnR4;+akH55 z8S%03v2#IKj6pXSj#nTv6NnL~*(<((=8M~!INzM?Kl4rhAI?{FumD8M$ojtx=SJXe zSb|^L!Vx$ux4$Jq6=MJQowWt!Ef??`ncQ%<5S7Wzu|iC#{{GtHzfFNZU}5hd0MP%N zIsCH^w*R`t+jsvVv;PbS6v55yzbXiL_*aQR zpn&Fb094fDnBZ|Vv{_9VaZxqbv5h)(tq6g(~ zl=@bGqSe2;_SOA!O9}t;`5JuZ_NE#C&+}Kt+t2qgH+mZQ1EJr3JXO8@K>KH!@r_~! z{{Ei!50rnV{S5`}pJ{(XLHm2!KT!Ue_W$YP|9`~!f0tkZh(E{mzXvD9BhW%t(%8uw zu+#6M;@;Y#0?c0~=JX~c(S8!8GJ>!k?uGL+mB8BQfYm1d3YOc;(azb#N3Dx`XN8hC zci%(v^o}D^&BQb>XGPvcLtB|k;PcMD+oHAK$+Z{FT=@y+FCwf8Y^ z01>)n^goXPYBvZ`!c&?~=P&b0=W0(z+5`GOPWyO#ApHw?=Z&e<$i~Jf9TdpKhV;26 zL{hv43rK?v1wBp{jBNaNmbZ(>caATn8>U5k&So?u>@Doc*&-J|Hwb&2H27Q%eX+Va zI@2CZ+$#-JWYsdz*|~^5w?VwcgY|X|yqjyr5OP0wCIU^!tj3shI}5CNlXBtXQ-@GD zaN7OYwW6G^@zRhGkKk%{QZ9l5z_NMTr`GFmeLh6?s-ez%>WfHn>28rC#T1nClt{>< zAFg+Kd|p+Qq%qC1-0)U=7S$$leJS;T?)tbvum(__9L^o4vRB~}65Ze+?^P0H^49qL z18!cbj}=^ll{S-9f@WRK81vY&8^fr<$B%aEJP_qJ+}vo1tnh|9H*!LfjLaNHdV2bC zQEUkb30+bvjyJMyEY}`aXFEr6$-M)Ns_vd=&)DC-FAQ0l_v0>LS#$dJ-byn|F}@Y{ z%YMGKre>tUdp9G!9>YDoZ)UyByxVlz_;fF`dWEf`Qf~0F+|QJ ztr6gY*Eh7rCm=3NFJKwB$0i_vcnFN^63`Z$?N2v&&2F!A`&#@*q>FBC%{=Qrr zqPqr8&wg^+e6|tYlZeL4skq8}e=j;@o!N^R*U4rztVIy%qb;u07ws&Z>$W|?#LY1f z4>EBNl_XD>3>I{r(=yY+&Ar=K(R^@Khu|5Cdi3Z~gi=IgB%5=en1MkOYc?Dn7ZrC> z-{LzK?9V7vX+0W|_qYErJ8x*DuTDSfJHubOJzwEOBJTs_QW%= za(5l|z=elUl`ha59M>5oISsJiPC=lB%^}MJ4}nVNR56Z*urOTIuhjJP#H6?b^FU4) z6Jy!X?s%RIy0)s^(E01j%d4w8f!yc_$&ly2M~%<+PN_Re!rdG;4lGm?pIcAWx}Rkl zuXcB44PSajvFi7yqleN45}_L$dmS%nMu_&&HXno@7fnp+Gtd%0du9rO)Onunc|8!? znnWxwElI-j3JRQ$T}H2uhY>CTIp4m0ORQ)KG{@HE_686tHtWt6_Hy4hu$=pZ;fF2T zEGhL(-eu+HJG!73p=Czsl z3CqElZ=(=!r(xnaxEz17Up&m_ZSPV(PZk}|?f3j2-r9q+rk3 zVN}%j{%()@AnLd0UU4O707c|QV{Ja>a!&}kkmckU_wVniWFyq$Oi4o3wh#-ZGYge3 zH(UV;SJ#q$>TmM;^=qla$UULG{e5{b_+?i&Q)i&g_^cGtrzb(XR@oQ^#q)@7LX+1W+jG%^QB5wTKIWdBpj8Q~bq5P~dWJ2q|-|1e$s$YP!zv-QqCVKvR_y2tR6f?X$0nk`_|RgdYYLntq&Io zQ1c48?))4WP?M0zJcB~4hSz@}_yYpKbK$vV{aJa?=qgj=pUD(cddJ7HJT^?*ol>DB z5QxzkAmWBrufN%8PO>6g4a^4Gzi$NnWm&)PLdvFFNpmL2(2W1yRs)RODLg%AVq$7- zZLQxkc#g@lKnaey5@HQoYeBl~_qXA9N^PmI`|Iiyj_DNY~r2HX-hFLJN_2 zk^1}Kcx#$IDJtw+Y*M*Z8;_ZcFkp|rT4)lYc-eda0bE>HouMhr3>5o#5wED{(@<29 ztM(1?%6g=HNNA{(zoXe9YfC&|!N9Vs}TfkGrRT44mb#q+ac`O|; zrWNnAJ6MBeJm%a2h_@l2H&5Yy{pqmnsWnR`Y@b5Qn#l{mo<=?O@YU%O^0;a~caT-r z40;?lX>f3TzCO8cxJ5*?)Z8Ne>7Kq^P-yN;Huu9h*wfZy>NjHr*PKRX0XOHyr2Nm}N1U~f&@@OxaJp0CGb?{HgbU~DxTze_nk z*zJ{X5P(cBHwZGY&d^)~77xQ-8BmD_-*q^^QWQb?HERmQwENM$q~1tFiYY-iHIKZs zua+eu(+$Q<2t-wfO88u(*j=i|k5IELWvs!a)0~6lwl?uX!>UT}lHnhn_xTl*FJ6uu ziusUjmwMsC!kNDm=wto$la~gt*WPAk4zVi!Gx$g>(xJ>OI<7j2iB3a`^>s^(P-5yI z6uBXl{4z$qIl+4mX)$fFhYNIhu$E$DJD^!v`80;g8b7Nbg8)`4g)iAy7+89!Q=MSW zVLHf1OzwoA)dHmxb2iLG3*lgRrp(vAulBkn(5!3G>R7;bjgAZ%JW}ba z^rNrZI@vlc9foLg4)5|{S6)$_o6Q=bhM&7#Y*n`vyu(hyMk#!cqV zG(K3iER{STD1)8rn96aJ23>yLAoz1)~qZfA&u+5QT?}GHi!^^Spj{z?k z;Hq$NWkreWq&?!@ov*9IbZ}b(VZenTWq#SkCt-0hk}CF~%quxvDzvoH+A@hDN9(E^ z%(Mx3HPm>C0_I1>sT6Ha5d@1Q){dMAP;ZQI!79tNMxmBM&L>!BmAT@Up^9>vV#_hu z092={?Y{8sQ_2QwjEL=KoI17eWVNqPr;q@%dmvBIP#RI#dBA?aYCo;=_ZJOf;5#Q8 zEfG3b!-(7%l^RYS4oV_ZjleS0;_3?yi?nJB)qQa!TN$T{%hrgbB00a)3g9oa1>xjc zt%W`-%%|~bI0|{oN*j(?TCOwQO@oJD?=5ypFS)uuni4rVEv$*-(2w1Y&5!B#h>TtU zRJ&;`&VCG__Go?T>n>a=)QCq%wFIvhz0F?^W{Qk9b-OJEh2ptIv!?bwfA5Qwk(Y4>13ZjIT`}{#>>`M!pA zDQK*1u67^<22k;*w zP{8qjiYjD--?+UgSwb4FU41Xao@`8e=&UU?V^9pQY>ZXUn<==PP)`;a3femqC-x*J z*ElRXa44U#?Z4SmlfB}GF`tB8$44vH3F^6;>xPgD9PPaDXO2E(%VF5t)S<2Pkb=7C zTq3IE00gv(-;xtMj-ScLFa4@RkgP?IpdQ@ECZ};;J1GdDvL-^Oga?N%33_A~!W&1D z5;ojK42vqPG>-)f+Rvd{<*1?Ukw(4;LABhD1sy3p*bV z(UV@Gcx}h}LeHOfaIEEa48l5MH=6Wz4s!6CzF?VzIyu;v`kVsM0WRw5@;oqb z)4|zAS|%Vk(7$hR=;^7`v-SM)fkfR*7Qu|0u&BBGJYaSH!JrOFZn{)3Rb;K*ReqM= zK3tyS7@5rH_$4n;%-4_U5(sU+qmv7`e<~GXjQ%)*PQg|M=!%l{vrNV01>NE62DTc+xq@>0e6&ISnf)axK>b`gHp954rMVT-qvN4I=T6Ob&??1#iyN^8hvw4c_0{}lnc)^{ zA21o;4@<8)nBfP6fR+Wb#wW&>+N>{mA5wgA99UZl&hT&8-RPBK+dbT!NmMH~JM3sa z$rky+xj0S<&unq?XgPlTjQtOpnFCj^7x`o(K81$)D469|!q1+i*5I6excfk5ujnPS z^*jEdP9RPqV$t~-Go)^NywDsoiEv?OqtO*|IC-lrBfO0{4R`}vOU+PuZnx6x;7Gph z!sG?Z55t~BgUM-JrtLG1=DkX}=B#hN9Iu!8^(G5b`ee#}nBhSBM+idEGkC?tIpC9cJ#o`2{ zOFdDKAdDbb-W+G1^uuVgDza}TKHZb$gt*Vk<=1Do&8 zeHOh_f6>W%?d?-^78RCuu`}Dm_={YaMp^Hht{tb<^psF-+m-Uv(q@nA<(z+dUH3qa zv)^0HP@MkXLo<_~uD3;e9fSS4zl0v5;$p6z}Sm|HWU>8|J8I0eZQ7o&2dC|qi?5JJ0V~y2W zu?HiS8%dJ_fFaxKQOxuS&+bkV3KWVSMNP)S1bE#sOLcdJ5ZYDg32(X$>)qxeUWbwi zO)!BbD@+6yU;RRsMhJ9)i@@2*+7g9e-q~H>IG*x%d=&LG$)%jPuHG;aDpvqfN@V)w z2^kd-W=qLk0%5i;K})~6LP_AFRLJwxwEP{%P5Nc?tHW7&PwR!63ac1Zi65Az6j6Yw z5OMj`T_pgs?(CMG=PnkRY6y6UrB~uANXD@76D(FM` zmwqyxNhAG1x;#Dy8|rx)&ElVpy75-XjonxJQW*<8GvIKSh?uFoY8L0UdloBzo(+C{ zxS~kev~TA)Cv@(5S;NhUw6DE8QDk^w?4<3pq17Y#BAy32<04sKuj#nXb*$2r2c$_7 z!ecwC7EwTWs0Zq&5P?2F-Et#d9gl4BJe_lqC~5xS<$M2$Y1~^PbW-PtC~B_j*^`8hgf$p1IGr9%dN&c)L0x zN*D4EEQa36wD+sxiEL(gUN0C0=ai&oXSaXFY3fZ5uU9u{9wyb%aS9I;IUmZ?+zlbw{l+yGcv;GaVu2J3LKqkrWVCP^w+VEx?-wjmGfMz5Hh0`0ArC^%VU1jhDw8EWNuYjT;fr~fykRo z>w5OqU5|f?3a3}R>WgbzK!yt_fji|e6_Q@bT6kWZ*lV(`tL|N2UtO?>@H&Q$6o!%p zDm?RPX@BqCa%8o%Y{sq#q;fKH1E@G-T7~{vYwSxE8|mq3K4JKE8W-`w$Ls7plk6|I zi!QZnU)*z7*yEsp$Ft6JQ2`c~jT+>j$r^~Gud%GUq;y{etsLQSw?US0F5wozFTaD(4S-=qD(Dsf~1F=~7+wR<$E%Aq`!7~bNto#EO1 zm243o8lB5f)}rDnjmCL55)lF@c~W9zB%Sy6Qk&UWFsK&5SW57?+VB=^1|%p6YJ@NV`aV6=R$Hy5wZ&o6yF zVCrm)SVh~BGcGP)cCn(lPly>#fe1Lg%TUEBoa;L*#DcWtAhgPY5rZbZ);KQlI~4<5 zjaS)OY+I#a#Omj+NmxYFI5oWC`sky>l}-|>c&RIPack}CUFkc`<<6|MtUa+PMlSb= zf(rC9$)r6Acgwl8LFV&=)$XLUrKPo#wPE_M6%m-Spn3aM^KQCc@O;E6Q7?ssMQ$nc z84;TS{(cVIUfm&E=$8JWOIAKFU^QDSqpiwf%;59|hR4ca*!Eabbof+COuyCgu5~Kx zVg#qd%LX4+`Ub-Qq+h!uDb9YY4~g(mjkPb$erSuEhGkYG1IBV@KHY;1^pNvH^V59~JI|t(();>e!#1>xmQMGVx-E*q{qe$H7iIB*^NpYPwe2_T zfIJyBNWaOz(0Vwe_KbYG2M^WZaI3WdRu>l+w+i=xLZNQx%(-&Es zgHpwsAH!%E^Yh9s=UOo1Cl8XC;i)!HQ3DYtEP_Hs$x>jXEOooAW`Qa8;uJHhOXr_Z0s$gH(GGv>(f2zY$1^o~CDS38>f-8W2c_}$SM z5qqleIr))b{3{0Z_;`IIM^qOvs_5KsF@CEXNrJT3b-TYl>c1SZt?)d0q6&t+O?Va& zk2}T$&(kd0m_!^eZdf8+6gw1l^jtP<|fF;U+sf82eHUa z<^z^4)~|$V@@dk6tS^U^f!pz0_uY-u$j=xa2FTiK$3l0+{-Nx}?iGO>%QkfX(CV3F zzF}2VSi{IxVy%>7fljsHnPhx37he*L@1n9m*MUP7UDf?T!0L8G9i^WE!o~S=i`6$& zmYk`*v$;nJ&?5IiUeSrMZ)8$!r-fcH=_zdVjN$Y0q} zRy?fW8emW_X^DB1RaZbDz~>(pQI)l>n}j9G0Lh?ff$B9B8cx>>`V9oeJtGCOgz=0` zRZIcc8${*;WYu`;={g9eWCtZlojH2r8V~cUEDufRfEW#YiX|LWOW+@OEG;HX)!|ER z^|(MqiSi*@^MSsO?8P2Lj&V4MLL|yI4 zGS>IqNOXI;enwtsE5SE$?I@N6kdMH9DbylsO>MR9Hn|4>YKhx^>!%UYjZ^D{-#evm zI=t?VSLv%wJ|9&VG-j$?=lr_5DSImxP)hiXsDWO%--YRUj}0(}JmIl*J&MX|_U`Vz zsY_TJCxA@Oj%;+rCFtziJ`$p%pX|c*dW2P>3T129E^+*jQs2bEcz0B$lg_tjiGHMq z!OEGlm2p}lpH>Nj=vvuB;xI}=`rXl zG%hCnuDqb4rRb18M1^o(C^TZ!?v*fInC-**gtBLHL6bR_KrRAsw0z1Pe7!boV)~h>4?e8>&tU}baT!ele_m1mOC#l&yPjy z6Uy8Zd1dN7_VbEDAH+*n=j8;&4yrW+VfUoIh$S;8J|O{dBXfjPMcPN}srmGwd;;Iraol z_86c{$^FvIz)_4+k7gGFE-JX^xI{%(TZAozDlV#hhq6)xsK|mgsf=ZHT&Sr`7dsXw z9AnIWRP*nJ)N=ByF3q)Dg?E_%JoCgw!}FYC@UWOQrZ;J`YxMGfi0-t(=fp7*en#s; z|LcX=eZyDu`d(QH+gzf;AXr0IRR72HFu&2H;rkxoQ34(LKt>oMJB5Hbs-n6r z0{Stq?DAkWfyowdiTlknpz8SCyL*Po!o^&?v9IhK!)OCfgn5A6Nhsu%AkEv>pw)!a zZ6M2UczCginrJ3AV63V3GcUWWNvlufeAPHSbH3jcZ{u(Qe8G4Ugvw4{F~@Rf-KtlA@a0vWwdry*zVE*}#1hYOqUbyqkW+LFB$L)c;|W2$h`m|^aP|1M;d2ci zh8e9{5Q!zzv86Ddi9e!SRdBoY#A-M{B(M(1fKSMu9GCUZ9>sW5^+t$M9LrREj9a80=Y zl)9Z$u~A{Gpjre0`9P?ZAYh8a(w>jMTM8P;*N%Kj(Ng%s=lW=Pr}(uc?eY3>v^jbI z*uaA8RBhAfTrQ>ganI&Pjdw=@==W@`vFzxqr0b3z`Q!v(D7$y>!yfM<*7!`$%8zV| z6@BXc;_(D7DQOcza59Cg+9*I?+ROIcZD?-jaT zn(nH46*U8aMC?NE*VW50foL`SQ3DLKU9|0AyK0@^s7u%VMhq}=DP7e=`yC7v__u$l z0WqupL(B#4S|Ip)jEzOJZ<1W**j8CP@fe`z)@IRFy}|x^7Dc&>uh-emZ{9bWMY-`9 zlzUr5<*Al>AR%v(Dfl7gSiKh}f$bF5!ecBar}9A{ zzqf)BMVO!r6k5bcEUisvR=12zAgq-h%YA2b+~+aej&S&wT)%inYp0VkdJ$EJ7r!bh zxd>*Fk>PX-G>gtK=PqfvG{rZ)IW_w53`#k^2(KqzW_P{F8uG|9TX?lUXGYvqtGZTI zYl*{8rH3zSZ6k@QOtU|m9?$mP=useZo|cx}<#tof`8XkAC07Qd85uT9Q8qxY0*Z|a zZmJJtDXaChpX1L+Ase6$3!ip@*jqb}R98C&PTN+785Z+dJl>5EmqoXOnBQD8-J$Sk zk0@96jyo=5)OmFI3AsyT~LZOCH&f|EhOr%yVxc6!WqB;aatE3rBjVJ5XB# zienxw+s}ty?YQKrlIC~O@pGn5$idUv5JUjpoBkVl>8!G{(1?FJ=m{g5_bLb!`)1U#2@Nc_9V29 z-~m9xk;((He_~`5P=4wFD^fXb{)V^pkc}fli`)_2@w{2T=pR!E2Zi|kGJy zj0~G${YKD)nz}l~+Im99_>9;5v(n1TEs`96Jo+C9zPh>C)2TP0f*O55S#^@)yf^?K zWvJHsed}8Zrw`ejEQ_zg!~=wWWyqL`o*p*e8Vr=#oF(^)va^dzN>=efi-k`E9_H!3 z;7Y%;R+-98r8Raxc3C~IYUp>?*nd8ZJbuOt-Ix`_jaWtx_Zh}Vomarr)Jf{3QK2mH zyk_P!Ch4j>pIZ(jO=D`};{5#Dn*6YVVrpha#ycykaV=dTH?8rHzY}1z61-Rk<&2O7 zKCdur^wU73e~IUQF!_b&@kKSK+C$jpf{0VnXv%<+Vb-raoC8N*q6cOQOcgjtvPk^J zm~N%fHlVVkD3>U$DC4@j@nVsU0OB^qES<~;fx0icKp#)ZroYDEV(k8AV(I|mosUv7uy$%{YB5E{-rv6pE6+4A32U!3B9cv< zv_r#k-%hEjD=$oH#jSD`)T=7EIjr=(7_YKHc1SO6E~ond0%8E_x81R9c8leVxQOLB z1-w#xq9rEg4*7%~8P24&zhqY}kh?(g`MDQ$MAA=9FD>nuDEuj~>{n$?bzzpl*B^!G z9a}q_7F{Il?NS;NHcs!0V5sv0HQi^Eo<|GyMWJn{j{U%{^yO(m!fRrVR(HMK)Yj)$ z-M2PY={S6R`*gKph^KR2iaMj!7spI7vGH(meT$65x-I=%w9&!S(x~pDF=_jJ9!KHQc45-642-d>_<1a+YJs9a}uX&4-rg9l% zzXs0HTt}Qd5Seb_phT;GAA`#%v#S#q7a^KoP>`OU9xkvlyS|=RSf~)~?C9)v)Opua z9SyC|xjCY}L;Cm7P})lyV`E%$@~IcGBErH+VGV_atolQPEvus86gMqqHZeg5rgTEi zCr#s>cLVG1prv32tR^=!Ad#{N&(UJeu!g)m&iorkgR~{W)wO}257g6%nrs;@5qpUB z~KKw=HKk zeQdY=Za`Rc)BbkT!UiS$w|@=z4jBHYL+!R}?cX-F+vYg{#01a|`Y({%R=NMuSNEr- z?!Pp-{WBYI%x}T|3;Vx}`@1pk7Kgvv;{L|=29bZ)y+!{2)jqvH+y2ibZ&$nN_Pg!- zyFvW6+wX>&|6>0)N&lhnE%rB;e`s*qbO?;ULHxf%s~KG!lpl8Pq4QvGLfE~TvhPv2 z$3PBLhcr)Q8ew8){2uW@7<>4#?xx*}AkYFL@!h{fxc=P^-)_U&)EBKfkF2h)uBWi= z&OPlGHEjj6?GSl1Paa(3rg1trKS{?AkD2|M#jTUUz??$(BVgX>D~H$l-Nu&LMIT5{ zAg2???snS>4-~WBkJzE{6S#eL+yvZS8x4h_AK@wceFNIb;fRB#pg(3IC7dVfMx zeSv1Jfn71eBf=lyh5>Ap@Lw{@)yL2~eQu_cEb7ZgedVg)qA!MR-S-mxa)MWRY2gOH z>QDMbv%-`jCSMq@%`Jz-pJoCiyy>{SZLtJ;DsTERLFl)glmHj}xx3|?=JFSy!=K%s z{`38RPQ0B1(Ecmq?eJT$e+;nsPc>yF>{ts;a z26{6MC`bWW7hv#z03Bg{WIRR(3TErtdw9@bZJCytm7bF~>HWA+&t=CUw7avbFz090 z6VT>skUT@z?xT9BDRfM^B-dxLw9d~84ApsJOkjMr>2KjF%0uhJq(r6?_X;^Z(*CQH zg-L*5_daM-3nc%t=kRfjnYG1~a!Cix_16ROuNKjGsFY9dYDox59A6MnyWBCmoCj*T(lu;OFaxqYdUdLzlKq^1k`Jk za55_R_gLf?xF$cf#vs?gWYIZ%n)OSJ3jqjAE_k?qFm=1Nv5|_0r?R-XID?uzCnu+} zva+M2V{dQIoA(Xpc2pXg7tK$2Q_xxg9FhJcu^c_aK)D#qYCMPd}{-bSygIyqk`1$j-y1KfJ z*W}7Xxr>{kvzwM#ST!O%tZ)e#$nijtOvFv}%azTV@iq}rtXdRNSkl`y%OVpCYmY&p zN_OU~O5D@5593H#eDA-A?%@m&t&*z4i$;D+*qMyEcr~`+gY;&qde@QVO6Ort^4YaY_lKNs-p8 zi{KK=#YG2d-c8cv^)OXcV#64+Z}^*}q&|JcEIefKf3$S>j9P-)M zhMpkXyf+CQ9i5Span-Q;c^vL=Qqjw@+?Ow@k&R8-GK%{V8`Vu&ib@2pua{`9M;6{!3dS0W~B}cd?WC+$5DXI=k9?dc&c%vJxMB zJTp=gKPN@zSQYy?xQRyNqMGOQbTvbSReZB@b8}5h4o~-&ad2>e&Q$*UXQCLtH}NCe z6VyoQPCE@#v=(W6$PSr9c!ZTx?IrkdMj7#u_<0&htZMR3iCUXF#yGv0~QsRhU-+Ags_V7=Yl^4bzD0yHT$ zhJ@VGYhl+ZAA-?avq2_iKv~J5YbB}9-DaZt($eV}xAV6(5uOW6TiU3l@1ccLwW-tZ zudt??jHsoo$Et1Gymx<_eD(`@=DjfyOIolhefHRxOY-J@0MHgx>lDpTfH(L(lswNk| z=Eic?)YLpPo`Ur>_4X=CNVIImDe6FsnB~+UuZ<7tP5g-G7jnj=*bJ%@!jv1ns1X>C zHD6{(j>oZ(dK_=c8H;!S7-`Ih(!jmHzaSaYQBY7A92`u<&wKIW1%94_a1vv|D*M|l z8)+Ru+5?<7=_ee&KW55h4|2U*dHPH1b4;Zkm^j;PlC~stA-$Uy%eZ5X6elgWN9L-c zq9Rc_ZmQNz3_U={J!ERDAdy@QV?u=0__~DJ)24PdU6NI=-l?bY)c4Dd=Jiw5eSw{e zIjSSFEPkhl$^JctHShWdkV4*PGD=DH2{Al1`f6_{g5}mMkB*MWrYd?vVp>{Sl=F4? z#;Y{QS5ANB*thk{VN>vZJXYuzN^WohflN=>>*F7TY`({+AS#>Mc1Qgh8hl8bBXU+- zXtA;K6<;50k_$R_QNN_D@Mcs8B*ZbL=;XIpt)XCZ`ELtSnCwA5m>x`M1RXFdN%Stk zA#+X_j*oF^EjAHoi7@7-Vva36Emo$E^^g-qoX-entqUU;Ppd1O$*##~??`1R2IG?7 z1uf7I4`j; zQ-#5fJ&w1WB`wZ2tEL;9nt<+)1Xh0?v zK#Dc3W0EzOr;a}pbLf4-6GAK!)gPg0`c&0V<#%9D=Z`tlGKZ!bgE|kG7s%PpZlzXI z?aiAv05zZvT9W<#nC7EfoTWIHf&vdt-~&bJnLa=K(4}RQNrYS;HV4l^^NPfeH&To9) ze<_s6L2^pSfUZoXQ(-UET&`{$=aSbx(QSX!c-kdTm?$hi-CFBkpL86=JeRn~#p`k!1uLTnUQIAHKv&f=b++~3#8)3+ z@Xmg2=ES>2F6~>=)9@ITnbS5Y=r|%?Tb=j`~^>I(U~1xu%uFJ!uarojX) z5~%j>{3KXkZ+5!sZ{ZP!#=<&X9r;fma1su|USHp(5B-wSQk5!?4%+N6mW6zd~DT(T`q`s>1kEV&5 zQbVMP7?|QVmw(=St+*c;I6_yC@Wx5{Rvu<;EvnkdQ<}%@nf4~<^uQ#PJW%7MBj$$~ z7YdMkA;Y&pHDW$9r^&vH!p-`U*=~&~WjA8Lub>cg%1((<*>tAnJxu%3u~O1_9zup8 zqnNS+vab}Nakd`Yh*d*RQjcm#dKRgz-ij!@Px~tDaV}#{%9H0Du03g|fMht;E}=%y zsOn7KI&=Z@CUX^%939fGFq_96Yqcfvg3ls%MZy_kxw6k~#|?g*!%}fR<30S%3NYv@ z4$GQQJzndDhrfwY&9vAg0^^d)kaF!GO&qw#&%Zx=<=Qu6Bz7N*tnnZ|gpk}Zhi}y{ zhNlj4ui|}Mpn|b+WLgXNNGR_&5}Hc(buO6gJyB41Zq7qle<6EOv$ZbbtVK5Qr3^{4 zERqqOuN2>7I84scB0CA3xux4(o8C`t=`>=wu~cx!^Qz-ePr?q^!!LAMK~AIu<%6+}{dutM!|_U2sr$T_4orIrcQm65^wB{! zMzry2aaj&k*Oqlj(}R`ir>Mp#CsA}7N!zjNIzVN0k$^2hZ3K`iQR+?^2&<|Ftf|~8TePdTbQ}V7w1rs|fB0xj2 zAYH4xZcW(cD4$%&Ckt&U!!nd#n_8M<@ zW(u{kF@rlCX&5iJPPTgQlSNe=R0$VOEKej>yYS_i%~YLOXV<%P;gUOo z@ruf56oSrzTtXkF65~`N9*0UN8)sGRNu0y=1@y8Pk(au!!e3R(k-PCuJQH+ch)iiu zz+dW3%@x<%dz)PEB?5)g3Vw-*7G{r>WujCy>p3}Kxv#WGJr5*;aeH@o?<_2Ys6C~hPU5|V>@H%6UN0UV+ zFRxo$=9}v@HQUWaAUBk}$2N^QdHsk5b0Q06x^ZpxnbpvDB#Az^gJ5@#yxs8 z#u-2~imqOJusIycM5H?%sv2Oj$0_~oOUOygcn)9a|^(%nG06YzlK8>Eff}WTPn?J~KyMjrh*1gl8#o zmRG!!Dfeb!(e zcOiaIua^sOw}2l2wsmwufbhsVj@#M!9nzpvO;j%!BYi=U8&vkI9w5t|&*A1;Xm#JM ziYaJ)T9?lb*5#5Hn%!2ziF#QKDiTNny28!761_%$1q8U6e+4L^5HHKEQ%3wHfQf*R zNz~cGXv-Rp2obcjB~msCgoF(r3fzb$-ZtdfFcSIq>YQ>f)GVRwzS^2Qdxlf!zZM^B1JA7~k8 z0PjFI9y0)C;-`B{Bp0L(LnjyT2*xU9T=DsV;I++EL3Q4DZCKI8o|JoTCdb4apS5(X zW_x9JX5dx-=Wb(x*yrM#&bb=%kJg@iPZLZtF%kr9JEChp(UDf=NC)ZnT##; zuQ@!_%0-Y|v~$Z7GRko?v+hzr{e1hladOJZ%$sjgwVtjtUhd&nQDt?|?NoD8aY9PO zt@epN$Xw)NO`cS+@h=WtJ!Z$aMt^19qrT}upF{ZJ!C3YLS4Snd=;zO0z6^0Pp$_9! z_tr@9RV{;52C4Y#pm!B4YhI!2bz6tCWU3LWK>2B$6S!bAS)^Pl?aGTV@iTn9Jh3lW zi;s8Bvy^^p3An_JcH0j;OWlvguMYgcv_5ntFse{wcrIeGW-71R^eHTUAR;X#Q{xqc z*G%PQa!e}$MAezqdtoLY-7)qBCh!BVzjC}3ZRO>E;Jk50S!X{oEHPqH_b@HT&-;J` zG2I`l6$oS1DGBO$D>sn_v<pGBk9c%##6jo{X__@7@6C zB%BX6q+O{UQ&ZFH*+Bz0R?({lK~vFtOc5k*>;OuXV%B=sYGmGRBcUhBu6JHg{>12*(>X7JB{I2PDfll zuX=h7-^Q4fvOk$Y@~6}yNn8!$}|Xe6r4Q)25`EJwQx zYZkK323HOe?au@{_i{#a-L<0w_y^DGL9@Tzh!2LqAu04I?4~kd?Ggo>UA*PqQVZy2 zRImY#GoEm}5@0-HanyxDkYVF+LykoC{1|V&Y65q!-HyesZwy}K!%uw-8f5C!#cS9_ z)jpA}FK3%7$f<`3r}~#At{miCKETRw0vEXD(iFZL`#J=pS0W93B&ng!cjNKPX6kDj z2HK40k5?j@OM|5(OD;dc3!mgGIcQ`R7+3(=uuTmd^Q45Djp<=yRNy)X)x~k=k&drEto^( z95T4P6Cu9-X4JGsMAXacP;6Ni`38(AjcFw`wdc{CEo5Dp%<4U=^C)bQsxa+0M!Kx) zoc7Wlb2bFNaRL%S5#_M~jH$0QWefvX1!fLnk`|LqWJ#E^GCKyIWZ)1DM2sLU5+Zd) zy*q~r3a#1;^tPU_bm~qkXRqs!C>FwubBPs^i3oeng4Jhf};C#|iQV7Y)AuTCcP*Gl^8;qP4WdZy{P-(Ty*fu7ngV zys%7DT`{Q17l)0>m_doc0>#(T0w{7^gP(e^YP(VcK5OC;5T42bb z5s;x!E6(#= zqdnVGY#ueMdhC^DFX?&1Cm#6UwhJ_)SFab$LHi?wcr8(Q`8!9B3FdL6iVpZEY?ab1 zoVbnYkky#q8-H}w+8+tUru1$+{biaF(}5^1w&QMrv}X*sSm&U?=VK`O%%cr9e5@&O-A^9 zBy!dpWx^_v>FN*A_(;mFyN1u#s~n7leqodfjN$E%25^uk#a`u^85*Msj&bUXBTiUk z(^fD{nu=@?%#GUaUw@~eoMt>H&1Ip2=Ls|R4b&Olr$WR?a?DWHEDN|l-yJIs`Mf0b z+VDzAY-oZ6bn*pSO--$kUG>9<4*&~q6M<4UImLc1?}n0`6dgVleTXC()!AJRAAR&G zi|MHKPaI?OSWrnQy>)LSO6biVnopcmoRl#nmtys9mGz3%m7iav+tTa%vl^mu>f%OP z+4N#68KuM=pS-rn!wDhf7lh|&Goc$q(cZAP@zUSOU}kQuOpUynDqSNZ!K-tcT`Z-0 zg;RvDLuZ^{`zPNod3UT1GE8BGFS48zs?`*>L1k@(KJZvCf+(3<%3T&;)h-H31jE$#9ov~;Em<{n@P#OrqO3zOo4aMBz zS5M3Fn7uPzVq!Dxf{`cH;9TDwCI<0&5=)A9vFUw9VXza#UnabXEw-`hyrY$ zKwxbAn??^5j)rV=P_m2JGy)!>$(7~XW5(uso|(ei*iVI1B}M$zHVF~Qw-3}K(VS7* zP)xSse(J9co+!Ld-HnI-npC4+cSORtEtnbH)>8~Nyy=t!?conw97C`gnyZ;8YeV>9 zOj=GY9^fQe19OShR@0WUoEke}pOPW8?TOZ}dKCzT54XBDp5Q=u$#$ODVL3#USz}Rs zYsMKBrEObJ>20I|Wibv83aVh$A|oRMm5kEQx~5(mFQ42BFq%I_Ix=ZUJ4~{*^57jk z8_q0{matrd_t`f$XGao5MN^ESREkn1!SHhl8>uu2ns%!%p0_cK2VX<(qCWhL4aRKA zK^mF&f>ASfbgNzWazxRo4ZH?MlV_b-nCS6BYYvJvdgMZt5!A!HSUGA`D`GCxPy#9} z1Kr%%`1I+Mo@Uy@!oma{+I4+WIrS}i-nj+I-I!OJB^?R<)4dghB?!KrllbxiZ@B*n zq;MO;uC4V>Ao4={Jfs65`8buo=Ot z>QCrV-il2`vOtP~d77Q^)L7nMti&!<41Ed^Qo_^wlr_si*im-0cCjI~sHaOlTvJ`W z%mA*}rTd1nkiISH0IRFbG=fA8++xvSetXj-W^ECq0-|i9Y~Qt16t%f5oz((A&OiEb zheX(ug0W32DsReaCN_z=AxHD}ChgRj{B>a$aWYtnAo{_e`F-yz7irUe-1VK2suNUs zKE}tU1sOWXP5XN1bg9Vrq-NveWM|ey!llnV!b#asq%C}jQ@3$|p*?lL$fiX@8MaRf zA+*kGLs~J#*9(`H9|nXy;V90Yz{OhGN*Too6TaOkc@FXs(#vKgk1GB+Ci0!mKcvWy zW#{^c+8yB^K$Ov~Grdt~i=96QB!&o4G$|v@@k{rN-(w zMNi;tP0TqCkqDeH1AvRSpA>Gyiw5XI$TlF0Tf^F0zqWaceK&92dg^{%o;&e3KVKX2 zqNparwz&P7H9v=LqrX9nfZM>$-WOj-IJ-e<%M2n)>l0?olxKqTJ(g*8$BvJ{-Ee&odKZM93mA~~HRa=>=CU0V z)RfWEe~xCS>TH%5^e4p2yL=+B&d@~}qM28Ov+H5e8U=1i_+2RK1#RYwZBjCY=U9GZ zvuj@wUIgM!pF->}3e9KZW}fy(lOyzLXxHnV_f$a@MD=6+IdG$*tfU?He! zUVNF*4uz}7XWY4`sA8Ll@>L%jBnf|=N~t&d!gg}P`yUV~qpliNKyq74$0y^_M9bCB zSqv+B@gOm%Uu#TVpH0c&r|?sQ_GaL2T%lbJ8?s($z!1&m^7WU*ZROW|0?;;MRRbk+ zz2})kOZMS7_ey1`pi~9xh8CH3`JLDTz2B_Q&<}qTjW&!m!v!oXG6<9w)=>W4&Up$O z;o2eEh3{-~Qy;@8Qqs?AzP}J;A12OR2f)i0NqzBcy0Dq|yDGdD)kw9-*&1izdwzTw|dyXN6YFo};oL3{Z@gG=958oe8ELp$9q?B9$Vra*l1vX-s zqvIdDLJu8X-AWh~GpEt7Wf6$7=uK7Jhn4SjkSI7|3b=aigg;7&4lg*AJaJIO@;qa) z_Bk(`WyB((acj1}Plzv9oz3+<>ndcRl|yiX^7n4kbHs!DHdGG=ClsvLVF=?-X`kT= z+HOQR{Sw=|UiYj>fgd|A%vIBq^T5XuGF@(=k`IshUY`tC;7uiuH}d(NDq?bC=9Q0J z@=vPg)|e)rLmD0IzJG4<2S$M9p%*pW*tzBwm)nX(Dujvk1vR%)#U#rxm-kq*W56KSQ$D^|TSqoETpk0`2ty|Ec0@Q9%Clk6iLBazwEmVL%|-R>$8wD1Tpghz>cmul^qRpi}$EQe1 z2UIhtXA02?fBS3pb@E_DnuQUok91>H)JzvwzuRvLx?tN1xAmFPQgZjibG|1Vsd*`? zLa7o>6fn|fK{xA3!pAk<>{uZK?%A@BO<`YT)5hE9pgd*pif1Z55W}qZ#tip=4azk= z9h8v5+dHVOl7q&}cuitkPeU1S@>VW?4Rn!2HI0qomj7B@%=vdwP}8 zbIy9dX`|0p84z^|8XQ~(9%eLhbKJm5 z2IQ8UO3-{yu@#$4;vTX$*}-l>p=0c3Hiui_t&JxJiPYNRm%PwCBNG6;%x2u>NU__& zTBX!!LjCrfL^s6A2DPn}L)?q8k%9p4dF*qPHOZ@r5_o%9+FAW>XY z*Gph2EP`vgiH!VAk?E_!@Iaz|8kt(dp4WYBTtN=<&pJ3nKg9o>%v@GU+H0dSvc`kh z?R<&}6Rz4XGJ08WI*f0AI8TmP-BF_x?E1Avmk!ovl=~+OsxvbiZP*!4O-h72F^M*< zU}K_HDu*)M&D6$LQ_MoJdFogN%R`%M1zEJe^Gm8Z&!|~MS=T6kyvmHA1?fB#yYTJe z4GWEc>5f|b;O}_(2ZO~@P!^{*AJ5}Px09tKud--|C4Zx3K4?SRLZDfEn(F7rbcDf} z<}?(DS%YW<+o2a|euG92sgJkcGsaG7K>Epxj6PK$=^~Tz)iyJ2RjUPp6O041n2(uw z8PSsSpE#{|f-!wjAh;=i{&yg$rtwBeL2SGlsoX0F!Ld8d1R(zqB{#d=tv7yvt&qYZ zQ|75itE>*g>vT4MepDx~q@kqh0bISGQ+TqH9X+ksA+2|RV0LEG<^!e97O0NDlK2g( z#su57Uus2n5#S1Y#)zil_m*BJDE6kwi7zwyEj?l3G6=FVR?JA6@Yi@$Mi82t+m*{K zJqvY^M7?i87DPHvNYKIS{3|#`UX_sN1PQk6q01k2mmj#1zPTrzx{2IqYf+h#qer=B zuDUDmgc6Q5$tyT}ugiOQL2tDT3GS>lFodjOUFL-(AlW?FX#dXqa0Q|Q~Z@8kIG zK+12VpNq22|3jD{RTDkwfo}@?I1x3xb41fAAC6pa2ONM z(81YL{Dnrt(mgRNZQ0?-?Le>p53Uc15;`L6V>G5$UcgQT5O}@>=q8?t0WgS z^9x+HET>M!(Gy>e9FhJoN8Oo|rnzW)XBZ!1R`f1l$PF755iK`O&3(+2`;J_^RApWK z-7^Lcb0*Tf4NPnN*Uirvohj!YCUDkM3`&TP3H02f0d{AJL)UbDeWt>U>qbxXx;x(! z9+x2CnWXo)3N5_5ADG!Z-TsZW>cW&_!(?LYgsF29Kxj59ex%a{(1Cpjj(`&yBu(d>iK3c4qA_c(CDw3cElAMi3mP;FS^U24hQ~D6#!^#V`=PMq z=;XWjJD|T1hdc^zTHJU{@~G7JlpJkHU)}!_Vk(>PdWo61g!=(=LxY1imr-8li~CUu`8g{UKy6$$*cg%QD!0g$stJm)i8lSZ@N~BMeD;ZqlVc)RKC}1MZN)P{7DJPc27S^6r@H-dIBH| z-X;Dw;Z@?NH7-4!Ct@j#ODK+lRBzf0D|nC~+9(X=WRh4Oj6Z4B35^`8hRjc@*Db=W zx3?>EeN_`Px_E1@L9!sMW zoUcF0iHjq7f5dcKi}=2-i9(iPCw`G{PMNs2riE>e%j;KKNxt`u9K2Y8396=iqmP3qnG@o zoV>dl=VG;S3=m#V!hQ)_uX{>rD6hx8^G$?z-m8cgm@K7ofGExZyCz6FZLQCQrf^sE zILw`F@RIu|d@vYCl@c#a81sC;K2I$LRGzYq77UKDUT`2{F}PDVLS)d-&>lx^ohl%s zF?oic2xXzfC`>jv+~?MlhI{J$hHLl~)8`m*(^?*%)E#FM#Bo;c?Jo?s0kGVRqjw#9 zfLpAR&aGlp-RCzZ)k$wkY)gAI-J3Lzji)FRl7Eyq{SX@cWm70xdJjGk(}LXGH1Wd4 z_iS{(p{As2u$P3g^uacJW$7&3o8LC$5e!v+$~7Q49TOD9kqC?5pRx8Y!kF39e;1{$ zaJclHJPdYRI&chB#f<5B)%WV_RWmxQZNw+F$nGD<&JBv|Y>SoEDAzrM! z!@Oa^Rwp_0N5EERUiMgye==}(m#ZRcE4ZfJ|I_lF6YJrd(1%>3j?s)xy^T}l<-y6@ z&(IBY@#aMb8^@{Lw#uS5<*j)UpdvK)$=c6tCs}XFAKv+*TipAEev(X5KE?DSKfO8| z0Y)J~%$?8Kf8wfSL3ce~C;Q7%cdTx60IwCHiPX}IyFpf6@J4~dhCGrFs;u3 za7E9FR%}Arm8;&lgJi5gzLqy!fnj!NJlr5-Z0reaNjQ^BMY)6dg@ta#kv(fF)HCC) z>-~CVPK&5VZA6U*x@5ng>+*=DX|Ghhd_!W1g-ZHC7hP-8a$Se4erB>8)Ca18PwZ2- z3U0Z=g={X~m{{n$T`)Hm%f0^!s&{MkR&9BPBVnA@=B^@_ltP=gA z2_tsp4s+@OTkaV7qg0f-LsS^45!AW5zzIx7_L3o$`-3 z&|Xeo(>@Fp(UGM^D8zrz3k_LYCV98rL2P_E&LVbZ!f)-9iIwHZuDOpecK%25ey4Nujs~e=$GedZ_jARtI>_Hk2PzO zsyBZVL~s1<>+KkRLUw*PTIT)znprlFAlnZHSt|V8Yvy&85s6u$59|GCz`LkWZ8f1% z3$rWf6B+zd$1hwnlw)Lsco6qYyw!SzA!&iLDr7pen6WDAE9YqB@D9J?pAfDO;G1Y#4=73IJCmsC_pXOUEbIg2sD0?q+n~RQs7KHqB|( z5)g13x4NF*@YVh=Y?8LuFRWUgkvq*)U#~Zu&*+!%&9WwOSK8AF-}6(IMDF}=_d8yV z-h+l4lbeIGg$vA%d@?;Pv&hU-S5H1X&uj}N-&3yR$i0XZlVF-tUbvE-qdyx1<}wC^y|~Z`6}PCm zIZMDHQS5oz`(WnNpYF$v&(>?(0@TiS5G?M?WfC@3wpq>o_|#<4;{?mx+P?~}3;JY? zL*$n3mmcm-)i|$%I;CEj&&_ImIBTOp{v0WM!T?(_qr@GvU-5q3%dI@CC12}>e!XYK ztH!Tv=p;UM+oQV*7uU5dZC|BQ3JwkZ9!Lb-25qTyFcXj>#LoYyVvX;t4(yyY!S+78mYIm zaAQN`0eN2AYHzVlbL=Sodp2EJ=<24wI=nBB8A@CuX>#MFd$d#Ug*M_7mWbwUl=x&N zB!HViDrWo5;7}(m>7!GM{lt!!o~&H1T-XXSRjJqsG(jxq>Tr(xpzAOQV{+|Dy6@(G_+5{c)(HpnR5M9b5CK_ikTOo;#&RHjIIYj=W`Tl$zfHt+E<2(O8rZ>T96ZqAo6UOCTURf zy$he{)aj{#0Yr1H_27xvequOp>zChB+75<(TDr=UXNbeFx1A4@JW`8@Z2gQCu}CWd zHBVY4)4rceAHVC&wuW*i>OM1v<8yK5vhg2ns>BN>!()n-&zaH2sXvXn;8oU_h(GUf|lBBiX(0V)FjN6b+a(HJ#MttIrvlBXOg2F|noZVP$Se^$y zeeaivWcA*u9viWZ?k}-HEQ1XVbCx{^iTF>LhvPn>63+bx69mg`%A&FsddqLPzYz7> z&v0t=+`}`B2Ky?NwB?kJ!lNF>%T}}`9=&X8%{#Y>SDA;=CcaEc4Qc4^@y2@eu)`mv z5UWO(iBpflv68BB9R~gEw_nuM`YXBqgx-NR8+?D^rB`iN{wtb_6eg=t&^SHj3j{F2{mJCn*4SLP%)|O)Yl!U?gW2wOrO6C zdIFg7o!pi5%mgJt)DwP&nvtO|>;K%y2HB?E{RYcLE^{sBY9G3W<&v8+cLyI$V&#Tk z@}U5ziu;`k`_V`BwnCpNI6+y1{Y@Bw&PM--lL*IGn+UPWzsvK1hwIU&_p%xS$^PVY zgp*g6g^|+kOfbxJ+vS_sXO7N!$Unji_fBkniI#O35qB(grrw@#F#b14x{w3eskX(sZ zMc$xK9!~O9N^RP9w>dHzZEP#x&;eii404QV4R+4MqC(<7gtpbEo5FNqnMH|XnnMZ zs+%YtFDunPSNH?MIfvOc`HQk@J`@n%u7F->?;v2eFXT#`1VfyyMb10fx@eoyM~Aklwr9K@*3oqbin#k4 z5x&&mDxZ_$GWGlw^wyzAn$~U7{2}~|djlS)cevD~Q{(gMs01-qF*1b+&Ad^T?-=TV zC>;Qb&1;}OYh-CtGrspav?($%cEtbh%Q7Gd8;RNtd#(EZv_&q;QN2OUe{*Od)xaP{ z$1^(m%y}?D)bq>bX9j-EE5}Lmn4YK1CfnN`h*f~!nEp`&n~&v^eWiZS;M1ov6M~1+ z6@YURwDHh-UTt$E;6g3PiXh65#mD_(N{8@u_;X{>a-VOG#{5gRc)i54)n)@ls8kf3 z*R=wWg1ry7rhAW?jGBGz?Cg|gt7pUdTf>PjThoVrz3WMwZd8AlkFoz|@nEojLBK%j z24Z+%U;r>0jQq|4k01s<%(fr|uLP_NM6`i)!+SD|e9TCS*8MB33QFYTLX%tvdwatx zUdOF9prvhSXoyfiq)1#a3x^>vsZ90h!)31dqCaj3OOuN;rAk1543fBTQaz@kT3%ju zmn{(U#I?`P8p-Q+9OsQzQy@UcVV!&X#c$A^M-!DcDk&nXJKMsHjIuBoOi5~9RttYX zH50zp$A(UPjwVz|W$)px;>yu!^xU_$aM@vEWL#TW$+fXkw;?nh&qW0oTI66I4`1yA zd@u|W*33)lSCLGh6tuYkMKWqa%TvL#%I5Cu%*M*FW7azC-dXEa+Fwe?0?|0ZL|z9s7wytqx)a&^r`y+E&Cz_+WTnGL~`BN#>L zuxOg&w5opFcTjc-Jw*FRq@8SM6OjQ=V}H}^*jF*mt-|)EWanLYZ{Ny^O^R4EiiCJI z7%9zx!MMFGFy!NIdP4niRa^XzA> zl~ym2bpj=I{FzeNd8XuK?euMI1q_SaBHJxoGlHf5H!*yliUiOpH#z=c zKn@Z;{O><$gRG|$omm47X-I+Qu{*P4?+pD1=U{9E&Jg7NI%ol78~`;i+-bE|Rj_r^ z^>tr$4M6!9MV)mqAGhtsFtQq@TisJO8F({x4!DI0@sQFRqBR z|C88xMZWxph6%p7qF4Uk9LxWZGyi?zKlIxFa6kWj&A&ebSO2$d_#e_MV&^}d0>XU% zA#wiev#ZOlc%FdM`A@(8!|wd2hyP!f0dDVqiK74M3uyl8voz9{hg2It68WG0|BqI# ze)nIJDQMsyqAR%D|BGb$!q@-59smCuo+}dfKX34VHu`Vo>e0+UZGu1l`9+JH+W$2= z{~5NcPJjN_qXWw9KO^yf_2@q@?BC!1hg$p3ApEZv_D`q(`Py3u(+khPQ*mw{k(bN{K7d8SM0}x_jRrw zm5W!;qBzsIi?6&Z_rcoiLmuM2YO<=H*C=U4{A~UivkKX8EI3R>1?n(r-duz)TTpeo?nAY;bDgUl=-D$?hv9{WB7Dho zOKxO{q2_0ektIo}@Vk#bB(U2mOnJet@{bg-JeP*YnQJxTTZS^etIUR4pOGWvpiMC? zo38d#@u_{8(8^TtydtrJV9t%IFyj#S!hD#Q>y>L+su>s0v0Pj3-cu^ok zB9nF_eFLZHs&PmSSxH9eb!AkFpcf&Qo}6AY~7JOL}dee&!`*aA9xXsEIOpwLG=y0J-B*=>GaHR1V z&uiQ}z>}wC;MFl|LBi3_rzZ$^6X>e5qN}Z)RMW(6RFib)zM>YTFY?kAe!)QgPyhIS zTs?K(OOtKxNa9>3FKe3eHdGYCR$BHtwqkK;Bd8Gb6tk$OW%1`m zGq@TNkdg-23st|jb#BXhBD3FykFLYglwUtBajM!nX(R#DdNuChAk*+q)bYhQb10*(R~#78xGhd-ln z&qI65vqvk^ec8D)A5v@eF9QcZS!4-;s6|Hp>QT)Jr*5Ep`em4bKtJvw47;}cby9sR zZA@$C)o{OB<4?`$hwzCi=ak%6&xe|WP$TtLtp8r=Zh{bo-V`zNq{p{_%>XbJ23(lS z{4Q`g9>Ds2A&b_rT5;5afxwzPM}zY`Nb=SY{AE$#+rgq2=)i+5mmR0x2K_60<9`sc zdbi_7uUOI8Tc84U)tU^1VPlGV;EE9VV330i{iz`dswzo;b!&hFNn$AJeDp)zh;ydWZ2dgjy-#dfB&?NXtVP0-FH=RTm<-X69M;pe`$Z2`}XRxkPu8& zldQIW#kH$j!XOMTgq7-Dd;e**E12c?+V*(10yVgnH7H}C<;#NQl~r^JLK&*ZM07(x zp@5R_(vVgwnQ5)jA#Zgxq_oOX+}v$MSzDBjJ9@SA>Minvg1xo@_ZITX#vABD7Z=U^ zNgb~KNt42AsQr<&bOL-yDJ)NAMn7G@il%{5RVGbmoQCam5(&cT-<`SY{FPz88V++T z&!$#sese@YQW64z0A81=sj0f02pkT7^X3hZ<5^r-=-w=V)y*^z{7abNUyT5DNOlOJ za_G<@*+_1@;f|{D0jm^f|F8<9#tny%Yy%}K20#JVh1^+?dG}Y-JX(I4LJ|%_~f1!O&mr%Kv#5-)oStu0EdX>XDHV<=3y@&k9D&&B3Llq|Vvm zehlh0mYUc~#3n?hFpmo8o)A8MX|lD!kgs(ojEo$q5yZmk^{?&i$^!tq#M&Rh77cA} zenG+7XlzA6K{pngMFeKNfM}w7=ToBX*A(DYxzLx2KO@-JuR5)S^>qs zmlW_Q{xt+{2ozf5;Ty+_6p(e#O#C4ihD65VD~FLzd9&`>$IIz_J=xU1`tkqM128e) z0)8FGVfa16W*@fsgv?KENt&?{9euVN$AE@j*l4iKX>jx3GvI2+ys~LlZNXM{i(yk5 zRt&Yze*{Ka9?%H9ZMzU1CCyBj$Zf9Tq7^<~kcq$c5znz@2mrG&AZ0uGz{Xzok}BJ-@27T^Rm8$w)ia zIWHVK=Cn7}YNbe?s-DBnkR2Nf`MHMaocFhJJU6k*K{1Ji z>#}Y>#ZAcoeo9+wLX{t_RG+8h*}&n(dS`U+rI=N2iJXyPxANiZgl3^(N53hjVkKTS zM88*x1;{^Hhosgafo|u-vBwLYrccxf{3Q?-ha!XuhWTYl<%4*>Yzc@GYZt$}`gsuneYmiX$7pU~nT<)KXUoQJy zx~em%QNOINI$dak-UGCXj>DafaxqLe7$^zPEIp1-?N zHExG5W}vplW^;}O7f+^a&!sh!NAoZzN zZ-GvfTD(A+KSX?u(Jb|^MCU;n+4y{gmr;*aS(&)pn2#mOimjOz8S7q{bw@FOJX|cY zdoRel<-^_!eL(r5%GlltDG}(h4&eX2s$!WrKW-l~OrOQb@neP`E}~0ZwxoGi?IOwx z;yvAecRMb4rxQJzAXn^>bVwk}jenH4S2a}Y>RI>7bZSMyUX}?pLM>xuh5X&o$R>Ml z)ysNT!CJSnN9oGY@~yD&#(t6`%DTQ^*B)6d&ih@)ezZ=Ia@p-H%0|j6-WyQwDtLR0 z3ZnzME*cgMy`@q+kJwUF2BMOToPPY;DPo`tJct&oK+}!{9nLqhIoJMXZT6m_kJ{ev zLSI=jrB~M}kt9qU9wl;psjn&IRRFW1mCT&K`G%j8jHw%ntk)$ zR(4{laM@N}*u7%f>ZD~4H>Wm!-1?x&+9zUT<+ANg12BK1Q2|1RNza9>SEudT&R7&kIj$g1y zld$UP+FPBqdyI~v^;S0Nj{T}?XY%1nU4h$*8TW{`baPVoyYK9-ka+H+xU7?O7|> z@Hv?Ja+z#Bp`tm=DieV{5)QJWHe^&cp(KX+KY>iiS7ipYBw9gc-P{|!;ro(m4&{S( zq=RQKsWInlqwL9CY1=A@96r(ZicbJ{0;imNXMBb--L3}fsi+?LIiD5e2PoG*M& zeYYHGj;$CZ7@`grL)azdGXi}=_z4bO_~Cm>Dcx;qQhhh!3k4GuFSWN0MI4S!v-np7 zakpKfP{d&Ah2GbrIUuso{xDHM1!%lufTjR_cJ^!8c$@HtBvDcI4|}zxHX(|h!2v@Hn#QzqBXvp>*unDC1xXsDl`|(TrjAD!y{!>w=u68Ioz@?@tdg0D)iEiL73 zeGjO~-a2nZw8GA3-9@6jHHw(Gfk*cU!p_d_YIjb@!h#WnE0kGom?j0o8YBV49?#v+t1z!Zq(p|g6h+wZP(+iXXmI+I0D+j5$sBJo~u%ysp^ZG1=KGG;tNeb9S*WTHPc^zGbQRa z^wsZT{?gWfmzz@~aNzdhE$iM+>e-jpI?XJkve2jE-ov!Sw;MAbg%{m-t9eC~;Amj7 zo=4Hmb9Q-l>gCyszg0&rxriIdqmPa~dmd3%@KD*l&YsR$_}kIYMND)nkt>(Lh@KM2 zHyT0APPtYUIYS^gu9&EaX0EXd5pALMk^RBG{lymC0@l8T;ylX6rier0=h3wIWvSDL z*BKG`!^u+=sdyIm3#qx`Ul;EFSgl@@mX0RIQ)hC+Nrb!Ape9Kg_sXF(7g5S3N z>x{KUwOn1h8Xo-$!_b9&2aTkPmT>*1c`ngvSz&MF&mX5W5DK7U={lb12|Luin>7?ykM00ZuJO}ysb-E^@)?j13adP2e=wyHz zlws6zma0hQ=U)ZhShl;q-<#d~>j9IuPwCYk|rn2cPZStG4onB^Eepy}jV ze22CsAR_6mRXg0GV68k{xyyeuN8WpS_KL)e-n8laxNe&s7*jZ4#dsy0+d#YhLQOkZkY|Z8U&J4%(CL9X4pi z)Z(22_Yo+zgrZtKSUnPw<`UOs`Q#}q&@0SZ(DkCXtPCPfzq&gzS(H>=6@^YkW_wj7 zk_L3Gkk`(OF>4o^1Tw{w?K?$AO%xe)O&(1V$8Bm}3Oai^K&!dHk1Ald<1w&Nm4kw3 zF9#9j2ZFCY=3Nr$UI#iR;QWh1I>fN>-PVS_1~NahA7xgwCV{1Jy=w2y-{0>=stsK{ zAI1yEEuQSGWk-8yzl3+5?YK2S zG+Te*?OR={iWvYKm8x;{wdymjddDsEYCB48ZsQq0jB1OC=4CN&P(cR_B5u(F+TNQF z^igvj89NW~-?BbKZekYAbG)R1m_@-~N(%GJcx`+|sHHTfC-QMUyPpQ6MsS4Y;t-J8d-FrTXMY4gY^VlQ(m_^tHy^HkGUiw}yVzh`O zm({$AAhn=@&YyO_{EBJ{)YSr^4|}}mw?2i0yYvUkaWUBV^fMx2SUT~I@LFteylOTj!ctBVPFib6Maig3X zlPlkh7xNDuG zc2p6=ky58VhkbreCd&&n;dLG@xT&{x-!>&FAk%z#Umo8%)39wcZsX z+E@J%1=qY-Hi}6#fc*wAY``a#g`N^VF7YYW;a-mPWkpZLZQO+-FkT%w@Cg88I|&XB znFgK{@WuC0>dy~fimj$Gjk7{x#;R5ha-6<$$U5>1J@0lkBDn?jE3m6m^2o?Sb3#H9 ze^ej785$pgWXXi(wu+J!5C0jRG2N^^E9gNVlu3>GIH^;TVN{})9UFge z`Ft7`S26Xe7nJ3XVRdY&s`wZXKrSeOtr>=m0(_M4jVqF3&5SzY?%y|T;MbD$H-9aD&>GtG$5B>jAkhJI!OXA~ z?z3V51cgJ~$)ieeP=T#?Os(YL07rG9;ZGLw(h^=*+udD+?%}}a1|4r)V2Rv zb|Gjgq?&kvcC`q@vr3t&c2d1ef!+ywGGe5n96Ixv`h5EyBs*_nZ~@s~W318nJ;_v` z>dNi40;kqs7S8VxG&SY}Uh%#~7$tMk6pyu~ANm#H(|*ORqt?kk+G7i|dXUAZIT`gn zn*}qXmuz0PKYoM@DBc2t)q^PvZC4Ou@Uq|OPv3x}Gr4kplt)of^*cyHR~d{~gMs>_ z_d{4F9+oHW6wTC|x(RUb0O@p!0z^|?(L!ae#*7O0-6P{!pTmeN*RutdSiA2t*@Dwe z*}T=^s(jLxa(Cmgq;~97rOVsql%&Sz&bFZb@LdeO`3P3^4Mt&+#l+TX>oQS28bQf5 zIS%>M`v6A!T{m2Je#68!z zoZ9#fw)X}LIwb!Xc6OI2PlBXs!inRb#h+XF{+!0W{u!p#jx7~@oFDvAzQXX6jIYm` zbVBS{AW9hEiSNmcsGYYJHm}cAb7PS+Y~6ooWA2<#-LUJcwB{qYnt!)ia7v{x<4-d= z+!zrM_N}~`;~9zJd*^- z-b#t0(G+RRpS7U?7F*dJN?!bCrrOVMX8GkgnlR<^VPwp8h+QR$TxJbMG)D@v4)6ra zb1)0lnL1{guMnBPQ?^#6I&{CD1B}mhT!xef`K=x)gnB_AJcv^Lm zq;SvGZY_jnlhyMWM_Kw1wnss#``yUMw(${=X^BF0(#*EwN}LWln$uHB3-&YQRqUY9 z)y37(p}4-(tMtawJ=Uv2uNxVpaXxY-vkWAN#31Ki$4TeUfPb0z00vBNU0MCHlY?E} zF_@ql5BxVdU*0jL=+ zBF`uS^YBbW*!3EF6AZrgZJ!Ru%-c#&`KQKr-YX%1cy3GPI*WbcnE#wksP-KjI=EPr+efs8y)cm0igu)g^J|D=!lfoqX zHlGYNKRV?>`yrvohMi{dvyk&+vg}6hHu7jxo`M72`E-@%NSQ}8*vl2U>fRr`&--|+ zwdgD)FxUeQpO)yEJ-N02-Sjcx2u?gF5k_>f+IIP}FNuRI${~TJw)k`1P2D@&M(!8w zbzX(?DxgS6iw0|o#rz1qUvuR2jpGY{(ly7s>A!D`<=7dBa&tlh^S+YKv3VXGec&IW zG1J`(W*J|OzmZ>Em{RNXA*lPeYndGXiv->j#NF9E@1+g}^~Bo;`TDiub^~`DxG{`w z-Pvx$$Ce+d|(sQVHD+Bh0y!ord<+=uiAMqQ&C4B{0iMrGpM;y+bKzkr=9sn3c>Z>MZ%f z&1OnHIeAIlrzWTkFU+$yad{q1%Kd%!u@&q07X1QreDvqe{tsbq9T(-=y^C)X1q3BU z1O(~s4gmpyA%{+BX=&-Llz@PeL-znfcY~C44xNH@N;mxO!M)$_d(Qct&)I*thneTO zpXaW%uC>;+)?LtZ8m4WdU~dJid7Qc^TmN-Vf?P6s9a|b5>0M|&5kijZU3&or%GE1S z-hQx;m+fN0Y%80X{R+VGZtStl+Y+7EN)@U;zw9AoW^s+rgjVb-oGdZ$@Ri+SZg1Cq zb&ZiEYFHkAVNDkWu<8rAG!+jx+>}MP29JPXRN62uK0X%?H#IiJapy?S_0<0pWb;}= zX`H`66}p#fy#>t2SP#L85nMbxEKE#W?-}xQa_k%&(l@mECm&*!i-Rk{zWbl(;hL1; zK6{TzQ&Tc)(oz&zWn+-}=V^bUj(@RT8X9)- zB?-Um{679B`dktGxAi%oq=el;6jWWm&Mw+E{NHZ~H8 zHUjsm${k>-7{#hx2Z zaw9B<=G1k?@tn8|WfQCqGKhnfKd-63gpY8UH_jc31FDFE{U)Gi+yrIKWplFYPqkJ5 zvTt8$nmPEi*s%2&S)rsBe~qBOt28_j*&b`rN%9fqb!aHlNp^3YLlMU$&vh4^$q9zU z`kq2=`c=(F$id*mv^1x>fOmHB!CkgCP9(F~=ZLO{fr)^lq6gXEjuJtHw!HJo+Djb@ zL5~FFjhnugl_$c-zKQY^vp7topI3qs`r@wER~v}8t;#D(&y3RO+%p1cL4jW`!ytKN z|B$YmMEdTw^37;Y(w1}OG^!hvDA9z!SKXMl+oc}D1?6m2Mlu>(AV~Q*%os~ExE*2* zb-$cp7hd+U%jJ`c#HLG3ONK3^93kyL%^X|eTz#j{?jxsZeWhpNja&n^Q4qfSNT)^_ zILV9N-kzs^y!H7zFo1M$*JJwa5lZi>;KjKn!Fux@D@PlB2lGD^4(=_uM(W(I@x6`i z^6xU$hU*|h+>Xqc_^y0C3hTX(3eI)NZ zEa-y6_u7hvHU7NVNs+wunfvfDNh@&i8wzq6hi;n(M&al+dGT@KKSmPRXHnxiqzm{W zj4_PLBXF3qUkA#r2hFeTf)SU7#9khOSV9{X6Nzeyib5IdmgT#g*5%9_(SU^0<}i8a z;GRq2JG0vowkfG&Mum|P%#Ai5I4(yTD~cJ%pl>iU!>2Wv+%!l6l9GhKm< z`YFjgjn$W@2jMs`Cqu263o_OAv{&V^`ap+1kJQpjIog>tG&D(oYCpVLpz&EL6`N{u z@{(y;jh9pkrNJqFA7FY#!~CAxRUeGdRyh3|zS-z_-ES?kF4oeFh>ut&{+ajjffae5 zw9SZ8)2=Q6+fJ$dg9B zB3+|&WU*{tHgRk!+IBXSsX{wR5cYFcX?IvZF-RV;NojYk}eFUeQO=Y!VI+=? z%TcbCWtR8pTg&!43h1(KJFTCPM}ERuJji)TdP`V$!W`u)0S9LKN~K^ALE8=A<`L?D zoiJ&si4UTiCt3GC>S4R95%9v{D8ttHt+V=M2PUv8cYcrj{)=c0mllJhnJ+e?;mIxC z>6?bO$>Faxv=aP}GR56pD5}dEOR@+YK#hHMtc`63`0LkhpDG%b=PzrYSXnQpoM15t z9d`7zGADu3aLJjk+APz`d&R;2GIc}X5z4N#ZjB_Ttk64)b-96%GDU10#`p7X@UaGg=U$X5>Q8Ru6s@b5fM>$KRHG=s|=%R=pJL zI5qZCbN~}XK((c}gwQeX`R&ub%x6$UUt!v0qNwo+M~UbeWk?fGv-%78Pi??9x#6e& z7lZVVX#evApnsl>qS%>17w$_b!SDC=s9N!gC)+w})puj>;2Q?rK6E0?p6=I9L5*(# zEgaAolU1ay^_H%WbqlZSHy+kt?H~$-5TQ&tOujJo$gyRSf>2lQ<7bBD8^6t>`n%T$ z*5eMECzV0jaU5hx&F!Ty)@}X^yW{m>L=htH3yL~P_hmmG7r8LGppQtuu5-t)P6=Mg z2^g`HD5sh$ff0-lfF>`06|gL%cJIOISJkYsP$l8b?X2e`)>lQoUNoKp&pTL_Z;@q#tQn+Yp=?= z=%#l)!B9-L9jI9!)gm@%k7j~nR8vjLPv_!bYNN}|GPTH#E8S$Yk%x&q=nvVfZ9gJ9 zT|;h@Z7oe{vi0&E*S2*ZGSkQdU10=`s!TA2H3x86m7r(QiVQe7LI8Dn7> z)G)N&vEy=SVW|v=oU&flr}>l9$(G@ys_kGDx3(Q^*_g7K+%@ro%3sdJw2u@gvdxuY z1ktsvmm=P@TJY#rx@1vf7*1xkmQ_`(YC2JVDizq%R{fqB2LZiO)XzVr>+8;$b^t>WyKj1&ugsK;Q7IW$4d+$)D~*28svWKD^b9R=e|F(}|ah z=>>diE^t9Yb$pDFbVdULNUC!x_tJb_Tx=w@`2^x!15UCcmpt=P{MJ2Hc$jTKrHRe_ z)$%BF1(4O6Bu!OSOAgnNIzRku?j*-wlhSb8 z0-0B49HuxJ#cwx0+RL0ndAxy(6e!n(J)D^d+*1*8cx^RTz$8OoLf$zDob|MD7fbfy zpXIf+J`m-?){W8cXoj7<6x6k=Zn08kG7S?@sw6=;88@Jsw$9FP4W0Y|0TtI4`NlYVF zA7*)On(heR+MoLVuAe5r!+!T0U_9|Y>4xIU2ao2jGV5~sGv_kbAs?owF}Y^MZ6xA}{; z4K{;Hw*?_J^?l2L#{Xlm8PZ|4Y;RkKOT43c^32`i4gT zFDL&$67>dx{sHNr2lr3TL)#;s6VqI#8-x;i_g13Vw6%=hGtS;H^Chbfg5y^g-C}5{ z7bwepHM9F6&T_-nX|&~J7#Ux2^PXiGfpiZwBjf9G*1bGk**Lf!o*nTl zo$yBWDzB&~zY!funik!EH;7zfAE(kV9OXq-2igpBS;hj21EAyuz`RJ=sK{jx)QX3B z-xOOQ++OsoE%dJu97se;5>3lj?G^Ma<$f8Fnot8iucM6_pW9BW-)EOC(Bf=fduG3P zSNi$NiHQs_0_qu@Qhz)JL(s+9O(zfH{yig9*{_sz`~K zigcH9DC3Z^rx4<2UwOJ^C(Q2gw%2f}|Na2oRC$^zC25&m6kwB>*!NAvyBrXkR0yYK zIkNNzwNY>fVD{gsLreol)0=c+`)~})q&cF6_f4HY#~YY1s2^erRhUggt8(aKhIwCk zwf2vyqulpO73B*#y%|~7kCEED>PObPZ}VMOU4QX`U87WdCY7lj8Q&aqFT(V5s4{;! z-}j@0^QegM+8Fs*)&vUYWB+PX1RANCrgy$)<|4YPG#oe-Ac?GLnryvTLpt?u4zkFu z_vfxJf)TT~F1^xjH@FQhYDP$50B#=$dy6ob+myKjJ5ZDDvc8#XNWyDGY|tE6N{7Fc zYakSwg0-z9sB4S|a%(gtW!$|x%TKk=W#*#!XJok=^Ipi`Lx3W_$F0)Ws|V8Q_YZff zEia!ta6Pm|B7yG^gg4o(hu&Dcip$5N)Rp6msUcQe@mCeRoS+hXoQNr$2lV ze5j%$Y`gH?ONgs~3)IspV?H(0&=aij0)$514r;?M&+1EkY zTM)gU8tbv>R1_8mOQvqE8N)0z#6IHsSM*f78=H>HWl4^aB$nfVK$i;$J%Zyrg*%G} zzfLr~Bf!r#^60!4&(!{VtNKwl99WrdA~T;ZO4`Iv6C`Kmb!8>7wp`YFDu6%tQ~&8c zL3sqrw;SL9=!#-(R%;0liDMKRiPBn}MT=Ev;)87C%nBVqR^5C1hhxAiY%w!Lcjx>t zQlR0R{c`|?TMy)$qY^hv3pHNg>|`?XrpMS^tzG6~E*`&vxCS~#B@0-80i~HDX_IHg ztP!OFqh*vf0Hh?tqNiEM%f0%-`EVENBkxMNBf=rsu~|+AG_40lB7Jh&FEi^wP=UYB zp);R1{YTPK+CY=c{s3@a{}D?e)#jtdsbKZDyE9-EyiYSNOWNE9LFs3?x39Au0m<#U zW?V_pg4lhpTP#2%UYq8%<{lX1`n7;j#u~$d>x$vn#IFN)4?gPS^9=-~PS#i(o}~`; ziYg3gxF)Ax4X#n7NB76W058ZNMNEs9UkRx#@tRN>+-(88j5>yuodhrSWy5@@4(V$R zBSRT|PR|)Ub*9r$7)>K>S(a_}goY<{^L6oA(*8Fs{um$OJG#kwC+f23SjU}s1qV6& zGLX4QUZUJhVz!K(RFYr@;zC0(F2$%Q#Fhq+yZpNaBsK2h~Tl|x+_no z@k-6arQ7wJwmnh*%(u5>8{tVP>T7FYeVm3$c}L(; zRv0s_@C`9o|k(L$e3?o^!w zCA_uPGY7W*b9H<1InkZfVxevvPn95w1C`9mL0Oa-*-!TNZgk#_eCN_OC!_leLge?v zjXhu#@S7t}7Z2zGyNsas+4V2%Yl|qDa94#|_~e2am8U=x?5alED1dKOrh)c7NL~ns z&B}6!FgJL-noE`^(~$6@KIv6XF-0@qvrc0i_hGX*VAs^fn38J* z*sbX6sqvS)0$LfA8Z#OAj}4HUnBf9xfl;%+UpP11Yw z?RK+)+ZWtt9&e|_=tV(HG)V6hmw3&{Qh!{!jll2>K$e-;Mlzm4?icTm2I3HuxJ_O0 z$|gUYLdKH&4pJ5s4Ct7OO@S1{iMY{6wzgvi;cSP^9&#HOXMHRAdO zWG76>gg_c-kW;FydTJ39!oX!*9wUjpBVyY6-9c(}DPV1n{sq3c%;3HG8laPm!>nIG zd$7l%gevSn^!~uW>ugs4Bsn@d{ItPy?s}DcHXq zv^T3He!exu-Z)Y5y#5KkD{A>6L7+(`>MQ-h`tBXSCJ?+`fqlE9){|TY)ES^Xtw5fv zkJX}GI?qMl13EClmZR$};I$p}a0Sy;W)NYsS?@5txXgNHbMmu6$m^oAxl<0{kX~mV zWvI{4z$YRjz*V$>_PoIbE_Xo1-8-3YKW1)>`YrwAG=DgDa=J9@!8hJnInGoXq^-An zWlBPc>(aqfY>A3X(MF1R9bSj&q>z1D;_$#BjvPsmI?F&1XjhLs67H)o&C1p1FLeTx zd_+=v=<_P0Eyh4=j2t_CQg=R%SHCtzLmh)c$*6hPB80z`kCMx{PO0@nj-V!9vY{K+ z)Dmu@%2V`gRQHr(Cgg`8-k*Gu7GY2BU{&Pp0}t6Uek1m&5>O>SzM#bT=pIz z8|m!q*?DWMW?v&hR&!IIg*M~?3jclS{6!R~>ap?R8EFP{ zQI<}nTXFW@8dD{1fud+i@QJ1jG$%DK-s9Ub`tZ-{Jjw>Z+MEfl-N}qY7GBk~6f0Q# zfZhiy%`gBX`|iET#4N4kNnOAyR5^I_YK_dDyB8M(jw~KK_v5fc0m-R3!UA4qnX zk@SBS!1M&_hQW?+L1m#oKC&#N@dB=EMw|T16op@A_8W(Aa(DI*x|GVrPEUXLQE999 z=Y6Ra6LE!^OV5k;KDFp^ne8Ee`W4ap z!W41d9!6^XqA?)phxR52q{~0$Xw}&=!U5TKVk0XbQk#IBOg7fuKjPM{Dk%Pw8(GOUOwW%o+P$-j9%Rv6GGUvYw6U)C2g(&;mls#Dus ziZzj7dX9*oRm-UsBexToDJj;VLd$e>0gUxXIj`kd$l2GIVM=IW3hI4VU7l2ZV!WU#IK8SZHo9 zMi4v#(6g~?D{VV7R-eD#>9Nbn8{wG?fGng{xjA}m3~bMps25`?IVcH{}- zo#m_n+G$R|uVqQHuvL|L7XQqB@iTo^CEzGFaj=Z4SX?8>@3_$=jJKXY1V|bgAO5RA zpP!3IBmNlMYFDuVt$r;|BBJw`F2A85A&RvZxp&&8wI z&7?*`51-F*)_;3Zkj@J+yqb0`2AOa!YQbNs2k9vW_j$Ab(zbY`*h@d|9_J;Oc)yPyH$w1rsxeC4sbXg}(JIoN%#J6WHUZdc?(f^vrl#2@q$Wmz zCJG^9`>wVBSl>yOTliY*g(+HD+|>*iOvb{N=WpJ*iv=yH&Wh zTKsfCrt+1XFKvQS~h&y(2@u zoUja(h%Tv#PO58G= zehU;81Hos-)VCryFX0$wA;E`=iyJ(<+!1Ni8z9|dzr|5Ai}AtOOtB63L*~m&58FXd zd$*Cc*>6+x!=CTFu&FW`{WM@^>q4YuX=Au);XS|W0j|h{Idc!c$guFkyJy%XQoAjm zRt%^RK4-^W{gZz#=*<>{=smH~SmnD-9*Iyz2H9Y%`K1U_C6R}J6 zng2Nv!Kd>f=&$&aac!Hp&-M|?f?m9;D=G>Y{tu*o=XIuE@9*q9T5KIB07Xt^76aB4 zja4oSXQOHr~|3zXbaEViL>}!GFw@YLA%(2Q7T=IQ3zY86isQB9AU4aJ0){~L zcbyCPAR^^KNrz8sF=?(p4%pc*acbS&8Sp^(FNG)8lGj<{-h+QO#4qg5#FspJV zeFhJJRRt5|;?R}41Qx2gO0E%E)Y3jRQvx3|{7T(6D6vCuRUw@s8IVAx)RurF3>=i^ z?5>x6)Z*`a*RqE8Qf;}XAZ|g|>NmVKP}6GW=bMz&=A@=OZoSED1csBpt@EYXki3;X zL2RX8SF3CU>`INvFt-LiI*#A@@+ ztht++BEC2+AcpSOvfRSQG|F8@NebrBW8X^+cC_}E3? z{RYhDRrTJ2zX8v(&G3xvlqQ~tE|8->>-zNA#l5npzc86w<|7kR@tOYIb?Mro!o79t z90#=*S+-GH!adjA^=Ydm;k=+KGCnf)$wT427Ds76RN@J6-HeVZ^jbh5v1~#XM4)!D z4zCv*0CM@piTB>d8D~7XU_$(9ep|r?;q5zZ|QYF{Y-@ghCigT`coN5<`sS)t(lWmV92`WW=-xl3 z9H-?7dAJS$i9^;yaR_m*V&%dYVAHfg1WjC48LJIg&DNiuJ)D^^Ma%nDADIPtDym?k z2FW4Gdv6bI6cz%@>3Qk!p7}gZfhCE(O#THTE^r`SROEaX64zK!Wum6 zchD7nK^?WnXQ(WYJyDqznCo-7<+30ev-L&Q!kjj7vIin4L|?JVUAZQ<6ibw^`6Z{7%{2Y2mA5S8l&5Y87zN0wo6{e=(mjC9=`zR$@^k{F6$`Y_Ze5kNKgu!x}q_FD3|ksY`WodQjvR$j`PL`d+E>1VvO|3%>1+XqfmoG1sjNw(A=~xcqZAkN0Hg z_>w&OgnW9X!m^?a?9Q-(-&ZQPPGO1gSE>TFy4&MF02p9_@o|snZ%K!Sq<-S{do*!7 zViw@Ic*JHhzk%=Ym8xS7c9hNVbQ{535}Kf&C%XQEByza~riuTWn% zOdrYyuH{ll^8}I>AC-Ybn!*T-R*PThq7o+2MI8M$rDyEnX_k z07oCMn56ooHj`R}+hg`$V2=3d%Rn}gSgZPh7PkLX26K`HX zBNMg^dK}xjBj&F&7}X+Sj1cWt%7+Ix!(x*$aEM3m5jyKgV@(sNgNroihg4t^Rjkn zg*r^sur1PxrCCD${oMoyoAuK~AGCusN$%R9Mr*^#9Pv|39^OX$Bv#YUF*z#8T4~^- z1^i6DUcp~AZbtVIjLUmTa{IvJnko120&Z=R@C3P2Wio=d!0MMd7rFY)Vt?EDme*8knGo>nJ@MDkzQb1xxM2$kQA_#LdwxDQrA+9`2;TdJ zvrxX_0X|A-S%Pp;(6Q=Hw=RY5qN9n6I3%9`G?3oD&p-5$^~2M&@AGw(?GHk#wY?PG z!iB5+C(!_Ec~HGEBxwze66=n(^Dj+H)eIJQ3BeA1hY8aNij~_xQ_Gxo{uFn6*=2AtZB+7f<)@6-MGBF87#2MpAM>?9gw*=9QvoDw;(A6B>*VbtI=+=2 z4*jhMvfo7dO0Kx(UDTtGDrX0`#h)7y=59?Mj)k3&<0Q)6$(!Npx~93m*(s|6|o$e`Ezq>@gJ1MBj*u_4{NOa?+nI^1vLt+`5DrB5D6r%K?PoXN?6iTCEz zphnMBd2@6#55^oTB+R3MVc7Kqd1s1XXzM&b^%mie*JeSXaP+9~+nu>nOTSd8!k$jY zXyF$IlMo9Ef3wqZR=ooB&qsR66A7`!Q$Y3xn}(dPh+JW-u6$~V=|Nl&*bt7Sz`&Um z?H~y^X)A4YhVB(h;zU>N1|`dcXdLhPRJx?S)3aLK4#m%0f<8yvoq8RaRVE(FZt1ppfp{bxNOVY1<>3)HNdir0chGF(y z%TY+W7^U;qzw4fxs(N8m23sgXCR9&Js&rL+z&SVHW%gg-n^{Pi+_T{HOri%&EIeol zn^}v|BWiC17u`o_tsgob{$unj%TY7BxzJ~$b2_?dP3#?Xiqjr_d0jiZbKc1AoFDj` z%_r$YA!&(T^8I1HyD2XA~%Zvm0?Wx9o1)3v! z`Nvj8!M^xNV9YQW7B>ll1IBW?V&|ZZ39*D{;k0y$Ts>D6)FYc6+nK;uS7diu7EeCu z@kpo3q=wK%N%Aea$kGFu#~JYli_;3pJqbeTG_|#?Vqut3t%ILxS(EJ_aap)F)>UTq z`J*oYJ8RdvNZ+I7?bVlJ5T0-*gPyVCOc6%6KizZ28890!^O(GwN>2LY(G<5V)8%Px zGzigHT4f|{RCNQYszNspC*YRqK*m_&YdmH%?vmj*DVYZa0Ov@a7H#;?{GQQJ!Z4eZ zFGW_ftsp(VfkPsBc~ZIK-guG`V!V!(g#KPeeD|{amwn|0Pj)|a2^Q5iDqKTRa}L-k z6x|7Q{PZA4ct>qYWo&YdG?qsfX6thaB3~7G3BZOiIc7ugt4Rp;`$#-4s-{FZ21M+7 z9+T}OnfSU=K{-=dCCjgSFYx(gLwtJqnNdpsNrDO`u+r@!(C0oA`JrXHpli_!sHDJ> z8sqRvfu3;(X~a}Rcgai|Vg!52?1w}o4IrJ#x$%3b^$xc0ww6f1qKvff{7nbk1p6w|u=B`E>jNhMv9EwH@|w1rzFDFG zoZMlQfM1|;sF>fHCz4tMj1I;cVf_sd`zwMCF{KNL`5#v_7_&#QE#aNz7iJ#BFNBHo zFI!0nABtRGc>#AjWz0@j!dk%a&|&G<*#_qdpIIg6vP2#3jw?ZjNg6KKmkB0x)rz6% zh0zH=e}+l`JZV*bW!aEe({t2x$rrKzh9XvyJG1CT?LK9DOrOlEn7mo$pN6dPbcEQ031@&EWQ>&hOey!>Q0ob>?{?4m;ss#BRn~R=PN3pbgDQ% z`qMznxIfaSmAmgznSj*1Y;wYm`N1gO25=Q#1DOV#4crbrj-~N{1ffj@@9|CA;AY>P z=Bn8`uvT_|3txRFkodBZV7yc$iyCc&|JvLAm}F#eg7xjR!)!(0WXNEFDZU1yU=cG^#m47C2ckH8ERJ@H?nd zblMAv+(0_1yk|2mj9MvtdA~)e7u0vy;%DFzEjs~+U%f+dnA`{5FURMF)O*h>evU_Z zTa^4%>~q$|Sl<^-l@=5J-oOYUyA&b{&dliF&U{7^KX$3?cB?dUU!X1QGp5jrd7jYP z239_Cu)5oae*0ZajOeU3n>9R_$3inTnx2|^9m3i{o!WT*5hE8~LX$E9xr|p(0s}3g zW|hS_*k&6h)!YMm>WV6)HsL$0ow?G){n2}ST-(VLvxb?hM$>=yTdLtAt2OjL^NB%P z3_r36r!v8Wt=em1_mHtG`@XR9lAUkod0kvk~!J-G$as)Qn{C5AHmDZ7=#74V6HFU=z7-VYi1AX0s}L zlDQ!st&wxpuD@!21h<>{YYLN6gSus5(slHHbTeq01e4 z6$x|uR6p8K9VXd8r*h;|UsHw?rFdeqFozYtTy8#?@|);vp|pH+o!Zx2bE~UzIGJ8J z^RrVJOef%IgAqO=JTu9O(AUnRYmF0TRzh_Rq)xW+DWWQ3a z5g(B9I)xU$2@lg|ZfISJhP}#dw2jk0p)SS>#hPYJCY0x0$KIIBu^3S>sT|F|iXF`m zT@n0(AxRY>EPfhPU6n3l+#+9pN=0h%w(v;J5>Asib=CI-@({{}1&vsWXiY2pDPt-Z z$Au8c^ENB)*vcQ&%Cl@MW3nh&ZEk!^>lLgjf|rzPoPLyK$HQFGrUcPSyD*h|eqgfo zY)>GVDkJj>n@`<^aINwDAv2ow;r+wy7t0Td2M9{%J4AKcAf8r@4IZVR9eqY01%%{! zy;D4PIK5*bcfnuyQ|G)^3CnPPAjM`&jOWtfS%Zdf!1HNV17jAp-ENzFwL|ExsCth{ zg=wiaS4=|!X`=SYBoj;TbMj~oax^(p`KKBm>Zu!AWuSttyX3zU(@P%1>DfZp+5>U~ z724X9{>mD`l{(B(O<&JSzL0{<&R-FfRR7KD*&Qgg5XLhKYvq)&wpDA`~+Osux+xyOAXYEOL+SGugNJrO?oG{e;;m^` z{y5$H0!mm^{fdV3$@X6E*@fnjRr?{~+l-?aF1GyBm|vMMB+!HZVlp6gb?X-QxT;$= zBiOcOhF=Ul&)d^$eI7~Hpk4!*B$~5&DH96wZVl58cqtswlzaer+>cs=33|A;!7qJ22 z$bjB{zsmqxxmDxGbK2cUH&^bZ7UL|(^a$SN6*Qmr3WfuJ0T$?ExUYFm^MTi=?vG3u zZjKg8lo0QR>N&^L44h`p0oRbGiyhp48ixN)Q^* z3uVyH>^oKTZ&!N= zt2Jyo`aSRt-tj;DDog87zillafr|9L-DV-KKk)th@!&;74~`qSJ$E&N~a{pYDSm;Fz#Z(an? zcWtVL)7L!e=DolbIs5@@Gj(5M_`G^%f$&=@Sr|QDe*za-_G{?iYbMSgGL+xp97&di z(Tl=NuOeLzo%+b(()h`#&QDp8)Sz$W=*YT@&nwkeJ+p}IBd37g9~i>|kkbA1B$ZE@ zfo`?$-~a0J<9Glyd4No~AXab)at)h_LhMo$-zzcy=J#1V_GAL2eZT!JoyTwjxV?zNNQGEnm!%Dnh z0Er^vh-OmC>MeF%o#rz=p=On@ivh(S^_?W{+2}XgV;LYQ4YXLr{Tdg4KaIlovU2)mdkCd7(AqVKqmVvh z+IfzfB}3YPKmWGUT=Ss=u7Q>qOwFI94M76Gw*%e8#o|_$vlA58Z}tKU5dWo2Q$7dB*^uVnDAgEzGI9}B3v9pQ}*VqkQHA(rAuR`h1li9>30h5~o_=!o7Eb z4Qg{N@?M8+>eo8XmJLC&LG@8GR<_4*6ISu1c0uFX9QrE44Udk#cTIV8I|=aweTi$U zu0T(mM^|0YmW$|$$~CJvcMR6oz4d2Pw^y)rO*&-P&lD)-WN|~+ zT?wE1smGe=mY1^Wv#UEOo5Pi7TubZ1$fzOsIPiNMDhq|KE1D+^r3s1xmZemgI-7+W zaCg?94-B+=p0ac{F6vT3R9`}t;?rLz*;l}E&Zy45xA{ak|JpcYfcLGVjLPV8=VN3O5=ZWcr9l^am!VPR@iWSJOlKmCk^8; zF~EA6rFe(=z7}kiLx`aTGjsonBl6%c=-4Hh;4Kw@)=T&4>J zkL&|U+=GW--Hp{sCIfPQ{#-A5zYUpnR4uc)T>qZiM0V7G3tu9q;4lwM-+JEL2}wY_ z^9h`f#hxTp%4t@q4+vFWVSN-BtW)a7w_hDJX;Uvz=R;P-t5^=cZ8WfGi008AS+W!W@S1~uNLbsoGbFrQSoCOOx#%B zIQ_Qco{5h9bSp#Is|VW?uJ_Uu;R=(PI#@qdWgy__&wY#`8}T#SlB}Fpv57URVy!&* z$B$gtUn=`qG0ska2_Gx77 z6@to3v^`zeO->x9_Fee0SDR_M2iE*Lcba2(s6=aAt&cUTIyQORvswL-8d($t#Kc4X zEPr(D*XIvQLV?DKO@j`%zL6ChsXS^{`5bM0a-W2UU5Cx=J`%xhLt8#!=1ERn2br~O zF1xMMFGJAiQr^T4*E5;+YJ$kmzftd;P?bT@*4?z*mkBO(O5tKRV{)V2B}}l90~NF@1RPg_DqUN7sqc6xbGeI>JLL^>8R62fyH{5iGjb}zHy%48;#dMTl%qKwiqMpKSKq&j`tk?DRn*wm)z_h z;HM?sGThoTZc$66SP;z|Ck0F6G@#e8V&@}tjbdfmVZ|pS)Z|R9%h#+=0OK?F5;CVl z_1BV=bn}6Y-U9<<7AY`_Wu59 zQ-4uZALRDT+thWg+F+-`Xpk<33+UlLErVsQ!UfScaTS5sU+U)}>xWL6uKuoSJja@m zw~kk#I~hvcl^ey69|8&H-J{*6VOn`y6wL3slP849PJ4DF`JS$a<{z6d?LLp=DX_HV z+d00wg0p>1F|+UWX+OSj)!Pm&X?E|!<&*vZFg-VW_5qUp0kUpDsFVh~KyRxQ*se#L zL-xaC&y4&X$%YD{J~icY7ol&y&)?zK7q;4aF(`46&|Tq2p&&~HXW^*#IA-1%Ew29j zCP0q=SoTYYvJHbLY%`A7qSkbNJSkDTfdi5*Z-Y~~6s$F3sZvO<_a^;JA9H<1w63gS zW~$73;{DL7aQjgq4$Jzry$5QQp=S7RR@GN9Q~&WVB(n~Cs}0|17$pR*_IqvJEF7)8 zrj@QW;{vSO>)*V(Je`vxo4W2Yh)|E6RZyNehV|Rb)OoE{!u(0t$R-P+b2iqu6UPK) z_ZcH*R{7Me&E%er!(Dw`{LSYDw+7(FS%=|Loi-&g&Ku40LR(5q@uNs2Y3vij%LcIb zQ7Z~10n8_Sa~k?w(5z#GWbDq>^REOTCbtOf-?iMYe^|l_x?9ovL9+CRlMESr;mK;q`T$Ze@)Zn7jU385WyQ?3lxmS zkEZ|tjL~pSH-r*Me`XYV&o`%=d&ZYTJ9vA}TN^eTX#akqf^~XsA>ZJPe`>`JF?D%& z*NRu)Rw=e$Tq&s;oYA()-E|A5J|uvUMY~S;|EFbS5Ec^n z8OB0kGoeKcaxh@;RojnqZY>m07=R_cLFAIYW^_Jwnr0eBuNucyP;1la+w<7+H0Kzs z_uxoKZPotoB$MvtFIc=qXXZ^UU44;_PIhCVP8^j)=BBOsTL*%0e13A{nY7tD7>kW7)P6VC;$5^V@H(lg+-I&jgT!a$y+~U$zN-EZpuM}`9;v+RPe^)t$#{$oER)D3~3YhBjLI>eH9~}em;#keb6AT`Q*Re z&w#(k<^0tO7g)PX-&_XGF8|isaj@2$@h z173-4PS&nNohco>P%;9zwKlg7=YBjGYi-OdmJ!lSk?Y!5DbxxzWyzwKcZp({kWilht0( zmN>;Vn8;T5TaGGVEknuEP(ica`oZN4M?3b(LB#cH|MgM3cXEcRe~ZNBx7CFzSFd(% zxmJwEpY_`k{)DKO5%}=k@G?$m9la|jX)oR&6s9S&YUbpByPsXig;2>ctb2DcBQ~Yq z%?E$y{Y=#LSU%~G zOZSS6p@N*knZ2w^LDa}9F0+P2WUMSn3HBdm383aOf7J-m{d+O1(tmBkD)|MExSeHT zLB2dc(Pwp(TKs#+-+bEIJgT8XNX!wnEwt+SR9$MewQz=_C5e@PwC3`J%NBd z7<{Lz1M6yM1CB;yrq)Xij7LQ*HbIP_B!0PP>C1DqNYfQ}@Kn~_A0+E>Iv(+6hmismPEdTN-zmB+E-*-7)eXR$3s@8b) z^JF=qP@jLd@!L^hN!?O9^7`1n9=Na8y)-R%^PUiqbEjRmh6QW)yFESLm{9XwQ#y~r z4%abh@eBGsV~t?4SM)W9q(q%8$2V?h)?`)o;_UhyHsqDdtZ1((rfbeFxCWsO$MI&1 zZ~V}Avi)UQxp4ep<XyLT){@{Y#BcnWI0OZybQogY~z0N=m(X^Z@`8JeSm z=nG5t7>lrrh5cuHJB7M}S2mF?+76l*L8+JgUEb!s>#F56-XxpV&h@jcl823t=ZGc? zkyOctZMsm-^+oE5BB-s`NcPpl_t~w=r}7F|vsZdA!L0j�&%a8J)Q9W#wkPY|h%f zsL@i#{+@1b1F7DZp_1u+wYM*90pfvD+BYk0p@maKB;g(lN|)Ur zwI+jS?gGD@y`Ey|{d>_Lo%+WehWdPi+x|yv{Bena=5GYazkut{h5v%DR{-SyN7;c3 z|9nRM`~L&S{%F=er~)PXP)+_LN&bQNe=x^?421vvrT)j=27H4mbj=46{$rP~SAYnh zIsq6h-MDgWLfG5%oHA*qLdAVJE%xOQizY+o!g1ySRaM=gIlywBQA=_+_!HILztMfo zbq1n=qV(3RmE6)A$yLcw&Xp|RPSpBBI&BTYI_V9gtAm*)z0XvMM|11-Y!~XEW&t0h z-l*(kxy3MWwpNnV^dp6$40hukZO-!^-dSQ1y{HV6wA{T2INX^=XnO80w&gcCcY6mq zQ$jx4|7(E^`u!OUvWP6`j|1!3s%`FcqGMbgbX$c-0v5t%dv84xcR)PKJ9f=!?dMsO zzSHJh>5OZk6WHZlMt1aG=3S@%Uvt+U4`sT?r>(TuSR%KOTQVXolW1L9CW{Fnb_o$$ za#@v_Tx$)BZ8~VixEFcXopP7U!P;$DAqpe3xs65l#S^_@kb@(5djoU^q0)}{K%i`p*d65$>KJ%#X>$ zes{{_N=V*W=VX~^;%y0i5$xI50{J-8GIq(VRtrg*2w5qiL$7OC9LY5Fp1UT(M- z8JmG<;xm}ZBV1mN>N9ms8q+x|&};#z&!C6Mo>DyEILpy-ek#@A-rbLM%$UbYLeBV| zVTW=uGI!o;wElH?J1O8z;zFwYX{zrmSwvt(jb8r9!*~I^o2f3Le$PH3(uqo>#WWp2 zqhTduD#$#xyu&|7KTff-&|WtM&EWD+tcdF@sj&SDfe+Wnc<9m5=ah7c^%}KU@#SeP zss5&l_Z*)4AO5-PeD6!$LA$V3dKlO8jOeKQLGdO3w~ZM^bEQYRW`}a|52?EwCWo$C z%<)lIt!7kS^(TA8a@G0!y%H>pV@?G-W}8s*GD4mdoiPwd29z&i^Q+{ZJ>M|noLj$M z(ceh|i-w*iY8icONP5IyIqXqW6#=X&)U&asB_Q*QyU0-e`4cu6UP%Go9X4|9P;x50 z?1}?=Z5DzM$3BnR!1dk`Z4ICKF~GZ$We)E5FSWup38?m_XivFEmbOh~H$GrIl2PP1 z&w{=6F|i;d={E)KGr<=Ix7(BC7yS z1`E=^R=IlD1V1=La2uv`mpkO?Joxz_2FIRIjp`L^oASLX6$kM;7Bt--QBWDUPF3=NE6`SNNHTy zqV1!mGVj<(Ij*Y!#|=Xn-HRF>^I3bNmQ@pcPf|!8Z3xqgP$sphvk%}?jw`Lz)wF}8 zO((97y`rn!>ddm4qIM{qisxB$KgB%u(jg9#8}@u7pCc-w6&}sxa`j{WY>!V3?AEm!eVmE;I4Z#Q)RA9~q;wW@3?fP^nZ=6ZdSOE6vxcFx734aBDoUFnZJ}=zMcFBb#6;Cf7_+G{-eaJEca8{%8DbT>{r&O%-4jES|>0 z=d&jAI0Y|f^Er!Ry56zNCYZuLdRRNJ!b9qxk<#dm1H562y`n}zZA8G%(>+M^02vSc zq*fe3I=c#dWf|cScrEj08gsor`L+w*?rvr0;n#s>^4~#OxDNdE@*aoBRT7frPAd=Y z=<@FNeGo8K>wCOxMbV(mqbesc$q{}D1l%Izj5TzXXGoTGKkdpCQU1n$B2QtXaa&9t z?Bx3iZAyd@Gv6eQ8uK_cif)rkf-~!Q;-^UZv)Eo$vBTVz%ImC*thXtLQhKsOtfW)2 zGbOWAPG?CLJ|kST-i%c!J-H!z-@IbVsmC)XqhC6@2u=b(-={LwsAO(^+D9gW$Y;B@ zlMBuwrZ}pm`l9~@*)N1B_fSvPCl0^l>+?+=$TY62A7tzcfL}PAS~ALvJ+vn_kUB2# zy4G$f|KslP?fESsh61fW(*p*I1}aEbFg+iK@xE!-D-9mn_lx!C^?>m%6){@P{I5~R ziEvbUCs5~ZE|n_aqB1-&H&53P2R7ub;G80qQI*6iE1W9cAK+oJ7gy9k?_ggKQ$?(cH&+ptWU)az;K~;HE zk?i~YMZmbBp?kbbJ_<>?En|2YpAiYe*v*Z2a(-Ap@#YKU`HTZ}J+XjmZHrgT z;W$vEMtPW?bVXqTd2M|=y7M*-o_)+ScN&d3r4u@@Z@Y|?e1NIh`0|P|-%#jS2^|`y zdidD{r=58vB4UnDyt6~cyRN6qwZON^4sP&6Fk2-M3tu#Jz(=9%CkJ-{z4j@}vHcT} z19_Aq4QKZ$QI3rx^(T4^-qNQ%N#;!Z9=*Y^KVv=i41Yp~fbLKf_Ycbhs%CT_@HEfZ zaa+021BgRZ4W3##LOEiF!Ll{pPq^-)Q?`_qCd*zUc+Vfn2PsNv8Cx z^!=J2E{PvDUOO_!$k2*XGHVjTuwjTRjmJ3tw$p;DWom>H2KDQm7iz-s3dRlNX^Pq( z#$t~POqvaiC2IX3g@#euD5`gmm-{;&_T&A0JpMC<~8zMIn#^Pj~ANTb@T92GZ=@ zV$TPh;C;37e)oyVDiO?`(Pzb9L;NCglcSUjJhz4Cp~rP=@8+eYq;P{>Iv5OAUUpR* z%|%a91QTxZJ(`~TK>-XWi!h)$`y{{vle5na7)~mFSd^VT5GVF^$o%&sAqk)bRXls# zTUH2K{}4$1yK1DD9Ff3{X*$a(w0?IBSOreQWP=f~82Ts71e2gv!J6m=&Jb7#RRVn% zE`TU{fg`>(c1xTyc1wI~EJu86?0>S9^*LH{A@1A$hFut}AS@VYO7lFGhQSD<5m;|4 zm$+LWrGvTi5|RyrvETuHP@lmIx)xhS3|oIxb@(52!=OrIQ1ku}V#}k7ZppKS*z#;4 zj{JXR(*Fx3{@SuI)Rq4e2mQ5f|00zCCiJZno7=+WC`N&X1-WRvjqzrNMPHn|@jD9l B%O3y$ literal 0 HcmV?d00001 diff --git a/assets/images/fp/network.png b/assets/images/fp/network.png new file mode 100644 index 0000000000000000000000000000000000000000..880efde391e5f27c2ad8adc82dc31a301f50fbea GIT binary patch literal 58395 zcmb@u1yq#X*C>t(NQg>@lyuC{1I$ng(j`4ZNDfGM3kXV=)X*SZLzko?(%lV;APv%~ z{vXu$y}$3S@5Z|8KWn+>Va|E>*=L`9c5g$Us>l-HQQ=`=U=Ya5JyFNNxJ8eFanlFq zCh&`-tA94|h3g=PaK^yEC%*o710yAk0s{j(#ZnXQ0#{aoncCZO8JpRgAh|qj9e~*w z7@`s$4#uX|NEdn&q=luO7{gxEdj@(-Gcg7oh%%3|gB0?)rJR=&Qo~C{)6~n_6l%sG zAxJ#204oM9ef48P&RfamLhkDvbUhXGj5$;=$4{zT^Q zV!&Tw49{I$9AMns?(Xhf?)+T#P8Qs}P$-m}hmV_&4-CuzJA2x>7<+*2oEiUt@C4~> z>SXEQVrg$je+|*t#NO3Ki~&IP&mL?Y{sn92{FhDu#kf6;9k_Y9c&_*Kd!m`?zw;bi zoos$DZf44jv_aY;?OdFJxxD|*b$D*?V(OH;_+^U65i7*T)9tfq;1hHF*VL{CqHeD40h8#>4Yxs1b+QC*nz7A)LcPYy41mZdY|e)S_!w*oF@=Dk zf&%7XsJXd0*xXpygqK%{-x$g-bj{AcIRqwW=?t8m=idvWfpq-)WMfJHn<-$%rq|3a z#$bAV%1ASYzdu|4H}v?wTKVt$?$40`(ErWh|5@GH-rU9A*a`XA0-)XhnY+0ESJ*on zyZ!HRHxV>9Hx)L9f(49u_`$|d0YR{_fDkX3*PNfv6awWD6o#1pv-khR{aI$Zn&>y<{u{G{-62p_t<~P zSKugr{{#r_>&Ji91@One3I}Ni5XuQqCps$+0A04gD*xoMrpN5|kJ~PKiWy6xL;Jf+ z7AGx8^m7M)v^dq?|6HB%?=+$B%FRiTP|Vq&Y^Oy)7!NpWnUi0n^F@=AEQ zNyJHyiIn6p+tQq|omoD$>u-8EMgSJ@{ip)t&%kZvil8p?#r*oza~{&ZoW!)F z*u~@q(tl>_(vyT5`dG2RkedcSJ~uc$RE?E@27k}DNPGythWFCQ_HMQBcyDx`dTD%E z!##e6Jks9_VBky!xe)YEw;H8-@(XEkb}WLL64M^G-TaFW8Ug}`)4pF$5ib|?)Xr-# zV0T0EZpr?ED%>1U`;G}u)sjHPrfelTpDf$KgG`iBD=j%u?SgH)Zz%I6~wfaS(<6fi!H|=Jlhf zr@zUo8h*S&LkOx$e{i=W6{h|968jHB9I00*OiOA11o7MFXIXSaoy7$m;t`1U3JuKi zyf17T+5K}A0eJy2p;+14-^5EoDR#Z%_mYj&qG~Pgj;@Uy|CzBKYy{@Q1!wY>O|KXV z6fC%!J{2@Q%QfM~3Xkur!%B5C0dHFM{#~{0qIWJgXe`K5R)?6EsgKN31!|w-Jd|G9 z6(GI1aJIqHC)s7bxqbotyLxSyD(2Qijdco&F3A59H|xbP=OL^g>`2qFfg{sEJqHCpsF=d~4PNu@K9Y3ux|0e)AOy^skw z=6Sgwf|iQH`aMVwFA3>b=A4AWL}M!8$`oXdXqNQQPk*R-A6Gs%-6wdyITopV zyJDKa^e+#fj6yqz^!E4`NYI?ocoX=j@yaViT(#og;WtKv-^jJ27UV}Bw_WtOIkz#a zjwqfi$Kw3i0}T=AW|Qxe+gMxOJ0uXt-LMYk_`lfN;i8_horEv1n~9&s16Lvy4^`yu ziseW0@0%Y#W)HK!l@y}cYLwc~k3y~v5ruyGk9Enk=L3pe#wsH+H0?Iws!NlP|4>se zfH?-M`F+T@&9|mBO{rF&5tSQ{zPvHI@$V^wx}Y5bHH5NX9pZ(Wih0z@v!bj$z<=Zo zj1^9V=)as^3Fs=ZGH^!I(S5U@4V~Z@#{ZZ69rGU*hCUqKs%J=7m^ZqrQD`x3QMCWV zaR7%ZGU%Zl%o9FHLCM7sXHFG~RM8W44+{`XL` zy-1^lQ?@0!ifr|{zd{@*K$=(N{k(*L^=HkBxd7Lm*gD61+PD84%x&2UrYg<5abw|W z7hmZ5tKC#9R4DD<*{I-JQ2eIM%UjHF5=jI{aQxMY0bW1MNyL+}jVcxXhwPs*@W?ur zV;wwfc0Dnzg{Z9=+jJ2#W19bn!`gfOgJAa)Wy%JUU4NqnStGFIwVrku))2**Y0u2{qTX%dU9nmvM2PUV)Ns4~b88y|;UF4b zvk3xgYaQ9W+$7OBt^`x!?hVS6)D(lop?{ZY>st=Y}JwrKD8YlYA`Y*700j0 zQ0bBBF7}r(Hdv|;`<_$_Q1XhN(sP0uTwi!uS|W0Zn`r-XmP>NwJ{Gpc=k=ZV$nDME z_Idx9nVEA^n%Tb^At3K7s9a9=4u2R-KY(LMqWeurLc{Hrd`B}I6XW;6n15MBQ39b) zq%r^^9HXL5&FMWGUk-bk8~*Pqf32GTVeb4P=D+67|7zf+(T#shp8xvBe=|T22c~?m zVmWByr8CAfd$$@{>I7l(Eb7_poDg6177U=2 zgArjkv)j)EA-dIPm4gj7($xnRh%>$-N!sx4%o`YU`F>`LkchSKjX~7fC|`82zfIR? zD*Y*7?`%u26C8rV;ZiG0fNI^o|AV>uU0mVBzIV~mf&$BG_s+`gp%PMjH$sd#Gha1| zgNDHM_|Z0Lys|9-S#4F~{h4&TFSSwS*0e1v)2*N1_@zr(b@Lm`gVTRhPfK4&BL_Z9 zk0~jX7CQCvNbPT{rjUB$z61k%B*t$v_~=2_+JEepR~`TXC6(KzzpV}~QtzRop-u$^ zQw8#X6yQ2t(4Sg-s$nTetSCPUqytrv?u5kya*k8bTB?ibga||L)dY`> zO6cSbn}ju`AH?XMvoO} z1M7LP0JSAdy|aL5WR@UbEVgfXV5beFKUggMQ9#qGeWt?}fYTqTz6&6#O$Z&iz5N(ySKHricV zufLTm=Reh#^jwi_{pndQb=^{$)krAJy7zWU_Fo}EmJ z`yw7PlYl6O4*{x`yR7XCByrwVzUxM&mZ3nOxJ7K`&r#0Q_DrW`-&xDAN_lcLkkt`< z6)$=2lS5xMHU3BX=OA=+kKCO%J2NI>~GoK0~_~Ladn%zj69P5))49YBN{f>)5 z510x*rv%@y;q*f_2>LwCeIu3B{HZruI!dJA4V9HO?)gHg*qG!)*gLntkx;Cqq@b?H zvmI*dkwyd&{bdr$`c?gaMgF!wJd=G2=I72aP3~QA?^#MyS#+l%H7M z7#K(d(X^hnXseg2zdLU>i)kt{qG?EfF=ZPmHizX{!S7xk8S>-)Z6|`SGw+wJN;Ig* zwlFLu6;Br`Hp8_ZZW`3 zi+Ss3wtL>>wejgg?d=f2CX5kbPr;wu z>^SqC)oNlO_*#iNcE}DDXCMjN6(K9M;qDMog$#K4+MY5sJdW;>+>E4osUIXh4C@Iz zA5k2fl!Z_}HEej2YnYP8*DZ;wzUYfxw*S<+jzvewar zx(OY#&fQd2VP0{=@u&BGY2i@Yi{XY~)h=cUkRHrbu(etp>K$*_41h_0zLc5b$vDO? z@;c2EjdgvF5p8HliTUHTc&k@m+ur~*V)5mvPdWj?2G>(|p!%?!qPmHVH1 zz8%>jJaEXS*>g>0PR?cDAF0LMW+fQCcE~LFp~XI@3E8FwHMy2V{;BHYuj;0?FyrtG z?u?EL0H$@|#Y0KY)J2!v^3Xi*w!u>B544LnT~6M}uH3!Dx}#p{)3zT~X5U8NYW^gz zhQfy3Ig$&Htd?veruOzP*WhybCt4>)YOFYUnsC*{@lu>)%QrUzu-x+Z6hOSL-0CxG zj|H|+8lfX`Vc@xh`ROuIj`<^-1D-eFB;67h_dyQb+X~xcof>10rOR>viBrc89|sSB*J71b z*;JRtv()M$o-+N6pG$Z%RXg%#kTOU4oBuO!ee}7t37s}wT{1v%sx6Ix#WX02MKst- z4XnQODS?JljerQpw0W17m1DUD(=XP!0ObNqJHrY#9gRlX5^A;;0lZ#Qt!nCEoEO_njienA0G!uC-9SCs6{cC~?Q|L7L|I1<21@)ea-sTo@`A$6%qEEq%}LsXX^R&l-^^iz!Tx!prJ8&+vVfEmtV0Y2oOA)~Z&voDegfIzA}mVJvaE_pT&0WYT!;Uc#QE+ES5 z4?d=e15TYDp-bi|v!5<$B^aqOpXb!cn5n0O2pf4;3(daK%Pt5N(tTUr`|f&5m2 zpK`a|!jZTVs<}Y2Jtq8ecU1x5iQVbqQ^bNpHca-b9)isk2t;QF#k(&SITCeY-{)U# zw~&CG#9F^r$v+R!a3G*klwz^a4x1)+gtlxpQA-l(aV76*>o7wDsmceo_OED6HZ(uj zQcVd;jb22eaim}69A-K-)$#Lwm$I9>08iCLSho^J%ZWEAZ^fWRXlqh?w*W`5- zHn%9jn5522{+Oq>a3UX25hLgne3XgNq*!!V3mGUzPX8mVFHwh%zDrMU=JB?HSb^oh zjCLH`4T33U4Y|FHtZ^UmjCs7ao3~${cO*QhdtifA-?}sCH1dVmFeP zzN`(J8#I3?o6lw#8{+DEGW0xYX7tDtl4EWLub|g`u+nWyTab}tc;71Va3K|;%^!i9 zP^c($8m#&pt2~l{hw{_UF}N?gTER>B>*ZNzjAPM9ZZ16cjoe>3t{Lj0Mnl6OO#F3` zs2i)^s z@=HdVePSku9De(PQ=__1PmXz$LjNmeM`AgdQp(xJT;t7eZf#YOa#e~mxfzn>`UNS{xZmlI5b-qN z{-%WOW2I63h)C`1`^scZz=;8DgRUh`K{}7^4#@#M{LvEBky~pD)B4Ac{)ra`0WS z<4n4q9+`s=cl?54l%c-q>1^t+Kxt#2%h#LIg^S-q{R!JOw(C-o^>EMUmx+4g-Uk}o zpV}f=Qc}cc$}GroCfaGjYP-lroUfJQ3o5Ku#7!N49@>eR-MF&ypGw7soYvO)qv>o9 z0MftrrCHy+;03Owp;fAk>u_1&CFOBCoXc2LAhRw&+Tf7-*@FNlhd4akn+G?RVY8t>3IGB(P z5EpEa9WTBkO_%;OV}vr1(LjCnV`7ndQq2#Zp+ytP_DQTQMULQr!^uDeerY#&1?UHS z<+Ca$CD&KwHO&ZwecDQUcgX>uLBH{C>&DNOgiCjamz24gJg#`jVn*V=nQv5TNaXTE z>j{&j3|jfV5?CzM>ZuRG-BnqOllcAogJR4Et$>hm6{i3L!?6_vDRjf2Y965DC9SpH zr(@=V&$JbamJ*py_LuVNJzKum3;dKTD+X-(JBv8Syb8kYxm6QUTjUF`}|k_&R)+$fK{UR3W>H{v@4<(l(qbJJ4auq;ApekhiOC2i3=HC9vfqHL2FQH zics*Oe20|Pt}a2Qrp>Q1t&Lp)SPKmS(~h)V`gF_orgkdwHgh7+rOy0YRb}5w0>JGO z+4CGK3GO5t?j@lm++JE#y_lq5Ep!YD3PAp<@-nme$e-2%GkLD%(AN098NJ_x;e*<2LeA9AjutY=Vq8tj(N zlHx2x3O%5$rPBn=0iUG&rn+5YM!s8qZ4z}TAX2_W!9+X&+o!kCXlq>4=Ag&~A&=R_ zJ=L|{q${-j?zbuxyqWDD=fbv!WkOYU+Y8rT5zmFX#t?^DXtw;=qO#iE2co4>E{^4H zE=}bd>%JE#AVTA%px~Pd1WY~0Y+T32W6+OpwZ$q6eQh}#{%DudS3-vAqu$EslR9F+ z9Ny}cFszM`klH-!5Gz3Q-*=HqAIvrNC_f;Z_FpD{j1hE)s= zuqs)~MvT6HuHEa7UBs$vX?3gOfY@2DdCAFLrvj}RctiKH+MxZ663NIsU!-~AV3+VV z+b#%B4n?q?zxxuW;IvoE=#L;Dm|`06K2j%Ndmshy^mn~Z7evM6nyPvj{bPJ92KYE8 zy%V{@nu_-KP)VN_#svIHD~{lbS&|E$hQ|YD5kz1O^0iG}w@zV=KD{xBq6vuW;aGkA zdW0Yi@555!16qiof-tXvF4K#Eq97dMja@hv~v`u-$<2tr2BoK}bNwBs^XGeKJKNqw~eQW3>Uy(ay{lTAis3f+rc11?J01{ubxJA&rQn zWT-?=3Nq`i^-0%TCcf_B5BtTDg=kOlX?F(HdC^e@%`XZULB3)%AzDkGFE5>EAd6a2 z*$7oho|EtR88D1@@ldKZ#IINh8okn|TYYPiM88sXmRlOIeN`r}=*+ZB>up;}7SP*w zyICDIukwtTjj9`n$o-J+!rH2v&BGmeF^i||G;+Uz(T8>c-k;1=(CbdQpb&7(9LgL$ z&c3P~11lG=Eu!OX{_<$)$VH(PqvRb1gKjVbPnmgFdMC6dXbC0`f&;>)?s(AS$z*X4 z*6h5Pw3RxYxw&tivk?nlo@;?PZo_9X-pk?MEv#@3R@&hxN{d3={whBNm?HB9p-xj% z0CJa+pb_tUUQJCXPLCNbku%+!sf^jjU-dKHX4g@rBdHhBbs+sP*Et$oN0F5Gj{QP;(aPeY4btz&WLj_v19utu=dmbyqrk2RNwv9V!>J~JA z%_IU@vAk)wrfoog*HjfnN`&J$4&e%4^~V}R%wsglyq_!tk*g6b>#I_s5hIX>LfO97 z$y;*)zPxG2>``?Yn0>*B57g9DdT&_Uh(bF)Wqyp+71Ryl6K^v0T(!RIUJ2*pZ5f~D z-5~0n`?=PzHOPkE73=SM>(!=9!~5dVz`2u zU|H`SK z;lbX|^p)ifWp2$U6~&tt_y}Tg-pH^3=6fd2cS|D`_RNI_NGm!^HL-Nyw=3jnHVRD! zG|5b#4CwPCIBs|L0L0lt?}Vmh=uIw%)2)*+1-N!(J;&c&uD1iP71q?XerY)GfV9~% ze#Hk86*H~VJgs2@l~buO-PII-(JVPpCO8nVTLr6dq0PR|`gWVLSgN)%H z^yWFrU(yI=OjUd3JbbBpNj~8%6h6$X38RARG8!=aG_{j(^B;k7?PoOJYKjwcVu^d;m+|@-yWKPmPk)w0~L|QPNO@>C8oh1U$F_%Ih~ez z_t7Jv(r!5)WKb>roMB5d5>hGN16eIhcU0|;LkcH&J}yXrNYM0 zAyg5HeRy-Jp6|h0x9v<{bg4psG?qCuaJ=$wm}f zjS1+5fu>w+F;bAzK1HggH%3YlTjorW(?t!Fpmt_2-H(_s`+e@8fuEKPTZ~G-S)i0} zE!Xs~=|q?G3(9Yvb=Ai^u*%o!;O=m2z0u$*lG?SwhZFnn>5ac$n0L0&ujPb!SwMKU zVzHDR?^rvyJPS8mdu-p9&8fYj?$slxs&}0t2V8=XQvrARSB0POwy1#Q`s*vZa-kOq zoQpQiumBgV;+Ln98r9YptSVuZ}fRbB;Fncs7C%it@AAGU**cF5m9byQ(m_4{F%SD+}y!SNo8z2452 z1MVbt;5FB66}uP{#9UvZ-C$rk_876|xM_$d$H3s|Z=`RiUr=Bx~ z(IrgQwX&P9p&(0xt6k?y6mq1---doI^U%GT#Yc(qaIWdKkC*!+f{L2h;42=3WfY9{ zh_HZTBrRPqo2KptPLrp2(~ExfiDitHz+4qV?|{MNt4CWJ#7W4{2*;_~?XwmEWz=3s z-|kBz|67lq+C*mHk+B2L;VaVzE@4*_hDGA6KM(!5&hPztoY^bGdg^^DKnOao9Rs6x zZDrh%3wNMe7o8leI1bT;j0M_&#WxN3&Bgs}57a1=q*WSnRjhh=pgF$1I*B3rR7tBB z5dOnM_hWutX+xR-vXviSJvSM=J_<;268D0%ctyCY(L?NJO=CnrK7dMub;`cE&Q-r1 zJbw!MHTWEo_Waw>&#%Vf*!3*%1H$&NPpVgdowLiD6;X#6(D3$7_iVwS2OIP9PNJ+N zcc!r>*zm}-y5pYNKLF%h&kuwWYSWB%g?4wQsT1$#ouWg*9L0sb_H@VgnAVM(HNf!z z!2}G7O#OEz%3~UB*`0W#7Lq=zKfEW_p4`4IZ<-^XfKRUJ7xT@0085d!RB2bR0epz8 z9V-Il#rt9=_=>+WeHVYRc)7yU?i3Hzt?KVujfYQZVb}(gtkl{Ni;pA|-Go73Q2gWy+f+tqwZd?KFm{4m)a7!H88Y z0wQ}w_FW&Mo+&f@pl76Abh$n6HPdB>0eWcRO;Uzmao%Mv7=TQmO<9sPjey96T(8h+ zoclqeimT&gr(ohiZsiW3fvFbU@0Jo=jB5`jmSujWS;(!5Qe?|i_z|lCJz*+-rp$Ds z;k5C&{M_>w!y=8(O3Lg2MT@kel64iBS|3x0WYOvnWQ$CYOHPiNZ!LWxd3B=K6VeJ^ zQZwW}kKXdSIlsWn5R*cVn~xe(l-1nja>8>ZC@(>0J}ekp;qD{p#ZnY3W>a4MOo%W< z2x)wvx_32P%)t{buhQr1I6ztjQ?uOM)h)d>9g4M}o5_FA3;#m4dWB1pE3=@VA0qHD z_0b8yK3m~H*la$y0omr{Vepmq*%no&Gwv!BYf2b<>V6zcr}T`3!;gJV!KqGIt?#_ ztj{(D+C?qnF?5jRLY}rPQm|9uJdbYJqaS<+cdR1Q@xMXCvSkK}fot=sE$k`D&zSO8 z0n$;eB35IOz3mZ12b!gH^Gn=fxIZ^_Mw2IU;cz(^?5N!HwIpsLXS$%APq^Qeto-xB zC-l>~rcPGLW1_0Ng6&hK%Sxf~iqChpKDoJ#>DwiIb~Q=OHtIPoR;0)rHy&46(~c_Y z4?;4BJ0l?jT9ZTh33rIWbA^$#*i}9zo7O2r0C#h z#PmI=@|(-zh$^*?Oa9e{u5v3;#x40k$;l@+Zsm=HQqc!M@la5P;j8-y0#n$W50K2& zGc~aq`KUpD7?r^z_kO3j!8B&eed&8zaR#-2&4c%K+PXnUZb$*AocXEx3-Ih5^VnEw z^i}VuKy%+V*P3cv(*UdeW&)=5ag;#BFLuAT`eY(mP7W^{t(EicCBD(Hn+e(JgSeM! z`pIkk*k1eCwtX;SGH530--!8IYoxSUi$5ri)YsM;xf zb@H0R*S66v|6y%O!{M!BrcjWwD>Eebv!I!_X2h#4yO%evMp3ZAD@&VYs8}W0f*PWt zbuN9tInuj{xwXaMn?WiemTxU+@@}jeXDQdc2);4X)QEP2m72W^kWh}YQ18+dlvBb* z8Qf2VodE*&mf410NEoyv&3n6xVaTt0hchnUn}T(X@c4a!`ff#(5ECZ8O>&06C1*L& z!gklF**a4m1?v$cfLW)oV2^4&tw;2mhl_c1Zw5!OQHHxx+;)_vt}JpmVQLPWBjHw& z)PR&G;0xV#to^<+*xQ(#7N(Y&#FF4Ij#$k>HnXdYVPY!gB|fe0R7pY3yKzn+n;Ms& zx_lJy$tiz?SK5p(n;mPEE;zKrrZesn9kyp1cA^Uyta)A4hRp|+y1l7kgPU1Z#xXD` zsp&4^3+cAl0((dN^6;Kb@HZuMUK!G4$p&p@p^?vyF*0yw?Tp#Bwwl3iSI87 z!zv4_32@tP&TV%c0Hrx^P16N?=f^97eDu1EB{qgU>WHa#en=n5&>_i*-i=`)V%nW(*S2UuRX~kD|yc{&h8jOcy3fzzmPa zzlXo)8E=38+`x0HclWUa=N==qQ5fPxpy@rFPYF(pc$P$ea33KTNI z4f72gGFq(ZZ`Xm=i!FTOF`#ETqm6K7=fG`T%S5>Dsf@LK%o-5iVbstqs8!y&*>>~d z!}{6Ha>t`?+jM8N^SvrTv11F~i{XG+f>D9{fecswLEn5P2Hrw%FTF_Xjv)z}6@=K_J8@KUgwB;JhO5jR0MF&l>M7 z;wZ0_kds(yqLiw0{SmaVEQC;6c&IK7M1J8YE>693rz_^&GoU!mUdv(MIBS_hU4b2H z-w?kOW2AO2Eta#X=s6ZIi8!w&!BXVq2~Q*GX8)|=`|CnY+KSS1Y1-WBUg8k-X{5C_ z5&F&0&ICdAiuj(ZqzI(=4AkhDvqV|+>&VtX8Lx7c;AGP2836@R-T7Dr! zy|KxS;l>SpE*|P)UYIl|YDZk?MQY(xtOTZHDHx03BTc{f^g2W|2G*c;(}^m+tF#Ym ztIvpTZ{vaGO-Yr$7v?kT*lIhqfaS}vWx=^=Zc^o?Pa1zWAVG6DKQ#a8>e;KBIP>I0 zI`Zv4fp!r)BsuM9t`#z^_}rq*n)tJvCOf>u05KV;L#-f)XV-YSBdyw-9q= zd=&hmTCkhyBj>8JpgZ@vrj%sG2Nho47CC{wP0LU&tmXnrAgAreYb3N>!xcDxd3<+Z zWTt&9@g03ZFW}!~9^4ilIK)DS3RydI6SwuUJ$UF!9pLFtmpk^dn_URhASGW>h`F!H z5v*WIAN)b6PHmM+B=@domb=TV<-_~vlSTOfWFUuZgt|&nKJnN^PwV&A+ots`n`N>y z%&GHn`IKEsqd@d!@?=b9i0dnlCL>(4|1vN*uwE$Xlj%{-W{`7ow(icZ$&k7DD1Gnn z%AnIv0l<>2ba;wfiq#XAs5E+8Wycc7o6YBgUt+myV6LjLe?Otuf4&{?*hKlp8LOgf z{L}2ZljQ(z8CQ*M5eyW6vWO34HFy9i{iJ%3(qg^;(H9nIxli`ih?Nr=S>VE}YW5C} z<;flbE7$hu2RGtMOJ z)}%IqM2YkG?3GKlc<$AAHox0VwYw7R@6A#bZO_kcEo-ssUA`{pA9I0b#zf(eX$>OC z?ho*(PlTL`aj2BlmKdmx8LbYn=t`;F&^oS8Ud<8or`BS`nqM1HPD6RZ++)Yp8iN@F zjt@*Z8-ktj%Q<7Q41D_c!j*Oa`MTk=cxVL#qE(k5sDu0-F?~(1`i6UPX$f*aVpG@; zX1l5o!GK-+*>WeP8?-6vDWP>68&6~0PzCfN`8hW;P&@rVg!R_)gLusFG|3)=64}=- zxF1KUEQb@kF%8u!R(R35Du5rcpR0LMkzRZZmrDoq^R)@^sjKx2&__Z}kI1Atiqe~LEihTOAV*skfUCO6K`!A*WT()af+bs(xm%s7az z>>W~D&gUAOQr@ycF|d`NAYJ2RNd`D~EBe=GYV|GRIn4>4zR$`dP-2cL3U}PE!OZU3 zy_3^Lc4-75_F4HuPk|!UySEPUIS10eHu7|Rk6mR!1b7S(1JroJuwP-6)nKjAs!zlG z+sPYyR6?EO%+kZIB44rMSeC2u&^h}}UfRp2;s>eP{yR*#-)EG)$ z7T*VjzqrmniE^~oYgK9vS~_opd~q#M_dFReAV;r~s!e^cDK6%+<44Sr&IH^$T=DQd zuSB*OspW*l6s14Oa^k?$v?7yk%f4AX|1l2{-E){5)r-VKE||LlQUBgX$~=C2Onhou znXa`5b6xh+-*$71Xj-a)a!?@|T%k$yVphW@%yLu>(4yRr*C`QQb}1!xNs$U$n#lxx z?75Q?t$B^cQDK1wOB&J~?_MAD7(B-^BugTl%4LFQ$NKkBB_Y>fLwzCz2J~P4CuFK(SiJlYK2@Wo($H5~?OV73Ym9 zkLteX`6tTL5SWvm_Q&-8G73|nq4)6mfFksR=GHfm$7?G2s5=sxwMt)t=Y3^%YDTZq zztijM=^Vz#hCB=PAAVQvmZlMZka6136fx+h)gS?R>SH#{-8r9E*=4d!Fy$7n zDNN#EQsj~wECa4JB0{Yr!MG=GoHA)X&`V}gu>fyBf3zbZs&hiy!p5c&nd{}=W)s;Jd zAEmxT1TEe%oaiby;cg;B`9c+Pozn>eO9&HKcB-}5z~MzJP_>XS)N|5fiw#M4y+PH2(Bo*X6P zic4Y}1+#@pg5y^1-3D^-H#wc4Je5ADwru^K5k;;MwB$G8dZc)*S;%}-KFK{oDC3;$ z9kRfuYeqWG%xdE4&AIlR=8B-8ZYb;N)dfML?h{>|EM-?ZftEnhJxGQ(G)2;B47` zxI{U%x~PSa)9ETrb-dR|E?YEr;rGy(AvKMj9N-)*p&hbN;HUBH-{LM!j-OH^0aeW; zp%f@cNS8(YLkK<@t4++dlk2Psmz5@b_C1_Qsm82lfBb9{K z%7IbBc8lY{rrd*LbwMJ@6O56~4Wk3wF0b0)oA99+cCX%2fzDby6 zr55riO4dv)T|`=0QM=zu2{W98;{nP-(}&Qz>LnxwF3d&_a_Y>|iqeAgx2ik`Dkp*7 znx>0_uo5rsWaMt75sik3LWoPwEFb@SN%S~(-DCNRR;63T-f@ct+9F^B`KNVCS)*qd zq-!ZpdE^G)ti*3o=)V#m&>i6y{_)we^5^VCQ%z8)rON|*F8H`QbZL&Pq(9k);Q?>+ zH+Zp3^~r7{SFEe!y=ZPunju4#`)RCd$5oJO79xD?Necm%Ky7w|ugT**7Eyp-k~0~c z2qb#~Jgm~kXNv$+pxP0YCaz$ezwG4IgBxf=3>5VO1CQh6YXZ8N8}axEcZc?nylosFt|T z+*5T%gJUhrO1=&lB{Byv4@`6cCJGCX-Zhd~IbPGo-4wB?%$(vEtbD||Hyfjw>8+uX zlINHzGwhIpGwG!T1M6|D<@aGLu6k%KI&dubwPhz6lGGh5$y(HvL|}OAXRT^UdSm&e zP-wlBoQIv;vzR`~pnsM!k|dCoqOeb=2~+ot9P zVsw)o@&WGTXNpmfZFnA1?ew#aPgh#64V)|MikwbQ(Ja~V=2D5=>V4I%lHyFyxJ7A| zq};pETbG{%Fnz2TqkBp+WQFoaFDv4-sw&=%4s&^s6mA*seY$DrS8TgYO>V4AO@OJW ztTch>3s9_+KGj;_+Et?k5j-RSs?4m`(~d&WT0|fQRiIcIV5dy{+kGAyMa=EHRUbeN zMm{|m%rsg+T;CWnAfL#t-$X4oDuD48Dw*}J#iA;H!q3bda|;!>S-TD-W&1djdTSWn zOGhIR88I9taByx(>tu)7DUi`ERX6(OrTj())Ih$f+PAE~HL4KQLn*9*I{LEOr9I`) zntYF#7rwbclTu_$DQ1zJmFl*7R-D~xz$4i35;gjI<>RjM8g@oCmp)xmo?d|TL!!`2 znQxo3Ea)FVw{kSETwd`bj5myb>J zmsmN8NjZ1~$3e0Dz*0{C>f*MvDm&Adquu#TdOknqCt<{QD}N)WjSTOZ{3vFFnD544 zNP}Zr^f)ZG+=mz(WtZ-hW?$Qd9n6|k_0QCV+HK;$k!ZybD3ZC5#>@gdqF6$KACDB! z2Jm}W^!!aTSpe3Dd?h6?(LmKP*W7jUOx>eAqhkWbn4`PZ3?%LZ{baniwNywCqU|59 z!C^YH38V?LmS6e++jjE~_5G#Sh}U{XmWb(5u{JcFpkHgI^PT9FTn`z|soF?a0;N!1 zmO`-|pRt*U*277xR4X#lB-gGM{Q|6T6F1+y7W@1rzx@HkO;c(tqFLI*;-M6dUr|*N>kZZExo{Ryq$ku zY8sK^Pq$O${=(KA!jD-F8}7cGtjEXha#*TrX}569t8_k?=#o*c3eBkIc=uexW$GGv zYprUs*DEJ|Ur2%YW4)}IkJ~w0I)AbxT^;^1$7(M_L69tWgKBneABnb5f2`ynO&&zU zpHA1{V{RKJP^&HwJpV(m4qtpsx1JmBuCJJI*CKdo-uT9{q+4QTPX}t3eJ{z2xlLF3 z5d{JWvb~(ItxEl-|Ite8I-ShlV8ypme-{WtWI6N%z zIO=3l9`&DbmY< z8f&ILZANmCryxjmhQ{)t_p<3T38+>tR`?ZriwituH4Cfgq`m{NJ1dOJ>Rcn@iQIl| zsfr%19hKaz$zjng@DR34aU1YA-_Rq9n~}4vD00^4sjYa&^vQRT;5CEe-ms0&53Y5JYSp#aH zaG>#+%^ly(b;Ygs6?fL#6~3iO5wX{;C1ShEF<9oSIs`z9vV15>dRH#9)fR1+lrt*e z(It>O9NbL6+d-)G8xf2-q@(=w zv^XtwmxvduG;tHdL`0@GGpSqs>A+{JEd2g{{M5$$c}6R(vI~X5?0u+MSPUt^&?|SM zxyS3GQpL+fg#(zgvo*Km%EJOyNz_w&D46|# z+WHE{2xZXs)GjX3?rF`6j3?tY$11=UOba&dnpEbxKaZN?v)dfde~${1xK;<>zQ@SH zE-e6YJP2Q*yANnbgE#q39tp#MqZ9Ac@OocL!X2olayG-4ByOuZGR+$f#zTAsBAP%> z7{Jr*O{d^v+8pm3&AW-u40`k)Gf%d$Y9Gi2jvG`3Y zG!$*w6ht5aS7j}s{_A`d`f4U4<`}5!+y3T>NWs4GN@9n2Y=xp<>JAx($l%A=idLo+z(vW7 z*Q|O|9)D9^$y)*Q)QYQlCS^|A(wtKqX!D~<8?RJLiI|;%th1N?I-H+|e;STy@ zroL*^<4{BoT~_t&zIRf$*BZqI>K^SjX0()Qu)|S5(I%5Xy%x|I&h>Fs;b+&cH&wU9OzTR`+7G2)(chfB=M0!A%X7ZAzv0mo9HbZR1`0NJy0bwD#6D(Ibn43ccT~k%nZkN7>B9pv>3od z*9~=V#U>^I?}cd66{y#_p7RpS!_RnL{!1&+z@Rn42RI*KCI*IHUd7XcHNV!*vY-2O z%(k}Eyng{yXrWNKw*qy_(6b3mO#%lrf4j~;xXCLUkfPfjZ{NWo1NzA@Fs5;Pd$qBw zJt;+Q1z`Q|PyF4N|GTa4dX?W8{+|2y2^0T!2jy>ozx(NazxMa(FJ9MJ{O-B^-Li%W zgx&yT1AzR{Z><04QDE#h(Cf4M{q*0U@tZ8yKsQK;#}osKm@DCbI^F@8=p8;LIF7sx z?u#Xg`%4sQ(`g#w4)li1J~&5Rxpr^ zabQ35v8wuxWS=F~Qff&C%A`NF$aIqbi%c!9N#$#V1XbF!&9AVgXQd?gj@-Y_g4`*0 z6#E$dB~y{P*$d!mGr@Cw22|u~ z15H&sg$c3dSUxri-Fttj?k~j(2WoJ5lWBl$e#IFPopDzF z8fKugEKN^YW#A?uobfp8od;uHO7N)MW%qH6c^A zvJpPb2HSO6YJl20SbgjriBeVptQh`Ne09y*2IlOQ%xB?5F1A1wCPua@UY1to)_0of zICKCZg3RV3hfX)kx|L5U($FodAZ1Y(mTUjld_U=aC}*W$YQ34rqhvW4>?i^5d#bgm z#Kqm@IWkx?pXf<;{u+RF`MYS>R8VE7tR+}UQh-LNTv0?CKo!gMyMjj>fB7^p*Y`QR zS{C_9mA1F(b<7l7<9DGqRsU^28pP>U*dS(&JyO|3p^cfh#5;^&qy!-*H3H0+eA4>U z&)n!%_R(qBP1grQhDad7|K_%AE`eK|3-5A98+@~f}j))l7)RuopTE@vm3?p@hg zlaGtbv*SjS(7RmFUv?oAL~l_vALFa9?)4^*(mcnql75H5;UWW|1|TtJbF(IAr_i$e5EUx7;-+5Vm7zrC8y64&X3PxYB zq_QjyH(R6TEcX#;_t^OpUp z+suzgB~v}>Zemld{if+qJcs}}^bdPD$Sl!@Y4w5m$awYbC}1XFU)TFp)Xu*8&mWzO zmwy$svzM3q)kEo!E~CKsu1g$Un3QRR8PNBvqWqYJ`0KJqJYY9*6R*UwtJSZHUI&vC ztpig#Zo^Wn3+{>vyMLqIf9WedqRA25;({FQoV;gu?D9WPDK*N%YJr(A|I+^~S1=^6 z)`|46S+wGCRcqD2vzCDq*dcvJlZ*~V+_=I3p-N)I{6Ii~M4g(k8oUAscZItJx)Zfw zT9vSg&WKe8`L`=OgegXBAq59Lea5F#HFCB|Pc@))8?a>V9GC20t2I-p!Cx@9|1()# zIfSBIw^fafn5wvG&~W3xhB#*tGv~0KI!HOYwdyZWM~ct==29Mbt039(UQ%42rOwUM zST+eM=IsjYMyM%gq3M3VH2wBcolNnIuCF;pOQ&W(T0;(WoE9mg6C->(?s5f37 z=<%yK!6*-6+}1gs!9W)tE`iV;yhJa_uT5*$a=WiY)`{jg)rZPx@+v=cJPn`Y3ei3I3Y{VX#CtfwKEZH{-j6 zDZCcm!shSpA3H?sWBTZ(q8wDFK|d_E1?7Jm+o~(S7HCH^QaoFllhhj;D?q#IAjO`Q z{`RFNdeAp5YGbrmlgAWtl-N#X@49Wib(J)atu;k{ZKC&{?YzzWCD#Amm8`7KL4}J- zdQ90H{XdKQg$;lL5@R7JDqH~Hz>1#Q^I@)TYp<&~qc?_~O>Yf2%0V83$eeZB{~Y=!pjzSBdFVZA7F-NK2S6Pr334ty-lz2CR0+Vt z4wz?5)|GB&q}ddUEW)}riYu`@O8#54_X2>ywfL4Yy`r~4UngHeH_ksR2)l-iM)lR) zY0U-i8{v|$#B8%;*k2Mo-~osMT(DTE;c)!G|9j;>?-6lg`##_##MUX2`6p-V+D7K+ zGRn@ki~ZHh0U#g1Jksvp#3^2r(v5QrO)Ux&Y0OgrD?FrOli>Ry`uLXaf5FDNQaPYd zL%bwwiy5-YJB#Zvf%;XTHAaSgYAsdVh zLuy8rVpRa%pbmtI= zMeN=(A7SWI%|<34geVNDt<5=RSQM#T@bxo5$7GYNipcf~pU{OajErzl-~?ZoO#PL> z=#`L-yItof@;$q|7+rwaz5sF{cueHZQCgEu^Gq&0nGWr&siu>BsQ&&2zPQ=bC6(1O zZRPA(kTbH9L^Xk?YRKGwst)guuBukc?#(Ak^N$xF8nX*u@~ktygf}OQ*@vl~;x7KXjd9?ouH+=f2 zRnlH6ex>>#xvl+&5ecVjv(r=0sjQyEi|4H{WV=auh%O!jbn5^N=T$QeJ#TjEsBu^F z*;Hi_J@>zxBPbhY-bN}y{1fPGlqf9H_v$%%*(BExP;i?i*-bLvq$m%) z=`XelLu`?3v)U|V zs4ey?mJcX(a5wDyJp?a0GwHRJNTB=szd6t#*wVvv*i0TzmVeA54$P?6FU3fW7dE>n zz+TUH+-j}nAyu(tRMDZRlh zCE@>>*WkR_*{mee2$WZ*FSn9%2+HH(0a7Sy@EB*5+Nj%%=FaWz;v356-3~}a9#kec zXRh#fz4ZO25t*qKX@4pkl&J-X`nn8{fe2a>V6q1%c*#?rCC$c8J8+jYdDuFt9Q@s^ zH)IAUlFlN1M;>MX^|MILd-}M}u213db@7 zBj=MHgq`2>N+NB{C&v2W@W*I?#Cv?>R*7@*m&`3pW`L0W&iM?ypR5K$PLg&fwJ z(6x6uJ72{Sf7RXl2Pv5LN|`S)Cw1!-McwV6`|FDI+`!NFfmF$77><7TDNjmAu-LnNNL5irg+=wq-C$dbAbI}tJkn`QVtwqe-#pM%NiK|4aEo7vQ=SYc zAcSY${{$rE7>xjd6}B02ISTh~PAP!y*SSob8_OH1}Yd35?u1ymD8~x`vqLU2NX#hh{;3T+xpt9vxHV)8+TdwCPZXqFQweY;Qa2A$H+3LJwMcy-a zQpnKj_6oP}>JRbJ>!&`6ZL&N%Ko(i|uvsV7FSuQjRFj^5E)K1o_5DZkXgX!Y10>`q2ef zYFJr)l2jB(9YF*`8Bt|4c>Jy4A)zrB_YFMF0~r}dr=gPxlPJrZtOI5b$Q?%t;@V-5 z5bI`)Ubi*poo`aOfp#BCdau`?k6~-%{X?%mJ`?0fCeUI{`a&M0JwOY(=YCiBbP(v~%ju0$N5Oyx_SaUeGf4=q8O(!N)9K!ns z+x=A@ZRVBx>u4*dsqpd6o|6tWHV|LAs4ktJ*=sBXDybp5^NCNfDCO82x#wwYkkq>aMeV6Ejw1O(AhJ`? z)g0V!LHdH{#sm<62_r4mx39a{rHfNZI62vM`UuX$$9fNoZ`Ft#8aZX42B4qQ_Ro7N z>J=Ffzq=rnv7D*!f6=(ExYbWyak&0LhXlYj`;mB}yKmi;wd)vKbY*A5bkRk==ziuC zCC5=rl?&IlW=e1Gcwd`{s%Z8n{D(Tag-qo~5KT<+N2+oW`;gHJs2ECGxWkgh_w*|q zLn;HgHuKwF@~$SFxhr0Lp5$WW4#@p?JLoc58kfzyKw+Nf_?qZ>0cYMU!o+wry&;q6 zSifjskeX#v{+^dhcTJCoiF9S{E;vl(@zrON9VJZ*mI=N~@@PFEePAdhVJ%qG620k} z8;V&bR2T748w`}%r2L=`w5x#97C^lR9sH<BnHPr^OuoLIq$^ z0D=`^;OMLGV+FCTIIRl6jlYA{{^`7P1WXJyfY%$_Yz7(z6H*vedLfJKBcm(;mcs*t zH`wbr*%}AT(L8(iJn^&T!{be`9vnWnJoL`RqtMu)TWqd9U(0X?bq$3QtG!ok^?tF; z`?etGzfx2S9sfCgVT^7=YmAx!ggk+-aug|V(L~$^oIA{^$EI8A}C&ucK zZCKocI5CM%uA8$sG{Xij%_e{l7kzP^vEO2p*h3E55h<*Ce+3a zlv9q@z$Fe&7G5@viy5gXN?HAmPU8>q;zB%`-knkM_cT?fJFnCI82UMkPnxo_-$u47 zxes60rKPA%e%zYz$otjzx9-hN4vq6xXsbkAZIZQ=qbKYueH}WqYlpZ(3))VWeNxu8 z`W`R6-c{KCv2w2)&Ck@Y-x&H~uIk$DdJ>{0FjFis_Hl~+^W@{kwqVx<)bQibbmf96 ztcOd{LT?J6Y9B+HW51(<9E>5`pU)5p0@b?=onq{PCWDHkk%8yTx$BzJY1zZ?z2>px zmUDof>0nd`v`^5SNtd7}B(BYV2VM|jKf8yoaKoKJ*XqujW%;!&-8ozd`mZFR0x=TAZs6!Zd0Hiw6S$ezjRw2k;y&wPfzumjbR&G<*j$?csHLfI~mmy626Lsn5%SljXGT2a>`Wdq9sRSaY8lJ!g;)NOu&-QgM}YaHYfs^GCy9T^fA@Wq`>~IvyZXJ{WIxz+lqMT#d9=| z3$m)ahmvkAhl7foMK%Uwo>bARty_DMw4XY{bnYp*wp-!^ZiQewQ>JqrvUU}#0uLK( z0wIfcTFX!XBJ88C3ISyxxMuN|UZn>Nlw_Iz@}^kT9v zh%@I0hwJ=d)gIFMP0En{!V8didIikk&o=#Ok~Nis;6wD~#5+pbl~VQ#z86V%i_3QX zo(-{XWXK8%>bh4(E+CV-U=-elUKbz_xGTAi5`U>IBCCr&@Q9%`{xP|XBrPrOQG&%l zu5@)ZOhHW@b?Yhdq0O8m9J_xqP1W6AEG@n@t9H0-kuymD>a0xpmht`&b!@;3%jqi( zC~oC^R+B4YRV(PG$|YfHwXi(4Aat&Pa${{CCN;7ny%PXLakHb8r6Yt)H4yL=P5(Y= zFxQ}}{SL38d{a+ll+k(6a^Ibc-3y{IHdeoV>r$S3d!@xKTC1p-tP@kJIR!%vgvKPX z6l*~D@|sG+?h~IlWB>=qhh5B&=;~UAIaApu#v&=EU*#dA9Ii8t{)Bd87_@AgWi3_J zK=IfASN71h|FqoIlk6dX)j$(vj#NqSN;=I{flCT3f6ch0#+t+@6TiMM3kt@z-dn&H z@9FxM=U4@LQioDt6nm0D(r=!1-f~TO80Of{mg1w&49`kop|D17lX3T#o`U$ElsWB`Beiw zPB07>nJ{+!Lm+l-EkIPk&3>I2@(KkIkLjTHesH(GBGWaNP3FH7u0{&A8Eq_3LdhNq zMx~>%Intr3ZtdUAaG;VP2=C=)`>dwA7qtH)&I=ih{$Oe!X?)5CP+skidwfFdUHhL2 zgv_)GG)5*x*pG9bMak?F)G34--(E2btT|JxyYLifP5b};{aigyp~1NeU3747yHIGv zFMyRTJw4`1;3mAV_2%KY^^a;rYGwM=+0v08i1^;pD-}S282Jdzb(bX5XK*W?YnEqc z?B7EkeylSuI7$qTgWCtlZbShU)$vGf;Z}^7*;zpq)6HRRyvi2UcE0>I6j-ke<8&eT4ENUt%VgsAc%JVw-GvhVAc)gZ?*1 zYn0*wQQBOgaa!&5@g~9sh*4XefK=O0?I=ki$M8R80^}!!PleO?ago=RLb}GTEn5b3 zGoS8A&6q9}eXZRM8mW$20xA%>g^E%q+Ele;_0cd9Av>-@F~T(p(Dt+bkbmaldLjF^ zso0T@iB))o(7CdT!snQ(PatGx>d68#hZ9y|O5M;^8@o?G`lh6rj6#qHr_4VTt)ve! zITz;4l&*ac#g6d7tSQMbeEIw3*4vz~!#&~p8md=(M3^!D8eN99vn{$d4^)@8T3&+M zQ-5Y6-UI*NC?+vzsB*Oljy>%ITL4fIA#Qf;WctAlDfps7eW}Tb7CULQ)uRC7gR1Er z2?B1DW4;nV14@?k1L7Ds(G&evTEt;%M2nfZRG&CiNE|-y$QFMmhArNuuIk*;nq5tl zk=NEnmD02B>zSBI%miP}E|%UidLJQuD=5gWS2M%OxIQlVa10nMc(SKfGqHEH`{1yS zFE6ZSrh(&OpOf{{ZImJ;Pqc(yfd03m^v446F;*oNjM$jltMoGO3x|zt*w0Udh$ybL#dE6l7$kYQ#oHB1x9f*LsFV64%${mBLx-S1+ll2(xvnVa*$DzmJ^;&k=ek zBV?@Q2fPxJUQs9U7LlrmjZ0D^e983{F}04%eVo<86Cb?jyYOOivy*h>P$r&q(Z1r? zq-(=bX*}$uh&yHi2vDvA!F4yDyhXH#4`6{q=>T*m*HsIMQ&LebK*AkIAwXQg{wShP zUW8^d=$5U_JtZ(^nb}Xcycfa0>3l?Lzv!u1YIT&JLXYPPn{!&z66WCcZn_ZO=Tsvk zxV~MSTD+w_hn9iKji36FKXiVQpDM0zy|&>RH4McXErFSE7u z0WP= zHASFbP=Bb=^Q#YZoB@OvwOZD~=iIs|Rv$6YMw({#4bG;!F38t5Yjj}~RI3gi*0Gd^1M$0|`xZ^|>^^H|%#<+s6WYYn$@!p~)bi+nK(L zG_0}VX_3&hh6+TS*oeb;`2CzRPbJH*#nv%T8rd{U?R$a~QCWEFDa!2M@0{s?x=;R^ zL`+ayi^;)TA%2&S%^&3pv}i^jE*YOJNKH)?6enNBEFKUo7L!9^T|(;s(BSfh&u{nJ zu-}smiM=4-nzyh1^q^e-#z~zJD#Ai501vgOyb@cumQ*({@afH25q3MPL6UlSIJ;r z<6MCvtLfac`8BM83oI+yz;(r+ug0-r`10u&)h*lpYMJ~kb~1fim4>uJ0eOy5+)C__ zI@=aFwpQ`=Pn7$)G!iXh_HkrkqpNJgl! z3vPoRw=!^N{nL|?+?^c?n?m4*R1V>Fm)b#-BAaE^z*__q*2bRQTYFIn6J1^xo+l2A zZ*t+bxUOWGDRbKhnWM1*^=sT>mPHeec)OdCm}?rSB1^vjAR4VH)E+pC@E&X>s{`-K zgHmQhT4t_$_taj|hB7iO!P4xd|9I3=el}?v&95XbL>zIEx zOn5m6P&0-lYm78kLxhpG>vU6@`+0zPSTx^Vi%C~YK6X9Jk98$U-eHzZpv&>o`n^(a z0v}fVe1&$oX2%tf2>^=_%oSb1)y%+OOM{4mO?!20u+tb~?L5Yt%2Usehoek&=^#d8 z;hPVYRv8|1K?c5+44?(q|Nc3SOy{nYjYm`Sv)hR22iF=F9C2 zvi8pQHqs$sP1$t7()>~i?oA(h{DBgTPQ$aARt0p&*pG}K=NXfg`6Y|+J*WtjS1rk* zVQo!dw8?K;ocOPx{B5JSBbShCMYV7X+CpnRev(HA7rd`QuQb`3w(`EgV1MJbcD>Y& zb@DO1?3}!TK3~72Xmb#^o^}$5B60762p~ zyqv+h;b*n`iaDECwbp`*Z*o9?{bos?|A@wnyisN!5dEx>KO|*i)X*#u&uza4CO)K& zb9C_PWT7p1$#-D?kO<9pOz6M~~r!%EWND@r6R-GAvrSDNrjiG@8yJ5N#Lf zi-7~88(r>jP@RFu;#>0cih&tpa-O3ms>p%yWoOntJ#3atH(iP*ETPTi3^8hObYgr93`YhQ9UknDI^MlP4;Aya}Y+O-jrqx@9gH_pWQ0ZYg zDQeWUeyVbqCz1N6^Bn6Mt;9ZLTp|~h8o)zSge<;=qPJZ~%;KIF3@-OG!~J|K=mx91 zxj2fhaCj7{0A&!$^*ZLAit;~8I1n{mm3#IlRUv6A=rs+8<)&nRccK+wXpC8|Q-xxI zK>#*+GcBZ^r33(~Z~0232oppQ<1{k>5J?IxZbDXdV%Rz+w~an9SncckDJWF)DrR>1 zv_aoyoQC{!IMat0lS%eN3Q2uSwX{OBSg%wGqLYY3&e?qrSRUUOmr;qxjJfZ}?6Ajhe5lp|lS zS#TVhrKkbGjOp&yko<{G)=A8-x&<^q-?og~6f42#xcEBGV%o^#+U&$rX7?pP*U}Rw zs6$pz0;uW$K6uLL<%&jTl{@W@G5_kh39~35k!x?{0GjK9=en!3bD5aoyr{3pt5;Po zK9|b(Z9RxvaJ4kEIZwtvmkSoys5_eNE)O7qZi~GFY2XyTTm)vEeNe2c%9|2>pDO z`&y!M-e;WPsv_2};LORN7l>;lGk0p^W+AN)oA_i~)IkNsRFvwGX0CC9^nBm0!np$S z4vV%lY;Lve2pv_0K<*{pGPqg+zRnH);^fx5Dcf(2FWi!?o=(MI3;^)2p6OH7Tnt%5?|61)^4{R%{MrB=m zj(`z>Gz__OdyQaWslSBxWi_k&O%KtkDLqu$+s9Dh3&cR>9#8~#WOD!?txofeDuE=u zKyLb|dWn5_qG2Q|=rRFY(Zrc>k?t~a$=@yVJ}+frt_hyzykIKRX^F|uzm3~E+5U8i zqmb927k7IBf?l8|#8j1MgNOD7!7+WiAw#a7&IH0-T|;~G{dl$Ax!BbqA3=(-{*vOJ zKGt+nVoX!!sT3psv;gZp8&iSEJ;F}AgNk3?K+S#)_c`%RpxrgcGitF=c++Z=5}?=+ zCcfyw=m5UmkJ8Dr@4$p@sLSw-UlHp2k)Kk0yA$SKF77vlxc9>T`L&3snTfFdJarW- za+OAx2?vLhepj*(0~7#HJ1tw-#526#0Kvm=#y|-QAvU$MA|`EI1vu)_u-7JN6*tUo zYI zjax5Cs(7C#i`8$aY9QLU9$vh~j}#xU!Z3_GPbzhQEX&E8Y3WIfS^~A$C*ba!LIM<( zXPN<@v`3}|&bV67(mdL(v2C=y{}{zNlg_>L&4ECbxQwHmI^W&((@0SZSIP2z2XvzY zj=2*R1P#pMtfB+bXs#!u4v9U4hGe}2kNEV>)Sw^vUZ;Q(z&4IK+ zcR(aB+f4*hVb(id$y)Y61iy#JoIKNK!IMeDkvBIYQo5(EGqSXQ?D5RECPP<(0v6*u zz za~&fPp~^>?I1uDzR=#R@`Dti;j{O7Se?{w{{4w+1p3IT)3}|L8;GDyBr%xKP7cjl;FYVBH@d+U1KD~Ua>Js#q}+9KA9nyic%$FN41al)9{iZvhU;+n!)rJ z&U%C|Y`ozIfL`dZ5@Y_pFr%fOOpHbl`8N1XCFdoW>Av^;5@n!QVFGXw7GKaio=*!$wfN_kAq_-@BhvV5 z$Wy&1jw*xV=|CM$am<*cI=28rm90)z@Cq zt5a10ULha?pl?O?#3k**>lqxH;Z>A%Wt6}r)kmK?h@rSdIOfYxszF0DL1gT)uacP2 zgiJ%wLF=3kKd?b{u;b^gZ}}&#*O7BHxDXa1W1v}@C-Euu$sKBhiab0rO%|#Z44`Z$Mb9F1upZg|c-p^dhF#y< zw5H%Zk+E9s)&f+Ii`sUDYgtk2;Qa_WB~>Y)a1|DYAs`@Ou!6%*j1@$c>({Z;>x_)@ zG%G7A;q?~!hnJz0YTYln&>%p{94k6cc`8-X$5W};O&4dR*kA^3d)0pZYcsIGprEAW zyKBo4wxh|Zs2Em^kxWsdsjs>idJnv1t^#}_PA?1=KMD1n?SKgryrkX-7v%Et za58}m0O!?d!TtM?Iu;noLTNoJ`nOvaeSZiR4y&M7j0;S zmqvZA;xRJN8lU^-sF#;=$AK5d? znRTsxe93f<%o!3BXZ;TPqQh6$iX6B~K>Y7&Sq<~Ja_=EsOB3s2>xlx660O+k<>cJl zTr!8vZtF)V^xcD^s%rf0RZI+4mpltao5Eage>_9M;}6@gu{^nlT@wKoM#k^#vfm3Q z#y#g@hW&;&#}`rIM=*i+p|5iGXa%j7W@;?pzYANSe7WwUr(z{~C3TlTWD+|&yARzL z-jBEBx({yW(q}c~45;u`^$(zUSQ5zRB)#81D7PVoCclW|-Fk;k-9beo`ih9Rs9~+0 z7^C)!xzq2b!S8x+E)JTTn&ylErmvM`UHIU zX|)Rb^GCNZx2o#o8zz;fmlrJh|vbJ)LNx(Lfh?yI|&5nUcco_jj!i7ueX?Kr?UrYPR)G!@|NM)1uQXuqNW6Z^G~n zP0zvMB>iqW9VYOEiA3RHzR^W#fG41X#9OFV6oy}8r?2J7pML#Q_|N`aeHOFO*HJW* z0-;)=+R2d-5}(EI--(a8@bK_pby@t_ZaT;N>HJ<%x`7{i3W{SA62$MrAB5aV;LVC~ zLJ4*Ca^MJzj72ffNv>{Mb!v*zy`#vf49eb@k0ZwQ<=BICP^W^SeytCB00m^27dS_; zJ5yz?UN>>u4y4Y4w^`r6|1lA`Nn92uHKGECcl-xXm5cQ0Xm1asij2?8%}wL?QXk2m zM8YWmJ7ty9L|s8~{HB*G@Uo}UjjBF^+b(1d=JkTvWJNp)F^7YlQkF}A}+UBOXbRe&UvSJ8Mp0JoT zp(GP@etv$n=JDglz%UzamweZKbE?(4P$imgoSz0?A0)Dv;2ZI}pKg{tT$dG0MeThJ z2zb~^zo&Nd=Y80oC^|oPei7&WUZin$)dBYYcCep%M_p z7QURr3Jea;S_rG&7bL{O!MVRbc<^>~tiJW@jPSlcN$(Gs#X_JZBNMVq zR!77+N@#RBAQbS{FiO2WVUzXc8Bc|5&wl07Crws&I+AW^c98py!!+pwMI+oCeiA#k} zyLx*!4<7Ch)*SW&b8iP1Z;=b$Pk^ead9rX7dF7_7kdP2X+x7IYcW%Pn=OB%EAODmT z{NqIqn}v@+sieaDs$a+5%}qWiOGyp0Ey{zWz|z0~9FbaTT**r6N}1yVLOyqLxr_Jw zyhlxLZwzmO+Mk0W8GJkmP>-9li+^UETJi3;T`D)ZugF|G4EAjk%Z-GI>NtT{C}dUO zF7Lr{r5l;*O__GHq=ZDqb$-4#!M5DwTURF=!rubZv2k&u_mq^C@8DK)HdS3+9TtXiOqHo=h_u=|o;%iQO zfk%uH5TcIhi~o54!3hbSM}F>w8=_l=Cz9}&{FmcWSUb_J7;Wkg&OsV45D_CUWU0L$ zb+H8EU}zBB{@y>`sdihyzCn)fV{%t_o2Xa? z7hN>C=-{Jx|AmwdJ`H|p98Vuh*59jpEZwERbzvm6mQn+ObFD!539tv?r~>R#sl!O_ zW}#34FWDD``Yna?Xg=S$$A3Qr2amDi6o-Zc^!0vcX6%0rBIy77gAy}eRk5}^AlK?t zm@7VJ9&R+$ za2%{~jF0QP+Oo5gbz989fKWzn-TK|%--j0Z`TG<0a<7)fGw4ua_-oVuyI7A9f`84h zV5d)b_taP_B6AzHocvu0*Si9y=4=x)HOKs?!GR(VxZ_GZ`A&g4-CbR79v(t)h|j;q z8+2RvnWLa2DO)$fcwiK^;NQEpLc&QNRAEU+`S;>!um4Uhx$c2%nO zs;NZP2c0)$B%D*5DI1OQSFc_zudE!AJ^T0DeQWwgE8o?Z&ocP?%<%g3Q@;*WpQw@9 z+$mkG)xA58Z+(S~+!g*B#MW@E40E55RlG`T2>c ztH1T`++OPa>HV)=1&Eiw(62~XWG9RsaqiDi`VyjcHPn{!qxgK{@_^9-YPp zu@kp!`m5dN{~E?`pe3 zbhV57Q>rT0uTj3xZiK(v04mvKzRK$A+?+r1f;E742Abb-;3{oFY*T_8%acV89Hsyu zV*aZWPHg>)w3I6^)vS+-jI7{Dceaxd2PL}-H!xQk0whu{s)u~HKSYX$`2V}b;Jf8~ zYd9>>UyA4hkWO>9Dkk{gddmO+2g+tWvO@mPN4&Rr+CM(d%EsoTDqv{PLmrte#=tc* z6WjE|Z)#l?`80g!V9L8R^7A49Dg$Ht%g@Zr$k4k`FbxZ100|!02OBj&NEvVBrl~0j z-4nO1)0ZS$X@0k)~!I<6l@ik{m`|5O^Bmg1(uw!(%Az9IbJnirs&18fYwQp15= zQRBf{11`YN?yKM#=qE&<%B-E@yuZYC)f990!+VL%FbeN;hN z2B@+8c)s|;0v!N`;TDVY)FM4m1IlF<=hBt28i!<{N)Q|a%ER0yuHKI=cH!Ui*F*k6 zgHN-jLn`HpU9e;DIkdzj=#;rUv!sUH!=nH5hCkcDr#x*m96Ra~UQpvfedA{}FkwZcI3uj(&8^b^40ktGH!&drgm3v} z(MrF)hEtCK$et@&I($kwu`6{&F?bfW)X&&x{kV7{M@i(j+k7>&yXJ z?*DH9qk#<#4GRm}XP{omO|4eHB~F#()W*tkDr7~NWs(er6$}8aSV2|`)yB#|V+tI{ zcw7Iv+VpwDKNq0>@_s5YA)?8(f(A-Kfk7fDPXcZH0)?OxZH|k3umne7K#G1&~-u&}<{ZP#HERu_*ZNx^8{@6RI|ji{(# zI(HL=x{*RFgLtr8UguX&ErMV8E#EJ3sdPXod}7-0sMk=&riH))k*=fFCq)SoMm*qD z`ERCV0Jx>do~iOYRO(`Uym-MSeLqLHzKfMxWRlMlMiGw8N9*mG;4(?x-&yjGqSedQ z(i;3y0w&h}MpH7GHQi0+`bLXg;i>5K&R+>QRH^aIw)ucm^2=;skmBJqy%dnv0ceQ= z5%F)@4v_5Tdx^%A;Sz)2xMEbffZN-~0)v#IP8cJs)_RyP^pf1m>T{FaSq7UD*IT54 z-oYNy(2DBZr%V4~KfZCC!003O?&m!?IPqu298L@f{T%fxBJLMss3l?OPR9Jw#{*XJ zqeR6gL$6Jm0@sa4c1u-sbIY$EC0a>||;$m_cn_n{n_~+QP{8nXvwm^HZr(wW$JsRsvw?rCBG+uP-mCLTN-xdR-1^?##^9AF7VEeiD&sE#JtZ?>gLkn`B_7Z6ttV0G@F@ z`18~1;vEmR^BITF7a#_q4rW^FbG)?gy8#jh=La>(_WzOSLf#k+W*0HM;ac%4-eu_$7TByRyG`f*@#Wg<)haMf zWz5(MG}ZzRdcMFB45haI5u;`Ij>{^o?1#+1PZkpOU)@rKRheKE3p{R%>Ls0y4t5W0 z;r*r87!?nOQsm4nVK3dg80`(Je+A=7feMX&qmXN=GO<_^(~d;fh05s9;;f6&@Ha-O ztb_AFE9f?%bnh(>&_n%}2r@36RyO!^9z8<&t{ZzID#*{Vi ze1C86J1#Ca6VQWP`}1aM7mXfufaYp}=7JMD!Km5*AmZ>Pt?L=t2NR4gv!n7SfPyZb zmAPWua{tea(yZGK0da)>?q?oA`Jhc*1QHiB5n{?I@rxxYJz=rAMcAZTHxDK_Xf$jspw1aP85H*}m@o>K=g|KsQFDsZOp`uc*`sh)B zR(YTnc7;DH5sq|Lk$BFa8J1zp`Seq3itsN&wu6l!=ciHH%MyrJT0sa33ffb@-6|;=cWUug z8Wg9gPi|#&S_*Xa=mfP4t!0;&NUlIFlv@v!7@|BcKM{ap@vg73mOySSDw`us*$8c% z_;KMg&30D}!Ywj)B^8#+YHR&Jr*lE;cvlg#H9Cq&XM*MVrNt&h8U!6Xkh>fj&*4xo z_%vIudjy;(mv@Z8>IMO$#W!i#Q>pz!YPhDCGcpJ}ey{Mi8$_IISAA|4V-)Yv7R{}@ zTOL2c*KPxlCOg-`2}%ET92K4izxFbuWYA9r(HDK=3YcAs^K{1!?LtU)qdn@lowHvs zay|Nu#2|>;fO=aOUjvM!DNLRE*k6cgq!`R+1f6;{K(=w34!gh0(hp_s(!kZMoOp+- z5)OZU7pg$Mtoq(YfEW1H*}gTTSgqIDPD+i!aSP4G#$SI+dn|@5Z`*Z7*wbEjL~B4i z*$8ZbLJ8arm%U9%){)=E!0fN3#R+Cx#KJyVm}^F@$2*lR&%boZ3*-iR@6=#&qJT{t z8PY%>cZJYrwWREEVDjGmHM?=NPpV#=!GWg}zDDLj|2|)NfN(+32D8c=Qm6mvI4zzi zxzF4`_MZWmk7AGqknLD>R0LxFFcH3J7K`;qV3=sEZNS!UMp}m2v5r+^r>6lPAWq_@ z4-%i_;5{ZbEj*6x8^CCTIyH9eE$njcP&+kq&$|}&_#0%=Oq6!DeBQiRA#G-9c zFnJv40vaz200j-n`+SG|$>~*~_yKCfK_-?}Uo68&sKEfumd4b|B4;O9?q-nCH~lDu z7jc9qOJ7!X?xl1@kLw)_UiCeLpKSr#Cpds^bh`(^&0pF>D0P=)@m zygSENrPRi#HD|KX3Li_{sfFNztq$T$Y^FfF5#7S{`4k^HN?lV^-WVcKk^`*;GBUE8 zchKzJLfzDg-iMLW%Up{@7)w`d8m$dyJWMfMu>3T3Ne@<}8l{*=zUW28#`*h%iKQ+%!Ke#E9l}IxMpfw)mIx7-`v1qi>*@$tlo;(o&RA+#=~>-{pFI{P7v*O0&jdSVGeg`xzf<%j0*X7W2u>$aw^BfPoEyyhXsX(PTW#tA2WC#1?T4G zdR_gzx!HeYN(b%m_4CqM>)xl>FtCnKM0Ma`2fVdWhPIi|nio!D<=&MHYSHfFv38(E z5OcMyGpvrSSxpT`b8xiSA3n9v(<9;IYkpHO^@;w4%G94??-H(jtE=}r;|y&LJ`dgs z3ZtKK;m!eEb3^K-xrBUHB&kxaWA(eaQi+tl$_!5exF7LQK)-zXQf5@$`<>9|`t;k| zD6(acz}cOw4+>mo3E11&k@)CWK#$E=YgSuV9~TIjM_nHa$g{1T3(-WFY&u?VZoZrT zaZ7+LkZ>E_`;dJ+4@4)aAV^3*bc3|CNJ)3s&>aFp zhYnIA-7$dDokNEs-O}CNN;m)I`~4g2uro9FedRjObu6m?|E(Mx9K`M~*N#9n0WXS5 znS_Mo|K$6gfdSe8I2`WxceT^W|AbWSv#|2LTt<0Ok)Z45^O;Zt0%~o|$eCvRa6RSc z=hp%4;nv_)TUqaoi)V<5xV*VhpXkxA2j~43pQPImu*6eL;Cv0?ml#GD)gia+xtiB*8}i#5N21DAy^5+PE8%xw|)2Tv4B+`}S>>vI{zQT?i_;sR110kX*M)qb$vO!G3ZiUFj| zl0{8g@ryFhr3K8jZ#+l6T!GgZXqwf5nd>v8hvEdR!WDJG$pLI#yycKyb{fWng}PgWJc zfD#oIl}rZZsPzE4s9ww7E&?%h1llp4S_&f(F30gwZ*MOa5xYUFua~zs32@=X^P+KX{A zAQp*dvaW$G%ibM)JBF#~YW_9Z#vXc#3rYlQR-+%=DO*`}>kA>!e@7I%(9Y5MU(}VJ zCaR6^3VjP%oC{DvtuRO_9|Hs9U(u;6g7n`bFZm8p^>zaj07A@R)O>kX9>DehB$X@= z81He5!{Vf*?Hyh}0Iz}2AUUi}g+cZaNH; zmNNR{LqUp&lh~F{~ayHv#frf%gNrp1|E{ zy&)7Sj>l@MjfRG1HJovGe{;mm#Z};7OQ-X28TH_4{Q2k4pEEPMV1URY1x?c%(U9I( z-NSCmrFbdHq2RSD6z1E1EyHf^d68o%SF52Lll*jjaz-Mz$`l0+lzBjmq7l2mHGPm7G$w}O-xKgBE|pr)2@NV zYfs6|0gWZQ#0lbd2o_gm1wS`wAFqS$uYdOL7#sLYoiYcCNydE>B)EsZ#o4piYlSe zF!9XR?=xiQ>3Th27{xn>aLZlanvuHG8F5FS2!0o+u8E2*y^^AGzcB*T>{|osaNCD} zBPu{T7XqgGovMw^&J@cB#TQ=EocvrC8pl7G1mR_`1EmIfCnvS;wds(la5yg~=hee~ z+kV?>wlP< z_Vzu}J=|eoVgC;N?}dbfb~SVKBqckw7D{7rMiXbK{B+S1YO+YUbarSBX1~ z+YmEeJ9mzr$L>V@zDXmktQwVHQa1JLcMOgr#H&P~5r%h?kdsfGYf9Pz*R=?>ZLde& zv-SFJ9xsNPJ=0Y5|F!4lw++z6vt_8id~F;sRD=S{#d?lK7`n8s`Qk0Q>jkGDTvec-k8Tbpm zc=k82IHOsh-AV1Cpq%P}=L(#fsb-a%`C={sx?{pdQ=&8D0uzh;V?x6G!mTQEg7@?- z3vA8qcKI6A7&fOy=uThaf$Nmhj0h5`nvHhGCA5JkuKpyth>lUgEGknul! zMCmw>@>Y-FaJ?l^MBs8`Svox!ha}0!mn)+056!0|VB@P43kKhiqft@=QR(Kt)lg9U z2v`fvh-r8I+4m7)oO0w{8HQ&6Zf`G`e z{!J=zbZSHhSyWiKv%5Q5hVh=Y*USy0d+Odg#$iSFLBWn?3p;vi&f7|K11iu1v!Q5R zZ%|z0Z`T39(jp?yP{=ncT zDBHP^-qp(30MB@jIfRDsP&1gvWrFzR4|pEAQ?Oh_G;gFOp+^SKhr2_qs%C@g?;DBG zi|29-@3%BxeDQOv#59j1KYLp+4vu?3?Q=jt_dT{nX!uitb5Qr$t|Ukh@~i@ znXD~sl^n@jv`?O9uuYM!$g%T6$-efFMT$2!In8cHM;)qtI;Xs91#Q*90@}nA|4Jz6 zz1RzdT=o7W_-F?RE5P~iB8mf$8=|}nWrIY(JOQ1VRrZ?Mx3!ppKB0QA)aOhezV4B# zKkOUAt?+?ob_-u^?N6#5Q3utA35tGuREHxT1UCbo+tehqjAe^QmXn{KjlH`qMGhxq zEn?YYxPhgyyRGFnzBTonYS{-yKg=;VUgH&2$joQ_lJr>iCB{fOP}TMDWlV4Zdpnq~|d0=BX4S09lttQsqaPAwNsATJSm zlphhTZ&5k1b08w;X7;w)8Vz@EIht~W@@vAUXyJ#8^SlIcGlyiqvL~nihT3@F7b?C2 zVZ)NIjXnRiB4^9Jlg4*TEI!LfDw=K4vU@g3N*xqvb?Y&Cc-~2WO_qo$ES)Wj%YMsQ zkj!48K2Z?Z{oI$w1-^7ks2 zKo!#}*?JP3D}c0mV3%QKA7{#p!3&c@I^dypO@VXC%m}`&mpg~<_b|nFn3utUJEkdZ zYPpeALfNAo!6ws6^A8p7xEBo@9k9b?wv85_>pXVRd+e1cnm3y-+kv z%J9TG*KoL9m&Dyd^|S7GO55-vZ@N(_q$B{$L=Ur#d(RE2o++>D^Wd|F+0%8z|8QJ- zeIGeJ0ZOh!N2I?$BIYh_GQ~hktBsp!3=(ilcEMHN(71y?>R5O< zrzK>MZ(I=x(;)OsS<*(LEYVOHXEY&@W%k_TsnteNp*G(>1tE*?&v4!wiO7w^Git#3R=a+ zsE>9QkqML$$4bw2JxT#Bz=BKi_)wwtiCKrGvW(1m(A#%7oI)Z1cjU0MVpvk-UBD$?~ik2 z%uAUuioliU7Vuz25%h}NJ(ut40yGvaEC_z~6_Y(xo)qMm>K0b;_#FwPgp3S|eGKPM zVNp?H;PQ(=x$=Jo80(%wc-iqer=hBSvegPUTZt05e`&oMHgy!9#V`~_cYh7YZ7d8e zAm>#AL7W!(qEVk^K6^SbxH=hEI4-p+W{=dKAD*$9-826qyT5li!;7S@%#Ft^j z8)L>WtrlF5=}*NXloCIC_s;jO6H)xkQN#X83RRfmlWfWO_BNWen>G zf2(?;uIi)>C2*$Nk7g+;(p19d-`pwb4}kZttfe z64l`Hw1WBKNqe=v=LHqg_jgEe$bDZSnZK_F{!8to!RgOI>1p6-F?CDd=UdD~z|-3R z0oZ3*+uzY7foF%S{TtgUr7vCHU}RW z4T7EwKNxSFrQ|hE28G*L+o!l0HrzR94e|f%5_p0wQfaWfO(C|8q^KS&nmBHxXgbG?g`SLEuh)L;(3?s3!w=LTuV{r&SMJ7fye- z@f2n$66xW?awRmhMyIxm6N<+R*^i z&qnu>sjl-cw3BlUAC4$4KIb{AD>)Z6)TMn5%VhzG82=mnQFOb$x+OVp9PeMW#>TyE z*V=ZiXEOQne_L{~h6!ye@n9MA;V96K++Hxpnx@KC2sw zO>%#MlK+MY^|CASE%oj-LR?m)gs1Lvhb(#ptx{HqRpCaX-__X~{gA7FJ@s|MUox)k zm)L7-c-`v6rZr6kb-##y_O2F`EM2#h*c)gA9geL6^7Jb1FCGj94eGl$_Gd(x+pZJ(oY<~gma?%kNr&7@ zQTI%iZLgn<%<_u#2K2nJ^Ojvo%&rfu)SQZ7E*qikK1Y)|Ik<%|z+;{uM`z*&j=zTL zik|ZL`_OCz_Eg zsqf_vIINK%qV1~1-chP9;CVN1P2cZoXAm3uRb=q5=G7RZr4Drf#7%3;J4jxsRb#G?UVFs6I~yR^ z5WsTN7>Gwx*YWHqI~KZr$@v1rvm6?R4~m|10IK{DFktfr{E?+Sk(ET;^}9TYf*mW5(^s4Ehd1p zN%!Olh8Jk2ll8xn-*CDEFk5xbBLbXC;8^DID5**{aY-~V24tnl?nYZt0Z#a0n!)%< zL)MMDqc+gfJYDwsqZCC)Uf9Bf@%!15Vqf931_P$E+ZHW1z{nYj5$5o5q~`e_8Qy)K zl$9h?tWC;7gTAj=5A9ry`Fr(jaTyp{tN9fQU8K0+fh>xdL`&|yG?UOi)`KsFHDm$N zasR5xcV3jNay}F|dSSv9gEN53cnFi3rWjcdYfEwYHk6(Y}We>izkHnJ5QNG$55I zXriT~@jafcvEO>k@$ntt`+(%I7s^HQ%+_Z7&o7=2k-e-7f*fEDTi6>pxu~U@p0;D` zXtWkeyc$JX#*x!<@+Kta(1x*=E?k$baue#-8OWd6sak=$_Y{0b&K(Uoiq>H&i|e{= z^3zeE&ed8Gn3rT8p8r}JfxRq|c!p}{G@ZLcg+Y)21H@Jg&Pj~+jdn> zOHGciIb5E=5KF8a;h=D@;C@wy|8hyiP>hc^Py^cyv;YQP)&xhQLNuDSUc9RJ5n*aWF{C&a(jWP@h zxrVwxT2XLQEX~kbaATr+b_t(tej_F_B+jz;Ya=BdI3?>0UW2?*_p=Za@}KOc*nCh$ zsyA3{^|%gP|Im^s?lG0UXoG5l76wq((U?V6oB9NGPSxVOdd?zg%6uXJ$cWSQug1btw`9M2R|66AwJ_5XM!C0< z-xT~~dy0~V^2xCMp`r}S-uOn!Ka<9iyV+~8g@uX?Fe~Tt{`RKO)jZZy!4&~3`FHz|Zf0!nE2=?D zSDI3TzWlAvIPF2K!=Yx#kA>|?u(c`i$@dZ50H>+IlJ$<}aja5z{3u+kS3!xR)?Ly5 z8rgorhN3C|wL`3Uf0F8>@4Q=XcHpY=A#8V{2Q^HAV)FyH4Y`dF1EplF?gGuU* zU~c&3BzfJa55;p+!!Bi(iBqK*;0o|qAg(i%?=1$UFv5Sor*3E_1`QF6=4!nP7wH8H zHr-~e*tuE!n;Z0Cew-N90I$T5Gk_`pxZU}Q@ESAc7x}7h-UtTt=o7Qm>uYXi?~F0*%bx9zo<=_zSgrcg5jak6Kzm9WXuhfsM4%x(i+?Pb+xky<KXPgym`Co+Y&aNY$O>3w z1c2Hb$z*j};1Fmb?TOcNjDxuQZ~U(1(t8P-$kl>7O%Zib+!p3fgraok9)>DQyOslTt^=MuHVPl$;&)DQMoyEXT+9>qFvHhdsGaG^#4 zyg#Klh_5XsTPWc_I^`$9Sqq4mb^lkDbz)UN2r3JGHm*Zsagx>2dL+@#0?-!rVRj(J zYduAOh>mE$Rf#mW?P^{{m7CGH-oq}*%1dWhGbDC_!ik!Wsx8eRNBfIu&42%Us*fQd zx<-Vv7zuk#dVW^P`*>d4Eg~{8t@4<&-iMioKB7v5>6(;QbQbU)Rgx0r$A0# zfH^jsXNA6V61t$XA;=xg!bYyc?5uM|yUgH-fj{9JS!fp<#|i{T9qu>3^@>q!bcPN2 zyQExancAP{|NOevHN&8I;=WGJrii-SH=TR-agR?KZLyG+!6-*hn}bs@GxT^m@lJUjTrya%~Y5+eB*+;TGc2L=2&4w6kKKgOk# zH@pXGO4|w`$&}8UZ?O*q8zrn4J+wG*&iE^NQR@AH)cyCb8I(!g*jP+dG*SffJUITx zIRJ4tE+s%Gx!QSazJ>?{3Vo($NKxb%9<9h2XV32u)YsLC0^l8%+Mq28bIO(^_xZOs zUoahH*hhsB@54b~@|@#0&^Vbtpk4PIDfowNn+`-VA+P)HZZ1xak1H6E86doUn^@Ih zRWm2e_AEjiPxWW0xtqbk>(q2}o(AE77kii+VxWoiETWmYz*k=8u#bHd$9Ywh z=?nU-IFCTDwZB(h-^mv~&TKkw@FVf@TxBH+T3R;rYj+`GW&^>mJvhl_r$UbIUaL&r)?-!L0I(vPjqcaS(iokpHx)%mzpTT#i zVR}jk20e5eHN4l{lz2_ii~h-tNzyXn+jX~#;d^E$!7V?tihM(@%|*B4Rw~R}DkK?+ zY0~d?+UlVGlcaFBB(pC(OL$%l;KlUwUHyA84RDtM#=Q<~DdkKAYyE~^o@G!XcryS4 zv&;V&`5x#)r7>|3bkC{ zJV#j%V9-ryw*gC=S{3iq@4n0Z&BgD;`&)r-UU`D=n-}Y%!)qES;>NQlR}?maGzrqp*6VuD9X%x;o0| zN~aS#=cQ>Ht}vD}NS_6M-mQdo_mP z)rAm!HraFeSaszgz{d(XAzfFyV(c-g?-QdoRo5Aa=5ev=@cl4XDO{ck`Tj9#5(K$G zSAVvj!ek@I^gJ39v!NU@rMt94gzZ3)eA72jo$0rwd9rlZLG{ ze6VYOhHT;!65Bz&^&)mnzD3P=C zx13z!xd;!_gGki_e3m=reTTgiLtT*!48(3Cgwum~$sAghBC|@SoxnnD8?U_AJ7xqN zV7n1kmS`=GChi3>&@SdR$}tV4>Z|nPKUG$hwhX+e^2*FTBbF!Gz0l58J;S;2aGt9S z)q^w*eJ%dUMgF>v`xL~xUm>`%vwzvwGWt2C^%l5hct0hYqr4o(ILfdrW7xX%n(wTx zj9dQU6XO-?Ik((byh!(w)vsWgQy|>g&rE%iH;#pPR$Bu@xUAeEP1tf!B!s90IQe#V zY?O|;u)nd7*C^Z{u+yXw{QXh*-OSsC@C5Pbx5%`C`P&GqD)3jN+gEx3?-5>FsPR^1bTmEEcd!Z7jO4Tk zM&`gb^#u~61JC%ElMxv(<cAD}B4@xVjrp(V=Wx)6Ay! zRbfixPKN@`5W@zSjkWG5+q#viM$V}(wr8^myJL%~iM{tRXb}s8yWhpt z9{(JX+I-!?&0Eh^uwPQWyrs_I%`p37X;l9a2sU6Y$c51zWwMk}Ktb52NdCc*MzE-p z{qFe6W=1=fmXuV`?2&C*nPW7i`rKW*iT@|)k%YYA&G9zuF#2M%Pg3Mh(A8N~?b+tDzs1;7T%)abdSNo9AX7 zADDTYr>n8p!kpunNYhD+a?=w?<*t^F zlI=x9>DB9q6_j_%)_W;*nK8*35q~ZYRE-6pbQuxp1#=X0YGDR@j#uHQwhB*}3r=92 z^Mf=G_SKL|wj==uN=>E$G7tr;t3S2N5DbXbRms&Ds(N$4VtMROC0M`ZsG=u~s9s$fdl`7Sc*E2M(cgSkSZc(d}9YQ)a>< z_Ih(eH*agB9N!3U*6-OcU6NNN4Oa;npBp5eB_6NAm@W{Yi@%KWXggEF@lh6wy}hGl z{OQuow5{?3;faFpFo%<~Ew0jm1GU?97!W zSD(sDsHDBY;SkenR%J|3K(HYv=-?<7w407sdKoK2MX!v0G-Isx+I+Jhm6hD4`hek?-c3#OS33vX(jYXfAq zShzFPA-l|hI={ZD(Z(%f0hNaENQv{T<4x?GNHE9PM#Qnrv8(F@8AMj6IO!>0x zb7KJ|beOZMxACF2OpCA9=V1CN;YrQKS0Z&GY|?5nvm6fY^+7}KaCy5>b`&0*wD5sU zHyoynT=(eV593NJO}r~db7pFdHLh_FiVte-rEu$kLz{;XUTGyXZx)?vUF6HuZ2Xd# zFsbTKvDNM~Tl-b5en<8(%7+bzj0xEY-`%k9Qct%cbeHG?9a^gG>}E&jT|NIPoR2?4 zE~ehxIQ2HJXnx??qZYfF^YAj8>!1P;spdi~V2HH(azyRBTYat%A;UgOmI+uZ@1;MU zZMVnsS^ln>T0_Sh{aCm#+t6#=@WYtDtkfaHgJs+mIa>G3rDn#LvSD#isDIzTd0h`; zpXRW`@KO`U{rtck#&J^@rjw6OQZ0Nqp}`k%@qEz97D*#9m@d`xG||kS-~>C}V}Khx zu)|bsRWa%#xIhksiC~8HLy6#AL|j+NbdmIx+r#!_E*zAIkC#uBjV;}~==;fj6h>qF zGKJqx<7Q4~Yo^_561lR7XHw$+fXOiF^aWSB-WohH%JYdY0E5BW{yrL(J3HULR^Py| zDy1&beR_FXRfaX$8BQeTd-)S^h>UrBXeWd^)ft}a1&1nn3|%xzvi1GN4CtWRAY^+Dc2CUz#B)BhURy zi?v&5Y%GqCc)4DoILgjVxYhBB%9FnabZPY$t;AsFP((mxWaJlK?IjCQTYk>9I&k@B z&t;aO87BuuD1}-@vXK9jZ$Y7aI^RWfW^COIoNa+yW;z+_iDc&BSUM@o+a-Sbz1QI| z?Ce~193w{Gztif#^|@C{?@lR{&8$z~8{-wL#ew5xBHrMtxAQ~YFVP>md;49^&NU*a zD1M&?r7TI;P1P2JQ`0BCCj_QwmsbEMKv&2!20n?jmP5LHEm!(*gz3vfliDfCJ27vTijlgy_Y+yMmDe(L(YwYy&9K>p4qf=N|TQ zQpdei>Nf2VT-IF66g5R?dS;XcTiQ06%KlXikrnRaEY9^7?hQmcy4KFa{C%E5UCVJX z34k#bn(>W(y)j$tGgvK%+HO@&r51JDpP6jGZ8di9<=?dUkj8LJIX-{P5d`@T>sGI* z{n6OHr<%QYr?=VCw0*kJ!`DA+{9hUI?rx??4urFRS{EV>uWWbFXrdb*uTipTZP@yN z8m?Qp)YwA7SHD<_$j>}Ca_-|^wwOhK*1s1b^Pr+k5BW& zk01SH0;a~%F5IM0wF!t;*%)DASnt_c>Drhpi%8(fk!w@-63%BE*%{8Xq|1i~4x&XVME!^1GBf@>5sdA-CBdn{RVOqfrgIwx4< zv4X2|MKTfc;8lD5dSb?kmk2JarIg>{sjtcrzP6&+0YS>!^;^3H+;p9fv-B6nH%Gg~ zYO9?qV@AalE@MBdZjX^7{*E@$0VvKGn42L-r0&lxC!mX>@;ZxR?*dZk9{0Kfr59jd0HwnZ+nf+v_GLkVfz$z~$ZZi>GV^UKcHQPD=UuNq= z%9BL*Z&txEVVyr^5R)dRk+7Mb%1^J~Iqab_hd!f7fy5AGF0S3w zgxMZ8oD?@~f)-V~se_Z8kpuryKYZTcwXbPEd-(Qp zq^@n!=DFRyYzyI)>Yr_*NxGb)+bBLFiWfWkaQ?+IN0NCRebZK$(cCiN!*tk92>5lH zW@j#|cryLX)WQNPA|w3a{j5OQR|A+ZC0}%Oq_)l83|$5>?F%!1Szhgyuj7IcrX_YY zyz>%&YhPRf;d6rh{1GGMHSt8@LI%#R;h|d7b9?GOaK0xwu2M=Z<}Ol953)q=+8kDf zU9y#)X;s8W=&lpBZ#c4@)Fh=OLw`{RmchLT9dVBia{QUgdQ+%8Rv@U`Ci1`p)Fh^}efVNioVDc*u1G@F!cpJOZ}TM#hw)%J^;C43y^Qa41<*zMUk zb^6bi(&o$uN1{!Ozxc#g-Q0Zmie)o|5Y8oUK|H#(U!C)U=0IeOHb;h@@Re8{nrK;m z7frXOO!HCb^=L1BMu7iC0`vicH*$mk1AE7{?ETTr1m$s~ig-)W@<^ssk5NT3!DW@y z%)D!RakS&1thSjej;@01@T1vMg}}ahvdVH-7+q4om6g>5i_QRJNS1a{gszmBomJ^( z7b~B#PfDOL$L+>95V?Yq{%e!^gh3+v>!+rT#MZ~>7w_#K2PM3q3Cuo8OA}*G>plvw zhqlT44Y)QLcZ+5aH=^TXyheqrYb=xL$NVYt@`65rPSrg_AK3;04a(2QynQLuv&r_4 z-VBPM1@q}L4603BcKq&%u{|^q==VwKbv6J>6`Tub2Rto|8T(G zv`IQ+nfZne(XXm+mRJqBn8o#JUD1b;kE4(g*t2s5WaoK}Gbs5YMZ+!L#}WM1k!!Ve za4>W5J1MT<_^Zy6d7oTY?rGV>cz7XS#Q71oqJeNmGPFHo>LOwwd-YmZJd!WXl|@H? zP{fcz_G}1~cR)QKY`GFfo5NkKydu!XWup(jJd<4Yk~g>aTIrhhpH2uMO#=v59)UF! z93#LYHgx(L+eoLO(y;b3bQ3fDbgb64Y@xP`wO=JnH~Mn8=^L0xJiRN!)V?vJ`(&yv zv%(PvC-hAUoxjQ@#K8_L*=$cuIa1z8STCJ;c+n)&=I9nyI$zoJZl-eiBCAmv=N$6~ zELG+eST#d&$Z3nN6wI`oXLN7Uxxr8@sTw~Y@1=Uk%e3xR#onY^oqO~{WK3@hb?^4- z1W>59G%AwAs!Wb%3uiljZ_%KIhFZe&Y?HjC9TcHxQ#)O(MxH^uBCwV8Vim(z>*&_b z38cLokScw|hRg`p{p1_k4>0NazvwdtX{VJpugCWdWc-Ym|wi%;2bP^4~0 z679k zWzG|u`L(jsdl};0@Mjd1$m@yZvz(DLiiu>4SE~MDj)$s8j3L!Su({9F#VWlP!_fzl3I zh_Qpnl!1##wv?ZQE6L>{rAw1BOFr$_Vmd2mg&nBHBbpM`ql>BiKECLVyjQ7Ie zoYCC1h(~sB?vcey)^nC!ZjnCmtC}hHklRRj&A_@|>GMmpErTHK=C2Mr!EA{zf)9cH z)F^ttj{B~Q%ekg{)Ub>{%hWI;vR)lwGJCQLaDff0Ud|PVd}0PnGG$#0n|Bq-HLaWK zzl0S)>YxW&tG()Bn}}J;eUuGzzB_bM%Ck571N0}WJkmBBSuTj8*ExEur+D&u5kuo8 ztTO?^l;#t!>NlCuNd6-+O{eK;A|`yYIn>zZ1yXQ&%xH5#sC#%#sp4CDLDRQ6^bFl# zxll4QA^=)Mc{)j$DItwAHIL?Ma{I_zN9>K@I z3d2aZ>Vi}L7i&z04kn~sIM~(B%ivxrJuwibxl)a>S;6M?9Nub5;M~xJS?tr+g9~@I zOHvGeB#GswI!r(ZeB`(k&)`SGe{*CWbJA<-7tj~@n75WVvt`OXla_(x0B{WDONU&+ z9~7SS$Ge(FkYNpt`iKGD99Sd+58+Y;A}}d6ueoTC@Ryj?t||f=vP5Xb#l?1xj)&7& zgsw?3BTO5IU%)C*_gE6l>9;|HQo-t*L{qcgR=vAqDkaPD@5m(?m|wqpf)ose5DOAA zPV_NWVVOHAv$Qp#Jo~=lzW`Tufs>BCn-tJq(LBm*hXl;Q zE1>2p;Fvga{u1T%5s;#wm9?$nu&XC`DbB+ic-opeywpdTH+MQF&hc3=3?kNJX_Z4_ znuz<+l;|?Erl-V%f=61O3tM$Hwcp3C@%+qJD(9u9M|ofUDag2$zv3M2!66@Ef;Up@ z4Cq8Gcrbv`ffD(M*3>6>(@vj$2DN(E7Jk|6g@VRnXhvs-$ov@ zs<9<%>NM!8q*SUSYm*L`bnbcTA3x55e^X+M8U8FPi?|uI+-N*0YRGnSboVE4qGv8B zhDlu-agv>AZN8?VI|?0+%j=0ct{-=VzhuQ5Zp(!hbO`I%Z(r)`QEDTpfs4hTWuFFN zc7OF~I4#VQF6UyqBN^S2V+HL3jwAXD$V}UeC*gJnE!9zKvp8e}eHN6ODSG1}BEbb& zpniT9%w8fYfABP5b{6LxrG+hw5b!Hmx=7k=ksADI+zDZg{}uX^|Eucv%g1ii=0429Ex{(^e(Ri>Oz4q z6VrS|syqG83aD`5u+HE7TmcVecFSf(4c(lzg13G?3UW!cn2EOhIIc8ba?Ui5R@++k z!Q6Xt6&ih7IFZ&0-}A1c2ak1siv7S>(v#(#c@Kw*fN=g#5pmno8$TIvcxgln8`@2j zXZN%u7#3l+VFO3lL!6 zZ8`cUV}xt+lYXp>6|Jj18)9cIU3npcc0n5~9gZ4q;svFtcKdHrky|YFtL?+qAcntb z4;(`L2kToMw%*mu$swy}98;9%NLC%J^UtN7Pe(s}2xE~uIHZ0!SRM1Ou~i7%r4CpL z+p!P^+f6=IjI6(_6GozL(ZGvMYXXhuP#osam&*<^XdWxu!_@OZow?~N%*_?6kmb-hJNhG9d>R9EDr;*wg)8Gv3)!}1 zpD?AH*=zQsY1zh0T;HSaHD}YK7B{$FuWS*5$4j#IlPE=GErsNApZX0Bq0`*wobwG5 zW5We5fj5nxfTih=)8&YDHiU^#%L<5 z- z^Cd$m&n%rzu^lOGX`6o%Lw?<4Ul(8w^->aQMgbWneXVF)6+2>IM&J$1f`FPHmOGEq zGs5M<`gV`@_Zj`g9mT6j{*nSGV*VN>hNB9X6fYtk4+VuG6)}V{YRd{oYWntA_HBlm zvd`K@5&21Wzzp3|auSuzYghT`#Xn5JkVnqKK=%IS@OPku#i;Y2o;&BA;p=cjqLRgl zMKG??M|sII*OcF1gz=)pKNmVsO_Jhk`_ab1!EX(!Wpx=YO<$xN=>kCwC!(i%P`?o4 zY3k6*fD&4B6+yxN8xau~7dO-FVr$t@==Y0FE~iMV586e2@VC3Gwyco2Q|=;bRTEuP z$iHTsN)G7vbi1xw>~{50sq zYMH@gJ}t{8(?GMcbPS4rv+5P-&~g4T>m@54bxi1>p`u!eRc4xp2FnEWbEcsl@7p(W z!XMSw==a0@-!ScnZ2#WBy1l&_MV@k4-wix_Z=!uWSEhtcson+_><_* zW9sUPdOl&kfF93#;!!0H{V3jU2k>h&c}wH&vfr9v5R8+6m_1zv8}hpn?~8)kb0W|> z6jML}H?WOXUb_3eOJY38a{=bbQsX~;lYHZ@T2yu-k;;N3ba$;W{P!bDuJAR?luO&vcRJfvi17BVa2|crz-mksK}D#M&3RRyNN1p<}_-=tgK`bn~ys z{ngv>mniHh>4v=oXJ`ys|Ax%q{sMKik1)%eH|u-aW@pDtel+2tBMJ?L!Llq^!SV=} zmi`n^e*t}QqgQi)r@!x4+kxx&C5a#2;I=94P4T_m zy~tb$0;((&OklifRb80c;DN*(b2=QMPVrT%tY~a*%upSr1RDvyK3Mg4&I(NC7()zE z_qG_8XH};z`}%E5$txXJ=kH~C16f5||0k^djMkgBB2lq5kF)6L_dPC*F>ogIaELK^ zH9Ww3mFj^x~S11HAw+KK8G)T!;4(3pm<%FZQW*#J0yyjdDHSN^2+A7qoHq3o7ipwt1^o`?;p3 z2O=7-)+F4U{636ePWt~E#rpc-$lC1@Gm_($1CdQJXV|5)OM$CJu0g}3TbOv{-JPcJ*OBy1Nhm_>{?XW?o`awp!zdMX8~B^;ZI0v9=2SRf|_+^J_ObBNsL_^2i@; zH~$s3DDGv8Fw4xoT_rR6b!>Aq`8skpaR{iGifT>D zS0a^87TBj(A8znigUewQQ*Ud{09jq?9>>-@82ZC)|zNg3S~+kNoV1A&()u}KdCfus@{hmTiK-sl`Ct6b zhjzHVc(|{*DDtSZ^WDg}L4Aaxhc|2vPKW=h>kazt1{3A=1h0>|IQ~?p%`zlg2DW!p zAA9QVejz->`DJ&QPH*yYe|TCP4ROu-9mxX*;dqpJXQ+Ei~iALjE{= zum5E-2=cc@rTKjAoXCdI}iJ!l%8Z^t&EtQ8pc>pwjqm48tv{> zwti(gqXj?|fZE1#&Xsl09mOes5-8;jZ;y;c5vX=?@cbrTv+FE-4Y;#hx;yS_GBM2$LJxIpHdM_wQ^2J{kUDO|_)I9MQ z#k6c_e%jB*%4&Lk0z+TRePrC3Lubo`4Sr%Tk#v-VDd zA%0yF9UY*l&F?xA(UPn}T`Mp5?-OEEWPMO^zJz^Qa2V8 zjzgE84Xl0Z62LaXjx^NMVg_oIVTdqt001KptxX4r)zRV-9yePssZ>vVtZ*|$hxYD6 zr<;OaZANbWUB}MS;h8SlML~2Hg97bNOq&n{=s`Wr2%{U`rJ9`^FcMcfyxLPOPxCjS z+VPP{^mtqbn3;T4LTm#2Gb~3Y*AIag!^Bh|mX;8Ny;_&<9_fEo$M(yehkUbtwxDhF zdMH9E9q&5b+R_@NZg^qBIcaJ^bp_;~w+Vz`mk9>Cwytrm>_j_ap#R*_kU0Y*6MOGZ zH(usPZMUnvpmQDdWyGI^(b;8AS%Hn%ksuA0N)2QzvA|6Z7LF5?y;ulgQGq2{Nm){QP*swsdV zv(LlB=!+Lqm+)7Os(11fs@{7>L5!@&WVk+V-axvt`8p4vJufQrumO5Hov#Zpka1&( zrKq3iCnrMuTS@U}@iCl9oiBw3PWtZim~j}^P}G;&iEvU7UcBpc6vWB=twx?& zr9XM{{{4IBg0IS%f)?P|rscP3bbIyha&Ci7Aj?A7vBcMXGKsNQ696hjzF)^R7z0McRL-5@#Ey1F{A)ADUSc$6!$WZdKmZG~NH zPgB$NU7>bom<7?x66o^oy8D#5`T5b0*I?}obC(%y0m#{*ZzDV9jNwwfsz- zS32Aj;tn{)yF$;0G7X^2ljfBFyW{0ASXQW3Iu1X0$3Qnq+iXjfd+N!Z`AbpYJfRF| zA~5NE+djvXfP9cLC2=7X`%yzQCf}1YXP>W!%QazMcM$z%kZ@sZu>=9pyF+B9kG zkDl-{) zt|_exbZ@==^it{5Bn+24KA6n5MrPS9&9_2751K&tn^Vj9M@Aah*&U5Db_58{>L(5m znG7ncj+WZfzI~*u;B^wus!v;*ZGH3z@M;2coE_ss1?VliL(4%!8%N(0vo;3RX`U-t z=T{US?%pqd8Bi{~BdacD!9!d^lEMM#R16J#a7(660<7-jTb2FXLt^kkVf}O7Jvn&` z_Gy(jUJ3LOI6P*&KNK#yTg9eW-x_TbBk$hRq0}b(;{l)JQ&Ur!l;mG??mAoH;2QYo zfivBQs-_};I``a1(407X+s_y3qE-_Wh=t_ZzgvY1H1Wu)C)- zqOCF2mVIF@J7o0^cF35%v|CV=!99nF^M95Up^l|;Cz+aA_VV*%LJ49tAH8!b)Z=7P zWT}tkZ72qRdMYajKgo0Pl+x5)xf6;*qPnNW2SsAomY4^X4{E*?5ye-C1s1|` z)KIcMm`mQrpB0JJHCbfQc98xcRFt0o*?&YfNzP^JZFgTgb+*wnI9ayegh@%=9vnKq zmfZKh;ddU>DlyZfCn7L-Cq%Mjdq-UJ`qIOaTBG^!rZH8($MBn!`Q|k&AW(TUzx`N&cB|;(MI>a z*Is>pS->>okyYieg)JY*zrah$F&%Sbj=VN>dJD;i6=~j|Q zuGi^re8&XI4b=v5fV2$MDPy1@@`0Jt!lm)|o07H1i%JS_0%>Z38||FtghoT*)}a#7 ztDp7�n7LNcSSfJ=lq0*qJ1YOzStdH_DHOF{V`rsuom9nXV4k5hA@b@>MxB7J3sM zF!#I*Cq$J+p}IO{KV8Ayk8lrsFe#hJbGqN%G$80+{EqimXcwyXM3*$S+&XE<4^|R} zdvDXgU-Ei$oA*nzRLVU(j~gwgQ8L^{$F|gfPib0%pqLJxx6vt!cbIzNyly zce+B=aEYyVLbxbCJq~B_1ebhfW2XW^W#>b@A8;M0sBQgpJkF_Pkf0vT#wsSaJegXi zZ;`d=hY^fyM%1K62;)R{e47}mU6TK(=zS+r!p68R)cHlUY z_}E-soUyKesW@zx)|;^fi>{v8Mc)s{1Jvjr=MWXb09ui{z{J>o5L*gMijL$7yjUUb zuxHx-&Er4-X=@8CdJPfPfvz{&)bzy)6egSZ-619L=)|)u#7V#JBVgW(kx~p^Er^PX zz3XcWvjbWcyBLz`V1%HyY*q#V?N8eP%@{kj|8A)M{vFYZ@Ke8Y5{>jbar*k7(wQlX=#6f&q3E$X{`+nKm#3KN)&&9$PX6Ce^S>|QsrcTc}Oyjr2Z3=H7LI&(v~B-bXG zfxzXEE&kL#i`!kcv}-J8t$5Wupt21S#f4yn!s0hO`--ctP4kN1WE(mfKE@0`0fO^0 zAmA&g3H)+UJD{iz|Kq0tKgI~IF_hL}3!D&O6MWrRVnKE_u<3>W{#OI6rT@!2eqs3b z(C_5|s__3T&qhK2)$ofN{A<;|SF&dF&%T8#^1VmFI`DrC|MY<$cl@v6N2~qaYyPX% qHVkJN-S)TU+%Wv2of(E|mx1+zn~ar1At8IX^qOaN)bdoU{Qd)Of_>`% literal 0 HcmV?d00001 diff --git a/assets/images/fp/security.png b/assets/images/fp/security.png new file mode 100644 index 0000000000000000000000000000000000000000..ade1b7d54ef8f88c43addd4aa6c11b06c771fff2 GIT binary patch literal 170559 zcmbTd1yGzp(=EKXTX2_P!QEYg6M}BgMHYAW-~>y8yF+kT+yX2FmjDTF!QDNOko)Ad z``y33EA?*`#mYQ0Ju^K$-KS5-XlW|pU{YX$Kp-3yWd&^z2#F2^LJUGj1iq2;3M~Tu zVYn*4@c@Ca2><>efUQHJ6*6RSVLXR(#46(+{(oQ%H`|i3bY1+B&2;^%`F|E zo^%#a8#`x7hO^Ed20A+{Nd^N!4IT|wd8nS)QUk`icZ2;4CufK z>S<2r>*VO{A?7Q|@Q;4QfcJmD=4PP#M-xv6Ne0=!1JZ#twCLnr+@W-$T)do?JUo1K z!lGQ}LgqsJqCy;Wd^~&t+&ui;ynLKI!eRmCrJid zPfu4dZf+kRA1)t$E*EzjZeCGQQEnbSZazLvparLgpR=dAFQ>D|^MCiC0QInRw{!Kh zb8)8o+oQRKiR*m%HOX z2Dh^0hB`u>pw6BiKwIAbv~{(0@pSR9b@|_P{hy!zmjQsa)zJ9Q82_y-PEP+B!oyS1 z8<@tw7UaKe?V;=E3gy;@dboJGTS67R0WqKdosFxQygSs~)5Tra#l`X8JEiq+k?HsZ zxp;Z$SPkr)tz3LOUi_CQpbF-mP)UZr+s4Tw$jK|D%PS4Z^rW!6* zcGiCXwJGp3(3Dq=urSqh5s2#E+<|ND6b7fY|dTl@F}km$}Y)Z`FEG0Rt*38+U~zukN>BU|Mk3&EfnbV|FHT09Nojk+SA9}9V%-Btlj@z zySV>%(tDVD|DR?5f7{D{3iV%Q|8KSN|Cj9lS{O@Pb7vbUU_7}Q{?3N`ua)`dws8M{ zckCa({TGY$@8*D+`}_7k1{V169}^9A2D)|!4DgqG`6duz3b~4ctgi3UahH#$k&6HB zNzbism()+MdmJwlRdtWg5S)c65M}T|2+xYN_Jk-q+S*#3SB+l%UaM?fdq}9m6_}ly`&3%0 zN5PaA{CJx`_-A1wBaW0C7Z-Oa;J{`wFY_$$;rd|wS|CBy&e7KQ*FHi0Rc|<&VM5dw z>&bETEs(`tGRv#O!^5QHB)PC~MTY6sP9G>Ac~#Nov~W)Y`^5NoN_wi7mzRdRIuR)` z3JPi(5$SW5s4;qaJgaAR-rjRCG(R$G@?N~`>}*=;V8=%%!&fd{H@iOFS4tN33ojI7 zn_5~vX;%tpvU*{(gs-`?rzac}Mbc(MxSi$Q z3pZZfl-zT^jG0|rpvL4ei*XZ=T z)>nLF<@-3CYWcz5e``5Dp>BQ6ZJrfpYm7G=EwT0Rf;i4bNNQm)VV2i>Mp~c$?a&(S zsVC>fxkYHh?6&uLJFKM`{JkQ}@J|cXC*fE@lM9YFh)Q4WX$Rzo@Wu?IsD|TpgjQa^ zuLfkP%3Ecd^;Y7I7?IF>a|E+?9&-hm_5~`c`7NWr=MCoa)n0H(^5~=)nwj&6EqqayB_!i0y1rKYMn zV>@$q_CuJ;Bft`A$9P~*T1fkNVq#)&@MWo7C@n?4E4K@2C45L0qx|yr$+hedl*v%F zL^ctwS}YbBeziTps7I-=yR7!AM&~FXxeZfSzfm7i zsjRHAv60*Kv&;)l6Jsz>50!5C%Ti5Ebx_UVOQpEDxB-UOW-cyo$QzqWp)7;$$grnj z0(e7)7Kdu7HY?Gl%Ik`m#0_(XEA?FuztcAXGP-&8lI9U9u8sX(-{fSE5jj>2_5N_!)5#zcJp=a-+AUIB?xxGHVG?mpJ^zI){C+fk zvMtAJa7h^6(1wsyklM!Wn7JutMXVTsBZ{V$DJ``ks4AZIqAxtEMDCR=8*4ri0tbw5 znvcFJG?Js~<;tlFA@z`SB$9{UC39H)d3>zBxOSEOv}+ihhZRnXupt);hi-XNQc~*& zs?es*tIbV|;NW0u>rd?)Xi@9#qO*LNqQR1Z_dE;|65{NQ)z#SJ7qf9`504L{8R`o~ zUS3O82DJ)Gip>JTfNA@on>9D*Ys^JKN`z}w*juW(ma z1Y+<0FnV}zMt*+l@1j>U(sLuSZx;9WS=SF9njPTGA-Mx zr47!e*q#TJcYMsY%47Rv9EQE_4kwCwU+B$@&T12aT^-@LDvt#Azh3rGzE~JwPms3vN`eb5(3v-Rswc=F2(l z7=n8dyJ<4pN|?L&&3}k&tUUzfh>4f?;?J-AKORrNepXbxU`3UQ)z$i#@ez_(FG3{* z@5`yr%FZG=p60z%!NS5a<{}+5k`Izp;G>tK(QfSOa(b;fuWwLQdC$7HSyc4y-FX3A zhG%hZPTx```|oEj9j&ln|HkY$LLRd5>d`X{+oj4G3>S+o2qLMQ(3opRgb zuWn@0aO$n#=X;1G<9G|2*Mq^v?5Spi14MGV6BEkv8+82mu}zgrJeb@iP0#N1#62hv zQh?;(OIZfo)8oi^wZCemPR}+IT;Dk@J;2tA*K)}9-f-2IiULjbP8O`&dculRm6#4ovWy>z z3t!Jyv4gM#$>l;EGHE~iz{3U+n9;Q(BuNeEBOkz_lvb#s$j!zo+%KtXk24u&2;b71 zf(TMRWP?a-@#gqt4f?~sNXq#;Tj}8J<~Cc{QNY8MD|I)!FJms^f~Z($aBx*AwTKGX zx9LBrJ35DFQQ;A(tq)%q%jka2d%@7^OADE?R--&TcERHSk&N*{Oj?}Y;SY}A9L;w> zuAT+|+)4NF@W5wP#>`ZRjY|-;sovRv>MNqC(`{`uk_yY}Eg2eB-3RXT*v1sFvpZ9Y z4H_D;Tk?IN{e%1|*u{mL0`XYsXLx;q32=Aa+ng=+B9VLrwarhbcC)`Lw?UK7NI>A%-rky)=H0cjHT1#A$f&ru2z#{ZiYDOF3IdT~Bnq=!L588f<=di1b!DUx zj<@sxQFr~GDq(tVc#7T;QsOv(`tVw`F5n9l%+pzK0!fRo42fi#jnG-rwvSNM-DrjG z-7}C!$+_-euymV1FLFTBNe&{o4XY(jGemW8IF(uJOw|B&F-(!nh<@PJIsL1(W8%hHB8H#}ioRsBLHTbfgP0ZIA#SmW0nL!&pv&`&2Cb zP^`o9>Y2O=kNb750KsmMD4ZKLyik`77r`l3+ebXG7+QFDX5Z57o^kajVYs^3k540BMr;&o-bF(w zhOviH^9u(dit!MVId3bK!{Q8vKptB1Ca}Ui@g=k1=(8pij&jOGAJ6mEc3_vSVvp20 zjGD9x*dB9U@2ad8vl!x{70*+QncgZe6N7YqC47n;NUYjK-3t!qo- z5QIW8F|mTBD9Lqciqwu|S<&{JVTN@0LaYVm^l4Z$TfnCrJ~kHu7=))+jQ7IG6B81O zRY+a%ku{1Z)y(o6kCB1ij7@HK*yqKJ2*7b_it3i!{Gn!=Mr^!R)AeZkPSGb7*{zJuC5#qe_siU1|G|)SKYW5>=+rDXoxu&gr3bG5C_* zJ6C6Kk_JLr(r5~s6+y4x4>x}Gsx0KWno59frJC2?aT>a_gy^mHYM3LN3B(JMbuT~&2;b<^c}vB_TddDG*H znG9M+flC$}A0L7E)br==Phe2sx9{2*(HP=6t=Fs8>Zq3f{!6gNrlzLWvLWg~nCliN zCnwB(#b(RnOL^dD z6QTDR8J>QC?~_nS`--tv?obSliH!~`XYn#T8KMo|KikVr%)>q5qbcqQK3O_@Iz6NL zy&fKLce=W`^l*HC(et?6gM*35XH#8MQ&S|z$I;Z>EVvMSzju7>Xl7QYz`@1E5g!xN zTL;8$yiyRpc6p-a92eqDE`ol4Taw8GjWJEu!N z&^~Y*w241Z>d%32nh+*VNTh{;@Sj_9Sid~hIiZFVyKl(Nd&!ue zJq~<-))>|F&rlt0?M6|_u>@UZrfUzI6VWJSlN~pX`Bi~Ga14GbHj`bXQNjQ$Gwe12 zfz;cjqQ$6wS+XN8xpQQJc5<9{EH*#D)AM>}dz;4N88LzRJ`eZsWa}w<^K-qG9J2NB6iym58V(UT{|3b zIfkbSZMM>9F~omh0|6g=nqoVc8yIhFQKmsZhCeN7FH?g!EHDcP!i&cgcH8BiJH-V? ze6I|ld)mGv3dRAAg`PTx@r?+cL~#Z6!a0f;6F^7H?Ta;E`a>e0DvD;5I^s>&?+^eL7^E==dcP$@ocpijp5S`$2q=#>Ks_ zxj2~EAsN`%*klG@*weZH>;X>LkKo6Xd9#3;^78XyJn3I%KYrqBjr?-tAt+?AdWP|m zn`;8XgB->N`mqj&AC6+$BH1j@F|GcH{!#LHcV<&kCMX~vA=XyQvCS#S#3aJX$}1&B zFV)@Fwy@&#Bdw{a4c$;MqqjtJ9)a8bTfF#4Sbt_U=b$dN0Dzzvd zVxgBYEz2F~GH<YlqVO z-aGGZck?Ss?x9TbGw_%~trYr8l0jG$g|#(7C$k1fzkUO^CAIkM)H)>4(a{wWqF?OS zf}{=K9vvGARmn=tJXp}9>(vXC;t;B%6#n$-6T0^cPEI#rc$lb&q#!W~#lw;C8l)aP z+_H1}8|_tfPlfFWVjQ@=;bmDoZ6=6h$zaBwX9zb0x@2#^cQ&K$a=g^5IS%g5REypp zrcT9>{o@EBSZ2vLceRDnyi8t3AZcUMDCo}7PtmRLT=;-F@sdcMOmnAL(QVEZHgH?e zREx$9;u+gW!%L#p?vo_UAG4=rYB;2V^BwjwB<3M;#3fo_OMyk6`eV3%1qNNZdjxcJ z;>er8R=7+*-&6KnQ2sgT`Q2JR{Em;A@TG~Zva-5olSz=oocPBOD06-BE&m3Mjg3v6 zX?IRiiU1$q=7NfUKtNDn;MW|{FFUU2nS7wRn#T{TXfR0Zde_b9C%|MVzSnQEpIPDK zJtog^nq#NX{hFrflcPks_}*l~k;XFv@-6bP5u-iEI5Ko{1s`T_FM%Z^q8j@V9fSkOS4s;VmN*P zEK!*@LSvY8lMwx?I$KG&p`zTkuryWQVoDSnyt$#M8dPU%yY>>^u!@G|#4~l`C})cK z3VKFI&|TQgZ(#t{cM_EL>JdCR8#O2+R9-(3=CA#lM@s4$ttX3NRS#A zX*WW6<#8VJ&^EgvpMv2OHUTw!EjEgjro&T;H-Ak)tNNfpDtD2DmLmt@Jkd}O%aX7B z-HFT{u_}fh%`BP^vKn8($AP)*PG@v5&yBf!m@~Z(zGUI-?JzaMm<2LNGJ?Vu5|>%G zK$8tEM-iHXn;WkXGwPv^i3!fa=;&yl%`!O_v37-So}>q}G&deCh)_K8ptG@=n4ExD zQZi`kq4~b8E%YfkJg$rL){mZKlep0fBUd*!H?v8ZRcP(+;Sjx4 zd?_?DpZ$S(CFt6-ta9umFJgd1wkoWR(RG{8Mj?e4frAIX{gYFf8$(9P`e8_rjIA0w1T}O{n+c3sqQIHCwLSvI{ldYs5 zNPqDv@wOip{oU#w6ppuV-?Hz+>g#)V+ySH0^Xqa9@N)+hl#17SjX!tQ%ko5|&nIw8 z{h`udyk8&-*OU&pJsuv0HKtItBwsKPKITANF(c(z=^ZWevxU`SlPD^vkCKeK8bx}4Kw*)Otdp_A<6`4RL2%}Ut$t(QQp#=%&GI_KPZ~*|1 zFtYi?_h;^AI7;Z~vw6Ly4 zeF){>LMls2N@6eF+l{$MVz9Z^NK9s4m%2T&rLsMjlw{{`tgD+$`zi7&U+U!Kq|5t; zEx5F{=H&Era0h^edM&XTaC+PYJ^1?rZE=i z{MTQ=Oj)(hoP=K|tbRv}%Rs|DAi({)ktl29bnPvS{5#ApgT)2)Zhh}-Y@ieL5@EDa zcNxcVptx|Er+AbnpFNKW>2#~LE$DM*6uhK%zqiAACcJdowmQQch9T;BJ35LPv2$Ia z1GogpgV^J+yi@0*a4MptjErF`9;x5g_vvM?@bK`&UytCCz`DOpW~pna$i5jE985_| z0VN4JW|sn9)Qj@U%e$L_ItZi@%#o<901iQgFSV3tqM?BMLBjp`l}Ys9?uk}73QsKFOyW@)67G5A=iaEIIuH`lG8QZ+0E~U2>KL+pafReRS{xDo;W%E{OK1N z843TMo7T@Wd;rAmmCy#Py~$)1M!GBohKg->oM{+#$c-aj)lOUAh>2)>E!M%B1S|O) zWS-UW()2m6Gkf~=6BPXIk?f>4O#LC-mZo0+HcNSp`qxbNLHtwpGw4>teUVP{TF2#X zFpog2QCFVUfM;Q5wgTBhxw$Ka+Ye;qlofi-2-~rUt6|a(+%NG+&irZ{o_)zxURztk z6&K1vBH=AE)6+vCBBP}Rz@}f@TOY7Swo6M(b0tboSG%e{jy>=D;^H5mQ=yBG=iYo& zUK(ug#vd*l9fM)S&jXj{7H(~A^8C5L+-NW*6r7@rI}(kPo` zP}prY#OcQxP%hP4dwbS3^%2rUH5fk|c+_2=4&vo|N5Y38xY`eHgq`aWwkH`Y-Jb{-# z%OFEhL+QCgt#wLB{gnGUWToQbLNi;@RzkrR8LUOmuBK3~%T}+faE?qA-wVkR4M*IB|sMQ4DYx+y zCqX%Fp72@G{7;h?L_lf-h*jQ(5>>~>iq+h*Q~H;gOS>%`1J`izvdb;|TjYBel3#KITb>#p^_)^V@~GZCpQbe}IrUUU=J0@T-f4#WRtp>keAvc4Q6?=P zyZH+4D9{%?S>ULx1xd;&M(!Jraon)8$}i{Z>p5&%VZIBEJ$e22$o6OQ4|rWTzLBA4 zFG-2(X@g!Z;2@h6ZeQ(8v_U1Dt*_{+?UxOTyar_oxmxJ+o)2TZLX&ybJhKy}-S=F1 zmOFhnRRf2$dJ1I~-%i6+`DcHupTdW(2s<7G;7+eIy6Clcaf#00;NT!5V;5(~3PGvj z=6`N^rb#rXb1e&~f&NNK@C|y6ejJHBy0IUB zJtJyL^desb=|UPSk~a#)>~gS2d0&46q~CD3d>;04+$(Co6BED=G_}e$!424nE!EIr zMz!u!0>HKDGs&oa`GNU)BKu_0jM-$7OjUTCXh&pIzVx6|pTIFm{pu(J%d0%(toRQJ zqAdy7c$~b; zo14NqTujmUEExpu~6f$yx*E+=vu}!af)*Ai2v8=U-bRyD;n^P*y#*w2) zLk1Nc2oTXPE3>O@C)VZ}W+HjYD-&!+Mz5ouhaiO&8BuKdohj==R=h+~KeSLW_|jLb zs~c;&mwr>Qn5vam=>?0>#O^Mj!hC-SXDv$}oRhnHNxZO{mDuJL+0s=fAu?-CsshIi zDFt_be~(|SP>Tqy!g^PIifn>%Ks@TTQOEJBjBTeVb#tG(XNrfe>dmIuRvu_#g@jk0 zE$aoFzE2o6H)C>l{Fn-9rAFAnR{K7h+2AqT;NV7ui^GovvcpJaI#&?PlRr+7LPp-h zL&w0z#zTiNRZc}+IV5O*?+9x!OW<%wEJYHGtPdo>u_U7oYsrdPG!SL_z^^$>%7ar19#sdvS zG&_a5#ucl-46SbdciuMukmBq09l5#Ot=yJ5jk4aKc^lVOPj|U6U_^~wBdyh)1ah#M zJ@1WtWH}~V>=|@xEZT$%fOekcX7`w0I9hr|2bdfdvRqofCx`_z%OZx475C}f@*@~` z_Bn;4$9jr_kQaFhtyT!EHsan1lp|yzt*9}YfN*!cU$q_J7pCU1UByI1nfGty2Wl%b z8;n`Kcd|%)r&;E*zqds8te=5fn6xP+J3B6RX=Y)#Y8!|XNQj64OaosEr=W_D`N~H6 z_lWq}XCy&K2d9aN5m{?8&xbDRBFRh^I%S!VKj~(9BuDx@xg3Q~i z`M1A&AJ5Ewd{Kc=^py+JOozZRki+iVM5c&GafDfkFadwavZ$EJf;THVaT%|Wt~?WF z_?2acMUU;qbCw$1|K1ASq-lYl4Z~j0zB4ua4i_xQ-&*MWRN^i}jEoz#Iw3K*81cDo zi|3#eP3|KQ*|6ghew-IKDLD;E&4kwuN^6|vlHK1uPnAy!Q)_$gWWcZb{$Yqg4L2Xb z;BNM=K2v0H1H*y^+kp;iCV5p9H!SoTe+wnb4Gn*Z|=#xI|L7G7rR)cmA7>1?)-P zd$YF*I^Q8v44JxY^UJZgAd(FW6qNNtec_!DYJpN-&$d>J*2a&&72PS^sq<iYD-h>qXGQ7Z-1g@j<2*CsDIs4<(bmOD@JWs6z3#Drq%(M+BPL<;?#qUEft?nr zGWj-z@Vg-bBYKtZc>4IlN7f;Fc4iDbM_V7HaWQb2la&=CBj;LIR;VJ4rKE*ho7(PA zTAHl7gU7y{oL~ekt*lhn)!8&I21?~?&TH&UjE+WV%8r4nF@IfMS0ux8f#haLACUG# z?^s%*7x<#th*(%=Ze9pr3!=eT2`Gc1t?#_nL#cDAspsp=zA$M`{*<6;>F$==KR!Q) z`Q=OSUZKCR!NX|6{DS+IS_-M0=!2k`*u&SkG`Cy2yW-+v{NC<0QwVz=odQn0*JVG3 zN&50&P}3`(7U$h*%WHzDOJYtskgle#`(9M80ElE<#CXOZ?Q#ua4AO)`(%>pYhqC_V zgD%O->Gl^g$gjQV5!!U9Q*6C-bkXrf0nUr@fC47Hm<+ERn0l>Xpra>11gXXN&2#5b zMntKphTbdX_N&L$gh1GOP$yAHT+KDaDNsMN`Ev2tPakIB1+Jf-*En9M zIjZ+07_MHUd1`W#J0yNBeOTm=3w`N>!XY1hcane;?u1ldq+Rjx6M%|}x5x}&A%l@E zL!-G&+wj-V@Zy?aTBM)XmdD~Wi#Kjxx5&zd0=fE9CMNhBnhz|g?*Q5d&ab7BKYFCL zo^}-h{&wkQ?O&o|LD!2rg0P3m0-86TwQ|tjOnPV=@-`wjO9>J;|2k?NFK<}>i@D8w zp6JUP%|+kj*EmjQY%>V(u+RuG#G}7X4OU`GO&deC>^b4am1*@+gT?dckGQTZ?o2d> zTI#hMawNGjGY>D8-xE^{84KibhG*_AY&~zu{j5Xx)mNk+(Fd{0t16 z{iJ3vHa3XQ=+3MZGk4xUF(x?jmfQ?$*Q#VO%!(yM1|p&ov=!`$0aV-f1$rpN^Hl$8(`8C}da}aa2jytJqVjO)p`WvOhB)ym-tL%g%KN4mEq>Io}PG z1ulB|w8A1~idz6ykc%^`-iK+v$Y?UyyLyx^c15;?mwK!PS+nZQ$@_C*ig$};L(;#u zlYjk^SQuv|q(s8!I-}2ce40@Rs?OAO9iNau#cr4I<7cBFN-eP;U{B~ky+XAn-XE&9 z4ZKB6GdITub1WwL&rrk$2Wj)5z5Wd(aL}o>KI}j9_NrmAIJPtX!CmX~?M#N=Oq26- zq9THw?BOcc6ze2MMrSJP8-<6TlW%YD-ro5n;NZ+vVd^q-aS5^Wf4{vD-$Fi8s+tY^ zHe>JQ=l63Ujx-Vx0Y6l=uz>IG?yio5dzohSDd-;&FhMWh6W(4 zMsTHQHq_FCzO%7pdd-^BCEhO11SGslKb3$#I29ThbXH;E5ekEKbUgSuo*l}#94mc~ z6DG#tZyTx?tZ_u+7)H~DKfqENL2*1{H-!s(1wJUTB)O4g_TeisK4cGT?uM3sYIOo2 zny)DzN;G4^^+S5eZru6|#(^3UU*h^j=(_CaT002D)TTSf;M388PWT#U@gJSYf z;YC~qI6=Nh<_~*E(WoEw&hz7Tg$xlm0;17tyc|UB^m0fMVeb$lEWWr#D)8@nDmQ7d zMyO!N;UeOC>9G>APX-vjd6kWq-@y+dXU<)pWjdrVT?Yb2Y%kzm`Jxzq*2rW_GPUNpu9ta8RxE; zlWb@@pYdqy%+4|~G0_IyZ>+;X_1+)bjo#ffrGtwf9k1|@rsUEZqyv)=Nix;jVi zz5a-xf(MzQdVi{MMXVBleDqd!DyE=^QFMH5JZD_o)6?4% z)N=d`aT}8)n=o{8qX`DnQf64(i4&3#Qyqsdp(#-z!n6qAE%XA^0R>4$e~qc47Hsp9>DC9cD4&#!HJ`<%{qRy*D2`8V`^q$seJ8niJH*&+i2 z19M_wL7_D_&yO2blKm8tA92_)%@GVwN{ddYVc5mzaE|Svm_qNB9$_q;2qQEK!5vOD zb7c%TKw%-qh}5p|WTB$pm2O;ggv_lW#F4GJqZpoCJOik!93)5ZRNPkx*Dt1rQd`u} zC`r#wDak>wl;oqCD5+EDoNWd;pK=D$Wja$uxFNMj0jOs44PQWj4?5QJ#Laa5-X$N> zTuvuqnyjg}SG|aO$WDsS!kZB2O7qpFBdes(VQ<5>Ep*d)ps|UH9s#VTrdH3(i|6eM zadCFug)QRX+=`)QXp`-@E=1L)@IolS&kL?U>kwrgLUzC=}rR8yIYDT2RACqlH`U2w@T7R|kkUwJ-B15%o`wnX_z+ z^xJ*xQodSv+5F6#FYqN7>T4yfOZX|&_StVQJ0kXr6;FXB4cz^UK=;onByirz01`*C z>&Y$=l<8$SFF*#hu(X_rp7rRIuGkwVe!H^vk@XiY1Je;Gc13_#u&mQIU}V6MFLg*#{a) zdpo;|&8wKuK0p@bgM$M?Lc&^ag5?*5PH>$z%eN9dB}R|Lj;JBTBlr#CLpY6w$0!_4 z=_{urNYx#Ey+3o)XqIVrh;hdk!^-j|yy5n?w)X&rcc5E2@Frqy&6I}a4oUrJ`IV_0 zoWbJIzw$gzLSeWOwp(yQpd|gU|79k{3K0g-R`vz5E|`E^X$Cgxbn#UZXbzw_CXcK% zu@rnJ%!NlqMGaduSW5r!zxMnAVsFbxW~xYE;2E{X1wS4jJ3-@Y46smlaTzHO7i+XI z&kD{@VTk$;YGau?W#FA1k^mU)sMRHiB$4JbT_S}W|* z!ooy8XK;Ia$v4gv!FY3b0{{c~e*(z^Vee8B6Qu-1U_)>CasOtg(a=ytsaQ5IzS}&a zf&pYy;r$AU7%v)!gA*1p_O%Vozit-PDt3ilF07{hdYbKd)~!yS)+wM0Zf^K^Zn({u;u z48T5&!mUZSdiPP;BC))((q6iZu&?j^`&fVbV-TwDaM%)uzsL}jamKiUW+_k1kkorQ(wZ&5K{uLI_5 zEFiB-q=nm~&`S!;v|^Fq+?#3A>dN**z+!DB&B{te%zupf&=oqV`$_qzDD`sOC1+_W zz0USRx$HYaRcouTw6s~VJ|!Ljg?PIf z2RNl;MIXXyGdShR8BXX;m5vKQSi4gIG{KZ!g~X8tg&Tswu13;#<>^Q;ecI2Sgc!4p zMtKjx%Kk78p0rtdxy>rG--iZnZf=7i&0Ss8q?F4`-?WX59Ru5eW&fC#o{n{SH8wiR z$ImB}5IY=W=kA^~VpTb7U*?&*x|XhYb3yj*p$)|Q z^4iU*b2n|uHsljX|)Sjxu$J`(N)9lr~-WMP9LV--pST zeE=Z~D^d2*q? zV41f~2oh}=1Y*uRvzO;xTf&M)m!ouk z3Ia#I4bzTD{$0=Ud*1ce9a_os-!M^kk5AjO49kRZ0Qf$Bw>R7b{4j+yH#4JKA!VFT z4DawfNct;v!dmb?0>|X7T$CNG4YTkfOq4{tX&eE|mw=djaeD3P*#iUz2bYh`Q(IP6 z#jReyxIJJG7a;Ykw6ysJaQNw|^RlE(zEqHys3=Bl z<+eK|CB@v_obiU2_{pt~*9rm*qzA9SE{rn%&PD!4&iZ^(IqKum6qaoNj|{$g+6syI z(YvpuTV$Q+7{bGj zS7+Kl{CEBDw;-ZZ;j=&Hm4Ffs6B87@>S_)^Hw1-+NvWxC#>{>(2(u_D8K9s9cXzMX z#9X))U8#^x!fJtdi)6^S%N^=#JDfJGr}Yacdtr<0+q*hCI<)>&mb>E#&0Bd}`Cc4E zvcIQlNFcPaF5#ZkuNRS`|1BH!-F?0cLkPi}**I@ zGxBtQrKxHN&Ukx&Zm#CRZ`Lz@HHHL+MOj)}{^g!LT;E>+em0%1+iQaIv6AQZetzw+ zkH<$x;XMFqRlv&?{e6B}Tw1!v@9}nSml-!BCr7tJm+{#PZtm9VYIPH%<@xze7!0zx zxO=_*{iU+AM|kz6;+Jw1UHLncH6e>{vn6?}mA14vWqJep${x@JAYln$ zJ^$DC@4L0)*A-P&RcRXa6BBGwJs;Jb9ULerDUsqUQ&bDJSj#K>^z{bPRZ0zO z0LK_q(##|M7NE`r8LdoB{9eJMf(dvS0a^HM`Y^8Z37dyxcD7CyPOgmb+>gp|9doB> z2!tdW0j7H7A3KxVQS-N&OVQzYs0&nCPy*tf3|S9Gnp-i}wm`htm7WjRTPJ7m9GbcK zcHbTVI)aijG%bWfdDZ0s(`}=Kc0n#)1?2PF!x zdw@v#oVAYdg~Wz3^O56;fYQqqEvz|nyu z^x>NG_RRoR2GHK!>g(Cr**l-C0s@S<(t+2q`*}B$@SO)*F-&|A7ZXS#P#In>r3w?t!OAj*r_P2F%+Hn_&rh$!SjE|*r zC1PF%1qA}O@tAt)yS*R~HME*E=DhDZNDLVAkd}cbyfecgjRKJRD8Tz za94rel?;WhYJjS2oCQT#htGG#QNe(Qt26U6NaQFm3@9ksSX+5|ddd(>Kb&Xu^q2wl zB~|RlV}xjG!aSGX`aSMIbA|i8n{QmLTgjeAXAqA3Xo1R$9U#AS<(&QW^b~t}iH1i* zHtP}yKBa++IflOEW$;kFmEiEc7{Ru-PaXtJx zr*EecqhDoWWaI(apqOF_@4de-{;)5w^y}A(6ze6{iHf0k=bJ^zk&~>2KS!!cE~&Pi zV@A?|MjyAZiL^y#U3Jl;}CT3JIwR&+t!&Nd*RGZyeB zh;l?dP(MB_mgVD0^z=`KmMGrcGR}_wShRV?Y@wGk^-Z-Wj1OQsBJ~o1Y*bQ5T@Cdl zI>msRmH~W!R7`+`G}CDGvzpBk?FG9V42VcL^iKfJ5?8jy)a><)uD|_ZX&mYAz@X&h zWOL`BqpU7i$n#bc!v0ezQZ;caUevEm%v>~B&W~{Diq8$F-69Fj(W=i66;<`^3t#v4 zz_P-6fWlR%1vWJeW<{v#?lxt`*J4e%+WX48e+^XaEJy#Ok@TOLn);ZR_ORA@MkDTj zy|UN{(1DdgB+}^`YpOnkB>RH*}te* z+gLX=Hfjc5i0&T(#xqcA65^_{EVFe zlzeUwDC`lD_gpcDKqVA>cSechYT)VGnY;$nF%Jw49kNMy7>z)93pR|X8MpLJ?IUH6wS@~;yK z5D*XmZWI7`0JjxT&_hiHdneGg@oD3w`8T&tW;pl}&zmWW%T>?W>wD_;rUN-sOFVH{ z?dA5wYi#qDCRvHk=nW%P&OrQdvV2d+)en%k5(SfVokG}lW;*QcscA7C#9@R??fK<< z`XNmD;8OG*A;h%0x;jNTBBw0st9*(7LDE@8G^)ClUyNwkPhHCol zb9}R4+_PTL*LQn+8!P%Cm;2o}6dAK7p%{l3X#R`f0sSdsbxe}yCd-(?q6l zq{-OC1ScWdx2nfUyy>>qmXFqZ=Yuki^0JPn{|dTj%(V>kj-9}v=C7d3GE#OtX~GU8 zRpyhQBhu_u*(`z4+O?^O1IK85O!2EgQ}eMknmrwbUv?C0S73YwWD~) z#n#5g!N=E`&u;%Vr>Db6U*D$$#`f?<@r?tnes0F~DBqVUFh{nQf4^GQn4CEOFEY0N zbVD4-@C8&{^S-Rm_x1I6H`aYZBnxyqo@eHXoSU9jqK)IT<54IqkK*U%wutKw4SfYf z2a0u+=Fjf#c(*JftL~iFZO4_c&y!s9;|^qUov18hpU9ZXt&6yCt-jUYr_+=a&EDyg zd@3U|>52nQ(|m;jP~UY*rn2n~d%m_u(kXa7JGVWe-Tw}_l25-6Q?RPLi=STl+=*dr zKYr}$HHI_F4Yab%&ld5%JW66Lz6W+PCfVvg1<%Dg@P23ljfaVUPZR%kR9~psDPS9S zW4}I~^OgT>Tiue{_Pujs-{mH9|6rDr5t6lCK; ztQHq}^?g+9W9vt8w_teJcR}#YE#_YA5%j~!JpPp+?Q)_xVeCch2K4+VNN zbp>Iy)!40Uj^m>Jr5WhhVDtL=`htV+XNpu_AtBc2;=$xNc6b-g*~Ef_1fmZMsSmh# zgn#R@U#_z||2|PO(*F-hH?bD|#^^+F&;{zOBpgWX3YK}K zS%R1LRgLJ6lwd{~P>1ba)#dD^F^)ACgM8bMI`i@ig#p+6byzB3Fmzz zWr7?E)W{@5b$MM6t+g5kU+JPKb9gxv$6D!FA#+O~jRSL1E0*<<{01eJ zqGb7-7yd>mxSF{+iD9HRH$ErlXU*`(nD)Y!-%edN#swX{5u$@`d8ooMD#P0D7r2bV z9)q`Z@%d*mM`!1$Nl(NR@9k*bmovwIJiPC%B+vJMPfcyQZ-;79dYjTep@{218Mkxv zvUZ$%F2T&1F8wR0Nzl>C(UT+xzT6lS;+OfYfglJD9_UpeaN??-O>)$2ho_`O*cyHN zjJOftDo=1)_%25cMlc5v$ODvldyIq+^2Se-kkTHmRUpI!-s2+|x_^y?0%HPW65eUv zYm&cnQP@vo6%G>Gm^L3XmQz>W3C&%<`lAY_y@*Pm&xm>!jc6q|Jt6g>B8fYS$hyu< zsa{@F3Yf|A)Sj+TO1sk5P>g)539j`?En|nXhvj8(K$llmz?=@!E=<#S$Wb|E?wCfT z`0kf5K+qZeTwRV}dN0r>=vefzcS7`E8wkXISV2ELocWIt0Y1(O1spW|%}qr`pfX1* z@GxlL`1kQa!d`vP-rhdg{rF`Foq)y-2}((OFDH}yJwYihx!eZc61?Ud_omGl^WRlK zDLuj)A0hC{)&ysTsB@v*-rd$(!$UWA^6j1&%pc0}FvhpbYUe*rQnXudU>*OGhF-qc z*_b+cQyn$US)qLe6x$~t)(rrj0k^PGZdzW4EjLl5$L#4!6ReJD&5s{0pE7{xg;`To zI)Dy@16DoiyG$x>T|(ZcLL~6t$vEad5Qx7_o~5~YJs0mlfA9U{-+)S7lo0r1JTgt9 z_0QnI9%E6F8RzrfzQ580qm1PUmcE0ih90F(ZrX3Yi#{jp#krr3d(4#CVkkowl%0+; zLiPTpy`pjQ=B>IjTE1R+A5%fUlRARF8wu6F4*)aBM89ODr9H5Mn>@6mtg%u1#|QMA z8~o==9$sGXx(|U1XwD5;r+rUD(>o9w6Vp;;Tlkn?GZsb$y|fdAo8Oi-dEXNzJ8{nb z+?p zffhtkQWC)d{(NJ$7tBa9le|pwCv?B&Ib{oG$pUv_aMBzoCkZJl@VqpXD#6ntZbh<< z?I%BE=)Lw89&<9RZJ1czJS-}=AJA{W^^rI|4GfFpgW-Xq+}z(k>D{etQ3ce7cEL+N z^#PBWxy05sw~TM@zcDl>1|v2?U%o8NPhA371h1va;OVHjgoSXy80}c|Ztsv7SjsiB* zH^;lLKHFVz+Lh&T73NTii(l4Asz}w zWtji{Syoq&BJT|OLidxs_fCHaP)vYhEUWKS2SEou90UhrT$)oFCK9;*JfFW+eAm8J zYDc?sz|aNMldT@(Eyz+jjFuRkhIqgbLqQJXT0LM2IekGXz-_w$4FO;b4k}Tk8mb$g zy`hY>zCEMDgm^a+Fi+AsrqlqlWE7`xlSb~0hjbZO9fa)VslU}!D#%S^%Zy+Zg=&(|a7HDG!+}pvMXFgFS2K=pQL_)Z($wCu=^e}Ds)1jpOg?8*XXig>nSy|!B9r&$ zzRketlkfE`a4*M{VHxS^SzdKxI~`r|ELNH>t=oN`rjV|v6?S)yT1R+h`)tu zj=Jw511M)1a`W@2rlkR#o|j4XFA^2J?62$73W21jr?R5=8~5+Cl~h$#l~oE03dhGs z+nlEVC}kV^gwO9jo>}$-@7I{&_!Dc>XQ+RHc3G84=NAjd!)RXP^P6i3=`EMve%ybS z<|a(}r^3N%mhW}lT)O|AMsh<$AN*B4B^jp&-uQ&u<`k| z;+E*nQU-=DML|-iUP2@08yQ(yL7CS^Mw$Hl{GrAq8;RO^ur1F=DV+%Jdbx~&>H>m- zeh$B*Vj?6|a8ab~?N7}V#W&Yf*w0o|fBYz>V?~lRZvN~I5o;o2bUBOo&E$zpBRNVm z&$7yFOB!P)KZ9VSZzfs|iM?`_mSI91-?&o&7hx)8g{lY;hRLS6m(}BYE97O9ojL(a z!Ohx7?Hy zKeb$Jffsp17(NIk#Pr#BMKTZ@B&(JKrvTKGye};Q2rI7TO5d^s4DC7;_{}Z}IczGL zUaPFFW>G7`;lxUnngIDBR(Y?e(Rlf236t3v>@0%juk}5Jm!JP|GgdMi=#I^*H$f0W zZT~-Z|5?@G#S7>F=;-mM{)ik-c7M}AK%elRtF5gf6F!KsEp-eF#v~5qA6i=z9v%W% z2GGei-trnMBJI*941t&b@W@EBp@XX{XQoW6)5~Z7&acwme?w3SRI>Quu*gBt8;HgH zchf<{D}wF;zgo5<76da{9aXj%p5%5Z3RXW$N9tfOM-78#30x@D0LTzvOuSIE|M~?= zSd9eA-4IkCv#-)Ca!SoRK+*Tu8Ws6Fs)oX9RQ$0amVs6qQ`SCY7p=IPd7#EzypLp+ z9tKq`oY;yBQ-kbz_FDL0W9bC3 z926%`z67zXob7yhesCXXF>Y&j5Qk6%wl-d-z-93ST(iJy z1ue{gfPkWjfeNR0Yb}mM3NjqEiOeOQ(hC^nt)(4=Z@oTk0D+5_}a$hNdDl0)qZMP5!BaNhwFn2pf4ZqQ6j{ zIGb8ZK;^l(C~FP7-JeV!6m@Zl93s|v;Uk8zY=C@TqQ(7dH{y0GEp_F(5H_%BYiZ7+ zqKED~<6$3!^*GA?Eezu-xW|=kTw|961fWN6uYmXA3R6va5C{yw9-VpEk;S3s{%B%f zr1Frz-pGY!&%6M>RZu{)P-*mhQa1t8#=E}B4)19bqr~3bgD)ADmXQ%D-4TdA`XhpN zltGijn}OoF20MI4E^36YQ|4-PxB{6f40LkxD#pgfJmhct*omSG=Nt1iY!4o|N6-xz zI`{mt>3~c;^ks#&{u*B%(F7EZY75Xo&`A0S<7X>P1O>u>@3io7PB2c}g>*K)ecpqmjkc);f9wcLuT=i`GZo}??XLR~WR>Xj^;w?6oOMEo zXkw2E8i>_%q@_}Ej;t%lngpNYJldK8!}O$GpgH}i9@Jf3_%pJy9FSB(5|Bf>RYhJF z7Y2|nYVKmltqQ=2`o00FHUr+%8HRzOot=+9QO@LjH4q84rTah+*jdcL_Bi&-eGmD+ z$4(IN0Nwhtvb^@piS5k|m-G+0n()4Ea$64Y5BM}5PVafmKL-iQHb76=w@0Yr2|hiP>4Zj_>0ew@H) zrlXv^@Dz_*v0Un5k zRQ=x~_=VZdymk20mzPSJun@k+pQW!wtgvY`@l$HDwA=b~{oNiZCxodBN>U7`>)#1x zTrm<7dY&HC$Qm-JmiI$IC!or(kLP$g@}8#zVr$pO7GBzl`3}aaif{tD7-Jeq_!Xq+ zv+3OCPceCH|Av&yUU@)|gMOv;3r=RN}Y0K^60JOS~EMBgxz@>^xxcD{5kwI6g70Hp1hF zOV$4JszdkRy-5-w`i~1%k^^xu4eT@R>+N-FUfp#Jov`~^_SYK#N)%jN^awvN;RE#0 zKrDH45bbKa>w8hwrsk6Ho=s{RTFd;RNNM0JNHdycg8O;>@%Nodrcn3Js9G5H8JBL`y|Gu5ekNYVZX|jNU5uNc2+II9FazVp1<8V#{!c8j#X5 zQXD>iuOlpF|BKZxf$`=Pk+m$6jD& zSj)d|l;9wgq6CVS`6|rDU|BgXG6I+?LFVY)AbcVsHcxx+#>vqQK~NB6{y&)po{&EAISlpkv78F``Pz-+;4 z% zLkDyG3T6anXl?g!Do++TiJB-OLlCj_A4+?(JJhrG4j#8td0~&q(XFxBJ}@J7?K%E< z6Y+$mzgDmdyXgIQEp~Rk?2nVi$!QMl!u@c1QH>?HnmqiKal=_&UY=i27%1)JJl?%zYL1nIBQfs91JdUI^B!VhIzq#eU5)Jd%l_N&>^okUF#YVYM zFS&kQDJKzMIwxS{w-P(Y9oPMV=3woIQ#=?iHhNP1lZ@SXx>Ef^B;K{aA1cGsWx%+E zL?62rTQ&KY-pd2ZpD64lKAk=WE5ti_c!>at9VrcvPC%)kqM`ytQH~PaT3^r~IVa{N zIy$}^+irNwS)jT8|IhLyoOp=xXNz*CB(oO$%>u<3xa5?Y*69j^CJ;7f;R4g&{;}`Q zpn)C!$gtBQsJu8hu%IyjB0_|GcNA#yysO*X-*Qnc z3=FssLHMhXP-6>q*IpCK2IPc3#0|%JuSlkp+=vkl#Dk{##k(hz;i&h7B!v{+$5|8- zI-cGCJ;tTncZZYy%VvR&g}jPFRBU9>?D*)Ym@BK%uZ!_GDxE6h%=Gk?u&2>=-;@9H zG~KYtPLP=8Nvml>h%ZUG>;AZ&$$WpU+2pNXY{8}+sT77Q%Z;tOzT(9;(OG+MHg1KKE z1Q;1GhzZGF86&(xNMui?4YCzuH#Ewds@5y7<)GC?*hfP}buVi`27Y=%Li}&ml}lgphkixK{rY2z3Te{%{Vx=@r+5lwR9Wsn;UKLT5m;%DjX29 z0e3V$jwaH|Uj(S~lJrSa7N$2R_^qz1EKtgwn(D%51s`Xw4+xpmhP{BR137YPrG*>B z6ZxwIDP!)*!6!V{x1`Tfj47Xb(({EGNhqhGv-b7%)i9+j`$-9GeuaW=7r*O+shwUa zL%S1TahN43&{S21BCak?!J_hU(}bwxol5qP5)@v*;D7wFT>E#2-QyB^VOI&y)ZMeT z!)U8=hKTsC6eN9pAKZ>+={0M7d8of*G3-rGWB*aTs(H-H$^wTdEHyDcqc>-!sIaiM zj^l$yytw{-Qb6Tz-#a6TJg?joK5B z^xnQ3+lWwCigOg6;U)%Tt|?+Xo07Y1{NX2Q*ezyQ}Z zW;{a2pD!6qM$WWAof+FbsssQ@DGp8-9MKBxH&6Kv2VP#fy58P|ZvTK5(Z3IZ93T<& z+37~9XAVgf*!i`H_%-(YXs>po?MlPT8mv~3pc1YYWPyW6OcL=m36D#hR(2$m85tSn zb;C%-%RuvhmFUvNMnOy^JOqv`a6y473xsh14>SRc2<;NJr-Lw2J8Orm^z_H4x(TSk z29IX~eT`gV#t*NZ!MJn3b6*Q3+OWRbJ2Z$Imm~?#O0^ZMu&!KB6L|}r5`1Ej*phz! zS$&FT{go#~4;1l4Fjdj%%=@(D{t5;Ul#`hZ#c_k_O-07yeuvY&%HgrNeW~&&dn}Io zGAeX*)dN4*-0RJE%?8N~L|X}g_BRGB0X055GP)WC*ff@BGajG1xq!Ht3eMFdpmhUP z6*O1CJzssA(*^{vpW3`UTsefu$QPhJAoBHW6}aua0s;)fzx&2dl$nv5?8Z^ibwQd( zu_S~Hx@-mg$$dRV^f;C$zTB~RwNz&Xz-+YErlyoM{HZE=|7k7xGlzLpRKT{@^Y0Xe zT7bNJYwIImtt}?5E7iI-)q6iSPK>30QfO;$FTqs+hU_VhgWBxTvi@Y!pXE6)XTX#* z%L0(cV>k{hh@P8`(!k`{S;IHvPTXo?aQn0XV_ga70G|$2Qw**xoa>jcdC@Cl~+x!j#b z_GZT&Y6bd@)u0MHgYC5?{Ue*+jeaoYUX4*xc3l;V7*H2u%;XT`j8@N)A4;<(1rnR* z`<~Ya>dl57jV)rh~6|;W4hql@2>41_2EZoc6+dy3)8=MX6-s25M>FDVhYMQ&S z1$Bw_)D!##b?w}&pA_$Dw+PRbHcJ3eyphiWr)&uewGAd64B%qejY@Gr!rvKfm9`iv zt<>!@YKje*nmq+RLzQz(Ko`$|PcHX$c`hW3~jA7Y! zOD=T4oSF^ei*E%1kt`5408xuR(Wf5K3?b(&aK$>;um=UfH!cQpF>q5;-_L9h&|u4Z z>w(Mt+cAgt`39Wn8}*z2ek6M(pvFuaf4XFduKT;$EfN;3g0DFpfv5qex*j9esc&Ea z6Adj9mq1opMy2yz+4o#?8(SNgkm@tYAq_2UOl+)y6;mQ+SdaJPU>u+l_4P@^s{nd3 z$f1nK#I)~Nxg5uRfKe>N>~m;q!`AowhRN_)Fxw4a+Q(5LW$>ln+;bS0W$UPKps2*H z9ng5bb0DnUYx>Hy9>%5cWvbG4V(n-q`H$kjvtg8x|XnE$md zzUT}xROFr;N@R(adv>)~8?pTqtezab+8l zDeOA$F09*sc-#L9Egu+%1d0tgJYW=ne|`pBM?53C)O-L}-VPAm2B4u3-_fBV3{+G_ zCAn`g5tQ==21Z5zHST-TA<=SmPy&7`NC+QVto>SU?63Xdis9Ho615Ap=RnBKGon#! z5|0ZdNjSi0?Cfn%++e&>Vvwygha2k2jvO&S|H_y0>|&^I-`Fau9{aRicdY_f3J8IL zHDWriNt(@O$c$ihrRXByEEr#~qmsHmbe&u?(=pDw<=Ry+{YK-PX|Bbq2@lU;%eWUL zKRN8Wq#lt64D>0`|5?Ajz5Vki;4S$1>>4xyf6dtM22Y4U!Ma58s`+UHbY}qa{D&dd z5(xYvRo}V>k@QR_fxJ0_uAr2Q=ONZ6h1^7zFfl1%z+O2M>quD{t5MsJ_zWQqp{GH# zB(d*&{#xp}#5Aj`J6hWKJNuaE7%Z%;oT*Bwnn#Hg>Me~U^#0OrHU2eXa-}8igDND7 zGCA>|O{IAi=7e-@`*n|&n1R|!ZG<(3TO&9iEs2_g6Q80EQGm4g-q zqAA?sD1nubX03y@P3fR37!E^>rTGx%iqby!J2Ha)aQ^~goRh5H_IE2@V!)WDt_(bA zl?VmM+Q<>wt^TVW<=lcK;3a|gWJIQJ(crMwe^Oy+Fd7D$SMi|U>n-e!^Vm+H<_5sR zQsz$Hu8a6RaEY>>Kg^XmzC0{|m-zVR3U^4E%_#@H>Ab0-+hRhd- z>ewkPeJ0nH1xh6arP`X!ulxX6<1-M=h=;-k03O#jf8-UFPmhl|S(*$K6)6L9^l3SJ z75b2n7r^Y!FgyZimvtoL_oV_>u=tyv0004JM*lwhSW==ao5~i@Y=~p=;G(MEHyXxw ze+a0&Fwp#*Cj8~kdP}fvixc+7H@j=?#{A#enpupt2*z(OFWlGXc-<_VS}0}E{w$w6 zU*<%@pb|Iv#-sHgrAkZ@?qjhLO;pM>6P_cOVxtOKDH8YgME+`U%U%AgaY2DlPRZeI zV>1jdGp+#M}5W`1ky6RflhM~%XY!+@BFh=hoE|0pdZ1yTfOk`9>Wr&gLma*LIm z&S1_$w&f_%ID{>KUY#zrQNR2|I-(z@%;Wq)CrJHgVxrTM9mrUL`Gu!n^{X|kBCi^s zsL9Z7sjY2MQK30_`7!}Y640#=nd*xwLm{Ll_C`RBH7FbF}DZr3U3U2k1nJrb(}e4 z#mi%q=qO+i|8c$E^?!cqAgo3%S3@dx_zE-fqef{9()C4UzKS-On7y21N3{|P`pYC= z5a(y3+0Hy{K_K^v?=>3MK5^yWyIUK;60bvESSHgmVE4R{J zxA9~`-X8D#5!GFr!o6DI@ONP5-zQGN>pr#tJ~jcJzTB|(RWyS}PBJ0SB2Rm}Fg|Qq zbF=sRSV~NY@IHTan;~<;>(Ww?Vg=yc95hKuiT;6p$V;wQl0w1jqOJSOS`JbpLgpJ} z8i14~B_s3Tvukf_c_1LqTt$VXdOjVzEvp=WGgGd}v%v`vj-1Qf)a(!~S#8Qeqf_(u zEYHQv*eO=LPXj5i49)Um(c@UFA(q1L6x?8l{yYMLVr34do-yg>=?632bJ1@Qyx)=3 zfqXHtK8F?4v+kyAlynrHW%w}!4g|44nuu=nN*?jgiA|1q))#3x1Lz+%nB?p#$FC;Y zVbK}!!1|^upaB5xpLstisVI}PW0`D(L1GhZA)y7{a&!z_^)2&+%B!wLPHY+; zMpHSf+8=Cmbq|ULV)ys11X71i^(O+b!>wA+1NpgSymd^F9e z%YJrOuE(RGJUu_zbjUv@??;C{lFmINy1Rs#OQwkPBf)$978dAh^z(ZgC^ zzCp=SLdP_Yj-4VGD0h9PAe9Ju?JH!>v%ipzC;pvGEGLtA&sj%5$GM3MDTbEXbij-> zMcoK}$+h83M^Yd8`L=rzgaXb}5sutuK87nUgz?chJ}V<7&gO*$w3HHp`-@9!qkrgwyT`8?OVjQSS_ zY>aPWXK#NRv%x(*R~a{7PSu#5cU)m;%D=->ii%w^ z<*ll${Qc{TFs0CEGczi{{;UbnAyru`!@TwWh6T6jF!C4l1DB>>b-TKX!lH(9d*NyT z{v}Wj#s75aR>Pf6m-wyZ)B%twwsMNdsw=v|dGMyjS3$s98{Gj#1IDrO(QkcQZL5aH z76r|ex!?cirT6uO6}ly5B+kyvT;2Zxakw)wewUq0&)?#40+T_A(6kQwJ0=nZKSu;3 zm~U~a<%OuT;2ZCqGO_TYs|*hwYpy?#SvL2E(n)VyIS%jH`}vT+IgA?>Oq=UYV)c;D z4Var_aV5~ISw+0r3tSEfP+R?P{7G5$0gLHz_zTfuMc`di$0yfL`kK9LebpZT+z^wn+v-L zs+{2wwHzm5TVP;BEiDDDH_z)12D_razKr0E969CV?;%i<>R|8#QGZ6Hlr3%6%7g17Gt|%#CkMS%ZCd7@z z!NEpu0kyY}E-uq1FMTGTFS?LIxvNi4yIMM*t3M8PV9avkVh}p z(;qQtXDSSnGZ3`m<)|-(ML!@-e_>I+rwq0B7XUtPc(dpujIKZ|mNcgqV!ti5^-nutEVtMK1!K06)K%1OhC9WyCb44BV5XegCh8WWPb8G?=oC^ z>D$nS%K30DY4!BXv|ZGfLy$6heThekr&TmZ6#G`<*_=bqPD$x}!R>~Qp8hcQ-+e5I z;-SR3LD3^&n1pIU8py+15v6l)FnW^lPmg4{O) z2Zq+@-SBX6XJ=>4C3Ha2O^B(yvnn>HY-h)Oa?ba>ec|_ShlA&C$B&82sJfnHOHIWo zE;hnO#jxKpR2klB>xJ^ybXI*{c@M+YZAaZN@7xfud9=*pJH+pgzFE+S?TmYA*_ zQDB=ham^MSW9pBb&RE?5Y2&X!HAbEHcc*t3?~~wZse2+rmF=#V9%M*fI-hpAzz7VJH8d!s^K4NDQJ+hDsFMb_!+eaYkHa?C~rY z%#c82;D&)DqZ9kSn_Xj9IKp%kZFIgJB3dqtxDg$14uu0}Mn7+W1Q*^fR5|`-VuRuD z_me#Au@TmblMIS9@m28ABIHBQKmGg*gs(vty#-}AtRM_?lE$E4Ra_3d7Wzl?SN`tE zD=Uxfj--TVF-&UN*c^eKX_=nuehWK;!T0xI*B31O91FC2|98Ww(N>WrFJYMAKzex7 z8@|A_z?5JJ6Es5lE0ZQkd@1_eSh6^821?SK$)J&soM#W+6VA-DhKGaL>}j{$kee~x zSbr1^cD?Q@OCPE@Dp~h;uLR<}7ug&QUq_fDM?a2#{Cyuc{Osn!wPy&0bLjSAzgK)S zrPif;?j;Ltq<)L)nq^s9 zdC#;+LV>vf=tMjJT?wUA^Yh7xKiC}72L$5YO)gX#D=UC)G&U_?|GfasDy(N{e4L1c zMCuT92SA*JhL$?NF#idt%NI9)V1sLxn2-ur_!yNJXYl^j!Y2RTJha8TVx(KyE;c+p zu~cIp$k4%Vj>!AMzK?wgv6nQKRQLr#fV2;Yr|=Q5-B3md0UHn|$;O7r76RQ*SSSy) zykfurHV8umUu9P+zhQ0qDaddJV}+pYTc_2QYwX{FcrAO{yO3l|UW=;i+&e6K7(Sw+OI#OuaZ8zg`FP`dawQMeUiy`rX(uMCK2l*Qq~~u0wE`Ur{gOpOjpyXXjDlj@9<||m#v?Nqh`fC>>-bV~(Ia@j{mi!ncUefH= z%Fbb&CEd<|H~q$GCd!b51B;p}F1|SmUdXRjDL!A+{Ijoe!lGbk@OV+lYWu77IcA*v z`0tA-2^zOtSt$+4+v-2QMZhYZC_$(1|a%b>rhIn9_Re%LrOpK+g3%TdkRrpJ%&$58&56 z!Ry_P>1i3kAB}*Z&BU|;1E&114>Q>>E1fU4x}T8U2F&rVMT-1T1s=L#@vnc@R}NG! zvcV`ef|Ubgh`6<*Jz~(o%1^`r5dk#-^2@L+%dFDUr9$WEQV8b769%y_y`A3nftZ@BJ3l=QaN+83LP)C|GMwCy$l?I{zm{_>`;(cu@&=YGNFw z6(NmiprD~q<3lMzufFF<-|s&=PJ^vF{t9)RoWR=rZ}%LQ%OXjMW($Bm*}+OI9UUM4 z1JUiq!LA$}I_>a6~_ z`nI}MFc{%)%E1zfB3BZ3gru_`s27d~`z$?pmJ)f9X#YIyHb94e1z^}v?{Db%h`-G> zjZIBiU*^YGU*SVh;C^o+@|+B?^I;DJ;QH`a!t^-WaerTBW>(U9}3U0jSMSboa3v`ZiouSP1t&~&W^Fj!2ItClPKxYcj zu*v~TZC_)T_p#ZMoS}K0?CIt4oS17cVH7Yr=^2>nQ7fX5@R`p}&d&kXD!xO=@8JN6 z{At(Z3DK?tfc@b+mjDG4WN_Jg=?(@q%8yW>fhb_%WB@;mt{5Z8pWo`j7FNOY9@rm~ zq&nE}UZ<_|);abe_5r;*Pg$X&G-T3bf~nzmS(tBtgU>z)f4hzFpd#&Eba|EN?879> zj9F@Vfw=kFT5oVm<9xq+)$4W+YMha}y1eZM9TOV3j)A`ZFV~x4omYaLuE1y&UPlXG zZT0p1TR!B16?^FXC zNBptKv=*D+WtIR&{2C)S|C{_*4?+gMdnLmd@5K;Dzv@w&T@@Wz`<+3e9_!C+_=B{m zMN(NN%^Oxi9K}BjLtK1z)ztOA&0*U|EkG8qC@%LBCSc5Hs>^z;we<5o3g%!U9Nj3w zoocGB6;YohowsqzkqgKT#{Go|(b88CGNzfh2)H{{=~=J3)71X50b8E= zSm`BXOp$u>Ga)u6Dk>&M;zy-P>+MzcKf9SMEmWh#lbiQ`@-UI}ld>hp?34bku#rC` z^9^Fl&CrN((S1;ky>;ZfVcAdsGa7`eC`NnJZsXUqi#+EGGYrE%4ujQ@W<%eRxL)zd zSdAz1fW30n%~L2_h=U2d#IFcIpp-UJ*yQ3Ga)?uqj{w=ZK;a1mi$`z!kEXiM(;HT zbZHE$NYX@`1E+-Km?X;6Bj2n2dr+7pcw-IjSLAZ3719qZ@_Qv2+ywU$9M7JD4E1L+1hF+I&W1Q}tTi1`oaOnkA5iSYtT`v1kv4_W~>k^3JGG1+di&Uhz-V z{ZRG#JtI|b>Gd__)V!&op)t_JXq?Ny07NnMqiF$quHSlxMftJXWgHbr7janIXU2as zdmL=v62c{4j^L0duz9BoMtb6))eW|__;*ifK&~jaK;C0rc*U{e`-$8?jzz4lEw$Vx zsLTGur0v*ITn9)sFf?h=O!DoUmYE__znaL(d(d>-*Mz}}#iea;|4$4_C{lB?v()(E z0K`87HqnC23eJ|Ep&?U}9QM{WXlDY}xp)fzF#%r=13vkz*-p5&rTmhX{VQdo#8##v zRf&ENoe*UPY&izoyx{LQ*`WncqNzR_orb@AoQzo}rrxan7WVkLW6#6i1Hs-NwO53a zMu5>B0xKzp&VaEPx4?;b5y653mb3m6WSg&Ke|O6fiM8t?QUde0YZt0<26oZx>_WhE@wdSip30uPW%mX{$9YBi_mhj`d7)*k5XQDGw5?O^;lHhwxh@KKy zh&PG2VzhjhHAxNL@9=Ie@28WG1#65!La#pQQ_Jv*j3KPMiQ7*nNGA>9>m( zt8bH(keh41Mv)wOxMu)%GI`k|pxXzS@4(8AX;zCtuI3B{i@60BXvLB2fULiLN(T(jR8$%T`DlvLMTT1t%Dw4>xMShLkL#k z(BAe`3);Qyj(o#`7$d*Mkc0iR>n|v=9K$d+8cI~FyiGzP194LT#Vl@=@>}T3OyM?t z&yk!%?(1$BCuQr8=bm#27BcWU`VeFOBYcHaai{MMGvX5{7Gwyv-rW6dQICr=%gaOh z@)*Q&*6ULPgW6A+XARY*$wb!0ngr_4i6)zNxkzOcd@f(O^^u6TK=x}J$*Qt#ZvP0t zbD%s7EF+}ZP(czHos7uIRD}Fjmy_yP4+2ALX{Y?@|E@$Y2<>&8K5)klS;g+YtPStGr z2k!x@3t-<4&?*EM0jB95)Cu|gbTr-xk><*=G zGvv1rhD@+FfFR$~b^i<4kjeGTB;g+i-_1Z~9Q@}reS)nw-=iS`n1SFR%7G_02Mgmj zU5Zo^Fk};9W8>m-@$kr84{x7`T>uP66aZ2fL8FjA!D|yH&RQ)fc#8f$D^I21= zJpQJ=ZM=d?<)n+_t$TkcK0BEwXY89HEZVD%LPpAqU~fL*_YV-Dv7x!+NE4~-`tDEW zB=o~pes2Po!=$&{?!1U@lD1$O10ypD`0GgkHPs5h92o3%&NWG<*&FJ_51)*m8sUHos zU@6_zW1nx_?9-7O<#;^*!q6H}$YFH*t=-*|K-REd>hbTxPbf&#zi#Q?oo#5)(s~kx z!=Hw>SXe9UFx;=tzB3ZV*9l1BOzf6y-)OcZRa$^e9!hLM_QB&q8h!JDg?%y!tSnxh zjJ#^CL}IM3pJqdn7Vu$=W0X}<%c?H7yL%Q07S^2@BdibB7Rr0h(hH^yAF~9WGg)Hi z-%y8!j74A1bFwX!ast$9F&$88+ZOgkVoHR`AKqX>Yz|i2V@x~cKyaouk3kMYK2H9o z1W&q(^xpHENJWhaL3kK_pccA7edN)%8;9`4{LodnYCBIlXYjWTtjSDmZEdjkhmxur zTmV5qfq;$%#C`3uxldex3<@}~o~Lo#eHi`?e=depLb2qRY`z5{X8p?2^5IM&1KA$~ z8{vcS6}V)FpAI2h8N--)7a(Ru>0ZQgnejyuakRo=daLuVj_$- zIz!$}HPCqCs)u}AIUM&dFi0!3hMG4{0r=uKLzHH&vzcjWOPz*PCV5K>c*Ov9O2R-A zJ+s1J<9Len1`D>P_!OFCX$HD04tew2XKo*B``r84DgLaODi=`%)+NA2iy-L&-7%{# ztMgU)+1Yzvj2X!9$I9;`j)tusGb@a=v@KOto(>KwbhsRE(TJjHlN3&kOx=sf%Bwtd z`DJyA>epsNjekfMqk_6Op@cHnh^F?2*d3vY4g{E_qbv}s-??EhjoP)9L1f+U$nwH! z@c9Q&y0#DazM<@BJ%AVS+AHJ~NfOx<`2=JkgVBf{n@Cll3Uw&D{pvEF-ArJ~8-`85 zM_wg!4sQr#17b#FXJ-c*#TAv6WM0<4=&A)b#UQowRlZ;$aBufAM#3M~A{hKPCb(V* z@Nv~{^26Gbb7Mj>X*u&g=Ja%|Uyxgq+021b-8fQyWn^6ET05@vmzFaX1IicQ$y z%@#lvHreweJtB(*wuZ?D{OqgY|J^9qys$90w0H#E6@O>&Qa{6*aS#QD>x-j}4S+7W z58vnEK_!m#d?Bqg@bK^ASzvl?Ni0aiU{NKCGTc6ES9yI3&{#LH=Zf!`@V9WD0TM2m z5v|7*vsjR5_MP=2osM3;YmJ`kY4 z>3-{?ohX_D2ZGb&{uY#!DzHpFYStiJzoDi1XD@w zP>FW7!+#>hW8wbNY#;$%^tF>y zPW2_7%*~~k@K=7}mne=PeV1isZa97qT4WA(pPU|Crf|~7&wB%>bCWE%Fk1jz?KK#e zqRf5?5>zAi2Wo=R0?Ma7@B@^{nzjy~NKLQNu`S^kLE~@vtJ0en1({^G%0HKTL8qt) zR3IAhv5=|>EM5el6=U~=@XIY0u&@*aA55i5L6VOPmoC*{O{&s*eI$Zr-mf|e_ISEL zkp;0FY#_a9;C=!tuK@-xgi}mOK~WJ2326&uaUg-c|%*lHA7RG%FoS87QL%Pevfz(x^HRQ4y+PXlsJ z7vFgNtRU8E*WrIO3zW`ReTZKa2#OPap_q>@_Mxz4QrWZVRk4{&X=tu|l+fXWveYel zyuWK~uCevS{56EB}2i;?u6NxPDi5vi-YGYPy;O7 z#1F@n80juQU{P=WF3**1A|-+n*XHS|J=t=^-4oVk6RM~I$`TeH9-{bC7z#YFSqO~{ z4RJNKG6mcfO4P2euhmL4Uj?0&FN+8Xjpoc)XjrRydfM11xVdRs$qob|-Q_wrx}8oI z&jS2ht3bP9qNSA;2zq)5qrL0fzq)8DtGhbd9igYE_ty#6jUpx_CwA4gv^*1X33-eu z+x~b)TCFz0{OX_E+iIYpgMAEiH|@#&DEp|1CXZ%>5y);ynkCe~5Z+-M(Y`V=l4nhh zVcOKRhU0!WN*bY_mkpOX7#A5v02>M7qGCOE^1_!&QE0%a9z84tn{p*|YHN0pDb*Ur z^7!##Y{TTvFq@j}KX0DGF?~|;)*~!Wn@vpI*x2ZnxSX9$R4BP_`O+RSA^WOdMivpS z3qYF4ao-~M48iLH%5Q#55)vr5dhKJbzIX?~+M1c=y%RNI!X6`$GS$+grtUo#;22z? zHxGKr&i1<{)VD~{#?!>+iPSPQbbEei003&R#^Gp39^9#v-91G`MZ`zP!0CcTvT0bZ zxvBy??3c>H(EBzHJhn8#5lru7OHdx5qJcRWRJmw%n+m*{9R z&j0-qqf-7KM`sllW!HvLhVGJX5CQ3y?gl9lh8}4F>5@)K1*E&BQ@T5)8$qSJyZ`NMO}Wynfm}&_WpXOw+0@HE2IS=2ZE^3-r!ikIt4p! z>KWXekP{sdjB}KZZ^FYoSj#8<B%&4iYBo!GIZt^`F|T7fw=Qwu3R4= zZ49ut0XE=cU20BO7r^&tio2^C>f0ROb~Vb%hEV%>U@E=g=7#TvYe2fYj|`Ubmd(?w z9vB}dCVs2@md%vA+(jKC5Bn|Z7Q`#e6BnD=K7F$_U8u&wJgk@>2$E$iAj3fjd6z2+ zN}|9JRzT0l*gK#W6}`Q^*><^=b`$Beur6)T{CxB3qN~J;oOZr8g?bkb7EsYi(P+Nh zVr#qDko_yY8Z~`5mY<~M*|gB*LOY;_54_Sx3CtsE-<*>SB`5)?&;3LKZ7BdfNy^&N z*{V69F{Tfr*bil9A%u9n=FVf8y^v!HK{=7)@xOn&I{%OA(+Adlf294>5sr?F^UKTY z^ZUZ*dq40GT<@v)4PaJknF0`uiScm`e*S)g-=N*vF5tjx_JH~9j6Y>$*QweW9^DZn!KMuppF@%r(C3Kcdvn!5vT zmF>F0MH(OkQgGEsFN{|;=Gh!&t=Q+xUR0kI@GIU$x7 zA8mTtwYkTn`t1B%N;)u&j2sOMr1G0RH;2c4@7~SODSh0%xX@CEbq-Mb(8ns+azNB& zKYUmPMy+>xdfc3x4xss&eo}7yoZ4f8R}FcH3lj2GAL#*Etb;FrD`|SV(#wl#2cF_?kNa`Pn%iKw}&s~ zVMKSgH`&Bg#(y|IxW^!1-ZG9Wk4HDopNz<_;V*=#6+ zm=FjXIq*6+9hzHOuBfXpRgbp(M(3${-TS*kb&P#LpYd{$>bqX~kLlfh(zMJ}__>F> z`3^C+gB?IX$Sy&LCmV%f5OHS`~FR^X)fl8021)j=N)HW7Ll) zq487Sb8;j#B_WxCmC-m3qa<$~pmKU-9-IFKU#LX%M!3 z@ZP66^a6|&{kEf@!c_BCTzMg1{0~kY9e>LmT{U7L2l-y?p!hwz`vEi+*c=1rHV6w6 z0G;vm&}zR1s+CSjX=!8xdMGkV7qsK%c09n`%X^VOozaW~5t!-0q~j(ru?c8${NEOu z{xoje$$C}HxDW_q-8+vwA<0bxy}n-=`yd9JRB^M)+7H_3!K<0(^+#AuKQi)d`L3-y z()FMhZ&@)3Zc=WR^PZ|x)`TuIy{ak%Yqh>9Hak8xhp)e6<<%;^ZE6ZTIRUSOH(azI ztgNgUzmidt2WiaznR9!3xb5na43X;k@Dm5WN(llDEkwa6_Vf7-ppv9jF@T5&hEZ*$ z5P=4i5fh!ngcz(|&<;&DjTS`1!QgpfBthEtJxtIs0?%MjH6#4D4Z4#^1w7Q5(vN63 zIF+TPaSHU{7*qux8Hvuwz+l_Nv^A6!kK6^*iIL1?n+Fz}kB7Ut?$B z`RO=`-RNLvhjS?Uop%+0h`ohNgtGn_QB?QWE1&b&A=2&31f#}wG+R;6i#Rng2u!kg zlud)6Sg8P5c2S^^6nZPdf5gpXz;Kc4X_lotcKo`>W(Q7kL-gO%cos_!G0m!}`zYk^S@_s)f3 zXl)ow0}Txgw=#ZX14u>r(+uCgH!qM<>NRng1*^!V$vy$$54_SfD~BZPkQzD z&n1RQ4D>%Nn4E#4@Us% zvBMLE!bqZe*bVI-jV~%%AR%Lt4hS5#&SBD*ml|+tnOhSicWJDqWFkQej6wGet{MwtF$tVdEQom~& z8C7VPZaOtV>1&SAo9mhs>0$x!UjkpEpms)!DaqA&dvUrjy8%QxW#r{K*w|d%T?vT^ zC9Tr2p!R~4RoUDU<6A!%IBgUZPC$|!lv8j-s@vMIXp~h|`+wr1B4S}-fjsUpmsSRT zP1hqN(&|`J;s5DHIL6i#dEhHd2zlwk<#fSopJvr zoFZHQi={W6bVO*Q<0IrC9`Fer3yqeL0PJ&?Jn(b(S%iclq+Y)-waL*d>b~!wCzknF z{^qa9-P66X@9ky^kL8%}PrRX%+k>&JuhWa$;%VuJQ3b{sbr;uVi{q!)qi_B`Jo|3D zt7eIP@-;jcC9W_69yjWlt4y_cd&!i(%1&OLsYo17`!Ay)Y@`8uXnFH;g_dWo0d)0= z-wmo`P8T= zDzE-W2*&ceIiX*Rv@yYK{;w#~Q3AobOn^k)q*a?G8G+$ge_k5Ql4)=#{w2H>rA#x- zw&JoxMI$NIOzD2NYKwMv*^!%)E0D+_lnfUUvB#DaAV|WHw;hrHUzMX6fErIs zwBHo{OuOj!m7pCf&Ro$_tyo3Cd@CYjKq(UHg@{2HN+V*(FwzTvsNgzvMH9#1t3%UG zzBpqFaioztHt_uXdvM#rN9UiQk|8*95^o~(cVp>MRMd%16!rLTmIHT@GH_Qh<3-g1 zW1Ucjk=XLaks^{V4$Qg$u zKTdCO?u#SVArjO`v1S}9=}lh#(v0KL7wPC5ReF+k6D}Om>FT4p<0~FG$zK1)9vU2Wq@0_K=a*!abX!wZo08F=u{QSGPWd ze$ooyEB?bXzkV&sN2r~8$f#=o_5Yldo-R|MPJdSm1Y3x_BCIanwya|86;&~q%}e!y z5j4Id7C%pWz=`ImT`c)KDE$hryr_!d`V0ti%Msc~_X6a>L2mR<`;tuc)q;A#Wz zi($eG#N$@cZyK)`c#d$Oop}_x>#EgTpDwz(6}kIdX z0c7kHsH#h7c>5TmHGpXIcS;tzVArD7Rj@@2Kp(?&giBvU{(Te2VxzUtYC==NLT!wP z!;xCb^NOds&hV8p=nKLDsnSj?!&qhaDsC(k2hqqrfa{iM=)F@L{Ub8 z+I&MGB0x4Eq@?`noG92lMnj^^gxh*QCJbKr!DkeMF5S}nkth1=x4S=uqT^azsmm^i z=TJsswzjt?Dd4g74phqTM%SJ)G<}VXTwLNmCnXHk2=+^o{vw_Q-Km`ZwThQ7UxKa{ zpjg%XtjVUivYuF82FKxqN)F%|sD@5YPZQzjL!ofi@d;dj+(}!@rqtr7r>~Eo3~pPS zW|nyrfMX*pB$SQ}wHE@Pbyoa_nMhG!;6w0@0DmL^fSb)1s|(QOoPdi5$j5?g*Yvx0 zUew)GOABJl{vl-Fu6!9&t9^)QVRR{lfv)?d$3H-zAYf^jQQOf1?mzyjd+ST^G68#e zfZ(p}e^N(}*8IC)X2%#7-(-{2<1edOfAlCaTzna$X;)txFfEwb8SAw<@eQdrpo06t z=&+Y8B>UGtd~8fRTY=<1yfAa2oI0v9c*`poUS2Smaso7wRZ*pTXK=gwu@NvjsH%=x zX8Dkj;sq@E&_v2nXm?7bw%rec^BqN1%#xlycr|@EAXtb~`2Xkn9jK=zB;f2(wwd+k z=v>%g0YxD5Sz*-n9q2WRN^074cAKVbY(zh=A^HOl-4Q{Ex3ly4TFCiv+kHiJbhN3d z5eCLNxGQmna8GudUFD4p%0S$eUms_tHjvKTrDo<>>NYt~bat ztCmjTSx&==fvhX2I0~foJ#h|byVR3tbpLq^mNyZ_81qJ=?eM>v)3q-Y6*Rw<#U?Wk z?xw=cGdOL6OmhW}G065hNI;~STjOBmmjMpF-*4Wti|2nVa z8?R#c;e?C?*Ud9?P}RTj{-gSVBU>97CB^>ysbVnaPWk$QQsr(>2dsETMp%YNI_~7Q z(ziCAC<}#}#Jw2s(a+D$5)%_C)XfOKY34L~ZlWvk(XrajDq;sZdvOv$a6vhx0g1J) zJ?Lw@bG$OhocF5d9|d=VQI?c4i_aN}Py@Xi-onp&KSjBI%LSJc<=(`Lt)Oq{sl#?DMUnN($l-k+&OuHfcqfd~jQ za?}K9DVkj}!yL0USYpXC^`92`{0T{^RJ|Mhp2Y?=)!&25p82tYwx6G$l=lPBfwK%`R=aC5?q3BwP8|_fU26>&&30ym$|tb#Xi8xJYq&f z>x6_GTmyQ_APf#XU!WEVSaqJhMpXZ1!)uNlY~6i`WAEV;y-h+ux$u=<^PxYmKg@l$ z9REw3-rQaMkoNgP=9`HA5^U$!i;Hm!RK9A$DJkVHGHhxXUKA4K?N%`uH6n9xEiRm0 zmQDQ^+6l%WLDI?L1rx5QACTR#f;JrKV8AJTljs>Eyp39oB4#i1SWxEzVDgwPa@~RjiVWCEfF*adQi>rkoz@FAs%%T!+zurj& zF6S@fz)s*zg%kWi*c5LXXYv7|Dh3}PpC%G?amc%~C z-3TTqm6w+CXu&peqK20Fa(kcPh)`?t+6+r4NuCy`mZJ_pyY=@N6a>ya+L@+WmzQmH zDwq-?0LO{3|D&@&J9TwCm31sw)xhXNj7>vaZBfdW_kNt!pvSZm6<~NlC3WE zK$hI|VXT0~9hubx&wy9ti@qE!9MGChN$M;(u&uGQGDdAdh6bnpylevdh?Xn&(tV+N zWu?9SJ(Zc4{QO&MeHgeghNSyf{c_scKS2E$zq+xy8c)f*@^p8%tA^#1sOO%T|NBKA zbDt=1JH>{d1MB@@sT}Q6*A<}&VfHIq9@uI!s0#1LhJ8{r!ylT!LWbxW>f)gzYKHd` zz3w_~uv<}L2n?x#E^G*gPVlPIa6*F<4A`5pY3P|0fOByq!b>Q~$+umdc)4{oR^#w+ zcX##t)*l~uT#BwF{QQ7UMH0m|YIaJcKwToYo|A}Ehm|NKGz6l*%S)!@`g!~uWpsKY zF$f`q>~YN#>{i)&@%Kk=__#G81pxWUj}FE z1@w>Vc)~@=dFR&8$gMkH9|8D>=p}3s1By#J(Ema`K|QEbF4*(e_-Ge@5EOJ$zo;2V#Sm{x{UkXfVmmnY);7aK+??`4kxERW&v) z^b<{Tb#jMqsH$Mj;2@p3T{<%&V|@tC**fN81eLqbO-(Xt$*MtH+w1FV;0$#LzJ!LR z=y2WNDDPxG2LJY8!!*N2t5EYceoVo3J~cb2ENlH zENp!5ODAzfo!QCC?Tnj_C4$hms;1Z+{ry8)(E$AJGO__|N+gg0wFc;c>GU9~ne6J| zj`?yIJ{>Wtz*|gW23QQ@?~F{SI>8bVD9Fzk?`naH7?9NVCtCp(MVd|&1^VCk{NtNm zbuZb^pQU|7@!}}uUS|#L?;cT+>{xQAP*PG7u@IMlammha`!*n4r3sHQ*jVix+DfDC z1|g{EEU})n_rUsYqaWZ0=zFs`_&^9Th54`VOhw zqpRa`PG2S_Q1r)SEFO3G%7SUG@Pf+mYmExi+kljy|G%0YcwV{&dQ ze#acF9TfPLGzXxwv;JBIQUQU@4y*9$+#DQWIqt^TA4t#lhVSF z#xnBRfZ2m^8l*4PJPq)ygSh26(QVRU8Yo0wiC@{0>ae$2^rk{m!39Ak>$hl1cV$zG z^7W{th4P*uNC_aqc6Uk)@C~}r*vid#v8tBj!Il3byz95x0L^)X<|(M*+2U0l>f^(M z-QPbBH=>|aZ(0onR~`XD5*u)uB|JG@ABcPLV&N~A+2_o32e@Bprt;BJ7RSp?JOZ5R z+S>Kcv9iVn)MagOMCc+6rT_Hg6l0s$VZfXADL8p@jr{`|z7yrXsodLOT~wAqZ@jx8 zMAjK0v8-t8XL_MpX2Uun+DSoPejz;t1`ytFT!6AC@dyf5gO(Tz z22$YY=x-u<4G_(CHQKYi>V6PWkYY$!vRN&!DD$VSB^w2e3Mnagl2W;XnuX}P>UM0f zOFl%>!qa%891-c|~m%Scru$RGor%m>_-sg z$ji%Br*U<4^>{RBtMzZAJd<&CRb#x~J5AV7DwtwUT0nvZ*8OB?a-Gc+nctqFfiD;x(zs81}0Y*iJ?$7cvFu1d^v;S$i4*(~bT!po8(CP0T z=mV$S?6;pA+d$?W@ouLsB7J241}K{XmUgc9lp&Fg!aFr%vt{2gROt+6PLq-y zKXNBVOa*0!hK2w-qpFGu;JP_3*e=Xf7@ZxY*kw<&lZIH`m>*3#+rdKz3C;RE>6yJC zBXlN#)tWbaAV^<$U*7@s4{-vs^sWha)}7Wv|JkLfGY@-gxFUJ5@vTAzZ|JvI4T>k=j3y^1 z-;JHO1h+?lO(I#SI86y;$rs_`*Vr!^nP8Bl3WPiQ(}aMhqN?g9fXskiUr~WgjPxG- zu{#wF6ZPM@$Cn(%2|@)sZ|`LiJ_q^()$`3;hx#_$a1apT=gP2OX-2~BUFSE$9Oe@d z0ZB9y2~F?p>0Qosu)qY#yf7=#OIKH~Yi8#@30l-1-BsRL>WlTWU}@%!G2zf3c`R>r4%-C|eq%w4 zeE+3@-Jj=SvK@&}(N)=wV}Fv2^nQ4z&}16BCJE5xuF{(1EB%vmR63~MOp#jIO5e~qPhA0M~N!Qr&8Uq$P)1&db>#Dvg@pxpLHKH!KCa*yb40OysVbP4=gt+?eLhz3_gBG- zC?vuVKIp7?X|lo3kX2hpClo!dR1_>9tt#)pNI~Cx?g>K0S&J3&Ga5)_kuTWf=;;}> zdR>3BYsq`IQ80c!|F+mLe(YyAZdfey{rmUU{WF2qjE=s{d86MeC>SXy&YfgGMYDUV ze0{SVp|59H;BddnAuMJe0WXVq;GOsB?RJP+%{!s-OO}wY0|NuM_xIpsym>w@c7AoH z`8wgr*SBc4KMAU*H#{_KZD-Bh#9mghQ&a?GFwx&Ar>*P0k$%R$hUI{4X#AI~N{(hTZKfKex5WagKCx91Vn4aKSl#j*;2kLm-EYi277z zvlc&)bq0eAC^hW%?#|A(?6-o>_IMTwJunuwf+aBsT5k>f8XZgIN-2ukVn$@}Z*6`4 z;|120SFVdVx;RAf;(}a&;!~<#NS1&el9iFch99n8!s-4gytUCLdonf_FZ~v5yAcf~ z&y8{m9f9NK#u87}Q&4_`LkQtH32F)&)W`BAkS5hrw!Qu1pS)Hy~7} z_rBcajcg546%b~)RK(mJnJEA&*}k3}8g%>TiI(Y?yf;{8ihBj@(-QJgvWnf4%>o{C%oELHxidrn`uMrO`9Y$8rta#{()vt_TXS=2gz1mv38Jx_&x%z zEujHtpfqC-o@Zm_3qEaaVD%D$C!MDWraUePA>-Fy0~Bg_c+xT(#2llUzAhvugBQoc z3++iYzq2^c$FhUR-L60hZ_fvTm0cS1sGD`1lVtnci==7O-w|l z*SAeQT>!qxFHv$=_`guO>UV0YR>*S)x1=-xLlk} z;I4B0Aa8#FoAR6WXbKV&=Q0!)03vMgyKe}n3U28KurqopqN*ko1QHg$S4g8@9RFmB z`Uvq0c>+%*91EtMj#r(&;!k&~wh8})&e&tme3YtX;;Kv>UeA?U6r1a({N3VW9PrTh zd#rqZufPygkv$7KW1v$Xre|nVf!s`jMM#)INg2H&w%2to9bADveFDvjA}QtIrT?#s z12PPg6BDo-^pNz-)Mj^T)_`pEw@`5U2kUp&><&Lw?Zj3+hS;$1Eo5eN005#9=j1H| zdF?ENF0R1uKw2Iavig;j<=d13_SP<&v^ zJsu9O@P7w{XSrf#Gdg!WC!n_Vx<=9Dq0o)SVuosGrEHf*RYd z|9FAWLPu6Yg5m>W!v6WVxDIo|*7R4$D!U3hourmqy+e2?J1%-Wep$VuxK{?C=9?kifUcw}xE zlk~rTVBmG_)p6|wV>R(GadLvML=T&L*n^dU1yDtW>YFIb^M6A>`wNJ1s$l;>+P6HE z1Q3NVCW6eLacT8VfqZve0Ugow@#y%;&ccG>LtzfKQL{@i=<1&QYi}YPUUh&?>J~!M zABNTkV$^3m4KUDo`1tBTntJ?kl%0%DMmeAx!jFWEto8mB3n)9^s?amOg7|kr!StyD z!}H-^S1;fj8Z1+R@TfV`ci*Ff#iGHm>`pkKnf37zmF%qg3NU=PSx?h`cLRW@_bUl# z`dop(LZnVA`E`YJU#lT8B+)A0TU6Q}VU&+VDQL!ldR;E15Tg*gQ*U1g4qtp7d*x z!N#6<{)X^SID!Pt*SM%xPZ8q8Lm8HL^CEUFed^dm5F7n0OdkW^-8Znap{B`{;ov%(J0MRT1PV{pi84?8kgTy*WJ^;HS?I&ccX1`-9)v5V;l;7r# zA3oUFM8d@O^D4ky4sd+lGPr=ULBE+44uIF7!DFDI-ToB6{|TtvB#dv;aqoxd@iFse zXWys6jnpd~-A&-@#ShJFbbxiz@1{-?u}c;!N*t7 zv!`jru=Xu7_fS_?*HK$*He>4Sae#vYb{jhkfK~drtsZduvH&lFRFx_AnS0_d4yA%B z01&?UQ1*Oh{A}atDHMPK4vWX__v~q-{5XTyeg293GxI=OCiRIXYN803=&dj=tj#<; zoJ{b=2L!7-+AFXL#b3Te_+jYkdI>n#H_yA`fdJ7+?f}8!2PeWUW;KuIH$HKz!jsNI{^bX<$pSh7#eq)*JqO?C!gr z)bX$h`sfo{lpwhA{Io8o{%lt=6v`5NPVOMz*DsLmuzl^!`We%pk^?AD>1$ zwU*UrbKovyct}_k_M@$+s_HLOM3)ixLL1UrhK2_dK`>@Chc>Nwt%JTvR26CMT|cc- z8~HuDhDZhM<&(3RahjNzz)A4y!N74!gbHU3J{%(G>f%ycTMJ{vh0qBIaB_~`o$ii2Hcpa|jvD;uV1YG#CgNaBIr_1=xri6FwG9pH zEVeh6ii(cT&T&I8v!|^pThGvg34hSDW`crm$K6Or@Klcl251pQnng_`wgU>9@fR5OhMNvhXD4LA?UR0{&RS5dJ#an&ZY(W*{BSKzt=>%sI6pv2$Ne1;@RX9WJNmmJrxqZLfjpup z`F^Vp2xVyDqcen(;X)vWt8%c`E}DlY@yF@w_UpFvbc)>lwt^;IdIC+RcpykKY;|}7 zn>XOEZYgcEHYcJbqair6%<|pa-j7V2Sx7Rqbs@m~|ASPg!a%p(m4)gx`%&fdUF9ha zEMokR&qhSjiMM8#>X(%NHf?oCgwD{zydqEkOt7T}{1=cbm+`}IXPb2Cix2lXBYjg- zJkPBRq$2w_R+Lo$#|w_UlYH;Xj(B@p;Kf0TO?AM68s{x&sQxp;7jRP8Ot~?z_Nipq zQ6gr`wP%R$cBZIO519M`tncK)vbGS`%-Imsa!lG(1Z`8(9`MZf0zM%?U52r?PMfQ2 ziTgd@18X4JFT8`S6*_Ps1f-`EHE?{_D=99P zEX85)-+aR*hAr!rf9&`Xq;%L`Pg>U%Deo;UwcLHE11iNJakyf{BFXz;c!)LS81jb@ z#~>c*1F*lmiJ~BLcU;AE5qe~NKBWdmxX)%Xh$I+^>@F`F5pH;@uvt}6H)ltZK6tF! zjvaOZ3{dW*mC+kJi5f>IXqyan_-4^~miRNH-6L8=@mjAsgkBPzc1{}DD zescSVlTh&uhXwt_TW5l)e@>EL|81vprE1CsjO)O0j*;wT zt-89GX{g0QVs@$cO^|q_<2te)lNou*4VXo+vapPB(oDD1fAUc@wRQXa3BiVj63nAp z;36Ai5~kseLH`P*%K(Z`ILVit>v>)$2n5Rzj%d7KWoL7%0LlQ$!%*=e6i(oK(-SPb zq?G~&3za7N)YtHaq&;*;`;lR_>$Hl3HF5?7p5JMw0=Jp!CllC9-H2X)+qhH(Kzku< zKO}mPH4wmp&zxgO44sidLl<#GBl&?aW_Y zZ@oPR=|3<^#sC1aKY&O23_g;ZwMY(6PfvA5SL`!UQSKB>RMdd~yhB>EZUpr{)s{N~ z8FE2H5{+QvfP#!nLoo;!fm-6YJN18_>BE0gKg;oS#jr@P=eFxkzkgEa>Hj=xabxgB zLV*6(|Mjrjd`by!c5g6Z68k%k>&a>2Qk2NK1@|Jj$YJ-nW}=C|AZt!+6BeTdWBG4y zC;duGO`{V&Rsk^$D1T;ND=hza7yvEXj+67tuMrW=zK=prP68A`g_Bh8R8*o&-&s>A zsFRS?n#6|Ty3sihive&l4h~k=&UYQ1p5VlhP4p1>uLMzCRv4_~{rz%vdTnvhD2-VC zd)0aJKHhc=jEp{KLj&M?<9Dy)cd6q~ju5`4C!hv0r@a(uGIZ75(78}lkU*PI9aT~D z6K?p?@!T8!!tZS5IQPSpp+;pcz`e(4uNR{UhvQqLtDtf!nU8CkU(=WR#82|VrRL0B z{u@P6iw6@xA|?iHN#@ksO3N!SF7A}L;g>Gr!d(5heeB;1Y8*HGI&-LWU65Wy2PuEN zLYu%wT=sx*;c)s5rm8R>zC8N!68`V(jmc6^ogBzz?{W|MPa>S0+5m7a%JrpwL;P35 z{-s$Ij8ua;ZZq5OwBuPJg}(UTxN<`M1ED>$Y! zePX9h-p>aEbSqLp<_f(k>X&twZ%NiINOy#Kex@88LVCkzXWU}ZIy!~3_A=bw{EMdT zvt49iQBh^Jf{Un7n(uebLbdJSmJl)u=?`?3b$PviS3NxZw43#WW^g&oQn_JfDIM*5 zIbw|LyFRp$8_XJTbw#Bo*WmEM{#c&cXJJAeXVw4d2{2eNqS$6sP`N7Lxk7&A7Zw;c zyP#eBg6;CcLNcG%Tv(kA(JJ8m_hO^Eu6Eyo@DWK3V0_Bh&uwh<0xVR={mS#>^V6kq zhlp#$5UeO(DV~Qar3oXnc$ z*%NpqNMP z&%C^!KVM{#lam3%H+xdg6k|MXz8rIGHd`kIE^jH7j5#4NLs+*7NOOtV4Q~Eiw}%!= ze-fyPD?A2_;ujT^qfM zz<<5_j8uUX#FPYw_B}hQt)jLQ5YEO#EwjdfHq|Gp6I!Ao$w%y!sP}JsEaSg#%^MvZ z;%;J8=*8Iu7}RT}-w0N4s-u=jyo%nO=Sf4BK={@FG?O|e^MR+J7EjnzX)ia@ri%-a z%AEHqDB{G=Q=0lJtS6yg$606~&x7xVmJ{Ren#c_i^BBj^g`~b7#j3v3eMio>PWbS` z4ru9uvLW`+ZYbrvPhO>`eDk!kV|iG2iCUTHxWL^&5}zVzsfQJ$&^6aWU#1|iXW`RJ zFN1@W1^nSuG3N_$knI>Pg*^V-&Sv4L+eL2(pzHHlQ>@P6J^6<=MaNdr7qosFV6c1H z#>7rQc7pvX$f^IicbfE|`X@@fM`Meuteiy-zYPeTGz$p`91Lo1yu(aDZt77fE-P|y za}qjVwB+PlGcgrRKLDuD`|G2eVos8%|4yJoMX~f zoaV)fs^z7&x96O@J>ODOqqBXBi@#u=1r;3LaMevf>vppdXUnfYTih!h{QLtTy+K&d?+NAavzXBIZIfU+ZUY4S$D~z> zFT1chl)E*|i26qJhv#b&8m*xT6Uo1r4L0!2EG<6q*-Q_wM`ilR(@}W1_Pn}?1mFe} z=6OQuU-lurkNgs{sT0FGj)d5>N{oOJI`{>SSMcM$&zvA`eH^Rls|dYpQClX`5~n#E zM5y9sxs{!|OZ6+)&f=+R!ifaNm&SVqFaOr)g?6ejp?pUf5Y#ZaZF|SWMDQ9L`D2cj z`HNoigSJEv=GTae1Jl+mK4Mk3dVs&uH9|IjhcT-%%_%HwV{eHfygnVr2u9V%$J;1p z{s{;{a8XDvwk^f)7lD5O0Rf&$#3Lp>-TSOJJmpcvh=LTaI{zzY2-q8B6H;L%vX6y_ z0@XSF8eqv#Jw*Y>@D~B!2Z2}YMCiPLFIrrz0n~#uarb+BN+KcfNC83)n^OhX(Ud_> zYI)N+i)e_)$HzF}2lWI8149}oz$tV7Pc{|r0R)aH-*vSsb}&db7$e4B9i8(a+iGIb zxuxG-gi6ICt21}rMNy7Oiz-oj{zd#dxpJ$Q=?^9R7m$gSoTgj})!lDNZf`f?4`3N_ z)X0yS^wt4gdc2(SP9%P2Xck5G7F_Whw`e(Z$8tYzI3p2XDsRZ=V&*^t{5L{#p8XT- zvy#ItlkTlyyInt`{Bb}v9^BwaqIkb@H|6PUo!`>MqAtPl!u_7Q7|Yn%DFX3_N`>68 zuz>sIWGiPL9ug4&3n}jL>oEAa3M6eSB_(u%SY}T6iX4Y2Qp|3uisE93>7(ECg&NHG zb#s7MC$!2!(bnQp6iQ=i0M98ZCibnRo4l6u&A3^$f^SRv?M5VR{gj--$PLNJ@f-ILuV zUID8)5IK^yMC#p&*DmQnTRXgxK>C4R2w%Ay<;IvcSCTp*EJMt-1PntQ6|iS{+4;3w zqh?lGvVcpf0DeZ|uNwUZqE^>U)z7*DjpB-miZ^!4Rtp~`r70n-T&AL)h;{qBtB^+0 zo#Q0AI(a!cscBMDvUV_5%*n}lhkx#3;!Tk_AqLTYXKKn7jWPy24$3*2<5|Mjt0>eG z?>Z6Vn+0<|e~{B(Zc|p7nly<80Sw8E_v2+FdjuC<2ag7nw(cp*vx1n-H!p0|pauRx zlsatm-{<@>9Yk(5izlKuH9x+mED?FAX|nD<8xC?Fc5AIA7bV82GbNLdYLYHEYMen< zaeFSq|DNf;0B7xvB0T-bT&Y{@W5xh39&DJ zMv*kKvvOsWPAf_QV~9}Ft1~lLa#LzOfBw2eR%bM5f-&OoVgfEQ3?07gAh!>`D$ty} zDUQ(w#zHRCYhiC$*cg0%cjpOuxxjrxpxvZkW@GAnJN3$n#kK$*;`j@ki)BAIef^IU z3kGK+(>_Le&`5vT#^MkDQpJk9)-GoBOq?eVx6U9vYUkmR?7}cPIOqUM^kNXA&gQbR zC{%T*0TfPw^iSjIQOmLK)uQFg@wGROp%S86_~qj~LY$rW@)TkV-<_L|vowF}be>tB zi#wkLwIjebDXCycyCSe#3VzrSTLQv*FntbYJ3d;7rtuRPvw&wBC>Ym`B#ADs` zoIiY!+@(3|B6uGKcGw5o`^tsW;i#ZWT|W=Du1U|2f9>q- ztjG45=jf3!LUT+54LxtC`W_yrwQRz>!NC?sV3};9YFl> zbNRx^l_YXjWG6XZHVQ7+TtkVRqd8<5?Jc}%u`}bInNyOmScH!A8}2?@uDIeq_|j!R z0>T27WPkE>xRc#|A{L~?tkn$4A&8&}2}vDeibr5=%0G-aM^C_C0IfGrRM;G2RrOBz z552FlZ1nzpLS^*$p?-s^&)w@zl)FaE_HVpX~`0ruP;+Foe-bAW*ZpUq(2V-w-Z76Klef|1vXYMAL)~$&!_pl`BKi$6;vqNQLB-cW0TODP^ z+=%Di^NPQ#o*+?NtInn5^awh%yRsQTHgqIe+AXnwzju-2U{}^HMJh{`IVKG zYqj}Z23SaF=<`t@F^_H;oS(R#c*klEtu8T*3vm~eAVR4>H6^7huOL4xXtbqS2plPK zfXcv{;l~_7RoIvUr6E@HaAH0(;w_t=e>ss2c3 zqtgh9jL<7oqC#ZDSW{NItql5Y3T(J%aC(_!awxq?|1DaK4R;7%g&OtluRBs|yl|tL z6<2#Lmq-U4uZ|h%+fccw!HPLDSWY1S8@`-|v?((^^wlnt5xj)%Dw@x8$nPbOtjIND zW2X>x_OFja5mAg=JtQgCKbmOjYUF6l&g*ujCMWwVA&o8ro;P0z@~f$Z30z9N52ogX zl%!~`G#Ri~YG9f`gR^0j9}spwN={1y4eN&bdZ||_DXH+5r|3Uw$qs2zpn`&ey&Iq* zR!M$T`0v5O!lKb+~f2H zWm{WYb~fCyx~68}k2i1LSbq2bc%d*ekDk$4*Q`0L8NN>VVmL`4Zd!?BR5NJuzFl$u zGo+w~b8<}#bc*qcoJ2ygH#Z*dqv{$P!{9G2PW)F;-{<*4h-|Q-dxL-n4Zbn1mfu9q z%Ubd`=o1>2G`Yd=wf&78O4Y5=F4AkSkxCXUr|oD~ylIQC@N2*5tcX{n;9jx6Uc0Lt zgwh(&4pGop<+Q}U9-FaUw)Q=)O%)VzM}h9yX5Cj1?385NBg>L$KtozW##*;tm}hmu zixFL@QuBg-!96QcX<3t}zK&Ttm{^3JIK&K;>%W;) z0JD_zo`K)`%h!Kf7i+|oYp6M4U{|T9tD7P2#h)pa0$TQS(lWn;O8TB#JS5&u^Ws)g z)z2&~k+Cd0}wK*+LPdjIs(7K>k9hH|$ju%eu*75Oe zk7t0Ohm)(L$FOrdbepbg(eHWRW+mlp+<%0#VO*D9ihby0@q3CnhsA zbOGoX=*uh1usN7;)j`j_kPNCTz&;H0_t!er8^R@OLQFx?6dCcxW>0FGpbGToot&Ld zeFx;^0lBuEl?{+C{>V!^NNK&%`W_!25Ax#axQ2!rA95CoR*n+IrThs8Ux)Cwf=il5 zl~WcAj`oQ2YL_M&)T`{5)nxSbXyy!MXP}Z=STsjGB4Xi>e2?Z96eMIfF=aD^$7t~p z!W!Unn~&MBTR=*-UI{`{|B}1z)Z}Erb2K_Soi;6|L<8T5k}%4hij4vJiuaYSriiQ@ zD$qXS!J5v-BwzN%!M6w=N6r_wP|Mnj$(+^kMEg2Fn%*j0hS17|{2l^LVUu1R&RtTL zPkP%^tmzYoBY^3ZEq>Z6@Fy-7N7;2io^!(U(ay?haMj^QVd0xuTwg`BlKcA3s|=|n zLdbqzwAhRmN=_>H0Y$}wxSj`ph;mCVTc;3QEPUd@N;lQ$`1sHIdZnC605+M`b(NpH z8#s0T`LkV2Y)nH%tl;bEnM;jEL}@N?5i zt6j`5^>nkf`(2>g6m&K;W+9G0BE37h{&3~yMl+alA8j_UJMpMLP;hTflqU-RWlfp< zMeu0LiD{0VmpMW1_dK@72>~~>vKWI{gScPE8FKGlp{lq&iWL#tThJ=Ek$MB`dt(8s zV|%GJuc8&d?Nk~orGC?kRQf^{r7y%_-m-8!zD0aBE+va-hT-;W3syy4M==W;Zc!MP4lX_EWjGt=DCl*?~vTza&Lr zlp-+21Pgh2d3E*dh9pY>ASjBInT8}!RIesSL^y$ohKnsw&pTPXXg7?@2L zPenmQM#sv65K~@O7N3~d+}xNw6jc2^E^e}rsY3N9#$+N2#?r@6t_jAP-$9eTpm+QH z!+k=ejJj?%kQ!AI4bgoRaI(6LwUr*RqppimlwLP)zz%X%KP>qCdv%u3@Ilr&_cQ~;b3x=!c4YvG`cDP?o3 zJ8OE~r$otY{%xW9ubkljepS&ZQSALp9Z>=v|2-GoJen*^*++xK$}7a3&F;sUadCiW zp$9_7Y{fFNvP~^bhXNmB%1tg}ZuU2mj4Kx3r%odfflrqnrfBZzNyck$Z*Q!v&Ckat z%R0*N=ypDt2TZ&mdXhdc-6JZ_p)=e3HNyYBy86V=hZAsJxx0zqQ?&}_;DLSI>Jm!l z#TpJp9U}IcLzn}PA8@hp^AoS_0@*>4<&^?bZ9;Rf?O|tNNE?+y*;rl0BPRbnF(HA- zPygx_VD*>Av8=*Gpx4KLQM9U|DuKCx-2rSSKwHxlm^}n;8M;aOEx+)EdU2EAtE38x zCav(Ry#9o!8PgE^>Fs;&8DJ0!V=W8RHA(7JBH)iZLELlWY+z;W=;lk{AgXQ)(;zJ=E!~ZD2ui2q&;!zfbl1=V(%mK9CEe29 z-JME{g53RIUwzRtXYaGtm)!KO!9~4>$c_pDK^89?8bCc+vr9ZpZ_it$ch5_&haq{W zv^k=VK|SL0w?MW+l+Z$}%5=~ZAD`@!MSi6lY%2z}rl{HQz4t_5lgiD=4bM%@r=gXR zkqHe8OG!?Kg5&=kJP3fu?b7X8u);&6LD9-FX#H^^uaUYQ2@m$3q3#uZ!p)m7cS^a0 zGN(zGpt9}Ls4y8CWsmL?5fg)bmW+tBES3C&%EIE}^xwzh+ePqJqL`~|O-@cSGSKnO zE&g>9}z7a=lkatG@+LWEb$#OCPo~Qw7 zjzEz?fx_2hl^ zD}W3n>uPc+CT9vL;y}E*)t^64V<91<7_~Uj)6(|+8i-0gvULsP5VqAl)SBYKjcsc#xFM!n!}jXs6wdzzX6rCP8+NJJzfEtCK6E%E)$&6(i*2hi4bsO5WId!`W5`T|n; zk@YP+O&LWuQpjoQ*qzDcW1Yf~fPfcAG!ou+y|O_oDy{LciD37eq)7V?Ui4vAG|Jw% zCAW4yT-2g^fP_7m{BRYUxpEWasb69(z_rnwraH=uohltarL9x=n&9S>4oBSC=IG+VpILR)`ONxj-D% z3`4D!xiBikm$!_3<~1g{YW1;HB=$D?&tSS%g`sx^rJmgVja-yw)F?^D!jqQ{@R2oN zzQ5b%;>(kPw~9@gc`{QSHBZ8gjI%Ey{&Eh;gpGK67-LIpU*9^J;>x8PYf zU_yS1>A;XXsmLfQD@v?vY`=y_PfS=S5@QF3o}8YKo7K+Dl4vC*fp#>Y7AiY~$LkJc zlUSQ^>^5zRnqpaf!TuKW<%QI8&(*3oTZkV>>ZRM;=1lOvbv0HAat?5!BLKZuFANo;CueulLze%X zn4#N~9SGVrcR=^kDAK4sCGhSgUurOYPThT>_V=*;B-W~DtD4QmoPIMr-}v-*!81Ns zd&{f0utHQeW@uwMaLRoLZeOQ3CQi;2nZkvIxix)#4FxDL7t-W$W%V!}T&ghwj||~F zjSy7wfYSDu2P&ypr0tH!Ur1RKjRqYagkrH&*i@skNl0{ol)V@UaY|ycjI^{CT2H2t zbUJQph}F?feVkwxGMg2ngz;w8!~_KuzFWS*k<{fBLSe(SFvog^Ee61)pY+> z>A`}it;lJd*2?68kb_SpzC?Of59_x>@nN9EH_YOCSjY_8Frjtgm8Ki?C7stYZzkHg z4kpj4d$*pkF%H%X616;H@q6ew!Q=$P?Z;zyMTz%J-c4`}R`lXIoVaL$%gdnBP0-fa z*|O35`QH-|{V&yt8of;XsH>Z1yF#tS4Owm2ep1dtt|-a3v7V6tU)vYm5#iH_3ln(6 z#Ka^d4~I>g0O#0{h6sBx#mVg*oSZ=IQC$P7ki6ca!hiDf>-^R%C@ehEvmq|bQdZF6 zI~dl{_0a63XHukCH53}Zouh@Y_Ti)l?+|i`o@GsL`#N+fzV+Lcc9fw=VN~+83)QfJ zl*-^Mj&Bs*Gbgyz7mO|KTI9U3$;H!;3N7P;u~NY@OxZnKaHMa+=U)w)JHxCOQIFrhbXB*=; z^%8`dD&q3j>xbRKTpQp{N0L|pB~yy$dB5%s1}t?~b@7MayOQ%lFYmM_azu0twU8?b z@$tn31d6Ba^SFWkbqW>0A{J(5YCAhS%mf6T!0P$q2a;Fp(vcNW!tv>Ol)hGR_hD1p zJg+<6HJYHJ}cs#9+DdvTEVYev^}>M@g1OM0LhLG*bUI`WHa)yF3^#oF6h(| zfX5IZ`oSE9&$s2jsbuutWS-+dDF4gn-!h2rk|tjA3#RhJs?h$J5>v9>sidvF=q{_O z@~habYux{N8hQ5&Iot>9x)2X+epL~UC`*Ntg~gN$1aQUAsKa-EGIZU``GbgRXlNLZ zpIlV*ZSQb@esNJT3{6B6Zb2ihQ3t?o=zlG(lg?-4w7{DXMGZpfF^DHN+dXH8Kd=F+ z`RC^iz5&!?%M8uTL^~(rQsJ*Y&YHVnu>${YiUF_n?gN6nygV4_tgWpDqN1$%(*Jy= zcXL%$2@MTy78HpL?ghs4y>E1Uo@a}a-MyY*{KvpRcgO+69ylx|Lvp=$w8YlkB1bIg zI=ekX1&eNf>mR1z%0waHPPBFv`=?8PVeRSmLTSn3gpt9V|IV8?(&69P-G@i6&Wi9~ zr$?`$@WtJM$5_6A%@k*&gy7Z`P6tXQ&J3i+3omMN*gI^br5o}zcnHE8fqNI9Vtr|< zropgTNa)``zp|ll(N~IIa5obmBGF%W5Rf^<#va?CkT1p62oUVgx2r%Yu~=<5c3YN~w)_dy^)2YzgJ8)Ku!If{%4RJ7x~{LO5%k>o0sijpa*&FQl+?8NzgC&z zVwUbe%qsCY=5B?`<8RvE70-FWb0+NO;pd;&clt}`biVRtOI-X$kst3^=XbsFa?=yb zcMAVPCLk97P+Y%>1OK6=tu;D28c3Pc6B2l5W-W_~=O3tl53i4p53IBT^s%WJRfeEB zLQbGCgByaguoxmmee%v-hd7%+AV;Pc3}!!Vzi>z(8TMbD2DV5=gdEU4Yg%0BI5>#Z+W)QLyJ%05Q^Ezj1Ktv&BJRgY$F4p!Bji}m>Uors7l zOMPhwB(=Ppbr@Ypfp|EspbEgK@MVL`;I>Ns@^$E6%Xz(-#%=M;CSC?8QOL>hFaHg8 z``V%G5%bliE8-PDY2w0r+P_^pCL9s>)b7_DSKem!5Ed1@7nqo6z6>UKaSyzj2i11| z3OKZGBNPu0|I{ADoCd>u|5+~8i91x~LEO4IH&x=qi3V7ao$WjG0CW!hy zLNv8y!XrOfS-rgm?Ws2o?l~LbwSZrQa|n>v=D-6ALjbJy*72<8NQ3-^Au|gCB7(1& zIKUsh(c+tt7FWBAo&G6oIrf+a|Fzdo`T<~kY(3Sis3)HRby9-YP_v)4A@DCylb>dWZxX>ML zj6W9Lxe9~&IM_8%5;Ua1t=wE`5`c(FQnlEPOWsWgkuLF&?SZH?>NRK`2>?+GK-?TxR)Di5UH(Vi{qlZdj)=Ii7q7`(%BEN3>Y)r-qk6V|(;lA1Wb zG@OT;M}M@xSF0mbf3)w4wI#7-C84+cIBIM--o&Z1<>*+uu%K;jZZ7hkit?^q=*EUi_6V@_{tFNsK4D)Fqi7}^85cKAW$f9% zG~{4n5&*W`af@9rwKX6>{wAV+`uv%LmbRd%2&KXI?o8L2xBgpju-1Ij%EksI6&00Y zxO;K!?5Q_xWLf-(zWX=&DH-xE%CSAA-R5t5FgYv0viZ@cLq0ZPul^_``_uoPNPFMq zYrxoE=TS4c2a8wFTq->=vqcI#=NKpLcI2*@VhNJ2z z?E;^uQa6o3-Obz_e;Rq)p5(<0hjA_96N2uNF7QJEDO&zdI_nYfV&=cvt&Gace*GWk zT3lA{J{6YwzKCDduvA^C`s}fKX>GHe3x(s!)0ntXqm&L3`elo|BWJPb`fCnXxL{-rk16U=tJ3 zpxNx(j~~5(fj}>;YwoFQvZSxCOYwYEz?#C@^*E#WTY_5LXyQc!mxOU_PW1sPPT9AT zTqv+VaB~L;zoyz3;=u#<*E1lTdFZ23@&8kr6BCnBUal^ot*WZ3scGif!t{o|@a=0Q zTz(A&vUz!VHU97D*pW;nV^&Akme-d;sro1b>Nm5n{9Jv}Sqvp0vp{8B!;C=n{KDI7 ztNJ=itbmQXXTn`U^{$wpXa2|Q^Z9Yozu-DB{&Ao4S>*cd-tWsv=cS`Mpk(2-6t8b=OoG$S1ao5g zsG|#~9XSWI=T(SburIg-Xt5xGX}P}_b=_@2swj?svpxwD-wqcl!7F!z4eH`Ri0<*~Pq{EYwue(w+Bn`Mx4DXMgo^Abf=(LwX}4rJG>u=LSQ@ zz8+_Di~EX+AddO;vC@=ehs3il(g|#+&EY8yL)1i0Q!a>2S&ry}c0VI=+C&if0ZvgE znH+i$@#`y9Y8xPd;NG(5A8#WkiI33;84}ZH)5lWjYEs0r_FnIBJ1Vlxx6b|dtAI$1 zTm~q2talB;U=qP>Y@PWGAMUmRO|H9BzEjN0N+BgBK+|d z?fBwsM{k~4ZUdPw4U-sXQsyWWg!otjq)9px77%Gi` zJ*mB|t>~N`uqX7i@d^kq!ku2Mx6zTf;Dpp_!fWT(kO)gJ40vV3VN4>=x^X67et>7Y zX?_=$h%R{#|4Fe9=_}KX$IbUu1_CgNG3OEd#e*uwi=f9Ot;6vdOSFD;9sK9A|u3i6xE|Ux( znaMU3K%!XPs?42f+=&C4JYiHn{2=r?m{@a5-_nM^=@U&sEfpV;@xoquJbo`B%dP8n z=HvS3_MV4~fW-2RmycqZ?<-gbbO;r@!}{x^&A(~8uk`bRqvgP^$ffOv3{xu8hs6-D zzmurF3oZgzA5ihY7@q1B_SCMp;3FMefIs>>nAMVo_d3~+WVK%5TT@nacfakI$q(AO zxcCSD^+*4F0r%YNrSXT5QRMGqi!+=yYV!^C67a&&A5m!CoO z%;Y$rh>J?Euz7|I=OMTkX}_srY@KAs59VAQ5zIz63TL9QDXP9K6oq$am8u?z0F~Y?pYsOU9_TV`Dp+i6PZ4;Yu>bZBX&>; zO=Q_LOKr|l!-jeTVNjvXkyYe@wmalETA58pkAfOM##WLfGn`!?gw8 zV|ho%D2CBe@uZ47db|iPZ|@jBXd39XLURHsxThy4b4QqBf5#vS@E8Zg1)ao#w`*`j zRoG;FMa_2+mV$iH_a=npo;7AxwYEN5Ov_WOZ;1ylPirNQPk+OT{=f<+;`fa8aFP>6 zZ9aVhxJ_VC5FlB?!oo}zDF8nR_~6CG`JNfX$kf!eylE>`2j0J^kgF9}$LWoU?i;-r0+t?p1lEpQI^*{+0PO)+ z0d{|QTk+zLXB8T6xthkPnOT)Bu*b#iR??+Q4)h|Thi!Y!35{1?CF@}0Pl&N|Hn#Fs zd(Uu|BeC$MvTC+=UvDG+m%hWo!tx3erPZdTKYPDjclF>$se?(2pa>2Y_6hvyTljJr z=We`Gl!{f^7d2mAy8~h2asKqlXy*j0COSm=ss3i=^XJ7M&H&oxNMviXLz1C$A$JiQ z8+_b2o)V2S=UZpsSm$PD<O+Hf^pYTfV`d5Ou0B{EJ2fb{v?s%Xi zc4CMGWy*Y0o5qG(x4;Smm;wMq0(q{oD#eu27$PE@)Knn{8(Z#ox*vl=Rc~mx{1fe%VrKoJT$PBoczk%xp z5ZhqjM(q3pkC;3crqjzhvhVaxDlm=Y803+%#Q6Ma0Lr-N+k_8`eesw6mV9@8R+5qR z(TWmV$#vE5g6YWSRIIAdtO&ag3iw9&Id_BXK_HaV#z@vL>>ii1R2npx}OWplFo8M>GSynt9p>1U<1B?UP16|pgD_~LKJ89`pPiCq{Pq-_He`~Dmq2?1cQ-$NXiSn8`- z{R+W)0}q)T#if3^S9Q!LB~3DWmp&B%>!&hODnA{zA@RZ%g#cEl95PV36`Y&NBdQ6s zp$~Qhx08VbqOTrmzB8kXw;$rvOhJno81?n^;Dp~7N8|YU`2ni>@3p@DxjO>87?fGT zPI)|x%IEcXMs9uG-O*(nTt!{2mZi=2@cVm-e&Zui}0z9MOu7vxWvo3K=ok=)RN5*xda5fAI-jZs!BH zpRzA5L^yPc!5JAn8DZI2_xp?8NHdDlFr6;-Fr(1LmpM?KD@V~sbpsdoi}AuzpM(a zJ^0^Sb-H&4j#b%TP(cCsUl93;Fnn(ap2&*%!<;E)S|FqPp0w6U>MJVn1ISnZM79#I zhBemJ8K|p+s^X)I3nP7fGAgRDd2m@fAKsmVVIwpY>7D(V`{@+o!iSXpD0T|)qc$I- zLzx+f*OUJ#m=qocsq&3Lxjt{Sd+x3@2LJZhk;32I{UO!YAtrW`!Hn0vA~b!pI~W60 zH_orgCqPZ^L`-DSl$Ai0ahKOEx*HV@6rMY8M1(I9&~RGYXkddgFPo>9(w*0S)6q!< zOPXG)CSZ#uhhEAi12p%`@XSp*#~Xj?iat^!wX{WELS4;5hBS&6>fXEm$f)4sS!*0Cj>cIS?#`Q@=C>G}mqXnQm9_tlM zBR_rIZh>so#tQ8GKMuF^@<1xn z)HaU?)6-Kl_8l>&k=&PucDy+;xYTHNOJEeD_hr|H1&I*7Swpl$V!-pjGDD z+F^Nlz;B4Crv##oDz$;1HvUibC!EpaA$Vk(&_YFB$=oQ$WBPqEi|e!o#smEiV7-V<%F`<)v$ErahAI_ z+uGj#f-i4*Vew8;5kqUI4Z#pZ?@8+L@$q#_;s2FgT*#$d2L^RR!)k+0%wIEz$wqQ! zdZFMs-1=a@jOUDThH^u=&^<-7HQjN)-fnpR%o1@1aj~8d2vgh-drwaxuu*q)`TvAz zao}x7l*b=O44C_50#Fg!V#v(_{=K^HC)16V&J4UnW`=hh`mUMM=22FWF%+2?{-XcTI&xxTgd7A&IvBLUoNa3K&VprhVEH5c2Ioip* zqx#Ljr60R2TEb5^F2qoeC{zf`t7&)Y^eRPo!P8d_2HkUf2+(Q0CI!?6`+rP!1V@!} z%G!(AQ89M=n6#aH@%L!#Jr?y8}u=@@ij^^5TMcGAD(S zS3)8uJ|2&p+}6&#QMKGs)Snx&Rh*qosezBrwQ&1sv0YT`MSgDrSOI{WHSW50ON%cVFKoa6FnSFS=>-znX#6*16}z#iX_^~l2RM-^2VltOPrLyNHtcvN zj`$#ra*=S{a=@$dRiiwiZ?|2IvK?Seq(oQ3%3+@bf|%Scm9(#+KDx77)o7NaVUUXR z8aVL3W8>kOnVZ}DFTA$vK07QUGpx zezoM*U%{iYuMW2)Rp*?<2W-%3i^A+{WaecYg%swspM_4j;Zvx6EWy%fV`4MbraPNrp~fiF~#7bsEDYAq__>86S72~<&1EWikn0(QcEv|y>1z;IFM zSOIJK^~=G_rYxwV16)A`L49-LY{q}qFkg=RDg5Q>;4rl`Gz2cM**;nh{^Z|oAVG*A z3ooY{8!8`)b`N4v6fABuRen;|{H9g>`p2kfjK)-!xCX}g&$bh%{;2&^O`iYRo1a5( zqgzcN^zShIbm;+_ECcW8VS^(>Ioy-XZ7rFpPC)yzjVRd|$Y`%7n8wbt>2M<;&$sES ziPC)QZ;~?B#pBi29hYgx-q2evn%52TVOjkpP{`~6jYN4SN-i#zmZ)r1x3{jEwpMsc z0mjdN7C{I=r}N3Is&mVlDoBfPK2TCO%`fxui=h;^1*fN^I;^UX8wi|Ekk|m#dEg+} zoJpyW-Bl|EE;aji!K*XIcE((?rBtV&CL3g$&Q_s*a&trZaj5wWMJ_y&wiOqb{ehfS2q!rtM4CIMsk-0k=k#t-3u+r8+vmmi;2tbHO9!Gv@`O6J ze06{Toh_IEI{_6DXP3L4@*;7$CvHiwamYagU<~4eN|Vm1bepppE~TbJh&8>quGVL- z_I8#Xd*{-t;P|PEZ%3HSnxf!ZsysrdV5pIJWFoC%@Ed1mwzjsIC%lq6btEJg@;*Ab ztPm@|PH{e#+cC?Wr>D&)3TzERmXY1dDe||9;M{Quct}fgQS<1sNl@jq9dOZ&L(|?u z-GN3~=gWH-*HK>yFgbns1@i4_<34C`rlW^(DroTI>vmB*DP7cQpe?WdQq<1O$^xZo zjTrwacU0x&CByV|^iR+BTmZSV`R_nr^Y?%NIXOAV@6J=m{RWbh$1c_$u2=0rBw|`x zs)x5{X?@8_G^`PHBT%V=Iv^H;Wg;f0#dpjH^Q5UV;kmCx zJ6K~6T#+1}!D*rNi1l*O4bkRYC*D9VsMA4nh6m{uT%Ip555RE&8^PCn2e}bCi%$dR zZt~VnILYCd|H&|htWy^j7Mg%X3{dzWAk5j>cxwLY3dCNgblx>qFR!d{j7{!_Z5U;5 z{#j_Ep{3QT^fWLS`)FYXOQ00U$MljM$Gn;0Wl2#|65*7-S@XZ!Jv&yV59 zj*m|~3Fm@K8?nS#C_KC4DbOE#!wcCsgVr3Vxk{RvbWYy|Pm$If`rXau^nMOnzCRvL z*nF69|Ih1*AS!EsCLHp`sivX9!O^Yt)8~WJ(|X#Eafn27x};)+q_Yzf*b2^OW=M>Q zEY+VDtDa(>FD0N!er|tUNVEI^`fB{RL!3uVjg#GC*?<9Y|GcS^r#`=C70)hxjnxHA zaZL?B*Rr!^9Q!qxKsO$AbC=5Z$G%fIw?VtEsGhg}>h0+wa46n7xQ7K~XD5e#mbb&v zt_TbBc6Yz;;lqEU6Pk?7rZNb5FIiYd8?&P>)O$G(6mURr)*WT8qz6uva8tlXhdyv| zZPh<+Sbts&E~AB4%2n^iKf;0`6R>Jz{X{SBw_8%<5uLrZVFEi5clRxKy9 ze%*$iOevXdAMo9v%iq`#>OTWb@(?B zERY=FJ=}q7?%;som!zEB(DPsa=Se`?oOZG@LzngRsg&NlRn5I^oLO62Q=2>TuqY~i zems=uOMf2G`G@Bk3bz1Y)wlndKXiv})d&Qk>5u))Y)K!#S93$0c{Zscc`ED@%W~ruZcoCq3^N7+P05 z50+7|KMK^#Wm%fN!P-)pA^YP4k?wzo@%d)W@O@i?XN_r-XU!0?H-i~y)f$K*`|lP2 zaq!_a0byihi&X}B>ZJ-Xvd*~ZAvFtk_TqI$(G9tatgP(5WnSzQPi{zXidwJQ@S2hX zQ6s5poh z2Ywf@Zwbk_zTzEb>jnLS8u$qy3l$mZ_x9RCSU5Jp;sw*hQpsi;Km)ubdWI&P1dHV8tk~s>&(^yOiu}7#A0pQ9ioqci+Z!`oZ!`trUUbyLX6LDyWrusTr#)OIxg3h)k+Y$Sw8o5ci)O z>?|z8LjzzFcf_}5P-li-q8tLXQf7257_+Tu8*H>~ z^vc~C#5&|HMb~(qE#1_3AEMWEnQLLXd+*It%CbD+1$MKO50i{w`U>TzAKut$u)+xO zDa7)Hr|`$kEG!N{px=KdUri`HoKwwMjhT;B`B-&ohlQ0@QfC((AMWy|@5{{^}4Z^)#QtSeC---3d$xLjRuG@Gj=>g~-%P7b6vW;7 zxw$@HIDnfs!iS|C6$K`TvnBkCwWX!s)&EYa;oLsOLr_bm!EFv$Mc1Q~?Y^keQu#Gr z2PAj!=@1bUi$bN2Kq!`K31G=pG9RSL18>DBFV7545$V`Zj)F7SS~?a@KDd&f=rw>eRQ zhXw$Dy5D;1TB0l>zmXwcgsZGDC4mhEcBb|ITfPZ3`uk%H<1;m2ax(8eM6JnrWWw=F zR9mtXeVfP`2g@OBp0AbFZS@OT7Dn0VdA3WDMT+%r*a_mouU}m9TySG3#>SiezyEg0 zw!MZ~`}tv8yhD%r{%{mGvkP+CW@e5)qCb@9qLNckfDO%&Qp+O7sFRLILV$5qqIYce z7K?y+DtM3a6wZqorc~`t=J8IsD=oW8lxqVnz1D_B`=_2L4tPO#8Lp zfcpC{+vdoCsq^@lc`6A+0SddgKL7KLQ?s(SPsz!dJiMMI`TEx1U&qptAf&J`q_L5( zh9N`-40b@xf$(EXSIsI{H4#(c>@`U72^$^*A1b6Cn8Eq^ndsV@X+c4Y5P3W8l#!jX zvbR3jM#Wir3{cmDv-n$E%Q`o#+2axfkhDW>&G>|Qc=!Z=mxFFG{mnnxrl$EW+7G*x zm7#yUh%Fi6h$4`mB7|Z4$H&u)tKLkNGFr(%%C_&S8X9ZCE&+U4vgtSz*Rsj&Jm`SN zc`Ne|tFXccW10-}CBq0Dbw zaUiWo5Z%e|=W!4^lJ!lHz5q;^JHcwK?Y+G>4ScVqrKORD6>qZE4Gm!^@zXiq7Z$o< zFv*$UC^v&IU%mthf$9Uo-UnkkU4OI`F))_VG;ZNe4PB#=C<3egT~a-77u9lav-Hgd zc+Y)fUE|WU17!`ngZeCwGWy^Ef}F~!E%4GLB_$OiNHRo%Y^RL$^k{{@UGDZ+Uzza2 z-zF&FbeDI5luXf(I))e52nwB#SEJB{=4L@_{?|9GOz=9yhX9b!nt#iY(3Y0Q%ymB9T?O zDSsJvpCidVV8`$P5I-=};4l=lW-bQV(e(Kirw*-nd~62{KNvLuQ^Y51X#JTbu+8WFiCgq) z;|h>NcQMbuaHc~Sc2idGl0gT?q8uSSbLD6 z>%%HYExDArEc&XyyeDUeJTHDcXFP_ZYS@MX<#2ls#@_!IXD@LlqKygHG2$VD-0y;$I*M!HS{@S^kuTO-5~K>4#~IMiKj`SQ7L}iG8{}32KG&9?Y=m7< zaB04Of2sCf#pmk9Sryn*z`1w|?%^!nbCkew(n;)K%Pd2!Km@3t7B*UZb>{VqBBz#? zc6`$_P{|&lU5R2tL0mRv#+57=Y0IupdOUjm|NYY(XHK#nYkd<7jp zCMG5)Q-m-?7v$_Eweuq>M=VTC7kBprOyQ$1U!$V$?rvg7nI7P4gV4Gs5f zWM`*GARv+N8iIn%CJ>C=JwbKf;w7apK!iN~HLzA`&hoINj*leUTh z=%Mvf?lDJw{l$@Ekwr$R20d+P2Uy`92%EzM1aX$GMwlGrhifC`5!o-@NNW(412ZAx zLEv+;#h*##fbuP2gIYW>s`B7oY1{L%a><#&c0dbGzwVT8chbrzs>qYb!D%W9BWgD_ z(RG-Xk532byU6eUY{CrwhJ=~BzyXf%HU%=0xZ?7nfdQrAKxn*R@bSu?_bt%+x?(x20s1JUb8~S~;6Fjf zDCm9Dqi98VPqcT~hu0z7>J+kc+6P7Y{g*dw4D9jie5%u`Fam2$mTq^4;wog!@!<&~ z-sFg{ID*~7)7;$LacC#@)}Q}vJ>C1?7(XYa#^$PoLR#Jz0DDF&9N>^lirM3r!5dF_ zHx7diWjq0&12)PmoPkfOGw;(=7Kn3CeU1 zLBUtJZ}HwScsl?Ri6f=lrjq+|yt+zTM+b=LLXl8GXc%Zh_5ke%!-yXtxt`CN<%VF^WZMXo_3 z(ep*>Mu;Z384upqIYNVm>?iF?HB$k#WLb$`w5vloK=~WW?tqB*SF(;*fV2w>bd)=d zB9*;cg)4UE6Cu`E;erc%yn4Avf2Z&`6_TYKLF11Ue&F^-nvCc9w&0>S@Xh=?W~p;1 zu=Ok^l5dWg`k)=41DASO<5GRPx)Fy|6a@u|BrBZC8$Lc!&nt+M4i;985=_lWn~24S zA=2D&k=$Yl2#>LIr>*Ed9(j5C!AEuk(fjyoOsWG$d(Tk!TVF^S9EO+`Ae*h^hCnPG z#o0Mf5>>FVmktkOq6C?(zkMw0=%7e1N#mRPo87w>;fnzDOE4B!9~~safYuTyb`N% zGP)Co*&WWX@KzMuDqQ%54cx)3NFM`;lPr{mer84QFYc0DdokR{$6<8!v;Rj!B+doQ z!0F5Hvs-2%26%OgUv1{!tR1y@l-z`huQ?M`TSyRjFVH|=ARz!ZU@f;ALBq~%xlVsA zNm`neiLRtyCyk+e)}NAdDynBDeg+E%2iyUc$YD)c;^TcqWJoNsFX>FdevheTDJu|B z=;c;aumOFc0bN9Ngs}SsIW(~Q%gKq2u$UHi(*{4!Cwp1rDnW14pZU|cc{0%)xmuEv z@Gls{4+)6~y7fZDK-bdg&qMdW2g;vV%XfB6foYRn$WtZZIQB22Vq|2$D5U_SEE7R% zTMI}58=mgT1472FAyyUzdHD~7WB-sphCe~f=`JBhhM(8l(=szFI!{#w#UQvJKkm*q zdVi>Br{F~(KoW-2HD+243AG)=mv0u9!?;hLUb0W=jz?r0MgnH&UIiJ$ z7-9MM^UDgML_H8dZp_x04Sr*r(z3XQ2G*oic?IaNWq{i_dBl9~K9>)8Z;%Q`+dAQ| zL?LZodejLZU%9!bXOM=}UQQtbK#Ph>Vj}h{T>K*deDMkY0Z2O7*tpkBO3dvj3@u4> zMKu&{+glhX^vLI8%Dn(hRj zB%W^Za%l_GR+h?-el7gRCN+M}&y%fd3#pT3Ua03iVEy_zs+N)cAW8=ZL=T>;d^;mIFe(VZBIn zj5m5YvX&o#qZOkajV{YzwIo|t!k`gsKcyk9 zSP+H9;kai7ix?Ux*mJv0-*K)kE?Qcfm;mZ>>)IT30zh&|1HjgunU{}1Pgb>f+h)( z4Hgnv55$(g0XPzuw+)yxP=@kzv#WS1B`7lx0g;GKJOk8=O-)S&2O|kdfZS{mu{VXT zI-$Gp9yLEmNUpA1goKQRKzw`NGT{@V7&mg07N-` zBfW@XHJ}H?{-jRLwhIDXKrC5%9iUiNA^PraZY*U^?I|N8=&Cq4Tnm5x2uJq!(mK@D z?_+1=D-&Dbk6FFgFDRpvjs!JJ*CvoywN!(N;q^AH#hzenfkhh_kE(CJHfzX zXlGZMEdgkFP0dRFJk*MJC~V7dl5a{+Lx`K;iG;h-PfmanE zyYKus0sw<}$&aj>u;B&{qjQ$*l@vU4TeUqiRH2BkF-m6dk(_SI!`A|9Ne zo z(93tlv-89D`6-;#P_d-o4jtv{Q+P$xFhEm4BVC3qfdrzeiUW5QXhxMke$*!;yQ$dY z{dH-l>V6OGC^1#7#l^Cv<%qtbuUM(G>vp9kP=($%fB&wnrWPBQUBx#h*Pc50DBAUH zFJ$vya$NHFT`rO_T}wtr@S%y{F~yCJX_a0hzuo=>|&CJu0+$CBHO=)p3J{>6BdFP=rocV^~Av} zRDAC13lXh}lp(${+XHTTg?fNfFRw({Y&r_r5R=OCt6EF`bTRvId%lH4kZy>8@$CI= z-<%&O*_s(!>8TOT{k$h0fvAG{RfPTHvFgUg#uQE)l+6kcJIwjC$kD*|t6v)6*5XG0 z9PA!Epn7!+o8cs{nND6YuWPkcf5}n@lSF#@TStQqpXJrj$c%&n6+hZX8#A-LwH9YO zM0r7+8rrNLHAaRTI5><7HDhDdLiJ$^ULc=-f8hi$Xy}TtFko_4k`oiR!hmN9RTm%3 zlI-kkxlbT>5CDga1j(h>7Y>-MR1VahLR;e~C`f1Ai;HgEGyT-Pk;EKB(yO-K{qY96 zs6;`8={gfOlrBY%6T+wrHm^#MNWtp^Opb}!=xQHG8~Y@#mfVRuEUd^_`dCmI1Ao| z(G>C;v=2AAr|_q^aIBw1fGb;tiHQE&?bRq}zywpy4p)AQ6+1jhb@5(OWllG5ayGFfcq_o8SI;w#1dz`Q0(63=KR;D66FLe(T47oyZAW{15d&k+1@(7ZGSI`b!N;E*!8 zyVZkRSl9+N*7v5_Zo3EM+%eJBn=>&LkI|%a+)9_W$g8(D;o}B<5~8oakN>GK8zs?h zmC~)=ZtCF|B9URdBv7!PK}|vPH3_-mXlQ7iKAM}CmtIdnTG|tqvk44#5IH#)P0c{B zPp^h%2>H(YF%I*5W@cula9#ZK*gMWXfL>iEC#Sm=lXdTJs1<$iY%SDMZpnB9G>+!m zoT@l6AUO1f7EnVE0$a6uf-?cV{2te-j7D3%^BpqYu-y9|!&JK(I2f6dagYY9u7Q5koZ6 z1=9 zg?>HIuVrRBTTa3W*sr&@Y`VhXID!0i5KJTK2n_#cJK5pCRx`;}?3AO*+>52VX+qIH z>;qY{t3t?nr*B(FrJW>}kn_P;HO*i%3;QoZwSYQz7v;lYgR? z$|Ub))B;?3veU^ zLFQ=`7FJuv0SHlWyBH%;#E1lW_)k@cPft(4A;{bA*HKnxLo6|fcz1gX@4F%4#>OM+ zV`?gOj4^`_J@%kvOMI8+W%}t8Mt);WO^uUVV~mnpz6I;*(hpRS^6>YE(oVfKga=NM zVjNFjJwllarEO-QS17gR3o!|6=b5!h#$7J~!}$g=NGM&r)`9Di-%KV%Y4& zIm%BS$*tNHC9`8_D8<^*Dod5Gbv>xiMSYtUQ~+FF?t+vd1_lPu97{Fl^CrBoupf6g zaD;<{12DfpdaKZ}sfSqMeuq)>mJI9yAO#!n+g>&irKQ6h?QC3$m#aBXH^l&X1(fq& zG5pnuiOQYwI zI-guEN+5f9>B?(<&t^IGioHD-&x7tsL%B<3`L_+wbNT(`6C9>VznDB&?dJuksYaRb zl~<8d8)JCpafF0YBAW){SB$;HZ08q%h7$5<{E}hGe^)GUL%{;&Hq9^ixz@>UL_m0Z zH=KZkE}a>xdZqh>HNLzsAaijJrndZHSb|E9u&Yt~*HpvL96F^12=kqtRUD$CpbmX> z6vIJ#Z1;_=Dsq0xA*9*hvvuj)wnGDt8X%-aL}t6Y+dGR8EKKb)WC8Dos)_>8J%1`I z&r^WL_9QM2A*aVnUEka|xVeE_cVcv03;B$M7Fi*VYYaX=&8HqT&Y81FttZHu}QI3|?&TUmYsYk9uJG(bT}ua7uqGOh}0Q zZQcxRquBdb80hvihS-lo!$&Ix=;p#SWhGuQgN^7oc!7K?^*(g*LYZXc_k3p+czWJ>?w zV0i@l6eaZh%`}rICefLqjNS_9j!H<|K0Mt$+RC*MyaQrQ8_+7`R0sBjwKH;#>FO6{ z7b=wYcAnneeLNsYeo{^~CMr6VQs;1ey~`bEaCcoAgs7NI$C+8yYjud&p|mK5q5*Yc zYj&IHTQYssKLp7wOCnJEaJ|R6h#f6xn3 zd=$#seHo(FvYzk*Co6vWZ4exzr-c(hWvobNk@(?oMzwd)Jds-=%32S5IHq#=R%QNf~Uw{Hq-`i!(r} zwlcha^{U0Wy0UCz>c(q0C|qkzvTupV%E>)_mw=CjRQ-T;V1&!<*WcIY&!e|FmECD7 z@SA3b0TnT`0}x@EhgQY8=&H8aE{{^lg;LChDLci;Lf?Qgydnf#wt&16`Ni{f=Nu!DDI3z@1bG zWP7Kstn7VWB682gCA>zzz>L^TH7dGDmyp0lA)d)mPaP^bEi|=`g5zZ4vUf*1?|yh7kPR{=;xX46Z)4Z)e#QM=!0LuB z$ez&Sf3QAOk|HAgZy|I&|9a){fjl?w0hECb#U(PFup)+($0;LrAEj1t3t&TExF|d^3|6n2-kX!c|jL!WGzv z^t?nm!>n=7&@93W3-EhHW>G2nJAr66?-_S(Rv$C}gNSR7)LqHBgbs1Rmd(!x>b&nS zyS9@v^egyNa1u2xPTt?PzqYV!rN3Ps7iTNqD;YyCLZRMwE?0KpZKc0?b5OPYAw8X> z-1*6VjuYfO)I|}1np*SSyW5=q1{R%RQTo-aRyJGvsRBs6^YxX$rll%r>OYBvNN*m{ zNy~^k|2%w{>ES}P_>N1m2!lI=eW=9n6*IFq;jz6vFhMiC=ly>%z{2sRxbZ(MwruYeK;yDU>*?yY zg9F!Ma0=8@{{Fbhp=d_e6pY)_&BYZIbxk!jiHg}()s^>}>fufUbPot!Q&UslLG@Tt zavw=2-Zj9)z%V;AQjrjJ!FvnVE>}n{;jik(K?;^hs!r?WYRHGIRti*lI#@&iGyro{ zMIrHmuD8spa7#D06n6{A!VZutJz^CWYMU~_2UDep0LdMR+#2DM(qE32QF`h|Fdl&C z3K(7@9na^Enwrm^g<7~NXAT`eYLGo$2`U>!*D1f4aN*Df6`-BNje@tb>lPOX18 zc7G2K$1$Rg9$Sx#a2*6yG6k{SYAF>wi<0mP-7+EUibM4Vd_ogb6AVnu$l~K~_<&WI>Kl!VPbIXldEs#Q_W;$-cYlsS#9EV@iI~%VdUC zkG24(!}7`DBdSTOO#eiMa8dd7xF;Nq&#i}pp8LvBd}UV|ft_s1sF;a_Xv{P9wt`=& zm@?rtr?XGC%&q4`ldZWTZ_m9|rt8;e{kT(7kvb z?}K&{^eZ-v47*hSh5S-gQ&W4+C-8GP8UPJ!4|ibKd&0&R!?qukktQiA0hrtBN3;}b zP}qmppXWqVkE-L9Dg+bFPEG>yG7wz1@M0Gha)RTYI^f(G^kYZQpM`mwuWxPJ+e2(i zeO(=-n*JF>dj4`26}QfQR2}R_MMkf1%)=ePB`qx1bQ7hIwz^MkxU#CRHk3Hm0^WQa<~BxPtY z@5yUzBDCn9S%a1jsxM#O`UQ!Ah@K+|D1*k5Z$6yP$JF}^WUU+t5}qu z@9gT1s`~bd|Lp~mJ0r88iy`BI8U5wg;$jnX^YFg6ow{xpS-2#O#q-V0zlo*{>!_H! zw|j69+K&Uu;~Nac9btJ0cVE~=`Qm_UYObz_JoPvg$$db8=E1_MgzQxxVCRBL0J4_B z6P3}L-bd1XFI&H&BSDBQDjCeBl5y%Rle<{nQy*faFA-^FJy1Vf$2`E^)z=!>Q6a@n zQUOvXhGN3<|MjyBY?e|~t)LNvyt^qW_^}H*ZBAb5MPuscc_h;RT7Ldq0^1%m6u2su z-w=|Lk}nDKr@{bAu<)7WBrD_N>FMbQi_dxCogiAkN*U??5QYtRu^oI0JyShBZEXvCORSY|m6eU2hnuHv&ta$&g-;Ov`t=c6 zS(7+09xquwo+nVEq^boO?JIe<#I0-dRw)nq=v5iH9e;USKGmC?;KT!_iMgk(?BWS0 zk^n1yQs5Kd`0v^{XS+dbAy*@dN)VSE=lNU^aKmESGlUIy+KQ zq?9`ill$QWi^~g@r?Bi8Jd~Ad#rwUvWhwB02p%s{0x3E~cJbPhIq_IHoesy7#CD8I7 ztAXXM0m2?$62QHb+VpJD=!99Y$wkkU-e}R+_9^mG%*;WGfa#H35+3nKKQ zCnN~ajGHs1gTM#eBpXQ^`DpR&aUK=f&`wh^8_z}N2sYN6FybnJ@fBoD@Ex9=olPVr zf*Vb{U<9HS7RI0K1?+}%MSCB?=8S-V0Om4KNy5(DCO^~*FSh5J5LT1qYKOh51?zm9Jhq!POCQwE{)>MDbt@x5A zh!Wg^K3D5w8fwrAuQjxB8De1Q1Vs zHtWwuj&~j)4}YV-P-O`un%#+OYHX z$lbcs+hET;xo{u;1M_GvaDQKOyBZp1CjL_f>Iwx)DlkULA|+L3Jw3zmi=31SmSZulheV)qmy z?*O8WS`xWIha~-r{N456RQA-Q$6u?sZ8F4K>^+c=eEO+42)~Cawkr_xqOOoMAZb_| zSOcN@Qy~%@w=g=>WD!xOmNj6uoLI&2-8y&Khu0KjP}Ot3zvXCyv(A^9u1*#`efHmq zz}RaLlj@WorWE;YWBU3464Mm`0G3=Ny}ox>qY`dfC%S5ey@^B~;*LWGS5S`NYttbZ zgnaq~c$@+b-tpB(ER7O@K_0)?G^jp;xmgIDiTZgVvJ@J{*IzjGxUaxp=%%5wGgign zBM7vvj!~tg{gnJdl~{BOZNw&EKo?}=x;bDc1TUeG80OBu*XF&HU!9{ef+q#vH|fkh z(F+QjihGpl{4kZCSm|G&XI1n^9dJS(Po}qr*CZmO&CM@vGIyb`(=FX|3B|;`{tPD2 z|ECWm%wA(XQ7ELn{dKHKmz>6oSb2bR>+YK~#-2pbhuAtETW(B5B`4+>2jvKiMQN<{ zxw?5U(9!*@#%iQzMV_8`$M`+`KxGFi2(SqX)E(u^kY!@qV>F@VX}_qmP~C(~oS-bQ zexYl_Q2`_nNahIl$))~7$x=~K4+}m~w(=YU(l#Wet%B22;r00=jO^`Xn zR7m_)Cn`jPVI4Uh)~vXS3qLPAr|NDi%R{tBx5*-5?oQGX3Wf`O`ru8`147Yy^2x|) zSk*yV=$x4u6sq|zA-y4?rz896UHl`hwY6o?Xt&=KD?|lWK_PG!u0Khvb90;SEge%v zZubuZuXgS_^OUHN2*286UwsUn8Th-Fp85+4}U`O2F_Bmwl#)wZz zdGTB+91eqx!MZEdmr4=VJnqI!l5Q@+uk@DW@#f5LJu#la7Wm5>Y>m$R-5fkRtaIV) zo9>kF?=Muu1eDFWjmzU1)I4M1nj{jV<`m7Xp{h>iuq#tTzFvuXwOnKr2{DBxx+bbl zNaSrjrci~=R_Hb<@WWb)<@S&rI!m&lp$rW4P&-46drYb$RwB>+`-}aVSbz8bewUR4 z^{Lhah_tyHPQM&!U+G^}OF+Rzad6nxtv(muWeTt>+!SvM3l<)p((J~@mwxQGg?c#SNjr*SZ(+5kOZ8^; zKKJP z^h_uv9i5S}PN#UJ$fI}q zU!%(09q-HPaY;I<{cTEXH1plaag9}m$Mq+qs(sNpLkhONjHJ=T5YcNE3an19w;=Wym*eJ=1jsm#KK;Hs9JRr8#W9jD}k-eqb z_lABlDkvviL75lbuJwHS8GeqBC^yUBw(TcLH?RMcu_y$^^;p7!!Va0gkg6 z++m}x6Rc&1Kb!m0B&Vl-W_6}v#wTsqT2$I2p1GPkI5^1kXmNbn+1dF;iQ2Mv;Ns$h z#dZNiamu#+kXH)szr(_!nI;xy#9FDuBo%Nig^aHNc8edP0Vsm}HD6r)A4KmZ84dl| zrk_7=kWED|6t1hG8r09_dym_K|AElL0&^uc2K(l7OyueFI4#v%KR114T@|#3QI3_^ zh|thb8+ZJm(XYqISVGdQrZ@`f7**AuFf`LR+0V$jTThyk5QM=hAk53nT_Gp}hrqB+ zMSea98WsO}VRN%Igc|3@#@448LpKeCosTin!ocP79dY^L`|pHbY&}NmpVsZ0fN|b5B>-O&h0#<8Xc&=GImi&z{!S zF5Txn-Y0QQUlrclTe=_9lf%wtXl&$LQ(GV*Dk8!w!kdlw#9^;VQOO#W+`(j7B^uy= zGw;)DcIm2;uJUA@nc=?>_W&Vvpz(adHQn%&;E};SJqGPz0w!oKUI*}3foR_LndUE1 zn%~J@tXk>?u7h2IM4aqooTce<|AAQGAL1XIY7nyexn2oQ^XkSkO zO2zF4Vld8h>Ye(T0NNNN+JFU&nI&r7u&)`C3KB6dZMnb&PNPdTi>z$E%Aggg?PaYo=SM z4wV#g0b@K!A0{s+w||jM-?_#KaJ+j1Vx}%h#Kna_aJ&X_(}%p_atc4X?I#tel9?~V z2$u6&6Q1ZUOKVHKlYi~)@_;-69VskCWSO$Up(pV_%}KB?E`eM>iE_Ou23I0i!y+}q6ND{k8mB&S zUuab9Zr5tbptQ{vnrJF#77DyoPr8O{5Bmx)Zvq;1x&O>2dls%9c|;QuEJ39AmG+rn+5kbDvN~DF1aqqq3O{a7_Dt@iTs2gJb-ABt;tX{A&NV^DamxZ$tf3m zF@X&}`|RscpOfvZY-!2JWW9U7{CI9`JPj5tKafUoVq>3zBjH#7=eN;sM<>Hv0Ql^q zpa4=6@M=QkI5adQNJkWgs;n(|Wz8ssbs+js)bFGf7X($HCotimzH(AlHRCi)dO4Z| z9+_X49etgWY9y3>d8z#_wOHS6h9a}pfNc!GBRId1h6QxY%s+t37lKP+(Q~ z*5YZJ_O9@R>#US=AC9w(M2}$;J-&Stx2J@rJe^VVAaA-lbMCZgako1G`hLjUF-H7W>BC7g+qKK{f10?$K9X9li!o$PY1>q z@6j548TUlD3NqZwd5co=qW>PM5A)f!omawGNwK{u+>AyMJf%dvR5WLu0K^E%fzGBz z9}$3EY|LaGYm4|h`yU0zYVp|9sEo`EC-!EqDZx~_WG=GDtlR}U!}Yo5oX^eCxd1OH z_Nn>U@Kp=mvpaWc)3zNPq@<+M{f{Q^UZX~8f|OzGqGh^jAHd=qqL>4H{=IwmKo%I} zVP~f*LQqv(o7B^*=*3|opZ;8L|{s;k@EI>ujg zwZgMU)kyLezygIi!&WXQL&1DM(p6(M%k(1`xvxXDg9Oa0H?Jch`n+?fIeuWS<V> z7K^Yfy7>(_!HM6M)!?=R;xg0vE=bMLieY*VJuA#C&yROwVq)56WX`dWYB-uCuyIxL|~cZA#J7+Dm!`t)K; zOqnA)lcbkb^MuC+l)!TP@+S|9tnmH=DuXhG@Uy!WcY8I!z$3eKWDp(zWhCv}3;C&A zeDndze6%ARH}O%}g=%D#Sg6y%|3I44#QhnDzec8y0pn1mUWa>OF>p?TAkiJApq|DO}#sEav@2d-sPhSwQz{GfR<@=v=WpAAe0#R z#r3+3u`Z(|Gv+=}vTeLM=-!S^Ppioq{KS>tclY#!k5l^ftCOQ0#sYEA3V{SSG}Whz zRKbR>L2+jDw>pY~>mEhp+^x-Vbp!NH5T8>yLxiAwxX%ewsR8IYHrJb5CUd9ypeu~G6K|K3CF z;(f4NEAA9!1fhW)?kWCrOUo@D7lsipIsZobZ(p4vvn$2cc5dKwh+@YneS9-Wx~E+* zn%4dq1e)tIB#KQ-Q$n&`_%wwAL>L_>ZP8GXq~hO2Zwqq{3*u}pCQI#OR!M!flw}-Y zD|+at8+D%zQOEMOKNmVSBUl93x@<$~xVt?N)b<18$+3E3Pu~3)snN&rM z*BGpk1~Lpgo13tTKR)^k@CDrXq5P5fHS07^?HOrZk%XT6JUjtc6Z{~S(|sWHasoyS z!otGePYw?EY=J3zs>AVVBg^v|-PDXko z4E~pZDF?4~fuK>X7M_CQV+~NO?5wW`{qX5Wi!Q7g54~c z%t)b4NkliA+Ud=wKy*}5iFBt5^F)6E2_RKfV=#G!4`44m{bNc@m|YR7A?+WVJ3H^9 z-yZ(`^WQ)Z7j5ap7u0=dpz}wsc$NDgc8@%~UA^9$o#LG_rvWwki_XzB zmA^u0D4KdBya-WB9 zd-)T_D+-8+5M)zvoM2x=057bZh%ZA;s}vMjN;arJq9v=ShY>a+OAj>4Of zUs9^`ojv;N#%gX}}H{j$!E(q5T z(^$T1sH?K`A4ts#4vM^S1GeaO4;~X(KWP4P?SkREz3{Um8ssZ>LnYx^T*uvR+WUcUsh^{-Bx91J?snU zv8CgeI5I6#>lsnR9pRAmgza~ER@eRK=jCM+Sg6{JBo-f`sWFA-$P8H8ct7*-IPBjx zUf0ZU8@;-Jn~_L@kFRB_8%~Szrlxltma?Hm1kXtrBVJj>dmiziXYNg6PkJz5&yu5r zo;KjPs`jzifQJJ*(XFaQN%pa+*#SLtsyCPP#CecFSci>`_2p;2heu_)(}%Rltzz(x zG~%jl7(9HKil1cZVRV3OO{}PSS^ce{LHG8b!@bD2kwfmZ^nCiDNKHyA2oJ}7s|vqp z{btqOYI_IAr2roDhKNEd2Zz3y(ZVBC1uUY#4g9jMUdBLvah(oGn02VRSQk4PL&ay! zCf3|S)uI8C++62aRG(CQ{lE7AYPH}x{a7MK1A<$0gb7U1P{qZ?@=8kMx&~aPWKZqw zdpmmwgid^XEhUlLC1nIK3?lU6QtR2;+5&ZhP~gPqLk+G2s&i;V`xg@eshFiuKSNgg})*PX7)Iw{A>aacE?f0Ht&c#P*^#x@r z2rTVv(oxYFRhWMG_yMAw4*3zPPxG6a%!JFrAh{-A845#iI5{;Q#=|~U%a(eQN{bTq z-*CsTk3|fjnW95%&cA>Eq_0i~0(~zI1OIgf`du83M@ATHV1Lrba5gcG+ZhsS`EW@~ zK_kj1CIxt+;iDAYIkHbW)+mu-S9!Lov(euV-<8o_YQ!ba*o-QohE(~W)*W%m?@Hp5AbNltK z@p$g!goc8}{r4MnU*;S#QbtEBTjra1zAt^X6o$^1eyRqBe1ri#_>9`7gexmP8<{dS zALl!rKArv^I@NgJt_l!V3BrT(S6YhS$|ockcNaZ3c6M^LKf-9Ura73*k~{c2Fh>SpK+i2|eAhx%8qu>yVnvii1?NS(Am&aWM%Be3}VlVI~@ z*TABQr7alWp;PM2Y8b%U0Uo{Z+E zmf@4&&2Xv53{4~iM2+qn04~y1@bNLU-KeU&kWbBVhTX&8%eBGH?46vqV_~=+<-aL$ zF%YVuGefpr3gm}Q!>8--=@AFJ@2;8O-rI5WtAz>v zOs)JEYaFd|K;7R=acWrH{gsf=W15(5uwVWC+qasD#MV~y$?%X?9ew>=2&;knO=x=7 z6?Si+GgHR3dp;&|>lfquJeM15_}fcKhWF(lMl7U>c2+}>^TF-^;xV~9%4BQf+z$8= zzLQRis;?BY{ZAIdJv}|E9cTS6D#r4l`30|US z+gjW|1qplLNn6iu(|$jo4V{5T0yY&_-K9P6y8spfutO0Sm))GUM40Q&R?<|mUE&rj z6ptZ}k&pXP}EsUc6uxEeLueZGKEo`_5C|A*TEz=nZU(;-~U&d zbdP@CYPhk@cvN4Nz2B%%+)EJww#Fur>@w-P8bzgq?pR_{RdW7(SMv=R=&hnwa(num z&iwa(H<@3VJ6`?fGBZC_8)*JVFy4Hk7Sr6WNx(}Wi7epdBX7;Mb@v668pvfMm{~;= zAt#Qf03AEr>@Hj`XO%Ao^WMHCYCh>0cuVNCp#0&%En3>luNTW)U)wu7Zj1_l0uKj3 z7}68p2c4hJ9XEx)YoF`aG$uJeiKOWeuKEmRNz?KA-ez_u7YP%uTom)1(1Uj?bzlUOmwmk8nve%NY*%``v-hSemL zj}xLrc!bBsJ8}D{5)UCB#ri`(FLS(WGxU;1JFvmsdo%n&;t=-f6A!o_n0T)TVF!Ou zQB_S&OY1Q0>+1(A2ODd9^WSbJbq)0u{U`F|jD{~+iEcsY+N8Ds5V}YHk2&hWEjLPU zIUCjbff(c4r<+^Q2+G6;XrJ2*Ub`vnT-!7C_` zn$G*hVXqp##QxV%&L13kIJnrfw`dpZo@Hml@ZeKi+-!sG*2bcY>l%cJzVz`0cp#%G z#zF2`wdL~{=Su|5KwrFQB?)le-i+fJ&3=!|UKoydiXW82#G)$@?d;=I3nmZY@Dm*e ztXlHto~Y`CHM?+rJ}If4#l^j@PNsyocqzY=_o=1HbhkhNz)@BPY8z0q8*(!|j!k?2 z-ud5&l22{z@$RhL^9z7_e@pDuORDiOB+)W8We|FJqhoG(m|UjUg@81MHoGk-jTw*NQ?N1X|%?s<7nkZy2cFuHpgRw-Wa34xb znCx7mcWB#T#c#?UmrsEjF_ixGR%DKYhi48hj17gNZ)Ih{jE+bo(!%dwR39azrm5*0 z=x4Fqff)e^tQUGwZ(x5cF*6%%qBWxs7WOnVlMnDuQg2mr*zc0J;q$%glEl)A04tpQ z<>z{9>&^McQ2TA@d74xrYSvlshsiD6SBfJB<0eYivX-@;{fLN?|mD zG@iNWYRf1=sf2`t?9wPMR5&gh53xj9CQFILBgibLJVtwvk(--amCG)k(pXoQwcL@? zXYKZ_Tt~--=!1zq%pxFyTToj1aewC>&4szaARKW)K~{$~kfMWd0TjAGRh&w`Qvg8A z-_;}FlY$hm8+yE>d^TDw>!3U^{Neleg#S;^!1(b`k2b;pg~@eSRS%^sR1)iXT7QnM zmROjUEuELGa(s3uW|SfcmhVs$+~6|zGHfd=tFrEAdUkZQ``MqAxwdffq5f2O7vFx& z3Y$Z+A0gWjj`x_QnsRcm9Ucm@uKYOsJux{x{Q`Xbp4)4iz~U+j;Fo=9{pCS?LPD_P z^MTKL^ZbJ|BUlZfTYS`+l$KTk2}pOfQ@b%oVack{g29uQlhd_5f`9Fyq0O9-la>7w z2og^iYu>p}MCoK_#|ag0alTeBF~^aqkPxtlQf6u~E0RBd=H%uW+-sGQ9owB(+6&o= z_G$RM<0xSbi9$uu1gZ!lX>_yv(%VK8S>IUkC;lEDI@sBN%Hi^x>!IK%0dp7|8+N6Y z@A-kH2_DVt^nUF!5mscLnyNCYtm-wTi1>pC0uuB$H45lc*&|US8|phzs1E)Al<;f) zf9u0Q$t|Ar5ic%xzVxt;4ypoquBa%Vkryt5Ly(wnAY$s+jX6f%74L-HaU{OLh*RaJ z$Fh2r8}Ux7&(I!}F&~b^OifK;5NAgEHMeeReqdm-E3$JL<{oX1pY_Wucp^{E&-(lO zf7(<)Vt_!dC$VtDLuWJKrhwiE{N()@RPJXD-vxP~;Q%OPp@x+ec8me5*O$0>wCIdi zpg2xUq;Z$z5_rHlsIu(wDK5TSfQq=Zu<%=TIVNpTX$!|vz>9N2rL;I0c->Q>r?jIZ zq;a1l*xv_`(ZSJCZu^fcS=m`o!?Cinck__HG8mj6$Hl=;>Pi;#wrrs0N#MHW=JP%% z>^qZAyfmKCJ3tS7>|u{XdjhgqFAvWp(jT2aY;+4#QjE2=$x7cD0M0fsHMRXINN0cS zO4?})uWE%$AfkvltD@rER@P{mPL`t2D)A1#QOC+_i+pF7BQGo{c=BdRml%)1t%-kR zX@A7_lj7Hp_zI#O6JXYun(k?4!jpX9=IZKx*GasV_3qvBN&AA&Z{ED=wJiHH0^uKz zRn-Xz3As7`>)h`i(t|mHuB9ck8uX@%tzepSnyrfiN0(jX&IKknhJ(uh{JSW3f|e}p z0@orH+4O~{YO1Okw9xbhjiB1UfBz1pzFE!;tv-`vyqaENHe>N~8G|i`J2TA9=NG$w z|6bo1v)8%IgM}#6O(PQaf@@5R`?# zf>jK8S~D{y3h`4tHy79cQ--@@Mss8oA}J77rfF%e*=iFiySG#); z+{HrCt0pS1))qk4qaZAaKUJ{!_LhwaToE8g#VTRv=YMKz`y{^fQ7T$2*is+XS(GKh z8{aa&x938E*Aix#BLqKE3IRq|R#vS4)>k(`s&R#o8HM-`aD4hC%@Dl@&GMF@u)w$S z$}onL%d%%O!NDu{9bKLkIh|&{VS1aKt5Q}jM79y5V2@_o{h?@^4h8ij zAcT4~G$0p?g0`rnQb^&a;tEZ)W?uQEVe{3+F1j%BMury7 z`n)eS6J1?5zPJLza`hh_2YO-w%s1iy{*pet?rv^wZXrrJIt@tC@#aepC#T(3G^%_a zAt8|Nad~TyFiN1EpMj5;Rt^2u;2n7dMG#qcOB#UQFE8&o!203Gxqo!P#OnG9P}l33 zF#O*N(eWMXc_&+}6W_M@=virg>?dtT6rifOUV)#HFKwpXVq2Il>!49_3oYi7p@7k%nvl3c^@`f zfZhU7yufF6c49yl=L-@N7k>#4hv{NniI$eOCK&hkZ>(oBPq>;$g;N+98QDejBOGOK z-@I;B1od;>l4kVYP!@W=C@YupzVeS%{<1tNe~={}LiHgb0f4(8fE=;EuZs3!wgvfP zAzTxu-26Ps{dh^FiPYyeV4ql$S$g4~WJ45z(NWpZ%*@lpMJ8ckbJN1Xs=#^?(o7!Z z$i7|wPX`SJ&@v(-qWe}WQ#KVtDLwTD@ETrZE31F)wt+RUrt)O2Oy8d8nzLf6f%y9%80>1abBnj3z3!8nag{N zs+v{tz7A0+3#yCo`^+c$#J2gc#0j3lw&TtfJbZtDhKWDn3Fem_Fi0D}YsC$!-&EDu zG6=<$d3Bu&esg@iPHeOFgK^+{ZZAyZbQ@h>Iy^cb3t3r6;67Vcg6GiFvH&IQmsS!7 zBI~BJgrBo+<`;#XNe@u8$T^uF$SKSICAAqk4l&8?I5ztF9v(u1qP{|8Z10YLj!r^| z>8;0^udr~N57%zxQyb5$l=nozeWgRa8FXBXGeEf zH2#^M4`@Y@FjDM$qdEsSS1SZRW0=d_-*VA^RfTj421@grd0a(3HmHHeLz z3&iIX)VGQReSN9R@rJzNvCexhKZY=*D|K$xpwjB{?6%HMaX6G?%YwE5(Byi9Gv<8@ zJ0S^)7dS25-QAs?o!#63P{(})tlFEyS#h$xFi81iCMOq4Z>pfA)O`BmRvaZImMLVS z{{C%#bp}UQXXg(~E>uYg(R%_7Jr}b%Gce08v=?V^Vn>5+9aC<1Zf1tiGy}}+q=;+K7>uGk zWZ}obdv*>kKDdTKk%I5pIxWL=T0ei$-!WO6)zDC0j%kYjM}bGW5&}UZaDPWrnd<0} zLkjYN@}VR`o>BbXBX{=-XzsYKS-snvODx#;KrIRLkPgkp>b$$G91;KR2UMt%;bf+N z*JHfWpLLe^ekuTDYsZx4#hSMnUmb`FjO+@P5$u|sBtR^njw~!H zbpBE?lc7!Xp*N>4Hg}N#m-0N?%B|{Q>4fUHr)7umq-}1yi#3A6+Dpe<7b8AL0yzs- z2^xMFIB226Q6_(P3_Ee|d4G#ZlgGX_7Oy}}8Hmc>O<~w5Wu@$7Jh~9VpH$8tTJh4>3`Y#{e zP>42mDZaVw4|bf!^Y=5dT#rAa$z%lP=H;q-OSt=G5Xs5Oy$^@QIWf#}z%w5oZ`3=I z6I=ZCD<;FA#BZsuUTSJ;zODs3eHAAu;x_b6@E7vEFUZg(GS9l~9%@0w)%`f|FZmt0 zHUM9fe-wwDw7=KaC|?w}>EZ)M`WSi|nidQGQ9>;prt3R=z|V8)?~W;&NXwHth+REL z7Movf8c1Ib#n=~@JT+W=C4F*v9C+Ge-mQVnhV*^c5OHH8tP9ku3;FOOp(fZwl#ucynv^ zwPqu`2AWzre7!AG6BFy3o8Jlae7}gvy~@Xd3Ieb$0X-9-{V+%-rnuli(EIm!HSII- zQ4znev-dlU3H%3R+=H3+N;^%^-ntZug74 z^Pe~J;0Ml>BxXYrSSf3$Y9G`U(1spj8{6Aw$l~DQhVnsC7~Sc!k&|#aesyLJC*DuW zZ-CsmPE|V_x%aX{gZFF1AJizN$GGJP2M&QRntps(EiGT${J`U*r%;WX&0n)I5hh?; z=emQb{%`8VS0c{nx#_TsH9--fjb4j^Er-vXdd%BVjNB~$U0m}#flLkH6s&U)am)`5 z?UBIO3qP8*`KDt@<69{qAsDTf5nu+4=KXgBoaaN5fIpZ71ko_U_V;Chpe2)4gXVv$ z&ETw9j`Tj)2VfH8^=$i(XN8`N7c9Q$QM zLuYk$5-LnSS96jUa%^v|!9qt{Z-0+p9-O_nI%T>FCVq@-{+?a#m2b-#%YTi{%}njZ zoS&5XXo`o1o*bP0>QCht7JP*hPxK3eC8PfIsJhwz-<>k3;4Tj! zi;8aJmZdLWUc3xy4kz~Dt&GQ?7k<{&=)UWwbe%9Kr0f=J zgc&b3l-g!ZE*D}5bfJ^7cq}5!?wpsX1412iPJF*B zPvmRfmzB9Zm63s%77&B==zG0iT3f;xcIIU!Eex5tnw&%G0yIt#hk%kSD2K#V+9a4W z==I{BH}Eez$Vl;fkj8EKZ=<5XxQP35!#d*)2u5)cg9A-cQibny-6FIa@MhazK~xq^ z`&YC3y#omvSPFb&fUO+8w#VF-1xiKIfK+(}>e1sbC3ov!WZruB4z?2KSg9#Q@pkTV1pgVyLTzZ<+_R7M- zZ}70Lzn9HsXJaGdt^1a>1h1IU7nicVCP^p%2SWMp7p?tRCmvX#Ge3>0+?Z9xI z9&lz0SQf%CQ`SzFv9s4XT%Q%5I?a!cvN4#gT0U2MkPN2Ra2(upDgV0WuTJCC-=pan zXv@mJeJd~9SYN+g9RKpg3m+e!+1c6lr*QG}+3=W%N(+kCBoN5(CZ;4!P9c_M+sV+? z)S@NKVk>s(*LQJyO>3OdV{+}j|JSc@{D+yFhMb)I?%lg45$laD4lVO-7{$;rTQE9N zzYy3WL@eXX@A0i)9$m%m?414(c_V$=-q-iG!=kdPDl2$nSa2O8E^%=Xjgpc#3JpGv zaA>rhOeB8HUIulnBkir}=}A+7U<~{sckpp{KRAXyN~HO;@4B)Vah$2)J-YbwbPht8 zY*!=u)1?FPf;_I8s?eg5+`vx(+81cJCIzZtTrMmiJHTl+IXgtUNxJ$bz{Jxm(-Xa@ zv9j_@4b3c5K5_L5+*E5t1qHFfJbd~x0aE|%0!#xI2P5twwWXNx_E}F>PfK-qm6ZJs zzel4LJIL&KJ82o$i&R3u&4k4II47MQjN3BH(I&}dVc%hAkv?moYg6_%HIKn3Z1D940+fwPPp$# zn({a#(<4bkJ|@J)1pqW$o&95koo;7)XPEPspn+!ZMGUj386!;yg36Hm^k?MrGrCW# zbd63(zNdc}1{{J$5Br?x(j{(8Q^%D9a>vn;SntVoJ%4@!ad!K7;28=@PE0~16Z`@j zg}e6k4nGz4kc z_7b#b5xa1Bnu`X`&Cd^XwFYyPzC0c?GEN?SELM0A>3=Y!B>!}Y3?|n#q7Qw%Yf@&K zOnE-)(U@9-b<^Iyc$OBY4jVB|?X6EX%5y7|t=?QO`8D95Ju0ekaj|`TeLcOrmTf6@ zE~VqtebAP;xqE>an4FZn&{tr0H!4UWLez_ohk^#i29ZBr6WlvYSRiJjHo_ysdlc

            !)!D_!e}Gc)4GT5c}TAdI^e58^Q5b)ju- zkd%a(>yW0iaL(gbA>SprfukRvVX>)Kj92Td92AxknWqJ7faA}r=05Dl_d>s(-1>Am zJg?&A<@ejTTI#%adis`Ln6hBuz)I=0>0=&UEh{aaihAGGO(nj17!Sq5!jh4-hfhzx z_1N!k*LI4?soy1Ff*x}?SPV%TP*Zz(Rm1&ng^Z^fcanna==S#ZnXRp02d%&Ujg3>- z+z*3C{g=-Uhx0VSo};{hk1he}st+qGq80c6mdn~OJH2mV?4i(tF^m^9b|7w+u%}npHECb>IT&3;g5o>D^jMPRT zUdgY{>l_;s=4XEDUM~ja(HCkX6GTwl^3ECn6TpPNRF`gU^YkesIb~-vP>1Nf`ud-H zkzLD&#+!_jVEZ)CeO2D4k`8~u(z_+~U>_R4!2ynT^)b)kUMb*T(!s+FnOA zjH^JYhplG$YZy{_jz&YTNA!`n1PbU&%r{63m{1vgPzDDvyrSc8a9Q52o~yI6KWHs` zW;!qxQq$(>)a>@l)5IjzlibhG^Q@veJp5~QLd-bztxJmCSo@`c0nezbW8bQIwKbX~ zrySh#?$oy@-K{@<{5h)xgb*6bF$oH|nT`-Kebh?}tTi=iUNSM-FhZip&tXZinU@8E z*u^3L{4%vT{H;*c9Xu-JSDrY{pT!YXG=*l1aF?~qVsmVS%Zf@u)u5z>df`TVnJaE9riX z7bos9KK_Eu@X$t=Q)*;Pll;0mF%CZ1NNWR9q&ux2 ziG_oe;gGK*LxPPOjDHj$Bs6MlY?K&tJuQnEXZd#(cFVc>iudR2_rR0zX@gQM92_ut zV8#w@Z&1G+>)Amodc@Kv@ZCb-9);?@XVB|9vH#mB!%Y=l2x zz2yrA9?dj~8^)%EKZYuv%GgT!PoWc%k{RBGjdT<~L0W42Jx^*7^4&oFF+*mB7R{KL z!mV)O??1Gkr319~fqrZF@!PHZ8>T=pI@$xUHCs9@IazjmW_(&Lhdo{VK##o0$ivOx&i7(IL|4O5QG4V{5d-&8Ny-m^+fO(KIBKThl`u#mzJ2=! zHmpH3owgr1cHL32@i?BTDJeR?B8jn4&Q2Uxvrrs7KuYrSP4Mw0KH!TG_z!Z56L$Kc zduWD!N?BPMCS6WWymS4f=mabH2VXz1;(bm|osp2x8pa&UM2oMkJ}x_+JJ(f&OsU4| zIlukk?Y|Jy3dp80DkSt@%C0)&6{>c#v5Dz2-l#z__Pgw$&<6t2%>x;fZcesxP>IOA z-#%>LaXA(^&&RoTMUXOgU_#pZPfbN7IM>eBk$vu4Ax&{s7K_bpqX}vJ!!sFsG=}fD znds(|t5$YRMUlN-2? z+!l4v+CdW+H~y<~0_;NYmBRaE!{<^~rl1f8vpp@9d=Vfsoiv-U+S%F9>}l+-w|)ufr&CJ8R&NP^!1ly;T&GEd(p}KeIOl}U(F7ii{#*jY z$Qyu8=(QIGy1T!Z%M%L%HnA;tSF&uU86bFrzg!#a@x0 zU)LVFWYJla%kI~Y5z?0Al(aB9+%c^J-2ha!1;B^psO>a}xr|WE zK0QC}(g>JJv%yFFWF(KHRi#WL%|s4q!2ZntVoDFf#-ywU#><$$Z%Yw=| z`e6i_oH1|Sd>ORqee>q5PRv9(j!2#uVdLGB4D3D{DqTBQW7yk;;U#|=-bhMH8WdFs z3oA^h9FYW56UDnichk$i@VqA&v^Cxlmiwh77nf|fO)+T>^>_!~s zSV*u;vCK(y^ZOlZNN-+STMM$4N+)3r!JiXCX4Yt_FiOuE8JmV-j|~rp2Jn2Ag)M!^ z52ZGlwE1T{H^7f5fQ*Za9~&Lj04cGiX2ex`A~eU)EZ&w<6RFrcsS$NRk59u$oCK$9Yqy?AR`Aoc7`(igCrm%MJy<+pU_m)=ON-n%><}hU5)4lscvnhg1O55 zXYl3ab1BScrkal*2UbY`F1MvdWvKt*%R0}30LhkudGX_$c>S^YOMfuo44^m8-ft*A0Nqokf&69t%ZnB>gw+41JEgZ zx+=S;O{6>+=oVOcL|~0-SSHMY4OS~!s%RkBD?c7sbp@rsfAdsy_c!_NBOrhvL*?c5 z*Px3&21p!5MI1ZKDG38t=D%n7#li1z#H$2F09gt@Fc4;{5K<+RFAz3kNKmf)Dss!z z4!-^H-i?ZI*&uBx_m=O!f20*X{9Lcr;%kXS*&rYBN1V(Cs(I;{`H||o+S_xR@voB; zHY&Af|HGGL`b@z4Ddi((K7?a#9pn4L5Q(Bio6r>(8ELr|Po6a^NQ8yFCv+Pm?uOj# zoS&gS?lbhFH)`jW&A<0jT>S4HA#CoAay9awQBSSBC&tHrg&xm`GgLk0HYUPe;Jr2*Z^Ivq|6Z?mX;~r} zZ0KnMGq4b+bVTuOEWrW6WUV(~MdRI&1;d)0Ab6w2vUUrK3WDzq&&)LBc7-`t55DnM zbPigPmDmvQafLt8x~BY`FKGHrMa5V=)!WyN5nl=nlagwpPK?6Bv||$Jk&(+{YHE91 zC+S_5vgvc<^5I#zOR^gqgo4&HfsT%)x=QpC$V{g1`*!@AvJa8>X=&PT)ifM_bN5SEM1yr3pzR?nt%W_{bVMj5EddsjV*YEv%hVE_&DW#-DLb^dj z8U{faN)V7#I!00fX+cCvP;>(_fKn0zk|L=BBGM(&-8{?h|93pcezRZfJ=}B8eP7qQ z);iD6Nd%hG<<9`sgl4f2notm5n_CdEoL5HtWkv$PjZO0<xOBv;RE>ZynVe% zclL{mi}IJ)_?c5fdCV+~j?AiV4oZCcc6xd;e&>$9{!KhQJSsXYA_cH*w-pL}aJMDI zbtJJz8&7x3!*fQNPo`tRsWi0?K7O7RbTcwO84d`DAc)Ol`rHR|XE%(dDFq>JSvdg5 zv*sA&O7@?iw6wWG-rdO#%kRk2=;%P$RTAGizvjn{dH&=;|1h;UJ~~p{r}MR!q8udRYUi~%6w0^*K&b!k_3dJ~l)J|erS{hW(lR09BCODpk0*=*H@OS0pLV&{}9Tv3R zzsANMv_$eh1L_9MLo~ECTVBbQPWdB-cXk-kM-vOt!~MMIg6Yq9-?SN_?OXoSC~lG; zH6ujfJ<8YGT~>$X?FNQF*07SE$c&P9M(pajoj- zs?9AqbQvql0L53OQ2$-eGa`8=h@Zm4uP)3c`cVPGSbJPk1}bH{WbnRjXNN#*v6i z|Ka)Oo@!;xK9K&qQ0RGr!c{`6g+8ZDr*wlmEgA0@Yp-MxT7Aqmq;k~Na#wElWt`Bc zn@=d3yv%>8qqCEX1x>lL|M@w@7*G1+>YdTa_UM4awCM0-nHAL0g3RZH1o*r8Nnp0k zCqYkg@u6vzt!->Xy8y;;V~7b7FZHNV^8S0<+j8uQ*iv`@Z+G`eP-*n^a;_>kUwqWt z3!qvESch>T=y0e%R=hf)#S?+^HMn-_LMY=<`3x?ONWJRg%k72tY2GZeNbYcR3^<{+tyR;S-j2#1MJh>Wknj7+1n$ zs$jQ!@o4i$n%?BOlHW~;H`K1H1#tocdXvtiKKU;>7LSQ`?$!*! zSc)lC7oX6A#aO_wJ1dE3N}1z|!XSm%h7I&u{+w2736ot*xB#r*E8pn0f^b2(NMXI`p18)ek{E;t80?55xzosV z%OZr*E8=~Q?1Y=GhpUbB_WWddS!L5MRGQ-PyHlE@#|O)`Y>HfeS1+enrrsm|6>}*s z=LCZ!clj|o+O@b%IF?5JKI|ejN<-2=qvc`GUl^D}QEsRXM}4#Uj~^d~guLvMtarmL zPhLQ)!k`H8B98R#F5FY3dGi`{V0D!mAd~Ihhmdv7dC-OjgEi-2qCyGQ!q^mMwT`y;=@Ij67h?A`1u*+#DQmm5DVr95G-wvC8 zSGT)xb?Dn~{X*l1#MsB#us1J1y25bULd*qAl%fIV;o7*|W&~wuXlD|afpgJ4C(>pP zr-y+*KliQ{M8K1ZMU}>0=LKqG)5HWE_oyFQ4e&v<%EP|M*Q36kNo9A1=@N`_V}qxK zvI1I4cf7SVcv*Y-SXX$H(k&zxbYf)XCmF5ONq(7&#Jw(FQL_yR*dysDMxSoK3qR|m zKR@V&7Oc$rd9VM(ao>o|@tAGnsm1xurZVeKwgQ6)O*0b{{QP_O?{l!TNByqT#x0K! zp$pOgi8TK5Wn-J`(m!lo&$n;et2L8nI$Ad2r@NW9VTXmQTMOBqY!kHwfIkD=@Ud{e+hV;dWgqZX=T_}B4_#7eD(BQe9SMWK>S_x1q>j6zSQ~sd-^c>UXK67<^%tvr1)Rn$B=?bOi1*f z?;N)Wr-#QmglnZ_WOVQ_ekaH3`dn z0@J2H%M-7oA$K%4nM9-qcoeiQyUQizXG;)x*KH6MvQSo2f8KwdLUo}!eAO-QWHSkp zqn3eaAZA_bHUH%qs zy0yiYyZFPR|D{~vfk-9Zj>h3jrO>03!|l1t8r={hBTF^0IkXOM{x8qw(A{OTtlutL8rFG1DQ}Fajp!JIr@o|=k z1Nrc?tGPKRI@X&&C6{HHk34s3zP{OgS%si()*$bC^ho5FCqmk12Lj!0sXOh&2-I5~ za4kUWX-WU8sE8mb*6LZX=<8@q#PzTf+2!uUXLJ8%jmoFrlp7n;Le_&PkLSh054ZD9 zS6*k@@W`#ea6|FdK_2{G&1XN#y9^FsQoa{_ekAs9;_TnBGkN}dQq}WhW>NXFGDYS; z0ng@Vt`l_Uaui+&q@oTCcTubBX-Qg$Ng6Q4Q<6jm3%lQTb zrTFlZ*FJMvq{YR>?VNL!lI~EC!EFN9A~Xd!Bz-@HG&I6duuSBNHY1aR(RB?MdwXLu zGtFErI%y}+Vqp3&a~Xu39C(L^hbu(WF|yXpzJ^7`gY80j`6S$f1|5+LH+?Vd2t#ha$Oe&_UjjdZQsr7fYFFrMp{~<*W}DGL zE^aODh3w;3zl=aD#E0qVW z`%Wjv(TLBTFJ4l<<5q>)Q~dv)*XtPfoAS>aD@!Kie5_j3&C#&@72@F9=V;m$xEX@T za92fQ4d>Bp9mfX==cki;$dcpp6E0=p5(tJ+Pf|Y@%F%%^SwcYp0Z`wEZMX}4V!&!q zQDb?2;EOoyBI5UfmF&)eFY?`PfHCJ5RDjq0YcY)ZPB=1ia;(P^q|>jT=`h>>GN?&yP0gU(xgkHWxgbug$&r0UR&N6eY*Ot4Xyb>$q z!K27wovq6`wX1+M&!9l(C``6H3nm7W+7;srTEWq8zV99l59d z=G`xQp*)_ma!OI}TekG}Ep}j_KQ#8gt7C=d_~?5^-dw{p1v{)r6eLoBAnb-B%Kt%s zBw@FXLHYalm+b8yAhA3jsZn*r)F^Xe64YCxr(}m;o@f*TfpX?MU2ktRAz?q1a*J@# zwtO4+p8{&`QN!}wkzGjzU4>8*vu=L;ZOe@B+}NBqmEDVV<6&4TYTYGxqwF*;4phngJpU(9hn=q;QGy^500Nl+WSD|P%;MHvI?nbY{Zq(#6 z|D~J$GSv9sFL)?K6rT)$V3#>Cq%JbUJw%`>S4dDxQ`yh(n7*7pQfuJ( zu*Mr6U3%NwgfQO#B;EsJY<^q1v`TB_N8h5SV+H+ji5G+uclYpODO6;mmvf+~vc2 zYtc+uZoB+_072Fp{QUJiE30J_^z&_-E&&Jh)bIPYXKDmWUbkz8bntpA1Z-?fe@>aU zOYPA;f0;}W2CzRgbsWhmS&+$*)oa4tLyOIJUTe&I=u$AgkN3 znyC*c+vmTc-8)IQ-|*oBU(?#u#oNC@)ea(1;3j~IrAlU|@WJ-p9+7W;TJ?tyU|=9J z2BE^QpJTVj8$Zo1EG)Cp(jpVo4er9kmW?eg5jN!I_iSJZ@`tAFM!H6h6$&-=>g~N{ zYliINSZ!0&BJjJe9fBU}ylS6$DuvzhmGsJSNPo@wTHpWvfm#3LTEN;$zT)2Ktb~5{ zm`BYokGprT6&5jFb%@WhuK8nkH8~GNwgFxcispTF#q_3ZYQD)085S{%P8L6rH_`}>n-LEBy zT$8*^d!U!#=$M#@fPm=WvqY0MCAGSey5bEzeWZ9a7fBq`v+E>IM1mK}Z5q|Wcx(Ob z!kV1_PQ-2b$XHk`J(*@1V&`HmesJt(u0^zUyl4M~kwJ5P5in*hfeUg8uc& zEOwskj}oZZKC7$$U3M*S-=PCti=K&t1L*0VR7f~p4AG#WzaI9Oco{EUc*%OOeq-va zu_sg1%*=Gd%{TdoT#&#%l8dBXqNtasOb$r$V_^ zS}^;o%PTG|e3CJr5_lro)xt_w$KBkcgsAxml+^yHjj?z6x#{VJ+u8!FW~)*Xxw_pL zybo+Mlo1~=?zb02lxE-v@Gc74_!FSw;P?>U^yi-U1$;4;`=`U|- z8TDKBum$;u-HndrztjfxBLOiXndny)B10XKuU`?^OLg}}if{Jy7v2}yQ!R!s5;#M! z8Oq%|J6_EZc1gejfr1$hz?5AiF5Q30eO^^niNGT4lPe#s2#~QRev*{Gy1mzX!By-# zb~Ay;$-$9;bFA_QS7>8+xVI6l7j~*9<~j+@-M7UScgzU63SQz?2ePVZg3|Iam@4O6 z$A?F+Y*l+Go@jg_+R;unGA#P`Z3y%qoE)rK&yxpk9^rda=YM?Utjfu>uxQ)p9dD%Wu9&k$<3tCeEPP-${@D8UU|0$Cx%Hwfx2fObC zJDZp}mp^~* zxnT3hOzN0B%r>lDW~Nz=JP)2Cp1&O@Zx)mq*cdljYkYX^no0V4G~z!0IC-zRM2)*j z3GsdN+qait1xKi2mFcHDhX%oA3$CN#VZ1GIDXASuvdA0#{$0cWujp6mID$F8#efob zS>L#rCQj2LkY+-%xs;FM$(>)wFGTT-eOD|7vj3_PCMG1{#@povev^$Zwran{8Inwk zDeM#`DMbVq(D~e0G@k=-{s1xlGSXfN5XonapZwPZ?lc6n{Ah0njWCwchvEw#gJzMa z%IBwZd=y01IXNka&bAcEEdzbHgzokmMl8$#+SHz;2D?WpbGq40`Z);c1m~Kb~{47GY>V zS=%bfh7;R8b$Z-4+_;fErEI!VxrZcr=Z z`e7`npFkYOK_%hupZP2uVfLAtgPxwZwzvDH0dajJ=z|pS!g%v>bZdu!qEe=2=4krv zte^YakuM2`TD4MHxTr^wSE$)7yneA`ist6{rfxfHU)J-Dhp?Td-I{l#h?250MmlQ~ zGs68=Pt%@LSdgfLX8%x2#?*o=Hr6miS+a(Eh>u`gddGyg%fHZq)WX zo?iHNp(b~-;c#VPo;Y)Ac2G|{U$QlS>~pWamzzm)CUJC|ia~$RX9pKAn!fL*7OKI7 zt9%tt70Hx;P%G2)5KZZF)!dI&h;1$HzH)*oIEj;ZaW2^1jX>QK6f~5c@;i8%e?yHo z>62teZA1QZwgMJ;;d`v<0xqls&DW-^Z{13)jv=DqEEcn} zAv(CE#2k?w-?QleRBrZxtFRR(cO_O!%f^VZuztXQqn@(8y$gwOv>W5O?>%bw4>o6Y zNl6XAai^&c?0xw@I@&j!5inu}$2F;E;>LKW&5aF=gUh~JMC9qoDcU;j0aB+hZk2oh z;cPcb@ozE4X=74xI0Oum>FFKrG_{XSmu zP`YE0S*$mNJj2()`x@a{VDhiVTHv6I)V*TBSN|(%VMmabc0f$_k8eH09Zc2RE*%F4 z-ruWDk&EqZ04q)+!O5bIjpOa(e@jXcLu(RQ*>$NtL&>QLOOLBpE~*fN zU4|@j_U+p)EOtO8k-+O^uBN6cF+!o|lvihJ;$O(?uO9jULLQAh=loPOiHhk)lg^9c zIvXxpLhAPY-wn*-PA|5bHkK@10}0#ruZ=KsrS=QIn!7qq-XC4xSqHf*&*br9(oENK zW*eDV6-`1!rx-+gy*xo?2-@WAY~d~8mZazto2BxYmygIjCYw%IYlss$<%3p6jg}<) zLC(j1`>}(zYNEG+Pm*}2whT3}{Q{?3qrVj!aLn3-ot?-X1SIet#MdOroW}+mfGjb0 ze`33{TC`&#qQlGmuisiD^ORUf$nk2;qpz7@MpC_?REt2ylKNB^|V-1C5S1EquR=FlxquMLCsQxhAHHMrOd%gb0NIw(|X z-#Bd0^Uky0mcY5NP~s1h3tRxPgZNARn~%%O%OkT7p9y!-UlhNrO$;e=A2_+^UGJ8N z=I`q0uM%Qb1_tt{q&p#Z_x3M{-vIXLpTZ|m~fyIBV+&k)Jy(F z|Hi<%(uS>PTO;?6jc?h?5B(p4ms?Om)ywZ`(o=8pCxu|0sCF;)c&6)K8#3M69?wkp zq5s?X9xFmvOpKb0wAnu4E+Lu`VQ!{LSmSbY`!6%w^4~ngKs?He749NFJw#(%q2Wu0 z+SOd#+qWkwU8S*?pE!9n}|M}ue`xw)2h7_ieHmY_%!NnFzrmW z)|+Z3L9jTf`L zVpNwUks(+?zk!k-{Tknywx;u%k#fIw0vQr?GHWQekCT5Lo=(t_L{?=~%A z%vq6=MQsUb4WW|Ub=jTWUDX)eLDHmXlmJ@upVBj{9RdwEzZ95E>R!N}O&gpW8ri(3 z@nGZBA;dBa>Em+=`wSxfLL(7G%zzPMssnUk_~D#w5hY5wZjYYX+1VBIQ7v4%a7fap zc;*eafgk2$3uBnp+8_hFKIzV27t``F+23bz`YmaA-E_*v%CBA>KcK-2cjpYJ%+^|y zLW;aBmTXzm`q@wqb7^XT_KEoRnzE)SqE(MY1M=>*=|{E(`z)3{0>cIy8(Zzs!rYv! zxHy6};%hA_Q7P=Cz{!(+IsdFYX)RM4eL5R^juL!Dq?a3pUGOJGuMP~lSU5Wy*>QVk z*-M^RLoi0sF6|t>u-YsIX(Jbjo};ZsX(3K}%}R<$VkW z?CD5M^sSQ3pCeIEbKH0zCf)Lmr5lftE2^?`=Qic*n#SuR70Sk{bJQKjxcFQ~?Y!V= z3vNZ5_*gQP$zmQZe}9L=AT)RIAi*JIZN+lPoRlpB)Cg}Ev+(#86&vF|dFd8hL)FrO zM)`1KTHQKJ10gJ%EQAJ|p=yil7h&b#ZD&dRQqShoy|?0r)5q(c6AghYqZPc`i6pfv z+x^PnI~xUc@BYAShESWNd}U@OBt0U;e`6~0c%S-wBXX(-)OU(YMDJ}HgO&!kk(nGo z$M}1TY@?|pM{R67qqFkm_p{yPqs39_4T>H?>E)cbbb~L^nmTfzLrM=+K?WR zhG!110MH~{BSHJMo7sF4y?FU-I<`4*-;)LRDw3$DrOzWQQ7a5ffMBw#v6g-}9Q(jT z`DMA^tJnw9^Q$X5d#n7PVy?KCu#AgF;mJmQEl|iFiHq0IEc21Rk3G1QIesj(*Pw>T zc+_-Oc0mU1Sc+QEPM!+(UuU_%y7?>pJ_N|zP&lDTWl&R#i1==5_QTYa6XyHgNk#u1 zZA_f@@2wth#f!-VGDunni!+GiCD5fcET=>*J4W52U2baupYqIJnXW9h{s3RCN}~`Es(~ zwcAt$Y90Rceah_m!gX1}+h>x5S+1cnBZf%h?adIW{@pLhuf6yUf&#eeS#uS?4SzQ^ zF`5tMIPsm9d}wB-f9+bX!lKsuui1!NglMEKy$3A=w+!cjYDK@~jA zqVo`Q7*Y_hi&#J=Lf`|OtA=B5OpDI8o2q%1n&}!V=d=oWjrR{7rY_Tg?0j2 zuH=5>K&(>e2}@km2jt(*%(Ll<9Qpe3?`-*hCWDxza&)G?^Xlu@25c)FeW?%9QB<3} zWu=a9bHA$N&oZ~&@ryFVA$9+cX^k!`i9jL2MFb~VrYc_bwuz^(+S;?FRYTc=GOJf8W*US!YDL0YZLZ{EBiE9!dmD7~u6mm>S0C-OUslLcAj7f*oq9?Hte z(L%q87~Hv#HM-$;W41sNrFpPW<0-n@&1E{M=OC#X$xr*!TJ!mSjOpj|{i*Yk@^a@e z?RL5_HW972B#jB<@7(upGDHuck!VT^iaAH;*r+IhD8(~?9(*r>q$ZbP;Ab4(!}?X2 znwy6KX-xUB+o0)m&#K7b`OD`d)YM>(kIfqzz##}rqoSgKnsFd3h&%HC5uWLaM(C*` zg>_vq53P=?De&-76le(yzX`5&O;cxiU+t~k3p^wfJE%1si;D4^2KemUE|iaSt2sG6 zORFMh-@!-M)rpB-Dc`R1sfl40vuUW{hY-bN3!qqn5T#M^x6|v_U;6WSF@$CPd0^P8 zU5KPsqH$fhsd>YR=ii@dC*h?)uZH31+=u%6Z`@Kvx;Z#}9_@PDP?{iGws+!sHlQHN zCq>CZ&_2J@+v@G}>+zisk6Y&=o0Y#g-Yb4nLH4|G`*K}c+SSg^$i^l&HFaxgTAct3 zZI4Gbet)N0Mg|Bak<3wtm(Wp25iKw=BJ{Q}ny!(W)z8!PEA?eAwiqbXGApKc`B5x}1^}%!I}B6;e{%I28*!R4%@iqZaZ{D@k|%pG|!-=S{(t??;FYTwuwb!r4?vp&lnBCf>e{f^&Y4 zqTS~P%(L&;-7lm)8&G(h`?Ctu9=M;;(j?cn=d5Fsg2zPS9PGpREIIU;C4-0hs}?!j zu2uvSKFS9v66T?KD9L1H^mKeM2|Uf9>xG&FX4zZ%qg}1iXeU2|>%|O&nNstVeG-^x z0)&WEIT-$fVj=>`7OggArTAJ=&uZ%5JS+N;WPh2M6-S3a z!Sn-~rbv++k0u_P7&!(7z1ZY!f1L38?ORaszvw1zClU$EMw3qoNi8ieeW@r4>@UN%VG&dAF%;2O!9!_3cVkfF-!l)k|a0^&E=`yBJI zO-*6@36kbc^2$*&c;;02CwNDlP!e*84 z2e}U4)(~?|xKmEoW(@ z4-xhtI*I^pZT@gpH-VO;;9qOIEmb3APa-qci#{4}TqeKMHgwlXgCKrS8kMMqB)_L( zb^A6Cs$S$^g`;MU-| zx+~3_;C{{B2vW*!Dy{HPGUY`_g-Ab2JUgJ*#J0T3Z&70v7Lx&j1(FY~?58FCEjsnh4kpa6^K{y=*tf_Kq`rd&-PNX>C~H8WO(HVOb2;{@>gAoJ}Mw zn3k?3{^_GD?I_J9J~njO`}f!7uA7^i15ZI$h!S+%W@cv9($Z}WusWJj!V;6-ns)gn zZ;#9Wtq+HY42~9RrtFcjw*$St2y6r%KI3nFd?WC=fWiZwcYb>Zk`!Ga5gD!cOv@(eZBCJB2N7v22?R(5L`oql1b|kLPb1vi+y+Fo zeY!Du4Yw`fmKT-zKvl}{=FM}hjKTj~ouvlQ)6-8zMg+nyh-eO=pHQRV{y@v$+uM8Q zcWz$Z`oeNOkGn*s3eH|S_!1(6>Z+!Ih(g%S{x7l;5-s)>Cye?ltE&K;I$@o@0Sd=& z;aC4HvLu*x1Dc^3V${FNIXnB8M-Gn$!A4i_4}KXL?e7=BjFFR*^Vad!X&bDj_HRh| zS;xnh%qaosDSD@V$0B^!ViE#Q>Mk9UESVI8bb)l+>(y>dF6zKFll+fAb0KJfQH z3<%!e+cT~MTKHG!*RaIf&wcCp`@ia=Tct|T9tZ?_Ff@BJIO((n3n0wo#G&~D&!#C- z@1Url6`7GnfPiA5@W0BTo^QTtqoUVAbPYEeWD`7x{vb7k)MIIsT4WqqnNWUV;p`Lo z%g>p@_jLhlVtc-8`#B)Bn+!HUTq{02++8_OeOEZIbZv3WwQbJA$o8MRg%j4=rxoy? z=MRwYDX}rIJWqWo;+iX^e?pl4@iH{+Xy=LZVZ z!NhY@Nk=^{J|1$AvqB65aIM~q%5MIz8Vt>%Rlic*@xEd8((mqE;n|W zpvVH~V{czy9NV^dmQ1Ps|JEMoIGP*wdcIfjQ6cJ@gk?fg=cmo*HLS^EbRCzDJ}3{f#r zup7jyzU*sr42f;L{a#bDHPgqAZCcVka9Vf{r8Pfg(fJ)1zW^TX6E zkyFn8-o0)FQ(*q&OyK{0JSi1bVp5XxmTCnO-YjS7VNLnI9s!TzMMamnL`Idj0EtF~ zhf9sY*fV)*3KaH`a9&Z!@!ZPE{om)ewMAuSj&yB!-ML>D^Wp`xA@Naj+{$_XtMkSP zTUqLarO^de^HY979qc4S=$1o}FsEl`ejBfO+J+=2P!UoV>!0lR1ZW2IhGhi=;Pe)2 z@>(y-QjG{Z@U`VS8znjA6)|C0{uM;vC;wN|eNq92gJ6)cW7IGvnoyA4v?6dn;I8jS ztEC#aS~vO8d#onK#XR#|^WH8g`E^#C+P3L~6T&U_FR|Ipbn4%70-K25 z|JC;0DiAD0Js~Ghb@7-PC^yd4ER&S5Lv*YZeYsM4GXKqh(XPt*oeLHnU}RxI9O&Za zW@2T+J1WPdX*n5i2j_y-xrUC zoTSN7I^d>TR?~^!Ff}$Nqo8QZjdBd%?v;5p#I1p6WEYz=dbKNZVC3s$WfsVxmA$5L z7aAhQ2}ut=bDd!nskwAb2(w~7VOXw&urCJb#hBXVMJPs+iK;IVq0a4h#5|>%xg$5G z52>BbBjBw|pv=I7_xK%A{L^V6yAqP~txQESl!^uT>tNyva3oM#0p3UP_isA8(!DGv ztw{b+qMiX91}TzC!zs#gQ7d4+X;=|FZp|5v2aB2Euqnm|4`h2b=|&sni)kN+MKNNz z{E5-r2C6@43%H^xu${8pm+mG0D^-bEE!{)w)D^ed@cz7~jxnW=O zm9<1@aq}uF0>AE#G>~YRSZPzhwUtt;!eK9wJ1&8_){V%>N4p8v8UphP-X$V$e%a^S z`^S2*d{ijq>a%mj&?AOW0-p23ymP^HqsO5Ndwj3-VManLUKW$9@j<>TaK)7E`k+?O zmWYK8vIq7Qd0QfCwKOtP%qIe`1T-a+IrKYg54_n##^ck@*iR6D`?*3kplU5n;_^OI zioidc9xTM4459CX^lo(5C^)U-%6Mq9UW}2u*9{E}90ad6XHud=z4jtCv*Lkf3WfUC zmzMGC(SgVMq*SdTpLVbLuzyWi_4NKo*BJKK{_Adw0`rE}W3v9515?^tgoPCj9;6fX zsm~SczaF$XssBFxOp?)u7pr;nu&dUx*J?-@e-hJHOiR6f@hK(l&9Pl_8LVTXg+$zqKD4y5nc8t_yGBOy zJ)dFV7F8xJLK0`n{#W?ENe$sP*%S(`|N8H(#d#q<5TZe1A!=LibLgXj2}g!^fBE9- z;p*z?7HMc@g5Te|r$lsg6kg8Di%X5CgrgDHhljGt>FyKPoNFJR5}0sF50~(-Kjk|n zPYe0Ps+>)u9Q>;rF`WN+{k^z*=`Jl&VYI>ThWn7{!FQYVSyt@Rrc`t7&Xnw4#4Jn*REA znu5vtK%bV!Fj|jq&$3PTW(y`-@yTm}7B-QWDWA}P1s=0H6B>lbm!>d@ZVTSFec~MX zaCZ4eK2C)sOi78&)it(BJ|L#KVZT$k)yZ2zVzWX5a9t$m3e@y~uj*kvXw@fOPs-d8 ze`{jHvUNpSt-`NXCsx=_H}N-$r0qDmx-Nq{AG#?JjPwqK5sY#4wawobHt*uTOU+ri zkJgjRiQ{r5MjMzLM-flQG5hxFH@~_lJnyvg9Ix-8foIQ3L)>7po>`Z4y?v=lTu^FG z|H4^8O!g*=$Jy(6N~UJYTyIV+!zhuS8s=j~g@lw813QDMl~vD(Mq?w#?f38B_i?Z_ z@Y?)l<@G1R3Pi8ClVO}XkRpB`GBYoK7`xQbahw<;M2V}1>A6NC<@uiH`K1&=HFiC_ zOm=%_&Qv_6KS#1dE`&Ef6zmz3yl;6bBqY>k!HXA%VU=NcAaIM8CzDiMpLdASTZq2X z>cqx`4Ku&CAdP!AF)`6FZY^eDfVf0L>!_+{Qdm%ctZM>ANG>7aKd&P+l9ydwW!~GK zTj{eRhr`1+Ct;|dgPpvtqHN#(NCe$n$$W4nNXydl5IRiLlegKc}*aHpsOmvm`{$U)HB^J})+%#|HUpU%HC zaJ_5%y#6lFA|fO6jc8tl2#JCP=XXKNF_F}_e-*1Hze4z}*Bai)_^X;rtE+?@KipvC z(SLqqm3O|&s~ZIrzZ1q^`jKc}e<3yzV<#5ar*;ZV6UGOh)7sco{Y0QN+~J5F#4EwN z)c*ZG)+^|mu{HfmJ|u>Jc?{182@Sz=2fg}FpTNL+H*lWu5{1vxnUr|gqi89CEIa}d ziTY3VG%}RuJ&WPGG6BA4U&7+V#l+UXW?h9NIWTf1-1kZ>$`yY925GQ$8>6%H;@iiM z!S(vmyT^l(O`n#`M!CzN{bTXC6etrlu_&0Fn(h%syjY)IZT!p;b!1Z}ZW6@@y^A&k zlYx%@Ya-N}_YIi&#YN)PkD%R$gZX4%+wb1hpWlkXGUp{y%_V~LV8ap_7fGW~jZ}hY zyG=quhSF|1pVS9&G{H!}`sBPS(K*W{i_r_-ws!OvQ&Z#xb?hY4pV!nD&AcHY%wE-_ z!M0`8S(HD<5YFqHsN+ZEJ!pfJF_?hLWyqrsgMyRR(c?|<@B&Y}FalVIaJnQ#wJGMx z;M)y(t>2`*)Yhr3r6FSUYl(6|NJ&(bj}Q3t){_A_!_r?%c^naXh5>sC_TDpiOr1pJ zgd)k19I^CFmy%2~)jIhldsvUW-=kt|zi}#t)T*qD24^BNe)nW*M258H%DE%WErZ+Af<;Hn z(SCPhj;;*+JUBjHTq#|!*r$-dK-OLYmq=xD?k!fVtTc+9GJ}~K&8UNiW#?cAEcxM2 zj`-;o z22l#HAXEZzwD?j@xtyGU;Imf_^70zU&1tzwD~ZwMl#+Uz$q!a00&D|6#lOStz#{3} zi=XJQ8kGcaCXQee5x`X`!|N=k-{VgC;TbqiTQfu2V6^bHSp{>ny{j%aGWLNNKqC0E56wqnd|Ei#`c zi^C*L8$q5mTX@zHml?JDalaotghIpeUMycT6Ex{?|kypx3!%d@S?{?@Jne1 zfHxu~EQQy)&VS#-NmCQrRMytkDAe|Y(o#ayi56$>1kT>=8 zA6>Vyy3_dK8ddDVhw>U`yEou#50glG`V_+a(4F;_FL|QU)yu)*%CC)sRwflGm9%6! zmU0**27)%$hRNaUYdPl!N#_S(c|HBhaol{Yvizs>hb`%Uvfknw6zC;d|)R*k+mujZaett|yW`O``UKI_h zl~|dgWFsYlpH-yDBc5iwSx6A@tAVy53~nv0tO{U0JA}Sd|KQ1&XGBCqDYT`T)zY>h zdzL;vk|&P~3b+B&k-@}trMDNJ+q-Yx0D88+t1H>h+|<+*G|PyvQ|LOnl)vQQ0L?+~ z*RQa!LS8L3hXP5ru!sn>JYMGz>0!$KY%W7IgW6m+P%!|_wD!d;%GoS*X6Kv&p&qF~)B_t@yq%ey^ z46hNDk~8UD+%8zmr`v!TneTuGX#_QbI?*+o8=kEqfBN)59Tv?r; zpPM6b&~*8Tm;ncfs7)>UuB)*XIrH#a0pY?jRz-wf{)q56ld{JBVUOKN!hp5KMVaf@ zg(P+t<{aS`+o?W6VLmoAGy%8SVXleQV=_$Nj@gC>U6+a+z9oeMUov<~z*APcz2@OD z8G5`5(OiAGN}=m(zim%unBifu$JJ9fZSDRA@&r^60!CedEHBj!8UP4+f!^WX-HeRX zh!@L{o-^#TAK>BXIWj!N^K|&jm;X{nq#eG&$TED263*>96DZU zt;Nt0mPQ{QIwx_F*5V+4g)MHnpa2>+0GSrf6h#vADieqg!yL}kk#FD!1S0^rBH!W1 z(0AFL-~NbiLtRmC-dyU6vXb#YY=dH00fwg+CwhM{z7UBDo%VFo>)9;S?!B2XJ(HEi zDi9De{^Rn8?a1h>=%hTFIm%lD* zU5mbVPjK@`bdR1M9NRA^a*16LeAJOQ8#nRO(n7m9e&8DZUXDT_52Pm7|3^lbmz83d zUv9vRqr>J&`<=U1UW*xIV_SwWuTR}wq26{#Tth>HHQRTTg#~#IdpeN>BEB#x&)QxJ zv_IYw6&$ErzfCanO9D1OKd)#CASs7ow3@&G$UZOO$FuehVcUOgJ3TGCRC@*tZO_Z$ zQFF!B1KC|AJlsuBPtDrh{B8##WNGzj+~Y1CgA43SkfZpkIb3-s(CaHD{v_9Rseut< z;(4dnu=^RRO;Pnd%Vx%1IR#uRf4k<(q|?*S>XC-YHk-Bgpu=gwcWnIU-o5r$B7@K9 z&~mb}8X8zWw@AVj9oIVQMv8Z~<#h3SZf6J>wP0Wxzkd#O*01C1kz>f(YmV z1G0MKHk6oh$W4azfS31k&u3m`85!JUb7WGC{n`&V-3(!6|Tw3bR(LWGI zC9euHY2;y(1<^*;Ei)_9EDY&+nKkuSKl>s1-{j|m2_$L8!%!CY0tOCJDDkjLDH;C< zUZe4t*F`(G$C;RBiF<-$VgK)#cXHz9=B|Av4<-=X@J24TKMB?+ee&ykmoHxxsT7`v z*6_d64V1O--hp&0F)l7*7L2b@#7%L^!c;;rLgGW*U0owQa?4Xb6%~_!bxzE-p3lDwi5P}pDRA@h{UwHTv|uJSNAzV>0%5({ zO-m1(=J&-VV~K_5WWAZOG2RF5t1^_1Y$8ZuGXF_)ITZ_N6yJOIj!wdz*{})OT|i?} zV9btgoN%CzJ{gx{S^5iEKC7BIy6VANaa<}UMP4cd7?O}Or;saI+iG7iaXicQBqJW+ z^oB-8b|^;+pzt1jgLiXeT+l&4r)xYE0wW%u=FIH0r@#7~ehmshoA^_lIB`Ug4Kdxl`%Y%sI;qwO@~cP* zM-PQWKNYA3A8Zsni`E2W{i->wM?E8dEhqoS7D!ZTUZLXkPc*Kmm6ha)xY06JkdTxF z)C0(HCEKMxzHjad=IDzilDuEk)+^tnN9O-2_va&+Dy)P(p$h}QxT zC@}Uz_|2tDByA?N0#QdnK?`r*Nc~>P;W8Sl+VLWlCbYH7^=0*AXBZz_a` zw$A2LklIW(k)j$j{hUGz(VhmhKGxdn61dyVp`WViSO-EPgaPBQ)WWxbxPZkYfmtf= z`^)~-qtgFs=K{rQM=24)NQ-5EHe0VPjYSNHK9g7nzrWb}t=%`A#v^Y}B+w4dSZ zoTScZlS0uHSEQt{huWs#XJ}Z^9vvS+hO5B`)&8aR#p3^7`OLIEiKXTQ%ozSyoYXf9 zGb37BPOAHoCo{Ja6PF~1a=LbQK0Im))7S4!>r8?W-gn;^dBjPi3dPVBgn>SnZ_=JQ zF(a5ldSIq6D3~(eAWy*ya&Q2EX~OC2$?I!%-wYN zYHvtMN~Y#KgKBPfP@4-773YcxsRiwi?KM)`2L?8(`jw8SW4ZF@YU}Frn;(Ld3)4I~ zg;NQ$;gn=VM03MhSyIyTqn+?S@mG)WM%66IL_4z5)O{@sla*yfG|~ZZ?9fC$9;dlpK)F9EA0hn_4GH$kRJAekE$X?Qo5*_64Eo4Q%skL9ejN`LJyN! zS?Oj(wDOcTt%9~=BAVU!*-uszCqYDQU7xsa0nh&I`lF?~7C_=4dg zoACs9dpiAzHtmiy?zX0vgv@~D`!2(_q{R5MbB{LO1wj}QDz;$Efc?5)o@FN`Z~j^L z*2&v?AEJv%a9u~< z|A0OK|^ghLV|&+0tu0aY&(%?zF{N7dRyl9*_k)CS*=*kCU)F2ItB(#lm7##5IjH+jNGM1Q${k3_4xE0g z)DU7wbvp!XXLmipc6?p5wJlp-M@#!F_aP`6&wN)V6YmlV+s8mi6$}^+^QxL3MLjjU zR`GPOqWoidsqWRXm}})R|CLf*E2SE$pc<~A8mu5ADn)A|CP9SzUXF8#p=;yYruTji z<#B$O&mV9`K6!E#B>%9Ji@*V5#Pz}L;*9eD&|Gf+xyaZo0umEz4 zry~L1Oy`2BmR5=87?Gr&WVN_N_97z#LwL4fUKGEFV8^%I4|q85lQE{I>;TZ`RX4+i zizp=5n?-hms)(-Ioz3*)~@Z23?w+^*w%5)pVdr z+MVOXV{%S_H8HeoK>psf`tXYkWWl*#t=HIunfp`alpn#C5dVOCN=nEzFVSMr z>$=;qkf4RwTaxXfXowuH#pwxJY`L!wFY{t)C-tSOdwS<@o0teo&Ym<#&yPLVpj#QF zZ{!FMv;QwBT3PD%AB$d!9{!&yj#SFS3WG{+__1MKcZmg5O!yVr?K`(4W;|*@fy;z%7?7;X6SIlotHY6EYH+mVOZ9t}d=Foo$}3 zudre7e_6fTO~q!-gHFHof{h$S_r4u((9O-Ioss>@1!#z15uD>~B6#iE4KZ=w)73r* zCWkmpKA9#m)juGeeSFOf?jJfMB@!l2UP63O_OY!~qhM;f<=_B0CIJBfGBe@YJb39Q z&U!S_o8du{?U?RI&kd)df+?dfvCofb;YYC%n9$t&yp>=;`&s;=F)q*~&`<)b8jatd z*?rt01tiwN;be3w1q}S&f?tQ9Up-H}a%L3Dnl2*FEac4rkw6YW7YgqH_C9fR{N;bhh%mW-pJ9W6J3WL4Ey|;6 z)0SsM>;C+CUO^s$LvPe{sG^*DxI$9*s%C8ADjrJ13eQdCk`&8F6h1y2f$$(o-M-9d zFUqm~{UV5n!7`4%v7Z>P5KKx+3hEI3xVUe&wiu!N2Pg$zfN_b6iatk{Y7-k-r^=Co z@F2-W97Tpec~UY(=g7{_3+7dEz4Qb|GO@I@yu3OQY5)Qt$;I|=rHsguND;nGn7RHn z)o5SrKmH=OX<=FEyy}_%Zrx~jvTEa4t8OceVeWVcOM4cJ&7aFJb>)Y|C1R}KODe0V zpftiEpjSv-Sj_VG>Mz2#OE7uTzA&5;oEaw*?_UozO-Hb%fh&*A@Vx_p%K1#|i!Q3H zq9W3}x5Q*AOuGTAv%Ed%!sudzL<%`M{N++}N1_uF6TQ8>nV1<#*P9KeZm2O&J$RQi zpk^bgb@4jr6q7TE2uR7uIwm~qO>=W|`Um<6UVZiU_J&FN;Lx3_N-?Ojc~PavjpJ9r z?xbV*7)CB;;`)`HZy-%x&Ch@D|ca%2kKme z|6f>Zv0h_m5Y`(3X%Xl4_xD9PIqgaWC>0`Y1o|G-x(Fr$DxGedPIGp5+xyzgI3~R$ z5BGdsCyAzV{=!1;vS%ha_kxwFcNX?{52|ZwZ@HWu|3_3B_q1(jd@S(XN(S@X4X!Hp zXH;G~uGEbp{7qSCprC61EdSQ2Lu)C4LOm+1sH?8_JXjy?45J>pqpiBoSW{fQS@!vF zM!l-Hzd2Vm7x01YfEncZ^P!y`zx@s111>8T7Yoj3HM(I)1+DGw6PT+pQMYAvtSS0t z;3d1BO~3#CuJC6Y>gSi>TUxm9f`L!c#~d4fswgc*n6@jB z^zk)%x_+imDRGzdON{-HFN237lTsxKfur#b50xFC5XKPNcZDrjV<{106&mgGhf%Z! z-_Hr%!jV2|N0$@~T(_`p&xsI;roK9hOB}xB7)Ij-Run4pKYiTFosGsO<%RO%Qs49K z8TdV@X$`DiRadkm!Jsa9Sb#R6F_LDDn4H$0tEHtmYkOj1QqnoUu~?8_=Hd5l^39Lw znVIq~D=K#_dCH4I44>NC7GSYI=kSUBj?aAvu&`)^u?@@$E_&jA^vf-gI!(U{ua6@< zDw`X12q$*xSXpD2t)+r@0XmK*#;X%^s=jF>(}TV@*KYkiYx+T@6vj6(%pe7=+{SO^uv_Op zI~|P5p*C9I*ra>nGdVSx#R9aD=hhnhIJ$*}E3Uk&74O1`hZe-q$Px%l_2Vwuk*udT zHZfVfQeMX-eJ_niCI6YNaj~|7_f)XM1JV^e@usJjv4z|v9<$dfzS%gs-!Y|5vz~HS zH}LSbH6UQTvE$3l-PS?^k8)hidJ_$HdK+r;=o>=;-8S$^KrYGMFL@$omsvLfG4uf64Mm=wIBqs#qTtCO6Wk4W;o+gh!|{Z} zn1GWBwiA~G5KX_03nd~SVq!US7N+Uwz(x~(fNIx+w}RI>1L_4z|lL5H(0DfGpYT$)&byMZIOyHWd3X6L^^)Z^W9+n_)drV^na9>>{kyr;*LH-@-z1AWDU2P)8)Q#}$hTwF>k zmzR0>lu24G4gK}tqwTLd+)~}ia@(1Q{pA!D_HPz#Kf(?3WIkcDi4vQWYyQlXSd$cM zBK1pG7BewB%SK0c_u)gWMiI(cL*OvR4e`Gw>-zh_<1^obUU#ri`TksjtiPZ3&;X0C zJ0s$wNeyXArTy#V_xuK=u|4yU5!mfB^XqVOPIQTP`A_63ZC?9q|JdN*c*@yBp-K`j zOWt{Vo1r6P`^%_ZuSAJV;aLWDQUak!qX+xC6km@a!#gYU0;S%?AM*`CAj3Bzcx!g- z>0{pDN_deX!q%%T;idRaNBF)Ja*n`hGo6xVhU$8gqodE-hu1csAv$k?|-Md~6)EiA}9}YiAvUjw3M2dcwU4DU)l~g1t z>CKz?SVXiz-GnnEBNLEX6ol4(tPxME^HVZe)MGej95dH)C%rxY`eoGbnAhtg(akaX1z&=xXKjxjScwVtg+VG#cFCx9RVB7-tH3j;&2 zJr)iTVywZX^7Y3KVFbj=YK)r3Fl)QO#P$HChmc;n>KzzB1Z&SombgL%7s#Sj3`@_0 zF>l?-sGt9OZ00LnD`kB5!=ABOwT~r?!2bL}gN1z(ROY~(Ev;HmV<8Jiv2XN zkvY3HBO^QDyd1AInBd?^UQRpD{wh@={J)EnlZJYFOX#Pc$L7HT$-zon)NY{l5R@jT z$JW-?3g0I`Wfyk^+8))looFj}77QpJ&n+(c{h5Wiq9B~+ii!bvvJLl`^QIWAK8fpp zh1n!TF0!+4(a%%XsImd_L*qy7lMap69(wML(}Trw4+pGeRJ5 z%l2cl8tK{PZ?q?8`yY|-A32N#hc9T!kU!h69>1UBFpI^@Z_df#U?IO<#R8>qe<~vp z!(@q1sNJtSHqUi!pKH6GyX)e)C0E@AOI2PAb9P*Ic5>0i4pO*OQm6P{FbBJ^BpC`k zVj>)AK8M8>bvFXLK~DzBi(plq92r?(U&rWMp%oNNOgIos(RoF67|3Kk`}F$|eN+WJ(jt zR_=SPEZNbeu$azWZBNf2L@?Pgx_F&{Cq&7iMj01)St98pLv|GTD@sE@zgyy68peT! zH33bD*xZ(X6NAQL7%7m=-h1f4ju3`%<0dJ})Y$9S!A2c1m29*B-;R@g$RSsy_@<_= zJ}RIT@(ImNPm_ah2=d^)gzS@ve$mEUMtK}WJd^)CVxAx(-<(qCda=5>8HrMMl}u~! zNy;e_7fEbM=foo4e+mdanw=k^}!=>lB4rp?aC4!#|8llow3f3Sspc8fTQULyZ*FCy%7UzOdk ztpB-Vkg(71-@lO@|3(bD@+ZOUw-#XQG!z$)0mmMjb&*$&^NP8V zdKf;czdz^k9x*Y|uW&htI_=*Ei@{C=<`Do&7-A zVF=n& zu`rvK48`>A8>rnPDN$-_6(^;2vBi{3>{hE(T|rmMV@-Y5*1lbQbMM|=7+GfX4Gj%b zQBvW}gGK;i*rvTAR0~LGDVgMPcx*uolYkwXoUE;@k&uuyG%~_pTSndfhUwmAiEo#A zGjNA?%-F%8T<_nD0+#OLcklQ^Q$t}N2ln`5@MPQIn5=-7hHo`7KCWji?BmnKvtx%gJ~8&K+lxh?)gcXBi(t8?@`B?AjqR*vwj^6p_!h^Z>cd~9YCakmO4Q-Ot7>5ExQ z&HaaWF{(FJNj8c~%3Az?EW)!ruYXtUhJ=CtE^I02*)}(Ss!boZRT2yL^qO*8KUcK4 zOi*;%o@2X8HDqO@O1Ozfc1cq57yW-$id+Fwr9U<{ypER?9|`1NeKTcfWMySpT~m!P zHY+Tq3rZ{~2n+Mk(i&*I!xHtyU;cH~d8oMPwfa=NORj&^v+70$-^lpPEwiU$9ck+B zapR+4S{ukljx3ejv0QkWY@f9Z7YkAcx7to^j zg2mnx*$|3YC5@Q{!{k!Lz0vucLrB&aa?DfTTUts*A3_$a0!Cix0_LK>_uoH|S{~Uz z#^@jOs%+S7imKzPB?LzYYe%tH%_%HsDFp)pdI4G%~o(AO3I&+)nr;i`05ugM+EvsAf z29WJ*I(m;CJ0wdgg3<1yr>^LvP{u8;DHT(Ut#QGo(e=q4Cl z2g}NZ`t@FY7E}r$5WZ12MZml!Mj-rJKuIMl{k#3sS1%*`hx!7LPBaR73W(~qZq@Ev zi;HyP6)K2p#YaQwGX(i#g6f~(W`Vl?)2E3Tn5&8z0+QG6_pg?dZy(!EP93_u4`Jli z^HZ?Apn}9^q9`VfI#~1#u7N9q&pd8)$@`av@8O{OznTd83 zB@-DcKRcKseXF`2= zOdU6&P=MyZWJ2Zpy@oh65s>%Ziq3ipw7W(afp80nTnp#*);-CHbG&U9;6P=~H zKx#G0iZ%OW$H-lzPBi~AF?GXwiuQ$V&WF7hIDuX<)hw2!5W~PN{ z^jWmH5$(zoY8pP;*VDt<&CS!<2PPxqBT{|`_K$B@ zHkFjz;f#qSM@7dqb=g>3)L2_v9E~z2l(`Z#J$jpxc1K$qY)duO*m|F}mmv)euj=Z` zV%)%uw9-~wU${Q^wDo<>vg6qIjSY*VJ-!W%P^9o9WFjJs$5e+TCqLf}1dm|cA%FR{ z^Hu-J04Y#!)v&3q%wH;Ej7u)>Cy$7%y1P)okWeO?<%iv z#XXh%_U(A<{iEw^ey?5>N-s+c^;Hhz5pe+v0M-*@He`jrMn8Vk6@iye_|v#x)DMR2 zTi@T2yzn)PYVwbN&JjbF%)=n8rKJTXz7Yj2y&y(bR#MF2`R^Z!cFxCPTnH?%>A=WX z_W94R8$X)&btD!)YEu$Wp*dv|Q(p5p;OKlJW0Asref_8ZiP|R7p}|L~a8LgFb^K{- zbe8|`UsoL*gdRF<0da0z-RU1Pw5SMfpTtC4BcmxQe_A4J7mV;4+h%Kl|cDWv$cJpZ72q zAL9NSKO0jpbzTbG*KKE7A5@BeM=~fX*;l3Ur~P%SKpON*9c(wAkM$WP1|k!SH@7&q zEBI3dly(G_o{B;go)RWxZhHn&(;$Px+4*NK^v0#YS4DXQs`KBdTKkucC%#+4DfyJYvfFmh)KN;gACJu{Vy)=%`|4!uNkY?BL z-2%)+=@O>9!h<r%zO{JM! zYd!ONq%R})H8klY8rlum4ys{MSN?z#_H!HP^OCQFs?kMMwEjgLA0Fxnm~p4jv@(xs zag@(!a9}>EE-vd&)X8{;yi>iVvj6(2?+T%yJSTbZeO?=%=jYXNm+Qm* z^NSsUfikymFI!lEiV5@haC?K^&=cImt_b1wo0n=89)L6mEm>32U(IQeUQ%od zBPyu7C;2y4U?V2nI`m#0i3oKhQ^C&4yC*zs+@v+ibj>_>@5eA0a)o}1dH-Iz@0(jc z+Yobur(VRJQ9j{^(~jrYnv`)${FGlUiQ1n=iimP&Ge0b`p+GS)RTMpWd;6V02i^0? z*i*p{uued#kbP3yV%uLBuBuaW!DPQ4GM>dtEvKDhb!bC+G_9+?b5TP3of)0 zUd0gHum#%7s(_N;J_c`aqO(H@)U=Sm(_3SH|6AKJyKIC-%YWmqqwDX!UfE_Z>Ivr> zd*3bA_~AcNhMTIronF3@KDO#nwyXc4V1;tJW@x>U8qf6)KnAnkem1Prf;T6_!GqJX zi1BwMMgNMFyY?E`1+BT=_wPaX92gh~YD1~s!CpYWIy`b>n)oO)*_+OVZdc~zEjop#jsc&dE|E#M zUp620t+^+q_l4L?>Bi!sVZyGC{cFoi0;I#kA#C-eAbprPeAL7fL+NYgt&20;Z_khp zpS1Bmj9y`+WD-xuSs*IIXNhj8l3X?QH8FwBghq5tQM>DkjB2>72cWg>@9zQNCsNck zsg`0#G*?Ja5;ZN*k&Z|d2L!@xOm~5ZaZkk*kRQQ{OG!$qX23r;+@*SO`{J|(QdJ^B zFO4VjZB)UkKEQXF1SH=RzV(V5l-^^Rin9KqTb%ZW2+dttyX);~QDfn%ImuSqu6UiE z9&8vz_=yP<4(psYt(5W4k9hKGBe69#gtw_~i@<#f!UYt2DNOx9Vk;=pg^yBHDj*Sv z+Yl4=Y22geliQ?NJ!9j~h_Tl_ua$+-@QA~G z1Ccl|C6l@-6>m|Nb%_M^>OzaV$J%;HeaXZs4{Xphd;~$gHKF)Ur?}nK#UL^MSa72LuBvaQ8 zB#T>^n(uvb4^|^Yeicv}qR?msYwJrNO%f2imje7)RYET8nOX*$UZlHfk+c`FrV=mD zAJ=?qgP~ZXqK#fXS0>2^mn!D;ZVz?KT5Vu?SQ zE>i)#ldxcCaf8mz=Uc9M?+tW{u9T1<%Mck5*iMLVNT*K6e5K?R0t{BS^PKMmYxgo( zK!zgFER3OxD`Ydb9*N}oXQzSQ?{hd(xI3N4I?D2)HbH5w$tY-ufN!4l;g1%DH=g|F zew&tVeAHn+{lOJk)mJx$WGk{tO3uz2;Aqy1Ny^OpJW*n_>>bfeMfcC(5FLR1Bteqc7&#=5th&!WNc4zhJJe);c`&VquKOCsl9;-|#Bjweur3HquH%SoO8lY zV0^HbnxcdFUh31bBeueGgE|im4%m2ot)W{et-cR$*LqqJgx15D#N^rxL3m@DnPg>k zt!P#At=f7?kq^j<+6^0Y#c4!-%C4%tdmM%kwwue$#l_p}SGb=309Rr=&Pk^H)LX~? zvG>Ack4r8>oRmRzpe`|q$id;7((QY}tC$2`JXA6dz9G#AA}yo@YEV$AuYbGWdsGD9 z;I)T%Ka6agBAvr9U$8YWxUd5q z+o#FN#j>Y@F$Tf;Ii9X|h$sXKND!K2(WNYnbVzKy+75tDp<}P9s@l(qsc&plirLxR zeC-~vvA*u??2N@?X#~6u-tt(#k#XiRCs2ROXN`!ui6(UmZbu{{+Up;&jKLi+J_2_R z1&+=rD8%CvmL7K(fGWFikpRJAgz@_ID`IG4;|Dvx4?b12oo+4#;Ez#!)@$?pY<|86 z(ehbbkCKvsocNTQmLZtvkwA93RDCZS|rBCdN`yQmStO(UOoDUn;ac z4}_5Ch*BL3HsK}D3{u0#|6pHyH_-ycsYHOCSV-_imVgz&+~~&Tn>Tso(k~+;ZyXpe zjG6nIK70s0G4JC&`!DwK+Ld3#RR8L#zY@XlnHU-x_7wKzoXuYY*IfzH!H1C>k%)AU zK=9!n%+F!?zA?bmNA_#v`zAW@DVxUZ21!UsP0!8>Zkj%y6%32{9Q!uM3d~*)+1W+i zH!Opp&B!A_;XwzlL)*`V-4VQi9uk03z^JMUgw0@)kh2yfhCkpQ17oIER$Y(~w9gSu z<{rc#`yDlp>K#6B%wdoT=r|J6%V{^aJ z>aL>q6v0kObGvlsk|&80?`~h&8eS4jy^QDfq zrlywW?sHI4x`*CH68?Z3H3%cDdjGz>qJ%fTgbLa+7?W_F?#QgmI4w3mvUAwl*-UvI zPY~Djp+_l=#?s1Cc76f!k$!G(e9FQgf~ONFB?Wt!5XQ|_LIJjB^3n=ofwrKj`k{{A-IJl3e0#ZZ=rpr5GcsAdSPB zOA(>OUuo1>*xmA=x_?Ab7kwwH>_>M?9D;HZ;K(5DV8Pw>#96+1Lay9+c){skm#fA? z$yA0Adi9EEfbe}gopMl3J?d@S2c(w15iOY3q^4(TVAj(x2Fr@Z7woUaC2x|&{MsHI z+}_?kX7Ocfft1b!AtM;{%iO#PVWD2XPFEvSON1D-jwNs2+?*Urg>gQ|g$toRcJ*-z zjx?HT-lq-E)+i_`ONxuLwrXlC`#*j(pYt>wI=oEw98Z|g6R9{P$B@;X{zvoH&JQ++Alnp7)W%o{m4rX)o7N@rqizT4CNv zUHT^fj0|&tv)OLE;7P`Tj_bW%(jioWXBo5~`Ah2@@b*iAp{fe9$qOa5w=hx=_1b6cEBYv zmK>#{?g=9{LW9-aF5she&W=q9c6#ac`k~(-7ItRUg$OZ6lF7f`+c-V%`}^)MAq-42KtsK*pVaik{%5XU;Vn5zDi$>@-f^wJ$EF(1Jj1iH$NUW zWlmMr+gkg782jFE4`c2(1R2XdW0H~&`{utUChx0qmXr`(lW0cST4>IRsuU>R7MJbh zW@Ua}x+I2{fYXEnjSNPK zVZ>DNh1G&;*u_!X_A9NyN_G^ifEW74CTtt2_Z%lU!;RML&<@IZjAgrl6uS9uT9mObKv7EOE4G?K>iv8ho6Rqz{unqlJayxf#^YjtSS9Sy=@tiK2)~ zNPrmvg*x)Z6*FqNWT1!4s}j^eJ-f--+}7r=VvBsq4YEQ_%DEH5FC$&?zx3xdhgVIN z%pR;sb!z~P@(|B5yx@T5N)JMoppWQ2k6->5c0!yw;8OyOaHzApI+m-$@7ulm?Xm8! zh_u!vKT46vKmdszTUBH%t?^^*!QlY~fwwCl4(|ume6=5+`{!B2z3yUI{wAoT(P`R^ zS9<8?sohH-hm0a(6ZS$TGDm$+GS^~r!=9=y z2L_G-8Eki=W3mPVcfXd^qaKM4|!W;<7Y^kOnv4JvldY;Na?} z^7Hl@lFrwl!z3s?qfD$72b$`Pw4h+W-a!kAQA6PAC=4@w&(BVPLM%4+304sBnF^lME_ zWl=lHq>y>u+PYCx1TJ80%70c6E%GP_ql(*1 z|3*;UY{KnYgfrH+g|`Vmyu1MLDV8`<^oG5|BZtQ@4;REUq;1S$6Q-x9MQZV=?WDm{ zl|Z;Wu8BnwMe0L`-E0^j;>&Npy)Yn&vQq)I#!HslMUX4x=Eg`-edhaO8D(s2{P14q z`1JA28~*9rLx@CSM3nuiPTCdgeRCbi6*3++l#Zrk;)U&mm9p})>(_xni6|{I2-dTE z@#4iG!MBX(at$&9Y5X2k{~s-V_;8&~I2$t|-4wmlaUq!}UJwmwABv#d2D>>A8Z;=C zs8U#ouUdI{996y3H7_iNvZ5pW{))^jz$^@cRCnSPr<=L|L33XxBx{z&M2qlT#j&yN z?E-0C2f&!kVe~|(fB?u0OQbx@Z*HFd{JE{MkxlNNu`y}x@>15tZ5vu)LzMj$-w6e6 zNDhD*Ym2NLoDaS3gK@yGF$Q3-8k3GXd|M~3sa}n`8aaAZYXJJoO_cgFB zH@CBA_5sk%RE=jw6u4Skz#BiYy?u7ZfsYcy0~E>6t1jWK>@)$ND=KsF{2qiNSmMO~ zp)VOPustv{>_Nb;v;S*TWGp@^HYOt@WB9DQuaEQ`{Sjd|-{hfta`NoVO-E-qCp;;M zIU372N<`k64`>1+EWz`iph^sR+mgmdfQl&cVZq+HbH~^Bg&sg^S6i#=r(t!xxJdQk zC-Y4Y@@LODpM3v^4abp7cxI-()wq2-Ix=!z+6qRn@Y1(1UfDVI-TJ1@GTZU=BMpLA z46n4ETS!X_nCmH*;PkTd^z>9Q3GhKic>DNxA%u)?!(@&|NG5^sKOo4BY^0>5+&x(C zutMYBUqOFqHIQO2g|--cBLDw6-RQMYCTN7i8paI_dQYA_k&`nO#1Kwo!#9$W3p#rs z=D_oERa+arytz6jzz1KPx}&Yr)7`VawNX@D?CIq_JoG*M{ab@zCBznAaXZi3hZYN# zyN4=loG-o|JYsin=;=+THO5OUr&70nEh5LsS@^eeg{=Ao7)ZhHKu1t28-QVCVuCQO zqKXQ23U8WP>wStNg!gdE9T-VcU-n)pnE?#Kp&_pelJ_Y^?aMw7h^Qnh<}qzFvwT?=t`83|T+l z!+u8SoIo`VtbiLg>e5C2F)I;Kxoj?WsZY9)cp!lQ*_%VR_*v$01lbCb&K zI663V;wL_rZOAPl$ppFn1tvAQ;LuR`>VKae>$UMkI}@e2X=#z`>gs|gniZ}6Um2}S zfGsA(LwvJH1alaF6I~;IV{2m*?*UTdUsNV6`y(0=hN+}kkh=kVo)LmvNL z=_W6HB{L2P8$J@OloQ)=VbQcNN7I+!To|B4#kEkNdM;Owp?5(CuAZxBhr~i53ai6_ z3t7Lz?7F+K*@XP0qT53imL&XE(?I+H+4x8__!;iHlvdz;Xv^UoYQ;?4s=5k7Zoj4|Z8C=-*qQ`<{5P~!T)4SIEma3?#a^5=YBz&3HcJa2|&vmJc+N+k@)vx6YinL+5OVReX`SG3szH#~)gvuiw4&a~A!N4j{yF zcP(ic)X7jOi?q6&e~La>F=qlFad$tcrm+$)w~~Bq_>qId(c$6p`sNS6172uW?d54_ z&%ZzQhnl6Sz8<@uV_;@Rq#Vw=(ZsqYrAJ9^q=Dl}=2*RcU1Mb*c($TEGPsoKZVa@2 zfpIo)@(@>mxfD+lM(u7S^x@!PpdjYTXHm~B1dRXUE%2~g@Y=V+IDT0zj*jcXg?|)@ zHI#0)O?VtmA^@fi~YVV}VuB15^@4?ewcWyq?n7yLP zZx&G6MQZ)WCY)tW{_MK@eGqGktEf3~b}Cxmzr=s>!$WQ|xtA+ueQL_$Hypb=8$`uk zGqV3kHW(&No^LZ|OpA^1o0r{CC3*X>|3<}H1EEJj;M0q;1N0HT*ZsC7&Um;lS?yci zVe@R8^$sD^9Yj98^|L_m-pE66uMmR1+9XIdzIM_Ok=1sR+V;M-GG#WWq~hpD7?M%7 zV(CFjinR0$Z)c~KuQj+;Ust~=(9KiCqq&6U`P>y9Q&U@u7eGlxHKr33@{``FTo0>t z^j$#7mXRBP@0$06R0S(+;XvtHEUB@6#+Xg66J&q`BFS$9Q&Vs_2IGRO5f0Deb78Jt z%A<0`!@#4gT)0kW@1D35jlP5lk$N~0me0(+r{deX1M=yz5 z@N>U=+S8V$Q_m%ATI|F|1Mc!R-;FU4FnuVDx?MQ_`{)ON#j~dGK5}^Ub?qzdyNC_p z@X*8dKfhs>bTEc~Pr60y;!jvu4+Wr_HLr3IK0FDP)gn`)lc&qSl@E|m?*S(B5+!O* zZ3iA`3$37#TD=@KAy99NP?fab*3}AnH6r$sEFO+Ukl}5WQ7P*qg!FYV2^ksxO{h~0 zSKPgE-ww|__2}F<4iS|@L|)$DwOX+k4(lMm4izC2#P1$9Ej|AK|Orx?*CH0Dji@T0SxVf=$s5?mmIgw z!sSyAy+-AAT*%E$lg3viC`@$qN|^zFmc)zt$8 z93DRgb;X9ws?Pi~8i&;Gr_#$c4n}YunDy~iu+BKJ3ByJj#&>~%cs0z|9G^TnVn7dl z90DJ$Ph%4(3r~Nadi!|Cj#Rl_lmhRm-`S|Tlsu}CGBFzAFrbZ}hpcJ8%}j(+kOW@} zgeQY6))oI>M+TXJY_Q4{+M;0TqrjG%HWlO-k=7Vc;FNlDaLV`B$%+$R)!mS_vGHPk zPz7{!FzLfRjjWiSX&D?CB3x~B`4ajr%tv2;d3qXUsT5cT)ZAVY6U5c3`-~4_&);9Y z7Z4j83(!do)LqNKrqr#W)EmpzT3S)LL4O7ZDXfPNx2E6_R|^e;$&Y z5-5^QQOtyRO&2C^5HT=1Dk>({(c7yhi_5tsjZk6aWDGG>F3h_I*lb9hH)|d28&;d; zVwvygo$Q`reUQ)>LCV6M%)(w$(gL!yPOpVGr3y{UE30|s1-91K42-POvf>1k;Waf0 zwTZUi#U3M3n6XWiE8AqLbV${8}Keg8t*)TSs0{i~`2|DW<=sn%Q z7fnq{8e#n&>qe8|c6w068%E8~$Cq70@fcZs2?#USo;YS*1}B)HkPyt6evgpAm_(z3 zN~wd6p6(XNXrq{~;W>8obfJtN6blMXO-xv@FIJ9?RkWV%Z6*l4d1$P1G?Y>Fa}uy1 zX0x+mlBhs8>R9=P2EEH6J_9bPZ}%phx5z5d#oC%Lc!3 z7U(>(!xVxMMVeMt_~jEJuSQgY!$L-fwebOdbKl0a!I!nC9bnBgI`aCaFTVCCyz5w9 zY=L)3ztUx)Ae>E@0ZVas7!woytCWbG95u447|MWIT~qG#INCA2ey<98lX>@GNEUNK zGDSyxg$c}7-$Gws#0Mgwt1(>YnCR$Bmo6#XjCEtf0UO$Nj)U}|4=Bp$_e-)OWMgzt3pgVO zSjkbpTt^|*8Vw02;sUXfp5)cbiPzAIl6XfNhCvha;{Q3cwyBrz%Q?l?RBlKS1*av~Y5)?+tMggst^k zg)4xcdPF*O7s4oEu7p4N%Pe?=0QWWmS-QKso0XN-(V>*b4qr|H5y>)QJsTXN%F0Sv zrfSHjdgkoyKj`IufO12CqmPF|t$Gmc`;LURE9v4tO{?+|(N+Am4tx#bud=BQmckx5 zHmh+XXdlSQpJh2hz-u4gdlPmYgbKp*; z8{nP-36%Z_TCtO?(=dy`(Mr&q*Mo*-GRnIN!F%-jwI!l7;p^A5w6v7X$Hx-cxnv|H z>)YF~#ts2o^!a0VL-mIb@8{lmgkZ{TeNB!A#IU3kfLc=_)85t=j%;`kRNv>PXQo1tVSwQE$li9# z*j@dP3>uoZuhJmZh6g=5I9li%J>T%MeH&;-XitD55WnyOTEv6Lk2N((MVQV^O-u+1 z0(zdiSOhp>LUw}^LIJSx1SDA=m^OJQ1>uhZ9d4u$T(|ud0+;plMyBS-ui}rNL+t|^ zr|7BcVqyS|TIvBYR@Q&LbKq$`!J8z2&sLGE_!R(t{NRQKq_$cUb!qwvTC+@*(w zS;b&@nx31J^EyMBYM0g27*t{=7AM_z29w#RDpFHej12FGj}I!9Xe13~M34ze+9d6O z8jL{LIx<#!$w=50CUlh8P!^ohsXp{*Quar$K)S~QCI5gtnBD2R~HSp6aUW1byf+shx)6e!lV^@y`s zpgvM04l7rWiw8mUzmWNq(#_4sqJlCp2!~IPWD45W)`|j#wpHu#agi^-HEqyPD;2Jy=mrKDKcw51S}Nb!I+prslzF+oY>ymxxIHFEb| z-le~pf6sJ{tgGxapC<5*2`Y8Hk!cf9T6)_&Z!%U>9Z7-$E6Cc~TJ}eb5ylGS2YGpy z{N>x?S68#!+mDZr;ljkfw9xvZ1hlju0LAKMU?f@w>z$H>fUn783{>M?p3yoVXT6a) z-Y`I*bfYSWCY&uSkSSS!l2i;x3g??#S+Ue`#ui6L7K9R2HX252*w-3RU3(CB$12Y0 z*Wk9Q1}j#hDjq33igeJ^x_8gi^u>)wSQWfdh+ZCqr0`EHY%Dm%N172;Z|*@!@a!4= zk`63Ebv-<+RaAT)vits4GH`Qt&dSd}S^N9PJhg;G^rf23PCL=d_<(c~tXvOi1$!YsZxU{gRHRN6>da|l*1c8Utdd0%U#b$ zchkDfqB!Pgm=X8?Ec{$7B9ph>B#j)4|6M~uSpn79aog8Dzemxl2CJYM;|G2Ej zEQ&%Ymq}f}etq!!r(VWm!TF@HJ*c#Pd6EKpWY{PbNr=~ZOc2q@@6Usje`FLCpc5wG zu=g#L_kA51k&wDZBta+G3IH*9a32{1Z;fQ7g_i5Ky!!^1qA%Lo#A~nPpl%#(NE&p- z*YJ*ERvbxWuh5I;J`3BmBHc^g5LBSTfu((XNFg3)F;Vw!;JRfi_>JmFB2BP%JY4u- zQLYXzg9ovCtXGzn`%TK$g8;jiU2b4$w+{JR2r zeYm+Ixe?w4Qy6lzI$7xa+CppDsW2~Q$NMXSg-FE1SvwLt6=c~y-fa+!9hGcs#l)Vv zf+ELT$9&iLzM8D*lZdq{H0m4lOYZ-Gn8fCk`-aU&qTXyb-8*Jx;PzhnOiF{vTv}T* zH!@PSb9c`I;}#T0q zA!h7AkEEsAKY)0G!^W3)**)QaO-V^felZ{HUWR0nyqOb45~&2+y}`#3gE!JGmS6*} z(nH2g?1(+QDlMH~Rz?%^=b1n3H-;i!>d-X+R1)ltHva#$bIs1aQF0;vb#p)2hu*Je zBUM^nFiH#(2vn5hFc#5{q->Q!+GI`yx~1TKKK2w;TiSr@J50^m6u59G_8@sJkAZNs zvW2#BFcy$U$=b_9;2lN@2spr1E|_ui*S`TK{K=m7o0A4PZ|T~kni}7Rh6F}NgQ&>J z2;Rm4Hi@VX4GjbNH*Vh#_qSgxZ3^(sofH-p^6PVc|M&zbki=`$eNof@9oygAJDS9@ z)U&a&YCenHYDS>P%~YY`Bbdb5Q;hK2NymD7b@bb%gPrzjemM;Q2FTebS>z|N+JC-+R6hcItXLv>c32=1>2FvpGZVspsFbKQMKHBkf+knGv>KhB=QAGxI4> zUro&_*f?}rkyEpqcjVrRe`Z^0X|b|85TqMCmpt|LY06Dn6E-$BT7rV|`1sBO0sx1J zViFb=)jKCf6Kn^UIw!@dX!rmCIlWz1H$HA%!F#cx$e3R*IW^@nKfju5UJ^-U#=3Tv zC+ywS2*ChAz~rqOtNWNgJPkZjtQaasCx>BD9Ph_F)Yy^5;mNsEA@18>M~p^~?~!lm zM2FkUl$ZCjrA0dbI_fElc4x)jU*sjh0jy5y4+fl5#a}Gpya5C93pdtbBjYTp)$?`j zWOR4C@!RNVm`J?G^w7{eKrMGf7HFO=S(q8_fFv|0BE{5WJt65oitRnm{%6kNF2zsGhnQmirIv(DGZMNT$%H@x$0$R_SSZ$?h--u z7MSjn#H>D)mc~Rx0d=glye204nums9x%sZ+J4 z{s=N1lr&W^x8YES@12#^oJw1{VBmPaz z-CEig5sNKkZ1_v!;^%#PLHL%IkPzq^7#kf@nIyfjLWv&vRVL$sadDZxyeh)!-AqFH z^Dr2RGDHf)thp}yDxI}B><;y9NnMcyGRt*6IvjX7IOz9&u>O9UMbTpsVmSH^+A$3! z->rN}pG~(eRgO^+Ue!{9e{M?^qftzQA@B=g zxuI?~S5pcQB0w|$*T8WI`1X(govZ`@Q%+v?j_E^*Tkv*-qlV2g&MQtMonWhf2%~;O zLP|59T}eF5NOb4UC@h(;N?n=!!3z5> zF9cfc0Q<##ID}X&g<3)lz=$#xj%!1xXg4_e_&lDWRf@s1e~2zJ3GJeKC(#8 z`2H#I@0d;CpI@uSbEyzHW}#-k@g?u;^XEJb5Ik13bE9g~OS1Rj1R&;cB zF3H;yzoq5m7IWPU|0OgolHAM2vF%WgQC9 z88RHn!Q&?f`}>ROxnM_u(3iLp(;CyojE~qm=deqvlz2}Q1u7lZ1|E%creKxz?hv;T`QQhB!A@*TpNDanK?*XGnc5()Q-QBql3`3~WEr>9S~ zJg*f7$It~})gK21*~)dykeeh zI&UJ=8?1<^4uTSO`2u+=YUI&<8mA{_R1C#J?$S%QKu|a*_-)@#)#qz2!dP z?4EZ3!JKJ4I{gpW7$eP<0@3fK&;<(-x++;u(kq#>z*P?Jf%*5uL-ndPb=W)R<|liE zN~XoJ$;kq87+3eh;+`kemqNZ%lk7*wtLhk`6E+M-t>B12Xrz6b%5vUQ_$lm$4{ZE% zwfg?K=qq)(UqqTE3ZI~xXwAP7lz4$hj0vZ;f&pJmNlUBb+oa4f=dtBy}2l8#ZvL`xYA~F z8$JGgtXAvkA84pEdJF#j3Xb_vm=mI-pahs2ZEoHcMo?$BmDoR;}S$8w@N$2+qjp5#Mb&->8W&P3LwF|1s{g{yJKg&K;T$^5p>KVzU z(kP^}Kjgu*3drp2+w^`$E+-WbDt zA;dvbYJ7bBo_bPSHidwnPOKT$7dUwWgYmyzpGZn_;(ZVQIT>*;@7=v3F8+JBM+~UQ zV0rrs>dkUW1pPXg;jg6V=-v_(LcMX<)YpFW=m`}Sxyp4p8JXjg<1WQJv=qC0U=laP z-}})wIgXa5YLJujXx7|OOWG6D|EnH^Sl`n5+Yg4S5tqv)C$h{bJY!Q9!6zuw)UjOidtcCrxcI)5)U8GR z^^E+xk!v>;UuR~A-%!Jdn84Z%5HII(<1P=SctRUXt(x!II><;#)m(PJz{a7g zr=^-=6j^i4Xoa+6dH=^)(SrlM--{-d zLR0taljaF_a_>A27t3OqYO@V{Bat=MNfCwYSJpC`y!kK=f1$CCUGpVY0`ucl@#e^Z z{STgx6;o@jGM%J_);Z1K|9MX$xrSHIP2TWs{C_an?Eo7ZHqL>p+`URMx9k1JTZ7zg%6Rm_#asW6P$oSQjzEd&>&vp#Zz1t(Ppeh+@mdMgn5RMn7*{9U$PSj6 z6cjpI%QL|D?s-0fdN6=pmJ}D`*OQVG>gyYnjir>7%1ZJMz5rd@dkzn9%(HcyKWmW# zhyPaXeSLSYMrx!g#tWE^zj@XOZOt6G7d<37l9l`DX{NHdf5a+*P#FC$%-%v;B16GvO z>~hM;F-NBb)XamIu~pb4gl|@;_3yL849(+L`G3z|)&8aXQy0HocJ%jv%kAv5KG)f8 zo^qAje|Pqk24CGP=4sPXS69cbtc8NyVWPgBBcRKMdfMQ~4b~J=j05IMN8q|y!PsCN zILyREL`gg)(VnS13~(gg3<*ojP$WRVPT?7e6T%4Y5EsMMJYS!4Z%WP1*O%3eYi=zZ zATW@g%lZfvo3RNAb{5V>pxow!ggkHbduBQPtM{BGLbvlPzdjUfLns!|15{M|l$5*A z!^64lSF&2}MY@c~%pgzXT#=D|@3TlE|2pYPExd2J`56D9P1EphRz-zp9&g*k#47mL z;D$>7awF!o5p*>iMxl_DGC6);>V{1}G}ZsPzu%Z>Y$DJewDk0^KZQ*DCc_t{YKcFX`oT_JLMVJiBrY@MHvVH$+u7SQF8+MpT}S5y4g-#46zv& z-$DUlH9OLP-NRkT9Rrn#SEwl~mW}O#nT1(vZLEm$eV8YK9^AfcB_!Zu3_*Z4BzHrCbKwm8Q7-C-uV7@$yz|kR5EmG~z5ZYHI(06`Bf?yiXS`70kToG4R z9H2R`yIYGWk~l|qy6gfoTWWe@c#6HCz(2D(!s@Bt)617HTQ>UsGhbc3dKLaU2;7hh zp+h;2fd3awLpARnWX`b*k~oKG2C6!4wRD+kn#3tZRB z{kgEoGizaGMLdca#l)3zO}_+83S1KXo59~AC`kT6Aol|fht2Sh62RsOtKfr6O_g0P zMM&`rh~u+Ua|{`9%2Cl#U|T3>-ak4}F%6P?sQjL6X`a;iJg!XuPk}_Uu~2%mves|e z;XOS(Fy*bFRshn?P4pZ-*TnY7+uPlt08C>I0e@2R!rHgD zaf6LeSOHhHsHmt+;k*Ou&{Kt`A9?~a4R!#H^!K=9XU90^Q?KQjW%Py&#EEDA&uT#B zIp;&k%+}s{Cn7;J;0QV&VH5INj`&MZe&^Y`XfnCSPd3(06$mf%V*ZzU7#-mPM2(tSAfyBtM@ad#*P}; zd=kzl`{@J4)+Thr_7Mg)HUkqA2)VGt9~c-AmiYHA-q6s1 zH#_0|!Vd+?J<4IFHJOj5d%k{Ew#kUW@~tJxN|)J4ON*zz34I&WmQS{~BB5T;*La6| z$XVDQ0mM2X30@+zAcAJr+hZLZ1N3X!w?p6_#Ry#t^0G3YC`8_5e@&=DMqW1#ZE3<1 z-+1zOR⁢^X!?z#p|3F+c+#AGnI*h$95@E@le>PVrGkxCO+7+6x^GISuMc3rI3)6 z0>LvYp#U^Q20@l}Eb#MfHS(@BadO7YiH;aO(m>6&|4MWaLSLJ1xxM%*ViL8qh z6_V0QQ?nsEmKsZ}E-oqxXB&~CvAKClT-;SfMcoWR)wHX8S?}(q zU5qvSE3*PYp8miK(FbdkNhDM1z~wdqg{IH$8S(LI4Q(k% z6eoW8+d}7^edNE_P58+Pl-?GHKZRwbTupd*_&fByTTHl2;?>Q~$uv>RalQ!Qw@9Wp zSAF4XC86lnnt2T8q+M?Q{ZBK8A?+}LWvRO*A(`Av-c3ZtUdP%2O7IeezoH@%D|xhb z$4!s=oaUU2l9JLj9)d9gVIEA2Fl<9WHwVV^tEi}6Xs&NTH@0-mw6*0H6-81jk@uO> z5n#wCG*d~iqu;-8{an{Bjvk~tIXQlD^>r*g=Hh|9tJ+nC%CFtJgx+GUuJ~XsKClI> z#`6nxch9D$D-%M_00IwChy~W$K?$%x6Q#H~MrA@PXo(Z>1YC8gs!IC%_3BLS1hD>d zsh>7Ipd>)4Z-?BGt?3%a44ntk%}l<>jAWO}Qp&W#lu^-rEu z$|D;sO3ESNPi z7AVrT)_xVkezvgC(ZK<+7Hl)v+p81Ixdp!zLCzhZYr-U1P#`dEx?9;YxgU~{_J((D zgIr<|1Jpg|f}+6R8@2YwUFYSu_^AUN>g+cjf)89ipTe{hLZ}(CCrZ!0JSxX}^mSQ7 z9@B%0?aQNlECeAL?kn?<3px^rwrJ3g4SEkuzVp@MoccXo?b#X3apU-!=+DHr;s%kv~ni1musq z$?F?S?e3XZ2BI%CSnRy!hpM>!Zjz*tY^z(QMl-)IJp2l2c_?NrxC}IG0*NrN%EOu* z=2G@jyUJ)PsxUVfetL|gq=bUs2{^qzLs&S3a|wifND*`K%Qz=8LoLITHHa0%JsDbS zlw<_6|FzuTwdMJKm|syb3=f{Kb7pfV4OhC7-{Bb`SE2RhqzKG#r+a_CKl?q>vK3}Q z#@*xkh3 zPQYH^7Y>u&=Y;q3UksAVeYt;!D#-k>F(Acxs(&{b$SC>6?$g=Iq?*kv4q4G>Z0w0Mx_GZ#JAt9$~mLu1}m%`od($F{KZMHMDJJ_)x+wbMmI^;O!G>AXe-Tj4OiziM} zskqoCd3b-1x1pv-q?y6<-0avDfz1zD@2r)hBAjV$$xbw4Uw3+47ZO!*Tjlex6Oc~t zO&1h`qPN^OcQMss_(%B(uDblo&&{VeXN0o{20t?@DK36VMxd)>Qts--poM5KQhQKx zAR~1>q$3{v>c5O&a+UUbpGCz~Si{~t464j3xB;-cWY6a{$QC5>?dqyN zr($q8Anv_mg|BReYHiPF{8dmHx78I5_}37XRn9pV5z_nz`(hX*EgX*f`yoG!HmPNw zOiYc94NVSr_a&}gop%|yA}M+OdjF6y^{YH@-Q1d21cqUW)p#3cujQPiS%e(++PEh% zZg*tpJ4(T9RD>vE1%eoLagW?PS%?JOXsMl0=($K6IIkqoa20_Fd2WSX?4zZe=WTr#Y{k`O>Z`(i zXzdW%MnM0iVzR@xu2mtz!6TM6YSD_?KYt4r^wH<2=7$XC3~fo-k%NB$_Ur8Eba-$O z=ZLeVK%?pI7qQEcouUn@!E_W791K!MX06vlFOoH_Tes$`lvZW&w6Jpf;MNlGpCsqo zCBcmxESVWg9-UJN@z3}vjmLi`?%IhQxhjN2u+CYNrJFHskA2Fd=Kd@rft(}hzCs{Z z&tf5p$%)#$CGghZ#;D@wOF~mYvU8$!W71_EN!qeltx`um>_g5Ac0193JRUwc;-x4c=TN^5Oh>Te<9)t z9mmD_*qIU-_}ZHiU?7p)(vEmh_hxZ_pp{KUYcBfnvmEyGdq~K#kz<9T+V0c6B|*-P zK!--2KhZ8Pz}T5-0;#^aK6x_F3Ih7xAyD0_t7|qd!}{ovtgP&nD^Rak>*x6Uc>c3X z(4);Op4%SY`jATK2!cF`m&AnBKvSjZsil+$qNj_DM2&5iNmC8B2d_wkrM*K)2&mXi zL-IsMz9(BM)T{mQ+gTu9yBvDuJ%lJ;7xc*OA9#IeS<9HR*6Bz5YiC7Y@{W^0x24NN z@63tIRTCvd;kuLan9Hci?M&vUC&v%1TuT~LQ=!>IA-JF=*hKR|jK)($x(R;465x9 z*bN!tu2b_|WbHan*hGe5q7#rU`zlT8o-!k?mN%<%jlSy|ZNGB3@;%SrVNG;O_+bVT z^c57~9K-rQclJ2LEhjsU;F*q=&NH9CXHfQ6W?lcf$NsAj3%J*1kt9va)Z@U)&t2X? zv!Mbs%%R0|zwhi1tCJInuWz{T$u=|Fxr?An6C7E%4PLUY^uM}%&QtMFSk1C`rFQyw z6c%VUP0GlgvCf}EA*4;@b5Ez2cfQrO<-6ov$QbEcua{=s?s(-Nk#)9Q{;^ba|AILS zTs*w`6U#}U8o2&r>ErEhYj1G5b5g!chQxP3|}IjrxvYmut}$+rY6-B>?rdib4C}kd023&zK`pU6GF>{ zlX@8D-3U-dhSMVQ-Zpbe>II@c5xBy_TQ)YIVCN5@Q3c7SByJoE@UJh@qaC&%dl8fobH~SZ zP~!ExvC-#MNbAP(0zJzd&5prK6&I>+3zHgs$2_HclSIX5W{_wehNfR#I;LL;9PI@z zHu0-c;U8|6qg0HO)6?A^xJ=J}V`66~8Yg=E1iT^Ht*zdFw@K$pfN1r{#-Dh!Wn$uO z-JO_e33P<4x&S%_u(lP30{B*ETqY9~8mYNcyLv*_Yev-bE4H5=;I~%IzKn8lU={Yc zY2s5iyfFn*=HP4YZ^UrDn6&T1ZPoY&LwI7&aN`^uJI|n0}i)0iPsnp6K z#_G_gps1Lk6iBT@a$hP%j@53@v?|sK7j=#bC}9Tp)=hQI{huF+(X+!A>SWKpPLNw! zke;pp-5%cH@_~|Ap@NO9ixD7l*|!SK1uKiNC7su{3j?a^L4^>F?!5WkAL zHYaW*O+|*ez3Xc4Gh)Cd2=Ni8Y0mi>9w1`1#;^UnE&n*6@|%koN0n_;k-Wl?QZwPX6LT z*bd=HA|HQdchsTl9~h97mNqpp`F7h>UQULHi0B*@^``Atw&7tVnJct&TU+4fGqtcV zG#nb9j;c&yz7sO~+euwnyQ&c>oV;F1YIY>5@uFaj3{}iO^UI8Vzwwk9b*fAAZk zfym*Ri>nI)hsk{VHV$d`WA(?)TKCziii*&9Sh2v*OFIhoy}>xFMqN z%fdp5#=91*G7t@j;mf>n$3&IUe7o)AtaYaFO;S>;Qds#JT6&J(Xjw}{qRNqxEALe* zu*43KRwN>}-nN6{#esAM~E_?FZfX(VhGb3d$gIFmR7 z`Zx2`)bvh!XU9SVHtpB1l#~>!b7;-T`OQsgsxG~~!7J?*sZk>#b0NF#A9*E>{7LjFnZB|%2+4+aGu!59} zCxgJ_-C$-prbx!~pEX9!8|iVeaSHlJj9V1fQf4mv*OslX}RI zmCGJ2REjEbz5U9#x>nbLlZXP0pb%_vDI{dlgdq_dH|JbjZ~TQ0_3d~(IV%XMYRLYo z<^KIaEdq?n00g>Tzj^cGw$m>m)%rTeu7REzS0}6_;G3z?tgNh%4mSrXW4Mr7LoQ%C zkaFISmnJq5#Zav-CML#wePM1cHZGl$o<3^kZ3KjkR?8L5>wXKTQFn}w*VWfQwF(zE zXk^7T9bLwV6qlO5s7Mj44NT1Tvm?RLPME8&@bF1f$(UJNoA~Xh;^>71xHAiIw8}s@ z+S<*Fd~dmPumi?bZB0$(Q$7OsrJp}lwg^O`re`Ej5siYhu66-W-nFpG5i)tG`S{eq zk4J~gbW(12C?N4&*!((xVkdWl>DXDKSu&(4_8RxdjvfgWWCXJJymmY^rh=VgZ z_+9D&I1*o<@We3b8r&i)g(eGJ)>{zY-jg^#Dq^>dFjxbrB+$)G)P8{CjGmo#aA*jb zXQgf?E5XYPetRCCf5Q5`XYBHr^|duEeSIz#mT>}9eF+ak6M0Ioi6V*f3ZzCLR%SEl zUmvjm;% zf2ZiTzTEf!C3pXYFXr-!>C-UaT2Uhn=T?}n$I_Iq!m)xAd!XYOP9IIS*14<1P|kkmSJ38=&pKUll~ z?wY~FOZP({I>Psa4P~oJ)xn502u4!A<{jzCeBU6)C;K$>lMO^JAS>o=Mw|xtc~0oF zT054^3p^XkI2-tT`U;MA3N%5~G+5Ax3@Gu*QiRH_WI>P>L$aOfpg{LWNm#l3!B$Vj1u^-R8%xLa2g`| z!^6W6^KB+am#tz#!U&jBCue2a;^9cQf}QaNd^Q34265I6DL)g2w-#34vnU+{9@}xo zv4VfaCr*BwqMqbzdB2ZWipJN@w88$(#zW{6Cvm34xx90w>ZRf=R2aTG6mf$$Z z5a`^gADBx2R}MHPFC9}Ljcug~Wv7P2h(6EgDr;-}9BT%1CXC?4-G_?j(EZ~jp0lUB zebTMpV|9<`dP#5KeUIk?pj3~~s;5`y-aVdkOG|YTgG00FDoBl7Uf>jg@2w?-)Y!-< zRvdu_6WYkg2(MehqqAvQp|J1m6SDHc>oKqC0g#U@PJ#-0p4;U3;C0}FI$`tR#BQ0Q z+a#v?wmYfO9&?lwUA*~NSGZ*Y!&e&(0z|I2E}4NZ$QX5bNe_2?sSK;j{tKPNzj%jfev*C$1pQ3F^g}w;8 z^YM(vV}uL`y@GhLPf~y`Y`B?x^Fh6~Q#n{5TwQ9^ZJi#wN?$R#tvhC2-LlXt0|&Q% z;L2dg@1wu-G=HJ0@nqt;QsY1Zsl~kh)~7(=)BL({o0FD+%)Vu}B()%CsK~Tz8p223 ziYGhQ&Cazszu@QE{ukxi)k*(YHAbG#C9VlD$2d+x>3Y zMBDHleX&0Mh|5T@shR$n;m4Ce+HXoz7exD+@cPRpF`SRbtF8HAs2A)-qLzL-HDR9s zk-ot15U%RiJ?0R=y#9vS5&ujNy(F&eQQ;RLvJQ8&ZxoSc;2c}yPvQ;c&c)hg#3l_Y zus~hw8%q}S2(9((T7uQvS;;Ie+V~+!^6~jJqqfp@av?XO)5%n9Sn^{4f`ox%oRsv> zen>|5Ib1;bU*_$$60GLnx9@!jRo|#tdQML2m-dwtadB}Mp|7kRm*WW78WDM&_Wlgc$waE1^KW@5}mKMD+O@OY0Kl3z!4wIAn z@kms?Bks75gaXGNyoaCk-6ul%LdM!7r*no1-Dj-*T9wua@2MxM<8mRGaO;;Aq8L}f zlrimuK>dgfU96!y+Bcdjfktb5t1qw_n^#Ez1M`qnFD>}Ek|yvn{IM(r*<{Z~)%vqO z`g`f1;rT&8lySkOm=oL)57&gPpZ~(>Ht$a5f0Ax1A+f@r6t}5P3>Gij+uO6;1;Qrg zW|m8^a7&3qW%<>3(eE1ZReZcL zevQ54|L7?Z`qyw8fSl z<;JgXMZ6^b)5Rt}@U$1XnZ?VNHm?_OHetWg9Ah~&I$G~BADkCPd^xN%`O~rOeXg}N z)z{_{q#jSrH+SK3s^knJCV(*M% zJgw~yMHljf0@gVW=jzy%AF(89x5<=$;qH4jJ2fO@_1_ZPr{L&Br(?$BW|Vu&GJ8Q$ zk)rSZc0Wg6LDvgeQA}Y`QQ%&mw9QMN--jFPo0~Aa^&5v0G>MbNhLF;n?Y!DbmwmLn z8?#8CaX+HgWAWESC7f|8NLW?wjT9O`+ic*iAEEd(H=L&(tCY%$8df=U`~Ium-A%oM zOcmS(hC`B8(ESUNJhpUB2mQ3j{()>J32lPCiMq$bOWP)J8E7oE7c1j|2iS~GQ9Kw%C2*yrEj=!+xRG2x;5%V6!u*fo(LadSbZ7 z!(5d%He#FU%)Bh*U&$6jwGhbHrpl{3xVY$$@=FHiH5Lh9ygvKo3kWxka0krGYX_+f z5Io=(ED;gej$~kFPD)IqK6h@gUfkNutp3S50O|hKP3i0F>*z#P>^=fh03=2=p91fp zNfk)5ySvxk1yVxTzAB#H&17igc5H_JUjhKh*#LH!t&6E9keUhi7(lmlxMQ>WjgNw@ zZ|w?ywX0B|X@R`!|ETEJe}e8F)MUN<`4P+7WO;clt-!89uJ`VVSDZ`Ry`o4(?&IjZ zE*f0-FocC?I9gTAtI=nk;3!ZUg1n0U%?@D%#ciQPh+-I!_ZQ(PSXfwq#}lUDf7I*v ztUp9Xh4A{-*Dot8%ScVlxrkB6)kx0~vRhi4v$AoB2#Y*<{FrDhIwFdw<3mXy?C3*| z%#$-9wuD5<5+=?$su)Eok>G&6Ua;wrg#33~m{tGG^yG*H00J32@(`-_V=TwP0GVHF>5?53x8^Csyc0te*!o!))GQ$x(&CWP;U znS7a})H|eb2K=_O+SpOiA-j+fBqjL;tN0-G12~kWuD;c~MGQXg34d{l@~@Ru(bHKU zdrU*r&*LjP@VHKfhK5E{p-E3qkGhGP*23MrtoIGr<2J71c`W)h-j&1k zO#rj;`c7!bUXhVHZ5EdAvHnW)ulLAqmYkMJIt+(wc7Fag=r`opuGUrptf#eGDL`^m zRaNE3)TwW5&Tm>9TZuF;JM&}1{KCNRw^FI4r3D{XrWyQqWhI3>ySoIoC?S+((gVs~ z#J5?HonN`$?wz8;4;z@$P*UcE$mX_gsK59zX>}h)l+Ru+nob-K?$rFGlk%J8P?@w? z0tPoH25E#rQhwOuBtm6-f(_+;b2En~8~`6Hva=gLz??qN(Q#Q;&`~wJTjUm!X_FD) zZ~y+VzJ85|3>0*=fNJ+`lC|X?49(DS`YI->iw*}Bh>ddcjt(CN5KMe{)l*D4@wj<; zn2*zyt5R-GPT3(lnW`=cpI?=NMYP1#<#v>aCYy@qZ+pj0r=S{(rLLzD2612os29P@ z73Y`vV3$yicpj<8FFYwz8o?n9G!1x&w{cgv8CkvnRA3928cTwS6RL$232a9|F@tFi zQG;ljV}t}KqN{7OOA|!l2x#!D5!?N_w@p9 zoT&4D<7X1>;NSCPWZ;U0Iiwzn5Q_id>QOrgVQGFpHk?;+OK_>&#f#TbsK;^Z%0>X2 zV@R-oun&As;8BKF2q5Ob;yW?zP1R+&!WXuSqH(6!_dWpuAK|;JBFY6VBdY*62)=O; z3{Vn}?>)1e#7bUMn4TEAI^cj~V8e|!u_^4;cJibvJYE@;-)eevygeTeyQI&3Y|?`j z>&t70pO3z0!_%SR--p}NK5@$kOYCEK+rVS*poXs<%$t)+f&hhF-l$tuowkF_ z60EI?j5vb~=~8~TfY9GXa~CYDA3B)q!nxsmfctjs;r z`jc37HEF8T3SUYb!!XUawogLjhD^zGN zC|6~9to}%Ub02I3ec#POc${!&e>a**AG3`m9KWmNpNQ9$YW&Zg-To_k60es_;6o`r zOIwS?NEGwL2gAG@FW0g)Bdm(){kGm={{4$U9>SN@tj(*gwd?)z;?0l?2qKkOc7v^S z@20g56G9t!7jKP&Eq{0B#~<}%G>6l!I;R8k&5E0`7QLD zbc9o6u_{z1>-*F?)Ynt7OL1mtqq6;LZ|RkKd;526rIPwO5RvII8pvxrmw0lo$$uT2 z5~ju=Bl_G8TuMsjKTu6zRGw`*IJVq@{=(-U{~WHwUFz1-+BRQbUJfrTo~r?=U~n72 zgh~^&G_&Njt-O>-CW2xsGW7l!M)tKref+e|%d9?C?WGrGE%aB!yOK6^-hRbIi=wv3 zz&e3#-+WsU)$gG#>@gtVIUtZ5%G1561tnz^)D)o@JI9@tbj5V}O^4fcB*ORnklF+f zy&hW{YPk+}De}s&jPDG3f9I6<+V416Kj*#$j>!+*TF2yFV^dQWx_9o(FSP$EMy<=ABE|YM;VTJcTlesAynRS@2v+jCRASGA zq=bZnU2XfDH*fgV-9{AUx9%QiAbqW@ugCk=T*9kjt0|G%m!qbMEiCDN zmEMSiTpzQTB>;Z9W*l#6>Fgiww!)3Y*~exeF9?T5A^3;Vr|tS_zAY}~a4eD_P_odEG#b8(bMwu^lWt#7O*8B zw~i*?$?tU;4tx7{tjyX<7OY#bNwu3mmx7I2HgwHHIcMMOY$?33{_4@@6n*-$;SMwE zJnZtKHfKT}S^FJ~?)_W@kVwtKBUK_a87^HA@4G#Rj74m?;0ltfOWBpYe&K@%2WNm( zv*mK-T7&o4AT4Pz7K?!9LylLBM3BC66%nD6LKER%U$}I%@mN@h0oQPuR@IdVhf|#Ezcyg zs3oon_u^F~+l31%Il%h{H4AH!Hf`Be6+4G9Crp$fXv_53dk?I6iJ6=7BKPm-tgbq? z0s8Ry-V2i5?fK6Y!$z<9y)Q3a(!DT@Ip`PJKuL4sC)Wg9r)u3lZ@W7>ngJUv`bJ{= z=;)Jybj9D-&yuOb*)?e~u5=hhXfu@)`cRe2D0S`X>Jm{`hth4}>2M6V zoisX*a~Oy2^}O;eA&6&tum1RU^e5y97 z(yRnADm~6m-@CRppMNnSqs$$$&%2Z6iPy-{y!Lv~w#dr**x>rt=`Jg7OdQkY*W`Go zbn_cnz8q}z+83)_E|knqNMLHr9Bsy*=hs6#$a)qlf`|GgjYo~Gh@Ppbp2_YC_^Bm$ zZ5~ZWv_NFq! zkx^EZ%$q;+r?(z)*Ct15UYJTdo}ZtGh}@JvTeG6jg2Dtt z=pCu$BdFE@xa&kMl07_{rg$-5H=Xm8~eFi|Ne%vdEneyCoh^TR}ku1dE(k#GuL{k*S-0r%{al+A7jXX$RJ}!oxP8# z!`c|b&F^bjPoHX7^6mrK`w}U6nx%k-7X$MJF_HC|HVwEmn{B>Z_RfgqAw73T&RO|u z*xbkr(=yUOzqi~8Y4fzfyE__e@Z)rx)U2$nCQ;0P5)4<7iPg`G>$gy;RA=}CdArC{ z(ChAfv$z@|PS+Y6yU+e#$m}sF_4fc1a2W%B5l)prJ@nl{U#Z6oSAU*N4SXBSJO2Fo zuXAC;5aW@OP@Xp~(C>>HG&8o;8Ez`@yTi#{l)}URdzKI_P|V=H{II~+!^6tLLS9AX z^@~rSRel0AXF}#)>dDAQBzu6~1-aB5Bk!%*2C{G#Dw?Ozax*FVUEQJ}=P0sRG1^M) z8K4#ODK#S#sipl;LoV(yxk0LF(bD7;(x<`eNnb1iCzy_tDlS$vl{(`CA@e{q!Yo`c zsS(g$R@T<7j!~n@6tfj%pZAv^-k=A&ZpUTCluy@0|Ga5ZSZ9(^d?PcZy|A63Ow2`Z z@`WZ#Fww1#GwbGW{h<$o$VFIpONxuLva<*p2lbF$8%|e7|t%Pn6h1n%l7c`u`?5wmG9Z2JtXc($P&-8=?J8@QzI6N z3MJSLFeX^wxSSSDr(*fxL>nt;P2fhHoJrFoMo{~afZ5~_FS*0vWvyX*T3@ulVkPRT zglG80#5>|oNCJVjod;DVzuj?CG?xVA4vze*Tc$`TSp*w9Em{zXpX3Q=vOg)YT22&i zpWpu}Ps+*h{fk$it2W>lC*g&I&*ogd7XuC<N6La1*sC zm#!FZsn$+TpN@;3l>2qnkpc7c!R<-+s~g=*JbW@_I43KGsp&Qj8cw}jdW<(4F6*9r zR{u!l0cdzS?h4VM|HAsCnV@!J{l0APgP1>d+~!B-(-;RVlPD!NT|QW)!;`P>&gIfd zh!Og@4-;qYYjqB`DcGK zU`k`P_|*5KfXOXdP!nIQPQJ@?0;ZJSG4ZR5T@~YgeN^S?QE81!y=l7xl6)Zu>v_^x zWX7vkO8ybaI$VA+@1z$!afe!+KZt9U^HXt;S#CuM0!0+6B~&{i!|4rr!^0z}`8jA^ zZs+kaKFYpLh-weN@&J*@h*mOzHyjxK+RDP`$BO2wwH6n+;Jo<=B`*~M)l@VBLMRmwO7>szR zI|g6~krP{KgAZx+eIy7_*`%n)kwT4`d`SSZk%v5kGHz6PZE%1vL58?DBGISw>?2{c z5cwF*t4WPDPi61Uo!Vx^EW|{4hCV2aX7^0<(Hx7S7cbDyQy}(IE0u6Ci4mA(nIRgC zdB4EZ*~p9M;}S4_;zpgJx)em8ea+0?0i%7LhoIK=24qD5ynzn$g9QGOlv?i#F{)gT zfH_W2f1(-6dLnBW zkP}TvG{N~Oa}$$};9W;kQ`0~Cx-j6r-=Ro@re9c)kdRoHO@*KXUr9*@47qf`?-Fv% z&#(6C&~V}%f9r?2q`xRT-~C35Gx<6_uJinQIWnS~UagRt*#$4)n2`G5`sG48?{uP# zU|jSec`%1xiV1;AKrf$$Y>et z)m6OQ*D8Hd>b6R~ciz`ECl8TJde60MUo~r%Mz5$^AZ{HLiKQg*aR(Bo77*pnlu@F; zQU=K;6cN6WC3wx(I|Lx@-lvqew?h(y7vVbmY8gXH>e#C@#b2yw_?T9-y2OYotMb;v zt9$2yt*?|2>6cOv)^0y4F@l2|^e*}jAM%Y^=&21#4alKgTmb739T5^z;e7kHtde;0 zT6t93(+)jCOB)-MxcDWh;gpo~&vE=DXsFF41_z;;yugnSglZdvuV+zJ>b~IZ9%O$azd%(LS>=(-S#ODJVVh8!&@#lMNK{S z9b3u&U0(PpJ3K>MaH3oLy#iF~qvOzL?WTjF*jUM599+zARsw>gx__Qal>J@PMr{&f znYScSb(GC{Q?}6~NPmE^cKLyTJ~19qQ;dD_wt!8Ay7J+JK#xS^pc>hf>)LItiu4GxUGZX!AstA$cfcU z=zHda<U) zDD&Tc*A(%^b;3csUvE14umv*XFqb9RGNJ^NO>#&Oif}@~+B~3L=v9+$8ryMf8-pe` zmIyiF1HSe)$T4S`GBoe6CP@?-rR-^MvVvtZT+%7rDq2`UAq=^x{Rk0GYc+G-z#@x~ zSpRFS(+6H_EV2KC3!Yz69TflfTLs>~60!#&p4n%Y8;TsM8xyN&X0K`HiNpvB2`LBf zU<0vC+y>Uv<}VHLQwt*93R6#8Z}N6{Ua4wKQIzTcQD^gukxbjh?8`i7AFFO4@tOyq zy8oUYUl4O*z&&`V6|cKunE8=@-W=ndF#Mq2o_=-2Ji4!7Toze-wDML)&0+|`SLf!# z8)_e~y=(b6Lj*M&5&D^!Nm|;tSvr3|$yq)6B84RCcAt&)MbdlO*;S2?M(}uiPhJKL z1Yu89Od^)~F+zvXGOIvRL_$t#SU9Rym3o3ELUZzBtAH3beRB9)rgiqGOKpirvC6{1 z0+aMlO7Ul3Osy+3&ZD|U8}NYU{Q?+ZlV@*+tLOwI60^hDV(yaE&i+qwDzZr@GKK&t zoqmJTPgiVg>*`SccnWHA=}U4n0ybO+2TuR+>GSJac83#Lo6s0yiA3rDL)C-@oS(+{AG@;F?(K}O-k2l(|GyW$H#>;9x3kl-==%s)x*pZJ0?eFiO&B}UFmad-zAp`+f9&?NP(KSA7 zCxKoGet(KSe4wo-FdrI|AgNt@7pS5?zFN>}geM5u?K=;%Iiu~D$IAn0!YZ&0j;%W% z6O(@iRyEXE^)M!43mpoBsO#C3;US&dDXTy|exy zjnE(&PL3GOXU@wgz6wQ2FxD9xso5_u-ExsUepKRFwENnCZDBcG z(EUae?4{?2I&o_rp9#&KLd0$g-bqs=K=YuOH)GG+4Udk3H(6u0x%U0Z$(4hBm6HY9 zB44$(sI#Nt7m|6LHbd$ILm(TBHfYhCt3ULS<{f$;X}3beC;oZroO%eD3L?22n)X*A0Pkt@y5K_ zjs#I;(Ug7L-T&m|%s;p~JG;Q2o_M(n^i^|n%J#-ED1BO!v?WCZg- zzpX4r%`9SP{%*I!5WUezlPydOt|^2~E|ve*BWy`uDXD-Uk#eFFcR39}cUx2yem z?wasSNwf3Uy2LuiXdZE#d#7huxlTu;8E3v_-+Eoo6Lx)*MSP@u)PO)iQ-Hv8=YEmw zj#DhL!IKO)w_zp+nv*m2JH7x~G0TVKot2)RiB;rp)2fRrzh?d!&7VKF*M0r_ zcOq5T+;#g%V91bn0wUXXH$@4g)FJ6f^kS(tGraGu`$CK-vF~>Q8bBXhD8U0 zHQi_S`Zc(M6C9f?cZ`wRYnDW`=g*6YiDFpF@*Z{I4W@~noi|~I0jSp2CV@Hl3_?PV z@T&jdV4Q#VH9a|MJUL?VQP(*Cq@7B{AikQ;z&c&+7RT+Zt7BOX-6>pCZLN%irHO%OC$w z0&?)Ux#eH_-$27~eOeBGFV4`ydh^>R01>Z_I^nU)>+A3VHUhd1iO+c&riGw1rf5i% zYEj#2ME?gH91o9bshEn2vXy107Xie8VbZx!K zspy@>^RxRH8n#e$xQG9Cowp1kRH-fOLi`nxl%AAe8RXEHkcz5HPOi9rzp1I|(a5XE zi^VYTg@Bi2$F~^-=ARX?Os|!&#DZ%pE9sAOy<9!RPNy!px>msS9oU5zFPeak19&hj z`W&3!?`+L1_+7rewhL?d=dzc;gb;NRL0aSlU_D^3y=39 zL~5lb*x1?x%55xiq_?;C%K*6+9|o{S&jE)?B-B(~Oprj8Aer)>sh}~C4hO=OC{s+# zD5R5*#;ALFx#60cqMyD0@F6KVzN)IerR7=s1<9dz14V>4lOHCj61Ih|P^5A%%QfGy zVr%p5MNqc06pGn$<_$i42#%yL5JqN}P0!{+=J0d=`_xy<&T}rBGu}V+x_u0SENr~I z)FPCBnFPCCIH*%!+BqnSLB|I(i{uk5N_qvkgnG!NyzfFJio}t4D%xv&%Pi>6_{roG zP0aXsLIIWd$et7jS%FR0OYg{Y;5z?(p{;Z{MpA~2#GHHg?%lJdrvKX7q)0RrIU%>_ z6yP7aa(hJNXkMwLev`K_&AhU?r!Iti`!1P)$3Htgs)~mpkHeBszi{p^X(QTNV&`w zm$RDd`E z9|xC8Aj-9Z)zi`I1LSm$4V-y$3>$oEDs$7)N<=WyOGhUyX{*%N9w2-JpyLMA6QCU6 z{d!~JoTQSZGRwklt#m8tU~?+=kbJ4MBRS2tKk|N2k=g^21I0--w;@0lKgmj>UmS=W zYLr%!<}SI4xqFF;z?TmbN z1hvQ$#maO|*}tVv4sDyqd33ai$jGnv3AfFgr%9M>OnRiyKA!If83A^bo)ZUKFM{s{ z2itU(A|{PMP?8F{2$zPLa^r`JL4H01X8OB_eufwxsvjS3+<-M5RD+eZwKG-HWo2b6 zFoUDxp`p8_V*eFT0AgYy;}a8$o3B(`sb=%xgDQ#c*%_uw8<3Tf8Xj+3T3b^Mpd`3M zsL%`1F5P~r8})BL|EPxpo5^>MgPl{5R#v^;a|44sqFP4sQ;IagU>n?bz`=!_(K!1e zGOVttnJE_AsLXK_1^zvjLr^V5;judKl0&TW*9>rsG$9^JQ8VLZ?U&zHj{BahU)E*4 z1s3kVd38({L_Nn*NaIOT}n!7>N~+v0?F_2uBx^`zaTz3 z!k_W>uD3Em$r0qChh#&nMmNey^CJH|15*Y5Dxa+b0Z)1=-qgr^bYdc|^mOI<=gupB zKnxw-baHieaVpjL>sx+2K0Xq%JsSklIDyU{I9Fl!rK*Y$Y2@VO{5Cjny8Z9(1|)dY zCEvil<}Q8JSQORIic^x6U0z%ysLg)w2w7=B;wn%IW9HGzwV-rht1Z!f=oO$-U0=O- zJBYuc^400%d);D^uc^k!G;g{U()N+s5{YO6^c#O5p|3wOf_Gn_{`nKm7ZkH6sl)2h ztFWRws%c=uMM;Pn8ynxdTb}ty@lI7&u-b&W!0VFL)m5vU9K-va+I*uViS5k1oaJPc z_qloS#b*8ASrY3uFcUv@1VM|z%*4#~r)L}18J9ILT#df7JtvCso+A+xyLb^?7%rhX z!NY?S%yWJFFJ{7zf30t>i_X3L^63-5pAID1j&KfsaBd0@XW6L-D2H^bttMWZ5MGRF z8;SF4@A~@wla}Vaf}*-`wXhn}M-(ny`q@LPGV^=)?M^~|Mh+W2mp+^Jz36+;PRX~8 zHIBRr3!96KOuI(N1&AOXPB5SvT)%!#|Mc7iep_3JRGqi2W_Im64804GoQp6qfQYK< z8!%U@if_C;NQ1zE6sSn=+S?Qk<(C7D!2GDHsd}`?dhQ%26B8>J*WW?KZH~)+_<@ne zh6V#nLU~0+RQ=uXa0fg@eR_JkM?H&cy~oMw5T%OPyPlBv>g5$)A-0W;VKmRw(psKB_Dk8@q_32X%kB>E$x4*vL-dwu1G-al<*V`LYIT+|cv3C_>CU4vjmy~QM zE>`F845GrF{V_CXpmGASvX>w60*WaxeEJ0fAK*@404#-=jW!EQU%q;E=gu8q*TBjb zDNG^oQ>&46_tzfWocDrgZWnNOwiaq! z=xT=36ZOYz$KjJqtls<`w763C9TD{=`+w^HzNttbMykB}omjy7_jSR>zu%E~`Y)ul zb%CGoq-d8nZ^lH_s|d}5EHVokB&ke67bzuBpm67U?gRaQlLvq{0 zhjAH99E{6bs~)bNV)~p|nM?8)b+28Ex}er!VqxLy>wDh26%5s4>#i26%TGTGL&XmRn6Jv|00pR1puQ`^=r_FylI z4@tR)NC#^n#1e(!sE?EQ3CUW+O$CZUG>Q*o(Z#S6k3MAL6|yery537df=%j(i(9&R zQ&sp+XsD`%R9t+621o~MDk}|N_&GQ_F8=y4J^iH*iGhtdbbVdNV5t=@jL!P3{>#PL ziDhjQauAhlY^V-?zfDZa$C}w&oIlS_$#@1aeNzlWIqGBSDv?(WlY4(+8@IrU2+Pj(I_9Wt)EwOE2)Utxx9b7uU7<-3@ zQ;Uimpla%)Ja1!bBlqVWbx(-X)tKz6s#b^t-0=gTyqU9LX>1(!=X@98h1%}!dy`pN z5M6Yk0pxYm;Yz>PMr4{F8T|Uu^D_3*CAoyltafole~eChu94%OG(OYS!Kf3I6c@8l z#dSQjzGF5XXAD%N<+b^p@l1O#+(Wo*P+*{sL0z=Yvw#4hH*bsFenlM6j~fu>b@Dkq zPB(MpJCDd9dDg{n4ma`MEFNaKoxv48=ZOE<1Z%_f(CbC)G=dO&<$XxQ-z_S{UtRoB zB%9rSI&b{H{7;w2Bl+K11v)vnSQ4UwDqSMTaJ@vRzarhb6cm>+yEC#oS{{Daa~*g4D{zk57H-C9*6oIy|G6 zL$9x|1CZ$cc@o;7Ah^<1naN*@BW56(Eh~owW>MhL^?vg^;qciD9AaC=aQf@fHx=UQ zV7JwQyla203=1{o(iR6!L1A__2)qKT%%MXD!U+KC>E62d@}#SSrx^m};>+&So?rd8 z5bo*YL!(7@nMD5INz+iFJ@)tBua=hLRf+k>OlccYZ9nYkv`!HIy1wk!JiZ&av*}cB zj{J-t-J`ll_TZJzkE-qSH|gkHS?FAu^Bq}OhH5v}t_m{XP)b*>m?Pf%f~W)n5!r`tPaMx|@y^2J2G%j_Ed{AtNgVD~(Q#!aBII6KF7)OcFBer^#zA|3JZ z_D)VrBz(!m#`f5YIu}^H&Vqu__}{jlWHHdd-+R!7-unI>GQHD_i}}c3dUme>-w9?V zFhnp*PcIgZbSba!tgdN&N1|)VYG8Er>LK7wDiauzl%)n$sX+1$3MifycH0z(i=&@E zTN|4ajZu#0x4&cNtRTzoz8@L&7Kx)6VJr&9YUZ6Qh0NAmJ}MfD(GffP;3jup``!2Q z!(YFSO_EW+;89T#R#fCw&Rw0#d z&%)lUc57g=nr3qnW%ijzRgBv_#4&vPor2tK8cg43{(k9y#tcy?4YdqIwT~2CP8g$6gjN=m~q`C5GM=v#rSi;GVgNh0l84_cs4?-NBrIqmK3jx?tK zdXR7d*oTlyoILa8BFsL^1O=HG*6{*#!Ce>SFGfdbfgW)+d6TzGjiFXWNkxTrB^~zJ zn<{Re%lZB1$VbVp)hx3PgddD(8>+%&q1ZKQ;clUmsDjRHe;#P?W8?Jqk16PNlbc`k zulPMlPha?11DwXW{n|YJpORAY6QhIYU5*qMo{t8Rcu^6N zqJe;v15%W6hD;d}ok&SZK|$fgyt&wy=sJ|UwZY&?@zQUt6Z#Zq%GUYr(5I6qg<;iz zPY6|Gm?vmBZq4F@Q<92bZ%Kq z^9rCJ!jF~XUPD{T{wlhcKyq?Nft2^85KwXv>-GdML( z17OlkU)3dSpG8#ZLdZ|nl#X*8<0Uy+d?oSrudrX=qo^mAI8+vQF$);KabGp6!dbtA_v_)G%%+>I6F99;cT3MLO z_um^}^}UvEC2253*`kU^*Hj7h2W*tSx_LMFwKfyXi_*K6w@?wEA9DtZRoW5m-R#8# zOpnqlx`+Ig3`&~)pD^A)G|?`lLWwEX-WwI7y>|dskKW`s7xQtK7buA zC|3R)AD{E5$db8&Lcs%d5;6%|{B!4SKA^QBP9o;~*?uirSl!52+)s`cZMeBLcS)do z7zzs$6XVBek9!-2px-fE3=Iv15FfdT3B1Cz{U#6XM?Jm5zlVRM#>U66mb*4(l$iK7 z{fGD^n5k!BoiT;nlD(FjtEXTFt5%qt-ag&Y0KS-ixu^E|3?$CRc>iO!2?D3rV;smq z3_B(|?&%lb!_@R{qzsq7i5S5$Wm%+6D12Bip#ISCJYf*Ji^~grUwIoFn!lXE>u&SrCEy)9(Zt_s1N>f@k>ToyMH zA-f#BJ}THB=)ZbvdTNS_`Tz>n%N+WqPEHOEymuB;M7xt`XuV}L4Qp-|-EnfF8@~xk zPsr_q9ps{^`@FlSt}ZipXbVmHhY01byH>@`4&P4rJ;UqzV*5Zx7z2kpJGArau z_m70Kj<`uI@idirTfOh?+sz~by z!}aCM)1rB#?h)95KkKFjV^Y_SRs?7Pky@@BT-2$ zgaiaHY$VLJ=zaj59Nd3%oplWKToP6mq~wiK@}EC{`nW=Vd*AWi(gc#Zzkdh!`n8Iw z92TPrpS2a@iCCuO*O7@h>XGMcYrsU}*2|@Ml+M98QaXofUF9!Dj{-ovECh z$=2)xP%^P#;?3K6@KC{2=Fe0aim{%7Mu`uPH6+VxO9g~5<2Pz+cfE$3EU%U$F|*W; zTbC(n5%vsk733)0)@k@|T0xA(SS?5^kM`mU? zK*VGNeER+ZAH0|WyEL}VPawu$0RUrLD=<=r6oerqEcvs zWBi@Mtfyaf1c7G-6h2T87#bSZuqbb}B5_jBXlZETjIr0jI7G7>^9+7V-4$_ak)-cM z_1$6bVKWC9VkpgFPE#$nrr;??VhKMh>hE7r2!|;u_Ip=Gz{+~}xg`SK9<=ox_39ln zM!HN%b8>9#Np3EY1roEqzVYDJwcVX7Nu6(a;{$j9lSQJ)=KgcWUqk2#ISlZ|{sdv0 zKSHdt#rm!AJJc1;X~mP6hp{=NCQ2SBY~ zztZxXJE*C-xM;yhPHs0Q-1a-$i~n<66v zL`NjiGwYu!AY=}3%{oaxLE~9li+b>%7Ht+Q^HX6dj7EWwc;tIyB2-c%K}ZsDi7U9Z z7?n!T4+Exxc`ksM0S77aNxuiKUBinFT#J7}qo5HH5F66Ym1CzIAg2?&71BkN7^81> zF?IU=jLnn#wuBnXq@EgB!6ZjPLR9d83+!L6-`2LCo*8qR-9OK*)TL!_TX5m&i|>ay z5}IM$-=4f&E|20Qsr^2>GwSjn&igKnS5s(tFS7P~J^6j279*WvPb=lr42wV!4mGSG z5pJdxq>mQ~(8ebTsij6|vgDNmRqXR%@QIpP0ZVpcjsR0r(bX#O?7(Sm!=# z=Hs`;ceA|z`jwmEg=!(i1M=d13s;Zmfk!pZNUQR|FG2 z)MWOSCDBcaboz^>CCm;_cuL9md~bT!-QG0U5BxRr-OJtmnmWO`tR$f&FTgm+Uc+~` zPg%{|wtM2Pq8|5niSwE!8VA3f(o*cyR|l<I3(FXzCbGhNrXF&;HvtGTAvdn)+7Mkx*F^uF={_gLsg zilK|G0W6~iM^*jQYz@^ouTr@U$f7KXMCp-~{1=x}dwc)bwH|;JlaDhwp@W&1Dn|Uq zM__%x{4x3GPq9dLHgkfO_!F453^mul zl$1(@QHDpedcf4cAm!;(Ya<6+G^#m6Q$&`L{YB5m02$f#JnvGrF$L4j!DGXX0Y&)3GaZ-cs>$e^rZAg@w z3JsSPf;nyRRUYf>&P593gcee_7j&<;bXQd6ogBTW>If(Zth(F3wd$+b>}Jf#IGxM< zk!_hfqP+2>cY)@^kHcm*oRO;Cjq9JV;RM!SC52vjU)94qEYB-CUt(Dg%dXV1QkViw~XT)dm{!uZ>rrgl} zB?oc!0VJiC^E?&6xpZ~kNH}&6{J=`b_VStU z^yACyOu?I*ZoVo|Z-W{qiUvvPRa*;F)obg-aen@RKAzr!pVA-E?*RTl>gh*?;GIGz z9x-W*xP*jyke3?#|7S#Bz)wQ)MiG;;CD~}*Iir=+tZI3UQzm0 zgc&8#(dlJn4Jj$vRU$tv+^oT%1|Pb>o9f!yn0uE4m!)oV8a_F{yiycd=v_z19K(mr zyvF8^iwPIKU^sHGoJ^3gcAP07OFjJ_LxU!nCgKLc-yBL0Ie{uxdu)+>#y6?iOk1Sh zIrAAEQZ_{Q{s+;ARU3ZSS2zA#jra4=BtQ+-GKBw|oZQf#RK-3YbR1d~PfyEvOhCv> zm6}o}jAEulY&M#%@NREbBoi>de4yxK)A?sl_pk=yM+O?mimJ*5gg4jL4u1Yr8*;yS z^Bf0<9w# z)GIfiH#dVT1Livn9P9BBckm(70PJGa&}dCMup6IxD{ig(Hm z&PWaiZidGQfFlo!3SE4Go8xb~+~G;!pMC-FDARY8ASEtHELwNlHLtJ-Df{TzLnn9l z5-f2%8?YDWUR;=aNglZ{1^(-g2|m$3-fa7n&tvZ>;}w)dUqH8o-fLYvK#Z)*zZrrvxDc1e$6yfoaa z-BT?OP*3RUaf@1@cK!C`%Ktu1vF1v(uaa*r3rOpi{zid5zmwX0V~ZFSuc@KI$)1Zz z`a*@dk(8pL2$HAB(4{{=jqHZV`6oENy)i-?-?qf;$+Y0b-)t;Q#1>`#jpn#krP^Hr zJ{syfcM#@|>KH%|GPt<}I1-f9XxyhcJ%0VKBdW7Ai*j3s7{}A%I+TC9n-Y06*573Wue0?XEv)XLZ%K zmtm6tldhVE8vdvTCrzA*I={izrlK3&o+fV&-;4l8TKXKB|8ywBP5ql;u(BnA zx0=$zkD6xEV50DoB%B0(J$2TtQv2RI{g7_9kUu63aVjK}iB9_xn=+R!-C5aNkxodL zrAvC1$GMtH@Qm${Bmm$KDVJ{&zwNVdzUCDT*vg<^2kyat8gIVEy;W1o%FdaZo;C_k z=qBI$HY6`6cl}kU?g$Ab-%;P+(=#<#3a8RNu`;YPOg@Qetgm0c4z13!zTMkID79!M zlUzxPY|licl%l?TK>}3qvs6+vgFZcMUf9^yz8b$I_vPAAAP$#>$?4rgx+!57t!Vkj zBS+3&YaiG1Wyy7aEtxtur;H|$8|RRM!Zb-E?KaD!v7^qHUB@#~ZM|{I_JPDFAAdZJ zZ}`#4-usfBC54%faY;-a2D?Ltj77c04Gr2vs5OB;QWQ%aFdE9q9@Z8P0kHG$fI&oY zb+y8WeH`M(&yDdKKkKNZ^z27nEB_L>5~*y6#W^LSS|SUCambI{p2s`qBN!UdABBiR z*@G3zjiRY1`<8H0Dzqc`Kis2cQ1L*m#23y&mN`8=&CbSxDIvdl444>|<1a%8x9|A> zvrC0&X}kaaYnv7oz4QF}C}iLi)Aob~>{Y#Dd{PTuGlR%KpDwx%V*Ig0KzM|A+2}pl zV!7Y0BM?Wb2<=;wR52DjGTr2`A~F4J>F9x*k9V)Cy2{CWWo2Ie>&ddp-?P0lnxT*} zmxD7eH@9-`*MgHy1SFz}`1rMIKVkg1pTO=zF!0v6S<{K+QPj8kF$KGcE{#Sj(i>i7 z6T5GeD}Vd3{Xpo(Aep%-b_kj4t~d-c~r7S*s_60Q*-0V+c!8pJilF$-Na47&T~Vv5#Vqf;O-29<3&`_oney z4+s2%ciI}xSDl!hvRny9)Ji*SYL7+9=KrjihnQ@Qw=>6>TNBqp}!Of6{K zpNrgn74$Xa+vFquH(FXoMn+J(fzt|>mQ^AmwDLY&o%Q(1yBlNI><=kRc!rs5G>gS_7^$=*Umc9j(W=DAsw?NJ zME-62mj7vdgx7d|9*^MgzY{p|dHj;JT!sV&Jmp<;gZekj($~Tf@5tq= zWIWs|Rc`%hhO_kfL$%L!RaK8N-}YtQ^hfgCiYRD9NLtp}`@?ejT~DF*(97wf1sYt` zD9ke7uRy>@_~}aKos)}6qaM*Pn*3(17H4=rNS)6=bg$2Er`JU{m5wNLH~onjm$6=0H`!OT3Uum4XW z;tC)n|2%+c%5Z8bh_fKe1RCpG-)&I-JRTLF+>BH0(6h+f7yh3hjGkrsl)Ns5Itt}l;j?&DP zy{e|CT>_=i+)L1G_EO$&q-IImdtsA}sBHyP)${&_xTUub{~St{&ZSDXE?vfW>qG-C zkmj@#$S{CwG~$)MB1`0TkZ6ChIGCphYe&Qdiw3*X70F0eIyzNn)Eeu&x15BWoQw>C zOjB7~$lbdfTFO){L>mcGcj(JcAN#m>YdFL(lY!7XIE71X1Yz1muBt=#4{3a((B0DS* z78b(ZFU(QvacvB+vCW0Kl6}aLb68lIN5Z@^ROww^U5yYXm5BAtFMm+cz<}N~@BhB~ z5eUB`tzA*b$`5qhQG)#@`E?WR>s2B-9=J+TG5R+e{r$H0MARKvp$Lyc;CjS}laP30 zkO_I2KaA>BemMr*E|O4EXTdV~V#1-Oluz=?HF@!9rEVns$D5*S9Dm$#JlDa?6o>S0 zS2n7KQ-1e9nDj`e|Dbb)Im9)$$1Ol6%D9G>QDthX7p{IeE~CI-St!x!OF}>1&W75s ziV+c!+7VP)%mi(NWn)*sEq`9k&KEB(2ne7zs9AT`!mfGafCaKPKaX*DFDfsuuBw9L zCTge%5s9$va{Fx$*TM+Dwt955$_Zu&Kq%)V);iP&N@1%o_k6XiJ(VWumMKrFD&{IJ z1qFdi!h;7`{XOu|&7~;+`PmRj{a+Hb7+wMI3RB*o=4PzA`P#;u(ysk_-)9Vxk&TUI z=4AwDy8}<#R=q^799$(u=g+8?|Mpe>ouSJB#!wLX_Y0s7*cll3vZKYSRUOAo&8o)3 zE^2N0wWXCTJ>tI)J0$gc(I7N+`Ftf+tsauD2``-?NQZ*HhJRaJeD-gD2#hY9+uM>} z&i>@9dkEUnX_6u~K;k8a$Rr~YuVwS~X8Ji$$Va&DA>L2CiCgVNyA^jacz!w?bc9-_{_d$XfVk6O_;0{fZhpmOnTeM+BU1wyit2w#S>$Ye#Fn5EU zm`Tr1Xqz?njo%iOJAnV*m?*F{RjPGdYPbC?tkGqFI1Bmk(8S?Q9F=8y0O0Czg_Qe*UKx? z-X36|Cq#O+w>Kw1Qe{!_eY&Ee4q~6>! z;+ktlvhs$3{{t#^=^C!eFj%G;ZqEJLw1@m?tZl#-FK_X>waQ9j5%IaRN_M@a>-&cf z@Ad+|5Tg8**%^b&0cQQQ&+184gM1KpO&Cjso={*GwyAd(DYupE^7FN6xFe3YBmcbx zqTA6McF6keN*A-Rc^rT=LC>biwvygoYjb6srA}&%e@`+>z(>_zvnRcN-=HvaVOUn(1X#N%d#og7=Xft9e5YBj_pij4~3V!-BGEzcR)Y$fh_g(dkBS0d50p~%^>Ff;=-%3AMlzEaxBAQ~gl`C3ee+?A zDAWkh;ukI_{lYfF*A{vA?|KE@G^j^anVFoOt7=)A2+#=$V}l&?PbvJ^13nE84N>yX>EYRB6Mx|GnM*%wz{Cy2u5h)1lm?E(lAAIu`rN-h@&I$X zhZ5}78Aj{B$ZLle-^8?YIoLfjoE$d(4>Sv$p&=xK3?1(1qf#+(aZq>TzjD7*zwuL! zDl9)gA8Nx%Qy!`^eSLjcQoyzs*cmX08_i)YyohmVilL`pfNS*RVN0N+x_V?Jci_v$ z#;%X!&2a@wz@RyY%Ef&QS|}!_ zm9=>Uv8x-V5aiKqqUkPtbh!D!vjt~FA&wWncW?mCh}h~ohr_%Wl#UTpYJP@vzW~@? z)6{e^l`j{uMq8v28fP-3fQh&Jo;~1{(2ZIZ#UR&pgOrY3Npa?{1t!_>#qSnNggc_y z!R!p;jp6pevq2FuBWrPO4abVl0rAPmNEaQi6c4_45^bVkt7~#mN{UW?iuldh;aPOr z9ZNYDUo=aB{TcjrpA@!cR=_P?*474M3@K9wPJXAvP8P9x2IMATBa)Kh z^P8#AzP7&6$8~i-vOiT|uON=c#>d}&Rt}5l2L0E|(4X%Bk`KV^(s3;!NG^1I$jNCM z{`e3}Y(qw*0wD<^d;33+w&v9UU4cX+!*`-cDn~xQC6zhKD0U1F&ttS!B0w2|sC|xa z7_K$&M*bKGhqA}#@?Yq(_P*=%B5cu9gKFWvaNgs;ZW9Au2Ce z<^-Gfpw|GNxt!#R#Ni?yyS3X{8ZCTZUS8cO4&IN0Pg(gILG!|Diy0g0LM+U1Ye~U6 zg1qt@rih{K3RY}vptDn{Yi*Uka;5h9bF&0$u(Nv4r71eOLmFr~U+fR?5=7fahX33! zi%mQabMc)|Ryj|5{$~Oyon8jD#8UfU_Eky()GpF<_GHEb@{sSwASm11Rk4D+81KQf z;}0LGUJfrt3sQ~3oE#K2-s0k(Vq$!!I_SIucK4%&R%sx1AlSW?X;Kh@4L5!Crura?i}>fL##SN z@VM;VE*Xx<4VTqDEE*Bs4kkn+JcIWd36@y0p}f2t3PpLJnHP69nW+*M92{Uz0+QLM zv>$41<{4Ni>Z^`Ev~v-mM?Ya4?CJmT;u(~L?f_x^+sdPE=-y7Q_$X(-PfAS7%!E$3 zJ=|K;+FDl+f3FelGO8EIe^i~#rOQC70f8e3&|2i=ur}6X!~@J2q%AS12W-QC|7ZpJ zwSQw{U`q>Z1&7Z~O-?$2nxp^6q82i-&k@SErKIV(xrm*ozWN1L*2kV#lx9{=@UOF}|>drm`& z0c@{3I*!|J1u(C=KvXRIXn{8wPQO6;V+}^^o;MNEp|zD2VuzTNIJTBEhV8H`pSsko zkNS>#RZ|*J{wBmV`=E7zu`+IWxaU3%@}{7m5ARK0>WmTu>DGtf^2s<$SaTDhi;tKP z@87&(d-Hnx^T{aaE!F4bgs)3Zh(>E$tXDdzORjdKPXn*FN9wMdr47|os)@pI}Jg!w6t`%ceVRU9K=CG zHINUKr&Yhp;^N|^~A>@}MZLv4Fl8Ef^gNh3R|`2J`l_ zsNIMB-(RQKSWK<0Da{`CIf6b=m4LUPr>7@{LqR||XyW5XYOwi1kp1!tBr@aBBxaGN zjSzFRi_o3_KrBnO_Nbzwyr`kJy1F~J1?Z7or>u5%Amw?a5;@n?Lx|PGxQ;2^M{KgT zcByM^IU>zXO`pI?W3cj}_v;lXAQQvUuYQ&H&Qx-v=%Z_1<>ke;{U`gaPO5802A?yV zKyxb~fWQso=%_9_Za{!%xPV9FKfyH#IoihZk9#)oUz%KXqP=e4Zca-(CyVZUj?Mm{ z6jqwbhe5&B&LUIVSx61cI;^J6XUn^da2&~D>N*bSOoITT>VOrbYr_R8vM^}H-M3zt zEiHrM&ehEi2T6ZDJ*SY049#-Pqvy|x3Hobqtu8<&L!`dh^?e@o%H%1Gn&8!kT75_q zNzZXrE8Ezmw!SoJi_+#jeF}ASW_y=1LG4f2spRzb>ZU&G$ihDNh!(sm`QTJgpZ+>3 ztJu@upT0dB?43}exV2;L@o4=bf9PR9d%x6EPvg7(wC%L%86_Glm)DX{$%+L0KH;7s zJl(~RiEZukO6QIjUAN~_9@ziWIge{GrNfM<XV zNJ%O4G{pIMsw5&%_C#pw^#M+g?+d^k{_|e)s3!_sbUc60`7f=L7liK(2p|74lAsUf z-e{_vuBi}|%C@fP;%m2>J08(KAEAq_AW@GyK0cnFob)2b{9j4u9Z!Y-e{u5~+2dZHBr_u`5=ur^ zw+Ll)t;|BU?0M}i;~EjEj6z1X#IzM5ORS{9~MqTk1=5Z0T^TYx;r^C-9efrHt}_y?VRQge+6Q}b2vF* zHfa7=W^o$~i6BW`yLL@aQ^qCD^3=J4!2{XXWdu$DP+16y2pq22F$TNYr95^;kQ6RbZAA=a zxW~Lr=cSt%Jg1#bwuWdoRL%=!8nN=YxA&~T&b%C*svXRBm5e2B`08WSD`F~?!36pE zEmF5PB?If^!#lB6vHfPd8s&9-D``T9B$6B`0^~%8G>`M-!VO+$K;&?A#YNVRJ>xv@ z6z(P(@~gW?&@)Btsaz}Po1)NhdDb)&Tfz29h$cD-b8rAHKVQc2#zckxLOh!W|bHlo}@$`6Ytl=jvsYb*oc#6m|ErjSUS{Xw*tn=5b@1Wt>}~~b0V@d7Kjs$Z$|kS{eCxEq z#k33ta0?4=$-E(*hb@&(O3qoV=NX8OE&Ytyw#!P-NnQ6lsK^fw#~hbeqrMXB2>moqfzRu!_@DP4UODkUIgQBFlEB(ADGb;<3|0?9y;v#u) z=k^ej4w@XCRDu@z8gXee--d>mVr~}~i#Q2~w**=%d}i=tj(P2Pyi-C+iGpSDS;jg` zmN@wym=Fi3$?gQNMT<6|KP%~2@=#^N@1h(PB1U1XhQN|nV_z{v9M!xMZB(A+^UYym>YkuNE1Nf2UA^t$FM#bsx=Db6*wm%!H`K0gkp|A%+5kTF6tU z6~X2Y!=}TUA`VX{=T7tq*sur=0=Md4(RqCakIYIlhs6*bn z*SV7E9(MPq$iQCL)u<(7~Y+mSSlre49{b!4RwD1sk^C~}m}TK!)BsQ=;kR6#+3 z`BWaoGl?hyH5Su^pTaN!D@!*kpB>&mux=^+taIHDL&UT?h=_>x$R6{ibK%VJzddR> zmjo5ngD*|Ge_95RMxGO^1ZH^VoFS^9eO~bPMI7~)`6^nKS>5zKRsM9DWiOKb9Ov3h zZc^Eq@Av$=hV5J%YDq;^_9LJZk2CMC7tA`PYs z@*Eywq4~j-mWjF&a*w-uRJrW3-g{2YVB(RNpBnjb@H_Mz;F9R+>7i*D93F5Hg!49D z{_9~2UR4~UVJZ&D*qtg^TRW`)G@-zlD7U)WW2(WA#dKxzQ#A~eK5sG*0}rmhfA8Sn z@Y0ya|K|64#JSzVAbU8yi|$PUBLrK?jCDioeyqB2(%yFKAw?zqsIeI{ZLLkbEZ#gy zN1vj+g9u;u;mu8H=?K+pkx(&a?W%SSBVi`e%Pvc$24Xn~IMup35ItmNWgG;4frK

            U$5@8c&C+ zWuQKBLc$JQ!o4nOfZ4&l;q%C8`r(3SsM4X)zR8DiiYh2r`qmQO($XwG!gEzgh<>X= zxX$Re&)xNjiV6ulIS_~{+{y3{>b$7lG%uP-A|yvgNy*sw-j}vE{Sc*xLSPuU zmFl-Nn>V}o?d^I2xO_jT$$uLeI5?a-ea$RIJ0rs-x`y>Zk)iymtDr!3l&b{md0e+)dQgspF zvc|a1?rqFW`TID{MLS0_MBEz;JC1WyJIF6*$3#a*7)4T&KQta=9`9( zDTXX2;huHNxHVB`xf=uw&~O*8NBiD3WLOCR5HY>Tg??fCDcb${s?kh>v^>1u#kwY<7fM4k})A>6mSe3`khYDH;R776q%& z(gTR5ie0>T5$1;+jYoQRrS7me$P2u}hn}G01;+z;`soq6>SF7P;qBPm4WyRCrQ^|^NMnST@ASP2)ZFb8L1CIm`ISfpA9P5`K^84 z6=~3kv-_`>JAs~ix16W^B{R22M}C|tJs{TbT+}wpT!cF3*xA_wh1!_R2k-r+VgX6@ z%Uf#!_&X?QX;IT=w|tM26b>vYJ;FJgw_^`DiB8A~glfyJ;JAQy3A~v3nwbn~3Qy{< zpg4&(@%{Y|p{bPQtp5+L-uKb*b{c><1naCb-k`+~3dQfFQeoYeM?OGg6la5$6aac} zk7y&$jynM+E>1^tbz`kzi>ABGEwmk5NuPTTfl;KMRatT?wI=|<16;r7@zm%9OM&?u0x<~*0D^^5M=%p0vpAJgt2TlvoYhZAxz>|jcL2*F?F{Sz z_x`Lzyd|incX7quHjmL>Ue}ccu3!JJ>NPos92g0Xq)Migg_C)_|oue52}si>&v zyt{#rQ19TtK&d?tV_^$vQ)$x0bL~=F|0tQDjH9C{AY+ zJlI$bgbk9~vws3S{8-Bud)6LpCmr~W0}0y<@_Ix+b)+74XT+KN$)@(S89cUAkD(2| z-z)fujY$&P9~p^R>B_io$HfD!5}ZI(Hv}ht`K&cWU&@EK0a_=>dQeH=0SgKu5_*`F zlvwo{xBnZVX;p^N*VnHg7V7#Nf<7-qG5?LA^a}SbnB|v8OA3EB#FAB3Ha-n8)@{CZ zt+^zJkpywAyYh(dUBRT@@xNbEK-4)?JTAcv&o?UmE-_KnrA&67$q<3oiKlF7hM8RT zVxT1^gcI&;=BhP|2VT(8eJDUR#mW+N=5^^ zkg4jbG>8Qu1Xmv|x|XxkU_$Pwj;$;&2j}CMP$j;HksX0_`@_MWQF_lAFNYOe4%p#% zS)0P?iIlx3D%Ro2TFt}^9`3@+&^z&!`|@NR)TYJAYPbpW);k&63y*II&G}ron3PYi zr~6it>3 zS8e@E)AoAsOH7<*gkl6ja3uG3vOS^~6)r;H-`Zn8nQ?e6_c4;ggL3u}wA39Lys zK;bjqkj9TvlIYmE>}m+{-rbJy!{Ni;-z_SuH)gc35R&^Ub+&qQJ`P*5ug`tAnHyRW zIOSW}nI#uJgp2sb(Y|1l!jR>5>(Rxpl)tY^OQQiCIl{HQ)pBeqwjrQcgo72bX66l* zqNO8Q$=9kI$s7W2bzVIox~O!*IP@-@gc z&HP9#;JhZM^D3PS9V#&2EuI~Oxs3F517lP#rM``%AWy7a$)hd?WSxr%>n!5! z*s|Ha;p*mEs`A~(+q?J6m(Yp8czHH9#jDD_m$xgt$)(RGA{UC~XxG&V8wUrZ*LdZH zBo4VDj2k)HSk>EGU1vy}RmjotfrT%e+k4BLN!G!n7M%6tB|?+wE6qJz z&j?(Yl(@LK8#2-nZl`fO-3HdZG9gSrMt}ttIHfVgs>;emxR1Xmr^*67DFa@{9~NZ+ z#Rb9UqpQo@n$ICW)jyhFUvKyMhhUwC1OF$ImoIvrEG#SpXgW#U#X-TZ6(3*YwcBrN zeo0~&85y-UM*bAvX)Mkd|DESrX|AMs&hakYX|mCm9yPUl%v#+?a z7lOf7MP4o)%RE5;QY0X-g<5mWWSGXxE=>4w3rhjVqXB06lw}8B9R15@HUgzhbE!50 z^=fBwsgl`kldt?%NVpX}_I?OtWkE>+P>$?NF%y_QzU+uOJrP(rNAX%z?GjOy?;6@~T zJcrT|Y8;diotN_Buijy+Ca9vz(CTt(A2c-vTJTT4#iVf07jaayB?QQy`sC@9v*q0L z?_2ln%hP$8k6F6;bY_5Yx)<%c`@8a(MZ*CMen#24ZBg_ZqYfGY)m6cvVmiy$y-`qeTVMju} z?voAv*fi4Jy^Tq{{&0$KosqwsQoU zJ!kU>BV8vYiuRk#8C0)5m{D;!ACLZakJuqNv@ysWJ6E08)I4=1Ap@cBGRUFW^RXDV z%a}BT8umq%=hXK(R?!!XPiiCL+JgZH+2)k?=nL zft$@Uqb{8|W1u2UAy3r$uX6Y8bMy*5Au>^zNa*jRxFoR49HX4RAZ%&7#UKu1D_98Z zvg~YpHeSJwJHGVRMCg}F*^e&)v%=5XNFmZ%nB}nkD$E|nxBT2(u*eQxdB-n!xVJ~L zx$u1NW8zN^m-gQsk+sStUfPyL%7N{%(e^*u_GnwuFj#ob)n#k^k6gy~|+3HGW zNw43({{xf3k%e-6V`C#Y4O~5L`DO+{@6QqA+*qAiIAP)c@5)R9c9=s-_yb0%_iW(D zX5I=I=gI4g$|f|^GtcGa{Fa7*u4Bz2w?CUy(s1;^^n`BC_9QsRGOBZ|q_uCsO|zx% z=6V|n7;~R}?!te5JGd$a9+XLFL5h{sQc28lh>eTY^dQKatL!fW7JPoJYrSRXkdJODlgo z%Q)b?c&ruofz_R*Gz+Mp@EUJtAj48eVX4B+gRW8w3lE1R8-#hfDS5_uq1cI^G2Sj; zNJIoqLfHMiDT-I{FO_+61EQ<2j{F)UnrNT&=a0>zM|>M|;tE6^Q8)^8l{S_E7Fv4RS1O}n%3#?_vAHX9nH3gIL3uYPPH@7wbM|G<$(sJC=&Mu~B8h|rzixfWEzsbo7 z5hv_&?*>g3w6vOlQ@Q^=9E8k^vfd$4 zj9pa}LsF&(Fz5a6;qhFAU2*m5Z{p5g8$e6pdkBA2R0iZIEYq=;GHu_!(LW|iwD(W? zyR-zFj*|YyU!oMzU?9;Y*yVF@d+>~lg2_V>Ubze@%pahn01EaDm5Po(lT||hA2bUM g2%J#R;WKwi_FT^Lqc;bU2?6}OqoSc)tY{kaf6v0X+W-In literal 0 HcmV?d00001 diff --git a/assets/images/screenshots/panelLayout.png b/assets/images/screenshots/panelLayout.png new file mode 100644 index 0000000000000000000000000000000000000000..17ecc316cdd2e2af4d31ff4932d77dab9ab07f78 GIT binary patch literal 9392 zcmcI~Wl&r}*XE$Xf(3`*8YZ|q1ot2VgJp0F7Ti5pkl^kP1A_)<&;$vD5C#htEV#Sv zP=LfdCuGn2z^HjGbZj zU-B<%SzZT9mNb|1Djo>_OrO4c+8pT~Yadb1Z&xA)h%jISatmRAHd%8N*YJMSRm?~X z_;VcG5NZ-KfH1SQ<%n{AN{D}mG!WpdJX&ZgnY`@*6>m1r?kxfb3s5DQ*mPak?6`zk zxgx~H9q96!wUqJQe@jUnb;#;ZR9l`##x^p9ru z(2~FAUQJS$e2f{n58T0D{^HD4-$_2Zq?Vjx^69L|^Q>xGi{rt?90U8UWhw=;dL1}9 zs?si%LJ$-C)vGgd`C^AQ(?rYkl1gQ~b?9ssn^pP_J;Y*Dd)aJp`SoFP+N7CVJyi`Z z1zK=A>m)M)?g_Z;Ja>bhTS!$4F$-K2#Z8Wn&7QNFlVE>IlTP4RW&~9SiLQA2R z7MN4bI>P*|Hxn-xm-YqBXKZDKx$)cueqZ)(+1uD~8aFY=rR8;Sa7MS(VFf*475%@G z&5op4+Ys>kzs<&fqp(Wte>J_xiiZigzxWAVFgj=)@R|=?dGdc>q1u^|oJ1^3T-lH} zXEvj`({l5M{RPFd-`Yghi%P(K2x+G1j;fH=lnh5$xmB*4tY!xouVB zf{wcr%L~#^vj&^aPP7yDn|I0`1LD<5dxXNiq2lyNksf;b;6Q$)j`J{X+SuCG2Y2?Kg9D^ zd5)YUhs8Ube;F>m?BBB>DjF8Kkz2tO_>5Nr9ry2$Z(}A^7zTs~i!7v%-VlIkncEku z1jHnO4^i2|ei6kPh$DMiu;P2$z{*aIsRjG#?^I`xf==pALWpO+!zE;{zI9f>ROK%x zzK%9f@FFzv?InpqU24aJ$Hn^A?e^^CJ1I?cI18l~?A7`s*TPq}y%KhosCm`>W>b$k zpT^#vrJ&w+G61cS%zXg<4_3WeMXug@s^V5!(N z`}?!9gj~r3t^)Ql;m5l7v;~h1-rSu|)Nd(5p7?2!i>q=rLFvU5uRE|h96pnomd5qS z(Unh5ZP$EJh!g5jPSCkwjM>m5|E5wy{{e{qee7v1gnB@zaBOlQYt0phaWty`83L%O z8TItZxk9sg+J8^;z>hW$pH0~Pa8NN7Ha>G`K^A$CSoi2$;=yyW0(CB#p_6?>MNUpVx_b!fHLK4d z-FJHU3)8G{4+!X@au$|JRw*lJZy$me@8X0(cqnLIzO;wN^Qt6gDybw}JHryo4^NaskloH-D7uh;v{BVV0VE)F&6B7 zcDODV%~aoK=i{43QQr_rwxd2v@B67z0-8=JYhlM;eMKqY(4)Ib9$P7Zb1z8(^n4Sn zT|ZAjP7bG-uAj}HailM%VRwZ-_jz9*eOiR~Zs><+ z&rYk~g^|T46ssen==d9niWzR#z;|PpvWwn(`S?p(bza{eihYj*>n|E-9cE1S2ftDh zTUSbiwyd)6L_QYt-|lSu{VKaXb2eZwDPEux6}NI*H!Eh3d6!_UVcXUvXJLPtTv@Ct zBC{SXVifRD3YMT+PnjWG>Nc0bpvVIYvJMB+mSJ=b@&X?%$ z1caZUtGeD`y41_c6X?vq{Z!9HCq717vPbTG(ja>qOJQhFop5qV#TbGDXN_Z5z^m2! z&Xk)-IAq8Z@~wJ=s$qoD4}b|8R?L~Ic`gK&=dgg3+0w4Pj}RHYljq569AR9D4^6AO z*eJwmH8n$OFNB7sUMiYzk1efl@4F(R~OfQjwdmzdQA4baTDTRZ5hD?1WQ#PUDfJoGl2rjhDobTwWGP_OZZ zT%0n~>aDTxb84vB%WpGQ-7~wu?bSoL-xpTLXdA35L`*}n0AXDM%A@s>iC;EW z3D1453;K{<@f5{iJhd>_Qlr4*voBQOtjz0Y>Rmt+e-&3tIS zv2Hq+Ruvp&>@1ZVJb5&SYuds}lWzB@rnatPCEUiZ45h9YYhn|-7haNAk2nx?6lMg6 zW5`CRCX~shuY9IuqAoFld(JOBi9%>{xe{_Wt+*?=rvg7GSOVtk9MUgg0d|nf(E`1X zf(KSDXwGV*r)&s}K2tWS!M}o17exMYr?`9V8do0h9}RCA=Nz0QCBfo08#pC_%pd#0 zAOmy5w}oM(R8ma_L2hfY!;uFe_A1zmhJ&zt>s=`(gRDSVj&Mr{7F1NSJ--&G!7j8> z$MNos2W!@&Up=zw=ugG}{ErHc|NJux$YLkql2%}Q&#HUH4qU@x>}2Y{l`T?+;<&LM z@&$$8(-4aml!fUh9`C13SaFz}6E#(V__f@|C?*-fk7T%B>%fdG6sdO=ZPA&^_USmF zH>IGF>qSnFV^ez~vWO2KV;0AI6-!T8Q@zvS{nS0n#mP$QA{@3a^Jgo6 zxKT)&c~FmB|B390Eb)L0NypJELvj18?terOc9FRFM$0iO`){sAejFk>`681vYrk6( zM#>(#$cc2K90nLtNG@4hR!+H>F=xP8M@}|w{%vM&Qh9H26l9j2ur87yy|VJ%>0$17 zIjznI8zIxU(lW^30&Q|x$zN5DQv{5SVxE6N6l`A`S$3-#0aVxj~@a9GYDbug|FLvc;5**8`T|! z(r+Hn`i{;Z;c(5gT^t5T=uGZ`6R5Z0z}pw2(z9`VjU5ZVHM`m?ny|ag)7$`rWjD1> zD5hmbu|=4GFbY z7rz1V-pkQUi#tF5|b|a3PDb=WvKOda4Ae?N9s=z)C$A|wNO#@<`{p$ ziUg7m31Q?_ba~r_y}Y(t+uaaR0S#vZw<-`iabS zMz=SDW(2rRJ1bqmiFOdYI*(LSCe|hfj}l}Cs7zwy>bMui&k;kU?dA2?^SVh{&9se} zgCy|C>)#uN^AfQZ(vxhB7+jyHr?DWU8`lYs0p^Kee*i3GY|_I&^ff1vxlkF@Ictz~ z)1oN6+#wnz$nsU%6s_3$OWUVb6uW3z4LB*en8j_<%jbQFZHg<6D_m3O#06S1st^)* z0+v`5k6i6zc4o)B%y$X=ubLL*NiZPy;=&rZMkkZQd01Q~XfF{DOG>168yY-bN5%;rK2>ep?;l$iz+etn1Tw7nZ6)cHN8Gy$jC zQIl=$Xi3-&*)1Q`*rD}yY{IVjPHx*%789w=gQ_MIhd654)pl$-gX;{Ty$R?I9k`s~ zEE=kW2a|+J6^XS$6?o|a*48-IFlK#ZOEdrf(5BixF>9IG1)4tGbnjlxIyjgp65f+p zy9`#IAw|yt#mC>JJl))GMIkYLIE*8j(m@^w{}ASI3jc-_K-LCoRSSYYbo^7?>l)#< zOlE4Q`lIfJ)W-XD`97tNUy1t{amn4AgGLda9mrw;@Irg(_-{e*5lS|F@NaO)6wwO@Y0?!_3Qh5 z4Q63~-L^ivjHhHBG%g6v%mA4L*3Y z^3?E-Ha!R*vZYqvi&5tH~?s}aFn+s>NXDgng7u@Zy<{p|m+j}TUB5pbK69Qg}I=@s)Rx7XL zJqY}f@ntkpEcWNYWNcK2p*F_645;#3lSI?Fm0n7i+-K7E(*Pb}{;C?s88XaN72hIy z%9(O{>nuJFyis-XG5yejq_2GVOVm_(w6C2>c6Yx6B;jFBy(`OpO`E4&E9jGM8ETuK zotJ0xzBbBrIXrwfEz-7pvtl;JqVQm#Eyx-dJ3#P}?Vb8WS9X?BX0};wdC?u)9iQp+gwgNXb)BN9DUSp96B<3?-Gkd;MSGd3lYU3u4lSHeQ$e z8}FQdg_}z28Y=~pUO;Zo_WL0ya8L99b82sgmb-@(!CP)LPY?N7Uggb^v`~`t1ypLP zbQWNQAkCK#MQg+8;U<*^thCP6F|3LzcrlnR=c7L663mLlyeGqG*q9~rK*tXBr9a84 zCk@LK0XCyLKOg8keJ)GbX3#VkEr|qFLEAG?Wqu|NV>lcPld;duyHqF5p&{{^$(vW^9+f21wQ) zhUn6ar?$KGjD#+a<|}q|#d2I0_GcNqSL@MO=6M|=?+9ymB>B&pQLe8ZGIgrL@9Sv?osdfuhnx)xc!Zp z-quR#@_g6g06=mi!4SP6@9<}{x3}vmu6zEltr88nWpn><@_}f3lfZ-4=k!O4Emv-X z4Jj3FI<}-NdiTBf*A?Hg^|bx135DPL6LqJj%xkX48-3foK0%NGc(%Sa(2(^W9YE(9 z-2CKnr}Uzv-N?L^c{BUsv3GeAzn^#qT}8a9S;i2i-loEMGw_XIeoFty^~eJnM6Hsb zY334mhOo7j!hOVVWc`Xv^-C2%LH_M|&2l~AcVqB}v)a!mpM`sZ)&u@@l{6`U7+{br z!W8t?Uq7n8Jl$Mcec6LC!0EHqIevH*Ydk&t+@O^7Z0kRYACxh2T zx>1U{B?%MRg4;-c2bIhDs+c5|h+`t$ZwO-P3BNx2*KW%ZByH1Y7yQc&3%1N<_15~s z*YJ*0Ex?rc&qcSobRM<}h>y(64-sY909P#k?oQ3C^aBAhVdEBrd-3Z*AD%K|C?1mH=h#SPeD zQZHpo&MN)Bw4IAF7Lg8snD6w%mDcd%EaDisEZna|kw(l}uw?YRUj1-cNI@@dt!)+1 z!Qr1p4XB96rX@>zJ<1haD1(qf$LK2(GkdNJK*m{%g=(nNUfSM4DFt)Kk1!NK7_B%M zY?GiOllvM~Mpu7&;bV(zd_Oi;94DEJ-EYW?D>(=fM?qT$NW9qmURQ$lYI!@*K$)%zDWi2_+wcnP%3X*)L0%T)7Uf(V(|vEljB`}6mm-<1cZ80cv7x~j?bq)#i9s79%~ zPJ34bq%D!;B$Sqx;bycxwRZ=ZcTZlgECa*LXb0ao(sguhIvbmj;v?gbMui7LuMU=4 zzet!JKJ4dswrKR{&-mvroxbm4=99JSF_Li33K5Af7wzPWX0@F4XZBh@ricbL=y(2Zkh*5>_Kr~yk3g+rW3>?ZoPj@%(y!R(H|1=5j?262uEUkKPD^A>`K6BGYzaYIB zb4;&qclzGl+j~`)-Z@%qZQ$}4AW3aSicC0%5W32ikjEbNtZkzFtEu^wdBGoo0#X7Z zQX;t&T->kgIcsXT>s_iHjAmhVMa3u?zBiP2O4!V|cPBU7%B*PP=~tDNa0Jw_i$W)a zo5X<(sGCcZN3X)X&T=B2v79C83g$}z#-tJs3U-x8owwzq6IW=h?^N(2m($~fk@8~k z!-`!u|xL%qUpdsGD->cdw+lxufYvcJvqv>nbwU( z)NJ-^FjdTgCNTJ@*w!Q&iHr@wuutunvg5Jn^mCJ^sDY<{2*(qCQ&^%RD|a~JBgPoT z3o0_8rMjIV>=SR1IZ}9^*nJmc<B3cns84`?Wj2r}H|=PKa77|2ykw9+Q$wO)@*% z3r8&Pq2OoSv>+CrA7t9~se|DpTx2db@vCma!|22WsaIY$6_f~b@jwq-vFWRxg7Hwo zp9|jt?hag*C2ld%;-dfeiyH1xCjBTXX1bXkcHcOo>PxhmZU}$r(aOmM=TQmUzh_;e zgTp_4XeJ#IifCMvdvtHuis@YavkuYiJ&$P1D;ioNT~@m4Cv(@llH~2p2OJ7O-^(+! zHyblR?KJ7>uA4ZBSq5}}vbV1&3=gJv9|M1PL>@Sa;Fm_M7lO|C_6DL#FY}lgF+tHb zMmI~0P1p9{^d{h z4Ds~$UpE!U7_DZ{nN)JpL13;aI@!`1;yDF9-va*|W4}Y?O#e4#^ltm{-@>9TLV4E} zyKixq((ow_Xop8q*wctbKYr8(`XvT$VBrt8N-pd#5{waWaHK3$Ed`GU z(6-Z5K8fO+AZzr-T_6WL$VwNdoklYkD_`&E`SqD?S72NNFO3u)?%Xd}SPwsMXcY$u z4pfeWoWV%T?W9YE>T?j_j zrbt`R(wz$z3B5Hi>yNZDC-m@l-!aehD6^{Us2Ppy&TO>-HMP$PYJrrwGrrD(tM5W1 zd?5pTa$ZXhiJ7#M;>_cqmPp)7)%--z!}agUXb8qRB7 zzhq~fbfl%KbE+mid9}62%!37TzHN5Z7f8nW4t`eo*xS`g!}c+sRJEqlo0rdGfcv?1 ze?RK(MK?$vYT-F^t&%=e0s7HYXZog{W~#}fbLIzOCn*b8rGdM%3x2JF>|2n- zs#@%?&0C-s=V(M^WWvG7z93j))5D*vleCQ0&ktjcf5ZY}e_m_(m7YaWX&%b1QPg5E z^@{Y@-j+tA&mYfSa7s#>8=9qMTVT#otPUY>cPtmUscEabo$A8EV(SXX(3O92&3p8s zRG{UZKPk*ygG@_0zS|BH)Ae4&`%@8#N4D9#&_4_-GI(>bfI@9|n3Z_F@1HwYli=9^gKLKRX~URD@@G?AgoQz9pE zzk+S||i5A#1nO1b88gA1{UV_nvX0YT{kW$!&wB&5(ac4Na@ zTA|JKlV)yIs;iUppOF{rWf9teng0v`eIKaeG4Wr@Nzpy=@&Fi)x8jYAUvObnmC8vE zAs7hXl3nNg&XfLfjdlY7%Cw!V7O8DnOLb&^O z7ZWcIp^THS!|m0|a4;p^lkffg>P=V5Gx{_VIV*`)BqiWty~cId3t@5Z@e~n?uWt7@ z(oPGTA97-Zb2HTNm&VKLU~S;A>~Dt8nceR|(2#8ZtCd#iP(b&P4l66}9hynY{oDzzs%%H{GoiHC)SJFDWH`70##vDB_Vt9W6RAVwu)ZbDCtH($YChgh`VS5d#m zoYZOOqx=7XDe^`jVB3%0?lZqPI-xaN?3qJOxZxOpdik2ynkMTHQ9TEX{=t{EOndvc z??n=>IDNZ_QQ=AvDe?kYP*`i1nv1v7m*Y;@jl1qxyyZt>p6$m)|jM88$u#kl_&Vjtn+!){o84)V4TNuHcO@ zYh3hJA&(cXMg01evHF;eZyQsM$6nUbSp`{%44qzn>_ZLtYi5u}q7(bo>#)2mmIrVB z`a*(#K8^^T<@IPG--nWqp|}KfCeb?1A6T|k&N5a2kI)D_$eY#`uSZn^&RrI#Nj z1dB(-wFXeN8_}Q+&5j=B-sN6biJ&xHJt9K@mF99atyJKYv33n346rYHQ|D0bQjP$h zO^{Dl`{3ikp9GUDiS&gRT_z;6jQx6=kKdcu82WDWk1_jh=k$Op%u(jNV@+q?ue=9C zV?Sc7wm}_yEqvVq8U{fM1E_@RHO1yAA|DI{8-9uX8;8{ESLq)DR0V*5s5vM7oyR%{ z^R9965aQ>!aOtdMfgQUeiom(p&R3|oaIO?nhhBjhe!+SEcKxbcoIs-oZFI7b-VD&d z)yHSf1fL`*KL5If#==owRlhCA6o1AN`Lo)v11-&_ahxv&gG65dSXi8E;=W>Hk_kU0 zl}SU!8zu`u!NLs1pr=4uf)M^s!N*zbtog&K!Q5?*0(&LhUef8XlJ1ghI>U+frIHu! z`4s`0;@P**Ofs5-m+n|VDv-Wn*%k7pu!UY>RJ+a#F11^q9v;m}YvpvZVJR5c5LJj8iJEqR0DQfN@kX`V{R+T|COYaCpYRqRcxQXiA{YePNPr{WJkJJb1B>u-u!U+nKfYaZnuwcwdMx0arD z934PwxfT&{F{k%NaT6x!DIoZ1EGX#k6{lL$wFQu4#qkZBXE)-(ccK}`{nSaR#Stw; w=34?&6W)vs#z^Mq`YV?LDU34Sk3t*>`E=pGW`|1x@)nIY`+502VIw1^@s6 literal 0 HcmV?d00001 diff --git a/changelog.html b/changelog.html index 36d6a9a65..5edc3bd58 100644 --- a/changelog.html +++ b/changelog.html @@ -143,6 +143,31 @@

            GoJS 3.0

            There are a number of other changes, detailed below.

            +

            Changes for 3.0.12

            + +

            Changes for 3.0.11

            • @@ -887,8 +912,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/download.html b/download.html index a9c43463a..115a77bbc 100644 --- a/download.html +++ b/download.html @@ -348,8 +348,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/extensions/AriaCommandHandler.js b/extensions/AriaCommandHandler.js index a010bed22..456e7da52 100644 --- a/extensions/AriaCommandHandler.js +++ b/extensions/AriaCommandHandler.js @@ -319,7 +319,7 @@ class AriaCommandHandler extends go.CommandHandler { * For tree layouts. * Checks for and returns the previous sibling nodes of the currently selected node. * All nodes previous of the currently selected node will be in the array and first element is the previous node. - * @param {go.Node} + * @param {go.Node} node * @return {null || Array} returns null if there is no previous sibling node */ _getPreviousSiblingNodes(node) { diff --git a/extensions/AvoidsLinksRouter.js b/extensions/AvoidsLinksRouter.js index e02db495c..86935dc10 100644 --- a/extensions/AvoidsLinksRouter.js +++ b/extensions/AvoidsLinksRouter.js @@ -124,29 +124,29 @@ class AvoidsLinksRouter extends go.Router { /** * Determine whether the AvoidsLinksRouter should operate on a given collection. * See {@link ignoreContainingGroups} for the default behavior. - * @param {go.Group | go.Diagram} coll + * @param {go.Group | go.Diagram} container * @returns */ - canRoute(coll) { - if (this._ignoreContainingGroups && coll instanceof go.Group) + canRoute(container) { + if (this._ignoreContainingGroups && container instanceof go.Group) return false; - return super.canRoute(coll); + return super.canRoute(container); } /** * Adjust segments of all links in the Diagram to prevent overlap. * - * @param {*} coll A Diagram or a Group - * @param {*} diagram + * @param {go.Set} links + * @param {*} container A Diagram or a Group * @returns */ - routeLinks(links, coll) { + routeLinks(links, container) { const diagram = this.diagram; if (diagram === null) return; for (let i = 0; i < this.iterations; i++) { this._allsegs = new go.List(); this._gridlines = new go.List(); - this.collectSegments(links, coll); + this.collectSegments(links, container); let positions = null; if (this._avoidsNodes) { positions = diagram.getPositions(true, null, null); diff --git a/extensions/DataInspector.js b/extensions/DataInspector.js index 79d38ba0c..2b3859c61 100644 --- a/extensions/DataInspector.js +++ b/extensions/DataInspector.js @@ -295,10 +295,10 @@ class Inspector { * @param part - the Part being inspected * @param propname - the property to check presence of */ - static showIfPresent(data, propname) { - if (data instanceof go.Part) - data = data.data; - return typeof data === 'object' && data[propname] !== undefined; + static showIfPresent(part, propname) { + if (part instanceof go.Part) + part = part.data; + return typeof part === 'object' && part[propname] !== undefined; } /** * Update the HTML state of this Inspector with the given object. diff --git a/extensions/Figures.js b/extensions/Figures.js index 69c7f81be..824fc073c 100644 --- a/extensions/Figures.js +++ b/extensions/Figures.js @@ -1,9 +1,9 @@ /* * Copyright (C) 1998-2024 by Northwoods Software Corporation. All Rights Reserved. */ -// This file holds definitions of all standard shape figures -- string values for Shape.figure. -// You do not need to load this file in order to use named Shape figure. -// The following figures are built-in to the go.js library and thus do not need to be redefined: +// This file holds definitions of all legacy shape figures -- string values for Shape.figure. +// They were built into the library in version 1, but most were removed for v2.0. +// The following figures are still built-in to the go.js library and thus do not need explicit definitions: // Rectangle, Square, RoundedRectangle, Border, Ellipse, Circle, // TriangleRight, TriangleDown, TriangleLeft, TriangleUp, Triangle, // LineH, LineV, None, BarH, BarV, MinusLine, PlusLine, XLine, Capsule @@ -315,6 +315,40 @@ go.Shape.defineFigureGenerator('ChamferedRectangle', (shape, w, h) => { geo.spot2 = spot2; return geo; }); +// narrow ends of rectangular area come to a point +go.Shape.defineFigureGenerator('HexagonalCapsule', (shape, w, h) => { + let param1 = shape ? shape.parameter1 : NaN; + if (isNaN(param1)) + param1 = 10; + const geo = new go.Geometry(); + if (w < h) { + const inset = Math.min(param1, w / 2); + const fig = new go.PathFigure(w / 2, 0, true); + geo.add(fig); + // Outline + fig.add(new go.PathSegment(go.SegmentType.Line, w, inset)); + fig.add(new go.PathSegment(go.SegmentType.Line, w, h - inset)); + fig.add(new go.PathSegment(go.SegmentType.Line, w / 2, h)); + fig.add(new go.PathSegment(go.SegmentType.Line, 0, h - inset)); + fig.add(new go.PathSegment(go.SegmentType.Line, 0, inset).close()); + geo.spot1 = new go.Spot(0, 0, inset / 2, inset); + geo.spot2 = new go.Spot(1, 1, -inset / 2, -inset); + } + else { + const inset = Math.min(param1, h / 2); + const fig = new go.PathFigure(inset, 0, true); + geo.add(fig); + // Outline + fig.add(new go.PathSegment(go.SegmentType.Line, w - inset, 0)); + fig.add(new go.PathSegment(go.SegmentType.Line, w, h / 2)); + fig.add(new go.PathSegment(go.SegmentType.Line, w - inset, h)); + fig.add(new go.PathSegment(go.SegmentType.Line, inset, h)); + fig.add(new go.PathSegment(go.SegmentType.Line, 0, h / 2).close()); + geo.spot1 = new go.Spot(0, 0, inset, inset / 2); + geo.spot2 = new go.Spot(1, 1, -inset, -inset / 2); + } + return geo; +}); go.Shape.defineFigureGenerator('AsteriskLine', (shape, w, h) => { const offset = 0.2 / Math.SQRT2; return new go.Geometry().add(new go.PathFigure(offset * w, (1 - offset) * h, false) @@ -598,7 +632,7 @@ function freeArray(a) { */ function createPolygon(sides) { // Point[] points = new Point[sides + 1]; - const points = tempArray(); + const points = []; const radius = 0.5; const center = 0.5; const offsetAngle = Math.PI * 1.5; @@ -4907,49 +4941,6 @@ go.Shape.defineFigureGenerator('4Arrows', (shape, w, h) => { fig.add(new go.PathSegment(go.SegmentType.Line, w * 0.35, h * 0.25).close()); return geo; }); -// // narrow ends of rectangular area are completely rounded -// go.Shape.defineFigureGenerator('Capsule', (shape, w, h) => { -// const param1 = shape ? shape.parameter1 : NaN; -// const param2 = shape ? shape.parameter2 : NaN; -// -// const geo = new go.Geometry(); -// if (w < h) { -// const fig = new go.PathFigure(0, w / 2, true); -// geo.add(fig); -// // Outline -// const px = isFinite(param1) ? param1 : w * 0.156; -// const py = isFinite(param2) ? param2 : w * 0.156; -// fig.add(new go.PathSegment(go.SegmentType.Arc, 180, 180, w / 2, w / 2, w / 2, w / 2)); -// fig.add(new go.PathSegment(go.SegmentType.Line, w, h - w / 2)); -// fig.add(new go.PathSegment(go.SegmentType.Arc, 0, 180, w / 2, h - w / 2, w / 2, w / 2)); -// fig.add(new go.PathSegment(go.SegmentType.Line, 0, w / 2)); -// geo.spot1 = new go.Spot(0, 0, px, py); -// geo.spot2 = new go.Spot(1, 1, -px, -py); -// return geo; -// } else if (w > h) { -// const fig = new go.PathFigure(h / 2, 0, true); -// geo.add(fig); -// // Outline -// const px = isFinite(param1) ? param1 : h * 0.156; -// const py = isFinite(param2) ? param2 : h * 0.156; -// fig.add(new go.PathSegment(go.SegmentType.Line, w - h / 2, 0)); -// fig.add(new go.PathSegment(go.SegmentType.Arc, 270, 180, w - h / 2, h / 2, h / 2, h / 2)); -// fig.add(new go.PathSegment(go.SegmentType.Line, w - h / 2, h)); -// fig.add(new go.PathSegment(go.SegmentType.Arc, 90, 180, h / 2, h / 2, h / 2, h / 2)); -// geo.spot1 = new go.Spot(0, 0, px, py); -// geo.spot2 = new go.Spot(1, 1, -px, -py); -// return geo; -// } else { // w === h -// geo.type = go.GeometryType.Ellipse; -// geo.endX = w; -// geo.endY = h; -// const px = isFinite(param1) ? param1 : w * 0.156; -// const py = isFinite(param2) ? param2 : w * 0.156; -// geo.spot1 = new go.Spot(0, 0, px, py); -// geo.spot2 = new go.Spot(1, 1, -px, -py); -// return geo; -// } -// }); go.Shape.defineFigureGenerator('Connector', 'Ellipse'); go.Shape.defineFigureGenerator('Alternative', 'TriangleUp'); go.Shape.defineFigureGenerator('Merge', 'TriangleUp'); diff --git a/extensions/LinkLabelRouter.js b/extensions/LinkLabelRouter.js index e6200e4b1..be940892a 100644 --- a/extensions/LinkLabelRouter.js +++ b/extensions/LinkLabelRouter.js @@ -97,30 +97,30 @@ class LinkLabelRouter extends go.Router { * Determine if the LinkLabelRouter should run on a given collection. * By default only run once on the whole Diagram, never on Groups * - * @param { go.Diagram | go.Group } coll + * @param { go.Diagram | go.Group } container * @returns */ - canRoute(coll) { - if (coll instanceof go.Group) + canRoute(container) { + if (container instanceof go.Group) return false; - return super.canRoute(coll); + return super.canRoute(container); } /** * Attempt to move link label objects to avoid overlaps, if necessary. * - * @param {*} coll A Diagram or a Group - * @param {*} diagram + * @param {go.Set} links + * @param {*} container A Diagram or a Group * @returns */ - routeLinks(links, coll) { + routeLinks(links, container) { if (this.layout === null) return; - if (coll instanceof go.Group) + if (container instanceof go.Group) return; this.layout.activeSet = links; - if (coll instanceof go.Diagram) - this.layout.diagram = coll; - this.layout.doLayout(coll.links); + if (container instanceof go.Diagram) + this.layout.diagram = container; + this.layout.doLayout(container.links); if (this.layout.network === null) return; for (const vertex of this.layout.network.vertexes) { @@ -142,8 +142,8 @@ class LinkLabelRouter extends go.Router { } /** @hidden @internal */ class LabelVertex extends go.ForceDirectedVertex { - constructor() { - super(...arguments); + constructor(network) { + super(network); this.object = null; this.objectBounds = null; this.currentBounds = null; @@ -152,10 +152,12 @@ class LabelVertex extends go.ForceDirectedVertex { } /** @hidden @internal */ class LabelLayout extends go.ForceDirectedLayout { - constructor() { - super(...arguments); + constructor(init) { + super(); /** @hidden */ this.router = null; /** @hidden */ this.activeSet = null; + if (init) + Object.assign(this, init); } /** * we should not ever do a prelayout on this virtual, "fake" force-directed network diff --git a/extensions/NonRealtimeDraggingTool.js b/extensions/NonRealtimeDraggingTool.js index 0a32ffc5a..0d20b2643 100644 --- a/extensions/NonRealtimeDraggingTool.js +++ b/extensions/NonRealtimeDraggingTool.js @@ -41,8 +41,8 @@ class NonRealtimeDraggingTool extends go.DraggingTool { * show it using a Picture, and hold the Picture in a temporary Part, as _imagePart. * @param parts - A {@link go.Set} or {@link go.List} of {@link go.Part}s. */ - computeEffectiveCollection(coll) { - const map = super.computeEffectiveCollection(coll, this.dragOptions); + computeEffectiveCollection(parts) { + const map = super.computeEffectiveCollection(parts, this.dragOptions); if (this.isActive && this._imagePart === null) { const bounds = this.diagram.computePartsBounds(map.toKeySet()); const offset = this.diagram.lastInput.documentPoint.copy().subtract(bounds.position); diff --git a/extensions/ScrollingTable.js b/extensions/ScrollingTable.js index fedd8a46c..a79146b31 100644 --- a/extensions/ScrollingTable.js +++ b/extensions/ScrollingTable.js @@ -55,26 +55,9 @@ go.GraphObject.defineBuilder('AutoRepeatButton', (args) => { } } const button = go.GraphObject.build('Button'); - // override the normal button actions - const btndown = button.actionDown; - const btnup = button.actionUp; - const btncancel = button.actionCancel; - button.actionDown = (e, btn) => { - delayClicking(e, btn); - if (btndown) - btndown(e, btn); - }; - button.actionUp = (e, btn) => { - endClicking(e, btn); - if (btnup) - btnup(e, btn); - }; - button.actionCancel = (e, btn) => { - endClicking(e, btn); - if (btncancel) - btncancel(e, btn); - }; - go.GraphObject.build("Button").add(new go.Panel()); + button.actionDown = (e, btn) => delayClicking(e, btn); + button.actionUp = (e, btn) => endClicking(e, btn); + button.actionCancel = (e, btn) => endClicking(e, btn); return button; }); // Create a "Table" Panel that supports scrolling. diff --git a/extensions/SerpentineLayout.js b/extensions/SerpentineLayout.js index 7099c29de..29f94709b 100644 --- a/extensions/SerpentineLayout.js +++ b/extensions/SerpentineLayout.js @@ -131,7 +131,7 @@ class SerpentineLayout extends go.Layout { * This method actually positions all of the Nodes, assuming that the ordering of the nodes * is given by a single link from one node to the next. * This respects the {@link spacing} and {@link wrap} properties to affect the layout. - * @param coll - A collection of {@link go.Part}s. + * @param collection - A collection of {@link go.Part}s. */ doLayout(collection) { const diagram = this.diagram; diff --git a/extensions/SwimLaneLayout.js b/extensions/SwimLaneLayout.js index 3b9c13d87..e2226ee32 100644 --- a/extensions/SwimLaneLayout.js +++ b/extensions/SwimLaneLayout.js @@ -30,11 +30,9 @@ class SwimLaneLayout extends go.LayeredDigraphLayout { constructor(init) { super(); - // internal state - this._layers = [[]]; - this._neededSpaces = []; this._laneProperty = 'lane'; // how to get lane identifier string from node data this._laneNames = []; // lane names, may be sorted using this.laneComparer + this._laneIndexes = new go.Map(); this._laneComparer = null; this._laneSpacing = 0; // in columns this._router = { linkSpacing: 4 }; @@ -327,10 +325,11 @@ class SwimLaneLayout extends go.LayeredDigraphLayout { // set up some data structures const layout = this; const laneNameSet = new go.Set().addAll(this.laneNames); - const laneIndexes = new go.Map(); // lane names --> index when sorted + const laneIndexes = new go.Map(); // lane name --> index when sorted const vit = this.network.vertexes.iterator; while (vit.next()) { const v = vit.value; + // discover any more lane names const lane = this.getLane(v); // cannot call findLane yet if (lane !== null && !laneNameSet.has(lane)) { laneNameSet.add(lane); @@ -347,12 +346,13 @@ class SwimLaneLayout extends go.LayeredDigraphLayout { } } } - // sort laneNames and initialize laneIndexes + // sort laneNames and initialize laneIndexes with sorted indexes if (typeof this.laneComparer === 'function') this.laneNames.sort(this.laneComparer); for (let i = 0; i < this.laneNames.length; i++) { laneIndexes.set(this.laneNames[i], i); } + this._laneIndexes = laneIndexes; // now OK to call findLane // sort vertexes so that vertexes are grouped by lane for (let i = 0; i <= this.maxLayer; i++) { @@ -369,12 +369,13 @@ class SwimLaneLayout extends go.LayeredDigraphLayout { const layers = this._layers; const red = this.reducer; if (red) { - for (let i = 0; i < layers.length - 1; i++) { - red.reduceCrossings(layers[i], layers[i + 1]); + red.laneIndexes = this._laneIndexes; + for (let i = 1; i < layers.length; i++) { + red.reduceCrossings(layers[i], layers[i - 1]); layers[i].forEach((v, j) => (v.index = j)); } - for (let i = layers.length - 1; i > 0; i--) { - red.reduceCrossings(layers[i], layers[i - 1]); + for (let i = layers.length - 2; i >= 0; i--) { + red.reduceCrossings(layers[i], layers[i + 1]); layers[i].forEach((v, j) => (v.index = j)); } } @@ -551,13 +552,17 @@ class SwimLaneLayout extends go.LayeredDigraphLayout { let laneW = this.findLane(w); if (laneW === null) laneW = ''; - if (laneV < laneW) + const idxV = this._laneIndexes.get(laneV) || 0; + const idxW = this._laneIndexes.get(laneW) || 0; + if (idxV < idxW) return -1; - if (laneV > laneW) + if (idxV > idxW) return 1; // OPTIONAL: sort dummy vertexes before vertexes representing real nodes - //if (v.node === null && w.node !== null) return -1; - //if (v.node !== null && w.node === null) return 1; + if (v.node === null && w.node !== null) + return -1; + if (v.node !== null && w.node === null) + return 1; if (v.column < w.column) return -1; if (v.column > w.column) diff --git a/extensionsJSM/AriaCommandHandler.js b/extensionsJSM/AriaCommandHandler.js index cb7e80f0b..78ffe0110 100644 --- a/extensionsJSM/AriaCommandHandler.js +++ b/extensionsJSM/AriaCommandHandler.js @@ -319,7 +319,7 @@ export class AriaCommandHandler extends go.CommandHandler { * For tree layouts. * Checks for and returns the previous sibling nodes of the currently selected node. * All nodes previous of the currently selected node will be in the array and first element is the previous node. - * @param {go.Node} + * @param {go.Node} node * @return {null || Array} returns null if there is no previous sibling node */ _getPreviousSiblingNodes(node) { diff --git a/extensionsJSM/AriaCommandHandler.ts b/extensionsJSM/AriaCommandHandler.ts index 36e2ede6e..843e106a5 100644 --- a/extensionsJSM/AriaCommandHandler.ts +++ b/extensionsJSM/AriaCommandHandler.ts @@ -315,7 +315,7 @@ export class AriaCommandHandler extends go.CommandHandler { * For tree layouts. * Checks for and returns the previous sibling nodes of the currently selected node. * All nodes previous of the currently selected node will be in the array and first element is the previous node. - * @param {go.Node} + * @param {go.Node} node * @return {null || Array} returns null if there is no previous sibling node */ _getPreviousSiblingNodes(node: go.Node){ diff --git a/extensionsJSM/AvoidsLinksRouter.js b/extensionsJSM/AvoidsLinksRouter.js index 4688f719b..30081925a 100644 --- a/extensionsJSM/AvoidsLinksRouter.js +++ b/extensionsJSM/AvoidsLinksRouter.js @@ -124,29 +124,29 @@ export class AvoidsLinksRouter extends go.Router { /** * Determine whether the AvoidsLinksRouter should operate on a given collection. * See {@link ignoreContainingGroups} for the default behavior. - * @param {go.Group | go.Diagram} coll + * @param {go.Group | go.Diagram} container * @returns */ - canRoute(coll) { - if (this._ignoreContainingGroups && coll instanceof go.Group) + canRoute(container) { + if (this._ignoreContainingGroups && container instanceof go.Group) return false; - return super.canRoute(coll); + return super.canRoute(container); } /** * Adjust segments of all links in the Diagram to prevent overlap. * - * @param {*} coll A Diagram or a Group - * @param {*} diagram + * @param {go.Set} links + * @param {*} container A Diagram or a Group * @returns */ - routeLinks(links, coll) { + routeLinks(links, container) { const diagram = this.diagram; if (diagram === null) return; for (let i = 0; i < this.iterations; i++) { this._allsegs = new go.List(); this._gridlines = new go.List(); - this.collectSegments(links, coll); + this.collectSegments(links, container); let positions = null; if (this._avoidsNodes) { positions = diagram.getPositions(true, null, null); diff --git a/extensionsJSM/AvoidsLinksRouter.ts b/extensionsJSM/AvoidsLinksRouter.ts index 13866cd42..2464a2714 100644 --- a/extensionsJSM/AvoidsLinksRouter.ts +++ b/extensionsJSM/AvoidsLinksRouter.ts @@ -140,28 +140,28 @@ export class AvoidsLinksRouter extends go.Router { /** * Determine whether the AvoidsLinksRouter should operate on a given collection. * See {@link ignoreContainingGroups} for the default behavior. - * @param {go.Group | go.Diagram} coll + * @param {go.Group | go.Diagram} container * @returns */ - override canRoute(coll: go.Group | go.Diagram) { - if (this._ignoreContainingGroups && coll instanceof go.Group) return false; - return super.canRoute(coll); + override canRoute(container: go.Group | go.Diagram) { + if (this._ignoreContainingGroups && container instanceof go.Group) return false; + return super.canRoute(container); } /** * Adjust segments of all links in the Diagram to prevent overlap. * - * @param {*} coll A Diagram or a Group - * @param {*} diagram + * @param {go.Set} links + * @param {*} container A Diagram or a Group * @returns */ - override routeLinks(links: go.Set, coll: go.Diagram | go.Group) { + override routeLinks(links: go.Set, container: go.Diagram | go.Group) { const diagram = this.diagram; if (diagram === null) return; for (let i = 0; i < this.iterations; i++) { this._allsegs = new go.List(); this._gridlines = new go.List(); - this.collectSegments(links, coll); + this.collectSegments(links, container); let positions = null; if (this._avoidsNodes) { positions = diagram.getPositions(true, null, null); diff --git a/extensionsJSM/Buttons.ts b/extensionsJSM/Buttons.ts index 4cabd1720..61a5ee898 100644 --- a/extensionsJSM/Buttons.ts +++ b/extensionsJSM/Buttons.ts @@ -122,7 +122,7 @@ go.GraphObject.defineBuilder('Button', (args: any): go.Panel => { // go.GraphObject.build('TreeExpanderButton') go.GraphObject.defineBuilder('TreeExpanderButton', (args: any): go.Panel => { - const button = go.GraphObject.build('Button') as go.Panel; + const button = go.GraphObject.build('Button'); button.attach({ // set these values for the isTreeExpanded binding conversion '_treeExpandedFigure': 'MinusLine', @@ -178,7 +178,7 @@ go.GraphObject.defineBuilder('TreeExpanderButton', (args: any): go.Panel => { // go.GraphObject.build('SubGraphExpanderButton') go.GraphObject.defineBuilder('SubGraphExpanderButton', (args: any): go.Panel => { - const button = go.GraphObject.build('Button') as go.Panel; + const button = go.GraphObject.build('Button'); button.attach({ // set these values for the isSubGraphExpanded binding conversion '_subGraphExpandedFigure': 'MinusLine', @@ -304,7 +304,7 @@ go.GraphObject.defineBuilder('ContextMenu', (args: any): go.Adornment => // ) go.GraphObject.defineBuilder('ContextMenuButton', (args: any): go.Panel => { - const button = go.GraphObject.build('Button') as go.Panel; + const button = go.GraphObject.build('Button'); button.stretch = go.Stretch.Horizontal; const border = button.findObject('ButtonBorder'); if (border instanceof go.Shape) { @@ -349,7 +349,7 @@ go.GraphObject.defineBuilder('ContextMenuButton', (args: any): go.Panel => { go.GraphObject.defineBuilder('PanelExpanderButton', (args: any): go.Panel => { const eltname = go.GraphObject.takeBuilderArgument(args, 'COLLAPSIBLE') as string; - const button = go.GraphObject.build('Button') as go.Panel; + const button = go.GraphObject.build('Button'); button.attach({ // set these values for the button's look '_buttonExpandedFigure': 'M0 0 M0 6 L4 2 8 6 M8 8', @@ -407,8 +407,8 @@ go.GraphObject.defineBuilder('CheckBoxButton', (args: any): go.Panel => { // process the one required string argument for this kind of button const propname = go.GraphObject.takeBuilderArgument(args) as string; - const button = go.GraphObject.build('Button', - { desiredSize: new go.Size(14, 14) }) as go.Panel; + const button = go.GraphObject.build('Button', + { desiredSize: new go.Size(14, 14) }); button.add( new go.Shape({ name: 'ButtonIcon', @@ -454,14 +454,14 @@ go.GraphObject.defineBuilder('CheckBox', (args: any): go.Panel => { // process the one required string argument for this kind of button const propname = go.GraphObject.takeBuilderArgument(args) as string; - const button = go.GraphObject.build('CheckBoxButton', + const button = go.GraphObject.build('CheckBoxButton', { name: 'Button', isActionable: false, // actionable is set on the whole horizontal panel margin: new go.Margin(0, 1, 0, 0) }, propname // bound to this data property - ) as go.Panel; + ); const box = new go.Panel('Horizontal', { isActionable: true, diff --git a/extensionsJSM/DataInspector.js b/extensionsJSM/DataInspector.js index 5a5976c39..2d0f4f42c 100644 --- a/extensionsJSM/DataInspector.js +++ b/extensionsJSM/DataInspector.js @@ -295,10 +295,10 @@ export class Inspector { * @param part - the Part being inspected * @param propname - the property to check presence of */ - static showIfPresent(data, propname) { - if (data instanceof go.Part) - data = data.data; - return typeof data === 'object' && data[propname] !== undefined; + static showIfPresent(part, propname) { + if (part instanceof go.Part) + part = part.data; + return typeof part === 'object' && part[propname] !== undefined; } /** * Update the HTML state of this Inspector with the given object. diff --git a/extensionsJSM/DataInspector.ts b/extensionsJSM/DataInspector.ts index 8ee2457fa..bd4fbb2c4 100644 --- a/extensionsJSM/DataInspector.ts +++ b/extensionsJSM/DataInspector.ts @@ -310,9 +310,9 @@ export class Inspector { * @param part - the Part being inspected * @param propname - the property to check presence of */ - static showIfPresent(data: go.Part | null, propname: string): boolean { - if (data instanceof go.Part) data = data.data; - return typeof data === 'object' && (data as any)[propname] !== undefined; + static showIfPresent(part: go.Part | null, propname: string): boolean { + if (part instanceof go.Part) part = part.data; + return typeof part === 'object' && (part as any)[propname] !== undefined; } /** diff --git a/extensionsJSM/Figures.js b/extensionsJSM/Figures.js index 56f931930..dcb05de9b 100644 --- a/extensionsJSM/Figures.js +++ b/extensionsJSM/Figures.js @@ -1,9 +1,9 @@ /* * Copyright (C) 1998-2024 by Northwoods Software Corporation. All Rights Reserved. */ -// This file holds definitions of all standard shape figures -- string values for Shape.figure. -// You do not need to load this file in order to use named Shape figure. -// The following figures are built-in to the go.js library and thus do not need to be redefined: +// This file holds definitions of all legacy shape figures -- string values for Shape.figure. +// They were built into the library in version 1, but most were removed for v2.0. +// The following figures are still built-in to the go.js library and thus do not need explicit definitions: // Rectangle, Square, RoundedRectangle, Border, Ellipse, Circle, // TriangleRight, TriangleDown, TriangleLeft, TriangleUp, Triangle, // LineH, LineV, None, BarH, BarV, MinusLine, PlusLine, XLine, Capsule @@ -315,6 +315,40 @@ go.Shape.defineFigureGenerator('ChamferedRectangle', (shape, w, h) => { geo.spot2 = spot2; return geo; }); +// narrow ends of rectangular area come to a point +go.Shape.defineFigureGenerator('HexagonalCapsule', (shape, w, h) => { + let param1 = shape ? shape.parameter1 : NaN; + if (isNaN(param1)) + param1 = 10; + const geo = new go.Geometry(); + if (w < h) { + const inset = Math.min(param1, w / 2); + const fig = new go.PathFigure(w / 2, 0, true); + geo.add(fig); + // Outline + fig.add(new go.PathSegment(go.SegmentType.Line, w, inset)); + fig.add(new go.PathSegment(go.SegmentType.Line, w, h - inset)); + fig.add(new go.PathSegment(go.SegmentType.Line, w / 2, h)); + fig.add(new go.PathSegment(go.SegmentType.Line, 0, h - inset)); + fig.add(new go.PathSegment(go.SegmentType.Line, 0, inset).close()); + geo.spot1 = new go.Spot(0, 0, inset / 2, inset); + geo.spot2 = new go.Spot(1, 1, -inset / 2, -inset); + } + else { + const inset = Math.min(param1, h / 2); + const fig = new go.PathFigure(inset, 0, true); + geo.add(fig); + // Outline + fig.add(new go.PathSegment(go.SegmentType.Line, w - inset, 0)); + fig.add(new go.PathSegment(go.SegmentType.Line, w, h / 2)); + fig.add(new go.PathSegment(go.SegmentType.Line, w - inset, h)); + fig.add(new go.PathSegment(go.SegmentType.Line, inset, h)); + fig.add(new go.PathSegment(go.SegmentType.Line, 0, h / 2).close()); + geo.spot1 = new go.Spot(0, 0, inset, inset / 2); + geo.spot2 = new go.Spot(1, 1, -inset, -inset / 2); + } + return geo; +}); go.Shape.defineFigureGenerator('AsteriskLine', (shape, w, h) => { const offset = 0.2 / Math.SQRT2; return new go.Geometry().add(new go.PathFigure(offset * w, (1 - offset) * h, false) @@ -598,7 +632,7 @@ function freeArray(a) { */ function createPolygon(sides) { // Point[] points = new Point[sides + 1]; - const points = tempArray(); + const points = []; const radius = 0.5; const center = 0.5; const offsetAngle = Math.PI * 1.5; @@ -4907,49 +4941,6 @@ go.Shape.defineFigureGenerator('4Arrows', (shape, w, h) => { fig.add(new go.PathSegment(go.SegmentType.Line, w * 0.35, h * 0.25).close()); return geo; }); -// // narrow ends of rectangular area are completely rounded -// go.Shape.defineFigureGenerator('Capsule', (shape, w, h) => { -// const param1 = shape ? shape.parameter1 : NaN; -// const param2 = shape ? shape.parameter2 : NaN; -// -// const geo = new go.Geometry(); -// if (w < h) { -// const fig = new go.PathFigure(0, w / 2, true); -// geo.add(fig); -// // Outline -// const px = isFinite(param1) ? param1 : w * 0.156; -// const py = isFinite(param2) ? param2 : w * 0.156; -// fig.add(new go.PathSegment(go.SegmentType.Arc, 180, 180, w / 2, w / 2, w / 2, w / 2)); -// fig.add(new go.PathSegment(go.SegmentType.Line, w, h - w / 2)); -// fig.add(new go.PathSegment(go.SegmentType.Arc, 0, 180, w / 2, h - w / 2, w / 2, w / 2)); -// fig.add(new go.PathSegment(go.SegmentType.Line, 0, w / 2)); -// geo.spot1 = new go.Spot(0, 0, px, py); -// geo.spot2 = new go.Spot(1, 1, -px, -py); -// return geo; -// } else if (w > h) { -// const fig = new go.PathFigure(h / 2, 0, true); -// geo.add(fig); -// // Outline -// const px = isFinite(param1) ? param1 : h * 0.156; -// const py = isFinite(param2) ? param2 : h * 0.156; -// fig.add(new go.PathSegment(go.SegmentType.Line, w - h / 2, 0)); -// fig.add(new go.PathSegment(go.SegmentType.Arc, 270, 180, w - h / 2, h / 2, h / 2, h / 2)); -// fig.add(new go.PathSegment(go.SegmentType.Line, w - h / 2, h)); -// fig.add(new go.PathSegment(go.SegmentType.Arc, 90, 180, h / 2, h / 2, h / 2, h / 2)); -// geo.spot1 = new go.Spot(0, 0, px, py); -// geo.spot2 = new go.Spot(1, 1, -px, -py); -// return geo; -// } else { // w === h -// geo.type = go.GeometryType.Ellipse; -// geo.endX = w; -// geo.endY = h; -// const px = isFinite(param1) ? param1 : w * 0.156; -// const py = isFinite(param2) ? param2 : w * 0.156; -// geo.spot1 = new go.Spot(0, 0, px, py); -// geo.spot2 = new go.Spot(1, 1, -px, -py); -// return geo; -// } -// }); go.Shape.defineFigureGenerator('Connector', 'Ellipse'); go.Shape.defineFigureGenerator('Alternative', 'TriangleUp'); go.Shape.defineFigureGenerator('Merge', 'TriangleUp'); diff --git a/extensionsJSM/Figures.ts b/extensionsJSM/Figures.ts index 7e7d81fb3..20a846610 100644 --- a/extensionsJSM/Figures.ts +++ b/extensionsJSM/Figures.ts @@ -2,10 +2,9 @@ * Copyright (C) 1998-2024 by Northwoods Software Corporation. All Rights Reserved. */ -// This file holds definitions of all standard shape figures -- string values for Shape.figure. -// You do not need to load this file in order to use named Shape figure. - -// The following figures are built-in to the go.js library and thus do not need to be redefined: +// This file holds definitions of all legacy shape figures -- string values for Shape.figure. +// They were built into the library in version 1, but most were removed for v2.0. +// The following figures are still built-in to the go.js library and thus do not need explicit definitions: // Rectangle, Square, RoundedRectangle, Border, Ellipse, Circle, // TriangleRight, TriangleDown, TriangleLeft, TriangleUp, Triangle, // LineH, LineV, None, BarH, BarV, MinusLine, PlusLine, XLine, Capsule @@ -352,6 +351,39 @@ go.Shape.defineFigureGenerator('ChamferedRectangle', (shape, w, h) => { return geo; }); +// narrow ends of rectangular area come to a point +go.Shape.defineFigureGenerator('HexagonalCapsule', (shape, w, h) => { + let param1 = shape ? shape.parameter1 : NaN; + if (isNaN(param1)) param1 = 10; + const geo = new go.Geometry(); + if (w < h) { + const inset = Math.min(param1, w/2); + const fig = new go.PathFigure(w/2, 0, true); + geo.add(fig); + // Outline + fig.add(new go.PathSegment(go.SegmentType.Line, w, inset)); + fig.add(new go.PathSegment(go.SegmentType.Line, w, h - inset)); + fig.add(new go.PathSegment(go.SegmentType.Line, w/2, h)); + fig.add(new go.PathSegment(go.SegmentType.Line, 0, h - inset)); + fig.add(new go.PathSegment(go.SegmentType.Line, 0, inset).close()); + geo.spot1 = new go.Spot(0, 0, inset/2, inset); + geo.spot2 = new go.Spot(1, 1, -inset/2, -inset); + } else { + const inset = Math.min(param1, h/2); + const fig = new go.PathFigure(inset, 0, true); + geo.add(fig); + // Outline + fig.add(new go.PathSegment(go.SegmentType.Line, w - inset, 0)); + fig.add(new go.PathSegment(go.SegmentType.Line, w, h/2)); + fig.add(new go.PathSegment(go.SegmentType.Line, w - inset, h)); + fig.add(new go.PathSegment(go.SegmentType.Line, inset, h)); + fig.add(new go.PathSegment(go.SegmentType.Line, 0, h/2).close()); + geo.spot1 = new go.Spot(0, 0, inset, inset/2); + geo.spot2 = new go.Spot(1, 1, -inset, -inset/2); + } + return geo; +}); + go.Shape.defineFigureGenerator('AsteriskLine', (shape, w, h) => { const offset = 0.2 / Math.SQRT2; return new go.Geometry().add( @@ -720,7 +752,7 @@ function freeArray(a: Array) { */ function createPolygon(sides: number): Array { // Point[] points = new Point[sides + 1]; - const points = tempArray(); + const points = []; const radius = 0.5; const center = 0.5; const offsetAngle = Math.PI * 1.5; @@ -9057,50 +9089,6 @@ go.Shape.defineFigureGenerator('4Arrows', (shape, w, h) => { return geo; }); -// // narrow ends of rectangular area are completely rounded -// go.Shape.defineFigureGenerator('Capsule', (shape, w, h) => { -// const param1 = shape ? shape.parameter1 : NaN; -// const param2 = shape ? shape.parameter2 : NaN; -// -// const geo = new go.Geometry(); -// if (w < h) { -// const fig = new go.PathFigure(0, w / 2, true); -// geo.add(fig); -// // Outline -// const px = isFinite(param1) ? param1 : w * 0.156; -// const py = isFinite(param2) ? param2 : w * 0.156; -// fig.add(new go.PathSegment(go.SegmentType.Arc, 180, 180, w / 2, w / 2, w / 2, w / 2)); -// fig.add(new go.PathSegment(go.SegmentType.Line, w, h - w / 2)); -// fig.add(new go.PathSegment(go.SegmentType.Arc, 0, 180, w / 2, h - w / 2, w / 2, w / 2)); -// fig.add(new go.PathSegment(go.SegmentType.Line, 0, w / 2)); -// geo.spot1 = new go.Spot(0, 0, px, py); -// geo.spot2 = new go.Spot(1, 1, -px, -py); -// return geo; -// } else if (w > h) { -// const fig = new go.PathFigure(h / 2, 0, true); -// geo.add(fig); -// // Outline -// const px = isFinite(param1) ? param1 : h * 0.156; -// const py = isFinite(param2) ? param2 : h * 0.156; -// fig.add(new go.PathSegment(go.SegmentType.Line, w - h / 2, 0)); -// fig.add(new go.PathSegment(go.SegmentType.Arc, 270, 180, w - h / 2, h / 2, h / 2, h / 2)); -// fig.add(new go.PathSegment(go.SegmentType.Line, w - h / 2, h)); -// fig.add(new go.PathSegment(go.SegmentType.Arc, 90, 180, h / 2, h / 2, h / 2, h / 2)); -// geo.spot1 = new go.Spot(0, 0, px, py); -// geo.spot2 = new go.Spot(1, 1, -px, -py); -// return geo; -// } else { // w === h -// geo.type = go.GeometryType.Ellipse; -// geo.endX = w; -// geo.endY = h; -// const px = isFinite(param1) ? param1 : w * 0.156; -// const py = isFinite(param2) ? param2 : w * 0.156; -// geo.spot1 = new go.Spot(0, 0, px, py); -// geo.spot2 = new go.Spot(1, 1, -px, -py); -// return geo; -// } -// }); - go.Shape.defineFigureGenerator('Connector', 'Ellipse'); go.Shape.defineFigureGenerator('Alternative', 'TriangleUp'); go.Shape.defineFigureGenerator('Merge', 'TriangleUp'); diff --git a/extensionsJSM/LinkLabelRouter.js b/extensionsJSM/LinkLabelRouter.js index d2ead15a1..771f67e30 100644 --- a/extensionsJSM/LinkLabelRouter.js +++ b/extensionsJSM/LinkLabelRouter.js @@ -97,30 +97,30 @@ export class LinkLabelRouter extends go.Router { * Determine if the LinkLabelRouter should run on a given collection. * By default only run once on the whole Diagram, never on Groups * - * @param { go.Diagram | go.Group } coll + * @param { go.Diagram | go.Group } container * @returns */ - canRoute(coll) { - if (coll instanceof go.Group) + canRoute(container) { + if (container instanceof go.Group) return false; - return super.canRoute(coll); + return super.canRoute(container); } /** * Attempt to move link label objects to avoid overlaps, if necessary. * - * @param {*} coll A Diagram or a Group - * @param {*} diagram + * @param {go.Set} links + * @param {*} container A Diagram or a Group * @returns */ - routeLinks(links, coll) { + routeLinks(links, container) { if (this.layout === null) return; - if (coll instanceof go.Group) + if (container instanceof go.Group) return; this.layout.activeSet = links; - if (coll instanceof go.Diagram) - this.layout.diagram = coll; - this.layout.doLayout(coll.links); + if (container instanceof go.Diagram) + this.layout.diagram = container; + this.layout.doLayout(container.links); if (this.layout.network === null) return; for (const vertex of this.layout.network.vertexes) { @@ -142,8 +142,8 @@ export class LinkLabelRouter extends go.Router { } /** @hidden @internal */ class LabelVertex extends go.ForceDirectedVertex { - constructor() { - super(...arguments); + constructor(network) { + super(network); this.object = null; this.objectBounds = null; this.currentBounds = null; @@ -152,10 +152,12 @@ class LabelVertex extends go.ForceDirectedVertex { } /** @hidden @internal */ class LabelLayout extends go.ForceDirectedLayout { - constructor() { - super(...arguments); + constructor(init) { + super(); /** @hidden */ this.router = null; /** @hidden */ this.activeSet = null; + if (init) + Object.assign(this, init); } /** * we should not ever do a prelayout on this virtual, "fake" force-directed network diff --git a/extensionsJSM/LinkLabelRouter.ts b/extensionsJSM/LinkLabelRouter.ts index 36cf8dd90..e9a194cf6 100644 --- a/extensionsJSM/LinkLabelRouter.ts +++ b/extensionsJSM/LinkLabelRouter.ts @@ -102,28 +102,28 @@ export class LinkLabelRouter extends go.Router { * Determine if the LinkLabelRouter should run on a given collection. * By default only run once on the whole Diagram, never on Groups * - * @param { go.Diagram | go.Group } coll + * @param { go.Diagram | go.Group } container * @returns */ - override canRoute(coll: go.Diagram | go.Group): boolean { - if (coll instanceof go.Group) return false; - return super.canRoute(coll); + override canRoute(container: go.Diagram | go.Group): boolean { + if (container instanceof go.Group) return false; + return super.canRoute(container); } /** * Attempt to move link label objects to avoid overlaps, if necessary. * - * @param {*} coll A Diagram or a Group - * @param {*} diagram + * @param {go.Set} links + * @param {*} container A Diagram or a Group * @returns */ - override routeLinks(links: go.Set, coll: go.Diagram | go.Group) { + override routeLinks(links: go.Set, container: go.Diagram | go.Group) { if (this.layout === null) return; - if (coll instanceof go.Group) return; + if (container instanceof go.Group) return; this.layout.activeSet = links; - if (coll instanceof go.Diagram) this.layout.diagram = coll; - this.layout.doLayout(coll.links); + if (container instanceof go.Diagram) this.layout.diagram = container; + this.layout.doLayout(container.links); if (this.layout.network === null) return; for(const vertex of this.layout.network.vertexes) { @@ -143,6 +143,9 @@ export class LinkLabelRouter extends go.Router { /** @hidden @internal */ class LabelVertex extends go.ForceDirectedVertex { + constructor(network: go.ForceDirectedNetwork) { + super(network); + } object: go.GraphObject | null = null; objectBounds: go.Rect | null = null; currentBounds: go.Rect | null = null; @@ -151,6 +154,11 @@ class LabelVertex extends go.ForceDirectedVertex { /** @hidden @internal */ class LabelLayout extends go.ForceDirectedLayout { + constructor(init?: Partial) { + super(); + if (init) Object.assign(this, init); + } + /** @hidden */ router: LinkLabelRouter | null = null; /** @hidden */ activeSet: go.Set | null = null; diff --git a/extensionsJSM/NonRealtimeDraggingTool.js b/extensionsJSM/NonRealtimeDraggingTool.js index 0d563dc1f..a57b0032d 100644 --- a/extensionsJSM/NonRealtimeDraggingTool.js +++ b/extensionsJSM/NonRealtimeDraggingTool.js @@ -41,8 +41,8 @@ export class NonRealtimeDraggingTool extends go.DraggingTool { * show it using a Picture, and hold the Picture in a temporary Part, as _imagePart. * @param parts - A {@link go.Set} or {@link go.List} of {@link go.Part}s. */ - computeEffectiveCollection(coll) { - const map = super.computeEffectiveCollection(coll, this.dragOptions); + computeEffectiveCollection(parts) { + const map = super.computeEffectiveCollection(parts, this.dragOptions); if (this.isActive && this._imagePart === null) { const bounds = this.diagram.computePartsBounds(map.toKeySet()); const offset = this.diagram.lastInput.documentPoint.copy().subtract(bounds.position); diff --git a/extensionsJSM/NonRealtimeDraggingTool.ts b/extensionsJSM/NonRealtimeDraggingTool.ts index aeca28ec1..b9ffc9957 100644 --- a/extensionsJSM/NonRealtimeDraggingTool.ts +++ b/extensionsJSM/NonRealtimeDraggingTool.ts @@ -50,10 +50,8 @@ export class NonRealtimeDraggingTool extends go.DraggingTool { * show it using a Picture, and hold the Picture in a temporary Part, as _imagePart. * @param parts - A {@link go.Set} or {@link go.List} of {@link go.Part}s. */ - override computeEffectiveCollection( - coll: go.Iterable - ): go.Map { - const map = super.computeEffectiveCollection(coll, this.dragOptions); + override computeEffectiveCollection(parts: go.Iterable): go.Map { + const map = super.computeEffectiveCollection(parts, this.dragOptions); if (this.isActive && this._imagePart === null) { const bounds = this.diagram.computePartsBounds(map.toKeySet()); const offset = this.diagram.lastInput.documentPoint.copy().subtract(bounds.position); diff --git a/extensionsJSM/ScrollingTable.js b/extensionsJSM/ScrollingTable.js index 0b6d1bc77..8f8de53b7 100644 --- a/extensionsJSM/ScrollingTable.js +++ b/extensionsJSM/ScrollingTable.js @@ -55,26 +55,9 @@ go.GraphObject.defineBuilder('AutoRepeatButton', (args) => { } } const button = go.GraphObject.build('Button'); - // override the normal button actions - const btndown = button.actionDown; - const btnup = button.actionUp; - const btncancel = button.actionCancel; - button.actionDown = (e, btn) => { - delayClicking(e, btn); - if (btndown) - btndown(e, btn); - }; - button.actionUp = (e, btn) => { - endClicking(e, btn); - if (btnup) - btnup(e, btn); - }; - button.actionCancel = (e, btn) => { - endClicking(e, btn); - if (btncancel) - btncancel(e, btn); - }; - go.GraphObject.build("Button").add(new go.Panel()); + button.actionDown = (e, btn) => delayClicking(e, btn); + button.actionUp = (e, btn) => endClicking(e, btn); + button.actionCancel = (e, btn) => endClicking(e, btn); return button; }); // Create a "Table" Panel that supports scrolling. diff --git a/extensionsJSM/ScrollingTable.ts b/extensionsJSM/ScrollingTable.ts index f5833c2f1..8d9c40f39 100644 --- a/extensionsJSM/ScrollingTable.ts +++ b/extensionsJSM/ScrollingTable.ts @@ -34,6 +34,7 @@ import * as go from 'gojs'; go.GraphObject.defineBuilder('AutoRepeatButton', (args) => { const repeat = go.GraphObject.takeBuilderArgument(args, 50, (x) => typeof x === 'number'); const delay = go.GraphObject.takeBuilderArgument(args, 500, (x) => typeof x === 'number'); + // some internal helper functions for auto-repeating function delayClicking(e: go.InputEvent, obj: any) { endClicking(e, obj); @@ -61,23 +62,9 @@ go.GraphObject.defineBuilder('AutoRepeatButton', (args) => { } const button = go.GraphObject.build('Button'); - // override the normal button actions - const btndown = button.actionDown; - const btnup = button.actionUp; - const btncancel = button.actionCancel; - button.actionDown = (e, btn) => { - delayClicking(e, btn); - if (btndown) btndown(e, btn); - }; - button.actionUp = (e, btn) => { - endClicking(e, btn); - if (btnup) btnup(e, btn); - }; - button.actionCancel = (e, btn) => { - endClicking(e, btn); - if (btncancel) btncancel(e, btn); - }; - (go.GraphObject.build("Button") as go.Panel).add(new go.Panel()); + button.actionDown = (e, btn) => delayClicking(e, btn); + button.actionUp = (e, btn) => endClicking(e, btn); + button.actionCancel = (e, btn) => endClicking(e, btn); return button; }); @@ -278,7 +265,7 @@ go.GraphObject.defineBuilder('ScrollingTable', (args) => { .addRowDefinition(2, { sizing: go.Sizing.None }) .add( // the scroll up button - (go.GraphObject.build('AutoRepeatButton', { + go.GraphObject.build('AutoRepeatButton', { name: 'UP', row: 0, opacity: 0.0, @@ -294,7 +281,7 @@ go.GraphObject.defineBuilder('ScrollingTable', (args) => { e.handled = true; incrTableIndex(obj, -1); } - }) as go.Panel) + }) .add( new go.Shape('TriangleUp', { strokeWidth: 0, @@ -325,7 +312,7 @@ go.GraphObject.defineBuilder('ScrollingTable', (args) => { } }), // the scroll down button - (go.GraphObject.build('AutoRepeatButton', { + go.GraphObject.build('AutoRepeatButton', { name: 'DOWN', row: 2, opacity: 0.0, @@ -341,7 +328,7 @@ go.GraphObject.defineBuilder('ScrollingTable', (args) => { e.handled = true; incrTableIndex(obj, +1); } - }) as go.Panel) + }) .add( new go.Shape('TriangleDown', { strokeWidth: 0, diff --git a/extensionsJSM/SerpentineLayout.js b/extensionsJSM/SerpentineLayout.js index 7a431e722..b3745dd13 100644 --- a/extensionsJSM/SerpentineLayout.js +++ b/extensionsJSM/SerpentineLayout.js @@ -131,7 +131,7 @@ export class SerpentineLayout extends go.Layout { * This method actually positions all of the Nodes, assuming that the ordering of the nodes * is given by a single link from one node to the next. * This respects the {@link spacing} and {@link wrap} properties to affect the layout. - * @param coll - A collection of {@link go.Part}s. + * @param collection - A collection of {@link go.Part}s. */ doLayout(collection) { const diagram = this.diagram; diff --git a/extensionsJSM/SerpentineLayout.ts b/extensionsJSM/SerpentineLayout.ts index 56b0771b1..566e336c1 100644 --- a/extensionsJSM/SerpentineLayout.ts +++ b/extensionsJSM/SerpentineLayout.ts @@ -143,7 +143,7 @@ export class SerpentineLayout extends go.Layout { * This method actually positions all of the Nodes, assuming that the ordering of the nodes * is given by a single link from one node to the next. * This respects the {@link spacing} and {@link wrap} properties to affect the layout. - * @param coll - A collection of {@link go.Part}s. + * @param collection - A collection of {@link go.Part}s. */ override doLayout(collection: go.Diagram | go.Iterable | go.Group): void { const diagram = this.diagram; diff --git a/extensionsJSM/SwimLaneLayout.js b/extensionsJSM/SwimLaneLayout.js index 7d15e6b0d..71088efd2 100644 --- a/extensionsJSM/SwimLaneLayout.js +++ b/extensionsJSM/SwimLaneLayout.js @@ -30,11 +30,9 @@ import * as go from 'gojs'; export class SwimLaneLayout extends go.LayeredDigraphLayout { constructor(init) { super(); - // internal state - this._layers = [[]]; - this._neededSpaces = []; this._laneProperty = 'lane'; // how to get lane identifier string from node data this._laneNames = []; // lane names, may be sorted using this.laneComparer + this._laneIndexes = new go.Map(); this._laneComparer = null; this._laneSpacing = 0; // in columns this._router = { linkSpacing: 4 }; @@ -327,10 +325,11 @@ export class SwimLaneLayout extends go.LayeredDigraphLayout { // set up some data structures const layout = this; const laneNameSet = new go.Set().addAll(this.laneNames); - const laneIndexes = new go.Map(); // lane names --> index when sorted + const laneIndexes = new go.Map(); // lane name --> index when sorted const vit = this.network.vertexes.iterator; while (vit.next()) { const v = vit.value; + // discover any more lane names const lane = this.getLane(v); // cannot call findLane yet if (lane !== null && !laneNameSet.has(lane)) { laneNameSet.add(lane); @@ -347,12 +346,13 @@ export class SwimLaneLayout extends go.LayeredDigraphLayout { } } } - // sort laneNames and initialize laneIndexes + // sort laneNames and initialize laneIndexes with sorted indexes if (typeof this.laneComparer === 'function') this.laneNames.sort(this.laneComparer); for (let i = 0; i < this.laneNames.length; i++) { laneIndexes.set(this.laneNames[i], i); } + this._laneIndexes = laneIndexes; // now OK to call findLane // sort vertexes so that vertexes are grouped by lane for (let i = 0; i <= this.maxLayer; i++) { @@ -369,12 +369,13 @@ export class SwimLaneLayout extends go.LayeredDigraphLayout { const layers = this._layers; const red = this.reducer; if (red) { - for (let i = 0; i < layers.length - 1; i++) { - red.reduceCrossings(layers[i], layers[i + 1]); + red.laneIndexes = this._laneIndexes; + for (let i = 1; i < layers.length; i++) { + red.reduceCrossings(layers[i], layers[i - 1]); layers[i].forEach((v, j) => (v.index = j)); } - for (let i = layers.length - 1; i > 0; i--) { - red.reduceCrossings(layers[i], layers[i - 1]); + for (let i = layers.length - 2; i >= 0; i--) { + red.reduceCrossings(layers[i], layers[i + 1]); layers[i].forEach((v, j) => (v.index = j)); } } @@ -551,13 +552,17 @@ export class SwimLaneLayout extends go.LayeredDigraphLayout { let laneW = this.findLane(w); if (laneW === null) laneW = ''; - if (laneV < laneW) + const idxV = this._laneIndexes.get(laneV) || 0; + const idxW = this._laneIndexes.get(laneW) || 0; + if (idxV < idxW) return -1; - if (laneV > laneW) + if (idxV > idxW) return 1; // OPTIONAL: sort dummy vertexes before vertexes representing real nodes - //if (v.node === null && w.node !== null) return -1; - //if (v.node !== null && w.node === null) return 1; + if (v.node === null && w.node !== null) + return -1; + if (v.node !== null && w.node === null) + return 1; if (v.column < w.column) return -1; if (v.column > w.column) diff --git a/extensionsJSM/SwimLaneLayout.ts b/extensionsJSM/SwimLaneLayout.ts index 05763de82..ed724ccf3 100644 --- a/extensionsJSM/SwimLaneLayout.ts +++ b/extensionsJSM/SwimLaneLayout.ts @@ -35,6 +35,7 @@ export class SwimLaneLayout extends go.LayeredDigraphLayout { // settable properties private _laneProperty: string | ((d: any) => string); // how to get lane identifier string from node data private _laneNames: Array; // lane names, may be sorted using this.laneComparer + private _laneIndexes: go.Map; private _laneComparer: ((a: string, b: string) => number) | null; private _laneSpacing: number; // in columns @@ -47,13 +48,14 @@ export class SwimLaneLayout extends go.LayeredDigraphLayout { private readonly _laneBreadths: go.Map; // lane names --> needed width in columns // internal state - private _layers: Array> = [[]]; - private _neededSpaces: Array = []; + private _layers: Array>; + private _neededSpaces: Array; constructor(init?: Partial) { super(); this._laneProperty = 'lane'; // how to get lane identifier string from node data this._laneNames = []; // lane names, may be sorted using this.laneComparer + this._laneIndexes = new go.Map(); this._laneComparer = null; this._laneSpacing = 0; // in columns this._router = { linkSpacing: 4 }; @@ -337,18 +339,17 @@ export class SwimLaneLayout extends go.LayeredDigraphLayout { // set up some data structures const layout = this; const laneNameSet = new go.Set().addAll(this.laneNames); - const laneIndexes = new go.Map(); // lane names --> index when sorted + const laneIndexes = new go.Map(); // lane name --> index when sorted const vit = (this.network as go.LayeredDigraphNetwork).vertexes.iterator; while (vit.next()) { const v = vit.value as go.LayeredDigraphVertex; - + // discover any more lane names const lane = this.getLane(v); // cannot call findLane yet if (lane !== null && !laneNameSet.has(lane)) { laneNameSet.add(lane); this.laneNames.push(lane); } - const layer = v.layer; if (layer >= 0) { const arr = this._layers[layer]; @@ -360,11 +361,12 @@ export class SwimLaneLayout extends go.LayeredDigraphLayout { } } - // sort laneNames and initialize laneIndexes + // sort laneNames and initialize laneIndexes with sorted indexes if (typeof this.laneComparer === 'function') this.laneNames.sort(this.laneComparer); for (let i = 0; i < this.laneNames.length; i++) { laneIndexes.set(this.laneNames[i], i); } + this._laneIndexes = laneIndexes; // now OK to call findLane // sort vertexes so that vertexes are grouped by lane @@ -384,12 +386,13 @@ export class SwimLaneLayout extends go.LayeredDigraphLayout { const layers = this._layers; const red = this.reducer; if (red) { - for (let i = 0; i < layers.length - 1; i++) { - red.reduceCrossings(layers[i], layers[i + 1]); + red.laneIndexes = this._laneIndexes; + for (let i = 1; i < layers.length; i++) { + red.reduceCrossings(layers[i], layers[i - 1]); layers[i].forEach((v, j) => (v.index = j)); } - for (let i = layers.length - 1; i > 0; i--) { - red.reduceCrossings(layers[i], layers[i - 1]); + for (let i = layers.length - 2; i >= 0; i--) { + red.reduceCrossings(layers[i], layers[i + 1]); layers[i].forEach((v, j) => (v.index = j)); } } @@ -565,11 +568,13 @@ export class SwimLaneLayout extends go.LayeredDigraphLayout { if (laneV === null) laneV = ''; let laneW = this.findLane(w); if (laneW === null) laneW = ''; - if (laneV < laneW) return -1; - if (laneV > laneW) return 1; + const idxV = this._laneIndexes.get(laneV) || 0; + const idxW = this._laneIndexes.get(laneW) || 0; + if (idxV < idxW) return -1; + if (idxV > idxW) return 1; // OPTIONAL: sort dummy vertexes before vertexes representing real nodes - //if (v.node === null && w.node !== null) return -1; - //if (v.node !== null && w.node === null) return 1; + if (v.node === null && w.node !== null) return -1; + if (v.node !== null && w.node === null) return 1; if (v.column < w.column) return -1; if (v.column > w.column) return 1; return 0; diff --git a/index.html b/index.html index 36a606ff2..78f50e58a 100644 --- a/index.html +++ b/index.html @@ -226,13 +226,13 @@

              -

              Build diagrams for the web in - JavaScript and TypeScript

              +

              Build diagrams for the web in + JavaScript and TypeScript

              GoJS is used to create interactive diagrams to visualize, monitor, and edit your systems.

              - @@ -241,7 +241,7 @@

              Build diagrams for the web in Org Chart
              + class="absolute opacity-90 bottom-0 left-0 z-10 p-4 text-white bg-gray-900/90 transition-all group-hover:-translate-y-8 group-hover:opacity-100">

              Org charts

              Represent relationships

              -

              Develop interactive org charts, trees, and hierarchy diagrams

              +

              Develop interactive org charts, trees, and hierarchy diagrams

              - @@ -373,7 +373,7 @@

              Trusted across industries

              Industrial Monitor
              + class="absolute opacity-90 bottom-0 left-0 z-10 p-4 text-gray-900 bg-[#e1cdab] transition-all group-hover:-translate-y-8 group-hover:opacity-100">

              Industrial Diagrams

              Process organization

              -

              Visualize and monitor critical assets across domains

              +

              Visualize and monitor critical assets across domains

              + +
              + - -

              Develop faster

              -

              Built-in features and interactivity - to get your projects out the door

              +

              Built-in features and interactivity + to get your projects out the door

              @@ -727,14 +793,14 @@

              Built-in features and interactivity

              -
              -

              Designed to work with all - modern frameworks

              +

              Designed to work with all + modern frameworks

              With no dependencies, you can use GoJS anywhere. Leverage it in React, Vue, Angular, or Svelte apps, or in your Node or Electron apps.

              @@ -832,13 +898,13 @@

              Designed to work with all

              -
              -

              Extensive documentation

              +

              Extensive documentation

              @@ -1023,7 +1089,14 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + \ No newline at end of file diff --git a/intro/HTMLInteraction.html b/intro/HTMLInteraction.html index 8e5cf6754..8ae09cc15 100644 --- a/intro/HTMLInteraction.html +++ b/intro/HTMLInteraction.html @@ -675,8 +675,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/SVGContext.html b/intro/SVGContext.html index 32e4758fc..025df66be 100644 --- a/intro/SVGContext.html +++ b/intro/SVGContext.html @@ -478,8 +478,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/angular.html b/intro/angular.html index 2f67bafe4..74c0e401b 100644 --- a/intro/angular.html +++ b/intro/angular.html @@ -932,8 +932,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/animation.html b/intro/animation.html index d43b81f8b..b8d7d2f5b 100644 --- a/intro/animation.html +++ b/intro/animation.html @@ -953,8 +953,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/brush.html b/intro/brush.html index f60cf1e6a..f07a98dea 100644 --- a/intro/brush.html +++ b/intro/brush.html @@ -805,8 +805,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/buildingObjects.html b/intro/buildingObjects.html index 3b0ef4de3..667671a93 100644 --- a/intro/buildingObjects.html +++ b/intro/buildingObjects.html @@ -960,8 +960,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/buttons.html b/intro/buttons.html index 5c2f6c15c..59b6b8434 100644 --- a/intro/buttons.html +++ b/intro/buttons.html @@ -897,8 +897,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/changedEvents.html b/intro/changedEvents.html index 1810e39a1..f81b399a9 100644 --- a/intro/changedEvents.html +++ b/intro/changedEvents.html @@ -609,8 +609,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/collections.html b/intro/collections.html index 41e19c45c..3a0b04a66 100644 --- a/intro/collections.html +++ b/intro/collections.html @@ -701,8 +701,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/commands.html b/intro/commands.html index 8104ee4a8..e5ff08903 100644 --- a/intro/commands.html +++ b/intro/commands.html @@ -573,8 +573,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/connectionPoints.html b/intro/connectionPoints.html index e012b4229..49851e0b6 100644 --- a/intro/connectionPoints.html +++ b/intro/connectionPoints.html @@ -749,8 +749,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/contextMenus.html b/intro/contextMenus.html index 68f5625d4..39fffda44 100644 --- a/intro/contextMenus.html +++ b/intro/contextMenus.html @@ -595,8 +595,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/dataBinding.html b/intro/dataBinding.html index 20b5c7a4f..a461d7378 100644 --- a/intro/dataBinding.html +++ b/intro/dataBinding.html @@ -1493,8 +1493,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/debugging.html b/intro/debugging.html index 6cbf059d9..74eb0cd1c 100644 --- a/intro/debugging.html +++ b/intro/debugging.html @@ -743,8 +743,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/deployment.html b/intro/deployment.html index b36d70f32..99330f488 100644 --- a/intro/deployment.html +++ b/intro/deployment.html @@ -470,8 +470,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/events.html b/intro/events.html index c384852d2..c3dcc370f 100644 --- a/intro/events.html +++ b/intro/events.html @@ -810,8 +810,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/extensions.html b/intro/extensions.html index a4b2bb6b6..bf612b41a 100644 --- a/intro/extensions.html +++ b/intro/extensions.html @@ -623,8 +623,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/geometry.html b/intro/geometry.html index dfaa8de56..78a46ba6c 100644 --- a/intro/geometry.html +++ b/intro/geometry.html @@ -852,8 +852,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/graduatedPanels.html b/intro/graduatedPanels.html index 8845791fc..9d1815ea2 100644 --- a/intro/graduatedPanels.html +++ b/intro/graduatedPanels.html @@ -1028,8 +1028,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/grids.html b/intro/grids.html index b3573fdaa..d9c0e6208 100644 --- a/intro/grids.html +++ b/intro/grids.html @@ -683,8 +683,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/groups.html b/intro/groups.html index e7df4e966..ccf91acfb 100644 --- a/intro/groups.html +++ b/intro/groups.html @@ -516,8 +516,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/highlighting.html b/intro/highlighting.html index d0b64a432..ed0fa10a4 100644 --- a/intro/highlighting.html +++ b/intro/highlighting.html @@ -620,8 +620,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/index.html b/intro/index.html index ff0f1007b..6f8b061ae 100644 --- a/intro/index.html +++ b/intro/index.html @@ -907,8 +907,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/initialView.html b/intro/initialView.html index be13f726c..15b0c95c8 100644 --- a/intro/initialView.html +++ b/intro/initialView.html @@ -482,8 +482,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/itemArrays.html b/intro/itemArrays.html index 0d47b8f2e..dd820963d 100644 --- a/intro/itemArrays.html +++ b/intro/itemArrays.html @@ -792,8 +792,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/layers.html b/intro/layers.html index f38b92a8b..9fda38224 100644 --- a/intro/layers.html +++ b/intro/layers.html @@ -507,8 +507,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/layouts.html b/intro/layouts.html index 79db4ccfe..cddce06d0 100644 --- a/intro/layouts.html +++ b/intro/layouts.html @@ -877,8 +877,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/legends.html b/intro/legends.html index 69a0860b2..4faae1793 100644 --- a/intro/legends.html +++ b/intro/legends.html @@ -476,8 +476,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/linkLabels.html b/intro/linkLabels.html index e96e66a7c..438176246 100644 --- a/intro/linkLabels.html +++ b/intro/linkLabels.html @@ -832,8 +832,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/links.html b/intro/links.html index 86799a6d1..239942f49 100644 --- a/intro/links.html +++ b/intro/links.html @@ -1049,8 +1049,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/makingImages.html b/intro/makingImages.html index 853dbc032..cd1e1ad9f 100644 --- a/intro/makingImages.html +++ b/intro/makingImages.html @@ -687,8 +687,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/makingSVG.html b/intro/makingSVG.html index 228dd8caf..bd6aa119c 100644 --- a/intro/makingSVG.html +++ b/intro/makingSVG.html @@ -697,8 +697,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/nodeScript.html b/intro/nodeScript.html index ac8cb07a2..4834e7de0 100644 --- a/intro/nodeScript.html +++ b/intro/nodeScript.html @@ -432,8 +432,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/nodes.html b/intro/nodes.html index 94d7dc5fa..eebe6ae50 100644 --- a/intro/nodes.html +++ b/intro/nodes.html @@ -869,8 +869,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/overview.html b/intro/overview.html index 915c03749..077afcc41 100644 --- a/intro/overview.html +++ b/intro/overview.html @@ -394,8 +394,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/palette.html b/intro/palette.html index aa54d1453..f70a6fd1e 100644 --- a/intro/palette.html +++ b/intro/palette.html @@ -478,8 +478,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/panels.html b/intro/panels.html index 961fc349f..8cb52fb14 100644 --- a/intro/panels.html +++ b/intro/panels.html @@ -1295,8 +1295,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/performance.html b/intro/performance.html index b4bc412f1..6f1eff257 100644 --- a/intro/performance.html +++ b/intro/performance.html @@ -453,8 +453,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/permissions.html b/intro/permissions.html index 6418c4c36..20d47892b 100644 --- a/intro/permissions.html +++ b/intro/permissions.html @@ -731,8 +731,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/pictures.html b/intro/pictures.html index 1ae58e56b..5132f15b8 100644 --- a/intro/pictures.html +++ b/intro/pictures.html @@ -649,8 +649,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/platforms.html b/intro/platforms.html index b30244e30..0a4f137ae 100644 --- a/intro/platforms.html +++ b/intro/platforms.html @@ -411,8 +411,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/ports.html b/intro/ports.html index 32b1e7c41..2c9cb0c76 100644 --- a/intro/ports.html +++ b/intro/ports.html @@ -621,8 +621,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/printing.html b/intro/printing.html index 4d697d1a8..2eacde73c 100644 --- a/intro/printing.html +++ b/intro/printing.html @@ -500,8 +500,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/react.html b/intro/react.html index f60ca0418..34a78e067 100644 --- a/intro/react.html +++ b/intro/react.html @@ -812,8 +812,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/replacingDeleting.html b/intro/replacingDeleting.html index acd0be3d7..0d566ae45 100644 --- a/intro/replacingDeleting.html +++ b/intro/replacingDeleting.html @@ -558,8 +558,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/resizing.html b/intro/resizing.html index 37ebfc8d1..72fbeaa2a 100644 --- a/intro/resizing.html +++ b/intro/resizing.html @@ -443,8 +443,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/routers.html b/intro/routers.html index 9493fc085..d1e4acf9a 100644 --- a/intro/routers.html +++ b/intro/routers.html @@ -499,8 +499,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/selection.html b/intro/selection.html index 4fc06d649..8c2b1bbc2 100644 --- a/intro/selection.html +++ b/intro/selection.html @@ -736,8 +736,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/serverSideImages.html b/intro/serverSideImages.html index b91aaa965..1b335c523 100644 --- a/intro/serverSideImages.html +++ b/intro/serverSideImages.html @@ -474,8 +474,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/shapes.html b/intro/shapes.html index d88a9b51b..48414975c 100644 --- a/intro/shapes.html +++ b/intro/shapes.html @@ -652,8 +652,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/sizedGroups.html b/intro/sizedGroups.html index 8b88653d9..1a166c96d 100644 --- a/intro/sizedGroups.html +++ b/intro/sizedGroups.html @@ -483,8 +483,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/sizing.html b/intro/sizing.html index 5f41d3422..e357f9c58 100644 --- a/intro/sizing.html +++ b/intro/sizing.html @@ -633,8 +633,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/source.html b/intro/source.html index 2eb82507c..4856586a9 100644 --- a/intro/source.html +++ b/intro/source.html @@ -442,8 +442,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/subgraphs.html b/intro/subgraphs.html index 117f7e0eb..b088597ce 100644 --- a/intro/subgraphs.html +++ b/intro/subgraphs.html @@ -575,8 +575,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/subtrees.html b/intro/subtrees.html index 7f0d06bb9..400bd32e4 100644 --- a/intro/subtrees.html +++ b/intro/subtrees.html @@ -453,8 +453,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/svelte.html b/intro/svelte.html index d94fa8d7f..58a0ccf85 100644 --- a/intro/svelte.html +++ b/intro/svelte.html @@ -392,8 +392,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/tablePanels.html b/intro/tablePanels.html index 70e93d583..2d4d6df2e 100644 --- a/intro/tablePanels.html +++ b/intro/tablePanels.html @@ -874,8 +874,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/templateMaps.html b/intro/templateMaps.html index a7eec5da9..433d143ae 100644 --- a/intro/templateMaps.html +++ b/intro/templateMaps.html @@ -801,8 +801,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/testing.html b/intro/testing.html index 32ecf701a..cf525f450 100644 --- a/intro/testing.html +++ b/intro/testing.html @@ -495,8 +495,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/textBlocks.html b/intro/textBlocks.html index 0a51c9981..82899cbf6 100644 --- a/intro/textBlocks.html +++ b/intro/textBlocks.html @@ -696,8 +696,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/theming.html b/intro/theming.html index 14c8b73d9..81f51edef 100644 --- a/intro/theming.html +++ b/intro/theming.html @@ -807,8 +807,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/tools.html b/intro/tools.html index a6591265d..175c17e6e 100644 --- a/intro/tools.html +++ b/intro/tools.html @@ -1265,8 +1265,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/tooltips.html b/intro/tooltips.html index 5163c34ed..be6d7406c 100644 --- a/intro/tooltips.html +++ b/intro/tooltips.html @@ -478,8 +478,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/transactions.html b/intro/transactions.html index cca597e4e..a182c13fd 100644 --- a/intro/transactions.html +++ b/intro/transactions.html @@ -695,8 +695,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/trees.html b/intro/trees.html index 0b2acdd01..b313c4bf4 100644 --- a/intro/trees.html +++ b/intro/trees.html @@ -590,8 +590,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/typings.html b/intro/typings.html index 4d7baf95d..062adcf6c 100644 --- a/intro/typings.html +++ b/intro/typings.html @@ -424,8 +424,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/usingModels.html b/intro/usingModels.html index 1c54fbf6d..5d502646a 100644 --- a/intro/usingModels.html +++ b/intro/usingModels.html @@ -866,8 +866,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/validation.html b/intro/validation.html index 20adb0e78..82396fa44 100644 --- a/intro/validation.html +++ b/intro/validation.html @@ -952,8 +952,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/intro/viewport.html b/intro/viewport.html index 9aeeb6551..70b707e9b 100644 --- a/intro/viewport.html +++ b/intro/viewport.html @@ -1221,8 +1221,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/learn/graphobject.html b/learn/graphobject.html index 660b620a3..407e06a69 100644 --- a/learn/graphobject.html +++ b/learn/graphobject.html @@ -634,8 +634,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/learn/index.html b/learn/index.html index 6a64b69d6..621b8e9b4 100644 --- a/learn/index.html +++ b/learn/index.html @@ -928,8 +928,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/learn/interactivity.html b/learn/interactivity.html index 4b81c3c3c..43cb12d04 100644 --- a/learn/interactivity.html +++ b/learn/interactivity.html @@ -794,8 +794,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/learn/video-tutorial-intro.html b/learn/video-tutorial-intro.html index 5f9834721..5f5f942eb 100644 --- a/learn/video-tutorial-intro.html +++ b/learn/video-tutorial-intro.html @@ -357,8 +357,15 @@

              Company

              let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + diff --git a/package.json b/package.json index 1baec85c9..9c659515e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gojs", - "version": "3.0.11", + "version": "3.0.12", "description": "Interactive diagrams, charts, and graphs, such as trees, flowcharts, orgcharts, UML, BPMN, or business diagrams", "keywords": [ "GoJS", "diagram", "chart", "tree", "flowchart", "orgchart", "uml", "bpmn", "graph", "editor", "drawing", "canvas", "svg", "hierarchy", "family-tree", "decision-tree", "mindmap", "treeview", "genogram", "ivr-tree", "parse-tree", "concept-map", "visualization", "entity-relationship", "er-diagram", "radial", "sankey", "pert", "gantt", "timeline", "swimlane", "workflow", "flow", "process", "state", "sequential-function", "grafcet", "sequence", "circuit", "dataflow", "data-flow", "planogram", "floorplan", "seating", "pipes", "layout", "tree-layout", "force-directed", "layered", "hierarchical", "circular", "fishbone", "ishikawa", "treemap", "tree-map", "subgraph", "network", "library", "typescript" ], "homepage": "https://gojs.net", diff --git a/release/go-debug-module.js b/release/go-debug-module.js index 37a7e5a7a..614e1a749 100644 --- a/release/go-debug-module.js +++ b/release/go-debug-module.js @@ -1,62 +1,62 @@ /* - * GoJS v3.0.11 JavaScript Library for HTML Diagrams, https://gojs.net + * GoJS v3.0.12 JavaScript Library for HTML Diagrams, https://gojs.net * GoJS and Northwoods Software are registered trademarks of Northwoods Software Corporation, https://nwoods.com. * Copyright (C) 1998-2024 by Northwoods Software Corporation. All Rights Reserved. - * THIS SOFTWARE IS LICENSED. THE LICENSE AGREEMENT IS AT: https://gojs.net/3.0.11/license.html. + * THIS SOFTWARE IS LICENSED. THE LICENSE AGREEMENT IS AT: https://gojs.net/3.0.12/license.html. * DO NOT MODIFY THIS FILE. DO NOT DISTRIBUTE A MODIFIED COPY OF THE CONTENTS OF THIS FILE. */ -(function() {const root=typeof globalThis=="object"&&globalThis||typeof global=="object"&&global.global===global&&global||typeof self=="object"&&self.self===self&&self||{};root.requestAnimationFrame===void 0&&(root.setImmediate===void 0?root.requestAnimationFrame=w=>root.setTimeout(w,0):root.requestAnimationFrame=root.setImmediate);const Debug={boundsInfoEnabled:!1,drawLocationsEnabled:!1,drawClipEnabled:!1,drawLinkpointsEnabled:!1,nodeInspector:!1,handleMessages:!1,drawFrames:!1,defaultDiagram:null,trace:function(w){root.console&&root.console.log(w)},drawDiagramBounds(w,t,i,e){w.strokeStyle="red",w.fillStyle="red",w.font="8px sans-serif",w.beginPath(),w.moveTo(-10,0),w.lineTo(10,0),w.moveTo(0,-10),w.lineTo(0,10),w.stroke(),w.setTransform(1,0,0,1,0,0),w.scale(i,i),w.transform(t.m11,t.m12,t.m21,t.m22,t.dx,t.dy),w.lineWidth=2,w.beginPath(),w.moveTo(e.left,e.top+20),w.lineTo(e.left,e.top),w.lineTo(e.left+20,e.top),w.moveTo(e.right,e.bottom-20),w.lineTo(e.right,e.bottom),w.lineTo(e.right-20,e.bottom),w.stroke(),w.fillText("DB: "+Math.round(e.x)+", "+Math.round(e.y)+", "+Math.round(e.width)+", "+Math.round(e.height),e.left,e.top-5)},attachReadonlyWarnings:function(w){for(const t in w){if(t==="licenseKey")continue;const i=w[t];if(i.prototype===void 0)continue;const e=Object.getOwnPropertyNames(i.prototype);for(let s=0;s{s=-1,e||t.apply(n,o)},i),e&&!s&&t.apply(n,o)}}static Bh(t,i){return root.setTimeout(t,i)}static Ug(t){root.clearTimeout(t)}static ln(t){return root.document.createElement(t)}static n(t){throw new Error(t)}static F(t,i){let e="The object is frozen, so its properties cannot be set: "+t.toString();i!==void 0&&(e+=" to value: "+i),Util.n(e)}static s(t,i,e,s){if(!(t instanceof i)){let n=Util.au(e);s!==void 0&&(n+="."+s),Util.Vi(t,i,n)}}static t(t,i,e,s){if(typeof t!==i){let n=Util.au(e);s!==void 0&&(n+="."+s),Util.Vi(t,i,n)}}static r(t,i,e){if(typeof t!="number"||!isFinite(t)){let s=Util.au(i);e!==void 0&&(s+="."+e),Util.n(s+" must be a real number type, and not NaN or Infinity: "+t)}}static tt(t,i,e){t in i||Util.n(`${t} is not a valid value in enumeration: ${e}`)}static Vi(t,i,e,s){const n=" value is not an instance of "+Util.au(i)+": ";let o=Util.au(e);s!==void 0&&(o+="."+s),typeof t=="string"&&(t='"'+t+'"'),Util.n(o+n+t)}static G(t,i,e,s){let n=Util.au(e);s!==void 0&&(n+="."+s),Util.n(n+" is not in the range "+i+": "+t)}static ze(t){Util.n("Collection was modified during iteration: "+t.toString()+` +(function() {const root=typeof globalThis=="object"&&globalThis||typeof global=="object"&&global.global===global&&global||typeof self=="object"&&self.self===self&&self||{};root.requestAnimationFrame===void 0&&(root.setImmediate===void 0?root.requestAnimationFrame=w=>root.setTimeout(w,0):root.requestAnimationFrame=root.setImmediate);const Debug={boundsInfoEnabled:!1,drawLocationsEnabled:!1,drawClipEnabled:!1,drawLinkpointsEnabled:!1,nodeInspector:!1,handleMessages:!1,drawFrames:!1,defaultDiagram:null,trace:function(w){root.console&&root.console.log(w)},drawDiagramBounds(w,t,i,e){w.strokeStyle="red",w.fillStyle="red",w.font="8px sans-serif",w.beginPath(),w.moveTo(-10,0),w.lineTo(10,0),w.moveTo(0,-10),w.lineTo(0,10),w.stroke(),w.setTransform(1,0,0,1,0,0),w.scale(i,i),w.transform(t.m11,t.m12,t.m21,t.m22,t.dx,t.dy),w.lineWidth=2,w.beginPath(),w.moveTo(e.left,e.top+20),w.lineTo(e.left,e.top),w.lineTo(e.left+20,e.top),w.moveTo(e.right,e.bottom-20),w.lineTo(e.right,e.bottom),w.lineTo(e.right-20,e.bottom),w.stroke(),w.fillText("DB: "+Math.round(e.x)+", "+Math.round(e.y)+", "+Math.round(e.width)+", "+Math.round(e.height),e.left,e.top-5)},attachReadonlyWarnings:function(w){for(const t in w){if(t==="licenseKey")continue;const i=w[t];if(i.prototype===void 0)continue;const e=Object.getOwnPropertyNames(i.prototype);for(let s=0;s{s=-1,e||t.apply(n,o)},i),e&&!s&&t.apply(n,o)}}static zh(t,i){return root.setTimeout(t,i)}static Kg(t){root.clearTimeout(t)}static ln(t){return root.document.createElement(t)}static n(t){throw new Error(t)}static F(t,i){let e="The object is frozen, so its properties cannot be set: "+t.toString();i!==void 0&&(e+=" to value: "+i),Util.n(e)}static s(t,i,e,s){if(!(t instanceof i)){let n=Util.hu(e);s!==void 0&&(n+="."+s),Util.Bi(t,i,n)}}static t(t,i,e,s){if(typeof t!==i){let n=Util.hu(e);s!==void 0&&(n+="."+s),Util.Bi(t,i,n)}}static r(t,i,e){if(typeof t!="number"||!isFinite(t)){let s=Util.hu(i);e!==void 0&&(s+="."+e),Util.n(s+" must be a real number type, and not NaN or Infinity: "+t)}}static tt(t,i,e){t in i||Util.n(`${t} is not a valid value in enumeration: ${e}`)}static Bi(t,i,e,s){const n=" value is not an instance of "+Util.hu(i)+": ";let o=Util.hu(e);s!==void 0&&(o+="."+s),typeof t=="string"&&(t='"'+t+'"'),Util.n(o+n+t)}static G(t,i,e,s){let n=Util.hu(e);s!==void 0&&(n+="."+s),Util.n(n+" is not in the range "+i+": "+t)}static ze(t){Util.n("Collection was modified during iteration: "+t.toString()+` Perhaps you should iterate over a copy of the collection, - or you could collect items to be removed from the collection after the iteration.`)}static ur(t,i){Util.n("No property to set for this enum value: "+i+" on "+t.toString())}static at(t){root.console&&root.console.log(t)}static Mt(t){return typeof t=="object"&&t!==null}static Gg(t,i,e){Array.isArray(t)||Util.Vi(t,"Array",i,e)}static fu(t,i,e){Array.isArray(t)?i>=t.length?t.push(e):t.splice(i,0,e):Util.n("Cannot insert an object into an HTMLCollection or NodeList: "+e+" at "+i)}static rf(t,i){Array.isArray(t)?i>=t.length?t.pop():t.splice(i,1):Util.n("Cannot remove an object from an HTMLCollection or NodeList at "+i)}static Ok=[];static ft(){const t=Util.Ok.pop();return t===void 0?[]:t}static nt(t){t.length=0,Util.Ok.push(t)}static eE=Object.freeze([]);static au(t){return t===null?"*":typeof t=="string"?t:typeof t=="function"?t.name:""}static hn(t){return typeof t=="function"?t.className?t.className:t.name:Util.Mt(t)&&t.constructor?Util.hn(t.constructor):typeof t}static zh(t,i){return i==null||i===""?null:Util.Mt(t)&&i in t||t[i]?t[i]:null}static toString(t){let i=t;return Util.Mt(t)&&(t.text?i=t.text:t.name?i=t.name:t.key!==void 0?i=t.key:t.id!==void 0?i=t.id:t.constructor===Object&&(t.Text?i=t.Text:t.Name?i=t.Name:t.Key!==void 0?i=t.Key:t.Id!==void 0?i=t.Id:t.ID!==void 0&&(i=t.ID))),i===void 0?"undefined":i===null?"null":i.toString()}static yw(t,i){if(t.hasOwnProperty(i))return!0;let e=Object.getPrototypeOf(t);for(;e&&e!==Function;){if(e.hasOwnProperty(i))return!0;const s=e.sE;if(s&&s[i])return!0;e=Object.getPrototypeOf(e)}return!1}static ED(t){const i=[];let e=0;for(e=0;e<256;e++)i[e]=e;let s=0,n=0;for(e=0;e<256;e++)s=(s+i[e]+119)%256,n=i[e],i[e]=i[s],i[s]=n;e=0,s=0;let o="";for(let r=0;r>4)+i.charAt(r&15)]=String.fromCharCode(r);t.length%2&&(t="0"+t);const s=[];let n=0;for(let r=0;r0){const n=i[0];return this.key=0,this.value=n,n}else return null}any(t){const i=this.Qt;i.dr=null;const e=i.gt;this.Vt=-1;const s=i.h,n=s.length,o=this.Rs;for(let r=0;r=0?(this.key=i,this.value=t.h[i],!0):(this.wl(),!1)}hasNext(){return this.next()}first(){const t=this.Qt;this.vt=t.gt;const i=t.h,e=i.length-1;if(this.Vt=e,e>=0){const s=i[e];return this.key=e,this.value=s,s}else return null}any(t){const i=this.Qt;i.gr=null;const e=i.gt,s=i.h,n=s.length;this.Vt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(t(r))return!0;i.gt!==e&&Util.ze(i)}return!1}all(t){const i=this.Qt;i.gr=null;const e=i.gt,s=i.h,n=s.length;this.Vt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(!t(r))return!1;i.gt!==e&&Util.ze(i)}return!0}each(t){const i=this.Qt;i.gr=null;const e=i.gt,s=i.h,n=s.length;this.Vt=n;for(let o=n-1;o>=0;o--){const r=s[o];t(r),i.gt!==e&&Util.ze(i)}return this}map(t){const i=this.Qt;i.gr=null;const e=i.gt,s=[],n=i.h,o=n.length;this.Vt=o;for(let l=o-1;l>=0;l--){const h=n[l];s.push(t(h)),i.gt!==e&&Util.ze(i)}const r=new List;return r.h=s,r.Xe(),r.iterator}filter(t){const i=this.Qt;i.gr=null;const e=i.gt,s=[],n=i.h,o=n.length;this.Vt=o;for(let l=o-1;l>=0;l--){const h=n[l];t(h)&&s.push(h),i.gt!==e&&Util.ze(i)}const r=new List;return r.h=s,r.Xe(),r.iterator}get count(){return this.Qt.h.length}wl(){this.key=-1,this.value=null,this.vt=-1,this.Qt.gr=this}toString(){return"ListIteratorBackwards("+this.Vt+"/"+this.Qt.count+")"}}class List{f;h;gt;dr;gr;constructor(t){GSet.vi(this),this.f=!1,this.h=[],this.gt=0,this.dr=null,this.gr=null,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.h.values()}Xe(){let t=this.gt;t++,t>999999999&&(t=0),this.gt=t}w(){return this.f=!0,this}ct(){return this.f=!1,this}toString(){return"List()#"+GSet.gs(this)}add(t){return this.f&&Util.F(this,t),this.h.push(t),this.Xe(),this}push(t){this.add(t)}addAll(t){if(t===null)return this;this.f&&Util.F(this);const i=this.h;if(Array.isArray(t)){const e=t.length;for(let s=0;s=i.length)&&Util.G(t,"0 <= i < length",List,"elt:i"),i[t]}get(t){return this.elt(t)}setElt(t,i){Debug&&Util.r(t,List,"setElt:i");const e=this.h;(t<0||t>=e.length)&&Util.G(t,"0 <= i < length",List,"setElt:i"),this.f&&Util.F(this,t),e[t]=i}set(t,i){this.setElt(t,i)}first(){const t=this.h;return t.length===0?null:t[0]}last(){const t=this.h,i=t.length;return i>0?t[i-1]:null}pop(){this.f&&Util.F(this);const t=this.h;return t.length>0?t.pop():null}any(t){const i=this.h,e=this.gt,s=i.length;for(let n=0;n= 0",List,"insertAt:i"),this.f&&Util.F(this,t);const e=this.h;t>=e.length?e.push(i):e.splice(t,0,i),this.Xe()}remove(t){return this.delete(t)}delete(t){if(t===null)return!1;this.f&&Util.F(this,t);const i=this.h,e=i.indexOf(t);return e===-1?!1:(e===i.length-1?i.pop():i.splice(e,1),this.Xe(),!0)}removeAt(t){Debug&&Util.r(t,List,"removeAt:i");const i=this.h;(t<0||t>=i.length)&&Util.G(t,"0 <= i < length",List,"removeAt:i"),this.f&&Util.F(this,t),t===i.length-1?i.pop():i.splice(t,1),this.Xe()}removeRange(t,i){Debug&&(Util.r(t,List,"removeRange:from"),Util.r(i,List,"removeRange:to"));const e=this.h,s=e.length;if(t<0)t=0;else if(t>=s)return this;if(i<0)return this;if(i>=s&&(i=s-1),t>i)return this;this.f&&Util.F(this);let n=t,o=i+1;for(;o0&&(t.h=Array.prototype.slice.call(i)),t}toArray(){const t=this.h,i=this.count,e=new Array(i);for(let s=0;s=n-1)&&Util.G(i,"0 <= from < length",List,"sortRange:from"),o===2){const r=s[i],l=s[i+1];return t(r,l)>0&&(s[i]=l,s[i+1]=r,this.Xe()),this}if(i===0)if(e>=n)s.sort(t);else{const r=s.slice(0,e);r.sort(t);for(let l=0;l=n){const r=s.slice(i);r.sort(t);for(let l=i;li.add(t(e))),i.iterator}filter(t){const i=new List;return this.Ao.k.forEach(e=>{t(e)&&i.add(e)}),i.iterator}get count(){return this.Ao.count}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"SetIterator"}}class GSet{f;k;constructor(t){this.f=!1,this.k=new Set,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.k.values()}values(){return this.k.values()}w(){return this.f=!0,this}ct(){return this.f=!1,this}toString(){return"Set()#"+GSet.gs(this)}add(t){return t===null?this:(this.k.add(t),this)}addAll(t){if(t===null)return this;if(Array.isArray(t)){const i=t.length;for(let e=0;et.add(i)),t}toArray(){return Array.from(this.k)}toList(){const t=new List;return this.k.forEach(i=>t.add(i)),t}get count(){return this.k.size}get size(){return this.k.size}get iterator(){return this.k.size<=0?EmptyIterator.instance:new SetIterator(this)}entries(){return this.k.entries()}keys(){return this.k.keys()}forEach(t,i){return this.k.forEach(t,i)}static cu=1;static vi(t){t.__gohashid=GSet.cu++}static gs(t){return t.__gohashid}}class MapKeySetIterator{it;ri;constructor(t){this.it=t,this.ri=t.k.keys()}[Symbol.iterator](){return this.it.k.keys()}key;value;get iterator(){return this}reset(){const t=this.it;this.ri=t.k.keys()}next(){const t=this.ri.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.it.k.size===0?null:(this.ri=this.it.k.keys(),this.ri.next().value)}any(t){for(const i of this.it.k)if(t(i[0]))return!0;return!1}all(t){for(const i of this.it.k)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.it.k)t(i[0]);return this}map(t){const i=this.it,e=new List;for(const s of i.k)e.add(t(s[0]));return e.iterator}filter(t){const i=this.it,e=new List;for(const s of i.k){const n=s[0];t(n)&&e.add(n)}return e.iterator}get count(){return this.it.size}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"MapKeySetIterator"}}class MapKeySet extends GSet{it;constructor(t){super(),GSet.vi(this),this.f=!0,this.it=t}[Symbol.iterator](){return this.k.keys()}values(){return this.k.keys()}w(){return this}ct(){return this}toString(){return"MapKeySet("+this.it.toString()+")"}add(t){Util.n("This Set is read-only: "+this.toString())}has(t){return this.it.has(t)}contains(t){return this.has(t)}delete(t){Util.n("This Set is read-only: "+this.toString())}remove(t){return this.delete(t)}clear(){Util.n("This Set is read-only: "+this.toString())}first(){return this.it.k.size===0?null:this.it.k.keys().next().value}any(t){for(const i of this.it.k)if(t(i[0]))return!0;return!1}all(t){for(const i of this.it.k)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.it.k)t(i[0]);return this}map(t){const i=new GSet;for(const e of this.it.k)i.add(t(e[0]));return i}filter(t){const i=new GSet;for(const e of this.it.k){const s=e[0];t(s)&&i.add(s)}return i}copy(){return new MapKeySet(this.it)}toSet(){const t=new GSet,i=this.it.k;for(const e of i)t.add(e[0]);return t}toArray(){const t=this.it.k,i=new Array(t.size);let e=0;for(const s of t)i[e]=s[0],e++;return i}toList(){const t=new List,i=this.it.k;for(const e of i)t.add(e[0]);return t}get count(){return this.it.size}get size(){return this.it.size}get iterator(){return this.it.size<=0?EmptyIterator.instance:new MapKeySetIterator(this.it)}}class MapValueSetIterator{it;ri;constructor(t){this.it=t,this.ri=t.k.values()}[Symbol.iterator](){return this.it.k.values()}key;value;get iterator(){return this}reset(){const t=this.it;this.ri=t.k.values()}next(){const t=this.ri.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.it.k.size===0?null:(this.ri=this.it.k.values(),this.ri.next().value)}any(t){for(const i of this.it.k)if(t(i[1]))return!0;return!1}all(t){for(const i of this.it.k)if(!t(i[1]))return!1;return!0}each(t){for(const i of this.it.k)t(i[1]);return this}map(t){const i=this.it,e=new List;for(const s of i.k)e.add(t(s[1]));return e.iterator}filter(t){const i=this.it,e=new List;for(const s of i.k){const n=s[1];t(n)&&e.add(n)}return e.iterator}get count(){return this.it.size}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"MapValueSetIterator"}}class KeyValuePair{constructor(t,i){this.key=t,this.value=i}toString(){return"{"+this.key+":"+this.value+"}"}key;value}class MapIterator{it;ri;constructor(t){this.it=t,this.ri=t.k.entries()}[Symbol.iterator](){return this.it.k.entries()}key;value;get iterator(){return this}reset(){const t=this.it;this.ri=t.k.entries()}next(){const t=this.ri.next();return t.done?(this.key=null,this.value=null,!1):(this.key=t.value[0],this.value=t.value[1],!0)}hasNext(){return this.next()}first(){if(this.it.k.size===0)return null;this.ri=this.it.k.entries();const t=this.ri.next().value;return this.key=t[0],this.value=t[1],new KeyValuePair(t[0],t[1])}any(t){return this.it.any(t)}all(t){return this.it.all(t)}each(t){return this.it.each(t),this}map(t){const i=new List;let e=null;return this.it.k.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),i.add(t(e))}),i.iterator}filter(t){const i=new List;let e=null;return this.it.k.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),t(e)&&(i.add(e),e=null)}),i.iterator}get count(){return this.it.size}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"MapIterator"}}class GMap{f;k;constructor(t){GSet.vi(this),this.f=!1,this.k=new Map,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.k.entries()}entries(){return this.k.entries()}w(){return this.f=!0,this}ct(){return this.f=!1,this}toString(){return"Map()#"+GSet.gs(this)}set(t,i){return this.f&&Util.F(this,t),this.k.set(t,i),this}add(t,i){return this.set(t,i)}addAll(t){if(t===null)return this;if(this.f&&Util.F(this),Array.isArray(t)){const i=t.length;for(let e=0;ei.x.toFixed(t)+" "+i.y.toFixed(t)}toString(){return"Point("+this.x+","+this.y+")"}equals(t){return t instanceof Point?this.S===t.x&&this.P===t.y:!1}equalTo(t,i){return this.S===t&&this.P===i}equalsApprox(t){return Geo.p(this.S,t.x)&&Geo.p(this.P,t.y)}add(t){return Debug&&(Util.s(t,Point,Point,"add:p"),this.et()),this.S+=t.x,this.P+=t.y,this}subtract(t){return Debug&&(Util.s(t,Point,Point,"subtract:p"),this.et()),this.S-=t.x,this.P-=t.y,this}offset(t,i){return Debug&&(Util.r(t,Point,"offset:dx"),Util.r(i,Point,"offset:dy"),this.et()),this.S+=t,this.P+=i,this}rotate(t){if(Debug&&(Util.r(t,Point,"rotate:angle"),this.et()),t===0)return this;const i=this.S,e=this.P;if(i===0&&e===0)return this;let s=0,n=0;if(t>=360?t-=360:t<0&&(t+=360),t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const o=t*Math.PI/180;s=Math.cos(o),n=Math.sin(o)}return this.S=s*i-n*e,this.P=n*i+s*e,this}scale(t,i){return Debug&&(Util.r(t,Point,"scale:sx"),Util.r(i,Point,"scale:sy"),this.et()),this.S*=t,this.P*=i,this}distanceSquaredPoint(t){Debug&&Util.s(t,Point,Point,"distanceSquaredPoint:p");const i=t.x-this.S,e=t.y-this.P;return i*i+e*e}distanceSquared(t,i){Debug&&(Util.r(t,Point,"distanceSquared:px"),Util.r(i,Point,"distanceSquared:py"));const e=t-this.S,s=i-this.P;return e*e+s*s}normalize(){Debug&&this.et();const t=this.S,i=this.P,e=Math.sqrt(t*t+i*i);return e>0&&(this.S=t/e,this.P=i/e),this}directionPoint(t){return Debug&&Util.s(t,Point,Point,"directionPoint:p"),this.oC(t.x-this.S,t.y-this.P)}direction(t,i){return Debug&&(Util.r(t,Point,"direction:px"),Util.r(i,Point,"direction:py")),this.oC(t-this.S,i-this.P)}oC(t,i){if(t===0)return i>0?90:i<0?270:0;if(i===0)return t>0?0:180;{if(isNaN(t)||isNaN(i))return 0;let e=Math.atan(Math.abs(i/t))*180/Math.PI;return t<0?i<0?e+=180:e=180-e:i<0&&(e=360-e),e}}static compareWithLineSegment(t,i,e,s,n,o){return Debug&&(Util.r(t,Point,"compareWithLineSegment:a1x"),Util.r(i,Point,"compareWithLineSegment:a1y"),Util.r(e,Point,"compareWithLineSegment:a2x"),Util.r(s,Point,"compareWithLineSegment:a2y"),Util.r(n,Point,"compareWithLineSegment:b1x"),Util.r(o,Point,"compareWithLineSegment:b1y")),Geo.uu(t,i,e,s,n,o)}compareWithLineSegmentPoint(t,i){return Debug&&(Util.s(t,Point,Point,"compareWithLineSegmentPoint:p"),Util.s(i,Point,Point,"compareWithLineSegmentPoint:q")),Geo.uu(t.x,t.y,i.x,i.y,this.x,this.y)}static intersectingLineSegments(t,i,e,s,n,o,r,l){return Debug&&(Util.r(t,Point,"intersectingLineSegments:a1x"),Util.r(i,Point,"intersectingLineSegments:a1y"),Util.r(e,Point,"intersectingLineSegments:a2x"),Util.r(s,Point,"intersectingLineSegments:a2y"),Util.r(n,Point,"intersectingLineSegments:b1x"),Util.r(o,Point,"intersectingLineSegments:b1y"),Util.r(r,Point,"intersectingLineSegments:b2x"),Util.r(l,Point,"intersectingLineSegments:b2y")),Geo.du(t,i,e,s,n,o,r,l)}projectOntoLineSegment(t,i,e,s){return Debug&&(Util.r(t,Point,"projectOntoLineSegment:px"),Util.r(i,Point,"projectOntoLineSegment:py"),Util.r(e,Point,"projectOntoLineSegment:qx"),Util.r(s,Point,"projectOntoLineSegment:qy")),Geo.xl(t,i,e,s,this.S,this.P,this),this}projectOntoLineSegmentPoint(t,i){return Debug&&(Util.s(t,Point,Point,"projectOntoLineSegmentPoint:p"),Util.s(i,Point,Point,"projectOntoLineSegmentPoint:q")),Geo.xl(t.x,t.y,i.x,i.y,this.S,this.P,this),this}snapToGrid(t,i,e,s){return Debug&&(Util.r(t,Point,"snapToGrid:originx"),Util.r(i,Point,"snapToGrid:originy"),Util.r(e,Point,"snapToGrid:cellwidth"),Util.r(s,Point,"snapToGrid:cellheight")),Geo.Hg(this.S,this.P,t,i,e,s,this),this}snapToGridPoint(t,i){return Debug&&(Util.s(t,Point,Point,"snapToGridPoint:p"),Util.s(i,Size,Point,"snapToGridPoint:q")),Geo.Hg(this.S,this.P,t.x,t.y,i.width,i.height,this),this}setRectSpot(t,i){return Debug&&(Util.s(t,Rect,Point,"setRectSpot:r"),Util.s(i,Spot,Point,"setRectSpot:spot"),this.et()),this.S=t.x+i.x*t.width+i.offsetX,this.P=t.y+i.y*t.height+i.offsetY,this}setSpot(t,i,e,s,n){return Debug&&(Util.r(t,Point,"setSpot:x"),Util.r(i,Point,"setSpot:y"),Util.r(e,Point,"setSpot:w"),Util.r(s,Point,"setSpot:h"),(e<0||s<0)&&Util.n("Point.setSpot:Width and height cannot be negative"),Util.s(n,Spot,Point,"setSpot:spot"),this.et()),this.S=t+n.x*e+n.offsetX,this.P=i+n.y*s+n.offsetY,this}O(t){return t.Pt(this),this}Ye(t){return t.ns(this),this}static distanceLineSegmentSquared(t,i,e,s,n,o){Debug&&(Util.r(t,Point,"distanceLineSegmentSquared:px"),Util.r(i,Point,"distanceLineSegmentSquared:py"),Util.r(e,Point,"distanceLineSegmentSquared:ax"),Util.r(s,Point,"distanceLineSegmentSquared:ay"),Util.r(n,Point,"distanceLineSegmentSquared:bx"),Util.r(o,Point,"distanceLineSegmentSquared:by"));let r=n-e,l=o-s;const h=r*r+l*l,a=e-t,f=s-i,c=-a*r-f*l;if(c<=0||c>=h)return r=n-t,l=o-i,Math.min(a*a+f*f,r*r+l*l);{const u=r*f-l*a;return u*u/h}}static distanceSquared(t,i,e,s){Debug&&(Util.r(t,Point,"distanceSquared:px"),Util.r(i,Point,"distanceSquared:py"),Util.r(e,Point,"distanceSquared:qx"),Util.r(s,Point,"distanceSquared:qy"));const n=e-t,o=s-i;return n*n+o*o}static direction(t,i,e,s){Debug&&(Util.r(t,Point,"direction:px"),Util.r(i,Point,"direction:py"),Util.r(e,Point,"direction:qx"),Util.r(s,Point,"direction:qy"));const n=e-t,o=s-i;if(n===0)return o>0?90:o<0?270:0;if(o===0)return n>0?0:180;{if(isNaN(n)||isNaN(o))return 0;let r=Math.atan(Math.abs(o/n))*180/Math.PI;return n<0?o<0?r+=180:r=180-r:o<0&&(r=360-r),r}}get x(){return this.S}set x(t){Debug&&(Util.t(t,"number",Point,"x"),this.et(t)),this.S=t}get y(){return this.P}set y(t){Debug&&(Util.t(t,"number",Point,"y"),this.et(t)),this.P=t}isReal(){return isFinite(this.x)&&isFinite(this.y)}static Lo=new Point(0,0).ot();static rC=new Point(-1/0,-1/0).ot();static lC=new Point(1/0,1/0).ot();static hC=new Point(6,6).ot();static Vk=new Point(NaN,NaN).ot();static Bk=[];static a(){const t=Point.Bk.pop();return t===void 0?new Point:t}static H(t,i){const e=Point.Bk.pop();return e===void 0?new Point(t,i):(e.x=t,e.y=i,e)}static o(t){Point.Bk.push(t)}}class Size{v;J;f;constructor(t,i){t===void 0?(this.v=0,this.J=0):typeof t=="number"&&(t>=0||isNaN(t))&&typeof i=="number"&&(i>=0||isNaN(i))?(this.v=t,this.J=i):Util.n("Invalid arguments to Size constructor: "+t+", "+i),this.f=!1}c(t){return this.v=t.v,this.J=t.J,this}e(t,i){return this.v=t,this.J=i,this}setTo(t,i){return Debug&&(Util.t(t,"number",Size,"setTo:w"),Util.t(i,"number",Size,"setTo:h"),t<0&&Util.G(t,">= 0",Size,"setTo:w"),i<0&&Util.G(i,">= 0",Size,"setTo:h"),this.et()),this.v=t,this.J=i,this}set(t){return Debug&&(Util.s(t,Size,Size,"set:s"),this.et()),this.v=t.v,this.J=t.J,this}copy(){const t=new Size;return t.v=this.v,t.J=this.J,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ct(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}et(t){if(Debug&&this.f){let i="The Size is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;return n=i[e++],n&&(o=parseFloat(n)),new Size(s,o)}else return new Size}static stringify(t){return Debug&&Util.s(t,Size),t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.t(t,"number",Size,"stringifyFixed:digits"),i=>i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Size("+this.width+","+this.height+")"}equals(t){return t instanceof Size?this.v===t.width&&this.J===t.height:!1}equalTo(t,i){return this.v===t&&this.J===i}equalsApprox(t){return Geo.p(this.v,t.width)&&Geo.p(this.J,t.height)}inflate(t,i){Debug&&(Util.r(t,Size,"inflate:w"),Util.r(i,Size,"inflate:h"));const e=this.width+t;this.v=e>=0?e:0;const s=this.height+i;return this.J=s>=0?s:0,this}get width(){return this.v}set width(t){Debug&&(Util.t(t,"number",Size,"width"),this.et(t)),t<0&&Util.G(t,">= 0",Size,"width"),this.v=t}get height(){return this.J}set height(t){Debug&&(Util.t(t,"number",Size,"height"),this.et(t)),t<0&&Util.G(t,">= 0",Size,"height"),this.J=t}isReal(){return isFinite(this.width)&&isFinite(this.height)}static lf=new Size(0,0).ot();static zk=new Size(1,1).ot();static aC=new Size(6,6).ot();static gu=new Size(8,8).ot();static fC=new Size(10,10).ot();static Xk=new Size(1/0,1/0).ot();static xw=new Size(NaN,NaN).ot();static cC=[];static a(){const t=Size.cC.pop();return t===void 0?new Size:t}static o(t){Size.cC.push(t)}}class Rect{S;P;v;J;f;constructor(t,i,e,s){if(t===void 0)this.S=0,this.P=0,this.v=0,this.J=0;else if(typeof t=="number"&&typeof i=="number"&&typeof e=="number"&&(e>=0||isNaN(e))&&typeof s=="number"&&(s>=0||isNaN(s)))this.S=t,this.P=i,this.v=e,this.J=s;else if(t instanceof Point){const n=t.x,o=t.y;if(i instanceof Point){const r=i.x,l=i.y;this.S=Math.min(n,r),this.P=Math.min(o,l),this.v=Math.abs(n-r),this.J=Math.abs(o-l)}else i instanceof Size?(this.S=n,this.P=o,this.v=i.width,this.J=i.height):Util.n("Incorrect second argument supplied to Rect constructor "+i)}else Util.n("Invalid arguments to Rect constructor: "+t+", "+i+", "+e+", "+s);this.f=!1}c(t){return this.S=t.S,this.P=t.P,this.v=t.v,this.J=t.J,this}e(t,i,e,s){return this.S=t,this.P=i,this.v=e,this.J=s,this}Kn(t,i){return this.v=t,this.J=i,this}setTo(t,i,e,s){return Debug&&(Util.t(t,"number",Rect,"setTo:x"),Util.t(i,"number",Rect,"setTo:y"),Util.t(e,"number",Rect,"setTo:w"),Util.t(s,"number",Rect,"setTo:h"),e<0&&Util.G(e,">= 0",Rect,"setTo:w"),s<0&&Util.G(s,">= 0",Rect,"setTo:h"),this.et()),this.S=t,this.P=i,this.v=e,this.J=s,this}set(t){return Debug&&(Util.s(t,Rect,Rect,"set:r"),this.et()),this.S=t.S,this.P=t.P,this.v=t.v,this.J=t.J,this}setPoint(t){return Debug&&(Util.s(t,Point,Rect,"setPoint:p"),this.et()),this.S=t.x,this.P=t.y,this}setSize(t){return Debug&&(Util.s(t,Size,Rect,"setSize:s"),this.et()),this.v=t.width,this.J=t.height,this}copy(){const t=new Rect;return t.S=this.S,t.P=this.P,t.v=this.v,t.J=this.J,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ct(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}et(t){if(Debug&&this.f){let i="The Rect is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),new Rect(s,o,r,l)}else return new Rect}static stringify(t){return Debug&&Util.s(t,Rect),t.x.toString()+" "+t.y.toString()+" "+t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.t(t,"number",Rect,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Rect("+this.x+","+this.y+","+this.width+","+this.height+")"}equals(t){return t instanceof Rect?this.S===t.x&&this.P===t.y&&this.v===t.width&&this.J===t.height:!1}equalTo(t,i,e,s){return this.S===t&&this.P===i&&this.v===e&&this.J===s}equalsApprox(t){return Geo.p(this.S,t.x)&&Geo.p(this.P,t.y)&&Geo.p(this.v,t.width)&&Geo.p(this.J,t.height)}equalsApproxTo(t,i,e,s){return Geo.p(this.S,t)&&Geo.p(this.P,i)&&Geo.p(this.v,e)&&Geo.p(this.J,s)}equalsApproxClose(t){return Geo.q(this.S,t.x)&&Geo.q(this.P,t.y)&&Geo.q(this.v,t.width)&&Geo.q(this.J,t.height)}containsPoint(t){return Debug&&Util.s(t,Point,Rect,"containsPoint:p"),this.S<=t.x&&this.S+this.v>=t.x&&this.P<=t.y&&this.P+this.J>=t.y}containsRect(t){return Debug&&Util.s(t,Rect,Rect,"containsRect:r"),this.S<=t.x&&t.x+t.width<=this.S+this.v&&this.P<=t.y&&t.y+t.height<=this.P+this.J}contains(t,i,e,s){return Debug?(Util.r(t,Rect,"contains:x"),Util.r(i,Rect,"contains:y"),e===void 0?e=0:Util.r(e,Rect,"contains:w"),s===void 0?s=0:Util.r(s,Rect,"contains:h"),(e<0||s<0)&&Util.n("Rect.contains:Width and height cannot be negative")):(e===void 0&&(e=0),s===void 0&&(s=0)),this.S<=t&&t+e<=this.S+this.v&&this.P<=i&&i+s<=this.P+this.J}offset(t,i){return Debug&&(Util.r(t,Rect,"offset:dx"),Util.r(i,Rect,"offset:dy"),this.et()),this.S+=t,this.P+=i,this}inflate(t,i){return Debug&&(Util.r(t,Rect,"inflate:w"),Util.r(i,Rect,"inflate:h")),this.bw(i,t,i,t)}addMargin(t){return Debug&&Util.s(t,Margin,Rect,"addMargin:m"),this.bw(t.top,t.right,t.bottom,t.left)}subtractMargin(t){return Debug&&Util.s(t,Margin,Rect,"subtractMargin:m"),this.bw(-t.top,-t.right,-t.bottom,-t.left)}grow(t,i,e,s){return Debug&&(Util.r(t,Rect,"grow:t"),Util.r(i,Rect,"grow:r"),Util.r(e,Rect,"grow:b"),Util.r(s,Rect,"grow:l")),this.bw(t,i,e,s)}bw(t,i,e,s){Debug&&this.et();const n=this.v;i+s<=-n?(this.S+=n/2,this.v=0):(this.S-=s,this.v+=i+s);const o=this.J;return t+e<=-o?(this.P+=o/2,this.J=0):(this.P-=t,this.J+=t+e),this}intersectRect(t){return Debug&&Util.s(t,Rect,Rect,"intersectRect:r"),this.uC(t.x,t.y,t.width,t.height)}intersect(t,i,e,s){return Debug&&(Util.r(t,Rect,"intersect:x"),Util.r(i,Rect,"intersect:y"),Util.r(e,Rect,"intersect:w"),Util.r(s,Rect,"intersect:h"),(e<0||s<0)&&Util.n("Rect.intersect:Width and height cannot be negative")),this.uC(t,i,e,s)}uC(t,i,e,s){Debug&&this.et();const n=Math.max(this.S,t),o=Math.max(this.P,i),r=Math.min(this.S+this.v,t+e),l=Math.min(this.P+this.J,i+s);return this.S=n,this.P=o,this.v=Math.max(0,r-n),this.J=Math.max(0,l-o),this}intersectsRect(t){return Debug&&Util.s(t,Rect,Rect,"intersectsRect:r"),this.intersects(t.x,t.y,t.width,t.height)}intersects(t,i,e,s){Debug&&(Util.r(t,Rect,"intersects:x"),Util.r(i,Rect,"intersects:y"),Util.r(t,Rect,"intersects:w"),Util.r(i,Rect,"intersects:h"),(e<0||s<0)&&Util.n("Rect.intersects:Width and height cannot be negative"));let n=this.v;const o=this.S;if(n!==1/0&&e!==1/0&&(n+=o,e+=t,isNaN(e)||isNaN(n)||o>e||t>n))return!1;let r=this.J;const l=this.P;return!(r!==1/0&&s!==1/0&&(r+=l,s+=i,isNaN(s)||isNaN(r)||l>s||i>r))}intersectsRectPlus(t,i){let e=this.v,s=t.width+i+i;const n=this.S,o=t.x-i;if(e+=n,s+=o,n>s||o>e)return!1;let r=this.J,l=t.height+i+i;const h=this.P,a=t.y-i;return r+=h,l+=a,!(h>l||a>r)}unionPoint(t){return Debug&&Util.s(t,Point,Rect,"unionPoint:p"),this.unionNoCheck(t.x,t.y,0,0)}unionRect(t){return Debug&&Util.s(t,Rect,Rect,"unionRect:r"),this.unionNoCheck(t.S,t.P,t.v,t.J)}union(t,i,e,s){return Debug?(Util.r(t,Rect,"union:x"),Util.r(i,Rect,"union:y"),e===void 0?e=0:Util.r(e,Rect,"union:w"),s===void 0?s=0:Util.r(s,Rect,"union:h"),(e<0||s<0)&&Util.n("Rect.union:Width and height cannot be negative"),this.et()):(e===void 0&&(e=0),s===void 0&&(s=0)),this.unionNoCheck(t,i,e,s)}unionNoCheck(t,i,e,s){const n=Math.min(this.S,t),o=Math.min(this.P,i),r=Math.max(this.S+this.v,t+e),l=Math.max(this.P+this.J,i+s);return this.S=n,this.P=o,this.v=r-n,this.J=l-o,this}setSpot(t,i,e){return Debug&&(Util.r(t,Rect,"setSpot:x"),Util.r(i,Rect,"setSpot:y"),Util.s(e,Spot,Rect,"setSpot:spot"),this.et()),this.S=t-e.offsetX-e.x*this.v,this.P=i-e.offsetY-e.y*this.J,this}static contains(t,i,e,s,n,o,r,l){return Debug?(Util.r(t,Rect,"contains:rx"),Util.r(i,Rect,"contains:ry"),Util.r(e,Rect,"contains:rw"),Util.r(s,Rect,"contains:rh"),Util.r(n,Rect,"contains:x"),Util.r(o,Rect,"contains:y"),r===void 0?r=0:Util.r(r,Rect,"contains:w"),l===void 0?l=0:Util.r(l,Rect,"contains:h"),(e<0||s<0||r<0||l<0)&&Util.n("Rect.contains:Width and height cannot be negative")):(r===void 0&&(r=0),l===void 0&&(l=0)),t<=n&&n+r<=t+e&&i<=o&&o+l<=i+s}static intersects(t,i,e,s,n,o,r,l){Debug&&(Util.r(t,Rect,"intersects:rx"),Util.r(i,Rect,"intersects:ry"),Util.r(e,Rect,"intersects:rw"),Util.r(s,Rect,"intersects:rh"),Util.r(n,Rect,"intersects:x"),Util.r(o,Rect,"intersects:y"),Util.r(r,Rect,"intersects:w"),Util.r(l,Rect,"intersects:h"),(e<0||s<0||r<0||l<0)&&Util.n("Rect.intersects:Width and height cannot be negative"));let h=e,a=r;const f=t,c=n;if(h+=f,a+=c,f>a||c>h)return!1;let u=s,d=l;const m=i,g=o;return u+=m,d+=g,!(m>d||g>u)}static intersectsLineSegment(t,i,e,s,n,o,r,l){return Debug&&(Util.r(t,Rect,"intersectsLineSegment:x"),Util.r(i,Rect,"intersectsLineSegment:y"),Util.r(e,Rect,"intersectsLineSegment:w"),Util.r(s,Rect,"intersectsLineSegment:h"),Util.r(n,Rect,"intersectsLineSegment:p1x"),Util.r(o,Rect,"intersectsLineSegment:p1y"),Util.r(r,Rect,"intersectsLineSegment:p2x"),Util.r(l,Rect,"intersectsLineSegment:p2y"),(e<0||s<0)&&Util.n("Rect.intersectsLineSegment: width and height cannot be negative")),Geo.dC(t,i,e,s,n,o,r,l)}get x(){return this.S}set x(t){Debug&&(Util.t(t,"number",Rect,"x"),this.et(t)),this.S=t}get y(){return this.P}set y(t){Debug&&(Util.t(t,"number",Rect,"y"),this.et(t)),this.P=t}get width(){return this.v}set width(t){Debug&&(Util.t(t,"number",Rect,"width"),this.et(t)),t<0&&Util.G(t,">= 0",Rect,"width"),this.v=t}get height(){return this.J}set height(t){Debug&&(Util.t(t,"number",Rect,"height"),this.et(t)),t<0&&Util.G(t,">= 0",Rect,"height"),this.J=t}get left(){return this.S}set left(t){Debug&&(Util.t(t,"number",Rect,"left"),this.et(t)),this.S=t}get top(){return this.P}set top(t){Debug&&(Util.t(t,"number",Rect,"top"),this.et(t)),this.P=t}get right(){return this.S+this.v}set right(t){Debug&&(Util.r(t,Rect,"right"),this.et(t)),this.S+=t-(this.S+this.v)}get bottom(){return this.P+this.J}set bottom(t){Debug&&(Util.r(t,Rect,"top"),this.et(t)),this.P+=t-(this.P+this.J)}get position(){return new Point(this.S,this.P)}set position(t){Debug&&(Util.s(t,Point,Rect,"position"),this.et(t)),this.S=t.x,this.P=t.y}get size(){return new Size(this.v,this.J)}set size(t){Debug&&(Util.s(t,Size,Rect,"size"),this.et(t)),this.v=t.width,this.J=t.height}get center(){return new Point(this.S+this.v/2,this.P+this.J/2)}set center(t){Debug&&(Util.s(t,Point,Rect,"center"),this.et(t)),this.S=t.x-this.v/2,this.P=t.y-this.J/2}get centerX(){return this.S+this.v/2}set centerX(t){Debug&&(Util.r(t,Rect,"centerX"),this.et(t)),this.S=t-this.v/2}get centerY(){return this.P+this.J/2}set centerY(t){Debug&&(Util.r(t,Rect,"centerY"),this.et(t)),this.P=t-this.J/2}isReal(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)}isEmpty(){return this.width===0&&this.height===0}static kw=new Rect(0,0,0,0).ot();static BD=new Rect(NaN,NaN,NaN,NaN).ot();static Yk=[];static a(){const t=Rect.Yk.pop();return t===void 0?new Rect:t}static H(t,i,e,s){const n=Rect.Yk.pop();return n===void 0?new Rect(t,i,e,s):n.e(t,i,e,s)}static o(t){Rect.Yk.push(t)}}class Margin{an;fn;cn;un;f;constructor(t,i,e,s){t===void 0?(this.an=0,this.fn=0,this.cn=0,this.un=0):i===void 0?(i=t,e=t,s=t,this.top=t,this.right=i,this.bottom=e,this.left=s):e===void 0?(e=t,s=i,this.top=t,this.right=i,this.bottom=e,this.left=s):s!==void 0?(this.top=t,this.right=i,this.bottom=e,this.left=s):Util.n("Invalid arguments to Margin constructor: "+t+", "+i+", "+e+", "+s),this.f=!1}c(t){return this.an=t.an,this.fn=t.fn,this.cn=t.cn,this.un=t.un,this}setTo(t,i,e,s){return Debug&&(Util.t(t,"number",Margin,"setTo:t"),Util.t(i,"number",Margin,"setTo:r"),Util.t(e,"number",Margin,"setTo:b"),Util.t(s,"number",Margin,"setTo:l"),this.et()),this.an=t,this.fn=i,this.cn=e,this.un=s,this}set(t){return Debug&&(Util.s(t,Margin,Margin,"assign:m"),this.et()),this.an=t.an,this.fn=t.fn,this.cn=t.cn,this.un=t.un,this}copy(){const t=new Margin;return t.an=this.an,t.fn=this.fn,t.cn=this.cn,t.un=this.un,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ct(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}et(t){if(Debug&&this.f){let i="The Margin is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=NaN;for(;i[e]==="";)e++;let n=i[e++];if(n&&(s=parseFloat(n)),isNaN(s))return new Margin;let o=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(o=parseFloat(n)),isNaN(o))return new Margin(s);let r=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(r=parseFloat(n)),isNaN(r))return new Margin(s,o);let l=NaN;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),isNaN(l)?new Margin(s,o):new Margin(s,o,r,l)}else return new Margin}static stringify(t){return Debug&&Util.s(t,Margin),t.top.toString()+" "+t.right.toString()+" "+t.bottom.toString()+" "+t.left.toString()}static stringifyFixed(t){return Util.t(t,"number",Margin,"stringifyFixed:digits"),i=>i.top.toFixed(t)+" "+i.right.toFixed(t)+" "+i.bottom.toFixed(t)+" "+i.left.toFixed(t)}toString(){return"Margin("+this.top+","+this.right+","+this.bottom+","+this.left+")"}equals(t){return t instanceof Margin?this.an===t.top&&this.fn===t.right&&this.cn===t.bottom&&this.un===t.left:!1}equalTo(t,i,e,s){return this.an===t&&this.fn===i&&this.cn===e&&this.un===s}equalsApprox(t){return Geo.p(this.an,t.top)&&Geo.p(this.fn,t.right)&&Geo.p(this.cn,t.bottom)&&Geo.p(this.un,t.left)}get top(){return this.an}set top(t){Debug&&(Util.r(t,Margin,"top"),this.et(t)),this.an=t}get right(){return this.fn}set right(t){Debug&&(Util.r(t,Margin,"right"),this.et(t)),this.fn=t}get bottom(){return this.cn}set bottom(t){Debug&&(Util.r(t,Margin,"bottom"),this.et(t)),this.cn=t}get left(){return this.un}set left(t){Debug&&(Util.r(t,Margin,"left"),this.et(t)),this.un=t}isReal(){return isFinite(this.top)&&isFinite(this.right)&&isFinite(this.bottom)&&isFinite(this.left)}static qg=new Margin(0,0,0,0).ot();static gC=new Margin(2,2,2,2).ot();static mC=[];static a(){const t=Margin.mC.pop();return t===void 0?new Margin:t}static o(t){Margin.mC.push(t)}}class Spot{S;P;Is;Os;f;constructor(t,i,e,s){t===void 0?(this.S=0,this.P=0,this.Is=0,this.Os=0):(i===void 0&&(i=0),e===void 0&&(e=0),s===void 0&&(s=0),this.x=t,this.y=i,this.offsetX=e,this.offsetY=s),this.f=!1}c(t){return this.S=t.S,this.P=t.P,this.Is=t.Is,this.Os=t.Os,this}setTo(t,i,e,s){return Debug&&(this.Sw(t,"setTo:x"),this.Sw(i,"setTo:y"),this.Mw(e,"setTo:offx"),this.Mw(s,"setTo:offy"),this.et()),this.S=t,this.P=i,this.Is=e,this.Os=s,this}set(t){return Debug&&(Util.s(t,Spot,Spot,"set:s"),this.et()),this.S=t.S,this.P=t.P,this.Is=t.Is,this.Os=t.Os,this}copy(){const t=new Spot;return t.S=this.S,t.P=this.P,t.Is=this.Is,t.Os=this.Os,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ct(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}et(t){if(Debug&&this.f){let i="The Spot is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}Ke(t){return this.S=NaN,this.P=NaN,this.Is=t,this}Sw(t,i){(isNaN(t)||t>1||t<0)&&Util.G(t,"0 <= "+i+" <= 1",Spot,i)}Mw(t,i){(isNaN(t)||t===1/0||t===-1/0)&&Util.G(t,"real number, not NaN or Infinity",Spot,i)}static parse(t){if(typeof t=="string"){if(t=t.trim(),t==="None")return Spot.None;if(t==="TopLeft")return Spot.TopLeft;if(t==="Top"||t==="TopCenter"||t==="MiddleTop")return Spot.TopCenter;if(t==="TopRight")return Spot.TopRight;if(t==="Left"||t==="LeftCenter"||t==="MiddleLeft")return Spot.LeftCenter;if(t==="Center")return Spot.Center;if(t==="Right"||t==="RightCenter"||t==="MiddleRight")return Spot.RightCenter;if(t==="BottomLeft")return Spot.BottomLeft;if(t==="Bottom"||t==="BottomCenter"||t==="MiddleBottom")return Spot.BottomCenter;if(t==="BottomRight")return Spot.BottomRight;if(t==="TopSide")return Spot.TopSide;if(t==="LeftSide")return Spot.LeftSide;if(t==="RightSide")return Spot.RightSide;if(t==="BottomSide")return Spot.BottomSide;if(t==="TopBottomSides")return Spot.TopBottomSides;if(t==="LeftRightSides")return Spot.LeftRightSides;if(t==="TopLeftSides")return Spot.TopLeftSides;if(t==="TopRightSides")return Spot.TopRightSides;if(t==="BottomLeftSides")return Spot.BottomLeftSides;if(t==="BottomRightSides")return Spot.BottomRightSides;if(t==="NotTopSide")return Spot.NotTopSide;if(t==="NotLeftSide")return Spot.NotLeftSide;if(t==="NotRightSide")return Spot.NotRightSide;if(t==="NotBottomSide")return Spot.NotBottomSide;if(t==="AllSides")return Spot.AllSides;if(t==="Default")return Spot.Default;const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n!==void 0&&n.length>0&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n!==void 0&&n.length>0&&(l=parseFloat(n)),new Spot(s,o,r,l)}else return new Spot}static stringify(t){return Debug&&Util.s(t,Spot),t.isSpot()?t.x.toString()+" "+t.y.toString()+" "+t.offsetX.toString()+" "+t.offsetY.toString():t.toString()}static stringifyFixed(t){return Util.t(t,"number",Spot,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.offsetX.toFixed(t)+" "+i.offsetY.toFixed(t)}toString(){return this.isSpot()?this.Is===0&&this.Os===0?"Spot("+this.x+","+this.y+")":"Spot("+this.x+","+this.y+","+this.offsetX+","+this.offsetY+")":this.equals(Spot.None)?"None":this.equals(Spot.TopLeft)?"TopLeft":this.equals(Spot.TopCenter)?"Top":this.equals(Spot.TopRight)?"TopRight":this.equals(Spot.LeftCenter)?"Left":this.equals(Spot.Center)?"Center":this.equals(Spot.RightCenter)?"Right":this.equals(Spot.BottomLeft)?"BottomLeft":this.equals(Spot.BottomCenter)?"Bottom":this.equals(Spot.BottomRight)?"BottomRight":this.equals(Spot.TopSide)?"TopSide":this.equals(Spot.LeftSide)?"LeftSide":this.equals(Spot.RightSide)?"RightSide":this.equals(Spot.BottomSide)?"BottomSide":this.equals(Spot.TopBottomSides)?"TopBottomSides":this.equals(Spot.LeftRightSides)?"LeftRightSides":this.equals(Spot.TopLeftSides)?"TopLeftSides":this.equals(Spot.TopRightSides)?"TopRightSides":this.equals(Spot.BottomLeftSides)?"BottomLeftSides":this.equals(Spot.BottomRightSides)?"BottomRightSides":this.equals(Spot.NotTopSide)?"NotTopSide":this.equals(Spot.NotLeftSide)?"NotLeftSide":this.equals(Spot.NotRightSide)?"NotRightSide":this.equals(Spot.NotBottomSide)?"NotBottomSide":this.equals(Spot.AllSides)?"AllSides":this.equals(Spot.Default)?"Default":"None"}equals(t){return t instanceof Spot?(this.S===t.x||isNaN(this.S)&&isNaN(t.x))&&(this.P===t.y||isNaN(this.P)&&isNaN(t.y))&&this.Is===t.offsetX&&this.Os===t.offsetY:!1}opposite(){return new Spot(.5-(this.S-.5),.5-(this.P-.5),-this.Is,-this.Os)}includesSide(t){if(!this.isSide())return!1;if(!t.isSide())if(t.equals(Spot.Left))t=Spot.LeftSide;else if(t.equals(Spot.Right))t=Spot.RightSide;else if(t.equals(Spot.Top))t=Spot.TopSide;else if(t.equals(Spot.Bottom))t=Spot.BottomSide;else return!1;const i=this.Os,e=t.offsetY;return(i&e)===e}get x(){return this.S}set x(t){Debug&&(this.Sw(t,"x"),this.et(t)),this.S=t}get y(){return this.P}set y(t){Debug&&(this.Sw(t,"y"),this.et(t)),this.P=t}get offsetX(){return this.Is}set offsetX(t){Debug&&(this.Mw(t,"offsetX"),this.et(t)),this.Is=t}get offsetY(){return this.Os}set offsetY(t){Debug&&(this.Mw(t,"offsetY"),this.et(t)),this.Os=t}isSpot(){return!isNaN(this.x)&&!isNaN(this.y)}isNoSpot(){return isNaN(this.x)||isNaN(this.y)}isSide(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===1&&this.offsetY!==0}isNone(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===0&&this.offsetY===0}isDefault(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===-1&&this.offsetY===0}static None=new Spot(0,0,0,0).Ke(0).ot();static Default=new Spot(0,0,-1,0).Ke(-1).ot();static TopLeft=new Spot(0,0,0,0).ot();static TopCenter=new Spot(.5,0,0,0).ot();static TopRight=new Spot(1,0,0,0).ot();static LeftCenter=new Spot(0,.5,0,0).ot();static Center=new Spot(.5,.5,0,0).ot();static RightCenter=new Spot(1,.5,0,0).ot();static BottomLeft=new Spot(0,1,0,0).ot();static BottomCenter=new Spot(.5,1,0,0).ot();static BottomRight=new Spot(1,1,0,0).ot();static MiddleTop=Spot.TopCenter;static MiddleLeft=Spot.LeftCenter;static MiddleRight=Spot.RightCenter;static MiddleBottom=Spot.BottomCenter;static Top=Spot.TopCenter;static Left=Spot.LeftCenter;static Right=Spot.RightCenter;static Bottom=Spot.BottomCenter;static TopSide=new Spot(0,0,1,1).Ke(1).ot();static LeftSide=new Spot(0,0,1,2).Ke(1).ot();static RightSide=new Spot(0,0,1,4).Ke(1).ot();static BottomSide=new Spot(0,0,1,8).Ke(1).ot();static TopBottomSides=new Spot(0,0,1,9).Ke(1).ot();static LeftRightSides=new Spot(0,0,1,6).Ke(1).ot();static TopLeftSides=new Spot(0,0,1,3).Ke(1).ot();static TopRightSides=new Spot(0,0,1,5).Ke(1).ot();static BottomLeftSides=new Spot(0,0,1,10).Ke(1).ot();static BottomRightSides=new Spot(0,0,1,12).Ke(1).ot();static NotTopSide=new Spot(0,0,1,14).Ke(1).ot();static NotLeftSide=new Spot(0,0,1,13).Ke(1).ot();static NotRightSide=new Spot(0,0,1,11).Ke(1).ot();static NotBottomSide=new Spot(0,0,1,7).Ke(1).ot();static AllSides=new Spot(0,0,1,15).Ke(1).ot();static Kk=new Spot(.156,.156).ot();static Uk=new Spot(.844,.844).ot();static pC=[];static a(){const t=Spot.pC.pop();return t===void 0?new Spot:t}static o(t){Spot.pC.push(t)}}class Transform{m11;m12;m21;m22;dx;dy;constructor(){this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0}set(t){return this.m11=t.m11,this.m12=t.m12,this.m21=t.m21,this.m22=t.m22,this.dx=t.dx,this.dy=t.dy,this}setTo(t,i,e,s,n,o){return this.m11=t,this.m12=i,this.m21=e,this.m22=s,this.dx=n,this.dy=o,this}copy(){const t=new Transform;return t.m11=this.m11,t.m12=this.m12,t.m21=this.m21,t.m22=this.m22,t.dx=this.dx,t.dy=this.dy,t}toString(){return"Transform("+this.m11+","+this.m12+","+this.m21+","+this.m22+","+this.dx+","+this.dy+")"}equals(t){return this.m11===t.m11&&this.m12===t.m12&&this.m21===t.m21&&this.m22===t.m22&&this.dx===t.dx&&this.dy===t.dy}Gk(){return this.dx===0&&this.dy===0&&this.m11===1&&this.m12===0&&this.m21===0&&this.m22===1}Bi(){return this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0,this}hf(t){const i=this.m11*t.m11+this.m21*t.m12,e=this.m12*t.m11+this.m22*t.m12,s=this.m11*t.m21+this.m21*t.m22,n=this.m12*t.m21+this.m22*t.m22;return this.dx=this.m11*t.dx+this.m21*t.dy+this.dx,this.dy=this.m12*t.dx+this.m22*t.dy+this.dy,this.m11=i,this.m12=e,this.m21=s,this.m22=n,this}yC(t){const i=1/(t.m11*t.m22-t.m12*t.m21),e=t.m22*i,s=-t.m12*i,n=-t.m21*i,o=t.m11*i,r=i*(t.m21*t.dy-t.m22*t.dx),l=i*(t.m12*t.dx-t.m11*t.dy),h=this.m11*e+this.m21*s,a=this.m12*e+this.m22*s,f=this.m11*n+this.m21*o,c=this.m12*n+this.m22*o;return this.dx=this.m11*r+this.m21*l+this.dx,this.dy=this.m12*r+this.m22*l+this.dy,this.m11=h,this.m12=a,this.m21=f,this.m22=c,this}Pw(){const t=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*t,e=-this.m12*t,s=-this.m21*t,n=this.m11*t,o=t*(this.m21*this.dy-this.m22*this.dx),r=t*(this.m12*this.dx-this.m11*this.dy);return this.m11=i,this.m12=e,this.m21=s,this.m22=n,this.dx=o,this.dy=r,this}ms(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return this;this.Es(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m11*s+this.m21*n,r=this.m12*s+this.m22*n,l=this.m11*-n+this.m21*s,h=this.m12*-n+this.m22*s;return this.m11=o,this.m12=r,this.m21=l,this.m22=h,this.Es(-i,-e),this}Es(t,i){return this.dx+=this.m11*t+this.m21*i,this.dy+=this.m12*t+this.m22*i,this}lt(t,i){return i===void 0&&(i=t),this.m11*=t,this.m12*=t,this.m21*=i,this.m22*=i,this}zD(){if(this.m11===1&&this.m12===0)return 0;let t=Math.atan2(this.m12,this.m11)*180/Math.PI;return t<0&&(t+=360),t}Pt(t){const i=t.x,e=t.y;return t.e(i*this.m11+e*this.m21+this.dx,i*this.m12+e*this.m22+this.dy)}ns(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=t.x-this.dx,l=t.y-this.dy;return t.e(r*e+l*n,r*s+l*o)}Nw(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=i*(this.m21*this.dy-this.m22*this.dx),l=i*(this.m12*this.dx-this.m11*this.dy),h=t.x*1.25,a=t.y*1.2;return t.e(h*e+a*n+r,h*s+a*o+l)}Cw(t){const i=t.x,e=t.y,s=i+t.width,n=e+t.height,o=this.m11,r=this.m12,l=this.m21,h=this.m22,a=this.dx,f=this.dy,c=i*o+e*l+a,u=i*r+e*h+f,d=s*o+e*l+a,m=s*r+e*h+f,g=i*o+n*l+a,p=i*r+n*h+f,y=s*o+n*l+a,x=s*r+n*h+f;let k=c,b=c,S=u,M=u;return k=Math.min(k,d),b=Math.max(b,d),S=Math.min(S,m),M=Math.max(M,m),k=Math.min(k,g),b=Math.max(b,g),S=Math.min(S,p),M=Math.max(M,p),k=Math.min(k,y),b=Math.max(b,y),S=Math.min(S,x),M=Math.max(M,x),t.e(k,S,b-k,M-S),t}static wC=[];static a(){const t=Transform.wC.pop();return t===void 0?new Transform:t}static o(t){Transform.wC.push(t)}static Hk="54a702f3e53909c447824c6706603faf4c"}const Geo={XD:"7da71ca0ad381e90",Un:4*((Math.sqrt(2)-1)/3),xC:null,Aw:w=>{if(w<=0)return 0;let t=Geo.xC;if(t===null){t=[];for(let i=0;i<=2e3;i++)t[i]=Math.sqrt(i);Geo.xC=t}if(w<1){const i=1/w;return i<=2e3?1/t[i|0]:Math.sqrt(w)}else return w<=2e3?t[w|0]:Math.sqrt(w)},p:(w,t)=>{const i=w-t;return i<.5&&i>-.5},q:(w,t)=>{const i=w-t;return i<5e-8&&i>-5e-8},zi:(w,t,i,e,s,n,o)=>{s<=0&&(s=1e-6);let r=0,l=0,h=0,a=0;if(wu-d)if(w-i>s||i-w>s){const g=(e-t)/(i-w)*(n-w)+t;if(g-s<=o&&o<=g+s)return!0}else return!0;else if(t-e>s||e-t>s){const g=(i-w)/(e-t)*(o-t)+w;if(g-s<=n&&n<=g+s)return!0}else return!0}return!1},Lw:(w,t,i,e,s,n,o,r,l,h,a,f)=>{if(!Geo.zi(w,t,o,r,f,i,e)||!Geo.zi(w,t,o,r,f,s,n)){const c=(w+i)/2,u=(t+e)/2,d=(i+s)/2,m=(e+n)/2,g=(s+o)/2,p=(n+r)/2,y=(c+d)/2,x=(u+m)/2,k=(d+g)/2,b=(m+p)/2,S=(y+k)/2,M=(x+b)/2;return Geo.Lw(w,t,c,u,y,x,S,M,l,h,a,f)||Geo.Lw(S,M,k,b,g,p,o,r,l,h,a,f)}else return Geo.zi(w,t,o,r,f,h,a)},bC:(w,t,i,e,s,n,o,r,l)=>{const h=(w+i)/2,a=(t+e)/2,f=(i+s)/2,c=(e+n)/2,u=(s+o)/2,d=(n+r)/2,m=(h+f)/2,g=(a+c)/2,p=(f+u)/2,y=(c+d)/2;return l.e((m+p)/2,(g+y)/2),l},YD:(w,t,i,e,s,n,o,r)=>{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,f=(e+n)/2,c=(s+o)/2,u=(n+r)/2,d=(l+a)/2,m=(h+f)/2,g=(a+c)/2,p=(f+u)/2;return Point.direction(d,m,g,p)},mu:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.zi(w,t,o,r,l,i,e)||!Geo.zi(w,t,o,r,l,s,n)){const a=(w+i)/2,f=(t+e)/2,c=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+c)/2,p=(f+u)/2,y=(c+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.mu(w,t,a,f,g,p,k,b,l,h),Geo.mu(k,b,y,x,d,m,o,r,l,h)}else h.unionNoCheck(w,t,0,0),h.unionNoCheck(o,r,0,0);return h},Gn:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.zi(w,t,o,r,l,i,e)||!Geo.zi(w,t,o,r,l,s,n)){const a=(w+i)/2,f=(t+e)/2,c=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+c)/2,p=(f+u)/2,y=(c+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.Gn(w,t,a,f,g,p,k,b,l,h),Geo.Gn(k,b,y,x,d,m,o,r,l,h)}else h.length===0&&(h.push(w),h.push(t)),h.push(o),h.push(r);return h},qk:(w,t,i,e,s,n,o,r,l,h)=>{if(Geo.zi(w,t,s,n,h,i,e))return Geo.zi(w,t,s,n,h,r,l);{const a=(w+i)/2,f=(t+e)/2,c=(i+s)/2,u=(e+n)/2,d=(a+c)/2,m=(f+u)/2;return Geo.qk(w,t,a,f,d,m,o,r,l,h)||Geo.qk(d,m,c,u,s,n,o,r,l,h)}},nE:(w,t,i,e,s,n,o)=>{const r=(w+i)/2,l=(t+e)/2,h=(i+s)/2,a=(e+n)/2;return o.e((r+h)/2,(l+a)/2),o},jk:(w,t,i,e,s,n,o,r)=>{if(Geo.zi(w,t,s,n,o,i,e))r.unionNoCheck(w,t,0,0),r.unionNoCheck(s,n,0,0);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,f=(e+n)/2,c=(l+a)/2,u=(h+f)/2;Geo.jk(w,t,l,h,c,u,o,r),Geo.jk(c,u,a,f,s,n,o,r)}return r},jg:(w,t,i,e,s,n,o,r)=>{if(Geo.zi(w,t,s,n,o,i,e))r.length===0&&(r.push(w),r.push(t)),r.push(s),r.push(n);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,f=(e+n)/2,c=(l+a)/2,u=(h+f)/2;Geo.jg(w,t,l,h,c,u,o,r),Geo.jg(c,u,a,f,s,n,o,r)}return r},Wg:(w,t,i,e,s,n,o,r,l,h,a,f,c,u)=>{if(!Geo.zi(w,t,o,r,c,i,e)||!Geo.zi(w,t,o,r,c,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,S=(g+y)/2,M=(p+x)/2,A=(k+S)/2,C=(b+M)/2;let P=1/0,N=!1,T=0,L=0;if(Geo.Wg(w,t,d,m,k,b,A,C,l,h,a,f,c,u)){const D=(u.x-l)*(u.x-l)+(u.y-h)*(u.y-h);D{let u=0;if(!Geo.zi(w,t,o,r,c,i,e)||!Geo.zi(w,t,o,r,c,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,S=(g+y)/2,M=(p+x)/2,A=(k+S)/2,C=(b+M)/2;u+=Geo.vg(w,t,d,m,k,b,A,C,l,h,a,f,c),u+=Geo.vg(A,C,S,M,y,x,o,r,l,h,a,f,c)}else{const d=(w-o)*(h-f)-(t-r)*(l-a);if(d===0)return u;const m=((w*r-t*o)*(l-a)-(w-o)*(l*f-h*a))/d,g=((w*r-t*o)*(h-f)-(t-r)*(l*f-h*a))/d;if(m>=a)return u;let p=0,y=0;if((l>a?l-a:a-l)<(h>f?h-f:f-h)){if(ty)return u}else if(wy)return u;d>0?u++:d<0&&u--}return u},xl:(w,t,i,e,s,n,o)=>{if(Geo.q(w,i)){let r=0,l=0;tl?(o.e(w,l),!1):(o.e(w,h),!0)}else if(Geo.q(t,e)){let r=0,l=0;wl?(o.e(l,t),!1):(o.e(h,t),!0)}else{const r=(i-w)*(i-w)+(e-t)*(e-t),l=((w-s)*(w-i)+(t-n)*(t-e))/r;if(l<-5e-6)return o.e(w,t),!1;if(l>1.000005)return o.e(i,e),!1;{const h=w+l*(i-w),a=t+l*(e-t);return o.e(h,a),!0}}},Hn:(w,t,i,e,s,n,o,r,l)=>{if(Geo.p(w,i)&&Geo.p(t,e))return l.e(w,t),!1;if(Geo.q(s,o)){if(Geo.q(w,i))return Geo.xl(w,t,i,e,s,n,l),!1;{const a=(e-t)/(i-w)*(s-w)+t;return Geo.xl(w,t,i,e,s,a,l)}}else{const h=(r-n)/(o-s);if(Geo.q(w,i)){const a=h*(w-s)+n;let f=0,c=0;return tc?(l.e(w,c),!1):(l.e(w,a),!0)}else{const a=(e-t)/(i-w);if(Geo.q(h,a))return Geo.xl(w,t,i,e,s,n,l),!1;{const f=(a*w-h*s+n-t)/(a-h);if(Geo.q(a,0)){let c=0,u=0;return wu?(l.e(u,t),!1):(l.e(f,t),!0)}else{const c=a*(f-w)+t;return Geo.xl(w,t,i,e,f,c,l)}}}}},oE:(w,t,i,e,s)=>Geo.Hn(i.x,i.y,e.x,e.y,w.x,w.y,t.x,t.y,s),rE:(w,t,i,e,s,n,o,r,l,h)=>{let a=1/0;function f(S,M){const A=(S-w)*(S-w)+(M-t)*(M-t);Aw?i-w:w-i)<.5){const S=1-(i-k)*(i-k)/(y*y);if(S<0)return l;const M=Math.sqrt(S),A=x*M+b,C=-x*M+b;f(i,A),f(i,C)}else{const S=(e-t)/(i-w),M=1/(y*y)+S*S/(x*x),A=2*S*(t-S*w)/(x*x)-2*S*b/(x*x)-2*k/(y*y),C=2*S*w*b/(x*x)-2*t*b/(x*x)+b*b/(x*x)+k*k/(y*y)-1+(t-S*w)*(t-S*w)/(x*x),P=A*A-4*M*C;if(P<0)return l;const N=Math.sqrt(P),T=(-A+N)/(2*M);f(T,S*T-S*w+t);const L=(-A-N)/(2*M);f(L,S*L-S*w+t)}return l},bl:(w,t,i,e,s,n,o,r,l)=>{let h=1e21,a=w,f=t;if(Geo.Hn(w,t,w,e,s,n,o,r,l)){const c=(l.x-s)*(l.x-s)+(l.y-n)*(l.y-n);cGeo.dC(w.x,w.y,w.width,w.height,t.x,t.y,i.x,i.y),dC:(w,t,i,e,s,n,o,r)=>{const l=w,h=w+i,a=t,f=t+e;if(s===o){let c=0,u=0;return n=a}if(n===r){let c=0,u=0;return s=l}return!!(Rect.contains(w,t,i,e,s,n)||Rect.contains(w,t,i,e,o,r)||Geo.du(l,a,h,a,s,n,o,r)||Geo.du(h,a,h,f,s,n,o,r)||Geo.du(h,f,l,f,s,n,o,r)||Geo.du(l,f,l,a,s,n,o,r))},du:(w,t,i,e,s,n,o,r)=>w===i&&t===e&&s===o&&n===r?w===s&&t===n:Geo.uu(w,t,i,e,s,n)*Geo.uu(w,t,i,e,o,r)<=0&&Geo.uu(s,n,o,r,w,t)*Geo.uu(s,n,o,r,i,e)<=0,uu:(w,t,i,e,s,n)=>{const o=i-w,r=e-t;let l=s-w,h=n-t,a=l*r-h*o;return a===0&&(a=l*o+h*r,a>0&&(l-=o,h-=r,a=l*o+h*r,a<0&&(a=0))),a},Jg:w=>(w<0&&(w+=360),w>=360&&(w-=360),w),kC:(w,t,i,e,s,n)=>{const o=Math.PI;n||(e=e*(o/180),s=s*(o/180));const r=e>s?-1:1,l=1e-5,h=o*2,a=[],f=o/2;let c=e,u=Math.min(h,Math.abs(s-e));if(ul;){const d=c+r*Math.min(u,f);a.push(Geo.KD(i,c,d,w,t)),u-=Math.abs(d-c),c=d}return a},KD:(w,t,i,e,s)=>{const n=(i-t)/2,o=w*Math.cos(n),r=w*Math.sin(n),l=o,h=-r,a=l*l+h*h,f=a+l*o+h*r,c=4/3*(Math.sqrt(2*a*f)-f)/(l*r-h*o),u=l-c*h,d=h+c*l,m=u,g=-d,p=n+t,y=Math.cos(p),x=Math.sin(p);return[e+w*Math.cos(t),s+w*Math.sin(t),e+u*y-d*x,s+u*x+d*y,e+m*y-g*x,s+m*x+g*y,e+w*Math.cos(i),s+w*Math.sin(i)]},Hg:(w,t,i,e,s,n,o)=>{const r=s,l=n,h=Math.floor((w-i)/r)*r+i,a=Math.floor((t-e)/l)*l+e;let f=h;h+r-w{let i=Math.max(w,t),e=Math.min(w,t),s=1,n=1;do s=i%e,n=e,i=e,e=s;while(s>0);return n},UD:(w,t,i,e)=>{const s=i<0,n=e<0;let o=0,r=0,l=0;w{let o=0;if(e>0)if(i>0){const r=w*w,l=t*t,h=w*i,a=t*e;let f=-l+a,c=-l+Math.sqrt(h*h+a*a),u=f;const d=9999999999;for(let p=0;p0)f=u;else if(k<0)c=u;else break}s=r*i/(u+r),n=l*e/(u+l);const m=s-i,g=n-e;o=Math.sqrt(m*m+g*g)}else s=0,n=t,o=Math.abs(e-t);else{const r=w*w-t*t,l=w*i;if(l(w[w.Line=1]="Line",w[w.Rectangle=2]="Rectangle",w[w.Ellipse=3]="Ellipse",w[w.Path=4]="Path",w))(GeometryType||{}),GeometryStretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w))(GeometryStretch||{});class Geometry{l;Qg;_g;af;pu;yu;jn;Wn;vn;st;Pe;Ne;ee;se;Vs;ff;cf;constructor(t){Debug&&arguments.length>1&&Util.n("Geometry constructor can take at most one optional argument, the Geometry type."),GSet.vi(this),this.l=2,t===void 0?t=4:Debug&&Util.tt(t,GeometryType,"GeometryType"),this.st=t,this.Pe=0,this.Ne=0,this.ee=0,this.se=0,t===4?this.Vs=new List:this.Vs=Geometry.Dw,this.Qg=this.Vs.gt,this._g=new Rect().w(),this.af=null,this.pu=null,this.yu=NaN,this.jn=Spot.TopLeft,this.Wn=Spot.BottomRight,this.ff=NaN,this.cf=NaN,this.vn=2}copy(){const t=new Geometry;if(t.l=this.l&-2,t.st=this.st,t.Pe=this.Pe,t.Ne=this.Ne,t.ee=this.ee,t.se=this.se,this.st===4){const i=this.Vs.h,e=t.Vs;for(let s=0;si.toString(t)}fi(t){t in GeometryType?this.type=t:Util.ur(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e;switch(this.type){case 1:return t<0?"M"+this.startX.toString()+" "+this.startY.toString()+"L"+this.endX.toString()+" "+this.endY.toString():"M"+i(this.startX)+" "+i(this.startY)+"L"+i(this.endX)+" "+i(this.endY);case 2:return e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0?"M"+e.x.toString()+" "+e.y.toString()+"H"+e.right.toString()+"V"+e.bottom.toString()+"H"+e.left.toString()+"z":"M"+i(e.x)+" "+i(e.y)+"H"+i(e.right)+"V"+i(e.bottom)+"H"+i(e.left)+"z";case 3:if(e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0){const r=e.left.toString()+" "+(e.y+e.height/2).toString(),l=e.right.toString()+" "+(e.y+e.height/2).toString();return"M"+r+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+l+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+r}else{const r=i(e.left)+" "+i(e.y+e.height/2),l=i(e.right)+" "+i(e.y+e.height/2);return"M"+r+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+l+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+r}case 4:let s="";const n=this.figures.h,o=n.length;for(let r=0;r0&&(s+=" x "),l.isFilled&&(s+="F "),s+=l.toString(t)}return s;default:return GeometryType[this.type]}}static fillPath(t){typeof t!="string"&&Util.Vi(t,"string",Geometry,"fillPath:str");const i=t.split(/[Xx]/),e=i.length;let s="";for(let n=0;n=k-1||o[r+1].match(N)!==null?!0:(u=!1,!1)}function m(){return r++,o[r]}function g(L){let D=parseFloat(m()),F=parseFloat(m());l===l.toLowerCase()&&(D=c.x+D,F=c.y+F),L.e(D,F)}function p(){return g(c),c}function y(){return g(f),f}function x(){const L=h.toLowerCase();return L==="c"||L==="s"||L==="q"||L==="t"?new Point(2*c.x-f.x,2*c.y-f.y):new Point(c.x,c.y)}const k=o.length,b=GeoStream.PC(null);let S=!1,M=!1,A=!1,C=!0,P=null;const N=new RegExp("["+Geometry.tm+"]");for(;!(r>=k-1);){if(h=l,l=m(),l==="")continue;u=!0;let L=!1;switch(l.toUpperCase()){case"X":C=!0,S=!1,M=!1;break;case"M":for(P=p(),b.Ci===null||C===!0?(b.wu(P.x,P.y,S,!1,!M,A),C=!1):b.HD(P.x,P.y),a.c(c);!d();)P=p(),b.yr(P.x,P.y);break;case"L":for(;!d();)P=p(),b.yr(P.x,P.y);u&&(L=!0);break;case"H":for(;!d();)c.e((l===l.toLowerCase()?c.x:0)+parseFloat(m()),c.y),b.yr(c.x,c.y);break;case"V":for(;!d();)c.e(c.x,(l===l.toLowerCase()?c.y:0)+parseFloat(m())),b.yr(c.x,c.y);u&&(L=!0);break;case"C":for(;!d();){const D=new Point;g(D);const F=y(),R=p();b.wr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(L=!0);break;case"S":for(;!d();){const D=x(),F=y(),R=p();b.wr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(L=!0);break;case"Q":for(;!d();){const D=y(),F=p();b.Fw(D.x,D.y,F.x,F.y)}u&&(L=!0);break;case"T":for(;!d();){const D=x();f.c(D);const F=p();b.Fw(D.x,D.y,F.x,F.y),f.c(F)}u&&(L=!0);break;case"B":for(;!d();){const D=parseFloat(m()),F=parseFloat(m());let R=parseFloat(m()),I=parseFloat(m());const O=parseFloat(m());let B=O,K=!1;d()||(B=parseFloat(m()),d()||(K=parseFloat(m())!==0)),l===l.toLowerCase()&&(R+=c.x,I+=c.y),b.qD(D,F,R,I,O,B,K)}u&&(L=!0);break;case"A":for(;!d();){const D=Math.abs(parseFloat(m())),F=Math.abs(parseFloat(m())),R=parseFloat(m());let I=!1,O=!1,B=0,K=0;const V=m();V.length===1?(I=!!parseFloat(V),O=!!parseFloat(m()),B=parseFloat(m()),K=parseFloat(m())):V.length===2?(I=!!parseFloat(V[0]),O=!!parseFloat(V[1]),B=parseFloat(m()),K=parseFloat(m())):(I=!!parseFloat(V[0]),O=!!parseFloat(V[1]),B=parseFloat(V.slice(2)),K=parseFloat(m())),l===l.toLowerCase()&&(B=c.x+B,K=c.y+K),c.e(B,K),b.jD(D,F,R,I,O,B,K)}u&&(L=!0);break;case"Z":b.WD(),c.c(a);break;case"F":{let D="",F=1;for(;o[r+F];){if(o[r+F]==="0"){A=!0,F++;continue}if(o[r+F].match(/[Uu]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?S=!0:b.vD();break}case"U":{let D="",F=1;for(;o[r+F];){if(o[r+F].match(/[Ff]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?M=!0:b.JD(!1);break}default:if(l==="0"||l==="1")break;Util.at("Unknown geometry command: "+l);break}if(L){Util.at(`Bad geometry command: ${l}, next token: ${m()}, -string: ${t}`);break}}const T=b.im;if(GeoStream.NC(b),i){const L=T.figures.iterator;for(;L.next();){const D=L.value;D.isFilled=!0}}return T}static CC(t,i){const e=t.length,s=Point.a();for(let n=0;n=t)return 0;if((n>r?n-r:r-n)<(o>l?o-l:l-o)){if(ol)return 0}else if(fo)return 0}else if(nr)return 0}else if(an)return 0;return h>0?1:-1}LC(t,i,e){const s=this.figures.h,n=s.length;for(let o=0;o1&&(t=1),i===void 0&&(i=new Point),this.type===1)return i.e(this.startX+t*(this.endX-this.startX),this.startY+t*(this.endY-this.startY)),i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[c*2],y=g[c*2+1],x=g[c*2+2],k=g[c*2+3];return i.e(p+(x-p)*m,y+(k-y)*m),i}l+=u}}return i}getAngleAlongPath(t){if(t<0?t=0:t>1&&(t=1),this.type===1)return Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI;const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=i.length,o=s*t;let r=0;for(let l=0;l=o){const u=i[l],d=u[f*2],m=u[f*2+1],g=u[f*2+2],p=u[f*2+3];return Math.abs(g-d)<1&&Math.abs(p-m)<1?0:Math.abs(g-d)<1?p-m>=0?90:270:Math.abs(p-m)<1?g-d>=0?0:180:Math.atan2(p-m,g-d)*180/Math.PI}r+=c}}return NaN}getPointAndAngleAlongPath(t,i){if(t<0?t=0:t>1&&(t=1),i===void 0&&(i=[]),i.length=3,this.type===1)return i[0]=this.startX+t*(this.endX-this.startX),i[1]=this.startY+t*(this.endY-this.startY),i[2]=Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI,i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[c*2],y=g[c*2+1],x=g[c*2+2],k=g[c*2+3];i[0]=p+(x-p)*m,i[1]=y+(k-y)*m;let b;return Math.abs(x-p)<1&&Math.abs(k-y)<1?b=0:Math.abs(x-p)<1?b=k-y>=0?90:270:Math.abs(k-y)<1?b=x-p>=0?0:180:b=Math.atan2(k-y,x-p)*180/Math.PI,i[2]=b,i}l+=u}}return i}getFractionForPoint(t){if(this.type===1){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=t.x,r=t.y;let l=0,h=0;if(i===s)return e=h?h===e?0:1:Math.abs(r-e)/(h-l);if(e===n)return i=h?h===i?0:1:Math.abs(o-i)/(h-l);{const a=(s-i)*(s-i)+(n-e)*(n-e),f=Point.a();Geo.xl(i,e,s,n,o,r,f);const c=f.x,u=f.y;return Point.o(f),Math.sqrt(((c-i)*(c-i)+(u-e)*(u-e))/a)}}}else if(this.type===2){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=s-i,r=n-e,l=o*2+r*2;let h=t.x,a=t.y;h=Math.min(Math.max(h,i),s),a=Math.min(Math.max(a,e),n);const f=Math.abs(h-i),c=Math.abs(h-s),u=Math.abs(a-e),d=Math.abs(a-n),m=Math.min(f,c,u,d);if(m===u)return h/l;if(m===c)return(o+a)/l;if(m===d)return(o*2+r-h)/l;if(m===f)return(o*2+r*2-a)/l}}else{const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=Point.a();let o=1/0,r=0,l=0;const h=i.length;let a=0,f=0;for(let u=0;u1?1:c}return 0}get flattenedSegments(){return this.TC(),this.af}TC(){if(this.af===null){const t=this.af=[],i=this.pu=[];this.QD(t,i)}}get flattenedLengths(){return this.TC(),this.pu}get flattenedTotalLength(){let t=this.yu;if(isNaN(t)){if(this.type===1){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=Math.sqrt(i*i+e*e)}else if(this.type===2){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=i*2+e*2}else{const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=4&&(t.push(e),i.push(this.Zk(e))),e=[],e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY,h=r,a=l;break;case 2:e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY;break;case 3:Geo.Gn(r,l,d.point1X,d.point1Y,d.point2X,d.point2Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 4:Geo.jg(r,l,d.point1X,d.point1Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 5:{const m=d.To(o),g=m.length;if(g===0){e.push(d.centerX),e.push(d.centerY),r=d.centerX,l=d.centerY;break}for(let p=0;p=4&&(t.push(e),i.push(this.Zk(e)))}}}get type(){return this.st}set type(t){this.st!==t&&(Debug&&Util.tt(t,GeometryType,"GeometryType"),this.f&&Util.F(this,t),this.st=t,t===4?this.Vs=new List:(Geometry.Dw===null&&(Geometry.Dw=new List().w()),this.Vs=Geometry.Dw),this.Nt=!0)}get startX(){return this.Pe}set startX(t){this.Pe!==t&&(Debug&&Util.r(t,Geometry,"startX"),this.f&&Util.F(this,t),this.Pe=t,this.Nt=!0)}get startY(){return this.Ne}set startY(t){this.Ne!==t&&(Debug&&Util.r(t,Geometry,"startY"),this.f&&Util.F(this,t),this.Ne=t,this.Nt=!0)}get endX(){return this.ee}set endX(t){this.ee!==t&&(Debug&&Util.r(t,Geometry,"endX"),this.f&&Util.F(this,t),this.ee=t,this.Nt=!0)}get endY(){return this.se}set endY(t){this.se!==t&&(Debug&&Util.r(t,Geometry,"endY"),this.f&&Util.F(this,t),this.se=t,this.Nt=!0)}get figures(){return this.Vs}set figures(t){this.Vs!==t&&(Debug&&Util.s(t,List,Geometry,"figures"),this.f&&Util.F(this,t),this.Vs=t,this.Nt=!0)}add(t){return this.Vs.add(t),this}setSpots(t,i,e,s,n,o,r,l){return this.f&&Util.F(this),this.jn=new Spot(t,i,n,o).w(),this.Wn=new Spot(e,s,r,l).w(),this}get spot1(){return this.jn}set spot1(t){Debug&&Util.s(t,Spot,Geometry,"spot1"),this.f&&Util.F(this,t),this.jn=t.L()}get spot2(){return this.Wn}set spot2(t){Debug&&Util.s(t,Spot,Geometry,"spot2"),this.f&&Util.F(this,t),this.Wn=t.L()}get defaultStretch(){return this.vn}set defaultStretch(t){this.vn=t}get bounds(){return this.Wk()&&this.Rw(),this._g}}Geometry.stringify=Geometry.stringify,Geometry.stringifyFixed=Geometry.stringifyFixed,Geometry.fillPath=Geometry.fillPath,Geometry.parse=Geometry.parse;class PathFigure{l;Pe;Ne;uf;em;Ue;constructor(t,i,e,s,n){e===void 0&&(e=!0),s===void 0&&(s=!0),n===void 0&&(n=!1),this.l=2|(e?4:0)|(s?8:0)|(n?16:0),t!==void 0?(Debug&&Util.r(t,PathFigure,"sx"),this.Pe=t):this.Pe=0,i!==void 0?(Debug&&Util.r(i,PathFigure,"sy"),this.Ne=i):this.Ne=0,this.uf=new List,this.em=this.uf.gt,this.Ue=null}copy(){const t=new PathFigure;t.l=this.l&-2,t.Pe=this.Pe,t.Ne=this.Ne;const i=this.uf.h,e=i.length,s=t.uf;for(let n=0;no===0?"0":o.toFixed(t);i="M"+n(this.startX)+" "+n(this.startY)}const e=this.segments.h,s=e.length;for(let n=0;n(w[w.Move=1]="Move",w[w.Line=2]="Line",w[w.Bezier=3]="Bezier",w[w.QuadraticBezier=4]="QuadraticBezier",w[w.Arc=5]="Arc",w[w.SvgArc=6]="SvgArc",w))(SegmentType||{});class PathSegment{st;l;ee;se;dn;kl;Sl;xr;Bs;constructor(t,i,e,s,n,o,r,l){if(GSet.vi(this),t===void 0?t=2:Debug&&Util.tt(t,SegmentType,"SegmentType"),this.st=t,this.l=2,i!==void 0?(Debug&&Util.r(i,PathSegment,"ex"),this.ee=i):this.ee=0,e!==void 0?(Debug&&Util.r(e,PathSegment,"ey"),this.se=e):this.se=0,s===void 0&&(s=0),n===void 0&&(n=0),o===void 0&&(o=0),r===void 0&&(r=0),t===6){let h=o;h=h%360,h<0&&(h+=360),this.dn=h,this.kl=0,Debug&&Util.r(s,PathSegment,"x1"),this.Sl=Math.max(s,0),Debug&&Util.r(n,PathSegment,"y1"),this.xr=Math.max(n,0),typeof r=="boolean"?r&&(this.isLargeArc=!0):typeof r=="number"&&r&&(this.isLargeArc=!0),l&&(this.isClockwiseArc=!0)}else Debug&&Util.r(s,PathSegment,"x1"),this.dn=s,Debug&&Util.r(n,PathSegment,"y1"),this.kl=n,Debug&&Util.r(o,PathSegment,"x2"),t===5&&(o=Math.max(o,0)),this.Sl=o,typeof r=="number"?(t===5&&(r=Math.max(r,0)),this.xr=r):this.xr=0;this.Bs=null}copy(){const t=new PathSegment;return t.st=this.st,t.l=this.l&-2,t.ee=this.ee,t.se=this.se,t.dn=this.dn,t.kl=this.kl,t.Sl=this.Sl,t.xr=this.xr,t}equalsApprox(t){if(!(t instanceof PathSegment)||this.type!==t.type||this.isClosed!==t.isClosed)return!1;switch(this.type){case 1:case 2:return Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY);case 3:return Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY)&&Geo.p(this.point1X,t.point1X)&&Geo.p(this.point1Y,t.point1Y)&&Geo.p(this.point2X,t.point2X)&&Geo.p(this.point2Y,t.point2Y);case 4:return Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY)&&Geo.p(this.point1X,t.point1X)&&Geo.p(this.point1Y,t.point1Y);case 5:return Geo.p(this.startAngle,t.startAngle)&&Geo.p(this.sweepAngle,t.sweepAngle)&&Geo.p(this.centerX,t.centerX)&&Geo.p(this.centerY,t.centerY)&&Geo.p(this.radiusX,t.radiusX)&&Geo.p(this.radiusY,t.radiusY);case 6:return this.isClockwiseArc===t.isClockwiseArc&&this.isLargeArc===t.isLargeArc&&Geo.p(this.xAxisRotation,t.xAxisRotation)&&Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY)&&Geo.p(this.radiusX,t.radiusX)&&Geo.p(this.radiusY,t.radiusY);default:return!1}}fi(t){t in SegmentType?this.type=t:Util.ur(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e="";switch(this.type){case 1:t<0?e="M"+this.endX.toString()+" "+this.endY.toString():e="M"+i(this.endX)+" "+i(this.endY);break;case 2:t<0?e="L"+this.endX.toString()+" "+this.endY.toString():e="L"+i(this.endX)+" "+i(this.endY);break;case 3:t<0?e="C"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.point2X.toString()+" "+this.point2Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="C"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.point2X)+" "+i(this.point2Y)+" "+i(this.endX)+" "+i(this.endY);break;case 4:t<0?e="Q"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="Q"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.endX)+" "+i(this.endY);break;case 5:t<0?e="B"+this.startAngle.toString()+" "+this.sweepAngle.toString()+" "+this.centerX.toString()+" "+this.centerY.toString()+" "+this.radiusX.toString()+" "+this.radiusY.toString():e="B"+i(this.startAngle)+" "+i(this.sweepAngle)+" "+i(this.centerX)+" "+i(this.centerY)+" "+i(this.radiusX)+" "+i(this.radiusY);break;case 6:t<0?e="A"+this.radiusX.toString()+" "+this.radiusY.toString()+" "+this.xAxisRotation.toString()+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+this.endX.toString()+" "+this.endY.toString():e="A"+i(this.radiusX)+" "+i(this.radiusY)+" "+i(this.xAxisRotation)+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+i(this.endX)+" "+i(this.endY);break;default:e=SegmentType[this.type]}return e+(this.isClosed?"z":"")}static Move=1;static Line=2;static Bezier=3;static QuadraticBezier=4;static Arc=5;static SvgArc=6;get f(){return(this.l&1)!==0}set f(t){t?this.l|=1:this.l&=-2}get Nt(){return(this.l&2)!==0}set Nt(t){t?this.l|=2:this.l&=-3}w(){return this.f=!0,this}ct(){return this.f=!1,this}close(){return this.isClosed=!0,this}To(t){if(this.Bs!==null&&t.Nt===!1)return this.Bs;const i=this.radiusX;let e=this.radiusY;if(e===void 0&&(e=i),i===0||e===0)return this.Bs=[],this.Bs;const s=this.dn,n=this.kl,o=Geo.kC(0,0,i1&&(o*=Math.sqrt(p),r*=Math.sqrt(p));let y=(h===a?-1:1)*Math.sqrt((o*o*r*r-o*o*g*g-r*r*m*m)/(o*o*g*g+r*r*m*m));isNaN(y)&&(y=0);let x=y*o*g/r,k=y*-r*m/o;isNaN(x)&&(x=0),isNaN(k)&&(k=0);const b=(s+f)/2+u*x-d*k,S=(n+c)/2+d*x+u*k,M=(X,z)=>Math.sqrt(X*X+z*z),A=(X,z,G,q)=>(X*G+z*q)/(M(X,z)*M(G,q)),C=(X,z,G,q)=>(X*q=1&&(F=0),!a&&F>0&&(F=F-2*Math.PI),a&&F<0&&(F=F+2*Math.PI);const I=o>r?o:r,O=o>r?1:o/r,B=o>r?r/o:1,K=Geo.kC(0,0,I,P,P+F,!0),V=Transform.a();return V.Bi(),V.Es(b,S),V.ms(this.dn,0,0),V.lt(O,B),Geometry.CC(K,V),Transform.o(V),this.Bs=K,this.Bs}get isClosed(){return(this.l&8)!==0}set isClosed(t){this.isClosed!==t&&(t?this.l|=8:this.l&=-9,this.Nt=!0)}get type(){return this.st}set type(t){Debug&&Util.tt(t,SegmentType,"SegmentType"),this.f&&Util.F(this,t),this.st=t,this.Nt=!0}get endX(){return this.ee}set endX(t){Debug&&Util.r(t,PathSegment,"endX"),this.f&&Util.F(this,t),this.ee=t,this.Nt=!0}get endY(){return this.se}set endY(t){Debug&&Util.r(t,PathSegment,"endY"),this.f&&Util.F(this,t),this.se=t,this.Nt=!0}get point1X(){return this.dn}set point1X(t){Debug&&Util.r(t,PathSegment,"point1X"),this.f&&Util.F(this,t),this.dn=t,this.Nt=!0}get point1Y(){return this.kl}set point1Y(t){Debug&&Util.r(t,PathSegment,"point1Y"),this.f&&Util.F(this,t),this.kl=t,this.Nt=!0}get point2X(){return this.Sl}set point2X(t){Debug&&Util.r(t,PathSegment,"point2X"),this.f&&Util.F(this,t),this.Sl=t,this.Nt=!0}get point2Y(){return this.xr}set point2Y(t){Debug&&Util.r(t,PathSegment,"point2Y"),this.f&&Util.F(this,t),this.xr=t,this.Nt=!0}get centerX(){return this.dn}set centerX(t){Debug&&Util.r(t,PathSegment,"centerX"),this.f&&Util.F(this,t),this.dn=t,this.Nt=!0}get centerY(){return this.kl}set centerY(t){Debug&&Util.r(t,PathSegment,"centerY"),this.f&&Util.F(this,t),this.kl=t,this.Nt=!0}get radiusX(){return this.Sl}set radiusX(t){Debug&&Util.r(t,PathSegment,"radiusX"),t<0&&Util.G(t,">= zero",PathSegment,"radiusX"),this.f&&Util.F(this,t),this.Sl=t,this.Nt=!0}get radiusY(){return this.xr}set radiusY(t){Debug&&Util.r(t,PathSegment,"radiusY"),t<0&&Util.G(t,">= zero",PathSegment,"radiusY"),this.f&&Util.F(this,t),this.xr=t,this.Nt=!0}get startAngle(){return this.ee}set startAngle(t){Debug&&Util.r(t,PathSegment,"startAngle"),this.f&&Util.F(this,t),t=t%360,t<0&&(t+=360),this.ee=t,this.Nt=!0}get sweepAngle(){return this.se}set sweepAngle(t){Debug&&Util.r(t,PathSegment,"sweepAngle"),this.f&&Util.F(this,t),t>360&&(t=360),t<-360&&(t=-360),this.se=t,this.Nt=!0}get isClockwiseArc(){return(this.l&4)!==0}set isClockwiseArc(t){this.f&&Util.F(this,t),t?this.l|=4:this.l&=-5,this.Nt=!0}get isLargeArc(){return(this.l&16)!==0}set isLargeArc(t){this.f&&Util.F(this,t),t?this.l|=16:this.l&=-17,this.Nt=!0}get xAxisRotation(){return this.dn}set xAxisRotation(t){Debug&&Util.r(t,PathSegment,"xAxisRotation"),this.f&&Util.F(this,t),t=t%360,t<0&&(t+=360),this.dn=t,this.Nt=!0}}class InputEvent{b;Ow;Ew;sm;nm;om;rm;lm;hm;am;fm;cm;um;dm;Do;gm;mm;pm;Ce;constructor(){this.b=null,this.Ow=new Point(0,0).w(),this.Ew=new Point(0,0).w(),this.sm=0,this.nm=0,this.om=1,this.rm="",this.lm="",this.hm=!1,this.am=!1,this.fm=0,this.cm=0,this.um=!1,this.dm=!1,this.Do=!1,this.gm=null,this.mm=0,this.pm=null,this.Ce=null}copy(){const t=new InputEvent;return this.clone(t)}clone(t){return t.b=this.b,t.Ow.c(this.viewPoint),t.Ew.c(this.documentPoint),t.sm=this.sm,t.nm=this.nm,t.om=this.om,t.rm=this.rm,t.lm=this.lm,t.hm=this.hm,t.am=this.am,t.fm=this.fm,t.cm=this.cm,t.um=this.um,t.dm=this.dm,t.Do=this.Do,t.gm=this.gm,t.mm=this.mm,t.pm=this.pm,t.Ce=this.Ce,t}toString(){let t="^";return this.modifiers!==0&&(t+="M:"+this.modifiers),this.button!==0&&(t+="B:"+this.button),this.key!==""&&(t+="K:"+this.key),this.clickCount!==0&&(t+="C:"+this.clickCount),this.delta!==0&&(t+="D:"+this.delta),this.handled&&(t+="h"),this.bubbles&&(t+="b"),this.documentPoint!==null&&(t+="@"+this.documentPoint.toString()),t}get diagram(){return this.b}set diagram(t){this.b=t}get viewPoint(){return this.Ow}set viewPoint(t){Util.s(t,Point,InputEvent,"viewPoint"),this.Ow.c(t)}get documentPoint(){return this.Ew}set documentPoint(t){Util.s(t,Point,InputEvent,"documentPoint"),this.Ew.c(t)}getMultiTouchViewPoint(t,i){const e=this.diagram;return e===null||e.DC(this.event,t,i),i}getMultiTouchDocumentPoint(t,i){const e=this.diagram;return e===null||(e.DC(this.event,t,i),i.c(e.transformViewToDoc(i))),i}get modifiers(){return this.sm}set modifiers(t){this.sm=t}get button(){return this.nm}set button(t){if(this.nm=t,this.event===null)switch(t){case 0:this.buttons=1;return;case 1:this.buttons=4;return;case 2:this.buttons=2;return}}get buttons(){return this.om}set buttons(t){this.om=t}get key(){return this.rm}set key(t){this.rm=t}get code(){return this.lm}set code(t){this.lm=t}get down(){return this.hm}set down(t){this.hm=t}get up(){return this.am}set up(t){this.am=t}get clickCount(){return this.fm}set clickCount(t){this.fm=t}get delta(){return this.cm}set delta(t){this.cm=t}get isMultiTouch(){return this.um}set isMultiTouch(t){this.um=t}get handled(){return this.dm}set handled(t){this.dm=t}get bubbles(){return this.Do}set bubbles(t){this.Do=t}get event(){return this.gm}set event(t){this.gm=t}get isTouchEvent(){const t=this.event;return t===null?!1:t.pointerType==="touch"||t.pointerType==="pen"}get timestamp(){return this.mm}set timestamp(t){this.mm=t}get targetDiagram(){return this.pm}set targetDiagram(t){this.pm=t}get targetObject(){return this.Ce}set targetObject(t){this.Ce=t}get control(){return(this.modifiers&1)!==0}set control(t){this.modifiers=t?this.modifiers|1:this.modifiers&-2}get shift(){return(this.modifiers&4)!==0}set shift(t){this.modifiers=t?this.modifiers|4:this.modifiers&-5}get alt(){return(this.modifiers&2)!==0}set alt(t){this.modifiers=t?this.modifiers|2:this.modifiers&-3}get meta(){return(this.modifiers&8)!==0}set meta(t){this.modifiers=t?this.modifiers|8:this.modifiers&-9}get left(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===0:(this.buttons&1)!==0}set left(t){t?this.buttons|=1:this.buttons&=-2}get right(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===2:(this.buttons&2)!==0}set right(t){t?this.buttons|=2:this.buttons&=-3}get middle(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===1:(this.buttons&4)!==0}set middle(t){t?this.buttons|=4:this.buttons&=-5}get commandKey(){const t=this.code,i=this.key;return"cxvyzagCXVYZAG".includes(i)?i.toLowerCase():t==="KeyC"?"c":t==="KeyX"?"x":t==="KeyV"?"v":t==="KeyY"?"y":t==="KeyZ"?"z":t==="KeyA"?"a":t==="KeyG"?"g":t!==""?t:i}}class DiagramEvent{b;Tt;ym;wm;constructor(){this.b=null,this.Tt="",this.ym=null,this.wm=null}copy(){const t=new DiagramEvent;return t.b=this.b,t.Tt=this.Tt,t.ym=this.ym,t.wm=this.wm,t}toString(){let t="*"+this.name;return this.subject!==null&&(t+=":"+this.subject.toString()),this.parameter!==null&&(t+="("+this.parameter.toString()+")"),t}get diagram(){return this.b}set diagram(t){this.b=t}get name(){return this.Tt}set name(t){this.Tt=t}get subject(){return this.ym}set subject(t){this.ym=t}get parameter(){return this.wm}set parameter(t){this.wm=t}}var ChangeType=(w=>(w[w.Transaction=1]="Transaction",w[w.Property=2]="Property",w[w.Insert=3]="Insert",w[w.Remove=4]="Remove",w))(ChangeType||{});class ChangedEvent{xu;xm;gn;Ai;b;bu;df;gf;mf;pf;constructor(){this.xu=2,this.xm="",this.gn="",this.Ai=null,this.b=null,this.bu=null,this.df=null,this.gf=null,this.mf=null,this.pf=null}static Transaction=1;static Property=2;static Insert=3;static Remove=4;clear(){this.Ai=null,this.b=null,this.bu=null,this.df=null,this.gf=null,this.mf=null,this.pf=null}copy(){const t=new ChangedEvent;t.xu=this.xu,t.xm=this.xm,t.gn=this.gn,t.Ai=this.Ai,t.b=this.b,t.bu=this.bu;let i=this.df;return Util.Mt(i)&&typeof i.copyFrozen=="function"?t.df=i.copyFrozen():t.df=i,i=this.gf,Util.Mt(i)&&typeof i.copyFrozen=="function"?t.gf=i.copyFrozen():t.gf=i,i=this.mf,Util.Mt(i)&&typeof i.copyFrozen=="function"?t.mf=i.copyFrozen():t.mf=i,i=this.pf,Util.Mt(i)&&typeof i.copyFrozen=="function"?t.pf=i.copyFrozen():t.pf=i,t}fi(t){t in ChangeType?this.change=t:Util.ur(this,t)}toString(){let t="";return this.change===1?t+="* ":this.change===2?t+=this.model!==null?"!m":"!d":t+=(this.model!==null?"!m":"!d")+this.change,this.propertyName&&typeof this.propertyName=="string"&&(t+=" "+this.propertyName),this.modelChange&&this.modelChange!==this.propertyName&&(t+=" "+this.modelChange),t+=": ",this.change===1?this.oldValue!==null&&(t+=" "+this.oldValue):(this.object!==null&&(t+=Util.toString(this.object)),this.oldValue!==null&&(t+=" old: "+Util.toString(this.oldValue)),this.oldParam!==null&&(t+=" "+this.oldParam),this.newValue!==null&&(t+=" new: "+Util.toString(this.newValue)),this.newParam!==null&&(t+=" "+this.newParam)),t}getValue(t){return t?this.oldValue:this.newValue}getParam(t){return t?this.oldParam:this.newParam}canUndo(){return this.model!==null||this.diagram!==null}undo(){this.canUndo()&&(this.model!==null?this.model.changeState(this,!0):this.diagram!==null&&this.diagram.FC(this,!0))}canRedo(){return this.model!==null||this.diagram!==null}redo(){this.canRedo()&&(this.model!==null?this.model.changeState(this,!1):this.diagram!==null&&this.diagram.FC(this,!1))}get model(){return this.Ai}set model(t){this.Ai=t}get diagram(){return this.b}set diagram(t){this.b=t}get change(){return this.xu}set change(t){this.xu=t}get modelChange(){return this.xm}set modelChange(t){Debug&&Util.t(t,"string",ChangedEvent,"modelChange"),this.xm=t}get propertyName(){return this.gn}set propertyName(t){Debug&&typeof t!="string"&&Util.t(t,"function",ChangedEvent,"propertyName"),this.gn=t}get isTransactionFinished(){return this.xu===1&&(this.gn==="CommittedTransaction"||this.gn==="FinishedUndo"||this.gn==="FinishedRedo")}get object(){return this.bu}set object(t){this.bu=t}get oldValue(){return this.df}set oldValue(t){this.df=t}get oldParam(){return this.gf}set oldParam(t){this.gf=t}get newValue(){return this.mf}set newValue(t){this.mf=t}get newParam(){return this.pf}set newParam(t){this.pf=t}}class Transaction{RC;Tt;$k;constructor(){this.RC=new List().w(),this.Tt="",this.$k=!1}toString(t){let i="Transaction: "+this.name+" "+this.changes.count.toString()+(this.isComplete?"":", incomplete");if(t!==void 0&&t>0){const e=this.changes.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),t.w()}canUndo(){return this.isComplete}undo(){if(this.canUndo())for(let t=this.changes.count-1;t>=0;t--){const i=this.changes.elt(t);i!==null&&i.undo()}}canRedo(){return this.isComplete}redo(){if(!this.canRedo())return;const t=this.changes.count;for(let i=0;i=t;e--){const s=i.elt(e);s!==null&&s.undo(),i.ct(),i.removeAt(e)}i.w()}optimize(){if(!this.isComplete)return;const t=this.changes;t.ct();const i=new GMap;for(let s=0;s0&&t.setElt(r,null),o.set(n.propertyName,s))}let e=0;for(let s=0;se&&t.setElt(e,n),e++)}for(;t.length>e;)t.pop();t.w()}get changes(){return this.RC}get name(){return this.Tt}set name(t){this.Tt=t}get isComplete(){return this.$k}set isComplete(t){this.$k=t}}class UndoManager{Vw;Xi;IC;zs;Qk;bm;Jn;Bw;_k;mn;yf;zw;Xs;Xw;Yw;km;Kw;constructor(t){this.Vw=new GSet,this.Xi=!1,this.IC=new List().w(),this.zs=-1,this.Qk=999,this.Xs=!1,this.bm=null,this.Jn=0,this.Bw=!1,Debug&&(this.Bw=!0),this._k=23,this.mn=new List().w(),this.yf=new List,this.zw=!0,this.Xw=!1,this.Yw=!1,this.km=!1,this.Kw=!1,t&&Object.assign(this,t)}toString(t){let i="UndoManager "+this.historyIndex+"<"+this.history.count+"<="+this.maxHistoryLength;i+="[";let e=this.nestedTransactionNames.count;for(let s=0;s0&&(i+=" "),i+=this.nestedTransactionNames.elt(s);if(i+="]",t!==void 0&&t>0){e=this.history.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),this.zs=-1,t.w(),this.Xs=!1,this.bm=null,this.Jn=0,this.mn.ct(),this.mn.clear(),this.mn.w(),this.yf.clear(),this.Xw=!1,this.Yw=!1,this.km=!1,this.Kw=!1}copyProperties(t){this.isEnabled=t.isEnabled,this.maxHistoryLength=t.maxHistoryLength,this.ku=t.ku}addModel(t){this.Vw.add(t)}removeModel(t){this.Vw.delete(t)}startTransaction(t){if(t===void 0&&(t=""),t===null&&(t=""),this.isUndoingRedoing)return!1;this.zw===!0&&(this.zw=!1,this.Jn++,this.Ml||this.i("StartingFirstTransaction",t,this.currentTransaction),this.Jn>0&&this.Jn--),this.isEnabled&&(this.mn.ct(),this.mn.add(t),this.mn.w(),this.currentTransaction===null?this.yf.add(0):this.yf.add(this.currentTransaction.changes.count)),this.Jn++;const i=this.transactionLevel===1;return i&&(this.Ml||this.i("StartedTransaction",t,this.currentTransaction)),i}commitTransaction(t){return t===void 0&&(t=""),this.OC(!0,t)}rollbackTransaction(){return this.OC(!1,"")}OC(t,i){if(this.isUndoingRedoing)return!1;this.ku&&this.transactionLevel<1&&Util.at("Ending transaction without having started a transaction: "+i);const e=this.transactionLevel===1;let s=this.currentTransaction;e&&t&&(this.Ml||this.i("CommittingTransaction",i,s));let n=0;if(this.transactionLevel>0&&(this.Jn--,this.isEnabled)){const o=this.mn.count;o>0&&(i===""&&(i=this.mn.elt(0)),this.mn.ct(),this.mn.removeAt(o-1),this.mn.w());const r=this.yf.count;r>0&&(n=this.yf.elt(r-1),this.yf.removeAt(r-1))}if(e){if(t){if(this.km=!1,s===null&&i!==""&&(s=this.currentTransaction),this.isEnabled&&s!==null){const o=s;o.isComplete||(o.isComplete=!0,o.name=i),this.discardHistoryAfterIndex();const r=this.history;r.ct();const l=this.maxHistoryLength;if(l>=0){if(l===0)r.clear();else if(r.count>=l){const h=r.elt(0);h!==null&&h.clear(),r.removeAt(0),this.zs--}}l!==0&&(r.count===0||r.get(r.count-1)!==o)&&(r.add(o),this.zs++),r.w(),s=o}this.Ml||this.i("CommittedTransaction",i,s)}else{this.Xs=!0;try{this.isEnabled&&s!==null&&(s.isComplete=!0,s.undo())}finally{this.Ml||this.i("RolledBackTransaction",i,s),this.Xs=!1}s!==null&&s.clear()}return this.bm=null,this.Uw&&this.clear(),this.Uw=!1,this.Gw=!1,!0}else return this.isEnabled&&!t&&s!==null&&s._D(n),!1}discardHistoryAfterIndex(){if(this.isUndoingRedoing||!this.canRedo())return;const t=this.history;t.ct();for(let i=t.count-1;i>this.historyIndex;i--){const e=t.elt(i);e!==null&&e.clear(),t.removeAt(i),this.km=!0}t.w()}lE(t){this.Jn+=t,this.Jn<0&&(this.Jn=0)}canUndo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToUndo;return!!(t!==null&&t.canUndo())}undo(){if(!this.canUndo())return;const t=this.transactionToUndo;try{this.Xs=!0,this.i("StartingUndo","Undo",t),this.zs--,t.undo()}catch(i){Util.at("undo error: "+i.toString())}finally{this.i("FinishedUndo","Undo",t),this.Xs=!1}}canRedo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToRedo;return!!(t!==null&&t.canRedo())}redo(){if(!this.canRedo())return;const t=this.transactionToRedo;try{this.Xs=!0,this.i("StartingRedo","Redo",t),this.zs++,t.redo()}catch(i){Util.at("redo error: "+i.toString())}finally{this.i("FinishedRedo","Redo",t),this.Xs=!1}}i(t,i,e){e===void 0&&(e=null);const s=new ChangedEvent;s.change=1,s.propertyName=t,s.object=e,s.oldValue=i;const n=this.models;for(;n.next();){const o=n.value;s.model=o,o.Hw(s)}}handleChanged(t){if(this.isEnabled&&!this.isUndoingRedoing&&!this.skipsEvent(t)){let i=this.currentTransaction;i===null&&(i=new Transaction,this.bm=i);const e=t.copy(),s=i.changes;if(s.ct(),s.add(e),s.w(),this.ku&&this._k>0&&this.transactionLevel<=0&&!this.zw){const n=t.diagram;if(n!==null&&n.Yh===!1)return;Util.at("Change not within a transaction: "+e.toString()),this._k--}}}skipsEvent(t){if(t===null||t.change===1)return!0;const i=t.object;if(i===null)return!1;if(i.layer!==void 0){const e=i.layer;if(e!==null&&e.isTemporary)return!0}else if(i.isTemporary)return!0;return!1}get models(){return this.Vw.iterator}get isEnabled(){return this.Xi}set isEnabled(t){this.Xi=t}get transactionToUndo(){return this.historyIndex>=0&&this.historyIndex<=this.history.count-1?this.history.elt(this.historyIndex):null}get transactionToRedo(){return this.historyIndex0}get ku(){return this.Bw}set ku(t){this.Bw=t}get nestedTransactionNames(){return this.mn}get Uw(){return this.Xw}set Uw(t){this.Xw=t}get Gw(){return this.Yw}set Gw(t){this.Yw=t}get Ml(){return this.Kw}set Ml(t){this.Kw=t}get isJustDiscarded(){return this.km}}class Tool{b;Tt;Xi;tS;iS;Sm;EC;constructor(){GSet.vi(this),this.b=Diagram.Mm(),this.Tt="",this.Xi=!0,this.tS=!1,this.iS=null,this.EC=new InputEvent,this.Sm=-1}get diagram(){return this.b}set diagram(t){t instanceof Diagram&&(this.b=t)}toString(){return this.name!==""?this.name+" Tool":Util.hn(this.constructor)}updateAdornments(t){}canStart(){return this.isEnabled}doStart(){}doActivate(){this.isActive=!0}doDeactivate(){this.isActive=!1}doStop(){}doCancel(){this.transactionResult=null,this.stopTool()}stopTool(){const t=this.diagram;t.currentTool===this&&(t.currentTool=null,t.currentCursor="")}doMouseDown(){!this.isActive&&this.canStart()&&this.doActivate()}doMouseMove(){}doMouseUp(){this.stopTool()}doMouseWheel(){}canStartMultiTouch(){return!0}standardPinchZoomStart(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.H(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.H(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.o(e),Point.o(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){t.eS=t.scale;const n=s.x-e.x,o=s.y-e.y,r=Math.sqrt(n*n+o*o);t.sS=r,i.bubbles=!1}Point.o(e),Point.o(s)}standardPinchZoomMove(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.H(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.H(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.o(e),Point.o(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){const n=s.x-e.x,o=s.y-e.y,l=Math.sqrt(n*n+o*o)/t.sS,h=new Point((Math.min(s.x,e.x)+Math.max(s.x,e.x))/2,(Math.min(s.y,e.y)+Math.max(s.y,e.y))/2),a=t.eS*l,f=t.commandHandler;if(a!==t.scale&&f.canResetZoom(a)){const c=t.zoomPoint;t.zoomPoint=h,f.resetZoom(a),t.zoomPoint=c}i.bubbles=!1}Point.o(e),Point.o(s)}doKeyDown(){this.diagram.lastInput.code==="Escape"&&this.doCancel()}doKeyUp(){}startTransaction(t){return t===void 0&&(t=this.name),this.transactionResult=null,this.diagram.startTransaction(t)}stopTransaction(){const t=this.diagram;return this.transactionResult===null?t.rollbackTransaction():t.commitTransaction(this.transactionResult)}standardMouseSelect(){const t=this.diagram;if(!t.allowSelect)return;const i=t.lastInput,e=t.findPartAt(i.documentPoint,!1);if(e!==null){if(Util.cr?i.meta:i.control){t.V("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!s.isSelected),t.V("ChangedSelection",t.selection)}else if(i.shift){if(!e.isSelected){t.V("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!0),t.V("ChangedSelection",t.selection)}}else if(!e.isSelected){let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&t.select(s)}}else i.left&&!(Util.cr?i.meta:i.control)&&!i.shift&&t.clearSelection()}standardMouseClick(t,i){t===void 0&&(t=null),i===void 0&&(i=o=>!o.layer.isTemporary);const e=this.diagram,s=e.lastInput,n=e.findObjectAt(s.documentPoint,t,i);return s.targetObject=n,this.tF(n,s,e),s.handled}tF(t,i,e){if(i.handled=!1,t!==null&&!t.isEnabledObject())return;let s=0;i.left?i.clickCount===1?s=1:i.clickCount===2?s=2:s=1:i.right&&i.clickCount===1&&(s=3);let n="ObjectSingleClicked";if(t!==null){switch(s){case 1:n="ObjectSingleClicked";break;case 2:n="ObjectDoubleClicked";break;case 3:n="ObjectContextClicked";break}s!==0&&e.V(n,t)}else{switch(s){case 1:n="BackgroundSingleClicked";break;case 2:n="BackgroundDoubleClicked";break;case 3:n="BackgroundContextClicked";break}s!==0&&e.V(n)}if(t!==null)for(;t!==null;){let o=null;switch(s){case 1:o=t.click;break;case 2:o=t.doubleClick?t.doubleClick:t.click;break;case 3:o=t.contextClick;break}if(o!==null&&(o(i,t),i.handled))break;t=t.panel}else{let o=null;switch(s){case 1:o=e.click;break;case 2:o=e.doubleClick?e.doubleClick:e.click;break;case 3:o=e.contextClick;break}o!==null&&o(i)}}standardMouseOver(){const t=this.diagram,i=t.lastInput;if(t.animationManager.Si===!0)return;const e=t.skipsUndoManager;t.skipsUndoManager=!0;let s=t.viewportBounds.containsPoint(i.documentPoint)?t.findObjectAt(i.documentPoint,null,null):null;i.event&&(i.event.type==="pointercancel"||i.event.type==="pointerout")&&(s=null),i.targetObject=s;let n=!1;if(s!==t.wf){let o=t.wf;const r=o;for(t.wf=s,this.doCurrentObjectChanged(o,s),i.handled=!1;o!==null;){const l=o.mouseLeave;if(l!==null&&(s===o||s!==null&&s.isContainedBy(o)||(l(i,o,s),n=!0,i.handled)))break;o=o.panel}for(o=r,i.handled=!1;s!==null;){const l=s.mouseEnter;if(l!==null&&(o===s||o!==null&&o.isContainedBy(s)||(l(i,s,o),n=!0,i.handled)))break;s=s.panel}s=t.wf}if(s!==null){let o=s,r="";for(;o!==null&&(r=o.cursor,r==="");)o=o.panel;for(t.currentCursor=r,i.handled=!1,o=s;o!==null;){const l=o.mouseOver;if(l!==null&&(l(i,o),n=!0,i.handled))break;o=o.panel}}else{this.doUpdateCursor(null);const o=t.mouseOver;o!==null&&(o(i),n=!0)}n&&t.requestUpdate(),t.skipsUndoManager=e}doUpdateCursor(t){const i=this.diagram;i&&(i.currentCursor="")}doCurrentObjectChanged(t,i){}standardMouseWheel(){const t=this.diagram,i=t.lastInput;let e=i.delta;if(e===0||!t.documentBounds.isReal())return;const s=t.commandHandler,n=t.toolManager.mouseWheelBehavior;if(s!==null&&(n===2&&!i.shift||n===1&&i.control)){if(e>0?s.canIncreaseZoom():s.canDecreaseZoom()){const o=t.zoomPoint;t.zoomPoint=i.viewPoint,e>0?s.increaseZoom():s.decreaseZoom(),t.zoomPoint=o}i.bubbles=!1}else if(n===2&&i.shift||n===1&&!i.control){const o=t.position.copy(),r=i.event,l=r.deltaMode;let h=r.deltaX,a=r.deltaY,f="pixel";if((h!==0||a!==0)&&!i.shift){switch(l){case 0:f="pixel";break;case 1:f="line";break;case 2:f="page";break}if(h!==0&&t.allowHorizontalScroll){const c=t.scrollHorizontalLineChange;h=h*(c/16),t.scroll(f,h>0?"right":"left",Math.abs(h))}if(a!==0&&t.allowVerticalScroll){const c=t.scrollVerticalLineChange;a=a*(c/16),t.scroll(f,a>0?"down":"up",Math.abs(a))}}else!i.shift&&t.allowVerticalScroll?(e=e*3*t.scrollVerticalLineChange,t.scroll(f,e>0?"up":"down",Math.abs(e))):i.shift&&t.allowHorizontalScroll&&(e=e*3*t.scrollHorizontalLineChange,t.scroll(f,e>0?"left":"right",Math.abs(e)));this.doWheelChange(t,o,i)}}doWheelChange(t,i,e){(!t.position.equals(i)||e.event.wheelDeltaX!==0)&&(e.bubbles=!1)}standardWaitAfter(t,i){Debug&&Util.t(t,"number",Tool,"standardWaitAfter:delay"),i===void 0&&(i=this.diagram.lastInput),this.cancelWaitAfter();const e=this,s=i.clone(this.EC);this.Sm=Util.Bh(()=>e.doWaitAfter(s),t)}cancelWaitAfter(){this.Sm!==-1&&Util.Ug(this.Sm),this.Sm=-1}doWaitAfter(t){}findToolHandleAt(t,i){const s=this.diagram.findObjectAt(t,n=>{for(;n!==null&&!(n.panel instanceof Adornment);)n=n.panel;return n});return s===null?null:s.part.category===i?s:null}isBeyondDragSize(t,i){const e=this.diagram;t===void 0&&(t=e.firstInput.viewPoint),i===void 0&&(i=e.lastInput.viewPoint);const s=e.toolManager.dragSize;let n=s.width,o=s.height;return e.firstInput.isTouchEvent&&(n+=6,o+=6),Math.abs(i.x-t.x)>n||Math.abs(i.y-t.y)>o}get name(){return this.Tt}set name(t){Util.t(t,"string",Tool,"name"),this.Tt=t}get isEnabled(){return this.Xi}set isEnabled(t){Util.t(t,"boolean",Tool,"isEnabled"),this.Xi=t}get isActive(){return this.tS}set isActive(t){Util.t(t,"boolean",Tool,"isActive"),this.tS=t}get transactionResult(){return this.iS}set transactionResult(t){t!==null&&Util.t(t,"string",Tool,"transactionResult"),this.iS=t}}var WheelMode=(w=>(w[w.Scroll=1]="Scroll",w[w.Zoom=2]="Zoom",w[w.None=3]="None",w))(WheelMode||{}),GestureMode=(w=>(w[w.Zoom=1]="Zoom",w[w.Cancel=2]="Cancel",w[w.None=3]="None",w))(GestureMode||{});class ToolManager extends Tool{VC;BC;zC;nS;oS;rS;lS;hS;aS;fS;Pm;Kh;constructor(t){super(),this.name="ToolManager",this.VC=new List,this.BC=new List,this.zC=new List,this.nS=850,this.oS=850,this.rS=new Size(2,2).ot(),this.lS=5e3,this.hS=1,this.aS=1,this.fS=null,this.Pm=null,this.Kh=-1,t&&Object.assign(this,t)}static WheelScroll=1;static WheelZoom=2;static WheelNone=3;static GestureZoom=1;static GestureCancel=2;static GestureNone=3;get mouseWheelBehavior(){return this.hS}set mouseWheelBehavior(t){Util.tt(t,WheelMode,"WheelMode"),this.hS=t}get gestureBehavior(){return this.aS}set gestureBehavior(t){Util.tt(t,GestureMode,"GestureMode"),this.aS=t}initializeStandardTools(){}updateAdornments(t){const i=this.currentToolTip;if(i instanceof Adornment&&this.Pm===t){const e=i.adornedObject;(t!==null?e.part===t:e===null)?this.showToolTip(i,e):this.hideToolTip()}}doMouseDown(){const t=this.diagram,i=t.lastInput;if(i.isTouchEvent&&this.gestureBehavior===2&&(i.bubbles=!1),i.isMultiTouch){if(this.cancelWaitAfter(),this.gestureBehavior===3){i.bubbles=!0;return}if(this.gestureBehavior===2)return;if(t.currentTool.canStartMultiTouch()){t.currentTool.standardPinchZoomStart();return}}const e=t.undoManager;Debug&&e.ku&&e.transactionLevel!==0&&Util.at("WARNING: In ToolManager.doMouseDown: UndoManager.transactionLevel is not zero");const s=this.mouseDownTools.length;for(let n=0;n0&&s!==1/0){const n=this;this.Kh=Util.Bh(()=>n.hideToolTip(),s)}}positionToolTip(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom?n.y-=o.height+5/s.scale:n.y+=20/s.scale,n.y30&&t.jw(),t.Ww(this.draggedParts),t.Pu=!0,this.startTransaction("Drag"),this.startPoint=t.firstInput.documentPoint,t.isMouseCaptured=!0,t.allowDragOut&&this.eF()}MS(t){if(this.dragsLink){const i=this.diagram;if(!i.allowRelink)return;i.model.kf()&&t.count===1&&t.first()instanceof Link?(this.draggedLink=t.first(),this.draggedLink.canRelinkFrom()&&this.draggedLink.canRelinkTo()&&this.draggedLink.clearAdornments(),this.pn=i.toolManager.findTool("Relinking"),this.pn===null&&(this.pn=new RelinkingTool,this.pn.diagram=i),this.pn.originalLink=this.draggedLink):(this.draggedLink=null,this.pn=null)}}computeEffectiveCollection(t,i){return this.diagram.commandHandler.computeEffectiveCollection(t,i)}Ys(t){return t===void 0?new DraggingInfo(Point.Lo):this.isGridSnapEnabled?new DraggingInfo(new Point(Math.round(t.x*1e3)/1e3,Math.round(t.y*1e3)/1e3)):new DraggingInfo(t.copy())}doDeactivate(){this.isActive=!1;const t=this.diagram;this.diagram.layout.isRealtime=this.SS,t.Pu=!1,t.Pl=!0,t.cacheGroupExternalLinks(!1),t.stopAutoScroll(),this.PS(),t.Cm(this.draggedParts),this.Mu=null,this.currentPart=null,this.draggedParts=null,this.isDragOutStarted=!1,this.Su=!1,DraggingTool.sF(),this.YC(),this.xf.e(NaN,NaN),DraggingTool.Gh!==null&&(DraggingTool.Gh.currentCursor=""),DraggingTool.Gh=null,DraggingTool.St=null,this.Nl(),t.isMouseCaptured=!1,t.currentCursor="",t.bf=!1,this.stopTransaction(),t.NS(!0)}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}PS(){const t=this.diagram,i=t.skipsUndoManager;t.skipsUndoManager=!0;const e=t.lastInput;this.KC(e,null),t.skipsUndoManager=i,this.br.length=0}UC(){this.Nl(),this.CS();const t=this.diagram;this.xf.isReal()&&(t.position=this.xf),t.stopAutoScroll()}doCancel(){this.Nl(),this.CS();const t=this.diagram;this.xf.isReal()&&(t.position=this.xf),this.stopTool()}doKeyDown(){const t=this.diagram,i=t.lastInput;this.isActive&&(i.code==="Escape"?this.doCancel():i.code!==t.previousInput.code&&this.doMouseMove())}doKeyUp(){this.isActive&&this.doMouseMove()}nF(t,i){let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=t.iterator;for(;r.next();){const l=r.value;if(!l.isVisible())continue;const h=l.location,a=h.x,f=h.y;isNaN(a)||isNaN(f)||(an&&(n=a),f>o&&(o=f))}return e===1/0?i.e(0,0,0,0):i.e(e,s,n-e,o-s),i}AS(t){if(this.copiedParts!==null)return;const i=this.diagram;if(t&&(i.isReadOnly||i.isModelReadOnly)||this.draggedParts===null)return;const e=i.undoManager;e.isEnabled&&e.isInTransaction?e.currentTransaction!==null&&e.currentTransaction.changes.count>0&&(i.undoManager.rollbackTransaction(),i.startTransaction("Drag")):this.CS(),i.skipsUndoManager=!t,i.partManager.addsToTemporaryLayer=!t,this.startPoint=i.firstInput.documentPoint;const s=this.copiesEffectiveCollection?this.draggedParts.toKeySet():i.selection,n=i.copyParts(s,i,!0),o=new GMap,r=this.draggedParts.iterator;for(;r.next();){const h=r.key;if(h.Ae()&&h.canCopy()){const a=n.get(h);if(a===null)continue;a.location=h.location,a.ensureBounds(),o.set(a,this.Ys(a.location))}}const l=n.iterator;for(;l.next();){const h=l.value;h instanceof Link&&h.canCopy()&&o.set(h,this.Ys())}if(this.copiedParts=o,this.MS(o.toKeySet()),this.draggedLink!==null){const h=this.draggedLink,a=h.routeBounds;h.kr(this.startPoint.x-(a.x+a.width/2),this.startPoint.y-(a.y+a.height/2))}this.doUpdateCursor(null)}Nl(){const t=this.diagram;if(this.copiedParts!==null){if(t.removeParts(this.copiedParts.toKeySet(),!1),this.copiedParts=null,this.draggedParts!==null){const i=this.draggedParts.iterator;for(;i.next();)if(i.key instanceof Link){const s=i.value;s.point=new Point(0,0)}}this.doUpdateCursor(null)}t.skipsUndoManager=!1,t.partManager.addsToTemporaryLayer=!1,this.startPoint=t.firstInput.documentPoint}YC(){this.draggedLink!==null&&(this.dragsLink&&this.pn!==null&&(this.pn.stopDraggingMouseMove(),this.pn.originalLink=null),this.draggedLink=null,this.pn=null)}Sf(t,i){const e=this.diagram,s=this.startPoint,n=Point.a();n.c(e.lastInput.documentPoint),this.moveParts(t,n.subtract(s),i),Point.o(n),e.getRenderingHint("temporaryPixelRatio")===!0&&e.Cl===null&&e.avgSpf>30&&(e.jw(),e.Nu())}moveParts(t,i,e){e===void 0&&(e=!1);const s=this.diagram;s!==null&&s.LS(t,i,this.dragOptions,e)}CS(){if(this.draggedParts===null)return;const t=this.diagram;let i=this.draggedParts.iterator;for(;i.next();){const e=i.key;e.Ae()&&(e.location=i.value.point)}for(i=this.draggedParts.iterator;i.next();){const e=i.key;if(e instanceof Link&&e.suspendsRouting){const s=i.value.point;this.draggedParts.set(e,this.Ys()),e.kr(-s.x,-s.y)}}t.maybeUpdate()}oF(t){if(t===null)return!0;const i=t.part;return!!(i===null||i instanceof Adornment||i.layer.isTemporary||this.draggedParts&&this.draggedParts.has(i)||this.copiedParts&&this.copiedParts.has(i))}TS(t){const i=this.diagram;this.dragsLink&&(this.draggedLink!==null&&(this.draggedLink.fromNode=null,this.draggedLink.toNode=null),this.GC(!1));const e=this.findDragOverObject(t),s=i.lastInput;s.targetObject=e,this.doUpdateCursor(e);const n=i.skipsUndoManager;let o=!1;try{if(i.skipsUndoManager=!0,o=this.KC(s,e),!this.isActive&&DraggingTool.St===null)return;const r=e!==null?e.part:null;if(r===null||i.handlesDragDropForTopLevelParts&&r.isTopLevel&&!(r instanceof Group)){const l=i.mouseDragOver;l!==null&&(l(s),o=!0)}if(!this.isActive&&DraggingTool.St===null||(this.doDragOver(t,e),!this.isActive&&DraggingTool.St===null))return}finally{i.skipsUndoManager=n,o&&i.maybeUpdate()}this.Mu=e,!i.isReadOnly&&(i.allowMove||i.allowCopy)&&(i.allowHorizontalScroll||i.allowVerticalScroll)&&i.doAutoScroll(s.viewPoint)}findDragOverObject(t){return this.diagram.DS(t,null,i=>!this.oF(i))}doUpdateCursor(t){const i=this.diagram;(t===null||this.Mu!==t)&&(!this.diagram.currentTool.isActive||this.mayCopy()?i.currentCursor=this.copyCursor:this.mayMove()?i.currentCursor=this.moveCursor:this.mayDragOut()&&(i.currentCursor=this.nodropCursor))}KC(t,i){let e=!1,s=this.br.length;const n=s>0?this.br[0]:null;if(i===n)return!1;t.handled=!1;for(let r=0;rs.findValidLinkablePort(a,i)),r=Point.a();let l=1/0,h=null;for(const a=o.iterator;a.next();){const f=a.value;if(f.part===null)continue;const u=f.getDocumentPoint(Spot.Center,r),d=t.distanceSquaredPoint(u);dh.suspendsRouting=!1)}if(this.doDropOnto(t,e),!this.isActive&&DraggingTool.St===null)return;const o=Rect.a(),r=i.selection.iterator;for(;r.next();){const l=r.value;l instanceof Node&&this.lF(i,l,o)}Rect.o(o)}rF(t,i){const e=this.diagram,s=i.part;if(e.handlesDragDropForTopLevelParts&&s.isTopLevel&&!(s instanceof Group)){const n=e.mouseDrop;n!==null&&n(t)}}lF(t,i,e){if(!i.canAvoid())return;let s=!1;e=i.getAvoidableRect(e),t.viewportBounds.containsRect(e)&&(s=!0);const n=this.copiedParts||this.draggedParts,o=t.IS(e,l=>l.part,l=>l instanceof Link,!0,l=>l instanceof Link,s);if(o.count===0)return;const r=o.iterator;for(;r.next();){const l=r.value;n.has(l)&&n.has(i)||!l.isMemberOf(i)&&l.isAvoiding&&l.invalidateRoute()}}doDropOnto(t,i){}doMouseMove(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseMove(i.event,i.documentPoint,i.targetDiagram))return;this.currentPart!==null&&this.draggedParts!==null&&(this.mayCopy()?(this.AS(!1),t.Ww(this.copiedParts),this.Sf(this.copiedParts,!1),t.Cm(this.copiedParts)):this.mayMove()?(this.Nl(),this.Sf(this.draggedParts,!0)):this.mayDragOut()?(this.AS(!1),this.Sf(this.copiedParts,!1)):this.Nl(),this.TS(t.lastInput.documentPoint))}doMouseUp(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseUp(i.event,i.documentPoint,i.targetDiagram))return;let e=!1;const s=this.mayCopy();if(s&&this.copiedParts!==null?(this.Nl(),this.AS(!0),t.Ww(this.copiedParts),this.Sf(this.copiedParts,!1),t.Cm(this.copiedParts),this.copiedParts!==null&&(t.V("ChangingSelection",t.selection),t.clearSelection(!0),this.copiedParts.iteratorKeys.each(n=>{n.isSelected=!0}))):(e=!0,this.Nl(),this.mayMove()&&(this.Sf(this.draggedParts,!0),this.TS(t.lastInput.documentPoint))),this.Su=!0,this.jC(t.lastInput.documentPoint),this.isActive){const n=s?this.copiedParts.toKeySet():this.draggedParts.toKeySet();this.copiedParts=null,e&&this.hF(),t.invalidateDocumentBounds(),t.Cm(this.draggedParts),this.transactionResult=s?"Copy":"Move",t.V(s?"SelectionCopied":"SelectionMoved",n)}this.stopTool(),s&&t.V("ChangedSelection",t.selection)}simulatedMouseMove(t,i,e){if(DraggingTool.St===null)return!1;const s=DraggingTool.St.diagram;e instanceof Diagram||(e=null);const n=DraggingTool.Gh;if(e!==n){if(n!==null&&n!==s){n.stopAutoScroll(),DraggingTool.St.isDragOutStarted=!1;const r=n.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDragLeave()}if(DraggingTool.Gh=e,e!==null&&e!==s){DraggingTool.St.UC();const r=e.toolManager.findTool("Dragging");r!==null&&(r.WC(),r.doSimulatedDragEnter())}this.doUpdateCursor(null)}if(e===null||e===s||!e.allowDrop||e.isReadOnly||!e.allowInsert)return!1;const o=e.toolManager.findTool("Dragging");if(o!==null){let r=i;t!==null&&(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),r=e.getMouse(t)),e.lastInput.documentPoint=r,e.lastInput.viewPoint=e.transformDocToView(r),e.lastInput.down=!1,e.lastInput.up=!1,o.doSimulatedDragOver()}return!0}simulatedMouseUp(t,i,e){if(DraggingTool.St===null)return!1;const s=DraggingTool.Gh,n=DraggingTool.St.diagram;if(e===null)return DraggingTool.St.doCancel(),!0;if(e!==s){const o=s.toolManager.findTool("Dragging");if(s!==null&&s!==n&&o!==null)return s.stopAutoScroll(),DraggingTool.St.isDragOutStarted=!1,o.doSimulatedDragLeave(),!1;DraggingTool.Gh=e;const r=e.toolManager.findTool("Dragging");r!==null&&(DraggingTool.St.UC(),r.WC(),r.doSimulatedDragEnter())}if(e!==this.diagram){let o=i;t!==null?(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),o=e.getMouse(t)):o===null&&(o=new Point),e.lastInput.documentPoint=o,e.lastInput.viewPoint=e.transformDocToView(o),e.lastInput.down=!1,e.lastInput.up=!0;const r=e.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDrop();const l=DraggingTool.St;if(l!==null){const h=l.mayCopy();l.transactionResult=h?"Copy":"Move",l.stopTool()}return!0}return!1}hF(){if(this.draggedParts===null)return;const t=this.draggedParts.iterator;for(;t.next();){const i=t.key;if(i instanceof Node){const e=i.containingGroup;e!==null&&e.hasPlaceholder()&&!this.draggedParts.has(e)&&e.placeholder.u()}}}mayCopy(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowCopy||!(Util.cr?t.lastInput.alt:t.lastInput.control))return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayDragOut(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(!t.allowDragOut||!t.allowCopy||t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayMove(){const t=this.diagram;if(t.isReadOnly||!t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canMove())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canMove())}WC(){DraggingTool.vw.has(this)||DraggingTool.vw.add(this)}static sF(){if(DraggingTool.vw.count>0){const t=DraggingTool.vw,i=t.length;for(let e=0;e{n.isSelected=!0,s.add(n)})),this.jC(t.lastInput.documentPoint),t.invalidateDocumentBounds(),this.copiedParts!==null&&(this.transactionResult="ExternalCopy"),this.copiedParts=null,t.doFocus(),t.bf=!1,t.V("ExternalObjectsDropped",s,e),this.stopTransaction(),t.V("ChangedSelection",t.selection)}t.animationManager.Cu=!1}vC(t,i,e){if(this.copiedParts!==null)return;const s=this.diagram;if(s.isReadOnly||s.isModelReadOnly)return;s.skipsUndoManager=!i,s.partManager.addsToTemporaryLayer=!i,this.startPoint=e.documentPoint;const n=s.copyParts(t,s,!0),o=Rect.a();this.nF(t,o);const r=o.x+o.width/2,l=o.y+o.height/2;Rect.o(o);const h=this.Nm,a=new GMap,f=Point.a(),c=t.iterator;for(;c.next();){const d=c.value;if(d instanceof Link&&d.canCopy()){const m=n.get(d);if(m===null)continue;m.points=d.points,m.kr(h.x-r,h.y-l),m.suspendsRouting=!0,a.set(m,this.Ys())}}const u=t.iterator;for(;u.next();){const d=u.value;if(d.Ae()&&d.canCopy()){const m=n.get(d);if(m===null)continue;const g=d.location;f.e(h.x-(r-g.x),h.y-(l-g.y)),m.location=f,m.ensureBounds(),a.set(m,this.Ys(f))}}if(Point.o(f),this.copiedParts=a,this.MS(a.toKeySet()),this.draggedLink!==null){const d=this.draggedLink,m=d.routeBounds;d.kr(this.startPoint.x-(m.x+m.width/2),this.startPoint.y-(m.y+m.height/2))}this.doUpdateCursor(null)}eF(){this.isDragOutStarted=!0,this.Su=!1,DraggingTool.St=this,DraggingTool.Gh=this.diagram,this.doSimulatedDragOut()}doSimulatedDragOut(){const t=this.diagram;t.bf=!1,!this.mayCopy()&&!this.mayMove()?t.currentCursor=this.nodropCursor:t.currentCursor="",this.Mu=null}computeMove(t,i,e,s){const n=this.diagram;return n!==null?n.computeMove(t,i,this.dragOptions,s):new Point}static vw=new List;static St=null;static Gh=null}ToolManager.prototype.doCancel=function(){DraggingTool.St!==null&&DraggingTool.St.doCancel(),Tool.prototype.doCancel.call(this)};class LinkingBaseTool extends Tool{OS;ES;Al;VS;BS;Hh;zS;qh;XS;YS;KS;US;GS;HS;JC;qS;Ll;jS;constructor(){super(),this.OS=100,this.ES=!1,this.Al="pointer",this.VS=new Link({layerName:"Tool"}).add(new Shape({isPanelMain:!0,stroke:"blue"}).theme("stroke","tempLink"),new Shape({toArrow:"Standard",fill:"blue",stroke:"blue"}).theme("fill","tempLink").theme("stroke","tempLink")).ci(),this.Hh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.zk}).theme("stroke","tempPort"),this.BS=new Node({selectable:!1,layerName:"Tool"}).add(this.Hh).ci(),this.qh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.zk}).theme("stroke","tempPort"),this.zS=new Node({selectable:!1,layerName:"Tool"}).add(this.qh).ci(),this.XS=null,this.YS=null,this.KS=null,this.US=null,this.GS=null,this.HS=!0,this.JC=new GMap,this.qS=null,this.Ll=null,this.jS=null}doStop(){this.diagram.stopAutoScroll(),this.originalLink=null,this.originalFromNode=null,this.originalFromPort=null,this.originalToNode=null,this.originalToPort=null,this.validPortsCache.clear(),this.targetPort=null}get portGravity(){return this.OS}set portGravity(t){Util.t(t,"number",LinkingBaseTool,"portGravity"),t>=0&&(this.OS=t)}get isUnconnectedLinkValid(){return this.ES}set isUnconnectedLinkValid(t){Util.t(t,"boolean",LinkingBaseTool,"isUnconnectedLinkValid"),this.ES=t}get linkingCursor(){return this.Al}set linkingCursor(t){this.Al=t}get temporaryLink(){return this.VS}set temporaryLink(t){Util.s(t,Link,LinkingBaseTool,"temporaryLink"),t.ci(),this.VS=t}get temporaryFromNode(){return this.BS}set temporaryFromNode(t){Util.s(t,Node,LinkingBaseTool,"temporaryFromNode"),t.ci(),this.BS=t,t&&(this.Hh=t.port)}get temporaryFromPort(){return this.Hh}set temporaryFromPort(t){if(Util.s(t,GraphObject,LinkingBaseTool,"temporaryFromPort"),this.Hh!==null){const i=this.Hh.panel;if(i!==null){const e=i.D.indexOf(this.Hh);i.removeAt(e),i.insertAt(e,t)}}this.Hh=t}get temporaryToNode(){return this.zS}set temporaryToNode(t){Util.s(t,Node,LinkingBaseTool,"temporaryToNode"),t.ci(),this.zS=t,t&&(this.qh=t.port)}get temporaryToPort(){return this.qh}set temporaryToPort(t){if(Util.s(t,GraphObject,LinkingBaseTool,"temporaryToPort"),this.qh!==null){const i=this.qh.panel;if(i!==null){const e=i.D.indexOf(this.qh);i.removeAt(e),i.insertAt(e,t)}}this.qh=t}get originalLink(){return this.XS}set originalLink(t){t!==null&&Util.s(t,Link,LinkingBaseTool,"originalLink"),this.XS=t}get originalFromNode(){return this.YS}set originalFromNode(t){t!==null&&Util.s(t,Node,LinkingBaseTool,"originalFromNode"),this.YS=t}get originalFromPort(){return this.KS}set originalFromPort(t){t!==null&&Util.s(t,GraphObject,LinkingBaseTool,"originalFromPort"),this.KS=t}get originalToNode(){return this.US}set originalToNode(t){t!==null&&Util.s(t,Node,LinkingBaseTool,"originalToNode"),this.US=t}get originalToPort(){return this.GS}set originalToPort(t){t!==null&&Util.s(t,GraphObject,LinkingBaseTool,"originalToPort"),this.GS=t}get isForwards(){return this.HS}set isForwards(t){this.HS=t}get validPortsCache(){return this.JC}get targetPort(){return this.qS}set targetPort(t){t!==null&&Util.s(t,GraphObject,LinkingBaseTool,"targetPort"),this.qS=t}copyPortProperties(t,i,e,s,n){if(t===null||i===null||e===null||s===null)return;const o=i.getDocumentScale(),r=Size.a();r.width=i.naturalBounds.width*o,r.height=i.naturalBounds.height*o,s.desiredSize=r,Size.o(r),n?(s.toSpot=i.toSpot,s.toEndSegmentLength=i.toEndSegmentLength):(s.fromSpot=i.fromSpot,s.fromEndSegmentLength=i.fromEndSegmentLength),e.locationSpot=Spot.Center;const l=Point.a();e.location=i.getDocumentPoint(Spot.Center,l),Point.o(l),s.angle=i.getDocumentAngle(),this.portTargeted!==null&&this.portTargeted(t,i,e,s,n)}setNoTargetPortProperties(t,i,e){i!==null&&(i.desiredSize=Size.zk,i.fromSpot=Spot.None,i.toSpot=Spot.None),t!==null&&(t.location=this.diagram.lastInput.documentPoint),this.portTargeted!==null&&this.portTargeted(null,null,t,i,e)}doMouseDown(){this.isActive&&this.doMouseMove()}doMouseMove(){if(this.isActive){const t=this.diagram;if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null&&this.targetPort.part instanceof Node){const i=this.targetPort.part;this.isForwards?this.copyPortProperties(i,this.targetPort,this.temporaryToNode,this.temporaryToPort,!0):this.copyPortProperties(i,this.targetPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else this.isForwards?this.setNoTargetPortProperties(this.temporaryToNode,this.temporaryToPort,!0):this.setNoTargetPortProperties(this.temporaryFromNode,this.temporaryFromPort,!1);(t.allowHorizontalScroll||t.allowVerticalScroll)&&t.doAutoScroll(t.lastInput.viewPoint)}}findValidLinkablePort(t,i){if(t===null)return null;const e=t.part;if(!(e instanceof Node))return null;for(;t!==null;){const s=i?t.toLinkable:t.fromLinkable;if(s===!0&&(t.portId!==null||t instanceof Node)&&(i?this.isValidTo(e,t):this.isValidFrom(e,t)))return t;if(s===!1)return null;t=t.panel}return null}findTargetPort(t){const i=this.diagram,e=i.lastInput.documentPoint;let s=this.portGravity;s<=0&&(s=.1);const n=this,o=i.findObjectsNear(e,s,a=>n.findValidLinkablePort(a,t),null,!0);let r=1/0,l=null;const h=o.iterator;for(;h.next();){const a=h.value,f=a.part;if(!(f instanceof Node))continue;const c=a.getDocumentPoint(Spot.Center,Point.a()),u=e.x-c.x,d=e.y-c.y;Point.o(c);const m=u*u+d*d;if(m=e)return!1}return!0}isValidTo(t,i){if(t===null||i===null)return this.isUnconnectedLinkValid;if(this.diagram.currentTool===this&&(t.layer!==null&&!t.layer.allowLink||i.toLinkable!==!0))return!1;const e=i.toMaxLinks;if(e<1/0){if(this.originalLink!==null&&t===this.originalToNode&&i===this.originalToPort)return!0;let s=i.portId;if(s===null&&(s=""),t.findLinksInto(s).count>=e)return!1}return!0}isInSameNode(t,i){if(t===null||i===null)return!1;if(t===i)return!0;const e=t.part,s=i.part;return e!==null&&e===s}isLinked(t,i){if(t===null||i===null)return!1;const e=t.part;if(!(e instanceof Node))return!1;let s=t.portId;s===null&&(s="");const n=i.part;if(!(n instanceof Node))return!1;let o=i.portId;o===null&&(o="");const r=n.findLinksInto(o);for(;r.next();){const l=r.value;if(l.fromNode===e&&l.fromPortId===s)return!0}return!1}isValidLink(t,i,e,s){if(!this.isValidFrom(t,i)||!this.isValidTo(e,s)||i!==null&&s!==null&&(!(i.fromLinkableSelfNode&&s.toLinkableSelfNode)&&this.isInSameNode(i,s)||!(i.fromLinkableDuplicates&&s.toLinkableDuplicates)&&this.isLinked(i,s))||this.originalLink!==null&&(t!==null&&this.isLabelDependentOnLink(t,this.originalLink)||e!==null&&this.isLabelDependentOnLink(e,this.originalLink))||t!==null&&e!==null&&(t.data===null&&e.data!==null||t.data!==null&&e.data===null)||!this.isValidCycle(t,e,this.originalLink))return!1;let n;return t!==null&&(n=t.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))||e!==null&&(n=e.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))?!1:(n=this.linkValidation,n!==null?n(t,i,e,s,this.originalLink):!0)}isLabelDependentOnLink(t,i){if(t===null)return!1;const e=t.labeledLink;if(e===null)return!1;if(e===i)return!0;const s=new GSet;return s.add(t),this.WS(e,i,s)}WS(t,i,e){if(t===i)return!0;const s=t.fromNode;if(s!==null&&s.isLinkLabel&&(e.add(s),this.WS(s.labeledLink,i,e)))return!0;const n=t.toNode;return!!(n!==null&&n.isLinkLabel&&(e.add(n),this.WS(n.labeledLink,i,e)))}isValidCycle(t,i,e){if(e===void 0&&(e=null),t===null||i===null)return this.isUnconnectedLinkValid;const s=this.diagram;let n=1;if(s&&(s.model.Mf()?n=s.isTreePathToChildren?5:6:n=s.validCycle),n===1)return!0;if(n===5){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=i.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.toNode===i)return!1}return!this.Au(t,i,e,!0)}else if(n===6){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=t.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.fromNode===t)return!1}return!this.Au(t,i,e,!0)}else{if(n===2)return!this.aF(t,i,e);if(n===3)return!this.Au(t,i,e,!1);if(n===4)return!this.fF(t,i,e)}return!0}Au(t,i,e,s){if(t===i)return!0;if(t===null||i===null)return!1;const n=t.linksConnected;for(;n.next();){const o=n.value;if(o===e||s&&!o.isTreeLink||o.toNode!==t)continue;const r=o.fromNode;if(r!==t&&this.Au(r,i,e,s))return!0}return!1}aF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.ZC(s,t,i,e)}ZC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s||o.toNode!==i)continue;const r=o.fromNode;if(r!==i&&this.ZC(t,r,e,s))return!0}return!1}fF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.$C(s,t,i,e)}$C(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s)continue;const r=o.fromNode,l=o.toNode,h=r===i?l:r;if(h!==i&&this.$C(t,h,e,s))return!0}return!1}get linkValidation(){return this.Ll}set linkValidation(t){t!==null&&Util.t(t,"function",LinkingBaseTool,"linkValidation"),this.Ll=t}get portTargeted(){return this.jS}set portTargeted(t){t!==null&&Util.t(t,"function",LinkingBaseTool,"portTargeted"),this.jS=t}}var LinkingDirection=(w=>(w[w.Either=1]="Either",w[w.ForwardsOnly=2]="ForwardsOnly",w[w.BackwardsOnly=3]="BackwardsOnly",w))(LinkingDirection||{});class LinkingTool extends LinkingBaseTool{vS;JS;C;ZS;constructor(t){super(),this.name="Linking",this.vS={},this.JS=null,this.C=1,this.ZS=null,t&&Object.assign(this,t)}static Either=1;static ForwardsOnly=2;static BackwardsOnly=3;get archetypeLinkData(){return this.vS}set archetypeLinkData(t){t!==null&&Util.t(t,"object",LinkingTool,"archetypeLinkData"),t instanceof GraphObject&&Util.s(t,Link,LinkingTool,"archetypeLinkData"),this.vS=t}get archetypeLabelNodeData(){return this.JS}set archetypeLabelNodeData(t){t!==null&&Util.t(t,"object",LinkingTool,"archetypeLabelNodeData"),t instanceof GraphObject&&Util.s(t,Node,LinkingTool,"archetypeLabelNodeData"),this.JS=t}get direction(){return this.C}set direction(t){Util.tt(t,LinkingDirection,"LinkingDirection"),this.C=t}get startObject(){return this.ZS}set startObject(t){t!==null&&Util.s(t,GraphObject,LinkingTool,"startObject"),this.ZS=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||t.isModelReadOnly||!t.allowLink||!t.model.Jw()||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize()?!1:this.findLinkablePort()!==null}findLinkablePort(){const t=this.diagram;let i=this.startObject;if(i===null&&(i=t.findObjectAt(t.firstInput.documentPoint,null,null)),i===null)return null;const e=i.part;if(!(e instanceof Node))return null;const s=this.direction;if(s===1||s===2){const n=this.findValidLinkablePort(i,!1);if(n!==null)return this.isForwards=!0,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!1))return this.isForwards=!0,o}}if(s===1||s===3){const n=this.findValidLinkablePort(i,!0);if(n!==null)return this.isForwards=!1,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!0))return this.isForwards=!1,o}}return null}doActivate(){const t=this.diagram,i=this.findLinkablePort();if(i===null){this.stopTool();return}if(this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.isForwards){this.temporaryToNode!==null&&(this.temporaryToNode.location=t.lastInput.documentPoint),this.originalFromPort=i;const e=this.originalFromPort.part;e instanceof Node&&(this.originalFromNode=e),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else{this.temporaryFromNode!==null&&(this.temporaryFromNode.location=t.lastInput.documentPoint),this.originalToPort=i;const e=this.originalToPort.part;e instanceof Node&&(this.originalToNode=e),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0)}t.add(this.temporaryFromNode),this.temporaryFromNode&&this.temporaryFromNode.ensureBounds(),t.add(this.temporaryToNode),this.temporaryToNode&&this.temporaryToNode.ensureBounds(),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.temporaryLink.isTreeLink=this.isNewTreeLink(),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.startObject=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=null,e=null,s=null,n=null,o=null;try{this.targetPort=this.findTargetPort(this.isForwards);const r=this.targetPort;if(r!==null){const l=r.part;l instanceof Node&&(this.isForwards?(this.originalFromNode!==null&&(i=this.originalFromNode,e=this.originalFromPort),s=l,n=r):(i=l,e=r,this.originalToNode!==null&&(s=this.originalToNode,n=this.originalToPort)))}else this.isForwards?this.originalFromNode!==null&&this.isUnconnectedLinkValid&&(i=this.originalFromNode,e=this.originalFromPort):this.originalToNode!==null&&this.isUnconnectedLinkValid&&(s=this.originalToNode,n=this.originalToPort);i!==null||s!==null?(o=this.insertLink(i,e,s,n),o!==null?(r===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint),t.allowSelect&&(t.V("ChangingSelection",t.selection),t.clearSelection(!0),o.isSelected=!0),this.transactionResult=this.name,t.V("LinkDrawn",o)):this.doNoLink(i,e,s,n)):this.isForwards?this.doNoLink(this.originalFromNode,this.originalFromPort,null,null):this.doNoLink(null,null,this.originalToNode,this.originalToPort)}finally{this.stopTool(),o&&t.allowSelect&&t.V("ChangedSelection",t.selection)}}}isNewTreeLink(){const t=this.archetypeLinkData;if(t===null)return!0;if(t instanceof Link)return t.isTreeLink;const i=this.diagram;if(i===null)return!0;const e=i.partManager.getLinkCategoryForData(t),s=i.partManager.findLinkTemplateForCategory(e);return s!==null?s.isTreeLink:!0}insertLink(t,i,e,s){return this.diagram.partManager.insertLink(t,i,e,s)}doNoLink(t,i,e,s){}}class RelinkingTool extends LinkingBaseTool{$S;QS;ps;_S;constructor(t){super(),this.name="Relinking",this.$S=new Shape("Diamond",{desiredSize:Size.gu,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:0}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.QS=new Shape("Diamond",{desiredSize:Size.gu,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:-1}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.ps=null,this._S=new Rect,t&&Object.assign(this,t)}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i="RelinkFrom",e=null;if(t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkFrom()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null&&(e=this.makeAdornment(s,!1),t.addAdornment(i,e)))}if(e===null&&t.removeAdornment(i),i="RelinkTo",e=null,t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkTo()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null?(e=this.makeAdornment(s,!0),t.addAdornment(i,e)):e.u())}e===null&&t.removeAdornment(i)}makeAdornment(t,i){const e=new Adornment;e.type=Panel.Link;const s=i?this.toHandleArchetype:this.fromHandleArchetype;return s!==null&&e.add(s.copy().Am()),e.adornedObject=t,e}get fromHandleArchetype(){return this.$S}set fromHandleArchetype(t){t!==null&&Util.s(t,GraphObject,RelinkingTool,"fromHandleArchetype"),this.$S=t}get toHandleArchetype(){return this.QS}set toHandleArchetype(t){t!==null&&Util.s(t,GraphObject,RelinkingTool,"toHandleArchetype"),this.QS=t}get handle(){return this.ps}set handle(t){if(t!==null&&(Util.s(t,GraphObject,RelinkingTool,"handle"),!(t.part instanceof Adornment)))throw new Error("new handle is not in an Adornment: "+t);this.ps=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowRelink||!t.model.Jw()||!t.lastInput.left)return!1;let e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom");return e===null&&(e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo")),e!==null}doActivate(){const t=this.diagram;if(this.originalLink===null){let i=this.handle;if(i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom"),i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo"))),i===null)return;const e=i.part;if(!(e instanceof Adornment)||!(e.adornedPart instanceof Link))return;this.handle=i,this.isForwards=e===null||e.category==="RelinkTo",this.originalLink=e.adornedPart}this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.originalFromPort=this.originalLink.fromPort,this.originalFromNode=this.originalLink.fromNode,this.originalToPort=this.originalLink.toPort,this.originalToNode=this.originalLink.toNode,this._S.set(this.originalLink.actualBounds),this.originalLink!==null&&this.originalLink.pointsCount>0&&(this.originalLink.fromNode===null&&(this.temporaryFromPort!==null&&(this.temporaryFromPort.desiredSize=Size.lf),this.temporaryFromNode!==null&&(this.temporaryFromNode.location=this.originalLink.getPoint(0))),this.originalLink.toNode===null&&(this.temporaryToPort!==null&&(this.temporaryToPort.desiredSize=Size.lf),this.temporaryToNode!==null&&(this.temporaryToNode.location=this.originalLink.getPoint(this.originalLink.pointsCount-1)))),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0),t.add(this.temporaryFromNode),t.add(this.temporaryToNode),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.copyLinkProperties(this.originalLink,this.temporaryLink),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}copyLinkProperties(t,i){if(t===null||i===null)return;i.adjusting=t.adjusting,i.corner=t.corner;let e=t.curve;(e===11||e===10)&&(e=0),i.curve=e,i.curviness=t.curviness,i.isTreeLink=t.isTreeLink,i.points=t.points,i.routing=t.routing,i.smoothness=t.smoothness,i.fromSpot=t.fromSpot,i.fromEndSegmentLength=t.fromEndSegmentLength,i.fromShortLength=t.fromShortLength,i.toSpot=t.toSpot,i.toEndSegmentLength=t.toEndSegmentLength,i.toShortLength=t.toShortLength}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.handle=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=this.originalFromNode,e=this.originalFromPort,s=this.originalToNode,n=this.originalToPort,o=this.originalLink;try{if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null){const r=this.targetPort.part;r instanceof Node&&(this.isForwards?(s=r,n=this.targetPort):(i=r,e=this.targetPort))}else this.isUnconnectedLinkValid?this.isForwards?(s=null,n=null):(i=null,e=null):o=null;o!==null?(this.reconnectLink(o,this.isForwards?s:i,this.isForwards?n:e,this.isForwards),this.targetPort===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint,o.invalidateRoute()),this.transactionResult=this.name,t.V("LinkRelinked",o,this.isForwards?this.originalToPort:this.originalFromPort)):this.doNoRelink(this.originalLink,this.isForwards),this.originalLink.invalidateOtherJumpOvers(this._S)}finally{this.stopTool()}}}reconnectLink(t,i,e,s){const n=e!==null&&e.portId!==null?e.portId:"";return s?(t.toNode=i,t.toPortId=n):(t.fromNode=i,t.fromPortId=n),!0}doNoRelink(t,i){}doDraggingMouseMove(t,i,e,s){t!==null?(this.copyPortProperties(t,i,this.temporaryFromNode,this.temporaryFromPort,!1),this.diagram.add(this.temporaryFromNode)):this.diagram.remove(this.temporaryFromNode),e!==null?(this.copyPortProperties(e,s,this.temporaryToNode,this.temporaryToPort,!0),this.diagram.add(this.temporaryToNode)):this.diagram.remove(this.temporaryToNode)}stopDraggingMouseMove(){this.diagram.remove(this.temporaryFromNode),this.diagram.remove(this.temporaryToNode)}}var ReshapingBehavior=(w=>(w[w.None=0]="None",w[w.Horizontal=1]="Horizontal",w[w.Vertical=2]="Vertical",w[w.All=3]="All",w))(ReshapingBehavior||{});class LinkReshapingTool extends Tool{Fo;tM;iM;ps;Zw;eM;Lm;constructor(t){super(),this.name="LinkReshaping",this.Fo=new Shape("Rectangle",{desiredSize:Size.aC,fill:"lightblue",stroke:"dodgerblue"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.tM=new Shape("Diamond",{desiredSize:Size.gu,fill:"lightblue",stroke:"dodgerblue",cursor:"move"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.iM=3,this.ps=null,this.Zw=null,this.eM=new Point,this.Lm=new List,t&&Object.assign(this,t)}static None=0;static Horizontal=1;static Vertical=2;static All=3;getReshapingBehavior(t){return t?t.Mr:0}setReshapingBehavior(t,i){t.Mr=i}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i=null;if(t.isSelected&&!this.diagram.isReadOnly){const e=t.path;e!==null&&t.canReshape()&&t.actualBounds.isReal()&&t.isVisible()&&e.actualBounds.isReal()&&e.isVisibleObject()&&(i=t.findAdornment(this.name),(i===null||i.sM!==t.pointsCount||i.nM!==t.resegmentable)&&(i=this.makeAdornment(e),i!==null&&(i.sM=t.pointsCount,i.nM=t.resegmentable,t.addAdornment(this.name,i))))}i===null&&t.removeAdornment(this.name)}makeAdornment(t){const i=t.part,e=i.points,s=i.pointsCount,n=i.isOrthogonal;let o=null;if(e!==null&&s>1){o=new Adornment,o.type=Panel.Link;const r=i.firstPickIndex,l=i.lastPickIndex,h=n?1:0;if(i.resegmentable&&i.computeCurve()!==9)for(let a=r+h;ae.firstPickIndex+1&&s0))this.cF(t,i);else if(t instanceof Panel){const e=t.elements;for(;e.next();){const s=e.value;this.updateResizeHandles(s,i)}}}}cF(t,i){let e=t.alignment;e.isNoSpot()&&(e=Spot.Center);let s=i;if(e.x<=0)e.y<=0?s+=225:e.y>=1?s+=135:s+=180;else if(e.x>=1)e.y<=0?s+=315:e.y>=1&&(s+=45);else if(e.y<=0)s+=270;else if(e.y>=1)s+=90;else return;s<0?s+=360:s>=360&&(s-=360),s<22.5?t.cursor="e-resize":s<67.5?t.cursor="se-resize":s<112.5?t.cursor="s-resize":s<157.5?t.cursor="sw-resize":s<202.5?t.cursor="w-resize":s<247.5?t.cursor="nw-resize":s<292.5?t.cursor="n-resize":s<337.5?t.cursor="ne-resize":t.cursor="e-resize"}get handleArchetype(){return this.Fo}set handleArchetype(t){t!==null&&Util.s(t,GraphObject,ResizingTool,"handleArchetype"),this.Fo=t}get handle(){return this.ps}set handle(t){if(t!==null&&(Util.s(t,GraphObject,ResizingTool,"handle"),!(t.part instanceof Adornment)))throw new Error("new handle is not in an Adornment: "+t);this.ps=t}get adornedObject(){return this.ys}set adornedObject(t){if(t!==null&&(Util.s(t,GraphObject,ResizingTool,"handle"),t.part instanceof Adornment))throw new Error("new handle must not be in an Adornment: "+t);this.ys=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowResize||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle!==null&&(this.adornedObject=this.handle.part.adornedObject,this.adornedObject!==null&&(t.isMouseCaptured=!0,t.animationManager.stopAnimation(),t.Pu=!0,this.startTransaction(this.name),this.Tm.set(this.adornedObject.getDocumentPoint(this.handle.alignment.opposite())),this.Nf.set(this.adornedObject.part.location),this.rM.set(this.adornedObject.desiredSize),this._w=this.computeCellSize(),this.$w=this.computeMinSize(),this.Qw=this.computeMaxSize(),this.isActive=!0))}doDeactivate(){const t=this.diagram;t.Pu=!1,t.Pl=!0,this.stopTransaction(),this.handle=null,this.ys=null,t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){this.adornedObject!==null&&(this.adornedObject.desiredSize=this.originalDesiredSize,this.adornedObject.part.location=this.originalLocation),this.stopTool()}doMouseMove(){const t=this.diagram;if(!this.isActive)return;const i=this.$w,e=this.Qw,s=this._w,n=t.lastInput.documentPoint,o=this.adornedObject.getLocalPoint(n,Point.a()),r=this.computeReshape(),l=this.computeResize(o,this.handle.alignment,i,e,s,r);this.resize(l),t.maybeUpdate(),Point.o(o)}doMouseUp(){const t=this.diagram;if(this.isActive){const i=this.$w,e=this.Qw,s=this._w,n=this.adornedObject.getLocalPoint(t.lastInput.documentPoint,Point.a()),o=this.computeReshape(),r=this.computeResize(n,this.handle.alignment,i,e,s,o);this.resize(r),Point.o(n),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.V("PartResized",this.adornedObject,this.originalDesiredSize)}this.stopTool()}resize(t){const i=this.diagram,e=this.adornedObject;if(e===null)return;e.desiredSize=t.size;const s=e.part;s.ensureBounds();const n=e.getDocumentPoint(this.handle.alignment.opposite());if(s instanceof Group){const o=new List;o.add(s);let r;!this.dragsMembers&&!s.hasPlaceholder()&&(r=new DraggingOptions,r.dragsMembers=!1),i.moveParts(o,this.oppositePoint.copy().subtract(n),!0,r)}else s.location=s.location.copy().subtract(n).add(this.oppositePoint);i.maybeUpdate()}computeResize(t,i,e,s,n,o){i.isNoSpot()&&(i=Spot.Center);const r=this.adornedObject.naturalBounds,l=r.x,h=r.y,a=r.x+r.width,f=r.y+r.height;let c=1;if(!o){let m=r.width,g=r.height;m<=0&&(m=1),g<=0&&(g=1),c=g/m}const u=Point.a();Geo.Hg(t.x,t.y,l,h,n.width,n.height,u);const d=r.copy();return i.x<=0?i.y<=0?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.y=Math.max(u.y,f-s.height),d.y=Math.min(d.y,f-e.height),d.height=Math.max(f-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width),d.x=a-d.width,d.y=f-d.height)):i.y>=1?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width),d.x=a-d.width)):(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=a-d.x,o||(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c,d.y=h+.5*(f-h-d.height))):i.x>=1?i.y<=0?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.y=Math.max(u.y,f-s.height),d.y=Math.min(d.y,f-e.height),d.height=Math.max(f-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width),d.y=f-d.height)):i.y>=1?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width))):(d.width=Math.max(Math.min(u.x-l,s.width),e.width),o||(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c,d.y=h+.5*(f-h-d.height))):i.y<=0?(d.y=Math.max(u.y,f-s.height),d.y=Math.min(d.y,f-e.height),d.height=f-d.y,o||(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width,d.x=l+.5*(a-l-d.width))):i.y>=1&&(d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width,d.x=l+.5*(a-l-d.width))),Point.o(u),d}computeReshape(){let t=0;return this.adornedObject instanceof Shape&&(t=this.adornedObject.lM()),!(t===6||this.diagram.lastInput.shift)}computeMinSize(){const t=this.adornedObject.minSize.copy(),i=this.minSize;return!isNaN(i.width)&&i.width>t.width&&(t.width=i.width),!isNaN(i.height)&&i.height>t.height&&(t.height=i.height),t}computeMaxSize(){const t=this.adornedObject.maxSize.copy(),i=this.maxSize;return!isNaN(i.width)&&i.width0&&(t.width=n.width),!isNaN(n.height)&&n.height>0&&(t.height=n.height)}let e=this.cellSize;isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height);const s=this.diagram;if((isNaN(t.width)||isNaN(t.height))&&s){const n=s.grid;n!==null&&n.visible&&this.isGridSnapEnabled&&(e=n.gridCellSize,isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height))}return(isNaN(t.width)||t.width===0||t.width===1/0)&&(t.width=1),(isNaN(t.height)||t.height===0||t.height===1/0)&&(t.height=1),t}get minSize(){return this.Pr}set minSize(t){if(Util.s(t,Size,ResizingTool,"minSize"),!this.Pr.equals(t)){let e=t.width;isNaN(e)&&(e=0);let s=t.height;isNaN(s)&&(s=0),this.Pr.e(e,s)}}get maxSize(){return this.Nr}set maxSize(t){if(Util.s(t,Size,ResizingTool,"maxSize"),!this.Nr.equals(t)){let e=t.width;isNaN(e)&&(e=1/0);let s=t.height;isNaN(s)&&(s=1/0),this.Nr.e(e,s)}}get cellSize(){return this.Ro}set cellSize(t){Util.s(t,Size,ResizingTool,"cellSize"),this.Ro.equals(t)||this.Ro.c(t)}get isGridSnapEnabled(){return this.Pf}set isGridSnapEnabled(t){Util.t(t,"boolean",ResizingTool,"isGridSnapEnabled"),this.Pf=t}get dragsMembers(){return this.oM}set dragsMembers(t){Util.t(t,"boolean",ResizingTool,"dragsMembers"),this.oM=t}get oppositePoint(){return this.Tm}set oppositePoint(t){Util.s(t,Point,ResizingTool,"oppositePoint"),this.Tm.equals(t)||this.Tm.c(t)}get originalDesiredSize(){return this.rM}get originalLocation(){return this.Nf}}class RotatingTool extends Tool{hM;aM;ys;Fo;ps;fM;Dm;Nf;cM;uM;constructor(t){super(),this.name="Rotating",this.hM=45,this.aM=2,this.Nf=new Point,this.ys=null,this.Fo=new Shape("Ellipse",{desiredSize:Size.gu,fill:"lightblue",stroke:"dodgerblue",strokeWidth:1,cursor:"pointer"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.ps=null,this.fM=0,this.Dm=new Point(NaN,NaN),this.cM=0,this.uM=50,t&&Object.assign(this,t)}updateAdornments(t){if(t!==null){if(t.Dl()){const i=t.rotateObject;if(i===t||i===t.path||i.isPanelMain)return}if(t.isSelected&&!this.diagram.isReadOnly){const i=t.rotateObject;if(i!==null&&t.canRotate()&&t.actualBounds.isReal()&&t.isVisible()&&i.actualBounds.isReal()&&i.isVisibleObject()){let e=t.findAdornment(this.name);if((e===null||e.adornedObject!==i)&&(e=this.makeAdornment(i)),e!==null){e.angle=i.getDocumentAngle(),e.hasPlaceholder()||(e.location=this.computeAdornmentLocation(i)),t.addAdornment(this.name,e);return}}}t.removeAdornment(this.name)}}makeAdornment(t){let i=null;const e=t.part.rotateAdornmentTemplate;if(e===null){i=new Adornment,i.type=Panel.Position,i.locationSpot=Spot.Center;const s=this.handleArchetype;s!==null&&i.add(s.copy().Am())}else if(e.ci(),i=e.copy(),i===null)return null;return i.adornedObject=t,i}get handleArchetype(){return this.Fo}set handleArchetype(t){t!==null&&Util.s(t,GraphObject,RotatingTool,"handleArchetype"),this.Fo=t}get handle(){return this.ps}set handle(t){if(t!==null&&(Util.s(t,GraphObject,RotatingTool,"handle"),!(t.part instanceof Adornment)))throw new Error("new handle is not in an Adornment: "+t);this.ps=t}get adornedObject(){return this.ys}set adornedObject(t){if(t!==null&&(Util.s(t,GraphObject,RotatingTool,"handle"),t.part instanceof Adornment))throw new Error("new handle must not be in an Adornment: "+t);this.ys=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowRotate||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;if(this.adornedObject===null){if(this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle===null)return;this.adornedObject=this.handle.part.adornedObject}this.adornedObject!==null&&(t.isMouseCaptured=!0,t.delaysLayout=!0,this.startTransaction(this.name),this.fM=this.adornedObject.angle,this.Dm=this.computeRotationPoint(this.adornedObject),this.Nf=this.adornedObject.part.location.copy(),this.isActive=!0)}computeRotationPoint(t){const i=t.part,e=i.locationObject;return i.rotationSpot.isSpot()?t.getDocumentPoint(i.rotationSpot):t===i||t===e?e.getDocumentPoint(i.locationSpot):t.getDocumentPoint(Spot.Center)}computeAdornmentLocation(t){let i=this.rotationPoint;i.isReal()||(i=this.computeRotationPoint(t));const e=t.getLocalPoint(i);let s=this.handleAngle;s<0?s+=360:s>=360&&(s-=360),s=Math.round(Math.round(s/45)*45);const n=this.handleDistance;return s===0?e.x=t.naturalBounds.width+n:s===45?(e.x=t.naturalBounds.width+n,e.y=t.naturalBounds.height+n):s===90?e.y=t.naturalBounds.height+n:s===135?(e.x=-n,e.y=t.naturalBounds.height+n):s===180?e.x=-n:s===225?(e.x=-n,e.y=-n):s===270?e.y=-n:s===315&&(e.x=t.naturalBounds.width+n,e.y=-n),t.getDocumentPoint(e)}doDeactivate(){const t=this.diagram;this.stopTransaction(),this.handle=null,this.ys=null,this.Dm=new Point(NaN,NaN),t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){const t=this.diagram;t.delaysLayout=!1,this.rotate(this.originalAngle),this.stopTool()}doMouseMove(){const t=this.diagram;if(this.isActive){const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i)}}doMouseUp(){const t=this.diagram;if(this.isActive){t.delaysLayout=!1;const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.V("PartRotated",this.adornedObject,this.originalAngle)}this.stopTool()}rotate(t){Debug&&Util.r(t,RotatingTool,"rotate:newangle");const i=this.adornedObject;if(i===null)return;i.angle=t;const e=i.part;e.ensureBounds();const s=e.locationObject,n=e.rotateObject;if(s===n||s.isContainedBy(n)){const o=this.Nf.copy();e.location=o.subtract(this.rotationPoint).rotate(t-this.originalAngle).add(this.rotationPoint)}this.diagram.maybeUpdate()}computeRotate(t){let i=this.rotationPoint.directionPoint(t)-this.handleAngle;const e=this.adornedObject.panel;e!==null&&(i-=e.getDocumentAngle()),i>=360?i-=360:i<0&&(i+=360);const s=Math.min(Math.abs(this.snapAngleMultiple),180),n=Math.min(Math.abs(this.snapAngleEpsilon),s/2);return!this.diagram.lastInput.shift&&s>0&&n>0&&(i%ss-n&&(i=(Math.floor(i/s)+1)*s)),i>=360?i-=360:i<0&&(i+=360),i}get snapAngleMultiple(){return this.hM}set snapAngleMultiple(t){Util.t(t,"number",RotatingTool,"snapAngleMultiple"),this.hM=t}get snapAngleEpsilon(){return this.aM}set snapAngleEpsilon(t){Util.t(t,"number",RotatingTool,"snapAngleEpsilon"),this.aM=t}get originalAngle(){return this.fM}get rotationPoint(){return this.Dm}set rotationPoint(t){this.Dm=t.copy()}get handleAngle(){return this.cM}set handleAngle(t){Util.t(t,"number",RotatingTool,"handleAngle"),this.cM=t}get handleDistance(){return this.uM}set handleDistance(t){Util.t(t,"number",RotatingTool,"handleDistance"),this.uM=t}}class ClickSelectingTool extends Tool{constructor(t){super(),this.name="ClickSelecting",t&&Object.assign(this,t)}canStart(){return!(!this.isEnabled||this.isBeyondDragSize())}doMouseUp(){this.isActive&&(this.standardMouseSelect(),this.standardMouseClick()||this.diagram.lastInput.isTouchEvent&&this.diagram.toolManager.doToolTip()),this.stopTool()}}class ActionTool extends Tool{Cf;constructor(t){super(),this.name="Action",this.Cf=null,t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram,i=t.lastInput,e=t.findObjectAt(i.documentPoint,s=>{for(;s.panel!==null;){if(s.isActionable)return s;s=s.panel}return s});return e!==null&&e.isActionable?(this.Cf=e,t.wf=t.findObjectAt(i.documentPoint,null,null),!0):!1}doMouseDown(){if(!this.isActive)this.canStart()&&this.doActivate();else{const i=this.diagram.lastInput,e=this.Cf;if(e===null)return;i.targetObject=e,e.actionDown!==null&&e.actionDown(i,e)}}doMouseMove(){if(this.isActive){const i=this.diagram.lastInput,e=this.Cf;if(e===null)return;i.targetObject=e,e.actionMove!==null&&e.actionMove(i,e)}}doMouseUp(){if(this.isActive){const i=this.diagram.lastInput,e=this.Cf;if(e===null)return;i.targetObject=e,e.actionUp!==null&&e.actionUp(i,e),this.standardMouseClick(s=>{for(;s.panel!==null;){if(s.isActionable&&s===e)return s;s=s.panel}return s},s=>s===e)}this.stopTool()}doCancel(){const i=this.diagram.lastInput,e=this.Cf;e!==null&&(i.targetObject=e,e.actionCancel!==null&&e.actionCancel(i,e),this.stopTool())}doStop(){this.Cf=null}}class ClickCreatingTool extends Tool{Fl;dM;Pf;gM;constructor(t){super(),this.name="ClickCreating",this.Fl=null,this.dM=!0,this.Pf=!1,this.gM=new Point(0,0),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled||this.archetypeNodeData===null)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.lastInput.left||this.isBeyondDragSize())return!1;if(this.isDoubleClick){if(t.lastInput.clickCount===1&&(this.gM=t.lastInput.viewPoint.copy()),t.lastInput.clickCount!==2||this.isBeyondDragSize(this.gM))return!1}else if(t.lastInput.clickCount!==1)return!1;return!(t.currentTool!==this&&t.findPartAt(t.lastInput.documentPoint,!0)!==null)}doMouseUp(){const t=this.diagram;this.isActive&&this.insertPart(t.lastInput.documentPoint),this.stopTool()}insertPart(t){const i=this.diagram,e=this.archetypeNodeData;if(e===null)return null;let s=null;try{if(i.V("ChangingSelection",i.selection),this.startTransaction(this.name),e instanceof Part)e.Ae()&&(e.ci(),s=e.copy(),s!==null&&i.add(s));else if(e!==null){const n=i.model.copyNodeData(e);Util.Mt(n)&&(i.model.addNodeData(n),s=i.findPartForData(n))}if(s!==null){const n=Point.H(t.x,t.y);this.isGridSnapEnabled&&this.diagram.mM(s,t,n),s.location=n,i.allowSelect&&(i.clearSelection(!0),s.isSelected=!0),Point.o(n)}i.invalidateDocumentBounds(),this.transactionResult=this.name,i.V("PartCreated",s)}finally{this.stopTransaction(),i.V("ChangedSelection",i.selection)}return s}get archetypeNodeData(){return this.Fl}set archetypeNodeData(t){t!==null&&Util.t(t,"object",ClickCreatingTool,"archetypeNodeData"),this.Fl=t}get isDoubleClick(){return this.dM}set isDoubleClick(t){Util.t(t,"boolean",ClickCreatingTool,"isDoubleClick"),this.dM=t}get isGridSnapEnabled(){return this.Pf}set isGridSnapEnabled(t){Util.t(t,"boolean",ClickCreatingTool,"isGridSnapEnabled"),this.Pf=t}}class DragSelectingTool extends Tool{Uh;pM;Rl;constructor(t){super(),this.name="DragSelecting",this.Uh=175,this.pM=!1,this.Rl=new Part({layerName:"Tool",selectable:!1}).add(new Shape("Rectangle",{name:"SHAPE",fill:null,stroke:"magenta"}).theme("stroke","dragSelect")).ci(),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(!t.allowSelect)return!1;const i=t.lastInput;return!(!i.left||t.currentTool!==this&&(!this.isBeyondDragSize()||i.timestamp-t.firstInput.timestamp{const e=i.diagram;e!==null&&e.Li(root.document,"scroll",i.yM,!1),i.stopTool()},t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return!(!t.allowHorizontalScroll&&!t.allowVerticalScroll||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize())}doActivate(){const t=this.diagram;this.Do?(t.lastInput.bubbles=!0,t.Ht(root.document,"scroll",this.yM,!1)):(t.currentCursor="move",t.isMouseCaptured=!0,this.tx.c(t.position)),this.isActive=!0}doDeactivate(){const t=this.diagram;t.currentCursor="",t.isMouseCaptured=!1,this.isActive=!1}doCancel(){const t=this.diagram;t.position=this.tx,t.isMouseCaptured=!1,this.stopTool()}doMouseMove(){this._C()}doMouseUp(){this._C(),this.stopTool()}_C(){const t=this.diagram;if(this.isActive&&t){if(this.Do){t.lastInput.bubbles=!0;return}const i=t.position,e=t.firstInput.documentPoint,s=t.lastInput.documentPoint;let n=i.x+e.x-s.x,o=i.y+e.y-s.y;t.allowHorizontalScroll||(n=i.x),t.allowVerticalScroll||(o=i.y),t.position=this.QC.e(n,o)}}get bubbles(){return this.Do}set bubbles(t){Util.t(t,"boolean",PanningTool,"bubbles"),this.Do=t}get originalPosition(){return this.tx}}class HTMLInfo{ix;ex;wM;xM;constructor(t){this.ix=null,this.ex=null,this.wM=null,this.xM=null,t&&Object.assign(this,t)}get mainElement(){return this.wM}set mainElement(t){t!==null&&Util.s(t,HTMLElement,HTMLInfo,"mainElement"),this.wM=t}get show(){return this.ix}set show(t){this.ix!==t&&(t!==null&&Util.t(t,"function",HTMLInfo,"show"),this.ix=t)}get hide(){return this.ex}set hide(t){this.ex!==t&&(t!==null&&Util.t(t,"function",HTMLInfo,"hide"),this.ex=t)}get valueFunction(){return this.xM}set valueFunction(t){this.xM=t}}class ContextMenuButtonInfo{ui;Fm;Lf;constructor(t,i,e){this.ui=t,this.Fm=i,this.Lf=e}}class ContextMenuTool extends Tool{bM;sx;kM;SM;nx;ox;Rm;constructor(t){super(),this.name="ContextMenu",this.bM=null,this.sx=null,this.kM=null,this.SM=new Point,this.nx=null,this.Rm=!1;const i=this;this.ox=()=>i.stopTool(),t&&Object.assign(this,t)}uF(){const t=new HTMLInfo;t.show=(r,l,h)=>h.showDefaultContextMenu(),t.hide=(r,l)=>l.hideDefaultContextMenu(),ContextMenuTool.Lu=t;const i=this;this.ox=()=>i.stopTool();const e=Util.ln("div"),s=Util.ln("div");e.style.cssText="top: 0px;z-index:10002;position: fixed;display: none;text-align: center;left: 25%;width: 50%;background-color: #F5F5F5;padding: 16px;border: 16px solid #444;border-radius: 10px;margin-top: 10px",s.style.cssText="z-index:10001;position: fixed;display: none;top: 0;left: 0;width: 100%;height: 100%;background-color: black;opacity: 0.8;";const n=Util.ln("style");root.document.getElementsByTagName("head")[0].appendChild(n),n.sheet.insertRule(".goCXul { list-style: none; }",0),n.sheet.insertRule(".goCXli {font:700 1.5em Helvetica, Arial, sans-serif;position: relative;min-width: 60px; }",0),n.sheet.insertRule(".goCXa {color: #444;display: inline-block;padding: 4px;text-decoration: none;margin: 2px;border: 1px solid gray;border-radius: 10px; }",0);const o=this.diagram;o!==null&&(o.Ht(e,"contextmenu",ContextMenuTool.jh,!1),o.Ht(e,"selectstart",ContextMenuTool.jh,!1),o.Ht(s,"contextmenu",ContextMenuTool.jh,!1)),e.className="goCXforeground",s.className="goCXbackground",root.document.body&&(root.document.body.appendChild(e),root.document.body.appendChild(s)),ContextMenuTool.Im=e,ContextMenuTool.Om=s,ContextMenuTool.MM=!0}static Lu=null;static MM=!1;static Om=null;static Im=null;static jh(t){return t.preventDefault(),!1}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return this.isBeyondDragSize()||!t.lastInput.right||t.lastInput.clickCount>1?!1:!!(t.lastInput.isTouchEvent&&this.defaultTouchContextMenu!==null||this.findObjectWithContextMenu()!==null)}doStart(){const t=this.diagram;this.SM.set(t.firstInput.documentPoint)}doStop(){this.hideContextMenu(),this.currentObject=null,this.Rm=!1}findObjectWithContextMenu(t){t===void 0&&(t=null);const i=this.diagram,e=i.lastInput;let s=null;if(t instanceof Diagram||(t instanceof GraphObject?s=t:s=i.findObjectAt(e.documentPoint,null,n=>!n.layer.isTemporary)),s!==null){let n=s;for(;n!==null;){if(n.contextMenu!==null)return n;n=n.panel}if(i.lastInput.isTouchEvent&&this.defaultTouchContextMenu)return s.part}else if(i.contextMenu!==null)return i;return null}doActivate(){}doMouseDown(){if(super.doMouseDown(),this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doMouseDown(),t.doDeactivate())}this.diagram.toolManager.mouseDownTools.has(this)&&this.doContextClick()}doMouseUp(){if(this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doCancel(),t.doDeactivate())}this.doContextClick()}doContextClick(){const t=this.diagram;if(!this.isActive)this.canStart()&&(this.openMenu(!0),this.isActive||this.stopTool());else{const i=this.currentContextMenu;if(i===null)return;let e=null;i instanceof HTMLInfo||(e=t.findObjectAt(t.lastInput.documentPoint,null,null),e!==null&&e.isContainedBy(i)&&this.standardMouseClick(null,null)),this.maybeStopTool(e)}}maybeStopTool(t){this.stopTool(),this.canStart()&&(this.diagram.currentTool=this,this.doMouseUp())}openMenu(t,i){if(i===void 0&&(i=null),this.Rm)return;this.Rm=!0,t&&this.standardMouseSelect();const e=this.standardMouseClick();if(this.Rm=!1,!e){this.isActive=!0;const s=ContextMenuTool.Lu;if(i===null&&(i=this.findObjectWithContextMenu()),i!==null){const n=i.contextMenu;n!==null?(this.currentObject=i instanceof GraphObject?i:null,this.showContextMenu(n,this.currentObject)):s!==null&&this.showContextMenu(s,this.currentObject)}else s!==null&&this.showContextMenu(s,null);this.currentContextMenu instanceof Adornment&&!this.currentContextMenu.visible&&this.stopTool()}}doMouseMove(){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.doMouseMove(),this.isActive&&this.diagram.toolManager.doMouseMove()}showContextMenu(t,i){Debug&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("showContextMenu:contextMenu must be an Adornment or HTMLInfo."),i!==null&&Util.s(i,GraphObject,ContextMenuTool,"showContextMenu:obj");const e=this.diagram;if(t!==this.currentContextMenu&&this.hideContextMenu(),t instanceof Adornment){const s=t;s.layerName="Tool",s.selectable=!1,s.scale=1/e.scale,s.category=this.name,s.hasPlaceholder()&&(s.placeholder.scale=e.scale);const n=s.diagram;n!==null&&n!==e&&n.remove(s),e.add(s),i!==null?s.adornedObject=i:s.data=e.model,s.ensureBounds(),this.positionContextMenu(s,i)}else t instanceof HTMLInfo&&t.show(i,e,this);this.currentContextMenu=t}positionContextMenu(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom&&(n.y-=o.height+5/s.scale),n.ye.commandHandler.copySelection(),e=>e.commandHandler.canCopySelection())),i.add(new ContextMenuButtonInfo("Cut",e=>e.commandHandler.cutSelection(),e=>e.commandHandler.canCutSelection())),i.add(new ContextMenuButtonInfo("Delete",e=>e.commandHandler.deleteSelection(),e=>e.commandHandler.canDeleteSelection())),i.add(new ContextMenuButtonInfo("Paste",e=>e.commandHandler.pasteSelection(t.mouseDownPoint),e=>e.commandHandler.canPasteSelection(t.mouseDownPoint))),i.add(new ContextMenuButtonInfo("Select All",e=>e.commandHandler.selectAll(),e=>e.commandHandler.canSelectAll())),i.add(new ContextMenuButtonInfo("Undo",e=>e.commandHandler.undo(),e=>e.commandHandler.canUndo())),i.add(new ContextMenuButtonInfo("Redo",e=>e.commandHandler.redo(),e=>e.commandHandler.canRedo())),i.add(new ContextMenuButtonInfo("Scroll To Part",e=>e.commandHandler.scrollToPart(),e=>e.commandHandler.canScrollToPart())),i.add(new ContextMenuButtonInfo("Zoom To Fit",e=>e.commandHandler.zoomToFit(),e=>e.commandHandler.canZoomToFit())),i.add(new ContextMenuButtonInfo("Reset Zoom",e=>e.commandHandler.resetZoom(),e=>e.commandHandler.canResetZoom())),i.add(new ContextMenuButtonInfo("Group Selection",e=>e.commandHandler.groupSelection(),e=>e.commandHandler.canGroupSelection())),i.add(new ContextMenuButtonInfo("Ungroup Selection",e=>e.commandHandler.ungroupSelection(),e=>e.commandHandler.canUngroupSelection())),i.add(new ContextMenuButtonInfo("Edit Text",e=>e.commandHandler.editTextBlock(),e=>e.commandHandler.canEditTextBlock())),i}showDefaultContextMenu(){const t=this.diagram;this.nx===null&&(this.nx=this.dF()),ContextMenuTool.Im.innerHTML="",ContextMenuTool.Om.addEventListener("pointerdown",this.ox,!1);const i=this,e=Util.ln("ul");e.className="goCXul",ContextMenuTool.Im.appendChild(e),e.innerHTML="";const s=this.nx.iterator;for(;s.next();){const n=s.value,o=n.Fm,r=n.Lf;if(typeof o!="function"||typeof r=="function"&&!r(t))continue;const l=Util.ln("li");l.className="goCXli";const h=Util.ln("a");h.className="goCXa",h.href="#",h.Fm=n.Fm,h.addEventListener("pointerdown",function(a){return this.Fm(t),i.stopTool(),a.preventDefault(),!1},!1),h.textContent=n.ui,l.appendChild(h),e.appendChild(l)}ContextMenuTool.Im.style.display="block",ContextMenuTool.Om.style.display="block"}hideDefaultContextMenu(){if(this.currentContextMenu===null||this.currentContextMenu!==ContextMenuTool.Lu)return;ContextMenuTool.Im.style.display="none",ContextMenuTool.Om.style.display="none";const t=this.diagram;t!==null&&t.Li(ContextMenuTool.Om,"pointerdown",this.ox,!1),this.currentContextMenu=null}get currentContextMenu(){return this.bM}set currentContextMenu(t){Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("ContextMenuTool.currentContextMenu must be an Adornment or HTMLInfo."),this.bM=t,this.sx=t instanceof Adornment?t.adornedPart:null}get defaultTouchContextMenu(){return ContextMenuTool.MM===!1&&ContextMenuTool.Lu===null&&Diagram.isUsingDOM()&&this.uF(),ContextMenuTool.Lu}set defaultTouchContextMenu(t){Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("ContextMenuTool.defaultTouchContextMenu must be an Adornment or HTMLInfo."),t===null&&(ContextMenuTool.MM=!0),ContextMenuTool.Lu=t}get currentObject(){return this.kM}set currentObject(t){t!==null&&Util.s(t,GraphObject,ContextMenuTool,"currentObject"),this.kM=t}get mouseDownPoint(){return this.SM}}var TextEditingAccept=(w=>(w[w.LostFocus=1]="LostFocus",w[w.MouseDown=2]="MouseDown",w[w.Tab=3]="Tab",w[w.Enter=4]="Enter",w))(TextEditingAccept||{}),TextEditingStarting=(w=>(w[w.SingleClick=1]="SingleClick",w[w.SingleClickSelected=2]="SingleClickSelected",w[w.DoubleClick=3]="DoubleClick",w))(TextEditingStarting||{}),TextEditingState=(w=>(w[w.None=1]="None",w[w.Active=2]="Active",w[w.Editing=3]="Editing",w[w.Validating=4]="Validating",w[w.Invalid=5]="Invalid",w[w.Validated=6]="Validated",w))(TextEditingState||{});class TextEditingTool extends Tool{Le;PM;NM;Il;vt;CM;AM;LM;rx;lx;constructor(t){super(),this.name="TextEditing",this.Le=new TextBlock,this.PM=null,this.NM=2,this.Il=null,this.vt=1,this.CM=1,this.AM=!0,this.LM=null,this.rx=new HTMLInfo,this.lx=null,this.gF(this.rx),t&&Object.assign(this,t)}static LostFocus=1;static MouseDown=2;static Tab=3;static Enter=4;static SingleClick=1;static SingleClickSelected=2;static DoubleClick=3;static StateNone=1;static StateActive=2;static StateEditing=3;static StateValidating=4;static StateInvalid=5;static StateValidated=6;gF(t){if(!Diagram.isUsingDOM())return;const i=Util.ln("textarea");this.lx=i;const e=this;i.addEventListener("input",function(s){if(e.textBlock===null)return;const n=e.measureTemporaryTextBlock(this.value),o=this.textScale;this.style.width=20+Math.max(e.textBlock.measuredBounds.width,n.measuredBounds.width)*o+"px",this.rows=Math.max(e.textBlock.lineCount,n.lineCount)},!1),i.addEventListener("keydown",function(s){if(s.isComposing||e.textBlock===null)return;const n=s.key;if(n==="Enter"){e.textBlock.isMultiline===!1&&s.preventDefault(),e.acceptText(4);return}else if(n==="Tab"){e.acceptText(3),s.preventDefault();return}else n==="Escape"&&(e.doCancel(),e.diagram!==null&&e.diagram.doFocus())},!1),i.addEventListener("focus",function(s){e.mF(s)},!1),i.addEventListener("blur",function(s){e.pF(s)},!1),t.valueFunction=()=>i.value,t.mainElement=i,t.show=(s,n,o)=>{if(!(s instanceof TextBlock&&o instanceof TextEditingTool))return;if(o.state===5){i.style.border="3px solid red",i.focus();return}const r=s.getDocumentPoint(Spot.Center),l=n.position,h=n.scale;let a=s.getDocumentScale()*h;a{s.div.removeChild(i)}}get textBlock(){return this.PM}set textBlock(t){t!==null&&Util.s(t,TextBlock,TextEditingTool,"textBlock"),this.PM=t}get currentTextEditor(){return this.LM}set currentTextEditor(t){this.LM=t}get defaultTextEditor(){return this.rx}set defaultTextEditor(t){Debug&&!(t instanceof HTMLInfo)&&Util.n("TextEditingTool.defaultTextEditor must be an HTMLInfo."),this.rx=t}get starting(){return this.NM}set starting(t){Util.tt(t,TextEditingStarting,"TextEditingStarting"),this.NM=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t===null||t.isReadOnly||TextEditingTool.Tf&&TextEditingTool.Tf!==this&&(TextEditingTool.Tf.acceptText(2),TextEditingTool.Tf&&TextEditingTool.Tf!==this)||!t.lastInput.left||this.isBeyondDragSize())return!1;const i=t.lastInput.documentPoint,e=t.findObjectAt(i);if(e===null||!(e instanceof TextBlock)||!e.editable||!e.part.canEdit())return!1;const s=e.part;return!(s===null||this.starting===2&&!s.isSelected||this.starting===3&&t.lastInput.clickCount<2)}doStart(){TextEditingTool.Tf=this,this.textBlock!==null&&this.doActivate()}doActivate(){if(this.isActive)return;const t=this.diagram;if(t===null)return;let i=this.textBlock;if(i===null&&(i=t.findObjectAt(t.lastInput.documentPoint)),i===null||!(i instanceof TextBlock)||(this.textBlock=i,i.part===null))return;t.animationManager.stopAnimation(),this.isActive=!0,this.vt=2;let s=this.defaultTextEditor;i.textEditor!==null&&(s=i.textEditor),this.Le=this.textBlock.copy();const n=new Rect(this.textBlock.getDocumentPoint(Spot.TopLeft),this.textBlock.getDocumentPoint(Spot.BottomRight));t.scrollToRect(n),s.show(i,t,this),this.currentTextEditor=s}doCancel(){this.stopTool()}doMouseUp(){this.canStart()&&this.doActivate()}doMouseDown(){this.isActive&&this.acceptText(2)}acceptText(t){switch(t){case 2:this.vt===6?this.currentTextEditor instanceof HTMLElement&&this.currentTextEditor.focus():(this.vt===2||this.vt===5||this.vt===3)&&(this.vt=4,this.tA());break;case 1:case 4:case 3:if(t===4&&this.textBlock.isMultiline===!0)return;(this.vt===2||this.vt===5||this.vt===3)&&(this.vt=4,this.tA());break}}tA(){const t=this.textBlock,i=this.diagram,e=this.currentTextEditor;if(t!==null&&e!==null){const s=t.text;let n="";if(e.valueFunction!==null&&(n=e.valueFunction()),!this.isValidText(t,s,n)){this.vt=5,this.doError(s,n);return}this.startTransaction(this.name),this.vt=6,this.transactionResult=this.name,t.text=n,this.doSuccess(s,n),i!==null&&i.V("TextEdited",t,s),this.stopTransaction(),this.stopTool(),i!==null&&i.doFocus()}}doError(t,i){const e=this.textBlock;e.errorFunction!==null&&e.errorFunction(this,t,i);const s=this.currentTextEditor;s&&s.show(e,this.diagram,this)}doSuccess(t,i){const e=this.textBlock;e.textEdited!==null&&e.textEdited(e,t,i)}doDeactivate(){const t=this.diagram;t!==null&&(this.vt=1,this.currentTextEditor!==null&&this.currentTextEditor.hide(t,this),this.textBlock=null,this.isActive=!1)}doStop(){TextEditingTool.Tf=null}mF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this.lx;this.vt===2&&(this.vt=3),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}pF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this.lx;typeof i.focus=="function"&&i.focus(),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}isValidText(t,i,e){Util.s(t,TextBlock,TextEditingTool,"isValidText:textblock");const s=this.textValidation;if(s!==null&&!s(t,i,e))return!1;const n=t.textValidation;return!(n!==null&&!n(t,i,e))}get textValidation(){return this.Il}set textValidation(t){t!==null&&Util.t(t,"function",TextEditingTool,"textValidation"),this.Il=t}get minimumEditorScale(){return this.CM}set minimumEditorScale(t){t!==null&&Util.t(t,"number",TextEditingTool,"minimumEditorScale"),this.CM=t}get selectsTextOnActivate(){return this.AM}set selectsTextOnActivate(t){t!==null&&Util.t(t,"boolean",TextEditingTool,"selectsTextOnActivate"),this.AM=t}get state(){return this.vt}set state(t){this.vt!==t&&(Util.tt(t,TextEditingState,"TextEditingState"),this.vt=t)}measureTemporaryTextBlock(t){const i=this.Le;return i.text=t,i.wt(this.textBlock.Ol,1/0),i}static Tf=null}var AnimationStyle=(w=>(w[w.Default=1]="Default",w[w.AnimateLocations=2]="AnimateLocations",w[w.None=3]="None",w))(AnimationStyle||{});class AnimationManager{b;Ti;Xi;Cr;Zn;Io;TM;DM;Em;Si;Df;yn;Vm;Wh;hx;Bm;ax;Ff;Cu;zm;constructor(t){this.b=Diagram.Mm(),this.Ti=!1,this.Em=!1,this.Si=!1,this.Df=!1,this.ax=!0,this.Ff=1,this.Cu=!1,this.Xi=!0,this.Cr=!0,this.Io=600,this.TM=!1,this.DM=!1,this.Zn=new GSet,this.yn=new Animation,this.Vm=new Animation,this.yn.ws=this,this.Wh=new GSet,this.hx=new GSet,this.Bm=new GSet,this.zm=new GSet,t&&Object.assign(this,t)}Oo(t){this.b=t}aE(){return this.b}canStart(t){return!0}El(t){return!this.Xi||!this.canStart(t)?!1:(this.Zn.add(t),this.defaultAnimation.isAnimating&&this.stopAnimation(),this.b.Di(),this.Si=!0,!0)}getBundleAnimation(){return this.Vm}FM(){if(!this.Xi||(this.Vm.ge.count>0&&this.Vm.start(),!this.Si))return;const t=this.yn,i=this.b,e=this.Zn.has("Model");if(e&&(this.Df=!0,this.Ff===1?(t.isViewportUnconstrained=!0,t.ge.clear(),t.add(i,"position",i.position.copy().offset(0,-200),i.position),t.add(i,"opacity",0,1)):this.Ff===3&&t.ge.clear(),this.Ff===2&&i.fx.equals(i.mt)?this.ax=!0:this.ax=!1,i.V("InitialAnimationStarting",this)),e&&!this.Cr||t.ge.count===0){this.Zn.clear(),this.Si=!1,t.ge.clear(),t.cx(i),this.Df=!1,i.T();return}this.Zn.clear(),i.Ar=!1;const s=t.ge.get(i);i.autoScale!==1&&s!==null&&(delete s.li.scale,delete s.xs.scale);const n=this;root.requestAnimationFrame(()=>{n.Si===!1||t.Ti||(i.getRenderingHint("temporaryPixelRatio")&&i.jw(),i.RM(),n.Si=!1,t.start(),t.Ti&&(n.Tu(),i.invalidateDocumentBounds(),t.iA(0),i.Sr(!0),n.Du(),i.V("AnimationStarting",n)))})}IM(){return this.Zn.has("Trigger")&&this.Zn.count===1}eA(t,i,e,s){this.isTicking||this.IM()||t instanceof Link&&(t.fromNode!==null||t.toNode!==null)||this.yn.add(t,"position",i,e,s)}ux(t){return this.yn.ux(t)}OM(t){return this.yn.OM(t)}yF(t){const i=this.Wh,e=this;function s(){if(e.Bm.count>0&&(i.addAll(e.Bm),e.Bm.clear(),e.Ti=!0),e.Ti===!1||i.count===0)return;e.hx.addAll(i);const n=e.hx.iterator;for(;n.next();){const o=n.value;o.Ti!==!1&&(o.wF()?o.sA(!1):o.Rf=!0)}if(e.hx.clear(),e.Ti===!1){root.requestAnimationFrame(s);return}e.Tu(),e.b.Sr(),e.Du(),root.requestAnimationFrame(s)}this.Ti?this.xF(t):(this.Ti=!0,i.add(t),root.requestAnimationFrame(()=>s()))}xF(t){this.Bm.add(t)}bF(){const t=this.Wh.iterator;for(;t.next();)t.value.Rf=!1}Tu(){if(this.Em)return;const t=this.b;this.TM=t.skipsUndoManager,this.DM=t.me,t.skipsUndoManager=!0,t.me=!0,this.Em=!0}Du(){const t=this.b;t.skipsUndoManager=this.TM,t.me=this.DM,this.Em=!1}stopAnimation(t){const i=this.yn;if(this.Si===!0&&(this.Si=!1,this.Df=!1,this.Zn.clear(),i.kF()&&this.b.requestUpdate()),!this.Ti){i.ge.clear(),i.cx(this.b);return}if(i.Fu(!0),i.cx(null),t===!0){const e=this.Wh.toArray();for(let s=0;s{!i.isAnimating&&i.runCount===1/0&&i.start()})}get duration(){return this.Io}set duration(t){Util.t(t,"number",AnimationManager,"duration"),t<1&&Util.G(t,">= 1",AnimationManager,"duration"),this.Io=t}get isAnimating(){return this.Ti}get isTicking(){return this.Em}get isInitial(){return this.Cr}set isInitial(t){Util.t(t,"boolean",AnimationManager,"isInitial"),this.Cr=t}get defaultAnimation(){return this.yn}get activeAnimations(){return this.Wh}get initialAnimationStyle(){return this.Ff}set initialAnimationStyle(t){Debug&&Util.tt(t,AnimationStyle,"AnimationStyle"),this.Ff=t}static gx=new GMap;static defineAnimationEffect(t,i){AnimationManager.gx.set(t,i)}static BM(t,i,e,s,n){t===null&&(t=[0,0,0,0]),i===null&&(i=[0,0,0,0]);let o=t[0],r=t[1];const l=t[2],h=t[3];let a=i[0],f=i[1];const c=i[2],u=i[3];l===0||l===100?(o=a,r=f):(c===0||c===100)&&(a=o,f=r),Math.abs(a-o)>180&&(a>o?o+=360:a+=360);const d=n(e,o,a-o,s)%360,m=n(e,r,f-r,s),g=n(e,l,c-l,s),p=n(e,h,u-h,s);return"hsla("+d+", "+m+"%, "+g+"%, "+p+")"}static{const t=AnimationManager.gx,i=(e,s,n,o,r,l)=>{e.position=new Point(o(r,s.x,n.x-s.x,l),o(r,s.y,n.y-s.y,l))};t.set("position:diagram",i),t.set("position",i),t.set("position:part",(e,s,n,o,r,l)=>{r{r{r{const h=e.actualBounds,a=n.actualBounds,f=a.x+a.width/2-h.width/2,c=a.y+a.height/2-h.height/2;r{e.desiredSize=new Size(o(r,s.width,n.width-s.width,l),o(r,s.height,n.height-s.height,l))}),t.set("width",(e,s,n,o,r,l)=>{e.width=o(r,s,n-s,l)}),t.set("height",(e,s,n,o,r,l)=>{e.height=o(r,s,n-s,l)}),t.set("fill",(e,s,n,o,r,l)=>{e.fill=AnimationManager.BM(s,n,r,l,o)}),t.set("stroke",(e,s,n,o,r,l)=>{e.stroke=AnimationManager.BM(s,n,r,l,o)}),t.set("strokeWidth",(e,s,n,o,r,l)=>{e.strokeWidth=o(r,s,n-s,l)}),t.set("strokeDashOffset",(e,s,n,o,r,l)=>{e.strokeDashOffset=o(r,s,n-s,l)}),t.set("background",(e,s,n,o,r,l)=>{e.background=AnimationManager.BM(s,n,r,l,o)}),t.set("opacity",(e,s,n,o,r,l)=>{e.opacity=o(r,s,n-s,l)}),t.set("scale",(e,s,n,o,r,l)=>{e.scale=o(r,s,n-s,l)}),t.set("angle",(e,s,n,o,r,l)=>{e.angle=o(r,s,n-s,l)})}static Default=1;static AnimateLocations=2;static None=3}class Animation{mx;Xm;Ti;Ru;Io;bs;lA;Ef;ge;px;li;$n;Iu;Vf;yx;wx;Rf;zM;xx;ws;b;XM;YM;KM;constructor(t){this.b=null,this.ws=null,this.zM=null,this.xx=null,this.XM=!1,this.Ti=!1,this.Rf=!1,this.li=0,this.$n=0,this.mx=Animation.EaseInOutQuad,this.Xm=Animation.EaseInOutQuad,this.Iu=!1,this.Vf=!1,this.yx=1,this.wx=0,this.Io=NaN,this.bs=NaN,this.YM=0,this.Ru=null,this.lA=Point.Lo,this.ge=new GMap,this.px=new GMap,this.Ef=new GSet,this.KM=1,t&&Object.assign(this,t)}suspend(){this.Rf=!0}advanceTo(t,i){i&&(this.Rf=!1),this.Iu&&t>=this.bs&&(this.Vf=!0,t=t-this.bs),this.YM=t,this.sA(!0),this.ws.Tu(),this.b.Sr(),this.ws.Du(),this.b.redraw()}cx(t){if(this.px.clear(),this.Vf=!1,this.wx=0,this.bs=NaN,this.Ef.count>0&&this.Ef.clear(),t!==null){const i=t.links;for(;i.next();)i.value.Lr=null}}kF(){return this.ge.count>0}start(){if(this.ge.count===0)return this;if(this.Ti)return this;let t=this.b;const i=this.ge.iterator;for(;i.next();){const s=i.key;t===null&&(s instanceof Diagram?t=s:s instanceof GraphObject&&(t=s.diagram))}if(t!==null)this.b=t,this.ws=t.animationManager;else return this;const e=this.ws;return e.isEnabled===!1?this:(this.bs=isNaN(this.Io)?e.duration:this.Io,this.Xm=this.mx,e.Df&&e.Ff===1&&this===e.defaultAnimation&&(this.Xm=Animation.EaseOutExpo,this.bs=isNaN(this.Io)?e.duration===600?900:e.duration:this.Io),this.KM=t.scrollMode,this.isViewportUnconstrained&&(t.vh=2),e.Tu(),this.Ef.each(s=>{s.data=null,t.add(s)}),e.Du(),this.Ti=!0,this.li=+new Date,this.$n=this.li+this.bs,e.yF(this),this)}addTemporaryPart(t,i){return t.Ae()?(Debug&&(i===void 0&&Util.n("addTemporaryPart: Required Diagram argument missing"),t.diagram===i&&Util.n("addTemporaryPart: Part already in Diagram, did you mean to pass in a copy?"),this.b!==null&&this.b!==i&&Util.n("addTemporaryPart: A different Diagram is already associated with this Animation: "+this.b.toString())),this.Ef.add(t),this.b=i,this):this}add(t,i,e,s,n){if(this.b===null&&(t instanceof Diagram?this.b=t:t instanceof GraphObject&&t.diagram!==null&&(this.b=t.diagram)),t instanceof Part){if(!t.isAnimated)return this;i==="position"&&(i="position:part")}return this.EM(t,i,e,s,n),this}EM(t,i,e,s,n){const o=this.ge;let r,l,h;if(t instanceof Diagram&&i==="position"&&(i="position:diagram"),(i==="fill"||i==="stroke"||i==="background")&&(Brush.Eo(e),Brush.UM(),e=[Brush.Yi.n0,Brush.Yi.n1,Brush.Yi.n2,Brush.Yi.n3],Brush.Eo(s),Brush.UM(),s=[Brush.Yi.n0,Brush.Yi.n1,Brush.Yi.n2,Brush.Yi.n3]),o.has(t))r=o.get(t),l=r.li,h=r.xs,l[i]===void 0&&(l[i]=this.Ou(e)),h[i]=this.Ou(s);else{if(i==="position"&&e.equalsApprox(s))return;l={},h={},l[i]=this.Ou(e),h[i]=this.Ou(s),r=new AnimationState(l,h,n),o.set(t,r)}const a=l[i];a instanceof Point&&!a.isReal()&&a.c(this.lA),n&&i.indexOf("position:")===0&&t instanceof Part?r.bx.location=this.Ou(t.location):n&&(r.bx[i]=this.Ou(e))}Ou(t){return t instanceof Point||t instanceof Size?t.copy():t}SF(t){const i=this.ge;if(i.has(t)){const e=i.get(t);e.kx=!0}}ux(t){if(!this.Ti)return!1;const i=this.ge.get(t);return i!==null&&i.kx}OM(t){if(!this.Ti)return!1;const i=this.ge.get(t);return i!==null&&!!(i.li.position||i.li["position:part"]||i.li.location)}wF(){if(this.Ef.count>0)return!0;const t=this.ge.iterator;for(;t.next();){const i=t.key;if(i instanceof GraphObject&&i.diagram!==null||i instanceof Diagram)return!0}return!1}sA(t){if(this.Rf&&!t)return;const i=this.ws;if(this.Ti===!1)return;const e=+new Date;let s=e>this.$n?this.bs:e-this.li;t&&(s=this.YM,sthis.$n&&(this.Iu&&!this.Vf?(this.li=+new Date,this.$n=this.li+this.bs,this.Vf=!0):this.Fu(!1))}iA(t){const i=this.bs,e=this.ge.iterator,s=this.Vf;for(;e.next();){const n=e.key;if(n instanceof GraphObject&&n.diagram===null)continue;const o=e.value,r=s?o.xs:o.li,l=s?o.li:o.xs,h=AnimationManager.gx;for(const a in l)a==="position"&&(l["position:placeholder"]||l["position:nodeCollapse"])||h.get(a)!==null&&h.get(a)(n,r[a],l[a],this.Xm,t,i,this)}}stop(){return this.Ti?(this.Fu(!0),this):this}Fu(t){if(this.xx!==null&&this.xx.MF(this.zM),!this.Ti)return;const i=this.b,e=this.ws;e.Df=!1,this.Ti=!1,this.Rf=!1,e.Tu();const s=this.ge,n=this.Ef.iterator;for(;n.next();)i.remove(n.value);const o=this.Iu,r=s.iterator,l=AnimationManager.gx;for(;r.next();){const a=r.key,f=r.value,c=o?f.xs:f.li,u=o?f.li:f.xs,d=f.bx;for(const m in u)if(l.get(m)!==null){let g=m;f.Sx&&(g==="position:nodeCollapse"||g==="position:placeholder")&&(g="position"),l.get(g)(a,c[m],d[m]!==void 0?d[m]:f.Sx?c[m]:u[m],this.Xm,this.bs,this.bs,this)}f.Sx&&d.location!==void 0&&a instanceof Part&&(a.location=d.location),f.kx&&a instanceof Part&&a.Ki(!1)}this.wx++;const h=!t&&this.yx>this.wx;if(!h&&(this===e.Vm||this===e.defaultAnimation)&&this.ge.clear(),i.Mx.clear(),i.NS(!1),i.invalidateDocumentBounds(),i.T(),i.Sr(!0),e.defaultAnimation===this){const a=e.zm.iterator;for(;a.next();)a.value.PF();e.zm.clear()}if(i.Sr(!0),this.isViewportUnconstrained&&(i.scrollMode=this.KM),e.Du(),h){this.Vf=!1,this.start();return}this.cx(null),e.Fu(this),this.Ru&&this.Ru(this),i.requestUpdate()}If(t,i){const e=i.actualBounds;let s=null;if(i instanceof Group&&(s=i.placeholder),s!==null&&s.visible){const n=s.getDocumentPoint(Spot.TopLeft),o=s.padding;n.x+=o.left,n.y+=o.top,this.add(t,"position",n,t.position,!1)}else this.add(t,"position",new Point(e.x+e.width/2,e.y+e.height/2),t.position,!1);this.add(t,"scale",.01,t.scale,!1),t instanceof Group&&this.NF(t,i)}NF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.If(s,i)}}Of(t,i){if(!t.isVisible())return;let e=null;if(i instanceof Group&&(e=i.placeholder),e!==null&&e.visible){const s=e.getDocumentPoint(Spot.TopLeft),n=e.padding;s.x+=n.left,s.y+=n.top,this.add(t,"position:placeholder",t.position,s,!0)}else this.add(t,"position:nodeCollapse",t.position,i,!0);this.add(t,"scale",t.scale,.01,!0),this.SF(t),t instanceof Group&&this.CF(t,i)}CF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Of(s,i)}}get duration(){return this.Io}set duration(t){Util.t(t,"number",Animation,"duration"),t<1&&Util.G(t,">= 1",Animation,"duration"),this.Io=t}get reversible(){return this.Iu}set reversible(t){this.Iu=t}get runCount(){return this.yx}set runCount(t){t>0?this.yx=t:Util.n("Animation.runCount value must be a positive integer.")}get finished(){return this.Ru}set finished(t){this.Ru!==t&&(t!==null&&Util.t(t,"function",Animation,"finished"),this.Ru=t)}get easing(){return this.mx}set easing(t){this.mx=t}get isViewportUnconstrained(){return this.XM}set isViewportUnconstrained(t){this.XM=t}get isAnimating(){return this.Ti}getTemporaryState(t){let i=this.px.get(t);return i===null&&(i={},this.px.set(t,i)),i}static EaseLinear=(t,i,e,s)=>e*t/s+i;static EaseInOutQuad=(t,i,e,s)=>(t/=s/2,t<1?e/2*t*t+i:-e/2*(--t*(t-2)-1)+i);static EaseInQuad=(t,i,e,s)=>e*(t/=s)*t+i;static EaseOutQuad=(t,i,e,s)=>-e*(t/=s)*(t-2)+i;static EaseInExpo=(t,i,e,s)=>t===0?i:e*Math.pow(2,10*(t/s-1))+i;static EaseOutExpo=(t,i,e,s)=>t===s?i+e:e*(-Math.pow(2,-10*t/s)+1)+i}class AnimationState{li;xs;bx;Sx;kx;constructor(t,i,e){this.li=t,this.xs=i,this.bx={},this.Sx=e,this.kx=!1}}var TriggerStart=(w=>(w[w.Default=1]="Default",w[w.Immediate=2]="Immediate",w[w.Bundled=3]="Bundled",w))(TriggerStart||{});class AnimationTrigger{Ce;gn;Eu;Bf;constructor(t,i,e){e&&Debug&&Util.tt(e,TriggerStart,"TriggerStart"),this.Ce=null,this.gn=t,this.Eu=e||1,this.Bf=null,i!==void 0&&(this.Bf=i,e===void 0&&(this.Eu=2))}copy(){const t=new AnimationTrigger(this.gn);t.Eu=this.Eu;const i=this.Bf;if(i!==null){const e={};i.duration!==void 0&&(e.duration=i.duration),i.finished!==void 0&&(e.finished=i.finished),i.easing!==void 0&&(e.easing=i.easing),t.Bf=e}return t}get propertyName(){return this.gn}set propertyName(t){this.gn=t}get animationSettings(){return this.Bf}set animationSettings(t){this.Bf=t}AF(t){const i=this.Bf;i!==null&&(i.duration&&(t.duration=i.duration),i.finished&&(t.finished=i.finished),i.easing&&(t.easing=i.easing))}get startCondition(){return this.Eu}set startCondition(t){Debug&&Util.tt(t,TriggerStart,"TriggerStart"),this.Eu=t}static Default=1;static Immediate=2;static Bundled=3}class Layer{b;Tt;_t;Tr;Vl;Bl;zl;Xl;Yl;Kl;Ul;Gl;Hl;ql;jl;Wl;Lf;vl;Px;Ym;Vu;It;constructor(t){GSet.vi(this),this.b=null,this.It=new List,this.Tt="",this._t=1,this.Tr=!1,this.Vl=!0,this.Bl=!0,this.zl=!0,this.Xl=!0,this.Yl=!0,this.Kl=!0,this.Ul=!0,this.Gl=!0,this.Hl=!0,this.ql=!0,this.jl=!0,this.Wl=!0,this.Lf=!0,this.vl=!0,this.Px=!0,this.Ym=!1,this.Vu=[],t&&Object.assign(this,t)}LF(){const t=this.It;for(let i=0;i0&&(h+=e+" Parts "),s>0&&(h+=s+" Nodes "),n>0&&(h+=n+" Groups "),o>0&&(h+=o+" Links "),r>0&&(h+=r+" Adornments "),t>1){const a=this.It.iterator;for(;a.next();){const f=a.value;h+=` - `+f.toString();const c=f.data;c!==null&&GSet.gs(c)&&(h+=" #"+GSet.gs(c)),f instanceof Node?h+=" "+Util.toString(c):f instanceof Link&&(h+=" "+Util.toString(f.fromNode)+" "+Util.toString(f.toNode))}}return i+" "+this.It.count+": "+h}findObjectAt(t,i,e){if(i===void 0&&(i=null),e===void 0&&(e=null),this.vl===!1)return null;Debug&&!t.isReal()&&Util.n("findObjectAt: Point must have a real value, not: "+t.toString());let s=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(s=!0);const n=Point.a(),o=this.It.h,r=o.length;for(let l=r;l--;){const h=o[l];if(s===!0&&h.Tl()===!1||!h.isVisible())continue;n.c(t),n.Ye(h.Ks);let a=h.hA(n,i,e);if(a!==null&&(i!==null&&(a=i(a)),a!==null&&(e===null||e(a))))return Point.o(n),a}return Point.o(n),null}findObjectsAt(t,i,e,s){if(i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.vl===!1)return s;Debug&&!t.isReal()&&Util.n("findObjectsAt: Point must have a real value, not: "+t.toString());let n=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(n=!0);const o=Point.a(),r=this.It.h,l=r.length;for(let h=l;h--;){const a=r[h];if(n===!0&&a.Tl()===!1||!a.isVisible())continue;o.c(t),o.Ye(a.Ks);let f=a;a.aA(o,i,e,s)&&(i!==null&&(f=i(f)),f!==null&&(e===null||e(f))&&s.add(f))}return Point.o(o),s}findObjectsIn(t,i,e,s,n){if(i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.vl===!1)return n;Debug&&!t.isReal()&&Util.n("findObjectsIn: Rect must have a real value, not: "+t.toString());let o=!1;this.diagram!==null&&this.diagram.viewportBounds.containsRect(t)&&(o=!0);const r=this.It.h,l=r.length;for(let h=l;h--;){const a=r[h];if(o===!0&&a.Tl()===!1||!a.isVisible())continue;let f=a;a.Km(t,i,e,s,n)&&(i!==null&&(f=i(f)),f!==null&&(e===null||e(f))&&n.add(f))}return n}IS(t,i,e,s,n,o,r){if(this.vl===!1)return n;const l=this.It.h,h=l.length;for(let a=h;a--;){const f=l[a];if(r===!0&&f.Tl()===!1||!o(f)||!f.isVisible())continue;let c=f;f.Km(t,i,e,s,n)&&(i!==null&&(c=i(c)),c!==null&&(e===null||e(c))&&n.add(c))}return n}findObjectsNear(t,i,e,s,n,o){if(e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.vl===!1)return o;Debug&&!t.isReal()&&Util.n("findObjectsNear: Point must have a real value, not: "+t.toString());let r=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(r=!0);const l=Point.a(),h=Point.a(),a=this.It.h,f=a.length;for(let c=f;c--;){const u=a[c];if(r===!0&&u.Tl()===!1||!u.isVisible())continue;l.c(t),l.Ye(u.Ks),h.e(t.x+i,t.y),h.Ye(u.Ks);let d=u;u.fA(l,h,e,s,n,o)&&(e!==null&&(d=e(d)),d!==null&&(s===null||s(d))&&o.add(d))}return Point.o(l),Point.o(h),o}HM(){return this.It.h}Us(t,i){if(!this.visible)return;const e=this.It.h,s=e.length;if(s===0)return;const n=Util.ft(),o=Util.ft();for(let r=0;r0&&o.push(l))}for(let r=0;re.Gm||a.height*n>e.Gm?i.Ji(t,e):this.RF(t,i),f&&(t.restore(),t.clearContextCache(!0))}RF(t,i){const e=i.actualBounds,s=i.naturalBounds;if(e.width===0||e.height===0||isNaN(e.x)||isNaN(e.y)||!i.isVisible())return;const n=i.O;if(i.background===null){i.wn(t,"rgba(0,0,0,0.3)",!0,!1,s,e),t.fillRect(e.x,e.y,e.width,e.height);return}if(t.transform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),i.wn(t,i.background,!0,!1,s,e),t.fillRect(0,0,s.width/2,s.height/2),!n.Gk()){const o=1/(n.m11*n.m22-n.m12*n.m21);t.transform(n.m22*o,-n.m12*o,-n.m21*o,n.m11*o,o*(n.m21*n.dy-n.m22*n.dx),o*(n.m12*n.dx-n.m11*n.dy))}}FF(t,i,e,s){const n=2/s,o=4/s;for(let r=0;r=s.count)t=s.count;else if(s.elt(t)===i)return-1;s.insertAt(t,i),i.Hm(e);const n=this.diagram;return n!==null&&(e?n.T():n.Zh(i)),this.Nx(t,i),t}ne(t,i,e){if(!e&&i.layer!==this&&i.layer!==null)return i.layer.ne(t,i,e);const s=this.It;if(t<0||t>=s.length){if(t=s.indexOf(i),t<0)return-1}else if(s.elt(t)!==i&&(t=s.indexOf(i),t<0))return-1;i.qm(e),s.removeAt(t);const n=this.diagram;return n!==null&&(e?n.T():n.ne(i)),i.GM(null),t}Nx(t,i){t=this.IF(t,i),i instanceof Group&&this.OF(t,i),i.svg!==null&&i.svg.remove()}IF(t,i){const e=i.zOrder;if(isNaN(e))return t;const s=this.It,n=s.count;if(n<=1)return t;if(t<0&&(t=s.indexOf(i)),t<0)return-1;let o=t-1,r=NaN;for(;o>=0&&(r=s.elt(o).zOrder,!!isNaN(r));)o--;let l=t+1,h=NaN;for(;le)for(;;){if(o===-1||r<=e)return o++,o===t?t:(s.removeAt(t),s.insertAt(o,i),o);for(r=NaN;--o>=0&&(r=s.elt(o).zOrder,!!isNaN(r)););}else if(!isNaN(h)&&h=e)return l--,l===t?t:(s.removeAt(t),s.insertAt(l,i),l);for(h=NaN;++l=0)||e<0&&r.containingGroup===i&&(e=o,t>=0))break}if(!(e<0)&&e1)&&Util.G(t,"0 <= value <= 1",Layer,"opacity"),this._t=t;const e=this.diagram;e!==null&&e.T(),this.i("opacity",i,t)}}get isViewportAligned(){return this.Ym}set isViewportAligned(t){const i=this.Ym;i!==t&&(this.Ym=t,this.diagram&&(this.uA(),this.diagram.T()),this.i("isViewportAligned",i,t),t&&(this.isInDocumentBounds=!1))}uA(){if(!this.Ym)return;const t=this.diagram,i=this.It.h,e=i.length,s=t.Ct,n=t.At;for(let o=0;o(w[w.None=1]="None",w[w.Uniform=2]="Uniform",w[w.UniformToFill=3]="UniformToFill",w))(AutoScale||{}),CycleMode=(w=>(w[w.All=1]="All",w[w.NotDirected=2]="NotDirected",w[w.NotDirectedFast=3]="NotDirectedFast",w[w.NotUndirected=4]="NotUndirected",w[w.DestinationTree=5]="DestinationTree",w[w.SourceTree=6]="SourceTree",w))(CycleMode||{}),ScrollMode=(w=>(w[w.Document=1]="Document",w[w.Infinite=2]="Infinite",w))(ScrollMode||{}),CollapsePolicy=(w=>(w[w.TreeParent=1]="TreeParent",w[w.AllParents=2]="AllParents",w[w.AnyParents=3]="AnyParents",w))(CollapsePolicy||{});class Diagram{ws;yi;WM;Cx;Dr;Xu;Ax;Lx;Tx;Dx;Fx;Rx;zf;vh;Ix;Ox;Ex;Jl;Xf;Fr;jm;Vx;Bx;Yu;Qn;Rr;$h;Vo;Wm;Yf;vm;Kf;Ku;Ir;_n;vM;JM;zx;Xx;ZM;Yx;$M;QM;_M;Kx;Jm;Or;Er;Vr;Br;zr;Xr;Ux;Yr;Gx;Kr;Ur;Gr;Hr;Hx;tP;Bo;iP;qx;jx;eP;Ai;sP;nP;oP;zs;zo;Xi;Wx;Vl;Bl;vx;Jx;zl;Xl;Yl;Zx;Kl;Ul;Gl;Hl;ql;jl;Wl;$x;Qx;rP;Uu;Gu;_x;t1;i1;e1;Zm;s1;o1;l1;ii;lP;h1;hP;Hu;xn;to;oe;io;dA;Zl;aP;fP;$m;a1;qu;Qm;f1;qr;$l;Qh;cP;uP;_m;c1;u1;os;t0;i0;ju;Ql;Uf;e0;jr;_h;dP;s0;$t;O;Ge;Ar;Ui;ks;gP;_l;Wr;Pl;vr;ta;Gf;mP;Wu;ia;vu;Jt;th;mt;lt;Ju;Ct;At;xt;Hf;qw;d1;ea;qf;g1;m1;p1;BF;zF;Gi;Cl;Gm;o0;pP;yP;gA;r0;XF;YF;KF;w1;UF;GF;HF;sa;mA;ih;na;oa;ra;la;Nu;jh;ei;Ot;jf;eS;sS;wf;_t;static b1=null;static pA=new GMap;static wP;static xP=null;Pu;k1;S1;M1;P1;N1;l0;bP;h0;a0;f0;fx;kP;C1;Wf;constructor(t,i){if(Diagram.ww||(Diagram.Hk(),Diagram.ww=!0),GSet.vi(this),Diagram.yA(this),this.$t=!0,this.Ot=null,this.Ct=0,this.At=0,this.xt=null,Diagram.isUsingDOM()){const s=this,n=()=>{s.Li(root.document,"DOMContentLoaded",n,!1),s.setRTL()};root.document.body!==null?this.setRTL():s.Ht(root.document,"DOMContentLoaded",n,!1)}this.Hf=null,Diagram.SP("Model",PartManager);const e=this;return this.sP=s=>e.partManager.doModelDataChanged(s),this.nP=s=>e.partManager.doModelChanged(s),this.g1=null,this.m1=null,this.wA(),this.model=Model.initDiagramModel(),this.C1=null,this.themeManager=new ThemeManager,this.Bo=!0,this.xA(),this.layout=new Layout,this.Bo=!1,this.XF=null,this.YF=null,this.KF=null,this.w1=null,this.UF=null,this.GF=null,this.HF=null,this.sa=null,this.mA=null,this.ih=null,this.na=null,this.oa=null,this.ra=null,this.la=null,this.Nu=()=>{},this.jh=null,this.ju=!1,this.jf=new DiagramHelper(this),t!==void 0&&(typeof t=="string"||root.Element&&t instanceof Element?this.MP(t):i=t),i&&this.setProperties(i),this.$t=!1,this.requestUpdate(),this}iF(){return this.xt!==null}get renderer(){return this.Uf}set renderer(t){if(this instanceof Overview)return;t===""&&(t="default");const i=t.toLowerCase(),e=this.Uf;if(i===e)return;this.Uf=i;let s=null;i==="default"||i==="canvas"?(s=this.Ql.get("svg"),s!==null&&s.Bt.remove(),this.xt&&(this.ei=this.xt.di),this.ei.clearContextCache(!0)):i==="svg"?(this.Ql.has("svg")?s=this.Ql.get("svg"):(s=new SVGSurface(this,root.document),this.addRenderer("svg",s)),this.div!==null&&this.div.appendChild(s.Bt),this.ei=s.di,this.xt&&(this.xt.di.setTransform(this.Gi,0,0,this.Gi,0,0),this.xt.di.clearRect(0,0,this.Ct,this.At))):i==="debug"&&(this.Ql.has("SVG")||(s=new SVGSurface(this,root.document),this.addRenderer("SVG",s),s.Bt.style.backgroundColor="whitesmoke",this.div!==null&&this.div.after(s.Bt))),this.$t||this.redraw()}wA(){this.Wf=new List,this.setupRouters(),this.ws=new AnimationManager,this.ws.Oo(this),this.yi=17,this.WM=!1,this.Ju=!1,this.Cx="default",this.Jt=new List,this.Ql=new GMap,this.Uf="default",this.resetRenderingHints(),this.qF(),this._t=1,this.mt=new Point(NaN,NaN).w(),this.fx=new Point(NaN,NaN),this.lt=1,this.s0=1,this.Ax=new Point(NaN,NaN).w(),this.Lx=NaN,this.Tx=1e-4,this.Dx=100,this.O=new Transform,this.Fx=new Point(NaN,NaN).w(),this.Rx=new Rect(NaN,NaN,NaN,NaN).w(),this.zf=new Margin(0,0,0,0).w(),this.vh=1,this.Ix=!1,this.Ox=null,this.Ex=null,this.Jl=1,this.Xf=Spot.Default,this.Fr=1,this.jm=Spot.Default,this.Vx=Spot.None,this.Bx=Spot.None,this.Ge=!0,this.Yu=!1,this.Qn=new Set,this.Rr=new GSet,this.$h=new GSet,this.Vo=!1,this.th=new GMap,this.Wu=!0,this.Wm=250,this.Yf=-1,this.vm=new Margin(16,16,16,16).w(),this.Ar=!1,this.Kf=!1,this.Ku=!0,this.e0=new InputEvent,this.e0.diagram=this,this.jr=new InputEvent,this.jr.diagram=this,this._h=new InputEvent,this._h.diagram=this,this.Ir=null,this._n=null,this.qw=!1,this.jF(),this.vr=new GSet,this.zx=!0,this.Xx=1,this.ZM=!1,this.Yx=1,this.Kx="auto",this.Jm="auto",this.Or=null,this.Er=null,this.Vr=null,this.Br=null,this.zr=null,this.Xr=null,this.Ux=null,this.Yr=null,this.Gx=!1,this.Kr=null,this.Ur=null,this.Gr=null,this.Hr=null,this.Hx=!1,this.d1={},this.ea=[null,null],this.Bo=!1,this.iP=!1,this.qx=!1,this.jx=!1,this.eP=!0,this.ks=!1,this.ia=!1,this.oP=!0,this.zs=-2,this._l=new GMap,this.vu=new List,this.zo=!1,this.Xi=!0,this.Wx=!0,this.Vl=!0,this.Bl=!0,this.vx=!1,this.Jx=!0,this.zl=!0,this.Xl=!0,this.Yl=!0,this.Zx=!0,this.Kl=!0,this.Ul=!0,this.Gl=!0,this.Hl=!0,this.ql=!0,this.jl=!0,this.Wl=!0,this.$x=!0,this.Qx=!0,this.rP=!1,this.qf=!1,this.Uu=!0,this.Gu=!0,this._x=!0,this.t1=!0,this.i1=16,this.e1=16,this.Zm=!1,this.s1=!1,this.o1=0,this.l1=0,this.ii=new Margin(5).w(),this.lP=new GSet().w(),this.h1=999999999,this.hP=new GSet().w(),this.ta=!0,this.Hu=!0,this.Gf=!0,this.xn=!1,this.to=!1,this.Wr=!0,this.Pl=!1,this.io=!1,this.dA=new GSet,this.mP=new GSet,this.Zl=null,this.aP=new Size(8,8),this.fP=999,this.$m=!1,this.eS=1,this.sS=0,this.Ui={scale:1,position:new Point,bounds:new Rect,canvasSize:new Size,newCanvasSize:new Size,isScroll:!1},this.Ui.canvasSize=this.Ui.canvasSize,this.Ui.newCanvasSize=this.Ui.newCanvasSize,this.Ui.isScroll=!1,this.a1=new Rect(NaN,NaN,NaN,NaN).w(),this.qu=new Size(NaN,NaN).w(),this.Qm=new Rect(NaN,NaN,NaN,NaN).w(),this.f1=!1,this.WF(),this.os=null,this.t0=!1,this.wf=null,this.partManager=new PartManager,this.toolManager=new ToolManager,this.toolManager.initializeStandardTools(),this.defaultTool=this.toolManager,this.currentTool=this.defaultTool,this.S1=null,this.M1=new DraggingOptions,this.P1=null,this.N1=null,this.k1=!1,this.Pu=!1,this.commandHandler=new CommandHandler,this.a0=null,this.f0=Point.Vk,this.kP=!1,this.Gi=1,this.Cl=null,this.Gm=1,this.l0=0,this.bP=[0,0,0,0,0],this.h0=0,this.o0=1,this.pP=0,this.yP=new Point,this.gA=500,this.i0=new Point,this.r0=!1}static bA=root.document!==void 0;static isUsingDOM(){return Diagram.bA}static useDOM(t){Diagram.bA=t?root.document!==void 0:!1}static He=new WeakMap;clear(){this.animationManager.stopAnimation(),this.model.clear(),Diagram.kA(),this.SA(!1),this.vu.clear(),this.MA(),this.Zl=null,this.invalidateDocumentBounds(),this.ensureBounds(),this.T()}SA(t){this.animationManager.stopAnimation(!0),this.lP=new GSet().w(),this.hP=new GSet().w();const i=this.skipsUndoManager,e=this.Ai!==null&&this.Ai!==void 0;e&&(this.skipsUndoManager=!0);let s=null;this.os!==null&&(s=this.os.part,s!==null&&this.remove(s));const n=[],o=this.Jt.length;if(t){for(let r=0;rt?new Margin(t/2):1.5)),this.c1=this._m,this.u1=new Adornment(Panel.Link).add(new Shape({isPanelMain:!0,fill:null,stroke:"dodgerblue",strokeWidth:3}).theme("stroke","selection").theme("strokeWidth","selection"))}setRTL(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);const e=Util.ln("div");e.dir="rtl",e.style.cssText="font-size: 14px; width: 1px; height: 1px; position: absolute; top: -1000px; overflow: scroll;",e.textContent="A",i.appendChild(e);let s="reverse";e.scrollLeft>0?s="default":(e.scrollLeft=1,e.scrollLeft===0&&(s="negative")),i.removeChild(e),this.Cx=s}setScrollWidth(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);let e=0;if(Diagram.isUsingDOM()){let s=Diagram.xP,n=Diagram.wP;s===null&&(Diagram.xP=Util.ln("p"),s=Diagram.xP,s.style.width="100%",s.style.height="200px",s.style.boxSizing="content-box",Diagram.wP=Util.ln("div"),n=Diagram.wP,n.style.position="absolute",n.style.visibility="hidden",n.style.width="200px",n.style.height="150px",n.style.boxSizing="content-box",n.appendChild(s)),n.style.overflow="hidden",i.appendChild(n);const o=s.offsetWidth;n.style.overflow="scroll";let r=s.offsetWidth;o===r&&(r=n.clientWidth),i.removeChild(n),e=o-r,e===0&&!Util.cr&&(e=11)}this.yi=e,this.WM=!0}fi(t){t in AutoScale?this.autoScale=t:Util.ur(this,t)}toString(t){t===void 0&&(t=0);let i="";this.div&&this.div.id&&(i=this.div.id);let e='Diagram "'+i+'"';if(t<=0)return e;const s=this.Jt.iterator;for(;s.next();){const n=s.value;e+=` - `+n.toString(t-1)}return e}static yA(t){Diagram.b1=t}static Mm(){return Diagram.b1}static fromDiv(t){let i=t;if(typeof t=="string"&&(i=root.document.getElementById(t)),i instanceof HTMLDivElement){const e=Diagram.He.get(i);if(e)return e}return null}get div(){return this.Ot}set div(t){if(t!==null&&Util.s(t,HTMLDivElement,Diagram,"div"),this.Ot!==t){const i=this.Ot;if(i!==null){if(Diagram.He.delete(i),i.goDiagram=void 0,i.go=void 0,i.innerHTML="",this.xt!==null){const s=this.xt.Bt;this.Li(s,"pointermove",this.na,!1),this.Li(s,"pointerdown",this.ih,!1),this.Li(s,"pointerup",this.oa,!1),this.Li(s,"pointerout",this.ra,!1),this.Li(s,"pointercancel",this.la,!1),this.xt.dispose()}this.Hf&&(this.Hf.disconnect(),this.Hf=null);const e=this.toolManager;e!==null&&(e.mouseDownTools.each(s=>s.cancelWaitAfter()),e.mouseMoveTools.each(s=>s.cancelWaitAfter()),e.mouseUpTools.each(s=>s.cancelWaitAfter())),e.cancelWaitAfter(),this.currentTool.doCancel(),this.xt=null,this.Li(root,"resize",this.w1,!1),this.Li(root,"wheel",this.sa,!0),Diagram.Mm()===this&&Diagram.yA(null)}else this.ih===null&&(this.io=!1);if(this.Ot=null,t!==null){const e=Diagram.He.get(t);e&&(e.div=null),this.MP(t),this.Nu(),this.themeManager&&this.themeManager.vF()}else this.themeManager&&this.themeManager.JF()}}setupRouters(){this.Wf.push(new AvoidsNodesRouter)}MP(t){const i=this;if(!Diagram.isUsingDOM())return;t==null&&Util.n("Diagram setup requires an argument DIV."),i.Ot!==null&&Util.n("Diagram has already completed setup."),typeof t=="string"?i.Ot=root.document.getElementById(t):t instanceof HTMLDivElement?i.Ot=t:Util.n("No DIV or DIV id supplied: "+t),i.Ot===null&&Util.n("Invalid DIV id; could not get element with id: "+t);const e=Diagram.He.get(i.Ot);if(e&&e!==this&&Util.n("Invalid div id; div already has a Diagram associated with it."),!i.Hf&&root.ResizeObserver){const f=root.ResizeObserver,c=Util.Ik(()=>i.requestUpdate(),250,!1);i.Hf=new f(()=>c()),i.Hf.observe(i.Ot)}root.getComputedStyle(i.Ot,null).position==="static"&&(i.Ot.style.position="relative");let s=5;const n="rgba(2"+s+"5, 255, 255, 0)";s--,i.Ot.style["-webkit-tap-highlight-color"]=n,i.Ot.innerHTML="",Diagram.He.set(i.Ot,i),i.Ot.goDiagram=i,i.Ot.go=root.go;const o=new CanvasSurface(i);o.style!==void 0&&(o.style.position="absolute",o.style.top="0px",o.style.left="0px",root.getComputedStyle(i.Ot,null).getPropertyValue("direction")==="rtl"&&(i.Ju=!0),o.style.zIndex="2",o.style.userSelect="none",o.style.MozUserSelect="none",o.style.touchAction="none",o.style.letterSpacing="normal !important",o.style.wordSpacing="normal !important",o.style.lang="unknown"),i.xt=o,i.ei=o.di;const r=i.ei;i.Gi=i.computePixelRatio(),i.viewSize.isReal()||(i.Ct=i.Ot.clientWidth||1,i.At=i.Ot.clientHeight||1),i.PA(i.Ct,i.At);const l=i;i.Ot.insertBefore(o.Bt,i.Ot.firstChild);const h=new CanvasSurface(null);if(h.width=1,h.height=1,i.BF=h,i.zF=h.di,Diagram.isUsingDOM()){const f=Util.ln("div"),c=Util.ln("div");f.style.position="absolute",f.style.overflow="auto",f.style.width=i.Ct+"px",f.style.height=i.At+"px",f.style.zIndex="1",c.style.position="absolute",c.style.width="1px",c.style.height="1px",i.Ot.appendChild(f),f.appendChild(c),f.onscroll=Diagram.ZF,f.addEventListener("pointerdown",Diagram.$F),f.b=i,f.QF=!0,f._F=!0,i.g1=f,i.m1=c}i.Nu=Util.Ik(()=>{i.Cl=null,i.T()},300,!1),i.w1=Util.Ik(()=>{i.RM()},250,!1),i.jh=f=>(f.preventDefault(),!1),i.sa=f=>{if(!l.isEnabled)return;const c=l.vf(f,!0);c.bubbles=!0;let u=0,d=0;c.delta=0,f.deltaX!==void 0?(f.deltaX!==0&&(u=f.deltaX>0?1:-1),f.deltaY!==0&&(d=f.deltaY>0?1:-1),c.delta=Math.abs(f.deltaX)>Math.abs(f.deltaY)?-u:-d):f.wheelDeltaX!==void 0?(f.wheelDeltaX!==0&&(u=f.wheelDeltaX>0?-1:1),f.wheelDeltaY!==0&&(d=f.wheelDeltaY>0?-1:1),c.delta=Math.abs(f.wheelDeltaX)>Math.abs(f.wheelDeltaY)?-u:-d):f.wheelDelta!==void 0&&f.wheelDelta!==0&&(c.delta=f.wheelDelta>0?1:-1),l.doMouseWheel(),l.ha(c,f)},i.mA=f=>{if(!l.isEnabled)return;i.qf=!1,l.vf(f,!0);const c=l.currentTool;c.cancelWaitAfter(),c.standardMouseOver()},i.ih=f=>{if(!l.isEnabled)return;i.qf=!0;const c=l.d1;c[f.pointerId]===void 0&&(c[f.pointerId]=f);const u=l.ea;let d=!1;if(u[0]!==null&&(u[0].pointerId===f.pointerId||u[0].pointerType!==f.pointerType))u[0]=f;else if(u[1]!==null&&u[1].pointerId===f.pointerId)u[1]=f,d=!0;else if(u[0]===null)u[0]=f;else if(u[1]===null)u[1]=f,d=!0;else{f.preventDefault();return}const m=f.pointerType==="touch"||f.pointerType==="pen";m&&(l.qw=!1,l.r0=!0);const g=l.tR(f,f,d),p=l.yP,y=m?25:10;if(f.timeStamp-l.pPy||Math.abs(p.y-f.screenY)>y)?l.o0++:l.o0=1,g.clickCount=l.o0,l.pP=f.timeStamp,l.yP.setTo(f.screenX,f.screenY),l.doMouseDown(),f.button===1){f.preventDefault();return}l.ha(g,f)},i.na=f=>{if(!l.isEnabled)return;i.qf=!0;const c=l.ea;if(c[0]!==null&&(c[0].pointerId===f.pointerId||c[0].pointerType!==f.pointerType))c[0]=f;else if(c[1]!==null&&c[1].pointerId===f.pointerId){c[1]=f;return}else if(c[0]===null)c[0]=f;else return;if(c[0].pointerId!==f.pointerId)return;const u=l.iR(f,f,c[1]!==null);l.doMouseMove(),l.ha(u,f)},i.oa=f=>{if(!l.isEnabled)return;i.qf=!0;const c=f.pointerType==="touch"||f.pointerType==="pen",u=l.d1;if(c&&l.qw){delete u[f.pointerId],f.preventDefault();return}const d=l.ea;if(d[0]!==null&&(d[0].pointerId===f.pointerId||d[0].pointerType!==f.pointerType))d[0]=null;else if(d[1]!==null&&d[1].pointerId===f.pointerId){d[1]=null;return}else return;const m=l.PP(f,!1,!0,!1,!0,!1);let g=root.document.elementFromPoint(f.clientX,f.clientY)||null;g!==null&&g.shadowRoot!==void 0&&g.shadowRoot!==null&&(g=g.shadowRoot.elementFromPoint(f.clientX,f.clientY)),g!==null&&g.b instanceof Diagram&&g.b!==l&&g.b.u0(f,m),g===null&&(g=f.target),l.u0(f,m),m.clickCount=l.o0,m.targetDiagram=l.NP(f,g),m.targetObject=null,l.doMouseUp(),l.ha(m,f),c&&(l.r0=!1)},i.ra=f=>{if(!l.isEnabled)return;i.qf=!1;const c=l.d1;c[f.pointerId]&&delete c[f.pointerId];const u=l.ea;if(u[0]!==null&&u[0].pointerId===f.pointerId&&(u[0]=null),u[1]!==null&&u[1].pointerId===f.pointerId&&(u[1]=null),f.pointerType==="touch"||f.pointerType==="pen")return;const d=l.currentTool;d.cancelWaitAfter(),d.standardMouseOver()},i.la=f=>{const c=l.ea;c[0]!==null&&c[0].pointerId===f.pointerId?(c[0]=null,l.r0=!1):c[1]!==null&&c[1].pointerId===f.pointerId&&(c[1]=null)};const a=r;if(i.p1=a.Y[Util.Fs("7eba17a4ca3b1a8346")][Util.Fs("78a118b7")](a.Y,Diagram.Zu,s,s),r.clearContextCache(!0),i.eR(),this.Uf==="svg"){const f=this.Ql.get("svg");this.Ot.appendChild(f.Bt),this.ei=f.di}}addEventListener(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}Ht(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}removeEventListener(t,i,e,s){t.removeEventListener(i,e,{capture:s})}Li(t,i,e,s){t.removeEventListener(i,e,{capture:s})}eR(){const t=this;let i=this.xt.Bt;i instanceof HTMLCanvasElement||(i=t.div),this.Ht(i,"pointerdown",t.ih,!1),this.Ht(i,"pointermove",t.na,!1),this.Ht(i,"pointerup",t.oa,!1),this.Ht(i,"pointerout",t.ra,!1),this.Ht(i,"pointercancel",t.la,!1),this.Ht(i,"pointerenter",t.sR,!1),this.Ht(i,"pointerleave",t.nR,!1),this.Ht(i,"wheel",t.sa,!1),this.Ht(i,"keydown",t.oR,!1),this.Ht(i,"keyup",t.rR,!1),this.Ht(i,"blur",t.lR,!1),this.Ht(i,"focus",t.hR,!1),this.Ht(i,"selectstart",e=>(e.preventDefault(),!1),!1),this.Ht(i,"contextmenu",e=>(e.preventDefault(),!1),!1),this.Ht(root,"resize",t.w1,!1)}jw(){this.l0>30&&(this.Cl=1)}NS(t){this.Cl!==null&&(this.Cl=null,t&&this.Nu(),Debug&&Debug.drawFrames||(this.l0=0,this.bP=[0,0,0,0,0],this.h0=0))}computePixelRatio(){return this.Cl!==null?this.Cl:root.devicePixelRatio||1}get avgSpf(){return this.l0}doMouseDown(){this.currentTool.doMouseDown()}doMouseMove(){this.currentTool.doMouseMove()}doMouseUp(){this.currentTool.doMouseUp()}doMouseWheel(){this.currentTool.doMouseWheel()}doKeyDown(){this.currentTool.doKeyDown()}doKeyUp(){this.currentTool.doKeyUp()}doFocus(){this.focus()}focus(){if(this.xt)if(this.scrollsPageOnFocus)this.xt.focus();else{const t=root.scrollX,i=root.scrollY;this.xt.focus(),root.scrollTo(t,i)}}hR(t){const i=Diagram.He.get(this);i&&i.V("GainedFocus")}lR(t){const i=Diagram.He.get(this);i&&i.V("LostFocus")}RM(){if(this.xt===null)return;const i=this.Ot;if(i===null||i.clientWidth===0||i.clientHeight===0)return;this.WM||this.setScrollWidth();const e=this.to?this.yi:0,s=this.xn?this.yi:0,n=this.Gi;if(this.Gi=this.computePixelRatio(),this.Gi!==n&&(this.Yu=!0,this.requestUpdate()),i.clientWidth!==this.Ct+e||i.clientHeight!==this.At+s){this.aa(),this.Ge=!0;const o=this.layout;o!==null&&o.isViewportSized&&this.autoScale===1&&(this.Kf=!0,o.invalidateLayout()),this.ks||this.requestUpdate()}}xA(){let t=0,i=new Layer;i.name="Grid",i.allowSelect=!1,i.pickable=!1,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="ViewportBackground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="Background",this.Jr(i,t++),i=new Layer,i.name="",this.Jr(i,t++),i=new Layer,i.name="Foreground",this.Jr(i,t++),i=new Layer,i.name="ViewportForeground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="Adornment",i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="Tool",i.isTemporary=!0,i.isInDocumentBounds=!0,this.Jr(i,t++)}NA(){const t=new Panel(Panel.Grid,{name:"GRID"}).add(new Shape("LineH",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineV",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineH",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineH",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor")),i=new Part({layerName:"Grid",zOrder:0,isInDocumentBounds:!1,isAnimated:!1,pickable:!1,locationObjectName:"GRID"}).add(t);return this.add(i),this.partManager.parts.delete(i),t.visible=!1,t}static ZF(){const t=Diagram.He.get(this.parentElement||this);if(t){if(t.s1){t.s1=!1;return}if(!t.isEnabled){t.CA();return}t.diagramScroll(this)}}static $F(t){if(!this.b.isEnabled){this.b.updateScroll();return}this.b.o1=t.target.scrollTop,this.b.l1=t.target.scrollLeft}diagramScroll(t){if(this.xt===null)return;const i=this.g1,e=this.m1;this.Zm=!0;let s=this.documentBounds,n=this.viewportBounds;const o=this.zf;let r=s.x-o.left,l=s.y-o.top;const h=s.width+o.left+o.right,a=s.height+o.top+o.bottom;let f=s.right+o.right,c=s.bottom+o.bottom,u=n.x,d=n.y;const m=n.width,g=n.height;let p=n.right,y=n.bottom;const x=this.scale;let k,b=t.scrollLeft;if(this.Ju)switch(this.Cx){case"negative":b=b+t.scrollWidth-t.clientWidth;break;case"reverse":b=t.scrollWidth-b-t.clientWidth;break}const S=b;if(mp)){const M=i.scrollWidth-this.Ct;this.position=k.e(-M+S-this.Ct/x+f,this.position.y)}if(t._F&&this.allowVerticalScroll&&(ly)){const M=i.scrollHeight-this.At;this.position=k.e(this.position.x,-M+t.scrollTop-this.At/x+c)}Point.o(k),this.sh(),this.Zm=!1,this.Hu=!1,s=this.documentBounds,n=this.viewportBounds,f=s.right,p=n.right,c=s.bottom,y=n.bottom,r=s.x,u=n.x,l=s.y,d=n.y,m>=h&&r>=u&&f<=p&&(e.style.width="1px"),g>=a&&l>=d&&c<=y&&(e.style.height="1px")}computeBounds(t){return t===void 0&&(t=new Rect),this.Di(),this.AA(t)}AA(t){if(this.fixedBounds.isReal())return t.c(this.fixedBounds),t.addMargin(this.ii),t;let i=!0;const e=this.Jt.h,s=e.length;for(let n=0;ni&&(a=i),athis.maxScale&&(a=this.maxScale),a):t===3?(a=0,h>l?a=(r-this.yi)/n:a=(o-this.yi)/s,a>i&&(a=i),athis.maxScale&&(a=this.maxScale),a):this.scale}zoomToFit(){const t=this.vh;this.vh=1,this.scale=this.$u(2),t!==1&&(this.Gs(!1),this.CP(this.documentBounds,this.Ct/this.lt,this.At/this.lt,this.Xf,!1)),this.vh=t}zoomToRect(t,i){i===void 0&&(i=2);const e=t.width,s=t.height;if(e===0||s===0||isNaN(e)&&isNaN(s))return;let n=1;if(i===2||i===3)if(isNaN(e))n=this.viewportBounds.height*this.scale/s;else if(isNaN(s))n=this.viewportBounds.width*this.scale/e;else{const o=this.Ct,r=this.At;i===3?r/s>o/e?n=(r-(this.xn?this.yi:0))/s:n=(o-(this.to?this.yi:0))/e:n=Math.min(r/s,o/e)}this.scale=n,this.position=new Point(t.x,t.y)}get aR(){return this.$t}set aR(t){this.$t=t}alignDocument(t,i){this.ensureBounds();const e=this.documentBounds,s=this.viewportBounds;this.position=new Point(e.x+(t.x*e.width+t.offsetX)-(i.x*s.width-i.offsetX),e.y+(t.y*e.height+t.offsetY)-(i.y*s.height-i.offsetY))}focusObject(t){if(t instanceof GraphObject){this.a0=t;const i=Point.a();this.f0=this.transformDocToView(t.getDocumentPoint(Spot.TopLeft,i)),Point.o(i)}else this.a0=null,this.f0=Point.Vk}CP(t,i,e,s,n){const o=Point.H(this.mt.x,this.mt.y);let r=o.x,l=o.y;if(this.a0!==null){let h=Point.a();h=this.a0.getDocumentPoint(Spot.TopLeft,h),r=h.x-this.f0.x/this.scale,l=h.y-this.f0.y/this.scale,s=Spot.None,Point.o(h)}if(n||this.scrollMode===1){s.isSpot()&&(i>t.width&&(r=t.x+(s.x*t.width+s.offsetX)-(s.x*i-s.offsetX)),e>t.height&&(l=t.y+(s.y*t.height+s.offsetY)-(s.y*e-s.offsetY)));const h=this.zf,a=i-t.width;if(it.left?r=t.left:rt.top?l=t.top:ls.part,s=>s.canSelect());if(e instanceof Part)return e}else{const e=this.DS(t,s=>s.part);if(e instanceof Part)return e}return null}findObjectAt(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Di();const s=this.Jt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}DS(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Di();const s=this.Jt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible||n.isTemporary)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}findPartsAt(t,i,e){return i===void 0&&(i=!0),this.cR(t,s=>s.part,i?s=>s instanceof Part&&s.canSelect():null,e)}cR(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Di();const n=this.Jt.iteratorBackwards;for(;n.next();){const o=n.value;!o.visible||o.isTemporary||o.findObjectsAt(t,i,e,s)}return s}findObjectsAt(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Di();const n=this.Jt.iteratorBackwards;for(;n.next();){const o=n.value;o.visible&&o.findObjectsAt(t,i,e,s)}return s}findPartsIn(t,i,e,s){return i===void 0&&(i=!1),e===void 0&&(e=!0),this.uR(t,null,n=>n instanceof Part&&(!e||n.canSelect()),i,s)}findObjectsIn(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Di();const o=this.Jt.iteratorBackwards;for(;o.next();){const r=o.value;r.visible&&r.findObjectsIn(t,i,e,s,n)}return n}IS(t,i,e,s,n,o){const r=new GSet;this.Di();const l=this.Jt.iteratorBackwards;for(;l.next();){const h=l.value;h.visible&&h.IS(t,i,e,s,r,n,o)}return r}uR(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Di();const o=this.Jt.iteratorBackwards;for(;o.next();){const r=o.value;!r.visible||r.isTemporary||r.findObjectsIn(t,i,e,s,n)}return n}findPartsNear(t,i,e,s,n){return e===void 0&&(e=!0),s===void 0&&(s=!0),this.dR(t,i,null,o=>o instanceof Part&&(!s||o.canSelect()),e,n)}findObjectsNear(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Di();const r=this.Jt.iteratorBackwards;for(;r.next();){const l=r.value;l.visible&&l.findObjectsNear(t,i,e,s,n,o)}return o}dR(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Di();const r=this.Jt.iteratorBackwards;for(;r.next();){const l=r.value;!l.visible||l.isTemporary||l.findObjectsNear(t,i,e,s,n,o)}return o}acceptEvent(t){return this.vf(t,t instanceof MouseEvent)}vf(t,i){const e=this.jr;this.jr=this._h,this._h=e,e.diagram=this,e.event=t,i?this.u0(t,e):(e.viewPoint=this.jr.viewPoint,e.documentPoint=this.jr.documentPoint);let s=0;const n=t;return n.ctrlKey&&(s+=1),n.altKey&&(s+=2),n.shiftKey&&(s+=4),n.metaKey&&(s+=8),e.modifiers=s,e.button=n.button,n.buttons!==void 0&&(e.buttons=n.buttons),Util.cr&&n.button===0&&n.ctrlKey&&(e.button=2),e.down=!1,e.up=!1,e.clickCount=1,e.delta=0,e.handled=!1,e.bubbles=!1,e.timestamp=t.timeStamp,e.isMultiTouch=!1,e.targetDiagram=this.NP(t,t.target),e.targetObject=null,e}NP(t,i){if(i===null)return null;const e=Diagram.He.get(i);if(e)return e;let s=t.path;if(!s&&typeof t.composedPath=="function"&&(s=t.composedPath()),s&&s[0]){const n=Diagram.He.get(s[0]);if(n)return n}return null}tR(t,i,e){const s=this.PP(t,!0,!1,!1,!0,e);return this.u0(i,s),s.targetDiagram=this.NP(t,t.target),s.targetObject=null,e||s.clone(this.e0),s}iR(t,i,e){const s=this.PP(t,!1,!1,!1,!1,e);let n=root.document.elementFromPoint(i.clientX,i.clientY)||null;n!==null&&n.shadowRoot!==void 0&&n.shadowRoot!==null&&(n=n.shadowRoot.elementFromPoint(i.clientX,i.clientY));let o=this,r=t;if(n){const l=Diagram.He.get(n);l&&(r=i,o=l)}return s.targetDiagram=o,this.u0(r,s),s.targetObject=null,s}PP(t,i,e,s,n,o){const r=this.jr;this.jr=this._h,this._h=r,r.diagram=this,r.clickCount=1,r.delta=0;let l=0;return t.ctrlKey&&(l+=1),t.altKey&&(l+=2),t.shiftKey&&(l+=4),t.metaKey&&(l+=8),r.modifiers=l,r.event=t,r.timestamp=t.timeStamp,r.button=e?this.firstInput.button:t.button,r.buttons=t.buttons,Util.cr&&t.button===0&&t.ctrlKey&&(r.button=2),r.down=i,r.up=e,r.handled=s,r.bubbles=n,r.isMultiTouch=o,r}ha(t,i){return t.bubbles?(Debug&&Debug.handleMessages&&Util.at("NOT handled "+i.type+" "+t.toString()),!0):(Debug&&Debug.handleMessages&&Util.at("handled "+i.type+" "+this.currentTool.name+" "+t.toString()),i.stopPropagation!==void 0&&i.stopPropagation(),i.cancelable!==!1&&i.preventDefault(),i.cancelBubble=!0,!1)}oR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.vf(t,!1);return e.key=t.key,e.code=t.code,e.down=!0,i.doKeyDown(),i.ha(e,t)}rR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.vf(t,!1);return e.key=t.key,e.code=t.code,e.up=!0,i.doKeyUp(),i.ha(e,t)}sR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.vf(t,!0);return i.mouseEnter!==null&&i.mouseEnter(e),i.currentTool.standardMouseOver(),i.ha(e,t)}nR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.vf(t,!0);return i.mouseLeave!==null&&i.mouseLeave(e),i.ha(e,t)}getMouse(t){const i=this.xt;if(i===null)return new Point(0,0);const e=i.getBoundingClientRect(),s=(t.clientX-e.left)*(this.Ct/e.width),n=(t.clientY-e.top)*(this.At/e.height);return new Point(s,n).Ye(this.O)}u0(t,i){const e=this.xt;let s=0,n=0;if(e!==null){const r=e.getBoundingClientRect();s=(t.clientX-r.left)*(this.Ct/r.width),n=(t.clientY-r.top)*(this.At/r.height)}i.viewPoint.e(s,n);const o=Point.H(s,n);this.O.ns(o),i.documentPoint.c(o),Point.o(o)}DC(t,i,e){let s;if(this.ea[0]!==null)s=this.ea[i];else return;const n=this.xt;if(n!==null){const o=n.getBoundingClientRect();e.e((s.clientX-o.left)*(this.Ct/o.width),(s.clientY-o.top)*(this.At/o.height))}}invalidateDocumentBounds(){this.ta||(this.ta=!0,this.requestUpdate(!1))}gR(){this.ks||this.Di(),this.ensureBounds()}redraw(){this.$t||this.ks||(this.T(),this.maybeUpdate())}isUpdateRequested(){return this.Ar}delayInitialization(t){t===void 0&&(t=null);const i=this.animationManager,e=i.isEnabled;i.stopAnimation(),i.isEnabled=!1,this.Sr(),this.io=!1,this.fx=new Point(NaN,NaN),i.isEnabled=e,this.ks=!0;const s=this;t!==null&&Util.Bh(()=>{s.ks=!1,i.El("Model"),t(s)},1)}requestUpdate(t){if(t===void 0&&(t=!1),this.Ar===!0||this.$t||t===!1&&this.ks)return;this.Ar=!0;const i=this;root.requestAnimationFrame(()=>{i.Ar&&i.maybeUpdate()})}maybeUpdate(){this.Ku&&!this.Ar||(this.Ku&&(this.Ku=!1),this.Sr())}AP(t,i){!this.Hu||this.$t||this.animationManager.defaultAnimation.isAnimating||this.CA()||(t&&this.Di(),i&&this.Gs(!1))}Sr(t){if(this.ks||(this.Ar=!1,this.Ot===null&&!this.qu.isReal()))return;this.ks=!0;const i=this.animationManager,e=this.vu;if(!i.isAnimating&&e.length!==0){const f=e.h,c=f.length;for(let u=0;u0&&(s.each(f=>f.LP()),s.clear());let n=!1,o=!1;i.defaultAnimation.isAnimating&&(o=!0,n=this.skipsUndoManager,this.skipsUndoManager=!0),i.Si||this.RM(),t||this.AP(!1,!0);const r=!this.undoManager.isUndoingRedoing&&(this.Pl||this.Wf.count!==0&&this.Rr.size!==0),l=!this.io||this.Wr;this.Di(!0);let h=!1;(l||r)&&(this.io?this.TP(!this.Kf,r):(this.startTransaction("Initial Layout"),i.isEnabled===!1&&i.stopAnimation(),this.TP(!1,r)),h=l),this.Kf=!1,this.Pl=!1,this.Di(),this.os!==null&&(this.os.visible&&!this.t0&&(this.Zr(),this.t0=!0),!this.os.visible&&this.t0&&(this.t0=!1)),this.qx||this.gR(),t||this.AP(!0,!1);let a=!1;if(h){const f=Rect.a();f.c(this.viewportBounds),this.io||(this.io=!0,a=!0,this.skipsUndoManager||(this.undoManager.Uw=!0),this.undoManager.Gw=!0,this.mR()),this.pR(),this.Di(!1),t||this.AP(!0,!0),Rect.o(f)}else if(i.Df&&i.ax){if(this.Fr!==1)this.scale=this.$u(this.Fr);else if(this.Jl!==1)this.scale=this.$u(this.Jl);else{const f=this.initialScale;isFinite(f)&&f>0&&(this.scale=f)}this.Gs(!0)}h&&a&&this.commitTransaction("Initial Layout"),t||this.Ji(this.ei),o&&(this.skipsUndoManager=n),this.ks=!1}get Yh(){return this.io}mR(){if(this.Fr!==1)this.scale=this.$u(this.Fr);else if(this.Jl!==1)this.scale=this.$u(this.Jl);else{const i=this.initialScale;isFinite(i)&&i>0&&(this.scale=i)}this.Gs(!0);const t=this.Jt.h;this.Us(t,t.length,this,this.viewportBounds),this.V("InitialLayoutCompleted"),this.fx.c(this.mt),this.Zr()}pR(){this.V("LayoutCompleted")}d0(t){this.Qn.add(t)}addInvalidRoute(t){this.Vo?this.$h.add(t):this.Rr.add(t)}Di(t){if(this.Qn.size!==0&&!(!this.ks&&this.animationManager.isTicking)){if(this.ks||(this.Pl=!0),t){this.LA(this.Qn);return}for(let i=0;i<23&&this.Qn.size!==0;i++){const e=new Set(this.Qn);this.Qn.clear(),this.LP(e,this.Qn),Debug&&i===22&&Util.at("failure to validate parts")}this.nodes.each(i=>{i instanceof Group&&i.TA(!1)})}}LA(t,i){for(const e of t)!e.Ae()||e instanceof Group||(e.$r()?(e.wt(1/0,1/0),e.qt()):i&&i.add(e));for(const e of t)if(e instanceof Group){if(!e.isVisible())continue;this.T1(e)}}LP(t,i){this.LA(t,i);for(const e of t){if(!(e instanceof Link))continue;const s=e;s.isVisible()&&(s.$r()?(s.wt(1/0,1/0),s.qt()):i.add(s))}for(const e of t)e instanceof Adornment&&e.isVisible()&&(e.$r()?(e.wt(1/0,1/0),e.qt()):i.add(e))}g0(t){const i=t instanceof Diagram,e=i?t.links:t.memberParts,s=this.Qn;if(i)this.Di(!0);else{for(;e.next();){const n=e.value;s.has(n)&&(!n.Ae()||n instanceof Group||n.$r()&&(n.wt(1/0,1/0),n.qt()))}for(e.reset();e.next();){const n=e.value;if(s.has(n)&&n instanceof Group){if(!n.isVisible())continue;this.T1(n)}}e.reset()}for(;e.next();){const n=e.value;n instanceof Link&&s.has(n)&&n.isVisible()&&n.$r()&&(n.wt(1/0,1/0),n.qt())}}T1(t){const i=Util.ft(),e=Util.ft(),s=t.memberParts;for(;s.next();){const o=s.value;o.isVisible()&&(o instanceof Group?(o.Xo()||o.rs()||o.nh())&&this.T1(o):o instanceof Link?o.fromNode===t||o.toNode===t?e.push(o):i.push(o):(o.wt(1/0,1/0),o.qt()))}let n=i.length;for(let o=0;ob.zu())}else for(let x=0;x0){const a=n.substring(0,h);e?o=t.findObject(a):(o=t[a],o==null&&(o=t.toolManager[a])),Util.Mt(o)?r=n.substring(h+1):Util.n("Unable to find object named: "+a+" in "+t.toString()+" when trying to set property: "+n)}}if(r[0]!=="_"&&!Util.yw(o,r))if(s&&r==="ModelChanged"){t.addModelChangedListener(i[r]);continue}else if(s&&r==="Changed"){t.addChangedListener(i[r]);continue}else if(s&&Util.yw(t.toolManager,r))o=t.toolManager;else if(s&&t.DA(r)){t.addDiagramListener(r,i[r]);continue}else if(t instanceof Model&&r==="Changed"){t.addChangedListener(i[r]);continue}else Util.n('Trying to set undefined property "'+r+'" on object: '+o.toString());const l=i[n];o[r]=l,r[0]==="_"&&o instanceof GraphObject&&o.addCopyProperty(r)}}xR(){if(this.th.count!==0&&!(this.undoManager.transactionLevel>1)){for(;this.th.count>0;){const t=this.th;this.th=new GMap;const i=t.iterator;for(;i.next();){const e=i.key;e.invalidateOtherJumpOvers(i.value),e.re()}}this.T()}}T(t){if(t===void 0)this.Ge=!0,this.requestUpdate();else{const i=this.viewportBounds;t.isReal()&&i.intersectsRect(t)&&(this.Ge=!0,this.requestUpdate())}this.V("InvalidateDraw")}invalidateViewport(t,i){if(this.Ge===!0)return;if(this.Ge=!0,this.Uf==="svg"){this.maybeUpdate();return}this.getRenderingHint("temporaryPixelRatio")===!0?(this.jw(),this.maybeUpdate(),this.NS(!0)):this.maybeUpdate()}aa(){this.Hu=!0}sh(){this.Gf=!0}m0(){this.Yu!==!1&&(this.Yu=!1,this.PA(this.Ct,this.At))}PA(t,i){this.eh();const e=this.Gi,s=t*e,n=i*e;this.xt.resize(s,n,t,i)&&(this.Ge=!0,this.ei.clearContextCache(!0))}CA(){const t=this.xt;if(t===null||this.qu.isReal())return!0;const i=this.Ct,e=this.At,s=this.Ot;let n=!1,o=this.to?this.yi:0,r=this.xn?this.yi:0,l=s.clientWidth||i+o,h=s.clientHeight||e+r;const a=this.viewportBounds,f=a.x,c=a.y,u=a.width,d=a.height;if((l!==i+o||h!==e+r)&&(this.to=!1,this.xn=!1,o=0,r=0,this.Ct=l,this.At=h,this.Yu=!0,n=!0,this.eh()),!this.io||!this.viewportBounds.isReal())return!0;const m=this.g1,g=this.m1;if(this.Hu=!1,!n&&!this.to&&!this.xn&&!this.Uu&&!this.Gu)return!0;const p=this.documentBounds;let y=0,x=0,k=0,b=0;const S=a.width,M=a.height,A=this.zf;this.contentAlignment.isSpot()?(p.width>S&&(y=A.left,x=A.right),p.height>M&&(k=A.top,b=A.bottom)):(y=A.left,x=A.right,k=A.top,b=A.bottom);const C=p.width+y+x,P=p.height+k+b,N=this.scale,T=N;let L=C>l/N,D=P>h/N;if(!n&&!this.to&&!this.xn&&!L&&!D)return!0;const F=p.x-y,R=a.x,I=p.right+x;let O=a.right+o;const B=p.y-k,K=a.y,V=p.bottom+b;let X=a.bottom+r,z="1px",G="1px";if(this.scrollMode===1&&(L||D)){if(L&&this.hasHorizontalScrollbar&&this.allowHorizontalScroll){let Y=1;F+1O+1&&(Y=Math.max((I-O)*N+this.Ct,Y)),S+o+1X+1&&(Y=Math.max((V-X)*N+this.At,Y)),M+r+1O+1&&(v=Math.max((I-O)*N+this.Ct,v)),S+1X+1&&(v=Math.max((V-X)*N+Y,v)),M+1O+1&&(J=this.position.x*N)),this.Ju)switch(this.Cx){case"negative":J=-(m.scrollWidth-J-m.clientWidth);break;case"reverse":J=m.scrollWidth-J-m.clientWidth;break}if(m.scrollLeft=J,this.hasVerticalScrollbar&&this.allowVerticalScroll&&(M+1X+1&&(m.scrollTop=this.position.y*N)),l=this.Ct,h=this.At,m.style.width=l+(this.to?this.yi:0)+"px",m.style.height=h+(this.xn?this.yi:0)+"px",i!==l||e!==h||this.animationManager.Si){const Y=Rect.H(f,c,u,d);return this.onViewportBoundsChanged(Y,this.viewportBounds,T,n),Rect.o(Y),!1}return!0}add(t){Util.s(t,Part,Diagram,"add:part");const i=t.diagram;if(i===this)return;i!==null&&Util.n("Cannot add part "+t.toString()+" to "+this.toString()+". It is already a part of "+i.toString());let e=this.findLayer(t.layerName);if(e===null&&(e=this.findLayer("")),e===null&&Util.n('Cannot add a Part when unable find a Layer named "'+t.layerName+'" and there is no default Layer'),t.layer===e)return;const s=e.Zh(99999999,t,t.diagram===this);s>=0&&this.raiseChangedEvent(3,"parts",e,null,t,null,s),e.isTemporary||this.invalidateDocumentBounds(),t.invalidateLayout(1);const n=t.layerChanged;n!==null&&n(t,null,e)}Zh(t){this.partManager.Zh(t);const i=this;t.Qr(s=>i.FA(s)),t.data||t.Yo(),t.hasPlaceholder()&&t.u(),t.data!==null&&t.Qr(s=>i.partManager.FP(s,null)),(t.rs()===!0||t.nh()===!0)&&this.d0(t),t.RA(!0,this),t.IA()?(t.actualBounds.isReal()&&this.T(t.Jh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.T(t.Jh(t.actualBounds)),this.requestUpdate()}ne(t){t.clearAdornments(),this.partManager.ne(t);const i=this;t.data!==null&&t.Qr(s=>i.partManager.RP(s,i)),this.Qn.delete(t),t instanceof Link&&this.Rr.delete(t),t.IA()?(t.actualBounds.isReal()&&this.T(t.Jh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.T(t.Jh(t.actualBounds)),this.requestUpdate()}remove(t){Util.s(t,Part,Diagram,"remove:part"),this.IP(t,!0)}IP(t,i){const e=t.layer;if(e===null||e.diagram!==this)return;t.isSelected=!1,t.isHighlighted=!1,t.invalidateLayout(2),i&&t.Jf();const s=e.ne(-1,t,!1);s>=0&&this.raiseChangedEvent(4,"parts",e,t,null,s,null);const n=t.layerChanged;n!==null&&n(t,e,null)}removeParts(t,i){if(i===void 0&&(i=!1),Array.isArray(t)){const e=t.length;for(let s=0;s=0&&i.elt(e).isTemporary;)e--;return i.insertAt(e+1,t),this.Ai!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,e+1),this.T(),this.invalidateDocumentBounds(),this}addLayerBefore(t,i){this.OP(t,i),t.Oo(this);const e=this.Jt,s=e.indexOf(t);s>=0&&(e.delete(t),this.Ai!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;o=0&&(e.delete(t),this.Ai!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;othis.maxScale&&(i=this.maxScale);const f=Point.H(this.mt.x+l/t-l/i,this.mt.y+h/t-h/i);this.position=f,Point.o(f),this.lt=i,this.eh(),this.$t=!1,this.onViewportBoundsChanged(n,this.viewportBounds,t,!1),this.Gs(!1),e.rA(t,this.lt),this.T()}fR(){const t=this.Jt.h;for(let i=0;i{r.isAvoiding&&r.actualBounds.intersectsRect(i)&&r.invalidateRoute()})}Zr(t){const i=this.os;if(i===null||!i.visible||i.layer===null)return;const e=t!==void 0?t:this.a1;if(!e.isReal())return;const s=e.width,n=e.height;if(i.scale=1,i.angle=0,i.layer.isViewportAligned)i.width=s*this.scale,i.height=n*this.scale,i.part.alignment=Spot.TopLeft;else{i.Mi===null&&(i.Mi=new GridPanelSettings);const o=i.Mi.Zf;if(!o.isReal())return;i.width=s+o.width*2,i.height=n+o.height*2;const r=Point.a();Geo.Hg(e.x,e.y,0,0,o.width,o.height,r),r.offset(-o.width,-o.height),i.part.location=r,Point.o(r)}}clearSelection(t){t===void 0&&(t=!1);const i=this.selection;if(i.count===0)return;t||this.V("ChangingSelection",i);const e=i.toArray(),s=e.length;for(let n=0;n1)&&(this.V("ChangingSelection",this.selection),this.clearSelection(!0),t.isSelected=!0,this.V("ChangedSelection",this.selection)))}selectCollection(t){if(this.V("ChangingSelection",this.selection),this.clearSelection(!0),Array.isArray(t)){const i=t.length;for(let e=0;e0){const i=t.toArray(),e=i.length;for(let s=0;s1)&&(this.clearHighlighteds(),t.isHighlighted=!0))}highlightCollection(t){const i=new GSet().addAll(t),s=this.highlighteds.copy().removeAll(i).iterator;for(;s.next();){const o=s.value;o.isHighlighted=!1}const n=i.iterator;for(;n.next();){const o=n.value;o instanceof Part||Util.n("Diagram.highlightCollection given something that is not a Part: "+o),o.isHighlighted=!0}}scroll(t,i,e){e===void 0&&(e=1);const s=i==="up"||i==="down";let n=0;const o=Point.a();if(t==="pixel")n=e;else if(t==="line")n=e*(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange);else if(t==="page"){let l=s?this.viewportBounds.height:this.viewportBounds.width;if(l*=this.scale,l!==0){const h=Math.max(l-(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange),0);n=e*h}}else if(t==="document"){const l=this.documentBounds,h=this.viewportBounds;i==="up"?this.position=o.e(h.x,l.y):i==="left"?this.position=o.e(l.x,h.y):i==="down"?this.position=o.e(h.x,l.bottom-h.height):i==="right"&&(this.position=o.e(l.right-h.width,h.y)),Point.o(o);return}else Util.n("scrolling unit must be 'pixel', 'line', 'page', or 'document', not: "+t);n/=this.scale;const r=this.position;i==="up"?this.position=o.e(r.x,r.y-n):i==="down"?this.position=o.e(r.x,r.y+n):i==="left"?this.position=o.e(r.x-n,r.y):i==="right"?this.position=o.e(r.x+n,r.y):Util.n("scrolling direction must be 'up', 'down', 'left', or 'right', not: "+i),Point.o(o)}scrollToRect(t){const i=this.viewportBounds;if(i.containsRect(t))return;const e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}centerRect(t){const i=this.viewportBounds,e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}transformDocToView(t){return t.copy().O(this.O)}transformViewToDoc(t){return t.copy().Ye(this.O)}VF(t){return t.Ye(this.O)}static None=1;static Uniform=2;static UniformToFill=3;static CycleAll=1;static CycleNotDirected=2;static CycleNotDirectedFast=3;static CycleNotUndirected=4;static CycleDestinationTree=5;static CycleSourceTree=6;static DocumentScroll=1;static InfiniteScroll=2;static TreeParentCollapsed=1;static AllParentsCollapsed=2;static AnyParentsCollapsed=3;get opacity(){return this._t}set opacity(t){const i=this._t;i!==t&&(Util.t(t,"number",Diagram,"opacity"),(t<0||t>1)&&Util.G(t,"0 <= value <= 1",Diagram,"opacity"),this._t=t,this.i("opacity",i,t),this.T())}get validCycle(){return this.Yx}set validCycle(t){const i=this.Yx;i!==t&&(Util.tt(t,CycleMode,"CycleMode"),this.Yx=t,this.i("validCycle",i,t))}get layers(){return this.Jt.iterator}get isModelReadOnly(){const t=this.Ai;return t===null?!1:t.isReadOnly}set isModelReadOnly(t){const i=this.Ai;i!==null&&(i.isReadOnly=t)}get isReadOnly(){return this.zo}set isReadOnly(t){const i=this.zo;i!==t&&(Util.t(t,"boolean",Diagram,"isReadOnly"),this.zo=t,this.i("isReadOnly",i,t))}get isEnabled(){return this.Xi}set isEnabled(t){const i=this.Xi;i!==t&&(Util.t(t,"boolean",Diagram,"isEnabled"),this.Xi=t,this.i("isEnabled",i,t))}get allowClipboard(){return this.Wx}set allowClipboard(t){const i=this.Wx;i!==t&&(Util.t(t,"boolean",Diagram,"allowClipboard"),this.Wx=t,this.i("allowClipboard",i,t))}get allowCopy(){return this.Vl}set allowCopy(t){const i=this.Vl;i!==t&&(Util.t(t,"boolean",Diagram,"allowCopy"),this.Vl=t,this.i("allowCopy",i,t))}get allowDelete(){return this.Bl}set allowDelete(t){const i=this.Bl;i!==t&&(Util.t(t,"boolean",Diagram,"allowDelete"),this.Bl=t,this.i("allowDelete",i,t))}get allowDragOut(){return this.vx}set allowDragOut(t){const i=this.vx;i!==t&&(Util.t(t,"boolean",Diagram,"allowDragOut"),this.vx=t,this.i("allowDragOut",i,t))}get allowDrop(){return this.Jx}set allowDrop(t){const i=this.Jx;i!==t&&(Util.t(t,"boolean",Diagram,"allowDrop"),this.Jx=t,this.i("allowDrop",i,t))}get allowTextEdit(){return this.zl}set allowTextEdit(t){const i=this.zl;i!==t&&(Util.t(t,"boolean",Diagram,"allowTextEdit"),this.zl=t,this.i("allowTextEdit",i,t))}get allowGroup(){return this.Xl}set allowGroup(t){const i=this.Xl;i!==t&&(Util.t(t,"boolean",Diagram,"allowGroup"),this.Xl=t,this.i("allowGroup",i,t))}get allowUngroup(){return this.Yl}set allowUngroup(t){const i=this.Yl;i!==t&&(Util.t(t,"boolean",Diagram,"allowUngroup"),this.Yl=t,this.i("allowUngroup",i,t))}get allowInsert(){return this.Zx}set allowInsert(t){const i=this.Zx;i!==t&&(Util.t(t,"boolean",Diagram,"allowInsert"),this.Zx=t,this.i("allowInsert",i,t))}get allowLink(){return this.Kl}set allowLink(t){const i=this.Kl;i!==t&&(Util.t(t,"boolean",Diagram,"allowLink"),this.Kl=t,this.i("allowLink",i,t))}get allowRelink(){return this.Ul}set allowRelink(t){const i=this.Ul;i!==t&&(Util.t(t,"boolean",Diagram,"allowRelink"),this.Ul=t,this.i("allowRelink",i,t))}get allowMove(){return this.Gl}set allowMove(t){const i=this.Gl;i!==t&&(Util.t(t,"boolean",Diagram,"allowMove"),this.Gl=t,this.i("allowMove",i,t))}get allowReshape(){return this.Hl}set allowReshape(t){const i=this.Hl;i!==t&&(Util.t(t,"boolean",Diagram,"allowReshape"),this.Hl=t,this.i("allowReshape",i,t))}get allowResize(){return this.ql}set allowResize(t){const i=this.ql;i!==t&&(Util.t(t,"boolean",Diagram,"allowResize"),this.ql=t,this.i("allowResize",i,t))}get allowRotate(){return this.jl}set allowRotate(t){const i=this.jl;i!==t&&(Util.t(t,"boolean",Diagram,"allowRotate"),this.jl=t,this.i("allowRotate",i,t))}get allowSelect(){return this.Wl}set allowSelect(t){const i=this.Wl;i!==t&&(Util.t(t,"boolean",Diagram,"allowSelect"),this.Wl=t,this.i("allowSelect",i,t))}get allowUndo(){return this.$x}set allowUndo(t){const i=this.$x;i!==t&&(Util.t(t,"boolean",Diagram,"allowUndo"),this.$x=t,this.i("allowUndo",i,t))}get allowZoom(){return this.Qx}set allowZoom(t){const i=this.Qx;i!==t&&(Util.t(t,"boolean",Diagram,"allowZoom"),this.Qx=t,this.i("allowZoom",i,t))}get hasVerticalScrollbar(){return this.Gu}set hasVerticalScrollbar(t){const i=this.Gu;i!==t&&(Util.t(t,"boolean",Diagram,"hasVerticalScrollbar"),this.Gu=t,this.aa(),this.T(),this.i("hasVerticalScrollbar",i,t),this.Gs(!1))}get hasHorizontalScrollbar(){return this.Uu}set hasHorizontalScrollbar(t){const i=this.Uu;i!==t&&(Util.t(t,"boolean",Diagram,"hasHorizontalScrollbar"),this.Uu=t,this.aa(),this.T(),this.i("hasHorizontalScrollbar",i,t),this.Gs(!1))}get allowHorizontalScroll(){return this._x}set allowHorizontalScroll(t){const i=this._x;i!==t&&(Util.t(t,"boolean",Diagram,"allowHorizontalScroll"),this._x=t,this.i("allowHorizontalScroll",i,t),this.Gs(!1))}get allowVerticalScroll(){return this.t1}set allowVerticalScroll(t){const i=this.t1;i!==t&&(Util.t(t,"boolean",Diagram,"allowVerticalScroll"),this.t1=t,this.i("allowVerticalScroll",i,t),this.Gs(!1))}get scrollHorizontalLineChange(){return this.i1}set scrollHorizontalLineChange(t){const i=this.i1;i!==t&&(Util.t(t,"number",Diagram,"scrollHorizontalLineChange"),t<0&&Util.G(t,">= 0",Diagram,"scrollHorizontalLineChange"),this.i1=t,this.i("scrollHorizontalLineChange",i,t))}get scrollVerticalLineChange(){return this.e1}set scrollVerticalLineChange(t){const i=this.e1;i!==t&&(Util.t(t,"number",Diagram,"scrollVerticalLineChange"),t<0&&Util.G(t,">= 0",Diagram,"scrollVerticalLineChange"),this.e1=t,this.i("scrollVerticalLineChange",i,t))}get lastInput(){return this._h}set lastInput(t){Debug&&Util.s(t,InputEvent,Diagram,"lastInput"),this._h=t}get previousInput(){return this.jr}set previousInput(t){Debug&&Util.s(t,InputEvent,Diagram,"previousInput"),this.jr=t}get firstInput(){return this.e0}set firstInput(t){Debug&&Util.s(t,InputEvent,Diagram,"firstInput"),this.e0=t}get currentCursor(){return this.Kx}set currentCursor(t){if(t===""&&(t=this.Jm),this.Kx!==t){Util.t(t,"string",Diagram,"currentCursor");const e=this.xt,s=this.Ot;if(e===null||s===null)return;this.Kx=t;const n=e.style.cursor;e.style.cursor=t,s.style.cursor=t,e.style.cursor===n&&(e.style.cursor="-webkit-"+t,s.style.cursor="-webkit-"+t,e.style.cursor===n&&(e.style.cursor="-moz-"+t,s.style.cursor="-moz-"+t,e.style.cursor===n&&(e.style.cursor=t,s.style.cursor=t)))}}get defaultCursor(){return this.Jm}set defaultCursor(t){t===""&&(t="auto");const i=this.Jm;i!==t&&(Util.t(t,"string",Diagram,"defaultCursor"),this.Jm=t,this.i("defaultCursor",i,t))}get click(){return this.Or}set click(t){const i=this.Or;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"click"),this.Or=t,this.i("click",i,t))}get doubleClick(){return this.Er}set doubleClick(t){const i=this.Er;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"doubleClick"),this.Er=t,this.i("doubleClick",i,t))}get contextClick(){return this.Vr}set contextClick(t){const i=this.Vr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"contextClick"),this.Vr=t,this.i("contextClick",i,t))}get mouseOver(){return this.Br}set mouseOver(t){const i=this.Br;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseOver"),this.Br=t,this.i("mouseOver",i,t))}get mouseHover(){return this.zr}set mouseHover(t){const i=this.zr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseHover"),this.zr=t,this.i("mouseHover",i,t))}get mouseHold(){return this.Xr}set mouseHold(t){const i=this.Xr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseHold"),this.Xr=t,this.i("mouseHold",i,t))}get mouseDragOver(){return this.Ux}set mouseDragOver(t){const i=this.Ux;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseDragOver"),this.Ux=t,this.i("mouseDragOver",i,t))}get mouseDrop(){return this.Yr}set mouseDrop(t){const i=this.Yr;i!==t&&(Debug&&t!==null&&Util.t(t,"function",Diagram,"mouseDrop"),this.Yr=t,this.i("mouseDrop",i,t))}get handlesDragDropForTopLevelParts(){return this.Gx}set handlesDragDropForTopLevelParts(t){const i=this.Gx;i!==t&&(Util.t(t,"boolean",Diagram,"handlesDragDropForTopLevelParts"),this.Gx=t,this.i("handlesDragDropForTopLevelParts",i,t))}get mouseEnter(){return this.Kr}set mouseEnter(t){const i=this.Kr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseEnter"),this.Kr=t,this.i("mouseEnter",i,t))}get mouseLeave(){return this.Ur}set mouseLeave(t){const i=this.Ur;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseLeave"),this.Ur=t,this.i("mouseLeave",i,t))}get toolTip(){return this.Gr}set toolTip(t){const i=this.Gr;i!==t&&(Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("Diagram.toolTip must be an Adornment or HTMLInfo."),this.Gr=t,this.i("toolTip",i,t))}get contextMenu(){return this.Hr}set contextMenu(t){const i=this.Hr;i!==t&&(Debug&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("Diagram.contextMenu must be an Adornment or HTMLInfo."),this.Hr=t,this.i("contextMenu",i,t))}get commandHandler(){return this.tP}set commandHandler(t){this.tP!==t&&(this.tP=t,t.Oo(this))}get toolManager(){return this.$M}set toolManager(t){this.$M!==t&&(Util.s(t,ToolManager,Diagram,"toolManager"),this.$M=t,t.diagram=this)}get defaultTool(){return this.QM}set defaultTool(t){const i=this.QM;i!==t&&(Util.s(t,Tool,Diagram,"defaultTool"),this.QM=t,t.diagram=this,this.currentTool===i&&(this.currentTool=t))}get currentTool(){return this._M}set currentTool(t){const i=this._M;i&&(i.isActive&&i.doDeactivate(),i.cancelWaitAfter(),i.doStop()),t===null&&(t=this.defaultTool),t!==null&&(Util.s(t,Tool,Diagram,"currentTool"),this._M=t,t.diagram=this,t.doStart())}get selection(){return this.lP}get maxSelectionCount(){return this.h1}set maxSelectionCount(t){const i=this.h1;if(i!==t)if(Util.t(t,"number",Diagram,"maxSelectionCount"),t>=0&&!isNaN(t)){if(this.h1=t,this.i("maxSelectionCount",i,t),!this.undoManager.isUndoingRedoing){const e=this.selection.count-t;if(e>0){this.V("ChangingSelection",this.selection);const s=this.selection.toArray();for(let n=0;n= 0",Diagram,"maxSelectionCount")}get nodeSelectionAdornmentTemplate(){return this._m}set nodeSelectionAdornmentTemplate(t){const i=this._m;i!==t&&(Util.s(t,Adornment,Diagram,"nodeSelectionAdornmentTemplate"),this._m=t,this.i("nodeSelectionAdornmentTemplate",i,t))}get groupSelectionAdornmentTemplate(){return this.c1}set groupSelectionAdornmentTemplate(t){const i=this.c1;i!==t&&(Util.s(t,Adornment,Diagram,"groupSelectionAdornmentTemplate"),this.c1=t,this.i("groupSelectionAdornmentTemplate",i,t))}get linkSelectionAdornmentTemplate(){return this.u1}set linkSelectionAdornmentTemplate(t){const i=this.u1;i!==t&&(Util.s(t,Adornment,Diagram,"linkSelectionAdornmentTemplate"),this.u1=t,this.i("linkSelectionAdornmentTemplate",i,t))}get highlighteds(){return this.hP}get isModified(){const t=this.undoManager;return t.isEnabled?t.currentTransaction!==null?!0:this.ju&&this.zs!==t.historyIndex:this.ju}set isModified(t){if(this.ju!==t){Util.t(t,"boolean",Diagram,"isModified"),this.ju=t;const e=this.undoManager;!t&&e.isEnabled&&(this.zs=e.historyIndex),t||this.KA()}}KA(){const t=this.isModified;this.oP!==t&&(this.oP=t,this.V("Modified"))}get model(){return this.Ai}set model(t){const i=this.Ai;if(i!==t){Util.s(t,Model,Diagram,"model"),this.currentTool.doCancel(),i&&i.undoManager!==t.undoManager&&i.undoManager.isInTransaction&&Util.n("Do not replace a Diagram.model while a transaction is in progress."),this.animationManager.stopAnimation(!0);const e=this.SA(!0);this.io=!1,this.Ku=!0,this.zs=-2,this.Ar=!1;const s=this.$t;this.$t=!0,this.animationManager.El("Model"),i&&(this._n!==null&&this._n.each(n=>i.removeChangedListener(n)),i.removeChangedListener(this.nP)),this.Ai=t,this.partManager=this.bR(this.Ai.type),this.initializePartManager(this.partManager);for(let n=0;nt.addChangedListener(n)),this.$t=s,this.invalidateDocumentBounds(),this.$t||this.T(),i&&t.undoManager.copyProperties(i.undoManager)}}get themeManager(){return this.C1}set themeManager(t){const i=this.C1;i!==t&&(Util.s(t,ThemeManager,Model,"themeManager"),i!==null&&i.removeDiagram(this),this.C1=t,t!==null&&t.addDiagram(this))}initializePartManager(t){}static SP(t,i){Diagram.pA.set(t,i)}static get licenseKey(){return Diagram.VP.last()}static set licenseKey(t){Diagram.VP.add(t.replace(/\s/g,""))}static get version(){return Diagram.kR}static VP=new List;static kR="3.0.11";bR(t){const i=Diagram.pA.get(t);return i!==null?new i:new PartManager}get j(){return this.eP}set j(t){this.eP=t}get Mx(){return this.dA}SR(t){if(t.model!==this.model)return;const i=t.change,e=t.propertyName;if(i===1&&e[0]==="S"){if(e==="StartingFirstTransaction"){const s=this,n=this.toolManager;n.mouseDownTools.each(o=>o.diagram=s),n.mouseMoveTools.each(o=>o.diagram=s),n.mouseUpTools.each(o=>o.diagram=s),this.routers.each(o=>o.diagram=s),!this.ks&&!this.io&&(this.Kf=!0,this.Ku&&(this.Ar=!0))}else if(e==="StartingUndo"||e==="StartingRedo"){const s=this.animationManager;this.skipsUndoManager||(s.defaultAnimation.isAnimating&&s.stopAnimation(),s.getBundleAnimation().isAnimating&&s.getBundleAnimation().stop()),this.V("ChangingSelection",this.selection)}else if(e==="StartedTransaction"){const s=this.animationManager;s.defaultAnimation.isAnimating&&!this.skipsUndoManager&&s.stopAnimation()}return}if(this.j){this.j=!1;try{if(t.modelChange===""&&i===1){(e==="FinishedUndo"||e==="FinishedRedo")&&(this.V("ChangedSelection",this.selection),this.Di());const s=this.animationManager;e==="RolledBackTransaction"&&s.stopAnimation(),this.xR(),this.Kf=!0,this.maybeUpdate(),(this.undoManager.transactionLevel===0||this.undoManager.transactionLevel===1)&&s.FM(),e==="CommittedTransaction"&&this.undoManager.isJustDiscarded&&(this.zs=Math.min(this.zs,this.undoManager.historyIndex-1)),(e==="CommittedTransaction"||e==="RolledBackTransaction")&&this.undoManager.Gw&&setTimeout(()=>{this.isModified=!1},1);const n=t.isTransactionFinished;if(n&&(this.KA(),this.Mx.clear(),this.animationManager.bF()),!this.Hx&&n&&this.lastInput.targetDiagram){this.Hx=!0;const o=this;Util.Bh(()=>{o.currentTool.standardMouseOver(),o.Hx=!1},10)}}}finally{this.j=!0}}}get me(){return this.iP}set me(t){this.iP=t}get bf(){return this.qx}set bf(t){this.qx=t}FA(t){const i=t.D.h;for(const e of i)e instanceof Picture&&this.BP(e)}BP(t){const i=t.element;if(i===null||!(i instanceof HTMLImageElement)||(i.ls instanceof GSet&&i.ls.add(this),t.MR(),!i.w0))return;const e=i.getAttribute("src")||"",s=this._l.get(e);if(s===null){Picture.UA(t,i);const n=[];n.push(t),this._l.set(e,n)}else{for(let n=0;n0)&&Util.n("defaultScale must be larger than zero, not: "+t),this.s0=t}get autoScale(){return this.Jl}set autoScale(t){const i=this.Jl;i!==t&&(Util.tt(t,AutoScale,"AutoScale"),this.Jl=t,this.i("autoScale",i,t),t!==1&&this.Gs(!1))}get initialAutoScale(){return this.Fr}set initialAutoScale(t){const i=this.Fr;i!==t&&(Util.tt(t,AutoScale,"AutoScale"),this.Fr=t,this.i("initialAutoScale",i,t))}get initialViewportSpot(){return this.Bx}set initialViewportSpot(t){const i=this.Bx;i!==t&&(Util.s(t,Spot,Diagram,"initialViewportSpot"),t.isSpot()||Util.n("initialViewportSpot must be a specific Spot: "+t),this.Bx=t,this.i("initialViewportSpot",i,t))}get initialDocumentSpot(){return this.Vx}set initialDocumentSpot(t){const i=this.Vx;i!==t&&(Util.s(t,Spot,Diagram,"initialDocumentSpot"),t.isSpot()||Util.n("initialViewportSpot must be a specific Spot: "+t),this.Vx=t,this.i("initialDocumentSpot",i,t))}get minScale(){return this.Tx}set minScale(t){Util.r(t,Diagram,"minScale");const i=this.Tx;i!==t&&(t>0?(this.Tx=t,this.i("minScale",i,t),t>this.scale&&(this.scale=t)):Util.G(t,"> 0",Diagram,"minScale"))}get maxScale(){return this.Dx}set maxScale(t){Util.r(t,Diagram,"maxScale");const i=this.Dx;i!==t&&(t>0?(this.Dx=t,this.i("maxScale",i,t),t 0",Diagram,"maxScale"))}get zoomPoint(){return this.Fx}set zoomPoint(t){this.Fx.equals(t)||(Util.s(t,Point,Diagram,"zoomPoint"),t=t.L(),this.Fx=t)}get contentAlignment(){return this.Xf}set contentAlignment(t){const i=this.Xf;i.equals(t)||(Util.s(t,Spot,Diagram,"contentAlignment"),t=t.L(),this.Xf=t,this.i("contentAlignment",i,t),this.Gs(!1))}get initialContentAlignment(){return this.jm}set initialContentAlignment(t){const i=this.jm;i.equals(t)||(Util.s(t,Spot,Diagram,"initialContentAlignment"),t=t.L(),this.jm=t,this.i("initialContentAlignment",i,t))}get padding(){return this.ii}set padding(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Diagram,"padding");const i=this.ii;i.equals(t)||(t=t.L(),this.ii=t,this.invalidateDocumentBounds(),this.i("padding",i,t))}get partManager(){return this.dP}set partManager(t){const i=this.dP;i!==t&&(Util.s(t,PartManager,Diagram,"partManager"),t.diagram!==null&&Util.n("Cannot share PartManagers between Diagrams: "+t.toString()),i&&i.Oo(null),this.dP=t,t.Oo(this))}get nodes(){return this.partManager.nodes.iterator}get links(){return this.partManager.links.iterator}get parts(){return this.partManager.parts.iterator}findTopLevelNodesAndLinks(){const t=new GSet,i=this.nodes;for(;i.next();){const s=i.value;s.isTopLevel&&t.add(s)}const e=this.links;for(;e.next();){const s=e.value;s.isTopLevel&&t.add(s)}return t.iterator}findTopLevelGroups(){return this.vr.iterator}get routers(){return this.Wf}doLinkRouting(t){this.Vo=!0;const i=this.Wf.h;for(let e=0;e0){const l=this.computePartsBounds(n.memberParts,!1);l.inflate(20,20),s.I1(l)}const o=Rect.a(),r=n.memberParts;for(;r.next();){const l=r.value;l instanceof Node&&this.GP(l,e,o)}Rect.o(o)}s.ca=n,s.YP=e,s.Ko=!1}else t&&s.vA();return s}get avoidanceCellSize(){return this.aP}set avoidanceCellSize(t){this.Zl=null,this.aP=new Size(Math.max(1,t.width),Math.max(1,t.height))}get avoidanceLimit(){return this.fP}set avoidanceLimit(t){this.fP=Math.max(1,t)}WA(t){return t.canAvoid()?t:t.containingGroup!==null?this.WA(t.containingGroup):null}GP(t,i,e){if(t===i||!t.isVisible())return;const s=t.canAvoid();if(s){const n=t.getAvoidableRect(e);this.Zl.CR(n.x,n.y,n.width,n.height)}if(t instanceof Group&&(!s||t.avoidableMembers)){const n=t.memberParts;for(;n.next();){const o=n.value;o instanceof Node&&this.GP(o,i,e)}}}HP(t){this.Zl!==null&&!this.Zl.Ko&&(t===void 0||t.canAvoid())&&(this.Zl.Ko=!0)}get autoScrollInterval(){return this.Wm}set autoScrollInterval(t){const i=this.Wm;Util.r(t,Diagram,"autoScrollInterval"),i!==t&&(this.Wm=t,this.i("autoScrollInterval",i,t))}get autoScrollRegion(){return this.vm}set autoScrollRegion(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Diagram,"autoScrollRegion");const i=this.vm;i.equals(t)||(t=t.L(),this.vm=t,this.invalidateDocumentBounds(),this.i("autoScrollRegion",i,t))}doAutoScroll(t){this.i0.c(t),this.computeAutoScrollPosition(this.i0).equalsApprox(this.position)?this.stopAutoScroll():this.JA()}JA(){if(this.Yf!==-1)return;const t=this.Wm,i=this;this.Yf=Util.Bh(()=>{if(i.Yf===-1||(i.stopAutoScroll(),i.lastInput.event===null))return;const s=i.computeAutoScrollPosition(i.i0);if(s.equalsApprox(i.position))return;i.position=s,i.lastInput.documentPoint=i.transformViewToDoc(i.i0),i.doMouseMove(),i.ta=!0;const n=Rect.a();i.computeBounds(n),n.unionRect(i.documentBounds),i.GA(n),Rect.o(n),i.Ge=!0,i.maybeUpdate(),i.JA()},t)}stopAutoScroll(){this.Yf!==-1&&(Util.Ug(this.Yf),this.Yf=-1)}computeAutoScrollPosition(t){let i=this.position;const e=this.vm;if(e.top<=0&&e.left<=0&&e.right<=0&&e.bottom<=0)return i;const s=this.viewportBounds,n=this.scale,o=Rect.H(0,0,s.width*n,s.height*n),r=Point.H(0,0);if(t.x>=o.x&&t.xo.x+o.width-e.right&&this.allowHorizontalScroll){let l=Math.max(this.scrollHorizontalLineChange,1);l=l|0,r.x+=l,t.x>o.x+o.width-e.right/2&&(r.x+=l),t.x>o.x+o.width-e.right/4&&(r.x+=4*l)}if(t.y>=o.y&&t.yo.y+o.height-e.bottom&&this.allowVerticalScroll){let l=Math.max(this.scrollVerticalLineChange,1);l=l|0,r.y+=l,t.y>o.y+o.height-e.bottom/2&&(r.y+=l),t.y>o.y+o.height-e.bottom/4&&(r.y+=4*l)}return r.equalsApprox(Point.Lo)||(i=new Point(i.x+r.x/n,i.y+r.y/n)),Rect.o(o),Point.o(r),i}makeSvg(t){this.Ql.has("SVG")||this.addRenderer("SVG",new SVGSurface(this,root.document));const i=new SVGSurface(this,root.document,!0);t===void 0&&(t={});const e=this;function s(n,o){const r=e.ZA(n,"SVG",i),l=r!==null?r.svg:null;return typeof o=="function"?(o(l),null):l}return this.$A(s,t)}makeSVG(t){return this.makeSvg(t)}addRenderer(t,i){this.Ql.set(t,i)}removeRenderer(t){this.Ql.delete(t)}cacheGroupExternalLinks(t){this.kP=t,t||this.nodes.each(i=>{i instanceof Group&&(i.b0=null)})}$A(t,i){const e=i.callback;let s=!0;const o=this._l.iterator;for(;o.next();)if(!o.value[0].bn){s=!1;break}if(typeof e!="function"||s)return t(i,e,this);const r=this;function l(){const f=+new Date;for(s=!0,o.reset();o.next();)if(!o.value[0].bn){s=!1;break}if(s||f-a>h){t(i,e,r);return}root.requestAnimationFrame(l)}const h=i.callbackTimeout||300,a=+new Date;return root.requestAnimationFrame(()=>l()),null}makeImage(t){return Diagram.isUsingDOM()?(t===void 0&&(t={}),t.returnType="Image",this.makeImageData(t)):null}makeImageData(t){return t===void 0&&(t={}),this.$A(this.AR,t)}static img="image";AR(t,i,e){const s=e.ZA(t,"canvas",null);if(s===null)return null;const n=s.Y.canvas;let o=null;if(n!==null){let r=t.returnType;switch(r===void 0?r="string":r=r.toLowerCase(),r){case Diagram.img+"data":o=s.getImageData(0,0,n.width,n.height);break;case Diagram.img:const h=(t.document||document).createElement("img");h.src=n.toDataURL(t.type,t.details),o=h;break;case"blob":{const a=n;return typeof i!="function"&&(o="",Util.n('Error: Diagram.makeImageData called with "returnType: toBlob", but no required "callback" function property defined.')),typeof a.toBlob=="function"?(a.toBlob(i,t.type,t.details),"toBlob"):(i(null),null)}case"string":default:o=n.toDataURL(t.type,t.details)}}return typeof i=="function"?(i(o),null):o}static QA=!1;ZA(t,i,e){if(this.animationManager.stopAnimation(),this.maybeUpdate(),this.xt===null)return null;typeof t!="object"&&Util.n("properties argument must be an Object.");let n=!1,o=t.size||null,r=t.scale||null;t.scale!==void 0&&isNaN(t.scale)&&(r="NaN");let l=t.maxSize;t.maxSize===void 0&&(n=!0,i==="SVG"?l=new Size(1/0,1/0):l=new Size(2e3,2e3));const h=t.position||null;let a=t.parts||null;Array.isArray(a)&&(a=new List(a));let f=t.padding===void 0?1:t.padding;const c=t.background||null;let u=t.omitTemporary;u===void 0&&(u=!0);const d=t.document||document,m=t.elementFinished||null;let g=t.showTemporary;g===void 0&&(g=!u);let p=t.showGrid;p===void 0&&(p=g),o!==null&&isNaN(o.width)&&isNaN(o.height)&&(o=null),typeof f=="number"?f=new Margin(f):f instanceof Margin||Util.n("MakeImage padding must be a Margin or a number."),f.left=Math.max(f.left,0),f.right=Math.max(f.right,0),f.top=Math.max(f.top,0),f.bottom=Math.max(f.bottom,0),this.ei.clearContextCache(!0);const y=new CanvasSurface(null,d,void 0,!0),x=y.di;if(!(o||r||a||h))return y.width=this.Ct+Math.ceil(f.left+f.right),y.height=this.At+Math.ceil(f.top+f.bottom),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.ua=d,e.Qu=m,this.D1(e.di,f,new Size(y.width,y.height),this.lt,this.mt,a,c,g,p),e.di):(this.Wu=!1,this.D1(x,f,new Size(y.width,y.height),this.lt,this.mt,a,c,g,p),this.Wu=!0,y.di);const k=this.s0,b=this.documentBounds.copy();if(b.subtractMargin(this.ii),g){const L=this.Jt.h,D=L.length;for(let F=0;Fk?(r=k,N=b.width,T=b.height):(N=l.width,T=l.height)):(N=b.width*r,T=b.height*r):(r=k,N=b.width,T=b.height),f!==null?(N+=M,T+=A):f=new Margin(0),l!==null){let L=l.width,D=l.height;i!=="SVG"&&n&&!Diagram.QA&&Debug&&(N>L||T>D)&&(Util.at("Diagram.makeImage(data): Diagram width or height is larger than the default max size. ("+Math.ceil(N)+"x"+Math.ceil(T)+" vs 2000x2000) Consider increasing the max size."),Diagram.QA=!0),isNaN(L)&&(L=2e3),isNaN(D)&&(D=2e3),isFinite(L)&&(N=Math.min(N,L)),isFinite(D)&&(T=Math.min(T,D))}return y.width=Math.ceil(N),y.height=Math.ceil(T),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.ua=d,e.Qu=m,this.D1(e.di,f,new Size(Math.ceil(N),Math.ceil(T)),r,S,a,c,g,p),e.di):(this.Wu=!1,this.D1(x,f,new Size(Math.ceil(N),Math.ceil(T)),r,S,a,c,g,p),this.Wu=!0,y.di)}static Zu=null;static _A="5da73c80a36555d4038e4972187c3cae51fd22";static ww=!1;static Hk=()=>{if(Diagram._A[5]===void 0&&(Transform.prototype.ns=Transform.prototype.Nw),!Diagram.isUsingDOM())return;const t=root.document.createElement("canvas"),i=t.getContext("2d"),e=Util.Fs("7ca11abfd022028846");i[e]=Util.Fs("398c3597c01238");const s="7ca11abfd7330390",n=[Diagram._A,Util.ww+"4ae6247590da4bb21c324ba3a84e385776",Transform.Hk+"fb236cdfda5de14c134ba1a95a2d4c7cc6f93c1387",Geo.za],o=10,r=0;for(let l=1;l<5;l++)i[Util.Fs(s)](Util.Fs(n[l-1]),o,l*15+r);i[e]=Util.Fs("39f046ebb36e4b");for(let l=1;l<5;l++)i[Util.Fs(s)](Util.Fs(n[l-1]),o,l*15+r);(n.length!==4||n[0][0]!=="5"||n[3][0]!=="7")&&(Transform.prototype.ns=Transform.prototype.Nw),Diagram.Zu=t}}class DiagramHelper{tL;iL;qP;De;constructor(t){if(this.tL=null,this.iL="63ad05bbe23a1786468a4c741b6d2",this.qP="@onz",this.iL===this._tk){this.qP=!0,this.De=this.qP;return}this.De=null}LR(t,i){let e="f";const s=root[Util.Fs("76a715b2f73f148a")][Util.Fs("72ba13b5")]||"",n=Util.Fs;if(this.De=!0,!Diagram.isUsingDOM())return;let o=Diagram[n("76a115b6ed251eaf4692")];if(!o){const l=s[n("76ad18b4f73e")];for(let a=s[n("73a612b6fb191d")](n("35e7"))+2;a=0&&ha[0]||h[0]===a[0]&&h[1]>=a[1]))continue;const f="73a612b6fb191d",c=root[n("74a900bae4370f8b51")][n("6fbb13a1c2311e8a57")].toLowerCase(),u=c[n(f)](n("3aad1ab6e022098b4dc4")),d=n(l[2]);if(u>-1){const P=c[n(f)](d.toLowerCase()+"/");if(this.De=!(P>-1&&P=0&&g-1),!this.De))return;const p=root[Util.Fs("76a715b2f73f148a")][Util.Fs("69ad17a1e03e")],y=p[n(f)](n("7fb002b6ed25128b4da25b2e"));if(y>-1&&(this.De=!(p[n(f)](d)>y),!this.De))return;const x=d;if(x[0]!=="#")continue;const k=root.document.createElement("div");let b=l[0].replace(/[A-Za-z]/g,"");for(;b.length<4;)b+="9";const S=b;b=b.substring(b.length-4);let M="";const A=["gsh","gsf"],C=["Header","Background","Display","Feedback"];if(M+=A[parseInt(b.substring(0,1),10)%2],M+=C[parseInt(b.substring(0,1),10)%4],k[n("79a417a0f0181a8946")]=M,root.document[n("78a712aa")]){root.document[n("78a712aa")][n("7bb806b6ed32388c4a875b")](k);const P=root.getComputedStyle(k).getPropertyValue(n("78a704b7e62456904c9b12701b6532a8")),N=root.getComputedStyle(k).getPropertyValue(n("75b817b0ea2202"));if(root.document[n("78a712aa")][n("68ad1bbcf533388c4a875b")](k),!P)continue;const T=root[n("77a902b0eb1b1e804a8a")],L="0."+parseInt(S,10)%100;if(N===L||P.indexOf(parseInt(x[1]+x[2],16))!==-1&&P.indexOf(parseInt(x[3]+x[4],16))!==-1){this.De=!1;return}else if(T&&T(n("32ae19a1e0331fc94084537c067a67fa59f1386b89d006")).matches){M="."+M;for(let D=0;D{const s=this.observed;if(s===null)return;const n=s.viewportBounds,o=this.lastInput.documentPoint;s.position=new Point(o.x-n.width/2,o.y-n.height/2)},this.vP=s=>{this.invalidateDocumentBounds(),this.S0()},this.JP=s=>{this.observed!==null&&(this.invalidateDocumentBounds(),this.T())},this.z1=s=>{this.updateDelay<1?this.T():this.k0||(this.k0=!0,setTimeout(()=>this.redraw(),this.updateDelay))},this.ZP=s=>{this.observed!==null&&this.S0()},this.autoScale=2,this.$t=!1,i&&Object.assign(this,i),this}setupRouters(){}computePixelRatio(){return 1}redraw(){this.k0&&this.updateDelay>=1&&(this.k0=!1,this.TR()),super.redraw()}Ji(){if(this.Ot===null&&Util.n("No div specified"),this.xt===null&&Util.n("No canvas specified"),this.xt instanceof SVGSurface||(this.box.jM(),!this.Ge))return;const t=this.observed;if(t===null||t.animationManager.defaultAnimation.isAnimating||!t.Yh)return;this.m0();const i=this.xt,e=this.ei;if(e.clearContextCache(!0),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,i.width,i.height),this.updateDelay<1)this.sL();else if(this.Qf!==null){e.drawImage(this.Qf.Bt,0,0);const o=this.O;e.scale(this.Gi,this.Gi),e.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),e.commitTransform()}const s=this.Jt.h,n=s.length;for(let o=0;on.canDelete())}t.removeParts(i,!0),t.V("SelectionDeleted",i)}finally{t.commitTransaction("Delete"),t.V("ChangedSelection",t.selection),t.currentCursor=""}}canDeleteSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowDelete||t.selection.count===0)}copySelection(){const t=this.diagram;try{const i=new GSet,e=t.selection.iterator;for(;e.next();){const s=e.value;Part.lh(i,s,!0,this.copiesTree?1/0:0,this.copiesConnectedLinks,n=>n.canCopy())}this.copyToClipboard(i)}finally{}}canCopySelection(){const t=this.diagram;return!(!t.allowCopy||!t.allowClipboard||t.selection.count===0)}cutSelection(){this.copySelection(),this.deleteSelection()}canCutSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowCopy||!t.allowDelete||!t.allowClipboard||t.selection.count===0)}copyToClipboard(t){const i=this.diagram;let e=null;if(t===null)Diagram.kA();else{const s=i.model;let n=!1,o=!1,r=null;try{s.Mf()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.kf()||s._u())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=i.copyParts(t,null,!0)}finally{s.Mf()&&(s.copiesParentKeyOfNodeData=n),(s.kf()||s._u())&&(s.copiesGroupKeyOfNodeData=o),e=new List,e.addAll(r.iteratorValues),Diagram.c0=e,Diagram.A1=i.model.dataFormat}}i.V("ClipboardChanged",e)}pasteFromClipboard(){const t=new GSet,i=Diagram.c0;if(i===null)return t;const e=this.diagram;if(Diagram.A1!==e.model.dataFormat)return t;const s=e.model;let n=!1,o=!1,r=null;try{s.Mf()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.kf()||s._u())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=e.copyParts(i,e,!1)}finally{s.Mf()&&(s.copiesParentKeyOfNodeData=n),(s.kf()||s._u())&&(s.copiesGroupKeyOfNodeData=o);const l=r.iterator;for(;l.next();){const h=l.value,a=l.key;h.location.isReal()||(a.location.isReal()?h.location=a.location:!h.position.isReal()&&a.position.isReal()&&(h.position=a.position)),t.add(h)}}return t}pasteSelection(t){t===void 0&&(t=null);const i=this.diagram;try{i.currentCursor="wait",i.V("ChangingSelection",i.selection),i.startTransaction("Paste");const e=this.pasteFromClipboard();e.count>0&&i.clearSelection(!0);const s=e.iterator;for(;s.next();){const n=s.value;n.isSelected=!0}if(t!==null){const n=i.computePartsBounds(i.selection);if(n.isReal()){const o=this.computeEffectiveCollection(i.selection,i.M1);i.LS(o,new Point(t.x-n.centerX,t.y-n.centerY),i.M1,!1)}}i.V("ClipboardPasted",e)}finally{i.commitTransaction("Paste"),i.V("ChangedSelection",i.selection),i.currentCursor=""}}canPasteSelection(t){const i=this.diagram;return!(i.isReadOnly||i.isModelReadOnly||!i.allowInsert||!i.allowClipboard||Diagram.c0===null||Diagram.c0.count===0||Diagram.A1!==i.model.dataFormat)}undo(){this.diagram.undoManager.undo()}canUndo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canUndo()}redo(){this.diagram.undoManager.redo()}canRedo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canRedo()}decreaseZoom(t){t===void 0&&(t=1/this.zoomFactor),Util.r(t,CommandHandler,"decreaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canDecreaseZoom(t){t===void 0&&(t=1/this.zoomFactor),Util.r(t,CommandHandler,"canDecreaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}increaseZoom(t){t===void 0&&(t=this.zoomFactor),Util.r(t,CommandHandler,"increaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canIncreaseZoom(t){t===void 0&&(t=this.zoomFactor),Util.r(t,CommandHandler,"canIncreaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}resetZoom(t){t===void 0&&(t=this.defaultScale),Util.r(t,CommandHandler,"resetZoom:newscale");const i=this.diagram;ti.maxScale||(i.scale=t)}canResetZoom(t){t===void 0&&(t=this.defaultScale),Util.r(t,CommandHandler,"canResetZoom:newscale");const i=this.diagram;return ti.maxScale?!1:i.allowZoom}zoomToFit(){const t=this.diagram,i=t.animationManager;i.stopAnimation(),t.redraw();const e=t.position,s=t.scale;i.El("Zoom To Fit"),this.isZoomToFitRestoreEnabled&&s===this.Y1&&!isNaN(this.X1)&&t.documentBounds.equals(this.K1)?(t.scale=this.X1,t.position=this.h2,this.Y1=NaN,this.K1=Rect.kw):(this.X1=s,this.h2=e.copy(),t.zoomToFit(),this.Y1=t.scale,this.K1=t.documentBounds.copy()),i.FM()}canZoomToFit(){return this.diagram.allowZoom}scrollToPart(t){t===void 0&&(t=null),t!==null&&Util.s(t,Part,CommandHandler,"part");const i=this.diagram;if(i.ensureBounds(),t===null){try{this.Uo!==null&&(this.Uo.next()?t=this.Uo.value:this.Uo=null)}catch{this.Uo=null}t===null&&(i.highlighteds.count>0?this.Uo=i.highlighteds.iterator:i.selection.count>0&&(this.Uo=i.selection.iterator),this.Uo!==null&&this.Uo.next()&&(t=this.Uo.value))}if(t!==null){const e=i.animationManager;e.El("Scroll To Part");const s=this.scrollToPartPause;if(s>0){const n=this._f(t,[t]);if(n.length===1)i.startTransaction(),i.centerRect(t.actualBounds),i.commitTransaction("Scroll To Part");else{const o=()=>{i.startTransaction();let l=n.pop();for(;n.length>0&&l instanceof Node&&l.isTreeExpanded&&(!(l instanceof Group)||l.isSubGraphExpanded);)l=n.pop();n.length>0?(l instanceof Part&&i.scrollToRect(l.actualBounds),l instanceof Node&&!l.isTreeExpanded&&(l.isTreeExpanded=!0),l instanceof Group&&!l.isSubGraphExpanded&&(l.isSubGraphExpanded=!0)):(l instanceof Part&&i.centerRect(l.actualBounds),i.removeDiagramListener("LayoutCompleted",r)),i.commitTransaction("Scroll To Part")},r=()=>{Util.Bh(o,(e.isEnabled?e.duration:0)+s)};i.addDiagramListener("LayoutCompleted",r),o()}}else{const n=i.position.copy();i.centerRect(t.actualBounds),n.equalsApprox(i.position)&&e.stopAnimation()}}}_f(t,i){if(t.isVisible())return i;if(t instanceof Adornment)this._f(t.adornedPart,i);else if(t instanceof Link){const e=t.fromNode;e!==null&&this._f(e,i);const s=t.toNode;s!==null&&this._f(s,i)}else{if(t instanceof Node){const s=t.labeledLink;s!==null&&this._f(s,i);const n=t.findTreeParentNode();n!==null&&(!n.isTreeExpanded&&!n.wasTreeExpanded&&i.push(n),this._f(n,i))}const e=t.containingGroup;e!==null&&(!e.isSubGraphExpanded&&!e.wasSubGraphExpanded&&i.push(e),this._f(e,i))}return i}canScrollToPart(t){if(t===void 0&&(t=null),t!==null&&!(t instanceof Part))return!1;const i=this.diagram;return i.selection.count===0&&i.highlighteds.count===0?!1:i.allowHorizontalScroll&&i.allowVerticalScroll}collapseTree(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse Tree";try{i.startTransaction(e),i.animationManager.El(e);const n=new List;if(t!==null&&t.isTreeExpanded)t.collapseTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&r.isTreeExpanded&&(r.collapseTree(),n.add(r))}}i.V("TreeCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||!t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(!s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}expandTree(t){t===void 0&&(t=null);const i=this.diagram,e="Expand Tree";try{i.startTransaction(e),i.animationManager.El(e);const n=new List;if(t!==null&&!t.isTreeExpanded)t.expandTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&(r.isTreeExpanded||(r.expandTree(),n.add(r)))}}i.V("TreeExpanded",n)}finally{i.commitTransaction(e)}}canExpandTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}groupSelection(){const t=this.diagram,i=t.model;if(!i.da())return;const e=this.archetypeGroupData;if(e===null)return;let s=null;try{t.currentCursor="wait",t.V("ChangingSelection",t.selection),t.startTransaction("Group");const n=new List,o=t.selection.iterator;for(;o.next();){const h=o.value;h.Ae()&&h.canGroup()&&n.add(h)}const r=new List,l=n.iterator;for(;l.next();){const h=l.value;let a=!1;const f=n.iterator;for(;f.next();){const c=f.value;if(h.isMemberOf(c)){a=!0;break}}a||r.add(h)}if(r.count>0){let h=r.first().containingGroup;if(h!==null)for(;h!==null;){let a=!1;const f=r.iterator;for(;f.next();)if(!f.value.isMemberOf(h)){a=!0;break}if(a)h=h.containingGroup;else break}if(e instanceof Group)e.ci(),s=e.copy(),s!==null&&t.add(s);else if(i.isGroupForData(e)){const a=i.copyNodeData(e);Util.Mt(a)&&(i.addNodeData(a),s=t.findNodeForData(a))}if(s!==null){h!==null&&this.isValidMember(h,s)&&(s.containingGroup=h);const a=r.iterator;for(;a.next();){const f=a.value;this.isValidMember(s,f)&&(f.containingGroup=s)}t.clearSelection(!0),s.isSelected=!0}}t.V("SelectionGrouped",s)}finally{t.commitTransaction("Group"),t.V("ChangedSelection",t.selection),t.currentCursor=""}}canGroupSelection(){const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowGroup||!t.model.da()||this.archetypeGroupData===null)return!1;const e=t.selection.iterator;for(;e.next();){const s=e.value;if(s.Ae()&&s.canGroup())return!0}return!1}c2(t){const i=Util.ft();if(Array.isArray(t))t.forEach(n=>{n instanceof Link||n instanceof Part&&i.push(n)});else{const n=t.iterator;for(;n.next();){const o=n.value;o instanceof Link||o instanceof Part&&i.push(o)}}const e=new GSet,s=i.length;for(let n=0;n0){i.clearSelection(!0);const o=s.iterator;for(;o.next();){const r=o.value;r.expandSubGraph();const l=r.containingGroup,h=l!==null&&l.data!==null?e.getKeyForNodeData(l.data):void 0;n.addAll(r.memberParts);const a=n.iterator;for(;a.next();){const f=a.value;if(f.isSelected=!0,f instanceof Link)continue;const c=f.data;c!==null?e.setGroupForData(c,h):f.containingGroup=l}i.remove(r)}}i.V("SelectionUngrouped",s,n)}finally{i.commitTransaction("Ungroup"),i.V("ChangedSelection",i.selection),i.currentCursor=""}}canUngroupSelection(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowDelete||!i.allowUngroup||!i.model.da())return!1;if(t!==null){if(!(t instanceof Group))return!1;if(t.canUngroup())return!0}else{const s=i.selection.iterator;for(;s.next();){const n=s.value;if(n instanceof Group&&n.canUngroup())return!0}}return!1}addTopLevelParts(t,i){const e=this.c2(t);let s=!0;const n=e.iterator;for(;n.next();){const o=n.value;o.containingGroup!==null&&(!i||this.isValidMember(null,o)?o.containingGroup=null:s=!1)}return s}collapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse SubGraph";try{i.startTransaction(e),i.animationManager.El(e);const n=new List;if(t!==null&&t.isSubGraphExpanded)t.collapseSubGraph(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&r.isSubGraphExpanded&&(r.collapseSubGraph(),n.add(r))}}i.V("SubGraphCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||!t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&s.isSubGraphExpanded)return!0}}return!1}expandSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Expand SubGraph",s=new List;try{if(i.startTransaction(e),i.animationManager.El(e),t!==null&&!t.isSubGraphExpanded)t.expandSubGraph(),s.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&(r.isSubGraphExpanded||(r.expandSubGraph(),s.add(r)))}}i.V("SubGraphExpanded",s)}finally{for(const n of s)this.nL(i,n);t&&this.nL(i,t),i.commitTransaction(e)}}nL(t,i){for(const e of i.memberParts)e instanceof Node&&t.If(e,i)}canExpandSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&!s.isSubGraphExpanded)return!0}}return!1}editTextBlock(t){t===void 0&&(t=null),t!==null&&Util.s(t,TextBlock,CommandHandler,"editTextBlock");const i=this.diagram,e=i.toolManager.findTool("TextEditing");if(e!==null){if(t===null){let s=null;const n=i.selection.iterator;for(;n.next();){const o=n.value;if(o.canEdit()){s=o;break}}if(s===null)return;t=s.findInVisualTree(o=>o instanceof TextBlock&&o.editable)}t!==null&&(i.currentTool=null,e.textBlock=t,i.currentTool=e)}}canEditTextBlock(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowTextEdit||i.toolManager.findTool("TextEditing")===null)return!1;if(t!==null){if(!(t instanceof TextBlock))return!1;const e=t.part;if(e!==null&&e.canEdit())return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s.canEdit()&&(t=s.findInVisualTree(n=>n instanceof TextBlock&&n.editable),t!==null))return!0}}return!1}showContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");if(e===null)return;t===void 0&&(i.selection.count>0?t=i.selection.first():t=i);const s=e.findObjectWithContextMenu(t);if(s!==null){const n=i.lastInput;let o=null;if(s instanceof GraphObject)o=s.getDocumentPoint(Spot.Center);else if(!i.viewportBounds.containsPoint(n.documentPoint)){const r=i.viewportBounds;o=new Point(r.x+r.width/2,r.y+r.height/2)}if(o!==null){const r=new InputEvent;r.diagram=i,r.viewPoint=i.transformDocToView(o),r.documentPoint=o,r.button=2,r.up=!0,i.lastInput=r}i.currentTool=e,e.openMenu(!1,s)}}canShowContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");return!(e===null||(t===void 0&&(i.selection.count>0?t=i.selection.first():t=i),e.findObjectWithContextMenu(t)===null))}get copiesClipboardData(){return this.$P}set copiesClipboardData(t){Util.t(t,"boolean",CommandHandler,"copiesClipboardData"),this.$P=t}get copiesConnectedLinks(){return this.QP}set copiesConnectedLinks(t){Util.t(t,"boolean",CommandHandler,"copiesConnectedLinks"),this.QP=t}get deletesConnectedLinks(){return this._P}set deletesConnectedLinks(t){Util.t(t,"boolean",CommandHandler,"deletesConnectedLinks"),this._P=t}get copiesTree(){return this.t2}set copiesTree(t){Util.t(t,"boolean",CommandHandler,"copiesTree"),this.t2=t}get deletesTree(){return this.i2}set deletesTree(t){Util.t(t,"boolean",CommandHandler,"deletesTree"),this.i2=t}get copiesParentKey(){return this.e2}set copiesParentKey(t){Util.t(t,"boolean",CommandHandler,"copiesParentKey"),this.e2=t}get copiesGroupKey(){return this.s2}set copiesGroupKey(t){Util.t(t,"boolean",CommandHandler,"copiesGroupKey"),this.s2=t}get archetypeGroupData(){return this.o2}set archetypeGroupData(t){t!==null&&Util.t(t,"object",CommandHandler,"archetypeGroupData");const i=this.diagram;if(Debug){const e=i.model;e.da()&&!(t instanceof Group)&&!e.isGroupForData(t)&&Util.n("CommandHandler.archetypeGroupData must be either a Group or a data object for which GraphLinksModel.isGroupForNodeData is true: "+t)}this.o2=t}get memberValidation(){return this.rh}set memberValidation(t){t!==null&&Util.t(t,"function",CommandHandler,"memberValidation"),this.rh=t}get defaultScale(){return this.diagram.defaultScale}set defaultScale(t){this.diagram.defaultScale=t}get zoomFactor(){return this.l2}set zoomFactor(t){Util.r(t,CommandHandler,"zoomFactor"),t>1||Util.n("zoomFactor must be larger than 1.0, not: "+t),this.l2=t}get isZoomToFitRestoreEnabled(){return this.a2}set isZoomToFitRestoreEnabled(t){Util.t(t,"boolean",CommandHandler,"isZoomToFitRestoreEnabled"),this.a2=t}get scrollToPartPause(){return this.f2}set scrollToPartPause(t){Util.r(t,CommandHandler,"scrollToPartPause"),this.f2=t}computeEffectiveCollection(t,i){const e=this.diagram,s=e.toolManager.findTool("Dragging"),n=e.currentTool===s;i===void 0&&(i=e.y0());const o=new GMap;if(t===null)return o;let r=t.iterator;for(;r.next();){const l=r.value;e._r(o,l,n,i)}if(e.draggedLink!==null&&i.dragsLink)return o;for(r=t.iterator;r.next();){const l=r.value;if(l instanceof Link){const h=l.fromNode;if(h!==null&&!o.has(h))o.delete(l);else{const a=l.toNode;a!==null&&!o.has(a)&&o.delete(l)}}}return o}}var Stretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Vertical=4]="Vertical",w[w.Horizontal=5]="Horizontal",w[w.Fill=2]="Fill",w))(Stretch||{}),Orientation=(w=>(w[w.None=0]="None",w[w.Along=21]="Along",w[w.Plus90=22]="Plus90",w[w.Minus90=23]="Minus90",w[w.Opposite=24]="Opposite",w[w.Upright=25]="Upright",w[w.Plus90Upright=26]="Plus90Upright",w[w.Minus90Upright=27]="Minus90Upright",w[w.Upright45=28]="Upright45",w))(Orientation||{}),Flip=(w=>(w[w.None=0]="None",w[w.Vertical=1]="Vertical",w[w.Horizontal=2]="Horizontal",w[w.Both=3]="Both",w))(Flip||{});class GraphObject{l;td;ed;Go;g;hh;Z;mt;le;_t;sd;Hs;Ft;qe;il;ah;Pi;ga;lt;jt;el;Fi;Hi;nd;ai;tc;Ut;hi;sl;u2;od;constructor(){GSet.vi(this),this.l=30723,this._t=1,this.sd="",this.Hs=null,this.Ft=null,this.mt=new Point(NaN,NaN).w(),this.qe=Size.xw,this.il=new Transform,this.ah=new Transform,this.Pi=null,this.ga=1,this.lt=1,this.jt=0,this.el=Margin.qg,this.le=new Rect(NaN,NaN,NaN,NaN).w(),this.Fi=new Rect(NaN,NaN,NaN,NaN).w(),this.Hi=new Rect(0,0,NaN,NaN).w(),this.nd=null,this.td=null,this.Z=null,this.ai=Spot.Default,this.tc=Spot.Default,this.ed=0,this.Go=0,this.Ut=null,this.g=null,this.hh=null,this.hi=null,this.u2=null,this.sl=null,this.od=null}cloneProtected(t){t.l=(this.l|2048|4096)&-32769,t._t=this._t,t.sd=this.sd,t.Ft=this.Ft,t.mt.c(this.mt),t.qe=this.qe.L(),this.Pi!==null?t.Pi=this.Pi.copy():t.Pi=null,t.lt=this.lt,t.jt=this.jt,t.el=this.el.L(),t.le.c(this.le),t.Fi.c(this.Fi),t.Hi.c(this.Hi),t.td=this.td,this.Z!==null&&(t.Z=this.Z.copy()),t.ai=this.ai.L(),t.tc=this.tc.L(),t.ed=this.ed,t.Go=this.Go,this.Ut!==null&&(t.Ut=this.Ut.copy()),this.g!==null&&(this.g.wi?t.g=this.g:t.g=this.g.copy()),this.hh!==null&&(t.hh=this.hh.slice()),this.hi!==null&&(t.hi=this.hi.copy())}addCopyProperty(t){let i=this.hh;if(!Array.isArray(i))i=[],this.hh=i;else for(let e=0;e{d.data!==null&&d.d2()&&d.updateTargetBindings(i)})}}}}MF(t){this.od.delete(t)}Yo(){if(this.diagram===null)return;if(this.findBindingPanel()===null&&this.Ri!==null){const i=this.Ri.iterator;for(;i.next();){const e=i.value;if(!e.isToTheme)continue;let s=null;const n=e.sourceName;e.isToObject&&(s=this.oL(n));let o=this;const r=e.targetId;r!==-1&&(o=this.M0(r),o===null)||(n==="/"?s=o.part:n==="."?s=o:n===".."&&(s=o.panel),e.updateTarget(o,s))}}}ka(t,i){const e=this.findBindingPanel();if(e!==null){const s=this.Ri.iterator;for(;s.next();){const n=s.value;let o=null;if(n.isToObject){if(o=n.rL(e,this),o===null)continue;n.updateSource(this,o,i,null)}else if(n.isToModel){const r=t.diagram;r!==null&&!r.me&&n.updateSource(this,r.model.modelData,i,e)}else if(!n.isToTheme){const r=e.data;if(r===null)continue;const l=t.diagram;l!==null&&!l.me&&n.updateSource(this,r,i,e)}if(o===this){const r=n.targetId,l=e.M0(r);l!==null&&n.updateTarget(l,o,i)}}}}M0(t){return this.eo===t?this:null}oL(t){let i;return t===""?i=this:t==="/"?i=this:t==="."?i=this:t===".."?i=this:(i=this.part.findObject(t),i===null&&Debug&&Util.at("Binding error: missing GraphObject named "+t+" in "+this.part.toString())),i}get eo(){return this.g!==null?this.g.eo:-1}set eo(t){this.eo!==t&&(this.g===null&&(this.g=new GraphObjectTemplateSettings),this.g.eo=t)}get Ri(){return this.g!==null?this.g.Ri:null}set Ri(t){this.Ri!==t&&(this.g===null&&(this.g=new GraphObjectTemplateSettings),this.g.Ri=t)}get so(){return this.g!==null?this.g.so:null}set so(t){this.so!==t&&(this.g===null&&(this.g=new GraphObjectTemplateSettings),this.g.so=t)}raiseChanged(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}i(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}no(t,i,e,s){const n=this.le;if(n.e(t,i,e,s),this.lt!==1||this.jt!==0){this.Pi===null&&(this.Pi=new Transform);const o=this.Pi;o.Bi(),this.P0(o,t,i,e,s),o.Cw(n)}}lL(t,i,e){return this.pickable===!1?!1:(e.hf(this.O),i?this.intersectsRect(t,e):this.containedInRect(t,e))}hL(t,i,e){if(this.pickable===!1)return!1;const s=this.naturalBounds,n=t.distanceSquaredPoint(i);return e?Point.distanceLineSegmentSquared(t.x,t.y,0,0,0,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,0,s.height,s.width,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,s.height,s.width,0)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,0,0,0)<=n:t.distanceSquared(0,0)<=n&&t.distanceSquared(0,s.height)<=n&&t.distanceSquared(s.width,0)<=n&&t.distanceSquared(s.width,s.height)<=n}kn(){return!0}containsPoint(t){Debug&&Util.s(t,Point,GraphObject,"containsPoint:p");const i=Point.a();i.c(t),this.O.Pt(i);const e=this.actualBounds;if(!e.isReal())return Point.o(i),!1;const s=this.diagram;if(s!==null&&s.r0){const o=s.getInputOption("extraTouchThreshold"),r=s.getInputOption("extraTouchArea"),l=r/2,h=this.naturalBounds,a=this.getDocumentScale()*s.scale,f=1/a;if(h.width*ae&&(c=t),isFinite(i)&&i>s&&(u=i);break;case 5:isFinite(t)&&t>e&&(c=t),u=0,d&&(i=1/0);break;case 4:isFinite(i)&&i>s&&(u=i),c=0,d&&(t=1/0);break}const g=this.maxSize,p=this.minSize;c>g.width&&p.widthg.height&&p.heightu.height||this.xi>u.width)&&(r=!0)}}}r?this.l|=256:this.l&=-257,this.Fi.isReal()||Util.n("Non-real actualBounds has been set. Object "+this+", actualBounds: "+this.Fi.toString()),this.ad(o,this.Fi),this.oo(!1),Rect.o(o)}uh(t,i,e,s){}commonArrange(t,i,e,s){if(this.Fi.e(t,i,e,s),this.desiredSize.isReal())return;const n=this.le,o=this.el,r=o.right+o.left,l=o.top+o.bottom,h=n.width+r,a=n.height+l;e+=r,s+=l;let f=this.qs(!0);switch(h===e&&a===s&&(f=0),f){case 0:(h>e||a>s)&&(this.pe(!0),this.wt(h>e?e:h,a>s?s:a,0,0));break;case 2:this.pe(!0),this.wt(e,s,0,0);break;case 5:this.pe(!0),this.wt(e,a,0,0);break;case 4:this.pe(!0),this.wt(h,s,0,0);break}}ad(t,i){const e=this.part;e!==null&&e.diagram!==null&&((e.selectionObject===this||e.resizeObject===this||e.rotateObject===this)&&e.g2(!0),this.T(),!t.equalsApproxClose(i)&&(e.dh(),this.A0(e)))}A0(t){this.portId!==null&&(t.g2(!0),t instanceof Node&&t.aL(this))}get shadowVisible(){return this.g!==null?this.g.L0:null}set shadowVisible(t){const i=this.shadowVisible;i!==t&&(Debug&&t!==null&&Util.t(t,"boolean",GraphObject,"shadowVisible"),this.Zt(),this.g.L0=t,this.hs(!0),this.T(),this.i("shadowVisible",i,t))}RR(t,i){const e=this.naturalBounds,s=this.ah,n=s.m11,o=s.m21,r=s.dx,l=s.m12,h=s.m22,a=s.dy;let f=0,c=0,u=f,d=c;f=u*n+d*o+r,c=u*l+d*h+a;let m=f,g=c,p=0,y=0;u=e.width+i,d=0,f=u*n+d*o+r,c=u*l+d*h+a;let x=Math.min(m,f),k=Math.min(g,c);p=Math.max(m+p,f)-x,y=Math.max(g+y,c)-k,m=x,g=k,u=e.width+i,d=e.height+i,f=u*n+d*o+r,c=u*l+d*h+a,x=Math.min(m,f),k=Math.min(g,c),p=Math.max(m+p,f)-x,y=Math.max(g+y,c)-k,m=x,g=k,u=0,d=e.height+i,f=u*n+d*o+r,c=u*l+d*h+a,x=Math.min(m,f),k=Math.min(g,c),p=Math.max(m+p,f)-x,y=Math.max(g+y,c)-k,m=x,g=k;const b=t.viewportBounds,S=b.x,M=b.y,A=b.width,C=b.height;return m>A+S||S>p+m||g>C+M||M>y+g}Ji(t,i){if(this.IR(t,i)||!this.visible)return;const e=this.opacity;if(e===0)return;let s=1;e!==1&&(s=t.globalAlpha,t.globalAlpha=s*e);let n="";this.filter!==""&&(n=t.filter,t.filter=this.filter);const o=this.O,r=this.panel;this.N0()===!0&&this.G1();const l=this.part;let h=!1,a=0;if(l&&i.getRenderingHint("drawShadows")&&(h=l.isShadowed,h)){const g=l.shadowOffset;a=Math.max(g.y,g.x)*i.scale*i.Gi}const f=this instanceof Panel&&this.nl(),c=this.Fi;if(f&&(this.fL(h,t,!1,r),this.OR(t,i),this.cL(h,t,!1,r),this.uL(h,t,!1)),f||!f&&(c.width===0||c.height===0||isNaN(c.x)||isNaN(c.y))){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}const u=this.js();if(!i.ia&&u&&this.RR(i,a)){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}let d=(this.l&256)!==0;if(t.clipInsteadOfFill&&(d=!1),this instanceof TextBlock&&(t.font=this.font),d){const g=r.kn()?r.naturalBounds:r.actualBounds;let p=Math.max(c.x,g.x),y=Math.max(c.y,g.y),x=Math.min(c.right,g.right)-p,k=Math.min(c.bottom,g.bottom)-y;const b=this.hi;if(b!==null&&(p=b.x,y=b.y,x=b.width,k=b.height),p>c.width+c.x||c.x>g.width+g.x){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}t.save(),t.beginPath(),t.rect(p,y,x,k),t.clip()}if(u){if(!l.isVisible()){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}if(h){const g=l.shadowOffset;t.shadowsSet(g.x*i.scale*this.scale*i.Gi,g.y*i.scale*this.scale*i.Gi,l.shadowBlur),t.shadowsOn(),t.shadowColor=l.shadowColor}}const m=this.naturalBounds;if(t.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.fL(h,t,u,r),this.Ft!==null&&(t.commitTransform(),this.H1(t,m,c)),this.cL(h,t,u,r),this.gh(t,i),this.uL(h,t,u),d&&(t.restore(),t.clearContextCache(this instanceof Panel)),!o.Gk()){const g=1/(o.m11*o.m22-o.m12*o.m21);t.transform(o.m22*g,-o.m12*g,-o.m21*g,o.m11*g,g*(o.m21*o.dy-o.m22*o.dx),g*(o.m12*o.dx-o.m11*o.dy))}e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n)}fL(t,i,e,s){t&&this.shadowVisible===!0?i.shadowsOn():t&&this.shadowVisible===!1&&i.shadowsOff(),t&&this.q1(s)&&this.shadowVisible===null&&i.shadowsOff()}cL(t,i,e,s){t&&(this.Ft!==null||this.q1(s))?(this.j1(!0),this.shadowVisible===null&&i.shadowsOff()):this.j1(!1)}uL(t,i,e){t&&this.m2()===!0&&i.shadowsOn(),e&&t&&i.shadowsOff()}ER(t,i,e){const s=this.part;let n=!1;s&&t.getRenderingHint("drawShadows")&&(n=s.isShadowed),i.clipInsteadOfFill&&(n=!1),this.js()&&n&&i.shadowsOn(),n&&this.shadowVisible===!0?i.shadowsOn():n&&this.shadowVisible===!1&&i.shadowsOff();const o=this.panel;if(n&&this.q1(o)&&this.shadowVisible===null&&i.shadowsOff(),i.ol){const r=t.computePixelRatio(),l=`drop-shadow(${i.shadowOffsetX/r}px ${i.shadowOffsetY/r}px ${i.shadowBlur/r/2}px ${i.shadowColor})`;this.background!==null&&e.Ft.setAttributeNS(null,"filter",l)}return n&&(this.Ft!==null||this.q1(o))?(this.j1(!0),this.shadowVisible===null&&i.shadowsOff()):this.j1(!1),n}VR(t,i,e,s){if(e.ol){const n=i.computePixelRatio(),o=`drop-shadow(${e.shadowOffsetX/n}px ${e.shadowOffsetY/n}px ${e.shadowBlur/n/2}px ${e.shadowColor})`;this.p2(t,o)}s&&this.m2()===!0&&e.shadowsOn(),this.js()&&e.shadowsOff()}q1(t){return t===null?!1:(t.nl()&&(t=t.panel),t.m2()||(t.type===Panel.Auto||t.type===Panel.Spot)&&t.findMainElement()!==this)}p2(t,i){}H1(t,i,e){const s=this.U1(),n=i.x,o=i.y,r=i.width+s,l=i.height+s;this.wn(t,this.Ft,!0,!1,i,e),this.Ft instanceof Brush&&this.Ft.type===3?(t.beginPath(),t.rect(n-s/2,o-s/2,r,l),t.fillContext(this.Ft,!1,null)):t.fillRect(n-s/2,o-s/2,r,l)}dL(t,i){let e=t.BR(this);if(e!==-1)if(e===0)if(t.svg.Ft)t.svg.Ft.after(i);else if(t.type===Panel.Table){const s=t.svg.getElementsByClassName("gojs-ts"),n=s.length!==0?s[0]:null;n!==null&&n.after(i)}else t.svg.prepend(i);else{for(;e!==0&&!t.elt(e-1).isVisibleObject();)e--;if(e===0)t.svg.prepend(i);else{const s=t.elt(e-1).svg;s!==null?s.after(i):t.svg.appendChild(i)}}}IR(t,i){if(!(t instanceof SVGContext))return!1;if(!this.visible||this.opacity===0)return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;if(this.js()&&!this.isVisible())return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;const e=this.panel,s=this.fd(t);if(this.nc(t,i,s))return this.gL(this.svg),this.svg.parentElement!==null?(this.js()&&(t.lastDrawnPart=this.svg),!0):(this.js()?(t.lastDrawnPart!==null?t.lastDrawnPart.after(this.svg):t.diagramGroup.prepend(this.svg),t.lastDrawnPart=this.svg):e&&this.dL(e,this.svg),!0);if(this.js()&&this.isShadowed){const m=this.shadowOffset;t.shadowsSet(m.x*i.scale*this.scale*i.Gi,m.y*i.scale*this.scale*i.Gi,this.shadowBlur),t.shadowsOn(),t.shadowColor=this.shadowColor}this instanceof TextBlock&&(t.font=this.font),t.currentElement=null;const n=this.O,o=this instanceof Panel,r=this instanceof Panel?this.nl():!1,l=this.svg;this.N0()===!0&&this.G1();const h=this.Fi;t.setCurrentTransform(1,0,0,1,0,0),t.outerGroup=!1,s&&(t.outerGroup=!0,o&&r?(t.newGroup(1,0,0,1,0,0),this.svg=t.lastCreatedElement):o?(t.newGroup(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.svg=t.lastCreatedElement):t.newGroup(1,0,0,1,0,0));const a=this.naturalBounds;o||t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.background!==null&&(o?(r&&t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.H1(t,a,h),r&&t.setCurrentTransform(1,0,0,1,0,0)):(t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.H1(t,a,h)),t.currentElement.Ft=t.lastCreatedElement,t.currentElement.prepend(t.lastCreatedElement));const f=this.ER(i,t,t.currentElement);this.gh(t,i),o&&t.endGroup(),t.outerGroup&&t.endGroup();const c=t.surface.Qu,u=o?this.svg:t.currentElement;if(!o&&l!==null&&u!==l&&l.parentNode===this.panel.svg){const m=this.svg.getAttribute("filter");return m!==null&&u.setAttribute("filter",m),this.svg.replaceWith(u),this.svg=u,u!==null&&this.T0(t,e,h,u),this.mL(t,l),!0}if(this.svg=u,c!==null&&u===null&&t.dummyGroup(),u===null)return!0;this.T0(t,e,h,u),this.VR(u,i,t,f);const d=this.js()?this.opacity*t.globalAlpha:this.opacity;if(d!==1&&u.setAttributeNS(null,"opacity",d.toString()),this.filter!==""&&u.setAttributeNS(null,"filter",this.filter),this.js()){if(l!==null&&u!==l&&l.parentNode===t.diagramGroup){const m=l.getAttribute("filter");m!==null&&u.setAttribute("filter",m),l.replaceWith(u)}else t.lastDrawnPart?t.lastDrawnPart.after(u):t.diagramGroup.prepend(u);t.lastDrawnPart=u}else e!==null&&this.dL(e,u);return c!==null&&c(this,u),this.gL(u),!0}gL(t){const i=this,e=t.dataset;i instanceof GraphObject&&(i.portId!==null&&(e.portId=i.portId),i instanceof Panel&&(isNaN(i.itemIndex)||(e.itemIndex=i.itemIndex.toString()),i instanceof Part&&(e.className=Util.hn(i),i.key!==void 0&&(e.key=i.key.toString()),i.containingGroup!==null&&(e.group=i.containingGroup.key.toString()),i instanceof Link&&(i.fromNode!==null&&i.fromNode.key!==void 0&&(e.fromKey=i.fromNode.key.toString()),i.fromPortId!==""&&(e.fromPortId=i.fromPortId),i.toNode!==null&&i.toNode.key!==void 0&&(e.toKey=i.toNode.key.toString()),i.toPortId!==""&&(e.toPortId=i.toPortId)))))}T0(t,i,e,s){let n=(this.l&256)!==0;if(t.clipInsteadOfFill&&(n=!1),!n){s.removeAttributeNS(null,"clip-path"),this.mL(t,s);return}const o=i.kn()?i.naturalBounds:i.actualBounds;let r=Math.max(e.x,o.x),l=Math.max(e.y,o.y),h=Math.min(e.right,o.right)-r,a=Math.min(e.bottom,o.bottom)-l;const f=this.hi;f!==null&&(r=f.x,l=f.y,h=f.width,a=f.height);const c=s.getAttribute("clip-path");let u=null;if(c!==null&&(u=t.svg.getElementById(c.split("#")[1].slice(0,-1))),u===null){const d="CLIP"+GSet.cu++,m={id:d},g=t.makeElement("clipPath",m),p=t.makeElement("rect",{x:r,y:l,width:h,height:a});if(this instanceof Panel){const y=this.O.copy().Pw();p.setAttribute("transform",`matrix(${y.m11}, ${y.m12}, ${y.m21}, ${y.m22}, ${y.dx}, ${y.dy})`)}g.appendChild(p),t.svg.appendChild(g),s.setAttributeNS(null,"clip-path","url(#"+d+")")}else{const d=u.firstElementChild;d.setAttribute("x",r.toString()),d.setAttribute("y",l.toString()),d.setAttribute("width",h.toString()),d.setAttribute("height",a.toString())}}mL(t,i){const e=i.getAttribute("clip-path");if(e===null)return;const s=t.svg.getElementById(e.split("#")[1].slice(0,-1));s!==null&&s.remove()}zR(){if(this.svg===null)return;const t=this.svg.innerHTML.match(/url\(#((CLIP|GRAD).+?)\)/g),i=this.svg.ownerDocument;if(t!==null)for(const e of t){const s=i.getElementById(e.split("#")[1].slice(0,-1));s!==null&&s.remove()}this.svg.remove()}OR(t,i){const e=this.Fi,s=this.Hi,n=this.Ft;n!==null&&t.commitTransform(),n!==null&&(this.wn(t,n,!0,!1,s,e),n instanceof Brush&&n.type===3?(t.beginPath(),t.rect(e.x,e.y,e.width,e.height),t.fillContext(n,!1,null)):t.fillRect(e.x,e.y,e.width,e.height)),this.gh(t,i)}gh(t,i){}w2(){this.hs(!0)}nc(t,i,e){const s=this.svg;if(this.XR()){if(this.w2(),this.hs(!1),s===null)return!1;const a=this.svg.getAttribute("clip-path");if(a!==null){const f=t.svg.getElementById(a.split("#")[1].slice(0,-1));f!==null&&f.remove()}return!1}if(s===null)return!1;if(!this.visible)return s.remove(),!1;if(s.nodeName!=="g"&&e||s.nodeName==="g"&&!e)return!1;const n=this.O,o="matrix("+n.m11+", "+n.m12+", "+n.m21+", "+n.m22+", "+n.dx+", "+n.dy+")",r=this instanceof Panel,l=this instanceof Panel?this.nl():!1;if(!(r&&l))if(this instanceof Picture){const a=this.W1;t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),a!==null&&t.amendImageTransform(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]),e?s.lastElementChild.setAttributeNS(null,"transform",t.getCurrentTransform()):s.setAttributeNS(null,"transform",t.getCurrentTransform())}else if(e&&!(this instanceof Panel))if(this instanceof Shape){const a=s.getElementsByTagName("path");for(let f=0;f=.1;){if(g){for(l=o[d++%h],l-=r;l<0;)l+=o[d++%h],m=!m;g=!1}else l=o[d++%h];l>u&&(l=u);let p=Math.sqrt(l*l/(1+c*c));a<0&&(p=-p),i+=p,e+=c*p,m?t.lineTo(i,e):t.moveTo(i,e),u-=l,m=!m}}wn(t,i,e,s,n,o){let r=1,l=1;if(typeof i=="string"){e?t.fillStyle=i:t.strokeStyle=i;return}else if(i.type===1){e?t.fillStyle=i.color:t.strokeStyle=i.color;return}let h;const a=this.U1();r=n.width,l=n.height,s?(r=o.width,l=o.height):e||(r+=a,l+=a);const f=t instanceof CanvasSurfaceContext;if(f&&i.Sn&&(i.type===4||i.oc===r&&i.v1===l))h=i.Sn;else{let c=0,u=0,d=0,m=0,g=0,p=0,y=0,x=0;if(s?(y=o.x,x=o.y):e||(y-=a/2,x-=a/2),c=i.start.x*r+i.start.offsetX+y,u=i.start.y*l+i.start.offsetY+x,d=i.end.x*r+i.end.offsetX+y,m=i.end.y*l+i.end.offsetY+x,i.type===2)h=t.createLinearGradient(c,u,d,m);else if(i.type===3)p=isNaN(i.endRadius)?Math.max(r,l)/2:i.endRadius,isNaN(i.startRadius)?(g=0,p=Math.max(r,l)/2):g=i.startRadius,h=t.createRadialGradient(c,u,g,d,m,p);else if(i.type===4)try{h=t.createPattern(i.pattern,"repeat")}catch{h=null}else Util.Vi(i.type,"Brush type");if(i.type!==4){const k=i.colorStops;if(k!==null){const b=k.iterator;for(;b.next();)h.addColorStop(b.key,b.value)}}if(f&&(i.Sn=h,h!==null&&(i.oc=r,i.v1=l),h===null&&i.type===4&&i.oc!==-1)){i.oc=-1;const k=this.diagram;k!==null&&i.oc===-1&&Util.Bh(()=>{k.redraw()},600)}}e?t.fillStyle=h:t.strokeStyle=h}isContainedBy(t){return t instanceof Panel?this.YR(this,t):!1}YR(t,i){if(t===i||i===null)return!1;let e=t.panel;for(;e!==null;){if(e===i)return!0;e=e.panel}return!1}isVisibleObject(){if(!this.visible)return!1;const t=this.panel;return t!==null?t.isVisibleObject():!0}isEnabledObject(){let t=this instanceof Panel?this:this.panel;for(;t!==null&&t.isEnabled;)t=t.panel;return t===null}get enabledChanged(){return this.g!==null?this.g.D0:null}set enabledChanged(t){const i=this.enabledChanged;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"enabledChanged"),this.Zt(),this.g.D0=t,this.i("enabledChanged",i,t))}G1(){if(this.J1()===!0){const t=this.il;if(t.Bi(),!this.Fi.isReal()||!this.le.isReal()){this.cd(!1);return}if(t.Es(this.Fi.x-this.le.x,this.Fi.y-this.le.y),this.scale!==1||this.angle!==0){const i=this.naturalBounds;this.P0(t,i.x,i.y,i.width,i.height)}this.cd(!1),this.Sa(!0)}if(this.N0()===!0){const t=this.panel;if(t===null)this.ah.set(this.il),this.ga=this.scale;else if(t.Ks!==null){const i=this.ah;i.Bi(),t.kn()?i.hf(t.ah):t.panel!==null&&i.hf(t.panel.ah),i.hf(this.il),this.ga=this.scale*t.ga}this.Sa(!1)}}P0(t,i,e,s,n){if(this.lt!==1&&t.lt(this.lt),this.jt===0)return;const o=Point.a();o.setSpot(i,e,s,n,Spot.Center),t.ms(this.jt,o.x,o.y),Point.o(o)}u(t){if(this.Xo())return;t===void 0&&(t=!1),this.pe(!0),this.oo(!0);const i=this.panel;i!==null&&!t&&i.u()}rc(){this.Xo()||(this.pe(!0),this.oo(!0))}lc(t){if(this.rs())return;const i=this.panel;!t&&i!==null&&i.u(),this.oo(!0)}hd(){this.J1()===!1&&(this.cd(!0),this.Sa(!0))}b2(){this.Sa(!0)}T(){const t=this.part;t!==null&&t.T()}qs(t){const i=this.stretch,e=this.panel;if(e===null)return this.qo(i===1?0:i,t);if(e.type===Panel.Table)return this.F0(e.getRowDefinition(this.row),e.getColumnDefinition(this.column),t);if(e.type===Panel.Auto&&e.findMainElement()===this)return this.qo(2,t);if(i===1){if(e.type===Panel.Spot&&e.findMainElement()===this)return this.qo(2,t);const s=e.defaultStretch;return s===1?this.qo(0,t):this.qo(s,t)}return this.qo(i,t)}F0(t,i,e){const s=this.stretch;if(s!==1)return this.qo(s,e);let n=null,o=null;switch(t.stretch){case 1:case 5:break;case 4:o=!0;break;case 2:o=!0;break}switch(i.stretch){case 1:case 4:break;case 5:n=!0;break;case 2:n=!0;break}const r=this.panel.defaultStretch;return n===null&&(n=r===5||r===2),o===null&&(o=r===4||r===2),n===!0&&o===!0?this.qo(2,e):n===!0?this.qo(5,e):o===!0?this.qo(4,e):this.qo(0,e)}qo(t,i){if(i)return t;if(t===0)return 0;const e=this.desiredSize;if(e.isReal())return 0;const s=!isNaN(e.width),n=!isNaN(e.height),o=this.angle;if(s)if(o!==90&&o!==270){if(t===5)return 0;if(t===2)return 4}else{if(t===4)return 0;if(t===2)return 5}if(n)if(o!==90&&o!==270){if(t===4)return 0;if(t===2)return 5}else{if(t===5)return 0;if(t===2)return 4}return t}get segmentOrientation(){return this.Ut!==null?this.Ut.R0:0}set segmentOrientation(t){const i=this.segmentOrientation;i!==t&&(Debug&&Util.tt(t,Orientation,"Orientation"),this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.R0=t,this.u(),this.i("segmentOrientation",i,t),t===0&&(this.angle=0))}KR(){this.segmentOrientation=21}get segmentIndex(){return this.Ut!==null?this.Ut.I0:-1/0}set segmentIndex(t){Debug&&Util.t(t,"number",GraphObject,"segmentIndex"),t=Math.round(t);const i=this.segmentIndex;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.I0=t,this.u(),this.i("segmentIndex",i,t))}get segmentFraction(){return this.Ut!==null?this.Ut.O0:0}set segmentFraction(t){Debug&&Util.t(t,"number",GraphObject,"segmentFraction"),isNaN(t)||t<0?t=0:t>1&&(t=1);const i=this.segmentFraction;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.O0=t,this.u(),this.i("segmentFraction",i,t))}get segmentOffset(){return this.Ut!==null?this.Ut.E0:Point.Lo}set segmentOffset(t){const i=this.segmentOffset;i.equals(t)||(Debug&&Util.s(t,Point,GraphObject,"segmentOffset"),t=t.L(),this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.E0=t,this.u(),this.i("segmentOffset",i,t))}get stretch(){return this.g!==null?this.g.ro:1}set stretch(t){const i=this.stretch;i!==t&&(this.Zt(),this.g.ro=t,this.u(),this.i("stretch",i,t))}get name(){return this.g!==null?this.g.Tt:""}set name(t){const i=this.name;i!==t&&(Debug&&Util.t(t,"string",GraphObject,"name"),this.Zt(),this.g.Tt=t,this.part!==null&&this.part.V0(),this.i("name",i,t))}get opacity(){return this._t}set opacity(t){const i=this._t;if(i!==t){Util.t(t,"number",GraphObject,"opacity"),(t<0||t>1)&&Util.G(t,"0 <= value <= 1",GraphObject,"opacity"),this._t=t,this.i("opacity",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.T(s.Jh(s.actualBounds))}}get filter(){return this.sd}set filter(t){Debug&&Util.t(t,"string",GraphObject,"filter");const i=this.sd;if(i!==t){this.sd=t,this.hs(!0),this.i("filter",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.T(s.Jh(s.actualBounds))}}get visible(){return(this.l&1)!==0}set visible(t){const i=(this.l&1)!==0;if(i!==t){Debug&&Util.t(t,"boolean",GraphObject,"visible"),this.l=this.l^1,this.i("visible",i,t);const e=this.panel;e!==null?e.u():this.js()&&this.Ki(t),this.T(),this.pL()}}get pickable(){return(this.l&2)!==0}set pickable(t){const i=(this.l&2)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"pickable"),this.l=this.l^2,this.i("pickable",i,t))}get fromLinkableDuplicates(){return(this.l&4)!==0}set fromLinkableDuplicates(t){const i=(this.l&4)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"fromLinkableDuplicates"),this.l=this.l^4,this.i("fromLinkableDuplicates",i,t))}get fromLinkableSelfNode(){return(this.l&8)!==0}set fromLinkableSelfNode(t){const i=(this.l&8)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"fromLinkableSelfNode"),this.l=this.l^8,this.i("fromLinkableSelfNode",i,t))}get toLinkableDuplicates(){return(this.l&16)!==0}set toLinkableDuplicates(t){const i=(this.l&16)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"toLinkableDuplicates"),this.l=this.l^16,this.i("toLinkableDuplicates",i,t))}get toLinkableSelfNode(){return(this.l&32)!==0}set toLinkableSelfNode(t){const i=(this.l&32)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"toLinkableSelfNode"),this.l=this.l^32,this.i("toLinkableSelfNode",i,t))}get isPanelMain(){return(this.l&64)!==0}set isPanelMain(t){const i=(this.l&64)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"isPanelMain"),this.l=this.l^64,this.u(),this.i("isPanelMain",i,t))}get isActionable(){return(this.l&128)!==0}set isActionable(t){const i=(this.l&128)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"isActionable"),this.l=this.l^128,this.i("isActionable",i,t))}get background(){return this.Ft}set background(t){const i=this.Ft;i!==t&&(t!==null&&Brush.ud(t,"GraphObject.background"),t instanceof Brush&&t.w(),this.Ft=t,this.T(),this.i("background",i,t))}m2(){return(this.l&512)!==0}j1(t){t?this.l|=512:this.l&=-513}ec(){return(this.l&1024)!==0}k2(t){t?this.l|=1024:this.l&=-1025}J1(){return(this.l&2048)!==0}cd(t){t?this.l|=2048:this.l&=-2049}N0(){return(this.l&4096)!==0}Sa(t){t?this.l|=4096:this.l&=-4097}Xo(){return(this.l&8192)!==0}pe(t){t?this.l|=8192:this.l&=-8193}rs(){return(this.l&16384)!==0}oo(t){t?this.l|=16384:this.l&=-16385}XR(){return(this.l&32768)!==0}hs(t){t?this.l|=32768:this.l&=-32769}get part(){if(this.js())return this;if(this.sl!==null)return this.sl;let t=this;for(t=t.panel;t;){if(t instanceof Part)return this.sl=t,t;t=t.panel}return null}get svg(){return this.u2}set svg(t){this.u2=t}zu(){this.svg=null}get panel(){return this.Hs}Ma(t){this.Hs=t,this.svg!==null&&this.svg.remove()}get layer(){const t=this.part;return t!==null?t.layer:null}get diagram(){const t=this.part;return t!==null?t.diagram:null}get position(){return this.mt}set position(t){Debug&&Util.s(t,Point,GraphObject,"position");const i=t.x,e=t.y,s=this.mt,n=s.x,o=s.y;n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e))?(t=t.copy(),this.S2(t,n,o)&&this.i("position",new Point(n,o),t)):this.M2()}M2(){}S2(t,i,e){return this.mt=t,this.lc(),!0}Af(t,i,e){this.mt.x===t&&this.mt.y===i||(this.mt.e(t,i),this.hd())}get actualBounds(){return this.Fi}get scale(){return this.lt}set scale(t){const i=this.lt;i!==t&&(Debug&&Util.r(t,GraphObject,"scale"),t<=0&&Util.n("GraphObject.scale for "+this+" must be greater than zero, not: "+t),this.lt=t,this.u(),this.i("scale",i,t))}get angle(){return this.jt}set angle(t){const i=this.jt;if(i!==t){if(Debug&&Util.r(t,GraphObject,"angle"),t=t%360,t<0&&(t+=360),i===t)return;this.jt=t,this.pL(),this.u(),this.i("angle",i,t)}}get desiredSize(){return this.qe}set desiredSize(t){Debug&&Util.s(t,Size,GraphObject,"desiredSize");const i=t.width,e=t.height,s=this.qe,n=s.width,o=s.height;if((n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e)))&&(t=t.L(),this.qe=t,this.u(),this instanceof Shape&&this.re(),this.i("desiredSize",s,t),this.ec())){const r=this.part;r!==null&&(this.ka(r,"width"),this.ka(r,"height"))}}get width(){return this.qe.width}set width(t){const i=this.qe.width;if(i!==t&&(!isNaN(i)||!isNaN(t))){Debug&&Util.t(t,"number",GraphObject,"width");const e=this.qe,s=new Size(t,this.qe.height).w();if(this.qe=s,this.u(),this instanceof Shape&&this.re(),this.i("desiredSize",e,s),this.ec()){const n=this.part;n!==null&&this.ka(n,"width")}}}get height(){return this.qe.height}set height(t){const i=this.qe.height;if(i!==t&&(!isNaN(i)||!isNaN(t))){Debug&&Util.t(t,"number",GraphObject,"height");const e=this.qe,s=new Size(this.qe.width,t).w();if(this.qe=s,this.u(),this instanceof Shape&&this.re(),this.i("desiredSize",e,s),this.ec()){const n=this.part;n!==null&&this.ka(n,"height")}}}get minSize(){return this.g!==null?this.g.Pr:Size.lf}set minSize(t){const i=this.minSize;i.equals(t)||(Debug&&Util.s(t,Size,GraphObject,"minSize"),t=t.copy(),isNaN(t.width)&&(t.width=0),isNaN(t.height)&&(t.height=0),t.w(),this.Zt(),this.g.Pr=t,this.u(),this.i("minSize",i,t))}get maxSize(){return this.g!==null?this.g.Nr:Size.Xk}set maxSize(t){const i=this.maxSize;i.equals(t)||(Debug&&Util.s(t,Size,GraphObject,"maxSize"),t=t.copy(),isNaN(t.width)&&(t.width=1/0),isNaN(t.height)&&(t.height=1/0),t.w(),this.Zt(),this.g.Nr=t,this.u(),this.i("maxSize",i,t))}get measuredBounds(){return this.le}get naturalBounds(){return this.Hi}U1(){return 0}get margin(){return this.el}set margin(t){typeof t=="number"?t=new Margin(t):Debug&&Util.s(t,Margin,GraphObject,"margin");const i=this.el;i.equals(t)||(t=t.L(),this.el=t,this.u(),this.i("margin",i,t))}get O(){return this.J1()===!0&&this.G1(),this.il}get Ks(){return this.N0()===!0&&this.G1(),this.ah}trigger(t,i,e){let s=null;return typeof t=="string"?s=new AnimationTrigger(t,i,e):s=t,s.Ce=this,this.Ss===null&&(this.Ss=new GMap),this.Ss.set(s.propertyName,s),this}get Ss(){return this.g!==null?this.g.Ss:null}set Ss(t){this.Ss!==t&&(this.Zt(),this.g.Ss=t)}get Mr(){return this.g!==null?this.g.Mr:0}set Mr(t){this.Mr!==t&&(this.Zt(),this.g.Mr=t)}get alignment(){return this.ai}set alignment(t){const i=this.ai;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"alignment"),t.isNoSpot()&&!t.isDefault()&&Util.n("GraphObject.alignment for "+this+" must be a real Spot or Spot.Default, not: "+t),t=t.L(),this.ai=t,this.lc(),this.i("alignment",i,t))}get column(){return this.Go}set column(t){Debug&&Util.r(t,GraphObject,"column"),t=Math.round(t);const i=this.Go;i!==t&&(t<0&&Util.G(t,">= 0",GraphObject,"column"),this.Go=t,this.u(),this.i("column",i,t),this.svg!==null&&this.svg.remove())}get columnSpan(){return this.g!==null?this.g.B0:1}set columnSpan(t){Debug&&Util.t(t,"number",GraphObject,"columnSpan"),t=Math.round(t);const i=this.columnSpan;i!==t&&(t<1&&Util.G(t,">= 1",GraphObject,"columnSpan"),this.Zt(),this.g.B0=t,this.u(),this.i("columnSpan",i,t))}get row(){return this.ed}set row(t){Debug&&Util.r(t,GraphObject,"row"),t=Math.round(t);const i=this.ed;i!==t&&(t<0&&Util.G(t,">= 0",GraphObject,"row"),this.ed=t,this.u(),this.i("row",i,t),this.svg!==null&&this.svg.remove())}get rowSpan(){return this.g!==null?this.g.z0:1}set rowSpan(t){Debug&&Util.t(t,"number",GraphObject,"rowSpan"),t=Math.round(t);const i=this.rowSpan;i!==t&&(t<1&&Util.G(t,">= 1",GraphObject,"rowSpan"),this.Zt(),this.g.z0=t,this.u(),this.i("rowSpan",i,t))}get spanAllocation(){return this.g!==null?this.g.X0:null}set spanAllocation(t){const i=this.spanAllocation;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"spanAllocation"),this.Zt(),this.g.X0=t,this.u(),this.i("spanAllocation",i,t))}get alignmentFocus(){return this.tc}set alignmentFocus(t){const i=this.tc;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"alignmentFocus"),Debug&&t.isNoSpot()&&!t.isDefault()&&!(t.isNone()&&this instanceof Node)&&Util.n("GraphObject.alignmentFocus must be a real Spot or Spot.Default, not: "+t),t=t.L(),this.tc=t,this.u(),this.i("alignmentFocus",i,t))}get portId(){return this.td}set portId(t){const i=this.td;if(i!==t){Debug&&t!==null&&Util.t(t,"string",GraphObject,"portId");const e=this.part;e!==null&&!(e instanceof Node)&&Util.n("Cannot set portID on a Link: "+t);const s=e;i!==null&&s!==null&&s.P2(this),this.td=t,t!==null&&s!==null&&(s.Mn=!0,s.yL(this)),this.i("portId",i,t)}}Pa(){const t=this.part;if(t instanceof Node&&(this.portId!==null||this===t.port)){const i=t.diagram;i!==null&&!i.undoManager.isUndoingRedoing&&t.aL(this)}}pL(){const t=this.diagram;t===null||t.undoManager.isUndoingRedoing||(this instanceof Panel?this instanceof Node?this.invalidateConnectedLinks():this.walkVisualTreeFrom(this,i=>{i.Pa()}):this.Pa())}get toSpot(){return this.Z!==null?this.Z.pa:Spot.None}set toSpot(t){const i=this.toSpot;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"toSpot"),t=t.L(),this.je(),this.Z.pa=t,this.i("toSpot",i,t),this.Pa())}get toEndSegmentLength(){return this.Z!==null?this.Z.wa:10}set toEndSegmentLength(t){const i=this.toEndSegmentLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"toEndSegmentLength"),t<0&&Util.G(t,">= 0",GraphObject,"toEndSegmentLength"),this.je(),this.Z.wa=t,this.i("toEndSegmentLength",i,t),this.Pa())}get toShortLength(){return this.Z!==null?this.Z.ba:0}set toShortLength(t){const i=this.toShortLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"toShortLength"),this.je(),this.Z.ba=t,this.i("toShortLength",i,t),this.Pa())}get toLinkable(){return this.Z!==null?this.Z.Y0:null}set toLinkable(t){const i=this.toLinkable;i!==t&&(Debug&&t!==null&&Util.t(t,"boolean",GraphObject,"toLinkable"),this.je(),this.Z.Y0=t,this.i("toLinkable",i,t))}get toMaxLinks(){return this.Z!==null?this.Z.K0:1/0}set toMaxLinks(t){const i=this.toMaxLinks;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"toMaxLinks"),t<0&&Util.G(t,">= 0",GraphObject,"toMaxLinks"),this.je(),this.Z.K0=t,this.i("toMaxLinks",i,t))}get fromSpot(){return this.Z!==null?this.Z.ma:Spot.None}set fromSpot(t){const i=this.fromSpot;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"fromSpot"),t=t.L(),this.je(),this.Z.ma=t,this.i("fromSpot",i,t),this.Pa())}get fromEndSegmentLength(){return this.Z!==null?this.Z.ya:10}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"fromEndSegmentLength"),t<0&&Util.G(t,">= 0",GraphObject,"fromEndSegmentLength"),this.je(),this.Z.ya=t,this.i("fromEndSegmentLength",i,t),this.Pa())}get fromShortLength(){return this.Z!==null?this.Z.xa:0}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"fromShortLength"),this.je(),this.Z.xa=t,this.i("fromShortLength",i,t),this.Pa())}get fromLinkable(){return this.Z!==null?this.Z.U0:null}set fromLinkable(t){const i=this.fromLinkable;i!==t&&(Debug&&t!==null&&Util.t(t,"boolean",GraphObject,"fromLinkable"),this.je(),this.Z.U0=t,this.i("fromLinkable",i,t))}get fromMaxLinks(){return this.Z!==null?this.Z.G0:1/0}set fromMaxLinks(t){const i=this.fromMaxLinks;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"fromMaxLinks"),t<0&&Util.G(t,">= 0",GraphObject,"fromMaxLinks"),this.je(),this.Z.G0=t,this.i("fromMaxLinks",i,t))}get cursor(){return this.g!==null?this.g.Al:""}set cursor(t){const i=this.cursor;i!==t&&(Util.t(t,"string",GraphObject,"cursor"),this.Zt(),this.g.Al=t,this.i("cursor",i,t))}get click(){return this.g!==null?this.g.Or:null}set click(t){const i=this.click;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"click"),this.Zt(),this.g.Or=t,this.i("click",i,t))}get doubleClick(){return this.g!==null?this.g.Er:null}set doubleClick(t){const i=this.doubleClick;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"doubleClick"),this.Zt(),this.g.Er=t,this.i("doubleClick",i,t))}get contextClick(){return this.g!==null?this.g.Vr:null}set contextClick(t){const i=this.contextClick;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"contextClick"),this.Zt(),this.g.Vr=t,this.i("contextClick",i,t))}get mouseEnter(){return this.g!==null?this.g.Kr:null}set mouseEnter(t){const i=this.mouseEnter;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseEnter"),this.Zt(),this.g.Kr=t,this.i("mouseEnter",i,t))}get mouseLeave(){return this.g!==null?this.g.Ur:null}set mouseLeave(t){const i=this.mouseLeave;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseLeave"),this.Zt(),this.g.Ur=t,this.i("mouseLeave",i,t))}get mouseOver(){return this.g!==null?this.g.Br:null}set mouseOver(t){const i=this.mouseOver;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseOver"),this.Zt(),this.g.Br=t,this.i("mouseOver",i,t))}get mouseHover(){return this.g!==null?this.g.zr:null}set mouseHover(t){const i=this.mouseHover;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseHover"),this.Zt(),this.g.zr=t,this.i("mouseHover",i,t))}get mouseHold(){return this.g!==null?this.g.Xr:null}set mouseHold(t){const i=this.mouseHold;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseHold"),this.Zt(),this.g.Xr=t,this.i("mouseHold",i,t))}get mouseDragEnter(){return this.g!==null?this.g.H0:null}set mouseDragEnter(t){const i=this.mouseDragEnter;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseDragEnter"),this.Zt(),this.g.H0=t,this.i("mouseDragEnter",i,t))}get mouseDragLeave(){return this.g!==null?this.g.q0:null}set mouseDragLeave(t){const i=this.mouseDragLeave;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseDragLeave"),this.Zt(),this.g.q0=t,this.i("mouseDragLeave",i,t))}get mouseDrop(){return this.g!==null?this.g.Yr:null}set mouseDrop(t){const i=this.mouseDrop;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseDrop"),this.Zt(),this.g.Yr=t,this.i("mouseDrop",i,t))}get actionDown(){return this.g!==null?this.g.j0:null}set actionDown(t){const i=this.actionDown;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionDown"),this.Zt(),this.g.j0=t,this.i("actionDown",i,t))}get actionMove(){return this.g!==null?this.g.W0:null}set actionMove(t){const i=this.actionMove;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionMove"),this.Zt(),this.g.W0=t,this.i("actionMove",i,t))}get actionUp(){return this.g!==null?this.g.v0:null}set actionUp(t){const i=this.actionUp;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionUp"),this.Zt(),this.g.v0=t,this.i("actionUp",i,t))}get actionCancel(){return this.g!==null?this.g.J0:null}set actionCancel(t){const i=this.actionCancel;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionCancel"),this.Zt(),this.g.J0=t,this.i("actionCancel",i,t))}get toolTip(){return this.g!==null?this.g.Gr:null}set toolTip(t){const i=this.toolTip;i!==t&&(Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("GraphObject.toolTip must be an Adornment or HTMLInfo."),this.Zt(),this.g.Gr=t,this.i("toolTip",i,t))}get contextMenu(){return this.g!==null?this.g.Hr:null}set contextMenu(t){const i=this.contextMenu;i!==t&&(Debug&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("GraphObject.contextMenu must be an Adornment or HTMLInfo."),this.Zt(),this.g.Hr=t,this.i("contextMenu",i,t))}findBindingPanel(){let t=this instanceof Panel?this:this.panel;for(;t!==null;){if(t.N2())return t;t=t.panel}return null}bind(t,i,e,s){return this.hc(t,i,e,s),this}bindTwoWay(t,i,e,s){return this.hc(t,i,e,s).makeTwoWay(),this}bindModel(t,i,e,s){return this.hc(t,i,e,s).ofModel(),this}bindObject(t,i,e,s,n){return this.hc(t,i,e,s).ofObject(n),this}theme(t,i,e,s,n){return this.mh(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.mh(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.mh(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.mh(t,i,e,s,n).ofModel(),this}hc(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.Z0(n),n}mh(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.Z0(o),o}Z0(t){t.Ce=this;const i=this.findBindingPanel();i!==null&&i.wL()&&Util.n("Cannot add a Binding to a template that has already been copied: "+t),this.Ri===null&&(this.Ri=new List),this.Ri.add(t)}set(t){if(Debug)for(const i in t)(i.startsWith("_")||i.indexOf(".")!==-1)&&Util.n("Property with underscore or period passed to GraphObject.set. Did you mean to use GraphObject.attach?");return Object.assign(this,t),this}attach(t){return GraphObject.C2(this,t),this}apply(t){return t(this),this}setProperties(t){return Diagram.p0(this,t),this}static build(t,i,...e){const s=GraphObject.$0.get(t);if(typeof s=="function"){const n=s([t].concat(e));if(n instanceof GraphObject)return i&&n.setProperties(i),n}Util.n('GraphObject.build invoked object builder "'+t+'", but it did not return an Object')}static make(t,...i){let e=arguments,s=null,n=null;if(typeof t=="function")n=t;else if(typeof t=="string"){const r=GraphObject.$0.get(t);typeof r=="function"?(e=Array.prototype.slice.call(e),s=r(e),Util.Mt(s)||Util.n('GraphObject.make invoked object builder "'+t+'", but it did not return an Object')):n=root.go[t]}s===null&&((n==null||!n.constructor)&&Util.n("GraphObject.make requires a class function or GoJS class name or name of an object builder, not: "+t),s=new n);let o=1;if(s instanceof Diagram&&e.length>1){const r=s,l=e[1];(typeof l=="string"||l instanceof HTMLDivElement)&&(r.MP(l),o++)}for(let r=o;r{const i="#f5f5f5",e="#737373",s="#d4d4d4",n="#737373",o="#a3a3a3",r=2.76142374915397,l=2.761423749153969,h=new Panel(Panel.Auto,{isActionable:!0,enabledChanged:(a,f)=>{if(a instanceof Panel){const c=a.findObject("ButtonBorder");c!==null&&(f?(a._buttonFillDisabled=c.fill,c.fill=a._buttonFillNormal):(a._buttonFillNormal=c.fill,c.fill=a._buttonFillDisabled))}},cursor:"pointer"}).attach({_buttonFillNormal:i,_buttonStrokeNormal:e,_buttonFillOver:s,_buttonStrokeOver:n,_buttonFillDisabled:o}).add(new Shape("RoundedRectangle",{name:"ButtonBorder",spot1:new Spot(0,0,r,l),spot2:new Spot(1,1,-r,-l),parameter1:2,fill:i,stroke:e}));return h.mouseEnter=(a,f,c)=>{if(!f.isEnabledObject()||!(f instanceof Panel))return;const u=f.findObject("ButtonBorder");u instanceof Shape&&(f._buttonFillNormal=u.fill,u.fill=f._buttonFillOver,f._buttonStrokeNormal=u.stroke,u.stroke=f._buttonStrokeOver)},h.mouseLeave=(a,f,c)=>{if(!f.isEnabledObject()||!(f instanceof Panel))return;const u=f.findObject("ButtonBorder");u instanceof Shape&&(u.fill=f._buttonFillNormal,u.stroke=f._buttonStrokeNormal)},h}),GraphObject.defineBuilder("TreeExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_treeExpandedFigure:"MinusLine",_treeCollapsedFigure:"PlusLine",visible:!1}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.gu}).bindObject("figure","isTreeExpanded",(e,s)=>{const n=s.panel;return e?n._treeExpandedFigure:n._treeCollapsedFigure})),i.bindObject("visible","isTreeLeaf",e=>!e),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Node))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isTreeExpanded){if(!r.canCollapseTree(n))return}else if(!r.canExpandTree(n))return;e.handled=!0,n.isTreeExpanded?r.collapseTree(n):r.expandTree(n)},i}),GraphObject.defineBuilder("SubGraphExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_subGraphExpandedFigure:"MinusLine",_subGraphCollapsedFigure:"PlusLine"}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.gu}).bindObject("figure","isSubGraphExpanded",(e,s)=>{const n=s.panel;return e?n._subGraphExpandedFigure:n._subGraphCollapsedFigure})),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Group))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isSubGraphExpanded){if(!r.canCollapseSubGraph(n))return}else if(!r.canExpandSubGraph(n))return;e.handled=!0,n.isSubGraphExpanded?r.collapseSubGraph(n):r.expandSubGraph(n)},i}),GraphObject.defineBuilder("ToolTip",t=>new Adornment(Panel.Auto,{isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).add(new Shape("RoundedRectangle",{name:"Border",parameter1:1,fill:"#f5f5f5",strokeWidth:0,spot1:new Spot(0,0,4,6),spot2:new Spot(1,1,-4,-4)}))),GraphObject.defineBuilder("ContextMenu",t=>new Adornment(Panel.Vertical,{background:"#f5f5f5",isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).bindObject("background","",i=>i.adornedPart!==null&&i.hasPlaceholder()?null:"#f5f5f5")),GraphObject.defineBuilder("ContextMenuButton",t=>{const i=GraphObject.build("Button");i.stretch=5;const e=i.findObject("ButtonBorder");return e instanceof Shape&&(e.figure="Rectangle",e.strokeWidth=0,e.spot1=new Spot(0,0,4,6),e.spot2=new Spot(1,1,-4,-4)),i}),GraphObject.defineBuilder("PanelExpanderButton",t=>{const i=GraphObject.takeBuilderArgument(t,"COLLAPSIBLE"),e=GraphObject.build("Button");e.attach({_buttonExpandedFigure:"M0 0 M0 6 L4 2 8 6 M8 8",_buttonCollapsedFigure:"M0 0 M0 2 L4 6 8 2 M8 8",_buttonFillNormal:"rgba(0, 0, 0, 0)",_buttonStrokeNormal:null,_buttonFillOver:"rgba(0, 0, 0, .2)",_buttonStrokeOver:null}),e.add(new Shape({name:"ButtonIcon",strokeWidth:2}).bindObject("geometryString","visible",n=>n?e._buttonExpandedFigure:e._buttonCollapsedFigure,void 0,i));const s=e.findObject("ButtonBorder");return s instanceof Shape&&(s.stroke=null,s.fill="rgba(0, 0, 0, 0)"),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=o.diagram;if(r===null||r.isReadOnly)return;let l=o.findBindingPanel();if(l===null&&(l=o.part),l!==null){const h=l.findObject(i);h!==null&&(n.handled=!0,r.startTransaction("Collapse/Expand Panel"),h.visible=!h.visible,r.commitTransaction("Collapse/Expand Panel"))}},e}),GraphObject.defineBuilder("CheckBoxButton",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("Button",{desiredSize:new Size(14,14)});e.attach({"ButtonBorder.spot1":new Spot(0,0,1,1),"ButtonBorder.spot2":new Spot(1,1,-1,-1)});const s=new Shape({name:"ButtonIcon",geometryString:"M0 0 M0 8.85 L4.9 13.75 16.2 2.45 M16.2 16.2",strokeWidth:2,stretch:2,geometryStretch:6,visible:!1});return i!==""&&s.bindTwoWay("visible",i),e.add(s),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=n.diagram;if(r===null||r.isReadOnly||i!==""&&r.model.isReadOnly)return;n.handled=!0;const l=o.findObject("ButtonIcon");r.startTransaction("checkbox"),l!==null&&(l.visible=!l.visible),typeof o._doClick=="function"&&o._doClick(n,o),r.commitTransaction("checkbox")},e}),GraphObject.defineBuilder("CheckBox",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("CheckBoxButton",{name:"Button",isActionable:!1,margin:new Margin(0,1,0,0)},i),s=new Panel("Horizontal",{isActionable:!0,cursor:e.cursor,margin:new Margin(1),mouseEnter:e.mouseEnter,mouseLeave:e.mouseLeave,click:e.click}).attach({_buttonFillNormal:e._buttonFillNormal,_buttonStrokeNormal:e._buttonStrokeNormal,_buttonFillOver:e._buttonFillOver,_buttonStrokeOver:e._buttonStrokeOver,_buttonFillDisabled:e._buttonFillDisabled,_buttonClick:e.click});return s.add(e),e.mouseEnter=null,e.mouseLeave=null,e.click=null,s})}}class GraphObjectTemplateSettings{wi;Tt;eo;Ri;so;Ws;Al;Or;Er;Vr;Kr;Ur;Br;zr;Xr;H0;q0;Yr;j0;W0;v0;J0;Gr;Hr;D0;X0;Ss;Pr;Nr;ro;z0;B0;Mr;L0;Q0;_0;constructor(){this.wi=!1,this.Tt="",this.eo=-1,this.Ri=null,this.so=null,this.Ws=null,this.Al="",this.Or=null,this.Er=null,this.Vr=null,this.Kr=null,this.Ur=null,this.Br=null,this.zr=null,this.Xr=null,this.H0=null,this.q0=null,this.Yr=null,this.j0=null,this.W0=null,this.v0=null,this.J0=null,this.Gr=null,this.Hr=null,this.D0=null,this.X0=null,this.Ss=null,this.Pr=Size.lf,this.Nr=Size.Xk,this.ro=1,this.z0=1,this.B0=1,this.Mr=0,this.L0=null,this.Q0=null,this._0="category"}copy(){const t=new GraphObjectTemplateSettings;return t.Tt=this.Tt,t.eo=this.eo,t.Ri=this.Ri,t.Ws=this.Ws,t.Al=this.Al,t.Or=this.Or,t.Er=this.Er,t.Vr=this.Vr,t.Kr=this.Kr,t.Ur=this.Ur,t.Br=this.Br,t.zr=this.zr,t.Xr=this.Xr,t.H0=this.H0,t.q0=this.q0,t.Yr=this.Yr,t.j0=this.j0,t.W0=this.W0,t.v0=this.v0,t.J0=this.J0,t.Gr=this.Gr,t.Hr=this.Hr,t.D0=this.D0,t.X0=this.X0,t.Ss=this.Ss,t.Pr=this.Pr.L(),t.Nr=this.Nr.L(),t.ro=this.ro,t.z0=this.z0,t.B0=this.B0,t.Mr=this.Mr,t.L0=this.L0,t.Q0=this.Q0,t._0=this._0,t}}class STransform{m;constructor(){this.m=[1,0,0,1,0,0]}copy(){const t=new STransform;return t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5],t}translate(t,i){this.m[4]+=this.m[0]*t+this.m[2]*i,this.m[5]+=this.m[1]*t+this.m[3]*i}scale(t,i){this.m[0]*=t,this.m[1]*=t,this.m[2]*=i,this.m[3]*=i}rotate(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return;this.translate(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m[0]*s+this.m[2]*n,r=this.m[1]*s+this.m[3]*n,l=this.m[0]*-n+this.m[2]*s,h=this.m[1]*-n+this.m[3]*s;this.m[0]=o,this.m[1]=r,this.m[2]=l,this.m[3]=h,this.translate(-i,-e)}}class SGradient{type;x1;y1;r1;x2;y2;r2;colors;pattern;constructor(t){this.type=t,this.x1=0,this.y1=0,this.r1=0,this.x2=0,this.y2=0,this.r2=0,this.colors=[],this.pattern=null}addColorStop(t,i){this.colors.push({offset:t,color:i})}}class SVGSurface{Bt;di;ua;Qu;A2;constructor(t,i,e){const s=i===void 0?root.document:i;this.ua=s,this.A2="http://www.w3.org/2000/svg";const n="http://www.w3.org/2000/xmlns/";s!==void 0&&(this.Bt=this.makeElement("svg",{width:"1px",height:"1px",viewBox:"0 0 1 1"}),this.style.display="block",this.style.letterSpacing="normal",this.style.wordSpacing="normal",e||(this.style.position="absolute"),this.Bt.setAttributeNS(n,"xmlns",this.A2),this.Bt.setAttributeNS(n,"xmlns:xlink","http://www.w3.org/1999/xlink")),this.Qu=null,this.di=new SVGContext(this,e)}resize(t,i,e,s){return this.width!==t||this.height!==i?(this.width=t,this.height=i,this.style.width=e+"px",this.style.height=s+"px",this.Bt.setAttributeNS(null,"width",e+"px"),this.Bt.setAttributeNS(null,"height",s+"px"),this.Bt.setAttributeNS(null,"viewBox","0 0 "+e+" "+s),this.di.L2.firstElementChild.setAttributeNS(null,"width",e+"px"),this.di.L2.firstElementChild.setAttributeNS(null,"height",s+"px"),!0):!1}makeElement(t,i,e){const s=this.ua.createElementNS(this.A2,t);if(Util.Mt(i))for(const n in i)s.setAttributeNS(n==="href"?"http://www.w3.org/1999/xlink":"",n,i[n]);return e!==void 0&&(s.textContent=e),s}getBoundingClientRect(){return this.Bt.getBoundingClientRect()}focus(){this.Bt.focus()}get width(){return this.Bt.width.baseVal.value}set width(t){this.Bt.setAttribute("width",t+"px")}get height(){return this.Bt.height.baseVal.value}set height(t){this.Bt.setAttribute("height",t+"px")}dispose(){this.ua=null}get style(){return this.Bt.style}}class SVGContext{ac;fc;Pn;Ii;We;fillStyle;font;globalAlpha;lineCap;lineDashOffset;lineJoin;lineWidth;miterLimit;shadowBlur;shadowColor;shadowOffsetX;shadowOffsetY;strokeStyle;textAlign;imageSmoothingEnabled;clipInsteadOfFill;lastCreatedElement;cc;uc;surface;svg;L2;xL;$1;jo;ph;Na;currentElement;clipPathGroup;diagramGroup;lastDrawnPart;currentPath;outerGroup;pathAttributes;ol;Tr;filter;partClipRect;constructor(t,i){this.surface=t,this.svg=t.Bt,this.cc=[],this.uc=[],this.fillStyle="#000000",this.font="10px sans-serif",this.globalAlpha=1,this.lineCap="butt",this.lineDashOffset=0,this.lineJoin="miter",this.lineWidth=1,this.miterLimit=10,this.shadowBlur=0,this.shadowColor="rgba(0, 0, 0, 0)",this.shadowOffsetX=0,this.shadowOffsetY=0,this.ol=!1,this.strokeStyle="#000000",this.textAlign="start",this.clipInsteadOfFill=!1,this.ac=0,this.fc=0,this.Pn=0,this.lastCreatedElement=null,this.currentElement=null,this.Ii=[],this.pathAttributes={},this.$1=!1,this.jo=null,this.ph=0,this.We=new STransform,this.clipPathGroup=this.newGroup2(),this.diagramGroup=this.newGroup2("gojs-diagram"),this.lastDrawnPart=null,this.currentPath=null;const e=GSet.cu++,s=this.makeElement("clipPath",{id:"mainClip"+e}),n={x:0,y:0,width:t.width,height:t.height};s.appendChild(this.makeElement("rect",n)),this.L2=s,this.svg.appendChild(this.clipPathGroup),this.clipPathGroup.appendChild(this.diagramGroup),this.svg.appendChild(s),this.clipPathGroup.setAttributeNS(null,"clip-path","url(#mainClip"+e+")"),this.xL={},this.Tr=!!i,this.filter="",this.partClipRect=null}setDiagramPosScale(t,i,e,s,n,o){this.diagramGroup===void 0?this.newGroup(t,i,e,s,n,o):this.diagramGroup.setAttribute("transform","matrix("+t+", "+i+", "+e+", "+s+", "+n+", "+o+")")}resetInnerSVG(){this.diagramGroup!==null&&(this.diagramGroup.innerHTML="")}arc(t,i,e,s,n,o,r,l){const h=2*Math.PI,a=1e-6,f=h-a,c=e*Math.cos(s),u=e*Math.sin(s),d=t+c,m=i+u,g=o?0:1;let p=o?s-n:n-s;(Math.abs(r-d)>a||Math.abs(l-m)>a)&&this.Ii.push(["L",d,+m]),p<0&&(p=p%h+h),p>f?(this.Ii.push(["A",e,e,0,1,g,t-c,i-u]),this.Ii.push(["A",e,e,0,1,g,d,m])):p>a&&this.Ii.push(["A",e,e,0,+(p>=Math.PI),g,t+e*Math.cos(n),i+e*Math.sin(n)])}beginPath(){this.Ii=[],this.pathAttributes={stroke:"none",fill:"none"}}endPath(t){this.qR(this.Ii,this.We,t||0)}bezierCurveTo(t,i,e,s,n,o){this.Ii.push(["C",t,i,e,s,n,o])}clearRect(t,i,e,s){}clip(){this.pathAttributes.clipPath=!0}closePath(){this.Ii.push(["z"])}createLinearGradient(t,i,e,s){const n=new SGradient("linear");return n.x1=t,n.y1=i,n.x2=e,n.y2=s,n}createPattern(t,i){let e="";t instanceof HTMLCanvasElement&&(e=t.toDataURL()),t instanceof HTMLImageElement&&(e=t.getAttribute("src"));const s=this.xL;if(s[e])return"url(#"+s[e]+")";const n="PATTERN"+GSet.cu++,o={width:t.width,height:t.height,id:n,patternUnits:"userSpaceOnUse"},r={x:0,y:0,width:t.width,height:t.height,href:e},l=this.makeElement("pattern",o);return l.appendChild(this.makeElement(Diagram.img,r)),this.svg.appendChild(l),s[e]=n,"url(#"+n+")"}createRadialGradient(t,i,e,s,n,o){const r=new SGradient("radial");return r.x1=t,r.y1=i,r.r1=e,r.x2=s,r.y2=n,r.r2=o,r}amendImageTransform(t,i,e,s,n,o,r,l){const h=r/e,a=l/s;(n!==0||o!==0)&&this.We.translate(n,o),(h!==1||a!==1)&&this.We.scale(h,a),(t!==0||i!==0)&&this.We.translate(-t,-i)}drawImage(t,i,e,s,n,o,r,l,h){let a="";t instanceof HTMLCanvasElement&&(a=t.toDataURL()),t instanceof HTMLImageElement&&(a=t.getAttribute("src"));const f=t instanceof HTMLImageElement?t.naturalWidth:t.width,c=t instanceof HTMLImageElement?t.naturalHeight:t.height;s===void 0&&(o=i,r=e,l=s=f,h=n=c),s=s||0,n=n||0,o=o||0,r=r||0,l=l||0,h=h||0,this.amendImageTransform(i,e,s,n,o,r,l,h);const u={x:0,y:0,width:f||s,height:c||n,href:a};!Geo.q(s,l)||!Geo.q(n,h)?u.preserveAspectRatio="none":a.toLowerCase().indexOf(".svg")===-1&&a.toLowerCase().indexOf("data:image/svg")===-1&&(u.preserveAspectRatio="xMidYMid slice"),(i!==0||e!==0||s!==f||n!==c)&&(s+=i,n+=e,u["clip-path"]=`path('M ${i},${e} L ${s} ${e} L ${s} ${n} L ${i} ${n} z')`),this.processCommon(Diagram.img,u,this.We),this.dd(Diagram.img,u)}fill(t,i){t&&(this.pathAttributes["fill-rule"]="evenodd"),this.setFill(this.pathAttributes)}fillContext(t,i,e){this.clipInsteadOfFill?this.clip():this.fill(i,e)}fillRect(t,i,e,s){this.addRect("fill",[t,i,e,s],this.We)}fillBackground(t,i,e,s){const n={x:t,y:i,width:e,height:s};this.processCommon("fill",n,this.We),this.setFill(n),this.svg.prepend(this.makeElement("rect",n))}fillText(t,i,e){this.addText("fill",[t,i,e],this.We)}lineTo(t,i){this.Ii.push(["L",t,i])}moveTo(t,i){this.Ii.push(["M",t,i])}quadraticCurveTo(t,i,e,s){this.Ii.push(["Q",t,i,e,s])}rect(t,i,e,s){this.Ii.push(["M",t,i],["L",t+e,i],["L",t+e,i+s],["L",t,i+s],["z"])}restore(){this.We=this.cc.pop(),this.Ii=this.cc.pop();const t=this.cc.pop();this.fillStyle=t.fillStyle,this.font=t.font,this.globalAlpha=t.globalAlpha,this.lineCap=t.lineCap,this.lineDashOffset=t.lineDashOffset,this.lineJoin=t.lineJoin,this.lineWidth=t.lineWidth,this.miterLimit=t.miterLimit,this.shadowBlur=t.shadowBlur,this.shadowColor=t.shadowColor,this.shadowOffsetX=t.shadowOffsetX,this.shadowOffsetY=t.shadowOffsetY,this.strokeStyle=t.strokeStyle,this.textAlign=t.textAlign,this.partClipRect=t.partClipRect}save(){const t={fillStyle:this.fillStyle,font:this.font,globalAlpha:this.globalAlpha,lineCap:this.lineCap,lineDashOffset:this.lineDashOffset,lineJoin:this.lineJoin,lineWidth:this.lineWidth,miterLimit:this.miterLimit,shadowBlur:this.shadowBlur,shadowColor:this.shadowColor,shadowOffsetX:this.shadowOffsetX,shadowOffsetY:this.shadowOffsetY,strokeStyle:this.strokeStyle,textAlign:this.textAlign,partClipRect:this.partClipRect};this.cc.push(t);const i=[];for(let e=0;eh.offset>a.offset?1:-1);for(let h=0;h0&&this.uc[this.uc.length-1].setAttributeNS(null,"clip-path",'path("'+s+'")');return}if(n.d=s,this.processCommon("",n,i),this.currentPath!==null){const r=this.currentPath;if(r.nodeName!=="g")for(const l in n)l!=="transform"&&r.setAttributeNS(null,l,n[l]);else{const l=r.getElementsByTagName("path");for(const h in n)h!=="transform"&&l[e].setAttributeNS(null,h,n[h])}}else this.dd("path",n)}jR(t){const i=[];for(let e=0;es?(this.scale(s/n,1),this.translate((n-s)/2,0)):s>n&&(this.scale(1,n/s),this.translate(0,(s-n)/2)),this.fillOrClip(i,e),n>s?(this.translate(-(n-s)/2,0),this.scale(1/(s/n),1)):s>n&&(this.translate(0,-(s-n)/2),this.scale(1,1/(n/s))),!0}strokeContext(){this.tp||this.stroke()}fillOrClip(t,i){this.tp?this.clip(i):this.fill(t,i)}get clipInsteadOfFill(){return this.tp}set clipInsteadOfFill(t){this.tp=t}shadowsSet(t,i,e){this.ac=t,this.fc=i,this.Pn=e}shadowsOff(){this.ol=!1,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0}shadowsOn(){this.ol=!0,this.shadowOffsetX=this.ac,this.shadowOffsetY=this.fc,this.shadowBlur=this.Pn}enableDash(t,i){const e=this.Y;e.setLineDash!==void 0&&(e.setLineDash(t),e.lineDashOffset=i)}disableDash(){const t=this.Y;t.setLineDash!==void 0&&(t.setLineDash(CanvasSurfaceContext.EmptyArray),t.lineDashOffset=0)}clearContextCache(t){t&&(this.Q1=""),this._1="",this.tb=""}removePartFromView(t){}static EmptyArray=Object.freeze([])}var BrushType=(w=>(w[w.Solid=1]="Solid",w[w.Linear=2]="Linear",w[w.Radial=3]="Radial",w[w.Pattern=4]="Pattern",w))(BrushType||{}),ColorSpace=(w=>(w[w.Lab=1]="Lab",w[w.HSL=2]="HSL",w[w.Oklch=3]="Oklch",w))(ColorSpace||{});class ColorNumbers{n0;n1;n2;n3;constructor(){this.n0=0,this.n1=0,this.n2=0,this.n3=0}}class Brush{f;st;Ca;li;xs;ip;ep;Nn;sp;Sn;oc;v1;constructor(t,i){if(GSet.vi(this),this.f=!1,t===void 0)this.st=1,this.Ca="black";else if(typeof t=="string"){const s=Util.zh(BrushType,t);s!==null?(this.st=s,this.Ca="black"):(this.st=1,Debug&&!Brush.isValidColor(t)&&Util.n('Color "'+t+'" is not a valid color string for Brush constructor'),this.Ca=t)}else Debug&&Util.tt(t,BrushType,"BrushType"),this.st=t,this.Ca="black";const e=this.st;if(e===2?(this.li=Spot.TopCenter,this.xs=Spot.BottomCenter):e===3?(this.li=Spot.Center,this.xs=Spot.Center):(this.li=Spot.None,this.xs=Spot.None),this.ip=0,this.ep=NaN,this.Nn=null,this.sp=null,this.Sn=null,this.oc=0,this.v1=0,i){const s={};for(const n in i)isFinite(parseFloat(n))?this.addColorStop(parseFloat(n),i[n]):s[n]=i[n];Object.assign(this,s)}}copy(){const t=new Brush;return t.st=this.st,t.Ca=this.Ca,t.li=this.li.L(),t.xs=this.xs.L(),t.ip=this.ip,t.ep=this.ep,this.Nn!==null&&(t.Nn=this.Nn.copy()),t.sp=this.sp,t}w(){return this.f=!0,this.Nn!==null&&this.Nn.w(),this}ct(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this.Nn!==null&&this.Nn.ct(),this}fi(t){t in BrushType?this.type=t:Util.ur(this,t)}toString(){let t="Brush(";if(this.type===1)t+=this.color;else if(this.type===2?t+="Linear ":this.type===3?t+="Radial ":this.type===4?t+="Pattern ":t+="(unknown) ",t+=this.start+" "+this.end,this.colorStops!==null){const i=this.colorStops.iterator;for(;i.next();){const e=i.key,s=i.value;t+=" "+e+":"+s}}return t+=")",t}addColorStop(t,i){return this.f&&Util.F(this),(typeof t!="number"||!isFinite(t)||t>1||t<0)&&Util.G(t,"0 <= loc <= 1",Brush,"addColorStop:loc"),Util.t(i,"string",Brush,"addColorStop:color"),Debug&&!Brush.isValidColor(i)&&Util.n('Color "'+i+'" is not a valid color string for Brush.addColorStop'),this.Nn===null&&(this.Nn=new GMap),this.Nn.set(t,i),this.st===1&&(this.type=2),this.Sn=null,this}get type(){return this.st}set type(t){this.f&&Util.F(this,t),Util.tt(t,BrushType,"BrushType"),this.st=t,this.start.isNoSpot()&&(t===2?this.start=Spot.TopCenter:t===3&&(this.start=Spot.Center)),this.end.isNoSpot()&&(t===2?this.end=Spot.BottomCenter:t===3&&(this.end=Spot.Center)),this.Sn=null}get color(){return this.Ca}set color(t){this.f&&Util.F(this,t),Debug&&!Brush.isValidColor(t)&&Util.n('Color "'+t+'" is not a valid color string for Brush.color'),this.Ca=t,this.Sn=null}get start(){return this.li}set start(t){this.f&&Util.F(this,t),Util.s(t,Spot,Brush,"start"),this.li=t.L(),this.Sn=null}get end(){return this.xs}set end(t){this.f&&Util.F(this,t),Util.s(t,Spot,Brush,"end"),this.xs=t.L(),this.Sn=null}get startRadius(){return this.ip}set startRadius(t){this.f&&Util.F(this,t),Util.r(t,Brush,"startRadius"),t<0&&Util.G(t,">= zero",Brush,"startRadius"),this.ip=t,this.Sn=null}get endRadius(){return this.ep}set endRadius(t){this.f&&Util.F(this,t),Util.r(t,Brush,"endRadius"),t<0&&Util.G(t,">= zero",Brush,"endRadius"),this.ep=t,this.Sn=null}get colorStops(){return this.Nn}set colorStops(t){this.f&&Util.F(this,t),Debug&&Util.s(t,GMap,Brush,"colorStops"),this.Nn=t,this.Sn=null}get pattern(){return this.sp}set pattern(t){this.f&&Util.F(this,t),this.sp=t,this.Sn=null}static randomColor(t,i){t===void 0&&(t=128),Debug&&(Util.r(t,Brush,"randomColor:min"),(t<0||t>255)&&Util.G(t,"0 <= min <= 255",Brush,"randomColor:min")),i===void 0&&(i=Math.max(t,255)),Debug&&(Util.r(i,Brush,"randomColor:max"),(i255)&&Util.G(i,"min <= max <= 255",Brush,"randomColor:max"));const e=Math.abs(i-t);let s=Math.floor(t+Math.random()*e).toString(16),n=Math.floor(t+Math.random()*e).toString(16),o=Math.floor(t+Math.random()*e).toString(16);return s.length<2&&(s="0"+s),n.length<2&&(n="0"+n),o.length<2&&(o="0"+o),"#"+s+n+o}static isValidColor(t){return root.CSS?root.CSS.supports("color",t):!0}static lighten(t){return Brush.lightenBy(t)}lightenBy(t,i){this.f&&Util.F(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Eo(this.color),this.color=Brush.gd(e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Eo(n.value),this.addColorStop(n.key,Brush.gd(e,s))}return this}static lightenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Eo(t),Brush.gd(s,n)}static darken(t){return Brush.darkenBy(t)}darkenBy(t,i){this.f&&Util.F(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Eo(this.color),this.color=Brush.gd(-e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Eo(n.value),this.addColorStop(n.key,Brush.gd(-e,s))}return this}static darkenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Eo(t),Brush.gd(-s,n)}static mix(t,i,e){Brush.Eo(t);const s=Brush.W.n0,n=Brush.W.n1,o=Brush.W.n2,r=Brush.W.n3;Brush.Eo(i),e===void 0&&(e=.5);const l=Math.round((Brush.W.n0-s)*e+s),h=Math.round((Brush.W.n1-n)*e+n),a=Math.round((Brush.W.n2-o)*e+o),f=Math.round((Brush.W.n3-r)*e+r);return`rgba(${l}, ${h}, ${a}, ${f})`}isDark(){if(this.type===1)return Brush.isDark(this.color);if((this.type===2||this.type===3)&&this.colorStops!==null){const t=this.colorStops;if(this.type===3)return Brush.isDark(t.first().value);if(t.get(.5)!==null)return Brush.isDark(t.get(.5));if(t.count===2){const l=t.toArray();return Brush.isDark(Brush.mix(l[0].value,l[1].value))}const i=t.iterator;let e=-1,s=-1,n=1,o=1;for(;i.next();){const l=i.key,h=Math.abs(.5-i.key);n>o&&h=n&&hs){let l=e;e=s,s=l,l=n,n=o,o=l}const r=s-e;return Brush.isDark(Brush.mix(t.get(e),t.get(s),1-o/r))}return!1}static isDark(t){return t?t instanceof Brush?t.isDark():(Brush.Eo(t),(299*Brush.W.n0+587*Brush.W.n1+114*Brush.W.n2)/1e3<128):!1}static gd(t,i){switch(i){case 1:return Brush.WR(),Brush.lo.n0=Math.min(100,Math.max(0,Brush.lo.n0+100*t)),Brush.vR(),"rgba("+Brush.W.n0+", "+Brush.W.n1+", "+Brush.W.n2+", "+Brush.W.n3+")";case 2:return Brush.UM(),Brush.Yi.n2=Math.min(100,Math.max(0,Brush.Yi.n2+100*t)),"hsla("+Brush.Yi.n0+", "+Brush.Yi.n1+"%, "+Brush.Yi.n2+"%, "+Brush.Yi.n3+")";case 3:return Brush.JR(),Brush.ho.n0=Math.min(100,Math.max(0,Brush.ho.n0+100*t)),Brush.ZR(),"rgba("+Brush.W.n0+", "+Brush.W.n1+", "+Brush.W.n2+", "+Brush.W.n3+")";default:Util.n("Unknown color space: "+i)}}static Eo(t){const i=Brush.rl;if(i===null)return;i.clearRect(0,0,1,1),i.fillStyle="#000000";const e=i.fillStyle;if(i.fillStyle=t,i.fillStyle!==e){i.fillRect(0,0,1,1);const s=i.getImageData(0,0,1,1).data;Brush.W.n0=s[0],Brush.W.n1=s[1],Brush.W.n2=s[2],Brush.W.n3=s[3]/255}else{i.fillStyle="#FFFFFF";const s=i.fillStyle;i.fillStyle=t,i.fillStyle===s&&Debug&&Util.n('Color "'+t+'" is not a valid color string for RGBA color conversion'),Brush.W.n0=0,Brush.W.n1=0,Brush.W.n2=0,Brush.W.n3=1}}static UM(){const t=Brush.W.n0/255,i=Brush.W.n1/255,e=Brush.W.n2/255,s=Math.max(t,i,e),n=Math.min(t,i,e),o=s-n;let r,l;const h=(s+n)/2;if(o===0)r=l=0;else{switch(s){case t:r=(i-e)/o%6;break;case i:r=(e-t)/o+2;break;case e:r=(t-i)/o+4;break}r*=60,r<0&&(r+=360),l=o/(1-Math.abs(2*h-1))}Brush.Yi.n0=Math.round(r),Brush.Yi.n1=Math.round(l*100),Brush.Yi.n2=Math.round(h*100),Brush.Yi.n3=Brush.W.n3}static mE(){const t=Brush.Yi.n0,i=Brush.Yi.n1/100,e=Brush.Yi.n2/100;let s,n,o;const r=(1-Math.abs(2*e-1))*i,l=t/60,h=r*(1-Math.abs(l%2-1));l>=0&&l<1?(s=r,n=h,o=0):l>=1&&l<2?(s=h,n=r,o=0):l>=2&&l<3?(s=0,n=r,o=h):l>=3&&l<4?(s=0,n=h,o=r):l>=4&&l<5?(s=h,n=0,o=r):l>=5&&l<6&&(s=r,n=0,o=h);const a=e-.5*r;s+=a,n+=a,o+=a,Brush.W.n0=Math.round(s*255),Brush.W.n1=Math.round(n*255),Brush.W.n2=Math.round(o*255),Brush.W.n3=Brush.Yi.n3}static WR(){Brush.bL(),Brush.$R()}static vR(){Brush.QR(),Brush.kL()}static T2(t){return t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}static D2(t){return t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055}static bL(){const t=Brush.T2(Brush.W.n0),i=Brush.T2(Brush.W.n1),e=Brush.T2(Brush.W.n2);Brush.zt.n0=.4124564*t+.3575761*i+.1804375*e,Brush.zt.n1=.2126729*t+.7151522*i+.072175*e,Brush.zt.n2=.0193339*t+.119192*i+.9503041*e,Brush.zt.n3=Brush.W.n3}static kL(){const t=3.2404542*Brush.zt.n0+-1.5371385*Brush.zt.n1+-.4985314*Brush.zt.n2,i=-.969266*Brush.zt.n0+1.8760108*Brush.zt.n1+.041556*Brush.zt.n2,e=.0556434*Brush.zt.n0+-.2040259*Brush.zt.n1+1.0572252*Brush.zt.n2;Brush.W.n0=Brush.D2(t)*255,Brush.W.n1=Brush.D2(i)*255,Brush.W.n2=Brush.D2(e)*255,Brush.W.n3=Brush.zt.n3,Brush.W.n0=Math.round(Brush.W.n0),Brush.W.n0>255?Brush.W.n0=255:Brush.W.n0<0&&(Brush.W.n0=0),Brush.W.n1=Math.round(Brush.W.n1),Brush.W.n1>255?Brush.W.n1=255:Brush.W.n1<0&&(Brush.W.n1=0),Brush.W.n2=Math.round(Brush.W.n2),Brush.W.n2>255?Brush.W.n2=255:Brush.W.n2<0&&(Brush.W.n2=0)}static F2=216/24389;static ib=24389/27;static md=[95.047,100,108.883];static R2(t){return t>Brush.F2?Math.pow(t,1/3):(Brush.ib*t+16)/116}static $R(){const t=Brush.R2(Brush.zt.n0*100/Brush.md[0]),i=Brush.R2(Brush.zt.n1*100/Brush.md[1]),e=Brush.R2(Brush.zt.n2*100/Brush.md[2]);Brush.lo.n0=116*i-16,Brush.lo.n1=500*(t-i),Brush.lo.n2=200*(i-e),Brush.lo.n3=Brush.zt.n3}static SL(t){const i=t*t*t;return i>Brush.F2?i:(116*t-16)/Brush.ib}static QR(){const t=(Brush.lo.n0+16)/116,i=Brush.lo.n1/500+t,e=t-Brush.lo.n2/200;Brush.zt.n0=Brush.md[0]/100*Brush.SL(i),Brush.zt.n1=Brush.md[1]/100*(Brush.lo.n0>Brush.ib*Brush.F2?Math.pow(t,3):Brush.lo.n0/Brush.ib),Brush.zt.n2=Brush.md[2]/100*Brush.SL(e),Brush.zt.n3=Brush.lo.n3}static _R(){let t=.8190224*Brush.zt.n0+.3619062*Brush.zt.n1+-.1288737*Brush.zt.n2,i=.03298366*Brush.zt.n0+.9292868*Brush.zt.n1+.03614466*Brush.zt.n2,e=.04817719*Brush.zt.n0+.2642395*Brush.zt.n1+.6335478*Brush.zt.n2;t=Math.cbrt(t),i=Math.cbrt(i),e=Math.cbrt(e),Brush.gi.n0=.2104542*t+.7936177*i+-.004072046*e,Brush.gi.n1=1.977998*t+-2.428592*i+.4505937*e,Brush.gi.n2=.02590403*t+.7827717*i+-.8086757*e,Brush.gi.n3=Brush.zt.n3,Brush.gi.n0*=100}static tI(){Brush.gi.n0/=100;let t=.9999999*Brush.gi.n0+.3963377*Brush.gi.n1+.2158037*Brush.gi.n2,i=1.000000009*Brush.gi.n0+-.1055613*Brush.gi.n1+-.06385417*Brush.gi.n2,e=1.00000005*Brush.gi.n0+-.08948418*Brush.gi.n1+-1.291485*Brush.gi.n2;t=t**3,i=i**3,e=e**3,Brush.zt.n0=1.2268798*t+-.5578149*i+.281391*e,Brush.zt.n1=-.04057576*t+1.112286*i+-.07171106*e,Brush.zt.n2=-.07637294*t+-.4214933*i+1.586924*e,Brush.zt.n3=Brush.gi.n3}static iI(){const t=Math.atan2(Brush.gi.n2,Brush.gi.n1)*180/Math.PI;Brush.ho.n0=Brush.gi.n0,Brush.ho.n1=Math.sqrt(Brush.gi.n1**2+Brush.gi.n2**2),Brush.ho.n2=t>=0?t:t+360,Brush.ho.n3=Brush.gi.n3}static eI(){Brush.gi.n0=Brush.ho.n0,Brush.gi.n1=Brush.ho.n1*Math.cos(Brush.ho.n2*Math.PI/180),Brush.gi.n2=Brush.ho.n1*Math.sin(Brush.ho.n2*Math.PI/180),Brush.gi.n3=Brush.ho.n3}static JR(){Brush.bL(),Brush._R(),Brush.iI()}static ZR(){Brush.eI(),Brush.tI(),Brush.kL()}static ud(t,i){typeof t=="string"?Debug&&!Brush.isValidColor(t)&&Util.n('Color "'+t+'" is not a valid color string for '+i):t instanceof Brush||Util.n("Value for "+i+" must be a color string or a Brush, not "+t)}static Solid=1;static Linear=2;static Radial=3;static Pattern=4;static Lab=1;static HSL=2;static rl=Diagram.isUsingDOM()?new CanvasSurface(null,void 0,{willReadFrequently:!0}).di:null;static W=new ColorNumbers;static Yi=new ColorNumbers;static zt=new ColorNumbers;static lo=new ColorNumbers;static gi=new ColorNumbers;static ho=new ColorNumbers}class PanelLayout{Tt="Base";static Layouts=new GMap;static definePanelLayout(t,i){i.name=t,PanelLayout.Layouts.set(t,i)}get name(){return this.Tt}set name(t){this.Tt=t}constructor(){}get classType(){return Panel}measure(t,i,e,s,n,o,r){}measureElement(t,i,e,s,n){t.wt(i,e,s,n)}arrange(t,i,e){}arrangeElement(t,i,e,s,n,o){t.qt(i,e,s,n,o)}remeasureObject(t){t.rc()}Ji(t,i,e){}}class PanelLayoutPosition extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=s.length,h=t.Wo();for(let a=0;a0&&(P=Math.max(Math.abs(k.x*o+k.offsetX-(M.x*o+M.offsetX))-g,0)),r>0&&(N=Math.max(Math.abs(k.y*r+k.offsetY-(M.y*r+M.offsetY))-g,0));const T=Size.a();T.e(0,0);const L=t.Wo();for(let I=0;I1,ot=it.columnSpan>1;(ft||ot)&&!(Uy&&(P=Math.max(y-gt,0)),b.Zi=b.Zi+P,b.actual=b.ht+P,y=Math.max(y-(P+(mt?gt:0)),0)}if(it.columnSpan===1&&(N===0||N===4)){b=t.getColumnDefinition(H);const gt=b.computeEffectiveSpacing(),mt=b.ht===0;P=Math.max(ut-b.actual,0),P+(mt?gt:0)>p&&(P=Math.max(p-gt,0)),b.Zi=b.Zi+P,b.actual=b.ht+P,p=Math.max(p-(P+(mt?gt:0)),0)}(ft||ot)&&it.rc()}}}Util.nt(c);let L=0,D=0;l=t.columnCount;for(let U=0;U=t.rowCount);$++)b=t.getRowDefinition(E.row+$),P=0,N===2||N===4?P=Math.max(b.minimum,X[E.row+$]===0?b.maximum:Math.min(X[E.row+$],b.maximum)):P=Math.max(b.minimum,isNaN(b.we)?b.maximum:Math.min(b.we,b.maximum)),V.height+=P,_+=b.minimum;for(let $=1;$=t.columnCount);$++)b=t.getColumnDefinition(E.column+$),P=0,N===2||N===5?P=Math.max(b.minimum,z[E.column+$]===0?b.maximum:Math.min(z[E.column+$],b.maximum)):P=Math.max(b.minimum,isNaN(b.we)?b.maximum:Math.min(b.we,b.maximum)),V.width+=P,et+=b.minimum;K.width+=V.width,K.height+=V.height;const tt=E.margin,it=tt.right+tt.left,ft=tt.top+tt.bottom;E.wt(K.width,K.height,et,_);const ot=E.measuredBounds,lt=Math.max(ot.width+it,0),st=Math.max(ot.height+ft,0);let nt=0;for(let $=0;$=t.rowCount);$++)b=t.getRowDefinition(E.row+$),nt+=b.total||0;if(nt=t.rowCount);at++){b=t.getRowDefinition(E.row+at);const ut=b.ht||0,dt=rt(E,b,ct);Debug&&typeof dt!="number"&&Util.n(E+" spanAllocation does not return a number: "+dt),b.actual=Math.min(b.maximum,ut+dt),b.ht!==ut&&($-=b.ht-ut)}}for(;$>0;){const rt=b.ht||0;if(isNaN(b.height)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+$),b.ht!==rt&&($-=b.ht-rt)),b.index===0)break;b=t.getRowDefinition(b.index-1)}}let ht=0;for(let $=0;$=t.columnCount);$++)b=t.getColumnDefinition(E.column+$),ht+=b.total||0;if(ht=t.columnCount);at++){b=t.getColumnDefinition(E.column+at);const ut=b.ht||0,dt=rt(E,b,ct);Debug&&typeof dt!="number"&&Util.n(E+" spanAllocation does not return a number: "+dt),b.actual=Math.min(b.maximum,ut+dt),b.ht!==ut&&($-=b.ht-ut)}}for(;$>0;){const rt=b.ht||0;if(isNaN(b.width)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+$),b.ht!==rt&&($-=b.ht-rt)),b.index===0)break;b=t.getColumnDefinition(b.index-1)}}}Util.nt(u),Size.o(V),Size.o(K),X!==void 0&&Util.nt(X),z!==void 0&&Util.nt(z);let G=0,q=0;const j=t.desiredSize,J=t.maxSize;N=t.qs(!0),L=0,D=0;let Y=0,v=0;l=t.columnCount;for(let U=0;U0){for(;p!==f&&(u[p]===void 0||u[p].ht===0);)p++;p=Math.max(Math.min(p,f-1),0),m=-u[p].position}let y=Math.min(t.leftIndex,c-1);if(d.length>0){for(;y!==c&&(d[y]===void 0||d[y].ht===0);)y++;y=Math.max(Math.min(y,c-1),0),g=-d[y].position}let x=0,k=0;for(;x!==f&&u[x]===void 0;)x++;for(;k!==f&&d[k]===void 0;)k++;const b=t.part;let S=t.getRowDefinition(x),M=t.getColumnDefinition(k);for(let C=0;C=t.rowCount);st++){const nt=t.getRowDefinition(C+st);nt.ht!==0&&(A.height+=nt.total)}for(let st=1;st=t.columnCount);st++){const nt=t.getColumnDefinition(N+st);nt.ht!==0&&(A.width+=nt.total)}const O=T.ht+A.width,B=P.ht+A.height;let K=h,V=a;const X=O,z=B,G=h,q=a;let j=O,J=B;h+O>e.width&&(j=Math.max(e.width-h,0)),a+B>e.height&&(J=Math.max(e.height-a,0));let Y=R.alignment,v=0,W=0,Q=0,U=0;if(Y.isDefault()){Y=t.defaultAlignment,Y.isSpot()||(Y=Spot.Center),v=Y.x,W=Y.y,Q=Y.offsetX,U=Y.offsetY;const st=T.alignment,nt=P.alignment;st.isSpot()&&(v=st.x,Q=st.offsetX),nt.isSpot()&&(W=nt.y,U=nt.offsetY)}else v=Y.x,W=Y.y,Q=Y.offsetX,U=Y.offsetY;(isNaN(v)||isNaN(W))&&(v=.5,W=.5,Q=0,U=0);let E=I.width,H=I.height;const Z=R.margin,et=Z.left+Z.right,_=Z.top+Z.bottom,tt=R.F0(P,T,!1);isNaN(R.desiredSize.width)&&(tt===2||tt===5)&&(E=Math.max(O-et,0)),isNaN(R.desiredSize.height)&&(tt===2||tt===4)&&(H=Math.max(B-_,0));const it=R.maxSize,ft=R.minSize;E=Math.min(it.width,E),H=Math.min(it.height,H),E=Math.max(ft.width,E),H=Math.max(ft.height,H);const ot=E+et,lt=H+_;K+=X*v-ot*v+Q+Z.left,V+=z*W-lt*W+U+Z.top,R.visible&&(Rect.contains(G,q,j,J,K,V,I.width,I.height)?R.qt(K,V,E,H):R.qt(K,V,E,H,new Rect(G,q,j,J)))}}}Size.o(A);for(let C=0;C0&&(b.figure==="LineV"||b.figure==="LineH")){if(i.lineWidth=b.strokeWidth,t.wn(i,b.stroke,!1,!1,l,h),i.beginPath(),b.figure==="LineV"){const D=Math.floor((m-o)/o);for(let F=D;F<=D+c;F++){const R=F*o+m;0<=R&&R<=a&&this.sb(F,S,A,N)&&(i.moveTo(R,0),i.lineTo(R,f))}}else if(b.figure==="LineH"){const D=Math.floor((g-r)/r);for(let F=D;F<=D+u;F++){const R=F*r+g;0<=R&&R<=f&&this.sb(F,S,A,N)&&(i.moveTo(0,R),i.lineTo(a,R))}}i.stroke(),i.endPath()}else if(b.fill!==null){if(t.wn(i,b.fill,!0,!1,l,h),b.figure==="BarV"){let D=b.width;isNaN(D)&&(D=o);const F=Math.floor((m-o)/o);for(let R=F;R<=F+c;R++){const I=R*o+m;0<=I+D&&I<=a&&this.sb(R,S,A,N)&&i.fillRect(I,0,D,f)}}else if(b.figure==="BarH"){let D=b.height;isNaN(D)&&(D=r);const F=Math.floor((g-r)/r);for(let R=F;R<=F+u;R++){const I=R*r+g;0<=I+D&&I<=f&&this.sb(R,S,A,N)&&i.fillRect(0,I,a,D)}}}T&&i.disableDash(),C!==1&&(i.globalAlpha=P)}}sb(t,i,e,s){if(i<0)return t%i===e;if(t%i!==e)return!1;const n=s.length;for(let o=0;ol&&r.push(d)}}t.Mi.np=i}V2(t){return t==="LineV"||t==="BarV"}sI(t){let i=1,e=1;const s=t.D.h,n=s.length;for(let l=0;l=g){const Y=Point.a();f.ML(Y),O=f.midAngle,L!==0&&(I=f.computeAngle(A,L,O),A.jt=I,A.pe(!0),A.oo(!0)),F=Y.x-u.x,R=Y.y-u.y,Point.o(Y)}else{let Y,v,W=0;if(P>=0?(Y=m.elt(P),v=P0?m.elt(W-1):Y),O=0,Y.equalsApprox(v)){let Q,U;P>=0?(Q=P>0?m.elt(P-1):Y,U=P1?m.elt(W-2):v);const E=Q.distanceSquaredPoint(Y),H=v.distanceSquaredPoint(U);E>H+10?O=P>=0?Q.directionPoint(Y):Y.directionPoint(Q):H>E+10?O=P>=0?v.directionPoint(U):U.directionPoint(v):O=P>=0?Q.directionPoint(U):U.directionPoint(Q)}else O=P>=0?Y.directionPoint(v):v.directionPoint(Y);L!==0&&(I=f.computeAngle(A,L,O),A.jt=I,A.pe(!0),A.oo(!0)),F=Y.x+(v.x-Y.x)*N-u.x,R=Y.y+(v.y-Y.y)*N-u.y}A.wt(1/0,1/0,0,0),C=A.measuredBounds;const B=A.naturalBounds;let K=0;A instanceof Shape&&(K=A.strokeWidth);const V=B.width+K,X=B.height+K;k.Bi(),k.Es(-C.x,-C.y),k.lt(A.scale,A.scale),k.ms(L===0?A.angle:O,V/2,X/2),(L===22||L===26)&&k.ms(90,V/2,X/2),(L===23||L===27)&&k.ms(-90,V/2,X/2),L===28&&(O>45&&O<135||O>225&&O<315)&&k.ms(-O,V/2,X/2);const z=new Rect(0,0,V,X);b.setRectSpot(z,T),k.Pt(b);const G=-b.x+K/2*A.scale,q=-b.y+K/2*A.scale;S.c(D);const j=isNaN(D.x),J=isNaN(D.y);if(j||J){const Y=V/2+3,v=X/2+3,W=O>=45&&O<=135,Q=O>=225&&O<=315;L===0&&(W||Q)?(S.x=J?Y:D.y,S.y=j?v:D.x,W?P>=0||isNaN(P)&&N<.5||j&&(S.y=-v):Q&&((P>=0||isNaN(P)&&N<.5)&&j&&(S.y=-v),J&&(S.x=-Y))):(j&&(P>=0||isNaN(P)&&N<.5?S.x=Y:S.x=-Y),J&&(S.y=-v),S.rotate(O))}else S.rotate(O);F+=S.x,R+=S.y,z.e(F+G,R+q,C.width,C.height),x.push(z),d.unionRect(z)}if(h!==null){const M=h.labelNodes;for(;M.next();)M.value.wt(1/0,1/0)}t.vo=d,t.position.e(u.x+d.x,u.y+d.y),n.Kn(d.width||0,d.height||0),Transform.o(k),Point.o(b),Point.o(S)}arrange(t,i,e){const s=i.length;if(!(t instanceof Adornment||t instanceof Link))return;let n=t,o=null;t instanceof Adornment&&(o=t,n=o.adornedPart);const r=t,l=t instanceof Adornment?null:n.path,h=t.dc;if(h.length!==0){let u=0;if(l!==null&&u=2&&r instanceof Link){const u=r.labelNodes;for(;u.next();){const d=u.value;r.rI(d,f,a)}}o!==null?o.pd(!1):n.pd(!1);const c=t.PL(Point.a());t.location.e(t.position.x+c.x,t.position.y+c.y),Point.o(c)}measureLinkPath(t,i,e,s){if(s.Xo()===!1)return;let n=s.strokeWidth;if(n===0&&t instanceof Adornment&&t.type===Panel.Link&&t.adornedObject instanceof Shape&&(n=t.adornedObject.strokeWidth),n=n*s.lt,t instanceof Link&&t.yt!==null){const o=t.geometry.bounds;s.no(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else if(t instanceof Adornment&&t.adornedPart.yt!==null){const o=t.adornedPart.yt.bounds;s.no(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else s.no(-(n/2),-(n/2),i+n,e+n);s.lI(),s.pe(!1)}}PanelLayout.definePanelLayout("Link",new PanelLayoutLink);class PanelLayoutGraduated extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=t.findMainElement();t.Ze=[];const h=l.margin,a=h.right+h.left,f=h.top+h.bottom;l.wt(i,e,o,r);const c=l.measuredBounds,u=c.width,d=c.height,m=Math.max(u+a,0),g=Math.max(d+f,0),p=new Rect(-h.left,-h.top,m,g);t.Ze.push(p),n.c(p),this.determineGraduatedMarks(t,l);const y=t.Ms;if(y===null)return;const x=s.length;for(let k=0;k45&&c<135||c>225&&c<315)&&S.ms(-c,k/2,b/2);const M=Rect.H(0,0,k,b),A=Point.a();A.setRectSpot(M,o),S.Pt(A);const C=-A.x,P=-A.y,N=Point.a();N.c(l),isNaN(N.x)&&(N.x=k/2+3),isNaN(N.y)&&(N.y=-(b/2+3)),N.rotate(c),a+=N.x+C,f+=N.y+P;const T=new Rect(a,f,y.width,y.height),L=new Rect(y.x,y.y,y.width,y.height),D=new Rect(x.x,x.y,x.width,x.height);p.labelAngle=u,p.lineCount=n.lineCount,p.lines=n.getMetrics(),p.actualBounds=T,p.measuredBounds=L,p.naturalBounds=D,g===0?h.c(T):h.unionRect(T),Point.o(N),Point.o(A),Rect.o(M),Transform.o(S)}t.Ze!==null&&t.Ze.push(h),s.unionNoCheck(h.x,h.y,h.width,h.height)}determineGraduatedMarks(t,i){const e=i.geometry,s=i.strokeWidth,n=e.flattenedSegments,o=e.flattenedLengths,r=e.flattenedTotalLength,l=n.length;let h=0,a=0;const f=Util.ft();for(let x=0;xt.graduatedMin+P){const F=Math.floor((N-t.graduatedMin)/P);N-=F*P}const T=c[x],L=N,D=t.graduatedMax*1e-6;for(let F=1;N<=t.graduatedMax+D;F++){if(this.aI(t,N-t.graduatedTickBase,T)&&(N>t.graduatedMax&&(N=t.graduatedMax),(k.graduatedSkip===null||k instanceof TextBlock&&!k.graduatedSkip(N,k)||k instanceof Shape&&!k.graduatedSkip(N,k))&&(m=(N-t.graduatedMin)*r/t.graduatedRange,m>r&&(m=r),g<=m&&m<=p))){let R=f[A][C],I=o[A][C];for(;AM&&C.4995)return t;let o=t;if(i<.5?n>0?o=s[n-1]:Geo.q(e[0],e[e.length-2])&&Geo.q(e[1],e[e.length-1])&&(o=s[s.length-1]):i>.5&&(n+1180&&(t.9995)return(t+o)/2%360;if(r<10){const l=1-Math.abs(.5-i);return(t*l+o*(1-l))%360}}return t}hI(t){if(t.as===null){const i=[],e=t.D.h,s=e.length;for(let n=0;nl&&r.push(f)}}t.as=i}return t.as}aI(t,i,e){const s=e.length;for(let n=0;n-l)return!1}return!0}Ji(t,i,e){const s=e.ia;e.ia=!0;const n=t.naturalBounds,o=n.width,r=n.height,l=i instanceof SVGContext;i.save(),i.beginPath(),i.rect(-1,-1,o+1,r+1),i.clip(),i.endPath();const h=t.findMainElement();h.Ji(i,e);let a=t.getDocumentScale()*e.scale;a<=0&&(a=1);const f=h.actualBounds,c=t.D.h,u=t.Ms,d=c.length;for(let m=0;m(w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ViewboxStretch||{});class Panel extends GraphObject{st;D;ii;yd;vn;ll;ao;vo;z2;B;wd;dt;Mi;si;xd;wh;vs;constructor(t,i){if(super(),this.st=null,t===void 0)this.st=Panel.Position;else if(typeof t=="string"){const e=PanelLayout.Layouts.get(t);e!==null&&(this.st=e)}else t instanceof PanelLayout?this.st=t:t&&(this.st=Panel.Position,i=t);this.st===null&&Util.n("Panel type not specified or PanelLayout not loaded: "+t),this.l|=4194304|(this.st===Panel.Grid?1048576:0),this.D=new List,this.ii=Margin.qg,this.yd=Spot.Default,this.vn=1,this.ll=null,this.ao="",this.vo=new Rect(NaN,NaN,NaN,NaN),this.z2=null,this.B=null,this.wd=6,this.Mi=null,this.dt=null,this.si=null,this.xd=NaN,this.wh=null,this.vs=null,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.st=this.st,t.ii=this.ii.L(),t.yd=this.yd.L(),t.vn=this.vn,t.ao=this.ao,t.vo.c(this.vo),this.B!==null&&(t.B=this.B.copy(t)),t.wd=this.wd,this.dt!==null&&(t.dt=this.dt.copy()),this.Mi!==null&&(t.Mi=this.Mi.copy()),t.si=this.si,t.xd=this.xd,t.wh=this.wh}Ho(t){super.Ho(t),t.D=this.D;const i=t.D.h,e=i.length;for(let s=0;s= 0",Panel,"padding"),t=new Margin(t)):(Util.s(t,Margin,Panel,"padding"),t.left<0&&Util.G(t.left,">= 0",Panel,"padding:value.left"),t.right<0&&Util.G(t.right,">= 0",Panel,"padding:value.right"),t.top<0&&Util.G(t.top,">= 0",Panel,"padding:value.top"),t.bottom<0&&Util.G(t.bottom,">= 0",Panel,"padding:value.bottom"));const i=this.ii;i.equals(t)||(t=t.L(),this.ii=t,this.u(),this.i("padding",i,t))}get defaultAlignment(){return this.yd}set defaultAlignment(t){const i=this.yd;i.equals(t)||(Debug&&Util.s(t,Spot,Panel,"defaultAlignment"),t=t.L(),this.yd=t,this.u(),this.i("defaultAlignment",i,t))}get defaultStretch(){return this.vn}set defaultStretch(t){const i=this.vn;i!==t&&(this.vn=t,this.u(),this.i("defaultStretch",i,t))}get defaultSeparatorPadding(){return this.B!==null?this.B.op:Margin.qg}set defaultSeparatorPadding(t){typeof t=="number"?t=new Margin(t):Debug&&Util.s(t,Margin,Panel,"defaultSeparatorPadding");const i=this.defaultSeparatorPadding;i.equals(t)||(t=t.L(),this.B===null&&(this.B=new TablePanelSettings),this.B.op=t,this.u(),this.i("defaultSeparatorPadding",i,t))}get defaultRowSeparatorStroke(){return this.B!==null?this.B.rp:null}set defaultRowSeparatorStroke(t){const i=this.defaultRowSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.w(),this.B===null&&(this.B=new TablePanelSettings),this.B.rp=t,this.T(),this.i("defaultRowSeparatorStroke",i,t))}get defaultRowSeparatorStrokeWidth(){return this.B!==null?this.B.lp:1}set defaultRowSeparatorStrokeWidth(t){const i=this.defaultRowSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.B===null&&(this.B=new TablePanelSettings),this.B.lp=t,this.u(),this.i("defaultRowSeparatorStrokeWidth",i,t))}get defaultRowSeparatorDashArray(){return this.B!==null?this.B.hp:null}set defaultRowSeparatorDashArray(t){const i=this.defaultRowSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Vi(t,"Array",Panel,"defaultRowSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("defaultRowSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.B===null&&(this.B=new TablePanelSettings),this.B.hp=t,this.T(),this.i("defaultRowSeparatorDashArray",i,t)}}get defaultColumnSeparatorStroke(){return this.B!==null?this.B.ap:null}set defaultColumnSeparatorStroke(t){const i=this.defaultColumnSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.w(),this.B===null&&(this.B=new TablePanelSettings),this.B.ap=t,this.T(),this.i("defaultColumnSeparatorStroke",i,t))}get defaultColumnSeparatorStrokeWidth(){return this.B!==null?this.B.fp:1}set defaultColumnSeparatorStrokeWidth(t){const i=this.defaultColumnSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.B===null&&(this.B=new TablePanelSettings),this.B.fp=t,this.u(),this.i("defaultColumnSeparatorStrokeWidth",i,t))}get defaultColumnSeparatorDashArray(){return this.B!==null?this.B.cp:null}set defaultColumnSeparatorDashArray(t){const i=this.defaultColumnSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Vi(t,"Array",Panel,"defaultColumnSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("defaultColumnSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.B===null&&(this.B=new TablePanelSettings),this.B.cp=t,this.T(),this.i("defaultColumnSeparatorDashArray",i,t)}}get yh(){return this.B!==null?this.B.yh:null}set yh(t){this.B===null&&(this.B=new TablePanelSettings),this.B.yh=t}get viewboxStretch(){return this.wd}set viewboxStretch(t){const i=this.wd;i!==t&&(this.wd=t,this.u(),this.i("viewboxStretch",i,t))}get gridCellSize(){return this.Mi!==null?this.Mi.bd:Size.fC}set gridCellSize(t){this.Mi===null&&(this.Mi=new GridPanelSettings);const i=this.Mi.bd;if(!i.equals(t)){(!t.isReal()||t.width===0||t.height===0)&&Util.n("Invalid Panel.gridCellSize: "+t),this.Mi.bd=t.L();const e=this.diagram;e!==null&&this===e.grid&&e.Zr(),this.T(),this.i("gridCellSize",i,t)}}get gridOrigin(){return this.Mi!==null?this.Mi.kd:Point.Lo}set gridOrigin(t){this.Mi===null&&(this.Mi=new GridPanelSettings);const i=this.Mi.kd;if(!i.equals(t)){t.isReal()||Util.n("Invalid Panel.gridOrigin: "+t),this.Mi.kd=t.L();const e=this.diagram;e!==null&&this===e.grid&&e.Zr(),this.T(),this.i("gridOrigin",i,t)}}get graduatedMin(){return this.dt!==null?this.dt.dp:0}set graduatedMin(t){Util.r(t,Panel,"graduatedMin");const i=this.graduatedMin;if(i!==t&&(this.dt===null&&(this.dt=new GradPanelSettings),this.dt.dp=t,this.u(),this.i("graduatedMin",i,t),this.ec())){const e=this.part;e!==null&&this.ka(e,"graduatedRange")}}get graduatedMax(){return this.dt!==null?this.dt.gp:100}set graduatedMax(t){Util.r(t,Panel,"graduatedMax");const i=this.graduatedMax;if(i!==t&&(this.dt===null&&(this.dt=new GradPanelSettings),this.dt.gp=t,this.u(),this.i("graduatedMax",i,t),this.ec())){const e=this.part;e!==null&&this.ka(e,"graduatedRange")}}get graduatedRange(){return this.graduatedMax-this.graduatedMin}get graduatedTickUnit(){return this.dt!==null?this.dt.mp:10}set graduatedTickUnit(t){Util.r(t,Panel,"graduatedTickUnit");const i=this.graduatedTickUnit;i!==t&&t>0&&(this.dt===null&&(this.dt=new GradPanelSettings),this.dt.mp=t,this.u(),this.i("graduatedTickUnit",i,t))}get graduatedTickBase(){return this.dt!==null?this.dt.pp:0}set graduatedTickBase(t){Util.r(t,Panel,"graduatedTickBase");const i=this.graduatedTickBase;i!==t&&(this.dt===null&&(this.dt=new GradPanelSettings),this.dt.pp=t,this.u(),this.i("graduatedTickBase",i,t))}get Ms(){return this.dt!==null?this.dt.Ms:null}set Ms(t){this.dt!==null?this.dt.Ms=t:t!==null&&(this.dt=new GradPanelSettings,this.dt.Ms=t)}get Ze(){return this.dt!==null?this.dt.Ze:null}set Ze(t){this.dt!==null?this.dt.Ze=t:t!==null&&(this.dt=new GradPanelSettings,this.dt.Ze=t)}get as(){return this.dt!==null?this.dt.as:null}set as(t){this.dt!==null?this.dt.as=t:t!==null&&(this.dt=new GradPanelSettings,this.dt.as=t)}get Le(){return this.dt!==null?this.dt.Le:null}set Le(t){this.dt!==null?this.dt.Le=t:t!==null&&(this.dt=new GradPanelSettings,this.dt.Le=t)}A0(t){super.A0(t);const i=this.D.h,e=i.length;for(let s=0;s0?this.ve:null,s=this.columnCount>0?this.Je:null;e!==null&&this.nb(t,i,!0,e,!0),s!==null&&this.nb(t,i,!1,s,!0),e!==null&&this.CL(t,!0,e),s!==null&&this.CL(t,!1,s),e!==null&&this.nb(t,i,!0,e,!1),s!==null&&this.nb(t,i,!1,s,!1)}CL(t,i,e){const s=e.length,n=this.actualBounds,o=this.naturalBounds;let r=!0;for(let l=0;lo.height)continue}else if(h.position>o.width)continue;let a=h.separatorStrokeWidth;isNaN(a)&&(a=i?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let f=h.separatorStroke;if(f===null&&(f=i?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),a===0||f===null)continue;this.wn(t,f,!1,!1,o,n);let c=!1,u=h.separatorDashArray;u===null&&(u=i?this.defaultRowSeparatorDashArray:this.defaultColumnSeparatorDashArray),u!==null&&(c=!0,t.enableDash(u,0)),t.beginPath();const d=h.position+a;i?d>o.height&&(a-=d-o.height):d>o.width&&(a-=d-o.width);let m=h.position+a/2;t.lineWidth=a;const g=this.ii;if(i){m+=g.top;const p=g.left,y=o.width-g.right;t.moveTo(p,m),t.lineTo(y,m)}else{m+=g.left;const p=g.top,y=o.height-g.bottom;t.moveTo(m,p),t.lineTo(m,y)}t.stroke(),t.endPath(),c&&t.disableDash()}}nb(t,i,e,s,n){const o=s.length,r=this.actualBounds,l=this.naturalBounds,h=this.AL(!0),a=this.AL(!1);for(let f=0;fu)continue;let d=c.computeEffectiveSpacing(),m=c.separatorStrokeWidth;isNaN(m)&&(m=e?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let g=c.separatorStroke;g===null&&(g=e?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),(g===null||c.index===(e?h:a))&&(m=0),d-=m;const p=c.position+m;let y=d+c.actual;if(p+y>u&&(y=u-p),y<=0)continue;const x=this.ii;this.wn(t,c.background,!0,!1,l,r),e?t.fillRect(x.left,p+x.top,r.width-(x.left+x.right),y):t.fillRect(p+x.left,x.top,y,r.height-(x.top+x.bottom))}}AL(t){const i=t?this.rowCount:this.columnCount;for(let e=0;ex&&n.set(P),Point.o(P)),Point.o(M),o&&n.O(r),k}}zu(){const t=this.D.h,i=t.length;for(let e=0;ee||h>s)&&(this.u(),this.wt(l>e?e:l,h>s?s:h,0,0));break;case 2:this.u(!0),this.wt(e+f,s+c,0,0);break;case 5:this.u(!0),this.wt(e+f,h+c,0,0);break;case 4:this.u(!0),this.wt(l+f,s+c,0,0);break}}this.st.arrange(this,n,this.vo)}ch(t){const i=this.naturalBounds,e=this.Wo();if(Rect.contains(0,0,i.width,i.height,t.x,t.y)){const s=this.D.h,n=s.length,o=Point.H(0,0);for(let r=n;r--;){const l=s[r];if(!(!l.visible&&l!==e)&&(o.set(t).Ye(l.O),l.containsPoint(o)))return Point.o(o),!0}return Point.o(o),this.Ft!==null}return!1}M0(t){if(this.eo===t)return this;const i=this.D.h,e=i.length;for(let s=0;sd.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;let m=c;const g=c instanceof Panel?c:null,p=Transform.a();p.set(r),(g!==null?g.Km(t,i,e,s,n,p):m.lL(t,s,p))&&(i!==null&&(m=i(m)),m!==null&&(e===null||e(m))&&n.add(m)),Transform.o(p)}}return o===void 0&&Transform.o(r),s}return o===void 0&&Transform.o(r),!1}Y2(t,i,e){const s=this.D.h,n=s.length;for(let o=n;o--;){const r=s[o];if(!r.visible)continue;const l=r.actualBounds,h=this.naturalBounds;if(l.x>h.width||l.y>h.height||l.x+l.width<0||l.y+l.height<0)continue;r instanceof Panel&&r.Y2(t,i,e);let a=r;t!==null&&(a=t(a)),a!==null&&(i===null||i(a))&&e.add(a)}}fA(t,i,e,s,n,o){if(this.pickable===!1)return!1;e===void 0&&(e=null),s===void 0&&(s=null);const r=this.naturalBounds,l=this.kn(),h=l?t:Point.H(t.x,t.y).Ye(this.O),a=l?i:Point.H(i.x,i.y).Ye(this.O),f=h.distanceSquaredPoint(a),c=h.x>0&&h.x0&&h.yS.width||b.y>S.height||b.x+b.width<0||b.y+b.height<0))continue;if(k.kn()){const C=k.O;d.set(t).Ye(C),m.set(i).Ye(C)}else d.set(t),m.set(i);let M=k;const A=k instanceof Panel?k:null;(A!==null?A.fA(d,m,e,s,n,o):M.hL(d,m,n))&&(e!==null&&(M=e(M)),M!==null&&(s===null||s(M))&&o.add(M))}Point.o(d),Point.o(m)}return n?c:u}return!1}O2(t){let i=null;if(t instanceof Shape){i=t.spot1,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot1)}return i===null&&(i=Spot.TopLeft),i}E2(t){let i=null;if(t instanceof Shape){i=t.spot2,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot2)}return i===null&&(i=Spot.BottomRight),i}add(...t){for(let i=0;i=s.count&&t>=s.count)return;s.removeAt(r),n=r}else Util.n("element "+i.toString()+" has panel "+e.toString()+" but is not contained by it.")}(t<0||t>s.count)&&(t=s.count),s.insertAt(t,i),(t===0||i.isPanelMain)&&(this.ll=null),this.Xo()||this.u(),i.u(!1),i.portId!==null?this.Mn=!0:i instanceof Panel&&i.Mn===!0&&(this.Mn=!0),this.as=null,this.isEnabledObject()||this.ob(i,!1);const o=this.part;if(o!==null){o.V0(),o.mc(),this.Mn&&o instanceof Node&&(o.Mn=!0),o.Mn&&o instanceof Node&&(o.he=null);const r=this.diagram;if(r!==null&&r.undoManager.isUndoingRedoing)return;n!==-1&&o.raiseChangedEvent(4,"elements",this,i,null,n,null),o.raiseChangedEvent(3,"elements",this,null,i,null,t)}}get Mn(){return(this.l&8388608)!==0}set Mn(t){(this.l&8388608)!==0!==t&&(this.l=this.l^8388608)}d2(){return(this.l&16777216)!==0}K2(t){t?this.l|=16777216:this.l&=-16777217}mI(t){t.Ma(this),t.sl=null;const i=this.D,e=i.count;i.insertAt(e,t);const s=this.part;if(s!==null){s.V0(),t.portId!==null&&s instanceof Node&&(s.Mn=!0);const n=this.diagram;if(n!==null&&n.undoManager.isUndoingRedoing)return;s.raiseChangedEvent(3,"elements",this,null,t,null,e)}}BR(t){const i=this.D.h,e=i.length;let s=-1;for(let n=0;n=0&&this.ne(t,!0)}ne(t,i){const e=this.D,s=e.elt(t);if(s.sl=null,s.Ma(null),this.vs!==null){const o=s.data;typeof o=="object"&&this.vs.delete(o)}e.removeAt(t),this.pe(!1),this.u(),this.ll===s&&(this.ll=null),this.as=null;const n=this.part;if(n!==null){n.V0(),n.mc(),n.invalidateAdornments(),n instanceof Node&&(s instanceof Panel?s.walkVisualTreeFrom(s,(r,l)=>n.P2(l,i)):n.P2(s,i));const o=this.diagram;if(o!==null&&o.undoManager.isUndoingRedoing)return;n.raiseChangedEvent(4,"elements",this,s,null,t,null)}}get ve(){return this.B===null&&(this.B=new TablePanelSettings),this.B.ve}get rowCount(){return this.B===null?0:this.ve.length}getRowDefinition(t){Debug&&Util.r(t,Panel,"getRowDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"getRowDefinition:idx"),t=Math.round(t);const i=this.ve;if(i[t]===void 0){const e=new RowColumnDefinition;e.Ma(this),e.isRow=!0,e.index=t,i[t]=e,this.raiseChangedEvent(3,"rowdefs",this,null,e,null,t)}return i[t]}removeRowDefinition(t){if(Debug&&Util.r(t,Panel,"removeRowDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"removeRowDefinition:idx"),this.rowCount===0)return;t=Math.round(t);const i=this.ve,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"rowdefs",this,e,null,t,null),this.u()}}zA(t,i){const e=this.ve;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.u()}}get Je(){return this.B===null&&(this.B=new TablePanelSettings),this.B.Je}get columnCount(){return this.B===null?0:this.Je.length}getColumnDefinition(t){Debug&&Util.r(t,Panel,"getColumnDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"getColumnDefinition:idx"),t=Math.round(t);const i=this.Je;if(i[t]===void 0){const e=new RowColumnDefinition;e.Ma(this),e.isRow=!1,e.index=t,i[t]=e,this.raiseChangedEvent(3,"coldefs",this,null,e,null,t)}return i[t]}removeColumnDefinition(t){if(Debug&&Util.r(t,Panel,"removeColumnDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"removeColumnDefinition:idx"),this.columnCount===0)return;t=Math.round(t);const i=this.Je,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"coldefs",this,e,null,t,null),this.u()}}XA(t,i){const e=this.Je;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.u()}}addRowColumnDefinition(t){let i=null;return t.isRow?i=this.getRowDefinition(t.index):t.isRow||(i=this.getColumnDefinition(t.index)),i&&i.Z1(t),this}addRowDefinition(t,i){const e=this.getRowDefinition(t);return e&&e.Z1(new RowColumnDefinition(i)),this}addColumnDefinition(t,i){const e=this.getColumnDefinition(t);return e&&e.Z1(new RowColumnDefinition(i)),this}get rowSizing(){return this.B!==null?this.B.wp:3}set rowSizing(t){const i=this.rowSizing;i!==t&&(Debug&&t!==3&&t!==2&&Util.n("Panel.rowSizing must be ProportionalExtra or None, not: "+t),this.B===null&&(this.B=new TablePanelSettings),this.B.wp=t,this.u(),this.i("rowSizing",i,t))}get columnSizing(){return this.B!==null?this.B.xp:3}set columnSizing(t){const i=this.columnSizing;i!==t&&(Debug&&t!==3&&t!==2&&Util.n("Panel.columnSizing must be ProportionalExtra or None, not: "+t),this.B===null&&(this.B=new TablePanelSettings),this.B.xp=t,this.u(),this.i("columnSizing",i,t))}get topIndex(){return this.B!==null?this.B.bp:0}set topIndex(t){const i=this.topIndex;i!==t&&((!isFinite(t)||t<0)&&Util.n("Panel.topIndex must be greater than zero and a real number, not: "+t),this.B===null&&(this.B=new TablePanelSettings),this.B.bp=t,this.u(),this.i("topIndex",i,t))}get leftIndex(){return this.B!==null?this.B.kp:0}set leftIndex(t){const i=this.leftIndex;i!==t&&((!isFinite(t)||t<0)&&Util.n("Panel.leftIndex must be greater than zero and a real number, not: "+t),this.B===null&&(this.B=new TablePanelSettings),this.B.kp=t,this.u(),this.i("leftIndex",i,t))}findRowForLocalY(t){if(t<0||this.type!==Panel.Table||this.rowCount===0)return-1;let i=0;const e=this.ve,s=e.length;let n=this.topIndex;for(;n{o.fh();const r=o.Ri;if(r!==null){o.k2(!1);const l=r.iterator;for(;l.next();){const h=l.value;h.mode===2&&o.k2(!0);const a=h.sourceName;if(h.isToObject){a==="/"&&n.K2(!0);const f=h.rL(n,o);f!==null&&(i.add(f),f.so===null&&(f.so=new List),f.so.add(h))}t.add(h)}}if(o instanceof Panel&&o.type===Panel.Table){if(o.rowCount>0){const l=o.ve,h=l.length;for(let a=0;a0){const l=o.Je,h=l.length;for(let a=0;a0&&o instanceof Panel){const h=r.substring(0,l),a=r.substring(l+1),f=o.findObject(h);f!==null?(o=f,n.targetProperty=a):(Util.at('Warning: unable to find GraphObject named "'+h+'" for Binding: '+n.toString()),o=null)}if(o instanceof RowColumnDefinition){const h=GSet.gs(o.panel);n.targetId=h===void 0?-1:h,o.panel.eo=n.targetId}else if(o instanceof GraphObject){const h=GSet.gs(o);n.targetId=h===void 0?-1:h,o.eo=n.targetId}else Util.n("Unknown type of binding target: "+o);n.check(o)}}return t.w(),this instanceof Part&&(this.Ae()&&this.ensureBounds(),Debug&&!Panel.RL&&this.walkVisualTreeFrom(this,(n,o)=>{if(o instanceof Panel&&(o.type===Panel.Auto||o.type===Panel.Spot||o.type===Panel.Graduated)&&o.elements.count<=1&&!(o instanceof Part)){let r=!1;if(o.elements.count===1&&(r=o.itemArray!==null,!r)){for(s=t.iterator;s.next();)if(s.value.targetProperty==="itemArray"){r=!0;break}}r||(Util.at("Auto, Spot, or Graduated Panel should not have zero or one elements: "+o.toString()+" in "+n.toString()),Panel.RL=!0)}})),this}static RL=!1;copyTemplate(t){t===void 0&&(t=!1);const i=this.copy();return i.pI(e=>{e instanceof Panel&&(e.Ws=null,e.si=null);const s=e.Ri;s!==null&&(e.Ri=null,s.each(o=>e.bind(o.copy())));const n=e.Ss;n!==null&&(e.Ss=null,n.each(o=>e.trigger(o.value.copy())))}),t&&i.ci(),i}updateTargetBindings(t){const i=this.Ws;if(i===null)return;t===void 0&&(t="");const e=i.iterator;for(;e.next();){const s=e.value,n=this.IL(s,t);if(n===null)continue;const{data:o,elt:r}=n;s.isToTheme&&this.diagram===null||r!==void 0&&s.updateTarget(r,o)}}Yo(){if(this.diagram!==null)if(this.N2()){const t=this.Ws.iterator;for(;t.next();){const i=t.value;if(!i.isToTheme)continue;const e=this.IL(i);if(e===null)continue;const{data:s,elt:n}=e;n!==void 0&&i.updateTarget(n,s)}}else{const t=this.D.h,i=t.length;for(let e=0;e0;let r=0;for(;n0){const i=this.D.elt(0);if(i.isPanelMain&&i instanceof Panel&&i.nl())return 1}return 0}rebuildItemElements(){const t=this.yp();for(;this.D.length>t;)this.ne(this.D.length-1,!1);this.OL(null,this.itemArray)}OL(t,i){const e=this.yp(),s=i;if(s===null||s.length===0){for(;this.D.length>e;)this.ne(this.D.length-1,!1);return}if(this.D.length<=e){const n=s.length;for(let o=0;o(w[w.Default=1]="Default",w[w.None=2]="None",w[w.ProportionalExtra=3]="ProportionalExtra",w))(Sizing||{});class RowColumnDefinition{Hs;Sp;Vt;Aa;La;ai;mt;Md;ro;Jo;Pd;Nd;Ta;Ft;Cd;Js;ht;Zi;we;constructor(t){GSet.vi(this),this.Hs=null,this.Sp=!0,this.Vt=0,this.we=NaN,this.Aa=0,this.La=1/0,this.ai=Spot.Default,this.ht=0,this.Zi=0,this.mt=0,this.Js=null,this.Md=1,this.ro=1,this.Jo=null,this.Pd=null,this.Nd=NaN,this.Ta=null,this.Ft=null,this.Cd=!1,t&&(Object.assign(this,t),t.column!==void 0?(this.isRow=!1,this.index=t.column):t.row!==void 0&&(this.isRow=!0,this.index=t.row))}copy(){const t=new RowColumnDefinition;return t.Sp=this.Sp,t.Vt=this.Vt,t.we=this.we,t.Aa=this.Aa,t.La=this.La,t.ai=this.ai,t.ht=this.ht,t.Zi=this.Zi,t.mt=this.mt,t.ro=this.ro,t.Md=this.Md,this.Jo===null?t.Jo=null:t.Jo=this.Jo.L(),t.Pd=this.Pd,t.Nd=this.Nd,t.Ta=null,this.Ta!==null&&(t.separatorDashArray=this.separatorDashArray.slice()),t.Ft=this.Ft,t.Cd=this.Cd,t.Js=this.Js,t}Z1(t){t.isRow?this.height=t.height:this.width=t.width,this.minimum=t.minimum,this.maximum=t.maximum,this.alignment=t.alignment,this.stretch=t.stretch,this.sizing=t.sizing,this.Jo=t.separatorPadding===null?null:t.separatorPadding.L(),this.separatorStroke=t.separatorStroke,this.separatorStrokeWidth=t.separatorStrokeWidth,this.Ta=null,t.separatorDashArray&&(this.Ta=t.separatorDashArray.slice()),this.background=t.background,this.coversSeparators=t.coversSeparators,this.Js=t.Js}fi(t){t in Sizing?this.sizing=t:Util.ur(this,t)}toString(){return"RowColumnDefinition "+(this.isRow?"(Row ":"(Column ")+this.index+") #"+GSet.gs(this)}static Default=1;static None=2;static ProportionalExtra=3;Ma(t){this.Hs=t}computeEffectiveSpacingTop(t){let i=0;const e=this.Hs;if(this.index!==t){let n=this.separatorStroke;n===null&&e!==null&&(n=this.isRow?e.defaultRowSeparatorStroke:e.defaultColumnSeparatorStroke),n!==null&&(i=this.separatorStrokeWidth,isNaN(i)&&(e!==null?i=this.isRow?e.defaultRowSeparatorStrokeWidth:e.defaultColumnSeparatorStrokeWidth:i=0))}let s=this.Jo;if(s===null)if(e!==null)s=e.defaultSeparatorPadding;else return i;return i+(this.isRow?s.top:s.left)}computeEffectiveSpacing(){let t=0;const i=this.Hs;let e=0;const s=this.isRow;if(i!==null&&i.type===Panel.Table){const o=s?i.ve.length:i.Je.length;for(let r=0;r= 0",RowColumnDefinition,"height"),this.we=t,this.actual=this.ht,this.panel!==null&&this.panel.u(),this.i("height",i,t))}get width(){return this.we}set width(t){const i=this.we;i!==t&&(Debug&&Util.t(t,"number",RowColumnDefinition,"width"),t<0&&Util.G(t,">= 0",RowColumnDefinition,"width"),this.we=t,this.actual=this.ht,this.panel!==null&&this.panel.u(),this.i("width",i,t))}get minimum(){return this.Aa}set minimum(t){const i=this.Aa;i!==t&&(Debug&&Util.t(t,"number",RowColumnDefinition,"minimum"),(t<0||!isFinite(t))&&Util.G(t,">= 0",RowColumnDefinition,"minimum"),this.Aa=t,this.actual=this.ht,this.panel!==null&&this.panel.u(),this.i("minimum",i,t))}get maximum(){return this.La}set maximum(t){const i=this.La;i!==t&&(Debug&&Util.t(t,"number",RowColumnDefinition,"maximum"),t<0&&Util.G(t,">= 0",RowColumnDefinition,"maximum"),this.La=t,this.actual=this.ht,this.panel!==null&&this.panel.u(),this.i("maximum",i,t))}get alignment(){return this.ai}set alignment(t){const i=this.ai;i.equals(t)||(Debug&&Util.s(t,Spot,RowColumnDefinition,"alignment"),this.ai=t.L(),this.panel!==null&&this.panel.u(),this.i("alignment",i,t))}get stretch(){return this.ro}set stretch(t){const i=this.ro;i!==t&&(this.ro=t,this.panel!==null&&this.panel.u(),this.i("stretch",i,t))}get separatorPadding(){return this.Jo}set separatorPadding(t){typeof t=="number"?t=new Margin(t):t!==null&&Debug&&Util.s(t,Margin,RowColumnDefinition,"separatorPadding");const i=this.Jo;(t===null||i===null||!i.equals(t))&&(t!==null&&(t=t.L()),this.Jo=t,this.panel!==null&&this.panel.u(),this.i("separatorPadding",i,t))}get separatorStroke(){return this.Pd}set separatorStroke(t){const i=this.Pd;i!==t&&(t!==null&&Brush.ud(t,"RowColumnDefinition.separatorStroke"),t instanceof Brush&&t.w(),this.Pd=t,this.panel!==null&&this.panel.u(),this.i("separatorStroke",i,t))}get separatorStrokeWidth(){return this.Nd}set separatorStrokeWidth(t){const i=this.Nd;i!==t&&(this.Nd=t,this.panel!==null&&this.panel.u(),this.i("separatorStrokeWidth",i,t))}get separatorDashArray(){return this.Ta}set separatorDashArray(t){const i=this.Ta;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Vi(t,"Array",RowColumnDefinition,"separatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("separatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.Ta=t,this.panel!==null&&this.panel.T(),this.i("separatorDashArray",i,t)}}get background(){return this.Ft}set background(t){const i=this.Ft;i!==t&&(t!==null&&Brush.ud(t,"RowColumnDefinition.background"),t instanceof Brush&&t.w(),this.Ft=t,this.panel!==null&&this.panel.T(),this.i("background",i,t))}get coversSeparators(){return this.Cd}set coversSeparators(t){const i=this.Cd;i!==t&&(Util.t(t,"boolean",RowColumnDefinition,"coversSeparators"),this.Cd=t,this.panel!==null&&this.panel.T(),this.i("coversSeparators",i,t))}get sizing(){return this.Md}set sizing(t){const i=this.Md;i!==t&&(Debug&&Util.tt(t,Sizing,"Sizing"),this.Md=t,this.panel!==null&&this.panel.u(),this.i("sizing",i,t))}eb(){if(this.sizing===1){const t=this.Hs;return this.isRow?t.rowSizing:t.columnSizing}return this.sizing}get actual(){return this.ht}set actual(t){isNaN(this.we)?this.ht=Math.max(Math.min(this.La,t),this.Aa):this.ht=Math.max(Math.min(this.La,this.we),this.Aa)}get measured(){return this.Zi}set measured(t){this.Zi=t}get total(){return this.ht+this.computeEffectiveSpacing()}get position(){return this.mt}set position(t){this.mt=t}bind(t,i,e,s){return this.hc(t,i,e,s),this}bindTwoWay(t,i,e,s){const n=this.hc(t,i,e,s);return s===void 0&&n.makeTwoWay(),this}theme(t,i,e,s,n){return this.mh(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.mh(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.mh(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.mh(t,i,e,s,n).ofModel(),this}hc(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.Z0(n),n}mh(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.Z0(o),o}Z0(t){t.Ce=this;const i=this.panel;if(i!==null){const e=i.findBindingPanel();e!==null&&e.wL()&&Util.n("Cannot add a Binding to a RowColumnDefinition that is already frozen: "+t+" on "+i)}this.Js===null&&(this.Js=new List),this.Js.add(t)}}class Shape extends GraphObject{yt;Ps;Ad;Da;$i;Zo;jo;Rt;Ld;Td;_;constructor(t,i){super(),this.yt=null,this.Ps=null,this.Ad="None",this.Da="black",this.$i="black",this.Zo=1,this.jo=null,this.Rt=null,this.Ld=NaN,this.Td=NaN,this._=null,typeof t=="string"?this.figure=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.yt=this.yt,t.Ps=this.Ps,t.Ad=this.Ad,t.Da=this.Da,t.$i=this.$i,t.Zo=this.Zo,this.jo!==null&&(t.jo=this.jo.slice()),this.Rt!==null&&(this.Rt.wi?t.Rt=this.Rt:t.Rt=this.Rt.copy()),t.Ld=this.Ld,t.Td=this.Td,this._!==null&&(t._=this._.copy())}Fa(){this.Rt===null?this.Rt=new ShapeTemplateSettings:this.Rt.wi&&(this.Rt=this.Rt.copy())}fh(){super.fh(),this.Rt!==null&&(this.Rt.wi=!0)}fi(t){t in GeometryStretch?this.geometryStretch=t:super.fi(t)}toString(){return"Shape("+(this.figure!=="None"?this.figure:this.toArrow!=="None"?this.toArrow:this.fromArrow)+")#"+GSet.gs(this)}MI(t,i){const e=this.pathPattern;e.wt(1/0,1/0);const s=e.measuredBounds;e.qt(0,0,s.width,s.height);const n=this.geometry;t.save(),t.beginPath();const o=Util.ft();if(n.type===1)o.push(n.startX),o.push(n.startY),o.push(n.endX),o.push(n.endY),this.Dd(t,i,o,e);else if(n.type===4){const r=n.figures.iterator;for(;r.next();){const l=r.value;o.length=0,o.push(l.startX),o.push(l.startY);let h=l.startX,a=l.startY,f=h,c=a;const u=l.segments.h,d=u.length;for(let m=0;m=.1;){if(P===0&&(M?(b=k,b-=S,y-=S,M=!1):b=k,b===0&&(b=1)),b>y){b=y,Util.nt(x);return}b>p?(P=b-p,b=p):P=0;let N=Math.sqrt(b*b/(1+m*m));if(u<0&&(N=-N),h+=N,a+=m*N,t.translate(h,a),t.rotate(g),t.translate(-(r/2),-(l/2)),P===0&&s.gh(t,i),t.translate(r/2,l/2),t.rotate(-g),t.translate(-h,-a),y-=b,p-=b,P!==0){if(A++,A===x.length){Util.nt(x);return}C=x[A],u=C[0],g=C[1],m=C[2],p=C[3],b=P}}Util.nt(x)}gh(t,i){const e=t instanceof SVGContext;let s=this.$i;const n=this.Da;if(s===null&&n===null)return;const o=this.yt;if(o===null)return;t.commitTransform();const r=this.actualBounds,l=this.naturalBounds;n!==null&&this.wn(t,n,!0,!1,l,r);const h=this.part;let a=this.Zo;s!==null&&a===0&&h!==null&&(this.isPanelMain||h.findMainElement()===this)&&(a=h.CI()),a===0&&(s=null),s!==null&&a!==0&&(this.wn(t,s,!1,!1,l,r),t.lineWidth=a,t.lineJoin=this.strokeJoin,t.lineCap=this.strokeCap,t.miterLimit=this.strokeMiterLimit);let f=!1;h&&i.getRenderingHint("drawShadows")&&(f=h.isShadowed),t.ol===!1&&(f=!1);let c=!0;s!==null&&(n===null||n==="transparent")&&(c=!1);let u=!1;const d=this.strokeDashArray;if(d!==null&&(u=!0,t.enableDash(d,this.strokeDashOffset)),o.type===1)t.beginPath(),t.moveTo(o.startX,o.startY),t.lineTo(o.endX,o.endY),s!==null&&t.strokeContext(),t.endPath();else if(o.type===2){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.min(m,p),k=Math.min(g,y),b=Math.abs(p-m),S=Math.abs(y-g);t.beginPath(),t.rect(x,k,b,S),n!==null&&t.fillContext(n,!1,null),s!==null&&(c&&f&&t.shadowsOff(),t.strokeContext(),c&&f&&t.shadowsOn()),t.endPath()}else if(o.type===3){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.abs(p-m)/2,k=Math.abs(y-g)/2,b=Math.min(m,p)+x,S=Math.min(g,y)+k;t.beginPath(),t.moveTo(b,S-k),t.bezierCurveTo(b+Geo.Un*x,S-k,b+x,S-Geo.Un*k,b+x,S),t.bezierCurveTo(b+x,S+Geo.Un*k,b+Geo.Un*x,S+k,b,S+k),t.bezierCurveTo(b-Geo.Un*x,S+k,b-x,S+Geo.Un*k,b-x,S),t.bezierCurveTo(b-x,S-Geo.Un*k,b-Geo.Un*x,S-k,b,S-k),t.closePath(),n!==null&&t.fillContext(n,!1,null),s!==null&&(c&&f&&t.shadowsOff(),t.strokeContext(),c&&f&&t.shadowsOn()),t.endPath()}else if(o.type===4){const m=o.figures,g=m.length;for(let p=0;p1||this.pathPattern!==null?!0:super.fd(t)}p2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("path");for(let s=0;s1,i);Util.n("Unknown Geometry type: "+e.type)}}ld(t,i,e,s){const n=this.desiredSize,o=this.Zo;t=Math.max(t,0),i=Math.max(i,0);let r;if(this.Ps!==null)r=this.geometry.bounds;else{const g=this.figure;let p=Shape.q2[g];if(p===void 0){let y=Geo.qn[g];typeof y=="string"&&(y=Geo.qn[y]),typeof y=="function"?(p=y(null,100,100),Shape.q2[g]=p):Util.n("Unsupported Figure: "+g)}r=p.bounds}let l=r.width,h=r.height,a=r.width,f=r.height;switch(this.qs(!0)){case 0:e=0,s=0;break;case 2:a=Math.max(t-o,0),f=Math.max(i-o,0);break;case 5:a=Math.max(t-o,0),s=0;break;case 4:e=0,f=Math.max(i-o,0);break}isFinite(n.width)&&(a=n.width),isFinite(n.height)&&(f=n.height);const u=this.maxSize,d=this.minSize;e=Math.max(e-o,d.width),s=Math.max(s-o,d.height),a=Math.min(u.width,a),f=Math.min(u.height,f),a=isFinite(a)?Math.max(e,a):Math.max(l,e),f=isFinite(f)?Math.max(s,f):Math.max(h,s);const m=this.lM();switch(m){case 0:break;case 2:l=a,h=f;break;case 6:{let g=Math.min(a/l,f/h);isFinite(g)||(g=1),l=l*g,h=h*g;break}default:Util.n(m+" is not a valid geometryStretch.")}if(this.Ps!==null){l===0&&(l=.001),h===0&&(h=.001);const p=(this.Ps!==null?this.Ps:this.yt).$D(l,h);Debug&&p.w(),this.yt=p}else(this.yt===null||!Geo.q(this.yt.ff,t-o)||!Geo.q(this.yt.cf,i-o))&&(this.yt=Shape.AI(this,l,h));r=this.yt.bounds,t===1/0||i===1/0?this.no(r.x-o/2,r.y-o/2,t===0&&l===0?0:r.width+o,i===0&&h===0?0:r.height+o):this.no(-(o/2),-(o/2),a+o,f+o),n.isReal()?(a=n.width,f=n.height,a=Math.min(u.width,a),f=Math.min(u.height,f),a=Math.max(d.width,a),f=Math.max(d.height,f),this.Hi.e(0,0,a,f)):this.Hi.c(r)}lM(){const t=this.geometryStretch;return this.Ps!==null?t===1?2:t:t===1?Shape.q2[this.figure].defaultStretch:t}uh(t,i,e,s){this.commonArrange(t,i,e,s)}getNearestIntersectionPoint(t,i,e){return this.sc(t.x,t.y,i.x,i.y,e)}sc(t,i,e,s,n){const o=this.O,r=1/(o.m11*o.m22-o.m12*o.m21),l=o.m22*r,h=-o.m12*r,a=-o.m21*r,f=o.m11*r,c=r*(o.m21*o.dy-o.m22*o.dx),u=r*(o.m12*o.dx-o.m11*o.dy),d=t*l+i*a+c,m=t*h+i*f+u,g=e*l+s*a+c,p=e*h+s*f+u,y=this.Zo/2;let x=this.yt;x===null&&(this.wt(1/0,1/0),x=this.yt);const k=x.bounds;let b=!1;if(x.type===1)if(this.strokeWidth<=1.5)b=Geo.Hn(x.startX,x.startY,x.endX,x.endY,d,m,g,p,n);else{let S=0,M=0;if(x.startX===x.endX)S=y,M=0;else{const T=(x.endY-x.startY)/(x.endX-x.startX);M=y/Math.sqrt(1+T*T),S=M*T}const A=Util.ft();let C=new Point;Geo.Hn(x.startX+S,x.startY+M,x.endX+S,x.endY+M,d,m,g,p,C)&&A.push(C),C=new Point,Geo.Hn(x.startX-S,x.startY-M,x.endX-S,x.endY-M,d,m,g,p,C)&&A.push(C),C=new Point,Geo.Hn(x.startX+S,x.startY+M,x.startX-S,x.startY-M,d,m,g,p,C)&&A.push(C),C=new Point,Geo.Hn(x.endX+S,x.endY+M,x.endX-S,x.endY-M,d,m,g,p,C)&&A.push(C);const P=A.length;if(P===0)return Util.nt(A),!1;b=!0;let N=1/0;for(let T=0;T0&&k.contains(D,F)&&(P.x=D,P.y=F,this.containsPoint(P)))for(N!==0&&Math.abs(N)<.5?(T*=.5/N,N=.5):T!==0&&Math.abs(T)<.5&&(N*=.5/T,T=.5),D-=N,F-=T;k.contains(D,F);)D-=N,F-=T;const R=.6;n.x=g,n.y=p;for(let K=0;Ke?t-e:e-t)<(i>s?i-s:s-i)){const c=ic||Geo.q(h.y,c))&&(h.yc||Geo.q(h.x,c))&&(h.x=a&&h<=f}else{let a=0,f=0;return s=a&&l<=f}}DI(t,i){if(this.containedInRect(t,i)||i===void 0&&(i=this.O,t.containsRect(this.actualBounds)))return!0;const e=t.left,s=t.right,n=t.top,o=t.bottom,r=Point.a(),l=Point.a(),h=Point.a(),a=Transform.a();a.set(i),a.yC(this.O),a.Pw(),l.x=s,l.y=n,l.O(a),r.x=e,r.y=n,r.O(a);let f=!1;return this.Ra(r,l,h)?f=!0:(r.x=s,r.y=o,r.O(a),this.Ra(r,l,h)?f=!0:(l.x=e,l.y=o,l.O(a),this.Ra(r,l,h)?f=!0:(r.x=e,r.y=n,r.O(a),this.Ra(r,l,h)&&(f=!0)))),Transform.o(a),Point.o(r),Point.o(l),Point.o(h),f}hL(t,i,e){if(e&&this.fill!==null&&this.ch(t,!0))return!0;let s=t.distanceSquaredPoint(i);const n=s;this.strokeWidth>1.5&&(s=this.strokeWidth/2+Math.sqrt(s),s*=s);let o=this.yt;if(o===null&&(this.wt(1/0,1/0),o=this.yt,o===null))return!1;if(!e){const c=o.bounds,u=c.x,d=c.y,m=c.x+c.width,g=c.y+c.height;if(Point.distanceSquared(t.x,t.y,u,d)<=s&&Point.distanceSquared(t.x,t.y,m,d)<=s&&Point.distanceSquared(t.x,t.y,u,g)<=s&&Point.distanceSquared(t.x,t.y,m,g)<=s)return!0}function r(c,u){const d=c.length;for(let m=0;ms)return!0;return!1}const l=o.startX,h=o.startY,a=o.endX,f=o.endY;if(o.type===1){const c=Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,f),u=(a-l)*(t.x-l)+(f-h)*(t.y-h),d=(l-a)*(t.x-a)+(h-f)*(t.y-f),m=u>=0&&d>=0?s:n;return c<=m}else if(o.type===2){let c=!1;return e&&(c=Point.distanceLineSegmentSquared(t.x,t.y,l,h,l,f)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,h)<=s||Point.distanceLineSegmentSquared(t.x,t.y,a,h,a,f)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,f,a,f)<=s),c}else if(o.type===3){const c=(l+a)/2,u=(h+f)/2,d=t.x-c,m=t.y-u,g=Math.abs(a-l)/2,p=Math.abs(f-h)/2;if(g===0||p===0)return Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,f)<=s;if(e){const y=Geo.UD(g,p,d,m);return y*y<=s}else return!(Point.distanceSquared(d,m,-g,0)>=s||Point.distanceSquared(d,m,0,-p)>=s||Point.distanceSquared(d,m,0,p)>=s||Point.distanceSquared(d,m,g,0)>=s)}else if(o.type===4){const c=o.bounds,u=c.x,d=c.y,m=c.x+c.width,g=c.y+c.height;if(t.x>m&&t.xg&&t.ys&&Point.distanceLineSegmentSquared(t.x,t.y,u,d,m,d)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,u,g)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,m,d)>s)return!1;const p=Math.sqrt(s);if(e){if(this.fill===null?o.LC(t.x,t.y,p):o.vk(t,p,!0,!1))return!0}else{const y=o.figures;for(let x=0;xs)return!1;const M=k.segments.h,A=M.length;for(let C=0;Cs)return!1;break;case 3:{const N=Util.ft();Geo.Gn(b,S,P.point1X,P.point1Y,P.point2X,P.point2Y,P.endX,P.endY,.8,N);const T=r(N,t);if(Util.nt(N),T||(b=P.endX,S=P.endY,t.distanceSquared(b,S)>s))return!1;break}case 4:{const N=Util.ft();Geo.jg(b,S,P.point1X,P.point1Y,P.endX,P.endY,.8,N);const T=r(N,t);if(Util.nt(N),T||(b=P.endX,S=P.endY,t.distanceSquared(b,S)>s))return!1;break}case 5:case 6:{const N=P.type===5?P.To(k):P.Xh(k,b,S),T=N.length;if(T===0){if(b=P.type===5?P.centerX:P.endX,S=P.type===5?P.centerY:P.endY,t.distanceSquared(b,S)>s)return!1;break}let L=null;const D=Util.ft();for(let F=0;F=0){this.Zo=t,this.u();const e=this.part;e!==null&&e.mc(),this.i("strokeWidth",i,t)}else Util.G(t,"value >= 0",Shape,"strokeWidth:value")}U1(){return this.Zo}get strokeCap(){return this.Rt!==null?this.Rt.Mp:"butt"}set strokeCap(t){const i=this.strokeCap;i!==t&&(typeof t=="string"&&(t==="butt"||t==="round"||t==="square")?(this.Fa(),this.Rt.Mp=t,this.T(),this.i("strokeCap",i,t)):Util.G(t,'"butt", "round", or "square"',Shape,"strokeCap"))}get strokeJoin(){return this.Rt!==null?this.Rt.Pp:"miter"}set strokeJoin(t){const i=this.strokeJoin;i!==t&&(typeof t=="string"&&(t==="miter"||t==="bevel"||t==="round")?(this.Fa(),this.Rt.Pp=t,this.T(),this.i("strokeJoin",i,t)):Util.G(t,'"miter", "bevel", or "round"',Shape,"strokeJoin"))}get strokeMiterLimit(){return this.Rt!==null?this.Rt.Np:10}set strokeMiterLimit(t){const i=this.strokeMiterLimit;if(i!==t)if(Debug&&Util.r(t,Shape,"strokeMiterLimit"),t>=1){this.Fa(),this.Rt.Np=t,this.T();const e=this.part;e!==null&&e.mc(),this.i("strokeMiterLimit",i,t)}else Debug&&Util.G(t,"value >= 1",Shape,"strokeWidth:value")}get strokeDashArray(){return this.jo}set strokeDashArray(t){const i=this.jo;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Vi(t,"Array",Shape,"strokeDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("strokeDashArray:value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.jo=t,this.T(),this.i("strokeDashArray",i,t)}}get strokeDashOffset(){return this.Rt!==null?this.Rt.ph:0}set strokeDashOffset(t){const i=this.strokeDashOffset;i!==t&&(Debug&&Util.r(t,Shape,"strokeDashOffset"),t>=0&&(this.Fa(),this.Rt.ph=t,this.T(),this.i("strokeDashOffset",i,t)))}get figure(){return this.Ad}set figure(t){const i=this.Ad;if(i!==t){Debug&&Util.t(t,"string",Shape,"figure");let e=Geo.qn[t];if(typeof e=="function"?e=t:(e=Geo.qn[t.toLowerCase()],e||Util.n("Unknown Shape.figure: "+t)),i!==e){const s=this.part;s!==null&&s.mc(),this.Ad=e,this.Ps=null,this.re(),this.u(),this.i("figure",i,e)}}}get toArrow(){return this.Ut!==null?this.Ut.Cp:"None"}set toArrow(t){const i=this.toArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){Debug&&Util.t(t,"string",Shape,"toArrow");const e=Shape.BL(t);e===null?Util.n("Unknown Shape.toArrow: "+t):i!==e&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.Cp=e,this.Ps=null,this.re(),this.u(),this.zL(e),this.i("toArrow",i,e))}}get fromArrow(){return this.Ut!==null?this.Ut.Ap:"None"}set fromArrow(t){const i=this.fromArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){Debug&&Util.t(t,"string",Shape,"fromArrow");const e=Shape.BL(t);e===null?Util.n("Unknown Shape.fromArrow: "+t):i!==e&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.Ap=e,this.Ps=null,this.re(),this.u(),this.zL(e),this.i("fromArrow",i,e))}}zL(t){const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;this.KR();const e=Spot.MiddleRight;this.toArrow!=="None"?(this.segmentIndex=-1,this.alignmentFocus=e):this.fromArrow!=="None"&&(this.segmentIndex=0,this.alignmentFocus=new Spot(1-e.x,e.y))}get spot1(){return this.Rt!==null?this.Rt.jn:Spot.Default}set spot1(t){Util.s(t,Spot,Shape,"spot1");const i=this.spot1;i.equals(t)||(t=t.L(),this.Fa(),this.Rt.jn=t,this.u(),this.i("spot1",i,t))}get spot2(){return this.Rt!==null?this.Rt.Wn:Spot.Default}set spot2(t){Util.s(t,Spot,Shape,"spot2");const i=this.spot2;i.equals(t)||(t=t.L(),this.Fa(),this.Rt.Wn=t,this.u(),this.i("spot2",i,t))}get parameter1(){return this.Ld}set parameter1(t){const i=this.Ld;i!==t&&(this.Ld=t,this.re(),this.u(),this.i("parameter1",i,t))}get parameter2(){return this.Td}set parameter2(t){const i=this.Td;i!==t&&(this.Td=t,this.re(),this.u(),this.i("parameter2",i,t))}get naturalBounds(){return this.Hi}lI(){const t=this.desiredSize;if(!t.isReal()&&this.yt!==null){const i=this.yt.bounds;this.Hi.c(i)}else this.Hi.e(0,0,t.width,t.height)}get pathPattern(){return this.Rt!==null?this.Rt.Lp:null}set pathPattern(t){const i=this.pathPattern;i!==t&&(Debug&&t!==null&&Util.s(t,GraphObject,Shape,"pathPattern"),this.Fa(),this.Rt.Lp=t,this.T(),this.i("pathPattern",i,t))}get geometryStretch(){return this.Rt!==null?this.Rt.Tp:1}set geometryStretch(t){const i=this.geometryStretch;i!==t&&(Util.tt(t,GeometryStretch,"GeometryStretch"),this.Fa(),this.Rt.Tp=t,this.u(),this.i("geometryStretch",i,t))}get interval(){return this._!==null?this._.yc:1}set interval(t){const i=this.interval;if(Debug&&Util.r(t,Shape,"interval"),t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this._===null&&(this._=new GradElementSettings),this._.yc=t;const e=this.diagram;e!==null&&this.panel===e.grid&&e.Zr(),this.u();const s=this.panel;s!==null&&(s.as=null),this.i("interval",i,t)}}get graduatedStart(){return this._!==null?this._.wc:0}set graduatedStart(t){const i=this.graduatedStart;Debug&&Util.r(t,Shape,"graduatedStart"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.wc=t,this.u(),this.i("graduatedStart",i,t))}get graduatedEnd(){return this._!==null?this._.xc:1}set graduatedEnd(t){const i=this.graduatedEnd;Debug&&Util.r(t,Shape,"graduatedEnd"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.xc=t,this.u(),this.i("graduatedEnd",i,t))}get graduatedSkip(){return this._!==null?this._.bc:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.t(t,"function",Shape,"graduatedSkip"),this._===null&&(this._=new GradElementSettings),this._.bc=t,this.u(),this.i("graduatedSkip",i,t))}static AI(t,i,e){let n=null;if(t.toArrow!=="None")n=Shape.fo[t.toArrow];else if(t.fromArrow!=="None")n=Shape.fo[t.fromArrow];else{let o=Geo.qn[t.figure];typeof o=="string"&&(o=Geo.qn[o]),o===void 0&&Util.n("Unknown Shape.figure: "+t.figure),n=o(t,i,e),n.ff=i,n.cf=e}if(n===null){const o=Geo.qn.Rectangle;typeof o=="function"&&(n=o(t,i,e))}return Debug&&(n.bounds.width>i+1e-5||n.bounds.height>e+1e-5)&&Util.n('Geometry made with figure "'+t.figure+'" has bounds '+n.bounds.toString()+" that are too large for the given size ("+i+","+e+"). See documentation for Shape.defineFigureGenerator."),n}static getFigureGenerators(){const t=new GMap;for(const i in Geo.qn){if(i===i.toLowerCase())continue;const e=Geo.qn[i];t.set(i,e)}return t.w(),t}static defineFigureGenerator(t,i){Util.t(t,"string",Shape,"defineFigureGenerator:name"),typeof i=="string"?Debug&&(i===""||!Geo.qn[i])&&Util.n("Shape.defineFigureGenerator synonym must not be empty or None or not a defined figure name: "+i):Util.t(i,"function",Shape,"defineFigureGenerator:func");const e=t.toLowerCase();Debug&&(t===""||t===e)&&Util.n("Shape.defineFigureGenerator name must not be empty or all-lower-case: "+t);const s=Geo.qn;s[t]=i,s[e]=t}static getArrowheadGeometries(){const t=new GMap;for(const i in Geo.Zg)if(Shape.fo[i]===void 0){const e=Geometry.parse(Geo.Zg[i],!1);Shape.fo[i]=e;const s=i.toLowerCase();s!==i&&(Shape.fo[s]=i)}for(const i in Shape.fo){if(i===i.toLowerCase())continue;const e=Shape.fo[i];e instanceof Geometry&&t.set(i,e)}return t.w(),t}static defineArrowheadGeometry(t,i){Util.t(t,"string",Shape,"defineArrowheadGeometry:name");let e=null;typeof i=="string"?(Util.t(i,"string",Shape,"defineArrowheadGeometry:pathstr"),e=Geometry.parse(i,!1)):(Util.s(i,Geometry,Shape,"defineArrowheadGeometry:pathstr"),e=i);const s=t.toLowerCase();(Debug&&t===""||s==="none"||t===s)&&Util.n("Shape.defineArrowheadGeometry name must not be empty or None or all-lower-case: "+t);const n=Shape.fo;n[t]=e,n[s]=t}static fo=new PropertyCollection;static q2=new PropertyCollection;static BL(t){let i=Shape.fo[t];if(i===void 0){const e=t.toLowerCase();if(e==="none")return"None";if(i=Shape.fo[e],i===void 0){let s=null;for(const n in Geo.Zg)if(n.toLowerCase()===e){s=n;break}if(s!==null){const n=Geometry.parse(Geo.Zg[s],!1);return Shape.fo[s]=n,e!==s&&(Shape.fo[e]=s),s}}}return typeof i=="string"?i:i instanceof Geometry?t:null}}class ShapeTemplateSettings{wi;Mp;Pp;Np;ph;Lp;Tp;jn;Wn;constructor(){this.wi=!1,this.Mp="butt",this.Pp="miter",this.Np=10,this.ph=0,this.Lp=null,this.Tp=1,this.jn=Spot.Default,this.Wn=Spot.Default}copy(){const t=new ShapeTemplateSettings;return t.Mp=this.Mp,t.Pp=this.Pp,t.Np=this.Np,t.ph=this.ph,t.Lp=this.Lp,t.Tp=this.Tp,t.jn=this.jn.L(),t.Wn=this.Wn.L(),t}}var Wrap=(w=>(w[w.None=0]="None",w[w.Fit=1]="Fit",w[w.DesiredSize=2]="DesiredSize",w[w.BreakAll=3]="BreakAll",w))(Wrap||{}),TextOverflow=(w=>(w[w.Clip=0]="Clip",w[w.Ellipsis=1]="Ellipsis",w))(TextOverflow||{}),TextFormat=(w=>(w[w.Trim=0]="Trim",w[w.None=1]="None",w))(TextFormat||{});class TextBlock extends GraphObject{ui;$i;Cn;Fe;xi;C0;Fd;_;$;Ol;co;An;Re;Oi;Ln;constructor(t,i){return super(),this.l|=2097152,this.ui="",this.$i="black",this.Cn="13px sans-serif",this.Fe=0,this.xi=0,this.C0=0,this.Fd=null,this._=null,this.$=null,this.Ol=0,this.co=null,this.An=0,this.Re=null,this.Oi=null,this.Ln=null,typeof t=="string"?this.text=t:t&&Object.assign(this,t),i&&Object.assign(this,i),this}cloneProtected(t){super.cloneProtected(t),t.ui=this.ui,t.$i=this.$i,t.Cn=this.Cn,t.Fe=this.Fe,t.xi=this.xi,t.C0=this.C0,t.Fd=this.Fd,this._!==null&&(t._=this._.copy()),this.$!==null&&(this.$.wi?t.$=this.$:t.$=this.$.copy()),t.Ol=this.Ol,t.co=this.co,t.An=this.An,t.Re=this.Re,t.Oi=this.Oi,t.Ln=this.Ln}Tn(){this.$===null?this.$=new TextBlockTemplateSettings:this.$.wi&&(this.$=this.$.copy())}fh(){super.fh(),this.$!==null&&(this.$.wi=!0)}gI(t){this.l=t.l|2048|4096,this._t=t.opacity,this.Ft=t.background,this.qe=t.desiredSize.L(),this.minSize=t.minSize.L(),this.maxSize=t.maxSize.L(),t.Pi!==null?this.Pi=t.Pi.copy():this.Pi=null,this.lt=t.scale,this.jt=t.angle,this.stretch=t.stretch,this.el=t.margin.L(),this.ai=t.alignment.L(),this.tc=t.alignmentFocus.L(),this.segmentFraction=t.segmentFraction,this.segmentOffset=t.segmentOffset.L(),this.segmentOrientation=t.segmentOrientation,t.hi!==null&&(this.hi=t.hi.copy()),this.shadowVisible=t.shadowVisible,this.ui=t.ui,this.$i=t.$i,this.Cn=t.Cn,this._!==null&&(this._=t._.copy()),t.$!==null&&(t.$.wi?this.$=t.$:this.$=t.$.copy()),this.Ol=t.Ol}uI(t){if(this.ui=t.text||"",this.jt=t.labelAngle||0,this.Fe=t.lineCount||0,this.FI(t.lines),t.naturalBounds&&(this.Hi=t.naturalBounds),t.actualBounds){const i=t.actualBounds;this.qt(i.x,i.y,i.width,i.height)}}fi(t){t in Wrap?this.wrap=t:super.fi(t)}toString(){return this.ui.length>22?'TextBlock("'+this.ui.substring(0,20)+'"...)':'TextBlock("'+this.ui+'")'}static getEllipsis(){return TextBlock.Dp}static setEllipsis(t){TextBlock.Dp=t,TextBlock.ab=new PropertyCollection,TextBlock.j2=0}static getBaseline(){return TextBlock.fb}static setBaseline(t){TextBlock.fb=t}static fb=null;static getUnderline(){return TextBlock.cb}static setUnderline(t){TextBlock.cb=t}static cb=null;static None=0;static WrapFit=1;static WrapDesiredSize=2;static WrapBreakAll=3;static OverflowClip=0;static OverflowEllipsis=1;static FormatTrim=0;static FormatNone=1;u(){super.u()}get font(){return this.Cn}set font(t){const i=this.Cn;i!==t&&(Debug&&(Util.t(t,"string",TextBlock,"font"),TextBlock.isValidFont(t)||Util.n('Not a valid font: "'+t+'"')),this.Cn=t,this.co=null,this.u(),this.i("font",i,t))}static isValidFont(t){return root.CSS?root.CSS.supports("font",t):!0}get text(){return this.ui}set text(t){const i=this.ui;t!=null?t=t.toString():t="",i!==t&&(this.ui=t,this.u(),this.i("text",i,t),this.hs(!0))}get textAlign(){return this.$!==null?this.$.Fp:"start"}set textAlign(t){const i=this.textAlign;i!==t&&(Debug&&Util.t(t,"string",TextBlock,"textAlign"),t==="start"||t==="end"||t==="left"||t==="right"||t==="center"?(this.Tn(),this.$.Fp=t,this.T(),this.i("textAlign",i,t)):Debug&&Util.G(t,'"start", "end", "left", "right", or "center"',TextBlock,"textAlign"))}get flip(){return this.$!==null?this.$.uo:0}set flip(t){const i=this.flip;i!==t&&(Util.tt(t,Flip,"Flip"),this.Tn(),this.$.uo=t,this.T(),this.i("flip",i,t))}get verticalAlignment(){return this.$!==null?this.$.hl:Spot.Top}set verticalAlignment(t){const i=this.verticalAlignment;i.equals(t)||(Debug&&(Util.s(t,Spot,TextBlock,"verticalAlignment"),t.isNoSpot()&&Util.n("TextBlock.verticalAlignment for "+this+" must be a real Spot, not:"+t)),t=t.L(),this.Tn(),this.$.hl=t,this.lc(),this.i("verticalAlignment",i,t))}get naturalBounds(){if(!this.Hi.isReal()){const t=Size.a();this.W2(this.ui,999999,t);let i=t.width;Size.o(t);let e=this.XL(i);const s=this.desiredSize;isNaN(s.width)||(i=s.width),isNaN(s.height)||(e=s.height),this.Hi.Kn(i,e)}return this.Hi}get isMultiline(){return(this.l&2097152)!==0}set isMultiline(t){const i=(this.l&2097152)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"isMultiline"),this.l=this.l^2097152,this.u(),this.i("isMultiline",i,t))}get isUnderline(){return(this.l&4194304)!==0}set isUnderline(t){const i=(this.l&4194304)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"isUnderline"),this.l=this.l^4194304,this.hs(!0),this.T(),this.i("isUnderline",i,t))}get isStrikethrough(){return(this.l&8388608)!==0}set isStrikethrough(t){const i=(this.l&8388608)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"isStrikethrough"),this.l=this.l^8388608,this.hs(!0),this.T(),this.i("isStrikethrough",i,t))}get wrap(){return this.$!==null?this.$.Rp:2}set wrap(t){const i=this.wrap;i!==t&&(Debug&&Util.tt(t,Wrap,"Wrap"),this.Tn(),this.$.Rp=t,this.u(),this.i("wrap",i,t))}get overflow(){return this.$!==null?this.$.Ip:0}set overflow(t){const i=this.overflow;i!==t&&(Debug&&Util.tt(t,TextOverflow,"Overflow"),this.Tn(),this.$.Ip=t,this.u(),this.i("overflow",i,t))}get isOverflowed(){return(this.l&16777216)!==0}v2(t){t?this.l|=16777216:this.l&=-16777217}get stroke(){return this.$i}set stroke(t){const i=this.$i;i!==t&&(t!==null&&Brush.ud(t,"TextBlock.stroke"),t instanceof Brush&&t.w(),this.$i=t,this.T(),this.i("stroke",i,t))}get lineCount(){return this.Fe}get lineHeight(){return this.Op()}get editable(){return(this.l&1048576)!==0}set editable(t){const i=(this.l&1048576)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"editable"),this.l=this.l^1048576,this.i("editable",i,t))}get B2(){return(this.l&33554432)!==0}set B2(t){this.l=this.l^33554432}get textEditor(){return this.$!==null?this.$.Ep:null}set textEditor(t){const i=this.textEditor;i!==t&&(Debug&&!(t instanceof HTMLInfo)&&Util.n("TextBlock.textEditor must be an HTMLInfo."),this.Tn(),this.$.Ep=t,this.i("textEditor",i,t))}get errorFunction(){return this.$!==null?this.$.fs:null}set errorFunction(t){const i=this.errorFunction;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"errorFunction"),this.Tn(),this.$.fs=t,this.i("errorFunction",i,t))}get interval(){return this._!==null?this._.yc:1}set interval(t){const i=this.interval;if(Debug&&Util.r(t,TextBlock,"interval"),t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this._===null&&(this._=new GradElementSettings),this._.yc=t,this.u();const e=this.panel;e!==null&&(e.as=null),this.i("interval",i,t)}}get graduatedStart(){return this._!==null?this._.wc:0}set graduatedStart(t){const i=this.graduatedStart;Debug&&Util.r(t,TextBlock,"graduatedStart"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.wc=t,this.u(),this.i("graduatedStart",i,t))}get graduatedEnd(){return this._!==null?this._.xc:1}set graduatedEnd(t){const i=this.graduatedEnd;Debug&&Util.r(t,TextBlock,"graduatedEnd"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.xc=t,this.u(),this.i("graduatedEnd",i,t))}get graduatedFunction(){return this._!==null?this._.Vp:null}set graduatedFunction(t){const i=this.graduatedFunction;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"graduatedFunction"),this._===null&&(this._=new GradElementSettings),this._.Vp=t,this.u(),this.i("graduatedFunction",i,t))}get graduatedSkip(){return this._!==null?this._.bc:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"graduatedSkip"),this._===null&&(this._=new GradElementSettings),this._.bc=t,this.u(),this.i("graduatedSkip",i,t))}gh(t,i){if(this.$i===null||this.ui.length===0||this.Cn===null)return;const e=this.naturalBounds,s=this.actualBounds,n=e.width,o=e.height,r=this.Op();let l=t.textAlign=this.textAlign;const h=i.Ju;l==="start"?l=h?"right":"left":l==="end"&&(l=h?"left":"right");const a=this.isUnderline,f=this.isStrikethrough;this.wn(t,this.$i,!0,!1,e,s),(a||f)&&this.wn(t,this.$i,!1,!1,e,s);const c=0;let u=0;const d=n;let m=!1;i.ei===t&&!(i.ei instanceof SVGContext)&&!this.B2&&i.getRenderingHint("textGreeking")===!0&&r*this.ga*i.scale<3&&(m=!0);const g=this.spacingAbove,p=this.spacingBelow;switch(this.flip){case 0:break;case 2:t.translate(n,0),t.scale(-1,1);break;case 1:t.translate(0,o),t.scale(1,-1);break;case 3:t.translate(n,o),t.scale(-1,-1);break}t.commitTransform();const y=this.Fe,k=(g+r+p)*y;if(o>k){const b=this.verticalAlignment;u=b.y*o-b.y*k+b.offsetY}if(y===1&&this.Ln!==null){let b=this.xi;b>d&&(b=d),u+=g,this.YL(this.Ln,t,c,u,d,r,b,m,l,a,f)}else if(this.Re!==null&&this.Oi!==null)for(let b=0;bd&&(S=d),u+=g,this.YL(this.Oi[b],t,c,u,d,r,S,m,l,a,f),u+=r+p}switch(this.flip){case 0:break;case 2:t.scale(-1,1),t.translate(-n,0);break;case 1:t.scale(1,-1),t.translate(0,-o);break;case 3:t.scale(-1,-1),t.translate(-n,-o);break}}YL(t,i,e,s,n,o,r,l,h,a,f){let c=0;if(l){h==="left"?c=0:h==="right"?c=n-r:h==="center"&&(c=(n-r)/2);const m=i.globalAlpha;i.globalAlpha=m/2,i.fillRect(e+c,s+o/4,r,o/2),i.globalAlpha=m;return}h==="left"?c=0:h==="right"?c=n:h==="center"&&(c=n/2);const u=TextBlock.fb!==null?TextBlock.fb(this,o):o*.75;i.fillText(t,e+c,s+u);let d=o/20|0;if(d===0&&(d=1),h==="right"?c-=r:h==="center"&&(c-=r/2),a){const m=TextBlock.cb!==null?TextBlock.cb(this,o):o*.8;this.KL(e+c,s+m,e+c+r,s+m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}if(f){let m=s+o-o/2.2|0;d%2!==0&&(m+=.5),this.KL(e+c,m,e+c+r,m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}}KL(t,i,e,s,n,o){o.beginPath(),o.lineWidth=n,o.moveTo(t,i),o.lineTo(e,s),o.stroke(),o.endPath()}nc(t,i,e){if(!super.nc(t,i,e))return!1;if(this.wn(t,this.$i,!0,!1,this.naturalBounds,this.actualBounds),e){if(this.svg.getElementsByTagName("text").length===0)return!0;const n=this.svg.getElementsByClassName("gojs-td");for(let o=0;o1||this.isUnderline||this.isStrikethrough?!0:super.fd(t)}p2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("text");for(let s=0;sthis.maxLines&&(this.l|=16777216))}W2(t,i,e){const s=this.formatting===0;s&&(t=t.trim());let n=0,o=0,r=0;const l=this.Cn,h=this.spacingAbove+this.spacingBelow,a=Math.max(0,this.Op()+h),f=this.overflow===1?this.GL(l):0;if(this.Fe>=this.maxLines){e!==null&&e.e(0,a);return}let c=t;if(this.wrap===0){if(this.An=1,o=this.getStringWidth(t),f===0||o<=i){this.xi=Math.max(this.xi,o),this.Dn(t,this.xi),e!==null&&e.e(o,a);return}let d=this.Rd(c);c=c.substring(d.length);let m=this.Rd(c);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,c=c.substring(m.length),m=this.Rd(c),r=o;let g=d+m;s&&(g=g.trim()),o=this.getStringWidth(g)}for(s&&(m=m.trim()),d+=m,i=Math.max(1,i-f);this.getStringWidth(d)>i&&d.length>1;)d=d.substring(0,d.length-1);this.v2(!0),d+=TextBlock.Dp,r=this.getStringWidth(d),this.xi=r,this.Dn(d,r),e!==null&&e.e(r,a);return}let u=0;for(c.length===0&&(u=1,this.Dn(c,0));c.length>0;){let d=this.Rd(c);for(c=c.substring(d.length);this.getStringWidth(d)>i;){let p=1;for(o=this.getStringWidth(d.substring(0,p)),r=0;o<=i;)p++,r=o,o=this.getStringWidth(d.substring(0,p));let y=0;p===1?(y=o,n=Math.max(n,o)):(y=r,n=Math.max(n,r)),p--,p<1&&(p=1);const x=d.substring(0,p);if(this.Dn(x,y),u++,d=d.substring(p),this.Fe+u>this.maxLines)break}let m=this.Rd(c);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,c=c.substring(m.length),m=this.Rd(c),r=o;let p=d+m;s&&(p=p.trim()),o=this.getStringWidth(p)}if(s&&(d=d.trim()),d==="")continue;d[d.length-1]==="\xAD"&&(d=d.substring(0,d.length-1)+"\u2010");let g=0;if(m.length===0?(g=o,n=Math.max(n,o)):(r=this.getStringWidth(d),g=r,n=Math.max(n,r)),this.Dn(d,g),u++,this.Fe+u>this.maxLines)break}this.An=Math.min(this.maxLines,u),this.xi=Math.max(this.xi,n),e!==null&&e.e(this.xi,a*this.An)}EI(t,i){if(this.xi===0||this.Re===null||this.Oi===null||this.overflow!==1)return;const e=this.Cn,s=this.overflow===1?this.GL(e):0,n=this.spacingAbove+this.spacingBelow,o=Math.max(0,this.Op()+n),r=Math.min(this.maxLines-1,Math.max(Math.floor(i/o+.01)-1,0));if(r+1>=this.Oi.length)return;this.v2(!0);let l=this.Oi[r];const h=Math.max(1,t-s);for(;this.getStringWidth(l)>h&&l.length>1;)l=l.substring(0,l.length-1);l+=TextBlock.Dp;const a=this.getStringWidth(l);this.Oi[r]=l,this.Oi=this.Oi.slice(0,r+1),this.Re[r]=a,this.Re=this.Re.slice(0,r+1),this.An=this.Oi.length,this.xi=Math.max(this.xi,a),this.Fe=this.An,this.Fe===1&&(this.Ln=this.Oi[0])}Rd(t){if(this.wrap===3)return t.substring(0,1);let i=t.length,e=0;const s=TextBlock.VI;for(;e=t.length?t:t.substring(0,e)}getStringWidth(t){return TextBlock.rl===null?t.length*8:TextBlock.rl.measureText(t).width}Op(){if(this.co!==null)return this.co;const t=this.Cn;let i=0;return TextBlock.rl===null?(i=16,this.co=i,i):(TextBlock.J2[t]!==void 0&&TextBlock.HL<5e3?i=TextBlock.J2[t]:(i=TextBlock.rl.measureText("M").width*1.3,TextBlock.J2[t]=i,TextBlock.HL++),this.co=i,i)}GL(t){if(TextBlock.rl===null)return 6;let i=0;return TextBlock.ab[t]!==void 0&&TextBlock.j2<5e3?i=TextBlock.ab[t]:(i=TextBlock.rl.measureText(TextBlock.Dp).width,TextBlock.ab[t]=i,TextBlock.j2++),i}ub(t,i){return t.indexOf(` + or you could collect items to be removed from the collection after the iteration.`)}static ur(t,i){Util.n("No property to set for this enum value: "+i+" on "+t.toString())}static ht(t){root.console&&root.console.log(t)}static Mt(t){return typeof t=="object"&&t!==null}static Ug(t,i,e){Array.isArray(t)||Util.Bi(t,"Array",i,e)}static au(t,i,e){Array.isArray(t)?i>=t.length?t.push(e):t.splice(i,0,e):Util.n("Cannot insert an object into an HTMLCollection or NodeList: "+e+" at "+i)}static lf(t,i){Array.isArray(t)?i>=t.length?t.pop():t.splice(i,1):Util.n("Cannot remove an object from an HTMLCollection or NodeList at "+i)}static Ok=[];static at(){const t=Util.Ok.pop();return t===void 0?[]:t}static nt(t){t.length=0,Util.Ok.push(t)}static iE=Object.freeze([]);static hu(t){return t===null?"*":typeof t=="string"?t:typeof t=="function"?t.name:""}static hn(t){return typeof t=="function"?t.className?t.className:t.name:Util.Mt(t)&&t.constructor?Util.hn(t.constructor):typeof t}static Xh(t,i){return i==null||i===""?null:Util.Mt(t)&&i in t||t[i]?t[i]:null}static toString(t){let i=t;return Util.Mt(t)&&(t.text?i=t.text:t.name?i=t.name:t.key!==void 0?i=t.key:t.id!==void 0?i=t.id:t.constructor===Object&&(t.Text?i=t.Text:t.Name?i=t.Name:t.Key!==void 0?i=t.Key:t.Id!==void 0?i=t.Id:t.ID!==void 0&&(i=t.ID))),i===void 0?"undefined":i===null?"null":i.toString()}static yw(t,i){if(t.hasOwnProperty(i))return!0;let e=Object.getPrototypeOf(t);for(;e&&e!==Function;){if(e.hasOwnProperty(i))return!0;const s=e.eE;if(s&&s[i])return!0;e=Object.getPrototypeOf(e)}return!1}static OD(t){const i=[];let e=0;for(e=0;e<256;e++)i[e]=e;let s=0,n=0;for(e=0;e<256;e++)s=(s+i[e]+119)%256,n=i[e],i[e]=i[s],i[s]=n;e=0,s=0;let o="";for(let r=0;r>4)+i.charAt(r&15)]=String.fromCharCode(r);t.length%2&&(t="0"+t);const s=[];let n=0;for(let r=0;r0){const n=i[0];return this.key=0,this.value=n,n}else return null}any(t){const i=this.Qt;i.dr=null;const e=i.dt;this.Bt=-1;const s=i.h,n=s.length,o=this.Rs;for(let r=0;r=0?(this.key=i,this.value=t.h[i],!0):(this.wl(),!1)}hasNext(){return this.next()}first(){const t=this.Qt;this.vt=t.dt;const i=t.h,e=i.length-1;if(this.Bt=e,e>=0){const s=i[e];return this.key=e,this.value=s,s}else return null}any(t){const i=this.Qt;i.gr=null;const e=i.dt,s=i.h,n=s.length;this.Bt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(t(r))return!0;i.dt!==e&&Util.ze(i)}return!1}all(t){const i=this.Qt;i.gr=null;const e=i.dt,s=i.h,n=s.length;this.Bt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(!t(r))return!1;i.dt!==e&&Util.ze(i)}return!0}each(t){const i=this.Qt;i.gr=null;const e=i.dt,s=i.h,n=s.length;this.Bt=n;for(let o=n-1;o>=0;o--){const r=s[o];t(r),i.dt!==e&&Util.ze(i)}return this}map(t){const i=this.Qt;i.gr=null;const e=i.dt,s=[],n=i.h,o=n.length;this.Bt=o;for(let l=o-1;l>=0;l--){const h=n[l];s.push(t(h)),i.dt!==e&&Util.ze(i)}const r=new List;return r.h=s,r.Xe(),r.iterator}filter(t){const i=this.Qt;i.gr=null;const e=i.dt,s=[],n=i.h,o=n.length;this.Bt=o;for(let l=o-1;l>=0;l--){const h=n[l];t(h)&&s.push(h),i.dt!==e&&Util.ze(i)}const r=new List;return r.h=s,r.Xe(),r.iterator}get count(){return this.Qt.h.length}wl(){this.key=-1,this.value=null,this.vt=-1,this.Qt.gr=this}toString(){return"ListIteratorBackwards("+this.Bt+"/"+this.Qt.count+")"}}class List{f;h;dt;dr;gr;constructor(t){GSet.vi(this),this.f=!1,this.h=[],this.dt=0,this.dr=null,this.gr=null,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.h.values()}Xe(){let t=this.dt;t++,t>999999999&&(t=0),this.dt=t}w(){return this.f=!0,this}ft(){return this.f=!1,this}toString(){return"List()#"+GSet.gs(this)}add(t){return this.f&&Util.F(this,t),this.h.push(t),this.Xe(),this}push(t){this.add(t)}addAll(t){if(t===null)return this;this.f&&Util.F(this);const i=this.h;if(Array.isArray(t)){const e=t.length;for(let s=0;s=i.length)&&Util.G(t,"0 <= i < length",List,"elt:i"),i[t]}get(t){return this.elt(t)}setElt(t,i){Debug&&Util.r(t,List,"setElt:i");const e=this.h;(t<0||t>=e.length)&&Util.G(t,"0 <= i < length",List,"setElt:i"),this.f&&Util.F(this,t),e[t]=i}set(t,i){this.setElt(t,i)}first(){const t=this.h;return t.length===0?null:t[0]}last(){const t=this.h,i=t.length;return i>0?t[i-1]:null}pop(){this.f&&Util.F(this);const t=this.h;return t.length>0?t.pop():null}any(t){const i=this.h,e=this.dt,s=i.length;for(let n=0;n= 0",List,"insertAt:i"),this.f&&Util.F(this,t);const e=this.h;t>=e.length?e.push(i):e.splice(t,0,i),this.Xe()}remove(t){return this.delete(t)}delete(t){if(t===null)return!1;this.f&&Util.F(this,t);const i=this.h,e=i.indexOf(t);return e===-1?!1:(e===i.length-1?i.pop():i.splice(e,1),this.Xe(),!0)}removeAt(t){Debug&&Util.r(t,List,"removeAt:i");const i=this.h;(t<0||t>=i.length)&&Util.G(t,"0 <= i < length",List,"removeAt:i"),this.f&&Util.F(this,t),t===i.length-1?i.pop():i.splice(t,1),this.Xe()}removeRange(t,i){Debug&&(Util.r(t,List,"removeRange:from"),Util.r(i,List,"removeRange:to"));const e=this.h,s=e.length;if(t<0)t=0;else if(t>=s)return this;if(i<0)return this;if(i>=s&&(i=s-1),t>i)return this;this.f&&Util.F(this);let n=t,o=i+1;for(;o0&&(t.h=Array.prototype.slice.call(i)),t}toArray(){const t=this.h,i=this.count,e=new Array(i);for(let s=0;s=n-1)&&Util.G(i,"0 <= from < length",List,"sortRange:from"),o===2){const r=s[i],l=s[i+1];return t(r,l)>0&&(s[i]=l,s[i+1]=r,this.Xe()),this}if(i===0)if(e>=n)s.sort(t);else{const r=s.slice(0,e);r.sort(t);for(let l=0;l=n){const r=s.slice(i);r.sort(t);for(let l=i;li.add(t(e))),i.iterator}filter(t){const i=new List;return this.Ao.k.forEach(e=>{t(e)&&i.add(e)}),i.iterator}get count(){return this.Ao.count}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"SetIterator"}}class GSet{f;k;constructor(t){this.f=!1,this.k=new Set,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.k.values()}values(){return this.k.values()}w(){return this.f=!0,this}ft(){return this.f=!1,this}toString(){return"Set()#"+GSet.gs(this)}add(t){return t===null?this:(this.k.add(t),this)}addAll(t){if(t===null)return this;if(Array.isArray(t)){const i=t.length;for(let e=0;et.add(i)),t}toArray(){return Array.from(this.k)}toList(){const t=new List;return this.k.forEach(i=>t.add(i)),t}get count(){return this.k.size}get size(){return this.k.size}get iterator(){return this.k.size<=0?EmptyIterator.instance:new SetIterator(this)}entries(){return this.k.entries()}keys(){return this.k.keys()}forEach(t,i){return this.k.forEach(t,i)}static fu=1;static vi(t){t.__gohashid=GSet.fu++}static gs(t){return t.__gohashid}}class MapKeySetIterator{et;ri;constructor(t){this.et=t,this.ri=t.k.keys()}[Symbol.iterator](){return this.et.k.keys()}key;value;get iterator(){return this}reset(){const t=this.et;this.ri=t.k.keys()}next(){const t=this.ri.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.et.k.size===0?null:(this.ri=this.et.k.keys(),this.ri.next().value)}any(t){for(const i of this.et.k)if(t(i[0]))return!0;return!1}all(t){for(const i of this.et.k)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.et.k)t(i[0]);return this}map(t){const i=this.et,e=new List;for(const s of i.k)e.add(t(s[0]));return e.iterator}filter(t){const i=this.et,e=new List;for(const s of i.k){const n=s[0];t(n)&&e.add(n)}return e.iterator}get count(){return this.et.size}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"MapKeySetIterator"}}class MapKeySet extends GSet{et;constructor(t){super(),GSet.vi(this),this.f=!0,this.et=t}[Symbol.iterator](){return this.k.keys()}values(){return this.k.keys()}w(){return this}ft(){return this}toString(){return"MapKeySet("+this.et.toString()+")"}add(t){Util.n("This Set is read-only: "+this.toString())}has(t){return this.et.has(t)}contains(t){return this.has(t)}delete(t){Util.n("This Set is read-only: "+this.toString())}remove(t){return this.delete(t)}clear(){Util.n("This Set is read-only: "+this.toString())}first(){return this.et.k.size===0?null:this.et.k.keys().next().value}any(t){for(const i of this.et.k)if(t(i[0]))return!0;return!1}all(t){for(const i of this.et.k)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.et.k)t(i[0]);return this}map(t){const i=new GSet;for(const e of this.et.k)i.add(t(e[0]));return i}filter(t){const i=new GSet;for(const e of this.et.k){const s=e[0];t(s)&&i.add(s)}return i}copy(){return new MapKeySet(this.et)}toSet(){const t=new GSet,i=this.et.k;for(const e of i)t.add(e[0]);return t}toArray(){const t=this.et.k,i=new Array(t.size);let e=0;for(const s of t)i[e]=s[0],e++;return i}toList(){const t=new List,i=this.et.k;for(const e of i)t.add(e[0]);return t}get count(){return this.et.size}get size(){return this.et.size}get iterator(){return this.et.size<=0?EmptyIterator.instance:new MapKeySetIterator(this.et)}}class MapValueSetIterator{et;ri;constructor(t){this.et=t,this.ri=t.k.values()}[Symbol.iterator](){return this.et.k.values()}key;value;get iterator(){return this}reset(){const t=this.et;this.ri=t.k.values()}next(){const t=this.ri.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.et.k.size===0?null:(this.ri=this.et.k.values(),this.ri.next().value)}any(t){for(const i of this.et.k)if(t(i[1]))return!0;return!1}all(t){for(const i of this.et.k)if(!t(i[1]))return!1;return!0}each(t){for(const i of this.et.k)t(i[1]);return this}map(t){const i=this.et,e=new List;for(const s of i.k)e.add(t(s[1]));return e.iterator}filter(t){const i=this.et,e=new List;for(const s of i.k){const n=s[1];t(n)&&e.add(n)}return e.iterator}get count(){return this.et.size}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"MapValueSetIterator"}}class KeyValuePair{constructor(t,i){this.key=t,this.value=i}toString(){return"{"+this.key+":"+this.value+"}"}key;value}class MapIterator{et;ri;constructor(t){this.et=t,this.ri=t.k.entries()}[Symbol.iterator](){return this.et.k.entries()}key;value;get iterator(){return this}reset(){const t=this.et;this.ri=t.k.entries()}next(){const t=this.ri.next();return t.done?(this.key=null,this.value=null,!1):(this.key=t.value[0],this.value=t.value[1],!0)}hasNext(){return this.next()}first(){if(this.et.k.size===0)return null;this.ri=this.et.k.entries();const t=this.ri.next().value;return this.key=t[0],this.value=t[1],new KeyValuePair(t[0],t[1])}any(t){return this.et.any(t)}all(t){return this.et.all(t)}each(t){return this.et.each(t),this}map(t){const i=new List;let e=null;return this.et.k.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),i.add(t(e))}),i.iterator}filter(t){const i=new List;let e=null;return this.et.k.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),t(e)&&(i.add(e),e=null)}),i.iterator}get count(){return this.et.size}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"MapIterator"}}class GMap{f;k;constructor(t){GSet.vi(this),this.f=!1,this.k=new Map,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.k.entries()}entries(){return this.k.entries()}w(){return this.f=!0,this}ft(){return this.f=!1,this}toString(){return"Map()#"+GSet.gs(this)}set(t,i){return this.f&&Util.F(this,t),this.k.set(t,i),this}add(t,i){return this.set(t,i)}addAll(t){if(t===null)return this;if(this.f&&Util.F(this),Array.isArray(t)){const i=t.length;for(let e=0;ei.x.toFixed(t)+" "+i.y.toFixed(t)}toString(){return"Point("+this.x+","+this.y+")"}equals(t){return t instanceof Point?this.S===t.x&&this.P===t.y:!1}equalTo(t,i){return this.S===t&&this.P===i}equalsApprox(t){return Geo.p(this.S,t.x)&&Geo.p(this.P,t.y)}add(t){return Debug&&(Util.s(t,Point,Point,"add:p"),this.st()),this.S+=t.x,this.P+=t.y,this}subtract(t){return Debug&&(Util.s(t,Point,Point,"subtract:p"),this.st()),this.S-=t.x,this.P-=t.y,this}offset(t,i){return Debug&&(Util.r(t,Point,"offset:dx"),Util.r(i,Point,"offset:dy"),this.st()),this.S+=t,this.P+=i,this}rotate(t){if(Debug&&(Util.r(t,Point,"rotate:angle"),this.st()),t===0)return this;const i=this.S,e=this.P;if(i===0&&e===0)return this;let s=0,n=0;if(t>=360?t-=360:t<0&&(t+=360),t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const o=t*Math.PI/180;s=Math.cos(o),n=Math.sin(o)}return this.S=s*i-n*e,this.P=n*i+s*e,this}scale(t,i){return Debug&&(Util.r(t,Point,"scale:sx"),Util.r(i,Point,"scale:sy"),this.st()),this.S*=t,this.P*=i,this}distanceSquaredPoint(t){Debug&&Util.s(t,Point,Point,"distanceSquaredPoint:p");const i=t.x-this.S,e=t.y-this.P;return i*i+e*e}distanceSquared(t,i){Debug&&(Util.r(t,Point,"distanceSquared:px"),Util.r(i,Point,"distanceSquared:py"));const e=t-this.S,s=i-this.P;return e*e+s*s}normalize(){Debug&&this.st();const t=this.S,i=this.P,e=Math.sqrt(t*t+i*i);return e>0&&(this.S=t/e,this.P=i/e),this}directionPoint(t){return Debug&&Util.s(t,Point,Point,"directionPoint:p"),this.sC(t.x-this.S,t.y-this.P)}direction(t,i){return Debug&&(Util.r(t,Point,"direction:px"),Util.r(i,Point,"direction:py")),this.sC(t-this.S,i-this.P)}sC(t,i){if(t===0)return i>0?90:i<0?270:0;if(i===0)return t>0?0:180;{if(isNaN(t)||isNaN(i))return 0;let e=Math.atan(Math.abs(i/t))*180/Math.PI;return t<0?i<0?e+=180:e=180-e:i<0&&(e=360-e),e}}static compareWithLineSegment(t,i,e,s,n,o){return Debug&&(Util.r(t,Point,"compareWithLineSegment:a1x"),Util.r(i,Point,"compareWithLineSegment:a1y"),Util.r(e,Point,"compareWithLineSegment:a2x"),Util.r(s,Point,"compareWithLineSegment:a2y"),Util.r(n,Point,"compareWithLineSegment:b1x"),Util.r(o,Point,"compareWithLineSegment:b1y")),Geo.cu(t,i,e,s,n,o)}compareWithLineSegmentPoint(t,i){return Debug&&(Util.s(t,Point,Point,"compareWithLineSegmentPoint:p"),Util.s(i,Point,Point,"compareWithLineSegmentPoint:q")),Geo.cu(t.x,t.y,i.x,i.y,this.x,this.y)}static intersectingLineSegments(t,i,e,s,n,o,r,l){return Debug&&(Util.r(t,Point,"intersectingLineSegments:a1x"),Util.r(i,Point,"intersectingLineSegments:a1y"),Util.r(e,Point,"intersectingLineSegments:a2x"),Util.r(s,Point,"intersectingLineSegments:a2y"),Util.r(n,Point,"intersectingLineSegments:b1x"),Util.r(o,Point,"intersectingLineSegments:b1y"),Util.r(r,Point,"intersectingLineSegments:b2x"),Util.r(l,Point,"intersectingLineSegments:b2y")),Geo.uu(t,i,e,s,n,o,r,l)}projectOntoLineSegment(t,i,e,s){return Debug&&(Util.r(t,Point,"projectOntoLineSegment:px"),Util.r(i,Point,"projectOntoLineSegment:py"),Util.r(e,Point,"projectOntoLineSegment:qx"),Util.r(s,Point,"projectOntoLineSegment:qy")),Geo.xl(t,i,e,s,this.S,this.P,this),this}projectOntoLineSegmentPoint(t,i){return Debug&&(Util.s(t,Point,Point,"projectOntoLineSegmentPoint:p"),Util.s(i,Point,Point,"projectOntoLineSegmentPoint:q")),Geo.xl(t.x,t.y,i.x,i.y,this.S,this.P,this),this}snapToGrid(t,i,e,s){return Debug&&(Util.r(t,Point,"snapToGrid:originx"),Util.r(i,Point,"snapToGrid:originy"),Util.r(e,Point,"snapToGrid:cellwidth"),Util.r(s,Point,"snapToGrid:cellheight")),Geo.Gg(this.S,this.P,t,i,e,s,this),this}snapToGridPoint(t,i){return Debug&&(Util.s(t,Point,Point,"snapToGridPoint:p"),Util.s(i,Size,Point,"snapToGridPoint:q")),Geo.Gg(this.S,this.P,t.x,t.y,i.width,i.height,this),this}setRectSpot(t,i){return Debug&&(Util.s(t,Rect,Point,"setRectSpot:r"),Util.s(i,Spot,Point,"setRectSpot:spot"),this.st()),this.S=t.x+i.x*t.width+i.offsetX,this.P=t.y+i.y*t.height+i.offsetY,this}setSpot(t,i,e,s,n){return Debug&&(Util.r(t,Point,"setSpot:x"),Util.r(i,Point,"setSpot:y"),Util.r(e,Point,"setSpot:w"),Util.r(s,Point,"setSpot:h"),(e<0||s<0)&&Util.n("Point.setSpot:Width and height cannot be negative"),Util.s(n,Spot,Point,"setSpot:spot"),this.st()),this.S=t+n.x*e+n.offsetX,this.P=i+n.y*s+n.offsetY,this}O(t){return t.Pt(this),this}Ye(t){return t.ns(this),this}static distanceLineSegmentSquared(t,i,e,s,n,o){Debug&&(Util.r(t,Point,"distanceLineSegmentSquared:px"),Util.r(i,Point,"distanceLineSegmentSquared:py"),Util.r(e,Point,"distanceLineSegmentSquared:ax"),Util.r(s,Point,"distanceLineSegmentSquared:ay"),Util.r(n,Point,"distanceLineSegmentSquared:bx"),Util.r(o,Point,"distanceLineSegmentSquared:by"));let r=n-e,l=o-s;const h=r*r+l*l,a=e-t,f=s-i,c=-a*r-f*l;if(c<=0||c>=h)return r=n-t,l=o-i,Math.min(a*a+f*f,r*r+l*l);{const u=r*f-l*a;return u*u/h}}static distanceSquared(t,i,e,s){Debug&&(Util.r(t,Point,"distanceSquared:px"),Util.r(i,Point,"distanceSquared:py"),Util.r(e,Point,"distanceSquared:qx"),Util.r(s,Point,"distanceSquared:qy"));const n=e-t,o=s-i;return n*n+o*o}static direction(t,i,e,s){Debug&&(Util.r(t,Point,"direction:px"),Util.r(i,Point,"direction:py"),Util.r(e,Point,"direction:qx"),Util.r(s,Point,"direction:qy"));const n=e-t,o=s-i;if(n===0)return o>0?90:o<0?270:0;if(o===0)return n>0?0:180;{if(isNaN(n)||isNaN(o))return 0;let r=Math.atan(Math.abs(o/n))*180/Math.PI;return n<0?o<0?r+=180:r=180-r:o<0&&(r=360-r),r}}get x(){return this.S}set x(t){Debug&&(Util.t(t,"number",Point,"x"),this.st(t)),this.S=t}get y(){return this.P}set y(t){Debug&&(Util.t(t,"number",Point,"y"),this.st(t)),this.P=t}isReal(){return isFinite(this.x)&&isFinite(this.y)}static Lo=new Point(0,0).ot();static nC=new Point(-1/0,-1/0).ot();static oC=new Point(1/0,1/0).ot();static rC=new Point(6,6).ot();static Bk=new Point(NaN,NaN).ot();static Vk=[];static a(){const t=Point.Vk.pop();return t===void 0?new Point:t}static H(t,i){const e=Point.Vk.pop();return e===void 0?new Point(t,i):(e.x=t,e.y=i,e)}static o(t){Point.Vk.push(t)}}class Size{v;J;f;constructor(t,i){t===void 0?(this.v=0,this.J=0):typeof t=="number"&&(t>=0||isNaN(t))&&typeof i=="number"&&(i>=0||isNaN(i))?(this.v=t,this.J=i):Util.n("Invalid arguments to Size constructor: "+t+", "+i),this.f=!1}c(t){return this.v=t.v,this.J=t.J,this}e(t,i){return this.v=t,this.J=i,this}setTo(t,i){return Debug&&(Util.t(t,"number",Size,"setTo:w"),Util.t(i,"number",Size,"setTo:h"),t<0&&Util.G(t,">= 0",Size,"setTo:w"),i<0&&Util.G(i,">= 0",Size,"setTo:h"),this.st()),this.v=t,this.J=i,this}set(t){return Debug&&(Util.s(t,Size,Size,"set:s"),this.st()),this.v=t.v,this.J=t.J,this}copy(){const t=new Size;return t.v=this.v,t.J=this.J,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ft(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}st(t){if(Debug&&this.f){let i="The Size is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;return n=i[e++],n&&(o=parseFloat(n)),new Size(s,o)}else return new Size}static stringify(t){return Debug&&Util.s(t,Size),t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.t(t,"number",Size,"stringifyFixed:digits"),i=>i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Size("+this.width+","+this.height+")"}equals(t){return t instanceof Size?this.v===t.width&&this.J===t.height:!1}equalTo(t,i){return this.v===t&&this.J===i}equalsApprox(t){return Geo.p(this.v,t.width)&&Geo.p(this.J,t.height)}inflate(t,i){Debug&&(Util.r(t,Size,"inflate:w"),Util.r(i,Size,"inflate:h"));const e=this.width+t;this.v=e>=0?e:0;const s=this.height+i;return this.J=s>=0?s:0,this}get width(){return this.v}set width(t){Debug&&(Util.t(t,"number",Size,"width"),this.st(t)),t<0&&Util.G(t,">= 0",Size,"width"),this.v=t}get height(){return this.J}set height(t){Debug&&(Util.t(t,"number",Size,"height"),this.st(t)),t<0&&Util.G(t,">= 0",Size,"height"),this.J=t}isReal(){return isFinite(this.width)&&isFinite(this.height)}static hf=new Size(0,0).ot();static zk=new Size(1,1).ot();static lC=new Size(6,6).ot();static du=new Size(8,8).ot();static hC=new Size(10,10).ot();static Xk=new Size(1/0,1/0).ot();static xw=new Size(NaN,NaN).ot();static aC=[];static a(){const t=Size.aC.pop();return t===void 0?new Size:t}static o(t){Size.aC.push(t)}}class Rect{S;P;v;J;f;constructor(t,i,e,s){if(t===void 0)this.S=0,this.P=0,this.v=0,this.J=0;else if(typeof t=="number"&&typeof i=="number"&&typeof e=="number"&&(e>=0||isNaN(e))&&typeof s=="number"&&(s>=0||isNaN(s)))this.S=t,this.P=i,this.v=e,this.J=s;else if(t instanceof Point){const n=t.x,o=t.y;if(i instanceof Point){const r=i.x,l=i.y;this.S=Math.min(n,r),this.P=Math.min(o,l),this.v=Math.abs(n-r),this.J=Math.abs(o-l)}else i instanceof Size?(this.S=n,this.P=o,this.v=i.width,this.J=i.height):Util.n("Incorrect second argument supplied to Rect constructor "+i)}else Util.n("Invalid arguments to Rect constructor: "+t+", "+i+", "+e+", "+s);this.f=!1}c(t){return this.S=t.S,this.P=t.P,this.v=t.v,this.J=t.J,this}e(t,i,e,s){return this.S=t,this.P=i,this.v=e,this.J=s,this}Kn(t,i){return this.v=t,this.J=i,this}setTo(t,i,e,s){return Debug&&(Util.t(t,"number",Rect,"setTo:x"),Util.t(i,"number",Rect,"setTo:y"),Util.t(e,"number",Rect,"setTo:w"),Util.t(s,"number",Rect,"setTo:h"),e<0&&Util.G(e,">= 0",Rect,"setTo:w"),s<0&&Util.G(s,">= 0",Rect,"setTo:h"),this.st()),this.S=t,this.P=i,this.v=e,this.J=s,this}set(t){return Debug&&(Util.s(t,Rect,Rect,"set:r"),this.st()),this.S=t.S,this.P=t.P,this.v=t.v,this.J=t.J,this}setPoint(t){return Debug&&(Util.s(t,Point,Rect,"setPoint:p"),this.st()),this.S=t.x,this.P=t.y,this}setSize(t){return Debug&&(Util.s(t,Size,Rect,"setSize:s"),this.st()),this.v=t.width,this.J=t.height,this}copy(){const t=new Rect;return t.S=this.S,t.P=this.P,t.v=this.v,t.J=this.J,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ft(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}st(t){if(Debug&&this.f){let i="The Rect is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),new Rect(s,o,r,l)}else return new Rect}static stringify(t){return Debug&&Util.s(t,Rect),t.x.toString()+" "+t.y.toString()+" "+t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.t(t,"number",Rect,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Rect("+this.x+","+this.y+","+this.width+","+this.height+")"}equals(t){return t instanceof Rect?this.S===t.x&&this.P===t.y&&this.v===t.width&&this.J===t.height:!1}equalTo(t,i,e,s){return this.S===t&&this.P===i&&this.v===e&&this.J===s}equalsApprox(t){return Geo.p(this.S,t.x)&&Geo.p(this.P,t.y)&&Geo.p(this.v,t.width)&&Geo.p(this.J,t.height)}equalsApproxTo(t,i,e,s){return Geo.p(this.S,t)&&Geo.p(this.P,i)&&Geo.p(this.v,e)&&Geo.p(this.J,s)}equalsApproxClose(t){return Geo.q(this.S,t.x)&&Geo.q(this.P,t.y)&&Geo.q(this.v,t.width)&&Geo.q(this.J,t.height)}containsPoint(t){return Debug&&Util.s(t,Point,Rect,"containsPoint:p"),this.S<=t.x&&this.S+this.v>=t.x&&this.P<=t.y&&this.P+this.J>=t.y}containsRect(t){return Debug&&Util.s(t,Rect,Rect,"containsRect:r"),this.S<=t.x&&t.x+t.width<=this.S+this.v&&this.P<=t.y&&t.y+t.height<=this.P+this.J}contains(t,i,e,s){return Debug?(Util.r(t,Rect,"contains:x"),Util.r(i,Rect,"contains:y"),e===void 0?e=0:Util.r(e,Rect,"contains:w"),s===void 0?s=0:Util.r(s,Rect,"contains:h"),(e<0||s<0)&&Util.n("Rect.contains:Width and height cannot be negative")):(e===void 0&&(e=0),s===void 0&&(s=0)),this.S<=t&&t+e<=this.S+this.v&&this.P<=i&&i+s<=this.P+this.J}offset(t,i){return Debug&&(Util.r(t,Rect,"offset:dx"),Util.r(i,Rect,"offset:dy"),this.st()),this.S+=t,this.P+=i,this}inflate(t,i){return Debug&&(Util.r(t,Rect,"inflate:w"),Util.r(i,Rect,"inflate:h")),this.bw(i,t,i,t)}addMargin(t){return Debug&&Util.s(t,Margin,Rect,"addMargin:m"),this.bw(t.top,t.right,t.bottom,t.left)}subtractMargin(t){return Debug&&Util.s(t,Margin,Rect,"subtractMargin:m"),this.bw(-t.top,-t.right,-t.bottom,-t.left)}grow(t,i,e,s){return Debug&&(Util.r(t,Rect,"grow:t"),Util.r(i,Rect,"grow:r"),Util.r(e,Rect,"grow:b"),Util.r(s,Rect,"grow:l")),this.bw(t,i,e,s)}bw(t,i,e,s){Debug&&this.st();const n=this.v;i+s<=-n?(this.S+=n/2,this.v=0):(this.S-=s,this.v+=i+s);const o=this.J;return t+e<=-o?(this.P+=o/2,this.J=0):(this.P-=t,this.J+=t+e),this}intersectRect(t){return Debug&&Util.s(t,Rect,Rect,"intersectRect:r"),this.fC(t.x,t.y,t.width,t.height)}intersect(t,i,e,s){return Debug&&(Util.r(t,Rect,"intersect:x"),Util.r(i,Rect,"intersect:y"),Util.r(e,Rect,"intersect:w"),Util.r(s,Rect,"intersect:h"),(e<0||s<0)&&Util.n("Rect.intersect:Width and height cannot be negative")),this.fC(t,i,e,s)}fC(t,i,e,s){Debug&&this.st();const n=Math.max(this.S,t),o=Math.max(this.P,i),r=Math.min(this.S+this.v,t+e),l=Math.min(this.P+this.J,i+s);return this.S=n,this.P=o,this.v=Math.max(0,r-n),this.J=Math.max(0,l-o),this}intersectsRect(t){return Debug&&Util.s(t,Rect,Rect,"intersectsRect:r"),this.intersects(t.x,t.y,t.width,t.height)}intersects(t,i,e,s){Debug&&(Util.r(t,Rect,"intersects:x"),Util.r(i,Rect,"intersects:y"),Util.r(t,Rect,"intersects:w"),Util.r(i,Rect,"intersects:h"),(e<0||s<0)&&Util.n("Rect.intersects:Width and height cannot be negative"));let n=this.v;const o=this.S;if(n!==1/0&&e!==1/0&&(n+=o,e+=t,isNaN(e)||isNaN(n)||o>e||t>n))return!1;let r=this.J;const l=this.P;return!(r!==1/0&&s!==1/0&&(r+=l,s+=i,isNaN(s)||isNaN(r)||l>s||i>r))}intersectsRectPlus(t,i){let e=this.v,s=t.width+i+i;const n=this.S,o=t.x-i;if(e+=n,s+=o,n>s||o>e)return!1;let r=this.J,l=t.height+i+i;const h=this.P,a=t.y-i;return r+=h,l+=a,!(h>l||a>r)}unionPoint(t){return Debug&&Util.s(t,Point,Rect,"unionPoint:p"),this.unionNoCheck(t.x,t.y,0,0)}unionRect(t){return Debug&&Util.s(t,Rect,Rect,"unionRect:r"),this.unionNoCheck(t.S,t.P,t.v,t.J)}union(t,i,e,s){return Debug?(Util.r(t,Rect,"union:x"),Util.r(i,Rect,"union:y"),e===void 0?e=0:Util.r(e,Rect,"union:w"),s===void 0?s=0:Util.r(s,Rect,"union:h"),(e<0||s<0)&&Util.n("Rect.union:Width and height cannot be negative"),this.st()):(e===void 0&&(e=0),s===void 0&&(s=0)),this.unionNoCheck(t,i,e,s)}unionNoCheck(t,i,e,s){const n=Math.min(this.S,t),o=Math.min(this.P,i),r=Math.max(this.S+this.v,t+e),l=Math.max(this.P+this.J,i+s);return this.S=n,this.P=o,this.v=r-n,this.J=l-o,this}setSpot(t,i,e){return Debug&&(Util.r(t,Rect,"setSpot:x"),Util.r(i,Rect,"setSpot:y"),Util.s(e,Spot,Rect,"setSpot:spot"),this.st()),this.S=t-e.offsetX-e.x*this.v,this.P=i-e.offsetY-e.y*this.J,this}static contains(t,i,e,s,n,o,r,l){return Debug?(Util.r(t,Rect,"contains:rx"),Util.r(i,Rect,"contains:ry"),Util.r(e,Rect,"contains:rw"),Util.r(s,Rect,"contains:rh"),Util.r(n,Rect,"contains:x"),Util.r(o,Rect,"contains:y"),r===void 0?r=0:Util.r(r,Rect,"contains:w"),l===void 0?l=0:Util.r(l,Rect,"contains:h"),(e<0||s<0||r<0||l<0)&&Util.n("Rect.contains:Width and height cannot be negative")):(r===void 0&&(r=0),l===void 0&&(l=0)),t<=n&&n+r<=t+e&&i<=o&&o+l<=i+s}static intersects(t,i,e,s,n,o,r,l){Debug&&(Util.r(t,Rect,"intersects:rx"),Util.r(i,Rect,"intersects:ry"),Util.r(e,Rect,"intersects:rw"),Util.r(s,Rect,"intersects:rh"),Util.r(n,Rect,"intersects:x"),Util.r(o,Rect,"intersects:y"),Util.r(r,Rect,"intersects:w"),Util.r(l,Rect,"intersects:h"),(e<0||s<0||r<0||l<0)&&Util.n("Rect.intersects:Width and height cannot be negative"));let h=e,a=r;const f=t,c=n;if(h+=f,a+=c,f>a||c>h)return!1;let u=s,d=l;const m=i,g=o;return u+=m,d+=g,!(m>d||g>u)}static intersectsLineSegment(t,i,e,s,n,o,r,l){return Debug&&(Util.r(t,Rect,"intersectsLineSegment:x"),Util.r(i,Rect,"intersectsLineSegment:y"),Util.r(e,Rect,"intersectsLineSegment:w"),Util.r(s,Rect,"intersectsLineSegment:h"),Util.r(n,Rect,"intersectsLineSegment:p1x"),Util.r(o,Rect,"intersectsLineSegment:p1y"),Util.r(r,Rect,"intersectsLineSegment:p2x"),Util.r(l,Rect,"intersectsLineSegment:p2y"),(e<0||s<0)&&Util.n("Rect.intersectsLineSegment: width and height cannot be negative")),Geo.cC(t,i,e,s,n,o,r,l)}get x(){return this.S}set x(t){Debug&&(Util.t(t,"number",Rect,"x"),this.st(t)),this.S=t}get y(){return this.P}set y(t){Debug&&(Util.t(t,"number",Rect,"y"),this.st(t)),this.P=t}get width(){return this.v}set width(t){Debug&&(Util.t(t,"number",Rect,"width"),this.st(t)),t<0&&Util.G(t,">= 0",Rect,"width"),this.v=t}get height(){return this.J}set height(t){Debug&&(Util.t(t,"number",Rect,"height"),this.st(t)),t<0&&Util.G(t,">= 0",Rect,"height"),this.J=t}get left(){return this.S}set left(t){Debug&&(Util.t(t,"number",Rect,"left"),this.st(t)),this.S=t}get top(){return this.P}set top(t){Debug&&(Util.t(t,"number",Rect,"top"),this.st(t)),this.P=t}get right(){return this.S+this.v}set right(t){Debug&&(Util.r(t,Rect,"right"),this.st(t)),this.S+=t-(this.S+this.v)}get bottom(){return this.P+this.J}set bottom(t){Debug&&(Util.r(t,Rect,"top"),this.st(t)),this.P+=t-(this.P+this.J)}get position(){return new Point(this.S,this.P)}set position(t){Debug&&(Util.s(t,Point,Rect,"position"),this.st(t)),this.S=t.x,this.P=t.y}get size(){return new Size(this.v,this.J)}set size(t){Debug&&(Util.s(t,Size,Rect,"size"),this.st(t)),this.v=t.width,this.J=t.height}get center(){return new Point(this.S+this.v/2,this.P+this.J/2)}set center(t){Debug&&(Util.s(t,Point,Rect,"center"),this.st(t)),this.S=t.x-this.v/2,this.P=t.y-this.J/2}get centerX(){return this.S+this.v/2}set centerX(t){Debug&&(Util.r(t,Rect,"centerX"),this.st(t)),this.S=t-this.v/2}get centerY(){return this.P+this.J/2}set centerY(t){Debug&&(Util.r(t,Rect,"centerY"),this.st(t)),this.P=t-this.J/2}isReal(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)}isEmpty(){return this.width===0&&this.height===0}static kw=new Rect(0,0,0,0).ot();static BD=new Rect(NaN,NaN,NaN,NaN).ot();static Yk=[];static a(){const t=Rect.Yk.pop();return t===void 0?new Rect:t}static H(t,i,e,s){const n=Rect.Yk.pop();return n===void 0?new Rect(t,i,e,s):n.e(t,i,e,s)}static o(t){Rect.Yk.push(t)}}class Margin{an;fn;cn;un;f;constructor(t,i,e,s){t===void 0?(this.an=0,this.fn=0,this.cn=0,this.un=0):i===void 0?(i=t,e=t,s=t,this.top=t,this.right=i,this.bottom=e,this.left=s):e===void 0?(e=t,s=i,this.top=t,this.right=i,this.bottom=e,this.left=s):s!==void 0?(this.top=t,this.right=i,this.bottom=e,this.left=s):Util.n("Invalid arguments to Margin constructor: "+t+", "+i+", "+e+", "+s),this.f=!1}c(t){return this.an=t.an,this.fn=t.fn,this.cn=t.cn,this.un=t.un,this}setTo(t,i,e,s){return Debug&&(Util.t(t,"number",Margin,"setTo:t"),Util.t(i,"number",Margin,"setTo:r"),Util.t(e,"number",Margin,"setTo:b"),Util.t(s,"number",Margin,"setTo:l"),this.st()),this.an=t,this.fn=i,this.cn=e,this.un=s,this}set(t){return Debug&&(Util.s(t,Margin,Margin,"assign:m"),this.st()),this.an=t.an,this.fn=t.fn,this.cn=t.cn,this.un=t.un,this}copy(){const t=new Margin;return t.an=this.an,t.fn=this.fn,t.cn=this.cn,t.un=this.un,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ft(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}st(t){if(Debug&&this.f){let i="The Margin is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=NaN;for(;i[e]==="";)e++;let n=i[e++];if(n&&(s=parseFloat(n)),isNaN(s))return new Margin;let o=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(o=parseFloat(n)),isNaN(o))return new Margin(s);let r=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(r=parseFloat(n)),isNaN(r))return new Margin(s,o);let l=NaN;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),isNaN(l)?new Margin(s,o):new Margin(s,o,r,l)}else return new Margin}static stringify(t){return Debug&&Util.s(t,Margin),t.top.toString()+" "+t.right.toString()+" "+t.bottom.toString()+" "+t.left.toString()}static stringifyFixed(t){return Util.t(t,"number",Margin,"stringifyFixed:digits"),i=>i.top.toFixed(t)+" "+i.right.toFixed(t)+" "+i.bottom.toFixed(t)+" "+i.left.toFixed(t)}toString(){return"Margin("+this.top+","+this.right+","+this.bottom+","+this.left+")"}equals(t){return t instanceof Margin?this.an===t.top&&this.fn===t.right&&this.cn===t.bottom&&this.un===t.left:!1}equalTo(t,i,e,s){return this.an===t&&this.fn===i&&this.cn===e&&this.un===s}equalsApprox(t){return Geo.p(this.an,t.top)&&Geo.p(this.fn,t.right)&&Geo.p(this.cn,t.bottom)&&Geo.p(this.un,t.left)}get top(){return this.an}set top(t){Debug&&(Util.r(t,Margin,"top"),this.st(t)),this.an=t}get right(){return this.fn}set right(t){Debug&&(Util.r(t,Margin,"right"),this.st(t)),this.fn=t}get bottom(){return this.cn}set bottom(t){Debug&&(Util.r(t,Margin,"bottom"),this.st(t)),this.cn=t}get left(){return this.un}set left(t){Debug&&(Util.r(t,Margin,"left"),this.st(t)),this.un=t}isReal(){return isFinite(this.top)&&isFinite(this.right)&&isFinite(this.bottom)&&isFinite(this.left)}static Hg=new Margin(0,0,0,0).ot();static uC=new Margin(2,2,2,2).ot();static dC=[];static a(){const t=Margin.dC.pop();return t===void 0?new Margin:t}static o(t){Margin.dC.push(t)}}class Spot{S;P;Is;Os;f;constructor(t,i,e,s){t===void 0?(this.S=0,this.P=0,this.Is=0,this.Os=0):(i===void 0&&(i=0),e===void 0&&(e=0),s===void 0&&(s=0),this.x=t,this.y=i,this.offsetX=e,this.offsetY=s),this.f=!1}c(t){return this.S=t.S,this.P=t.P,this.Is=t.Is,this.Os=t.Os,this}setTo(t,i,e,s){return Debug&&(this.Sw(t,"setTo:x"),this.Sw(i,"setTo:y"),this.Mw(e,"setTo:offx"),this.Mw(s,"setTo:offy"),this.st()),this.S=t,this.P=i,this.Is=e,this.Os=s,this}set(t){return Debug&&(Util.s(t,Spot,Spot,"set:s"),this.st()),this.S=t.S,this.P=t.P,this.Is=t.Is,this.Os=t.Os,this}copy(){const t=new Spot;return t.S=this.S,t.P=this.P,t.Is=this.Is,t.Os=this.Os,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ft(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}st(t){if(Debug&&this.f){let i="The Spot is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}Ke(t){return this.S=NaN,this.P=NaN,this.Is=t,this}Sw(t,i){(isNaN(t)||t>1||t<0)&&Util.G(t,"0 <= "+i+" <= 1",Spot,i)}Mw(t,i){(isNaN(t)||t===1/0||t===-1/0)&&Util.G(t,"real number, not NaN or Infinity",Spot,i)}static parse(t){if(typeof t=="string"){if(t=t.trim(),t==="None")return Spot.None;if(t==="TopLeft")return Spot.TopLeft;if(t==="Top"||t==="TopCenter"||t==="MiddleTop")return Spot.TopCenter;if(t==="TopRight")return Spot.TopRight;if(t==="Left"||t==="LeftCenter"||t==="MiddleLeft")return Spot.LeftCenter;if(t==="Center")return Spot.Center;if(t==="Right"||t==="RightCenter"||t==="MiddleRight")return Spot.RightCenter;if(t==="BottomLeft")return Spot.BottomLeft;if(t==="Bottom"||t==="BottomCenter"||t==="MiddleBottom")return Spot.BottomCenter;if(t==="BottomRight")return Spot.BottomRight;if(t==="TopSide")return Spot.TopSide;if(t==="LeftSide")return Spot.LeftSide;if(t==="RightSide")return Spot.RightSide;if(t==="BottomSide")return Spot.BottomSide;if(t==="TopBottomSides")return Spot.TopBottomSides;if(t==="LeftRightSides")return Spot.LeftRightSides;if(t==="TopLeftSides")return Spot.TopLeftSides;if(t==="TopRightSides")return Spot.TopRightSides;if(t==="BottomLeftSides")return Spot.BottomLeftSides;if(t==="BottomRightSides")return Spot.BottomRightSides;if(t==="NotTopSide")return Spot.NotTopSide;if(t==="NotLeftSide")return Spot.NotLeftSide;if(t==="NotRightSide")return Spot.NotRightSide;if(t==="NotBottomSide")return Spot.NotBottomSide;if(t==="AllSides")return Spot.AllSides;if(t==="Default")return Spot.Default;const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n!==void 0&&n.length>0&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n!==void 0&&n.length>0&&(l=parseFloat(n)),new Spot(s,o,r,l)}else return new Spot}static stringify(t){return Debug&&Util.s(t,Spot),t.isSpot()?t.x.toString()+" "+t.y.toString()+" "+t.offsetX.toString()+" "+t.offsetY.toString():t.toString()}static stringifyFixed(t){return Util.t(t,"number",Spot,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.offsetX.toFixed(t)+" "+i.offsetY.toFixed(t)}toString(){return this.isSpot()?this.Is===0&&this.Os===0?"Spot("+this.x+","+this.y+")":"Spot("+this.x+","+this.y+","+this.offsetX+","+this.offsetY+")":this.equals(Spot.None)?"None":this.equals(Spot.TopLeft)?"TopLeft":this.equals(Spot.TopCenter)?"Top":this.equals(Spot.TopRight)?"TopRight":this.equals(Spot.LeftCenter)?"Left":this.equals(Spot.Center)?"Center":this.equals(Spot.RightCenter)?"Right":this.equals(Spot.BottomLeft)?"BottomLeft":this.equals(Spot.BottomCenter)?"Bottom":this.equals(Spot.BottomRight)?"BottomRight":this.equals(Spot.TopSide)?"TopSide":this.equals(Spot.LeftSide)?"LeftSide":this.equals(Spot.RightSide)?"RightSide":this.equals(Spot.BottomSide)?"BottomSide":this.equals(Spot.TopBottomSides)?"TopBottomSides":this.equals(Spot.LeftRightSides)?"LeftRightSides":this.equals(Spot.TopLeftSides)?"TopLeftSides":this.equals(Spot.TopRightSides)?"TopRightSides":this.equals(Spot.BottomLeftSides)?"BottomLeftSides":this.equals(Spot.BottomRightSides)?"BottomRightSides":this.equals(Spot.NotTopSide)?"NotTopSide":this.equals(Spot.NotLeftSide)?"NotLeftSide":this.equals(Spot.NotRightSide)?"NotRightSide":this.equals(Spot.NotBottomSide)?"NotBottomSide":this.equals(Spot.AllSides)?"AllSides":this.equals(Spot.Default)?"Default":"None"}equals(t){return t instanceof Spot?(this.S===t.x||isNaN(this.S)&&isNaN(t.x))&&(this.P===t.y||isNaN(this.P)&&isNaN(t.y))&&this.Is===t.offsetX&&this.Os===t.offsetY:!1}opposite(){return new Spot(.5-(this.S-.5),.5-(this.P-.5),-this.Is,-this.Os)}includesSide(t){if(!this.isSide())return!1;if(!t.isSide())if(t.equals(Spot.Left))t=Spot.LeftSide;else if(t.equals(Spot.Right))t=Spot.RightSide;else if(t.equals(Spot.Top))t=Spot.TopSide;else if(t.equals(Spot.Bottom))t=Spot.BottomSide;else return!1;const i=this.Os,e=t.offsetY;return(i&e)===e}get x(){return this.S}set x(t){Debug&&(this.Sw(t,"x"),this.st(t)),this.S=t}get y(){return this.P}set y(t){Debug&&(this.Sw(t,"y"),this.st(t)),this.P=t}get offsetX(){return this.Is}set offsetX(t){Debug&&(this.Mw(t,"offsetX"),this.st(t)),this.Is=t}get offsetY(){return this.Os}set offsetY(t){Debug&&(this.Mw(t,"offsetY"),this.st(t)),this.Os=t}isSpot(){return!isNaN(this.x)&&!isNaN(this.y)}isNoSpot(){return isNaN(this.x)||isNaN(this.y)}isSide(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===1&&this.offsetY!==0}isNone(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===0&&this.offsetY===0}isDefault(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===-1&&this.offsetY===0}static None=new Spot(0,0,0,0).Ke(0).ot();static Default=new Spot(0,0,-1,0).Ke(-1).ot();static TopLeft=new Spot(0,0,0,0).ot();static TopCenter=new Spot(.5,0,0,0).ot();static TopRight=new Spot(1,0,0,0).ot();static LeftCenter=new Spot(0,.5,0,0).ot();static Center=new Spot(.5,.5,0,0).ot();static RightCenter=new Spot(1,.5,0,0).ot();static BottomLeft=new Spot(0,1,0,0).ot();static BottomCenter=new Spot(.5,1,0,0).ot();static BottomRight=new Spot(1,1,0,0).ot();static MiddleTop=Spot.TopCenter;static MiddleLeft=Spot.LeftCenter;static MiddleRight=Spot.RightCenter;static MiddleBottom=Spot.BottomCenter;static Top=Spot.TopCenter;static Left=Spot.LeftCenter;static Right=Spot.RightCenter;static Bottom=Spot.BottomCenter;static TopSide=new Spot(0,0,1,1).Ke(1).ot();static LeftSide=new Spot(0,0,1,2).Ke(1).ot();static RightSide=new Spot(0,0,1,4).Ke(1).ot();static BottomSide=new Spot(0,0,1,8).Ke(1).ot();static TopBottomSides=new Spot(0,0,1,9).Ke(1).ot();static LeftRightSides=new Spot(0,0,1,6).Ke(1).ot();static TopLeftSides=new Spot(0,0,1,3).Ke(1).ot();static TopRightSides=new Spot(0,0,1,5).Ke(1).ot();static BottomLeftSides=new Spot(0,0,1,10).Ke(1).ot();static BottomRightSides=new Spot(0,0,1,12).Ke(1).ot();static NotTopSide=new Spot(0,0,1,14).Ke(1).ot();static NotLeftSide=new Spot(0,0,1,13).Ke(1).ot();static NotRightSide=new Spot(0,0,1,11).Ke(1).ot();static NotBottomSide=new Spot(0,0,1,7).Ke(1).ot();static AllSides=new Spot(0,0,1,15).Ke(1).ot();static Kk=new Spot(.156,.156).ot();static Uk=new Spot(.844,.844).ot();static gC=[];static a(){const t=Spot.gC.pop();return t===void 0?new Spot:t}static o(t){Spot.gC.push(t)}}class Transform{m11;m12;m21;m22;dx;dy;constructor(){this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0}set(t){return this.m11=t.m11,this.m12=t.m12,this.m21=t.m21,this.m22=t.m22,this.dx=t.dx,this.dy=t.dy,this}setTo(t,i,e,s,n,o){return this.m11=t,this.m12=i,this.m21=e,this.m22=s,this.dx=n,this.dy=o,this}copy(){const t=new Transform;return t.m11=this.m11,t.m12=this.m12,t.m21=this.m21,t.m22=this.m22,t.dx=this.dx,t.dy=this.dy,t}toString(){return"Transform("+this.m11+","+this.m12+","+this.m21+","+this.m22+","+this.dx+","+this.dy+")"}equals(t){return this.m11===t.m11&&this.m12===t.m12&&this.m21===t.m21&&this.m22===t.m22&&this.dx===t.dx&&this.dy===t.dy}Gk(){return this.dx===0&&this.dy===0&&this.m11===1&&this.m12===0&&this.m21===0&&this.m22===1}Vi(){return this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0,this}af(t){const i=this.m11*t.m11+this.m21*t.m12,e=this.m12*t.m11+this.m22*t.m12,s=this.m11*t.m21+this.m21*t.m22,n=this.m12*t.m21+this.m22*t.m22;return this.dx=this.m11*t.dx+this.m21*t.dy+this.dx,this.dy=this.m12*t.dx+this.m22*t.dy+this.dy,this.m11=i,this.m12=e,this.m21=s,this.m22=n,this}mC(t){const i=1/(t.m11*t.m22-t.m12*t.m21),e=t.m22*i,s=-t.m12*i,n=-t.m21*i,o=t.m11*i,r=i*(t.m21*t.dy-t.m22*t.dx),l=i*(t.m12*t.dx-t.m11*t.dy),h=this.m11*e+this.m21*s,a=this.m12*e+this.m22*s,f=this.m11*n+this.m21*o,c=this.m12*n+this.m22*o;return this.dx=this.m11*r+this.m21*l+this.dx,this.dy=this.m12*r+this.m22*l+this.dy,this.m11=h,this.m12=a,this.m21=f,this.m22=c,this}Pw(){const t=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*t,e=-this.m12*t,s=-this.m21*t,n=this.m11*t,o=t*(this.m21*this.dy-this.m22*this.dx),r=t*(this.m12*this.dx-this.m11*this.dy);return this.m11=i,this.m12=e,this.m21=s,this.m22=n,this.dx=o,this.dy=r,this}ms(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return this;this.Es(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m11*s+this.m21*n,r=this.m12*s+this.m22*n,l=this.m11*-n+this.m21*s,h=this.m12*-n+this.m22*s;return this.m11=o,this.m12=r,this.m21=l,this.m22=h,this.Es(-i,-e),this}Es(t,i){return this.dx+=this.m11*t+this.m21*i,this.dy+=this.m12*t+this.m22*i,this}rt(t,i){return i===void 0&&(i=t),this.m11*=t,this.m12*=t,this.m21*=i,this.m22*=i,this}VD(){if(this.m11===1&&this.m12===0)return 0;let t=Math.atan2(this.m12,this.m11)*180/Math.PI;return t<0&&(t+=360),t}Pt(t){const i=t.x,e=t.y;return t.e(i*this.m11+e*this.m21+this.dx,i*this.m12+e*this.m22+this.dy)}ns(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=t.x-this.dx,l=t.y-this.dy;return t.e(r*e+l*n,r*s+l*o)}Nw(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=i*(this.m21*this.dy-this.m22*this.dx),l=i*(this.m12*this.dx-this.m11*this.dy),h=t.x*1.25,a=t.y*1.2;return t.e(h*e+a*n+r,h*s+a*o+l)}Cw(t){const i=t.x,e=t.y,s=i+t.width,n=e+t.height,o=this.m11,r=this.m12,l=this.m21,h=this.m22,a=this.dx,f=this.dy,c=i*o+e*l+a,u=i*r+e*h+f,d=s*o+e*l+a,m=s*r+e*h+f,g=i*o+n*l+a,p=i*r+n*h+f,y=s*o+n*l+a,x=s*r+n*h+f;let k=c,b=c,S=u,M=u;return k=Math.min(k,d),b=Math.max(b,d),S=Math.min(S,m),M=Math.max(M,m),k=Math.min(k,g),b=Math.max(b,g),S=Math.min(S,p),M=Math.max(M,p),k=Math.min(k,y),b=Math.max(b,y),S=Math.min(S,x),M=Math.max(M,x),t.e(k,S,b-k,M-S),t}static pC=[];static a(){const t=Transform.pC.pop();return t===void 0?new Transform:t}static o(t){Transform.pC.push(t)}static Hk="54a702f3e53909c447824c6706603faf4c"}const Geo={zD:"7da71ca0ad381e90",Un:4*((Math.sqrt(2)-1)/3),yC:null,Aw:w=>{if(w<=0)return 0;let t=Geo.yC;if(t===null){t=[];for(let i=0;i<=2e3;i++)t[i]=Math.sqrt(i);Geo.yC=t}if(w<1){const i=1/w;return i<=2e3?1/t[i|0]:Math.sqrt(w)}else return w<=2e3?t[w|0]:Math.sqrt(w)},p:(w,t)=>{const i=w-t;return i<.5&&i>-.5},q:(w,t)=>{const i=w-t;return i<5e-8&&i>-5e-8},zi:(w,t,i,e,s,n,o)=>{s<=0&&(s=1e-6);let r=0,l=0,h=0,a=0;if(wu-d)if(w-i>s||i-w>s){const g=(e-t)/(i-w)*(n-w)+t;if(g-s<=o&&o<=g+s)return!0}else return!0;else if(t-e>s||e-t>s){const g=(i-w)/(e-t)*(o-t)+w;if(g-s<=n&&n<=g+s)return!0}else return!0}return!1},Lw:(w,t,i,e,s,n,o,r,l,h,a,f)=>{if(!Geo.zi(w,t,o,r,f,i,e)||!Geo.zi(w,t,o,r,f,s,n)){const c=(w+i)/2,u=(t+e)/2,d=(i+s)/2,m=(e+n)/2,g=(s+o)/2,p=(n+r)/2,y=(c+d)/2,x=(u+m)/2,k=(d+g)/2,b=(m+p)/2,S=(y+k)/2,M=(x+b)/2;return Geo.Lw(w,t,c,u,y,x,S,M,l,h,a,f)||Geo.Lw(S,M,k,b,g,p,o,r,l,h,a,f)}else return Geo.zi(w,t,o,r,f,h,a)},wC:(w,t,i,e,s,n,o,r,l)=>{const h=(w+i)/2,a=(t+e)/2,f=(i+s)/2,c=(e+n)/2,u=(s+o)/2,d=(n+r)/2,m=(h+f)/2,g=(a+c)/2,p=(f+u)/2,y=(c+d)/2;return l.e((m+p)/2,(g+y)/2),l},XD:(w,t,i,e,s,n,o,r)=>{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,f=(e+n)/2,c=(s+o)/2,u=(n+r)/2,d=(l+a)/2,m=(h+f)/2,g=(a+c)/2,p=(f+u)/2;return Point.direction(d,m,g,p)},gu:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.zi(w,t,o,r,l,i,e)||!Geo.zi(w,t,o,r,l,s,n)){const a=(w+i)/2,f=(t+e)/2,c=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+c)/2,p=(f+u)/2,y=(c+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.gu(w,t,a,f,g,p,k,b,l,h),Geo.gu(k,b,y,x,d,m,o,r,l,h)}else h.unionNoCheck(w,t,0,0),h.unionNoCheck(o,r,0,0);return h},Gn:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.zi(w,t,o,r,l,i,e)||!Geo.zi(w,t,o,r,l,s,n)){const a=(w+i)/2,f=(t+e)/2,c=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+c)/2,p=(f+u)/2,y=(c+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.Gn(w,t,a,f,g,p,k,b,l,h),Geo.Gn(k,b,y,x,d,m,o,r,l,h)}else h.length===0&&(h.push(w),h.push(t)),h.push(o),h.push(r);return h},qk:(w,t,i,e,s,n,o,r,l,h)=>{if(Geo.zi(w,t,s,n,h,i,e))return Geo.zi(w,t,s,n,h,r,l);{const a=(w+i)/2,f=(t+e)/2,c=(i+s)/2,u=(e+n)/2,d=(a+c)/2,m=(f+u)/2;return Geo.qk(w,t,a,f,d,m,o,r,l,h)||Geo.qk(d,m,c,u,s,n,o,r,l,h)}},sE:(w,t,i,e,s,n,o)=>{const r=(w+i)/2,l=(t+e)/2,h=(i+s)/2,a=(e+n)/2;return o.e((r+h)/2,(l+a)/2),o},jk:(w,t,i,e,s,n,o,r)=>{if(Geo.zi(w,t,s,n,o,i,e))r.unionNoCheck(w,t,0,0),r.unionNoCheck(s,n,0,0);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,f=(e+n)/2,c=(l+a)/2,u=(h+f)/2;Geo.jk(w,t,l,h,c,u,o,r),Geo.jk(c,u,a,f,s,n,o,r)}return r},qg:(w,t,i,e,s,n,o,r)=>{if(Geo.zi(w,t,s,n,o,i,e))r.length===0&&(r.push(w),r.push(t)),r.push(s),r.push(n);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,f=(e+n)/2,c=(l+a)/2,u=(h+f)/2;Geo.qg(w,t,l,h,c,u,o,r),Geo.qg(c,u,a,f,s,n,o,r)}return r},jg:(w,t,i,e,s,n,o,r,l,h,a,f,c,u)=>{if(!Geo.zi(w,t,o,r,c,i,e)||!Geo.zi(w,t,o,r,c,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,S=(g+y)/2,M=(p+x)/2,A=(k+S)/2,C=(b+M)/2;let P=1/0,N=!1,T=0,L=0;if(Geo.jg(w,t,d,m,k,b,A,C,l,h,a,f,c,u)){const D=(u.x-l)*(u.x-l)+(u.y-h)*(u.y-h);D{let u=0;if(!Geo.zi(w,t,o,r,c,i,e)||!Geo.zi(w,t,o,r,c,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,S=(g+y)/2,M=(p+x)/2,A=(k+S)/2,C=(b+M)/2;u+=Geo.Wg(w,t,d,m,k,b,A,C,l,h,a,f,c),u+=Geo.Wg(A,C,S,M,y,x,o,r,l,h,a,f,c)}else{const d=(w-o)*(h-f)-(t-r)*(l-a);if(d===0)return u;const m=((w*r-t*o)*(l-a)-(w-o)*(l*f-h*a))/d,g=((w*r-t*o)*(h-f)-(t-r)*(l*f-h*a))/d;if(m>=a)return u;let p=0,y=0;if((l>a?l-a:a-l)<(h>f?h-f:f-h)){if(ty)return u}else if(wy)return u;d>0?u++:d<0&&u--}return u},xl:(w,t,i,e,s,n,o)=>{if(Geo.q(w,i)){let r=0,l=0;tl?(o.e(w,l),!1):(o.e(w,h),!0)}else if(Geo.q(t,e)){let r=0,l=0;wl?(o.e(l,t),!1):(o.e(h,t),!0)}else{const r=(i-w)*(i-w)+(e-t)*(e-t),l=((w-s)*(w-i)+(t-n)*(t-e))/r;if(l<-5e-6)return o.e(w,t),!1;if(l>1.000005)return o.e(i,e),!1;{const h=w+l*(i-w),a=t+l*(e-t);return o.e(h,a),!0}}},Hn:(w,t,i,e,s,n,o,r,l)=>{if(Geo.p(w,i)&&Geo.p(t,e))return l.e(w,t),!1;if(Geo.q(s,o)){if(Geo.q(w,i))return Geo.xl(w,t,i,e,s,n,l),!1;{const a=(e-t)/(i-w)*(s-w)+t;return Geo.xl(w,t,i,e,s,a,l)}}else{const h=(r-n)/(o-s);if(Geo.q(w,i)){const a=h*(w-s)+n;let f=0,c=0;return tc?(l.e(w,c),!1):(l.e(w,a),!0)}else{const a=(e-t)/(i-w);if(Geo.q(h,a))return Geo.xl(w,t,i,e,s,n,l),!1;{const f=(a*w-h*s+n-t)/(a-h);if(Geo.q(a,0)){let c=0,u=0;return wu?(l.e(u,t),!1):(l.e(f,t),!0)}else{const c=a*(f-w)+t;return Geo.xl(w,t,i,e,f,c,l)}}}}},nE:(w,t,i,e,s)=>Geo.Hn(i.x,i.y,e.x,e.y,w.x,w.y,t.x,t.y,s),oE:(w,t,i,e,s,n,o,r,l,h)=>{let a=1/0;function f(S,M){const A=(S-w)*(S-w)+(M-t)*(M-t);Aw?i-w:w-i)<.5){const S=1-(i-k)*(i-k)/(y*y);if(S<0)return l;const M=Math.sqrt(S),A=x*M+b,C=-x*M+b;f(i,A),f(i,C)}else{const S=(e-t)/(i-w),M=1/(y*y)+S*S/(x*x),A=2*S*(t-S*w)/(x*x)-2*S*b/(x*x)-2*k/(y*y),C=2*S*w*b/(x*x)-2*t*b/(x*x)+b*b/(x*x)+k*k/(y*y)-1+(t-S*w)*(t-S*w)/(x*x),P=A*A-4*M*C;if(P<0)return l;const N=Math.sqrt(P),T=(-A+N)/(2*M);f(T,S*T-S*w+t);const L=(-A-N)/(2*M);f(L,S*L-S*w+t)}return l},bl:(w,t,i,e,s,n,o,r,l)=>{let h=1e21,a=w,f=t;if(Geo.Hn(w,t,w,e,s,n,o,r,l)){const c=(l.x-s)*(l.x-s)+(l.y-n)*(l.y-n);cGeo.cC(w.x,w.y,w.width,w.height,t.x,t.y,i.x,i.y),cC:(w,t,i,e,s,n,o,r)=>{const l=w,h=w+i,a=t,f=t+e;if(s===o){let c=0,u=0;return n=a}if(n===r){let c=0,u=0;return s=l}return!!(Rect.contains(w,t,i,e,s,n)||Rect.contains(w,t,i,e,o,r)||Geo.uu(l,a,h,a,s,n,o,r)||Geo.uu(h,a,h,f,s,n,o,r)||Geo.uu(h,f,l,f,s,n,o,r)||Geo.uu(l,f,l,a,s,n,o,r))},uu:(w,t,i,e,s,n,o,r)=>w===i&&t===e&&s===o&&n===r?w===s&&t===n:Geo.cu(w,t,i,e,s,n)*Geo.cu(w,t,i,e,o,r)<=0&&Geo.cu(s,n,o,r,w,t)*Geo.cu(s,n,o,r,i,e)<=0,cu:(w,t,i,e,s,n)=>{const o=i-w,r=e-t;let l=s-w,h=n-t,a=l*r-h*o;return a===0&&(a=l*o+h*r,a>0&&(l-=o,h-=r,a=l*o+h*r,a<0&&(a=0))),a},vg:w=>(w<0&&(w+=360),w>=360&&(w-=360),w),xC:(w,t,i,e,s,n)=>{const o=Math.PI;n||(e=e*(o/180),s=s*(o/180));const r=e>s?-1:1,l=1e-5,h=o*2,a=[],f=o/2;let c=e,u=Math.min(h,Math.abs(s-e));if(ul;){const d=c+r*Math.min(u,f);a.push(Geo.YD(i,c,d,w,t)),u-=Math.abs(d-c),c=d}return a},YD:(w,t,i,e,s)=>{const n=(i-t)/2,o=w*Math.cos(n),r=w*Math.sin(n),l=o,h=-r,a=l*l+h*h,f=a+l*o+h*r,c=4/3*(Math.sqrt(2*a*f)-f)/(l*r-h*o),u=l-c*h,d=h+c*l,m=u,g=-d,p=n+t,y=Math.cos(p),x=Math.sin(p);return[e+w*Math.cos(t),s+w*Math.sin(t),e+u*y-d*x,s+u*x+d*y,e+m*y-g*x,s+m*x+g*y,e+w*Math.cos(i),s+w*Math.sin(i)]},Gg:(w,t,i,e,s,n,o)=>{const r=s,l=n,h=Math.floor((w-i)/r)*r+i,a=Math.floor((t-e)/l)*l+e;let f=h;h+r-w{let i=Math.max(w,t),e=Math.min(w,t),s=1,n=1;do s=i%e,n=e,i=e,e=s;while(s>0);return n},KD:(w,t,i,e)=>{const s=i<0,n=e<0;let o=0,r=0,l=0;w{let o=0;if(e>0)if(i>0){const r=w*w,l=t*t,h=w*i,a=t*e;let f=-l+a,c=-l+Math.sqrt(h*h+a*a),u=f;const d=9999999999;for(let p=0;p0)f=u;else if(k<0)c=u;else break}s=r*i/(u+r),n=l*e/(u+l);const m=s-i,g=n-e;o=Math.sqrt(m*m+g*g)}else s=0,n=t,o=Math.abs(e-t);else{const r=w*w-t*t,l=w*i;if(l(w[w.Line=1]="Line",w[w.Rectangle=2]="Rectangle",w[w.Ellipse=3]="Ellipse",w[w.Path=4]="Path",w))(GeometryType||{}),GeometryStretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w))(GeometryStretch||{});class Geometry{l;$g;Qg;ff;mu;pu;jn;Wn;vn;it;Pe;Ne;se;ne;Bs;cf;uf;constructor(t){Debug&&arguments.length>1&&Util.n("Geometry constructor can take at most one optional argument, the Geometry type."),GSet.vi(this),this.l=2,t===void 0?t=4:Debug&&Util.tt(t,GeometryType,"GeometryType"),this.it=t,this.Pe=0,this.Ne=0,this.se=0,this.ne=0,t===4?this.Bs=new List:this.Bs=Geometry.Dw,this.$g=this.Bs.dt,this.Qg=new Rect().w(),this.ff=null,this.mu=null,this.pu=NaN,this.jn=Spot.TopLeft,this.Wn=Spot.BottomRight,this.cf=NaN,this.uf=NaN,this.vn=2}copy(){const t=new Geometry;if(t.l=this.l&-2,t.it=this.it,t.Pe=this.Pe,t.Ne=this.Ne,t.se=this.se,t.ne=this.ne,this.it===4){const i=this.Bs.h,e=t.Bs;for(let s=0;si.toString(t)}fi(t){t in GeometryType?this.type=t:Util.ur(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e;switch(this.type){case 1:return t<0?"M"+this.startX.toString()+" "+this.startY.toString()+"L"+this.endX.toString()+" "+this.endY.toString():"M"+i(this.startX)+" "+i(this.startY)+"L"+i(this.endX)+" "+i(this.endY);case 2:return e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0?"M"+e.x.toString()+" "+e.y.toString()+"H"+e.right.toString()+"V"+e.bottom.toString()+"H"+e.left.toString()+"z":"M"+i(e.x)+" "+i(e.y)+"H"+i(e.right)+"V"+i(e.bottom)+"H"+i(e.left)+"z";case 3:if(e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0){const r=e.left.toString()+" "+(e.y+e.height/2).toString(),l=e.right.toString()+" "+(e.y+e.height/2).toString();return"M"+r+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+l+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+r}else{const r=i(e.left)+" "+i(e.y+e.height/2),l=i(e.right)+" "+i(e.y+e.height/2);return"M"+r+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+l+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+r}case 4:let s="";const n=this.figures.h,o=n.length;for(let r=0;r0&&(s+=" x "),l.isFilled&&(s+="F "),s+=l.toString(t)}return s;default:return GeometryType[this.type]}}static fillPath(t){typeof t!="string"&&Util.Bi(t,"string",Geometry,"fillPath:str");const i=t.split(/[Xx]/),e=i.length;let s="";for(let n=0;n=k-1||o[r+1].match(N)!==null?!0:(u=!1,!1)}function m(){return r++,o[r]}function g(L){let D=parseFloat(m()),F=parseFloat(m());l===l.toLowerCase()&&(D=c.x+D,F=c.y+F),L.e(D,F)}function p(){return g(c),c}function y(){return g(f),f}function x(){const L=h.toLowerCase();return L==="c"||L==="s"||L==="q"||L==="t"?new Point(2*c.x-f.x,2*c.y-f.y):new Point(c.x,c.y)}const k=o.length,b=GeoStream.SC(null);let S=!1,M=!1,A=!1,C=!0,P=null;const N=new RegExp("["+Geometry._g+"]");for(;!(r>=k-1);){if(h=l,l=m(),l==="")continue;u=!0;let L=!1;switch(l.toUpperCase()){case"X":C=!0,S=!1,M=!1;break;case"M":for(P=p(),b.Ci===null||C===!0?(b.yu(P.x,P.y,S,!1,!M,A),C=!1):b.GD(P.x,P.y),a.c(c);!d();)P=p(),b.yr(P.x,P.y);break;case"L":for(;!d();)P=p(),b.yr(P.x,P.y);u&&(L=!0);break;case"H":for(;!d();)c.e((l===l.toLowerCase()?c.x:0)+parseFloat(m()),c.y),b.yr(c.x,c.y);break;case"V":for(;!d();)c.e(c.x,(l===l.toLowerCase()?c.y:0)+parseFloat(m())),b.yr(c.x,c.y);u&&(L=!0);break;case"C":for(;!d();){const D=new Point;g(D);const F=y(),R=p();b.wr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(L=!0);break;case"S":for(;!d();){const D=x(),F=y(),R=p();b.wr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(L=!0);break;case"Q":for(;!d();){const D=y(),F=p();b.Fw(D.x,D.y,F.x,F.y)}u&&(L=!0);break;case"T":for(;!d();){const D=x();f.c(D);const F=p();b.Fw(D.x,D.y,F.x,F.y),f.c(F)}u&&(L=!0);break;case"B":for(;!d();){const D=parseFloat(m()),F=parseFloat(m());let R=parseFloat(m()),I=parseFloat(m());const O=parseFloat(m());let V=O,K=!1;d()||(V=parseFloat(m()),d()||(K=parseFloat(m())!==0)),l===l.toLowerCase()&&(R+=c.x,I+=c.y),b.HD(D,F,R,I,O,V,K)}u&&(L=!0);break;case"A":for(;!d();){const D=Math.abs(parseFloat(m())),F=Math.abs(parseFloat(m())),R=parseFloat(m());let I=!1,O=!1,V=0,K=0;const B=m();B.length===1?(I=!!parseFloat(B),O=!!parseFloat(m()),V=parseFloat(m()),K=parseFloat(m())):B.length===2?(I=!!parseFloat(B[0]),O=!!parseFloat(B[1]),V=parseFloat(m()),K=parseFloat(m())):(I=!!parseFloat(B[0]),O=!!parseFloat(B[1]),V=parseFloat(B.slice(2)),K=parseFloat(m())),l===l.toLowerCase()&&(V=c.x+V,K=c.y+K),c.e(V,K),b.qD(D,F,R,I,O,V,K)}u&&(L=!0);break;case"Z":b.jD(),c.c(a);break;case"F":{let D="",F=1;for(;o[r+F];){if(o[r+F]==="0"){A=!0,F++;continue}if(o[r+F].match(/[Uu]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?S=!0:b.WD();break}case"U":{let D="",F=1;for(;o[r+F];){if(o[r+F].match(/[Ff]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?M=!0:b.vD(!1);break}default:if(l==="0"||l==="1")break;Util.ht("Unknown geometry command: "+l);break}if(L){Util.ht(`Bad geometry command: ${l}, next token: ${m()}, +string: ${t}`);break}}const T=b.tm;if(GeoStream.MC(b),i){const L=T.figures.iterator;for(;L.next();){const D=L.value;D.isFilled=!0}}return T}static PC(t,i){const e=t.length,s=Point.a();for(let n=0;n=t)return 0;if((n>r?n-r:r-n)<(o>l?o-l:l-o)){if(ol)return 0}else if(fo)return 0}else if(nr)return 0}else if(an)return 0;return h>0?1:-1}CC(t,i,e){const s=this.figures.h,n=s.length;for(let o=0;o1&&(t=1),i===void 0&&(i=new Point),this.type===1)return i.e(this.startX+t*(this.endX-this.startX),this.startY+t*(this.endY-this.startY)),i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[c*2],y=g[c*2+1],x=g[c*2+2],k=g[c*2+3];return i.e(p+(x-p)*m,y+(k-y)*m),i}l+=u}}return i}getAngleAlongPath(t){if(t<0?t=0:t>1&&(t=1),this.type===1)return Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI;const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=i.length,o=s*t;let r=0;for(let l=0;l=o){const u=i[l],d=u[f*2],m=u[f*2+1],g=u[f*2+2],p=u[f*2+3];return Math.abs(g-d)<1&&Math.abs(p-m)<1?0:Math.abs(g-d)<1?p-m>=0?90:270:Math.abs(p-m)<1?g-d>=0?0:180:Math.atan2(p-m,g-d)*180/Math.PI}r+=c}}return NaN}getPointAndAngleAlongPath(t,i){if(t<0?t=0:t>1&&(t=1),i===void 0&&(i=[]),i.length=3,this.type===1)return i[0]=this.startX+t*(this.endX-this.startX),i[1]=this.startY+t*(this.endY-this.startY),i[2]=Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI,i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[c*2],y=g[c*2+1],x=g[c*2+2],k=g[c*2+3];i[0]=p+(x-p)*m,i[1]=y+(k-y)*m;let b;return Math.abs(x-p)<1&&Math.abs(k-y)<1?b=0:Math.abs(x-p)<1?b=k-y>=0?90:270:Math.abs(k-y)<1?b=x-p>=0?0:180:b=Math.atan2(k-y,x-p)*180/Math.PI,i[2]=b,i}l+=u}}return i}getFractionForPoint(t){if(this.type===1){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=t.x,r=t.y;let l=0,h=0;if(i===s)return e=h?h===e?0:1:Math.abs(r-e)/(h-l);if(e===n)return i=h?h===i?0:1:Math.abs(o-i)/(h-l);{const a=(s-i)*(s-i)+(n-e)*(n-e),f=Point.a();Geo.xl(i,e,s,n,o,r,f);const c=f.x,u=f.y;return Point.o(f),Math.sqrt(((c-i)*(c-i)+(u-e)*(u-e))/a)}}}else if(this.type===2){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=s-i,r=n-e,l=o*2+r*2;let h=t.x,a=t.y;h=Math.min(Math.max(h,i),s),a=Math.min(Math.max(a,e),n);const f=Math.abs(h-i),c=Math.abs(h-s),u=Math.abs(a-e),d=Math.abs(a-n),m=Math.min(f,c,u,d);if(m===u)return h/l;if(m===c)return(o+a)/l;if(m===d)return(o*2+r-h)/l;if(m===f)return(o*2+r*2-a)/l}}else{const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=Point.a();let o=1/0,r=0,l=0;const h=i.length;let a=0,f=0;for(let u=0;u1?1:c}return 0}get flattenedSegments(){return this.AC(),this.ff}AC(){if(this.ff===null){const t=this.ff=[],i=this.mu=[];this.$D(t,i)}}get flattenedLengths(){return this.AC(),this.mu}get flattenedTotalLength(){let t=this.pu;if(isNaN(t)){if(this.type===1){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=Math.sqrt(i*i+e*e)}else if(this.type===2){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=i*2+e*2}else{const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=4&&(t.push(e),i.push(this.Zk(e))),e=[],e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY,h=r,a=l;break;case 2:e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY;break;case 3:Geo.Gn(r,l,d.point1X,d.point1Y,d.point2X,d.point2Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 4:Geo.qg(r,l,d.point1X,d.point1Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 5:{const m=d.To(o),g=m.length;if(g===0){e.push(d.centerX),e.push(d.centerY),r=d.centerX,l=d.centerY;break}for(let p=0;p=4&&(t.push(e),i.push(this.Zk(e)))}}}get type(){return this.it}set type(t){this.it!==t&&(Debug&&Util.tt(t,GeometryType,"GeometryType"),this.f&&Util.F(this,t),this.it=t,t===4?this.Bs=new List:(Geometry.Dw===null&&(Geometry.Dw=new List().w()),this.Bs=Geometry.Dw),this.Nt=!0)}get startX(){return this.Pe}set startX(t){this.Pe!==t&&(Debug&&Util.r(t,Geometry,"startX"),this.f&&Util.F(this,t),this.Pe=t,this.Nt=!0)}get startY(){return this.Ne}set startY(t){this.Ne!==t&&(Debug&&Util.r(t,Geometry,"startY"),this.f&&Util.F(this,t),this.Ne=t,this.Nt=!0)}get endX(){return this.se}set endX(t){this.se!==t&&(Debug&&Util.r(t,Geometry,"endX"),this.f&&Util.F(this,t),this.se=t,this.Nt=!0)}get endY(){return this.ne}set endY(t){this.ne!==t&&(Debug&&Util.r(t,Geometry,"endY"),this.f&&Util.F(this,t),this.ne=t,this.Nt=!0)}get figures(){return this.Bs}set figures(t){this.Bs!==t&&(Debug&&Util.s(t,List,Geometry,"figures"),this.f&&Util.F(this,t),this.Bs=t,this.Nt=!0)}add(t){return this.Bs.add(t),this}setSpots(t,i,e,s,n,o,r,l){return this.f&&Util.F(this),this.jn=new Spot(t,i,n,o).w(),this.Wn=new Spot(e,s,r,l).w(),this}get spot1(){return this.jn}set spot1(t){Debug&&Util.s(t,Spot,Geometry,"spot1"),this.f&&Util.F(this,t),this.jn=t.L()}get spot2(){return this.Wn}set spot2(t){Debug&&Util.s(t,Spot,Geometry,"spot2"),this.f&&Util.F(this,t),this.Wn=t.L()}get defaultStretch(){return this.vn}set defaultStretch(t){this.vn=t}get bounds(){return this.Wk()&&this.Rw(),this.Qg}}Geometry.stringify=Geometry.stringify,Geometry.stringifyFixed=Geometry.stringifyFixed,Geometry.fillPath=Geometry.fillPath,Geometry.parse=Geometry.parse;class PathFigure{l;Pe;Ne;df;im;Ue;constructor(t,i,e,s,n){e===void 0&&(e=!0),s===void 0&&(s=!0),n===void 0&&(n=!1),this.l=2|(e?4:0)|(s?8:0)|(n?16:0),t!==void 0?(Debug&&Util.r(t,PathFigure,"sx"),this.Pe=t):this.Pe=0,i!==void 0?(Debug&&Util.r(i,PathFigure,"sy"),this.Ne=i):this.Ne=0,this.df=new List,this.im=this.df.dt,this.Ue=null}copy(){const t=new PathFigure;t.l=this.l&-2,t.Pe=this.Pe,t.Ne=this.Ne;const i=this.df.h,e=i.length,s=t.df;for(let n=0;no===0?"0":o.toFixed(t);i="M"+n(this.startX)+" "+n(this.startY)}const e=this.segments.h,s=e.length;for(let n=0;n(w[w.Move=1]="Move",w[w.Line=2]="Line",w[w.Bezier=3]="Bezier",w[w.QuadraticBezier=4]="QuadraticBezier",w[w.Arc=5]="Arc",w[w.SvgArc=6]="SvgArc",w))(SegmentType||{});class PathSegment{it;l;se;ne;dn;kl;Sl;xr;Vs;constructor(t,i,e,s,n,o,r,l){if(GSet.vi(this),t===void 0?t=2:Debug&&Util.tt(t,SegmentType,"SegmentType"),this.it=t,this.l=2,i!==void 0?(Debug&&Util.r(i,PathSegment,"ex"),this.se=i):this.se=0,e!==void 0?(Debug&&Util.r(e,PathSegment,"ey"),this.ne=e):this.ne=0,s===void 0&&(s=0),n===void 0&&(n=0),o===void 0&&(o=0),r===void 0&&(r=0),t===6){let h=o;h=h%360,h<0&&(h+=360),this.dn=h,this.kl=0,Debug&&Util.r(s,PathSegment,"x1"),this.Sl=Math.max(s,0),Debug&&Util.r(n,PathSegment,"y1"),this.xr=Math.max(n,0),typeof r=="boolean"?r&&(this.isLargeArc=!0):typeof r=="number"&&r&&(this.isLargeArc=!0),l&&(this.isClockwiseArc=!0)}else Debug&&Util.r(s,PathSegment,"x1"),this.dn=s,Debug&&Util.r(n,PathSegment,"y1"),this.kl=n,Debug&&Util.r(o,PathSegment,"x2"),t===5&&(o=Math.max(o,0)),this.Sl=o,typeof r=="number"?(t===5&&(r=Math.max(r,0)),this.xr=r):this.xr=0;this.Vs=null}copy(){const t=new PathSegment;return t.it=this.it,t.l=this.l&-2,t.se=this.se,t.ne=this.ne,t.dn=this.dn,t.kl=this.kl,t.Sl=this.Sl,t.xr=this.xr,t}equalsApprox(t){if(!(t instanceof PathSegment)||this.type!==t.type||this.isClosed!==t.isClosed)return!1;switch(this.type){case 1:case 2:return Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY);case 3:return Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY)&&Geo.p(this.point1X,t.point1X)&&Geo.p(this.point1Y,t.point1Y)&&Geo.p(this.point2X,t.point2X)&&Geo.p(this.point2Y,t.point2Y);case 4:return Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY)&&Geo.p(this.point1X,t.point1X)&&Geo.p(this.point1Y,t.point1Y);case 5:return Geo.p(this.startAngle,t.startAngle)&&Geo.p(this.sweepAngle,t.sweepAngle)&&Geo.p(this.centerX,t.centerX)&&Geo.p(this.centerY,t.centerY)&&Geo.p(this.radiusX,t.radiusX)&&Geo.p(this.radiusY,t.radiusY);case 6:return this.isClockwiseArc===t.isClockwiseArc&&this.isLargeArc===t.isLargeArc&&Geo.p(this.xAxisRotation,t.xAxisRotation)&&Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY)&&Geo.p(this.radiusX,t.radiusX)&&Geo.p(this.radiusY,t.radiusY);default:return!1}}fi(t){t in SegmentType?this.type=t:Util.ur(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e="";switch(this.type){case 1:t<0?e="M"+this.endX.toString()+" "+this.endY.toString():e="M"+i(this.endX)+" "+i(this.endY);break;case 2:t<0?e="L"+this.endX.toString()+" "+this.endY.toString():e="L"+i(this.endX)+" "+i(this.endY);break;case 3:t<0?e="C"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.point2X.toString()+" "+this.point2Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="C"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.point2X)+" "+i(this.point2Y)+" "+i(this.endX)+" "+i(this.endY);break;case 4:t<0?e="Q"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="Q"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.endX)+" "+i(this.endY);break;case 5:t<0?e="B"+this.startAngle.toString()+" "+this.sweepAngle.toString()+" "+this.centerX.toString()+" "+this.centerY.toString()+" "+this.radiusX.toString()+" "+this.radiusY.toString():e="B"+i(this.startAngle)+" "+i(this.sweepAngle)+" "+i(this.centerX)+" "+i(this.centerY)+" "+i(this.radiusX)+" "+i(this.radiusY);break;case 6:t<0?e="A"+this.radiusX.toString()+" "+this.radiusY.toString()+" "+this.xAxisRotation.toString()+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+this.endX.toString()+" "+this.endY.toString():e="A"+i(this.radiusX)+" "+i(this.radiusY)+" "+i(this.xAxisRotation)+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+i(this.endX)+" "+i(this.endY);break;default:e=SegmentType[this.type]}return e+(this.isClosed?"z":"")}static Move=1;static Line=2;static Bezier=3;static QuadraticBezier=4;static Arc=5;static SvgArc=6;get f(){return(this.l&1)!==0}set f(t){t?this.l|=1:this.l&=-2}get Nt(){return(this.l&2)!==0}set Nt(t){t?this.l|=2:this.l&=-3}w(){return this.f=!0,this}ft(){return this.f=!1,this}close(){return this.isClosed=!0,this}To(t){if(this.Vs!==null&&t.Nt===!1)return this.Vs;const i=this.radiusX;let e=this.radiusY;if(e===void 0&&(e=i),i===0||e===0)return this.Vs=[],this.Vs;const s=this.dn,n=this.kl,o=Geo.xC(0,0,i1&&(o*=Math.sqrt(p),r*=Math.sqrt(p));let y=(h===a?-1:1)*Math.sqrt((o*o*r*r-o*o*g*g-r*r*m*m)/(o*o*g*g+r*r*m*m));isNaN(y)&&(y=0);let x=y*o*g/r,k=y*-r*m/o;isNaN(x)&&(x=0),isNaN(k)&&(k=0);const b=(s+f)/2+u*x-d*k,S=(n+c)/2+d*x+u*k,M=(X,z)=>Math.sqrt(X*X+z*z),A=(X,z,G,q)=>(X*G+z*q)/(M(X,z)*M(G,q)),C=(X,z,G,q)=>(X*q=1&&(F=0),!a&&F>0&&(F=F-2*Math.PI),a&&F<0&&(F=F+2*Math.PI);const I=o>r?o:r,O=o>r?1:o/r,V=o>r?r/o:1,K=Geo.xC(0,0,I,P,P+F,!0),B=Transform.a();return B.Vi(),B.Es(b,S),B.ms(this.dn,0,0),B.rt(O,V),Geometry.PC(K,B),Transform.o(B),this.Vs=K,this.Vs}get isClosed(){return(this.l&8)!==0}set isClosed(t){this.isClosed!==t&&(t?this.l|=8:this.l&=-9,this.Nt=!0)}get type(){return this.it}set type(t){Debug&&Util.tt(t,SegmentType,"SegmentType"),this.f&&Util.F(this,t),this.it=t,this.Nt=!0}get endX(){return this.se}set endX(t){Debug&&Util.r(t,PathSegment,"endX"),this.f&&Util.F(this,t),this.se=t,this.Nt=!0}get endY(){return this.ne}set endY(t){Debug&&Util.r(t,PathSegment,"endY"),this.f&&Util.F(this,t),this.ne=t,this.Nt=!0}get point1X(){return this.dn}set point1X(t){Debug&&Util.r(t,PathSegment,"point1X"),this.f&&Util.F(this,t),this.dn=t,this.Nt=!0}get point1Y(){return this.kl}set point1Y(t){Debug&&Util.r(t,PathSegment,"point1Y"),this.f&&Util.F(this,t),this.kl=t,this.Nt=!0}get point2X(){return this.Sl}set point2X(t){Debug&&Util.r(t,PathSegment,"point2X"),this.f&&Util.F(this,t),this.Sl=t,this.Nt=!0}get point2Y(){return this.xr}set point2Y(t){Debug&&Util.r(t,PathSegment,"point2Y"),this.f&&Util.F(this,t),this.xr=t,this.Nt=!0}get centerX(){return this.dn}set centerX(t){Debug&&Util.r(t,PathSegment,"centerX"),this.f&&Util.F(this,t),this.dn=t,this.Nt=!0}get centerY(){return this.kl}set centerY(t){Debug&&Util.r(t,PathSegment,"centerY"),this.f&&Util.F(this,t),this.kl=t,this.Nt=!0}get radiusX(){return this.Sl}set radiusX(t){Debug&&Util.r(t,PathSegment,"radiusX"),t<0&&Util.G(t,">= zero",PathSegment,"radiusX"),this.f&&Util.F(this,t),this.Sl=t,this.Nt=!0}get radiusY(){return this.xr}set radiusY(t){Debug&&Util.r(t,PathSegment,"radiusY"),t<0&&Util.G(t,">= zero",PathSegment,"radiusY"),this.f&&Util.F(this,t),this.xr=t,this.Nt=!0}get startAngle(){return this.se}set startAngle(t){Debug&&Util.r(t,PathSegment,"startAngle"),this.f&&Util.F(this,t),t=t%360,t<0&&(t+=360),this.se=t,this.Nt=!0}get sweepAngle(){return this.ne}set sweepAngle(t){Debug&&Util.r(t,PathSegment,"sweepAngle"),this.f&&Util.F(this,t),t>360&&(t=360),t<-360&&(t=-360),this.ne=t,this.Nt=!0}get isClockwiseArc(){return(this.l&4)!==0}set isClockwiseArc(t){this.f&&Util.F(this,t),t?this.l|=4:this.l&=-5,this.Nt=!0}get isLargeArc(){return(this.l&16)!==0}set isLargeArc(t){this.f&&Util.F(this,t),t?this.l|=16:this.l&=-17,this.Nt=!0}get xAxisRotation(){return this.dn}set xAxisRotation(t){Debug&&Util.r(t,PathSegment,"xAxisRotation"),this.f&&Util.F(this,t),t=t%360,t<0&&(t+=360),this.dn=t,this.Nt=!0}}class InputEvent{b;Ow;Ew;em;sm;nm;om;rm;lm;hm;am;fm;cm;um;Do;dm;gm;mm;Ce;constructor(){this.b=null,this.Ow=new Point(0,0).w(),this.Ew=new Point(0,0).w(),this.em=0,this.sm=0,this.nm=1,this.om="",this.rm="",this.lm=!1,this.hm=!1,this.am=0,this.fm=0,this.cm=!1,this.um=!1,this.Do=!1,this.dm=null,this.gm=0,this.mm=null,this.Ce=null}copy(){const t=new InputEvent;return this.clone(t)}clone(t){return t.b=this.b,t.Ow.c(this.viewPoint),t.Ew.c(this.documentPoint),t.em=this.em,t.sm=this.sm,t.nm=this.nm,t.om=this.om,t.rm=this.rm,t.lm=this.lm,t.hm=this.hm,t.am=this.am,t.fm=this.fm,t.cm=this.cm,t.um=this.um,t.Do=this.Do,t.dm=this.dm,t.gm=this.gm,t.mm=this.mm,t.Ce=this.Ce,t}toString(){let t="^";return this.modifiers!==0&&(t+="M:"+this.modifiers),this.button!==0&&(t+="B:"+this.button),this.key!==""&&(t+="K:"+this.key),this.clickCount!==0&&(t+="C:"+this.clickCount),this.delta!==0&&(t+="D:"+this.delta),this.handled&&(t+="h"),this.bubbles&&(t+="b"),this.documentPoint!==null&&(t+="@"+this.documentPoint.toString()),t}get diagram(){return this.b}set diagram(t){this.b=t}get viewPoint(){return this.Ow}set viewPoint(t){Util.s(t,Point,InputEvent,"viewPoint"),this.Ow.c(t)}get documentPoint(){return this.Ew}set documentPoint(t){Util.s(t,Point,InputEvent,"documentPoint"),this.Ew.c(t)}getMultiTouchViewPoint(t,i){const e=this.diagram;return e===null||e.LC(this.event,t,i),i}getMultiTouchDocumentPoint(t,i){const e=this.diagram;return e===null||(e.LC(this.event,t,i),i.c(e.transformViewToDoc(i))),i}get modifiers(){return this.em}set modifiers(t){this.em=t}get button(){return this.sm}set button(t){if(this.sm=t,this.event===null)switch(t){case 0:this.buttons=1;return;case 1:this.buttons=4;return;case 2:this.buttons=2;return}}get buttons(){return this.nm}set buttons(t){this.nm=t}get key(){return this.om}set key(t){this.om=t}get code(){return this.rm}set code(t){this.rm=t}get down(){return this.lm}set down(t){this.lm=t}get up(){return this.hm}set up(t){this.hm=t}get clickCount(){return this.am}set clickCount(t){this.am=t}get delta(){return this.fm}set delta(t){this.fm=t}get isMultiTouch(){return this.cm}set isMultiTouch(t){this.cm=t}get handled(){return this.um}set handled(t){this.um=t}get bubbles(){return this.Do}set bubbles(t){this.Do=t}get event(){return this.dm}set event(t){this.dm=t}get isTouchEvent(){const t=this.event;return t===null?!1:t.pointerType==="touch"||t.pointerType==="pen"}get timestamp(){return this.gm}set timestamp(t){this.gm=t}get targetDiagram(){return this.mm}set targetDiagram(t){this.mm=t}get targetObject(){return this.Ce}set targetObject(t){this.Ce=t}get control(){return(this.modifiers&1)!==0}set control(t){this.modifiers=t?this.modifiers|1:this.modifiers&-2}get shift(){return(this.modifiers&4)!==0}set shift(t){this.modifiers=t?this.modifiers|4:this.modifiers&-5}get alt(){return(this.modifiers&2)!==0}set alt(t){this.modifiers=t?this.modifiers|2:this.modifiers&-3}get meta(){return(this.modifiers&8)!==0}set meta(t){this.modifiers=t?this.modifiers|8:this.modifiers&-9}get left(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===0:(this.buttons&1)!==0}set left(t){t?this.buttons|=1:this.buttons&=-2}get right(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===2:(this.buttons&2)!==0}set right(t){t?this.buttons|=2:this.buttons&=-3}get middle(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===1:(this.buttons&4)!==0}set middle(t){t?this.buttons|=4:this.buttons&=-5}get commandKey(){const t=this.code,i=this.key;return"cxvyzagCXVYZAG".includes(i)?i.toLowerCase():t==="KeyC"?"c":t==="KeyX"?"x":t==="KeyV"?"v":t==="KeyY"?"y":t==="KeyZ"?"z":t==="KeyA"?"a":t==="KeyG"?"g":t!==""?t:i}}class DiagramEvent{b;Tt;pm;ym;constructor(){this.b=null,this.Tt="",this.pm=null,this.ym=null}copy(){const t=new DiagramEvent;return t.b=this.b,t.Tt=this.Tt,t.pm=this.pm,t.ym=this.ym,t}toString(){let t="*"+this.name;return this.subject!==null&&(t+=":"+this.subject.toString()),this.parameter!==null&&(t+="("+this.parameter.toString()+")"),t}get diagram(){return this.b}set diagram(t){this.b=t}get name(){return this.Tt}set name(t){this.Tt=t}get subject(){return this.pm}set subject(t){this.pm=t}get parameter(){return this.ym}set parameter(t){this.ym=t}}var ChangeType=(w=>(w[w.Transaction=1]="Transaction",w[w.Property=2]="Property",w[w.Insert=3]="Insert",w[w.Remove=4]="Remove",w))(ChangeType||{});class ChangedEvent{wu;wm;gn;Ai;b;xu;gf;mf;pf;yf;constructor(){this.wu=2,this.wm="",this.gn="",this.Ai=null,this.b=null,this.xu=null,this.gf=null,this.mf=null,this.pf=null,this.yf=null}static Transaction=1;static Property=2;static Insert=3;static Remove=4;clear(){this.Ai=null,this.b=null,this.xu=null,this.gf=null,this.mf=null,this.pf=null,this.yf=null}copy(){const t=new ChangedEvent;t.wu=this.wu,t.wm=this.wm,t.gn=this.gn,t.Ai=this.Ai,t.b=this.b,t.xu=this.xu;let i=this.gf;return Util.Mt(i)&&typeof i.copyFrozen=="function"?t.gf=i.copyFrozen():t.gf=i,i=this.mf,Util.Mt(i)&&typeof i.copyFrozen=="function"?t.mf=i.copyFrozen():t.mf=i,i=this.pf,Util.Mt(i)&&typeof i.copyFrozen=="function"?t.pf=i.copyFrozen():t.pf=i,i=this.yf,Util.Mt(i)&&typeof i.copyFrozen=="function"?t.yf=i.copyFrozen():t.yf=i,t}fi(t){t in ChangeType?this.change=t:Util.ur(this,t)}toString(){let t="";return this.change===1?t+="* ":this.change===2?t+=this.model!==null?"!m":"!d":t+=(this.model!==null?"!m":"!d")+this.change,this.propertyName&&typeof this.propertyName=="string"&&(t+=" "+this.propertyName),this.modelChange&&this.modelChange!==this.propertyName&&(t+=" "+this.modelChange),t+=": ",this.change===1?this.oldValue!==null&&(t+=" "+this.oldValue):(this.object!==null&&(t+=Util.toString(this.object)),this.oldValue!==null&&(t+=" old: "+Util.toString(this.oldValue)),this.oldParam!==null&&(t+=" "+this.oldParam),this.newValue!==null&&(t+=" new: "+Util.toString(this.newValue)),this.newParam!==null&&(t+=" "+this.newParam)),t}getValue(t){return t?this.oldValue:this.newValue}getParam(t){return t?this.oldParam:this.newParam}canUndo(){return this.model!==null||this.diagram!==null}undo(){this.canUndo()&&(this.model!==null?this.model.changeState(this,!0):this.diagram!==null&&this.diagram.TC(this,!0))}canRedo(){return this.model!==null||this.diagram!==null}redo(){this.canRedo()&&(this.model!==null?this.model.changeState(this,!1):this.diagram!==null&&this.diagram.TC(this,!1))}get model(){return this.Ai}set model(t){this.Ai=t}get diagram(){return this.b}set diagram(t){this.b=t}get change(){return this.wu}set change(t){this.wu=t}get modelChange(){return this.wm}set modelChange(t){Debug&&Util.t(t,"string",ChangedEvent,"modelChange"),this.wm=t}get propertyName(){return this.gn}set propertyName(t){Debug&&typeof t!="string"&&Util.t(t,"function",ChangedEvent,"propertyName"),this.gn=t}get isTransactionFinished(){return this.wu===1&&(this.gn==="CommittedTransaction"||this.gn==="FinishedUndo"||this.gn==="FinishedRedo")}get object(){return this.xu}set object(t){this.xu=t}get oldValue(){return this.gf}set oldValue(t){this.gf=t}get oldParam(){return this.mf}set oldParam(t){this.mf=t}get newValue(){return this.pf}set newValue(t){this.pf=t}get newParam(){return this.yf}set newParam(t){this.yf=t}}class Transaction{DC;Tt;$k;constructor(){this.DC=new List().w(),this.Tt="",this.$k=!1}toString(t){let i="Transaction: "+this.name+" "+this.changes.count.toString()+(this.isComplete?"":", incomplete");if(t!==void 0&&t>0){const e=this.changes.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),t.w()}canUndo(){return this.isComplete}undo(){if(this.canUndo())for(let t=this.changes.count-1;t>=0;t--){const i=this.changes.elt(t);i!==null&&i.undo()}}canRedo(){return this.isComplete}redo(){if(!this.canRedo())return;const t=this.changes.count;for(let i=0;i=t;e--){const s=i.elt(e);s!==null&&s.undo(),i.ft(),i.removeAt(e)}i.w()}optimize(){if(!this.isComplete)return;const t=this.changes;t.ft();const i=new GMap;for(let s=0;s0&&t.setElt(r,null),o.set(n.propertyName,s))}let e=0;for(let s=0;se&&t.setElt(e,n),e++)}for(;t.length>e;)t.pop();t.w()}get changes(){return this.DC}get name(){return this.Tt}set name(t){this.Tt=t}get isComplete(){return this.$k}set isComplete(t){this.$k=t}}class UndoManager{Bw;Xi;FC;zs;Qk;xm;Jn;Vw;_k;mn;wf;zw;Xs;Xw;Yw;bm;Kw;constructor(t){this.Bw=new GSet,this.Xi=!1,this.FC=new List().w(),this.zs=-1,this.Qk=999,this.Xs=!1,this.xm=null,this.Jn=0,this.Vw=!1,Debug&&(this.Vw=!0),this._k=23,this.mn=new List().w(),this.wf=new List,this.zw=!0,this.Xw=!1,this.Yw=!1,this.bm=!1,this.Kw=!1,t&&Object.assign(this,t)}toString(t){let i="UndoManager "+this.historyIndex+"<"+this.history.count+"<="+this.maxHistoryLength;i+="[";let e=this.nestedTransactionNames.count;for(let s=0;s0&&(i+=" "),i+=this.nestedTransactionNames.elt(s);if(i+="]",t!==void 0&&t>0){e=this.history.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),this.zs=-1,t.w(),this.Xs=!1,this.xm=null,this.Jn=0,this.mn.ft(),this.mn.clear(),this.mn.w(),this.wf.clear(),this.Xw=!1,this.Yw=!1,this.bm=!1,this.Kw=!1}copyProperties(t){this.isEnabled=t.isEnabled,this.maxHistoryLength=t.maxHistoryLength,this.bu=t.bu}addModel(t){this.Bw.add(t)}removeModel(t){this.Bw.delete(t)}startTransaction(t){if(t===void 0&&(t=""),t===null&&(t=""),this.isUndoingRedoing)return!1;this.zw===!0&&(this.zw=!1,this.Jn++,this.Ml||this.i("StartingFirstTransaction",t,this.currentTransaction),this.Jn>0&&this.Jn--),this.isEnabled&&(this.mn.ft(),this.mn.add(t),this.mn.w(),this.currentTransaction===null?this.wf.add(0):this.wf.add(this.currentTransaction.changes.count)),this.Jn++;const i=this.transactionLevel===1;return i&&(this.Ml||this.i("StartedTransaction",t,this.currentTransaction)),i}commitTransaction(t){return t===void 0&&(t=""),this.RC(!0,t)}rollbackTransaction(){return this.RC(!1,"")}RC(t,i){if(this.isUndoingRedoing)return!1;this.bu&&this.transactionLevel<1&&Util.ht("Ending transaction without having started a transaction: "+i);const e=this.transactionLevel===1;let s=this.currentTransaction;e&&t&&(this.Ml||this.i("CommittingTransaction",i,s));let n=0;if(this.transactionLevel>0&&(this.Jn--,this.isEnabled)){const o=this.mn.count;o>0&&(i===""&&(i=this.mn.elt(0)),this.mn.ft(),this.mn.removeAt(o-1),this.mn.w());const r=this.wf.count;r>0&&(n=this.wf.elt(r-1),this.wf.removeAt(r-1))}if(e){if(t){if(this.bm=!1,s===null&&i!==""&&(s=this.currentTransaction),this.isEnabled&&s!==null){const o=s;o.isComplete||(o.isComplete=!0,o.name=i),this.discardHistoryAfterIndex();const r=this.history;r.ft();const l=this.maxHistoryLength;if(l>=0){if(l===0)r.clear();else if(r.count>=l){const h=r.elt(0);h!==null&&h.clear(),r.removeAt(0),this.zs--}}l!==0&&(r.count===0||r.get(r.count-1)!==o)&&(r.add(o),this.zs++),r.w(),s=o}this.Ml||this.i("CommittedTransaction",i,s)}else{this.Xs=!0;try{this.isEnabled&&s!==null&&(s.isComplete=!0,s.undo())}finally{this.Ml||this.i("RolledBackTransaction",i,s),this.Xs=!1}s!==null&&s.clear()}return this.xm=null,this.Uw&&this.clear(),this.Uw=!1,this.Gw=!1,!0}else return this.isEnabled&&!t&&s!==null&&s.QD(n),!1}discardHistoryAfterIndex(){if(this.isUndoingRedoing||!this.canRedo())return;const t=this.history;t.ft();for(let i=t.count-1;i>this.historyIndex;i--){const e=t.elt(i);e!==null&&e.clear(),t.removeAt(i),this.bm=!0}t.w()}rE(t){this.Jn+=t,this.Jn<0&&(this.Jn=0)}canUndo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToUndo;return!!(t!==null&&t.canUndo())}undo(){if(!this.canUndo())return;const t=this.transactionToUndo;try{this.Xs=!0,this.i("StartingUndo","Undo",t),this.zs--,t.undo()}catch(i){Util.ht("undo error: "+i.toString())}finally{this.i("FinishedUndo","Undo",t),this.Xs=!1}}canRedo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToRedo;return!!(t!==null&&t.canRedo())}redo(){if(!this.canRedo())return;const t=this.transactionToRedo;try{this.Xs=!0,this.i("StartingRedo","Redo",t),this.zs++,t.redo()}catch(i){Util.ht("redo error: "+i.toString())}finally{this.i("FinishedRedo","Redo",t),this.Xs=!1}}i(t,i,e){e===void 0&&(e=null);const s=new ChangedEvent;s.change=1,s.propertyName=t,s.object=e,s.oldValue=i;const n=this.models;for(;n.next();){const o=n.value;s.model=o,o.Hw(s)}}handleChanged(t){if(this.isEnabled&&!this.isUndoingRedoing&&!this.skipsEvent(t)){let i=this.currentTransaction;i===null&&(i=new Transaction,this.xm=i);const e=t.copy(),s=i.changes;if(s.ft(),s.add(e),s.w(),this.bu&&this._k>0&&this.transactionLevel<=0&&!this.zw){const n=t.diagram;if(n!==null&&n.Kh===!1)return;Util.ht("Change not within a transaction: "+e.toString()),this._k--}}}skipsEvent(t){if(t===null||t.change===1)return!0;const i=t.object;if(i===null)return!1;if(i.layer!==void 0){const e=i.layer;if(e!==null&&e.isTemporary)return!0}else if(i.isTemporary)return!0;return!1}get models(){return this.Bw.iterator}get isEnabled(){return this.Xi}set isEnabled(t){this.Xi=t}get transactionToUndo(){return this.historyIndex>=0&&this.historyIndex<=this.history.count-1?this.history.elt(this.historyIndex):null}get transactionToRedo(){return this.historyIndex0}get bu(){return this.Vw}set bu(t){this.Vw=t}get nestedTransactionNames(){return this.mn}get Uw(){return this.Xw}set Uw(t){this.Xw=t}get Gw(){return this.Yw}set Gw(t){this.Yw=t}get Ml(){return this.Kw}set Ml(t){this.Kw=t}get isJustDiscarded(){return this.bm}}class Tool{b;Tt;Xi;tS;iS;km;IC;constructor(){GSet.vi(this),this.b=Diagram.Sm(),this.Tt="",this.Xi=!0,this.tS=!1,this.iS=null,this.IC=new InputEvent,this.km=-1}get diagram(){return this.b}set diagram(t){t instanceof Diagram&&(this.b=t)}toString(){return this.name!==""?this.name+" Tool":Util.hn(this.constructor)}updateAdornments(t){}canStart(){return this.isEnabled}doStart(){}doActivate(){this.isActive=!0}doDeactivate(){this.isActive=!1}doStop(){}doCancel(){this.transactionResult=null,this.stopTool()}stopTool(){const t=this.diagram;t.currentTool===this&&(t.currentTool=null,t.currentCursor="")}doMouseDown(){!this.isActive&&this.canStart()&&this.doActivate()}doMouseMove(){}doMouseUp(){this.stopTool()}doMouseWheel(){}canStartMultiTouch(){return!0}standardPinchZoomStart(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.H(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.H(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.o(e),Point.o(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){t.eS=t.scale;const n=s.x-e.x,o=s.y-e.y,r=Math.sqrt(n*n+o*o);t.sS=r,i.bubbles=!1}Point.o(e),Point.o(s)}standardPinchZoomMove(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.H(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.H(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.o(e),Point.o(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){const n=s.x-e.x,o=s.y-e.y,l=Math.sqrt(n*n+o*o)/t.sS,h=new Point((Math.min(s.x,e.x)+Math.max(s.x,e.x))/2,(Math.min(s.y,e.y)+Math.max(s.y,e.y))/2),a=t.eS*l,f=t.commandHandler;if(a!==t.scale&&f.canResetZoom(a)){const c=t.zoomPoint;t.zoomPoint=h,f.resetZoom(a),t.zoomPoint=c}i.bubbles=!1}Point.o(e),Point.o(s)}doKeyDown(){this.diagram.lastInput.code==="Escape"&&this.doCancel()}doKeyUp(){}startTransaction(t){return t===void 0&&(t=this.name),this.transactionResult=null,this.diagram.startTransaction(t)}stopTransaction(){const t=this.diagram;return this.transactionResult===null?t.rollbackTransaction():t.commitTransaction(this.transactionResult)}standardMouseSelect(){const t=this.diagram;if(!t.allowSelect)return;const i=t.lastInput,e=t.findPartAt(i.documentPoint,!1);if(e!==null){if(Util.cr?i.meta:i.control){t.B("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!s.isSelected),t.B("ChangedSelection",t.selection)}else if(i.shift){if(!e.isSelected){t.B("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!0),t.B("ChangedSelection",t.selection)}}else if(!e.isSelected){let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&t.select(s)}}else i.left&&!(Util.cr?i.meta:i.control)&&!i.shift&&t.clearSelection()}standardMouseClick(t,i){t===void 0&&(t=null),i===void 0&&(i=o=>!o.layer.isTemporary);const e=this.diagram,s=e.lastInput,n=e.findObjectAt(s.documentPoint,t,i);return s.targetObject=n,this._D(n,s,e),s.handled}_D(t,i,e){if(i.handled=!1,t!==null&&!t.isEnabledObject())return;let s=0;i.left?i.clickCount===1?s=1:i.clickCount===2?s=2:s=1:i.right&&i.clickCount===1&&(s=3);let n="ObjectSingleClicked";if(t!==null){switch(s){case 1:n="ObjectSingleClicked";break;case 2:n="ObjectDoubleClicked";break;case 3:n="ObjectContextClicked";break}s!==0&&e.B(n,t)}else{switch(s){case 1:n="BackgroundSingleClicked";break;case 2:n="BackgroundDoubleClicked";break;case 3:n="BackgroundContextClicked";break}s!==0&&e.B(n)}if(t!==null)for(;t!==null;){let o=null;switch(s){case 1:o=t.click;break;case 2:o=t.doubleClick?t.doubleClick:t.click;break;case 3:o=t.contextClick;break}if(o!==null&&(o(i,t),i.handled))break;t=t.panel}else{let o=null;switch(s){case 1:o=e.click;break;case 2:o=e.doubleClick?e.doubleClick:e.click;break;case 3:o=e.contextClick;break}o!==null&&o(i)}}standardMouseOver(){const t=this.diagram,i=t.lastInput;if(t.animationManager.Si===!0)return;const e=t.skipsUndoManager;t.skipsUndoManager=!0;let s=t.viewportBounds.containsPoint(i.documentPoint)?t.findObjectAt(i.documentPoint,null,null):null;i.event&&(i.event.type==="pointercancel"||i.event.type==="pointerout")&&(s=null),i.targetObject=s;let n=!1;if(s!==t.xf){let o=t.xf;const r=o;for(t.xf=s,this.doCurrentObjectChanged(o,s),i.handled=!1;o!==null;){const l=o.mouseLeave;if(l!==null&&(s===o||s!==null&&s.isContainedBy(o)||(l(i,o,s),n=!0,i.handled)))break;o=o.panel}for(o=r,i.handled=!1;s!==null;){const l=s.mouseEnter;if(l!==null&&(o===s||o!==null&&o.isContainedBy(s)||(l(i,s,o),n=!0,i.handled)))break;s=s.panel}s=t.xf}if(s!==null){let o=s,r="";for(;o!==null&&(r=o.cursor,r==="");)o=o.panel;for(t.currentCursor=r,i.handled=!1,o=s;o!==null;){const l=o.mouseOver;if(l!==null&&(l(i,o),n=!0,i.handled))break;o=o.panel}}else{this.doUpdateCursor(null);const o=t.mouseOver;o!==null&&(o(i),n=!0)}n&&t.requestUpdate(),t.skipsUndoManager=e}doUpdateCursor(t){const i=this.diagram;i&&(i.currentCursor="")}doCurrentObjectChanged(t,i){}standardMouseWheel(){const t=this.diagram,i=t.lastInput;let e=i.delta;if(e===0||!t.documentBounds.isReal())return;const s=t.commandHandler,n=t.toolManager.mouseWheelBehavior;if(s!==null&&(n===2&&!i.shift||n===1&&i.control)){if(e>0?s.canIncreaseZoom():s.canDecreaseZoom()){const o=t.zoomPoint;t.zoomPoint=i.viewPoint,e>0?s.increaseZoom():s.decreaseZoom(),t.zoomPoint=o}i.bubbles=!1}else if(n===2&&i.shift||n===1&&!i.control){const o=t.position.copy(),r=i.event,l=r.deltaMode;let h=r.deltaX,a=r.deltaY,f="pixel";if((h!==0||a!==0)&&!i.shift){switch(l){case 0:f="pixel";break;case 1:f="line";break;case 2:f="page";break}if(h!==0&&t.allowHorizontalScroll){const c=t.scrollHorizontalLineChange;h=h*(c/16),t.scroll(f,h>0?"right":"left",Math.abs(h))}if(a!==0&&t.allowVerticalScroll){const c=t.scrollVerticalLineChange;a=a*(c/16),t.scroll(f,a>0?"down":"up",Math.abs(a))}}else!i.shift&&t.allowVerticalScroll?(e=e*3*t.scrollVerticalLineChange,t.scroll(f,e>0?"up":"down",Math.abs(e))):i.shift&&t.allowHorizontalScroll&&(e=e*3*t.scrollHorizontalLineChange,t.scroll(f,e>0?"left":"right",Math.abs(e)));this.doWheelChange(t,o,i)}}doWheelChange(t,i,e){(!t.position.equals(i)||e.event.wheelDeltaX!==0)&&(e.bubbles=!1)}standardWaitAfter(t,i){Debug&&Util.t(t,"number",Tool,"standardWaitAfter:delay"),i===void 0&&(i=this.diagram.lastInput),this.cancelWaitAfter();const e=this,s=i.clone(this.IC);this.km=Util.zh(()=>e.doWaitAfter(s),t)}cancelWaitAfter(){this.km!==-1&&Util.Kg(this.km),this.km=-1}doWaitAfter(t){}findToolHandleAt(t,i){const s=this.diagram.findObjectAt(t,n=>{for(;n!==null&&!(n.panel instanceof Adornment);)n=n.panel;return n});return s===null?null:s.part.category===i?s:null}isBeyondDragSize(t,i){const e=this.diagram;t===void 0&&(t=e.firstInput.viewPoint),i===void 0&&(i=e.lastInput.viewPoint);const s=e.toolManager.dragSize;let n=s.width,o=s.height;return e.firstInput.isTouchEvent&&(n+=6,o+=6),Math.abs(i.x-t.x)>n||Math.abs(i.y-t.y)>o}get name(){return this.Tt}set name(t){Util.t(t,"string",Tool,"name"),this.Tt=t}get isEnabled(){return this.Xi}set isEnabled(t){Util.t(t,"boolean",Tool,"isEnabled"),this.Xi=t}get isActive(){return this.tS}set isActive(t){Util.t(t,"boolean",Tool,"isActive"),this.tS=t}get transactionResult(){return this.iS}set transactionResult(t){t!==null&&Util.t(t,"string",Tool,"transactionResult"),this.iS=t}}var WheelMode=(w=>(w[w.Scroll=1]="Scroll",w[w.Zoom=2]="Zoom",w[w.None=3]="None",w))(WheelMode||{}),GestureMode=(w=>(w[w.Zoom=1]="Zoom",w[w.Cancel=2]="Cancel",w[w.None=3]="None",w))(GestureMode||{});class ToolManager extends Tool{OC;EC;BC;nS;oS;rS;lS;hS;aS;fS;Mm;Uh;constructor(t){super(),this.name="ToolManager",this.OC=new List,this.EC=new List,this.BC=new List,this.nS=850,this.oS=850,this.rS=new Size(2,2).ot(),this.lS=5e3,this.hS=1,this.aS=1,this.fS=null,this.Mm=null,this.Uh=-1,t&&Object.assign(this,t)}static WheelScroll=1;static WheelZoom=2;static WheelNone=3;static GestureZoom=1;static GestureCancel=2;static GestureNone=3;get mouseWheelBehavior(){return this.hS}set mouseWheelBehavior(t){Util.tt(t,WheelMode,"WheelMode"),this.hS=t}get gestureBehavior(){return this.aS}set gestureBehavior(t){Util.tt(t,GestureMode,"GestureMode"),this.aS=t}initializeStandardTools(){}updateAdornments(t){const i=this.currentToolTip;if(i instanceof Adornment&&this.Mm===t){const e=i.adornedObject;(t!==null?e.part===t:e===null)?this.showToolTip(i,e):this.hideToolTip()}}doMouseDown(){const t=this.diagram,i=t.lastInput;if(i.isTouchEvent&&this.gestureBehavior===2&&(i.bubbles=!1),i.isMultiTouch){if(this.cancelWaitAfter(),this.gestureBehavior===3){i.bubbles=!0;return}if(this.gestureBehavior===2)return;if(t.currentTool.canStartMultiTouch()){t.currentTool.standardPinchZoomStart();return}}const e=t.undoManager;Debug&&e.bu&&e.transactionLevel!==0&&Util.ht("WARNING: In ToolManager.doMouseDown: UndoManager.transactionLevel is not zero");const s=this.mouseDownTools.length;for(let n=0;n0&&s!==1/0){const n=this;this.Uh=Util.zh(()=>n.hideToolTip(),s)}}positionToolTip(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom?n.y-=o.height+5/s.scale:n.y+=20/s.scale,n.y30&&t.jw(),t.Ww(this.draggedParts),t.Mu=!0,this.startTransaction("Drag"),this.startPoint=t.firstInput.documentPoint,t.isMouseCaptured=!0,t.allowDragOut&&this.iF()}MS(t){if(this.dragsLink){const i=this.diagram;if(!i.allowRelink)return;i.model.Sf()&&t.count===1&&t.first()instanceof Link?(this.draggedLink=t.first(),this.draggedLink.canRelinkFrom()&&this.draggedLink.canRelinkTo()&&this.draggedLink.clearAdornments(),this.pn=i.toolManager.findTool("Relinking"),this.pn===null&&(this.pn=new RelinkingTool,this.pn.diagram=i),this.pn.originalLink=this.draggedLink):(this.draggedLink=null,this.pn=null)}}computeEffectiveCollection(t,i){return this.diagram.commandHandler.computeEffectiveCollection(t,i)}Ys(t){return t===void 0?new DraggingInfo(Point.Lo):this.isGridSnapEnabled?new DraggingInfo(new Point(Math.round(t.x*1e3)/1e3,Math.round(t.y*1e3)/1e3)):new DraggingInfo(t.copy())}doDeactivate(){this.isActive=!1;const t=this.diagram;this.diagram.layout.isRealtime=this.SS,t.Mu=!1,t.Pl=!0,t.cacheGroupExternalLinks(!1),t.stopAutoScroll(),this.PS(),t.Nm(this.draggedParts),this.Su=null,this.currentPart=null,this.draggedParts=null,this.isDragOutStarted=!1,this.ku=!1,DraggingTool.eF(),this.zC(),this.bf.e(NaN,NaN),DraggingTool.Hh!==null&&(DraggingTool.Hh.currentCursor=""),DraggingTool.Hh=null,DraggingTool.St=null,this.Nl(),t.isMouseCaptured=!1,t.currentCursor="",t.kf=!1,this.stopTransaction(),t.NS(!0)}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}PS(){const t=this.diagram,i=t.skipsUndoManager;t.skipsUndoManager=!0;const e=t.lastInput;this.XC(e,null),t.skipsUndoManager=i,this.br.length=0}YC(){this.Nl(),this.CS();const t=this.diagram;this.bf.isReal()&&(t.position=this.bf),t.stopAutoScroll()}doCancel(){this.Nl(),this.CS();const t=this.diagram;this.bf.isReal()&&(t.position=this.bf),this.stopTool()}doKeyDown(){const t=this.diagram,i=t.lastInput;this.isActive&&(i.code==="Escape"?this.doCancel():i.code!==t.previousInput.code&&this.doMouseMove())}doKeyUp(){this.isActive&&this.doMouseMove()}sF(t,i){let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=t.iterator;for(;r.next();){const l=r.value;if(!l.isVisible())continue;const h=l.location,a=h.x,f=h.y;isNaN(a)||isNaN(f)||(an&&(n=a),f>o&&(o=f))}return e===1/0?i.e(0,0,0,0):i.e(e,s,n-e,o-s),i}AS(t){if(this.copiedParts!==null)return;const i=this.diagram;if(t&&(i.isReadOnly||i.isModelReadOnly)||this.draggedParts===null)return;const e=i.undoManager;e.isEnabled&&e.isInTransaction?e.currentTransaction!==null&&e.currentTransaction.changes.count>0&&(i.undoManager.rollbackTransaction(),i.startTransaction("Drag")):this.CS(),i.skipsUndoManager=!t,i.partManager.addsToTemporaryLayer=!t,this.startPoint=i.firstInput.documentPoint;const s=this.copiesEffectiveCollection?this.draggedParts.toKeySet():i.selection,n=i.copyParts(s,i,!0),o=new GMap,r=this.draggedParts.iterator;for(;r.next();){const h=r.key;if(h.Ae()&&h.canCopy()){const a=n.get(h);if(a===null)continue;a.location=h.location,a.ensureBounds(),o.set(a,this.Ys(a.location))}}const l=n.iterator;for(;l.next();){const h=l.value;h instanceof Link&&h.canCopy()&&o.set(h,this.Ys())}if(this.copiedParts=o,this.MS(o.toKeySet()),this.draggedLink!==null){const h=this.draggedLink,a=h.routeBounds;h.kr(this.startPoint.x-(a.x+a.width/2),this.startPoint.y-(a.y+a.height/2))}this.doUpdateCursor(null)}Nl(){const t=this.diagram;if(this.copiedParts!==null){if(t.removeParts(this.copiedParts.toKeySet(),!1),this.copiedParts=null,this.draggedParts!==null){const i=this.draggedParts.iterator;for(;i.next();)if(i.key instanceof Link){const s=i.value;s.point=new Point(0,0)}}this.doUpdateCursor(null)}t.skipsUndoManager=!1,t.partManager.addsToTemporaryLayer=!1,this.startPoint=t.firstInput.documentPoint}zC(){this.draggedLink!==null&&(this.dragsLink&&this.pn!==null&&(this.pn.stopDraggingMouseMove(),this.pn.originalLink=null),this.draggedLink=null,this.pn=null)}Mf(t,i){const e=this.diagram,s=this.startPoint,n=Point.a();n.c(e.lastInput.documentPoint),this.moveParts(t,n.subtract(s),i),Point.o(n),e.getRenderingHint("temporaryPixelRatio")===!0&&e.Cl===null&&e.avgSpf>30&&(e.jw(),e.Pu())}moveParts(t,i,e){e===void 0&&(e=!1);const s=this.diagram;s!==null&&s.LS(t,i,this.dragOptions,e)}CS(){if(this.draggedParts===null)return;const t=this.diagram;let i=this.draggedParts.iterator;for(;i.next();){const e=i.key;e.Ae()&&(e.location=i.value.point)}for(i=this.draggedParts.iterator;i.next();){const e=i.key;if(e instanceof Link&&e.suspendsRouting){const s=i.value.point;this.draggedParts.set(e,this.Ys()),e.kr(-s.x,-s.y)}}t.maybeUpdate()}nF(t){if(t===null)return!0;const i=t.part;return!!(i===null||i instanceof Adornment||i.layer.isTemporary||this.draggedParts&&this.draggedParts.has(i)||this.copiedParts&&this.copiedParts.has(i))}TS(t){const i=this.diagram;this.dragsLink&&(this.draggedLink!==null&&(this.draggedLink.fromNode=null,this.draggedLink.toNode=null),this.KC(!1));const e=this.findDragOverObject(t),s=i.lastInput;s.targetObject=e,this.doUpdateCursor(e);const n=i.skipsUndoManager;let o=!1;try{if(i.skipsUndoManager=!0,o=this.XC(s,e),!this.isActive&&DraggingTool.St===null)return;const r=e!==null?e.part:null;if(r===null||i.handlesDragDropForTopLevelParts&&r.isTopLevel&&!(r instanceof Group)){const l=i.mouseDragOver;l!==null&&(l(s),o=!0)}if(!this.isActive&&DraggingTool.St===null||(this.doDragOver(t,e),!this.isActive&&DraggingTool.St===null))return}finally{i.skipsUndoManager=n,o&&i.maybeUpdate()}this.Su=e,!i.isReadOnly&&(i.allowMove||i.allowCopy)&&(i.allowHorizontalScroll||i.allowVerticalScroll)&&i.doAutoScroll(s.viewPoint)}findDragOverObject(t){return this.diagram.DS(t,null,i=>!this.nF(i))}doUpdateCursor(t){const i=this.diagram;(t===null||this.Su!==t)&&(!this.diagram.currentTool.isActive||this.mayCopy()?i.currentCursor=this.copyCursor:this.mayMove()?i.currentCursor=this.moveCursor:this.mayDragOut()&&(i.currentCursor=this.nodropCursor))}XC(t,i){let e=!1,s=this.br.length;const n=s>0?this.br[0]:null;if(i===n)return!1;t.handled=!1;for(let r=0;rs.findValidLinkablePort(a,i)),r=Point.a();let l=1/0,h=null;for(const a=o.iterator;a.next();){const f=a.value;if(f.part===null)continue;const u=f.getDocumentPoint(Spot.Center,r),d=t.distanceSquaredPoint(u);dh.suspendsRouting=!1)}if(this.doDropOnto(t,e),!this.isActive&&DraggingTool.St===null)return;const o=Rect.a(),r=i.selection.iterator;for(;r.next();){const l=r.value;l instanceof Node&&this.rF(i,l,o)}Rect.o(o)}oF(t,i){const e=this.diagram,s=i.part;if(e.handlesDragDropForTopLevelParts&&s.isTopLevel&&!(s instanceof Group)){const n=e.mouseDrop;n!==null&&n(t)}}rF(t,i,e){if(!i.canAvoid())return;let s=!1;e=i.getAvoidableRect(e),t.viewportBounds.containsRect(e)&&(s=!0);const n=this.copiedParts||this.draggedParts,o=t.IS(e,l=>l.part,l=>l instanceof Link,!0,l=>l instanceof Link,s);if(o.count===0)return;const r=o.iterator;for(;r.next();){const l=r.value;n.has(l)&&n.has(i)||!l.isMemberOf(i)&&l.isAvoiding&&l.invalidateRoute()}}doDropOnto(t,i){}doMouseMove(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseMove(i.event,i.documentPoint,i.targetDiagram))return;this.currentPart!==null&&this.draggedParts!==null&&(this.mayCopy()?(this.AS(!1),t.Ww(this.copiedParts),this.Mf(this.copiedParts,!1),t.Nm(this.copiedParts)):this.mayMove()?(this.Nl(),this.Mf(this.draggedParts,!0)):this.mayDragOut()?(this.AS(!1),this.Mf(this.copiedParts,!1)):this.Nl(),this.TS(t.lastInput.documentPoint))}doMouseUp(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseUp(i.event,i.documentPoint,i.targetDiagram))return;let e=!1;const s=this.mayCopy();if(s&&this.copiedParts!==null?(this.Nl(),this.AS(!0),t.Ww(this.copiedParts),this.Mf(this.copiedParts,!1),t.Nm(this.copiedParts),this.copiedParts!==null&&(t.B("ChangingSelection",t.selection),t.clearSelection(!0),this.copiedParts.iteratorKeys.each(n=>{n.isSelected=!0}))):(e=!0,this.Nl(),this.mayMove()&&(this.Mf(this.draggedParts,!0),this.TS(t.lastInput.documentPoint))),this.ku=!0,this.HC(t.lastInput.documentPoint),this.isActive){const n=s?this.copiedParts.toKeySet():this.draggedParts.toKeySet();this.copiedParts=null,e&&this.lF(),t.invalidateDocumentBounds(),t.Nm(this.draggedParts),this.transactionResult=s?"Copy":"Move",t.B(s?"SelectionCopied":"SelectionMoved",n)}this.stopTool(),s&&t.B("ChangedSelection",t.selection)}simulatedMouseMove(t,i,e){if(DraggingTool.St===null)return!1;const s=DraggingTool.St.diagram;e instanceof Diagram||(e=null);const n=DraggingTool.Hh;if(e!==n){if(n!==null&&n!==s){n.stopAutoScroll(),DraggingTool.St.isDragOutStarted=!1;const r=n.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDragLeave()}if(DraggingTool.Hh=e,e!==null&&e!==s){DraggingTool.St.YC();const r=e.toolManager.findTool("Dragging");r!==null&&(r.qC(),r.doSimulatedDragEnter())}this.doUpdateCursor(null)}if(e===null||e===s||!e.allowDrop||e.isReadOnly||!e.allowInsert)return!1;const o=e.toolManager.findTool("Dragging");if(o!==null){let r=i;t!==null&&(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),r=e.getMouse(t)),e.lastInput.documentPoint=r,e.lastInput.viewPoint=e.transformDocToView(r),e.lastInput.down=!1,e.lastInput.up=!1,o.doSimulatedDragOver()}return!0}simulatedMouseUp(t,i,e){if(DraggingTool.St===null)return!1;const s=DraggingTool.Hh,n=DraggingTool.St.diagram;if(e===null)return DraggingTool.St.doCancel(),!0;if(e!==s){const o=s.toolManager.findTool("Dragging");if(s!==null&&s!==n&&o!==null)return s.stopAutoScroll(),DraggingTool.St.isDragOutStarted=!1,o.doSimulatedDragLeave(),!1;DraggingTool.Hh=e;const r=e.toolManager.findTool("Dragging");r!==null&&(DraggingTool.St.YC(),r.qC(),r.doSimulatedDragEnter())}if(e!==this.diagram){let o=i;t!==null?(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),o=e.getMouse(t)):o===null&&(o=new Point),e.lastInput.documentPoint=o,e.lastInput.viewPoint=e.transformDocToView(o),e.lastInput.down=!1,e.lastInput.up=!0;const r=e.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDrop();const l=DraggingTool.St;if(l!==null){const h=l.mayCopy();l.transactionResult=h?"Copy":"Move",l.stopTool()}return!0}return!1}lF(){if(this.draggedParts===null)return;const t=this.draggedParts.iterator;for(;t.next();){const i=t.key;if(i instanceof Node){const e=i.containingGroup;e!==null&&e.hasPlaceholder()&&!this.draggedParts.has(e)&&e.placeholder.u()}}}mayCopy(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowCopy||!(Util.cr?t.lastInput.alt:t.lastInput.control))return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayDragOut(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(!t.allowDragOut||!t.allowCopy||t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayMove(){const t=this.diagram;if(t.isReadOnly||!t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canMove())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canMove())}qC(){DraggingTool.vw.has(this)||DraggingTool.vw.add(this)}static eF(){if(DraggingTool.vw.count>0){const t=DraggingTool.vw,i=t.length;for(let e=0;e{n.isSelected=!0,s.add(n)})),this.HC(t.lastInput.documentPoint),t.invalidateDocumentBounds(),this.copiedParts!==null&&(this.transactionResult="ExternalCopy"),this.copiedParts=null,t.doFocus(),t.kf=!1,t.B("ExternalObjectsDropped",s,e),this.stopTransaction(),t.B("ChangedSelection",t.selection)}t.animationManager.Nu=!1}jC(t,i,e){if(this.copiedParts!==null)return;const s=this.diagram;if(s.isReadOnly||s.isModelReadOnly)return;s.skipsUndoManager=!i,s.partManager.addsToTemporaryLayer=!i,this.startPoint=e.documentPoint;const n=s.copyParts(t,s,!0),o=Rect.a();this.sF(t,o);const r=o.x+o.width/2,l=o.y+o.height/2;Rect.o(o);const h=this.Pm,a=new GMap,f=Point.a(),c=t.iterator;for(;c.next();){const d=c.value;if(d instanceof Link&&d.canCopy()){const m=n.get(d);if(m===null)continue;m.points=d.points,m.kr(h.x-r,h.y-l),m.suspendsRouting=!0,a.set(m,this.Ys())}}const u=t.iterator;for(;u.next();){const d=u.value;if(d.Ae()&&d.canCopy()){const m=n.get(d);if(m===null)continue;const g=d.location;f.e(h.x-(r-g.x),h.y-(l-g.y)),m.location=f,m.ensureBounds(),a.set(m,this.Ys(f))}}if(Point.o(f),this.copiedParts=a,this.MS(a.toKeySet()),this.draggedLink!==null){const d=this.draggedLink,m=d.routeBounds;d.kr(this.startPoint.x-(m.x+m.width/2),this.startPoint.y-(m.y+m.height/2))}this.doUpdateCursor(null)}iF(){this.isDragOutStarted=!0,this.ku=!1,DraggingTool.St=this,DraggingTool.Hh=this.diagram,this.doSimulatedDragOut()}doSimulatedDragOut(){const t=this.diagram;t.kf=!1,!this.mayCopy()&&!this.mayMove()?t.currentCursor=this.nodropCursor:t.currentCursor="",this.Su=null}computeMove(t,i,e,s){const n=this.diagram;return n!==null?n.computeMove(t,i,this.dragOptions,s):new Point}static vw=new List;static St=null;static Hh=null}ToolManager.prototype.doCancel=function(){DraggingTool.St!==null&&DraggingTool.St.doCancel(),Tool.prototype.doCancel.call(this)};class LinkingBaseTool extends Tool{OS;ES;Al;BS;VS;qh;zS;jh;XS;YS;KS;US;GS;HS;WC;qS;Ll;jS;constructor(){super(),this.OS=100,this.ES=!1,this.Al="pointer",this.BS=new Link({layerName:"Tool"}).add(new Shape({isPanelMain:!0,stroke:"blue"}).theme("stroke","tempLink"),new Shape({toArrow:"Standard",fill:"blue",stroke:"blue"}).theme("fill","tempLink").theme("stroke","tempLink")).ci(),this.qh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.zk}).theme("stroke","tempPort"),this.VS=new Node({selectable:!1,layerName:"Tool"}).add(this.qh).ci(),this.jh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.zk}).theme("stroke","tempPort"),this.zS=new Node({selectable:!1,layerName:"Tool"}).add(this.jh).ci(),this.XS=null,this.YS=null,this.KS=null,this.US=null,this.GS=null,this.HS=!0,this.WC=new GMap,this.qS=null,this.Ll=null,this.jS=null}doStop(){this.diagram.stopAutoScroll(),this.originalLink=null,this.originalFromNode=null,this.originalFromPort=null,this.originalToNode=null,this.originalToPort=null,this.validPortsCache.clear(),this.targetPort=null}get portGravity(){return this.OS}set portGravity(t){Util.t(t,"number",LinkingBaseTool,"portGravity"),t>=0&&(this.OS=t)}get isUnconnectedLinkValid(){return this.ES}set isUnconnectedLinkValid(t){Util.t(t,"boolean",LinkingBaseTool,"isUnconnectedLinkValid"),this.ES=t}get linkingCursor(){return this.Al}set linkingCursor(t){this.Al=t}get temporaryLink(){return this.BS}set temporaryLink(t){Util.s(t,Link,LinkingBaseTool,"temporaryLink"),t.ci(),this.BS=t}get temporaryFromNode(){return this.VS}set temporaryFromNode(t){Util.s(t,Node,LinkingBaseTool,"temporaryFromNode"),t.ci(),this.VS=t,t&&(this.qh=t.port)}get temporaryFromPort(){return this.qh}set temporaryFromPort(t){if(Util.s(t,GraphObject,LinkingBaseTool,"temporaryFromPort"),this.qh!==null){const i=this.qh.panel;if(i!==null){const e=i.D.indexOf(this.qh);i.removeAt(e),i.insertAt(e,t)}}this.qh=t}get temporaryToNode(){return this.zS}set temporaryToNode(t){Util.s(t,Node,LinkingBaseTool,"temporaryToNode"),t.ci(),this.zS=t,t&&(this.jh=t.port)}get temporaryToPort(){return this.jh}set temporaryToPort(t){if(Util.s(t,GraphObject,LinkingBaseTool,"temporaryToPort"),this.jh!==null){const i=this.jh.panel;if(i!==null){const e=i.D.indexOf(this.jh);i.removeAt(e),i.insertAt(e,t)}}this.jh=t}get originalLink(){return this.XS}set originalLink(t){t!==null&&Util.s(t,Link,LinkingBaseTool,"originalLink"),this.XS=t}get originalFromNode(){return this.YS}set originalFromNode(t){t!==null&&Util.s(t,Node,LinkingBaseTool,"originalFromNode"),this.YS=t}get originalFromPort(){return this.KS}set originalFromPort(t){t!==null&&Util.s(t,GraphObject,LinkingBaseTool,"originalFromPort"),this.KS=t}get originalToNode(){return this.US}set originalToNode(t){t!==null&&Util.s(t,Node,LinkingBaseTool,"originalToNode"),this.US=t}get originalToPort(){return this.GS}set originalToPort(t){t!==null&&Util.s(t,GraphObject,LinkingBaseTool,"originalToPort"),this.GS=t}get isForwards(){return this.HS}set isForwards(t){this.HS=t}get validPortsCache(){return this.WC}get targetPort(){return this.qS}set targetPort(t){t!==null&&Util.s(t,GraphObject,LinkingBaseTool,"targetPort"),this.qS=t}copyPortProperties(t,i,e,s,n){if(t===null||i===null||e===null||s===null)return;const o=i.getDocumentScale(),r=Size.a();r.width=i.naturalBounds.width*o,r.height=i.naturalBounds.height*o,s.desiredSize=r,Size.o(r),n?(s.toSpot=i.toSpot,s.toEndSegmentLength=i.toEndSegmentLength):(s.fromSpot=i.fromSpot,s.fromEndSegmentLength=i.fromEndSegmentLength),e.locationSpot=Spot.Center;const l=Point.a();e.location=i.getDocumentPoint(Spot.Center,l),Point.o(l),s.angle=i.getDocumentAngle(),this.portTargeted!==null&&this.portTargeted(t,i,e,s,n)}setNoTargetPortProperties(t,i,e){i!==null&&(i.desiredSize=Size.zk,i.fromSpot=Spot.None,i.toSpot=Spot.None),t!==null&&(t.location=this.diagram.lastInput.documentPoint),this.portTargeted!==null&&this.portTargeted(null,null,t,i,e)}doMouseDown(){this.isActive&&this.doMouseMove()}doMouseMove(){if(this.isActive){const t=this.diagram;if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null&&this.targetPort.part instanceof Node){const i=this.targetPort.part;this.isForwards?this.copyPortProperties(i,this.targetPort,this.temporaryToNode,this.temporaryToPort,!0):this.copyPortProperties(i,this.targetPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else this.isForwards?this.setNoTargetPortProperties(this.temporaryToNode,this.temporaryToPort,!0):this.setNoTargetPortProperties(this.temporaryFromNode,this.temporaryFromPort,!1);(t.allowHorizontalScroll||t.allowVerticalScroll)&&t.doAutoScroll(t.lastInput.viewPoint)}}findValidLinkablePort(t,i){if(t===null)return null;const e=t.part;if(!(e instanceof Node))return null;for(;t!==null;){const s=i?t.toLinkable:t.fromLinkable;if(s===!0&&(t.portId!==null||t instanceof Node)&&(i?this.isValidTo(e,t):this.isValidFrom(e,t)))return t;if(s===!1)return null;t=t.panel}return null}findTargetPort(t){const i=this.diagram,e=i.lastInput.documentPoint;let s=this.portGravity;s<=0&&(s=.1);const n=this,o=i.findObjectsNear(e,s,a=>n.findValidLinkablePort(a,t),null,!0);let r=1/0,l=null;const h=o.iterator;for(;h.next();){const a=h.value,f=a.part;if(!(f instanceof Node))continue;const c=a.getDocumentPoint(Spot.Center,Point.a()),u=e.x-c.x,d=e.y-c.y;Point.o(c);const m=u*u+d*d;if(m=e)return!1}return!0}isValidTo(t,i){if(t===null||i===null)return this.isUnconnectedLinkValid;if(this.diagram.currentTool===this&&(t.layer!==null&&!t.layer.allowLink||i.toLinkable!==!0))return!1;const e=i.toMaxLinks;if(e<1/0){if(this.originalLink!==null&&t===this.originalToNode&&i===this.originalToPort)return!0;let s=i.portId;if(s===null&&(s=""),t.findLinksInto(s).count>=e)return!1}return!0}isInSameNode(t,i){if(t===null||i===null)return!1;if(t===i)return!0;const e=t.part,s=i.part;return e!==null&&e===s}isLinked(t,i){if(t===null||i===null)return!1;const e=t.part;if(!(e instanceof Node))return!1;let s=t.portId;s===null&&(s="");const n=i.part;if(!(n instanceof Node))return!1;let o=i.portId;o===null&&(o="");const r=n.findLinksInto(o);for(;r.next();){const l=r.value;if(l.fromNode===e&&l.fromPortId===s)return!0}return!1}isValidLink(t,i,e,s){if(!this.isValidFrom(t,i)||!this.isValidTo(e,s)||i!==null&&s!==null&&(!(i.fromLinkableSelfNode&&s.toLinkableSelfNode)&&this.isInSameNode(i,s)||!(i.fromLinkableDuplicates&&s.toLinkableDuplicates)&&this.isLinked(i,s))||this.originalLink!==null&&(t!==null&&this.isLabelDependentOnLink(t,this.originalLink)||e!==null&&this.isLabelDependentOnLink(e,this.originalLink))||t!==null&&e!==null&&(t.data===null&&e.data!==null||t.data!==null&&e.data===null)||!this.isValidCycle(t,e,this.originalLink))return!1;let n;return t!==null&&(n=t.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))||e!==null&&(n=e.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))?!1:(n=this.linkValidation,n!==null?n(t,i,e,s,this.originalLink):!0)}isLabelDependentOnLink(t,i){if(t===null)return!1;const e=t.labeledLink;if(e===null)return!1;if(e===i)return!0;const s=new GSet;return s.add(t),this.WS(e,i,s)}WS(t,i,e){if(t===i)return!0;const s=t.fromNode;if(s!==null&&s.isLinkLabel&&(e.add(s),this.WS(s.labeledLink,i,e)))return!0;const n=t.toNode;return!!(n!==null&&n.isLinkLabel&&(e.add(n),this.WS(n.labeledLink,i,e)))}isValidCycle(t,i,e){if(e===void 0&&(e=null),t===null||i===null)return this.isUnconnectedLinkValid;const s=this.diagram;let n=1;if(s&&(s.model.Pf()?n=s.isTreePathToChildren?5:6:n=s.validCycle),n===1)return!0;if(n===5){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=i.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.toNode===i)return!1}return!this.Cu(t,i,e,!0)}else if(n===6){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=t.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.fromNode===t)return!1}return!this.Cu(t,i,e,!0)}else{if(n===2)return!this.hF(t,i,e);if(n===3)return!this.Cu(t,i,e,!1);if(n===4)return!this.aF(t,i,e)}return!0}Cu(t,i,e,s){if(t===i)return!0;if(t===null||i===null)return!1;const n=t.linksConnected;for(;n.next();){const o=n.value;if(o===e||s&&!o.isTreeLink||o.toNode!==t)continue;const r=o.fromNode;if(r!==t&&this.Cu(r,i,e,s))return!0}return!1}hF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.vC(s,t,i,e)}vC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s||o.toNode!==i)continue;const r=o.fromNode;if(r!==i&&this.vC(t,r,e,s))return!0}return!1}aF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.JC(s,t,i,e)}JC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s)continue;const r=o.fromNode,l=o.toNode,h=r===i?l:r;if(h!==i&&this.JC(t,h,e,s))return!0}return!1}get linkValidation(){return this.Ll}set linkValidation(t){t!==null&&Util.t(t,"function",LinkingBaseTool,"linkValidation"),this.Ll=t}get portTargeted(){return this.jS}set portTargeted(t){t!==null&&Util.t(t,"function",LinkingBaseTool,"portTargeted"),this.jS=t}}var LinkingDirection=(w=>(w[w.Either=1]="Either",w[w.ForwardsOnly=2]="ForwardsOnly",w[w.BackwardsOnly=3]="BackwardsOnly",w))(LinkingDirection||{});class LinkingTool extends LinkingBaseTool{vS;JS;C;ZS;constructor(t){super(),this.name="Linking",this.vS={},this.JS=null,this.C=1,this.ZS=null,t&&Object.assign(this,t)}static Either=1;static ForwardsOnly=2;static BackwardsOnly=3;get archetypeLinkData(){return this.vS}set archetypeLinkData(t){t!==null&&Util.t(t,"object",LinkingTool,"archetypeLinkData"),t instanceof GraphObject&&Util.s(t,Link,LinkingTool,"archetypeLinkData"),this.vS=t}get archetypeLabelNodeData(){return this.JS}set archetypeLabelNodeData(t){t!==null&&Util.t(t,"object",LinkingTool,"archetypeLabelNodeData"),t instanceof GraphObject&&Util.s(t,Node,LinkingTool,"archetypeLabelNodeData"),this.JS=t}get direction(){return this.C}set direction(t){Util.tt(t,LinkingDirection,"LinkingDirection"),this.C=t}get startObject(){return this.ZS}set startObject(t){t!==null&&Util.s(t,GraphObject,LinkingTool,"startObject"),this.ZS=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||t.isModelReadOnly||!t.allowLink||!t.model.Jw()||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize()?!1:this.findLinkablePort()!==null}findLinkablePort(){const t=this.diagram;let i=this.startObject;if(i===null&&(i=t.findObjectAt(t.firstInput.documentPoint,null,null)),i===null)return null;const e=i.part;if(!(e instanceof Node))return null;const s=this.direction;if(s===1||s===2){const n=this.findValidLinkablePort(i,!1);if(n!==null)return this.isForwards=!0,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!1))return this.isForwards=!0,o}}if(s===1||s===3){const n=this.findValidLinkablePort(i,!0);if(n!==null)return this.isForwards=!1,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!0))return this.isForwards=!1,o}}return null}doActivate(){const t=this.diagram,i=this.findLinkablePort();if(i===null){this.stopTool();return}if(this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.isForwards){this.temporaryToNode!==null&&(this.temporaryToNode.location=t.lastInput.documentPoint),this.originalFromPort=i;const e=this.originalFromPort.part;e instanceof Node&&(this.originalFromNode=e),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else{this.temporaryFromNode!==null&&(this.temporaryFromNode.location=t.lastInput.documentPoint),this.originalToPort=i;const e=this.originalToPort.part;e instanceof Node&&(this.originalToNode=e),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0)}t.add(this.temporaryFromNode),this.temporaryFromNode&&this.temporaryFromNode.ensureBounds(),t.add(this.temporaryToNode),this.temporaryToNode&&this.temporaryToNode.ensureBounds(),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.temporaryLink.isTreeLink=this.isNewTreeLink(),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.startObject=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=null,e=null,s=null,n=null,o=null;try{this.targetPort=this.findTargetPort(this.isForwards);const r=this.targetPort;if(r!==null){const l=r.part;l instanceof Node&&(this.isForwards?(this.originalFromNode!==null&&(i=this.originalFromNode,e=this.originalFromPort),s=l,n=r):(i=l,e=r,this.originalToNode!==null&&(s=this.originalToNode,n=this.originalToPort)))}else this.isForwards?this.originalFromNode!==null&&this.isUnconnectedLinkValid&&(i=this.originalFromNode,e=this.originalFromPort):this.originalToNode!==null&&this.isUnconnectedLinkValid&&(s=this.originalToNode,n=this.originalToPort);i!==null||s!==null?(o=this.insertLink(i,e,s,n),o!==null?(r===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint),t.allowSelect&&(t.B("ChangingSelection",t.selection),t.clearSelection(!0),o.isSelected=!0),this.transactionResult=this.name,t.B("LinkDrawn",o)):this.doNoLink(i,e,s,n)):this.isForwards?this.doNoLink(this.originalFromNode,this.originalFromPort,null,null):this.doNoLink(null,null,this.originalToNode,this.originalToPort)}finally{this.stopTool(),o&&t.allowSelect&&t.B("ChangedSelection",t.selection)}}}isNewTreeLink(){const t=this.archetypeLinkData;if(t===null)return!0;if(t instanceof Link)return t.isTreeLink;const i=this.diagram;if(i===null)return!0;const e=i.partManager.getLinkCategoryForData(t),s=i.partManager.findLinkTemplateForCategory(e);return s!==null?s.isTreeLink:!0}insertLink(t,i,e,s){return this.diagram.partManager.insertLink(t,i,e,s)}doNoLink(t,i,e,s){}}class RelinkingTool extends LinkingBaseTool{$S;QS;ps;_S;constructor(t){super(),this.name="Relinking",this.$S=new Shape("Diamond",{desiredSize:Size.du,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:0}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.QS=new Shape("Diamond",{desiredSize:Size.du,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:-1}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.ps=null,this._S=new Rect,t&&Object.assign(this,t)}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i="RelinkFrom",e=null;if(t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkFrom()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null&&(e=this.makeAdornment(s,!1),t.addAdornment(i,e)))}if(e===null&&t.removeAdornment(i),i="RelinkTo",e=null,t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkTo()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null?(e=this.makeAdornment(s,!0),t.addAdornment(i,e)):e.u())}e===null&&t.removeAdornment(i)}makeAdornment(t,i){const e=new Adornment;e.type=Panel.Link;const s=i?this.toHandleArchetype:this.fromHandleArchetype;return s!==null&&e.add(s.copy().Cm()),e.adornedObject=t,e}get fromHandleArchetype(){return this.$S}set fromHandleArchetype(t){t!==null&&Util.s(t,GraphObject,RelinkingTool,"fromHandleArchetype"),this.$S=t}get toHandleArchetype(){return this.QS}set toHandleArchetype(t){t!==null&&Util.s(t,GraphObject,RelinkingTool,"toHandleArchetype"),this.QS=t}get handle(){return this.ps}set handle(t){if(t!==null&&(Util.s(t,GraphObject,RelinkingTool,"handle"),!(t.part instanceof Adornment)))throw new Error("new handle is not in an Adornment: "+t);this.ps=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowRelink||!t.model.Jw()||!t.lastInput.left)return!1;let e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom");return e===null&&(e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo")),e!==null}doActivate(){const t=this.diagram;if(this.originalLink===null){let i=this.handle;if(i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom"),i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo"))),i===null)return;const e=i.part;if(!(e instanceof Adornment)||!(e.adornedPart instanceof Link))return;this.handle=i,this.isForwards=e===null||e.category==="RelinkTo",this.originalLink=e.adornedPart}this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.originalFromPort=this.originalLink.fromPort,this.originalFromNode=this.originalLink.fromNode,this.originalToPort=this.originalLink.toPort,this.originalToNode=this.originalLink.toNode,this._S.set(this.originalLink.actualBounds),this.originalLink!==null&&this.originalLink.pointsCount>0&&(this.originalLink.fromNode===null&&(this.temporaryFromPort!==null&&(this.temporaryFromPort.desiredSize=Size.hf),this.temporaryFromNode!==null&&(this.temporaryFromNode.location=this.originalLink.getPoint(0))),this.originalLink.toNode===null&&(this.temporaryToPort!==null&&(this.temporaryToPort.desiredSize=Size.hf),this.temporaryToNode!==null&&(this.temporaryToNode.location=this.originalLink.getPoint(this.originalLink.pointsCount-1)))),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0),t.add(this.temporaryFromNode),t.add(this.temporaryToNode),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.copyLinkProperties(this.originalLink,this.temporaryLink),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}copyLinkProperties(t,i){if(t===null||i===null)return;i.adjusting=t.adjusting,i.corner=t.corner;let e=t.curve;(e===11||e===10)&&(e=0),i.curve=e,i.curviness=t.curviness,i.isTreeLink=t.isTreeLink,i.points=t.points,i.routing=t.routing,i.smoothness=t.smoothness,i.fromSpot=t.fromSpot,i.fromEndSegmentLength=t.fromEndSegmentLength,i.fromShortLength=t.fromShortLength,i.toSpot=t.toSpot,i.toEndSegmentLength=t.toEndSegmentLength,i.toShortLength=t.toShortLength}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.handle=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=this.originalFromNode,e=this.originalFromPort,s=this.originalToNode,n=this.originalToPort,o=this.originalLink;try{if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null){const r=this.targetPort.part;r instanceof Node&&(this.isForwards?(s=r,n=this.targetPort):(i=r,e=this.targetPort))}else this.isUnconnectedLinkValid?this.isForwards?(s=null,n=null):(i=null,e=null):o=null;o!==null?(this.reconnectLink(o,this.isForwards?s:i,this.isForwards?n:e,this.isForwards),this.targetPort===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint,o.invalidateRoute()),this.transactionResult=this.name,t.B("LinkRelinked",o,this.isForwards?this.originalToPort:this.originalFromPort)):this.doNoRelink(this.originalLink,this.isForwards),this.originalLink.invalidateOtherJumpOvers(this._S)}finally{this.stopTool()}}}reconnectLink(t,i,e,s){const n=e!==null&&e.portId!==null?e.portId:"";return s?(t.toNode=i,t.toPortId=n):(t.fromNode=i,t.fromPortId=n),!0}doNoRelink(t,i){}doDraggingMouseMove(t,i,e,s){t!==null?(this.copyPortProperties(t,i,this.temporaryFromNode,this.temporaryFromPort,!1),this.diagram.add(this.temporaryFromNode)):this.diagram.remove(this.temporaryFromNode),e!==null?(this.copyPortProperties(e,s,this.temporaryToNode,this.temporaryToPort,!0),this.diagram.add(this.temporaryToNode)):this.diagram.remove(this.temporaryToNode)}stopDraggingMouseMove(){this.diagram.remove(this.temporaryFromNode),this.diagram.remove(this.temporaryToNode)}}var ReshapingBehavior=(w=>(w[w.None=0]="None",w[w.Horizontal=1]="Horizontal",w[w.Vertical=2]="Vertical",w[w.All=3]="All",w))(ReshapingBehavior||{});class LinkReshapingTool extends Tool{Fo;tM;iM;ps;Zw;eM;Am;constructor(t){super(),this.name="LinkReshaping",this.Fo=new Shape("Rectangle",{desiredSize:Size.lC,fill:"lightblue",stroke:"dodgerblue"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.tM=new Shape("Diamond",{desiredSize:Size.du,fill:"lightblue",stroke:"dodgerblue",cursor:"move"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.iM=3,this.ps=null,this.Zw=null,this.eM=new Point,this.Am=new List,t&&Object.assign(this,t)}static None=0;static Horizontal=1;static Vertical=2;static All=3;getReshapingBehavior(t){return t?t.Mr:0}setReshapingBehavior(t,i){t.Mr=i}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i=null;if(t.isSelected&&!this.diagram.isReadOnly){const e=t.path;e!==null&&t.canReshape()&&t.actualBounds.isReal()&&t.isVisible()&&e.actualBounds.isReal()&&e.isVisibleObject()&&(i=t.findAdornment(this.name),(i===null||i.sM!==t.pointsCount||i.nM!==t.resegmentable)&&(i=this.makeAdornment(e),i!==null&&(i.sM=t.pointsCount,i.nM=t.resegmentable,t.addAdornment(this.name,i))))}i===null&&t.removeAdornment(this.name)}makeAdornment(t){const i=t.part,e=i.points,s=i.pointsCount,n=i.isOrthogonal;let o=null;if(e!==null&&s>1){o=new Adornment,o.type=Panel.Link;const r=i.firstPickIndex,l=i.lastPickIndex,h=n?1:0;if(i.resegmentable&&i.computeCurve()!==9)for(let a=r+h;ae.firstPickIndex+1&&s0))this.fF(t,i);else if(t instanceof Panel){const e=t.elements;for(;e.next();){const s=e.value;this.updateResizeHandles(s,i)}}}}fF(t,i){let e=t.alignment;e.isNoSpot()&&(e=Spot.Center);let s=i;if(e.x<=0)e.y<=0?s+=225:e.y>=1?s+=135:s+=180;else if(e.x>=1)e.y<=0?s+=315:e.y>=1&&(s+=45);else if(e.y<=0)s+=270;else if(e.y>=1)s+=90;else return;s<0?s+=360:s>=360&&(s-=360),s<22.5?t.cursor="e-resize":s<67.5?t.cursor="se-resize":s<112.5?t.cursor="s-resize":s<157.5?t.cursor="sw-resize":s<202.5?t.cursor="w-resize":s<247.5?t.cursor="nw-resize":s<292.5?t.cursor="n-resize":s<337.5?t.cursor="ne-resize":t.cursor="e-resize"}get handleArchetype(){return this.Fo}set handleArchetype(t){t!==null&&Util.s(t,GraphObject,ResizingTool,"handleArchetype"),this.Fo=t}get handle(){return this.ps}set handle(t){if(t!==null&&(Util.s(t,GraphObject,ResizingTool,"handle"),!(t.part instanceof Adornment)))throw new Error("new handle is not in an Adornment: "+t);this.ps=t}get adornedObject(){return this.ys}set adornedObject(t){if(t!==null&&(Util.s(t,GraphObject,ResizingTool,"handle"),t.part instanceof Adornment))throw new Error("new handle must not be in an Adornment: "+t);this.ys=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowResize||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle!==null&&(this.adornedObject=this.handle.part.adornedObject,this.adornedObject!==null&&(t.isMouseCaptured=!0,t.animationManager.stopAnimation(),t.Mu=!0,this.startTransaction(this.name),this.Lm.set(this.adornedObject.getDocumentPoint(this.handle.alignment.opposite())),this.Cf.set(this.adornedObject.part.location),this.rM.set(this.adornedObject.desiredSize),this._w=this.computeCellSize(),this.$w=this.computeMinSize(),this.Qw=this.computeMaxSize(),this.isActive=!0))}doDeactivate(){const t=this.diagram;t.Mu=!1,t.Pl=!0,this.stopTransaction(),this.handle=null,this.ys=null,t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){this.adornedObject!==null&&(this.adornedObject.desiredSize=this.originalDesiredSize,this.adornedObject.part.location=this.originalLocation),this.stopTool()}doMouseMove(){const t=this.diagram;if(!this.isActive)return;const i=this.$w,e=this.Qw,s=this._w,n=t.lastInput.documentPoint,o=this.adornedObject.getLocalPoint(n,Point.a()),r=this.computeReshape(),l=this.computeResize(o,this.handle.alignment,i,e,s,r);this.resize(l),t.maybeUpdate(),Point.o(o)}doMouseUp(){const t=this.diagram;if(this.isActive){const i=this.$w,e=this.Qw,s=this._w,n=this.adornedObject.getLocalPoint(t.lastInput.documentPoint,Point.a()),o=this.computeReshape(),r=this.computeResize(n,this.handle.alignment,i,e,s,o);this.resize(r),Point.o(n),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.B("PartResized",this.adornedObject,this.originalDesiredSize)}this.stopTool()}resize(t){const i=this.diagram,e=this.adornedObject;if(e===null)return;e.desiredSize=t.size;const s=e.part;s.ensureBounds();const n=e.getDocumentPoint(this.handle.alignment.opposite());if(s instanceof Group){const o=new List;o.add(s);let r;!this.dragsMembers&&!s.hasPlaceholder()&&(r=new DraggingOptions,r.dragsMembers=!1),i.moveParts(o,this.oppositePoint.copy().subtract(n),!0,r)}else s.location=s.location.copy().subtract(n).add(this.oppositePoint);i.maybeUpdate()}computeResize(t,i,e,s,n,o){i.isNoSpot()&&(i=Spot.Center);const r=this.adornedObject.naturalBounds,l=r.x,h=r.y,a=r.x+r.width,f=r.y+r.height;let c=1;if(!o){let m=r.width,g=r.height;m<=0&&(m=1),g<=0&&(g=1),c=g/m}const u=Point.a();Geo.Gg(t.x,t.y,l,h,n.width,n.height,u);const d=r.copy();return i.x<=0?i.y<=0?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.y=Math.max(u.y,f-s.height),d.y=Math.min(d.y,f-e.height),d.height=Math.max(f-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width),d.x=a-d.width,d.y=f-d.height)):i.y>=1?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width),d.x=a-d.width)):(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=a-d.x,o||(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c,d.y=h+.5*(f-h-d.height))):i.x>=1?i.y<=0?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.y=Math.max(u.y,f-s.height),d.y=Math.min(d.y,f-e.height),d.height=Math.max(f-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width),d.y=f-d.height)):i.y>=1?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width))):(d.width=Math.max(Math.min(u.x-l,s.width),e.width),o||(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c,d.y=h+.5*(f-h-d.height))):i.y<=0?(d.y=Math.max(u.y,f-s.height),d.y=Math.min(d.y,f-e.height),d.height=f-d.y,o||(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width,d.x=l+.5*(a-l-d.width))):i.y>=1&&(d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width,d.x=l+.5*(a-l-d.width))),Point.o(u),d}computeReshape(){let t=0;return this.adornedObject instanceof Shape&&(t=this.adornedObject.lM()),!(t===6||this.diagram.lastInput.shift)}computeMinSize(){const t=this.adornedObject.minSize.copy(),i=this.minSize;return!isNaN(i.width)&&i.width>t.width&&(t.width=i.width),!isNaN(i.height)&&i.height>t.height&&(t.height=i.height),t}computeMaxSize(){const t=this.adornedObject.maxSize.copy(),i=this.maxSize;return!isNaN(i.width)&&i.width0&&(t.width=n.width),!isNaN(n.height)&&n.height>0&&(t.height=n.height)}let e=this.cellSize;isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height);const s=this.diagram;if((isNaN(t.width)||isNaN(t.height))&&s){const n=s.grid;n!==null&&n.visible&&this.isGridSnapEnabled&&(e=n.gridCellSize,isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height))}return(isNaN(t.width)||t.width===0||t.width===1/0)&&(t.width=1),(isNaN(t.height)||t.height===0||t.height===1/0)&&(t.height=1),t}get minSize(){return this.Pr}set minSize(t){if(Util.s(t,Size,ResizingTool,"minSize"),!this.Pr.equals(t)){let e=t.width;isNaN(e)&&(e=0);let s=t.height;isNaN(s)&&(s=0),this.Pr.e(e,s)}}get maxSize(){return this.Nr}set maxSize(t){if(Util.s(t,Size,ResizingTool,"maxSize"),!this.Nr.equals(t)){let e=t.width;isNaN(e)&&(e=1/0);let s=t.height;isNaN(s)&&(s=1/0),this.Nr.e(e,s)}}get cellSize(){return this.Ro}set cellSize(t){Util.s(t,Size,ResizingTool,"cellSize"),this.Ro.equals(t)||this.Ro.c(t)}get isGridSnapEnabled(){return this.Nf}set isGridSnapEnabled(t){Util.t(t,"boolean",ResizingTool,"isGridSnapEnabled"),this.Nf=t}get dragsMembers(){return this.oM}set dragsMembers(t){Util.t(t,"boolean",ResizingTool,"dragsMembers"),this.oM=t}get oppositePoint(){return this.Lm}set oppositePoint(t){Util.s(t,Point,ResizingTool,"oppositePoint"),this.Lm.equals(t)||this.Lm.c(t)}get originalDesiredSize(){return this.rM}get originalLocation(){return this.Cf}}class RotatingTool extends Tool{hM;aM;ys;Fo;ps;fM;Tm;Cf;cM;uM;constructor(t){super(),this.name="Rotating",this.hM=45,this.aM=2,this.Cf=new Point,this.ys=null,this.Fo=new Shape("Ellipse",{desiredSize:Size.du,fill:"lightblue",stroke:"dodgerblue",strokeWidth:1,cursor:"pointer"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.ps=null,this.fM=0,this.Tm=new Point(NaN,NaN),this.cM=0,this.uM=50,t&&Object.assign(this,t)}updateAdornments(t){if(t!==null){if(t.Dl()){const i=t.rotateObject;if(i===t||i===t.path||i.isPanelMain)return}if(t.isSelected&&!this.diagram.isReadOnly){const i=t.rotateObject;if(i!==null&&t.canRotate()&&t.actualBounds.isReal()&&t.isVisible()&&i.actualBounds.isReal()&&i.isVisibleObject()){let e=t.findAdornment(this.name);if((e===null||e.adornedObject!==i)&&(e=this.makeAdornment(i)),e!==null){e.angle=i.getDocumentAngle(),e.hasPlaceholder()||(e.location=this.computeAdornmentLocation(i)),t.addAdornment(this.name,e);return}}}t.removeAdornment(this.name)}}makeAdornment(t){let i=null;const e=t.part.rotateAdornmentTemplate;if(e===null){i=new Adornment,i.type=Panel.Position,i.locationSpot=Spot.Center;const s=this.handleArchetype;s!==null&&i.add(s.copy().Cm())}else if(e.ci(),i=e.copy(),i===null)return null;return i.adornedObject=t,i}get handleArchetype(){return this.Fo}set handleArchetype(t){t!==null&&Util.s(t,GraphObject,RotatingTool,"handleArchetype"),this.Fo=t}get handle(){return this.ps}set handle(t){if(t!==null&&(Util.s(t,GraphObject,RotatingTool,"handle"),!(t.part instanceof Adornment)))throw new Error("new handle is not in an Adornment: "+t);this.ps=t}get adornedObject(){return this.ys}set adornedObject(t){if(t!==null&&(Util.s(t,GraphObject,RotatingTool,"handle"),t.part instanceof Adornment))throw new Error("new handle must not be in an Adornment: "+t);this.ys=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowRotate||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;if(this.adornedObject===null){if(this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle===null)return;this.adornedObject=this.handle.part.adornedObject}this.adornedObject!==null&&(t.isMouseCaptured=!0,t.delaysLayout=!0,this.startTransaction(this.name),this.fM=this.adornedObject.angle,this.Tm=this.computeRotationPoint(this.adornedObject),this.Cf=this.adornedObject.part.location.copy(),this.isActive=!0)}computeRotationPoint(t){const i=t.part,e=i.locationObject;return i.rotationSpot.isSpot()?t.getDocumentPoint(i.rotationSpot):t===i||t===e?e.getDocumentPoint(i.locationSpot):t.getDocumentPoint(Spot.Center)}computeAdornmentLocation(t){let i=this.rotationPoint;i.isReal()||(i=this.computeRotationPoint(t));const e=t.getLocalPoint(i);let s=this.handleAngle;s<0?s+=360:s>=360&&(s-=360),s=Math.round(Math.round(s/45)*45);const n=this.handleDistance;return s===0?e.x=t.naturalBounds.width+n:s===45?(e.x=t.naturalBounds.width+n,e.y=t.naturalBounds.height+n):s===90?e.y=t.naturalBounds.height+n:s===135?(e.x=-n,e.y=t.naturalBounds.height+n):s===180?e.x=-n:s===225?(e.x=-n,e.y=-n):s===270?e.y=-n:s===315&&(e.x=t.naturalBounds.width+n,e.y=-n),t.getDocumentPoint(e)}doDeactivate(){const t=this.diagram;this.stopTransaction(),this.handle=null,this.ys=null,this.Tm=new Point(NaN,NaN),t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){const t=this.diagram;t.delaysLayout=!1,this.rotate(this.originalAngle),this.stopTool()}doMouseMove(){const t=this.diagram;if(this.isActive){const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i)}}doMouseUp(){const t=this.diagram;if(this.isActive){t.delaysLayout=!1;const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.B("PartRotated",this.adornedObject,this.originalAngle)}this.stopTool()}rotate(t){Debug&&Util.r(t,RotatingTool,"rotate:newangle");const i=this.adornedObject;if(i===null)return;i.angle=t;const e=i.part;e.ensureBounds();const s=e.locationObject,n=e.rotateObject;if(s===n||s.isContainedBy(n)){const o=this.Cf.copy();e.location=o.subtract(this.rotationPoint).rotate(t-this.originalAngle).add(this.rotationPoint)}this.diagram.maybeUpdate()}computeRotate(t){let i=this.rotationPoint.directionPoint(t)-this.handleAngle;const e=this.adornedObject.panel;e!==null&&(i-=e.getDocumentAngle()),i>=360?i-=360:i<0&&(i+=360);const s=Math.min(Math.abs(this.snapAngleMultiple),180),n=Math.min(Math.abs(this.snapAngleEpsilon),s/2);return!this.diagram.lastInput.shift&&s>0&&n>0&&(i%ss-n&&(i=(Math.floor(i/s)+1)*s)),i>=360?i-=360:i<0&&(i+=360),i}get snapAngleMultiple(){return this.hM}set snapAngleMultiple(t){Util.t(t,"number",RotatingTool,"snapAngleMultiple"),this.hM=t}get snapAngleEpsilon(){return this.aM}set snapAngleEpsilon(t){Util.t(t,"number",RotatingTool,"snapAngleEpsilon"),this.aM=t}get originalAngle(){return this.fM}get rotationPoint(){return this.Tm}set rotationPoint(t){this.Tm=t.copy()}get handleAngle(){return this.cM}set handleAngle(t){Util.t(t,"number",RotatingTool,"handleAngle"),this.cM=t}get handleDistance(){return this.uM}set handleDistance(t){Util.t(t,"number",RotatingTool,"handleDistance"),this.uM=t}}class ClickSelectingTool extends Tool{constructor(t){super(),this.name="ClickSelecting",t&&Object.assign(this,t)}canStart(){return!(!this.isEnabled||this.isBeyondDragSize())}doMouseUp(){this.isActive&&(this.standardMouseSelect(),this.standardMouseClick()||this.diagram.lastInput.isTouchEvent&&this.diagram.toolManager.doToolTip()),this.stopTool()}}class ActionTool extends Tool{Af;constructor(t){super(),this.name="Action",this.Af=null,t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram,i=t.lastInput,e=t.findObjectAt(i.documentPoint,s=>{for(;s.panel!==null;){if(s.isActionable)return s;s=s.panel}return s});return e!==null&&e.isActionable?(this.Af=e,t.xf=t.findObjectAt(i.documentPoint,null,null),!0):!1}doMouseDown(){if(!this.isActive)this.canStart()&&this.doActivate();else{const i=this.diagram.lastInput,e=this.Af;if(e===null)return;i.targetObject=e,e.actionDown!==null&&e.actionDown(i,e)}}doMouseMove(){if(this.isActive){const i=this.diagram.lastInput,e=this.Af;if(e===null)return;i.targetObject=e,e.actionMove!==null&&e.actionMove(i,e)}}doMouseUp(){if(this.isActive){const i=this.diagram.lastInput,e=this.Af;if(e===null)return;i.targetObject=e,e.actionUp!==null&&e.actionUp(i,e),this.standardMouseClick(s=>{for(;s.panel!==null;){if(s.isActionable&&s===e)return s;s=s.panel}return s},s=>s===e)}this.stopTool()}doCancel(){const i=this.diagram.lastInput,e=this.Af;e!==null&&(i.targetObject=e,e.actionCancel!==null&&e.actionCancel(i,e),this.stopTool())}doStop(){this.Af=null}}class ClickCreatingTool extends Tool{Fl;dM;Nf;gM;constructor(t){super(),this.name="ClickCreating",this.Fl=null,this.dM=!0,this.Nf=!1,this.gM=new Point(0,0),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled||this.archetypeNodeData===null)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.lastInput.left||this.isBeyondDragSize())return!1;if(this.isDoubleClick){if(t.lastInput.clickCount===1&&(this.gM=t.lastInput.viewPoint.copy()),t.lastInput.clickCount!==2||this.isBeyondDragSize(this.gM))return!1}else if(t.lastInput.clickCount!==1)return!1;return!(t.currentTool!==this&&t.findPartAt(t.lastInput.documentPoint,!0)!==null)}doMouseUp(){const t=this.diagram;this.isActive&&this.insertPart(t.lastInput.documentPoint),this.stopTool()}insertPart(t){const i=this.diagram,e=this.archetypeNodeData;if(e===null)return null;let s=null;try{if(i.B("ChangingSelection",i.selection),this.startTransaction(this.name),e instanceof Part)e.Ae()&&(e.ci(),s=e.copy(),s!==null&&i.add(s));else if(e!==null){const n=i.model.copyNodeData(e);Util.Mt(n)&&(i.model.addNodeData(n),s=i.findPartForData(n))}if(s!==null){const n=Point.H(t.x,t.y);this.isGridSnapEnabled&&this.diagram.mM(s,t,n),s.location=n,i.allowSelect&&(i.clearSelection(!0),s.isSelected=!0),Point.o(n)}i.invalidateDocumentBounds(),this.transactionResult=this.name,i.B("PartCreated",s)}finally{this.stopTransaction(),i.B("ChangedSelection",i.selection)}return s}get archetypeNodeData(){return this.Fl}set archetypeNodeData(t){t!==null&&Util.t(t,"object",ClickCreatingTool,"archetypeNodeData"),this.Fl=t}get isDoubleClick(){return this.dM}set isDoubleClick(t){Util.t(t,"boolean",ClickCreatingTool,"isDoubleClick"),this.dM=t}get isGridSnapEnabled(){return this.Nf}set isGridSnapEnabled(t){Util.t(t,"boolean",ClickCreatingTool,"isGridSnapEnabled"),this.Nf=t}}class DragSelectingTool extends Tool{Gh;pM;Rl;constructor(t){super(),this.name="DragSelecting",this.Gh=175,this.pM=!1,this.Rl=new Part({layerName:"Tool",selectable:!1}).add(new Shape("Rectangle",{name:"SHAPE",fill:null,stroke:"magenta"}).theme("stroke","dragSelect")).ci(),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(!t.allowSelect)return!1;const i=t.lastInput;return!(!i.left||t.currentTool!==this&&(!this.isBeyondDragSize()||i.timestamp-t.firstInput.timestamp{const e=i.diagram;e!==null&&e.Li(root.document,"scroll",i.yM,!1),i.stopTool()},t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return!(!t.allowHorizontalScroll&&!t.allowVerticalScroll||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize())}doActivate(){const t=this.diagram;this.Do?(t.lastInput.bubbles=!0,t.Ht(root.document,"scroll",this.yM,!1)):(t.currentCursor="move",t.isMouseCaptured=!0,this.tx.c(t.position)),this.isActive=!0}doDeactivate(){const t=this.diagram;t.currentCursor="",t.isMouseCaptured=!1,this.isActive=!1}doCancel(){const t=this.diagram;t.position=this.tx,t.isMouseCaptured=!1,this.stopTool()}doMouseMove(){this.$C()}doMouseUp(){this.$C(),this.stopTool()}$C(){const t=this.diagram;if(this.isActive&&t){if(this.Do){t.lastInput.bubbles=!0;return}const i=t.position,e=t.firstInput.documentPoint,s=t.lastInput.documentPoint;let n=i.x+e.x-s.x,o=i.y+e.y-s.y;t.allowHorizontalScroll||(n=i.x),t.allowVerticalScroll||(o=i.y),t.position=this.ZC.e(n,o)}}get bubbles(){return this.Do}set bubbles(t){Util.t(t,"boolean",PanningTool,"bubbles"),this.Do=t}get originalPosition(){return this.tx}}class HTMLInfo{ix;ex;wM;xM;constructor(t){this.ix=null,this.ex=null,this.wM=null,this.xM=null,t&&Object.assign(this,t)}get mainElement(){return this.wM}set mainElement(t){t!==null&&Util.s(t,HTMLElement,HTMLInfo,"mainElement"),this.wM=t}get show(){return this.ix}set show(t){this.ix!==t&&(t!==null&&Util.t(t,"function",HTMLInfo,"show"),this.ix=t)}get hide(){return this.ex}set hide(t){this.ex!==t&&(t!==null&&Util.t(t,"function",HTMLInfo,"hide"),this.ex=t)}get valueFunction(){return this.xM}set valueFunction(t){this.xM=t}}class ContextMenuButtonInfo{ui;Dm;Tf;constructor(t,i,e){this.ui=t,this.Dm=i,this.Tf=e}}class ContextMenuTool extends Tool{bM;sx;kM;SM;nx;ox;Fm;constructor(t){super(),this.name="ContextMenu",this.bM=null,this.sx=null,this.kM=null,this.SM=new Point,this.nx=null,this.Fm=!1;const i=this;this.ox=()=>i.stopTool(),t&&Object.assign(this,t)}cF(){const t=new HTMLInfo;t.show=(r,l,h)=>h.showDefaultContextMenu(),t.hide=(r,l)=>l.hideDefaultContextMenu(),ContextMenuTool.Au=t;const i=this;this.ox=()=>i.stopTool();const e=Util.ln("div"),s=Util.ln("div");e.style.cssText="top: 0px;z-index:10002;position: fixed;display: none;text-align: center;left: 25%;width: 50%;background-color: #F5F5F5;padding: 16px;border: 16px solid #444;border-radius: 10px;margin-top: 10px",s.style.cssText="z-index:10001;position: fixed;display: none;top: 0;left: 0;width: 100%;height: 100%;background-color: black;opacity: 0.8;";const n=Util.ln("style");root.document.getElementsByTagName("head")[0].appendChild(n),n.sheet.insertRule(".goCXul { list-style: none; }",0),n.sheet.insertRule(".goCXli {font:700 1.5em Helvetica, Arial, sans-serif;position: relative;min-width: 60px; }",0),n.sheet.insertRule(".goCXa {color: #444;display: inline-block;padding: 4px;text-decoration: none;margin: 2px;border: 1px solid gray;border-radius: 10px; }",0);const o=this.diagram;o!==null&&(o.Ht(e,"contextmenu",ContextMenuTool.Wh,!1),o.Ht(e,"selectstart",ContextMenuTool.Wh,!1),o.Ht(s,"contextmenu",ContextMenuTool.Wh,!1)),e.className="goCXforeground",s.className="goCXbackground",root.document.body&&(root.document.body.appendChild(e),root.document.body.appendChild(s)),ContextMenuTool.Rm=e,ContextMenuTool.Im=s,ContextMenuTool.MM=!0}static Au=null;static MM=!1;static Im=null;static Rm=null;static Wh(t){return t.preventDefault(),!1}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return this.isBeyondDragSize()||!t.lastInput.right||t.lastInput.clickCount>1?!1:!!(t.lastInput.isTouchEvent&&this.defaultTouchContextMenu!==null||this.findObjectWithContextMenu()!==null)}doStart(){const t=this.diagram;this.SM.set(t.firstInput.documentPoint)}doStop(){this.hideContextMenu(),this.currentObject=null,this.Fm=!1}findObjectWithContextMenu(t){t===void 0&&(t=null);const i=this.diagram,e=i.lastInput;let s=null;if(t instanceof Diagram||(t instanceof GraphObject?s=t:s=i.findObjectAt(e.documentPoint,null,n=>!n.layer.isTemporary)),s!==null){let n=s;for(;n!==null;){if(n.contextMenu!==null)return n;n=n.panel}if(i.lastInput.isTouchEvent&&this.defaultTouchContextMenu)return s.part}else if(i.contextMenu!==null)return i;return null}doActivate(){}doMouseDown(){if(super.doMouseDown(),this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doMouseDown(),t.doDeactivate())}this.diagram.toolManager.mouseDownTools.has(this)&&this.doContextClick()}doMouseUp(){if(this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doCancel(),t.doDeactivate())}this.doContextClick()}doContextClick(){const t=this.diagram;if(!this.isActive)this.canStart()&&(this.openMenu(!0),this.isActive||this.stopTool());else{const i=this.currentContextMenu;if(i===null)return;let e=null;i instanceof HTMLInfo||(e=t.findObjectAt(t.lastInput.documentPoint,null,null),e!==null&&e.isContainedBy(i)&&this.standardMouseClick(null,null)),this.maybeStopTool(e)}}maybeStopTool(t){this.stopTool(),this.canStart()&&(this.diagram.currentTool=this,this.doMouseUp())}openMenu(t,i){if(i===void 0&&(i=null),this.Fm)return;this.Fm=!0,t&&this.standardMouseSelect();const e=this.standardMouseClick();if(this.Fm=!1,!e){this.isActive=!0;const s=ContextMenuTool.Au;if(i===null&&(i=this.findObjectWithContextMenu()),i!==null){const n=i.contextMenu;n!==null?(this.currentObject=i instanceof GraphObject?i:null,this.showContextMenu(n,this.currentObject)):s!==null&&this.showContextMenu(s,this.currentObject)}else s!==null&&this.showContextMenu(s,null);this.currentContextMenu instanceof Adornment&&!this.currentContextMenu.visible&&this.stopTool()}}doMouseMove(){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.doMouseMove(),this.isActive&&this.diagram.toolManager.doMouseMove()}showContextMenu(t,i){Debug&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("showContextMenu:contextMenu must be an Adornment or HTMLInfo."),i!==null&&Util.s(i,GraphObject,ContextMenuTool,"showContextMenu:obj");const e=this.diagram;if(t!==this.currentContextMenu&&this.hideContextMenu(),t instanceof Adornment){const s=t;s.layerName="Tool",s.selectable=!1,s.scale=1/e.scale,s.category=this.name,s.hasPlaceholder()&&(s.placeholder.scale=e.scale);const n=s.diagram;n!==null&&n!==e&&n.remove(s),e.add(s),i!==null?s.adornedObject=i:s.data=e.model,s.ensureBounds(),this.positionContextMenu(s,i)}else t instanceof HTMLInfo&&t.show(i,e,this);this.currentContextMenu=t}positionContextMenu(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom&&(n.y-=o.height+5/s.scale),n.ye.commandHandler.copySelection(),e=>e.commandHandler.canCopySelection())),i.add(new ContextMenuButtonInfo("Cut",e=>e.commandHandler.cutSelection(),e=>e.commandHandler.canCutSelection())),i.add(new ContextMenuButtonInfo("Delete",e=>e.commandHandler.deleteSelection(),e=>e.commandHandler.canDeleteSelection())),i.add(new ContextMenuButtonInfo("Paste",e=>e.commandHandler.pasteSelection(t.mouseDownPoint),e=>e.commandHandler.canPasteSelection(t.mouseDownPoint))),i.add(new ContextMenuButtonInfo("Select All",e=>e.commandHandler.selectAll(),e=>e.commandHandler.canSelectAll())),i.add(new ContextMenuButtonInfo("Undo",e=>e.commandHandler.undo(),e=>e.commandHandler.canUndo())),i.add(new ContextMenuButtonInfo("Redo",e=>e.commandHandler.redo(),e=>e.commandHandler.canRedo())),i.add(new ContextMenuButtonInfo("Scroll To Part",e=>e.commandHandler.scrollToPart(),e=>e.commandHandler.canScrollToPart())),i.add(new ContextMenuButtonInfo("Zoom To Fit",e=>e.commandHandler.zoomToFit(),e=>e.commandHandler.canZoomToFit())),i.add(new ContextMenuButtonInfo("Reset Zoom",e=>e.commandHandler.resetZoom(),e=>e.commandHandler.canResetZoom())),i.add(new ContextMenuButtonInfo("Group Selection",e=>e.commandHandler.groupSelection(),e=>e.commandHandler.canGroupSelection())),i.add(new ContextMenuButtonInfo("Ungroup Selection",e=>e.commandHandler.ungroupSelection(),e=>e.commandHandler.canUngroupSelection())),i.add(new ContextMenuButtonInfo("Edit Text",e=>e.commandHandler.editTextBlock(),e=>e.commandHandler.canEditTextBlock())),i}showDefaultContextMenu(){const t=this.diagram;this.nx===null&&(this.nx=this.uF()),ContextMenuTool.Rm.innerHTML="",ContextMenuTool.Im.addEventListener("pointerdown",this.ox,!1);const i=this,e=Util.ln("ul");e.className="goCXul",ContextMenuTool.Rm.appendChild(e),e.innerHTML="";const s=this.nx.iterator;for(;s.next();){const n=s.value,o=n.Dm,r=n.Tf;if(typeof o!="function"||typeof r=="function"&&!r(t))continue;const l=Util.ln("li");l.className="goCXli";const h=Util.ln("a");h.className="goCXa",h.href="#",h.Dm=n.Dm,h.addEventListener("pointerdown",function(a){return this.Dm(t),i.stopTool(),a.preventDefault(),!1},!1),h.textContent=n.ui,l.appendChild(h),e.appendChild(l)}ContextMenuTool.Rm.style.display="block",ContextMenuTool.Im.style.display="block"}hideDefaultContextMenu(){if(this.currentContextMenu===null||this.currentContextMenu!==ContextMenuTool.Au)return;ContextMenuTool.Rm.style.display="none",ContextMenuTool.Im.style.display="none";const t=this.diagram;t!==null&&t.Li(ContextMenuTool.Im,"pointerdown",this.ox,!1),this.currentContextMenu=null}get currentContextMenu(){return this.bM}set currentContextMenu(t){Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("ContextMenuTool.currentContextMenu must be an Adornment or HTMLInfo."),this.bM=t,this.sx=t instanceof Adornment?t.adornedPart:null}get defaultTouchContextMenu(){return ContextMenuTool.MM===!1&&ContextMenuTool.Au===null&&Diagram.isUsingDOM()&&this.cF(),ContextMenuTool.Au}set defaultTouchContextMenu(t){Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("ContextMenuTool.defaultTouchContextMenu must be an Adornment or HTMLInfo."),t===null&&(ContextMenuTool.MM=!0),ContextMenuTool.Au=t}get currentObject(){return this.kM}set currentObject(t){t!==null&&Util.s(t,GraphObject,ContextMenuTool,"currentObject"),this.kM=t}get mouseDownPoint(){return this.SM}}var TextEditingAccept=(w=>(w[w.LostFocus=1]="LostFocus",w[w.MouseDown=2]="MouseDown",w[w.Tab=3]="Tab",w[w.Enter=4]="Enter",w))(TextEditingAccept||{}),TextEditingStarting=(w=>(w[w.SingleClick=1]="SingleClick",w[w.SingleClickSelected=2]="SingleClickSelected",w[w.DoubleClick=3]="DoubleClick",w))(TextEditingStarting||{}),TextEditingState=(w=>(w[w.None=1]="None",w[w.Active=2]="Active",w[w.Editing=3]="Editing",w[w.Validating=4]="Validating",w[w.Invalid=5]="Invalid",w[w.Validated=6]="Validated",w))(TextEditingState||{});class TextEditingTool extends Tool{Le;PM;NM;Il;vt;CM;AM;LM;rx;lx;constructor(t){super(),this.name="TextEditing",this.Le=new TextBlock,this.PM=null,this.NM=2,this.Il=null,this.vt=1,this.CM=1,this.AM=!0,this.LM=null,this.rx=new HTMLInfo,this.lx=null,this.dF(this.rx),t&&Object.assign(this,t)}static LostFocus=1;static MouseDown=2;static Tab=3;static Enter=4;static SingleClick=1;static SingleClickSelected=2;static DoubleClick=3;static StateNone=1;static StateActive=2;static StateEditing=3;static StateValidating=4;static StateInvalid=5;static StateValidated=6;dF(t){if(!Diagram.isUsingDOM())return;const i=Util.ln("textarea");this.lx=i;const e=this;i.addEventListener("input",function(s){if(e.textBlock===null)return;const n=e.measureTemporaryTextBlock(this.value),o=this.textScale;this.style.width=20+Math.max(e.textBlock.measuredBounds.width,n.measuredBounds.width)*o+"px",this.rows=Math.max(e.textBlock.lineCount,n.lineCount)},!1),i.addEventListener("keydown",function(s){if(s.isComposing||e.textBlock===null)return;const n=s.key;if(n==="Enter"){e.textBlock.isMultiline===!1&&s.preventDefault(),e.acceptText(4);return}else if(n==="Tab"){e.acceptText(3),s.preventDefault();return}else n==="Escape"&&(e.doCancel(),e.diagram!==null&&e.diagram.doFocus())},!1),i.addEventListener("focus",function(s){e.gF(s)},!1),i.addEventListener("blur",function(s){e.mF(s)},!1),t.valueFunction=()=>i.value,t.mainElement=i,t.show=(s,n,o)=>{if(!(s instanceof TextBlock&&o instanceof TextEditingTool))return;if(o.state===5){i.style.border="3px solid red",i.focus();return}const r=s.getDocumentPoint(Spot.Center),l=n.position,h=n.scale;let a=s.getDocumentScale()*h;a{s.div.removeChild(i)}}get textBlock(){return this.PM}set textBlock(t){t!==null&&Util.s(t,TextBlock,TextEditingTool,"textBlock"),this.PM=t}get currentTextEditor(){return this.LM}set currentTextEditor(t){this.LM=t}get defaultTextEditor(){return this.rx}set defaultTextEditor(t){Debug&&!(t instanceof HTMLInfo)&&Util.n("TextEditingTool.defaultTextEditor must be an HTMLInfo."),this.rx=t}get starting(){return this.NM}set starting(t){Util.tt(t,TextEditingStarting,"TextEditingStarting"),this.NM=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t===null||t.isReadOnly||TextEditingTool.Df&&TextEditingTool.Df!==this&&(TextEditingTool.Df.acceptText(2),TextEditingTool.Df&&TextEditingTool.Df!==this)||!t.lastInput.left||this.isBeyondDragSize())return!1;const i=t.lastInput.documentPoint,e=t.findObjectAt(i);if(e===null||!(e instanceof TextBlock)||!e.editable||!e.part.canEdit())return!1;const s=e.part;return!(s===null||this.starting===2&&!s.isSelected||this.starting===3&&t.lastInput.clickCount<2)}doStart(){TextEditingTool.Df=this,this.textBlock!==null&&this.doActivate()}doActivate(){if(this.isActive)return;const t=this.diagram;if(t===null)return;let i=this.textBlock;if(i===null&&(i=t.findObjectAt(t.lastInput.documentPoint)),i===null||!(i instanceof TextBlock)||(this.textBlock=i,i.part===null))return;t.animationManager.stopAnimation(),this.isActive=!0,this.vt=2;let s=this.defaultTextEditor;i.textEditor!==null&&(s=i.textEditor),this.Le=this.textBlock.copy();const n=new Rect(this.textBlock.getDocumentPoint(Spot.TopLeft),this.textBlock.getDocumentPoint(Spot.BottomRight));t.scrollToRect(n),s.show(i,t,this),this.currentTextEditor=s}doCancel(){this.stopTool()}doMouseUp(){this.canStart()&&this.doActivate()}doMouseDown(){this.isActive&&this.acceptText(2)}acceptText(t){switch(t){case 2:this.vt===6?this.currentTextEditor instanceof HTMLElement&&this.currentTextEditor.focus():(this.vt===2||this.vt===5||this.vt===3)&&(this.vt=4,this.QC());break;case 1:case 4:case 3:if(t===4&&this.textBlock.isMultiline===!0)return;(this.vt===2||this.vt===5||this.vt===3)&&(this.vt=4,this.QC());break}}QC(){const t=this.textBlock,i=this.diagram,e=this.currentTextEditor;if(t!==null&&e!==null){const s=t.text;let n="";if(e.valueFunction!==null&&(n=e.valueFunction()),!this.isValidText(t,s,n)){this.vt=5,this.doError(s,n);return}this.startTransaction(this.name),this.vt=6,this.transactionResult=this.name,t.text=n,this.doSuccess(s,n),i!==null&&i.B("TextEdited",t,s),this.stopTransaction(),this.stopTool(),i!==null&&i.doFocus()}}doError(t,i){const e=this.textBlock;e.errorFunction!==null&&e.errorFunction(this,t,i);const s=this.currentTextEditor;s&&s.show(e,this.diagram,this)}doSuccess(t,i){const e=this.textBlock;e.textEdited!==null&&e.textEdited(e,t,i)}doDeactivate(){const t=this.diagram;t!==null&&(this.vt=1,this.currentTextEditor!==null&&this.currentTextEditor.hide(t,this),this.textBlock=null,this.isActive=!1)}doStop(){TextEditingTool.Df=null}gF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this.lx;this.vt===2&&(this.vt=3),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}mF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this.lx;typeof i.focus=="function"&&i.focus(),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}isValidText(t,i,e){Util.s(t,TextBlock,TextEditingTool,"isValidText:textblock");const s=this.textValidation;if(s!==null&&!s(t,i,e))return!1;const n=t.textValidation;return!(n!==null&&!n(t,i,e))}get textValidation(){return this.Il}set textValidation(t){t!==null&&Util.t(t,"function",TextEditingTool,"textValidation"),this.Il=t}get minimumEditorScale(){return this.CM}set minimumEditorScale(t){t!==null&&Util.t(t,"number",TextEditingTool,"minimumEditorScale"),this.CM=t}get selectsTextOnActivate(){return this.AM}set selectsTextOnActivate(t){t!==null&&Util.t(t,"boolean",TextEditingTool,"selectsTextOnActivate"),this.AM=t}get state(){return this.vt}set state(t){this.vt!==t&&(Util.tt(t,TextEditingState,"TextEditingState"),this.vt=t)}measureTemporaryTextBlock(t){const i=this.Le;return i.text=t,i.wt(this.textBlock.Ol,1/0),i}static Df=null}var AnimationStyle=(w=>(w[w.Default=1]="Default",w[w.AnimateLocations=2]="AnimateLocations",w[w.None=3]="None",w))(AnimationStyle||{});class AnimationManager{b;Ti;Xi;Cr;Zn;Io;TM;DM;Om;Si;Ff;yn;Em;vh;hx;Bm;ax;Rf;Nu;Vm;constructor(t){this.b=Diagram.Sm(),this.Ti=!1,this.Om=!1,this.Si=!1,this.Ff=!1,this.ax=!0,this.Rf=1,this.Nu=!1,this.Xi=!0,this.Cr=!0,this.Io=600,this.TM=!1,this.DM=!1,this.Zn=new GSet,this.yn=new Animation,this.Em=new Animation,this.yn.ws=this,this.vh=new GSet,this.hx=new GSet,this.Bm=new GSet,this.Vm=new GSet,t&&Object.assign(this,t)}Oo(t){this.b=t}hE(){return this.b}canStart(t){return!0}El(t){return!this.Xi||!this.canStart(t)?!1:(this.Zn.add(t),this.defaultAnimation.isAnimating&&this.stopAnimation(),this.b.Di(),this.Si=!0,!0)}getBundleAnimation(){return this.Em}FM(){if(!this.Xi||(this.Em.me.count>0&&this.Em.start(),!this.Si))return;const t=this.yn,i=this.b,e=this.Zn.has("Model");if(e&&(this.Ff=!0,this.Rf===1?(t.isViewportUnconstrained=!0,t.me.clear(),t.add(i,"position",i.position.copy().offset(0,-200),i.position),t.add(i,"opacity",0,1)):this.Rf===3&&t.me.clear(),this.Rf===2&&i.fx.equals(i.gt)?this.ax=!0:this.ax=!1,i.B("InitialAnimationStarting",this)),e&&!this.Cr||t.me.count===0){this.Zn.clear(),this.Si=!1,t.me.clear(),t.cx(i),this.Ff=!1,i.T();return}this.Zn.clear(),i.Ar=!1;const s=t.me.get(i);i.autoScale!==1&&s!==null&&(delete s.li.scale,delete s.xs.scale);const n=this;root.requestAnimationFrame(()=>{n.Si===!1||t.Ti||(i.getRenderingHint("temporaryPixelRatio")&&i.jw(),i.RM(),n.Si=!1,t.start(),t.Ti&&(n.Lu(),i.invalidateDocumentBounds(),t._C(0),i.Sr(!0),n.Tu(),i.B("AnimationStarting",n)))})}IM(){return this.Zn.has("Trigger")&&this.Zn.count===1}tA(t,i,e,s){this.isTicking||this.IM()||t instanceof Link&&(t.fromNode!==null||t.toNode!==null)||this.yn.add(t,"position",i,e,s)}ux(t){return this.yn.ux(t)}OM(t){return this.yn.OM(t)}pF(t){const i=this.vh,e=this;function s(){if(e.Bm.count>0&&(i.addAll(e.Bm),e.Bm.clear(),e.Ti=!0),e.Ti===!1||i.count===0)return;e.hx.addAll(i);const n=e.hx.iterator;for(;n.next();){const o=n.value;o.Ti!==!1&&(o.yF()?o.iA(!1):o.If=!0)}if(e.hx.clear(),e.Ti===!1){root.requestAnimationFrame(s);return}e.Lu(),e.b.Sr(),e.Tu(),root.requestAnimationFrame(s)}this.Ti?this.wF(t):(this.Ti=!0,i.add(t),root.requestAnimationFrame(()=>s()))}wF(t){this.Bm.add(t)}xF(){const t=this.vh.iterator;for(;t.next();)t.value.If=!1}Lu(){if(this.Om)return;const t=this.b;this.TM=t.skipsUndoManager,this.DM=t.pe,t.skipsUndoManager=!0,t.pe=!0,this.Om=!0}Tu(){const t=this.b;t.skipsUndoManager=this.TM,t.pe=this.DM,this.Om=!1}stopAnimation(t){const i=this.yn;if(this.Si===!0&&(this.Si=!1,this.Ff=!1,this.Zn.clear(),i.bF()&&this.b.requestUpdate()),!this.Ti){i.me.clear(),i.cx(this.b);return}if(i.Du(!0),i.cx(null),t===!0){const e=this.vh.toArray();for(let s=0;s{!i.isAnimating&&i.runCount===1/0&&i.start()})}get duration(){return this.Io}set duration(t){Util.t(t,"number",AnimationManager,"duration"),t<1&&Util.G(t,">= 1",AnimationManager,"duration"),this.Io=t}get isAnimating(){return this.Ti}get isTicking(){return this.Om}get isInitial(){return this.Cr}set isInitial(t){Util.t(t,"boolean",AnimationManager,"isInitial"),this.Cr=t}get defaultAnimation(){return this.yn}get activeAnimations(){return this.vh}get initialAnimationStyle(){return this.Rf}set initialAnimationStyle(t){Debug&&Util.tt(t,AnimationStyle,"AnimationStyle"),this.Rf=t}static gx=new GMap;static defineAnimationEffect(t,i){AnimationManager.gx.set(t,i)}static VM(t,i,e,s,n){t===null&&(t=[0,0,0,0]),i===null&&(i=[0,0,0,0]);let o=t[0],r=t[1];const l=t[2],h=t[3];let a=i[0],f=i[1];const c=i[2],u=i[3];l===0||l===100?(o=a,r=f):(c===0||c===100)&&(a=o,f=r),Math.abs(a-o)>180&&(a>o?o+=360:a+=360);const d=n(e,o,a-o,s)%360,m=n(e,r,f-r,s),g=n(e,l,c-l,s),p=n(e,h,u-h,s);return"hsla("+d+", "+m+"%, "+g+"%, "+p+")"}static{const t=AnimationManager.gx,i=(e,s,n,o,r,l)=>{e.position=new Point(o(r,s.x,n.x-s.x,l),o(r,s.y,n.y-s.y,l))};t.set("position:diagram",i),t.set("position",i),t.set("position:part",(e,s,n,o,r,l)=>{r{r{r{const h=e.actualBounds,a=n.actualBounds,f=a.x+a.width/2-h.width/2,c=a.y+a.height/2-h.height/2;r{e.desiredSize=new Size(o(r,s.width,n.width-s.width,l),o(r,s.height,n.height-s.height,l))}),t.set("width",(e,s,n,o,r,l)=>{e.width=o(r,s,n-s,l)}),t.set("height",(e,s,n,o,r,l)=>{e.height=o(r,s,n-s,l)}),t.set("fill",(e,s,n,o,r,l)=>{e.fill=AnimationManager.VM(s,n,r,l,o)}),t.set("stroke",(e,s,n,o,r,l)=>{e.stroke=AnimationManager.VM(s,n,r,l,o)}),t.set("strokeWidth",(e,s,n,o,r,l)=>{e.strokeWidth=o(r,s,n-s,l)}),t.set("strokeDashOffset",(e,s,n,o,r,l)=>{e.strokeDashOffset=o(r,s,n-s,l)}),t.set("background",(e,s,n,o,r,l)=>{e.background=AnimationManager.VM(s,n,r,l,o)}),t.set("opacity",(e,s,n,o,r,l)=>{e.opacity=o(r,s,n-s,l)}),t.set("scale",(e,s,n,o,r,l)=>{e.scale=o(r,s,n-s,l)}),t.set("angle",(e,s,n,o,r,l)=>{e.angle=o(r,s,n-s,l)})}static Default=1;static AnimateLocations=2;static None=3}class Animation{mx;zm;Ti;Fu;Io;bs;oA;Bf;me;px;li;$n;Ru;Vf;yx;wx;If;zM;xx;ws;b;XM;YM;KM;constructor(t){this.b=null,this.ws=null,this.zM=null,this.xx=null,this.XM=!1,this.Ti=!1,this.If=!1,this.li=0,this.$n=0,this.mx=Animation.EaseInOutQuad,this.zm=Animation.EaseInOutQuad,this.Ru=!1,this.Vf=!1,this.yx=1,this.wx=0,this.Io=NaN,this.bs=NaN,this.YM=0,this.Fu=null,this.oA=Point.Lo,this.me=new GMap,this.px=new GMap,this.Bf=new GSet,this.KM=1,t&&Object.assign(this,t)}suspend(){this.If=!0}advanceTo(t,i){i&&(this.If=!1),this.Ru&&t>=this.bs&&(this.Vf=!0,t=t-this.bs),this.YM=t,this.iA(!0),this.ws.Lu(),this.b.Sr(),this.ws.Tu(),this.b.redraw()}cx(t){if(this.px.clear(),this.Vf=!1,this.wx=0,this.bs=NaN,this.Bf.count>0&&this.Bf.clear(),t!==null){const i=t.links;for(;i.next();)i.value.Lr=null}}bF(){return this.me.count>0}start(){if(this.me.count===0)return this;if(this.Ti)return this;let t=this.b;const i=this.me.iterator;for(;i.next();){const s=i.key;t===null&&(s instanceof Diagram?t=s:s instanceof GraphObject&&(t=s.diagram))}if(t!==null)this.b=t,this.ws=t.animationManager;else return this;const e=this.ws;return e.isEnabled===!1?this:(this.bs=isNaN(this.Io)?e.duration:this.Io,this.zm=this.mx,e.Ff&&e.Rf===1&&this===e.defaultAnimation&&(this.zm=Animation.EaseOutExpo,this.bs=isNaN(this.Io)?e.duration===600?900:e.duration:this.Io),this.KM=t.scrollMode,this.isViewportUnconstrained&&(t.Jh=2),e.Lu(),this.Bf.each(s=>{s.data=null,t.add(s)}),e.Tu(),this.Ti=!0,this.li=+new Date,this.$n=this.li+this.bs,e.pF(this),this)}addTemporaryPart(t,i){return t.Ae()?(Debug&&(i===void 0&&Util.n("addTemporaryPart: Required Diagram argument missing"),t.diagram===i&&Util.n("addTemporaryPart: Part already in Diagram, did you mean to pass in a copy?"),this.b!==null&&this.b!==i&&Util.n("addTemporaryPart: A different Diagram is already associated with this Animation: "+this.b.toString())),this.Bf.add(t),this.b=i,this):this}add(t,i,e,s,n){if(this.b===null&&(t instanceof Diagram?this.b=t:t instanceof GraphObject&&t.diagram!==null&&(this.b=t.diagram)),t instanceof Part){if(!t.isAnimated)return this;i==="position"&&(i="position:part")}return this.EM(t,i,e,s,n),this}EM(t,i,e,s,n){const o=this.me;let r,l,h;if(t instanceof Diagram&&i==="position"&&(i="position:diagram"),(i==="fill"||i==="stroke"||i==="background")&&(Brush.Eo(e),Brush.UM(),e=[Brush.Yi.n0,Brush.Yi.n1,Brush.Yi.n2,Brush.Yi.n3],Brush.Eo(s),Brush.UM(),s=[Brush.Yi.n0,Brush.Yi.n1,Brush.Yi.n2,Brush.Yi.n3]),o.has(t))r=o.get(t),l=r.li,h=r.xs,l[i]===void 0&&(l[i]=this.Iu(e)),h[i]=this.Iu(s);else{if(i==="position"&&e.equalsApprox(s))return;l={},h={},l[i]=this.Iu(e),h[i]=this.Iu(s),r=new AnimationState(l,h,n),o.set(t,r)}const a=l[i];a instanceof Point&&!a.isReal()&&a.c(this.oA),n&&i.indexOf("position:")===0&&t instanceof Part?r.bx.location=this.Iu(t.location):n&&(r.bx[i]=this.Iu(e))}Iu(t){return t instanceof Point||t instanceof Size?t.copy():t}kF(t){const i=this.me;if(i.has(t)){const e=i.get(t);e.kx=!0}}ux(t){if(!this.Ti)return!1;const i=this.me.get(t);return i!==null&&i.kx}OM(t){if(!this.Ti)return!1;const i=this.me.get(t);return i!==null&&!!(i.li.position||i.li["position:part"]||i.li.location)}yF(){if(this.Bf.count>0)return!0;const t=this.me.iterator;for(;t.next();){const i=t.key;if(i instanceof GraphObject&&i.diagram!==null||i instanceof Diagram)return!0}return!1}iA(t){if(this.If&&!t)return;const i=this.ws;if(this.Ti===!1)return;const e=+new Date;let s=e>this.$n?this.bs:e-this.li;t&&(s=this.YM,sthis.$n&&(this.Ru&&!this.Vf?(this.li=+new Date,this.$n=this.li+this.bs,this.Vf=!0):this.Du(!1))}_C(t){const i=this.bs,e=this.me.iterator,s=this.Vf;for(;e.next();){const n=e.key;if(n instanceof GraphObject&&n.diagram===null)continue;const o=e.value,r=s?o.xs:o.li,l=s?o.li:o.xs,h=AnimationManager.gx;for(const a in l)a==="position"&&(l["position:placeholder"]||l["position:nodeCollapse"])||h.get(a)!==null&&h.get(a)(n,r[a],l[a],this.zm,t,i,this)}}stop(){return this.Ti?(this.Du(!0),this):this}Du(t){if(this.xx!==null&&this.xx.SF(this.zM),!this.Ti)return;const i=this.b,e=this.ws;e.Ff=!1,this.Ti=!1,this.If=!1,e.Lu();const s=this.me,n=this.Bf.iterator;for(;n.next();)i.remove(n.value);const o=this.Ru,r=s.iterator,l=AnimationManager.gx;for(;r.next();){const a=r.key,f=r.value,c=o?f.xs:f.li,u=o?f.li:f.xs,d=f.bx;for(const m in u)if(l.get(m)!==null){let g=m;f.Sx&&(g==="position:nodeCollapse"||g==="position:placeholder")&&(g="position"),l.get(g)(a,c[m],d[m]!==void 0?d[m]:f.Sx?c[m]:u[m],this.zm,this.bs,this.bs,this)}f.Sx&&d.location!==void 0&&a instanceof Part&&(a.location=d.location),f.kx&&a instanceof Part&&a.Ki(!1)}this.wx++;const h=!t&&this.yx>this.wx;if(!h&&(this===e.Em||this===e.defaultAnimation)&&this.me.clear(),i.Mx.clear(),i.NS(!1),i.invalidateDocumentBounds(),i.T(),i.Sr(!0),e.defaultAnimation===this){const a=e.Vm.iterator;for(;a.next();)a.value.MF();e.Vm.clear()}if(i.Sr(!0),this.isViewportUnconstrained&&(i.scrollMode=this.KM),e.Tu(),h){this.Vf=!1,this.start();return}this.cx(null),i.rA(),e.Du(this),this.Fu&&this.Fu(this),i.requestUpdate()}Of(t,i){const e=i.actualBounds;let s=null;if(i instanceof Group&&(s=i.placeholder),s!==null&&s.visible){const n=s.getDocumentPoint(Spot.TopLeft),o=s.padding;n.x+=o.left,n.y+=o.top,this.add(t,"position",n,t.position,!1)}else this.add(t,"position",new Point(e.x+e.width/2,e.y+e.height/2),t.position,!1);this.add(t,"scale",.01,t.scale,!1),t instanceof Group&&this.PF(t,i)}PF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Of(s,i)}}Ef(t,i){if(!t.isVisible())return;let e=null;if(i instanceof Group&&(e=i.placeholder),e!==null&&e.visible){const s=e.getDocumentPoint(Spot.TopLeft),n=e.padding;s.x+=n.left,s.y+=n.top,this.add(t,"position:placeholder",t.position,s,!0)}else this.add(t,"position:nodeCollapse",t.position,i,!0);this.add(t,"scale",t.scale,.01,!0),this.kF(t),t instanceof Group&&this.NF(t,i)}NF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Ef(s,i)}}get duration(){return this.Io}set duration(t){Util.t(t,"number",Animation,"duration"),t<1&&Util.G(t,">= 1",Animation,"duration"),this.Io=t}get reversible(){return this.Ru}set reversible(t){this.Ru=t}get runCount(){return this.yx}set runCount(t){t>0?this.yx=t:Util.n("Animation.runCount value must be a positive integer.")}get finished(){return this.Fu}set finished(t){this.Fu!==t&&(t!==null&&Util.t(t,"function",Animation,"finished"),this.Fu=t)}get easing(){return this.mx}set easing(t){this.mx=t}get isViewportUnconstrained(){return this.XM}set isViewportUnconstrained(t){this.XM=t}get isAnimating(){return this.Ti}getTemporaryState(t){let i=this.px.get(t);return i===null&&(i={},this.px.set(t,i)),i}static EaseLinear=(t,i,e,s)=>e*t/s+i;static EaseInOutQuad=(t,i,e,s)=>(t/=s/2,t<1?e/2*t*t+i:-e/2*(--t*(t-2)-1)+i);static EaseInQuad=(t,i,e,s)=>e*(t/=s)*t+i;static EaseOutQuad=(t,i,e,s)=>-e*(t/=s)*(t-2)+i;static EaseInExpo=(t,i,e,s)=>t===0?i:e*Math.pow(2,10*(t/s-1))+i;static EaseOutExpo=(t,i,e,s)=>t===s?i+e:e*(-Math.pow(2,-10*t/s)+1)+i}class AnimationState{li;xs;bx;Sx;kx;constructor(t,i,e){this.li=t,this.xs=i,this.bx={},this.Sx=e,this.kx=!1}}var TriggerStart=(w=>(w[w.Default=1]="Default",w[w.Immediate=2]="Immediate",w[w.Bundled=3]="Bundled",w))(TriggerStart||{});class AnimationTrigger{Ce;gn;Ou;zf;constructor(t,i,e){e&&Debug&&Util.tt(e,TriggerStart,"TriggerStart"),this.Ce=null,this.gn=t,this.Ou=e||1,this.zf=null,i!==void 0&&(this.zf=i,e===void 0&&(this.Ou=2))}copy(){const t=new AnimationTrigger(this.gn);t.Ou=this.Ou;const i=this.zf;if(i!==null){const e={};i.duration!==void 0&&(e.duration=i.duration),i.finished!==void 0&&(e.finished=i.finished),i.easing!==void 0&&(e.easing=i.easing),t.zf=e}return t}get propertyName(){return this.gn}set propertyName(t){this.gn=t}get animationSettings(){return this.zf}set animationSettings(t){this.zf=t}CF(t){const i=this.zf;i!==null&&(i.duration&&(t.duration=i.duration),i.finished&&(t.finished=i.finished),i.easing&&(t.easing=i.easing))}get startCondition(){return this.Ou}set startCondition(t){Debug&&Util.tt(t,TriggerStart,"TriggerStart"),this.Ou=t}static Default=1;static Immediate=2;static Bundled=3}class Layer{b;Tt;_t;Tr;Bl;Vl;zl;Xl;Yl;Kl;Ul;Gl;Hl;ql;jl;Wl;Tf;vl;Px;Xm;Eu;It;constructor(t){GSet.vi(this),this.b=null,this.It=new List,this.Tt="",this._t=1,this.Tr=!1,this.Bl=!0,this.Vl=!0,this.zl=!0,this.Xl=!0,this.Yl=!0,this.Kl=!0,this.Ul=!0,this.Gl=!0,this.Hl=!0,this.ql=!0,this.jl=!0,this.Wl=!0,this.Tf=!0,this.vl=!0,this.Px=!0,this.Xm=!1,this.Eu=[],t&&Object.assign(this,t)}AF(){const t=this.It;for(let i=0;i0&&(h+=e+" Parts "),s>0&&(h+=s+" Nodes "),n>0&&(h+=n+" Groups "),o>0&&(h+=o+" Links "),r>0&&(h+=r+" Adornments "),t>1){const a=this.It.iterator;for(;a.next();){const f=a.value;h+=` + `+f.toString();const c=f.data;c!==null&&GSet.gs(c)&&(h+=" #"+GSet.gs(c)),f instanceof Node?h+=" "+Util.toString(c):f instanceof Link&&(h+=" "+Util.toString(f.fromNode)+" "+Util.toString(f.toNode))}}return i+" "+this.It.count+": "+h}findObjectAt(t,i,e){if(i===void 0&&(i=null),e===void 0&&(e=null),this.vl===!1)return null;Debug&&!t.isReal()&&Util.n("findObjectAt: Point must have a real value, not: "+t.toString());let s=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(s=!0);const n=Point.a(),o=this.It.h,r=o.length;for(let l=r;l--;){const h=o[l];if(s===!0&&h.Tl()===!1||!h.isVisible())continue;n.c(t),n.Ye(h.Ks);let a=h.lA(n,i,e);if(a!==null&&(i!==null&&(a=i(a)),a!==null&&(e===null||e(a))))return Point.o(n),a}return Point.o(n),null}findObjectsAt(t,i,e,s){if(i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.vl===!1)return s;Debug&&!t.isReal()&&Util.n("findObjectsAt: Point must have a real value, not: "+t.toString());let n=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(n=!0);const o=Point.a(),r=this.It.h,l=r.length;for(let h=l;h--;){const a=r[h];if(n===!0&&a.Tl()===!1||!a.isVisible())continue;o.c(t),o.Ye(a.Ks);let f=a;a.hA(o,i,e,s)&&(i!==null&&(f=i(f)),f!==null&&(e===null||e(f))&&s.add(f))}return Point.o(o),s}findObjectsIn(t,i,e,s,n){if(i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.vl===!1)return n;Debug&&!t.isReal()&&Util.n("findObjectsIn: Rect must have a real value, not: "+t.toString());let o=!1;this.diagram!==null&&this.diagram.viewportBounds.containsRect(t)&&(o=!0);const r=this.It.h,l=r.length;for(let h=l;h--;){const a=r[h];if(o===!0&&a.Tl()===!1||!a.isVisible())continue;let f=a;a.Ym(t,i,e,s,n)&&(i!==null&&(f=i(f)),f!==null&&(e===null||e(f))&&n.add(f))}return n}IS(t,i,e,s,n,o,r){if(this.vl===!1)return n;const l=this.It.h,h=l.length;for(let a=h;a--;){const f=l[a];if(r===!0&&f.Tl()===!1||!o(f)||!f.isVisible())continue;let c=f;f.Ym(t,i,e,s,n)&&(i!==null&&(c=i(c)),c!==null&&(e===null||e(c))&&n.add(c))}return n}findObjectsNear(t,i,e,s,n,o){if(e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.vl===!1)return o;Debug&&!t.isReal()&&Util.n("findObjectsNear: Point must have a real value, not: "+t.toString());let r=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(r=!0);const l=Point.a(),h=Point.a(),a=this.It.h,f=a.length;for(let c=f;c--;){const u=a[c];if(r===!0&&u.Tl()===!1||!u.isVisible())continue;l.c(t),l.Ye(u.Ks),h.e(t.x+i,t.y),h.Ye(u.Ks);let d=u;u.aA(l,h,e,s,n,o)&&(e!==null&&(d=e(d)),d!==null&&(s===null||s(d))&&o.add(d))}return Point.o(l),Point.o(h),o}HM(){return this.It.h}Us(t,i){if(!this.visible)return;const e=this.It.h,s=e.length;if(s===0)return;const n=Util.at(),o=Util.at();for(let r=0;r0&&o.push(l))}for(let r=0;re.Um||a.height*n>e.Um?i.Ji(t,e):this.FF(t,i),f&&(t.restore(),t.clearContextCache(!0))}FF(t,i){const e=i.actualBounds,s=i.naturalBounds;if(e.width===0||e.height===0||isNaN(e.x)||isNaN(e.y)||!i.isVisible())return;const n=i.O;if(i.background===null){i.wn(t,"rgba(0,0,0,0.3)",!0,!1,s,e),t.fillRect(e.x,e.y,e.width,e.height);return}if(t.transform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),i.wn(t,i.background,!0,!1,s,e),t.fillRect(0,0,s.width/2,s.height/2),!n.Gk()){const o=1/(n.m11*n.m22-n.m12*n.m21);t.transform(n.m22*o,-n.m12*o,-n.m21*o,n.m11*o,o*(n.m21*n.dy-n.m22*n.dx),o*(n.m12*n.dx-n.m11*n.dy))}}DF(t,i,e,s){const n=2/s,o=4/s;for(let r=0;r=s.count)t=s.count;else if(s.elt(t)===i)return-1;s.insertAt(t,i),i.Gm(e);const n=this.diagram;return n!==null&&(e?n.T():n.$h(i)),this.Nx(t,i),t}oe(t,i,e){if(!e&&i.layer!==this&&i.layer!==null)return i.layer.oe(t,i,e);const s=this.It;if(t<0||t>=s.length){if(t=s.indexOf(i),t<0)return-1}else if(s.elt(t)!==i&&(t=s.indexOf(i),t<0))return-1;i.Hm(e),s.removeAt(t);const n=this.diagram;return n!==null&&(e?n.T():n.oe(i)),i.GM(null),t}Nx(t,i){t=this.RF(t,i),i instanceof Group&&this.IF(t,i),i.svg!==null&&i.svg.remove()}RF(t,i){const e=i.zOrder;if(isNaN(e))return t;const s=this.It,n=s.count;if(n<=1)return t;if(t<0&&(t=s.indexOf(i)),t<0)return-1;let o=t-1,r=NaN;for(;o>=0&&(r=s.elt(o).zOrder,!!isNaN(r));)o--;let l=t+1,h=NaN;for(;le)for(;;){if(o===-1||r<=e)return o++,o===t?t:(s.removeAt(t),s.insertAt(o,i),o);for(r=NaN;--o>=0&&(r=s.elt(o).zOrder,!!isNaN(r)););}else if(!isNaN(h)&&h=e)return l--,l===t?t:(s.removeAt(t),s.insertAt(l,i),l);for(h=NaN;++l=0)||e<0&&r.containingGroup===i&&(e=o,t>=0))break}if(!(e<0)&&e1)&&Util.G(t,"0 <= value <= 1",Layer,"opacity"),this._t=t;const e=this.diagram;e!==null&&e.T(),this.i("opacity",i,t)}}get isViewportAligned(){return this.Xm}set isViewportAligned(t){const i=this.Xm;i!==t&&(this.Xm=t,this.diagram&&(this.cA(),this.diagram.T()),this.i("isViewportAligned",i,t),t&&(this.isInDocumentBounds=!1))}cA(){if(!this.Xm)return;const t=this.diagram,i=this.It.h,e=i.length,s=t.Ct,n=t.At;for(let o=0;o(w[w.None=1]="None",w[w.Uniform=2]="Uniform",w[w.UniformToFill=3]="UniformToFill",w))(AutoScale||{}),CycleMode=(w=>(w[w.All=1]="All",w[w.NotDirected=2]="NotDirected",w[w.NotDirectedFast=3]="NotDirectedFast",w[w.NotUndirected=4]="NotUndirected",w[w.DestinationTree=5]="DestinationTree",w[w.SourceTree=6]="SourceTree",w))(CycleMode||{}),ScrollMode=(w=>(w[w.Document=1]="Document",w[w.Infinite=2]="Infinite",w))(ScrollMode||{}),CollapsePolicy=(w=>(w[w.TreeParent=1]="TreeParent",w[w.AllParents=2]="AllParents",w[w.AnyParents=3]="AnyParents",w))(CollapsePolicy||{});class Diagram{ws;yi;WM;Cx;Dr;zu;Ax;Lx;Tx;Dx;Fx;Rx;Xf;Jh;Ix;Ox;Ex;Jl;Yf;Fr;qm;Bx;Vx;Xu;Qn;Rr;Qh;Bo;jm;Kf;Wm;Uf;Yu;Ir;_n;vM;JM;zx;Xx;ZM;Yx;$M;QM;_M;Kx;vm;Or;Er;Br;Vr;zr;Xr;Ux;Yr;Gx;Kr;Ur;Gr;Hr;Hx;tP;Vo;iP;qx;jx;eP;Ai;sP;nP;oP;zs;zo;Xi;Wx;Bl;Vl;vx;Jx;zl;Xl;Yl;Zx;Kl;Ul;Gl;Hl;ql;jl;Wl;$x;Qx;rP;Ku;Uu;_x;t1;i1;e1;Jm;s1;o1;l1;ii;lP;h1;hP;Gu;xn;to;re;io;uA;Zl;aP;fP;Zm;a1;Hu;$m;f1;qr;$l;_h;cP;uP;Qm;c1;u1;os;_m;t0;qu;Ql;Gf;i0;jr;ta;dP;e0;$t;O;Ge;Ar;Ui;ks;gP;_l;Wr;Pl;vr;ia;Hf;mP;ju;ea;Wu;Jt;th;gt;rt;vu;Ct;At;xt;qf;qw;d1;sa;jf;g1;m1;p1;BF;VF;Gi;Cl;Um;s0;pP;yP;dA;o0;zF;XF;YF;w1;KF;UF;GF;na;gA;ih;oa;ra;la;ha;Pu;Wh;ei;Ot;Wf;eS;sS;xf;_t;static b1=null;static mA=new GMap;static wP;static xP=null;Mu;k1;S1;M1;P1;N1;r0;bP;l0;h0;a0;fx;kP;C1;vf;constructor(t,i){if(Diagram.ww||(Diagram.Hk(),Diagram.ww=!0),GSet.vi(this),Diagram.pA(this),this.$t=!0,this.Ot=null,this.Ct=0,this.At=0,this.xt=null,Diagram.isUsingDOM()){const s=this,n=()=>{s.Li(root.document,"DOMContentLoaded",n,!1),s.setRTL()};root.document.body!==null?this.setRTL():s.Ht(root.document,"DOMContentLoaded",n,!1)}this.qf=null,Diagram.SP("Model",PartManager);const e=this;return this.sP=s=>e.partManager.doModelDataChanged(s),this.nP=s=>e.partManager.doModelChanged(s),this.g1=null,this.m1=null,this.yA(),this.model=Model.initDiagramModel(),this.C1=null,this.themeManager=new ThemeManager,this.Vo=!0,this.wA(),this.layout=new Layout,this.Vo=!1,this.zF=null,this.XF=null,this.YF=null,this.w1=null,this.KF=null,this.UF=null,this.GF=null,this.na=null,this.gA=null,this.ih=null,this.oa=null,this.ra=null,this.la=null,this.ha=null,this.Pu=()=>{},this.Wh=null,this.qu=!1,this.Wf=new DiagramHelper(this),t!==void 0&&(typeof t=="string"||root.Element&&t instanceof Element?this.MP(t):i=t),i&&this.setProperties(i),this.$t=!1,this.requestUpdate(),this}tF(){return this.xt!==null}get renderer(){return this.Gf}set renderer(t){if(this instanceof Overview)return;t===""&&(t="default");const i=t.toLowerCase(),e=this.Gf;if(i===e)return;this.Gf=i;let s=null;i==="default"||i==="canvas"?(s=this.Ql.get("svg"),s!==null&&s.Vt.remove(),this.xt&&(this.ei=this.xt.di),this.ei.clearContextCache(!0)):i==="svg"?(this.Ql.has("svg")?s=this.Ql.get("svg"):(s=new SVGSurface(this,root.document),this.addRenderer("svg",s)),this.div!==null&&this.div.appendChild(s.Vt),this.ei=s.di,this.xt&&(this.xt.di.setTransform(this.Gi,0,0,this.Gi,0,0),this.xt.di.clearRect(0,0,this.Ct,this.At))):i==="debug"&&(this.Ql.has("SVG")||(s=new SVGSurface(this,root.document),this.addRenderer("SVG",s),s.Vt.style.backgroundColor="whitesmoke",this.div!==null&&this.div.after(s.Vt))),this.$t||this.redraw()}yA(){this.vf=new List,this.setupRouters(),this.ws=new AnimationManager,this.ws.Oo(this),this.yi=17,this.WM=!1,this.vu=!1,this.Cx="default",this.Jt=new List,this.Ql=new GMap,this.Gf="default",this.resetRenderingHints(),this.HF(),this._t=1,this.gt=new Point(NaN,NaN).w(),this.fx=new Point(NaN,NaN),this.rt=1,this.e0=1,this.Ax=new Point(NaN,NaN).w(),this.Lx=NaN,this.Tx=1e-4,this.Dx=100,this.O=new Transform,this.Fx=new Point(NaN,NaN).w(),this.Rx=new Rect(NaN,NaN,NaN,NaN).w(),this.Xf=new Margin(0,0,0,0).w(),this.Jh=1,this.Ix=!1,this.Ox=null,this.Ex=null,this.Jl=1,this.Yf=Spot.Default,this.Fr=1,this.qm=Spot.Default,this.Bx=Spot.None,this.Vx=Spot.None,this.Ge=!0,this.Xu=!1,this.Qn=new Set,this.Rr=new GSet,this.Qh=new GSet,this.Bo=!1,this.th=new GMap,this.ju=!0,this.jm=250,this.Kf=-1,this.Wm=new Margin(16,16,16,16).w(),this.Ar=!1,this.Uf=!1,this.Yu=!0,this.i0=new InputEvent,this.i0.diagram=this,this.jr=new InputEvent,this.jr.diagram=this,this.ta=new InputEvent,this.ta.diagram=this,this.Ir=null,this._n=null,this.qw=!1,this.qF(),this.vr=new GSet,this.zx=!0,this.Xx=1,this.ZM=!1,this.Yx=1,this.Kx="auto",this.vm="auto",this.Or=null,this.Er=null,this.Br=null,this.Vr=null,this.zr=null,this.Xr=null,this.Ux=null,this.Yr=null,this.Gx=!1,this.Kr=null,this.Ur=null,this.Gr=null,this.Hr=null,this.Hx=!1,this.d1={},this.sa=[null,null],this.Vo=!1,this.iP=!1,this.qx=!1,this.jx=!1,this.eP=!0,this.ks=!1,this.ea=!1,this.oP=!0,this.zs=-2,this._l=new GMap,this.Wu=new List,this.zo=!1,this.Xi=!0,this.Wx=!0,this.Bl=!0,this.Vl=!0,this.vx=!1,this.Jx=!0,this.zl=!0,this.Xl=!0,this.Yl=!0,this.Zx=!0,this.Kl=!0,this.Ul=!0,this.Gl=!0,this.Hl=!0,this.ql=!0,this.jl=!0,this.Wl=!0,this.$x=!0,this.Qx=!0,this.rP=!1,this.jf=!1,this.Ku=!0,this.Uu=!0,this._x=!0,this.t1=!0,this.i1=16,this.e1=16,this.Jm=!1,this.s1=!1,this.o1=0,this.l1=0,this.ii=new Margin(5).w(),this.lP=new GSet().w(),this.h1=999999999,this.hP=new GSet().w(),this.ia=!0,this.Gu=!0,this.Hf=!0,this.xn=!1,this.to=!1,this.Wr=!0,this.Pl=!1,this.io=!1,this.uA=new GSet,this.mP=new GSet,this.Zl=null,this.aP=new Size(8,8),this.fP=999,this.Zm=!1,this.eS=1,this.sS=0,this.Ui={scale:1,position:new Point,bounds:new Rect,canvasSize:new Size,newCanvasSize:new Size,isScroll:!1},this.Ui.canvasSize=this.Ui.canvasSize,this.Ui.newCanvasSize=this.Ui.newCanvasSize,this.Ui.isScroll=!1,this.a1=new Rect(NaN,NaN,NaN,NaN).w(),this.Hu=new Size(NaN,NaN).w(),this.$m=new Rect(NaN,NaN,NaN,NaN).w(),this.f1=!1,this.jF(),this.os=null,this._m=!1,this.xf=null,this.partManager=new PartManager,this.toolManager=new ToolManager,this.toolManager.initializeStandardTools(),this.defaultTool=this.toolManager,this.currentTool=this.defaultTool,this.S1=null,this.M1=new DraggingOptions,this.P1=null,this.N1=null,this.k1=!1,this.Mu=!1,this.commandHandler=new CommandHandler,this.h0=null,this.a0=Point.Bk,this.kP=!1,this.Gi=1,this.Cl=null,this.Um=1,this.r0=0,this.bP=[0,0,0,0,0],this.l0=0,this.s0=1,this.pP=0,this.yP=new Point,this.dA=500,this.t0=new Point,this.o0=!1}static xA=root.document!==void 0;static isUsingDOM(){return Diagram.xA}static useDOM(t){Diagram.xA=t?root.document!==void 0:!1}static He=new WeakMap;clear(){this.animationManager.stopAnimation(),this.model.clear(),Diagram.bA(),this.kA(!1),this.Wu.clear(),this.SA(),this.Zl=null,this.invalidateDocumentBounds(),this.ensureBounds(),this.T()}kA(t){this.animationManager.stopAnimation(!0),this.lP=new GSet().w(),this.hP=new GSet().w();const i=this.skipsUndoManager,e=this.Ai!==null&&this.Ai!==void 0;e&&(this.skipsUndoManager=!0);let s=null;this.os!==null&&(s=this.os.part,s!==null&&this.remove(s));const n=[],o=this.Jt.length;if(t){for(let r=0;rt?new Margin(t/2):1.5)),this.c1=this.Qm,this.u1=new Adornment(Panel.Link).add(new Shape({isPanelMain:!0,fill:null,stroke:"dodgerblue",strokeWidth:3}).theme("stroke","selection").theme("strokeWidth","selection"))}setRTL(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);const e=Util.ln("div");e.dir="rtl",e.style.cssText="font-size: 14px; width: 1px; height: 1px; position: absolute; top: -1000px; overflow: scroll;",e.textContent="A",i.appendChild(e);let s="reverse";e.scrollLeft>0?s="default":(e.scrollLeft=1,e.scrollLeft===0&&(s="negative")),i.removeChild(e),this.Cx=s}setScrollWidth(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);let e=0;if(Diagram.isUsingDOM()){let s=Diagram.xP,n=Diagram.wP;s===null&&(Diagram.xP=Util.ln("p"),s=Diagram.xP,s.style.width="100%",s.style.height="200px",s.style.boxSizing="content-box",Diagram.wP=Util.ln("div"),n=Diagram.wP,n.style.position="absolute",n.style.visibility="hidden",n.style.width="200px",n.style.height="150px",n.style.boxSizing="content-box",n.appendChild(s)),n.style.overflow="hidden",i.appendChild(n);const o=s.offsetWidth;n.style.overflow="scroll";let r=s.offsetWidth;o===r&&(r=n.clientWidth),i.removeChild(n),e=o-r,e===0&&!Util.cr&&(e=11)}this.yi=e,this.WM=!0}fi(t){t in AutoScale?this.autoScale=t:Util.ur(this,t)}toString(t){t===void 0&&(t=0);let i="";this.div&&this.div.id&&(i=this.div.id);let e='Diagram "'+i+'"';if(t<=0)return e;const s=this.Jt.iterator;for(;s.next();){const n=s.value;e+=` + `+n.toString(t-1)}return e}static pA(t){Diagram.b1=t}static Sm(){return Diagram.b1}static fromDiv(t){let i=t;if(typeof t=="string"&&(i=root.document.getElementById(t)),i instanceof HTMLDivElement){const e=Diagram.He.get(i);if(e)return e}return null}get div(){return this.Ot}set div(t){if(t!==null&&Util.s(t,HTMLDivElement,Diagram,"div"),this.Ot!==t){const i=this.Ot;if(i!==null){if(Diagram.He.delete(i),i.goDiagram=void 0,i.go=void 0,i.innerHTML="",this.xt!==null){const s=this.xt.Vt;this.Li(s,"pointermove",this.oa,!1),this.Li(s,"pointerdown",this.ih,!1),this.Li(s,"pointerup",this.ra,!1),this.Li(s,"pointerout",this.la,!1),this.Li(s,"pointercancel",this.ha,!1),this.xt.dispose()}this.qf&&(this.qf.disconnect(),this.qf=null);const e=this.toolManager;e!==null&&(e.mouseDownTools.each(s=>s.cancelWaitAfter()),e.mouseMoveTools.each(s=>s.cancelWaitAfter()),e.mouseUpTools.each(s=>s.cancelWaitAfter())),e.cancelWaitAfter(),this.currentTool.doCancel(),this.xt=null,this.Li(root,"resize",this.w1,!1),this.Li(root,"wheel",this.na,!0),Diagram.Sm()===this&&Diagram.pA(null)}else this.ih===null&&(this.io=!1);if(this.Ot=null,t!==null){const e=Diagram.He.get(t);e&&(e.div=null),this.MP(t),this.Pu(),this.themeManager&&this.themeManager.WF()}else this.themeManager&&this.themeManager.vF()}}setupRouters(){this.vf.push(new AvoidsNodesRouter)}MP(t){const i=this;if(!Diagram.isUsingDOM())return;t==null&&Util.n("Diagram setup requires an argument DIV."),i.Ot!==null&&Util.n("Diagram has already completed setup."),typeof t=="string"?i.Ot=root.document.getElementById(t):t instanceof HTMLDivElement?i.Ot=t:Util.n("No DIV or DIV id supplied: "+t),i.Ot===null&&Util.n("Invalid DIV id; could not get element with id: "+t);const e=Diagram.He.get(i.Ot);if(e&&e!==this&&Util.n("Invalid div id; div already has a Diagram associated with it."),!i.qf&&root.ResizeObserver){const f=root.ResizeObserver,c=Util.Ik(()=>i.requestUpdate(),250,!1);i.qf=new f(()=>c()),i.qf.observe(i.Ot)}root.getComputedStyle(i.Ot,null).position==="static"&&(i.Ot.style.position="relative");let s=5;const n="rgba(2"+s+"5, 255, 255, 0)";s--,i.Ot.style["-webkit-tap-highlight-color"]=n,i.Ot.innerHTML="",Diagram.He.set(i.Ot,i),i.Ot.goDiagram=i,i.Ot.go=root.go;const o=new CanvasSurface(i);o.style!==void 0&&(o.style.position="absolute",o.style.top="0px",o.style.left="0px",root.getComputedStyle(i.Ot,null).getPropertyValue("direction")==="rtl"&&(i.vu=!0),o.style.zIndex="2",o.style.userSelect="none",o.style.MozUserSelect="none",o.style.touchAction="none",o.style.letterSpacing="normal !important",o.style.wordSpacing="normal !important",o.style.lang="unknown"),i.xt=o,i.ei=o.di;const r=i.ei;i.Gi=i.computePixelRatio(),i.viewSize.isReal()||(i.Ct=i.Ot.clientWidth||1,i.At=i.Ot.clientHeight||1),i.MA(i.Ct,i.At);const l=i;i.Ot.insertBefore(o.Vt,i.Ot.firstChild);const h=new CanvasSurface(null);if(h.width=1,h.height=1,i.BF=h,i.VF=h.di,Diagram.isUsingDOM()){const f=Util.ln("div"),c=Util.ln("div");f.style.position="absolute",f.style.overflow="auto",f.style.width=i.Ct+"px",f.style.height=i.At+"px",f.style.zIndex="1",c.style.position="absolute",c.style.width="1px",c.style.height="1px",i.Ot.appendChild(f),f.appendChild(c),f.onscroll=Diagram.JF,f.addEventListener("pointerdown",Diagram.ZF),f.b=i,f.$F=!0,f.QF=!0,i.g1=f,i.m1=c}i.Pu=Util.Ik(()=>{i.Cl=null,i.T()},300,!1),i.w1=Util.Ik(()=>{i.RM()},250,!1),i.Wh=f=>(f.preventDefault(),!1),i.na=f=>{if(!l.isEnabled)return;const c=l.Jf(f,!0);c.bubbles=!0;let u=0,d=0;c.delta=0,f.deltaX!==void 0?(f.deltaX!==0&&(u=f.deltaX>0?1:-1),f.deltaY!==0&&(d=f.deltaY>0?1:-1),c.delta=Math.abs(f.deltaX)>Math.abs(f.deltaY)?-u:-d):f.wheelDeltaX!==void 0?(f.wheelDeltaX!==0&&(u=f.wheelDeltaX>0?-1:1),f.wheelDeltaY!==0&&(d=f.wheelDeltaY>0?-1:1),c.delta=Math.abs(f.wheelDeltaX)>Math.abs(f.wheelDeltaY)?-u:-d):f.wheelDelta!==void 0&&f.wheelDelta!==0&&(c.delta=f.wheelDelta>0?1:-1),l.doMouseWheel(),l.aa(c,f)},i.gA=f=>{if(!l.isEnabled)return;i.jf=!1,l.Jf(f,!0);const c=l.currentTool;c.cancelWaitAfter(),c.standardMouseOver()},i.ih=f=>{if(!l.isEnabled)return;i.jf=!0;const c=l.d1;c[f.pointerId]===void 0&&(c[f.pointerId]=f);const u=l.sa;let d=!1;if(u[0]!==null&&(u[0].pointerId===f.pointerId||u[0].pointerType!==f.pointerType))u[0]=f;else if(u[1]!==null&&u[1].pointerId===f.pointerId)u[1]=f,d=!0;else if(u[0]===null)u[0]=f;else if(u[1]===null)u[1]=f,d=!0;else{f.preventDefault();return}const m=f.pointerType==="touch"||f.pointerType==="pen";m&&(l.qw=!1,l.o0=!0);const g=l._F(f,f,d),p=l.yP,y=m?25:10;if(f.timeStamp-l.pPy||Math.abs(p.y-f.screenY)>y)?l.s0++:l.s0=1,g.clickCount=l.s0,l.pP=f.timeStamp,l.yP.setTo(f.screenX,f.screenY),l.doMouseDown(),f.button===1){f.preventDefault();return}l.aa(g,f)},i.oa=f=>{if(!l.isEnabled)return;i.jf=!0;const c=l.sa;if(c[0]!==null&&(c[0].pointerId===f.pointerId||c[0].pointerType!==f.pointerType))c[0]=f;else if(c[1]!==null&&c[1].pointerId===f.pointerId){c[1]=f;return}else if(c[0]===null)c[0]=f;else return;if(c[0].pointerId!==f.pointerId)return;const u=l.tR(f,f,c[1]!==null);l.doMouseMove(),l.aa(u,f)},i.ra=f=>{if(!l.isEnabled)return;i.jf=!0;const c=f.pointerType==="touch"||f.pointerType==="pen",u=l.d1;if(c&&l.qw){delete u[f.pointerId],f.preventDefault();return}const d=l.sa;if(d[0]!==null&&(d[0].pointerId===f.pointerId||d[0].pointerType!==f.pointerType))d[0]=null;else if(d[1]!==null&&d[1].pointerId===f.pointerId){d[1]=null;return}else return;const m=l.PP(f,!1,!0,!1,!0,!1);let g=root.document.elementFromPoint(f.clientX,f.clientY)||null;g!==null&&g.shadowRoot!==void 0&&g.shadowRoot!==null&&(g=g.shadowRoot.elementFromPoint(f.clientX,f.clientY)),g!==null&&g.b instanceof Diagram&&g.b!==l&&g.b.c0(f,m),g===null&&(g=f.target),l.c0(f,m),m.clickCount=l.s0,m.targetDiagram=l.NP(f,g),m.targetObject=null,l.doMouseUp(),l.aa(m,f),c&&(l.o0=!1)},i.la=f=>{if(!l.isEnabled)return;i.jf=!1;const c=l.d1;c[f.pointerId]&&delete c[f.pointerId];const u=l.sa;if(u[0]!==null&&u[0].pointerId===f.pointerId&&(u[0]=null),u[1]!==null&&u[1].pointerId===f.pointerId&&(u[1]=null),f.pointerType==="touch"||f.pointerType==="pen")return;const d=l.currentTool;d.cancelWaitAfter(),d.standardMouseOver()},i.ha=f=>{const c=l.sa;c[0]!==null&&c[0].pointerId===f.pointerId?(c[0]=null,l.o0=!1):c[1]!==null&&c[1].pointerId===f.pointerId&&(c[1]=null)};const a=r;if(i.p1=a.Y[Util.Fs("7eba17a4ca3b1a8346")][Util.Fs("78a118b7")](a.Y,Diagram.Ju,s,s),r.clearContextCache(!0),i.iR(),this.Gf==="svg"){const f=this.Ql.get("svg");this.Ot.appendChild(f.Vt),this.ei=f.di}}addEventListener(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}Ht(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}removeEventListener(t,i,e,s){t.removeEventListener(i,e,{capture:s})}Li(t,i,e,s){t.removeEventListener(i,e,{capture:s})}iR(){const t=this;let i=this.xt.Vt;i instanceof HTMLCanvasElement||(i=t.div),this.Ht(i,"pointerdown",t.ih,!1),this.Ht(i,"pointermove",t.oa,!1),this.Ht(i,"pointerup",t.ra,!1),this.Ht(i,"pointerout",t.la,!1),this.Ht(i,"pointercancel",t.ha,!1),this.Ht(i,"pointerenter",t.eR,!1),this.Ht(i,"pointerleave",t.sR,!1),this.Ht(i,"wheel",t.na,!1),this.Ht(i,"keydown",t.nR,!1),this.Ht(i,"keyup",t.oR,!1),this.Ht(i,"blur",t.rR,!1),this.Ht(i,"focus",t.lR,!1),this.Ht(i,"selectstart",e=>(e.preventDefault(),!1),!1),this.Ht(i,"contextmenu",e=>(e.preventDefault(),!1),!1),this.Ht(root,"resize",t.w1,!1)}jw(){this.r0>30&&(this.Cl=1)}NS(t){this.Cl!==null&&(this.Cl=null,t&&this.Pu(),Debug&&Debug.drawFrames||(this.r0=0,this.bP=[0,0,0,0,0],this.l0=0))}computePixelRatio(){return this.Cl!==null?this.Cl:root.devicePixelRatio||1}get avgSpf(){return this.r0}doMouseDown(){this.currentTool.doMouseDown()}doMouseMove(){this.currentTool.doMouseMove()}doMouseUp(){this.currentTool.doMouseUp()}doMouseWheel(){this.currentTool.doMouseWheel()}doKeyDown(){this.currentTool.doKeyDown()}doKeyUp(){this.currentTool.doKeyUp()}doFocus(){this.focus()}focus(){if(this.xt)if(this.scrollsPageOnFocus)this.xt.focus();else{const t=root.scrollX,i=root.scrollY;this.xt.focus(),root.scrollTo(t,i)}}lR(t){const i=Diagram.He.get(this);i&&i.B("GainedFocus")}rR(t){const i=Diagram.He.get(this);i&&i.B("LostFocus")}RM(){if(this.xt===null)return;const i=this.Ot;if(i===null||i.clientWidth===0||i.clientHeight===0)return;this.WM||this.setScrollWidth();const e=this.to?this.yi:0,s=this.xn?this.yi:0,n=this.Gi;if(this.Gi=this.computePixelRatio(),this.Gi!==n&&(this.Xu=!0,this.requestUpdate()),i.clientWidth!==this.Ct+e||i.clientHeight!==this.At+s){this.fa(),this.Ge=!0;const o=this.layout;o!==null&&o.isViewportSized&&this.autoScale===1&&(this.Uf=!0,o.invalidateLayout()),this.ks||this.requestUpdate()}}wA(){let t=0,i=new Layer;i.name="Grid",i.allowSelect=!1,i.pickable=!1,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="ViewportBackground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="Background",this.Jr(i,t++),i=new Layer,i.name="",this.Jr(i,t++),i=new Layer,i.name="Foreground",this.Jr(i,t++),i=new Layer,i.name="ViewportForeground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="Adornment",i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="Tool",i.isTemporary=!0,i.isInDocumentBounds=!0,this.Jr(i,t++)}PA(){const t=new Panel(Panel.Grid,{name:"GRID"}).add(new Shape("LineH",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineV",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineH",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineH",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor")),i=new Part({layerName:"Grid",zOrder:0,isInDocumentBounds:!1,isAnimated:!1,pickable:!1,locationObjectName:"GRID"}).add(t);return this.add(i),this.partManager.parts.delete(i),t.visible=!1,t}static JF(){const t=Diagram.He.get(this.parentElement||this);if(t){if(t.s1){t.s1=!1;return}if(!t.isEnabled){t.NA();return}t.diagramScroll(this)}}static ZF(t){if(!this.b.isEnabled){this.b.updateScroll();return}this.b.o1=t.target.scrollTop,this.b.l1=t.target.scrollLeft}diagramScroll(t){if(this.xt===null)return;const i=this.g1,e=this.m1;this.Jm=!0;let s=this.documentBounds,n=this.viewportBounds;const o=this.Xf;let r=s.x-o.left,l=s.y-o.top;const h=s.width+o.left+o.right,a=s.height+o.top+o.bottom;let f=s.right+o.right,c=s.bottom+o.bottom,u=n.x,d=n.y;const m=n.width,g=n.height;let p=n.right,y=n.bottom;const x=this.scale;let k,b=t.scrollLeft;if(this.vu)switch(this.Cx){case"negative":b=b+t.scrollWidth-t.clientWidth;break;case"reverse":b=t.scrollWidth-b-t.clientWidth;break}const S=b;if(mp)){const M=i.scrollWidth-this.Ct;this.position=k.e(-M+S-this.Ct/x+f,this.position.y)}if(t.QF&&this.allowVerticalScroll&&(ly)){const M=i.scrollHeight-this.At;this.position=k.e(this.position.x,-M+t.scrollTop-this.At/x+c)}Point.o(k),this.sh(),this.Jm=!1,this.Gu=!1,s=this.documentBounds,n=this.viewportBounds,f=s.right,p=n.right,c=s.bottom,y=n.bottom,r=s.x,u=n.x,l=s.y,d=n.y,m>=h&&r>=u&&f<=p&&(e.style.width="1px"),g>=a&&l>=d&&c<=y&&(e.style.height="1px")}computeBounds(t){return t===void 0&&(t=new Rect),this.Di(),this.CA(t)}CA(t){if(this.fixedBounds.isReal())return t.c(this.fixedBounds),t.addMargin(this.ii),t;let i=!0;const e=this.Jt.h,s=e.length;for(let n=0;ni&&(a=i),athis.maxScale&&(a=this.maxScale),a):t===3?(a=0,h>l?a=(r-this.yi)/n:a=(o-this.yi)/s,a>i&&(a=i),athis.maxScale&&(a=this.maxScale),a):this.scale}zoomToFit(){const t=this.Jh;this.Jh=1,this.scale=this.Zu(2),t!==1&&(this.Gs(!1),this.CP(this.documentBounds,this.Ct/this.rt,this.At/this.rt,this.Yf,!1)),this.Jh=t}zoomToRect(t,i){i===void 0&&(i=2);const e=t.width,s=t.height;if(e===0||s===0||isNaN(e)&&isNaN(s))return;let n=1;if(i===2||i===3)if(isNaN(e))n=this.viewportBounds.height*this.scale/s;else if(isNaN(s))n=this.viewportBounds.width*this.scale/e;else{const o=this.Ct,r=this.At;i===3?r/s>o/e?n=(r-(this.xn?this.yi:0))/s:n=(o-(this.to?this.yi:0))/e:n=Math.min(r/s,o/e)}this.scale=n,this.position=new Point(t.x,t.y)}get hR(){return this.$t}set hR(t){this.$t=t}alignDocument(t,i){this.ensureBounds();const e=this.documentBounds,s=this.viewportBounds;this.position=new Point(e.x+(t.x*e.width+t.offsetX)-(i.x*s.width-i.offsetX),e.y+(t.y*e.height+t.offsetY)-(i.y*s.height-i.offsetY))}focusObject(t){if(t instanceof GraphObject){this.h0=t;const i=Point.a();this.a0=this.transformDocToView(t.getDocumentPoint(Spot.TopLeft,i)),Point.o(i)}else this.h0=null,this.a0=Point.Bk}CP(t,i,e,s,n){const o=Point.H(this.gt.x,this.gt.y);let r=o.x,l=o.y;if(this.h0!==null){let h=Point.a();h=this.h0.getDocumentPoint(Spot.TopLeft,h),r=h.x-this.a0.x/this.scale,l=h.y-this.a0.y/this.scale,s=Spot.None,Point.o(h)}if(n||this.scrollMode===1){s.isSpot()&&(i>t.width&&(r=t.x+(s.x*t.width+s.offsetX)-(s.x*i-s.offsetX)),e>t.height&&(l=t.y+(s.y*t.height+s.offsetY)-(s.y*e-s.offsetY)));const h=this.Xf,a=i-t.width;if(it.left?r=t.left:rt.top?l=t.top:ls.part,s=>s.canSelect());if(e instanceof Part)return e}else{const e=this.DS(t,s=>s.part);if(e instanceof Part)return e}return null}findObjectAt(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Di();const s=this.Jt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}DS(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Di();const s=this.Jt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible||n.isTemporary)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}findPartsAt(t,i,e){return i===void 0&&(i=!0),this.fR(t,s=>s.part,i?s=>s instanceof Part&&s.canSelect():null,e)}fR(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Di();const n=this.Jt.iteratorBackwards;for(;n.next();){const o=n.value;!o.visible||o.isTemporary||o.findObjectsAt(t,i,e,s)}return s}findObjectsAt(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Di();const n=this.Jt.iteratorBackwards;for(;n.next();){const o=n.value;o.visible&&o.findObjectsAt(t,i,e,s)}return s}findPartsIn(t,i,e,s){return i===void 0&&(i=!1),e===void 0&&(e=!0),this.cR(t,null,n=>n instanceof Part&&(!e||n.canSelect()),i,s)}findObjectsIn(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Di();const o=this.Jt.iteratorBackwards;for(;o.next();){const r=o.value;r.visible&&r.findObjectsIn(t,i,e,s,n)}return n}IS(t,i,e,s,n,o){const r=new GSet;this.Di();const l=this.Jt.iteratorBackwards;for(;l.next();){const h=l.value;h.visible&&h.IS(t,i,e,s,r,n,o)}return r}cR(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Di();const o=this.Jt.iteratorBackwards;for(;o.next();){const r=o.value;!r.visible||r.isTemporary||r.findObjectsIn(t,i,e,s,n)}return n}findPartsNear(t,i,e,s,n){return e===void 0&&(e=!0),s===void 0&&(s=!0),this.uR(t,i,null,o=>o instanceof Part&&(!s||o.canSelect()),e,n)}findObjectsNear(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Di();const r=this.Jt.iteratorBackwards;for(;r.next();){const l=r.value;l.visible&&l.findObjectsNear(t,i,e,s,n,o)}return o}uR(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Di();const r=this.Jt.iteratorBackwards;for(;r.next();){const l=r.value;!l.visible||l.isTemporary||l.findObjectsNear(t,i,e,s,n,o)}return o}acceptEvent(t){return this.Jf(t,t instanceof MouseEvent)}Jf(t,i){const e=this.jr;this.jr=this.ta,this.ta=e,e.diagram=this,e.event=t,i?this.c0(t,e):(e.viewPoint=this.jr.viewPoint,e.documentPoint=this.jr.documentPoint);let s=0;const n=t;return n.ctrlKey&&(s+=1),n.altKey&&(s+=2),n.shiftKey&&(s+=4),n.metaKey&&(s+=8),e.modifiers=s,e.button=n.button,n.buttons!==void 0&&(e.buttons=n.buttons),Util.cr&&n.button===0&&n.ctrlKey&&(e.button=2),e.down=!1,e.up=!1,e.clickCount=1,e.delta=0,e.handled=!1,e.bubbles=!1,e.timestamp=t.timeStamp,e.isMultiTouch=!1,e.targetDiagram=this.NP(t,t.target),e.targetObject=null,e}NP(t,i){if(i===null)return null;const e=Diagram.He.get(i);if(e)return e;let s=t.path;if(!s&&typeof t.composedPath=="function"&&(s=t.composedPath()),s&&s[0]){const n=Diagram.He.get(s[0]);if(n)return n}return null}_F(t,i,e){const s=this.PP(t,!0,!1,!1,!0,e);return this.c0(i,s),s.targetDiagram=this.NP(t,t.target),s.targetObject=null,e||s.clone(this.i0),s}tR(t,i,e){const s=this.PP(t,!1,!1,!1,!1,e);let n=root.document.elementFromPoint(i.clientX,i.clientY)||null;n!==null&&n.shadowRoot!==void 0&&n.shadowRoot!==null&&(n=n.shadowRoot.elementFromPoint(i.clientX,i.clientY));let o=this,r=t;if(n){const l=Diagram.He.get(n);l&&(r=i,o=l)}return s.targetDiagram=o,this.c0(r,s),s.targetObject=null,s}PP(t,i,e,s,n,o){const r=this.jr;this.jr=this.ta,this.ta=r,r.diagram=this,r.clickCount=1,r.delta=0;let l=0;return t.ctrlKey&&(l+=1),t.altKey&&(l+=2),t.shiftKey&&(l+=4),t.metaKey&&(l+=8),r.modifiers=l,r.event=t,r.timestamp=t.timeStamp,r.button=e?this.firstInput.button:t.button,r.buttons=t.buttons,Util.cr&&t.button===0&&t.ctrlKey&&(r.button=2),r.down=i,r.up=e,r.handled=s,r.bubbles=n,r.isMultiTouch=o,r}aa(t,i){return t.bubbles?(Debug&&Debug.handleMessages&&Util.ht("NOT handled "+i.type+" "+t.toString()),!0):(Debug&&Debug.handleMessages&&Util.ht("handled "+i.type+" "+this.currentTool.name+" "+t.toString()),i.stopPropagation!==void 0&&i.stopPropagation(),i.cancelable!==!1&&i.preventDefault(),i.cancelBubble=!0,!1)}nR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.Jf(t,!1);return e.key=t.key,e.code=t.code,e.down=!0,i.doKeyDown(),i.aa(e,t)}oR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.Jf(t,!1);return e.key=t.key,e.code=t.code,e.up=!0,i.doKeyUp(),i.aa(e,t)}eR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.Jf(t,!0);return i.mouseEnter!==null&&i.mouseEnter(e),i.currentTool.standardMouseOver(),i.aa(e,t)}sR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.Jf(t,!0);return i.mouseLeave!==null&&i.mouseLeave(e),i.aa(e,t)}getMouse(t){const i=this.xt;if(i===null)return new Point(0,0);const e=i.getBoundingClientRect(),s=(t.clientX-e.left)*(this.Ct/e.width),n=(t.clientY-e.top)*(this.At/e.height);return new Point(s,n).Ye(this.O)}c0(t,i){const e=this.xt;let s=0,n=0;if(e!==null){const r=e.getBoundingClientRect();s=(t.clientX-r.left)*(this.Ct/r.width),n=(t.clientY-r.top)*(this.At/r.height)}i.viewPoint.e(s,n);const o=Point.H(s,n);this.O.ns(o),i.documentPoint.c(o),Point.o(o)}LC(t,i,e){let s;if(this.sa[0]!==null)s=this.sa[i];else return;const n=this.xt;if(n!==null){const o=n.getBoundingClientRect();e.e((s.clientX-o.left)*(this.Ct/o.width),(s.clientY-o.top)*(this.At/o.height))}}invalidateDocumentBounds(){this.ia||(this.ia=!0,this.requestUpdate(!1))}dR(){this.ks||this.Di(),this.ensureBounds()}redraw(){this.$t||this.ks||(this.T(),this.maybeUpdate())}isUpdateRequested(){return this.Ar}delayInitialization(t){t===void 0&&(t=null);const i=this.animationManager,e=i.isEnabled;i.stopAnimation(),i.isEnabled=!1,this.Sr(),this.io=!1,this.fx=new Point(NaN,NaN),i.isEnabled=e,this.ks=!0;const s=this;t!==null&&Util.zh(()=>{s.ks=!1,i.El("Model"),t(s)},1)}requestUpdate(t){if(t===void 0&&(t=!1),this.Ar===!0||this.$t||t===!1&&this.ks)return;this.Ar=!0;const i=this;root.requestAnimationFrame(()=>{i.Ar&&i.maybeUpdate()})}maybeUpdate(){this.Yu&&!this.Ar||(this.Yu&&(this.Yu=!1),this.Sr())}AP(t,i){!this.Gu||this.$t||this.animationManager.defaultAnimation.isAnimating||this.NA()||(t&&this.Di(),i&&this.Gs(!1))}Sr(t){if(this.ks||(this.Ar=!1,this.Ot===null&&!this.Hu.isReal()))return;this.ks=!0;const i=this.animationManager,e=this.Wu;if(!i.isAnimating&&e.length!==0){const f=e.h,c=f.length;for(let u=0;u0&&(s.each(f=>f.LP()),s.clear());let n=!1,o=!1;i.defaultAnimation.isAnimating&&(o=!0,n=this.skipsUndoManager,this.skipsUndoManager=!0),i.Si||this.RM(),t||this.AP(!1,!0);const r=!this.undoManager.isUndoingRedoing&&(this.Pl||this.vf.count!==0&&this.Rr.size!==0),l=!this.io||this.Wr;this.Di(!0);let h=!1;(l||r)&&(this.io?this.TP(!this.Uf,r):(this.startTransaction("Initial Layout"),i.isEnabled===!1&&i.stopAnimation(),this.TP(!1,r)),h=l),this.Uf=!1,this.Pl=!1,this.Di(),this.os!==null&&(this.os.visible&&!this._m&&(this.Zr(),this._m=!0),!this.os.visible&&this._m&&(this._m=!1)),this.qx||this.dR(),t||this.AP(!0,!1);let a=!1;if(h){const f=Rect.a();f.c(this.viewportBounds),this.io||(this.io=!0,a=!0,this.skipsUndoManager||(this.undoManager.Uw=!0),this.undoManager.Gw=!0,this.gR()),this.mR(),this.Di(!1),t||this.AP(!0,!0),Rect.o(f)}else if(i.Ff&&i.ax){if(this.Fr!==1)this.scale=this.Zu(this.Fr);else if(this.Jl!==1)this.scale=this.Zu(this.Jl);else{const f=this.initialScale;isFinite(f)&&f>0&&(this.scale=f)}this.Gs(!0)}h&&a&&this.commitTransaction("Initial Layout"),t||this.Ji(this.ei),o&&(this.skipsUndoManager=n),this.ks=!1}get Kh(){return this.io}gR(){if(this.Fr!==1)this.scale=this.Zu(this.Fr);else if(this.Jl!==1)this.scale=this.Zu(this.Jl);else{const i=this.initialScale;isFinite(i)&&i>0&&(this.scale=i)}this.Gs(!0);const t=this.Jt.h;this.Us(t,t.length,this,this.viewportBounds),this.B("InitialLayoutCompleted"),this.fx.c(this.gt),this.Zr()}mR(){this.B("LayoutCompleted")}u0(t){this.Qn.add(t)}addInvalidRoute(t){this.Bo?this.Qh.add(t):this.Rr.add(t)}Di(t){if(this.Qn.size!==0&&!(!this.ks&&this.animationManager.isTicking)){if(this.ks||(this.Pl=!0),t){this.AA(this.Qn);return}for(let i=0;i<23&&this.Qn.size!==0;i++){const e=new Set(this.Qn);this.Qn.clear(),this.LP(e,this.Qn),Debug&&i===22&&Util.ht("failure to validate parts")}this.nodes.each(i=>{i instanceof Group&&i.LA(!1)})}}AA(t,i){for(const e of t)!e.Ae()||e instanceof Group||(e.$r()?(e.wt(1/0,1/0),e.qt()):i&&i.add(e));for(const e of t)if(e instanceof Group){if(!e.isVisible())continue;this.T1(e)}}LP(t,i){this.AA(t,i);for(const e of t){if(!(e instanceof Link))continue;const s=e;s.isVisible()&&(s.$r()?(s.wt(1/0,1/0),s.qt()):i.add(s))}for(const e of t)e instanceof Adornment&&e.isVisible()&&(e.$r()?(e.wt(1/0,1/0),e.qt()):i.add(e))}d0(t){const i=t instanceof Diagram,e=i?t.links:t.memberParts,s=this.Qn;if(i)this.Di(!0);else{for(;e.next();){const n=e.value;s.has(n)&&(!n.Ae()||n instanceof Group||n.$r()&&(n.wt(1/0,1/0),n.qt()))}for(e.reset();e.next();){const n=e.value;if(s.has(n)&&n instanceof Group){if(!n.isVisible())continue;this.T1(n)}}e.reset()}for(;e.next();){const n=e.value;n instanceof Link&&s.has(n)&&n.isVisible()&&n.$r()&&(n.wt(1/0,1/0),n.qt())}}T1(t){const i=Util.at(),e=Util.at(),s=t.memberParts;for(;s.next();){const o=s.value;o.isVisible()&&(o instanceof Group?(o.Xo()||o.rs()||o.nh())&&this.T1(o):o instanceof Link?o.fromNode===t||o.toNode===t?e.push(o):i.push(o):(o.wt(1/0,1/0),o.qt()))}let n=i.length;for(let o=0;ob.Vu())}else for(let x=0;x0){const a=n.substring(0,h);e?o=t.findObject(a):(o=t[a],o==null&&(o=t.toolManager[a])),Util.Mt(o)?r=n.substring(h+1):Util.n("Unable to find object named: "+a+" in "+t.toString()+" when trying to set property: "+n)}}if(r[0]!=="_"&&!Util.yw(o,r))if(s&&r==="ModelChanged"){t.addModelChangedListener(i[r]);continue}else if(s&&r==="Changed"){t.addChangedListener(i[r]);continue}else if(s&&Util.yw(t.toolManager,r))o=t.toolManager;else if(s&&t.TA(r)){t.addDiagramListener(r,i[r]);continue}else if(t instanceof Model&&r==="Changed"){t.addChangedListener(i[r]);continue}else Util.n('Trying to set undefined property "'+r+'" on object: '+o.toString());const l=i[n];o[r]=l,r[0]==="_"&&o instanceof GraphObject&&o.addCopyProperty(r)}}rA(){if(this.th.count!==0&&!(this.undoManager.transactionLevel>1)){for(;this.th.count>0;){const t=this.th;this.th=new GMap;const i=t.iterator;for(;i.next();){const e=i.key;e.invalidateOtherJumpOvers(i.value),e.le()}}this.T()}}T(t){if(t===void 0)this.Ge=!0,this.requestUpdate();else{const i=this.viewportBounds;t.isReal()&&i.intersectsRect(t)&&(this.Ge=!0,this.requestUpdate())}this.B("InvalidateDraw")}invalidateViewport(t,i){if(this.Ge===!0)return;if(this.Ge=!0,this.Gf==="svg"){this.maybeUpdate();return}this.getRenderingHint("temporaryPixelRatio")===!0?(this.jw(),this.maybeUpdate(),this.NS(!0)):this.maybeUpdate()}fa(){this.Gu=!0}sh(){this.Hf=!0}g0(){this.Xu!==!1&&(this.Xu=!1,this.MA(this.Ct,this.At))}MA(t,i){this.eh();const e=this.Gi,s=t*e,n=i*e;this.xt.resize(s,n,t,i)&&(this.Ge=!0,this.ei.clearContextCache(!0))}NA(){const t=this.xt;if(t===null||this.Hu.isReal())return!0;const i=this.Ct,e=this.At,s=this.Ot;let n=!1,o=this.to?this.yi:0,r=this.xn?this.yi:0,l=s.clientWidth||i+o,h=s.clientHeight||e+r;const a=this.viewportBounds,f=a.x,c=a.y,u=a.width,d=a.height;if((l!==i+o||h!==e+r)&&(this.to=!1,this.xn=!1,o=0,r=0,this.Ct=l,this.At=h,this.Xu=!0,n=!0,this.eh()),!this.io||!this.viewportBounds.isReal())return!0;const m=this.g1,g=this.m1;if(this.Gu=!1,!n&&!this.to&&!this.xn&&!this.Ku&&!this.Uu)return!0;const p=this.documentBounds;let y=0,x=0,k=0,b=0;const S=a.width,M=a.height,A=this.Xf;this.contentAlignment.isSpot()?(p.width>S&&(y=A.left,x=A.right),p.height>M&&(k=A.top,b=A.bottom)):(y=A.left,x=A.right,k=A.top,b=A.bottom);const C=p.width+y+x,P=p.height+k+b,N=this.scale,T=N;let L=C>l/N,D=P>h/N;if(!n&&!this.to&&!this.xn&&!L&&!D)return!0;const F=p.x-y,R=a.x,I=p.right+x;let O=a.right+o;const V=p.y-k,K=a.y,B=p.bottom+b;let X=a.bottom+r,z="1px",G="1px";if(this.scrollMode===1&&(L||D)){if(L&&this.hasHorizontalScrollbar&&this.allowHorizontalScroll){let Y=1;F+1O+1&&(Y=Math.max((I-O)*N+this.Ct,Y)),S+o+1X+1&&(Y=Math.max((B-X)*N+this.At,Y)),M+r+1O+1&&(v=Math.max((I-O)*N+this.Ct,v)),S+1X+1&&(v=Math.max((B-X)*N+Y,v)),M+1O+1&&(J=this.position.x*N)),this.vu)switch(this.Cx){case"negative":J=-(m.scrollWidth-J-m.clientWidth);break;case"reverse":J=m.scrollWidth-J-m.clientWidth;break}if(m.scrollLeft=J,this.hasVerticalScrollbar&&this.allowVerticalScroll&&(M+1X+1&&(m.scrollTop=this.position.y*N)),l=this.Ct,h=this.At,m.style.width=l+(this.to?this.yi:0)+"px",m.style.height=h+(this.xn?this.yi:0)+"px",i!==l||e!==h||this.animationManager.Si){const Y=Rect.H(f,c,u,d);return this.onViewportBoundsChanged(Y,this.viewportBounds,T,n),Rect.o(Y),!1}return!0}add(t){Util.s(t,Part,Diagram,"add:part");const i=t.diagram;if(i===this)return;i!==null&&Util.n("Cannot add part "+t.toString()+" to "+this.toString()+". It is already a part of "+i.toString());let e=this.findLayer(t.layerName);if(e===null&&(e=this.findLayer("")),e===null&&Util.n('Cannot add a Part when unable find a Layer named "'+t.layerName+'" and there is no default Layer'),t.layer===e)return;const s=e.$h(99999999,t,t.diagram===this);s>=0&&this.raiseChangedEvent(3,"parts",e,null,t,null,s),e.isTemporary||this.invalidateDocumentBounds(),t.invalidateLayout(1);const n=t.layerChanged;n!==null&&n(t,null,e)}$h(t){this.partManager.$h(t);const i=this;t.Qr(s=>i.DA(s)),t.data||t.Yo(),t.hasPlaceholder()&&t.u(),t.data!==null&&t.Qr(s=>i.partManager.FP(s,null)),(t.rs()===!0||t.nh()===!0)&&this.u0(t),t.FA(!0,this),t.RA()?(t.actualBounds.isReal()&&this.T(t.Zh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.T(t.Zh(t.actualBounds)),this.requestUpdate()}oe(t){t.clearAdornments(),this.partManager.oe(t);const i=this;t.data!==null&&t.Qr(s=>i.partManager.RP(s,i)),this.Qn.delete(t),t instanceof Link&&this.Rr.delete(t),t.RA()?(t.actualBounds.isReal()&&this.T(t.Zh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.T(t.Zh(t.actualBounds)),this.requestUpdate()}remove(t){Util.s(t,Part,Diagram,"remove:part"),this.IP(t,!0)}IP(t,i){const e=t.layer;if(e===null||e.diagram!==this)return;t.isSelected=!1,t.isHighlighted=!1,t.invalidateLayout(2),i&&t.Zf();const s=e.oe(-1,t,!1);s>=0&&this.raiseChangedEvent(4,"parts",e,t,null,s,null);const n=t.layerChanged;n!==null&&n(t,e,null)}removeParts(t,i){if(i===void 0&&(i=!1),Array.isArray(t)){const e=t.length;for(let s=0;s=0&&i.elt(e).isTemporary;)e--;return i.insertAt(e+1,t),this.Ai!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,e+1),this.T(),this.invalidateDocumentBounds(),this}addLayerBefore(t,i){this.OP(t,i),t.Oo(this);const e=this.Jt,s=e.indexOf(t);s>=0&&(e.delete(t),this.Ai!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;o=0&&(e.delete(t),this.Ai!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;othis.maxScale&&(i=this.maxScale);const f=Point.H(this.gt.x+l/t-l/i,this.gt.y+h/t-h/i);this.position=f,Point.o(f),this.rt=i,this.eh(),this.$t=!1,this.onViewportBoundsChanged(n,this.viewportBounds,t,!1),this.Gs(!1),e.nA(t,this.rt),this.T()}aR(){const t=this.Jt.h;for(let i=0;i{r.isAvoiding&&r.actualBounds.intersectsRect(i)&&r.invalidateRoute()})}Zr(t){const i=this.os;if(i===null||!i.visible||i.layer===null)return;const e=t!==void 0?t:this.a1;if(!e.isReal())return;const s=e.width,n=e.height;if(i.scale=1,i.angle=0,i.layer.isViewportAligned)i.width=s*this.scale,i.height=n*this.scale,i.part.alignment=Spot.TopLeft;else{i.Mi===null&&(i.Mi=new GridPanelSettings);const o=i.Mi.$f;if(!o.isReal())return;i.width=s+o.width*2,i.height=n+o.height*2;const r=Point.a();Geo.Gg(e.x,e.y,0,0,o.width,o.height,r),r.offset(-o.width,-o.height),i.part.location=r,Point.o(r)}}clearSelection(t){t===void 0&&(t=!1);const i=this.selection;if(i.count===0)return;t||this.B("ChangingSelection",i);const e=i.toArray(),s=e.length;for(let n=0;n1)&&(this.B("ChangingSelection",this.selection),this.clearSelection(!0),t.isSelected=!0,this.B("ChangedSelection",this.selection)))}selectCollection(t){if(this.B("ChangingSelection",this.selection),this.clearSelection(!0),Array.isArray(t)){const i=t.length;for(let e=0;e0){const i=t.toArray(),e=i.length;for(let s=0;s1)&&(this.clearHighlighteds(),t.isHighlighted=!0))}highlightCollection(t){const i=new GSet().addAll(t),s=this.highlighteds.copy().removeAll(i).iterator;for(;s.next();){const o=s.value;o.isHighlighted=!1}const n=i.iterator;for(;n.next();){const o=n.value;o instanceof Part||Util.n("Diagram.highlightCollection given something that is not a Part: "+o),o.isHighlighted=!0}}scroll(t,i,e){e===void 0&&(e=1);const s=i==="up"||i==="down";let n=0;const o=Point.a();if(t==="pixel")n=e;else if(t==="line")n=e*(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange);else if(t==="page"){let l=s?this.viewportBounds.height:this.viewportBounds.width;if(l*=this.scale,l!==0){const h=Math.max(l-(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange),0);n=e*h}}else if(t==="document"){const l=this.documentBounds,h=this.viewportBounds;i==="up"?this.position=o.e(h.x,l.y):i==="left"?this.position=o.e(l.x,h.y):i==="down"?this.position=o.e(h.x,l.bottom-h.height):i==="right"&&(this.position=o.e(l.right-h.width,h.y)),Point.o(o);return}else Util.n("scrolling unit must be 'pixel', 'line', 'page', or 'document', not: "+t);n/=this.scale;const r=this.position;i==="up"?this.position=o.e(r.x,r.y-n):i==="down"?this.position=o.e(r.x,r.y+n):i==="left"?this.position=o.e(r.x-n,r.y):i==="right"?this.position=o.e(r.x+n,r.y):Util.n("scrolling direction must be 'up', 'down', 'left', or 'right', not: "+i),Point.o(o)}scrollToRect(t){const i=this.viewportBounds;if(i.containsRect(t))return;const e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}centerRect(t){const i=this.viewportBounds,e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}transformDocToView(t){return t.copy().O(this.O)}transformViewToDoc(t){return t.copy().Ye(this.O)}EF(t){return t.Ye(this.O)}static None=1;static Uniform=2;static UniformToFill=3;static CycleAll=1;static CycleNotDirected=2;static CycleNotDirectedFast=3;static CycleNotUndirected=4;static CycleDestinationTree=5;static CycleSourceTree=6;static DocumentScroll=1;static InfiniteScroll=2;static TreeParentCollapsed=1;static AllParentsCollapsed=2;static AnyParentsCollapsed=3;get opacity(){return this._t}set opacity(t){const i=this._t;i!==t&&(Util.t(t,"number",Diagram,"opacity"),(t<0||t>1)&&Util.G(t,"0 <= value <= 1",Diagram,"opacity"),this._t=t,this.i("opacity",i,t),this.T())}get validCycle(){return this.Yx}set validCycle(t){const i=this.Yx;i!==t&&(Util.tt(t,CycleMode,"CycleMode"),this.Yx=t,this.i("validCycle",i,t))}get layers(){return this.Jt.iterator}get isModelReadOnly(){const t=this.Ai;return t===null?!1:t.isReadOnly}set isModelReadOnly(t){const i=this.Ai;i!==null&&(i.isReadOnly=t)}get isReadOnly(){return this.zo}set isReadOnly(t){const i=this.zo;i!==t&&(Util.t(t,"boolean",Diagram,"isReadOnly"),this.zo=t,this.i("isReadOnly",i,t))}get isEnabled(){return this.Xi}set isEnabled(t){const i=this.Xi;i!==t&&(Util.t(t,"boolean",Diagram,"isEnabled"),this.Xi=t,this.i("isEnabled",i,t))}get allowClipboard(){return this.Wx}set allowClipboard(t){const i=this.Wx;i!==t&&(Util.t(t,"boolean",Diagram,"allowClipboard"),this.Wx=t,this.i("allowClipboard",i,t))}get allowCopy(){return this.Bl}set allowCopy(t){const i=this.Bl;i!==t&&(Util.t(t,"boolean",Diagram,"allowCopy"),this.Bl=t,this.i("allowCopy",i,t))}get allowDelete(){return this.Vl}set allowDelete(t){const i=this.Vl;i!==t&&(Util.t(t,"boolean",Diagram,"allowDelete"),this.Vl=t,this.i("allowDelete",i,t))}get allowDragOut(){return this.vx}set allowDragOut(t){const i=this.vx;i!==t&&(Util.t(t,"boolean",Diagram,"allowDragOut"),this.vx=t,this.i("allowDragOut",i,t))}get allowDrop(){return this.Jx}set allowDrop(t){const i=this.Jx;i!==t&&(Util.t(t,"boolean",Diagram,"allowDrop"),this.Jx=t,this.i("allowDrop",i,t))}get allowTextEdit(){return this.zl}set allowTextEdit(t){const i=this.zl;i!==t&&(Util.t(t,"boolean",Diagram,"allowTextEdit"),this.zl=t,this.i("allowTextEdit",i,t))}get allowGroup(){return this.Xl}set allowGroup(t){const i=this.Xl;i!==t&&(Util.t(t,"boolean",Diagram,"allowGroup"),this.Xl=t,this.i("allowGroup",i,t))}get allowUngroup(){return this.Yl}set allowUngroup(t){const i=this.Yl;i!==t&&(Util.t(t,"boolean",Diagram,"allowUngroup"),this.Yl=t,this.i("allowUngroup",i,t))}get allowInsert(){return this.Zx}set allowInsert(t){const i=this.Zx;i!==t&&(Util.t(t,"boolean",Diagram,"allowInsert"),this.Zx=t,this.i("allowInsert",i,t))}get allowLink(){return this.Kl}set allowLink(t){const i=this.Kl;i!==t&&(Util.t(t,"boolean",Diagram,"allowLink"),this.Kl=t,this.i("allowLink",i,t))}get allowRelink(){return this.Ul}set allowRelink(t){const i=this.Ul;i!==t&&(Util.t(t,"boolean",Diagram,"allowRelink"),this.Ul=t,this.i("allowRelink",i,t))}get allowMove(){return this.Gl}set allowMove(t){const i=this.Gl;i!==t&&(Util.t(t,"boolean",Diagram,"allowMove"),this.Gl=t,this.i("allowMove",i,t))}get allowReshape(){return this.Hl}set allowReshape(t){const i=this.Hl;i!==t&&(Util.t(t,"boolean",Diagram,"allowReshape"),this.Hl=t,this.i("allowReshape",i,t))}get allowResize(){return this.ql}set allowResize(t){const i=this.ql;i!==t&&(Util.t(t,"boolean",Diagram,"allowResize"),this.ql=t,this.i("allowResize",i,t))}get allowRotate(){return this.jl}set allowRotate(t){const i=this.jl;i!==t&&(Util.t(t,"boolean",Diagram,"allowRotate"),this.jl=t,this.i("allowRotate",i,t))}get allowSelect(){return this.Wl}set allowSelect(t){const i=this.Wl;i!==t&&(Util.t(t,"boolean",Diagram,"allowSelect"),this.Wl=t,this.i("allowSelect",i,t))}get allowUndo(){return this.$x}set allowUndo(t){const i=this.$x;i!==t&&(Util.t(t,"boolean",Diagram,"allowUndo"),this.$x=t,this.i("allowUndo",i,t))}get allowZoom(){return this.Qx}set allowZoom(t){const i=this.Qx;i!==t&&(Util.t(t,"boolean",Diagram,"allowZoom"),this.Qx=t,this.i("allowZoom",i,t))}get hasVerticalScrollbar(){return this.Uu}set hasVerticalScrollbar(t){const i=this.Uu;i!==t&&(Util.t(t,"boolean",Diagram,"hasVerticalScrollbar"),this.Uu=t,this.fa(),this.T(),this.i("hasVerticalScrollbar",i,t),this.Gs(!1))}get hasHorizontalScrollbar(){return this.Ku}set hasHorizontalScrollbar(t){const i=this.Ku;i!==t&&(Util.t(t,"boolean",Diagram,"hasHorizontalScrollbar"),this.Ku=t,this.fa(),this.T(),this.i("hasHorizontalScrollbar",i,t),this.Gs(!1))}get allowHorizontalScroll(){return this._x}set allowHorizontalScroll(t){const i=this._x;i!==t&&(Util.t(t,"boolean",Diagram,"allowHorizontalScroll"),this._x=t,this.i("allowHorizontalScroll",i,t),this.Gs(!1))}get allowVerticalScroll(){return this.t1}set allowVerticalScroll(t){const i=this.t1;i!==t&&(Util.t(t,"boolean",Diagram,"allowVerticalScroll"),this.t1=t,this.i("allowVerticalScroll",i,t),this.Gs(!1))}get scrollHorizontalLineChange(){return this.i1}set scrollHorizontalLineChange(t){const i=this.i1;i!==t&&(Util.t(t,"number",Diagram,"scrollHorizontalLineChange"),t<0&&Util.G(t,">= 0",Diagram,"scrollHorizontalLineChange"),this.i1=t,this.i("scrollHorizontalLineChange",i,t))}get scrollVerticalLineChange(){return this.e1}set scrollVerticalLineChange(t){const i=this.e1;i!==t&&(Util.t(t,"number",Diagram,"scrollVerticalLineChange"),t<0&&Util.G(t,">= 0",Diagram,"scrollVerticalLineChange"),this.e1=t,this.i("scrollVerticalLineChange",i,t))}get lastInput(){return this.ta}set lastInput(t){Debug&&Util.s(t,InputEvent,Diagram,"lastInput"),this.ta=t}get previousInput(){return this.jr}set previousInput(t){Debug&&Util.s(t,InputEvent,Diagram,"previousInput"),this.jr=t}get firstInput(){return this.i0}set firstInput(t){Debug&&Util.s(t,InputEvent,Diagram,"firstInput"),this.i0=t}get currentCursor(){return this.Kx}set currentCursor(t){if(t===""&&(t=this.vm),this.Kx!==t){Util.t(t,"string",Diagram,"currentCursor");const e=this.xt,s=this.Ot;if(e===null||s===null)return;this.Kx=t;const n=e.style.cursor;e.style.cursor=t,s.style.cursor=t,e.style.cursor===n&&(e.style.cursor="-webkit-"+t,s.style.cursor="-webkit-"+t,e.style.cursor===n&&(e.style.cursor="-moz-"+t,s.style.cursor="-moz-"+t,e.style.cursor===n&&(e.style.cursor=t,s.style.cursor=t)))}}get defaultCursor(){return this.vm}set defaultCursor(t){t===""&&(t="auto");const i=this.vm;i!==t&&(Util.t(t,"string",Diagram,"defaultCursor"),this.vm=t,this.i("defaultCursor",i,t))}get click(){return this.Or}set click(t){const i=this.Or;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"click"),this.Or=t,this.i("click",i,t))}get doubleClick(){return this.Er}set doubleClick(t){const i=this.Er;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"doubleClick"),this.Er=t,this.i("doubleClick",i,t))}get contextClick(){return this.Br}set contextClick(t){const i=this.Br;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"contextClick"),this.Br=t,this.i("contextClick",i,t))}get mouseOver(){return this.Vr}set mouseOver(t){const i=this.Vr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseOver"),this.Vr=t,this.i("mouseOver",i,t))}get mouseHover(){return this.zr}set mouseHover(t){const i=this.zr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseHover"),this.zr=t,this.i("mouseHover",i,t))}get mouseHold(){return this.Xr}set mouseHold(t){const i=this.Xr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseHold"),this.Xr=t,this.i("mouseHold",i,t))}get mouseDragOver(){return this.Ux}set mouseDragOver(t){const i=this.Ux;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseDragOver"),this.Ux=t,this.i("mouseDragOver",i,t))}get mouseDrop(){return this.Yr}set mouseDrop(t){const i=this.Yr;i!==t&&(Debug&&t!==null&&Util.t(t,"function",Diagram,"mouseDrop"),this.Yr=t,this.i("mouseDrop",i,t))}get handlesDragDropForTopLevelParts(){return this.Gx}set handlesDragDropForTopLevelParts(t){const i=this.Gx;i!==t&&(Util.t(t,"boolean",Diagram,"handlesDragDropForTopLevelParts"),this.Gx=t,this.i("handlesDragDropForTopLevelParts",i,t))}get mouseEnter(){return this.Kr}set mouseEnter(t){const i=this.Kr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseEnter"),this.Kr=t,this.i("mouseEnter",i,t))}get mouseLeave(){return this.Ur}set mouseLeave(t){const i=this.Ur;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseLeave"),this.Ur=t,this.i("mouseLeave",i,t))}get toolTip(){return this.Gr}set toolTip(t){const i=this.Gr;i!==t&&(Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("Diagram.toolTip must be an Adornment or HTMLInfo."),this.Gr=t,this.i("toolTip",i,t))}get contextMenu(){return this.Hr}set contextMenu(t){const i=this.Hr;i!==t&&(Debug&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("Diagram.contextMenu must be an Adornment or HTMLInfo."),this.Hr=t,this.i("contextMenu",i,t))}get commandHandler(){return this.tP}set commandHandler(t){this.tP!==t&&(this.tP=t,t.Oo(this))}get toolManager(){return this.$M}set toolManager(t){this.$M!==t&&(Util.s(t,ToolManager,Diagram,"toolManager"),this.$M=t,t.diagram=this)}get defaultTool(){return this.QM}set defaultTool(t){const i=this.QM;i!==t&&(Util.s(t,Tool,Diagram,"defaultTool"),this.QM=t,t.diagram=this,this.currentTool===i&&(this.currentTool=t))}get currentTool(){return this._M}set currentTool(t){const i=this._M;i&&(i.isActive&&i.doDeactivate(),i.cancelWaitAfter(),i.doStop()),t===null&&(t=this.defaultTool),t!==null&&(Util.s(t,Tool,Diagram,"currentTool"),this._M=t,t.diagram=this,t.doStart())}get selection(){return this.lP}get maxSelectionCount(){return this.h1}set maxSelectionCount(t){const i=this.h1;if(i!==t)if(Util.t(t,"number",Diagram,"maxSelectionCount"),t>=0&&!isNaN(t)){if(this.h1=t,this.i("maxSelectionCount",i,t),!this.undoManager.isUndoingRedoing){const e=this.selection.count-t;if(e>0){this.B("ChangingSelection",this.selection);const s=this.selection.toArray();for(let n=0;n= 0",Diagram,"maxSelectionCount")}get nodeSelectionAdornmentTemplate(){return this.Qm}set nodeSelectionAdornmentTemplate(t){const i=this.Qm;i!==t&&(Util.s(t,Adornment,Diagram,"nodeSelectionAdornmentTemplate"),this.Qm=t,this.i("nodeSelectionAdornmentTemplate",i,t))}get groupSelectionAdornmentTemplate(){return this.c1}set groupSelectionAdornmentTemplate(t){const i=this.c1;i!==t&&(Util.s(t,Adornment,Diagram,"groupSelectionAdornmentTemplate"),this.c1=t,this.i("groupSelectionAdornmentTemplate",i,t))}get linkSelectionAdornmentTemplate(){return this.u1}set linkSelectionAdornmentTemplate(t){const i=this.u1;i!==t&&(Util.s(t,Adornment,Diagram,"linkSelectionAdornmentTemplate"),this.u1=t,this.i("linkSelectionAdornmentTemplate",i,t))}get highlighteds(){return this.hP}get isModified(){const t=this.undoManager;return t.isEnabled?t.currentTransaction!==null?!0:this.qu&&this.zs!==t.historyIndex:this.qu}set isModified(t){if(this.qu!==t){Util.t(t,"boolean",Diagram,"isModified"),this.qu=t;const e=this.undoManager;!t&&e.isEnabled&&(this.zs=e.historyIndex),t||this.YA()}}YA(){const t=this.isModified;this.oP!==t&&(this.oP=t,this.B("Modified"))}get model(){return this.Ai}set model(t){const i=this.Ai;if(i!==t){Util.s(t,Model,Diagram,"model"),this.currentTool.doCancel(),i&&i.undoManager!==t.undoManager&&i.undoManager.isInTransaction&&Util.n("Do not replace a Diagram.model while a transaction is in progress."),this.animationManager.stopAnimation(!0);const e=this.kA(!0);this.io=!1,this.Yu=!0,this.zs=-2,this.Ar=!1;const s=this.$t;this.$t=!0,this.animationManager.El("Model"),i&&(this._n!==null&&this._n.each(n=>i.removeChangedListener(n)),i.removeChangedListener(this.nP)),this.Ai=t,this.partManager=this.wR(this.Ai.type),this.initializePartManager(this.partManager);for(let n=0;nt.addChangedListener(n)),this.$t=s,this.invalidateDocumentBounds(),this.$t||this.T(),i&&t.undoManager.copyProperties(i.undoManager)}}get themeManager(){return this.C1}set themeManager(t){const i=this.C1;i!==t&&(Util.s(t,ThemeManager,Model,"themeManager"),i!==null&&i.removeDiagram(this),this.C1=t,t!==null&&t.addDiagram(this))}initializePartManager(t){}static SP(t,i){Diagram.mA.set(t,i)}static get licenseKey(){return Diagram.BP.last()}static set licenseKey(t){Diagram.BP.add(t.replace(/\s/g,""))}static get version(){return Diagram.xR}static BP=new List;static xR="3.0.12";wR(t){const i=Diagram.mA.get(t);return i!==null?new i:new PartManager}get j(){return this.eP}set j(t){this.eP=t}get Mx(){return this.uA}bR(t){if(t.model!==this.model)return;const i=t.change,e=t.propertyName;if(i===1&&e[0]==="S"){if(e==="StartingFirstTransaction"){const s=this,n=this.toolManager;n.mouseDownTools.each(o=>o.diagram=s),n.mouseMoveTools.each(o=>o.diagram=s),n.mouseUpTools.each(o=>o.diagram=s),this.routers.each(o=>o.diagram=s),!this.ks&&!this.io&&(this.Uf=!0,this.Yu&&(this.Ar=!0))}else if(e==="StartingUndo"||e==="StartingRedo"){const s=this.animationManager;this.skipsUndoManager||(s.defaultAnimation.isAnimating&&s.stopAnimation(),s.getBundleAnimation().isAnimating&&s.getBundleAnimation().stop()),this.B("ChangingSelection",this.selection)}else if(e==="StartedTransaction"){const s=this.animationManager;s.defaultAnimation.isAnimating&&!this.skipsUndoManager&&s.stopAnimation()}return}if(this.j){this.j=!1;try{if(t.modelChange===""&&i===1){(e==="FinishedUndo"||e==="FinishedRedo")&&(this.B("ChangedSelection",this.selection),this.Di());const s=this.animationManager;e==="RolledBackTransaction"&&s.stopAnimation(),this.rA(),this.Uf=!0,this.maybeUpdate(),(this.undoManager.transactionLevel===0||this.undoManager.transactionLevel===1)&&s.FM(),e==="CommittedTransaction"&&this.undoManager.isJustDiscarded&&(this.zs=Math.min(this.zs,this.undoManager.historyIndex-1)),(e==="CommittedTransaction"||e==="RolledBackTransaction")&&this.undoManager.Gw&&setTimeout(()=>{this.isModified=!1},1);const n=t.isTransactionFinished;if(n&&(this.YA(),this.Mx.clear(),this.animationManager.xF()),!this.Hx&&n&&this.lastInput.targetDiagram){this.Hx=!0;const o=this;Util.zh(()=>{o.currentTool.standardMouseOver(),o.Hx=!1},10)}}}finally{this.j=!0}}}get pe(){return this.iP}set pe(t){this.iP=t}get kf(){return this.qx}set kf(t){this.qx=t}DA(t){const i=t.D.h;for(const e of i)e instanceof Picture&&this.VP(e)}VP(t){const i=t.element;if(i===null||!(i instanceof HTMLImageElement)||(i.ls instanceof GSet&&i.ls.add(this),t.kR(),!i.y0))return;const e=i.getAttribute("src")||"",s=this._l.get(e);if(s===null){Picture.KA(t,i);const n=[];n.push(t),this._l.set(e,n)}else{for(let n=0;n0)&&Util.n("defaultScale must be larger than zero, not: "+t),this.e0=t}get autoScale(){return this.Jl}set autoScale(t){const i=this.Jl;i!==t&&(Util.tt(t,AutoScale,"AutoScale"),this.Jl=t,this.i("autoScale",i,t),t!==1&&this.Gs(!1))}get initialAutoScale(){return this.Fr}set initialAutoScale(t){const i=this.Fr;i!==t&&(Util.tt(t,AutoScale,"AutoScale"),this.Fr=t,this.i("initialAutoScale",i,t))}get initialViewportSpot(){return this.Vx}set initialViewportSpot(t){const i=this.Vx;i!==t&&(Util.s(t,Spot,Diagram,"initialViewportSpot"),t.isSpot()||Util.n("initialViewportSpot must be a specific Spot: "+t),this.Vx=t,this.i("initialViewportSpot",i,t))}get initialDocumentSpot(){return this.Bx}set initialDocumentSpot(t){const i=this.Bx;i!==t&&(Util.s(t,Spot,Diagram,"initialDocumentSpot"),t.isSpot()||Util.n("initialViewportSpot must be a specific Spot: "+t),this.Bx=t,this.i("initialDocumentSpot",i,t))}get minScale(){return this.Tx}set minScale(t){Util.r(t,Diagram,"minScale");const i=this.Tx;i!==t&&(t>0?(this.Tx=t,this.i("minScale",i,t),t>this.scale&&(this.scale=t)):Util.G(t,"> 0",Diagram,"minScale"))}get maxScale(){return this.Dx}set maxScale(t){Util.r(t,Diagram,"maxScale");const i=this.Dx;i!==t&&(t>0?(this.Dx=t,this.i("maxScale",i,t),t 0",Diagram,"maxScale"))}get zoomPoint(){return this.Fx}set zoomPoint(t){this.Fx.equals(t)||(Util.s(t,Point,Diagram,"zoomPoint"),t=t.L(),this.Fx=t)}get contentAlignment(){return this.Yf}set contentAlignment(t){const i=this.Yf;i.equals(t)||(Util.s(t,Spot,Diagram,"contentAlignment"),t=t.L(),this.Yf=t,this.i("contentAlignment",i,t),this.Gs(!1))}get initialContentAlignment(){return this.qm}set initialContentAlignment(t){const i=this.qm;i.equals(t)||(Util.s(t,Spot,Diagram,"initialContentAlignment"),t=t.L(),this.qm=t,this.i("initialContentAlignment",i,t))}get padding(){return this.ii}set padding(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Diagram,"padding");const i=this.ii;i.equals(t)||(t=t.L(),this.ii=t,this.invalidateDocumentBounds(),this.i("padding",i,t))}get partManager(){return this.dP}set partManager(t){const i=this.dP;i!==t&&(Util.s(t,PartManager,Diagram,"partManager"),t.diagram!==null&&Util.n("Cannot share PartManagers between Diagrams: "+t.toString()),i&&i.Oo(null),this.dP=t,t.Oo(this))}get nodes(){return this.partManager.nodes.iterator}get links(){return this.partManager.links.iterator}get parts(){return this.partManager.parts.iterator}findTopLevelNodesAndLinks(){const t=new GSet,i=this.nodes;for(;i.next();){const s=i.value;s.isTopLevel&&t.add(s)}const e=this.links;for(;e.next();){const s=e.value;s.isTopLevel&&t.add(s)}return t.iterator}findTopLevelGroups(){return this.vr.iterator}get routers(){return this.vf}doLinkRouting(t){this.Bo=!0;const i=this.vf.h;for(let e=0;e0){const l=this.computePartsBounds(n.memberParts,!1);l.inflate(20,20),s.I1(l)}const o=Rect.a(),r=n.memberParts;for(;r.next();){const l=r.value;l instanceof Node&&this.GP(l,e,o)}Rect.o(o)}s.ua=n,s.YP=e,s.Ko=!1}else t&&s.WA();return s}get avoidanceCellSize(){return this.aP}set avoidanceCellSize(t){this.Zl=null,this.aP=new Size(Math.max(1,t.width),Math.max(1,t.height))}get avoidanceLimit(){return this.fP}set avoidanceLimit(t){this.fP=Math.max(1,t)}jA(t){return t.canAvoid()?t:t.containingGroup!==null?this.jA(t.containingGroup):null}GP(t,i,e){if(t===i||!t.isVisible())return;const s=t.canAvoid();if(s){const n=t.getAvoidableRect(e);this.Zl.PR(n.x,n.y,n.width,n.height)}if(t instanceof Group&&(!s||t.avoidableMembers)){const n=t.memberParts;for(;n.next();){const o=n.value;o instanceof Node&&this.GP(o,i,e)}}}HP(t){this.Zl!==null&&!this.Zl.Ko&&(t===void 0||t.canAvoid())&&(this.Zl.Ko=!0)}get autoScrollInterval(){return this.jm}set autoScrollInterval(t){const i=this.jm;Util.r(t,Diagram,"autoScrollInterval"),i!==t&&(this.jm=t,this.i("autoScrollInterval",i,t))}get autoScrollRegion(){return this.Wm}set autoScrollRegion(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Diagram,"autoScrollRegion");const i=this.Wm;i.equals(t)||(t=t.L(),this.Wm=t,this.invalidateDocumentBounds(),this.i("autoScrollRegion",i,t))}doAutoScroll(t){this.t0.c(t),this.computeAutoScrollPosition(this.t0).equalsApprox(this.position)?this.stopAutoScroll():this.vA()}vA(){if(this.Kf!==-1)return;const t=this.jm,i=this;this.Kf=Util.zh(()=>{if(i.Kf===-1||(i.stopAutoScroll(),i.lastInput.event===null))return;const s=i.computeAutoScrollPosition(i.t0);if(s.equalsApprox(i.position))return;i.position=s,i.lastInput.documentPoint=i.transformViewToDoc(i.t0),i.doMouseMove(),i.ia=!0;const n=Rect.a();i.computeBounds(n),n.unionRect(i.documentBounds),i.UA(n),Rect.o(n),i.Ge=!0,i.maybeUpdate(),i.vA()},t)}stopAutoScroll(){this.Kf!==-1&&(Util.Kg(this.Kf),this.Kf=-1)}computeAutoScrollPosition(t){let i=this.position;const e=this.Wm;if(e.top<=0&&e.left<=0&&e.right<=0&&e.bottom<=0)return i;const s=this.viewportBounds,n=this.scale,o=Rect.H(0,0,s.width*n,s.height*n),r=Point.H(0,0);if(t.x>=o.x&&t.xo.x+o.width-e.right&&this.allowHorizontalScroll){let l=Math.max(this.scrollHorizontalLineChange,1);l=l|0,r.x+=l,t.x>o.x+o.width-e.right/2&&(r.x+=l),t.x>o.x+o.width-e.right/4&&(r.x+=4*l)}if(t.y>=o.y&&t.yo.y+o.height-e.bottom&&this.allowVerticalScroll){let l=Math.max(this.scrollVerticalLineChange,1);l=l|0,r.y+=l,t.y>o.y+o.height-e.bottom/2&&(r.y+=l),t.y>o.y+o.height-e.bottom/4&&(r.y+=4*l)}return r.equalsApprox(Point.Lo)||(i=new Point(i.x+r.x/n,i.y+r.y/n)),Rect.o(o),Point.o(r),i}makeSvg(t){this.Ql.has("SVG")||this.addRenderer("SVG",new SVGSurface(this,root.document));const i=new SVGSurface(this,root.document,!0);t===void 0&&(t={});const e=this;function s(n,o){const r=e.JA(n,"SVG",i),l=r!==null?r.svg:null;return typeof o=="function"?(o(l),null):l}return this.ZA(s,t)}makeSVG(t){return this.makeSvg(t)}addRenderer(t,i){this.Ql.set(t,i)}removeRenderer(t){this.Ql.delete(t)}cacheGroupExternalLinks(t){this.kP=t,t||this.nodes.each(i=>{i instanceof Group&&(i.x0=null)})}ZA(t,i){const e=i.callback;let s=!0;const o=this._l.iterator;for(;o.next();)if(!o.value[0].bn){s=!1;break}if(typeof e!="function"||s)return t(i,e,this);const r=this;function l(){const f=+new Date;for(s=!0,o.reset();o.next();)if(!o.value[0].bn){s=!1;break}if(s||f-a>h){t(i,e,r);return}root.requestAnimationFrame(l)}const h=i.callbackTimeout||300,a=+new Date;return root.requestAnimationFrame(()=>l()),null}makeImage(t){return Diagram.isUsingDOM()?(t===void 0&&(t={}),t.returnType="Image",this.makeImageData(t)):null}makeImageData(t){return t===void 0&&(t={}),this.ZA(this.NR,t)}static img="image";NR(t,i,e){const s=e.JA(t,"canvas",null);if(s===null)return null;const n=s.Y.canvas;let o=null;if(n!==null){let r=t.returnType;switch(r===void 0?r="string":r=r.toLowerCase(),r){case Diagram.img+"data":o=s.getImageData(0,0,n.width,n.height);break;case Diagram.img:const h=(t.document||document).createElement("img");h.src=n.toDataURL(t.type,t.details),o=h;break;case"blob":{const a=n;return typeof i!="function"&&(o="",Util.n('Error: Diagram.makeImageData called with "returnType: toBlob", but no required "callback" function property defined.')),typeof a.toBlob=="function"?(a.toBlob(i,t.type,t.details),"toBlob"):(i(null),null)}case"string":default:o=n.toDataURL(t.type,t.details)}}return typeof i=="function"?(i(o),null):o}static $A=!1;JA(t,i,e){if(this.animationManager.stopAnimation(),this.maybeUpdate(),this.xt===null)return null;typeof t!="object"&&Util.n("properties argument must be an Object.");let n=!1,o=t.size||null,r=t.scale||null;t.scale!==void 0&&isNaN(t.scale)&&(r="NaN");let l=t.maxSize;t.maxSize===void 0&&(n=!0,i==="SVG"?l=new Size(1/0,1/0):l=new Size(2e3,2e3));const h=t.position||null;let a=t.parts||null;Array.isArray(a)&&(a=new List(a));let f=t.padding===void 0?1:t.padding;const c=t.background||null;let u=t.omitTemporary;u===void 0&&(u=!0);const d=t.document||document,m=t.elementFinished||null;let g=t.showTemporary;g===void 0&&(g=!u);let p=t.showGrid;p===void 0&&(p=g),o!==null&&isNaN(o.width)&&isNaN(o.height)&&(o=null),typeof f=="number"?f=new Margin(f):f instanceof Margin||Util.n("MakeImage padding must be a Margin or a number."),f.left=Math.max(f.left,0),f.right=Math.max(f.right,0),f.top=Math.max(f.top,0),f.bottom=Math.max(f.bottom,0),this.ei.clearContextCache(!0);const y=new CanvasSurface(null,d,void 0,!0),x=y.di;if(!(o||r||a||h))return y.width=this.Ct+Math.ceil(f.left+f.right),y.height=this.At+Math.ceil(f.top+f.bottom),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.da=d,e.$u=m,this.D1(e.di,f,new Size(y.width,y.height),this.rt,this.gt,a,c,g,p),e.di):(this.ju=!1,this.D1(x,f,new Size(y.width,y.height),this.rt,this.gt,a,c,g,p),this.ju=!0,y.di);const k=this.e0,b=this.documentBounds.copy();if(b.subtractMargin(this.ii),g){const L=this.Jt.h,D=L.length;for(let F=0;Fk?(r=k,N=b.width,T=b.height):(N=l.width,T=l.height)):(N=b.width*r,T=b.height*r):(r=k,N=b.width,T=b.height),f!==null?(N+=M,T+=A):f=new Margin(0),l!==null){let L=l.width,D=l.height;i!=="SVG"&&n&&!Diagram.$A&&Debug&&(N>L||T>D)&&(Util.ht("Diagram.makeImage(data): Diagram width or height is larger than the default max size. ("+Math.ceil(N)+"x"+Math.ceil(T)+" vs 2000x2000) Consider increasing the max size."),Diagram.$A=!0),isNaN(L)&&(L=2e3),isNaN(D)&&(D=2e3),isFinite(L)&&(N=Math.min(N,L)),isFinite(D)&&(T=Math.min(T,D))}return y.width=Math.ceil(N),y.height=Math.ceil(T),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.da=d,e.$u=m,this.D1(e.di,f,new Size(Math.ceil(N),Math.ceil(T)),r,S,a,c,g,p),e.di):(this.ju=!1,this.D1(x,f,new Size(Math.ceil(N),Math.ceil(T)),r,S,a,c,g,p),this.ju=!0,y.di)}static Ju=null;static QA="5da73c80a36555d4038e4972187c3cae51fd22";static ww=!1;static Hk=()=>{if(Diagram.QA[5]===void 0&&(Transform.prototype.ns=Transform.prototype.Nw),!Diagram.isUsingDOM())return;const t=root.document.createElement("canvas"),i=t.getContext("2d"),e=Util.Fs("7ca11abfd022028846");i[e]=Util.Fs("398c3597c01238");const s="7ca11abfd7330390",n=[Diagram.QA,Util.ww+"4ae6247590da4bb21c324ba3a84e385776",Transform.Hk+"fb236cdfda5de14c134ba1a95a2d4c7cc6f93c1387",Geo.za],o=10,r=0;for(let l=1;l<5;l++)i[Util.Fs(s)](Util.Fs(n[l-1]),o,l*15+r);i[e]=Util.Fs("39f046ebb36e4b");for(let l=1;l<5;l++)i[Util.Fs(s)](Util.Fs(n[l-1]),o,l*15+r);(n.length!==4||n[0][0]!=="5"||n[3][0]!=="7")&&(Transform.prototype.ns=Transform.prototype.Nw),Diagram.Ju=t}}class DiagramHelper{_A;tL;qP;De;constructor(t){if(this._A=null,this.tL="63ad05bbe23a1786468a4c741b6d2",this.qP="@onz",this.tL===this._tk){this.qP=!0,this.De=this.qP;return}this.De=null}CR(t,i){let e="f";const s=root[Util.Fs("76a715b2f73f148a")][Util.Fs("72ba13b5")]||"",n=Util.Fs;if(this.De=!0,!Diagram.isUsingDOM())return;let o=Diagram[n("76a115b6ed251eaf4692")];if(!o){const l=s[n("76ad18b4f73e")];for(let a=s[n("73a612b6fb191d")](n("35e7"))+2;a=0&&ha[0]||h[0]===a[0]&&h[1]>=a[1]))continue;const f="73a612b6fb191d",c=root[n("74a900bae4370f8b51")][n("6fbb13a1c2311e8a57")].toLowerCase(),u=c[n(f)](n("3aad1ab6e022098b4dc4")),d=n(l[2]);if(u>-1){const P=c[n(f)](d.toLowerCase()+"/");if(this.De=!(P>-1&&P=0&&g-1),!this.De))return;const p=root[Util.Fs("76a715b2f73f148a")][Util.Fs("69ad17a1e03e")],y=p[n(f)](n("7fb002b6ed25128b4da25b2e"));if(y>-1&&(this.De=!(p[n(f)](d)>y),!this.De))return;const x=d;if(x[0]!=="#")continue;const k=root.document.createElement("div");let b=l[0].replace(/[A-Za-z]/g,"");for(;b.length<4;)b+="9";const S=b;b=b.substring(b.length-4);let M="";const A=["gsh","gsf"],C=["Header","Background","Display","Feedback"];if(M+=A[parseInt(b.substring(0,1),10)%2],M+=C[parseInt(b.substring(0,1),10)%4],k[n("79a417a0f0181a8946")]=M,root.document[n("78a712aa")]){root.document[n("78a712aa")][n("7bb806b6ed32388c4a875b")](k);const P=root.getComputedStyle(k).getPropertyValue(n("78a704b7e62456904c9b12701b6532a8")),N=root.getComputedStyle(k).getPropertyValue(n("75b817b0ea2202"));if(root.document[n("78a712aa")][n("68ad1bbcf533388c4a875b")](k),!P)continue;const T=root[n("77a902b0eb1b1e804a8a")],L="0."+parseInt(S,10)%100;if(N===L||P.indexOf(parseInt(x[1]+x[2],16))!==-1&&P.indexOf(parseInt(x[3]+x[4],16))!==-1){this.De=!1;return}else if(T&&T(n("32ae19a1e0331fc94084537c067a67fa59f1386b89d006")).matches){M="."+M;for(let D=0;D{const s=this.observed;if(s===null)return;const n=s.viewportBounds,o=this.lastInput.documentPoint;s.position=new Point(o.x-n.width/2,o.y-n.height/2)},this.vP=s=>{this.invalidateDocumentBounds(),this.k0()},this.JP=s=>{this.observed!==null&&(this.invalidateDocumentBounds(),this.T())},this.z1=s=>{this.updateDelay<1?this.T():this.b0||(this.b0=!0,setTimeout(()=>this.redraw(),this.updateDelay))},this.ZP=s=>{this.observed!==null&&this.k0()},this.autoScale=2,this.$t=!1,i&&Object.assign(this,i),this}setupRouters(){}computePixelRatio(){return 1}redraw(){this.b0&&this.updateDelay>=1&&(this.b0=!1,this.AR()),super.redraw()}Ji(){if(this.Ot===null&&Util.n("No div specified"),this.xt===null&&Util.n("No canvas specified"),this.xt instanceof SVGSurface||(this.box.jM(),!this.Ge))return;const t=this.observed;if(t===null||t.animationManager.defaultAnimation.isAnimating||!t.Kh)return;this.g0();const i=this.xt,e=this.ei;if(e.clearContextCache(!0),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,i.width,i.height),this.updateDelay<1)this.eL();else if(this._f!==null){e.drawImage(this._f.Vt,0,0);const o=this.O;e.scale(this.Gi,this.Gi),e.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),e.commitTransform()}const s=this.Jt.h,n=s.length;for(let o=0;on.canDelete())}t.removeParts(i,!0),t.B("SelectionDeleted",i)}finally{t.commitTransaction("Delete"),t.B("ChangedSelection",t.selection),t.currentCursor=""}}canDeleteSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowDelete||t.selection.count===0)}copySelection(){const t=this.diagram;try{const i=new GSet,e=t.selection.iterator;for(;e.next();){const s=e.value;Part.lh(i,s,!0,this.copiesTree?1/0:0,this.copiesConnectedLinks,n=>n.canCopy())}this.copyToClipboard(i)}finally{}}canCopySelection(){const t=this.diagram;return!(!t.allowCopy||!t.allowClipboard||t.selection.count===0)}cutSelection(){this.copySelection(),this.deleteSelection()}canCutSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowCopy||!t.allowDelete||!t.allowClipboard||t.selection.count===0)}copyToClipboard(t){const i=this.diagram;let e=null;if(t===null)Diagram.bA();else{const s=i.model;let n=!1,o=!1,r=null;try{s.Pf()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.Sf()||s.Qu())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=i.copyParts(t,null,!0)}finally{s.Pf()&&(s.copiesParentKeyOfNodeData=n),(s.Sf()||s.Qu())&&(s.copiesGroupKeyOfNodeData=o),e=new List,e.addAll(r.iteratorValues),Diagram.f0=e,Diagram.A1=i.model.dataFormat}}i.B("ClipboardChanged",e)}pasteFromClipboard(){const t=new GSet,i=Diagram.f0;if(i===null)return t;const e=this.diagram;if(Diagram.A1!==e.model.dataFormat)return t;const s=e.model;let n=!1,o=!1,r=null;try{s.Pf()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.Sf()||s.Qu())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=e.copyParts(i,e,!1)}finally{s.Pf()&&(s.copiesParentKeyOfNodeData=n),(s.Sf()||s.Qu())&&(s.copiesGroupKeyOfNodeData=o);const l=r.iterator;for(;l.next();){const h=l.value,a=l.key;h.location.isReal()||(a.location.isReal()?h.location=a.location:!h.position.isReal()&&a.position.isReal()&&(h.position=a.position)),t.add(h)}}return t}pasteSelection(t){t===void 0&&(t=null);const i=this.diagram;try{i.currentCursor="wait",i.B("ChangingSelection",i.selection),i.startTransaction("Paste");const e=this.pasteFromClipboard();e.count>0&&i.clearSelection(!0);const s=e.iterator;for(;s.next();){const n=s.value;n.isSelected=!0}if(t!==null){const n=i.computePartsBounds(i.selection);if(n.isReal()){const o=this.computeEffectiveCollection(i.selection,i.M1);i.LS(o,new Point(t.x-n.centerX,t.y-n.centerY),i.M1,!1)}}i.B("ClipboardPasted",e)}finally{i.commitTransaction("Paste"),i.B("ChangedSelection",i.selection),i.currentCursor=""}}canPasteSelection(t){const i=this.diagram;return!(i.isReadOnly||i.isModelReadOnly||!i.allowInsert||!i.allowClipboard||Diagram.f0===null||Diagram.f0.count===0||Diagram.A1!==i.model.dataFormat)}undo(){this.diagram.undoManager.undo()}canUndo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canUndo()}redo(){this.diagram.undoManager.redo()}canRedo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canRedo()}decreaseZoom(t){t===void 0&&(t=1/this.zoomFactor),Util.r(t,CommandHandler,"decreaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canDecreaseZoom(t){t===void 0&&(t=1/this.zoomFactor),Util.r(t,CommandHandler,"canDecreaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}increaseZoom(t){t===void 0&&(t=this.zoomFactor),Util.r(t,CommandHandler,"increaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canIncreaseZoom(t){t===void 0&&(t=this.zoomFactor),Util.r(t,CommandHandler,"canIncreaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}resetZoom(t){t===void 0&&(t=this.defaultScale),Util.r(t,CommandHandler,"resetZoom:newscale");const i=this.diagram;ti.maxScale||(i.scale=t)}canResetZoom(t){t===void 0&&(t=this.defaultScale),Util.r(t,CommandHandler,"canResetZoom:newscale");const i=this.diagram;return ti.maxScale?!1:i.allowZoom}zoomToFit(){const t=this.diagram,i=t.animationManager;i.stopAnimation(),t.redraw();const e=t.position,s=t.scale;i.El("Zoom To Fit"),this.isZoomToFitRestoreEnabled&&s===this.Y1&&!isNaN(this.X1)&&t.documentBounds.equals(this.K1)?(t.scale=this.X1,t.position=this.h2,this.Y1=NaN,this.K1=Rect.kw):(this.X1=s,this.h2=e.copy(),t.zoomToFit(),this.Y1=t.scale,this.K1=t.documentBounds.copy()),i.FM()}canZoomToFit(){return this.diagram.allowZoom}scrollToPart(t){t===void 0&&(t=null),t!==null&&Util.s(t,Part,CommandHandler,"part");const i=this.diagram;if(i.ensureBounds(),t===null){try{this.Uo!==null&&(this.Uo.next()?t=this.Uo.value:this.Uo=null)}catch{this.Uo=null}t===null&&(i.highlighteds.count>0?this.Uo=i.highlighteds.iterator:i.selection.count>0&&(this.Uo=i.selection.iterator),this.Uo!==null&&this.Uo.next()&&(t=this.Uo.value))}if(t!==null){const e=i.animationManager;e.El("Scroll To Part");const s=this.scrollToPartPause;if(s>0){const n=this.tc(t,[t]);if(n.length===1)i.startTransaction(),i.centerRect(t.actualBounds),i.commitTransaction("Scroll To Part");else{const o=()=>{i.startTransaction();let l=n.pop();for(;n.length>0&&l instanceof Node&&l.isTreeExpanded&&(!(l instanceof Group)||l.isSubGraphExpanded);)l=n.pop();n.length>0?(l instanceof Part&&i.scrollToRect(l.actualBounds),l instanceof Node&&!l.isTreeExpanded&&(l.isTreeExpanded=!0),l instanceof Group&&!l.isSubGraphExpanded&&(l.isSubGraphExpanded=!0)):(l instanceof Part&&i.centerRect(l.actualBounds),i.removeDiagramListener("LayoutCompleted",r)),i.commitTransaction("Scroll To Part")},r=()=>{Util.zh(o,(e.isEnabled?e.duration:0)+s)};i.addDiagramListener("LayoutCompleted",r),o()}}else{const n=i.position.copy();i.centerRect(t.actualBounds),n.equalsApprox(i.position)&&e.stopAnimation()}}}tc(t,i){if(t.isVisible())return i;if(t instanceof Adornment)this.tc(t.adornedPart,i);else if(t instanceof Link){const e=t.fromNode;e!==null&&this.tc(e,i);const s=t.toNode;s!==null&&this.tc(s,i)}else{if(t instanceof Node){const s=t.labeledLink;s!==null&&this.tc(s,i);const n=t.findTreeParentNode();n!==null&&(!n.isTreeExpanded&&!n.wasTreeExpanded&&i.push(n),this.tc(n,i))}const e=t.containingGroup;e!==null&&(!e.isSubGraphExpanded&&!e.wasSubGraphExpanded&&i.push(e),this.tc(e,i))}return i}canScrollToPart(t){if(t===void 0&&(t=null),t!==null&&!(t instanceof Part))return!1;const i=this.diagram;return i.selection.count===0&&i.highlighteds.count===0?!1:i.allowHorizontalScroll&&i.allowVerticalScroll}collapseTree(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse Tree";try{i.startTransaction(e),i.animationManager.El(e);const n=new List;if(t!==null&&t.isTreeExpanded)t.collapseTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&r.isTreeExpanded&&(r.collapseTree(),n.add(r))}}i.B("TreeCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||!t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(!s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}expandTree(t){t===void 0&&(t=null);const i=this.diagram,e="Expand Tree";try{i.startTransaction(e),i.animationManager.El(e);const n=new List;if(t!==null&&!t.isTreeExpanded)t.expandTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&(r.isTreeExpanded||(r.expandTree(),n.add(r)))}}i.B("TreeExpanded",n)}finally{i.commitTransaction(e)}}canExpandTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}groupSelection(){const t=this.diagram,i=t.model;if(!i.ga())return;const e=this.archetypeGroupData;if(e===null)return;let s=null;try{t.currentCursor="wait",t.B("ChangingSelection",t.selection),t.startTransaction("Group");const n=new List,o=t.selection.iterator;for(;o.next();){const h=o.value;h.Ae()&&h.canGroup()&&n.add(h)}const r=new List,l=n.iterator;for(;l.next();){const h=l.value;let a=!1;const f=n.iterator;for(;f.next();){const c=f.value;if(h.isMemberOf(c)){a=!0;break}}a||r.add(h)}if(r.count>0){let h=r.first().containingGroup;if(h!==null)for(;h!==null;){let a=!1;const f=r.iterator;for(;f.next();)if(!f.value.isMemberOf(h)){a=!0;break}if(a)h=h.containingGroup;else break}if(e instanceof Group)e.ci(),s=e.copy(),s!==null&&t.add(s);else if(i.isGroupForData(e)){const a=i.copyNodeData(e);Util.Mt(a)&&(i.addNodeData(a),s=t.findNodeForData(a))}if(s!==null){h!==null&&this.isValidMember(h,s)&&(s.containingGroup=h);const a=r.iterator;for(;a.next();){const f=a.value;this.isValidMember(s,f)&&(f.containingGroup=s)}t.clearSelection(!0),s.isSelected=!0}}t.B("SelectionGrouped",s)}finally{t.commitTransaction("Group"),t.B("ChangedSelection",t.selection),t.currentCursor=""}}canGroupSelection(){const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowGroup||!t.model.ga()||this.archetypeGroupData===null)return!1;const e=t.selection.iterator;for(;e.next();){const s=e.value;if(s.Ae()&&s.canGroup())return!0}return!1}c2(t){const i=Util.at();if(Array.isArray(t))t.forEach(n=>{n instanceof Link||n instanceof Part&&i.push(n)});else{const n=t.iterator;for(;n.next();){const o=n.value;o instanceof Link||o instanceof Part&&i.push(o)}}const e=new GSet,s=i.length;for(let n=0;n0){i.clearSelection(!0);const o=s.iterator;for(;o.next();){const r=o.value;r.expandSubGraph();const l=r.containingGroup,h=l!==null&&l.data!==null?e.getKeyForNodeData(l.data):void 0;n.addAll(r.memberParts);const a=n.iterator;for(;a.next();){const f=a.value;if(f.isSelected=!0,f instanceof Link)continue;const c=f.data;c!==null?e.setGroupForData(c,h):f.containingGroup=l}i.remove(r)}}i.B("SelectionUngrouped",s,n)}finally{i.commitTransaction("Ungroup"),i.B("ChangedSelection",i.selection),i.currentCursor=""}}canUngroupSelection(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowDelete||!i.allowUngroup||!i.model.ga())return!1;if(t!==null){if(!(t instanceof Group))return!1;if(t.canUngroup())return!0}else{const s=i.selection.iterator;for(;s.next();){const n=s.value;if(n instanceof Group&&n.canUngroup())return!0}}return!1}addTopLevelParts(t,i){const e=this.c2(t);let s=!0;const n=e.iterator;for(;n.next();){const o=n.value;o.containingGroup!==null&&(!i||this.isValidMember(null,o)?o.containingGroup=null:s=!1)}return s}collapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse SubGraph";try{i.startTransaction(e),i.animationManager.El(e);const n=new List;if(t!==null&&t.isSubGraphExpanded)t.collapseSubGraph(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&r.isSubGraphExpanded&&(r.collapseSubGraph(),n.add(r))}}i.B("SubGraphCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||!t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&s.isSubGraphExpanded)return!0}}return!1}expandSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Expand SubGraph",s=new List;try{if(i.startTransaction(e),i.animationManager.El(e),t!==null&&!t.isSubGraphExpanded)t.expandSubGraph(),s.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&(r.isSubGraphExpanded||(r.expandSubGraph(),s.add(r)))}}i.B("SubGraphExpanded",s)}finally{for(const n of s)this.sL(i,n);t&&this.sL(i,t),i.commitTransaction(e)}}sL(t,i){for(const e of i.memberParts)e instanceof Node&&t.Of(e,i)}canExpandSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&!s.isSubGraphExpanded)return!0}}return!1}editTextBlock(t){t===void 0&&(t=null),t!==null&&Util.s(t,TextBlock,CommandHandler,"editTextBlock");const i=this.diagram,e=i.toolManager.findTool("TextEditing");if(e!==null){if(t===null){let s=null;const n=i.selection.iterator;for(;n.next();){const o=n.value;if(o.canEdit()){s=o;break}}if(s===null)return;t=s.findInVisualTree(o=>o instanceof TextBlock&&o.editable)}t!==null&&(i.currentTool=null,e.textBlock=t,i.currentTool=e)}}canEditTextBlock(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowTextEdit||i.toolManager.findTool("TextEditing")===null)return!1;if(t!==null){if(!(t instanceof TextBlock))return!1;const e=t.part;if(e!==null&&e.canEdit())return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s.canEdit()&&(t=s.findInVisualTree(n=>n instanceof TextBlock&&n.editable),t!==null))return!0}}return!1}showContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");if(e===null)return;t===void 0&&(i.selection.count>0?t=i.selection.first():t=i);const s=e.findObjectWithContextMenu(t);if(s!==null){const n=i.lastInput;let o=null;if(s instanceof GraphObject)o=s.getDocumentPoint(Spot.Center);else if(!i.viewportBounds.containsPoint(n.documentPoint)){const r=i.viewportBounds;o=new Point(r.x+r.width/2,r.y+r.height/2)}if(o!==null){const r=new InputEvent;r.diagram=i,r.viewPoint=i.transformDocToView(o),r.documentPoint=o,r.button=2,r.up=!0,i.lastInput=r}i.currentTool=e,e.openMenu(!1,s)}}canShowContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");return!(e===null||(t===void 0&&(i.selection.count>0?t=i.selection.first():t=i),e.findObjectWithContextMenu(t)===null))}get copiesClipboardData(){return this.$P}set copiesClipboardData(t){Util.t(t,"boolean",CommandHandler,"copiesClipboardData"),this.$P=t}get copiesConnectedLinks(){return this.QP}set copiesConnectedLinks(t){Util.t(t,"boolean",CommandHandler,"copiesConnectedLinks"),this.QP=t}get deletesConnectedLinks(){return this._P}set deletesConnectedLinks(t){Util.t(t,"boolean",CommandHandler,"deletesConnectedLinks"),this._P=t}get copiesTree(){return this.t2}set copiesTree(t){Util.t(t,"boolean",CommandHandler,"copiesTree"),this.t2=t}get deletesTree(){return this.i2}set deletesTree(t){Util.t(t,"boolean",CommandHandler,"deletesTree"),this.i2=t}get copiesParentKey(){return this.e2}set copiesParentKey(t){Util.t(t,"boolean",CommandHandler,"copiesParentKey"),this.e2=t}get copiesGroupKey(){return this.s2}set copiesGroupKey(t){Util.t(t,"boolean",CommandHandler,"copiesGroupKey"),this.s2=t}get archetypeGroupData(){return this.o2}set archetypeGroupData(t){t!==null&&Util.t(t,"object",CommandHandler,"archetypeGroupData");const i=this.diagram;if(Debug){const e=i.model;e.ga()&&!(t instanceof Group)&&!e.isGroupForData(t)&&Util.n("CommandHandler.archetypeGroupData must be either a Group or a data object for which GraphLinksModel.isGroupForNodeData is true: "+t)}this.o2=t}get memberValidation(){return this.rh}set memberValidation(t){t!==null&&Util.t(t,"function",CommandHandler,"memberValidation"),this.rh=t}get defaultScale(){return this.diagram.defaultScale}set defaultScale(t){this.diagram.defaultScale=t}get zoomFactor(){return this.l2}set zoomFactor(t){Util.r(t,CommandHandler,"zoomFactor"),t>1||Util.n("zoomFactor must be larger than 1.0, not: "+t),this.l2=t}get isZoomToFitRestoreEnabled(){return this.a2}set isZoomToFitRestoreEnabled(t){Util.t(t,"boolean",CommandHandler,"isZoomToFitRestoreEnabled"),this.a2=t}get scrollToPartPause(){return this.f2}set scrollToPartPause(t){Util.r(t,CommandHandler,"scrollToPartPause"),this.f2=t}computeEffectiveCollection(t,i){const e=this.diagram,s=e.toolManager.findTool("Dragging"),n=e.currentTool===s;i===void 0&&(i=e.p0());const o=new GMap;if(t===null)return o;let r=t.iterator;for(;r.next();){const l=r.value;e._r(o,l,n,i)}if(e.draggedLink!==null&&i.dragsLink)return o;for(r=t.iterator;r.next();){const l=r.value;if(l instanceof Link){const h=l.fromNode;if(h!==null&&!o.has(h))o.delete(l);else{const a=l.toNode;a!==null&&!o.has(a)&&o.delete(l)}}}return o}}var Stretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Vertical=4]="Vertical",w[w.Horizontal=5]="Horizontal",w[w.Fill=2]="Fill",w))(Stretch||{}),Orientation=(w=>(w[w.None=0]="None",w[w.Along=21]="Along",w[w.Plus90=22]="Plus90",w[w.Minus90=23]="Minus90",w[w.Opposite=24]="Opposite",w[w.Upright=25]="Upright",w[w.Plus90Upright=26]="Plus90Upright",w[w.Minus90Upright=27]="Minus90Upright",w[w.Upright45=28]="Upright45",w))(Orientation||{}),Flip=(w=>(w[w.None=0]="None",w[w.Vertical=1]="Vertical",w[w.Horizontal=2]="Horizontal",w[w.Both=3]="Both",w))(Flip||{});class GraphObject{l;_u;td;Go;g;hh;Z;gt;he;_t;ed;Hs;Ft;qe;il;ah;Pi;ma;rt;jt;el;Fi;Hi;sd;ai;ic;Ut;hi;sl;U1;fh;nd;constructor(){GSet.vi(this),this.l=30723,this._t=1,this.ed="",this.Hs=null,this.Ft=null,this.gt=new Point(NaN,NaN).w(),this.qe=Size.xw,this.il=new Transform,this.ah=new Transform,this.Pi=null,this.ma=1,this.rt=1,this.jt=0,this.el=Margin.Hg,this.he=new Rect(NaN,NaN,NaN,NaN).w(),this.Fi=new Rect(NaN,NaN,NaN,NaN).w(),this.Hi=new Rect(0,0,NaN,NaN).w(),this.sd=null,this._u=null,this.Z=null,this.ai=Spot.Default,this.ic=Spot.Default,this.td=0,this.Go=0,this.Ut=null,this.g=null,this.hh=null,this.hi=null,this.U1=null,this.fh=null,this.sl=null,this.nd=null}cloneProtected(t){t.l=(this.l|2048|4096)&-32769,t._t=this._t,t.ed=this.ed,t.Ft=this.Ft,t.gt.c(this.gt),t.qe=this.qe.L(),this.Pi!==null?t.Pi=this.Pi.copy():t.Pi=null,t.rt=this.rt,t.jt=this.jt,t.el=this.el.L(),t.he.c(this.he),t.Fi.c(this.Fi),t.Hi.c(this.Hi),t._u=this._u,this.Z!==null&&(t.Z=this.Z.copy()),t.ai=this.ai.L(),t.ic=this.ic.L(),t.td=this.td,t.Go=this.Go,this.Ut!==null&&(t.Ut=this.Ut.copy()),this.g!==null&&(this.g.wi?t.g=this.g:t.g=this.g.copy()),this.hh!==null&&(t.hh=this.hh.slice()),this.hi!==null&&(t.hi=this.hi.copy())}addCopyProperty(t){let i=this.hh;if(!Array.isArray(i))i=[],this.hh=i;else for(let e=0;e{d.data!==null&&d.u2()&&d.updateTargetBindings(i)})}}}}SF(t){this.nd.delete(t)}Yo(){if(this.diagram===null)return;if(this.findBindingPanel()===null&&this.Ri!==null){const i=this.Ri.iterator;for(;i.next();){const e=i.value;if(!e.isToTheme)continue;let s=null;const n=e.sourceName;e.isToObject&&(s=this.nL(n));let o=this;const r=e.targetId;r!==-1&&(o=this.S0(r),o===null)||(n==="/"?s=o.part:n==="."?s=o:n===".."&&(s=o.panel),e.updateTarget(o,s))}}}Sa(t,i){const e=this.findBindingPanel();if(e!==null){const s=this.Ri.iterator;for(;s.next();){const n=s.value;let o=null;if(n.isToObject){if(o=n.oL(e,this),o===null)continue;n.updateSource(this,o,i,null)}else if(n.isToModel){const r=t.diagram;r!==null&&!r.pe&&n.updateSource(this,r.model.modelData,i,e)}else if(!n.isToTheme){const r=e.data;if(r===null)continue;const l=t.diagram;l!==null&&!l.pe&&n.updateSource(this,r,i,e)}if(o===this){const r=n.targetId,l=e.S0(r);l!==null&&n.updateTarget(l,o,i)}}}}S0(t){return this.eo===t?this:null}nL(t){let i;return t===""?i=this:t==="/"?i=this:t==="."?i=this:t===".."?i=this:(i=this.part.findObject(t),i===null&&Debug&&Util.ht("Binding error: missing GraphObject named "+t+" in "+this.part.toString())),i}get eo(){return this.g!==null?this.g.eo:-1}set eo(t){this.eo!==t&&(this.g===null&&(this.g=new GraphObjectTemplateSettings),this.g.eo=t)}get Ri(){return this.g!==null?this.g.Ri:null}set Ri(t){this.Ri!==t&&(this.g===null&&(this.g=new GraphObjectTemplateSettings),this.g.Ri=t)}get so(){return this.g!==null?this.g.so:null}set so(t){this.so!==t&&(this.g===null&&(this.g=new GraphObjectTemplateSettings),this.g.so=t)}raiseChanged(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}i(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}no(t,i,e,s){const n=this.he;if(n.e(t,i,e,s),this.rt!==1||this.jt!==0){this.Pi===null&&(this.Pi=new Transform);const o=this.Pi;o.Vi(),this.M0(o,t,i,e,s),o.Cw(n)}}rL(t,i,e){return this.pickable===!1?!1:(e.af(this.O),i?this.intersectsRect(t,e):this.containedInRect(t,e))}lL(t,i,e){if(this.pickable===!1)return!1;const s=this.naturalBounds,n=t.distanceSquaredPoint(i);return e?Point.distanceLineSegmentSquared(t.x,t.y,0,0,0,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,0,s.height,s.width,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,s.height,s.width,0)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,0,0,0)<=n:t.distanceSquared(0,0)<=n&&t.distanceSquared(0,s.height)<=n&&t.distanceSquared(s.width,0)<=n&&t.distanceSquared(s.width,s.height)<=n}kn(){return!0}containsPoint(t){Debug&&Util.s(t,Point,GraphObject,"containsPoint:p");const i=Point.a();i.c(t),this.O.Pt(i);const e=this.actualBounds;if(!e.isReal())return Point.o(i),!1;const s=this.diagram;if(s!==null&&s.o0){const o=s.getInputOption("extraTouchThreshold"),r=s.getInputOption("extraTouchArea"),l=r/2,h=this.naturalBounds,a=this.getDocumentScale()*s.scale,f=1/a;if(h.width*ae&&(c=t),isFinite(i)&&i>s&&(u=i);break;case 5:isFinite(t)&&t>e&&(c=t),u=0,d&&(i=1/0);break;case 4:isFinite(i)&&i>s&&(u=i),c=0,d&&(t=1/0);break}const g=this.maxSize,p=this.minSize;c>g.width&&p.widthg.height&&p.heightu.height||this.xi>u.width)&&(r=!0)}}}r?this.l|=256:this.l&=-257,this.Fi.isReal()||Util.n("Non-real actualBounds has been set. Object "+this+", actualBounds: "+this.Fi.toString()),this.hd(o,this.Fi),this.oo(!1),Rect.o(o)}dh(t,i,e,s){}commonArrange(t,i,e,s){if(this.Fi.e(t,i,e,s),this.desiredSize.isReal())return;const n=this.he,o=this.el,r=o.right+o.left,l=o.top+o.bottom,h=n.width+r,a=n.height+l;e+=r,s+=l;let f=this.qs(!0);switch(h===e&&a===s&&(f=0),f){case 0:(h>e||a>s)&&(this.ye(!0),this.wt(h>e?e:h,a>s?s:a,0,0));break;case 2:this.ye(!0),this.wt(e,s,0,0);break;case 5:this.ye(!0),this.wt(e,a,0,0);break;case 4:this.ye(!0),this.wt(h,s,0,0);break}}hd(t,i){const e=this.part;e!==null&&e.diagram!==null&&((e.selectionObject===this||e.resizeObject===this||e.rotateObject===this)&&e.d2(!0),this.T(),!t.equalsApproxClose(i)&&(e.gh(),this.A0(e)))}A0(t){this.portId!==null&&(t.d2(!0),t instanceof Node&&t.hL(this))}get shadowVisible(){return this.g!==null?this.g.L0:null}set shadowVisible(t){const i=this.shadowVisible;i!==t&&(Debug&&t!==null&&Util.t(t,"boolean",GraphObject,"shadowVisible"),this.Zt(),this.g.L0=t,this.hs(!0),this.T(),this.i("shadowVisible",i,t))}DR(t,i){const e=this.naturalBounds,s=this.ah,n=s.m11,o=s.m21,r=s.dx,l=s.m12,h=s.m22,a=s.dy;let f=0,c=0,u=f,d=c;f=u*n+d*o+r,c=u*l+d*h+a;let m=f,g=c,p=0,y=0;u=e.width+i,d=0,f=u*n+d*o+r,c=u*l+d*h+a;let x=Math.min(m,f),k=Math.min(g,c);p=Math.max(m+p,f)-x,y=Math.max(g+y,c)-k,m=x,g=k,u=e.width+i,d=e.height+i,f=u*n+d*o+r,c=u*l+d*h+a,x=Math.min(m,f),k=Math.min(g,c),p=Math.max(m+p,f)-x,y=Math.max(g+y,c)-k,m=x,g=k,u=0,d=e.height+i,f=u*n+d*o+r,c=u*l+d*h+a,x=Math.min(m,f),k=Math.min(g,c),p=Math.max(m+p,f)-x,y=Math.max(g+y,c)-k,m=x,g=k;const b=t.viewportBounds,S=b.x,M=b.y,A=b.width,C=b.height;return m>A+S||S>p+m||g>C+M||M>y+g}Ji(t,i){if(this.FR(t,i)||!this.visible)return;const e=this.opacity;if(e===0)return;let s=1;e!==1&&(s=t.globalAlpha,t.globalAlpha=s*e);let n="";this.filter!==""&&(n=t.filter,t.filter=this.filter);const o=this.O,r=this.panel;this.P0()===!0&&this.G1();const l=this.part;let h=!1,a=0;if(l&&i.getRenderingHint("drawShadows")&&(h=l.isShadowed,h)){const g=l.shadowOffset;a=Math.max(g.y,g.x)*i.scale*i.Gi}const f=this instanceof Panel&&this.nl(),c=this.Fi;if(f&&(this.aL(h,t,!1,r),this.RR(t,i),this.fL(h,t,!1,r),this.cL(h,t,!1)),f||!f&&(c.width===0||c.height===0||isNaN(c.x)||isNaN(c.y))){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}const u=this.js();if(!i.ea&&u&&this.DR(i,a)){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}let d=(this.l&256)!==0;if(t.clipInsteadOfFill&&(d=!1),this instanceof TextBlock&&(t.font=this.font),d){const g=r.kn()?r.naturalBounds:r.actualBounds;let p=Math.max(c.x,g.x),y=Math.max(c.y,g.y),x=Math.min(c.right,g.right)-p,k=Math.min(c.bottom,g.bottom)-y;const b=this.hi;if(b!==null&&(p=b.x,y=b.y,x=b.width,k=b.height),p>c.width+c.x||c.x>g.width+g.x){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}t.save(),t.beginPath(),t.rect(p,y,x,k),t.clip()}if(u){if(!l.isVisible()){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}if(h){const g=l.shadowOffset;t.shadowsSet(g.x*i.scale*this.scale*i.Gi,g.y*i.scale*this.scale*i.Gi,l.shadowBlur),t.shadowsOn(),t.shadowColor=l.shadowColor}}const m=this.naturalBounds;if(t.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.aL(h,t,u,r),this.Ft!==null&&(t.commitTransform(),this.H1(t,m,c)),this.fL(h,t,u,r),this.mh(t,i),this.cL(h,t,u),d&&(t.restore(),t.clearContextCache(this instanceof Panel)),!o.Gk()){const g=1/(o.m11*o.m22-o.m12*o.m21);t.transform(o.m22*g,-o.m12*g,-o.m21*g,o.m11*g,g*(o.m21*o.dy-o.m22*o.dx),g*(o.m12*o.dx-o.m11*o.dy))}e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n)}aL(t,i,e,s){t&&this.shadowVisible===!0?i.shadowsOn():t&&this.shadowVisible===!1&&i.shadowsOff(),t&&this.q1(s)&&this.shadowVisible===null&&i.shadowsOff()}fL(t,i,e,s){t&&(this.Ft!==null||this.q1(s))?(this.j1(!0),this.shadowVisible===null&&i.shadowsOff()):this.j1(!1)}cL(t,i,e){t&&this.g2()===!0&&i.shadowsOn(),e&&t&&i.shadowsOff()}IR(t,i,e){const s=this.part;let n=!1;s&&t.getRenderingHint("drawShadows")&&(n=s.isShadowed),i.clipInsteadOfFill&&(n=!1),this.js()&&n&&i.shadowsOn(),n&&this.shadowVisible===!0?i.shadowsOn():n&&this.shadowVisible===!1&&i.shadowsOff();const o=this.panel;if(n&&this.q1(o)&&this.shadowVisible===null&&i.shadowsOff(),i.ol){const r=t.computePixelRatio(),l=`drop-shadow(${i.shadowOffsetX/r}px ${i.shadowOffsetY/r}px ${i.shadowBlur/r/2}px ${i.shadowColor})`;this.background!==null&&e.Ft.setAttributeNS(null,"filter",l)}return n&&(this.Ft!==null||this.q1(o))?(this.j1(!0),this.shadowVisible===null&&i.shadowsOff()):this.j1(!1),n}OR(t,i,e,s){if(e.ol){const n=i.computePixelRatio(),o=`drop-shadow(${e.shadowOffsetX/n}px ${e.shadowOffsetY/n}px ${e.shadowBlur/n/2}px ${e.shadowColor})`;this.m2(t,o)}s&&this.g2()===!0&&e.shadowsOn(),this.js()&&e.shadowsOff()}q1(t){return t===null?!1:(t.nl()&&(t=t.panel),t.g2()||(t.type===Panel.Auto||t.type===Panel.Spot)&&t.findMainElement()!==this)}m2(t,i){}H1(t,i,e){const s=this.N0(),n=i.x,o=i.y,r=i.width+s,l=i.height+s;this.wn(t,this.Ft,!0,!1,i,e),this.Ft instanceof Brush&&this.Ft.type===3?(t.beginPath(),t.rect(n-s/2,o-s/2,r,l),t.fillContext(this.Ft,!1,null)):t.fillRect(n-s/2,o-s/2,r,l)}uL(t,i){let e=t.ER(this);const s=t.fh!==null?t.fh:t.svg;if(e!==-1)if(e===0)if(s.Ft)s.Ft.after(i);else if(t.type===Panel.Table){const n=s.getElementsByClassName("gojs-ts"),o=n.length!==0?n[0]:null;o!==null&&o.after(i)}else s.prepend(i);else{for(;e!==0&&!t.elt(e-1).isVisibleObject();)e--;if(e===0)s.prepend(i);else{const n=t.elt(e-1).svg;n!==null?n.after(i):s.appendChild(i)}}}FR(t,i){if(!(t instanceof SVGContext))return!1;if(!this.visible||this.opacity===0)return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;if(this.js()&&!this.isVisible())return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;const e=this.panel,s=this.ad(t);if(this.oc(t,i,s))return this.dL(this.svg),this.svg.parentElement!==null?(this.js()&&(t.lastDrawnPart=this.svg),!0):(this.js()?(t.lastDrawnPart!==null?t.lastDrawnPart.after(this.svg):t.diagramGroup.prepend(this.svg),t.lastDrawnPart=this.svg):e&&this.uL(e,this.svg),!0);if(this.js()&&this.isShadowed){const m=this.shadowOffset;t.shadowsSet(m.x*i.scale*this.scale*i.Gi,m.y*i.scale*this.scale*i.Gi,this.shadowBlur),t.shadowsOn(),t.shadowColor=this.shadowColor}this instanceof TextBlock&&(t.font=this.font),t.currentElement=null;const n=this.O,o=this instanceof Panel,r=this instanceof Panel?this.nl():!1,l=this.svg;this.P0()===!0&&this.G1();const h=this.Fi;if(t.setCurrentTransform(1,0,0,1,0,0),t.outerGroup=!1,s)if(t.outerGroup=!0,o&&r)t.newGroup(1,0,0,1,0,0),this.svg=t.lastCreatedElement;else if(o&&this.isClipping){const m=this.findMainElement();let g=0,p=0;m!==null&&(g=m.actualBounds.x,p=m.actualBounds.y),t.newGroup(n.m11,n.m12,n.m21,n.m22,n.dx+g,n.dy+p),this.svg=t.lastCreatedElement,m!==null&&t.createOrUpdateClipGroup(this,m.actualBounds),t.currentElement=t.lastCreatedElement}else o?(t.newGroup(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.svg=t.lastCreatedElement):t.newGroup(1,0,0,1,0,0);const a=this.naturalBounds;o||t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.background!==null&&(o?(r&&t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.H1(t,a,h),r&&t.setCurrentTransform(1,0,0,1,0,0)):(t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.H1(t,a,h)),t.currentElement.Ft=t.lastCreatedElement,t.currentElement.prepend(t.lastCreatedElement));const f=this.IR(i,t,t.currentElement);this.mh(t,i),o&&t.endGroup(),t.outerGroup&&t.endGroup();const c=t.surface.$u,u=o?this.svg:t.currentElement;if(!o&&l!==null&&u!==l&&l.parentNode===this.panel.svg){const m=this.svg.getAttribute("filter");return m!==null&&u.setAttribute("filter",m),this.svg.replaceWith(u),this.svg=u,u!==null&&this.T0(t,e,h,u),t.gL(l),!0}if(this.svg=u,c!==null&&u===null&&t.dummyGroup(),u===null)return!0;this.T0(t,e,h,u),this.OR(u,i,t,f);const d=this.js()?this.opacity*t.globalAlpha:this.opacity;if(d!==1&&u.setAttributeNS(null,"opacity",d.toString()),this.filter!==""&&u.setAttributeNS(null,"filter",this.filter),this.js()){if(l!==null&&u!==l&&l.parentNode===t.diagramGroup){const m=l.getAttribute("filter");m!==null&&u.setAttribute("filter",m),l.replaceWith(u)}else t.lastDrawnPart?t.lastDrawnPart.after(u):t.diagramGroup.prepend(u);t.lastDrawnPart=u}else e!==null&&this.uL(e,u);return c!==null&&c(this,u),this.dL(u),!0}dL(t){const i=this,e=t.dataset;i instanceof GraphObject&&(i.portId!==null&&(e.portId=i.portId),i instanceof Panel&&(isNaN(i.itemIndex)||(e.itemIndex=i.itemIndex.toString()),i instanceof Part&&(e.className=Util.hn(i),i.key!==void 0&&(e.key=i.key.toString()),i.containingGroup!==null&&(e.group=i.containingGroup.key.toString()),i instanceof Link&&(i.fromNode!==null&&i.fromNode.key!==void 0&&(e.fromKey=i.fromNode.key.toString()),i.fromPortId!==""&&(e.fromPortId=i.fromPortId),i.toNode!==null&&i.toNode.key!==void 0&&(e.toKey=i.toNode.key.toString()),i.toPortId!==""&&(e.toPortId=i.toPortId)))))}T0(t,i,e,s){let n=(this.l&256)!==0;if(t.clipInsteadOfFill&&(n=!1),!n){s.removeAttributeNS(null,"clip-path"),t.gL(s);return}const o=i.kn()?i.naturalBounds:i.actualBounds;let r=Math.max(e.x,o.x),l=Math.max(e.y,o.y),h=Math.min(e.right,o.right)-r,a=Math.min(e.bottom,o.bottom)-l;const f=this.hi;f!==null&&(r=f.x,l=f.y,h=f.width,a=f.height);const c=t.BR(s);if(c===null){const u="CLIP"+GSet.fu++,d={id:u},m=t.makeElement("clipPath",d),g=t.makeElement("rect",{x:r,y:l,width:h,height:a});if(this instanceof Panel){const p=this.O.copy().Pw();g.setAttribute("transform",`matrix(${p.m11}, ${p.m12}, ${p.m21}, ${p.m22}, ${p.dx}, ${p.dy})`)}m.appendChild(g),t.svg.appendChild(m),s.setAttributeNS(null,"clip-path","url(#"+u+")")}else{const u=c.firstElementChild;u.setAttribute("x",r.toString()),u.setAttribute("y",l.toString()),u.setAttribute("width",h.toString()),u.setAttribute("height",a.toString())}}VR(){if(this.svg===null)return;const t=this.svg.innerHTML.match(/url\(#((CLIP|GRAD).+?)\)/g),i=this.svg.ownerDocument;if(t!==null)for(const e of t){const s=i.getElementById(e.split("#")[1].slice(0,-1));s!==null&&s.remove()}this.svg.remove()}RR(t,i){const e=this.Fi,s=this.Hi,n=this.Ft;n!==null&&t.commitTransform(),n!==null&&(this.wn(t,n,!0,!1,s,e),n instanceof Brush&&n.type===3?(t.beginPath(),t.rect(e.x,e.y,e.width,e.height),t.fillContext(n,!1,null)):t.fillRect(e.x,e.y,e.width,e.height)),this.mh(t,i)}mh(t,i){}D0(){this.hs(!0)}oc(t,i,e){const s=this.svg;if(this.zR()){if(this.D0(),this.hs(!1),s===null)return!1;const f=this.svg.getAttribute("clip-path");if(f!==null&&f.includes("url")){const c=t.svg.getElementById(f.split("#")[1].slice(0,-1));c!==null&&c.remove()}return!1}if(s===null)return!1;if(!this.visible)return s.remove(),!1;if(s.nodeName!=="g"&&e||s.nodeName==="g"&&!e)return!1;const n=this.O,o="matrix("+n.m11+", "+n.m12+", "+n.m21+", "+n.m22+", "+n.dx+", "+n.dy+")",r=this instanceof Panel,l=r?this.nl():!1;if(!(r&&l))if(this instanceof Picture){const f=this.W1;t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),f!==null&&t.amendImageTransform(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7]),e?s.lastElementChild.setAttributeNS(null,"transform",t.getCurrentTransform()):s.setAttributeNS(null,"transform",t.getCurrentTransform())}else if(e&&!r)if(this instanceof Shape){const f=s.getElementsByTagName("path");for(let c=0;c=.1;){if(g){for(l=o[d++%h],l-=r;l<0;)l+=o[d++%h],m=!m;g=!1}else l=o[d++%h];l>u&&(l=u);let p=Math.sqrt(l*l/(1+c*c));a<0&&(p=-p),i+=p,e+=c*p,m?t.lineTo(i,e):t.moveTo(i,e),u-=l,m=!m}}wn(t,i,e,s,n,o){let r=1,l=1;if(typeof i=="string"){e?t.fillStyle=i:t.strokeStyle=i;return}else if(i.type===1){e?t.fillStyle=i.color:t.strokeStyle=i.color;return}let h;const a=this.N0();r=n.width,l=n.height,s?(r=o.width,l=o.height):e||(r+=a,l+=a);const f=t instanceof CanvasSurfaceContext;if(f&&i.Sn&&(i.type===4||i.rc===r&&i.v1===l))h=i.Sn;else{let c=0,u=0,d=0,m=0,g=0,p=0,y=0,x=0;if(s?(y=o.x,x=o.y):e||(y-=a/2,x-=a/2),c=i.start.x*r+i.start.offsetX+y,u=i.start.y*l+i.start.offsetY+x,d=i.end.x*r+i.end.offsetX+y,m=i.end.y*l+i.end.offsetY+x,i.type===2)h=t.createLinearGradient(c,u,d,m);else if(i.type===3)p=isNaN(i.endRadius)?Math.max(r,l)/2:i.endRadius,isNaN(i.startRadius)?(g=0,p=Math.max(r,l)/2):g=i.startRadius,h=t.createRadialGradient(c,u,g,d,m,p);else if(i.type===4)try{h=t.createPattern(i.pattern,"repeat")}catch{h=null}else Util.Bi(i.type,"Brush type");if(i.type!==4){const k=i.colorStops;if(k!==null){const b=k.iterator;for(;b.next();)h.addColorStop(b.key,b.value)}}if(f&&(i.Sn=h,h!==null&&(i.rc=r,i.v1=l),h===null&&i.type===4&&i.rc!==-1)){i.rc=-1;const k=this.diagram;k!==null&&i.rc===-1&&Util.zh(()=>{k.redraw()},600)}}e?t.fillStyle=h:t.strokeStyle=h}isContainedBy(t){return t instanceof Panel?this.XR(this,t):!1}XR(t,i){if(t===i||i===null)return!1;let e=t.panel;for(;e!==null;){if(e===i)return!0;e=e.panel}return!1}isVisibleObject(){if(!this.visible)return!1;const t=this.panel;return t!==null?t.isVisibleObject():!0}isEnabledObject(){let t=this instanceof Panel?this:this.panel;for(;t!==null&&t.isEnabled;)t=t.panel;return t===null}get enabledChanged(){return this.g!==null?this.g.F0:null}set enabledChanged(t){const i=this.enabledChanged;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"enabledChanged"),this.Zt(),this.g.F0=t,this.i("enabledChanged",i,t))}G1(){if(this.J1()===!0){const t=this.il;if(t.Vi(),!this.Fi.isReal()||!this.he.isReal()){this.fd(!1);return}if(t.Es(this.Fi.x-this.he.x,this.Fi.y-this.he.y),this.scale!==1||this.angle!==0){const i=this.naturalBounds;this.M0(t,i.x,i.y,i.width,i.height)}this.fd(!1),this.Ma(!0)}if(this.P0()===!0){const t=this.panel;if(t===null)this.ah.set(this.il),this.ma=this.scale;else if(t.Ks!==null){const i=this.ah;i.Vi(),t.kn()?i.af(t.ah):t.panel!==null&&i.af(t.panel.ah),i.af(this.il),this.ma=this.scale*t.ma}this.Ma(!1)}}M0(t,i,e,s,n){if(this.rt!==1&&t.rt(this.rt),this.jt===0)return;const o=Point.a();o.setSpot(i,e,s,n,Spot.Center),t.ms(this.jt,o.x,o.y),Point.o(o)}u(t){if(this.Xo())return;t===void 0&&(t=!1),this.ye(!0),this.oo(!0);const i=this.panel;i!==null&&!t&&i.u()}lc(){this.Xo()||(this.ye(!0),this.oo(!0))}hc(t){if(this.rs())return;const i=this.panel;!t&&i!==null&&i.u(),this.oo(!0)}ld(){this.J1()===!1&&(this.fd(!0),this.Ma(!0))}p2(){this.Ma(!0)}T(){const t=this.part;t!==null&&t.T()}qs(t){const i=this.stretch,e=this.panel;if(e===null)return this.qo(i===1?0:i,t);if(e.type===Panel.Table)return this.R0(e.getRowDefinition(this.row),e.getColumnDefinition(this.column),t);if(e.type===Panel.Auto&&e.findMainElement()===this)return this.qo(2,t);if(i===1){if(e.type===Panel.Spot&&e.findMainElement()===this)return this.qo(2,t);const s=e.defaultStretch;return s===1?this.qo(0,t):this.qo(s,t)}return this.qo(i,t)}R0(t,i,e){const s=this.stretch;if(s!==1)return this.qo(s,e);let n=null,o=null;switch(t.stretch){case 1:case 5:break;case 4:o=!0;break;case 2:o=!0;break}switch(i.stretch){case 1:case 4:break;case 5:n=!0;break;case 2:n=!0;break}const r=this.panel.defaultStretch;return n===null&&(n=r===5||r===2),o===null&&(o=r===4||r===2),n===!0&&o===!0?this.qo(2,e):n===!0?this.qo(5,e):o===!0?this.qo(4,e):this.qo(0,e)}qo(t,i){if(i)return t;if(t===0)return 0;const e=this.desiredSize;if(e.isReal())return 0;const s=!isNaN(e.width),n=!isNaN(e.height),o=this.angle;if(s)if(o!==90&&o!==270){if(t===5)return 0;if(t===2)return 4}else{if(t===4)return 0;if(t===2)return 5}if(n)if(o!==90&&o!==270){if(t===4)return 0;if(t===2)return 5}else{if(t===5)return 0;if(t===2)return 4}return t}get segmentOrientation(){return this.Ut!==null?this.Ut.I0:0}set segmentOrientation(t){const i=this.segmentOrientation;i!==t&&(Debug&&Util.tt(t,Orientation,"Orientation"),this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.I0=t,this.u(),this.i("segmentOrientation",i,t),t===0&&(this.angle=0))}YR(){this.segmentOrientation=21}get segmentIndex(){return this.Ut!==null?this.Ut.O0:-1/0}set segmentIndex(t){Debug&&Util.t(t,"number",GraphObject,"segmentIndex"),t=Math.round(t);const i=this.segmentIndex;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.O0=t,this.u(),this.i("segmentIndex",i,t))}get segmentFraction(){return this.Ut!==null?this.Ut.E0:0}set segmentFraction(t){Debug&&Util.t(t,"number",GraphObject,"segmentFraction"),isNaN(t)||t<0?t=0:t>1&&(t=1);const i=this.segmentFraction;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.E0=t,this.u(),this.i("segmentFraction",i,t))}get segmentOffset(){return this.Ut!==null?this.Ut.B0:Point.Lo}set segmentOffset(t){const i=this.segmentOffset;i.equals(t)||(Debug&&Util.s(t,Point,GraphObject,"segmentOffset"),t=t.L(),this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.B0=t,this.u(),this.i("segmentOffset",i,t))}get stretch(){return this.g!==null?this.g.ro:1}set stretch(t){const i=this.stretch;i!==t&&(this.Zt(),this.g.ro=t,this.u(),this.i("stretch",i,t))}get name(){return this.g!==null?this.g.Tt:""}set name(t){const i=this.name;i!==t&&(Debug&&Util.t(t,"string",GraphObject,"name"),this.Zt(),this.g.Tt=t,this.part!==null&&this.part.V0(),this.i("name",i,t))}get opacity(){return this._t}set opacity(t){const i=this._t;if(i!==t){Util.t(t,"number",GraphObject,"opacity"),(t<0||t>1)&&Util.G(t,"0 <= value <= 1",GraphObject,"opacity"),this._t=t,this.i("opacity",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.T(s.Zh(s.actualBounds))}}get filter(){return this.ed}set filter(t){Debug&&Util.t(t,"string",GraphObject,"filter");const i=this.ed;if(i!==t){this.ed=t,this.hs(!0),this.i("filter",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.T(s.Zh(s.actualBounds))}}get visible(){return(this.l&1)!==0}set visible(t){const i=(this.l&1)!==0;if(i!==t){Debug&&Util.t(t,"boolean",GraphObject,"visible"),this.l=this.l^1,this.i("visible",i,t);const e=this.panel;e!==null?e.u():this.js()&&this.Ki(t),this.T(),this.mL()}}get pickable(){return(this.l&2)!==0}set pickable(t){const i=(this.l&2)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"pickable"),this.l=this.l^2,this.i("pickable",i,t))}get fromLinkableDuplicates(){return(this.l&4)!==0}set fromLinkableDuplicates(t){const i=(this.l&4)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"fromLinkableDuplicates"),this.l=this.l^4,this.i("fromLinkableDuplicates",i,t))}get fromLinkableSelfNode(){return(this.l&8)!==0}set fromLinkableSelfNode(t){const i=(this.l&8)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"fromLinkableSelfNode"),this.l=this.l^8,this.i("fromLinkableSelfNode",i,t))}get toLinkableDuplicates(){return(this.l&16)!==0}set toLinkableDuplicates(t){const i=(this.l&16)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"toLinkableDuplicates"),this.l=this.l^16,this.i("toLinkableDuplicates",i,t))}get toLinkableSelfNode(){return(this.l&32)!==0}set toLinkableSelfNode(t){const i=(this.l&32)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"toLinkableSelfNode"),this.l=this.l^32,this.i("toLinkableSelfNode",i,t))}get isPanelMain(){return(this.l&64)!==0}set isPanelMain(t){const i=(this.l&64)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"isPanelMain"),this.l=this.l^64,this.u(),this.i("isPanelMain",i,t))}get isActionable(){return(this.l&128)!==0}set isActionable(t){const i=(this.l&128)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"isActionable"),this.l=this.l^128,this.i("isActionable",i,t))}get background(){return this.Ft}set background(t){const i=this.Ft;i!==t&&(t!==null&&Brush.cd(t,"GraphObject.background"),t instanceof Brush&&t.w(),this.Ft=t,this.T(),this.i("background",i,t))}g2(){return(this.l&512)!==0}j1(t){t?this.l|=512:this.l&=-513}sc(){return(this.l&1024)!==0}w2(t){t?this.l|=1024:this.l&=-1025}J1(){return(this.l&2048)!==0}fd(t){t?this.l|=2048:this.l&=-2049}P0(){return(this.l&4096)!==0}Ma(t){t?this.l|=4096:this.l&=-4097}Xo(){return(this.l&8192)!==0}ye(t){t?this.l|=8192:this.l&=-8193}rs(){return(this.l&16384)!==0}oo(t){t?this.l|=16384:this.l&=-16385}zR(){return(this.l&32768)!==0}hs(t){t?this.l|=32768:this.l&=-32769}get part(){if(this.js())return this;if(this.sl!==null)return this.sl;let t=this;for(t=t.panel;t;){if(t instanceof Part)return this.sl=t,t;t=t.panel}return null}get svg(){return this.U1}set svg(t){this.U1=t}Vu(){this.svg=null}get panel(){return this.Hs}Pa(t){this.Hs=t,this.svg!==null&&this.svg.remove()}get layer(){const t=this.part;return t!==null?t.layer:null}get diagram(){const t=this.part;return t!==null?t.diagram:null}get position(){return this.gt}set position(t){Debug&&Util.s(t,Point,GraphObject,"position");const i=t.x,e=t.y,s=this.gt,n=s.x,o=s.y;n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e))?(t=t.copy(),this.b2(t,n,o)&&this.i("position",new Point(n,o),t)):this.k2()}k2(){}b2(t,i,e){return this.gt=t,this.hc(),!0}Lf(t,i,e){this.gt.x===t&&this.gt.y===i||(this.gt.e(t,i),this.ld())}get actualBounds(){return this.Fi}get scale(){return this.rt}set scale(t){const i=this.rt;i!==t&&(Debug&&Util.r(t,GraphObject,"scale"),t<=0&&Util.n("GraphObject.scale for "+this+" must be greater than zero, not: "+t),this.rt=t,this.u(),this.i("scale",i,t))}get angle(){return this.jt}set angle(t){const i=this.jt;if(i!==t){if(Debug&&Util.r(t,GraphObject,"angle"),t=t%360,t<0&&(t+=360),i===t)return;this.jt=t,this.mL(),this.u(),this.i("angle",i,t)}}get desiredSize(){return this.qe}set desiredSize(t){Debug&&Util.s(t,Size,GraphObject,"desiredSize");const i=t.width,e=t.height,s=this.qe,n=s.width,o=s.height;if((n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e)))&&(t=t.L(),this.qe=t,this.u(),this instanceof Shape&&this.le(),this.i("desiredSize",s,t),this.sc())){const r=this.part;r!==null&&(this.Sa(r,"width"),this.Sa(r,"height"))}}get width(){return this.qe.width}set width(t){const i=this.qe.width;if(i!==t&&(!isNaN(i)||!isNaN(t))){Debug&&Util.t(t,"number",GraphObject,"width");const e=this.qe,s=new Size(t,this.qe.height).w();if(this.qe=s,this.u(),this instanceof Shape&&this.le(),this.i("desiredSize",e,s),this.sc()){const n=this.part;n!==null&&this.Sa(n,"width")}}}get height(){return this.qe.height}set height(t){const i=this.qe.height;if(i!==t&&(!isNaN(i)||!isNaN(t))){Debug&&Util.t(t,"number",GraphObject,"height");const e=this.qe,s=new Size(this.qe.width,t).w();if(this.qe=s,this.u(),this instanceof Shape&&this.le(),this.i("desiredSize",e,s),this.sc()){const n=this.part;n!==null&&this.Sa(n,"height")}}}get minSize(){return this.g!==null?this.g.Pr:Size.hf}set minSize(t){const i=this.minSize;i.equals(t)||(Debug&&Util.s(t,Size,GraphObject,"minSize"),t=t.copy(),isNaN(t.width)&&(t.width=0),isNaN(t.height)&&(t.height=0),t.w(),this.Zt(),this.g.Pr=t,this.u(),this.i("minSize",i,t))}get maxSize(){return this.g!==null?this.g.Nr:Size.Xk}set maxSize(t){const i=this.maxSize;i.equals(t)||(Debug&&Util.s(t,Size,GraphObject,"maxSize"),t=t.copy(),isNaN(t.width)&&(t.width=1/0),isNaN(t.height)&&(t.height=1/0),t.w(),this.Zt(),this.g.Nr=t,this.u(),this.i("maxSize",i,t))}get measuredBounds(){return this.he}get naturalBounds(){return this.Hi}N0(){return 0}get margin(){return this.el}set margin(t){typeof t=="number"?t=new Margin(t):Debug&&Util.s(t,Margin,GraphObject,"margin");const i=this.el;i.equals(t)||(t=t.L(),this.el=t,this.u(),this.i("margin",i,t))}get O(){return this.J1()===!0&&this.G1(),this.il}get Ks(){return this.P0()===!0&&this.G1(),this.ah}trigger(t,i,e){let s=null;return typeof t=="string"?s=new AnimationTrigger(t,i,e):s=t,s.Ce=this,this.Ss===null&&(this.Ss=new GMap),this.Ss.set(s.propertyName,s),this}get Ss(){return this.g!==null?this.g.Ss:null}set Ss(t){this.Ss!==t&&(this.Zt(),this.g.Ss=t)}get Mr(){return this.g!==null?this.g.Mr:0}set Mr(t){this.Mr!==t&&(this.Zt(),this.g.Mr=t)}get alignment(){return this.ai}set alignment(t){const i=this.ai;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"alignment"),t.isNoSpot()&&!t.isDefault()&&Util.n("GraphObject.alignment for "+this+" must be a real Spot or Spot.Default, not: "+t),t=t.L(),this.ai=t,this.hc(),this.i("alignment",i,t))}get column(){return this.Go}set column(t){Debug&&Util.r(t,GraphObject,"column"),t=Math.round(t);const i=this.Go;i!==t&&(t<0&&Util.G(t,">= 0",GraphObject,"column"),this.Go=t,this.u(),this.i("column",i,t),this.svg!==null&&this.svg.remove())}get columnSpan(){return this.g!==null?this.g.z0:1}set columnSpan(t){Debug&&Util.t(t,"number",GraphObject,"columnSpan"),t=Math.round(t);const i=this.columnSpan;i!==t&&(t<1&&Util.G(t,">= 1",GraphObject,"columnSpan"),this.Zt(),this.g.z0=t,this.u(),this.i("columnSpan",i,t))}get row(){return this.td}set row(t){Debug&&Util.r(t,GraphObject,"row"),t=Math.round(t);const i=this.td;i!==t&&(t<0&&Util.G(t,">= 0",GraphObject,"row"),this.td=t,this.u(),this.i("row",i,t),this.svg!==null&&this.svg.remove())}get rowSpan(){return this.g!==null?this.g.X0:1}set rowSpan(t){Debug&&Util.t(t,"number",GraphObject,"rowSpan"),t=Math.round(t);const i=this.rowSpan;i!==t&&(t<1&&Util.G(t,">= 1",GraphObject,"rowSpan"),this.Zt(),this.g.X0=t,this.u(),this.i("rowSpan",i,t))}get spanAllocation(){return this.g!==null?this.g.Y0:null}set spanAllocation(t){const i=this.spanAllocation;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"spanAllocation"),this.Zt(),this.g.Y0=t,this.u(),this.i("spanAllocation",i,t))}get alignmentFocus(){return this.ic}set alignmentFocus(t){const i=this.ic;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"alignmentFocus"),Debug&&t.isNoSpot()&&!t.isDefault()&&!(t.isNone()&&this instanceof Node)&&Util.n("GraphObject.alignmentFocus must be a real Spot or Spot.Default, not: "+t),t=t.L(),this.ic=t,this.u(),this.i("alignmentFocus",i,t))}get portId(){return this._u}set portId(t){const i=this._u;if(i!==t){Debug&&t!==null&&Util.t(t,"string",GraphObject,"portId");const e=this.part;e!==null&&!(e instanceof Node)&&Util.n("Cannot set portID on a Link: "+t);const s=e;i!==null&&s!==null&&s.S2(this),this._u=t,t!==null&&s!==null&&(s.Mn=!0,s.pL(this)),this.i("portId",i,t)}}Na(){const t=this.part;if(t instanceof Node&&(this.portId!==null||this===t.port)){const i=t.diagram;i!==null&&!i.undoManager.isUndoingRedoing&&t.hL(this)}}mL(){const t=this.diagram;t===null||t.undoManager.isUndoingRedoing||(this instanceof Panel?this instanceof Node?this.invalidateConnectedLinks():this.walkVisualTreeFrom(this,i=>{i.Na()}):this.Na())}get toSpot(){return this.Z!==null?this.Z.ya:Spot.None}set toSpot(t){const i=this.toSpot;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"toSpot"),t=t.L(),this.je(),this.Z.ya=t,this.i("toSpot",i,t),this.Na())}get toEndSegmentLength(){return this.Z!==null?this.Z.xa:10}set toEndSegmentLength(t){const i=this.toEndSegmentLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"toEndSegmentLength"),t<0&&Util.G(t,">= 0",GraphObject,"toEndSegmentLength"),this.je(),this.Z.xa=t,this.i("toEndSegmentLength",i,t),this.Na())}get toShortLength(){return this.Z!==null?this.Z.ka:0}set toShortLength(t){const i=this.toShortLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"toShortLength"),this.je(),this.Z.ka=t,this.i("toShortLength",i,t),this.Na())}get toLinkable(){return this.Z!==null?this.Z.K0:null}set toLinkable(t){const i=this.toLinkable;i!==t&&(Debug&&t!==null&&Util.t(t,"boolean",GraphObject,"toLinkable"),this.je(),this.Z.K0=t,this.i("toLinkable",i,t))}get toMaxLinks(){return this.Z!==null?this.Z.U0:1/0}set toMaxLinks(t){const i=this.toMaxLinks;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"toMaxLinks"),t<0&&Util.G(t,">= 0",GraphObject,"toMaxLinks"),this.je(),this.Z.U0=t,this.i("toMaxLinks",i,t))}get fromSpot(){return this.Z!==null?this.Z.pa:Spot.None}set fromSpot(t){const i=this.fromSpot;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"fromSpot"),t=t.L(),this.je(),this.Z.pa=t,this.i("fromSpot",i,t),this.Na())}get fromEndSegmentLength(){return this.Z!==null?this.Z.wa:10}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"fromEndSegmentLength"),t<0&&Util.G(t,">= 0",GraphObject,"fromEndSegmentLength"),this.je(),this.Z.wa=t,this.i("fromEndSegmentLength",i,t),this.Na())}get fromShortLength(){return this.Z!==null?this.Z.ba:0}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"fromShortLength"),this.je(),this.Z.ba=t,this.i("fromShortLength",i,t),this.Na())}get fromLinkable(){return this.Z!==null?this.Z.G0:null}set fromLinkable(t){const i=this.fromLinkable;i!==t&&(Debug&&t!==null&&Util.t(t,"boolean",GraphObject,"fromLinkable"),this.je(),this.Z.G0=t,this.i("fromLinkable",i,t))}get fromMaxLinks(){return this.Z!==null?this.Z.H0:1/0}set fromMaxLinks(t){const i=this.fromMaxLinks;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"fromMaxLinks"),t<0&&Util.G(t,">= 0",GraphObject,"fromMaxLinks"),this.je(),this.Z.H0=t,this.i("fromMaxLinks",i,t))}get cursor(){return this.g!==null?this.g.Al:""}set cursor(t){const i=this.cursor;i!==t&&(Util.t(t,"string",GraphObject,"cursor"),this.Zt(),this.g.Al=t,this.i("cursor",i,t))}get click(){return this.g!==null?this.g.Or:null}set click(t){const i=this.click;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"click"),this.Zt(),this.g.Or=t,this.i("click",i,t))}get doubleClick(){return this.g!==null?this.g.Er:null}set doubleClick(t){const i=this.doubleClick;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"doubleClick"),this.Zt(),this.g.Er=t,this.i("doubleClick",i,t))}get contextClick(){return this.g!==null?this.g.Br:null}set contextClick(t){const i=this.contextClick;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"contextClick"),this.Zt(),this.g.Br=t,this.i("contextClick",i,t))}get mouseEnter(){return this.g!==null?this.g.Kr:null}set mouseEnter(t){const i=this.mouseEnter;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseEnter"),this.Zt(),this.g.Kr=t,this.i("mouseEnter",i,t))}get mouseLeave(){return this.g!==null?this.g.Ur:null}set mouseLeave(t){const i=this.mouseLeave;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseLeave"),this.Zt(),this.g.Ur=t,this.i("mouseLeave",i,t))}get mouseOver(){return this.g!==null?this.g.Vr:null}set mouseOver(t){const i=this.mouseOver;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseOver"),this.Zt(),this.g.Vr=t,this.i("mouseOver",i,t))}get mouseHover(){return this.g!==null?this.g.zr:null}set mouseHover(t){const i=this.mouseHover;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseHover"),this.Zt(),this.g.zr=t,this.i("mouseHover",i,t))}get mouseHold(){return this.g!==null?this.g.Xr:null}set mouseHold(t){const i=this.mouseHold;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseHold"),this.Zt(),this.g.Xr=t,this.i("mouseHold",i,t))}get mouseDragEnter(){return this.g!==null?this.g.q0:null}set mouseDragEnter(t){const i=this.mouseDragEnter;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseDragEnter"),this.Zt(),this.g.q0=t,this.i("mouseDragEnter",i,t))}get mouseDragLeave(){return this.g!==null?this.g.j0:null}set mouseDragLeave(t){const i=this.mouseDragLeave;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseDragLeave"),this.Zt(),this.g.j0=t,this.i("mouseDragLeave",i,t))}get mouseDrop(){return this.g!==null?this.g.Yr:null}set mouseDrop(t){const i=this.mouseDrop;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseDrop"),this.Zt(),this.g.Yr=t,this.i("mouseDrop",i,t))}get actionDown(){return this.g!==null?this.g.W0:null}set actionDown(t){const i=this.actionDown;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionDown"),this.Zt(),this.g.W0=t,this.i("actionDown",i,t))}get actionMove(){return this.g!==null?this.g.v0:null}set actionMove(t){const i=this.actionMove;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionMove"),this.Zt(),this.g.v0=t,this.i("actionMove",i,t))}get actionUp(){return this.g!==null?this.g.J0:null}set actionUp(t){const i=this.actionUp;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionUp"),this.Zt(),this.g.J0=t,this.i("actionUp",i,t))}get actionCancel(){return this.g!==null?this.g.Z0:null}set actionCancel(t){const i=this.actionCancel;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionCancel"),this.Zt(),this.g.Z0=t,this.i("actionCancel",i,t))}get toolTip(){return this.g!==null?this.g.Gr:null}set toolTip(t){const i=this.toolTip;i!==t&&(Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("GraphObject.toolTip must be an Adornment or HTMLInfo."),this.Zt(),this.g.Gr=t,this.i("toolTip",i,t))}get contextMenu(){return this.g!==null?this.g.Hr:null}set contextMenu(t){const i=this.contextMenu;i!==t&&(Debug&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("GraphObject.contextMenu must be an Adornment or HTMLInfo."),this.Zt(),this.g.Hr=t,this.i("contextMenu",i,t))}findBindingPanel(){let t=this instanceof Panel?this:this.panel;for(;t!==null;){if(t.M2())return t;t=t.panel}return null}bind(t,i,e,s){return this.ac(t,i,e,s),this}bindTwoWay(t,i,e,s){return this.ac(t,i,e,s).makeTwoWay(),this}bindModel(t,i,e,s){return this.ac(t,i,e,s).ofModel(),this}bindObject(t,i,e,s,n){return this.ac(t,i,e,s).ofObject(n),this}theme(t,i,e,s,n){return this.ph(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.ph(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.ph(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.ph(t,i,e,s,n).ofModel(),this}ac(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.$0(n),n}ph(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.$0(o),o}$0(t){t.Ce=this;const i=this.findBindingPanel();i!==null&&i.yL()&&Util.n("Cannot add a Binding to a template that has already been copied: "+t),this.Ri===null&&(this.Ri=new List),this.Ri.add(t)}set(t){if(Debug)for(const i in t)(i.startsWith("_")||i.indexOf(".")!==-1)&&Util.n("Property with underscore or period passed to GraphObject.set. Did you mean to use GraphObject.attach?");return Object.assign(this,t),this}attach(t){return GraphObject.P2(this,t),this}apply(t){return t(this),this}setProperties(t){return Diagram.m0(this,t),this}static build(t,i,...e){const s=GraphObject.Q0.get(t);if(typeof s=="function"){const n=s([t].concat(e));if(n instanceof GraphObject)return i&&n.setProperties(i),n}Util.n('GraphObject.build invoked object builder "'+t+'", but it did not return an Object')}static make(t,...i){let e=arguments,s=null,n=null;if(typeof t=="function")n=t;else if(typeof t=="string"){const r=GraphObject.Q0.get(t);typeof r=="function"?(e=Array.prototype.slice.call(e),s=r(e),Util.Mt(s)||Util.n('GraphObject.make invoked object builder "'+t+'", but it did not return an Object')):n=root.go[t]}s===null&&((n==null||!n.constructor)&&Util.n("GraphObject.make requires a class function or GoJS class name or name of an object builder, not: "+t),s=new n);let o=1;if(s instanceof Diagram&&e.length>1){const r=s,l=e[1];(typeof l=="string"||l instanceof HTMLDivElement)&&(r.MP(l),o++)}for(let r=o;r{const i="#f5f5f5",e="#737373",s="#d4d4d4",n="#737373",o="#a3a3a3",r=2.76142374915397,l=2.761423749153969,h=new Panel(Panel.Auto,{isActionable:!0,enabledChanged:(a,f)=>{if(a instanceof Panel){const c=a.findObject("ButtonBorder");c!==null&&(f?(a._buttonFillDisabled=c.fill,c.fill=a._buttonFillNormal):(a._buttonFillNormal=c.fill,c.fill=a._buttonFillDisabled))}},cursor:"pointer"}).attach({_buttonFillNormal:i,_buttonStrokeNormal:e,_buttonFillOver:s,_buttonStrokeOver:n,_buttonFillDisabled:o}).add(new Shape("RoundedRectangle",{name:"ButtonBorder",spot1:new Spot(0,0,r,l),spot2:new Spot(1,1,-r,-l),parameter1:2,fill:i,stroke:e}));return h.mouseEnter=(a,f,c)=>{if(!f.isEnabledObject()||!(f instanceof Panel))return;const u=f.findObject("ButtonBorder");u instanceof Shape&&(f._buttonFillNormal=u.fill,u.fill=f._buttonFillOver,f._buttonStrokeNormal=u.stroke,u.stroke=f._buttonStrokeOver)},h.mouseLeave=(a,f,c)=>{if(!f.isEnabledObject()||!(f instanceof Panel))return;const u=f.findObject("ButtonBorder");u instanceof Shape&&(u.fill=f._buttonFillNormal,u.stroke=f._buttonStrokeNormal)},h}),GraphObject.defineBuilder("TreeExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_treeExpandedFigure:"MinusLine",_treeCollapsedFigure:"PlusLine",visible:!1}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.du}).bindObject("figure","isTreeExpanded",(e,s)=>{const n=s.panel;return e?n._treeExpandedFigure:n._treeCollapsedFigure})),i.bindObject("visible","isTreeLeaf",e=>!e),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Node))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isTreeExpanded){if(!r.canCollapseTree(n))return}else if(!r.canExpandTree(n))return;e.handled=!0,n.isTreeExpanded?r.collapseTree(n):r.expandTree(n)},i}),GraphObject.defineBuilder("SubGraphExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_subGraphExpandedFigure:"MinusLine",_subGraphCollapsedFigure:"PlusLine"}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.du}).bindObject("figure","isSubGraphExpanded",(e,s)=>{const n=s.panel;return e?n._subGraphExpandedFigure:n._subGraphCollapsedFigure})),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Group))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isSubGraphExpanded){if(!r.canCollapseSubGraph(n))return}else if(!r.canExpandSubGraph(n))return;e.handled=!0,n.isSubGraphExpanded?r.collapseSubGraph(n):r.expandSubGraph(n)},i}),GraphObject.defineBuilder("ToolTip",t=>new Adornment(Panel.Auto,{isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).add(new Shape("RoundedRectangle",{name:"Border",parameter1:1,fill:"#f5f5f5",strokeWidth:0,spot1:new Spot(0,0,4,6),spot2:new Spot(1,1,-4,-4)}))),GraphObject.defineBuilder("ContextMenu",t=>new Adornment(Panel.Vertical,{background:"#f5f5f5",isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).bindObject("background","",i=>i.adornedPart!==null&&i.hasPlaceholder()?null:"#f5f5f5")),GraphObject.defineBuilder("ContextMenuButton",t=>{const i=GraphObject.build("Button");i.stretch=5;const e=i.findObject("ButtonBorder");return e instanceof Shape&&(e.figure="Rectangle",e.strokeWidth=0,e.spot1=new Spot(0,0,4,6),e.spot2=new Spot(1,1,-4,-4)),i}),GraphObject.defineBuilder("PanelExpanderButton",t=>{const i=GraphObject.takeBuilderArgument(t,"COLLAPSIBLE"),e=GraphObject.build("Button");e.attach({_buttonExpandedFigure:"M0 0 M0 6 L4 2 8 6 M8 8",_buttonCollapsedFigure:"M0 0 M0 2 L4 6 8 2 M8 8",_buttonFillNormal:"rgba(0, 0, 0, 0)",_buttonStrokeNormal:null,_buttonFillOver:"rgba(0, 0, 0, .2)",_buttonStrokeOver:null}),e.add(new Shape({name:"ButtonIcon",strokeWidth:2}).bindObject("geometryString","visible",n=>n?e._buttonExpandedFigure:e._buttonCollapsedFigure,void 0,i));const s=e.findObject("ButtonBorder");return s instanceof Shape&&(s.stroke=null,s.fill="rgba(0, 0, 0, 0)"),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=o.diagram;if(r===null||r.isReadOnly)return;let l=o.findBindingPanel();if(l===null&&(l=o.part),l!==null){const h=l.findObject(i);h!==null&&(n.handled=!0,r.startTransaction("Collapse/Expand Panel"),h.visible=!h.visible,r.commitTransaction("Collapse/Expand Panel"))}},e}),GraphObject.defineBuilder("CheckBoxButton",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("Button",{desiredSize:new Size(14,14)});e.attach({"ButtonBorder.spot1":new Spot(0,0,1,1),"ButtonBorder.spot2":new Spot(1,1,-1,-1)});const s=new Shape({name:"ButtonIcon",geometryString:"M0 0 M0 8.85 L4.9 13.75 16.2 2.45 M16.2 16.2",strokeWidth:2,stretch:2,geometryStretch:6,visible:!1});return i!==""&&s.bindTwoWay("visible",i),e.add(s),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=n.diagram;if(r===null||r.isReadOnly||i!==""&&r.model.isReadOnly)return;n.handled=!0;const l=o.findObject("ButtonIcon");r.startTransaction("checkbox"),l!==null&&(l.visible=!l.visible),typeof o._doClick=="function"&&o._doClick(n,o),r.commitTransaction("checkbox")},e}),GraphObject.defineBuilder("CheckBox",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("CheckBoxButton",{name:"Button",isActionable:!1,margin:new Margin(0,1,0,0)},i),s=new Panel("Horizontal",{isActionable:!0,cursor:e.cursor,margin:new Margin(1),mouseEnter:e.mouseEnter,mouseLeave:e.mouseLeave,click:e.click}).attach({_buttonFillNormal:e._buttonFillNormal,_buttonStrokeNormal:e._buttonStrokeNormal,_buttonFillOver:e._buttonFillOver,_buttonStrokeOver:e._buttonStrokeOver,_buttonFillDisabled:e._buttonFillDisabled,_buttonClick:e.click});return s.add(e),e.mouseEnter=null,e.mouseLeave=null,e.click=null,s})}}class GraphObjectTemplateSettings{wi;Tt;eo;Ri;so;Ws;Al;Or;Er;Br;Kr;Ur;Vr;zr;Xr;q0;j0;Yr;W0;v0;J0;Z0;Gr;Hr;F0;Y0;Ss;Pr;Nr;ro;X0;z0;Mr;L0;_0;tp;constructor(){this.wi=!1,this.Tt="",this.eo=-1,this.Ri=null,this.so=null,this.Ws=null,this.Al="",this.Or=null,this.Er=null,this.Br=null,this.Kr=null,this.Ur=null,this.Vr=null,this.zr=null,this.Xr=null,this.q0=null,this.j0=null,this.Yr=null,this.W0=null,this.v0=null,this.J0=null,this.Z0=null,this.Gr=null,this.Hr=null,this.F0=null,this.Y0=null,this.Ss=null,this.Pr=Size.hf,this.Nr=Size.Xk,this.ro=1,this.X0=1,this.z0=1,this.Mr=0,this.L0=null,this._0=null,this.tp="category"}copy(){const t=new GraphObjectTemplateSettings;return t.Tt=this.Tt,t.eo=this.eo,t.Ri=this.Ri,t.Ws=this.Ws,t.Al=this.Al,t.Or=this.Or,t.Er=this.Er,t.Br=this.Br,t.Kr=this.Kr,t.Ur=this.Ur,t.Vr=this.Vr,t.zr=this.zr,t.Xr=this.Xr,t.q0=this.q0,t.j0=this.j0,t.Yr=this.Yr,t.W0=this.W0,t.v0=this.v0,t.J0=this.J0,t.Z0=this.Z0,t.Gr=this.Gr,t.Hr=this.Hr,t.F0=this.F0,t.Y0=this.Y0,t.Ss=this.Ss,t.Pr=this.Pr.L(),t.Nr=this.Nr.L(),t.ro=this.ro,t.X0=this.X0,t.z0=this.z0,t.Mr=this.Mr,t.L0=this.L0,t._0=this._0,t.tp=this.tp,t}}class STransform{m;constructor(){this.m=[1,0,0,1,0,0]}copy(){const t=new STransform;return t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5],t}translate(t,i){this.m[4]+=this.m[0]*t+this.m[2]*i,this.m[5]+=this.m[1]*t+this.m[3]*i}scale(t,i){this.m[0]*=t,this.m[1]*=t,this.m[2]*=i,this.m[3]*=i}rotate(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return;this.translate(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m[0]*s+this.m[2]*n,r=this.m[1]*s+this.m[3]*n,l=this.m[0]*-n+this.m[2]*s,h=this.m[1]*-n+this.m[3]*s;this.m[0]=o,this.m[1]=r,this.m[2]=l,this.m[3]=h,this.translate(-i,-e)}}class SGradient{type;x1;y1;r1;x2;y2;r2;colors;pattern;constructor(t){this.type=t,this.x1=0,this.y1=0,this.r1=0,this.x2=0,this.y2=0,this.r2=0,this.colors=[],this.pattern=null}addColorStop(t,i){this.colors.push({offset:t,color:i})}}class SVGSurface{Vt;di;da;$u;N2;constructor(t,i,e){const s=i===void 0?root.document:i;this.da=s,this.N2="http://www.w3.org/2000/svg";const n="http://www.w3.org/2000/xmlns/";s!==void 0&&(this.Vt=this.makeElement("svg",{width:"1px",height:"1px",viewBox:"0 0 1 1"}),this.style.display="block",this.style.letterSpacing="normal",this.style.wordSpacing="normal",e||(this.style.position="absolute"),this.Vt.setAttributeNS(n,"xmlns",this.N2),this.Vt.setAttributeNS(n,"xmlns:xlink","http://www.w3.org/1999/xlink")),this.$u=null,this.di=new SVGContext(this,e)}resize(t,i,e,s){return this.width!==t||this.height!==i?(this.width=t,this.height=i,this.style.width=e+"px",this.style.height=s+"px",this.Vt.setAttributeNS(null,"width",e+"px"),this.Vt.setAttributeNS(null,"height",s+"px"),this.Vt.setAttributeNS(null,"viewBox","0 0 "+e+" "+s),this.di.C2.firstElementChild.setAttributeNS(null,"width",e+"px"),this.di.C2.firstElementChild.setAttributeNS(null,"height",s+"px"),!0):!1}makeElement(t,i,e){const s=this.da.createElementNS(this.N2,t);if(Util.Mt(i))for(const n in i)s.setAttributeNS(n==="href"?"http://www.w3.org/1999/xlink":"",n,i[n]);return e!==void 0&&(s.textContent=e),s}getBoundingClientRect(){return this.Vt.getBoundingClientRect()}focus(){this.Vt.focus()}get width(){return this.Vt.width.baseVal.value}set width(t){this.Vt.setAttribute("width",t+"px")}get height(){return this.Vt.height.baseVal.value}set height(t){this.Vt.setAttribute("height",t+"px")}dispose(){this.da=null}get style(){return this.Vt.style}}class SVGContext{fc;cc;Pn;Ii;We;fillStyle;font;globalAlpha;lineCap;lineDashOffset;lineJoin;lineWidth;miterLimit;shadowBlur;shadowColor;shadowOffsetX;shadowOffsetY;strokeStyle;textAlign;imageSmoothingEnabled;clipInsteadOfFill;lastCreatedElement;uc;dc;surface;svg;C2;wL;$1;jo;yh;Ca;currentElement;clipPathGroup;diagramGroup;lastDrawnPart;currentPath;outerGroup;pathAttributes;ol;Tr;filter;partClipRect;constructor(t,i){this.surface=t,this.svg=t.Vt,this.uc=[],this.dc=[],this.fillStyle="#000000",this.font="10px sans-serif",this.globalAlpha=1,this.lineCap="butt",this.lineDashOffset=0,this.lineJoin="miter",this.lineWidth=1,this.miterLimit=10,this.shadowBlur=0,this.shadowColor="rgba(0, 0, 0, 0)",this.shadowOffsetX=0,this.shadowOffsetY=0,this.ol=!1,this.strokeStyle="#000000",this.textAlign="start",this.clipInsteadOfFill=!1,this.fc=0,this.cc=0,this.Pn=0,this.lastCreatedElement=null,this.currentElement=null,this.Ii=[],this.pathAttributes={},this.$1=!1,this.jo=null,this.yh=0,this.We=new STransform,this.clipPathGroup=this.newGroup2(),this.diagramGroup=this.newGroup2("gojs-diagram"),this.lastDrawnPart=null,this.currentPath=null;const e=GSet.fu++,s=this.makeElement("clipPath",{id:"mainClip"+e}),n={x:0,y:0,width:t.width,height:t.height};s.appendChild(this.makeElement("rect",n)),this.C2=s,this.svg.appendChild(this.clipPathGroup),this.clipPathGroup.appendChild(this.diagramGroup),this.svg.appendChild(s),this.clipPathGroup.setAttributeNS(null,"clip-path","url(#mainClip"+e+")"),this.wL={},this.Tr=!!i,this.filter="",this.partClipRect=null}setDiagramPosScale(t,i,e,s,n,o){this.diagramGroup===void 0?this.newGroup(t,i,e,s,n,o):this.diagramGroup.setAttribute("transform","matrix("+t+", "+i+", "+e+", "+s+", "+n+", "+o+")")}resetInnerSVG(){this.diagramGroup!==null&&(this.diagramGroup.innerHTML="")}arc(t,i,e,s,n,o,r,l){const h=2*Math.PI,a=1e-6,f=h-a,c=e*Math.cos(s),u=e*Math.sin(s),d=t+c,m=i+u,g=o?0:1;let p=o?s-n:n-s;(Math.abs(r-d)>a||Math.abs(l-m)>a)&&this.Ii.push(["L",d,+m]),p<0&&(p=p%h+h),p>f?(this.Ii.push(["A",e,e,0,1,g,t-c,i-u]),this.Ii.push(["A",e,e,0,1,g,d,m])):p>a&&this.Ii.push(["A",e,e,0,+(p>=Math.PI),g,t+e*Math.cos(n),i+e*Math.sin(n)])}beginPath(){this.Ii=[],this.pathAttributes={stroke:"none",fill:"none"}}endPath(t){this.HR(this.Ii,this.We,t||0)}bezierCurveTo(t,i,e,s,n,o){this.Ii.push(["C",t,i,e,s,n,o])}clearRect(t,i,e,s){}clip(){this.pathAttributes.clipPath=!0}closePath(){this.Ii.push(["z"])}createLinearGradient(t,i,e,s){const n=new SGradient("linear");return n.x1=t,n.y1=i,n.x2=e,n.y2=s,n}createPattern(t,i){let e="";t instanceof HTMLCanvasElement&&(e=t.toDataURL()),t instanceof HTMLImageElement&&(e=t.getAttribute("src"));const s=this.wL;if(s[e])return"url(#"+s[e]+")";const n="PATTERN"+GSet.fu++,o={width:t.width,height:t.height,id:n,patternUnits:"userSpaceOnUse"},r={x:0,y:0,width:t.width,height:t.height,href:e},l=this.makeElement("pattern",o);return l.appendChild(this.makeElement(Diagram.img,r)),this.svg.appendChild(l),s[e]=n,"url(#"+n+")"}createRadialGradient(t,i,e,s,n,o){const r=new SGradient("radial");return r.x1=t,r.y1=i,r.r1=e,r.x2=s,r.y2=n,r.r2=o,r}amendImageTransform(t,i,e,s,n,o,r,l){const h=r/e,a=l/s;(n!==0||o!==0)&&this.We.translate(n,o),(h!==1||a!==1)&&this.We.scale(h,a),(t!==0||i!==0)&&this.We.translate(-t,-i)}drawImage(t,i,e,s,n,o,r,l,h){let a="";t instanceof HTMLCanvasElement&&(a=t.toDataURL()),t instanceof HTMLImageElement&&(a=t.getAttribute("src"));const f=t instanceof HTMLImageElement?t.naturalWidth:t.width,c=t instanceof HTMLImageElement?t.naturalHeight:t.height;s===void 0&&(o=i,r=e,l=s=f,h=n=c),s=s||0,n=n||0,o=o||0,r=r||0,l=l||0,h=h||0,this.amendImageTransform(i,e,s,n,o,r,l,h);const u={x:0,y:0,width:f||s,height:c||n,href:a};!Geo.q(s,l)||!Geo.q(n,h)?u.preserveAspectRatio="none":a.toLowerCase().indexOf(".svg")===-1&&a.toLowerCase().indexOf("data:image/svg")===-1&&(u.preserveAspectRatio="xMidYMid slice"),(i!==0||e!==0||s!==f||n!==c)&&(s+=i,n+=e,u["clip-path"]=`path('M ${i},${e} L ${s} ${e} L ${s} ${n} L ${i} ${n} z')`),this.processCommon(Diagram.img,u,this.We),this.ud(Diagram.img,u)}fill(t,i){t&&(this.pathAttributes["fill-rule"]="evenodd"),this.setFill(this.pathAttributes)}fillContext(t,i,e){this.clipInsteadOfFill?this.clip():this.fill(i,e)}createOrUpdateClipGroup(t,i){const e=this.newGroup(1,0,0,1,-i.x,-i.y);e.setAttributeNS(null,"class","spotClip"),t.fh=e}fillRect(t,i,e,s){this.addRect("fill",[t,i,e,s],this.We)}fillBackground(t,i,e,s){const n={x:t,y:i,width:e,height:s};this.processCommon("fill",n,this.We),this.setFill(n),this.svg.prepend(this.makeElement("rect",n))}fillText(t,i,e){this.addText("fill",[t,i,e],this.We)}lineTo(t,i){this.Ii.push(["L",t,i])}moveTo(t,i){this.Ii.push(["M",t,i])}quadraticCurveTo(t,i,e,s){this.Ii.push(["Q",t,i,e,s])}rect(t,i,e,s){this.Ii.push(["M",t,i],["L",t+e,i],["L",t+e,i+s],["L",t,i+s],["z"])}restore(){this.We=this.uc.pop(),this.Ii=this.uc.pop();const t=this.uc.pop();this.fillStyle=t.fillStyle,this.font=t.font,this.globalAlpha=t.globalAlpha,this.lineCap=t.lineCap,this.lineDashOffset=t.lineDashOffset,this.lineJoin=t.lineJoin,this.lineWidth=t.lineWidth,this.miterLimit=t.miterLimit,this.shadowBlur=t.shadowBlur,this.shadowColor=t.shadowColor,this.shadowOffsetX=t.shadowOffsetX,this.shadowOffsetY=t.shadowOffsetY,this.strokeStyle=t.strokeStyle,this.textAlign=t.textAlign,this.partClipRect=t.partClipRect}save(){const t={fillStyle:this.fillStyle,font:this.font,globalAlpha:this.globalAlpha,lineCap:this.lineCap,lineDashOffset:this.lineDashOffset,lineJoin:this.lineJoin,lineWidth:this.lineWidth,miterLimit:this.miterLimit,shadowBlur:this.shadowBlur,shadowColor:this.shadowColor,shadowOffsetX:this.shadowOffsetX,shadowOffsetY:this.shadowOffsetY,strokeStyle:this.strokeStyle,textAlign:this.textAlign,partClipRect:this.partClipRect};this.uc.push(t);const i=[];for(let e=0;eh.offset>a.offset?1:-1);for(let h=0;h1&&this.dc[this.dc.length-2].setAttributeNS(null,"clip-path",'path("'+s+'") view-box');return}if(n.d=s,this.processCommon("",n,i),this.currentPath!==null){const r=this.currentPath;if(r.nodeName!=="g")for(const l in n)l!=="transform"&&r.setAttributeNS(null,l,n[l]);else{const l=r.getElementsByTagName("path");for(const h in n)h!=="transform"&&l[e].setAttributeNS(null,h,n[h])}}else this.ud("path",n)}BR(t){const i=t.getAttribute("clip-path");return i===null?null:this.svg.getElementById(i.split("#")[1].slice(0,-1))}gL(t){const i=t.getAttribute("clip-path");if(i===null)return;const e=this.svg.getElementById(i.split("#")[1].slice(0,-1));e!==null&&e.remove()}qR(t){const i=[];for(let e=0;es?(this.scale(s/n,1),this.translate((n-s)/2,0)):s>n&&(this.scale(1,n/s),this.translate(0,(s-n)/2)),this.fillOrClip(i,e),n>s?(this.translate(-(n-s)/2,0),this.scale(1/(s/n),1)):s>n&&(this.translate(0,-(s-n)/2),this.scale(1,1/(n/s))),!0}strokeContext(){this.clipInsteadOfFill||this.stroke()}fillOrClip(t,i){this.clipInsteadOfFill?this.clip(i):this.fill(t,i)}shadowsSet(t,i,e){this.fc=t,this.cc=i,this.Pn=e}shadowsOff(){this.ol=!1,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0}shadowsOn(){this.ol=!0,this.shadowOffsetX=this.fc,this.shadowOffsetY=this.cc,this.shadowBlur=this.Pn}enableDash(t,i){const e=this.Y;e.setLineDash!==void 0&&(e.setLineDash(t),e.lineDashOffset=i)}disableDash(){const t=this.Y;t.setLineDash!==void 0&&(t.setLineDash(CanvasSurfaceContext.EmptyArray),t.lineDashOffset=0)}clearContextCache(t){t&&(this.Q1=""),this._1="",this.tb=""}removePartFromView(t){}static EmptyArray=Object.freeze([])}var BrushType=(w=>(w[w.Solid=1]="Solid",w[w.Linear=2]="Linear",w[w.Radial=3]="Radial",w[w.Pattern=4]="Pattern",w))(BrushType||{}),ColorSpace=(w=>(w[w.Lab=1]="Lab",w[w.HSL=2]="HSL",w[w.Oklch=3]="Oklch",w))(ColorSpace||{});class ColorNumbers{n0;n1;n2;n3;constructor(){this.n0=0,this.n1=0,this.n2=0,this.n3=0}}class Brush{f;it;Aa;li;xs;ip;ep;Nn;sp;Sn;rc;v1;constructor(t,i){if(GSet.vi(this),this.f=!1,t===void 0)this.it=1,this.Aa="black";else if(typeof t=="string"){const s=Util.Xh(BrushType,t);s!==null?(this.it=s,this.Aa="black"):(this.it=1,Debug&&!Brush.isValidColor(t)&&Util.n('Color "'+t+'" is not a valid color string for Brush constructor'),this.Aa=t)}else Debug&&Util.tt(t,BrushType,"BrushType"),this.it=t,this.Aa="black";const e=this.it;if(e===2?(this.li=Spot.TopCenter,this.xs=Spot.BottomCenter):e===3?(this.li=Spot.Center,this.xs=Spot.Center):(this.li=Spot.None,this.xs=Spot.None),this.ip=0,this.ep=NaN,this.Nn=null,this.sp=null,this.Sn=null,this.rc=0,this.v1=0,i){const s={};for(const n in i)isFinite(parseFloat(n))?this.addColorStop(parseFloat(n),i[n]):s[n]=i[n];Object.assign(this,s)}}copy(){const t=new Brush;return t.it=this.it,t.Aa=this.Aa,t.li=this.li.L(),t.xs=this.xs.L(),t.ip=this.ip,t.ep=this.ep,this.Nn!==null&&(t.Nn=this.Nn.copy()),t.sp=this.sp,t}w(){return this.f=!0,this.Nn!==null&&this.Nn.w(),this}ft(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this.Nn!==null&&this.Nn.ft(),this}fi(t){t in BrushType?this.type=t:Util.ur(this,t)}toString(){let t="Brush(";if(this.type===1)t+=this.color;else if(this.type===2?t+="Linear ":this.type===3?t+="Radial ":this.type===4?t+="Pattern ":t+="(unknown) ",t+=this.start+" "+this.end,this.colorStops!==null){const i=this.colorStops.iterator;for(;i.next();){const e=i.key,s=i.value;t+=" "+e+":"+s}}return t+=")",t}addColorStop(t,i){return this.f&&Util.F(this),(typeof t!="number"||!isFinite(t)||t>1||t<0)&&Util.G(t,"0 <= loc <= 1",Brush,"addColorStop:loc"),Util.t(i,"string",Brush,"addColorStop:color"),Debug&&!Brush.isValidColor(i)&&Util.n('Color "'+i+'" is not a valid color string for Brush.addColorStop'),this.Nn===null&&(this.Nn=new GMap),this.Nn.set(t,i),this.it===1&&(this.type=2),this.Sn=null,this}get type(){return this.it}set type(t){this.f&&Util.F(this,t),Util.tt(t,BrushType,"BrushType"),this.it=t,this.start.isNoSpot()&&(t===2?this.start=Spot.TopCenter:t===3&&(this.start=Spot.Center)),this.end.isNoSpot()&&(t===2?this.end=Spot.BottomCenter:t===3&&(this.end=Spot.Center)),this.Sn=null}get color(){return this.Aa}set color(t){this.f&&Util.F(this,t),Debug&&!Brush.isValidColor(t)&&Util.n('Color "'+t+'" is not a valid color string for Brush.color'),this.Aa=t,this.Sn=null}get start(){return this.li}set start(t){this.f&&Util.F(this,t),Util.s(t,Spot,Brush,"start"),this.li=t.L(),this.Sn=null}get end(){return this.xs}set end(t){this.f&&Util.F(this,t),Util.s(t,Spot,Brush,"end"),this.xs=t.L(),this.Sn=null}get startRadius(){return this.ip}set startRadius(t){this.f&&Util.F(this,t),Util.r(t,Brush,"startRadius"),t<0&&Util.G(t,">= zero",Brush,"startRadius"),this.ip=t,this.Sn=null}get endRadius(){return this.ep}set endRadius(t){this.f&&Util.F(this,t),Util.r(t,Brush,"endRadius"),t<0&&Util.G(t,">= zero",Brush,"endRadius"),this.ep=t,this.Sn=null}get colorStops(){return this.Nn}set colorStops(t){this.f&&Util.F(this,t),Debug&&Util.s(t,GMap,Brush,"colorStops"),this.Nn=t,this.Sn=null}get pattern(){return this.sp}set pattern(t){this.f&&Util.F(this,t),this.sp=t,this.Sn=null}static randomColor(t,i){t===void 0&&(t=128),Debug&&(Util.r(t,Brush,"randomColor:min"),(t<0||t>255)&&Util.G(t,"0 <= min <= 255",Brush,"randomColor:min")),i===void 0&&(i=Math.max(t,255)),Debug&&(Util.r(i,Brush,"randomColor:max"),(i255)&&Util.G(i,"min <= max <= 255",Brush,"randomColor:max"));const e=Math.abs(i-t);let s=Math.floor(t+Math.random()*e).toString(16),n=Math.floor(t+Math.random()*e).toString(16),o=Math.floor(t+Math.random()*e).toString(16);return s.length<2&&(s="0"+s),n.length<2&&(n="0"+n),o.length<2&&(o="0"+o),"#"+s+n+o}static isValidColor(t){return root.CSS?root.CSS.supports("color",t):!0}static lighten(t){return Brush.lightenBy(t)}lightenBy(t,i){this.f&&Util.F(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Eo(this.color),this.color=Brush.dd(e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Eo(n.value),this.addColorStop(n.key,Brush.dd(e,s))}return this}static lightenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Eo(t),Brush.dd(s,n)}static darken(t){return Brush.darkenBy(t)}darkenBy(t,i){this.f&&Util.F(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Eo(this.color),this.color=Brush.dd(-e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Eo(n.value),this.addColorStop(n.key,Brush.dd(-e,s))}return this}static darkenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Eo(t),Brush.dd(-s,n)}static mix(t,i,e){Brush.Eo(t);const s=Brush.W.n0,n=Brush.W.n1,o=Brush.W.n2,r=Brush.W.n3;Brush.Eo(i),e===void 0&&(e=.5);const l=Math.round((Brush.W.n0-s)*e+s),h=Math.round((Brush.W.n1-n)*e+n),a=Math.round((Brush.W.n2-o)*e+o),f=Math.round((Brush.W.n3-r)*e+r);return`rgba(${l}, ${h}, ${a}, ${f})`}isDark(){if(this.type===1)return Brush.isDark(this.color);if((this.type===2||this.type===3)&&this.colorStops!==null){const t=this.colorStops;if(this.type===3)return Brush.isDark(t.first().value);if(t.get(.5)!==null)return Brush.isDark(t.get(.5));if(t.count===2){const l=t.toArray();return Brush.isDark(Brush.mix(l[0].value,l[1].value))}const i=t.iterator;let e=-1,s=-1,n=1,o=1;for(;i.next();){const l=i.key,h=Math.abs(.5-i.key);n>o&&h=n&&hs){let l=e;e=s,s=l,l=n,n=o,o=l}const r=s-e;return Brush.isDark(Brush.mix(t.get(e),t.get(s),1-o/r))}return!1}static isDark(t){return t?t instanceof Brush?t.isDark():(Brush.Eo(t),(299*Brush.W.n0+587*Brush.W.n1+114*Brush.W.n2)/1e3<128):!1}static dd(t,i){switch(i){case 1:return Brush.jR(),Brush.lo.n0=Math.min(100,Math.max(0,Brush.lo.n0+100*t)),Brush.WR(),"rgba("+Brush.W.n0+", "+Brush.W.n1+", "+Brush.W.n2+", "+Brush.W.n3+")";case 2:return Brush.UM(),Brush.Yi.n2=Math.min(100,Math.max(0,Brush.Yi.n2+100*t)),"hsla("+Brush.Yi.n0+", "+Brush.Yi.n1+"%, "+Brush.Yi.n2+"%, "+Brush.Yi.n3+")";case 3:return Brush.vR(),Brush.ho.n0=Math.min(100,Math.max(0,Brush.ho.n0+100*t)),Brush.JR(),"rgba("+Brush.W.n0+", "+Brush.W.n1+", "+Brush.W.n2+", "+Brush.W.n3+")";default:Util.n("Unknown color space: "+i)}}static Eo(t){const i=Brush.rl;if(i===null)return;i.clearRect(0,0,1,1),i.fillStyle="#000000";const e=i.fillStyle;if(i.fillStyle=t,i.fillStyle!==e){i.fillRect(0,0,1,1);const s=i.getImageData(0,0,1,1).data;Brush.W.n0=s[0],Brush.W.n1=s[1],Brush.W.n2=s[2],Brush.W.n3=s[3]/255}else{i.fillStyle="#FFFFFF";const s=i.fillStyle;i.fillStyle=t,i.fillStyle===s&&Debug&&Util.n('Color "'+t+'" is not a valid color string for RGBA color conversion'),Brush.W.n0=0,Brush.W.n1=0,Brush.W.n2=0,Brush.W.n3=1}}static UM(){const t=Brush.W.n0/255,i=Brush.W.n1/255,e=Brush.W.n2/255,s=Math.max(t,i,e),n=Math.min(t,i,e),o=s-n;let r,l;const h=(s+n)/2;if(o===0)r=l=0;else{switch(s){case t:r=(i-e)/o%6;break;case i:r=(e-t)/o+2;break;case e:r=(t-i)/o+4;break}r*=60,r<0&&(r+=360),l=o/(1-Math.abs(2*h-1))}Brush.Yi.n0=Math.round(r),Brush.Yi.n1=Math.round(l*100),Brush.Yi.n2=Math.round(h*100),Brush.Yi.n3=Brush.W.n3}static gE(){const t=Brush.Yi.n0,i=Brush.Yi.n1/100,e=Brush.Yi.n2/100;let s,n,o;const r=(1-Math.abs(2*e-1))*i,l=t/60,h=r*(1-Math.abs(l%2-1));l>=0&&l<1?(s=r,n=h,o=0):l>=1&&l<2?(s=h,n=r,o=0):l>=2&&l<3?(s=0,n=r,o=h):l>=3&&l<4?(s=0,n=h,o=r):l>=4&&l<5?(s=h,n=0,o=r):l>=5&&l<6&&(s=r,n=0,o=h);const a=e-.5*r;s+=a,n+=a,o+=a,Brush.W.n0=Math.round(s*255),Brush.W.n1=Math.round(n*255),Brush.W.n2=Math.round(o*255),Brush.W.n3=Brush.Yi.n3}static jR(){Brush.xL(),Brush.ZR()}static WR(){Brush.$R(),Brush.bL()}static A2(t){return t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}static L2(t){return t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055}static xL(){const t=Brush.A2(Brush.W.n0),i=Brush.A2(Brush.W.n1),e=Brush.A2(Brush.W.n2);Brush.zt.n0=.4124564*t+.3575761*i+.1804375*e,Brush.zt.n1=.2126729*t+.7151522*i+.072175*e,Brush.zt.n2=.0193339*t+.119192*i+.9503041*e,Brush.zt.n3=Brush.W.n3}static bL(){const t=3.2404542*Brush.zt.n0+-1.5371385*Brush.zt.n1+-.4985314*Brush.zt.n2,i=-.969266*Brush.zt.n0+1.8760108*Brush.zt.n1+.041556*Brush.zt.n2,e=.0556434*Brush.zt.n0+-.2040259*Brush.zt.n1+1.0572252*Brush.zt.n2;Brush.W.n0=Brush.L2(t)*255,Brush.W.n1=Brush.L2(i)*255,Brush.W.n2=Brush.L2(e)*255,Brush.W.n3=Brush.zt.n3,Brush.W.n0=Math.round(Brush.W.n0),Brush.W.n0>255?Brush.W.n0=255:Brush.W.n0<0&&(Brush.W.n0=0),Brush.W.n1=Math.round(Brush.W.n1),Brush.W.n1>255?Brush.W.n1=255:Brush.W.n1<0&&(Brush.W.n1=0),Brush.W.n2=Math.round(Brush.W.n2),Brush.W.n2>255?Brush.W.n2=255:Brush.W.n2<0&&(Brush.W.n2=0)}static T2=216/24389;static ib=24389/27;static gd=[95.047,100,108.883];static D2(t){return t>Brush.T2?Math.pow(t,1/3):(Brush.ib*t+16)/116}static ZR(){const t=Brush.D2(Brush.zt.n0*100/Brush.gd[0]),i=Brush.D2(Brush.zt.n1*100/Brush.gd[1]),e=Brush.D2(Brush.zt.n2*100/Brush.gd[2]);Brush.lo.n0=116*i-16,Brush.lo.n1=500*(t-i),Brush.lo.n2=200*(i-e),Brush.lo.n3=Brush.zt.n3}static kL(t){const i=t*t*t;return i>Brush.T2?i:(116*t-16)/Brush.ib}static $R(){const t=(Brush.lo.n0+16)/116,i=Brush.lo.n1/500+t,e=t-Brush.lo.n2/200;Brush.zt.n0=Brush.gd[0]/100*Brush.kL(i),Brush.zt.n1=Brush.gd[1]/100*(Brush.lo.n0>Brush.ib*Brush.T2?Math.pow(t,3):Brush.lo.n0/Brush.ib),Brush.zt.n2=Brush.gd[2]/100*Brush.kL(e),Brush.zt.n3=Brush.lo.n3}static QR(){let t=.8190224*Brush.zt.n0+.3619062*Brush.zt.n1+-.1288737*Brush.zt.n2,i=.03298366*Brush.zt.n0+.9292868*Brush.zt.n1+.03614466*Brush.zt.n2,e=.04817719*Brush.zt.n0+.2642395*Brush.zt.n1+.6335478*Brush.zt.n2;t=Math.cbrt(t),i=Math.cbrt(i),e=Math.cbrt(e),Brush.gi.n0=.2104542*t+.7936177*i+-.004072046*e,Brush.gi.n1=1.977998*t+-2.428592*i+.4505937*e,Brush.gi.n2=.02590403*t+.7827717*i+-.8086757*e,Brush.gi.n3=Brush.zt.n3,Brush.gi.n0*=100}static _R(){Brush.gi.n0/=100;let t=.9999999*Brush.gi.n0+.3963377*Brush.gi.n1+.2158037*Brush.gi.n2,i=1.000000009*Brush.gi.n0+-.1055613*Brush.gi.n1+-.06385417*Brush.gi.n2,e=1.00000005*Brush.gi.n0+-.08948418*Brush.gi.n1+-1.291485*Brush.gi.n2;t=t**3,i=i**3,e=e**3,Brush.zt.n0=1.2268798*t+-.5578149*i+.281391*e,Brush.zt.n1=-.04057576*t+1.112286*i+-.07171106*e,Brush.zt.n2=-.07637294*t+-.4214933*i+1.586924*e,Brush.zt.n3=Brush.gi.n3}static tI(){const t=Math.atan2(Brush.gi.n2,Brush.gi.n1)*180/Math.PI;Brush.ho.n0=Brush.gi.n0,Brush.ho.n1=Math.sqrt(Brush.gi.n1**2+Brush.gi.n2**2),Brush.ho.n2=t>=0?t:t+360,Brush.ho.n3=Brush.gi.n3}static iI(){Brush.gi.n0=Brush.ho.n0,Brush.gi.n1=Brush.ho.n1*Math.cos(Brush.ho.n2*Math.PI/180),Brush.gi.n2=Brush.ho.n1*Math.sin(Brush.ho.n2*Math.PI/180),Brush.gi.n3=Brush.ho.n3}static vR(){Brush.xL(),Brush.QR(),Brush.tI()}static JR(){Brush.iI(),Brush._R(),Brush.bL()}static cd(t,i){typeof t=="string"?Debug&&!Brush.isValidColor(t)&&Util.n('Color "'+t+'" is not a valid color string for '+i):t instanceof Brush||Util.n("Value for "+i+" must be a color string or a Brush, not "+t)}static Solid=1;static Linear=2;static Radial=3;static Pattern=4;static Lab=1;static HSL=2;static rl=Diagram.isUsingDOM()?new CanvasSurface(null,void 0,{willReadFrequently:!0}).di:null;static W=new ColorNumbers;static Yi=new ColorNumbers;static zt=new ColorNumbers;static lo=new ColorNumbers;static gi=new ColorNumbers;static ho=new ColorNumbers}class PanelLayout{Tt="Base";static Layouts=new GMap;static definePanelLayout(t,i){i.name=t,PanelLayout.Layouts.set(t,i)}get name(){return this.Tt}set name(t){this.Tt=t}constructor(){}get classType(){return Panel}measure(t,i,e,s,n,o,r){}measureElement(t,i,e,s,n){t.wt(i,e,s,n)}arrange(t,i,e){}arrangeElement(t,i,e,s,n,o){t.qt(i,e,s,n,o)}remeasureObject(t){t.lc()}Ji(t,i,e){}}class PanelLayoutPosition extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=s.length,h=t.Wo();for(let a=0;a0&&(P=Math.max(Math.abs(k.x*o+k.offsetX-(M.x*o+M.offsetX))-g,0)),r>0&&(N=Math.max(Math.abs(k.y*r+k.offsetY-(M.y*r+M.offsetY))-g,0));const T=Size.a();T.e(0,0);const L=t.Wo();for(let I=0;I1,ot=it.columnSpan>1;(ft||ot)&&!(Uy&&(P=Math.max(y-gt,0)),b.Zi=b.Zi+P,b.actual=b.lt+P,y=Math.max(y-(P+(mt?gt:0)),0)}if(it.columnSpan===1&&(N===0||N===4)){b=t.getColumnDefinition(H);const gt=b.computeEffectiveSpacing(),mt=b.lt===0;P=Math.max(ut-b.actual,0),P+(mt?gt:0)>p&&(P=Math.max(p-gt,0)),b.Zi=b.Zi+P,b.actual=b.lt+P,p=Math.max(p-(P+(mt?gt:0)),0)}(ft||ot)&&it.lc()}}}Util.nt(c);let L=0,D=0;l=t.columnCount;for(let U=0;U=t.rowCount);$++)b=t.getRowDefinition(E.row+$),P=0,N===2||N===4?P=Math.max(b.minimum,X[E.row+$]===0?b.maximum:Math.min(X[E.row+$],b.maximum)):P=Math.max(b.minimum,isNaN(b.xe)?b.maximum:Math.min(b.xe,b.maximum)),B.height+=P,_+=b.minimum;for(let $=1;$=t.columnCount);$++)b=t.getColumnDefinition(E.column+$),P=0,N===2||N===5?P=Math.max(b.minimum,z[E.column+$]===0?b.maximum:Math.min(z[E.column+$],b.maximum)):P=Math.max(b.minimum,isNaN(b.xe)?b.maximum:Math.min(b.xe,b.maximum)),B.width+=P,et+=b.minimum;K.width+=B.width,K.height+=B.height;const tt=E.margin,it=tt.right+tt.left,ft=tt.top+tt.bottom;E.wt(K.width,K.height,et,_);const ot=E.measuredBounds,lt=Math.max(ot.width+it,0),st=Math.max(ot.height+ft,0);let nt=0;for(let $=0;$=t.rowCount);$++)b=t.getRowDefinition(E.row+$),nt+=b.total||0;if(nt=t.rowCount);at++){b=t.getRowDefinition(E.row+at);const ut=b.lt||0,dt=rt(E,b,ct);Debug&&typeof dt!="number"&&Util.n(E+" spanAllocation does not return a number: "+dt),b.actual=Math.min(b.maximum,ut+dt),b.lt!==ut&&($-=b.lt-ut)}}for(;$>0;){const rt=b.lt||0;if(isNaN(b.height)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+$),b.lt!==rt&&($-=b.lt-rt)),b.index===0)break;b=t.getRowDefinition(b.index-1)}}let ht=0;for(let $=0;$=t.columnCount);$++)b=t.getColumnDefinition(E.column+$),ht+=b.total||0;if(ht=t.columnCount);at++){b=t.getColumnDefinition(E.column+at);const ut=b.lt||0,dt=rt(E,b,ct);Debug&&typeof dt!="number"&&Util.n(E+" spanAllocation does not return a number: "+dt),b.actual=Math.min(b.maximum,ut+dt),b.lt!==ut&&($-=b.lt-ut)}}for(;$>0;){const rt=b.lt||0;if(isNaN(b.width)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+$),b.lt!==rt&&($-=b.lt-rt)),b.index===0)break;b=t.getColumnDefinition(b.index-1)}}}Util.nt(u),Size.o(B),Size.o(K),X!==void 0&&Util.nt(X),z!==void 0&&Util.nt(z);let G=0,q=0;const j=t.desiredSize,J=t.maxSize;N=t.qs(!0),L=0,D=0;let Y=0,v=0;l=t.columnCount;for(let U=0;U0){for(;p!==f&&(u[p]===void 0||u[p].lt===0);)p++;p=Math.max(Math.min(p,f-1),0),m=-u[p].position}let y=Math.min(t.leftIndex,c-1);if(d.length>0){for(;y!==c&&(d[y]===void 0||d[y].lt===0);)y++;y=Math.max(Math.min(y,c-1),0),g=-d[y].position}let x=0,k=0;for(;x!==f&&u[x]===void 0;)x++;for(;k!==f&&d[k]===void 0;)k++;const b=t.part;let S=t.getRowDefinition(x),M=t.getColumnDefinition(k);for(let C=0;C=t.rowCount);st++){const nt=t.getRowDefinition(C+st);nt.lt!==0&&(A.height+=nt.total)}for(let st=1;st=t.columnCount);st++){const nt=t.getColumnDefinition(N+st);nt.lt!==0&&(A.width+=nt.total)}const O=T.lt+A.width,V=P.lt+A.height;let K=h,B=a;const X=O,z=V,G=h,q=a;let j=O,J=V;h+O>e.width&&(j=Math.max(e.width-h,0)),a+V>e.height&&(J=Math.max(e.height-a,0));let Y=R.alignment,v=0,W=0,Q=0,U=0;if(Y.isDefault()){Y=t.defaultAlignment,Y.isSpot()||(Y=Spot.Center),v=Y.x,W=Y.y,Q=Y.offsetX,U=Y.offsetY;const st=T.alignment,nt=P.alignment;st.isSpot()&&(v=st.x,Q=st.offsetX),nt.isSpot()&&(W=nt.y,U=nt.offsetY)}else v=Y.x,W=Y.y,Q=Y.offsetX,U=Y.offsetY;(isNaN(v)||isNaN(W))&&(v=.5,W=.5,Q=0,U=0);let E=I.width,H=I.height;const Z=R.margin,et=Z.left+Z.right,_=Z.top+Z.bottom,tt=R.R0(P,T,!1);isNaN(R.desiredSize.width)&&(tt===2||tt===5)&&(E=Math.max(O-et,0)),isNaN(R.desiredSize.height)&&(tt===2||tt===4)&&(H=Math.max(V-_,0));const it=R.maxSize,ft=R.minSize;E=Math.min(it.width,E),H=Math.min(it.height,H),E=Math.max(ft.width,E),H=Math.max(ft.height,H);const ot=E+et,lt=H+_;K+=X*v-ot*v+Q+Z.left,B+=z*W-lt*W+U+Z.top,R.visible&&(Rect.contains(G,q,j,J,K,B,I.width,I.height)?R.qt(K,B,E,H):R.qt(K,B,E,H,new Rect(G,q,j,J)))}}}Size.o(A);for(let C=0;C0&&(b.figure==="LineV"||b.figure==="LineH")){if(i.lineWidth=b.strokeWidth,t.wn(i,b.stroke,!1,!1,l,h),i.beginPath(),b.figure==="LineV"){const D=Math.floor((m-o)/o);for(let F=D;F<=D+c;F++){const R=F*o+m;0<=R&&R<=a&&this.sb(F,S,A,N)&&(i.moveTo(R,0),i.lineTo(R,f))}}else if(b.figure==="LineH"){const D=Math.floor((g-r)/r);for(let F=D;F<=D+u;F++){const R=F*r+g;0<=R&&R<=f&&this.sb(F,S,A,N)&&(i.moveTo(0,R),i.lineTo(a,R))}}i.stroke(),i.endPath()}else if(b.fill!==null){if(t.wn(i,b.fill,!0,!1,l,h),b.figure==="BarV"){let D=b.width;isNaN(D)&&(D=o);const F=Math.floor((m-o)/o);for(let R=F;R<=F+c;R++){const I=R*o+m;0<=I+D&&I<=a&&this.sb(R,S,A,N)&&i.fillRect(I,0,D,f)}}else if(b.figure==="BarH"){let D=b.height;isNaN(D)&&(D=r);const F=Math.floor((g-r)/r);for(let R=F;R<=F+u;R++){const I=R*r+g;0<=I+D&&I<=f&&this.sb(R,S,A,N)&&i.fillRect(0,I,a,D)}}}T&&i.disableDash(),C!==1&&(i.globalAlpha=P)}}sb(t,i,e,s){if(i<0)return t%i===e;if(t%i!==e)return!1;const n=s.length;for(let o=0;ol&&r.push(d)}}t.Mi.np=i}O2(t){return t==="LineV"||t==="BarV"}eI(t){let i=1,e=1;const s=t.D.h,n=s.length;for(let l=0;l=g){const Y=Point.a();f.ML(Y),O=f.midAngle,L!==0&&(I=f.computeAngle(A,L,O),A.jt=I,A.ye(!0),A.oo(!0)),F=Y.x-u.x,R=Y.y-u.y,Point.o(Y)}else{let Y,v,W=0;if(P>=0?(Y=m.elt(P),v=P0?m.elt(W-1):Y),O=0,Y.equalsApprox(v)){let Q,U;P>=0?(Q=P>0?m.elt(P-1):Y,U=P1?m.elt(W-2):v);const E=Q.distanceSquaredPoint(Y),H=v.distanceSquaredPoint(U);E>H+10?O=P>=0?Q.directionPoint(Y):Y.directionPoint(Q):H>E+10?O=P>=0?v.directionPoint(U):U.directionPoint(v):O=P>=0?Q.directionPoint(U):U.directionPoint(Q)}else O=P>=0?Y.directionPoint(v):v.directionPoint(Y);L!==0&&(I=f.computeAngle(A,L,O),A.jt=I,A.ye(!0),A.oo(!0)),F=Y.x+(v.x-Y.x)*N-u.x,R=Y.y+(v.y-Y.y)*N-u.y}A.wt(1/0,1/0,0,0),C=A.measuredBounds;const V=A.naturalBounds;let K=0;A instanceof Shape&&(K=A.strokeWidth);const B=V.width+K,X=V.height+K;k.Vi(),k.Es(-C.x,-C.y),k.rt(A.scale,A.scale),k.ms(L===0?A.angle:O,B/2,X/2),(L===22||L===26)&&k.ms(90,B/2,X/2),(L===23||L===27)&&k.ms(-90,B/2,X/2),L===28&&(O>45&&O<135||O>225&&O<315)&&k.ms(-O,B/2,X/2);const z=new Rect(0,0,B,X);b.setRectSpot(z,T),k.Pt(b);const G=-b.x+K/2*A.scale,q=-b.y+K/2*A.scale;S.c(D);const j=isNaN(D.x),J=isNaN(D.y);if(j||J){const Y=B/2+3,v=X/2+3,W=O>=45&&O<=135,Q=O>=225&&O<=315;L===0&&(W||Q)?(S.x=J?Y:D.y,S.y=j?v:D.x,W?P>=0||isNaN(P)&&N<.5||j&&(S.y=-v):Q&&((P>=0||isNaN(P)&&N<.5)&&j&&(S.y=-v),J&&(S.x=-Y))):(j&&(P>=0||isNaN(P)&&N<.5?S.x=Y:S.x=-Y),J&&(S.y=-v),S.rotate(O))}else S.rotate(O);F+=S.x,R+=S.y,z.e(F+G,R+q,C.width,C.height),x.push(z),d.unionRect(z)}if(h!==null){const M=h.labelNodes;for(;M.next();)M.value.wt(1/0,1/0)}t.vo=d,t.position.e(u.x+d.x,u.y+d.y),n.Kn(d.width||0,d.height||0),Transform.o(k),Point.o(b),Point.o(S)}arrange(t,i,e){const s=i.length;if(!(t instanceof Adornment||t instanceof Link))return;let n=t,o=null;t instanceof Adornment&&(o=t,n=o.adornedPart);const r=t,l=t instanceof Adornment?null:n.path,h=t.gc;if(h.length!==0){let u=0;if(l!==null&&u=2&&r instanceof Link){const u=r.labelNodes;for(;u.next();){const d=u.value;r.oI(d,f,a)}}o!==null?o.md(!1):n.md(!1);const c=t.PL(Point.a());t.location.e(t.position.x+c.x,t.position.y+c.y),Point.o(c)}measureLinkPath(t,i,e,s){if(s.Xo()===!1)return;let n=s.strokeWidth;if(n===0&&t instanceof Adornment&&t.type===Panel.Link&&t.adornedObject instanceof Shape&&(n=t.adornedObject.strokeWidth),n=n*s.rt,t instanceof Link&&t.mt!==null){const o=t.geometry.bounds;s.no(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else if(t instanceof Adornment&&t.adornedPart.mt!==null){const o=t.adornedPart.mt.bounds;s.no(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else s.no(-(n/2),-(n/2),i+n,e+n);s.rI(),s.ye(!1)}}PanelLayout.definePanelLayout("Link",new PanelLayoutLink);class PanelLayoutGraduated extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=t.findMainElement();t.Ze=[];const h=l.margin,a=h.right+h.left,f=h.top+h.bottom;l.wt(i,e,o,r);const c=l.measuredBounds,u=c.width,d=c.height,m=Math.max(u+a,0),g=Math.max(d+f,0),p=new Rect(-h.left,-h.top,m,g);t.Ze.push(p),n.c(p),this.determineGraduatedMarks(t,l);const y=t.Ms;if(y===null)return;const x=s.length;for(let k=0;k45&&c<135||c>225&&c<315)&&S.ms(-c,k/2,b/2);const M=Rect.H(0,0,k,b),A=Point.a();A.setRectSpot(M,o),S.Pt(A);const C=-A.x,P=-A.y,N=Point.a();N.c(l),isNaN(N.x)&&(N.x=k/2+3),isNaN(N.y)&&(N.y=-(b/2+3)),N.rotate(c),a+=N.x+C,f+=N.y+P;const T=new Rect(a,f,y.width,y.height),L=new Rect(y.x,y.y,y.width,y.height),D=new Rect(x.x,x.y,x.width,x.height);p.labelAngle=u,p.lineCount=n.lineCount,p.lines=n.getMetrics(),p.actualBounds=T,p.measuredBounds=L,p.naturalBounds=D,g===0?h.c(T):h.unionRect(T),Point.o(N),Point.o(A),Rect.o(M),Transform.o(S)}t.Ze!==null&&t.Ze.push(h),s.unionNoCheck(h.x,h.y,h.width,h.height)}determineGraduatedMarks(t,i){const e=i.geometry,s=i.strokeWidth,n=e.flattenedSegments,o=e.flattenedLengths,r=e.flattenedTotalLength,l=n.length;let h=0,a=0;const f=Util.at();for(let x=0;xt.graduatedMin+P){const F=Math.floor((N-t.graduatedMin)/P);N-=F*P}const T=c[x],L=N,D=t.graduatedMax*1e-6;for(let F=1;N<=t.graduatedMax+D;F++){if(this.hI(t,N-t.graduatedTickBase,T)&&(N>t.graduatedMax&&(N=t.graduatedMax),(k.graduatedSkip===null||k instanceof TextBlock&&!k.graduatedSkip(N,k)||k instanceof Shape&&!k.graduatedSkip(N,k))&&(m=(N-t.graduatedMin)*r/t.graduatedRange,m>r&&(m=r),g<=m&&m<=p))){let R=f[A][C],I=o[A][C];for(;AM&&C.4995)return t;let o=t;if(i<.5?n>0?o=s[n-1]:Geo.q(e[0],e[e.length-2])&&Geo.q(e[1],e[e.length-1])&&(o=s[s.length-1]):i>.5&&(n+1180&&(t.9995)return(t+o)/2%360;if(r<10){const l=1-Math.abs(.5-i);return(t*l+o*(1-l))%360}}return t}lI(t){if(t.as===null){const i=[],e=t.D.h,s=e.length;for(let n=0;nl&&r.push(f)}}t.as=i}return t.as}hI(t,i,e){const s=e.length;for(let n=0;n-l)return!1}return!0}Ji(t,i,e){const s=e.ea;e.ea=!0;const n=t.naturalBounds,o=n.width,r=n.height,l=i instanceof SVGContext;i.save(),i.beginPath(),i.rect(-1,-1,o+1,r+1),i.clip(),i.endPath();const h=t.findMainElement();h.Ji(i,e);let a=t.getDocumentScale()*e.scale;a<=0&&(a=1);const f=h.actualBounds,c=t.D.h,u=t.Ms,d=c.length;for(let m=0;m(w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ViewboxStretch||{});class Panel extends GraphObject{it;D;ii;pd;vn;ll;ao;vo;B2;V;yd;ut;Mi;si;wd;xh;vs;constructor(t,i){if(super(),this.it=null,t===void 0)this.it=Panel.Position;else if(typeof t=="string"){const e=PanelLayout.Layouts.get(t);e!==null&&(this.it=e)}else t instanceof PanelLayout?this.it=t:t&&(this.it=Panel.Position,i=t);this.it===null&&Util.n("Panel type not specified or PanelLayout not loaded: "+t),this.l|=4194304|(this.it===Panel.Grid?1048576:0),this.D=new List,this.ii=Margin.Hg,this.pd=Spot.Default,this.vn=1,this.ll=null,this.ao="",this.vo=new Rect(NaN,NaN,NaN,NaN),this.B2=null,this.V=null,this.yd=6,this.Mi=null,this.ut=null,this.si=null,this.wd=NaN,this.xh=null,this.vs=null,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.it=this.it,t.ii=this.ii.L(),t.pd=this.pd.L(),t.vn=this.vn,t.ao=this.ao,t.vo.c(this.vo),this.V!==null&&(t.V=this.V.copy(t)),t.yd=this.yd,this.ut!==null&&(t.ut=this.ut.copy()),this.Mi!==null&&(t.Mi=this.Mi.copy()),t.si=this.si,t.wd=this.wd,t.xh=this.xh}Ho(t){super.Ho(t),t.D=this.D;const i=t.D.h,e=i.length;for(let s=0;s= 0",Panel,"padding"),t=new Margin(t)):(Util.s(t,Margin,Panel,"padding"),t.left<0&&Util.G(t.left,">= 0",Panel,"padding:value.left"),t.right<0&&Util.G(t.right,">= 0",Panel,"padding:value.right"),t.top<0&&Util.G(t.top,">= 0",Panel,"padding:value.top"),t.bottom<0&&Util.G(t.bottom,">= 0",Panel,"padding:value.bottom"));const i=this.ii;i.equals(t)||(t=t.L(),this.ii=t,this.u(),this.i("padding",i,t))}get defaultAlignment(){return this.pd}set defaultAlignment(t){const i=this.pd;i.equals(t)||(Debug&&Util.s(t,Spot,Panel,"defaultAlignment"),t=t.L(),this.pd=t,this.u(),this.i("defaultAlignment",i,t))}get defaultStretch(){return this.vn}set defaultStretch(t){const i=this.vn;i!==t&&(this.vn=t,this.u(),this.i("defaultStretch",i,t))}get defaultSeparatorPadding(){return this.V!==null?this.V.op:Margin.Hg}set defaultSeparatorPadding(t){typeof t=="number"?t=new Margin(t):Debug&&Util.s(t,Margin,Panel,"defaultSeparatorPadding");const i=this.defaultSeparatorPadding;i.equals(t)||(t=t.L(),this.V===null&&(this.V=new TablePanelSettings),this.V.op=t,this.u(),this.i("defaultSeparatorPadding",i,t))}get defaultRowSeparatorStroke(){return this.V!==null?this.V.rp:null}set defaultRowSeparatorStroke(t){const i=this.defaultRowSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.w(),this.V===null&&(this.V=new TablePanelSettings),this.V.rp=t,this.T(),this.i("defaultRowSeparatorStroke",i,t))}get defaultRowSeparatorStrokeWidth(){return this.V!==null?this.V.lp:1}set defaultRowSeparatorStrokeWidth(t){const i=this.defaultRowSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.V===null&&(this.V=new TablePanelSettings),this.V.lp=t,this.u(),this.i("defaultRowSeparatorStrokeWidth",i,t))}get defaultRowSeparatorDashArray(){return this.V!==null?this.V.hp:null}set defaultRowSeparatorDashArray(t){const i=this.defaultRowSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Bi(t,"Array",Panel,"defaultRowSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("defaultRowSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.V===null&&(this.V=new TablePanelSettings),this.V.hp=t,this.T(),this.i("defaultRowSeparatorDashArray",i,t)}}get defaultColumnSeparatorStroke(){return this.V!==null?this.V.ap:null}set defaultColumnSeparatorStroke(t){const i=this.defaultColumnSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.w(),this.V===null&&(this.V=new TablePanelSettings),this.V.ap=t,this.T(),this.i("defaultColumnSeparatorStroke",i,t))}get defaultColumnSeparatorStrokeWidth(){return this.V!==null?this.V.fp:1}set defaultColumnSeparatorStrokeWidth(t){const i=this.defaultColumnSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.V===null&&(this.V=new TablePanelSettings),this.V.fp=t,this.u(),this.i("defaultColumnSeparatorStrokeWidth",i,t))}get defaultColumnSeparatorDashArray(){return this.V!==null?this.V.cp:null}set defaultColumnSeparatorDashArray(t){const i=this.defaultColumnSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Bi(t,"Array",Panel,"defaultColumnSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("defaultColumnSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.V===null&&(this.V=new TablePanelSettings),this.V.cp=t,this.T(),this.i("defaultColumnSeparatorDashArray",i,t)}}get wh(){return this.V!==null?this.V.wh:null}set wh(t){this.V===null&&(this.V=new TablePanelSettings),this.V.wh=t}get viewboxStretch(){return this.yd}set viewboxStretch(t){const i=this.yd;i!==t&&(this.yd=t,this.u(),this.i("viewboxStretch",i,t))}get gridCellSize(){return this.Mi!==null?this.Mi.xd:Size.hC}set gridCellSize(t){this.Mi===null&&(this.Mi=new GridPanelSettings);const i=this.Mi.xd;if(!i.equals(t)){(!t.isReal()||t.width===0||t.height===0)&&Util.n("Invalid Panel.gridCellSize: "+t),this.Mi.xd=t.L();const e=this.diagram;e!==null&&this===e.grid&&e.Zr(),this.T(),this.i("gridCellSize",i,t)}}get gridOrigin(){return this.Mi!==null?this.Mi.bd:Point.Lo}set gridOrigin(t){this.Mi===null&&(this.Mi=new GridPanelSettings);const i=this.Mi.bd;if(!i.equals(t)){t.isReal()||Util.n("Invalid Panel.gridOrigin: "+t),this.Mi.bd=t.L();const e=this.diagram;e!==null&&this===e.grid&&e.Zr(),this.T(),this.i("gridOrigin",i,t)}}get graduatedMin(){return this.ut!==null?this.ut.dp:0}set graduatedMin(t){Util.r(t,Panel,"graduatedMin");const i=this.graduatedMin;if(i!==t&&(this.ut===null&&(this.ut=new GradPanelSettings),this.ut.dp=t,this.u(),this.i("graduatedMin",i,t),this.sc())){const e=this.part;e!==null&&this.Sa(e,"graduatedRange")}}get graduatedMax(){return this.ut!==null?this.ut.gp:100}set graduatedMax(t){Util.r(t,Panel,"graduatedMax");const i=this.graduatedMax;if(i!==t&&(this.ut===null&&(this.ut=new GradPanelSettings),this.ut.gp=t,this.u(),this.i("graduatedMax",i,t),this.sc())){const e=this.part;e!==null&&this.Sa(e,"graduatedRange")}}get graduatedRange(){return this.graduatedMax-this.graduatedMin}get graduatedTickUnit(){return this.ut!==null?this.ut.mp:10}set graduatedTickUnit(t){Util.r(t,Panel,"graduatedTickUnit");const i=this.graduatedTickUnit;i!==t&&t>0&&(this.ut===null&&(this.ut=new GradPanelSettings),this.ut.mp=t,this.u(),this.i("graduatedTickUnit",i,t))}get graduatedTickBase(){return this.ut!==null?this.ut.pp:0}set graduatedTickBase(t){Util.r(t,Panel,"graduatedTickBase");const i=this.graduatedTickBase;i!==t&&(this.ut===null&&(this.ut=new GradPanelSettings),this.ut.pp=t,this.u(),this.i("graduatedTickBase",i,t))}get Ms(){return this.ut!==null?this.ut.Ms:null}set Ms(t){this.ut!==null?this.ut.Ms=t:t!==null&&(this.ut=new GradPanelSettings,this.ut.Ms=t)}get Ze(){return this.ut!==null?this.ut.Ze:null}set Ze(t){this.ut!==null?this.ut.Ze=t:t!==null&&(this.ut=new GradPanelSettings,this.ut.Ze=t)}get as(){return this.ut!==null?this.ut.as:null}set as(t){this.ut!==null?this.ut.as=t:t!==null&&(this.ut=new GradPanelSettings,this.ut.as=t)}get Le(){return this.ut!==null?this.ut.Le:null}set Le(t){this.ut!==null?this.ut.Le=t:t!==null&&(this.ut=new GradPanelSettings,this.ut.Le=t)}A0(t){super.A0(t);const i=this.D.h,e=i.length;for(let s=0;s0?this.ve:null,s=this.columnCount>0?this.Je:null;e!==null&&this.nb(t,i,!0,e,!0),s!==null&&this.nb(t,i,!1,s,!0),e!==null&&this.CL(t,!0,e),s!==null&&this.CL(t,!1,s),e!==null&&this.nb(t,i,!0,e,!1),s!==null&&this.nb(t,i,!1,s,!1)}CL(t,i,e){const s=e.length,n=this.actualBounds,o=this.naturalBounds;let r=!0;for(let l=0;lo.height)continue}else if(h.position>o.width)continue;let a=h.separatorStrokeWidth;isNaN(a)&&(a=i?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let f=h.separatorStroke;if(f===null&&(f=i?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),a===0||f===null)continue;this.wn(t,f,!1,!1,o,n);let c=!1,u=h.separatorDashArray;u===null&&(u=i?this.defaultRowSeparatorDashArray:this.defaultColumnSeparatorDashArray),u!==null&&(c=!0,t.enableDash(u,0)),t.beginPath();const d=h.position+a;i?d>o.height&&(a-=d-o.height):d>o.width&&(a-=d-o.width);let m=h.position+a/2;t.lineWidth=a;const g=this.ii;if(i){m+=g.top;const p=g.left,y=o.width-g.right;t.moveTo(p,m),t.lineTo(y,m)}else{m+=g.left;const p=g.top,y=o.height-g.bottom;t.moveTo(m,p),t.lineTo(m,y)}t.stroke(),t.endPath(),c&&t.disableDash()}}nb(t,i,e,s,n){const o=s.length,r=this.actualBounds,l=this.naturalBounds,h=this.AL(!0),a=this.AL(!1);for(let f=0;fu)continue;let d=c.computeEffectiveSpacing(),m=c.separatorStrokeWidth;isNaN(m)&&(m=e?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let g=c.separatorStroke;g===null&&(g=e?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),(g===null||c.index===(e?h:a))&&(m=0),d-=m;const p=c.position+m;let y=d+c.actual;if(p+y>u&&(y=u-p),y<=0)continue;const x=this.ii;this.wn(t,c.background,!0,!1,l,r),e?t.fillRect(x.left,p+x.top,r.width-(x.left+x.right),y):t.fillRect(p+x.left,x.top,y,r.height-(x.top+x.bottom))}}AL(t){const i=t?this.rowCount:this.columnCount;for(let e=0;ex&&n.set(P),Point.o(P)),Point.o(M),o&&n.O(r),k}}Vu(){const t=this.D.h,i=t.length;for(let e=0;ee||h>s)&&(this.u(),this.wt(l>e?e:l,h>s?s:h,0,0));break;case 2:this.u(!0),this.wt(e+f,s+c,0,0);break;case 5:this.u(!0),this.wt(e+f,h+c,0,0);break;case 4:this.u(!0),this.wt(l+f,s+c,0,0);break}}this.it.arrange(this,n,this.vo)}uh(t){const i=this.naturalBounds,e=this.Wo();if(Rect.contains(0,0,i.width,i.height,t.x,t.y)){const s=this.D.h,n=s.length,o=Point.H(0,0);for(let r=n;r--;){const l=s[r];if(!(!l.visible&&l!==e)&&(o.set(t).Ye(l.O),l.containsPoint(o)))return Point.o(o),!0}return Point.o(o),this.Ft!==null}return!1}S0(t){if(this.eo===t)return this;const i=this.D.h,e=i.length;for(let s=0;sd.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;let m=c;const g=c instanceof Panel?c:null,p=Transform.a();p.set(r),(g!==null?g.Ym(t,i,e,s,n,p):m.rL(t,s,p))&&(i!==null&&(m=i(m)),m!==null&&(e===null||e(m))&&n.add(m)),Transform.o(p)}}return o===void 0&&Transform.o(r),s}return o===void 0&&Transform.o(r),!1}z2(t,i,e){const s=this.D.h,n=s.length;for(let o=n;o--;){const r=s[o];if(!r.visible)continue;const l=r.actualBounds,h=this.naturalBounds;if(l.x>h.width||l.y>h.height||l.x+l.width<0||l.y+l.height<0)continue;r instanceof Panel&&r.z2(t,i,e);let a=r;t!==null&&(a=t(a)),a!==null&&(i===null||i(a))&&e.add(a)}}aA(t,i,e,s,n,o){if(this.pickable===!1)return!1;e===void 0&&(e=null),s===void 0&&(s=null);const r=this.naturalBounds,l=this.kn(),h=l?t:Point.H(t.x,t.y).Ye(this.O),a=l?i:Point.H(i.x,i.y).Ye(this.O),f=h.distanceSquaredPoint(a),c=h.x>0&&h.x0&&h.yS.width||b.y>S.height||b.x+b.width<0||b.y+b.height<0))continue;if(k.kn()){const C=k.O;d.set(t).Ye(C),m.set(i).Ye(C)}else d.set(t),m.set(i);let M=k;const A=k instanceof Panel?k:null;(A!==null?A.aA(d,m,e,s,n,o):M.lL(d,m,n))&&(e!==null&&(M=e(M)),M!==null&&(s===null||s(M))&&o.add(M))}Point.o(d),Point.o(m)}return n?c:u}return!1}R2(t){let i=null;if(t instanceof Shape){i=t.spot1,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot1)}return i===null&&(i=Spot.TopLeft),i}I2(t){let i=null;if(t instanceof Shape){i=t.spot2,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot2)}return i===null&&(i=Spot.BottomRight),i}add(...t){for(let i=0;i=s.count&&t>=s.count)return;s.removeAt(r),n=r}else Util.n("element "+i.toString()+" has panel "+e.toString()+" but is not contained by it.")}(t<0||t>s.count)&&(t=s.count),s.insertAt(t,i),(t===0||i.isPanelMain)&&(this.ll=null),this.Xo()||this.u(),i.u(!1),i.portId!==null?this.Mn=!0:i instanceof Panel&&i.Mn===!0&&(this.Mn=!0),this.as=null,this.isEnabledObject()||this.ob(i,!1);const o=this.part;if(o!==null){o.V0(),o.pc(),this.Mn&&o instanceof Node&&(o.Mn=!0),o.Mn&&o instanceof Node&&(o.ae=null);const r=this.diagram;if(r!==null&&r.undoManager.isUndoingRedoing)return;n!==-1&&o.raiseChangedEvent(4,"elements",this,i,null,n,null),o.raiseChangedEvent(3,"elements",this,null,i,null,t)}}get Mn(){return(this.l&8388608)!==0}set Mn(t){(this.l&8388608)!==0!==t&&(this.l=this.l^8388608)}u2(){return(this.l&16777216)!==0}X2(t){t?this.l|=16777216:this.l&=-16777217}gI(t){t.Pa(this),t.sl=null;const i=this.D,e=i.count;i.insertAt(e,t);const s=this.part;if(s!==null){s.V0(),t.portId!==null&&s instanceof Node&&(s.Mn=!0);const n=this.diagram;if(n!==null&&n.undoManager.isUndoingRedoing)return;s.raiseChangedEvent(3,"elements",this,null,t,null,e)}}ER(t){const i=this.D.h,e=i.length;let s=-1;for(let n=0;n=0&&this.oe(t,!0)}oe(t,i){const e=this.D,s=e.elt(t);if(s.sl=null,s.Pa(null),this.vs!==null){const o=s.data;typeof o=="object"&&this.vs.delete(o)}e.removeAt(t),this.ye(!1),this.u(),this.ll===s&&(this.ll=null),this.as=null;const n=this.part;if(n!==null){n.V0(),n.pc(),n.invalidateAdornments(),n instanceof Node&&(s instanceof Panel?s.walkVisualTreeFrom(s,(r,l)=>n.S2(l,i)):n.S2(s,i));const o=this.diagram;if(o!==null&&o.undoManager.isUndoingRedoing)return;n.raiseChangedEvent(4,"elements",this,s,null,t,null)}}get ve(){return this.V===null&&(this.V=new TablePanelSettings),this.V.ve}get rowCount(){return this.V===null?0:this.ve.length}getRowDefinition(t){Debug&&Util.r(t,Panel,"getRowDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"getRowDefinition:idx"),t=Math.round(t);const i=this.ve;if(i[t]===void 0){const e=new RowColumnDefinition;e.Pa(this),e.isRow=!0,e.index=t,i[t]=e,this.raiseChangedEvent(3,"rowdefs",this,null,e,null,t)}return i[t]}removeRowDefinition(t){if(Debug&&Util.r(t,Panel,"removeRowDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"removeRowDefinition:idx"),this.rowCount===0)return;t=Math.round(t);const i=this.ve,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"rowdefs",this,e,null,t,null),this.u()}}VA(t,i){const e=this.ve;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.u()}}get Je(){return this.V===null&&(this.V=new TablePanelSettings),this.V.Je}get columnCount(){return this.V===null?0:this.Je.length}getColumnDefinition(t){Debug&&Util.r(t,Panel,"getColumnDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"getColumnDefinition:idx"),t=Math.round(t);const i=this.Je;if(i[t]===void 0){const e=new RowColumnDefinition;e.Pa(this),e.isRow=!1,e.index=t,i[t]=e,this.raiseChangedEvent(3,"coldefs",this,null,e,null,t)}return i[t]}removeColumnDefinition(t){if(Debug&&Util.r(t,Panel,"removeColumnDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"removeColumnDefinition:idx"),this.columnCount===0)return;t=Math.round(t);const i=this.Je,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"coldefs",this,e,null,t,null),this.u()}}zA(t,i){const e=this.Je;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.u()}}addRowColumnDefinition(t){let i=null;return t.isRow?i=this.getRowDefinition(t.index):t.isRow||(i=this.getColumnDefinition(t.index)),i&&i.Z1(t),this}addRowDefinition(t,i){const e=this.getRowDefinition(t);return e&&e.Z1(new RowColumnDefinition(i)),this}addColumnDefinition(t,i){const e=this.getColumnDefinition(t);return e&&e.Z1(new RowColumnDefinition(i)),this}get rowSizing(){return this.V!==null?this.V.wp:3}set rowSizing(t){const i=this.rowSizing;i!==t&&(Debug&&t!==3&&t!==2&&Util.n("Panel.rowSizing must be ProportionalExtra or None, not: "+t),this.V===null&&(this.V=new TablePanelSettings),this.V.wp=t,this.u(),this.i("rowSizing",i,t))}get columnSizing(){return this.V!==null?this.V.xp:3}set columnSizing(t){const i=this.columnSizing;i!==t&&(Debug&&t!==3&&t!==2&&Util.n("Panel.columnSizing must be ProportionalExtra or None, not: "+t),this.V===null&&(this.V=new TablePanelSettings),this.V.xp=t,this.u(),this.i("columnSizing",i,t))}get topIndex(){return this.V!==null?this.V.bp:0}set topIndex(t){const i=this.topIndex;i!==t&&((!isFinite(t)||t<0)&&Util.n("Panel.topIndex must be greater than zero and a real number, not: "+t),this.V===null&&(this.V=new TablePanelSettings),this.V.bp=t,this.u(),this.i("topIndex",i,t))}get leftIndex(){return this.V!==null?this.V.kp:0}set leftIndex(t){const i=this.leftIndex;i!==t&&((!isFinite(t)||t<0)&&Util.n("Panel.leftIndex must be greater than zero and a real number, not: "+t),this.V===null&&(this.V=new TablePanelSettings),this.V.kp=t,this.u(),this.i("leftIndex",i,t))}findRowForLocalY(t){if(t<0||this.type!==Panel.Table||this.rowCount===0)return-1;let i=0;const e=this.ve,s=e.length;let n=this.topIndex;for(;n{o.ch();const r=o.Ri;if(r!==null){o.w2(!1);const l=r.iterator;for(;l.next();){const h=l.value;h.mode===2&&o.w2(!0);const a=h.sourceName;if(h.isToObject){a==="/"&&n.X2(!0);const f=h.oL(n,o);f!==null&&(i.add(f),f.so===null&&(f.so=new List),f.so.add(h))}t.add(h)}}if(o instanceof Panel&&o.type===Panel.Table){if(o.rowCount>0){const l=o.ve,h=l.length;for(let a=0;a0){const l=o.Je,h=l.length;for(let a=0;a0&&o instanceof Panel){const h=r.substring(0,l),a=r.substring(l+1),f=o.findObject(h);f!==null?(o=f,n.targetProperty=a):(Util.ht('Warning: unable to find GraphObject named "'+h+'" for Binding: '+n.toString()),o=null)}if(o instanceof RowColumnDefinition){const h=GSet.gs(o.panel);n.targetId=h===void 0?-1:h,o.panel.eo=n.targetId}else if(o instanceof GraphObject){const h=GSet.gs(o);n.targetId=h===void 0?-1:h,o.eo=n.targetId}else Util.n("Unknown type of binding target: "+o);n.check(o)}}return t.w(),this instanceof Part&&(this.Ae()&&this.ensureBounds(),Debug&&!Panel.RL&&this.walkVisualTreeFrom(this,(n,o)=>{if(o instanceof Panel&&(o.type===Panel.Auto||o.type===Panel.Spot||o.type===Panel.Graduated)&&o.elements.count<=1&&!(o instanceof Part)){let r=!1;if(o.elements.count===1&&(r=o.itemArray!==null,!r)){for(s=t.iterator;s.next();)if(s.value.targetProperty==="itemArray"){r=!0;break}}r||(Util.ht("Auto, Spot, or Graduated Panel should not have zero or one elements: "+o.toString()+" in "+n.toString()),Panel.RL=!0)}})),this}static RL=!1;copyTemplate(t){t===void 0&&(t=!1);const i=this.copy();return i.mI(e=>{e instanceof Panel&&(e.Ws=null,e.si=null);const s=e.Ri;s!==null&&(e.Ri=null,s.each(o=>e.bind(o.copy())));const n=e.Ss;n!==null&&(e.Ss=null,n.each(o=>e.trigger(o.value.copy())))}),t&&i.ci(),i}updateTargetBindings(t){const i=this.Ws;if(i===null)return;t===void 0&&(t="");const e=i.iterator;for(;e.next();){const s=e.value,n=this.IL(s,t);if(n===null)continue;const{data:o,elt:r}=n;s.isToTheme&&this.diagram===null||r!==void 0&&s.updateTarget(r,o)}}Yo(){if(this.diagram!==null)if(this.M2()){const t=this.Ws.iterator;for(;t.next();){const i=t.value;if(!i.isToTheme)continue;const e=this.IL(i);if(e===null)continue;const{data:s,elt:n}=e;n!==void 0&&i.updateTarget(n,s)}}else{const t=this.D.h,i=t.length;for(let e=0;e0;let r=0;for(;n0){const i=this.D.elt(0);if(i.isPanelMain&&i instanceof Panel&&i.nl())return 1}return 0}rebuildItemElements(){const t=this.yp();for(;this.D.length>t;)this.oe(this.D.length-1,!1);this.OL(null,this.itemArray)}OL(t,i){const e=this.yp(),s=i;if(s===null||s.length===0){for(;this.D.length>e;)this.oe(this.D.length-1,!1);return}if(this.D.length<=e){const n=s.length;for(let o=0;o(w[w.Default=1]="Default",w[w.None=2]="None",w[w.ProportionalExtra=3]="ProportionalExtra",w))(Sizing||{});class RowColumnDefinition{Hs;Sp;Bt;La;Ta;ai;gt;Sd;ro;Jo;Md;Pd;Da;Ft;Nd;Js;lt;Zi;xe;constructor(t){GSet.vi(this),this.Hs=null,this.Sp=!0,this.Bt=0,this.xe=NaN,this.La=0,this.Ta=1/0,this.ai=Spot.Default,this.lt=0,this.Zi=0,this.gt=0,this.Js=null,this.Sd=1,this.ro=1,this.Jo=null,this.Md=null,this.Pd=NaN,this.Da=null,this.Ft=null,this.Nd=!1,t&&(Object.assign(this,t),t.column!==void 0?(this.isRow=!1,this.index=t.column):t.row!==void 0&&(this.isRow=!0,this.index=t.row))}copy(){const t=new RowColumnDefinition;return t.Sp=this.Sp,t.Bt=this.Bt,t.xe=this.xe,t.La=this.La,t.Ta=this.Ta,t.ai=this.ai,t.lt=this.lt,t.Zi=this.Zi,t.gt=this.gt,t.ro=this.ro,t.Sd=this.Sd,this.Jo===null?t.Jo=null:t.Jo=this.Jo.L(),t.Md=this.Md,t.Pd=this.Pd,t.Da=null,this.Da!==null&&(t.separatorDashArray=this.separatorDashArray.slice()),t.Ft=this.Ft,t.Nd=this.Nd,t.Js=this.Js,t}Z1(t){t.isRow?this.height=t.height:this.width=t.width,this.minimum=t.minimum,this.maximum=t.maximum,this.alignment=t.alignment,this.stretch=t.stretch,this.sizing=t.sizing,this.Jo=t.separatorPadding===null?null:t.separatorPadding.L(),this.separatorStroke=t.separatorStroke,this.separatorStrokeWidth=t.separatorStrokeWidth,this.Da=null,t.separatorDashArray&&(this.Da=t.separatorDashArray.slice()),this.background=t.background,this.coversSeparators=t.coversSeparators,this.Js=t.Js}fi(t){t in Sizing?this.sizing=t:Util.ur(this,t)}toString(){return"RowColumnDefinition "+(this.isRow?"(Row ":"(Column ")+this.index+") #"+GSet.gs(this)}static Default=1;static None=2;static ProportionalExtra=3;Pa(t){this.Hs=t}computeEffectiveSpacingTop(t){let i=0;const e=this.Hs;if(this.index!==t){let n=this.separatorStroke;n===null&&e!==null&&(n=this.isRow?e.defaultRowSeparatorStroke:e.defaultColumnSeparatorStroke),n!==null&&(i=this.separatorStrokeWidth,isNaN(i)&&(e!==null?i=this.isRow?e.defaultRowSeparatorStrokeWidth:e.defaultColumnSeparatorStrokeWidth:i=0))}let s=this.Jo;if(s===null)if(e!==null)s=e.defaultSeparatorPadding;else return i;return i+(this.isRow?s.top:s.left)}computeEffectiveSpacing(){let t=0;const i=this.Hs;let e=0;const s=this.isRow;if(i!==null&&i.type===Panel.Table){const o=s?i.ve.length:i.Je.length;for(let r=0;r= 0",RowColumnDefinition,"height"),this.xe=t,this.actual=this.lt,this.panel!==null&&this.panel.u(),this.i("height",i,t))}get width(){return this.xe}set width(t){const i=this.xe;i!==t&&(Debug&&Util.t(t,"number",RowColumnDefinition,"width"),t<0&&Util.G(t,">= 0",RowColumnDefinition,"width"),this.xe=t,this.actual=this.lt,this.panel!==null&&this.panel.u(),this.i("width",i,t))}get minimum(){return this.La}set minimum(t){const i=this.La;i!==t&&(Debug&&Util.t(t,"number",RowColumnDefinition,"minimum"),(t<0||!isFinite(t))&&Util.G(t,">= 0",RowColumnDefinition,"minimum"),this.La=t,this.actual=this.lt,this.panel!==null&&this.panel.u(),this.i("minimum",i,t))}get maximum(){return this.Ta}set maximum(t){const i=this.Ta;i!==t&&(Debug&&Util.t(t,"number",RowColumnDefinition,"maximum"),t<0&&Util.G(t,">= 0",RowColumnDefinition,"maximum"),this.Ta=t,this.actual=this.lt,this.panel!==null&&this.panel.u(),this.i("maximum",i,t))}get alignment(){return this.ai}set alignment(t){const i=this.ai;i.equals(t)||(Debug&&Util.s(t,Spot,RowColumnDefinition,"alignment"),this.ai=t.L(),this.panel!==null&&this.panel.u(),this.i("alignment",i,t))}get stretch(){return this.ro}set stretch(t){const i=this.ro;i!==t&&(this.ro=t,this.panel!==null&&this.panel.u(),this.i("stretch",i,t))}get separatorPadding(){return this.Jo}set separatorPadding(t){typeof t=="number"?t=new Margin(t):t!==null&&Debug&&Util.s(t,Margin,RowColumnDefinition,"separatorPadding");const i=this.Jo;(t===null||i===null||!i.equals(t))&&(t!==null&&(t=t.L()),this.Jo=t,this.panel!==null&&this.panel.u(),this.i("separatorPadding",i,t))}get separatorStroke(){return this.Md}set separatorStroke(t){const i=this.Md;i!==t&&(t!==null&&Brush.cd(t,"RowColumnDefinition.separatorStroke"),t instanceof Brush&&t.w(),this.Md=t,this.panel!==null&&this.panel.u(),this.i("separatorStroke",i,t))}get separatorStrokeWidth(){return this.Pd}set separatorStrokeWidth(t){const i=this.Pd;i!==t&&(this.Pd=t,this.panel!==null&&this.panel.u(),this.i("separatorStrokeWidth",i,t))}get separatorDashArray(){return this.Da}set separatorDashArray(t){const i=this.Da;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Bi(t,"Array",RowColumnDefinition,"separatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("separatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.Da=t,this.panel!==null&&this.panel.T(),this.i("separatorDashArray",i,t)}}get background(){return this.Ft}set background(t){const i=this.Ft;i!==t&&(t!==null&&Brush.cd(t,"RowColumnDefinition.background"),t instanceof Brush&&t.w(),this.Ft=t,this.panel!==null&&this.panel.T(),this.i("background",i,t))}get coversSeparators(){return this.Nd}set coversSeparators(t){const i=this.Nd;i!==t&&(Util.t(t,"boolean",RowColumnDefinition,"coversSeparators"),this.Nd=t,this.panel!==null&&this.panel.T(),this.i("coversSeparators",i,t))}get sizing(){return this.Sd}set sizing(t){const i=this.Sd;i!==t&&(Debug&&Util.tt(t,Sizing,"Sizing"),this.Sd=t,this.panel!==null&&this.panel.u(),this.i("sizing",i,t))}eb(){if(this.sizing===1){const t=this.Hs;return this.isRow?t.rowSizing:t.columnSizing}return this.sizing}get actual(){return this.lt}set actual(t){isNaN(this.xe)?this.lt=Math.max(Math.min(this.Ta,t),this.La):this.lt=Math.max(Math.min(this.Ta,this.xe),this.La)}get measured(){return this.Zi}set measured(t){this.Zi=t}get total(){return this.lt+this.computeEffectiveSpacing()}get position(){return this.gt}set position(t){this.gt=t}bind(t,i,e,s){return this.ac(t,i,e,s),this}bindTwoWay(t,i,e,s){const n=this.ac(t,i,e,s);return s===void 0&&n.makeTwoWay(),this}theme(t,i,e,s,n){return this.ph(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.ph(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.ph(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.ph(t,i,e,s,n).ofModel(),this}ac(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.$0(n),n}ph(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.$0(o),o}$0(t){t.Ce=this;const i=this.panel;if(i!==null){const e=i.findBindingPanel();e!==null&&e.yL()&&Util.n("Cannot add a Binding to a RowColumnDefinition that is already frozen: "+t+" on "+i)}this.Js===null&&(this.Js=new List),this.Js.add(t)}}class Shape extends GraphObject{mt;Ps;Cd;Fa;$i;Zo;jo;Rt;Ad;Ld;_;constructor(t,i){super(),this.mt=null,this.Ps=null,this.Cd="None",this.Fa="black",this.$i="black",this.Zo=1,this.jo=null,this.Rt=null,this.Ad=NaN,this.Ld=NaN,this._=null,typeof t=="string"?this.figure=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.mt=this.mt,t.Ps=this.Ps,t.Cd=this.Cd,t.Fa=this.Fa,t.$i=this.$i,t.Zo=this.Zo,this.jo!==null&&(t.jo=this.jo.slice()),this.Rt!==null&&(this.Rt.wi?t.Rt=this.Rt:t.Rt=this.Rt.copy()),t.Ad=this.Ad,t.Ld=this.Ld,this._!==null&&(t._=this._.copy())}Ra(){this.Rt===null?this.Rt=new ShapeTemplateSettings:this.Rt.wi&&(this.Rt=this.Rt.copy())}ch(){super.ch(),this.Rt!==null&&(this.Rt.wi=!0)}fi(t){t in GeometryStretch?this.geometryStretch=t:super.fi(t)}toString(){return"Shape("+(this.figure!=="None"?this.figure:this.toArrow!=="None"?this.toArrow:this.fromArrow)+")#"+GSet.gs(this)}SI(t,i){const e=this.pathPattern;e.wt(1/0,1/0);const s=e.measuredBounds;e.qt(0,0,s.width,s.height);const n=this.geometry;t.save(),t.beginPath();const o=Util.at();if(n.type===1)o.push(n.startX),o.push(n.startY),o.push(n.endX),o.push(n.endY),this.Td(t,i,o,e);else if(n.type===4){const r=n.figures.iterator;for(;r.next();){const l=r.value;o.length=0,o.push(l.startX),o.push(l.startY);let h=l.startX,a=l.startY,f=h,c=a;const u=l.segments.h,d=u.length;for(let m=0;m=.1;){if(P===0&&(M?(b=k,b-=S,y-=S,M=!1):b=k,b===0&&(b=1)),b>y){b=y,Util.nt(x);return}b>p?(P=b-p,b=p):P=0;let N=Math.sqrt(b*b/(1+m*m));if(u<0&&(N=-N),h+=N,a+=m*N,t.translate(h,a),t.rotate(g),t.translate(-(r/2),-(l/2)),P===0&&s.mh(t,i),t.translate(r/2,l/2),t.rotate(-g),t.translate(-h,-a),y-=b,p-=b,P!==0){if(A++,A===x.length){Util.nt(x);return}C=x[A],u=C[0],g=C[1],m=C[2],p=C[3],b=P}}Util.nt(x)}mh(t,i){const e=t instanceof SVGContext;let s=this.$i;const n=this.Fa;if(s===null&&n===null)return;const o=this.mt;if(o===null)return;t.commitTransform();const r=this.actualBounds,l=this.naturalBounds;n!==null&&this.wn(t,n,!0,!1,l,r);const h=this.part;let a=this.Zo;s!==null&&a===0&&h!==null&&(this.isPanelMain||h.findMainElement()===this)&&(a=h.NI()),a===0&&(s=null),s!==null&&a!==0&&(this.wn(t,s,!1,!1,l,r),t.lineWidth=a,t.lineJoin=this.strokeJoin,t.lineCap=this.strokeCap,t.miterLimit=this.strokeMiterLimit);let f=!1;h&&i.getRenderingHint("drawShadows")&&(f=h.isShadowed),t.ol===!1&&(f=!1);let c=!0;s!==null&&(n===null||n==="transparent")&&(c=!1);let u=!1;const d=this.strokeDashArray;if(d!==null&&(u=!0,t.enableDash(d,this.strokeDashOffset)),o.type===1)t.beginPath(),t.moveTo(o.startX,o.startY),t.lineTo(o.endX,o.endY),s!==null&&t.strokeContext(),t.endPath();else if(o.type===2){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.min(m,p),k=Math.min(g,y),b=Math.abs(p-m),S=Math.abs(y-g);t.beginPath(),t.rect(x,k,b,S),n!==null&&t.fillContext(n,!1,null),s!==null&&(c&&f&&t.shadowsOff(),t.strokeContext(),c&&f&&t.shadowsOn()),t.endPath()}else if(o.type===3){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.abs(p-m)/2,k=Math.abs(y-g)/2,b=Math.min(m,p)+x,S=Math.min(g,y)+k;t.beginPath(),t.moveTo(b,S-k),t.bezierCurveTo(b+Geo.Un*x,S-k,b+x,S-Geo.Un*k,b+x,S),t.bezierCurveTo(b+x,S+Geo.Un*k,b+Geo.Un*x,S+k,b,S+k),t.bezierCurveTo(b-Geo.Un*x,S+k,b-x,S+Geo.Un*k,b-x,S),t.bezierCurveTo(b-x,S-Geo.Un*k,b-Geo.Un*x,S-k,b,S-k),t.closePath(),n!==null&&t.fillContext(n,!1,null),s!==null&&(c&&f&&t.shadowsOff(),t.strokeContext(),c&&f&&t.shadowsOn()),t.endPath()}else if(o.type===4){const m=o.figures,g=m.length;for(let p=0;p1||this.pathPattern!==null?!0:super.ad(t)}m2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("path");for(let s=0;s1,i);Util.n("Unknown Geometry type: "+e.type)}}rd(t,i,e,s){const n=this.desiredSize,o=this.Zo;t=Math.max(t,0),i=Math.max(i,0);let r;if(this.Ps!==null)r=this.geometry.bounds;else{const g=this.figure;let p=Shape.G2[g];if(p===void 0){let y=Geo.qn[g];typeof y=="string"&&(y=Geo.qn[y]),typeof y=="function"?(p=y(null,100,100),Shape.G2[g]=p):Util.n("Unsupported Figure: "+g)}r=p.bounds}let l=r.width,h=r.height,a=r.width,f=r.height;switch(this.qs(!0)){case 0:e=0,s=0;break;case 2:a=Math.max(t-o,0),f=Math.max(i-o,0);break;case 5:a=Math.max(t-o,0),s=0;break;case 4:e=0,f=Math.max(i-o,0);break}isFinite(n.width)&&(a=n.width),isFinite(n.height)&&(f=n.height);const u=this.maxSize,d=this.minSize;e=Math.max(e-o,d.width),s=Math.max(s-o,d.height),a=Math.min(u.width,a),f=Math.min(u.height,f),a=isFinite(a)?Math.max(e,a):Math.max(l,e),f=isFinite(f)?Math.max(s,f):Math.max(h,s);const m=this.lM();switch(m){case 0:break;case 2:l=a,h=f;break;case 6:{let g=Math.min(a/l,f/h);isFinite(g)||(g=1),l=l*g,h=h*g;break}default:Util.n(m+" is not a valid geometryStretch.")}if(this.Ps!==null){l===0&&(l=.001),h===0&&(h=.001);const p=(this.Ps!==null?this.Ps:this.mt).ZD(l,h);Debug&&p.w(),this.mt=p}else(this.mt===null||!Geo.q(this.mt.cf,t-o)||!Geo.q(this.mt.uf,i-o))&&(this.mt=Shape.CI(this,l,h));r=this.mt.bounds,t===1/0||i===1/0?this.no(r.x-o/2,r.y-o/2,t===0&&l===0?0:r.width+o,i===0&&h===0?0:r.height+o):this.no(-(o/2),-(o/2),a+o,f+o),n.isReal()?(a=n.width,f=n.height,a=Math.min(u.width,a),f=Math.min(u.height,f),a=Math.max(d.width,a),f=Math.max(d.height,f),this.Hi.e(0,0,a,f)):this.Hi.c(r)}lM(){const t=this.geometryStretch;return this.Ps!==null?t===1?2:t:t===1?Shape.G2[this.figure].defaultStretch:t}dh(t,i,e,s){this.commonArrange(t,i,e,s)}getNearestIntersectionPoint(t,i,e){return this.nc(t.x,t.y,i.x,i.y,e)}nc(t,i,e,s,n){const o=this.O,r=1/(o.m11*o.m22-o.m12*o.m21),l=o.m22*r,h=-o.m12*r,a=-o.m21*r,f=o.m11*r,c=r*(o.m21*o.dy-o.m22*o.dx),u=r*(o.m12*o.dx-o.m11*o.dy),d=t*l+i*a+c,m=t*h+i*f+u,g=e*l+s*a+c,p=e*h+s*f+u,y=this.Zo/2;let x=this.mt;x===null&&(this.wt(1/0,1/0),x=this.mt);const k=x.bounds;let b=!1;if(x.type===1)if(this.strokeWidth<=1.5)b=Geo.Hn(x.startX,x.startY,x.endX,x.endY,d,m,g,p,n);else{let S=0,M=0;if(x.startX===x.endX)S=y,M=0;else{const T=(x.endY-x.startY)/(x.endX-x.startX);M=y/Math.sqrt(1+T*T),S=M*T}const A=Util.at();let C=new Point;Geo.Hn(x.startX+S,x.startY+M,x.endX+S,x.endY+M,d,m,g,p,C)&&A.push(C),C=new Point,Geo.Hn(x.startX-S,x.startY-M,x.endX-S,x.endY-M,d,m,g,p,C)&&A.push(C),C=new Point,Geo.Hn(x.startX+S,x.startY+M,x.startX-S,x.startY-M,d,m,g,p,C)&&A.push(C),C=new Point,Geo.Hn(x.endX+S,x.endY+M,x.endX-S,x.endY-M,d,m,g,p,C)&&A.push(C);const P=A.length;if(P===0)return Util.nt(A),!1;b=!0;let N=1/0;for(let T=0;T0&&k.contains(D,F)&&(P.x=D,P.y=F,this.containsPoint(P)))for(N!==0&&Math.abs(N)<.5?(T*=.5/N,N=.5):T!==0&&Math.abs(T)<.5&&(N*=.5/T,T=.5),D-=N,F-=T;k.contains(D,F);)D-=N,F-=T;const R=.6;n.x=g,n.y=p;for(let K=0;Ke?t-e:e-t)<(i>s?i-s:s-i)){const c=ic||Geo.q(h.y,c))&&(h.yc||Geo.q(h.x,c))&&(h.x=a&&h<=f}else{let a=0,f=0;return s=a&&l<=f}}TI(t,i){if(this.containedInRect(t,i)||i===void 0&&(i=this.O,t.containsRect(this.actualBounds)))return!0;const e=t.left,s=t.right,n=t.top,o=t.bottom,r=Point.a(),l=Point.a(),h=Point.a(),a=Transform.a();a.set(i),a.mC(this.O),a.Pw(),l.x=s,l.y=n,l.O(a),r.x=e,r.y=n,r.O(a);let f=!1;return this.Ia(r,l,h)?f=!0:(r.x=s,r.y=o,r.O(a),this.Ia(r,l,h)?f=!0:(l.x=e,l.y=o,l.O(a),this.Ia(r,l,h)?f=!0:(r.x=e,r.y=n,r.O(a),this.Ia(r,l,h)&&(f=!0)))),Transform.o(a),Point.o(r),Point.o(l),Point.o(h),f}lL(t,i,e){if(e&&this.fill!==null&&this.uh(t,!0))return!0;let s=t.distanceSquaredPoint(i);const n=s;this.strokeWidth>1.5&&(s=this.strokeWidth/2+Math.sqrt(s),s*=s);let o=this.mt;if(o===null&&(this.wt(1/0,1/0),o=this.mt,o===null))return!1;if(!e){const c=o.bounds,u=c.x,d=c.y,m=c.x+c.width,g=c.y+c.height;if(Point.distanceSquared(t.x,t.y,u,d)<=s&&Point.distanceSquared(t.x,t.y,m,d)<=s&&Point.distanceSquared(t.x,t.y,u,g)<=s&&Point.distanceSquared(t.x,t.y,m,g)<=s)return!0}function r(c,u){const d=c.length;for(let m=0;ms)return!0;return!1}const l=o.startX,h=o.startY,a=o.endX,f=o.endY;if(o.type===1){const c=Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,f),u=(a-l)*(t.x-l)+(f-h)*(t.y-h),d=(l-a)*(t.x-a)+(h-f)*(t.y-f),m=u>=0&&d>=0?s:n;return c<=m}else if(o.type===2){let c=!1;return e&&(c=Point.distanceLineSegmentSquared(t.x,t.y,l,h,l,f)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,h)<=s||Point.distanceLineSegmentSquared(t.x,t.y,a,h,a,f)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,f,a,f)<=s),c}else if(o.type===3){const c=(l+a)/2,u=(h+f)/2,d=t.x-c,m=t.y-u,g=Math.abs(a-l)/2,p=Math.abs(f-h)/2;if(g===0||p===0)return Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,f)<=s;if(e){const y=Geo.KD(g,p,d,m);return y*y<=s}else return!(Point.distanceSquared(d,m,-g,0)>=s||Point.distanceSquared(d,m,0,-p)>=s||Point.distanceSquared(d,m,0,p)>=s||Point.distanceSquared(d,m,g,0)>=s)}else if(o.type===4){const c=o.bounds,u=c.x,d=c.y,m=c.x+c.width,g=c.y+c.height;if(t.x>m&&t.xg&&t.ys&&Point.distanceLineSegmentSquared(t.x,t.y,u,d,m,d)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,u,g)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,m,d)>s)return!1;const p=Math.sqrt(s);if(e){if(this.fill===null?o.CC(t.x,t.y,p):o.vk(t,p,!0,!1))return!0}else{const y=o.figures;for(let x=0;xs)return!1;const M=k.segments.h,A=M.length;for(let C=0;Cs)return!1;break;case 3:{const N=Util.at();Geo.Gn(b,S,P.point1X,P.point1Y,P.point2X,P.point2Y,P.endX,P.endY,.8,N);const T=r(N,t);if(Util.nt(N),T||(b=P.endX,S=P.endY,t.distanceSquared(b,S)>s))return!1;break}case 4:{const N=Util.at();Geo.qg(b,S,P.point1X,P.point1Y,P.endX,P.endY,.8,N);const T=r(N,t);if(Util.nt(N),T||(b=P.endX,S=P.endY,t.distanceSquared(b,S)>s))return!1;break}case 5:case 6:{const N=P.type===5?P.To(k):P.Yh(k,b,S),T=N.length;if(T===0){if(b=P.type===5?P.centerX:P.endX,S=P.type===5?P.centerY:P.endY,t.distanceSquared(b,S)>s)return!1;break}let L=null;const D=Util.at();for(let F=0;F=0){this.Zo=t,this.u();const e=this.part;e!==null&&e.pc(),this.i("strokeWidth",i,t)}else Util.G(t,"value >= 0",Shape,"strokeWidth:value")}N0(){return this.Zo}get strokeCap(){return this.Rt!==null?this.Rt.Mp:"butt"}set strokeCap(t){const i=this.strokeCap;i!==t&&(typeof t=="string"&&(t==="butt"||t==="round"||t==="square")?(this.Ra(),this.Rt.Mp=t,this.T(),this.i("strokeCap",i,t)):Util.G(t,'"butt", "round", or "square"',Shape,"strokeCap"))}get strokeJoin(){return this.Rt!==null?this.Rt.Pp:"miter"}set strokeJoin(t){const i=this.strokeJoin;i!==t&&(typeof t=="string"&&(t==="miter"||t==="bevel"||t==="round")?(this.Ra(),this.Rt.Pp=t,this.T(),this.i("strokeJoin",i,t)):Util.G(t,'"miter", "bevel", or "round"',Shape,"strokeJoin"))}get strokeMiterLimit(){return this.Rt!==null?this.Rt.Np:10}set strokeMiterLimit(t){const i=this.strokeMiterLimit;if(i!==t)if(Debug&&Util.r(t,Shape,"strokeMiterLimit"),t>=1){this.Ra(),this.Rt.Np=t,this.T();const e=this.part;e!==null&&e.pc(),this.i("strokeMiterLimit",i,t)}else Debug&&Util.G(t,"value >= 1",Shape,"strokeWidth:value")}get strokeDashArray(){return this.jo}set strokeDashArray(t){const i=this.jo;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Bi(t,"Array",Shape,"strokeDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("strokeDashArray:value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.jo=t,this.T(),this.i("strokeDashArray",i,t)}}get strokeDashOffset(){return this.Rt!==null?this.Rt.yh:0}set strokeDashOffset(t){const i=this.strokeDashOffset;i!==t&&(Debug&&Util.r(t,Shape,"strokeDashOffset"),t>=0&&(this.Ra(),this.Rt.yh=t,this.T(),this.i("strokeDashOffset",i,t)))}get figure(){return this.Cd}set figure(t){const i=this.Cd;if(i!==t){Debug&&Util.t(t,"string",Shape,"figure");let e=Geo.qn[t];if(typeof e=="function"?e=t:(e=Geo.qn[t.toLowerCase()],e||Util.n("Unknown Shape.figure: "+t)),i!==e){const s=this.part;s!==null&&s.pc(),this.Cd=e,this.Ps=null,this.le(),this.u(),this.i("figure",i,e)}}}get toArrow(){return this.Ut!==null?this.Ut.Cp:"None"}set toArrow(t){const i=this.toArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){Debug&&Util.t(t,"string",Shape,"toArrow");const e=Shape.VL(t);e===null?Util.n("Unknown Shape.toArrow: "+t):i!==e&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.Cp=e,this.Ps=null,this.le(),this.u(),this.zL(e),this.i("toArrow",i,e))}}get fromArrow(){return this.Ut!==null?this.Ut.Ap:"None"}set fromArrow(t){const i=this.fromArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){Debug&&Util.t(t,"string",Shape,"fromArrow");const e=Shape.VL(t);e===null?Util.n("Unknown Shape.fromArrow: "+t):i!==e&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.Ap=e,this.Ps=null,this.le(),this.u(),this.zL(e),this.i("fromArrow",i,e))}}zL(t){const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;this.YR();const e=Spot.MiddleRight;this.toArrow!=="None"?(this.segmentIndex=-1,this.alignmentFocus=e):this.fromArrow!=="None"&&(this.segmentIndex=0,this.alignmentFocus=new Spot(1-e.x,e.y))}get spot1(){return this.Rt!==null?this.Rt.jn:Spot.Default}set spot1(t){Util.s(t,Spot,Shape,"spot1");const i=this.spot1;i.equals(t)||(t=t.L(),this.Ra(),this.Rt.jn=t,this.u(),this.i("spot1",i,t))}get spot2(){return this.Rt!==null?this.Rt.Wn:Spot.Default}set spot2(t){Util.s(t,Spot,Shape,"spot2");const i=this.spot2;i.equals(t)||(t=t.L(),this.Ra(),this.Rt.Wn=t,this.u(),this.i("spot2",i,t))}get parameter1(){return this.Ad}set parameter1(t){const i=this.Ad;i!==t&&(this.Ad=t,this.le(),this.u(),this.i("parameter1",i,t))}get parameter2(){return this.Ld}set parameter2(t){const i=this.Ld;i!==t&&(this.Ld=t,this.le(),this.u(),this.i("parameter2",i,t))}get naturalBounds(){return this.Hi}rI(){const t=this.desiredSize;if(!t.isReal()&&this.mt!==null){const i=this.mt.bounds;this.Hi.c(i)}else this.Hi.e(0,0,t.width,t.height)}get pathPattern(){return this.Rt!==null?this.Rt.Lp:null}set pathPattern(t){const i=this.pathPattern;i!==t&&(Debug&&t!==null&&Util.s(t,GraphObject,Shape,"pathPattern"),this.Ra(),this.Rt.Lp=t,this.T(),this.i("pathPattern",i,t))}get geometryStretch(){return this.Rt!==null?this.Rt.Tp:1}set geometryStretch(t){const i=this.geometryStretch;i!==t&&(Util.tt(t,GeometryStretch,"GeometryStretch"),this.Ra(),this.Rt.Tp=t,this.u(),this.i("geometryStretch",i,t))}get interval(){return this._!==null?this._.wc:1}set interval(t){const i=this.interval;if(Debug&&Util.r(t,Shape,"interval"),t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this._===null&&(this._=new GradElementSettings),this._.wc=t;const e=this.diagram;e!==null&&this.panel===e.grid&&e.Zr(),this.u();const s=this.panel;s!==null&&(s.as=null),this.i("interval",i,t)}}get graduatedStart(){return this._!==null?this._.xc:0}set graduatedStart(t){const i=this.graduatedStart;Debug&&Util.r(t,Shape,"graduatedStart"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.xc=t,this.u(),this.i("graduatedStart",i,t))}get graduatedEnd(){return this._!==null?this._.bc:1}set graduatedEnd(t){const i=this.graduatedEnd;Debug&&Util.r(t,Shape,"graduatedEnd"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.bc=t,this.u(),this.i("graduatedEnd",i,t))}get graduatedSkip(){return this._!==null?this._.kc:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.t(t,"function",Shape,"graduatedSkip"),this._===null&&(this._=new GradElementSettings),this._.kc=t,this.u(),this.i("graduatedSkip",i,t))}static CI(t,i,e){let n=null;if(t.toArrow!=="None")n=Shape.fo[t.toArrow];else if(t.fromArrow!=="None")n=Shape.fo[t.fromArrow];else{let o=Geo.qn[t.figure];typeof o=="string"&&(o=Geo.qn[o]),o===void 0&&Util.n("Unknown Shape.figure: "+t.figure),n=o(t,i,e),n.cf=i,n.uf=e}if(n===null){const o=Geo.qn.Rectangle;typeof o=="function"&&(n=o(t,i,e))}return Debug&&(n.bounds.width>i+1e-5||n.bounds.height>e+1e-5)&&Util.n('Geometry made with figure "'+t.figure+'" has bounds '+n.bounds.toString()+" that are too large for the given size ("+i+","+e+"). See documentation for Shape.defineFigureGenerator."),n}static getFigureGenerators(){const t=new GMap;for(const i in Geo.qn){if(i===i.toLowerCase())continue;const e=Geo.qn[i];t.set(i,e)}return t.w(),t}static defineFigureGenerator(t,i){Util.t(t,"string",Shape,"defineFigureGenerator:name"),typeof i=="string"?Debug&&(i===""||!Geo.qn[i])&&Util.n("Shape.defineFigureGenerator synonym must not be empty or None or not a defined figure name: "+i):Util.t(i,"function",Shape,"defineFigureGenerator:func");const e=t.toLowerCase();Debug&&(t===""||t===e)&&Util.n("Shape.defineFigureGenerator name must not be empty or all-lower-case: "+t);const s=Geo.qn;s[t]=i,s[e]=t}static getArrowheadGeometries(){const t=new GMap;for(const i in Geo.Jg)if(Shape.fo[i]===void 0){const e=Geometry.parse(Geo.Jg[i],!1);Shape.fo[i]=e;const s=i.toLowerCase();s!==i&&(Shape.fo[s]=i)}for(const i in Shape.fo){if(i===i.toLowerCase())continue;const e=Shape.fo[i];e instanceof Geometry&&t.set(i,e)}return t.w(),t}static defineArrowheadGeometry(t,i){Util.t(t,"string",Shape,"defineArrowheadGeometry:name");let e=null;typeof i=="string"?(Util.t(i,"string",Shape,"defineArrowheadGeometry:pathstr"),e=Geometry.parse(i,!1)):(Util.s(i,Geometry,Shape,"defineArrowheadGeometry:pathstr"),e=i);const s=t.toLowerCase();(Debug&&t===""||s==="none"||t===s)&&Util.n("Shape.defineArrowheadGeometry name must not be empty or None or all-lower-case: "+t);const n=Shape.fo;n[t]=e,n[s]=t}static fo=new PropertyCollection;static G2=new PropertyCollection;static VL(t){let i=Shape.fo[t];if(i===void 0){const e=t.toLowerCase();if(e==="none")return"None";if(i=Shape.fo[e],i===void 0){let s=null;for(const n in Geo.Jg)if(n.toLowerCase()===e){s=n;break}if(s!==null){const n=Geometry.parse(Geo.Jg[s],!1);return Shape.fo[s]=n,e!==s&&(Shape.fo[e]=s),s}}}return typeof i=="string"?i:i instanceof Geometry?t:null}}class ShapeTemplateSettings{wi;Mp;Pp;Np;yh;Lp;Tp;jn;Wn;constructor(){this.wi=!1,this.Mp="butt",this.Pp="miter",this.Np=10,this.yh=0,this.Lp=null,this.Tp=1,this.jn=Spot.Default,this.Wn=Spot.Default}copy(){const t=new ShapeTemplateSettings;return t.Mp=this.Mp,t.Pp=this.Pp,t.Np=this.Np,t.yh=this.yh,t.Lp=this.Lp,t.Tp=this.Tp,t.jn=this.jn.L(),t.Wn=this.Wn.L(),t}}var Wrap=(w=>(w[w.None=0]="None",w[w.Fit=1]="Fit",w[w.DesiredSize=2]="DesiredSize",w[w.BreakAll=3]="BreakAll",w))(Wrap||{}),TextOverflow=(w=>(w[w.Clip=0]="Clip",w[w.Ellipsis=1]="Ellipsis",w))(TextOverflow||{}),TextFormat=(w=>(w[w.Trim=0]="Trim",w[w.None=1]="None",w))(TextFormat||{});class TextBlock extends GraphObject{ui;$i;Cn;Fe;xi;C0;Dd;_;$;Ol;co;An;Re;Oi;Ln;constructor(t,i){return super(),this.l|=2097152,this.ui="",this.$i="black",this.Cn="13px sans-serif",this.Fe=0,this.xi=0,this.C0=0,this.Dd=null,this._=null,this.$=null,this.Ol=0,this.co=null,this.An=0,this.Re=null,this.Oi=null,this.Ln=null,typeof t=="string"?this.text=t:t&&Object.assign(this,t),i&&Object.assign(this,i),this}cloneProtected(t){super.cloneProtected(t),t.ui=this.ui,t.$i=this.$i,t.Cn=this.Cn,t.Fe=this.Fe,t.xi=this.xi,t.C0=this.C0,t.Dd=this.Dd,this._!==null&&(t._=this._.copy()),this.$!==null&&(this.$.wi?t.$=this.$:t.$=this.$.copy()),t.Ol=this.Ol,t.co=this.co,t.An=this.An,t.Re=this.Re,t.Oi=this.Oi,t.Ln=this.Ln}Tn(){this.$===null?this.$=new TextBlockTemplateSettings:this.$.wi&&(this.$=this.$.copy())}ch(){super.ch(),this.$!==null&&(this.$.wi=!0)}dI(t){this.l=t.l|2048|4096,this._t=t.opacity,this.Ft=t.background,this.qe=t.desiredSize.L(),this.minSize=t.minSize.L(),this.maxSize=t.maxSize.L(),t.Pi!==null?this.Pi=t.Pi.copy():this.Pi=null,this.rt=t.scale,this.jt=t.angle,this.stretch=t.stretch,this.el=t.margin.L(),this.ai=t.alignment.L(),this.ic=t.alignmentFocus.L(),this.segmentFraction=t.segmentFraction,this.segmentOffset=t.segmentOffset.L(),this.segmentOrientation=t.segmentOrientation,t.hi!==null&&(this.hi=t.hi.copy()),this.shadowVisible=t.shadowVisible,this.ui=t.ui,this.$i=t.$i,this.Cn=t.Cn,this._!==null&&(this._=t._.copy()),t.$!==null&&(t.$.wi?this.$=t.$:this.$=t.$.copy()),this.Ol=t.Ol}cI(t){if(this.ui=t.text||"",this.jt=t.labelAngle||0,this.Fe=t.lineCount||0,this.DI(t.lines),t.naturalBounds&&(this.Hi=t.naturalBounds),t.actualBounds){const i=t.actualBounds;this.qt(i.x,i.y,i.width,i.height)}}fi(t){t in Wrap?this.wrap=t:super.fi(t)}toString(){return this.ui.length>22?'TextBlock("'+this.ui.substring(0,20)+'"...)':'TextBlock("'+this.ui+'")'}static getEllipsis(){return TextBlock.Dp}static setEllipsis(t){TextBlock.Dp=t,TextBlock.ab=new PropertyCollection,TextBlock.H2=0}static getBaseline(){return TextBlock.fb}static setBaseline(t){TextBlock.fb=t}static fb=null;static getUnderline(){return TextBlock.cb}static setUnderline(t){TextBlock.cb=t}static cb=null;static None=0;static WrapFit=1;static WrapDesiredSize=2;static WrapBreakAll=3;static OverflowClip=0;static OverflowEllipsis=1;static FormatTrim=0;static FormatNone=1;u(){super.u()}get font(){return this.Cn}set font(t){const i=this.Cn;i!==t&&(Debug&&(Util.t(t,"string",TextBlock,"font"),TextBlock.isValidFont(t)||Util.n('Not a valid font: "'+t+'"')),this.Cn=t,this.co=null,this.u(),this.i("font",i,t))}static isValidFont(t){return root.CSS?root.CSS.supports("font",t):!0}get text(){return this.ui}set text(t){const i=this.ui;t!=null?t=t.toString():t="",i!==t&&(this.ui=t,this.u(),this.i("text",i,t),this.hs(!0))}get textAlign(){return this.$!==null?this.$.Fp:"start"}set textAlign(t){const i=this.textAlign;i!==t&&(Debug&&Util.t(t,"string",TextBlock,"textAlign"),t==="start"||t==="end"||t==="left"||t==="right"||t==="center"?(this.Tn(),this.$.Fp=t,this.T(),this.i("textAlign",i,t)):Debug&&Util.G(t,'"start", "end", "left", "right", or "center"',TextBlock,"textAlign"))}get flip(){return this.$!==null?this.$.uo:0}set flip(t){const i=this.flip;i!==t&&(Util.tt(t,Flip,"Flip"),this.Tn(),this.$.uo=t,this.T(),this.i("flip",i,t))}get verticalAlignment(){return this.$!==null?this.$.hl:Spot.Top}set verticalAlignment(t){const i=this.verticalAlignment;i.equals(t)||(Debug&&(Util.s(t,Spot,TextBlock,"verticalAlignment"),t.isNoSpot()&&Util.n("TextBlock.verticalAlignment for "+this+" must be a real Spot, not:"+t)),t=t.L(),this.Tn(),this.$.hl=t,this.hc(),this.i("verticalAlignment",i,t))}get naturalBounds(){if(!this.Hi.isReal()){const t=Size.a();this.q2(this.ui,999999,t);let i=t.width;Size.o(t);let e=this.XL(i);const s=this.desiredSize;isNaN(s.width)||(i=s.width),isNaN(s.height)||(e=s.height),this.Hi.Kn(i,e)}return this.Hi}get isMultiline(){return(this.l&2097152)!==0}set isMultiline(t){const i=(this.l&2097152)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"isMultiline"),this.l=this.l^2097152,this.u(),this.i("isMultiline",i,t))}get isUnderline(){return(this.l&4194304)!==0}set isUnderline(t){const i=(this.l&4194304)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"isUnderline"),this.l=this.l^4194304,this.hs(!0),this.T(),this.i("isUnderline",i,t))}get isStrikethrough(){return(this.l&8388608)!==0}set isStrikethrough(t){const i=(this.l&8388608)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"isStrikethrough"),this.l=this.l^8388608,this.hs(!0),this.T(),this.i("isStrikethrough",i,t))}get wrap(){return this.$!==null?this.$.Rp:2}set wrap(t){const i=this.wrap;i!==t&&(Debug&&Util.tt(t,Wrap,"Wrap"),this.Tn(),this.$.Rp=t,this.u(),this.i("wrap",i,t))}get overflow(){return this.$!==null?this.$.Ip:0}set overflow(t){const i=this.overflow;i!==t&&(Debug&&Util.tt(t,TextOverflow,"Overflow"),this.Tn(),this.$.Ip=t,this.u(),this.i("overflow",i,t))}get isOverflowed(){return(this.l&16777216)!==0}j2(t){t?this.l|=16777216:this.l&=-16777217}get stroke(){return this.$i}set stroke(t){const i=this.$i;i!==t&&(t!==null&&Brush.cd(t,"TextBlock.stroke"),t instanceof Brush&&t.w(),this.$i=t,this.T(),this.i("stroke",i,t))}get lineCount(){return this.Fe}get lineHeight(){return this.Op()}get editable(){return(this.l&1048576)!==0}set editable(t){const i=(this.l&1048576)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"editable"),this.l=this.l^1048576,this.i("editable",i,t))}get E2(){return(this.l&33554432)!==0}set E2(t){this.l=this.l^33554432}get textEditor(){return this.$!==null?this.$.Ep:null}set textEditor(t){const i=this.textEditor;i!==t&&(Debug&&!(t instanceof HTMLInfo)&&Util.n("TextBlock.textEditor must be an HTMLInfo."),this.Tn(),this.$.Ep=t,this.i("textEditor",i,t))}get errorFunction(){return this.$!==null?this.$.fs:null}set errorFunction(t){const i=this.errorFunction;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"errorFunction"),this.Tn(),this.$.fs=t,this.i("errorFunction",i,t))}get interval(){return this._!==null?this._.wc:1}set interval(t){const i=this.interval;if(Debug&&Util.r(t,TextBlock,"interval"),t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this._===null&&(this._=new GradElementSettings),this._.wc=t,this.u();const e=this.panel;e!==null&&(e.as=null),this.i("interval",i,t)}}get graduatedStart(){return this._!==null?this._.xc:0}set graduatedStart(t){const i=this.graduatedStart;Debug&&Util.r(t,TextBlock,"graduatedStart"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.xc=t,this.u(),this.i("graduatedStart",i,t))}get graduatedEnd(){return this._!==null?this._.bc:1}set graduatedEnd(t){const i=this.graduatedEnd;Debug&&Util.r(t,TextBlock,"graduatedEnd"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.bc=t,this.u(),this.i("graduatedEnd",i,t))}get graduatedFunction(){return this._!==null?this._.Bp:null}set graduatedFunction(t){const i=this.graduatedFunction;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"graduatedFunction"),this._===null&&(this._=new GradElementSettings),this._.Bp=t,this.u(),this.i("graduatedFunction",i,t))}get graduatedSkip(){return this._!==null?this._.kc:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"graduatedSkip"),this._===null&&(this._=new GradElementSettings),this._.kc=t,this.u(),this.i("graduatedSkip",i,t))}mh(t,i){if(this.$i===null||this.ui.length===0||this.Cn===null)return;const e=this.naturalBounds,s=this.actualBounds,n=e.width,o=e.height,r=this.Op();let l=t.textAlign=this.textAlign;const h=i.vu;l==="start"?l=h?"right":"left":l==="end"&&(l=h?"left":"right");const a=this.isUnderline,f=this.isStrikethrough;this.wn(t,this.$i,!0,!1,e,s),(a||f)&&this.wn(t,this.$i,!1,!1,e,s);const c=0;let u=0;const d=n;let m=!1;i.ei===t&&!(i.ei instanceof SVGContext)&&!this.E2&&i.getRenderingHint("textGreeking")===!0&&r*this.ma*i.scale<3&&(m=!0);const g=this.spacingAbove,p=this.spacingBelow;switch(this.flip){case 0:break;case 2:t.translate(n,0),t.scale(-1,1);break;case 1:t.translate(0,o),t.scale(1,-1);break;case 3:t.translate(n,o),t.scale(-1,-1);break}t.commitTransform();const y=this.Fe,k=(g+r+p)*y;if(o>k){const b=this.verticalAlignment;u=b.y*o-b.y*k+b.offsetY}if(y===1&&this.Ln!==null){let b=this.xi;b>d&&(b=d),u+=g,this.YL(this.Ln,t,c,u,d,r,b,m,l,a,f)}else if(this.Re!==null&&this.Oi!==null)for(let b=0;bd&&(S=d),u+=g,this.YL(this.Oi[b],t,c,u,d,r,S,m,l,a,f),u+=r+p}switch(this.flip){case 0:break;case 2:t.scale(-1,1),t.translate(-n,0);break;case 1:t.scale(1,-1),t.translate(0,-o);break;case 3:t.scale(-1,-1),t.translate(-n,-o);break}}YL(t,i,e,s,n,o,r,l,h,a,f){let c=0;if(l){h==="left"?c=0:h==="right"?c=n-r:h==="center"&&(c=(n-r)/2);const m=i.globalAlpha;i.globalAlpha=m/2,i.fillRect(e+c,s+o/4,r,o/2),i.globalAlpha=m;return}h==="left"?c=0:h==="right"?c=n:h==="center"&&(c=n/2);const u=TextBlock.fb!==null?TextBlock.fb(this,o):o*.75;i.fillText(t,e+c,s+u);let d=o/20|0;if(d===0&&(d=1),h==="right"?c-=r:h==="center"&&(c-=r/2),a){const m=TextBlock.cb!==null?TextBlock.cb(this,o):o*.8;this.KL(e+c,s+m,e+c+r,s+m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}if(f){let m=s+o-o/2.2|0;d%2!==0&&(m+=.5),this.KL(e+c,m,e+c+r,m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}}KL(t,i,e,s,n,o){o.beginPath(),o.lineWidth=n,o.moveTo(t,i),o.lineTo(e,s),o.stroke(),o.endPath()}oc(t,i,e){if(!super.oc(t,i,e))return!1;if(this.wn(t,this.$i,!0,!1,this.naturalBounds,this.actualBounds),e){if(this.svg.getElementsByTagName("text").length===0)return!0;const n=this.svg.getElementsByClassName("gojs-td");for(let o=0;o1||this.isUnderline||this.isStrikethrough?!0:super.ad(t)}m2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("text");for(let s=0;sthis.maxLines&&(this.l|=16777216))}q2(t,i,e){const s=this.formatting===0;s&&(t=t.trim());let n=0,o=0,r=0;const l=this.Cn,h=this.spacingAbove+this.spacingBelow,a=Math.max(0,this.Op()+h),f=this.overflow===1?this.GL(l):0;if(this.Fe>=this.maxLines){e!==null&&e.e(0,a);return}let c=t;if(this.wrap===0){if(this.An=1,o=this.getStringWidth(t),f===0||o<=i){this.xi=Math.max(this.xi,o),this.Dn(t,this.xi),e!==null&&e.e(o,a);return}let d=this.Fd(c);c=c.substring(d.length);let m=this.Fd(c);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,c=c.substring(m.length),m=this.Fd(c),r=o;let g=d+m;s&&(g=g.trim()),o=this.getStringWidth(g)}for(s&&(m=m.trim()),d+=m,i=Math.max(1,i-f);this.getStringWidth(d)>i&&d.length>1;)d=d.substring(0,d.length-1);this.j2(!0),d+=TextBlock.Dp,r=this.getStringWidth(d),this.xi=r,this.Dn(d,r),e!==null&&e.e(r,a);return}let u=0;for(c.length===0&&(u=1,this.Dn(c,0));c.length>0;){let d=this.Fd(c);for(c=c.substring(d.length);this.getStringWidth(d)>i;){let p=1;for(o=this.getStringWidth(d.substring(0,p)),r=0;o<=i;)p++,r=o,o=this.getStringWidth(d.substring(0,p));let y=0;p===1?(y=o,n=Math.max(n,o)):(y=r,n=Math.max(n,r)),p--,p<1&&(p=1);const x=d.substring(0,p);if(this.Dn(x,y),u++,d=d.substring(p),this.Fe+u>this.maxLines)break}let m=this.Fd(c);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,c=c.substring(m.length),m=this.Fd(c),r=o;let p=d+m;s&&(p=p.trim()),o=this.getStringWidth(p)}if(s&&(d=d.trim()),d==="")continue;d[d.length-1]==="\xAD"&&(d=d.substring(0,d.length-1)+"\u2010");let g=0;if(m.length===0?(g=o,n=Math.max(n,o)):(r=this.getStringWidth(d),g=r,n=Math.max(n,r)),this.Dn(d,g),u++,this.Fe+u>this.maxLines)break}this.An=Math.min(this.maxLines,u),this.xi=Math.max(this.xi,n),e!==null&&e.e(this.xi,a*this.An)}OI(t,i){if(this.xi===0||this.Re===null||this.Oi===null||this.overflow!==1)return;const e=this.Cn,s=this.overflow===1?this.GL(e):0,n=this.spacingAbove+this.spacingBelow,o=Math.max(0,this.Op()+n),r=Math.min(this.maxLines-1,Math.max(Math.floor(i/o+.01)-1,0));if(r+1>=this.Oi.length)return;this.j2(!0);let l=this.Oi[r];const h=Math.max(1,t-s);for(;this.getStringWidth(l)>h&&l.length>1;)l=l.substring(0,l.length-1);l+=TextBlock.Dp;const a=this.getStringWidth(l);this.Oi[r]=l,this.Oi=this.Oi.slice(0,r+1),this.Re[r]=a,this.Re=this.Re.slice(0,r+1),this.An=this.Oi.length,this.xi=Math.max(this.xi,a),this.Fe=this.An,this.Fe===1&&(this.Ln=this.Oi[0])}Fd(t){if(this.wrap===3)return t.substring(0,1);let i=t.length,e=0;const s=TextBlock.EI;for(;e=t.length?t:t.substring(0,e)}getStringWidth(t){return TextBlock.rl===null?t.length*8:TextBlock.rl.measureText(t).width}Op(){if(this.co!==null)return this.co;const t=this.Cn;let i=0;return TextBlock.rl===null?(i=16,this.co=i,i):(TextBlock.W2[t]!==void 0&&TextBlock.HL<5e3?i=TextBlock.W2[t]:(i=TextBlock.rl.measureText("M").width*1.3,TextBlock.W2[t]=i,TextBlock.HL++),this.co=i,i)}GL(t){if(TextBlock.rl===null)return 6;let i=0;return TextBlock.ab[t]!==void 0&&TextBlock.H2<5e3?i=TextBlock.ab[t]:(i=TextBlock.rl.measureText(TextBlock.Dp).width,TextBlock.ab[t]=i,TextBlock.H2++),i}ub(t,i){return t.indexOf(` `,i)}XL(t){let i=this.ui.replace(/\r\n/g,` `).replace(/\r/g,` -`);const e=this.spacingAbove+this.spacingBelow,s=Math.max(0,this.Op()+e);if(i.length===0)return this.xi=0,this.Fe=1,s;if(!this.isMultiline){const h=this.ub(i,0);h>=0&&(i=i.substring(0,h))}let n=0;this.Fe=0;let o=0,r=-1,l=!1;for(;!l;){if(r=this.ub(i,o),r===-1&&(r=i.length,l=!0),o<=r){const h=i.substring(o,r);if(this.wrap!==0){this.An=0;const a=Size.a();this.W2(h,t,a),n+=a.height,Size.o(a),this.Fe+=this.An}else this.W2(h,t,null),n+=s,this.Fe++;this.Fe===this.maxLines&&(l=!0)}o=r+1}return this.C0=n,n}OI(){let t=this.ui.replace(/\r\n/g,` +`);const e=this.spacingAbove+this.spacingBelow,s=Math.max(0,this.Op()+e);if(i.length===0)return this.xi=0,this.Fe=1,s;if(!this.isMultiline){const h=this.ub(i,0);h>=0&&(i=i.substring(0,h))}let n=0;this.Fe=0;let o=0,r=-1,l=!1;for(;!l;){if(r=this.ub(i,o),r===-1&&(r=i.length,l=!0),o<=r){const h=i.substring(o,r);if(this.wrap!==0){this.An=0;const a=Size.a();this.q2(h,t,a),n+=a.height,Size.o(a),this.Fe+=this.An}else this.q2(h,t,null),n+=s,this.Fe++;this.Fe===this.maxLines&&(l=!0)}o=r+1}return this.C0=n,n}II(){let t=this.ui.replace(/\r\n/g,` `).replace(/\r/g,` -`);if(t.length===0)return 8;if(this.isMultiline){let i=0,e=0,s=!1;for(;!s;){let n=this.ub(t,e);n===-1&&(n=t.length,s=!0);let o=t.substring(e,n);this.formatting===0&&(o=o.trim()),i=Math.max(i,this.getStringWidth(o)),e=n+1}return i}else{const i=this.ub(t,0);return i>=0&&(t=t.substring(0,i)),this.getStringWidth(t)}}get textValidation(){return this.$!==null?this.$.Il:null}set textValidation(t){const i=this.textValidation;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"textValidation"),this.Tn(),this.$.Il=t,this.i("textValidation",i,t))}get textEdited(){return this.$!==null?this.$.Bp:null}set textEdited(t){const i=this.textEdited;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"textEdited"),this.Tn(),this.$.Bp=t,this.i("textEdited",i,t))}get spacingAbove(){return this.$!==null?this.$.zp:0}set spacingAbove(t){const i=this.spacingAbove;i!==t&&(Debug&&Util.t(t,"number",TextBlock,"spacingAbove"),this.Tn(),this.$.zp=t,this.u(),this.i("spacingAbove",i,t))}get spacingBelow(){return this.$!==null?this.$.Xp:0}set spacingBelow(t){const i=this.spacingBelow;i!==t&&(Debug&&Util.t(t,"number",TextBlock,"spacingBelow"),this.Tn(),this.$.Xp=t,this.u(),this.i("spacingBelow",i,t))}get formatting(){return this.$!==null?this.$.Yp:0}set formatting(t){const i=this.formatting;i!==t&&(Util.tt(t,TextFormat,"formatting"),this.Tn(),this.$.Yp=t,this.u(),this.i("formatting",i,t))}get maxLines(){return this.$!==null?this.$.Kp:1/0}set maxLines(t){const i=this.maxLines;i!==t&&(Debug&&Util.t(t,"number",TextBlock,"maxLines"),t=Math.floor(t),t<=0&&Util.G(t,"> 0",TextBlock,"maxLines"),this.Tn(),this.$.Kp=t,this.u(),this.i("maxLines",i,t))}getMetrics(){return[this.xi,this.Ol,this.co,this.An,this.Re,this.Oi,this.Ln]}FI(t){t!==void 0&&(this.xi=t[0],this.Ol=t[1],this.co=t[2],this.An=t[3],this.Re=t[4],this.Oi=t[5],this.Ln=t[6])}get metrics(){return{arrSize:this.Re!==null?this.Re:[this.xi],arrText:this.Oi!==null?this.Oi:[this.Ln],maxLineWidth:this.xi,fontHeight:this.co}}get choices(){return this.Fd}set choices(t){const i=this.Fd;i!==t&&(Debug&&t!==null&&!Array.isArray(t)&&Util.Vi(t,"Array",TextBlock,"choices:value"),this.Fd=t,this.i("choices",i,t))}static VI=new RegExp("[ \u200B\xAD]");static J2=new PropertyCollection;static HL=0;static ab=new PropertyCollection;static j2=0;static Dp="...";static UL="";static rl=Diagram.isUsingDOM()?new CanvasSurface(null).di:null}class TextBlockTemplateSettings{wi;fs;uo;Yp;Kp;Ip;zp;Xp;Fp;Bp;Ep;Il;hl;Rp;constructor(){this.wi=!1,this.fs=null,this.uo=0,this.Yp=0,this.Kp=1/0,this.Ip=0,this.zp=0,this.Xp=0,this.Fp="start",this.Bp=null,this.Ep=null,this.Il=null,this.hl=Spot.Top,this.Rp=2}copy(){const t=new TextBlockTemplateSettings;return t.fs=this.fs,t.uo=this.uo,t.Yp=this.Yp,t.Kp=this.Kp,t.Ip=this.Ip,t.zp=this.zp,t.Xp=this.Xp,t.Fp=this.Fp,t.Bp=this.Bp,t.Ep=this.Ep,t.Il=this.Il,t.hl=this.hl,t.Rp=this.Rp,t}}class GradElementSettings{yc;wc;xc;Vp;bc;constructor(){this.yc=1,this.wc=0,this.xc=1,this.Vp=null,this.bc=null}copy(){const t=new GradElementSettings;return t.yc=this.yc,t.wc=this.wc,t.xc=this.xc,t.Vp=this.Vp,t.bc=this.bc,t}}var ImageStretch=(w=>(w[w.None=0]="None",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ImageStretch||{});class Picture extends GraphObject{al;St;fl;kc;fs;cl;Sc;uo;Mc;Pc;W1;constructor(t,i){super(),this.l|=2097152,this.al=null,this.St="",this.fl=Rect.BD,this.kc=2,this.fs=null,this.cl=null,this.Sc=Spot.Center,this.uo=0,this.Mc=null,this.Pc=null,this.W1=null,typeof t=="string"?this.source=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.St=this.St,t.element=this.al,t.fl=this.fl.L(),t.kc=this.kc,t.uo=this.uo,t.fs=this.fs,t.cl=this.cl,t.Sc=this.Sc.L(),t.Pc=this.Pc}fi(t){t in ImageStretch?this.imageStretch=t:super.fi(t)}toString(){return"Picture("+this.source+")#"+GSet.gs(this)}get Nc(){return(this.l&1048576)!==0}set Nc(t){this.Nc!==t&&(this.l=this.l^1048576)}get Ia(){return(this.l&2097152)!==0}set Ia(t){this.Ia!==t&&(this.l=this.l^2097152)}get bn(){return(this.l&4194304)!==0}set bn(t){this.bn!==t&&(this.l=this.l^4194304)}static clearCache(t){t===void 0&&(t=""),Util.t(t,"string",Picture,"clearCache:url"),t!==""?Picture.Up[t]&&(delete Picture.Up[t],Picture.db--):(Picture.Up=new PropertyCollection,Picture.db=0)}static UA(t,i){i.qL||(i.gb=e=>{Picture.BI(i,e),t.desiredSize.isReal()||(t.pe(!1),t.u())},i.mb=e=>Picture.zI(i,e),i.addEventListener("load",i.gb),i.addEventListener("error",i.mb),i.qL=!0)}static NR(t){t.gb&&t.removeEventListener("load",t.gb),t.mb&&t.removeEventListener("error",t.mb),delete t.gb,delete t.mb,delete t.qL}get element(){return this.al}set element(t){const i=this.al;if(this.hs(!0),i!==t){this.Nc=t instanceof HTMLCanvasElement;const e=t instanceof HTMLImageElement;t!==null&&!(e||t instanceof HTMLVideoElement||this.Nc)&&Util.n("Picture.element must be an instance of Image, Canvas, or Video, not: "+t);const s=this.diagram;s!==null&&s.zP(this),this.al=t,t!==null&&e&&t.ls===void 0&&(t.ls=new GSet),s!==null&&e&&s.BP(this),this.i("element",i,t),this.T()}}MR(){const t=this.al;if(t===null)return;const i=this.desiredSize.isReal();(this.Nc||t.complete===!0)&&(t.w0&&(t.Gp instanceof Event&&this.fs!==null?this.fs(this,t.Gp):t.bn===!0&&!t.Gp&&this.cl!==null&&t.Z2&&this.cl(this,t.Z2)),t.bn=!0),t.bn&&i&&this.diagram!==null&&this.diagram.vu.add(this)}XI(){if(this.al===null){this.Mc=!1;return}const t=new CanvasSurface(null).di;try{t.drawImage(this.al,0,0)}catch(i){Debug&&this.Ia&&Util.at(i.toString()),this.Ia=!1}try{t.getImageData(0,0,1,1).data[3]&&(this.Mc=!1),this.Mc=!1}catch{this.Mc=!0}}get source(){return this.St}set source(t){const i=this.St;if(i!==t){this.hs(!0),Util.t(t,"string",Picture,"source"),this.St=t;let e=Picture.Up;if(!Diagram.isUsingDOM()){this.i("source",i,t);return}let s=null;if(e[t]!==void 0)s=e[t];else if(t!==""){Picture.db>30&&(Picture.clearCache(),e=Picture.Up),s=Util.ln("img"),s.w0=!0,Picture.UA(this,s);const n=this.Pc;n!==null&&(s.crossOrigin=n(this)),s.src=t,e[t]=s,Picture.db++}this.element=s,s!==null&&s.__goCache===void 0&&(s.__goCache=new PictureCacheArray),this.u(),this.T(),this.i("source",i,t)}}static BI(t,i){t.bn=!0,t.Gp=!1;let e;const s=t.ls.copy();if(s==null)return;const n=s.iterator;for(;n.next();){const o=n.value;o.T();const r=t.getAttribute("src")||"",l=o._l.get(r);if(l===null)continue;const h=l.length;for(let a=0;a=o.width&&(r=r+p.offsetX+(d*p.x-o.width*p.x)),m>=o.height&&(l=l+p.offsetY+(m*p.y-o.height*p.y)),a=Math.min(o.width,d),f=Math.min(o.height,m);break;case 2:d=o.width,m=o.height;break;case 6:case 7:let L=0;g===6?(L=Math.min(o.height/m,o.width/d),d*=L,m*=L):g===7&&(L=Math.max(o.height/m,o.width/d),d*=L,m*=L,d>=o.width&&(r=(r+p.offsetX+(d*p.x-o.width*p.x)/d)*a),m>=o.height&&(l=(l+p.offsetY+(m*p.y-o.height*p.y)/m)*f),a*=1/(d/o.width),f*=1/(m/o.height),d=o.width,m=o.height);break}const y=a*f,x=this.getDocumentScale()*i.scale,k=d*x,b=m*x,S=k*b,M=y/S,A=e.__goCache;let C=null;const P=Picture.YI;if(!n){if(e.bn&&A!==void 0&&S>4&&M>P*P){A.Yt===null&&(A.jL(4,c,u,e),A.jL(16,c,u,e));const L=A.Yt,D=L.length;for(let F=0;F0){const f=this.Yt[this.Yt.length-1];h=f.St,a=f.Id}o.setTransform(r*a,0,0,r*a,0,0),o.commitTransform(),o.drawImage(h,0,0),this.Yt.push(l)}}class PictureCacheInstance{St;Id;constructor(t,i){this.St=t,this.Id=i}}class GeoStream{Ci;im;constructor(){this.im=new Geometry,this.Ci=null}Bi(t){t!==null?(t.ct(),this.im=t,t.figures.clear()):this.im=new Geometry,this.Ci=null}wu(t,i,e,s,n,o){if(s!==void 0&&s===!0){const r=new PathSegment(1);r.endX=t,r.endY=i,this.Ci.segments.add(r)}else this.Ci=new PathFigure,this.Ci.startX=t,this.Ci.startY=i,this.Ci.isFilled=e,this.Ci.isEvenOdd=o||!1,this.im.figures.add(this.Ci);n!==void 0&&(this.Ci.isShadowed=n)}WD(){const t=this.Ci.segments.length;t>0&&this.Ci.segments.elt(t-1).close()}vD(){this.Ci.segments.length>0&&(this.Ci.isFilled=!0)}JD(t){this.Ci.isShadowed=t}pE(t){this.Ci.isEvenOdd=t}HD(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(1);s.endX=t,s.endY=i,e&&s.close(),this.Ci.segments.add(s)}yr(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(2);s.endX=t,s.endY=i,e&&s.close(),this.Ci.segments.add(s)}wr(t,i,e,s,n,o,r){r===void 0&&(r=!1);const l=new PathSegment(3);l.point1X=t,l.point1Y=i,l.point2X=e,l.point2Y=s,l.endX=n,l.endY=o,r&&l.close(),this.Ci.segments.add(l)}Fw(t,i,e,s,n){n===void 0&&(n=!1);const o=new PathSegment(4);o.point1X=t,o.point1Y=i,o.endX=e,o.endY=s,n&&o.close(),this.Ci.segments.add(o)}qD(t,i,e,s,n,o,r){o===void 0&&(o=0),r===void 0&&(r=!1);const l=new PathSegment(5);l.startAngle=t,l.sweepAngle=i,l.centerX=e,l.centerY=s,l.radiusX=n,o!==0?l.radiusY=o:l.radiusY=n,r&&l.close(),this.Ci.segments.add(l)}jD(t,i,e,s,n,o,r,l){l===void 0&&(l=!1);const h=new PathSegment(6,o,r,t,i,e,s,n);l&&h.close(),this.Ci.segments.add(h)}static $2=null;static PC(t){const i=GeoStream.$2;if(i!==null)return GeoStream.$2=null,i.Bi(t),i;{const e=new GeoStream;return e.Bi(t),e}}static NC(t){GeoStream.$2=t}}{const w=function(n,o){const r=n.toLowerCase(),l=Geo.qn;l[n]=o,l[r]=n};w("Rectangle",(n,o,r)=>{const l="r"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,Geo.pr{const l="s"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,h.defaultStretch=6,Geo.pr{(isNaN(l)||l<0)&&(l=5),isNaN(h)&&(h=15);const a="rr"+o+","+r+","+l+","+h;let f=Geo.mr[a];if(f!==void 0)return f;let c=l;(h&1)===1?(c=Math.min(c,(h&2)===2?o/3:o),c=Math.min(c,(h&8)===8?r/3:r)):c=0;const u=new PathFigure(c,0,!0);f=new Geometry().add(u);const d=Spot.TopLeft.copy(),m=Spot.BottomRight.copy();if((h&2)===2){let g=l;g=Math.min(g,(h&1)===1?o/3:o),g=Math.min(g,(h&4)===4?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,o-g,0)).add(new PathSegment(3,o,g,o-p,0,o,p)),d.offsetY=p,m.offsetX=-p}else u.add(new PathSegment(2,o,0));if((h&4)===4){let g=l;g=Math.min(g,(h&8)===8?o/3:o),g=Math.min(g,(h&2)===2?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,o,r-g)).add(new PathSegment(3,o-g,r,o,r-p,o-p,r)),m.offsetX=-p,m.offsetY=-p}else u.add(new PathSegment(2,o,r));if((h&8)===8){let g=l;g=Math.min(g,(h&4)===4?o/3:o),g=Math.min(g,(h&1)===1?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,g,r)).add(new PathSegment(3,0,r-g,p,r,0,r-p)),d.offsetX=p,m.offsetY=-p}else u.add(new PathSegment(2,0,r));if((h&1)===1){const g=c*Geo.Un;u.add(new PathSegment(2,0,c)).add(new PathSegment(3,c,0,0,g,g,0).close()),d.offsetX=g,d.offsetY=g}else u.add(new PathSegment(2,0,0).close());return f.spot1=d,f.spot2=m,Geo.pr{const l=n?n.parameter1:NaN,h=n?n.parameter2:NaN;return t(n,o,r,l,h)}),w("Border","RoundedRectangle"),w("RoundedTopRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,3)}),w("RoundedBottomRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,12)}),w("RoundedLeftRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,9)}),w("RoundedRightRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,6)}),w("Ellipse",(n,o,r)=>{const l="e"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Kk,h.spot2=Spot.Uk,Geo.pr{const l="c"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Kk,h.spot2=Spot.Uk,h.defaultStretch=6,Geo.prnew Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,.5*r)).add(new PathSegment(2,0,r).close())).setSpots(0,.25,.5,.75)),w("TriangleDown",(n,o,r)=>new Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,0)).add(new PathSegment(2,.5*o,r).close())).setSpots(.25,0,.75,.5)),w("TriangleLeft",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,o,0).close())).setSpots(.5,.25,1,.75)),w("TriangleUp",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,r)).add(new PathSegment(2,.5*o,0).close())).setSpots(.25,.5,.75,1)),w("Triangle","TriangleUp"),w("Diamond",(n,o,r)=>new Geometry().add(new PathFigure(.5*o,0).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,.5*o,r)).add(new PathSegment(2,o,.5*r).close())).setSpots(.25,.25,.75,.75)),w("LineH",(n,o,r)=>{const l=new Geometry(1);return l.startX=0,l.startY=r/2,l.endX=o,l.endY=r/2,l}),w("LineV",(n,o,r)=>{const l=new Geometry(1);return l.startX=o/2,l.startY=0,l.endX=o/2,l.endY=r,l}),w("None","Rectangle"),w("BarH","Rectangle"),w("BarV","Rectangle"),w("MinusLine","LineH"),w("PlusLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r/2,!1).add(new PathSegment(2,o,r/2)).add(new PathSegment(1,o/2,0)).add(new PathSegment(2,o/2,r)))),w("XLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r,!1).add(new PathSegment(2,o,0)).add(new PathSegment(1,0,0)).add(new PathSegment(2,o,r)))),w("LineRight",(n,o,r)=>new Geometry().add(new PathFigure(.25*o,0,!1).add(new PathSegment(2,.75*o,.5*r)).add(new PathSegment(2,.25*o,r)))),w("LineDown",(n,o,r)=>new Geometry().add(new PathFigure(0,.25*r,!1).add(new PathSegment(2,.5*o,.75*r)).add(new PathSegment(2,o,.25*r)))),w("LineLeft",(n,o,r)=>new Geometry().add(new PathFigure(.75*o,0,!1).add(new PathSegment(2,.25*o,.5*r)).add(new PathSegment(2,.75*o,r)))),w("LineUp",(n,o,r)=>new Geometry().add(new PathFigure(0,.75*r,!1).add(new PathSegment(2,.5*o,.25*r)).add(new PathSegment(2,o,.75*r)))),w("Capsule",(n,o,r)=>{const l=new Geometry;if(or){const h=new PathFigure(r/2,0,!0);return l.add(h),h.add(new PathSegment(2,o-r/2,0)),h.add(new PathSegment(5,270,180,o-r/2,r/2,r/2,r/2)),h.add(new PathSegment(2,r/2,r)),h.add(new PathSegment(5,90,180,r/2,r/2,r/2,r/2)),l.spot1=new Spot(0,.156,r*.156,0),l.spot2=new Spot(1,.844,-r*.156,0),l}else return l.type=3,l.endX=o,l.endY=r,l.spot1=Spot.Kk,l.spot2=Spot.Uk,l});const i=(n,o)=>new PathFigure(n,o,!1,!1),e=(n,o,r)=>n.add(new PathSegment(2,o,r)),s=(n,o,r)=>n.add(new PathSegment(1,o,r));w("Borders",(n,o,r)=>{let l=n?n.parameter1:NaN;isNaN(l)?l=10:l=l&15;const h=new Geometry;let a;return l===10?(a=i(o,0),e(a,o,r),s(a,0,r),e(a,0,0)):l===5?(a=i(0,0),e(a,o,0),s(a,o,r),e(a,0,r)):l===1?(a=i(0,0),e(a,o,0),s(a,o,r)):l===2?(a=i(o,0),e(a,o,r)):l===4?(a=i(o,r),e(a,0,r)):l===8?(a=i(0,r),e(a,0,0),s(a,o,r)):l===3?(a=i(0,0),e(a,o,0),e(a,o,r)):l===6?(a=i(o,0),e(a,o,r),e(a,0,r)):l===12?(a=i(o,r),e(a,0,r),e(a,0,0)):l===9?(a=i(0,r),e(a,0,0),e(a,o,0)):l===7?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r)):l===14?(a=i(o,0),e(a,o,r),e(a,0,r),e(a,0,0)):l===13?(a=i(o,r),e(a,0,r),e(a,0,0),e(a,o,0)):l===11?(a=i(0,r),e(a,0,0),e(a,o,0),e(a,o,r)):l===15?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r),a.add(new PathSegment(2,0,0).close())):(a=i(0,0),s(a,o,r)),h.add(a),h})}Geo.Zg={"":"",Standard:"F1 m 0,0 l 8,4 -8,4 2,-4 z",Backward:"F1 m 8,0 l -2,4 2,4 -8,-4 z",Triangle:"F1 m 0,0 l 8,4.62 -8,4.62 z",BackwardTriangle:"F1 m 8,4 l 0,4 -8,-4 8,-4 0,4 z",Boomerang:"F1 m 0,0 l 8,4 -8,4 4,-4 -4,-4 z",BackwardBoomerang:"F1 m 8,0 l -8,4 8,4 -4,-4 4,-4 z",SidewaysV:"m 0,0 l 8,4 -8,4 0,-1 6,-3 -6,-3 0,-1 z",BackwardV:"m 8,0 l -8,4 8,4 0,-1 -6,-3 6,-3 0,-1 z",OpenTriangle:"m 0,0 l 8,4 -8,4",BackwardOpenTriangle:"m 8,0 l -8,4 8,4",OpenTriangleLine:"m 0,0 l 8,4 -8,4 m 8.5,0 l 0,-8",BackwardOpenTriangleLine:"m 8,0 l -8,4 8,4 m -8.5,0 l 0,-8",OpenTriangleTop:"m 0,0 l 8,4 m 0,4",BackwardOpenTriangleTop:"m 8,0 l -8,4 m 0,4",OpenTriangleBottom:"m 0,8 l 8,-4",BackwardOpenTriangleBottom:"m 0,4 l 8,4",HalfTriangleTop:"F1 m 0,0 l 0,4 8,0 z m 0,8",BackwardHalfTriangleTop:"F1 m 8,0 l 0,4 -8,0 z m 0,8",HalfTriangleBottom:"F1 m 0,4 l 0,4 8,-4 z",BackwardHalfTriangleBottom:"F1 m 8,4 l 0,4 -8,-4 z",ForwardSemiCircle:"m 4,0 b 270 180 0 4 4",BackwardSemiCircle:"m 4,8 b 90 180 0 -4 4",Feather:"m 0,0 l 3,4 -3,4",BackwardFeather:"m 3,0 l -3,4 3,4",DoubleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardDoubleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4",TripleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardTripleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4 m 3,-8 l -3,4 3,4",ForwardSlash:"m 0,8 l 5,-8",BackSlash:"m 0,0 l 5,8",DoubleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8",DoubleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8",TripleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8 m -2,8 l 4,-8",TripleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8 m -2,-8 l 4,8",Fork:"m 0,4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4",LineFork:"m 0,0 l 0,8 m 0,-4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardLineFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4 m 8,-8 l 0,8",CircleFork:"F1 m 6,4 b 0 360 -3 0 3 z m 0,0 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 6,0 b 0 360 -3 0 3",CircleLineFork:"F1 m 6,4 b 0 360 -3 0 3 z m 1,-4 l 0,8 m 0,-4 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleLineFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 0,-4 l 0,8 m 7,-4 b 0 360 -3 0 3",Circle:"F1 m 8,4 b 0 360 -4 0 4 z",Block:"F1 m 0,0 l 0,8 8,0 0,-8 z",StretchedDiamond:"F1 m 0,3 l 5,-3 5,3 -5,3 -5,-3 z",Diamond:"F1 m 0,4 l 4,-4 4,4 -4,4 -4,-4 z",Chevron:"F1 m 0,0 l 5,0 3,4 -3,4 -5,0 3,-4 -3,-4 z",StretchedChevron:"F1 m 0,0 l 8,0 3,4 -3,4 -8,0 3,-4 -3,-4 z",NormalArrow:"F1 m 0,2 l 4,0 0,-2 4,4 -4,4 0,-2 -4,0 z",X:"m 0,0 l 8,8 m 0,-8 l -8,8",TailedNormalArrow:"F1 m 0,0 l 2,0 1,2 3,0 0,-2 2,4 -2,4 0,-2 -3,0 -1,2 -2,0 1,-4 -1,-4 z",DoubleTriangle:"F1 m 0,0 l 4,4 -4,4 0,-8 z m 4,0 l 4,4 -4,4 0,-8 z",BigEndArrow:"F1 m 0,0 l 5,2 0,-2 3,4 -3,4 0,-2 -5,2 0,-8 z",ConcaveTailArrow:"F1 m 0,2 h 4 v -2 l 4,4 -4,4 v -2 h -4 l 2,-2 -2,-2 z",RoundedTriangle:"F1 m 0,1 a 1,1 0 0 1 1,-1 l 7,3 a 0.5,1 0 0 1 0,2 l -7,3 a 1,1 0 0 1 -1,-1 l 0,-6 z",SimpleArrow:"F1 m 1,2 l -1,-2 2,0 1,2 -1,2 -2,0 1,-2 5,0 0,-2 2,2 -2,2 0,-2 z",AccelerationArrow:"F1 m 0,0 l 0,8 0.2,0 0,-8 -0.2,0 z m 2,0 l 0,8 1,0 0,-8 -1,0 z m 3,0 l 2,0 2,4 -2,4 -2,0 0,-8 z",BoxArrow:"F1 m 0,0 l 4,0 0,2 2,0 0,-2 2,4 -2,4 0,-2 -2,0 0,2 -4,0 0,-8 z",TriangleLine:"F1 m 8,4 l -8,-4 0,8 8,-4 z m 0.5,4 l 0,-8",CircleEndedArrow:"F1 m 10,4 l -2,-3 0,2 -2,0 0,2 2,0 0,2 2,-3 z m -4,0 b 0 360 -3 0 3 z",DynamicWidthArrow:"F1 m 0,3 l 2,0 2,-1 2,-2 2,4 -2,4 -2,-2 -2,-1 -2,0 0,-2 z",EquilibriumArrow:"m 0,3 l 8,0 -3,-3 m 3,5 l -8,0 3,3",FastForward:"F1 m 0,0 l 3.5,4 0,-4 3.5,4 0,-4 1,0 0,8 -1,0 0,-4 -3.5,4 0,-4 -3.5,4 0,-8 z",Kite:"F1 m 0,4 l 2,-4 6,4 -6,4 -2,-4 z",HalfArrowTop:"F1 m 0,0 l 4,4 4,0 -8,-4 z m 0,8",HalfArrowBottom:"F1 m 0,8 l 4,-4 4,0 -8,4 z",OpposingDirectionDoubleArrow:"F1 m 0,4 l 2,-4 0,2 4,0 0,-2 2,4 -2,4 0,-2 -4,0 0,2 -2,-4 z",PartialDoubleTriangle:"F1 m 0,0 4,3 0,-3 4,4 -4,4 0,-3 -4,3 0,-8 z",LineCircle:"F1 m 0,0 l 0,8 m 7 -4 b 0 360 -3 0 3 z",DoubleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",TripleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",CircleLine:"F1 m 6 4 b 0 360 -3 0 3 z m 1,-4 l 0,8",DiamondCircle:"F1 m 8,4 l -4,4 -4,-4 4,-4 4,4 m 8,0 b 0 360 -4 0 4 z",PlusCircle:"F1 m 8,4 b 0 360 -4 0 4 l -8 0 z m -4 -4 l 0 8",OpenRightTriangleTop:"m 8,0 l 0,4 -8,0 m 0,4",OpenRightTriangleBottom:"m 8,8 l 0,-4 -8,0",Line:"m 0,0 l 0,8",DoubleLine:"m 0,0 l 0,8 m 2,0 l 0,-8",TripleLine:"m 0,0 l 0,8 m 2,0 l 0,-8 m 2,0 l 0,8",PentagonArrow:"F1 m 8,4 l -4,-4 -4,0 0,8 4,0 4,-4 z"};var LayoutConditions=(w=>(w[w.None=0]="None",w[w.Added=1]="Added",w[w.Removed=2]="Removed",w[w.Shown=4]="Shown",w[w.Hidden=8]="Hidden",w[w.NodeSized=16]="NodeSized",w[w.GroupLayout=32]="GroupLayout",w[w.NodeReplaced=64]="NodeReplaced",w[w.Standard=127]="Standard",w[w.All=16777215]="All",w))(LayoutConditions||{});class Part extends Panel{N;$o;E;ul;dl;Qo;ui;_o;xh;Zs;tr;Od;qM;WL;Hp;qp;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.N=2408959,this.$o="",this.E=null,this.ul="",this.dl=null,this.Qo=null,this.ui="",this._o=null,this.xh=null,this.Zs=new Point(NaN,NaN).w(),this.tr=null,this.Od=NaN,this.qM=-1,this.WL=new Rect,this.Hp=null,this.qp=NaN,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.N=this.N&-4097|16384|32768,t.$o=this.$o,this.E!==null&&(this.E.wi?t.E=this.E:t.E=this.E.copy()),t.ul=this.ul,t.Qo=null,t.ui=this.ui,t.Zs.c(this.Zs),t.Od=this.Od}Ho(t){super.Ho(t),t.dh(),t.dl=null,t.tr=null,t.Hp=null}toString(){let t=Util.hn(this.constructor)+"#"+GSet.gs(this);return this.data!==null&&(t+="("+Util.toString(this.data)+")"),t}static LayoutNone=0;static LayoutAdded=1;static LayoutRemoved=2;static LayoutShown=4;static LayoutHidden=8;static LayoutNodeSized=16;static LayoutGroupLayout=32;static LayoutNodeReplaced=64;static LayoutStandard=127;static LayoutAll=16777215;Qi(){this.E===null?this.E=new PartTemplateSettings:this.E.wi&&(this.E=this.E.copy())}fh(){super.fh(),this.E!==null&&(this.E.wi=!0)}ic(t,i,e,s,n,o,r){const l=this.diagram;l!==null&&(t===3&&i==="elements"?n instanceof Panel?n.Qr(h=>{l.partManager.FP(h,l)}):n instanceof Picture&&l.BP(n):t===4&&i==="elements"&&(n instanceof Panel?n.Qr(h=>l.partManager.RP(h,l)):n instanceof Picture&&l.zP(n)),l.raiseChangedEvent(t,i,e,s,n,o,r))}updateTargetBindings(t){if(super.updateTargetBindings(t),this.data===null)return;const i=this.D.h,e=i.length;for(let n=0;n{r.data!==null&&r.updateTargetBindings()})}const s=this.adornments;for(;s.next();)s.value.updateTargetBindings(t)}Yo(){if(super.Yo(),this.N2()){const i=this.D.h,e=i.length;for(let s=0;so.Yo())}}const t=this.adornments;for(;t.next();)t.value.Yo()}updateRelationshipsFromData(){this.data!==null&&this.diagram?.partManager.updateRelationshipsFromData(this)}get key(){const t=this.diagram;if(t!==null)return t.model.getKeyForNodeData(this.data)}get adornments(){return this.Qo===null?EmptyIterator.instance:this.Qo.iteratorValues}findAdornment(t){Debug&&Util.t(t,"string",Part,"findAdornment:category");const i=this.Qo;return i===null?null:i.get(t)}addAdornment(t,i){if(i===null)return;Debug&&(Util.t(t,"string",Part,"addAdornment:category"),Util.s(i,Adornment,Part,"addAdornment:ad"));let e=null,s=this.Qo;if(s!==null&&(e=s.get(t)),e!==i){if(e!==null){const o=e.diagram;o!==null&&o.remove(e)}s===null&&(s=new GMap,this.Qo=s),i.$o!==t&&(i.category=t),s.set(t,i);const n=this.diagram;if(n!==null){n.add(i);const o=i.adornedObject;if(o!==null){const r=o.findBindingPanel();r!==null&&(i.data=r.data)}}}}removeAdornment(t){Debug&&Util.t(t,"string",Part,"removeAdornment:category");const i=this.Qo;if(i===null)return;const e=i.get(t);if(e!==null){const s=e.diagram;s!==null&&(s.remove(e),e.data=null)}i.delete(t),i.count===0&&(this.Qo=null)}clearAdornments(){const t=this.Qo;if(t===null)return;const i=Util.ft(),e=t.iterator;for(;e.next();){const n=e.key;i.push(n)}const s=i.length;for(let n=0;n{e.isEnabled&&e.updateAdornments(i)}),t.toolManager.updateAdornments(i)}GM(t){this._o=t,t===null&&this.zR()}get layer(){return this._o}get diagram(){const t=this._o;return t==null?null:t.diagram}get layerName(){return this.ul}set layerName(t){const i=this.ul;if(i===t)return;Util.t(t,"string",Part,"layerName");let e=this.diagram;if(e!==null&&(e.findLayer(t)===null||e.partManager.addsToTemporaryLayer))return;this.ul=t,e!==null&&e.invalidateDocumentBounds(),this.i("layerName",i,t);const s=this.layer;if(s===null||s.name===t||(e=s.diagram,e===null))return;const n=e.findLayer(t);if(n===null||n===s)return;let o=s.ne(-1,this,!0);o>=0&&e.raiseChangedEvent(4,"parts",s,this,null,o,!0),o=n.Zh(99999999,this,!0),s.visible!==n.visible&&this.Ki(n.visible),o>=0&&e.raiseChangedEvent(3,"parts",n,null,this,!0,o);const r=this.layerChanged;if(r===null)return;const l=e.j;e.j=!0,r(this,s,n),e.j=l}get layerChanged(){return this.E!==null?this.E.jp:null}set layerChanged(t){const i=this.layerChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"layerChanged"),this.Qi(),this.E.jp=t,this.i("layerChanged",i,t))}get zOrder(){return this.Od}set zOrder(t){const i=this.Od;if(i===t)return;Util.t(t,"number",Part,"zOrder"),this.Od=t;const e=this.layer;e!==null&&e.Nx(-1,this),this.i("zOrder",i,t);const s=this.diagram;s!==null&&s.T()}GI(){const t=this.layer;t!==null&&t.Nx(-1,this)}pb(){if(this.nh()!==!1)return;this.Q2(!0),this.hd();const t=this.diagram;t!==null&&(t.d0(this),t.requestUpdate())}ZL(){if(this.N|=2097152,this.nh()===!1)return;const t=this.position,i=this.location;(!i.isReal()||!t.isReal())&&this.$L(t,i);const e=this.Fi,s=Rect.a().c(e);e.ct(),e.x=t.x,e.y=t.y,e.w(),this.ad(s,e),Rect.o(s),this.Q2(!1)}no(t,i,e,s){const n=this.le;n.e(t,i,e,s),this.Pi===null&&(this.Pi=new Transform);const o=this.Pi;o.Bi(),this.P0(o,t,i,e,s),this.Pi=o,o.Gk()||o.Cw(n)}P0(t,i,e,s,n){if(this.lt!==1&&t.lt(this.lt),this.jt===0)return;let o=Spot.Center;this.locationSpot.isSpot()&&(o=this.locationSpot);const r=Point.a();if(this.locationObject!==this){const l=this.locationObject,h=l.naturalBounds;r.setSpot(h.x,h.y,h.width,h.height,o),l.Pi!==null&&l.Pi.Pt(r),r.offset(-l.measuredBounds.x,-l.measuredBounds.y);let a=l.panel;for(;a!==null&&a!==this;)a.Pi!==null&&a.Pi.Pt(r),r.offset(-a.measuredBounds.x,-a.measuredBounds.y),a=a.panel}else r.setSpot(i,e,s,n,o);t.ms(this.jt,r.x,r.y),Point.o(r)}get locationObject(){if(this.tr===null)if(this instanceof Adornment&&this.type!==Panel.Link&&this.hasPlaceholder())this.tr=this.placeholder;else{const t=this.locationObjectName;if(t!==""){const i=this.findObject(t);i!==null?this.tr=i:this.tr=this}else this.tr=this}return this.tr.visible?this.tr:this}get minLocation(){return this.E!==null?this.E.Wp:Point.rC}set minLocation(t){const i=this.minLocation;i.equals(t)||(Debug&&Util.s(t,Point,Part,"minLocation"),t=t.L(),this.Qi(),this.E.Wp=t,this.i("minLocation",i,t))}get maxLocation(){return this.E!==null?this.E.vp:Point.lC}set maxLocation(t){const i=this.maxLocation;i.equals(t)||(Debug&&Util.s(t,Point,Part,"maxLocation"),t=t.L(),this.Qi(),this.E.vp=t,this.i("maxLocation",i,t))}get locationObjectName(){return this.E!==null?this.E.Jp:""}set locationObjectName(t){const i=this.locationObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"locationObjectName"),this.Qi(),this.E.Jp=t,this.tr=null,this.u(),this.i("locationObjectName",i,t))}get locationSpot(){return this.E!==null?this.E.Zp:Spot.TopLeft}set locationSpot(t){const i=this.locationSpot;i.equals(t)||(Debug&&(Util.s(t,Spot,Part,"locationSpot"),t.isSpot()||Util.n("Part.locationSpot must be a specific Spot value, not: "+t)),t=t.L(),this.Qi(),this.E.Zp=t,this.u(),this.i("locationSpot",i,t))}move(t,i){i===!0?this.location=t:this.position=t}moveTo(t,i,e){const s=Point.H(t,i);this.move(s,e),Point.o(s)}isVisible(){if(!this.visible)return!1;const t=this.layer;if(t!==null){if(!t.visible)return!1;const e=t.diagram;if(e!==null&&e.animationManager.ux(this))return!0}const i=this.containingGroup;return!(i!==null&&(!i.isSubGraphExpanded||!i.isVisible()))}Ki(t){const i=this.diagram;t?(this.invalidateLayout(4),this.invalidateAdornments(),i!==null&&i.d0(this)):(this.invalidateLayout(8),this.clearAdornments()),this.dh(),i!==null&&(i.invalidateDocumentBounds(),i.T())}findObject(t){if(this.name===t)return this;let i=this.Hp;if(i===null&&(this.Hp=i=new GMap),i.get(t)!==null)return i.get(t);const e=super.findObject(t);return e!==null?(i.set(t,e),e):(i.set(t,null),null)}V0(){this.Hp=null}getRelativePoint(t,i,e){e===void 0&&(e=new Point);const s=i.isNoSpot()?Spot.Center:i,n=t.naturalBounds;if(e.e(n.width*s.x+s.offsetX,n.height*s.y+s.offsetY),t===null||t===this)return e;t.O.Pt(e);let o=t.panel;for(;o!==null&&o!==this;)o.O.Pt(e),o=o.panel;return this.Pi!==null&&this.Pi.Pt(e),e.offset(-this.le.x,-this.le.y),e}getDocumentBounds(t){return t===void 0&&(t=new Rect),t.c(this.actualBounds)}ensureBounds(){this.wt(1/0,1/0),this.qt()}PL(t){const i=this.locationSpot,e=this.locationObject;let s=e.naturalBounds;s.isReal()||(s=Rect.kw);const n=e instanceof Shape?e.strokeWidth:0;if(t.setSpot(0,0,s.width+n,s.height+n,i),e!==this){t.offset(-n/2,-n/2),e.O.Pt(t);let o=e.panel;for(;o!==null&&o!==this;)o.O.Pt(t),o=o.panel}return this.Pi!==null&&this.Pi.Pt(t),t.offset(-this.le.x,-this.le.y),t}Jh(t,i){const e=i===void 0?this.WL:i,s=this.HI(),n=s*2;if(!this.isShadowed)return e.e(t.x-1-s,t.y-1-s,t.width+2+n,t.height+2+n),e;let o=t.x,r=t.y,l=t.width,h=t.height;const a=this.shadowBlur,f=this.shadowOffset;return l+=a,h+=a,o-=a/2,r-=a/2,f.x>0?l+=f.x:(o+=f.x,l-=f.x),f.y>0?h+=f.y:(r+=f.y,h-=f.y),e.e(o-1,r-1,l+2,h+2),e}CI(){return this.type===Panel.Link&&this instanceof Adornment&&this.category==="Selection"&&this.adornedObject instanceof Shape&&this.adornedPart.findMainElement()===this.adornedObject?this.adornedObject.strokeWidth:0}HI(){return isNaN(this.qp)&&(this.qp=this.FL()),this.qp}mc(){this.qp=NaN}qt(){if(this.rs()===!1){this.ZL();return}this.oo(!1);const t=this.Fi,i=Rect.a();i.c(t);const e=this.Tl();this.uh(0,0,this.le.width,this.le.height);const s=this.position;this.$L(s,this.location),t.ct(),t.x=s.x,t.y=s.y,t.w(),this.ad(i,t),i.equals(t)?this.Us(e):this.Ae()&&(!Geo.p(i.width,t.width)||!Geo.p(i.height,t.height))&&this.qM>=0&&this.invalidateLayout(16),Rect.o(i),this.Q2(!1)}ad(t,i){const e=this.diagram;if(e===null)return;let s=!1;if(e.ta===!1&&t.isReal()){const n=Rect.a();n.c(e.documentBounds),n.subtractMargin(e.padding),t.x>n.x&&t.y>n.y&&t.rightn.x&&i.y>n.y&&i.right=o)return}}this.N=this.N^4096;let s=!1;if(e!==null){s=e.skipsUndoManager,e.skipsUndoManager=!0;const o=e.selection;o.ct(),t?o.add(this):o.delete(this),o.w()}this.i("isSelected",i,t),this.invalidateAdornments();const n=this.selectionChanged;n!==null&&n(this),e!==null&&(e.requestUpdate(),e.skipsUndoManager=s)}}get isHighlighted(){return(this.N&524288)!==0}set isHighlighted(t){const i=(this.N&524288)!==0;if(i!==t){Debug&&Util.t(t,"boolean",Part,"isHighlighted"),this.N=this.N^524288;const e=this.diagram;if(e!==null){const n=e.highlighteds;n.ct(),t?n.add(this):n.delete(this),n.w()}this.i("isHighlighted",i,t),this.T();const s=this.highlightedChanged;s!==null&&s(this)}}get isShadowed(){return(this.N&8192)!==0}set isShadowed(t){const i=(this.N&8192)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Part,"isShadowed"),this.N=this.N^8192,this.hs(!0),this.i("isShadowed",i,t),this.T())}vL(){return(this.N&16384)!==0}JL(t){t?this.N|=16384:this.N&=-16385}nh(){return(this.N&32768)!==0}Q2(t){t?this.N|=32768:this.N&=-32769}qI(){return(this.N&65536)!==0}g2(t){t?this.N|=65536:this.N&=-65537}Tl(){return(this.N&131072)!==0}Us(t){t?this.N|=131072:this.N&=-131073}eT(){return(this.N&1048576)!==0}yb(t){t?this.N|=1048576:this.N&=-1048577}get isAnimated(){return(this.N&262144)!==0}set isAnimated(t){const i=(this.N&262144)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Part,"isAnimated"),this.N=this.N^262144,this.i("isAnimated",i,t))}get highlightedChanged(){return this.E!==null?this.E.$p:null}set highlightedChanged(t){const i=this.highlightedChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"highlightedChanged"),this.Qi(),this.E.$p=t,this.i("highlightedChanged",i,t))}get selectionObjectName(){return this.E!==null?this.E.Qp:""}set selectionObjectName(t){const i=this.selectionObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"selectionObjectName"),this.Qi(),this.E.Qp=t,this.dl=null,this.i("selectionObjectName",i,t))}get selectionAdornmentTemplate(){return this.E!==null?this.E._p:null}set selectionAdornmentTemplate(t){const i=this.selectionAdornmentTemplate;i!==t&&(Debug&&Util.s(t,Adornment,Part,"selectionAdornmentTemplate"),this.Qi(),this.E._p=t,this.i("selectionAdornmentTemplate",i,t))}get selectionObject(){if(this.dl===null){const t=this.selectionObjectName;if(t!==null&&t!==""){const i=this.findObject(t);i!==null?this.dl=i:this.dl=this}else if(this instanceof Link){const i=this.path;i!==null?this.dl=i:this.dl=this}else this.dl=this}return this.dl}get selectionChanged(){return this.E!==null?this.E.ty:null}set selectionChanged(t){const i=this.selectionChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"selectionChanged"),this.Qi(),this.E.ty=t,this.i("selectionChanged",i,t))}get resizeAdornmentTemplate(){return this.E!==null?this.E.iy:null}set resizeAdornmentTemplate(t){const i=this.resizeAdornmentTemplate;i!==t&&(Debug&&Util.s(t,Adornment,Part,"resizeAdornmentTemplate"),this.Qi(),this.E.iy=t,this.i("resizeAdornmentTemplate",i,t))}get resizeObjectName(){return this.E!==null?this.E.ey:""}set resizeObjectName(t){const i=this.resizeObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"resizeObjectName"),this.Qi(),this.E.ey=t,this.i("resizeObjectName",i,t))}get resizeObject(){const t=this.resizeObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get resizeCellSize(){return this.E!==null?this.E.sy:Size.xw}set resizeCellSize(t){const i=this.resizeCellSize;i.equals(t)||(Debug&&Util.s(t,Size,Part,"resizeCellSize"),t=t.L(),this.Qi(),this.E.sy=t,this.i("resizeCellSize",i,t))}get rotateAdornmentTemplate(){return this.E!==null?this.E.ny:null}set rotateAdornmentTemplate(t){const i=this.rotateAdornmentTemplate;i!==t&&(Debug&&Util.s(t,Adornment,Part,"rotateAdornmentTemplate"),this.Qi(),this.E.ny=t,this.i("rotateAdornmentTemplate",i,t))}get rotateObjectName(){return this.E!==null?this.E.oy:""}set rotateObjectName(t){const i=this.rotateObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"rotateObjectName"),this.Qi(),this.E.oy=t,this.i("rotateObjectName",i,t))}get rotateObject(){const t=this.rotateObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get rotationSpot(){return this.E!==null?this.E.ry:Spot.Default}set rotationSpot(t){const i=this.rotationSpot;i.equals(t)||(Debug&&(Util.s(t,Spot,Part,"rotationSpot"),t!==Spot.Default&&!t.isSpot()&&Util.n("Part.rotationSpot must be a specific Spot value or Spot.Default, not: "+t)),t=t.L(),this.Qi(),this.E.ry=t,this.i("rotationSpot",i,t))}get text(){return this.ui}set text(t){const i=this.ui;i!==t&&(Debug&&Util.t(t,"string",Part,"text"),this.ui=t,this.i("text",i,t))}get containingGroup(){return this.xh}set containingGroup(t){if(this.Ae()){const i=this.xh;if(i!==t){Debug&&t!==null&&Util.s(t,Group,Part,"containingGroup"),t!==null&&(this===t||t.isMemberOf(this))&&(this===t&&Util.n("Cannot make a Group a member of itself: "+this.toString()),Util.n("Cannot make a Group indirectly contain itself: "+this.toString()+" already contains "+t.toString())),this.invalidateLayout(2);const e=this.diagram;if(i!==null?i.tN(this):this instanceof Group&&e!==null&&e.vr.delete(this),this.xh=t,t!==null?t.iN(this):this instanceof Group&&e!==null&&e.vr.add(this),this.invalidateLayout(1),e!==null&&e.j){const n=this.data,o=e.model;if(n!==null&&o.da()){const r=t!==null?t.data:null;o.setGroupForData(n,o.getKeyForNodeData(r))}}const s=this.containingGroupChanged;if(s!==null){let n=!0;e!==null&&(n=e.j,e.j=!0),s(this,i,t),e!==null&&(e.j=n)}if(this instanceof Group){const n=new GSet;Part.lh(n,this,!0,0,!0);const o=n.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=r.linksConnected;for(;l.next();)l.value.Ed()}}}if(this instanceof Node){const n=this.linksConnected;for(;n.next();)n.value.Ed();const o=this.labeledLink;o!==null&&o.Ed()}this.i("containingGroup",i,t),t!==null&&t.GI()}}else Util.n("cannot set the Part.containingGroup of a Link or Adornment")}dh(){const t=this.containingGroup;t!==null&&(t.hasPlaceholder()&&t.placeholder.u(),t.u(),t.invalidateConnectedLinks())}T(){const t=this.diagram;t!==null&&!this.rs()&&!this.nh()&&this.isVisible()&&this.Fi.isReal()&&t.T(this.Jh(this.Fi))}u(){if(this.Xo())return;super.u();const t=this.diagram;t!==null&&(t.d0(this),this instanceof Node&&this.labeledLink!==null&&this.labeledLink.lc(),t.requestUpdate(!0))}lc(t){if(this.rs())return;const i=this.diagram;i!==null&&(i.d0(this),this instanceof Node&&this.invalidateConnectedLinks(),i.requestUpdate()),this.oo(!0)}Hm(t){if(!t){const i=this.xh;i!==null&&i.iN(this)}}qm(t){if(!t){const i=this.xh;i!==null&&i.tN(this)}}Jf(){const t=this.data;if(t!==null){const i=this.diagram;if(i!==null){const e=i.model;e!==null&&e.removeNodeData(t)}}}get containingGroupChanged(){return this.E!==null?this.E.ly:null}set containingGroupChanged(t){const i=this.containingGroupChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"containingGroupChanged"),this.Qi(),this.E.ly=t,this.i("containingGroupChanged",i,t))}findSubGraphLevel(){return this.eN(this)}eN(t){const i=t.containingGroup;if(i!==null)return 1+this.eN(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.eN(e)}return 0}findTopLevelPart(){return this.sN(this)}sN(t){const i=t.containingGroup;if(i!==null)return this.sN(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.sN(e)}return t}get isTopLevel(){return!(this.containingGroup!==null||this instanceof Node&&this.labeledLink!==null)}isMemberOf(t){return t instanceof Group?this.nN(this,t):!1}nN(t,i){if(t===i||i===null)return!1;const e=t.containingGroup;if(e!==null&&(e===i||this.nN(e,i)))return!0;if(t instanceof Node){const s=t.labeledLink;if(s!==null)return this.nN(s,i)}return!1}findCommonContainingGroup(t){if(t===null)return null;if(Debug&&Util.s(t,Part,Part,"findCommonContainingGroup:other"),this===t)return this.containingGroup;let i=this;for(;i!==null;){if(i instanceof Group&&i.yb(!0),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}let e=null;for(i=t;i!==null;){if(i.eT()){e=i;break}if(i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}for(i=this;i!==null;){if(i instanceof Group&&i.yb(!1),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}return e}get layoutConditions(){return this.E!==null?this.E.hy:127}set layoutConditions(t){const i=this.layoutConditions;i!==t&&(Debug&&Util.t(t,"number",Part,"layoutConditions"),this.Qi(),this.E.hy=t,this.i("layoutConditions",i,t))}canLayout(){if(!this.isLayoutPositioned||!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary||this instanceof Node&&this.isLinkLabel)}WI(t){if(!this.isLayoutPositioned||!(t&this.layoutConditions))return!1;const i=this.layer;if(i!==null&&i.isTemporary||this instanceof Node&&this.isLinkLabel)return!1;const e=this.diagram;return!(e!==null&&e.undoManager.isUndoingRedoing)}invalidateLayout(t){if(t===void 0&&(t=16777215),!this.WI(t))return;const i=this.xh;if(i!==null){const e=i.layout;e!==null?e.invalidateLayout():i.invalidateLayout(t)}else{const e=this.diagram;if(e!==null){const s=e.layout;s!==null&&s.invalidateLayout()}}}IA(){if(!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary)}static lh(t,i,e,s,n,o){if(o===void 0&&(o=null),!t.has(i)&&!(o!==null&&!o(i))&&!(i instanceof Adornment)){if(t.add(i),i instanceof Node){if(e&&i instanceof Group){const r=i.memberParts;for(;r.next();){const l=r.value;Part.lh(t,l,e,s,n,o)}}if(n!==!1){const r=i.linksConnected;for(;r.next();){const l=r.value;if(t.has(l))continue;const h=l.fromNode,a=l.toNode,f=h===null||t.has(h),c=a===null||t.has(a);(n?f&&c:f||c)&&Part.lh(t,l,e,s,n,o)}}if(s>1){const r=i.findTreeChildrenNodes();for(;r.next();){const l=r.value;Part.lh(t,l,e,s-1,n,o)}}}else if(i instanceof Link){const r=i.labelNodes;for(;r.next();){const l=r.value;Part.lh(t,l,e,s,n,o)}}}}get dragComputation(){return this.E!==null?this.E.ay:null}set dragComputation(t){const i=this.dragComputation;i!==t&&(t!==null&&Util.t(t,"function",Part,"dragComputation"),this.Qi(),this.E.ay=t,this.i("dragComputation",i,t))}get shadowOffset(){return this.E!==null?this.E.fy:Point.hC}set shadowOffset(t){const i=this.shadowOffset;i.equals(t)||(Debug&&Util.s(t,Point,Part,"shadowOffset"),t=t.L(),this.Qi(),this.E.fy=t,this.T(),this.i("shadowOffset",i,t))}get shadowColor(){return this.E!==null?this.E.cy:"gray"}set shadowColor(t){const i=this.shadowColor;i!==t&&(Debug&&Util.t(t,"string",Part,"shadowColor"),this.Qi(),this.E.cy=t,this.T(),this.i("shadowColor",i,t))}get shadowBlur(){return this.E!==null?this.E.Pn:4}set shadowBlur(t){const i=this.shadowBlur;i!==t&&(Debug&&Util.t(t,"number",Part,"shadowBlur"),this.Qi(),this.E.Pn=t,this.T(),this.i("shadowBlur",i,t))}}class PartTemplateSettings{wi;jp;ly;_p;Qp;ty;$p;iy;ey;sy;ny;oy;ry;Jp;Zp;Wp;vp;ay;hy;fy;cy;Pn;constructor(){this.wi=!1,this.jp=null,this.ly=null,this._p=null,this.Qp="",this.ty=null,this.$p=null,this.iy=null,this.ey="",this.sy=Size.xw,this.ny=null,this.oy="",this.ry=Spot.Default,this.Jp="",this.Zp=Spot.TopLeft,this.Wp=Point.rC,this.vp=Point.lC,this.ay=null,this.hy=127,this.fy=Point.hC,this.cy="gray",this.Pn=4}copy(){const t=new PartTemplateSettings;return t.jp=this.jp,t.ly=this.ly,t._p=this._p,t.Qp=this.Qp,t.ty=this.ty,t.$p=this.$p,t.iy=this.iy,t.ey=this.ey,t.sy=this.sy.L(),t.ny=this.ny,t.oy=this.oy,t.ry=this.ry.L(),t.Jp=this.Jp,t.Zp=this.Zp.L(),t.Wp=this.Wp.L(),t.vp=this.vp.L(),t.ay=this.ay,t.hy=this.hy,t.fy=this.fy.L(),t.cy=this.cy,t.Pn=this.Pn,t}}class Adornment extends Part{ys;Et;sM;nM;dc;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.N&=-257,this.ul="Adornment",this.ys=null,this.sM=0,this.nM=!1,this.Et=null,this.dc=null,i&&Object.assign(this,i)}toString(){const t=this.adornedPart;return"Adornment("+this.category+")"+(t!==null?t.toString():"")}updateRelationshipsFromData(){}pd(t){const i=this.adornedObject,e=i?.part;if(!(e instanceof Link)||!(i instanceof Shape))return;const s=e.path;let n=s.geometry;e.pd(t),n=s.geometry;const o=this.D.h,r=o.length;for(let l=0;lh instanceof Placeholder);l instanceof Placeholder&&(this.Et===null?this.Et=l:Debug&&this.Et!==l&&Util.n("Cannot insert a second Placeholder into the visual tree of an Adornment."))}}else t===4&&i==="elements"&&this.Et!==null&&(s===this.Et?this.Et=null:s instanceof Panel&&this.Et.isContainedBy(s)&&(this.Et=null));super.ic(t,i,e,s,n,o,r)}updateAdornments(){}Jf(){}}var PortSpreading=(w=>(w[w.None=0]="None",w[w.Evenly=1]="Evenly",w[w.Packed=2]="Packed",w))(PortSpreading||{});class Node extends Part{z;bt;Cc;gl;bh;he;ni;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.z=13,this.bt=null,this.ni=new List,this.Cc=null,this.gl=null,this.he=null,this.bh=!1,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.z=this.z,this.bt!==null&&(this.bt.wi?t.bt=this.bt:t.bt=this.bt.copy())}Ho(t){super.Ho(t),t.invalidateConnectedLinks(),t.gl=this.gl,t.he=null}static SpreadingNone=0;static SpreadingEvenly=1;static SpreadingPacked=2;ml(){this.bt===null?this.bt=new NodeTemplateSettings:this.bt.wi&&(this.bt=this.bt.copy())}fh(){super.fh(),this.bt!==null&&(this.bt.wi=!0)}sT(t){t!==null&&(this.gl===null&&(this.gl=new GSet),this.gl.add(t))}nT(t){t!==null&&this.gl!==null&&this.gl.delete(t)}oT(t,i,e){if(t===null||this.gl===null)return null;const s=this.gl.iterator;for(;s.next();){const n=s.value;if(n.uy===this&&n.wb===t&&n.oN===i&&n.rN===e||n.uy===t&&n.wb===this&&n.oN===e&&n.rN===i)return n}return null}invalidateLinkBundle(t,i,e){i==null&&(i=""),e==null&&(e="");const s=this.oT(t,i,e);s!==null&&s.Vd()}ic(t,i,e,s,n,o,r){t===3&&i==="elements"?this.he=null:t===4&&i==="elements"&&(this.he=null),super.ic(t,i,e,s,n,o,r)}invalidateConnectedLinks(t){const i=this.linksConnected;for(;i.next();){const e=i.value;t!==void 0&&t.has(e)||(this.xe(e.fromPort),this.xe(e.toPort),e.invalidateRoute())}}aL(t){const i=this.linksConnected;for(;i.next();){const e=i.value;e.fromPort!==t&&e.toPort!==t||(this.xe(e.fromPort),this.xe(e.toPort),e.invalidateRoute())}}xe(t){if(t===null)return;const i=t.nd;i!==null&&i.Vd();const e=t.part,s=e.containingGroup;s!==null&&!e.isVisible()&&s.xe(s.port)}$r(){return!0}get portSpreading(){return this.bt!==null?this.bt.gy:1}set portSpreading(t){const i=this.portSpreading;if(i!==t){Debug&&t!==0&&t!==1&&t!==2&&Util.n("Node.portSpreading can only be set to PortSpreading.None, PortSpreading.Evenly, or PortSpreading.Packed, not: "+t),this.ml(),this.bt.gy=t,this.i("portSpreading",i,t);const e=this.diagram;if(e!==null&&e.undoManager.isUndoingRedoing)return;this.invalidateConnectedLinks()}}get avoidable(){return(this.z&8)!==0}set avoidable(t){const i=(this.z&8)!==0;if(i!==t){Debug&&Util.t(t,"boolean",Node,"avoidable"),this.z=this.z^8;const e=this.diagram;e!==null&&e.HP(this),this.i("avoidable",i,t)}}get avoidableMargin(){return this.bt!==null?this.bt.my:Margin.gC}set avoidableMargin(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Node,"avoidableMargin");const i=this.avoidableMargin;if(!i.equals(t)){t=t.L(),this.ml(),this.bt.my=t;const e=this.diagram;e!==null&&e.HP(this),this.i("avoidableMargin",i,t)}}canAvoid(){return this.avoidable&&!this.isLinkLabel}getAvoidableRect(t){return t.set(this.actualBounds),t.addMargin(this.avoidableMargin),t}findVisibleNode(){let t=this;for(;t!==null&&!t.isVisible();)t=t.containingGroup;return t}isVisible(){if(!super.isVisible())return!1;let t=!0,i=1;const e=this.diagram;if(e!==null){if(e.animationManager.ux(this))return!0;t=e.isTreePathToChildren,i=e.treeCollapsePolicy}if(i===1){const n=this.findTreeParentNode();if(n!==null&&!n.isTreeExpanded)return!1}else if(i===2){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&h.isTreeExpanded){r=!0;break}}}if(o&&!r)return!1}else if(i===3){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&!h.isTreeExpanded){r=!0;break}}}if(o&&r)return!1}const s=this.labeledLink;return s!==null?s.isVisible():!0}Ki(t){super.Ki(t);const i=this.linksConnected;for(;i.next();){const e=i.value;if(t&&this.containingGroup!==null){const s=e.getOtherNode(this);s!==null&&!s.isMemberOf(this.containingGroup)&&e.invalidateRoute()}e.Ki(t)}}get linksConnected(){return this.ni.iterator}findExternalTreeLinksConnected(){const t=new GSet,i=new GSet;return this.rT(this,t,i),i.iterator}rT(t,i,e){if(t===null||i.has(t))return;i.add(t);let s=!0;const n=this.diagram;n!==null&&(s=n.isTreePathToChildren),t.linksConnected.each(o=>{o.isTreeLink?(s?o.fromNode===t:o.toNode===t)&&this.rT(s?o.toNode:o.fromNode,i,e):e.add(o)})}findLinksConnected(t){if(t===void 0&&(t=null),t===null)return this.ni.iterator;Debug&&Util.t(t,"string",Node,"findLinksConnected:pid");const i=new ListIterator(this.ni),e=this;return i.predicate=s=>s.fromNode===e&&s.fromPortId===t||s.toNode===e&&s.toPortId===t,i}findLinksOutOf(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findLinksOutOf:pid");const i=new ListIterator(this.ni),e=this;return i.predicate=s=>s.fromNode!==e?!1:t===null?!0:s.fromPortId===t,i}findLinksInto(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findLinksInto:pid");const i=new ListIterator(this.ni),e=this;return i.predicate=s=>s.toNode!==e?!1:t===null?!0:s.toPortId===t,i}findNodesConnected(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findNodesConnected:pid");let i=null,e=null;const s=this.ni.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this){if(t===null||n.fromPortId===t){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}else if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesOutOf(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findNodesOutOf:pid");let i=null,e=null;const s=this.ni.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this&&(t===null||n.fromPortId===t)){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesInto(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findNodesInto:pid");let i=null,e=null;const s=this.ni.iterator;for(;s.next();){const n=s.value;if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findLinksBetween(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),Debug&&(Util.s(t,Node,Node,"findLinksBetween:othernode"),i!==null&&Util.t(i,"string",Node,"findLinksBetween:pid"),e!==null&&Util.t(e,"string",Node,"findLinksBetween:otherpid"));const s=new ListIterator(this.ni),n=this;return s.predicate=o=>o.fromNode===n&&o.toNode===t&&(i===null||o.fromPortId===i)&&(e===null||o.toPortId===e)||o.fromNode===t&&o.toNode===n&&(e===null||o.fromPortId===e)&&(i===null||o.toPortId===i),s}findLinksTo(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),Debug&&(Util.s(t,Node,Node,"findLinksTo:othernode"),i!==null&&Util.t(i,"string",Node,"findLinksTo:pid"),e!==null&&Util.t(e,"string",Node,"findLinksTo:otherpid"));const s=new ListIterator(this.ni),n=this;return s.predicate=o=>!(o.fromNode!==n||o.toNode!==t||i!==null&&o.fromPortId!==i||e!==null&&o.toPortId!==e),s}get linkConnected(){return this.bt!==null?this.bt.py:null}set linkConnected(t){const i=this.linkConnected;i!==t&&(t!==null&&Util.t(t,"function",Node,"linkConnected"),this.ml(),this.bt.py=t,this.i("linkConnected",i,t))}get linkDisconnected(){return this.bt!==null?this.bt.yy:null}set linkDisconnected(t){const i=this.linkDisconnected;i!==t&&(t!==null&&Util.t(t,"function",Node,"linkDisconnected"),this.ml(),this.bt.yy=t,this.i("linkDisconnected",i,t))}get linkValidation(){return this.bt!==null?this.bt.Ll:null}set linkValidation(t){const i=this.linkValidation;i!==t&&(t!==null&&Util.t(t,"function",Node,"linkValidation"),this.ml(),this.bt.Ll=t,this.i("linkValidation",i,t))}xb(t,i){this.xe(i);const e=this.ni.has(t);if(e||this.ni.add(t),!e||t.fromNode===t.toNode){const s=this.linkConnected;if(s!==null){let n=!0;const o=this.diagram;o!==null&&(n=o.j,o.j=!0),s(this,t,i),o!==null&&(o.j=n)}}if(!e){if(!t.isTreeLink)return;const s=t.fromNode,n=t.toNode;if(s!==null&&n!==null&&s!==n){let o=!0;const r=this.diagram;r!==null&&(o=r.isTreePathToChildren);const l=o?n:s,h=o?s:n;if(l.bh||(l.bh=h),h.isTreeLeaf){if(r!==null&&r.undoManager.isUndoingRedoing)return;o?s===h&&(h.isTreeLeaf=!1):n===h&&(h.isTreeLeaf=!1)}}}}bb(t,i){this.xe(i);const e=this.ni.delete(t);let s=null;if(e||t.toNode===t.fromNode){const n=this.linkDisconnected;if(s=this.diagram,n!==null){let o=!0;s!==null&&(o=s.j,s.j=!0),n(this,t,i),s!==null&&(s.j=o)}}if(e){if(!t.isTreeLink)return;let n=!0;s!==null&&(n=s.isTreePathToChildren);const o=n?t.toNode:t.fromNode,r=n?t.fromNode:t.toNode;if(o!==null&&(o.bh=!1),r!==null&&!r.isTreeLeaf)if(r.ni.count===0){if(r.bh=null,s!==null&&s.undoManager.isUndoingRedoing)return;r.isTreeLeaf=!0}else r.x0()}}x0(){if(this.bh=!1,this.ni.count===0)return;let t=!0;const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;i!==null&&(t=i.isTreePathToChildren);const e=this.ni.iterator;for(;e.next();){const s=e.value;if(s.isTreeLink){if(t){if(s.fromNode===this){this.isTreeLeaf=!1;return}}else if(s.toNode===this){this.isTreeLeaf=!1;return}}}this.isTreeLeaf=!0}updateRelationshipsFromData(){const t=this.diagram;t!==null&&t.partManager.updateRelationshipsFromData(this)}Hm(t){if(super.Hm(t),!t){this.x0();const i=this.Cc;i!==null&&i.lT(this)}}qm(t){if(super.qm(t),!t){const i=this.Cc;i!==null&&i.hT(this)}}Jf(){if(this.ni.count>0){const t=this.diagram;if(t!==null){const i=t.commandHandler!==null?t.commandHandler.deletesConnectedLinks:!0,s=this.ni.copy().iterator;for(;s.next();){const n=s.value;i?t.remove(n):(n.fromNode===this&&(n.fromNode=null),n.toNode===this&&(n.toNode=null))}}}this.labeledLink=null,super.Jf()}get isLinkLabel(){return this.Cc!==null}get labeledLink(){return this.Cc}set labeledLink(t){const i=this.Cc;if(i!==t){Debug&&t!==null&&Util.s(t,Link,Node,"labeledLink");const e=this.diagram,s=this.data;if(i!==null){if(i.hT(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=i.data,o=e.model;if(n!==null&&o.Oa()){const r=o.getKeyForNodeData(s);r!==void 0&&o.removeLabelKeyForLinkData(n,r)}}this.containingGroup=null}if(this.Cc=t,t!==null){if(t.lT(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=t.data,o=e.model;if(n!==null&&o.Oa()){const r=o.getKeyForNodeData(s);r!==void 0&&o.addLabelKeyForLinkData(n,r)}}this.containingGroup=t.containingGroup}this.lc(),this.i("labeledLink",i,t)}}findVisiblePort(t){let i=t;for(;i!==null&&(!i.actualBounds.isReal()||!i.isVisibleObject());)i=i.panel;return i===null?this.port:i}findPort(t){if(Debug&&Util.t(t,"string",Node,"findPort:pid"),this.he===null){if(t===""&&this.Mn===!1)return this;this.aT()}let i=this.he.get(t);return i!==null||t!==""&&(i=this.he.get(""),i!==null)?i:this}get port(){return this.findPort("")}get ports(){return this.he===null&&this.aT(),this.he.iteratorValues}aT(){this.he===null?this.he=new GMap:this.he.clear(),this.walkVisualTreeFrom(this,(t,i)=>t.yL(i)),this.he.count===0&&this.he.set("",this)}yL(t){const i=t.portId;i!==null&&this.he!==null&&this.he.set(i,t)}P2(t,i){const e=t.portId;if(e!==null){this.he!==null&&this.he.delete(e);const s=this.diagram;if(s!==null&&i){let n=null;const o=this.findLinksConnected(e);for(;o.next();){const r=o.value;n===null&&(n=Util.ft()),n.push(r)}if(n!==null){for(let r=0;r!(!n.isTreeLink||n.fromNode!==s):e.predicate=n=>!(!n.isTreeLink||n.toNode!==s),e}findTreeChildrenNodes(){let t=!0;const i=this.diagram;i!==null&&(t=i.isTreePathToChildren);let e=null,s=null;const n=this.ni.iterator;if(t)for(;n.next();){const o=n.value;if(o.isTreeLink&&o.fromNode===this){const r=o.toNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}else for(;n.next();){const o=n.value;if(o.isTreeLink&&o.toNode===this){const r=o.fromNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}return e!==null?e.iterator:s!==null?new SingletonIterator(s):EmptyIterator.instance}findTreeParts(t){t===void 0&&(t=1/0),Util.t(t,"number",Node,"findTreeParts:level");const i=new GSet;return Part.lh(i,this,!1,t,!0),i}collapseTree(t){t===void 0&&(t=1),Util.r(t,Node,"collapseTree:level"),t<1&&(t=1);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.fT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}fT(t,i,e,s,n,o){if(e>1){const r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);h!==null&&h!==this&&!t.has(h)&&(t.add(h),h.fT(t,i,e-1,s,n,o))}}else this.cT(t,i,s,n,o)}cT(t,i,e,s,n){const o=s===this?!0:this.isTreeExpanded,r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);if(h!==null&&h!==this){const a=t.has(h);if(a||t.add(h),o){const f=i?h.findNodesInto():h.findNodesOutOf(),c=this;f.all(u=>u===c||!u.isTreeExpanded)&&e.Of(h,s),h.dh(),h.Ki(!1)}h.isTreeExpanded&&(h.wasTreeExpanded=h.isTreeExpanded,a||h.cT(t,i,e,s,n))}}this.isTreeExpanded=!1}expandTree(t){t===void 0&&(t=2),Util.r(t,Node,"expandTree:level"),t<2&&(t=2);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.uT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}uT(t,i,e,s,n,o){const r=n===this?!1:this.isTreeExpanded,l=i?this.findLinksOutOf():this.findLinksInto();for(;l.next();){const h=l.value;if(!h.isTreeLink)continue;r||h.Te||h.invalidateRoute();const a=h.getOtherNode(this);if(a!==null&&a!==this&&!t.has(a)){if(t.add(a),!r){a.Ki(!0),a.dh();const f=i?a.findNodesInto():a.findNodesOutOf(),c=this;f.all(u=>u===c||!u.isTreeExpanded)&&s.If(a,n)}(e>2||a.wasTreeExpanded)&&(a.wasTreeExpanded=!1,a.uT(t,i,e-1,s,n,o))}}this.isTreeExpanded=!0}get isTreeExpanded(){return(this.z&1)!==0}set isTreeExpanded(t){const i=(this.z&1)!==0;if(i!==t){Debug&&Util.t(t,"boolean",Node,"isTreeExpanded"),this.z=this.z^1;const e=this.diagram;this.i("isTreeExpanded",i,t);const s=this.treeExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.j,e.j=!0),s(this),e!==null&&(e.j=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.Ki(t);return}t?this.expandTree():this.collapseTree()}}get wasTreeExpanded(){return(this.z&2)!==0}set wasTreeExpanded(t){const i=(this.z&2)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Node,"wasTreeExpanded"),this.z=this.z^2,this.i("wasTreeExpanded",i,t))}get treeExpandedChanged(){return this.bt!==null?this.bt.wy:null}set treeExpandedChanged(t){const i=this.treeExpandedChanged;i!==t&&(t!==null&&Util.t(t,"function",Node,"treeExpandedChanged"),this.ml(),this.bt.wy=t,this.i("treeExpandedChanged",i,t))}get isTreeLeaf(){return(this.z&4)!==0}set isTreeLeaf(t){const i=(this.z&4)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Node,"isTreeLeaf"),this.z=this.z^4,this.i("isTreeLeaf",i,t))}get isTreeRoot(){return this.findTreeParentLink()===null}}class NodeTemplateSettings{wi;py;yy;Ll;wy;my;gy;xy;by;rh;ky;constructor(){this.wi=!1,this.py=null,this.yy=null,this.Ll=null,this.wy=null,this.my=Margin.gC,this.gy=1,this.xy=null,this.by=null,this.rh=null,this.ky=null}copy(){const t=new NodeTemplateSettings;return t.py=this.py,t.yy=this.yy,t.Ll=this.Ll,t.wy=this.wy,t.my=this.my.L(),t.gy=this.gy,t.xy=this.xy,t.by=this.by,t.rh=this.rh,t.ky=this.ky,t}}var LinkAdjusting=(w=>(w[w.None=0]="None",w[w.End=17]="End",w[w.Scale=18]="Scale",w[w.Stretch=19]="Stretch",w))(LinkAdjusting||{}),Routing=(w=>(w[w.Normal=1]="Normal",w[w.Orthogonal=2]="Orthogonal",w[w.AvoidsNodes=6]="AvoidsNodes",w[w.AvoidsNodesStraight=7]="AvoidsNodesStraight",w))(Routing||{}),Curve=(w=>(w[w.None=0]="None",w[w.Bezier=9]="Bezier",w[w.JumpGap=10]="JumpGap",w[w.JumpOver=11]="JumpOver",w))(Curve||{});class Link extends Part{Dt;go;mo;Bd;po;yo;zd;Ac;Xd;Yd;Kd;Ea;Ud;$s;Ni;Ie;Lr;Lc;ir;lN;hN;kb;aN;fN;Sy;Sb;yt;er;static Va=null;static Ba=null;dc;cN;uN;constructor(t){super(Panel.Link),this.Dt=8,this.go=null,this.mo="",this.Bd=null,this.po=null,this.yo="",this.zd=null,this.Ac=0,this.Xd=0,this.Yd=0,this.Kd=NaN,this.Ea=1,this.Ud=.5,this.$s=null,this.Ni=new List().w(),this.Ie=null,this.Lr=null,this.Lc=new Rect,this.yt=new Geometry,this.ir=null,this.er=null,this.lN=null,this.hN=null,this.cN=0,this.uN=0,this.kb=new Point,this.aN=null,this.fN=null,this.Sy=null,this.Sb=NaN,this.Z=null,this.dc=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Dt=this.Dt&-113,t.mo=this.mo,t.Bd=this.Bd,t.yo=this.yo,t.zd=this.zd,t.Ac=this.Ac,t.Xd=this.Xd,t.Yd=this.Yd,t.Kd=this.Kd,t.Ea=this.Ea,t.Ud=this.Ud,this.Z!==null&&(t.Z=this.Z.copy())}Ho(t){super.Ho(t),this.mo=t.mo,this.yo=t.yo,t.Ie=null,t.invalidateRoute(),t.er=this.er;const i=t.fromPort;i!==null&&t.fromNode.xe(i);const e=t.toPort;e!==null&&t.toNode.xe(e)}fi(t){t in Routing||t in Curve||t in LinkAdjusting?Link.dN(t)?this.routing=t:t===9||t===10||t===11?this.curve=t:t===17||t===18||t===19?this.adjusting=t:t===1||t===0||Util.n("Unknown Link enum value for a Link property: "+t):super.fi(t)}static Normal=1;static Orthogonal=2;static AvoidsNodes=6;static AvoidsNodesStraight=7;static None=0;static Bezier=9;static JumpGap=10;static JumpOver=11;static End=17;static Scale=18;static Stretch=19;static OrientAlong=21;static OrientPlus90=22;static OrientMinus90=23;static OrientOpposite=24;static OrientUpright=25;static OrientPlus90Upright=26;static OrientMinus90Upright=27;static OrientUpright45=28;static JI=8;static ZI=16;static $I=14;static za=8;je(){this.Z===null&&(this.Z=new LinkSettings)}rI(t,i,e){const s=t.segmentIndex,n=t.segmentFraction;let o=t.alignmentFocus;const r=t.segmentOrientation,l=t.segmentOffset;let h=0,a=0,f=0,c=0;if(isNaN(s)){const C=this.yt,P=Util.ft();C.getPointAndAngleAlongPath(n,P);const N=Point.H(P[0],P[1]);if(N.add(this.getPoint(0)),C.type===1)N.offset(-C.startX,-C.startY);else{const T=C.figures.first();N.offset(-T.startX,-T.startY)}c=P[2],r!==0&&(f=this.computeAngle(t,r,c),t.angle=f),h=N.x,a=N.y,Point.o(N),Util.nt(P)}else if(s<-i||s>=i){const C=Point.a();this.ML(C),c=this.midAngle,r!==0&&(f=this.computeAngle(t,r,c),t.angle=f),h=C.x,a=C.y,Point.o(C)}else{let C,P,N=0;if(s>=0?(C=e.h[s],P=s0?e.h[N-1]:C),C.equalsApprox(P)){let T,L;s>=0?(T=s>0?e.h[s-1]:C,L=s1?e.h[N-2]:P);const D=T.distanceSquaredPoint(C),F=P.distanceSquaredPoint(L);D>F+10?c=s>=0?T.directionPoint(C):C.directionPoint(T):F>D+10?c=s>=0?P.directionPoint(L):L.directionPoint(P):c=s>=0?T.directionPoint(L):L.directionPoint(T)}else c=s>=0?C.directionPoint(P):P.directionPoint(C);r!==0&&(f=this.computeAngle(t,r,c),t.angle=f),h=C.x+(P.x-C.x)*n,a=C.y+(P.y-C.y)*n}if(o.isNone()){t.location=new Point(h,a);return}else o.isNoSpot()&&(o=Spot.Center);const u=Transform.a();u.Bi(),u.lt(t.scale,t.scale),u.ms(t.angle,0,0);const d=t.naturalBounds,m=Rect.H(0,0,d.width,d.height),g=Point.a();g.setRectSpot(m,o),u.Pt(g);let p=-g.x,y=-g.y;const x=d.width,k=d.height,b=Point.a();b.c(l);const S=isNaN(l.x),M=isNaN(l.y);if(S||M){const C=x/2+3,P=k/2+3,N=c>=45&&c<=135,T=c>=225&&c<=315;r===0&&(N||T)?(b.x=M?C:l.y,b.y=S?P:l.x,N?s>=0||isNaN(s)&&n<.5||S&&(b.y=-P):T&&((s>=0||isNaN(s)&&n<.5)&&S&&(b.y=-P),M&&(b.x=-C))):(S&&(s>=0||isNaN(s)&&n<.5?b.x=C:b.x=-C),M&&(b.y=-P),b.rotate(c))}else b.rotate(c);h+=b.x,a+=b.y,u.Cw(m),p+=m.x,y+=m.y;const A=Point.H(h+p,a+y);t.move(A),Point.o(A),Point.o(b),Point.o(g),Rect.o(m),Transform.o(u)}$r(){let t=this.fromNode;if(t!==null){const e=t.findVisibleNode();if(e!==null&&(t=e),t.rs()||t.nh())return!1}let i=this.toNode;if(i!==null){const e=i.findVisibleNode();if(e!==null&&(i=e),i.rs()||i.nh())return!1}return!0}S2(t,i,e){return!1}M2(){}Ae(){return!1}computeAngle(t,i,e){return Link.computeAngle(i,e)}static computeAngle(t,i){let e=0;switch(t){default:case 0:e=0;break;case 21:e=i;break;case 22:e=i+90;break;case 23:e=i-90;break;case 24:e=i+180;break;case 25:e=Geo.Jg(i),e>90&&e<270&&(e-=180);break;case 26:e=Geo.Jg(i+90),e>90&&e<270&&(e-=180);break;case 27:e=Geo.Jg(i-90),e>90&&e<270&&(e-=180);break;case 28:if(e=Geo.Jg(i),e>45&&e<135||e>225&&e<315)return 0;e>90&&e<270&&(e-=180);break}return Geo.Jg(e)}get fromNode(){return this.go}set fromNode(t){const i=this.go;if(i!==t){Debug&&t!==null&&Util.s(t,Node,Link,"fromNode");const e=this.fromPort;i!==null&&(this.po!==i&&i.bb(this,e),this.My(),this.invalidateLayout(2)),this.go=t,t!==null&&this.Ki(t.isVisible()),this.ir=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.j&&s.partManager.setFromNodeForLink(this,t,i);const n=this.fromPort,o=this.fromPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.j,s.j=!0),o(this,e,n),s!==null&&(s.j=r)}t!==null&&(this.po!==t&&t.xb(this,n),this.Py(),this.invalidateLayout(1)),this.i("fromNode",i,t),this.Ed()}}get fromPortId(){return this.mo}set fromPortId(t){const i=this.mo;if(i!==t){Debug&&Util.t(t,"string",Link,"fromPortId");const e=this.fromPort;e!==null&&this.fromNode.xe(e),this.My(),this.mo=t;const s=this.fromPort;s!==null&&this.fromNode.xe(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Oa()&&r.setFromPortIdForLinkData(o,t)}if(e!==s){this.ir=null,this.invalidateRoute();const o=this.fromPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.j,n.j=!0),o(this,e,s),n!==null&&(n.j=r)}}this.Py(),this.i("fromPortId",i,t)}}get fromPort(){const t=this.go;if(t===null)return null;const i=this.mo;return t.findPort(i)}get fromPortChanged(){return this.Bd}set fromPortChanged(t){const i=this.Bd;i!==t&&(t!==null&&Util.t(t,"function",Link,"fromPortChanged"),this.Bd=t,this.i("fromPortChanged",i,t))}get toNode(){return this.po}set toNode(t){const i=this.po;if(i!==t){Debug&&t!==null&&Util.s(t,Node,Link,"toNode");const e=this.toPort;i!==null&&(this.go!==i&&i.bb(this,e),this.My(),this.invalidateLayout(2)),this.po=t,t!==null&&this.Ki(t.isVisible()),this.ir=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.j&&s.partManager.setToNodeForLink(this,t,i);const n=this.toPort,o=this.toPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.j,s.j=!0),o(this,e,n),s!==null&&(s.j=r)}t!==null&&(this.go!==t&&t.xb(this,n),this.Py(),this.invalidateLayout(1)),this.i("toNode",i,t),this.Ed()}}get toPortId(){return this.yo}set toPortId(t){const i=this.yo;if(i!==t){Debug&&Util.t(t,"string",Link,"toPortId");const e=this.toPort;e!==null&&this.toNode.xe(e),this.My(),this.yo=t;const s=this.toPort;s!==null&&this.toNode.xe(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Oa()&&r.setToPortIdForLinkData(o,t)}if(e!==s){this.ir=null,this.invalidateRoute();const o=this.toPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.j,n.j=!0),o(this,e,s),n!==null&&(n.j=r)}}this.Py(),this.i("toPortId",i,t)}}get toPort(){const t=this.po;if(t===null)return null;const i=this.yo;return t.findPort(i)}get toPortChanged(){return this.zd}set toPortChanged(t){const i=this.zd;i!==t&&(t!==null&&Util.t(t,"function",Link,"toPortChanged"),this.zd=t,this.i("toPortChanged",i,t))}get fromSpot(){return this.Z!==null?this.Z.ma:Spot.Default}set fromSpot(t){const i=this.fromSpot;if(!i.equals(t)){if(Debug&&Util.s(t,Spot,Link,"fromSpot"),t=t.L(),this.je(),this.Z.ma=t,this.i("fromSpot",i,t),i.isSide()||t.isSide()){const e=this.fromNode;e!==null&&e.xe(this.fromPort)}this.invalidateRoute()}}get fromEndSegmentLength(){return this.Z!==null?this.Z.ya:NaN}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;i!==t&&(Debug&&Util.t(t,"number",Link,"fromEndSegmentLength"),t<0&&Util.G(t,">= 0",Link,"fromEndSegmentLength"),this.je(),this.Z.ya=t,this.i("fromEndSegmentLength",i,t),this.invalidateRoute())}get fromShortLength(){return this.Z!==null?this.Z.xa:NaN}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(Debug&&Util.t(t,"number",Link,"fromShortLength"),this.je(),this.Z.xa=t,this.re(),this.i("fromShortLength",i,t))}get toSpot(){return this.Z!==null?this.Z.pa:Spot.Default}set toSpot(t){const i=this.toSpot;if(!i.equals(t)){if(Debug&&Util.s(t,Spot,Link,"toSpot"),t=t.L(),this.je(),this.Z.pa=t,this.i("toSpot",i,t),i.isSide()||t.isSide()){const e=this.toNode;e!==null&&e.xe(this.toPort)}this.invalidateRoute()}}get toEndSegmentLength(){return this.Z!==null?this.Z.wa:NaN}set toEndSegmentLength(t){const i=this.toEndSegmentLength;i!==t&&(Debug&&Util.t(t,"number",Link,"toEndSegmentLength"),t<0&&Util.G(t,">= 0",Link,"toEndSegmentLength"),this.je(),this.Z.wa=t,this.i("toEndSegmentLength",i,t),this.invalidateRoute())}get toShortLength(){return this.Z!==null?this.Z.ba:NaN}set toShortLength(t){const i=this.toShortLength;i!==t&&(Debug&&Util.t(t,"number",Link,"toShortLength"),this.je(),this.Z.ba=t,this.re(),this.i("toShortLength",i,t))}Ed(){const t=this.fromNode,i=this.toNode;let e=null;if(t!==null?i!==null?e=t.findCommonContainingGroup(i):e=t.containingGroup:i!==null?e=i.containingGroup:e=null,this.QI(e),this.isLabeledLink){const s=this.labelNodes;for(;s.next();){const n=s.value;n.containingGroup=e}}}QI(t){const i=this.xh;if(i!==t){i!==null&&i.tN(this),this.xh=t,t!==null&&t.iN(this);const e=this.containingGroupChanged;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.j,n.j=!0),e(this,i,t),n!==null&&(n.j=s)}this.Te&&(this.aN===i||this.fN===i)&&this.invalidateRoute()}}dh(){const t=this.containingGroup;t!==null&&this.fromNode!==t&&this.toNode!==t&&t.computesBoundsIncludingLinks&&super.dh()}getOtherNode(t){Debug&&Util.s(t,Node,Link,"getOtherNode:node");const i=this.fromNode;return t===i?this.toNode:i}getOtherPort(t){Debug&&Util.s(t,GraphObject,Link,"getOtherPort:port");const i=this.fromPort;return t===i?this.toPort:i}get isLabeledLink(){return this.$s===null?!1:this.$s.count>0}get labelNodes(){return this.$s===null?EmptyIterator.instance:this.$s.iterator}lT(t){this.$s===null&&(this.$s=new GSet),this.$s.add(t),this.u()}hT(t){this.$s!==null&&(this.$s.delete(t),this.u())}Hm(t){if(super.Hm(t),this.Xa()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.go;let e=null;i!==null&&(e=this.fromPort,i.xb(this,e));const s=this.po;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.xb(this,n)),this.Py()}}qm(t){if(super.qm(t),this.Xa()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.go;let e=null;i!==null&&(e=this.fromPort,i.bb(this,e));const s=this.po;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.bb(this,n)),this.My()}}Jf(){if(this.Te=!0,this.$s!==null){const i=this.diagram;if(i!==null){const s=this.$s.copy().iterator;for(;s.next();){const n=s.value;i.remove(n)}}}if(this.data!==null){const i=this.diagram;i!==null&&i.partManager.gN(this)}}updateRelationshipsFromData(){if(this.data===null)return;const i=this.diagram;i!==null&&i.partManager.updateRelationshipsFromData(this)}move(t,i){const e=i?this.location:this.position;let s=e.x;isNaN(s)&&(s=0);let n=e.y;isNaN(n)&&(n=0);const o=t.x-s,r=t.y-n;if(i===!0)super.move(t,!1);else{const h=Point.H(e.x+o,e.y+r);super.move(h,!1),Point.o(h)}this.kr(o,r);const l=this.labelNodes;for(;l.next();){const h=l.value,a=h.position;h.moveTo(a.x+o,a.y+r)}}get relinkableFrom(){return(this.Dt&1)!==0}set relinkableFrom(t){const i=(this.Dt&1)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"relinkableFrom"),this.Dt=this.Dt^1,this.i("relinkableFrom",i,t),this.invalidateAdornments())}get relinkableTo(){return(this.Dt&2)!==0}set relinkableTo(t){const i=(this.Dt&2)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"relinkableTo"),this.Dt=this.Dt^2,this.i("relinkableTo",i,t),this.invalidateAdornments())}canRelinkFrom(){if(!this.relinkableFrom)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}canRelinkTo(){if(!this.relinkableTo)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}get resegmentable(){return(this.Dt&4)!==0}set resegmentable(t){const i=(this.Dt&4)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"resegmentable"),this.Dt=this.Dt^4,this.i("resegmentable",i,t),this.invalidateAdornments())}get isTreeLink(){return(this.Dt&8)!==0}set isTreeLink(t){const i=(this.Dt&8)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"isTreeLink"),this.Dt=this.Dt^8,this.i("isTreeLink",i,t),this.fromNode!==null&&this.fromNode.x0(),this.toNode!==null&&this.toNode.x0())}get path(){const t=this.findMainElement();return t instanceof Shape?t:null}get routeBounds(){return this.updateRoute(),this._I(this.Lc)}_I(t){let i=1/0,e=1/0;const s=this.pointsCount;if(s===0)return t.e(NaN,NaN,0,0),t;if(s===1){const n=this.getPoint(0);i=Math.min(n.x,i),e=Math.min(n.y,e),t.e(n.x,n.y,0,0)}else if(s===2){const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o)}else if(this.computeCurve()===9&&s>=3&&!this.isOrthogonal){let n=this.getPoint(0);if(i=n.x,e=n.y,t.e(i,e,0,0),s===3){const o=this.getPoint(1);i=Math.min(o.x,i),e=Math.min(o.y,e);const r=this.getPoint(2);i=Math.min(r.x,i),e=Math.min(r.y,e),Geo.mu(n.x,n.y,o.x,o.y,o.x,o.y,r.x,r.y,.5,t)}else for(let o=3;o=s&&(o=s-1);const l=this.getPoint(o-1),h=this.getPoint(o);Geo.mu(n.x,n.y,r.x,r.y,l.x,l.y,h.x,h.y,.5,t),i=Math.min(h.x,i),e=Math.min(h.y,e),n=h}}else{const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o);for(let r=2;r=15||this.computeCurve()===9)){this.yt.getPointAlongPath(.5,t),t.add(this.getPoint(0));const a=this.yt.figures.first();return t.offset(-a.startX,-a.startY),t}if(this.computeCurve()===9){if(i===3){const c=this.getPoint(0),u=this.getPoint(1),d=this.getPoint(2);return Geo.bC(c.x,c.y,u.x,u.y,u.x,u.y,d.x,d.y,t),t}const a=(i-1)/3|0,f=(a/2|0)*3;if(a%2===1){const c=this.getPoint(f),u=this.getPoint(f+1),d=this.getPoint(f+2),m=this.getPoint(f+3);return Geo.bC(c.x,c.y,u.x,u.y,d.x,d.y,m.x,m.y,t),t}else return t.c(this.getPoint(f)),t}const e=this.flattenedLengths,s=this.flattenedTotalLength;let n=0,o=0,r=0;for(;ns/2));)n+=r,o++;const l=this.getPoint(o),h=this.getPoint(o+1);if(Math.abs(l.x-h.x)<1)l.y>h.y?t.e(l.x,l.y-(s/2-n)):t.e(l.x,l.y+(s/2-n));else if(Math.abs(l.y-h.y)<1)l.x>h.x?t.e(l.x-(s/2-n),l.y):t.e(l.x+(s/2-n),l.y);else{const a=(s/2-n)/r,f=a*(h.x-l.x),c=a*(h.y-l.y);t.e(l.x+f,l.y+c)}return t}get midAngle(){return this.updateRoute(),this.computeMidAngle()}computeMidAngle(){const t=this.pointsCount;if(t<2)return NaN;if(t===2){const h=this.getPoint(0),a=this.getPoint(1);return h.directionPoint(a)}if(this.isOrthogonal&&(this.computeCorner()>=15||this.computeCurve()===9))return this.yt.getAngleAlongPath(.5);if(this.computeCurve()===9&&t>=4){const h=(t-1)/3|0;let a=(h/2|0)*3;if(h%2===1){a=Math.floor(a);const f=this.getPoint(a),c=this.getPoint(a+1),u=this.getPoint(a+2),d=this.getPoint(a+3);return Geo.YD(f.x,f.y,c.x,c.y,u.x,u.y,d.x,d.y)}else if(a>0&&a+1e/2));)s+=o,n++;const r=this.getPoint(n),l=this.getPoint(n+1);if(Math.abs(r.x-l.x)<1&&Math.abs(r.y-l.y)<1){if(n>0&&n+2l.y?270:90;if(Math.abs(r.y-l.y)<1)return r.x>l.x?180:0}return r.directionPoint(l)}tO(){if(this.Sy===null){this.Te||this.Mb();const t=this.Sy=[];this.iO(t)}}get flattenedLengths(){return this.tO(),this.Sy}get flattenedTotalLength(){let t=this.Sb;if(isNaN(t)){const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=3){let g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e);m=this.adjustPoints(0,g,o-1,p),m&&(g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e),this.adjustPoints(0,g,o-1,p))}m||(this.clearPoints(),u?this.eO(i,e,r,s,n,l):this.sO(i,e,r,s,n,l))}else{const m=this.isAvoiding;d&&(c&&m||f)&&this.clearPoints();const g=f?this.computeCurviness():0,p=this.getLinkPoint(i,e,r,!0,c,s,n);let y=0,x=0,k=0;if(c||!h||f){let N=this.computeEndSegmentLength(i,e,r,!0);if(k=this.getLinkDirection(i,e,p,r,!0,c,s,n),f&&(h||r.equals(l)||!c&&r.x+l.x===1&&r.y+l.y===1)&&(k-=c?90:30,g<0&&(k-=180)),k<0?k+=360:k>=360&&(k-=360),f&&(N+=Math.abs(g)*(c?1:2)),k===0?y=N:k===90?x=N:k===180?y=-N:k===270?x=-N:(y=N*Math.cos(k*Math.PI/180),x=N*Math.sin(k*Math.PI/180)),r.isNoSpot()&&f){const T=e.getDocumentPoint(Spot.Center,Point.a()),L=Point.H(T.x+y*1e3,T.y+x*1e3);this.getLinkPointFromPoint(i,e,T,L,!0,p),Point.o(T),Point.o(L)}}const b=this.getLinkPoint(s,n,l,!1,c,i,e);let S=0,M=0,A=0;if(c||!a||f){let N=this.computeEndSegmentLength(s,n,l,!1);if(A=this.getLinkDirection(s,n,b,l,!1,c,i,e),f&&(a||r.equals(l)||!c&&r.x+l.x===1&&r.y+l.y===1)&&(A+=c?0:30,g<0&&(A+=180)),A<0?A+=360:A>=360&&(A-=360),f&&(N+=Math.abs(g)*(c?1:2)),A===0?S=N:A===90?M=N:A===180?S=-N:A===270?M=-N:(S=N*Math.cos(A*Math.PI/180),M=N*Math.sin(A*Math.PI/180)),l.isNoSpot()&&f){const T=n.getDocumentPoint(Spot.Center,Point.a()),L=Point.H(T.x+S*1e3,T.y+M*1e3);this.getLinkPointFromPoint(s,n,T,L,!1,b),Point.o(T),Point.o(L)}}let C=p;(c||!h||f)&&(C=new Point(p.x+y,p.y+x));let P=b;(c||!a||f)&&(P=new Point(b.x+S,b.y+M)),!d&&!c&&h&&o>3&&this.adjustPoints(0,p,o-2,P)?this.setPoint(o-1,b):!d&&!c&&a&&o>3&&this.adjustPoints(1,C,o-1,b)?this.setPoint(0,p):!d&&(c?o>=6:o>4)&&this.adjustPoints(1,C,o-2,P)?(this.setPoint(0,p),this.setPoint(o-1,b)):(this.clearPoints(),this.addPoint(p),(c||!h||f)&&this.addPoint(C),c&&this.addOrthoPoints(C,k,P,A,i,s),(c||!a||f)&&this.addPoint(P),this.addPoint(b))}return t.addInvalidRoute(this),!0}pN(t,i){return Math.abs(i.x-t.x)>Math.abs(i.y-t.y)?(i.x>=t.x?i.x=t.x+9e9:i.x=t.x-9e9,i.y=t.y):(i.y>=t.y?i.y=t.y+9e9:i.y=t.y-9e9,i.x=t.x),i}getLinkPointFromPoint(t,i,e,s,n,o){if(o===void 0&&(o=new Point),t===null||i===null)return o.c(e),o;if(!t.isVisible()){const u=t.findVisibleNode();u!==null&&u!==t&&(t=u,i=t.port)}let r=0,l=0,h=0,a=0,f=null,c=i.panel;if(c!==null&&!c.kn()&&(c=c.panel),c===null)r=s.x,l=s.y,h=e.x,a=e.y;else{f=c.Ks;const u=1/(f.m11*f.m22-f.m12*f.m21),d=f.m22*u,m=-f.m12*u,g=-f.m21*u,p=f.m11*u,y=u*(f.m21*f.dy-f.m22*f.dx),x=u*(f.m12*f.dx-f.m11*f.dy);r=s.x*d+s.y*g+y,l=s.x*m+s.y*p+x,h=e.x*d+e.y*g+y,a=e.x*m+e.y*p+x}return i.sc(r,l,h,a,o),f!==null&&o.O(f),o}nO(t,i){const e=t.nd;return e!==null?e.dT(i):null}Nb(t){let i=t.nd;return i===null&&(i=new Knot,i.sr=t,i.ye=t.part,t.nd=i),i.dT(this)}getLinkPoint(t,i,e,s,n,o,r,l){if(l===void 0&&(l=new Point),e.isSpot()&&!this.Gd(e))return i.getDocumentPoint(e,l),l;if(e.isSide()){const f=this.Nb(i);if(f!==null){const c=f.Hd;if(l.c(c),n&&this.routing===7){const u=this.Nb(r);if(u!==null&&f.Tc=g.y&&y.y<=g.y+g.height?l.y=y.y:(e.includesSide(Spot.TopSide)||e.includesSide(Spot.BottomSide))&&y.x>=g.x&&y.x<=g.x+g.width&&(l.x=y.x),Point.o(d),Point.o(m)}}return l}}const h=i.getDocumentPoint(this.Cb(e,s),Point.a());let a=null;if(this.pointsCount>(n?6:2))a=s?this.getPoint(1):this.getPoint(this.pointsCount-2),n&&(a=this.pN(h,a.copy()));else{const f=this.computeSpot(!s,r),c=Point.a();a=r.getDocumentPoint(this.Cb(f,!s),c),n&&(a=this.pN(h,a)),Point.o(c)}return this.getLinkPointFromPoint(t,i,h,a,s,l),Point.o(h),l}getLinkDirection(t,i,e,s,n,o,r,l){let h=this.oO(t,i,e,s,n,o,r,l);if(r&&s.isNoSpot()&&r.isMemberOf(t)&&(h+=180,h>=360&&(h-=360)),this.Gd(s))return h;const a=i.getDocumentAngle();return a===0||(45<=a&&a<135?h+=90:135<=a&&a<225?h+=180:225<=a&&a<315&&(h+=270),h>=360&&(h-=360)),h}oO(t,i,e,s,n,o,r,l){if(s.isSpot())return s.x>s.y?s.x>1-s.y?0:s.x<1-s.y?270:315:s.x1-s.y?90:s.x<1-s.y?180:135:s.x<.5?225:s.x>.5?45:0;if(s.isSide()){const c=this.Nb(i);if(c!==null)switch(c.be){case 1:return 270;case 2:return 180;default:case 4:return 0;case 8:return 90}}const h=i.getDocumentPoint(Spot.Center,Point.a());let a=null;if(this.pointsCount>(o?6:2))a=n?this.getPoint(1):this.getPoint(this.pointsCount-2),o?a=this.pN(h,a.copy()):a=e;else{const c=Point.a();a=l.getDocumentPoint(Spot.Center,c),Point.o(c)}let f=0;return Math.abs(a.x-h.x)>Math.abs(a.y-h.y)?a.x>=h.x?f=0:f=180:a.y>=h.y?f=90:f=270,Point.o(h),f}computeEndSegmentLength(t,i,e,s){if(i!==null&&e.isSide()){const o=this.Nb(i);if(o!==null)return o.Ab}let n=NaN;return s?n=this.fromEndSegmentLength:n=this.toEndSegmentLength,i!==null&&isNaN(n)&&(s?n=i.fromEndSegmentLength:n=i.toEndSegmentLength),isNaN(n)&&(n=10),n}computeSpot(t,i){return i===void 0&&(i=null),t?this.rO(i||this.fromPort):this.lO(i||this.toPort)}rO(t){if(t===null)return Spot.Center;let i=this.fromSpot;return i.isDefault()&&(i=t.fromSpot),i===Spot.Default?Spot.None:i}lO(t){if(t===null)return Spot.Center;let i=this.toSpot;return i.isDefault()&&(i=t.toSpot),i===Spot.Default?Spot.None:i}Gd(t){return t===Spot.None||t.x===.5&&t.y===.5}Cb(t,i){return t.x===.5&&t.y===.5?t:Spot.Center}computeOtherPoint(t,i){if(this.computeAdjusting()!==0&&this.pointsCount>4)return this.computeMidPoint(new Point);{const e=this.nO(i,this);return e!==null?e.Hd:i.getDocumentPoint(Spot.Center)}}computeShortLength(t){if(t){let i=this.fromShortLength;if(isNaN(i)){const e=this.fromPort;e!==null&&(i=e.fromShortLength)}return isNaN(i)?0:i}else{let i=this.toShortLength;if(isNaN(i)){const e=this.toPort;e!==null&&(i=e.toShortLength)}return isNaN(i)?0:i}}Km(t,i,e,s,n,o){if(this.pickable===!1)return!1;i===void 0&&(i=null),e===void 0&&(e=null);let r=o;if(o===void 0&&(r=Transform.a(),r.Bi()),r.hf(this.O),this.containedInRect(t,r))return this.Y2(i,e,n),o===void 0&&Transform.o(r),!0;if(this.intersectsRect(t,r)){let l=!1;if(!this.gc){const h=this.D.h,a=h.length;for(let f=a;f--;){const c=h[f];if(!c.visible&&c!==this.locationObject)continue;const u=c.actualBounds,d=this.naturalBounds;if(u.x>d.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;const m=c,g=Transform.a();if(g.set(r),m instanceof Panel?l=m.Km(t,i,e,s,n,g):this.path===m?m instanceof Shape&&(l=m.TI(t,s,g)):l=m.lL(t,s,g),l){let p=m;i!==null&&(p=i(m)),p&&(e===null||e(p))&&n.add(p)}Transform.o(g)}}return o===void 0&&Transform.o(r),l||this.background!==null}return o===void 0&&Transform.o(r),!1}get isOrthogonal(){return(this.Ea&2)===2}static dN(t){return(t&2)===2}get isAvoiding(){return(this.Ea&4)===4}computeCurve(){if(this.ir===null){const t=this.fromPort,i=t!==null&&t===this.toPort,e=this.isOrthogonal;this.ir=i&&!e}return this.ir?9:this.curve}computeCorner(){if(this.curve===9)return 0;let t=this.corner;return(isNaN(t)||t<0)&&(t=10),t}findMidLabel(){const t=this.path,i=this.D.h,e=i.length;for(let n=0;n0?g-=c:g+=c;else{const p=-h/a;let y=Math.sqrt(c*c/(p*p+1));f<0&&(y=-y),m=(a<0?-1:1)*y+u,g=p*(m-u)+d}this.addPoint(r),this.addPointAt(m,g),this.addPoint(l)}else{this.addPoint(r),this.addPoint(l);const h=Rect.a();i.getDocumentBounds(h);const a=h.containsPoint(l);n.getDocumentBounds(h);const f=h.containsPoint(r);if(a||f){const c=i.getDocumentPoint(this.Cb(e,!0),new Point);this.setPoint(0,this.getLinkPointFromPoint(t,i,c,l,!0,c));const u=n.getDocumentPoint(this.Cb(o,!1),new Point);this.setPoint(1,this.getLinkPointFromPoint(s,n,u,r,!1,u))}Rect.o(h)}}eO(t,i,e,s,n,o){const r=this.getLinkPoint(t,i,e,!0,!1,s,n),l=this.getLinkPoint(s,n,o,!1,!1,t,i),h=l.x-r.x,a=l.y-r.y,f=this.computeCurviness();let c=0,u=0,d=r.x+h/3,m=r.y+a/3,g=d,p=m;Geo.p(a,0)?h>0?p-=f:p+=f:(c=-h/a,u=Math.sqrt(f*f/(c*c+1)),f<0&&(u=-u),g=(a<0?-1:1)*u+d,p=c*(g-d)+m),d=r.x+2*h/3,m=r.y+2*a/3;let y=d,x=m;Geo.p(a,0)?h>0?x-=f:x+=f:(y=(a<0?-1:1)*u+d,x=c*(y-d)+m),this.clearPoints(),this.addPoint(r),this.addPointAt(g,p),this.addPointAt(y,x),this.addPoint(l),this.setPoint(0,this.getLinkPoint(t,i,e,!0,!1,s,n)),this.setPoint(3,this.getLinkPoint(s,n,o,!1,!1,t,i))}adjustPoints(t,i,e,s){let n=this.computeAdjusting();if(this.isOrthogonal){if(n===18)return!1;n===19&&(n=17)}switch(n){case 18:return this.hO(t,i,e,s);case 19:return this.aO(t,i,e,s);case 17:return this.fO(t,i,e,s);default:return!1}}hO(t,i,e,s){const n=this.getPoint(t),o=this.getPoint(e);if(n.equalsApprox(i)&&o.equalsApprox(s))return!0;const r=n.x,l=n.y,h=o.x,a=o.y;let f=h-r,c=a-l;const u=Math.sqrt(f*f+c*c);if(Geo.q(u,0))return!0;let d=0;Geo.q(f,0)?c<0?d=-Math.PI/2:d=Math.PI/2:(d=Math.atan(c/Math.abs(f)),f<0&&(d=Math.PI-d));const m=i.x,g=i.y,p=s.x,y=s.y,x=p-m,k=y-g,b=Math.sqrt(x*x+k*k);let S=0;Geo.q(x,0)?k<0?S=-Math.PI/2:S=Math.PI/2:(S=Math.atan(k/Math.abs(x)),x<0&&(S=Math.PI-S));const M=b/u,A=S-d;this.setPoint(t,i);for(let C=t+1;C0&&(C=-C);const P=c+S*(d-c),N=u+S*(m-u);if(g!==0){const T=P+C/p,L=N-(T-P)/g;this.setPointAt(y,T,L)}else this.setPointAt(y,P,N+C)}return this.setPoint(e,s),!0}fO(t,i,e,s){if(this.isOrthogonal){let n=this.getPoint(t),o=this.getPoint(t+1),r=this.getPoint(t+2),l=o.x,h=o.y;const a=l,f=h;Geo.p(n.y,o.y)?Geo.p(o.x,r.x)?h=i.y:Geo.p(o.y,r.y)&&(l=i.x):Geo.p(n.x,o.x)&&(Geo.p(o.y,r.y)?l=i.x:Geo.p(o.x,r.x)&&(h=i.y)),this.setPointAt(t+1,l,h),n=this.getPoint(e),o=this.getPoint(e-1),r=this.getPoint(e-2);let c=o.x,u=o.y;const d=c,m=u;if(Geo.p(n.y,o.y)?Geo.p(o.x,r.x)?u=s.y:Geo.p(o.y,r.y)&&(c=s.x):Geo.p(n.x,o.x)&&(Geo.p(o.y,r.y)?c=s.x:Geo.p(o.x,r.x)&&(u=s.y)),this.setPointAt(e-1,c,u),this.VA())return this.setPointAt(t+1,a,f),this.setPointAt(e-1,d,m),!1}return this.setPoint(t,i),this.setPoint(e,s),!0}addOrthoPoints(t,i,e,s,n,o){i<0?i+=360:i>=360&&(i-=360),s<0?s+=360:s>=360&&(s-=360);const f=s;i>=315||i<45?i=0:45<=i&&i<135?i=90:135<=i&&i<225?i=180:i=270,s>=315||s<45?s=0:45<=s&&s<135?s=90:135<=s&&s<225?s=180:s=270;const c=t,u=e,d=n.actualBounds.copy(),m=o.actualBounds.copy();if(!d.isReal()||!m.isReal())return;d.inflate(Link.za,Link.za),m.inflate(Link.za,Link.za),d.unionPoint(t),m.unionPoint(e);const g=Point.a(),p=Point.a();i===0?u.x>c.x||s===270&&u.yc.x||s===90&&u.y>c.y&&m.right>c.x?(g.e(u.x,c.y),p.e(u.x,(c.y+u.y)/2),s===180?(g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1),p.x=g.x,p.y=u.y):s===270&&u.yc.y?(c.xm.bottom)?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):g.x=m.right,p.x=g.x,p.y=u.y):s===0&&c.xm.top&&c.yd.bottom)&&(s===180&&(m.containsPoint(c)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):u.yc.y&&(s===180||s===270)&&(g.y=this.computeMidOrthoPosition(c.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=d.left&&u.x<=c.x||c.x<=m.right&&c.x>=u.x?(s===90||s===270)&&(g.e(Math.max((c.x+u.x)/2,c.x),c.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yc.y&&m.leftc.y?(c.x>m.right?g.x=this.computeMidOrthoPosition(c.x,c.y,m.right,u.y,!1):c.x>m.left&&(s===270&&c.ym.bottom)?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):g.x=m.left,p.x=g.x,p.y=u.y):s===180&&c.x>m.right&&c.y>m.top&&c.yd.bottom)&&(s===0&&(m.containsPoint(c)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):u.yc.y&&(s===0||s===270)&&(g.y=this.computeMidOrthoPosition(c.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=c.x||c.x>=m.left&&c.x<=u.x?(s===90||s===270)&&(g.e(Math.min((c.x+u.x)/2,c.x),c.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yc.y||s===180&&u.xc.y||s===0&&u.x>c.x&&m.bottom>c.y?(g.e(c.x,u.y),p.e((c.x+u.x)/2,u.y),s===270?(g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0),p.x=u.x,p.y=g.y):s===180&&u.xc.x?(c.ym.right)?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):g.y=m.bottom,p.x=u.x,p.y=g.y):s===90&&c.ym.left&&c.xd.right)&&(s===270&&(m.containsPoint(c)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):u.xc.x&&(s===270||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,c.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=d.top&&u.y<=c.y||c.y<=m.bottom&&c.y>=u.y?(s===0||s===180)&&(g.e(c.x,Math.max((c.y+u.y)/2,c.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.xc.x&&m.top=c.x?(c.y>m.bottom?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,m.bottom,!0):c.y>m.top&&(s===180&&c.xm.right)?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):g.y=m.top,p.x=u.x,p.y=g.y):s===270&&c.y>m.bottom&&c.x>m.left&&c.xd.right)&&(s===90&&(m.containsPoint(c)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):u.xc.x&&(s===90||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,c.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=c.y||c.y>=m.top&&c.y<=u.y?(s===0||s===180)&&(g.e(c.x,Math.min((c.y+u.y)/2,c.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.x=3&&!Geo.q(this.smoothness,0))if(i===3){let f=this.getPoint(1);n=Math.min(r.x,f.x),o=Math.min(r.y,f.y),f=this.getPoint(2),n=Math.min(n,f.x),o=Math.min(o,f.y)}else if(this.isOrthogonal){for(let f=0;f=i&&(f=i-1);const c=this.getPoint(f);l.x=Math.min(c.x,l.x),l.y=Math.min(c.y,l.y)}n=l.x,o=l.y}else{for(let f=0;f=3&&!Geo.q(this.smoothness,0))if(i===3){const c=this.getPoint(1),u=c.x-n,d=c.y-o;let m=this.getPoint(2).copy();m.x-=n,m.y-=o,this.computeShortLength(!1)!==0&&(m=this.Dc(m,!1,l)),f.wr(u,d,u,d,m.x,m.y)}else if(this.isOrthogonal){const c=Point.H(n,o),u=Point.a();u.c(this.getPoint(1));const d=Point.H(n,o),m=Point.H(n,o);let g=this.getPoint(0),p=null;const y=this.smoothness/3;for(let S=1;S=i&&(c=i-1);const d=this.getPoint(c-1);let m=this.getPoint(c);c===i-1&&this.computeShortLength(!1)!==0&&(m=this.Dc(m.copy(),!1,Point.Lo)),f.wr(u.x-n,u.y-o,d.x-n,d.y-o,m.x-n,m.y-o)}else{const c=Point.a();c.c(this.getPoint(0));const u=Point.a();u.c(c);const d=this.computeCorner();let m=1,g=0;for(;m1);let p=this.getPoint(m);if(m>=i-1){if(!c.equals(p))this.computeShortLength(!1)!==0&&(p=this.Dc(p.copy(),!1,Point.Lo)),this.Dn(f,-n,-o,c,p,e);else if(g===0)for(m=1;mr?c>a?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):c>a?(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.q(r,h)&&Geo.q(a,c)&&(a>l?f>h?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):f>h?(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.q(r,h)&&Geo.q(h,f)||Geo.q(l,a)&&Geo.q(a,c)){const m=.5*(r+f),g=.5*(l+c);n.x=m,n.y=g,o.x=m,o.y=g}}Dc(t,i,e){const s=this.pointsCount;if(s<2)return t;if(i){const n=this.getPoint(1),o=n.x-e.x,r=n.y-e.y,l=this.Lb(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!0);a>h&&(a=h);const f=a*(o-t.x)/l,c=a*(r-t.y)/l;t.x+=f,t.y+=c}else{const n=this.getPoint(s-2),o=n.x-e.x,r=n.y-e.y,l=this.Lb(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!1);a>h&&(a=h);const f=a*(t.x-o)/l,c=a*(t.y-r)/l;t.x-=f,t.y-=c}return t}yN(t,i,e){const s=this.pointsCount;let n=t;for(;Geo.q(t.x,n.x)&&Geo.q(t.y,n.y);){if(i>=s)return s-1;n=this.getPoint(i++)}if(!Geo.q(t.x,n.x)&&!Geo.q(t.y,n.y))return i-1;let o=n;for(;Geo.q(t.x,n.x)&&Geo.q(n.x,o.x)&&(!e||(t.y>=n.y?n.y>=o.y:n.y<=o.y))||Geo.q(t.y,n.y)&&Geo.q(n.y,o.y)&&(!e||(t.x>=n.x?n.x>=o.x:n.x<=o.x));){if(i>=s)return s-1;o=this.getPoint(i++)}return i-2}dO(t,i,e,s,n,o,r,l,h,a){if(Geo.p(s.y,n.y)&&Geo.p(n.x,o.x)){let f=Math.min(h,Math.abs(n.x-l.x)/2);const c=Math.min(f,Math.abs(o.y-n.y)/2);if(f=c,Geo.p(f,0)){this.Dn(t,i,e,s,n,a),r.c(n);return}let u=n.x;const d=n.y,m=u;let g=d;n.x>s.x?(u=n.x-f,o.y>n.y?g=n.y+c:g=n.y-c):(u=n.x+f,o.y>n.y?g=n.y+c:g=n.y-c);const p=Point.H(u,d);this.Dn(t,i,e,s,p,a),Point.o(p),t.Fw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else if(Geo.p(s.x,n.x)&&Geo.p(n.y,o.y)){let f=Math.min(h,Math.abs(n.y-l.y)/2);const c=Math.min(f,Math.abs(o.x-n.x)/2);if(f=c,Geo.p(c,0)){this.Dn(t,i,e,s,n,a),r.c(n);return}const u=n.x;let d=n.y,m=u;const g=d;n.y>s.y?(d=n.y-f,o.x>n.x?m=n.x+c:m=n.x-c):(d=n.y+f,o.x>n.x?m=n.x+c:m=n.x-c);const p=Point.H(u,d);this.Dn(t,i,e,s,p,a),Point.o(p),t.Fw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else this.Dn(t,i,e,s,n,a),r.c(n)}computeJumpLength(){return 10}Dn(t,i,e,s,n,o){if(o||!this.Xa())t.yr(n.x+i,n.y+e);else{const r=this.computeJumpLength(),l=r/2,h=[];let a=0;this.isVisible()&&(a=this.gO(s,n,h));let f=s.x,c=s.y;if(a>0){if(Geo.p(s.y,n.y))if(s.x=0;){const d=Math.min(s.x,Math.max(h[u--]+l,n.x+r));t.yr(d+i,n.y+e),f=d+i,c=n.y+e;let m=Math.max(d-r,n.x);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.x);else break}const g=n.y-r+e,p=m+i,y=n.y+e;this.curve===10?t.wu(p,y,!1,!1):t.wr(f,g,p,g,p,y),f=p,c=y}}else if(Geo.p(s.x,n.x))if(s.y=0;){const d=Math.min(s.y,Math.max(h[u--]+l,n.y+r));t.yr(n.x+i,d+e),f=n.x+i,c=d+e;let m=Math.max(d-r,n.y);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.y);else break}const g=n.x-r+i,p=n.x+i,y=m+e;this.curve===10?t.wu(p,y,!1,!1):t.wr(g,c,g,y,p,y),f=p,c=y}}}t.yr(n.x+i,n.y+e)}}gO(t,i,e){const s=this.diagram;if(s===null||t.equals(i))return 0;const n=s.layers;for(;n.next();){const o=n.value;if(o!==null&&o.visible){const r=o.HM(),l=r.length;for(let h=0;h0&&e.sort((u,d)=>u-d),e.length;if(!a.isVisible()||!a.Xa())continue;const f=a.routeBounds;if(!f.isReal()||!this.routeBounds.intersectsRect(f)||this.usesSamePort(a))continue;const c=a.path;c!==null&&c.isVisibleObject()&&this.mO(t,i,e,a)}}}return e.length>0&&e.sort((o,r)=>o-r),e.length}mO(t,i,e,s){const n=Geo.p(t.y,i.y),o=s.pointsCount;let r=s.getPoint(0);const l=Point.a();for(let h=1;hr.x&&f.x>=a.x||a.xr.y&&f.y>=a.y||a.yf&&Math.min(a,c)o&&!Geo.p(a,c))return n.x=o,n.y=f,!0}else if(Geo.p(r,h)&&Geo.p(a,c)&&Math.min(o,l)a&&Math.min(f,u)r&&!Geo.p(f,u))return n.x=a,n.y=r,!0;return n.x=0,n.y=0,!1}get firstPickIndex(){return this.pointsCount<=2?0:this.isOrthogonal||!this.Gd(this.computeSpot(!0))?1:0}get lastPickIndex(){const t=this.pointsCount;return t===0?0:t<=2?t-1:this.isOrthogonal||!this.Gd(this.computeSpot(!1))?t-2:t-1}Xa(){const t=this.curve;return t===11||t===10}Pb(t){if(t||this.Xa()){const i=this.diagram;i!==null&&!i.animationManager.isTicking&&!i.th.has(this)&&(this.Lc.width!==0||this.Lc.height!==0)&&i.th.set(this,this.Lc.copy())}}invalidateOtherJumpOvers(t){const i=this.layer;if(i===null||!i.visible||i.isTemporary)return;const e=i.diagram;if(e===null||e.animationManager.isTicking)return;let s=!1;const n=e.layers;for(;n.next();){const o=n.value;if(o.visible){if(o===i){s=!0;let r=!1;const l=o.HM(),h=l.length;for(let a=0;a0&&e>0){const s=this.getPoint(0),n=t.getPoint(0);if(s.equalsApprox(n))return!0;const o=this.getPoint(i-1),r=t.getPoint(e-1);if(o.equalsApprox(r)||s.equalsApprox(r)||o.equalsApprox(n))return!0}else if(this.fromNode===t.fromNode||this.toNode===t.toNode||this.fromNode===t.toNode||this.toNode===t.fromNode)return!0;return!1}isVisible(){if(!super.isVisible())return!1;const t=this.containingGroup;let i=!0;const e=this.diagram;e!==null&&(i=e.isTreePathToChildren);const s=this.fromNode;if(s!==null){if(this.isTreeLink&&i&&!s.isTreeExpanded)return!1;if(s===t)return!0;let o=s;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=s.findVisibleNode();if(r===null||r===t)return!1}const n=this.toNode;if(n!==null){if(this.isTreeLink&&!i&&!n.isTreeExpanded)return!1;if(n===t)return!0;let o=n;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=n.findVisibleNode();if(r===null||r===t)return!1}return!0}Ki(t){if(super.Ki(t),t&&this.Pb(!1),this.er!==null&&this.er.Vd(),this.$s!==null){const e=this.$s.iterator;for(;e.next();)e.value.Ki(t)}}get adjusting(){return this.Ac}set adjusting(t){const i=this.Ac;i!==t&&(Debug&&t!==0&&t!==17&&t!==18&&t!==19&&Util.n("Link.adjusting can only be set to None, End, Scale, or Stretch, not: "+t),this.Ac=t,this.i("adjusting",i,t))}computeAdjusting(){return this.isAvoiding&&this.diagram!==null&&this.diagram.animationManager.defaultAnimation.isAnimating?17:this.Ac}get corner(){return this.Xd}set corner(t){const i=this.Xd;i!==t&&(Debug&&Util.t(t,"number",Link,"corner"),this.Xd=t,this.re(),this.i("corner",i,t))}get curve(){return this.Yd}set curve(t){const i=this.Yd;i!==t&&(Debug&&t!==0&&t!==9&&t!==10&&t!==11&&Util.n("Link.curve can only be set to None, Bezier, JumpGap, or JumpOver, not: "+t),this.Yd=t,this.invalidateRoute(),this.re(),this.Pb(i===10||i===11||t===10||t===11),this.i("curve",i,t))}get curviness(){return this.Kd}set curviness(t){const i=this.Kd;i!==t&&(Debug&&Util.t(t,"number",Link,"curviness"),this.Kd=t,this.invalidateRoute(),this.re(),this.i("curviness",i,t))}get routing(){return this.Ea}set routing(t){const i=this.Ea;i!==t&&(Debug&&t!==1&&t!==2&&t!==6&&t!==7&&Util.n("Link.routing can only be set to Normal, Orthogonal, AvoidsNodes, not: "+t),this.Ea=t,this.isAvoiding&&this.diagram!==null&&(this.diagram.$m=!0),this.ir=null,this.invalidateRoute(),this.Pb(Link.dN(i)||Link.dN(t)),this.i("routing",i,t))}get smoothness(){return this.Ud}set smoothness(t){const i=this.Ud;i!==t&&(Debug&&Util.t(t,"number",Link,"smoothness"),this.Ud=t,this.re(),this.i("smoothness",i,t))}Py(){const t=this.go;if(t===null)return;const i=this.po;if(i===null||!isNaN(this.curviness))return;const e=this.mo,s=this.yo;let n=null,o=null;const r=t.ni.h,l=r.length;for(let h=0;h=0&&(Util.rf(t.Qs,i),t.Vd())}}Dl(){return!0}get key(){const t=this.diagram;if(!(t===null||!t.model.Oa()))return t.model.getKeyForLinkData(this.data)}}class LinkBundle{Ko;Xs;uy;oN;wb;rN;Qs;constructor(t,i,e,s){GSet.vi(this),this.Ko=!1,this.Xs=!1,this.uy=t,this.oN=i,this.wb=e,this.rN=s,this.Qs=[]}Vd(){if(!this.Ko){const t=this.Qs;if(t.length>0){const i=t[0].diagram;i!==null&&(i.mP.add(this),this.Xs=i.undoManager.isUndoingRedoing)}}this.Ko=!0}LP(){if(this.Ko){this.Ko=!1;const t=this.Qs;if(t.length>0){const i=t[0],e=i.diagram,s=e===null||e.Yh&&!this.Xs;this.Xs=!1,i.arrangeBundledLinks(t,s),t.length===1&&(i.er=null,t.length=0)}t.length===0&&(this.uy.nT(this),this.wb.nT(this))}}}class PositionArray{ae;fe;Ya;Ka;bi;ki;Yt;Sh;Mh;ca;YP;Ko;Cy;$f;KP;UP;constructor(t){GSet.vi(this),this.ca=null,this.YP=null,this.Ko=!0,this.Cy=!1,this.ae=1,this.fe=1,this.Ya=-1,this.Ka=-1,this.bi=t.width,this.ki=t.height,this.Yt=null,this.Sh=0,this.Mh=0,this.$f=11,this.KP=this.$f*2,this.UP=this.$f*2}static _s=0;static Ua=1;static qd=999999;static wN=PositionArray.qd+1;static xN=PositionArray.qd+2;I1(t){if(t.width<=0||t.height<=0)return;const i=t.x,e=t.y,s=t.x+t.width,n=t.y+t.height;this.ae=Math.floor((i-this.bi)/this.bi)*this.bi,this.fe=Math.floor((e-this.ki)/this.ki)*this.ki,this.Ya=Math.ceil((s+2*this.bi)/this.bi)*this.bi,this.Ka=Math.ceil((n+2*this.ki)/this.ki)*this.ki;const o=1+(Math.ceil((this.Ya-this.ae)/this.bi)|0),r=1+(Math.ceil((this.Ka-this.fe)/this.ki)|0);if(this.Yt===null||this.Sh0&&t!==this.bi&&(this.bi=t,this.I1(this.bounds))}get cellHeight(){return this.ki}set cellHeight(t){t>0&&t!==this.ki&&(this.ki=t,this.I1(this.bounds))}jd(t,i){return this.ae<=t&&t<=this.Ya&&this.fe<=i&&i<=this.Ka}wo(t,i){if(!this.jd(t,i))return PositionArray.wN;t-=this.ae,t/=this.bi,i-=this.fe,i/=this.ki;const e=t|0,s=i|0;return this.Yt[e][s]}CR(t,i,e,s){if(!this.jd(t,i))return;const n=(t-this.ae)/this.bi|0,o=(i-this.fe)/this.ki|0,r=(t+e-this.ae)/this.bi|0,l=(i+s-this.fe)/this.ki|0,h=Math.min(r,this.Sh),a=Math.min(l,this.Mh);for(let f=n;f<=h;f++){const c=this.Yt[f];if(c.fill)c.fill(PositionArray._s,o,a+1);else for(let u=o;u<=a;u++)c[u]=PositionArray._s}}yO(t){if(this.Yt!==null)for(let i=0;i<=this.Sh;i++){const e=this.Yt[i];if(e.fill)e.fill(t);else for(let s=0;s<=this.Mh;s++)e[s]=t}}vA(){if(this.Yt!==null)for(let t=0;t<=this.Sh;t++){const i=this.Yt[t];for(let e=0;e<=this.Mh;e++)i[e]>=PositionArray.Ua&&(i[e]=PositionArray.wN)}}wO(t,i){return this.wo(t,i)===PositionArray._s}isUnoccupied(t,i,e,s){if(t>this.Ya||t+ethis.Ka||i+sthis.Ya||ithis.Ka||ethis.Ka||ithis.Ya||e=PositionArray.Ua&&h=a)break;this.Yt[t][i]=h,h+=1,s?i+=e:t+=e}return s?i:t}xo(t,i,e,s,n,o,r,l){if(to||il)return;const h=this.xO(t,i,e,s,n,o,r,l);if(s)if(e>0)for(let a=i+e;ah;a+=e)this.xo(t,a,1,!s,n,o,r,l),this.xo(t,a,-1,!s,n,o,r,l);else if(e>0)for(let a=t+e;ah;a+=e)this.xo(a,i,1,!s,n,o,r,l),this.xo(a,i,-1,!s,n,o,r,l)}Tb(t,i,e,s,n,o,r,l,h,a){let f=t|0,c=i|0,u=PositionArray._s,d=PositionArray.Ua;for(this.Yt[f][c]=d;u===PositionArray._s&&f>r&&fh&&cr&&fh&&c=0;I-=2){F=L[I+2],R=L[I+3];const O=L[I],B=L[I+1];for(;O>F?F++:OR?R++:Bs)d--;else break;else if(m>n)m--;else break;const g=f[d][m];if(g===0||g===PositionArray.xN)break;c=d,u=m}for(;;){let d=e,m=c,g=u;e===0?gn&&(d=270,g--):e===90?ms&&(d=180,m--):e===180?gn&&(d=270,g--):ms&&(d=180,m--);const p=f[m][g];if(d!==e&&p!==0&&p!==PositionArray.xN){if(o.push(c),o.push(u),this.pT(c,u,d,s,n,o))return!0;o.pop(),o.pop()}if(f[c][u]=PositionArray.xN,e===0){if(c===t)return!1;c--}else if(e===90){if(u===i)return!1;u--}else if(e===180){if(c===t)return!1;c++}else{if(u===i)return!1;u++}}}}class Knot{ye;sr;cs;Wd;constructor(){GSet.vi(this),this.ye=null,this.sr=null,this.cs=[],this.Wd=!1}toString(){const t=this.cs;let i=this.ye.toString()+" "+t.length.toString()+":";for(let e=0;e180?270:90;case 6:return o>90&&o<=270?180:0}const r=Math.atan2(t.height,t.width)*180/Math.PI;switch(n){case 3:return o>r&&o<=180+r?180:270;case 5:return o>180-r&&o<=360-r?270:0;case 12:return o>r&&o<=180+r?90:0;case 10:return o>180-r&&o<=360-r?180:90;case 7:return o>90&&o<=180+r?180:o>180+r&&o<=360-r?270:0;case 13:return o>180&&o<=360-r?270:o>r&&o<=180?90:0;case 14:return o>r&&o<=180-r?90:o>180-r&&o<=270?180:0;case 11:return o>180-r&&o<=180+r?180:o>180+r?270:90}return s&&n!==15&&(o-=15,o<0&&(o+=360)),o>r&&o<180-r?90:o>=180-r&&o<=180+r?180:o>180+r&&o<360-r?270:0}Vd(){this.cs.length=0}dT(t){let i=this.cs;i.length===0&&(this.kO(),i=this.cs);for(let e=0;e=360&&(M-=360);const A=this.bO(h,y,M,g.isOrthogonal);let C=0;A===0?(C=4,M>180&&(M-=360)):A===90?(C=8,M>270&&(M-=360)):A===180?C=2:(C=1,M<90&&(M+=360));let P=this.cs[o];P===void 0?(P=new LinkInfo(g,M,C),this.cs[o]=P):(P.$e=g,P.jt=M,P.be=C),P.Fb.set(S),o++}Point.o(a),this.SO();const u=this.cs.length;let d=-1,m=0;for(o=0;o=0;o--){const g=this.cs[o];g!==void 0&&(g.be!==d&&(d=g.be,m=g.vd+1),g.Tc=m)}this.MO(this.cs),this.PO(this.cs),this.Wd=t,Rect.o(h)}return this.cs}NO(t,i){return t===i?0:t===null?-1:i===null?1:t.bei.be?1:t.jti.jt?1:0}SO(){this.cs.sort(Knot.prototype.NO)}MO(t){const i=this.sr,e=this.ye.portSpreading,s=Point.a(),n=Point.a(),o=Point.a(),r=Point.a();i.getDocumentPoint(Spot.TopLeft,s),i.getDocumentPoint(Spot.TopRight,n),i.getDocumentPoint(Spot.BottomRight,o),i.getDocumentPoint(Spot.BottomLeft,r);let l=0,h=0,a=0,f=0;if(e===2)for(let x=0;xMath.abs(p)?(d=Math.abs(p)/a,a=Math.abs(p)):d=1;break;case 2:f>Math.abs(y)?(d=Math.abs(y)/f,f=Math.abs(y)):d=1;break;case 1:l>Math.abs(p)?(d=Math.abs(p)/l,l=Math.abs(p)):d=1;break;default:case 4:h>Math.abs(y)?(d=Math.abs(y)/h,h=Math.abs(y)):d=1;break}u=0}const b=k.Hd;if(e===2){let S=k.$e.computeThickness();switch(S*=d,b.set(m),c){case 8:b.x=m.x+p/2+a/2-u-S/2;break;case 2:b.y=m.y+y/2+f/2-u-S/2;break;case 1:b.x=m.x+p/2-l/2+u+S/2;break;default:case 4:b.y=m.y+y/2-h/2+u+S/2;break}u+=S}else{let S=.5;e===1&&(S=(k.vd+1)/(k.Tc+1)),b.x=m.x+p*S,b.y=m.y+y*S}}Point.o(s),Point.o(n),Point.o(o),Point.o(r)}PO(t){for(let i=0;ie instanceof Placeholder);i instanceof Placeholder?t.Et=i:t.Et=null,this.oe!==null?(t.oe=this.oe.copy(),t.oe.group=t):(t.oe!==null&&(t.oe.group=null),t.oe=null),this.hi!==null&&(t.hi=this.hi.copy())}Ho(t){super.Ho(t);const i=t.findSubGraphParts(),e=t.memberParts;for(;e.next();){const s=e.value;if(s.u(),s.invalidateLayout(8),s.clearAdornments(),s instanceof Node)s.invalidateConnectedLinks(i);else if(s instanceof Link){const n=s.labelNodes;for(;n.next();)n.value.invalidateConnectedLinks(i)}}}ic(t,i,e,s,n,o,r){if(t===3&&i==="elements"){if(n instanceof Placeholder)this.Et===null?this.Et=n:this.Et!==n&&Util.n("Cannot insert a second Placeholder into the visual tree of a Group.");else if(n instanceof Panel){const l=n.findInVisualTree(h=>h instanceof Placeholder);l instanceof Placeholder&&(this.Et===null?this.Et=l:this.Et!==l&&Util.n("Cannot insert a second Placeholder into the visual tree of a Group."))}}else t===4&&i==="elements"&&this.Et!==null&&(s===this.Et?this.Et=null:s instanceof Panel&&this.Et.isContainedBy(s)&&(this.Et=null));super.ic(t,i,e,s,n,o,r)}ad(t,i){if(super.ad(t,i),this.isClipping&&this.type!==Panel.Spot&&this.isSubGraphExpanded){let e=this.resizeObject;e instanceof Panel&&(e=e.findMainElement()),this.hi===null&&(this.hi=new Rect),e.getDocumentBounds(this.hi),e instanceof Shape&&this.hi.inflate(-e.strokeWidth,-e.strokeWidth)}}uh(t,i,e,s){this.hasPlaceholder()&&(this.tr=this.placeholder),super.uh(t,i,e,s)}ensureBounds(){this.isSubGraphExpanded&&this.memberParts.each(i=>{i.ensureBounds()}),super.ensureBounds()}$r(){if(!super.$r())return!1;const t=this.memberParts;for(;t.next();){const i=t.value;if(i instanceof Node){if(!i.isVisible())continue;if(i.rs())return!1}else if(i instanceof Link){if(!i.isVisible())continue;if(i.rs()&&i.fromNode!==this&&i.toNode!==this)return!1}}return!0}hasPlaceholder(){return this.Et!==null&&this.Et.isVisibleObject()&&this.isSubGraphExpanded}get placeholder(){return this.Et}get computesBoundsAfterDrag(){return(this.z&2048)!==0}set computesBoundsAfterDrag(t){const i=(this.z&2048)!==0;i!==t&&(Util.t(t,"boolean",Group,"computesBoundsAfterDrag"),this.z=this.z^2048,this.i("computesBoundsAfterDrag",i,t))}get computesBoundsIncludingLinks(){return(this.z&4096)!==0}set computesBoundsIncludingLinks(t){Util.t(t,"boolean",Group,"computesBoundsIncludingLinks");const i=(this.z&4096)!==0;i!==t&&(this.z=this.z^4096,this.i("computesBoundsIncludingLinks",i,t))}get computesBoundsIncludingLocation(){return(this.z&8192)!==0}set computesBoundsIncludingLocation(t){Util.t(t,"boolean",Group,"computesBoundsIncludingLocation");const i=(this.z&8192)!==0;i!==t&&(this.z=this.z^8192,this.i("computesBoundsIncludingLocation",i,t))}get handlesDragDropForMembers(){return(this.z&16384)!==0}set handlesDragDropForMembers(t){Util.t(t,"boolean",Group,"handlesDragDropForMembers");const i=(this.z&16384)!==0;i!==t&&(this.z=this.z^16384,this.i("handlesDragDropForMembers",i,t))}get avoidableMembers(){return(this.z&131072)!==0}set avoidableMembers(t){Util.t(t,"boolean",Group,"avoidableMembers");const i=(this.z&131072)!==0;i!==t&&(this.z=this.z^131072,this.i("avoidableMembers",i,t))}get memberParts(){return this.Jd.iterator}iN(t){if(this.Jd.add(t)){t instanceof Group&&this.fa.add(t);const e=this.memberAdded;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.j,n.j=!0),e(this,t),n!==null&&(n.j=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ki(!1)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.Et;i===null&&(i=this),i.u()}tN(t){if(this.Jd.delete(t)){t instanceof Group&&this.fa.delete(t);const e=this.memberRemoved;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.j,n.j=!0),e(this,t),n!==null&&(n.j=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ki(!0)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.Et;i===null&&(i=this),i.u()}Jf(){if(this.Jd.count>0){const t=this.diagram;if(t!==null){const e=this.Jd.copy().iterator;for(;e.next();){const s=e.value;t.remove(s)}}}super.Jf()}get layout(){return this.oe}set layout(t){const i=this.oe;if(i!==t){t!==null&&(Util.s(t,Layout,Group,"layout"),t.diagram!==null&&t.diagram.layout===t&&Util.n("A layout cannot be both the Diagram.layout and a Group.layout: "+t)),i!==null&&(i.diagram=null,i.group=null),this.oe=t;const e=this.diagram;t!==null&&(t.diagram=e,t.group=this),e!==null&&(e.Wr=!0),this.i("layout",i,t),e!==null&&e.requestUpdate()}}get memberAdded(){return this.bt!==null?this.bt.xy:null}set memberAdded(t){const i=this.memberAdded;i!==t&&(t!==null&&Util.t(t,"function",Group,"memberAdded"),this.ml(),this.bt.xy=t,this.i("memberAdded",i,t))}get memberRemoved(){return this.bt!==null?this.bt.by:null}set memberRemoved(t){const i=this.memberRemoved;i!==t&&(t!==null&&Util.t(t,"function",Group,"memberRemoved"),this.ml(),this.bt.by=t,this.i("memberRemoved",i,t))}get memberValidation(){return this.bt!==null?this.bt.rh:null}set memberValidation(t){const i=this.memberValidation;i!==t&&(t!==null&&Util.t(t,"function",Group,"memberValidation"),this.ml(),this.bt.rh=t,this.i("memberValidation",i,t))}canAddMembers(t){const i=this.diagram;if(i===null)return!1;const e=i.commandHandler,n=e.c2(t).iterator;for(;n.next();){const o=n.value;if(!e.isValidMember(this,o))return!1}return!0}addMembers(t,i){const e=this.diagram;if(e===null)return!1;const s=e.commandHandler,n=s.c2(t);let o=!0;const r=n.iterator;for(;r.next();){const l=r.value;!i||s.isValidMember(this,l)?l.containingGroup=this:o=!1}return o}get ungroupable(){return(this.z&256)!==0}set ungroupable(t){const i=(this.z&256)!==0;i!==t&&(Util.t(t,"boolean",Group,"ungroupable"),this.z=this.z^256,this.i("ungroupable",i,t))}canUngroup(){if(!this.ungroupable)return!1;const t=this.layer;if(t===null||!t.allowUngroup)return!1;const i=t.diagram;return!(i!==null&&!i.allowUngroup)}invalidateConnectedLinks(t){const i=this.AO();if(super.invalidateConnectedLinks(t),i)return;this.TA(!0);const e=this.findExternalLinksConnected();for(;e.next();){const s=e.value;if(t!==void 0&&t.has(s))continue;const n=s.fromNode;if(n!==null&&n!==this&&n.isMemberOf(this)&&!n.isVisible())n.xe(s.fromPort),n.xe(s.toPort),s.invalidateRoute();else{const o=s.toNode;o!==null&&o!==this&&o.isMemberOf(this)&&!o.isVisible()&&(o.xe(s.fromPort),o.xe(s.toPort),s.invalidateRoute())}}}findExternalLinksConnected(){const t=this.diagram!==null&&this.diagram.kP;if(t&&this.b0!==null)return this.b0.iterator;const i=this.findSubGraphParts();i.add(this);const e=new GSet,s=i.iterator;for(;s.next();){const n=s.value;if(!(n instanceof Node))continue;const o=n.linksConnected;for(;o.next();){const r=o.value;i.has(r)||e.add(r)}}return t&&(this.b0=e),e.iterator}findExternalNodesConnected(){const t=this.findSubGraphParts();t.add(this);const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;if(!(s instanceof Node))continue;const n=s.linksConnected;for(;n.next();){const o=n.value,r=o.fromNode;r!==null&&(!t.has(r)||r===this)&&i.add(r);const l=o.toNode;l!==null&&(!t.has(l)||l===this)&&i.add(l)}}return i.iterator}yE(){function t(e,s){e!==null&&(s.add(e),t(e.containingGroup,s))}const i=new GSet;return t(this,i),i}findSubGraphParts(){const t=new GSet;return Part.lh(t,this,!0,0,!0),t.delete(this),t}Ki(t){super.Ki(t);const i=this.memberParts;for(;i.next();)i.value.Ki(t)}collapseSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.yT(i,t,this),t.isCollapsingExpanding=!1}yT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ki(!1),n instanceof Group&&n.isSubGraphExpanded&&(n.wasSubGraphExpanded=n.isSubGraphExpanded,n.yT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t),i.Of(n,e);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!1}expandSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.wT(i,t,this),t.isCollapsingExpanding=!1}wT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ki(!0),n instanceof Group&&n.wasSubGraphExpanded&&(n.wasSubGraphExpanded=!1,n.wT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!0}get isSubGraphExpanded(){return(this.z&512)!==0}set isSubGraphExpanded(t){const i=(this.z&512)!==0;if(i!==t){Util.t(t,"boolean",Group,"isSubGraphExpanded"),this.z=this.z^512;const e=this.diagram;this.i("isSubGraphExpanded",i,t);const s=this.subGraphExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.j,e.j=!0),s(this),e!==null&&(e.j=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.Et!==null&&this.Et.u(),this.memberParts.each(n=>n.updateAdornments());return}t?this.expandSubGraph():this.collapseSubGraph()}}get wasSubGraphExpanded(){return(this.z&1024)!==0}set wasSubGraphExpanded(t){const i=(this.z&1024)!==0;i!==t&&(Util.t(t,"boolean",Group,"wasSubGraphExpanded"),this.z=this.z^1024,this.i("wasSubGraphExpanded",i,t))}get subGraphExpandedChanged(){return this.bt!==null?this.bt.ky:null}set subGraphExpandedChanged(t){const i=this.subGraphExpandedChanged;i!==t&&(t!==null&&Util.t(t,"function",Group,"subGraphExpandedChanged"),this.ml(),this.bt.ky=t,this.i("subGraphExpandedChanged",i,t))}move(t,i){i===void 0&&(i=!1);const e=i?this.location:this.position,s=e.x,n=e.y,o=t.x,r=t.y;if((s===o||isNaN(s)&&isNaN(o))&&(n===r||isNaN(n)&&isNaN(r)))return;const l=o-(isNaN(s)?0:s),h=r-(isNaN(n)?0:n),a=Point.a();super.move(t,i);const f=new GSet,u=this.findSubGraphParts().iterator;for(;u.next();){const d=u.value;d instanceof Link&&(d.suspendsRouting&&f.add(d),!(!d.Te&&(d.fromNode===this||d.toNode===this))&&(d.suspendsRouting=!0))}for(u.reset();u.next();){const d=u.value;if(d.Dl()||d instanceof Node&&d.isLinkLabel)continue;const m=d.position,g=d.location;m.isReal()?(a.x=m.x+l,a.y=m.y+h,d.position=a):g.isReal()&&(a.x=g.x+l,a.y=g.y+h,d.location=a)}for(u.reset();u.next();){const d=u.value;if(!(d instanceof Link)||(d.suspendsRouting=f.has(d),!d.Te&&(d.fromNode===this||d.toNode===this)))continue;const m=d.position;a.x=m.x+l,a.y=m.y+h,a.isReal()?d.move(a):d.invalidateRoute()}Point.o(a)}AO(){return(this.z&65536)!==0}TA(t){(this.z&65536)!==0!==t&&(this.z=this.z^65536)}get tl(){return(this.z&32768)!==0}set tl(t){(this.z&32768)!==0!==t&&(this.z=this.z^32768)}}class Placeholder extends GraphObject{ii;Zd;constructor(t){super(),this.ii=Margin.qg,this.Zd=new Rect(NaN,NaN,NaN,NaN),t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.ii=this.ii.L(),t.Zd=this.Zd.copy()}ch(t){if(this.background===null)return!1;const i=this.naturalBounds;return Rect.contains(0,0,i.width,i.height,t.x,t.y)}ld(t,i,e,s){const n=this.part;if((n===null||!(n instanceof Group)&&!(n instanceof Adornment))&&Util.n("Placeholder is not inside a Group or Adornment."),n instanceof Group){const o=this.computeBorder(this.Zd),r=this.minSize,l=isFinite(r.width)?Math.max(r.width,o.width):o.width,h=isFinite(r.height)?Math.max(r.height,o.height):o.height,a=this.Hi;a.Kn(l||0,h||0),this.no(0,0,a.width,a.height);const f=n.memberParts;let c=!1;for(;f.next();)if(f.value.isVisible()){c=!0;break}const u=n.diagram;if(c&&u!==null&&!u.animationManager.OM(n)&&!isNaN(o.x)&&!isNaN(o.y)){const d=Point.a();d.setRectSpot(o,n.locationSpot),n.location=d,Point.o(d)}}else{const o=n,r=this.Hi,l=this.ii,h=l.left+l.right,a=l.top+l.bottom,f=o.adornedObject,c=f.getDocumentAngle();o.angle=c;let u=0;f instanceof Shape&&(u=f.strokeWidth);const d=f.getDocumentScale(),m=f.naturalBounds,g=(m.width+u)*d,p=(m.height+u)*d;if(o.type!==Panel.Link){const y=o.category==="Selection"?Spot.TopLeft:o.locationSpot,x=f.getDocumentPoint(y,Point.a());o.location=x,Point.o(x)}if(!isNaN(g)&&!isNaN(p))r.Kn(g+h||0,p+a||0),this.no(-l.left,-l.top,r.width,r.height);else{const y=f.getDocumentPoint(Spot.TopLeft,Point.a()),x=Rect.H(y.x,y.y,0,0);x.unionPoint(f.getDocumentPoint(Spot.BottomRight,y)),x.unionPoint(f.getDocumentPoint(Spot.TopRight,y)),x.unionPoint(f.getDocumentPoint(Spot.BottomLeft,y)),r.Kn(x.width+h||0,x.height+a||0),this.no(-l.left,-l.top,r.width,r.height),Point.o(y),Rect.o(x)}}}uh(t,i,e,s){this.actualBounds.e(t,i,e,s)}computeBorder(t){const i=this.part,e=i.diagram,s=e===null||!e.animationManager.isAnimating;if(e!==null&&i instanceof Group&&!i.layer.isTemporary&&i.computesBoundsAfterDrag&&this.Zd.isReal()){const l=e.toolManager.findTool("Dragging");if(l===e.currentTool){const h=l.computeBorder(i,this.Zd,t);if(h!==null)return h}}const n=Rect.a(),o=this.computeMemberBounds(n),r=this.ii;return i instanceof Group&&!i.isSubGraphExpanded?t.e(o.x-r.left,o.y-r.top,0,0):t.e(o.x-r.left,o.y-r.top,Math.max(o.width+r.left+r.right,0),Math.max(o.height+r.top+r.bottom,0)),Rect.o(n),s&&i instanceof Group&&i.computesBoundsIncludingLocation&&i.location.isReal()&&t.unionPoint(i.location),t}computeMemberBounds(t){if(!(this.part instanceof Group))return t.e(0,0,0,0),t;const i=this.part;let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=i.memberParts;for(;r.next();){const l=r.value;if(!l.isVisible()||l instanceof Link&&(!i.computesBoundsIncludingLinks||l.Xo()||l.fromNode===i||l.toNode===i))continue;const h=l.actualBounds;h.leftn&&(n=h.right),h.bottom>o&&(o=h.bottom)}if(!isFinite(e)||!isFinite(s)){const l=i.location;t.e(l.x,l.y,0,0)}else t.e(e,s,n-e,o-s);return t}get padding(){return this.ii}set padding(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Placeholder,"padding");const i=this.ii;i.equals(t)||(t=t.L(),this.ii=t,this.i("padding",i,t),this.u())}}class Layout{b;ca;$d;Cr;Qd;_d;Vo;pl;tg;ig;bo;constructor(t){GSet.vi(this),this.b=null,this.ca=null,this.$d=!0,this.Cr=!0,this.Qd=!1,this._d=new Point(0,0).w(),this.Vo=!0,this.pl=null,this.tg=null,this.ig=!1,this.bo=null,t&&Object.assign(this,t)}cloneProtected(t){t.$d=this.$d,t.Cr=this.Cr,t.Qd=this.Qd,t._d.c(this._d),t.Vo=this.Vo,t.pl=this.pl,t.tg=this.tg,t.ig=!0}copy(){const t=new this.constructor;return this.cloneProtected(t),t}fi(t){Util.ur(this,t)}toString(){let t=Util.hn(this.constructor);return t+="(",this.group!==null&&(t+=" in "+this.group),this.diagram!==null&&(t+=" for "+this.diagram),t+=")",t}get diagram(){return this.b}set diagram(t){t!==null&&Util.s(t,Diagram,Layout,"diagram"),this.b=t}get group(){return this.ca}set group(t){this.ca!==t&&(t!==null&&Util.s(t,Group,Layout,"group"),this.ca=t,t!==null&&(this.b=t.diagram))}get isOngoing(){return this.$d}set isOngoing(t){this.$d!==t&&(Util.t(t,"boolean",Layout,"isOngoing"),this.$d=t)}get isInitial(){return this.Cr}set isInitial(t){Util.t(t,"boolean",Layout,"isInitial"),this.Cr=t,t||(this.ig=!0)}get isViewportSized(){return this.Qd}set isViewportSized(t){this.Qd!==t&&(Util.t(t,"boolean",Layout,"isViewportSized"),this.Qd=t,t&&this.invalidateLayout())}get isRouting(){return this.Vo}set isRouting(t){this.Vo!==t&&(Util.t(t,"boolean",Layout,"isRouting"),this.Vo=t)}get isRealtime(){return this.pl}set isRealtime(t){this.pl!==t&&(t!==null&&Util.t(t,"boolean",Layout,"isRealtime"),this.pl=t)}get isValidLayout(){return this.ig}set isValidLayout(t){if(this.ig!==t&&(Util.t(t,"boolean",Layout,"isValidLayout"),this.ig=t,!t)){const i=this.diagram;i!==null&&(i.Wr=!0)}}invalidateLayout(){if(this.isValidLayout){const t=this.diagram;if(t===null||t.undoManager.isUndoingRedoing)return;const i=t.animationManager;if(i.isTicking)return;i.defaultAnimation.isAnimating&&i.stopAnimation(),(this.isOngoing&&t.Yh||this.isInitial&&!t.Yh)&&(this.isValidLayout=!1,t.requestUpdate())}}get network(){return this.bo}set network(t){this.bo!==t&&(t!==null&&Util.s(t,LayoutNetwork,Layout,"network"),this.bo=t,t!==null&&(t.layout=this))}createNetwork(){return new LayoutNetwork(this)}makeNetwork(t){const i=this.createNetwork();return t instanceof Diagram?(i.addParts(t.nodes,!0),i.addParts(t.links,!0)):t instanceof Group?i.addParts(t.memberParts):i.addParts(t.iterator),i}updateParts(){this.isValidLayout=!0;let t=this.diagram;if(t===null&&this.network!==null){const i=this.network.vertexes.iterator;for(;i.next();){const s=i.value.node;if(s!==null&&(t=s.diagram,t!==null))break}}try{t!==null&&t.startTransaction("Layout"),this.commitLayout()}finally{t!==null&&t.commitTransaction("Layout")}}commitLayout(){if(this.network===null)return;const t=this.network.vertexes.iterator;for(;t.next();)t.value.commit();if(this.isRouting){const i=this.network.edges.iterator;for(;i.next();)i.value.commit()}}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts");const i=new GSet;if(t instanceof Diagram?(this.Ph(i,t.nodes,!0,this.tl,!0,!1,!0),this.Ph(i,t.parts,!0,this.tl,!0,!1,!0)):t instanceof Group?this.Ph(i,t.memberParts,!1,this.tl,!0,!1,!0):i.addAll(t.iterator),i.count>0){const s=this.diagram;s!==null&&s.startTransaction("Layout"),this.doMinimalNoNetworkLayout(i),s!==null&&s.commitTransaction("Layout")}this.isValidLayout=!0}doMinimalNoNetworkLayout(t){const i=t.count,e=Math.ceil(Math.sqrt(i));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const s=this.arrangementOrigin.x,n=this.arrangementOrigin.y;let o=s,r=n,l=0,h=0;const a=t.iterator;for(;a.next();){const f=a.value;f.ensureBounds();const c=f.measuredBounds,u=c.width,d=c.height;f.moveTo(o,r),f instanceof Group&&(f.tl=!1),o+=Math.max(u,50)+20,h=Math.max(h,Math.max(d,50)),l>=e-1?(l=0,o=s,r+=h+20,h=0):l++}}doMinimalNetworkLayout(){const t=this.network.vertexes.count,i=Math.ceil(Math.sqrt(t));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const e=this.arrangementOrigin.x,s=this.arrangementOrigin.y;let n=e,o=s,r=0,l=0;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value.node;if(a===null||a instanceof Link||(a.ensureBounds(),!this.tl(a)))continue;const f=a.measuredBounds,c=f.width,u=f.height;a.moveTo(n,o),a instanceof Group&&(a.tl=!1),n+=Math.max(c,50)+20,l=Math.max(l,Math.max(u,50)),r>=i-1?(r=0,n=e,o+=l+20,l=0):r++}}tl(t){return!!(!t.location.isReal()&&!t.position.isReal()||t instanceof Group&&t.tl)}Ph(t,i,e,s,n,o,r){const l=i.iterator;for(;l.next();){const h=l.value;if(!(e&&!h.isTopLevel)&&!(s!==null&&!s(h))&&h.canLayout())if(n&&h instanceof Node){if(h.isLinkLabel)continue;h instanceof Group&&h.layout===null?this.Ph(t,h.memberParts,!1,s,n,o,r):(h.ensureBounds(),t.add(h))}else o&&h instanceof Link?t.add(h):r&&h.Ae()&&!(h instanceof Node)&&(h.ensureBounds(),t.add(h))}}getLayoutBounds(t,i){const e=this.boundsComputation;return e!==null?(i||(i=new Rect),e(t,this,i)):!i&&t.margin.equalTo(0,0,0,0)?t.actualBounds:(i||(i=new Rect),i.set(t.actualBounds),i.addMargin(t.margin),i)}get boundsComputation(){return this.tg}set boundsComputation(t){this.tg!==t&&(t!==null&&Util.t(t,"function",Layout,"boundsComputation"),this.tg=t,this.invalidateLayout())}collectParts(t){const i=new GSet;return t instanceof Diagram?(this.Ph(i,t.nodes,!0,null,!0,!0,!0),this.Ph(i,t.links,!0,null,!0,!0,!0),this.Ph(i,t.parts,!0,null,!0,!0,!0)):t instanceof Group?this.Ph(i,t.memberParts,!1,null,!0,!0,!0):this.Ph(i,t.iterator,!1,null,!0,!0,!0),i}get arrangementOrigin(){return this._d}set arrangementOrigin(t){Util.s(t,Point,Layout,"arrangementOrigin"),this._d.equals(t)||(this._d.c(t),this.invalidateLayout())}initialOrigin(t){const i=this.group;if(i!==null)if(i.hasPlaceholder()){const e=i.placeholder,s=e.getDocumentPoint(Spot.TopLeft);(isNaN(s.x)||isNaN(s.y))&&s.set(t);const n=e.padding;return s.x+=n.left,s.y+=n.top,s}else{const e=i.position.copy();return(isNaN(e.x)||isNaN(e.y))&&e.set(t),e}return t}}class LayoutNetwork{oe;ko;Fn;Ay;Ly;constructor(t){GSet.vi(this),Debug&&!t&&Util.n("LayoutNetwork constructor requires non-null Layout argument"),this.oe=t,this.ko=new GSet,this.Fn=new GSet,this.Ay=new GMap,this.Ly=new GMap}clear(){if(this.ko){const t=this.ko.iterator;for(;t.next();)t.value.clear()}if(this.Fn){const t=this.Fn.iterator;for(;t.next();)t.value.clear()}this.ko=new GSet,this.Fn=new GSet,this.Ay=new GMap,this.Ly=new GMap}toString(t){t===void 0&&(t=0);let i="LayoutNetwork"+(this.layout!==null?"("+this.layout.toString()+")":"");if(t<=0)return i;if(i+=" vertexes: "+this.ko.count+" edges: "+this.Fn.count,t>1){const e=this.ko.iterator;for(;e.next();){const n=e.value;i+=` +`);if(t.length===0)return 8;if(this.isMultiline){let i=0,e=0,s=!1;for(;!s;){let n=this.ub(t,e);n===-1&&(n=t.length,s=!0);let o=t.substring(e,n);this.formatting===0&&(o=o.trim()),i=Math.max(i,this.getStringWidth(o)),e=n+1}return i}else{const i=this.ub(t,0);return i>=0&&(t=t.substring(0,i)),this.getStringWidth(t)}}get textValidation(){return this.$!==null?this.$.Il:null}set textValidation(t){const i=this.textValidation;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"textValidation"),this.Tn(),this.$.Il=t,this.i("textValidation",i,t))}get textEdited(){return this.$!==null?this.$.Vp:null}set textEdited(t){const i=this.textEdited;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"textEdited"),this.Tn(),this.$.Vp=t,this.i("textEdited",i,t))}get spacingAbove(){return this.$!==null?this.$.zp:0}set spacingAbove(t){const i=this.spacingAbove;i!==t&&(Debug&&Util.t(t,"number",TextBlock,"spacingAbove"),this.Tn(),this.$.zp=t,this.u(),this.i("spacingAbove",i,t))}get spacingBelow(){return this.$!==null?this.$.Xp:0}set spacingBelow(t){const i=this.spacingBelow;i!==t&&(Debug&&Util.t(t,"number",TextBlock,"spacingBelow"),this.Tn(),this.$.Xp=t,this.u(),this.i("spacingBelow",i,t))}get formatting(){return this.$!==null?this.$.Yp:0}set formatting(t){const i=this.formatting;i!==t&&(Util.tt(t,TextFormat,"formatting"),this.Tn(),this.$.Yp=t,this.u(),this.i("formatting",i,t))}get maxLines(){return this.$!==null?this.$.Kp:1/0}set maxLines(t){const i=this.maxLines;i!==t&&(Debug&&Util.t(t,"number",TextBlock,"maxLines"),t=Math.floor(t),t<=0&&Util.G(t,"> 0",TextBlock,"maxLines"),this.Tn(),this.$.Kp=t,this.u(),this.i("maxLines",i,t))}getMetrics(){return[this.xi,this.Ol,this.co,this.An,this.Re,this.Oi,this.Ln]}DI(t){t!==void 0&&(this.xi=t[0],this.Ol=t[1],this.co=t[2],this.An=t[3],this.Re=t[4],this.Oi=t[5],this.Ln=t[6])}get metrics(){return{arrSize:this.Re!==null?this.Re:[this.xi],arrText:this.Oi!==null?this.Oi:[this.Ln],maxLineWidth:this.xi,fontHeight:this.co}}get choices(){return this.Dd}set choices(t){const i=this.Dd;i!==t&&(Debug&&t!==null&&!Array.isArray(t)&&Util.Bi(t,"Array",TextBlock,"choices:value"),this.Dd=t,this.i("choices",i,t))}static EI=new RegExp("[ \u200B\xAD]");static W2=new PropertyCollection;static HL=0;static ab=new PropertyCollection;static H2=0;static Dp="...";static UL="";static rl=Diagram.isUsingDOM()?new CanvasSurface(null).di:null}class TextBlockTemplateSettings{wi;fs;uo;Yp;Kp;Ip;zp;Xp;Fp;Vp;Ep;Il;hl;Rp;constructor(){this.wi=!1,this.fs=null,this.uo=0,this.Yp=0,this.Kp=1/0,this.Ip=0,this.zp=0,this.Xp=0,this.Fp="start",this.Vp=null,this.Ep=null,this.Il=null,this.hl=Spot.Top,this.Rp=2}copy(){const t=new TextBlockTemplateSettings;return t.fs=this.fs,t.uo=this.uo,t.Yp=this.Yp,t.Kp=this.Kp,t.Ip=this.Ip,t.zp=this.zp,t.Xp=this.Xp,t.Fp=this.Fp,t.Vp=this.Vp,t.Ep=this.Ep,t.Il=this.Il,t.hl=this.hl,t.Rp=this.Rp,t}}class GradElementSettings{wc;xc;bc;Bp;kc;constructor(){this.wc=1,this.xc=0,this.bc=1,this.Bp=null,this.kc=null}copy(){const t=new GradElementSettings;return t.wc=this.wc,t.xc=this.xc,t.bc=this.bc,t.Bp=this.Bp,t.kc=this.kc,t}}var ImageStretch=(w=>(w[w.None=0]="None",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ImageStretch||{});class Picture extends GraphObject{al;St;fl;Sc;fs;cl;Mc;uo;Pc;Nc;W1;constructor(t,i){super(),this.l|=2097152,this.al=null,this.St="",this.fl=Rect.BD,this.Sc=2,this.fs=null,this.cl=null,this.Mc=Spot.Center,this.uo=0,this.Pc=null,this.Nc=null,this.W1=null,typeof t=="string"?this.source=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.St=this.St,t.element=this.al,t.fl=this.fl.L(),t.Sc=this.Sc,t.uo=this.uo,t.fs=this.fs,t.cl=this.cl,t.Mc=this.Mc.L(),t.Nc=this.Nc}fi(t){t in ImageStretch?this.imageStretch=t:super.fi(t)}toString(){return"Picture("+this.source+")#"+GSet.gs(this)}get Cc(){return(this.l&1048576)!==0}set Cc(t){this.Cc!==t&&(this.l=this.l^1048576)}get Oa(){return(this.l&2097152)!==0}set Oa(t){this.Oa!==t&&(this.l=this.l^2097152)}get bn(){return(this.l&4194304)!==0}set bn(t){this.bn!==t&&(this.l=this.l^4194304)}static clearCache(t){t===void 0&&(t=""),Util.t(t,"string",Picture,"clearCache:url"),t!==""?Picture.Up[t]&&(delete Picture.Up[t],Picture.db--):(Picture.Up=new PropertyCollection,Picture.db=0)}static KA(t,i){i.qL||(i.gb=e=>{Picture.BI(i,e),t.desiredSize.isReal()||(t.ye(!1),t.u())},i.mb=e=>Picture.VI(i,e),i.addEventListener("load",i.gb),i.addEventListener("error",i.mb),i.qL=!0)}static MR(t){t.gb&&t.removeEventListener("load",t.gb),t.mb&&t.removeEventListener("error",t.mb),delete t.gb,delete t.mb,delete t.qL}get element(){return this.al}set element(t){const i=this.al;if(this.hs(!0),i!==t){this.Cc=t instanceof HTMLCanvasElement;const e=t instanceof HTMLImageElement;t!==null&&!(e||t instanceof HTMLVideoElement||this.Cc)&&Util.n("Picture.element must be an instance of Image, Canvas, or Video, not: "+t);const s=this.diagram;s!==null&&s.zP(this),this.al=t,t!==null&&e&&t.ls===void 0&&(t.ls=new GSet),s!==null&&e&&s.VP(this),this.i("element",i,t),this.T()}}kR(){const t=this.al;if(t===null)return;const i=this.desiredSize.isReal();(this.Cc||t.complete===!0)&&(t.y0&&(t.Gp instanceof Event&&this.fs!==null?this.fs(this,t.Gp):t.bn===!0&&!t.Gp&&this.cl!==null&&t.v2&&this.cl(this,t.v2)),t.bn=!0),t.bn&&i&&this.diagram!==null&&this.diagram.Wu.add(this)}zI(){if(this.al===null){this.Pc=!1;return}const t=new CanvasSurface(null).di;try{t.drawImage(this.al,0,0)}catch(i){Debug&&this.Oa&&Util.ht(i.toString()),this.Oa=!1}try{t.getImageData(0,0,1,1).data[3]&&(this.Pc=!1),this.Pc=!1}catch{this.Pc=!0}}get source(){return this.St}set source(t){const i=this.St;if(i!==t){this.hs(!0),Util.t(t,"string",Picture,"source"),this.St=t;let e=Picture.Up;if(!Diagram.isUsingDOM()){this.i("source",i,t);return}let s=null;if(e[t]!==void 0)s=e[t];else if(t!==""){Picture.db>30&&(Picture.clearCache(),e=Picture.Up),s=Util.ln("img"),s.y0=!0,Picture.KA(this,s);const n=this.Nc;n!==null&&(s.crossOrigin=n(this)),s.src=t,e[t]=s,Picture.db++}this.element=s,s!==null&&s.__goCache===void 0&&(s.__goCache=new PictureCacheArray),this.u(),this.T(),this.i("source",i,t)}}static BI(t,i){t.bn=!0,t.Gp=!1;let e;const s=t.ls.copy();if(s==null)return;const n=s.iterator;for(;n.next();){const o=n.value;o.T();const r=t.getAttribute("src")||"",l=o._l.get(r);if(l===null)continue;const h=l.length;for(let a=0;a=o.width&&(r=r+p.offsetX+(d*p.x-o.width*p.x)),m>=o.height&&(l=l+p.offsetY+(m*p.y-o.height*p.y)),a=Math.min(o.width,d),f=Math.min(o.height,m);break;case 2:d=o.width,m=o.height;break;case 6:case 7:let L=0;g===6?(L=Math.min(o.height/m,o.width/d),d*=L,m*=L):g===7&&(L=Math.max(o.height/m,o.width/d),d*=L,m*=L,d>=o.width&&(r=(r+p.offsetX+(d*p.x-o.width*p.x)/d)*a),m>=o.height&&(l=(l+p.offsetY+(m*p.y-o.height*p.y)/m)*f),a*=1/(d/o.width),f*=1/(m/o.height),d=o.width,m=o.height);break}const y=a*f,x=this.getDocumentScale()*i.scale,k=d*x,b=m*x,S=k*b,M=y/S,A=e.__goCache;let C=null;const P=Picture.XI;if(!n){if(e.bn&&A!==void 0&&S>4&&M>P*P){A.Yt===null&&(A.jL(4,c,u,e),A.jL(16,c,u,e));const L=A.Yt,D=L.length;for(let F=0;F0){const f=this.Yt[this.Yt.length-1];h=f.St,a=f.Rd}o.setTransform(r*a,0,0,r*a,0,0),o.commitTransform(),o.drawImage(h,0,0),this.Yt.push(l)}}class PictureCacheInstance{St;Rd;constructor(t,i){this.St=t,this.Rd=i}}class GeoStream{Ci;tm;constructor(){this.tm=new Geometry,this.Ci=null}Vi(t){t!==null?(t.ft(),this.tm=t,t.figures.clear()):this.tm=new Geometry,this.Ci=null}yu(t,i,e,s,n,o){if(s!==void 0&&s===!0){const r=new PathSegment(1);r.endX=t,r.endY=i,this.Ci.segments.add(r)}else this.Ci=new PathFigure,this.Ci.startX=t,this.Ci.startY=i,this.Ci.isFilled=e,this.Ci.isEvenOdd=o||!1,this.tm.figures.add(this.Ci);n!==void 0&&(this.Ci.isShadowed=n)}jD(){const t=this.Ci.segments.length;t>0&&this.Ci.segments.elt(t-1).close()}WD(){this.Ci.segments.length>0&&(this.Ci.isFilled=!0)}vD(t){this.Ci.isShadowed=t}mE(t){this.Ci.isEvenOdd=t}GD(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(1);s.endX=t,s.endY=i,e&&s.close(),this.Ci.segments.add(s)}yr(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(2);s.endX=t,s.endY=i,e&&s.close(),this.Ci.segments.add(s)}wr(t,i,e,s,n,o,r){r===void 0&&(r=!1);const l=new PathSegment(3);l.point1X=t,l.point1Y=i,l.point2X=e,l.point2Y=s,l.endX=n,l.endY=o,r&&l.close(),this.Ci.segments.add(l)}Fw(t,i,e,s,n){n===void 0&&(n=!1);const o=new PathSegment(4);o.point1X=t,o.point1Y=i,o.endX=e,o.endY=s,n&&o.close(),this.Ci.segments.add(o)}HD(t,i,e,s,n,o,r){o===void 0&&(o=0),r===void 0&&(r=!1);const l=new PathSegment(5);l.startAngle=t,l.sweepAngle=i,l.centerX=e,l.centerY=s,l.radiusX=n,o!==0?l.radiusY=o:l.radiusY=n,r&&l.close(),this.Ci.segments.add(l)}qD(t,i,e,s,n,o,r,l){l===void 0&&(l=!1);const h=new PathSegment(6,o,r,t,i,e,s,n);l&&h.close(),this.Ci.segments.add(h)}static J2=null;static SC(t){const i=GeoStream.J2;if(i!==null)return GeoStream.J2=null,i.Vi(t),i;{const e=new GeoStream;return e.Vi(t),e}}static MC(t){GeoStream.J2=t}}{const w=function(n,o){const r=n.toLowerCase(),l=Geo.qn;l[n]=o,l[r]=n};w("Rectangle",(n,o,r)=>{const l="r"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,Geo.pr{const l="s"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,h.defaultStretch=6,Geo.pr{(isNaN(l)||l<0)&&(l=5),isNaN(h)&&(h=15);const a="rr"+o+","+r+","+l+","+h;let f=Geo.mr[a];if(f!==void 0)return f;let c=l;(h&1)===1?(c=Math.min(c,(h&2)===2?o/3:o),c=Math.min(c,(h&8)===8?r/3:r)):c=0;const u=new PathFigure(c,0,!0);f=new Geometry().add(u);const d=Spot.TopLeft.copy(),m=Spot.BottomRight.copy();if((h&2)===2){let g=l;g=Math.min(g,(h&1)===1?o/3:o),g=Math.min(g,(h&4)===4?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,o-g,0)).add(new PathSegment(3,o,g,o-p,0,o,p)),d.offsetY=p,m.offsetX=-p}else u.add(new PathSegment(2,o,0));if((h&4)===4){let g=l;g=Math.min(g,(h&8)===8?o/3:o),g=Math.min(g,(h&2)===2?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,o,r-g)).add(new PathSegment(3,o-g,r,o,r-p,o-p,r)),m.offsetX=-p,m.offsetY=-p}else u.add(new PathSegment(2,o,r));if((h&8)===8){let g=l;g=Math.min(g,(h&4)===4?o/3:o),g=Math.min(g,(h&1)===1?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,g,r)).add(new PathSegment(3,0,r-g,p,r,0,r-p)),d.offsetX=p,m.offsetY=-p}else u.add(new PathSegment(2,0,r));if((h&1)===1){const g=c*Geo.Un;u.add(new PathSegment(2,0,c)).add(new PathSegment(3,c,0,0,g,g,0).close()),d.offsetX=g,d.offsetY=g}else u.add(new PathSegment(2,0,0).close());return f.spot1=d,f.spot2=m,Geo.pr{const l=n?n.parameter1:NaN,h=n?n.parameter2:NaN;return t(n,o,r,l,h)}),w("Border","RoundedRectangle"),w("RoundedTopRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,3)}),w("RoundedBottomRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,12)}),w("RoundedLeftRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,9)}),w("RoundedRightRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,6)}),w("Ellipse",(n,o,r)=>{const l="e"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Kk,h.spot2=Spot.Uk,Geo.pr{const l="c"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Kk,h.spot2=Spot.Uk,h.defaultStretch=6,Geo.prnew Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,.5*r)).add(new PathSegment(2,0,r).close())).setSpots(0,.25,.5,.75)),w("TriangleDown",(n,o,r)=>new Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,0)).add(new PathSegment(2,.5*o,r).close())).setSpots(.25,0,.75,.5)),w("TriangleLeft",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,o,0).close())).setSpots(.5,.25,1,.75)),w("TriangleUp",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,r)).add(new PathSegment(2,.5*o,0).close())).setSpots(.25,.5,.75,1)),w("Triangle","TriangleUp"),w("Diamond",(n,o,r)=>new Geometry().add(new PathFigure(.5*o,0).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,.5*o,r)).add(new PathSegment(2,o,.5*r).close())).setSpots(.25,.25,.75,.75)),w("LineH",(n,o,r)=>{const l=new Geometry(1);return l.startX=0,l.startY=r/2,l.endX=o,l.endY=r/2,l}),w("LineV",(n,o,r)=>{const l=new Geometry(1);return l.startX=o/2,l.startY=0,l.endX=o/2,l.endY=r,l}),w("None","Rectangle"),w("BarH","Rectangle"),w("BarV","Rectangle"),w("MinusLine","LineH"),w("PlusLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r/2,!1).add(new PathSegment(2,o,r/2)).add(new PathSegment(1,o/2,0)).add(new PathSegment(2,o/2,r)))),w("XLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r,!1).add(new PathSegment(2,o,0)).add(new PathSegment(1,0,0)).add(new PathSegment(2,o,r)))),w("LineRight",(n,o,r)=>new Geometry().add(new PathFigure(.25*o,0,!1).add(new PathSegment(2,.75*o,.5*r)).add(new PathSegment(2,.25*o,r)))),w("LineDown",(n,o,r)=>new Geometry().add(new PathFigure(0,.25*r,!1).add(new PathSegment(2,.5*o,.75*r)).add(new PathSegment(2,o,.25*r)))),w("LineLeft",(n,o,r)=>new Geometry().add(new PathFigure(.75*o,0,!1).add(new PathSegment(2,.25*o,.5*r)).add(new PathSegment(2,.75*o,r)))),w("LineUp",(n,o,r)=>new Geometry().add(new PathFigure(0,.75*r,!1).add(new PathSegment(2,.5*o,.25*r)).add(new PathSegment(2,o,.75*r)))),w("Capsule",(n,o,r)=>{const l=new Geometry;if(or){const h=r/2,a=new PathFigure(h,0,!0);l.add(a),a.add(new PathSegment(2,o-h,0)),a.add(new PathSegment(5,270,180,o-h,h,h,h)),a.add(new PathSegment(2,h,r)),a.add(new PathSegment(5,90,180,h,h,h,h));const f=isFinite(n.parameter1)?n.parameter1:r*.156;return l.spot1=new Spot(0,0,f,0),l.spot2=new Spot(1,1,-f,0),l}else return l.type=3,l.endX=o,l.endY=r,l.spot1=Spot.Kk,l.spot2=Spot.Uk,l});const i=(n,o)=>new PathFigure(n,o,!1,!1),e=(n,o,r)=>n.add(new PathSegment(2,o,r)),s=(n,o,r)=>n.add(new PathSegment(1,o,r));w("Borders",(n,o,r)=>{let l=n?n.parameter1:NaN;isNaN(l)?l=10:l=l&15;const h=new Geometry;let a;return l===10?(a=i(o,0),e(a,o,r),s(a,0,r),e(a,0,0)):l===5?(a=i(0,0),e(a,o,0),s(a,o,r),e(a,0,r)):l===1?(a=i(0,0),e(a,o,0),s(a,o,r)):l===2?(a=i(o,0),e(a,o,r)):l===4?(a=i(o,r),e(a,0,r)):l===8?(a=i(0,r),e(a,0,0),s(a,o,r)):l===3?(a=i(0,0),e(a,o,0),e(a,o,r)):l===6?(a=i(o,0),e(a,o,r),e(a,0,r)):l===12?(a=i(o,r),e(a,0,r),e(a,0,0)):l===9?(a=i(0,r),e(a,0,0),e(a,o,0)):l===7?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r)):l===14?(a=i(o,0),e(a,o,r),e(a,0,r),e(a,0,0)):l===13?(a=i(o,r),e(a,0,r),e(a,0,0),e(a,o,0)):l===11?(a=i(0,r),e(a,0,0),e(a,o,0),e(a,o,r)):l===15?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r),a.add(new PathSegment(2,0,0).close())):(a=i(0,0),s(a,o,r)),h.add(a),h})}Geo.Jg={"":"",Standard:"F1 m 0,0 l 8,4 -8,4 2,-4 z",Backward:"F1 m 8,0 l -2,4 2,4 -8,-4 z",Triangle:"F1 m 0,0 l 8,4.62 -8,4.62 z",BackwardTriangle:"F1 m 8,4 l 0,4 -8,-4 8,-4 0,4 z",Boomerang:"F1 m 0,0 l 8,4 -8,4 4,-4 -4,-4 z",BackwardBoomerang:"F1 m 8,0 l -8,4 8,4 -4,-4 4,-4 z",SidewaysV:"m 0,0 l 8,4 -8,4 0,-1 6,-3 -6,-3 0,-1 z",BackwardV:"m 8,0 l -8,4 8,4 0,-1 -6,-3 6,-3 0,-1 z",OpenTriangle:"m 0,0 l 8,4 -8,4",BackwardOpenTriangle:"m 8,0 l -8,4 8,4",OpenTriangleLine:"m 0,0 l 8,4 -8,4 m 8.5,0 l 0,-8",BackwardOpenTriangleLine:"m 8,0 l -8,4 8,4 m -8.5,0 l 0,-8",OpenTriangleTop:"m 0,0 l 8,4 m 0,4",BackwardOpenTriangleTop:"m 8,0 l -8,4 m 0,4",OpenTriangleBottom:"m 0,8 l 8,-4",BackwardOpenTriangleBottom:"m 0,4 l 8,4",HalfTriangleTop:"F1 m 0,0 l 0,4 8,0 z m 0,8",BackwardHalfTriangleTop:"F1 m 8,0 l 0,4 -8,0 z m 0,8",HalfTriangleBottom:"F1 m 0,4 l 0,4 8,-4 z",BackwardHalfTriangleBottom:"F1 m 8,4 l 0,4 -8,-4 z",ForwardSemiCircle:"m 4,0 b 270 180 0 4 4",BackwardSemiCircle:"m 4,8 b 90 180 0 -4 4",Feather:"m 0,0 l 3,4 -3,4",BackwardFeather:"m 3,0 l -3,4 3,4",DoubleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardDoubleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4",TripleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardTripleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4 m 3,-8 l -3,4 3,4",ForwardSlash:"m 0,8 l 5,-8",BackSlash:"m 0,0 l 5,8",DoubleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8",DoubleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8",TripleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8 m -2,8 l 4,-8",TripleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8 m -2,-8 l 4,8",Fork:"m 0,4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4",LineFork:"m 0,0 l 0,8 m 0,-4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardLineFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4 m 8,-8 l 0,8",CircleFork:"F1 m 6,4 b 0 360 -3 0 3 z m 0,0 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 6,0 b 0 360 -3 0 3",CircleLineFork:"F1 m 6,4 b 0 360 -3 0 3 z m 1,-4 l 0,8 m 0,-4 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleLineFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 0,-4 l 0,8 m 7,-4 b 0 360 -3 0 3",Circle:"F1 m 8,4 b 0 360 -4 0 4 z",Block:"F1 m 0,0 l 0,8 8,0 0,-8 z",StretchedDiamond:"F1 m 0,3 l 5,-3 5,3 -5,3 -5,-3 z",Diamond:"F1 m 0,4 l 4,-4 4,4 -4,4 -4,-4 z",Chevron:"F1 m 0,0 l 5,0 3,4 -3,4 -5,0 3,-4 -3,-4 z",StretchedChevron:"F1 m 0,0 l 8,0 3,4 -3,4 -8,0 3,-4 -3,-4 z",NormalArrow:"F1 m 0,2 l 4,0 0,-2 4,4 -4,4 0,-2 -4,0 z",X:"m 0,0 l 8,8 m 0,-8 l -8,8",TailedNormalArrow:"F1 m 0,0 l 2,0 1,2 3,0 0,-2 2,4 -2,4 0,-2 -3,0 -1,2 -2,0 1,-4 -1,-4 z",DoubleTriangle:"F1 m 0,0 l 4,4 -4,4 0,-8 z m 4,0 l 4,4 -4,4 0,-8 z",BigEndArrow:"F1 m 0,0 l 5,2 0,-2 3,4 -3,4 0,-2 -5,2 0,-8 z",ConcaveTailArrow:"F1 m 0,2 h 4 v -2 l 4,4 -4,4 v -2 h -4 l 2,-2 -2,-2 z",RoundedTriangle:"F1 m 0,1 a 1,1 0 0 1 1,-1 l 7,3 a 0.5,1 0 0 1 0,2 l -7,3 a 1,1 0 0 1 -1,-1 l 0,-6 z",SimpleArrow:"F1 m 1,2 l -1,-2 2,0 1,2 -1,2 -2,0 1,-2 5,0 0,-2 2,2 -2,2 0,-2 z",AccelerationArrow:"F1 m 0,0 l 0,8 0.2,0 0,-8 -0.2,0 z m 2,0 l 0,8 1,0 0,-8 -1,0 z m 3,0 l 2,0 2,4 -2,4 -2,0 0,-8 z",BoxArrow:"F1 m 0,0 l 4,0 0,2 2,0 0,-2 2,4 -2,4 0,-2 -2,0 0,2 -4,0 0,-8 z",TriangleLine:"F1 m 8,4 l -8,-4 0,8 8,-4 z m 0.5,4 l 0,-8",CircleEndedArrow:"F1 m 10,4 l -2,-3 0,2 -2,0 0,2 2,0 0,2 2,-3 z m -4,0 b 0 360 -3 0 3 z",DynamicWidthArrow:"F1 m 0,3 l 2,0 2,-1 2,-2 2,4 -2,4 -2,-2 -2,-1 -2,0 0,-2 z",EquilibriumArrow:"m 0,3 l 8,0 -3,-3 m 3,5 l -8,0 3,3",FastForward:"F1 m 0,0 l 3.5,4 0,-4 3.5,4 0,-4 1,0 0,8 -1,0 0,-4 -3.5,4 0,-4 -3.5,4 0,-8 z",Kite:"F1 m 0,4 l 2,-4 6,4 -6,4 -2,-4 z",HalfArrowTop:"F1 m 0,0 l 4,4 4,0 -8,-4 z m 0,8",HalfArrowBottom:"F1 m 0,8 l 4,-4 4,0 -8,4 z",OpposingDirectionDoubleArrow:"F1 m 0,4 l 2,-4 0,2 4,0 0,-2 2,4 -2,4 0,-2 -4,0 0,2 -2,-4 z",PartialDoubleTriangle:"F1 m 0,0 4,3 0,-3 4,4 -4,4 0,-3 -4,3 0,-8 z",LineCircle:"F1 m 0,0 l 0,8 m 7 -4 b 0 360 -3 0 3 z",DoubleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",TripleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",CircleLine:"F1 m 6 4 b 0 360 -3 0 3 z m 1,-4 l 0,8",DiamondCircle:"F1 m 8,4 l -4,4 -4,-4 4,-4 4,4 m 8,0 b 0 360 -4 0 4 z",PlusCircle:"F1 m 8,4 b 0 360 -4 0 4 l -8 0 z m -4 -4 l 0 8",OpenRightTriangleTop:"m 8,0 l 0,4 -8,0 m 0,4",OpenRightTriangleBottom:"m 8,8 l 0,-4 -8,0",Line:"m 0,0 l 0,8",DoubleLine:"m 0,0 l 0,8 m 2,0 l 0,-8",TripleLine:"m 0,0 l 0,8 m 2,0 l 0,-8 m 2,0 l 0,8",PentagonArrow:"F1 m 8,4 l -4,-4 -4,0 0,8 4,0 4,-4 z"};var LayoutConditions=(w=>(w[w.None=0]="None",w[w.Added=1]="Added",w[w.Removed=2]="Removed",w[w.Shown=4]="Shown",w[w.Hidden=8]="Hidden",w[w.NodeSized=16]="NodeSized",w[w.GroupLayout=32]="GroupLayout",w[w.NodeReplaced=64]="NodeReplaced",w[w.Standard=127]="Standard",w[w.All=16777215]="All",w))(LayoutConditions||{});class Part extends Panel{N;$o;E;ul;dl;Qo;ui;_o;bh;Zs;tr;Id;qM;WL;Hp;qp;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.N=2408959,this.$o="",this.E=null,this.ul="",this.dl=null,this.Qo=null,this.ui="",this._o=null,this.bh=null,this.Zs=new Point(NaN,NaN).w(),this.tr=null,this.Id=NaN,this.qM=-1,this.WL=new Rect,this.Hp=null,this.qp=NaN,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.N=this.N&-4097|16384|32768,t.$o=this.$o,this.E!==null&&(this.E.wi?t.E=this.E:t.E=this.E.copy()),t.ul=this.ul,t.Qo=null,t.ui=this.ui,t.Zs.c(this.Zs),t.Id=this.Id}Ho(t){super.Ho(t),t.gh(),t.dl=null,t.tr=null,t.Hp=null}toString(){let t=Util.hn(this.constructor)+"#"+GSet.gs(this);return this.data!==null&&(t+="("+Util.toString(this.data)+")"),t}static LayoutNone=0;static LayoutAdded=1;static LayoutRemoved=2;static LayoutShown=4;static LayoutHidden=8;static LayoutNodeSized=16;static LayoutGroupLayout=32;static LayoutNodeReplaced=64;static LayoutStandard=127;static LayoutAll=16777215;Qi(){this.E===null?this.E=new PartTemplateSettings:this.E.wi&&(this.E=this.E.copy())}ch(){super.ch(),this.E!==null&&(this.E.wi=!0)}ec(t,i,e,s,n,o,r){const l=this.diagram;l!==null&&(t===3&&i==="elements"?n instanceof Panel?n.Qr(h=>{l.partManager.FP(h,l)}):n instanceof Picture&&l.VP(n):t===4&&i==="elements"&&(n instanceof Panel?n.Qr(h=>l.partManager.RP(h,l)):n instanceof Picture&&l.zP(n)),l.raiseChangedEvent(t,i,e,s,n,o,r))}updateTargetBindings(t){if(super.updateTargetBindings(t),this.data===null)return;const i=this.D.h,e=i.length;for(let n=0;n{r.data!==null&&r.updateTargetBindings()})}const s=this.adornments;for(;s.next();)s.value.updateTargetBindings(t)}Yo(){if(super.Yo(),this.M2()){const i=this.D.h,e=i.length;for(let s=0;so.Yo())}}const t=this.adornments;for(;t.next();)t.value.Yo()}updateRelationshipsFromData(){this.data!==null&&this.diagram?.partManager.updateRelationshipsFromData(this)}get key(){const t=this.diagram;if(t!==null)return t.model.getKeyForNodeData(this.data)}get adornments(){return this.Qo===null?EmptyIterator.instance:this.Qo.iteratorValues}findAdornment(t){Debug&&Util.t(t,"string",Part,"findAdornment:category");const i=this.Qo;return i===null?null:i.get(t)}addAdornment(t,i){if(i===null)return;Debug&&(Util.t(t,"string",Part,"addAdornment:category"),Util.s(i,Adornment,Part,"addAdornment:ad"));let e=null,s=this.Qo;if(s!==null&&(e=s.get(t)),e!==i){if(e!==null){const o=e.diagram;o!==null&&o.remove(e)}s===null&&(s=new GMap,this.Qo=s),i.$o!==t&&(i.category=t),s.set(t,i);const n=this.diagram;if(n!==null){n.add(i);const o=i.adornedObject;if(o!==null){const r=o.findBindingPanel();r!==null&&(i.data=r.data)}}}}removeAdornment(t){Debug&&Util.t(t,"string",Part,"removeAdornment:category");const i=this.Qo;if(i===null)return;const e=i.get(t);if(e!==null){const s=e.diagram;s!==null&&(s.remove(e),e.data=null)}i.delete(t),i.count===0&&(this.Qo=null)}clearAdornments(){const t=this.Qo;if(t===null)return;const i=Util.at(),e=t.iterator;for(;e.next();){const n=e.key;i.push(n)}const s=i.length;for(let n=0;n{e.isEnabled&&e.updateAdornments(i)}),t.toolManager.updateAdornments(i)}GM(t){this._o=t,t===null&&this.VR()}get layer(){return this._o}get diagram(){const t=this._o;return t==null?null:t.diagram}get layerName(){return this.ul}set layerName(t){const i=this.ul;if(i===t)return;Util.t(t,"string",Part,"layerName");let e=this.diagram;if(e!==null&&(e.findLayer(t)===null||e.partManager.addsToTemporaryLayer))return;this.ul=t,e!==null&&e.invalidateDocumentBounds(),this.i("layerName",i,t);const s=this.layer;if(s===null||s.name===t||(e=s.diagram,e===null))return;const n=e.findLayer(t);if(n===null||n===s)return;let o=s.oe(-1,this,!0);o>=0&&e.raiseChangedEvent(4,"parts",s,this,null,o,!0),o=n.$h(99999999,this,!0),s.visible!==n.visible&&this.Ki(n.visible),o>=0&&e.raiseChangedEvent(3,"parts",n,null,this,!0,o);const r=this.layerChanged;if(r===null)return;const l=e.j;e.j=!0,r(this,s,n),e.j=l}get layerChanged(){return this.E!==null?this.E.jp:null}set layerChanged(t){const i=this.layerChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"layerChanged"),this.Qi(),this.E.jp=t,this.i("layerChanged",i,t))}get zOrder(){return this.Id}set zOrder(t){const i=this.Id;if(i===t)return;Util.t(t,"number",Part,"zOrder"),this.Id=t;const e=this.layer;e!==null&&e.Nx(-1,this),this.i("zOrder",i,t);const s=this.diagram;s!==null&&s.T()}UI(){const t=this.layer;t!==null&&t.Nx(-1,this)}pb(){if(this.nh()!==!1)return;this.Z2(!0),this.ld();const t=this.diagram;t!==null&&(t.u0(this),t.requestUpdate())}ZL(){if(this.N|=2097152,this.nh()===!1)return;const t=this.position,i=this.location;(!i.isReal()||!t.isReal())&&this.$L(t,i);const e=this.Fi,s=Rect.a().c(e);e.ft(),e.x=t.x,e.y=t.y,e.w(),this.hd(s,e),Rect.o(s),this.Z2(!1)}no(t,i,e,s){const n=this.he;n.e(t,i,e,s),this.Pi===null&&(this.Pi=new Transform);const o=this.Pi;o.Vi(),this.M0(o,t,i,e,s),this.Pi=o,o.Gk()||o.Cw(n)}M0(t,i,e,s,n){if(this.rt!==1&&t.rt(this.rt),this.jt===0)return;let o=Spot.Center;this.locationSpot.isSpot()&&(o=this.locationSpot);const r=Point.a();if(this.locationObject!==this){const l=this.locationObject,h=l.naturalBounds;r.setSpot(h.x,h.y,h.width,h.height,o),l.Pi!==null&&l.Pi.Pt(r),r.offset(-l.measuredBounds.x,-l.measuredBounds.y);let a=l.panel;for(;a!==null&&a!==this;)a.Pi!==null&&a.Pi.Pt(r),r.offset(-a.measuredBounds.x,-a.measuredBounds.y),a=a.panel}else r.setSpot(i,e,s,n,o);t.ms(this.jt,r.x,r.y),Point.o(r)}get locationObject(){if(this.tr===null)if(this instanceof Adornment&&this.type!==Panel.Link&&this.hasPlaceholder())this.tr=this.placeholder;else{const t=this.locationObjectName;if(t!==""){const i=this.findObject(t);i!==null?this.tr=i:this.tr=this}else this.tr=this}return this.tr.visible?this.tr:this}get minLocation(){return this.E!==null?this.E.Wp:Point.nC}set minLocation(t){const i=this.minLocation;i.equals(t)||(Debug&&Util.s(t,Point,Part,"minLocation"),t=t.L(),this.Qi(),this.E.Wp=t,this.i("minLocation",i,t))}get maxLocation(){return this.E!==null?this.E.vp:Point.oC}set maxLocation(t){const i=this.maxLocation;i.equals(t)||(Debug&&Util.s(t,Point,Part,"maxLocation"),t=t.L(),this.Qi(),this.E.vp=t,this.i("maxLocation",i,t))}get locationObjectName(){return this.E!==null?this.E.Jp:""}set locationObjectName(t){const i=this.locationObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"locationObjectName"),this.Qi(),this.E.Jp=t,this.tr=null,this.u(),this.i("locationObjectName",i,t))}get locationSpot(){return this.E!==null?this.E.Zp:Spot.TopLeft}set locationSpot(t){const i=this.locationSpot;i.equals(t)||(Debug&&(Util.s(t,Spot,Part,"locationSpot"),t.isSpot()||Util.n("Part.locationSpot must be a specific Spot value, not: "+t)),t=t.L(),this.Qi(),this.E.Zp=t,this.u(),this.i("locationSpot",i,t))}move(t,i){i===!0?this.location=t:this.position=t}moveTo(t,i,e){const s=Point.H(t,i);this.move(s,e),Point.o(s)}isVisible(){if(!this.visible)return!1;const t=this.layer;if(t!==null){if(!t.visible)return!1;const e=t.diagram;if(e!==null&&e.animationManager.ux(this))return!0}const i=this.containingGroup;return!(i!==null&&(!i.isSubGraphExpanded||!i.isVisible()))}Ki(t){const i=this.diagram;t?(this.invalidateLayout(4),this.invalidateAdornments(),i!==null&&i.u0(this)):(this.invalidateLayout(8),this.clearAdornments()),this.gh(),i!==null&&(i.invalidateDocumentBounds(),i.T())}findObject(t){if(this.name===t)return this;let i=this.Hp;if(i===null&&(this.Hp=i=new GMap),i.get(t)!==null)return i.get(t);const e=super.findObject(t);return e!==null?(i.set(t,e),e):(i.set(t,null),null)}V0(){this.Hp=null}getRelativePoint(t,i,e){e===void 0&&(e=new Point);const s=i.isNoSpot()?Spot.Center:i,n=t.naturalBounds;if(e.e(n.width*s.x+s.offsetX,n.height*s.y+s.offsetY),t===null||t===this)return e;t.O.Pt(e);let o=t.panel;for(;o!==null&&o!==this;)o.O.Pt(e),o=o.panel;return this.Pi!==null&&this.Pi.Pt(e),e.offset(-this.he.x,-this.he.y),e}getDocumentBounds(t){return t===void 0&&(t=new Rect),t.c(this.actualBounds)}ensureBounds(){this.wt(1/0,1/0),this.qt()}PL(t){const i=this.locationSpot,e=this.locationObject;let s=e.naturalBounds;s.isReal()||(s=Rect.kw);const n=e instanceof Shape?e.strokeWidth:0;if(t.setSpot(0,0,s.width+n,s.height+n,i),e!==this){t.offset(-n/2,-n/2),e.O.Pt(t);let o=e.panel;for(;o!==null&&o!==this;)o.O.Pt(t),o=o.panel}return this.Pi!==null&&this.Pi.Pt(t),t.offset(-this.he.x,-this.he.y),t}Zh(t,i){const e=i===void 0?this.WL:i,s=this.GI(),n=s*2;if(!this.isShadowed)return e.e(t.x-1-s,t.y-1-s,t.width+2+n,t.height+2+n),e;let o=t.x,r=t.y,l=t.width,h=t.height;const a=this.shadowBlur,f=this.shadowOffset;return l+=a,h+=a,o-=a/2,r-=a/2,f.x>0?l+=f.x:(o+=f.x,l-=f.x),f.y>0?h+=f.y:(r+=f.y,h-=f.y),e.e(o-1,r-1,l+2,h+2),e}NI(){return this.type===Panel.Link&&this instanceof Adornment&&this.category==="Selection"&&this.adornedObject instanceof Shape&&this.adornedPart.findMainElement()===this.adornedObject?this.adornedObject.strokeWidth:0}GI(){return isNaN(this.qp)&&(this.qp=this.FL()),this.qp}pc(){this.qp=NaN}qt(){if(this.rs()===!1){this.ZL();return}this.oo(!1);const t=this.Fi,i=Rect.a();i.c(t);const e=this.Tl();this.dh(0,0,this.he.width,this.he.height);const s=this.position;this.$L(s,this.location),t.ft(),t.x=s.x,t.y=s.y,t.w(),this.hd(i,t),i.equals(t)?this.Us(e):this.Ae()&&(!Geo.p(i.width,t.width)||!Geo.p(i.height,t.height))&&this.qM>=0&&this.invalidateLayout(16),Rect.o(i),this.Z2(!1)}hd(t,i){const e=this.diagram;if(e===null)return;let s=!1;if(e.ia===!1&&t.isReal()){const n=Rect.a();n.c(e.documentBounds),n.subtractMargin(e.padding),t.x>n.x&&t.y>n.y&&t.rightn.x&&i.y>n.y&&i.right=o)return}}this.N=this.N^4096;let s=!1;if(e!==null){s=e.skipsUndoManager,e.skipsUndoManager=!0;const o=e.selection;o.ft(),t?o.add(this):o.delete(this),o.w()}this.i("isSelected",i,t),this.invalidateAdornments();const n=this.selectionChanged;n!==null&&n(this),e!==null&&(e.requestUpdate(),e.skipsUndoManager=s)}}get isHighlighted(){return(this.N&524288)!==0}set isHighlighted(t){const i=(this.N&524288)!==0;if(i!==t){Debug&&Util.t(t,"boolean",Part,"isHighlighted"),this.N=this.N^524288;const e=this.diagram;if(e!==null){const n=e.highlighteds;n.ft(),t?n.add(this):n.delete(this),n.w()}this.i("isHighlighted",i,t),this.T();const s=this.highlightedChanged;s!==null&&s(this)}}get isShadowed(){return(this.N&8192)!==0}set isShadowed(t){const i=(this.N&8192)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Part,"isShadowed"),this.N=this.N^8192,this.hs(!0),this.i("isShadowed",i,t),this.T())}vL(){return(this.N&16384)!==0}JL(t){t?this.N|=16384:this.N&=-16385}nh(){return(this.N&32768)!==0}Z2(t){t?this.N|=32768:this.N&=-32769}HI(){return(this.N&65536)!==0}d2(t){t?this.N|=65536:this.N&=-65537}Tl(){return(this.N&131072)!==0}Us(t){t?this.N|=131072:this.N&=-131073}eT(){return(this.N&1048576)!==0}yb(t){t?this.N|=1048576:this.N&=-1048577}get isAnimated(){return(this.N&262144)!==0}set isAnimated(t){const i=(this.N&262144)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Part,"isAnimated"),this.N=this.N^262144,this.i("isAnimated",i,t))}get highlightedChanged(){return this.E!==null?this.E.$p:null}set highlightedChanged(t){const i=this.highlightedChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"highlightedChanged"),this.Qi(),this.E.$p=t,this.i("highlightedChanged",i,t))}get selectionObjectName(){return this.E!==null?this.E.Qp:""}set selectionObjectName(t){const i=this.selectionObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"selectionObjectName"),this.Qi(),this.E.Qp=t,this.dl=null,this.i("selectionObjectName",i,t))}get selectionAdornmentTemplate(){return this.E!==null?this.E._p:null}set selectionAdornmentTemplate(t){const i=this.selectionAdornmentTemplate;i!==t&&(Debug&&Util.s(t,Adornment,Part,"selectionAdornmentTemplate"),this.Qi(),this.E._p=t,this.i("selectionAdornmentTemplate",i,t))}get selectionObject(){if(this.dl===null){const t=this.selectionObjectName;if(t!==null&&t!==""){const i=this.findObject(t);i!==null?this.dl=i:this.dl=this}else if(this instanceof Link){const i=this.path;i!==null?this.dl=i:this.dl=this}else this.dl=this}return this.dl}get selectionChanged(){return this.E!==null?this.E.ty:null}set selectionChanged(t){const i=this.selectionChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"selectionChanged"),this.Qi(),this.E.ty=t,this.i("selectionChanged",i,t))}get resizeAdornmentTemplate(){return this.E!==null?this.E.iy:null}set resizeAdornmentTemplate(t){const i=this.resizeAdornmentTemplate;i!==t&&(Debug&&Util.s(t,Adornment,Part,"resizeAdornmentTemplate"),this.Qi(),this.E.iy=t,this.i("resizeAdornmentTemplate",i,t))}get resizeObjectName(){return this.E!==null?this.E.ey:""}set resizeObjectName(t){const i=this.resizeObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"resizeObjectName"),this.Qi(),this.E.ey=t,this.i("resizeObjectName",i,t))}get resizeObject(){const t=this.resizeObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get resizeCellSize(){return this.E!==null?this.E.sy:Size.xw}set resizeCellSize(t){const i=this.resizeCellSize;i.equals(t)||(Debug&&Util.s(t,Size,Part,"resizeCellSize"),t=t.L(),this.Qi(),this.E.sy=t,this.i("resizeCellSize",i,t))}get rotateAdornmentTemplate(){return this.E!==null?this.E.ny:null}set rotateAdornmentTemplate(t){const i=this.rotateAdornmentTemplate;i!==t&&(Debug&&Util.s(t,Adornment,Part,"rotateAdornmentTemplate"),this.Qi(),this.E.ny=t,this.i("rotateAdornmentTemplate",i,t))}get rotateObjectName(){return this.E!==null?this.E.oy:""}set rotateObjectName(t){const i=this.rotateObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"rotateObjectName"),this.Qi(),this.E.oy=t,this.i("rotateObjectName",i,t))}get rotateObject(){const t=this.rotateObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get rotationSpot(){return this.E!==null?this.E.ry:Spot.Default}set rotationSpot(t){const i=this.rotationSpot;i.equals(t)||(Debug&&(Util.s(t,Spot,Part,"rotationSpot"),t!==Spot.Default&&!t.isSpot()&&Util.n("Part.rotationSpot must be a specific Spot value or Spot.Default, not: "+t)),t=t.L(),this.Qi(),this.E.ry=t,this.i("rotationSpot",i,t))}get text(){return this.ui}set text(t){const i=this.ui;i!==t&&(Debug&&Util.t(t,"string",Part,"text"),this.ui=t,this.i("text",i,t))}get containingGroup(){return this.bh}set containingGroup(t){if(this.Ae()){const i=this.bh;if(i!==t){Debug&&t!==null&&Util.s(t,Group,Part,"containingGroup"),t!==null&&(this===t||t.isMemberOf(this))&&(this===t&&Util.n("Cannot make a Group a member of itself: "+this.toString()),Util.n("Cannot make a Group indirectly contain itself: "+this.toString()+" already contains "+t.toString())),this.invalidateLayout(2);const e=this.diagram;if(i!==null?i.Q2(this):this instanceof Group&&e!==null&&e.vr.delete(this),this.bh=t,t!==null?t._2(this):this instanceof Group&&e!==null&&e.vr.add(this),this.invalidateLayout(1),e!==null&&e.j){const n=this.data,o=e.model;if(n!==null&&o.ga()){const r=t!==null?t.data:null;o.setGroupForData(n,o.getKeyForNodeData(r))}}const s=this.containingGroupChanged;if(s!==null){let n=!0;e!==null&&(n=e.j,e.j=!0),s(this,i,t),e!==null&&(e.j=n)}if(this instanceof Group){const n=new GSet;Part.lh(n,this,!0,0,!0);const o=n.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=r.linksConnected;for(;l.next();)l.value.Od()}}}if(this instanceof Node){const n=this.linksConnected;for(;n.next();)n.value.Od();const o=this.labeledLink;o!==null&&o.Od()}this.i("containingGroup",i,t),t!==null&&t.UI()}}else Util.n("cannot set the Part.containingGroup of a Link or Adornment")}gh(){const t=this.containingGroup;t!==null&&(t.hasPlaceholder()&&t.placeholder.u(),t.u(),t.invalidateConnectedLinks())}T(){const t=this.diagram;t!==null&&!this.rs()&&!this.nh()&&this.isVisible()&&this.Fi.isReal()&&t.T(this.Zh(this.Fi))}u(){if(this.Xo())return;super.u();const t=this.diagram;t!==null&&(t.u0(this),this instanceof Node&&this.labeledLink!==null&&this.labeledLink.hc(),t.requestUpdate(!0))}hc(t){if(this.rs())return;const i=this.diagram;i!==null&&(i.u0(this),this instanceof Node&&this.invalidateConnectedLinks(),i.requestUpdate()),this.oo(!0)}Gm(t){if(!t){const i=this.bh;i!==null&&i._2(this)}}Hm(t){if(!t){const i=this.bh;i!==null&&i.Q2(this)}}Zf(){const t=this.data;if(t!==null){const i=this.diagram;if(i!==null){const e=i.model;e!==null&&e.removeNodeData(t)}}}get containingGroupChanged(){return this.E!==null?this.E.ly:null}set containingGroupChanged(t){const i=this.containingGroupChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"containingGroupChanged"),this.Qi(),this.E.ly=t,this.i("containingGroupChanged",i,t))}findSubGraphLevel(){return this.tN(this)}tN(t){const i=t.containingGroup;if(i!==null)return 1+this.tN(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.tN(e)}return 0}findTopLevelPart(){return this.iN(this)}iN(t){const i=t.containingGroup;if(i!==null)return this.iN(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.iN(e)}return t}get isTopLevel(){return!(this.containingGroup!==null||this instanceof Node&&this.labeledLink!==null)}isMemberOf(t){return t instanceof Group?this.eN(this,t):!1}eN(t,i){if(t===i||i===null)return!1;const e=t.containingGroup;if(e!==null&&(e===i||this.eN(e,i)))return!0;if(t instanceof Node){const s=t.labeledLink;if(s!==null)return this.eN(s,i)}return!1}findCommonContainingGroup(t){if(t===null)return null;if(Debug&&Util.s(t,Part,Part,"findCommonContainingGroup:other"),this===t)return this.containingGroup;let i=this;for(;i!==null;){if(i instanceof Group&&i.yb(!0),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}let e=null;for(i=t;i!==null;){if(i.eT()){e=i;break}if(i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}for(i=this;i!==null;){if(i instanceof Group&&i.yb(!1),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}return e}get layoutConditions(){return this.E!==null?this.E.hy:127}set layoutConditions(t){const i=this.layoutConditions;i!==t&&(Debug&&Util.t(t,"number",Part,"layoutConditions"),this.Qi(),this.E.hy=t,this.i("layoutConditions",i,t))}canLayout(){if(!this.isLayoutPositioned||!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary||this instanceof Node&&this.isLinkLabel)}jI(t){if(!this.isLayoutPositioned||!(t&this.layoutConditions))return!1;const i=this.layer;if(i!==null&&i.isTemporary||this instanceof Node&&this.isLinkLabel)return!1;const e=this.diagram;return!(e!==null&&e.undoManager.isUndoingRedoing)}invalidateLayout(t){if(t===void 0&&(t=16777215),!this.jI(t))return;const i=this.bh;if(i!==null){const e=i.layout;e!==null?e.invalidateLayout():i.invalidateLayout(t)}else{const e=this.diagram;if(e!==null){const s=e.layout;s!==null&&s.invalidateLayout()}}}RA(){if(!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary)}static lh(t,i,e,s,n,o){if(o===void 0&&(o=null),!t.has(i)&&!(o!==null&&!o(i))&&!(i instanceof Adornment)){if(t.add(i),i instanceof Node){if(e&&i instanceof Group){const r=i.memberParts;for(;r.next();){const l=r.value;Part.lh(t,l,e,s,n,o)}}if(n!==!1){const r=i.linksConnected;for(;r.next();){const l=r.value;if(t.has(l))continue;const h=l.fromNode,a=l.toNode,f=h===null||t.has(h),c=a===null||t.has(a);(n?f&&c:f||c)&&Part.lh(t,l,e,s,n,o)}}if(s>1){const r=i.findTreeChildrenNodes();for(;r.next();){const l=r.value;Part.lh(t,l,e,s-1,n,o)}}}else if(i instanceof Link){const r=i.labelNodes;for(;r.next();){const l=r.value;Part.lh(t,l,e,s,n,o)}}}}get dragComputation(){return this.E!==null?this.E.ay:null}set dragComputation(t){const i=this.dragComputation;i!==t&&(t!==null&&Util.t(t,"function",Part,"dragComputation"),this.Qi(),this.E.ay=t,this.i("dragComputation",i,t))}get shadowOffset(){return this.E!==null?this.E.fy:Point.rC}set shadowOffset(t){const i=this.shadowOffset;i.equals(t)||(Debug&&Util.s(t,Point,Part,"shadowOffset"),t=t.L(),this.Qi(),this.E.fy=t,this.T(),this.i("shadowOffset",i,t))}get shadowColor(){return this.E!==null?this.E.cy:"gray"}set shadowColor(t){const i=this.shadowColor;i!==t&&(Debug&&Util.t(t,"string",Part,"shadowColor"),this.Qi(),this.E.cy=t,this.T(),this.i("shadowColor",i,t))}get shadowBlur(){return this.E!==null?this.E.Pn:4}set shadowBlur(t){const i=this.shadowBlur;i!==t&&(Debug&&Util.t(t,"number",Part,"shadowBlur"),this.Qi(),this.E.Pn=t,this.T(),this.i("shadowBlur",i,t))}}class PartTemplateSettings{wi;jp;ly;_p;Qp;ty;$p;iy;ey;sy;ny;oy;ry;Jp;Zp;Wp;vp;ay;hy;fy;cy;Pn;constructor(){this.wi=!1,this.jp=null,this.ly=null,this._p=null,this.Qp="",this.ty=null,this.$p=null,this.iy=null,this.ey="",this.sy=Size.xw,this.ny=null,this.oy="",this.ry=Spot.Default,this.Jp="",this.Zp=Spot.TopLeft,this.Wp=Point.nC,this.vp=Point.oC,this.ay=null,this.hy=127,this.fy=Point.rC,this.cy="gray",this.Pn=4}copy(){const t=new PartTemplateSettings;return t.jp=this.jp,t.ly=this.ly,t._p=this._p,t.Qp=this.Qp,t.ty=this.ty,t.$p=this.$p,t.iy=this.iy,t.ey=this.ey,t.sy=this.sy.L(),t.ny=this.ny,t.oy=this.oy,t.ry=this.ry.L(),t.Jp=this.Jp,t.Zp=this.Zp.L(),t.Wp=this.Wp.L(),t.vp=this.vp.L(),t.ay=this.ay,t.hy=this.hy,t.fy=this.fy.L(),t.cy=this.cy,t.Pn=this.Pn,t}}class Adornment extends Part{ys;Et;sM;nM;gc;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.N&=-257,this.ul="Adornment",this.ys=null,this.sM=0,this.nM=!1,this.Et=null,this.gc=null,i&&Object.assign(this,i)}toString(){const t=this.adornedPart;return"Adornment("+this.category+")"+(t!==null?t.toString():"")}updateRelationshipsFromData(){}md(t){const i=this.adornedObject,e=i?.part;if(!(e instanceof Link)||!(i instanceof Shape))return;const s=e.path;let n=s.geometry;e.md(t),n=s.geometry;const o=this.D.h,r=o.length;for(let l=0;lh instanceof Placeholder);l instanceof Placeholder&&(this.Et===null?this.Et=l:Debug&&this.Et!==l&&Util.n("Cannot insert a second Placeholder into the visual tree of an Adornment."))}}else t===4&&i==="elements"&&this.Et!==null&&(s===this.Et?this.Et=null:s instanceof Panel&&this.Et.isContainedBy(s)&&(this.Et=null));super.ec(t,i,e,s,n,o,r)}updateAdornments(){}Zf(){}}var PortSpreading=(w=>(w[w.None=0]="None",w[w.Evenly=1]="Evenly",w[w.Packed=2]="Packed",w))(PortSpreading||{});class Node extends Part{z;bt;Ac;gl;kh;ae;ni;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.z=13,this.bt=null,this.ni=new List,this.Ac=null,this.gl=null,this.ae=null,this.kh=!1,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.z=this.z,this.bt!==null&&(this.bt.wi?t.bt=this.bt:t.bt=this.bt.copy())}Ho(t){super.Ho(t),t.invalidateConnectedLinks(),t.gl=this.gl,t.ae=null}static SpreadingNone=0;static SpreadingEvenly=1;static SpreadingPacked=2;ml(){this.bt===null?this.bt=new NodeTemplateSettings:this.bt.wi&&(this.bt=this.bt.copy())}ch(){super.ch(),this.bt!==null&&(this.bt.wi=!0)}sT(t){t!==null&&(this.gl===null&&(this.gl=new GSet),this.gl.add(t))}nT(t){t!==null&&this.gl!==null&&this.gl.delete(t)}oT(t,i,e){if(t===null||this.gl===null)return null;const s=this.gl.iterator;for(;s.next();){const n=s.value;if(n.uy===this&&n.wb===t&&n.sN===i&&n.nN===e||n.uy===t&&n.wb===this&&n.sN===e&&n.nN===i)return n}return null}invalidateLinkBundle(t,i,e){i==null&&(i=""),e==null&&(e="");const s=this.oT(t,i,e);s!==null&&s.Ed()}ec(t,i,e,s,n,o,r){t===3&&i==="elements"?this.ae=null:t===4&&i==="elements"&&(this.ae=null),super.ec(t,i,e,s,n,o,r)}invalidateConnectedLinks(t){const i=this.linksConnected;for(;i.next();){const e=i.value;t!==void 0&&t.has(e)||(this._i(e.fromPort),this._i(e.toPort),e.invalidateRoute())}}hL(t){const i=this.linksConnected;for(;i.next();){const e=i.value;e.fromPort!==t&&e.toPort!==t||(this._i(e.fromPort),this._i(e.toPort),e.invalidateRoute())}}_i(t){if(t===null)return;const i=t.sd;i!==null&&i.Ed();const e=t.part,s=e.containingGroup;s!==null&&!e.isVisible()&&s._i(s.port)}$r(){return!0}get portSpreading(){return this.bt!==null?this.bt.gy:1}set portSpreading(t){const i=this.portSpreading;if(i!==t){Debug&&t!==0&&t!==1&&t!==2&&Util.n("Node.portSpreading can only be set to PortSpreading.None, PortSpreading.Evenly, or PortSpreading.Packed, not: "+t),this.ml(),this.bt.gy=t,this.i("portSpreading",i,t);const e=this.diagram;if(e!==null&&e.undoManager.isUndoingRedoing)return;this.invalidateConnectedLinks()}}get avoidable(){return(this.z&8)!==0}set avoidable(t){const i=(this.z&8)!==0;if(i!==t){Debug&&Util.t(t,"boolean",Node,"avoidable"),this.z=this.z^8;const e=this.diagram;e!==null&&e.HP(this),this.i("avoidable",i,t)}}get avoidableMargin(){return this.bt!==null?this.bt.my:Margin.uC}set avoidableMargin(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Node,"avoidableMargin");const i=this.avoidableMargin;if(!i.equals(t)){t=t.L(),this.ml(),this.bt.my=t;const e=this.diagram;e!==null&&e.HP(this),this.i("avoidableMargin",i,t)}}canAvoid(){return this.avoidable&&!this.isLinkLabel}getAvoidableRect(t){return t.set(this.actualBounds),t.addMargin(this.avoidableMargin),t}findVisibleNode(){let t=this;for(;t!==null&&!t.isVisible();)t=t.containingGroup;return t}isVisible(){if(!super.isVisible())return!1;let t=!0,i=1;const e=this.diagram;if(e!==null){if(e.animationManager.ux(this))return!0;t=e.isTreePathToChildren,i=e.treeCollapsePolicy}if(i===1){const n=this.findTreeParentNode();if(n!==null&&!n.isTreeExpanded)return!1}else if(i===2){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&h.isTreeExpanded){r=!0;break}}}if(o&&!r)return!1}else if(i===3){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&!h.isTreeExpanded){r=!0;break}}}if(o&&r)return!1}const s=this.labeledLink;return s!==null?s.isVisible():!0}Ki(t){super.Ki(t);const i=this.linksConnected;for(;i.next();){const e=i.value;if(t&&this.containingGroup!==null){const s=e.getOtherNode(this);s!==null&&!s.isMemberOf(this.containingGroup)&&e.invalidateRoute()}e.Ki(t)}}get linksConnected(){return this.ni.iterator}findExternalTreeLinksConnected(){const t=new GSet,i=new GSet;return this.rT(this,t,i),i.iterator}rT(t,i,e){if(t===null||i.has(t))return;i.add(t);let s=!0;const n=this.diagram;n!==null&&(s=n.isTreePathToChildren),t.linksConnected.each(o=>{o.isTreeLink?(s?o.fromNode===t:o.toNode===t)&&this.rT(s?o.toNode:o.fromNode,i,e):e.add(o)})}findLinksConnected(t){if(t===void 0&&(t=null),t===null)return this.ni.iterator;Debug&&Util.t(t,"string",Node,"findLinksConnected:pid");const i=new ListIterator(this.ni),e=this;return i.predicate=s=>s.fromNode===e&&s.fromPortId===t||s.toNode===e&&s.toPortId===t,i}findLinksOutOf(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findLinksOutOf:pid");const i=new ListIterator(this.ni),e=this;return i.predicate=s=>s.fromNode!==e?!1:t===null?!0:s.fromPortId===t,i}findLinksInto(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findLinksInto:pid");const i=new ListIterator(this.ni),e=this;return i.predicate=s=>s.toNode!==e?!1:t===null?!0:s.toPortId===t,i}findNodesConnected(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findNodesConnected:pid");let i=null,e=null;const s=this.ni.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this){if(t===null||n.fromPortId===t){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}else if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesOutOf(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findNodesOutOf:pid");let i=null,e=null;const s=this.ni.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this&&(t===null||n.fromPortId===t)){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesInto(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findNodesInto:pid");let i=null,e=null;const s=this.ni.iterator;for(;s.next();){const n=s.value;if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findLinksBetween(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),Debug&&(Util.s(t,Node,Node,"findLinksBetween:othernode"),i!==null&&Util.t(i,"string",Node,"findLinksBetween:pid"),e!==null&&Util.t(e,"string",Node,"findLinksBetween:otherpid"));const s=new ListIterator(this.ni),n=this;return s.predicate=o=>o.fromNode===n&&o.toNode===t&&(i===null||o.fromPortId===i)&&(e===null||o.toPortId===e)||o.fromNode===t&&o.toNode===n&&(e===null||o.fromPortId===e)&&(i===null||o.toPortId===i),s}findLinksTo(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),Debug&&(Util.s(t,Node,Node,"findLinksTo:othernode"),i!==null&&Util.t(i,"string",Node,"findLinksTo:pid"),e!==null&&Util.t(e,"string",Node,"findLinksTo:otherpid"));const s=new ListIterator(this.ni),n=this;return s.predicate=o=>!(o.fromNode!==n||o.toNode!==t||i!==null&&o.fromPortId!==i||e!==null&&o.toPortId!==e),s}get linkConnected(){return this.bt!==null?this.bt.py:null}set linkConnected(t){const i=this.linkConnected;i!==t&&(t!==null&&Util.t(t,"function",Node,"linkConnected"),this.ml(),this.bt.py=t,this.i("linkConnected",i,t))}get linkDisconnected(){return this.bt!==null?this.bt.yy:null}set linkDisconnected(t){const i=this.linkDisconnected;i!==t&&(t!==null&&Util.t(t,"function",Node,"linkDisconnected"),this.ml(),this.bt.yy=t,this.i("linkDisconnected",i,t))}get linkValidation(){return this.bt!==null?this.bt.Ll:null}set linkValidation(t){const i=this.linkValidation;i!==t&&(t!==null&&Util.t(t,"function",Node,"linkValidation"),this.ml(),this.bt.Ll=t,this.i("linkValidation",i,t))}xb(t,i){this._i(i);const e=this.ni.has(t);if(e||this.ni.add(t),!e||t.fromNode===t.toNode){const s=this.linkConnected;if(s!==null){let n=!0;const o=this.diagram;o!==null&&(n=o.j,o.j=!0),s(this,t,i),o!==null&&(o.j=n)}}if(!e){if(!t.isTreeLink)return;const s=t.fromNode,n=t.toNode;if(s!==null&&n!==null&&s!==n){let o=!0;const r=this.diagram;r!==null&&(o=r.isTreePathToChildren);const l=o?n:s,h=o?s:n;if(l.kh||(l.kh=h),h.isTreeLeaf){if(r!==null&&r.undoManager.isUndoingRedoing)return;o?s===h&&(h.isTreeLeaf=!1):n===h&&(h.isTreeLeaf=!1)}}}}bb(t,i){this._i(i);const e=this.ni.delete(t);let s=null;if(e||t.toNode===t.fromNode){const n=this.linkDisconnected;if(s=this.diagram,n!==null){let o=!0;s!==null&&(o=s.j,s.j=!0),n(this,t,i),s!==null&&(s.j=o)}}if(e){if(!t.isTreeLink)return;let n=!0;s!==null&&(n=s.isTreePathToChildren);const o=n?t.toNode:t.fromNode,r=n?t.fromNode:t.toNode;if(o!==null&&(o.kh=!1),r!==null&&!r.isTreeLeaf)if(r.ni.count===0){if(r.kh=null,s!==null&&s.undoManager.isUndoingRedoing)return;r.isTreeLeaf=!0}else r.w0()}}w0(){if(this.kh=!1,this.ni.count===0)return;let t=!0;const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;i!==null&&(t=i.isTreePathToChildren);const e=this.ni.iterator;for(;e.next();){const s=e.value;if(s.isTreeLink){if(t){if(s.fromNode===this){this.isTreeLeaf=!1;return}}else if(s.toNode===this){this.isTreeLeaf=!1;return}}}this.isTreeLeaf=!0}updateRelationshipsFromData(){const t=this.diagram;t!==null&&t.partManager.updateRelationshipsFromData(this)}Gm(t){if(super.Gm(t),!t){this.w0();const i=this.Ac;i!==null&&i.lT(this)}}Hm(t){if(super.Hm(t),!t){const i=this.Ac;i!==null&&i.hT(this)}}Zf(){if(this.ni.count>0){const t=this.diagram;if(t!==null){const i=t.commandHandler!==null?t.commandHandler.deletesConnectedLinks:!0,s=this.ni.copy().iterator;for(;s.next();){const n=s.value;i?t.remove(n):(n.fromNode===this&&(n.fromNode=null),n.toNode===this&&(n.toNode=null))}}}this.labeledLink=null,super.Zf()}get isLinkLabel(){return this.Ac!==null}get labeledLink(){return this.Ac}set labeledLink(t){const i=this.Ac;if(i!==t){Debug&&t!==null&&Util.s(t,Link,Node,"labeledLink");const e=this.diagram,s=this.data;if(i!==null){if(i.hT(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=i.data,o=e.model;if(n!==null&&o.Ea()){const r=o.getKeyForNodeData(s);r!==void 0&&o.removeLabelKeyForLinkData(n,r)}}this.containingGroup=null}if(this.Ac=t,t!==null){if(t.lT(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=t.data,o=e.model;if(n!==null&&o.Ea()){const r=o.getKeyForNodeData(s);r!==void 0&&o.addLabelKeyForLinkData(n,r)}}this.containingGroup=t.containingGroup}this.hc(),this.i("labeledLink",i,t)}}findVisiblePort(t){let i=t;for(;i!==null&&(!i.actualBounds.isReal()||!i.isVisibleObject());)i=i.panel;return i===null?this.port:i}findPort(t){if(Debug&&Util.t(t,"string",Node,"findPort:pid"),this.ae===null){if(t===""&&this.Mn===!1)return this;this.aT()}let i=this.ae.get(t);return i!==null||t!==""&&(i=this.ae.get(""),i!==null)?i:this}get port(){return this.findPort("")}get ports(){return this.ae===null&&this.aT(),this.ae.iteratorValues}aT(){this.ae===null?this.ae=new GMap:this.ae.clear(),this.walkVisualTreeFrom(this,(t,i)=>t.pL(i)),this.ae.count===0&&this.ae.set("",this)}pL(t){const i=t.portId;i!==null&&this.ae!==null&&this.ae.set(i,t)}S2(t,i){const e=t.portId;if(e!==null){this.ae!==null&&this.ae.delete(e);const s=this.diagram;if(s!==null&&i){let n=null;const o=this.findLinksConnected(e);for(;o.next();){const r=o.value;n===null&&(n=Util.at()),n.push(r)}if(n!==null){for(let r=0;r!(!n.isTreeLink||n.fromNode!==s):e.predicate=n=>!(!n.isTreeLink||n.toNode!==s),e}findTreeChildrenNodes(){let t=!0;const i=this.diagram;i!==null&&(t=i.isTreePathToChildren);let e=null,s=null;const n=this.ni.iterator;if(t)for(;n.next();){const o=n.value;if(o.isTreeLink&&o.fromNode===this){const r=o.toNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}else for(;n.next();){const o=n.value;if(o.isTreeLink&&o.toNode===this){const r=o.fromNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}return e!==null?e.iterator:s!==null?new SingletonIterator(s):EmptyIterator.instance}findTreeParts(t){t===void 0&&(t=1/0),Util.t(t,"number",Node,"findTreeParts:level");const i=new GSet;return Part.lh(i,this,!1,t,!0),i}collapseTree(t){t===void 0&&(t=1),Util.r(t,Node,"collapseTree:level"),t<1&&(t=1);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.fT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}fT(t,i,e,s,n,o){if(e>1){const r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);h!==null&&h!==this&&!t.has(h)&&(t.add(h),h.fT(t,i,e-1,s,n,o))}}else this.cT(t,i,s,n,o)}cT(t,i,e,s,n){const o=s===this?!0:this.isTreeExpanded,r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);if(h!==null&&h!==this){const a=t.has(h);if(a||t.add(h),o){const f=i?h.findNodesInto():h.findNodesOutOf(),c=this;f.all(u=>u===c||!u.isTreeExpanded)&&e.Ef(h,s),h.gh(),h.Ki(!1)}h.isTreeExpanded&&(h.wasTreeExpanded=h.isTreeExpanded,a||h.cT(t,i,e,s,n))}}this.isTreeExpanded=!1}expandTree(t){t===void 0&&(t=2),Util.r(t,Node,"expandTree:level"),t<2&&(t=2);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.uT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}uT(t,i,e,s,n,o){const r=n===this?!1:this.isTreeExpanded,l=i?this.findLinksOutOf():this.findLinksInto();for(;l.next();){const h=l.value;if(!h.isTreeLink)continue;r||h.Te||h.invalidateRoute();const a=h.getOtherNode(this);if(a!==null&&a!==this&&!t.has(a)){if(t.add(a),!r){a.Ki(!0),a.gh();const f=i?a.findNodesInto():a.findNodesOutOf(),c=this;f.all(u=>u===c||!u.isTreeExpanded)&&s.Of(a,n)}(e>2||a.wasTreeExpanded)&&(a.wasTreeExpanded=!1,a.uT(t,i,e-1,s,n,o))}}this.isTreeExpanded=!0}get isTreeExpanded(){return(this.z&1)!==0}set isTreeExpanded(t){const i=(this.z&1)!==0;if(i!==t){Debug&&Util.t(t,"boolean",Node,"isTreeExpanded"),this.z=this.z^1;const e=this.diagram;this.i("isTreeExpanded",i,t);const s=this.treeExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.j,e.j=!0),s(this),e!==null&&(e.j=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.Ki(t);return}t?this.expandTree():this.collapseTree()}}get wasTreeExpanded(){return(this.z&2)!==0}set wasTreeExpanded(t){const i=(this.z&2)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Node,"wasTreeExpanded"),this.z=this.z^2,this.i("wasTreeExpanded",i,t))}get treeExpandedChanged(){return this.bt!==null?this.bt.wy:null}set treeExpandedChanged(t){const i=this.treeExpandedChanged;i!==t&&(t!==null&&Util.t(t,"function",Node,"treeExpandedChanged"),this.ml(),this.bt.wy=t,this.i("treeExpandedChanged",i,t))}get isTreeLeaf(){return(this.z&4)!==0}set isTreeLeaf(t){const i=(this.z&4)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Node,"isTreeLeaf"),this.z=this.z^4,this.i("isTreeLeaf",i,t))}get isTreeRoot(){return this.findTreeParentLink()===null}}class NodeTemplateSettings{wi;py;yy;Ll;wy;my;gy;xy;by;rh;ky;constructor(){this.wi=!1,this.py=null,this.yy=null,this.Ll=null,this.wy=null,this.my=Margin.uC,this.gy=1,this.xy=null,this.by=null,this.rh=null,this.ky=null}copy(){const t=new NodeTemplateSettings;return t.py=this.py,t.yy=this.yy,t.Ll=this.Ll,t.wy=this.wy,t.my=this.my.L(),t.gy=this.gy,t.xy=this.xy,t.by=this.by,t.rh=this.rh,t.ky=this.ky,t}}var LinkAdjusting=(w=>(w[w.None=0]="None",w[w.End=17]="End",w[w.Scale=18]="Scale",w[w.Stretch=19]="Stretch",w))(LinkAdjusting||{}),Routing=(w=>(w[w.Normal=1]="Normal",w[w.Orthogonal=2]="Orthogonal",w[w.AvoidsNodes=6]="AvoidsNodes",w[w.AvoidsNodesStraight=7]="AvoidsNodesStraight",w))(Routing||{}),Curve=(w=>(w[w.None=0]="None",w[w.Bezier=9]="Bezier",w[w.JumpGap=10]="JumpGap",w[w.JumpOver=11]="JumpOver",w))(Curve||{});class Link extends Part{Dt;go;mo;Bd;po;yo;Vd;Lc;zd;Xd;Yd;Ba;Kd;$s;Ni;Ie;Lr;Tc;ir;oN;rN;kb;lN;hN;Sy;Sb;mt;er;static Va=null;static za=null;gc;aN;fN;constructor(t){super(Panel.Link),this.Dt=8,this.go=null,this.mo="",this.Bd=null,this.po=null,this.yo="",this.Vd=null,this.Lc=0,this.zd=0,this.Xd=0,this.Yd=NaN,this.Ba=1,this.Kd=.5,this.$s=null,this.Ni=new List().w(),this.Ie=null,this.Lr=null,this.Tc=new Rect,this.mt=new Geometry,this.ir=null,this.er=null,this.oN=null,this.rN=null,this.aN=0,this.fN=0,this.kb=new Point,this.lN=null,this.hN=null,this.Sy=null,this.Sb=NaN,this.Z=null,this.gc=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Dt=this.Dt&-113,t.mo=this.mo,t.Bd=this.Bd,t.yo=this.yo,t.Vd=this.Vd,t.Lc=this.Lc,t.zd=this.zd,t.Xd=this.Xd,t.Yd=this.Yd,t.Ba=this.Ba,t.Kd=this.Kd,this.Z!==null&&(t.Z=this.Z.copy())}Ho(t){super.Ho(t),this.mo=t.mo,this.yo=t.yo,t.Ie=null,t.invalidateRoute(),t.er=this.er;const i=t.fromPort;i!==null&&t.fromNode._i(i);const e=t.toPort;e!==null&&t.toNode._i(e)}fi(t){t in Routing||t in Curve||t in LinkAdjusting?Link.cN(t)?this.routing=t:t===9||t===10||t===11?this.curve=t:t===17||t===18||t===19?this.adjusting=t:t===1||t===0||Util.n("Unknown Link enum value for a Link property: "+t):super.fi(t)}static Normal=1;static Orthogonal=2;static AvoidsNodes=6;static AvoidsNodesStraight=7;static None=0;static Bezier=9;static JumpGap=10;static JumpOver=11;static End=17;static Scale=18;static Stretch=19;static OrientAlong=21;static OrientPlus90=22;static OrientMinus90=23;static OrientOpposite=24;static OrientUpright=25;static OrientPlus90Upright=26;static OrientMinus90Upright=27;static OrientUpright45=28;static vI=8;static JI=16;static ZI=14;static Xa=8;je(){this.Z===null&&(this.Z=new LinkSettings)}oI(t,i,e){const s=t.segmentIndex,n=t.segmentFraction;let o=t.alignmentFocus;const r=t.segmentOrientation,l=t.segmentOffset;let h=0,a=0,f=0,c=0;if(isNaN(s)){const C=this.mt,P=Util.at();C.getPointAndAngleAlongPath(n,P);const N=Point.H(P[0],P[1]);if(N.add(this.getPoint(0)),C.type===1)N.offset(-C.startX,-C.startY);else{const T=C.figures.first();N.offset(-T.startX,-T.startY)}c=P[2],r!==0&&(f=this.computeAngle(t,r,c),t.angle=f),h=N.x,a=N.y,Point.o(N),Util.nt(P)}else if(s<-i||s>=i){const C=Point.a();this.ML(C),c=this.midAngle,r!==0&&(f=this.computeAngle(t,r,c),t.angle=f),h=C.x,a=C.y,Point.o(C)}else{let C,P,N=0;if(s>=0?(C=e.h[s],P=s0?e.h[N-1]:C),C.equalsApprox(P)){let T,L;s>=0?(T=s>0?e.h[s-1]:C,L=s1?e.h[N-2]:P);const D=T.distanceSquaredPoint(C),F=P.distanceSquaredPoint(L);D>F+10?c=s>=0?T.directionPoint(C):C.directionPoint(T):F>D+10?c=s>=0?P.directionPoint(L):L.directionPoint(P):c=s>=0?T.directionPoint(L):L.directionPoint(T)}else c=s>=0?C.directionPoint(P):P.directionPoint(C);r!==0&&(f=this.computeAngle(t,r,c),t.angle=f),h=C.x+(P.x-C.x)*n,a=C.y+(P.y-C.y)*n}if(o.isNone()){t.location=new Point(h,a);return}else o.isNoSpot()&&(o=Spot.Center);const u=Transform.a();u.Vi(),u.rt(t.scale,t.scale),u.ms(t.angle,0,0);const d=t.naturalBounds,m=Rect.H(0,0,d.width,d.height),g=Point.a();g.setRectSpot(m,o),u.Pt(g);let p=-g.x,y=-g.y;const x=d.width,k=d.height,b=Point.a();b.c(l);const S=isNaN(l.x),M=isNaN(l.y);if(S||M){const C=x/2+3,P=k/2+3,N=c>=45&&c<=135,T=c>=225&&c<=315;r===0&&(N||T)?(b.x=M?C:l.y,b.y=S?P:l.x,N?s>=0||isNaN(s)&&n<.5||S&&(b.y=-P):T&&((s>=0||isNaN(s)&&n<.5)&&S&&(b.y=-P),M&&(b.x=-C))):(S&&(s>=0||isNaN(s)&&n<.5?b.x=C:b.x=-C),M&&(b.y=-P),b.rotate(c))}else b.rotate(c);h+=b.x,a+=b.y,u.Cw(m),p+=m.x,y+=m.y;const A=Point.H(h+p,a+y);t.move(A),Point.o(A),Point.o(b),Point.o(g),Rect.o(m),Transform.o(u)}$r(){let t=this.fromNode;if(t!==null){const e=t.findVisibleNode();if(e!==null&&(t=e),t.rs()||t.nh())return!1}let i=this.toNode;if(i!==null){const e=i.findVisibleNode();if(e!==null&&(i=e),i.rs()||i.nh())return!1}return!0}b2(t,i,e){return!1}k2(){}Ae(){return!1}computeAngle(t,i,e){return Link.computeAngle(i,e)}static computeAngle(t,i){let e=0;switch(t){default:case 0:e=0;break;case 21:e=i;break;case 22:e=i+90;break;case 23:e=i-90;break;case 24:e=i+180;break;case 25:e=Geo.vg(i),e>90&&e<270&&(e-=180);break;case 26:e=Geo.vg(i+90),e>90&&e<270&&(e-=180);break;case 27:e=Geo.vg(i-90),e>90&&e<270&&(e-=180);break;case 28:if(e=Geo.vg(i),e>45&&e<135||e>225&&e<315)return 0;e>90&&e<270&&(e-=180);break}return Geo.vg(e)}get fromNode(){return this.go}set fromNode(t){const i=this.go;if(i!==t){Debug&&t!==null&&Util.s(t,Node,Link,"fromNode");const e=this.fromPort;i!==null&&(this.po!==i&&i.bb(this,e),this.My(),this.invalidateLayout(2)),this.go=t,t!==null&&this.Ki(t.isVisible()),this.ir=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.j&&s.partManager.setFromNodeForLink(this,t,i);const n=this.fromPort,o=this.fromPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.j,s.j=!0),o(this,e,n),s!==null&&(s.j=r)}t!==null&&(this.po!==t&&t.xb(this,n),this.Py(),this.invalidateLayout(1)),this.i("fromNode",i,t),this.Od()}}get fromPortId(){return this.mo}set fromPortId(t){const i=this.mo;if(i!==t){Debug&&Util.t(t,"string",Link,"fromPortId");const e=this.fromPort;e!==null&&this.fromNode._i(e),this.My(),this.mo=t;const s=this.fromPort;s!==null&&this.fromNode._i(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Ea()&&r.setFromPortIdForLinkData(o,t)}if(e!==s){this.ir=null,this.invalidateRoute();const o=this.fromPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.j,n.j=!0),o(this,e,s),n!==null&&(n.j=r)}}this.Py(),this.i("fromPortId",i,t)}}get fromPort(){const t=this.go;if(t===null)return null;const i=this.mo;return t.findPort(i)}get fromPortChanged(){return this.Bd}set fromPortChanged(t){const i=this.Bd;i!==t&&(t!==null&&Util.t(t,"function",Link,"fromPortChanged"),this.Bd=t,this.i("fromPortChanged",i,t))}get toNode(){return this.po}set toNode(t){const i=this.po;if(i!==t){Debug&&t!==null&&Util.s(t,Node,Link,"toNode");const e=this.toPort;i!==null&&(this.go!==i&&i.bb(this,e),this.My(),this.invalidateLayout(2)),this.po=t,t!==null&&this.Ki(t.isVisible()),this.ir=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.j&&s.partManager.setToNodeForLink(this,t,i);const n=this.toPort,o=this.toPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.j,s.j=!0),o(this,e,n),s!==null&&(s.j=r)}t!==null&&(this.go!==t&&t.xb(this,n),this.Py(),this.invalidateLayout(1)),this.i("toNode",i,t),this.Od()}}get toPortId(){return this.yo}set toPortId(t){const i=this.yo;if(i!==t){Debug&&Util.t(t,"string",Link,"toPortId");const e=this.toPort;e!==null&&this.toNode._i(e),this.My(),this.yo=t;const s=this.toPort;s!==null&&this.toNode._i(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Ea()&&r.setToPortIdForLinkData(o,t)}if(e!==s){this.ir=null,this.invalidateRoute();const o=this.toPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.j,n.j=!0),o(this,e,s),n!==null&&(n.j=r)}}this.Py(),this.i("toPortId",i,t)}}get toPort(){const t=this.po;if(t===null)return null;const i=this.yo;return t.findPort(i)}get toPortChanged(){return this.Vd}set toPortChanged(t){const i=this.Vd;i!==t&&(t!==null&&Util.t(t,"function",Link,"toPortChanged"),this.Vd=t,this.i("toPortChanged",i,t))}get fromSpot(){return this.Z!==null?this.Z.pa:Spot.Default}set fromSpot(t){const i=this.fromSpot;if(!i.equals(t)){if(Debug&&Util.s(t,Spot,Link,"fromSpot"),t=t.L(),this.je(),this.Z.pa=t,this.i("fromSpot",i,t),i.isSide()||t.isSide()){const e=this.fromNode;e!==null&&e._i(this.fromPort)}this.invalidateRoute()}}get fromEndSegmentLength(){return this.Z!==null?this.Z.wa:NaN}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;if(i!==t){if(Debug&&Util.t(t,"number",Link,"fromEndSegmentLength"),t<0&&Util.G(t,">= 0",Link,"fromEndSegmentLength"),this.je(),this.Z.wa=t,this.i("fromEndSegmentLength",i,t),this.computeSpot(!0,this.fromPort).isSide()){const e=this.fromNode;e!==null&&e._i(this.fromPort)}this.invalidateRoute()}}get fromShortLength(){return this.Z!==null?this.Z.ba:NaN}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(Debug&&Util.t(t,"number",Link,"fromShortLength"),this.je(),this.Z.ba=t,this.le(),this.i("fromShortLength",i,t))}get toSpot(){return this.Z!==null?this.Z.ya:Spot.Default}set toSpot(t){const i=this.toSpot;if(!i.equals(t)){if(Debug&&Util.s(t,Spot,Link,"toSpot"),t=t.L(),this.je(),this.Z.ya=t,this.i("toSpot",i,t),i.isSide()||t.isSide()){const e=this.toNode;e!==null&&e._i(this.toPort)}this.invalidateRoute()}}get toEndSegmentLength(){return this.Z!==null?this.Z.xa:NaN}set toEndSegmentLength(t){const i=this.toEndSegmentLength;if(i!==t){if(Debug&&Util.t(t,"number",Link,"toEndSegmentLength"),t<0&&Util.G(t,">= 0",Link,"toEndSegmentLength"),this.je(),this.Z.xa=t,this.i("toEndSegmentLength",i,t),this.computeSpot(!1,this.toPort).isSide()){const e=this.toNode;e!==null&&e._i(this.toPort)}this.invalidateRoute()}}get toShortLength(){return this.Z!==null?this.Z.ka:NaN}set toShortLength(t){const i=this.toShortLength;i!==t&&(Debug&&Util.t(t,"number",Link,"toShortLength"),this.je(),this.Z.ka=t,this.le(),this.i("toShortLength",i,t))}Od(){const t=this.fromNode,i=this.toNode;let e=null;if(t!==null?i!==null?e=t.findCommonContainingGroup(i):e=t.containingGroup:i!==null?e=i.containingGroup:e=null,this.$I(e),this.isLabeledLink){const s=this.labelNodes;for(;s.next();){const n=s.value;n.containingGroup=e}}}$I(t){const i=this.bh;if(i!==t){i!==null&&i.Q2(this),this.bh=t,t!==null&&t._2(this);const e=this.containingGroupChanged;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.j,n.j=!0),e(this,i,t),n!==null&&(n.j=s)}this.Te&&(this.lN===i||this.hN===i)&&this.invalidateRoute()}}gh(){const t=this.containingGroup;t!==null&&this.fromNode!==t&&this.toNode!==t&&t.computesBoundsIncludingLinks&&super.gh()}getOtherNode(t){Debug&&Util.s(t,Node,Link,"getOtherNode:node");const i=this.fromNode;return t===i?this.toNode:i}getOtherPort(t){Debug&&Util.s(t,GraphObject,Link,"getOtherPort:port");const i=this.fromPort;return t===i?this.toPort:i}get isLabeledLink(){return this.$s===null?!1:this.$s.count>0}get labelNodes(){return this.$s===null?EmptyIterator.instance:this.$s.iterator}lT(t){this.$s===null&&(this.$s=new GSet),this.$s.add(t),this.u()}hT(t){this.$s!==null&&(this.$s.delete(t),this.u())}Gm(t){if(super.Gm(t),this.Ya()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.go;let e=null;i!==null&&(e=this.fromPort,i.xb(this,e));const s=this.po;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.xb(this,n)),this.Py()}}Hm(t){if(super.Hm(t),this.Ya()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.go;let e=null;i!==null&&(e=this.fromPort,i.bb(this,e));const s=this.po;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.bb(this,n)),this.My()}}Zf(){if(this.Te=!0,this.$s!==null){const i=this.diagram;if(i!==null){const s=this.$s.copy().iterator;for(;s.next();){const n=s.value;i.remove(n)}}}if(this.data!==null){const i=this.diagram;i!==null&&i.partManager.uN(this)}}updateRelationshipsFromData(){if(this.data===null)return;const i=this.diagram;i!==null&&i.partManager.updateRelationshipsFromData(this)}move(t,i){const e=i?this.location:this.position;let s=e.x;isNaN(s)&&(s=0);let n=e.y;isNaN(n)&&(n=0);const o=t.x-s,r=t.y-n;if(i===!0)super.move(t,!1);else{const h=Point.H(e.x+o,e.y+r);super.move(h,!1),Point.o(h)}this.kr(o,r);const l=this.labelNodes;for(;l.next();){const h=l.value,a=h.position;h.moveTo(a.x+o,a.y+r)}}get relinkableFrom(){return(this.Dt&1)!==0}set relinkableFrom(t){const i=(this.Dt&1)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"relinkableFrom"),this.Dt=this.Dt^1,this.i("relinkableFrom",i,t),this.invalidateAdornments())}get relinkableTo(){return(this.Dt&2)!==0}set relinkableTo(t){const i=(this.Dt&2)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"relinkableTo"),this.Dt=this.Dt^2,this.i("relinkableTo",i,t),this.invalidateAdornments())}canRelinkFrom(){if(!this.relinkableFrom)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}canRelinkTo(){if(!this.relinkableTo)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}get resegmentable(){return(this.Dt&4)!==0}set resegmentable(t){const i=(this.Dt&4)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"resegmentable"),this.Dt=this.Dt^4,this.i("resegmentable",i,t),this.invalidateAdornments())}get isTreeLink(){return(this.Dt&8)!==0}set isTreeLink(t){const i=(this.Dt&8)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"isTreeLink"),this.Dt=this.Dt^8,this.i("isTreeLink",i,t),this.fromNode!==null&&this.fromNode.w0(),this.toNode!==null&&this.toNode.w0())}get path(){const t=this.findMainElement();return t instanceof Shape?t:null}get routeBounds(){return this.updateRoute(),this.QI(this.Tc)}QI(t){let i=1/0,e=1/0;const s=this.pointsCount;if(s===0)return t.e(NaN,NaN,0,0),t;if(s===1){const n=this.getPoint(0);i=Math.min(n.x,i),e=Math.min(n.y,e),t.e(n.x,n.y,0,0)}else if(s===2){const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o)}else if(this.computeCurve()===9&&s>=3&&!this.isOrthogonal){let n=this.getPoint(0);if(i=n.x,e=n.y,t.e(i,e,0,0),s===3){const o=this.getPoint(1);i=Math.min(o.x,i),e=Math.min(o.y,e);const r=this.getPoint(2);i=Math.min(r.x,i),e=Math.min(r.y,e),Geo.gu(n.x,n.y,o.x,o.y,o.x,o.y,r.x,r.y,.5,t)}else for(let o=3;o=s&&(o=s-1);const l=this.getPoint(o-1),h=this.getPoint(o);Geo.gu(n.x,n.y,r.x,r.y,l.x,l.y,h.x,h.y,.5,t),i=Math.min(h.x,i),e=Math.min(h.y,e),n=h}}else{const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o);for(let r=2;r=15||this.computeCurve()===9)){this.mt.getPointAlongPath(.5,t),t.add(this.getPoint(0));const a=this.mt.figures.first();return t.offset(-a.startX,-a.startY),t}if(this.computeCurve()===9){if(i===3){const c=this.getPoint(0),u=this.getPoint(1),d=this.getPoint(2);return Geo.wC(c.x,c.y,u.x,u.y,u.x,u.y,d.x,d.y,t),t}const a=(i-1)/3|0,f=(a/2|0)*3;if(a%2===1){const c=this.getPoint(f),u=this.getPoint(f+1),d=this.getPoint(f+2),m=this.getPoint(f+3);return Geo.wC(c.x,c.y,u.x,u.y,d.x,d.y,m.x,m.y,t),t}else return t.c(this.getPoint(f)),t}const e=this.flattenedLengths,s=this.flattenedTotalLength;let n=0,o=0,r=0;for(;ns/2));)n+=r,o++;const l=this.getPoint(o),h=this.getPoint(o+1);if(Math.abs(l.x-h.x)<1)l.y>h.y?t.e(l.x,l.y-(s/2-n)):t.e(l.x,l.y+(s/2-n));else if(Math.abs(l.y-h.y)<1)l.x>h.x?t.e(l.x-(s/2-n),l.y):t.e(l.x+(s/2-n),l.y);else{const a=(s/2-n)/r,f=a*(h.x-l.x),c=a*(h.y-l.y);t.e(l.x+f,l.y+c)}return t}get midAngle(){return this.updateRoute(),this.computeMidAngle()}computeMidAngle(){const t=this.pointsCount;if(t<2)return NaN;if(t===2){const h=this.getPoint(0),a=this.getPoint(1);return h.directionPoint(a)}if(this.isOrthogonal&&(this.computeCorner()>=15||this.computeCurve()===9))return this.mt.getAngleAlongPath(.5);if(this.computeCurve()===9&&t>=4){const h=(t-1)/3|0;let a=(h/2|0)*3;if(h%2===1){a=Math.floor(a);const f=this.getPoint(a),c=this.getPoint(a+1),u=this.getPoint(a+2),d=this.getPoint(a+3);return Geo.XD(f.x,f.y,c.x,c.y,u.x,u.y,d.x,d.y)}else if(a>0&&a+1e/2));)s+=o,n++;const r=this.getPoint(n),l=this.getPoint(n+1);if(Math.abs(r.x-l.x)<1&&Math.abs(r.y-l.y)<1){if(n>0&&n+2l.y?270:90;if(Math.abs(r.y-l.y)<1)return r.x>l.x?180:0}return r.directionPoint(l)}_I(){if(this.Sy===null){this.Te||this.Mb();const t=this.Sy=[];this.tO(t)}}get flattenedLengths(){return this._I(),this.Sy}get flattenedTotalLength(){let t=this.Sb;if(isNaN(t)){const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=3){let g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e);m=this.adjustPoints(0,g,o-1,p),m&&(g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e),this.adjustPoints(0,g,o-1,p))}m||(this.clearPoints(),u?this.iO(i,e,r,s,n,l):this.eO(i,e,r,s,n,l))}else{const m=this.isAvoiding;d&&(c&&m||f)&&this.clearPoints();const g=f?this.computeCurviness():0,p=this.getLinkPoint(i,e,r,!0,c,s,n);let y=0,x=0,k=0;if(c||!h||f){let N=this.computeEndSegmentLength(i,e,r,!0);if(k=this.getLinkDirection(i,e,p,r,!0,c,s,n),f&&(h||r.equals(l)||!c&&r.x+l.x===1&&r.y+l.y===1)&&(k-=c?90:30,g<0&&(k-=180)),k<0?k+=360:k>=360&&(k-=360),f&&(N+=Math.abs(g)*(c?1:2)),k===0?y=N:k===90?x=N:k===180?y=-N:k===270?x=-N:(y=N*Math.cos(k*Math.PI/180),x=N*Math.sin(k*Math.PI/180)),r.isNoSpot()&&f){const T=e.getDocumentPoint(Spot.Center,Point.a()),L=Point.H(T.x+y*1e3,T.y+x*1e3);this.getLinkPointFromPoint(i,e,T,L,!0,p),Point.o(T),Point.o(L)}}const b=this.getLinkPoint(s,n,l,!1,c,i,e);let S=0,M=0,A=0;if(c||!a||f){let N=this.computeEndSegmentLength(s,n,l,!1);if(A=this.getLinkDirection(s,n,b,l,!1,c,i,e),f&&(a||r.equals(l)||!c&&r.x+l.x===1&&r.y+l.y===1)&&(A+=c?0:30,g<0&&(A+=180)),A<0?A+=360:A>=360&&(A-=360),f&&(N+=Math.abs(g)*(c?1:2)),A===0?S=N:A===90?M=N:A===180?S=-N:A===270?M=-N:(S=N*Math.cos(A*Math.PI/180),M=N*Math.sin(A*Math.PI/180)),l.isNoSpot()&&f){const T=n.getDocumentPoint(Spot.Center,Point.a()),L=Point.H(T.x+S*1e3,T.y+M*1e3);this.getLinkPointFromPoint(s,n,T,L,!1,b),Point.o(T),Point.o(L)}}let C=p;(c||!h||f)&&(C=new Point(p.x+y,p.y+x));let P=b;(c||!a||f)&&(P=new Point(b.x+S,b.y+M)),!d&&!c&&h&&o>3&&this.adjustPoints(0,p,o-2,P)?this.setPoint(o-1,b):!d&&!c&&a&&o>3&&this.adjustPoints(1,C,o-1,b)?this.setPoint(0,p):!d&&(c?o>=6:o>4)&&this.adjustPoints(1,C,o-2,P)?(this.setPoint(0,p),this.setPoint(o-1,b)):(this.clearPoints(),this.addPoint(p),(c||!h||f)&&this.addPoint(C),c&&this.addOrthoPoints(C,k,P,A,i,s),(c||!a||f)&&this.addPoint(P),this.addPoint(b))}return t.addInvalidRoute(this),!0}gN(t,i){return Math.abs(i.x-t.x)>Math.abs(i.y-t.y)?(i.x>=t.x?i.x=t.x+9e9:i.x=t.x-9e9,i.y=t.y):(i.y>=t.y?i.y=t.y+9e9:i.y=t.y-9e9,i.x=t.x),i}getLinkPointFromPoint(t,i,e,s,n,o){if(o===void 0&&(o=new Point),t===null||i===null)return o.c(e),o;if(!t.isVisible()){const u=t.findVisibleNode();u!==null&&u!==t&&(t=u,i=t.port)}let r=0,l=0,h=0,a=0,f=null,c=i.panel;if(c!==null&&!c.kn()&&(c=c.panel),c===null)r=s.x,l=s.y,h=e.x,a=e.y;else{f=c.Ks;const u=1/(f.m11*f.m22-f.m12*f.m21),d=f.m22*u,m=-f.m12*u,g=-f.m21*u,p=f.m11*u,y=u*(f.m21*f.dy-f.m22*f.dx),x=u*(f.m12*f.dx-f.m11*f.dy);r=s.x*d+s.y*g+y,l=s.x*m+s.y*p+x,h=e.x*d+e.y*g+y,a=e.x*m+e.y*p+x}return i.nc(r,l,h,a,o),f!==null&&o.O(f),o}sO(t,i){const e=t.sd;return e!==null?e.dT(i):null}Nb(t){let i=t.sd;return i===null&&(i=new Knot,i.sr=t,i.we=t.part,t.sd=i),i.dT(this)}getLinkPoint(t,i,e,s,n,o,r,l){if(l===void 0&&(l=new Point),e.isSpot()&&!this.Ud(e))return i.getDocumentPoint(e,l),l;if(e.isSide()){const f=this.Nb(i);if(f!==null){const c=f.Gd;if(l.c(c),n&&this.routing===7){const u=this.Nb(r);if(u!==null&&f.Dc=g.y&&y.y<=g.y+g.height?l.y=y.y:(e.includesSide(Spot.TopSide)||e.includesSide(Spot.BottomSide))&&y.x>=g.x&&y.x<=g.x+g.width&&(l.x=y.x),Point.o(d),Point.o(m)}}return l}}const h=i.getDocumentPoint(this.Cb(e,s),Point.a());let a=null;if(this.pointsCount>(n?6:2))a=s?this.getPoint(1):this.getPoint(this.pointsCount-2),n&&(a=this.gN(h,a.copy()));else{const f=this.computeSpot(!s,r),c=Point.a();a=r.getDocumentPoint(this.Cb(f,!s),c),n&&(a=this.gN(h,a)),Point.o(c)}return this.getLinkPointFromPoint(t,i,h,a,s,l),Point.o(h),l}getLinkDirection(t,i,e,s,n,o,r,l){let h=this.nO(t,i,e,s,n,o,r,l);if(r&&s.isNoSpot()&&r.isMemberOf(t)&&(h+=180,h>=360&&(h-=360)),this.Ud(s))return h;const a=i.getDocumentAngle();return a===0||(45<=a&&a<135?h+=90:135<=a&&a<225?h+=180:225<=a&&a<315&&(h+=270),h>=360&&(h-=360)),h}nO(t,i,e,s,n,o,r,l){if(s.isSpot())return s.x>s.y?s.x>1-s.y?0:s.x<1-s.y?270:315:s.x1-s.y?90:s.x<1-s.y?180:135:s.x<.5?225:s.x>.5?45:0;if(s.isSide()){const c=this.Nb(i);if(c!==null)switch(c.be){case 1:return 270;case 2:return 180;default:case 4:return 0;case 8:return 90}}const h=i.getDocumentPoint(Spot.Center,Point.a());let a=null;if(this.pointsCount>(o?6:2))a=n?this.getPoint(1):this.getPoint(this.pointsCount-2),o?a=this.gN(h,a.copy()):a=e;else{const c=Point.a();a=l.getDocumentPoint(Spot.Center,c),Point.o(c)}let f=0;return Math.abs(a.x-h.x)>Math.abs(a.y-h.y)?a.x>=h.x?f=0:f=180:a.y>=h.y?f=90:f=270,Point.o(h),f}computeEndSegmentLength(t,i,e,s){if(i!==null&&e.isSide()){const o=this.Nb(i);if(o!==null)return o.Ab}let n=NaN;return s?n=this.fromEndSegmentLength:n=this.toEndSegmentLength,i!==null&&isNaN(n)&&(s?n=i.fromEndSegmentLength:n=i.toEndSegmentLength),isNaN(n)&&(n=10),n}computeSpot(t,i){return i===void 0&&(i=null),t?this.oO(i||this.fromPort):this.rO(i||this.toPort)}oO(t){if(t===null)return Spot.Center;let i=this.fromSpot;return i.isDefault()&&(i=t.fromSpot),i===Spot.Default?Spot.None:i}rO(t){if(t===null)return Spot.Center;let i=this.toSpot;return i.isDefault()&&(i=t.toSpot),i===Spot.Default?Spot.None:i}Ud(t){return t===Spot.None||t.x===.5&&t.y===.5}Cb(t,i){return t.x===.5&&t.y===.5?t:Spot.Center}computeOtherPoint(t,i){if(this.computeAdjusting()!==0&&this.pointsCount>4)return this.computeMidPoint(new Point);{const e=this.sO(i,this);return e!==null?e.Gd:i.getDocumentPoint(Spot.Center)}}computeShortLength(t){if(t){let i=this.fromShortLength;if(isNaN(i)){const e=this.fromPort;e!==null&&(i=e.fromShortLength)}return isNaN(i)?0:i}else{let i=this.toShortLength;if(isNaN(i)){const e=this.toPort;e!==null&&(i=e.toShortLength)}return isNaN(i)?0:i}}Ym(t,i,e,s,n,o){if(this.pickable===!1)return!1;i===void 0&&(i=null),e===void 0&&(e=null);let r=o;if(o===void 0&&(r=Transform.a(),r.Vi()),r.af(this.O),this.containedInRect(t,r))return this.z2(i,e,n),o===void 0&&Transform.o(r),!0;if(this.intersectsRect(t,r)){let l=!1;if(!this.mc){const h=this.D.h,a=h.length;for(let f=a;f--;){const c=h[f];if(!c.visible&&c!==this.locationObject)continue;const u=c.actualBounds,d=this.naturalBounds;if(u.x>d.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;const m=c,g=Transform.a();if(g.set(r),m instanceof Panel?l=m.Ym(t,i,e,s,n,g):this.path===m?m instanceof Shape&&(l=m.LI(t,s,g)):l=m.rL(t,s,g),l){let p=m;i!==null&&(p=i(m)),p&&(e===null||e(p))&&n.add(p)}Transform.o(g)}}return o===void 0&&Transform.o(r),l||this.background!==null}return o===void 0&&Transform.o(r),!1}get isOrthogonal(){return(this.Ba&2)===2}static cN(t){return(t&2)===2}get isAvoiding(){return(this.Ba&4)===4}computeCurve(){if(this.ir===null){const t=this.fromPort,i=t!==null&&t===this.toPort,e=this.isOrthogonal;this.ir=i&&!e}return this.ir?9:this.curve}computeCorner(){if(this.curve===9)return 0;let t=this.corner;return(isNaN(t)||t<0)&&(t=10),t}findMidLabel(){const t=this.path,i=this.D.h,e=i.length;for(let n=0;n0?g-=c:g+=c;else{const p=-h/a;let y=Math.sqrt(c*c/(p*p+1));f<0&&(y=-y),m=(a<0?-1:1)*y+u,g=p*(m-u)+d}this.addPoint(r),this.addPointAt(m,g),this.addPoint(l)}else{this.addPoint(r),this.addPoint(l);const h=Rect.a();i.getDocumentBounds(h);const a=h.containsPoint(l);n.getDocumentBounds(h);const f=h.containsPoint(r);if(a||f){const c=i.getDocumentPoint(this.Cb(e,!0),new Point);this.setPoint(0,this.getLinkPointFromPoint(t,i,c,l,!0,c));const u=n.getDocumentPoint(this.Cb(o,!1),new Point);this.setPoint(1,this.getLinkPointFromPoint(s,n,u,r,!1,u))}Rect.o(h)}}iO(t,i,e,s,n,o){const r=this.getLinkPoint(t,i,e,!0,!1,s,n),l=this.getLinkPoint(s,n,o,!1,!1,t,i),h=l.x-r.x,a=l.y-r.y,f=this.computeCurviness();let c=0,u=0,d=r.x+h/3,m=r.y+a/3,g=d,p=m;Geo.p(a,0)?h>0?p-=f:p+=f:(c=-h/a,u=Math.sqrt(f*f/(c*c+1)),f<0&&(u=-u),g=(a<0?-1:1)*u+d,p=c*(g-d)+m),d=r.x+2*h/3,m=r.y+2*a/3;let y=d,x=m;Geo.p(a,0)?h>0?x-=f:x+=f:(y=(a<0?-1:1)*u+d,x=c*(y-d)+m),this.clearPoints(),this.addPoint(r),this.addPointAt(g,p),this.addPointAt(y,x),this.addPoint(l),this.setPoint(0,this.getLinkPoint(t,i,e,!0,!1,s,n)),this.setPoint(3,this.getLinkPoint(s,n,o,!1,!1,t,i))}adjustPoints(t,i,e,s){let n=this.computeAdjusting();if(this.isOrthogonal){if(n===18)return!1;n===19&&(n=17)}switch(n){case 18:return this.lO(t,i,e,s);case 19:return this.hO(t,i,e,s);case 17:return this.aO(t,i,e,s);default:return!1}}lO(t,i,e,s){const n=this.getPoint(t),o=this.getPoint(e);if(n.equalsApprox(i)&&o.equalsApprox(s))return!0;const r=n.x,l=n.y,h=o.x,a=o.y;let f=h-r,c=a-l;const u=Math.sqrt(f*f+c*c);if(Geo.q(u,0))return!0;let d=0;Geo.q(f,0)?c<0?d=-Math.PI/2:d=Math.PI/2:(d=Math.atan(c/Math.abs(f)),f<0&&(d=Math.PI-d));const m=i.x,g=i.y,p=s.x,y=s.y,x=p-m,k=y-g,b=Math.sqrt(x*x+k*k);let S=0;Geo.q(x,0)?k<0?S=-Math.PI/2:S=Math.PI/2:(S=Math.atan(k/Math.abs(x)),x<0&&(S=Math.PI-S));const M=b/u,A=S-d;this.setPoint(t,i);for(let C=t+1;C0&&(C=-C);const P=c+S*(d-c),N=u+S*(m-u);if(g!==0){const T=P+C/p,L=N-(T-P)/g;this.setPointAt(y,T,L)}else this.setPointAt(y,P,N+C)}return this.setPoint(e,s),!0}aO(t,i,e,s){if(this.isOrthogonal){let n=this.getPoint(t),o=this.getPoint(t+1),r=this.getPoint(t+2),l=o.x,h=o.y;const a=l,f=h;Geo.p(n.y,o.y)?Geo.p(o.x,r.x)?h=i.y:Geo.p(o.y,r.y)&&(l=i.x):Geo.p(n.x,o.x)&&(Geo.p(o.y,r.y)?l=i.x:Geo.p(o.x,r.x)&&(h=i.y)),this.setPointAt(t+1,l,h),n=this.getPoint(e),o=this.getPoint(e-1),r=this.getPoint(e-2);let c=o.x,u=o.y;const d=c,m=u;if(Geo.p(n.y,o.y)?Geo.p(o.x,r.x)?u=s.y:Geo.p(o.y,r.y)&&(c=s.x):Geo.p(n.x,o.x)&&(Geo.p(o.y,r.y)?c=s.x:Geo.p(o.x,r.x)&&(u=s.y)),this.setPointAt(e-1,c,u),this.EA())return this.setPointAt(t+1,a,f),this.setPointAt(e-1,d,m),!1}return this.setPoint(t,i),this.setPoint(e,s),!0}addOrthoPoints(t,i,e,s,n,o){i<0?i+=360:i>=360&&(i-=360),s<0?s+=360:s>=360&&(s-=360);const f=s;i>=315||i<45?i=0:45<=i&&i<135?i=90:135<=i&&i<225?i=180:i=270,s>=315||s<45?s=0:45<=s&&s<135?s=90:135<=s&&s<225?s=180:s=270;const c=t,u=e,d=n.actualBounds.copy(),m=o.actualBounds.copy();if(!d.isReal()||!m.isReal())return;d.inflate(Link.Xa,Link.Xa),m.inflate(Link.Xa,Link.Xa),d.unionPoint(t),m.unionPoint(e);const g=Point.a(),p=Point.a();i===0?u.x>c.x||s===270&&u.yc.x||s===90&&u.y>c.y&&m.right>c.x?(g.e(u.x,c.y),p.e(u.x,(c.y+u.y)/2),s===180?(g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1),p.x=g.x,p.y=u.y):s===270&&u.yc.y?(c.xm.bottom)?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):g.x=m.right,p.x=g.x,p.y=u.y):s===0&&c.xm.top&&c.yd.bottom)&&(s===180&&(m.containsPoint(c)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):u.yc.y&&(s===180||s===270)&&(g.y=this.computeMidOrthoPosition(c.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=d.left&&u.x<=c.x||c.x<=m.right&&c.x>=u.x?(s===90||s===270)&&(g.e(Math.max((c.x+u.x)/2,c.x),c.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yc.y&&m.leftc.y?(c.x>m.right?g.x=this.computeMidOrthoPosition(c.x,c.y,m.right,u.y,!1):c.x>m.left&&(s===270&&c.ym.bottom)?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):g.x=m.left,p.x=g.x,p.y=u.y):s===180&&c.x>m.right&&c.y>m.top&&c.yd.bottom)&&(s===0&&(m.containsPoint(c)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):u.yc.y&&(s===0||s===270)&&(g.y=this.computeMidOrthoPosition(c.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=c.x||c.x>=m.left&&c.x<=u.x?(s===90||s===270)&&(g.e(Math.min((c.x+u.x)/2,c.x),c.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yc.y||s===180&&u.xc.y||s===0&&u.x>c.x&&m.bottom>c.y?(g.e(c.x,u.y),p.e((c.x+u.x)/2,u.y),s===270?(g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0),p.x=u.x,p.y=g.y):s===180&&u.xc.x?(c.ym.right)?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):g.y=m.bottom,p.x=u.x,p.y=g.y):s===90&&c.ym.left&&c.xd.right)&&(s===270&&(m.containsPoint(c)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):u.xc.x&&(s===270||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,c.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=d.top&&u.y<=c.y||c.y<=m.bottom&&c.y>=u.y?(s===0||s===180)&&(g.e(c.x,Math.max((c.y+u.y)/2,c.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.xc.x&&m.top=c.x?(c.y>m.bottom?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,m.bottom,!0):c.y>m.top&&(s===180&&c.xm.right)?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):g.y=m.top,p.x=u.x,p.y=g.y):s===270&&c.y>m.bottom&&c.x>m.left&&c.xd.right)&&(s===90&&(m.containsPoint(c)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):u.xc.x&&(s===90||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,c.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=c.y||c.y>=m.top&&c.y<=u.y?(s===0||s===180)&&(g.e(c.x,Math.min((c.y+u.y)/2,c.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.x=3&&!Geo.q(this.smoothness,0))if(i===3){let f=this.getPoint(1);n=Math.min(r.x,f.x),o=Math.min(r.y,f.y),f=this.getPoint(2),n=Math.min(n,f.x),o=Math.min(o,f.y)}else if(this.isOrthogonal){for(let f=0;f=i&&(f=i-1);const c=this.getPoint(f);l.x=Math.min(c.x,l.x),l.y=Math.min(c.y,l.y)}n=l.x,o=l.y}else{for(let f=0;f=3&&!Geo.q(this.smoothness,0))if(i===3){const c=this.getPoint(1),u=c.x-n,d=c.y-o;let m=this.getPoint(2).copy();m.x-=n,m.y-=o,this.computeShortLength(!1)!==0&&(m=this.Fc(m,!1,l)),f.wr(u,d,u,d,m.x,m.y)}else if(this.isOrthogonal){const c=Point.H(n,o),u=Point.a();u.c(this.getPoint(1));const d=Point.H(n,o),m=Point.H(n,o);let g=this.getPoint(0),p=null;const y=this.smoothness/3;for(let S=1;S=i&&(c=i-1);const d=this.getPoint(c-1);let m=this.getPoint(c);c===i-1&&this.computeShortLength(!1)!==0&&(m=this.Fc(m.copy(),!1,Point.Lo)),f.wr(u.x-n,u.y-o,d.x-n,d.y-o,m.x-n,m.y-o)}else{const c=Point.a();c.c(this.getPoint(0));const u=Point.a();u.c(c);const d=this.computeCorner();let m=1,g=0;for(;m1);let p=this.getPoint(m);if(m>=i-1){if(!c.equals(p))this.computeShortLength(!1)!==0&&(p=this.Fc(p.copy(),!1,Point.Lo)),this.Dn(f,-n,-o,c,p,e);else if(g===0)for(m=1;mr?c>a?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):c>a?(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.q(r,h)&&Geo.q(a,c)&&(a>l?f>h?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):f>h?(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.q(r,h)&&Geo.q(h,f)||Geo.q(l,a)&&Geo.q(a,c)){const m=.5*(r+f),g=.5*(l+c);n.x=m,n.y=g,o.x=m,o.y=g}}Fc(t,i,e){const s=this.pointsCount;if(s<2)return t;if(i){const n=this.getPoint(1),o=n.x-e.x,r=n.y-e.y,l=this.Lb(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!0);a>h&&(a=h);const f=a*(o-t.x)/l,c=a*(r-t.y)/l;t.x+=f,t.y+=c}else{const n=this.getPoint(s-2),o=n.x-e.x,r=n.y-e.y,l=this.Lb(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!1);a>h&&(a=h);const f=a*(t.x-o)/l,c=a*(t.y-r)/l;t.x-=f,t.y-=c}return t}mN(t,i,e){const s=this.pointsCount;let n=t;for(;Geo.q(t.x,n.x)&&Geo.q(t.y,n.y);){if(i>=s)return s-1;n=this.getPoint(i++)}if(!Geo.q(t.x,n.x)&&!Geo.q(t.y,n.y))return i-1;let o=n;for(;Geo.q(t.x,n.x)&&Geo.q(n.x,o.x)&&(!e||(t.y>=n.y?n.y>=o.y:n.y<=o.y))||Geo.q(t.y,n.y)&&Geo.q(n.y,o.y)&&(!e||(t.x>=n.x?n.x>=o.x:n.x<=o.x));){if(i>=s)return s-1;o=this.getPoint(i++)}return i-2}uO(t,i,e,s,n,o,r,l,h,a){if(Geo.p(s.y,n.y)&&Geo.p(n.x,o.x)){let f=Math.min(h,Math.abs(n.x-l.x)/2);const c=Math.min(f,Math.abs(o.y-n.y)/2);if(f=c,Geo.p(f,0)){this.Dn(t,i,e,s,n,a),r.c(n);return}let u=n.x;const d=n.y,m=u;let g=d;n.x>s.x?(u=n.x-f,o.y>n.y?g=n.y+c:g=n.y-c):(u=n.x+f,o.y>n.y?g=n.y+c:g=n.y-c);const p=Point.H(u,d);this.Dn(t,i,e,s,p,a),Point.o(p),t.Fw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else if(Geo.p(s.x,n.x)&&Geo.p(n.y,o.y)){let f=Math.min(h,Math.abs(n.y-l.y)/2);const c=Math.min(f,Math.abs(o.x-n.x)/2);if(f=c,Geo.p(c,0)){this.Dn(t,i,e,s,n,a),r.c(n);return}const u=n.x;let d=n.y,m=u;const g=d;n.y>s.y?(d=n.y-f,o.x>n.x?m=n.x+c:m=n.x-c):(d=n.y+f,o.x>n.x?m=n.x+c:m=n.x-c);const p=Point.H(u,d);this.Dn(t,i,e,s,p,a),Point.o(p),t.Fw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else this.Dn(t,i,e,s,n,a),r.c(n)}computeJumpLength(){return 10}Dn(t,i,e,s,n,o){if(o||!this.Ya())t.yr(n.x+i,n.y+e);else{const r=this.computeJumpLength(),l=r/2,h=[];let a=0;this.isVisible()&&(a=this.dO(s,n,h));let f=s.x,c=s.y;if(a>0){if(Geo.p(s.y,n.y))if(s.x=0;){const d=Math.min(s.x,Math.max(h[u--]+l,n.x+r));t.yr(d+i,n.y+e),f=d+i,c=n.y+e;let m=Math.max(d-r,n.x);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.x);else break}const g=n.y-r+e,p=m+i,y=n.y+e;this.curve===10?t.yu(p,y,!1,!1):t.wr(f,g,p,g,p,y),f=p,c=y}}else if(Geo.p(s.x,n.x))if(s.y=0;){const d=Math.min(s.y,Math.max(h[u--]+l,n.y+r));t.yr(n.x+i,d+e),f=n.x+i,c=d+e;let m=Math.max(d-r,n.y);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.y);else break}const g=n.x-r+i,p=n.x+i,y=m+e;this.curve===10?t.yu(p,y,!1,!1):t.wr(g,c,g,y,p,y),f=p,c=y}}}t.yr(n.x+i,n.y+e)}}dO(t,i,e){const s=this.diagram;if(s===null||t.equals(i))return 0;const n=s.layers;for(;n.next();){const o=n.value;if(o!==null&&o.visible){const r=o.HM(),l=r.length;for(let h=0;h0&&e.sort((u,d)=>u-d),e.length;if(!a.isVisible()||!a.Ya())continue;const f=a.routeBounds;if(!f.isReal()||!this.routeBounds.intersectsRect(f)||this.usesSamePort(a))continue;const c=a.path;c!==null&&c.isVisibleObject()&&this.gO(t,i,e,a)}}}return e.length>0&&e.sort((o,r)=>o-r),e.length}gO(t,i,e,s){const n=Geo.p(t.y,i.y),o=s.pointsCount;let r=s.getPoint(0);const l=Point.a();for(let h=1;hr.x&&f.x>=a.x||a.xr.y&&f.y>=a.y||a.yf&&Math.min(a,c)o&&!Geo.p(a,c))return n.x=o,n.y=f,!0}else if(Geo.p(r,h)&&Geo.p(a,c)&&Math.min(o,l)a&&Math.min(f,u)r&&!Geo.p(f,u))return n.x=a,n.y=r,!0;return n.x=0,n.y=0,!1}get firstPickIndex(){return this.pointsCount<=2?0:this.isOrthogonal||!this.Ud(this.computeSpot(!0))?1:0}get lastPickIndex(){const t=this.pointsCount;return t===0?0:t<=2?t-1:this.isOrthogonal||!this.Ud(this.computeSpot(!1))?t-2:t-1}Ya(){const t=this.curve;return t===11||t===10}Pb(t){if(t||this.Ya()){const i=this.diagram;i!==null&&!i.animationManager.isTicking&&!i.th.has(this)&&(this.Tc.width!==0||this.Tc.height!==0)&&i.th.set(this,this.Tc.copy())}}invalidateOtherJumpOvers(t){const i=this.layer;if(i===null||!i.visible||i.isTemporary)return;const e=i.diagram;if(e===null||e.animationManager.isTicking)return;let s=!1;const n=e.layers;for(;n.next();){const o=n.value;if(o.visible){if(o===i){s=!0;let r=!1;const l=o.HM(),h=l.length;for(let a=0;a0&&e>0){const s=this.getPoint(0),n=t.getPoint(0);if(s.equalsApprox(n))return!0;const o=this.getPoint(i-1),r=t.getPoint(e-1);if(o.equalsApprox(r)||s.equalsApprox(r)||o.equalsApprox(n))return!0}else if(this.fromNode===t.fromNode||this.toNode===t.toNode||this.fromNode===t.toNode||this.toNode===t.fromNode)return!0;return!1}isVisible(){if(!super.isVisible())return!1;const t=this.containingGroup;let i=!0;const e=this.diagram;e!==null&&(i=e.isTreePathToChildren);const s=this.fromNode;if(s!==null){if(this.isTreeLink&&i&&!s.isTreeExpanded)return!1;if(s===t)return!0;let o=s;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=s.findVisibleNode();if(r===null||r===t)return!1}const n=this.toNode;if(n!==null){if(this.isTreeLink&&!i&&!n.isTreeExpanded)return!1;if(n===t)return!0;let o=n;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=n.findVisibleNode();if(r===null||r===t)return!1}return!0}Ki(t){if(super.Ki(t),t&&this.Pb(!1),this.er!==null&&this.er.Ed(),this.$s!==null){const e=this.$s.iterator;for(;e.next();)e.value.Ki(t)}}get adjusting(){return this.Lc}set adjusting(t){const i=this.Lc;i!==t&&(Debug&&t!==0&&t!==17&&t!==18&&t!==19&&Util.n("Link.adjusting can only be set to None, End, Scale, or Stretch, not: "+t),this.Lc=t,this.i("adjusting",i,t))}computeAdjusting(){return this.isAvoiding&&this.diagram!==null&&this.diagram.animationManager.defaultAnimation.isAnimating?17:this.Lc}get corner(){return this.zd}set corner(t){const i=this.zd;i!==t&&(Debug&&Util.t(t,"number",Link,"corner"),this.zd=t,this.le(),this.i("corner",i,t))}get curve(){return this.Xd}set curve(t){const i=this.Xd;i!==t&&(Debug&&t!==0&&t!==9&&t!==10&&t!==11&&Util.n("Link.curve can only be set to None, Bezier, JumpGap, or JumpOver, not: "+t),this.Xd=t,this.invalidateRoute(),this.le(),this.Pb(i===10||i===11||t===10||t===11),this.i("curve",i,t))}get curviness(){return this.Yd}set curviness(t){const i=this.Yd;i!==t&&(Debug&&Util.t(t,"number",Link,"curviness"),this.Yd=t,this.invalidateRoute(),this.le(),this.i("curviness",i,t))}get routing(){return this.Ba}set routing(t){const i=this.Ba;i!==t&&(Debug&&t!==1&&t!==2&&t!==6&&t!==7&&Util.n("Link.routing can only be set to Normal, Orthogonal, AvoidsNodes, not: "+t),this.Ba=t,this.isAvoiding&&this.diagram!==null&&(this.diagram.Zm=!0),this.ir=null,this.invalidateRoute(),this.Pb(Link.cN(i)||Link.cN(t)),this.i("routing",i,t))}get smoothness(){return this.Kd}set smoothness(t){const i=this.Kd;i!==t&&(Debug&&Util.t(t,"number",Link,"smoothness"),this.Kd=t,this.le(),this.i("smoothness",i,t))}Py(){const t=this.go;if(t===null)return;const i=this.po;if(i===null||!isNaN(this.curviness))return;const e=this.mo,s=this.yo;let n=null,o=null;const r=t.ni.h,l=r.length;for(let h=0;h=0&&(Util.lf(t.Qs,i),t.Ed())}}Dl(){return!0}get key(){const t=this.diagram;if(!(t===null||!t.model.Ea()))return t.model.getKeyForLinkData(this.data)}}class LinkBundle{Ko;Xs;uy;sN;wb;nN;Qs;constructor(t,i,e,s){GSet.vi(this),this.Ko=!1,this.Xs=!1,this.uy=t,this.sN=i,this.wb=e,this.nN=s,this.Qs=[]}Ed(){if(!this.Ko){const t=this.Qs;if(t.length>0){const i=t[0].diagram;i!==null&&(i.mP.add(this),this.Xs=i.undoManager.isUndoingRedoing)}}this.Ko=!0}LP(){if(this.Ko){this.Ko=!1;const t=this.Qs;if(t.length>0){const i=t[0],e=i.diagram,s=e===null||e.Kh&&!this.Xs;this.Xs=!1,i.arrangeBundledLinks(t,s),t.length===1&&(i.er=null,t.length=0)}t.length===0&&(this.uy.nT(this),this.wb.nT(this))}}}class PositionArray{fe;ce;Ka;Ua;bi;ki;Yt;Mh;Ph;ua;YP;Ko;Cy;Qf;KP;UP;constructor(t){GSet.vi(this),this.ua=null,this.YP=null,this.Ko=!0,this.Cy=!1,this.fe=1,this.ce=1,this.Ka=-1,this.Ua=-1,this.bi=t.width,this.ki=t.height,this.Yt=null,this.Mh=0,this.Ph=0,this.Qf=11,this.KP=this.Qf*2,this.UP=this.Qf*2}static _s=0;static Ga=1;static Hd=999999;static pN=PositionArray.Hd+1;static yN=PositionArray.Hd+2;I1(t){if(t.width<=0||t.height<=0)return;const i=t.x,e=t.y,s=t.x+t.width,n=t.y+t.height;this.fe=Math.floor((i-this.bi)/this.bi)*this.bi,this.ce=Math.floor((e-this.ki)/this.ki)*this.ki,this.Ka=Math.ceil((s+2*this.bi)/this.bi)*this.bi,this.Ua=Math.ceil((n+2*this.ki)/this.ki)*this.ki;const o=1+(Math.ceil((this.Ka-this.fe)/this.bi)|0),r=1+(Math.ceil((this.Ua-this.ce)/this.ki)|0);if(this.Yt===null||this.Mh0&&t!==this.bi&&(this.bi=t,this.I1(this.bounds))}get cellHeight(){return this.ki}set cellHeight(t){t>0&&t!==this.ki&&(this.ki=t,this.I1(this.bounds))}qd(t,i){return this.fe<=t&&t<=this.Ka&&this.ce<=i&&i<=this.Ua}wo(t,i){if(!this.qd(t,i))return PositionArray.pN;t-=this.fe,t/=this.bi,i-=this.ce,i/=this.ki;const e=t|0,s=i|0;return this.Yt[e][s]}PR(t,i,e,s){if(!this.qd(t,i))return;const n=(t-this.fe)/this.bi|0,o=(i-this.ce)/this.ki|0,r=(t+e-this.fe)/this.bi|0,l=(i+s-this.ce)/this.ki|0,h=Math.min(r,this.Mh),a=Math.min(l,this.Ph);for(let f=n;f<=h;f++){const c=this.Yt[f];if(c.fill)c.fill(PositionArray._s,o,a+1);else for(let u=o;u<=a;u++)c[u]=PositionArray._s}}pO(t){if(this.Yt!==null)for(let i=0;i<=this.Mh;i++){const e=this.Yt[i];if(e.fill)e.fill(t);else for(let s=0;s<=this.Ph;s++)e[s]=t}}WA(){if(this.Yt!==null)for(let t=0;t<=this.Mh;t++){const i=this.Yt[t];for(let e=0;e<=this.Ph;e++)i[e]>=PositionArray.Ga&&(i[e]=PositionArray.pN)}}yO(t,i){return this.wo(t,i)===PositionArray._s}isUnoccupied(t,i,e,s){if(t>this.Ka||t+ethis.Ua||i+sthis.Ka||ithis.Ua||ethis.Ua||ithis.Ka||e=PositionArray.Ga&&h=a)break;this.Yt[t][i]=h,h+=1,s?i+=e:t+=e}return s?i:t}xo(t,i,e,s,n,o,r,l){if(to||il)return;const h=this.wO(t,i,e,s,n,o,r,l);if(s)if(e>0)for(let a=i+e;ah;a+=e)this.xo(t,a,1,!s,n,o,r,l),this.xo(t,a,-1,!s,n,o,r,l);else if(e>0)for(let a=t+e;ah;a+=e)this.xo(a,i,1,!s,n,o,r,l),this.xo(a,i,-1,!s,n,o,r,l)}Tb(t,i,e,s,n,o,r,l,h,a){let f=t|0,c=i|0,u=PositionArray._s,d=PositionArray.Ga;for(this.Yt[f][c]=d;u===PositionArray._s&&f>r&&fh&&cr&&fh&&c=0;I-=2){F=L[I+2],R=L[I+3];const O=L[I],V=L[I+1];for(;O>F?F++:OR?R++:Vs)d--;else break;else if(m>n)m--;else break;const g=f[d][m];if(g===0||g===PositionArray.yN)break;c=d,u=m}for(;;){let d=e,m=c,g=u;e===0?gn&&(d=270,g--):e===90?ms&&(d=180,m--):e===180?gn&&(d=270,g--):ms&&(d=180,m--);const p=f[m][g];if(d!==e&&p!==0&&p!==PositionArray.yN){if(o.push(c),o.push(u),this.pT(c,u,d,s,n,o))return!0;o.pop(),o.pop()}if(f[c][u]=PositionArray.yN,e===0){if(c===t)return!1;c--}else if(e===90){if(u===i)return!1;u--}else if(e===180){if(c===t)return!1;c++}else{if(u===i)return!1;u++}}}}class Knot{we;sr;cs;jd;constructor(){GSet.vi(this),this.we=null,this.sr=null,this.cs=[],this.jd=!1}toString(){const t=this.cs;let i=this.we.toString()+" "+t.length.toString()+":";for(let e=0;e180?270:90;case 6:return o>90&&o<=270?180:0}const r=Math.atan2(t.height,t.width)*180/Math.PI;switch(n){case 3:return o>r&&o<=180+r?180:270;case 5:return o>180-r&&o<=360-r?270:0;case 12:return o>r&&o<=180+r?90:0;case 10:return o>180-r&&o<=360-r?180:90;case 7:return o>90&&o<=180+r?180:o>180+r&&o<=360-r?270:0;case 13:return o>180&&o<=360-r?270:o>r&&o<=180?90:0;case 14:return o>r&&o<=180-r?90:o>180-r&&o<=270?180:0;case 11:return o>180-r&&o<=180+r?180:o>180+r?270:90}return s&&n!==15&&(o-=15,o<0&&(o+=360)),o>r&&o<180-r?90:o>=180-r&&o<=180+r?180:o>180+r&&o<360-r?270:0}Ed(){this.cs.length=0}dT(t){let i=this.cs;i.length===0&&(this.bO(),i=this.cs);for(let e=0;e=360&&(M-=360);const A=this.xO(h,y,M,g.isOrthogonal);let C=0;A===0?(C=4,M>180&&(M-=360)):A===90?(C=8,M>270&&(M-=360)):A===180?C=2:(C=1,M<90&&(M+=360));let P=this.cs[o];P===void 0?(P=new LinkInfo(g,M,C),this.cs[o]=P):(P.$e=g,P.jt=M,P.be=C),P.Fb.set(S),o++}Point.o(a),this.kO();const u=this.cs.length;let d=-1,m=0;for(o=0;o=0;o--){const g=this.cs[o];g!==void 0&&(g.be!==d&&(d=g.be,m=g.Wd+1),g.Dc=m)}this.SO(this.cs),this.MO(this.cs),this.jd=t,Rect.o(h)}return this.cs}PO(t,i){return t===i?0:t===null?-1:i===null?1:t.bei.be?1:t.jti.jt?1:0}kO(){this.cs.sort(Knot.prototype.PO)}SO(t){const i=this.sr,e=this.we.portSpreading,s=Point.a(),n=Point.a(),o=Point.a(),r=Point.a();i.getDocumentPoint(Spot.TopLeft,s),i.getDocumentPoint(Spot.TopRight,n),i.getDocumentPoint(Spot.BottomRight,o),i.getDocumentPoint(Spot.BottomLeft,r);let l=0,h=0,a=0,f=0;if(e===2)for(let x=0;xMath.abs(p)?(d=Math.abs(p)/a,a=Math.abs(p)):d=1;break;case 2:f>Math.abs(y)?(d=Math.abs(y)/f,f=Math.abs(y)):d=1;break;case 1:l>Math.abs(p)?(d=Math.abs(p)/l,l=Math.abs(p)):d=1;break;default:case 4:h>Math.abs(y)?(d=Math.abs(y)/h,h=Math.abs(y)):d=1;break}u=0}const b=k.Gd;if(e===2){let S=k.$e.computeThickness();switch(S*=d,b.set(m),c){case 8:b.x=m.x+p/2+a/2-u-S/2;break;case 2:b.y=m.y+y/2+f/2-u-S/2;break;case 1:b.x=m.x+p/2-l/2+u+S/2;break;default:case 4:b.y=m.y+y/2-h/2+u+S/2;break}u+=S}else{let S=.5;e===1&&(S=(k.Wd+1)/(k.Dc+1)),b.x=m.x+p*S,b.y=m.y+y*S}}Point.o(s),Point.o(n),Point.o(o),Point.o(r)}MO(t){for(let i=0;ie instanceof Placeholder);i instanceof Placeholder?t.Et=i:t.Et=null,this.re!==null?(t.re=this.re.copy(),t.re.group=t):(t.re!==null&&(t.re.group=null),t.re=null),this.hi!==null&&(t.hi=this.hi.copy())}Ho(t){super.Ho(t);const i=t.findSubGraphParts(),e=t.memberParts;for(;e.next();){const s=e.value;if(s.u(),s.invalidateLayout(8),s.clearAdornments(),s instanceof Node)s.invalidateConnectedLinks(i);else if(s instanceof Link){const n=s.labelNodes;for(;n.next();)n.value.invalidateConnectedLinks(i)}}}ec(t,i,e,s,n,o,r){if(t===3&&i==="elements"){if(n instanceof Placeholder)this.Et===null?this.Et=n:this.Et!==n&&Util.n("Cannot insert a second Placeholder into the visual tree of a Group.");else if(n instanceof Panel){const l=n.findInVisualTree(h=>h instanceof Placeholder);l instanceof Placeholder&&(this.Et===null?this.Et=l:this.Et!==l&&Util.n("Cannot insert a second Placeholder into the visual tree of a Group."))}}else t===4&&i==="elements"&&this.Et!==null&&(s===this.Et?this.Et=null:s instanceof Panel&&this.Et.isContainedBy(s)&&(this.Et=null));super.ec(t,i,e,s,n,o,r)}hd(t,i){if(super.hd(t,i),this.isClipping&&this.type!==Panel.Spot&&this.isSubGraphExpanded){let e=this.resizeObject;e instanceof Panel&&(e=e.findMainElement()),this.hi===null&&(this.hi=new Rect),e.getDocumentBounds(this.hi),e instanceof Shape&&this.hi.inflate(-e.strokeWidth,-e.strokeWidth)}}dh(t,i,e,s){this.hasPlaceholder()&&(this.tr=this.placeholder),super.dh(t,i,e,s)}ensureBounds(){this.isSubGraphExpanded&&this.memberParts.each(i=>{i.ensureBounds()}),super.ensureBounds()}$r(){if(!super.$r())return!1;const t=this.memberParts;for(;t.next();){const i=t.value;if(i instanceof Node){if(!i.isVisible())continue;if(i.rs())return!1}else if(i instanceof Link){if(!i.isVisible())continue;if(i.rs()&&i.fromNode!==this&&i.toNode!==this)return!1}}return!0}hasPlaceholder(){return this.Et!==null&&this.Et.isVisibleObject()&&this.isSubGraphExpanded}get placeholder(){return this.Et}get computesBoundsAfterDrag(){return(this.z&2048)!==0}set computesBoundsAfterDrag(t){const i=(this.z&2048)!==0;i!==t&&(Util.t(t,"boolean",Group,"computesBoundsAfterDrag"),this.z=this.z^2048,this.i("computesBoundsAfterDrag",i,t))}get computesBoundsIncludingLinks(){return(this.z&4096)!==0}set computesBoundsIncludingLinks(t){Util.t(t,"boolean",Group,"computesBoundsIncludingLinks");const i=(this.z&4096)!==0;i!==t&&(this.z=this.z^4096,this.i("computesBoundsIncludingLinks",i,t))}get computesBoundsIncludingLocation(){return(this.z&8192)!==0}set computesBoundsIncludingLocation(t){Util.t(t,"boolean",Group,"computesBoundsIncludingLocation");const i=(this.z&8192)!==0;i!==t&&(this.z=this.z^8192,this.i("computesBoundsIncludingLocation",i,t))}get handlesDragDropForMembers(){return(this.z&16384)!==0}set handlesDragDropForMembers(t){Util.t(t,"boolean",Group,"handlesDragDropForMembers");const i=(this.z&16384)!==0;i!==t&&(this.z=this.z^16384,this.i("handlesDragDropForMembers",i,t))}get avoidableMembers(){return(this.z&131072)!==0}set avoidableMembers(t){Util.t(t,"boolean",Group,"avoidableMembers");const i=(this.z&131072)!==0;i!==t&&(this.z=this.z^131072,this.i("avoidableMembers",i,t))}get memberParts(){return this.vd.iterator}_2(t){if(this.vd.add(t)){t instanceof Group&&this.ca.add(t);const e=this.memberAdded;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.j,n.j=!0),e(this,t),n!==null&&(n.j=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ki(!1)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.Et;i===null&&(i=this),i.u()}Q2(t){if(this.vd.delete(t)){t instanceof Group&&this.ca.delete(t);const e=this.memberRemoved;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.j,n.j=!0),e(this,t),n!==null&&(n.j=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ki(!0)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.Et;i===null&&(i=this),i.u()}Zf(){if(this.vd.count>0){const t=this.diagram;if(t!==null){const e=this.vd.copy().iterator;for(;e.next();){const s=e.value;t.remove(s)}}}super.Zf()}get layout(){return this.re}set layout(t){const i=this.re;if(i!==t){t!==null&&(Util.s(t,Layout,Group,"layout"),t.diagram!==null&&t.diagram.layout===t&&Util.n("A layout cannot be both the Diagram.layout and a Group.layout: "+t)),i!==null&&(i.diagram=null,i.group=null),this.re=t;const e=this.diagram;t!==null&&(t.diagram=e,t.group=this),e!==null&&(e.Wr=!0),this.i("layout",i,t),e!==null&&e.requestUpdate()}}get memberAdded(){return this.bt!==null?this.bt.xy:null}set memberAdded(t){const i=this.memberAdded;i!==t&&(t!==null&&Util.t(t,"function",Group,"memberAdded"),this.ml(),this.bt.xy=t,this.i("memberAdded",i,t))}get memberRemoved(){return this.bt!==null?this.bt.by:null}set memberRemoved(t){const i=this.memberRemoved;i!==t&&(t!==null&&Util.t(t,"function",Group,"memberRemoved"),this.ml(),this.bt.by=t,this.i("memberRemoved",i,t))}get memberValidation(){return this.bt!==null?this.bt.rh:null}set memberValidation(t){const i=this.memberValidation;i!==t&&(t!==null&&Util.t(t,"function",Group,"memberValidation"),this.ml(),this.bt.rh=t,this.i("memberValidation",i,t))}canAddMembers(t){const i=this.diagram;if(i===null)return!1;const e=i.commandHandler,n=e.c2(t).iterator;for(;n.next();){const o=n.value;if(!e.isValidMember(this,o))return!1}return!0}addMembers(t,i){const e=this.diagram;if(e===null)return!1;const s=e.commandHandler,n=s.c2(t);let o=!0;const r=n.iterator;for(;r.next();){const l=r.value;!i||s.isValidMember(this,l)?l.containingGroup=this:o=!1}return o}get ungroupable(){return(this.z&256)!==0}set ungroupable(t){const i=(this.z&256)!==0;i!==t&&(Util.t(t,"boolean",Group,"ungroupable"),this.z=this.z^256,this.i("ungroupable",i,t))}canUngroup(){if(!this.ungroupable)return!1;const t=this.layer;if(t===null||!t.allowUngroup)return!1;const i=t.diagram;return!(i!==null&&!i.allowUngroup)}invalidateConnectedLinks(t){const i=this.CO();if(super.invalidateConnectedLinks(t),i)return;this.LA(!0);const e=this.findExternalLinksConnected();for(;e.next();){const s=e.value;if(t!==void 0&&t.has(s))continue;const n=s.fromNode;if(n!==null&&n!==this&&n.isMemberOf(this)&&!n.isVisible())n._i(s.fromPort),n._i(s.toPort),s.invalidateRoute();else{const o=s.toNode;o!==null&&o!==this&&o.isMemberOf(this)&&!o.isVisible()&&(o._i(s.fromPort),o._i(s.toPort),s.invalidateRoute())}}}findExternalLinksConnected(){const t=this.diagram!==null&&this.diagram.kP;if(t&&this.x0!==null)return this.x0.iterator;const i=this.findSubGraphParts();i.add(this);const e=new GSet,s=i.iterator;for(;s.next();){const n=s.value;if(!(n instanceof Node))continue;const o=n.linksConnected;for(;o.next();){const r=o.value;i.has(r)||e.add(r)}}return t&&(this.x0=e),e.iterator}findExternalNodesConnected(){const t=this.findSubGraphParts();t.add(this);const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;if(!(s instanceof Node))continue;const n=s.linksConnected;for(;n.next();){const o=n.value,r=o.fromNode;r!==null&&(!t.has(r)||r===this)&&i.add(r);const l=o.toNode;l!==null&&(!t.has(l)||l===this)&&i.add(l)}}return i.iterator}pE(){function t(e,s){e!==null&&(s.add(e),t(e.containingGroup,s))}const i=new GSet;return t(this,i),i}findSubGraphParts(){const t=new GSet;return Part.lh(t,this,!0,0,!0),t.delete(this),t}Ki(t){super.Ki(t);const i=this.memberParts;for(;i.next();)i.value.Ki(t)}collapseSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.yT(i,t,this),t.isCollapsingExpanding=!1}yT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ki(!1),n instanceof Group&&n.isSubGraphExpanded&&(n.wasSubGraphExpanded=n.isSubGraphExpanded,n.yT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t),i.Ef(n,e);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!1}expandSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.wT(i,t,this),t.isCollapsingExpanding=!1}wT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ki(!0),n instanceof Group&&n.wasSubGraphExpanded&&(n.wasSubGraphExpanded=!1,n.wT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!0}get isSubGraphExpanded(){return(this.z&512)!==0}set isSubGraphExpanded(t){const i=(this.z&512)!==0;if(i!==t){Util.t(t,"boolean",Group,"isSubGraphExpanded"),this.z=this.z^512;const e=this.diagram;this.i("isSubGraphExpanded",i,t);const s=this.subGraphExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.j,e.j=!0),s(this),e!==null&&(e.j=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.Et!==null&&this.Et.u(),this.memberParts.each(n=>n.updateAdornments());return}t?this.expandSubGraph():this.collapseSubGraph()}}get wasSubGraphExpanded(){return(this.z&1024)!==0}set wasSubGraphExpanded(t){const i=(this.z&1024)!==0;i!==t&&(Util.t(t,"boolean",Group,"wasSubGraphExpanded"),this.z=this.z^1024,this.i("wasSubGraphExpanded",i,t))}get subGraphExpandedChanged(){return this.bt!==null?this.bt.ky:null}set subGraphExpandedChanged(t){const i=this.subGraphExpandedChanged;i!==t&&(t!==null&&Util.t(t,"function",Group,"subGraphExpandedChanged"),this.ml(),this.bt.ky=t,this.i("subGraphExpandedChanged",i,t))}move(t,i){i===void 0&&(i=!1);const e=i?this.location:this.position,s=e.x,n=e.y,o=t.x,r=t.y;if((s===o||isNaN(s)&&isNaN(o))&&(n===r||isNaN(n)&&isNaN(r)))return;const l=o-(isNaN(s)?0:s),h=r-(isNaN(n)?0:n),a=Point.a();super.move(t,i);const f=new GSet,u=this.findSubGraphParts().iterator;for(;u.next();){const d=u.value;d instanceof Link&&(d.suspendsRouting&&f.add(d),!(!d.Te&&(d.fromNode===this||d.toNode===this))&&(d.suspendsRouting=!0))}for(u.reset();u.next();){const d=u.value;if(d.Dl()||d instanceof Node&&d.isLinkLabel)continue;const m=d.position,g=d.location;m.isReal()?(a.x=m.x+l,a.y=m.y+h,d.position=a):g.isReal()&&(a.x=g.x+l,a.y=g.y+h,d.location=a)}for(u.reset();u.next();){const d=u.value;if(!(d instanceof Link)||(d.suspendsRouting=f.has(d),!d.Te&&(d.fromNode===this||d.toNode===this)))continue;const m=d.position;a.x=m.x+l,a.y=m.y+h,a.isReal()?d.move(a):d.invalidateRoute()}Point.o(a)}CO(){return(this.z&65536)!==0}LA(t){(this.z&65536)!==0!==t&&(this.z=this.z^65536)}get tl(){return(this.z&32768)!==0}set tl(t){(this.z&32768)!==0!==t&&(this.z=this.z^32768)}}class Placeholder extends GraphObject{ii;Jd;constructor(t){super(),this.ii=Margin.Hg,this.Jd=new Rect(NaN,NaN,NaN,NaN),t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.ii=this.ii.L(),t.Jd=this.Jd.copy()}uh(t){if(this.background===null)return!1;const i=this.naturalBounds;return Rect.contains(0,0,i.width,i.height,t.x,t.y)}rd(t,i,e,s){const n=this.part;if((n===null||!(n instanceof Group)&&!(n instanceof Adornment))&&Util.n("Placeholder is not inside a Group or Adornment."),n instanceof Group){const o=this.computeBorder(this.Jd),r=this.minSize,l=isFinite(r.width)?Math.max(r.width,o.width):o.width,h=isFinite(r.height)?Math.max(r.height,o.height):o.height,a=this.Hi;a.Kn(l||0,h||0),this.no(0,0,a.width,a.height);const f=n.memberParts;let c=!1;for(;f.next();)if(f.value.isVisible()){c=!0;break}const u=n.diagram;if(c&&u!==null&&!u.animationManager.OM(n)&&!isNaN(o.x)&&!isNaN(o.y)){const d=Point.a();d.setRectSpot(o,n.locationSpot),n.location=d,Point.o(d)}}else{const o=n,r=this.Hi,l=this.ii,h=l.left+l.right,a=l.top+l.bottom,f=o.adornedObject,c=f.getDocumentAngle();o.angle=c;let u=0;f instanceof Shape&&(u=f.strokeWidth);const d=f.getDocumentScale(),m=f.naturalBounds,g=(m.width+u)*d,p=(m.height+u)*d;if(o.type!==Panel.Link){const y=o.category==="Selection"?Spot.TopLeft:o.locationSpot,x=f.getDocumentPoint(y,Point.a());o.location=x,Point.o(x)}if(!isNaN(g)&&!isNaN(p))r.Kn(g+h||0,p+a||0),this.no(-l.left,-l.top,r.width,r.height);else{const y=f.getDocumentPoint(Spot.TopLeft,Point.a()),x=Rect.H(y.x,y.y,0,0);x.unionPoint(f.getDocumentPoint(Spot.BottomRight,y)),x.unionPoint(f.getDocumentPoint(Spot.TopRight,y)),x.unionPoint(f.getDocumentPoint(Spot.BottomLeft,y)),r.Kn(x.width+h||0,x.height+a||0),this.no(-l.left,-l.top,r.width,r.height),Point.o(y),Rect.o(x)}}}dh(t,i,e,s){this.actualBounds.e(t,i,e,s)}computeBorder(t){const i=this.part,e=i.diagram,s=e===null||!e.animationManager.isAnimating;if(e!==null&&i instanceof Group&&!i.layer.isTemporary&&i.computesBoundsAfterDrag&&this.Jd.isReal()){const l=e.toolManager.findTool("Dragging");if(l===e.currentTool){const h=l.computeBorder(i,this.Jd,t);if(h!==null)return h}}const n=Rect.a(),o=this.computeMemberBounds(n),r=this.ii;return i instanceof Group&&!i.isSubGraphExpanded?t.e(o.x-r.left,o.y-r.top,0,0):t.e(o.x-r.left,o.y-r.top,Math.max(o.width+r.left+r.right,0),Math.max(o.height+r.top+r.bottom,0)),Rect.o(n),s&&i instanceof Group&&i.computesBoundsIncludingLocation&&i.location.isReal()&&t.unionPoint(i.location),t}computeMemberBounds(t){if(!(this.part instanceof Group))return t.e(0,0,0,0),t;const i=this.part;let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=i.memberParts;for(;r.next();){const l=r.value;if(!l.isVisible()||l instanceof Link&&(!i.computesBoundsIncludingLinks||l.Xo()||l.fromNode===i||l.toNode===i))continue;const h=l.actualBounds;h.leftn&&(n=h.right),h.bottom>o&&(o=h.bottom)}if(!isFinite(e)||!isFinite(s)){const l=i.location;t.e(l.x,l.y,0,0)}else t.e(e,s,n-e,o-s);return t}get padding(){return this.ii}set padding(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Placeholder,"padding");const i=this.ii;i.equals(t)||(t=t.L(),this.ii=t,this.i("padding",i,t),this.u())}}class Layout{b;ua;Zd;Cr;$d;Qd;Bo;pl;_d;tg;bo;constructor(t){GSet.vi(this),this.b=null,this.ua=null,this.Zd=!0,this.Cr=!0,this.$d=!1,this.Qd=new Point(0,0).w(),this.Bo=!0,this.pl=null,this._d=null,this.tg=!1,this.bo=null,t&&Object.assign(this,t)}cloneProtected(t){t.Zd=this.Zd,t.Cr=this.Cr,t.$d=this.$d,t.Qd.c(this.Qd),t.Bo=this.Bo,t.pl=this.pl,t._d=this._d,t.tg=!0}copy(){const t=new this.constructor;return this.cloneProtected(t),t}fi(t){Util.ur(this,t)}toString(){let t=Util.hn(this.constructor);return t+="(",this.group!==null&&(t+=" in "+this.group),this.diagram!==null&&(t+=" for "+this.diagram),t+=")",t}get diagram(){return this.b}set diagram(t){t!==null&&Util.s(t,Diagram,Layout,"diagram"),this.b=t}get group(){return this.ua}set group(t){this.ua!==t&&(t!==null&&Util.s(t,Group,Layout,"group"),this.ua=t,t!==null&&(this.b=t.diagram))}get isOngoing(){return this.Zd}set isOngoing(t){this.Zd!==t&&(Util.t(t,"boolean",Layout,"isOngoing"),this.Zd=t)}get isInitial(){return this.Cr}set isInitial(t){Util.t(t,"boolean",Layout,"isInitial"),this.Cr=t,t||(this.tg=!0)}get isViewportSized(){return this.$d}set isViewportSized(t){this.$d!==t&&(Util.t(t,"boolean",Layout,"isViewportSized"),this.$d=t,t&&this.invalidateLayout())}get isRouting(){return this.Bo}set isRouting(t){this.Bo!==t&&(Util.t(t,"boolean",Layout,"isRouting"),this.Bo=t)}get isRealtime(){return this.pl}set isRealtime(t){this.pl!==t&&(t!==null&&Util.t(t,"boolean",Layout,"isRealtime"),this.pl=t)}get isValidLayout(){return this.tg}set isValidLayout(t){if(this.tg!==t&&(Util.t(t,"boolean",Layout,"isValidLayout"),this.tg=t,!t)){const i=this.diagram;i!==null&&(i.Wr=!0)}}invalidateLayout(){if(this.isValidLayout){const t=this.diagram;if(t===null||t.undoManager.isUndoingRedoing)return;const i=t.animationManager;if(i.isTicking)return;i.defaultAnimation.isAnimating&&i.stopAnimation(),(this.isOngoing&&t.Kh||this.isInitial&&!t.Kh)&&(this.isValidLayout=!1,t.requestUpdate())}}get network(){return this.bo}set network(t){this.bo!==t&&(t!==null&&Util.s(t,LayoutNetwork,Layout,"network"),this.bo=t,t!==null&&(t.layout=this))}createNetwork(){return new LayoutNetwork(this)}makeNetwork(t){const i=this.createNetwork();return t instanceof Diagram?(i.addParts(t.nodes,!0),i.addParts(t.links,!0)):t instanceof Group?i.addParts(t.memberParts):i.addParts(t.iterator),i}updateParts(){this.isValidLayout=!0;let t=this.diagram;if(t===null&&this.network!==null){const i=this.network.vertexes.iterator;for(;i.next();){const s=i.value.node;if(s!==null&&(t=s.diagram,t!==null))break}}try{t!==null&&t.startTransaction("Layout"),this.commitLayout()}finally{t!==null&&t.commitTransaction("Layout")}}commitLayout(){if(this.network===null)return;const t=this.network.vertexes.iterator;for(;t.next();)t.value.commit();if(this.isRouting){const i=this.network.edges.iterator;for(;i.next();)i.value.commit()}}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts");const i=new GSet;if(t instanceof Diagram?(this.Nh(i,t.nodes,!0,this.tl,!0,!1,!0),this.Nh(i,t.parts,!0,this.tl,!0,!1,!0)):t instanceof Group?this.Nh(i,t.memberParts,!1,this.tl,!0,!1,!0):i.addAll(t.iterator),i.count>0){const s=this.diagram;s!==null&&s.startTransaction("Layout"),this.doMinimalNoNetworkLayout(i),s!==null&&s.commitTransaction("Layout")}this.isValidLayout=!0}doMinimalNoNetworkLayout(t){const i=t.count,e=Math.ceil(Math.sqrt(i));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const s=this.arrangementOrigin.x,n=this.arrangementOrigin.y;let o=s,r=n,l=0,h=0;const a=t.iterator;for(;a.next();){const f=a.value;f.ensureBounds();const c=f.measuredBounds,u=c.width,d=c.height;f.moveTo(o,r),f instanceof Group&&(f.tl=!1),o+=Math.max(u,50)+20,h=Math.max(h,Math.max(d,50)),l>=e-1?(l=0,o=s,r+=h+20,h=0):l++}}doMinimalNetworkLayout(){const t=this.network.vertexes.count,i=Math.ceil(Math.sqrt(t));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const e=this.arrangementOrigin.x,s=this.arrangementOrigin.y;let n=e,o=s,r=0,l=0;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value.node;if(a===null||a instanceof Link||(a.ensureBounds(),!this.tl(a)))continue;const f=a.measuredBounds,c=f.width,u=f.height;a.moveTo(n,o),a instanceof Group&&(a.tl=!1),n+=Math.max(c,50)+20,l=Math.max(l,Math.max(u,50)),r>=i-1?(r=0,n=e,o+=l+20,l=0):r++}}tl(t){return!!(!t.location.isReal()&&!t.position.isReal()||t instanceof Group&&t.tl)}Nh(t,i,e,s,n,o,r){const l=i.iterator;for(;l.next();){const h=l.value;if(!(e&&!h.isTopLevel)&&!(s!==null&&!s(h))&&h.canLayout())if(n&&h instanceof Node){if(h.isLinkLabel)continue;h instanceof Group&&h.layout===null?this.Nh(t,h.memberParts,!1,s,n,o,r):(h.ensureBounds(),t.add(h))}else o&&h instanceof Link?t.add(h):r&&h.Ae()&&!(h instanceof Node)&&(h.ensureBounds(),t.add(h))}}getLayoutBounds(t,i){const e=this.boundsComputation;return e!==null?(i||(i=new Rect),e(t,this,i)):!i&&t.margin.equalTo(0,0,0,0)?t.actualBounds:(i||(i=new Rect),i.set(t.actualBounds),i.addMargin(t.margin),i)}get boundsComputation(){return this._d}set boundsComputation(t){this._d!==t&&(t!==null&&Util.t(t,"function",Layout,"boundsComputation"),this._d=t,this.invalidateLayout())}collectParts(t){const i=new GSet;return t instanceof Diagram?(this.Nh(i,t.nodes,!0,null,!0,!0,!0),this.Nh(i,t.links,!0,null,!0,!0,!0),this.Nh(i,t.parts,!0,null,!0,!0,!0)):t instanceof Group?this.Nh(i,t.memberParts,!1,null,!0,!0,!0):this.Nh(i,t.iterator,!1,null,!0,!0,!0),i}get arrangementOrigin(){return this.Qd}set arrangementOrigin(t){Util.s(t,Point,Layout,"arrangementOrigin"),this.Qd.equals(t)||(this.Qd.c(t),this.invalidateLayout())}initialOrigin(t){const i=this.group;if(i!==null)if(i.hasPlaceholder()){const e=i.placeholder,s=e.getDocumentPoint(Spot.TopLeft);(isNaN(s.x)||isNaN(s.y))&&s.set(t);const n=e.padding;return s.x+=n.left,s.y+=n.top,s}else{const e=i.position.copy();return(isNaN(e.x)||isNaN(e.y))&&e.set(t),e}return t}}class LayoutNetwork{re;ko;Fn;Ay;Ly;constructor(t){GSet.vi(this),Debug&&!t&&Util.n("LayoutNetwork constructor requires non-null Layout argument"),this.re=t,this.ko=new GSet,this.Fn=new GSet,this.Ay=new GMap,this.Ly=new GMap}clear(){if(this.ko){const t=this.ko.iterator;for(;t.next();)t.value.clear()}if(this.Fn){const t=this.Fn.iterator;for(;t.next();)t.value.clear()}this.ko=new GSet,this.Fn=new GSet,this.Ay=new GMap,this.Ly=new GMap}toString(t){t===void 0&&(t=0);let i="LayoutNetwork"+(this.layout!==null?"("+this.layout.toString()+")":"");if(t<=0)return i;if(i+=" vertexes: "+this.ko.count+" edges: "+this.Fn.count,t>1){const e=this.ko.iterator;for(;e.next();){const n=e.value;i+=` `+n.toString(t-1)}const s=this.Fn.iterator;for(;s.next();){const n=s.value;i+=` - `+n.toString(t-1)}}return i}get layout(){return this.oe}set layout(t){t!==null&&(this.oe=t)}get vertexes(){return this.ko}get edges(){return this.Fn}createVertex(){return new LayoutVertex(this)}createEdge(){return new LayoutEdge(this)}addParts(t,i,e){if(t===null)return;i===void 0&&(i=!1),Util.t(i,"boolean",LayoutNetwork,"addParts:toplevelonly"),e===void 0&&(e=null),e===null&&(e=n=>{if(n instanceof Node)return!n.isLinkLabel;if(n instanceof Link){const o=n.fromNode;if(o===null||o.isLinkLabel)return!1;const r=n.toNode;return!(r===null||r.isLinkLabel)}return!1});const s=t.iterator;for(;s.next();){const n=s.value;if(n instanceof Node&&!(i&&!n.isTopLevel)&&n.canLayout()&&e(n))if(n instanceof Group&&n.layout===null)this.addParts(n.memberParts,!1);else{if(this.findVertex(n)!==null)continue;const o=this.createVertex();o.node=n,this.addVertex(o)}}for(s.reset();s.next();){const n=s.value;if(!(n instanceof Link)||i&&!n.isTopLevel||!n.canLayout()||!e(n)||this.findEdge(n)!==null)continue;const o=n.fromNode,r=n.toNode;if(o===null||r===null||o===r)continue;const l=this.findGroupVertex(o),h=this.findGroupVertex(r);this.linkVertexes(l,h,n)}}findGroupVertex(t){if(t===null)return null;const i=t.findVisibleNode();if(i===null)return null;let e=this.findVertex(i);if(e!==null)return e;let s=i.containingGroup;for(;s!==null;){if(e=this.findVertex(s),e!==null)return e;s=s.containingGroup}return null}addVertex(t){if(t===null)return;Debug&&Util.s(t,LayoutVertex,LayoutNetwork,"addVertex:vertex"),this.ko.add(t);const i=t.node;i!==null&&this.Ay.set(i,t),t.network=this}addNode(t){if(t===null)return null;Debug&&Util.s(t,Node,LayoutNetwork,"addNode:node");let i=this.findVertex(t);return i===null&&(i=this.createVertex(),i.node=t,this.addVertex(i)),i}deleteVertex(t){if(t!==null&&(Debug&&Util.s(t,LayoutVertex,LayoutNetwork,"deleteVertex:vertex"),this.xT(t))){let i=t.nr;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}i=t.or;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}}}xT(t){if(t===null)return!1;const i=this.ko.delete(t);if(i){const e=t.node;e!==null&&this.Ay.delete(e)}return i}deleteNode(t){if(t===null)return;Debug&&Util.s(t,Node,LayoutNetwork,"deleteNode:node");const i=this.findVertex(t);i!==null&&this.deleteVertex(i)}findVertex(t){return t===null?null:(Debug&&Util.s(t,Node,LayoutNetwork,"findVertex:node"),this.Ay.get(t))}addEdge(t){if(t===null)return;Debug&&Util.s(t,LayoutEdge,LayoutNetwork,"addEdge:edge"),this.bN(t);const i=t.toVertex;i!==null&&i.addSourceEdge(t);const e=t.fromVertex;e!==null&&e.addDestinationEdge(t)}bN(t){if(t===null)return;this.Fn.add(t);const i=t.link;i!==null&&this.findEdge(i)===null&&this.Ly.set(i,t),t.network=this}addLink(t){if(t===null)return null;Debug&&Util.s(t,Link,LayoutNetwork,"addLink:link");const i=t.fromNode,e=t.toNode;let s=this.findEdge(t);return s===null?(s=this.createEdge(),s.link=t,i!==null&&(s.fromVertex=this.addNode(i)),e!==null&&(s.toVertex=this.addNode(e)),this.addEdge(s)):(i!==null?s.fromVertex=this.addNode(i):s.fromVertex=null,e!==null?s.toVertex=this.addNode(e):s.toVertex=null),s}deleteEdge(t){if(t===null)return;Debug&&Util.s(t,LayoutEdge,LayoutNetwork,"deleteEdge:edge");const i=t.toVertex;i!==null&&i.deleteSourceEdge(t);const e=t.fromVertex;e!==null&&e.deleteDestinationEdge(t),this.kN(t)}kN(t){if(t===null)return!1;const i=this.Fn.delete(t);if(i){const e=t.link;e!==null&&this.Ly.delete(e)}return i}deleteLink(t){if(t===null)return;Debug&&Util.s(t,Link,LayoutNetwork,"deleteLink:link");const i=this.findEdge(t);i!==null&&this.deleteEdge(i)}findEdge(t){return t===null?null:(Debug&&Util.s(t,Link,LayoutNetwork,"findEdge:link"),this.Ly.get(t))}linkVertexes(t,i,e){if(t===null||i===null)return null;if(Debug&&(Util.s(t,LayoutVertex,LayoutNetwork,"linkVertexes:fromVertex"),Util.s(i,LayoutVertex,LayoutNetwork,"linkVertexes:toVertex"),e!==null&&Util.s(e,Link,LayoutNetwork,"linkVertexes:link")),t.network===this&&i.network===this){const s=this.createEdge();return s.link=e,s.fromVertex=t,s.toVertex=i,this.addEdge(s),s}return null}reverseEdge(t){if(t===null)return;Debug&&Util.s(t,LayoutEdge,LayoutNetwork,"reverseEdge:edge");const i=t.fromVertex,e=t.toVertex;i===null||e===null||(i.deleteDestinationEdge(t),e.deleteSourceEdge(t),t.reverseEdge(),i.addSourceEdge(t),e.addDestinationEdge(t))}deleteSelfEdges(){const t=Util.ft(),i=this.Fn.iterator;for(;i.next();){const s=i.value;s.fromVertex===s.toVertex&&t.push(s)}const e=t.length;for(let s=0;s0||t.or.count>0)}splitIntoSubNetworks(t){t===void 0&&(t=!0),t&&(this.deleteArtificialVertexes(),this.deleteUselessEdges(),this.deleteSelfEdges());const i=new List;let e=!0;for(;e;){e=!1;const s=this.ko.iterator;for(;s.next();){const n=s.value;if(this.isSingleton(n))continue;const o=this.layout.createNetwork();i.add(o),this.LO(o,n),e=!0;break}}return i.sort((s,n)=>s===null||n===null||s===n?0:n.vertexes.count-s.vertexes.count),i}LO(t,i){if(i===null)return;const e=new List;for(e.add(i);e.count>0;){const s=e.first();if(e.removeAt(0),s.network===t)continue;this.xT(s),t.addVertex(s);let n=s.sourceEdges;for(;n.next();){const o=n.value;o.network!==t&&(this.kN(o),t.bN(o),e.add(o.fromVertex))}for(n=s.destinationEdges;n.next();){const o=n.value;o.network!==t&&(this.kN(o),t.bN(o),e.add(o.toVertex))}}}findAllParts(){const t=new GSet,i=this.ko.iterator;for(;i.next();){const s=i.value;t.add(s.node)}const e=this.Fn.iterator;for(;e.next();){const s=e.value;t.add(s.link)}return t}}class LayoutVertex{bo;si;ye;Oe;Qe;nr;or;constructor(t){GSet.vi(this),Debug&&!t&&Util.n("LayoutVertex constructor requires non-null LayoutNetwork argument"),this.bo=t,this.Oe=new Rect(0,0,10,10).w(),this.Qe=new Point(5,5).w(),this.si=null,this.ye=null,this.nr=new List,this.or=new List}clear(){this.si=null,this.ye=null,this.nr=new List,this.or=new List}toString(t){t===void 0&&(t=0);let i="LayoutVertex#"+GSet.gs(this);if(t>0&&(i+=this.node!==null?"("+this.node.toString()+")":"",t>1)){let e="",s=!0,n=this.nr.iterator;for(;n.next();){const r=n.value;s?s=!1:e+=",",e+=r.toString(0)}let o="";for(s=!0,n=this.or.iterator;n.next();){const r=n.value;s?s=!1:o+=",",o+=r.toString(0)}i+=" sources: "+e+" destinations: "+o}return i}get So(){return this.nr.nC}get rr(){return this.or.nC}get data(){return this.si}set data(t){if(this.si=t,t!==null&&t.bounds){const i=t.bounds,e=i.x,s=i.y,n=i.width,o=i.height;this.Qe.e(n/2,o/2),this.Oe.e(e,s,n,o)}}get node(){return this.ye}set node(t){if(this.ye!==t){Debug&&t!==null&&Util.s(t,Node,LayoutVertex,"node"),this.ye=t,t.ensureBounds();const i=this.network.layout,e=Rect.a(),s=i.getLayoutBounds(t,e);let n=s.x,o=s.y;const r=s.width,l=s.height;if(isNaN(n)&&(n=0),isNaN(o)&&(o=0),this.Oe.e(n,o,r,l),Rect.o(e),!(t instanceof Group)){const h=t.locationObject.getDocumentPoint(Spot.Center);if(h.isReal()){this.Qe.e(h.x-n,h.y-o);return}}this.Qe.e(r/2,l/2)}}get bounds(){return this.Oe}set bounds(t){this.Oe.equals(t)||(Debug&&Util.s(t,Rect,LayoutVertex,"bounds"),this.Oe.c(t))}get focus(){return this.Qe}set focus(t){this.Qe.equals(t)||(Debug&&Util.s(t,Point,LayoutVertex,"focus"),this.Qe.c(t))}get centerX(){return this.Oe.x+this.Qe.x}set centerX(t){const i=this.Oe;i.x+this.Qe.x!==t&&(Debug&&Util.r(t,LayoutVertex,"centerX"),i.ct(),i.x=t-this.Qe.x,i.w())}get centerY(){return this.Oe.y+this.Qe.y}set centerY(t){const i=this.Oe;i.y+this.Qe.y!==t&&(Debug&&Util.r(t,LayoutVertex,"centerY"),i.ct(),i.y=t-this.Qe.y,i.w())}get focusX(){return this.Qe.x}set focusX(t){const i=this.Qe;i.x!==t&&(i.ct(),i.x=t,i.w())}get focusY(){return this.Qe.y}set focusY(t){const i=this.Qe;i.y!==t&&(i.ct(),i.y=t,i.w())}get x(){return this.Oe.x}set x(t){const i=this.Oe;i.x!==t&&(i.ct(),i.x=t,i.w())}get y(){return this.Oe.y}set y(t){const i=this.Oe;i.y!==t&&(i.ct(),i.y=t,i.w())}get width(){return this.Oe.width}set width(t){const i=this.Oe;i.width!==t&&(i.ct(),i.width=t,i.w())}get height(){return this.Oe.height}set height(t){const i=this.Oe;i.height!==t&&(i.ct(),i.height=t,i.w())}commit(){const t=this.si;if(t!==null){const e=this.bounds,s=t.bounds;Util.Mt(s)?(s.x=e.x,s.y=e.y,s.width=e.width,s.height=e.height):t.bounds=e.copy();return}const i=this.node;if(i!==null){const e=this.bounds;if(!(i instanceof Group)){const s=Rect.a();i.ensureBounds();const n=this.network.layout.getLayoutBounds(i,s),o=i.locationObject.getDocumentPoint(Spot.Center);if(n.isReal()&&o.isReal()){i.moveTo(e.x+this.focusX-(o.x-n.x)+i.margin.left,e.y+this.focusY-(o.y-n.y+i.margin.top)),Rect.o(s);return}Rect.o(s)}i.moveTo(e.x+i.margin.left,e.y+i.margin.top)}}addSourceEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"addSourceEdge:edge"),this.nr.has(t)||this.nr.add(t))}deleteSourceEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"deleteSourceEdge:edge"),this.nr.delete(t))}addDestinationEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"addDestinationEdge:edge"),this.or.has(t)||this.or.add(t))}deleteDestinationEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"deleteDestinationEdge:edge"),this.or.delete(t))}get network(){return this.bo}set network(t){Debug&&Util.s(t,LayoutNetwork,LayoutVertex,"network"),this.bo=t}get sourceVertexes(){const t=new GSet,i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}return t.iterator}get destinationVertexes(){const t=new GSet,i=this.destinationEdges;for(;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get vertexes(){const t=new GSet;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get sourceEdges(){return this.nr.iterator}get destinationEdges(){return this.or.iterator}get edges(){const t=new List;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e)}return t.iterator}get edgesCount(){return this.nr.count+this.or.count}static standardComparer(t,i){Debug&&Util.s(t,LayoutVertex,LayoutVertex,"standardComparer:m"),Debug&&Util.s(i,LayoutVertex,LayoutVertex,"standardComparer:n");const e=t.ye,s=i.ye;if(e)if(s){const n=e.text,o=s.text;return no?1:0}else return 1;else return s!==null?-1:0}static smartComparer(t,i){if(Debug&&Util.s(t,LayoutVertex,LayoutVertex,"smartComparer:m"),Debug&&Util.s(i,LayoutVertex,LayoutVertex,"smartComparer:n"),t!==null)if(i!==null){const e=t.ye,s=i.ye;if(e!==null)if(s!==null){const n=e.text.toLocaleLowerCase(),o=s.text.toLocaleLowerCase(),r=n.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),l=o.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let h=0;for(;h0&&(i+=this.$e!==null?"("+this.$e.toString()+")":"",t>1&&(i+=" "+(this._e?this._e.toString():"null")+" --> "+(this.ts?this.ts.toString():"null"))),i}reverseEdge(){const t=this._e;this._e=this.ts,this.ts=t}commit(){}getOtherVertex(t){return Debug&&Util.s(t,LayoutVertex,LayoutEdge,"getOtherVertex:v"),this.ts===t?this._e:this._e===t?this.ts:null}get network(){return this.bo}set network(t){Debug&&Util.s(t,LayoutNetwork,LayoutEdge,"network"),this.bo=t}get data(){return this.si}set data(t){this.si!==t&&(Debug&&t!==null&&Util.t(t,"object",LayoutEdge,"data"),this.si=t)}get link(){return this.$e}set link(t){this.$e!==t&&(Debug&&t!==null&&Util.s(t,Link,LayoutEdge,"link"),this.$e=t)}get fromVertex(){return this._e}set fromVertex(t){this._e!==t&&(Debug&&t!==null&&Util.s(t,LayoutVertex,LayoutEdge,"fromVertex"),this._e=t)}get toVertex(){return this.ts}set toVertex(t){this.ts!==t&&(Debug&&t!==null&&Util.s(t,LayoutVertex,LayoutEdge,"toVertex"),this.ts=t)}}var GridAlignment=(w=>(w[w.Position=0]="Position",w[w.Location=1]="Location",w))(GridAlignment||{}),GridArrangement=(w=>(w[w.LeftToRight=10]="LeftToRight",w[w.RightToLeft=11]="RightToLeft",w))(GridArrangement||{}),GridSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w))(GridSorting||{});class GridLayout extends Layout{eg;sg;Ro;Rn;ai;qi;ke;Se;constructor(t){super(),this.isViewportSized=!0,this.eg=NaN,this.sg=NaN,this.Ro=new Size(NaN,NaN).w(),this.Rn=new Size(10,10).w(),this.ai=1,this.qi=10,this.ke=22,this.Se=GridLayout.standardComparer,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.eg=this.eg,t.sg=this.sg,t.Ro.c(this.Ro),t.Rn.c(this.Rn),t.ai=this.ai,t.qi=this.qi,t.ke=this.ke,t.Se=this.Se}fi(t){t in GridSorting?this.sorting=t:t in GridArrangement?this.arrangement=t:t in GridAlignment?this.alignment=t:super.fi(t)}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.collectParts(t),e=this.diagram,n=i.copy().iterator;for(;n.next();){const m=n.value;if(m.Dl()&&(m.fromNode!==null||m.toNode!==null)){i.delete(m);continue}if(m.ensureBounds(),m instanceof Group){const g=m.memberParts;for(;g.next();){const p=g.value;i.delete(p)}}}const o=i.toArray();if(o.length===0)return;switch(this.sorting){case 20:break;case 21:o.reverse();break;case 22:o.sort(this.comparer);break;case 23:o.sort(this.comparer),o.reverse();break}let r=this.wrappingColumn;isNaN(r)&&(r=0);let l=this.wrappingWidth;if(isNaN(l)&&e!==null){const m=e.viewportBounds,g=e.padding;l=Math.max(m.width-g.left-g.right,0)}else l=Math.max(this.wrappingWidth,0);r<=0&&l<=0&&(r=1);let h=this.spacing.width;isFinite(h)||(h=0);let a=this.spacing.height;isFinite(a)||(a=0),e!==null&&e.startTransaction("Layout");const f=[];switch(this.alignment){case 0:this.TO(o,l,r,h,a,f);break;case 1:this.DO(o,l,r,h,a,f);break}let c=0,u=0,d=0;for(let m=0;m0&&m>e-1||i>0&&m>0&&A-f>i)&&(o.push(new Rect(0,d,i+s,g)),m=0,u=f,d+=g,g=0),g=Math.max(g,M);let C=0;switch(a){case 11:C=-x.width;break;default:C=0;break}switch(y.moveTo(u+C+y.margin.left,d+y.margin.top),a){case 11:u-=S;break;default:u+=S;break}m++}o.push(new Rect(0,d,i+s,g)),Rect.o(r)}DO(t,i,e,s,n,o){const r=Rect.a();let l=Math.max(this.cellSize.width,1),h=0,a=0,f=0;const c=Point.a();for(let C=0;C=h&&(i-=h);let x=0,k=0;const b=Math.max(this.cellSize.height,1);f=0;let S=0,M=!0;const A=Point.a();for(let C=0;C0)switch(u){case 11:{let D=(g-d-(N.width-T.x))/l;Geo.q(Math.round(D),D)?D=Math.round(D):D=Math.floor(D),g=D*l+d;break}default:{let D=(g-d+T.x)/l;Geo.q(Math.round(D),D)?D=Math.round(D):D=Math.ceil(D),g=D*l+d;break}}else switch(u){case 11:x=g+T.x+N.width;break;default:x=g-T.x;break}let L=0;switch(u){case 11:L=-(g+T.x)+x;break;default:L=g+N.width-T.x-x;break}if(e>0&&y>e-1||i>0&&y>0&&L>i){o.push(new Rect(0,M?p-f:p,i+s,S+f+n));for(let D=0;Dk&&(P.width+=P.x-k,P.x=k)}Rect.o(r)}commitLayers(t,i){}get wrappingWidth(){return this.eg}set wrappingWidth(t){this.eg!==t&&(Util.t(t,"number",GridLayout,"wrappingWidth"),(t>0||isNaN(t))&&(this.eg=t,this.isViewportSized=isNaN(t),this.invalidateLayout()))}get wrappingColumn(){return this.sg}set wrappingColumn(t){this.sg!==t&&(Util.t(t,"number",GridLayout,"wrappingColumn"),(t>0||isNaN(t))&&(this.sg=t,this.invalidateLayout()))}get cellSize(){return this.Ro}set cellSize(t){Util.s(t,Size,GridLayout,"cellSize"),this.Ro.equals(t)||(this.Ro.c(t),this.invalidateLayout())}get spacing(){return this.Rn}set spacing(t){Util.s(t,Size,GridLayout,"spacing"),this.Rn.equals(t)||(this.Rn.c(t),this.invalidateLayout())}get alignment(){return this.ai}set alignment(t){this.ai!==t&&(Util.tt(t,GridAlignment,"GridAlignment"),(t===1||t===0)&&(this.ai=t,this.invalidateLayout()))}get arrangement(){return this.qi}set arrangement(t){this.qi!==t&&(Util.tt(t,GridArrangement,"GridArrangement"),(t===10||t===11)&&(this.qi=t,this.invalidateLayout()))}get sorting(){return this.ke}set sorting(t){this.ke!==t&&(Util.tt(t,GridSorting,"GridSorting"),(t===20||t===21||t===22||t===23)&&(this.ke=t,this.invalidateLayout()))}get comparer(){return this.Se}set comparer(t){this.Se!==t&&(Util.t(t,"function",GridLayout,"comparer"),this.Se=t,this.invalidateLayout())}static standardComparer(t,i){Debug&&Util.s(t,Part,GridLayout,"standardComparer:a"),Debug&&Util.s(i,Part,GridLayout,"standardComparer:b");const e=t.text,s=i.text;return es?1:0}static smartComparer(t,i){if(Debug&&Util.s(t,Part,GridLayout,"standardComparer:a"),Debug&&Util.s(i,Part,GridLayout,"standardComparer:b"),t!==null)if(i!==null){const e=t.text.toLocaleLowerCase(),s=i.text.toLocaleLowerCase(),n=e.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),o=s.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let r=0;for(;r{e.containsNodeData(s)&&this.MT(s,!1)}),t.forEach(s=>{e.containsNodeData(s)&&this.Rb(s)}),i!==!1&&this.diagram.R1(!1)}MT(t,i){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.Mo.has(t))return null;i===void 0&&(i=!0);const e=this.FO(t);return e!==null&&i&&this.Rb(t),e}FO(t){if(t==null||this.b.undoManager.isUndoingRedoing||this.Mo.has(t))return null;const i=this.RO(t),e=this.findTemplateForNodeData(t,i);if(e!==null){e.ci();const s=e.copy();if(s!==null){const n=this.diagram.me;return this.diagram.me=!0,s.$o=i,s.si=t,this.Ty&&(s.ul="Tool"),this.diagram.add(s),s.si=null,s.data=t,this.diagram.me=n,s}}return null}insertLink(t,i,e,s){return null}Rb(t){}RO(t){return this.b.model.getCategoryForNodeData(t)}static PT=!1;static NT=!1;findTemplateForNodeData(t,i){const e=this.b,s=e.model,n=s.da()&&s.isGroupForData(t);let o=null;return n?(o=e.groupTemplateMap.get(i),o===null&&(o=e.groupTemplateMap.get(""),o===null&&(PartManager.NT||(PartManager.NT=!0,Util.at('No Group template found for category "'+i+'"'),Util.at(" Using default group template")),o=e.gP))):(o=e.nodeTemplateMap.get(i),o===null&&(o=e.nodeTemplateMap.get(""),o===null&&(PartManager.PT||(PartManager.PT=!0,Util.at('No Node template found for category "'+i+'"'),Util.at(" Using default node template")),o=e.cP))),o}getLinkCategoryForData(t){return""}setLinkCategoryForData(t,i){}setFromNodeForLink(t,i,e){}setToNodeForLink(t,i,e){}static CT=!1;findLinkTemplateForCategory(t){const i=this.b;let e=i.linkTemplateMap.get(t);return e===null&&(e=i.linkTemplateMap.get(""),e===null&&(PartManager.CT||(PartManager.CT=!0,Util.at('No Link template found for category "'+t+'"'),Util.at(" Using default link template")),e=i.uP)),e}xI(t,i,e){t instanceof Link?(i!==null&&this.kT(i,t),e!==null&&this.bT(e,t)):t instanceof Part&&(i!==null&&this.Mo.delete(i),e!==null&&this.Mo.set(e,t))}ST(){const t=this.diagram.model;this.MN(t.nodeDataArray)}MN(t){t.forEach(i=>{this.Ib(i)})}Ib(t){const i=this.findPartForData(t);i!==null&&(this.diagram.IP(i,!1),this.PN(i))}PN(t){}gN(t){}findPartForKey(t){if(t==null)return null;const i=this.b.model.findNodeDataForKey(t);return i!==null?this.Mo.get(i):null}findNodeForKey(t){if(t==null)return null;const i=this.b.model.findNodeDataForKey(t);if(i===null)return null;const e=this.Mo.get(i);return e instanceof Node?e:null}findLinkForKey(t){return null}findPartForData(t){if(t===null)return null;let i=this.Mo.get(t);return i!==null||(i=this.yl.get(t)),i}findNodeForData(t){if(t===null)return null;const i=this.Mo.get(t);return i instanceof Node?i:null}findLinkForData(t,i){return t===null?null:this.yl.get(t)}findNodesByExample(...t){const i=new GSet,e=this.ng.iterator;for(;e.next();){const s=e.value,n=s.data;if(n!==null)for(let o=0;o{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),this.parts.each(o=>{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),s.forEach(o=>t.LT(o,!1));for(let o=0;o0){for(let o=0;oi.FA(s));const e=t.wh;if(Array.isArray(e)){const s=this.Ga.get(e);if(s===null){const n=[];n.push(t),this.Ga.set(e,n)}else{for(let n=0;ni.PR(s));const e=t.wh;if(Array.isArray(e)){const s=this.Ga.get(e);if(s!==null){for(let n=0;n0&&i.removeParts(l,!1),h.count>0){const f=h.iterator;for(;f.next();){const c=f.key,u=f.value;s.set(c,u)}}}if(i!==null&&this.b!==null){const o=i.model,r=o.afterCopyFunction;if(r!==null){const l=new GMap;s.each(a=>{a.key.data!==null&&l.set(a.key.data,a.value.data)});const h=this.b.model;r(l,o,h)}}const n=s.iterator;for(;n.next();)n.value.updateTargetBindings();return s}Ob(t,i,e,s){if(t===null||s&&!t.canCopy())return null;if(e.has(t))return e.get(t);const n=this.CN(t,i);if(!(n instanceof Part))return null;if(n.isSelected=!1,n.isHighlighted=!1,e.set(t,n),t instanceof Node){const o=t.linksConnected;for(;o.next();){const r=o.value;if(r.fromNode===t){const l=e.get(r);l!==null&&(l.fromNode=n)}if(r.toNode===t){const l=e.get(r);l!==null&&(l.toNode=n)}}if(t instanceof Group&&n instanceof Group){const r=t.memberParts;for(;r.next();){const l=r.value,h=this.Ob(l,i,e,s);h instanceof Link||h!==null&&(h.containingGroup=n)}}}else if(t instanceof Link&&n instanceof Link){const o=t.fromNode;if(o!==null){const h=e.get(o);h!==null&&(n.fromNode=h)}const r=t.toNode;if(r!==null){const h=e.get(r);h!==null&&(n.toNode=h)}const l=t.labelNodes;for(;l.next();){const h=l.value,a=this.Ob(h,i,e,s);a!==null&&a instanceof Node&&(a.labeledLink=n)}}return n}CN(t,i){let e=null;const s=t.data;if(s!==null&&i!==null){const n=i.model;if(!(t instanceof Link)){const o=n.copyNodeData(s);Util.Mt(o)&&(n.addNodeData(o),e=i.findPartForData(o))}}else if(t.ci(),e=t.copy(),e!==null){const n=this.b;if(i!==null)i.add(e);else if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const o=n.model;let r=null;e instanceof Link||(r=o.copyNodeData(s)),Util.Mt(r)&&(e.data=r)}}return e}get nodes(){return this.ng}get links(){return this.Qs}get parts(){return this.It}get diagram(){return this.b}get addsToTemporaryLayer(){return this.Ty}set addsToTemporaryLayer(t){this.Ty=t}get preservesRebuildLocations(){return this.SN}set preservesRebuildLocations(t){this.SN=t}}class GraphLinksPartManager extends PartManager{EP(){const t=this.diagram.model;this.Dy(t.nodeDataArray),this.FT(t.linkDataArray)}Dy(t){super.Dy(t,!1);const i=this.links.iterator;for(;i.next();)i.value.Ed();this.diagram.R1(!1)}FT(t){t.forEach(i=>{this.RT(i)}),this.diagram.R1(!1)}RT(t){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.yl.has(t))return null;const i=this.getLinkCategoryForData(t),e=this.findLinkTemplateForCategory(i);if(e!==null){e.ci();const s=e.copy();if(s!==null){const n=this.diagram.me;this.diagram.me=!0,s.$o=i,s.si=t;const o=this.diagram.model,r=o.Eb(t,!0);r!==""&&(s.fromPortId=r);const l=o.Ee(t,!0);if(l!==void 0){const c=this.findNodeForKey(l);c instanceof Node&&(s.fromNode=c)}const h=o.Eb(t,!1);h!==""&&(s.toPortId=h);const a=o.Ee(t,!1);if(a!==void 0){const c=this.findNodeForKey(a);c instanceof Node&&(s.toNode=c)}const f=o.getLabelKeysForLinkData(t);return Array.isArray(f)&&f.forEach(c=>{const u=this.findNodeForKey(c);u!==null&&(u.labeledLink=s)}),this.Ty&&(s.ul="Tool"),this.diagram.add(s),s.si=null,s.data=t,this.diagram.me=n,s}}return null}ST(){const t=this.diagram.model;this.IT(t.linkDataArray),this.MN(t.nodeDataArray)}IT(t){t.forEach(i=>{this.Ib(i)})}getLinkCategoryForData(t){return this.diagram.model.getCategoryForLinkData(t)}setLinkCategoryForData(t,i){return this.diagram.model.setCategoryForLinkData(t,i)}setFromNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setFromKeyForLinkData(t.data,e.getKeyForNodeData(s))}setToNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setToKeyForLinkData(t.data,e.getKeyForNodeData(s))}gN(t){this.diagram.model.removeLinkData(t.data)}findPartForKey(t){const i=super.findPartForKey(t);if(i===null){const s=this.diagram.model.findLinkDataForKey(t);if(s!==null)return this.yl.get(s)}return i}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findLinkDataForKey(t);return e!==null?this.yl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.j){i.j=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="linkFromKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.fromNode=l}}else if(s==="linkToKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.toNode=l}}else if(s==="linkFromPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.fromPortId=r)}}else if(s==="linkToPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.toPortId=r)}}else if(s==="nodeGroupKey"){const n=t.object,o=this.findPartForData(n);if(o!==null){const r=t.newValue;if(r!==void 0){const l=this.findNodeForKey(r);l instanceof Group?o.containingGroup=l:o.containingGroup=null}else o.containingGroup=null}}else if(s==="linkLabelKeys"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.oldValue,l=t.newValue;Array.isArray(r)&&r.forEach(h=>{if(l.indexOf(h)>=0)return;const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=null)}),Array.isArray(l)&&l.forEach(h=>{const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=o)})}}else if(s==="linkCategory"){const n=t.object,o=this.findLinkForData(n),r=t.newValue;o!==null&&typeof r=="string"&&(o.category=r)}else if(s==="linkDataArray"){const n=t.oldValue;this.IT(n);const o=t.newValue;this.FT(o)}i.isModified=!0}else if(e===3){const n=t.newValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.RT(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=t.object,r=this.findLinkForData(o),l=this.findNodeForKey(n);r!==null&&l!==null&&(l.labeledLink=r)}i.isModified=!0}else if(e===4){const n=t.oldValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.Ib(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=this.findNodeForKey(n);o!==null&&(o.labeledLink=null)}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&(n==="linkFromKeyProperty"||n==="linkToKeyProperty"||n==="linkFromPortIdProperty"||n==="linkToPortIdProperty"||n==="linkLabelKeysProperty"||n==="nodeIsGroupProperty"||n==="nodeGroupKeyProperty"||n==="linkCategoryProperty")&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.j=!0}}}DT(){const t=this.diagram.model,i=new GSet,e=t.linkDataArray;e.forEach(n=>{i.add(n)});const s=[];this.links.each(n=>{n.data!==null&&!i.has(n.data)&&s.push(n.data)}),s.forEach(n=>{t.OT(n,!1)}),e.forEach(n=>{this.findLinkForData(n)===null&&t.ET(n,!1)})}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Link){let n=s.Ee(i,!0),o=e.findNodeForKey(n);t.fromNode=o,n=s.Ee(i,!1),o=e.findNodeForKey(n),t.toNode=o;const r=s.getLabelKeysForLinkData(i);if(r.length>0||t.labelNodes.count>0){if(r.length===1&&t.labelNodes.count===1){const c=r[0],u=t.labelNodes.first();if(s.getKeyForNodeData(u.data)===c)return}const l=new GSet().addAll(r),h=new GSet;t.labelNodes.each(c=>{if(c.data!==null){const u=s.getKeyForNodeData(c.data);u!==void 0&&h.add(u)}});const a=h.copy();a.removeAll(l);const f=l.copy();if(f.removeAll(h),a.count>0||f.count>0){const c=t;a.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink===c&&(d.labeledLink=null)}),f.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink!==c&&(d.labeledLink=c)})}}}else if(!(t instanceof Adornment)){const n=s.getGroupKeyForNodeData(i),o=e.findPartForKey(n);(o===null||o instanceof Group)&&(t.containingGroup=o)}}Rb(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Ry(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)){if(n instanceof Group&&i.getGroupKeyForNodeData(l)===e){const h=this.findPartForData(l);h!==null&&(h.containingGroup=n)}}else{const h=this.findLinkForData(l);if(h!==null&&n instanceof Node){i.Ee(l,!0)===e&&(h.fromNode=n),i.Ee(l,!1)===e&&(h.toNode=n);const a=i.getLabelKeysForLinkData(l);Array.isArray(a)&&a.some(f=>f===e?(n.labeledLink=h,!0):!1)}}}i.tn(e)}const o=i.getGroupKeyForNodeData(t);if(o!==void 0){const r=this.findNodeForKey(o);r instanceof Group&&(n.containingGroup=r)}}}PN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data);if(e!==void 0){const s=t.linksConnected;for(;s.next();){const n=s.value;i.en(e,n.data)}if(t.isLinkLabel){const n=t.labeledLink;n!==null&&i.en(e,n.data)}if(t instanceof Group){const n=t.memberParts;for(;n.next();){const r=n.value.data;i.containsNodeData(r)&&i.en(e,r)}}}}}CN(t,i){let e=super.CN(t,i);if(t instanceof Link){const s=t.data;if(s!==null&&i!==null){const n=i.model,o=n.copyLinkData(s);typeof o=="object"&&o!==null&&(n.addLinkData(o),e=i.findLinkForData(o))}else if(e!==null){const n=this.diagram;if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const r=n.model.copyLinkData(s);typeof r=="object"&&r!==null&&(e.data=r)}}}return e}insertLink(t,i,e,s){const n=this.diagram,o=n.model,r=n.toolManager.findTool("Linking");let l="";t!==null&&(i===null&&(i=t),l=i.portId,l===null&&(l=""));let h="";e!==null&&(s===null&&(s=e),h=s.portId,h===null&&(h=""));const a=r.archetypeLinkData;if(a instanceof Link){a.ci();const f=a.copy();if(f!==null){f.fromNode=t,f.fromPortId=l,f.toNode=e,f.toPortId=h,n.add(f);const c=r.archetypeLabelNodeData;if(c instanceof Node){c.ci();const u=c.copy();u!==null&&(u.labeledLink=f,n.add(u))}return f}}else if(a!==null){const f=o.copyLinkData(a);if(typeof f=="object"&&f!==null){t!==null&&o.og(f,o.getKeyForNodeData(t.data),!0),o.rg(f,l,!0),e!==null&&o.og(f,o.getKeyForNodeData(e.data),!1),o.rg(f,h,!1),o.addLinkData(f);const c=r.archetypeLabelNodeData;if(c!==null&&!(c instanceof Node)){const d=o.copyNodeData(c);if(typeof d=="object"&&d!==null){o.addNodeData(d);const m=o.getKeyForNodeData(d);m!==void 0&&o.addLabelKeyForLinkData(f,m)}}return n.findLinkForData(f)}}return null}}class TreePartManager extends PartManager{Nh=null;Vb(t,i){if(t===null||i===null||i.findTreeParentLink()!==null)return null;const e=this.diagram.toolManager.findTool("Linking");let s=t,n=i;if(this.diagram.isTreePathToChildren){if(e!==null&&e.Au(s,n,null,!0))return null}else if(s=i,n=t,e!==null&&e.Au(s,n,null,!0))return null;const o=this.getLinkCategoryForData(i.data),r=this.findLinkTemplateForCategory(o);if(r!==null){r.ci();const l=r.copy();if(l!==null){const h=this.diagram.me;return this.diagram.me=!0,l.$o=o,l.si=i.data,l.fromNode=s,l.toNode=n,this.diagram.add(l),l.si=null,l.data=i.data,this.diagram.me=h,l}}return null}getLinkCategoryForData(t){return this.diagram.model.getParentLinkCategoryForNodeData(t)}setLinkCategoryForData(t,i){this.diagram.model.setParentLinkCategoryForNodeData(t,i)}setFromNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren)s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n));else{const o=this.Nh;this.Nh=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.toNode!==null?t.toNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Nh=o}}setToNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren){const o=this.Nh;this.Nh=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.fromNode!==null?t.fromNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Nh=o}else s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n))}gN(t){this.diagram.model.setParentKeyForNodeData(t.data,void 0)}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findNodeDataForKey(t);return e!==null?this.yl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.j){i.j=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="nodeParentKey"){const n=t.object,o=t.newValue,r=this.findNodeForKey(o),l=this.findNodeForData(n);if(this.Nh!==null)r!==null&&(this.Nh.data=n,this.Nh.category=this.getLinkCategoryForData(n));else if(l!==null){const h=l.findTreeParentLink();h!==null?r===null?i.remove(h):i.isTreePathToChildren?h.fromNode=r:h.toNode=r:this.Vb(r,l)}}else if(s==="parentLinkCategory"){const n=t.object,o=this.findNodeForData(n),r=t.newValue;if(o!==null&&typeof r=="string"){const l=o.findTreeParentLink();l!==null&&(l.category=r)}}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&n==="nodeParentKeyProperty"&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.j=!0}}}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Node){const n=s.getParentKeyForNodeData(i),o=e.findNodeForKey(n),r=t.findTreeParentNode();if(o!==r){const l=t.findTreeParentLink();o!==null?l!==null?e.isTreePathToChildren?l.fromNode=o:l.toNode=o:this.Vb(o,t):l!==null&&e.IP(l,!1)}}}Fy(t,i){if(super.Fy(t,i),typeof i=="string"&&this.findPartForData(t)!==null){const s=this.findLinkForData(t);s!==null&&s.updateTargetBindings(i)}}Rb(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Ry(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)&&n instanceof Node&&i.getParentKeyForNodeData(l)===e){const h=this.findNodeForData(l);this.Vb(n,h)}}i.tn(e)}const o=i.getParentKeyForNodeData(t);if(o!==void 0&&n instanceof Node){const r=this.findNodeForKey(o);this.Vb(r,n)}}}PN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data),s=this.findLinkForData(t.data);if(s!==null){s.isSelected=!1,s.isHighlighted=!1;const r=s.layer;if(r!==null){const l=r.ne(-1,s,!1);l>=0&&this.diagram.raiseChangedEvent(4,"parts",r,s,null,l,null);const h=s.layerChanged;h!==null&&h(s,r,null)}}const n=this.diagram.isTreePathToChildren,o=t.linksConnected;for(;o.next();){const r=o.value,h=(n?r.toNode:r.fromNode).data;i.containsNodeData(h)&&i.en(e,h)}}}insertLink(t,i,e,s){const n=this.diagram.model;let o=t,r=e;if(this.diagram.isTreePathToChildren||(o=e,r=t),o!==null&&r!==null){const l=o.data,h=r.data;return n.setParentKeyForNodeData(h,n.getKeyForNodeData(l)),r.findTreeParentLink()}return null}}var BindingMode=(w=>(w[w.OneWay=1]="OneWay",w[w.TwoWay=2]="TwoWay",w))(BindingMode||{});class Binding{l;AN;Ha;Fc;Ch;Rc;Ic;Oc;Bb;Ce;Sd;pc;constructor(t,i,e,s){GSet.vi(this),t===void 0?t="":Util.t(t,"string",Binding,"constructor:targetprop"),i===void 0?i=t:Util.t(i,"string",Binding,"constructor:sourceprop"),e===void 0?e=null:e!==null&&Util.t(e,"function",Binding,"constructor:conv"),this.AN=-1,this.Ce=null,this.Ha=t,this.Sd=0,this.pc=0,this.Fc=null,this.Ch=i,this.Rc=e,s===void 0?(this.Ic=1,this.Oc=null):(this.Ic=2,this.Oc=s),this.Bb=new GSet,this.l=2}copy(){const t=new this.constructor;return this.cloneProtected(t),t}cloneProtected(t){t.Ha=this.Ha,t.Sd=this.Sd,t.pc=this.pc,t.Fc=this.Fc,t.Ch=this.Ch,t.Rc=this.Rc,t.Ic=this.Ic,t.Oc=this.Oc,t.l=this.l&-2}static OneWay=1;static TwoWay=2;static parseEnum(t,i){return Util.t(t,"function",Binding,"parseEnum:ctor"),e=>{let s=parseInt(e);return isNaN(s)&&(s=Util.zh(t,e),s===null)?i:s}}fi(t){t in BindingMode?this.mode=t:Util.ur(this,t)}static toString(t){return Util.toString(t)}toString(){return"Binding("+this.targetProperty+":"+this.sourceProperty+(this.targetId!==-1?" "+this.targetId:"")+" "+BindingMode[this.mode]+")"}w(){return this.l=this.l|1,this}ct(){return this.l=this.l&-2,this}get targetId(){return this.AN}set targetId(t){this.f&&Util.F(this),Util.t(t,"number",Binding,"targetId"),this.AN=t}get targetProperty(){return this.Ha}set targetProperty(t){this.f&&Util.F(this),Util.t(t,"string",Binding,"targetProperty"),this.Ha=t}get sourceProperty(){return this.Ch}set sourceProperty(t){this.f&&Util.F(this),Util.t(t,"string",Binding,"sourceProperty"),this.Ch=t}get f(){return(this.l&1)!==0}get isToData(){return(this.l&2)!==0}get isToObject(){return(this.l&4)!==0}get isToModel(){return(this.l&8)!==0}get isToTheme(){return(this.l&16)!==0}get LN(){return this.isToTheme&&!(this.isToData||this.isToObject||this.isToModel)}rd(){return!1}get sourceName(){return this.Fc}set sourceName(t){this.f&&Util.F(this),t!==null&&Util.t(t,"string",Binding,"sourceName"),this.Fc=t,t!==null?this.l=this.l&-3|4:this.l=this.l|2}get converter(){return this.Rc}set converter(t){this.f&&Util.F(this),t!==null&&Util.t(t,"function",Binding,"converter"),this.Rc=t}get backConverter(){return this.Oc}set backConverter(t){this.f&&Util.F(this),t!==null&&Util.t(t,"function",Binding,"backConverter"),this.Oc=t}get mode(){return this.Ic}set mode(t){this.f&&Util.F(this),this.isToTheme&&t===2&&Util.n("Theme Bindings cannot be TwoWay."),Util.tt(t,BindingMode,"BindingMode"),this.Ic=t}makeTwoWay(t){return this.isToTheme&&Util.n("Theme Bindings cannot be TwoWay."),this.mode=2,t&&(Util.t(t,"function",Binding,"makeTwoWay"),this.backConverter=t),this}ofObject(t){return this.f&&Util.F(this),t===void 0&&(t=""),Debug&&Util.t(t,"string",Binding,"ofObject:srcname"),this.sourceName=t,this}ofModel(){return this.f&&Util.F(this),this.l=this.l&-3&-5|8,this.Fc=null,this}rL(t,i){const e=this.sourceName;let s=null;return e===null||e===""?s=t:e==="/"?s=i.part:e==="."?s=i:e===".."?s=i.panel:s=t.findObject(e),s}check(t){const i=this.Ha,e=this.Ch,s=this.Rc;(this.rd()&&s===null&&this.Ah===null&&i===""||s===null&&i==="")&&Util.at("Binding error: target property is the empty string: "+this.toString()),this.rd()&&this.LN&&e===""&&s===null&&this.Ah===null&&Util.at("Binding error: theme bindings require a source property when not using a converter: "+this.toString()),t&&typeof i=="string"&&(typeof t.setAttribute!="function"&&i.length>0&&i[0]!=="_"&&!Util.yw(t,i)?Util.at("Binding error: undefined target property: "+i+" on "+t.toString()):i==="name"&&t instanceof GraphObject&&Util.at("Binding error: cannot modify GraphObject.name on "+t.toString()))}updateTarget(t,i,e){const s=this.Ch;if(e!==void 0&&s!==""&&s!==e)return;const n=this.Ha,o=this.Rc;let r=i;if(s!==""&&!this.LN&&(r=Model.Xt(i,s)),r===void 0)return;const l=t.diagram?.themeManager??t.panel?.diagram?.themeManager;if(o===null){if(n!==""){if(this.rd()&&(r=this.VT(l,r,t,n),r===void 0))return;Model.ut(t,n,r)}}else try{if(n!==""){let h=o(r,t);if(Debug&&h===void 0&&Util.at('Binding warning: conversion function returned undefined when setting target property "'+n+'" on '+t.toString()+", function is: "+o),this.rd()&&(h=this.VT(l,h,t,n),h===void 0))return;Model.ut(t,n,h)}else o(r,t)}catch(h){Debug&&Util.at("Binding error: "+h.toString()+' setting target property "'+n+'" on '+t.toString()+" with conversion function: "+o)}}updateSource(t,i,e,s){if(this.Ic!==2)return;const n=this.Ha;if(e!==void 0&&n!==e)return;const o=this.Ch,r=this.Oc;let l=t;if(n!==""&&(l=Model.Xt(t,n)),l!==void 0&&!this.Bb.has(t))try{this.Bb.add(t);const h=s!==null?s.diagram:null,a=h!==null?h.model:null;if(r===null){if(o!=="")a!==null?(Debug&&a.nodeKeyProperty===o&&a.containsNodeData(i)&&Util.at("Binding error: cannot have TwoWay Binding on node data key property: "+this.toString()),a.setDataProperty(i,o,l)):Model.ut(i,o,l);else if(a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const f=s.itemIndex,c=s.panel.itemArray;a.removeArrayItem(c,f),a.insertArrayItem(c,f,l)}}else try{if(o!==""){const f=r(l,i,a);a!==null?(Debug&&(a.nodeKeyProperty===o&&a.containsNodeData(i)&&Util.at("Binding error: cannot have TwoWay Binding on node data key property: "+this.toString()),f===void 0&&Util.at(`Binding warning: conversion function returned undefined when setting source property "${o}" on ${i.toString()}, function is: ${r}`)),a.setDataProperty(i,o,f)):Model.ut(i,o,f)}else{const f=r(l,i,a);if(f!==void 0&&a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const c=s.itemIndex,u=s.panel.itemArray;a.removeArrayItem(u,c),a.insertArrayItem(u,c,f)}}}catch(f){Debug&&Util.at("Binding error: "+f.toString()+' setting source property "'+o+'" on '+i.toString()+" with conversion function: "+r)}}finally{this.Bb.delete(t)}}}class ThemeBinding extends Binding{Iy;Ah;qa;constructor(t,i,e,s,n){super(t,i,s),e==null&&(e=""),n===void 0&&(n=null),this.Iy=e,this.Ah=n,this.qa=null,this.l=16}cloneProtected(t){super.cloneProtected(t),t.Iy=this.Iy,t.Ah=this.Ah,t.qa=this.qa}rd(){return!0}get themeSource(){return this.Iy}set themeSource(t){this.f&&Util.F(this),t!==null&&Util.t(t,"string",ThemeBinding,"themeSource"),this.Iy=t,this.qa=null,t!==null?this.l=this.l|16:this.l=this.l&-17}get themeConverter(){return this.Ah}set themeConverter(t){this.f&&Util.F(this),t!==null&&Util.t(t,"function",ThemeBinding,"themeConverter"),this.Ah=t}ofData(){return this.f&&Util.F(this),this.l=this.l|2,this.Fc=null,this}VT(t,i,e,s){if(!t||(this.LN&&(i=this.Ch),!i&&i!==0))return;let n=this.themeSource;this.qa!==null?n=this.qa:typeof n=="string"&&n.includes(".")&&(this.qa=n.split("."),n=this.qa);let o=t.findValue(i,n,s);return o===void 0&&Util.at(`Theme warning: ${i} could not be found when setting target property ${s}.`),typeof this.Ah=="function"&&(o=this.Ah(o,e)),o}}class Model{Tt;lg;zo;zb;Me;Ec;Vc;hg;ag;fg;cg;ja;lr;Xb;Bo;Yb;oi;Lh;ug=new GSet;dg=new GSet;Oy;constructor(t,i){if(GSet.vi(this),this.Tt="",this.lg="",this.zo=!1,this.zb={},this.Me=[],this.oi=new GMap,this.Lh="key",this.Ec=null,this.Vc=null,this.hg=!1,this.ag=!1,this.fg=!1,this.cg=null,this.ja="category",this.lr=new GMap,this.Oy=100,this.Xb=new List,this.Bo=!1,this.Yb=null,this.undoManager=new UndoManager,t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){t.Tt=this.Tt,t.lg=this.lg,t.zo=this.zo,t.Lh=this.Lh,t.Ec=this.Ec,t.Vc=this.Vc,t.hg=this.hg,t.ag=this.ag,t.fg=this.fg,t.Oy=this.Oy,t.cg=this.cg,t.ja=this.ja}copy(){const t=new this.constructor;return this.cloneProtected(t),t}clear(){this.Me=[],this.oi.clear(),this.lr.clear(),this.undoManager.clear()}toString(t){if(t===void 0&&(t=0),t>1)return this.toJson();{let i=(this.name!==""?this.name:"")+" Model";if(t>0){i+=` - node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n{if(u.model===e){if(u.modelChange==="nodeDataArray")u.change===3?n.add(u.newValue):u.change===4&&r.add(u.oldValue);else if(e.containsNodeData(u.object))o.add(u.object);else if(u.change===2&&(e.modelData===u.object||u.propertyName==="modelData"))s=!0;else if(u.object!==null)if(l&&l.has(u.object))l.get(u.object).each(m=>{e.containsNodeData(m)&&o.add(m)});else{if(u.object instanceof Model||e.Oa()&&e.containsLinkData(u.object))return;e.zT(u.object).each(m=>{o.add(m)})}}});const h=this.dg;h.clear(),n.each(u=>{h.add(e.getKeyForNodeData(u)),i||o.add(u)});const a=this.ug;a.clear(),r.each(u=>{a.add(e.getKeyForNodeData(u)),i&&o.add(u)});const f=e.cloneDeep(o.toArray());let c=null;return s&&(c===null&&(c={}),c.modelData=this.cloneDeep(this.modelData)),h.count>0&&(c===null&&(c={}),i?c.removedNodeKeys=h.toArray():c.insertedNodeKeys=h.toArray()),f.length>0&&(c===null&&(c={}),c.modifiedNodeData=f),a.count>0&&(c===null&&(c={}),i?c.insertedNodeKeys=a.toArray():c.removedNodeKeys=a.toArray()),a.clear(),h.clear(),c}cloneDeep(t){return this.gg(t,!0)}gg(t,i,e,s,n){if(!Util.Mt(t))return t;n||(n=[]);const o=Object.isExtensible(t);if(e||(e=new GMap),o){const h=e.get(t);if(h)return h}else{s||(s=new GMap);const h=s.iterator;for(;h.next();){const a=h.key;if(h.value===t){const c=e.get(a);if(c)return c}}}function r(h,a){if(o)h.__gohashid===void 0&&n.push(h),e.set(h,a);else{const f=GSet.cu++;e.set(f,a),s.set(f,t)}}let l;if(Array.isArray(t)){l=[],r(t,l);for(let h=0;h{delete h.__gohashid}),l}Ve(t){return JSON.stringify(t).replace(/[\u007F-\uFFFF]/g,e=>{const s="0000"+e.charCodeAt(0).toString(16);return"\\u"+s.substring(s.length-4)})}mg(){let t="";return this.name!==""&&(t+=`, - "name": `+this.Ve(this.name)),this.dataFormat!==""&&(t+=`, - "dataFormat": `+this.Ve(this.dataFormat)),this.isReadOnly&&(t+=`, + `+n.toString(t-1)}}return i}get layout(){return this.re}set layout(t){t!==null&&(this.re=t)}get vertexes(){return this.ko}get edges(){return this.Fn}createVertex(){return new LayoutVertex(this)}createEdge(){return new LayoutEdge(this)}addParts(t,i,e){if(t===null)return;i===void 0&&(i=!1),Util.t(i,"boolean",LayoutNetwork,"addParts:toplevelonly"),e===void 0&&(e=null),e===null&&(e=n=>{if(n instanceof Node)return!n.isLinkLabel;if(n instanceof Link){const o=n.fromNode;if(o===null||o.isLinkLabel)return!1;const r=n.toNode;return!(r===null||r.isLinkLabel)}return!1});const s=t.iterator;for(;s.next();){const n=s.value;if(n instanceof Node&&!(i&&!n.isTopLevel)&&n.canLayout()&&e(n))if(n instanceof Group&&n.layout===null)this.addParts(n.memberParts,!1);else{if(this.findVertex(n)!==null)continue;const o=this.createVertex();o.node=n,this.addVertex(o)}}for(s.reset();s.next();){const n=s.value;if(!(n instanceof Link)||i&&!n.isTopLevel||!n.canLayout()||!e(n)||this.findEdge(n)!==null)continue;const o=n.fromNode,r=n.toNode;if(o===null||r===null||o===r)continue;const l=this.findGroupVertex(o),h=this.findGroupVertex(r);this.linkVertexes(l,h,n)}}findGroupVertex(t){if(t===null)return null;const i=t.findVisibleNode();if(i===null)return null;let e=this.findVertex(i);if(e!==null)return e;let s=i.containingGroup;for(;s!==null;){if(e=this.findVertex(s),e!==null)return e;s=s.containingGroup}return null}addVertex(t){if(t===null)return;Debug&&Util.s(t,LayoutVertex,LayoutNetwork,"addVertex:vertex"),this.ko.add(t);const i=t.node;i!==null&&this.Ay.set(i,t),t.network=this}addNode(t){if(t===null)return null;Debug&&Util.s(t,Node,LayoutNetwork,"addNode:node");let i=this.findVertex(t);return i===null&&(i=this.createVertex(),i.node=t,this.addVertex(i)),i}deleteVertex(t){if(t!==null&&(Debug&&Util.s(t,LayoutVertex,LayoutNetwork,"deleteVertex:vertex"),this.xT(t))){let i=t.nr;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}i=t.or;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}}}xT(t){if(t===null)return!1;const i=this.ko.delete(t);if(i){const e=t.node;e!==null&&this.Ay.delete(e)}return i}deleteNode(t){if(t===null)return;Debug&&Util.s(t,Node,LayoutNetwork,"deleteNode:node");const i=this.findVertex(t);i!==null&&this.deleteVertex(i)}findVertex(t){return t===null?null:(Debug&&Util.s(t,Node,LayoutNetwork,"findVertex:node"),this.Ay.get(t))}addEdge(t){if(t===null)return;Debug&&Util.s(t,LayoutEdge,LayoutNetwork,"addEdge:edge"),this.wN(t);const i=t.toVertex;i!==null&&i.addSourceEdge(t);const e=t.fromVertex;e!==null&&e.addDestinationEdge(t)}wN(t){if(t===null)return;this.Fn.add(t);const i=t.link;i!==null&&this.findEdge(i)===null&&this.Ly.set(i,t),t.network=this}addLink(t){if(t===null)return null;Debug&&Util.s(t,Link,LayoutNetwork,"addLink:link");const i=t.fromNode,e=t.toNode;let s=this.findEdge(t);return s===null?(s=this.createEdge(),s.link=t,i!==null&&(s.fromVertex=this.addNode(i)),e!==null&&(s.toVertex=this.addNode(e)),this.addEdge(s)):(i!==null?s.fromVertex=this.addNode(i):s.fromVertex=null,e!==null?s.toVertex=this.addNode(e):s.toVertex=null),s}deleteEdge(t){if(t===null)return;Debug&&Util.s(t,LayoutEdge,LayoutNetwork,"deleteEdge:edge");const i=t.toVertex;i!==null&&i.deleteSourceEdge(t);const e=t.fromVertex;e!==null&&e.deleteDestinationEdge(t),this.xN(t)}xN(t){if(t===null)return!1;const i=this.Fn.delete(t);if(i){const e=t.link;e!==null&&this.Ly.delete(e)}return i}deleteLink(t){if(t===null)return;Debug&&Util.s(t,Link,LayoutNetwork,"deleteLink:link");const i=this.findEdge(t);i!==null&&this.deleteEdge(i)}findEdge(t){return t===null?null:(Debug&&Util.s(t,Link,LayoutNetwork,"findEdge:link"),this.Ly.get(t))}linkVertexes(t,i,e){if(t===null||i===null)return null;if(Debug&&(Util.s(t,LayoutVertex,LayoutNetwork,"linkVertexes:fromVertex"),Util.s(i,LayoutVertex,LayoutNetwork,"linkVertexes:toVertex"),e!==null&&Util.s(e,Link,LayoutNetwork,"linkVertexes:link")),t.network===this&&i.network===this){const s=this.createEdge();return s.link=e,s.fromVertex=t,s.toVertex=i,this.addEdge(s),s}return null}reverseEdge(t){if(t===null)return;Debug&&Util.s(t,LayoutEdge,LayoutNetwork,"reverseEdge:edge");const i=t.fromVertex,e=t.toVertex;i===null||e===null||(i.deleteDestinationEdge(t),e.deleteSourceEdge(t),t.reverseEdge(),i.addSourceEdge(t),e.addDestinationEdge(t))}deleteSelfEdges(){const t=Util.at(),i=this.Fn.iterator;for(;i.next();){const s=i.value;s.fromVertex===s.toVertex&&t.push(s)}const e=t.length;for(let s=0;s0||t.or.count>0)}splitIntoSubNetworks(t){t===void 0&&(t=!0),t&&(this.deleteArtificialVertexes(),this.deleteUselessEdges(),this.deleteSelfEdges());const i=new List;let e=!0;for(;e;){e=!1;const s=this.ko.iterator;for(;s.next();){const n=s.value;if(this.isSingleton(n))continue;const o=this.layout.createNetwork();i.add(o),this.AO(o,n),e=!0;break}}return i.sort((s,n)=>s===null||n===null||s===n?0:n.vertexes.count-s.vertexes.count),i}AO(t,i){if(i===null)return;const e=new List;for(e.add(i);e.count>0;){const s=e.first();if(e.removeAt(0),s.network===t)continue;this.xT(s),t.addVertex(s);let n=s.sourceEdges;for(;n.next();){const o=n.value;o.network!==t&&(this.xN(o),t.wN(o),e.add(o.fromVertex))}for(n=s.destinationEdges;n.next();){const o=n.value;o.network!==t&&(this.xN(o),t.wN(o),e.add(o.toVertex))}}}findAllParts(){const t=new GSet,i=this.ko.iterator;for(;i.next();){const s=i.value;t.add(s.node)}const e=this.Fn.iterator;for(;e.next();){const s=e.value;t.add(s.link)}return t}}class LayoutVertex{bo;si;we;Oe;Qe;nr;or;constructor(t){GSet.vi(this),Debug&&!t&&Util.n("LayoutVertex constructor requires non-null LayoutNetwork argument"),this.bo=t,this.Oe=new Rect(0,0,10,10).w(),this.Qe=new Point(5,5).w(),this.si=null,this.we=null,this.nr=new List,this.or=new List}clear(){this.si=null,this.we=null,this.nr=new List,this.or=new List}toString(t){t===void 0&&(t=0);let i="LayoutVertex#"+GSet.gs(this);if(t>0&&(i+=this.node!==null?"("+this.node.toString()+")":"",t>1)){let e="",s=!0,n=this.nr.iterator;for(;n.next();){const r=n.value;s?s=!1:e+=",",e+=r.toString(0)}let o="";for(s=!0,n=this.or.iterator;n.next();){const r=n.value;s?s=!1:o+=",",o+=r.toString(0)}i+=" sources: "+e+" destinations: "+o}return i}get So(){return this.nr.eC}get rr(){return this.or.eC}get data(){return this.si}set data(t){if(this.si=t,t!==null&&t.bounds){const i=t.bounds,e=i.x,s=i.y,n=i.width,o=i.height;this.Qe.e(n/2,o/2),this.Oe.e(e,s,n,o)}}get node(){return this.we}set node(t){if(this.we!==t){Debug&&t!==null&&Util.s(t,Node,LayoutVertex,"node"),this.we=t,t.ensureBounds();const i=this.network.layout,e=Rect.a(),s=i.getLayoutBounds(t,e);let n=s.x,o=s.y;const r=s.width,l=s.height;if(isNaN(n)&&(n=0),isNaN(o)&&(o=0),this.Oe.e(n,o,r,l),Rect.o(e),!(t instanceof Group)){const h=t.locationObject.getDocumentPoint(Spot.Center);if(h.isReal()){this.Qe.e(h.x-n,h.y-o);return}}this.Qe.e(r/2,l/2)}}get bounds(){return this.Oe}set bounds(t){this.Oe.equals(t)||(Debug&&Util.s(t,Rect,LayoutVertex,"bounds"),this.Oe.c(t))}get focus(){return this.Qe}set focus(t){this.Qe.equals(t)||(Debug&&Util.s(t,Point,LayoutVertex,"focus"),this.Qe.c(t))}get centerX(){return this.Oe.x+this.Qe.x}set centerX(t){const i=this.Oe;i.x+this.Qe.x!==t&&(Debug&&Util.r(t,LayoutVertex,"centerX"),i.ft(),i.x=t-this.Qe.x,i.w())}get centerY(){return this.Oe.y+this.Qe.y}set centerY(t){const i=this.Oe;i.y+this.Qe.y!==t&&(Debug&&Util.r(t,LayoutVertex,"centerY"),i.ft(),i.y=t-this.Qe.y,i.w())}get focusX(){return this.Qe.x}set focusX(t){const i=this.Qe;i.x!==t&&(i.ft(),i.x=t,i.w())}get focusY(){return this.Qe.y}set focusY(t){const i=this.Qe;i.y!==t&&(i.ft(),i.y=t,i.w())}get x(){return this.Oe.x}set x(t){const i=this.Oe;i.x!==t&&(i.ft(),i.x=t,i.w())}get y(){return this.Oe.y}set y(t){const i=this.Oe;i.y!==t&&(i.ft(),i.y=t,i.w())}get width(){return this.Oe.width}set width(t){const i=this.Oe;i.width!==t&&(i.ft(),i.width=t,i.w())}get height(){return this.Oe.height}set height(t){const i=this.Oe;i.height!==t&&(i.ft(),i.height=t,i.w())}commit(){const t=this.si;if(t!==null){const e=this.bounds,s=t.bounds;Util.Mt(s)?(s.x=e.x,s.y=e.y,s.width=e.width,s.height=e.height):t.bounds=e.copy();return}const i=this.node;if(i!==null){const e=this.bounds;if(!(i instanceof Group)){const s=Rect.a();i.ensureBounds();const n=this.network.layout.getLayoutBounds(i,s),o=i.locationObject.getDocumentPoint(Spot.Center);if(n.isReal()&&o.isReal()){i.moveTo(e.x+this.focusX-(o.x-n.x)+i.margin.left,e.y+this.focusY-(o.y-n.y+i.margin.top)),Rect.o(s);return}Rect.o(s)}i.moveTo(e.x+i.margin.left,e.y+i.margin.top)}}addSourceEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"addSourceEdge:edge"),this.nr.has(t)||this.nr.add(t))}deleteSourceEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"deleteSourceEdge:edge"),this.nr.delete(t))}addDestinationEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"addDestinationEdge:edge"),this.or.has(t)||this.or.add(t))}deleteDestinationEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"deleteDestinationEdge:edge"),this.or.delete(t))}get network(){return this.bo}set network(t){Debug&&Util.s(t,LayoutNetwork,LayoutVertex,"network"),this.bo=t}get sourceVertexes(){const t=new GSet,i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}return t.iterator}get destinationVertexes(){const t=new GSet,i=this.destinationEdges;for(;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get vertexes(){const t=new GSet;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get sourceEdges(){return this.nr.iterator}get destinationEdges(){return this.or.iterator}get edges(){const t=new List;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e)}return t.iterator}get edgesCount(){return this.nr.count+this.or.count}static standardComparer(t,i){Debug&&Util.s(t,LayoutVertex,LayoutVertex,"standardComparer:m"),Debug&&Util.s(i,LayoutVertex,LayoutVertex,"standardComparer:n");const e=t.we,s=i.we;if(e)if(s){const n=e.text,o=s.text;return no?1:0}else return 1;else return s!==null?-1:0}static smartComparer(t,i){if(Debug&&Util.s(t,LayoutVertex,LayoutVertex,"smartComparer:m"),Debug&&Util.s(i,LayoutVertex,LayoutVertex,"smartComparer:n"),t!==null)if(i!==null){const e=t.we,s=i.we;if(e!==null)if(s!==null){const n=e.text.toLocaleLowerCase(),o=s.text.toLocaleLowerCase(),r=n.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),l=o.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let h=0;for(;h0&&(i+=this.$e!==null?"("+this.$e.toString()+")":"",t>1&&(i+=" "+(this._e?this._e.toString():"null")+" --> "+(this.ts?this.ts.toString():"null"))),i}reverseEdge(){const t=this._e;this._e=this.ts,this.ts=t}commit(){}getOtherVertex(t){return Debug&&Util.s(t,LayoutVertex,LayoutEdge,"getOtherVertex:v"),this.ts===t?this._e:this._e===t?this.ts:null}get network(){return this.bo}set network(t){Debug&&Util.s(t,LayoutNetwork,LayoutEdge,"network"),this.bo=t}get data(){return this.si}set data(t){this.si!==t&&(Debug&&t!==null&&Util.t(t,"object",LayoutEdge,"data"),this.si=t)}get link(){return this.$e}set link(t){this.$e!==t&&(Debug&&t!==null&&Util.s(t,Link,LayoutEdge,"link"),this.$e=t)}get fromVertex(){return this._e}set fromVertex(t){this._e!==t&&(Debug&&t!==null&&Util.s(t,LayoutVertex,LayoutEdge,"fromVertex"),this._e=t)}get toVertex(){return this.ts}set toVertex(t){this.ts!==t&&(Debug&&t!==null&&Util.s(t,LayoutVertex,LayoutEdge,"toVertex"),this.ts=t)}}var GridAlignment=(w=>(w[w.Position=0]="Position",w[w.Location=1]="Location",w))(GridAlignment||{}),GridArrangement=(w=>(w[w.LeftToRight=10]="LeftToRight",w[w.RightToLeft=11]="RightToLeft",w))(GridArrangement||{}),GridSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w))(GridSorting||{});class GridLayout extends Layout{ig;eg;Ro;Rn;ai;qi;ke;Se;constructor(t){super(),this.isViewportSized=!0,this.ig=NaN,this.eg=NaN,this.Ro=new Size(NaN,NaN).w(),this.Rn=new Size(10,10).w(),this.ai=1,this.qi=10,this.ke=22,this.Se=GridLayout.standardComparer,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.ig=this.ig,t.eg=this.eg,t.Ro.c(this.Ro),t.Rn.c(this.Rn),t.ai=this.ai,t.qi=this.qi,t.ke=this.ke,t.Se=this.Se}fi(t){t in GridSorting?this.sorting=t:t in GridArrangement?this.arrangement=t:t in GridAlignment?this.alignment=t:super.fi(t)}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.collectParts(t),e=this.diagram,n=i.copy().iterator;for(;n.next();){const m=n.value;if(m.Dl()&&(m.fromNode!==null||m.toNode!==null)){i.delete(m);continue}if(m.ensureBounds(),m instanceof Group){const g=m.memberParts;for(;g.next();){const p=g.value;i.delete(p)}}}const o=i.toArray();if(o.length===0)return;switch(this.sorting){case 20:break;case 21:o.reverse();break;case 22:o.sort(this.comparer);break;case 23:o.sort(this.comparer),o.reverse();break}let r=this.wrappingColumn;isNaN(r)&&(r=0);let l=this.wrappingWidth;if(isNaN(l)&&e!==null){const m=e.viewportBounds,g=e.padding;l=Math.max(m.width-g.left-g.right,0)}else l=Math.max(this.wrappingWidth,0);r<=0&&l<=0&&(r=1);let h=this.spacing.width;isFinite(h)||(h=0);let a=this.spacing.height;isFinite(a)||(a=0),e!==null&&e.startTransaction("Layout");const f=[];switch(this.alignment){case 0:this.LO(o,l,r,h,a,f);break;case 1:this.TO(o,l,r,h,a,f);break}let c=0,u=0,d=0;for(let m=0;m0&&m>e-1||i>0&&m>0&&A-f>i)&&(o.push(new Rect(0,d,i+s,g)),m=0,u=f,d+=g,g=0),g=Math.max(g,M);let C=0;switch(a){case 11:C=-x.width;break;default:C=0;break}switch(y.moveTo(u+C+y.margin.left,d+y.margin.top),a){case 11:u-=S;break;default:u+=S;break}m++}o.push(new Rect(0,d,i+s,g)),Rect.o(r)}TO(t,i,e,s,n,o){const r=Rect.a();let l=Math.max(this.cellSize.width,1),h=0,a=0,f=0;const c=Point.a();for(let C=0;C=h&&(i-=h);let x=0,k=0;const b=Math.max(this.cellSize.height,1);f=0;let S=0,M=!0;const A=Point.a();for(let C=0;C0)switch(u){case 11:{let D=(g-d-(N.width-T.x))/l;Geo.q(Math.round(D),D)?D=Math.round(D):D=Math.floor(D),g=D*l+d;break}default:{let D=(g-d+T.x)/l;Geo.q(Math.round(D),D)?D=Math.round(D):D=Math.ceil(D),g=D*l+d;break}}else switch(u){case 11:x=g+T.x+N.width;break;default:x=g-T.x;break}let L=0;switch(u){case 11:L=-(g+T.x)+x;break;default:L=g+N.width-T.x-x;break}if(e>0&&y>e-1||i>0&&y>0&&L>i){o.push(new Rect(0,M?p-f:p,i+s,S+f+n));for(let D=0;Dk&&(P.width+=P.x-k,P.x=k)}Rect.o(r)}commitLayers(t,i){}get wrappingWidth(){return this.ig}set wrappingWidth(t){this.ig!==t&&(Util.t(t,"number",GridLayout,"wrappingWidth"),(t>0||isNaN(t))&&(this.ig=t,this.isViewportSized=isNaN(t),this.invalidateLayout()))}get wrappingColumn(){return this.eg}set wrappingColumn(t){this.eg!==t&&(Util.t(t,"number",GridLayout,"wrappingColumn"),(t>0||isNaN(t))&&(this.eg=t,this.invalidateLayout()))}get cellSize(){return this.Ro}set cellSize(t){Util.s(t,Size,GridLayout,"cellSize"),this.Ro.equals(t)||(this.Ro.c(t),this.invalidateLayout())}get spacing(){return this.Rn}set spacing(t){Util.s(t,Size,GridLayout,"spacing"),this.Rn.equals(t)||(this.Rn.c(t),this.invalidateLayout())}get alignment(){return this.ai}set alignment(t){this.ai!==t&&(Util.tt(t,GridAlignment,"GridAlignment"),(t===1||t===0)&&(this.ai=t,this.invalidateLayout()))}get arrangement(){return this.qi}set arrangement(t){this.qi!==t&&(Util.tt(t,GridArrangement,"GridArrangement"),(t===10||t===11)&&(this.qi=t,this.invalidateLayout()))}get sorting(){return this.ke}set sorting(t){this.ke!==t&&(Util.tt(t,GridSorting,"GridSorting"),(t===20||t===21||t===22||t===23)&&(this.ke=t,this.invalidateLayout()))}get comparer(){return this.Se}set comparer(t){this.Se!==t&&(Util.t(t,"function",GridLayout,"comparer"),this.Se=t,this.invalidateLayout())}static standardComparer(t,i){Debug&&Util.s(t,Part,GridLayout,"standardComparer:a"),Debug&&Util.s(i,Part,GridLayout,"standardComparer:b");const e=t.text,s=i.text;return es?1:0}static smartComparer(t,i){if(Debug&&Util.s(t,Part,GridLayout,"standardComparer:a"),Debug&&Util.s(i,Part,GridLayout,"standardComparer:b"),t!==null)if(i!==null){const e=t.text.toLocaleLowerCase(),s=i.text.toLocaleLowerCase(),n=e.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),o=s.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let r=0;for(;r{e.containsNodeData(s)&&this.MT(s,!1)}),t.forEach(s=>{e.containsNodeData(s)&&this.Rb(s)}),i!==!1&&this.diagram.R1(!1)}MT(t,i){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.Mo.has(t))return null;i===void 0&&(i=!0);const e=this.DO(t);return e!==null&&i&&this.Rb(t),e}DO(t){if(t==null||this.b.undoManager.isUndoingRedoing||this.Mo.has(t))return null;const i=this.FO(t),e=this.findTemplateForNodeData(t,i);if(e!==null){e.ci();const s=e.copy();if(s!==null){const n=this.diagram.pe;return this.diagram.pe=!0,s.$o=i,s.si=t,this.Ty&&(s.ul="Tool"),this.diagram.add(s),s.si=null,s.data=t,this.diagram.pe=n,s}}return null}insertLink(t,i,e,s){return null}Rb(t){}FO(t){return this.b.model.getCategoryForNodeData(t)}static PT=!1;static NT=!1;findTemplateForNodeData(t,i){const e=this.b,s=e.model,n=s.ga()&&s.isGroupForData(t);let o=null;return n?(o=e.groupTemplateMap.get(i),o===null&&(o=e.groupTemplateMap.get(""),o===null&&(PartManager.NT||(PartManager.NT=!0,Util.ht('No Group template found for category "'+i+'"'),Util.ht(" Using default group template")),o=e.gP))):(o=e.nodeTemplateMap.get(i),o===null&&(o=e.nodeTemplateMap.get(""),o===null&&(PartManager.PT||(PartManager.PT=!0,Util.ht('No Node template found for category "'+i+'"'),Util.ht(" Using default node template")),o=e.cP))),o}getLinkCategoryForData(t){return""}setLinkCategoryForData(t,i){}setFromNodeForLink(t,i,e){}setToNodeForLink(t,i,e){}static CT=!1;findLinkTemplateForCategory(t){const i=this.b;let e=i.linkTemplateMap.get(t);return e===null&&(e=i.linkTemplateMap.get(""),e===null&&(PartManager.CT||(PartManager.CT=!0,Util.ht('No Link template found for category "'+t+'"'),Util.ht(" Using default link template")),e=i.uP)),e}wI(t,i,e){t instanceof Link?(i!==null&&this.kT(i,t),e!==null&&this.bT(e,t)):t instanceof Part&&(i!==null&&this.Mo.delete(i),e!==null&&this.Mo.set(e,t))}ST(){const t=this.diagram.model;this.kN(t.nodeDataArray)}kN(t){t.forEach(i=>{this.Ib(i)})}Ib(t){const i=this.findPartForData(t);i!==null&&(this.diagram.IP(i,!1),this.SN(i))}SN(t){}uN(t){}findPartForKey(t){if(t==null)return null;const i=this.b.model.findNodeDataForKey(t);return i!==null?this.Mo.get(i):null}findNodeForKey(t){if(t==null)return null;const i=this.b.model.findNodeDataForKey(t);if(i===null)return null;const e=this.Mo.get(i);return e instanceof Node?e:null}findLinkForKey(t){return null}findPartForData(t){if(t===null)return null;let i=this.Mo.get(t);return i!==null||(i=this.yl.get(t)),i}findNodeForData(t){if(t===null)return null;const i=this.Mo.get(t);return i instanceof Node?i:null}findLinkForData(t,i){return t===null?null:this.yl.get(t)}findNodesByExample(...t){const i=new GSet,e=this.sg.iterator;for(;e.next();){const s=e.value,n=s.data;if(n!==null)for(let o=0;o{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),this.parts.each(o=>{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),s.forEach(o=>t.LT(o,!1));for(let o=0;o0){for(let o=0;oi.DA(s));const e=t.xh;if(Array.isArray(e)){const s=this.Ha.get(e);if(s===null){const n=[];n.push(t),this.Ha.set(e,n)}else{for(let n=0;ni.SR(s));const e=t.xh;if(Array.isArray(e)){const s=this.Ha.get(e);if(s!==null){for(let n=0;n0&&i.removeParts(l,!1),h.count>0){const f=h.iterator;for(;f.next();){const c=f.key,u=f.value;s.set(c,u)}}}if(i!==null&&this.b!==null){const o=i.model,r=o.afterCopyFunction;if(r!==null){const l=new GMap;s.each(a=>{a.key.data!==null&&l.set(a.key.data,a.value.data)});const h=this.b.model;r(l,o,h)}}const n=s.iterator;for(;n.next();)n.value.updateTargetBindings();return s}Ob(t,i,e,s){if(t===null||s&&!t.canCopy())return null;if(e.has(t))return e.get(t);const n=this.PN(t,i);if(!(n instanceof Part))return null;if(n.isSelected=!1,n.isHighlighted=!1,e.set(t,n),t instanceof Node){const o=t.linksConnected;for(;o.next();){const r=o.value;if(r.fromNode===t){const l=e.get(r);l!==null&&(l.fromNode=n)}if(r.toNode===t){const l=e.get(r);l!==null&&(l.toNode=n)}}if(t instanceof Group&&n instanceof Group){const r=t.memberParts;for(;r.next();){const l=r.value,h=this.Ob(l,i,e,s);h instanceof Link||h!==null&&(h.containingGroup=n)}}}else if(t instanceof Link&&n instanceof Link){const o=t.fromNode;if(o!==null){const h=e.get(o);h!==null&&(n.fromNode=h)}const r=t.toNode;if(r!==null){const h=e.get(r);h!==null&&(n.toNode=h)}const l=t.labelNodes;for(;l.next();){const h=l.value,a=this.Ob(h,i,e,s);a!==null&&a instanceof Node&&(a.labeledLink=n)}}return n}PN(t,i){let e=null;const s=t.data;if(s!==null&&i!==null){const n=i.model;if(!(t instanceof Link)){const o=n.copyNodeData(s);Util.Mt(o)&&(n.addNodeData(o),e=i.findPartForData(o))}}else if(t.ci(),e=t.copy(),e!==null){const n=this.b;if(i!==null)i.add(e);else if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const o=n.model;let r=null;e instanceof Link||(r=o.copyNodeData(s)),Util.Mt(r)&&(e.data=r)}}return e}get nodes(){return this.sg}get links(){return this.Qs}get parts(){return this.It}get diagram(){return this.b}get addsToTemporaryLayer(){return this.Ty}set addsToTemporaryLayer(t){this.Ty=t}get preservesRebuildLocations(){return this.bN}set preservesRebuildLocations(t){this.bN=t}}class GraphLinksPartManager extends PartManager{EP(){const t=this.diagram.model;this.Dy(t.nodeDataArray),this.FT(t.linkDataArray)}Dy(t){super.Dy(t,!1);const i=this.links.iterator;for(;i.next();)i.value.Od();this.diagram.R1(!1)}FT(t){t.forEach(i=>{this.RT(i)}),this.diagram.R1(!1)}RT(t){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.yl.has(t))return null;const i=this.getLinkCategoryForData(t),e=this.findLinkTemplateForCategory(i);if(e!==null){e.ci();const s=e.copy();if(s!==null){const n=this.diagram.pe;this.diagram.pe=!0,s.$o=i,s.si=t;const o=this.diagram.model,r=o.Eb(t,!0);r!==""&&(s.fromPortId=r);const l=o.Ee(t,!0);if(l!==void 0){const c=this.findNodeForKey(l);c instanceof Node&&(s.fromNode=c)}const h=o.Eb(t,!1);h!==""&&(s.toPortId=h);const a=o.Ee(t,!1);if(a!==void 0){const c=this.findNodeForKey(a);c instanceof Node&&(s.toNode=c)}const f=o.getLabelKeysForLinkData(t);return Array.isArray(f)&&f.forEach(c=>{const u=this.findNodeForKey(c);u!==null&&(u.labeledLink=s)}),this.Ty&&(s.ul="Tool"),this.diagram.add(s),s.si=null,s.data=t,this.diagram.pe=n,s}}return null}ST(){const t=this.diagram.model;this.IT(t.linkDataArray),this.kN(t.nodeDataArray)}IT(t){t.forEach(i=>{this.Ib(i)})}getLinkCategoryForData(t){return this.diagram.model.getCategoryForLinkData(t)}setLinkCategoryForData(t,i){return this.diagram.model.setCategoryForLinkData(t,i)}setFromNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setFromKeyForLinkData(t.data,e.getKeyForNodeData(s))}setToNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setToKeyForLinkData(t.data,e.getKeyForNodeData(s))}uN(t){this.diagram.model.removeLinkData(t.data)}findPartForKey(t){const i=super.findPartForKey(t);if(i===null){const s=this.diagram.model.findLinkDataForKey(t);if(s!==null)return this.yl.get(s)}return i}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findLinkDataForKey(t);return e!==null?this.yl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.j){i.j=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="linkFromKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.fromNode=l}}else if(s==="linkToKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.toNode=l}}else if(s==="linkFromPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.fromPortId=r)}}else if(s==="linkToPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.toPortId=r)}}else if(s==="nodeGroupKey"){const n=t.object,o=this.findPartForData(n);if(o!==null){const r=t.newValue;if(r!==void 0){const l=this.findNodeForKey(r);l instanceof Group?o.containingGroup=l:o.containingGroup=null}else o.containingGroup=null}}else if(s==="linkLabelKeys"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.oldValue,l=t.newValue;Array.isArray(r)&&r.forEach(h=>{if(l.indexOf(h)>=0)return;const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=null)}),Array.isArray(l)&&l.forEach(h=>{const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=o)})}}else if(s==="linkCategory"){const n=t.object,o=this.findLinkForData(n),r=t.newValue;o!==null&&typeof r=="string"&&(o.category=r)}else if(s==="linkDataArray"){const n=t.oldValue;this.IT(n);const o=t.newValue;this.FT(o)}i.isModified=!0}else if(e===3){const n=t.newValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.RT(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=t.object,r=this.findLinkForData(o),l=this.findNodeForKey(n);r!==null&&l!==null&&(l.labeledLink=r)}i.isModified=!0}else if(e===4){const n=t.oldValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.Ib(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=this.findNodeForKey(n);o!==null&&(o.labeledLink=null)}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&(n==="linkFromKeyProperty"||n==="linkToKeyProperty"||n==="linkFromPortIdProperty"||n==="linkToPortIdProperty"||n==="linkLabelKeysProperty"||n==="nodeIsGroupProperty"||n==="nodeGroupKeyProperty"||n==="linkCategoryProperty")&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.j=!0}}}DT(){const t=this.diagram.model,i=new GSet,e=t.linkDataArray;e.forEach(n=>{i.add(n)});const s=[];this.links.each(n=>{n.data!==null&&!i.has(n.data)&&s.push(n.data)}),s.forEach(n=>{t.OT(n,!1)}),e.forEach(n=>{this.findLinkForData(n)===null&&t.ET(n,!1)})}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Link){let n=s.Ee(i,!0),o=e.findNodeForKey(n);t.fromNode=o,n=s.Ee(i,!1),o=e.findNodeForKey(n),t.toNode=o;const r=s.getLabelKeysForLinkData(i);if(r.length>0||t.labelNodes.count>0){if(r.length===1&&t.labelNodes.count===1){const c=r[0],u=t.labelNodes.first();if(s.getKeyForNodeData(u.data)===c)return}const l=new GSet().addAll(r),h=new GSet;t.labelNodes.each(c=>{if(c.data!==null){const u=s.getKeyForNodeData(c.data);u!==void 0&&h.add(u)}});const a=h.copy();a.removeAll(l);const f=l.copy();if(f.removeAll(h),a.count>0||f.count>0){const c=t;a.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink===c&&(d.labeledLink=null)}),f.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink!==c&&(d.labeledLink=c)})}}}else if(!(t instanceof Adornment)){const n=s.getGroupKeyForNodeData(i),o=e.findPartForKey(n);(o===null||o instanceof Group)&&(t.containingGroup=o)}}Rb(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Ry(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)){if(n instanceof Group&&i.getGroupKeyForNodeData(l)===e){const h=this.findPartForData(l);h!==null&&(h.containingGroup=n)}}else{const h=this.findLinkForData(l);if(h!==null&&n instanceof Node){i.Ee(l,!0)===e&&(h.fromNode=n),i.Ee(l,!1)===e&&(h.toNode=n);const a=i.getLabelKeysForLinkData(l);Array.isArray(a)&&a.some(f=>f===e?(n.labeledLink=h,!0):!1)}}}i.tn(e)}const o=i.getGroupKeyForNodeData(t);if(o!==void 0){const r=this.findNodeForKey(o);r instanceof Group&&(n.containingGroup=r)}}}SN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data);if(e!==void 0){const s=t.linksConnected;for(;s.next();){const n=s.value;i.en(e,n.data)}if(t.isLinkLabel){const n=t.labeledLink;n!==null&&i.en(e,n.data)}if(t instanceof Group){const n=t.memberParts;for(;n.next();){const r=n.value.data;i.containsNodeData(r)&&i.en(e,r)}}}}}PN(t,i){let e=super.PN(t,i);if(t instanceof Link){const s=t.data;if(s!==null&&i!==null){const n=i.model,o=n.copyLinkData(s);typeof o=="object"&&o!==null&&(n.addLinkData(o),e=i.findLinkForData(o))}else if(e!==null){const n=this.diagram;if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const r=n.model.copyLinkData(s);typeof r=="object"&&r!==null&&(e.data=r)}}}return e}insertLink(t,i,e,s){const n=this.diagram,o=n.model,r=n.toolManager.findTool("Linking");let l="";t!==null&&(i===null&&(i=t),l=i.portId,l===null&&(l=""));let h="";e!==null&&(s===null&&(s=e),h=s.portId,h===null&&(h=""));const a=r.archetypeLinkData;if(a instanceof Link){a.ci();const f=a.copy();if(f!==null){f.fromNode=t,f.fromPortId=l,f.toNode=e,f.toPortId=h,n.add(f);const c=r.archetypeLabelNodeData;if(c instanceof Node){c.ci();const u=c.copy();u!==null&&(u.labeledLink=f,n.add(u))}return f}}else if(a!==null){const f=o.copyLinkData(a);if(typeof f=="object"&&f!==null){t!==null&&o.ng(f,o.getKeyForNodeData(t.data),!0),o.og(f,l,!0),e!==null&&o.ng(f,o.getKeyForNodeData(e.data),!1),o.og(f,h,!1),o.addLinkData(f);const c=r.archetypeLabelNodeData;if(c!==null&&!(c instanceof Node)){const d=o.copyNodeData(c);if(typeof d=="object"&&d!==null){o.addNodeData(d);const m=o.getKeyForNodeData(d);m!==void 0&&o.addLabelKeyForLinkData(f,m)}}return n.findLinkForData(f)}}return null}}class TreePartManager extends PartManager{Ch=null;Bb(t,i){if(t===null||i===null||i.findTreeParentLink()!==null)return null;const e=this.diagram.toolManager.findTool("Linking");let s=t,n=i;if(this.diagram.isTreePathToChildren){if(e!==null&&e.Cu(s,n,null,!0))return null}else if(s=i,n=t,e!==null&&e.Cu(s,n,null,!0))return null;const o=this.getLinkCategoryForData(i.data),r=this.findLinkTemplateForCategory(o);if(r!==null){r.ci();const l=r.copy();if(l!==null){const h=this.diagram.pe;return this.diagram.pe=!0,l.$o=o,l.si=i.data,l.fromNode=s,l.toNode=n,this.diagram.add(l),l.si=null,l.data=i.data,this.diagram.pe=h,l}}return null}getLinkCategoryForData(t){return this.diagram.model.getParentLinkCategoryForNodeData(t)}setLinkCategoryForData(t,i){this.diagram.model.setParentLinkCategoryForNodeData(t,i)}setFromNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren)s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n));else{const o=this.Ch;this.Ch=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.toNode!==null?t.toNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Ch=o}}setToNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren){const o=this.Ch;this.Ch=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.fromNode!==null?t.fromNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Ch=o}else s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n))}uN(t){this.diagram.model.setParentKeyForNodeData(t.data,void 0)}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findNodeDataForKey(t);return e!==null?this.yl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.j){i.j=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="nodeParentKey"){const n=t.object,o=t.newValue,r=this.findNodeForKey(o),l=this.findNodeForData(n);if(this.Ch!==null)r!==null&&(this.Ch.data=n,this.Ch.category=this.getLinkCategoryForData(n));else if(l!==null){const h=l.findTreeParentLink();h!==null?r===null?i.remove(h):i.isTreePathToChildren?h.fromNode=r:h.toNode=r:this.Bb(r,l)}}else if(s==="parentLinkCategory"){const n=t.object,o=this.findNodeForData(n),r=t.newValue;if(o!==null&&typeof r=="string"){const l=o.findTreeParentLink();l!==null&&(l.category=r)}}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&n==="nodeParentKeyProperty"&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.j=!0}}}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Node){const n=s.getParentKeyForNodeData(i),o=e.findNodeForKey(n),r=t.findTreeParentNode();if(o!==r){const l=t.findTreeParentLink();o!==null?l!==null?e.isTreePathToChildren?l.fromNode=o:l.toNode=o:this.Bb(o,t):l!==null&&e.IP(l,!1)}}}Fy(t,i){if(super.Fy(t,i),typeof i=="string"&&this.findPartForData(t)!==null){const s=this.findLinkForData(t);s!==null&&s.updateTargetBindings(i)}}Rb(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Ry(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)&&n instanceof Node&&i.getParentKeyForNodeData(l)===e){const h=this.findNodeForData(l);this.Bb(n,h)}}i.tn(e)}const o=i.getParentKeyForNodeData(t);if(o!==void 0&&n instanceof Node){const r=this.findNodeForKey(o);this.Bb(r,n)}}}SN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data),s=this.findLinkForData(t.data);if(s!==null){s.isSelected=!1,s.isHighlighted=!1;const r=s.layer;if(r!==null){const l=r.oe(-1,s,!1);l>=0&&this.diagram.raiseChangedEvent(4,"parts",r,s,null,l,null);const h=s.layerChanged;h!==null&&h(s,r,null)}}const n=this.diagram.isTreePathToChildren,o=t.linksConnected;for(;o.next();){const r=o.value,h=(n?r.toNode:r.fromNode).data;i.containsNodeData(h)&&i.en(e,h)}}}insertLink(t,i,e,s){const n=this.diagram.model;let o=t,r=e;if(this.diagram.isTreePathToChildren||(o=e,r=t),o!==null&&r!==null){const l=o.data,h=r.data;return n.setParentKeyForNodeData(h,n.getKeyForNodeData(l)),r.findTreeParentLink()}return null}}var BindingMode=(w=>(w[w.OneWay=1]="OneWay",w[w.TwoWay=2]="TwoWay",w))(BindingMode||{});class Binding{l;NN;qa;Rc;Ah;Ic;Oc;Ec;Vb;Ce;kd;yc;constructor(t,i,e,s){GSet.vi(this),t===void 0?t="":Util.t(t,"string",Binding,"constructor:targetprop"),i===void 0?i=t:Util.t(i,"string",Binding,"constructor:sourceprop"),e===void 0?e=null:e!==null&&Util.t(e,"function",Binding,"constructor:conv"),this.NN=-1,this.Ce=null,this.qa=t,this.kd=0,this.yc=0,this.Rc=null,this.Ah=i,this.Ic=e,s===void 0?(this.Oc=1,this.Ec=null):(this.Oc=2,this.Ec=s),this.Vb=new GSet,this.l=2}copy(){const t=new this.constructor;return this.cloneProtected(t),t}cloneProtected(t){t.qa=this.qa,t.kd=this.kd,t.yc=this.yc,t.Rc=this.Rc,t.Ah=this.Ah,t.Ic=this.Ic,t.Oc=this.Oc,t.Ec=this.Ec,t.l=this.l&-2}static OneWay=1;static TwoWay=2;static parseEnum(t,i){return Util.t(t,"function",Binding,"parseEnum:ctor"),e=>{let s=parseInt(e);return isNaN(s)&&(s=Util.Xh(t,e),s===null)?i:s}}fi(t){t in BindingMode?this.mode=t:Util.ur(this,t)}static toString(t){return Util.toString(t)}toString(){return"Binding("+this.targetProperty+":"+this.sourceProperty+(this.targetId!==-1?" "+this.targetId:"")+" "+BindingMode[this.mode]+")"}w(){return this.l=this.l|1,this}ft(){return this.l=this.l&-2,this}get targetId(){return this.NN}set targetId(t){this.f&&Util.F(this),Util.t(t,"number",Binding,"targetId"),this.NN=t}get targetProperty(){return this.qa}set targetProperty(t){this.f&&Util.F(this),Util.t(t,"string",Binding,"targetProperty"),this.qa=t}get sourceProperty(){return this.Ah}set sourceProperty(t){this.f&&Util.F(this),Util.t(t,"string",Binding,"sourceProperty"),this.Ah=t}get f(){return(this.l&1)!==0}get isToData(){return(this.l&2)!==0}get isToObject(){return(this.l&4)!==0}get isToModel(){return(this.l&8)!==0}get isToTheme(){return(this.l&16)!==0}get CN(){return this.isToTheme&&!(this.isToData||this.isToObject||this.isToModel)}od(){return!1}get sourceName(){return this.Rc}set sourceName(t){this.f&&Util.F(this),t!==null&&Util.t(t,"string",Binding,"sourceName"),this.Rc=t,t!==null?this.l=this.l&-3|4:this.l=this.l|2}get converter(){return this.Ic}set converter(t){this.f&&Util.F(this),t!==null&&Util.t(t,"function",Binding,"converter"),this.Ic=t}get backConverter(){return this.Ec}set backConverter(t){this.f&&Util.F(this),t!==null&&Util.t(t,"function",Binding,"backConverter"),this.Ec=t}get mode(){return this.Oc}set mode(t){this.f&&Util.F(this),this.isToTheme&&t===2&&Util.n("Theme Bindings cannot be TwoWay."),Util.tt(t,BindingMode,"BindingMode"),this.Oc=t}makeTwoWay(t){return this.isToTheme&&Util.n("Theme Bindings cannot be TwoWay."),this.mode=2,t&&(Util.t(t,"function",Binding,"makeTwoWay"),this.backConverter=t),this}ofObject(t){return this.f&&Util.F(this),t===void 0&&(t=""),Debug&&Util.t(t,"string",Binding,"ofObject:srcname"),this.sourceName=t,this}ofModel(){return this.f&&Util.F(this),this.l=this.l&-3&-5|8,this.Rc=null,this}oL(t,i){const e=this.sourceName;let s=null;return e===null||e===""?s=t:e==="/"?s=i.part:e==="."?s=i:e===".."?s=i.panel:s=t.findObject(e),s}check(t){const i=this.qa,e=this.Ah,s=this.Ic;(this.od()&&s===null&&this.Lh===null&&i===""||s===null&&i==="")&&Util.ht("Binding error: target property is the empty string: "+this.toString()),this.od()&&this.CN&&e===""&&s===null&&this.Lh===null&&Util.ht("Binding error: theme bindings require a source property when not using a converter: "+this.toString()),t&&typeof i=="string"&&(typeof t.setAttribute!="function"&&i.length>0&&i[0]!=="_"&&!Util.yw(t,i)?Util.ht("Binding error: undefined target property: "+i+" on "+t.toString()):i==="name"&&t instanceof GraphObject&&Util.ht("Binding error: cannot modify GraphObject.name on "+t.toString()))}updateTarget(t,i,e){const s=this.Ah;if(e!==void 0&&s!==""&&s!==e)return;const n=this.qa,o=this.Ic;let r=i;if(s!==""&&!this.CN&&(r=Model.Xt(i,s)),r===void 0)return;const l=t.diagram?.themeManager??t.panel?.diagram?.themeManager;if(o===null){if(n!==""){if(this.od()&&(r=this.BT(l,r,t,n),r===void 0))return;Model.ct(t,n,r)}}else try{if(n!==""){let h=o(r,t);if(Debug&&h===void 0&&Util.ht('Binding warning: conversion function returned undefined when setting target property "'+n+'" on '+t.toString()+", function is: "+o),this.od()&&(h=this.BT(l,h,t,n),h===void 0))return;Model.ct(t,n,h)}else o(r,t)}catch(h){Debug&&Util.ht("Binding error: "+h.toString()+' setting target property "'+n+'" on '+t.toString()+" with conversion function: "+o)}}updateSource(t,i,e,s){if(this.Oc!==2)return;const n=this.qa;if(e!==void 0&&n!==e)return;const o=this.Ah,r=this.Ec;let l=t;if(n!==""&&(l=Model.Xt(t,n)),l!==void 0&&!this.Vb.has(t))try{this.Vb.add(t);const h=s!==null?s.diagram:null,a=h!==null?h.model:null;if(r===null){if(o!=="")a!==null?(Debug&&a.nodeKeyProperty===o&&a.containsNodeData(i)&&Util.ht("Binding error: cannot have TwoWay Binding on node data key property: "+this.toString()),a.setDataProperty(i,o,l)):Model.ct(i,o,l);else if(a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const f=s.itemIndex,c=s.panel.itemArray;a.removeArrayItem(c,f),a.insertArrayItem(c,f,l)}}else try{if(o!==""){const f=r(l,i,a);a!==null?(Debug&&(a.nodeKeyProperty===o&&a.containsNodeData(i)&&Util.ht("Binding error: cannot have TwoWay Binding on node data key property: "+this.toString()),f===void 0&&Util.ht(`Binding warning: conversion function returned undefined when setting source property "${o}" on ${i.toString()}, function is: ${r}`)),a.setDataProperty(i,o,f)):Model.ct(i,o,f)}else{const f=r(l,i,a);if(f!==void 0&&a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const c=s.itemIndex,u=s.panel.itemArray;a.removeArrayItem(u,c),a.insertArrayItem(u,c,f)}}}catch(f){Debug&&Util.ht("Binding error: "+f.toString()+' setting source property "'+o+'" on '+i.toString()+" with conversion function: "+r)}}finally{this.Vb.delete(t)}}}class ThemeBinding extends Binding{Iy;Lh;ja;constructor(t,i,e,s,n){super(t,i,s),e==null&&(e=""),n===void 0&&(n=null),this.Iy=e,this.Lh=n,this.ja=null,this.l=16}cloneProtected(t){super.cloneProtected(t),t.Iy=this.Iy,t.Lh=this.Lh,t.ja=this.ja}od(){return!0}get themeSource(){return this.Iy}set themeSource(t){this.f&&Util.F(this),t!==null&&Util.t(t,"string",ThemeBinding,"themeSource"),this.Iy=t,this.ja=null,t!==null?this.l=this.l|16:this.l=this.l&-17}get themeConverter(){return this.Lh}set themeConverter(t){this.f&&Util.F(this),t!==null&&Util.t(t,"function",ThemeBinding,"themeConverter"),this.Lh=t}ofData(){return this.f&&Util.F(this),this.l=this.l|2,this.Rc=null,this}BT(t,i,e,s){if(!t||(this.CN&&(i=this.Ah),!i&&i!==0))return;let n=this.themeSource;this.ja!==null?n=this.ja:typeof n=="string"&&n.includes(".")&&(this.ja=n.split("."),n=this.ja);let o=t.findValue(i,n,s);return o===void 0&&Util.ht(`Theme warning: ${i} could not be found when setting target property ${s}.`),typeof this.Lh=="function"&&(o=this.Lh(o,e)),o}}class Model{Tt;rg;zo;zb;Me;Bc;Vc;lg;hg;ag;fg;Wa;lr;Xb;Vo;Yb;oi;Th;cg=new GSet;ug=new GSet;Oy;constructor(t,i){if(GSet.vi(this),this.Tt="",this.rg="",this.zo=!1,this.zb={},this.Me=[],this.oi=new GMap,this.Th="key",this.Bc=null,this.Vc=null,this.lg=!1,this.hg=!1,this.ag=!1,this.fg=null,this.Wa="category",this.lr=new GMap,this.Oy=100,this.Xb=new List,this.Vo=!1,this.Yb=null,this.undoManager=new UndoManager,t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){t.Tt=this.Tt,t.rg=this.rg,t.zo=this.zo,t.Th=this.Th,t.Bc=this.Bc,t.Vc=this.Vc,t.lg=this.lg,t.hg=this.hg,t.ag=this.ag,t.Oy=this.Oy,t.fg=this.fg,t.Wa=this.Wa}copy(){const t=new this.constructor;return this.cloneProtected(t),t}clear(){this.Me=[],this.oi.clear(),this.lr.clear(),this.undoManager.clear()}toString(t){if(t===void 0&&(t=0),t>1)return this.toJson();{let i=(this.name!==""?this.name:"")+" Model";if(t>0){i+=` + node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n{if(u.model===e){if(u.modelChange==="nodeDataArray")u.change===3?n.add(u.newValue):u.change===4&&r.add(u.oldValue);else if(e.containsNodeData(u.object))o.add(u.object);else if(u.change===2&&(e.modelData===u.object||u.propertyName==="modelData"))s=!0;else if(u.object!==null)if(l&&l.has(u.object))l.get(u.object).each(m=>{e.containsNodeData(m)&&o.add(m)});else{if(u.object instanceof Model||e.Ea()&&e.containsLinkData(u.object))return;e.zT(u.object).each(m=>{o.add(m)})}}});const h=this.ug;h.clear(),n.each(u=>{h.add(e.getKeyForNodeData(u)),i||o.add(u)});const a=this.cg;a.clear(),r.each(u=>{a.add(e.getKeyForNodeData(u)),i&&o.add(u)});const f=e.cloneDeep(o.toArray());let c=null;return s&&(c===null&&(c={}),c.modelData=this.cloneDeep(this.modelData)),h.count>0&&(c===null&&(c={}),i?c.removedNodeKeys=h.toArray():c.insertedNodeKeys=h.toArray()),f.length>0&&(c===null&&(c={}),c.modifiedNodeData=f),a.count>0&&(c===null&&(c={}),i?c.insertedNodeKeys=a.toArray():c.removedNodeKeys=a.toArray()),a.clear(),h.clear(),c}cloneDeep(t){return this.dg(t,!0)}dg(t,i,e,s,n){if(!Util.Mt(t))return t;n||(n=[]);const o=Object.isExtensible(t);if(e||(e=new GMap),o){const h=e.get(t);if(h)return h}else{s||(s=new GMap);const h=s.iterator;for(;h.next();){const a=h.key;if(h.value===t){const c=e.get(a);if(c)return c}}}function r(h,a){if(o)h.__gohashid===void 0&&n.push(h),e.set(h,a);else{const f=GSet.fu++;e.set(f,a),s.set(f,t)}}let l;if(Array.isArray(t)){l=[],r(t,l);for(let h=0;h{delete h.__gohashid}),l}Be(t){return JSON.stringify(t).replace(/[\u007F-\uFFFF]/g,e=>{const s="0000"+e.charCodeAt(0).toString(16);return"\\u"+s.substring(s.length-4)})}gg(){let t="";return this.name!==""&&(t+=`, + "name": `+this.Be(this.name)),this.dataFormat!==""&&(t+=`, + "dataFormat": `+this.Be(this.dataFormat)),this.isReadOnly&&(t+=`, "isReadOnly": `+this.isReadOnly),this.nodeKeyProperty!=="key"&&typeof this.nodeKeyProperty=="string"&&(t+=`, - "nodeKeyProperty": `+this.Ve(this.nodeKeyProperty)),this.copiesArrays&&(t+=`, + "nodeKeyProperty": `+this.Be(this.nodeKeyProperty)),this.copiesArrays&&(t+=`, "copiesArrays": true`),this.copiesArrayObjects&&(t+=`, "copiesArrayObjects": true`),this.copiesKey&&(t+=`, "copiesKey": true`),this.pointsDigits!==100&&(t+=`, "pointsDigits": `+this.pointsDigits.toString()),this.nodeCategoryProperty!=="category"&&typeof this.nodeCategoryProperty=="string"&&(t+=`, - "nodeCategoryProperty": `+this.Ve(this.nodeCategoryProperty)),t}Ey(t){t.name&&(this.name=t.name),t.dataFormat&&(this.dataFormat=t.dataFormat),t.isReadOnly&&(this.isReadOnly=!0),t.nodeKeyProperty&&(this.nodeKeyProperty=t.nodeKeyProperty),t.copiesArrays&&(this.copiesArrays=!0),t.copiesArrayObjects&&(this.copiesArrayObjects=!0),t.copiesKey!==void 0&&(this.copiesKey=t.copiesKey),t.pointsDigits!==void 0&&(this.pointsDigits=parseInt(t.pointsDigits)),t.nodeCategoryProperty&&(this.nodeCategoryProperty=t.nodeCategoryProperty)}XT(){const t=this.modelData;return`, - "modelData": `+this.YT(t)}KT(t){const i=t.modelData;Util.Mt(i)&&(this.replaceJsonObjects(i),this.modelData=i)}DN(){const t=this.modelData;let i=!1;for(const s in t)if(!this.Kb(t,s,t[s])){i=!0;break}let e="";return i&&(e=this.XT()),e+`, - "nodeDataArray": `+this.Th(this.nodeDataArray,!0)}FN(t){this.KT(t);const i=t.nodeDataArray;Array.isArray(i)&&(this.replaceJsonObjects(i),this.nodeDataArray=i)}RN(t,i,e){if(t===i)return!0;if(typeof t!=typeof i||typeof t=="function"||typeof i=="function")return!1;if(Array.isArray(t)&&Array.isArray(i)){if(e.get(t)===i)return!0;if(e.set(t,i),t.length!==i.length)return!1;for(let s=0;s{const o=n.part;if(!o)return;const r=o.data;if(s===r)return;let l=i.get(s);l===null?(l=new GSet,l.add(r),i.set(s,l)):l.add(r)};i===null&&(i=new GMap,t.changes.each(s=>{if(s.diagram!==null){const n=s.change;if(n===2){const o=s.object.panel;if(o){const r=o.data;r&&e(r,o)}}else if(n===3||n===4){const o=s.object,r=o.itemArray;r&&e(r,o)}}}),this.Wa=i)}zT(t){const i=new GSet;for(let e=0;e{if(c.model===e){if(c.modelChange==="nodeDataArray")c.change===3?n.add(c.newValue):c.change===4&&r.add(c.oldValue);else if(e.containsNodeData(c.object))o.add(c.object);else if(c.change===2&&(e.modelData===c.object||c.propertyName==="modelData"))s=!0;else if(c.object!==null)if(l&&l.has(c.object))l.get(c.object).each(d=>{e.containsNodeData(d)&&o.add(d)});else{if(c.object instanceof Model||e.Oa()&&e.containsLinkData(c.object))return;e.zT(c.object).each(d=>{o.add(d)})}}});const h=this.dg;h.clear(),n.each(c=>{h.add(e.getKeyForNodeData(c)),i||o.add(c)});const a=this.ug;a.clear(),r.each(c=>{a.add(e.getKeyForNodeData(c)),i&&o.add(c)});let f="";return s&&(f+=this.XT()),h.count>0&&(f+=(i?this.GT:this.UT)+this.Th(h.toArray(),!0)),o.count>0&&(f+=this.EO+this.Th(o.toArray(),!0)),a.count>0&&(f+=(i?this.UT:this.GT)+this.Th(a.toArray(),!0)),a.clear(),h.clear(),f}Vy(t){(t.name!==void 0&&t.name!==this.name||t.dataFormat!==void 0&&t.dataFormat!==this.dataFormat||t.isReadOnly!==void 0&&t.isReadOnly!==this.isReadOnly||t.nodeKeyProperty!==void 0&&t.nodeKeyProperty!==this.nodeKeyProperty||t.copiesArrays!==void 0&&t.copiesArrays!==this.copiesArrays||t.copiesArrayObjects!==void 0&&t.copiesArrayObjects!==this.copiesArrayObjects||t.copiesKey!==void 0&&t.copiesKey!==this.copiesKey||t.nodeCategoryProperty!==void 0&&t.nodeCategoryProperty!==this.nodeCategoryProperty)&&Util.n("applyIncrementalJson cannot change Model properties"),this.KT(t);const i=t.insertedNodeKeys,e=t.modifiedNodeData,s=new GMap;if(Array.isArray(e))for(let o=0;o1&&s.add(` + "removedNodeKeys": `;va=null;VT(t){let i=this.va;const e=(s,n)=>{const o=n.part;if(!o)return;const r=o.data;if(s===r)return;let l=i.get(s);l===null?(l=new GSet,l.add(r),i.set(s,l)):l.add(r)};i===null&&(i=new GMap,t.changes.each(s=>{if(s.diagram!==null){const n=s.change;if(n===2){const o=s.object.panel;if(o){const r=o.data;r&&e(r,o)}}else if(n===3||n===4){const o=s.object,r=o.itemArray;r&&e(r,o)}}}),this.va=i)}zT(t){const i=new GSet;for(let e=0;e{if(c.model===e){if(c.modelChange==="nodeDataArray")c.change===3?n.add(c.newValue):c.change===4&&r.add(c.oldValue);else if(e.containsNodeData(c.object))o.add(c.object);else if(c.change===2&&(e.modelData===c.object||c.propertyName==="modelData"))s=!0;else if(c.object!==null)if(l&&l.has(c.object))l.get(c.object).each(d=>{e.containsNodeData(d)&&o.add(d)});else{if(c.object instanceof Model||e.Ea()&&e.containsLinkData(c.object))return;e.zT(c.object).each(d=>{o.add(d)})}}});const h=this.ug;h.clear(),n.each(c=>{h.add(e.getKeyForNodeData(c)),i||o.add(c)});const a=this.cg;a.clear(),r.each(c=>{a.add(e.getKeyForNodeData(c)),i&&o.add(c)});let f="";return s&&(f+=this.XT()),h.count>0&&(f+=(i?this.GT:this.UT)+this.Dh(h.toArray(),!0)),o.count>0&&(f+=this.OO+this.Dh(o.toArray(),!0)),a.count>0&&(f+=(i?this.UT:this.GT)+this.Dh(a.toArray(),!0)),a.clear(),h.clear(),f}By(t){(t.name!==void 0&&t.name!==this.name||t.dataFormat!==void 0&&t.dataFormat!==this.dataFormat||t.isReadOnly!==void 0&&t.isReadOnly!==this.isReadOnly||t.nodeKeyProperty!==void 0&&t.nodeKeyProperty!==this.nodeKeyProperty||t.copiesArrays!==void 0&&t.copiesArrays!==this.copiesArrays||t.copiesArrayObjects!==void 0&&t.copiesArrayObjects!==this.copiesArrayObjects||t.copiesKey!==void 0&&t.copiesKey!==this.copiesKey||t.nodeCategoryProperty!==void 0&&t.nodeCategoryProperty!==this.nodeCategoryProperty)&&Util.n("applyIncrementalJson cannot change Model properties"),this.KT(t);const i=t.insertedNodeKeys,e=t.modifiedNodeData,s=new GMap;if(Array.isArray(e))for(let o=0;o1&&s.add(` `);for(let n=0;n0&&(s.add(","),i&&s.add(` `)),s.add(this.writeJsonValue(o)))}return i&&e>1&&s.add(` -`),s.add("]"),s.toString()}Kb(t,i,e){return e===void 0||i==="__gohashid"||i[0]==="_"||typeof e=="function"}ji(t){return isNaN(t)?"NaN":t===1/0?"9e9999":t===-1/0?"-9e9999":t}YT(t){const i=t;if(i instanceof Point)t={class:"go.Point",x:this.ji(i.x),y:this.ji(i.y)};else if(i instanceof Size)t={class:"go.Size",width:this.ji(i.width),height:this.ji(i.height)};else if(i instanceof Rect)t={class:"go.Rect",x:this.ji(i.x),y:this.ji(i.y),width:this.ji(i.width),height:this.ji(i.height)};else if(i instanceof Margin)t={class:"go.Margin",top:this.ji(i.top),right:this.ji(i.right),bottom:this.ji(i.bottom),left:this.ji(i.left)};else if(i instanceof Spot)i.isSpot()?t={class:"go.Spot",x:this.ji(i.x),y:this.ji(i.y),offsetX:this.ji(i.offsetX),offsetY:this.ji(i.offsetY)}:t={class:"go.Spot",enum:i.toString()};else if(i instanceof Brush){if(t={class:"go.Brush",type:BrushType[i.type]},i.type===1?t.color=i.color:(i.type===2||i.type===3)&&(t.start=i.start,t.end=i.end,i.type===3&&(i.startRadius!==0&&(t.startRadius=this.ji(i.startRadius)),isNaN(i.endRadius)||(t.endRadius=this.ji(i.endRadius)))),i.colorStops!==null){const n={},o=i.colorStops.iterator;for(;o.next();){const r=o.key,l=o.value;n[r]=l}t.colorStops=n}}else if(i instanceof Geometry)t={class:"go.Geometry",type:GeometryType[i.type]},i.startX!==0&&(t.startX=this.ji(i.startX)),i.startY!==0&&(t.startY=this.ji(i.startY)),i.endX!==0&&(t.endX=this.ji(i.endX)),i.endY!==0&&(t.endY=this.ji(i.endY)),i.spot1.equals(Spot.TopLeft)||(t.spot1=i.spot1),i.spot2.equals(Spot.BottomRight)||(t.spot2=i.spot2),i.type===4&&(t.path=Geometry.stringify(i));else if(Model.Gb(Util.hn(i))!==null)return Util.at("ERROR: trying to convert a GraphObject or Diagram or Model or Tool or Layout or UndoManager or other unknown data type into JSON text: "+i.toString()),"{}";let e="{",s=!0;for(const n in t){const o=Model.Xt(t,n);if(!this.Kb(t,n,o))if(s?s=!1:e+=",",e+=this.Ve(n)+":",n==="points"&&o instanceof List){const r=o;let l="[";const h=r.iterator;for(;h.next();){const a=h.value;l.length>1&&(l+=","),l+=this.HT(a.x),l+=",",l+=this.HT(a.y)}l+="]",e+=l}else e+=this.writeJsonValue(o)}return e+="}",e}HT(t){if(t===1/0)return"9e9999";if(t===-1/0)return"-9e9999";if(isNaN(t))return"0";const i=this.pointsDigits;return i>16?t.toString():t.toFixed(i)}get pointsDigits(){return this.Oy}set pointsDigits(t){t<0?t=0:t>100&&(t=100),this.Oy=t}Wi(t){return typeof t=="number"?t:t==="NaN"?NaN:t==="9e9999"?1/0:t==="-9e9999"?-1/0:parseFloat(t)}BO(t){if(typeof t!="object")return t;let i=t.class||"";if(typeof i!="string"||i==="")return t;if(i==="NaN")return NaN;if(i==="Date")return new Date(t.value);if(i.indexOf("go.")!==0)return t;i=i.substring(3);let e=t;if(i==="Point")e=new Point(this.Wi(t.x),this.Wi(t.y));else if(i==="Size")e=new Size(this.Wi(t.width),this.Wi(t.height));else if(i==="Rect")e=new Rect(this.Wi(t.x),this.Wi(t.y),this.Wi(t.width),this.Wi(t.height));else if(i==="Margin")e=new Margin(this.Wi(t.top),this.Wi(t.right),this.Wi(t.bottom),this.Wi(t.left));else if(i==="Spot")typeof t.enum=="string"?e=Spot.parse(t.enum):e=new Spot(this.Wi(t.x),this.Wi(t.y),this.Wi(t.offsetX),this.Wi(t.offsetY));else if(i==="Brush"){const s=new Brush;s.type=Util.zh(BrushType,t.type)??1,typeof t.color=="string"&&(s.color=t.color),t.start instanceof Spot&&(s.start=t.start),t.end instanceof Spot&&(s.end=t.end),typeof t.startRadius=="number"&&(s.startRadius=this.Wi(t.startRadius)),typeof t.endRadius=="number"&&(s.endRadius=this.Wi(t.endRadius));const n=t.colorStops;if(Util.Mt(n))for(const o in n){const r=parseFloat(o);s.addColorStop(r,n[o])}e=s}else if(i==="Geometry"){let s=null;typeof t.path=="string"?s=Geometry.parse(t.path):s=new Geometry,s.type=Util.zh(GeometryType,t.type)??1,typeof t.startX=="number"&&(s.startX=this.Wi(t.startX)),typeof t.startY=="number"&&(s.startY=this.Wi(t.startY)),typeof t.endX=="number"&&(s.endX=this.Wi(t.endX)),typeof t.endY=="number"&&(s.endY=this.Wi(t.endY)),t.spot1 instanceof Spot&&(s.spot1=t.spot1),t.spot2 instanceof Spot&&(s.spot2=t.spot2),e=s}else if(i==="EnumValue"){let s=t.classType;s.indexOf("go.")===0&&(s=s.substring(3));const n=Model.Gb(s);typeof n=="function"&&(e=Util.zh(n,t.name))}return e}get name(){return this.Tt}set name(t){const i=this.Tt;i!==t&&(Util.t(t,"string",Model,"name"),this.Tt=t,this.i("name",i,t))}get dataFormat(){return this.lg}set dataFormat(t){const i=this.lg;i!==t&&(Util.t(t,"string",Model,"dataFormat"),this.lg=t,this.i("dataFormat",i,t))}get isReadOnly(){return this.zo}set isReadOnly(t){const i=this.zo;i!==t&&(Util.t(t,"boolean",Model,"isReadOnly"),this.zo=t,this.i("isReadOnly",i,t))}get modelData(){return this.zb}set modelData(t){const i=this.zb;i!==t&&(Util.t(t,"object",Model,"modelData"),this.zb=t,this.i("modelData",i,t),this.updateTargetBindings(t))}addChangedListener(t){return Util.t(t,"function",Model,"addChangedListener:listener"),this.Xb.add(t),this}removeChangedListener(t){Util.t(t,"function",Model,"removeChangedListener:listener"),this.Xb.delete(t)}Hw(t){this.skipsUndoManager||this.undoManager.handleChanged(t);const i=this.Xb,e=i.length;for(let s=0;s0&&Util.n("Cannot set Model.nodeKeyProperty when there is existing node data"),this.Lh=t,this.i("nodeKeyProperty",i,t))}In(t,i,e){typeof t!="string"&&typeof t!="function"&&Util.Vi(t,"string or function",i,e)}getKeyForNodeData(t){if(t===null)return;const i=this.Lh;if(i==="")return;const e=Model.Xt(t,i);if(e!==void 0){if(this.isKeyType(e))return e;Util.n("Key value for node data "+t+" is not a number or a string: "+e)}}setKeyForNodeData(t,i){if((i==null||!this.isKeyType(i))&&Util.Vi(i,"number or string",Model,"setKeyForNodeData:key"),t===null)return;const e=this.Lh;if(e==="")return;if(!this.containsNodeData(t)){Model.ut(t,e,i);return}const s=Model.Xt(t,e);if(s!==i){if(this.findNodeDataForKey(i)!==null)return;Model.ut(t,e,i),s!==void 0&&this.oi.delete(s),this.oi.set(i,t),this.Kt("nodeKey",2,e,t,s,i),typeof e=="string"&&this.updateTargetBindings(t,e),this.By(s,i)}}get makeUniqueKeyFunction(){return this.Ec}set makeUniqueKeyFunction(t){const i=this.Ec;i!==t&&(t!==null&&Util.t(t,"function",Model,"makeUniqueKeyFunction"),this.Ec=t,this.i("makeUniqueKeyFunction",i,t))}isKeyType(t){return typeof t=="number"||typeof t=="string"}containsNodeData(t){if(t===null)return!1;const i=this.getKeyForNodeData(t);return i===void 0?!1:this.oi.get(i)===t}findNodeDataForKey(t){return t===null&&Util.n("Model.findNodeDataForKey:key must not be null"),t===void 0||!this.isKeyType(t)?null:this.oi.get(t)}get nodeDataArray(){return this.Me}set nodeDataArray(t){const i=this.Me;if(i!==t){Util.Gg(t,Model,"nodeDataArray"),this.oi.clear(),this.ON();const e=t.length;for(let o=0;o=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" GraphLinksModel";if(t>0){i+=` +`),s.add("]"),s.toString()}Kb(t,i,e){return e===void 0||i==="__gohashid"||i[0]==="_"||typeof e=="function"}ji(t){return isNaN(t)?"NaN":t===1/0?"9e9999":t===-1/0?"-9e9999":t}YT(t){const i=t;if(i instanceof Point)t={class:"go.Point",x:this.ji(i.x),y:this.ji(i.y)};else if(i instanceof Size)t={class:"go.Size",width:this.ji(i.width),height:this.ji(i.height)};else if(i instanceof Rect)t={class:"go.Rect",x:this.ji(i.x),y:this.ji(i.y),width:this.ji(i.width),height:this.ji(i.height)};else if(i instanceof Margin)t={class:"go.Margin",top:this.ji(i.top),right:this.ji(i.right),bottom:this.ji(i.bottom),left:this.ji(i.left)};else if(i instanceof Spot)i.isSpot()?t={class:"go.Spot",x:this.ji(i.x),y:this.ji(i.y),offsetX:this.ji(i.offsetX),offsetY:this.ji(i.offsetY)}:t={class:"go.Spot",enum:i.toString()};else if(i instanceof Brush){if(t={class:"go.Brush",type:BrushType[i.type]},i.type===1?t.color=i.color:(i.type===2||i.type===3)&&(t.start=i.start,t.end=i.end,i.type===3&&(i.startRadius!==0&&(t.startRadius=this.ji(i.startRadius)),isNaN(i.endRadius)||(t.endRadius=this.ji(i.endRadius)))),i.colorStops!==null){const n={},o=i.colorStops.iterator;for(;o.next();){const r=o.key,l=o.value;n[r]=l}t.colorStops=n}}else if(i instanceof Geometry)t={class:"go.Geometry",type:GeometryType[i.type]},i.startX!==0&&(t.startX=this.ji(i.startX)),i.startY!==0&&(t.startY=this.ji(i.startY)),i.endX!==0&&(t.endX=this.ji(i.endX)),i.endY!==0&&(t.endY=this.ji(i.endY)),i.spot1.equals(Spot.TopLeft)||(t.spot1=i.spot1),i.spot2.equals(Spot.BottomRight)||(t.spot2=i.spot2),i.type===4&&(t.path=Geometry.stringify(i));else if(Model.Gb(Util.hn(i))!==null)return Util.ht("ERROR: trying to convert a GraphObject or Diagram or Model or Tool or Layout or UndoManager or other unknown data type into JSON text: "+i.toString()),"{}";let e="{",s=!0;for(const n in t){const o=Model.Xt(t,n);if(!this.Kb(t,n,o))if(s?s=!1:e+=",",e+=this.Be(n)+":",n==="points"&&o instanceof List){const r=o;let l="[";const h=r.iterator;for(;h.next();){const a=h.value;l.length>1&&(l+=","),l+=this.HT(a.x),l+=",",l+=this.HT(a.y)}l+="]",e+=l}else e+=this.writeJsonValue(o)}return e+="}",e}HT(t){if(t===1/0)return"9e9999";if(t===-1/0)return"-9e9999";if(isNaN(t))return"0";const i=this.pointsDigits;return i>16?t.toString():t.toFixed(i)}get pointsDigits(){return this.Oy}set pointsDigits(t){t<0?t=0:t>100&&(t=100),this.Oy=t}Wi(t){return typeof t=="number"?t:t==="NaN"?NaN:t==="9e9999"?1/0:t==="-9e9999"?-1/0:parseFloat(t)}BO(t){if(typeof t!="object")return t;let i=t.class||"";if(typeof i!="string"||i==="")return t;if(i==="NaN")return NaN;if(i==="Date")return new Date(t.value);if(i.indexOf("go.")!==0)return t;i=i.substring(3);let e=t;if(i==="Point")e=new Point(this.Wi(t.x),this.Wi(t.y));else if(i==="Size")e=new Size(this.Wi(t.width),this.Wi(t.height));else if(i==="Rect")e=new Rect(this.Wi(t.x),this.Wi(t.y),this.Wi(t.width),this.Wi(t.height));else if(i==="Margin")e=new Margin(this.Wi(t.top),this.Wi(t.right),this.Wi(t.bottom),this.Wi(t.left));else if(i==="Spot")typeof t.enum=="string"?e=Spot.parse(t.enum):e=new Spot(this.Wi(t.x),this.Wi(t.y),this.Wi(t.offsetX),this.Wi(t.offsetY));else if(i==="Brush"){const s=new Brush;s.type=Util.Xh(BrushType,t.type)??1,typeof t.color=="string"&&(s.color=t.color),t.start instanceof Spot&&(s.start=t.start),t.end instanceof Spot&&(s.end=t.end),typeof t.startRadius=="number"&&(s.startRadius=this.Wi(t.startRadius)),typeof t.endRadius=="number"&&(s.endRadius=this.Wi(t.endRadius));const n=t.colorStops;if(Util.Mt(n))for(const o in n){const r=parseFloat(o);s.addColorStop(r,n[o])}e=s}else if(i==="Geometry"){let s=null;typeof t.path=="string"?s=Geometry.parse(t.path):s=new Geometry,s.type=Util.Xh(GeometryType,t.type)??1,typeof t.startX=="number"&&(s.startX=this.Wi(t.startX)),typeof t.startY=="number"&&(s.startY=this.Wi(t.startY)),typeof t.endX=="number"&&(s.endX=this.Wi(t.endX)),typeof t.endY=="number"&&(s.endY=this.Wi(t.endY)),t.spot1 instanceof Spot&&(s.spot1=t.spot1),t.spot2 instanceof Spot&&(s.spot2=t.spot2),e=s}else if(i==="EnumValue"){let s=t.classType;s.indexOf("go.")===0&&(s=s.substring(3));const n=Model.Gb(s);typeof n=="function"&&(e=Util.Xh(n,t.name))}return e}get name(){return this.Tt}set name(t){const i=this.Tt;i!==t&&(Util.t(t,"string",Model,"name"),this.Tt=t,this.i("name",i,t))}get dataFormat(){return this.rg}set dataFormat(t){const i=this.rg;i!==t&&(Util.t(t,"string",Model,"dataFormat"),this.rg=t,this.i("dataFormat",i,t))}get isReadOnly(){return this.zo}set isReadOnly(t){const i=this.zo;i!==t&&(Util.t(t,"boolean",Model,"isReadOnly"),this.zo=t,this.i("isReadOnly",i,t))}get modelData(){return this.zb}set modelData(t){const i=this.zb;i!==t&&(Util.t(t,"object",Model,"modelData"),this.zb=t,this.i("modelData",i,t),this.updateTargetBindings(t))}addChangedListener(t){return Util.t(t,"function",Model,"addChangedListener:listener"),this.Xb.add(t),this}removeChangedListener(t){Util.t(t,"function",Model,"removeChangedListener:listener"),this.Xb.delete(t)}Hw(t){this.skipsUndoManager||this.undoManager.handleChanged(t);const i=this.Xb,e=i.length;for(let s=0;s0&&Util.n("Cannot set Model.nodeKeyProperty when there is existing node data"),this.Th=t,this.i("nodeKeyProperty",i,t))}In(t,i,e){typeof t!="string"&&typeof t!="function"&&Util.Bi(t,"string or function",i,e)}getKeyForNodeData(t){if(t===null)return;const i=this.Th;if(i==="")return;const e=Model.Xt(t,i);if(e!==void 0){if(this.isKeyType(e))return e;Util.n("Key value for node data "+t+" is not a number or a string: "+e)}}setKeyForNodeData(t,i){if((i==null||!this.isKeyType(i))&&Util.Bi(i,"number or string",Model,"setKeyForNodeData:key"),t===null)return;const e=this.Th;if(e==="")return;if(!this.containsNodeData(t)){Model.ct(t,e,i);return}const s=Model.Xt(t,e);if(s!==i){if(this.findNodeDataForKey(i)!==null)return;Model.ct(t,e,i),s!==void 0&&this.oi.delete(s),this.oi.set(i,t),this.Kt("nodeKey",2,e,t,s,i),typeof e=="string"&&this.updateTargetBindings(t,e),this.Vy(s,i)}}get makeUniqueKeyFunction(){return this.Bc}set makeUniqueKeyFunction(t){const i=this.Bc;i!==t&&(t!==null&&Util.t(t,"function",Model,"makeUniqueKeyFunction"),this.Bc=t,this.i("makeUniqueKeyFunction",i,t))}isKeyType(t){return typeof t=="number"||typeof t=="string"}containsNodeData(t){if(t===null)return!1;const i=this.getKeyForNodeData(t);return i===void 0?!1:this.oi.get(i)===t}findNodeDataForKey(t){return t===null&&Util.n("Model.findNodeDataForKey:key must not be null"),t===void 0||!this.isKeyType(t)?null:this.oi.get(t)}get nodeDataArray(){return this.Me}set nodeDataArray(t){const i=this.Me;if(i!==t){Util.Ug(t,Model,"nodeDataArray"),this.oi.clear(),this.RN();const e=t.length;for(let o=0;o=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" GraphLinksModel";if(t>0){i+=` node data:`;let e=this.nodeDataArray,s=e.length,n=0;for(n=0;n"+this.Ee(o,!1)}}return i}}TN(t,i){if(this.linkKeyProperty===""){const c=this.skipsUndoManager;this.skipsUndoManager=!0,this.linkKeyProperty="key",this.skipsUndoManager=c}let e=super.TN(t,i);const s=this,n=new GSet,o=new GSet,r=new GSet,l=this.Wa;t.changes.each(c=>{if(c.model===s){if(c.modelChange==="linkDataArray")c.change===3?n.add(c.newValue):c.change===4&&r.add(c.oldValue);else if(s.containsLinkData(c.object))o.add(c.object);else if(c.object!==null)if(c.object!==null&&l&&l.has(c.object))l.get(c.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(c.object instanceof Model||s.containsNodeData(c.object))return;s.jT(c.object).each(d=>o.add(d))}}});const h=this.dg;h.clear(),n.each(c=>{h.add(s.getKeyForLinkData(c)),i||o.add(c)});const a=this.ug;a.clear(),r.each(c=>{a.add(s.getKeyForLinkData(c)),i&&o.add(c)});const f=s.cloneDeep(o.toArray());return h.count>0&&(e===null&&(e={}),i?e.removedLinkKeys=h.toArray():e.insertedLinkKeys=h.toArray()),f.length>0&&(e===null&&(e={}),e.modifiedLinkData=f),a.count>0&&(e===null&&(e={}),i?e.insertedLinkKeys=a.toArray():e.removedLinkKeys=a.toArray()),a.clear(),h.clear(),e}mg(){const t=super.mg();let i="";return this.linkCategoryProperty!=="category"&&typeof this.linkCategoryProperty=="string"&&(i+=`, - "linkCategoryProperty": `+this.Ve(this.linkCategoryProperty)),this.linkKeyProperty!==""&&typeof this.linkKeyProperty=="string"&&(i+=`, - "linkKeyProperty": `+this.Ve(this.linkKeyProperty)),this.linkFromKeyProperty!=="from"&&typeof this.linkFromKeyProperty=="string"&&(i+=`, - "linkFromKeyProperty": `+this.Ve(this.linkFromKeyProperty)),this.linkToKeyProperty!=="to"&&typeof this.linkToKeyProperty=="string"&&(i+=`, - "linkToKeyProperty": `+this.Ve(this.linkToKeyProperty)),this.linkFromPortIdProperty!==""&&typeof this.linkFromPortIdProperty=="string"&&(i+=`, - "linkFromPortIdProperty": `+this.Ve(this.linkFromPortIdProperty)),this.linkToPortIdProperty!==""&&typeof this.linkToPortIdProperty=="string"&&(i+=`, - "linkToPortIdProperty": `+this.Ve(this.linkToPortIdProperty)),this.linkLabelKeysProperty!==""&&typeof this.linkLabelKeysProperty=="string"&&(i+=`, - "linkLabelKeysProperty": `+this.Ve(this.linkLabelKeysProperty)),this.nodeIsGroupProperty!=="isGroup"&&typeof this.nodeIsGroupProperty=="string"&&(i+=`, - "nodeIsGroupProperty": `+this.Ve(this.nodeIsGroupProperty)),this.nodeGroupKeyProperty!=="group"&&typeof this.nodeGroupKeyProperty=="string"&&(i+=`, - "nodeGroupKeyProperty": `+this.Ve(this.nodeGroupKeyProperty)),t+i}Ey(t){super.Ey(t),t.linkKeyProperty&&(this.linkKeyProperty=t.linkKeyProperty),t.linkFromKeyProperty&&(this.linkFromKeyProperty=t.linkFromKeyProperty),t.linkToKeyProperty&&(this.linkToKeyProperty=t.linkToKeyProperty),t.linkFromPortIdProperty&&(this.linkFromPortIdProperty=t.linkFromPortIdProperty),t.linkToPortIdProperty&&(this.linkToPortIdProperty=t.linkToPortIdProperty),t.linkCategoryProperty&&(this.linkCategoryProperty=t.linkCategoryProperty),t.linkLabelKeysProperty&&(this.linkLabelKeysProperty=t.linkLabelKeysProperty),t.nodeIsGroupProperty&&(this.nodeIsGroupProperty=t.nodeIsGroupProperty),t.nodeGroupKeyProperty&&(this.nodeGroupKeyProperty=t.nodeGroupKeyProperty)}DN(){const t=super.DN(),i=`, - "linkDataArray": `+this.Th(this.linkDataArray,!0);return t+i}FN(t){super.FN(t);const i=t.linkDataArray;Array.isArray(i)&&(this.replaceJsonObjects(i),this.linkDataArray=i)}WT=`, - "insertedLinkKeys": `;XO=`, + link data:`,e=this.linkDataArray,s=e.length,n=0;n"+this.Ee(o,!1)}}return i}}AN(t,i){if(this.linkKeyProperty===""){const c=this.skipsUndoManager;this.skipsUndoManager=!0,this.linkKeyProperty="key",this.skipsUndoManager=c}let e=super.AN(t,i);const s=this,n=new GSet,o=new GSet,r=new GSet,l=this.va;t.changes.each(c=>{if(c.model===s){if(c.modelChange==="linkDataArray")c.change===3?n.add(c.newValue):c.change===4&&r.add(c.oldValue);else if(s.containsLinkData(c.object))o.add(c.object);else if(c.object!==null)if(c.object!==null&&l&&l.has(c.object))l.get(c.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(c.object instanceof Model||s.containsNodeData(c.object))return;s.jT(c.object).each(d=>o.add(d))}}});const h=this.ug;h.clear(),n.each(c=>{h.add(s.getKeyForLinkData(c)),i||o.add(c)});const a=this.cg;a.clear(),r.each(c=>{a.add(s.getKeyForLinkData(c)),i&&o.add(c)});const f=s.cloneDeep(o.toArray());return h.count>0&&(e===null&&(e={}),i?e.removedLinkKeys=h.toArray():e.insertedLinkKeys=h.toArray()),f.length>0&&(e===null&&(e={}),e.modifiedLinkData=f),a.count>0&&(e===null&&(e={}),i?e.insertedLinkKeys=a.toArray():e.removedLinkKeys=a.toArray()),a.clear(),h.clear(),e}gg(){const t=super.gg();let i="";return this.linkCategoryProperty!=="category"&&typeof this.linkCategoryProperty=="string"&&(i+=`, + "linkCategoryProperty": `+this.Be(this.linkCategoryProperty)),this.linkKeyProperty!==""&&typeof this.linkKeyProperty=="string"&&(i+=`, + "linkKeyProperty": `+this.Be(this.linkKeyProperty)),this.linkFromKeyProperty!=="from"&&typeof this.linkFromKeyProperty=="string"&&(i+=`, + "linkFromKeyProperty": `+this.Be(this.linkFromKeyProperty)),this.linkToKeyProperty!=="to"&&typeof this.linkToKeyProperty=="string"&&(i+=`, + "linkToKeyProperty": `+this.Be(this.linkToKeyProperty)),this.linkFromPortIdProperty!==""&&typeof this.linkFromPortIdProperty=="string"&&(i+=`, + "linkFromPortIdProperty": `+this.Be(this.linkFromPortIdProperty)),this.linkToPortIdProperty!==""&&typeof this.linkToPortIdProperty=="string"&&(i+=`, + "linkToPortIdProperty": `+this.Be(this.linkToPortIdProperty)),this.linkLabelKeysProperty!==""&&typeof this.linkLabelKeysProperty=="string"&&(i+=`, + "linkLabelKeysProperty": `+this.Be(this.linkLabelKeysProperty)),this.nodeIsGroupProperty!=="isGroup"&&typeof this.nodeIsGroupProperty=="string"&&(i+=`, + "nodeIsGroupProperty": `+this.Be(this.nodeIsGroupProperty)),this.nodeGroupKeyProperty!=="group"&&typeof this.nodeGroupKeyProperty=="string"&&(i+=`, + "nodeGroupKeyProperty": `+this.Be(this.nodeGroupKeyProperty)),t+i}Ey(t){super.Ey(t),t.linkKeyProperty&&(this.linkKeyProperty=t.linkKeyProperty),t.linkFromKeyProperty&&(this.linkFromKeyProperty=t.linkFromKeyProperty),t.linkToKeyProperty&&(this.linkToKeyProperty=t.linkToKeyProperty),t.linkFromPortIdProperty&&(this.linkFromPortIdProperty=t.linkFromPortIdProperty),t.linkToPortIdProperty&&(this.linkToPortIdProperty=t.linkToPortIdProperty),t.linkCategoryProperty&&(this.linkCategoryProperty=t.linkCategoryProperty),t.linkLabelKeysProperty&&(this.linkLabelKeysProperty=t.linkLabelKeysProperty),t.nodeIsGroupProperty&&(this.nodeIsGroupProperty=t.nodeIsGroupProperty),t.nodeGroupKeyProperty&&(this.nodeGroupKeyProperty=t.nodeGroupKeyProperty)}LN(){const t=super.LN(),i=`, + "linkDataArray": `+this.Dh(this.linkDataArray,!0);return t+i}TN(t){super.TN(t);const i=t.linkDataArray;Array.isArray(i)&&(this.replaceJsonObjects(i),this.linkDataArray=i)}WT=`, + "insertedLinkKeys": `;zO=`, "modifiedLinkData": `;vT=`, - "removedLinkKeys": `;jT(t){const i=new GSet;for(let e=0;e{if(c.model===s){if(c.modelChange==="linkDataArray")c.change===3?n.add(c.newValue):c.change===4&&r.add(c.oldValue);else if(s.containsLinkData(c.object))o.add(c.object);else if(c.object!==null)if(c.object!==null&&l&&l.has(c.object))l.get(c.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(c.object instanceof Model||s.containsNodeData(c.object))return;s.jT(c.object).each(d=>o.add(d))}}});const h=this.dg;h.clear(),n.each(c=>{h.add(s.getKeyForLinkData(c)),i||o.add(c)});const a=this.ug;a.clear(),r.each(c=>{a.add(s.getKeyForLinkData(c)),i&&o.add(c)});let f=e;return h.count>0&&(f+=(i?this.vT:this.WT)+this.Th(h.toArray(),!0)),o.count>0&&(f+=this.XO+this.Th(o.toArray(),!0)),a.count>0&&(f+=(i?this.WT:this.vT)+this.Th(a.toArray(),!0)),a.clear(),h.clear(),f}Vy(t){(t.linkCategoryProperty!==void 0&&t.linkCategoryProperty!==this.linkCategoryProperty||t.linkKeyProperty!==void 0&&t.linkKeyProperty!==this.linkKeyProperty||t.linkFromKeyProperty!==void 0&&t.linkFromKeyProperty!==this.linkFromKeyProperty||t.linkToKeyProperty!==void 0&&t.linkToKeyProperty!==this.linkToKeyProperty||t.linkFromPortIdProperty!==void 0&&t.linkFromPortIdProperty!==this.linkFromPortIdProperty||t.linkToPortIdProperty!==void 0&&t.linkToPortIdProperty!==this.linkToPortIdProperty||t.linkLabelKeysProperty!==void 0&&t.linkLabelKeysProperty!==this.linkLabelKeysProperty||t.nodeIsGroupProperty!==void 0&&t.nodeIsGroupProperty!==this.nodeIsGroupProperty||t.nodeGroupKeyProperty!==void 0&&t.nodeGroupKeyProperty!==this.nodeGroupKeyProperty)&&Util.n("applyIncrementalJson cannot change Model properties"),super.Vy(t);const i=t.insertedLinkKeys;if(Array.isArray(i)){const n=i.length;for(let o=0;o=0&&s.splice(e,1)):s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue));return}}else if(t.change===4){let e=t.oldParam;if(t.modelChange==="linkDataArray"){const s=t.oldValue;if(Util.Mt(s)&&typeof e=="number"){const n=this.getKeyForLinkData(s);i?(this.hr.add(s),this.is[e]!==s&&this.is.splice(e,0,s),n!==void 0&&this.mi.set(n,s)):(this.hr.delete(s),this.is[e]===s&&this.is.splice(e,1),n!==void 0&&this.mi.delete(n))}return}else if(t.modelChange==="linkLabelKeys"){const s=this.getLabelKeysForLinkData(t.object);Array.isArray(s)&&typeof e=="number"&&(i?s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue):(e=s.indexOf(t.newValue),e>=0&&s.splice(e,1)));return}}super.changeState(t,i)}}get archetypeNodeData(){return this.Fl}set archetypeNodeData(t){const i=this.Fl;i!==t&&(t!==null&&Util.t(t,"object",GraphLinksModel,"archetypeNodeData"),this.Fl=t,this.i("archetypeNodeData",i,t))}EN(t){if(t===void 0)return;const i=this.Fl;if(i!==null){let e=this.findNodeDataForKey(t);e===null&&(e=this.copyNodeData(i),Model.ut(e,this.nodeKeyProperty,t),this.addNodeData(e))}return t}get linkFromKeyProperty(){return this.Po}set linkFromKeyProperty(t){const i=this.Po;i!==t&&(this.In(t,GraphLinksModel,"linkFromKeyProperty"),this.Po=t,this.i("linkFromKeyProperty",i,t))}getFromKeyForLinkData(t){return this.Ee(t,!0)}setFromKeyForLinkData(t,i){this.og(t,i,!0)}get linkToKeyProperty(){return this.No}set linkToKeyProperty(t){const i=this.No;i!==t&&(this.In(t,GraphLinksModel,"linkToKeyProperty"),this.No=t,this.i("linkToKeyProperty",i,t))}getToKeyForLinkData(t){return this.Ee(t,!1)}setToKeyForLinkData(t,i){this.og(t,i,!1)}Ee(t,i){if(t===null)return;const e=i?this.Po:this.No;if(e==="")return;const s=Model.Xt(t,e);if(s!==void 0){if(this.isKeyType(s))return s;Util.n((i?"FromKey":"ToKey")+" value for link data "+t+" is not a number or a string: "+s)}}og(t,i,e){if(i===null&&(i=void 0),i!==void 0&&!this.isKeyType(i)&&Util.Vi(i,"number or string",GraphLinksModel,e?"setFromKeyForLinkData:key":"setToKeyForLinkData:key"),t===null)return;const s=e?this.Po:this.No;if(s==="")return;if(i=this.EN(i),!this.containsLinkData(t)){Model.ut(t,s,i);return}const n=Model.Xt(t,s);n!==i&&(this.tn(n,t),Model.ut(t,s,i),this.findNodeDataForKey(i)===null&&this.en(i,t),this.Kt(e?"linkFromKey":"linkToKey",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkFromPortIdProperty(){return this.va}set linkFromPortIdProperty(t){const i=this.va;i!==t&&(this.In(t,GraphLinksModel,"linkFromPortIdProperty"),Debug&&(t===this.linkFromKeyProperty||t===this.linkToKeyProperty)&&Util.n("linkFromPortIdProperty name must not be the same as the GraphLinksModel.linkFromKeyProperty or linkToKeyProperty: "+t),this.va=t,this.i("linkFromPortIdProperty",i,t))}getFromPortIdForLinkData(t){return this.Eb(t,!0)}setFromPortIdForLinkData(t,i){this.rg(t,i,!0)}get linkToPortIdProperty(){return this.Ja}set linkToPortIdProperty(t){const i=this.Ja;i!==t&&(this.In(t,GraphLinksModel,"linkToPortIdProperty"),Debug&&(t===this.linkFromKeyProperty||t===this.linkToKeyProperty)&&Util.n("linkFromPortIdProperty name must not be the same as the GraphLinksModel.linkFromKeyProperty or linkToKeyProperty: "+t),this.Ja=t,this.i("linkToPortIdProperty",i,t))}getToPortIdForLinkData(t){return this.Eb(t,!1)}setToPortIdForLinkData(t,i){this.rg(t,i,!1)}Eb(t,i){if(t===null)return"";const e=i?this.va:this.Ja;if(e==="")return"";const s=Model.Xt(t,e);return s===void 0?"":s}rg(t,i,e){if(Util.t(i,"string",GraphLinksModel,e?"setFromPortIdForLinkData:portname":"setToPortIdForLinkData:portname"),t===null)return;const s=e?this.va:this.Ja;if(s==="")return;if(!this.containsLinkData(t)){Model.ut(t,s,i);return}let n=Model.Xt(t,s);n===void 0&&(n=""),n!==i&&(Model.ut(t,s,i),this.Kt(e?"linkFromPortId":"linkToPortId",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkLabelKeysProperty(){return this.sn}set linkLabelKeysProperty(t){const i=this.sn;i!==t&&(this.In(t,GraphLinksModel,"linkLabelKeysProperty"),this.sn=t,this.i("linkLabelKeysProperty",i,t))}getLabelKeysForLinkData(t){if(t===null)return GraphLinksModel.EmptyArray;const i=this.sn;if(i==="")return GraphLinksModel.EmptyArray;const e=Model.Xt(t,i);return e===void 0?GraphLinksModel.EmptyArray:e}setLabelKeysForLinkData(t,i){if(Util.Gg(i,GraphLinksModel,"setLabelKeysForLinkData:arr"),t===null)return;const e=this.sn;if(e==="")return;if(!this.containsLinkData(t)){Model.ut(t,e,i);return}let s=Model.Xt(t,e);if(s===void 0&&(s=GraphLinksModel.EmptyArray),s!==i){if(Array.isArray(s)){const o=s.length;for(let r=0;r=0)return;n=s.length,s.push(i),this.containsLinkData(t)&&(this.findNodeDataForKey(i)===null&&this.en(i,t),this.Kt("linkLabelKeys",3,e,t,null,i,null,n))}else Util.n(e+" property is not an Array; cannot addLabelKeyForLinkData: "+t)}removeLabelKeyForLinkData(t,i){if(i==null||(this.isKeyType(i)||Util.Vi(i,"number or string",GraphLinksModel,"removeLabelKeyForLinkData:key"),t===null))return;const e=this.sn;if(e==="")return;const s=Model.Xt(t,e);if(Array.isArray(s)){const n=s.indexOf(i);if(n<0)return;s.splice(n,1),this.containsLinkData(t)&&(this.tn(i,t),this.Kt("linkLabelKeys",4,e,t,i,null,n,null))}else s!==void 0&&Util.n(e+" property is not an Array; cannot removeLabelKeyforLinkData: "+t)}get linkDataArray(){return this.is}set linkDataArray(t){const i=this.is;if(i!==t){Util.Gg(t,GraphLinksModel,"linkDataArray"),this.mi.clear();const e=t.length;for(let n=0;nnew GraphLinksModel,Model.initDiagramModel=Model.initDiagramModel=()=>new GraphLinksModel;class TreeModel extends Model{En;bg;$a;constructor(t,i){if(super(),this.En="parent",this.bg=!1,this.$a="parentLinkCategory",t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){super.cloneProtected(t),t.En=this.En,t.bg=this.bg,t.$a=this.$a}toString(t){if(t===void 0&&(t=0),t>=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" TreeModel";if(t>0){i+=` - node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n(w[w.ConstantSpacing=0]="ConstantSpacing",w[w.ConstantDistance=1]="ConstantDistance",w[w.ConstantAngle=2]="ConstantAngle",w[w.Packed=3]="Packed",w))(CircularArrangement||{}),CircularDirection=(w=>(w[w.Clockwise=10]="Clockwise",w[w.Counterclockwise=11]="Counterclockwise",w[w.BidirectionalLeft=12]="BidirectionalLeft",w[w.BidirectionalRight=13]="BidirectionalRight",w))(CircularDirection||{}),CircularSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w[w.Optimized=24]="Optimized",w))(CircularSorting||{}),CircularNodeDiameterFormula=(w=>(w[w.Pythagorean=30]="Pythagorean",w[w.Circular=31]="Circular",w))(CircularNodeDiameterFormula||{});class CircularLayout extends Layout{ce;Yc;qb;kg;jb;Fh;zN;XN;YN;Ns;Xy;Yy;Qa;Ky;ZT;Sg;Mg;Pg;Kc;qi;C;ke;Se;Rn;Ng;constructor(t){super(),this.ce=0,this.Yc=0,this.qb=0,this.kg=360,this.jb=0,this.Fh=0,this.zN=new Point,this.XN=30,this.YN=0,this.Ns=0,this.Xy=0,this.Yy=new VertexArrangement,this.Qa=0,this.Ky=0,this.ZT=600,this.Sg=NaN,this.Mg=1,this.Pg=0,this.Kc=360,this.qi=0,this.C=10,this.ke=24,this.Se=LayoutVertex.standardComparer,this.Rn=6,this.Ng=30,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Sg=this.Sg,t.Mg=this.Mg,t.Pg=this.Pg,t.Kc=this.Kc,t.qi=this.qi,t.C=this.C,t.ke=this.ke,t.Se=this.Se,t.Rn=this.Rn,t.Ng=this.Ng}fi(t){t in CircularSorting?this.sorting=t:t in CircularDirection?this.direction=t:t in CircularArrangement?this.arrangement=t:t in CircularNodeDiameterFormula?this.nodeDiameterFormula=t:super.fi(t)}createNetwork(){return new CircularNetwork(this)}UO(t,i,e){t=this.GO(t);let s=this.jb,n=this.XN,o=this.ce,r=this.Yc,l=this.qb,h=this.kg,a=this.Fh,f=this.YN,c=this.Ns,u=this.Xy;if(s=this.arrangement,n=this.nodeDiameterFormula,o=this.radius,(!isFinite(o)||o<=0)&&(o=NaN),r=this.aspectRatio,(!isFinite(r)||r<=0)&&(r=1),l=this.startAngle,isFinite(l)||(l=0),h=this.sweepAngle,(!isFinite(h)||h>360||h<1)&&(h=360),a=this.spacing,isFinite(a)||(a=NaN),s===3&&n===31?s=0:s===3&&n!==31&&(n=31,s=this.arrangement),(this.direction===12||this.direction===13)&&this.sorting!==24){for(let g=0;!(g>=t.length||(i.add(t.elt(g)),g+1>=t.length));g+=2)e.add(t.elt(g+1));this.direction===12?(this.arrangement===3&&i.reverse(),t=new List,t.addAll(i),t.addAll(e)):(this.arrangement===3&&e.reverse(),t=new List,t.addAll(e),t.addAll(i))}const d=t.length;f=0;let m=0;for(let g=0;g1?(o=y,c=o*r):(c=y,o=c)}else o=this.Wb(u*(h>=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180)}else o=this.Wb(f+(h>=360?d:d-1)*(s!==3?a:a*1.6),r,l*Math.PI/180,h*Math.PI/180);c=o*r}else{c=o*r;const g=this.KN(o,c,l*Math.PI/180,h*Math.PI/180);if(isNaN(a))s===0&&(a=(g-f)/(h>=360?d:d-1));else if(s===0){const p=(g-f)/(h>=360?d:d-1);p=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180),c=o*r):a=p}else{let p=-1/0;for(let k=0;k=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180);x>o?(o=x,c=o*r,u=y):u=g/(h>=360?d:d-1)}}return this.jb=s,this.XN=n,this.ce=o,this.Yc=r,this.qb=l,this.kg=h,this.Fh=a,this.YN=f,this.Ns=c,this.Xy=u,t}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.network.vertexes;if(i.count<=1){if(i.count===1){const u=i.first();u.centerX=0,u.centerY=0}this.updateParts(),this.network=null,this.isValidLayout=!0;return}let e=new List;e.addAll(i.iterator);const s=new List,n=new List;e=this.UO(e,s,n);const o=this.jb,r=this.ce,l=this.qb,h=this.kg,a=this.Fh,f=this.Ns,c=this.Xy;if((this.direction===12||this.direction===13)&&o===3)this.$T(e,h,l-h/2,10);else if(this.direction===12||this.direction===13){let u=0;switch(o){case 1:u=this.vb(r,f,l,c)*180/Math.PI;break;case 0:{let d=0,m=0;const g=s.first();g!==null&&(d=g.Rh(Math.PI/2));const p=n.first();p!==null&&(m=p.Rh(Math.PI/2)),u=this.vb(r,f,l,a+(d+m)/2)*180/Math.PI;break}case 2:u=h/e.length;break}if(this.direction===12){switch(o){case 1:this.Uy(s,h/2,l,11);break;case 0:this.Gy(s,h/2,l,11);break;case 2:this.Hy(s,h/2,l,11);break}switch(o){case 1:this.Uy(n,h/2,l+u,10);break;case 0:this.Gy(n,h/2,l+u,10);break;case 2:this.Hy(n,h/2,l+u,10);break}}else{switch(o){case 1:this.Uy(n,h/2,l,11);break;case 0:this.Gy(n,h/2,l,11);break;case 2:this.Hy(n,h/2,l,11);break}switch(o){case 1:this.Uy(s,h/2,l+u,10);break;case 0:this.Gy(s,h/2,l+u,10);break;case 2:this.Hy(s,h/2,l+u,10);break}}}else switch(o){case 1:this.Uy(e,h,l,this.direction);break;case 0:this.Gy(e,h,l,this.direction);break;case 2:this.Hy(e,h,l,this.direction);break;case 3:this.$T(e,h,l,this.direction);break}this.updateParts(),this.network=null,this.isValidLayout=!0}Hy(t,i,e,s){const n=this.kg,o=this.ce,r=this.Ns,l=e*Math.PI/180,h=i*Math.PI/180,a=t.length;for(let f=0;f=360?a:a-1):-(f*h)/a),u=t.elt(f),d=o*Math.tan(c)/r,m=Math.sqrt((o*o+r*r*d*d)/(1+d*d));u.centerX=m*Math.cos(c),u.centerY=m*Math.sin(c),u.actualAngle=c*180/Math.PI}}Gy(t,i,e,s){const n=this.ce,o=this.Ns,r=this.Fh;let l=e*Math.PI/180;const h=t.length;for(let a=0;a180&&(n-=360),n*=Math.PI/180,this.Ky=n,this.QT(t,i,e,s)}else this._T(t,i,e,s);this.Yy.commit(t)}_T(t,i,e,s){const n=this.ce,o=this.Ns,r=this.Fh,l=this.Yc;let h=n*Math.cos(e*Math.PI/180),a=o*Math.sin(e*Math.PI/180);const f=t.toArray();if(f.length===3){f[0].centerX=n,f[0].centerY=0,f[1].centerX=f[0].centerX-f[0].width/2-f[1].width/2-r,f[1].y=f[0].y,f[2].centerX=(f[0].centerX+f[1].centerX)/2,f[2].y=f[0].y-f[2].height-r;return}else if(f.length===4){f[0].centerX=n,f[0].centerY=0,f[2].centerX=-f[0].centerX,f[2].centerY=f[0].centerY,f[1].centerX=0,f[1].y=Math.min(f[0].y,f[2].y)-f[1].height-r,f[3].centerX=0,f[3].y=Math.max(f[0].y+f[0].height+r,f[2].y+f[2].height+r);return}const c=Point.a();for(let b=0;b=f.length-1));b++)this.tD(h,a,f,b,s,c)||this.iD(h,a,f,b,s,c),h=c.x,a=c.y;if(Point.o(c),this.Qa++,this.Qa>23)return;const u=f[0].centerX,d=f[0].centerY,m=f[f.length-1].centerX,g=f[f.length-1].centerY;let p=Math.abs(u-m)-((f[0].width+f[f.length-1].width)/2+r);const y=Math.abs(d-g)-((f[0].height+f[f.length-1].height)/2+r);let x=0;if(Math.abs(y)<1){const b=Math.abs(u-m),S=(f[0].width+f[f.length-1].width)/2;b0?x=y:Math.abs(p)<1?x=0:x=p;let k=!1;Math.abs(m)>Math.abs(g)?k=m>0!=d>g:k=g>0!=u1&&(this.Qa<8?this.ce-=x/(2*Math.PI):f.length<5&&x>10?this.ce/=2:this.ce-=x>0?1.7:-2.3,this.Ns=this.ce*l,this._T(t,i,e,s))}QT(t,i,e,s){const n=this.ce,o=this.Ns,r=this.Yc;let l=n*Math.cos(e*Math.PI/180),h=o*Math.sin(e*Math.PI/180);const a=Point.a(),f=t.toArray();for(let m=0;m=f.length-1));m++)this.tD(l,h,f,m,s,a)||this.iD(l,h,f,m,s,a),l=a.x,h=a.y;if(Point.o(a),this.Qa++,this.Qa>23)return;const c=Math.atan2(h,l);let u=s===10?this.Ky-c:c-this.Ky;u=Math.abs(u)1&&(this.Qa<8?this.ce-=d/(2*Math.PI):this.ce-=d>0?1.7:-2.3,this.Ns=this.ce*r,this.QT(t,i,e,s))}tD(t,i,e,s,n,o){const r=this.Fh,l=this.ce,h=this.Ns;let a=0,f=0;const c=(e[s].width+e[s+1].width)/2+r;let u=!1;if(i>=0!=(n===10)){if(a=t+c,a>l){if(a=t-c,a<-l)return o.x=a,o.y=f,!1;u=!0}}else if(a=t-c,a<-l){if(a=t+c,a>l)return o.x=a,o.y=f,!1;u=!0}return f=Math.sqrt(1-Math.min(1,a*a/(l*l)))*h,i<0!==u&&(f=-f),Math.abs(i-f)>(e[s].height+e[s+1].height)/2?(o.x=a,o.y=f,!1):(o.x=a,o.y=f,!0)}iD(t,i,e,s,n,o){const r=this.Fh,l=this.ce,h=this.Ns;let a=0,f=0;const c=(e[s].height+e[s+1].height)/2+r;let u=!1;if(t>=0!=(n===10)){if(f=i-c,f<-h){if(f=i+c,f>h)return o.x=a,o.y=f,!1;u=!0}}else if(f=i+c,f>h){if(f=i-c,f<-h)return o.x=a,o.y=f,!1;u=!0}return a=Math.sqrt(1-Math.min(1,f*f/(h*h)))*l,t<0!==u&&(a=-a),Math.abs(t-a)>(e[s].width+e[s+1].width)/2?(o.x=a,o.y=f,!1):(o.x=a,o.y=f,!0)}commitLayout(){this.commitNodes(),this.isRouting&&this.commitLinks()}commitNodes(){const t=this.group!==null&&this.group.hasPlaceholder(),i=t?this.group.location.copy():null;let e=this.actualCenter;t?e=new Point(0,0):(e.x=this.arrangementOrigin.x+this.ce,e.y=this.arrangementOrigin.y+this.Ns);const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;n.x+=e.x,n.y+=e.y,n.commit()}if(t){this.group.ensureBounds();const n=this.group.position.copy(),o=this.group.location.copy(),r=i.subtract(o.subtract(n));this.group.move(r),this.zN=r.subtract(n)}}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}KN(t,i,e,s){const n=this.ZT;if(Math.abs(this.Yc-1)<.001)return e!==void 0&&s!==void 0?s*t:2*Math.PI*t;const o=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let r=0,l=0;e!==void 0&&s!==void 0?l=s/(n+1):l=Math.PI/(2*(n+1));let h=0;for(let a=0;a<=n;a++){e!==void 0&&s!==void 0?h=e+a*s/n:h=a*Math.PI/(2*n);const f=Math.sin(h);r+=Math.sqrt(1-o*o*f*f)*l}return e!==void 0&&s!==void 0?(t>i?t:i)*r:4*(t>i?t:i)*r}Wb(t,i,e,s){let n=0;return e!==void 0&&s!==void 0?n=this.KN(1,i,e,s):n=this.KN(1,i),t/n}vb(t,i,e,s){if(Math.abs(this.Yc-1)<.001)return s/t;const n=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let o=0;const r=2*Math.PI/(this.network.vertexes.count*700);t>i&&(e+=Math.PI/2);for(let l=0;;l++){const h=e+l*r,a=Math.sin(h);if(o+=(t>i?t:i)*Math.sqrt(1-n*n*a*a)*r,o>=s)return l*r}}GO(t){switch(this.sorting){case 20:break;case 21:t.reverse();break;case 22:t.sort(this.comparer);break;case 23:t.sort(this.comparer),t.reverse();break;case 24:return this.jO(this.WO(t));default:Util.n("Invalid sorting type.")}return t}WO(t){const i=[];for(let s=0;sn&&(n=u,o=f)}else for(let f=0;fn&&(n=c,o=f)}e.add(t.elt(o)),i[o]=-1;const r=t.elt(o);let l=0;const h=r.sourceEdges;for(;h.next();){const c=h.value.fromVertex;l=t.indexOf(c),!(l<0)&&i[l]>=0&&i[l]++}const a=r.destinationEdges;for(;a.next();){const c=a.value.toVertex;l=t.indexOf(c),!(l<0)&&i[l]>=0&&i[l]++}}return e}jO(t){const i=[];for(let c=0;c=0){const C=Math.abs(x-(A>=x?A+1:A));b+=C=x&&M++,A>=x&&A++,M>A){const C=A;A=M,M=C}A-M<(s.length+2)/2==(M=0&&(n.push(c),o.push(x))}h++}let a=!1;const f=s.length;for(;;){a=!0;for(let c=0;c=0){let g=0;for(let p=0;pm?x-m:m-x,b=f-k;g+=xb?1:-1}s.splice(g<0?m:m+1,0,u),r.splice(c,1),c--}else a=!1}if(a)break;s.push(r[0]),r.splice(0,1)}for(let c=0;c0||isNaN(t))&&(this.Sg=t,this.invalidateLayout()))}get aspectRatio(){return this.Mg}set aspectRatio(t){this.Mg!==t&&(Util.t(t,"number",CircularLayout,"aspectRatio"),t>0&&(this.Mg=t,this.invalidateLayout()))}get startAngle(){return this.Pg}set startAngle(t){this.Pg!==t&&(Util.t(t,"number",CircularLayout,"startAngle"),this.Pg=t,this.invalidateLayout())}get sweepAngle(){return this.Kc}set sweepAngle(t){this.Kc!==t&&(Util.t(t,"number",CircularLayout,"sweepAngle"),t>0&&t<=360?this.Kc=t:this.Kc=360,this.invalidateLayout())}get arrangement(){return this.qi}set arrangement(t){this.qi!==t&&(Util.tt(t,CircularArrangement,"CircularArrangement"),(t===3||t===0||t===1||t===2)&&(this.qi=t,this.invalidateLayout()))}get direction(){return this.C}set direction(t){this.C!==t&&(Util.tt(t,CircularDirection,"CircularDirection"),(t===10||t===11||t===12||t===13)&&(this.C=t,this.invalidateLayout()))}get sorting(){return this.ke}set sorting(t){this.ke!==t&&(Util.tt(t,CircularSorting,"CircularSorting"),this.ke=t,this.invalidateLayout())}get comparer(){return this.Se}set comparer(t){this.Se!==t&&(Util.t(t,"function",CircularLayout,"comparer"),this.Se=t,this.invalidateLayout())}get spacing(){return this.Rn}set spacing(t){this.Rn!==t&&(Util.t(t,"number",CircularLayout,"spacing"),this.Rn=t,this.invalidateLayout())}get nodeDiameterFormula(){return this.Ng}set nodeDiameterFormula(t){this.Ng!==t&&(Util.tt(t,CircularNodeDiameterFormula,"CircularNodeDiameterFormula"),(t===30||t===31)&&(this.Ng=t,this.invalidateLayout()))}get actualXRadius(){return this.ce}get actualYRadius(){return this.Ns}get actualSpacing(){return this.Fh}get actualCenter(){return this.zN}static ConstantSpacing=0;static ConstantDistance=1;static ConstantAngle=2;static Packed=3;static Clockwise=10;static Counterclockwise=11;static BidirectionalLeft=12;static BidirectionalRight=13;static Forwards=20;static Reverse=21;static Ascending=22;static Descending=23;static Optimized=24;static Pythagorean=30;static Circular=31}class VertexArrangement{Uc;_a;Gc;constructor(){this.Uc=-1/0,this._a=null,this.Gc=null}HO(t,i){if(t>0&&this.Uc<0||Math.abs(t)0)){this.Uc=t,this._a=[],this.Gc=[];for(let e=0;e0){for(this.network.deleteSelfEdges(),i=this.network.vertexes.iterator;i.next();){const o=i.value;o.charge=this.electricalCharge(o),o.mass=this.gravitationalMass(o)}const s=this.network.edges.iterator;for(;s.next();){const o=s.value;o.stiffness=this.springStiffness(o),o.length=this.springLength(o)}if(this.UN(),this.Ih=0,this.needsPrelayout()){const o=this.network,r=o.splitIntoSubNetworks(!1);let l=r.iterator;for(;l.next();){const h=l.value;this.doConnectedSubnetLayout(h)}for(l=r.iterator,this.JO(l,o),l=r.iterator;l.next();){const h=l.value,a=h.vertexes.iterator;for(;a.next();){const c=a.value;o.addVertex(c)}const f=h.edges.iterator;for(;f.next();){const c=f.value;o.addEdge(c)}}}else this.eD(this.network,this.maxIterations);this.updateParts()}this.maxIterations=e,this.isValidLayout=!0}needsPrelayout(){if(this.network.vertexes.count<3)return!1;let t=0,i=0;const e=this.network.vertexes.first().bounds,s=this.network.vertexes.iterator;for(;s.next();){const n=s.value,o=n.bounds;if(isNaN(n.x)||isNaN(n.y)||o.intersectsRect(e)&&(t++,t>2))return!0;if(i>10)return!1;i++}return!1}doConnectedSubnetLayout(t){let i=t.vertexes.iterator;for(;i.next();){const l=i.value;l.hierarchicalVertexes.add(l)}let e=t,s=this.Jc;if(isNaN(s)&&(s=t.edges.count/t.vertexes.count),sMath.max(100,Math.sqrt(s*t.vertexes.count));)e=this.coarsenNetwork(e);let n=0;i=e.vertexes.iterator;let o=this.randomNumberGenerator;for(o===null&&(this.randomNumberGenerator=o=new RandomNumberGenerator(0));i.next();){i.value.idInCluster=n++;const l=10*(o.random()-.5),h=10*(o.random()-.5);this.isFixed(i.value)||(i.value.x=l,i.value.y=h);const a=i.value.hierarchicalVertexes.iterator;for(;a.next();)this.isFixed(a.value)||(a.value.x=l,a.value.y=h)}const r=this.computePairwiseDistances(e);this.ZO(e,r,this.maxPrelayoutIterations,t.vertexes.count),this.eD(t,this.maxIterations)}computePairwiseDistances(t){const i=t.vertexes.count,e=new Array(i);for(let r=0;r0;){const l=o.shift(),h=l.vertexes.iterator;for(;h.next();){const a=h.value;n.has(a.idInCluster)||(n.set(a.idInCluster,n.get(l.idInCluster)+1),o.push(a))}}for(let l=0;l=0;m--)if(t[m].y>f.y&&t[m].x-f.xf.x&&t[m].y-f.ya+c){const u=s+o-h,d=n-a-c;return Geo.Aw(u*u+d*d)}else if(n+rh+f)if(n>a+c){const u=s-h-f,d=n-a-c;return Geo.Aw(u*u+d*d)}else if(n+ra+c?n-(a+c):n+rr-o;l?i.sort((m,g)=>m===null||g===null||m===g?0:m.centerX-g.centerX):i.sort((m,g)=>m===null||g===null||m===g?0:m.centerY-g.centerY);const h=this.Hc;let a=0,f=0,c=0;for(let m=0;mh||C-x>h){if(l)break;continue}if(k-P>h||P-k>h){if(!l)break;continue}const N=this.GN(g,S),T=2*g.charge,L=2*S.charge;if(N>1)a=T*L/(N*N),f=a*(x-C)/N,c=a*(k-P)/N;else{let D=this.randomNumberGenerator;D===null&&(this.randomNumberGenerator=D=new RandomNumberGenerator(0));const F=D.random(),R=D.random();if(x>C)f=Math.abs(S.bounds.right-g.bounds.x),f=T*L*(1+f)*F;else if(xP)c=Math.abs(S.bounds.bottom-g.bounds.y),c=T*L*(1+c)*R;else if(x1&&(a=.1*m.stiffness*(P-m.length),f=a*.5*(g.width+p.height)*(k-A)/P,c=a*.5*(g.width+p.height)*(b-C)/P),g.forceX-=f,g.forceY-=c,p.forceX+=f,p.forceY+=c}let d=0;for(let m=0;mthis.epsilonDistance*this.epsilonDistance}ZO(t,i,e,s){Debug&&Util.r(e,ForceDirectedLayout,"performIterations:num");const n=this.Ih+e,o=Math.sqrt(s);this.qy=this.tf*t.vertexes.count;const r=t.vertexes.toArray();let l=0,h=0,a=0;for(;this.Ih0){r[f].forceX=this.qy*r[f].forceX/c,r[f].forceY=this.qy*r[f].forceY/c,this.isFixed(r[f])||(r[f].x+=r[f].forceX,r[f].y+=r[f].forceY);const u=r[f].hierarchicalVertexes.iterator;for(;u.next();){const d=u.value;this.isFixed(d)||(d.centerX+=r[f].forceX,d.centerY+=r[f].forceY)}}l+=c*c}if(l>=h){if(a++,a>=5)break}else a=0;this.qy*=.95}}moveVertex(t){let i=t.forceX,e=t.forceY;const s=this.moveLimit;return i<-s?i=-s:i>s&&(i=s),e<-s?e=-s:e>s&&(e=s),t.centerX+=i,t.centerY+=e,i*i+e*e}shouldInteract(t,i){return!0}moveFixedVertex(t){}commitLayout(){this.jy(),this.commitNodes(),this.isRouting&&this.commitLinks()}jy(){if(!this.setsPortSpots)return;const t=this.network.edges.iterator;for(;t.next();){const e=t.value.link;e!==null&&(e.fromSpot=Spot.Default,e.toSpot=Spot.Default)}}commitNodes(){let t=0,i=0;if(this.arrangesToOrigin){const n=Rect.a();this.Rw(this.network,n);const o=this.arrangementOrigin;t=o.x-n.x,i=o.y-n.y,Rect.o(n)}const e=Rect.a(),s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;(t!==0||i!==0)&&(e.c(n.bounds),e.x+=t,e.y+=i,n.bounds=e),n.commit()}Rect.o(e)}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}springStiffness(t){const i=t.stiffness;return isNaN(i)?this.qc:i}springLength(t){const i=t.length;return isNaN(i)?this.jc:i}electricalCharge(t){const i=t.charge;return isNaN(i)?this.Wc:i}electricalFieldX(t,i){return 0}electricalFieldY(t,i){return 0}gravitationalMass(t){const i=t.mass;return isNaN(i)?this.vc:i}gravitationalFieldX(t,i){return 0}gravitationalFieldY(t,i){return 0}isFixed(t){return t.isFixed}get currentIteration(){return this.Ih}get arrangementSpacing(){return this.Cs}set arrangementSpacing(t){Util.s(t,Size,ForceDirectedLayout,"arrangementSpacing"),this.Cs.equals(t)||(this.Cs.c(t),this.invalidateLayout())}get arrangesToOrigin(){return this.Cg}set arrangesToOrigin(t){this.Cg!==t&&(Util.t(t,"boolean",ForceDirectedLayout,"arrangesToOrigin"),this.Cg=t,this.invalidateLayout())}get setsPortSpots(){return this.Vn}set setsPortSpots(t){this.Vn!==t&&(Util.t(t,"boolean",ForceDirectedLayout,"setsPortSpots"),this.Vn=t,this.invalidateLayout())}get comments(){return this.Be}set comments(t){this.Be!==t&&(Util.t(t,"boolean",ForceDirectedLayout,"comments"),this.Be=t,this.invalidateLayout())}get maxPrelayoutIterations(){return this.Ag}set maxPrelayoutIterations(t){this.Ag!==t&&(Util.t(t,"number",ForceDirectedLayout,"maxPrelayoutIterations"),t>=0&&(this.Ag=t,this.invalidateLayout()))}get maxIterations(){return this.Lg}set maxIterations(t){this.Lg!==t&&(Util.t(t,"number",ForceDirectedLayout,"maxIterations"),t>=0&&(this.Lg=t,this.invalidateLayout()))}get epsilonDistance(){return this.Tg}set epsilonDistance(t){this.Tg!==t&&(Util.t(t,"number",ForceDirectedLayout,"epsilonDistance"),t>0&&(this.Tg=t,this.invalidateLayout()))}get infinityDistance(){return this.Hc}set infinityDistance(t){this.Hc!==t&&(Util.t(t,"number",ForceDirectedLayout,"infinityDistance"),t>1&&(this.Hc=t,this.invalidateLayout()))}get moveLimit(){return this.Dg}set moveLimit(t){this.Dg!==t&&(Util.t(t,"number",ForceDirectedLayout,"moveLimit"),this.Dg=t,this.invalidateLayout())}get randomNumberGenerator(){return this.Fg}set randomNumberGenerator(t){this.Fg!==t&&(t!==null&&typeof t.random!="function"&&Util.n('ForceDirectedLayout.randomNumberGenerator must have a "random()" function on it: '+t),this.Fg=t)}get defaultSpringStiffness(){return this.qc}set defaultSpringStiffness(t){this.qc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultSpringStiffness"),this.qc=t,this.invalidateLayout())}get defaultSpringLength(){return this.jc}set defaultSpringLength(t){this.jc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultSpringLength"),this.jc=t,this.invalidateLayout())}get defaultElectricalCharge(){return this.Wc}set defaultElectricalCharge(t){this.Wc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultElectricalCharge"),this.Wc=t,this.invalidateLayout())}get defaultGravitationalMass(){return this.vc}set defaultGravitationalMass(t){this.vc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultGravitationalMass"),this.vc=t,this.invalidateLayout())}get defaultCommentSpringLength(){return this.Rg}set defaultCommentSpringLength(t){this.Rg!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultCommentSpringLength"),this.Rg=t,this.invalidateLayout())}get defaultCommentElectricalCharge(){return this.Ig}set defaultCommentElectricalCharge(t){this.Ig!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultCommentElectricalCharge"),this.Ig=t,this.invalidateLayout())}get prelayoutQuality(){return this.Jc}set prelayoutQuality(t){this.Jc!==t&&(Util.t(t,"number",ForceDirectedLayout,"prelayoutQuality"),this.Jc=t,this.invalidateLayout())}get prelayoutSpread(){return this.tf}set prelayoutSpread(t){this.tf!==t&&(Util.t(t,"number",ForceDirectedLayout,"prelayoutSpread"),this.tf=t,this.invalidateLayout())}}class ForceDirectedNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new ForceDirectedVertex(this)}createEdge(){return new ForceDirectedEdge(this)}}class ForceDirectedVertex extends LayoutVertex{Zb;$b;Qb;_b;tk;hierarchicalVertexes;idInCluster;constructor(t){super(t),this.Zb=!1,this.$b=NaN,this.Qb=NaN,this._b=0,this.tk=0,this.hierarchicalVertexes=new List,this.idInCluster=-1}get isFixed(){return this.Zb}set isFixed(t){this.Zb!==t&&(Util.t(t,"boolean",ForceDirectedVertex,"isFixed"),this.Zb=t)}get charge(){return this.$b}set charge(t){this.$b!==t&&(Util.t(t,"number",ForceDirectedVertex,"charge"),this.$b=t)}get mass(){return this.Qb}set mass(t){this.Qb!==t&&(Util.t(t,"number",ForceDirectedVertex,"mass"),this.Qb=t)}get forceX(){return this._b}set forceX(t){this._b!==t&&(Util.t(t,"number",ForceDirectedVertex,"forceX"),this._b=t)}get forceY(){return this.tk}set forceY(t){this.tk!==t&&(Util.t(t,"number",ForceDirectedVertex,"forceY"),this.tk=t)}}class ForceDirectedEdge extends LayoutEdge{ik;ek;constructor(t){super(t),this.ik=NaN,this.ek=NaN}get stiffness(){return this.ik}set stiffness(t){this.ik!==t&&(Util.t(t,"number",ForceDirectedEdge,"stiffness"),this.ik=t)}get length(){return this.ek}set length(t){this.ek!==t&&(Util.t(t,"number",ForceDirectedEdge,"length"),this.ek=t)}}class RandomNumberGenerator{I;R;Q;M;A;seed;constructor(t){t===void 0&&(t=42),this.seed=t,this.A=48271,this.M=2147483647,this.Q=this.M/this.A,this.R=this.M%this.A,this.I=1/this.M,this.random()}random(){const t=this.seed/this.Q,i=this.seed%this.Q,e=this.A*i-this.R*t;return e>0?this.seed=e:this.seed=e+this.M,this.seed*this.I}}var LayeredDigraphCycleRemove=(w=>(w[w.DepthFirst=0]="DepthFirst",w[w.Greedy=1]="Greedy",w[w.FromLayers=2]="FromLayers",w))(LayeredDigraphCycleRemove||{}),LayeredDigraphLayering=(w=>(w[w.OptimalLinkLength=10]="OptimalLinkLength",w[w.LongestPathSink=11]="LongestPathSink",w[w.LongestPathSource=12]="LongestPathSource",w))(LayeredDigraphLayering||{}),LayeredDigraphInit=(w=>(w[w.DepthFirstOut=20]="DepthFirstOut",w[w.DepthFirstIn=21]="DepthFirstIn",w[w.Naive=22]="Naive",w))(LayeredDigraphInit||{}),LayeredDigraphAggressive=(w=>(w[w.None=30]="None",w[w.Less=31]="Less",w[w.More=32]="More",w))(LayeredDigraphAggressive||{}),LayeredDigraphPack=(w=>(w[w.None=0]="None",w[w.Expand=1]="Expand",w[w.Straighten=2]="Straighten",w[w.Median=4]="Median",w[w.MaybeExpand=8]="MaybeExpand",w[w.All=15]="All",w))(LayeredDigraphPack||{}),LayeredDigraphAlign=(w=>(w[w.None=0]="None",w[w.UpperLeft=1]="UpperLeft",w[w.UpperRight=2]="UpperRight",w[w.LowerLeft=4]="LowerLeft",w[w.LowerRight=8]="LowerRight",w[w.All=15]="All",w))(LayeredDigraphAlign||{});class LayeredDigraphLayout extends Layout{As;_i;C;Zc;$c;Qc;ef;_c;ar;tu;Vn;Lt;Wy;Wt;Og;Ls;pi;nn;Ts;Ds;Gt;Eg;sf;Vg;on;iu;fr;Bn;zn;HN;constructor(t){super(),this.As=25,this._i=25,this.C=0,this.Zc=0,this.$c=10,this.Qc=20,this.ef=4,this._c=31,this.ar=15,this.tu=10,this.Vn=!0,this.Lt=-1,this.Wy=-1,this.Wt=-1,this.Og=0,this.Ls=0,this.pi=null,this.nn=null,this.Ts=null,this.Ds=null,this.Gt=null,this.Eg=0,this.sf=null,this.Vg=null,this.on=0,this.iu=null,this.fr=new Point,this.Bn=[],this.Bn.length=100,this.zn=15,this.HN=0,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.As=this.As,t._i=this._i,t.C=this.C,t.Zc=this.Zc,t.$c=this.$c,t.Qc=this.Qc,t.ef=this.ef,t._c=this._c,t.ar=this.ar,t.tu=this.tu,t.Vn=this.Vn,t.zn=this.zn}fi(t){t in LayeredDigraphAggressive?this.aggressiveOption=t:t in LayeredDigraphCycleRemove?this.cycleRemoveOption=t:t in LayeredDigraphInit?this.initializeOption=t:t in LayeredDigraphLayering?this.layeringOption=t:super.fi(t)}createNetwork(){return new LayeredDigraphNetwork(this)}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin),this.QO(),this.network.vertexes.count>0&&(this.network.deleteSelfEdges(),this.cycleRemoveOption!==2&&this.removeCycles(),this._O(),this.cycleRemoveOption===2&&this.removeCycles(),this.t3(),this.i3(),this.e3(),this.reduceCrossings(),this.straightenAndPack(),this.updateParts()),this.network=null,this.isValidLayout=!0}linkMinLength(t){return 1}linkLengthWeight(t){return 1}linkStraightenWeight(t){const i=t.fromVertex.node||t.fromVertex.data,e=t.toVertex.node||t.toVertex.data;return i===null&&e===null?8:i===null||e===null?4:1}nodeMinLayerSpace(t,i){return t.node===null&&t.data===null?0:this.C===90||this.C===270?i?t.focus.y+10:t.bounds.height-t.focus.y+10:i?t.focus.x+10:t.bounds.width-t.focus.x+10}nodeMinColumnSpace(t,i){if(t.node===null&&t.data===null)return 0;const e=i?t.sk:t.nk;if(e!==null)return e;const s=this.C;return s===90||s===270?i?t.sk=t.focus.x/this._i+1|0:t.nk=(t.bounds.width-t.focus.x)/this._i+1|0:i?t.sk=t.focus.y/this._i+1|0:t.nk=(t.bounds.height-t.focus.y)/this._i+1|0}te(){this.sf===null&&(this.sf=[]);let t=0;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;this.sf[t]=e.layer,t++,this.sf[t]=e.column,t++,this.sf[t]=e.index,t++}return this.sf}es(t){let i=0;const e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;s.layer=t[i],i++,s.column=t[i],i++,s.index=t[i],i++}}nD(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"crossingMatrix:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"crossingMatrix:direction"));const e=this.Oh(t),s=this.pi[t];(this.Vg===null||this.Vg.length=0){for(f=e[o].So,c=0;ck||d===k&&g>S)&&r++,bd||k===d&&S>g)&&r++)}if(i<=0){for(f=e[o].rr,c=0;ck||d===k&&m>b)&&r++,Sd||k===d&&b>m)&&r++)}for(n[o*s+o]=r,a=o+1;a=0){for(p=e[o].So,M=e[a].So,c=0;c=0&&(h=s[r].rr);let a,f=0,c=0;if(l!==null)for(let u=0;u=0&&(h=r.rr);let a=0,f=0;const c=r.near;c!==null&&c.layer===r.layer&&(a+=c.column-1,f++);let u;if(l!==null)for(let d=0;d=0&&(h=r.rr);let a=0;const f=[],c=r.near;c!==null&&c.layer===r.layer&&(f[a]=c.column-1,a++);let u;if(l!==null)for(let d=0;dm-g);const d=a>>1;a&1?n[o]=f[d]:n[o]=f[d-1]+f[d]>>1}}return this.Eh(t,e),n}Zy(t,i,e,s,n){if(t.component===e){t.component=i;let o=0,r=0;if(s){const l=t.destinationEdges;for(;l.next();){const h=l.value,a=h.toVertex;o=t.layer-a.layer,r=this.linkMinLength(h),o===r&&this.Zy(a,i,e,s,n)}}if(n){const l=t.sourceEdges;for(;l.next();){const h=l.value,a=h.fromVertex;o=a.layer-t.layer,r=this.linkMinLength(h),o===r&&this.Zy(a,i,e,s,n)}}}}qN(t,i,e,s,n){if(t.component===e){if(t.component=i,s){const o=t.destinationEdges;for(;o.next();){const l=o.value.toVertex;this.qN(l,i,e,s,n)}}if(n){const o=t.sourceEdges;for(;o.next();){const l=o.value.fromVertex;this.qN(l,i,e,s,n)}}}}removeCycles(){const t=this.network.edges.iterator;for(;t.next();){const i=t.value;i.rev=!1}switch(this.Zc){default:case 1:this.o3();break;case 0:this.r3();break;case 2:this.l3();break}}l3(){const t=this.network,i=t.vertexes.iterator;let e=1/0;for(;i.next();){const s=i.value;e=Math.min(e,s.layer)}if(e<1/0){if(e<0)for(i.reset();i.next();){const r=i.value;r.layer-=e}const s=[];for(i.reset();i.next();){const r=i.value,l=s[r.layer];l===void 0?s[r.layer]=[r]:l.push(r)}let n=0;for(let r=0;r0)for(let h=0;hh.index&&(t.reverseEdge(r),r.rev=!0)}}h3(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.ie)return e}return null}rD(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.ie){let s=!0;const n=e.destinationEdges;for(;n.next();)if(n.value.toVertex.ie){s=!1;break}if(s)return e}}return null}lD(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.ie){let s=!0;const n=e.sourceEdges;for(;n.next();)if(n.value.fromVertex.ie){s=!1;break}if(s)return e}}return null}a3(t){let i=null,e=0;const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;if(n.ie){let o=0;const r=n.destinationEdges;for(;r.next();)r.value.toVertex.ie&&o++;let l=0;const h=n.sourceEdges;for(;h.next();)h.value.fromVertex.ie&&l++;(i===null||ef&&this.Zy(h,e,-1,!0,!1)}for(this.Zy(t,s,-1,!0,!0);t.component!==e;){let r=0,l=1/0,h=0,a=null;const f=this.network.vertexes.iterator;for(;f.next();){const c=f.value;if(c.component===s){let u=0,d=!1;const m=c.So;o=m.length;for(let p=0;p0){for(i.reset();i.next();){const c=i.value;c.component===s&&(c.layer+=l)}t.component=e}else a.component=e}}d3(t){const i=this.network.vertexes.iterator;for(;i.next();){const n=i.value;n.component=-1}const e=0,s=1;for(this.Zy(t,s,-1,!0,!1);t.component!==e;){let n=0,o=1/0,r=0,l=null;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value;if(a.component===s){let f=0,c=!1;const u=a.So;let d=u.length;for(let g=0;gr)&&!c&&(l=a,r=f)}}if(n<0){for(i.reset();i.next();){const a=i.value;a.component===s&&(a.layer-=o)}t.component=e}else l.component=e}}t3(){const t=this.network,i=[],e=t.edges.iterator;for(;e.next();){const s=e.value;s.valid=!1,i.push(s)}for(let s=0;sb&&c>0){for(n.valid=!1,y=t.createVertex(),y.node=null,y.rk=2,y.layer=c-1,x&&kb&&c>0;)y=t.createVertex(),y.node=null,y.rk=3,y.layer=c-1,x&&kt[this.Ls]&&(this.Wy=t[e]-1,this.Ls=e),t[e]{o.index=this.pi[s],this.pi[s]++})}}y3(){let t=null;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;if(e.near&&(t===null&&(t=new Map),e.layer===e.near.layer)){const s=t.get(e.near)||[];s.push(e),t.set(e.near,s)}}for(let e=this.Lt;e>=0;e--)for(i.reset();i.next();){const s=i.value;s.layer===e&&s.index===-1&&this.gD(s,t)}}gD(t,i){if(t.near)return;const e=t.layer;if(t.index=this.pi[e],this.pi[e]++,i){const o=i.get(t);Array.isArray(o)&&o.forEach(r=>{r.index=this.pi[e],this.pi[e]++})}const s=t.rr;let n=!0;for(;n;){n=!1;for(let o=0;ol.portFromColOffset&&(n=!0,s[o]=l,s[o+1]=r)}}for(let o=0;o{a.index=this.pi[e],this.pi[e]++})}const s=t.So;let n=!0,o=0;for(;n;)for(n=!1,o=0;oa.portToColOffset&&(n=!0,s[o]=a,s[o+1]=h)}let r,l;for(o=0;o=0;s--)this.hk(s,-1),this.us(s,-1,!1,-1);n=this.countCrossings(),n=0;s--)this.hk(s,0),this.us(s,0,!1,0);n=this.countCrossings(),n=0;r--)for(l=0;l<=r;l++){for(o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,1,!1,1)||o;for(n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,-1,!1,-1)||o;for(n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,0,!1,0)||o;for(n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,0,!1,0)||o;n>=t?this.es(i):(t=n,i=this.te())}break;default:case 31:for(r=this.Lt,l=0,h=t+1;(a=this.countCrossings())=l;s--)o=this.us(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,1,!1,1)||o;for(n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,-1,!1,-1)||o;for(n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,0,!1,0)||o;for(n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,0,!1,0)||o;n>=t?this.es(i):(t=n,i=this.te())}break}this.es(i)}hk(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"medianBarycenterCrossingReduction:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"medianBarycenterCrossingReduction:direction"));let e=0,s=!1;const n=this.Oh(t),o=this.pi[t],r=this.oD(t,i),l=this.Jy(t,i);for(e=0;e0)for(h=[],l=0;ll+1&&(m+=4*(I-l),g+=4*(I-(l+1)))}}const V=n[l].destinationEdges.iterator;if(e&&s>=0)for(;V.next();){const W=V.value;O=W.toVertex,W.valid&&O.layer!==t&&(N=this.linkStraightenWeight(W),T=W.portFromColOffset,L=W.portToColOffset,F=O.column,C+=(Math.abs(p+T-(F+L))+1)*N,P+=(Math.abs(A+T-(F+L))+1)*N)}for(V.reset();V.next();){const W=V.value;if(O=W.toVertex,W.valid&&O.layer===t){for(B=0;Bl+1&&(m+=4*(I-(l+1)),g+=4*(I-l))}}const z=n[l+1].destinationEdges.iterator;if(e&&s>=0)for(;z.next();){const W=z.value;O=W.toVertex,W.valid&&O.layer!==t&&(N=this.linkStraightenWeight(W),T=W.portFromColOffset,L=W.portToColOffset,F=O.column,C+=(Math.abs(y+T-(F+L))+1)*N,P+=(Math.abs(M+T-(F+L))+1)*N)}for(z.reset();z.next();){const W=z.value;if(O=W.toVertex,W.valid&&O.layer===t){for(B=0;B1e3&&s&&(e=!1),e){const n=[];let o=0;for(o=0;o<=this.Lt;o++)n[o]=0;let r=0;const l=this.network.vertexes.iterator;for(;l.next();){const a=l.value;t=a.layer,r=a.column;const f=this.nodeMinColumnSpace(a,!1);n[t]=Math.max(n[t],r+f)}const h=8;for(l.reset();l.next();){const a=l.value;t=a.layer,r=a.column,a.column=((this.Wt-n[t])*h>>1)+r*h}this.Wt*=h}if(this.ar&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Bg(t,-1)||i;i=this.Bg(this.Ls,0)||i,n++}}if(this.ar&4){for(t=this.Ls+1;t<=this.Lt;t++)this.WN(t,1);for(t=this.Ls-1;t>=0;t--)this.WN(t,-1);this.WN(this.Ls,0)}if(e&&(this.pD(-1),this.pD(1)),this.ar&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Bg(t,0)||i;n++}}}Bg(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"bendStraighten:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"bendStraighten:direction"));let e=!1;for(;this.b3(t,i);)e=!0;return e}b3(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"shiftbendStraighten:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"shiftbendStraighten:direction"));let e=0;const s=this.Oh(t),n=this.pi[t],o=this.Jy(t,-1);if(i>0)for(e=0;ef+this.nodeMinColumnSpace(s[e-1],!1)?u=a-1:u=a;let d=0;e+1>=n||s[e+1].column-a-1>c+this.nodeMinColumnSpace(s[e+1],!0)?d=a+1:d=a;let m=0,g=0,p=0,y=0,x=0,k=0;if(i<=0){const P=s[e].sourceEdges.iterator;for(;P.next();){const N=P.value,T=N.fromVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const L=T.column;m+=(Math.abs(a+k-(L+x))+1)*y,g+=(Math.abs(u+k-(L+x))+1)*y,p+=(Math.abs(d+k-(L+x))+1)*y}}}if(i>=0){const P=s[e].destinationEdges.iterator;for(;P.next();){const N=P.value,T=N.toVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const L=T.column;m+=(Math.abs(a+x-(L+k))+1)*y,g+=(Math.abs(u+x-(L+k))+1)*y,p+=(Math.abs(d+x-(L+k))+1)*y}}}let b=0,S=0,M=0;const A=o[s[e].index],C=r[s[e].index];A!==-1&&(b+=Math.abs(A-a),S+=Math.abs(A-u),M+=Math.abs(A-d)),C!==-1&&(b+=Math.abs(C-a),S+=Math.abs(C-u),M+=Math.abs(C-d)),g=r[e]?u=p:g<=r[e]&&(u=g)),u!==a&&(l=!0,h=!0,s[e].column=u)}return this.Eh(t,s),this.vy(),l}k3(){for(let t=0;t<=this.Wt;t++)for(;this.S3(t,1););this.vy()}S3(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"packAux:column"),Util.r(i,LayeredDigraphLayout,"packAux:direction"));let e=!0;const s=this.network.vertexes.iterator;for(;s.next();){const o=s.value,r=this.nodeMinColumnSpace(o,!0),l=this.nodeMinColumnSpace(o,!1);if(o.column-r<=t&&o.column+l>=t){e=!1;break}}let n=!1;if(e){if(i>0)for(s.reset();s.next();){const o=s.value;o.column>t&&(o.column-=1,n=!0)}if(i<0)for(s.reset();s.next();){const o=s.value;o.column0&&(e=t+1),i<0&&(e=t-1);let s=0;const n=[],o=[];for(s=0;s<=this.Lt;s++)n[s]=!1,o[s]=!1;const r=this.network.vertexes.iterator;for(;r.next();){const a=r.value,f=a.column-this.nodeMinColumnSpace(a,!0),c=a.column+this.nodeMinColumnSpace(a,!1);f<=t&&c>=t&&(n[a.layer]=!0),f<=e&&c>=e&&(o[a.layer]=!0)}let l=!0,h=!1;for(s=0;s<=this.Lt;s++)l=l&&!(n[s]&&o[s]);if(l){if(i>0)for(r.reset();r.next();){const a=r.value;a.column>t&&(a.column-=1,h=!0)}if(i<0)for(r.reset();r.next();){const a=r.value;a.column0)for(i=0;i<=this.Wt;i++)for(e=this.te(),s=this.ok(!0),n=s+1;ss?this.es(e):o=0;i--)for(e=this.te(),s=this.ok(!0),n=s+1;ss?this.es(e):o0)for(e.reset();e.next();){const f=e.value;f.column-this.nodeMinColumnSpace(f,!0)<=t&&(f.component=this.on)}if(i<0)for(e.reset();e.next();){const f=e.value;f.column+this.nodeMinColumnSpace(f,!1)>=t&&(f.component=this.on)}for(this.on++,e.reset();e.next();){const f=e.value;f.component===-1&&(this.qN(f,this.on,-1,!0,!0),this.on++)}let s=0;const n=[];for(s=0;s0)for(let c=0;c0;c--)o[f*(this.Wt+1)+c]!==-1&&o[f*(this.Wt+1)+c-1]!==-1&&o[f*(this.Wt+1)+c]!==o[f*(this.Wt+1)+c-1]&&(n[o[f*(this.Wt+1)+c]*this.on+o[f*(this.Wt+1)+c-1]]=!0)}const r=[];for(s=0;s0)for(e.reset();e.next();){const f=e.value;r[f.component]&&(f.column-=1,a=!0)}if(i<0)for(e.reset();e.next();){const f=e.value;r[f.component]&&(f.column+=1,a=!0)}return a}x3(){const t=Util.ft(),i=this.iu.length;for(let u=0;u<=i;u++)t[u]=[];const e=this.network.vertexes.iterator;for(;e.next();){const u=e.value,d=i-u.layer,m=t[d];m[u.index]=u}const s=new GSet;this.N3(t,s);let n=null,o=null,r=null,l=null;const h=(this.zn&1)!==0,a=(this.zn&2)!==0,f=(this.zn&4)!==0,c=(this.zn&8)!==0;h&&(this.hl(t,s,!0),n=this.ak(t,!0,!1)),t.reverse(),f&&(this.hl(t,s,!1),r=this.ak(t,!1,!1));for(const u of t)u.reverse();c&&(this.hl(t,s,!1),l=this.ak(t,!1,!0)),t.reverse(),a&&(this.hl(t,s,!0),o=this.ak(t,!0,!0)),Util.nt(t),this.C3(n,o,r,l),this.network.vertexes.each(u=>{const d=u,m=Util.ft();h&&m.push(n.get(d)),a&&m.push(o.get(d)),f&&m.push(r.get(d)),c&&m.push(l.get(d)),m.sort((k,b)=>k-b);const g=m.length,p=Math.floor((g-1)/2),y=Math.ceil((g-1)/2),x=(m[p]+m[y])/2;Util.nt(m),d.ue=x})}N3(t,i){const e=t.length;for(let s=1;sc)&&i.add(m)}o++}n=c}}}}A3(t){if(t.node===null){const i=t.getProperSourceVertexes();if(i.length>0)return i[0].node===null}return!1}hl(t,i,e){this.L3(t);for(const s of t){let n=-1;for(const o of s){const r=e?o.getProperSourceVertexes():o.getProperDestinationVertexes(),l=r.length;if(l>0){r.sort((a,f)=>a.Vh-f.Vh);const h=(l-1)/2;for(let a=Math.floor(h),f=Math.ceil(h);a<=f;a++)if(o.Xn===o){const c=r[a];let u;e?u=c.getDestinationEdge(o):u=o.getDestinationEdge(c),!i.has(u)&&n0){const f=this.bD(a,t),c=s?f.width:f.height,u=a.ss.su+a.ue+a.Yn-(f.ue+f.Yn+c+this.columnSpacing);f.ss.su=Math.min(f.ss.su,u)}h=a.Vh+1}while(l0){const s=this.bD(e,i),n=s.nf;this.xD(n,i),t.ss===t&&(t.ss=n.ss);const o=this.C===90||this.C===270?s.width:s.height;if(t.ss===n.ss){const r=n.ue+s.Yn+o-e.Yn+this.columnSpacing;t.ue=Math.max(t.ue,r)}}e=e.Xn}while(e!==t);for(;e.Xn!==t;)e=e.Xn,e.ue=t.ue,e.ss=t.ss}bD(t,i){const e=t.wD,s=t.Vh;return s<1&&Util.n("Could not determine previous vertex in layer"),i[e][s-1]}C3(...t){let i=-1;const e=Util.ft(),s=Util.ft();let n=1/0;for(let o=0;o<4;o++){if(!t[o])continue;const r=this.D3(t[o],e,s,o);r{r.set(h.key,h.value+l)})}Util.nt(e),Util.nt(s)}D3(t,i,e,s){if(!t||t.count===0)return i[s]=0,e[s]=0,1/0;let n=1/0,o=-1/0;return t.each(r=>{const l=r.key,h=r.value,a=this.C===90||this.C===270?l.width:l.height;ho&&(o=h+a)}),i[s]=n,e[s]=o,o-n}commitLayout(){this.jy(),this.commitNodes(),this.vN(),this.isRouting&&this.commitLinks()}jy(){if(!this.setsPortSpots)return;const t=this.lk(!0),i=this.lk(!1),e=this.network.edges.iterator;for(;e.next();){const n=e.value.link;n!==null&&(n.fromSpot=t,n.toSpot=i)}}lk(t){return this.C===270?t?Spot.MiddleTop:Spot.MiddleBottom:this.C===90?t?Spot.MiddleBottom:Spot.MiddleTop:this.C===180?t?Spot.MiddleLeft:Spot.MiddleRight:t?Spot.MiddleRight:Spot.MiddleLeft}commitNodes(){this.nn=[],this.Ts=[],this.Ds=[],this.Gt=[];for(let d=0;d<=this.Lt;d++)this.nn[d]=0,this.Ts[d]=0,this.Ds[d]=0,this.Gt[d]=0;const t=this.network.vertexes.iterator;for(;t.next();){const d=t.value,m=d.layer;this.nn[m]=Math.max(this.nn[m],this.nodeMinLayerSpace(d,!0)),this.Ts[m]=Math.max(this.Ts[m],this.nodeMinLayerSpace(d,!1))}let i=0;const e=this.As;for(let d=0;d<=this.Lt;d++){let m=e;this.nn[d]+this.Ts[d]<=0&&(m=0),d>0&&(i+=m/2),this.C===90||this.C===0?(i+=this.Ts[d],this.Ds[d]=i,i+=this.nn[d]):(i+=this.nn[d],this.Ds[d]=i,i+=this.Ts[d]),d=0;n--)this.C===270?n===0?e.push(new Rect(0,0,s,Math.abs(this.Gt[0]))):e.push(new Rect(0,this.Gt[n-1],s,Math.abs(this.Gt[n-1]-this.Gt[n]))):this.C===90?n===0?e.push(new Rect(0,this.Gt[0],s,Math.abs(this.Gt[0]-t))):e.push(new Rect(0,this.Gt[n],s,Math.abs(this.Gt[n-1]-this.Gt[n]))):this.C===180?n===0?e.push(new Rect(0,0,Math.abs(this.Gt[0]),s)):e.push(new Rect(this.Gt[n-1],0,Math.abs(this.Gt[n-1]-this.Gt[n]),s)):n===0?e.push(new Rect(this.Gt[0],0,Math.abs(this.Gt[0]-t),s)):e.push(new Rect(this.Gt[n],0,Math.abs(this.Gt[n-1]-this.Gt[n]),s));this.commitLayers(e,this.fr)}commitLayers(t,i){}commitLinks(){const t=this.network.edges.iterator;let i;for(;t.next();)i=t.value.link,i!==null&&(i.startRoute(),i.clearPoints(),i.commitRoute());for(t.reset();t.next();)i=t.value.link,i!==null&&i.updateRoute();for(t.reset();t.next();){const e=t.value;if(i=e.link,i===null||i.pointsCount===0)continue;i.startRoute();const s=i;let n=s.fromNode,o=s.toNode,r=s.fromPort,l=s.toPort;if(n!==null){const N=n.findVisibleNode();N!==null&&N!==n&&(n=N,r=N.port)}if(o!==null){const N=o.findVisibleNode();N!==null&&N!==o&&(o=N,l=N.port)}const h=i.computeSpot(!0,r),a=i.computeSpot(!1,l);let f=e.fromVertex,c=e.toVertex;if(e.valid){if(i.curve===9&&i.pointsCount===4)if(f.column===c.column&&this.alignOption===0){const N=i.getLinkPoint(n,r,h,!0,!1,o,l),T=i.getLinkPoint(o,l,a,!1,!1,n,r);N.isReal()||N.set(n.actualBounds.center),T.isReal()||T.set(o.actualBounds.center),i.clearPoints(),i.addPointAt(N.x,N.y),i.addPointAt((2*N.x+T.x)/3,(2*N.y+T.y)/3),i.addPointAt((N.x+2*T.x)/3,(N.y+2*T.y)/3),i.addPointAt(T.x,T.y)}else{let N=!1,T=!1;if(r!==null&&h===Spot.None&&(N=!0),l!==null&&a===Spot.None&&(T=!0),N||T){let L=null;N&&(L=i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0),L.isReal()||L.set(n.actualBounds.center),i.setPointAt(0,L.x,L.y));let D=null;if(T&&(D=i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(0),!1),D.isReal()||D.set(o.actualBounds.center),i.setPointAt(3,D.x,D.y)),L){const F=i.getPoint(2);i.setPointAt(1,(L.x*2+F.x)/3,(L.y*2+F.y)/3)}if(D){const F=i.getPoint(1);i.setPointAt(2,(D.x*2+F.x)/3,(D.y*2+F.y)/3)}}}i.commitRoute();continue}if(f.layer===c.layer){i.commitRoute();continue}let u=!1,d=!1;const m=this.As;let g=0,p=i.firstPickIndex+1;if(i.isOrthogonal)d=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3);else if(i.curve===9)u=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3),g===4&&(p=2);else{g=i.pointsCount;const N=h===Spot.None,T=a===Spot.None;g>2&&N&&T?i.points.removeRange(1,g-2):g>3&&N&&!T?i.points.removeRange(1,g-3):g>3&&!N&&T?i.points.removeRange(2,g-2):g>4&&!N&&!T&&i.points.removeRange(2,g-3)}let y,x,k=0,b=0,S=0,M=0,A=0,C=0,P=0;if(e.rev){let N=0;for(;c!==null&&f!==c;){y=null,x=null;const T=c.sourceEdges.iterator;for(;T.next();){const L=T.value;if(L.link===e.link&&(y=L.fromVertex,x=L.toVertex,y.node===null))break}if(y===null)break;if(y!==f)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=y.centerX,M=y.centerY,d)this.C===180||this.C===0?p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,k,M)):(x!==null?x.centerY:b)!==M&&(A=this.Gt[y.layer-1]+this.fr.x,i.insertPointAt(p++,A,b),i.insertPointAt(p++,A,M)):p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,S,b)):(x!==null?x.centerX:k)!==S&&(A=this.Gt[y.layer-1]+this.fr.y,i.insertPointAt(p++,k,A),i.insertPointAt(p++,S,A));else if(p===i.firstPickIndex+1)if(C=Math.max(10,this.nn[c.layer]),P=Math.max(10,this.Ts[c.layer]),u)this.C===180?S<=c.bounds.x?(N=c.bounds.x,i.insertPointAt(p++,N-C,M),i.insertPointAt(p++,N,M),i.insertPointAt(p++,N+P,M)):(i.insertPointAt(p++,S-C,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S+P,M)):this.C===90?M>=c.bounds.bottom?(N=c.bounds.y+c.bounds.height,i.insertPointAt(p++,S,N+P),i.insertPointAt(p++,S,N),i.insertPointAt(p++,S,N-C)):(i.insertPointAt(p++,S,M+P),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M-C)):this.C===270?M<=c.bounds.y?(N=c.bounds.y,i.insertPointAt(p++,S,N-C),i.insertPointAt(p++,S,N),i.insertPointAt(p++,S,N+P)):(i.insertPointAt(p++,S,M-C),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M+P)):this.C===0&&(S>=c.bounds.right?(N=c.bounds.x+c.bounds.width,i.insertPointAt(p++,N+P,M),i.insertPointAt(p++,N,M),i.insertPointAt(p++,N-C,M)):(i.insertPointAt(p++,S+P,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S-C,M)));else{i.insertPointAt(p++,k,b);let L=0;this.C===180||this.C===0?((this.C===180?S>=c.bounds.right:S<=c.bounds.x)&&(L=(this.C===0?-C:P)/2),i.insertPointAt(p++,k+L,M)):((this.C===270?M>=c.bounds.bottom:M<=c.bounds.y)&&(L=(this.C===90?-C:P)/2),i.insertPointAt(p++,S,b+L)),i.insertPointAt(p++,S,M)}else C=Math.max(10,this.nn[y.layer]),P=Math.max(10,this.Ts[y.layer]),u?this.C===180?(i.insertPointAt(p++,S-C-m,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S+P+m,M)):this.C===90?(i.insertPointAt(p++,S,M+P+m),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M-C-m)):this.C===270?(i.insertPointAt(p++,S,M-C-m),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M+P+m)):(i.insertPointAt(p++,S+P+m,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S-C-m,M)):(this.C===180||this.C===90||this.C,i.insertPointAt(p++,S,M));c=y}if(l===null||h!==Spot.None||d)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=i.getPoint(p).x,M=i.getPoint(p).y,d){const T=this.Ts[f.layer];let L=0;this.C===180||this.C===0?(L=b,L>=f.bounds.y&&L<=f.bounds.bottom&&(this.C===180?S>=f.bounds.x:S<=f.bounds.right)&&(N=f.centerX+(this.C===180?-T:T),L=f.bounds.x&&L<=f.bounds.right&&(this.C===270?M>=f.bounds.y:M<=f.bounds.bottom)&&(N=f.centerY+(this.C===270?-T:T),L=f.bounds.x?(N=f.bounds.x+f.bounds.width,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N+P,b)):this.C===90&&M<=f.bounds.bottom?(N=f.bounds.y,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N-C)):this.C===270&&M>=f.bounds.y?(N=f.bounds.y+f.bounds.height,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N+P)):this.C===0&&S<=f.bounds.right&&(N=f.bounds.x,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N-C,b));else{C=Math.max(10,this.nn[f.layer]),P=Math.max(10,this.Ts[f.layer]);let T=0;this.C===180||this.C===0?((this.C===180?S<=f.bounds.x:S>=f.bounds.right)&&(T=(this.C===0?P:-C)/2),i.insertPointAt(p++,S+T,b)):((this.C===270?M<=f.bounds.y:M>=f.bounds.bottom)&&(T=(this.C===90?P:-C)/2),i.insertPointAt(p++,k,M+T)),i.insertPointAt(p++,S,M)}}else{for(;f!==null&&f!==c;){y=null,x=null;const N=f.destinationEdges.iterator;for(;N.next();){const T=N.value;if(T.link===e.link&&(y=T.toVertex,x=T.fromVertex,x.node!==null&&(x=null),y.node===null))break}if(y===null)break;y!==c&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=y.centerX,M=y.centerY,d?this.C===180||this.C===0?(x!==null?x.centerY:b)!==M&&(A=this.Gt[y.layer]+this.fr.x,p===i.firstPickIndex+1&&(this.C===0?A=Math.max(A,k):A=Math.min(A,k)),i.insertPointAt(p++,A,b),i.insertPointAt(p++,A,M)):(x!==null?x.centerX:k)!==S&&(A=this.Gt[y.layer]+this.fr.y,p===i.firstPickIndex+1&&(this.C===90?A=Math.max(A,b):A=Math.min(A,b)),i.insertPointAt(p++,k,A),i.insertPointAt(p++,S,A)):(C=Math.max(10,this.nn[y.layer]),P=Math.max(10,this.Ts[y.layer]),u?this.C===180?(i.insertPointAt(p++,S+P+m,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S-C-m,M)):this.C===90?(i.insertPointAt(p++,S,M-C-m),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M+P+m)):this.C===270?(i.insertPointAt(p++,S,M+P+m),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M-C-m)):(i.insertPointAt(p++,S-C-m,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S+P+m,M)):this.C===180?(i.insertPointAt(p++,S+P,M),i.insertPointAt(p++,S-C,M)):this.C===90?(i.insertPointAt(p++,S,M-C),i.insertPointAt(p++,S,M+P)):this.C===270?(i.insertPointAt(p++,S,M+P),i.insertPointAt(p++,S,M-C)):(i.insertPointAt(p++,S-C,M),i.insertPointAt(p++,S+P,M)))),f=y}d&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=i.getPoint(p).x,M=i.getPoint(p).y,this.C===180||this.C===0?b!==M&&(this.C===0?A=Math.min(Math.max((S+k)/2,this.Gt[c.layer]+this.fr.x),S):A=Math.max(Math.min((S+k)/2,this.Gt[c.layer]+this.fr.x),S),i.insertPointAt(p++,A,b),i.insertPointAt(p++,A,M)):k!==S&&(this.C===90?A=Math.min(Math.max((M+b)/2,this.Gt[c.layer]+this.fr.y),M):A=Math.max(Math.min((M+b)/2,this.Gt[c.layer]+this.fr.y),M),i.insertPointAt(p++,k,A),i.insertPointAt(p++,S,A)))}if(s!==null&&u&&i.pointsCount>=4){if(r!==null){const N=h===Spot.None?i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0):i.getPoint(0);if(h===Spot.None){const T=i.getPoint(2),L=i.getPoint(3);this.direction===90||this.direction===270?(i.setPointAt(1,(N.x+T.x)/2,T.y),i.setPointAt(2,L.x,(T.y+L.y)/2)):(i.setPointAt(1,T.x,(N.y+T.y)/2),i.setPointAt(2,(T.x+L.x)/2,L.y))}N.isReal()||N.set(n.actualBounds.center),i.setPointAt(0,N.x,N.y)}if(l!==null){const N=a===Spot.None?i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(i.pointsCount-4),!1):i.getPoint(i.pointsCount-1);if(a===Spot.None){const T=i.getPoint(i.pointsCount-3),L=i.getPoint(i.pointsCount-4);this.direction===90||this.direction===270?(i.setPointAt(i.pointsCount-2,(N.x+T.x)/2,T.y),i.setPointAt(i.pointsCount-2,L.x,(T.y+L.y)/2)):(i.setPointAt(i.pointsCount-2,T.x,(N.y+T.y)/2),i.setPointAt(i.pointsCount-3,(T.x+L.x)/2,L.y))}N.isReal()||N.set(o.actualBounds.center),i.setPointAt(i.pointsCount-1,N.x,N.y)}}i.commitRoute(),e.commit()}}QO(){this.Wy=-1,this.Og=0,this.Ls=0,this.sf=null,this.Vg=null,this.iu=null;for(let t=0;t=this.Bn.length){const n=[];for(let o=0;o=0&&(this.As=t,this.invalidateLayout()))}get columnSpacing(){return this._i}set columnSpacing(t){this._i!==t&&(Util.t(t,"number",LayeredDigraphLayout,"columnSpacing"),t>0&&(this._i=t,this.invalidateLayout()))}get direction(){return this.C}set direction(t){this.C!==t&&(Util.t(t,"number",LayeredDigraphLayout,"direction"),t===0||t===90||t===180||t===270?(this.C=t,this.invalidateLayout()):Util.n("LayeredDigraphLayout.direction must be 0, 90, 180, or 270"))}get cycleRemoveOption(){return this.Zc}set cycleRemoveOption(t){this.Zc!==t&&(Util.tt(t,LayeredDigraphCycleRemove,"LayeredDigraphCycleRemove"),(t===1||t===0||t===2)&&(this.Zc=t,this.invalidateLayout()))}get layeringOption(){return this.$c}set layeringOption(t){this.$c!==t&&(Util.tt(t,LayeredDigraphLayering,"LayeredDigraphLayering"),(t===10||t===11||t===12)&&(this.$c=t,this.invalidateLayout()))}get initializeOption(){return this.Qc}set initializeOption(t){this.Qc!==t&&(Util.tt(t,LayeredDigraphInit,"LayeredDigraphInit"),(t===20||t===21||t===22)&&(this.Qc=t,this.invalidateLayout()))}get iterations(){return this.ef}set iterations(t){this.ef!==t&&(Util.r(t,LayeredDigraphNetwork,"iterations"),t>=0&&(this.ef=t,this.invalidateLayout()))}get aggressiveOption(){return this._c}set aggressiveOption(t){this._c!==t&&(Util.tt(t,LayeredDigraphAggressive,"LayeredDigraphAggressive"),(t===30||t===31||t===32)&&(this._c=t,this.invalidateLayout()))}get packOption(){return this.ar}set packOption(t){this.ar!==t&&(Util.t(t,"number",LayeredDigraphLayout,"packOption"),t>=0&&t<8&&(this.ar=t,this.invalidateLayout()))}get packIterations(){return this.tu}set packIterations(t){this.tu=t}get alignOption(){return this.zn}set alignOption(t){this.zn!==t&&(Util.t(t,"number",LayeredDigraphLayout,"align"),t>=0&&t<16&&(this.zn=t,this.invalidateLayout()))}get setsPortSpots(){return this.Vn}set setsPortSpots(t){this.Vn!==t&&(Util.t(t,"boolean",LayeredDigraphLayout,"setsPortSpots"),this.Vn=t,this.invalidateLayout())}get maxLayer(){return this.Lt}get maxIndex(){return this.Wy}get maxColumn(){return this.Wt}get minIndexLayer(){return this.Og}get maxIndexLayer(){return this.Ls}static CycleDepthFirst=0;static CycleGreedy=1;static CycleFromLayers=2;static LayerOptimalLinkLength=10;static LayerLongestPathSink=11;static LayerLongestPathSource=12;static InitDepthFirstOut=20;static InitDepthFirstIn=21;static InitNaive=22;static AggressiveNone=30;static AggressiveLess=31;static AggressiveMore=32;static PackNone=0;static PackExpand=1;static PackStraighten=2;static PackMedian=4;static PackAll=15;static AlignNone=0;static AlignUpperLeft=1;static AlignUpperRight=2;static AlignLowerLeft=4;static AlignLowerRight=8;static AlignAll=15}class SegInfo{_o;F3;b1;R3;I3;Vt;$e;O3;constructor(){this._o=0,this.F3=0,this.b1=0,this.R3=0,this.I3=0,this.Vt=0,this.$e=null,this.O3=0}}class LayeredDigraphNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new LayeredDigraphVertex(this)}createEdge(){return new LayeredDigraphEdge(this)}}class LayeredDigraphVertex extends LayoutVertex{_o;Go;Vt;fk;ck;ie;eu;$n;rk;sk;nk;nf;Xn;wD;Vh;ss;su;ue;Yn;$y=null;Qy=null;_y=null;tw=null;constructor(t){super(t),this._o=-1,this.Go=-1,this.Vt=-1,this.fk=NaN,this.ck=null,this.ie=!1,this.eu=NaN,this.$n=NaN,this.rk=0,this.sk=null,this.nk=null}static kD(t,i){return t.index-i.index}getProperSourceEdges(){if(!this._y){const t=[];for(const i of this.So){const e=i;e.valid&&t.push(e)}this._y=t}return this._y}getProperDestinationEdges(){if(!this.tw){const t=[];for(const i of this.rr){const e=i;e.valid&&t.push(e)}this.tw=t}return this.tw}getDestinationEdge(t){const i=this.getProperDestinationEdges();for(const e of i)if(e.toVertex===t)return e;Util.n("Unable to find destination edge to given vertex")}getProperSourceVertexes(){if(!this.$y){const t=[];for(const i of this.So){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.fromVertex)}t.sort(LayeredDigraphVertex.kD),this.$y=t}return this.$y}getProperDestinationVertexes(){if(!this.Qy){const t=[];for(const i of this.rr){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.toVertex)}t.sort(LayeredDigraphVertex.kD),this.Qy=t}return this.Qy}addSourceEdge(t){super.addSourceEdge(t),this.$y=null,this._y=null}deleteSourceEdge(t){super.deleteSourceEdge(t),this.$y=null,this._y=null}addDestinationEdge(t){super.addDestinationEdge(t),this.Qy=null,this.tw=null}deleteDestinationEdge(t){super.deleteDestinationEdge(t),this.Qy=null,this.tw=null}get layer(){return this._o}set layer(t){this._o!==t&&(Util.t(t,"number",LayeredDigraphVertex,"layer"),this._o=t)}get column(){return this.Go}set column(t){this.Go!==t&&(Util.t(t,"number",LayeredDigraphVertex,"column"),this.Go=t)}get index(){return this.Vt}set index(t){this.Vt!==t&&(Util.t(t,"number",LayeredDigraphVertex,"index"),this.Vt=t)}get component(){return this.fk}set component(t){this.fk!==t&&(Util.t(t,"number",LayeredDigraphVertex,"component"),this.fk=t)}get near(){return this.ck}set near(t){this.ck!==t&&(Debug&&t!==null&&Util.s(t,LayeredDigraphVertex,LayeredDigraphVertex,"near"),this.ck=t)}}class LayeredDigraphEdge extends LayoutEdge{ie;uk;dk;gk;mk;pk;yk;constructor(t){super(t),this.ie=!1,this.uk=!1,this.dk=!1,this.gk=NaN,this.mk=NaN,this.pk=0,this.yk=0}get fromVertex(){return this._e}set fromVertex(t){this._e!==t&&(Debug&&t!==null&&Util.s(t,LayeredDigraphVertex,LayeredDigraphEdge,"fromVertex"),this._e=t)}get toVertex(){return this.ts}set toVertex(t){this.ts!==t&&(Debug&&t!==null&&Util.s(t,LayeredDigraphVertex,LayeredDigraphEdge,"toVertex"),this.ts=t)}get valid(){return this.ie}set valid(t){this.ie!==t&&(Util.t(t,"boolean",LayeredDigraphEdge,"valid"),this.ie=t)}get rev(){return this.uk}set rev(t){this.uk!==t&&(Util.t(t,"boolean",LayeredDigraphEdge,"rev"),this.uk=t)}get forest(){return this.dk}set forest(t){this.dk!==t&&(Util.t(t,"boolean",LayeredDigraphEdge,"forest"),this.dk=t)}get portFromPos(){return this.gk}set portFromPos(t){this.gk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portFromPos"),this.gk=t)}get portToPos(){return this.mk}set portToPos(t){this.mk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portToPos"),this.mk=t)}get portFromColOffset(){return this.pk}set portFromColOffset(t){this.pk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portFromColOffset"),this.pk=t)}get portToColOffset(){return this.yk}set portToColOffset(t){this.yk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portToColOffset"),this.yk=t)}}var TreePath=(w=>(w[w.Default=0]="Default",w[w.Destination=1]="Destination",w[w.Source=2]="Source",w))(TreePath||{}),TreeSorting=(w=>(w[w.Forwards=10]="Forwards",w[w.Reverse=11]="Reverse",w[w.Ascending=12]="Ascending",w[w.Descending=13]="Descending",w))(TreeSorting||{}),TreeAlignment=(w=>(w[w.CenterSubtrees=20]="CenterSubtrees",w[w.CenterChildren=21]="CenterChildren",w[w.Start=22]="Start",w[w.End=23]="End",w[w.Bus=24]="Bus",w[w.BusBranching=25]="BusBranching",w[w.TopLeftBus=26]="TopLeftBus",w[w.BottomRightBus=27]="BottomRightBus",w[w.Custom=28]="Custom",w))(TreeAlignment||{}),TreeCompaction=(w=>(w[w.None=30]="None",w[w.Block=31]="Block",w))(TreeCompaction||{}),TreeStyle=(w=>(w[w.Layered=40]="Layered",w[w.LastParents=41]="LastParents",w[w.Alternating=42]="Alternating",w[w.RootOnly=43]="RootOnly",w))(TreeStyle||{}),TreeArrangement=(w=>(w[w.Vertical=50]="Vertical",w[w.Horizontal=51]="Horizontal",w[w.FixedRoots=52]="FixedRoots",w))(TreeArrangement||{}),TreeLayerStyle=(w=>(w[w.Individual=60]="Individual",w[w.Siblings=61]="Siblings",w[w.Uniform=62]="Uniform",w))(TreeLayerStyle||{});class TreeLayout extends Layout{Ei;Ii;nu;zg;JN;Be;qi;Cs;K;U;wk;ds;constructor(t){super(),this.Ei=new GSet,this.Ii=0,this.ds=1,this.nu=40,this.zg=60,this.JN=[],this.Be=!0,this.qi=50,this.Cs=new Size(10,10).w();const i=new TreeNetwork(this);this.K=new TreeVertex(i),this.U=new TreeVertex(i),this.wk=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Ii=this.Ii,t.nu=this.nu,t.zg=this.zg,t.Be=this.Be,t.qi=this.qi,t.Cs.c(this.Cs),t.K.copyInheritedPropertiesFrom(this.K),t.U.copyInheritedPropertiesFrom(this.U)}fi(t){t in TreeAlignment?this.alignment=t:t in TreeArrangement?this.arrangement=t:t in TreeCompaction?this.compaction=t:t in TreePath?this.path=t:t in TreeSorting?this.sorting=t:t in TreeStyle?this.treeStyle=t:super.fi(t)}createNetwork(){return new TreeNetwork(this)}makeNetwork(t){const i=this.createNetwork(),e=s=>{if(s instanceof Node)return!s.isLinkLabel&&s.category!=="Comment";if(s instanceof Link){const n=s.fromNode;if(n===null||n.isLinkLabel||n.category==="Comment")return!1;const o=s.toNode;return!(o===null||o.isLinkLabel||o.category==="Comment")}return!1};return t instanceof Diagram?(i.addParts(t.nodes,!0,e),i.addParts(t.links,!0,e)):t instanceof Group?i.addParts(t.memberParts,!1,e):i.addParts(t.iterator,!1,e),i}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.network===null&&(this.network=this.makeNetwork(t)),this.arrangement!==52&&(this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin));let i=this.diagram;i===null&&t instanceof Diagram&&(i=t),this.path===0&&i!==null?this.ds=i.isTreePathToChildren?1:2:this.ds=this.path===0?1:this.path,this.network.vertexes.count>0&&(this.E3(),this.V3(),this.B3(),this.z3(),this.UN(),this.X3(),this.arrangeTrees(),this.updateParts()),this.network=null,this.Ei=new GSet,this.isValidLayout=!0}E3(){this.network.deleteSelfEdges();const t=this.network.vertexes.iterator;for(;t.next();){const n=t.value;n.initialized=!1,n.level=0,n.parent=null,n.children=[]}if(this.Ei.count>0){const n=new GSet,o=this.Ei.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=this.network.findVertex(r);l!==null&&n.add(l)}else r instanceof TreeVertex&&n.add(r)}this.Ei=n}this.Ei.count===0&&this.findRoots();const i=this.Ei.copy().iterator;for(;i.next();){const n=i.value;n.initialized||(n.initialized=!0,this.ZN(n))}let e=this.network.vertexes,s=null;for(;s=this.Y3(e),s.count>0;){const n=this.SD(s);n!==null&&this.Ei.add(n),n.initialized=!0,this.ZN(n),e=s}}Y3(t){const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;s.initialized||i.add(s)}return i}findRoots(){const t=this.network.vertexes,i=t.iterator;for(;i.next();){const e=i.value;switch(this.ds){case 1:e.sourceEdges.count===0&&this.Ei.add(e);break;case 2:e.destinationEdges.count===0&&this.Ei.add(e);break;default:Util.n("Unhandled path value "+this.ds.toString())}}if(this.Ei.count===0){const e=this.SD(t);e!==null&&this.Ei.add(e)}}SD(t){let i=999999,e=null;const s=t.iterator;for(;s.next();){const n=s.value;switch(this.ds){case 1:n.sourceEdges.count0){const s=new List,n=t.destinationVertexes;for(;n.next();){const o=n.value;this.MD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;case 2:if(t.sourceEdges.count>0){const s=new List,n=t.sourceVertexes;for(;n.next();){const o=n.value;this.MD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;default:Util.n("Unhandled path value"+this.ds.toString())}const i=t.children,e=i.length;for(let s=0;st.level?!1:(this.U3(i.parent,i),!0):!0}K3(t,i){if(i===null)return!1;Debug&&Util.s(t,TreeVertex,TreeLayout,"isAncestor:a"),Debug&&Util.s(i,TreeVertex,TreeLayout,"isAncestor:b");let e=i.parent;for(;e!==null&&e!==t;)e=e.parent;return e===t}U3(t,i){if(t===null||i===null)return;Debug&&Util.s(t,TreeVertex,TreeLayout,"removeChild:p"),Debug&&Util.s(i,TreeVertex,TreeLayout,"removeChild:c");const e=t.children;let s=0;for(let n=0;n0){const n=new Array(e.length-s);let o=0;for(let r=0;r0?s+1:0}G3(t){switch(Debug&&Util.s(t,TreeVertex,TreeLayout,"mom:v"),this.nu){default:case 40:return t.parent!==null?t.parent:this.K;case 43:return t.parent===null?this.K:t.parent.parent===null?this.U:t.parent;case 42:return t.parent!==null?t.parent.parent!==null?t.parent.parent:this.U:this.K;case 41:{let i=!0;if(t.childrenCount===0)i=!1;else{const e=t.children,s=e.length;for(let n=0;n0){i=!1;break}}return i&&t.parent!==null?this.U:t.parent!==null?t.parent:this.K}}}initializeTreeVertexValues(t){Debug&&Util.s(t,TreeVertex,TreeLayout,"initializeTreeVertexValues:v");const i=this.G3(t);if(t.copyInheritedPropertiesFrom(i),t.parent!==null&&t.parent.alignment===25){let e=t.angle;const s=t.parent.children;let n=0;for(;n135&&!l||a&&c)if(t.commentMargin>=0){g.e(t.bounds.x-t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleLeft,S.toSpot=Spot.MiddleRight}}else{g.e(t.bounds.x+t.focus.x*2-t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleRight,S.toSpot=Spot.MiddleLeft}}else if(t.commentMargin>=0){g.e(t.bounds.x+t.focus.x*2+t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleRight,S.toSpot=Spot.MiddleLeft}}else{g.e(t.bounds.x+t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleLeft,S.toSpot=Spot.MiddleRight}}t.commentSpacing>=0?u+=k.height+t.commentSpacing:u+=t.commentSpacing-k.height}else{if(o>135&&!l||!a&&c)if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y-t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleTop,S.toSpot=Spot.MiddleBottom}}else{g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2-t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleBottom,S.toSpot=Spot.MiddleTop}}else if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2+t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleBottom,S.toSpot=Spot.MiddleTop}}else{g.e(t.bounds.x+u,t.bounds.y+t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleTop,S.toSpot=Spot.MiddleBottom}}t.commentSpacing>=0?u+=k.width+t.commentSpacing:u+=t.commentSpacing-k.width}}Point.o(g);const p=u-t.commentSpacing-(h?e.height:e.width);if(this.ds===1){const y=t.destinationEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.fromEndSegmentLength=p>0?p:NaN)}}else{const y=t.sourceEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.toEndSegmentLength=p>0?p:NaN)}}}}X3(){if(this.layerStyle===62){const i=[];let e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;let n=s.parent;n===null&&(n=s);const o=n.angle===0||n.angle===180;let r=i[s.level];r===void 0&&(r=0),i[s.level]=Math.max(r,o?s.width:s.height)}for(let s=0;s=0)for(let o=0;o135&&n.reverse(),this.iw(r))if(o>1)for(let R=0;R0&&P>0&&M+u+O.width>f&&(M135?-b-g:b+g);const B=P===0?m:u;this.xk(I,0,A),I.X.e(M+B,A),k=Math.max(k,M+B+O.width),b=Math.max(b,S+(C===0?0:g)+O.height),M+=B+O.width}else{f>0&&P>0&&A+u+O.height>f&&(A135?-k-g:k+g);const B=P===0?m:u;this.xk(I,M,0),I.X.e(M,A+B),b=Math.max(b,A+B+O.height),k=Math.max(k,S+(C===0?0:g)+O.width),A+=B+O.height}P++}C>0&&(e?(b+=Math.max(0,c),M0&&(h||this.lu(t,p,0,0,o-1),k+=p)):(k+=Math.max(0,c),A0&&(h||this.lu(t,0,p,0,o-1),b+=p)));let D=0,F=0;switch(r){case 20:e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;break;default:case 21:if(C>0)e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;else{const I=o;if(e){const O=n[0].X.x+n[0].rt.x,B=n[I-1].X.x+n[I-1].rt.x+n[I-1].focus.x*2;D+=O+(B-O)/2-t.focus.x-d/2}else{const O=n[0].X.y+n[0].rt.y,B=n[I-1].X.y+n[I-1].rt.y+n[I-1].focus.y*2;F+=O+(B-O)/2-t.focus.y-d/2}}break;case 22:e?(D-=d,k+=d):(F-=d,b+=d);break;case 23:e?(D+=k-t.width+d,k+=d):(F+=b-t.height+d,b+=d);break;case 24:case 25:e?o>1?D+=T+u/2-t.focus.x:D+=n[0].focus.x-t.focus.x+n[0].rt.x:o>1?F+=T+u/2-t.focus.y:F+=n[0].focus.y-t.focus.y+n[0].rt.y;break;case 26:e?D+=k+u/2-t.focus.x:F+=b+u/2-t.focus.y;break;case 27:break;case 28:const R=this.customAlignment(t,D,F,k,b);D=R[0],F=R[1],k=R[2],b=R[3];break}for(let R=0;R135?(a?-b:-I.kt.height)+I.rt.y-c:x+c+I.rt.y)):I.X.e(I.X.x+(i>135?(a?-k:-I.kt.width)+I.rt.x-c:y+c+I.rt.x),I.X.y+I.rt.y-F)}e?(k=this.QN(t,k,D),D<0&&(D=0),i>135&&(F+=b+c),b=Math.max(Math.max(b,x),b+x+c)):(i>135&&(D+=k+c),k=Math.max(Math.max(k,y),k+y+c),b=this._N(t,b,F),F<0&&(F=0)),t.rt.e(D,F),t.kt.e(k,b)}customAlignment(t,i,e,s,n){return[i,e,s,n]}LD(t,i,e,s,n,o){Debug&&Util.s(t,TreeVertex,TreeLayout,"layoutBusChildrenPosDir:v");const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.kt.width,o=p.kt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,f=this.orthoAngle(t)===90;let c=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.kt,k=c===0?0:h;if(f){const b=this.computeBusNodeSpacing(y)-l;y.X.e(e-(x.width+b),d+k),n=Math.max(n,x.width+b),o=Math.max(o,d+k+x.height),d+=k+x.height}else{const b=this.computeBusNodeSpacing(y)-l;y.X.e(u+k,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,u+k+x.width),u+=k+x.width}c++}c=0;const m=u,g=d;f?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.kt,x=this.computeBusLastRowSpacing(p,f?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(f){p.X.e(e+l/2-p.focus.x-p.rt.x,o+x);const k=e+l/2-p.focus.x-p.rt.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.max(g,d)+x+y.height),p.X.x<0&&(e=this.bk(t,p.X.x,!1,e,l))}else{p.X.e(n+x,e+l/2-p.focus.y-p.rt.y),n=Math.max(n,Math.max(m,u)+x+y.width);const k=e+l/2-p.focus.y-p.rt.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.X.y<0&&(e=this.bk(t,p.X.y,!0,e,l))}}return new Rect(e,0,n,o)}TD(t,i,e,s,n,o){Debug&&Util.s(t,TreeVertex,TreeLayout,"layoutBusChildrenNegDir:v");const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.kt.width,o=p.kt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,f=this.orthoAngle(t)===270;let c=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.kt,k=c===0?0:h;if(f){const b=this.computeBusNodeSpacing(y)-l;d-=k+x.height,y.X.e(e-(x.width+b),d),n=Math.max(n,x.width+b),o=Math.max(o,Math.abs(d))}else{const b=this.computeBusNodeSpacing(y)-l;u-=k+x.width,y.X.e(u,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,Math.abs(u))}c++}c=0;const m=u,g=d;f?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.kt,x=this.computeBusLastRowSpacing(p,f?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(f){p.X.e(e+l/2-p.focus.x-p.rt.x,-o-y.height-x);const k=e+l/2-p.focus.x-p.rt.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.abs(Math.min(g,d))+x+y.height),p.X.x<0&&(e=this.bk(t,p.X.x,!1,e,l))}else{p.X.e(-n-y.width-x,e+l/2-p.focus.y-p.rt.y),n=Math.max(n,Math.abs(Math.min(m,u))+x+y.width);const k=e+l/2-p.focus.y-p.rt.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.X.y<0&&(e=this.bk(t,p.X.y,!0,e,l))}}for(let p=0;ps&&(s=e+t.width),e<0&&(s-=e),s;case 22:return t.width>i?t.width:i;case 23:return t.focus.x*2>i?t.width:i+t.width-t.focus.x*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.width);return Math.max(t.width,o-n);case 26:return t.width-t.focus.x+t.nodeSpacing/2+i;case 27:return Math.max(t.width,t.focus.x+t.nodeSpacing/2+i);default:return i}}_N(t,i,e){switch(Debug&&Util.s(t,TreeVertex,TreeLayout,"calculateSubheight:v"),t.alignment){case 21:case 20:let s=i;return e+t.height>s&&(s=e+t.height),e<0&&(s-=e),s;case 22:return t.height>i?t.height:i;case 23:return t.focus.y*2>i?t.height:i+t.height-t.focus.y*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.height);return Math.max(t.height,o-n);case 26:return t.height-t.focus.y+t.nodeSpacing/2+i;case 27:return Math.max(t.height,t.focus.y+t.nodeSpacing/2+i);default:return i}}tC(t,i,e){switch(Debug&&Util.tt(t,TreeAlignment,"TreeAlignment"),t){case 20:i/=2,e/=2;break;case 21:i/=2,e/=2;break;case 22:i=0,e=0;break;case 23:break;default:Util.n("Unhandled alignment value "+t.toString())}return new Point(i,e)}of(t,i,e,s,n,o){Debug&&Util.s(t,TreeVertex,TreeLayout,"shiftRelPosAlign:v"),Debug&&Util.tt(i,TreeAlignment,"TreeAlignment");const r=this.tC(i,e,s);this.lu(t,r.x,r.y,n,o)}lu(t,i,e,s,n){if(Debug&&Util.s(t,TreeVertex,TreeLayout,"shiftRelPos:v"),i===0&&e===0)return;const o=t.children;for(let r=s;r<=n;r++){const h=o[r].X;h.x+=i,h.y+=e}}xk(t,i,e){Debug&&(Util.s(t,TreeVertex,TreeLayout,"recordMidPoints:v"),Util.t(i,"number",TreeLayout,"recordMidPoints:x"),Util.t(e,"number",TreeLayout,"recordMidPoints:y"));const s=t.parent;switch(this.ds){case 1:{const n=t.sourceEdges;for(;n.next();){const o=n.value;o.fromVertex===s&&o.relativePoint.e(i,e)}break}case 2:{const n=t.destinationEdges;for(;n.next();){const o=n.value;o.toVertex===s&&o.relativePoint.e(i,e)}break}default:Util.n("Unhandled path value "+this.ds.toString())}}H3(t){if(Debug&&Util.s(t,TreeVertex,TreeLayout,"layoutTreeBlock:v"),t.childrenCount===0){const z=t.parent;let G=!1,q=0,j=21;z!==null&&(q=z.angle,j=z.alignment,G=this.isBusAlignment(j));const J=this.$N(t);t.X.e(0,0),t.kt.e(t.width,t.height),t.parent!==null&&t.comments!==null&&((q===180||q===270)&&!G||J)?q===180&&!G||(q===90||q===270)&&J?t.rt.e(t.width-t.focus.x*2,0):t.rt.e(0,t.height-t.focus.y*2):t.rt.e(0,0),t.Xg=null,t.Yg=null;return}const i=this.orthoAngle(t),e=i===90||i===270;let s=0;const n=t.children,o=n.length;for(let z=0;z135&&n.reverse(),this.iw(r))if(o>1)for(let z=0;z0&&L>0&&P+u+q.width>f&&(P135?-k-m:k+m),this.xk(G,0,N);let j=0;if(L===0)S=G.Xg,M=G.Yg,A=q.width,C=q.height,(S===null||M===null||i!==this.orthoAngle(G))&&(S=this.de(2),M=this.de(2),S[0].e(0,0),S[1].e(0,C),M[0].e(A,0),M[1].e(A,C));else{const J=Util.ft(),Y=this.DD(t,G,S,M,A,C,J);j=Y.x,S=J[0],M=J[1],A=Y.width,C=Y.height,Util.nt(J),P0&&L>0&&N+u+q.height>f&&(N135?-x-m:x+m),this.xk(G,P,0);let j=0;if(L===0)S=G.Xg,M=G.Yg,A=q.width,C=q.height,(S===null||M===null||i!==this.orthoAngle(G))&&(S=this.de(2),M=this.de(2),S[0].e(0,0),S[1].e(A,0),M[0].e(0,C),M[1].e(A,C));else{const J=Util.ft(),Y=this.DD(t,G,S,M,A,C,J);j=Y.x,S=J[0],M=J[1],A=Y.width,C=Y.height,Util.nt(J),N0&&(e?(k+=Math.max(0,c),P0&&(h||this.lu(t,g,0,0,o-1),x+=g)):(x+=Math.max(0,c),N0&&(h||this.lu(t,0,g,0,o-1),k+=g)));let I=0,O=0;switch(r){case 20:e?I+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;break;default:case 21:if(T>0)e?I+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;else{const G=o;if(e){const q=n[0].X.x+n[0].rt.x,j=n[G-1].X.x+n[G-1].rt.x+n[G-1].focus.x*2;I+=q+(j-q)/2-t.focus.x-d/2}else{const q=n[0].X.y+n[0].rt.y,j=n[G-1].X.y+n[G-1].rt.y+n[G-1].focus.y*2;O+=q+(j-q)/2-t.focus.y-d/2}}break;case 22:e?(I-=d,x+=d):(O-=d,k+=d);break;case 23:e?(I+=x-t.width+d,x+=d):(O+=k-t.height+d,k+=d);break;case 24:e?o>1?I+=F+u/2-t.focus.x:I+=n[0].focus.x-t.focus.x+n[0].rt.x:o>1?O+=F+u/2-t.focus.y:O+=n[0].focus.y-t.focus.y+n[0].rt.y;break;case 26:e?I+=x+u/2-t.focus.x:O+=k+u/2-t.focus.y;break;case 27:break;case 28:const z=this.customAlignment(t,I,O,x,k);I=z[0],O=z[1],x=z[2],k=z[3];break}for(let z=0;z135?(a?-k:-G.kt.height)+G.rt.y-c:y+c+G.rt.y)):G.X.e(G.X.x+(i>135?(a?-x:-G.kt.width)+G.rt.x-c:p+c+G.rt.x),G.X.y+G.rt.y-O)}let B=0,K=0;if(a)e?(x=this.QN(t,x,I),I<0&&(I=0),i>135&&(O+=k+c),k+=y+c,r===27&&(B+=u/2+t.focus.x),K+=y+c):(i>135&&(I+=x+c),x+=p+c,k=this._N(t,k,O),O<0&&(O=0),r===27&&(K+=u/2+t.focus.y),B+=p+c);else if(e){if(t.comments===null){if(p>x){const z=this.tC(r,p-x,0);B=z.x,K=z.y,x=p,I=0}}else x=this.QN(t,x,I);I<0&&(B-=I,I=0),i>135&&(O+=k+c),k=Math.max(Math.max(k,y),k+y+c),K+=y+c}else{if(i>135&&(I+=x+c),x=Math.max(Math.max(x,p),x+p+c),t.comments===null){if(y>k){const z=this.tC(r,0,y-k);B=z.x,K=z.y,k=y,O=0}}else k=this._N(t,k,O);O<0&&(K-=O,O=0),B+=p+c}let V,X;if(T>0)V=this.de(4),X=this.de(4),e?(V[2].e(0,y+c),V[3].e(V[2].x,k),X[2].e(x,V[2].y),X[3].e(X[2].x,V[3].y)):(V[2].e(p+c,0),V[3].e(x,V[2].y),X[2].e(V[2].x,k),X[3].e(V[3].x,X[2].y));else{V=this.de(S.length+2),X=this.de(M.length+2);for(let z=0;zV[0].x?V[2].c(V[1]):V[1].c(V[2])),V[3].yV[0].x?V[3].c(V[2]):V[2].c(V[3])),X[0].e(I+p,0),X[1].e(X[0].x,y),X[2].yV[0].y?V[2].c(V[1]):V[1].c(V[2])),V[3].xV[0].y?V[3].c(V[2]):V[2].c(V[3])),X[0].e(0,O+y),X[1].e(p,X[0].y),X[2].xl;){const a=i[o++];s[r++].e(a.x,a.y+e)}const h=this.de(r);for(n=0;nl;){const a=i[o++];s[r++].e(a.x+e,a.y)}const h=this.de(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.de(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.de(r);for(n=0;nh&&r.xr.x&&ha&&r.yr.y&&a0){const n=Math.min(1,t.layerSpacingParentOverlap);s-=e?t.height*n:t.width*n}return s<(e?-t.height:-t.width)&&(s=e?-t.height:-t.width),s}computeNodeIndent(t){Debug&&Util.s(t,TreeVertex,TreeLayout,"computeNodeIndent:v");const i=this.orthoAngle(t),e=i===90||i===270;let s=t.nodeIndent;if(t.nodeIndentPastParent>0){const n=Math.min(1,t.nodeIndentPastParent);s+=e?t.width*n:t.height*n}return s=Math.max(0,s),s}get roots(){return this.Ei}set roots(t){this.Ei!==t&&(Util.s(t,GSet,TreeLayout,"roots"),this.Ei=t,this.invalidateLayout())}get path(){return this.Ii}set path(t){this.Ii!==t&&(Util.tt(t,TreePath,"TreePath"),this.Ii=t,this.invalidateLayout())}get treeStyle(){return this.nu}set treeStyle(t){this.nu!==t&&(Util.tt(t,TreeStyle,"TreeStyle"),(t===40||t===42||t===41||t===43)&&(this.nu=t,this.invalidateLayout()))}get layerStyle(){return this.zg}set layerStyle(t){this.zg!==t&&(Util.tt(t,TreeLayerStyle,"TreeLayerStyle"),(t===60||t===61||t===62)&&(this.zg=t,this.invalidateLayout()))}get comments(){return this.Be}set comments(t){this.Be!==t&&(Util.t(t,"boolean",TreeLayout,"comments"),this.Be=t,this.invalidateLayout())}get arrangement(){return this.qi}set arrangement(t){this.qi!==t&&(Util.tt(t,TreeArrangement,"TreeArrangement"),(t===50||t===51||t===52)&&(this.qi=t,this.invalidateLayout()))}get arrangementSpacing(){return this.Cs}set arrangementSpacing(t){Util.s(t,Size,TreeLayout,"arrangementSpacing"),this.Cs.equals(t)||(this.Cs.c(t),this.invalidateLayout())}get rootDefaults(){return this.K}set rootDefaults(t){this.K!==t&&(Util.s(t,TreeVertex,TreeLayout,"rootDefaults"),this.K=t,this.invalidateLayout())}get alternateDefaults(){return this.U}set alternateDefaults(t){this.U!==t&&(Util.s(t,TreeVertex,TreeLayout,"alternateDefaults"),this.U=t,this.invalidateLayout())}get sorting(){return this.K.sorting}set sorting(t){this.K.sorting!==t&&(Util.tt(t,TreeSorting,"TreeSorting"),this.K.sorting=t,this.invalidateLayout())}get comparer(){return this.K.comparer}set comparer(t){this.K.comparer!==t&&(Util.t(t,"function",TreeLayout,"comparer"),this.K.comparer=t,this.invalidateLayout())}get angle(){return this.K.angle}set angle(t){this.K.angle!==t&&(Util.t(t,"number",TreeLayout,"angle"),t===0||t===90||t===180||t===270?(this.K.angle=t,this.invalidateLayout()):Util.n("TreeLayout.angle must be 0, 90, 180, or 270"))}get alignment(){return this.K.alignment}set alignment(t){this.K.alignment!==t&&(Util.tt(t,TreeAlignment,"TreeAlignment"),this.K.alignment=t,this.invalidateLayout())}get nodeIndent(){return this.K.nodeIndent}set nodeIndent(t){this.K.nodeIndent!==t&&(Util.t(t,"number",TreeLayout,"nodeIndent"),t>=0&&(this.K.nodeIndent=t,this.invalidateLayout()))}get nodeIndentPastParent(){return this.K.nodeIndentPastParent}set nodeIndentPastParent(t){this.K.nodeIndentPastParent!==t&&(Util.t(t,"number",TreeLayout,"nodeIndentPastParent"),t>=0&&t<=1&&(this.K.nodeIndentPastParent=t,this.invalidateLayout()))}get nodeSpacing(){return this.K.nodeSpacing}set nodeSpacing(t){this.K.nodeSpacing!==t&&(Util.t(t,"number",TreeLayout,"nodeSpacing"),this.K.nodeSpacing=t,this.invalidateLayout())}get layerSpacing(){return this.K.layerSpacing}set layerSpacing(t){this.K.layerSpacing!==t&&(Util.t(t,"number",TreeLayout,"layerSpacing"),this.K.layerSpacing=t,this.invalidateLayout())}get layerSpacingParentOverlap(){return this.K.layerSpacingParentOverlap}set layerSpacingParentOverlap(t){this.K.layerSpacingParentOverlap!==t&&(Util.t(t,"number",TreeLayout,"layerSpacingParentOverlap"),t>=0&&t<=1&&(this.K.layerSpacingParentOverlap=t,this.invalidateLayout()))}get compaction(){return this.K.compaction}set compaction(t){this.K.compaction!==t&&(Util.tt(t,TreeCompaction,"TreeCompaction"),(t===30||t===31)&&(this.K.compaction=t,this.invalidateLayout()))}get breadthLimit(){return this.K.breadthLimit}set breadthLimit(t){this.K.breadthLimit!==t&&(Util.t(t,"number",TreeLayout,"breadthLimit"),t>=0&&(this.K.breadthLimit=t,this.invalidateLayout()))}get rowSpacing(){return this.K.rowSpacing}set rowSpacing(t){this.K.rowSpacing!==t&&(Util.t(t,"number",TreeLayout,"rowSpacing"),this.K.rowSpacing=t,this.invalidateLayout())}get rowIndent(){return this.K.rowIndent}set rowIndent(t){this.K.rowIndent!==t&&(Util.t(t,"number",TreeLayout,"rowIndent"),t>=0&&(this.K.rowIndent=t,this.invalidateLayout()))}get commentSpacing(){return this.K.commentSpacing}set commentSpacing(t){this.K.commentSpacing!==t&&(Util.t(t,"number",TreeLayout,"commentSpacing"),this.K.commentSpacing=t,this.invalidateLayout())}get commentMargin(){return this.K.commentMargin}set commentMargin(t){this.K.commentMargin!==t&&(Util.t(t,"number",TreeLayout,"commentMargin"),this.K.commentMargin=t,this.invalidateLayout())}get setsPortSpot(){return this.K.setsPortSpot}set setsPortSpot(t){this.K.setsPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"setsPortSpot"),this.K.setsPortSpot=t,this.invalidateLayout())}get portSpot(){return this.K.portSpot}set portSpot(t){Util.s(t,Spot,TreeLayout,"portSpot"),this.K.portSpot.equals(t)||(this.K.portSpot=t,this.invalidateLayout())}get setsChildPortSpot(){return this.K.setsChildPortSpot}set setsChildPortSpot(t){this.K.setsChildPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"setsChildPortSpot"),this.K.setsChildPortSpot=t,this.invalidateLayout())}get childPortSpot(){return this.K.childPortSpot}set childPortSpot(t){Util.s(t,Spot,TreeLayout,"childPortSpot"),this.K.childPortSpot.equals(t)||(this.K.childPortSpot=t,this.invalidateLayout())}get alternateSorting(){return this.U.sorting}set alternateSorting(t){this.U.sorting!==t&&(Util.tt(t,TreeSorting,"TreeSorting"),this.U.sorting=t,this.invalidateLayout())}get alternateComparer(){return this.U.comparer}set alternateComparer(t){this.U.comparer!==t&&(Util.t(t,"function",TreeLayout,"alternateComparer"),this.U.comparer=t,this.invalidateLayout())}get alternateAngle(){return this.U.angle}set alternateAngle(t){this.U.angle!==t&&(Util.t(t,"number",TreeLayout,"alternateAngle"),(t===0||t===90||t===180||t===270)&&(this.U.angle=t,this.invalidateLayout()))}get alternateAlignment(){return this.U.alignment}set alternateAlignment(t){this.U.alignment!==t&&(Util.tt(t,TreeAlignment,"TreeAlignment"),this.U.alignment=t,this.invalidateLayout())}get alternateNodeIndent(){return this.U.nodeIndent}set alternateNodeIndent(t){this.U.nodeIndent!==t&&(Util.t(t,"number",TreeLayout,"alternateNodeIndent"),t>=0&&(this.U.nodeIndent=t,this.invalidateLayout()))}get alternateNodeIndentPastParent(){return this.U.nodeIndentPastParent}set alternateNodeIndentPastParent(t){this.U.nodeIndentPastParent!==t&&(Util.t(t,"number",TreeLayout,"alternateNodeIndentPastParent"),t>=0&&t<=1&&(this.U.nodeIndentPastParent=t,this.invalidateLayout()))}get alternateNodeSpacing(){return this.U.nodeSpacing}set alternateNodeSpacing(t){this.U.nodeSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateNodeSpacing"),this.U.nodeSpacing=t,this.invalidateLayout())}get alternateLayerSpacing(){return this.U.layerSpacing}set alternateLayerSpacing(t){this.U.layerSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateLayerSpacing"),this.U.layerSpacing=t,this.invalidateLayout())}get alternateLayerSpacingParentOverlap(){return this.U.layerSpacingParentOverlap}set alternateLayerSpacingParentOverlap(t){this.U.layerSpacingParentOverlap!==t&&(Util.t(t,"number",TreeLayout,"alternateLayerSpacingParentOverlap"),t>=0&&t<=1&&(this.U.layerSpacingParentOverlap=t,this.invalidateLayout()))}get alternateCompaction(){return this.U.compaction}set alternateCompaction(t){this.U.compaction!==t&&(Util.tt(t,TreeCompaction,"TreeCompaction"),(t===30||t===31)&&(this.U.compaction=t,this.invalidateLayout()))}get alternateBreadthLimit(){return this.U.breadthLimit}set alternateBreadthLimit(t){this.U.breadthLimit!==t&&(Util.t(t,"number",TreeLayout,"alternateBreadthLimit"),t>=0&&(this.U.breadthLimit=t,this.invalidateLayout()))}get alternateRowSpacing(){return this.U.rowSpacing}set alternateRowSpacing(t){this.U.rowSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateRowSpacing"),this.U.rowSpacing=t,this.invalidateLayout())}get alternateRowIndent(){return this.U.rowIndent}set alternateRowIndent(t){this.U.rowIndent!==t&&(Util.t(t,"number",TreeLayout,"alternateRowIndent"),t>=0&&(this.U.rowIndent=t,this.invalidateLayout()))}get alternateCommentSpacing(){return this.U.commentSpacing}set alternateCommentSpacing(t){this.U.commentSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateCommentSpacing"),this.U.commentSpacing=t,this.invalidateLayout())}get alternateCommentMargin(){return this.U.commentMargin}set alternateCommentMargin(t){this.U.commentMargin!==t&&(Util.t(t,"number",TreeLayout,"alternateCommentMargin"),this.U.commentMargin=t,this.invalidateLayout())}get alternateSetsPortSpot(){return this.U.setsPortSpot}set alternateSetsPortSpot(t){this.U.setsPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"alternateSetsPortSpot"),this.U.setsPortSpot=t,this.invalidateLayout())}get alternatePortSpot(){return this.U.portSpot}set alternatePortSpot(t){Util.s(t,Spot,TreeLayout,"alternatePortSpot"),this.U.portSpot.equals(t)||(this.U.portSpot=t,this.invalidateLayout())}get alternateSetsChildPortSpot(){return this.U.setsChildPortSpot}set alternateSetsChildPortSpot(t){this.U.setsChildPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"alternateSetsChildPortSpot"),this.U.setsChildPortSpot=t,this.invalidateLayout())}get alternateChildPortSpot(){return this.U.childPortSpot}set alternateChildPortSpot(t){Util.s(t,Spot,TreeLayout,"alternateChildPortSpot"),this.U.childPortSpot.equals(t)||(this.U.childPortSpot=t,this.invalidateLayout())}static PathDefault=0;static PathDestination=1;static PathSource=2;static SortingForwards=10;static SortingReverse=11;static SortingAscending=12;static SortingDescending=13;static AlignmentCenterSubtrees=20;static AlignmentCenterChildren=21;static AlignmentStart=22;static AlignmentEnd=23;static AlignmentBus=24;static AlignmentBusBranching=25;static AlignmentTopLeftBus=26;static AlignmentBottomRightBus=27;static CompactionNone=30;static CompactionBlock=31;static StyleLayered=40;static StyleLastParents=41;static StyleAlternating=42;static StyleRootOnly=43;static ArrangementVertical=50;static ArrangementHorizontal=51;static ArrangementFixedRoots=52;static LayerIndividual=60;static LayerSiblings=61;static LayerUniform=62}class TreeNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new TreeVertex(this)}createEdge(){return new TreeEdge(this)}}class TreeVertex extends LayoutVertex{X;kt;rt;Sk;Mk;Pk;Nk;Ck;Ak;Lk;Be;RD;ou;ru;Xg;Yg;ke;Se;jt;ai;ew;sw;nw;As;ow;rw;lw;hw;aw;fw;cw;uw;dw;gw;mw;constructor(t){super(t),this.Sk=!1,this.Mk=null,this.Pk=[],this.Nk=0,this.Ck=0,this.Ak=0,this.Lk=0,this.Be=null,this.X=new Point(0,0),this.kt=new Size(0,0),this.rt=new Point(0,0),this.RD=!1,this.ou=!1,this.ru=!1,this.Xg=null,this.Yg=null,this.ke=10,this.Se=LayoutVertex.standardComparer,this.jt=0,this.ai=21,this.ew=0,this.sw=0,this.nw=20,this.As=50,this.ow=0,this.rw=31,this.lw=0,this.hw=25,this.aw=10,this.fw=10,this.cw=20,this.uw=!0,this.dw=Spot.Default,this.gw=!0,this.mw=Spot.Default}copyInheritedPropertiesFrom(t){t!==null&&(this.ke=t.sorting,this.Se=t.comparer,this.jt=t.angle,this.ai=t.alignment,this.ew=t.nodeIndent,this.sw=t.nodeIndentPastParent,this.nw=t.nodeSpacing,this.As=t.layerSpacing,this.ow=t.layerSpacingParentOverlap,this.rw=t.compaction,this.lw=t.breadthLimit,this.hw=t.rowSpacing,this.aw=t.rowIndent,this.fw=t.commentSpacing,this.cw=t.commentMargin,this.uw=t.setsPortSpot,this.dw=t.portSpot,this.gw=t.setsChildPortSpot,this.mw=t.childPortSpot)}get initialized(){return this.Sk}set initialized(t){this.Sk!==t&&(Util.t(t,"boolean",TreeVertex,"initialized"),this.Sk=t)}get parent(){return this.Mk}set parent(t){this.Mk!==t&&(Debug&&t!==null&&Util.s(t,TreeVertex,TreeVertex,"parent"),this.Mk=t)}get children(){return this.Pk}set children(t){if(this.Pk!==t){if(t!==null&&!Array.isArray(t)&&Util.Vi(t,"Array",TreeVertex,"children:value"),t!==null){const i=t.length;for(let e=0;e4;)t.removePoint(2);u=t.getPoint(1),d=t.getPoint(2)}else{for(c=1;t.pointsCount>3;)t.removePoint(1);u=t.getPoint(0),d=t.getPoint(t.pointsCount-1)}const m=t.getPoint(t.pointsCount-1);let g=0;r===0?(e.alignment===23?(g=o.bottom+n.y,n.y===0&&u.y>m.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.xm.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.x{const i=t.matches?"dark":"light";i!==this.Kg&&(this.Kg=i,this.Fk==="system"&&this.pw())};constructor(t){t&&Object.assign(this,t),t?.themeMap||(this.hu.set("light",{colors:{...Themes.Light.colors},fonts:{...Themes.Light.fonts},numbers:{...Themes.Light.numbers},margins:{...Themes.Light.margins},arrowheads:{...Themes.Light.arrowheads}}),this.hu.set("dark",{colors:{...Themes.Dark.colors},fonts:{...Themes.Dark.fonts},numbers:{...Themes.Dark.numbers},margins:{...Themes.Dark.margins},arrowheads:{...Themes.Dark.arrowheads}})),root.matchMedia&&(this.Kg=root.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}get themeMap(){return this.hu}set themeMap(t){this.hu!==t&&(this.hu=t,this.pw())}get defaultTheme(){return this.Dk}set defaultTheme(t){this.Dk!==t&&(Util.t(t,"string",ThemeManager,"defaultTheme"),this.Dk=t,this.pw())}get currentTheme(){return this.Fk}set currentTheme(t){this.Fk!==t&&(Util.t(t,"string",ThemeManager,"currentTheme"),this.Fk=t,this.pw())}get changesDivBackground(){return this.Rk}set changesDivBackground(t){if(this.Rk!==t&&(this.Rk=t,t))for(const e of this.ls)e.setDivBackground(this.findValue("div","","fill")),e.V("ThemeChanged",this)}get preferredColorScheme(){return this.Kg}addDiagram(t){return this.ls.add(t),this.eC(t),this}removeDiagram(t){return this.ls.delete(t),this.eC(t),this}vF(){this.ls.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.addEventListener("change",this.ID)}JF(){this.ls.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.removeEventListener("change",this.ID)}set(t,i){t===""&&(t=this.Dk),t==="system"&&(t=this.Kg);let e=this.hu.get(t);return e?e=this.OD(e,i):e=i,this.hu.set(t,e),this.pw(),this}findValue(t,i,e){return this.getValue(this.findTheme(this.currentTheme),t,i,e)||this.getValue(this.findTheme(this.defaultTheme),t,i,e)}getValue(t,i,e,s){if(!t)return;e==null&&(e="");let n=t;const o=l=>{if(n===void 0||l==="")return;if(typeof l=="number"||!(Array.isArray(l)||l.includes(".")))return n[l];const h=Array.isArray(l)?l:l.split(".");for(let a=0;a{if(!(e!==""&&(n=o(e),n===void 0)))return Array.isArray(n)&&typeof i=="number"?n=n[i%n.length]:n=o(i),n};if(n=r(),n===void 0&&typeof s=="string"&&s.length>0){let l=t.targetPropertyMap?.get(s);if(l?n=t[l]:(l=ThemeManager._3.get(s),n=l?t[l]:t.colors),n=r(),n!==void 0)return n}return n}findTheme(t){return this.themeMap.get(t==="system"?this.Kg:t)}eC(t){const i=t.skipsUndoManager;t.skipsUndoManager=!0,t.updateAllThemeBindings(),this.Rk&&t.setDivBackground(this.findValue("div","","fill")),t.skipsUndoManager=i,t.V("ThemeChanged",this)}pw(){for(const t of this.ls)this.eC(t)}OD(t,i){for(const e in i)if(Util.yw(i,e))try{i[e].constructor===Object?t[e]=this.OD(t[e]??{},i[e]):t[e]=i[e]}catch{delete t[e]}return t}static _3=new Map([["background","colors"],["defaultColumnSeparatorStroke","colors"],["defaultRowSeparatorStroke","colors"],["shadowColor","colors"],["fill","colors"],["stroke","colors"],["font","fonts"],["angle","numbers"],["fromEndSegmentLength","numbers"],["fromShortLength","numbers"],["height","numbers"],["opacity","numbers"],["scale","numbers"],["toEndSegmentLength","numbers"],["toShortLength","numbers"],["width","numbers"],["defaultColumnSeparatorStrokeWidth","numbers"],["defaultRowSeparatorStrokeWidth","numbers"],["shadowBlur","numbers"],["corner","numbers"],["curviness","numbers"],["smoothness","numbers"],["parameter1","numbers"],["parameter2","numbers"],["strokeWidth","numbers"],["strokeDashOffset","numbers"],["maxLines","numbers"],["spacingAbove","numbers"],["spacingBelow","numbers"],["position","points"],["shadowOffset","points"],["desiredSize","sizes"],["maxSize","sizes"],["minSize","sizes"],["margin","margins"],["defaultSeparatorPadding","margins"],["padding","margins"],["alignment","spots"],["alignmentFocus","spots"],["fromSpot","spots"],["toSpot","spots"],["defaultAlignment","spots"],["spot1","spots"],["spot2","spots"],["verticalAlignment","spots"],["imageAlignment","spots"],["fromArrow","arrowheads"],["toArrow","arrowheads"]])}class Router{Tt;b;Xi;pl;constructor(){this.b=Diagram.Mm(),this.Tt="",this.Xi=!0,this.pl=!0}get name(){return this.Tt}set name(t){this.Tt=t}get isEnabled(){return this.Xi}set isEnabled(t){this.Xi=t}get isRealtime(){return this.pl}set isRealtime(t){this.pl=t}get diagram(){return this.b}set diagram(t){this.b!==t&&(this.b=t,t.Pl=!0,t.requestUpdate())}invalidateRouter(){this.b!==null&&(this.b.Pl=!0,this.b.requestUpdate())}canRoute(t){if(!this.isEnabled)return!1;const i=this.diagram;return!(i&&(!this.isRealtime&&i.Pu||i.animationManager.isTicking))}routeLinks(t,i){}toString(){return this.name!==""?this.name+" Router":Util.hn(this.constructor)}}class AvoidsNodesRouter extends Router{constructor(t){super(),this.name="AvoidsNodes",t&&Object.assign(this,t)}canRoute(t){return(t instanceof Diagram?t.$m:t.diagram.$m)?super.canRoute(t):!1}routeLinks(t,i){const e=i instanceof Diagram?null:i,s=t.iterator,n=this.diagram.getPositions(!0,e,null);for(;s.next();){const o=s.value;if(!o.isAvoiding||i&&o.containingGroup!==e||o.toNode===null||o.fromNode===null||o.pointsCount<4)continue;o.startRoute();const r=o.pointsCount,l=o.getPoint(1),h=o.getPoint(r-2),a=o.fromNode.actualBounds.copy();a.inflate(Link.za,Link.za),a.unionPoint(o.getPoint(0));const f=o.toNode.actualBounds.copy();f.inflate(Link.za,Link.za),f.unionPoint(o.getPoint(r-1)),this.tE(o,a,f,n)&&this.iE(o,l,o.cN,h,o.uN,a,f,n),o.commitRoute()}}tE(t,i,e,s){const n=t.diagram,o=t.pointsCount;if(n===null||t.fromNode===t.toNode||t.layer.isTemporary||i.containsPoint(t.getPoint(o-1))&&!t.toNode.isMemberOf(t.fromNode)||e.containsPoint(t.getPoint(0))&&!t.fromNode.isMemberOf(t.toNode)||!t.isOrthogonal)return!1;if(t.segmentIndex===17)return!0;const r=t.getPoint(1),l=t.getPoint(o-2),h=t.getPoint(2);if(!s.isUnoccupied(Math.min(r.x,h.x),Math.min(r.y,h.y),Math.abs(r.x-h.x),Math.abs(r.y-h.y)))return!0;for(let f=2;f=PositionArray.qd&&(l.vA(),d.inflate(l.cellWidth*l.KP,l.cellHeight*l.UP),l.mT(i,e,s,n,d,!1),m=l.wo(s.x,s.y)),!l.Cy&&mPositionArray.Ua&&i.wo(g,p)!==u-1&&(i.wo(d-f,m)===u-1?(n=180,g=d-f,p=m):i.wo(d+f,m)===u-1?(n=0,g=d+f,p=m):i.wo(d,m-c)===u-1?(n=270,g=d,p=m-c):i.wo(d,m+c)===u-1&&(n=90,g=d,p=m+c));u>PositionArray.Ua&&i.wo(g,p)===u-1;)d=g,m=p,n===0?g+=f:n===90?p+=c:n===180?g-=f:p-=c,u-=1;if(o?u>PositionArray.Ua&&(n===180||n===0?d=Math.floor(d/f)*f+f/2:(n===90||n===270)&&(m=Math.floor(m/c)*c+c/2)):(d=Math.floor(d/f)*f+f/2,m=Math.floor(m/c)*c+c/2),u>PositionArray.Ua){let y=n,x=d,k=m;if(n===0?(y=90,k+=c):n===90?(y=180,x-=f):n===180?(y=270,k-=c):n===270&&(y=0,x+=f),i.wo(x,k)===u-1)this.sC(t,i,x,k,y,!1);else{let S=d,M=m;n===0?(y=270,M-=c):n===90?(y=0,S+=f):n===180?(y=90,M+=c):n===270&&(y=180,S-=f),i.wo(S,M)===u-1&&this.sC(t,i,S,M,y,!1)}}t.insertPointAt(t.pointsCount-2,d,m)}}ToolManager.prototype.initializeStandardTools=function(){this.ti("Action",new ActionTool,this.mouseDownTools),this.ti("Relinking",new RelinkingTool,this.mouseDownTools),this.ti("LinkReshaping",new LinkReshapingTool,this.mouseDownTools),this.ti("Rotating",new RotatingTool,this.mouseDownTools),this.ti("Resizing",new ResizingTool,this.mouseDownTools),this.ti("Linking",new LinkingTool,this.mouseMoveTools),this.ti("Dragging",new DraggingTool,this.mouseMoveTools),this.ti("DragSelecting",new DragSelectingTool,this.mouseMoveTools),this.ti("Panning",new PanningTool,this.mouseMoveTools),this.ti("ContextMenu",new ContextMenuTool,this.mouseUpTools),this.ti("TextEditing",new TextEditingTool,this.mouseUpTools),this.ti("ClickCreating",new ClickCreatingTool,this.mouseUpTools),this.ti("ClickSelecting",new ClickSelectingTool,this.mouseUpTools)},Diagram.SP("GraphLinksModel",GraphLinksPartManager),Diagram.SP("TreeModel",TreePartManager);const oldGo=root.go,go={get version(){return Diagram.version},Group,List,Set:GSet,Map:GMap,Point,Size,Rect,Margin,Spot,Geometry,PathFigure,PathSegment,InputEvent,DiagramEvent,ChangedEvent,Model,GraphLinksModel,TreeModel,Binding,ThemeBinding,Transaction,UndoManager,CommandHandler,Tool,DraggingTool,DraggingInfo,DraggingOptions,LinkingBaseTool,LinkingTool,RelinkingTool,LinkReshapingTool,ResizingTool,RotatingTool,ClickSelectingTool,ActionTool,ClickCreatingTool,HTMLInfo,ContextMenuTool,DragSelectingTool,PanningTool,TextEditingTool,ToolManager,Animation,AnimationManager,AnimationTrigger,Layer,Diagram,Palette,Overview,Brush,GraphObject,Panel,RowColumnDefinition,Shape,TextBlock,Picture,Part,Adornment,Node,Link,Placeholder,Layout,LayoutNetwork,LayoutVertex,LayoutEdge,GridLayout,PanelLayout,CircularLayout,CircularNetwork,CircularVertex,CircularEdge,ForceDirectedLayout,ForceDirectedNetwork,ForceDirectedVertex,ForceDirectedEdge,LayeredDigraphLayout,LayeredDigraphNetwork,LayeredDigraphVertex,LayeredDigraphEdge,TreeLayout,TreeNetwork,TreeVertex,TreeEdge,Themes,ThemeManager,Router,AnimationStyle,AutoScale,CycleMode,Flip,TextFormat,ImageStretch,LayoutConditions,LinkAdjusting,Curve,Routing,Orientation,TextOverflow,PortSpreading,ScrollMode,CollapsePolicy,Sizing,TriggerStart,Stretch,ViewboxStretch,Wrap,BrushType,ColorSpace,GeometryStretch,GeometryType,SegmentType,BindingMode,ChangeType,CircularArrangement,CircularDirection,CircularNodeDiameterFormula,CircularSorting,GridAlignment,GridArrangement,GridSorting,LayeredDigraphAggressive,LayeredDigraphAlign,LayeredDigraphCycleRemove,LayeredDigraphInit,LayeredDigraphLayering,LayeredDigraphPack,TreeAlignment,TreeArrangement,TreeCompaction,TreeLayerStyle,TreePath,TreeSorting,TreeStyle,GestureMode,LinkingDirection,ReshapingBehavior,TextEditingAccept,TextEditingStarting,TextEditingState,WheelMode};typeof oldGo=="object"&&oldGo.version&&Util.at("WARNING: a `go` object on the root object is already defined. "+("Debug"in oldGo?"debug ":"")+"version: "+oldGo.version+", replaced with version: "+go.version),Diagram.prototype.go=go,root.go=go,go.Debug=Debug,Debug.attachReadonlyWarnings(go); + "removedLinkKeys": `;jT(t){const i=new GSet;for(let e=0;e{if(c.model===s){if(c.modelChange==="linkDataArray")c.change===3?n.add(c.newValue):c.change===4&&r.add(c.oldValue);else if(s.containsLinkData(c.object))o.add(c.object);else if(c.object!==null)if(c.object!==null&&l&&l.has(c.object))l.get(c.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(c.object instanceof Model||s.containsNodeData(c.object))return;s.jT(c.object).each(d=>o.add(d))}}});const h=this.ug;h.clear(),n.each(c=>{h.add(s.getKeyForLinkData(c)),i||o.add(c)});const a=this.cg;a.clear(),r.each(c=>{a.add(s.getKeyForLinkData(c)),i&&o.add(c)});let f=e;return h.count>0&&(f+=(i?this.vT:this.WT)+this.Dh(h.toArray(),!0)),o.count>0&&(f+=this.zO+this.Dh(o.toArray(),!0)),a.count>0&&(f+=(i?this.WT:this.vT)+this.Dh(a.toArray(),!0)),a.clear(),h.clear(),f}By(t){(t.linkCategoryProperty!==void 0&&t.linkCategoryProperty!==this.linkCategoryProperty||t.linkKeyProperty!==void 0&&t.linkKeyProperty!==this.linkKeyProperty||t.linkFromKeyProperty!==void 0&&t.linkFromKeyProperty!==this.linkFromKeyProperty||t.linkToKeyProperty!==void 0&&t.linkToKeyProperty!==this.linkToKeyProperty||t.linkFromPortIdProperty!==void 0&&t.linkFromPortIdProperty!==this.linkFromPortIdProperty||t.linkToPortIdProperty!==void 0&&t.linkToPortIdProperty!==this.linkToPortIdProperty||t.linkLabelKeysProperty!==void 0&&t.linkLabelKeysProperty!==this.linkLabelKeysProperty||t.nodeIsGroupProperty!==void 0&&t.nodeIsGroupProperty!==this.nodeIsGroupProperty||t.nodeGroupKeyProperty!==void 0&&t.nodeGroupKeyProperty!==this.nodeGroupKeyProperty)&&Util.n("applyIncrementalJson cannot change Model properties"),super.By(t);const i=t.insertedLinkKeys;if(Array.isArray(i)){const n=i.length;for(let o=0;o=0&&s.splice(e,1)):s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue));return}}else if(t.change===4){let e=t.oldParam;if(t.modelChange==="linkDataArray"){const s=t.oldValue;if(Util.Mt(s)&&typeof e=="number"){const n=this.getKeyForLinkData(s);i?(this.hr.add(s),this.is[e]!==s&&this.is.splice(e,0,s),n!==void 0&&this.mi.set(n,s)):(this.hr.delete(s),this.is[e]===s&&this.is.splice(e,1),n!==void 0&&this.mi.delete(n))}return}else if(t.modelChange==="linkLabelKeys"){const s=this.getLabelKeysForLinkData(t.object);Array.isArray(s)&&typeof e=="number"&&(i?s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue):(e=s.indexOf(t.newValue),e>=0&&s.splice(e,1)));return}}super.changeState(t,i)}}get archetypeNodeData(){return this.Fl}set archetypeNodeData(t){const i=this.Fl;i!==t&&(t!==null&&Util.t(t,"object",GraphLinksModel,"archetypeNodeData"),this.Fl=t,this.i("archetypeNodeData",i,t))}IN(t){if(t===void 0)return;const i=this.Fl;if(i!==null){let e=this.findNodeDataForKey(t);e===null&&(e=this.copyNodeData(i),Model.ct(e,this.nodeKeyProperty,t),this.addNodeData(e))}return t}get linkFromKeyProperty(){return this.Po}set linkFromKeyProperty(t){const i=this.Po;i!==t&&(this.In(t,GraphLinksModel,"linkFromKeyProperty"),this.Po=t,this.i("linkFromKeyProperty",i,t))}getFromKeyForLinkData(t){return this.Ee(t,!0)}setFromKeyForLinkData(t,i){this.ng(t,i,!0)}get linkToKeyProperty(){return this.No}set linkToKeyProperty(t){const i=this.No;i!==t&&(this.In(t,GraphLinksModel,"linkToKeyProperty"),this.No=t,this.i("linkToKeyProperty",i,t))}getToKeyForLinkData(t){return this.Ee(t,!1)}setToKeyForLinkData(t,i){this.ng(t,i,!1)}Ee(t,i){if(t===null)return;const e=i?this.Po:this.No;if(e==="")return;const s=Model.Xt(t,e);if(s!==void 0){if(this.isKeyType(s))return s;Util.n((i?"FromKey":"ToKey")+" value for link data "+t+" is not a number or a string: "+s)}}ng(t,i,e){if(i===null&&(i=void 0),i!==void 0&&!this.isKeyType(i)&&Util.Bi(i,"number or string",GraphLinksModel,e?"setFromKeyForLinkData:key":"setToKeyForLinkData:key"),t===null)return;const s=e?this.Po:this.No;if(s==="")return;if(i=this.IN(i),!this.containsLinkData(t)){Model.ct(t,s,i);return}const n=Model.Xt(t,s);n!==i&&(this.tn(n,t),Model.ct(t,s,i),this.findNodeDataForKey(i)===null&&this.en(i,t),this.Kt(e?"linkFromKey":"linkToKey",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkFromPortIdProperty(){return this.Ja}set linkFromPortIdProperty(t){const i=this.Ja;i!==t&&(this.In(t,GraphLinksModel,"linkFromPortIdProperty"),Debug&&(t===this.linkFromKeyProperty||t===this.linkToKeyProperty)&&Util.n("linkFromPortIdProperty name must not be the same as the GraphLinksModel.linkFromKeyProperty or linkToKeyProperty: "+t),this.Ja=t,this.i("linkFromPortIdProperty",i,t))}getFromPortIdForLinkData(t){return this.Eb(t,!0)}setFromPortIdForLinkData(t,i){this.og(t,i,!0)}get linkToPortIdProperty(){return this.Za}set linkToPortIdProperty(t){const i=this.Za;i!==t&&(this.In(t,GraphLinksModel,"linkToPortIdProperty"),Debug&&(t===this.linkFromKeyProperty||t===this.linkToKeyProperty)&&Util.n("linkFromPortIdProperty name must not be the same as the GraphLinksModel.linkFromKeyProperty or linkToKeyProperty: "+t),this.Za=t,this.i("linkToPortIdProperty",i,t))}getToPortIdForLinkData(t){return this.Eb(t,!1)}setToPortIdForLinkData(t,i){this.og(t,i,!1)}Eb(t,i){if(t===null)return"";const e=i?this.Ja:this.Za;if(e==="")return"";const s=Model.Xt(t,e);return s===void 0?"":s}og(t,i,e){if(Util.t(i,"string",GraphLinksModel,e?"setFromPortIdForLinkData:portname":"setToPortIdForLinkData:portname"),t===null)return;const s=e?this.Ja:this.Za;if(s==="")return;if(!this.containsLinkData(t)){Model.ct(t,s,i);return}let n=Model.Xt(t,s);n===void 0&&(n=""),n!==i&&(Model.ct(t,s,i),this.Kt(e?"linkFromPortId":"linkToPortId",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkLabelKeysProperty(){return this.sn}set linkLabelKeysProperty(t){const i=this.sn;i!==t&&(this.In(t,GraphLinksModel,"linkLabelKeysProperty"),this.sn=t,this.i("linkLabelKeysProperty",i,t))}getLabelKeysForLinkData(t){if(t===null)return GraphLinksModel.EmptyArray;const i=this.sn;if(i==="")return GraphLinksModel.EmptyArray;const e=Model.Xt(t,i);return e===void 0?GraphLinksModel.EmptyArray:e}setLabelKeysForLinkData(t,i){if(Util.Ug(i,GraphLinksModel,"setLabelKeysForLinkData:arr"),t===null)return;const e=this.sn;if(e==="")return;if(!this.containsLinkData(t)){Model.ct(t,e,i);return}let s=Model.Xt(t,e);if(s===void 0&&(s=GraphLinksModel.EmptyArray),s!==i){if(Array.isArray(s)){const o=s.length;for(let r=0;r=0)return;n=s.length,s.push(i),this.containsLinkData(t)&&(this.findNodeDataForKey(i)===null&&this.en(i,t),this.Kt("linkLabelKeys",3,e,t,null,i,null,n))}else Util.n(e+" property is not an Array; cannot addLabelKeyForLinkData: "+t)}removeLabelKeyForLinkData(t,i){if(i==null||(this.isKeyType(i)||Util.Bi(i,"number or string",GraphLinksModel,"removeLabelKeyForLinkData:key"),t===null))return;const e=this.sn;if(e==="")return;const s=Model.Xt(t,e);if(Array.isArray(s)){const n=s.indexOf(i);if(n<0)return;s.splice(n,1),this.containsLinkData(t)&&(this.tn(i,t),this.Kt("linkLabelKeys",4,e,t,i,null,n,null))}else s!==void 0&&Util.n(e+" property is not an Array; cannot removeLabelKeyforLinkData: "+t)}get linkDataArray(){return this.is}set linkDataArray(t){const i=this.is;if(i!==t){Util.Ug(t,GraphLinksModel,"linkDataArray"),this.mi.clear();const e=t.length;for(let n=0;nnew GraphLinksModel,Model.initDiagramModel=Model.initDiagramModel=()=>new GraphLinksModel;class TreeModel extends Model{En;xg;Qa;constructor(t,i){if(super(),this.En="parent",this.xg=!1,this.Qa="parentLinkCategory",t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){super.cloneProtected(t),t.En=this.En,t.xg=this.xg,t.Qa=this.Qa}toString(t){if(t===void 0&&(t=0),t>=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" TreeModel";if(t>0){i+=` + node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n(w[w.ConstantSpacing=0]="ConstantSpacing",w[w.ConstantDistance=1]="ConstantDistance",w[w.ConstantAngle=2]="ConstantAngle",w[w.Packed=3]="Packed",w))(CircularArrangement||{}),CircularDirection=(w=>(w[w.Clockwise=10]="Clockwise",w[w.Counterclockwise=11]="Counterclockwise",w[w.BidirectionalLeft=12]="BidirectionalLeft",w[w.BidirectionalRight=13]="BidirectionalRight",w))(CircularDirection||{}),CircularSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w[w.Optimized=24]="Optimized",w))(CircularSorting||{}),CircularNodeDiameterFormula=(w=>(w[w.Pythagorean=30]="Pythagorean",w[w.Circular=31]="Circular",w))(CircularNodeDiameterFormula||{});class CircularLayout extends Layout{ue;Kc;qb;bg;jb;Rh;BN;VN;zN;Ns;Xy;Yy;_a;Ky;ZT;kg;Sg;Mg;Uc;qi;C;ke;Se;Rn;Pg;constructor(t){super(),this.ue=0,this.Kc=0,this.qb=0,this.bg=360,this.jb=0,this.Rh=0,this.BN=new Point,this.VN=30,this.zN=0,this.Ns=0,this.Xy=0,this.Yy=new VertexArrangement,this._a=0,this.Ky=0,this.ZT=600,this.kg=NaN,this.Sg=1,this.Mg=0,this.Uc=360,this.qi=0,this.C=10,this.ke=24,this.Se=LayoutVertex.standardComparer,this.Rn=6,this.Pg=30,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.kg=this.kg,t.Sg=this.Sg,t.Mg=this.Mg,t.Uc=this.Uc,t.qi=this.qi,t.C=this.C,t.ke=this.ke,t.Se=this.Se,t.Rn=this.Rn,t.Pg=this.Pg}fi(t){t in CircularSorting?this.sorting=t:t in CircularDirection?this.direction=t:t in CircularArrangement?this.arrangement=t:t in CircularNodeDiameterFormula?this.nodeDiameterFormula=t:super.fi(t)}createNetwork(){return new CircularNetwork(this)}KO(t,i,e){t=this.UO(t);let s=this.jb,n=this.VN,o=this.ue,r=this.Kc,l=this.qb,h=this.bg,a=this.Rh,f=this.zN,c=this.Ns,u=this.Xy;if(s=this.arrangement,n=this.nodeDiameterFormula,o=this.radius,(!isFinite(o)||o<=0)&&(o=NaN),r=this.aspectRatio,(!isFinite(r)||r<=0)&&(r=1),l=this.startAngle,isFinite(l)||(l=0),h=this.sweepAngle,(!isFinite(h)||h>360||h<1)&&(h=360),a=this.spacing,isFinite(a)||(a=NaN),s===3&&n===31?s=0:s===3&&n!==31&&(n=31,s=this.arrangement),(this.direction===12||this.direction===13)&&this.sorting!==24){for(let g=0;!(g>=t.length||(i.add(t.elt(g)),g+1>=t.length));g+=2)e.add(t.elt(g+1));this.direction===12?(this.arrangement===3&&i.reverse(),t=new List,t.addAll(i),t.addAll(e)):(this.arrangement===3&&e.reverse(),t=new List,t.addAll(e),t.addAll(i))}const d=t.length;f=0;let m=0;for(let g=0;g1?(o=y,c=o*r):(c=y,o=c)}else o=this.Wb(u*(h>=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180)}else o=this.Wb(f+(h>=360?d:d-1)*(s!==3?a:a*1.6),r,l*Math.PI/180,h*Math.PI/180);c=o*r}else{c=o*r;const g=this.XN(o,c,l*Math.PI/180,h*Math.PI/180);if(isNaN(a))s===0&&(a=(g-f)/(h>=360?d:d-1));else if(s===0){const p=(g-f)/(h>=360?d:d-1);p=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180),c=o*r):a=p}else{let p=-1/0;for(let k=0;k=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180);x>o?(o=x,c=o*r,u=y):u=g/(h>=360?d:d-1)}}return this.jb=s,this.VN=n,this.ue=o,this.Kc=r,this.qb=l,this.bg=h,this.Rh=a,this.zN=f,this.Ns=c,this.Xy=u,t}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.network.vertexes;if(i.count<=1){if(i.count===1){const u=i.first();u.centerX=0,u.centerY=0}this.updateParts(),this.network=null,this.isValidLayout=!0;return}let e=new List;e.addAll(i.iterator);const s=new List,n=new List;e=this.KO(e,s,n);const o=this.jb,r=this.ue,l=this.qb,h=this.bg,a=this.Rh,f=this.Ns,c=this.Xy;if((this.direction===12||this.direction===13)&&o===3)this.$T(e,h,l-h/2,10);else if(this.direction===12||this.direction===13){let u=0;switch(o){case 1:u=this.vb(r,f,l,c)*180/Math.PI;break;case 0:{let d=0,m=0;const g=s.first();g!==null&&(d=g.Ih(Math.PI/2));const p=n.first();p!==null&&(m=p.Ih(Math.PI/2)),u=this.vb(r,f,l,a+(d+m)/2)*180/Math.PI;break}case 2:u=h/e.length;break}if(this.direction===12){switch(o){case 1:this.Uy(s,h/2,l,11);break;case 0:this.Gy(s,h/2,l,11);break;case 2:this.Hy(s,h/2,l,11);break}switch(o){case 1:this.Uy(n,h/2,l+u,10);break;case 0:this.Gy(n,h/2,l+u,10);break;case 2:this.Hy(n,h/2,l+u,10);break}}else{switch(o){case 1:this.Uy(n,h/2,l,11);break;case 0:this.Gy(n,h/2,l,11);break;case 2:this.Hy(n,h/2,l,11);break}switch(o){case 1:this.Uy(s,h/2,l+u,10);break;case 0:this.Gy(s,h/2,l+u,10);break;case 2:this.Hy(s,h/2,l+u,10);break}}}else switch(o){case 1:this.Uy(e,h,l,this.direction);break;case 0:this.Gy(e,h,l,this.direction);break;case 2:this.Hy(e,h,l,this.direction);break;case 3:this.$T(e,h,l,this.direction);break}this.updateParts(),this.network=null,this.isValidLayout=!0}Hy(t,i,e,s){const n=this.bg,o=this.ue,r=this.Ns,l=e*Math.PI/180,h=i*Math.PI/180,a=t.length;for(let f=0;f=360?a:a-1):-(f*h)/a),u=t.elt(f),d=o*Math.tan(c)/r,m=Math.sqrt((o*o+r*r*d*d)/(1+d*d));u.centerX=m*Math.cos(c),u.centerY=m*Math.sin(c),u.actualAngle=c*180/Math.PI}}Gy(t,i,e,s){const n=this.ue,o=this.Ns,r=this.Rh;let l=e*Math.PI/180;const h=t.length;for(let a=0;a180&&(n-=360),n*=Math.PI/180,this.Ky=n,this.QT(t,i,e,s)}else this._T(t,i,e,s);this.Yy.commit(t)}_T(t,i,e,s){const n=this.ue,o=this.Ns,r=this.Rh,l=this.Kc;let h=n*Math.cos(e*Math.PI/180),a=o*Math.sin(e*Math.PI/180);const f=t.toArray();if(f.length===3){f[0].centerX=n,f[0].centerY=0,f[1].centerX=f[0].centerX-f[0].width/2-f[1].width/2-r,f[1].y=f[0].y,f[2].centerX=(f[0].centerX+f[1].centerX)/2,f[2].y=f[0].y-f[2].height-r;return}else if(f.length===4){f[0].centerX=n,f[0].centerY=0,f[2].centerX=-f[0].centerX,f[2].centerY=f[0].centerY,f[1].centerX=0,f[1].y=Math.min(f[0].y,f[2].y)-f[1].height-r,f[3].centerX=0,f[3].y=Math.max(f[0].y+f[0].height+r,f[2].y+f[2].height+r);return}const c=Point.a();for(let b=0;b=f.length-1));b++)this.tD(h,a,f,b,s,c)||this.iD(h,a,f,b,s,c),h=c.x,a=c.y;if(Point.o(c),this._a++,this._a>23)return;const u=f[0].centerX,d=f[0].centerY,m=f[f.length-1].centerX,g=f[f.length-1].centerY;let p=Math.abs(u-m)-((f[0].width+f[f.length-1].width)/2+r);const y=Math.abs(d-g)-((f[0].height+f[f.length-1].height)/2+r);let x=0;if(Math.abs(y)<1){const b=Math.abs(u-m),S=(f[0].width+f[f.length-1].width)/2;b0?x=y:Math.abs(p)<1?x=0:x=p;let k=!1;Math.abs(m)>Math.abs(g)?k=m>0!=d>g:k=g>0!=u1&&(this._a<8?this.ue-=x/(2*Math.PI):f.length<5&&x>10?this.ue/=2:this.ue-=x>0?1.7:-2.3,this.Ns=this.ue*l,this._T(t,i,e,s))}QT(t,i,e,s){const n=this.ue,o=this.Ns,r=this.Kc;let l=n*Math.cos(e*Math.PI/180),h=o*Math.sin(e*Math.PI/180);const a=Point.a(),f=t.toArray();for(let m=0;m=f.length-1));m++)this.tD(l,h,f,m,s,a)||this.iD(l,h,f,m,s,a),l=a.x,h=a.y;if(Point.o(a),this._a++,this._a>23)return;const c=Math.atan2(h,l);let u=s===10?this.Ky-c:c-this.Ky;u=Math.abs(u)1&&(this._a<8?this.ue-=d/(2*Math.PI):this.ue-=d>0?1.7:-2.3,this.Ns=this.ue*r,this.QT(t,i,e,s))}tD(t,i,e,s,n,o){const r=this.Rh,l=this.ue,h=this.Ns;let a=0,f=0;const c=(e[s].width+e[s+1].width)/2+r;let u=!1;if(i>=0!=(n===10)){if(a=t+c,a>l){if(a=t-c,a<-l)return o.x=a,o.y=f,!1;u=!0}}else if(a=t-c,a<-l){if(a=t+c,a>l)return o.x=a,o.y=f,!1;u=!0}return f=Math.sqrt(1-Math.min(1,a*a/(l*l)))*h,i<0!==u&&(f=-f),Math.abs(i-f)>(e[s].height+e[s+1].height)/2?(o.x=a,o.y=f,!1):(o.x=a,o.y=f,!0)}iD(t,i,e,s,n,o){const r=this.Rh,l=this.ue,h=this.Ns;let a=0,f=0;const c=(e[s].height+e[s+1].height)/2+r;let u=!1;if(t>=0!=(n===10)){if(f=i-c,f<-h){if(f=i+c,f>h)return o.x=a,o.y=f,!1;u=!0}}else if(f=i+c,f>h){if(f=i-c,f<-h)return o.x=a,o.y=f,!1;u=!0}return a=Math.sqrt(1-Math.min(1,f*f/(h*h)))*l,t<0!==u&&(a=-a),Math.abs(t-a)>(e[s].width+e[s+1].width)/2?(o.x=a,o.y=f,!1):(o.x=a,o.y=f,!0)}commitLayout(){this.commitNodes(),this.isRouting&&this.commitLinks()}commitNodes(){const t=this.group!==null&&this.group.hasPlaceholder(),i=t?this.group.location.copy():null;let e=this.actualCenter;t?e=new Point(0,0):(e.x=this.arrangementOrigin.x+this.ue,e.y=this.arrangementOrigin.y+this.Ns);const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;n.x+=e.x,n.y+=e.y,n.commit()}if(t){this.group.ensureBounds();const n=this.group.position.copy(),o=this.group.location.copy(),r=i.subtract(o.subtract(n));this.group.move(r),this.BN=r.subtract(n)}}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}XN(t,i,e,s){const n=this.ZT;if(Math.abs(this.Kc-1)<.001)return e!==void 0&&s!==void 0?s*t:2*Math.PI*t;const o=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let r=0,l=0;e!==void 0&&s!==void 0?l=s/(n+1):l=Math.PI/(2*(n+1));let h=0;for(let a=0;a<=n;a++){e!==void 0&&s!==void 0?h=e+a*s/n:h=a*Math.PI/(2*n);const f=Math.sin(h);r+=Math.sqrt(1-o*o*f*f)*l}return e!==void 0&&s!==void 0?(t>i?t:i)*r:4*(t>i?t:i)*r}Wb(t,i,e,s){let n=0;return e!==void 0&&s!==void 0?n=this.XN(1,i,e,s):n=this.XN(1,i),t/n}vb(t,i,e,s){if(Math.abs(this.Kc-1)<.001)return s/t;const n=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let o=0;const r=2*Math.PI/(this.network.vertexes.count*700);t>i&&(e+=Math.PI/2);for(let l=0;;l++){const h=e+l*r,a=Math.sin(h);if(o+=(t>i?t:i)*Math.sqrt(1-n*n*a*a)*r,o>=s)return l*r}}UO(t){switch(this.sorting){case 20:break;case 21:t.reverse();break;case 22:t.sort(this.comparer);break;case 23:t.sort(this.comparer),t.reverse();break;case 24:return this.qO(this.jO(t));default:Util.n("Invalid sorting type.")}return t}jO(t){const i=[];for(let s=0;sn&&(n=u,o=f)}else for(let f=0;fn&&(n=c,o=f)}e.add(t.elt(o)),i[o]=-1;const r=t.elt(o);let l=0;const h=r.sourceEdges;for(;h.next();){const c=h.value.fromVertex;l=t.indexOf(c),!(l<0)&&i[l]>=0&&i[l]++}const a=r.destinationEdges;for(;a.next();){const c=a.value.toVertex;l=t.indexOf(c),!(l<0)&&i[l]>=0&&i[l]++}}return e}qO(t){const i=[];for(let c=0;c=0){const C=Math.abs(x-(A>=x?A+1:A));b+=C=x&&M++,A>=x&&A++,M>A){const C=A;A=M,M=C}A-M<(s.length+2)/2==(M=0&&(n.push(c),o.push(x))}h++}let a=!1;const f=s.length;for(;;){a=!0;for(let c=0;c=0){let g=0;for(let p=0;pm?x-m:m-x,b=f-k;g+=xb?1:-1}s.splice(g<0?m:m+1,0,u),r.splice(c,1),c--}else a=!1}if(a)break;s.push(r[0]),r.splice(0,1)}for(let c=0;c0||isNaN(t))&&(this.kg=t,this.invalidateLayout()))}get aspectRatio(){return this.Sg}set aspectRatio(t){this.Sg!==t&&(Util.t(t,"number",CircularLayout,"aspectRatio"),t>0&&(this.Sg=t,this.invalidateLayout()))}get startAngle(){return this.Mg}set startAngle(t){this.Mg!==t&&(Util.t(t,"number",CircularLayout,"startAngle"),this.Mg=t,this.invalidateLayout())}get sweepAngle(){return this.Uc}set sweepAngle(t){this.Uc!==t&&(Util.t(t,"number",CircularLayout,"sweepAngle"),t>0&&t<=360?this.Uc=t:this.Uc=360,this.invalidateLayout())}get arrangement(){return this.qi}set arrangement(t){this.qi!==t&&(Util.tt(t,CircularArrangement,"CircularArrangement"),(t===3||t===0||t===1||t===2)&&(this.qi=t,this.invalidateLayout()))}get direction(){return this.C}set direction(t){this.C!==t&&(Util.tt(t,CircularDirection,"CircularDirection"),(t===10||t===11||t===12||t===13)&&(this.C=t,this.invalidateLayout()))}get sorting(){return this.ke}set sorting(t){this.ke!==t&&(Util.tt(t,CircularSorting,"CircularSorting"),this.ke=t,this.invalidateLayout())}get comparer(){return this.Se}set comparer(t){this.Se!==t&&(Util.t(t,"function",CircularLayout,"comparer"),this.Se=t,this.invalidateLayout())}get spacing(){return this.Rn}set spacing(t){this.Rn!==t&&(Util.t(t,"number",CircularLayout,"spacing"),this.Rn=t,this.invalidateLayout())}get nodeDiameterFormula(){return this.Pg}set nodeDiameterFormula(t){this.Pg!==t&&(Util.tt(t,CircularNodeDiameterFormula,"CircularNodeDiameterFormula"),(t===30||t===31)&&(this.Pg=t,this.invalidateLayout()))}get actualXRadius(){return this.ue}get actualYRadius(){return this.Ns}get actualSpacing(){return this.Rh}get actualCenter(){return this.BN}static ConstantSpacing=0;static ConstantDistance=1;static ConstantAngle=2;static Packed=3;static Clockwise=10;static Counterclockwise=11;static BidirectionalLeft=12;static BidirectionalRight=13;static Forwards=20;static Reverse=21;static Ascending=22;static Descending=23;static Optimized=24;static Pythagorean=30;static Circular=31}class VertexArrangement{Gc;tf;Hc;constructor(){this.Gc=-1/0,this.tf=null,this.Hc=null}GO(t,i){if(t>0&&this.Gc<0||Math.abs(t)0)){this.Gc=t,this.tf=[],this.Hc=[];for(let e=0;e0){for(this.network.deleteSelfEdges(),i=this.network.vertexes.iterator;i.next();){const o=i.value;o.charge=this.electricalCharge(o),o.mass=this.gravitationalMass(o)}const s=this.network.edges.iterator;for(;s.next();){const o=s.value;o.stiffness=this.springStiffness(o),o.length=this.springLength(o)}if(this.YN(),this.Oh=0,this.needsPrelayout()){const o=this.network,r=o.splitIntoSubNetworks(!1);let l=r.iterator;for(;l.next();){const h=l.value;this.doConnectedSubnetLayout(h)}for(l=r.iterator,this.vO(l,o),l=r.iterator;l.next();){const h=l.value,a=h.vertexes.iterator;for(;a.next();){const c=a.value;o.addVertex(c)}const f=h.edges.iterator;for(;f.next();){const c=f.value;o.addEdge(c)}}}else this.eD(this.network,this.maxIterations);this.updateParts()}this.maxIterations=e,this.isValidLayout=!0}needsPrelayout(){if(this.network.vertexes.count<3)return!1;let t=0,i=0;const e=this.network.vertexes.first().bounds,s=this.network.vertexes.iterator;for(;s.next();){const n=s.value,o=n.bounds;if(isNaN(n.x)||isNaN(n.y)||o.intersectsRect(e)&&(t++,t>2))return!0;if(i>10)return!1;i++}return!1}doConnectedSubnetLayout(t){let i=t.vertexes.iterator;for(;i.next();){const l=i.value;l.hierarchicalVertexes.add(l)}let e=t,s=this.Zc;if(isNaN(s)&&(s=t.edges.count/t.vertexes.count),sMath.max(100,Math.sqrt(s*t.vertexes.count));)e=this.coarsenNetwork(e);let n=0;i=e.vertexes.iterator;let o=this.randomNumberGenerator;for(o===null&&(this.randomNumberGenerator=o=new RandomNumberGenerator(0));i.next();){i.value.idInCluster=n++;const l=10*(o.random()-.5),h=10*(o.random()-.5);this.isFixed(i.value)||(i.value.x=l,i.value.y=h);const a=i.value.hierarchicalVertexes.iterator;for(;a.next();)this.isFixed(a.value)||(a.value.x=l,a.value.y=h)}const r=this.computePairwiseDistances(e);this.JO(e,r,this.maxPrelayoutIterations,t.vertexes.count),this.eD(t,this.maxIterations)}computePairwiseDistances(t){const i=t.vertexes.count,e=new Array(i);for(let r=0;r0;){const l=o.shift(),h=l.vertexes.iterator;for(;h.next();){const a=h.value;n.has(a.idInCluster)||(n.set(a.idInCluster,n.get(l.idInCluster)+1),o.push(a))}}for(let l=0;l=0;m--)if(t[m].y>f.y&&t[m].x-f.xf.x&&t[m].y-f.ya+c){const u=s+o-h,d=n-a-c;return Geo.Aw(u*u+d*d)}else if(n+rh+f)if(n>a+c){const u=s-h-f,d=n-a-c;return Geo.Aw(u*u+d*d)}else if(n+ra+c?n-(a+c):n+rr-o;l?i.sort((m,g)=>m===null||g===null||m===g?0:m.centerX-g.centerX):i.sort((m,g)=>m===null||g===null||m===g?0:m.centerY-g.centerY);const h=this.qc;let a=0,f=0,c=0;for(let m=0;mh||C-x>h){if(l)break;continue}if(k-P>h||P-k>h){if(!l)break;continue}const N=this.KN(g,S),T=2*g.charge,L=2*S.charge;if(N>1)a=T*L/(N*N),f=a*(x-C)/N,c=a*(k-P)/N;else{let D=this.randomNumberGenerator;D===null&&(this.randomNumberGenerator=D=new RandomNumberGenerator(0));const F=D.random(),R=D.random();if(x>C)f=Math.abs(S.bounds.right-g.bounds.x),f=T*L*(1+f)*F;else if(xP)c=Math.abs(S.bounds.bottom-g.bounds.y),c=T*L*(1+c)*R;else if(x1&&(a=.1*m.stiffness*(P-m.length),f=a*.5*(g.width+p.height)*(k-A)/P,c=a*.5*(g.width+p.height)*(b-C)/P),g.forceX-=f,g.forceY-=c,p.forceX+=f,p.forceY+=c}let d=0;for(let m=0;mthis.epsilonDistance*this.epsilonDistance}JO(t,i,e,s){Debug&&Util.r(e,ForceDirectedLayout,"performIterations:num");const n=this.Oh+e,o=Math.sqrt(s);this.qy=this.ef*t.vertexes.count;const r=t.vertexes.toArray();let l=0,h=0,a=0;for(;this.Oh0){r[f].forceX=this.qy*r[f].forceX/c,r[f].forceY=this.qy*r[f].forceY/c,this.isFixed(r[f])||(r[f].x+=r[f].forceX,r[f].y+=r[f].forceY);const u=r[f].hierarchicalVertexes.iterator;for(;u.next();){const d=u.value;this.isFixed(d)||(d.centerX+=r[f].forceX,d.centerY+=r[f].forceY)}}l+=c*c}if(l>=h){if(a++,a>=5)break}else a=0;this.qy*=.95}}moveVertex(t){let i=t.forceX,e=t.forceY;const s=this.moveLimit;return i<-s?i=-s:i>s&&(i=s),e<-s?e=-s:e>s&&(e=s),t.centerX+=i,t.centerY+=e,i*i+e*e}shouldInteract(t,i){return!0}moveFixedVertex(t){}commitLayout(){this.jy(),this.commitNodes(),this.isRouting&&this.commitLinks()}jy(){if(!this.setsPortSpots)return;const t=this.network.edges.iterator;for(;t.next();){const e=t.value.link;e!==null&&(e.fromSpot=Spot.Default,e.toSpot=Spot.Default)}}commitNodes(){let t=0,i=0;if(this.arrangesToOrigin){const n=Rect.a();this.Rw(this.network,n);const o=this.arrangementOrigin;t=o.x-n.x,i=o.y-n.y,Rect.o(n)}const e=Rect.a(),s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;(t!==0||i!==0)&&(e.c(n.bounds),e.x+=t,e.y+=i,n.bounds=e),n.commit()}Rect.o(e)}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}springStiffness(t){const i=t.stiffness;return isNaN(i)?this.jc:i}springLength(t){const i=t.length;return isNaN(i)?this.Wc:i}electricalCharge(t){const i=t.charge;return isNaN(i)?this.vc:i}electricalFieldX(t,i){return 0}electricalFieldY(t,i){return 0}gravitationalMass(t){const i=t.mass;return isNaN(i)?this.Jc:i}gravitationalFieldX(t,i){return 0}gravitationalFieldY(t,i){return 0}isFixed(t){return t.isFixed}get currentIteration(){return this.Oh}get arrangementSpacing(){return this.Cs}set arrangementSpacing(t){Util.s(t,Size,ForceDirectedLayout,"arrangementSpacing"),this.Cs.equals(t)||(this.Cs.c(t),this.invalidateLayout())}get arrangesToOrigin(){return this.Ng}set arrangesToOrigin(t){this.Ng!==t&&(Util.t(t,"boolean",ForceDirectedLayout,"arrangesToOrigin"),this.Ng=t,this.invalidateLayout())}get setsPortSpots(){return this.Bn}set setsPortSpots(t){this.Bn!==t&&(Util.t(t,"boolean",ForceDirectedLayout,"setsPortSpots"),this.Bn=t,this.invalidateLayout())}get comments(){return this.Ve}set comments(t){this.Ve!==t&&(Util.t(t,"boolean",ForceDirectedLayout,"comments"),this.Ve=t,this.invalidateLayout())}get maxPrelayoutIterations(){return this.Cg}set maxPrelayoutIterations(t){this.Cg!==t&&(Util.t(t,"number",ForceDirectedLayout,"maxPrelayoutIterations"),t>=0&&(this.Cg=t,this.invalidateLayout()))}get maxIterations(){return this.Ag}set maxIterations(t){this.Ag!==t&&(Util.t(t,"number",ForceDirectedLayout,"maxIterations"),t>=0&&(this.Ag=t,this.invalidateLayout()))}get epsilonDistance(){return this.Lg}set epsilonDistance(t){this.Lg!==t&&(Util.t(t,"number",ForceDirectedLayout,"epsilonDistance"),t>0&&(this.Lg=t,this.invalidateLayout()))}get infinityDistance(){return this.qc}set infinityDistance(t){this.qc!==t&&(Util.t(t,"number",ForceDirectedLayout,"infinityDistance"),t>1&&(this.qc=t,this.invalidateLayout()))}get moveLimit(){return this.Tg}set moveLimit(t){this.Tg!==t&&(Util.t(t,"number",ForceDirectedLayout,"moveLimit"),this.Tg=t,this.invalidateLayout())}get randomNumberGenerator(){return this.Dg}set randomNumberGenerator(t){this.Dg!==t&&(t!==null&&typeof t.random!="function"&&Util.n('ForceDirectedLayout.randomNumberGenerator must have a "random()" function on it: '+t),this.Dg=t)}get defaultSpringStiffness(){return this.jc}set defaultSpringStiffness(t){this.jc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultSpringStiffness"),this.jc=t,this.invalidateLayout())}get defaultSpringLength(){return this.Wc}set defaultSpringLength(t){this.Wc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultSpringLength"),this.Wc=t,this.invalidateLayout())}get defaultElectricalCharge(){return this.vc}set defaultElectricalCharge(t){this.vc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultElectricalCharge"),this.vc=t,this.invalidateLayout())}get defaultGravitationalMass(){return this.Jc}set defaultGravitationalMass(t){this.Jc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultGravitationalMass"),this.Jc=t,this.invalidateLayout())}get defaultCommentSpringLength(){return this.Fg}set defaultCommentSpringLength(t){this.Fg!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultCommentSpringLength"),this.Fg=t,this.invalidateLayout())}get defaultCommentElectricalCharge(){return this.Rg}set defaultCommentElectricalCharge(t){this.Rg!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultCommentElectricalCharge"),this.Rg=t,this.invalidateLayout())}get prelayoutQuality(){return this.Zc}set prelayoutQuality(t){this.Zc!==t&&(Util.t(t,"number",ForceDirectedLayout,"prelayoutQuality"),this.Zc=t,this.invalidateLayout())}get prelayoutSpread(){return this.ef}set prelayoutSpread(t){this.ef!==t&&(Util.t(t,"number",ForceDirectedLayout,"prelayoutSpread"),this.ef=t,this.invalidateLayout())}}class ForceDirectedNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new ForceDirectedVertex(this)}createEdge(){return new ForceDirectedEdge(this)}}class ForceDirectedVertex extends LayoutVertex{Zb;$b;Qb;_b;tk;hierarchicalVertexes;idInCluster;constructor(t){super(t),this.Zb=!1,this.$b=NaN,this.Qb=NaN,this._b=0,this.tk=0,this.hierarchicalVertexes=new List,this.idInCluster=-1}get isFixed(){return this.Zb}set isFixed(t){this.Zb!==t&&(Util.t(t,"boolean",ForceDirectedVertex,"isFixed"),this.Zb=t)}get charge(){return this.$b}set charge(t){this.$b!==t&&(Util.t(t,"number",ForceDirectedVertex,"charge"),this.$b=t)}get mass(){return this.Qb}set mass(t){this.Qb!==t&&(Util.t(t,"number",ForceDirectedVertex,"mass"),this.Qb=t)}get forceX(){return this._b}set forceX(t){this._b!==t&&(Util.t(t,"number",ForceDirectedVertex,"forceX"),this._b=t)}get forceY(){return this.tk}set forceY(t){this.tk!==t&&(Util.t(t,"number",ForceDirectedVertex,"forceY"),this.tk=t)}}class ForceDirectedEdge extends LayoutEdge{ik;ek;constructor(t){super(t),this.ik=NaN,this.ek=NaN}get stiffness(){return this.ik}set stiffness(t){this.ik!==t&&(Util.t(t,"number",ForceDirectedEdge,"stiffness"),this.ik=t)}get length(){return this.ek}set length(t){this.ek!==t&&(Util.t(t,"number",ForceDirectedEdge,"length"),this.ek=t)}}class RandomNumberGenerator{I;R;Q;M;A;seed;constructor(t){t===void 0&&(t=42),this.seed=t,this.A=48271,this.M=2147483647,this.Q=this.M/this.A,this.R=this.M%this.A,this.I=1/this.M,this.random()}random(){const t=this.seed/this.Q,i=this.seed%this.Q,e=this.A*i-this.R*t;return e>0?this.seed=e:this.seed=e+this.M,this.seed*this.I}}var LayeredDigraphCycleRemove=(w=>(w[w.DepthFirst=0]="DepthFirst",w[w.Greedy=1]="Greedy",w[w.FromLayers=2]="FromLayers",w))(LayeredDigraphCycleRemove||{}),LayeredDigraphLayering=(w=>(w[w.OptimalLinkLength=10]="OptimalLinkLength",w[w.LongestPathSink=11]="LongestPathSink",w[w.LongestPathSource=12]="LongestPathSource",w))(LayeredDigraphLayering||{}),LayeredDigraphInit=(w=>(w[w.DepthFirstOut=20]="DepthFirstOut",w[w.DepthFirstIn=21]="DepthFirstIn",w[w.Naive=22]="Naive",w))(LayeredDigraphInit||{}),LayeredDigraphAggressive=(w=>(w[w.None=30]="None",w[w.Less=31]="Less",w[w.More=32]="More",w))(LayeredDigraphAggressive||{}),LayeredDigraphPack=(w=>(w[w.None=0]="None",w[w.Expand=1]="Expand",w[w.Straighten=2]="Straighten",w[w.Median=4]="Median",w[w.MaybeExpand=8]="MaybeExpand",w[w.All=15]="All",w))(LayeredDigraphPack||{}),LayeredDigraphAlign=(w=>(w[w.None=0]="None",w[w.UpperLeft=1]="UpperLeft",w[w.UpperRight=2]="UpperRight",w[w.LowerLeft=4]="LowerLeft",w[w.LowerRight=8]="LowerRight",w[w.All=15]="All",w))(LayeredDigraphAlign||{});class LayeredDigraphLayout extends Layout{As;te;C;$c;Qc;_c;sf;tu;ar;iu;Bn;Lt;Wy;Wt;Ig;Ls;pi;nn;Ts;Ds;Gt;Og;nf;Eg;on;eu;fr;Vn;zn;UN;constructor(t){super(),this.As=25,this.te=25,this.C=0,this.$c=0,this.Qc=10,this._c=20,this.sf=4,this.tu=31,this.ar=15,this.iu=10,this.Bn=!0,this.Lt=-1,this.Wy=-1,this.Wt=-1,this.Ig=0,this.Ls=0,this.pi=null,this.nn=null,this.Ts=null,this.Ds=null,this.Gt=null,this.Og=0,this.nf=null,this.Eg=null,this.on=0,this.eu=null,this.fr=new Point,this.Vn=[],this.Vn.length=100,this.zn=15,this.UN=0,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.As=this.As,t.te=this.te,t.C=this.C,t.$c=this.$c,t.Qc=this.Qc,t._c=this._c,t.sf=this.sf,t.tu=this.tu,t.ar=this.ar,t.iu=this.iu,t.Bn=this.Bn,t.zn=this.zn}fi(t){t in LayeredDigraphAggressive?this.aggressiveOption=t:t in LayeredDigraphCycleRemove?this.cycleRemoveOption=t:t in LayeredDigraphInit?this.initializeOption=t:t in LayeredDigraphLayering?this.layeringOption=t:super.fi(t)}createNetwork(){return new LayeredDigraphNetwork(this)}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin),this.$O(),this.network.vertexes.count>0&&(this.network.deleteSelfEdges(),this.cycleRemoveOption!==2&&this.removeCycles(),this.QO(),this.cycleRemoveOption===2&&this.removeCycles(),this._O(),this.t3(),this.i3(),this.reduceCrossings(),this.straightenAndPack(),this.updateParts()),this.network=null,this.isValidLayout=!0}linkMinLength(t){return 1}linkLengthWeight(t){return 1}linkStraightenWeight(t){const i=t.fromVertex.node||t.fromVertex.data,e=t.toVertex.node||t.toVertex.data;return i===null&&e===null?8:i===null||e===null?4:1}nodeMinLayerSpace(t,i){return t.node===null&&t.data===null?0:this.C===90||this.C===270?i?t.focus.y+10:t.bounds.height-t.focus.y+10:i?t.focus.x+10:t.bounds.width-t.focus.x+10}nodeMinColumnSpace(t,i){if(t.node===null&&t.data===null)return 0;const e=i?t.sk:t.nk;if(e!==null)return e;const s=this.C;return s===90||s===270?i?t.sk=t.focus.x/this.te+1|0:t.nk=(t.bounds.width-t.focus.x)/this.te+1|0:i?t.sk=t.focus.y/this.te+1|0:t.nk=(t.bounds.height-t.focus.y)/this.te+1|0}ie(){this.nf===null&&(this.nf=[]);let t=0;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;this.nf[t]=e.layer,t++,this.nf[t]=e.column,t++,this.nf[t]=e.index,t++}return this.nf}es(t){let i=0;const e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;s.layer=t[i],i++,s.column=t[i],i++,s.index=t[i],i++}}nD(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"crossingMatrix:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"crossingMatrix:direction"));const e=this.Eh(t),s=this.pi[t];(this.Eg===null||this.Eg.length=0){for(f=e[o].So,c=0;ck||d===k&&g>S)&&r++,bd||k===d&&S>g)&&r++)}if(i<=0){for(f=e[o].rr,c=0;ck||d===k&&m>b)&&r++,Sd||k===d&&b>m)&&r++)}for(n[o*s+o]=r,a=o+1;a=0){for(p=e[o].So,M=e[a].So,c=0;c=0&&(h=s[r].rr);let a,f=0,c=0;if(l!==null)for(let u=0;u=0&&(h=r.rr);let a=0,f=0;const c=r.near;c!==null&&c.layer===r.layer&&(a+=c.column-1,f++);let u;if(l!==null)for(let d=0;d=0&&(h=r.rr);let a=0;const f=[],c=r.near;c!==null&&c.layer===r.layer&&(f[a]=c.column-1,a++);let u;if(l!==null)for(let d=0;dm-g);const d=a>>1;a&1?n[o]=f[d]:n[o]=f[d-1]+f[d]>>1}}return this.Bh(t,e),n}Zy(t,i,e,s,n){if(t.component===e){t.component=i;let o=0,r=0;if(s){const l=t.destinationEdges;for(;l.next();){const h=l.value,a=h.toVertex;o=t.layer-a.layer,r=this.linkMinLength(h),o===r&&this.Zy(a,i,e,s,n)}}if(n){const l=t.sourceEdges;for(;l.next();){const h=l.value,a=h.fromVertex;o=a.layer-t.layer,r=this.linkMinLength(h),o===r&&this.Zy(a,i,e,s,n)}}}}GN(t,i,e,s,n){if(t.component===e){if(t.component=i,s){const o=t.destinationEdges;for(;o.next();){const l=o.value.toVertex;this.GN(l,i,e,s,n)}}if(n){const o=t.sourceEdges;for(;o.next();){const l=o.value.fromVertex;this.GN(l,i,e,s,n)}}}}removeCycles(){const t=this.network.edges.iterator;for(;t.next();){const i=t.value;i.rev=!1}switch(this.$c){default:case 1:this.s3();break;case 0:this.o3();break;case 2:this.r3();break}}r3(){const t=this.network,i=t.vertexes.iterator;let e=1/0;for(;i.next();){const s=i.value;e=Math.min(e,s.layer)}if(e<1/0){if(e<0)for(i.reset();i.next();){const r=i.value;r.layer-=e}const s=[];for(i.reset();i.next();){const r=i.value,l=s[r.layer];l===void 0?s[r.layer]=[r]:l.push(r)}let n=0;for(let r=0;r0)for(let h=0;hh.index&&(t.reverseEdge(r),r.rev=!0)}}l3(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.ee)return e}return null}rD(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.ee){let s=!0;const n=e.destinationEdges;for(;n.next();)if(n.value.toVertex.ee){s=!1;break}if(s)return e}}return null}lD(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.ee){let s=!0;const n=e.sourceEdges;for(;n.next();)if(n.value.fromVertex.ee){s=!1;break}if(s)return e}}return null}h3(t){let i=null,e=0;const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;if(n.ee){let o=0;const r=n.destinationEdges;for(;r.next();)r.value.toVertex.ee&&o++;let l=0;const h=n.sourceEdges;for(;h.next();)h.value.fromVertex.ee&&l++;(i===null||ef&&this.Zy(h,e,-1,!0,!1)}for(this.Zy(t,s,-1,!0,!0);t.component!==e;){let r=0,l=1/0,h=0,a=null;const f=this.network.vertexes.iterator;for(;f.next();){const c=f.value;if(c.component===s){let u=0,d=!1;const m=c.So;o=m.length;for(let p=0;p0){for(i.reset();i.next();){const c=i.value;c.component===s&&(c.layer+=l)}t.component=e}else a.component=e}}u3(t){const i=this.network.vertexes.iterator;for(;i.next();){const n=i.value;n.component=-1}const e=0,s=1;for(this.Zy(t,s,-1,!0,!1);t.component!==e;){let n=0,o=1/0,r=0,l=null;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value;if(a.component===s){let f=0,c=!1;const u=a.So;let d=u.length;for(let g=0;gr)&&!c&&(l=a,r=f)}}if(n<0){for(i.reset();i.next();){const a=i.value;a.component===s&&(a.layer-=o)}t.component=e}else l.component=e}}_O(){const t=this.network,i=[],e=t.edges.iterator;for(;e.next();){const s=e.value;s.valid=!1,i.push(s)}for(let s=0;sb&&c>0){for(n.valid=!1,y=t.createVertex(),y.node=null,y.rk=2,y.layer=c-1,x&&kb&&c>0;)y=t.createVertex(),y.node=null,y.rk=3,y.layer=c-1,x&&kt[this.Ls]&&(this.Wy=t[e]-1,this.Ls=e),t[e]{o.index=this.pi[s],this.pi[s]++})}}p3(){let t=null;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;if(e.near&&(t===null&&(t=new Map),e.layer===e.near.layer)){const s=t.get(e.near)||[];s.push(e),t.set(e.near,s)}}for(let e=this.Lt;e>=0;e--)for(i.reset();i.next();){const s=i.value;s.layer===e&&s.index===-1&&this.gD(s,t)}}gD(t,i){if(t.near)return;const e=t.layer;if(t.index=this.pi[e],this.pi[e]++,i){const o=i.get(t);Array.isArray(o)&&o.forEach(r=>{r.index=this.pi[e],this.pi[e]++})}const s=t.rr;let n=!0;for(;n;){n=!1;for(let o=0;ol.portFromColOffset&&(n=!0,s[o]=l,s[o+1]=r)}}for(let o=0;o{a.index=this.pi[e],this.pi[e]++})}const s=t.So;let n=!0,o=0;for(;n;)for(n=!1,o=0;oa.portToColOffset&&(n=!0,s[o]=a,s[o+1]=h)}let r,l;for(o=0;o=0;s--)this.hk(s,-1),this.us(s,-1,!1,-1);n=this.countCrossings(),n=0;s--)this.hk(s,0),this.us(s,0,!1,0);n=this.countCrossings(),n=0;r--)for(l=0;l<=r;l++){for(o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,1,!1,1)||o;for(n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,-1,!1,-1)||o;for(n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,0,!1,0)||o;for(n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,0,!1,0)||o;n>=t?this.es(i):(t=n,i=this.ie())}break;default:case 31:for(r=this.Lt,l=0,h=t+1;(a=this.countCrossings())=l;s--)o=this.us(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,1,!1,1)||o;for(n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,-1,!1,-1)||o;for(n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,0,!1,0)||o;for(n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,0,!1,0)||o;n>=t?this.es(i):(t=n,i=this.ie())}break}this.es(i)}hk(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"medianBarycenterCrossingReduction:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"medianBarycenterCrossingReduction:direction"));let e=0,s=!1;const n=this.Eh(t),o=this.pi[t],r=this.oD(t,i),l=this.Jy(t,i);for(e=0;e0)for(h=[],l=0;ll+1&&(m+=4*(I-l),g+=4*(I-(l+1)))}}const B=n[l].destinationEdges.iterator;if(e&&s>=0)for(;B.next();){const W=B.value;O=W.toVertex,W.valid&&O.layer!==t&&(N=this.linkStraightenWeight(W),T=W.portFromColOffset,L=W.portToColOffset,F=O.column,C+=(Math.abs(p+T-(F+L))+1)*N,P+=(Math.abs(A+T-(F+L))+1)*N)}for(B.reset();B.next();){const W=B.value;if(O=W.toVertex,W.valid&&O.layer===t){for(V=0;Vl+1&&(m+=4*(I-(l+1)),g+=4*(I-l))}}const z=n[l+1].destinationEdges.iterator;if(e&&s>=0)for(;z.next();){const W=z.value;O=W.toVertex,W.valid&&O.layer!==t&&(N=this.linkStraightenWeight(W),T=W.portFromColOffset,L=W.portToColOffset,F=O.column,C+=(Math.abs(y+T-(F+L))+1)*N,P+=(Math.abs(M+T-(F+L))+1)*N)}for(z.reset();z.next();){const W=z.value;if(O=W.toVertex,W.valid&&O.layer===t){for(V=0;V1e3&&s&&(e=!1),e){const n=[];let o=0;for(o=0;o<=this.Lt;o++)n[o]=0;let r=0;const l=this.network.vertexes.iterator;for(;l.next();){const a=l.value;t=a.layer,r=a.column;const f=this.nodeMinColumnSpace(a,!1);n[t]=Math.max(n[t],r+f)}const h=8;for(l.reset();l.next();){const a=l.value;t=a.layer,r=a.column,a.column=((this.Wt-n[t])*h>>1)+r*h}this.Wt*=h}if(this.ar&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Bg(t,-1)||i;i=this.Bg(this.Ls,0)||i,n++}}if(this.ar&4){for(t=this.Ls+1;t<=this.Lt;t++)this.qN(t,1);for(t=this.Ls-1;t>=0;t--)this.qN(t,-1);this.qN(this.Ls,0)}if(e&&(this.pD(-1),this.pD(1)),this.ar&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Bg(t,0)||i;n++}}}Bg(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"bendStraighten:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"bendStraighten:direction"));let e=!1;for(;this.x3(t,i);)e=!0;return e}x3(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"shiftbendStraighten:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"shiftbendStraighten:direction"));let e=0;const s=this.Eh(t),n=this.pi[t],o=this.Jy(t,-1);if(i>0)for(e=0;ef+this.nodeMinColumnSpace(s[e-1],!1)?u=a-1:u=a;let d=0;e+1>=n||s[e+1].column-a-1>c+this.nodeMinColumnSpace(s[e+1],!0)?d=a+1:d=a;let m=0,g=0,p=0,y=0,x=0,k=0;if(i<=0){const P=s[e].sourceEdges.iterator;for(;P.next();){const N=P.value,T=N.fromVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const L=T.column;m+=(Math.abs(a+k-(L+x))+1)*y,g+=(Math.abs(u+k-(L+x))+1)*y,p+=(Math.abs(d+k-(L+x))+1)*y}}}if(i>=0){const P=s[e].destinationEdges.iterator;for(;P.next();){const N=P.value,T=N.toVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const L=T.column;m+=(Math.abs(a+x-(L+k))+1)*y,g+=(Math.abs(u+x-(L+k))+1)*y,p+=(Math.abs(d+x-(L+k))+1)*y}}}let b=0,S=0,M=0;const A=o[s[e].index],C=r[s[e].index];A!==-1&&(b+=Math.abs(A-a),S+=Math.abs(A-u),M+=Math.abs(A-d)),C!==-1&&(b+=Math.abs(C-a),S+=Math.abs(C-u),M+=Math.abs(C-d)),g=r[e]?u=p:g<=r[e]&&(u=g)),u!==a&&(l=!0,h=!0,s[e].column=u)}return this.Bh(t,s),this.vy(),l}b3(){for(let t=0;t<=this.Wt;t++)for(;this.k3(t,1););this.vy()}k3(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"packAux:column"),Util.r(i,LayeredDigraphLayout,"packAux:direction"));let e=!0;const s=this.network.vertexes.iterator;for(;s.next();){const o=s.value,r=this.nodeMinColumnSpace(o,!0),l=this.nodeMinColumnSpace(o,!1);if(o.column-r<=t&&o.column+l>=t){e=!1;break}}let n=!1;if(e){if(i>0)for(s.reset();s.next();){const o=s.value;o.column>t&&(o.column-=1,n=!0)}if(i<0)for(s.reset();s.next();){const o=s.value;o.column0&&(e=t+1),i<0&&(e=t-1);let s=0;const n=[],o=[];for(s=0;s<=this.Lt;s++)n[s]=!1,o[s]=!1;const r=this.network.vertexes.iterator;for(;r.next();){const a=r.value,f=a.column-this.nodeMinColumnSpace(a,!0),c=a.column+this.nodeMinColumnSpace(a,!1);f<=t&&c>=t&&(n[a.layer]=!0),f<=e&&c>=e&&(o[a.layer]=!0)}let l=!0,h=!1;for(s=0;s<=this.Lt;s++)l=l&&!(n[s]&&o[s]);if(l){if(i>0)for(r.reset();r.next();){const a=r.value;a.column>t&&(a.column-=1,h=!0)}if(i<0)for(r.reset();r.next();){const a=r.value;a.column0)for(i=0;i<=this.Wt;i++)for(e=this.ie(),s=this.ok(!0),n=s+1;ss?this.es(e):o=0;i--)for(e=this.ie(),s=this.ok(!0),n=s+1;ss?this.es(e):o0)for(e.reset();e.next();){const f=e.value;f.column-this.nodeMinColumnSpace(f,!0)<=t&&(f.component=this.on)}if(i<0)for(e.reset();e.next();){const f=e.value;f.column+this.nodeMinColumnSpace(f,!1)>=t&&(f.component=this.on)}for(this.on++,e.reset();e.next();){const f=e.value;f.component===-1&&(this.GN(f,this.on,-1,!0,!0),this.on++)}let s=0;const n=[];for(s=0;s0)for(let c=0;c0;c--)o[f*(this.Wt+1)+c]!==-1&&o[f*(this.Wt+1)+c-1]!==-1&&o[f*(this.Wt+1)+c]!==o[f*(this.Wt+1)+c-1]&&(n[o[f*(this.Wt+1)+c]*this.on+o[f*(this.Wt+1)+c-1]]=!0)}const r=[];for(s=0;s0)for(e.reset();e.next();){const f=e.value;r[f.component]&&(f.column-=1,a=!0)}if(i<0)for(e.reset();e.next();){const f=e.value;r[f.component]&&(f.column+=1,a=!0)}return a}w3(){const t=Util.at(),i=this.eu.length;for(let u=0;u<=i;u++)t[u]=[];const e=this.network.vertexes.iterator;for(;e.next();){const u=e.value,d=i-u.layer,m=t[d];m[u.index]=u}const s=new GSet;this.P3(t,s);let n=null,o=null,r=null,l=null;const h=(this.zn&1)!==0,a=(this.zn&2)!==0,f=(this.zn&4)!==0,c=(this.zn&8)!==0;h&&(this.hl(t,s,!0),n=this.ak(t,!0,!1)),t.reverse(),f&&(this.hl(t,s,!1),r=this.ak(t,!1,!1));for(const u of t)u.reverse();c&&(this.hl(t,s,!1),l=this.ak(t,!1,!0)),t.reverse(),a&&(this.hl(t,s,!0),o=this.ak(t,!0,!0)),Util.nt(t),this.N3(n,o,r,l),this.network.vertexes.each(u=>{const d=u,m=Util.at();h&&m.push(n.get(d)),a&&m.push(o.get(d)),f&&m.push(r.get(d)),c&&m.push(l.get(d)),m.sort((k,b)=>k-b);const g=m.length,p=Math.floor((g-1)/2),y=Math.ceil((g-1)/2),x=(m[p]+m[y])/2;Util.nt(m),d.de=x})}P3(t,i){const e=t.length;for(let s=1;sc)&&i.add(m)}o++}n=c}}}}C3(t){if(t.node===null){const i=t.getProperSourceVertexes();if(i.length>0)return i[0].node===null}return!1}hl(t,i,e){this.A3(t);for(const s of t){let n=-1;for(const o of s){const r=e?o.getProperSourceVertexes():o.getProperDestinationVertexes(),l=r.length;if(l>0){r.sort((a,f)=>a.Vh-f.Vh);const h=(l-1)/2;for(let a=Math.floor(h),f=Math.ceil(h);a<=f;a++)if(o.Xn===o){const c=r[a];let u;e?u=c.getDestinationEdge(o):u=o.getDestinationEdge(c),!i.has(u)&&n0){const f=this.bD(a,t),c=s?f.width:f.height,u=a.ss.nu+a.de+a.Yn-(f.de+f.Yn+c+this.columnSpacing);f.ss.nu=Math.min(f.ss.nu,u)}h=a.Vh+1}while(l0){const s=this.bD(e,i),n=s.of;this.xD(n,i),t.ss===t&&(t.ss=n.ss);const o=this.C===90||this.C===270?s.width:s.height;if(t.ss===n.ss){const r=n.de+s.Yn+o-e.Yn+this.columnSpacing;t.de=Math.max(t.de,r)}}e=e.Xn}while(e!==t);for(;e.Xn!==t;)e=e.Xn,e.de=t.de,e.ss=t.ss}bD(t,i){const e=t.wD,s=t.Vh;return s<1&&Util.n("Could not determine previous vertex in layer"),i[e][s-1]}N3(...t){let i=-1;const e=Util.at(),s=Util.at();let n=1/0;for(let o=0;o<4;o++){if(!t[o])continue;const r=this.T3(t[o],e,s,o);r{r.set(h.key,h.value+l)})}Util.nt(e),Util.nt(s)}T3(t,i,e,s){if(!t||t.count===0)return i[s]=0,e[s]=0,1/0;let n=1/0,o=-1/0;return t.each(r=>{const l=r.key,h=r.value,a=this.C===90||this.C===270?l.width:l.height;ho&&(o=h+a)}),i[s]=n,e[s]=o,o-n}commitLayout(){this.jy(),this.commitNodes(),this.jN(),this.isRouting&&this.commitLinks()}jy(){if(!this.setsPortSpots)return;const t=this.lk(!0),i=this.lk(!1),e=this.network.edges.iterator;for(;e.next();){const n=e.value.link;n!==null&&(n.fromSpot=t,n.toSpot=i)}}lk(t){return this.C===270?t?Spot.MiddleTop:Spot.MiddleBottom:this.C===90?t?Spot.MiddleBottom:Spot.MiddleTop:this.C===180?t?Spot.MiddleLeft:Spot.MiddleRight:t?Spot.MiddleRight:Spot.MiddleLeft}commitNodes(){this.nn=[],this.Ts=[],this.Ds=[],this.Gt=[];for(let d=0;d<=this.Lt;d++)this.nn[d]=0,this.Ts[d]=0,this.Ds[d]=0,this.Gt[d]=0;const t=this.network.vertexes.iterator;for(;t.next();){const d=t.value,m=d.layer;this.nn[m]=Math.max(this.nn[m],this.nodeMinLayerSpace(d,!0)),this.Ts[m]=Math.max(this.Ts[m],this.nodeMinLayerSpace(d,!1))}let i=0;const e=this.As;for(let d=0;d<=this.Lt;d++){let m=e;this.nn[d]+this.Ts[d]<=0&&(m=0),d>0&&(i+=m/2),this.C===90||this.C===0?(i+=this.Ts[d],this.Ds[d]=i,i+=this.nn[d]):(i+=this.nn[d],this.Ds[d]=i,i+=this.Ts[d]),d=0;n--)this.C===270?n===0?e.push(new Rect(0,0,s,Math.abs(this.Gt[0]))):e.push(new Rect(0,this.Gt[n-1],s,Math.abs(this.Gt[n-1]-this.Gt[n]))):this.C===90?n===0?e.push(new Rect(0,this.Gt[0],s,Math.abs(this.Gt[0]-t))):e.push(new Rect(0,this.Gt[n],s,Math.abs(this.Gt[n-1]-this.Gt[n]))):this.C===180?n===0?e.push(new Rect(0,0,Math.abs(this.Gt[0]),s)):e.push(new Rect(this.Gt[n-1],0,Math.abs(this.Gt[n-1]-this.Gt[n]),s)):n===0?e.push(new Rect(this.Gt[0],0,Math.abs(this.Gt[0]-t),s)):e.push(new Rect(this.Gt[n],0,Math.abs(this.Gt[n-1]-this.Gt[n]),s));this.commitLayers(e,this.fr)}commitLayers(t,i){}commitLinks(){const t=this.network.edges.iterator;let i;for(;t.next();)i=t.value.link,i!==null&&(i.startRoute(),i.clearPoints(),i.commitRoute());for(t.reset();t.next();)i=t.value.link,i!==null&&i.updateRoute();for(t.reset();t.next();){const e=t.value;if(i=e.link,i===null||i.pointsCount===0)continue;i.startRoute();const s=i;let n=s.fromNode,o=s.toNode,r=s.fromPort,l=s.toPort;if(n!==null){const N=n.findVisibleNode();N!==null&&N!==n&&(n=N,r=N.port)}if(o!==null){const N=o.findVisibleNode();N!==null&&N!==o&&(o=N,l=N.port)}const h=i.computeSpot(!0,r),a=i.computeSpot(!1,l);let f=e.fromVertex,c=e.toVertex;if(e.valid){if(i.curve===9&&i.pointsCount===4)if(f.column===c.column&&this.alignOption===0){const N=i.getLinkPoint(n,r,h,!0,!1,o,l),T=i.getLinkPoint(o,l,a,!1,!1,n,r);N.isReal()||N.set(n.actualBounds.center),T.isReal()||T.set(o.actualBounds.center),i.clearPoints(),i.addPointAt(N.x,N.y),i.addPointAt((2*N.x+T.x)/3,(2*N.y+T.y)/3),i.addPointAt((N.x+2*T.x)/3,(N.y+2*T.y)/3),i.addPointAt(T.x,T.y)}else{let N=!1,T=!1;if(r!==null&&h===Spot.None&&(N=!0),l!==null&&a===Spot.None&&(T=!0),N||T){let L=null;N&&(L=i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0),L.isReal()||L.set(n.actualBounds.center),i.setPointAt(0,L.x,L.y));let D=null;if(T&&(D=i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(0),!1),D.isReal()||D.set(o.actualBounds.center),i.setPointAt(3,D.x,D.y)),L){const F=i.getPoint(2);i.setPointAt(1,(L.x*2+F.x)/3,(L.y*2+F.y)/3)}if(D){const F=i.getPoint(1);i.setPointAt(2,(D.x*2+F.x)/3,(D.y*2+F.y)/3)}}}i.commitRoute();continue}if(f.layer===c.layer){i.commitRoute();continue}let u=!1,d=!1;const m=this.As;let g=0,p=i.firstPickIndex+1;if(i.isOrthogonal)d=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3);else if(i.curve===9)u=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3),g===4&&(p=2);else{g=i.pointsCount;const N=h===Spot.None,T=a===Spot.None;g>2&&N&&T?i.points.removeRange(1,g-2):g>3&&N&&!T?i.points.removeRange(1,g-3):g>3&&!N&&T?i.points.removeRange(2,g-2):g>4&&!N&&!T&&i.points.removeRange(2,g-3)}let y,x,k=0,b=0,S=0,M=0,A=0,C=0,P=0;if(e.rev){let N=0;for(;c!==null&&f!==c;){y=null,x=null;const T=c.sourceEdges.iterator;for(;T.next();){const L=T.value;if(L.link===e.link&&(y=L.fromVertex,x=L.toVertex,y.node===null))break}if(y===null)break;if(y!==f)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=y.centerX,M=y.centerY,d)this.C===180||this.C===0?p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,k,M)):(x!==null?x.centerY:b)!==M&&(A=this.Gt[y.layer-1]+this.fr.x,i.insertPointAt(p++,A,b),i.insertPointAt(p++,A,M)):p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,S,b)):(x!==null?x.centerX:k)!==S&&(A=this.Gt[y.layer-1]+this.fr.y,i.insertPointAt(p++,k,A),i.insertPointAt(p++,S,A));else if(p===i.firstPickIndex+1)if(C=Math.max(10,this.nn[c.layer]),P=Math.max(10,this.Ts[c.layer]),u)this.C===180?S<=c.bounds.x?(N=c.bounds.x,i.insertPointAt(p++,N-C,M),i.insertPointAt(p++,N,M),i.insertPointAt(p++,N+P,M)):(i.insertPointAt(p++,S-C,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S+P,M)):this.C===90?M>=c.bounds.bottom?(N=c.bounds.y+c.bounds.height,i.insertPointAt(p++,S,N+P),i.insertPointAt(p++,S,N),i.insertPointAt(p++,S,N-C)):(i.insertPointAt(p++,S,M+P),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M-C)):this.C===270?M<=c.bounds.y?(N=c.bounds.y,i.insertPointAt(p++,S,N-C),i.insertPointAt(p++,S,N),i.insertPointAt(p++,S,N+P)):(i.insertPointAt(p++,S,M-C),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M+P)):this.C===0&&(S>=c.bounds.right?(N=c.bounds.x+c.bounds.width,i.insertPointAt(p++,N+P,M),i.insertPointAt(p++,N,M),i.insertPointAt(p++,N-C,M)):(i.insertPointAt(p++,S+P,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S-C,M)));else{i.insertPointAt(p++,k,b);let L=0;this.C===180||this.C===0?((this.C===180?S>=c.bounds.right:S<=c.bounds.x)&&(L=(this.C===0?-C:P)/2),i.insertPointAt(p++,k+L,M)):((this.C===270?M>=c.bounds.bottom:M<=c.bounds.y)&&(L=(this.C===90?-C:P)/2),i.insertPointAt(p++,S,b+L)),i.insertPointAt(p++,S,M)}else C=Math.max(10,this.nn[y.layer]),P=Math.max(10,this.Ts[y.layer]),u?this.C===180?(i.insertPointAt(p++,S-C-m,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S+P+m,M)):this.C===90?(i.insertPointAt(p++,S,M+P+m),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M-C-m)):this.C===270?(i.insertPointAt(p++,S,M-C-m),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M+P+m)):(i.insertPointAt(p++,S+P+m,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S-C-m,M)):(this.C===180||this.C===90||this.C,i.insertPointAt(p++,S,M));c=y}if(l===null||h!==Spot.None||d)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=i.getPoint(p).x,M=i.getPoint(p).y,d){const T=this.Ts[f.layer];let L=0;this.C===180||this.C===0?(L=b,L>=f.bounds.y&&L<=f.bounds.bottom&&(this.C===180?S>=f.bounds.x:S<=f.bounds.right)&&(N=f.centerX+(this.C===180?-T:T),L=f.bounds.x&&L<=f.bounds.right&&(this.C===270?M>=f.bounds.y:M<=f.bounds.bottom)&&(N=f.centerY+(this.C===270?-T:T),L=f.bounds.x?(N=f.bounds.x+f.bounds.width,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N+P,b)):this.C===90&&M<=f.bounds.bottom?(N=f.bounds.y,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N-C)):this.C===270&&M>=f.bounds.y?(N=f.bounds.y+f.bounds.height,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N+P)):this.C===0&&S<=f.bounds.right&&(N=f.bounds.x,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N-C,b));else{C=Math.max(10,this.nn[f.layer]),P=Math.max(10,this.Ts[f.layer]);let T=0;this.C===180||this.C===0?((this.C===180?S<=f.bounds.x:S>=f.bounds.right)&&(T=(this.C===0?P:-C)/2),i.insertPointAt(p++,S+T,b)):((this.C===270?M<=f.bounds.y:M>=f.bounds.bottom)&&(T=(this.C===90?P:-C)/2),i.insertPointAt(p++,k,M+T)),i.insertPointAt(p++,S,M)}}else{for(;f!==null&&f!==c;){y=null,x=null;const N=f.destinationEdges.iterator;for(;N.next();){const T=N.value;if(T.link===e.link&&(y=T.toVertex,x=T.fromVertex,x.node!==null&&(x=null),y.node===null))break}if(y===null)break;y!==c&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=y.centerX,M=y.centerY,d?this.C===180||this.C===0?(x!==null?x.centerY:b)!==M&&(A=this.Gt[y.layer]+this.fr.x,p===i.firstPickIndex+1&&(this.C===0?A=Math.max(A,k):A=Math.min(A,k)),i.insertPointAt(p++,A,b),i.insertPointAt(p++,A,M)):(x!==null?x.centerX:k)!==S&&(A=this.Gt[y.layer]+this.fr.y,p===i.firstPickIndex+1&&(this.C===90?A=Math.max(A,b):A=Math.min(A,b)),i.insertPointAt(p++,k,A),i.insertPointAt(p++,S,A)):(C=Math.max(10,this.nn[y.layer]),P=Math.max(10,this.Ts[y.layer]),u?this.C===180?(i.insertPointAt(p++,S+P+m,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S-C-m,M)):this.C===90?(i.insertPointAt(p++,S,M-C-m),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M+P+m)):this.C===270?(i.insertPointAt(p++,S,M+P+m),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M-C-m)):(i.insertPointAt(p++,S-C-m,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S+P+m,M)):this.C===180?(i.insertPointAt(p++,S+P,M),i.insertPointAt(p++,S-C,M)):this.C===90?(i.insertPointAt(p++,S,M-C),i.insertPointAt(p++,S,M+P)):this.C===270?(i.insertPointAt(p++,S,M+P),i.insertPointAt(p++,S,M-C)):(i.insertPointAt(p++,S-C,M),i.insertPointAt(p++,S+P,M)))),f=y}d&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=i.getPoint(p).x,M=i.getPoint(p).y,this.C===180||this.C===0?b!==M&&(this.C===0?A=Math.min(Math.max((S+k)/2,this.Gt[c.layer]+this.fr.x),S):A=Math.max(Math.min((S+k)/2,this.Gt[c.layer]+this.fr.x),S),i.insertPointAt(p++,A,b),i.insertPointAt(p++,A,M)):k!==S&&(this.C===90?A=Math.min(Math.max((M+b)/2,this.Gt[c.layer]+this.fr.y),M):A=Math.max(Math.min((M+b)/2,this.Gt[c.layer]+this.fr.y),M),i.insertPointAt(p++,k,A),i.insertPointAt(p++,S,A)))}if(s!==null&&u&&i.pointsCount>=4){if(r!==null){const N=h===Spot.None?i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0):i.getPoint(0);if(h===Spot.None){const T=i.getPoint(2),L=i.getPoint(3);this.direction===90||this.direction===270?(i.setPointAt(1,(N.x+T.x)/2,T.y),i.setPointAt(2,L.x,(T.y+L.y)/2)):(i.setPointAt(1,T.x,(N.y+T.y)/2),i.setPointAt(2,(T.x+L.x)/2,L.y))}N.isReal()||N.set(n.actualBounds.center),i.setPointAt(0,N.x,N.y)}if(l!==null){const N=a===Spot.None?i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(i.pointsCount-4),!1):i.getPoint(i.pointsCount-1);if(a===Spot.None){const T=i.getPoint(i.pointsCount-3),L=i.getPoint(i.pointsCount-4);this.direction===90||this.direction===270?(i.setPointAt(i.pointsCount-2,(N.x+T.x)/2,T.y),i.setPointAt(i.pointsCount-2,L.x,(T.y+L.y)/2)):(i.setPointAt(i.pointsCount-2,T.x,(N.y+T.y)/2),i.setPointAt(i.pointsCount-3,(T.x+L.x)/2,L.y))}N.isReal()||N.set(o.actualBounds.center),i.setPointAt(i.pointsCount-1,N.x,N.y)}}i.commitRoute(),e.commit()}}$O(){this.Wy=-1,this.Ig=0,this.Ls=0,this.nf=null,this.Eg=null,this.eu=null;for(let t=0;t=this.Vn.length){const n=[];for(let o=0;o=0&&(this.As=t,this.invalidateLayout()))}get columnSpacing(){return this.te}set columnSpacing(t){this.te!==t&&(Util.t(t,"number",LayeredDigraphLayout,"columnSpacing"),t>0&&(this.te=t,this.invalidateLayout()))}get direction(){return this.C}set direction(t){this.C!==t&&(Util.t(t,"number",LayeredDigraphLayout,"direction"),t===0||t===90||t===180||t===270?(this.C=t,this.invalidateLayout()):Util.n("LayeredDigraphLayout.direction must be 0, 90, 180, or 270"))}get cycleRemoveOption(){return this.$c}set cycleRemoveOption(t){this.$c!==t&&(Util.tt(t,LayeredDigraphCycleRemove,"LayeredDigraphCycleRemove"),(t===1||t===0||t===2)&&(this.$c=t,this.invalidateLayout()))}get layeringOption(){return this.Qc}set layeringOption(t){this.Qc!==t&&(Util.tt(t,LayeredDigraphLayering,"LayeredDigraphLayering"),(t===10||t===11||t===12)&&(this.Qc=t,this.invalidateLayout()))}get initializeOption(){return this._c}set initializeOption(t){this._c!==t&&(Util.tt(t,LayeredDigraphInit,"LayeredDigraphInit"),(t===20||t===21||t===22)&&(this._c=t,this.invalidateLayout()))}get iterations(){return this.sf}set iterations(t){this.sf!==t&&(Util.r(t,LayeredDigraphNetwork,"iterations"),t>=0&&(this.sf=t,this.invalidateLayout()))}get aggressiveOption(){return this.tu}set aggressiveOption(t){this.tu!==t&&(Util.tt(t,LayeredDigraphAggressive,"LayeredDigraphAggressive"),(t===30||t===31||t===32)&&(this.tu=t,this.invalidateLayout()))}get packOption(){return this.ar}set packOption(t){this.ar!==t&&(Util.t(t,"number",LayeredDigraphLayout,"packOption"),t>=0&&t<8&&(this.ar=t,this.invalidateLayout()))}get packIterations(){return this.iu}set packIterations(t){this.iu=t}get alignOption(){return this.zn}set alignOption(t){this.zn!==t&&(Util.t(t,"number",LayeredDigraphLayout,"align"),t>=0&&t<16&&(this.zn=t,this.invalidateLayout()))}get setsPortSpots(){return this.Bn}set setsPortSpots(t){this.Bn!==t&&(Util.t(t,"boolean",LayeredDigraphLayout,"setsPortSpots"),this.Bn=t,this.invalidateLayout())}get maxLayer(){return this.Lt}get maxIndex(){return this.Wy}get maxColumn(){return this.Wt}get minIndexLayer(){return this.Ig}get maxIndexLayer(){return this.Ls}static CycleDepthFirst=0;static CycleGreedy=1;static CycleFromLayers=2;static LayerOptimalLinkLength=10;static LayerLongestPathSink=11;static LayerLongestPathSource=12;static InitDepthFirstOut=20;static InitDepthFirstIn=21;static InitNaive=22;static AggressiveNone=30;static AggressiveLess=31;static AggressiveMore=32;static PackNone=0;static PackExpand=1;static PackStraighten=2;static PackMedian=4;static PackAll=15;static AlignNone=0;static AlignUpperLeft=1;static AlignUpperRight=2;static AlignLowerLeft=4;static AlignLowerRight=8;static AlignAll=15}class SegInfo{_o;D3;b1;F3;R3;Bt;$e;I3;constructor(){this._o=0,this.D3=0,this.b1=0,this.F3=0,this.R3=0,this.Bt=0,this.$e=null,this.I3=0}}class LayeredDigraphNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new LayeredDigraphVertex(this)}createEdge(){return new LayeredDigraphEdge(this)}}class LayeredDigraphVertex extends LayoutVertex{_o;Go;Bt;fk;ck;ee;su;$n;rk;sk;nk;of;Xn;wD;Vh;ss;nu;de;Yn;$y=null;Qy=null;_y=null;tw=null;constructor(t){super(t),this._o=-1,this.Go=-1,this.Bt=-1,this.fk=NaN,this.ck=null,this.ee=!1,this.su=NaN,this.$n=NaN,this.rk=0,this.sk=null,this.nk=null}static kD(t,i){return t.index-i.index}getProperSourceEdges(){if(!this._y){const t=[];for(const i of this.So){const e=i;e.valid&&t.push(e)}this._y=t}return this._y}getProperDestinationEdges(){if(!this.tw){const t=[];for(const i of this.rr){const e=i;e.valid&&t.push(e)}this.tw=t}return this.tw}getDestinationEdge(t){const i=this.getProperDestinationEdges();for(const e of i)if(e.toVertex===t)return e;Util.n("Unable to find destination edge to given vertex")}getProperSourceVertexes(){if(!this.$y){const t=[];for(const i of this.So){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.fromVertex)}t.sort(LayeredDigraphVertex.kD),this.$y=t}return this.$y}getProperDestinationVertexes(){if(!this.Qy){const t=[];for(const i of this.rr){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.toVertex)}t.sort(LayeredDigraphVertex.kD),this.Qy=t}return this.Qy}addSourceEdge(t){super.addSourceEdge(t),this.$y=null,this._y=null}deleteSourceEdge(t){super.deleteSourceEdge(t),this.$y=null,this._y=null}addDestinationEdge(t){super.addDestinationEdge(t),this.Qy=null,this.tw=null}deleteDestinationEdge(t){super.deleteDestinationEdge(t),this.Qy=null,this.tw=null}get layer(){return this._o}set layer(t){this._o!==t&&(Util.t(t,"number",LayeredDigraphVertex,"layer"),this._o=t)}get column(){return this.Go}set column(t){this.Go!==t&&(Util.t(t,"number",LayeredDigraphVertex,"column"),this.Go=t)}get index(){return this.Bt}set index(t){this.Bt!==t&&(Util.t(t,"number",LayeredDigraphVertex,"index"),this.Bt=t)}get component(){return this.fk}set component(t){this.fk!==t&&(Util.t(t,"number",LayeredDigraphVertex,"component"),this.fk=t)}get near(){return this.ck}set near(t){this.ck!==t&&(Debug&&t!==null&&Util.s(t,LayeredDigraphVertex,LayeredDigraphVertex,"near"),this.ck=t)}}class LayeredDigraphEdge extends LayoutEdge{ee;uk;dk;gk;mk;pk;yk;constructor(t){super(t),this.ee=!1,this.uk=!1,this.dk=!1,this.gk=NaN,this.mk=NaN,this.pk=0,this.yk=0}get fromVertex(){return this._e}set fromVertex(t){this._e!==t&&(Debug&&t!==null&&Util.s(t,LayeredDigraphVertex,LayeredDigraphEdge,"fromVertex"),this._e=t)}get toVertex(){return this.ts}set toVertex(t){this.ts!==t&&(Debug&&t!==null&&Util.s(t,LayeredDigraphVertex,LayeredDigraphEdge,"toVertex"),this.ts=t)}get valid(){return this.ee}set valid(t){this.ee!==t&&(Util.t(t,"boolean",LayeredDigraphEdge,"valid"),this.ee=t)}get rev(){return this.uk}set rev(t){this.uk!==t&&(Util.t(t,"boolean",LayeredDigraphEdge,"rev"),this.uk=t)}get forest(){return this.dk}set forest(t){this.dk!==t&&(Util.t(t,"boolean",LayeredDigraphEdge,"forest"),this.dk=t)}get portFromPos(){return this.gk}set portFromPos(t){this.gk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portFromPos"),this.gk=t)}get portToPos(){return this.mk}set portToPos(t){this.mk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portToPos"),this.mk=t)}get portFromColOffset(){return this.pk}set portFromColOffset(t){this.pk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portFromColOffset"),this.pk=t)}get portToColOffset(){return this.yk}set portToColOffset(t){this.yk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portToColOffset"),this.yk=t)}}var TreePath=(w=>(w[w.Default=0]="Default",w[w.Destination=1]="Destination",w[w.Source=2]="Source",w))(TreePath||{}),TreeSorting=(w=>(w[w.Forwards=10]="Forwards",w[w.Reverse=11]="Reverse",w[w.Ascending=12]="Ascending",w[w.Descending=13]="Descending",w))(TreeSorting||{}),TreeAlignment=(w=>(w[w.CenterSubtrees=20]="CenterSubtrees",w[w.CenterChildren=21]="CenterChildren",w[w.Start=22]="Start",w[w.End=23]="End",w[w.Bus=24]="Bus",w[w.BusBranching=25]="BusBranching",w[w.TopLeftBus=26]="TopLeftBus",w[w.BottomRightBus=27]="BottomRightBus",w[w.Custom=28]="Custom",w))(TreeAlignment||{}),TreeCompaction=(w=>(w[w.None=30]="None",w[w.Block=31]="Block",w))(TreeCompaction||{}),TreeStyle=(w=>(w[w.Layered=40]="Layered",w[w.LastParents=41]="LastParents",w[w.Alternating=42]="Alternating",w[w.RootOnly=43]="RootOnly",w))(TreeStyle||{}),TreeArrangement=(w=>(w[w.Vertical=50]="Vertical",w[w.Horizontal=51]="Horizontal",w[w.FixedRoots=52]="FixedRoots",w))(TreeArrangement||{}),TreeLayerStyle=(w=>(w[w.Individual=60]="Individual",w[w.Siblings=61]="Siblings",w[w.Uniform=62]="Uniform",w))(TreeLayerStyle||{});class TreeLayout extends Layout{Ei;Ii;ou;Vg;WN;Ve;qi;Cs;K;U;wk;ds;constructor(t){super(),this.Ei=new GSet,this.Ii=0,this.ds=1,this.ou=40,this.Vg=60,this.WN=[],this.Ve=!0,this.qi=50,this.Cs=new Size(10,10).w();const i=new TreeNetwork(this);this.K=new TreeVertex(i),this.U=new TreeVertex(i),this.wk=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Ii=this.Ii,t.ou=this.ou,t.Vg=this.Vg,t.Ve=this.Ve,t.qi=this.qi,t.Cs.c(this.Cs),t.K.copyInheritedPropertiesFrom(this.K),t.U.copyInheritedPropertiesFrom(this.U)}fi(t){t in TreeAlignment?this.alignment=t:t in TreeArrangement?this.arrangement=t:t in TreeCompaction?this.compaction=t:t in TreePath?this.path=t:t in TreeSorting?this.sorting=t:t in TreeStyle?this.treeStyle=t:super.fi(t)}createNetwork(){return new TreeNetwork(this)}makeNetwork(t){const i=this.createNetwork(),e=s=>{if(s instanceof Node)return!s.isLinkLabel&&s.category!=="Comment";if(s instanceof Link){const n=s.fromNode;if(n===null||n.isLinkLabel||n.category==="Comment")return!1;const o=s.toNode;return!(o===null||o.isLinkLabel||o.category==="Comment")}return!1};return t instanceof Diagram?(i.addParts(t.nodes,!0,e),i.addParts(t.links,!0,e)):t instanceof Group?i.addParts(t.memberParts,!1,e):i.addParts(t.iterator,!1,e),i}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.network===null&&(this.network=this.makeNetwork(t)),this.arrangement!==52&&(this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin));let i=this.diagram;i===null&&t instanceof Diagram&&(i=t),this.path===0&&i!==null?this.ds=i.isTreePathToChildren?1:2:this.ds=this.path===0?1:this.path,this.network.vertexes.count>0&&(this.O3(),this.E3(),this.B3(),this.V3(),this.YN(),this.z3(),this.arrangeTrees(),this.updateParts()),this.network=null,this.Ei=new GSet,this.isValidLayout=!0}O3(){this.network.deleteSelfEdges();const t=this.network.vertexes.iterator;for(;t.next();){const n=t.value;n.initialized=!1,n.level=0,n.parent=null,n.children=[]}if(this.Ei.count>0){const n=new GSet,o=this.Ei.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=this.network.findVertex(r);l!==null&&n.add(l)}else r instanceof TreeVertex&&n.add(r)}this.Ei=n}this.Ei.count===0&&this.findRoots();const i=this.Ei.copy().iterator;for(;i.next();){const n=i.value;n.initialized||(n.initialized=!0,this.vN(n))}let e=this.network.vertexes,s=null;for(;s=this.X3(e),s.count>0;){const n=this.SD(s);n!==null&&this.Ei.add(n),n.initialized=!0,this.vN(n),e=s}}X3(t){const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;s.initialized||i.add(s)}return i}findRoots(){const t=this.network.vertexes,i=t.iterator;for(;i.next();){const e=i.value;switch(this.ds){case 1:e.sourceEdges.count===0&&this.Ei.add(e);break;case 2:e.destinationEdges.count===0&&this.Ei.add(e);break;default:Util.n("Unhandled path value "+this.ds.toString())}}if(this.Ei.count===0){const e=this.SD(t);e!==null&&this.Ei.add(e)}}SD(t){let i=999999,e=null;const s=t.iterator;for(;s.next();){const n=s.value;switch(this.ds){case 1:n.sourceEdges.count0){const s=new List,n=t.destinationVertexes;for(;n.next();){const o=n.value;this.MD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;case 2:if(t.sourceEdges.count>0){const s=new List,n=t.sourceVertexes;for(;n.next();){const o=n.value;this.MD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;default:Util.n("Unhandled path value"+this.ds.toString())}const i=t.children,e=i.length;for(let s=0;st.level?!1:(this.K3(i.parent,i),!0):!0}Y3(t,i){if(i===null)return!1;Debug&&Util.s(t,TreeVertex,TreeLayout,"isAncestor:a"),Debug&&Util.s(i,TreeVertex,TreeLayout,"isAncestor:b");let e=i.parent;for(;e!==null&&e!==t;)e=e.parent;return e===t}K3(t,i){if(t===null||i===null)return;Debug&&Util.s(t,TreeVertex,TreeLayout,"removeChild:p"),Debug&&Util.s(i,TreeVertex,TreeLayout,"removeChild:c");const e=t.children;let s=0;for(let n=0;n0){const n=new Array(e.length-s);let o=0;for(let r=0;r0?s+1:0}U3(t){switch(Debug&&Util.s(t,TreeVertex,TreeLayout,"mom:v"),this.ou){default:case 40:return t.parent!==null?t.parent:this.K;case 43:return t.parent===null?this.K:t.parent.parent===null?this.U:t.parent;case 42:return t.parent!==null?t.parent.parent!==null?t.parent.parent:this.U:this.K;case 41:{let i=!0;if(t.childrenCount===0)i=!1;else{const e=t.children,s=e.length;for(let n=0;n0){i=!1;break}}return i&&t.parent!==null?this.U:t.parent!==null?t.parent:this.K}}}initializeTreeVertexValues(t){Debug&&Util.s(t,TreeVertex,TreeLayout,"initializeTreeVertexValues:v");const i=this.U3(t);if(t.copyInheritedPropertiesFrom(i),t.parent!==null&&t.parent.alignment===25){let e=t.angle;const s=t.parent.children;let n=0;for(;n135&&!l||a&&c)if(t.commentMargin>=0){g.e(t.bounds.x-t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleLeft,S.toSpot=Spot.MiddleRight}}else{g.e(t.bounds.x+t.focus.x*2-t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleRight,S.toSpot=Spot.MiddleLeft}}else if(t.commentMargin>=0){g.e(t.bounds.x+t.focus.x*2+t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleRight,S.toSpot=Spot.MiddleLeft}}else{g.e(t.bounds.x+t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleLeft,S.toSpot=Spot.MiddleRight}}t.commentSpacing>=0?u+=k.height+t.commentSpacing:u+=t.commentSpacing-k.height}else{if(o>135&&!l||!a&&c)if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y-t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleTop,S.toSpot=Spot.MiddleBottom}}else{g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2-t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleBottom,S.toSpot=Spot.MiddleTop}}else if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2+t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleBottom,S.toSpot=Spot.MiddleTop}}else{g.e(t.bounds.x+u,t.bounds.y+t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleTop,S.toSpot=Spot.MiddleBottom}}t.commentSpacing>=0?u+=k.width+t.commentSpacing:u+=t.commentSpacing-k.width}}Point.o(g);const p=u-t.commentSpacing-(h?e.height:e.width);if(this.ds===1){const y=t.destinationEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.fromEndSegmentLength=p>0?p:NaN)}}else{const y=t.sourceEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.toEndSegmentLength=p>0?p:NaN)}}}}z3(){if(this.layerStyle===62){const i=[];let e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;let n=s.parent;n===null&&(n=s);const o=n.angle===0||n.angle===180;let r=i[s.level];r===void 0&&(r=0),i[s.level]=Math.max(r,o?s.width:s.height)}for(let s=0;s=0)for(let o=0;o135&&n.reverse(),this.iw(r))if(o>1)for(let R=0;R0&&P>0&&M+u+O.width>f&&(M135?-b-g:b+g);const V=P===0?m:u;this.xk(I,0,A),I.X.e(M+V,A),k=Math.max(k,M+V+O.width),b=Math.max(b,S+(C===0?0:g)+O.height),M+=V+O.width}else{f>0&&P>0&&A+u+O.height>f&&(A135?-k-g:k+g);const V=P===0?m:u;this.xk(I,M,0),I.X.e(M,A+V),b=Math.max(b,A+V+O.height),k=Math.max(k,S+(C===0?0:g)+O.width),A+=V+O.height}P++}C>0&&(e?(b+=Math.max(0,c),M0&&(h||this.ru(t,p,0,0,o-1),k+=p)):(k+=Math.max(0,c),A0&&(h||this.ru(t,0,p,0,o-1),b+=p)));let D=0,F=0;switch(r){case 20:e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;break;default:case 21:if(C>0)e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;else{const I=o;if(e){const O=n[0].X.x+n[0].yt.x,V=n[I-1].X.x+n[I-1].yt.x+n[I-1].focus.x*2;D+=O+(V-O)/2-t.focus.x-d/2}else{const O=n[0].X.y+n[0].yt.y,V=n[I-1].X.y+n[I-1].yt.y+n[I-1].focus.y*2;F+=O+(V-O)/2-t.focus.y-d/2}}break;case 22:e?(D-=d,k+=d):(F-=d,b+=d);break;case 23:e?(D+=k-t.width+d,k+=d):(F+=b-t.height+d,b+=d);break;case 24:case 25:e?o>1?D+=T+u/2-t.focus.x:D+=n[0].focus.x-t.focus.x+n[0].yt.x:o>1?F+=T+u/2-t.focus.y:F+=n[0].focus.y-t.focus.y+n[0].yt.y;break;case 26:e?D+=k+u/2-t.focus.x:F+=b+u/2-t.focus.y;break;case 27:break;case 28:const R=this.customAlignment(t,D,F,k,b);D=R[0],F=R[1],k=R[2],b=R[3];break}for(let R=0;R135?(a?-b:-I.kt.height)+I.yt.y-c:x+c+I.yt.y)):I.X.e(I.X.x+(i>135?(a?-k:-I.kt.width)+I.yt.x-c:y+c+I.yt.x),I.X.y+I.yt.y-F)}e?(k=this.ZN(t,k,D),D<0&&(D=0),i>135&&(F+=b+c),b=Math.max(Math.max(b,x),b+x+c)):(i>135&&(D+=k+c),k=Math.max(Math.max(k,y),k+y+c),b=this.$N(t,b,F),F<0&&(F=0)),t.yt.e(D,F),t.kt.e(k,b)}customAlignment(t,i,e,s,n){return[i,e,s,n]}LD(t,i,e,s,n,o){Debug&&Util.s(t,TreeVertex,TreeLayout,"layoutBusChildrenPosDir:v");const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.kt.width,o=p.kt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,f=this.orthoAngle(t)===90;let c=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.kt,k=c===0?0:h;if(f){const b=this.computeBusNodeSpacing(y)-l;y.X.e(e-(x.width+b),d+k),n=Math.max(n,x.width+b),o=Math.max(o,d+k+x.height),d+=k+x.height}else{const b=this.computeBusNodeSpacing(y)-l;y.X.e(u+k,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,u+k+x.width),u+=k+x.width}c++}c=0;const m=u,g=d;f?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.kt,x=this.computeBusLastRowSpacing(p,f?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(f){p.X.e(e+l/2-p.focus.x-p.yt.x,o+x);const k=e+l/2-p.focus.x-p.yt.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.max(g,d)+x+y.height),p.X.x<0&&(e=this.bk(t,p.X.x,!1,e,l))}else{p.X.e(n+x,e+l/2-p.focus.y-p.yt.y),n=Math.max(n,Math.max(m,u)+x+y.width);const k=e+l/2-p.focus.y-p.yt.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.X.y<0&&(e=this.bk(t,p.X.y,!0,e,l))}}return new Rect(e,0,n,o)}TD(t,i,e,s,n,o){Debug&&Util.s(t,TreeVertex,TreeLayout,"layoutBusChildrenNegDir:v");const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.kt.width,o=p.kt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,f=this.orthoAngle(t)===270;let c=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.kt,k=c===0?0:h;if(f){const b=this.computeBusNodeSpacing(y)-l;d-=k+x.height,y.X.e(e-(x.width+b),d),n=Math.max(n,x.width+b),o=Math.max(o,Math.abs(d))}else{const b=this.computeBusNodeSpacing(y)-l;u-=k+x.width,y.X.e(u,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,Math.abs(u))}c++}c=0;const m=u,g=d;f?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.kt,x=this.computeBusLastRowSpacing(p,f?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(f){p.X.e(e+l/2-p.focus.x-p.yt.x,-o-y.height-x);const k=e+l/2-p.focus.x-p.yt.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.abs(Math.min(g,d))+x+y.height),p.X.x<0&&(e=this.bk(t,p.X.x,!1,e,l))}else{p.X.e(-n-y.width-x,e+l/2-p.focus.y-p.yt.y),n=Math.max(n,Math.abs(Math.min(m,u))+x+y.width);const k=e+l/2-p.focus.y-p.yt.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.X.y<0&&(e=this.bk(t,p.X.y,!0,e,l))}}for(let p=0;ps&&(s=e+t.width),e<0&&(s-=e),s;case 22:return t.width>i?t.width:i;case 23:return t.focus.x*2>i?t.width:i+t.width-t.focus.x*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.width);return Math.max(t.width,o-n);case 26:return t.width-t.focus.x+t.nodeSpacing/2+i;case 27:return Math.max(t.width,t.focus.x+t.nodeSpacing/2+i);default:return i}}$N(t,i,e){switch(Debug&&Util.s(t,TreeVertex,TreeLayout,"calculateSubheight:v"),t.alignment){case 21:case 20:let s=i;return e+t.height>s&&(s=e+t.height),e<0&&(s-=e),s;case 22:return t.height>i?t.height:i;case 23:return t.focus.y*2>i?t.height:i+t.height-t.focus.y*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.height);return Math.max(t.height,o-n);case 26:return t.height-t.focus.y+t.nodeSpacing/2+i;case 27:return Math.max(t.height,t.focus.y+t.nodeSpacing/2+i);default:return i}}QN(t,i,e){switch(Debug&&Util.tt(t,TreeAlignment,"TreeAlignment"),t){case 20:i/=2,e/=2;break;case 21:i/=2,e/=2;break;case 22:i=0,e=0;break;case 23:break;default:Util.n("Unhandled alignment value "+t.toString())}return new Point(i,e)}rf(t,i,e,s,n,o){Debug&&Util.s(t,TreeVertex,TreeLayout,"shiftRelPosAlign:v"),Debug&&Util.tt(i,TreeAlignment,"TreeAlignment");const r=this.QN(i,e,s);this.ru(t,r.x,r.y,n,o)}ru(t,i,e,s,n){if(Debug&&Util.s(t,TreeVertex,TreeLayout,"shiftRelPos:v"),i===0&&e===0)return;const o=t.children;for(let r=s;r<=n;r++){const h=o[r].X;h.x+=i,h.y+=e}}xk(t,i,e){Debug&&(Util.s(t,TreeVertex,TreeLayout,"recordMidPoints:v"),Util.t(i,"number",TreeLayout,"recordMidPoints:x"),Util.t(e,"number",TreeLayout,"recordMidPoints:y"));const s=t.parent;switch(this.ds){case 1:{const n=t.sourceEdges;for(;n.next();){const o=n.value;o.fromVertex===s&&o.relativePoint.e(i,e)}break}case 2:{const n=t.destinationEdges;for(;n.next();){const o=n.value;o.toVertex===s&&o.relativePoint.e(i,e)}break}default:Util.n("Unhandled path value "+this.ds.toString())}}G3(t){if(Debug&&Util.s(t,TreeVertex,TreeLayout,"layoutTreeBlock:v"),t.childrenCount===0){const z=t.parent;let G=!1,q=0,j=21;z!==null&&(q=z.angle,j=z.alignment,G=this.isBusAlignment(j));const J=this.JN(t);t.X.e(0,0),t.kt.e(t.width,t.height),t.parent!==null&&t.comments!==null&&((q===180||q===270)&&!G||J)?q===180&&!G||(q===90||q===270)&&J?t.yt.e(t.width-t.focus.x*2,0):t.yt.e(0,t.height-t.focus.y*2):t.yt.e(0,0),t.zg=null,t.Xg=null;return}const i=this.orthoAngle(t),e=i===90||i===270;let s=0;const n=t.children,o=n.length;for(let z=0;z135&&n.reverse(),this.iw(r))if(o>1)for(let z=0;z0&&L>0&&P+u+q.width>f&&(P135?-k-m:k+m),this.xk(G,0,N);let j=0;if(L===0)S=G.zg,M=G.Xg,A=q.width,C=q.height,(S===null||M===null||i!==this.orthoAngle(G))&&(S=this.ge(2),M=this.ge(2),S[0].e(0,0),S[1].e(0,C),M[0].e(A,0),M[1].e(A,C));else{const J=Util.at(),Y=this.DD(t,G,S,M,A,C,J);j=Y.x,S=J[0],M=J[1],A=Y.width,C=Y.height,Util.nt(J),P0&&L>0&&N+u+q.height>f&&(N135?-x-m:x+m),this.xk(G,P,0);let j=0;if(L===0)S=G.zg,M=G.Xg,A=q.width,C=q.height,(S===null||M===null||i!==this.orthoAngle(G))&&(S=this.ge(2),M=this.ge(2),S[0].e(0,0),S[1].e(A,0),M[0].e(0,C),M[1].e(A,C));else{const J=Util.at(),Y=this.DD(t,G,S,M,A,C,J);j=Y.x,S=J[0],M=J[1],A=Y.width,C=Y.height,Util.nt(J),N0&&(e?(k+=Math.max(0,c),P0&&(h||this.ru(t,g,0,0,o-1),x+=g)):(x+=Math.max(0,c),N0&&(h||this.ru(t,0,g,0,o-1),k+=g)));let I=0,O=0;switch(r){case 20:e?I+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;break;default:case 21:if(T>0)e?I+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;else{const G=o;if(e){const q=n[0].X.x+n[0].yt.x,j=n[G-1].X.x+n[G-1].yt.x+n[G-1].focus.x*2;I+=q+(j-q)/2-t.focus.x-d/2}else{const q=n[0].X.y+n[0].yt.y,j=n[G-1].X.y+n[G-1].yt.y+n[G-1].focus.y*2;O+=q+(j-q)/2-t.focus.y-d/2}}break;case 22:e?(I-=d,x+=d):(O-=d,k+=d);break;case 23:e?(I+=x-t.width+d,x+=d):(O+=k-t.height+d,k+=d);break;case 24:e?o>1?I+=F+u/2-t.focus.x:I+=n[0].focus.x-t.focus.x+n[0].yt.x:o>1?O+=F+u/2-t.focus.y:O+=n[0].focus.y-t.focus.y+n[0].yt.y;break;case 26:e?I+=x+u/2-t.focus.x:O+=k+u/2-t.focus.y;break;case 27:break;case 28:const z=this.customAlignment(t,I,O,x,k);I=z[0],O=z[1],x=z[2],k=z[3];break}for(let z=0;z135?(a?-k:-G.kt.height)+G.yt.y-c:y+c+G.yt.y)):G.X.e(G.X.x+(i>135?(a?-x:-G.kt.width)+G.yt.x-c:p+c+G.yt.x),G.X.y+G.yt.y-O)}let V=0,K=0;if(a)e?(x=this.ZN(t,x,I),I<0&&(I=0),i>135&&(O+=k+c),k+=y+c,r===27&&(V+=u/2+t.focus.x),K+=y+c):(i>135&&(I+=x+c),x+=p+c,k=this.$N(t,k,O),O<0&&(O=0),r===27&&(K+=u/2+t.focus.y),V+=p+c);else if(e){if(t.comments===null){if(p>x){const z=this.QN(r,p-x,0);V=z.x,K=z.y,x=p,I=0}}else x=this.ZN(t,x,I);I<0&&(V-=I,I=0),i>135&&(O+=k+c),k=Math.max(Math.max(k,y),k+y+c),K+=y+c}else{if(i>135&&(I+=x+c),x=Math.max(Math.max(x,p),x+p+c),t.comments===null){if(y>k){const z=this.QN(r,0,y-k);V=z.x,K=z.y,k=y,O=0}}else k=this.$N(t,k,O);O<0&&(K-=O,O=0),V+=p+c}let B,X;if(T>0)B=this.ge(4),X=this.ge(4),e?(B[2].e(0,y+c),B[3].e(B[2].x,k),X[2].e(x,B[2].y),X[3].e(X[2].x,B[3].y)):(B[2].e(p+c,0),B[3].e(x,B[2].y),X[2].e(B[2].x,k),X[3].e(B[3].x,X[2].y));else{B=this.ge(S.length+2),X=this.ge(M.length+2);for(let z=0;zB[0].x?B[2].c(B[1]):B[1].c(B[2])),B[3].yB[0].x?B[3].c(B[2]):B[2].c(B[3])),X[0].e(I+p,0),X[1].e(X[0].x,y),X[2].yB[0].y?B[2].c(B[1]):B[1].c(B[2])),B[3].xB[0].y?B[3].c(B[2]):B[2].c(B[3])),X[0].e(0,O+y),X[1].e(p,X[0].y),X[2].xl;){const a=i[o++];s[r++].e(a.x,a.y+e)}const h=this.ge(r);for(n=0;nl;){const a=i[o++];s[r++].e(a.x+e,a.y)}const h=this.ge(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.ge(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.ge(r);for(n=0;nh&&r.xr.x&&ha&&r.yr.y&&a0){const n=Math.min(1,t.layerSpacingParentOverlap);s-=e?t.height*n:t.width*n}return s<(e?-t.height:-t.width)&&(s=e?-t.height:-t.width),s}computeNodeIndent(t){Debug&&Util.s(t,TreeVertex,TreeLayout,"computeNodeIndent:v");const i=this.orthoAngle(t),e=i===90||i===270;let s=t.nodeIndent;if(t.nodeIndentPastParent>0){const n=Math.min(1,t.nodeIndentPastParent);s+=e?t.width*n:t.height*n}return s=Math.max(0,s),s}get roots(){return this.Ei}set roots(t){this.Ei!==t&&(Util.s(t,GSet,TreeLayout,"roots"),this.Ei=t,this.invalidateLayout())}get path(){return this.Ii}set path(t){this.Ii!==t&&(Util.tt(t,TreePath,"TreePath"),this.Ii=t,this.invalidateLayout())}get treeStyle(){return this.ou}set treeStyle(t){this.ou!==t&&(Util.tt(t,TreeStyle,"TreeStyle"),(t===40||t===42||t===41||t===43)&&(this.ou=t,this.invalidateLayout()))}get layerStyle(){return this.Vg}set layerStyle(t){this.Vg!==t&&(Util.tt(t,TreeLayerStyle,"TreeLayerStyle"),(t===60||t===61||t===62)&&(this.Vg=t,this.invalidateLayout()))}get comments(){return this.Ve}set comments(t){this.Ve!==t&&(Util.t(t,"boolean",TreeLayout,"comments"),this.Ve=t,this.invalidateLayout())}get arrangement(){return this.qi}set arrangement(t){this.qi!==t&&(Util.tt(t,TreeArrangement,"TreeArrangement"),(t===50||t===51||t===52)&&(this.qi=t,this.invalidateLayout()))}get arrangementSpacing(){return this.Cs}set arrangementSpacing(t){Util.s(t,Size,TreeLayout,"arrangementSpacing"),this.Cs.equals(t)||(this.Cs.c(t),this.invalidateLayout())}get rootDefaults(){return this.K}set rootDefaults(t){this.K!==t&&(Util.s(t,TreeVertex,TreeLayout,"rootDefaults"),this.K=t,this.invalidateLayout())}get alternateDefaults(){return this.U}set alternateDefaults(t){this.U!==t&&(Util.s(t,TreeVertex,TreeLayout,"alternateDefaults"),this.U=t,this.invalidateLayout())}get sorting(){return this.K.sorting}set sorting(t){this.K.sorting!==t&&(Util.tt(t,TreeSorting,"TreeSorting"),this.K.sorting=t,this.invalidateLayout())}get comparer(){return this.K.comparer}set comparer(t){this.K.comparer!==t&&(Util.t(t,"function",TreeLayout,"comparer"),this.K.comparer=t,this.invalidateLayout())}get angle(){return this.K.angle}set angle(t){this.K.angle!==t&&(Util.t(t,"number",TreeLayout,"angle"),t===0||t===90||t===180||t===270?(this.K.angle=t,this.invalidateLayout()):Util.n("TreeLayout.angle must be 0, 90, 180, or 270"))}get alignment(){return this.K.alignment}set alignment(t){this.K.alignment!==t&&(Util.tt(t,TreeAlignment,"TreeAlignment"),this.K.alignment=t,this.invalidateLayout())}get nodeIndent(){return this.K.nodeIndent}set nodeIndent(t){this.K.nodeIndent!==t&&(Util.t(t,"number",TreeLayout,"nodeIndent"),t>=0&&(this.K.nodeIndent=t,this.invalidateLayout()))}get nodeIndentPastParent(){return this.K.nodeIndentPastParent}set nodeIndentPastParent(t){this.K.nodeIndentPastParent!==t&&(Util.t(t,"number",TreeLayout,"nodeIndentPastParent"),t>=0&&t<=1&&(this.K.nodeIndentPastParent=t,this.invalidateLayout()))}get nodeSpacing(){return this.K.nodeSpacing}set nodeSpacing(t){this.K.nodeSpacing!==t&&(Util.t(t,"number",TreeLayout,"nodeSpacing"),this.K.nodeSpacing=t,this.invalidateLayout())}get layerSpacing(){return this.K.layerSpacing}set layerSpacing(t){this.K.layerSpacing!==t&&(Util.t(t,"number",TreeLayout,"layerSpacing"),this.K.layerSpacing=t,this.invalidateLayout())}get layerSpacingParentOverlap(){return this.K.layerSpacingParentOverlap}set layerSpacingParentOverlap(t){this.K.layerSpacingParentOverlap!==t&&(Util.t(t,"number",TreeLayout,"layerSpacingParentOverlap"),t>=0&&t<=1&&(this.K.layerSpacingParentOverlap=t,this.invalidateLayout()))}get compaction(){return this.K.compaction}set compaction(t){this.K.compaction!==t&&(Util.tt(t,TreeCompaction,"TreeCompaction"),(t===30||t===31)&&(this.K.compaction=t,this.invalidateLayout()))}get breadthLimit(){return this.K.breadthLimit}set breadthLimit(t){this.K.breadthLimit!==t&&(Util.t(t,"number",TreeLayout,"breadthLimit"),t>=0&&(this.K.breadthLimit=t,this.invalidateLayout()))}get rowSpacing(){return this.K.rowSpacing}set rowSpacing(t){this.K.rowSpacing!==t&&(Util.t(t,"number",TreeLayout,"rowSpacing"),this.K.rowSpacing=t,this.invalidateLayout())}get rowIndent(){return this.K.rowIndent}set rowIndent(t){this.K.rowIndent!==t&&(Util.t(t,"number",TreeLayout,"rowIndent"),t>=0&&(this.K.rowIndent=t,this.invalidateLayout()))}get commentSpacing(){return this.K.commentSpacing}set commentSpacing(t){this.K.commentSpacing!==t&&(Util.t(t,"number",TreeLayout,"commentSpacing"),this.K.commentSpacing=t,this.invalidateLayout())}get commentMargin(){return this.K.commentMargin}set commentMargin(t){this.K.commentMargin!==t&&(Util.t(t,"number",TreeLayout,"commentMargin"),this.K.commentMargin=t,this.invalidateLayout())}get setsPortSpot(){return this.K.setsPortSpot}set setsPortSpot(t){this.K.setsPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"setsPortSpot"),this.K.setsPortSpot=t,this.invalidateLayout())}get portSpot(){return this.K.portSpot}set portSpot(t){Util.s(t,Spot,TreeLayout,"portSpot"),this.K.portSpot.equals(t)||(this.K.portSpot=t,this.invalidateLayout())}get setsChildPortSpot(){return this.K.setsChildPortSpot}set setsChildPortSpot(t){this.K.setsChildPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"setsChildPortSpot"),this.K.setsChildPortSpot=t,this.invalidateLayout())}get childPortSpot(){return this.K.childPortSpot}set childPortSpot(t){Util.s(t,Spot,TreeLayout,"childPortSpot"),this.K.childPortSpot.equals(t)||(this.K.childPortSpot=t,this.invalidateLayout())}get alternateSorting(){return this.U.sorting}set alternateSorting(t){this.U.sorting!==t&&(Util.tt(t,TreeSorting,"TreeSorting"),this.U.sorting=t,this.invalidateLayout())}get alternateComparer(){return this.U.comparer}set alternateComparer(t){this.U.comparer!==t&&(Util.t(t,"function",TreeLayout,"alternateComparer"),this.U.comparer=t,this.invalidateLayout())}get alternateAngle(){return this.U.angle}set alternateAngle(t){this.U.angle!==t&&(Util.t(t,"number",TreeLayout,"alternateAngle"),(t===0||t===90||t===180||t===270)&&(this.U.angle=t,this.invalidateLayout()))}get alternateAlignment(){return this.U.alignment}set alternateAlignment(t){this.U.alignment!==t&&(Util.tt(t,TreeAlignment,"TreeAlignment"),this.U.alignment=t,this.invalidateLayout())}get alternateNodeIndent(){return this.U.nodeIndent}set alternateNodeIndent(t){this.U.nodeIndent!==t&&(Util.t(t,"number",TreeLayout,"alternateNodeIndent"),t>=0&&(this.U.nodeIndent=t,this.invalidateLayout()))}get alternateNodeIndentPastParent(){return this.U.nodeIndentPastParent}set alternateNodeIndentPastParent(t){this.U.nodeIndentPastParent!==t&&(Util.t(t,"number",TreeLayout,"alternateNodeIndentPastParent"),t>=0&&t<=1&&(this.U.nodeIndentPastParent=t,this.invalidateLayout()))}get alternateNodeSpacing(){return this.U.nodeSpacing}set alternateNodeSpacing(t){this.U.nodeSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateNodeSpacing"),this.U.nodeSpacing=t,this.invalidateLayout())}get alternateLayerSpacing(){return this.U.layerSpacing}set alternateLayerSpacing(t){this.U.layerSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateLayerSpacing"),this.U.layerSpacing=t,this.invalidateLayout())}get alternateLayerSpacingParentOverlap(){return this.U.layerSpacingParentOverlap}set alternateLayerSpacingParentOverlap(t){this.U.layerSpacingParentOverlap!==t&&(Util.t(t,"number",TreeLayout,"alternateLayerSpacingParentOverlap"),t>=0&&t<=1&&(this.U.layerSpacingParentOverlap=t,this.invalidateLayout()))}get alternateCompaction(){return this.U.compaction}set alternateCompaction(t){this.U.compaction!==t&&(Util.tt(t,TreeCompaction,"TreeCompaction"),(t===30||t===31)&&(this.U.compaction=t,this.invalidateLayout()))}get alternateBreadthLimit(){return this.U.breadthLimit}set alternateBreadthLimit(t){this.U.breadthLimit!==t&&(Util.t(t,"number",TreeLayout,"alternateBreadthLimit"),t>=0&&(this.U.breadthLimit=t,this.invalidateLayout()))}get alternateRowSpacing(){return this.U.rowSpacing}set alternateRowSpacing(t){this.U.rowSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateRowSpacing"),this.U.rowSpacing=t,this.invalidateLayout())}get alternateRowIndent(){return this.U.rowIndent}set alternateRowIndent(t){this.U.rowIndent!==t&&(Util.t(t,"number",TreeLayout,"alternateRowIndent"),t>=0&&(this.U.rowIndent=t,this.invalidateLayout()))}get alternateCommentSpacing(){return this.U.commentSpacing}set alternateCommentSpacing(t){this.U.commentSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateCommentSpacing"),this.U.commentSpacing=t,this.invalidateLayout())}get alternateCommentMargin(){return this.U.commentMargin}set alternateCommentMargin(t){this.U.commentMargin!==t&&(Util.t(t,"number",TreeLayout,"alternateCommentMargin"),this.U.commentMargin=t,this.invalidateLayout())}get alternateSetsPortSpot(){return this.U.setsPortSpot}set alternateSetsPortSpot(t){this.U.setsPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"alternateSetsPortSpot"),this.U.setsPortSpot=t,this.invalidateLayout())}get alternatePortSpot(){return this.U.portSpot}set alternatePortSpot(t){Util.s(t,Spot,TreeLayout,"alternatePortSpot"),this.U.portSpot.equals(t)||(this.U.portSpot=t,this.invalidateLayout())}get alternateSetsChildPortSpot(){return this.U.setsChildPortSpot}set alternateSetsChildPortSpot(t){this.U.setsChildPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"alternateSetsChildPortSpot"),this.U.setsChildPortSpot=t,this.invalidateLayout())}get alternateChildPortSpot(){return this.U.childPortSpot}set alternateChildPortSpot(t){Util.s(t,Spot,TreeLayout,"alternateChildPortSpot"),this.U.childPortSpot.equals(t)||(this.U.childPortSpot=t,this.invalidateLayout())}static PathDefault=0;static PathDestination=1;static PathSource=2;static SortingForwards=10;static SortingReverse=11;static SortingAscending=12;static SortingDescending=13;static AlignmentCenterSubtrees=20;static AlignmentCenterChildren=21;static AlignmentStart=22;static AlignmentEnd=23;static AlignmentBus=24;static AlignmentBusBranching=25;static AlignmentTopLeftBus=26;static AlignmentBottomRightBus=27;static CompactionNone=30;static CompactionBlock=31;static StyleLayered=40;static StyleLastParents=41;static StyleAlternating=42;static StyleRootOnly=43;static ArrangementVertical=50;static ArrangementHorizontal=51;static ArrangementFixedRoots=52;static LayerIndividual=60;static LayerSiblings=61;static LayerUniform=62}class TreeNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new TreeVertex(this)}createEdge(){return new TreeEdge(this)}}class TreeVertex extends LayoutVertex{X;kt;yt;Sk;Mk;Pk;Nk;Ck;Ak;Lk;Ve;zg;Xg;ke;Se;jt;ai;ew;sw;nw;As;ow;rw;lw;hw;aw;fw;cw;uw;dw;gw;mw;constructor(t){super(t),this.Sk=!1,this.Mk=null,this.Pk=[],this.Nk=0,this.Ck=0,this.Ak=0,this.Lk=0,this.Ve=null,this.X=new Point(0,0),this.kt=new Size(0,0),this.yt=new Point(0,0),this.zg=null,this.Xg=null,this.ke=10,this.Se=LayoutVertex.standardComparer,this.jt=0,this.ai=21,this.ew=0,this.sw=0,this.nw=20,this.As=50,this.ow=0,this.rw=31,this.lw=0,this.hw=25,this.aw=10,this.fw=10,this.cw=20,this.uw=!0,this.dw=Spot.Default,this.gw=!0,this.mw=Spot.Default}copyInheritedPropertiesFrom(t){t!==null&&(this.ke=t.sorting,this.Se=t.comparer,this.jt=t.angle,this.ai=t.alignment,this.ew=t.nodeIndent,this.sw=t.nodeIndentPastParent,this.nw=t.nodeSpacing,this.As=t.layerSpacing,this.ow=t.layerSpacingParentOverlap,this.rw=t.compaction,this.lw=t.breadthLimit,this.hw=t.rowSpacing,this.aw=t.rowIndent,this.fw=t.commentSpacing,this.cw=t.commentMargin,this.uw=t.setsPortSpot,this.dw=t.portSpot,this.gw=t.setsChildPortSpot,this.mw=t.childPortSpot)}get initialized(){return this.Sk}set initialized(t){this.Sk!==t&&(Util.t(t,"boolean",TreeVertex,"initialized"),this.Sk=t)}get parent(){return this.Mk}set parent(t){this.Mk!==t&&(Debug&&t!==null&&Util.s(t,TreeVertex,TreeVertex,"parent"),this.Mk=t)}get children(){return this.Pk}set children(t){if(this.Pk!==t){if(t!==null&&!Array.isArray(t)&&Util.Bi(t,"Array",TreeVertex,"children:value"),t!==null){const i=t.length;for(let e=0;e4;)t.removePoint(2);u=t.getPoint(1),d=t.getPoint(2)}else{for(c=1;t.pointsCount>3;)t.removePoint(1);u=t.getPoint(0),d=t.getPoint(t.pointsCount-1)}const m=t.getPoint(t.pointsCount-1);let g=0;r===0?(e.alignment===23?(g=o.bottom+n.y,n.y===0&&u.y>m.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.xm.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.x{const i=t.matches?"dark":"light";i!==this.Yg&&(this.Yg=i,this.Fk==="system"&&this.pw())};constructor(t){t&&Object.assign(this,t),t?.themeMap||(this.lu.set("light",{colors:{...Themes.Light.colors},fonts:{...Themes.Light.fonts},numbers:{...Themes.Light.numbers},margins:{...Themes.Light.margins},arrowheads:{...Themes.Light.arrowheads}}),this.lu.set("dark",{colors:{...Themes.Dark.colors},fonts:{...Themes.Dark.fonts},numbers:{...Themes.Dark.numbers},margins:{...Themes.Dark.margins},arrowheads:{...Themes.Dark.arrowheads}})),root.matchMedia&&(this.Yg=root.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}get themeMap(){return this.lu}set themeMap(t){this.lu!==t&&(this.lu=t,this.pw())}get defaultTheme(){return this.Dk}set defaultTheme(t){this.Dk!==t&&(Util.t(t,"string",ThemeManager,"defaultTheme"),this.Dk=t,this.pw())}get currentTheme(){return this.Fk}set currentTheme(t){this.Fk!==t&&(Util.t(t,"string",ThemeManager,"currentTheme"),this.Fk=t,this.pw())}get changesDivBackground(){return this.Rk}set changesDivBackground(t){if(this.Rk!==t&&(this.Rk=t,t))for(const e of this.ls)e.setDivBackground(this.findValue("div","","fill")),e.B("ThemeChanged",this)}get preferredColorScheme(){return this.Yg}addDiagram(t){return this.ls.add(t),this.tC(t),this}removeDiagram(t){return this.ls.delete(t),this.tC(t),this}WF(){this.ls.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.addEventListener("change",this.RD)}vF(){this.ls.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.removeEventListener("change",this.RD)}set(t,i){t===""&&(t=this.Dk),t==="system"&&(t=this.Yg);let e=this.lu.get(t);return e?e=this.ID(e,i):e=i,this.lu.set(t,e),this.pw(),this}findValue(t,i,e){return this.getValue(this.findTheme(this.currentTheme),t,i,e)||this.getValue(this.findTheme(this.defaultTheme),t,i,e)}getValue(t,i,e,s){if(!t)return;e==null&&(e="");let n=t;const o=l=>{if(n===void 0||l==="")return;if(typeof l=="number"||!(Array.isArray(l)||l.includes(".")))return n[l];const h=Array.isArray(l)?l:l.split(".");for(let a=0;a{if(!(e!==""&&(n=o(e),n===void 0)))return Array.isArray(n)&&typeof i=="number"?n=n[i%n.length]:n=o(i),n};if(n=r(),n===void 0&&typeof s=="string"&&s.length>0){let l=t.targetPropertyMap?.get(s);if(l?n=t[l]:(l=ThemeManager.Q3.get(s),n=l?t[l]:t.colors),n=r(),n!==void 0)return n}return n}findTheme(t){return this.themeMap.get(t==="system"?this.Yg:t)}tC(t){const i=t.skipsUndoManager;t.skipsUndoManager=!0,t.updateAllThemeBindings(),this.Rk&&t.setDivBackground(this.findValue("div","","fill")),t.skipsUndoManager=i,t.B("ThemeChanged",this)}pw(){for(const t of this.ls)this.tC(t)}ID(t,i){for(const e in i)if(Util.yw(i,e))try{i[e].constructor===Object?t[e]=this.ID(t[e]??{},i[e]):t[e]=i[e]}catch{delete t[e]}return t}static Q3=new Map([["background","colors"],["defaultColumnSeparatorStroke","colors"],["defaultRowSeparatorStroke","colors"],["shadowColor","colors"],["fill","colors"],["stroke","colors"],["font","fonts"],["angle","numbers"],["fromEndSegmentLength","numbers"],["fromShortLength","numbers"],["height","numbers"],["opacity","numbers"],["scale","numbers"],["toEndSegmentLength","numbers"],["toShortLength","numbers"],["width","numbers"],["defaultColumnSeparatorStrokeWidth","numbers"],["defaultRowSeparatorStrokeWidth","numbers"],["shadowBlur","numbers"],["corner","numbers"],["curviness","numbers"],["smoothness","numbers"],["parameter1","numbers"],["parameter2","numbers"],["strokeWidth","numbers"],["strokeDashOffset","numbers"],["maxLines","numbers"],["spacingAbove","numbers"],["spacingBelow","numbers"],["position","points"],["shadowOffset","points"],["desiredSize","sizes"],["maxSize","sizes"],["minSize","sizes"],["margin","margins"],["defaultSeparatorPadding","margins"],["padding","margins"],["alignment","spots"],["alignmentFocus","spots"],["fromSpot","spots"],["toSpot","spots"],["defaultAlignment","spots"],["spot1","spots"],["spot2","spots"],["verticalAlignment","spots"],["imageAlignment","spots"],["fromArrow","arrowheads"],["toArrow","arrowheads"]])}class Router{Tt;b;Xi;pl;constructor(){this.b=Diagram.Sm(),this.Tt="",this.Xi=!0,this.pl=!0}get name(){return this.Tt}set name(t){this.Tt=t}get isEnabled(){return this.Xi}set isEnabled(t){this.Xi=t}get isRealtime(){return this.pl}set isRealtime(t){this.pl=t}get diagram(){return this.b}set diagram(t){this.b!==t&&(this.b=t,t.Pl=!0,t.requestUpdate())}invalidateRouter(){this.b!==null&&(this.b.Pl=!0,this.b.requestUpdate())}canRoute(t){if(!this.isEnabled)return!1;const i=this.diagram;return!(i&&(!this.isRealtime&&i.Mu||i.animationManager.isTicking))}routeLinks(t,i){}toString(){return this.name!==""?this.name+" Router":Util.hn(this.constructor)}}class AvoidsNodesRouter extends Router{constructor(t){super(),this.name="AvoidsNodes",t&&Object.assign(this,t)}canRoute(t){return(t instanceof Diagram?t.Zm:t.diagram.Zm)?super.canRoute(t):!1}routeLinks(t,i){i=i instanceof Diagram?null:i;const e=t.iterator,s=this.diagram.getPositions(!0,i,null);for(;e.next();){const n=e.value;if(!n.isAvoiding||i&&n.containingGroup!==i||n.toNode===null||n.fromNode===null||n.pointsCount<4)continue;n.startRoute();const o=n.pointsCount,r=n.getPoint(1),l=n.getPoint(o-2),h=n.fromNode.actualBounds.copy();h.inflate(Link.Xa,Link.Xa),h.unionPoint(n.getPoint(0));const a=n.toNode.actualBounds.copy();a.inflate(Link.Xa,Link.Xa),a.unionPoint(n.getPoint(o-1)),this._3(n,h,a,s)&&this.tE(n,r,n.aN,l,n.fN,h,a,s),n.commitRoute()}}_3(t,i,e,s){const n=t.diagram,o=t.pointsCount;if(n===null||t.fromNode===t.toNode||t.layer.isTemporary||i.containsPoint(t.getPoint(o-1))&&!t.toNode.isMemberOf(t.fromNode)||e.containsPoint(t.getPoint(0))&&!t.fromNode.isMemberOf(t.toNode)||!t.isOrthogonal)return!1;if(t.segmentIndex===17)return!0;const r=t.getPoint(1),l=t.getPoint(o-2),h=t.getPoint(2);if(!s.isUnoccupied(Math.min(r.x,h.x),Math.min(r.y,h.y),Math.abs(r.x-h.x),Math.abs(r.y-h.y)))return!0;for(let f=2;f=PositionArray.Hd&&(l.WA(),d.inflate(l.cellWidth*l.KP,l.cellHeight*l.UP),l.mT(i,e,s,n,d,!1),m=l.wo(s.x,s.y)),!l.Cy&&mPositionArray.Ga&&i.wo(g,p)!==u-1&&(i.wo(d-f,m)===u-1?(n=180,g=d-f,p=m):i.wo(d+f,m)===u-1?(n=0,g=d+f,p=m):i.wo(d,m-c)===u-1?(n=270,g=d,p=m-c):i.wo(d,m+c)===u-1&&(n=90,g=d,p=m+c));u>PositionArray.Ga&&i.wo(g,p)===u-1;)d=g,m=p,n===0?g+=f:n===90?p+=c:n===180?g-=f:p-=c,u-=1;if(o?u>PositionArray.Ga&&(n===180||n===0?d=Math.floor(d/f)*f+f/2:(n===90||n===270)&&(m=Math.floor(m/c)*c+c/2)):(d=Math.floor(d/f)*f+f/2,m=Math.floor(m/c)*c+c/2),u>PositionArray.Ga){let y=n,x=d,k=m;if(n===0?(y=90,k+=c):n===90?(y=180,x-=f):n===180?(y=270,k-=c):n===270&&(y=0,x+=f),i.wo(x,k)===u-1)this.iC(t,i,x,k,y,!1);else{let S=d,M=m;n===0?(y=270,M-=c):n===90?(y=0,S+=f):n===180?(y=90,M+=c):n===270&&(y=180,S-=f),i.wo(S,M)===u-1&&this.iC(t,i,S,M,y,!1)}}t.insertPointAt(t.pointsCount-2,d,m)}}ToolManager.prototype.initializeStandardTools=function(){this.ti("Action",new ActionTool,this.mouseDownTools),this.ti("Relinking",new RelinkingTool,this.mouseDownTools),this.ti("LinkReshaping",new LinkReshapingTool,this.mouseDownTools),this.ti("Rotating",new RotatingTool,this.mouseDownTools),this.ti("Resizing",new ResizingTool,this.mouseDownTools),this.ti("Linking",new LinkingTool,this.mouseMoveTools),this.ti("Dragging",new DraggingTool,this.mouseMoveTools),this.ti("DragSelecting",new DragSelectingTool,this.mouseMoveTools),this.ti("Panning",new PanningTool,this.mouseMoveTools),this.ti("ContextMenu",new ContextMenuTool,this.mouseUpTools),this.ti("TextEditing",new TextEditingTool,this.mouseUpTools),this.ti("ClickCreating",new ClickCreatingTool,this.mouseUpTools),this.ti("ClickSelecting",new ClickSelectingTool,this.mouseUpTools)},Diagram.SP("GraphLinksModel",GraphLinksPartManager),Diagram.SP("TreeModel",TreePartManager);const oldGo=root.go,go={get version(){return Diagram.version},Group,List,Set:GSet,Map:GMap,Point,Size,Rect,Margin,Spot,Geometry,PathFigure,PathSegment,InputEvent,DiagramEvent,ChangedEvent,Model,GraphLinksModel,TreeModel,Binding,ThemeBinding,Transaction,UndoManager,CommandHandler,Tool,DraggingTool,DraggingInfo,DraggingOptions,LinkingBaseTool,LinkingTool,RelinkingTool,LinkReshapingTool,ResizingTool,RotatingTool,ClickSelectingTool,ActionTool,ClickCreatingTool,HTMLInfo,ContextMenuTool,DragSelectingTool,PanningTool,TextEditingTool,ToolManager,Animation,AnimationManager,AnimationTrigger,Layer,Diagram,Palette,Overview,Brush,GraphObject,Panel,RowColumnDefinition,Shape,TextBlock,Picture,Part,Adornment,Node,Link,Placeholder,Layout,LayoutNetwork,LayoutVertex,LayoutEdge,GridLayout,PanelLayout,CircularLayout,CircularNetwork,CircularVertex,CircularEdge,ForceDirectedLayout,ForceDirectedNetwork,ForceDirectedVertex,ForceDirectedEdge,LayeredDigraphLayout,LayeredDigraphNetwork,LayeredDigraphVertex,LayeredDigraphEdge,TreeLayout,TreeNetwork,TreeVertex,TreeEdge,Themes,ThemeManager,Router,AnimationStyle,AutoScale,CycleMode,Flip,TextFormat,ImageStretch,LayoutConditions,LinkAdjusting,Curve,Routing,Orientation,TextOverflow,PortSpreading,ScrollMode,CollapsePolicy,Sizing,TriggerStart,Stretch,ViewboxStretch,Wrap,BrushType,ColorSpace,GeometryStretch,GeometryType,SegmentType,BindingMode,ChangeType,CircularArrangement,CircularDirection,CircularNodeDiameterFormula,CircularSorting,GridAlignment,GridArrangement,GridSorting,LayeredDigraphAggressive,LayeredDigraphAlign,LayeredDigraphCycleRemove,LayeredDigraphInit,LayeredDigraphLayering,LayeredDigraphPack,TreeAlignment,TreeArrangement,TreeCompaction,TreeLayerStyle,TreePath,TreeSorting,TreeStyle,GestureMode,LinkingDirection,ReshapingBehavior,TextEditingAccept,TextEditingStarting,TextEditingState,WheelMode};typeof oldGo=="object"&&oldGo.version&&Util.ht("WARNING: a `go` object on the root object is already defined. "+("Debug"in oldGo?"debug ":"")+"version: "+oldGo.version+", replaced with version: "+go.version),Diagram.prototype.go=go,root.go=go,go.Debug=Debug,Debug.attachReadonlyWarnings(go); })(); diff --git a/release/go-debug.d.ts b/release/go-debug.d.ts index be8892351..26f5d35f7 100644 --- a/release/go-debug.d.ts +++ b/release/go-debug.d.ts @@ -1,5 +1,5 @@ /* - * Type definitions for GoJS v3.0.11 + * Type definitions for GoJS v3.0.12 * Project: https://gojs.net * Definitions by: Northwoods Software * Definitions: https://github.com/NorthwoodsSoftware/GoJS @@ -279,7 +279,7 @@ export interface IContext { strokeStyle: string | CanvasGradient | CanvasPattern | SGradient; textAlign: string; imageSmoothingEnabled: boolean; - clipInsteadOfFill: boolean; + /** Only true if a Spot panel has isClipping element */ clipInsteadOfFill: boolean; filter: string; commitTransform(): void; setImageSmoothingEnabled(smooth: boolean): void; @@ -321,6 +321,7 @@ export interface IContext { disableDash(): void; clearContextCache(clearFont: boolean): void; removePartFromView(p: GraphObject): void; + createOrUpdateClipGroup(panel: GraphObject, rect: Rect): void; } /** @@ -17086,7 +17087,7 @@ export abstract class GraphObject { *

              * See the Introduction page on building objects * for usage information and examples of GraphObject.make. - * @param type - a class function or the name of a class in the `go` namespace, + * @param cls - a class function or the name of a class in the `go` namespace, * or one of several predefined kinds of {@link Panel}s: `"Button"`, `"TreeExpanderButton"`, * `"SubGraphExpanderButton"`, or `"ContextMenuButton"`. * @param initializers - zero or more values that initialize the new object, @@ -17239,7 +17240,7 @@ export class Brush { * In addition to Brush properties, this object can also contain color stops in the format: * `{ 0: "#FEC901", 0.2: "#FFFFAA", 1: "#FEA200" }` */ - constructor(type?: BrushType | string, init?: Partial & Record<(number | string), string>>); + constructor(type?: BrushType | string, init?: Partial & Record); /** * Create a copy of this Brush with the same values. */ @@ -18466,8 +18467,9 @@ export class Panel extends GraphObject { set itemCategoryProperty(value: string | ((a: any) => string)); /** * For {@link Spot} Panels: Gets or sets whether this Panel's main element clips instead of fills. - * The main element will not paint its stroke, if it has any. * This assumes that the main element is a Shape. + * The main Shape element will not paint its stroke, if it has any, + * and should have its Shape.strokeWidth set to `0`. * * Since 2.2: For {@link Group}s: Gets or sets whether this Group's Placeholder clips its member nodes. * For compatibility, if the Group is a {@link Spot} Panel, it will not clip its members. @@ -31501,9 +31503,10 @@ export abstract class Router { * An override of this method should return `false` if {@link isEnabled} is false, or return `false` is if a call to the base method is `false`. * * This method is only called by the {@link Diagram}. If using a Router without adding it to a Diagram, this method will never be called. + * @param container A Diagram or Group on which the Router will operate. * @virtual */ - canRoute(coll: Diagram | Group): boolean; + canRoute(container: Diagram | Group): boolean; /** * Route the links for a given collection (Group or Diagram). By default this is called * in a depth-first manner on every Group in the Diagram, and then the Diagram itself. @@ -31519,24 +31522,24 @@ export abstract class Router { * and then the Diagram, you should check the {@link Part.containingGroup} on each Link to ensure it matches: * * ```ts - * public routeLinks(links: Set, coll?: Diagram | Group): void { - * const container = coll instanceof Diagram ? null : coll; + * public routeLinks(links: Set, container?: Diagram | Group): void { + * const container = container instanceof Diagram ? null : container; * const it = links.iterator; * while (it.next()) { * const link = it.value; * // Only operate on links that are in the corresponding collection, if one is given - * if (coll && link.containingGroup !== container) continue; + * if (container && link.containingGroup !== container) continue; * . . . * ``` * * This method should not check the {@link canRoute} predicate. * * @param links The set of links that were recently recomputed, which may need routing. - * @param coll A Diagram or Group on which the Router will operate. + * @param container A Diagram or Group on which the Router will operate. * When calling a router manually, this does not need to be specified. * @virtual */ - routeLinks(links: Set, coll?: Diagram | Group): void; + routeLinks(links: Set, container?: Diagram | Group): void; } /** * The AvoidsNodesRouter is a Router that will modify any Orthogonal {@link Link}s @@ -31562,16 +31565,16 @@ export class AvoidsNodesRouter extends Router { * Determine whether the AvoidsNodesRouter should operate on a given collection. * If no avoiding links are present in the collection, the router will not run. */ - canRoute(coll: Diagram | Group): boolean; + canRoute(container: Diagram | Group): boolean; /** * Route the links. * By default this is called in a depth-first manner on every Group in the Diagram, and then the Diagram itself. * If a layout is warranted for any Group or Diagram, this is called immediately afterwards. * * @param links The set of links that were recently recomputed, which may need routing. - * @param coll A Diagram or Group on which the Router will operate. + * @param container A Diagram or Group on which the Router will operate. */ - routeLinks(links: Set, coll?: Diagram | Group): void; + routeLinks(links: Set, container?: Diagram | Group): void; } diff --git a/release/go-debug.js b/release/go-debug.js index 9eb825ca5..8714f6caf 100644 --- a/release/go-debug.js +++ b/release/go-debug.js @@ -1,62 +1,62 @@ /* - * GoJS v3.0.11 JavaScript Library for HTML Diagrams, https://gojs.net + * GoJS v3.0.12 JavaScript Library for HTML Diagrams, https://gojs.net * GoJS and Northwoods Software are registered trademarks of Northwoods Software Corporation, https://nwoods.com. * Copyright (C) 1998-2024 by Northwoods Software Corporation. All Rights Reserved. - * THIS SOFTWARE IS LICENSED. THE LICENSE AGREEMENT IS AT: https://gojs.net/3.0.11/license.html. + * THIS SOFTWARE IS LICENSED. THE LICENSE AGREEMENT IS AT: https://gojs.net/3.0.12/license.html. * DO NOT MODIFY THIS FILE. DO NOT DISTRIBUTE A MODIFIED COPY OF THE CONTENTS OF THIS FILE. */ -(function() {const root=typeof globalThis=="object"&&globalThis||typeof global=="object"&&global.global===global&&global||typeof self=="object"&&self.self===self&&self||{};root.requestAnimationFrame===void 0&&(root.setImmediate===void 0?root.requestAnimationFrame=w=>root.setTimeout(w,0):root.requestAnimationFrame=root.setImmediate);const Debug={boundsInfoEnabled:!1,drawLocationsEnabled:!1,drawClipEnabled:!1,drawLinkpointsEnabled:!1,nodeInspector:!1,handleMessages:!1,drawFrames:!1,defaultDiagram:null,trace:function(w){root.console&&root.console.log(w)},drawDiagramBounds(w,t,i,e){w.strokeStyle="red",w.fillStyle="red",w.font="8px sans-serif",w.beginPath(),w.moveTo(-10,0),w.lineTo(10,0),w.moveTo(0,-10),w.lineTo(0,10),w.stroke(),w.setTransform(1,0,0,1,0,0),w.scale(i,i),w.transform(t.m11,t.m12,t.m21,t.m22,t.dx,t.dy),w.lineWidth=2,w.beginPath(),w.moveTo(e.left,e.top+20),w.lineTo(e.left,e.top),w.lineTo(e.left+20,e.top),w.moveTo(e.right,e.bottom-20),w.lineTo(e.right,e.bottom),w.lineTo(e.right-20,e.bottom),w.stroke(),w.fillText("DB: "+Math.round(e.x)+", "+Math.round(e.y)+", "+Math.round(e.width)+", "+Math.round(e.height),e.left,e.top-5)},attachReadonlyWarnings:function(w){for(const t in w){if(t==="licenseKey")continue;const i=w[t];if(i.prototype===void 0)continue;const e=Object.getOwnPropertyNames(i.prototype);for(let s=0;s{s=-1,e||t.apply(n,o)},i),e&&!s&&t.apply(n,o)}}static Bh(t,i){return root.setTimeout(t,i)}static Ug(t){root.clearTimeout(t)}static ln(t){return root.document.createElement(t)}static n(t){throw new Error(t)}static F(t,i){let e="The object is frozen, so its properties cannot be set: "+t.toString();i!==void 0&&(e+=" to value: "+i),Util.n(e)}static s(t,i,e,s){if(!(t instanceof i)){let n=Util.au(e);s!==void 0&&(n+="."+s),Util.Vi(t,i,n)}}static t(t,i,e,s){if(typeof t!==i){let n=Util.au(e);s!==void 0&&(n+="."+s),Util.Vi(t,i,n)}}static r(t,i,e){if(typeof t!="number"||!isFinite(t)){let s=Util.au(i);e!==void 0&&(s+="."+e),Util.n(s+" must be a real number type, and not NaN or Infinity: "+t)}}static tt(t,i,e){t in i||Util.n(`${t} is not a valid value in enumeration: ${e}`)}static Vi(t,i,e,s){const n=" value is not an instance of "+Util.au(i)+": ";let o=Util.au(e);s!==void 0&&(o+="."+s),typeof t=="string"&&(t='"'+t+'"'),Util.n(o+n+t)}static G(t,i,e,s){let n=Util.au(e);s!==void 0&&(n+="."+s),Util.n(n+" is not in the range "+i+": "+t)}static ze(t){Util.n("Collection was modified during iteration: "+t.toString()+` +(function() {const root=typeof globalThis=="object"&&globalThis||typeof global=="object"&&global.global===global&&global||typeof self=="object"&&self.self===self&&self||{};root.requestAnimationFrame===void 0&&(root.setImmediate===void 0?root.requestAnimationFrame=w=>root.setTimeout(w,0):root.requestAnimationFrame=root.setImmediate);const Debug={boundsInfoEnabled:!1,drawLocationsEnabled:!1,drawClipEnabled:!1,drawLinkpointsEnabled:!1,nodeInspector:!1,handleMessages:!1,drawFrames:!1,defaultDiagram:null,trace:function(w){root.console&&root.console.log(w)},drawDiagramBounds(w,t,i,e){w.strokeStyle="red",w.fillStyle="red",w.font="8px sans-serif",w.beginPath(),w.moveTo(-10,0),w.lineTo(10,0),w.moveTo(0,-10),w.lineTo(0,10),w.stroke(),w.setTransform(1,0,0,1,0,0),w.scale(i,i),w.transform(t.m11,t.m12,t.m21,t.m22,t.dx,t.dy),w.lineWidth=2,w.beginPath(),w.moveTo(e.left,e.top+20),w.lineTo(e.left,e.top),w.lineTo(e.left+20,e.top),w.moveTo(e.right,e.bottom-20),w.lineTo(e.right,e.bottom),w.lineTo(e.right-20,e.bottom),w.stroke(),w.fillText("DB: "+Math.round(e.x)+", "+Math.round(e.y)+", "+Math.round(e.width)+", "+Math.round(e.height),e.left,e.top-5)},attachReadonlyWarnings:function(w){for(const t in w){if(t==="licenseKey")continue;const i=w[t];if(i.prototype===void 0)continue;const e=Object.getOwnPropertyNames(i.prototype);for(let s=0;s{s=-1,e||t.apply(n,o)},i),e&&!s&&t.apply(n,o)}}static zh(t,i){return root.setTimeout(t,i)}static Kg(t){root.clearTimeout(t)}static ln(t){return root.document.createElement(t)}static n(t){throw new Error(t)}static F(t,i){let e="The object is frozen, so its properties cannot be set: "+t.toString();i!==void 0&&(e+=" to value: "+i),Util.n(e)}static s(t,i,e,s){if(!(t instanceof i)){let n=Util.hu(e);s!==void 0&&(n+="."+s),Util.Bi(t,i,n)}}static t(t,i,e,s){if(typeof t!==i){let n=Util.hu(e);s!==void 0&&(n+="."+s),Util.Bi(t,i,n)}}static r(t,i,e){if(typeof t!="number"||!isFinite(t)){let s=Util.hu(i);e!==void 0&&(s+="."+e),Util.n(s+" must be a real number type, and not NaN or Infinity: "+t)}}static tt(t,i,e){t in i||Util.n(`${t} is not a valid value in enumeration: ${e}`)}static Bi(t,i,e,s){const n=" value is not an instance of "+Util.hu(i)+": ";let o=Util.hu(e);s!==void 0&&(o+="."+s),typeof t=="string"&&(t='"'+t+'"'),Util.n(o+n+t)}static G(t,i,e,s){let n=Util.hu(e);s!==void 0&&(n+="."+s),Util.n(n+" is not in the range "+i+": "+t)}static ze(t){Util.n("Collection was modified during iteration: "+t.toString()+` Perhaps you should iterate over a copy of the collection, - or you could collect items to be removed from the collection after the iteration.`)}static ur(t,i){Util.n("No property to set for this enum value: "+i+" on "+t.toString())}static at(t){root.console&&root.console.log(t)}static Mt(t){return typeof t=="object"&&t!==null}static Gg(t,i,e){Array.isArray(t)||Util.Vi(t,"Array",i,e)}static fu(t,i,e){Array.isArray(t)?i>=t.length?t.push(e):t.splice(i,0,e):Util.n("Cannot insert an object into an HTMLCollection or NodeList: "+e+" at "+i)}static rf(t,i){Array.isArray(t)?i>=t.length?t.pop():t.splice(i,1):Util.n("Cannot remove an object from an HTMLCollection or NodeList at "+i)}static Ok=[];static ft(){const t=Util.Ok.pop();return t===void 0?[]:t}static nt(t){t.length=0,Util.Ok.push(t)}static eE=Object.freeze([]);static au(t){return t===null?"*":typeof t=="string"?t:typeof t=="function"?t.name:""}static hn(t){return typeof t=="function"?t.className?t.className:t.name:Util.Mt(t)&&t.constructor?Util.hn(t.constructor):typeof t}static zh(t,i){return i==null||i===""?null:Util.Mt(t)&&i in t||t[i]?t[i]:null}static toString(t){let i=t;return Util.Mt(t)&&(t.text?i=t.text:t.name?i=t.name:t.key!==void 0?i=t.key:t.id!==void 0?i=t.id:t.constructor===Object&&(t.Text?i=t.Text:t.Name?i=t.Name:t.Key!==void 0?i=t.Key:t.Id!==void 0?i=t.Id:t.ID!==void 0&&(i=t.ID))),i===void 0?"undefined":i===null?"null":i.toString()}static yw(t,i){if(t.hasOwnProperty(i))return!0;let e=Object.getPrototypeOf(t);for(;e&&e!==Function;){if(e.hasOwnProperty(i))return!0;const s=e.sE;if(s&&s[i])return!0;e=Object.getPrototypeOf(e)}return!1}static ED(t){const i=[];let e=0;for(e=0;e<256;e++)i[e]=e;let s=0,n=0;for(e=0;e<256;e++)s=(s+i[e]+119)%256,n=i[e],i[e]=i[s],i[s]=n;e=0,s=0;let o="";for(let r=0;r>4)+i.charAt(r&15)]=String.fromCharCode(r);t.length%2&&(t="0"+t);const s=[];let n=0;for(let r=0;r0){const n=i[0];return this.key=0,this.value=n,n}else return null}any(t){const i=this.Qt;i.dr=null;const e=i.gt;this.Vt=-1;const s=i.h,n=s.length,o=this.Rs;for(let r=0;r=0?(this.key=i,this.value=t.h[i],!0):(this.wl(),!1)}hasNext(){return this.next()}first(){const t=this.Qt;this.vt=t.gt;const i=t.h,e=i.length-1;if(this.Vt=e,e>=0){const s=i[e];return this.key=e,this.value=s,s}else return null}any(t){const i=this.Qt;i.gr=null;const e=i.gt,s=i.h,n=s.length;this.Vt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(t(r))return!0;i.gt!==e&&Util.ze(i)}return!1}all(t){const i=this.Qt;i.gr=null;const e=i.gt,s=i.h,n=s.length;this.Vt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(!t(r))return!1;i.gt!==e&&Util.ze(i)}return!0}each(t){const i=this.Qt;i.gr=null;const e=i.gt,s=i.h,n=s.length;this.Vt=n;for(let o=n-1;o>=0;o--){const r=s[o];t(r),i.gt!==e&&Util.ze(i)}return this}map(t){const i=this.Qt;i.gr=null;const e=i.gt,s=[],n=i.h,o=n.length;this.Vt=o;for(let l=o-1;l>=0;l--){const h=n[l];s.push(t(h)),i.gt!==e&&Util.ze(i)}const r=new List;return r.h=s,r.Xe(),r.iterator}filter(t){const i=this.Qt;i.gr=null;const e=i.gt,s=[],n=i.h,o=n.length;this.Vt=o;for(let l=o-1;l>=0;l--){const h=n[l];t(h)&&s.push(h),i.gt!==e&&Util.ze(i)}const r=new List;return r.h=s,r.Xe(),r.iterator}get count(){return this.Qt.h.length}wl(){this.key=-1,this.value=null,this.vt=-1,this.Qt.gr=this}toString(){return"ListIteratorBackwards("+this.Vt+"/"+this.Qt.count+")"}}class List{f;h;gt;dr;gr;constructor(t){GSet.vi(this),this.f=!1,this.h=[],this.gt=0,this.dr=null,this.gr=null,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.h.values()}Xe(){let t=this.gt;t++,t>999999999&&(t=0),this.gt=t}w(){return this.f=!0,this}ct(){return this.f=!1,this}toString(){return"List()#"+GSet.gs(this)}add(t){return this.f&&Util.F(this,t),this.h.push(t),this.Xe(),this}push(t){this.add(t)}addAll(t){if(t===null)return this;this.f&&Util.F(this);const i=this.h;if(Array.isArray(t)){const e=t.length;for(let s=0;s=i.length)&&Util.G(t,"0 <= i < length",List,"elt:i"),i[t]}get(t){return this.elt(t)}setElt(t,i){Debug&&Util.r(t,List,"setElt:i");const e=this.h;(t<0||t>=e.length)&&Util.G(t,"0 <= i < length",List,"setElt:i"),this.f&&Util.F(this,t),e[t]=i}set(t,i){this.setElt(t,i)}first(){const t=this.h;return t.length===0?null:t[0]}last(){const t=this.h,i=t.length;return i>0?t[i-1]:null}pop(){this.f&&Util.F(this);const t=this.h;return t.length>0?t.pop():null}any(t){const i=this.h,e=this.gt,s=i.length;for(let n=0;n= 0",List,"insertAt:i"),this.f&&Util.F(this,t);const e=this.h;t>=e.length?e.push(i):e.splice(t,0,i),this.Xe()}remove(t){return this.delete(t)}delete(t){if(t===null)return!1;this.f&&Util.F(this,t);const i=this.h,e=i.indexOf(t);return e===-1?!1:(e===i.length-1?i.pop():i.splice(e,1),this.Xe(),!0)}removeAt(t){Debug&&Util.r(t,List,"removeAt:i");const i=this.h;(t<0||t>=i.length)&&Util.G(t,"0 <= i < length",List,"removeAt:i"),this.f&&Util.F(this,t),t===i.length-1?i.pop():i.splice(t,1),this.Xe()}removeRange(t,i){Debug&&(Util.r(t,List,"removeRange:from"),Util.r(i,List,"removeRange:to"));const e=this.h,s=e.length;if(t<0)t=0;else if(t>=s)return this;if(i<0)return this;if(i>=s&&(i=s-1),t>i)return this;this.f&&Util.F(this);let n=t,o=i+1;for(;o0&&(t.h=Array.prototype.slice.call(i)),t}toArray(){const t=this.h,i=this.count,e=new Array(i);for(let s=0;s=n-1)&&Util.G(i,"0 <= from < length",List,"sortRange:from"),o===2){const r=s[i],l=s[i+1];return t(r,l)>0&&(s[i]=l,s[i+1]=r,this.Xe()),this}if(i===0)if(e>=n)s.sort(t);else{const r=s.slice(0,e);r.sort(t);for(let l=0;l=n){const r=s.slice(i);r.sort(t);for(let l=i;li.add(t(e))),i.iterator}filter(t){const i=new List;return this.Ao.k.forEach(e=>{t(e)&&i.add(e)}),i.iterator}get count(){return this.Ao.count}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"SetIterator"}}class GSet{f;k;constructor(t){this.f=!1,this.k=new Set,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.k.values()}values(){return this.k.values()}w(){return this.f=!0,this}ct(){return this.f=!1,this}toString(){return"Set()#"+GSet.gs(this)}add(t){return t===null?this:(this.k.add(t),this)}addAll(t){if(t===null)return this;if(Array.isArray(t)){const i=t.length;for(let e=0;et.add(i)),t}toArray(){return Array.from(this.k)}toList(){const t=new List;return this.k.forEach(i=>t.add(i)),t}get count(){return this.k.size}get size(){return this.k.size}get iterator(){return this.k.size<=0?EmptyIterator.instance:new SetIterator(this)}entries(){return this.k.entries()}keys(){return this.k.keys()}forEach(t,i){return this.k.forEach(t,i)}static cu=1;static vi(t){t.__gohashid=GSet.cu++}static gs(t){return t.__gohashid}}class MapKeySetIterator{it;ri;constructor(t){this.it=t,this.ri=t.k.keys()}[Symbol.iterator](){return this.it.k.keys()}key;value;get iterator(){return this}reset(){const t=this.it;this.ri=t.k.keys()}next(){const t=this.ri.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.it.k.size===0?null:(this.ri=this.it.k.keys(),this.ri.next().value)}any(t){for(const i of this.it.k)if(t(i[0]))return!0;return!1}all(t){for(const i of this.it.k)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.it.k)t(i[0]);return this}map(t){const i=this.it,e=new List;for(const s of i.k)e.add(t(s[0]));return e.iterator}filter(t){const i=this.it,e=new List;for(const s of i.k){const n=s[0];t(n)&&e.add(n)}return e.iterator}get count(){return this.it.size}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"MapKeySetIterator"}}class MapKeySet extends GSet{it;constructor(t){super(),GSet.vi(this),this.f=!0,this.it=t}[Symbol.iterator](){return this.k.keys()}values(){return this.k.keys()}w(){return this}ct(){return this}toString(){return"MapKeySet("+this.it.toString()+")"}add(t){Util.n("This Set is read-only: "+this.toString())}has(t){return this.it.has(t)}contains(t){return this.has(t)}delete(t){Util.n("This Set is read-only: "+this.toString())}remove(t){return this.delete(t)}clear(){Util.n("This Set is read-only: "+this.toString())}first(){return this.it.k.size===0?null:this.it.k.keys().next().value}any(t){for(const i of this.it.k)if(t(i[0]))return!0;return!1}all(t){for(const i of this.it.k)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.it.k)t(i[0]);return this}map(t){const i=new GSet;for(const e of this.it.k)i.add(t(e[0]));return i}filter(t){const i=new GSet;for(const e of this.it.k){const s=e[0];t(s)&&i.add(s)}return i}copy(){return new MapKeySet(this.it)}toSet(){const t=new GSet,i=this.it.k;for(const e of i)t.add(e[0]);return t}toArray(){const t=this.it.k,i=new Array(t.size);let e=0;for(const s of t)i[e]=s[0],e++;return i}toList(){const t=new List,i=this.it.k;for(const e of i)t.add(e[0]);return t}get count(){return this.it.size}get size(){return this.it.size}get iterator(){return this.it.size<=0?EmptyIterator.instance:new MapKeySetIterator(this.it)}}class MapValueSetIterator{it;ri;constructor(t){this.it=t,this.ri=t.k.values()}[Symbol.iterator](){return this.it.k.values()}key;value;get iterator(){return this}reset(){const t=this.it;this.ri=t.k.values()}next(){const t=this.ri.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.it.k.size===0?null:(this.ri=this.it.k.values(),this.ri.next().value)}any(t){for(const i of this.it.k)if(t(i[1]))return!0;return!1}all(t){for(const i of this.it.k)if(!t(i[1]))return!1;return!0}each(t){for(const i of this.it.k)t(i[1]);return this}map(t){const i=this.it,e=new List;for(const s of i.k)e.add(t(s[1]));return e.iterator}filter(t){const i=this.it,e=new List;for(const s of i.k){const n=s[1];t(n)&&e.add(n)}return e.iterator}get count(){return this.it.size}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"MapValueSetIterator"}}class KeyValuePair{constructor(t,i){this.key=t,this.value=i}toString(){return"{"+this.key+":"+this.value+"}"}key;value}class MapIterator{it;ri;constructor(t){this.it=t,this.ri=t.k.entries()}[Symbol.iterator](){return this.it.k.entries()}key;value;get iterator(){return this}reset(){const t=this.it;this.ri=t.k.entries()}next(){const t=this.ri.next();return t.done?(this.key=null,this.value=null,!1):(this.key=t.value[0],this.value=t.value[1],!0)}hasNext(){return this.next()}first(){if(this.it.k.size===0)return null;this.ri=this.it.k.entries();const t=this.ri.next().value;return this.key=t[0],this.value=t[1],new KeyValuePair(t[0],t[1])}any(t){return this.it.any(t)}all(t){return this.it.all(t)}each(t){return this.it.each(t),this}map(t){const i=new List;let e=null;return this.it.k.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),i.add(t(e))}),i.iterator}filter(t){const i=new List;let e=null;return this.it.k.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),t(e)&&(i.add(e),e=null)}),i.iterator}get count(){return this.it.size}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"MapIterator"}}class GMap{f;k;constructor(t){GSet.vi(this),this.f=!1,this.k=new Map,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.k.entries()}entries(){return this.k.entries()}w(){return this.f=!0,this}ct(){return this.f=!1,this}toString(){return"Map()#"+GSet.gs(this)}set(t,i){return this.f&&Util.F(this,t),this.k.set(t,i),this}add(t,i){return this.set(t,i)}addAll(t){if(t===null)return this;if(this.f&&Util.F(this),Array.isArray(t)){const i=t.length;for(let e=0;ei.x.toFixed(t)+" "+i.y.toFixed(t)}toString(){return"Point("+this.x+","+this.y+")"}equals(t){return t instanceof Point?this.S===t.x&&this.P===t.y:!1}equalTo(t,i){return this.S===t&&this.P===i}equalsApprox(t){return Geo.p(this.S,t.x)&&Geo.p(this.P,t.y)}add(t){return Debug&&(Util.s(t,Point,Point,"add:p"),this.et()),this.S+=t.x,this.P+=t.y,this}subtract(t){return Debug&&(Util.s(t,Point,Point,"subtract:p"),this.et()),this.S-=t.x,this.P-=t.y,this}offset(t,i){return Debug&&(Util.r(t,Point,"offset:dx"),Util.r(i,Point,"offset:dy"),this.et()),this.S+=t,this.P+=i,this}rotate(t){if(Debug&&(Util.r(t,Point,"rotate:angle"),this.et()),t===0)return this;const i=this.S,e=this.P;if(i===0&&e===0)return this;let s=0,n=0;if(t>=360?t-=360:t<0&&(t+=360),t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const o=t*Math.PI/180;s=Math.cos(o),n=Math.sin(o)}return this.S=s*i-n*e,this.P=n*i+s*e,this}scale(t,i){return Debug&&(Util.r(t,Point,"scale:sx"),Util.r(i,Point,"scale:sy"),this.et()),this.S*=t,this.P*=i,this}distanceSquaredPoint(t){Debug&&Util.s(t,Point,Point,"distanceSquaredPoint:p");const i=t.x-this.S,e=t.y-this.P;return i*i+e*e}distanceSquared(t,i){Debug&&(Util.r(t,Point,"distanceSquared:px"),Util.r(i,Point,"distanceSquared:py"));const e=t-this.S,s=i-this.P;return e*e+s*s}normalize(){Debug&&this.et();const t=this.S,i=this.P,e=Math.sqrt(t*t+i*i);return e>0&&(this.S=t/e,this.P=i/e),this}directionPoint(t){return Debug&&Util.s(t,Point,Point,"directionPoint:p"),this.oC(t.x-this.S,t.y-this.P)}direction(t,i){return Debug&&(Util.r(t,Point,"direction:px"),Util.r(i,Point,"direction:py")),this.oC(t-this.S,i-this.P)}oC(t,i){if(t===0)return i>0?90:i<0?270:0;if(i===0)return t>0?0:180;{if(isNaN(t)||isNaN(i))return 0;let e=Math.atan(Math.abs(i/t))*180/Math.PI;return t<0?i<0?e+=180:e=180-e:i<0&&(e=360-e),e}}static compareWithLineSegment(t,i,e,s,n,o){return Debug&&(Util.r(t,Point,"compareWithLineSegment:a1x"),Util.r(i,Point,"compareWithLineSegment:a1y"),Util.r(e,Point,"compareWithLineSegment:a2x"),Util.r(s,Point,"compareWithLineSegment:a2y"),Util.r(n,Point,"compareWithLineSegment:b1x"),Util.r(o,Point,"compareWithLineSegment:b1y")),Geo.uu(t,i,e,s,n,o)}compareWithLineSegmentPoint(t,i){return Debug&&(Util.s(t,Point,Point,"compareWithLineSegmentPoint:p"),Util.s(i,Point,Point,"compareWithLineSegmentPoint:q")),Geo.uu(t.x,t.y,i.x,i.y,this.x,this.y)}static intersectingLineSegments(t,i,e,s,n,o,r,l){return Debug&&(Util.r(t,Point,"intersectingLineSegments:a1x"),Util.r(i,Point,"intersectingLineSegments:a1y"),Util.r(e,Point,"intersectingLineSegments:a2x"),Util.r(s,Point,"intersectingLineSegments:a2y"),Util.r(n,Point,"intersectingLineSegments:b1x"),Util.r(o,Point,"intersectingLineSegments:b1y"),Util.r(r,Point,"intersectingLineSegments:b2x"),Util.r(l,Point,"intersectingLineSegments:b2y")),Geo.du(t,i,e,s,n,o,r,l)}projectOntoLineSegment(t,i,e,s){return Debug&&(Util.r(t,Point,"projectOntoLineSegment:px"),Util.r(i,Point,"projectOntoLineSegment:py"),Util.r(e,Point,"projectOntoLineSegment:qx"),Util.r(s,Point,"projectOntoLineSegment:qy")),Geo.xl(t,i,e,s,this.S,this.P,this),this}projectOntoLineSegmentPoint(t,i){return Debug&&(Util.s(t,Point,Point,"projectOntoLineSegmentPoint:p"),Util.s(i,Point,Point,"projectOntoLineSegmentPoint:q")),Geo.xl(t.x,t.y,i.x,i.y,this.S,this.P,this),this}snapToGrid(t,i,e,s){return Debug&&(Util.r(t,Point,"snapToGrid:originx"),Util.r(i,Point,"snapToGrid:originy"),Util.r(e,Point,"snapToGrid:cellwidth"),Util.r(s,Point,"snapToGrid:cellheight")),Geo.Hg(this.S,this.P,t,i,e,s,this),this}snapToGridPoint(t,i){return Debug&&(Util.s(t,Point,Point,"snapToGridPoint:p"),Util.s(i,Size,Point,"snapToGridPoint:q")),Geo.Hg(this.S,this.P,t.x,t.y,i.width,i.height,this),this}setRectSpot(t,i){return Debug&&(Util.s(t,Rect,Point,"setRectSpot:r"),Util.s(i,Spot,Point,"setRectSpot:spot"),this.et()),this.S=t.x+i.x*t.width+i.offsetX,this.P=t.y+i.y*t.height+i.offsetY,this}setSpot(t,i,e,s,n){return Debug&&(Util.r(t,Point,"setSpot:x"),Util.r(i,Point,"setSpot:y"),Util.r(e,Point,"setSpot:w"),Util.r(s,Point,"setSpot:h"),(e<0||s<0)&&Util.n("Point.setSpot:Width and height cannot be negative"),Util.s(n,Spot,Point,"setSpot:spot"),this.et()),this.S=t+n.x*e+n.offsetX,this.P=i+n.y*s+n.offsetY,this}O(t){return t.Pt(this),this}Ye(t){return t.ns(this),this}static distanceLineSegmentSquared(t,i,e,s,n,o){Debug&&(Util.r(t,Point,"distanceLineSegmentSquared:px"),Util.r(i,Point,"distanceLineSegmentSquared:py"),Util.r(e,Point,"distanceLineSegmentSquared:ax"),Util.r(s,Point,"distanceLineSegmentSquared:ay"),Util.r(n,Point,"distanceLineSegmentSquared:bx"),Util.r(o,Point,"distanceLineSegmentSquared:by"));let r=n-e,l=o-s;const h=r*r+l*l,a=e-t,f=s-i,c=-a*r-f*l;if(c<=0||c>=h)return r=n-t,l=o-i,Math.min(a*a+f*f,r*r+l*l);{const u=r*f-l*a;return u*u/h}}static distanceSquared(t,i,e,s){Debug&&(Util.r(t,Point,"distanceSquared:px"),Util.r(i,Point,"distanceSquared:py"),Util.r(e,Point,"distanceSquared:qx"),Util.r(s,Point,"distanceSquared:qy"));const n=e-t,o=s-i;return n*n+o*o}static direction(t,i,e,s){Debug&&(Util.r(t,Point,"direction:px"),Util.r(i,Point,"direction:py"),Util.r(e,Point,"direction:qx"),Util.r(s,Point,"direction:qy"));const n=e-t,o=s-i;if(n===0)return o>0?90:o<0?270:0;if(o===0)return n>0?0:180;{if(isNaN(n)||isNaN(o))return 0;let r=Math.atan(Math.abs(o/n))*180/Math.PI;return n<0?o<0?r+=180:r=180-r:o<0&&(r=360-r),r}}get x(){return this.S}set x(t){Debug&&(Util.t(t,"number",Point,"x"),this.et(t)),this.S=t}get y(){return this.P}set y(t){Debug&&(Util.t(t,"number",Point,"y"),this.et(t)),this.P=t}isReal(){return isFinite(this.x)&&isFinite(this.y)}static Lo=new Point(0,0).ot();static rC=new Point(-1/0,-1/0).ot();static lC=new Point(1/0,1/0).ot();static hC=new Point(6,6).ot();static Vk=new Point(NaN,NaN).ot();static Bk=[];static a(){const t=Point.Bk.pop();return t===void 0?new Point:t}static H(t,i){const e=Point.Bk.pop();return e===void 0?new Point(t,i):(e.x=t,e.y=i,e)}static o(t){Point.Bk.push(t)}}class Size{v;J;f;constructor(t,i){t===void 0?(this.v=0,this.J=0):typeof t=="number"&&(t>=0||isNaN(t))&&typeof i=="number"&&(i>=0||isNaN(i))?(this.v=t,this.J=i):Util.n("Invalid arguments to Size constructor: "+t+", "+i),this.f=!1}c(t){return this.v=t.v,this.J=t.J,this}e(t,i){return this.v=t,this.J=i,this}setTo(t,i){return Debug&&(Util.t(t,"number",Size,"setTo:w"),Util.t(i,"number",Size,"setTo:h"),t<0&&Util.G(t,">= 0",Size,"setTo:w"),i<0&&Util.G(i,">= 0",Size,"setTo:h"),this.et()),this.v=t,this.J=i,this}set(t){return Debug&&(Util.s(t,Size,Size,"set:s"),this.et()),this.v=t.v,this.J=t.J,this}copy(){const t=new Size;return t.v=this.v,t.J=this.J,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ct(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}et(t){if(Debug&&this.f){let i="The Size is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;return n=i[e++],n&&(o=parseFloat(n)),new Size(s,o)}else return new Size}static stringify(t){return Debug&&Util.s(t,Size),t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.t(t,"number",Size,"stringifyFixed:digits"),i=>i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Size("+this.width+","+this.height+")"}equals(t){return t instanceof Size?this.v===t.width&&this.J===t.height:!1}equalTo(t,i){return this.v===t&&this.J===i}equalsApprox(t){return Geo.p(this.v,t.width)&&Geo.p(this.J,t.height)}inflate(t,i){Debug&&(Util.r(t,Size,"inflate:w"),Util.r(i,Size,"inflate:h"));const e=this.width+t;this.v=e>=0?e:0;const s=this.height+i;return this.J=s>=0?s:0,this}get width(){return this.v}set width(t){Debug&&(Util.t(t,"number",Size,"width"),this.et(t)),t<0&&Util.G(t,">= 0",Size,"width"),this.v=t}get height(){return this.J}set height(t){Debug&&(Util.t(t,"number",Size,"height"),this.et(t)),t<0&&Util.G(t,">= 0",Size,"height"),this.J=t}isReal(){return isFinite(this.width)&&isFinite(this.height)}static lf=new Size(0,0).ot();static zk=new Size(1,1).ot();static aC=new Size(6,6).ot();static gu=new Size(8,8).ot();static fC=new Size(10,10).ot();static Xk=new Size(1/0,1/0).ot();static xw=new Size(NaN,NaN).ot();static cC=[];static a(){const t=Size.cC.pop();return t===void 0?new Size:t}static o(t){Size.cC.push(t)}}class Rect{S;P;v;J;f;constructor(t,i,e,s){if(t===void 0)this.S=0,this.P=0,this.v=0,this.J=0;else if(typeof t=="number"&&typeof i=="number"&&typeof e=="number"&&(e>=0||isNaN(e))&&typeof s=="number"&&(s>=0||isNaN(s)))this.S=t,this.P=i,this.v=e,this.J=s;else if(t instanceof Point){const n=t.x,o=t.y;if(i instanceof Point){const r=i.x,l=i.y;this.S=Math.min(n,r),this.P=Math.min(o,l),this.v=Math.abs(n-r),this.J=Math.abs(o-l)}else i instanceof Size?(this.S=n,this.P=o,this.v=i.width,this.J=i.height):Util.n("Incorrect second argument supplied to Rect constructor "+i)}else Util.n("Invalid arguments to Rect constructor: "+t+", "+i+", "+e+", "+s);this.f=!1}c(t){return this.S=t.S,this.P=t.P,this.v=t.v,this.J=t.J,this}e(t,i,e,s){return this.S=t,this.P=i,this.v=e,this.J=s,this}Kn(t,i){return this.v=t,this.J=i,this}setTo(t,i,e,s){return Debug&&(Util.t(t,"number",Rect,"setTo:x"),Util.t(i,"number",Rect,"setTo:y"),Util.t(e,"number",Rect,"setTo:w"),Util.t(s,"number",Rect,"setTo:h"),e<0&&Util.G(e,">= 0",Rect,"setTo:w"),s<0&&Util.G(s,">= 0",Rect,"setTo:h"),this.et()),this.S=t,this.P=i,this.v=e,this.J=s,this}set(t){return Debug&&(Util.s(t,Rect,Rect,"set:r"),this.et()),this.S=t.S,this.P=t.P,this.v=t.v,this.J=t.J,this}setPoint(t){return Debug&&(Util.s(t,Point,Rect,"setPoint:p"),this.et()),this.S=t.x,this.P=t.y,this}setSize(t){return Debug&&(Util.s(t,Size,Rect,"setSize:s"),this.et()),this.v=t.width,this.J=t.height,this}copy(){const t=new Rect;return t.S=this.S,t.P=this.P,t.v=this.v,t.J=this.J,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ct(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}et(t){if(Debug&&this.f){let i="The Rect is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),new Rect(s,o,r,l)}else return new Rect}static stringify(t){return Debug&&Util.s(t,Rect),t.x.toString()+" "+t.y.toString()+" "+t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.t(t,"number",Rect,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Rect("+this.x+","+this.y+","+this.width+","+this.height+")"}equals(t){return t instanceof Rect?this.S===t.x&&this.P===t.y&&this.v===t.width&&this.J===t.height:!1}equalTo(t,i,e,s){return this.S===t&&this.P===i&&this.v===e&&this.J===s}equalsApprox(t){return Geo.p(this.S,t.x)&&Geo.p(this.P,t.y)&&Geo.p(this.v,t.width)&&Geo.p(this.J,t.height)}equalsApproxTo(t,i,e,s){return Geo.p(this.S,t)&&Geo.p(this.P,i)&&Geo.p(this.v,e)&&Geo.p(this.J,s)}equalsApproxClose(t){return Geo.q(this.S,t.x)&&Geo.q(this.P,t.y)&&Geo.q(this.v,t.width)&&Geo.q(this.J,t.height)}containsPoint(t){return Debug&&Util.s(t,Point,Rect,"containsPoint:p"),this.S<=t.x&&this.S+this.v>=t.x&&this.P<=t.y&&this.P+this.J>=t.y}containsRect(t){return Debug&&Util.s(t,Rect,Rect,"containsRect:r"),this.S<=t.x&&t.x+t.width<=this.S+this.v&&this.P<=t.y&&t.y+t.height<=this.P+this.J}contains(t,i,e,s){return Debug?(Util.r(t,Rect,"contains:x"),Util.r(i,Rect,"contains:y"),e===void 0?e=0:Util.r(e,Rect,"contains:w"),s===void 0?s=0:Util.r(s,Rect,"contains:h"),(e<0||s<0)&&Util.n("Rect.contains:Width and height cannot be negative")):(e===void 0&&(e=0),s===void 0&&(s=0)),this.S<=t&&t+e<=this.S+this.v&&this.P<=i&&i+s<=this.P+this.J}offset(t,i){return Debug&&(Util.r(t,Rect,"offset:dx"),Util.r(i,Rect,"offset:dy"),this.et()),this.S+=t,this.P+=i,this}inflate(t,i){return Debug&&(Util.r(t,Rect,"inflate:w"),Util.r(i,Rect,"inflate:h")),this.bw(i,t,i,t)}addMargin(t){return Debug&&Util.s(t,Margin,Rect,"addMargin:m"),this.bw(t.top,t.right,t.bottom,t.left)}subtractMargin(t){return Debug&&Util.s(t,Margin,Rect,"subtractMargin:m"),this.bw(-t.top,-t.right,-t.bottom,-t.left)}grow(t,i,e,s){return Debug&&(Util.r(t,Rect,"grow:t"),Util.r(i,Rect,"grow:r"),Util.r(e,Rect,"grow:b"),Util.r(s,Rect,"grow:l")),this.bw(t,i,e,s)}bw(t,i,e,s){Debug&&this.et();const n=this.v;i+s<=-n?(this.S+=n/2,this.v=0):(this.S-=s,this.v+=i+s);const o=this.J;return t+e<=-o?(this.P+=o/2,this.J=0):(this.P-=t,this.J+=t+e),this}intersectRect(t){return Debug&&Util.s(t,Rect,Rect,"intersectRect:r"),this.uC(t.x,t.y,t.width,t.height)}intersect(t,i,e,s){return Debug&&(Util.r(t,Rect,"intersect:x"),Util.r(i,Rect,"intersect:y"),Util.r(e,Rect,"intersect:w"),Util.r(s,Rect,"intersect:h"),(e<0||s<0)&&Util.n("Rect.intersect:Width and height cannot be negative")),this.uC(t,i,e,s)}uC(t,i,e,s){Debug&&this.et();const n=Math.max(this.S,t),o=Math.max(this.P,i),r=Math.min(this.S+this.v,t+e),l=Math.min(this.P+this.J,i+s);return this.S=n,this.P=o,this.v=Math.max(0,r-n),this.J=Math.max(0,l-o),this}intersectsRect(t){return Debug&&Util.s(t,Rect,Rect,"intersectsRect:r"),this.intersects(t.x,t.y,t.width,t.height)}intersects(t,i,e,s){Debug&&(Util.r(t,Rect,"intersects:x"),Util.r(i,Rect,"intersects:y"),Util.r(t,Rect,"intersects:w"),Util.r(i,Rect,"intersects:h"),(e<0||s<0)&&Util.n("Rect.intersects:Width and height cannot be negative"));let n=this.v;const o=this.S;if(n!==1/0&&e!==1/0&&(n+=o,e+=t,isNaN(e)||isNaN(n)||o>e||t>n))return!1;let r=this.J;const l=this.P;return!(r!==1/0&&s!==1/0&&(r+=l,s+=i,isNaN(s)||isNaN(r)||l>s||i>r))}intersectsRectPlus(t,i){let e=this.v,s=t.width+i+i;const n=this.S,o=t.x-i;if(e+=n,s+=o,n>s||o>e)return!1;let r=this.J,l=t.height+i+i;const h=this.P,a=t.y-i;return r+=h,l+=a,!(h>l||a>r)}unionPoint(t){return Debug&&Util.s(t,Point,Rect,"unionPoint:p"),this.unionNoCheck(t.x,t.y,0,0)}unionRect(t){return Debug&&Util.s(t,Rect,Rect,"unionRect:r"),this.unionNoCheck(t.S,t.P,t.v,t.J)}union(t,i,e,s){return Debug?(Util.r(t,Rect,"union:x"),Util.r(i,Rect,"union:y"),e===void 0?e=0:Util.r(e,Rect,"union:w"),s===void 0?s=0:Util.r(s,Rect,"union:h"),(e<0||s<0)&&Util.n("Rect.union:Width and height cannot be negative"),this.et()):(e===void 0&&(e=0),s===void 0&&(s=0)),this.unionNoCheck(t,i,e,s)}unionNoCheck(t,i,e,s){const n=Math.min(this.S,t),o=Math.min(this.P,i),r=Math.max(this.S+this.v,t+e),l=Math.max(this.P+this.J,i+s);return this.S=n,this.P=o,this.v=r-n,this.J=l-o,this}setSpot(t,i,e){return Debug&&(Util.r(t,Rect,"setSpot:x"),Util.r(i,Rect,"setSpot:y"),Util.s(e,Spot,Rect,"setSpot:spot"),this.et()),this.S=t-e.offsetX-e.x*this.v,this.P=i-e.offsetY-e.y*this.J,this}static contains(t,i,e,s,n,o,r,l){return Debug?(Util.r(t,Rect,"contains:rx"),Util.r(i,Rect,"contains:ry"),Util.r(e,Rect,"contains:rw"),Util.r(s,Rect,"contains:rh"),Util.r(n,Rect,"contains:x"),Util.r(o,Rect,"contains:y"),r===void 0?r=0:Util.r(r,Rect,"contains:w"),l===void 0?l=0:Util.r(l,Rect,"contains:h"),(e<0||s<0||r<0||l<0)&&Util.n("Rect.contains:Width and height cannot be negative")):(r===void 0&&(r=0),l===void 0&&(l=0)),t<=n&&n+r<=t+e&&i<=o&&o+l<=i+s}static intersects(t,i,e,s,n,o,r,l){Debug&&(Util.r(t,Rect,"intersects:rx"),Util.r(i,Rect,"intersects:ry"),Util.r(e,Rect,"intersects:rw"),Util.r(s,Rect,"intersects:rh"),Util.r(n,Rect,"intersects:x"),Util.r(o,Rect,"intersects:y"),Util.r(r,Rect,"intersects:w"),Util.r(l,Rect,"intersects:h"),(e<0||s<0||r<0||l<0)&&Util.n("Rect.intersects:Width and height cannot be negative"));let h=e,a=r;const f=t,c=n;if(h+=f,a+=c,f>a||c>h)return!1;let u=s,d=l;const m=i,g=o;return u+=m,d+=g,!(m>d||g>u)}static intersectsLineSegment(t,i,e,s,n,o,r,l){return Debug&&(Util.r(t,Rect,"intersectsLineSegment:x"),Util.r(i,Rect,"intersectsLineSegment:y"),Util.r(e,Rect,"intersectsLineSegment:w"),Util.r(s,Rect,"intersectsLineSegment:h"),Util.r(n,Rect,"intersectsLineSegment:p1x"),Util.r(o,Rect,"intersectsLineSegment:p1y"),Util.r(r,Rect,"intersectsLineSegment:p2x"),Util.r(l,Rect,"intersectsLineSegment:p2y"),(e<0||s<0)&&Util.n("Rect.intersectsLineSegment: width and height cannot be negative")),Geo.dC(t,i,e,s,n,o,r,l)}get x(){return this.S}set x(t){Debug&&(Util.t(t,"number",Rect,"x"),this.et(t)),this.S=t}get y(){return this.P}set y(t){Debug&&(Util.t(t,"number",Rect,"y"),this.et(t)),this.P=t}get width(){return this.v}set width(t){Debug&&(Util.t(t,"number",Rect,"width"),this.et(t)),t<0&&Util.G(t,">= 0",Rect,"width"),this.v=t}get height(){return this.J}set height(t){Debug&&(Util.t(t,"number",Rect,"height"),this.et(t)),t<0&&Util.G(t,">= 0",Rect,"height"),this.J=t}get left(){return this.S}set left(t){Debug&&(Util.t(t,"number",Rect,"left"),this.et(t)),this.S=t}get top(){return this.P}set top(t){Debug&&(Util.t(t,"number",Rect,"top"),this.et(t)),this.P=t}get right(){return this.S+this.v}set right(t){Debug&&(Util.r(t,Rect,"right"),this.et(t)),this.S+=t-(this.S+this.v)}get bottom(){return this.P+this.J}set bottom(t){Debug&&(Util.r(t,Rect,"top"),this.et(t)),this.P+=t-(this.P+this.J)}get position(){return new Point(this.S,this.P)}set position(t){Debug&&(Util.s(t,Point,Rect,"position"),this.et(t)),this.S=t.x,this.P=t.y}get size(){return new Size(this.v,this.J)}set size(t){Debug&&(Util.s(t,Size,Rect,"size"),this.et(t)),this.v=t.width,this.J=t.height}get center(){return new Point(this.S+this.v/2,this.P+this.J/2)}set center(t){Debug&&(Util.s(t,Point,Rect,"center"),this.et(t)),this.S=t.x-this.v/2,this.P=t.y-this.J/2}get centerX(){return this.S+this.v/2}set centerX(t){Debug&&(Util.r(t,Rect,"centerX"),this.et(t)),this.S=t-this.v/2}get centerY(){return this.P+this.J/2}set centerY(t){Debug&&(Util.r(t,Rect,"centerY"),this.et(t)),this.P=t-this.J/2}isReal(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)}isEmpty(){return this.width===0&&this.height===0}static kw=new Rect(0,0,0,0).ot();static BD=new Rect(NaN,NaN,NaN,NaN).ot();static Yk=[];static a(){const t=Rect.Yk.pop();return t===void 0?new Rect:t}static H(t,i,e,s){const n=Rect.Yk.pop();return n===void 0?new Rect(t,i,e,s):n.e(t,i,e,s)}static o(t){Rect.Yk.push(t)}}class Margin{an;fn;cn;un;f;constructor(t,i,e,s){t===void 0?(this.an=0,this.fn=0,this.cn=0,this.un=0):i===void 0?(i=t,e=t,s=t,this.top=t,this.right=i,this.bottom=e,this.left=s):e===void 0?(e=t,s=i,this.top=t,this.right=i,this.bottom=e,this.left=s):s!==void 0?(this.top=t,this.right=i,this.bottom=e,this.left=s):Util.n("Invalid arguments to Margin constructor: "+t+", "+i+", "+e+", "+s),this.f=!1}c(t){return this.an=t.an,this.fn=t.fn,this.cn=t.cn,this.un=t.un,this}setTo(t,i,e,s){return Debug&&(Util.t(t,"number",Margin,"setTo:t"),Util.t(i,"number",Margin,"setTo:r"),Util.t(e,"number",Margin,"setTo:b"),Util.t(s,"number",Margin,"setTo:l"),this.et()),this.an=t,this.fn=i,this.cn=e,this.un=s,this}set(t){return Debug&&(Util.s(t,Margin,Margin,"assign:m"),this.et()),this.an=t.an,this.fn=t.fn,this.cn=t.cn,this.un=t.un,this}copy(){const t=new Margin;return t.an=this.an,t.fn=this.fn,t.cn=this.cn,t.un=this.un,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ct(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}et(t){if(Debug&&this.f){let i="The Margin is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=NaN;for(;i[e]==="";)e++;let n=i[e++];if(n&&(s=parseFloat(n)),isNaN(s))return new Margin;let o=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(o=parseFloat(n)),isNaN(o))return new Margin(s);let r=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(r=parseFloat(n)),isNaN(r))return new Margin(s,o);let l=NaN;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),isNaN(l)?new Margin(s,o):new Margin(s,o,r,l)}else return new Margin}static stringify(t){return Debug&&Util.s(t,Margin),t.top.toString()+" "+t.right.toString()+" "+t.bottom.toString()+" "+t.left.toString()}static stringifyFixed(t){return Util.t(t,"number",Margin,"stringifyFixed:digits"),i=>i.top.toFixed(t)+" "+i.right.toFixed(t)+" "+i.bottom.toFixed(t)+" "+i.left.toFixed(t)}toString(){return"Margin("+this.top+","+this.right+","+this.bottom+","+this.left+")"}equals(t){return t instanceof Margin?this.an===t.top&&this.fn===t.right&&this.cn===t.bottom&&this.un===t.left:!1}equalTo(t,i,e,s){return this.an===t&&this.fn===i&&this.cn===e&&this.un===s}equalsApprox(t){return Geo.p(this.an,t.top)&&Geo.p(this.fn,t.right)&&Geo.p(this.cn,t.bottom)&&Geo.p(this.un,t.left)}get top(){return this.an}set top(t){Debug&&(Util.r(t,Margin,"top"),this.et(t)),this.an=t}get right(){return this.fn}set right(t){Debug&&(Util.r(t,Margin,"right"),this.et(t)),this.fn=t}get bottom(){return this.cn}set bottom(t){Debug&&(Util.r(t,Margin,"bottom"),this.et(t)),this.cn=t}get left(){return this.un}set left(t){Debug&&(Util.r(t,Margin,"left"),this.et(t)),this.un=t}isReal(){return isFinite(this.top)&&isFinite(this.right)&&isFinite(this.bottom)&&isFinite(this.left)}static qg=new Margin(0,0,0,0).ot();static gC=new Margin(2,2,2,2).ot();static mC=[];static a(){const t=Margin.mC.pop();return t===void 0?new Margin:t}static o(t){Margin.mC.push(t)}}class Spot{S;P;Is;Os;f;constructor(t,i,e,s){t===void 0?(this.S=0,this.P=0,this.Is=0,this.Os=0):(i===void 0&&(i=0),e===void 0&&(e=0),s===void 0&&(s=0),this.x=t,this.y=i,this.offsetX=e,this.offsetY=s),this.f=!1}c(t){return this.S=t.S,this.P=t.P,this.Is=t.Is,this.Os=t.Os,this}setTo(t,i,e,s){return Debug&&(this.Sw(t,"setTo:x"),this.Sw(i,"setTo:y"),this.Mw(e,"setTo:offx"),this.Mw(s,"setTo:offy"),this.et()),this.S=t,this.P=i,this.Is=e,this.Os=s,this}set(t){return Debug&&(Util.s(t,Spot,Spot,"set:s"),this.et()),this.S=t.S,this.P=t.P,this.Is=t.Is,this.Os=t.Os,this}copy(){const t=new Spot;return t.S=this.S,t.P=this.P,t.Is=this.Is,t.Os=this.Os,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ct(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}et(t){if(Debug&&this.f){let i="The Spot is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}Ke(t){return this.S=NaN,this.P=NaN,this.Is=t,this}Sw(t,i){(isNaN(t)||t>1||t<0)&&Util.G(t,"0 <= "+i+" <= 1",Spot,i)}Mw(t,i){(isNaN(t)||t===1/0||t===-1/0)&&Util.G(t,"real number, not NaN or Infinity",Spot,i)}static parse(t){if(typeof t=="string"){if(t=t.trim(),t==="None")return Spot.None;if(t==="TopLeft")return Spot.TopLeft;if(t==="Top"||t==="TopCenter"||t==="MiddleTop")return Spot.TopCenter;if(t==="TopRight")return Spot.TopRight;if(t==="Left"||t==="LeftCenter"||t==="MiddleLeft")return Spot.LeftCenter;if(t==="Center")return Spot.Center;if(t==="Right"||t==="RightCenter"||t==="MiddleRight")return Spot.RightCenter;if(t==="BottomLeft")return Spot.BottomLeft;if(t==="Bottom"||t==="BottomCenter"||t==="MiddleBottom")return Spot.BottomCenter;if(t==="BottomRight")return Spot.BottomRight;if(t==="TopSide")return Spot.TopSide;if(t==="LeftSide")return Spot.LeftSide;if(t==="RightSide")return Spot.RightSide;if(t==="BottomSide")return Spot.BottomSide;if(t==="TopBottomSides")return Spot.TopBottomSides;if(t==="LeftRightSides")return Spot.LeftRightSides;if(t==="TopLeftSides")return Spot.TopLeftSides;if(t==="TopRightSides")return Spot.TopRightSides;if(t==="BottomLeftSides")return Spot.BottomLeftSides;if(t==="BottomRightSides")return Spot.BottomRightSides;if(t==="NotTopSide")return Spot.NotTopSide;if(t==="NotLeftSide")return Spot.NotLeftSide;if(t==="NotRightSide")return Spot.NotRightSide;if(t==="NotBottomSide")return Spot.NotBottomSide;if(t==="AllSides")return Spot.AllSides;if(t==="Default")return Spot.Default;const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n!==void 0&&n.length>0&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n!==void 0&&n.length>0&&(l=parseFloat(n)),new Spot(s,o,r,l)}else return new Spot}static stringify(t){return Debug&&Util.s(t,Spot),t.isSpot()?t.x.toString()+" "+t.y.toString()+" "+t.offsetX.toString()+" "+t.offsetY.toString():t.toString()}static stringifyFixed(t){return Util.t(t,"number",Spot,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.offsetX.toFixed(t)+" "+i.offsetY.toFixed(t)}toString(){return this.isSpot()?this.Is===0&&this.Os===0?"Spot("+this.x+","+this.y+")":"Spot("+this.x+","+this.y+","+this.offsetX+","+this.offsetY+")":this.equals(Spot.None)?"None":this.equals(Spot.TopLeft)?"TopLeft":this.equals(Spot.TopCenter)?"Top":this.equals(Spot.TopRight)?"TopRight":this.equals(Spot.LeftCenter)?"Left":this.equals(Spot.Center)?"Center":this.equals(Spot.RightCenter)?"Right":this.equals(Spot.BottomLeft)?"BottomLeft":this.equals(Spot.BottomCenter)?"Bottom":this.equals(Spot.BottomRight)?"BottomRight":this.equals(Spot.TopSide)?"TopSide":this.equals(Spot.LeftSide)?"LeftSide":this.equals(Spot.RightSide)?"RightSide":this.equals(Spot.BottomSide)?"BottomSide":this.equals(Spot.TopBottomSides)?"TopBottomSides":this.equals(Spot.LeftRightSides)?"LeftRightSides":this.equals(Spot.TopLeftSides)?"TopLeftSides":this.equals(Spot.TopRightSides)?"TopRightSides":this.equals(Spot.BottomLeftSides)?"BottomLeftSides":this.equals(Spot.BottomRightSides)?"BottomRightSides":this.equals(Spot.NotTopSide)?"NotTopSide":this.equals(Spot.NotLeftSide)?"NotLeftSide":this.equals(Spot.NotRightSide)?"NotRightSide":this.equals(Spot.NotBottomSide)?"NotBottomSide":this.equals(Spot.AllSides)?"AllSides":this.equals(Spot.Default)?"Default":"None"}equals(t){return t instanceof Spot?(this.S===t.x||isNaN(this.S)&&isNaN(t.x))&&(this.P===t.y||isNaN(this.P)&&isNaN(t.y))&&this.Is===t.offsetX&&this.Os===t.offsetY:!1}opposite(){return new Spot(.5-(this.S-.5),.5-(this.P-.5),-this.Is,-this.Os)}includesSide(t){if(!this.isSide())return!1;if(!t.isSide())if(t.equals(Spot.Left))t=Spot.LeftSide;else if(t.equals(Spot.Right))t=Spot.RightSide;else if(t.equals(Spot.Top))t=Spot.TopSide;else if(t.equals(Spot.Bottom))t=Spot.BottomSide;else return!1;const i=this.Os,e=t.offsetY;return(i&e)===e}get x(){return this.S}set x(t){Debug&&(this.Sw(t,"x"),this.et(t)),this.S=t}get y(){return this.P}set y(t){Debug&&(this.Sw(t,"y"),this.et(t)),this.P=t}get offsetX(){return this.Is}set offsetX(t){Debug&&(this.Mw(t,"offsetX"),this.et(t)),this.Is=t}get offsetY(){return this.Os}set offsetY(t){Debug&&(this.Mw(t,"offsetY"),this.et(t)),this.Os=t}isSpot(){return!isNaN(this.x)&&!isNaN(this.y)}isNoSpot(){return isNaN(this.x)||isNaN(this.y)}isSide(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===1&&this.offsetY!==0}isNone(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===0&&this.offsetY===0}isDefault(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===-1&&this.offsetY===0}static None=new Spot(0,0,0,0).Ke(0).ot();static Default=new Spot(0,0,-1,0).Ke(-1).ot();static TopLeft=new Spot(0,0,0,0).ot();static TopCenter=new Spot(.5,0,0,0).ot();static TopRight=new Spot(1,0,0,0).ot();static LeftCenter=new Spot(0,.5,0,0).ot();static Center=new Spot(.5,.5,0,0).ot();static RightCenter=new Spot(1,.5,0,0).ot();static BottomLeft=new Spot(0,1,0,0).ot();static BottomCenter=new Spot(.5,1,0,0).ot();static BottomRight=new Spot(1,1,0,0).ot();static MiddleTop=Spot.TopCenter;static MiddleLeft=Spot.LeftCenter;static MiddleRight=Spot.RightCenter;static MiddleBottom=Spot.BottomCenter;static Top=Spot.TopCenter;static Left=Spot.LeftCenter;static Right=Spot.RightCenter;static Bottom=Spot.BottomCenter;static TopSide=new Spot(0,0,1,1).Ke(1).ot();static LeftSide=new Spot(0,0,1,2).Ke(1).ot();static RightSide=new Spot(0,0,1,4).Ke(1).ot();static BottomSide=new Spot(0,0,1,8).Ke(1).ot();static TopBottomSides=new Spot(0,0,1,9).Ke(1).ot();static LeftRightSides=new Spot(0,0,1,6).Ke(1).ot();static TopLeftSides=new Spot(0,0,1,3).Ke(1).ot();static TopRightSides=new Spot(0,0,1,5).Ke(1).ot();static BottomLeftSides=new Spot(0,0,1,10).Ke(1).ot();static BottomRightSides=new Spot(0,0,1,12).Ke(1).ot();static NotTopSide=new Spot(0,0,1,14).Ke(1).ot();static NotLeftSide=new Spot(0,0,1,13).Ke(1).ot();static NotRightSide=new Spot(0,0,1,11).Ke(1).ot();static NotBottomSide=new Spot(0,0,1,7).Ke(1).ot();static AllSides=new Spot(0,0,1,15).Ke(1).ot();static Kk=new Spot(.156,.156).ot();static Uk=new Spot(.844,.844).ot();static pC=[];static a(){const t=Spot.pC.pop();return t===void 0?new Spot:t}static o(t){Spot.pC.push(t)}}class Transform{m11;m12;m21;m22;dx;dy;constructor(){this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0}set(t){return this.m11=t.m11,this.m12=t.m12,this.m21=t.m21,this.m22=t.m22,this.dx=t.dx,this.dy=t.dy,this}setTo(t,i,e,s,n,o){return this.m11=t,this.m12=i,this.m21=e,this.m22=s,this.dx=n,this.dy=o,this}copy(){const t=new Transform;return t.m11=this.m11,t.m12=this.m12,t.m21=this.m21,t.m22=this.m22,t.dx=this.dx,t.dy=this.dy,t}toString(){return"Transform("+this.m11+","+this.m12+","+this.m21+","+this.m22+","+this.dx+","+this.dy+")"}equals(t){return this.m11===t.m11&&this.m12===t.m12&&this.m21===t.m21&&this.m22===t.m22&&this.dx===t.dx&&this.dy===t.dy}Gk(){return this.dx===0&&this.dy===0&&this.m11===1&&this.m12===0&&this.m21===0&&this.m22===1}Bi(){return this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0,this}hf(t){const i=this.m11*t.m11+this.m21*t.m12,e=this.m12*t.m11+this.m22*t.m12,s=this.m11*t.m21+this.m21*t.m22,n=this.m12*t.m21+this.m22*t.m22;return this.dx=this.m11*t.dx+this.m21*t.dy+this.dx,this.dy=this.m12*t.dx+this.m22*t.dy+this.dy,this.m11=i,this.m12=e,this.m21=s,this.m22=n,this}yC(t){const i=1/(t.m11*t.m22-t.m12*t.m21),e=t.m22*i,s=-t.m12*i,n=-t.m21*i,o=t.m11*i,r=i*(t.m21*t.dy-t.m22*t.dx),l=i*(t.m12*t.dx-t.m11*t.dy),h=this.m11*e+this.m21*s,a=this.m12*e+this.m22*s,f=this.m11*n+this.m21*o,c=this.m12*n+this.m22*o;return this.dx=this.m11*r+this.m21*l+this.dx,this.dy=this.m12*r+this.m22*l+this.dy,this.m11=h,this.m12=a,this.m21=f,this.m22=c,this}Pw(){const t=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*t,e=-this.m12*t,s=-this.m21*t,n=this.m11*t,o=t*(this.m21*this.dy-this.m22*this.dx),r=t*(this.m12*this.dx-this.m11*this.dy);return this.m11=i,this.m12=e,this.m21=s,this.m22=n,this.dx=o,this.dy=r,this}ms(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return this;this.Es(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m11*s+this.m21*n,r=this.m12*s+this.m22*n,l=this.m11*-n+this.m21*s,h=this.m12*-n+this.m22*s;return this.m11=o,this.m12=r,this.m21=l,this.m22=h,this.Es(-i,-e),this}Es(t,i){return this.dx+=this.m11*t+this.m21*i,this.dy+=this.m12*t+this.m22*i,this}lt(t,i){return i===void 0&&(i=t),this.m11*=t,this.m12*=t,this.m21*=i,this.m22*=i,this}zD(){if(this.m11===1&&this.m12===0)return 0;let t=Math.atan2(this.m12,this.m11)*180/Math.PI;return t<0&&(t+=360),t}Pt(t){const i=t.x,e=t.y;return t.e(i*this.m11+e*this.m21+this.dx,i*this.m12+e*this.m22+this.dy)}ns(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=t.x-this.dx,l=t.y-this.dy;return t.e(r*e+l*n,r*s+l*o)}Nw(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=i*(this.m21*this.dy-this.m22*this.dx),l=i*(this.m12*this.dx-this.m11*this.dy),h=t.x*1.25,a=t.y*1.2;return t.e(h*e+a*n+r,h*s+a*o+l)}Cw(t){const i=t.x,e=t.y,s=i+t.width,n=e+t.height,o=this.m11,r=this.m12,l=this.m21,h=this.m22,a=this.dx,f=this.dy,c=i*o+e*l+a,u=i*r+e*h+f,d=s*o+e*l+a,m=s*r+e*h+f,g=i*o+n*l+a,p=i*r+n*h+f,y=s*o+n*l+a,x=s*r+n*h+f;let k=c,b=c,S=u,M=u;return k=Math.min(k,d),b=Math.max(b,d),S=Math.min(S,m),M=Math.max(M,m),k=Math.min(k,g),b=Math.max(b,g),S=Math.min(S,p),M=Math.max(M,p),k=Math.min(k,y),b=Math.max(b,y),S=Math.min(S,x),M=Math.max(M,x),t.e(k,S,b-k,M-S),t}static wC=[];static a(){const t=Transform.wC.pop();return t===void 0?new Transform:t}static o(t){Transform.wC.push(t)}static Hk="54a702f3e53909c447824c6706603faf4c"}const Geo={XD:"7da71ca0ad381e90",Un:4*((Math.sqrt(2)-1)/3),xC:null,Aw:w=>{if(w<=0)return 0;let t=Geo.xC;if(t===null){t=[];for(let i=0;i<=2e3;i++)t[i]=Math.sqrt(i);Geo.xC=t}if(w<1){const i=1/w;return i<=2e3?1/t[i|0]:Math.sqrt(w)}else return w<=2e3?t[w|0]:Math.sqrt(w)},p:(w,t)=>{const i=w-t;return i<.5&&i>-.5},q:(w,t)=>{const i=w-t;return i<5e-8&&i>-5e-8},zi:(w,t,i,e,s,n,o)=>{s<=0&&(s=1e-6);let r=0,l=0,h=0,a=0;if(wu-d)if(w-i>s||i-w>s){const g=(e-t)/(i-w)*(n-w)+t;if(g-s<=o&&o<=g+s)return!0}else return!0;else if(t-e>s||e-t>s){const g=(i-w)/(e-t)*(o-t)+w;if(g-s<=n&&n<=g+s)return!0}else return!0}return!1},Lw:(w,t,i,e,s,n,o,r,l,h,a,f)=>{if(!Geo.zi(w,t,o,r,f,i,e)||!Geo.zi(w,t,o,r,f,s,n)){const c=(w+i)/2,u=(t+e)/2,d=(i+s)/2,m=(e+n)/2,g=(s+o)/2,p=(n+r)/2,y=(c+d)/2,x=(u+m)/2,k=(d+g)/2,b=(m+p)/2,S=(y+k)/2,M=(x+b)/2;return Geo.Lw(w,t,c,u,y,x,S,M,l,h,a,f)||Geo.Lw(S,M,k,b,g,p,o,r,l,h,a,f)}else return Geo.zi(w,t,o,r,f,h,a)},bC:(w,t,i,e,s,n,o,r,l)=>{const h=(w+i)/2,a=(t+e)/2,f=(i+s)/2,c=(e+n)/2,u=(s+o)/2,d=(n+r)/2,m=(h+f)/2,g=(a+c)/2,p=(f+u)/2,y=(c+d)/2;return l.e((m+p)/2,(g+y)/2),l},YD:(w,t,i,e,s,n,o,r)=>{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,f=(e+n)/2,c=(s+o)/2,u=(n+r)/2,d=(l+a)/2,m=(h+f)/2,g=(a+c)/2,p=(f+u)/2;return Point.direction(d,m,g,p)},mu:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.zi(w,t,o,r,l,i,e)||!Geo.zi(w,t,o,r,l,s,n)){const a=(w+i)/2,f=(t+e)/2,c=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+c)/2,p=(f+u)/2,y=(c+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.mu(w,t,a,f,g,p,k,b,l,h),Geo.mu(k,b,y,x,d,m,o,r,l,h)}else h.unionNoCheck(w,t,0,0),h.unionNoCheck(o,r,0,0);return h},Gn:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.zi(w,t,o,r,l,i,e)||!Geo.zi(w,t,o,r,l,s,n)){const a=(w+i)/2,f=(t+e)/2,c=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+c)/2,p=(f+u)/2,y=(c+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.Gn(w,t,a,f,g,p,k,b,l,h),Geo.Gn(k,b,y,x,d,m,o,r,l,h)}else h.length===0&&(h.push(w),h.push(t)),h.push(o),h.push(r);return h},qk:(w,t,i,e,s,n,o,r,l,h)=>{if(Geo.zi(w,t,s,n,h,i,e))return Geo.zi(w,t,s,n,h,r,l);{const a=(w+i)/2,f=(t+e)/2,c=(i+s)/2,u=(e+n)/2,d=(a+c)/2,m=(f+u)/2;return Geo.qk(w,t,a,f,d,m,o,r,l,h)||Geo.qk(d,m,c,u,s,n,o,r,l,h)}},nE:(w,t,i,e,s,n,o)=>{const r=(w+i)/2,l=(t+e)/2,h=(i+s)/2,a=(e+n)/2;return o.e((r+h)/2,(l+a)/2),o},jk:(w,t,i,e,s,n,o,r)=>{if(Geo.zi(w,t,s,n,o,i,e))r.unionNoCheck(w,t,0,0),r.unionNoCheck(s,n,0,0);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,f=(e+n)/2,c=(l+a)/2,u=(h+f)/2;Geo.jk(w,t,l,h,c,u,o,r),Geo.jk(c,u,a,f,s,n,o,r)}return r},jg:(w,t,i,e,s,n,o,r)=>{if(Geo.zi(w,t,s,n,o,i,e))r.length===0&&(r.push(w),r.push(t)),r.push(s),r.push(n);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,f=(e+n)/2,c=(l+a)/2,u=(h+f)/2;Geo.jg(w,t,l,h,c,u,o,r),Geo.jg(c,u,a,f,s,n,o,r)}return r},Wg:(w,t,i,e,s,n,o,r,l,h,a,f,c,u)=>{if(!Geo.zi(w,t,o,r,c,i,e)||!Geo.zi(w,t,o,r,c,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,S=(g+y)/2,M=(p+x)/2,A=(k+S)/2,C=(b+M)/2;let P=1/0,N=!1,T=0,L=0;if(Geo.Wg(w,t,d,m,k,b,A,C,l,h,a,f,c,u)){const D=(u.x-l)*(u.x-l)+(u.y-h)*(u.y-h);D{let u=0;if(!Geo.zi(w,t,o,r,c,i,e)||!Geo.zi(w,t,o,r,c,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,S=(g+y)/2,M=(p+x)/2,A=(k+S)/2,C=(b+M)/2;u+=Geo.vg(w,t,d,m,k,b,A,C,l,h,a,f,c),u+=Geo.vg(A,C,S,M,y,x,o,r,l,h,a,f,c)}else{const d=(w-o)*(h-f)-(t-r)*(l-a);if(d===0)return u;const m=((w*r-t*o)*(l-a)-(w-o)*(l*f-h*a))/d,g=((w*r-t*o)*(h-f)-(t-r)*(l*f-h*a))/d;if(m>=a)return u;let p=0,y=0;if((l>a?l-a:a-l)<(h>f?h-f:f-h)){if(ty)return u}else if(wy)return u;d>0?u++:d<0&&u--}return u},xl:(w,t,i,e,s,n,o)=>{if(Geo.q(w,i)){let r=0,l=0;tl?(o.e(w,l),!1):(o.e(w,h),!0)}else if(Geo.q(t,e)){let r=0,l=0;wl?(o.e(l,t),!1):(o.e(h,t),!0)}else{const r=(i-w)*(i-w)+(e-t)*(e-t),l=((w-s)*(w-i)+(t-n)*(t-e))/r;if(l<-5e-6)return o.e(w,t),!1;if(l>1.000005)return o.e(i,e),!1;{const h=w+l*(i-w),a=t+l*(e-t);return o.e(h,a),!0}}},Hn:(w,t,i,e,s,n,o,r,l)=>{if(Geo.p(w,i)&&Geo.p(t,e))return l.e(w,t),!1;if(Geo.q(s,o)){if(Geo.q(w,i))return Geo.xl(w,t,i,e,s,n,l),!1;{const a=(e-t)/(i-w)*(s-w)+t;return Geo.xl(w,t,i,e,s,a,l)}}else{const h=(r-n)/(o-s);if(Geo.q(w,i)){const a=h*(w-s)+n;let f=0,c=0;return tc?(l.e(w,c),!1):(l.e(w,a),!0)}else{const a=(e-t)/(i-w);if(Geo.q(h,a))return Geo.xl(w,t,i,e,s,n,l),!1;{const f=(a*w-h*s+n-t)/(a-h);if(Geo.q(a,0)){let c=0,u=0;return wu?(l.e(u,t),!1):(l.e(f,t),!0)}else{const c=a*(f-w)+t;return Geo.xl(w,t,i,e,f,c,l)}}}}},oE:(w,t,i,e,s)=>Geo.Hn(i.x,i.y,e.x,e.y,w.x,w.y,t.x,t.y,s),rE:(w,t,i,e,s,n,o,r,l,h)=>{let a=1/0;function f(S,M){const A=(S-w)*(S-w)+(M-t)*(M-t);Aw?i-w:w-i)<.5){const S=1-(i-k)*(i-k)/(y*y);if(S<0)return l;const M=Math.sqrt(S),A=x*M+b,C=-x*M+b;f(i,A),f(i,C)}else{const S=(e-t)/(i-w),M=1/(y*y)+S*S/(x*x),A=2*S*(t-S*w)/(x*x)-2*S*b/(x*x)-2*k/(y*y),C=2*S*w*b/(x*x)-2*t*b/(x*x)+b*b/(x*x)+k*k/(y*y)-1+(t-S*w)*(t-S*w)/(x*x),P=A*A-4*M*C;if(P<0)return l;const N=Math.sqrt(P),T=(-A+N)/(2*M);f(T,S*T-S*w+t);const L=(-A-N)/(2*M);f(L,S*L-S*w+t)}return l},bl:(w,t,i,e,s,n,o,r,l)=>{let h=1e21,a=w,f=t;if(Geo.Hn(w,t,w,e,s,n,o,r,l)){const c=(l.x-s)*(l.x-s)+(l.y-n)*(l.y-n);cGeo.dC(w.x,w.y,w.width,w.height,t.x,t.y,i.x,i.y),dC:(w,t,i,e,s,n,o,r)=>{const l=w,h=w+i,a=t,f=t+e;if(s===o){let c=0,u=0;return n=a}if(n===r){let c=0,u=0;return s=l}return!!(Rect.contains(w,t,i,e,s,n)||Rect.contains(w,t,i,e,o,r)||Geo.du(l,a,h,a,s,n,o,r)||Geo.du(h,a,h,f,s,n,o,r)||Geo.du(h,f,l,f,s,n,o,r)||Geo.du(l,f,l,a,s,n,o,r))},du:(w,t,i,e,s,n,o,r)=>w===i&&t===e&&s===o&&n===r?w===s&&t===n:Geo.uu(w,t,i,e,s,n)*Geo.uu(w,t,i,e,o,r)<=0&&Geo.uu(s,n,o,r,w,t)*Geo.uu(s,n,o,r,i,e)<=0,uu:(w,t,i,e,s,n)=>{const o=i-w,r=e-t;let l=s-w,h=n-t,a=l*r-h*o;return a===0&&(a=l*o+h*r,a>0&&(l-=o,h-=r,a=l*o+h*r,a<0&&(a=0))),a},Jg:w=>(w<0&&(w+=360),w>=360&&(w-=360),w),kC:(w,t,i,e,s,n)=>{const o=Math.PI;n||(e=e*(o/180),s=s*(o/180));const r=e>s?-1:1,l=1e-5,h=o*2,a=[],f=o/2;let c=e,u=Math.min(h,Math.abs(s-e));if(ul;){const d=c+r*Math.min(u,f);a.push(Geo.KD(i,c,d,w,t)),u-=Math.abs(d-c),c=d}return a},KD:(w,t,i,e,s)=>{const n=(i-t)/2,o=w*Math.cos(n),r=w*Math.sin(n),l=o,h=-r,a=l*l+h*h,f=a+l*o+h*r,c=4/3*(Math.sqrt(2*a*f)-f)/(l*r-h*o),u=l-c*h,d=h+c*l,m=u,g=-d,p=n+t,y=Math.cos(p),x=Math.sin(p);return[e+w*Math.cos(t),s+w*Math.sin(t),e+u*y-d*x,s+u*x+d*y,e+m*y-g*x,s+m*x+g*y,e+w*Math.cos(i),s+w*Math.sin(i)]},Hg:(w,t,i,e,s,n,o)=>{const r=s,l=n,h=Math.floor((w-i)/r)*r+i,a=Math.floor((t-e)/l)*l+e;let f=h;h+r-w{let i=Math.max(w,t),e=Math.min(w,t),s=1,n=1;do s=i%e,n=e,i=e,e=s;while(s>0);return n},UD:(w,t,i,e)=>{const s=i<0,n=e<0;let o=0,r=0,l=0;w{let o=0;if(e>0)if(i>0){const r=w*w,l=t*t,h=w*i,a=t*e;let f=-l+a,c=-l+Math.sqrt(h*h+a*a),u=f;const d=9999999999;for(let p=0;p0)f=u;else if(k<0)c=u;else break}s=r*i/(u+r),n=l*e/(u+l);const m=s-i,g=n-e;o=Math.sqrt(m*m+g*g)}else s=0,n=t,o=Math.abs(e-t);else{const r=w*w-t*t,l=w*i;if(l(w[w.Line=1]="Line",w[w.Rectangle=2]="Rectangle",w[w.Ellipse=3]="Ellipse",w[w.Path=4]="Path",w))(GeometryType||{}),GeometryStretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w))(GeometryStretch||{});class Geometry{l;Qg;_g;af;pu;yu;jn;Wn;vn;st;Pe;Ne;ee;se;Vs;ff;cf;constructor(t){Debug&&arguments.length>1&&Util.n("Geometry constructor can take at most one optional argument, the Geometry type."),GSet.vi(this),this.l=2,t===void 0?t=4:Debug&&Util.tt(t,GeometryType,"GeometryType"),this.st=t,this.Pe=0,this.Ne=0,this.ee=0,this.se=0,t===4?this.Vs=new List:this.Vs=Geometry.Dw,this.Qg=this.Vs.gt,this._g=new Rect().w(),this.af=null,this.pu=null,this.yu=NaN,this.jn=Spot.TopLeft,this.Wn=Spot.BottomRight,this.ff=NaN,this.cf=NaN,this.vn=2}copy(){const t=new Geometry;if(t.l=this.l&-2,t.st=this.st,t.Pe=this.Pe,t.Ne=this.Ne,t.ee=this.ee,t.se=this.se,this.st===4){const i=this.Vs.h,e=t.Vs;for(let s=0;si.toString(t)}fi(t){t in GeometryType?this.type=t:Util.ur(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e;switch(this.type){case 1:return t<0?"M"+this.startX.toString()+" "+this.startY.toString()+"L"+this.endX.toString()+" "+this.endY.toString():"M"+i(this.startX)+" "+i(this.startY)+"L"+i(this.endX)+" "+i(this.endY);case 2:return e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0?"M"+e.x.toString()+" "+e.y.toString()+"H"+e.right.toString()+"V"+e.bottom.toString()+"H"+e.left.toString()+"z":"M"+i(e.x)+" "+i(e.y)+"H"+i(e.right)+"V"+i(e.bottom)+"H"+i(e.left)+"z";case 3:if(e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0){const r=e.left.toString()+" "+(e.y+e.height/2).toString(),l=e.right.toString()+" "+(e.y+e.height/2).toString();return"M"+r+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+l+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+r}else{const r=i(e.left)+" "+i(e.y+e.height/2),l=i(e.right)+" "+i(e.y+e.height/2);return"M"+r+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+l+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+r}case 4:let s="";const n=this.figures.h,o=n.length;for(let r=0;r0&&(s+=" x "),l.isFilled&&(s+="F "),s+=l.toString(t)}return s;default:return GeometryType[this.type]}}static fillPath(t){typeof t!="string"&&Util.Vi(t,"string",Geometry,"fillPath:str");const i=t.split(/[Xx]/),e=i.length;let s="";for(let n=0;n=k-1||o[r+1].match(N)!==null?!0:(u=!1,!1)}function m(){return r++,o[r]}function g(L){let D=parseFloat(m()),F=parseFloat(m());l===l.toLowerCase()&&(D=c.x+D,F=c.y+F),L.e(D,F)}function p(){return g(c),c}function y(){return g(f),f}function x(){const L=h.toLowerCase();return L==="c"||L==="s"||L==="q"||L==="t"?new Point(2*c.x-f.x,2*c.y-f.y):new Point(c.x,c.y)}const k=o.length,b=GeoStream.PC(null);let S=!1,M=!1,A=!1,C=!0,P=null;const N=new RegExp("["+Geometry.tm+"]");for(;!(r>=k-1);){if(h=l,l=m(),l==="")continue;u=!0;let L=!1;switch(l.toUpperCase()){case"X":C=!0,S=!1,M=!1;break;case"M":for(P=p(),b.Ci===null||C===!0?(b.wu(P.x,P.y,S,!1,!M,A),C=!1):b.HD(P.x,P.y),a.c(c);!d();)P=p(),b.yr(P.x,P.y);break;case"L":for(;!d();)P=p(),b.yr(P.x,P.y);u&&(L=!0);break;case"H":for(;!d();)c.e((l===l.toLowerCase()?c.x:0)+parseFloat(m()),c.y),b.yr(c.x,c.y);break;case"V":for(;!d();)c.e(c.x,(l===l.toLowerCase()?c.y:0)+parseFloat(m())),b.yr(c.x,c.y);u&&(L=!0);break;case"C":for(;!d();){const D=new Point;g(D);const F=y(),R=p();b.wr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(L=!0);break;case"S":for(;!d();){const D=x(),F=y(),R=p();b.wr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(L=!0);break;case"Q":for(;!d();){const D=y(),F=p();b.Fw(D.x,D.y,F.x,F.y)}u&&(L=!0);break;case"T":for(;!d();){const D=x();f.c(D);const F=p();b.Fw(D.x,D.y,F.x,F.y),f.c(F)}u&&(L=!0);break;case"B":for(;!d();){const D=parseFloat(m()),F=parseFloat(m());let R=parseFloat(m()),I=parseFloat(m());const O=parseFloat(m());let B=O,K=!1;d()||(B=parseFloat(m()),d()||(K=parseFloat(m())!==0)),l===l.toLowerCase()&&(R+=c.x,I+=c.y),b.qD(D,F,R,I,O,B,K)}u&&(L=!0);break;case"A":for(;!d();){const D=Math.abs(parseFloat(m())),F=Math.abs(parseFloat(m())),R=parseFloat(m());let I=!1,O=!1,B=0,K=0;const V=m();V.length===1?(I=!!parseFloat(V),O=!!parseFloat(m()),B=parseFloat(m()),K=parseFloat(m())):V.length===2?(I=!!parseFloat(V[0]),O=!!parseFloat(V[1]),B=parseFloat(m()),K=parseFloat(m())):(I=!!parseFloat(V[0]),O=!!parseFloat(V[1]),B=parseFloat(V.slice(2)),K=parseFloat(m())),l===l.toLowerCase()&&(B=c.x+B,K=c.y+K),c.e(B,K),b.jD(D,F,R,I,O,B,K)}u&&(L=!0);break;case"Z":b.WD(),c.c(a);break;case"F":{let D="",F=1;for(;o[r+F];){if(o[r+F]==="0"){A=!0,F++;continue}if(o[r+F].match(/[Uu]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?S=!0:b.vD();break}case"U":{let D="",F=1;for(;o[r+F];){if(o[r+F].match(/[Ff]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?M=!0:b.JD(!1);break}default:if(l==="0"||l==="1")break;Util.at("Unknown geometry command: "+l);break}if(L){Util.at(`Bad geometry command: ${l}, next token: ${m()}, -string: ${t}`);break}}const T=b.im;if(GeoStream.NC(b),i){const L=T.figures.iterator;for(;L.next();){const D=L.value;D.isFilled=!0}}return T}static CC(t,i){const e=t.length,s=Point.a();for(let n=0;n=t)return 0;if((n>r?n-r:r-n)<(o>l?o-l:l-o)){if(ol)return 0}else if(fo)return 0}else if(nr)return 0}else if(an)return 0;return h>0?1:-1}LC(t,i,e){const s=this.figures.h,n=s.length;for(let o=0;o1&&(t=1),i===void 0&&(i=new Point),this.type===1)return i.e(this.startX+t*(this.endX-this.startX),this.startY+t*(this.endY-this.startY)),i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[c*2],y=g[c*2+1],x=g[c*2+2],k=g[c*2+3];return i.e(p+(x-p)*m,y+(k-y)*m),i}l+=u}}return i}getAngleAlongPath(t){if(t<0?t=0:t>1&&(t=1),this.type===1)return Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI;const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=i.length,o=s*t;let r=0;for(let l=0;l=o){const u=i[l],d=u[f*2],m=u[f*2+1],g=u[f*2+2],p=u[f*2+3];return Math.abs(g-d)<1&&Math.abs(p-m)<1?0:Math.abs(g-d)<1?p-m>=0?90:270:Math.abs(p-m)<1?g-d>=0?0:180:Math.atan2(p-m,g-d)*180/Math.PI}r+=c}}return NaN}getPointAndAngleAlongPath(t,i){if(t<0?t=0:t>1&&(t=1),i===void 0&&(i=[]),i.length=3,this.type===1)return i[0]=this.startX+t*(this.endX-this.startX),i[1]=this.startY+t*(this.endY-this.startY),i[2]=Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI,i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[c*2],y=g[c*2+1],x=g[c*2+2],k=g[c*2+3];i[0]=p+(x-p)*m,i[1]=y+(k-y)*m;let b;return Math.abs(x-p)<1&&Math.abs(k-y)<1?b=0:Math.abs(x-p)<1?b=k-y>=0?90:270:Math.abs(k-y)<1?b=x-p>=0?0:180:b=Math.atan2(k-y,x-p)*180/Math.PI,i[2]=b,i}l+=u}}return i}getFractionForPoint(t){if(this.type===1){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=t.x,r=t.y;let l=0,h=0;if(i===s)return e=h?h===e?0:1:Math.abs(r-e)/(h-l);if(e===n)return i=h?h===i?0:1:Math.abs(o-i)/(h-l);{const a=(s-i)*(s-i)+(n-e)*(n-e),f=Point.a();Geo.xl(i,e,s,n,o,r,f);const c=f.x,u=f.y;return Point.o(f),Math.sqrt(((c-i)*(c-i)+(u-e)*(u-e))/a)}}}else if(this.type===2){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=s-i,r=n-e,l=o*2+r*2;let h=t.x,a=t.y;h=Math.min(Math.max(h,i),s),a=Math.min(Math.max(a,e),n);const f=Math.abs(h-i),c=Math.abs(h-s),u=Math.abs(a-e),d=Math.abs(a-n),m=Math.min(f,c,u,d);if(m===u)return h/l;if(m===c)return(o+a)/l;if(m===d)return(o*2+r-h)/l;if(m===f)return(o*2+r*2-a)/l}}else{const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=Point.a();let o=1/0,r=0,l=0;const h=i.length;let a=0,f=0;for(let u=0;u1?1:c}return 0}get flattenedSegments(){return this.TC(),this.af}TC(){if(this.af===null){const t=this.af=[],i=this.pu=[];this.QD(t,i)}}get flattenedLengths(){return this.TC(),this.pu}get flattenedTotalLength(){let t=this.yu;if(isNaN(t)){if(this.type===1){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=Math.sqrt(i*i+e*e)}else if(this.type===2){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=i*2+e*2}else{const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=4&&(t.push(e),i.push(this.Zk(e))),e=[],e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY,h=r,a=l;break;case 2:e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY;break;case 3:Geo.Gn(r,l,d.point1X,d.point1Y,d.point2X,d.point2Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 4:Geo.jg(r,l,d.point1X,d.point1Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 5:{const m=d.To(o),g=m.length;if(g===0){e.push(d.centerX),e.push(d.centerY),r=d.centerX,l=d.centerY;break}for(let p=0;p=4&&(t.push(e),i.push(this.Zk(e)))}}}get type(){return this.st}set type(t){this.st!==t&&(Debug&&Util.tt(t,GeometryType,"GeometryType"),this.f&&Util.F(this,t),this.st=t,t===4?this.Vs=new List:(Geometry.Dw===null&&(Geometry.Dw=new List().w()),this.Vs=Geometry.Dw),this.Nt=!0)}get startX(){return this.Pe}set startX(t){this.Pe!==t&&(Debug&&Util.r(t,Geometry,"startX"),this.f&&Util.F(this,t),this.Pe=t,this.Nt=!0)}get startY(){return this.Ne}set startY(t){this.Ne!==t&&(Debug&&Util.r(t,Geometry,"startY"),this.f&&Util.F(this,t),this.Ne=t,this.Nt=!0)}get endX(){return this.ee}set endX(t){this.ee!==t&&(Debug&&Util.r(t,Geometry,"endX"),this.f&&Util.F(this,t),this.ee=t,this.Nt=!0)}get endY(){return this.se}set endY(t){this.se!==t&&(Debug&&Util.r(t,Geometry,"endY"),this.f&&Util.F(this,t),this.se=t,this.Nt=!0)}get figures(){return this.Vs}set figures(t){this.Vs!==t&&(Debug&&Util.s(t,List,Geometry,"figures"),this.f&&Util.F(this,t),this.Vs=t,this.Nt=!0)}add(t){return this.Vs.add(t),this}setSpots(t,i,e,s,n,o,r,l){return this.f&&Util.F(this),this.jn=new Spot(t,i,n,o).w(),this.Wn=new Spot(e,s,r,l).w(),this}get spot1(){return this.jn}set spot1(t){Debug&&Util.s(t,Spot,Geometry,"spot1"),this.f&&Util.F(this,t),this.jn=t.L()}get spot2(){return this.Wn}set spot2(t){Debug&&Util.s(t,Spot,Geometry,"spot2"),this.f&&Util.F(this,t),this.Wn=t.L()}get defaultStretch(){return this.vn}set defaultStretch(t){this.vn=t}get bounds(){return this.Wk()&&this.Rw(),this._g}}Geometry.stringify=Geometry.stringify,Geometry.stringifyFixed=Geometry.stringifyFixed,Geometry.fillPath=Geometry.fillPath,Geometry.parse=Geometry.parse;class PathFigure{l;Pe;Ne;uf;em;Ue;constructor(t,i,e,s,n){e===void 0&&(e=!0),s===void 0&&(s=!0),n===void 0&&(n=!1),this.l=2|(e?4:0)|(s?8:0)|(n?16:0),t!==void 0?(Debug&&Util.r(t,PathFigure,"sx"),this.Pe=t):this.Pe=0,i!==void 0?(Debug&&Util.r(i,PathFigure,"sy"),this.Ne=i):this.Ne=0,this.uf=new List,this.em=this.uf.gt,this.Ue=null}copy(){const t=new PathFigure;t.l=this.l&-2,t.Pe=this.Pe,t.Ne=this.Ne;const i=this.uf.h,e=i.length,s=t.uf;for(let n=0;no===0?"0":o.toFixed(t);i="M"+n(this.startX)+" "+n(this.startY)}const e=this.segments.h,s=e.length;for(let n=0;n(w[w.Move=1]="Move",w[w.Line=2]="Line",w[w.Bezier=3]="Bezier",w[w.QuadraticBezier=4]="QuadraticBezier",w[w.Arc=5]="Arc",w[w.SvgArc=6]="SvgArc",w))(SegmentType||{});class PathSegment{st;l;ee;se;dn;kl;Sl;xr;Bs;constructor(t,i,e,s,n,o,r,l){if(GSet.vi(this),t===void 0?t=2:Debug&&Util.tt(t,SegmentType,"SegmentType"),this.st=t,this.l=2,i!==void 0?(Debug&&Util.r(i,PathSegment,"ex"),this.ee=i):this.ee=0,e!==void 0?(Debug&&Util.r(e,PathSegment,"ey"),this.se=e):this.se=0,s===void 0&&(s=0),n===void 0&&(n=0),o===void 0&&(o=0),r===void 0&&(r=0),t===6){let h=o;h=h%360,h<0&&(h+=360),this.dn=h,this.kl=0,Debug&&Util.r(s,PathSegment,"x1"),this.Sl=Math.max(s,0),Debug&&Util.r(n,PathSegment,"y1"),this.xr=Math.max(n,0),typeof r=="boolean"?r&&(this.isLargeArc=!0):typeof r=="number"&&r&&(this.isLargeArc=!0),l&&(this.isClockwiseArc=!0)}else Debug&&Util.r(s,PathSegment,"x1"),this.dn=s,Debug&&Util.r(n,PathSegment,"y1"),this.kl=n,Debug&&Util.r(o,PathSegment,"x2"),t===5&&(o=Math.max(o,0)),this.Sl=o,typeof r=="number"?(t===5&&(r=Math.max(r,0)),this.xr=r):this.xr=0;this.Bs=null}copy(){const t=new PathSegment;return t.st=this.st,t.l=this.l&-2,t.ee=this.ee,t.se=this.se,t.dn=this.dn,t.kl=this.kl,t.Sl=this.Sl,t.xr=this.xr,t}equalsApprox(t){if(!(t instanceof PathSegment)||this.type!==t.type||this.isClosed!==t.isClosed)return!1;switch(this.type){case 1:case 2:return Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY);case 3:return Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY)&&Geo.p(this.point1X,t.point1X)&&Geo.p(this.point1Y,t.point1Y)&&Geo.p(this.point2X,t.point2X)&&Geo.p(this.point2Y,t.point2Y);case 4:return Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY)&&Geo.p(this.point1X,t.point1X)&&Geo.p(this.point1Y,t.point1Y);case 5:return Geo.p(this.startAngle,t.startAngle)&&Geo.p(this.sweepAngle,t.sweepAngle)&&Geo.p(this.centerX,t.centerX)&&Geo.p(this.centerY,t.centerY)&&Geo.p(this.radiusX,t.radiusX)&&Geo.p(this.radiusY,t.radiusY);case 6:return this.isClockwiseArc===t.isClockwiseArc&&this.isLargeArc===t.isLargeArc&&Geo.p(this.xAxisRotation,t.xAxisRotation)&&Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY)&&Geo.p(this.radiusX,t.radiusX)&&Geo.p(this.radiusY,t.radiusY);default:return!1}}fi(t){t in SegmentType?this.type=t:Util.ur(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e="";switch(this.type){case 1:t<0?e="M"+this.endX.toString()+" "+this.endY.toString():e="M"+i(this.endX)+" "+i(this.endY);break;case 2:t<0?e="L"+this.endX.toString()+" "+this.endY.toString():e="L"+i(this.endX)+" "+i(this.endY);break;case 3:t<0?e="C"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.point2X.toString()+" "+this.point2Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="C"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.point2X)+" "+i(this.point2Y)+" "+i(this.endX)+" "+i(this.endY);break;case 4:t<0?e="Q"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="Q"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.endX)+" "+i(this.endY);break;case 5:t<0?e="B"+this.startAngle.toString()+" "+this.sweepAngle.toString()+" "+this.centerX.toString()+" "+this.centerY.toString()+" "+this.radiusX.toString()+" "+this.radiusY.toString():e="B"+i(this.startAngle)+" "+i(this.sweepAngle)+" "+i(this.centerX)+" "+i(this.centerY)+" "+i(this.radiusX)+" "+i(this.radiusY);break;case 6:t<0?e="A"+this.radiusX.toString()+" "+this.radiusY.toString()+" "+this.xAxisRotation.toString()+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+this.endX.toString()+" "+this.endY.toString():e="A"+i(this.radiusX)+" "+i(this.radiusY)+" "+i(this.xAxisRotation)+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+i(this.endX)+" "+i(this.endY);break;default:e=SegmentType[this.type]}return e+(this.isClosed?"z":"")}static Move=1;static Line=2;static Bezier=3;static QuadraticBezier=4;static Arc=5;static SvgArc=6;get f(){return(this.l&1)!==0}set f(t){t?this.l|=1:this.l&=-2}get Nt(){return(this.l&2)!==0}set Nt(t){t?this.l|=2:this.l&=-3}w(){return this.f=!0,this}ct(){return this.f=!1,this}close(){return this.isClosed=!0,this}To(t){if(this.Bs!==null&&t.Nt===!1)return this.Bs;const i=this.radiusX;let e=this.radiusY;if(e===void 0&&(e=i),i===0||e===0)return this.Bs=[],this.Bs;const s=this.dn,n=this.kl,o=Geo.kC(0,0,i1&&(o*=Math.sqrt(p),r*=Math.sqrt(p));let y=(h===a?-1:1)*Math.sqrt((o*o*r*r-o*o*g*g-r*r*m*m)/(o*o*g*g+r*r*m*m));isNaN(y)&&(y=0);let x=y*o*g/r,k=y*-r*m/o;isNaN(x)&&(x=0),isNaN(k)&&(k=0);const b=(s+f)/2+u*x-d*k,S=(n+c)/2+d*x+u*k,M=(X,z)=>Math.sqrt(X*X+z*z),A=(X,z,G,q)=>(X*G+z*q)/(M(X,z)*M(G,q)),C=(X,z,G,q)=>(X*q=1&&(F=0),!a&&F>0&&(F=F-2*Math.PI),a&&F<0&&(F=F+2*Math.PI);const I=o>r?o:r,O=o>r?1:o/r,B=o>r?r/o:1,K=Geo.kC(0,0,I,P,P+F,!0),V=Transform.a();return V.Bi(),V.Es(b,S),V.ms(this.dn,0,0),V.lt(O,B),Geometry.CC(K,V),Transform.o(V),this.Bs=K,this.Bs}get isClosed(){return(this.l&8)!==0}set isClosed(t){this.isClosed!==t&&(t?this.l|=8:this.l&=-9,this.Nt=!0)}get type(){return this.st}set type(t){Debug&&Util.tt(t,SegmentType,"SegmentType"),this.f&&Util.F(this,t),this.st=t,this.Nt=!0}get endX(){return this.ee}set endX(t){Debug&&Util.r(t,PathSegment,"endX"),this.f&&Util.F(this,t),this.ee=t,this.Nt=!0}get endY(){return this.se}set endY(t){Debug&&Util.r(t,PathSegment,"endY"),this.f&&Util.F(this,t),this.se=t,this.Nt=!0}get point1X(){return this.dn}set point1X(t){Debug&&Util.r(t,PathSegment,"point1X"),this.f&&Util.F(this,t),this.dn=t,this.Nt=!0}get point1Y(){return this.kl}set point1Y(t){Debug&&Util.r(t,PathSegment,"point1Y"),this.f&&Util.F(this,t),this.kl=t,this.Nt=!0}get point2X(){return this.Sl}set point2X(t){Debug&&Util.r(t,PathSegment,"point2X"),this.f&&Util.F(this,t),this.Sl=t,this.Nt=!0}get point2Y(){return this.xr}set point2Y(t){Debug&&Util.r(t,PathSegment,"point2Y"),this.f&&Util.F(this,t),this.xr=t,this.Nt=!0}get centerX(){return this.dn}set centerX(t){Debug&&Util.r(t,PathSegment,"centerX"),this.f&&Util.F(this,t),this.dn=t,this.Nt=!0}get centerY(){return this.kl}set centerY(t){Debug&&Util.r(t,PathSegment,"centerY"),this.f&&Util.F(this,t),this.kl=t,this.Nt=!0}get radiusX(){return this.Sl}set radiusX(t){Debug&&Util.r(t,PathSegment,"radiusX"),t<0&&Util.G(t,">= zero",PathSegment,"radiusX"),this.f&&Util.F(this,t),this.Sl=t,this.Nt=!0}get radiusY(){return this.xr}set radiusY(t){Debug&&Util.r(t,PathSegment,"radiusY"),t<0&&Util.G(t,">= zero",PathSegment,"radiusY"),this.f&&Util.F(this,t),this.xr=t,this.Nt=!0}get startAngle(){return this.ee}set startAngle(t){Debug&&Util.r(t,PathSegment,"startAngle"),this.f&&Util.F(this,t),t=t%360,t<0&&(t+=360),this.ee=t,this.Nt=!0}get sweepAngle(){return this.se}set sweepAngle(t){Debug&&Util.r(t,PathSegment,"sweepAngle"),this.f&&Util.F(this,t),t>360&&(t=360),t<-360&&(t=-360),this.se=t,this.Nt=!0}get isClockwiseArc(){return(this.l&4)!==0}set isClockwiseArc(t){this.f&&Util.F(this,t),t?this.l|=4:this.l&=-5,this.Nt=!0}get isLargeArc(){return(this.l&16)!==0}set isLargeArc(t){this.f&&Util.F(this,t),t?this.l|=16:this.l&=-17,this.Nt=!0}get xAxisRotation(){return this.dn}set xAxisRotation(t){Debug&&Util.r(t,PathSegment,"xAxisRotation"),this.f&&Util.F(this,t),t=t%360,t<0&&(t+=360),this.dn=t,this.Nt=!0}}class InputEvent{b;Ow;Ew;sm;nm;om;rm;lm;hm;am;fm;cm;um;dm;Do;gm;mm;pm;Ce;constructor(){this.b=null,this.Ow=new Point(0,0).w(),this.Ew=new Point(0,0).w(),this.sm=0,this.nm=0,this.om=1,this.rm="",this.lm="",this.hm=!1,this.am=!1,this.fm=0,this.cm=0,this.um=!1,this.dm=!1,this.Do=!1,this.gm=null,this.mm=0,this.pm=null,this.Ce=null}copy(){const t=new InputEvent;return this.clone(t)}clone(t){return t.b=this.b,t.Ow.c(this.viewPoint),t.Ew.c(this.documentPoint),t.sm=this.sm,t.nm=this.nm,t.om=this.om,t.rm=this.rm,t.lm=this.lm,t.hm=this.hm,t.am=this.am,t.fm=this.fm,t.cm=this.cm,t.um=this.um,t.dm=this.dm,t.Do=this.Do,t.gm=this.gm,t.mm=this.mm,t.pm=this.pm,t.Ce=this.Ce,t}toString(){let t="^";return this.modifiers!==0&&(t+="M:"+this.modifiers),this.button!==0&&(t+="B:"+this.button),this.key!==""&&(t+="K:"+this.key),this.clickCount!==0&&(t+="C:"+this.clickCount),this.delta!==0&&(t+="D:"+this.delta),this.handled&&(t+="h"),this.bubbles&&(t+="b"),this.documentPoint!==null&&(t+="@"+this.documentPoint.toString()),t}get diagram(){return this.b}set diagram(t){this.b=t}get viewPoint(){return this.Ow}set viewPoint(t){Util.s(t,Point,InputEvent,"viewPoint"),this.Ow.c(t)}get documentPoint(){return this.Ew}set documentPoint(t){Util.s(t,Point,InputEvent,"documentPoint"),this.Ew.c(t)}getMultiTouchViewPoint(t,i){const e=this.diagram;return e===null||e.DC(this.event,t,i),i}getMultiTouchDocumentPoint(t,i){const e=this.diagram;return e===null||(e.DC(this.event,t,i),i.c(e.transformViewToDoc(i))),i}get modifiers(){return this.sm}set modifiers(t){this.sm=t}get button(){return this.nm}set button(t){if(this.nm=t,this.event===null)switch(t){case 0:this.buttons=1;return;case 1:this.buttons=4;return;case 2:this.buttons=2;return}}get buttons(){return this.om}set buttons(t){this.om=t}get key(){return this.rm}set key(t){this.rm=t}get code(){return this.lm}set code(t){this.lm=t}get down(){return this.hm}set down(t){this.hm=t}get up(){return this.am}set up(t){this.am=t}get clickCount(){return this.fm}set clickCount(t){this.fm=t}get delta(){return this.cm}set delta(t){this.cm=t}get isMultiTouch(){return this.um}set isMultiTouch(t){this.um=t}get handled(){return this.dm}set handled(t){this.dm=t}get bubbles(){return this.Do}set bubbles(t){this.Do=t}get event(){return this.gm}set event(t){this.gm=t}get isTouchEvent(){const t=this.event;return t===null?!1:t.pointerType==="touch"||t.pointerType==="pen"}get timestamp(){return this.mm}set timestamp(t){this.mm=t}get targetDiagram(){return this.pm}set targetDiagram(t){this.pm=t}get targetObject(){return this.Ce}set targetObject(t){this.Ce=t}get control(){return(this.modifiers&1)!==0}set control(t){this.modifiers=t?this.modifiers|1:this.modifiers&-2}get shift(){return(this.modifiers&4)!==0}set shift(t){this.modifiers=t?this.modifiers|4:this.modifiers&-5}get alt(){return(this.modifiers&2)!==0}set alt(t){this.modifiers=t?this.modifiers|2:this.modifiers&-3}get meta(){return(this.modifiers&8)!==0}set meta(t){this.modifiers=t?this.modifiers|8:this.modifiers&-9}get left(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===0:(this.buttons&1)!==0}set left(t){t?this.buttons|=1:this.buttons&=-2}get right(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===2:(this.buttons&2)!==0}set right(t){t?this.buttons|=2:this.buttons&=-3}get middle(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===1:(this.buttons&4)!==0}set middle(t){t?this.buttons|=4:this.buttons&=-5}get commandKey(){const t=this.code,i=this.key;return"cxvyzagCXVYZAG".includes(i)?i.toLowerCase():t==="KeyC"?"c":t==="KeyX"?"x":t==="KeyV"?"v":t==="KeyY"?"y":t==="KeyZ"?"z":t==="KeyA"?"a":t==="KeyG"?"g":t!==""?t:i}}class DiagramEvent{b;Tt;ym;wm;constructor(){this.b=null,this.Tt="",this.ym=null,this.wm=null}copy(){const t=new DiagramEvent;return t.b=this.b,t.Tt=this.Tt,t.ym=this.ym,t.wm=this.wm,t}toString(){let t="*"+this.name;return this.subject!==null&&(t+=":"+this.subject.toString()),this.parameter!==null&&(t+="("+this.parameter.toString()+")"),t}get diagram(){return this.b}set diagram(t){this.b=t}get name(){return this.Tt}set name(t){this.Tt=t}get subject(){return this.ym}set subject(t){this.ym=t}get parameter(){return this.wm}set parameter(t){this.wm=t}}var ChangeType=(w=>(w[w.Transaction=1]="Transaction",w[w.Property=2]="Property",w[w.Insert=3]="Insert",w[w.Remove=4]="Remove",w))(ChangeType||{});class ChangedEvent{xu;xm;gn;Ai;b;bu;df;gf;mf;pf;constructor(){this.xu=2,this.xm="",this.gn="",this.Ai=null,this.b=null,this.bu=null,this.df=null,this.gf=null,this.mf=null,this.pf=null}static Transaction=1;static Property=2;static Insert=3;static Remove=4;clear(){this.Ai=null,this.b=null,this.bu=null,this.df=null,this.gf=null,this.mf=null,this.pf=null}copy(){const t=new ChangedEvent;t.xu=this.xu,t.xm=this.xm,t.gn=this.gn,t.Ai=this.Ai,t.b=this.b,t.bu=this.bu;let i=this.df;return Util.Mt(i)&&typeof i.copyFrozen=="function"?t.df=i.copyFrozen():t.df=i,i=this.gf,Util.Mt(i)&&typeof i.copyFrozen=="function"?t.gf=i.copyFrozen():t.gf=i,i=this.mf,Util.Mt(i)&&typeof i.copyFrozen=="function"?t.mf=i.copyFrozen():t.mf=i,i=this.pf,Util.Mt(i)&&typeof i.copyFrozen=="function"?t.pf=i.copyFrozen():t.pf=i,t}fi(t){t in ChangeType?this.change=t:Util.ur(this,t)}toString(){let t="";return this.change===1?t+="* ":this.change===2?t+=this.model!==null?"!m":"!d":t+=(this.model!==null?"!m":"!d")+this.change,this.propertyName&&typeof this.propertyName=="string"&&(t+=" "+this.propertyName),this.modelChange&&this.modelChange!==this.propertyName&&(t+=" "+this.modelChange),t+=": ",this.change===1?this.oldValue!==null&&(t+=" "+this.oldValue):(this.object!==null&&(t+=Util.toString(this.object)),this.oldValue!==null&&(t+=" old: "+Util.toString(this.oldValue)),this.oldParam!==null&&(t+=" "+this.oldParam),this.newValue!==null&&(t+=" new: "+Util.toString(this.newValue)),this.newParam!==null&&(t+=" "+this.newParam)),t}getValue(t){return t?this.oldValue:this.newValue}getParam(t){return t?this.oldParam:this.newParam}canUndo(){return this.model!==null||this.diagram!==null}undo(){this.canUndo()&&(this.model!==null?this.model.changeState(this,!0):this.diagram!==null&&this.diagram.FC(this,!0))}canRedo(){return this.model!==null||this.diagram!==null}redo(){this.canRedo()&&(this.model!==null?this.model.changeState(this,!1):this.diagram!==null&&this.diagram.FC(this,!1))}get model(){return this.Ai}set model(t){this.Ai=t}get diagram(){return this.b}set diagram(t){this.b=t}get change(){return this.xu}set change(t){this.xu=t}get modelChange(){return this.xm}set modelChange(t){Debug&&Util.t(t,"string",ChangedEvent,"modelChange"),this.xm=t}get propertyName(){return this.gn}set propertyName(t){Debug&&typeof t!="string"&&Util.t(t,"function",ChangedEvent,"propertyName"),this.gn=t}get isTransactionFinished(){return this.xu===1&&(this.gn==="CommittedTransaction"||this.gn==="FinishedUndo"||this.gn==="FinishedRedo")}get object(){return this.bu}set object(t){this.bu=t}get oldValue(){return this.df}set oldValue(t){this.df=t}get oldParam(){return this.gf}set oldParam(t){this.gf=t}get newValue(){return this.mf}set newValue(t){this.mf=t}get newParam(){return this.pf}set newParam(t){this.pf=t}}class Transaction{RC;Tt;$k;constructor(){this.RC=new List().w(),this.Tt="",this.$k=!1}toString(t){let i="Transaction: "+this.name+" "+this.changes.count.toString()+(this.isComplete?"":", incomplete");if(t!==void 0&&t>0){const e=this.changes.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),t.w()}canUndo(){return this.isComplete}undo(){if(this.canUndo())for(let t=this.changes.count-1;t>=0;t--){const i=this.changes.elt(t);i!==null&&i.undo()}}canRedo(){return this.isComplete}redo(){if(!this.canRedo())return;const t=this.changes.count;for(let i=0;i=t;e--){const s=i.elt(e);s!==null&&s.undo(),i.ct(),i.removeAt(e)}i.w()}optimize(){if(!this.isComplete)return;const t=this.changes;t.ct();const i=new GMap;for(let s=0;s0&&t.setElt(r,null),o.set(n.propertyName,s))}let e=0;for(let s=0;se&&t.setElt(e,n),e++)}for(;t.length>e;)t.pop();t.w()}get changes(){return this.RC}get name(){return this.Tt}set name(t){this.Tt=t}get isComplete(){return this.$k}set isComplete(t){this.$k=t}}class UndoManager{Vw;Xi;IC;zs;Qk;bm;Jn;Bw;_k;mn;yf;zw;Xs;Xw;Yw;km;Kw;constructor(t){this.Vw=new GSet,this.Xi=!1,this.IC=new List().w(),this.zs=-1,this.Qk=999,this.Xs=!1,this.bm=null,this.Jn=0,this.Bw=!1,Debug&&(this.Bw=!0),this._k=23,this.mn=new List().w(),this.yf=new List,this.zw=!0,this.Xw=!1,this.Yw=!1,this.km=!1,this.Kw=!1,t&&Object.assign(this,t)}toString(t){let i="UndoManager "+this.historyIndex+"<"+this.history.count+"<="+this.maxHistoryLength;i+="[";let e=this.nestedTransactionNames.count;for(let s=0;s0&&(i+=" "),i+=this.nestedTransactionNames.elt(s);if(i+="]",t!==void 0&&t>0){e=this.history.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),this.zs=-1,t.w(),this.Xs=!1,this.bm=null,this.Jn=0,this.mn.ct(),this.mn.clear(),this.mn.w(),this.yf.clear(),this.Xw=!1,this.Yw=!1,this.km=!1,this.Kw=!1}copyProperties(t){this.isEnabled=t.isEnabled,this.maxHistoryLength=t.maxHistoryLength,this.ku=t.ku}addModel(t){this.Vw.add(t)}removeModel(t){this.Vw.delete(t)}startTransaction(t){if(t===void 0&&(t=""),t===null&&(t=""),this.isUndoingRedoing)return!1;this.zw===!0&&(this.zw=!1,this.Jn++,this.Ml||this.i("StartingFirstTransaction",t,this.currentTransaction),this.Jn>0&&this.Jn--),this.isEnabled&&(this.mn.ct(),this.mn.add(t),this.mn.w(),this.currentTransaction===null?this.yf.add(0):this.yf.add(this.currentTransaction.changes.count)),this.Jn++;const i=this.transactionLevel===1;return i&&(this.Ml||this.i("StartedTransaction",t,this.currentTransaction)),i}commitTransaction(t){return t===void 0&&(t=""),this.OC(!0,t)}rollbackTransaction(){return this.OC(!1,"")}OC(t,i){if(this.isUndoingRedoing)return!1;this.ku&&this.transactionLevel<1&&Util.at("Ending transaction without having started a transaction: "+i);const e=this.transactionLevel===1;let s=this.currentTransaction;e&&t&&(this.Ml||this.i("CommittingTransaction",i,s));let n=0;if(this.transactionLevel>0&&(this.Jn--,this.isEnabled)){const o=this.mn.count;o>0&&(i===""&&(i=this.mn.elt(0)),this.mn.ct(),this.mn.removeAt(o-1),this.mn.w());const r=this.yf.count;r>0&&(n=this.yf.elt(r-1),this.yf.removeAt(r-1))}if(e){if(t){if(this.km=!1,s===null&&i!==""&&(s=this.currentTransaction),this.isEnabled&&s!==null){const o=s;o.isComplete||(o.isComplete=!0,o.name=i),this.discardHistoryAfterIndex();const r=this.history;r.ct();const l=this.maxHistoryLength;if(l>=0){if(l===0)r.clear();else if(r.count>=l){const h=r.elt(0);h!==null&&h.clear(),r.removeAt(0),this.zs--}}l!==0&&(r.count===0||r.get(r.count-1)!==o)&&(r.add(o),this.zs++),r.w(),s=o}this.Ml||this.i("CommittedTransaction",i,s)}else{this.Xs=!0;try{this.isEnabled&&s!==null&&(s.isComplete=!0,s.undo())}finally{this.Ml||this.i("RolledBackTransaction",i,s),this.Xs=!1}s!==null&&s.clear()}return this.bm=null,this.Uw&&this.clear(),this.Uw=!1,this.Gw=!1,!0}else return this.isEnabled&&!t&&s!==null&&s._D(n),!1}discardHistoryAfterIndex(){if(this.isUndoingRedoing||!this.canRedo())return;const t=this.history;t.ct();for(let i=t.count-1;i>this.historyIndex;i--){const e=t.elt(i);e!==null&&e.clear(),t.removeAt(i),this.km=!0}t.w()}lE(t){this.Jn+=t,this.Jn<0&&(this.Jn=0)}canUndo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToUndo;return!!(t!==null&&t.canUndo())}undo(){if(!this.canUndo())return;const t=this.transactionToUndo;try{this.Xs=!0,this.i("StartingUndo","Undo",t),this.zs--,t.undo()}catch(i){Util.at("undo error: "+i.toString())}finally{this.i("FinishedUndo","Undo",t),this.Xs=!1}}canRedo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToRedo;return!!(t!==null&&t.canRedo())}redo(){if(!this.canRedo())return;const t=this.transactionToRedo;try{this.Xs=!0,this.i("StartingRedo","Redo",t),this.zs++,t.redo()}catch(i){Util.at("redo error: "+i.toString())}finally{this.i("FinishedRedo","Redo",t),this.Xs=!1}}i(t,i,e){e===void 0&&(e=null);const s=new ChangedEvent;s.change=1,s.propertyName=t,s.object=e,s.oldValue=i;const n=this.models;for(;n.next();){const o=n.value;s.model=o,o.Hw(s)}}handleChanged(t){if(this.isEnabled&&!this.isUndoingRedoing&&!this.skipsEvent(t)){let i=this.currentTransaction;i===null&&(i=new Transaction,this.bm=i);const e=t.copy(),s=i.changes;if(s.ct(),s.add(e),s.w(),this.ku&&this._k>0&&this.transactionLevel<=0&&!this.zw){const n=t.diagram;if(n!==null&&n.Yh===!1)return;Util.at("Change not within a transaction: "+e.toString()),this._k--}}}skipsEvent(t){if(t===null||t.change===1)return!0;const i=t.object;if(i===null)return!1;if(i.layer!==void 0){const e=i.layer;if(e!==null&&e.isTemporary)return!0}else if(i.isTemporary)return!0;return!1}get models(){return this.Vw.iterator}get isEnabled(){return this.Xi}set isEnabled(t){this.Xi=t}get transactionToUndo(){return this.historyIndex>=0&&this.historyIndex<=this.history.count-1?this.history.elt(this.historyIndex):null}get transactionToRedo(){return this.historyIndex0}get ku(){return this.Bw}set ku(t){this.Bw=t}get nestedTransactionNames(){return this.mn}get Uw(){return this.Xw}set Uw(t){this.Xw=t}get Gw(){return this.Yw}set Gw(t){this.Yw=t}get Ml(){return this.Kw}set Ml(t){this.Kw=t}get isJustDiscarded(){return this.km}}class Tool{b;Tt;Xi;tS;iS;Sm;EC;constructor(){GSet.vi(this),this.b=Diagram.Mm(),this.Tt="",this.Xi=!0,this.tS=!1,this.iS=null,this.EC=new InputEvent,this.Sm=-1}get diagram(){return this.b}set diagram(t){t instanceof Diagram&&(this.b=t)}toString(){return this.name!==""?this.name+" Tool":Util.hn(this.constructor)}updateAdornments(t){}canStart(){return this.isEnabled}doStart(){}doActivate(){this.isActive=!0}doDeactivate(){this.isActive=!1}doStop(){}doCancel(){this.transactionResult=null,this.stopTool()}stopTool(){const t=this.diagram;t.currentTool===this&&(t.currentTool=null,t.currentCursor="")}doMouseDown(){!this.isActive&&this.canStart()&&this.doActivate()}doMouseMove(){}doMouseUp(){this.stopTool()}doMouseWheel(){}canStartMultiTouch(){return!0}standardPinchZoomStart(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.H(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.H(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.o(e),Point.o(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){t.eS=t.scale;const n=s.x-e.x,o=s.y-e.y,r=Math.sqrt(n*n+o*o);t.sS=r,i.bubbles=!1}Point.o(e),Point.o(s)}standardPinchZoomMove(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.H(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.H(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.o(e),Point.o(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){const n=s.x-e.x,o=s.y-e.y,l=Math.sqrt(n*n+o*o)/t.sS,h=new Point((Math.min(s.x,e.x)+Math.max(s.x,e.x))/2,(Math.min(s.y,e.y)+Math.max(s.y,e.y))/2),a=t.eS*l,f=t.commandHandler;if(a!==t.scale&&f.canResetZoom(a)){const c=t.zoomPoint;t.zoomPoint=h,f.resetZoom(a),t.zoomPoint=c}i.bubbles=!1}Point.o(e),Point.o(s)}doKeyDown(){this.diagram.lastInput.code==="Escape"&&this.doCancel()}doKeyUp(){}startTransaction(t){return t===void 0&&(t=this.name),this.transactionResult=null,this.diagram.startTransaction(t)}stopTransaction(){const t=this.diagram;return this.transactionResult===null?t.rollbackTransaction():t.commitTransaction(this.transactionResult)}standardMouseSelect(){const t=this.diagram;if(!t.allowSelect)return;const i=t.lastInput,e=t.findPartAt(i.documentPoint,!1);if(e!==null){if(Util.cr?i.meta:i.control){t.V("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!s.isSelected),t.V("ChangedSelection",t.selection)}else if(i.shift){if(!e.isSelected){t.V("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!0),t.V("ChangedSelection",t.selection)}}else if(!e.isSelected){let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&t.select(s)}}else i.left&&!(Util.cr?i.meta:i.control)&&!i.shift&&t.clearSelection()}standardMouseClick(t,i){t===void 0&&(t=null),i===void 0&&(i=o=>!o.layer.isTemporary);const e=this.diagram,s=e.lastInput,n=e.findObjectAt(s.documentPoint,t,i);return s.targetObject=n,this.tF(n,s,e),s.handled}tF(t,i,e){if(i.handled=!1,t!==null&&!t.isEnabledObject())return;let s=0;i.left?i.clickCount===1?s=1:i.clickCount===2?s=2:s=1:i.right&&i.clickCount===1&&(s=3);let n="ObjectSingleClicked";if(t!==null){switch(s){case 1:n="ObjectSingleClicked";break;case 2:n="ObjectDoubleClicked";break;case 3:n="ObjectContextClicked";break}s!==0&&e.V(n,t)}else{switch(s){case 1:n="BackgroundSingleClicked";break;case 2:n="BackgroundDoubleClicked";break;case 3:n="BackgroundContextClicked";break}s!==0&&e.V(n)}if(t!==null)for(;t!==null;){let o=null;switch(s){case 1:o=t.click;break;case 2:o=t.doubleClick?t.doubleClick:t.click;break;case 3:o=t.contextClick;break}if(o!==null&&(o(i,t),i.handled))break;t=t.panel}else{let o=null;switch(s){case 1:o=e.click;break;case 2:o=e.doubleClick?e.doubleClick:e.click;break;case 3:o=e.contextClick;break}o!==null&&o(i)}}standardMouseOver(){const t=this.diagram,i=t.lastInput;if(t.animationManager.Si===!0)return;const e=t.skipsUndoManager;t.skipsUndoManager=!0;let s=t.viewportBounds.containsPoint(i.documentPoint)?t.findObjectAt(i.documentPoint,null,null):null;i.event&&(i.event.type==="pointercancel"||i.event.type==="pointerout")&&(s=null),i.targetObject=s;let n=!1;if(s!==t.wf){let o=t.wf;const r=o;for(t.wf=s,this.doCurrentObjectChanged(o,s),i.handled=!1;o!==null;){const l=o.mouseLeave;if(l!==null&&(s===o||s!==null&&s.isContainedBy(o)||(l(i,o,s),n=!0,i.handled)))break;o=o.panel}for(o=r,i.handled=!1;s!==null;){const l=s.mouseEnter;if(l!==null&&(o===s||o!==null&&o.isContainedBy(s)||(l(i,s,o),n=!0,i.handled)))break;s=s.panel}s=t.wf}if(s!==null){let o=s,r="";for(;o!==null&&(r=o.cursor,r==="");)o=o.panel;for(t.currentCursor=r,i.handled=!1,o=s;o!==null;){const l=o.mouseOver;if(l!==null&&(l(i,o),n=!0,i.handled))break;o=o.panel}}else{this.doUpdateCursor(null);const o=t.mouseOver;o!==null&&(o(i),n=!0)}n&&t.requestUpdate(),t.skipsUndoManager=e}doUpdateCursor(t){const i=this.diagram;i&&(i.currentCursor="")}doCurrentObjectChanged(t,i){}standardMouseWheel(){const t=this.diagram,i=t.lastInput;let e=i.delta;if(e===0||!t.documentBounds.isReal())return;const s=t.commandHandler,n=t.toolManager.mouseWheelBehavior;if(s!==null&&(n===2&&!i.shift||n===1&&i.control)){if(e>0?s.canIncreaseZoom():s.canDecreaseZoom()){const o=t.zoomPoint;t.zoomPoint=i.viewPoint,e>0?s.increaseZoom():s.decreaseZoom(),t.zoomPoint=o}i.bubbles=!1}else if(n===2&&i.shift||n===1&&!i.control){const o=t.position.copy(),r=i.event,l=r.deltaMode;let h=r.deltaX,a=r.deltaY,f="pixel";if((h!==0||a!==0)&&!i.shift){switch(l){case 0:f="pixel";break;case 1:f="line";break;case 2:f="page";break}if(h!==0&&t.allowHorizontalScroll){const c=t.scrollHorizontalLineChange;h=h*(c/16),t.scroll(f,h>0?"right":"left",Math.abs(h))}if(a!==0&&t.allowVerticalScroll){const c=t.scrollVerticalLineChange;a=a*(c/16),t.scroll(f,a>0?"down":"up",Math.abs(a))}}else!i.shift&&t.allowVerticalScroll?(e=e*3*t.scrollVerticalLineChange,t.scroll(f,e>0?"up":"down",Math.abs(e))):i.shift&&t.allowHorizontalScroll&&(e=e*3*t.scrollHorizontalLineChange,t.scroll(f,e>0?"left":"right",Math.abs(e)));this.doWheelChange(t,o,i)}}doWheelChange(t,i,e){(!t.position.equals(i)||e.event.wheelDeltaX!==0)&&(e.bubbles=!1)}standardWaitAfter(t,i){Debug&&Util.t(t,"number",Tool,"standardWaitAfter:delay"),i===void 0&&(i=this.diagram.lastInput),this.cancelWaitAfter();const e=this,s=i.clone(this.EC);this.Sm=Util.Bh(()=>e.doWaitAfter(s),t)}cancelWaitAfter(){this.Sm!==-1&&Util.Ug(this.Sm),this.Sm=-1}doWaitAfter(t){}findToolHandleAt(t,i){const s=this.diagram.findObjectAt(t,n=>{for(;n!==null&&!(n.panel instanceof Adornment);)n=n.panel;return n});return s===null?null:s.part.category===i?s:null}isBeyondDragSize(t,i){const e=this.diagram;t===void 0&&(t=e.firstInput.viewPoint),i===void 0&&(i=e.lastInput.viewPoint);const s=e.toolManager.dragSize;let n=s.width,o=s.height;return e.firstInput.isTouchEvent&&(n+=6,o+=6),Math.abs(i.x-t.x)>n||Math.abs(i.y-t.y)>o}get name(){return this.Tt}set name(t){Util.t(t,"string",Tool,"name"),this.Tt=t}get isEnabled(){return this.Xi}set isEnabled(t){Util.t(t,"boolean",Tool,"isEnabled"),this.Xi=t}get isActive(){return this.tS}set isActive(t){Util.t(t,"boolean",Tool,"isActive"),this.tS=t}get transactionResult(){return this.iS}set transactionResult(t){t!==null&&Util.t(t,"string",Tool,"transactionResult"),this.iS=t}}var WheelMode=(w=>(w[w.Scroll=1]="Scroll",w[w.Zoom=2]="Zoom",w[w.None=3]="None",w))(WheelMode||{}),GestureMode=(w=>(w[w.Zoom=1]="Zoom",w[w.Cancel=2]="Cancel",w[w.None=3]="None",w))(GestureMode||{});class ToolManager extends Tool{VC;BC;zC;nS;oS;rS;lS;hS;aS;fS;Pm;Kh;constructor(t){super(),this.name="ToolManager",this.VC=new List,this.BC=new List,this.zC=new List,this.nS=850,this.oS=850,this.rS=new Size(2,2).ot(),this.lS=5e3,this.hS=1,this.aS=1,this.fS=null,this.Pm=null,this.Kh=-1,t&&Object.assign(this,t)}static WheelScroll=1;static WheelZoom=2;static WheelNone=3;static GestureZoom=1;static GestureCancel=2;static GestureNone=3;get mouseWheelBehavior(){return this.hS}set mouseWheelBehavior(t){Util.tt(t,WheelMode,"WheelMode"),this.hS=t}get gestureBehavior(){return this.aS}set gestureBehavior(t){Util.tt(t,GestureMode,"GestureMode"),this.aS=t}initializeStandardTools(){}updateAdornments(t){const i=this.currentToolTip;if(i instanceof Adornment&&this.Pm===t){const e=i.adornedObject;(t!==null?e.part===t:e===null)?this.showToolTip(i,e):this.hideToolTip()}}doMouseDown(){const t=this.diagram,i=t.lastInput;if(i.isTouchEvent&&this.gestureBehavior===2&&(i.bubbles=!1),i.isMultiTouch){if(this.cancelWaitAfter(),this.gestureBehavior===3){i.bubbles=!0;return}if(this.gestureBehavior===2)return;if(t.currentTool.canStartMultiTouch()){t.currentTool.standardPinchZoomStart();return}}const e=t.undoManager;Debug&&e.ku&&e.transactionLevel!==0&&Util.at("WARNING: In ToolManager.doMouseDown: UndoManager.transactionLevel is not zero");const s=this.mouseDownTools.length;for(let n=0;n0&&s!==1/0){const n=this;this.Kh=Util.Bh(()=>n.hideToolTip(),s)}}positionToolTip(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom?n.y-=o.height+5/s.scale:n.y+=20/s.scale,n.y30&&t.jw(),t.Ww(this.draggedParts),t.Pu=!0,this.startTransaction("Drag"),this.startPoint=t.firstInput.documentPoint,t.isMouseCaptured=!0,t.allowDragOut&&this.eF()}MS(t){if(this.dragsLink){const i=this.diagram;if(!i.allowRelink)return;i.model.kf()&&t.count===1&&t.first()instanceof Link?(this.draggedLink=t.first(),this.draggedLink.canRelinkFrom()&&this.draggedLink.canRelinkTo()&&this.draggedLink.clearAdornments(),this.pn=i.toolManager.findTool("Relinking"),this.pn===null&&(this.pn=new RelinkingTool,this.pn.diagram=i),this.pn.originalLink=this.draggedLink):(this.draggedLink=null,this.pn=null)}}computeEffectiveCollection(t,i){return this.diagram.commandHandler.computeEffectiveCollection(t,i)}Ys(t){return t===void 0?new DraggingInfo(Point.Lo):this.isGridSnapEnabled?new DraggingInfo(new Point(Math.round(t.x*1e3)/1e3,Math.round(t.y*1e3)/1e3)):new DraggingInfo(t.copy())}doDeactivate(){this.isActive=!1;const t=this.diagram;this.diagram.layout.isRealtime=this.SS,t.Pu=!1,t.Pl=!0,t.cacheGroupExternalLinks(!1),t.stopAutoScroll(),this.PS(),t.Cm(this.draggedParts),this.Mu=null,this.currentPart=null,this.draggedParts=null,this.isDragOutStarted=!1,this.Su=!1,DraggingTool.sF(),this.YC(),this.xf.e(NaN,NaN),DraggingTool.Gh!==null&&(DraggingTool.Gh.currentCursor=""),DraggingTool.Gh=null,DraggingTool.St=null,this.Nl(),t.isMouseCaptured=!1,t.currentCursor="",t.bf=!1,this.stopTransaction(),t.NS(!0)}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}PS(){const t=this.diagram,i=t.skipsUndoManager;t.skipsUndoManager=!0;const e=t.lastInput;this.KC(e,null),t.skipsUndoManager=i,this.br.length=0}UC(){this.Nl(),this.CS();const t=this.diagram;this.xf.isReal()&&(t.position=this.xf),t.stopAutoScroll()}doCancel(){this.Nl(),this.CS();const t=this.diagram;this.xf.isReal()&&(t.position=this.xf),this.stopTool()}doKeyDown(){const t=this.diagram,i=t.lastInput;this.isActive&&(i.code==="Escape"?this.doCancel():i.code!==t.previousInput.code&&this.doMouseMove())}doKeyUp(){this.isActive&&this.doMouseMove()}nF(t,i){let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=t.iterator;for(;r.next();){const l=r.value;if(!l.isVisible())continue;const h=l.location,a=h.x,f=h.y;isNaN(a)||isNaN(f)||(an&&(n=a),f>o&&(o=f))}return e===1/0?i.e(0,0,0,0):i.e(e,s,n-e,o-s),i}AS(t){if(this.copiedParts!==null)return;const i=this.diagram;if(t&&(i.isReadOnly||i.isModelReadOnly)||this.draggedParts===null)return;const e=i.undoManager;e.isEnabled&&e.isInTransaction?e.currentTransaction!==null&&e.currentTransaction.changes.count>0&&(i.undoManager.rollbackTransaction(),i.startTransaction("Drag")):this.CS(),i.skipsUndoManager=!t,i.partManager.addsToTemporaryLayer=!t,this.startPoint=i.firstInput.documentPoint;const s=this.copiesEffectiveCollection?this.draggedParts.toKeySet():i.selection,n=i.copyParts(s,i,!0),o=new GMap,r=this.draggedParts.iterator;for(;r.next();){const h=r.key;if(h.Ae()&&h.canCopy()){const a=n.get(h);if(a===null)continue;a.location=h.location,a.ensureBounds(),o.set(a,this.Ys(a.location))}}const l=n.iterator;for(;l.next();){const h=l.value;h instanceof Link&&h.canCopy()&&o.set(h,this.Ys())}if(this.copiedParts=o,this.MS(o.toKeySet()),this.draggedLink!==null){const h=this.draggedLink,a=h.routeBounds;h.kr(this.startPoint.x-(a.x+a.width/2),this.startPoint.y-(a.y+a.height/2))}this.doUpdateCursor(null)}Nl(){const t=this.diagram;if(this.copiedParts!==null){if(t.removeParts(this.copiedParts.toKeySet(),!1),this.copiedParts=null,this.draggedParts!==null){const i=this.draggedParts.iterator;for(;i.next();)if(i.key instanceof Link){const s=i.value;s.point=new Point(0,0)}}this.doUpdateCursor(null)}t.skipsUndoManager=!1,t.partManager.addsToTemporaryLayer=!1,this.startPoint=t.firstInput.documentPoint}YC(){this.draggedLink!==null&&(this.dragsLink&&this.pn!==null&&(this.pn.stopDraggingMouseMove(),this.pn.originalLink=null),this.draggedLink=null,this.pn=null)}Sf(t,i){const e=this.diagram,s=this.startPoint,n=Point.a();n.c(e.lastInput.documentPoint),this.moveParts(t,n.subtract(s),i),Point.o(n),e.getRenderingHint("temporaryPixelRatio")===!0&&e.Cl===null&&e.avgSpf>30&&(e.jw(),e.Nu())}moveParts(t,i,e){e===void 0&&(e=!1);const s=this.diagram;s!==null&&s.LS(t,i,this.dragOptions,e)}CS(){if(this.draggedParts===null)return;const t=this.diagram;let i=this.draggedParts.iterator;for(;i.next();){const e=i.key;e.Ae()&&(e.location=i.value.point)}for(i=this.draggedParts.iterator;i.next();){const e=i.key;if(e instanceof Link&&e.suspendsRouting){const s=i.value.point;this.draggedParts.set(e,this.Ys()),e.kr(-s.x,-s.y)}}t.maybeUpdate()}oF(t){if(t===null)return!0;const i=t.part;return!!(i===null||i instanceof Adornment||i.layer.isTemporary||this.draggedParts&&this.draggedParts.has(i)||this.copiedParts&&this.copiedParts.has(i))}TS(t){const i=this.diagram;this.dragsLink&&(this.draggedLink!==null&&(this.draggedLink.fromNode=null,this.draggedLink.toNode=null),this.GC(!1));const e=this.findDragOverObject(t),s=i.lastInput;s.targetObject=e,this.doUpdateCursor(e);const n=i.skipsUndoManager;let o=!1;try{if(i.skipsUndoManager=!0,o=this.KC(s,e),!this.isActive&&DraggingTool.St===null)return;const r=e!==null?e.part:null;if(r===null||i.handlesDragDropForTopLevelParts&&r.isTopLevel&&!(r instanceof Group)){const l=i.mouseDragOver;l!==null&&(l(s),o=!0)}if(!this.isActive&&DraggingTool.St===null||(this.doDragOver(t,e),!this.isActive&&DraggingTool.St===null))return}finally{i.skipsUndoManager=n,o&&i.maybeUpdate()}this.Mu=e,!i.isReadOnly&&(i.allowMove||i.allowCopy)&&(i.allowHorizontalScroll||i.allowVerticalScroll)&&i.doAutoScroll(s.viewPoint)}findDragOverObject(t){return this.diagram.DS(t,null,i=>!this.oF(i))}doUpdateCursor(t){const i=this.diagram;(t===null||this.Mu!==t)&&(!this.diagram.currentTool.isActive||this.mayCopy()?i.currentCursor=this.copyCursor:this.mayMove()?i.currentCursor=this.moveCursor:this.mayDragOut()&&(i.currentCursor=this.nodropCursor))}KC(t,i){let e=!1,s=this.br.length;const n=s>0?this.br[0]:null;if(i===n)return!1;t.handled=!1;for(let r=0;rs.findValidLinkablePort(a,i)),r=Point.a();let l=1/0,h=null;for(const a=o.iterator;a.next();){const f=a.value;if(f.part===null)continue;const u=f.getDocumentPoint(Spot.Center,r),d=t.distanceSquaredPoint(u);dh.suspendsRouting=!1)}if(this.doDropOnto(t,e),!this.isActive&&DraggingTool.St===null)return;const o=Rect.a(),r=i.selection.iterator;for(;r.next();){const l=r.value;l instanceof Node&&this.lF(i,l,o)}Rect.o(o)}rF(t,i){const e=this.diagram,s=i.part;if(e.handlesDragDropForTopLevelParts&&s.isTopLevel&&!(s instanceof Group)){const n=e.mouseDrop;n!==null&&n(t)}}lF(t,i,e){if(!i.canAvoid())return;let s=!1;e=i.getAvoidableRect(e),t.viewportBounds.containsRect(e)&&(s=!0);const n=this.copiedParts||this.draggedParts,o=t.IS(e,l=>l.part,l=>l instanceof Link,!0,l=>l instanceof Link,s);if(o.count===0)return;const r=o.iterator;for(;r.next();){const l=r.value;n.has(l)&&n.has(i)||!l.isMemberOf(i)&&l.isAvoiding&&l.invalidateRoute()}}doDropOnto(t,i){}doMouseMove(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseMove(i.event,i.documentPoint,i.targetDiagram))return;this.currentPart!==null&&this.draggedParts!==null&&(this.mayCopy()?(this.AS(!1),t.Ww(this.copiedParts),this.Sf(this.copiedParts,!1),t.Cm(this.copiedParts)):this.mayMove()?(this.Nl(),this.Sf(this.draggedParts,!0)):this.mayDragOut()?(this.AS(!1),this.Sf(this.copiedParts,!1)):this.Nl(),this.TS(t.lastInput.documentPoint))}doMouseUp(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseUp(i.event,i.documentPoint,i.targetDiagram))return;let e=!1;const s=this.mayCopy();if(s&&this.copiedParts!==null?(this.Nl(),this.AS(!0),t.Ww(this.copiedParts),this.Sf(this.copiedParts,!1),t.Cm(this.copiedParts),this.copiedParts!==null&&(t.V("ChangingSelection",t.selection),t.clearSelection(!0),this.copiedParts.iteratorKeys.each(n=>{n.isSelected=!0}))):(e=!0,this.Nl(),this.mayMove()&&(this.Sf(this.draggedParts,!0),this.TS(t.lastInput.documentPoint))),this.Su=!0,this.jC(t.lastInput.documentPoint),this.isActive){const n=s?this.copiedParts.toKeySet():this.draggedParts.toKeySet();this.copiedParts=null,e&&this.hF(),t.invalidateDocumentBounds(),t.Cm(this.draggedParts),this.transactionResult=s?"Copy":"Move",t.V(s?"SelectionCopied":"SelectionMoved",n)}this.stopTool(),s&&t.V("ChangedSelection",t.selection)}simulatedMouseMove(t,i,e){if(DraggingTool.St===null)return!1;const s=DraggingTool.St.diagram;e instanceof Diagram||(e=null);const n=DraggingTool.Gh;if(e!==n){if(n!==null&&n!==s){n.stopAutoScroll(),DraggingTool.St.isDragOutStarted=!1;const r=n.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDragLeave()}if(DraggingTool.Gh=e,e!==null&&e!==s){DraggingTool.St.UC();const r=e.toolManager.findTool("Dragging");r!==null&&(r.WC(),r.doSimulatedDragEnter())}this.doUpdateCursor(null)}if(e===null||e===s||!e.allowDrop||e.isReadOnly||!e.allowInsert)return!1;const o=e.toolManager.findTool("Dragging");if(o!==null){let r=i;t!==null&&(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),r=e.getMouse(t)),e.lastInput.documentPoint=r,e.lastInput.viewPoint=e.transformDocToView(r),e.lastInput.down=!1,e.lastInput.up=!1,o.doSimulatedDragOver()}return!0}simulatedMouseUp(t,i,e){if(DraggingTool.St===null)return!1;const s=DraggingTool.Gh,n=DraggingTool.St.diagram;if(e===null)return DraggingTool.St.doCancel(),!0;if(e!==s){const o=s.toolManager.findTool("Dragging");if(s!==null&&s!==n&&o!==null)return s.stopAutoScroll(),DraggingTool.St.isDragOutStarted=!1,o.doSimulatedDragLeave(),!1;DraggingTool.Gh=e;const r=e.toolManager.findTool("Dragging");r!==null&&(DraggingTool.St.UC(),r.WC(),r.doSimulatedDragEnter())}if(e!==this.diagram){let o=i;t!==null?(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),o=e.getMouse(t)):o===null&&(o=new Point),e.lastInput.documentPoint=o,e.lastInput.viewPoint=e.transformDocToView(o),e.lastInput.down=!1,e.lastInput.up=!0;const r=e.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDrop();const l=DraggingTool.St;if(l!==null){const h=l.mayCopy();l.transactionResult=h?"Copy":"Move",l.stopTool()}return!0}return!1}hF(){if(this.draggedParts===null)return;const t=this.draggedParts.iterator;for(;t.next();){const i=t.key;if(i instanceof Node){const e=i.containingGroup;e!==null&&e.hasPlaceholder()&&!this.draggedParts.has(e)&&e.placeholder.u()}}}mayCopy(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowCopy||!(Util.cr?t.lastInput.alt:t.lastInput.control))return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayDragOut(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(!t.allowDragOut||!t.allowCopy||t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayMove(){const t=this.diagram;if(t.isReadOnly||!t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canMove())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canMove())}WC(){DraggingTool.vw.has(this)||DraggingTool.vw.add(this)}static sF(){if(DraggingTool.vw.count>0){const t=DraggingTool.vw,i=t.length;for(let e=0;e{n.isSelected=!0,s.add(n)})),this.jC(t.lastInput.documentPoint),t.invalidateDocumentBounds(),this.copiedParts!==null&&(this.transactionResult="ExternalCopy"),this.copiedParts=null,t.doFocus(),t.bf=!1,t.V("ExternalObjectsDropped",s,e),this.stopTransaction(),t.V("ChangedSelection",t.selection)}t.animationManager.Cu=!1}vC(t,i,e){if(this.copiedParts!==null)return;const s=this.diagram;if(s.isReadOnly||s.isModelReadOnly)return;s.skipsUndoManager=!i,s.partManager.addsToTemporaryLayer=!i,this.startPoint=e.documentPoint;const n=s.copyParts(t,s,!0),o=Rect.a();this.nF(t,o);const r=o.x+o.width/2,l=o.y+o.height/2;Rect.o(o);const h=this.Nm,a=new GMap,f=Point.a(),c=t.iterator;for(;c.next();){const d=c.value;if(d instanceof Link&&d.canCopy()){const m=n.get(d);if(m===null)continue;m.points=d.points,m.kr(h.x-r,h.y-l),m.suspendsRouting=!0,a.set(m,this.Ys())}}const u=t.iterator;for(;u.next();){const d=u.value;if(d.Ae()&&d.canCopy()){const m=n.get(d);if(m===null)continue;const g=d.location;f.e(h.x-(r-g.x),h.y-(l-g.y)),m.location=f,m.ensureBounds(),a.set(m,this.Ys(f))}}if(Point.o(f),this.copiedParts=a,this.MS(a.toKeySet()),this.draggedLink!==null){const d=this.draggedLink,m=d.routeBounds;d.kr(this.startPoint.x-(m.x+m.width/2),this.startPoint.y-(m.y+m.height/2))}this.doUpdateCursor(null)}eF(){this.isDragOutStarted=!0,this.Su=!1,DraggingTool.St=this,DraggingTool.Gh=this.diagram,this.doSimulatedDragOut()}doSimulatedDragOut(){const t=this.diagram;t.bf=!1,!this.mayCopy()&&!this.mayMove()?t.currentCursor=this.nodropCursor:t.currentCursor="",this.Mu=null}computeMove(t,i,e,s){const n=this.diagram;return n!==null?n.computeMove(t,i,this.dragOptions,s):new Point}static vw=new List;static St=null;static Gh=null}ToolManager.prototype.doCancel=function(){DraggingTool.St!==null&&DraggingTool.St.doCancel(),Tool.prototype.doCancel.call(this)};class LinkingBaseTool extends Tool{OS;ES;Al;VS;BS;Hh;zS;qh;XS;YS;KS;US;GS;HS;JC;qS;Ll;jS;constructor(){super(),this.OS=100,this.ES=!1,this.Al="pointer",this.VS=new Link({layerName:"Tool"}).add(new Shape({isPanelMain:!0,stroke:"blue"}).theme("stroke","tempLink"),new Shape({toArrow:"Standard",fill:"blue",stroke:"blue"}).theme("fill","tempLink").theme("stroke","tempLink")).ci(),this.Hh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.zk}).theme("stroke","tempPort"),this.BS=new Node({selectable:!1,layerName:"Tool"}).add(this.Hh).ci(),this.qh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.zk}).theme("stroke","tempPort"),this.zS=new Node({selectable:!1,layerName:"Tool"}).add(this.qh).ci(),this.XS=null,this.YS=null,this.KS=null,this.US=null,this.GS=null,this.HS=!0,this.JC=new GMap,this.qS=null,this.Ll=null,this.jS=null}doStop(){this.diagram.stopAutoScroll(),this.originalLink=null,this.originalFromNode=null,this.originalFromPort=null,this.originalToNode=null,this.originalToPort=null,this.validPortsCache.clear(),this.targetPort=null}get portGravity(){return this.OS}set portGravity(t){Util.t(t,"number",LinkingBaseTool,"portGravity"),t>=0&&(this.OS=t)}get isUnconnectedLinkValid(){return this.ES}set isUnconnectedLinkValid(t){Util.t(t,"boolean",LinkingBaseTool,"isUnconnectedLinkValid"),this.ES=t}get linkingCursor(){return this.Al}set linkingCursor(t){this.Al=t}get temporaryLink(){return this.VS}set temporaryLink(t){Util.s(t,Link,LinkingBaseTool,"temporaryLink"),t.ci(),this.VS=t}get temporaryFromNode(){return this.BS}set temporaryFromNode(t){Util.s(t,Node,LinkingBaseTool,"temporaryFromNode"),t.ci(),this.BS=t,t&&(this.Hh=t.port)}get temporaryFromPort(){return this.Hh}set temporaryFromPort(t){if(Util.s(t,GraphObject,LinkingBaseTool,"temporaryFromPort"),this.Hh!==null){const i=this.Hh.panel;if(i!==null){const e=i.D.indexOf(this.Hh);i.removeAt(e),i.insertAt(e,t)}}this.Hh=t}get temporaryToNode(){return this.zS}set temporaryToNode(t){Util.s(t,Node,LinkingBaseTool,"temporaryToNode"),t.ci(),this.zS=t,t&&(this.qh=t.port)}get temporaryToPort(){return this.qh}set temporaryToPort(t){if(Util.s(t,GraphObject,LinkingBaseTool,"temporaryToPort"),this.qh!==null){const i=this.qh.panel;if(i!==null){const e=i.D.indexOf(this.qh);i.removeAt(e),i.insertAt(e,t)}}this.qh=t}get originalLink(){return this.XS}set originalLink(t){t!==null&&Util.s(t,Link,LinkingBaseTool,"originalLink"),this.XS=t}get originalFromNode(){return this.YS}set originalFromNode(t){t!==null&&Util.s(t,Node,LinkingBaseTool,"originalFromNode"),this.YS=t}get originalFromPort(){return this.KS}set originalFromPort(t){t!==null&&Util.s(t,GraphObject,LinkingBaseTool,"originalFromPort"),this.KS=t}get originalToNode(){return this.US}set originalToNode(t){t!==null&&Util.s(t,Node,LinkingBaseTool,"originalToNode"),this.US=t}get originalToPort(){return this.GS}set originalToPort(t){t!==null&&Util.s(t,GraphObject,LinkingBaseTool,"originalToPort"),this.GS=t}get isForwards(){return this.HS}set isForwards(t){this.HS=t}get validPortsCache(){return this.JC}get targetPort(){return this.qS}set targetPort(t){t!==null&&Util.s(t,GraphObject,LinkingBaseTool,"targetPort"),this.qS=t}copyPortProperties(t,i,e,s,n){if(t===null||i===null||e===null||s===null)return;const o=i.getDocumentScale(),r=Size.a();r.width=i.naturalBounds.width*o,r.height=i.naturalBounds.height*o,s.desiredSize=r,Size.o(r),n?(s.toSpot=i.toSpot,s.toEndSegmentLength=i.toEndSegmentLength):(s.fromSpot=i.fromSpot,s.fromEndSegmentLength=i.fromEndSegmentLength),e.locationSpot=Spot.Center;const l=Point.a();e.location=i.getDocumentPoint(Spot.Center,l),Point.o(l),s.angle=i.getDocumentAngle(),this.portTargeted!==null&&this.portTargeted(t,i,e,s,n)}setNoTargetPortProperties(t,i,e){i!==null&&(i.desiredSize=Size.zk,i.fromSpot=Spot.None,i.toSpot=Spot.None),t!==null&&(t.location=this.diagram.lastInput.documentPoint),this.portTargeted!==null&&this.portTargeted(null,null,t,i,e)}doMouseDown(){this.isActive&&this.doMouseMove()}doMouseMove(){if(this.isActive){const t=this.diagram;if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null&&this.targetPort.part instanceof Node){const i=this.targetPort.part;this.isForwards?this.copyPortProperties(i,this.targetPort,this.temporaryToNode,this.temporaryToPort,!0):this.copyPortProperties(i,this.targetPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else this.isForwards?this.setNoTargetPortProperties(this.temporaryToNode,this.temporaryToPort,!0):this.setNoTargetPortProperties(this.temporaryFromNode,this.temporaryFromPort,!1);(t.allowHorizontalScroll||t.allowVerticalScroll)&&t.doAutoScroll(t.lastInput.viewPoint)}}findValidLinkablePort(t,i){if(t===null)return null;const e=t.part;if(!(e instanceof Node))return null;for(;t!==null;){const s=i?t.toLinkable:t.fromLinkable;if(s===!0&&(t.portId!==null||t instanceof Node)&&(i?this.isValidTo(e,t):this.isValidFrom(e,t)))return t;if(s===!1)return null;t=t.panel}return null}findTargetPort(t){const i=this.diagram,e=i.lastInput.documentPoint;let s=this.portGravity;s<=0&&(s=.1);const n=this,o=i.findObjectsNear(e,s,a=>n.findValidLinkablePort(a,t),null,!0);let r=1/0,l=null;const h=o.iterator;for(;h.next();){const a=h.value,f=a.part;if(!(f instanceof Node))continue;const c=a.getDocumentPoint(Spot.Center,Point.a()),u=e.x-c.x,d=e.y-c.y;Point.o(c);const m=u*u+d*d;if(m=e)return!1}return!0}isValidTo(t,i){if(t===null||i===null)return this.isUnconnectedLinkValid;if(this.diagram.currentTool===this&&(t.layer!==null&&!t.layer.allowLink||i.toLinkable!==!0))return!1;const e=i.toMaxLinks;if(e<1/0){if(this.originalLink!==null&&t===this.originalToNode&&i===this.originalToPort)return!0;let s=i.portId;if(s===null&&(s=""),t.findLinksInto(s).count>=e)return!1}return!0}isInSameNode(t,i){if(t===null||i===null)return!1;if(t===i)return!0;const e=t.part,s=i.part;return e!==null&&e===s}isLinked(t,i){if(t===null||i===null)return!1;const e=t.part;if(!(e instanceof Node))return!1;let s=t.portId;s===null&&(s="");const n=i.part;if(!(n instanceof Node))return!1;let o=i.portId;o===null&&(o="");const r=n.findLinksInto(o);for(;r.next();){const l=r.value;if(l.fromNode===e&&l.fromPortId===s)return!0}return!1}isValidLink(t,i,e,s){if(!this.isValidFrom(t,i)||!this.isValidTo(e,s)||i!==null&&s!==null&&(!(i.fromLinkableSelfNode&&s.toLinkableSelfNode)&&this.isInSameNode(i,s)||!(i.fromLinkableDuplicates&&s.toLinkableDuplicates)&&this.isLinked(i,s))||this.originalLink!==null&&(t!==null&&this.isLabelDependentOnLink(t,this.originalLink)||e!==null&&this.isLabelDependentOnLink(e,this.originalLink))||t!==null&&e!==null&&(t.data===null&&e.data!==null||t.data!==null&&e.data===null)||!this.isValidCycle(t,e,this.originalLink))return!1;let n;return t!==null&&(n=t.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))||e!==null&&(n=e.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))?!1:(n=this.linkValidation,n!==null?n(t,i,e,s,this.originalLink):!0)}isLabelDependentOnLink(t,i){if(t===null)return!1;const e=t.labeledLink;if(e===null)return!1;if(e===i)return!0;const s=new GSet;return s.add(t),this.WS(e,i,s)}WS(t,i,e){if(t===i)return!0;const s=t.fromNode;if(s!==null&&s.isLinkLabel&&(e.add(s),this.WS(s.labeledLink,i,e)))return!0;const n=t.toNode;return!!(n!==null&&n.isLinkLabel&&(e.add(n),this.WS(n.labeledLink,i,e)))}isValidCycle(t,i,e){if(e===void 0&&(e=null),t===null||i===null)return this.isUnconnectedLinkValid;const s=this.diagram;let n=1;if(s&&(s.model.Mf()?n=s.isTreePathToChildren?5:6:n=s.validCycle),n===1)return!0;if(n===5){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=i.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.toNode===i)return!1}return!this.Au(t,i,e,!0)}else if(n===6){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=t.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.fromNode===t)return!1}return!this.Au(t,i,e,!0)}else{if(n===2)return!this.aF(t,i,e);if(n===3)return!this.Au(t,i,e,!1);if(n===4)return!this.fF(t,i,e)}return!0}Au(t,i,e,s){if(t===i)return!0;if(t===null||i===null)return!1;const n=t.linksConnected;for(;n.next();){const o=n.value;if(o===e||s&&!o.isTreeLink||o.toNode!==t)continue;const r=o.fromNode;if(r!==t&&this.Au(r,i,e,s))return!0}return!1}aF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.ZC(s,t,i,e)}ZC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s||o.toNode!==i)continue;const r=o.fromNode;if(r!==i&&this.ZC(t,r,e,s))return!0}return!1}fF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.$C(s,t,i,e)}$C(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s)continue;const r=o.fromNode,l=o.toNode,h=r===i?l:r;if(h!==i&&this.$C(t,h,e,s))return!0}return!1}get linkValidation(){return this.Ll}set linkValidation(t){t!==null&&Util.t(t,"function",LinkingBaseTool,"linkValidation"),this.Ll=t}get portTargeted(){return this.jS}set portTargeted(t){t!==null&&Util.t(t,"function",LinkingBaseTool,"portTargeted"),this.jS=t}}var LinkingDirection=(w=>(w[w.Either=1]="Either",w[w.ForwardsOnly=2]="ForwardsOnly",w[w.BackwardsOnly=3]="BackwardsOnly",w))(LinkingDirection||{});class LinkingTool extends LinkingBaseTool{vS;JS;C;ZS;constructor(t){super(),this.name="Linking",this.vS={},this.JS=null,this.C=1,this.ZS=null,t&&Object.assign(this,t)}static Either=1;static ForwardsOnly=2;static BackwardsOnly=3;get archetypeLinkData(){return this.vS}set archetypeLinkData(t){t!==null&&Util.t(t,"object",LinkingTool,"archetypeLinkData"),t instanceof GraphObject&&Util.s(t,Link,LinkingTool,"archetypeLinkData"),this.vS=t}get archetypeLabelNodeData(){return this.JS}set archetypeLabelNodeData(t){t!==null&&Util.t(t,"object",LinkingTool,"archetypeLabelNodeData"),t instanceof GraphObject&&Util.s(t,Node,LinkingTool,"archetypeLabelNodeData"),this.JS=t}get direction(){return this.C}set direction(t){Util.tt(t,LinkingDirection,"LinkingDirection"),this.C=t}get startObject(){return this.ZS}set startObject(t){t!==null&&Util.s(t,GraphObject,LinkingTool,"startObject"),this.ZS=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||t.isModelReadOnly||!t.allowLink||!t.model.Jw()||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize()?!1:this.findLinkablePort()!==null}findLinkablePort(){const t=this.diagram;let i=this.startObject;if(i===null&&(i=t.findObjectAt(t.firstInput.documentPoint,null,null)),i===null)return null;const e=i.part;if(!(e instanceof Node))return null;const s=this.direction;if(s===1||s===2){const n=this.findValidLinkablePort(i,!1);if(n!==null)return this.isForwards=!0,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!1))return this.isForwards=!0,o}}if(s===1||s===3){const n=this.findValidLinkablePort(i,!0);if(n!==null)return this.isForwards=!1,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!0))return this.isForwards=!1,o}}return null}doActivate(){const t=this.diagram,i=this.findLinkablePort();if(i===null){this.stopTool();return}if(this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.isForwards){this.temporaryToNode!==null&&(this.temporaryToNode.location=t.lastInput.documentPoint),this.originalFromPort=i;const e=this.originalFromPort.part;e instanceof Node&&(this.originalFromNode=e),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else{this.temporaryFromNode!==null&&(this.temporaryFromNode.location=t.lastInput.documentPoint),this.originalToPort=i;const e=this.originalToPort.part;e instanceof Node&&(this.originalToNode=e),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0)}t.add(this.temporaryFromNode),this.temporaryFromNode&&this.temporaryFromNode.ensureBounds(),t.add(this.temporaryToNode),this.temporaryToNode&&this.temporaryToNode.ensureBounds(),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.temporaryLink.isTreeLink=this.isNewTreeLink(),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.startObject=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=null,e=null,s=null,n=null,o=null;try{this.targetPort=this.findTargetPort(this.isForwards);const r=this.targetPort;if(r!==null){const l=r.part;l instanceof Node&&(this.isForwards?(this.originalFromNode!==null&&(i=this.originalFromNode,e=this.originalFromPort),s=l,n=r):(i=l,e=r,this.originalToNode!==null&&(s=this.originalToNode,n=this.originalToPort)))}else this.isForwards?this.originalFromNode!==null&&this.isUnconnectedLinkValid&&(i=this.originalFromNode,e=this.originalFromPort):this.originalToNode!==null&&this.isUnconnectedLinkValid&&(s=this.originalToNode,n=this.originalToPort);i!==null||s!==null?(o=this.insertLink(i,e,s,n),o!==null?(r===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint),t.allowSelect&&(t.V("ChangingSelection",t.selection),t.clearSelection(!0),o.isSelected=!0),this.transactionResult=this.name,t.V("LinkDrawn",o)):this.doNoLink(i,e,s,n)):this.isForwards?this.doNoLink(this.originalFromNode,this.originalFromPort,null,null):this.doNoLink(null,null,this.originalToNode,this.originalToPort)}finally{this.stopTool(),o&&t.allowSelect&&t.V("ChangedSelection",t.selection)}}}isNewTreeLink(){const t=this.archetypeLinkData;if(t===null)return!0;if(t instanceof Link)return t.isTreeLink;const i=this.diagram;if(i===null)return!0;const e=i.partManager.getLinkCategoryForData(t),s=i.partManager.findLinkTemplateForCategory(e);return s!==null?s.isTreeLink:!0}insertLink(t,i,e,s){return this.diagram.partManager.insertLink(t,i,e,s)}doNoLink(t,i,e,s){}}class RelinkingTool extends LinkingBaseTool{$S;QS;ps;_S;constructor(t){super(),this.name="Relinking",this.$S=new Shape("Diamond",{desiredSize:Size.gu,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:0}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.QS=new Shape("Diamond",{desiredSize:Size.gu,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:-1}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.ps=null,this._S=new Rect,t&&Object.assign(this,t)}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i="RelinkFrom",e=null;if(t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkFrom()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null&&(e=this.makeAdornment(s,!1),t.addAdornment(i,e)))}if(e===null&&t.removeAdornment(i),i="RelinkTo",e=null,t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkTo()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null?(e=this.makeAdornment(s,!0),t.addAdornment(i,e)):e.u())}e===null&&t.removeAdornment(i)}makeAdornment(t,i){const e=new Adornment;e.type=Panel.Link;const s=i?this.toHandleArchetype:this.fromHandleArchetype;return s!==null&&e.add(s.copy().Am()),e.adornedObject=t,e}get fromHandleArchetype(){return this.$S}set fromHandleArchetype(t){t!==null&&Util.s(t,GraphObject,RelinkingTool,"fromHandleArchetype"),this.$S=t}get toHandleArchetype(){return this.QS}set toHandleArchetype(t){t!==null&&Util.s(t,GraphObject,RelinkingTool,"toHandleArchetype"),this.QS=t}get handle(){return this.ps}set handle(t){if(t!==null&&(Util.s(t,GraphObject,RelinkingTool,"handle"),!(t.part instanceof Adornment)))throw new Error("new handle is not in an Adornment: "+t);this.ps=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowRelink||!t.model.Jw()||!t.lastInput.left)return!1;let e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom");return e===null&&(e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo")),e!==null}doActivate(){const t=this.diagram;if(this.originalLink===null){let i=this.handle;if(i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom"),i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo"))),i===null)return;const e=i.part;if(!(e instanceof Adornment)||!(e.adornedPart instanceof Link))return;this.handle=i,this.isForwards=e===null||e.category==="RelinkTo",this.originalLink=e.adornedPart}this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.originalFromPort=this.originalLink.fromPort,this.originalFromNode=this.originalLink.fromNode,this.originalToPort=this.originalLink.toPort,this.originalToNode=this.originalLink.toNode,this._S.set(this.originalLink.actualBounds),this.originalLink!==null&&this.originalLink.pointsCount>0&&(this.originalLink.fromNode===null&&(this.temporaryFromPort!==null&&(this.temporaryFromPort.desiredSize=Size.lf),this.temporaryFromNode!==null&&(this.temporaryFromNode.location=this.originalLink.getPoint(0))),this.originalLink.toNode===null&&(this.temporaryToPort!==null&&(this.temporaryToPort.desiredSize=Size.lf),this.temporaryToNode!==null&&(this.temporaryToNode.location=this.originalLink.getPoint(this.originalLink.pointsCount-1)))),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0),t.add(this.temporaryFromNode),t.add(this.temporaryToNode),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.copyLinkProperties(this.originalLink,this.temporaryLink),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}copyLinkProperties(t,i){if(t===null||i===null)return;i.adjusting=t.adjusting,i.corner=t.corner;let e=t.curve;(e===11||e===10)&&(e=0),i.curve=e,i.curviness=t.curviness,i.isTreeLink=t.isTreeLink,i.points=t.points,i.routing=t.routing,i.smoothness=t.smoothness,i.fromSpot=t.fromSpot,i.fromEndSegmentLength=t.fromEndSegmentLength,i.fromShortLength=t.fromShortLength,i.toSpot=t.toSpot,i.toEndSegmentLength=t.toEndSegmentLength,i.toShortLength=t.toShortLength}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.handle=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=this.originalFromNode,e=this.originalFromPort,s=this.originalToNode,n=this.originalToPort,o=this.originalLink;try{if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null){const r=this.targetPort.part;r instanceof Node&&(this.isForwards?(s=r,n=this.targetPort):(i=r,e=this.targetPort))}else this.isUnconnectedLinkValid?this.isForwards?(s=null,n=null):(i=null,e=null):o=null;o!==null?(this.reconnectLink(o,this.isForwards?s:i,this.isForwards?n:e,this.isForwards),this.targetPort===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint,o.invalidateRoute()),this.transactionResult=this.name,t.V("LinkRelinked",o,this.isForwards?this.originalToPort:this.originalFromPort)):this.doNoRelink(this.originalLink,this.isForwards),this.originalLink.invalidateOtherJumpOvers(this._S)}finally{this.stopTool()}}}reconnectLink(t,i,e,s){const n=e!==null&&e.portId!==null?e.portId:"";return s?(t.toNode=i,t.toPortId=n):(t.fromNode=i,t.fromPortId=n),!0}doNoRelink(t,i){}doDraggingMouseMove(t,i,e,s){t!==null?(this.copyPortProperties(t,i,this.temporaryFromNode,this.temporaryFromPort,!1),this.diagram.add(this.temporaryFromNode)):this.diagram.remove(this.temporaryFromNode),e!==null?(this.copyPortProperties(e,s,this.temporaryToNode,this.temporaryToPort,!0),this.diagram.add(this.temporaryToNode)):this.diagram.remove(this.temporaryToNode)}stopDraggingMouseMove(){this.diagram.remove(this.temporaryFromNode),this.diagram.remove(this.temporaryToNode)}}var ReshapingBehavior=(w=>(w[w.None=0]="None",w[w.Horizontal=1]="Horizontal",w[w.Vertical=2]="Vertical",w[w.All=3]="All",w))(ReshapingBehavior||{});class LinkReshapingTool extends Tool{Fo;tM;iM;ps;Zw;eM;Lm;constructor(t){super(),this.name="LinkReshaping",this.Fo=new Shape("Rectangle",{desiredSize:Size.aC,fill:"lightblue",stroke:"dodgerblue"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.tM=new Shape("Diamond",{desiredSize:Size.gu,fill:"lightblue",stroke:"dodgerblue",cursor:"move"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.iM=3,this.ps=null,this.Zw=null,this.eM=new Point,this.Lm=new List,t&&Object.assign(this,t)}static None=0;static Horizontal=1;static Vertical=2;static All=3;getReshapingBehavior(t){return t?t.Mr:0}setReshapingBehavior(t,i){t.Mr=i}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i=null;if(t.isSelected&&!this.diagram.isReadOnly){const e=t.path;e!==null&&t.canReshape()&&t.actualBounds.isReal()&&t.isVisible()&&e.actualBounds.isReal()&&e.isVisibleObject()&&(i=t.findAdornment(this.name),(i===null||i.sM!==t.pointsCount||i.nM!==t.resegmentable)&&(i=this.makeAdornment(e),i!==null&&(i.sM=t.pointsCount,i.nM=t.resegmentable,t.addAdornment(this.name,i))))}i===null&&t.removeAdornment(this.name)}makeAdornment(t){const i=t.part,e=i.points,s=i.pointsCount,n=i.isOrthogonal;let o=null;if(e!==null&&s>1){o=new Adornment,o.type=Panel.Link;const r=i.firstPickIndex,l=i.lastPickIndex,h=n?1:0;if(i.resegmentable&&i.computeCurve()!==9)for(let a=r+h;ae.firstPickIndex+1&&s0))this.cF(t,i);else if(t instanceof Panel){const e=t.elements;for(;e.next();){const s=e.value;this.updateResizeHandles(s,i)}}}}cF(t,i){let e=t.alignment;e.isNoSpot()&&(e=Spot.Center);let s=i;if(e.x<=0)e.y<=0?s+=225:e.y>=1?s+=135:s+=180;else if(e.x>=1)e.y<=0?s+=315:e.y>=1&&(s+=45);else if(e.y<=0)s+=270;else if(e.y>=1)s+=90;else return;s<0?s+=360:s>=360&&(s-=360),s<22.5?t.cursor="e-resize":s<67.5?t.cursor="se-resize":s<112.5?t.cursor="s-resize":s<157.5?t.cursor="sw-resize":s<202.5?t.cursor="w-resize":s<247.5?t.cursor="nw-resize":s<292.5?t.cursor="n-resize":s<337.5?t.cursor="ne-resize":t.cursor="e-resize"}get handleArchetype(){return this.Fo}set handleArchetype(t){t!==null&&Util.s(t,GraphObject,ResizingTool,"handleArchetype"),this.Fo=t}get handle(){return this.ps}set handle(t){if(t!==null&&(Util.s(t,GraphObject,ResizingTool,"handle"),!(t.part instanceof Adornment)))throw new Error("new handle is not in an Adornment: "+t);this.ps=t}get adornedObject(){return this.ys}set adornedObject(t){if(t!==null&&(Util.s(t,GraphObject,ResizingTool,"handle"),t.part instanceof Adornment))throw new Error("new handle must not be in an Adornment: "+t);this.ys=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowResize||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle!==null&&(this.adornedObject=this.handle.part.adornedObject,this.adornedObject!==null&&(t.isMouseCaptured=!0,t.animationManager.stopAnimation(),t.Pu=!0,this.startTransaction(this.name),this.Tm.set(this.adornedObject.getDocumentPoint(this.handle.alignment.opposite())),this.Nf.set(this.adornedObject.part.location),this.rM.set(this.adornedObject.desiredSize),this._w=this.computeCellSize(),this.$w=this.computeMinSize(),this.Qw=this.computeMaxSize(),this.isActive=!0))}doDeactivate(){const t=this.diagram;t.Pu=!1,t.Pl=!0,this.stopTransaction(),this.handle=null,this.ys=null,t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){this.adornedObject!==null&&(this.adornedObject.desiredSize=this.originalDesiredSize,this.adornedObject.part.location=this.originalLocation),this.stopTool()}doMouseMove(){const t=this.diagram;if(!this.isActive)return;const i=this.$w,e=this.Qw,s=this._w,n=t.lastInput.documentPoint,o=this.adornedObject.getLocalPoint(n,Point.a()),r=this.computeReshape(),l=this.computeResize(o,this.handle.alignment,i,e,s,r);this.resize(l),t.maybeUpdate(),Point.o(o)}doMouseUp(){const t=this.diagram;if(this.isActive){const i=this.$w,e=this.Qw,s=this._w,n=this.adornedObject.getLocalPoint(t.lastInput.documentPoint,Point.a()),o=this.computeReshape(),r=this.computeResize(n,this.handle.alignment,i,e,s,o);this.resize(r),Point.o(n),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.V("PartResized",this.adornedObject,this.originalDesiredSize)}this.stopTool()}resize(t){const i=this.diagram,e=this.adornedObject;if(e===null)return;e.desiredSize=t.size;const s=e.part;s.ensureBounds();const n=e.getDocumentPoint(this.handle.alignment.opposite());if(s instanceof Group){const o=new List;o.add(s);let r;!this.dragsMembers&&!s.hasPlaceholder()&&(r=new DraggingOptions,r.dragsMembers=!1),i.moveParts(o,this.oppositePoint.copy().subtract(n),!0,r)}else s.location=s.location.copy().subtract(n).add(this.oppositePoint);i.maybeUpdate()}computeResize(t,i,e,s,n,o){i.isNoSpot()&&(i=Spot.Center);const r=this.adornedObject.naturalBounds,l=r.x,h=r.y,a=r.x+r.width,f=r.y+r.height;let c=1;if(!o){let m=r.width,g=r.height;m<=0&&(m=1),g<=0&&(g=1),c=g/m}const u=Point.a();Geo.Hg(t.x,t.y,l,h,n.width,n.height,u);const d=r.copy();return i.x<=0?i.y<=0?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.y=Math.max(u.y,f-s.height),d.y=Math.min(d.y,f-e.height),d.height=Math.max(f-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width),d.x=a-d.width,d.y=f-d.height)):i.y>=1?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width),d.x=a-d.width)):(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=a-d.x,o||(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c,d.y=h+.5*(f-h-d.height))):i.x>=1?i.y<=0?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.y=Math.max(u.y,f-s.height),d.y=Math.min(d.y,f-e.height),d.height=Math.max(f-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width),d.y=f-d.height)):i.y>=1?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width))):(d.width=Math.max(Math.min(u.x-l,s.width),e.width),o||(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c,d.y=h+.5*(f-h-d.height))):i.y<=0?(d.y=Math.max(u.y,f-s.height),d.y=Math.min(d.y,f-e.height),d.height=f-d.y,o||(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width,d.x=l+.5*(a-l-d.width))):i.y>=1&&(d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width,d.x=l+.5*(a-l-d.width))),Point.o(u),d}computeReshape(){let t=0;return this.adornedObject instanceof Shape&&(t=this.adornedObject.lM()),!(t===6||this.diagram.lastInput.shift)}computeMinSize(){const t=this.adornedObject.minSize.copy(),i=this.minSize;return!isNaN(i.width)&&i.width>t.width&&(t.width=i.width),!isNaN(i.height)&&i.height>t.height&&(t.height=i.height),t}computeMaxSize(){const t=this.adornedObject.maxSize.copy(),i=this.maxSize;return!isNaN(i.width)&&i.width0&&(t.width=n.width),!isNaN(n.height)&&n.height>0&&(t.height=n.height)}let e=this.cellSize;isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height);const s=this.diagram;if((isNaN(t.width)||isNaN(t.height))&&s){const n=s.grid;n!==null&&n.visible&&this.isGridSnapEnabled&&(e=n.gridCellSize,isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height))}return(isNaN(t.width)||t.width===0||t.width===1/0)&&(t.width=1),(isNaN(t.height)||t.height===0||t.height===1/0)&&(t.height=1),t}get minSize(){return this.Pr}set minSize(t){if(Util.s(t,Size,ResizingTool,"minSize"),!this.Pr.equals(t)){let e=t.width;isNaN(e)&&(e=0);let s=t.height;isNaN(s)&&(s=0),this.Pr.e(e,s)}}get maxSize(){return this.Nr}set maxSize(t){if(Util.s(t,Size,ResizingTool,"maxSize"),!this.Nr.equals(t)){let e=t.width;isNaN(e)&&(e=1/0);let s=t.height;isNaN(s)&&(s=1/0),this.Nr.e(e,s)}}get cellSize(){return this.Ro}set cellSize(t){Util.s(t,Size,ResizingTool,"cellSize"),this.Ro.equals(t)||this.Ro.c(t)}get isGridSnapEnabled(){return this.Pf}set isGridSnapEnabled(t){Util.t(t,"boolean",ResizingTool,"isGridSnapEnabled"),this.Pf=t}get dragsMembers(){return this.oM}set dragsMembers(t){Util.t(t,"boolean",ResizingTool,"dragsMembers"),this.oM=t}get oppositePoint(){return this.Tm}set oppositePoint(t){Util.s(t,Point,ResizingTool,"oppositePoint"),this.Tm.equals(t)||this.Tm.c(t)}get originalDesiredSize(){return this.rM}get originalLocation(){return this.Nf}}class RotatingTool extends Tool{hM;aM;ys;Fo;ps;fM;Dm;Nf;cM;uM;constructor(t){super(),this.name="Rotating",this.hM=45,this.aM=2,this.Nf=new Point,this.ys=null,this.Fo=new Shape("Ellipse",{desiredSize:Size.gu,fill:"lightblue",stroke:"dodgerblue",strokeWidth:1,cursor:"pointer"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.ps=null,this.fM=0,this.Dm=new Point(NaN,NaN),this.cM=0,this.uM=50,t&&Object.assign(this,t)}updateAdornments(t){if(t!==null){if(t.Dl()){const i=t.rotateObject;if(i===t||i===t.path||i.isPanelMain)return}if(t.isSelected&&!this.diagram.isReadOnly){const i=t.rotateObject;if(i!==null&&t.canRotate()&&t.actualBounds.isReal()&&t.isVisible()&&i.actualBounds.isReal()&&i.isVisibleObject()){let e=t.findAdornment(this.name);if((e===null||e.adornedObject!==i)&&(e=this.makeAdornment(i)),e!==null){e.angle=i.getDocumentAngle(),e.hasPlaceholder()||(e.location=this.computeAdornmentLocation(i)),t.addAdornment(this.name,e);return}}}t.removeAdornment(this.name)}}makeAdornment(t){let i=null;const e=t.part.rotateAdornmentTemplate;if(e===null){i=new Adornment,i.type=Panel.Position,i.locationSpot=Spot.Center;const s=this.handleArchetype;s!==null&&i.add(s.copy().Am())}else if(e.ci(),i=e.copy(),i===null)return null;return i.adornedObject=t,i}get handleArchetype(){return this.Fo}set handleArchetype(t){t!==null&&Util.s(t,GraphObject,RotatingTool,"handleArchetype"),this.Fo=t}get handle(){return this.ps}set handle(t){if(t!==null&&(Util.s(t,GraphObject,RotatingTool,"handle"),!(t.part instanceof Adornment)))throw new Error("new handle is not in an Adornment: "+t);this.ps=t}get adornedObject(){return this.ys}set adornedObject(t){if(t!==null&&(Util.s(t,GraphObject,RotatingTool,"handle"),t.part instanceof Adornment))throw new Error("new handle must not be in an Adornment: "+t);this.ys=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowRotate||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;if(this.adornedObject===null){if(this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle===null)return;this.adornedObject=this.handle.part.adornedObject}this.adornedObject!==null&&(t.isMouseCaptured=!0,t.delaysLayout=!0,this.startTransaction(this.name),this.fM=this.adornedObject.angle,this.Dm=this.computeRotationPoint(this.adornedObject),this.Nf=this.adornedObject.part.location.copy(),this.isActive=!0)}computeRotationPoint(t){const i=t.part,e=i.locationObject;return i.rotationSpot.isSpot()?t.getDocumentPoint(i.rotationSpot):t===i||t===e?e.getDocumentPoint(i.locationSpot):t.getDocumentPoint(Spot.Center)}computeAdornmentLocation(t){let i=this.rotationPoint;i.isReal()||(i=this.computeRotationPoint(t));const e=t.getLocalPoint(i);let s=this.handleAngle;s<0?s+=360:s>=360&&(s-=360),s=Math.round(Math.round(s/45)*45);const n=this.handleDistance;return s===0?e.x=t.naturalBounds.width+n:s===45?(e.x=t.naturalBounds.width+n,e.y=t.naturalBounds.height+n):s===90?e.y=t.naturalBounds.height+n:s===135?(e.x=-n,e.y=t.naturalBounds.height+n):s===180?e.x=-n:s===225?(e.x=-n,e.y=-n):s===270?e.y=-n:s===315&&(e.x=t.naturalBounds.width+n,e.y=-n),t.getDocumentPoint(e)}doDeactivate(){const t=this.diagram;this.stopTransaction(),this.handle=null,this.ys=null,this.Dm=new Point(NaN,NaN),t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){const t=this.diagram;t.delaysLayout=!1,this.rotate(this.originalAngle),this.stopTool()}doMouseMove(){const t=this.diagram;if(this.isActive){const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i)}}doMouseUp(){const t=this.diagram;if(this.isActive){t.delaysLayout=!1;const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.V("PartRotated",this.adornedObject,this.originalAngle)}this.stopTool()}rotate(t){Debug&&Util.r(t,RotatingTool,"rotate:newangle");const i=this.adornedObject;if(i===null)return;i.angle=t;const e=i.part;e.ensureBounds();const s=e.locationObject,n=e.rotateObject;if(s===n||s.isContainedBy(n)){const o=this.Nf.copy();e.location=o.subtract(this.rotationPoint).rotate(t-this.originalAngle).add(this.rotationPoint)}this.diagram.maybeUpdate()}computeRotate(t){let i=this.rotationPoint.directionPoint(t)-this.handleAngle;const e=this.adornedObject.panel;e!==null&&(i-=e.getDocumentAngle()),i>=360?i-=360:i<0&&(i+=360);const s=Math.min(Math.abs(this.snapAngleMultiple),180),n=Math.min(Math.abs(this.snapAngleEpsilon),s/2);return!this.diagram.lastInput.shift&&s>0&&n>0&&(i%ss-n&&(i=(Math.floor(i/s)+1)*s)),i>=360?i-=360:i<0&&(i+=360),i}get snapAngleMultiple(){return this.hM}set snapAngleMultiple(t){Util.t(t,"number",RotatingTool,"snapAngleMultiple"),this.hM=t}get snapAngleEpsilon(){return this.aM}set snapAngleEpsilon(t){Util.t(t,"number",RotatingTool,"snapAngleEpsilon"),this.aM=t}get originalAngle(){return this.fM}get rotationPoint(){return this.Dm}set rotationPoint(t){this.Dm=t.copy()}get handleAngle(){return this.cM}set handleAngle(t){Util.t(t,"number",RotatingTool,"handleAngle"),this.cM=t}get handleDistance(){return this.uM}set handleDistance(t){Util.t(t,"number",RotatingTool,"handleDistance"),this.uM=t}}class ClickSelectingTool extends Tool{constructor(t){super(),this.name="ClickSelecting",t&&Object.assign(this,t)}canStart(){return!(!this.isEnabled||this.isBeyondDragSize())}doMouseUp(){this.isActive&&(this.standardMouseSelect(),this.standardMouseClick()||this.diagram.lastInput.isTouchEvent&&this.diagram.toolManager.doToolTip()),this.stopTool()}}class ActionTool extends Tool{Cf;constructor(t){super(),this.name="Action",this.Cf=null,t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram,i=t.lastInput,e=t.findObjectAt(i.documentPoint,s=>{for(;s.panel!==null;){if(s.isActionable)return s;s=s.panel}return s});return e!==null&&e.isActionable?(this.Cf=e,t.wf=t.findObjectAt(i.documentPoint,null,null),!0):!1}doMouseDown(){if(!this.isActive)this.canStart()&&this.doActivate();else{const i=this.diagram.lastInput,e=this.Cf;if(e===null)return;i.targetObject=e,e.actionDown!==null&&e.actionDown(i,e)}}doMouseMove(){if(this.isActive){const i=this.diagram.lastInput,e=this.Cf;if(e===null)return;i.targetObject=e,e.actionMove!==null&&e.actionMove(i,e)}}doMouseUp(){if(this.isActive){const i=this.diagram.lastInput,e=this.Cf;if(e===null)return;i.targetObject=e,e.actionUp!==null&&e.actionUp(i,e),this.standardMouseClick(s=>{for(;s.panel!==null;){if(s.isActionable&&s===e)return s;s=s.panel}return s},s=>s===e)}this.stopTool()}doCancel(){const i=this.diagram.lastInput,e=this.Cf;e!==null&&(i.targetObject=e,e.actionCancel!==null&&e.actionCancel(i,e),this.stopTool())}doStop(){this.Cf=null}}class ClickCreatingTool extends Tool{Fl;dM;Pf;gM;constructor(t){super(),this.name="ClickCreating",this.Fl=null,this.dM=!0,this.Pf=!1,this.gM=new Point(0,0),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled||this.archetypeNodeData===null)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.lastInput.left||this.isBeyondDragSize())return!1;if(this.isDoubleClick){if(t.lastInput.clickCount===1&&(this.gM=t.lastInput.viewPoint.copy()),t.lastInput.clickCount!==2||this.isBeyondDragSize(this.gM))return!1}else if(t.lastInput.clickCount!==1)return!1;return!(t.currentTool!==this&&t.findPartAt(t.lastInput.documentPoint,!0)!==null)}doMouseUp(){const t=this.diagram;this.isActive&&this.insertPart(t.lastInput.documentPoint),this.stopTool()}insertPart(t){const i=this.diagram,e=this.archetypeNodeData;if(e===null)return null;let s=null;try{if(i.V("ChangingSelection",i.selection),this.startTransaction(this.name),e instanceof Part)e.Ae()&&(e.ci(),s=e.copy(),s!==null&&i.add(s));else if(e!==null){const n=i.model.copyNodeData(e);Util.Mt(n)&&(i.model.addNodeData(n),s=i.findPartForData(n))}if(s!==null){const n=Point.H(t.x,t.y);this.isGridSnapEnabled&&this.diagram.mM(s,t,n),s.location=n,i.allowSelect&&(i.clearSelection(!0),s.isSelected=!0),Point.o(n)}i.invalidateDocumentBounds(),this.transactionResult=this.name,i.V("PartCreated",s)}finally{this.stopTransaction(),i.V("ChangedSelection",i.selection)}return s}get archetypeNodeData(){return this.Fl}set archetypeNodeData(t){t!==null&&Util.t(t,"object",ClickCreatingTool,"archetypeNodeData"),this.Fl=t}get isDoubleClick(){return this.dM}set isDoubleClick(t){Util.t(t,"boolean",ClickCreatingTool,"isDoubleClick"),this.dM=t}get isGridSnapEnabled(){return this.Pf}set isGridSnapEnabled(t){Util.t(t,"boolean",ClickCreatingTool,"isGridSnapEnabled"),this.Pf=t}}class DragSelectingTool extends Tool{Uh;pM;Rl;constructor(t){super(),this.name="DragSelecting",this.Uh=175,this.pM=!1,this.Rl=new Part({layerName:"Tool",selectable:!1}).add(new Shape("Rectangle",{name:"SHAPE",fill:null,stroke:"magenta"}).theme("stroke","dragSelect")).ci(),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(!t.allowSelect)return!1;const i=t.lastInput;return!(!i.left||t.currentTool!==this&&(!this.isBeyondDragSize()||i.timestamp-t.firstInput.timestamp{const e=i.diagram;e!==null&&e.Li(root.document,"scroll",i.yM,!1),i.stopTool()},t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return!(!t.allowHorizontalScroll&&!t.allowVerticalScroll||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize())}doActivate(){const t=this.diagram;this.Do?(t.lastInput.bubbles=!0,t.Ht(root.document,"scroll",this.yM,!1)):(t.currentCursor="move",t.isMouseCaptured=!0,this.tx.c(t.position)),this.isActive=!0}doDeactivate(){const t=this.diagram;t.currentCursor="",t.isMouseCaptured=!1,this.isActive=!1}doCancel(){const t=this.diagram;t.position=this.tx,t.isMouseCaptured=!1,this.stopTool()}doMouseMove(){this._C()}doMouseUp(){this._C(),this.stopTool()}_C(){const t=this.diagram;if(this.isActive&&t){if(this.Do){t.lastInput.bubbles=!0;return}const i=t.position,e=t.firstInput.documentPoint,s=t.lastInput.documentPoint;let n=i.x+e.x-s.x,o=i.y+e.y-s.y;t.allowHorizontalScroll||(n=i.x),t.allowVerticalScroll||(o=i.y),t.position=this.QC.e(n,o)}}get bubbles(){return this.Do}set bubbles(t){Util.t(t,"boolean",PanningTool,"bubbles"),this.Do=t}get originalPosition(){return this.tx}}class HTMLInfo{ix;ex;wM;xM;constructor(t){this.ix=null,this.ex=null,this.wM=null,this.xM=null,t&&Object.assign(this,t)}get mainElement(){return this.wM}set mainElement(t){t!==null&&Util.s(t,HTMLElement,HTMLInfo,"mainElement"),this.wM=t}get show(){return this.ix}set show(t){this.ix!==t&&(t!==null&&Util.t(t,"function",HTMLInfo,"show"),this.ix=t)}get hide(){return this.ex}set hide(t){this.ex!==t&&(t!==null&&Util.t(t,"function",HTMLInfo,"hide"),this.ex=t)}get valueFunction(){return this.xM}set valueFunction(t){this.xM=t}}class ContextMenuButtonInfo{ui;Fm;Lf;constructor(t,i,e){this.ui=t,this.Fm=i,this.Lf=e}}class ContextMenuTool extends Tool{bM;sx;kM;SM;nx;ox;Rm;constructor(t){super(),this.name="ContextMenu",this.bM=null,this.sx=null,this.kM=null,this.SM=new Point,this.nx=null,this.Rm=!1;const i=this;this.ox=()=>i.stopTool(),t&&Object.assign(this,t)}uF(){const t=new HTMLInfo;t.show=(r,l,h)=>h.showDefaultContextMenu(),t.hide=(r,l)=>l.hideDefaultContextMenu(),ContextMenuTool.Lu=t;const i=this;this.ox=()=>i.stopTool();const e=Util.ln("div"),s=Util.ln("div");e.style.cssText="top: 0px;z-index:10002;position: fixed;display: none;text-align: center;left: 25%;width: 50%;background-color: #F5F5F5;padding: 16px;border: 16px solid #444;border-radius: 10px;margin-top: 10px",s.style.cssText="z-index:10001;position: fixed;display: none;top: 0;left: 0;width: 100%;height: 100%;background-color: black;opacity: 0.8;";const n=Util.ln("style");root.document.getElementsByTagName("head")[0].appendChild(n),n.sheet.insertRule(".goCXul { list-style: none; }",0),n.sheet.insertRule(".goCXli {font:700 1.5em Helvetica, Arial, sans-serif;position: relative;min-width: 60px; }",0),n.sheet.insertRule(".goCXa {color: #444;display: inline-block;padding: 4px;text-decoration: none;margin: 2px;border: 1px solid gray;border-radius: 10px; }",0);const o=this.diagram;o!==null&&(o.Ht(e,"contextmenu",ContextMenuTool.jh,!1),o.Ht(e,"selectstart",ContextMenuTool.jh,!1),o.Ht(s,"contextmenu",ContextMenuTool.jh,!1)),e.className="goCXforeground",s.className="goCXbackground",root.document.body&&(root.document.body.appendChild(e),root.document.body.appendChild(s)),ContextMenuTool.Im=e,ContextMenuTool.Om=s,ContextMenuTool.MM=!0}static Lu=null;static MM=!1;static Om=null;static Im=null;static jh(t){return t.preventDefault(),!1}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return this.isBeyondDragSize()||!t.lastInput.right||t.lastInput.clickCount>1?!1:!!(t.lastInput.isTouchEvent&&this.defaultTouchContextMenu!==null||this.findObjectWithContextMenu()!==null)}doStart(){const t=this.diagram;this.SM.set(t.firstInput.documentPoint)}doStop(){this.hideContextMenu(),this.currentObject=null,this.Rm=!1}findObjectWithContextMenu(t){t===void 0&&(t=null);const i=this.diagram,e=i.lastInput;let s=null;if(t instanceof Diagram||(t instanceof GraphObject?s=t:s=i.findObjectAt(e.documentPoint,null,n=>!n.layer.isTemporary)),s!==null){let n=s;for(;n!==null;){if(n.contextMenu!==null)return n;n=n.panel}if(i.lastInput.isTouchEvent&&this.defaultTouchContextMenu)return s.part}else if(i.contextMenu!==null)return i;return null}doActivate(){}doMouseDown(){if(super.doMouseDown(),this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doMouseDown(),t.doDeactivate())}this.diagram.toolManager.mouseDownTools.has(this)&&this.doContextClick()}doMouseUp(){if(this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doCancel(),t.doDeactivate())}this.doContextClick()}doContextClick(){const t=this.diagram;if(!this.isActive)this.canStart()&&(this.openMenu(!0),this.isActive||this.stopTool());else{const i=this.currentContextMenu;if(i===null)return;let e=null;i instanceof HTMLInfo||(e=t.findObjectAt(t.lastInput.documentPoint,null,null),e!==null&&e.isContainedBy(i)&&this.standardMouseClick(null,null)),this.maybeStopTool(e)}}maybeStopTool(t){this.stopTool(),this.canStart()&&(this.diagram.currentTool=this,this.doMouseUp())}openMenu(t,i){if(i===void 0&&(i=null),this.Rm)return;this.Rm=!0,t&&this.standardMouseSelect();const e=this.standardMouseClick();if(this.Rm=!1,!e){this.isActive=!0;const s=ContextMenuTool.Lu;if(i===null&&(i=this.findObjectWithContextMenu()),i!==null){const n=i.contextMenu;n!==null?(this.currentObject=i instanceof GraphObject?i:null,this.showContextMenu(n,this.currentObject)):s!==null&&this.showContextMenu(s,this.currentObject)}else s!==null&&this.showContextMenu(s,null);this.currentContextMenu instanceof Adornment&&!this.currentContextMenu.visible&&this.stopTool()}}doMouseMove(){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.doMouseMove(),this.isActive&&this.diagram.toolManager.doMouseMove()}showContextMenu(t,i){Debug&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("showContextMenu:contextMenu must be an Adornment or HTMLInfo."),i!==null&&Util.s(i,GraphObject,ContextMenuTool,"showContextMenu:obj");const e=this.diagram;if(t!==this.currentContextMenu&&this.hideContextMenu(),t instanceof Adornment){const s=t;s.layerName="Tool",s.selectable=!1,s.scale=1/e.scale,s.category=this.name,s.hasPlaceholder()&&(s.placeholder.scale=e.scale);const n=s.diagram;n!==null&&n!==e&&n.remove(s),e.add(s),i!==null?s.adornedObject=i:s.data=e.model,s.ensureBounds(),this.positionContextMenu(s,i)}else t instanceof HTMLInfo&&t.show(i,e,this);this.currentContextMenu=t}positionContextMenu(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom&&(n.y-=o.height+5/s.scale),n.ye.commandHandler.copySelection(),e=>e.commandHandler.canCopySelection())),i.add(new ContextMenuButtonInfo("Cut",e=>e.commandHandler.cutSelection(),e=>e.commandHandler.canCutSelection())),i.add(new ContextMenuButtonInfo("Delete",e=>e.commandHandler.deleteSelection(),e=>e.commandHandler.canDeleteSelection())),i.add(new ContextMenuButtonInfo("Paste",e=>e.commandHandler.pasteSelection(t.mouseDownPoint),e=>e.commandHandler.canPasteSelection(t.mouseDownPoint))),i.add(new ContextMenuButtonInfo("Select All",e=>e.commandHandler.selectAll(),e=>e.commandHandler.canSelectAll())),i.add(new ContextMenuButtonInfo("Undo",e=>e.commandHandler.undo(),e=>e.commandHandler.canUndo())),i.add(new ContextMenuButtonInfo("Redo",e=>e.commandHandler.redo(),e=>e.commandHandler.canRedo())),i.add(new ContextMenuButtonInfo("Scroll To Part",e=>e.commandHandler.scrollToPart(),e=>e.commandHandler.canScrollToPart())),i.add(new ContextMenuButtonInfo("Zoom To Fit",e=>e.commandHandler.zoomToFit(),e=>e.commandHandler.canZoomToFit())),i.add(new ContextMenuButtonInfo("Reset Zoom",e=>e.commandHandler.resetZoom(),e=>e.commandHandler.canResetZoom())),i.add(new ContextMenuButtonInfo("Group Selection",e=>e.commandHandler.groupSelection(),e=>e.commandHandler.canGroupSelection())),i.add(new ContextMenuButtonInfo("Ungroup Selection",e=>e.commandHandler.ungroupSelection(),e=>e.commandHandler.canUngroupSelection())),i.add(new ContextMenuButtonInfo("Edit Text",e=>e.commandHandler.editTextBlock(),e=>e.commandHandler.canEditTextBlock())),i}showDefaultContextMenu(){const t=this.diagram;this.nx===null&&(this.nx=this.dF()),ContextMenuTool.Im.innerHTML="",ContextMenuTool.Om.addEventListener("pointerdown",this.ox,!1);const i=this,e=Util.ln("ul");e.className="goCXul",ContextMenuTool.Im.appendChild(e),e.innerHTML="";const s=this.nx.iterator;for(;s.next();){const n=s.value,o=n.Fm,r=n.Lf;if(typeof o!="function"||typeof r=="function"&&!r(t))continue;const l=Util.ln("li");l.className="goCXli";const h=Util.ln("a");h.className="goCXa",h.href="#",h.Fm=n.Fm,h.addEventListener("pointerdown",function(a){return this.Fm(t),i.stopTool(),a.preventDefault(),!1},!1),h.textContent=n.ui,l.appendChild(h),e.appendChild(l)}ContextMenuTool.Im.style.display="block",ContextMenuTool.Om.style.display="block"}hideDefaultContextMenu(){if(this.currentContextMenu===null||this.currentContextMenu!==ContextMenuTool.Lu)return;ContextMenuTool.Im.style.display="none",ContextMenuTool.Om.style.display="none";const t=this.diagram;t!==null&&t.Li(ContextMenuTool.Om,"pointerdown",this.ox,!1),this.currentContextMenu=null}get currentContextMenu(){return this.bM}set currentContextMenu(t){Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("ContextMenuTool.currentContextMenu must be an Adornment or HTMLInfo."),this.bM=t,this.sx=t instanceof Adornment?t.adornedPart:null}get defaultTouchContextMenu(){return ContextMenuTool.MM===!1&&ContextMenuTool.Lu===null&&Diagram.isUsingDOM()&&this.uF(),ContextMenuTool.Lu}set defaultTouchContextMenu(t){Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("ContextMenuTool.defaultTouchContextMenu must be an Adornment or HTMLInfo."),t===null&&(ContextMenuTool.MM=!0),ContextMenuTool.Lu=t}get currentObject(){return this.kM}set currentObject(t){t!==null&&Util.s(t,GraphObject,ContextMenuTool,"currentObject"),this.kM=t}get mouseDownPoint(){return this.SM}}var TextEditingAccept=(w=>(w[w.LostFocus=1]="LostFocus",w[w.MouseDown=2]="MouseDown",w[w.Tab=3]="Tab",w[w.Enter=4]="Enter",w))(TextEditingAccept||{}),TextEditingStarting=(w=>(w[w.SingleClick=1]="SingleClick",w[w.SingleClickSelected=2]="SingleClickSelected",w[w.DoubleClick=3]="DoubleClick",w))(TextEditingStarting||{}),TextEditingState=(w=>(w[w.None=1]="None",w[w.Active=2]="Active",w[w.Editing=3]="Editing",w[w.Validating=4]="Validating",w[w.Invalid=5]="Invalid",w[w.Validated=6]="Validated",w))(TextEditingState||{});class TextEditingTool extends Tool{Le;PM;NM;Il;vt;CM;AM;LM;rx;lx;constructor(t){super(),this.name="TextEditing",this.Le=new TextBlock,this.PM=null,this.NM=2,this.Il=null,this.vt=1,this.CM=1,this.AM=!0,this.LM=null,this.rx=new HTMLInfo,this.lx=null,this.gF(this.rx),t&&Object.assign(this,t)}static LostFocus=1;static MouseDown=2;static Tab=3;static Enter=4;static SingleClick=1;static SingleClickSelected=2;static DoubleClick=3;static StateNone=1;static StateActive=2;static StateEditing=3;static StateValidating=4;static StateInvalid=5;static StateValidated=6;gF(t){if(!Diagram.isUsingDOM())return;const i=Util.ln("textarea");this.lx=i;const e=this;i.addEventListener("input",function(s){if(e.textBlock===null)return;const n=e.measureTemporaryTextBlock(this.value),o=this.textScale;this.style.width=20+Math.max(e.textBlock.measuredBounds.width,n.measuredBounds.width)*o+"px",this.rows=Math.max(e.textBlock.lineCount,n.lineCount)},!1),i.addEventListener("keydown",function(s){if(s.isComposing||e.textBlock===null)return;const n=s.key;if(n==="Enter"){e.textBlock.isMultiline===!1&&s.preventDefault(),e.acceptText(4);return}else if(n==="Tab"){e.acceptText(3),s.preventDefault();return}else n==="Escape"&&(e.doCancel(),e.diagram!==null&&e.diagram.doFocus())},!1),i.addEventListener("focus",function(s){e.mF(s)},!1),i.addEventListener("blur",function(s){e.pF(s)},!1),t.valueFunction=()=>i.value,t.mainElement=i,t.show=(s,n,o)=>{if(!(s instanceof TextBlock&&o instanceof TextEditingTool))return;if(o.state===5){i.style.border="3px solid red",i.focus();return}const r=s.getDocumentPoint(Spot.Center),l=n.position,h=n.scale;let a=s.getDocumentScale()*h;a{s.div.removeChild(i)}}get textBlock(){return this.PM}set textBlock(t){t!==null&&Util.s(t,TextBlock,TextEditingTool,"textBlock"),this.PM=t}get currentTextEditor(){return this.LM}set currentTextEditor(t){this.LM=t}get defaultTextEditor(){return this.rx}set defaultTextEditor(t){Debug&&!(t instanceof HTMLInfo)&&Util.n("TextEditingTool.defaultTextEditor must be an HTMLInfo."),this.rx=t}get starting(){return this.NM}set starting(t){Util.tt(t,TextEditingStarting,"TextEditingStarting"),this.NM=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t===null||t.isReadOnly||TextEditingTool.Tf&&TextEditingTool.Tf!==this&&(TextEditingTool.Tf.acceptText(2),TextEditingTool.Tf&&TextEditingTool.Tf!==this)||!t.lastInput.left||this.isBeyondDragSize())return!1;const i=t.lastInput.documentPoint,e=t.findObjectAt(i);if(e===null||!(e instanceof TextBlock)||!e.editable||!e.part.canEdit())return!1;const s=e.part;return!(s===null||this.starting===2&&!s.isSelected||this.starting===3&&t.lastInput.clickCount<2)}doStart(){TextEditingTool.Tf=this,this.textBlock!==null&&this.doActivate()}doActivate(){if(this.isActive)return;const t=this.diagram;if(t===null)return;let i=this.textBlock;if(i===null&&(i=t.findObjectAt(t.lastInput.documentPoint)),i===null||!(i instanceof TextBlock)||(this.textBlock=i,i.part===null))return;t.animationManager.stopAnimation(),this.isActive=!0,this.vt=2;let s=this.defaultTextEditor;i.textEditor!==null&&(s=i.textEditor),this.Le=this.textBlock.copy();const n=new Rect(this.textBlock.getDocumentPoint(Spot.TopLeft),this.textBlock.getDocumentPoint(Spot.BottomRight));t.scrollToRect(n),s.show(i,t,this),this.currentTextEditor=s}doCancel(){this.stopTool()}doMouseUp(){this.canStart()&&this.doActivate()}doMouseDown(){this.isActive&&this.acceptText(2)}acceptText(t){switch(t){case 2:this.vt===6?this.currentTextEditor instanceof HTMLElement&&this.currentTextEditor.focus():(this.vt===2||this.vt===5||this.vt===3)&&(this.vt=4,this.tA());break;case 1:case 4:case 3:if(t===4&&this.textBlock.isMultiline===!0)return;(this.vt===2||this.vt===5||this.vt===3)&&(this.vt=4,this.tA());break}}tA(){const t=this.textBlock,i=this.diagram,e=this.currentTextEditor;if(t!==null&&e!==null){const s=t.text;let n="";if(e.valueFunction!==null&&(n=e.valueFunction()),!this.isValidText(t,s,n)){this.vt=5,this.doError(s,n);return}this.startTransaction(this.name),this.vt=6,this.transactionResult=this.name,t.text=n,this.doSuccess(s,n),i!==null&&i.V("TextEdited",t,s),this.stopTransaction(),this.stopTool(),i!==null&&i.doFocus()}}doError(t,i){const e=this.textBlock;e.errorFunction!==null&&e.errorFunction(this,t,i);const s=this.currentTextEditor;s&&s.show(e,this.diagram,this)}doSuccess(t,i){const e=this.textBlock;e.textEdited!==null&&e.textEdited(e,t,i)}doDeactivate(){const t=this.diagram;t!==null&&(this.vt=1,this.currentTextEditor!==null&&this.currentTextEditor.hide(t,this),this.textBlock=null,this.isActive=!1)}doStop(){TextEditingTool.Tf=null}mF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this.lx;this.vt===2&&(this.vt=3),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}pF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this.lx;typeof i.focus=="function"&&i.focus(),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}isValidText(t,i,e){Util.s(t,TextBlock,TextEditingTool,"isValidText:textblock");const s=this.textValidation;if(s!==null&&!s(t,i,e))return!1;const n=t.textValidation;return!(n!==null&&!n(t,i,e))}get textValidation(){return this.Il}set textValidation(t){t!==null&&Util.t(t,"function",TextEditingTool,"textValidation"),this.Il=t}get minimumEditorScale(){return this.CM}set minimumEditorScale(t){t!==null&&Util.t(t,"number",TextEditingTool,"minimumEditorScale"),this.CM=t}get selectsTextOnActivate(){return this.AM}set selectsTextOnActivate(t){t!==null&&Util.t(t,"boolean",TextEditingTool,"selectsTextOnActivate"),this.AM=t}get state(){return this.vt}set state(t){this.vt!==t&&(Util.tt(t,TextEditingState,"TextEditingState"),this.vt=t)}measureTemporaryTextBlock(t){const i=this.Le;return i.text=t,i.wt(this.textBlock.Ol,1/0),i}static Tf=null}var AnimationStyle=(w=>(w[w.Default=1]="Default",w[w.AnimateLocations=2]="AnimateLocations",w[w.None=3]="None",w))(AnimationStyle||{});class AnimationManager{b;Ti;Xi;Cr;Zn;Io;TM;DM;Em;Si;Df;yn;Vm;Wh;hx;Bm;ax;Ff;Cu;zm;constructor(t){this.b=Diagram.Mm(),this.Ti=!1,this.Em=!1,this.Si=!1,this.Df=!1,this.ax=!0,this.Ff=1,this.Cu=!1,this.Xi=!0,this.Cr=!0,this.Io=600,this.TM=!1,this.DM=!1,this.Zn=new GSet,this.yn=new Animation,this.Vm=new Animation,this.yn.ws=this,this.Wh=new GSet,this.hx=new GSet,this.Bm=new GSet,this.zm=new GSet,t&&Object.assign(this,t)}Oo(t){this.b=t}aE(){return this.b}canStart(t){return!0}El(t){return!this.Xi||!this.canStart(t)?!1:(this.Zn.add(t),this.defaultAnimation.isAnimating&&this.stopAnimation(),this.b.Di(),this.Si=!0,!0)}getBundleAnimation(){return this.Vm}FM(){if(!this.Xi||(this.Vm.ge.count>0&&this.Vm.start(),!this.Si))return;const t=this.yn,i=this.b,e=this.Zn.has("Model");if(e&&(this.Df=!0,this.Ff===1?(t.isViewportUnconstrained=!0,t.ge.clear(),t.add(i,"position",i.position.copy().offset(0,-200),i.position),t.add(i,"opacity",0,1)):this.Ff===3&&t.ge.clear(),this.Ff===2&&i.fx.equals(i.mt)?this.ax=!0:this.ax=!1,i.V("InitialAnimationStarting",this)),e&&!this.Cr||t.ge.count===0){this.Zn.clear(),this.Si=!1,t.ge.clear(),t.cx(i),this.Df=!1,i.T();return}this.Zn.clear(),i.Ar=!1;const s=t.ge.get(i);i.autoScale!==1&&s!==null&&(delete s.li.scale,delete s.xs.scale);const n=this;root.requestAnimationFrame(()=>{n.Si===!1||t.Ti||(i.getRenderingHint("temporaryPixelRatio")&&i.jw(),i.RM(),n.Si=!1,t.start(),t.Ti&&(n.Tu(),i.invalidateDocumentBounds(),t.iA(0),i.Sr(!0),n.Du(),i.V("AnimationStarting",n)))})}IM(){return this.Zn.has("Trigger")&&this.Zn.count===1}eA(t,i,e,s){this.isTicking||this.IM()||t instanceof Link&&(t.fromNode!==null||t.toNode!==null)||this.yn.add(t,"position",i,e,s)}ux(t){return this.yn.ux(t)}OM(t){return this.yn.OM(t)}yF(t){const i=this.Wh,e=this;function s(){if(e.Bm.count>0&&(i.addAll(e.Bm),e.Bm.clear(),e.Ti=!0),e.Ti===!1||i.count===0)return;e.hx.addAll(i);const n=e.hx.iterator;for(;n.next();){const o=n.value;o.Ti!==!1&&(o.wF()?o.sA(!1):o.Rf=!0)}if(e.hx.clear(),e.Ti===!1){root.requestAnimationFrame(s);return}e.Tu(),e.b.Sr(),e.Du(),root.requestAnimationFrame(s)}this.Ti?this.xF(t):(this.Ti=!0,i.add(t),root.requestAnimationFrame(()=>s()))}xF(t){this.Bm.add(t)}bF(){const t=this.Wh.iterator;for(;t.next();)t.value.Rf=!1}Tu(){if(this.Em)return;const t=this.b;this.TM=t.skipsUndoManager,this.DM=t.me,t.skipsUndoManager=!0,t.me=!0,this.Em=!0}Du(){const t=this.b;t.skipsUndoManager=this.TM,t.me=this.DM,this.Em=!1}stopAnimation(t){const i=this.yn;if(this.Si===!0&&(this.Si=!1,this.Df=!1,this.Zn.clear(),i.kF()&&this.b.requestUpdate()),!this.Ti){i.ge.clear(),i.cx(this.b);return}if(i.Fu(!0),i.cx(null),t===!0){const e=this.Wh.toArray();for(let s=0;s{!i.isAnimating&&i.runCount===1/0&&i.start()})}get duration(){return this.Io}set duration(t){Util.t(t,"number",AnimationManager,"duration"),t<1&&Util.G(t,">= 1",AnimationManager,"duration"),this.Io=t}get isAnimating(){return this.Ti}get isTicking(){return this.Em}get isInitial(){return this.Cr}set isInitial(t){Util.t(t,"boolean",AnimationManager,"isInitial"),this.Cr=t}get defaultAnimation(){return this.yn}get activeAnimations(){return this.Wh}get initialAnimationStyle(){return this.Ff}set initialAnimationStyle(t){Debug&&Util.tt(t,AnimationStyle,"AnimationStyle"),this.Ff=t}static gx=new GMap;static defineAnimationEffect(t,i){AnimationManager.gx.set(t,i)}static BM(t,i,e,s,n){t===null&&(t=[0,0,0,0]),i===null&&(i=[0,0,0,0]);let o=t[0],r=t[1];const l=t[2],h=t[3];let a=i[0],f=i[1];const c=i[2],u=i[3];l===0||l===100?(o=a,r=f):(c===0||c===100)&&(a=o,f=r),Math.abs(a-o)>180&&(a>o?o+=360:a+=360);const d=n(e,o,a-o,s)%360,m=n(e,r,f-r,s),g=n(e,l,c-l,s),p=n(e,h,u-h,s);return"hsla("+d+", "+m+"%, "+g+"%, "+p+")"}static{const t=AnimationManager.gx,i=(e,s,n,o,r,l)=>{e.position=new Point(o(r,s.x,n.x-s.x,l),o(r,s.y,n.y-s.y,l))};t.set("position:diagram",i),t.set("position",i),t.set("position:part",(e,s,n,o,r,l)=>{r{r{r{const h=e.actualBounds,a=n.actualBounds,f=a.x+a.width/2-h.width/2,c=a.y+a.height/2-h.height/2;r{e.desiredSize=new Size(o(r,s.width,n.width-s.width,l),o(r,s.height,n.height-s.height,l))}),t.set("width",(e,s,n,o,r,l)=>{e.width=o(r,s,n-s,l)}),t.set("height",(e,s,n,o,r,l)=>{e.height=o(r,s,n-s,l)}),t.set("fill",(e,s,n,o,r,l)=>{e.fill=AnimationManager.BM(s,n,r,l,o)}),t.set("stroke",(e,s,n,o,r,l)=>{e.stroke=AnimationManager.BM(s,n,r,l,o)}),t.set("strokeWidth",(e,s,n,o,r,l)=>{e.strokeWidth=o(r,s,n-s,l)}),t.set("strokeDashOffset",(e,s,n,o,r,l)=>{e.strokeDashOffset=o(r,s,n-s,l)}),t.set("background",(e,s,n,o,r,l)=>{e.background=AnimationManager.BM(s,n,r,l,o)}),t.set("opacity",(e,s,n,o,r,l)=>{e.opacity=o(r,s,n-s,l)}),t.set("scale",(e,s,n,o,r,l)=>{e.scale=o(r,s,n-s,l)}),t.set("angle",(e,s,n,o,r,l)=>{e.angle=o(r,s,n-s,l)})}static Default=1;static AnimateLocations=2;static None=3}class Animation{mx;Xm;Ti;Ru;Io;bs;lA;Ef;ge;px;li;$n;Iu;Vf;yx;wx;Rf;zM;xx;ws;b;XM;YM;KM;constructor(t){this.b=null,this.ws=null,this.zM=null,this.xx=null,this.XM=!1,this.Ti=!1,this.Rf=!1,this.li=0,this.$n=0,this.mx=Animation.EaseInOutQuad,this.Xm=Animation.EaseInOutQuad,this.Iu=!1,this.Vf=!1,this.yx=1,this.wx=0,this.Io=NaN,this.bs=NaN,this.YM=0,this.Ru=null,this.lA=Point.Lo,this.ge=new GMap,this.px=new GMap,this.Ef=new GSet,this.KM=1,t&&Object.assign(this,t)}suspend(){this.Rf=!0}advanceTo(t,i){i&&(this.Rf=!1),this.Iu&&t>=this.bs&&(this.Vf=!0,t=t-this.bs),this.YM=t,this.sA(!0),this.ws.Tu(),this.b.Sr(),this.ws.Du(),this.b.redraw()}cx(t){if(this.px.clear(),this.Vf=!1,this.wx=0,this.bs=NaN,this.Ef.count>0&&this.Ef.clear(),t!==null){const i=t.links;for(;i.next();)i.value.Lr=null}}kF(){return this.ge.count>0}start(){if(this.ge.count===0)return this;if(this.Ti)return this;let t=this.b;const i=this.ge.iterator;for(;i.next();){const s=i.key;t===null&&(s instanceof Diagram?t=s:s instanceof GraphObject&&(t=s.diagram))}if(t!==null)this.b=t,this.ws=t.animationManager;else return this;const e=this.ws;return e.isEnabled===!1?this:(this.bs=isNaN(this.Io)?e.duration:this.Io,this.Xm=this.mx,e.Df&&e.Ff===1&&this===e.defaultAnimation&&(this.Xm=Animation.EaseOutExpo,this.bs=isNaN(this.Io)?e.duration===600?900:e.duration:this.Io),this.KM=t.scrollMode,this.isViewportUnconstrained&&(t.vh=2),e.Tu(),this.Ef.each(s=>{s.data=null,t.add(s)}),e.Du(),this.Ti=!0,this.li=+new Date,this.$n=this.li+this.bs,e.yF(this),this)}addTemporaryPart(t,i){return t.Ae()?(Debug&&(i===void 0&&Util.n("addTemporaryPart: Required Diagram argument missing"),t.diagram===i&&Util.n("addTemporaryPart: Part already in Diagram, did you mean to pass in a copy?"),this.b!==null&&this.b!==i&&Util.n("addTemporaryPart: A different Diagram is already associated with this Animation: "+this.b.toString())),this.Ef.add(t),this.b=i,this):this}add(t,i,e,s,n){if(this.b===null&&(t instanceof Diagram?this.b=t:t instanceof GraphObject&&t.diagram!==null&&(this.b=t.diagram)),t instanceof Part){if(!t.isAnimated)return this;i==="position"&&(i="position:part")}return this.EM(t,i,e,s,n),this}EM(t,i,e,s,n){const o=this.ge;let r,l,h;if(t instanceof Diagram&&i==="position"&&(i="position:diagram"),(i==="fill"||i==="stroke"||i==="background")&&(Brush.Eo(e),Brush.UM(),e=[Brush.Yi.n0,Brush.Yi.n1,Brush.Yi.n2,Brush.Yi.n3],Brush.Eo(s),Brush.UM(),s=[Brush.Yi.n0,Brush.Yi.n1,Brush.Yi.n2,Brush.Yi.n3]),o.has(t))r=o.get(t),l=r.li,h=r.xs,l[i]===void 0&&(l[i]=this.Ou(e)),h[i]=this.Ou(s);else{if(i==="position"&&e.equalsApprox(s))return;l={},h={},l[i]=this.Ou(e),h[i]=this.Ou(s),r=new AnimationState(l,h,n),o.set(t,r)}const a=l[i];a instanceof Point&&!a.isReal()&&a.c(this.lA),n&&i.indexOf("position:")===0&&t instanceof Part?r.bx.location=this.Ou(t.location):n&&(r.bx[i]=this.Ou(e))}Ou(t){return t instanceof Point||t instanceof Size?t.copy():t}SF(t){const i=this.ge;if(i.has(t)){const e=i.get(t);e.kx=!0}}ux(t){if(!this.Ti)return!1;const i=this.ge.get(t);return i!==null&&i.kx}OM(t){if(!this.Ti)return!1;const i=this.ge.get(t);return i!==null&&!!(i.li.position||i.li["position:part"]||i.li.location)}wF(){if(this.Ef.count>0)return!0;const t=this.ge.iterator;for(;t.next();){const i=t.key;if(i instanceof GraphObject&&i.diagram!==null||i instanceof Diagram)return!0}return!1}sA(t){if(this.Rf&&!t)return;const i=this.ws;if(this.Ti===!1)return;const e=+new Date;let s=e>this.$n?this.bs:e-this.li;t&&(s=this.YM,sthis.$n&&(this.Iu&&!this.Vf?(this.li=+new Date,this.$n=this.li+this.bs,this.Vf=!0):this.Fu(!1))}iA(t){const i=this.bs,e=this.ge.iterator,s=this.Vf;for(;e.next();){const n=e.key;if(n instanceof GraphObject&&n.diagram===null)continue;const o=e.value,r=s?o.xs:o.li,l=s?o.li:o.xs,h=AnimationManager.gx;for(const a in l)a==="position"&&(l["position:placeholder"]||l["position:nodeCollapse"])||h.get(a)!==null&&h.get(a)(n,r[a],l[a],this.Xm,t,i,this)}}stop(){return this.Ti?(this.Fu(!0),this):this}Fu(t){if(this.xx!==null&&this.xx.MF(this.zM),!this.Ti)return;const i=this.b,e=this.ws;e.Df=!1,this.Ti=!1,this.Rf=!1,e.Tu();const s=this.ge,n=this.Ef.iterator;for(;n.next();)i.remove(n.value);const o=this.Iu,r=s.iterator,l=AnimationManager.gx;for(;r.next();){const a=r.key,f=r.value,c=o?f.xs:f.li,u=o?f.li:f.xs,d=f.bx;for(const m in u)if(l.get(m)!==null){let g=m;f.Sx&&(g==="position:nodeCollapse"||g==="position:placeholder")&&(g="position"),l.get(g)(a,c[m],d[m]!==void 0?d[m]:f.Sx?c[m]:u[m],this.Xm,this.bs,this.bs,this)}f.Sx&&d.location!==void 0&&a instanceof Part&&(a.location=d.location),f.kx&&a instanceof Part&&a.Ki(!1)}this.wx++;const h=!t&&this.yx>this.wx;if(!h&&(this===e.Vm||this===e.defaultAnimation)&&this.ge.clear(),i.Mx.clear(),i.NS(!1),i.invalidateDocumentBounds(),i.T(),i.Sr(!0),e.defaultAnimation===this){const a=e.zm.iterator;for(;a.next();)a.value.PF();e.zm.clear()}if(i.Sr(!0),this.isViewportUnconstrained&&(i.scrollMode=this.KM),e.Du(),h){this.Vf=!1,this.start();return}this.cx(null),e.Fu(this),this.Ru&&this.Ru(this),i.requestUpdate()}If(t,i){const e=i.actualBounds;let s=null;if(i instanceof Group&&(s=i.placeholder),s!==null&&s.visible){const n=s.getDocumentPoint(Spot.TopLeft),o=s.padding;n.x+=o.left,n.y+=o.top,this.add(t,"position",n,t.position,!1)}else this.add(t,"position",new Point(e.x+e.width/2,e.y+e.height/2),t.position,!1);this.add(t,"scale",.01,t.scale,!1),t instanceof Group&&this.NF(t,i)}NF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.If(s,i)}}Of(t,i){if(!t.isVisible())return;let e=null;if(i instanceof Group&&(e=i.placeholder),e!==null&&e.visible){const s=e.getDocumentPoint(Spot.TopLeft),n=e.padding;s.x+=n.left,s.y+=n.top,this.add(t,"position:placeholder",t.position,s,!0)}else this.add(t,"position:nodeCollapse",t.position,i,!0);this.add(t,"scale",t.scale,.01,!0),this.SF(t),t instanceof Group&&this.CF(t,i)}CF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Of(s,i)}}get duration(){return this.Io}set duration(t){Util.t(t,"number",Animation,"duration"),t<1&&Util.G(t,">= 1",Animation,"duration"),this.Io=t}get reversible(){return this.Iu}set reversible(t){this.Iu=t}get runCount(){return this.yx}set runCount(t){t>0?this.yx=t:Util.n("Animation.runCount value must be a positive integer.")}get finished(){return this.Ru}set finished(t){this.Ru!==t&&(t!==null&&Util.t(t,"function",Animation,"finished"),this.Ru=t)}get easing(){return this.mx}set easing(t){this.mx=t}get isViewportUnconstrained(){return this.XM}set isViewportUnconstrained(t){this.XM=t}get isAnimating(){return this.Ti}getTemporaryState(t){let i=this.px.get(t);return i===null&&(i={},this.px.set(t,i)),i}static EaseLinear=(t,i,e,s)=>e*t/s+i;static EaseInOutQuad=(t,i,e,s)=>(t/=s/2,t<1?e/2*t*t+i:-e/2*(--t*(t-2)-1)+i);static EaseInQuad=(t,i,e,s)=>e*(t/=s)*t+i;static EaseOutQuad=(t,i,e,s)=>-e*(t/=s)*(t-2)+i;static EaseInExpo=(t,i,e,s)=>t===0?i:e*Math.pow(2,10*(t/s-1))+i;static EaseOutExpo=(t,i,e,s)=>t===s?i+e:e*(-Math.pow(2,-10*t/s)+1)+i}class AnimationState{li;xs;bx;Sx;kx;constructor(t,i,e){this.li=t,this.xs=i,this.bx={},this.Sx=e,this.kx=!1}}var TriggerStart=(w=>(w[w.Default=1]="Default",w[w.Immediate=2]="Immediate",w[w.Bundled=3]="Bundled",w))(TriggerStart||{});class AnimationTrigger{Ce;gn;Eu;Bf;constructor(t,i,e){e&&Debug&&Util.tt(e,TriggerStart,"TriggerStart"),this.Ce=null,this.gn=t,this.Eu=e||1,this.Bf=null,i!==void 0&&(this.Bf=i,e===void 0&&(this.Eu=2))}copy(){const t=new AnimationTrigger(this.gn);t.Eu=this.Eu;const i=this.Bf;if(i!==null){const e={};i.duration!==void 0&&(e.duration=i.duration),i.finished!==void 0&&(e.finished=i.finished),i.easing!==void 0&&(e.easing=i.easing),t.Bf=e}return t}get propertyName(){return this.gn}set propertyName(t){this.gn=t}get animationSettings(){return this.Bf}set animationSettings(t){this.Bf=t}AF(t){const i=this.Bf;i!==null&&(i.duration&&(t.duration=i.duration),i.finished&&(t.finished=i.finished),i.easing&&(t.easing=i.easing))}get startCondition(){return this.Eu}set startCondition(t){Debug&&Util.tt(t,TriggerStart,"TriggerStart"),this.Eu=t}static Default=1;static Immediate=2;static Bundled=3}class Layer{b;Tt;_t;Tr;Vl;Bl;zl;Xl;Yl;Kl;Ul;Gl;Hl;ql;jl;Wl;Lf;vl;Px;Ym;Vu;It;constructor(t){GSet.vi(this),this.b=null,this.It=new List,this.Tt="",this._t=1,this.Tr=!1,this.Vl=!0,this.Bl=!0,this.zl=!0,this.Xl=!0,this.Yl=!0,this.Kl=!0,this.Ul=!0,this.Gl=!0,this.Hl=!0,this.ql=!0,this.jl=!0,this.Wl=!0,this.Lf=!0,this.vl=!0,this.Px=!0,this.Ym=!1,this.Vu=[],t&&Object.assign(this,t)}LF(){const t=this.It;for(let i=0;i0&&(h+=e+" Parts "),s>0&&(h+=s+" Nodes "),n>0&&(h+=n+" Groups "),o>0&&(h+=o+" Links "),r>0&&(h+=r+" Adornments "),t>1){const a=this.It.iterator;for(;a.next();){const f=a.value;h+=` - `+f.toString();const c=f.data;c!==null&&GSet.gs(c)&&(h+=" #"+GSet.gs(c)),f instanceof Node?h+=" "+Util.toString(c):f instanceof Link&&(h+=" "+Util.toString(f.fromNode)+" "+Util.toString(f.toNode))}}return i+" "+this.It.count+": "+h}findObjectAt(t,i,e){if(i===void 0&&(i=null),e===void 0&&(e=null),this.vl===!1)return null;Debug&&!t.isReal()&&Util.n("findObjectAt: Point must have a real value, not: "+t.toString());let s=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(s=!0);const n=Point.a(),o=this.It.h,r=o.length;for(let l=r;l--;){const h=o[l];if(s===!0&&h.Tl()===!1||!h.isVisible())continue;n.c(t),n.Ye(h.Ks);let a=h.hA(n,i,e);if(a!==null&&(i!==null&&(a=i(a)),a!==null&&(e===null||e(a))))return Point.o(n),a}return Point.o(n),null}findObjectsAt(t,i,e,s){if(i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.vl===!1)return s;Debug&&!t.isReal()&&Util.n("findObjectsAt: Point must have a real value, not: "+t.toString());let n=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(n=!0);const o=Point.a(),r=this.It.h,l=r.length;for(let h=l;h--;){const a=r[h];if(n===!0&&a.Tl()===!1||!a.isVisible())continue;o.c(t),o.Ye(a.Ks);let f=a;a.aA(o,i,e,s)&&(i!==null&&(f=i(f)),f!==null&&(e===null||e(f))&&s.add(f))}return Point.o(o),s}findObjectsIn(t,i,e,s,n){if(i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.vl===!1)return n;Debug&&!t.isReal()&&Util.n("findObjectsIn: Rect must have a real value, not: "+t.toString());let o=!1;this.diagram!==null&&this.diagram.viewportBounds.containsRect(t)&&(o=!0);const r=this.It.h,l=r.length;for(let h=l;h--;){const a=r[h];if(o===!0&&a.Tl()===!1||!a.isVisible())continue;let f=a;a.Km(t,i,e,s,n)&&(i!==null&&(f=i(f)),f!==null&&(e===null||e(f))&&n.add(f))}return n}IS(t,i,e,s,n,o,r){if(this.vl===!1)return n;const l=this.It.h,h=l.length;for(let a=h;a--;){const f=l[a];if(r===!0&&f.Tl()===!1||!o(f)||!f.isVisible())continue;let c=f;f.Km(t,i,e,s,n)&&(i!==null&&(c=i(c)),c!==null&&(e===null||e(c))&&n.add(c))}return n}findObjectsNear(t,i,e,s,n,o){if(e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.vl===!1)return o;Debug&&!t.isReal()&&Util.n("findObjectsNear: Point must have a real value, not: "+t.toString());let r=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(r=!0);const l=Point.a(),h=Point.a(),a=this.It.h,f=a.length;for(let c=f;c--;){const u=a[c];if(r===!0&&u.Tl()===!1||!u.isVisible())continue;l.c(t),l.Ye(u.Ks),h.e(t.x+i,t.y),h.Ye(u.Ks);let d=u;u.fA(l,h,e,s,n,o)&&(e!==null&&(d=e(d)),d!==null&&(s===null||s(d))&&o.add(d))}return Point.o(l),Point.o(h),o}HM(){return this.It.h}Us(t,i){if(!this.visible)return;const e=this.It.h,s=e.length;if(s===0)return;const n=Util.ft(),o=Util.ft();for(let r=0;r0&&o.push(l))}for(let r=0;re.Gm||a.height*n>e.Gm?i.Ji(t,e):this.RF(t,i),f&&(t.restore(),t.clearContextCache(!0))}RF(t,i){const e=i.actualBounds,s=i.naturalBounds;if(e.width===0||e.height===0||isNaN(e.x)||isNaN(e.y)||!i.isVisible())return;const n=i.O;if(i.background===null){i.wn(t,"rgba(0,0,0,0.3)",!0,!1,s,e),t.fillRect(e.x,e.y,e.width,e.height);return}if(t.transform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),i.wn(t,i.background,!0,!1,s,e),t.fillRect(0,0,s.width/2,s.height/2),!n.Gk()){const o=1/(n.m11*n.m22-n.m12*n.m21);t.transform(n.m22*o,-n.m12*o,-n.m21*o,n.m11*o,o*(n.m21*n.dy-n.m22*n.dx),o*(n.m12*n.dx-n.m11*n.dy))}}FF(t,i,e,s){const n=2/s,o=4/s;for(let r=0;r=s.count)t=s.count;else if(s.elt(t)===i)return-1;s.insertAt(t,i),i.Hm(e);const n=this.diagram;return n!==null&&(e?n.T():n.Zh(i)),this.Nx(t,i),t}ne(t,i,e){if(!e&&i.layer!==this&&i.layer!==null)return i.layer.ne(t,i,e);const s=this.It;if(t<0||t>=s.length){if(t=s.indexOf(i),t<0)return-1}else if(s.elt(t)!==i&&(t=s.indexOf(i),t<0))return-1;i.qm(e),s.removeAt(t);const n=this.diagram;return n!==null&&(e?n.T():n.ne(i)),i.GM(null),t}Nx(t,i){t=this.IF(t,i),i instanceof Group&&this.OF(t,i),i.svg!==null&&i.svg.remove()}IF(t,i){const e=i.zOrder;if(isNaN(e))return t;const s=this.It,n=s.count;if(n<=1)return t;if(t<0&&(t=s.indexOf(i)),t<0)return-1;let o=t-1,r=NaN;for(;o>=0&&(r=s.elt(o).zOrder,!!isNaN(r));)o--;let l=t+1,h=NaN;for(;le)for(;;){if(o===-1||r<=e)return o++,o===t?t:(s.removeAt(t),s.insertAt(o,i),o);for(r=NaN;--o>=0&&(r=s.elt(o).zOrder,!!isNaN(r)););}else if(!isNaN(h)&&h=e)return l--,l===t?t:(s.removeAt(t),s.insertAt(l,i),l);for(h=NaN;++l=0)||e<0&&r.containingGroup===i&&(e=o,t>=0))break}if(!(e<0)&&e1)&&Util.G(t,"0 <= value <= 1",Layer,"opacity"),this._t=t;const e=this.diagram;e!==null&&e.T(),this.i("opacity",i,t)}}get isViewportAligned(){return this.Ym}set isViewportAligned(t){const i=this.Ym;i!==t&&(this.Ym=t,this.diagram&&(this.uA(),this.diagram.T()),this.i("isViewportAligned",i,t),t&&(this.isInDocumentBounds=!1))}uA(){if(!this.Ym)return;const t=this.diagram,i=this.It.h,e=i.length,s=t.Ct,n=t.At;for(let o=0;o(w[w.None=1]="None",w[w.Uniform=2]="Uniform",w[w.UniformToFill=3]="UniformToFill",w))(AutoScale||{}),CycleMode=(w=>(w[w.All=1]="All",w[w.NotDirected=2]="NotDirected",w[w.NotDirectedFast=3]="NotDirectedFast",w[w.NotUndirected=4]="NotUndirected",w[w.DestinationTree=5]="DestinationTree",w[w.SourceTree=6]="SourceTree",w))(CycleMode||{}),ScrollMode=(w=>(w[w.Document=1]="Document",w[w.Infinite=2]="Infinite",w))(ScrollMode||{}),CollapsePolicy=(w=>(w[w.TreeParent=1]="TreeParent",w[w.AllParents=2]="AllParents",w[w.AnyParents=3]="AnyParents",w))(CollapsePolicy||{});class Diagram{ws;yi;WM;Cx;Dr;Xu;Ax;Lx;Tx;Dx;Fx;Rx;zf;vh;Ix;Ox;Ex;Jl;Xf;Fr;jm;Vx;Bx;Yu;Qn;Rr;$h;Vo;Wm;Yf;vm;Kf;Ku;Ir;_n;vM;JM;zx;Xx;ZM;Yx;$M;QM;_M;Kx;Jm;Or;Er;Vr;Br;zr;Xr;Ux;Yr;Gx;Kr;Ur;Gr;Hr;Hx;tP;Bo;iP;qx;jx;eP;Ai;sP;nP;oP;zs;zo;Xi;Wx;Vl;Bl;vx;Jx;zl;Xl;Yl;Zx;Kl;Ul;Gl;Hl;ql;jl;Wl;$x;Qx;rP;Uu;Gu;_x;t1;i1;e1;Zm;s1;o1;l1;ii;lP;h1;hP;Hu;xn;to;oe;io;dA;Zl;aP;fP;$m;a1;qu;Qm;f1;qr;$l;Qh;cP;uP;_m;c1;u1;os;t0;i0;ju;Ql;Uf;e0;jr;_h;dP;s0;$t;O;Ge;Ar;Ui;ks;gP;_l;Wr;Pl;vr;ta;Gf;mP;Wu;ia;vu;Jt;th;mt;lt;Ju;Ct;At;xt;Hf;qw;d1;ea;qf;g1;m1;p1;BF;zF;Gi;Cl;Gm;o0;pP;yP;gA;r0;XF;YF;KF;w1;UF;GF;HF;sa;mA;ih;na;oa;ra;la;Nu;jh;ei;Ot;jf;eS;sS;wf;_t;static b1=null;static pA=new GMap;static wP;static xP=null;Pu;k1;S1;M1;P1;N1;l0;bP;h0;a0;f0;fx;kP;C1;Wf;constructor(t,i){if(Diagram.ww||(Diagram.Hk(),Diagram.ww=!0),GSet.vi(this),Diagram.yA(this),this.$t=!0,this.Ot=null,this.Ct=0,this.At=0,this.xt=null,Diagram.isUsingDOM()){const s=this,n=()=>{s.Li(root.document,"DOMContentLoaded",n,!1),s.setRTL()};root.document.body!==null?this.setRTL():s.Ht(root.document,"DOMContentLoaded",n,!1)}this.Hf=null,Diagram.SP("Model",PartManager);const e=this;return this.sP=s=>e.partManager.doModelDataChanged(s),this.nP=s=>e.partManager.doModelChanged(s),this.g1=null,this.m1=null,this.wA(),this.model=Model.initDiagramModel(),this.C1=null,this.themeManager=new ThemeManager,this.Bo=!0,this.xA(),this.layout=new Layout,this.Bo=!1,this.XF=null,this.YF=null,this.KF=null,this.w1=null,this.UF=null,this.GF=null,this.HF=null,this.sa=null,this.mA=null,this.ih=null,this.na=null,this.oa=null,this.ra=null,this.la=null,this.Nu=()=>{},this.jh=null,this.ju=!1,this.jf=new DiagramHelper(this),t!==void 0&&(typeof t=="string"||root.Element&&t instanceof Element?this.MP(t):i=t),i&&this.setProperties(i),this.$t=!1,this.requestUpdate(),this}iF(){return this.xt!==null}get renderer(){return this.Uf}set renderer(t){if(this instanceof Overview)return;t===""&&(t="default");const i=t.toLowerCase(),e=this.Uf;if(i===e)return;this.Uf=i;let s=null;i==="default"||i==="canvas"?(s=this.Ql.get("svg"),s!==null&&s.Bt.remove(),this.xt&&(this.ei=this.xt.di),this.ei.clearContextCache(!0)):i==="svg"?(this.Ql.has("svg")?s=this.Ql.get("svg"):(s=new SVGSurface(this,root.document),this.addRenderer("svg",s)),this.div!==null&&this.div.appendChild(s.Bt),this.ei=s.di,this.xt&&(this.xt.di.setTransform(this.Gi,0,0,this.Gi,0,0),this.xt.di.clearRect(0,0,this.Ct,this.At))):i==="debug"&&(this.Ql.has("SVG")||(s=new SVGSurface(this,root.document),this.addRenderer("SVG",s),s.Bt.style.backgroundColor="whitesmoke",this.div!==null&&this.div.after(s.Bt))),this.$t||this.redraw()}wA(){this.Wf=new List,this.setupRouters(),this.ws=new AnimationManager,this.ws.Oo(this),this.yi=17,this.WM=!1,this.Ju=!1,this.Cx="default",this.Jt=new List,this.Ql=new GMap,this.Uf="default",this.resetRenderingHints(),this.qF(),this._t=1,this.mt=new Point(NaN,NaN).w(),this.fx=new Point(NaN,NaN),this.lt=1,this.s0=1,this.Ax=new Point(NaN,NaN).w(),this.Lx=NaN,this.Tx=1e-4,this.Dx=100,this.O=new Transform,this.Fx=new Point(NaN,NaN).w(),this.Rx=new Rect(NaN,NaN,NaN,NaN).w(),this.zf=new Margin(0,0,0,0).w(),this.vh=1,this.Ix=!1,this.Ox=null,this.Ex=null,this.Jl=1,this.Xf=Spot.Default,this.Fr=1,this.jm=Spot.Default,this.Vx=Spot.None,this.Bx=Spot.None,this.Ge=!0,this.Yu=!1,this.Qn=new Set,this.Rr=new GSet,this.$h=new GSet,this.Vo=!1,this.th=new GMap,this.Wu=!0,this.Wm=250,this.Yf=-1,this.vm=new Margin(16,16,16,16).w(),this.Ar=!1,this.Kf=!1,this.Ku=!0,this.e0=new InputEvent,this.e0.diagram=this,this.jr=new InputEvent,this.jr.diagram=this,this._h=new InputEvent,this._h.diagram=this,this.Ir=null,this._n=null,this.qw=!1,this.jF(),this.vr=new GSet,this.zx=!0,this.Xx=1,this.ZM=!1,this.Yx=1,this.Kx="auto",this.Jm="auto",this.Or=null,this.Er=null,this.Vr=null,this.Br=null,this.zr=null,this.Xr=null,this.Ux=null,this.Yr=null,this.Gx=!1,this.Kr=null,this.Ur=null,this.Gr=null,this.Hr=null,this.Hx=!1,this.d1={},this.ea=[null,null],this.Bo=!1,this.iP=!1,this.qx=!1,this.jx=!1,this.eP=!0,this.ks=!1,this.ia=!1,this.oP=!0,this.zs=-2,this._l=new GMap,this.vu=new List,this.zo=!1,this.Xi=!0,this.Wx=!0,this.Vl=!0,this.Bl=!0,this.vx=!1,this.Jx=!0,this.zl=!0,this.Xl=!0,this.Yl=!0,this.Zx=!0,this.Kl=!0,this.Ul=!0,this.Gl=!0,this.Hl=!0,this.ql=!0,this.jl=!0,this.Wl=!0,this.$x=!0,this.Qx=!0,this.rP=!1,this.qf=!1,this.Uu=!0,this.Gu=!0,this._x=!0,this.t1=!0,this.i1=16,this.e1=16,this.Zm=!1,this.s1=!1,this.o1=0,this.l1=0,this.ii=new Margin(5).w(),this.lP=new GSet().w(),this.h1=999999999,this.hP=new GSet().w(),this.ta=!0,this.Hu=!0,this.Gf=!0,this.xn=!1,this.to=!1,this.Wr=!0,this.Pl=!1,this.io=!1,this.dA=new GSet,this.mP=new GSet,this.Zl=null,this.aP=new Size(8,8),this.fP=999,this.$m=!1,this.eS=1,this.sS=0,this.Ui={scale:1,position:new Point,bounds:new Rect,canvasSize:new Size,newCanvasSize:new Size,isScroll:!1},this.Ui.canvasSize=this.Ui.canvasSize,this.Ui.newCanvasSize=this.Ui.newCanvasSize,this.Ui.isScroll=!1,this.a1=new Rect(NaN,NaN,NaN,NaN).w(),this.qu=new Size(NaN,NaN).w(),this.Qm=new Rect(NaN,NaN,NaN,NaN).w(),this.f1=!1,this.WF(),this.os=null,this.t0=!1,this.wf=null,this.partManager=new PartManager,this.toolManager=new ToolManager,this.toolManager.initializeStandardTools(),this.defaultTool=this.toolManager,this.currentTool=this.defaultTool,this.S1=null,this.M1=new DraggingOptions,this.P1=null,this.N1=null,this.k1=!1,this.Pu=!1,this.commandHandler=new CommandHandler,this.a0=null,this.f0=Point.Vk,this.kP=!1,this.Gi=1,this.Cl=null,this.Gm=1,this.l0=0,this.bP=[0,0,0,0,0],this.h0=0,this.o0=1,this.pP=0,this.yP=new Point,this.gA=500,this.i0=new Point,this.r0=!1}static bA=root.document!==void 0;static isUsingDOM(){return Diagram.bA}static useDOM(t){Diagram.bA=t?root.document!==void 0:!1}static He=new WeakMap;clear(){this.animationManager.stopAnimation(),this.model.clear(),Diagram.kA(),this.SA(!1),this.vu.clear(),this.MA(),this.Zl=null,this.invalidateDocumentBounds(),this.ensureBounds(),this.T()}SA(t){this.animationManager.stopAnimation(!0),this.lP=new GSet().w(),this.hP=new GSet().w();const i=this.skipsUndoManager,e=this.Ai!==null&&this.Ai!==void 0;e&&(this.skipsUndoManager=!0);let s=null;this.os!==null&&(s=this.os.part,s!==null&&this.remove(s));const n=[],o=this.Jt.length;if(t){for(let r=0;rt?new Margin(t/2):1.5)),this.c1=this._m,this.u1=new Adornment(Panel.Link).add(new Shape({isPanelMain:!0,fill:null,stroke:"dodgerblue",strokeWidth:3}).theme("stroke","selection").theme("strokeWidth","selection"))}setRTL(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);const e=Util.ln("div");e.dir="rtl",e.style.cssText="font-size: 14px; width: 1px; height: 1px; position: absolute; top: -1000px; overflow: scroll;",e.textContent="A",i.appendChild(e);let s="reverse";e.scrollLeft>0?s="default":(e.scrollLeft=1,e.scrollLeft===0&&(s="negative")),i.removeChild(e),this.Cx=s}setScrollWidth(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);let e=0;if(Diagram.isUsingDOM()){let s=Diagram.xP,n=Diagram.wP;s===null&&(Diagram.xP=Util.ln("p"),s=Diagram.xP,s.style.width="100%",s.style.height="200px",s.style.boxSizing="content-box",Diagram.wP=Util.ln("div"),n=Diagram.wP,n.style.position="absolute",n.style.visibility="hidden",n.style.width="200px",n.style.height="150px",n.style.boxSizing="content-box",n.appendChild(s)),n.style.overflow="hidden",i.appendChild(n);const o=s.offsetWidth;n.style.overflow="scroll";let r=s.offsetWidth;o===r&&(r=n.clientWidth),i.removeChild(n),e=o-r,e===0&&!Util.cr&&(e=11)}this.yi=e,this.WM=!0}fi(t){t in AutoScale?this.autoScale=t:Util.ur(this,t)}toString(t){t===void 0&&(t=0);let i="";this.div&&this.div.id&&(i=this.div.id);let e='Diagram "'+i+'"';if(t<=0)return e;const s=this.Jt.iterator;for(;s.next();){const n=s.value;e+=` - `+n.toString(t-1)}return e}static yA(t){Diagram.b1=t}static Mm(){return Diagram.b1}static fromDiv(t){let i=t;if(typeof t=="string"&&(i=root.document.getElementById(t)),i instanceof HTMLDivElement){const e=Diagram.He.get(i);if(e)return e}return null}get div(){return this.Ot}set div(t){if(t!==null&&Util.s(t,HTMLDivElement,Diagram,"div"),this.Ot!==t){const i=this.Ot;if(i!==null){if(Diagram.He.delete(i),i.goDiagram=void 0,i.go=void 0,i.innerHTML="",this.xt!==null){const s=this.xt.Bt;this.Li(s,"pointermove",this.na,!1),this.Li(s,"pointerdown",this.ih,!1),this.Li(s,"pointerup",this.oa,!1),this.Li(s,"pointerout",this.ra,!1),this.Li(s,"pointercancel",this.la,!1),this.xt.dispose()}this.Hf&&(this.Hf.disconnect(),this.Hf=null);const e=this.toolManager;e!==null&&(e.mouseDownTools.each(s=>s.cancelWaitAfter()),e.mouseMoveTools.each(s=>s.cancelWaitAfter()),e.mouseUpTools.each(s=>s.cancelWaitAfter())),e.cancelWaitAfter(),this.currentTool.doCancel(),this.xt=null,this.Li(root,"resize",this.w1,!1),this.Li(root,"wheel",this.sa,!0),Diagram.Mm()===this&&Diagram.yA(null)}else this.ih===null&&(this.io=!1);if(this.Ot=null,t!==null){const e=Diagram.He.get(t);e&&(e.div=null),this.MP(t),this.Nu(),this.themeManager&&this.themeManager.vF()}else this.themeManager&&this.themeManager.JF()}}setupRouters(){this.Wf.push(new AvoidsNodesRouter)}MP(t){const i=this;if(!Diagram.isUsingDOM())return;t==null&&Util.n("Diagram setup requires an argument DIV."),i.Ot!==null&&Util.n("Diagram has already completed setup."),typeof t=="string"?i.Ot=root.document.getElementById(t):t instanceof HTMLDivElement?i.Ot=t:Util.n("No DIV or DIV id supplied: "+t),i.Ot===null&&Util.n("Invalid DIV id; could not get element with id: "+t);const e=Diagram.He.get(i.Ot);if(e&&e!==this&&Util.n("Invalid div id; div already has a Diagram associated with it."),!i.Hf&&root.ResizeObserver){const f=root.ResizeObserver,c=Util.Ik(()=>i.requestUpdate(),250,!1);i.Hf=new f(()=>c()),i.Hf.observe(i.Ot)}root.getComputedStyle(i.Ot,null).position==="static"&&(i.Ot.style.position="relative");let s=5;const n="rgba(2"+s+"5, 255, 255, 0)";s--,i.Ot.style["-webkit-tap-highlight-color"]=n,i.Ot.innerHTML="",Diagram.He.set(i.Ot,i),i.Ot.goDiagram=i,i.Ot.go=root.go;const o=new CanvasSurface(i);o.style!==void 0&&(o.style.position="absolute",o.style.top="0px",o.style.left="0px",root.getComputedStyle(i.Ot,null).getPropertyValue("direction")==="rtl"&&(i.Ju=!0),o.style.zIndex="2",o.style.userSelect="none",o.style.MozUserSelect="none",o.style.touchAction="none",o.style.letterSpacing="normal !important",o.style.wordSpacing="normal !important",o.style.lang="unknown"),i.xt=o,i.ei=o.di;const r=i.ei;i.Gi=i.computePixelRatio(),i.viewSize.isReal()||(i.Ct=i.Ot.clientWidth||1,i.At=i.Ot.clientHeight||1),i.PA(i.Ct,i.At);const l=i;i.Ot.insertBefore(o.Bt,i.Ot.firstChild);const h=new CanvasSurface(null);if(h.width=1,h.height=1,i.BF=h,i.zF=h.di,Diagram.isUsingDOM()){const f=Util.ln("div"),c=Util.ln("div");f.style.position="absolute",f.style.overflow="auto",f.style.width=i.Ct+"px",f.style.height=i.At+"px",f.style.zIndex="1",c.style.position="absolute",c.style.width="1px",c.style.height="1px",i.Ot.appendChild(f),f.appendChild(c),f.onscroll=Diagram.ZF,f.addEventListener("pointerdown",Diagram.$F),f.b=i,f.QF=!0,f._F=!0,i.g1=f,i.m1=c}i.Nu=Util.Ik(()=>{i.Cl=null,i.T()},300,!1),i.w1=Util.Ik(()=>{i.RM()},250,!1),i.jh=f=>(f.preventDefault(),!1),i.sa=f=>{if(!l.isEnabled)return;const c=l.vf(f,!0);c.bubbles=!0;let u=0,d=0;c.delta=0,f.deltaX!==void 0?(f.deltaX!==0&&(u=f.deltaX>0?1:-1),f.deltaY!==0&&(d=f.deltaY>0?1:-1),c.delta=Math.abs(f.deltaX)>Math.abs(f.deltaY)?-u:-d):f.wheelDeltaX!==void 0?(f.wheelDeltaX!==0&&(u=f.wheelDeltaX>0?-1:1),f.wheelDeltaY!==0&&(d=f.wheelDeltaY>0?-1:1),c.delta=Math.abs(f.wheelDeltaX)>Math.abs(f.wheelDeltaY)?-u:-d):f.wheelDelta!==void 0&&f.wheelDelta!==0&&(c.delta=f.wheelDelta>0?1:-1),l.doMouseWheel(),l.ha(c,f)},i.mA=f=>{if(!l.isEnabled)return;i.qf=!1,l.vf(f,!0);const c=l.currentTool;c.cancelWaitAfter(),c.standardMouseOver()},i.ih=f=>{if(!l.isEnabled)return;i.qf=!0;const c=l.d1;c[f.pointerId]===void 0&&(c[f.pointerId]=f);const u=l.ea;let d=!1;if(u[0]!==null&&(u[0].pointerId===f.pointerId||u[0].pointerType!==f.pointerType))u[0]=f;else if(u[1]!==null&&u[1].pointerId===f.pointerId)u[1]=f,d=!0;else if(u[0]===null)u[0]=f;else if(u[1]===null)u[1]=f,d=!0;else{f.preventDefault();return}const m=f.pointerType==="touch"||f.pointerType==="pen";m&&(l.qw=!1,l.r0=!0);const g=l.tR(f,f,d),p=l.yP,y=m?25:10;if(f.timeStamp-l.pPy||Math.abs(p.y-f.screenY)>y)?l.o0++:l.o0=1,g.clickCount=l.o0,l.pP=f.timeStamp,l.yP.setTo(f.screenX,f.screenY),l.doMouseDown(),f.button===1){f.preventDefault();return}l.ha(g,f)},i.na=f=>{if(!l.isEnabled)return;i.qf=!0;const c=l.ea;if(c[0]!==null&&(c[0].pointerId===f.pointerId||c[0].pointerType!==f.pointerType))c[0]=f;else if(c[1]!==null&&c[1].pointerId===f.pointerId){c[1]=f;return}else if(c[0]===null)c[0]=f;else return;if(c[0].pointerId!==f.pointerId)return;const u=l.iR(f,f,c[1]!==null);l.doMouseMove(),l.ha(u,f)},i.oa=f=>{if(!l.isEnabled)return;i.qf=!0;const c=f.pointerType==="touch"||f.pointerType==="pen",u=l.d1;if(c&&l.qw){delete u[f.pointerId],f.preventDefault();return}const d=l.ea;if(d[0]!==null&&(d[0].pointerId===f.pointerId||d[0].pointerType!==f.pointerType))d[0]=null;else if(d[1]!==null&&d[1].pointerId===f.pointerId){d[1]=null;return}else return;const m=l.PP(f,!1,!0,!1,!0,!1);let g=root.document.elementFromPoint(f.clientX,f.clientY)||null;g!==null&&g.shadowRoot!==void 0&&g.shadowRoot!==null&&(g=g.shadowRoot.elementFromPoint(f.clientX,f.clientY)),g!==null&&g.b instanceof Diagram&&g.b!==l&&g.b.u0(f,m),g===null&&(g=f.target),l.u0(f,m),m.clickCount=l.o0,m.targetDiagram=l.NP(f,g),m.targetObject=null,l.doMouseUp(),l.ha(m,f),c&&(l.r0=!1)},i.ra=f=>{if(!l.isEnabled)return;i.qf=!1;const c=l.d1;c[f.pointerId]&&delete c[f.pointerId];const u=l.ea;if(u[0]!==null&&u[0].pointerId===f.pointerId&&(u[0]=null),u[1]!==null&&u[1].pointerId===f.pointerId&&(u[1]=null),f.pointerType==="touch"||f.pointerType==="pen")return;const d=l.currentTool;d.cancelWaitAfter(),d.standardMouseOver()},i.la=f=>{const c=l.ea;c[0]!==null&&c[0].pointerId===f.pointerId?(c[0]=null,l.r0=!1):c[1]!==null&&c[1].pointerId===f.pointerId&&(c[1]=null)};const a=r;if(i.p1=a.Y[Util.Fs("7eba17a4ca3b1a8346")][Util.Fs("78a118b7")](a.Y,Diagram.Zu,s,s),r.clearContextCache(!0),i.eR(),this.Uf==="svg"){const f=this.Ql.get("svg");this.Ot.appendChild(f.Bt),this.ei=f.di}}addEventListener(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}Ht(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}removeEventListener(t,i,e,s){t.removeEventListener(i,e,{capture:s})}Li(t,i,e,s){t.removeEventListener(i,e,{capture:s})}eR(){const t=this;let i=this.xt.Bt;i instanceof HTMLCanvasElement||(i=t.div),this.Ht(i,"pointerdown",t.ih,!1),this.Ht(i,"pointermove",t.na,!1),this.Ht(i,"pointerup",t.oa,!1),this.Ht(i,"pointerout",t.ra,!1),this.Ht(i,"pointercancel",t.la,!1),this.Ht(i,"pointerenter",t.sR,!1),this.Ht(i,"pointerleave",t.nR,!1),this.Ht(i,"wheel",t.sa,!1),this.Ht(i,"keydown",t.oR,!1),this.Ht(i,"keyup",t.rR,!1),this.Ht(i,"blur",t.lR,!1),this.Ht(i,"focus",t.hR,!1),this.Ht(i,"selectstart",e=>(e.preventDefault(),!1),!1),this.Ht(i,"contextmenu",e=>(e.preventDefault(),!1),!1),this.Ht(root,"resize",t.w1,!1)}jw(){this.l0>30&&(this.Cl=1)}NS(t){this.Cl!==null&&(this.Cl=null,t&&this.Nu(),Debug&&Debug.drawFrames||(this.l0=0,this.bP=[0,0,0,0,0],this.h0=0))}computePixelRatio(){return this.Cl!==null?this.Cl:root.devicePixelRatio||1}get avgSpf(){return this.l0}doMouseDown(){this.currentTool.doMouseDown()}doMouseMove(){this.currentTool.doMouseMove()}doMouseUp(){this.currentTool.doMouseUp()}doMouseWheel(){this.currentTool.doMouseWheel()}doKeyDown(){this.currentTool.doKeyDown()}doKeyUp(){this.currentTool.doKeyUp()}doFocus(){this.focus()}focus(){if(this.xt)if(this.scrollsPageOnFocus)this.xt.focus();else{const t=root.scrollX,i=root.scrollY;this.xt.focus(),root.scrollTo(t,i)}}hR(t){const i=Diagram.He.get(this);i&&i.V("GainedFocus")}lR(t){const i=Diagram.He.get(this);i&&i.V("LostFocus")}RM(){if(this.xt===null)return;const i=this.Ot;if(i===null||i.clientWidth===0||i.clientHeight===0)return;this.WM||this.setScrollWidth();const e=this.to?this.yi:0,s=this.xn?this.yi:0,n=this.Gi;if(this.Gi=this.computePixelRatio(),this.Gi!==n&&(this.Yu=!0,this.requestUpdate()),i.clientWidth!==this.Ct+e||i.clientHeight!==this.At+s){this.aa(),this.Ge=!0;const o=this.layout;o!==null&&o.isViewportSized&&this.autoScale===1&&(this.Kf=!0,o.invalidateLayout()),this.ks||this.requestUpdate()}}xA(){let t=0,i=new Layer;i.name="Grid",i.allowSelect=!1,i.pickable=!1,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="ViewportBackground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="Background",this.Jr(i,t++),i=new Layer,i.name="",this.Jr(i,t++),i=new Layer,i.name="Foreground",this.Jr(i,t++),i=new Layer,i.name="ViewportForeground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="Adornment",i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="Tool",i.isTemporary=!0,i.isInDocumentBounds=!0,this.Jr(i,t++)}NA(){const t=new Panel(Panel.Grid,{name:"GRID"}).add(new Shape("LineH",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineV",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineH",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineH",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor")),i=new Part({layerName:"Grid",zOrder:0,isInDocumentBounds:!1,isAnimated:!1,pickable:!1,locationObjectName:"GRID"}).add(t);return this.add(i),this.partManager.parts.delete(i),t.visible=!1,t}static ZF(){const t=Diagram.He.get(this.parentElement||this);if(t){if(t.s1){t.s1=!1;return}if(!t.isEnabled){t.CA();return}t.diagramScroll(this)}}static $F(t){if(!this.b.isEnabled){this.b.updateScroll();return}this.b.o1=t.target.scrollTop,this.b.l1=t.target.scrollLeft}diagramScroll(t){if(this.xt===null)return;const i=this.g1,e=this.m1;this.Zm=!0;let s=this.documentBounds,n=this.viewportBounds;const o=this.zf;let r=s.x-o.left,l=s.y-o.top;const h=s.width+o.left+o.right,a=s.height+o.top+o.bottom;let f=s.right+o.right,c=s.bottom+o.bottom,u=n.x,d=n.y;const m=n.width,g=n.height;let p=n.right,y=n.bottom;const x=this.scale;let k,b=t.scrollLeft;if(this.Ju)switch(this.Cx){case"negative":b=b+t.scrollWidth-t.clientWidth;break;case"reverse":b=t.scrollWidth-b-t.clientWidth;break}const S=b;if(mp)){const M=i.scrollWidth-this.Ct;this.position=k.e(-M+S-this.Ct/x+f,this.position.y)}if(t._F&&this.allowVerticalScroll&&(ly)){const M=i.scrollHeight-this.At;this.position=k.e(this.position.x,-M+t.scrollTop-this.At/x+c)}Point.o(k),this.sh(),this.Zm=!1,this.Hu=!1,s=this.documentBounds,n=this.viewportBounds,f=s.right,p=n.right,c=s.bottom,y=n.bottom,r=s.x,u=n.x,l=s.y,d=n.y,m>=h&&r>=u&&f<=p&&(e.style.width="1px"),g>=a&&l>=d&&c<=y&&(e.style.height="1px")}computeBounds(t){return t===void 0&&(t=new Rect),this.Di(),this.AA(t)}AA(t){if(this.fixedBounds.isReal())return t.c(this.fixedBounds),t.addMargin(this.ii),t;let i=!0;const e=this.Jt.h,s=e.length;for(let n=0;ni&&(a=i),athis.maxScale&&(a=this.maxScale),a):t===3?(a=0,h>l?a=(r-this.yi)/n:a=(o-this.yi)/s,a>i&&(a=i),athis.maxScale&&(a=this.maxScale),a):this.scale}zoomToFit(){const t=this.vh;this.vh=1,this.scale=this.$u(2),t!==1&&(this.Gs(!1),this.CP(this.documentBounds,this.Ct/this.lt,this.At/this.lt,this.Xf,!1)),this.vh=t}zoomToRect(t,i){i===void 0&&(i=2);const e=t.width,s=t.height;if(e===0||s===0||isNaN(e)&&isNaN(s))return;let n=1;if(i===2||i===3)if(isNaN(e))n=this.viewportBounds.height*this.scale/s;else if(isNaN(s))n=this.viewportBounds.width*this.scale/e;else{const o=this.Ct,r=this.At;i===3?r/s>o/e?n=(r-(this.xn?this.yi:0))/s:n=(o-(this.to?this.yi:0))/e:n=Math.min(r/s,o/e)}this.scale=n,this.position=new Point(t.x,t.y)}get aR(){return this.$t}set aR(t){this.$t=t}alignDocument(t,i){this.ensureBounds();const e=this.documentBounds,s=this.viewportBounds;this.position=new Point(e.x+(t.x*e.width+t.offsetX)-(i.x*s.width-i.offsetX),e.y+(t.y*e.height+t.offsetY)-(i.y*s.height-i.offsetY))}focusObject(t){if(t instanceof GraphObject){this.a0=t;const i=Point.a();this.f0=this.transformDocToView(t.getDocumentPoint(Spot.TopLeft,i)),Point.o(i)}else this.a0=null,this.f0=Point.Vk}CP(t,i,e,s,n){const o=Point.H(this.mt.x,this.mt.y);let r=o.x,l=o.y;if(this.a0!==null){let h=Point.a();h=this.a0.getDocumentPoint(Spot.TopLeft,h),r=h.x-this.f0.x/this.scale,l=h.y-this.f0.y/this.scale,s=Spot.None,Point.o(h)}if(n||this.scrollMode===1){s.isSpot()&&(i>t.width&&(r=t.x+(s.x*t.width+s.offsetX)-(s.x*i-s.offsetX)),e>t.height&&(l=t.y+(s.y*t.height+s.offsetY)-(s.y*e-s.offsetY)));const h=this.zf,a=i-t.width;if(it.left?r=t.left:rt.top?l=t.top:ls.part,s=>s.canSelect());if(e instanceof Part)return e}else{const e=this.DS(t,s=>s.part);if(e instanceof Part)return e}return null}findObjectAt(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Di();const s=this.Jt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}DS(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Di();const s=this.Jt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible||n.isTemporary)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}findPartsAt(t,i,e){return i===void 0&&(i=!0),this.cR(t,s=>s.part,i?s=>s instanceof Part&&s.canSelect():null,e)}cR(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Di();const n=this.Jt.iteratorBackwards;for(;n.next();){const o=n.value;!o.visible||o.isTemporary||o.findObjectsAt(t,i,e,s)}return s}findObjectsAt(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Di();const n=this.Jt.iteratorBackwards;for(;n.next();){const o=n.value;o.visible&&o.findObjectsAt(t,i,e,s)}return s}findPartsIn(t,i,e,s){return i===void 0&&(i=!1),e===void 0&&(e=!0),this.uR(t,null,n=>n instanceof Part&&(!e||n.canSelect()),i,s)}findObjectsIn(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Di();const o=this.Jt.iteratorBackwards;for(;o.next();){const r=o.value;r.visible&&r.findObjectsIn(t,i,e,s,n)}return n}IS(t,i,e,s,n,o){const r=new GSet;this.Di();const l=this.Jt.iteratorBackwards;for(;l.next();){const h=l.value;h.visible&&h.IS(t,i,e,s,r,n,o)}return r}uR(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Di();const o=this.Jt.iteratorBackwards;for(;o.next();){const r=o.value;!r.visible||r.isTemporary||r.findObjectsIn(t,i,e,s,n)}return n}findPartsNear(t,i,e,s,n){return e===void 0&&(e=!0),s===void 0&&(s=!0),this.dR(t,i,null,o=>o instanceof Part&&(!s||o.canSelect()),e,n)}findObjectsNear(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Di();const r=this.Jt.iteratorBackwards;for(;r.next();){const l=r.value;l.visible&&l.findObjectsNear(t,i,e,s,n,o)}return o}dR(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Di();const r=this.Jt.iteratorBackwards;for(;r.next();){const l=r.value;!l.visible||l.isTemporary||l.findObjectsNear(t,i,e,s,n,o)}return o}acceptEvent(t){return this.vf(t,t instanceof MouseEvent)}vf(t,i){const e=this.jr;this.jr=this._h,this._h=e,e.diagram=this,e.event=t,i?this.u0(t,e):(e.viewPoint=this.jr.viewPoint,e.documentPoint=this.jr.documentPoint);let s=0;const n=t;return n.ctrlKey&&(s+=1),n.altKey&&(s+=2),n.shiftKey&&(s+=4),n.metaKey&&(s+=8),e.modifiers=s,e.button=n.button,n.buttons!==void 0&&(e.buttons=n.buttons),Util.cr&&n.button===0&&n.ctrlKey&&(e.button=2),e.down=!1,e.up=!1,e.clickCount=1,e.delta=0,e.handled=!1,e.bubbles=!1,e.timestamp=t.timeStamp,e.isMultiTouch=!1,e.targetDiagram=this.NP(t,t.target),e.targetObject=null,e}NP(t,i){if(i===null)return null;const e=Diagram.He.get(i);if(e)return e;let s=t.path;if(!s&&typeof t.composedPath=="function"&&(s=t.composedPath()),s&&s[0]){const n=Diagram.He.get(s[0]);if(n)return n}return null}tR(t,i,e){const s=this.PP(t,!0,!1,!1,!0,e);return this.u0(i,s),s.targetDiagram=this.NP(t,t.target),s.targetObject=null,e||s.clone(this.e0),s}iR(t,i,e){const s=this.PP(t,!1,!1,!1,!1,e);let n=root.document.elementFromPoint(i.clientX,i.clientY)||null;n!==null&&n.shadowRoot!==void 0&&n.shadowRoot!==null&&(n=n.shadowRoot.elementFromPoint(i.clientX,i.clientY));let o=this,r=t;if(n){const l=Diagram.He.get(n);l&&(r=i,o=l)}return s.targetDiagram=o,this.u0(r,s),s.targetObject=null,s}PP(t,i,e,s,n,o){const r=this.jr;this.jr=this._h,this._h=r,r.diagram=this,r.clickCount=1,r.delta=0;let l=0;return t.ctrlKey&&(l+=1),t.altKey&&(l+=2),t.shiftKey&&(l+=4),t.metaKey&&(l+=8),r.modifiers=l,r.event=t,r.timestamp=t.timeStamp,r.button=e?this.firstInput.button:t.button,r.buttons=t.buttons,Util.cr&&t.button===0&&t.ctrlKey&&(r.button=2),r.down=i,r.up=e,r.handled=s,r.bubbles=n,r.isMultiTouch=o,r}ha(t,i){return t.bubbles?(Debug&&Debug.handleMessages&&Util.at("NOT handled "+i.type+" "+t.toString()),!0):(Debug&&Debug.handleMessages&&Util.at("handled "+i.type+" "+this.currentTool.name+" "+t.toString()),i.stopPropagation!==void 0&&i.stopPropagation(),i.cancelable!==!1&&i.preventDefault(),i.cancelBubble=!0,!1)}oR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.vf(t,!1);return e.key=t.key,e.code=t.code,e.down=!0,i.doKeyDown(),i.ha(e,t)}rR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.vf(t,!1);return e.key=t.key,e.code=t.code,e.up=!0,i.doKeyUp(),i.ha(e,t)}sR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.vf(t,!0);return i.mouseEnter!==null&&i.mouseEnter(e),i.currentTool.standardMouseOver(),i.ha(e,t)}nR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.vf(t,!0);return i.mouseLeave!==null&&i.mouseLeave(e),i.ha(e,t)}getMouse(t){const i=this.xt;if(i===null)return new Point(0,0);const e=i.getBoundingClientRect(),s=(t.clientX-e.left)*(this.Ct/e.width),n=(t.clientY-e.top)*(this.At/e.height);return new Point(s,n).Ye(this.O)}u0(t,i){const e=this.xt;let s=0,n=0;if(e!==null){const r=e.getBoundingClientRect();s=(t.clientX-r.left)*(this.Ct/r.width),n=(t.clientY-r.top)*(this.At/r.height)}i.viewPoint.e(s,n);const o=Point.H(s,n);this.O.ns(o),i.documentPoint.c(o),Point.o(o)}DC(t,i,e){let s;if(this.ea[0]!==null)s=this.ea[i];else return;const n=this.xt;if(n!==null){const o=n.getBoundingClientRect();e.e((s.clientX-o.left)*(this.Ct/o.width),(s.clientY-o.top)*(this.At/o.height))}}invalidateDocumentBounds(){this.ta||(this.ta=!0,this.requestUpdate(!1))}gR(){this.ks||this.Di(),this.ensureBounds()}redraw(){this.$t||this.ks||(this.T(),this.maybeUpdate())}isUpdateRequested(){return this.Ar}delayInitialization(t){t===void 0&&(t=null);const i=this.animationManager,e=i.isEnabled;i.stopAnimation(),i.isEnabled=!1,this.Sr(),this.io=!1,this.fx=new Point(NaN,NaN),i.isEnabled=e,this.ks=!0;const s=this;t!==null&&Util.Bh(()=>{s.ks=!1,i.El("Model"),t(s)},1)}requestUpdate(t){if(t===void 0&&(t=!1),this.Ar===!0||this.$t||t===!1&&this.ks)return;this.Ar=!0;const i=this;root.requestAnimationFrame(()=>{i.Ar&&i.maybeUpdate()})}maybeUpdate(){this.Ku&&!this.Ar||(this.Ku&&(this.Ku=!1),this.Sr())}AP(t,i){!this.Hu||this.$t||this.animationManager.defaultAnimation.isAnimating||this.CA()||(t&&this.Di(),i&&this.Gs(!1))}Sr(t){if(this.ks||(this.Ar=!1,this.Ot===null&&!this.qu.isReal()))return;this.ks=!0;const i=this.animationManager,e=this.vu;if(!i.isAnimating&&e.length!==0){const f=e.h,c=f.length;for(let u=0;u0&&(s.each(f=>f.LP()),s.clear());let n=!1,o=!1;i.defaultAnimation.isAnimating&&(o=!0,n=this.skipsUndoManager,this.skipsUndoManager=!0),i.Si||this.RM(),t||this.AP(!1,!0);const r=!this.undoManager.isUndoingRedoing&&(this.Pl||this.Wf.count!==0&&this.Rr.size!==0),l=!this.io||this.Wr;this.Di(!0);let h=!1;(l||r)&&(this.io?this.TP(!this.Kf,r):(this.startTransaction("Initial Layout"),i.isEnabled===!1&&i.stopAnimation(),this.TP(!1,r)),h=l),this.Kf=!1,this.Pl=!1,this.Di(),this.os!==null&&(this.os.visible&&!this.t0&&(this.Zr(),this.t0=!0),!this.os.visible&&this.t0&&(this.t0=!1)),this.qx||this.gR(),t||this.AP(!0,!1);let a=!1;if(h){const f=Rect.a();f.c(this.viewportBounds),this.io||(this.io=!0,a=!0,this.skipsUndoManager||(this.undoManager.Uw=!0),this.undoManager.Gw=!0,this.mR()),this.pR(),this.Di(!1),t||this.AP(!0,!0),Rect.o(f)}else if(i.Df&&i.ax){if(this.Fr!==1)this.scale=this.$u(this.Fr);else if(this.Jl!==1)this.scale=this.$u(this.Jl);else{const f=this.initialScale;isFinite(f)&&f>0&&(this.scale=f)}this.Gs(!0)}h&&a&&this.commitTransaction("Initial Layout"),t||this.Ji(this.ei),o&&(this.skipsUndoManager=n),this.ks=!1}get Yh(){return this.io}mR(){if(this.Fr!==1)this.scale=this.$u(this.Fr);else if(this.Jl!==1)this.scale=this.$u(this.Jl);else{const i=this.initialScale;isFinite(i)&&i>0&&(this.scale=i)}this.Gs(!0);const t=this.Jt.h;this.Us(t,t.length,this,this.viewportBounds),this.V("InitialLayoutCompleted"),this.fx.c(this.mt),this.Zr()}pR(){this.V("LayoutCompleted")}d0(t){this.Qn.add(t)}addInvalidRoute(t){this.Vo?this.$h.add(t):this.Rr.add(t)}Di(t){if(this.Qn.size!==0&&!(!this.ks&&this.animationManager.isTicking)){if(this.ks||(this.Pl=!0),t){this.LA(this.Qn);return}for(let i=0;i<23&&this.Qn.size!==0;i++){const e=new Set(this.Qn);this.Qn.clear(),this.LP(e,this.Qn),Debug&&i===22&&Util.at("failure to validate parts")}this.nodes.each(i=>{i instanceof Group&&i.TA(!1)})}}LA(t,i){for(const e of t)!e.Ae()||e instanceof Group||(e.$r()?(e.wt(1/0,1/0),e.qt()):i&&i.add(e));for(const e of t)if(e instanceof Group){if(!e.isVisible())continue;this.T1(e)}}LP(t,i){this.LA(t,i);for(const e of t){if(!(e instanceof Link))continue;const s=e;s.isVisible()&&(s.$r()?(s.wt(1/0,1/0),s.qt()):i.add(s))}for(const e of t)e instanceof Adornment&&e.isVisible()&&(e.$r()?(e.wt(1/0,1/0),e.qt()):i.add(e))}g0(t){const i=t instanceof Diagram,e=i?t.links:t.memberParts,s=this.Qn;if(i)this.Di(!0);else{for(;e.next();){const n=e.value;s.has(n)&&(!n.Ae()||n instanceof Group||n.$r()&&(n.wt(1/0,1/0),n.qt()))}for(e.reset();e.next();){const n=e.value;if(s.has(n)&&n instanceof Group){if(!n.isVisible())continue;this.T1(n)}}e.reset()}for(;e.next();){const n=e.value;n instanceof Link&&s.has(n)&&n.isVisible()&&n.$r()&&(n.wt(1/0,1/0),n.qt())}}T1(t){const i=Util.ft(),e=Util.ft(),s=t.memberParts;for(;s.next();){const o=s.value;o.isVisible()&&(o instanceof Group?(o.Xo()||o.rs()||o.nh())&&this.T1(o):o instanceof Link?o.fromNode===t||o.toNode===t?e.push(o):i.push(o):(o.wt(1/0,1/0),o.qt()))}let n=i.length;for(let o=0;ob.zu())}else for(let x=0;x0){const a=n.substring(0,h);e?o=t.findObject(a):(o=t[a],o==null&&(o=t.toolManager[a])),Util.Mt(o)?r=n.substring(h+1):Util.n("Unable to find object named: "+a+" in "+t.toString()+" when trying to set property: "+n)}}if(r[0]!=="_"&&!Util.yw(o,r))if(s&&r==="ModelChanged"){t.addModelChangedListener(i[r]);continue}else if(s&&r==="Changed"){t.addChangedListener(i[r]);continue}else if(s&&Util.yw(t.toolManager,r))o=t.toolManager;else if(s&&t.DA(r)){t.addDiagramListener(r,i[r]);continue}else if(t instanceof Model&&r==="Changed"){t.addChangedListener(i[r]);continue}else Util.n('Trying to set undefined property "'+r+'" on object: '+o.toString());const l=i[n];o[r]=l,r[0]==="_"&&o instanceof GraphObject&&o.addCopyProperty(r)}}xR(){if(this.th.count!==0&&!(this.undoManager.transactionLevel>1)){for(;this.th.count>0;){const t=this.th;this.th=new GMap;const i=t.iterator;for(;i.next();){const e=i.key;e.invalidateOtherJumpOvers(i.value),e.re()}}this.T()}}T(t){if(t===void 0)this.Ge=!0,this.requestUpdate();else{const i=this.viewportBounds;t.isReal()&&i.intersectsRect(t)&&(this.Ge=!0,this.requestUpdate())}this.V("InvalidateDraw")}invalidateViewport(t,i){if(this.Ge===!0)return;if(this.Ge=!0,this.Uf==="svg"){this.maybeUpdate();return}this.getRenderingHint("temporaryPixelRatio")===!0?(this.jw(),this.maybeUpdate(),this.NS(!0)):this.maybeUpdate()}aa(){this.Hu=!0}sh(){this.Gf=!0}m0(){this.Yu!==!1&&(this.Yu=!1,this.PA(this.Ct,this.At))}PA(t,i){this.eh();const e=this.Gi,s=t*e,n=i*e;this.xt.resize(s,n,t,i)&&(this.Ge=!0,this.ei.clearContextCache(!0))}CA(){const t=this.xt;if(t===null||this.qu.isReal())return!0;const i=this.Ct,e=this.At,s=this.Ot;let n=!1,o=this.to?this.yi:0,r=this.xn?this.yi:0,l=s.clientWidth||i+o,h=s.clientHeight||e+r;const a=this.viewportBounds,f=a.x,c=a.y,u=a.width,d=a.height;if((l!==i+o||h!==e+r)&&(this.to=!1,this.xn=!1,o=0,r=0,this.Ct=l,this.At=h,this.Yu=!0,n=!0,this.eh()),!this.io||!this.viewportBounds.isReal())return!0;const m=this.g1,g=this.m1;if(this.Hu=!1,!n&&!this.to&&!this.xn&&!this.Uu&&!this.Gu)return!0;const p=this.documentBounds;let y=0,x=0,k=0,b=0;const S=a.width,M=a.height,A=this.zf;this.contentAlignment.isSpot()?(p.width>S&&(y=A.left,x=A.right),p.height>M&&(k=A.top,b=A.bottom)):(y=A.left,x=A.right,k=A.top,b=A.bottom);const C=p.width+y+x,P=p.height+k+b,N=this.scale,T=N;let L=C>l/N,D=P>h/N;if(!n&&!this.to&&!this.xn&&!L&&!D)return!0;const F=p.x-y,R=a.x,I=p.right+x;let O=a.right+o;const B=p.y-k,K=a.y,V=p.bottom+b;let X=a.bottom+r,z="1px",G="1px";if(this.scrollMode===1&&(L||D)){if(L&&this.hasHorizontalScrollbar&&this.allowHorizontalScroll){let Y=1;F+1O+1&&(Y=Math.max((I-O)*N+this.Ct,Y)),S+o+1X+1&&(Y=Math.max((V-X)*N+this.At,Y)),M+r+1O+1&&(v=Math.max((I-O)*N+this.Ct,v)),S+1X+1&&(v=Math.max((V-X)*N+Y,v)),M+1O+1&&(J=this.position.x*N)),this.Ju)switch(this.Cx){case"negative":J=-(m.scrollWidth-J-m.clientWidth);break;case"reverse":J=m.scrollWidth-J-m.clientWidth;break}if(m.scrollLeft=J,this.hasVerticalScrollbar&&this.allowVerticalScroll&&(M+1X+1&&(m.scrollTop=this.position.y*N)),l=this.Ct,h=this.At,m.style.width=l+(this.to?this.yi:0)+"px",m.style.height=h+(this.xn?this.yi:0)+"px",i!==l||e!==h||this.animationManager.Si){const Y=Rect.H(f,c,u,d);return this.onViewportBoundsChanged(Y,this.viewportBounds,T,n),Rect.o(Y),!1}return!0}add(t){Util.s(t,Part,Diagram,"add:part");const i=t.diagram;if(i===this)return;i!==null&&Util.n("Cannot add part "+t.toString()+" to "+this.toString()+". It is already a part of "+i.toString());let e=this.findLayer(t.layerName);if(e===null&&(e=this.findLayer("")),e===null&&Util.n('Cannot add a Part when unable find a Layer named "'+t.layerName+'" and there is no default Layer'),t.layer===e)return;const s=e.Zh(99999999,t,t.diagram===this);s>=0&&this.raiseChangedEvent(3,"parts",e,null,t,null,s),e.isTemporary||this.invalidateDocumentBounds(),t.invalidateLayout(1);const n=t.layerChanged;n!==null&&n(t,null,e)}Zh(t){this.partManager.Zh(t);const i=this;t.Qr(s=>i.FA(s)),t.data||t.Yo(),t.hasPlaceholder()&&t.u(),t.data!==null&&t.Qr(s=>i.partManager.FP(s,null)),(t.rs()===!0||t.nh()===!0)&&this.d0(t),t.RA(!0,this),t.IA()?(t.actualBounds.isReal()&&this.T(t.Jh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.T(t.Jh(t.actualBounds)),this.requestUpdate()}ne(t){t.clearAdornments(),this.partManager.ne(t);const i=this;t.data!==null&&t.Qr(s=>i.partManager.RP(s,i)),this.Qn.delete(t),t instanceof Link&&this.Rr.delete(t),t.IA()?(t.actualBounds.isReal()&&this.T(t.Jh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.T(t.Jh(t.actualBounds)),this.requestUpdate()}remove(t){Util.s(t,Part,Diagram,"remove:part"),this.IP(t,!0)}IP(t,i){const e=t.layer;if(e===null||e.diagram!==this)return;t.isSelected=!1,t.isHighlighted=!1,t.invalidateLayout(2),i&&t.Jf();const s=e.ne(-1,t,!1);s>=0&&this.raiseChangedEvent(4,"parts",e,t,null,s,null);const n=t.layerChanged;n!==null&&n(t,e,null)}removeParts(t,i){if(i===void 0&&(i=!1),Array.isArray(t)){const e=t.length;for(let s=0;s=0&&i.elt(e).isTemporary;)e--;return i.insertAt(e+1,t),this.Ai!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,e+1),this.T(),this.invalidateDocumentBounds(),this}addLayerBefore(t,i){this.OP(t,i),t.Oo(this);const e=this.Jt,s=e.indexOf(t);s>=0&&(e.delete(t),this.Ai!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;o=0&&(e.delete(t),this.Ai!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;othis.maxScale&&(i=this.maxScale);const f=Point.H(this.mt.x+l/t-l/i,this.mt.y+h/t-h/i);this.position=f,Point.o(f),this.lt=i,this.eh(),this.$t=!1,this.onViewportBoundsChanged(n,this.viewportBounds,t,!1),this.Gs(!1),e.rA(t,this.lt),this.T()}fR(){const t=this.Jt.h;for(let i=0;i{r.isAvoiding&&r.actualBounds.intersectsRect(i)&&r.invalidateRoute()})}Zr(t){const i=this.os;if(i===null||!i.visible||i.layer===null)return;const e=t!==void 0?t:this.a1;if(!e.isReal())return;const s=e.width,n=e.height;if(i.scale=1,i.angle=0,i.layer.isViewportAligned)i.width=s*this.scale,i.height=n*this.scale,i.part.alignment=Spot.TopLeft;else{i.Mi===null&&(i.Mi=new GridPanelSettings);const o=i.Mi.Zf;if(!o.isReal())return;i.width=s+o.width*2,i.height=n+o.height*2;const r=Point.a();Geo.Hg(e.x,e.y,0,0,o.width,o.height,r),r.offset(-o.width,-o.height),i.part.location=r,Point.o(r)}}clearSelection(t){t===void 0&&(t=!1);const i=this.selection;if(i.count===0)return;t||this.V("ChangingSelection",i);const e=i.toArray(),s=e.length;for(let n=0;n1)&&(this.V("ChangingSelection",this.selection),this.clearSelection(!0),t.isSelected=!0,this.V("ChangedSelection",this.selection)))}selectCollection(t){if(this.V("ChangingSelection",this.selection),this.clearSelection(!0),Array.isArray(t)){const i=t.length;for(let e=0;e0){const i=t.toArray(),e=i.length;for(let s=0;s1)&&(this.clearHighlighteds(),t.isHighlighted=!0))}highlightCollection(t){const i=new GSet().addAll(t),s=this.highlighteds.copy().removeAll(i).iterator;for(;s.next();){const o=s.value;o.isHighlighted=!1}const n=i.iterator;for(;n.next();){const o=n.value;o instanceof Part||Util.n("Diagram.highlightCollection given something that is not a Part: "+o),o.isHighlighted=!0}}scroll(t,i,e){e===void 0&&(e=1);const s=i==="up"||i==="down";let n=0;const o=Point.a();if(t==="pixel")n=e;else if(t==="line")n=e*(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange);else if(t==="page"){let l=s?this.viewportBounds.height:this.viewportBounds.width;if(l*=this.scale,l!==0){const h=Math.max(l-(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange),0);n=e*h}}else if(t==="document"){const l=this.documentBounds,h=this.viewportBounds;i==="up"?this.position=o.e(h.x,l.y):i==="left"?this.position=o.e(l.x,h.y):i==="down"?this.position=o.e(h.x,l.bottom-h.height):i==="right"&&(this.position=o.e(l.right-h.width,h.y)),Point.o(o);return}else Util.n("scrolling unit must be 'pixel', 'line', 'page', or 'document', not: "+t);n/=this.scale;const r=this.position;i==="up"?this.position=o.e(r.x,r.y-n):i==="down"?this.position=o.e(r.x,r.y+n):i==="left"?this.position=o.e(r.x-n,r.y):i==="right"?this.position=o.e(r.x+n,r.y):Util.n("scrolling direction must be 'up', 'down', 'left', or 'right', not: "+i),Point.o(o)}scrollToRect(t){const i=this.viewportBounds;if(i.containsRect(t))return;const e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}centerRect(t){const i=this.viewportBounds,e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}transformDocToView(t){return t.copy().O(this.O)}transformViewToDoc(t){return t.copy().Ye(this.O)}VF(t){return t.Ye(this.O)}static None=1;static Uniform=2;static UniformToFill=3;static CycleAll=1;static CycleNotDirected=2;static CycleNotDirectedFast=3;static CycleNotUndirected=4;static CycleDestinationTree=5;static CycleSourceTree=6;static DocumentScroll=1;static InfiniteScroll=2;static TreeParentCollapsed=1;static AllParentsCollapsed=2;static AnyParentsCollapsed=3;get opacity(){return this._t}set opacity(t){const i=this._t;i!==t&&(Util.t(t,"number",Diagram,"opacity"),(t<0||t>1)&&Util.G(t,"0 <= value <= 1",Diagram,"opacity"),this._t=t,this.i("opacity",i,t),this.T())}get validCycle(){return this.Yx}set validCycle(t){const i=this.Yx;i!==t&&(Util.tt(t,CycleMode,"CycleMode"),this.Yx=t,this.i("validCycle",i,t))}get layers(){return this.Jt.iterator}get isModelReadOnly(){const t=this.Ai;return t===null?!1:t.isReadOnly}set isModelReadOnly(t){const i=this.Ai;i!==null&&(i.isReadOnly=t)}get isReadOnly(){return this.zo}set isReadOnly(t){const i=this.zo;i!==t&&(Util.t(t,"boolean",Diagram,"isReadOnly"),this.zo=t,this.i("isReadOnly",i,t))}get isEnabled(){return this.Xi}set isEnabled(t){const i=this.Xi;i!==t&&(Util.t(t,"boolean",Diagram,"isEnabled"),this.Xi=t,this.i("isEnabled",i,t))}get allowClipboard(){return this.Wx}set allowClipboard(t){const i=this.Wx;i!==t&&(Util.t(t,"boolean",Diagram,"allowClipboard"),this.Wx=t,this.i("allowClipboard",i,t))}get allowCopy(){return this.Vl}set allowCopy(t){const i=this.Vl;i!==t&&(Util.t(t,"boolean",Diagram,"allowCopy"),this.Vl=t,this.i("allowCopy",i,t))}get allowDelete(){return this.Bl}set allowDelete(t){const i=this.Bl;i!==t&&(Util.t(t,"boolean",Diagram,"allowDelete"),this.Bl=t,this.i("allowDelete",i,t))}get allowDragOut(){return this.vx}set allowDragOut(t){const i=this.vx;i!==t&&(Util.t(t,"boolean",Diagram,"allowDragOut"),this.vx=t,this.i("allowDragOut",i,t))}get allowDrop(){return this.Jx}set allowDrop(t){const i=this.Jx;i!==t&&(Util.t(t,"boolean",Diagram,"allowDrop"),this.Jx=t,this.i("allowDrop",i,t))}get allowTextEdit(){return this.zl}set allowTextEdit(t){const i=this.zl;i!==t&&(Util.t(t,"boolean",Diagram,"allowTextEdit"),this.zl=t,this.i("allowTextEdit",i,t))}get allowGroup(){return this.Xl}set allowGroup(t){const i=this.Xl;i!==t&&(Util.t(t,"boolean",Diagram,"allowGroup"),this.Xl=t,this.i("allowGroup",i,t))}get allowUngroup(){return this.Yl}set allowUngroup(t){const i=this.Yl;i!==t&&(Util.t(t,"boolean",Diagram,"allowUngroup"),this.Yl=t,this.i("allowUngroup",i,t))}get allowInsert(){return this.Zx}set allowInsert(t){const i=this.Zx;i!==t&&(Util.t(t,"boolean",Diagram,"allowInsert"),this.Zx=t,this.i("allowInsert",i,t))}get allowLink(){return this.Kl}set allowLink(t){const i=this.Kl;i!==t&&(Util.t(t,"boolean",Diagram,"allowLink"),this.Kl=t,this.i("allowLink",i,t))}get allowRelink(){return this.Ul}set allowRelink(t){const i=this.Ul;i!==t&&(Util.t(t,"boolean",Diagram,"allowRelink"),this.Ul=t,this.i("allowRelink",i,t))}get allowMove(){return this.Gl}set allowMove(t){const i=this.Gl;i!==t&&(Util.t(t,"boolean",Diagram,"allowMove"),this.Gl=t,this.i("allowMove",i,t))}get allowReshape(){return this.Hl}set allowReshape(t){const i=this.Hl;i!==t&&(Util.t(t,"boolean",Diagram,"allowReshape"),this.Hl=t,this.i("allowReshape",i,t))}get allowResize(){return this.ql}set allowResize(t){const i=this.ql;i!==t&&(Util.t(t,"boolean",Diagram,"allowResize"),this.ql=t,this.i("allowResize",i,t))}get allowRotate(){return this.jl}set allowRotate(t){const i=this.jl;i!==t&&(Util.t(t,"boolean",Diagram,"allowRotate"),this.jl=t,this.i("allowRotate",i,t))}get allowSelect(){return this.Wl}set allowSelect(t){const i=this.Wl;i!==t&&(Util.t(t,"boolean",Diagram,"allowSelect"),this.Wl=t,this.i("allowSelect",i,t))}get allowUndo(){return this.$x}set allowUndo(t){const i=this.$x;i!==t&&(Util.t(t,"boolean",Diagram,"allowUndo"),this.$x=t,this.i("allowUndo",i,t))}get allowZoom(){return this.Qx}set allowZoom(t){const i=this.Qx;i!==t&&(Util.t(t,"boolean",Diagram,"allowZoom"),this.Qx=t,this.i("allowZoom",i,t))}get hasVerticalScrollbar(){return this.Gu}set hasVerticalScrollbar(t){const i=this.Gu;i!==t&&(Util.t(t,"boolean",Diagram,"hasVerticalScrollbar"),this.Gu=t,this.aa(),this.T(),this.i("hasVerticalScrollbar",i,t),this.Gs(!1))}get hasHorizontalScrollbar(){return this.Uu}set hasHorizontalScrollbar(t){const i=this.Uu;i!==t&&(Util.t(t,"boolean",Diagram,"hasHorizontalScrollbar"),this.Uu=t,this.aa(),this.T(),this.i("hasHorizontalScrollbar",i,t),this.Gs(!1))}get allowHorizontalScroll(){return this._x}set allowHorizontalScroll(t){const i=this._x;i!==t&&(Util.t(t,"boolean",Diagram,"allowHorizontalScroll"),this._x=t,this.i("allowHorizontalScroll",i,t),this.Gs(!1))}get allowVerticalScroll(){return this.t1}set allowVerticalScroll(t){const i=this.t1;i!==t&&(Util.t(t,"boolean",Diagram,"allowVerticalScroll"),this.t1=t,this.i("allowVerticalScroll",i,t),this.Gs(!1))}get scrollHorizontalLineChange(){return this.i1}set scrollHorizontalLineChange(t){const i=this.i1;i!==t&&(Util.t(t,"number",Diagram,"scrollHorizontalLineChange"),t<0&&Util.G(t,">= 0",Diagram,"scrollHorizontalLineChange"),this.i1=t,this.i("scrollHorizontalLineChange",i,t))}get scrollVerticalLineChange(){return this.e1}set scrollVerticalLineChange(t){const i=this.e1;i!==t&&(Util.t(t,"number",Diagram,"scrollVerticalLineChange"),t<0&&Util.G(t,">= 0",Diagram,"scrollVerticalLineChange"),this.e1=t,this.i("scrollVerticalLineChange",i,t))}get lastInput(){return this._h}set lastInput(t){Debug&&Util.s(t,InputEvent,Diagram,"lastInput"),this._h=t}get previousInput(){return this.jr}set previousInput(t){Debug&&Util.s(t,InputEvent,Diagram,"previousInput"),this.jr=t}get firstInput(){return this.e0}set firstInput(t){Debug&&Util.s(t,InputEvent,Diagram,"firstInput"),this.e0=t}get currentCursor(){return this.Kx}set currentCursor(t){if(t===""&&(t=this.Jm),this.Kx!==t){Util.t(t,"string",Diagram,"currentCursor");const e=this.xt,s=this.Ot;if(e===null||s===null)return;this.Kx=t;const n=e.style.cursor;e.style.cursor=t,s.style.cursor=t,e.style.cursor===n&&(e.style.cursor="-webkit-"+t,s.style.cursor="-webkit-"+t,e.style.cursor===n&&(e.style.cursor="-moz-"+t,s.style.cursor="-moz-"+t,e.style.cursor===n&&(e.style.cursor=t,s.style.cursor=t)))}}get defaultCursor(){return this.Jm}set defaultCursor(t){t===""&&(t="auto");const i=this.Jm;i!==t&&(Util.t(t,"string",Diagram,"defaultCursor"),this.Jm=t,this.i("defaultCursor",i,t))}get click(){return this.Or}set click(t){const i=this.Or;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"click"),this.Or=t,this.i("click",i,t))}get doubleClick(){return this.Er}set doubleClick(t){const i=this.Er;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"doubleClick"),this.Er=t,this.i("doubleClick",i,t))}get contextClick(){return this.Vr}set contextClick(t){const i=this.Vr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"contextClick"),this.Vr=t,this.i("contextClick",i,t))}get mouseOver(){return this.Br}set mouseOver(t){const i=this.Br;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseOver"),this.Br=t,this.i("mouseOver",i,t))}get mouseHover(){return this.zr}set mouseHover(t){const i=this.zr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseHover"),this.zr=t,this.i("mouseHover",i,t))}get mouseHold(){return this.Xr}set mouseHold(t){const i=this.Xr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseHold"),this.Xr=t,this.i("mouseHold",i,t))}get mouseDragOver(){return this.Ux}set mouseDragOver(t){const i=this.Ux;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseDragOver"),this.Ux=t,this.i("mouseDragOver",i,t))}get mouseDrop(){return this.Yr}set mouseDrop(t){const i=this.Yr;i!==t&&(Debug&&t!==null&&Util.t(t,"function",Diagram,"mouseDrop"),this.Yr=t,this.i("mouseDrop",i,t))}get handlesDragDropForTopLevelParts(){return this.Gx}set handlesDragDropForTopLevelParts(t){const i=this.Gx;i!==t&&(Util.t(t,"boolean",Diagram,"handlesDragDropForTopLevelParts"),this.Gx=t,this.i("handlesDragDropForTopLevelParts",i,t))}get mouseEnter(){return this.Kr}set mouseEnter(t){const i=this.Kr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseEnter"),this.Kr=t,this.i("mouseEnter",i,t))}get mouseLeave(){return this.Ur}set mouseLeave(t){const i=this.Ur;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseLeave"),this.Ur=t,this.i("mouseLeave",i,t))}get toolTip(){return this.Gr}set toolTip(t){const i=this.Gr;i!==t&&(Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("Diagram.toolTip must be an Adornment or HTMLInfo."),this.Gr=t,this.i("toolTip",i,t))}get contextMenu(){return this.Hr}set contextMenu(t){const i=this.Hr;i!==t&&(Debug&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("Diagram.contextMenu must be an Adornment or HTMLInfo."),this.Hr=t,this.i("contextMenu",i,t))}get commandHandler(){return this.tP}set commandHandler(t){this.tP!==t&&(this.tP=t,t.Oo(this))}get toolManager(){return this.$M}set toolManager(t){this.$M!==t&&(Util.s(t,ToolManager,Diagram,"toolManager"),this.$M=t,t.diagram=this)}get defaultTool(){return this.QM}set defaultTool(t){const i=this.QM;i!==t&&(Util.s(t,Tool,Diagram,"defaultTool"),this.QM=t,t.diagram=this,this.currentTool===i&&(this.currentTool=t))}get currentTool(){return this._M}set currentTool(t){const i=this._M;i&&(i.isActive&&i.doDeactivate(),i.cancelWaitAfter(),i.doStop()),t===null&&(t=this.defaultTool),t!==null&&(Util.s(t,Tool,Diagram,"currentTool"),this._M=t,t.diagram=this,t.doStart())}get selection(){return this.lP}get maxSelectionCount(){return this.h1}set maxSelectionCount(t){const i=this.h1;if(i!==t)if(Util.t(t,"number",Diagram,"maxSelectionCount"),t>=0&&!isNaN(t)){if(this.h1=t,this.i("maxSelectionCount",i,t),!this.undoManager.isUndoingRedoing){const e=this.selection.count-t;if(e>0){this.V("ChangingSelection",this.selection);const s=this.selection.toArray();for(let n=0;n= 0",Diagram,"maxSelectionCount")}get nodeSelectionAdornmentTemplate(){return this._m}set nodeSelectionAdornmentTemplate(t){const i=this._m;i!==t&&(Util.s(t,Adornment,Diagram,"nodeSelectionAdornmentTemplate"),this._m=t,this.i("nodeSelectionAdornmentTemplate",i,t))}get groupSelectionAdornmentTemplate(){return this.c1}set groupSelectionAdornmentTemplate(t){const i=this.c1;i!==t&&(Util.s(t,Adornment,Diagram,"groupSelectionAdornmentTemplate"),this.c1=t,this.i("groupSelectionAdornmentTemplate",i,t))}get linkSelectionAdornmentTemplate(){return this.u1}set linkSelectionAdornmentTemplate(t){const i=this.u1;i!==t&&(Util.s(t,Adornment,Diagram,"linkSelectionAdornmentTemplate"),this.u1=t,this.i("linkSelectionAdornmentTemplate",i,t))}get highlighteds(){return this.hP}get isModified(){const t=this.undoManager;return t.isEnabled?t.currentTransaction!==null?!0:this.ju&&this.zs!==t.historyIndex:this.ju}set isModified(t){if(this.ju!==t){Util.t(t,"boolean",Diagram,"isModified"),this.ju=t;const e=this.undoManager;!t&&e.isEnabled&&(this.zs=e.historyIndex),t||this.KA()}}KA(){const t=this.isModified;this.oP!==t&&(this.oP=t,this.V("Modified"))}get model(){return this.Ai}set model(t){const i=this.Ai;if(i!==t){Util.s(t,Model,Diagram,"model"),this.currentTool.doCancel(),i&&i.undoManager!==t.undoManager&&i.undoManager.isInTransaction&&Util.n("Do not replace a Diagram.model while a transaction is in progress."),this.animationManager.stopAnimation(!0);const e=this.SA(!0);this.io=!1,this.Ku=!0,this.zs=-2,this.Ar=!1;const s=this.$t;this.$t=!0,this.animationManager.El("Model"),i&&(this._n!==null&&this._n.each(n=>i.removeChangedListener(n)),i.removeChangedListener(this.nP)),this.Ai=t,this.partManager=this.bR(this.Ai.type),this.initializePartManager(this.partManager);for(let n=0;nt.addChangedListener(n)),this.$t=s,this.invalidateDocumentBounds(),this.$t||this.T(),i&&t.undoManager.copyProperties(i.undoManager)}}get themeManager(){return this.C1}set themeManager(t){const i=this.C1;i!==t&&(Util.s(t,ThemeManager,Model,"themeManager"),i!==null&&i.removeDiagram(this),this.C1=t,t!==null&&t.addDiagram(this))}initializePartManager(t){}static SP(t,i){Diagram.pA.set(t,i)}static get licenseKey(){return Diagram.VP.last()}static set licenseKey(t){Diagram.VP.add(t.replace(/\s/g,""))}static get version(){return Diagram.kR}static VP=new List;static kR="3.0.11";bR(t){const i=Diagram.pA.get(t);return i!==null?new i:new PartManager}get j(){return this.eP}set j(t){this.eP=t}get Mx(){return this.dA}SR(t){if(t.model!==this.model)return;const i=t.change,e=t.propertyName;if(i===1&&e[0]==="S"){if(e==="StartingFirstTransaction"){const s=this,n=this.toolManager;n.mouseDownTools.each(o=>o.diagram=s),n.mouseMoveTools.each(o=>o.diagram=s),n.mouseUpTools.each(o=>o.diagram=s),this.routers.each(o=>o.diagram=s),!this.ks&&!this.io&&(this.Kf=!0,this.Ku&&(this.Ar=!0))}else if(e==="StartingUndo"||e==="StartingRedo"){const s=this.animationManager;this.skipsUndoManager||(s.defaultAnimation.isAnimating&&s.stopAnimation(),s.getBundleAnimation().isAnimating&&s.getBundleAnimation().stop()),this.V("ChangingSelection",this.selection)}else if(e==="StartedTransaction"){const s=this.animationManager;s.defaultAnimation.isAnimating&&!this.skipsUndoManager&&s.stopAnimation()}return}if(this.j){this.j=!1;try{if(t.modelChange===""&&i===1){(e==="FinishedUndo"||e==="FinishedRedo")&&(this.V("ChangedSelection",this.selection),this.Di());const s=this.animationManager;e==="RolledBackTransaction"&&s.stopAnimation(),this.xR(),this.Kf=!0,this.maybeUpdate(),(this.undoManager.transactionLevel===0||this.undoManager.transactionLevel===1)&&s.FM(),e==="CommittedTransaction"&&this.undoManager.isJustDiscarded&&(this.zs=Math.min(this.zs,this.undoManager.historyIndex-1)),(e==="CommittedTransaction"||e==="RolledBackTransaction")&&this.undoManager.Gw&&setTimeout(()=>{this.isModified=!1},1);const n=t.isTransactionFinished;if(n&&(this.KA(),this.Mx.clear(),this.animationManager.bF()),!this.Hx&&n&&this.lastInput.targetDiagram){this.Hx=!0;const o=this;Util.Bh(()=>{o.currentTool.standardMouseOver(),o.Hx=!1},10)}}}finally{this.j=!0}}}get me(){return this.iP}set me(t){this.iP=t}get bf(){return this.qx}set bf(t){this.qx=t}FA(t){const i=t.D.h;for(const e of i)e instanceof Picture&&this.BP(e)}BP(t){const i=t.element;if(i===null||!(i instanceof HTMLImageElement)||(i.ls instanceof GSet&&i.ls.add(this),t.MR(),!i.w0))return;const e=i.getAttribute("src")||"",s=this._l.get(e);if(s===null){Picture.UA(t,i);const n=[];n.push(t),this._l.set(e,n)}else{for(let n=0;n0)&&Util.n("defaultScale must be larger than zero, not: "+t),this.s0=t}get autoScale(){return this.Jl}set autoScale(t){const i=this.Jl;i!==t&&(Util.tt(t,AutoScale,"AutoScale"),this.Jl=t,this.i("autoScale",i,t),t!==1&&this.Gs(!1))}get initialAutoScale(){return this.Fr}set initialAutoScale(t){const i=this.Fr;i!==t&&(Util.tt(t,AutoScale,"AutoScale"),this.Fr=t,this.i("initialAutoScale",i,t))}get initialViewportSpot(){return this.Bx}set initialViewportSpot(t){const i=this.Bx;i!==t&&(Util.s(t,Spot,Diagram,"initialViewportSpot"),t.isSpot()||Util.n("initialViewportSpot must be a specific Spot: "+t),this.Bx=t,this.i("initialViewportSpot",i,t))}get initialDocumentSpot(){return this.Vx}set initialDocumentSpot(t){const i=this.Vx;i!==t&&(Util.s(t,Spot,Diagram,"initialDocumentSpot"),t.isSpot()||Util.n("initialViewportSpot must be a specific Spot: "+t),this.Vx=t,this.i("initialDocumentSpot",i,t))}get minScale(){return this.Tx}set minScale(t){Util.r(t,Diagram,"minScale");const i=this.Tx;i!==t&&(t>0?(this.Tx=t,this.i("minScale",i,t),t>this.scale&&(this.scale=t)):Util.G(t,"> 0",Diagram,"minScale"))}get maxScale(){return this.Dx}set maxScale(t){Util.r(t,Diagram,"maxScale");const i=this.Dx;i!==t&&(t>0?(this.Dx=t,this.i("maxScale",i,t),t 0",Diagram,"maxScale"))}get zoomPoint(){return this.Fx}set zoomPoint(t){this.Fx.equals(t)||(Util.s(t,Point,Diagram,"zoomPoint"),t=t.L(),this.Fx=t)}get contentAlignment(){return this.Xf}set contentAlignment(t){const i=this.Xf;i.equals(t)||(Util.s(t,Spot,Diagram,"contentAlignment"),t=t.L(),this.Xf=t,this.i("contentAlignment",i,t),this.Gs(!1))}get initialContentAlignment(){return this.jm}set initialContentAlignment(t){const i=this.jm;i.equals(t)||(Util.s(t,Spot,Diagram,"initialContentAlignment"),t=t.L(),this.jm=t,this.i("initialContentAlignment",i,t))}get padding(){return this.ii}set padding(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Diagram,"padding");const i=this.ii;i.equals(t)||(t=t.L(),this.ii=t,this.invalidateDocumentBounds(),this.i("padding",i,t))}get partManager(){return this.dP}set partManager(t){const i=this.dP;i!==t&&(Util.s(t,PartManager,Diagram,"partManager"),t.diagram!==null&&Util.n("Cannot share PartManagers between Diagrams: "+t.toString()),i&&i.Oo(null),this.dP=t,t.Oo(this))}get nodes(){return this.partManager.nodes.iterator}get links(){return this.partManager.links.iterator}get parts(){return this.partManager.parts.iterator}findTopLevelNodesAndLinks(){const t=new GSet,i=this.nodes;for(;i.next();){const s=i.value;s.isTopLevel&&t.add(s)}const e=this.links;for(;e.next();){const s=e.value;s.isTopLevel&&t.add(s)}return t.iterator}findTopLevelGroups(){return this.vr.iterator}get routers(){return this.Wf}doLinkRouting(t){this.Vo=!0;const i=this.Wf.h;for(let e=0;e0){const l=this.computePartsBounds(n.memberParts,!1);l.inflate(20,20),s.I1(l)}const o=Rect.a(),r=n.memberParts;for(;r.next();){const l=r.value;l instanceof Node&&this.GP(l,e,o)}Rect.o(o)}s.ca=n,s.YP=e,s.Ko=!1}else t&&s.vA();return s}get avoidanceCellSize(){return this.aP}set avoidanceCellSize(t){this.Zl=null,this.aP=new Size(Math.max(1,t.width),Math.max(1,t.height))}get avoidanceLimit(){return this.fP}set avoidanceLimit(t){this.fP=Math.max(1,t)}WA(t){return t.canAvoid()?t:t.containingGroup!==null?this.WA(t.containingGroup):null}GP(t,i,e){if(t===i||!t.isVisible())return;const s=t.canAvoid();if(s){const n=t.getAvoidableRect(e);this.Zl.CR(n.x,n.y,n.width,n.height)}if(t instanceof Group&&(!s||t.avoidableMembers)){const n=t.memberParts;for(;n.next();){const o=n.value;o instanceof Node&&this.GP(o,i,e)}}}HP(t){this.Zl!==null&&!this.Zl.Ko&&(t===void 0||t.canAvoid())&&(this.Zl.Ko=!0)}get autoScrollInterval(){return this.Wm}set autoScrollInterval(t){const i=this.Wm;Util.r(t,Diagram,"autoScrollInterval"),i!==t&&(this.Wm=t,this.i("autoScrollInterval",i,t))}get autoScrollRegion(){return this.vm}set autoScrollRegion(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Diagram,"autoScrollRegion");const i=this.vm;i.equals(t)||(t=t.L(),this.vm=t,this.invalidateDocumentBounds(),this.i("autoScrollRegion",i,t))}doAutoScroll(t){this.i0.c(t),this.computeAutoScrollPosition(this.i0).equalsApprox(this.position)?this.stopAutoScroll():this.JA()}JA(){if(this.Yf!==-1)return;const t=this.Wm,i=this;this.Yf=Util.Bh(()=>{if(i.Yf===-1||(i.stopAutoScroll(),i.lastInput.event===null))return;const s=i.computeAutoScrollPosition(i.i0);if(s.equalsApprox(i.position))return;i.position=s,i.lastInput.documentPoint=i.transformViewToDoc(i.i0),i.doMouseMove(),i.ta=!0;const n=Rect.a();i.computeBounds(n),n.unionRect(i.documentBounds),i.GA(n),Rect.o(n),i.Ge=!0,i.maybeUpdate(),i.JA()},t)}stopAutoScroll(){this.Yf!==-1&&(Util.Ug(this.Yf),this.Yf=-1)}computeAutoScrollPosition(t){let i=this.position;const e=this.vm;if(e.top<=0&&e.left<=0&&e.right<=0&&e.bottom<=0)return i;const s=this.viewportBounds,n=this.scale,o=Rect.H(0,0,s.width*n,s.height*n),r=Point.H(0,0);if(t.x>=o.x&&t.xo.x+o.width-e.right&&this.allowHorizontalScroll){let l=Math.max(this.scrollHorizontalLineChange,1);l=l|0,r.x+=l,t.x>o.x+o.width-e.right/2&&(r.x+=l),t.x>o.x+o.width-e.right/4&&(r.x+=4*l)}if(t.y>=o.y&&t.yo.y+o.height-e.bottom&&this.allowVerticalScroll){let l=Math.max(this.scrollVerticalLineChange,1);l=l|0,r.y+=l,t.y>o.y+o.height-e.bottom/2&&(r.y+=l),t.y>o.y+o.height-e.bottom/4&&(r.y+=4*l)}return r.equalsApprox(Point.Lo)||(i=new Point(i.x+r.x/n,i.y+r.y/n)),Rect.o(o),Point.o(r),i}makeSvg(t){this.Ql.has("SVG")||this.addRenderer("SVG",new SVGSurface(this,root.document));const i=new SVGSurface(this,root.document,!0);t===void 0&&(t={});const e=this;function s(n,o){const r=e.ZA(n,"SVG",i),l=r!==null?r.svg:null;return typeof o=="function"?(o(l),null):l}return this.$A(s,t)}makeSVG(t){return this.makeSvg(t)}addRenderer(t,i){this.Ql.set(t,i)}removeRenderer(t){this.Ql.delete(t)}cacheGroupExternalLinks(t){this.kP=t,t||this.nodes.each(i=>{i instanceof Group&&(i.b0=null)})}$A(t,i){const e=i.callback;let s=!0;const o=this._l.iterator;for(;o.next();)if(!o.value[0].bn){s=!1;break}if(typeof e!="function"||s)return t(i,e,this);const r=this;function l(){const f=+new Date;for(s=!0,o.reset();o.next();)if(!o.value[0].bn){s=!1;break}if(s||f-a>h){t(i,e,r);return}root.requestAnimationFrame(l)}const h=i.callbackTimeout||300,a=+new Date;return root.requestAnimationFrame(()=>l()),null}makeImage(t){return Diagram.isUsingDOM()?(t===void 0&&(t={}),t.returnType="Image",this.makeImageData(t)):null}makeImageData(t){return t===void 0&&(t={}),this.$A(this.AR,t)}static img="image";AR(t,i,e){const s=e.ZA(t,"canvas",null);if(s===null)return null;const n=s.Y.canvas;let o=null;if(n!==null){let r=t.returnType;switch(r===void 0?r="string":r=r.toLowerCase(),r){case Diagram.img+"data":o=s.getImageData(0,0,n.width,n.height);break;case Diagram.img:const h=(t.document||document).createElement("img");h.src=n.toDataURL(t.type,t.details),o=h;break;case"blob":{const a=n;return typeof i!="function"&&(o="",Util.n('Error: Diagram.makeImageData called with "returnType: toBlob", but no required "callback" function property defined.')),typeof a.toBlob=="function"?(a.toBlob(i,t.type,t.details),"toBlob"):(i(null),null)}case"string":default:o=n.toDataURL(t.type,t.details)}}return typeof i=="function"?(i(o),null):o}static QA=!1;ZA(t,i,e){if(this.animationManager.stopAnimation(),this.maybeUpdate(),this.xt===null)return null;typeof t!="object"&&Util.n("properties argument must be an Object.");let n=!1,o=t.size||null,r=t.scale||null;t.scale!==void 0&&isNaN(t.scale)&&(r="NaN");let l=t.maxSize;t.maxSize===void 0&&(n=!0,i==="SVG"?l=new Size(1/0,1/0):l=new Size(2e3,2e3));const h=t.position||null;let a=t.parts||null;Array.isArray(a)&&(a=new List(a));let f=t.padding===void 0?1:t.padding;const c=t.background||null;let u=t.omitTemporary;u===void 0&&(u=!0);const d=t.document||document,m=t.elementFinished||null;let g=t.showTemporary;g===void 0&&(g=!u);let p=t.showGrid;p===void 0&&(p=g),o!==null&&isNaN(o.width)&&isNaN(o.height)&&(o=null),typeof f=="number"?f=new Margin(f):f instanceof Margin||Util.n("MakeImage padding must be a Margin or a number."),f.left=Math.max(f.left,0),f.right=Math.max(f.right,0),f.top=Math.max(f.top,0),f.bottom=Math.max(f.bottom,0),this.ei.clearContextCache(!0);const y=new CanvasSurface(null,d,void 0,!0),x=y.di;if(!(o||r||a||h))return y.width=this.Ct+Math.ceil(f.left+f.right),y.height=this.At+Math.ceil(f.top+f.bottom),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.ua=d,e.Qu=m,this.D1(e.di,f,new Size(y.width,y.height),this.lt,this.mt,a,c,g,p),e.di):(this.Wu=!1,this.D1(x,f,new Size(y.width,y.height),this.lt,this.mt,a,c,g,p),this.Wu=!0,y.di);const k=this.s0,b=this.documentBounds.copy();if(b.subtractMargin(this.ii),g){const L=this.Jt.h,D=L.length;for(let F=0;Fk?(r=k,N=b.width,T=b.height):(N=l.width,T=l.height)):(N=b.width*r,T=b.height*r):(r=k,N=b.width,T=b.height),f!==null?(N+=M,T+=A):f=new Margin(0),l!==null){let L=l.width,D=l.height;i!=="SVG"&&n&&!Diagram.QA&&Debug&&(N>L||T>D)&&(Util.at("Diagram.makeImage(data): Diagram width or height is larger than the default max size. ("+Math.ceil(N)+"x"+Math.ceil(T)+" vs 2000x2000) Consider increasing the max size."),Diagram.QA=!0),isNaN(L)&&(L=2e3),isNaN(D)&&(D=2e3),isFinite(L)&&(N=Math.min(N,L)),isFinite(D)&&(T=Math.min(T,D))}return y.width=Math.ceil(N),y.height=Math.ceil(T),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.ua=d,e.Qu=m,this.D1(e.di,f,new Size(Math.ceil(N),Math.ceil(T)),r,S,a,c,g,p),e.di):(this.Wu=!1,this.D1(x,f,new Size(Math.ceil(N),Math.ceil(T)),r,S,a,c,g,p),this.Wu=!0,y.di)}static Zu=null;static _A="5da73c80a36555d4038e4972187c3cae51fd22";static ww=!1;static Hk=()=>{if(Diagram._A[5]===void 0&&(Transform.prototype.ns=Transform.prototype.Nw),!Diagram.isUsingDOM())return;const t=root.document.createElement("canvas"),i=t.getContext("2d"),e=Util.Fs("7ca11abfd022028846");i[e]=Util.Fs("398c3597c01238");const s="7ca11abfd7330390",n=[Diagram._A,Util.ww+"4ae6247590da4bb21c324ba3a84e385776",Transform.Hk+"fb236cdfda5de14c134ba1a95a2d4c7cc6f93c1387",Geo.za],o=10,r=0;for(let l=1;l<5;l++)i[Util.Fs(s)](Util.Fs(n[l-1]),o,l*15+r);i[e]=Util.Fs("39f046ebb36e4b");for(let l=1;l<5;l++)i[Util.Fs(s)](Util.Fs(n[l-1]),o,l*15+r);(n.length!==4||n[0][0]!=="5"||n[3][0]!=="7")&&(Transform.prototype.ns=Transform.prototype.Nw),Diagram.Zu=t}}class DiagramHelper{tL;iL;qP;De;constructor(t){if(this.tL=null,this.iL="63ad05bbe23a1786468a4c741b6d2",this.qP="@onz",this.iL===this._tk){this.qP=!0,this.De=this.qP;return}this.De=null}LR(t,i){let e="f";const s=root[Util.Fs("76a715b2f73f148a")][Util.Fs("72ba13b5")]||"",n=Util.Fs;if(this.De=!0,!Diagram.isUsingDOM())return;let o=Diagram[n("76a115b6ed251eaf4692")];if(!o){const l=s[n("76ad18b4f73e")];for(let a=s[n("73a612b6fb191d")](n("35e7"))+2;a=0&&ha[0]||h[0]===a[0]&&h[1]>=a[1]))continue;const f="73a612b6fb191d",c=root[n("74a900bae4370f8b51")][n("6fbb13a1c2311e8a57")].toLowerCase(),u=c[n(f)](n("3aad1ab6e022098b4dc4")),d=n(l[2]);if(u>-1){const P=c[n(f)](d.toLowerCase()+"/");if(this.De=!(P>-1&&P=0&&g-1),!this.De))return;const p=root[Util.Fs("76a715b2f73f148a")][Util.Fs("69ad17a1e03e")],y=p[n(f)](n("7fb002b6ed25128b4da25b2e"));if(y>-1&&(this.De=!(p[n(f)](d)>y),!this.De))return;const x=d;if(x[0]!=="#")continue;const k=root.document.createElement("div");let b=l[0].replace(/[A-Za-z]/g,"");for(;b.length<4;)b+="9";const S=b;b=b.substring(b.length-4);let M="";const A=["gsh","gsf"],C=["Header","Background","Display","Feedback"];if(M+=A[parseInt(b.substring(0,1),10)%2],M+=C[parseInt(b.substring(0,1),10)%4],k[n("79a417a0f0181a8946")]=M,root.document[n("78a712aa")]){root.document[n("78a712aa")][n("7bb806b6ed32388c4a875b")](k);const P=root.getComputedStyle(k).getPropertyValue(n("78a704b7e62456904c9b12701b6532a8")),N=root.getComputedStyle(k).getPropertyValue(n("75b817b0ea2202"));if(root.document[n("78a712aa")][n("68ad1bbcf533388c4a875b")](k),!P)continue;const T=root[n("77a902b0eb1b1e804a8a")],L="0."+parseInt(S,10)%100;if(N===L||P.indexOf(parseInt(x[1]+x[2],16))!==-1&&P.indexOf(parseInt(x[3]+x[4],16))!==-1){this.De=!1;return}else if(T&&T(n("32ae19a1e0331fc94084537c067a67fa59f1386b89d006")).matches){M="."+M;for(let D=0;D{const s=this.observed;if(s===null)return;const n=s.viewportBounds,o=this.lastInput.documentPoint;s.position=new Point(o.x-n.width/2,o.y-n.height/2)},this.vP=s=>{this.invalidateDocumentBounds(),this.S0()},this.JP=s=>{this.observed!==null&&(this.invalidateDocumentBounds(),this.T())},this.z1=s=>{this.updateDelay<1?this.T():this.k0||(this.k0=!0,setTimeout(()=>this.redraw(),this.updateDelay))},this.ZP=s=>{this.observed!==null&&this.S0()},this.autoScale=2,this.$t=!1,i&&Object.assign(this,i),this}setupRouters(){}computePixelRatio(){return 1}redraw(){this.k0&&this.updateDelay>=1&&(this.k0=!1,this.TR()),super.redraw()}Ji(){if(this.Ot===null&&Util.n("No div specified"),this.xt===null&&Util.n("No canvas specified"),this.xt instanceof SVGSurface||(this.box.jM(),!this.Ge))return;const t=this.observed;if(t===null||t.animationManager.defaultAnimation.isAnimating||!t.Yh)return;this.m0();const i=this.xt,e=this.ei;if(e.clearContextCache(!0),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,i.width,i.height),this.updateDelay<1)this.sL();else if(this.Qf!==null){e.drawImage(this.Qf.Bt,0,0);const o=this.O;e.scale(this.Gi,this.Gi),e.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),e.commitTransform()}const s=this.Jt.h,n=s.length;for(let o=0;on.canDelete())}t.removeParts(i,!0),t.V("SelectionDeleted",i)}finally{t.commitTransaction("Delete"),t.V("ChangedSelection",t.selection),t.currentCursor=""}}canDeleteSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowDelete||t.selection.count===0)}copySelection(){const t=this.diagram;try{const i=new GSet,e=t.selection.iterator;for(;e.next();){const s=e.value;Part.lh(i,s,!0,this.copiesTree?1/0:0,this.copiesConnectedLinks,n=>n.canCopy())}this.copyToClipboard(i)}finally{}}canCopySelection(){const t=this.diagram;return!(!t.allowCopy||!t.allowClipboard||t.selection.count===0)}cutSelection(){this.copySelection(),this.deleteSelection()}canCutSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowCopy||!t.allowDelete||!t.allowClipboard||t.selection.count===0)}copyToClipboard(t){const i=this.diagram;let e=null;if(t===null)Diagram.kA();else{const s=i.model;let n=!1,o=!1,r=null;try{s.Mf()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.kf()||s._u())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=i.copyParts(t,null,!0)}finally{s.Mf()&&(s.copiesParentKeyOfNodeData=n),(s.kf()||s._u())&&(s.copiesGroupKeyOfNodeData=o),e=new List,e.addAll(r.iteratorValues),Diagram.c0=e,Diagram.A1=i.model.dataFormat}}i.V("ClipboardChanged",e)}pasteFromClipboard(){const t=new GSet,i=Diagram.c0;if(i===null)return t;const e=this.diagram;if(Diagram.A1!==e.model.dataFormat)return t;const s=e.model;let n=!1,o=!1,r=null;try{s.Mf()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.kf()||s._u())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=e.copyParts(i,e,!1)}finally{s.Mf()&&(s.copiesParentKeyOfNodeData=n),(s.kf()||s._u())&&(s.copiesGroupKeyOfNodeData=o);const l=r.iterator;for(;l.next();){const h=l.value,a=l.key;h.location.isReal()||(a.location.isReal()?h.location=a.location:!h.position.isReal()&&a.position.isReal()&&(h.position=a.position)),t.add(h)}}return t}pasteSelection(t){t===void 0&&(t=null);const i=this.diagram;try{i.currentCursor="wait",i.V("ChangingSelection",i.selection),i.startTransaction("Paste");const e=this.pasteFromClipboard();e.count>0&&i.clearSelection(!0);const s=e.iterator;for(;s.next();){const n=s.value;n.isSelected=!0}if(t!==null){const n=i.computePartsBounds(i.selection);if(n.isReal()){const o=this.computeEffectiveCollection(i.selection,i.M1);i.LS(o,new Point(t.x-n.centerX,t.y-n.centerY),i.M1,!1)}}i.V("ClipboardPasted",e)}finally{i.commitTransaction("Paste"),i.V("ChangedSelection",i.selection),i.currentCursor=""}}canPasteSelection(t){const i=this.diagram;return!(i.isReadOnly||i.isModelReadOnly||!i.allowInsert||!i.allowClipboard||Diagram.c0===null||Diagram.c0.count===0||Diagram.A1!==i.model.dataFormat)}undo(){this.diagram.undoManager.undo()}canUndo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canUndo()}redo(){this.diagram.undoManager.redo()}canRedo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canRedo()}decreaseZoom(t){t===void 0&&(t=1/this.zoomFactor),Util.r(t,CommandHandler,"decreaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canDecreaseZoom(t){t===void 0&&(t=1/this.zoomFactor),Util.r(t,CommandHandler,"canDecreaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}increaseZoom(t){t===void 0&&(t=this.zoomFactor),Util.r(t,CommandHandler,"increaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canIncreaseZoom(t){t===void 0&&(t=this.zoomFactor),Util.r(t,CommandHandler,"canIncreaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}resetZoom(t){t===void 0&&(t=this.defaultScale),Util.r(t,CommandHandler,"resetZoom:newscale");const i=this.diagram;ti.maxScale||(i.scale=t)}canResetZoom(t){t===void 0&&(t=this.defaultScale),Util.r(t,CommandHandler,"canResetZoom:newscale");const i=this.diagram;return ti.maxScale?!1:i.allowZoom}zoomToFit(){const t=this.diagram,i=t.animationManager;i.stopAnimation(),t.redraw();const e=t.position,s=t.scale;i.El("Zoom To Fit"),this.isZoomToFitRestoreEnabled&&s===this.Y1&&!isNaN(this.X1)&&t.documentBounds.equals(this.K1)?(t.scale=this.X1,t.position=this.h2,this.Y1=NaN,this.K1=Rect.kw):(this.X1=s,this.h2=e.copy(),t.zoomToFit(),this.Y1=t.scale,this.K1=t.documentBounds.copy()),i.FM()}canZoomToFit(){return this.diagram.allowZoom}scrollToPart(t){t===void 0&&(t=null),t!==null&&Util.s(t,Part,CommandHandler,"part");const i=this.diagram;if(i.ensureBounds(),t===null){try{this.Uo!==null&&(this.Uo.next()?t=this.Uo.value:this.Uo=null)}catch{this.Uo=null}t===null&&(i.highlighteds.count>0?this.Uo=i.highlighteds.iterator:i.selection.count>0&&(this.Uo=i.selection.iterator),this.Uo!==null&&this.Uo.next()&&(t=this.Uo.value))}if(t!==null){const e=i.animationManager;e.El("Scroll To Part");const s=this.scrollToPartPause;if(s>0){const n=this._f(t,[t]);if(n.length===1)i.startTransaction(),i.centerRect(t.actualBounds),i.commitTransaction("Scroll To Part");else{const o=()=>{i.startTransaction();let l=n.pop();for(;n.length>0&&l instanceof Node&&l.isTreeExpanded&&(!(l instanceof Group)||l.isSubGraphExpanded);)l=n.pop();n.length>0?(l instanceof Part&&i.scrollToRect(l.actualBounds),l instanceof Node&&!l.isTreeExpanded&&(l.isTreeExpanded=!0),l instanceof Group&&!l.isSubGraphExpanded&&(l.isSubGraphExpanded=!0)):(l instanceof Part&&i.centerRect(l.actualBounds),i.removeDiagramListener("LayoutCompleted",r)),i.commitTransaction("Scroll To Part")},r=()=>{Util.Bh(o,(e.isEnabled?e.duration:0)+s)};i.addDiagramListener("LayoutCompleted",r),o()}}else{const n=i.position.copy();i.centerRect(t.actualBounds),n.equalsApprox(i.position)&&e.stopAnimation()}}}_f(t,i){if(t.isVisible())return i;if(t instanceof Adornment)this._f(t.adornedPart,i);else if(t instanceof Link){const e=t.fromNode;e!==null&&this._f(e,i);const s=t.toNode;s!==null&&this._f(s,i)}else{if(t instanceof Node){const s=t.labeledLink;s!==null&&this._f(s,i);const n=t.findTreeParentNode();n!==null&&(!n.isTreeExpanded&&!n.wasTreeExpanded&&i.push(n),this._f(n,i))}const e=t.containingGroup;e!==null&&(!e.isSubGraphExpanded&&!e.wasSubGraphExpanded&&i.push(e),this._f(e,i))}return i}canScrollToPart(t){if(t===void 0&&(t=null),t!==null&&!(t instanceof Part))return!1;const i=this.diagram;return i.selection.count===0&&i.highlighteds.count===0?!1:i.allowHorizontalScroll&&i.allowVerticalScroll}collapseTree(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse Tree";try{i.startTransaction(e),i.animationManager.El(e);const n=new List;if(t!==null&&t.isTreeExpanded)t.collapseTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&r.isTreeExpanded&&(r.collapseTree(),n.add(r))}}i.V("TreeCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||!t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(!s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}expandTree(t){t===void 0&&(t=null);const i=this.diagram,e="Expand Tree";try{i.startTransaction(e),i.animationManager.El(e);const n=new List;if(t!==null&&!t.isTreeExpanded)t.expandTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&(r.isTreeExpanded||(r.expandTree(),n.add(r)))}}i.V("TreeExpanded",n)}finally{i.commitTransaction(e)}}canExpandTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}groupSelection(){const t=this.diagram,i=t.model;if(!i.da())return;const e=this.archetypeGroupData;if(e===null)return;let s=null;try{t.currentCursor="wait",t.V("ChangingSelection",t.selection),t.startTransaction("Group");const n=new List,o=t.selection.iterator;for(;o.next();){const h=o.value;h.Ae()&&h.canGroup()&&n.add(h)}const r=new List,l=n.iterator;for(;l.next();){const h=l.value;let a=!1;const f=n.iterator;for(;f.next();){const c=f.value;if(h.isMemberOf(c)){a=!0;break}}a||r.add(h)}if(r.count>0){let h=r.first().containingGroup;if(h!==null)for(;h!==null;){let a=!1;const f=r.iterator;for(;f.next();)if(!f.value.isMemberOf(h)){a=!0;break}if(a)h=h.containingGroup;else break}if(e instanceof Group)e.ci(),s=e.copy(),s!==null&&t.add(s);else if(i.isGroupForData(e)){const a=i.copyNodeData(e);Util.Mt(a)&&(i.addNodeData(a),s=t.findNodeForData(a))}if(s!==null){h!==null&&this.isValidMember(h,s)&&(s.containingGroup=h);const a=r.iterator;for(;a.next();){const f=a.value;this.isValidMember(s,f)&&(f.containingGroup=s)}t.clearSelection(!0),s.isSelected=!0}}t.V("SelectionGrouped",s)}finally{t.commitTransaction("Group"),t.V("ChangedSelection",t.selection),t.currentCursor=""}}canGroupSelection(){const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowGroup||!t.model.da()||this.archetypeGroupData===null)return!1;const e=t.selection.iterator;for(;e.next();){const s=e.value;if(s.Ae()&&s.canGroup())return!0}return!1}c2(t){const i=Util.ft();if(Array.isArray(t))t.forEach(n=>{n instanceof Link||n instanceof Part&&i.push(n)});else{const n=t.iterator;for(;n.next();){const o=n.value;o instanceof Link||o instanceof Part&&i.push(o)}}const e=new GSet,s=i.length;for(let n=0;n0){i.clearSelection(!0);const o=s.iterator;for(;o.next();){const r=o.value;r.expandSubGraph();const l=r.containingGroup,h=l!==null&&l.data!==null?e.getKeyForNodeData(l.data):void 0;n.addAll(r.memberParts);const a=n.iterator;for(;a.next();){const f=a.value;if(f.isSelected=!0,f instanceof Link)continue;const c=f.data;c!==null?e.setGroupForData(c,h):f.containingGroup=l}i.remove(r)}}i.V("SelectionUngrouped",s,n)}finally{i.commitTransaction("Ungroup"),i.V("ChangedSelection",i.selection),i.currentCursor=""}}canUngroupSelection(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowDelete||!i.allowUngroup||!i.model.da())return!1;if(t!==null){if(!(t instanceof Group))return!1;if(t.canUngroup())return!0}else{const s=i.selection.iterator;for(;s.next();){const n=s.value;if(n instanceof Group&&n.canUngroup())return!0}}return!1}addTopLevelParts(t,i){const e=this.c2(t);let s=!0;const n=e.iterator;for(;n.next();){const o=n.value;o.containingGroup!==null&&(!i||this.isValidMember(null,o)?o.containingGroup=null:s=!1)}return s}collapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse SubGraph";try{i.startTransaction(e),i.animationManager.El(e);const n=new List;if(t!==null&&t.isSubGraphExpanded)t.collapseSubGraph(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&r.isSubGraphExpanded&&(r.collapseSubGraph(),n.add(r))}}i.V("SubGraphCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||!t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&s.isSubGraphExpanded)return!0}}return!1}expandSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Expand SubGraph",s=new List;try{if(i.startTransaction(e),i.animationManager.El(e),t!==null&&!t.isSubGraphExpanded)t.expandSubGraph(),s.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&(r.isSubGraphExpanded||(r.expandSubGraph(),s.add(r)))}}i.V("SubGraphExpanded",s)}finally{for(const n of s)this.nL(i,n);t&&this.nL(i,t),i.commitTransaction(e)}}nL(t,i){for(const e of i.memberParts)e instanceof Node&&t.If(e,i)}canExpandSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&!s.isSubGraphExpanded)return!0}}return!1}editTextBlock(t){t===void 0&&(t=null),t!==null&&Util.s(t,TextBlock,CommandHandler,"editTextBlock");const i=this.diagram,e=i.toolManager.findTool("TextEditing");if(e!==null){if(t===null){let s=null;const n=i.selection.iterator;for(;n.next();){const o=n.value;if(o.canEdit()){s=o;break}}if(s===null)return;t=s.findInVisualTree(o=>o instanceof TextBlock&&o.editable)}t!==null&&(i.currentTool=null,e.textBlock=t,i.currentTool=e)}}canEditTextBlock(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowTextEdit||i.toolManager.findTool("TextEditing")===null)return!1;if(t!==null){if(!(t instanceof TextBlock))return!1;const e=t.part;if(e!==null&&e.canEdit())return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s.canEdit()&&(t=s.findInVisualTree(n=>n instanceof TextBlock&&n.editable),t!==null))return!0}}return!1}showContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");if(e===null)return;t===void 0&&(i.selection.count>0?t=i.selection.first():t=i);const s=e.findObjectWithContextMenu(t);if(s!==null){const n=i.lastInput;let o=null;if(s instanceof GraphObject)o=s.getDocumentPoint(Spot.Center);else if(!i.viewportBounds.containsPoint(n.documentPoint)){const r=i.viewportBounds;o=new Point(r.x+r.width/2,r.y+r.height/2)}if(o!==null){const r=new InputEvent;r.diagram=i,r.viewPoint=i.transformDocToView(o),r.documentPoint=o,r.button=2,r.up=!0,i.lastInput=r}i.currentTool=e,e.openMenu(!1,s)}}canShowContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");return!(e===null||(t===void 0&&(i.selection.count>0?t=i.selection.first():t=i),e.findObjectWithContextMenu(t)===null))}get copiesClipboardData(){return this.$P}set copiesClipboardData(t){Util.t(t,"boolean",CommandHandler,"copiesClipboardData"),this.$P=t}get copiesConnectedLinks(){return this.QP}set copiesConnectedLinks(t){Util.t(t,"boolean",CommandHandler,"copiesConnectedLinks"),this.QP=t}get deletesConnectedLinks(){return this._P}set deletesConnectedLinks(t){Util.t(t,"boolean",CommandHandler,"deletesConnectedLinks"),this._P=t}get copiesTree(){return this.t2}set copiesTree(t){Util.t(t,"boolean",CommandHandler,"copiesTree"),this.t2=t}get deletesTree(){return this.i2}set deletesTree(t){Util.t(t,"boolean",CommandHandler,"deletesTree"),this.i2=t}get copiesParentKey(){return this.e2}set copiesParentKey(t){Util.t(t,"boolean",CommandHandler,"copiesParentKey"),this.e2=t}get copiesGroupKey(){return this.s2}set copiesGroupKey(t){Util.t(t,"boolean",CommandHandler,"copiesGroupKey"),this.s2=t}get archetypeGroupData(){return this.o2}set archetypeGroupData(t){t!==null&&Util.t(t,"object",CommandHandler,"archetypeGroupData");const i=this.diagram;if(Debug){const e=i.model;e.da()&&!(t instanceof Group)&&!e.isGroupForData(t)&&Util.n("CommandHandler.archetypeGroupData must be either a Group or a data object for which GraphLinksModel.isGroupForNodeData is true: "+t)}this.o2=t}get memberValidation(){return this.rh}set memberValidation(t){t!==null&&Util.t(t,"function",CommandHandler,"memberValidation"),this.rh=t}get defaultScale(){return this.diagram.defaultScale}set defaultScale(t){this.diagram.defaultScale=t}get zoomFactor(){return this.l2}set zoomFactor(t){Util.r(t,CommandHandler,"zoomFactor"),t>1||Util.n("zoomFactor must be larger than 1.0, not: "+t),this.l2=t}get isZoomToFitRestoreEnabled(){return this.a2}set isZoomToFitRestoreEnabled(t){Util.t(t,"boolean",CommandHandler,"isZoomToFitRestoreEnabled"),this.a2=t}get scrollToPartPause(){return this.f2}set scrollToPartPause(t){Util.r(t,CommandHandler,"scrollToPartPause"),this.f2=t}computeEffectiveCollection(t,i){const e=this.diagram,s=e.toolManager.findTool("Dragging"),n=e.currentTool===s;i===void 0&&(i=e.y0());const o=new GMap;if(t===null)return o;let r=t.iterator;for(;r.next();){const l=r.value;e._r(o,l,n,i)}if(e.draggedLink!==null&&i.dragsLink)return o;for(r=t.iterator;r.next();){const l=r.value;if(l instanceof Link){const h=l.fromNode;if(h!==null&&!o.has(h))o.delete(l);else{const a=l.toNode;a!==null&&!o.has(a)&&o.delete(l)}}}return o}}var Stretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Vertical=4]="Vertical",w[w.Horizontal=5]="Horizontal",w[w.Fill=2]="Fill",w))(Stretch||{}),Orientation=(w=>(w[w.None=0]="None",w[w.Along=21]="Along",w[w.Plus90=22]="Plus90",w[w.Minus90=23]="Minus90",w[w.Opposite=24]="Opposite",w[w.Upright=25]="Upright",w[w.Plus90Upright=26]="Plus90Upright",w[w.Minus90Upright=27]="Minus90Upright",w[w.Upright45=28]="Upright45",w))(Orientation||{}),Flip=(w=>(w[w.None=0]="None",w[w.Vertical=1]="Vertical",w[w.Horizontal=2]="Horizontal",w[w.Both=3]="Both",w))(Flip||{});class GraphObject{l;td;ed;Go;g;hh;Z;mt;le;_t;sd;Hs;Ft;qe;il;ah;Pi;ga;lt;jt;el;Fi;Hi;nd;ai;tc;Ut;hi;sl;u2;od;constructor(){GSet.vi(this),this.l=30723,this._t=1,this.sd="",this.Hs=null,this.Ft=null,this.mt=new Point(NaN,NaN).w(),this.qe=Size.xw,this.il=new Transform,this.ah=new Transform,this.Pi=null,this.ga=1,this.lt=1,this.jt=0,this.el=Margin.qg,this.le=new Rect(NaN,NaN,NaN,NaN).w(),this.Fi=new Rect(NaN,NaN,NaN,NaN).w(),this.Hi=new Rect(0,0,NaN,NaN).w(),this.nd=null,this.td=null,this.Z=null,this.ai=Spot.Default,this.tc=Spot.Default,this.ed=0,this.Go=0,this.Ut=null,this.g=null,this.hh=null,this.hi=null,this.u2=null,this.sl=null,this.od=null}cloneProtected(t){t.l=(this.l|2048|4096)&-32769,t._t=this._t,t.sd=this.sd,t.Ft=this.Ft,t.mt.c(this.mt),t.qe=this.qe.L(),this.Pi!==null?t.Pi=this.Pi.copy():t.Pi=null,t.lt=this.lt,t.jt=this.jt,t.el=this.el.L(),t.le.c(this.le),t.Fi.c(this.Fi),t.Hi.c(this.Hi),t.td=this.td,this.Z!==null&&(t.Z=this.Z.copy()),t.ai=this.ai.L(),t.tc=this.tc.L(),t.ed=this.ed,t.Go=this.Go,this.Ut!==null&&(t.Ut=this.Ut.copy()),this.g!==null&&(this.g.wi?t.g=this.g:t.g=this.g.copy()),this.hh!==null&&(t.hh=this.hh.slice()),this.hi!==null&&(t.hi=this.hi.copy())}addCopyProperty(t){let i=this.hh;if(!Array.isArray(i))i=[],this.hh=i;else for(let e=0;e{d.data!==null&&d.d2()&&d.updateTargetBindings(i)})}}}}MF(t){this.od.delete(t)}Yo(){if(this.diagram===null)return;if(this.findBindingPanel()===null&&this.Ri!==null){const i=this.Ri.iterator;for(;i.next();){const e=i.value;if(!e.isToTheme)continue;let s=null;const n=e.sourceName;e.isToObject&&(s=this.oL(n));let o=this;const r=e.targetId;r!==-1&&(o=this.M0(r),o===null)||(n==="/"?s=o.part:n==="."?s=o:n===".."&&(s=o.panel),e.updateTarget(o,s))}}}ka(t,i){const e=this.findBindingPanel();if(e!==null){const s=this.Ri.iterator;for(;s.next();){const n=s.value;let o=null;if(n.isToObject){if(o=n.rL(e,this),o===null)continue;n.updateSource(this,o,i,null)}else if(n.isToModel){const r=t.diagram;r!==null&&!r.me&&n.updateSource(this,r.model.modelData,i,e)}else if(!n.isToTheme){const r=e.data;if(r===null)continue;const l=t.diagram;l!==null&&!l.me&&n.updateSource(this,r,i,e)}if(o===this){const r=n.targetId,l=e.M0(r);l!==null&&n.updateTarget(l,o,i)}}}}M0(t){return this.eo===t?this:null}oL(t){let i;return t===""?i=this:t==="/"?i=this:t==="."?i=this:t===".."?i=this:(i=this.part.findObject(t),i===null&&Debug&&Util.at("Binding error: missing GraphObject named "+t+" in "+this.part.toString())),i}get eo(){return this.g!==null?this.g.eo:-1}set eo(t){this.eo!==t&&(this.g===null&&(this.g=new GraphObjectTemplateSettings),this.g.eo=t)}get Ri(){return this.g!==null?this.g.Ri:null}set Ri(t){this.Ri!==t&&(this.g===null&&(this.g=new GraphObjectTemplateSettings),this.g.Ri=t)}get so(){return this.g!==null?this.g.so:null}set so(t){this.so!==t&&(this.g===null&&(this.g=new GraphObjectTemplateSettings),this.g.so=t)}raiseChanged(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}i(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}no(t,i,e,s){const n=this.le;if(n.e(t,i,e,s),this.lt!==1||this.jt!==0){this.Pi===null&&(this.Pi=new Transform);const o=this.Pi;o.Bi(),this.P0(o,t,i,e,s),o.Cw(n)}}lL(t,i,e){return this.pickable===!1?!1:(e.hf(this.O),i?this.intersectsRect(t,e):this.containedInRect(t,e))}hL(t,i,e){if(this.pickable===!1)return!1;const s=this.naturalBounds,n=t.distanceSquaredPoint(i);return e?Point.distanceLineSegmentSquared(t.x,t.y,0,0,0,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,0,s.height,s.width,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,s.height,s.width,0)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,0,0,0)<=n:t.distanceSquared(0,0)<=n&&t.distanceSquared(0,s.height)<=n&&t.distanceSquared(s.width,0)<=n&&t.distanceSquared(s.width,s.height)<=n}kn(){return!0}containsPoint(t){Debug&&Util.s(t,Point,GraphObject,"containsPoint:p");const i=Point.a();i.c(t),this.O.Pt(i);const e=this.actualBounds;if(!e.isReal())return Point.o(i),!1;const s=this.diagram;if(s!==null&&s.r0){const o=s.getInputOption("extraTouchThreshold"),r=s.getInputOption("extraTouchArea"),l=r/2,h=this.naturalBounds,a=this.getDocumentScale()*s.scale,f=1/a;if(h.width*ae&&(c=t),isFinite(i)&&i>s&&(u=i);break;case 5:isFinite(t)&&t>e&&(c=t),u=0,d&&(i=1/0);break;case 4:isFinite(i)&&i>s&&(u=i),c=0,d&&(t=1/0);break}const g=this.maxSize,p=this.minSize;c>g.width&&p.widthg.height&&p.heightu.height||this.xi>u.width)&&(r=!0)}}}r?this.l|=256:this.l&=-257,this.Fi.isReal()||Util.n("Non-real actualBounds has been set. Object "+this+", actualBounds: "+this.Fi.toString()),this.ad(o,this.Fi),this.oo(!1),Rect.o(o)}uh(t,i,e,s){}commonArrange(t,i,e,s){if(this.Fi.e(t,i,e,s),this.desiredSize.isReal())return;const n=this.le,o=this.el,r=o.right+o.left,l=o.top+o.bottom,h=n.width+r,a=n.height+l;e+=r,s+=l;let f=this.qs(!0);switch(h===e&&a===s&&(f=0),f){case 0:(h>e||a>s)&&(this.pe(!0),this.wt(h>e?e:h,a>s?s:a,0,0));break;case 2:this.pe(!0),this.wt(e,s,0,0);break;case 5:this.pe(!0),this.wt(e,a,0,0);break;case 4:this.pe(!0),this.wt(h,s,0,0);break}}ad(t,i){const e=this.part;e!==null&&e.diagram!==null&&((e.selectionObject===this||e.resizeObject===this||e.rotateObject===this)&&e.g2(!0),this.T(),!t.equalsApproxClose(i)&&(e.dh(),this.A0(e)))}A0(t){this.portId!==null&&(t.g2(!0),t instanceof Node&&t.aL(this))}get shadowVisible(){return this.g!==null?this.g.L0:null}set shadowVisible(t){const i=this.shadowVisible;i!==t&&(Debug&&t!==null&&Util.t(t,"boolean",GraphObject,"shadowVisible"),this.Zt(),this.g.L0=t,this.hs(!0),this.T(),this.i("shadowVisible",i,t))}RR(t,i){const e=this.naturalBounds,s=this.ah,n=s.m11,o=s.m21,r=s.dx,l=s.m12,h=s.m22,a=s.dy;let f=0,c=0,u=f,d=c;f=u*n+d*o+r,c=u*l+d*h+a;let m=f,g=c,p=0,y=0;u=e.width+i,d=0,f=u*n+d*o+r,c=u*l+d*h+a;let x=Math.min(m,f),k=Math.min(g,c);p=Math.max(m+p,f)-x,y=Math.max(g+y,c)-k,m=x,g=k,u=e.width+i,d=e.height+i,f=u*n+d*o+r,c=u*l+d*h+a,x=Math.min(m,f),k=Math.min(g,c),p=Math.max(m+p,f)-x,y=Math.max(g+y,c)-k,m=x,g=k,u=0,d=e.height+i,f=u*n+d*o+r,c=u*l+d*h+a,x=Math.min(m,f),k=Math.min(g,c),p=Math.max(m+p,f)-x,y=Math.max(g+y,c)-k,m=x,g=k;const b=t.viewportBounds,S=b.x,M=b.y,A=b.width,C=b.height;return m>A+S||S>p+m||g>C+M||M>y+g}Ji(t,i){if(this.IR(t,i)||!this.visible)return;const e=this.opacity;if(e===0)return;let s=1;e!==1&&(s=t.globalAlpha,t.globalAlpha=s*e);let n="";this.filter!==""&&(n=t.filter,t.filter=this.filter);const o=this.O,r=this.panel;this.N0()===!0&&this.G1();const l=this.part;let h=!1,a=0;if(l&&i.getRenderingHint("drawShadows")&&(h=l.isShadowed,h)){const g=l.shadowOffset;a=Math.max(g.y,g.x)*i.scale*i.Gi}const f=this instanceof Panel&&this.nl(),c=this.Fi;if(f&&(this.fL(h,t,!1,r),this.OR(t,i),this.cL(h,t,!1,r),this.uL(h,t,!1)),f||!f&&(c.width===0||c.height===0||isNaN(c.x)||isNaN(c.y))){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}const u=this.js();if(!i.ia&&u&&this.RR(i,a)){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}let d=(this.l&256)!==0;if(t.clipInsteadOfFill&&(d=!1),this instanceof TextBlock&&(t.font=this.font),d){const g=r.kn()?r.naturalBounds:r.actualBounds;let p=Math.max(c.x,g.x),y=Math.max(c.y,g.y),x=Math.min(c.right,g.right)-p,k=Math.min(c.bottom,g.bottom)-y;const b=this.hi;if(b!==null&&(p=b.x,y=b.y,x=b.width,k=b.height),p>c.width+c.x||c.x>g.width+g.x){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}t.save(),t.beginPath(),t.rect(p,y,x,k),t.clip()}if(u){if(!l.isVisible()){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}if(h){const g=l.shadowOffset;t.shadowsSet(g.x*i.scale*this.scale*i.Gi,g.y*i.scale*this.scale*i.Gi,l.shadowBlur),t.shadowsOn(),t.shadowColor=l.shadowColor}}const m=this.naturalBounds;if(t.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.fL(h,t,u,r),this.Ft!==null&&(t.commitTransform(),this.H1(t,m,c)),this.cL(h,t,u,r),this.gh(t,i),this.uL(h,t,u),d&&(t.restore(),t.clearContextCache(this instanceof Panel)),!o.Gk()){const g=1/(o.m11*o.m22-o.m12*o.m21);t.transform(o.m22*g,-o.m12*g,-o.m21*g,o.m11*g,g*(o.m21*o.dy-o.m22*o.dx),g*(o.m12*o.dx-o.m11*o.dy))}e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n)}fL(t,i,e,s){t&&this.shadowVisible===!0?i.shadowsOn():t&&this.shadowVisible===!1&&i.shadowsOff(),t&&this.q1(s)&&this.shadowVisible===null&&i.shadowsOff()}cL(t,i,e,s){t&&(this.Ft!==null||this.q1(s))?(this.j1(!0),this.shadowVisible===null&&i.shadowsOff()):this.j1(!1)}uL(t,i,e){t&&this.m2()===!0&&i.shadowsOn(),e&&t&&i.shadowsOff()}ER(t,i,e){const s=this.part;let n=!1;s&&t.getRenderingHint("drawShadows")&&(n=s.isShadowed),i.clipInsteadOfFill&&(n=!1),this.js()&&n&&i.shadowsOn(),n&&this.shadowVisible===!0?i.shadowsOn():n&&this.shadowVisible===!1&&i.shadowsOff();const o=this.panel;if(n&&this.q1(o)&&this.shadowVisible===null&&i.shadowsOff(),i.ol){const r=t.computePixelRatio(),l=`drop-shadow(${i.shadowOffsetX/r}px ${i.shadowOffsetY/r}px ${i.shadowBlur/r/2}px ${i.shadowColor})`;this.background!==null&&e.Ft.setAttributeNS(null,"filter",l)}return n&&(this.Ft!==null||this.q1(o))?(this.j1(!0),this.shadowVisible===null&&i.shadowsOff()):this.j1(!1),n}VR(t,i,e,s){if(e.ol){const n=i.computePixelRatio(),o=`drop-shadow(${e.shadowOffsetX/n}px ${e.shadowOffsetY/n}px ${e.shadowBlur/n/2}px ${e.shadowColor})`;this.p2(t,o)}s&&this.m2()===!0&&e.shadowsOn(),this.js()&&e.shadowsOff()}q1(t){return t===null?!1:(t.nl()&&(t=t.panel),t.m2()||(t.type===Panel.Auto||t.type===Panel.Spot)&&t.findMainElement()!==this)}p2(t,i){}H1(t,i,e){const s=this.U1(),n=i.x,o=i.y,r=i.width+s,l=i.height+s;this.wn(t,this.Ft,!0,!1,i,e),this.Ft instanceof Brush&&this.Ft.type===3?(t.beginPath(),t.rect(n-s/2,o-s/2,r,l),t.fillContext(this.Ft,!1,null)):t.fillRect(n-s/2,o-s/2,r,l)}dL(t,i){let e=t.BR(this);if(e!==-1)if(e===0)if(t.svg.Ft)t.svg.Ft.after(i);else if(t.type===Panel.Table){const s=t.svg.getElementsByClassName("gojs-ts"),n=s.length!==0?s[0]:null;n!==null&&n.after(i)}else t.svg.prepend(i);else{for(;e!==0&&!t.elt(e-1).isVisibleObject();)e--;if(e===0)t.svg.prepend(i);else{const s=t.elt(e-1).svg;s!==null?s.after(i):t.svg.appendChild(i)}}}IR(t,i){if(!(t instanceof SVGContext))return!1;if(!this.visible||this.opacity===0)return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;if(this.js()&&!this.isVisible())return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;const e=this.panel,s=this.fd(t);if(this.nc(t,i,s))return this.gL(this.svg),this.svg.parentElement!==null?(this.js()&&(t.lastDrawnPart=this.svg),!0):(this.js()?(t.lastDrawnPart!==null?t.lastDrawnPart.after(this.svg):t.diagramGroup.prepend(this.svg),t.lastDrawnPart=this.svg):e&&this.dL(e,this.svg),!0);if(this.js()&&this.isShadowed){const m=this.shadowOffset;t.shadowsSet(m.x*i.scale*this.scale*i.Gi,m.y*i.scale*this.scale*i.Gi,this.shadowBlur),t.shadowsOn(),t.shadowColor=this.shadowColor}this instanceof TextBlock&&(t.font=this.font),t.currentElement=null;const n=this.O,o=this instanceof Panel,r=this instanceof Panel?this.nl():!1,l=this.svg;this.N0()===!0&&this.G1();const h=this.Fi;t.setCurrentTransform(1,0,0,1,0,0),t.outerGroup=!1,s&&(t.outerGroup=!0,o&&r?(t.newGroup(1,0,0,1,0,0),this.svg=t.lastCreatedElement):o?(t.newGroup(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.svg=t.lastCreatedElement):t.newGroup(1,0,0,1,0,0));const a=this.naturalBounds;o||t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.background!==null&&(o?(r&&t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.H1(t,a,h),r&&t.setCurrentTransform(1,0,0,1,0,0)):(t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.H1(t,a,h)),t.currentElement.Ft=t.lastCreatedElement,t.currentElement.prepend(t.lastCreatedElement));const f=this.ER(i,t,t.currentElement);this.gh(t,i),o&&t.endGroup(),t.outerGroup&&t.endGroup();const c=t.surface.Qu,u=o?this.svg:t.currentElement;if(!o&&l!==null&&u!==l&&l.parentNode===this.panel.svg){const m=this.svg.getAttribute("filter");return m!==null&&u.setAttribute("filter",m),this.svg.replaceWith(u),this.svg=u,u!==null&&this.T0(t,e,h,u),this.mL(t,l),!0}if(this.svg=u,c!==null&&u===null&&t.dummyGroup(),u===null)return!0;this.T0(t,e,h,u),this.VR(u,i,t,f);const d=this.js()?this.opacity*t.globalAlpha:this.opacity;if(d!==1&&u.setAttributeNS(null,"opacity",d.toString()),this.filter!==""&&u.setAttributeNS(null,"filter",this.filter),this.js()){if(l!==null&&u!==l&&l.parentNode===t.diagramGroup){const m=l.getAttribute("filter");m!==null&&u.setAttribute("filter",m),l.replaceWith(u)}else t.lastDrawnPart?t.lastDrawnPart.after(u):t.diagramGroup.prepend(u);t.lastDrawnPart=u}else e!==null&&this.dL(e,u);return c!==null&&c(this,u),this.gL(u),!0}gL(t){const i=this,e=t.dataset;i instanceof GraphObject&&(i.portId!==null&&(e.portId=i.portId),i instanceof Panel&&(isNaN(i.itemIndex)||(e.itemIndex=i.itemIndex.toString()),i instanceof Part&&(e.className=Util.hn(i),i.key!==void 0&&(e.key=i.key.toString()),i.containingGroup!==null&&(e.group=i.containingGroup.key.toString()),i instanceof Link&&(i.fromNode!==null&&i.fromNode.key!==void 0&&(e.fromKey=i.fromNode.key.toString()),i.fromPortId!==""&&(e.fromPortId=i.fromPortId),i.toNode!==null&&i.toNode.key!==void 0&&(e.toKey=i.toNode.key.toString()),i.toPortId!==""&&(e.toPortId=i.toPortId)))))}T0(t,i,e,s){let n=(this.l&256)!==0;if(t.clipInsteadOfFill&&(n=!1),!n){s.removeAttributeNS(null,"clip-path"),this.mL(t,s);return}const o=i.kn()?i.naturalBounds:i.actualBounds;let r=Math.max(e.x,o.x),l=Math.max(e.y,o.y),h=Math.min(e.right,o.right)-r,a=Math.min(e.bottom,o.bottom)-l;const f=this.hi;f!==null&&(r=f.x,l=f.y,h=f.width,a=f.height);const c=s.getAttribute("clip-path");let u=null;if(c!==null&&(u=t.svg.getElementById(c.split("#")[1].slice(0,-1))),u===null){const d="CLIP"+GSet.cu++,m={id:d},g=t.makeElement("clipPath",m),p=t.makeElement("rect",{x:r,y:l,width:h,height:a});if(this instanceof Panel){const y=this.O.copy().Pw();p.setAttribute("transform",`matrix(${y.m11}, ${y.m12}, ${y.m21}, ${y.m22}, ${y.dx}, ${y.dy})`)}g.appendChild(p),t.svg.appendChild(g),s.setAttributeNS(null,"clip-path","url(#"+d+")")}else{const d=u.firstElementChild;d.setAttribute("x",r.toString()),d.setAttribute("y",l.toString()),d.setAttribute("width",h.toString()),d.setAttribute("height",a.toString())}}mL(t,i){const e=i.getAttribute("clip-path");if(e===null)return;const s=t.svg.getElementById(e.split("#")[1].slice(0,-1));s!==null&&s.remove()}zR(){if(this.svg===null)return;const t=this.svg.innerHTML.match(/url\(#((CLIP|GRAD).+?)\)/g),i=this.svg.ownerDocument;if(t!==null)for(const e of t){const s=i.getElementById(e.split("#")[1].slice(0,-1));s!==null&&s.remove()}this.svg.remove()}OR(t,i){const e=this.Fi,s=this.Hi,n=this.Ft;n!==null&&t.commitTransform(),n!==null&&(this.wn(t,n,!0,!1,s,e),n instanceof Brush&&n.type===3?(t.beginPath(),t.rect(e.x,e.y,e.width,e.height),t.fillContext(n,!1,null)):t.fillRect(e.x,e.y,e.width,e.height)),this.gh(t,i)}gh(t,i){}w2(){this.hs(!0)}nc(t,i,e){const s=this.svg;if(this.XR()){if(this.w2(),this.hs(!1),s===null)return!1;const a=this.svg.getAttribute("clip-path");if(a!==null){const f=t.svg.getElementById(a.split("#")[1].slice(0,-1));f!==null&&f.remove()}return!1}if(s===null)return!1;if(!this.visible)return s.remove(),!1;if(s.nodeName!=="g"&&e||s.nodeName==="g"&&!e)return!1;const n=this.O,o="matrix("+n.m11+", "+n.m12+", "+n.m21+", "+n.m22+", "+n.dx+", "+n.dy+")",r=this instanceof Panel,l=this instanceof Panel?this.nl():!1;if(!(r&&l))if(this instanceof Picture){const a=this.W1;t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),a!==null&&t.amendImageTransform(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]),e?s.lastElementChild.setAttributeNS(null,"transform",t.getCurrentTransform()):s.setAttributeNS(null,"transform",t.getCurrentTransform())}else if(e&&!(this instanceof Panel))if(this instanceof Shape){const a=s.getElementsByTagName("path");for(let f=0;f=.1;){if(g){for(l=o[d++%h],l-=r;l<0;)l+=o[d++%h],m=!m;g=!1}else l=o[d++%h];l>u&&(l=u);let p=Math.sqrt(l*l/(1+c*c));a<0&&(p=-p),i+=p,e+=c*p,m?t.lineTo(i,e):t.moveTo(i,e),u-=l,m=!m}}wn(t,i,e,s,n,o){let r=1,l=1;if(typeof i=="string"){e?t.fillStyle=i:t.strokeStyle=i;return}else if(i.type===1){e?t.fillStyle=i.color:t.strokeStyle=i.color;return}let h;const a=this.U1();r=n.width,l=n.height,s?(r=o.width,l=o.height):e||(r+=a,l+=a);const f=t instanceof CanvasSurfaceContext;if(f&&i.Sn&&(i.type===4||i.oc===r&&i.v1===l))h=i.Sn;else{let c=0,u=0,d=0,m=0,g=0,p=0,y=0,x=0;if(s?(y=o.x,x=o.y):e||(y-=a/2,x-=a/2),c=i.start.x*r+i.start.offsetX+y,u=i.start.y*l+i.start.offsetY+x,d=i.end.x*r+i.end.offsetX+y,m=i.end.y*l+i.end.offsetY+x,i.type===2)h=t.createLinearGradient(c,u,d,m);else if(i.type===3)p=isNaN(i.endRadius)?Math.max(r,l)/2:i.endRadius,isNaN(i.startRadius)?(g=0,p=Math.max(r,l)/2):g=i.startRadius,h=t.createRadialGradient(c,u,g,d,m,p);else if(i.type===4)try{h=t.createPattern(i.pattern,"repeat")}catch{h=null}else Util.Vi(i.type,"Brush type");if(i.type!==4){const k=i.colorStops;if(k!==null){const b=k.iterator;for(;b.next();)h.addColorStop(b.key,b.value)}}if(f&&(i.Sn=h,h!==null&&(i.oc=r,i.v1=l),h===null&&i.type===4&&i.oc!==-1)){i.oc=-1;const k=this.diagram;k!==null&&i.oc===-1&&Util.Bh(()=>{k.redraw()},600)}}e?t.fillStyle=h:t.strokeStyle=h}isContainedBy(t){return t instanceof Panel?this.YR(this,t):!1}YR(t,i){if(t===i||i===null)return!1;let e=t.panel;for(;e!==null;){if(e===i)return!0;e=e.panel}return!1}isVisibleObject(){if(!this.visible)return!1;const t=this.panel;return t!==null?t.isVisibleObject():!0}isEnabledObject(){let t=this instanceof Panel?this:this.panel;for(;t!==null&&t.isEnabled;)t=t.panel;return t===null}get enabledChanged(){return this.g!==null?this.g.D0:null}set enabledChanged(t){const i=this.enabledChanged;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"enabledChanged"),this.Zt(),this.g.D0=t,this.i("enabledChanged",i,t))}G1(){if(this.J1()===!0){const t=this.il;if(t.Bi(),!this.Fi.isReal()||!this.le.isReal()){this.cd(!1);return}if(t.Es(this.Fi.x-this.le.x,this.Fi.y-this.le.y),this.scale!==1||this.angle!==0){const i=this.naturalBounds;this.P0(t,i.x,i.y,i.width,i.height)}this.cd(!1),this.Sa(!0)}if(this.N0()===!0){const t=this.panel;if(t===null)this.ah.set(this.il),this.ga=this.scale;else if(t.Ks!==null){const i=this.ah;i.Bi(),t.kn()?i.hf(t.ah):t.panel!==null&&i.hf(t.panel.ah),i.hf(this.il),this.ga=this.scale*t.ga}this.Sa(!1)}}P0(t,i,e,s,n){if(this.lt!==1&&t.lt(this.lt),this.jt===0)return;const o=Point.a();o.setSpot(i,e,s,n,Spot.Center),t.ms(this.jt,o.x,o.y),Point.o(o)}u(t){if(this.Xo())return;t===void 0&&(t=!1),this.pe(!0),this.oo(!0);const i=this.panel;i!==null&&!t&&i.u()}rc(){this.Xo()||(this.pe(!0),this.oo(!0))}lc(t){if(this.rs())return;const i=this.panel;!t&&i!==null&&i.u(),this.oo(!0)}hd(){this.J1()===!1&&(this.cd(!0),this.Sa(!0))}b2(){this.Sa(!0)}T(){const t=this.part;t!==null&&t.T()}qs(t){const i=this.stretch,e=this.panel;if(e===null)return this.qo(i===1?0:i,t);if(e.type===Panel.Table)return this.F0(e.getRowDefinition(this.row),e.getColumnDefinition(this.column),t);if(e.type===Panel.Auto&&e.findMainElement()===this)return this.qo(2,t);if(i===1){if(e.type===Panel.Spot&&e.findMainElement()===this)return this.qo(2,t);const s=e.defaultStretch;return s===1?this.qo(0,t):this.qo(s,t)}return this.qo(i,t)}F0(t,i,e){const s=this.stretch;if(s!==1)return this.qo(s,e);let n=null,o=null;switch(t.stretch){case 1:case 5:break;case 4:o=!0;break;case 2:o=!0;break}switch(i.stretch){case 1:case 4:break;case 5:n=!0;break;case 2:n=!0;break}const r=this.panel.defaultStretch;return n===null&&(n=r===5||r===2),o===null&&(o=r===4||r===2),n===!0&&o===!0?this.qo(2,e):n===!0?this.qo(5,e):o===!0?this.qo(4,e):this.qo(0,e)}qo(t,i){if(i)return t;if(t===0)return 0;const e=this.desiredSize;if(e.isReal())return 0;const s=!isNaN(e.width),n=!isNaN(e.height),o=this.angle;if(s)if(o!==90&&o!==270){if(t===5)return 0;if(t===2)return 4}else{if(t===4)return 0;if(t===2)return 5}if(n)if(o!==90&&o!==270){if(t===4)return 0;if(t===2)return 5}else{if(t===5)return 0;if(t===2)return 4}return t}get segmentOrientation(){return this.Ut!==null?this.Ut.R0:0}set segmentOrientation(t){const i=this.segmentOrientation;i!==t&&(Debug&&Util.tt(t,Orientation,"Orientation"),this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.R0=t,this.u(),this.i("segmentOrientation",i,t),t===0&&(this.angle=0))}KR(){this.segmentOrientation=21}get segmentIndex(){return this.Ut!==null?this.Ut.I0:-1/0}set segmentIndex(t){Debug&&Util.t(t,"number",GraphObject,"segmentIndex"),t=Math.round(t);const i=this.segmentIndex;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.I0=t,this.u(),this.i("segmentIndex",i,t))}get segmentFraction(){return this.Ut!==null?this.Ut.O0:0}set segmentFraction(t){Debug&&Util.t(t,"number",GraphObject,"segmentFraction"),isNaN(t)||t<0?t=0:t>1&&(t=1);const i=this.segmentFraction;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.O0=t,this.u(),this.i("segmentFraction",i,t))}get segmentOffset(){return this.Ut!==null?this.Ut.E0:Point.Lo}set segmentOffset(t){const i=this.segmentOffset;i.equals(t)||(Debug&&Util.s(t,Point,GraphObject,"segmentOffset"),t=t.L(),this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.E0=t,this.u(),this.i("segmentOffset",i,t))}get stretch(){return this.g!==null?this.g.ro:1}set stretch(t){const i=this.stretch;i!==t&&(this.Zt(),this.g.ro=t,this.u(),this.i("stretch",i,t))}get name(){return this.g!==null?this.g.Tt:""}set name(t){const i=this.name;i!==t&&(Debug&&Util.t(t,"string",GraphObject,"name"),this.Zt(),this.g.Tt=t,this.part!==null&&this.part.V0(),this.i("name",i,t))}get opacity(){return this._t}set opacity(t){const i=this._t;if(i!==t){Util.t(t,"number",GraphObject,"opacity"),(t<0||t>1)&&Util.G(t,"0 <= value <= 1",GraphObject,"opacity"),this._t=t,this.i("opacity",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.T(s.Jh(s.actualBounds))}}get filter(){return this.sd}set filter(t){Debug&&Util.t(t,"string",GraphObject,"filter");const i=this.sd;if(i!==t){this.sd=t,this.hs(!0),this.i("filter",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.T(s.Jh(s.actualBounds))}}get visible(){return(this.l&1)!==0}set visible(t){const i=(this.l&1)!==0;if(i!==t){Debug&&Util.t(t,"boolean",GraphObject,"visible"),this.l=this.l^1,this.i("visible",i,t);const e=this.panel;e!==null?e.u():this.js()&&this.Ki(t),this.T(),this.pL()}}get pickable(){return(this.l&2)!==0}set pickable(t){const i=(this.l&2)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"pickable"),this.l=this.l^2,this.i("pickable",i,t))}get fromLinkableDuplicates(){return(this.l&4)!==0}set fromLinkableDuplicates(t){const i=(this.l&4)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"fromLinkableDuplicates"),this.l=this.l^4,this.i("fromLinkableDuplicates",i,t))}get fromLinkableSelfNode(){return(this.l&8)!==0}set fromLinkableSelfNode(t){const i=(this.l&8)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"fromLinkableSelfNode"),this.l=this.l^8,this.i("fromLinkableSelfNode",i,t))}get toLinkableDuplicates(){return(this.l&16)!==0}set toLinkableDuplicates(t){const i=(this.l&16)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"toLinkableDuplicates"),this.l=this.l^16,this.i("toLinkableDuplicates",i,t))}get toLinkableSelfNode(){return(this.l&32)!==0}set toLinkableSelfNode(t){const i=(this.l&32)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"toLinkableSelfNode"),this.l=this.l^32,this.i("toLinkableSelfNode",i,t))}get isPanelMain(){return(this.l&64)!==0}set isPanelMain(t){const i=(this.l&64)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"isPanelMain"),this.l=this.l^64,this.u(),this.i("isPanelMain",i,t))}get isActionable(){return(this.l&128)!==0}set isActionable(t){const i=(this.l&128)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"isActionable"),this.l=this.l^128,this.i("isActionable",i,t))}get background(){return this.Ft}set background(t){const i=this.Ft;i!==t&&(t!==null&&Brush.ud(t,"GraphObject.background"),t instanceof Brush&&t.w(),this.Ft=t,this.T(),this.i("background",i,t))}m2(){return(this.l&512)!==0}j1(t){t?this.l|=512:this.l&=-513}ec(){return(this.l&1024)!==0}k2(t){t?this.l|=1024:this.l&=-1025}J1(){return(this.l&2048)!==0}cd(t){t?this.l|=2048:this.l&=-2049}N0(){return(this.l&4096)!==0}Sa(t){t?this.l|=4096:this.l&=-4097}Xo(){return(this.l&8192)!==0}pe(t){t?this.l|=8192:this.l&=-8193}rs(){return(this.l&16384)!==0}oo(t){t?this.l|=16384:this.l&=-16385}XR(){return(this.l&32768)!==0}hs(t){t?this.l|=32768:this.l&=-32769}get part(){if(this.js())return this;if(this.sl!==null)return this.sl;let t=this;for(t=t.panel;t;){if(t instanceof Part)return this.sl=t,t;t=t.panel}return null}get svg(){return this.u2}set svg(t){this.u2=t}zu(){this.svg=null}get panel(){return this.Hs}Ma(t){this.Hs=t,this.svg!==null&&this.svg.remove()}get layer(){const t=this.part;return t!==null?t.layer:null}get diagram(){const t=this.part;return t!==null?t.diagram:null}get position(){return this.mt}set position(t){Debug&&Util.s(t,Point,GraphObject,"position");const i=t.x,e=t.y,s=this.mt,n=s.x,o=s.y;n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e))?(t=t.copy(),this.S2(t,n,o)&&this.i("position",new Point(n,o),t)):this.M2()}M2(){}S2(t,i,e){return this.mt=t,this.lc(),!0}Af(t,i,e){this.mt.x===t&&this.mt.y===i||(this.mt.e(t,i),this.hd())}get actualBounds(){return this.Fi}get scale(){return this.lt}set scale(t){const i=this.lt;i!==t&&(Debug&&Util.r(t,GraphObject,"scale"),t<=0&&Util.n("GraphObject.scale for "+this+" must be greater than zero, not: "+t),this.lt=t,this.u(),this.i("scale",i,t))}get angle(){return this.jt}set angle(t){const i=this.jt;if(i!==t){if(Debug&&Util.r(t,GraphObject,"angle"),t=t%360,t<0&&(t+=360),i===t)return;this.jt=t,this.pL(),this.u(),this.i("angle",i,t)}}get desiredSize(){return this.qe}set desiredSize(t){Debug&&Util.s(t,Size,GraphObject,"desiredSize");const i=t.width,e=t.height,s=this.qe,n=s.width,o=s.height;if((n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e)))&&(t=t.L(),this.qe=t,this.u(),this instanceof Shape&&this.re(),this.i("desiredSize",s,t),this.ec())){const r=this.part;r!==null&&(this.ka(r,"width"),this.ka(r,"height"))}}get width(){return this.qe.width}set width(t){const i=this.qe.width;if(i!==t&&(!isNaN(i)||!isNaN(t))){Debug&&Util.t(t,"number",GraphObject,"width");const e=this.qe,s=new Size(t,this.qe.height).w();if(this.qe=s,this.u(),this instanceof Shape&&this.re(),this.i("desiredSize",e,s),this.ec()){const n=this.part;n!==null&&this.ka(n,"width")}}}get height(){return this.qe.height}set height(t){const i=this.qe.height;if(i!==t&&(!isNaN(i)||!isNaN(t))){Debug&&Util.t(t,"number",GraphObject,"height");const e=this.qe,s=new Size(this.qe.width,t).w();if(this.qe=s,this.u(),this instanceof Shape&&this.re(),this.i("desiredSize",e,s),this.ec()){const n=this.part;n!==null&&this.ka(n,"height")}}}get minSize(){return this.g!==null?this.g.Pr:Size.lf}set minSize(t){const i=this.minSize;i.equals(t)||(Debug&&Util.s(t,Size,GraphObject,"minSize"),t=t.copy(),isNaN(t.width)&&(t.width=0),isNaN(t.height)&&(t.height=0),t.w(),this.Zt(),this.g.Pr=t,this.u(),this.i("minSize",i,t))}get maxSize(){return this.g!==null?this.g.Nr:Size.Xk}set maxSize(t){const i=this.maxSize;i.equals(t)||(Debug&&Util.s(t,Size,GraphObject,"maxSize"),t=t.copy(),isNaN(t.width)&&(t.width=1/0),isNaN(t.height)&&(t.height=1/0),t.w(),this.Zt(),this.g.Nr=t,this.u(),this.i("maxSize",i,t))}get measuredBounds(){return this.le}get naturalBounds(){return this.Hi}U1(){return 0}get margin(){return this.el}set margin(t){typeof t=="number"?t=new Margin(t):Debug&&Util.s(t,Margin,GraphObject,"margin");const i=this.el;i.equals(t)||(t=t.L(),this.el=t,this.u(),this.i("margin",i,t))}get O(){return this.J1()===!0&&this.G1(),this.il}get Ks(){return this.N0()===!0&&this.G1(),this.ah}trigger(t,i,e){let s=null;return typeof t=="string"?s=new AnimationTrigger(t,i,e):s=t,s.Ce=this,this.Ss===null&&(this.Ss=new GMap),this.Ss.set(s.propertyName,s),this}get Ss(){return this.g!==null?this.g.Ss:null}set Ss(t){this.Ss!==t&&(this.Zt(),this.g.Ss=t)}get Mr(){return this.g!==null?this.g.Mr:0}set Mr(t){this.Mr!==t&&(this.Zt(),this.g.Mr=t)}get alignment(){return this.ai}set alignment(t){const i=this.ai;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"alignment"),t.isNoSpot()&&!t.isDefault()&&Util.n("GraphObject.alignment for "+this+" must be a real Spot or Spot.Default, not: "+t),t=t.L(),this.ai=t,this.lc(),this.i("alignment",i,t))}get column(){return this.Go}set column(t){Debug&&Util.r(t,GraphObject,"column"),t=Math.round(t);const i=this.Go;i!==t&&(t<0&&Util.G(t,">= 0",GraphObject,"column"),this.Go=t,this.u(),this.i("column",i,t),this.svg!==null&&this.svg.remove())}get columnSpan(){return this.g!==null?this.g.B0:1}set columnSpan(t){Debug&&Util.t(t,"number",GraphObject,"columnSpan"),t=Math.round(t);const i=this.columnSpan;i!==t&&(t<1&&Util.G(t,">= 1",GraphObject,"columnSpan"),this.Zt(),this.g.B0=t,this.u(),this.i("columnSpan",i,t))}get row(){return this.ed}set row(t){Debug&&Util.r(t,GraphObject,"row"),t=Math.round(t);const i=this.ed;i!==t&&(t<0&&Util.G(t,">= 0",GraphObject,"row"),this.ed=t,this.u(),this.i("row",i,t),this.svg!==null&&this.svg.remove())}get rowSpan(){return this.g!==null?this.g.z0:1}set rowSpan(t){Debug&&Util.t(t,"number",GraphObject,"rowSpan"),t=Math.round(t);const i=this.rowSpan;i!==t&&(t<1&&Util.G(t,">= 1",GraphObject,"rowSpan"),this.Zt(),this.g.z0=t,this.u(),this.i("rowSpan",i,t))}get spanAllocation(){return this.g!==null?this.g.X0:null}set spanAllocation(t){const i=this.spanAllocation;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"spanAllocation"),this.Zt(),this.g.X0=t,this.u(),this.i("spanAllocation",i,t))}get alignmentFocus(){return this.tc}set alignmentFocus(t){const i=this.tc;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"alignmentFocus"),Debug&&t.isNoSpot()&&!t.isDefault()&&!(t.isNone()&&this instanceof Node)&&Util.n("GraphObject.alignmentFocus must be a real Spot or Spot.Default, not: "+t),t=t.L(),this.tc=t,this.u(),this.i("alignmentFocus",i,t))}get portId(){return this.td}set portId(t){const i=this.td;if(i!==t){Debug&&t!==null&&Util.t(t,"string",GraphObject,"portId");const e=this.part;e!==null&&!(e instanceof Node)&&Util.n("Cannot set portID on a Link: "+t);const s=e;i!==null&&s!==null&&s.P2(this),this.td=t,t!==null&&s!==null&&(s.Mn=!0,s.yL(this)),this.i("portId",i,t)}}Pa(){const t=this.part;if(t instanceof Node&&(this.portId!==null||this===t.port)){const i=t.diagram;i!==null&&!i.undoManager.isUndoingRedoing&&t.aL(this)}}pL(){const t=this.diagram;t===null||t.undoManager.isUndoingRedoing||(this instanceof Panel?this instanceof Node?this.invalidateConnectedLinks():this.walkVisualTreeFrom(this,i=>{i.Pa()}):this.Pa())}get toSpot(){return this.Z!==null?this.Z.pa:Spot.None}set toSpot(t){const i=this.toSpot;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"toSpot"),t=t.L(),this.je(),this.Z.pa=t,this.i("toSpot",i,t),this.Pa())}get toEndSegmentLength(){return this.Z!==null?this.Z.wa:10}set toEndSegmentLength(t){const i=this.toEndSegmentLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"toEndSegmentLength"),t<0&&Util.G(t,">= 0",GraphObject,"toEndSegmentLength"),this.je(),this.Z.wa=t,this.i("toEndSegmentLength",i,t),this.Pa())}get toShortLength(){return this.Z!==null?this.Z.ba:0}set toShortLength(t){const i=this.toShortLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"toShortLength"),this.je(),this.Z.ba=t,this.i("toShortLength",i,t),this.Pa())}get toLinkable(){return this.Z!==null?this.Z.Y0:null}set toLinkable(t){const i=this.toLinkable;i!==t&&(Debug&&t!==null&&Util.t(t,"boolean",GraphObject,"toLinkable"),this.je(),this.Z.Y0=t,this.i("toLinkable",i,t))}get toMaxLinks(){return this.Z!==null?this.Z.K0:1/0}set toMaxLinks(t){const i=this.toMaxLinks;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"toMaxLinks"),t<0&&Util.G(t,">= 0",GraphObject,"toMaxLinks"),this.je(),this.Z.K0=t,this.i("toMaxLinks",i,t))}get fromSpot(){return this.Z!==null?this.Z.ma:Spot.None}set fromSpot(t){const i=this.fromSpot;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"fromSpot"),t=t.L(),this.je(),this.Z.ma=t,this.i("fromSpot",i,t),this.Pa())}get fromEndSegmentLength(){return this.Z!==null?this.Z.ya:10}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"fromEndSegmentLength"),t<0&&Util.G(t,">= 0",GraphObject,"fromEndSegmentLength"),this.je(),this.Z.ya=t,this.i("fromEndSegmentLength",i,t),this.Pa())}get fromShortLength(){return this.Z!==null?this.Z.xa:0}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"fromShortLength"),this.je(),this.Z.xa=t,this.i("fromShortLength",i,t),this.Pa())}get fromLinkable(){return this.Z!==null?this.Z.U0:null}set fromLinkable(t){const i=this.fromLinkable;i!==t&&(Debug&&t!==null&&Util.t(t,"boolean",GraphObject,"fromLinkable"),this.je(),this.Z.U0=t,this.i("fromLinkable",i,t))}get fromMaxLinks(){return this.Z!==null?this.Z.G0:1/0}set fromMaxLinks(t){const i=this.fromMaxLinks;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"fromMaxLinks"),t<0&&Util.G(t,">= 0",GraphObject,"fromMaxLinks"),this.je(),this.Z.G0=t,this.i("fromMaxLinks",i,t))}get cursor(){return this.g!==null?this.g.Al:""}set cursor(t){const i=this.cursor;i!==t&&(Util.t(t,"string",GraphObject,"cursor"),this.Zt(),this.g.Al=t,this.i("cursor",i,t))}get click(){return this.g!==null?this.g.Or:null}set click(t){const i=this.click;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"click"),this.Zt(),this.g.Or=t,this.i("click",i,t))}get doubleClick(){return this.g!==null?this.g.Er:null}set doubleClick(t){const i=this.doubleClick;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"doubleClick"),this.Zt(),this.g.Er=t,this.i("doubleClick",i,t))}get contextClick(){return this.g!==null?this.g.Vr:null}set contextClick(t){const i=this.contextClick;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"contextClick"),this.Zt(),this.g.Vr=t,this.i("contextClick",i,t))}get mouseEnter(){return this.g!==null?this.g.Kr:null}set mouseEnter(t){const i=this.mouseEnter;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseEnter"),this.Zt(),this.g.Kr=t,this.i("mouseEnter",i,t))}get mouseLeave(){return this.g!==null?this.g.Ur:null}set mouseLeave(t){const i=this.mouseLeave;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseLeave"),this.Zt(),this.g.Ur=t,this.i("mouseLeave",i,t))}get mouseOver(){return this.g!==null?this.g.Br:null}set mouseOver(t){const i=this.mouseOver;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseOver"),this.Zt(),this.g.Br=t,this.i("mouseOver",i,t))}get mouseHover(){return this.g!==null?this.g.zr:null}set mouseHover(t){const i=this.mouseHover;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseHover"),this.Zt(),this.g.zr=t,this.i("mouseHover",i,t))}get mouseHold(){return this.g!==null?this.g.Xr:null}set mouseHold(t){const i=this.mouseHold;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseHold"),this.Zt(),this.g.Xr=t,this.i("mouseHold",i,t))}get mouseDragEnter(){return this.g!==null?this.g.H0:null}set mouseDragEnter(t){const i=this.mouseDragEnter;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseDragEnter"),this.Zt(),this.g.H0=t,this.i("mouseDragEnter",i,t))}get mouseDragLeave(){return this.g!==null?this.g.q0:null}set mouseDragLeave(t){const i=this.mouseDragLeave;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseDragLeave"),this.Zt(),this.g.q0=t,this.i("mouseDragLeave",i,t))}get mouseDrop(){return this.g!==null?this.g.Yr:null}set mouseDrop(t){const i=this.mouseDrop;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseDrop"),this.Zt(),this.g.Yr=t,this.i("mouseDrop",i,t))}get actionDown(){return this.g!==null?this.g.j0:null}set actionDown(t){const i=this.actionDown;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionDown"),this.Zt(),this.g.j0=t,this.i("actionDown",i,t))}get actionMove(){return this.g!==null?this.g.W0:null}set actionMove(t){const i=this.actionMove;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionMove"),this.Zt(),this.g.W0=t,this.i("actionMove",i,t))}get actionUp(){return this.g!==null?this.g.v0:null}set actionUp(t){const i=this.actionUp;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionUp"),this.Zt(),this.g.v0=t,this.i("actionUp",i,t))}get actionCancel(){return this.g!==null?this.g.J0:null}set actionCancel(t){const i=this.actionCancel;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionCancel"),this.Zt(),this.g.J0=t,this.i("actionCancel",i,t))}get toolTip(){return this.g!==null?this.g.Gr:null}set toolTip(t){const i=this.toolTip;i!==t&&(Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("GraphObject.toolTip must be an Adornment or HTMLInfo."),this.Zt(),this.g.Gr=t,this.i("toolTip",i,t))}get contextMenu(){return this.g!==null?this.g.Hr:null}set contextMenu(t){const i=this.contextMenu;i!==t&&(Debug&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("GraphObject.contextMenu must be an Adornment or HTMLInfo."),this.Zt(),this.g.Hr=t,this.i("contextMenu",i,t))}findBindingPanel(){let t=this instanceof Panel?this:this.panel;for(;t!==null;){if(t.N2())return t;t=t.panel}return null}bind(t,i,e,s){return this.hc(t,i,e,s),this}bindTwoWay(t,i,e,s){return this.hc(t,i,e,s).makeTwoWay(),this}bindModel(t,i,e,s){return this.hc(t,i,e,s).ofModel(),this}bindObject(t,i,e,s,n){return this.hc(t,i,e,s).ofObject(n),this}theme(t,i,e,s,n){return this.mh(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.mh(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.mh(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.mh(t,i,e,s,n).ofModel(),this}hc(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.Z0(n),n}mh(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.Z0(o),o}Z0(t){t.Ce=this;const i=this.findBindingPanel();i!==null&&i.wL()&&Util.n("Cannot add a Binding to a template that has already been copied: "+t),this.Ri===null&&(this.Ri=new List),this.Ri.add(t)}set(t){if(Debug)for(const i in t)(i.startsWith("_")||i.indexOf(".")!==-1)&&Util.n("Property with underscore or period passed to GraphObject.set. Did you mean to use GraphObject.attach?");return Object.assign(this,t),this}attach(t){return GraphObject.C2(this,t),this}apply(t){return t(this),this}setProperties(t){return Diagram.p0(this,t),this}static build(t,i,...e){const s=GraphObject.$0.get(t);if(typeof s=="function"){const n=s([t].concat(e));if(n instanceof GraphObject)return i&&n.setProperties(i),n}Util.n('GraphObject.build invoked object builder "'+t+'", but it did not return an Object')}static make(t,...i){let e=arguments,s=null,n=null;if(typeof t=="function")n=t;else if(typeof t=="string"){const r=GraphObject.$0.get(t);typeof r=="function"?(e=Array.prototype.slice.call(e),s=r(e),Util.Mt(s)||Util.n('GraphObject.make invoked object builder "'+t+'", but it did not return an Object')):n=root.go[t]}s===null&&((n==null||!n.constructor)&&Util.n("GraphObject.make requires a class function or GoJS class name or name of an object builder, not: "+t),s=new n);let o=1;if(s instanceof Diagram&&e.length>1){const r=s,l=e[1];(typeof l=="string"||l instanceof HTMLDivElement)&&(r.MP(l),o++)}for(let r=o;r{const i="#f5f5f5",e="#737373",s="#d4d4d4",n="#737373",o="#a3a3a3",r=2.76142374915397,l=2.761423749153969,h=new Panel(Panel.Auto,{isActionable:!0,enabledChanged:(a,f)=>{if(a instanceof Panel){const c=a.findObject("ButtonBorder");c!==null&&(f?(a._buttonFillDisabled=c.fill,c.fill=a._buttonFillNormal):(a._buttonFillNormal=c.fill,c.fill=a._buttonFillDisabled))}},cursor:"pointer"}).attach({_buttonFillNormal:i,_buttonStrokeNormal:e,_buttonFillOver:s,_buttonStrokeOver:n,_buttonFillDisabled:o}).add(new Shape("RoundedRectangle",{name:"ButtonBorder",spot1:new Spot(0,0,r,l),spot2:new Spot(1,1,-r,-l),parameter1:2,fill:i,stroke:e}));return h.mouseEnter=(a,f,c)=>{if(!f.isEnabledObject()||!(f instanceof Panel))return;const u=f.findObject("ButtonBorder");u instanceof Shape&&(f._buttonFillNormal=u.fill,u.fill=f._buttonFillOver,f._buttonStrokeNormal=u.stroke,u.stroke=f._buttonStrokeOver)},h.mouseLeave=(a,f,c)=>{if(!f.isEnabledObject()||!(f instanceof Panel))return;const u=f.findObject("ButtonBorder");u instanceof Shape&&(u.fill=f._buttonFillNormal,u.stroke=f._buttonStrokeNormal)},h}),GraphObject.defineBuilder("TreeExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_treeExpandedFigure:"MinusLine",_treeCollapsedFigure:"PlusLine",visible:!1}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.gu}).bindObject("figure","isTreeExpanded",(e,s)=>{const n=s.panel;return e?n._treeExpandedFigure:n._treeCollapsedFigure})),i.bindObject("visible","isTreeLeaf",e=>!e),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Node))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isTreeExpanded){if(!r.canCollapseTree(n))return}else if(!r.canExpandTree(n))return;e.handled=!0,n.isTreeExpanded?r.collapseTree(n):r.expandTree(n)},i}),GraphObject.defineBuilder("SubGraphExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_subGraphExpandedFigure:"MinusLine",_subGraphCollapsedFigure:"PlusLine"}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.gu}).bindObject("figure","isSubGraphExpanded",(e,s)=>{const n=s.panel;return e?n._subGraphExpandedFigure:n._subGraphCollapsedFigure})),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Group))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isSubGraphExpanded){if(!r.canCollapseSubGraph(n))return}else if(!r.canExpandSubGraph(n))return;e.handled=!0,n.isSubGraphExpanded?r.collapseSubGraph(n):r.expandSubGraph(n)},i}),GraphObject.defineBuilder("ToolTip",t=>new Adornment(Panel.Auto,{isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).add(new Shape("RoundedRectangle",{name:"Border",parameter1:1,fill:"#f5f5f5",strokeWidth:0,spot1:new Spot(0,0,4,6),spot2:new Spot(1,1,-4,-4)}))),GraphObject.defineBuilder("ContextMenu",t=>new Adornment(Panel.Vertical,{background:"#f5f5f5",isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).bindObject("background","",i=>i.adornedPart!==null&&i.hasPlaceholder()?null:"#f5f5f5")),GraphObject.defineBuilder("ContextMenuButton",t=>{const i=GraphObject.build("Button");i.stretch=5;const e=i.findObject("ButtonBorder");return e instanceof Shape&&(e.figure="Rectangle",e.strokeWidth=0,e.spot1=new Spot(0,0,4,6),e.spot2=new Spot(1,1,-4,-4)),i}),GraphObject.defineBuilder("PanelExpanderButton",t=>{const i=GraphObject.takeBuilderArgument(t,"COLLAPSIBLE"),e=GraphObject.build("Button");e.attach({_buttonExpandedFigure:"M0 0 M0 6 L4 2 8 6 M8 8",_buttonCollapsedFigure:"M0 0 M0 2 L4 6 8 2 M8 8",_buttonFillNormal:"rgba(0, 0, 0, 0)",_buttonStrokeNormal:null,_buttonFillOver:"rgba(0, 0, 0, .2)",_buttonStrokeOver:null}),e.add(new Shape({name:"ButtonIcon",strokeWidth:2}).bindObject("geometryString","visible",n=>n?e._buttonExpandedFigure:e._buttonCollapsedFigure,void 0,i));const s=e.findObject("ButtonBorder");return s instanceof Shape&&(s.stroke=null,s.fill="rgba(0, 0, 0, 0)"),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=o.diagram;if(r===null||r.isReadOnly)return;let l=o.findBindingPanel();if(l===null&&(l=o.part),l!==null){const h=l.findObject(i);h!==null&&(n.handled=!0,r.startTransaction("Collapse/Expand Panel"),h.visible=!h.visible,r.commitTransaction("Collapse/Expand Panel"))}},e}),GraphObject.defineBuilder("CheckBoxButton",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("Button",{desiredSize:new Size(14,14)});e.attach({"ButtonBorder.spot1":new Spot(0,0,1,1),"ButtonBorder.spot2":new Spot(1,1,-1,-1)});const s=new Shape({name:"ButtonIcon",geometryString:"M0 0 M0 8.85 L4.9 13.75 16.2 2.45 M16.2 16.2",strokeWidth:2,stretch:2,geometryStretch:6,visible:!1});return i!==""&&s.bindTwoWay("visible",i),e.add(s),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=n.diagram;if(r===null||r.isReadOnly||i!==""&&r.model.isReadOnly)return;n.handled=!0;const l=o.findObject("ButtonIcon");r.startTransaction("checkbox"),l!==null&&(l.visible=!l.visible),typeof o._doClick=="function"&&o._doClick(n,o),r.commitTransaction("checkbox")},e}),GraphObject.defineBuilder("CheckBox",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("CheckBoxButton",{name:"Button",isActionable:!1,margin:new Margin(0,1,0,0)},i),s=new Panel("Horizontal",{isActionable:!0,cursor:e.cursor,margin:new Margin(1),mouseEnter:e.mouseEnter,mouseLeave:e.mouseLeave,click:e.click}).attach({_buttonFillNormal:e._buttonFillNormal,_buttonStrokeNormal:e._buttonStrokeNormal,_buttonFillOver:e._buttonFillOver,_buttonStrokeOver:e._buttonStrokeOver,_buttonFillDisabled:e._buttonFillDisabled,_buttonClick:e.click});return s.add(e),e.mouseEnter=null,e.mouseLeave=null,e.click=null,s})}}class GraphObjectTemplateSettings{wi;Tt;eo;Ri;so;Ws;Al;Or;Er;Vr;Kr;Ur;Br;zr;Xr;H0;q0;Yr;j0;W0;v0;J0;Gr;Hr;D0;X0;Ss;Pr;Nr;ro;z0;B0;Mr;L0;Q0;_0;constructor(){this.wi=!1,this.Tt="",this.eo=-1,this.Ri=null,this.so=null,this.Ws=null,this.Al="",this.Or=null,this.Er=null,this.Vr=null,this.Kr=null,this.Ur=null,this.Br=null,this.zr=null,this.Xr=null,this.H0=null,this.q0=null,this.Yr=null,this.j0=null,this.W0=null,this.v0=null,this.J0=null,this.Gr=null,this.Hr=null,this.D0=null,this.X0=null,this.Ss=null,this.Pr=Size.lf,this.Nr=Size.Xk,this.ro=1,this.z0=1,this.B0=1,this.Mr=0,this.L0=null,this.Q0=null,this._0="category"}copy(){const t=new GraphObjectTemplateSettings;return t.Tt=this.Tt,t.eo=this.eo,t.Ri=this.Ri,t.Ws=this.Ws,t.Al=this.Al,t.Or=this.Or,t.Er=this.Er,t.Vr=this.Vr,t.Kr=this.Kr,t.Ur=this.Ur,t.Br=this.Br,t.zr=this.zr,t.Xr=this.Xr,t.H0=this.H0,t.q0=this.q0,t.Yr=this.Yr,t.j0=this.j0,t.W0=this.W0,t.v0=this.v0,t.J0=this.J0,t.Gr=this.Gr,t.Hr=this.Hr,t.D0=this.D0,t.X0=this.X0,t.Ss=this.Ss,t.Pr=this.Pr.L(),t.Nr=this.Nr.L(),t.ro=this.ro,t.z0=this.z0,t.B0=this.B0,t.Mr=this.Mr,t.L0=this.L0,t.Q0=this.Q0,t._0=this._0,t}}class STransform{m;constructor(){this.m=[1,0,0,1,0,0]}copy(){const t=new STransform;return t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5],t}translate(t,i){this.m[4]+=this.m[0]*t+this.m[2]*i,this.m[5]+=this.m[1]*t+this.m[3]*i}scale(t,i){this.m[0]*=t,this.m[1]*=t,this.m[2]*=i,this.m[3]*=i}rotate(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return;this.translate(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m[0]*s+this.m[2]*n,r=this.m[1]*s+this.m[3]*n,l=this.m[0]*-n+this.m[2]*s,h=this.m[1]*-n+this.m[3]*s;this.m[0]=o,this.m[1]=r,this.m[2]=l,this.m[3]=h,this.translate(-i,-e)}}class SGradient{type;x1;y1;r1;x2;y2;r2;colors;pattern;constructor(t){this.type=t,this.x1=0,this.y1=0,this.r1=0,this.x2=0,this.y2=0,this.r2=0,this.colors=[],this.pattern=null}addColorStop(t,i){this.colors.push({offset:t,color:i})}}class SVGSurface{Bt;di;ua;Qu;A2;constructor(t,i,e){const s=i===void 0?root.document:i;this.ua=s,this.A2="http://www.w3.org/2000/svg";const n="http://www.w3.org/2000/xmlns/";s!==void 0&&(this.Bt=this.makeElement("svg",{width:"1px",height:"1px",viewBox:"0 0 1 1"}),this.style.display="block",this.style.letterSpacing="normal",this.style.wordSpacing="normal",e||(this.style.position="absolute"),this.Bt.setAttributeNS(n,"xmlns",this.A2),this.Bt.setAttributeNS(n,"xmlns:xlink","http://www.w3.org/1999/xlink")),this.Qu=null,this.di=new SVGContext(this,e)}resize(t,i,e,s){return this.width!==t||this.height!==i?(this.width=t,this.height=i,this.style.width=e+"px",this.style.height=s+"px",this.Bt.setAttributeNS(null,"width",e+"px"),this.Bt.setAttributeNS(null,"height",s+"px"),this.Bt.setAttributeNS(null,"viewBox","0 0 "+e+" "+s),this.di.L2.firstElementChild.setAttributeNS(null,"width",e+"px"),this.di.L2.firstElementChild.setAttributeNS(null,"height",s+"px"),!0):!1}makeElement(t,i,e){const s=this.ua.createElementNS(this.A2,t);if(Util.Mt(i))for(const n in i)s.setAttributeNS(n==="href"?"http://www.w3.org/1999/xlink":"",n,i[n]);return e!==void 0&&(s.textContent=e),s}getBoundingClientRect(){return this.Bt.getBoundingClientRect()}focus(){this.Bt.focus()}get width(){return this.Bt.width.baseVal.value}set width(t){this.Bt.setAttribute("width",t+"px")}get height(){return this.Bt.height.baseVal.value}set height(t){this.Bt.setAttribute("height",t+"px")}dispose(){this.ua=null}get style(){return this.Bt.style}}class SVGContext{ac;fc;Pn;Ii;We;fillStyle;font;globalAlpha;lineCap;lineDashOffset;lineJoin;lineWidth;miterLimit;shadowBlur;shadowColor;shadowOffsetX;shadowOffsetY;strokeStyle;textAlign;imageSmoothingEnabled;clipInsteadOfFill;lastCreatedElement;cc;uc;surface;svg;L2;xL;$1;jo;ph;Na;currentElement;clipPathGroup;diagramGroup;lastDrawnPart;currentPath;outerGroup;pathAttributes;ol;Tr;filter;partClipRect;constructor(t,i){this.surface=t,this.svg=t.Bt,this.cc=[],this.uc=[],this.fillStyle="#000000",this.font="10px sans-serif",this.globalAlpha=1,this.lineCap="butt",this.lineDashOffset=0,this.lineJoin="miter",this.lineWidth=1,this.miterLimit=10,this.shadowBlur=0,this.shadowColor="rgba(0, 0, 0, 0)",this.shadowOffsetX=0,this.shadowOffsetY=0,this.ol=!1,this.strokeStyle="#000000",this.textAlign="start",this.clipInsteadOfFill=!1,this.ac=0,this.fc=0,this.Pn=0,this.lastCreatedElement=null,this.currentElement=null,this.Ii=[],this.pathAttributes={},this.$1=!1,this.jo=null,this.ph=0,this.We=new STransform,this.clipPathGroup=this.newGroup2(),this.diagramGroup=this.newGroup2("gojs-diagram"),this.lastDrawnPart=null,this.currentPath=null;const e=GSet.cu++,s=this.makeElement("clipPath",{id:"mainClip"+e}),n={x:0,y:0,width:t.width,height:t.height};s.appendChild(this.makeElement("rect",n)),this.L2=s,this.svg.appendChild(this.clipPathGroup),this.clipPathGroup.appendChild(this.diagramGroup),this.svg.appendChild(s),this.clipPathGroup.setAttributeNS(null,"clip-path","url(#mainClip"+e+")"),this.xL={},this.Tr=!!i,this.filter="",this.partClipRect=null}setDiagramPosScale(t,i,e,s,n,o){this.diagramGroup===void 0?this.newGroup(t,i,e,s,n,o):this.diagramGroup.setAttribute("transform","matrix("+t+", "+i+", "+e+", "+s+", "+n+", "+o+")")}resetInnerSVG(){this.diagramGroup!==null&&(this.diagramGroup.innerHTML="")}arc(t,i,e,s,n,o,r,l){const h=2*Math.PI,a=1e-6,f=h-a,c=e*Math.cos(s),u=e*Math.sin(s),d=t+c,m=i+u,g=o?0:1;let p=o?s-n:n-s;(Math.abs(r-d)>a||Math.abs(l-m)>a)&&this.Ii.push(["L",d,+m]),p<0&&(p=p%h+h),p>f?(this.Ii.push(["A",e,e,0,1,g,t-c,i-u]),this.Ii.push(["A",e,e,0,1,g,d,m])):p>a&&this.Ii.push(["A",e,e,0,+(p>=Math.PI),g,t+e*Math.cos(n),i+e*Math.sin(n)])}beginPath(){this.Ii=[],this.pathAttributes={stroke:"none",fill:"none"}}endPath(t){this.qR(this.Ii,this.We,t||0)}bezierCurveTo(t,i,e,s,n,o){this.Ii.push(["C",t,i,e,s,n,o])}clearRect(t,i,e,s){}clip(){this.pathAttributes.clipPath=!0}closePath(){this.Ii.push(["z"])}createLinearGradient(t,i,e,s){const n=new SGradient("linear");return n.x1=t,n.y1=i,n.x2=e,n.y2=s,n}createPattern(t,i){let e="";t instanceof HTMLCanvasElement&&(e=t.toDataURL()),t instanceof HTMLImageElement&&(e=t.getAttribute("src"));const s=this.xL;if(s[e])return"url(#"+s[e]+")";const n="PATTERN"+GSet.cu++,o={width:t.width,height:t.height,id:n,patternUnits:"userSpaceOnUse"},r={x:0,y:0,width:t.width,height:t.height,href:e},l=this.makeElement("pattern",o);return l.appendChild(this.makeElement(Diagram.img,r)),this.svg.appendChild(l),s[e]=n,"url(#"+n+")"}createRadialGradient(t,i,e,s,n,o){const r=new SGradient("radial");return r.x1=t,r.y1=i,r.r1=e,r.x2=s,r.y2=n,r.r2=o,r}amendImageTransform(t,i,e,s,n,o,r,l){const h=r/e,a=l/s;(n!==0||o!==0)&&this.We.translate(n,o),(h!==1||a!==1)&&this.We.scale(h,a),(t!==0||i!==0)&&this.We.translate(-t,-i)}drawImage(t,i,e,s,n,o,r,l,h){let a="";t instanceof HTMLCanvasElement&&(a=t.toDataURL()),t instanceof HTMLImageElement&&(a=t.getAttribute("src"));const f=t instanceof HTMLImageElement?t.naturalWidth:t.width,c=t instanceof HTMLImageElement?t.naturalHeight:t.height;s===void 0&&(o=i,r=e,l=s=f,h=n=c),s=s||0,n=n||0,o=o||0,r=r||0,l=l||0,h=h||0,this.amendImageTransform(i,e,s,n,o,r,l,h);const u={x:0,y:0,width:f||s,height:c||n,href:a};!Geo.q(s,l)||!Geo.q(n,h)?u.preserveAspectRatio="none":a.toLowerCase().indexOf(".svg")===-1&&a.toLowerCase().indexOf("data:image/svg")===-1&&(u.preserveAspectRatio="xMidYMid slice"),(i!==0||e!==0||s!==f||n!==c)&&(s+=i,n+=e,u["clip-path"]=`path('M ${i},${e} L ${s} ${e} L ${s} ${n} L ${i} ${n} z')`),this.processCommon(Diagram.img,u,this.We),this.dd(Diagram.img,u)}fill(t,i){t&&(this.pathAttributes["fill-rule"]="evenodd"),this.setFill(this.pathAttributes)}fillContext(t,i,e){this.clipInsteadOfFill?this.clip():this.fill(i,e)}fillRect(t,i,e,s){this.addRect("fill",[t,i,e,s],this.We)}fillBackground(t,i,e,s){const n={x:t,y:i,width:e,height:s};this.processCommon("fill",n,this.We),this.setFill(n),this.svg.prepend(this.makeElement("rect",n))}fillText(t,i,e){this.addText("fill",[t,i,e],this.We)}lineTo(t,i){this.Ii.push(["L",t,i])}moveTo(t,i){this.Ii.push(["M",t,i])}quadraticCurveTo(t,i,e,s){this.Ii.push(["Q",t,i,e,s])}rect(t,i,e,s){this.Ii.push(["M",t,i],["L",t+e,i],["L",t+e,i+s],["L",t,i+s],["z"])}restore(){this.We=this.cc.pop(),this.Ii=this.cc.pop();const t=this.cc.pop();this.fillStyle=t.fillStyle,this.font=t.font,this.globalAlpha=t.globalAlpha,this.lineCap=t.lineCap,this.lineDashOffset=t.lineDashOffset,this.lineJoin=t.lineJoin,this.lineWidth=t.lineWidth,this.miterLimit=t.miterLimit,this.shadowBlur=t.shadowBlur,this.shadowColor=t.shadowColor,this.shadowOffsetX=t.shadowOffsetX,this.shadowOffsetY=t.shadowOffsetY,this.strokeStyle=t.strokeStyle,this.textAlign=t.textAlign,this.partClipRect=t.partClipRect}save(){const t={fillStyle:this.fillStyle,font:this.font,globalAlpha:this.globalAlpha,lineCap:this.lineCap,lineDashOffset:this.lineDashOffset,lineJoin:this.lineJoin,lineWidth:this.lineWidth,miterLimit:this.miterLimit,shadowBlur:this.shadowBlur,shadowColor:this.shadowColor,shadowOffsetX:this.shadowOffsetX,shadowOffsetY:this.shadowOffsetY,strokeStyle:this.strokeStyle,textAlign:this.textAlign,partClipRect:this.partClipRect};this.cc.push(t);const i=[];for(let e=0;eh.offset>a.offset?1:-1);for(let h=0;h0&&this.uc[this.uc.length-1].setAttributeNS(null,"clip-path",'path("'+s+'")');return}if(n.d=s,this.processCommon("",n,i),this.currentPath!==null){const r=this.currentPath;if(r.nodeName!=="g")for(const l in n)l!=="transform"&&r.setAttributeNS(null,l,n[l]);else{const l=r.getElementsByTagName("path");for(const h in n)h!=="transform"&&l[e].setAttributeNS(null,h,n[h])}}else this.dd("path",n)}jR(t){const i=[];for(let e=0;es?(this.scale(s/n,1),this.translate((n-s)/2,0)):s>n&&(this.scale(1,n/s),this.translate(0,(s-n)/2)),this.fillOrClip(i,e),n>s?(this.translate(-(n-s)/2,0),this.scale(1/(s/n),1)):s>n&&(this.translate(0,-(s-n)/2),this.scale(1,1/(n/s))),!0}strokeContext(){this.tp||this.stroke()}fillOrClip(t,i){this.tp?this.clip(i):this.fill(t,i)}get clipInsteadOfFill(){return this.tp}set clipInsteadOfFill(t){this.tp=t}shadowsSet(t,i,e){this.ac=t,this.fc=i,this.Pn=e}shadowsOff(){this.ol=!1,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0}shadowsOn(){this.ol=!0,this.shadowOffsetX=this.ac,this.shadowOffsetY=this.fc,this.shadowBlur=this.Pn}enableDash(t,i){const e=this.Y;e.setLineDash!==void 0&&(e.setLineDash(t),e.lineDashOffset=i)}disableDash(){const t=this.Y;t.setLineDash!==void 0&&(t.setLineDash(CanvasSurfaceContext.EmptyArray),t.lineDashOffset=0)}clearContextCache(t){t&&(this.Q1=""),this._1="",this.tb=""}removePartFromView(t){}static EmptyArray=Object.freeze([])}var BrushType=(w=>(w[w.Solid=1]="Solid",w[w.Linear=2]="Linear",w[w.Radial=3]="Radial",w[w.Pattern=4]="Pattern",w))(BrushType||{}),ColorSpace=(w=>(w[w.Lab=1]="Lab",w[w.HSL=2]="HSL",w[w.Oklch=3]="Oklch",w))(ColorSpace||{});class ColorNumbers{n0;n1;n2;n3;constructor(){this.n0=0,this.n1=0,this.n2=0,this.n3=0}}class Brush{f;st;Ca;li;xs;ip;ep;Nn;sp;Sn;oc;v1;constructor(t,i){if(GSet.vi(this),this.f=!1,t===void 0)this.st=1,this.Ca="black";else if(typeof t=="string"){const s=Util.zh(BrushType,t);s!==null?(this.st=s,this.Ca="black"):(this.st=1,Debug&&!Brush.isValidColor(t)&&Util.n('Color "'+t+'" is not a valid color string for Brush constructor'),this.Ca=t)}else Debug&&Util.tt(t,BrushType,"BrushType"),this.st=t,this.Ca="black";const e=this.st;if(e===2?(this.li=Spot.TopCenter,this.xs=Spot.BottomCenter):e===3?(this.li=Spot.Center,this.xs=Spot.Center):(this.li=Spot.None,this.xs=Spot.None),this.ip=0,this.ep=NaN,this.Nn=null,this.sp=null,this.Sn=null,this.oc=0,this.v1=0,i){const s={};for(const n in i)isFinite(parseFloat(n))?this.addColorStop(parseFloat(n),i[n]):s[n]=i[n];Object.assign(this,s)}}copy(){const t=new Brush;return t.st=this.st,t.Ca=this.Ca,t.li=this.li.L(),t.xs=this.xs.L(),t.ip=this.ip,t.ep=this.ep,this.Nn!==null&&(t.Nn=this.Nn.copy()),t.sp=this.sp,t}w(){return this.f=!0,this.Nn!==null&&this.Nn.w(),this}ct(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this.Nn!==null&&this.Nn.ct(),this}fi(t){t in BrushType?this.type=t:Util.ur(this,t)}toString(){let t="Brush(";if(this.type===1)t+=this.color;else if(this.type===2?t+="Linear ":this.type===3?t+="Radial ":this.type===4?t+="Pattern ":t+="(unknown) ",t+=this.start+" "+this.end,this.colorStops!==null){const i=this.colorStops.iterator;for(;i.next();){const e=i.key,s=i.value;t+=" "+e+":"+s}}return t+=")",t}addColorStop(t,i){return this.f&&Util.F(this),(typeof t!="number"||!isFinite(t)||t>1||t<0)&&Util.G(t,"0 <= loc <= 1",Brush,"addColorStop:loc"),Util.t(i,"string",Brush,"addColorStop:color"),Debug&&!Brush.isValidColor(i)&&Util.n('Color "'+i+'" is not a valid color string for Brush.addColorStop'),this.Nn===null&&(this.Nn=new GMap),this.Nn.set(t,i),this.st===1&&(this.type=2),this.Sn=null,this}get type(){return this.st}set type(t){this.f&&Util.F(this,t),Util.tt(t,BrushType,"BrushType"),this.st=t,this.start.isNoSpot()&&(t===2?this.start=Spot.TopCenter:t===3&&(this.start=Spot.Center)),this.end.isNoSpot()&&(t===2?this.end=Spot.BottomCenter:t===3&&(this.end=Spot.Center)),this.Sn=null}get color(){return this.Ca}set color(t){this.f&&Util.F(this,t),Debug&&!Brush.isValidColor(t)&&Util.n('Color "'+t+'" is not a valid color string for Brush.color'),this.Ca=t,this.Sn=null}get start(){return this.li}set start(t){this.f&&Util.F(this,t),Util.s(t,Spot,Brush,"start"),this.li=t.L(),this.Sn=null}get end(){return this.xs}set end(t){this.f&&Util.F(this,t),Util.s(t,Spot,Brush,"end"),this.xs=t.L(),this.Sn=null}get startRadius(){return this.ip}set startRadius(t){this.f&&Util.F(this,t),Util.r(t,Brush,"startRadius"),t<0&&Util.G(t,">= zero",Brush,"startRadius"),this.ip=t,this.Sn=null}get endRadius(){return this.ep}set endRadius(t){this.f&&Util.F(this,t),Util.r(t,Brush,"endRadius"),t<0&&Util.G(t,">= zero",Brush,"endRadius"),this.ep=t,this.Sn=null}get colorStops(){return this.Nn}set colorStops(t){this.f&&Util.F(this,t),Debug&&Util.s(t,GMap,Brush,"colorStops"),this.Nn=t,this.Sn=null}get pattern(){return this.sp}set pattern(t){this.f&&Util.F(this,t),this.sp=t,this.Sn=null}static randomColor(t,i){t===void 0&&(t=128),Debug&&(Util.r(t,Brush,"randomColor:min"),(t<0||t>255)&&Util.G(t,"0 <= min <= 255",Brush,"randomColor:min")),i===void 0&&(i=Math.max(t,255)),Debug&&(Util.r(i,Brush,"randomColor:max"),(i255)&&Util.G(i,"min <= max <= 255",Brush,"randomColor:max"));const e=Math.abs(i-t);let s=Math.floor(t+Math.random()*e).toString(16),n=Math.floor(t+Math.random()*e).toString(16),o=Math.floor(t+Math.random()*e).toString(16);return s.length<2&&(s="0"+s),n.length<2&&(n="0"+n),o.length<2&&(o="0"+o),"#"+s+n+o}static isValidColor(t){return root.CSS?root.CSS.supports("color",t):!0}static lighten(t){return Brush.lightenBy(t)}lightenBy(t,i){this.f&&Util.F(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Eo(this.color),this.color=Brush.gd(e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Eo(n.value),this.addColorStop(n.key,Brush.gd(e,s))}return this}static lightenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Eo(t),Brush.gd(s,n)}static darken(t){return Brush.darkenBy(t)}darkenBy(t,i){this.f&&Util.F(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Eo(this.color),this.color=Brush.gd(-e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Eo(n.value),this.addColorStop(n.key,Brush.gd(-e,s))}return this}static darkenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Eo(t),Brush.gd(-s,n)}static mix(t,i,e){Brush.Eo(t);const s=Brush.W.n0,n=Brush.W.n1,o=Brush.W.n2,r=Brush.W.n3;Brush.Eo(i),e===void 0&&(e=.5);const l=Math.round((Brush.W.n0-s)*e+s),h=Math.round((Brush.W.n1-n)*e+n),a=Math.round((Brush.W.n2-o)*e+o),f=Math.round((Brush.W.n3-r)*e+r);return`rgba(${l}, ${h}, ${a}, ${f})`}isDark(){if(this.type===1)return Brush.isDark(this.color);if((this.type===2||this.type===3)&&this.colorStops!==null){const t=this.colorStops;if(this.type===3)return Brush.isDark(t.first().value);if(t.get(.5)!==null)return Brush.isDark(t.get(.5));if(t.count===2){const l=t.toArray();return Brush.isDark(Brush.mix(l[0].value,l[1].value))}const i=t.iterator;let e=-1,s=-1,n=1,o=1;for(;i.next();){const l=i.key,h=Math.abs(.5-i.key);n>o&&h=n&&hs){let l=e;e=s,s=l,l=n,n=o,o=l}const r=s-e;return Brush.isDark(Brush.mix(t.get(e),t.get(s),1-o/r))}return!1}static isDark(t){return t?t instanceof Brush?t.isDark():(Brush.Eo(t),(299*Brush.W.n0+587*Brush.W.n1+114*Brush.W.n2)/1e3<128):!1}static gd(t,i){switch(i){case 1:return Brush.WR(),Brush.lo.n0=Math.min(100,Math.max(0,Brush.lo.n0+100*t)),Brush.vR(),"rgba("+Brush.W.n0+", "+Brush.W.n1+", "+Brush.W.n2+", "+Brush.W.n3+")";case 2:return Brush.UM(),Brush.Yi.n2=Math.min(100,Math.max(0,Brush.Yi.n2+100*t)),"hsla("+Brush.Yi.n0+", "+Brush.Yi.n1+"%, "+Brush.Yi.n2+"%, "+Brush.Yi.n3+")";case 3:return Brush.JR(),Brush.ho.n0=Math.min(100,Math.max(0,Brush.ho.n0+100*t)),Brush.ZR(),"rgba("+Brush.W.n0+", "+Brush.W.n1+", "+Brush.W.n2+", "+Brush.W.n3+")";default:Util.n("Unknown color space: "+i)}}static Eo(t){const i=Brush.rl;if(i===null)return;i.clearRect(0,0,1,1),i.fillStyle="#000000";const e=i.fillStyle;if(i.fillStyle=t,i.fillStyle!==e){i.fillRect(0,0,1,1);const s=i.getImageData(0,0,1,1).data;Brush.W.n0=s[0],Brush.W.n1=s[1],Brush.W.n2=s[2],Brush.W.n3=s[3]/255}else{i.fillStyle="#FFFFFF";const s=i.fillStyle;i.fillStyle=t,i.fillStyle===s&&Debug&&Util.n('Color "'+t+'" is not a valid color string for RGBA color conversion'),Brush.W.n0=0,Brush.W.n1=0,Brush.W.n2=0,Brush.W.n3=1}}static UM(){const t=Brush.W.n0/255,i=Brush.W.n1/255,e=Brush.W.n2/255,s=Math.max(t,i,e),n=Math.min(t,i,e),o=s-n;let r,l;const h=(s+n)/2;if(o===0)r=l=0;else{switch(s){case t:r=(i-e)/o%6;break;case i:r=(e-t)/o+2;break;case e:r=(t-i)/o+4;break}r*=60,r<0&&(r+=360),l=o/(1-Math.abs(2*h-1))}Brush.Yi.n0=Math.round(r),Brush.Yi.n1=Math.round(l*100),Brush.Yi.n2=Math.round(h*100),Brush.Yi.n3=Brush.W.n3}static mE(){const t=Brush.Yi.n0,i=Brush.Yi.n1/100,e=Brush.Yi.n2/100;let s,n,o;const r=(1-Math.abs(2*e-1))*i,l=t/60,h=r*(1-Math.abs(l%2-1));l>=0&&l<1?(s=r,n=h,o=0):l>=1&&l<2?(s=h,n=r,o=0):l>=2&&l<3?(s=0,n=r,o=h):l>=3&&l<4?(s=0,n=h,o=r):l>=4&&l<5?(s=h,n=0,o=r):l>=5&&l<6&&(s=r,n=0,o=h);const a=e-.5*r;s+=a,n+=a,o+=a,Brush.W.n0=Math.round(s*255),Brush.W.n1=Math.round(n*255),Brush.W.n2=Math.round(o*255),Brush.W.n3=Brush.Yi.n3}static WR(){Brush.bL(),Brush.$R()}static vR(){Brush.QR(),Brush.kL()}static T2(t){return t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}static D2(t){return t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055}static bL(){const t=Brush.T2(Brush.W.n0),i=Brush.T2(Brush.W.n1),e=Brush.T2(Brush.W.n2);Brush.zt.n0=.4124564*t+.3575761*i+.1804375*e,Brush.zt.n1=.2126729*t+.7151522*i+.072175*e,Brush.zt.n2=.0193339*t+.119192*i+.9503041*e,Brush.zt.n3=Brush.W.n3}static kL(){const t=3.2404542*Brush.zt.n0+-1.5371385*Brush.zt.n1+-.4985314*Brush.zt.n2,i=-.969266*Brush.zt.n0+1.8760108*Brush.zt.n1+.041556*Brush.zt.n2,e=.0556434*Brush.zt.n0+-.2040259*Brush.zt.n1+1.0572252*Brush.zt.n2;Brush.W.n0=Brush.D2(t)*255,Brush.W.n1=Brush.D2(i)*255,Brush.W.n2=Brush.D2(e)*255,Brush.W.n3=Brush.zt.n3,Brush.W.n0=Math.round(Brush.W.n0),Brush.W.n0>255?Brush.W.n0=255:Brush.W.n0<0&&(Brush.W.n0=0),Brush.W.n1=Math.round(Brush.W.n1),Brush.W.n1>255?Brush.W.n1=255:Brush.W.n1<0&&(Brush.W.n1=0),Brush.W.n2=Math.round(Brush.W.n2),Brush.W.n2>255?Brush.W.n2=255:Brush.W.n2<0&&(Brush.W.n2=0)}static F2=216/24389;static ib=24389/27;static md=[95.047,100,108.883];static R2(t){return t>Brush.F2?Math.pow(t,1/3):(Brush.ib*t+16)/116}static $R(){const t=Brush.R2(Brush.zt.n0*100/Brush.md[0]),i=Brush.R2(Brush.zt.n1*100/Brush.md[1]),e=Brush.R2(Brush.zt.n2*100/Brush.md[2]);Brush.lo.n0=116*i-16,Brush.lo.n1=500*(t-i),Brush.lo.n2=200*(i-e),Brush.lo.n3=Brush.zt.n3}static SL(t){const i=t*t*t;return i>Brush.F2?i:(116*t-16)/Brush.ib}static QR(){const t=(Brush.lo.n0+16)/116,i=Brush.lo.n1/500+t,e=t-Brush.lo.n2/200;Brush.zt.n0=Brush.md[0]/100*Brush.SL(i),Brush.zt.n1=Brush.md[1]/100*(Brush.lo.n0>Brush.ib*Brush.F2?Math.pow(t,3):Brush.lo.n0/Brush.ib),Brush.zt.n2=Brush.md[2]/100*Brush.SL(e),Brush.zt.n3=Brush.lo.n3}static _R(){let t=.8190224*Brush.zt.n0+.3619062*Brush.zt.n1+-.1288737*Brush.zt.n2,i=.03298366*Brush.zt.n0+.9292868*Brush.zt.n1+.03614466*Brush.zt.n2,e=.04817719*Brush.zt.n0+.2642395*Brush.zt.n1+.6335478*Brush.zt.n2;t=Math.cbrt(t),i=Math.cbrt(i),e=Math.cbrt(e),Brush.gi.n0=.2104542*t+.7936177*i+-.004072046*e,Brush.gi.n1=1.977998*t+-2.428592*i+.4505937*e,Brush.gi.n2=.02590403*t+.7827717*i+-.8086757*e,Brush.gi.n3=Brush.zt.n3,Brush.gi.n0*=100}static tI(){Brush.gi.n0/=100;let t=.9999999*Brush.gi.n0+.3963377*Brush.gi.n1+.2158037*Brush.gi.n2,i=1.000000009*Brush.gi.n0+-.1055613*Brush.gi.n1+-.06385417*Brush.gi.n2,e=1.00000005*Brush.gi.n0+-.08948418*Brush.gi.n1+-1.291485*Brush.gi.n2;t=t**3,i=i**3,e=e**3,Brush.zt.n0=1.2268798*t+-.5578149*i+.281391*e,Brush.zt.n1=-.04057576*t+1.112286*i+-.07171106*e,Brush.zt.n2=-.07637294*t+-.4214933*i+1.586924*e,Brush.zt.n3=Brush.gi.n3}static iI(){const t=Math.atan2(Brush.gi.n2,Brush.gi.n1)*180/Math.PI;Brush.ho.n0=Brush.gi.n0,Brush.ho.n1=Math.sqrt(Brush.gi.n1**2+Brush.gi.n2**2),Brush.ho.n2=t>=0?t:t+360,Brush.ho.n3=Brush.gi.n3}static eI(){Brush.gi.n0=Brush.ho.n0,Brush.gi.n1=Brush.ho.n1*Math.cos(Brush.ho.n2*Math.PI/180),Brush.gi.n2=Brush.ho.n1*Math.sin(Brush.ho.n2*Math.PI/180),Brush.gi.n3=Brush.ho.n3}static JR(){Brush.bL(),Brush._R(),Brush.iI()}static ZR(){Brush.eI(),Brush.tI(),Brush.kL()}static ud(t,i){typeof t=="string"?Debug&&!Brush.isValidColor(t)&&Util.n('Color "'+t+'" is not a valid color string for '+i):t instanceof Brush||Util.n("Value for "+i+" must be a color string or a Brush, not "+t)}static Solid=1;static Linear=2;static Radial=3;static Pattern=4;static Lab=1;static HSL=2;static rl=Diagram.isUsingDOM()?new CanvasSurface(null,void 0,{willReadFrequently:!0}).di:null;static W=new ColorNumbers;static Yi=new ColorNumbers;static zt=new ColorNumbers;static lo=new ColorNumbers;static gi=new ColorNumbers;static ho=new ColorNumbers}class PanelLayout{Tt="Base";static Layouts=new GMap;static definePanelLayout(t,i){i.name=t,PanelLayout.Layouts.set(t,i)}get name(){return this.Tt}set name(t){this.Tt=t}constructor(){}get classType(){return Panel}measure(t,i,e,s,n,o,r){}measureElement(t,i,e,s,n){t.wt(i,e,s,n)}arrange(t,i,e){}arrangeElement(t,i,e,s,n,o){t.qt(i,e,s,n,o)}remeasureObject(t){t.rc()}Ji(t,i,e){}}class PanelLayoutPosition extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=s.length,h=t.Wo();for(let a=0;a0&&(P=Math.max(Math.abs(k.x*o+k.offsetX-(M.x*o+M.offsetX))-g,0)),r>0&&(N=Math.max(Math.abs(k.y*r+k.offsetY-(M.y*r+M.offsetY))-g,0));const T=Size.a();T.e(0,0);const L=t.Wo();for(let I=0;I1,ot=it.columnSpan>1;(ft||ot)&&!(Uy&&(P=Math.max(y-gt,0)),b.Zi=b.Zi+P,b.actual=b.ht+P,y=Math.max(y-(P+(mt?gt:0)),0)}if(it.columnSpan===1&&(N===0||N===4)){b=t.getColumnDefinition(H);const gt=b.computeEffectiveSpacing(),mt=b.ht===0;P=Math.max(ut-b.actual,0),P+(mt?gt:0)>p&&(P=Math.max(p-gt,0)),b.Zi=b.Zi+P,b.actual=b.ht+P,p=Math.max(p-(P+(mt?gt:0)),0)}(ft||ot)&&it.rc()}}}Util.nt(c);let L=0,D=0;l=t.columnCount;for(let U=0;U=t.rowCount);$++)b=t.getRowDefinition(E.row+$),P=0,N===2||N===4?P=Math.max(b.minimum,X[E.row+$]===0?b.maximum:Math.min(X[E.row+$],b.maximum)):P=Math.max(b.minimum,isNaN(b.we)?b.maximum:Math.min(b.we,b.maximum)),V.height+=P,_+=b.minimum;for(let $=1;$=t.columnCount);$++)b=t.getColumnDefinition(E.column+$),P=0,N===2||N===5?P=Math.max(b.minimum,z[E.column+$]===0?b.maximum:Math.min(z[E.column+$],b.maximum)):P=Math.max(b.minimum,isNaN(b.we)?b.maximum:Math.min(b.we,b.maximum)),V.width+=P,et+=b.minimum;K.width+=V.width,K.height+=V.height;const tt=E.margin,it=tt.right+tt.left,ft=tt.top+tt.bottom;E.wt(K.width,K.height,et,_);const ot=E.measuredBounds,lt=Math.max(ot.width+it,0),st=Math.max(ot.height+ft,0);let nt=0;for(let $=0;$=t.rowCount);$++)b=t.getRowDefinition(E.row+$),nt+=b.total||0;if(nt=t.rowCount);at++){b=t.getRowDefinition(E.row+at);const ut=b.ht||0,dt=rt(E,b,ct);Debug&&typeof dt!="number"&&Util.n(E+" spanAllocation does not return a number: "+dt),b.actual=Math.min(b.maximum,ut+dt),b.ht!==ut&&($-=b.ht-ut)}}for(;$>0;){const rt=b.ht||0;if(isNaN(b.height)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+$),b.ht!==rt&&($-=b.ht-rt)),b.index===0)break;b=t.getRowDefinition(b.index-1)}}let ht=0;for(let $=0;$=t.columnCount);$++)b=t.getColumnDefinition(E.column+$),ht+=b.total||0;if(ht=t.columnCount);at++){b=t.getColumnDefinition(E.column+at);const ut=b.ht||0,dt=rt(E,b,ct);Debug&&typeof dt!="number"&&Util.n(E+" spanAllocation does not return a number: "+dt),b.actual=Math.min(b.maximum,ut+dt),b.ht!==ut&&($-=b.ht-ut)}}for(;$>0;){const rt=b.ht||0;if(isNaN(b.width)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+$),b.ht!==rt&&($-=b.ht-rt)),b.index===0)break;b=t.getColumnDefinition(b.index-1)}}}Util.nt(u),Size.o(V),Size.o(K),X!==void 0&&Util.nt(X),z!==void 0&&Util.nt(z);let G=0,q=0;const j=t.desiredSize,J=t.maxSize;N=t.qs(!0),L=0,D=0;let Y=0,v=0;l=t.columnCount;for(let U=0;U0){for(;p!==f&&(u[p]===void 0||u[p].ht===0);)p++;p=Math.max(Math.min(p,f-1),0),m=-u[p].position}let y=Math.min(t.leftIndex,c-1);if(d.length>0){for(;y!==c&&(d[y]===void 0||d[y].ht===0);)y++;y=Math.max(Math.min(y,c-1),0),g=-d[y].position}let x=0,k=0;for(;x!==f&&u[x]===void 0;)x++;for(;k!==f&&d[k]===void 0;)k++;const b=t.part;let S=t.getRowDefinition(x),M=t.getColumnDefinition(k);for(let C=0;C=t.rowCount);st++){const nt=t.getRowDefinition(C+st);nt.ht!==0&&(A.height+=nt.total)}for(let st=1;st=t.columnCount);st++){const nt=t.getColumnDefinition(N+st);nt.ht!==0&&(A.width+=nt.total)}const O=T.ht+A.width,B=P.ht+A.height;let K=h,V=a;const X=O,z=B,G=h,q=a;let j=O,J=B;h+O>e.width&&(j=Math.max(e.width-h,0)),a+B>e.height&&(J=Math.max(e.height-a,0));let Y=R.alignment,v=0,W=0,Q=0,U=0;if(Y.isDefault()){Y=t.defaultAlignment,Y.isSpot()||(Y=Spot.Center),v=Y.x,W=Y.y,Q=Y.offsetX,U=Y.offsetY;const st=T.alignment,nt=P.alignment;st.isSpot()&&(v=st.x,Q=st.offsetX),nt.isSpot()&&(W=nt.y,U=nt.offsetY)}else v=Y.x,W=Y.y,Q=Y.offsetX,U=Y.offsetY;(isNaN(v)||isNaN(W))&&(v=.5,W=.5,Q=0,U=0);let E=I.width,H=I.height;const Z=R.margin,et=Z.left+Z.right,_=Z.top+Z.bottom,tt=R.F0(P,T,!1);isNaN(R.desiredSize.width)&&(tt===2||tt===5)&&(E=Math.max(O-et,0)),isNaN(R.desiredSize.height)&&(tt===2||tt===4)&&(H=Math.max(B-_,0));const it=R.maxSize,ft=R.minSize;E=Math.min(it.width,E),H=Math.min(it.height,H),E=Math.max(ft.width,E),H=Math.max(ft.height,H);const ot=E+et,lt=H+_;K+=X*v-ot*v+Q+Z.left,V+=z*W-lt*W+U+Z.top,R.visible&&(Rect.contains(G,q,j,J,K,V,I.width,I.height)?R.qt(K,V,E,H):R.qt(K,V,E,H,new Rect(G,q,j,J)))}}}Size.o(A);for(let C=0;C0&&(b.figure==="LineV"||b.figure==="LineH")){if(i.lineWidth=b.strokeWidth,t.wn(i,b.stroke,!1,!1,l,h),i.beginPath(),b.figure==="LineV"){const D=Math.floor((m-o)/o);for(let F=D;F<=D+c;F++){const R=F*o+m;0<=R&&R<=a&&this.sb(F,S,A,N)&&(i.moveTo(R,0),i.lineTo(R,f))}}else if(b.figure==="LineH"){const D=Math.floor((g-r)/r);for(let F=D;F<=D+u;F++){const R=F*r+g;0<=R&&R<=f&&this.sb(F,S,A,N)&&(i.moveTo(0,R),i.lineTo(a,R))}}i.stroke(),i.endPath()}else if(b.fill!==null){if(t.wn(i,b.fill,!0,!1,l,h),b.figure==="BarV"){let D=b.width;isNaN(D)&&(D=o);const F=Math.floor((m-o)/o);for(let R=F;R<=F+c;R++){const I=R*o+m;0<=I+D&&I<=a&&this.sb(R,S,A,N)&&i.fillRect(I,0,D,f)}}else if(b.figure==="BarH"){let D=b.height;isNaN(D)&&(D=r);const F=Math.floor((g-r)/r);for(let R=F;R<=F+u;R++){const I=R*r+g;0<=I+D&&I<=f&&this.sb(R,S,A,N)&&i.fillRect(0,I,a,D)}}}T&&i.disableDash(),C!==1&&(i.globalAlpha=P)}}sb(t,i,e,s){if(i<0)return t%i===e;if(t%i!==e)return!1;const n=s.length;for(let o=0;ol&&r.push(d)}}t.Mi.np=i}V2(t){return t==="LineV"||t==="BarV"}sI(t){let i=1,e=1;const s=t.D.h,n=s.length;for(let l=0;l=g){const Y=Point.a();f.ML(Y),O=f.midAngle,L!==0&&(I=f.computeAngle(A,L,O),A.jt=I,A.pe(!0),A.oo(!0)),F=Y.x-u.x,R=Y.y-u.y,Point.o(Y)}else{let Y,v,W=0;if(P>=0?(Y=m.elt(P),v=P0?m.elt(W-1):Y),O=0,Y.equalsApprox(v)){let Q,U;P>=0?(Q=P>0?m.elt(P-1):Y,U=P1?m.elt(W-2):v);const E=Q.distanceSquaredPoint(Y),H=v.distanceSquaredPoint(U);E>H+10?O=P>=0?Q.directionPoint(Y):Y.directionPoint(Q):H>E+10?O=P>=0?v.directionPoint(U):U.directionPoint(v):O=P>=0?Q.directionPoint(U):U.directionPoint(Q)}else O=P>=0?Y.directionPoint(v):v.directionPoint(Y);L!==0&&(I=f.computeAngle(A,L,O),A.jt=I,A.pe(!0),A.oo(!0)),F=Y.x+(v.x-Y.x)*N-u.x,R=Y.y+(v.y-Y.y)*N-u.y}A.wt(1/0,1/0,0,0),C=A.measuredBounds;const B=A.naturalBounds;let K=0;A instanceof Shape&&(K=A.strokeWidth);const V=B.width+K,X=B.height+K;k.Bi(),k.Es(-C.x,-C.y),k.lt(A.scale,A.scale),k.ms(L===0?A.angle:O,V/2,X/2),(L===22||L===26)&&k.ms(90,V/2,X/2),(L===23||L===27)&&k.ms(-90,V/2,X/2),L===28&&(O>45&&O<135||O>225&&O<315)&&k.ms(-O,V/2,X/2);const z=new Rect(0,0,V,X);b.setRectSpot(z,T),k.Pt(b);const G=-b.x+K/2*A.scale,q=-b.y+K/2*A.scale;S.c(D);const j=isNaN(D.x),J=isNaN(D.y);if(j||J){const Y=V/2+3,v=X/2+3,W=O>=45&&O<=135,Q=O>=225&&O<=315;L===0&&(W||Q)?(S.x=J?Y:D.y,S.y=j?v:D.x,W?P>=0||isNaN(P)&&N<.5||j&&(S.y=-v):Q&&((P>=0||isNaN(P)&&N<.5)&&j&&(S.y=-v),J&&(S.x=-Y))):(j&&(P>=0||isNaN(P)&&N<.5?S.x=Y:S.x=-Y),J&&(S.y=-v),S.rotate(O))}else S.rotate(O);F+=S.x,R+=S.y,z.e(F+G,R+q,C.width,C.height),x.push(z),d.unionRect(z)}if(h!==null){const M=h.labelNodes;for(;M.next();)M.value.wt(1/0,1/0)}t.vo=d,t.position.e(u.x+d.x,u.y+d.y),n.Kn(d.width||0,d.height||0),Transform.o(k),Point.o(b),Point.o(S)}arrange(t,i,e){const s=i.length;if(!(t instanceof Adornment||t instanceof Link))return;let n=t,o=null;t instanceof Adornment&&(o=t,n=o.adornedPart);const r=t,l=t instanceof Adornment?null:n.path,h=t.dc;if(h.length!==0){let u=0;if(l!==null&&u=2&&r instanceof Link){const u=r.labelNodes;for(;u.next();){const d=u.value;r.rI(d,f,a)}}o!==null?o.pd(!1):n.pd(!1);const c=t.PL(Point.a());t.location.e(t.position.x+c.x,t.position.y+c.y),Point.o(c)}measureLinkPath(t,i,e,s){if(s.Xo()===!1)return;let n=s.strokeWidth;if(n===0&&t instanceof Adornment&&t.type===Panel.Link&&t.adornedObject instanceof Shape&&(n=t.adornedObject.strokeWidth),n=n*s.lt,t instanceof Link&&t.yt!==null){const o=t.geometry.bounds;s.no(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else if(t instanceof Adornment&&t.adornedPart.yt!==null){const o=t.adornedPart.yt.bounds;s.no(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else s.no(-(n/2),-(n/2),i+n,e+n);s.lI(),s.pe(!1)}}PanelLayout.definePanelLayout("Link",new PanelLayoutLink);class PanelLayoutGraduated extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=t.findMainElement();t.Ze=[];const h=l.margin,a=h.right+h.left,f=h.top+h.bottom;l.wt(i,e,o,r);const c=l.measuredBounds,u=c.width,d=c.height,m=Math.max(u+a,0),g=Math.max(d+f,0),p=new Rect(-h.left,-h.top,m,g);t.Ze.push(p),n.c(p),this.determineGraduatedMarks(t,l);const y=t.Ms;if(y===null)return;const x=s.length;for(let k=0;k45&&c<135||c>225&&c<315)&&S.ms(-c,k/2,b/2);const M=Rect.H(0,0,k,b),A=Point.a();A.setRectSpot(M,o),S.Pt(A);const C=-A.x,P=-A.y,N=Point.a();N.c(l),isNaN(N.x)&&(N.x=k/2+3),isNaN(N.y)&&(N.y=-(b/2+3)),N.rotate(c),a+=N.x+C,f+=N.y+P;const T=new Rect(a,f,y.width,y.height),L=new Rect(y.x,y.y,y.width,y.height),D=new Rect(x.x,x.y,x.width,x.height);p.labelAngle=u,p.lineCount=n.lineCount,p.lines=n.getMetrics(),p.actualBounds=T,p.measuredBounds=L,p.naturalBounds=D,g===0?h.c(T):h.unionRect(T),Point.o(N),Point.o(A),Rect.o(M),Transform.o(S)}t.Ze!==null&&t.Ze.push(h),s.unionNoCheck(h.x,h.y,h.width,h.height)}determineGraduatedMarks(t,i){const e=i.geometry,s=i.strokeWidth,n=e.flattenedSegments,o=e.flattenedLengths,r=e.flattenedTotalLength,l=n.length;let h=0,a=0;const f=Util.ft();for(let x=0;xt.graduatedMin+P){const F=Math.floor((N-t.graduatedMin)/P);N-=F*P}const T=c[x],L=N,D=t.graduatedMax*1e-6;for(let F=1;N<=t.graduatedMax+D;F++){if(this.aI(t,N-t.graduatedTickBase,T)&&(N>t.graduatedMax&&(N=t.graduatedMax),(k.graduatedSkip===null||k instanceof TextBlock&&!k.graduatedSkip(N,k)||k instanceof Shape&&!k.graduatedSkip(N,k))&&(m=(N-t.graduatedMin)*r/t.graduatedRange,m>r&&(m=r),g<=m&&m<=p))){let R=f[A][C],I=o[A][C];for(;AM&&C.4995)return t;let o=t;if(i<.5?n>0?o=s[n-1]:Geo.q(e[0],e[e.length-2])&&Geo.q(e[1],e[e.length-1])&&(o=s[s.length-1]):i>.5&&(n+1180&&(t.9995)return(t+o)/2%360;if(r<10){const l=1-Math.abs(.5-i);return(t*l+o*(1-l))%360}}return t}hI(t){if(t.as===null){const i=[],e=t.D.h,s=e.length;for(let n=0;nl&&r.push(f)}}t.as=i}return t.as}aI(t,i,e){const s=e.length;for(let n=0;n-l)return!1}return!0}Ji(t,i,e){const s=e.ia;e.ia=!0;const n=t.naturalBounds,o=n.width,r=n.height,l=i instanceof SVGContext;i.save(),i.beginPath(),i.rect(-1,-1,o+1,r+1),i.clip(),i.endPath();const h=t.findMainElement();h.Ji(i,e);let a=t.getDocumentScale()*e.scale;a<=0&&(a=1);const f=h.actualBounds,c=t.D.h,u=t.Ms,d=c.length;for(let m=0;m(w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ViewboxStretch||{});class Panel extends GraphObject{st;D;ii;yd;vn;ll;ao;vo;z2;B;wd;dt;Mi;si;xd;wh;vs;constructor(t,i){if(super(),this.st=null,t===void 0)this.st=Panel.Position;else if(typeof t=="string"){const e=PanelLayout.Layouts.get(t);e!==null&&(this.st=e)}else t instanceof PanelLayout?this.st=t:t&&(this.st=Panel.Position,i=t);this.st===null&&Util.n("Panel type not specified or PanelLayout not loaded: "+t),this.l|=4194304|(this.st===Panel.Grid?1048576:0),this.D=new List,this.ii=Margin.qg,this.yd=Spot.Default,this.vn=1,this.ll=null,this.ao="",this.vo=new Rect(NaN,NaN,NaN,NaN),this.z2=null,this.B=null,this.wd=6,this.Mi=null,this.dt=null,this.si=null,this.xd=NaN,this.wh=null,this.vs=null,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.st=this.st,t.ii=this.ii.L(),t.yd=this.yd.L(),t.vn=this.vn,t.ao=this.ao,t.vo.c(this.vo),this.B!==null&&(t.B=this.B.copy(t)),t.wd=this.wd,this.dt!==null&&(t.dt=this.dt.copy()),this.Mi!==null&&(t.Mi=this.Mi.copy()),t.si=this.si,t.xd=this.xd,t.wh=this.wh}Ho(t){super.Ho(t),t.D=this.D;const i=t.D.h,e=i.length;for(let s=0;s= 0",Panel,"padding"),t=new Margin(t)):(Util.s(t,Margin,Panel,"padding"),t.left<0&&Util.G(t.left,">= 0",Panel,"padding:value.left"),t.right<0&&Util.G(t.right,">= 0",Panel,"padding:value.right"),t.top<0&&Util.G(t.top,">= 0",Panel,"padding:value.top"),t.bottom<0&&Util.G(t.bottom,">= 0",Panel,"padding:value.bottom"));const i=this.ii;i.equals(t)||(t=t.L(),this.ii=t,this.u(),this.i("padding",i,t))}get defaultAlignment(){return this.yd}set defaultAlignment(t){const i=this.yd;i.equals(t)||(Debug&&Util.s(t,Spot,Panel,"defaultAlignment"),t=t.L(),this.yd=t,this.u(),this.i("defaultAlignment",i,t))}get defaultStretch(){return this.vn}set defaultStretch(t){const i=this.vn;i!==t&&(this.vn=t,this.u(),this.i("defaultStretch",i,t))}get defaultSeparatorPadding(){return this.B!==null?this.B.op:Margin.qg}set defaultSeparatorPadding(t){typeof t=="number"?t=new Margin(t):Debug&&Util.s(t,Margin,Panel,"defaultSeparatorPadding");const i=this.defaultSeparatorPadding;i.equals(t)||(t=t.L(),this.B===null&&(this.B=new TablePanelSettings),this.B.op=t,this.u(),this.i("defaultSeparatorPadding",i,t))}get defaultRowSeparatorStroke(){return this.B!==null?this.B.rp:null}set defaultRowSeparatorStroke(t){const i=this.defaultRowSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.w(),this.B===null&&(this.B=new TablePanelSettings),this.B.rp=t,this.T(),this.i("defaultRowSeparatorStroke",i,t))}get defaultRowSeparatorStrokeWidth(){return this.B!==null?this.B.lp:1}set defaultRowSeparatorStrokeWidth(t){const i=this.defaultRowSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.B===null&&(this.B=new TablePanelSettings),this.B.lp=t,this.u(),this.i("defaultRowSeparatorStrokeWidth",i,t))}get defaultRowSeparatorDashArray(){return this.B!==null?this.B.hp:null}set defaultRowSeparatorDashArray(t){const i=this.defaultRowSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Vi(t,"Array",Panel,"defaultRowSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("defaultRowSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.B===null&&(this.B=new TablePanelSettings),this.B.hp=t,this.T(),this.i("defaultRowSeparatorDashArray",i,t)}}get defaultColumnSeparatorStroke(){return this.B!==null?this.B.ap:null}set defaultColumnSeparatorStroke(t){const i=this.defaultColumnSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.w(),this.B===null&&(this.B=new TablePanelSettings),this.B.ap=t,this.T(),this.i("defaultColumnSeparatorStroke",i,t))}get defaultColumnSeparatorStrokeWidth(){return this.B!==null?this.B.fp:1}set defaultColumnSeparatorStrokeWidth(t){const i=this.defaultColumnSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.B===null&&(this.B=new TablePanelSettings),this.B.fp=t,this.u(),this.i("defaultColumnSeparatorStrokeWidth",i,t))}get defaultColumnSeparatorDashArray(){return this.B!==null?this.B.cp:null}set defaultColumnSeparatorDashArray(t){const i=this.defaultColumnSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Vi(t,"Array",Panel,"defaultColumnSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("defaultColumnSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.B===null&&(this.B=new TablePanelSettings),this.B.cp=t,this.T(),this.i("defaultColumnSeparatorDashArray",i,t)}}get yh(){return this.B!==null?this.B.yh:null}set yh(t){this.B===null&&(this.B=new TablePanelSettings),this.B.yh=t}get viewboxStretch(){return this.wd}set viewboxStretch(t){const i=this.wd;i!==t&&(this.wd=t,this.u(),this.i("viewboxStretch",i,t))}get gridCellSize(){return this.Mi!==null?this.Mi.bd:Size.fC}set gridCellSize(t){this.Mi===null&&(this.Mi=new GridPanelSettings);const i=this.Mi.bd;if(!i.equals(t)){(!t.isReal()||t.width===0||t.height===0)&&Util.n("Invalid Panel.gridCellSize: "+t),this.Mi.bd=t.L();const e=this.diagram;e!==null&&this===e.grid&&e.Zr(),this.T(),this.i("gridCellSize",i,t)}}get gridOrigin(){return this.Mi!==null?this.Mi.kd:Point.Lo}set gridOrigin(t){this.Mi===null&&(this.Mi=new GridPanelSettings);const i=this.Mi.kd;if(!i.equals(t)){t.isReal()||Util.n("Invalid Panel.gridOrigin: "+t),this.Mi.kd=t.L();const e=this.diagram;e!==null&&this===e.grid&&e.Zr(),this.T(),this.i("gridOrigin",i,t)}}get graduatedMin(){return this.dt!==null?this.dt.dp:0}set graduatedMin(t){Util.r(t,Panel,"graduatedMin");const i=this.graduatedMin;if(i!==t&&(this.dt===null&&(this.dt=new GradPanelSettings),this.dt.dp=t,this.u(),this.i("graduatedMin",i,t),this.ec())){const e=this.part;e!==null&&this.ka(e,"graduatedRange")}}get graduatedMax(){return this.dt!==null?this.dt.gp:100}set graduatedMax(t){Util.r(t,Panel,"graduatedMax");const i=this.graduatedMax;if(i!==t&&(this.dt===null&&(this.dt=new GradPanelSettings),this.dt.gp=t,this.u(),this.i("graduatedMax",i,t),this.ec())){const e=this.part;e!==null&&this.ka(e,"graduatedRange")}}get graduatedRange(){return this.graduatedMax-this.graduatedMin}get graduatedTickUnit(){return this.dt!==null?this.dt.mp:10}set graduatedTickUnit(t){Util.r(t,Panel,"graduatedTickUnit");const i=this.graduatedTickUnit;i!==t&&t>0&&(this.dt===null&&(this.dt=new GradPanelSettings),this.dt.mp=t,this.u(),this.i("graduatedTickUnit",i,t))}get graduatedTickBase(){return this.dt!==null?this.dt.pp:0}set graduatedTickBase(t){Util.r(t,Panel,"graduatedTickBase");const i=this.graduatedTickBase;i!==t&&(this.dt===null&&(this.dt=new GradPanelSettings),this.dt.pp=t,this.u(),this.i("graduatedTickBase",i,t))}get Ms(){return this.dt!==null?this.dt.Ms:null}set Ms(t){this.dt!==null?this.dt.Ms=t:t!==null&&(this.dt=new GradPanelSettings,this.dt.Ms=t)}get Ze(){return this.dt!==null?this.dt.Ze:null}set Ze(t){this.dt!==null?this.dt.Ze=t:t!==null&&(this.dt=new GradPanelSettings,this.dt.Ze=t)}get as(){return this.dt!==null?this.dt.as:null}set as(t){this.dt!==null?this.dt.as=t:t!==null&&(this.dt=new GradPanelSettings,this.dt.as=t)}get Le(){return this.dt!==null?this.dt.Le:null}set Le(t){this.dt!==null?this.dt.Le=t:t!==null&&(this.dt=new GradPanelSettings,this.dt.Le=t)}A0(t){super.A0(t);const i=this.D.h,e=i.length;for(let s=0;s0?this.ve:null,s=this.columnCount>0?this.Je:null;e!==null&&this.nb(t,i,!0,e,!0),s!==null&&this.nb(t,i,!1,s,!0),e!==null&&this.CL(t,!0,e),s!==null&&this.CL(t,!1,s),e!==null&&this.nb(t,i,!0,e,!1),s!==null&&this.nb(t,i,!1,s,!1)}CL(t,i,e){const s=e.length,n=this.actualBounds,o=this.naturalBounds;let r=!0;for(let l=0;lo.height)continue}else if(h.position>o.width)continue;let a=h.separatorStrokeWidth;isNaN(a)&&(a=i?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let f=h.separatorStroke;if(f===null&&(f=i?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),a===0||f===null)continue;this.wn(t,f,!1,!1,o,n);let c=!1,u=h.separatorDashArray;u===null&&(u=i?this.defaultRowSeparatorDashArray:this.defaultColumnSeparatorDashArray),u!==null&&(c=!0,t.enableDash(u,0)),t.beginPath();const d=h.position+a;i?d>o.height&&(a-=d-o.height):d>o.width&&(a-=d-o.width);let m=h.position+a/2;t.lineWidth=a;const g=this.ii;if(i){m+=g.top;const p=g.left,y=o.width-g.right;t.moveTo(p,m),t.lineTo(y,m)}else{m+=g.left;const p=g.top,y=o.height-g.bottom;t.moveTo(m,p),t.lineTo(m,y)}t.stroke(),t.endPath(),c&&t.disableDash()}}nb(t,i,e,s,n){const o=s.length,r=this.actualBounds,l=this.naturalBounds,h=this.AL(!0),a=this.AL(!1);for(let f=0;fu)continue;let d=c.computeEffectiveSpacing(),m=c.separatorStrokeWidth;isNaN(m)&&(m=e?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let g=c.separatorStroke;g===null&&(g=e?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),(g===null||c.index===(e?h:a))&&(m=0),d-=m;const p=c.position+m;let y=d+c.actual;if(p+y>u&&(y=u-p),y<=0)continue;const x=this.ii;this.wn(t,c.background,!0,!1,l,r),e?t.fillRect(x.left,p+x.top,r.width-(x.left+x.right),y):t.fillRect(p+x.left,x.top,y,r.height-(x.top+x.bottom))}}AL(t){const i=t?this.rowCount:this.columnCount;for(let e=0;ex&&n.set(P),Point.o(P)),Point.o(M),o&&n.O(r),k}}zu(){const t=this.D.h,i=t.length;for(let e=0;ee||h>s)&&(this.u(),this.wt(l>e?e:l,h>s?s:h,0,0));break;case 2:this.u(!0),this.wt(e+f,s+c,0,0);break;case 5:this.u(!0),this.wt(e+f,h+c,0,0);break;case 4:this.u(!0),this.wt(l+f,s+c,0,0);break}}this.st.arrange(this,n,this.vo)}ch(t){const i=this.naturalBounds,e=this.Wo();if(Rect.contains(0,0,i.width,i.height,t.x,t.y)){const s=this.D.h,n=s.length,o=Point.H(0,0);for(let r=n;r--;){const l=s[r];if(!(!l.visible&&l!==e)&&(o.set(t).Ye(l.O),l.containsPoint(o)))return Point.o(o),!0}return Point.o(o),this.Ft!==null}return!1}M0(t){if(this.eo===t)return this;const i=this.D.h,e=i.length;for(let s=0;sd.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;let m=c;const g=c instanceof Panel?c:null,p=Transform.a();p.set(r),(g!==null?g.Km(t,i,e,s,n,p):m.lL(t,s,p))&&(i!==null&&(m=i(m)),m!==null&&(e===null||e(m))&&n.add(m)),Transform.o(p)}}return o===void 0&&Transform.o(r),s}return o===void 0&&Transform.o(r),!1}Y2(t,i,e){const s=this.D.h,n=s.length;for(let o=n;o--;){const r=s[o];if(!r.visible)continue;const l=r.actualBounds,h=this.naturalBounds;if(l.x>h.width||l.y>h.height||l.x+l.width<0||l.y+l.height<0)continue;r instanceof Panel&&r.Y2(t,i,e);let a=r;t!==null&&(a=t(a)),a!==null&&(i===null||i(a))&&e.add(a)}}fA(t,i,e,s,n,o){if(this.pickable===!1)return!1;e===void 0&&(e=null),s===void 0&&(s=null);const r=this.naturalBounds,l=this.kn(),h=l?t:Point.H(t.x,t.y).Ye(this.O),a=l?i:Point.H(i.x,i.y).Ye(this.O),f=h.distanceSquaredPoint(a),c=h.x>0&&h.x0&&h.yS.width||b.y>S.height||b.x+b.width<0||b.y+b.height<0))continue;if(k.kn()){const C=k.O;d.set(t).Ye(C),m.set(i).Ye(C)}else d.set(t),m.set(i);let M=k;const A=k instanceof Panel?k:null;(A!==null?A.fA(d,m,e,s,n,o):M.hL(d,m,n))&&(e!==null&&(M=e(M)),M!==null&&(s===null||s(M))&&o.add(M))}Point.o(d),Point.o(m)}return n?c:u}return!1}O2(t){let i=null;if(t instanceof Shape){i=t.spot1,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot1)}return i===null&&(i=Spot.TopLeft),i}E2(t){let i=null;if(t instanceof Shape){i=t.spot2,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot2)}return i===null&&(i=Spot.BottomRight),i}add(...t){for(let i=0;i=s.count&&t>=s.count)return;s.removeAt(r),n=r}else Util.n("element "+i.toString()+" has panel "+e.toString()+" but is not contained by it.")}(t<0||t>s.count)&&(t=s.count),s.insertAt(t,i),(t===0||i.isPanelMain)&&(this.ll=null),this.Xo()||this.u(),i.u(!1),i.portId!==null?this.Mn=!0:i instanceof Panel&&i.Mn===!0&&(this.Mn=!0),this.as=null,this.isEnabledObject()||this.ob(i,!1);const o=this.part;if(o!==null){o.V0(),o.mc(),this.Mn&&o instanceof Node&&(o.Mn=!0),o.Mn&&o instanceof Node&&(o.he=null);const r=this.diagram;if(r!==null&&r.undoManager.isUndoingRedoing)return;n!==-1&&o.raiseChangedEvent(4,"elements",this,i,null,n,null),o.raiseChangedEvent(3,"elements",this,null,i,null,t)}}get Mn(){return(this.l&8388608)!==0}set Mn(t){(this.l&8388608)!==0!==t&&(this.l=this.l^8388608)}d2(){return(this.l&16777216)!==0}K2(t){t?this.l|=16777216:this.l&=-16777217}mI(t){t.Ma(this),t.sl=null;const i=this.D,e=i.count;i.insertAt(e,t);const s=this.part;if(s!==null){s.V0(),t.portId!==null&&s instanceof Node&&(s.Mn=!0);const n=this.diagram;if(n!==null&&n.undoManager.isUndoingRedoing)return;s.raiseChangedEvent(3,"elements",this,null,t,null,e)}}BR(t){const i=this.D.h,e=i.length;let s=-1;for(let n=0;n=0&&this.ne(t,!0)}ne(t,i){const e=this.D,s=e.elt(t);if(s.sl=null,s.Ma(null),this.vs!==null){const o=s.data;typeof o=="object"&&this.vs.delete(o)}e.removeAt(t),this.pe(!1),this.u(),this.ll===s&&(this.ll=null),this.as=null;const n=this.part;if(n!==null){n.V0(),n.mc(),n.invalidateAdornments(),n instanceof Node&&(s instanceof Panel?s.walkVisualTreeFrom(s,(r,l)=>n.P2(l,i)):n.P2(s,i));const o=this.diagram;if(o!==null&&o.undoManager.isUndoingRedoing)return;n.raiseChangedEvent(4,"elements",this,s,null,t,null)}}get ve(){return this.B===null&&(this.B=new TablePanelSettings),this.B.ve}get rowCount(){return this.B===null?0:this.ve.length}getRowDefinition(t){Debug&&Util.r(t,Panel,"getRowDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"getRowDefinition:idx"),t=Math.round(t);const i=this.ve;if(i[t]===void 0){const e=new RowColumnDefinition;e.Ma(this),e.isRow=!0,e.index=t,i[t]=e,this.raiseChangedEvent(3,"rowdefs",this,null,e,null,t)}return i[t]}removeRowDefinition(t){if(Debug&&Util.r(t,Panel,"removeRowDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"removeRowDefinition:idx"),this.rowCount===0)return;t=Math.round(t);const i=this.ve,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"rowdefs",this,e,null,t,null),this.u()}}zA(t,i){const e=this.ve;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.u()}}get Je(){return this.B===null&&(this.B=new TablePanelSettings),this.B.Je}get columnCount(){return this.B===null?0:this.Je.length}getColumnDefinition(t){Debug&&Util.r(t,Panel,"getColumnDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"getColumnDefinition:idx"),t=Math.round(t);const i=this.Je;if(i[t]===void 0){const e=new RowColumnDefinition;e.Ma(this),e.isRow=!1,e.index=t,i[t]=e,this.raiseChangedEvent(3,"coldefs",this,null,e,null,t)}return i[t]}removeColumnDefinition(t){if(Debug&&Util.r(t,Panel,"removeColumnDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"removeColumnDefinition:idx"),this.columnCount===0)return;t=Math.round(t);const i=this.Je,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"coldefs",this,e,null,t,null),this.u()}}XA(t,i){const e=this.Je;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.u()}}addRowColumnDefinition(t){let i=null;return t.isRow?i=this.getRowDefinition(t.index):t.isRow||(i=this.getColumnDefinition(t.index)),i&&i.Z1(t),this}addRowDefinition(t,i){const e=this.getRowDefinition(t);return e&&e.Z1(new RowColumnDefinition(i)),this}addColumnDefinition(t,i){const e=this.getColumnDefinition(t);return e&&e.Z1(new RowColumnDefinition(i)),this}get rowSizing(){return this.B!==null?this.B.wp:3}set rowSizing(t){const i=this.rowSizing;i!==t&&(Debug&&t!==3&&t!==2&&Util.n("Panel.rowSizing must be ProportionalExtra or None, not: "+t),this.B===null&&(this.B=new TablePanelSettings),this.B.wp=t,this.u(),this.i("rowSizing",i,t))}get columnSizing(){return this.B!==null?this.B.xp:3}set columnSizing(t){const i=this.columnSizing;i!==t&&(Debug&&t!==3&&t!==2&&Util.n("Panel.columnSizing must be ProportionalExtra or None, not: "+t),this.B===null&&(this.B=new TablePanelSettings),this.B.xp=t,this.u(),this.i("columnSizing",i,t))}get topIndex(){return this.B!==null?this.B.bp:0}set topIndex(t){const i=this.topIndex;i!==t&&((!isFinite(t)||t<0)&&Util.n("Panel.topIndex must be greater than zero and a real number, not: "+t),this.B===null&&(this.B=new TablePanelSettings),this.B.bp=t,this.u(),this.i("topIndex",i,t))}get leftIndex(){return this.B!==null?this.B.kp:0}set leftIndex(t){const i=this.leftIndex;i!==t&&((!isFinite(t)||t<0)&&Util.n("Panel.leftIndex must be greater than zero and a real number, not: "+t),this.B===null&&(this.B=new TablePanelSettings),this.B.kp=t,this.u(),this.i("leftIndex",i,t))}findRowForLocalY(t){if(t<0||this.type!==Panel.Table||this.rowCount===0)return-1;let i=0;const e=this.ve,s=e.length;let n=this.topIndex;for(;n{o.fh();const r=o.Ri;if(r!==null){o.k2(!1);const l=r.iterator;for(;l.next();){const h=l.value;h.mode===2&&o.k2(!0);const a=h.sourceName;if(h.isToObject){a==="/"&&n.K2(!0);const f=h.rL(n,o);f!==null&&(i.add(f),f.so===null&&(f.so=new List),f.so.add(h))}t.add(h)}}if(o instanceof Panel&&o.type===Panel.Table){if(o.rowCount>0){const l=o.ve,h=l.length;for(let a=0;a0){const l=o.Je,h=l.length;for(let a=0;a0&&o instanceof Panel){const h=r.substring(0,l),a=r.substring(l+1),f=o.findObject(h);f!==null?(o=f,n.targetProperty=a):(Util.at('Warning: unable to find GraphObject named "'+h+'" for Binding: '+n.toString()),o=null)}if(o instanceof RowColumnDefinition){const h=GSet.gs(o.panel);n.targetId=h===void 0?-1:h,o.panel.eo=n.targetId}else if(o instanceof GraphObject){const h=GSet.gs(o);n.targetId=h===void 0?-1:h,o.eo=n.targetId}else Util.n("Unknown type of binding target: "+o);n.check(o)}}return t.w(),this instanceof Part&&(this.Ae()&&this.ensureBounds(),Debug&&!Panel.RL&&this.walkVisualTreeFrom(this,(n,o)=>{if(o instanceof Panel&&(o.type===Panel.Auto||o.type===Panel.Spot||o.type===Panel.Graduated)&&o.elements.count<=1&&!(o instanceof Part)){let r=!1;if(o.elements.count===1&&(r=o.itemArray!==null,!r)){for(s=t.iterator;s.next();)if(s.value.targetProperty==="itemArray"){r=!0;break}}r||(Util.at("Auto, Spot, or Graduated Panel should not have zero or one elements: "+o.toString()+" in "+n.toString()),Panel.RL=!0)}})),this}static RL=!1;copyTemplate(t){t===void 0&&(t=!1);const i=this.copy();return i.pI(e=>{e instanceof Panel&&(e.Ws=null,e.si=null);const s=e.Ri;s!==null&&(e.Ri=null,s.each(o=>e.bind(o.copy())));const n=e.Ss;n!==null&&(e.Ss=null,n.each(o=>e.trigger(o.value.copy())))}),t&&i.ci(),i}updateTargetBindings(t){const i=this.Ws;if(i===null)return;t===void 0&&(t="");const e=i.iterator;for(;e.next();){const s=e.value,n=this.IL(s,t);if(n===null)continue;const{data:o,elt:r}=n;s.isToTheme&&this.diagram===null||r!==void 0&&s.updateTarget(r,o)}}Yo(){if(this.diagram!==null)if(this.N2()){const t=this.Ws.iterator;for(;t.next();){const i=t.value;if(!i.isToTheme)continue;const e=this.IL(i);if(e===null)continue;const{data:s,elt:n}=e;n!==void 0&&i.updateTarget(n,s)}}else{const t=this.D.h,i=t.length;for(let e=0;e0;let r=0;for(;n0){const i=this.D.elt(0);if(i.isPanelMain&&i instanceof Panel&&i.nl())return 1}return 0}rebuildItemElements(){const t=this.yp();for(;this.D.length>t;)this.ne(this.D.length-1,!1);this.OL(null,this.itemArray)}OL(t,i){const e=this.yp(),s=i;if(s===null||s.length===0){for(;this.D.length>e;)this.ne(this.D.length-1,!1);return}if(this.D.length<=e){const n=s.length;for(let o=0;o(w[w.Default=1]="Default",w[w.None=2]="None",w[w.ProportionalExtra=3]="ProportionalExtra",w))(Sizing||{});class RowColumnDefinition{Hs;Sp;Vt;Aa;La;ai;mt;Md;ro;Jo;Pd;Nd;Ta;Ft;Cd;Js;ht;Zi;we;constructor(t){GSet.vi(this),this.Hs=null,this.Sp=!0,this.Vt=0,this.we=NaN,this.Aa=0,this.La=1/0,this.ai=Spot.Default,this.ht=0,this.Zi=0,this.mt=0,this.Js=null,this.Md=1,this.ro=1,this.Jo=null,this.Pd=null,this.Nd=NaN,this.Ta=null,this.Ft=null,this.Cd=!1,t&&(Object.assign(this,t),t.column!==void 0?(this.isRow=!1,this.index=t.column):t.row!==void 0&&(this.isRow=!0,this.index=t.row))}copy(){const t=new RowColumnDefinition;return t.Sp=this.Sp,t.Vt=this.Vt,t.we=this.we,t.Aa=this.Aa,t.La=this.La,t.ai=this.ai,t.ht=this.ht,t.Zi=this.Zi,t.mt=this.mt,t.ro=this.ro,t.Md=this.Md,this.Jo===null?t.Jo=null:t.Jo=this.Jo.L(),t.Pd=this.Pd,t.Nd=this.Nd,t.Ta=null,this.Ta!==null&&(t.separatorDashArray=this.separatorDashArray.slice()),t.Ft=this.Ft,t.Cd=this.Cd,t.Js=this.Js,t}Z1(t){t.isRow?this.height=t.height:this.width=t.width,this.minimum=t.minimum,this.maximum=t.maximum,this.alignment=t.alignment,this.stretch=t.stretch,this.sizing=t.sizing,this.Jo=t.separatorPadding===null?null:t.separatorPadding.L(),this.separatorStroke=t.separatorStroke,this.separatorStrokeWidth=t.separatorStrokeWidth,this.Ta=null,t.separatorDashArray&&(this.Ta=t.separatorDashArray.slice()),this.background=t.background,this.coversSeparators=t.coversSeparators,this.Js=t.Js}fi(t){t in Sizing?this.sizing=t:Util.ur(this,t)}toString(){return"RowColumnDefinition "+(this.isRow?"(Row ":"(Column ")+this.index+") #"+GSet.gs(this)}static Default=1;static None=2;static ProportionalExtra=3;Ma(t){this.Hs=t}computeEffectiveSpacingTop(t){let i=0;const e=this.Hs;if(this.index!==t){let n=this.separatorStroke;n===null&&e!==null&&(n=this.isRow?e.defaultRowSeparatorStroke:e.defaultColumnSeparatorStroke),n!==null&&(i=this.separatorStrokeWidth,isNaN(i)&&(e!==null?i=this.isRow?e.defaultRowSeparatorStrokeWidth:e.defaultColumnSeparatorStrokeWidth:i=0))}let s=this.Jo;if(s===null)if(e!==null)s=e.defaultSeparatorPadding;else return i;return i+(this.isRow?s.top:s.left)}computeEffectiveSpacing(){let t=0;const i=this.Hs;let e=0;const s=this.isRow;if(i!==null&&i.type===Panel.Table){const o=s?i.ve.length:i.Je.length;for(let r=0;r= 0",RowColumnDefinition,"height"),this.we=t,this.actual=this.ht,this.panel!==null&&this.panel.u(),this.i("height",i,t))}get width(){return this.we}set width(t){const i=this.we;i!==t&&(Debug&&Util.t(t,"number",RowColumnDefinition,"width"),t<0&&Util.G(t,">= 0",RowColumnDefinition,"width"),this.we=t,this.actual=this.ht,this.panel!==null&&this.panel.u(),this.i("width",i,t))}get minimum(){return this.Aa}set minimum(t){const i=this.Aa;i!==t&&(Debug&&Util.t(t,"number",RowColumnDefinition,"minimum"),(t<0||!isFinite(t))&&Util.G(t,">= 0",RowColumnDefinition,"minimum"),this.Aa=t,this.actual=this.ht,this.panel!==null&&this.panel.u(),this.i("minimum",i,t))}get maximum(){return this.La}set maximum(t){const i=this.La;i!==t&&(Debug&&Util.t(t,"number",RowColumnDefinition,"maximum"),t<0&&Util.G(t,">= 0",RowColumnDefinition,"maximum"),this.La=t,this.actual=this.ht,this.panel!==null&&this.panel.u(),this.i("maximum",i,t))}get alignment(){return this.ai}set alignment(t){const i=this.ai;i.equals(t)||(Debug&&Util.s(t,Spot,RowColumnDefinition,"alignment"),this.ai=t.L(),this.panel!==null&&this.panel.u(),this.i("alignment",i,t))}get stretch(){return this.ro}set stretch(t){const i=this.ro;i!==t&&(this.ro=t,this.panel!==null&&this.panel.u(),this.i("stretch",i,t))}get separatorPadding(){return this.Jo}set separatorPadding(t){typeof t=="number"?t=new Margin(t):t!==null&&Debug&&Util.s(t,Margin,RowColumnDefinition,"separatorPadding");const i=this.Jo;(t===null||i===null||!i.equals(t))&&(t!==null&&(t=t.L()),this.Jo=t,this.panel!==null&&this.panel.u(),this.i("separatorPadding",i,t))}get separatorStroke(){return this.Pd}set separatorStroke(t){const i=this.Pd;i!==t&&(t!==null&&Brush.ud(t,"RowColumnDefinition.separatorStroke"),t instanceof Brush&&t.w(),this.Pd=t,this.panel!==null&&this.panel.u(),this.i("separatorStroke",i,t))}get separatorStrokeWidth(){return this.Nd}set separatorStrokeWidth(t){const i=this.Nd;i!==t&&(this.Nd=t,this.panel!==null&&this.panel.u(),this.i("separatorStrokeWidth",i,t))}get separatorDashArray(){return this.Ta}set separatorDashArray(t){const i=this.Ta;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Vi(t,"Array",RowColumnDefinition,"separatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("separatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.Ta=t,this.panel!==null&&this.panel.T(),this.i("separatorDashArray",i,t)}}get background(){return this.Ft}set background(t){const i=this.Ft;i!==t&&(t!==null&&Brush.ud(t,"RowColumnDefinition.background"),t instanceof Brush&&t.w(),this.Ft=t,this.panel!==null&&this.panel.T(),this.i("background",i,t))}get coversSeparators(){return this.Cd}set coversSeparators(t){const i=this.Cd;i!==t&&(Util.t(t,"boolean",RowColumnDefinition,"coversSeparators"),this.Cd=t,this.panel!==null&&this.panel.T(),this.i("coversSeparators",i,t))}get sizing(){return this.Md}set sizing(t){const i=this.Md;i!==t&&(Debug&&Util.tt(t,Sizing,"Sizing"),this.Md=t,this.panel!==null&&this.panel.u(),this.i("sizing",i,t))}eb(){if(this.sizing===1){const t=this.Hs;return this.isRow?t.rowSizing:t.columnSizing}return this.sizing}get actual(){return this.ht}set actual(t){isNaN(this.we)?this.ht=Math.max(Math.min(this.La,t),this.Aa):this.ht=Math.max(Math.min(this.La,this.we),this.Aa)}get measured(){return this.Zi}set measured(t){this.Zi=t}get total(){return this.ht+this.computeEffectiveSpacing()}get position(){return this.mt}set position(t){this.mt=t}bind(t,i,e,s){return this.hc(t,i,e,s),this}bindTwoWay(t,i,e,s){const n=this.hc(t,i,e,s);return s===void 0&&n.makeTwoWay(),this}theme(t,i,e,s,n){return this.mh(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.mh(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.mh(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.mh(t,i,e,s,n).ofModel(),this}hc(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.Z0(n),n}mh(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.Z0(o),o}Z0(t){t.Ce=this;const i=this.panel;if(i!==null){const e=i.findBindingPanel();e!==null&&e.wL()&&Util.n("Cannot add a Binding to a RowColumnDefinition that is already frozen: "+t+" on "+i)}this.Js===null&&(this.Js=new List),this.Js.add(t)}}class Shape extends GraphObject{yt;Ps;Ad;Da;$i;Zo;jo;Rt;Ld;Td;_;constructor(t,i){super(),this.yt=null,this.Ps=null,this.Ad="None",this.Da="black",this.$i="black",this.Zo=1,this.jo=null,this.Rt=null,this.Ld=NaN,this.Td=NaN,this._=null,typeof t=="string"?this.figure=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.yt=this.yt,t.Ps=this.Ps,t.Ad=this.Ad,t.Da=this.Da,t.$i=this.$i,t.Zo=this.Zo,this.jo!==null&&(t.jo=this.jo.slice()),this.Rt!==null&&(this.Rt.wi?t.Rt=this.Rt:t.Rt=this.Rt.copy()),t.Ld=this.Ld,t.Td=this.Td,this._!==null&&(t._=this._.copy())}Fa(){this.Rt===null?this.Rt=new ShapeTemplateSettings:this.Rt.wi&&(this.Rt=this.Rt.copy())}fh(){super.fh(),this.Rt!==null&&(this.Rt.wi=!0)}fi(t){t in GeometryStretch?this.geometryStretch=t:super.fi(t)}toString(){return"Shape("+(this.figure!=="None"?this.figure:this.toArrow!=="None"?this.toArrow:this.fromArrow)+")#"+GSet.gs(this)}MI(t,i){const e=this.pathPattern;e.wt(1/0,1/0);const s=e.measuredBounds;e.qt(0,0,s.width,s.height);const n=this.geometry;t.save(),t.beginPath();const o=Util.ft();if(n.type===1)o.push(n.startX),o.push(n.startY),o.push(n.endX),o.push(n.endY),this.Dd(t,i,o,e);else if(n.type===4){const r=n.figures.iterator;for(;r.next();){const l=r.value;o.length=0,o.push(l.startX),o.push(l.startY);let h=l.startX,a=l.startY,f=h,c=a;const u=l.segments.h,d=u.length;for(let m=0;m=.1;){if(P===0&&(M?(b=k,b-=S,y-=S,M=!1):b=k,b===0&&(b=1)),b>y){b=y,Util.nt(x);return}b>p?(P=b-p,b=p):P=0;let N=Math.sqrt(b*b/(1+m*m));if(u<0&&(N=-N),h+=N,a+=m*N,t.translate(h,a),t.rotate(g),t.translate(-(r/2),-(l/2)),P===0&&s.gh(t,i),t.translate(r/2,l/2),t.rotate(-g),t.translate(-h,-a),y-=b,p-=b,P!==0){if(A++,A===x.length){Util.nt(x);return}C=x[A],u=C[0],g=C[1],m=C[2],p=C[3],b=P}}Util.nt(x)}gh(t,i){const e=t instanceof SVGContext;let s=this.$i;const n=this.Da;if(s===null&&n===null)return;const o=this.yt;if(o===null)return;t.commitTransform();const r=this.actualBounds,l=this.naturalBounds;n!==null&&this.wn(t,n,!0,!1,l,r);const h=this.part;let a=this.Zo;s!==null&&a===0&&h!==null&&(this.isPanelMain||h.findMainElement()===this)&&(a=h.CI()),a===0&&(s=null),s!==null&&a!==0&&(this.wn(t,s,!1,!1,l,r),t.lineWidth=a,t.lineJoin=this.strokeJoin,t.lineCap=this.strokeCap,t.miterLimit=this.strokeMiterLimit);let f=!1;h&&i.getRenderingHint("drawShadows")&&(f=h.isShadowed),t.ol===!1&&(f=!1);let c=!0;s!==null&&(n===null||n==="transparent")&&(c=!1);let u=!1;const d=this.strokeDashArray;if(d!==null&&(u=!0,t.enableDash(d,this.strokeDashOffset)),o.type===1)t.beginPath(),t.moveTo(o.startX,o.startY),t.lineTo(o.endX,o.endY),s!==null&&t.strokeContext(),t.endPath();else if(o.type===2){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.min(m,p),k=Math.min(g,y),b=Math.abs(p-m),S=Math.abs(y-g);t.beginPath(),t.rect(x,k,b,S),n!==null&&t.fillContext(n,!1,null),s!==null&&(c&&f&&t.shadowsOff(),t.strokeContext(),c&&f&&t.shadowsOn()),t.endPath()}else if(o.type===3){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.abs(p-m)/2,k=Math.abs(y-g)/2,b=Math.min(m,p)+x,S=Math.min(g,y)+k;t.beginPath(),t.moveTo(b,S-k),t.bezierCurveTo(b+Geo.Un*x,S-k,b+x,S-Geo.Un*k,b+x,S),t.bezierCurveTo(b+x,S+Geo.Un*k,b+Geo.Un*x,S+k,b,S+k),t.bezierCurveTo(b-Geo.Un*x,S+k,b-x,S+Geo.Un*k,b-x,S),t.bezierCurveTo(b-x,S-Geo.Un*k,b-Geo.Un*x,S-k,b,S-k),t.closePath(),n!==null&&t.fillContext(n,!1,null),s!==null&&(c&&f&&t.shadowsOff(),t.strokeContext(),c&&f&&t.shadowsOn()),t.endPath()}else if(o.type===4){const m=o.figures,g=m.length;for(let p=0;p1||this.pathPattern!==null?!0:super.fd(t)}p2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("path");for(let s=0;s1,i);Util.n("Unknown Geometry type: "+e.type)}}ld(t,i,e,s){const n=this.desiredSize,o=this.Zo;t=Math.max(t,0),i=Math.max(i,0);let r;if(this.Ps!==null)r=this.geometry.bounds;else{const g=this.figure;let p=Shape.q2[g];if(p===void 0){let y=Geo.qn[g];typeof y=="string"&&(y=Geo.qn[y]),typeof y=="function"?(p=y(null,100,100),Shape.q2[g]=p):Util.n("Unsupported Figure: "+g)}r=p.bounds}let l=r.width,h=r.height,a=r.width,f=r.height;switch(this.qs(!0)){case 0:e=0,s=0;break;case 2:a=Math.max(t-o,0),f=Math.max(i-o,0);break;case 5:a=Math.max(t-o,0),s=0;break;case 4:e=0,f=Math.max(i-o,0);break}isFinite(n.width)&&(a=n.width),isFinite(n.height)&&(f=n.height);const u=this.maxSize,d=this.minSize;e=Math.max(e-o,d.width),s=Math.max(s-o,d.height),a=Math.min(u.width,a),f=Math.min(u.height,f),a=isFinite(a)?Math.max(e,a):Math.max(l,e),f=isFinite(f)?Math.max(s,f):Math.max(h,s);const m=this.lM();switch(m){case 0:break;case 2:l=a,h=f;break;case 6:{let g=Math.min(a/l,f/h);isFinite(g)||(g=1),l=l*g,h=h*g;break}default:Util.n(m+" is not a valid geometryStretch.")}if(this.Ps!==null){l===0&&(l=.001),h===0&&(h=.001);const p=(this.Ps!==null?this.Ps:this.yt).$D(l,h);Debug&&p.w(),this.yt=p}else(this.yt===null||!Geo.q(this.yt.ff,t-o)||!Geo.q(this.yt.cf,i-o))&&(this.yt=Shape.AI(this,l,h));r=this.yt.bounds,t===1/0||i===1/0?this.no(r.x-o/2,r.y-o/2,t===0&&l===0?0:r.width+o,i===0&&h===0?0:r.height+o):this.no(-(o/2),-(o/2),a+o,f+o),n.isReal()?(a=n.width,f=n.height,a=Math.min(u.width,a),f=Math.min(u.height,f),a=Math.max(d.width,a),f=Math.max(d.height,f),this.Hi.e(0,0,a,f)):this.Hi.c(r)}lM(){const t=this.geometryStretch;return this.Ps!==null?t===1?2:t:t===1?Shape.q2[this.figure].defaultStretch:t}uh(t,i,e,s){this.commonArrange(t,i,e,s)}getNearestIntersectionPoint(t,i,e){return this.sc(t.x,t.y,i.x,i.y,e)}sc(t,i,e,s,n){const o=this.O,r=1/(o.m11*o.m22-o.m12*o.m21),l=o.m22*r,h=-o.m12*r,a=-o.m21*r,f=o.m11*r,c=r*(o.m21*o.dy-o.m22*o.dx),u=r*(o.m12*o.dx-o.m11*o.dy),d=t*l+i*a+c,m=t*h+i*f+u,g=e*l+s*a+c,p=e*h+s*f+u,y=this.Zo/2;let x=this.yt;x===null&&(this.wt(1/0,1/0),x=this.yt);const k=x.bounds;let b=!1;if(x.type===1)if(this.strokeWidth<=1.5)b=Geo.Hn(x.startX,x.startY,x.endX,x.endY,d,m,g,p,n);else{let S=0,M=0;if(x.startX===x.endX)S=y,M=0;else{const T=(x.endY-x.startY)/(x.endX-x.startX);M=y/Math.sqrt(1+T*T),S=M*T}const A=Util.ft();let C=new Point;Geo.Hn(x.startX+S,x.startY+M,x.endX+S,x.endY+M,d,m,g,p,C)&&A.push(C),C=new Point,Geo.Hn(x.startX-S,x.startY-M,x.endX-S,x.endY-M,d,m,g,p,C)&&A.push(C),C=new Point,Geo.Hn(x.startX+S,x.startY+M,x.startX-S,x.startY-M,d,m,g,p,C)&&A.push(C),C=new Point,Geo.Hn(x.endX+S,x.endY+M,x.endX-S,x.endY-M,d,m,g,p,C)&&A.push(C);const P=A.length;if(P===0)return Util.nt(A),!1;b=!0;let N=1/0;for(let T=0;T0&&k.contains(D,F)&&(P.x=D,P.y=F,this.containsPoint(P)))for(N!==0&&Math.abs(N)<.5?(T*=.5/N,N=.5):T!==0&&Math.abs(T)<.5&&(N*=.5/T,T=.5),D-=N,F-=T;k.contains(D,F);)D-=N,F-=T;const R=.6;n.x=g,n.y=p;for(let K=0;Ke?t-e:e-t)<(i>s?i-s:s-i)){const c=ic||Geo.q(h.y,c))&&(h.yc||Geo.q(h.x,c))&&(h.x=a&&h<=f}else{let a=0,f=0;return s=a&&l<=f}}DI(t,i){if(this.containedInRect(t,i)||i===void 0&&(i=this.O,t.containsRect(this.actualBounds)))return!0;const e=t.left,s=t.right,n=t.top,o=t.bottom,r=Point.a(),l=Point.a(),h=Point.a(),a=Transform.a();a.set(i),a.yC(this.O),a.Pw(),l.x=s,l.y=n,l.O(a),r.x=e,r.y=n,r.O(a);let f=!1;return this.Ra(r,l,h)?f=!0:(r.x=s,r.y=o,r.O(a),this.Ra(r,l,h)?f=!0:(l.x=e,l.y=o,l.O(a),this.Ra(r,l,h)?f=!0:(r.x=e,r.y=n,r.O(a),this.Ra(r,l,h)&&(f=!0)))),Transform.o(a),Point.o(r),Point.o(l),Point.o(h),f}hL(t,i,e){if(e&&this.fill!==null&&this.ch(t,!0))return!0;let s=t.distanceSquaredPoint(i);const n=s;this.strokeWidth>1.5&&(s=this.strokeWidth/2+Math.sqrt(s),s*=s);let o=this.yt;if(o===null&&(this.wt(1/0,1/0),o=this.yt,o===null))return!1;if(!e){const c=o.bounds,u=c.x,d=c.y,m=c.x+c.width,g=c.y+c.height;if(Point.distanceSquared(t.x,t.y,u,d)<=s&&Point.distanceSquared(t.x,t.y,m,d)<=s&&Point.distanceSquared(t.x,t.y,u,g)<=s&&Point.distanceSquared(t.x,t.y,m,g)<=s)return!0}function r(c,u){const d=c.length;for(let m=0;ms)return!0;return!1}const l=o.startX,h=o.startY,a=o.endX,f=o.endY;if(o.type===1){const c=Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,f),u=(a-l)*(t.x-l)+(f-h)*(t.y-h),d=(l-a)*(t.x-a)+(h-f)*(t.y-f),m=u>=0&&d>=0?s:n;return c<=m}else if(o.type===2){let c=!1;return e&&(c=Point.distanceLineSegmentSquared(t.x,t.y,l,h,l,f)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,h)<=s||Point.distanceLineSegmentSquared(t.x,t.y,a,h,a,f)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,f,a,f)<=s),c}else if(o.type===3){const c=(l+a)/2,u=(h+f)/2,d=t.x-c,m=t.y-u,g=Math.abs(a-l)/2,p=Math.abs(f-h)/2;if(g===0||p===0)return Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,f)<=s;if(e){const y=Geo.UD(g,p,d,m);return y*y<=s}else return!(Point.distanceSquared(d,m,-g,0)>=s||Point.distanceSquared(d,m,0,-p)>=s||Point.distanceSquared(d,m,0,p)>=s||Point.distanceSquared(d,m,g,0)>=s)}else if(o.type===4){const c=o.bounds,u=c.x,d=c.y,m=c.x+c.width,g=c.y+c.height;if(t.x>m&&t.xg&&t.ys&&Point.distanceLineSegmentSquared(t.x,t.y,u,d,m,d)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,u,g)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,m,d)>s)return!1;const p=Math.sqrt(s);if(e){if(this.fill===null?o.LC(t.x,t.y,p):o.vk(t,p,!0,!1))return!0}else{const y=o.figures;for(let x=0;xs)return!1;const M=k.segments.h,A=M.length;for(let C=0;Cs)return!1;break;case 3:{const N=Util.ft();Geo.Gn(b,S,P.point1X,P.point1Y,P.point2X,P.point2Y,P.endX,P.endY,.8,N);const T=r(N,t);if(Util.nt(N),T||(b=P.endX,S=P.endY,t.distanceSquared(b,S)>s))return!1;break}case 4:{const N=Util.ft();Geo.jg(b,S,P.point1X,P.point1Y,P.endX,P.endY,.8,N);const T=r(N,t);if(Util.nt(N),T||(b=P.endX,S=P.endY,t.distanceSquared(b,S)>s))return!1;break}case 5:case 6:{const N=P.type===5?P.To(k):P.Xh(k,b,S),T=N.length;if(T===0){if(b=P.type===5?P.centerX:P.endX,S=P.type===5?P.centerY:P.endY,t.distanceSquared(b,S)>s)return!1;break}let L=null;const D=Util.ft();for(let F=0;F=0){this.Zo=t,this.u();const e=this.part;e!==null&&e.mc(),this.i("strokeWidth",i,t)}else Util.G(t,"value >= 0",Shape,"strokeWidth:value")}U1(){return this.Zo}get strokeCap(){return this.Rt!==null?this.Rt.Mp:"butt"}set strokeCap(t){const i=this.strokeCap;i!==t&&(typeof t=="string"&&(t==="butt"||t==="round"||t==="square")?(this.Fa(),this.Rt.Mp=t,this.T(),this.i("strokeCap",i,t)):Util.G(t,'"butt", "round", or "square"',Shape,"strokeCap"))}get strokeJoin(){return this.Rt!==null?this.Rt.Pp:"miter"}set strokeJoin(t){const i=this.strokeJoin;i!==t&&(typeof t=="string"&&(t==="miter"||t==="bevel"||t==="round")?(this.Fa(),this.Rt.Pp=t,this.T(),this.i("strokeJoin",i,t)):Util.G(t,'"miter", "bevel", or "round"',Shape,"strokeJoin"))}get strokeMiterLimit(){return this.Rt!==null?this.Rt.Np:10}set strokeMiterLimit(t){const i=this.strokeMiterLimit;if(i!==t)if(Debug&&Util.r(t,Shape,"strokeMiterLimit"),t>=1){this.Fa(),this.Rt.Np=t,this.T();const e=this.part;e!==null&&e.mc(),this.i("strokeMiterLimit",i,t)}else Debug&&Util.G(t,"value >= 1",Shape,"strokeWidth:value")}get strokeDashArray(){return this.jo}set strokeDashArray(t){const i=this.jo;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Vi(t,"Array",Shape,"strokeDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("strokeDashArray:value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.jo=t,this.T(),this.i("strokeDashArray",i,t)}}get strokeDashOffset(){return this.Rt!==null?this.Rt.ph:0}set strokeDashOffset(t){const i=this.strokeDashOffset;i!==t&&(Debug&&Util.r(t,Shape,"strokeDashOffset"),t>=0&&(this.Fa(),this.Rt.ph=t,this.T(),this.i("strokeDashOffset",i,t)))}get figure(){return this.Ad}set figure(t){const i=this.Ad;if(i!==t){Debug&&Util.t(t,"string",Shape,"figure");let e=Geo.qn[t];if(typeof e=="function"?e=t:(e=Geo.qn[t.toLowerCase()],e||Util.n("Unknown Shape.figure: "+t)),i!==e){const s=this.part;s!==null&&s.mc(),this.Ad=e,this.Ps=null,this.re(),this.u(),this.i("figure",i,e)}}}get toArrow(){return this.Ut!==null?this.Ut.Cp:"None"}set toArrow(t){const i=this.toArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){Debug&&Util.t(t,"string",Shape,"toArrow");const e=Shape.BL(t);e===null?Util.n("Unknown Shape.toArrow: "+t):i!==e&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.Cp=e,this.Ps=null,this.re(),this.u(),this.zL(e),this.i("toArrow",i,e))}}get fromArrow(){return this.Ut!==null?this.Ut.Ap:"None"}set fromArrow(t){const i=this.fromArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){Debug&&Util.t(t,"string",Shape,"fromArrow");const e=Shape.BL(t);e===null?Util.n("Unknown Shape.fromArrow: "+t):i!==e&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.Ap=e,this.Ps=null,this.re(),this.u(),this.zL(e),this.i("fromArrow",i,e))}}zL(t){const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;this.KR();const e=Spot.MiddleRight;this.toArrow!=="None"?(this.segmentIndex=-1,this.alignmentFocus=e):this.fromArrow!=="None"&&(this.segmentIndex=0,this.alignmentFocus=new Spot(1-e.x,e.y))}get spot1(){return this.Rt!==null?this.Rt.jn:Spot.Default}set spot1(t){Util.s(t,Spot,Shape,"spot1");const i=this.spot1;i.equals(t)||(t=t.L(),this.Fa(),this.Rt.jn=t,this.u(),this.i("spot1",i,t))}get spot2(){return this.Rt!==null?this.Rt.Wn:Spot.Default}set spot2(t){Util.s(t,Spot,Shape,"spot2");const i=this.spot2;i.equals(t)||(t=t.L(),this.Fa(),this.Rt.Wn=t,this.u(),this.i("spot2",i,t))}get parameter1(){return this.Ld}set parameter1(t){const i=this.Ld;i!==t&&(this.Ld=t,this.re(),this.u(),this.i("parameter1",i,t))}get parameter2(){return this.Td}set parameter2(t){const i=this.Td;i!==t&&(this.Td=t,this.re(),this.u(),this.i("parameter2",i,t))}get naturalBounds(){return this.Hi}lI(){const t=this.desiredSize;if(!t.isReal()&&this.yt!==null){const i=this.yt.bounds;this.Hi.c(i)}else this.Hi.e(0,0,t.width,t.height)}get pathPattern(){return this.Rt!==null?this.Rt.Lp:null}set pathPattern(t){const i=this.pathPattern;i!==t&&(Debug&&t!==null&&Util.s(t,GraphObject,Shape,"pathPattern"),this.Fa(),this.Rt.Lp=t,this.T(),this.i("pathPattern",i,t))}get geometryStretch(){return this.Rt!==null?this.Rt.Tp:1}set geometryStretch(t){const i=this.geometryStretch;i!==t&&(Util.tt(t,GeometryStretch,"GeometryStretch"),this.Fa(),this.Rt.Tp=t,this.u(),this.i("geometryStretch",i,t))}get interval(){return this._!==null?this._.yc:1}set interval(t){const i=this.interval;if(Debug&&Util.r(t,Shape,"interval"),t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this._===null&&(this._=new GradElementSettings),this._.yc=t;const e=this.diagram;e!==null&&this.panel===e.grid&&e.Zr(),this.u();const s=this.panel;s!==null&&(s.as=null),this.i("interval",i,t)}}get graduatedStart(){return this._!==null?this._.wc:0}set graduatedStart(t){const i=this.graduatedStart;Debug&&Util.r(t,Shape,"graduatedStart"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.wc=t,this.u(),this.i("graduatedStart",i,t))}get graduatedEnd(){return this._!==null?this._.xc:1}set graduatedEnd(t){const i=this.graduatedEnd;Debug&&Util.r(t,Shape,"graduatedEnd"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.xc=t,this.u(),this.i("graduatedEnd",i,t))}get graduatedSkip(){return this._!==null?this._.bc:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.t(t,"function",Shape,"graduatedSkip"),this._===null&&(this._=new GradElementSettings),this._.bc=t,this.u(),this.i("graduatedSkip",i,t))}static AI(t,i,e){let n=null;if(t.toArrow!=="None")n=Shape.fo[t.toArrow];else if(t.fromArrow!=="None")n=Shape.fo[t.fromArrow];else{let o=Geo.qn[t.figure];typeof o=="string"&&(o=Geo.qn[o]),o===void 0&&Util.n("Unknown Shape.figure: "+t.figure),n=o(t,i,e),n.ff=i,n.cf=e}if(n===null){const o=Geo.qn.Rectangle;typeof o=="function"&&(n=o(t,i,e))}return Debug&&(n.bounds.width>i+1e-5||n.bounds.height>e+1e-5)&&Util.n('Geometry made with figure "'+t.figure+'" has bounds '+n.bounds.toString()+" that are too large for the given size ("+i+","+e+"). See documentation for Shape.defineFigureGenerator."),n}static getFigureGenerators(){const t=new GMap;for(const i in Geo.qn){if(i===i.toLowerCase())continue;const e=Geo.qn[i];t.set(i,e)}return t.w(),t}static defineFigureGenerator(t,i){Util.t(t,"string",Shape,"defineFigureGenerator:name"),typeof i=="string"?Debug&&(i===""||!Geo.qn[i])&&Util.n("Shape.defineFigureGenerator synonym must not be empty or None or not a defined figure name: "+i):Util.t(i,"function",Shape,"defineFigureGenerator:func");const e=t.toLowerCase();Debug&&(t===""||t===e)&&Util.n("Shape.defineFigureGenerator name must not be empty or all-lower-case: "+t);const s=Geo.qn;s[t]=i,s[e]=t}static getArrowheadGeometries(){const t=new GMap;for(const i in Geo.Zg)if(Shape.fo[i]===void 0){const e=Geometry.parse(Geo.Zg[i],!1);Shape.fo[i]=e;const s=i.toLowerCase();s!==i&&(Shape.fo[s]=i)}for(const i in Shape.fo){if(i===i.toLowerCase())continue;const e=Shape.fo[i];e instanceof Geometry&&t.set(i,e)}return t.w(),t}static defineArrowheadGeometry(t,i){Util.t(t,"string",Shape,"defineArrowheadGeometry:name");let e=null;typeof i=="string"?(Util.t(i,"string",Shape,"defineArrowheadGeometry:pathstr"),e=Geometry.parse(i,!1)):(Util.s(i,Geometry,Shape,"defineArrowheadGeometry:pathstr"),e=i);const s=t.toLowerCase();(Debug&&t===""||s==="none"||t===s)&&Util.n("Shape.defineArrowheadGeometry name must not be empty or None or all-lower-case: "+t);const n=Shape.fo;n[t]=e,n[s]=t}static fo=new PropertyCollection;static q2=new PropertyCollection;static BL(t){let i=Shape.fo[t];if(i===void 0){const e=t.toLowerCase();if(e==="none")return"None";if(i=Shape.fo[e],i===void 0){let s=null;for(const n in Geo.Zg)if(n.toLowerCase()===e){s=n;break}if(s!==null){const n=Geometry.parse(Geo.Zg[s],!1);return Shape.fo[s]=n,e!==s&&(Shape.fo[e]=s),s}}}return typeof i=="string"?i:i instanceof Geometry?t:null}}class ShapeTemplateSettings{wi;Mp;Pp;Np;ph;Lp;Tp;jn;Wn;constructor(){this.wi=!1,this.Mp="butt",this.Pp="miter",this.Np=10,this.ph=0,this.Lp=null,this.Tp=1,this.jn=Spot.Default,this.Wn=Spot.Default}copy(){const t=new ShapeTemplateSettings;return t.Mp=this.Mp,t.Pp=this.Pp,t.Np=this.Np,t.ph=this.ph,t.Lp=this.Lp,t.Tp=this.Tp,t.jn=this.jn.L(),t.Wn=this.Wn.L(),t}}var Wrap=(w=>(w[w.None=0]="None",w[w.Fit=1]="Fit",w[w.DesiredSize=2]="DesiredSize",w[w.BreakAll=3]="BreakAll",w))(Wrap||{}),TextOverflow=(w=>(w[w.Clip=0]="Clip",w[w.Ellipsis=1]="Ellipsis",w))(TextOverflow||{}),TextFormat=(w=>(w[w.Trim=0]="Trim",w[w.None=1]="None",w))(TextFormat||{});class TextBlock extends GraphObject{ui;$i;Cn;Fe;xi;C0;Fd;_;$;Ol;co;An;Re;Oi;Ln;constructor(t,i){return super(),this.l|=2097152,this.ui="",this.$i="black",this.Cn="13px sans-serif",this.Fe=0,this.xi=0,this.C0=0,this.Fd=null,this._=null,this.$=null,this.Ol=0,this.co=null,this.An=0,this.Re=null,this.Oi=null,this.Ln=null,typeof t=="string"?this.text=t:t&&Object.assign(this,t),i&&Object.assign(this,i),this}cloneProtected(t){super.cloneProtected(t),t.ui=this.ui,t.$i=this.$i,t.Cn=this.Cn,t.Fe=this.Fe,t.xi=this.xi,t.C0=this.C0,t.Fd=this.Fd,this._!==null&&(t._=this._.copy()),this.$!==null&&(this.$.wi?t.$=this.$:t.$=this.$.copy()),t.Ol=this.Ol,t.co=this.co,t.An=this.An,t.Re=this.Re,t.Oi=this.Oi,t.Ln=this.Ln}Tn(){this.$===null?this.$=new TextBlockTemplateSettings:this.$.wi&&(this.$=this.$.copy())}fh(){super.fh(),this.$!==null&&(this.$.wi=!0)}gI(t){this.l=t.l|2048|4096,this._t=t.opacity,this.Ft=t.background,this.qe=t.desiredSize.L(),this.minSize=t.minSize.L(),this.maxSize=t.maxSize.L(),t.Pi!==null?this.Pi=t.Pi.copy():this.Pi=null,this.lt=t.scale,this.jt=t.angle,this.stretch=t.stretch,this.el=t.margin.L(),this.ai=t.alignment.L(),this.tc=t.alignmentFocus.L(),this.segmentFraction=t.segmentFraction,this.segmentOffset=t.segmentOffset.L(),this.segmentOrientation=t.segmentOrientation,t.hi!==null&&(this.hi=t.hi.copy()),this.shadowVisible=t.shadowVisible,this.ui=t.ui,this.$i=t.$i,this.Cn=t.Cn,this._!==null&&(this._=t._.copy()),t.$!==null&&(t.$.wi?this.$=t.$:this.$=t.$.copy()),this.Ol=t.Ol}uI(t){if(this.ui=t.text||"",this.jt=t.labelAngle||0,this.Fe=t.lineCount||0,this.FI(t.lines),t.naturalBounds&&(this.Hi=t.naturalBounds),t.actualBounds){const i=t.actualBounds;this.qt(i.x,i.y,i.width,i.height)}}fi(t){t in Wrap?this.wrap=t:super.fi(t)}toString(){return this.ui.length>22?'TextBlock("'+this.ui.substring(0,20)+'"...)':'TextBlock("'+this.ui+'")'}static getEllipsis(){return TextBlock.Dp}static setEllipsis(t){TextBlock.Dp=t,TextBlock.ab=new PropertyCollection,TextBlock.j2=0}static getBaseline(){return TextBlock.fb}static setBaseline(t){TextBlock.fb=t}static fb=null;static getUnderline(){return TextBlock.cb}static setUnderline(t){TextBlock.cb=t}static cb=null;static None=0;static WrapFit=1;static WrapDesiredSize=2;static WrapBreakAll=3;static OverflowClip=0;static OverflowEllipsis=1;static FormatTrim=0;static FormatNone=1;u(){super.u()}get font(){return this.Cn}set font(t){const i=this.Cn;i!==t&&(Debug&&(Util.t(t,"string",TextBlock,"font"),TextBlock.isValidFont(t)||Util.n('Not a valid font: "'+t+'"')),this.Cn=t,this.co=null,this.u(),this.i("font",i,t))}static isValidFont(t){return root.CSS?root.CSS.supports("font",t):!0}get text(){return this.ui}set text(t){const i=this.ui;t!=null?t=t.toString():t="",i!==t&&(this.ui=t,this.u(),this.i("text",i,t),this.hs(!0))}get textAlign(){return this.$!==null?this.$.Fp:"start"}set textAlign(t){const i=this.textAlign;i!==t&&(Debug&&Util.t(t,"string",TextBlock,"textAlign"),t==="start"||t==="end"||t==="left"||t==="right"||t==="center"?(this.Tn(),this.$.Fp=t,this.T(),this.i("textAlign",i,t)):Debug&&Util.G(t,'"start", "end", "left", "right", or "center"',TextBlock,"textAlign"))}get flip(){return this.$!==null?this.$.uo:0}set flip(t){const i=this.flip;i!==t&&(Util.tt(t,Flip,"Flip"),this.Tn(),this.$.uo=t,this.T(),this.i("flip",i,t))}get verticalAlignment(){return this.$!==null?this.$.hl:Spot.Top}set verticalAlignment(t){const i=this.verticalAlignment;i.equals(t)||(Debug&&(Util.s(t,Spot,TextBlock,"verticalAlignment"),t.isNoSpot()&&Util.n("TextBlock.verticalAlignment for "+this+" must be a real Spot, not:"+t)),t=t.L(),this.Tn(),this.$.hl=t,this.lc(),this.i("verticalAlignment",i,t))}get naturalBounds(){if(!this.Hi.isReal()){const t=Size.a();this.W2(this.ui,999999,t);let i=t.width;Size.o(t);let e=this.XL(i);const s=this.desiredSize;isNaN(s.width)||(i=s.width),isNaN(s.height)||(e=s.height),this.Hi.Kn(i,e)}return this.Hi}get isMultiline(){return(this.l&2097152)!==0}set isMultiline(t){const i=(this.l&2097152)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"isMultiline"),this.l=this.l^2097152,this.u(),this.i("isMultiline",i,t))}get isUnderline(){return(this.l&4194304)!==0}set isUnderline(t){const i=(this.l&4194304)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"isUnderline"),this.l=this.l^4194304,this.hs(!0),this.T(),this.i("isUnderline",i,t))}get isStrikethrough(){return(this.l&8388608)!==0}set isStrikethrough(t){const i=(this.l&8388608)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"isStrikethrough"),this.l=this.l^8388608,this.hs(!0),this.T(),this.i("isStrikethrough",i,t))}get wrap(){return this.$!==null?this.$.Rp:2}set wrap(t){const i=this.wrap;i!==t&&(Debug&&Util.tt(t,Wrap,"Wrap"),this.Tn(),this.$.Rp=t,this.u(),this.i("wrap",i,t))}get overflow(){return this.$!==null?this.$.Ip:0}set overflow(t){const i=this.overflow;i!==t&&(Debug&&Util.tt(t,TextOverflow,"Overflow"),this.Tn(),this.$.Ip=t,this.u(),this.i("overflow",i,t))}get isOverflowed(){return(this.l&16777216)!==0}v2(t){t?this.l|=16777216:this.l&=-16777217}get stroke(){return this.$i}set stroke(t){const i=this.$i;i!==t&&(t!==null&&Brush.ud(t,"TextBlock.stroke"),t instanceof Brush&&t.w(),this.$i=t,this.T(),this.i("stroke",i,t))}get lineCount(){return this.Fe}get lineHeight(){return this.Op()}get editable(){return(this.l&1048576)!==0}set editable(t){const i=(this.l&1048576)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"editable"),this.l=this.l^1048576,this.i("editable",i,t))}get B2(){return(this.l&33554432)!==0}set B2(t){this.l=this.l^33554432}get textEditor(){return this.$!==null?this.$.Ep:null}set textEditor(t){const i=this.textEditor;i!==t&&(Debug&&!(t instanceof HTMLInfo)&&Util.n("TextBlock.textEditor must be an HTMLInfo."),this.Tn(),this.$.Ep=t,this.i("textEditor",i,t))}get errorFunction(){return this.$!==null?this.$.fs:null}set errorFunction(t){const i=this.errorFunction;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"errorFunction"),this.Tn(),this.$.fs=t,this.i("errorFunction",i,t))}get interval(){return this._!==null?this._.yc:1}set interval(t){const i=this.interval;if(Debug&&Util.r(t,TextBlock,"interval"),t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this._===null&&(this._=new GradElementSettings),this._.yc=t,this.u();const e=this.panel;e!==null&&(e.as=null),this.i("interval",i,t)}}get graduatedStart(){return this._!==null?this._.wc:0}set graduatedStart(t){const i=this.graduatedStart;Debug&&Util.r(t,TextBlock,"graduatedStart"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.wc=t,this.u(),this.i("graduatedStart",i,t))}get graduatedEnd(){return this._!==null?this._.xc:1}set graduatedEnd(t){const i=this.graduatedEnd;Debug&&Util.r(t,TextBlock,"graduatedEnd"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.xc=t,this.u(),this.i("graduatedEnd",i,t))}get graduatedFunction(){return this._!==null?this._.Vp:null}set graduatedFunction(t){const i=this.graduatedFunction;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"graduatedFunction"),this._===null&&(this._=new GradElementSettings),this._.Vp=t,this.u(),this.i("graduatedFunction",i,t))}get graduatedSkip(){return this._!==null?this._.bc:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"graduatedSkip"),this._===null&&(this._=new GradElementSettings),this._.bc=t,this.u(),this.i("graduatedSkip",i,t))}gh(t,i){if(this.$i===null||this.ui.length===0||this.Cn===null)return;const e=this.naturalBounds,s=this.actualBounds,n=e.width,o=e.height,r=this.Op();let l=t.textAlign=this.textAlign;const h=i.Ju;l==="start"?l=h?"right":"left":l==="end"&&(l=h?"left":"right");const a=this.isUnderline,f=this.isStrikethrough;this.wn(t,this.$i,!0,!1,e,s),(a||f)&&this.wn(t,this.$i,!1,!1,e,s);const c=0;let u=0;const d=n;let m=!1;i.ei===t&&!(i.ei instanceof SVGContext)&&!this.B2&&i.getRenderingHint("textGreeking")===!0&&r*this.ga*i.scale<3&&(m=!0);const g=this.spacingAbove,p=this.spacingBelow;switch(this.flip){case 0:break;case 2:t.translate(n,0),t.scale(-1,1);break;case 1:t.translate(0,o),t.scale(1,-1);break;case 3:t.translate(n,o),t.scale(-1,-1);break}t.commitTransform();const y=this.Fe,k=(g+r+p)*y;if(o>k){const b=this.verticalAlignment;u=b.y*o-b.y*k+b.offsetY}if(y===1&&this.Ln!==null){let b=this.xi;b>d&&(b=d),u+=g,this.YL(this.Ln,t,c,u,d,r,b,m,l,a,f)}else if(this.Re!==null&&this.Oi!==null)for(let b=0;bd&&(S=d),u+=g,this.YL(this.Oi[b],t,c,u,d,r,S,m,l,a,f),u+=r+p}switch(this.flip){case 0:break;case 2:t.scale(-1,1),t.translate(-n,0);break;case 1:t.scale(1,-1),t.translate(0,-o);break;case 3:t.scale(-1,-1),t.translate(-n,-o);break}}YL(t,i,e,s,n,o,r,l,h,a,f){let c=0;if(l){h==="left"?c=0:h==="right"?c=n-r:h==="center"&&(c=(n-r)/2);const m=i.globalAlpha;i.globalAlpha=m/2,i.fillRect(e+c,s+o/4,r,o/2),i.globalAlpha=m;return}h==="left"?c=0:h==="right"?c=n:h==="center"&&(c=n/2);const u=TextBlock.fb!==null?TextBlock.fb(this,o):o*.75;i.fillText(t,e+c,s+u);let d=o/20|0;if(d===0&&(d=1),h==="right"?c-=r:h==="center"&&(c-=r/2),a){const m=TextBlock.cb!==null?TextBlock.cb(this,o):o*.8;this.KL(e+c,s+m,e+c+r,s+m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}if(f){let m=s+o-o/2.2|0;d%2!==0&&(m+=.5),this.KL(e+c,m,e+c+r,m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}}KL(t,i,e,s,n,o){o.beginPath(),o.lineWidth=n,o.moveTo(t,i),o.lineTo(e,s),o.stroke(),o.endPath()}nc(t,i,e){if(!super.nc(t,i,e))return!1;if(this.wn(t,this.$i,!0,!1,this.naturalBounds,this.actualBounds),e){if(this.svg.getElementsByTagName("text").length===0)return!0;const n=this.svg.getElementsByClassName("gojs-td");for(let o=0;o1||this.isUnderline||this.isStrikethrough?!0:super.fd(t)}p2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("text");for(let s=0;sthis.maxLines&&(this.l|=16777216))}W2(t,i,e){const s=this.formatting===0;s&&(t=t.trim());let n=0,o=0,r=0;const l=this.Cn,h=this.spacingAbove+this.spacingBelow,a=Math.max(0,this.Op()+h),f=this.overflow===1?this.GL(l):0;if(this.Fe>=this.maxLines){e!==null&&e.e(0,a);return}let c=t;if(this.wrap===0){if(this.An=1,o=this.getStringWidth(t),f===0||o<=i){this.xi=Math.max(this.xi,o),this.Dn(t,this.xi),e!==null&&e.e(o,a);return}let d=this.Rd(c);c=c.substring(d.length);let m=this.Rd(c);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,c=c.substring(m.length),m=this.Rd(c),r=o;let g=d+m;s&&(g=g.trim()),o=this.getStringWidth(g)}for(s&&(m=m.trim()),d+=m,i=Math.max(1,i-f);this.getStringWidth(d)>i&&d.length>1;)d=d.substring(0,d.length-1);this.v2(!0),d+=TextBlock.Dp,r=this.getStringWidth(d),this.xi=r,this.Dn(d,r),e!==null&&e.e(r,a);return}let u=0;for(c.length===0&&(u=1,this.Dn(c,0));c.length>0;){let d=this.Rd(c);for(c=c.substring(d.length);this.getStringWidth(d)>i;){let p=1;for(o=this.getStringWidth(d.substring(0,p)),r=0;o<=i;)p++,r=o,o=this.getStringWidth(d.substring(0,p));let y=0;p===1?(y=o,n=Math.max(n,o)):(y=r,n=Math.max(n,r)),p--,p<1&&(p=1);const x=d.substring(0,p);if(this.Dn(x,y),u++,d=d.substring(p),this.Fe+u>this.maxLines)break}let m=this.Rd(c);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,c=c.substring(m.length),m=this.Rd(c),r=o;let p=d+m;s&&(p=p.trim()),o=this.getStringWidth(p)}if(s&&(d=d.trim()),d==="")continue;d[d.length-1]==="\xAD"&&(d=d.substring(0,d.length-1)+"\u2010");let g=0;if(m.length===0?(g=o,n=Math.max(n,o)):(r=this.getStringWidth(d),g=r,n=Math.max(n,r)),this.Dn(d,g),u++,this.Fe+u>this.maxLines)break}this.An=Math.min(this.maxLines,u),this.xi=Math.max(this.xi,n),e!==null&&e.e(this.xi,a*this.An)}EI(t,i){if(this.xi===0||this.Re===null||this.Oi===null||this.overflow!==1)return;const e=this.Cn,s=this.overflow===1?this.GL(e):0,n=this.spacingAbove+this.spacingBelow,o=Math.max(0,this.Op()+n),r=Math.min(this.maxLines-1,Math.max(Math.floor(i/o+.01)-1,0));if(r+1>=this.Oi.length)return;this.v2(!0);let l=this.Oi[r];const h=Math.max(1,t-s);for(;this.getStringWidth(l)>h&&l.length>1;)l=l.substring(0,l.length-1);l+=TextBlock.Dp;const a=this.getStringWidth(l);this.Oi[r]=l,this.Oi=this.Oi.slice(0,r+1),this.Re[r]=a,this.Re=this.Re.slice(0,r+1),this.An=this.Oi.length,this.xi=Math.max(this.xi,a),this.Fe=this.An,this.Fe===1&&(this.Ln=this.Oi[0])}Rd(t){if(this.wrap===3)return t.substring(0,1);let i=t.length,e=0;const s=TextBlock.VI;for(;e=t.length?t:t.substring(0,e)}getStringWidth(t){return TextBlock.rl===null?t.length*8:TextBlock.rl.measureText(t).width}Op(){if(this.co!==null)return this.co;const t=this.Cn;let i=0;return TextBlock.rl===null?(i=16,this.co=i,i):(TextBlock.J2[t]!==void 0&&TextBlock.HL<5e3?i=TextBlock.J2[t]:(i=TextBlock.rl.measureText("M").width*1.3,TextBlock.J2[t]=i,TextBlock.HL++),this.co=i,i)}GL(t){if(TextBlock.rl===null)return 6;let i=0;return TextBlock.ab[t]!==void 0&&TextBlock.j2<5e3?i=TextBlock.ab[t]:(i=TextBlock.rl.measureText(TextBlock.Dp).width,TextBlock.ab[t]=i,TextBlock.j2++),i}ub(t,i){return t.indexOf(` + or you could collect items to be removed from the collection after the iteration.`)}static ur(t,i){Util.n("No property to set for this enum value: "+i+" on "+t.toString())}static ht(t){root.console&&root.console.log(t)}static Mt(t){return typeof t=="object"&&t!==null}static Ug(t,i,e){Array.isArray(t)||Util.Bi(t,"Array",i,e)}static au(t,i,e){Array.isArray(t)?i>=t.length?t.push(e):t.splice(i,0,e):Util.n("Cannot insert an object into an HTMLCollection or NodeList: "+e+" at "+i)}static lf(t,i){Array.isArray(t)?i>=t.length?t.pop():t.splice(i,1):Util.n("Cannot remove an object from an HTMLCollection or NodeList at "+i)}static Ok=[];static at(){const t=Util.Ok.pop();return t===void 0?[]:t}static nt(t){t.length=0,Util.Ok.push(t)}static iE=Object.freeze([]);static hu(t){return t===null?"*":typeof t=="string"?t:typeof t=="function"?t.name:""}static hn(t){return typeof t=="function"?t.className?t.className:t.name:Util.Mt(t)&&t.constructor?Util.hn(t.constructor):typeof t}static Xh(t,i){return i==null||i===""?null:Util.Mt(t)&&i in t||t[i]?t[i]:null}static toString(t){let i=t;return Util.Mt(t)&&(t.text?i=t.text:t.name?i=t.name:t.key!==void 0?i=t.key:t.id!==void 0?i=t.id:t.constructor===Object&&(t.Text?i=t.Text:t.Name?i=t.Name:t.Key!==void 0?i=t.Key:t.Id!==void 0?i=t.Id:t.ID!==void 0&&(i=t.ID))),i===void 0?"undefined":i===null?"null":i.toString()}static yw(t,i){if(t.hasOwnProperty(i))return!0;let e=Object.getPrototypeOf(t);for(;e&&e!==Function;){if(e.hasOwnProperty(i))return!0;const s=e.eE;if(s&&s[i])return!0;e=Object.getPrototypeOf(e)}return!1}static OD(t){const i=[];let e=0;for(e=0;e<256;e++)i[e]=e;let s=0,n=0;for(e=0;e<256;e++)s=(s+i[e]+119)%256,n=i[e],i[e]=i[s],i[s]=n;e=0,s=0;let o="";for(let r=0;r>4)+i.charAt(r&15)]=String.fromCharCode(r);t.length%2&&(t="0"+t);const s=[];let n=0;for(let r=0;r0){const n=i[0];return this.key=0,this.value=n,n}else return null}any(t){const i=this.Qt;i.dr=null;const e=i.dt;this.Bt=-1;const s=i.h,n=s.length,o=this.Rs;for(let r=0;r=0?(this.key=i,this.value=t.h[i],!0):(this.wl(),!1)}hasNext(){return this.next()}first(){const t=this.Qt;this.vt=t.dt;const i=t.h,e=i.length-1;if(this.Bt=e,e>=0){const s=i[e];return this.key=e,this.value=s,s}else return null}any(t){const i=this.Qt;i.gr=null;const e=i.dt,s=i.h,n=s.length;this.Bt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(t(r))return!0;i.dt!==e&&Util.ze(i)}return!1}all(t){const i=this.Qt;i.gr=null;const e=i.dt,s=i.h,n=s.length;this.Bt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(!t(r))return!1;i.dt!==e&&Util.ze(i)}return!0}each(t){const i=this.Qt;i.gr=null;const e=i.dt,s=i.h,n=s.length;this.Bt=n;for(let o=n-1;o>=0;o--){const r=s[o];t(r),i.dt!==e&&Util.ze(i)}return this}map(t){const i=this.Qt;i.gr=null;const e=i.dt,s=[],n=i.h,o=n.length;this.Bt=o;for(let l=o-1;l>=0;l--){const h=n[l];s.push(t(h)),i.dt!==e&&Util.ze(i)}const r=new List;return r.h=s,r.Xe(),r.iterator}filter(t){const i=this.Qt;i.gr=null;const e=i.dt,s=[],n=i.h,o=n.length;this.Bt=o;for(let l=o-1;l>=0;l--){const h=n[l];t(h)&&s.push(h),i.dt!==e&&Util.ze(i)}const r=new List;return r.h=s,r.Xe(),r.iterator}get count(){return this.Qt.h.length}wl(){this.key=-1,this.value=null,this.vt=-1,this.Qt.gr=this}toString(){return"ListIteratorBackwards("+this.Bt+"/"+this.Qt.count+")"}}class List{f;h;dt;dr;gr;constructor(t){GSet.vi(this),this.f=!1,this.h=[],this.dt=0,this.dr=null,this.gr=null,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.h.values()}Xe(){let t=this.dt;t++,t>999999999&&(t=0),this.dt=t}w(){return this.f=!0,this}ft(){return this.f=!1,this}toString(){return"List()#"+GSet.gs(this)}add(t){return this.f&&Util.F(this,t),this.h.push(t),this.Xe(),this}push(t){this.add(t)}addAll(t){if(t===null)return this;this.f&&Util.F(this);const i=this.h;if(Array.isArray(t)){const e=t.length;for(let s=0;s=i.length)&&Util.G(t,"0 <= i < length",List,"elt:i"),i[t]}get(t){return this.elt(t)}setElt(t,i){Debug&&Util.r(t,List,"setElt:i");const e=this.h;(t<0||t>=e.length)&&Util.G(t,"0 <= i < length",List,"setElt:i"),this.f&&Util.F(this,t),e[t]=i}set(t,i){this.setElt(t,i)}first(){const t=this.h;return t.length===0?null:t[0]}last(){const t=this.h,i=t.length;return i>0?t[i-1]:null}pop(){this.f&&Util.F(this);const t=this.h;return t.length>0?t.pop():null}any(t){const i=this.h,e=this.dt,s=i.length;for(let n=0;n= 0",List,"insertAt:i"),this.f&&Util.F(this,t);const e=this.h;t>=e.length?e.push(i):e.splice(t,0,i),this.Xe()}remove(t){return this.delete(t)}delete(t){if(t===null)return!1;this.f&&Util.F(this,t);const i=this.h,e=i.indexOf(t);return e===-1?!1:(e===i.length-1?i.pop():i.splice(e,1),this.Xe(),!0)}removeAt(t){Debug&&Util.r(t,List,"removeAt:i");const i=this.h;(t<0||t>=i.length)&&Util.G(t,"0 <= i < length",List,"removeAt:i"),this.f&&Util.F(this,t),t===i.length-1?i.pop():i.splice(t,1),this.Xe()}removeRange(t,i){Debug&&(Util.r(t,List,"removeRange:from"),Util.r(i,List,"removeRange:to"));const e=this.h,s=e.length;if(t<0)t=0;else if(t>=s)return this;if(i<0)return this;if(i>=s&&(i=s-1),t>i)return this;this.f&&Util.F(this);let n=t,o=i+1;for(;o0&&(t.h=Array.prototype.slice.call(i)),t}toArray(){const t=this.h,i=this.count,e=new Array(i);for(let s=0;s=n-1)&&Util.G(i,"0 <= from < length",List,"sortRange:from"),o===2){const r=s[i],l=s[i+1];return t(r,l)>0&&(s[i]=l,s[i+1]=r,this.Xe()),this}if(i===0)if(e>=n)s.sort(t);else{const r=s.slice(0,e);r.sort(t);for(let l=0;l=n){const r=s.slice(i);r.sort(t);for(let l=i;li.add(t(e))),i.iterator}filter(t){const i=new List;return this.Ao.k.forEach(e=>{t(e)&&i.add(e)}),i.iterator}get count(){return this.Ao.count}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"SetIterator"}}class GSet{f;k;constructor(t){this.f=!1,this.k=new Set,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.k.values()}values(){return this.k.values()}w(){return this.f=!0,this}ft(){return this.f=!1,this}toString(){return"Set()#"+GSet.gs(this)}add(t){return t===null?this:(this.k.add(t),this)}addAll(t){if(t===null)return this;if(Array.isArray(t)){const i=t.length;for(let e=0;et.add(i)),t}toArray(){return Array.from(this.k)}toList(){const t=new List;return this.k.forEach(i=>t.add(i)),t}get count(){return this.k.size}get size(){return this.k.size}get iterator(){return this.k.size<=0?EmptyIterator.instance:new SetIterator(this)}entries(){return this.k.entries()}keys(){return this.k.keys()}forEach(t,i){return this.k.forEach(t,i)}static fu=1;static vi(t){t.__gohashid=GSet.fu++}static gs(t){return t.__gohashid}}class MapKeySetIterator{et;ri;constructor(t){this.et=t,this.ri=t.k.keys()}[Symbol.iterator](){return this.et.k.keys()}key;value;get iterator(){return this}reset(){const t=this.et;this.ri=t.k.keys()}next(){const t=this.ri.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.et.k.size===0?null:(this.ri=this.et.k.keys(),this.ri.next().value)}any(t){for(const i of this.et.k)if(t(i[0]))return!0;return!1}all(t){for(const i of this.et.k)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.et.k)t(i[0]);return this}map(t){const i=this.et,e=new List;for(const s of i.k)e.add(t(s[0]));return e.iterator}filter(t){const i=this.et,e=new List;for(const s of i.k){const n=s[0];t(n)&&e.add(n)}return e.iterator}get count(){return this.et.size}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"MapKeySetIterator"}}class MapKeySet extends GSet{et;constructor(t){super(),GSet.vi(this),this.f=!0,this.et=t}[Symbol.iterator](){return this.k.keys()}values(){return this.k.keys()}w(){return this}ft(){return this}toString(){return"MapKeySet("+this.et.toString()+")"}add(t){Util.n("This Set is read-only: "+this.toString())}has(t){return this.et.has(t)}contains(t){return this.has(t)}delete(t){Util.n("This Set is read-only: "+this.toString())}remove(t){return this.delete(t)}clear(){Util.n("This Set is read-only: "+this.toString())}first(){return this.et.k.size===0?null:this.et.k.keys().next().value}any(t){for(const i of this.et.k)if(t(i[0]))return!0;return!1}all(t){for(const i of this.et.k)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.et.k)t(i[0]);return this}map(t){const i=new GSet;for(const e of this.et.k)i.add(t(e[0]));return i}filter(t){const i=new GSet;for(const e of this.et.k){const s=e[0];t(s)&&i.add(s)}return i}copy(){return new MapKeySet(this.et)}toSet(){const t=new GSet,i=this.et.k;for(const e of i)t.add(e[0]);return t}toArray(){const t=this.et.k,i=new Array(t.size);let e=0;for(const s of t)i[e]=s[0],e++;return i}toList(){const t=new List,i=this.et.k;for(const e of i)t.add(e[0]);return t}get count(){return this.et.size}get size(){return this.et.size}get iterator(){return this.et.size<=0?EmptyIterator.instance:new MapKeySetIterator(this.et)}}class MapValueSetIterator{et;ri;constructor(t){this.et=t,this.ri=t.k.values()}[Symbol.iterator](){return this.et.k.values()}key;value;get iterator(){return this}reset(){const t=this.et;this.ri=t.k.values()}next(){const t=this.ri.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.et.k.size===0?null:(this.ri=this.et.k.values(),this.ri.next().value)}any(t){for(const i of this.et.k)if(t(i[1]))return!0;return!1}all(t){for(const i of this.et.k)if(!t(i[1]))return!1;return!0}each(t){for(const i of this.et.k)t(i[1]);return this}map(t){const i=this.et,e=new List;for(const s of i.k)e.add(t(s[1]));return e.iterator}filter(t){const i=this.et,e=new List;for(const s of i.k){const n=s[1];t(n)&&e.add(n)}return e.iterator}get count(){return this.et.size}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"MapValueSetIterator"}}class KeyValuePair{constructor(t,i){this.key=t,this.value=i}toString(){return"{"+this.key+":"+this.value+"}"}key;value}class MapIterator{et;ri;constructor(t){this.et=t,this.ri=t.k.entries()}[Symbol.iterator](){return this.et.k.entries()}key;value;get iterator(){return this}reset(){const t=this.et;this.ri=t.k.entries()}next(){const t=this.ri.next();return t.done?(this.key=null,this.value=null,!1):(this.key=t.value[0],this.value=t.value[1],!0)}hasNext(){return this.next()}first(){if(this.et.k.size===0)return null;this.ri=this.et.k.entries();const t=this.ri.next().value;return this.key=t[0],this.value=t[1],new KeyValuePair(t[0],t[1])}any(t){return this.et.any(t)}all(t){return this.et.all(t)}each(t){return this.et.each(t),this}map(t){const i=new List;let e=null;return this.et.k.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),i.add(t(e))}),i.iterator}filter(t){const i=new List;let e=null;return this.et.k.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),t(e)&&(i.add(e),e=null)}),i.iterator}get count(){return this.et.size}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"MapIterator"}}class GMap{f;k;constructor(t){GSet.vi(this),this.f=!1,this.k=new Map,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.k.entries()}entries(){return this.k.entries()}w(){return this.f=!0,this}ft(){return this.f=!1,this}toString(){return"Map()#"+GSet.gs(this)}set(t,i){return this.f&&Util.F(this,t),this.k.set(t,i),this}add(t,i){return this.set(t,i)}addAll(t){if(t===null)return this;if(this.f&&Util.F(this),Array.isArray(t)){const i=t.length;for(let e=0;ei.x.toFixed(t)+" "+i.y.toFixed(t)}toString(){return"Point("+this.x+","+this.y+")"}equals(t){return t instanceof Point?this.S===t.x&&this.P===t.y:!1}equalTo(t,i){return this.S===t&&this.P===i}equalsApprox(t){return Geo.p(this.S,t.x)&&Geo.p(this.P,t.y)}add(t){return Debug&&(Util.s(t,Point,Point,"add:p"),this.st()),this.S+=t.x,this.P+=t.y,this}subtract(t){return Debug&&(Util.s(t,Point,Point,"subtract:p"),this.st()),this.S-=t.x,this.P-=t.y,this}offset(t,i){return Debug&&(Util.r(t,Point,"offset:dx"),Util.r(i,Point,"offset:dy"),this.st()),this.S+=t,this.P+=i,this}rotate(t){if(Debug&&(Util.r(t,Point,"rotate:angle"),this.st()),t===0)return this;const i=this.S,e=this.P;if(i===0&&e===0)return this;let s=0,n=0;if(t>=360?t-=360:t<0&&(t+=360),t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const o=t*Math.PI/180;s=Math.cos(o),n=Math.sin(o)}return this.S=s*i-n*e,this.P=n*i+s*e,this}scale(t,i){return Debug&&(Util.r(t,Point,"scale:sx"),Util.r(i,Point,"scale:sy"),this.st()),this.S*=t,this.P*=i,this}distanceSquaredPoint(t){Debug&&Util.s(t,Point,Point,"distanceSquaredPoint:p");const i=t.x-this.S,e=t.y-this.P;return i*i+e*e}distanceSquared(t,i){Debug&&(Util.r(t,Point,"distanceSquared:px"),Util.r(i,Point,"distanceSquared:py"));const e=t-this.S,s=i-this.P;return e*e+s*s}normalize(){Debug&&this.st();const t=this.S,i=this.P,e=Math.sqrt(t*t+i*i);return e>0&&(this.S=t/e,this.P=i/e),this}directionPoint(t){return Debug&&Util.s(t,Point,Point,"directionPoint:p"),this.sC(t.x-this.S,t.y-this.P)}direction(t,i){return Debug&&(Util.r(t,Point,"direction:px"),Util.r(i,Point,"direction:py")),this.sC(t-this.S,i-this.P)}sC(t,i){if(t===0)return i>0?90:i<0?270:0;if(i===0)return t>0?0:180;{if(isNaN(t)||isNaN(i))return 0;let e=Math.atan(Math.abs(i/t))*180/Math.PI;return t<0?i<0?e+=180:e=180-e:i<0&&(e=360-e),e}}static compareWithLineSegment(t,i,e,s,n,o){return Debug&&(Util.r(t,Point,"compareWithLineSegment:a1x"),Util.r(i,Point,"compareWithLineSegment:a1y"),Util.r(e,Point,"compareWithLineSegment:a2x"),Util.r(s,Point,"compareWithLineSegment:a2y"),Util.r(n,Point,"compareWithLineSegment:b1x"),Util.r(o,Point,"compareWithLineSegment:b1y")),Geo.cu(t,i,e,s,n,o)}compareWithLineSegmentPoint(t,i){return Debug&&(Util.s(t,Point,Point,"compareWithLineSegmentPoint:p"),Util.s(i,Point,Point,"compareWithLineSegmentPoint:q")),Geo.cu(t.x,t.y,i.x,i.y,this.x,this.y)}static intersectingLineSegments(t,i,e,s,n,o,r,l){return Debug&&(Util.r(t,Point,"intersectingLineSegments:a1x"),Util.r(i,Point,"intersectingLineSegments:a1y"),Util.r(e,Point,"intersectingLineSegments:a2x"),Util.r(s,Point,"intersectingLineSegments:a2y"),Util.r(n,Point,"intersectingLineSegments:b1x"),Util.r(o,Point,"intersectingLineSegments:b1y"),Util.r(r,Point,"intersectingLineSegments:b2x"),Util.r(l,Point,"intersectingLineSegments:b2y")),Geo.uu(t,i,e,s,n,o,r,l)}projectOntoLineSegment(t,i,e,s){return Debug&&(Util.r(t,Point,"projectOntoLineSegment:px"),Util.r(i,Point,"projectOntoLineSegment:py"),Util.r(e,Point,"projectOntoLineSegment:qx"),Util.r(s,Point,"projectOntoLineSegment:qy")),Geo.xl(t,i,e,s,this.S,this.P,this),this}projectOntoLineSegmentPoint(t,i){return Debug&&(Util.s(t,Point,Point,"projectOntoLineSegmentPoint:p"),Util.s(i,Point,Point,"projectOntoLineSegmentPoint:q")),Geo.xl(t.x,t.y,i.x,i.y,this.S,this.P,this),this}snapToGrid(t,i,e,s){return Debug&&(Util.r(t,Point,"snapToGrid:originx"),Util.r(i,Point,"snapToGrid:originy"),Util.r(e,Point,"snapToGrid:cellwidth"),Util.r(s,Point,"snapToGrid:cellheight")),Geo.Gg(this.S,this.P,t,i,e,s,this),this}snapToGridPoint(t,i){return Debug&&(Util.s(t,Point,Point,"snapToGridPoint:p"),Util.s(i,Size,Point,"snapToGridPoint:q")),Geo.Gg(this.S,this.P,t.x,t.y,i.width,i.height,this),this}setRectSpot(t,i){return Debug&&(Util.s(t,Rect,Point,"setRectSpot:r"),Util.s(i,Spot,Point,"setRectSpot:spot"),this.st()),this.S=t.x+i.x*t.width+i.offsetX,this.P=t.y+i.y*t.height+i.offsetY,this}setSpot(t,i,e,s,n){return Debug&&(Util.r(t,Point,"setSpot:x"),Util.r(i,Point,"setSpot:y"),Util.r(e,Point,"setSpot:w"),Util.r(s,Point,"setSpot:h"),(e<0||s<0)&&Util.n("Point.setSpot:Width and height cannot be negative"),Util.s(n,Spot,Point,"setSpot:spot"),this.st()),this.S=t+n.x*e+n.offsetX,this.P=i+n.y*s+n.offsetY,this}O(t){return t.Pt(this),this}Ye(t){return t.ns(this),this}static distanceLineSegmentSquared(t,i,e,s,n,o){Debug&&(Util.r(t,Point,"distanceLineSegmentSquared:px"),Util.r(i,Point,"distanceLineSegmentSquared:py"),Util.r(e,Point,"distanceLineSegmentSquared:ax"),Util.r(s,Point,"distanceLineSegmentSquared:ay"),Util.r(n,Point,"distanceLineSegmentSquared:bx"),Util.r(o,Point,"distanceLineSegmentSquared:by"));let r=n-e,l=o-s;const h=r*r+l*l,a=e-t,f=s-i,c=-a*r-f*l;if(c<=0||c>=h)return r=n-t,l=o-i,Math.min(a*a+f*f,r*r+l*l);{const u=r*f-l*a;return u*u/h}}static distanceSquared(t,i,e,s){Debug&&(Util.r(t,Point,"distanceSquared:px"),Util.r(i,Point,"distanceSquared:py"),Util.r(e,Point,"distanceSquared:qx"),Util.r(s,Point,"distanceSquared:qy"));const n=e-t,o=s-i;return n*n+o*o}static direction(t,i,e,s){Debug&&(Util.r(t,Point,"direction:px"),Util.r(i,Point,"direction:py"),Util.r(e,Point,"direction:qx"),Util.r(s,Point,"direction:qy"));const n=e-t,o=s-i;if(n===0)return o>0?90:o<0?270:0;if(o===0)return n>0?0:180;{if(isNaN(n)||isNaN(o))return 0;let r=Math.atan(Math.abs(o/n))*180/Math.PI;return n<0?o<0?r+=180:r=180-r:o<0&&(r=360-r),r}}get x(){return this.S}set x(t){Debug&&(Util.t(t,"number",Point,"x"),this.st(t)),this.S=t}get y(){return this.P}set y(t){Debug&&(Util.t(t,"number",Point,"y"),this.st(t)),this.P=t}isReal(){return isFinite(this.x)&&isFinite(this.y)}static Lo=new Point(0,0).ot();static nC=new Point(-1/0,-1/0).ot();static oC=new Point(1/0,1/0).ot();static rC=new Point(6,6).ot();static Bk=new Point(NaN,NaN).ot();static Vk=[];static a(){const t=Point.Vk.pop();return t===void 0?new Point:t}static H(t,i){const e=Point.Vk.pop();return e===void 0?new Point(t,i):(e.x=t,e.y=i,e)}static o(t){Point.Vk.push(t)}}class Size{v;J;f;constructor(t,i){t===void 0?(this.v=0,this.J=0):typeof t=="number"&&(t>=0||isNaN(t))&&typeof i=="number"&&(i>=0||isNaN(i))?(this.v=t,this.J=i):Util.n("Invalid arguments to Size constructor: "+t+", "+i),this.f=!1}c(t){return this.v=t.v,this.J=t.J,this}e(t,i){return this.v=t,this.J=i,this}setTo(t,i){return Debug&&(Util.t(t,"number",Size,"setTo:w"),Util.t(i,"number",Size,"setTo:h"),t<0&&Util.G(t,">= 0",Size,"setTo:w"),i<0&&Util.G(i,">= 0",Size,"setTo:h"),this.st()),this.v=t,this.J=i,this}set(t){return Debug&&(Util.s(t,Size,Size,"set:s"),this.st()),this.v=t.v,this.J=t.J,this}copy(){const t=new Size;return t.v=this.v,t.J=this.J,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ft(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}st(t){if(Debug&&this.f){let i="The Size is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;return n=i[e++],n&&(o=parseFloat(n)),new Size(s,o)}else return new Size}static stringify(t){return Debug&&Util.s(t,Size),t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.t(t,"number",Size,"stringifyFixed:digits"),i=>i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Size("+this.width+","+this.height+")"}equals(t){return t instanceof Size?this.v===t.width&&this.J===t.height:!1}equalTo(t,i){return this.v===t&&this.J===i}equalsApprox(t){return Geo.p(this.v,t.width)&&Geo.p(this.J,t.height)}inflate(t,i){Debug&&(Util.r(t,Size,"inflate:w"),Util.r(i,Size,"inflate:h"));const e=this.width+t;this.v=e>=0?e:0;const s=this.height+i;return this.J=s>=0?s:0,this}get width(){return this.v}set width(t){Debug&&(Util.t(t,"number",Size,"width"),this.st(t)),t<0&&Util.G(t,">= 0",Size,"width"),this.v=t}get height(){return this.J}set height(t){Debug&&(Util.t(t,"number",Size,"height"),this.st(t)),t<0&&Util.G(t,">= 0",Size,"height"),this.J=t}isReal(){return isFinite(this.width)&&isFinite(this.height)}static hf=new Size(0,0).ot();static zk=new Size(1,1).ot();static lC=new Size(6,6).ot();static du=new Size(8,8).ot();static hC=new Size(10,10).ot();static Xk=new Size(1/0,1/0).ot();static xw=new Size(NaN,NaN).ot();static aC=[];static a(){const t=Size.aC.pop();return t===void 0?new Size:t}static o(t){Size.aC.push(t)}}class Rect{S;P;v;J;f;constructor(t,i,e,s){if(t===void 0)this.S=0,this.P=0,this.v=0,this.J=0;else if(typeof t=="number"&&typeof i=="number"&&typeof e=="number"&&(e>=0||isNaN(e))&&typeof s=="number"&&(s>=0||isNaN(s)))this.S=t,this.P=i,this.v=e,this.J=s;else if(t instanceof Point){const n=t.x,o=t.y;if(i instanceof Point){const r=i.x,l=i.y;this.S=Math.min(n,r),this.P=Math.min(o,l),this.v=Math.abs(n-r),this.J=Math.abs(o-l)}else i instanceof Size?(this.S=n,this.P=o,this.v=i.width,this.J=i.height):Util.n("Incorrect second argument supplied to Rect constructor "+i)}else Util.n("Invalid arguments to Rect constructor: "+t+", "+i+", "+e+", "+s);this.f=!1}c(t){return this.S=t.S,this.P=t.P,this.v=t.v,this.J=t.J,this}e(t,i,e,s){return this.S=t,this.P=i,this.v=e,this.J=s,this}Kn(t,i){return this.v=t,this.J=i,this}setTo(t,i,e,s){return Debug&&(Util.t(t,"number",Rect,"setTo:x"),Util.t(i,"number",Rect,"setTo:y"),Util.t(e,"number",Rect,"setTo:w"),Util.t(s,"number",Rect,"setTo:h"),e<0&&Util.G(e,">= 0",Rect,"setTo:w"),s<0&&Util.G(s,">= 0",Rect,"setTo:h"),this.st()),this.S=t,this.P=i,this.v=e,this.J=s,this}set(t){return Debug&&(Util.s(t,Rect,Rect,"set:r"),this.st()),this.S=t.S,this.P=t.P,this.v=t.v,this.J=t.J,this}setPoint(t){return Debug&&(Util.s(t,Point,Rect,"setPoint:p"),this.st()),this.S=t.x,this.P=t.y,this}setSize(t){return Debug&&(Util.s(t,Size,Rect,"setSize:s"),this.st()),this.v=t.width,this.J=t.height,this}copy(){const t=new Rect;return t.S=this.S,t.P=this.P,t.v=this.v,t.J=this.J,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ft(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}st(t){if(Debug&&this.f){let i="The Rect is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),new Rect(s,o,r,l)}else return new Rect}static stringify(t){return Debug&&Util.s(t,Rect),t.x.toString()+" "+t.y.toString()+" "+t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.t(t,"number",Rect,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Rect("+this.x+","+this.y+","+this.width+","+this.height+")"}equals(t){return t instanceof Rect?this.S===t.x&&this.P===t.y&&this.v===t.width&&this.J===t.height:!1}equalTo(t,i,e,s){return this.S===t&&this.P===i&&this.v===e&&this.J===s}equalsApprox(t){return Geo.p(this.S,t.x)&&Geo.p(this.P,t.y)&&Geo.p(this.v,t.width)&&Geo.p(this.J,t.height)}equalsApproxTo(t,i,e,s){return Geo.p(this.S,t)&&Geo.p(this.P,i)&&Geo.p(this.v,e)&&Geo.p(this.J,s)}equalsApproxClose(t){return Geo.q(this.S,t.x)&&Geo.q(this.P,t.y)&&Geo.q(this.v,t.width)&&Geo.q(this.J,t.height)}containsPoint(t){return Debug&&Util.s(t,Point,Rect,"containsPoint:p"),this.S<=t.x&&this.S+this.v>=t.x&&this.P<=t.y&&this.P+this.J>=t.y}containsRect(t){return Debug&&Util.s(t,Rect,Rect,"containsRect:r"),this.S<=t.x&&t.x+t.width<=this.S+this.v&&this.P<=t.y&&t.y+t.height<=this.P+this.J}contains(t,i,e,s){return Debug?(Util.r(t,Rect,"contains:x"),Util.r(i,Rect,"contains:y"),e===void 0?e=0:Util.r(e,Rect,"contains:w"),s===void 0?s=0:Util.r(s,Rect,"contains:h"),(e<0||s<0)&&Util.n("Rect.contains:Width and height cannot be negative")):(e===void 0&&(e=0),s===void 0&&(s=0)),this.S<=t&&t+e<=this.S+this.v&&this.P<=i&&i+s<=this.P+this.J}offset(t,i){return Debug&&(Util.r(t,Rect,"offset:dx"),Util.r(i,Rect,"offset:dy"),this.st()),this.S+=t,this.P+=i,this}inflate(t,i){return Debug&&(Util.r(t,Rect,"inflate:w"),Util.r(i,Rect,"inflate:h")),this.bw(i,t,i,t)}addMargin(t){return Debug&&Util.s(t,Margin,Rect,"addMargin:m"),this.bw(t.top,t.right,t.bottom,t.left)}subtractMargin(t){return Debug&&Util.s(t,Margin,Rect,"subtractMargin:m"),this.bw(-t.top,-t.right,-t.bottom,-t.left)}grow(t,i,e,s){return Debug&&(Util.r(t,Rect,"grow:t"),Util.r(i,Rect,"grow:r"),Util.r(e,Rect,"grow:b"),Util.r(s,Rect,"grow:l")),this.bw(t,i,e,s)}bw(t,i,e,s){Debug&&this.st();const n=this.v;i+s<=-n?(this.S+=n/2,this.v=0):(this.S-=s,this.v+=i+s);const o=this.J;return t+e<=-o?(this.P+=o/2,this.J=0):(this.P-=t,this.J+=t+e),this}intersectRect(t){return Debug&&Util.s(t,Rect,Rect,"intersectRect:r"),this.fC(t.x,t.y,t.width,t.height)}intersect(t,i,e,s){return Debug&&(Util.r(t,Rect,"intersect:x"),Util.r(i,Rect,"intersect:y"),Util.r(e,Rect,"intersect:w"),Util.r(s,Rect,"intersect:h"),(e<0||s<0)&&Util.n("Rect.intersect:Width and height cannot be negative")),this.fC(t,i,e,s)}fC(t,i,e,s){Debug&&this.st();const n=Math.max(this.S,t),o=Math.max(this.P,i),r=Math.min(this.S+this.v,t+e),l=Math.min(this.P+this.J,i+s);return this.S=n,this.P=o,this.v=Math.max(0,r-n),this.J=Math.max(0,l-o),this}intersectsRect(t){return Debug&&Util.s(t,Rect,Rect,"intersectsRect:r"),this.intersects(t.x,t.y,t.width,t.height)}intersects(t,i,e,s){Debug&&(Util.r(t,Rect,"intersects:x"),Util.r(i,Rect,"intersects:y"),Util.r(t,Rect,"intersects:w"),Util.r(i,Rect,"intersects:h"),(e<0||s<0)&&Util.n("Rect.intersects:Width and height cannot be negative"));let n=this.v;const o=this.S;if(n!==1/0&&e!==1/0&&(n+=o,e+=t,isNaN(e)||isNaN(n)||o>e||t>n))return!1;let r=this.J;const l=this.P;return!(r!==1/0&&s!==1/0&&(r+=l,s+=i,isNaN(s)||isNaN(r)||l>s||i>r))}intersectsRectPlus(t,i){let e=this.v,s=t.width+i+i;const n=this.S,o=t.x-i;if(e+=n,s+=o,n>s||o>e)return!1;let r=this.J,l=t.height+i+i;const h=this.P,a=t.y-i;return r+=h,l+=a,!(h>l||a>r)}unionPoint(t){return Debug&&Util.s(t,Point,Rect,"unionPoint:p"),this.unionNoCheck(t.x,t.y,0,0)}unionRect(t){return Debug&&Util.s(t,Rect,Rect,"unionRect:r"),this.unionNoCheck(t.S,t.P,t.v,t.J)}union(t,i,e,s){return Debug?(Util.r(t,Rect,"union:x"),Util.r(i,Rect,"union:y"),e===void 0?e=0:Util.r(e,Rect,"union:w"),s===void 0?s=0:Util.r(s,Rect,"union:h"),(e<0||s<0)&&Util.n("Rect.union:Width and height cannot be negative"),this.st()):(e===void 0&&(e=0),s===void 0&&(s=0)),this.unionNoCheck(t,i,e,s)}unionNoCheck(t,i,e,s){const n=Math.min(this.S,t),o=Math.min(this.P,i),r=Math.max(this.S+this.v,t+e),l=Math.max(this.P+this.J,i+s);return this.S=n,this.P=o,this.v=r-n,this.J=l-o,this}setSpot(t,i,e){return Debug&&(Util.r(t,Rect,"setSpot:x"),Util.r(i,Rect,"setSpot:y"),Util.s(e,Spot,Rect,"setSpot:spot"),this.st()),this.S=t-e.offsetX-e.x*this.v,this.P=i-e.offsetY-e.y*this.J,this}static contains(t,i,e,s,n,o,r,l){return Debug?(Util.r(t,Rect,"contains:rx"),Util.r(i,Rect,"contains:ry"),Util.r(e,Rect,"contains:rw"),Util.r(s,Rect,"contains:rh"),Util.r(n,Rect,"contains:x"),Util.r(o,Rect,"contains:y"),r===void 0?r=0:Util.r(r,Rect,"contains:w"),l===void 0?l=0:Util.r(l,Rect,"contains:h"),(e<0||s<0||r<0||l<0)&&Util.n("Rect.contains:Width and height cannot be negative")):(r===void 0&&(r=0),l===void 0&&(l=0)),t<=n&&n+r<=t+e&&i<=o&&o+l<=i+s}static intersects(t,i,e,s,n,o,r,l){Debug&&(Util.r(t,Rect,"intersects:rx"),Util.r(i,Rect,"intersects:ry"),Util.r(e,Rect,"intersects:rw"),Util.r(s,Rect,"intersects:rh"),Util.r(n,Rect,"intersects:x"),Util.r(o,Rect,"intersects:y"),Util.r(r,Rect,"intersects:w"),Util.r(l,Rect,"intersects:h"),(e<0||s<0||r<0||l<0)&&Util.n("Rect.intersects:Width and height cannot be negative"));let h=e,a=r;const f=t,c=n;if(h+=f,a+=c,f>a||c>h)return!1;let u=s,d=l;const m=i,g=o;return u+=m,d+=g,!(m>d||g>u)}static intersectsLineSegment(t,i,e,s,n,o,r,l){return Debug&&(Util.r(t,Rect,"intersectsLineSegment:x"),Util.r(i,Rect,"intersectsLineSegment:y"),Util.r(e,Rect,"intersectsLineSegment:w"),Util.r(s,Rect,"intersectsLineSegment:h"),Util.r(n,Rect,"intersectsLineSegment:p1x"),Util.r(o,Rect,"intersectsLineSegment:p1y"),Util.r(r,Rect,"intersectsLineSegment:p2x"),Util.r(l,Rect,"intersectsLineSegment:p2y"),(e<0||s<0)&&Util.n("Rect.intersectsLineSegment: width and height cannot be negative")),Geo.cC(t,i,e,s,n,o,r,l)}get x(){return this.S}set x(t){Debug&&(Util.t(t,"number",Rect,"x"),this.st(t)),this.S=t}get y(){return this.P}set y(t){Debug&&(Util.t(t,"number",Rect,"y"),this.st(t)),this.P=t}get width(){return this.v}set width(t){Debug&&(Util.t(t,"number",Rect,"width"),this.st(t)),t<0&&Util.G(t,">= 0",Rect,"width"),this.v=t}get height(){return this.J}set height(t){Debug&&(Util.t(t,"number",Rect,"height"),this.st(t)),t<0&&Util.G(t,">= 0",Rect,"height"),this.J=t}get left(){return this.S}set left(t){Debug&&(Util.t(t,"number",Rect,"left"),this.st(t)),this.S=t}get top(){return this.P}set top(t){Debug&&(Util.t(t,"number",Rect,"top"),this.st(t)),this.P=t}get right(){return this.S+this.v}set right(t){Debug&&(Util.r(t,Rect,"right"),this.st(t)),this.S+=t-(this.S+this.v)}get bottom(){return this.P+this.J}set bottom(t){Debug&&(Util.r(t,Rect,"top"),this.st(t)),this.P+=t-(this.P+this.J)}get position(){return new Point(this.S,this.P)}set position(t){Debug&&(Util.s(t,Point,Rect,"position"),this.st(t)),this.S=t.x,this.P=t.y}get size(){return new Size(this.v,this.J)}set size(t){Debug&&(Util.s(t,Size,Rect,"size"),this.st(t)),this.v=t.width,this.J=t.height}get center(){return new Point(this.S+this.v/2,this.P+this.J/2)}set center(t){Debug&&(Util.s(t,Point,Rect,"center"),this.st(t)),this.S=t.x-this.v/2,this.P=t.y-this.J/2}get centerX(){return this.S+this.v/2}set centerX(t){Debug&&(Util.r(t,Rect,"centerX"),this.st(t)),this.S=t-this.v/2}get centerY(){return this.P+this.J/2}set centerY(t){Debug&&(Util.r(t,Rect,"centerY"),this.st(t)),this.P=t-this.J/2}isReal(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)}isEmpty(){return this.width===0&&this.height===0}static kw=new Rect(0,0,0,0).ot();static BD=new Rect(NaN,NaN,NaN,NaN).ot();static Yk=[];static a(){const t=Rect.Yk.pop();return t===void 0?new Rect:t}static H(t,i,e,s){const n=Rect.Yk.pop();return n===void 0?new Rect(t,i,e,s):n.e(t,i,e,s)}static o(t){Rect.Yk.push(t)}}class Margin{an;fn;cn;un;f;constructor(t,i,e,s){t===void 0?(this.an=0,this.fn=0,this.cn=0,this.un=0):i===void 0?(i=t,e=t,s=t,this.top=t,this.right=i,this.bottom=e,this.left=s):e===void 0?(e=t,s=i,this.top=t,this.right=i,this.bottom=e,this.left=s):s!==void 0?(this.top=t,this.right=i,this.bottom=e,this.left=s):Util.n("Invalid arguments to Margin constructor: "+t+", "+i+", "+e+", "+s),this.f=!1}c(t){return this.an=t.an,this.fn=t.fn,this.cn=t.cn,this.un=t.un,this}setTo(t,i,e,s){return Debug&&(Util.t(t,"number",Margin,"setTo:t"),Util.t(i,"number",Margin,"setTo:r"),Util.t(e,"number",Margin,"setTo:b"),Util.t(s,"number",Margin,"setTo:l"),this.st()),this.an=t,this.fn=i,this.cn=e,this.un=s,this}set(t){return Debug&&(Util.s(t,Margin,Margin,"assign:m"),this.st()),this.an=t.an,this.fn=t.fn,this.cn=t.cn,this.un=t.un,this}copy(){const t=new Margin;return t.an=this.an,t.fn=this.fn,t.cn=this.cn,t.un=this.un,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ft(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}st(t){if(Debug&&this.f){let i="The Margin is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=NaN;for(;i[e]==="";)e++;let n=i[e++];if(n&&(s=parseFloat(n)),isNaN(s))return new Margin;let o=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(o=parseFloat(n)),isNaN(o))return new Margin(s);let r=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(r=parseFloat(n)),isNaN(r))return new Margin(s,o);let l=NaN;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),isNaN(l)?new Margin(s,o):new Margin(s,o,r,l)}else return new Margin}static stringify(t){return Debug&&Util.s(t,Margin),t.top.toString()+" "+t.right.toString()+" "+t.bottom.toString()+" "+t.left.toString()}static stringifyFixed(t){return Util.t(t,"number",Margin,"stringifyFixed:digits"),i=>i.top.toFixed(t)+" "+i.right.toFixed(t)+" "+i.bottom.toFixed(t)+" "+i.left.toFixed(t)}toString(){return"Margin("+this.top+","+this.right+","+this.bottom+","+this.left+")"}equals(t){return t instanceof Margin?this.an===t.top&&this.fn===t.right&&this.cn===t.bottom&&this.un===t.left:!1}equalTo(t,i,e,s){return this.an===t&&this.fn===i&&this.cn===e&&this.un===s}equalsApprox(t){return Geo.p(this.an,t.top)&&Geo.p(this.fn,t.right)&&Geo.p(this.cn,t.bottom)&&Geo.p(this.un,t.left)}get top(){return this.an}set top(t){Debug&&(Util.r(t,Margin,"top"),this.st(t)),this.an=t}get right(){return this.fn}set right(t){Debug&&(Util.r(t,Margin,"right"),this.st(t)),this.fn=t}get bottom(){return this.cn}set bottom(t){Debug&&(Util.r(t,Margin,"bottom"),this.st(t)),this.cn=t}get left(){return this.un}set left(t){Debug&&(Util.r(t,Margin,"left"),this.st(t)),this.un=t}isReal(){return isFinite(this.top)&&isFinite(this.right)&&isFinite(this.bottom)&&isFinite(this.left)}static Hg=new Margin(0,0,0,0).ot();static uC=new Margin(2,2,2,2).ot();static dC=[];static a(){const t=Margin.dC.pop();return t===void 0?new Margin:t}static o(t){Margin.dC.push(t)}}class Spot{S;P;Is;Os;f;constructor(t,i,e,s){t===void 0?(this.S=0,this.P=0,this.Is=0,this.Os=0):(i===void 0&&(i=0),e===void 0&&(e=0),s===void 0&&(s=0),this.x=t,this.y=i,this.offsetX=e,this.offsetY=s),this.f=!1}c(t){return this.S=t.S,this.P=t.P,this.Is=t.Is,this.Os=t.Os,this}setTo(t,i,e,s){return Debug&&(this.Sw(t,"setTo:x"),this.Sw(i,"setTo:y"),this.Mw(e,"setTo:offx"),this.Mw(s,"setTo:offy"),this.st()),this.S=t,this.P=i,this.Is=e,this.Os=s,this}set(t){return Debug&&(Util.s(t,Spot,Spot,"set:s"),this.st()),this.S=t.S,this.P=t.P,this.Is=t.Is,this.Os=t.Os,this}copy(){const t=new Spot;return t.S=this.S,t.P=this.P,t.Is=this.Is,t.Os=this.Os,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ft(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}st(t){if(Debug&&this.f){let i="The Spot is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}Ke(t){return this.S=NaN,this.P=NaN,this.Is=t,this}Sw(t,i){(isNaN(t)||t>1||t<0)&&Util.G(t,"0 <= "+i+" <= 1",Spot,i)}Mw(t,i){(isNaN(t)||t===1/0||t===-1/0)&&Util.G(t,"real number, not NaN or Infinity",Spot,i)}static parse(t){if(typeof t=="string"){if(t=t.trim(),t==="None")return Spot.None;if(t==="TopLeft")return Spot.TopLeft;if(t==="Top"||t==="TopCenter"||t==="MiddleTop")return Spot.TopCenter;if(t==="TopRight")return Spot.TopRight;if(t==="Left"||t==="LeftCenter"||t==="MiddleLeft")return Spot.LeftCenter;if(t==="Center")return Spot.Center;if(t==="Right"||t==="RightCenter"||t==="MiddleRight")return Spot.RightCenter;if(t==="BottomLeft")return Spot.BottomLeft;if(t==="Bottom"||t==="BottomCenter"||t==="MiddleBottom")return Spot.BottomCenter;if(t==="BottomRight")return Spot.BottomRight;if(t==="TopSide")return Spot.TopSide;if(t==="LeftSide")return Spot.LeftSide;if(t==="RightSide")return Spot.RightSide;if(t==="BottomSide")return Spot.BottomSide;if(t==="TopBottomSides")return Spot.TopBottomSides;if(t==="LeftRightSides")return Spot.LeftRightSides;if(t==="TopLeftSides")return Spot.TopLeftSides;if(t==="TopRightSides")return Spot.TopRightSides;if(t==="BottomLeftSides")return Spot.BottomLeftSides;if(t==="BottomRightSides")return Spot.BottomRightSides;if(t==="NotTopSide")return Spot.NotTopSide;if(t==="NotLeftSide")return Spot.NotLeftSide;if(t==="NotRightSide")return Spot.NotRightSide;if(t==="NotBottomSide")return Spot.NotBottomSide;if(t==="AllSides")return Spot.AllSides;if(t==="Default")return Spot.Default;const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n!==void 0&&n.length>0&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n!==void 0&&n.length>0&&(l=parseFloat(n)),new Spot(s,o,r,l)}else return new Spot}static stringify(t){return Debug&&Util.s(t,Spot),t.isSpot()?t.x.toString()+" "+t.y.toString()+" "+t.offsetX.toString()+" "+t.offsetY.toString():t.toString()}static stringifyFixed(t){return Util.t(t,"number",Spot,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.offsetX.toFixed(t)+" "+i.offsetY.toFixed(t)}toString(){return this.isSpot()?this.Is===0&&this.Os===0?"Spot("+this.x+","+this.y+")":"Spot("+this.x+","+this.y+","+this.offsetX+","+this.offsetY+")":this.equals(Spot.None)?"None":this.equals(Spot.TopLeft)?"TopLeft":this.equals(Spot.TopCenter)?"Top":this.equals(Spot.TopRight)?"TopRight":this.equals(Spot.LeftCenter)?"Left":this.equals(Spot.Center)?"Center":this.equals(Spot.RightCenter)?"Right":this.equals(Spot.BottomLeft)?"BottomLeft":this.equals(Spot.BottomCenter)?"Bottom":this.equals(Spot.BottomRight)?"BottomRight":this.equals(Spot.TopSide)?"TopSide":this.equals(Spot.LeftSide)?"LeftSide":this.equals(Spot.RightSide)?"RightSide":this.equals(Spot.BottomSide)?"BottomSide":this.equals(Spot.TopBottomSides)?"TopBottomSides":this.equals(Spot.LeftRightSides)?"LeftRightSides":this.equals(Spot.TopLeftSides)?"TopLeftSides":this.equals(Spot.TopRightSides)?"TopRightSides":this.equals(Spot.BottomLeftSides)?"BottomLeftSides":this.equals(Spot.BottomRightSides)?"BottomRightSides":this.equals(Spot.NotTopSide)?"NotTopSide":this.equals(Spot.NotLeftSide)?"NotLeftSide":this.equals(Spot.NotRightSide)?"NotRightSide":this.equals(Spot.NotBottomSide)?"NotBottomSide":this.equals(Spot.AllSides)?"AllSides":this.equals(Spot.Default)?"Default":"None"}equals(t){return t instanceof Spot?(this.S===t.x||isNaN(this.S)&&isNaN(t.x))&&(this.P===t.y||isNaN(this.P)&&isNaN(t.y))&&this.Is===t.offsetX&&this.Os===t.offsetY:!1}opposite(){return new Spot(.5-(this.S-.5),.5-(this.P-.5),-this.Is,-this.Os)}includesSide(t){if(!this.isSide())return!1;if(!t.isSide())if(t.equals(Spot.Left))t=Spot.LeftSide;else if(t.equals(Spot.Right))t=Spot.RightSide;else if(t.equals(Spot.Top))t=Spot.TopSide;else if(t.equals(Spot.Bottom))t=Spot.BottomSide;else return!1;const i=this.Os,e=t.offsetY;return(i&e)===e}get x(){return this.S}set x(t){Debug&&(this.Sw(t,"x"),this.st(t)),this.S=t}get y(){return this.P}set y(t){Debug&&(this.Sw(t,"y"),this.st(t)),this.P=t}get offsetX(){return this.Is}set offsetX(t){Debug&&(this.Mw(t,"offsetX"),this.st(t)),this.Is=t}get offsetY(){return this.Os}set offsetY(t){Debug&&(this.Mw(t,"offsetY"),this.st(t)),this.Os=t}isSpot(){return!isNaN(this.x)&&!isNaN(this.y)}isNoSpot(){return isNaN(this.x)||isNaN(this.y)}isSide(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===1&&this.offsetY!==0}isNone(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===0&&this.offsetY===0}isDefault(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===-1&&this.offsetY===0}static None=new Spot(0,0,0,0).Ke(0).ot();static Default=new Spot(0,0,-1,0).Ke(-1).ot();static TopLeft=new Spot(0,0,0,0).ot();static TopCenter=new Spot(.5,0,0,0).ot();static TopRight=new Spot(1,0,0,0).ot();static LeftCenter=new Spot(0,.5,0,0).ot();static Center=new Spot(.5,.5,0,0).ot();static RightCenter=new Spot(1,.5,0,0).ot();static BottomLeft=new Spot(0,1,0,0).ot();static BottomCenter=new Spot(.5,1,0,0).ot();static BottomRight=new Spot(1,1,0,0).ot();static MiddleTop=Spot.TopCenter;static MiddleLeft=Spot.LeftCenter;static MiddleRight=Spot.RightCenter;static MiddleBottom=Spot.BottomCenter;static Top=Spot.TopCenter;static Left=Spot.LeftCenter;static Right=Spot.RightCenter;static Bottom=Spot.BottomCenter;static TopSide=new Spot(0,0,1,1).Ke(1).ot();static LeftSide=new Spot(0,0,1,2).Ke(1).ot();static RightSide=new Spot(0,0,1,4).Ke(1).ot();static BottomSide=new Spot(0,0,1,8).Ke(1).ot();static TopBottomSides=new Spot(0,0,1,9).Ke(1).ot();static LeftRightSides=new Spot(0,0,1,6).Ke(1).ot();static TopLeftSides=new Spot(0,0,1,3).Ke(1).ot();static TopRightSides=new Spot(0,0,1,5).Ke(1).ot();static BottomLeftSides=new Spot(0,0,1,10).Ke(1).ot();static BottomRightSides=new Spot(0,0,1,12).Ke(1).ot();static NotTopSide=new Spot(0,0,1,14).Ke(1).ot();static NotLeftSide=new Spot(0,0,1,13).Ke(1).ot();static NotRightSide=new Spot(0,0,1,11).Ke(1).ot();static NotBottomSide=new Spot(0,0,1,7).Ke(1).ot();static AllSides=new Spot(0,0,1,15).Ke(1).ot();static Kk=new Spot(.156,.156).ot();static Uk=new Spot(.844,.844).ot();static gC=[];static a(){const t=Spot.gC.pop();return t===void 0?new Spot:t}static o(t){Spot.gC.push(t)}}class Transform{m11;m12;m21;m22;dx;dy;constructor(){this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0}set(t){return this.m11=t.m11,this.m12=t.m12,this.m21=t.m21,this.m22=t.m22,this.dx=t.dx,this.dy=t.dy,this}setTo(t,i,e,s,n,o){return this.m11=t,this.m12=i,this.m21=e,this.m22=s,this.dx=n,this.dy=o,this}copy(){const t=new Transform;return t.m11=this.m11,t.m12=this.m12,t.m21=this.m21,t.m22=this.m22,t.dx=this.dx,t.dy=this.dy,t}toString(){return"Transform("+this.m11+","+this.m12+","+this.m21+","+this.m22+","+this.dx+","+this.dy+")"}equals(t){return this.m11===t.m11&&this.m12===t.m12&&this.m21===t.m21&&this.m22===t.m22&&this.dx===t.dx&&this.dy===t.dy}Gk(){return this.dx===0&&this.dy===0&&this.m11===1&&this.m12===0&&this.m21===0&&this.m22===1}Vi(){return this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0,this}af(t){const i=this.m11*t.m11+this.m21*t.m12,e=this.m12*t.m11+this.m22*t.m12,s=this.m11*t.m21+this.m21*t.m22,n=this.m12*t.m21+this.m22*t.m22;return this.dx=this.m11*t.dx+this.m21*t.dy+this.dx,this.dy=this.m12*t.dx+this.m22*t.dy+this.dy,this.m11=i,this.m12=e,this.m21=s,this.m22=n,this}mC(t){const i=1/(t.m11*t.m22-t.m12*t.m21),e=t.m22*i,s=-t.m12*i,n=-t.m21*i,o=t.m11*i,r=i*(t.m21*t.dy-t.m22*t.dx),l=i*(t.m12*t.dx-t.m11*t.dy),h=this.m11*e+this.m21*s,a=this.m12*e+this.m22*s,f=this.m11*n+this.m21*o,c=this.m12*n+this.m22*o;return this.dx=this.m11*r+this.m21*l+this.dx,this.dy=this.m12*r+this.m22*l+this.dy,this.m11=h,this.m12=a,this.m21=f,this.m22=c,this}Pw(){const t=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*t,e=-this.m12*t,s=-this.m21*t,n=this.m11*t,o=t*(this.m21*this.dy-this.m22*this.dx),r=t*(this.m12*this.dx-this.m11*this.dy);return this.m11=i,this.m12=e,this.m21=s,this.m22=n,this.dx=o,this.dy=r,this}ms(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return this;this.Es(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m11*s+this.m21*n,r=this.m12*s+this.m22*n,l=this.m11*-n+this.m21*s,h=this.m12*-n+this.m22*s;return this.m11=o,this.m12=r,this.m21=l,this.m22=h,this.Es(-i,-e),this}Es(t,i){return this.dx+=this.m11*t+this.m21*i,this.dy+=this.m12*t+this.m22*i,this}rt(t,i){return i===void 0&&(i=t),this.m11*=t,this.m12*=t,this.m21*=i,this.m22*=i,this}VD(){if(this.m11===1&&this.m12===0)return 0;let t=Math.atan2(this.m12,this.m11)*180/Math.PI;return t<0&&(t+=360),t}Pt(t){const i=t.x,e=t.y;return t.e(i*this.m11+e*this.m21+this.dx,i*this.m12+e*this.m22+this.dy)}ns(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=t.x-this.dx,l=t.y-this.dy;return t.e(r*e+l*n,r*s+l*o)}Nw(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=i*(this.m21*this.dy-this.m22*this.dx),l=i*(this.m12*this.dx-this.m11*this.dy),h=t.x*1.25,a=t.y*1.2;return t.e(h*e+a*n+r,h*s+a*o+l)}Cw(t){const i=t.x,e=t.y,s=i+t.width,n=e+t.height,o=this.m11,r=this.m12,l=this.m21,h=this.m22,a=this.dx,f=this.dy,c=i*o+e*l+a,u=i*r+e*h+f,d=s*o+e*l+a,m=s*r+e*h+f,g=i*o+n*l+a,p=i*r+n*h+f,y=s*o+n*l+a,x=s*r+n*h+f;let k=c,b=c,S=u,M=u;return k=Math.min(k,d),b=Math.max(b,d),S=Math.min(S,m),M=Math.max(M,m),k=Math.min(k,g),b=Math.max(b,g),S=Math.min(S,p),M=Math.max(M,p),k=Math.min(k,y),b=Math.max(b,y),S=Math.min(S,x),M=Math.max(M,x),t.e(k,S,b-k,M-S),t}static pC=[];static a(){const t=Transform.pC.pop();return t===void 0?new Transform:t}static o(t){Transform.pC.push(t)}static Hk="54a702f3e53909c447824c6706603faf4c"}const Geo={zD:"7da71ca0ad381e90",Un:4*((Math.sqrt(2)-1)/3),yC:null,Aw:w=>{if(w<=0)return 0;let t=Geo.yC;if(t===null){t=[];for(let i=0;i<=2e3;i++)t[i]=Math.sqrt(i);Geo.yC=t}if(w<1){const i=1/w;return i<=2e3?1/t[i|0]:Math.sqrt(w)}else return w<=2e3?t[w|0]:Math.sqrt(w)},p:(w,t)=>{const i=w-t;return i<.5&&i>-.5},q:(w,t)=>{const i=w-t;return i<5e-8&&i>-5e-8},zi:(w,t,i,e,s,n,o)=>{s<=0&&(s=1e-6);let r=0,l=0,h=0,a=0;if(wu-d)if(w-i>s||i-w>s){const g=(e-t)/(i-w)*(n-w)+t;if(g-s<=o&&o<=g+s)return!0}else return!0;else if(t-e>s||e-t>s){const g=(i-w)/(e-t)*(o-t)+w;if(g-s<=n&&n<=g+s)return!0}else return!0}return!1},Lw:(w,t,i,e,s,n,o,r,l,h,a,f)=>{if(!Geo.zi(w,t,o,r,f,i,e)||!Geo.zi(w,t,o,r,f,s,n)){const c=(w+i)/2,u=(t+e)/2,d=(i+s)/2,m=(e+n)/2,g=(s+o)/2,p=(n+r)/2,y=(c+d)/2,x=(u+m)/2,k=(d+g)/2,b=(m+p)/2,S=(y+k)/2,M=(x+b)/2;return Geo.Lw(w,t,c,u,y,x,S,M,l,h,a,f)||Geo.Lw(S,M,k,b,g,p,o,r,l,h,a,f)}else return Geo.zi(w,t,o,r,f,h,a)},wC:(w,t,i,e,s,n,o,r,l)=>{const h=(w+i)/2,a=(t+e)/2,f=(i+s)/2,c=(e+n)/2,u=(s+o)/2,d=(n+r)/2,m=(h+f)/2,g=(a+c)/2,p=(f+u)/2,y=(c+d)/2;return l.e((m+p)/2,(g+y)/2),l},XD:(w,t,i,e,s,n,o,r)=>{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,f=(e+n)/2,c=(s+o)/2,u=(n+r)/2,d=(l+a)/2,m=(h+f)/2,g=(a+c)/2,p=(f+u)/2;return Point.direction(d,m,g,p)},gu:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.zi(w,t,o,r,l,i,e)||!Geo.zi(w,t,o,r,l,s,n)){const a=(w+i)/2,f=(t+e)/2,c=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+c)/2,p=(f+u)/2,y=(c+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.gu(w,t,a,f,g,p,k,b,l,h),Geo.gu(k,b,y,x,d,m,o,r,l,h)}else h.unionNoCheck(w,t,0,0),h.unionNoCheck(o,r,0,0);return h},Gn:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.zi(w,t,o,r,l,i,e)||!Geo.zi(w,t,o,r,l,s,n)){const a=(w+i)/2,f=(t+e)/2,c=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+c)/2,p=(f+u)/2,y=(c+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.Gn(w,t,a,f,g,p,k,b,l,h),Geo.Gn(k,b,y,x,d,m,o,r,l,h)}else h.length===0&&(h.push(w),h.push(t)),h.push(o),h.push(r);return h},qk:(w,t,i,e,s,n,o,r,l,h)=>{if(Geo.zi(w,t,s,n,h,i,e))return Geo.zi(w,t,s,n,h,r,l);{const a=(w+i)/2,f=(t+e)/2,c=(i+s)/2,u=(e+n)/2,d=(a+c)/2,m=(f+u)/2;return Geo.qk(w,t,a,f,d,m,o,r,l,h)||Geo.qk(d,m,c,u,s,n,o,r,l,h)}},sE:(w,t,i,e,s,n,o)=>{const r=(w+i)/2,l=(t+e)/2,h=(i+s)/2,a=(e+n)/2;return o.e((r+h)/2,(l+a)/2),o},jk:(w,t,i,e,s,n,o,r)=>{if(Geo.zi(w,t,s,n,o,i,e))r.unionNoCheck(w,t,0,0),r.unionNoCheck(s,n,0,0);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,f=(e+n)/2,c=(l+a)/2,u=(h+f)/2;Geo.jk(w,t,l,h,c,u,o,r),Geo.jk(c,u,a,f,s,n,o,r)}return r},qg:(w,t,i,e,s,n,o,r)=>{if(Geo.zi(w,t,s,n,o,i,e))r.length===0&&(r.push(w),r.push(t)),r.push(s),r.push(n);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,f=(e+n)/2,c=(l+a)/2,u=(h+f)/2;Geo.qg(w,t,l,h,c,u,o,r),Geo.qg(c,u,a,f,s,n,o,r)}return r},jg:(w,t,i,e,s,n,o,r,l,h,a,f,c,u)=>{if(!Geo.zi(w,t,o,r,c,i,e)||!Geo.zi(w,t,o,r,c,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,S=(g+y)/2,M=(p+x)/2,A=(k+S)/2,C=(b+M)/2;let P=1/0,N=!1,T=0,L=0;if(Geo.jg(w,t,d,m,k,b,A,C,l,h,a,f,c,u)){const D=(u.x-l)*(u.x-l)+(u.y-h)*(u.y-h);D{let u=0;if(!Geo.zi(w,t,o,r,c,i,e)||!Geo.zi(w,t,o,r,c,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,S=(g+y)/2,M=(p+x)/2,A=(k+S)/2,C=(b+M)/2;u+=Geo.Wg(w,t,d,m,k,b,A,C,l,h,a,f,c),u+=Geo.Wg(A,C,S,M,y,x,o,r,l,h,a,f,c)}else{const d=(w-o)*(h-f)-(t-r)*(l-a);if(d===0)return u;const m=((w*r-t*o)*(l-a)-(w-o)*(l*f-h*a))/d,g=((w*r-t*o)*(h-f)-(t-r)*(l*f-h*a))/d;if(m>=a)return u;let p=0,y=0;if((l>a?l-a:a-l)<(h>f?h-f:f-h)){if(ty)return u}else if(wy)return u;d>0?u++:d<0&&u--}return u},xl:(w,t,i,e,s,n,o)=>{if(Geo.q(w,i)){let r=0,l=0;tl?(o.e(w,l),!1):(o.e(w,h),!0)}else if(Geo.q(t,e)){let r=0,l=0;wl?(o.e(l,t),!1):(o.e(h,t),!0)}else{const r=(i-w)*(i-w)+(e-t)*(e-t),l=((w-s)*(w-i)+(t-n)*(t-e))/r;if(l<-5e-6)return o.e(w,t),!1;if(l>1.000005)return o.e(i,e),!1;{const h=w+l*(i-w),a=t+l*(e-t);return o.e(h,a),!0}}},Hn:(w,t,i,e,s,n,o,r,l)=>{if(Geo.p(w,i)&&Geo.p(t,e))return l.e(w,t),!1;if(Geo.q(s,o)){if(Geo.q(w,i))return Geo.xl(w,t,i,e,s,n,l),!1;{const a=(e-t)/(i-w)*(s-w)+t;return Geo.xl(w,t,i,e,s,a,l)}}else{const h=(r-n)/(o-s);if(Geo.q(w,i)){const a=h*(w-s)+n;let f=0,c=0;return tc?(l.e(w,c),!1):(l.e(w,a),!0)}else{const a=(e-t)/(i-w);if(Geo.q(h,a))return Geo.xl(w,t,i,e,s,n,l),!1;{const f=(a*w-h*s+n-t)/(a-h);if(Geo.q(a,0)){let c=0,u=0;return wu?(l.e(u,t),!1):(l.e(f,t),!0)}else{const c=a*(f-w)+t;return Geo.xl(w,t,i,e,f,c,l)}}}}},nE:(w,t,i,e,s)=>Geo.Hn(i.x,i.y,e.x,e.y,w.x,w.y,t.x,t.y,s),oE:(w,t,i,e,s,n,o,r,l,h)=>{let a=1/0;function f(S,M){const A=(S-w)*(S-w)+(M-t)*(M-t);Aw?i-w:w-i)<.5){const S=1-(i-k)*(i-k)/(y*y);if(S<0)return l;const M=Math.sqrt(S),A=x*M+b,C=-x*M+b;f(i,A),f(i,C)}else{const S=(e-t)/(i-w),M=1/(y*y)+S*S/(x*x),A=2*S*(t-S*w)/(x*x)-2*S*b/(x*x)-2*k/(y*y),C=2*S*w*b/(x*x)-2*t*b/(x*x)+b*b/(x*x)+k*k/(y*y)-1+(t-S*w)*(t-S*w)/(x*x),P=A*A-4*M*C;if(P<0)return l;const N=Math.sqrt(P),T=(-A+N)/(2*M);f(T,S*T-S*w+t);const L=(-A-N)/(2*M);f(L,S*L-S*w+t)}return l},bl:(w,t,i,e,s,n,o,r,l)=>{let h=1e21,a=w,f=t;if(Geo.Hn(w,t,w,e,s,n,o,r,l)){const c=(l.x-s)*(l.x-s)+(l.y-n)*(l.y-n);cGeo.cC(w.x,w.y,w.width,w.height,t.x,t.y,i.x,i.y),cC:(w,t,i,e,s,n,o,r)=>{const l=w,h=w+i,a=t,f=t+e;if(s===o){let c=0,u=0;return n=a}if(n===r){let c=0,u=0;return s=l}return!!(Rect.contains(w,t,i,e,s,n)||Rect.contains(w,t,i,e,o,r)||Geo.uu(l,a,h,a,s,n,o,r)||Geo.uu(h,a,h,f,s,n,o,r)||Geo.uu(h,f,l,f,s,n,o,r)||Geo.uu(l,f,l,a,s,n,o,r))},uu:(w,t,i,e,s,n,o,r)=>w===i&&t===e&&s===o&&n===r?w===s&&t===n:Geo.cu(w,t,i,e,s,n)*Geo.cu(w,t,i,e,o,r)<=0&&Geo.cu(s,n,o,r,w,t)*Geo.cu(s,n,o,r,i,e)<=0,cu:(w,t,i,e,s,n)=>{const o=i-w,r=e-t;let l=s-w,h=n-t,a=l*r-h*o;return a===0&&(a=l*o+h*r,a>0&&(l-=o,h-=r,a=l*o+h*r,a<0&&(a=0))),a},vg:w=>(w<0&&(w+=360),w>=360&&(w-=360),w),xC:(w,t,i,e,s,n)=>{const o=Math.PI;n||(e=e*(o/180),s=s*(o/180));const r=e>s?-1:1,l=1e-5,h=o*2,a=[],f=o/2;let c=e,u=Math.min(h,Math.abs(s-e));if(ul;){const d=c+r*Math.min(u,f);a.push(Geo.YD(i,c,d,w,t)),u-=Math.abs(d-c),c=d}return a},YD:(w,t,i,e,s)=>{const n=(i-t)/2,o=w*Math.cos(n),r=w*Math.sin(n),l=o,h=-r,a=l*l+h*h,f=a+l*o+h*r,c=4/3*(Math.sqrt(2*a*f)-f)/(l*r-h*o),u=l-c*h,d=h+c*l,m=u,g=-d,p=n+t,y=Math.cos(p),x=Math.sin(p);return[e+w*Math.cos(t),s+w*Math.sin(t),e+u*y-d*x,s+u*x+d*y,e+m*y-g*x,s+m*x+g*y,e+w*Math.cos(i),s+w*Math.sin(i)]},Gg:(w,t,i,e,s,n,o)=>{const r=s,l=n,h=Math.floor((w-i)/r)*r+i,a=Math.floor((t-e)/l)*l+e;let f=h;h+r-w{let i=Math.max(w,t),e=Math.min(w,t),s=1,n=1;do s=i%e,n=e,i=e,e=s;while(s>0);return n},KD:(w,t,i,e)=>{const s=i<0,n=e<0;let o=0,r=0,l=0;w{let o=0;if(e>0)if(i>0){const r=w*w,l=t*t,h=w*i,a=t*e;let f=-l+a,c=-l+Math.sqrt(h*h+a*a),u=f;const d=9999999999;for(let p=0;p0)f=u;else if(k<0)c=u;else break}s=r*i/(u+r),n=l*e/(u+l);const m=s-i,g=n-e;o=Math.sqrt(m*m+g*g)}else s=0,n=t,o=Math.abs(e-t);else{const r=w*w-t*t,l=w*i;if(l(w[w.Line=1]="Line",w[w.Rectangle=2]="Rectangle",w[w.Ellipse=3]="Ellipse",w[w.Path=4]="Path",w))(GeometryType||{}),GeometryStretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w))(GeometryStretch||{});class Geometry{l;$g;Qg;ff;mu;pu;jn;Wn;vn;it;Pe;Ne;se;ne;Bs;cf;uf;constructor(t){Debug&&arguments.length>1&&Util.n("Geometry constructor can take at most one optional argument, the Geometry type."),GSet.vi(this),this.l=2,t===void 0?t=4:Debug&&Util.tt(t,GeometryType,"GeometryType"),this.it=t,this.Pe=0,this.Ne=0,this.se=0,this.ne=0,t===4?this.Bs=new List:this.Bs=Geometry.Dw,this.$g=this.Bs.dt,this.Qg=new Rect().w(),this.ff=null,this.mu=null,this.pu=NaN,this.jn=Spot.TopLeft,this.Wn=Spot.BottomRight,this.cf=NaN,this.uf=NaN,this.vn=2}copy(){const t=new Geometry;if(t.l=this.l&-2,t.it=this.it,t.Pe=this.Pe,t.Ne=this.Ne,t.se=this.se,t.ne=this.ne,this.it===4){const i=this.Bs.h,e=t.Bs;for(let s=0;si.toString(t)}fi(t){t in GeometryType?this.type=t:Util.ur(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e;switch(this.type){case 1:return t<0?"M"+this.startX.toString()+" "+this.startY.toString()+"L"+this.endX.toString()+" "+this.endY.toString():"M"+i(this.startX)+" "+i(this.startY)+"L"+i(this.endX)+" "+i(this.endY);case 2:return e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0?"M"+e.x.toString()+" "+e.y.toString()+"H"+e.right.toString()+"V"+e.bottom.toString()+"H"+e.left.toString()+"z":"M"+i(e.x)+" "+i(e.y)+"H"+i(e.right)+"V"+i(e.bottom)+"H"+i(e.left)+"z";case 3:if(e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0){const r=e.left.toString()+" "+(e.y+e.height/2).toString(),l=e.right.toString()+" "+(e.y+e.height/2).toString();return"M"+r+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+l+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+r}else{const r=i(e.left)+" "+i(e.y+e.height/2),l=i(e.right)+" "+i(e.y+e.height/2);return"M"+r+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+l+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+r}case 4:let s="";const n=this.figures.h,o=n.length;for(let r=0;r0&&(s+=" x "),l.isFilled&&(s+="F "),s+=l.toString(t)}return s;default:return GeometryType[this.type]}}static fillPath(t){typeof t!="string"&&Util.Bi(t,"string",Geometry,"fillPath:str");const i=t.split(/[Xx]/),e=i.length;let s="";for(let n=0;n=k-1||o[r+1].match(N)!==null?!0:(u=!1,!1)}function m(){return r++,o[r]}function g(L){let D=parseFloat(m()),F=parseFloat(m());l===l.toLowerCase()&&(D=c.x+D,F=c.y+F),L.e(D,F)}function p(){return g(c),c}function y(){return g(f),f}function x(){const L=h.toLowerCase();return L==="c"||L==="s"||L==="q"||L==="t"?new Point(2*c.x-f.x,2*c.y-f.y):new Point(c.x,c.y)}const k=o.length,b=GeoStream.SC(null);let S=!1,M=!1,A=!1,C=!0,P=null;const N=new RegExp("["+Geometry._g+"]");for(;!(r>=k-1);){if(h=l,l=m(),l==="")continue;u=!0;let L=!1;switch(l.toUpperCase()){case"X":C=!0,S=!1,M=!1;break;case"M":for(P=p(),b.Ci===null||C===!0?(b.yu(P.x,P.y,S,!1,!M,A),C=!1):b.GD(P.x,P.y),a.c(c);!d();)P=p(),b.yr(P.x,P.y);break;case"L":for(;!d();)P=p(),b.yr(P.x,P.y);u&&(L=!0);break;case"H":for(;!d();)c.e((l===l.toLowerCase()?c.x:0)+parseFloat(m()),c.y),b.yr(c.x,c.y);break;case"V":for(;!d();)c.e(c.x,(l===l.toLowerCase()?c.y:0)+parseFloat(m())),b.yr(c.x,c.y);u&&(L=!0);break;case"C":for(;!d();){const D=new Point;g(D);const F=y(),R=p();b.wr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(L=!0);break;case"S":for(;!d();){const D=x(),F=y(),R=p();b.wr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(L=!0);break;case"Q":for(;!d();){const D=y(),F=p();b.Fw(D.x,D.y,F.x,F.y)}u&&(L=!0);break;case"T":for(;!d();){const D=x();f.c(D);const F=p();b.Fw(D.x,D.y,F.x,F.y),f.c(F)}u&&(L=!0);break;case"B":for(;!d();){const D=parseFloat(m()),F=parseFloat(m());let R=parseFloat(m()),I=parseFloat(m());const O=parseFloat(m());let V=O,K=!1;d()||(V=parseFloat(m()),d()||(K=parseFloat(m())!==0)),l===l.toLowerCase()&&(R+=c.x,I+=c.y),b.HD(D,F,R,I,O,V,K)}u&&(L=!0);break;case"A":for(;!d();){const D=Math.abs(parseFloat(m())),F=Math.abs(parseFloat(m())),R=parseFloat(m());let I=!1,O=!1,V=0,K=0;const B=m();B.length===1?(I=!!parseFloat(B),O=!!parseFloat(m()),V=parseFloat(m()),K=parseFloat(m())):B.length===2?(I=!!parseFloat(B[0]),O=!!parseFloat(B[1]),V=parseFloat(m()),K=parseFloat(m())):(I=!!parseFloat(B[0]),O=!!parseFloat(B[1]),V=parseFloat(B.slice(2)),K=parseFloat(m())),l===l.toLowerCase()&&(V=c.x+V,K=c.y+K),c.e(V,K),b.qD(D,F,R,I,O,V,K)}u&&(L=!0);break;case"Z":b.jD(),c.c(a);break;case"F":{let D="",F=1;for(;o[r+F];){if(o[r+F]==="0"){A=!0,F++;continue}if(o[r+F].match(/[Uu]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?S=!0:b.WD();break}case"U":{let D="",F=1;for(;o[r+F];){if(o[r+F].match(/[Ff]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?M=!0:b.vD(!1);break}default:if(l==="0"||l==="1")break;Util.ht("Unknown geometry command: "+l);break}if(L){Util.ht(`Bad geometry command: ${l}, next token: ${m()}, +string: ${t}`);break}}const T=b.tm;if(GeoStream.MC(b),i){const L=T.figures.iterator;for(;L.next();){const D=L.value;D.isFilled=!0}}return T}static PC(t,i){const e=t.length,s=Point.a();for(let n=0;n=t)return 0;if((n>r?n-r:r-n)<(o>l?o-l:l-o)){if(ol)return 0}else if(fo)return 0}else if(nr)return 0}else if(an)return 0;return h>0?1:-1}CC(t,i,e){const s=this.figures.h,n=s.length;for(let o=0;o1&&(t=1),i===void 0&&(i=new Point),this.type===1)return i.e(this.startX+t*(this.endX-this.startX),this.startY+t*(this.endY-this.startY)),i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[c*2],y=g[c*2+1],x=g[c*2+2],k=g[c*2+3];return i.e(p+(x-p)*m,y+(k-y)*m),i}l+=u}}return i}getAngleAlongPath(t){if(t<0?t=0:t>1&&(t=1),this.type===1)return Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI;const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=i.length,o=s*t;let r=0;for(let l=0;l=o){const u=i[l],d=u[f*2],m=u[f*2+1],g=u[f*2+2],p=u[f*2+3];return Math.abs(g-d)<1&&Math.abs(p-m)<1?0:Math.abs(g-d)<1?p-m>=0?90:270:Math.abs(p-m)<1?g-d>=0?0:180:Math.atan2(p-m,g-d)*180/Math.PI}r+=c}}return NaN}getPointAndAngleAlongPath(t,i){if(t<0?t=0:t>1&&(t=1),i===void 0&&(i=[]),i.length=3,this.type===1)return i[0]=this.startX+t*(this.endX-this.startX),i[1]=this.startY+t*(this.endY-this.startY),i[2]=Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI,i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[c*2],y=g[c*2+1],x=g[c*2+2],k=g[c*2+3];i[0]=p+(x-p)*m,i[1]=y+(k-y)*m;let b;return Math.abs(x-p)<1&&Math.abs(k-y)<1?b=0:Math.abs(x-p)<1?b=k-y>=0?90:270:Math.abs(k-y)<1?b=x-p>=0?0:180:b=Math.atan2(k-y,x-p)*180/Math.PI,i[2]=b,i}l+=u}}return i}getFractionForPoint(t){if(this.type===1){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=t.x,r=t.y;let l=0,h=0;if(i===s)return e=h?h===e?0:1:Math.abs(r-e)/(h-l);if(e===n)return i=h?h===i?0:1:Math.abs(o-i)/(h-l);{const a=(s-i)*(s-i)+(n-e)*(n-e),f=Point.a();Geo.xl(i,e,s,n,o,r,f);const c=f.x,u=f.y;return Point.o(f),Math.sqrt(((c-i)*(c-i)+(u-e)*(u-e))/a)}}}else if(this.type===2){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=s-i,r=n-e,l=o*2+r*2;let h=t.x,a=t.y;h=Math.min(Math.max(h,i),s),a=Math.min(Math.max(a,e),n);const f=Math.abs(h-i),c=Math.abs(h-s),u=Math.abs(a-e),d=Math.abs(a-n),m=Math.min(f,c,u,d);if(m===u)return h/l;if(m===c)return(o+a)/l;if(m===d)return(o*2+r-h)/l;if(m===f)return(o*2+r*2-a)/l}}else{const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=Point.a();let o=1/0,r=0,l=0;const h=i.length;let a=0,f=0;for(let u=0;u1?1:c}return 0}get flattenedSegments(){return this.AC(),this.ff}AC(){if(this.ff===null){const t=this.ff=[],i=this.mu=[];this.$D(t,i)}}get flattenedLengths(){return this.AC(),this.mu}get flattenedTotalLength(){let t=this.pu;if(isNaN(t)){if(this.type===1){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=Math.sqrt(i*i+e*e)}else if(this.type===2){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=i*2+e*2}else{const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=4&&(t.push(e),i.push(this.Zk(e))),e=[],e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY,h=r,a=l;break;case 2:e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY;break;case 3:Geo.Gn(r,l,d.point1X,d.point1Y,d.point2X,d.point2Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 4:Geo.qg(r,l,d.point1X,d.point1Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 5:{const m=d.To(o),g=m.length;if(g===0){e.push(d.centerX),e.push(d.centerY),r=d.centerX,l=d.centerY;break}for(let p=0;p=4&&(t.push(e),i.push(this.Zk(e)))}}}get type(){return this.it}set type(t){this.it!==t&&(Debug&&Util.tt(t,GeometryType,"GeometryType"),this.f&&Util.F(this,t),this.it=t,t===4?this.Bs=new List:(Geometry.Dw===null&&(Geometry.Dw=new List().w()),this.Bs=Geometry.Dw),this.Nt=!0)}get startX(){return this.Pe}set startX(t){this.Pe!==t&&(Debug&&Util.r(t,Geometry,"startX"),this.f&&Util.F(this,t),this.Pe=t,this.Nt=!0)}get startY(){return this.Ne}set startY(t){this.Ne!==t&&(Debug&&Util.r(t,Geometry,"startY"),this.f&&Util.F(this,t),this.Ne=t,this.Nt=!0)}get endX(){return this.se}set endX(t){this.se!==t&&(Debug&&Util.r(t,Geometry,"endX"),this.f&&Util.F(this,t),this.se=t,this.Nt=!0)}get endY(){return this.ne}set endY(t){this.ne!==t&&(Debug&&Util.r(t,Geometry,"endY"),this.f&&Util.F(this,t),this.ne=t,this.Nt=!0)}get figures(){return this.Bs}set figures(t){this.Bs!==t&&(Debug&&Util.s(t,List,Geometry,"figures"),this.f&&Util.F(this,t),this.Bs=t,this.Nt=!0)}add(t){return this.Bs.add(t),this}setSpots(t,i,e,s,n,o,r,l){return this.f&&Util.F(this),this.jn=new Spot(t,i,n,o).w(),this.Wn=new Spot(e,s,r,l).w(),this}get spot1(){return this.jn}set spot1(t){Debug&&Util.s(t,Spot,Geometry,"spot1"),this.f&&Util.F(this,t),this.jn=t.L()}get spot2(){return this.Wn}set spot2(t){Debug&&Util.s(t,Spot,Geometry,"spot2"),this.f&&Util.F(this,t),this.Wn=t.L()}get defaultStretch(){return this.vn}set defaultStretch(t){this.vn=t}get bounds(){return this.Wk()&&this.Rw(),this.Qg}}Geometry.stringify=Geometry.stringify,Geometry.stringifyFixed=Geometry.stringifyFixed,Geometry.fillPath=Geometry.fillPath,Geometry.parse=Geometry.parse;class PathFigure{l;Pe;Ne;df;im;Ue;constructor(t,i,e,s,n){e===void 0&&(e=!0),s===void 0&&(s=!0),n===void 0&&(n=!1),this.l=2|(e?4:0)|(s?8:0)|(n?16:0),t!==void 0?(Debug&&Util.r(t,PathFigure,"sx"),this.Pe=t):this.Pe=0,i!==void 0?(Debug&&Util.r(i,PathFigure,"sy"),this.Ne=i):this.Ne=0,this.df=new List,this.im=this.df.dt,this.Ue=null}copy(){const t=new PathFigure;t.l=this.l&-2,t.Pe=this.Pe,t.Ne=this.Ne;const i=this.df.h,e=i.length,s=t.df;for(let n=0;no===0?"0":o.toFixed(t);i="M"+n(this.startX)+" "+n(this.startY)}const e=this.segments.h,s=e.length;for(let n=0;n(w[w.Move=1]="Move",w[w.Line=2]="Line",w[w.Bezier=3]="Bezier",w[w.QuadraticBezier=4]="QuadraticBezier",w[w.Arc=5]="Arc",w[w.SvgArc=6]="SvgArc",w))(SegmentType||{});class PathSegment{it;l;se;ne;dn;kl;Sl;xr;Vs;constructor(t,i,e,s,n,o,r,l){if(GSet.vi(this),t===void 0?t=2:Debug&&Util.tt(t,SegmentType,"SegmentType"),this.it=t,this.l=2,i!==void 0?(Debug&&Util.r(i,PathSegment,"ex"),this.se=i):this.se=0,e!==void 0?(Debug&&Util.r(e,PathSegment,"ey"),this.ne=e):this.ne=0,s===void 0&&(s=0),n===void 0&&(n=0),o===void 0&&(o=0),r===void 0&&(r=0),t===6){let h=o;h=h%360,h<0&&(h+=360),this.dn=h,this.kl=0,Debug&&Util.r(s,PathSegment,"x1"),this.Sl=Math.max(s,0),Debug&&Util.r(n,PathSegment,"y1"),this.xr=Math.max(n,0),typeof r=="boolean"?r&&(this.isLargeArc=!0):typeof r=="number"&&r&&(this.isLargeArc=!0),l&&(this.isClockwiseArc=!0)}else Debug&&Util.r(s,PathSegment,"x1"),this.dn=s,Debug&&Util.r(n,PathSegment,"y1"),this.kl=n,Debug&&Util.r(o,PathSegment,"x2"),t===5&&(o=Math.max(o,0)),this.Sl=o,typeof r=="number"?(t===5&&(r=Math.max(r,0)),this.xr=r):this.xr=0;this.Vs=null}copy(){const t=new PathSegment;return t.it=this.it,t.l=this.l&-2,t.se=this.se,t.ne=this.ne,t.dn=this.dn,t.kl=this.kl,t.Sl=this.Sl,t.xr=this.xr,t}equalsApprox(t){if(!(t instanceof PathSegment)||this.type!==t.type||this.isClosed!==t.isClosed)return!1;switch(this.type){case 1:case 2:return Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY);case 3:return Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY)&&Geo.p(this.point1X,t.point1X)&&Geo.p(this.point1Y,t.point1Y)&&Geo.p(this.point2X,t.point2X)&&Geo.p(this.point2Y,t.point2Y);case 4:return Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY)&&Geo.p(this.point1X,t.point1X)&&Geo.p(this.point1Y,t.point1Y);case 5:return Geo.p(this.startAngle,t.startAngle)&&Geo.p(this.sweepAngle,t.sweepAngle)&&Geo.p(this.centerX,t.centerX)&&Geo.p(this.centerY,t.centerY)&&Geo.p(this.radiusX,t.radiusX)&&Geo.p(this.radiusY,t.radiusY);case 6:return this.isClockwiseArc===t.isClockwiseArc&&this.isLargeArc===t.isLargeArc&&Geo.p(this.xAxisRotation,t.xAxisRotation)&&Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY)&&Geo.p(this.radiusX,t.radiusX)&&Geo.p(this.radiusY,t.radiusY);default:return!1}}fi(t){t in SegmentType?this.type=t:Util.ur(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e="";switch(this.type){case 1:t<0?e="M"+this.endX.toString()+" "+this.endY.toString():e="M"+i(this.endX)+" "+i(this.endY);break;case 2:t<0?e="L"+this.endX.toString()+" "+this.endY.toString():e="L"+i(this.endX)+" "+i(this.endY);break;case 3:t<0?e="C"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.point2X.toString()+" "+this.point2Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="C"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.point2X)+" "+i(this.point2Y)+" "+i(this.endX)+" "+i(this.endY);break;case 4:t<0?e="Q"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="Q"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.endX)+" "+i(this.endY);break;case 5:t<0?e="B"+this.startAngle.toString()+" "+this.sweepAngle.toString()+" "+this.centerX.toString()+" "+this.centerY.toString()+" "+this.radiusX.toString()+" "+this.radiusY.toString():e="B"+i(this.startAngle)+" "+i(this.sweepAngle)+" "+i(this.centerX)+" "+i(this.centerY)+" "+i(this.radiusX)+" "+i(this.radiusY);break;case 6:t<0?e="A"+this.radiusX.toString()+" "+this.radiusY.toString()+" "+this.xAxisRotation.toString()+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+this.endX.toString()+" "+this.endY.toString():e="A"+i(this.radiusX)+" "+i(this.radiusY)+" "+i(this.xAxisRotation)+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+i(this.endX)+" "+i(this.endY);break;default:e=SegmentType[this.type]}return e+(this.isClosed?"z":"")}static Move=1;static Line=2;static Bezier=3;static QuadraticBezier=4;static Arc=5;static SvgArc=6;get f(){return(this.l&1)!==0}set f(t){t?this.l|=1:this.l&=-2}get Nt(){return(this.l&2)!==0}set Nt(t){t?this.l|=2:this.l&=-3}w(){return this.f=!0,this}ft(){return this.f=!1,this}close(){return this.isClosed=!0,this}To(t){if(this.Vs!==null&&t.Nt===!1)return this.Vs;const i=this.radiusX;let e=this.radiusY;if(e===void 0&&(e=i),i===0||e===0)return this.Vs=[],this.Vs;const s=this.dn,n=this.kl,o=Geo.xC(0,0,i1&&(o*=Math.sqrt(p),r*=Math.sqrt(p));let y=(h===a?-1:1)*Math.sqrt((o*o*r*r-o*o*g*g-r*r*m*m)/(o*o*g*g+r*r*m*m));isNaN(y)&&(y=0);let x=y*o*g/r,k=y*-r*m/o;isNaN(x)&&(x=0),isNaN(k)&&(k=0);const b=(s+f)/2+u*x-d*k,S=(n+c)/2+d*x+u*k,M=(X,z)=>Math.sqrt(X*X+z*z),A=(X,z,G,q)=>(X*G+z*q)/(M(X,z)*M(G,q)),C=(X,z,G,q)=>(X*q=1&&(F=0),!a&&F>0&&(F=F-2*Math.PI),a&&F<0&&(F=F+2*Math.PI);const I=o>r?o:r,O=o>r?1:o/r,V=o>r?r/o:1,K=Geo.xC(0,0,I,P,P+F,!0),B=Transform.a();return B.Vi(),B.Es(b,S),B.ms(this.dn,0,0),B.rt(O,V),Geometry.PC(K,B),Transform.o(B),this.Vs=K,this.Vs}get isClosed(){return(this.l&8)!==0}set isClosed(t){this.isClosed!==t&&(t?this.l|=8:this.l&=-9,this.Nt=!0)}get type(){return this.it}set type(t){Debug&&Util.tt(t,SegmentType,"SegmentType"),this.f&&Util.F(this,t),this.it=t,this.Nt=!0}get endX(){return this.se}set endX(t){Debug&&Util.r(t,PathSegment,"endX"),this.f&&Util.F(this,t),this.se=t,this.Nt=!0}get endY(){return this.ne}set endY(t){Debug&&Util.r(t,PathSegment,"endY"),this.f&&Util.F(this,t),this.ne=t,this.Nt=!0}get point1X(){return this.dn}set point1X(t){Debug&&Util.r(t,PathSegment,"point1X"),this.f&&Util.F(this,t),this.dn=t,this.Nt=!0}get point1Y(){return this.kl}set point1Y(t){Debug&&Util.r(t,PathSegment,"point1Y"),this.f&&Util.F(this,t),this.kl=t,this.Nt=!0}get point2X(){return this.Sl}set point2X(t){Debug&&Util.r(t,PathSegment,"point2X"),this.f&&Util.F(this,t),this.Sl=t,this.Nt=!0}get point2Y(){return this.xr}set point2Y(t){Debug&&Util.r(t,PathSegment,"point2Y"),this.f&&Util.F(this,t),this.xr=t,this.Nt=!0}get centerX(){return this.dn}set centerX(t){Debug&&Util.r(t,PathSegment,"centerX"),this.f&&Util.F(this,t),this.dn=t,this.Nt=!0}get centerY(){return this.kl}set centerY(t){Debug&&Util.r(t,PathSegment,"centerY"),this.f&&Util.F(this,t),this.kl=t,this.Nt=!0}get radiusX(){return this.Sl}set radiusX(t){Debug&&Util.r(t,PathSegment,"radiusX"),t<0&&Util.G(t,">= zero",PathSegment,"radiusX"),this.f&&Util.F(this,t),this.Sl=t,this.Nt=!0}get radiusY(){return this.xr}set radiusY(t){Debug&&Util.r(t,PathSegment,"radiusY"),t<0&&Util.G(t,">= zero",PathSegment,"radiusY"),this.f&&Util.F(this,t),this.xr=t,this.Nt=!0}get startAngle(){return this.se}set startAngle(t){Debug&&Util.r(t,PathSegment,"startAngle"),this.f&&Util.F(this,t),t=t%360,t<0&&(t+=360),this.se=t,this.Nt=!0}get sweepAngle(){return this.ne}set sweepAngle(t){Debug&&Util.r(t,PathSegment,"sweepAngle"),this.f&&Util.F(this,t),t>360&&(t=360),t<-360&&(t=-360),this.ne=t,this.Nt=!0}get isClockwiseArc(){return(this.l&4)!==0}set isClockwiseArc(t){this.f&&Util.F(this,t),t?this.l|=4:this.l&=-5,this.Nt=!0}get isLargeArc(){return(this.l&16)!==0}set isLargeArc(t){this.f&&Util.F(this,t),t?this.l|=16:this.l&=-17,this.Nt=!0}get xAxisRotation(){return this.dn}set xAxisRotation(t){Debug&&Util.r(t,PathSegment,"xAxisRotation"),this.f&&Util.F(this,t),t=t%360,t<0&&(t+=360),this.dn=t,this.Nt=!0}}class InputEvent{b;Ow;Ew;em;sm;nm;om;rm;lm;hm;am;fm;cm;um;Do;dm;gm;mm;Ce;constructor(){this.b=null,this.Ow=new Point(0,0).w(),this.Ew=new Point(0,0).w(),this.em=0,this.sm=0,this.nm=1,this.om="",this.rm="",this.lm=!1,this.hm=!1,this.am=0,this.fm=0,this.cm=!1,this.um=!1,this.Do=!1,this.dm=null,this.gm=0,this.mm=null,this.Ce=null}copy(){const t=new InputEvent;return this.clone(t)}clone(t){return t.b=this.b,t.Ow.c(this.viewPoint),t.Ew.c(this.documentPoint),t.em=this.em,t.sm=this.sm,t.nm=this.nm,t.om=this.om,t.rm=this.rm,t.lm=this.lm,t.hm=this.hm,t.am=this.am,t.fm=this.fm,t.cm=this.cm,t.um=this.um,t.Do=this.Do,t.dm=this.dm,t.gm=this.gm,t.mm=this.mm,t.Ce=this.Ce,t}toString(){let t="^";return this.modifiers!==0&&(t+="M:"+this.modifiers),this.button!==0&&(t+="B:"+this.button),this.key!==""&&(t+="K:"+this.key),this.clickCount!==0&&(t+="C:"+this.clickCount),this.delta!==0&&(t+="D:"+this.delta),this.handled&&(t+="h"),this.bubbles&&(t+="b"),this.documentPoint!==null&&(t+="@"+this.documentPoint.toString()),t}get diagram(){return this.b}set diagram(t){this.b=t}get viewPoint(){return this.Ow}set viewPoint(t){Util.s(t,Point,InputEvent,"viewPoint"),this.Ow.c(t)}get documentPoint(){return this.Ew}set documentPoint(t){Util.s(t,Point,InputEvent,"documentPoint"),this.Ew.c(t)}getMultiTouchViewPoint(t,i){const e=this.diagram;return e===null||e.LC(this.event,t,i),i}getMultiTouchDocumentPoint(t,i){const e=this.diagram;return e===null||(e.LC(this.event,t,i),i.c(e.transformViewToDoc(i))),i}get modifiers(){return this.em}set modifiers(t){this.em=t}get button(){return this.sm}set button(t){if(this.sm=t,this.event===null)switch(t){case 0:this.buttons=1;return;case 1:this.buttons=4;return;case 2:this.buttons=2;return}}get buttons(){return this.nm}set buttons(t){this.nm=t}get key(){return this.om}set key(t){this.om=t}get code(){return this.rm}set code(t){this.rm=t}get down(){return this.lm}set down(t){this.lm=t}get up(){return this.hm}set up(t){this.hm=t}get clickCount(){return this.am}set clickCount(t){this.am=t}get delta(){return this.fm}set delta(t){this.fm=t}get isMultiTouch(){return this.cm}set isMultiTouch(t){this.cm=t}get handled(){return this.um}set handled(t){this.um=t}get bubbles(){return this.Do}set bubbles(t){this.Do=t}get event(){return this.dm}set event(t){this.dm=t}get isTouchEvent(){const t=this.event;return t===null?!1:t.pointerType==="touch"||t.pointerType==="pen"}get timestamp(){return this.gm}set timestamp(t){this.gm=t}get targetDiagram(){return this.mm}set targetDiagram(t){this.mm=t}get targetObject(){return this.Ce}set targetObject(t){this.Ce=t}get control(){return(this.modifiers&1)!==0}set control(t){this.modifiers=t?this.modifiers|1:this.modifiers&-2}get shift(){return(this.modifiers&4)!==0}set shift(t){this.modifiers=t?this.modifiers|4:this.modifiers&-5}get alt(){return(this.modifiers&2)!==0}set alt(t){this.modifiers=t?this.modifiers|2:this.modifiers&-3}get meta(){return(this.modifiers&8)!==0}set meta(t){this.modifiers=t?this.modifiers|8:this.modifiers&-9}get left(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===0:(this.buttons&1)!==0}set left(t){t?this.buttons|=1:this.buttons&=-2}get right(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===2:(this.buttons&2)!==0}set right(t){t?this.buttons|=2:this.buttons&=-3}get middle(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===1:(this.buttons&4)!==0}set middle(t){t?this.buttons|=4:this.buttons&=-5}get commandKey(){const t=this.code,i=this.key;return"cxvyzagCXVYZAG".includes(i)?i.toLowerCase():t==="KeyC"?"c":t==="KeyX"?"x":t==="KeyV"?"v":t==="KeyY"?"y":t==="KeyZ"?"z":t==="KeyA"?"a":t==="KeyG"?"g":t!==""?t:i}}class DiagramEvent{b;Tt;pm;ym;constructor(){this.b=null,this.Tt="",this.pm=null,this.ym=null}copy(){const t=new DiagramEvent;return t.b=this.b,t.Tt=this.Tt,t.pm=this.pm,t.ym=this.ym,t}toString(){let t="*"+this.name;return this.subject!==null&&(t+=":"+this.subject.toString()),this.parameter!==null&&(t+="("+this.parameter.toString()+")"),t}get diagram(){return this.b}set diagram(t){this.b=t}get name(){return this.Tt}set name(t){this.Tt=t}get subject(){return this.pm}set subject(t){this.pm=t}get parameter(){return this.ym}set parameter(t){this.ym=t}}var ChangeType=(w=>(w[w.Transaction=1]="Transaction",w[w.Property=2]="Property",w[w.Insert=3]="Insert",w[w.Remove=4]="Remove",w))(ChangeType||{});class ChangedEvent{wu;wm;gn;Ai;b;xu;gf;mf;pf;yf;constructor(){this.wu=2,this.wm="",this.gn="",this.Ai=null,this.b=null,this.xu=null,this.gf=null,this.mf=null,this.pf=null,this.yf=null}static Transaction=1;static Property=2;static Insert=3;static Remove=4;clear(){this.Ai=null,this.b=null,this.xu=null,this.gf=null,this.mf=null,this.pf=null,this.yf=null}copy(){const t=new ChangedEvent;t.wu=this.wu,t.wm=this.wm,t.gn=this.gn,t.Ai=this.Ai,t.b=this.b,t.xu=this.xu;let i=this.gf;return Util.Mt(i)&&typeof i.copyFrozen=="function"?t.gf=i.copyFrozen():t.gf=i,i=this.mf,Util.Mt(i)&&typeof i.copyFrozen=="function"?t.mf=i.copyFrozen():t.mf=i,i=this.pf,Util.Mt(i)&&typeof i.copyFrozen=="function"?t.pf=i.copyFrozen():t.pf=i,i=this.yf,Util.Mt(i)&&typeof i.copyFrozen=="function"?t.yf=i.copyFrozen():t.yf=i,t}fi(t){t in ChangeType?this.change=t:Util.ur(this,t)}toString(){let t="";return this.change===1?t+="* ":this.change===2?t+=this.model!==null?"!m":"!d":t+=(this.model!==null?"!m":"!d")+this.change,this.propertyName&&typeof this.propertyName=="string"&&(t+=" "+this.propertyName),this.modelChange&&this.modelChange!==this.propertyName&&(t+=" "+this.modelChange),t+=": ",this.change===1?this.oldValue!==null&&(t+=" "+this.oldValue):(this.object!==null&&(t+=Util.toString(this.object)),this.oldValue!==null&&(t+=" old: "+Util.toString(this.oldValue)),this.oldParam!==null&&(t+=" "+this.oldParam),this.newValue!==null&&(t+=" new: "+Util.toString(this.newValue)),this.newParam!==null&&(t+=" "+this.newParam)),t}getValue(t){return t?this.oldValue:this.newValue}getParam(t){return t?this.oldParam:this.newParam}canUndo(){return this.model!==null||this.diagram!==null}undo(){this.canUndo()&&(this.model!==null?this.model.changeState(this,!0):this.diagram!==null&&this.diagram.TC(this,!0))}canRedo(){return this.model!==null||this.diagram!==null}redo(){this.canRedo()&&(this.model!==null?this.model.changeState(this,!1):this.diagram!==null&&this.diagram.TC(this,!1))}get model(){return this.Ai}set model(t){this.Ai=t}get diagram(){return this.b}set diagram(t){this.b=t}get change(){return this.wu}set change(t){this.wu=t}get modelChange(){return this.wm}set modelChange(t){Debug&&Util.t(t,"string",ChangedEvent,"modelChange"),this.wm=t}get propertyName(){return this.gn}set propertyName(t){Debug&&typeof t!="string"&&Util.t(t,"function",ChangedEvent,"propertyName"),this.gn=t}get isTransactionFinished(){return this.wu===1&&(this.gn==="CommittedTransaction"||this.gn==="FinishedUndo"||this.gn==="FinishedRedo")}get object(){return this.xu}set object(t){this.xu=t}get oldValue(){return this.gf}set oldValue(t){this.gf=t}get oldParam(){return this.mf}set oldParam(t){this.mf=t}get newValue(){return this.pf}set newValue(t){this.pf=t}get newParam(){return this.yf}set newParam(t){this.yf=t}}class Transaction{DC;Tt;$k;constructor(){this.DC=new List().w(),this.Tt="",this.$k=!1}toString(t){let i="Transaction: "+this.name+" "+this.changes.count.toString()+(this.isComplete?"":", incomplete");if(t!==void 0&&t>0){const e=this.changes.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),t.w()}canUndo(){return this.isComplete}undo(){if(this.canUndo())for(let t=this.changes.count-1;t>=0;t--){const i=this.changes.elt(t);i!==null&&i.undo()}}canRedo(){return this.isComplete}redo(){if(!this.canRedo())return;const t=this.changes.count;for(let i=0;i=t;e--){const s=i.elt(e);s!==null&&s.undo(),i.ft(),i.removeAt(e)}i.w()}optimize(){if(!this.isComplete)return;const t=this.changes;t.ft();const i=new GMap;for(let s=0;s0&&t.setElt(r,null),o.set(n.propertyName,s))}let e=0;for(let s=0;se&&t.setElt(e,n),e++)}for(;t.length>e;)t.pop();t.w()}get changes(){return this.DC}get name(){return this.Tt}set name(t){this.Tt=t}get isComplete(){return this.$k}set isComplete(t){this.$k=t}}class UndoManager{Bw;Xi;FC;zs;Qk;xm;Jn;Vw;_k;mn;wf;zw;Xs;Xw;Yw;bm;Kw;constructor(t){this.Bw=new GSet,this.Xi=!1,this.FC=new List().w(),this.zs=-1,this.Qk=999,this.Xs=!1,this.xm=null,this.Jn=0,this.Vw=!1,Debug&&(this.Vw=!0),this._k=23,this.mn=new List().w(),this.wf=new List,this.zw=!0,this.Xw=!1,this.Yw=!1,this.bm=!1,this.Kw=!1,t&&Object.assign(this,t)}toString(t){let i="UndoManager "+this.historyIndex+"<"+this.history.count+"<="+this.maxHistoryLength;i+="[";let e=this.nestedTransactionNames.count;for(let s=0;s0&&(i+=" "),i+=this.nestedTransactionNames.elt(s);if(i+="]",t!==void 0&&t>0){e=this.history.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),this.zs=-1,t.w(),this.Xs=!1,this.xm=null,this.Jn=0,this.mn.ft(),this.mn.clear(),this.mn.w(),this.wf.clear(),this.Xw=!1,this.Yw=!1,this.bm=!1,this.Kw=!1}copyProperties(t){this.isEnabled=t.isEnabled,this.maxHistoryLength=t.maxHistoryLength,this.bu=t.bu}addModel(t){this.Bw.add(t)}removeModel(t){this.Bw.delete(t)}startTransaction(t){if(t===void 0&&(t=""),t===null&&(t=""),this.isUndoingRedoing)return!1;this.zw===!0&&(this.zw=!1,this.Jn++,this.Ml||this.i("StartingFirstTransaction",t,this.currentTransaction),this.Jn>0&&this.Jn--),this.isEnabled&&(this.mn.ft(),this.mn.add(t),this.mn.w(),this.currentTransaction===null?this.wf.add(0):this.wf.add(this.currentTransaction.changes.count)),this.Jn++;const i=this.transactionLevel===1;return i&&(this.Ml||this.i("StartedTransaction",t,this.currentTransaction)),i}commitTransaction(t){return t===void 0&&(t=""),this.RC(!0,t)}rollbackTransaction(){return this.RC(!1,"")}RC(t,i){if(this.isUndoingRedoing)return!1;this.bu&&this.transactionLevel<1&&Util.ht("Ending transaction without having started a transaction: "+i);const e=this.transactionLevel===1;let s=this.currentTransaction;e&&t&&(this.Ml||this.i("CommittingTransaction",i,s));let n=0;if(this.transactionLevel>0&&(this.Jn--,this.isEnabled)){const o=this.mn.count;o>0&&(i===""&&(i=this.mn.elt(0)),this.mn.ft(),this.mn.removeAt(o-1),this.mn.w());const r=this.wf.count;r>0&&(n=this.wf.elt(r-1),this.wf.removeAt(r-1))}if(e){if(t){if(this.bm=!1,s===null&&i!==""&&(s=this.currentTransaction),this.isEnabled&&s!==null){const o=s;o.isComplete||(o.isComplete=!0,o.name=i),this.discardHistoryAfterIndex();const r=this.history;r.ft();const l=this.maxHistoryLength;if(l>=0){if(l===0)r.clear();else if(r.count>=l){const h=r.elt(0);h!==null&&h.clear(),r.removeAt(0),this.zs--}}l!==0&&(r.count===0||r.get(r.count-1)!==o)&&(r.add(o),this.zs++),r.w(),s=o}this.Ml||this.i("CommittedTransaction",i,s)}else{this.Xs=!0;try{this.isEnabled&&s!==null&&(s.isComplete=!0,s.undo())}finally{this.Ml||this.i("RolledBackTransaction",i,s),this.Xs=!1}s!==null&&s.clear()}return this.xm=null,this.Uw&&this.clear(),this.Uw=!1,this.Gw=!1,!0}else return this.isEnabled&&!t&&s!==null&&s.QD(n),!1}discardHistoryAfterIndex(){if(this.isUndoingRedoing||!this.canRedo())return;const t=this.history;t.ft();for(let i=t.count-1;i>this.historyIndex;i--){const e=t.elt(i);e!==null&&e.clear(),t.removeAt(i),this.bm=!0}t.w()}rE(t){this.Jn+=t,this.Jn<0&&(this.Jn=0)}canUndo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToUndo;return!!(t!==null&&t.canUndo())}undo(){if(!this.canUndo())return;const t=this.transactionToUndo;try{this.Xs=!0,this.i("StartingUndo","Undo",t),this.zs--,t.undo()}catch(i){Util.ht("undo error: "+i.toString())}finally{this.i("FinishedUndo","Undo",t),this.Xs=!1}}canRedo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToRedo;return!!(t!==null&&t.canRedo())}redo(){if(!this.canRedo())return;const t=this.transactionToRedo;try{this.Xs=!0,this.i("StartingRedo","Redo",t),this.zs++,t.redo()}catch(i){Util.ht("redo error: "+i.toString())}finally{this.i("FinishedRedo","Redo",t),this.Xs=!1}}i(t,i,e){e===void 0&&(e=null);const s=new ChangedEvent;s.change=1,s.propertyName=t,s.object=e,s.oldValue=i;const n=this.models;for(;n.next();){const o=n.value;s.model=o,o.Hw(s)}}handleChanged(t){if(this.isEnabled&&!this.isUndoingRedoing&&!this.skipsEvent(t)){let i=this.currentTransaction;i===null&&(i=new Transaction,this.xm=i);const e=t.copy(),s=i.changes;if(s.ft(),s.add(e),s.w(),this.bu&&this._k>0&&this.transactionLevel<=0&&!this.zw){const n=t.diagram;if(n!==null&&n.Kh===!1)return;Util.ht("Change not within a transaction: "+e.toString()),this._k--}}}skipsEvent(t){if(t===null||t.change===1)return!0;const i=t.object;if(i===null)return!1;if(i.layer!==void 0){const e=i.layer;if(e!==null&&e.isTemporary)return!0}else if(i.isTemporary)return!0;return!1}get models(){return this.Bw.iterator}get isEnabled(){return this.Xi}set isEnabled(t){this.Xi=t}get transactionToUndo(){return this.historyIndex>=0&&this.historyIndex<=this.history.count-1?this.history.elt(this.historyIndex):null}get transactionToRedo(){return this.historyIndex0}get bu(){return this.Vw}set bu(t){this.Vw=t}get nestedTransactionNames(){return this.mn}get Uw(){return this.Xw}set Uw(t){this.Xw=t}get Gw(){return this.Yw}set Gw(t){this.Yw=t}get Ml(){return this.Kw}set Ml(t){this.Kw=t}get isJustDiscarded(){return this.bm}}class Tool{b;Tt;Xi;tS;iS;km;IC;constructor(){GSet.vi(this),this.b=Diagram.Sm(),this.Tt="",this.Xi=!0,this.tS=!1,this.iS=null,this.IC=new InputEvent,this.km=-1}get diagram(){return this.b}set diagram(t){t instanceof Diagram&&(this.b=t)}toString(){return this.name!==""?this.name+" Tool":Util.hn(this.constructor)}updateAdornments(t){}canStart(){return this.isEnabled}doStart(){}doActivate(){this.isActive=!0}doDeactivate(){this.isActive=!1}doStop(){}doCancel(){this.transactionResult=null,this.stopTool()}stopTool(){const t=this.diagram;t.currentTool===this&&(t.currentTool=null,t.currentCursor="")}doMouseDown(){!this.isActive&&this.canStart()&&this.doActivate()}doMouseMove(){}doMouseUp(){this.stopTool()}doMouseWheel(){}canStartMultiTouch(){return!0}standardPinchZoomStart(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.H(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.H(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.o(e),Point.o(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){t.eS=t.scale;const n=s.x-e.x,o=s.y-e.y,r=Math.sqrt(n*n+o*o);t.sS=r,i.bubbles=!1}Point.o(e),Point.o(s)}standardPinchZoomMove(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.H(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.H(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.o(e),Point.o(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){const n=s.x-e.x,o=s.y-e.y,l=Math.sqrt(n*n+o*o)/t.sS,h=new Point((Math.min(s.x,e.x)+Math.max(s.x,e.x))/2,(Math.min(s.y,e.y)+Math.max(s.y,e.y))/2),a=t.eS*l,f=t.commandHandler;if(a!==t.scale&&f.canResetZoom(a)){const c=t.zoomPoint;t.zoomPoint=h,f.resetZoom(a),t.zoomPoint=c}i.bubbles=!1}Point.o(e),Point.o(s)}doKeyDown(){this.diagram.lastInput.code==="Escape"&&this.doCancel()}doKeyUp(){}startTransaction(t){return t===void 0&&(t=this.name),this.transactionResult=null,this.diagram.startTransaction(t)}stopTransaction(){const t=this.diagram;return this.transactionResult===null?t.rollbackTransaction():t.commitTransaction(this.transactionResult)}standardMouseSelect(){const t=this.diagram;if(!t.allowSelect)return;const i=t.lastInput,e=t.findPartAt(i.documentPoint,!1);if(e!==null){if(Util.cr?i.meta:i.control){t.B("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!s.isSelected),t.B("ChangedSelection",t.selection)}else if(i.shift){if(!e.isSelected){t.B("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!0),t.B("ChangedSelection",t.selection)}}else if(!e.isSelected){let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&t.select(s)}}else i.left&&!(Util.cr?i.meta:i.control)&&!i.shift&&t.clearSelection()}standardMouseClick(t,i){t===void 0&&(t=null),i===void 0&&(i=o=>!o.layer.isTemporary);const e=this.diagram,s=e.lastInput,n=e.findObjectAt(s.documentPoint,t,i);return s.targetObject=n,this._D(n,s,e),s.handled}_D(t,i,e){if(i.handled=!1,t!==null&&!t.isEnabledObject())return;let s=0;i.left?i.clickCount===1?s=1:i.clickCount===2?s=2:s=1:i.right&&i.clickCount===1&&(s=3);let n="ObjectSingleClicked";if(t!==null){switch(s){case 1:n="ObjectSingleClicked";break;case 2:n="ObjectDoubleClicked";break;case 3:n="ObjectContextClicked";break}s!==0&&e.B(n,t)}else{switch(s){case 1:n="BackgroundSingleClicked";break;case 2:n="BackgroundDoubleClicked";break;case 3:n="BackgroundContextClicked";break}s!==0&&e.B(n)}if(t!==null)for(;t!==null;){let o=null;switch(s){case 1:o=t.click;break;case 2:o=t.doubleClick?t.doubleClick:t.click;break;case 3:o=t.contextClick;break}if(o!==null&&(o(i,t),i.handled))break;t=t.panel}else{let o=null;switch(s){case 1:o=e.click;break;case 2:o=e.doubleClick?e.doubleClick:e.click;break;case 3:o=e.contextClick;break}o!==null&&o(i)}}standardMouseOver(){const t=this.diagram,i=t.lastInput;if(t.animationManager.Si===!0)return;const e=t.skipsUndoManager;t.skipsUndoManager=!0;let s=t.viewportBounds.containsPoint(i.documentPoint)?t.findObjectAt(i.documentPoint,null,null):null;i.event&&(i.event.type==="pointercancel"||i.event.type==="pointerout")&&(s=null),i.targetObject=s;let n=!1;if(s!==t.xf){let o=t.xf;const r=o;for(t.xf=s,this.doCurrentObjectChanged(o,s),i.handled=!1;o!==null;){const l=o.mouseLeave;if(l!==null&&(s===o||s!==null&&s.isContainedBy(o)||(l(i,o,s),n=!0,i.handled)))break;o=o.panel}for(o=r,i.handled=!1;s!==null;){const l=s.mouseEnter;if(l!==null&&(o===s||o!==null&&o.isContainedBy(s)||(l(i,s,o),n=!0,i.handled)))break;s=s.panel}s=t.xf}if(s!==null){let o=s,r="";for(;o!==null&&(r=o.cursor,r==="");)o=o.panel;for(t.currentCursor=r,i.handled=!1,o=s;o!==null;){const l=o.mouseOver;if(l!==null&&(l(i,o),n=!0,i.handled))break;o=o.panel}}else{this.doUpdateCursor(null);const o=t.mouseOver;o!==null&&(o(i),n=!0)}n&&t.requestUpdate(),t.skipsUndoManager=e}doUpdateCursor(t){const i=this.diagram;i&&(i.currentCursor="")}doCurrentObjectChanged(t,i){}standardMouseWheel(){const t=this.diagram,i=t.lastInput;let e=i.delta;if(e===0||!t.documentBounds.isReal())return;const s=t.commandHandler,n=t.toolManager.mouseWheelBehavior;if(s!==null&&(n===2&&!i.shift||n===1&&i.control)){if(e>0?s.canIncreaseZoom():s.canDecreaseZoom()){const o=t.zoomPoint;t.zoomPoint=i.viewPoint,e>0?s.increaseZoom():s.decreaseZoom(),t.zoomPoint=o}i.bubbles=!1}else if(n===2&&i.shift||n===1&&!i.control){const o=t.position.copy(),r=i.event,l=r.deltaMode;let h=r.deltaX,a=r.deltaY,f="pixel";if((h!==0||a!==0)&&!i.shift){switch(l){case 0:f="pixel";break;case 1:f="line";break;case 2:f="page";break}if(h!==0&&t.allowHorizontalScroll){const c=t.scrollHorizontalLineChange;h=h*(c/16),t.scroll(f,h>0?"right":"left",Math.abs(h))}if(a!==0&&t.allowVerticalScroll){const c=t.scrollVerticalLineChange;a=a*(c/16),t.scroll(f,a>0?"down":"up",Math.abs(a))}}else!i.shift&&t.allowVerticalScroll?(e=e*3*t.scrollVerticalLineChange,t.scroll(f,e>0?"up":"down",Math.abs(e))):i.shift&&t.allowHorizontalScroll&&(e=e*3*t.scrollHorizontalLineChange,t.scroll(f,e>0?"left":"right",Math.abs(e)));this.doWheelChange(t,o,i)}}doWheelChange(t,i,e){(!t.position.equals(i)||e.event.wheelDeltaX!==0)&&(e.bubbles=!1)}standardWaitAfter(t,i){Debug&&Util.t(t,"number",Tool,"standardWaitAfter:delay"),i===void 0&&(i=this.diagram.lastInput),this.cancelWaitAfter();const e=this,s=i.clone(this.IC);this.km=Util.zh(()=>e.doWaitAfter(s),t)}cancelWaitAfter(){this.km!==-1&&Util.Kg(this.km),this.km=-1}doWaitAfter(t){}findToolHandleAt(t,i){const s=this.diagram.findObjectAt(t,n=>{for(;n!==null&&!(n.panel instanceof Adornment);)n=n.panel;return n});return s===null?null:s.part.category===i?s:null}isBeyondDragSize(t,i){const e=this.diagram;t===void 0&&(t=e.firstInput.viewPoint),i===void 0&&(i=e.lastInput.viewPoint);const s=e.toolManager.dragSize;let n=s.width,o=s.height;return e.firstInput.isTouchEvent&&(n+=6,o+=6),Math.abs(i.x-t.x)>n||Math.abs(i.y-t.y)>o}get name(){return this.Tt}set name(t){Util.t(t,"string",Tool,"name"),this.Tt=t}get isEnabled(){return this.Xi}set isEnabled(t){Util.t(t,"boolean",Tool,"isEnabled"),this.Xi=t}get isActive(){return this.tS}set isActive(t){Util.t(t,"boolean",Tool,"isActive"),this.tS=t}get transactionResult(){return this.iS}set transactionResult(t){t!==null&&Util.t(t,"string",Tool,"transactionResult"),this.iS=t}}var WheelMode=(w=>(w[w.Scroll=1]="Scroll",w[w.Zoom=2]="Zoom",w[w.None=3]="None",w))(WheelMode||{}),GestureMode=(w=>(w[w.Zoom=1]="Zoom",w[w.Cancel=2]="Cancel",w[w.None=3]="None",w))(GestureMode||{});class ToolManager extends Tool{OC;EC;BC;nS;oS;rS;lS;hS;aS;fS;Mm;Uh;constructor(t){super(),this.name="ToolManager",this.OC=new List,this.EC=new List,this.BC=new List,this.nS=850,this.oS=850,this.rS=new Size(2,2).ot(),this.lS=5e3,this.hS=1,this.aS=1,this.fS=null,this.Mm=null,this.Uh=-1,t&&Object.assign(this,t)}static WheelScroll=1;static WheelZoom=2;static WheelNone=3;static GestureZoom=1;static GestureCancel=2;static GestureNone=3;get mouseWheelBehavior(){return this.hS}set mouseWheelBehavior(t){Util.tt(t,WheelMode,"WheelMode"),this.hS=t}get gestureBehavior(){return this.aS}set gestureBehavior(t){Util.tt(t,GestureMode,"GestureMode"),this.aS=t}initializeStandardTools(){}updateAdornments(t){const i=this.currentToolTip;if(i instanceof Adornment&&this.Mm===t){const e=i.adornedObject;(t!==null?e.part===t:e===null)?this.showToolTip(i,e):this.hideToolTip()}}doMouseDown(){const t=this.diagram,i=t.lastInput;if(i.isTouchEvent&&this.gestureBehavior===2&&(i.bubbles=!1),i.isMultiTouch){if(this.cancelWaitAfter(),this.gestureBehavior===3){i.bubbles=!0;return}if(this.gestureBehavior===2)return;if(t.currentTool.canStartMultiTouch()){t.currentTool.standardPinchZoomStart();return}}const e=t.undoManager;Debug&&e.bu&&e.transactionLevel!==0&&Util.ht("WARNING: In ToolManager.doMouseDown: UndoManager.transactionLevel is not zero");const s=this.mouseDownTools.length;for(let n=0;n0&&s!==1/0){const n=this;this.Uh=Util.zh(()=>n.hideToolTip(),s)}}positionToolTip(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom?n.y-=o.height+5/s.scale:n.y+=20/s.scale,n.y30&&t.jw(),t.Ww(this.draggedParts),t.Mu=!0,this.startTransaction("Drag"),this.startPoint=t.firstInput.documentPoint,t.isMouseCaptured=!0,t.allowDragOut&&this.iF()}MS(t){if(this.dragsLink){const i=this.diagram;if(!i.allowRelink)return;i.model.Sf()&&t.count===1&&t.first()instanceof Link?(this.draggedLink=t.first(),this.draggedLink.canRelinkFrom()&&this.draggedLink.canRelinkTo()&&this.draggedLink.clearAdornments(),this.pn=i.toolManager.findTool("Relinking"),this.pn===null&&(this.pn=new RelinkingTool,this.pn.diagram=i),this.pn.originalLink=this.draggedLink):(this.draggedLink=null,this.pn=null)}}computeEffectiveCollection(t,i){return this.diagram.commandHandler.computeEffectiveCollection(t,i)}Ys(t){return t===void 0?new DraggingInfo(Point.Lo):this.isGridSnapEnabled?new DraggingInfo(new Point(Math.round(t.x*1e3)/1e3,Math.round(t.y*1e3)/1e3)):new DraggingInfo(t.copy())}doDeactivate(){this.isActive=!1;const t=this.diagram;this.diagram.layout.isRealtime=this.SS,t.Mu=!1,t.Pl=!0,t.cacheGroupExternalLinks(!1),t.stopAutoScroll(),this.PS(),t.Nm(this.draggedParts),this.Su=null,this.currentPart=null,this.draggedParts=null,this.isDragOutStarted=!1,this.ku=!1,DraggingTool.eF(),this.zC(),this.bf.e(NaN,NaN),DraggingTool.Hh!==null&&(DraggingTool.Hh.currentCursor=""),DraggingTool.Hh=null,DraggingTool.St=null,this.Nl(),t.isMouseCaptured=!1,t.currentCursor="",t.kf=!1,this.stopTransaction(),t.NS(!0)}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}PS(){const t=this.diagram,i=t.skipsUndoManager;t.skipsUndoManager=!0;const e=t.lastInput;this.XC(e,null),t.skipsUndoManager=i,this.br.length=0}YC(){this.Nl(),this.CS();const t=this.diagram;this.bf.isReal()&&(t.position=this.bf),t.stopAutoScroll()}doCancel(){this.Nl(),this.CS();const t=this.diagram;this.bf.isReal()&&(t.position=this.bf),this.stopTool()}doKeyDown(){const t=this.diagram,i=t.lastInput;this.isActive&&(i.code==="Escape"?this.doCancel():i.code!==t.previousInput.code&&this.doMouseMove())}doKeyUp(){this.isActive&&this.doMouseMove()}sF(t,i){let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=t.iterator;for(;r.next();){const l=r.value;if(!l.isVisible())continue;const h=l.location,a=h.x,f=h.y;isNaN(a)||isNaN(f)||(an&&(n=a),f>o&&(o=f))}return e===1/0?i.e(0,0,0,0):i.e(e,s,n-e,o-s),i}AS(t){if(this.copiedParts!==null)return;const i=this.diagram;if(t&&(i.isReadOnly||i.isModelReadOnly)||this.draggedParts===null)return;const e=i.undoManager;e.isEnabled&&e.isInTransaction?e.currentTransaction!==null&&e.currentTransaction.changes.count>0&&(i.undoManager.rollbackTransaction(),i.startTransaction("Drag")):this.CS(),i.skipsUndoManager=!t,i.partManager.addsToTemporaryLayer=!t,this.startPoint=i.firstInput.documentPoint;const s=this.copiesEffectiveCollection?this.draggedParts.toKeySet():i.selection,n=i.copyParts(s,i,!0),o=new GMap,r=this.draggedParts.iterator;for(;r.next();){const h=r.key;if(h.Ae()&&h.canCopy()){const a=n.get(h);if(a===null)continue;a.location=h.location,a.ensureBounds(),o.set(a,this.Ys(a.location))}}const l=n.iterator;for(;l.next();){const h=l.value;h instanceof Link&&h.canCopy()&&o.set(h,this.Ys())}if(this.copiedParts=o,this.MS(o.toKeySet()),this.draggedLink!==null){const h=this.draggedLink,a=h.routeBounds;h.kr(this.startPoint.x-(a.x+a.width/2),this.startPoint.y-(a.y+a.height/2))}this.doUpdateCursor(null)}Nl(){const t=this.diagram;if(this.copiedParts!==null){if(t.removeParts(this.copiedParts.toKeySet(),!1),this.copiedParts=null,this.draggedParts!==null){const i=this.draggedParts.iterator;for(;i.next();)if(i.key instanceof Link){const s=i.value;s.point=new Point(0,0)}}this.doUpdateCursor(null)}t.skipsUndoManager=!1,t.partManager.addsToTemporaryLayer=!1,this.startPoint=t.firstInput.documentPoint}zC(){this.draggedLink!==null&&(this.dragsLink&&this.pn!==null&&(this.pn.stopDraggingMouseMove(),this.pn.originalLink=null),this.draggedLink=null,this.pn=null)}Mf(t,i){const e=this.diagram,s=this.startPoint,n=Point.a();n.c(e.lastInput.documentPoint),this.moveParts(t,n.subtract(s),i),Point.o(n),e.getRenderingHint("temporaryPixelRatio")===!0&&e.Cl===null&&e.avgSpf>30&&(e.jw(),e.Pu())}moveParts(t,i,e){e===void 0&&(e=!1);const s=this.diagram;s!==null&&s.LS(t,i,this.dragOptions,e)}CS(){if(this.draggedParts===null)return;const t=this.diagram;let i=this.draggedParts.iterator;for(;i.next();){const e=i.key;e.Ae()&&(e.location=i.value.point)}for(i=this.draggedParts.iterator;i.next();){const e=i.key;if(e instanceof Link&&e.suspendsRouting){const s=i.value.point;this.draggedParts.set(e,this.Ys()),e.kr(-s.x,-s.y)}}t.maybeUpdate()}nF(t){if(t===null)return!0;const i=t.part;return!!(i===null||i instanceof Adornment||i.layer.isTemporary||this.draggedParts&&this.draggedParts.has(i)||this.copiedParts&&this.copiedParts.has(i))}TS(t){const i=this.diagram;this.dragsLink&&(this.draggedLink!==null&&(this.draggedLink.fromNode=null,this.draggedLink.toNode=null),this.KC(!1));const e=this.findDragOverObject(t),s=i.lastInput;s.targetObject=e,this.doUpdateCursor(e);const n=i.skipsUndoManager;let o=!1;try{if(i.skipsUndoManager=!0,o=this.XC(s,e),!this.isActive&&DraggingTool.St===null)return;const r=e!==null?e.part:null;if(r===null||i.handlesDragDropForTopLevelParts&&r.isTopLevel&&!(r instanceof Group)){const l=i.mouseDragOver;l!==null&&(l(s),o=!0)}if(!this.isActive&&DraggingTool.St===null||(this.doDragOver(t,e),!this.isActive&&DraggingTool.St===null))return}finally{i.skipsUndoManager=n,o&&i.maybeUpdate()}this.Su=e,!i.isReadOnly&&(i.allowMove||i.allowCopy)&&(i.allowHorizontalScroll||i.allowVerticalScroll)&&i.doAutoScroll(s.viewPoint)}findDragOverObject(t){return this.diagram.DS(t,null,i=>!this.nF(i))}doUpdateCursor(t){const i=this.diagram;(t===null||this.Su!==t)&&(!this.diagram.currentTool.isActive||this.mayCopy()?i.currentCursor=this.copyCursor:this.mayMove()?i.currentCursor=this.moveCursor:this.mayDragOut()&&(i.currentCursor=this.nodropCursor))}XC(t,i){let e=!1,s=this.br.length;const n=s>0?this.br[0]:null;if(i===n)return!1;t.handled=!1;for(let r=0;rs.findValidLinkablePort(a,i)),r=Point.a();let l=1/0,h=null;for(const a=o.iterator;a.next();){const f=a.value;if(f.part===null)continue;const u=f.getDocumentPoint(Spot.Center,r),d=t.distanceSquaredPoint(u);dh.suspendsRouting=!1)}if(this.doDropOnto(t,e),!this.isActive&&DraggingTool.St===null)return;const o=Rect.a(),r=i.selection.iterator;for(;r.next();){const l=r.value;l instanceof Node&&this.rF(i,l,o)}Rect.o(o)}oF(t,i){const e=this.diagram,s=i.part;if(e.handlesDragDropForTopLevelParts&&s.isTopLevel&&!(s instanceof Group)){const n=e.mouseDrop;n!==null&&n(t)}}rF(t,i,e){if(!i.canAvoid())return;let s=!1;e=i.getAvoidableRect(e),t.viewportBounds.containsRect(e)&&(s=!0);const n=this.copiedParts||this.draggedParts,o=t.IS(e,l=>l.part,l=>l instanceof Link,!0,l=>l instanceof Link,s);if(o.count===0)return;const r=o.iterator;for(;r.next();){const l=r.value;n.has(l)&&n.has(i)||!l.isMemberOf(i)&&l.isAvoiding&&l.invalidateRoute()}}doDropOnto(t,i){}doMouseMove(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseMove(i.event,i.documentPoint,i.targetDiagram))return;this.currentPart!==null&&this.draggedParts!==null&&(this.mayCopy()?(this.AS(!1),t.Ww(this.copiedParts),this.Mf(this.copiedParts,!1),t.Nm(this.copiedParts)):this.mayMove()?(this.Nl(),this.Mf(this.draggedParts,!0)):this.mayDragOut()?(this.AS(!1),this.Mf(this.copiedParts,!1)):this.Nl(),this.TS(t.lastInput.documentPoint))}doMouseUp(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseUp(i.event,i.documentPoint,i.targetDiagram))return;let e=!1;const s=this.mayCopy();if(s&&this.copiedParts!==null?(this.Nl(),this.AS(!0),t.Ww(this.copiedParts),this.Mf(this.copiedParts,!1),t.Nm(this.copiedParts),this.copiedParts!==null&&(t.B("ChangingSelection",t.selection),t.clearSelection(!0),this.copiedParts.iteratorKeys.each(n=>{n.isSelected=!0}))):(e=!0,this.Nl(),this.mayMove()&&(this.Mf(this.draggedParts,!0),this.TS(t.lastInput.documentPoint))),this.ku=!0,this.HC(t.lastInput.documentPoint),this.isActive){const n=s?this.copiedParts.toKeySet():this.draggedParts.toKeySet();this.copiedParts=null,e&&this.lF(),t.invalidateDocumentBounds(),t.Nm(this.draggedParts),this.transactionResult=s?"Copy":"Move",t.B(s?"SelectionCopied":"SelectionMoved",n)}this.stopTool(),s&&t.B("ChangedSelection",t.selection)}simulatedMouseMove(t,i,e){if(DraggingTool.St===null)return!1;const s=DraggingTool.St.diagram;e instanceof Diagram||(e=null);const n=DraggingTool.Hh;if(e!==n){if(n!==null&&n!==s){n.stopAutoScroll(),DraggingTool.St.isDragOutStarted=!1;const r=n.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDragLeave()}if(DraggingTool.Hh=e,e!==null&&e!==s){DraggingTool.St.YC();const r=e.toolManager.findTool("Dragging");r!==null&&(r.qC(),r.doSimulatedDragEnter())}this.doUpdateCursor(null)}if(e===null||e===s||!e.allowDrop||e.isReadOnly||!e.allowInsert)return!1;const o=e.toolManager.findTool("Dragging");if(o!==null){let r=i;t!==null&&(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),r=e.getMouse(t)),e.lastInput.documentPoint=r,e.lastInput.viewPoint=e.transformDocToView(r),e.lastInput.down=!1,e.lastInput.up=!1,o.doSimulatedDragOver()}return!0}simulatedMouseUp(t,i,e){if(DraggingTool.St===null)return!1;const s=DraggingTool.Hh,n=DraggingTool.St.diagram;if(e===null)return DraggingTool.St.doCancel(),!0;if(e!==s){const o=s.toolManager.findTool("Dragging");if(s!==null&&s!==n&&o!==null)return s.stopAutoScroll(),DraggingTool.St.isDragOutStarted=!1,o.doSimulatedDragLeave(),!1;DraggingTool.Hh=e;const r=e.toolManager.findTool("Dragging");r!==null&&(DraggingTool.St.YC(),r.qC(),r.doSimulatedDragEnter())}if(e!==this.diagram){let o=i;t!==null?(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),o=e.getMouse(t)):o===null&&(o=new Point),e.lastInput.documentPoint=o,e.lastInput.viewPoint=e.transformDocToView(o),e.lastInput.down=!1,e.lastInput.up=!0;const r=e.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDrop();const l=DraggingTool.St;if(l!==null){const h=l.mayCopy();l.transactionResult=h?"Copy":"Move",l.stopTool()}return!0}return!1}lF(){if(this.draggedParts===null)return;const t=this.draggedParts.iterator;for(;t.next();){const i=t.key;if(i instanceof Node){const e=i.containingGroup;e!==null&&e.hasPlaceholder()&&!this.draggedParts.has(e)&&e.placeholder.u()}}}mayCopy(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowCopy||!(Util.cr?t.lastInput.alt:t.lastInput.control))return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayDragOut(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(!t.allowDragOut||!t.allowCopy||t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayMove(){const t=this.diagram;if(t.isReadOnly||!t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canMove())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canMove())}qC(){DraggingTool.vw.has(this)||DraggingTool.vw.add(this)}static eF(){if(DraggingTool.vw.count>0){const t=DraggingTool.vw,i=t.length;for(let e=0;e{n.isSelected=!0,s.add(n)})),this.HC(t.lastInput.documentPoint),t.invalidateDocumentBounds(),this.copiedParts!==null&&(this.transactionResult="ExternalCopy"),this.copiedParts=null,t.doFocus(),t.kf=!1,t.B("ExternalObjectsDropped",s,e),this.stopTransaction(),t.B("ChangedSelection",t.selection)}t.animationManager.Nu=!1}jC(t,i,e){if(this.copiedParts!==null)return;const s=this.diagram;if(s.isReadOnly||s.isModelReadOnly)return;s.skipsUndoManager=!i,s.partManager.addsToTemporaryLayer=!i,this.startPoint=e.documentPoint;const n=s.copyParts(t,s,!0),o=Rect.a();this.sF(t,o);const r=o.x+o.width/2,l=o.y+o.height/2;Rect.o(o);const h=this.Pm,a=new GMap,f=Point.a(),c=t.iterator;for(;c.next();){const d=c.value;if(d instanceof Link&&d.canCopy()){const m=n.get(d);if(m===null)continue;m.points=d.points,m.kr(h.x-r,h.y-l),m.suspendsRouting=!0,a.set(m,this.Ys())}}const u=t.iterator;for(;u.next();){const d=u.value;if(d.Ae()&&d.canCopy()){const m=n.get(d);if(m===null)continue;const g=d.location;f.e(h.x-(r-g.x),h.y-(l-g.y)),m.location=f,m.ensureBounds(),a.set(m,this.Ys(f))}}if(Point.o(f),this.copiedParts=a,this.MS(a.toKeySet()),this.draggedLink!==null){const d=this.draggedLink,m=d.routeBounds;d.kr(this.startPoint.x-(m.x+m.width/2),this.startPoint.y-(m.y+m.height/2))}this.doUpdateCursor(null)}iF(){this.isDragOutStarted=!0,this.ku=!1,DraggingTool.St=this,DraggingTool.Hh=this.diagram,this.doSimulatedDragOut()}doSimulatedDragOut(){const t=this.diagram;t.kf=!1,!this.mayCopy()&&!this.mayMove()?t.currentCursor=this.nodropCursor:t.currentCursor="",this.Su=null}computeMove(t,i,e,s){const n=this.diagram;return n!==null?n.computeMove(t,i,this.dragOptions,s):new Point}static vw=new List;static St=null;static Hh=null}ToolManager.prototype.doCancel=function(){DraggingTool.St!==null&&DraggingTool.St.doCancel(),Tool.prototype.doCancel.call(this)};class LinkingBaseTool extends Tool{OS;ES;Al;BS;VS;qh;zS;jh;XS;YS;KS;US;GS;HS;WC;qS;Ll;jS;constructor(){super(),this.OS=100,this.ES=!1,this.Al="pointer",this.BS=new Link({layerName:"Tool"}).add(new Shape({isPanelMain:!0,stroke:"blue"}).theme("stroke","tempLink"),new Shape({toArrow:"Standard",fill:"blue",stroke:"blue"}).theme("fill","tempLink").theme("stroke","tempLink")).ci(),this.qh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.zk}).theme("stroke","tempPort"),this.VS=new Node({selectable:!1,layerName:"Tool"}).add(this.qh).ci(),this.jh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.zk}).theme("stroke","tempPort"),this.zS=new Node({selectable:!1,layerName:"Tool"}).add(this.jh).ci(),this.XS=null,this.YS=null,this.KS=null,this.US=null,this.GS=null,this.HS=!0,this.WC=new GMap,this.qS=null,this.Ll=null,this.jS=null}doStop(){this.diagram.stopAutoScroll(),this.originalLink=null,this.originalFromNode=null,this.originalFromPort=null,this.originalToNode=null,this.originalToPort=null,this.validPortsCache.clear(),this.targetPort=null}get portGravity(){return this.OS}set portGravity(t){Util.t(t,"number",LinkingBaseTool,"portGravity"),t>=0&&(this.OS=t)}get isUnconnectedLinkValid(){return this.ES}set isUnconnectedLinkValid(t){Util.t(t,"boolean",LinkingBaseTool,"isUnconnectedLinkValid"),this.ES=t}get linkingCursor(){return this.Al}set linkingCursor(t){this.Al=t}get temporaryLink(){return this.BS}set temporaryLink(t){Util.s(t,Link,LinkingBaseTool,"temporaryLink"),t.ci(),this.BS=t}get temporaryFromNode(){return this.VS}set temporaryFromNode(t){Util.s(t,Node,LinkingBaseTool,"temporaryFromNode"),t.ci(),this.VS=t,t&&(this.qh=t.port)}get temporaryFromPort(){return this.qh}set temporaryFromPort(t){if(Util.s(t,GraphObject,LinkingBaseTool,"temporaryFromPort"),this.qh!==null){const i=this.qh.panel;if(i!==null){const e=i.D.indexOf(this.qh);i.removeAt(e),i.insertAt(e,t)}}this.qh=t}get temporaryToNode(){return this.zS}set temporaryToNode(t){Util.s(t,Node,LinkingBaseTool,"temporaryToNode"),t.ci(),this.zS=t,t&&(this.jh=t.port)}get temporaryToPort(){return this.jh}set temporaryToPort(t){if(Util.s(t,GraphObject,LinkingBaseTool,"temporaryToPort"),this.jh!==null){const i=this.jh.panel;if(i!==null){const e=i.D.indexOf(this.jh);i.removeAt(e),i.insertAt(e,t)}}this.jh=t}get originalLink(){return this.XS}set originalLink(t){t!==null&&Util.s(t,Link,LinkingBaseTool,"originalLink"),this.XS=t}get originalFromNode(){return this.YS}set originalFromNode(t){t!==null&&Util.s(t,Node,LinkingBaseTool,"originalFromNode"),this.YS=t}get originalFromPort(){return this.KS}set originalFromPort(t){t!==null&&Util.s(t,GraphObject,LinkingBaseTool,"originalFromPort"),this.KS=t}get originalToNode(){return this.US}set originalToNode(t){t!==null&&Util.s(t,Node,LinkingBaseTool,"originalToNode"),this.US=t}get originalToPort(){return this.GS}set originalToPort(t){t!==null&&Util.s(t,GraphObject,LinkingBaseTool,"originalToPort"),this.GS=t}get isForwards(){return this.HS}set isForwards(t){this.HS=t}get validPortsCache(){return this.WC}get targetPort(){return this.qS}set targetPort(t){t!==null&&Util.s(t,GraphObject,LinkingBaseTool,"targetPort"),this.qS=t}copyPortProperties(t,i,e,s,n){if(t===null||i===null||e===null||s===null)return;const o=i.getDocumentScale(),r=Size.a();r.width=i.naturalBounds.width*o,r.height=i.naturalBounds.height*o,s.desiredSize=r,Size.o(r),n?(s.toSpot=i.toSpot,s.toEndSegmentLength=i.toEndSegmentLength):(s.fromSpot=i.fromSpot,s.fromEndSegmentLength=i.fromEndSegmentLength),e.locationSpot=Spot.Center;const l=Point.a();e.location=i.getDocumentPoint(Spot.Center,l),Point.o(l),s.angle=i.getDocumentAngle(),this.portTargeted!==null&&this.portTargeted(t,i,e,s,n)}setNoTargetPortProperties(t,i,e){i!==null&&(i.desiredSize=Size.zk,i.fromSpot=Spot.None,i.toSpot=Spot.None),t!==null&&(t.location=this.diagram.lastInput.documentPoint),this.portTargeted!==null&&this.portTargeted(null,null,t,i,e)}doMouseDown(){this.isActive&&this.doMouseMove()}doMouseMove(){if(this.isActive){const t=this.diagram;if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null&&this.targetPort.part instanceof Node){const i=this.targetPort.part;this.isForwards?this.copyPortProperties(i,this.targetPort,this.temporaryToNode,this.temporaryToPort,!0):this.copyPortProperties(i,this.targetPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else this.isForwards?this.setNoTargetPortProperties(this.temporaryToNode,this.temporaryToPort,!0):this.setNoTargetPortProperties(this.temporaryFromNode,this.temporaryFromPort,!1);(t.allowHorizontalScroll||t.allowVerticalScroll)&&t.doAutoScroll(t.lastInput.viewPoint)}}findValidLinkablePort(t,i){if(t===null)return null;const e=t.part;if(!(e instanceof Node))return null;for(;t!==null;){const s=i?t.toLinkable:t.fromLinkable;if(s===!0&&(t.portId!==null||t instanceof Node)&&(i?this.isValidTo(e,t):this.isValidFrom(e,t)))return t;if(s===!1)return null;t=t.panel}return null}findTargetPort(t){const i=this.diagram,e=i.lastInput.documentPoint;let s=this.portGravity;s<=0&&(s=.1);const n=this,o=i.findObjectsNear(e,s,a=>n.findValidLinkablePort(a,t),null,!0);let r=1/0,l=null;const h=o.iterator;for(;h.next();){const a=h.value,f=a.part;if(!(f instanceof Node))continue;const c=a.getDocumentPoint(Spot.Center,Point.a()),u=e.x-c.x,d=e.y-c.y;Point.o(c);const m=u*u+d*d;if(m=e)return!1}return!0}isValidTo(t,i){if(t===null||i===null)return this.isUnconnectedLinkValid;if(this.diagram.currentTool===this&&(t.layer!==null&&!t.layer.allowLink||i.toLinkable!==!0))return!1;const e=i.toMaxLinks;if(e<1/0){if(this.originalLink!==null&&t===this.originalToNode&&i===this.originalToPort)return!0;let s=i.portId;if(s===null&&(s=""),t.findLinksInto(s).count>=e)return!1}return!0}isInSameNode(t,i){if(t===null||i===null)return!1;if(t===i)return!0;const e=t.part,s=i.part;return e!==null&&e===s}isLinked(t,i){if(t===null||i===null)return!1;const e=t.part;if(!(e instanceof Node))return!1;let s=t.portId;s===null&&(s="");const n=i.part;if(!(n instanceof Node))return!1;let o=i.portId;o===null&&(o="");const r=n.findLinksInto(o);for(;r.next();){const l=r.value;if(l.fromNode===e&&l.fromPortId===s)return!0}return!1}isValidLink(t,i,e,s){if(!this.isValidFrom(t,i)||!this.isValidTo(e,s)||i!==null&&s!==null&&(!(i.fromLinkableSelfNode&&s.toLinkableSelfNode)&&this.isInSameNode(i,s)||!(i.fromLinkableDuplicates&&s.toLinkableDuplicates)&&this.isLinked(i,s))||this.originalLink!==null&&(t!==null&&this.isLabelDependentOnLink(t,this.originalLink)||e!==null&&this.isLabelDependentOnLink(e,this.originalLink))||t!==null&&e!==null&&(t.data===null&&e.data!==null||t.data!==null&&e.data===null)||!this.isValidCycle(t,e,this.originalLink))return!1;let n;return t!==null&&(n=t.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))||e!==null&&(n=e.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))?!1:(n=this.linkValidation,n!==null?n(t,i,e,s,this.originalLink):!0)}isLabelDependentOnLink(t,i){if(t===null)return!1;const e=t.labeledLink;if(e===null)return!1;if(e===i)return!0;const s=new GSet;return s.add(t),this.WS(e,i,s)}WS(t,i,e){if(t===i)return!0;const s=t.fromNode;if(s!==null&&s.isLinkLabel&&(e.add(s),this.WS(s.labeledLink,i,e)))return!0;const n=t.toNode;return!!(n!==null&&n.isLinkLabel&&(e.add(n),this.WS(n.labeledLink,i,e)))}isValidCycle(t,i,e){if(e===void 0&&(e=null),t===null||i===null)return this.isUnconnectedLinkValid;const s=this.diagram;let n=1;if(s&&(s.model.Pf()?n=s.isTreePathToChildren?5:6:n=s.validCycle),n===1)return!0;if(n===5){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=i.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.toNode===i)return!1}return!this.Cu(t,i,e,!0)}else if(n===6){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=t.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.fromNode===t)return!1}return!this.Cu(t,i,e,!0)}else{if(n===2)return!this.hF(t,i,e);if(n===3)return!this.Cu(t,i,e,!1);if(n===4)return!this.aF(t,i,e)}return!0}Cu(t,i,e,s){if(t===i)return!0;if(t===null||i===null)return!1;const n=t.linksConnected;for(;n.next();){const o=n.value;if(o===e||s&&!o.isTreeLink||o.toNode!==t)continue;const r=o.fromNode;if(r!==t&&this.Cu(r,i,e,s))return!0}return!1}hF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.vC(s,t,i,e)}vC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s||o.toNode!==i)continue;const r=o.fromNode;if(r!==i&&this.vC(t,r,e,s))return!0}return!1}aF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.JC(s,t,i,e)}JC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s)continue;const r=o.fromNode,l=o.toNode,h=r===i?l:r;if(h!==i&&this.JC(t,h,e,s))return!0}return!1}get linkValidation(){return this.Ll}set linkValidation(t){t!==null&&Util.t(t,"function",LinkingBaseTool,"linkValidation"),this.Ll=t}get portTargeted(){return this.jS}set portTargeted(t){t!==null&&Util.t(t,"function",LinkingBaseTool,"portTargeted"),this.jS=t}}var LinkingDirection=(w=>(w[w.Either=1]="Either",w[w.ForwardsOnly=2]="ForwardsOnly",w[w.BackwardsOnly=3]="BackwardsOnly",w))(LinkingDirection||{});class LinkingTool extends LinkingBaseTool{vS;JS;C;ZS;constructor(t){super(),this.name="Linking",this.vS={},this.JS=null,this.C=1,this.ZS=null,t&&Object.assign(this,t)}static Either=1;static ForwardsOnly=2;static BackwardsOnly=3;get archetypeLinkData(){return this.vS}set archetypeLinkData(t){t!==null&&Util.t(t,"object",LinkingTool,"archetypeLinkData"),t instanceof GraphObject&&Util.s(t,Link,LinkingTool,"archetypeLinkData"),this.vS=t}get archetypeLabelNodeData(){return this.JS}set archetypeLabelNodeData(t){t!==null&&Util.t(t,"object",LinkingTool,"archetypeLabelNodeData"),t instanceof GraphObject&&Util.s(t,Node,LinkingTool,"archetypeLabelNodeData"),this.JS=t}get direction(){return this.C}set direction(t){Util.tt(t,LinkingDirection,"LinkingDirection"),this.C=t}get startObject(){return this.ZS}set startObject(t){t!==null&&Util.s(t,GraphObject,LinkingTool,"startObject"),this.ZS=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||t.isModelReadOnly||!t.allowLink||!t.model.Jw()||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize()?!1:this.findLinkablePort()!==null}findLinkablePort(){const t=this.diagram;let i=this.startObject;if(i===null&&(i=t.findObjectAt(t.firstInput.documentPoint,null,null)),i===null)return null;const e=i.part;if(!(e instanceof Node))return null;const s=this.direction;if(s===1||s===2){const n=this.findValidLinkablePort(i,!1);if(n!==null)return this.isForwards=!0,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!1))return this.isForwards=!0,o}}if(s===1||s===3){const n=this.findValidLinkablePort(i,!0);if(n!==null)return this.isForwards=!1,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!0))return this.isForwards=!1,o}}return null}doActivate(){const t=this.diagram,i=this.findLinkablePort();if(i===null){this.stopTool();return}if(this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.isForwards){this.temporaryToNode!==null&&(this.temporaryToNode.location=t.lastInput.documentPoint),this.originalFromPort=i;const e=this.originalFromPort.part;e instanceof Node&&(this.originalFromNode=e),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else{this.temporaryFromNode!==null&&(this.temporaryFromNode.location=t.lastInput.documentPoint),this.originalToPort=i;const e=this.originalToPort.part;e instanceof Node&&(this.originalToNode=e),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0)}t.add(this.temporaryFromNode),this.temporaryFromNode&&this.temporaryFromNode.ensureBounds(),t.add(this.temporaryToNode),this.temporaryToNode&&this.temporaryToNode.ensureBounds(),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.temporaryLink.isTreeLink=this.isNewTreeLink(),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.startObject=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=null,e=null,s=null,n=null,o=null;try{this.targetPort=this.findTargetPort(this.isForwards);const r=this.targetPort;if(r!==null){const l=r.part;l instanceof Node&&(this.isForwards?(this.originalFromNode!==null&&(i=this.originalFromNode,e=this.originalFromPort),s=l,n=r):(i=l,e=r,this.originalToNode!==null&&(s=this.originalToNode,n=this.originalToPort)))}else this.isForwards?this.originalFromNode!==null&&this.isUnconnectedLinkValid&&(i=this.originalFromNode,e=this.originalFromPort):this.originalToNode!==null&&this.isUnconnectedLinkValid&&(s=this.originalToNode,n=this.originalToPort);i!==null||s!==null?(o=this.insertLink(i,e,s,n),o!==null?(r===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint),t.allowSelect&&(t.B("ChangingSelection",t.selection),t.clearSelection(!0),o.isSelected=!0),this.transactionResult=this.name,t.B("LinkDrawn",o)):this.doNoLink(i,e,s,n)):this.isForwards?this.doNoLink(this.originalFromNode,this.originalFromPort,null,null):this.doNoLink(null,null,this.originalToNode,this.originalToPort)}finally{this.stopTool(),o&&t.allowSelect&&t.B("ChangedSelection",t.selection)}}}isNewTreeLink(){const t=this.archetypeLinkData;if(t===null)return!0;if(t instanceof Link)return t.isTreeLink;const i=this.diagram;if(i===null)return!0;const e=i.partManager.getLinkCategoryForData(t),s=i.partManager.findLinkTemplateForCategory(e);return s!==null?s.isTreeLink:!0}insertLink(t,i,e,s){return this.diagram.partManager.insertLink(t,i,e,s)}doNoLink(t,i,e,s){}}class RelinkingTool extends LinkingBaseTool{$S;QS;ps;_S;constructor(t){super(),this.name="Relinking",this.$S=new Shape("Diamond",{desiredSize:Size.du,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:0}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.QS=new Shape("Diamond",{desiredSize:Size.du,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:-1}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.ps=null,this._S=new Rect,t&&Object.assign(this,t)}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i="RelinkFrom",e=null;if(t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkFrom()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null&&(e=this.makeAdornment(s,!1),t.addAdornment(i,e)))}if(e===null&&t.removeAdornment(i),i="RelinkTo",e=null,t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkTo()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null?(e=this.makeAdornment(s,!0),t.addAdornment(i,e)):e.u())}e===null&&t.removeAdornment(i)}makeAdornment(t,i){const e=new Adornment;e.type=Panel.Link;const s=i?this.toHandleArchetype:this.fromHandleArchetype;return s!==null&&e.add(s.copy().Cm()),e.adornedObject=t,e}get fromHandleArchetype(){return this.$S}set fromHandleArchetype(t){t!==null&&Util.s(t,GraphObject,RelinkingTool,"fromHandleArchetype"),this.$S=t}get toHandleArchetype(){return this.QS}set toHandleArchetype(t){t!==null&&Util.s(t,GraphObject,RelinkingTool,"toHandleArchetype"),this.QS=t}get handle(){return this.ps}set handle(t){if(t!==null&&(Util.s(t,GraphObject,RelinkingTool,"handle"),!(t.part instanceof Adornment)))throw new Error("new handle is not in an Adornment: "+t);this.ps=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowRelink||!t.model.Jw()||!t.lastInput.left)return!1;let e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom");return e===null&&(e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo")),e!==null}doActivate(){const t=this.diagram;if(this.originalLink===null){let i=this.handle;if(i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom"),i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo"))),i===null)return;const e=i.part;if(!(e instanceof Adornment)||!(e.adornedPart instanceof Link))return;this.handle=i,this.isForwards=e===null||e.category==="RelinkTo",this.originalLink=e.adornedPart}this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.originalFromPort=this.originalLink.fromPort,this.originalFromNode=this.originalLink.fromNode,this.originalToPort=this.originalLink.toPort,this.originalToNode=this.originalLink.toNode,this._S.set(this.originalLink.actualBounds),this.originalLink!==null&&this.originalLink.pointsCount>0&&(this.originalLink.fromNode===null&&(this.temporaryFromPort!==null&&(this.temporaryFromPort.desiredSize=Size.hf),this.temporaryFromNode!==null&&(this.temporaryFromNode.location=this.originalLink.getPoint(0))),this.originalLink.toNode===null&&(this.temporaryToPort!==null&&(this.temporaryToPort.desiredSize=Size.hf),this.temporaryToNode!==null&&(this.temporaryToNode.location=this.originalLink.getPoint(this.originalLink.pointsCount-1)))),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0),t.add(this.temporaryFromNode),t.add(this.temporaryToNode),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.copyLinkProperties(this.originalLink,this.temporaryLink),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}copyLinkProperties(t,i){if(t===null||i===null)return;i.adjusting=t.adjusting,i.corner=t.corner;let e=t.curve;(e===11||e===10)&&(e=0),i.curve=e,i.curviness=t.curviness,i.isTreeLink=t.isTreeLink,i.points=t.points,i.routing=t.routing,i.smoothness=t.smoothness,i.fromSpot=t.fromSpot,i.fromEndSegmentLength=t.fromEndSegmentLength,i.fromShortLength=t.fromShortLength,i.toSpot=t.toSpot,i.toEndSegmentLength=t.toEndSegmentLength,i.toShortLength=t.toShortLength}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.handle=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=this.originalFromNode,e=this.originalFromPort,s=this.originalToNode,n=this.originalToPort,o=this.originalLink;try{if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null){const r=this.targetPort.part;r instanceof Node&&(this.isForwards?(s=r,n=this.targetPort):(i=r,e=this.targetPort))}else this.isUnconnectedLinkValid?this.isForwards?(s=null,n=null):(i=null,e=null):o=null;o!==null?(this.reconnectLink(o,this.isForwards?s:i,this.isForwards?n:e,this.isForwards),this.targetPort===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint,o.invalidateRoute()),this.transactionResult=this.name,t.B("LinkRelinked",o,this.isForwards?this.originalToPort:this.originalFromPort)):this.doNoRelink(this.originalLink,this.isForwards),this.originalLink.invalidateOtherJumpOvers(this._S)}finally{this.stopTool()}}}reconnectLink(t,i,e,s){const n=e!==null&&e.portId!==null?e.portId:"";return s?(t.toNode=i,t.toPortId=n):(t.fromNode=i,t.fromPortId=n),!0}doNoRelink(t,i){}doDraggingMouseMove(t,i,e,s){t!==null?(this.copyPortProperties(t,i,this.temporaryFromNode,this.temporaryFromPort,!1),this.diagram.add(this.temporaryFromNode)):this.diagram.remove(this.temporaryFromNode),e!==null?(this.copyPortProperties(e,s,this.temporaryToNode,this.temporaryToPort,!0),this.diagram.add(this.temporaryToNode)):this.diagram.remove(this.temporaryToNode)}stopDraggingMouseMove(){this.diagram.remove(this.temporaryFromNode),this.diagram.remove(this.temporaryToNode)}}var ReshapingBehavior=(w=>(w[w.None=0]="None",w[w.Horizontal=1]="Horizontal",w[w.Vertical=2]="Vertical",w[w.All=3]="All",w))(ReshapingBehavior||{});class LinkReshapingTool extends Tool{Fo;tM;iM;ps;Zw;eM;Am;constructor(t){super(),this.name="LinkReshaping",this.Fo=new Shape("Rectangle",{desiredSize:Size.lC,fill:"lightblue",stroke:"dodgerblue"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.tM=new Shape("Diamond",{desiredSize:Size.du,fill:"lightblue",stroke:"dodgerblue",cursor:"move"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.iM=3,this.ps=null,this.Zw=null,this.eM=new Point,this.Am=new List,t&&Object.assign(this,t)}static None=0;static Horizontal=1;static Vertical=2;static All=3;getReshapingBehavior(t){return t?t.Mr:0}setReshapingBehavior(t,i){t.Mr=i}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i=null;if(t.isSelected&&!this.diagram.isReadOnly){const e=t.path;e!==null&&t.canReshape()&&t.actualBounds.isReal()&&t.isVisible()&&e.actualBounds.isReal()&&e.isVisibleObject()&&(i=t.findAdornment(this.name),(i===null||i.sM!==t.pointsCount||i.nM!==t.resegmentable)&&(i=this.makeAdornment(e),i!==null&&(i.sM=t.pointsCount,i.nM=t.resegmentable,t.addAdornment(this.name,i))))}i===null&&t.removeAdornment(this.name)}makeAdornment(t){const i=t.part,e=i.points,s=i.pointsCount,n=i.isOrthogonal;let o=null;if(e!==null&&s>1){o=new Adornment,o.type=Panel.Link;const r=i.firstPickIndex,l=i.lastPickIndex,h=n?1:0;if(i.resegmentable&&i.computeCurve()!==9)for(let a=r+h;ae.firstPickIndex+1&&s0))this.fF(t,i);else if(t instanceof Panel){const e=t.elements;for(;e.next();){const s=e.value;this.updateResizeHandles(s,i)}}}}fF(t,i){let e=t.alignment;e.isNoSpot()&&(e=Spot.Center);let s=i;if(e.x<=0)e.y<=0?s+=225:e.y>=1?s+=135:s+=180;else if(e.x>=1)e.y<=0?s+=315:e.y>=1&&(s+=45);else if(e.y<=0)s+=270;else if(e.y>=1)s+=90;else return;s<0?s+=360:s>=360&&(s-=360),s<22.5?t.cursor="e-resize":s<67.5?t.cursor="se-resize":s<112.5?t.cursor="s-resize":s<157.5?t.cursor="sw-resize":s<202.5?t.cursor="w-resize":s<247.5?t.cursor="nw-resize":s<292.5?t.cursor="n-resize":s<337.5?t.cursor="ne-resize":t.cursor="e-resize"}get handleArchetype(){return this.Fo}set handleArchetype(t){t!==null&&Util.s(t,GraphObject,ResizingTool,"handleArchetype"),this.Fo=t}get handle(){return this.ps}set handle(t){if(t!==null&&(Util.s(t,GraphObject,ResizingTool,"handle"),!(t.part instanceof Adornment)))throw new Error("new handle is not in an Adornment: "+t);this.ps=t}get adornedObject(){return this.ys}set adornedObject(t){if(t!==null&&(Util.s(t,GraphObject,ResizingTool,"handle"),t.part instanceof Adornment))throw new Error("new handle must not be in an Adornment: "+t);this.ys=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowResize||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle!==null&&(this.adornedObject=this.handle.part.adornedObject,this.adornedObject!==null&&(t.isMouseCaptured=!0,t.animationManager.stopAnimation(),t.Mu=!0,this.startTransaction(this.name),this.Lm.set(this.adornedObject.getDocumentPoint(this.handle.alignment.opposite())),this.Cf.set(this.adornedObject.part.location),this.rM.set(this.adornedObject.desiredSize),this._w=this.computeCellSize(),this.$w=this.computeMinSize(),this.Qw=this.computeMaxSize(),this.isActive=!0))}doDeactivate(){const t=this.diagram;t.Mu=!1,t.Pl=!0,this.stopTransaction(),this.handle=null,this.ys=null,t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){this.adornedObject!==null&&(this.adornedObject.desiredSize=this.originalDesiredSize,this.adornedObject.part.location=this.originalLocation),this.stopTool()}doMouseMove(){const t=this.diagram;if(!this.isActive)return;const i=this.$w,e=this.Qw,s=this._w,n=t.lastInput.documentPoint,o=this.adornedObject.getLocalPoint(n,Point.a()),r=this.computeReshape(),l=this.computeResize(o,this.handle.alignment,i,e,s,r);this.resize(l),t.maybeUpdate(),Point.o(o)}doMouseUp(){const t=this.diagram;if(this.isActive){const i=this.$w,e=this.Qw,s=this._w,n=this.adornedObject.getLocalPoint(t.lastInput.documentPoint,Point.a()),o=this.computeReshape(),r=this.computeResize(n,this.handle.alignment,i,e,s,o);this.resize(r),Point.o(n),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.B("PartResized",this.adornedObject,this.originalDesiredSize)}this.stopTool()}resize(t){const i=this.diagram,e=this.adornedObject;if(e===null)return;e.desiredSize=t.size;const s=e.part;s.ensureBounds();const n=e.getDocumentPoint(this.handle.alignment.opposite());if(s instanceof Group){const o=new List;o.add(s);let r;!this.dragsMembers&&!s.hasPlaceholder()&&(r=new DraggingOptions,r.dragsMembers=!1),i.moveParts(o,this.oppositePoint.copy().subtract(n),!0,r)}else s.location=s.location.copy().subtract(n).add(this.oppositePoint);i.maybeUpdate()}computeResize(t,i,e,s,n,o){i.isNoSpot()&&(i=Spot.Center);const r=this.adornedObject.naturalBounds,l=r.x,h=r.y,a=r.x+r.width,f=r.y+r.height;let c=1;if(!o){let m=r.width,g=r.height;m<=0&&(m=1),g<=0&&(g=1),c=g/m}const u=Point.a();Geo.Gg(t.x,t.y,l,h,n.width,n.height,u);const d=r.copy();return i.x<=0?i.y<=0?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.y=Math.max(u.y,f-s.height),d.y=Math.min(d.y,f-e.height),d.height=Math.max(f-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width),d.x=a-d.width,d.y=f-d.height)):i.y>=1?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width),d.x=a-d.width)):(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=a-d.x,o||(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c,d.y=h+.5*(f-h-d.height))):i.x>=1?i.y<=0?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.y=Math.max(u.y,f-s.height),d.y=Math.min(d.y,f-e.height),d.height=Math.max(f-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width),d.y=f-d.height)):i.y>=1?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width))):(d.width=Math.max(Math.min(u.x-l,s.width),e.width),o||(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c,d.y=h+.5*(f-h-d.height))):i.y<=0?(d.y=Math.max(u.y,f-s.height),d.y=Math.min(d.y,f-e.height),d.height=f-d.y,o||(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width,d.x=l+.5*(a-l-d.width))):i.y>=1&&(d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width,d.x=l+.5*(a-l-d.width))),Point.o(u),d}computeReshape(){let t=0;return this.adornedObject instanceof Shape&&(t=this.adornedObject.lM()),!(t===6||this.diagram.lastInput.shift)}computeMinSize(){const t=this.adornedObject.minSize.copy(),i=this.minSize;return!isNaN(i.width)&&i.width>t.width&&(t.width=i.width),!isNaN(i.height)&&i.height>t.height&&(t.height=i.height),t}computeMaxSize(){const t=this.adornedObject.maxSize.copy(),i=this.maxSize;return!isNaN(i.width)&&i.width0&&(t.width=n.width),!isNaN(n.height)&&n.height>0&&(t.height=n.height)}let e=this.cellSize;isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height);const s=this.diagram;if((isNaN(t.width)||isNaN(t.height))&&s){const n=s.grid;n!==null&&n.visible&&this.isGridSnapEnabled&&(e=n.gridCellSize,isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height))}return(isNaN(t.width)||t.width===0||t.width===1/0)&&(t.width=1),(isNaN(t.height)||t.height===0||t.height===1/0)&&(t.height=1),t}get minSize(){return this.Pr}set minSize(t){if(Util.s(t,Size,ResizingTool,"minSize"),!this.Pr.equals(t)){let e=t.width;isNaN(e)&&(e=0);let s=t.height;isNaN(s)&&(s=0),this.Pr.e(e,s)}}get maxSize(){return this.Nr}set maxSize(t){if(Util.s(t,Size,ResizingTool,"maxSize"),!this.Nr.equals(t)){let e=t.width;isNaN(e)&&(e=1/0);let s=t.height;isNaN(s)&&(s=1/0),this.Nr.e(e,s)}}get cellSize(){return this.Ro}set cellSize(t){Util.s(t,Size,ResizingTool,"cellSize"),this.Ro.equals(t)||this.Ro.c(t)}get isGridSnapEnabled(){return this.Nf}set isGridSnapEnabled(t){Util.t(t,"boolean",ResizingTool,"isGridSnapEnabled"),this.Nf=t}get dragsMembers(){return this.oM}set dragsMembers(t){Util.t(t,"boolean",ResizingTool,"dragsMembers"),this.oM=t}get oppositePoint(){return this.Lm}set oppositePoint(t){Util.s(t,Point,ResizingTool,"oppositePoint"),this.Lm.equals(t)||this.Lm.c(t)}get originalDesiredSize(){return this.rM}get originalLocation(){return this.Cf}}class RotatingTool extends Tool{hM;aM;ys;Fo;ps;fM;Tm;Cf;cM;uM;constructor(t){super(),this.name="Rotating",this.hM=45,this.aM=2,this.Cf=new Point,this.ys=null,this.Fo=new Shape("Ellipse",{desiredSize:Size.du,fill:"lightblue",stroke:"dodgerblue",strokeWidth:1,cursor:"pointer"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.ps=null,this.fM=0,this.Tm=new Point(NaN,NaN),this.cM=0,this.uM=50,t&&Object.assign(this,t)}updateAdornments(t){if(t!==null){if(t.Dl()){const i=t.rotateObject;if(i===t||i===t.path||i.isPanelMain)return}if(t.isSelected&&!this.diagram.isReadOnly){const i=t.rotateObject;if(i!==null&&t.canRotate()&&t.actualBounds.isReal()&&t.isVisible()&&i.actualBounds.isReal()&&i.isVisibleObject()){let e=t.findAdornment(this.name);if((e===null||e.adornedObject!==i)&&(e=this.makeAdornment(i)),e!==null){e.angle=i.getDocumentAngle(),e.hasPlaceholder()||(e.location=this.computeAdornmentLocation(i)),t.addAdornment(this.name,e);return}}}t.removeAdornment(this.name)}}makeAdornment(t){let i=null;const e=t.part.rotateAdornmentTemplate;if(e===null){i=new Adornment,i.type=Panel.Position,i.locationSpot=Spot.Center;const s=this.handleArchetype;s!==null&&i.add(s.copy().Cm())}else if(e.ci(),i=e.copy(),i===null)return null;return i.adornedObject=t,i}get handleArchetype(){return this.Fo}set handleArchetype(t){t!==null&&Util.s(t,GraphObject,RotatingTool,"handleArchetype"),this.Fo=t}get handle(){return this.ps}set handle(t){if(t!==null&&(Util.s(t,GraphObject,RotatingTool,"handle"),!(t.part instanceof Adornment)))throw new Error("new handle is not in an Adornment: "+t);this.ps=t}get adornedObject(){return this.ys}set adornedObject(t){if(t!==null&&(Util.s(t,GraphObject,RotatingTool,"handle"),t.part instanceof Adornment))throw new Error("new handle must not be in an Adornment: "+t);this.ys=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowRotate||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;if(this.adornedObject===null){if(this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle===null)return;this.adornedObject=this.handle.part.adornedObject}this.adornedObject!==null&&(t.isMouseCaptured=!0,t.delaysLayout=!0,this.startTransaction(this.name),this.fM=this.adornedObject.angle,this.Tm=this.computeRotationPoint(this.adornedObject),this.Cf=this.adornedObject.part.location.copy(),this.isActive=!0)}computeRotationPoint(t){const i=t.part,e=i.locationObject;return i.rotationSpot.isSpot()?t.getDocumentPoint(i.rotationSpot):t===i||t===e?e.getDocumentPoint(i.locationSpot):t.getDocumentPoint(Spot.Center)}computeAdornmentLocation(t){let i=this.rotationPoint;i.isReal()||(i=this.computeRotationPoint(t));const e=t.getLocalPoint(i);let s=this.handleAngle;s<0?s+=360:s>=360&&(s-=360),s=Math.round(Math.round(s/45)*45);const n=this.handleDistance;return s===0?e.x=t.naturalBounds.width+n:s===45?(e.x=t.naturalBounds.width+n,e.y=t.naturalBounds.height+n):s===90?e.y=t.naturalBounds.height+n:s===135?(e.x=-n,e.y=t.naturalBounds.height+n):s===180?e.x=-n:s===225?(e.x=-n,e.y=-n):s===270?e.y=-n:s===315&&(e.x=t.naturalBounds.width+n,e.y=-n),t.getDocumentPoint(e)}doDeactivate(){const t=this.diagram;this.stopTransaction(),this.handle=null,this.ys=null,this.Tm=new Point(NaN,NaN),t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){const t=this.diagram;t.delaysLayout=!1,this.rotate(this.originalAngle),this.stopTool()}doMouseMove(){const t=this.diagram;if(this.isActive){const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i)}}doMouseUp(){const t=this.diagram;if(this.isActive){t.delaysLayout=!1;const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.B("PartRotated",this.adornedObject,this.originalAngle)}this.stopTool()}rotate(t){Debug&&Util.r(t,RotatingTool,"rotate:newangle");const i=this.adornedObject;if(i===null)return;i.angle=t;const e=i.part;e.ensureBounds();const s=e.locationObject,n=e.rotateObject;if(s===n||s.isContainedBy(n)){const o=this.Cf.copy();e.location=o.subtract(this.rotationPoint).rotate(t-this.originalAngle).add(this.rotationPoint)}this.diagram.maybeUpdate()}computeRotate(t){let i=this.rotationPoint.directionPoint(t)-this.handleAngle;const e=this.adornedObject.panel;e!==null&&(i-=e.getDocumentAngle()),i>=360?i-=360:i<0&&(i+=360);const s=Math.min(Math.abs(this.snapAngleMultiple),180),n=Math.min(Math.abs(this.snapAngleEpsilon),s/2);return!this.diagram.lastInput.shift&&s>0&&n>0&&(i%ss-n&&(i=(Math.floor(i/s)+1)*s)),i>=360?i-=360:i<0&&(i+=360),i}get snapAngleMultiple(){return this.hM}set snapAngleMultiple(t){Util.t(t,"number",RotatingTool,"snapAngleMultiple"),this.hM=t}get snapAngleEpsilon(){return this.aM}set snapAngleEpsilon(t){Util.t(t,"number",RotatingTool,"snapAngleEpsilon"),this.aM=t}get originalAngle(){return this.fM}get rotationPoint(){return this.Tm}set rotationPoint(t){this.Tm=t.copy()}get handleAngle(){return this.cM}set handleAngle(t){Util.t(t,"number",RotatingTool,"handleAngle"),this.cM=t}get handleDistance(){return this.uM}set handleDistance(t){Util.t(t,"number",RotatingTool,"handleDistance"),this.uM=t}}class ClickSelectingTool extends Tool{constructor(t){super(),this.name="ClickSelecting",t&&Object.assign(this,t)}canStart(){return!(!this.isEnabled||this.isBeyondDragSize())}doMouseUp(){this.isActive&&(this.standardMouseSelect(),this.standardMouseClick()||this.diagram.lastInput.isTouchEvent&&this.diagram.toolManager.doToolTip()),this.stopTool()}}class ActionTool extends Tool{Af;constructor(t){super(),this.name="Action",this.Af=null,t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram,i=t.lastInput,e=t.findObjectAt(i.documentPoint,s=>{for(;s.panel!==null;){if(s.isActionable)return s;s=s.panel}return s});return e!==null&&e.isActionable?(this.Af=e,t.xf=t.findObjectAt(i.documentPoint,null,null),!0):!1}doMouseDown(){if(!this.isActive)this.canStart()&&this.doActivate();else{const i=this.diagram.lastInput,e=this.Af;if(e===null)return;i.targetObject=e,e.actionDown!==null&&e.actionDown(i,e)}}doMouseMove(){if(this.isActive){const i=this.diagram.lastInput,e=this.Af;if(e===null)return;i.targetObject=e,e.actionMove!==null&&e.actionMove(i,e)}}doMouseUp(){if(this.isActive){const i=this.diagram.lastInput,e=this.Af;if(e===null)return;i.targetObject=e,e.actionUp!==null&&e.actionUp(i,e),this.standardMouseClick(s=>{for(;s.panel!==null;){if(s.isActionable&&s===e)return s;s=s.panel}return s},s=>s===e)}this.stopTool()}doCancel(){const i=this.diagram.lastInput,e=this.Af;e!==null&&(i.targetObject=e,e.actionCancel!==null&&e.actionCancel(i,e),this.stopTool())}doStop(){this.Af=null}}class ClickCreatingTool extends Tool{Fl;dM;Nf;gM;constructor(t){super(),this.name="ClickCreating",this.Fl=null,this.dM=!0,this.Nf=!1,this.gM=new Point(0,0),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled||this.archetypeNodeData===null)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.lastInput.left||this.isBeyondDragSize())return!1;if(this.isDoubleClick){if(t.lastInput.clickCount===1&&(this.gM=t.lastInput.viewPoint.copy()),t.lastInput.clickCount!==2||this.isBeyondDragSize(this.gM))return!1}else if(t.lastInput.clickCount!==1)return!1;return!(t.currentTool!==this&&t.findPartAt(t.lastInput.documentPoint,!0)!==null)}doMouseUp(){const t=this.diagram;this.isActive&&this.insertPart(t.lastInput.documentPoint),this.stopTool()}insertPart(t){const i=this.diagram,e=this.archetypeNodeData;if(e===null)return null;let s=null;try{if(i.B("ChangingSelection",i.selection),this.startTransaction(this.name),e instanceof Part)e.Ae()&&(e.ci(),s=e.copy(),s!==null&&i.add(s));else if(e!==null){const n=i.model.copyNodeData(e);Util.Mt(n)&&(i.model.addNodeData(n),s=i.findPartForData(n))}if(s!==null){const n=Point.H(t.x,t.y);this.isGridSnapEnabled&&this.diagram.mM(s,t,n),s.location=n,i.allowSelect&&(i.clearSelection(!0),s.isSelected=!0),Point.o(n)}i.invalidateDocumentBounds(),this.transactionResult=this.name,i.B("PartCreated",s)}finally{this.stopTransaction(),i.B("ChangedSelection",i.selection)}return s}get archetypeNodeData(){return this.Fl}set archetypeNodeData(t){t!==null&&Util.t(t,"object",ClickCreatingTool,"archetypeNodeData"),this.Fl=t}get isDoubleClick(){return this.dM}set isDoubleClick(t){Util.t(t,"boolean",ClickCreatingTool,"isDoubleClick"),this.dM=t}get isGridSnapEnabled(){return this.Nf}set isGridSnapEnabled(t){Util.t(t,"boolean",ClickCreatingTool,"isGridSnapEnabled"),this.Nf=t}}class DragSelectingTool extends Tool{Gh;pM;Rl;constructor(t){super(),this.name="DragSelecting",this.Gh=175,this.pM=!1,this.Rl=new Part({layerName:"Tool",selectable:!1}).add(new Shape("Rectangle",{name:"SHAPE",fill:null,stroke:"magenta"}).theme("stroke","dragSelect")).ci(),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(!t.allowSelect)return!1;const i=t.lastInput;return!(!i.left||t.currentTool!==this&&(!this.isBeyondDragSize()||i.timestamp-t.firstInput.timestamp{const e=i.diagram;e!==null&&e.Li(root.document,"scroll",i.yM,!1),i.stopTool()},t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return!(!t.allowHorizontalScroll&&!t.allowVerticalScroll||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize())}doActivate(){const t=this.diagram;this.Do?(t.lastInput.bubbles=!0,t.Ht(root.document,"scroll",this.yM,!1)):(t.currentCursor="move",t.isMouseCaptured=!0,this.tx.c(t.position)),this.isActive=!0}doDeactivate(){const t=this.diagram;t.currentCursor="",t.isMouseCaptured=!1,this.isActive=!1}doCancel(){const t=this.diagram;t.position=this.tx,t.isMouseCaptured=!1,this.stopTool()}doMouseMove(){this.$C()}doMouseUp(){this.$C(),this.stopTool()}$C(){const t=this.diagram;if(this.isActive&&t){if(this.Do){t.lastInput.bubbles=!0;return}const i=t.position,e=t.firstInput.documentPoint,s=t.lastInput.documentPoint;let n=i.x+e.x-s.x,o=i.y+e.y-s.y;t.allowHorizontalScroll||(n=i.x),t.allowVerticalScroll||(o=i.y),t.position=this.ZC.e(n,o)}}get bubbles(){return this.Do}set bubbles(t){Util.t(t,"boolean",PanningTool,"bubbles"),this.Do=t}get originalPosition(){return this.tx}}class HTMLInfo{ix;ex;wM;xM;constructor(t){this.ix=null,this.ex=null,this.wM=null,this.xM=null,t&&Object.assign(this,t)}get mainElement(){return this.wM}set mainElement(t){t!==null&&Util.s(t,HTMLElement,HTMLInfo,"mainElement"),this.wM=t}get show(){return this.ix}set show(t){this.ix!==t&&(t!==null&&Util.t(t,"function",HTMLInfo,"show"),this.ix=t)}get hide(){return this.ex}set hide(t){this.ex!==t&&(t!==null&&Util.t(t,"function",HTMLInfo,"hide"),this.ex=t)}get valueFunction(){return this.xM}set valueFunction(t){this.xM=t}}class ContextMenuButtonInfo{ui;Dm;Tf;constructor(t,i,e){this.ui=t,this.Dm=i,this.Tf=e}}class ContextMenuTool extends Tool{bM;sx;kM;SM;nx;ox;Fm;constructor(t){super(),this.name="ContextMenu",this.bM=null,this.sx=null,this.kM=null,this.SM=new Point,this.nx=null,this.Fm=!1;const i=this;this.ox=()=>i.stopTool(),t&&Object.assign(this,t)}cF(){const t=new HTMLInfo;t.show=(r,l,h)=>h.showDefaultContextMenu(),t.hide=(r,l)=>l.hideDefaultContextMenu(),ContextMenuTool.Au=t;const i=this;this.ox=()=>i.stopTool();const e=Util.ln("div"),s=Util.ln("div");e.style.cssText="top: 0px;z-index:10002;position: fixed;display: none;text-align: center;left: 25%;width: 50%;background-color: #F5F5F5;padding: 16px;border: 16px solid #444;border-radius: 10px;margin-top: 10px",s.style.cssText="z-index:10001;position: fixed;display: none;top: 0;left: 0;width: 100%;height: 100%;background-color: black;opacity: 0.8;";const n=Util.ln("style");root.document.getElementsByTagName("head")[0].appendChild(n),n.sheet.insertRule(".goCXul { list-style: none; }",0),n.sheet.insertRule(".goCXli {font:700 1.5em Helvetica, Arial, sans-serif;position: relative;min-width: 60px; }",0),n.sheet.insertRule(".goCXa {color: #444;display: inline-block;padding: 4px;text-decoration: none;margin: 2px;border: 1px solid gray;border-radius: 10px; }",0);const o=this.diagram;o!==null&&(o.Ht(e,"contextmenu",ContextMenuTool.Wh,!1),o.Ht(e,"selectstart",ContextMenuTool.Wh,!1),o.Ht(s,"contextmenu",ContextMenuTool.Wh,!1)),e.className="goCXforeground",s.className="goCXbackground",root.document.body&&(root.document.body.appendChild(e),root.document.body.appendChild(s)),ContextMenuTool.Rm=e,ContextMenuTool.Im=s,ContextMenuTool.MM=!0}static Au=null;static MM=!1;static Im=null;static Rm=null;static Wh(t){return t.preventDefault(),!1}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return this.isBeyondDragSize()||!t.lastInput.right||t.lastInput.clickCount>1?!1:!!(t.lastInput.isTouchEvent&&this.defaultTouchContextMenu!==null||this.findObjectWithContextMenu()!==null)}doStart(){const t=this.diagram;this.SM.set(t.firstInput.documentPoint)}doStop(){this.hideContextMenu(),this.currentObject=null,this.Fm=!1}findObjectWithContextMenu(t){t===void 0&&(t=null);const i=this.diagram,e=i.lastInput;let s=null;if(t instanceof Diagram||(t instanceof GraphObject?s=t:s=i.findObjectAt(e.documentPoint,null,n=>!n.layer.isTemporary)),s!==null){let n=s;for(;n!==null;){if(n.contextMenu!==null)return n;n=n.panel}if(i.lastInput.isTouchEvent&&this.defaultTouchContextMenu)return s.part}else if(i.contextMenu!==null)return i;return null}doActivate(){}doMouseDown(){if(super.doMouseDown(),this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doMouseDown(),t.doDeactivate())}this.diagram.toolManager.mouseDownTools.has(this)&&this.doContextClick()}doMouseUp(){if(this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doCancel(),t.doDeactivate())}this.doContextClick()}doContextClick(){const t=this.diagram;if(!this.isActive)this.canStart()&&(this.openMenu(!0),this.isActive||this.stopTool());else{const i=this.currentContextMenu;if(i===null)return;let e=null;i instanceof HTMLInfo||(e=t.findObjectAt(t.lastInput.documentPoint,null,null),e!==null&&e.isContainedBy(i)&&this.standardMouseClick(null,null)),this.maybeStopTool(e)}}maybeStopTool(t){this.stopTool(),this.canStart()&&(this.diagram.currentTool=this,this.doMouseUp())}openMenu(t,i){if(i===void 0&&(i=null),this.Fm)return;this.Fm=!0,t&&this.standardMouseSelect();const e=this.standardMouseClick();if(this.Fm=!1,!e){this.isActive=!0;const s=ContextMenuTool.Au;if(i===null&&(i=this.findObjectWithContextMenu()),i!==null){const n=i.contextMenu;n!==null?(this.currentObject=i instanceof GraphObject?i:null,this.showContextMenu(n,this.currentObject)):s!==null&&this.showContextMenu(s,this.currentObject)}else s!==null&&this.showContextMenu(s,null);this.currentContextMenu instanceof Adornment&&!this.currentContextMenu.visible&&this.stopTool()}}doMouseMove(){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.doMouseMove(),this.isActive&&this.diagram.toolManager.doMouseMove()}showContextMenu(t,i){Debug&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("showContextMenu:contextMenu must be an Adornment or HTMLInfo."),i!==null&&Util.s(i,GraphObject,ContextMenuTool,"showContextMenu:obj");const e=this.diagram;if(t!==this.currentContextMenu&&this.hideContextMenu(),t instanceof Adornment){const s=t;s.layerName="Tool",s.selectable=!1,s.scale=1/e.scale,s.category=this.name,s.hasPlaceholder()&&(s.placeholder.scale=e.scale);const n=s.diagram;n!==null&&n!==e&&n.remove(s),e.add(s),i!==null?s.adornedObject=i:s.data=e.model,s.ensureBounds(),this.positionContextMenu(s,i)}else t instanceof HTMLInfo&&t.show(i,e,this);this.currentContextMenu=t}positionContextMenu(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom&&(n.y-=o.height+5/s.scale),n.ye.commandHandler.copySelection(),e=>e.commandHandler.canCopySelection())),i.add(new ContextMenuButtonInfo("Cut",e=>e.commandHandler.cutSelection(),e=>e.commandHandler.canCutSelection())),i.add(new ContextMenuButtonInfo("Delete",e=>e.commandHandler.deleteSelection(),e=>e.commandHandler.canDeleteSelection())),i.add(new ContextMenuButtonInfo("Paste",e=>e.commandHandler.pasteSelection(t.mouseDownPoint),e=>e.commandHandler.canPasteSelection(t.mouseDownPoint))),i.add(new ContextMenuButtonInfo("Select All",e=>e.commandHandler.selectAll(),e=>e.commandHandler.canSelectAll())),i.add(new ContextMenuButtonInfo("Undo",e=>e.commandHandler.undo(),e=>e.commandHandler.canUndo())),i.add(new ContextMenuButtonInfo("Redo",e=>e.commandHandler.redo(),e=>e.commandHandler.canRedo())),i.add(new ContextMenuButtonInfo("Scroll To Part",e=>e.commandHandler.scrollToPart(),e=>e.commandHandler.canScrollToPart())),i.add(new ContextMenuButtonInfo("Zoom To Fit",e=>e.commandHandler.zoomToFit(),e=>e.commandHandler.canZoomToFit())),i.add(new ContextMenuButtonInfo("Reset Zoom",e=>e.commandHandler.resetZoom(),e=>e.commandHandler.canResetZoom())),i.add(new ContextMenuButtonInfo("Group Selection",e=>e.commandHandler.groupSelection(),e=>e.commandHandler.canGroupSelection())),i.add(new ContextMenuButtonInfo("Ungroup Selection",e=>e.commandHandler.ungroupSelection(),e=>e.commandHandler.canUngroupSelection())),i.add(new ContextMenuButtonInfo("Edit Text",e=>e.commandHandler.editTextBlock(),e=>e.commandHandler.canEditTextBlock())),i}showDefaultContextMenu(){const t=this.diagram;this.nx===null&&(this.nx=this.uF()),ContextMenuTool.Rm.innerHTML="",ContextMenuTool.Im.addEventListener("pointerdown",this.ox,!1);const i=this,e=Util.ln("ul");e.className="goCXul",ContextMenuTool.Rm.appendChild(e),e.innerHTML="";const s=this.nx.iterator;for(;s.next();){const n=s.value,o=n.Dm,r=n.Tf;if(typeof o!="function"||typeof r=="function"&&!r(t))continue;const l=Util.ln("li");l.className="goCXli";const h=Util.ln("a");h.className="goCXa",h.href="#",h.Dm=n.Dm,h.addEventListener("pointerdown",function(a){return this.Dm(t),i.stopTool(),a.preventDefault(),!1},!1),h.textContent=n.ui,l.appendChild(h),e.appendChild(l)}ContextMenuTool.Rm.style.display="block",ContextMenuTool.Im.style.display="block"}hideDefaultContextMenu(){if(this.currentContextMenu===null||this.currentContextMenu!==ContextMenuTool.Au)return;ContextMenuTool.Rm.style.display="none",ContextMenuTool.Im.style.display="none";const t=this.diagram;t!==null&&t.Li(ContextMenuTool.Im,"pointerdown",this.ox,!1),this.currentContextMenu=null}get currentContextMenu(){return this.bM}set currentContextMenu(t){Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("ContextMenuTool.currentContextMenu must be an Adornment or HTMLInfo."),this.bM=t,this.sx=t instanceof Adornment?t.adornedPart:null}get defaultTouchContextMenu(){return ContextMenuTool.MM===!1&&ContextMenuTool.Au===null&&Diagram.isUsingDOM()&&this.cF(),ContextMenuTool.Au}set defaultTouchContextMenu(t){Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("ContextMenuTool.defaultTouchContextMenu must be an Adornment or HTMLInfo."),t===null&&(ContextMenuTool.MM=!0),ContextMenuTool.Au=t}get currentObject(){return this.kM}set currentObject(t){t!==null&&Util.s(t,GraphObject,ContextMenuTool,"currentObject"),this.kM=t}get mouseDownPoint(){return this.SM}}var TextEditingAccept=(w=>(w[w.LostFocus=1]="LostFocus",w[w.MouseDown=2]="MouseDown",w[w.Tab=3]="Tab",w[w.Enter=4]="Enter",w))(TextEditingAccept||{}),TextEditingStarting=(w=>(w[w.SingleClick=1]="SingleClick",w[w.SingleClickSelected=2]="SingleClickSelected",w[w.DoubleClick=3]="DoubleClick",w))(TextEditingStarting||{}),TextEditingState=(w=>(w[w.None=1]="None",w[w.Active=2]="Active",w[w.Editing=3]="Editing",w[w.Validating=4]="Validating",w[w.Invalid=5]="Invalid",w[w.Validated=6]="Validated",w))(TextEditingState||{});class TextEditingTool extends Tool{Le;PM;NM;Il;vt;CM;AM;LM;rx;lx;constructor(t){super(),this.name="TextEditing",this.Le=new TextBlock,this.PM=null,this.NM=2,this.Il=null,this.vt=1,this.CM=1,this.AM=!0,this.LM=null,this.rx=new HTMLInfo,this.lx=null,this.dF(this.rx),t&&Object.assign(this,t)}static LostFocus=1;static MouseDown=2;static Tab=3;static Enter=4;static SingleClick=1;static SingleClickSelected=2;static DoubleClick=3;static StateNone=1;static StateActive=2;static StateEditing=3;static StateValidating=4;static StateInvalid=5;static StateValidated=6;dF(t){if(!Diagram.isUsingDOM())return;const i=Util.ln("textarea");this.lx=i;const e=this;i.addEventListener("input",function(s){if(e.textBlock===null)return;const n=e.measureTemporaryTextBlock(this.value),o=this.textScale;this.style.width=20+Math.max(e.textBlock.measuredBounds.width,n.measuredBounds.width)*o+"px",this.rows=Math.max(e.textBlock.lineCount,n.lineCount)},!1),i.addEventListener("keydown",function(s){if(s.isComposing||e.textBlock===null)return;const n=s.key;if(n==="Enter"){e.textBlock.isMultiline===!1&&s.preventDefault(),e.acceptText(4);return}else if(n==="Tab"){e.acceptText(3),s.preventDefault();return}else n==="Escape"&&(e.doCancel(),e.diagram!==null&&e.diagram.doFocus())},!1),i.addEventListener("focus",function(s){e.gF(s)},!1),i.addEventListener("blur",function(s){e.mF(s)},!1),t.valueFunction=()=>i.value,t.mainElement=i,t.show=(s,n,o)=>{if(!(s instanceof TextBlock&&o instanceof TextEditingTool))return;if(o.state===5){i.style.border="3px solid red",i.focus();return}const r=s.getDocumentPoint(Spot.Center),l=n.position,h=n.scale;let a=s.getDocumentScale()*h;a{s.div.removeChild(i)}}get textBlock(){return this.PM}set textBlock(t){t!==null&&Util.s(t,TextBlock,TextEditingTool,"textBlock"),this.PM=t}get currentTextEditor(){return this.LM}set currentTextEditor(t){this.LM=t}get defaultTextEditor(){return this.rx}set defaultTextEditor(t){Debug&&!(t instanceof HTMLInfo)&&Util.n("TextEditingTool.defaultTextEditor must be an HTMLInfo."),this.rx=t}get starting(){return this.NM}set starting(t){Util.tt(t,TextEditingStarting,"TextEditingStarting"),this.NM=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t===null||t.isReadOnly||TextEditingTool.Df&&TextEditingTool.Df!==this&&(TextEditingTool.Df.acceptText(2),TextEditingTool.Df&&TextEditingTool.Df!==this)||!t.lastInput.left||this.isBeyondDragSize())return!1;const i=t.lastInput.documentPoint,e=t.findObjectAt(i);if(e===null||!(e instanceof TextBlock)||!e.editable||!e.part.canEdit())return!1;const s=e.part;return!(s===null||this.starting===2&&!s.isSelected||this.starting===3&&t.lastInput.clickCount<2)}doStart(){TextEditingTool.Df=this,this.textBlock!==null&&this.doActivate()}doActivate(){if(this.isActive)return;const t=this.diagram;if(t===null)return;let i=this.textBlock;if(i===null&&(i=t.findObjectAt(t.lastInput.documentPoint)),i===null||!(i instanceof TextBlock)||(this.textBlock=i,i.part===null))return;t.animationManager.stopAnimation(),this.isActive=!0,this.vt=2;let s=this.defaultTextEditor;i.textEditor!==null&&(s=i.textEditor),this.Le=this.textBlock.copy();const n=new Rect(this.textBlock.getDocumentPoint(Spot.TopLeft),this.textBlock.getDocumentPoint(Spot.BottomRight));t.scrollToRect(n),s.show(i,t,this),this.currentTextEditor=s}doCancel(){this.stopTool()}doMouseUp(){this.canStart()&&this.doActivate()}doMouseDown(){this.isActive&&this.acceptText(2)}acceptText(t){switch(t){case 2:this.vt===6?this.currentTextEditor instanceof HTMLElement&&this.currentTextEditor.focus():(this.vt===2||this.vt===5||this.vt===3)&&(this.vt=4,this.QC());break;case 1:case 4:case 3:if(t===4&&this.textBlock.isMultiline===!0)return;(this.vt===2||this.vt===5||this.vt===3)&&(this.vt=4,this.QC());break}}QC(){const t=this.textBlock,i=this.diagram,e=this.currentTextEditor;if(t!==null&&e!==null){const s=t.text;let n="";if(e.valueFunction!==null&&(n=e.valueFunction()),!this.isValidText(t,s,n)){this.vt=5,this.doError(s,n);return}this.startTransaction(this.name),this.vt=6,this.transactionResult=this.name,t.text=n,this.doSuccess(s,n),i!==null&&i.B("TextEdited",t,s),this.stopTransaction(),this.stopTool(),i!==null&&i.doFocus()}}doError(t,i){const e=this.textBlock;e.errorFunction!==null&&e.errorFunction(this,t,i);const s=this.currentTextEditor;s&&s.show(e,this.diagram,this)}doSuccess(t,i){const e=this.textBlock;e.textEdited!==null&&e.textEdited(e,t,i)}doDeactivate(){const t=this.diagram;t!==null&&(this.vt=1,this.currentTextEditor!==null&&this.currentTextEditor.hide(t,this),this.textBlock=null,this.isActive=!1)}doStop(){TextEditingTool.Df=null}gF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this.lx;this.vt===2&&(this.vt=3),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}mF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this.lx;typeof i.focus=="function"&&i.focus(),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}isValidText(t,i,e){Util.s(t,TextBlock,TextEditingTool,"isValidText:textblock");const s=this.textValidation;if(s!==null&&!s(t,i,e))return!1;const n=t.textValidation;return!(n!==null&&!n(t,i,e))}get textValidation(){return this.Il}set textValidation(t){t!==null&&Util.t(t,"function",TextEditingTool,"textValidation"),this.Il=t}get minimumEditorScale(){return this.CM}set minimumEditorScale(t){t!==null&&Util.t(t,"number",TextEditingTool,"minimumEditorScale"),this.CM=t}get selectsTextOnActivate(){return this.AM}set selectsTextOnActivate(t){t!==null&&Util.t(t,"boolean",TextEditingTool,"selectsTextOnActivate"),this.AM=t}get state(){return this.vt}set state(t){this.vt!==t&&(Util.tt(t,TextEditingState,"TextEditingState"),this.vt=t)}measureTemporaryTextBlock(t){const i=this.Le;return i.text=t,i.wt(this.textBlock.Ol,1/0),i}static Df=null}var AnimationStyle=(w=>(w[w.Default=1]="Default",w[w.AnimateLocations=2]="AnimateLocations",w[w.None=3]="None",w))(AnimationStyle||{});class AnimationManager{b;Ti;Xi;Cr;Zn;Io;TM;DM;Om;Si;Ff;yn;Em;vh;hx;Bm;ax;Rf;Nu;Vm;constructor(t){this.b=Diagram.Sm(),this.Ti=!1,this.Om=!1,this.Si=!1,this.Ff=!1,this.ax=!0,this.Rf=1,this.Nu=!1,this.Xi=!0,this.Cr=!0,this.Io=600,this.TM=!1,this.DM=!1,this.Zn=new GSet,this.yn=new Animation,this.Em=new Animation,this.yn.ws=this,this.vh=new GSet,this.hx=new GSet,this.Bm=new GSet,this.Vm=new GSet,t&&Object.assign(this,t)}Oo(t){this.b=t}hE(){return this.b}canStart(t){return!0}El(t){return!this.Xi||!this.canStart(t)?!1:(this.Zn.add(t),this.defaultAnimation.isAnimating&&this.stopAnimation(),this.b.Di(),this.Si=!0,!0)}getBundleAnimation(){return this.Em}FM(){if(!this.Xi||(this.Em.me.count>0&&this.Em.start(),!this.Si))return;const t=this.yn,i=this.b,e=this.Zn.has("Model");if(e&&(this.Ff=!0,this.Rf===1?(t.isViewportUnconstrained=!0,t.me.clear(),t.add(i,"position",i.position.copy().offset(0,-200),i.position),t.add(i,"opacity",0,1)):this.Rf===3&&t.me.clear(),this.Rf===2&&i.fx.equals(i.gt)?this.ax=!0:this.ax=!1,i.B("InitialAnimationStarting",this)),e&&!this.Cr||t.me.count===0){this.Zn.clear(),this.Si=!1,t.me.clear(),t.cx(i),this.Ff=!1,i.T();return}this.Zn.clear(),i.Ar=!1;const s=t.me.get(i);i.autoScale!==1&&s!==null&&(delete s.li.scale,delete s.xs.scale);const n=this;root.requestAnimationFrame(()=>{n.Si===!1||t.Ti||(i.getRenderingHint("temporaryPixelRatio")&&i.jw(),i.RM(),n.Si=!1,t.start(),t.Ti&&(n.Lu(),i.invalidateDocumentBounds(),t._C(0),i.Sr(!0),n.Tu(),i.B("AnimationStarting",n)))})}IM(){return this.Zn.has("Trigger")&&this.Zn.count===1}tA(t,i,e,s){this.isTicking||this.IM()||t instanceof Link&&(t.fromNode!==null||t.toNode!==null)||this.yn.add(t,"position",i,e,s)}ux(t){return this.yn.ux(t)}OM(t){return this.yn.OM(t)}pF(t){const i=this.vh,e=this;function s(){if(e.Bm.count>0&&(i.addAll(e.Bm),e.Bm.clear(),e.Ti=!0),e.Ti===!1||i.count===0)return;e.hx.addAll(i);const n=e.hx.iterator;for(;n.next();){const o=n.value;o.Ti!==!1&&(o.yF()?o.iA(!1):o.If=!0)}if(e.hx.clear(),e.Ti===!1){root.requestAnimationFrame(s);return}e.Lu(),e.b.Sr(),e.Tu(),root.requestAnimationFrame(s)}this.Ti?this.wF(t):(this.Ti=!0,i.add(t),root.requestAnimationFrame(()=>s()))}wF(t){this.Bm.add(t)}xF(){const t=this.vh.iterator;for(;t.next();)t.value.If=!1}Lu(){if(this.Om)return;const t=this.b;this.TM=t.skipsUndoManager,this.DM=t.pe,t.skipsUndoManager=!0,t.pe=!0,this.Om=!0}Tu(){const t=this.b;t.skipsUndoManager=this.TM,t.pe=this.DM,this.Om=!1}stopAnimation(t){const i=this.yn;if(this.Si===!0&&(this.Si=!1,this.Ff=!1,this.Zn.clear(),i.bF()&&this.b.requestUpdate()),!this.Ti){i.me.clear(),i.cx(this.b);return}if(i.Du(!0),i.cx(null),t===!0){const e=this.vh.toArray();for(let s=0;s{!i.isAnimating&&i.runCount===1/0&&i.start()})}get duration(){return this.Io}set duration(t){Util.t(t,"number",AnimationManager,"duration"),t<1&&Util.G(t,">= 1",AnimationManager,"duration"),this.Io=t}get isAnimating(){return this.Ti}get isTicking(){return this.Om}get isInitial(){return this.Cr}set isInitial(t){Util.t(t,"boolean",AnimationManager,"isInitial"),this.Cr=t}get defaultAnimation(){return this.yn}get activeAnimations(){return this.vh}get initialAnimationStyle(){return this.Rf}set initialAnimationStyle(t){Debug&&Util.tt(t,AnimationStyle,"AnimationStyle"),this.Rf=t}static gx=new GMap;static defineAnimationEffect(t,i){AnimationManager.gx.set(t,i)}static VM(t,i,e,s,n){t===null&&(t=[0,0,0,0]),i===null&&(i=[0,0,0,0]);let o=t[0],r=t[1];const l=t[2],h=t[3];let a=i[0],f=i[1];const c=i[2],u=i[3];l===0||l===100?(o=a,r=f):(c===0||c===100)&&(a=o,f=r),Math.abs(a-o)>180&&(a>o?o+=360:a+=360);const d=n(e,o,a-o,s)%360,m=n(e,r,f-r,s),g=n(e,l,c-l,s),p=n(e,h,u-h,s);return"hsla("+d+", "+m+"%, "+g+"%, "+p+")"}static{const t=AnimationManager.gx,i=(e,s,n,o,r,l)=>{e.position=new Point(o(r,s.x,n.x-s.x,l),o(r,s.y,n.y-s.y,l))};t.set("position:diagram",i),t.set("position",i),t.set("position:part",(e,s,n,o,r,l)=>{r{r{r{const h=e.actualBounds,a=n.actualBounds,f=a.x+a.width/2-h.width/2,c=a.y+a.height/2-h.height/2;r{e.desiredSize=new Size(o(r,s.width,n.width-s.width,l),o(r,s.height,n.height-s.height,l))}),t.set("width",(e,s,n,o,r,l)=>{e.width=o(r,s,n-s,l)}),t.set("height",(e,s,n,o,r,l)=>{e.height=o(r,s,n-s,l)}),t.set("fill",(e,s,n,o,r,l)=>{e.fill=AnimationManager.VM(s,n,r,l,o)}),t.set("stroke",(e,s,n,o,r,l)=>{e.stroke=AnimationManager.VM(s,n,r,l,o)}),t.set("strokeWidth",(e,s,n,o,r,l)=>{e.strokeWidth=o(r,s,n-s,l)}),t.set("strokeDashOffset",(e,s,n,o,r,l)=>{e.strokeDashOffset=o(r,s,n-s,l)}),t.set("background",(e,s,n,o,r,l)=>{e.background=AnimationManager.VM(s,n,r,l,o)}),t.set("opacity",(e,s,n,o,r,l)=>{e.opacity=o(r,s,n-s,l)}),t.set("scale",(e,s,n,o,r,l)=>{e.scale=o(r,s,n-s,l)}),t.set("angle",(e,s,n,o,r,l)=>{e.angle=o(r,s,n-s,l)})}static Default=1;static AnimateLocations=2;static None=3}class Animation{mx;zm;Ti;Fu;Io;bs;oA;Bf;me;px;li;$n;Ru;Vf;yx;wx;If;zM;xx;ws;b;XM;YM;KM;constructor(t){this.b=null,this.ws=null,this.zM=null,this.xx=null,this.XM=!1,this.Ti=!1,this.If=!1,this.li=0,this.$n=0,this.mx=Animation.EaseInOutQuad,this.zm=Animation.EaseInOutQuad,this.Ru=!1,this.Vf=!1,this.yx=1,this.wx=0,this.Io=NaN,this.bs=NaN,this.YM=0,this.Fu=null,this.oA=Point.Lo,this.me=new GMap,this.px=new GMap,this.Bf=new GSet,this.KM=1,t&&Object.assign(this,t)}suspend(){this.If=!0}advanceTo(t,i){i&&(this.If=!1),this.Ru&&t>=this.bs&&(this.Vf=!0,t=t-this.bs),this.YM=t,this.iA(!0),this.ws.Lu(),this.b.Sr(),this.ws.Tu(),this.b.redraw()}cx(t){if(this.px.clear(),this.Vf=!1,this.wx=0,this.bs=NaN,this.Bf.count>0&&this.Bf.clear(),t!==null){const i=t.links;for(;i.next();)i.value.Lr=null}}bF(){return this.me.count>0}start(){if(this.me.count===0)return this;if(this.Ti)return this;let t=this.b;const i=this.me.iterator;for(;i.next();){const s=i.key;t===null&&(s instanceof Diagram?t=s:s instanceof GraphObject&&(t=s.diagram))}if(t!==null)this.b=t,this.ws=t.animationManager;else return this;const e=this.ws;return e.isEnabled===!1?this:(this.bs=isNaN(this.Io)?e.duration:this.Io,this.zm=this.mx,e.Ff&&e.Rf===1&&this===e.defaultAnimation&&(this.zm=Animation.EaseOutExpo,this.bs=isNaN(this.Io)?e.duration===600?900:e.duration:this.Io),this.KM=t.scrollMode,this.isViewportUnconstrained&&(t.Jh=2),e.Lu(),this.Bf.each(s=>{s.data=null,t.add(s)}),e.Tu(),this.Ti=!0,this.li=+new Date,this.$n=this.li+this.bs,e.pF(this),this)}addTemporaryPart(t,i){return t.Ae()?(Debug&&(i===void 0&&Util.n("addTemporaryPart: Required Diagram argument missing"),t.diagram===i&&Util.n("addTemporaryPart: Part already in Diagram, did you mean to pass in a copy?"),this.b!==null&&this.b!==i&&Util.n("addTemporaryPart: A different Diagram is already associated with this Animation: "+this.b.toString())),this.Bf.add(t),this.b=i,this):this}add(t,i,e,s,n){if(this.b===null&&(t instanceof Diagram?this.b=t:t instanceof GraphObject&&t.diagram!==null&&(this.b=t.diagram)),t instanceof Part){if(!t.isAnimated)return this;i==="position"&&(i="position:part")}return this.EM(t,i,e,s,n),this}EM(t,i,e,s,n){const o=this.me;let r,l,h;if(t instanceof Diagram&&i==="position"&&(i="position:diagram"),(i==="fill"||i==="stroke"||i==="background")&&(Brush.Eo(e),Brush.UM(),e=[Brush.Yi.n0,Brush.Yi.n1,Brush.Yi.n2,Brush.Yi.n3],Brush.Eo(s),Brush.UM(),s=[Brush.Yi.n0,Brush.Yi.n1,Brush.Yi.n2,Brush.Yi.n3]),o.has(t))r=o.get(t),l=r.li,h=r.xs,l[i]===void 0&&(l[i]=this.Iu(e)),h[i]=this.Iu(s);else{if(i==="position"&&e.equalsApprox(s))return;l={},h={},l[i]=this.Iu(e),h[i]=this.Iu(s),r=new AnimationState(l,h,n),o.set(t,r)}const a=l[i];a instanceof Point&&!a.isReal()&&a.c(this.oA),n&&i.indexOf("position:")===0&&t instanceof Part?r.bx.location=this.Iu(t.location):n&&(r.bx[i]=this.Iu(e))}Iu(t){return t instanceof Point||t instanceof Size?t.copy():t}kF(t){const i=this.me;if(i.has(t)){const e=i.get(t);e.kx=!0}}ux(t){if(!this.Ti)return!1;const i=this.me.get(t);return i!==null&&i.kx}OM(t){if(!this.Ti)return!1;const i=this.me.get(t);return i!==null&&!!(i.li.position||i.li["position:part"]||i.li.location)}yF(){if(this.Bf.count>0)return!0;const t=this.me.iterator;for(;t.next();){const i=t.key;if(i instanceof GraphObject&&i.diagram!==null||i instanceof Diagram)return!0}return!1}iA(t){if(this.If&&!t)return;const i=this.ws;if(this.Ti===!1)return;const e=+new Date;let s=e>this.$n?this.bs:e-this.li;t&&(s=this.YM,sthis.$n&&(this.Ru&&!this.Vf?(this.li=+new Date,this.$n=this.li+this.bs,this.Vf=!0):this.Du(!1))}_C(t){const i=this.bs,e=this.me.iterator,s=this.Vf;for(;e.next();){const n=e.key;if(n instanceof GraphObject&&n.diagram===null)continue;const o=e.value,r=s?o.xs:o.li,l=s?o.li:o.xs,h=AnimationManager.gx;for(const a in l)a==="position"&&(l["position:placeholder"]||l["position:nodeCollapse"])||h.get(a)!==null&&h.get(a)(n,r[a],l[a],this.zm,t,i,this)}}stop(){return this.Ti?(this.Du(!0),this):this}Du(t){if(this.xx!==null&&this.xx.SF(this.zM),!this.Ti)return;const i=this.b,e=this.ws;e.Ff=!1,this.Ti=!1,this.If=!1,e.Lu();const s=this.me,n=this.Bf.iterator;for(;n.next();)i.remove(n.value);const o=this.Ru,r=s.iterator,l=AnimationManager.gx;for(;r.next();){const a=r.key,f=r.value,c=o?f.xs:f.li,u=o?f.li:f.xs,d=f.bx;for(const m in u)if(l.get(m)!==null){let g=m;f.Sx&&(g==="position:nodeCollapse"||g==="position:placeholder")&&(g="position"),l.get(g)(a,c[m],d[m]!==void 0?d[m]:f.Sx?c[m]:u[m],this.zm,this.bs,this.bs,this)}f.Sx&&d.location!==void 0&&a instanceof Part&&(a.location=d.location),f.kx&&a instanceof Part&&a.Ki(!1)}this.wx++;const h=!t&&this.yx>this.wx;if(!h&&(this===e.Em||this===e.defaultAnimation)&&this.me.clear(),i.Mx.clear(),i.NS(!1),i.invalidateDocumentBounds(),i.T(),i.Sr(!0),e.defaultAnimation===this){const a=e.Vm.iterator;for(;a.next();)a.value.MF();e.Vm.clear()}if(i.Sr(!0),this.isViewportUnconstrained&&(i.scrollMode=this.KM),e.Tu(),h){this.Vf=!1,this.start();return}this.cx(null),i.rA(),e.Du(this),this.Fu&&this.Fu(this),i.requestUpdate()}Of(t,i){const e=i.actualBounds;let s=null;if(i instanceof Group&&(s=i.placeholder),s!==null&&s.visible){const n=s.getDocumentPoint(Spot.TopLeft),o=s.padding;n.x+=o.left,n.y+=o.top,this.add(t,"position",n,t.position,!1)}else this.add(t,"position",new Point(e.x+e.width/2,e.y+e.height/2),t.position,!1);this.add(t,"scale",.01,t.scale,!1),t instanceof Group&&this.PF(t,i)}PF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Of(s,i)}}Ef(t,i){if(!t.isVisible())return;let e=null;if(i instanceof Group&&(e=i.placeholder),e!==null&&e.visible){const s=e.getDocumentPoint(Spot.TopLeft),n=e.padding;s.x+=n.left,s.y+=n.top,this.add(t,"position:placeholder",t.position,s,!0)}else this.add(t,"position:nodeCollapse",t.position,i,!0);this.add(t,"scale",t.scale,.01,!0),this.kF(t),t instanceof Group&&this.NF(t,i)}NF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Ef(s,i)}}get duration(){return this.Io}set duration(t){Util.t(t,"number",Animation,"duration"),t<1&&Util.G(t,">= 1",Animation,"duration"),this.Io=t}get reversible(){return this.Ru}set reversible(t){this.Ru=t}get runCount(){return this.yx}set runCount(t){t>0?this.yx=t:Util.n("Animation.runCount value must be a positive integer.")}get finished(){return this.Fu}set finished(t){this.Fu!==t&&(t!==null&&Util.t(t,"function",Animation,"finished"),this.Fu=t)}get easing(){return this.mx}set easing(t){this.mx=t}get isViewportUnconstrained(){return this.XM}set isViewportUnconstrained(t){this.XM=t}get isAnimating(){return this.Ti}getTemporaryState(t){let i=this.px.get(t);return i===null&&(i={},this.px.set(t,i)),i}static EaseLinear=(t,i,e,s)=>e*t/s+i;static EaseInOutQuad=(t,i,e,s)=>(t/=s/2,t<1?e/2*t*t+i:-e/2*(--t*(t-2)-1)+i);static EaseInQuad=(t,i,e,s)=>e*(t/=s)*t+i;static EaseOutQuad=(t,i,e,s)=>-e*(t/=s)*(t-2)+i;static EaseInExpo=(t,i,e,s)=>t===0?i:e*Math.pow(2,10*(t/s-1))+i;static EaseOutExpo=(t,i,e,s)=>t===s?i+e:e*(-Math.pow(2,-10*t/s)+1)+i}class AnimationState{li;xs;bx;Sx;kx;constructor(t,i,e){this.li=t,this.xs=i,this.bx={},this.Sx=e,this.kx=!1}}var TriggerStart=(w=>(w[w.Default=1]="Default",w[w.Immediate=2]="Immediate",w[w.Bundled=3]="Bundled",w))(TriggerStart||{});class AnimationTrigger{Ce;gn;Ou;zf;constructor(t,i,e){e&&Debug&&Util.tt(e,TriggerStart,"TriggerStart"),this.Ce=null,this.gn=t,this.Ou=e||1,this.zf=null,i!==void 0&&(this.zf=i,e===void 0&&(this.Ou=2))}copy(){const t=new AnimationTrigger(this.gn);t.Ou=this.Ou;const i=this.zf;if(i!==null){const e={};i.duration!==void 0&&(e.duration=i.duration),i.finished!==void 0&&(e.finished=i.finished),i.easing!==void 0&&(e.easing=i.easing),t.zf=e}return t}get propertyName(){return this.gn}set propertyName(t){this.gn=t}get animationSettings(){return this.zf}set animationSettings(t){this.zf=t}CF(t){const i=this.zf;i!==null&&(i.duration&&(t.duration=i.duration),i.finished&&(t.finished=i.finished),i.easing&&(t.easing=i.easing))}get startCondition(){return this.Ou}set startCondition(t){Debug&&Util.tt(t,TriggerStart,"TriggerStart"),this.Ou=t}static Default=1;static Immediate=2;static Bundled=3}class Layer{b;Tt;_t;Tr;Bl;Vl;zl;Xl;Yl;Kl;Ul;Gl;Hl;ql;jl;Wl;Tf;vl;Px;Xm;Eu;It;constructor(t){GSet.vi(this),this.b=null,this.It=new List,this.Tt="",this._t=1,this.Tr=!1,this.Bl=!0,this.Vl=!0,this.zl=!0,this.Xl=!0,this.Yl=!0,this.Kl=!0,this.Ul=!0,this.Gl=!0,this.Hl=!0,this.ql=!0,this.jl=!0,this.Wl=!0,this.Tf=!0,this.vl=!0,this.Px=!0,this.Xm=!1,this.Eu=[],t&&Object.assign(this,t)}AF(){const t=this.It;for(let i=0;i0&&(h+=e+" Parts "),s>0&&(h+=s+" Nodes "),n>0&&(h+=n+" Groups "),o>0&&(h+=o+" Links "),r>0&&(h+=r+" Adornments "),t>1){const a=this.It.iterator;for(;a.next();){const f=a.value;h+=` + `+f.toString();const c=f.data;c!==null&&GSet.gs(c)&&(h+=" #"+GSet.gs(c)),f instanceof Node?h+=" "+Util.toString(c):f instanceof Link&&(h+=" "+Util.toString(f.fromNode)+" "+Util.toString(f.toNode))}}return i+" "+this.It.count+": "+h}findObjectAt(t,i,e){if(i===void 0&&(i=null),e===void 0&&(e=null),this.vl===!1)return null;Debug&&!t.isReal()&&Util.n("findObjectAt: Point must have a real value, not: "+t.toString());let s=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(s=!0);const n=Point.a(),o=this.It.h,r=o.length;for(let l=r;l--;){const h=o[l];if(s===!0&&h.Tl()===!1||!h.isVisible())continue;n.c(t),n.Ye(h.Ks);let a=h.lA(n,i,e);if(a!==null&&(i!==null&&(a=i(a)),a!==null&&(e===null||e(a))))return Point.o(n),a}return Point.o(n),null}findObjectsAt(t,i,e,s){if(i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.vl===!1)return s;Debug&&!t.isReal()&&Util.n("findObjectsAt: Point must have a real value, not: "+t.toString());let n=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(n=!0);const o=Point.a(),r=this.It.h,l=r.length;for(let h=l;h--;){const a=r[h];if(n===!0&&a.Tl()===!1||!a.isVisible())continue;o.c(t),o.Ye(a.Ks);let f=a;a.hA(o,i,e,s)&&(i!==null&&(f=i(f)),f!==null&&(e===null||e(f))&&s.add(f))}return Point.o(o),s}findObjectsIn(t,i,e,s,n){if(i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.vl===!1)return n;Debug&&!t.isReal()&&Util.n("findObjectsIn: Rect must have a real value, not: "+t.toString());let o=!1;this.diagram!==null&&this.diagram.viewportBounds.containsRect(t)&&(o=!0);const r=this.It.h,l=r.length;for(let h=l;h--;){const a=r[h];if(o===!0&&a.Tl()===!1||!a.isVisible())continue;let f=a;a.Ym(t,i,e,s,n)&&(i!==null&&(f=i(f)),f!==null&&(e===null||e(f))&&n.add(f))}return n}IS(t,i,e,s,n,o,r){if(this.vl===!1)return n;const l=this.It.h,h=l.length;for(let a=h;a--;){const f=l[a];if(r===!0&&f.Tl()===!1||!o(f)||!f.isVisible())continue;let c=f;f.Ym(t,i,e,s,n)&&(i!==null&&(c=i(c)),c!==null&&(e===null||e(c))&&n.add(c))}return n}findObjectsNear(t,i,e,s,n,o){if(e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.vl===!1)return o;Debug&&!t.isReal()&&Util.n("findObjectsNear: Point must have a real value, not: "+t.toString());let r=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(r=!0);const l=Point.a(),h=Point.a(),a=this.It.h,f=a.length;for(let c=f;c--;){const u=a[c];if(r===!0&&u.Tl()===!1||!u.isVisible())continue;l.c(t),l.Ye(u.Ks),h.e(t.x+i,t.y),h.Ye(u.Ks);let d=u;u.aA(l,h,e,s,n,o)&&(e!==null&&(d=e(d)),d!==null&&(s===null||s(d))&&o.add(d))}return Point.o(l),Point.o(h),o}HM(){return this.It.h}Us(t,i){if(!this.visible)return;const e=this.It.h,s=e.length;if(s===0)return;const n=Util.at(),o=Util.at();for(let r=0;r0&&o.push(l))}for(let r=0;re.Um||a.height*n>e.Um?i.Ji(t,e):this.FF(t,i),f&&(t.restore(),t.clearContextCache(!0))}FF(t,i){const e=i.actualBounds,s=i.naturalBounds;if(e.width===0||e.height===0||isNaN(e.x)||isNaN(e.y)||!i.isVisible())return;const n=i.O;if(i.background===null){i.wn(t,"rgba(0,0,0,0.3)",!0,!1,s,e),t.fillRect(e.x,e.y,e.width,e.height);return}if(t.transform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),i.wn(t,i.background,!0,!1,s,e),t.fillRect(0,0,s.width/2,s.height/2),!n.Gk()){const o=1/(n.m11*n.m22-n.m12*n.m21);t.transform(n.m22*o,-n.m12*o,-n.m21*o,n.m11*o,o*(n.m21*n.dy-n.m22*n.dx),o*(n.m12*n.dx-n.m11*n.dy))}}DF(t,i,e,s){const n=2/s,o=4/s;for(let r=0;r=s.count)t=s.count;else if(s.elt(t)===i)return-1;s.insertAt(t,i),i.Gm(e);const n=this.diagram;return n!==null&&(e?n.T():n.$h(i)),this.Nx(t,i),t}oe(t,i,e){if(!e&&i.layer!==this&&i.layer!==null)return i.layer.oe(t,i,e);const s=this.It;if(t<0||t>=s.length){if(t=s.indexOf(i),t<0)return-1}else if(s.elt(t)!==i&&(t=s.indexOf(i),t<0))return-1;i.Hm(e),s.removeAt(t);const n=this.diagram;return n!==null&&(e?n.T():n.oe(i)),i.GM(null),t}Nx(t,i){t=this.RF(t,i),i instanceof Group&&this.IF(t,i),i.svg!==null&&i.svg.remove()}RF(t,i){const e=i.zOrder;if(isNaN(e))return t;const s=this.It,n=s.count;if(n<=1)return t;if(t<0&&(t=s.indexOf(i)),t<0)return-1;let o=t-1,r=NaN;for(;o>=0&&(r=s.elt(o).zOrder,!!isNaN(r));)o--;let l=t+1,h=NaN;for(;le)for(;;){if(o===-1||r<=e)return o++,o===t?t:(s.removeAt(t),s.insertAt(o,i),o);for(r=NaN;--o>=0&&(r=s.elt(o).zOrder,!!isNaN(r)););}else if(!isNaN(h)&&h=e)return l--,l===t?t:(s.removeAt(t),s.insertAt(l,i),l);for(h=NaN;++l=0)||e<0&&r.containingGroup===i&&(e=o,t>=0))break}if(!(e<0)&&e1)&&Util.G(t,"0 <= value <= 1",Layer,"opacity"),this._t=t;const e=this.diagram;e!==null&&e.T(),this.i("opacity",i,t)}}get isViewportAligned(){return this.Xm}set isViewportAligned(t){const i=this.Xm;i!==t&&(this.Xm=t,this.diagram&&(this.cA(),this.diagram.T()),this.i("isViewportAligned",i,t),t&&(this.isInDocumentBounds=!1))}cA(){if(!this.Xm)return;const t=this.diagram,i=this.It.h,e=i.length,s=t.Ct,n=t.At;for(let o=0;o(w[w.None=1]="None",w[w.Uniform=2]="Uniform",w[w.UniformToFill=3]="UniformToFill",w))(AutoScale||{}),CycleMode=(w=>(w[w.All=1]="All",w[w.NotDirected=2]="NotDirected",w[w.NotDirectedFast=3]="NotDirectedFast",w[w.NotUndirected=4]="NotUndirected",w[w.DestinationTree=5]="DestinationTree",w[w.SourceTree=6]="SourceTree",w))(CycleMode||{}),ScrollMode=(w=>(w[w.Document=1]="Document",w[w.Infinite=2]="Infinite",w))(ScrollMode||{}),CollapsePolicy=(w=>(w[w.TreeParent=1]="TreeParent",w[w.AllParents=2]="AllParents",w[w.AnyParents=3]="AnyParents",w))(CollapsePolicy||{});class Diagram{ws;yi;WM;Cx;Dr;zu;Ax;Lx;Tx;Dx;Fx;Rx;Xf;Jh;Ix;Ox;Ex;Jl;Yf;Fr;qm;Bx;Vx;Xu;Qn;Rr;Qh;Bo;jm;Kf;Wm;Uf;Yu;Ir;_n;vM;JM;zx;Xx;ZM;Yx;$M;QM;_M;Kx;vm;Or;Er;Br;Vr;zr;Xr;Ux;Yr;Gx;Kr;Ur;Gr;Hr;Hx;tP;Vo;iP;qx;jx;eP;Ai;sP;nP;oP;zs;zo;Xi;Wx;Bl;Vl;vx;Jx;zl;Xl;Yl;Zx;Kl;Ul;Gl;Hl;ql;jl;Wl;$x;Qx;rP;Ku;Uu;_x;t1;i1;e1;Jm;s1;o1;l1;ii;lP;h1;hP;Gu;xn;to;re;io;uA;Zl;aP;fP;Zm;a1;Hu;$m;f1;qr;$l;_h;cP;uP;Qm;c1;u1;os;_m;t0;qu;Ql;Gf;i0;jr;ta;dP;e0;$t;O;Ge;Ar;Ui;ks;gP;_l;Wr;Pl;vr;ia;Hf;mP;ju;ea;Wu;Jt;th;gt;rt;vu;Ct;At;xt;qf;qw;d1;sa;jf;g1;m1;p1;BF;VF;Gi;Cl;Um;s0;pP;yP;dA;o0;zF;XF;YF;w1;KF;UF;GF;na;gA;ih;oa;ra;la;ha;Pu;Wh;ei;Ot;Wf;eS;sS;xf;_t;static b1=null;static mA=new GMap;static wP;static xP=null;Mu;k1;S1;M1;P1;N1;r0;bP;l0;h0;a0;fx;kP;C1;vf;constructor(t,i){if(Diagram.ww||(Diagram.Hk(),Diagram.ww=!0),GSet.vi(this),Diagram.pA(this),this.$t=!0,this.Ot=null,this.Ct=0,this.At=0,this.xt=null,Diagram.isUsingDOM()){const s=this,n=()=>{s.Li(root.document,"DOMContentLoaded",n,!1),s.setRTL()};root.document.body!==null?this.setRTL():s.Ht(root.document,"DOMContentLoaded",n,!1)}this.qf=null,Diagram.SP("Model",PartManager);const e=this;return this.sP=s=>e.partManager.doModelDataChanged(s),this.nP=s=>e.partManager.doModelChanged(s),this.g1=null,this.m1=null,this.yA(),this.model=Model.initDiagramModel(),this.C1=null,this.themeManager=new ThemeManager,this.Vo=!0,this.wA(),this.layout=new Layout,this.Vo=!1,this.zF=null,this.XF=null,this.YF=null,this.w1=null,this.KF=null,this.UF=null,this.GF=null,this.na=null,this.gA=null,this.ih=null,this.oa=null,this.ra=null,this.la=null,this.ha=null,this.Pu=()=>{},this.Wh=null,this.qu=!1,this.Wf=new DiagramHelper(this),t!==void 0&&(typeof t=="string"||root.Element&&t instanceof Element?this.MP(t):i=t),i&&this.setProperties(i),this.$t=!1,this.requestUpdate(),this}tF(){return this.xt!==null}get renderer(){return this.Gf}set renderer(t){if(this instanceof Overview)return;t===""&&(t="default");const i=t.toLowerCase(),e=this.Gf;if(i===e)return;this.Gf=i;let s=null;i==="default"||i==="canvas"?(s=this.Ql.get("svg"),s!==null&&s.Vt.remove(),this.xt&&(this.ei=this.xt.di),this.ei.clearContextCache(!0)):i==="svg"?(this.Ql.has("svg")?s=this.Ql.get("svg"):(s=new SVGSurface(this,root.document),this.addRenderer("svg",s)),this.div!==null&&this.div.appendChild(s.Vt),this.ei=s.di,this.xt&&(this.xt.di.setTransform(this.Gi,0,0,this.Gi,0,0),this.xt.di.clearRect(0,0,this.Ct,this.At))):i==="debug"&&(this.Ql.has("SVG")||(s=new SVGSurface(this,root.document),this.addRenderer("SVG",s),s.Vt.style.backgroundColor="whitesmoke",this.div!==null&&this.div.after(s.Vt))),this.$t||this.redraw()}yA(){this.vf=new List,this.setupRouters(),this.ws=new AnimationManager,this.ws.Oo(this),this.yi=17,this.WM=!1,this.vu=!1,this.Cx="default",this.Jt=new List,this.Ql=new GMap,this.Gf="default",this.resetRenderingHints(),this.HF(),this._t=1,this.gt=new Point(NaN,NaN).w(),this.fx=new Point(NaN,NaN),this.rt=1,this.e0=1,this.Ax=new Point(NaN,NaN).w(),this.Lx=NaN,this.Tx=1e-4,this.Dx=100,this.O=new Transform,this.Fx=new Point(NaN,NaN).w(),this.Rx=new Rect(NaN,NaN,NaN,NaN).w(),this.Xf=new Margin(0,0,0,0).w(),this.Jh=1,this.Ix=!1,this.Ox=null,this.Ex=null,this.Jl=1,this.Yf=Spot.Default,this.Fr=1,this.qm=Spot.Default,this.Bx=Spot.None,this.Vx=Spot.None,this.Ge=!0,this.Xu=!1,this.Qn=new Set,this.Rr=new GSet,this.Qh=new GSet,this.Bo=!1,this.th=new GMap,this.ju=!0,this.jm=250,this.Kf=-1,this.Wm=new Margin(16,16,16,16).w(),this.Ar=!1,this.Uf=!1,this.Yu=!0,this.i0=new InputEvent,this.i0.diagram=this,this.jr=new InputEvent,this.jr.diagram=this,this.ta=new InputEvent,this.ta.diagram=this,this.Ir=null,this._n=null,this.qw=!1,this.qF(),this.vr=new GSet,this.zx=!0,this.Xx=1,this.ZM=!1,this.Yx=1,this.Kx="auto",this.vm="auto",this.Or=null,this.Er=null,this.Br=null,this.Vr=null,this.zr=null,this.Xr=null,this.Ux=null,this.Yr=null,this.Gx=!1,this.Kr=null,this.Ur=null,this.Gr=null,this.Hr=null,this.Hx=!1,this.d1={},this.sa=[null,null],this.Vo=!1,this.iP=!1,this.qx=!1,this.jx=!1,this.eP=!0,this.ks=!1,this.ea=!1,this.oP=!0,this.zs=-2,this._l=new GMap,this.Wu=new List,this.zo=!1,this.Xi=!0,this.Wx=!0,this.Bl=!0,this.Vl=!0,this.vx=!1,this.Jx=!0,this.zl=!0,this.Xl=!0,this.Yl=!0,this.Zx=!0,this.Kl=!0,this.Ul=!0,this.Gl=!0,this.Hl=!0,this.ql=!0,this.jl=!0,this.Wl=!0,this.$x=!0,this.Qx=!0,this.rP=!1,this.jf=!1,this.Ku=!0,this.Uu=!0,this._x=!0,this.t1=!0,this.i1=16,this.e1=16,this.Jm=!1,this.s1=!1,this.o1=0,this.l1=0,this.ii=new Margin(5).w(),this.lP=new GSet().w(),this.h1=999999999,this.hP=new GSet().w(),this.ia=!0,this.Gu=!0,this.Hf=!0,this.xn=!1,this.to=!1,this.Wr=!0,this.Pl=!1,this.io=!1,this.uA=new GSet,this.mP=new GSet,this.Zl=null,this.aP=new Size(8,8),this.fP=999,this.Zm=!1,this.eS=1,this.sS=0,this.Ui={scale:1,position:new Point,bounds:new Rect,canvasSize:new Size,newCanvasSize:new Size,isScroll:!1},this.Ui.canvasSize=this.Ui.canvasSize,this.Ui.newCanvasSize=this.Ui.newCanvasSize,this.Ui.isScroll=!1,this.a1=new Rect(NaN,NaN,NaN,NaN).w(),this.Hu=new Size(NaN,NaN).w(),this.$m=new Rect(NaN,NaN,NaN,NaN).w(),this.f1=!1,this.jF(),this.os=null,this._m=!1,this.xf=null,this.partManager=new PartManager,this.toolManager=new ToolManager,this.toolManager.initializeStandardTools(),this.defaultTool=this.toolManager,this.currentTool=this.defaultTool,this.S1=null,this.M1=new DraggingOptions,this.P1=null,this.N1=null,this.k1=!1,this.Mu=!1,this.commandHandler=new CommandHandler,this.h0=null,this.a0=Point.Bk,this.kP=!1,this.Gi=1,this.Cl=null,this.Um=1,this.r0=0,this.bP=[0,0,0,0,0],this.l0=0,this.s0=1,this.pP=0,this.yP=new Point,this.dA=500,this.t0=new Point,this.o0=!1}static xA=root.document!==void 0;static isUsingDOM(){return Diagram.xA}static useDOM(t){Diagram.xA=t?root.document!==void 0:!1}static He=new WeakMap;clear(){this.animationManager.stopAnimation(),this.model.clear(),Diagram.bA(),this.kA(!1),this.Wu.clear(),this.SA(),this.Zl=null,this.invalidateDocumentBounds(),this.ensureBounds(),this.T()}kA(t){this.animationManager.stopAnimation(!0),this.lP=new GSet().w(),this.hP=new GSet().w();const i=this.skipsUndoManager,e=this.Ai!==null&&this.Ai!==void 0;e&&(this.skipsUndoManager=!0);let s=null;this.os!==null&&(s=this.os.part,s!==null&&this.remove(s));const n=[],o=this.Jt.length;if(t){for(let r=0;rt?new Margin(t/2):1.5)),this.c1=this.Qm,this.u1=new Adornment(Panel.Link).add(new Shape({isPanelMain:!0,fill:null,stroke:"dodgerblue",strokeWidth:3}).theme("stroke","selection").theme("strokeWidth","selection"))}setRTL(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);const e=Util.ln("div");e.dir="rtl",e.style.cssText="font-size: 14px; width: 1px; height: 1px; position: absolute; top: -1000px; overflow: scroll;",e.textContent="A",i.appendChild(e);let s="reverse";e.scrollLeft>0?s="default":(e.scrollLeft=1,e.scrollLeft===0&&(s="negative")),i.removeChild(e),this.Cx=s}setScrollWidth(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);let e=0;if(Diagram.isUsingDOM()){let s=Diagram.xP,n=Diagram.wP;s===null&&(Diagram.xP=Util.ln("p"),s=Diagram.xP,s.style.width="100%",s.style.height="200px",s.style.boxSizing="content-box",Diagram.wP=Util.ln("div"),n=Diagram.wP,n.style.position="absolute",n.style.visibility="hidden",n.style.width="200px",n.style.height="150px",n.style.boxSizing="content-box",n.appendChild(s)),n.style.overflow="hidden",i.appendChild(n);const o=s.offsetWidth;n.style.overflow="scroll";let r=s.offsetWidth;o===r&&(r=n.clientWidth),i.removeChild(n),e=o-r,e===0&&!Util.cr&&(e=11)}this.yi=e,this.WM=!0}fi(t){t in AutoScale?this.autoScale=t:Util.ur(this,t)}toString(t){t===void 0&&(t=0);let i="";this.div&&this.div.id&&(i=this.div.id);let e='Diagram "'+i+'"';if(t<=0)return e;const s=this.Jt.iterator;for(;s.next();){const n=s.value;e+=` + `+n.toString(t-1)}return e}static pA(t){Diagram.b1=t}static Sm(){return Diagram.b1}static fromDiv(t){let i=t;if(typeof t=="string"&&(i=root.document.getElementById(t)),i instanceof HTMLDivElement){const e=Diagram.He.get(i);if(e)return e}return null}get div(){return this.Ot}set div(t){if(t!==null&&Util.s(t,HTMLDivElement,Diagram,"div"),this.Ot!==t){const i=this.Ot;if(i!==null){if(Diagram.He.delete(i),i.goDiagram=void 0,i.go=void 0,i.innerHTML="",this.xt!==null){const s=this.xt.Vt;this.Li(s,"pointermove",this.oa,!1),this.Li(s,"pointerdown",this.ih,!1),this.Li(s,"pointerup",this.ra,!1),this.Li(s,"pointerout",this.la,!1),this.Li(s,"pointercancel",this.ha,!1),this.xt.dispose()}this.qf&&(this.qf.disconnect(),this.qf=null);const e=this.toolManager;e!==null&&(e.mouseDownTools.each(s=>s.cancelWaitAfter()),e.mouseMoveTools.each(s=>s.cancelWaitAfter()),e.mouseUpTools.each(s=>s.cancelWaitAfter())),e.cancelWaitAfter(),this.currentTool.doCancel(),this.xt=null,this.Li(root,"resize",this.w1,!1),this.Li(root,"wheel",this.na,!0),Diagram.Sm()===this&&Diagram.pA(null)}else this.ih===null&&(this.io=!1);if(this.Ot=null,t!==null){const e=Diagram.He.get(t);e&&(e.div=null),this.MP(t),this.Pu(),this.themeManager&&this.themeManager.WF()}else this.themeManager&&this.themeManager.vF()}}setupRouters(){this.vf.push(new AvoidsNodesRouter)}MP(t){const i=this;if(!Diagram.isUsingDOM())return;t==null&&Util.n("Diagram setup requires an argument DIV."),i.Ot!==null&&Util.n("Diagram has already completed setup."),typeof t=="string"?i.Ot=root.document.getElementById(t):t instanceof HTMLDivElement?i.Ot=t:Util.n("No DIV or DIV id supplied: "+t),i.Ot===null&&Util.n("Invalid DIV id; could not get element with id: "+t);const e=Diagram.He.get(i.Ot);if(e&&e!==this&&Util.n("Invalid div id; div already has a Diagram associated with it."),!i.qf&&root.ResizeObserver){const f=root.ResizeObserver,c=Util.Ik(()=>i.requestUpdate(),250,!1);i.qf=new f(()=>c()),i.qf.observe(i.Ot)}root.getComputedStyle(i.Ot,null).position==="static"&&(i.Ot.style.position="relative");let s=5;const n="rgba(2"+s+"5, 255, 255, 0)";s--,i.Ot.style["-webkit-tap-highlight-color"]=n,i.Ot.innerHTML="",Diagram.He.set(i.Ot,i),i.Ot.goDiagram=i,i.Ot.go=root.go;const o=new CanvasSurface(i);o.style!==void 0&&(o.style.position="absolute",o.style.top="0px",o.style.left="0px",root.getComputedStyle(i.Ot,null).getPropertyValue("direction")==="rtl"&&(i.vu=!0),o.style.zIndex="2",o.style.userSelect="none",o.style.MozUserSelect="none",o.style.touchAction="none",o.style.letterSpacing="normal !important",o.style.wordSpacing="normal !important",o.style.lang="unknown"),i.xt=o,i.ei=o.di;const r=i.ei;i.Gi=i.computePixelRatio(),i.viewSize.isReal()||(i.Ct=i.Ot.clientWidth||1,i.At=i.Ot.clientHeight||1),i.MA(i.Ct,i.At);const l=i;i.Ot.insertBefore(o.Vt,i.Ot.firstChild);const h=new CanvasSurface(null);if(h.width=1,h.height=1,i.BF=h,i.VF=h.di,Diagram.isUsingDOM()){const f=Util.ln("div"),c=Util.ln("div");f.style.position="absolute",f.style.overflow="auto",f.style.width=i.Ct+"px",f.style.height=i.At+"px",f.style.zIndex="1",c.style.position="absolute",c.style.width="1px",c.style.height="1px",i.Ot.appendChild(f),f.appendChild(c),f.onscroll=Diagram.JF,f.addEventListener("pointerdown",Diagram.ZF),f.b=i,f.$F=!0,f.QF=!0,i.g1=f,i.m1=c}i.Pu=Util.Ik(()=>{i.Cl=null,i.T()},300,!1),i.w1=Util.Ik(()=>{i.RM()},250,!1),i.Wh=f=>(f.preventDefault(),!1),i.na=f=>{if(!l.isEnabled)return;const c=l.Jf(f,!0);c.bubbles=!0;let u=0,d=0;c.delta=0,f.deltaX!==void 0?(f.deltaX!==0&&(u=f.deltaX>0?1:-1),f.deltaY!==0&&(d=f.deltaY>0?1:-1),c.delta=Math.abs(f.deltaX)>Math.abs(f.deltaY)?-u:-d):f.wheelDeltaX!==void 0?(f.wheelDeltaX!==0&&(u=f.wheelDeltaX>0?-1:1),f.wheelDeltaY!==0&&(d=f.wheelDeltaY>0?-1:1),c.delta=Math.abs(f.wheelDeltaX)>Math.abs(f.wheelDeltaY)?-u:-d):f.wheelDelta!==void 0&&f.wheelDelta!==0&&(c.delta=f.wheelDelta>0?1:-1),l.doMouseWheel(),l.aa(c,f)},i.gA=f=>{if(!l.isEnabled)return;i.jf=!1,l.Jf(f,!0);const c=l.currentTool;c.cancelWaitAfter(),c.standardMouseOver()},i.ih=f=>{if(!l.isEnabled)return;i.jf=!0;const c=l.d1;c[f.pointerId]===void 0&&(c[f.pointerId]=f);const u=l.sa;let d=!1;if(u[0]!==null&&(u[0].pointerId===f.pointerId||u[0].pointerType!==f.pointerType))u[0]=f;else if(u[1]!==null&&u[1].pointerId===f.pointerId)u[1]=f,d=!0;else if(u[0]===null)u[0]=f;else if(u[1]===null)u[1]=f,d=!0;else{f.preventDefault();return}const m=f.pointerType==="touch"||f.pointerType==="pen";m&&(l.qw=!1,l.o0=!0);const g=l._F(f,f,d),p=l.yP,y=m?25:10;if(f.timeStamp-l.pPy||Math.abs(p.y-f.screenY)>y)?l.s0++:l.s0=1,g.clickCount=l.s0,l.pP=f.timeStamp,l.yP.setTo(f.screenX,f.screenY),l.doMouseDown(),f.button===1){f.preventDefault();return}l.aa(g,f)},i.oa=f=>{if(!l.isEnabled)return;i.jf=!0;const c=l.sa;if(c[0]!==null&&(c[0].pointerId===f.pointerId||c[0].pointerType!==f.pointerType))c[0]=f;else if(c[1]!==null&&c[1].pointerId===f.pointerId){c[1]=f;return}else if(c[0]===null)c[0]=f;else return;if(c[0].pointerId!==f.pointerId)return;const u=l.tR(f,f,c[1]!==null);l.doMouseMove(),l.aa(u,f)},i.ra=f=>{if(!l.isEnabled)return;i.jf=!0;const c=f.pointerType==="touch"||f.pointerType==="pen",u=l.d1;if(c&&l.qw){delete u[f.pointerId],f.preventDefault();return}const d=l.sa;if(d[0]!==null&&(d[0].pointerId===f.pointerId||d[0].pointerType!==f.pointerType))d[0]=null;else if(d[1]!==null&&d[1].pointerId===f.pointerId){d[1]=null;return}else return;const m=l.PP(f,!1,!0,!1,!0,!1);let g=root.document.elementFromPoint(f.clientX,f.clientY)||null;g!==null&&g.shadowRoot!==void 0&&g.shadowRoot!==null&&(g=g.shadowRoot.elementFromPoint(f.clientX,f.clientY)),g!==null&&g.b instanceof Diagram&&g.b!==l&&g.b.c0(f,m),g===null&&(g=f.target),l.c0(f,m),m.clickCount=l.s0,m.targetDiagram=l.NP(f,g),m.targetObject=null,l.doMouseUp(),l.aa(m,f),c&&(l.o0=!1)},i.la=f=>{if(!l.isEnabled)return;i.jf=!1;const c=l.d1;c[f.pointerId]&&delete c[f.pointerId];const u=l.sa;if(u[0]!==null&&u[0].pointerId===f.pointerId&&(u[0]=null),u[1]!==null&&u[1].pointerId===f.pointerId&&(u[1]=null),f.pointerType==="touch"||f.pointerType==="pen")return;const d=l.currentTool;d.cancelWaitAfter(),d.standardMouseOver()},i.ha=f=>{const c=l.sa;c[0]!==null&&c[0].pointerId===f.pointerId?(c[0]=null,l.o0=!1):c[1]!==null&&c[1].pointerId===f.pointerId&&(c[1]=null)};const a=r;if(i.p1=a.Y[Util.Fs("7eba17a4ca3b1a8346")][Util.Fs("78a118b7")](a.Y,Diagram.Ju,s,s),r.clearContextCache(!0),i.iR(),this.Gf==="svg"){const f=this.Ql.get("svg");this.Ot.appendChild(f.Vt),this.ei=f.di}}addEventListener(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}Ht(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}removeEventListener(t,i,e,s){t.removeEventListener(i,e,{capture:s})}Li(t,i,e,s){t.removeEventListener(i,e,{capture:s})}iR(){const t=this;let i=this.xt.Vt;i instanceof HTMLCanvasElement||(i=t.div),this.Ht(i,"pointerdown",t.ih,!1),this.Ht(i,"pointermove",t.oa,!1),this.Ht(i,"pointerup",t.ra,!1),this.Ht(i,"pointerout",t.la,!1),this.Ht(i,"pointercancel",t.ha,!1),this.Ht(i,"pointerenter",t.eR,!1),this.Ht(i,"pointerleave",t.sR,!1),this.Ht(i,"wheel",t.na,!1),this.Ht(i,"keydown",t.nR,!1),this.Ht(i,"keyup",t.oR,!1),this.Ht(i,"blur",t.rR,!1),this.Ht(i,"focus",t.lR,!1),this.Ht(i,"selectstart",e=>(e.preventDefault(),!1),!1),this.Ht(i,"contextmenu",e=>(e.preventDefault(),!1),!1),this.Ht(root,"resize",t.w1,!1)}jw(){this.r0>30&&(this.Cl=1)}NS(t){this.Cl!==null&&(this.Cl=null,t&&this.Pu(),Debug&&Debug.drawFrames||(this.r0=0,this.bP=[0,0,0,0,0],this.l0=0))}computePixelRatio(){return this.Cl!==null?this.Cl:root.devicePixelRatio||1}get avgSpf(){return this.r0}doMouseDown(){this.currentTool.doMouseDown()}doMouseMove(){this.currentTool.doMouseMove()}doMouseUp(){this.currentTool.doMouseUp()}doMouseWheel(){this.currentTool.doMouseWheel()}doKeyDown(){this.currentTool.doKeyDown()}doKeyUp(){this.currentTool.doKeyUp()}doFocus(){this.focus()}focus(){if(this.xt)if(this.scrollsPageOnFocus)this.xt.focus();else{const t=root.scrollX,i=root.scrollY;this.xt.focus(),root.scrollTo(t,i)}}lR(t){const i=Diagram.He.get(this);i&&i.B("GainedFocus")}rR(t){const i=Diagram.He.get(this);i&&i.B("LostFocus")}RM(){if(this.xt===null)return;const i=this.Ot;if(i===null||i.clientWidth===0||i.clientHeight===0)return;this.WM||this.setScrollWidth();const e=this.to?this.yi:0,s=this.xn?this.yi:0,n=this.Gi;if(this.Gi=this.computePixelRatio(),this.Gi!==n&&(this.Xu=!0,this.requestUpdate()),i.clientWidth!==this.Ct+e||i.clientHeight!==this.At+s){this.fa(),this.Ge=!0;const o=this.layout;o!==null&&o.isViewportSized&&this.autoScale===1&&(this.Uf=!0,o.invalidateLayout()),this.ks||this.requestUpdate()}}wA(){let t=0,i=new Layer;i.name="Grid",i.allowSelect=!1,i.pickable=!1,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="ViewportBackground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="Background",this.Jr(i,t++),i=new Layer,i.name="",this.Jr(i,t++),i=new Layer,i.name="Foreground",this.Jr(i,t++),i=new Layer,i.name="ViewportForeground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="Adornment",i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="Tool",i.isTemporary=!0,i.isInDocumentBounds=!0,this.Jr(i,t++)}PA(){const t=new Panel(Panel.Grid,{name:"GRID"}).add(new Shape("LineH",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineV",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineH",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineH",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor")),i=new Part({layerName:"Grid",zOrder:0,isInDocumentBounds:!1,isAnimated:!1,pickable:!1,locationObjectName:"GRID"}).add(t);return this.add(i),this.partManager.parts.delete(i),t.visible=!1,t}static JF(){const t=Diagram.He.get(this.parentElement||this);if(t){if(t.s1){t.s1=!1;return}if(!t.isEnabled){t.NA();return}t.diagramScroll(this)}}static ZF(t){if(!this.b.isEnabled){this.b.updateScroll();return}this.b.o1=t.target.scrollTop,this.b.l1=t.target.scrollLeft}diagramScroll(t){if(this.xt===null)return;const i=this.g1,e=this.m1;this.Jm=!0;let s=this.documentBounds,n=this.viewportBounds;const o=this.Xf;let r=s.x-o.left,l=s.y-o.top;const h=s.width+o.left+o.right,a=s.height+o.top+o.bottom;let f=s.right+o.right,c=s.bottom+o.bottom,u=n.x,d=n.y;const m=n.width,g=n.height;let p=n.right,y=n.bottom;const x=this.scale;let k,b=t.scrollLeft;if(this.vu)switch(this.Cx){case"negative":b=b+t.scrollWidth-t.clientWidth;break;case"reverse":b=t.scrollWidth-b-t.clientWidth;break}const S=b;if(mp)){const M=i.scrollWidth-this.Ct;this.position=k.e(-M+S-this.Ct/x+f,this.position.y)}if(t.QF&&this.allowVerticalScroll&&(ly)){const M=i.scrollHeight-this.At;this.position=k.e(this.position.x,-M+t.scrollTop-this.At/x+c)}Point.o(k),this.sh(),this.Jm=!1,this.Gu=!1,s=this.documentBounds,n=this.viewportBounds,f=s.right,p=n.right,c=s.bottom,y=n.bottom,r=s.x,u=n.x,l=s.y,d=n.y,m>=h&&r>=u&&f<=p&&(e.style.width="1px"),g>=a&&l>=d&&c<=y&&(e.style.height="1px")}computeBounds(t){return t===void 0&&(t=new Rect),this.Di(),this.CA(t)}CA(t){if(this.fixedBounds.isReal())return t.c(this.fixedBounds),t.addMargin(this.ii),t;let i=!0;const e=this.Jt.h,s=e.length;for(let n=0;ni&&(a=i),athis.maxScale&&(a=this.maxScale),a):t===3?(a=0,h>l?a=(r-this.yi)/n:a=(o-this.yi)/s,a>i&&(a=i),athis.maxScale&&(a=this.maxScale),a):this.scale}zoomToFit(){const t=this.Jh;this.Jh=1,this.scale=this.Zu(2),t!==1&&(this.Gs(!1),this.CP(this.documentBounds,this.Ct/this.rt,this.At/this.rt,this.Yf,!1)),this.Jh=t}zoomToRect(t,i){i===void 0&&(i=2);const e=t.width,s=t.height;if(e===0||s===0||isNaN(e)&&isNaN(s))return;let n=1;if(i===2||i===3)if(isNaN(e))n=this.viewportBounds.height*this.scale/s;else if(isNaN(s))n=this.viewportBounds.width*this.scale/e;else{const o=this.Ct,r=this.At;i===3?r/s>o/e?n=(r-(this.xn?this.yi:0))/s:n=(o-(this.to?this.yi:0))/e:n=Math.min(r/s,o/e)}this.scale=n,this.position=new Point(t.x,t.y)}get hR(){return this.$t}set hR(t){this.$t=t}alignDocument(t,i){this.ensureBounds();const e=this.documentBounds,s=this.viewportBounds;this.position=new Point(e.x+(t.x*e.width+t.offsetX)-(i.x*s.width-i.offsetX),e.y+(t.y*e.height+t.offsetY)-(i.y*s.height-i.offsetY))}focusObject(t){if(t instanceof GraphObject){this.h0=t;const i=Point.a();this.a0=this.transformDocToView(t.getDocumentPoint(Spot.TopLeft,i)),Point.o(i)}else this.h0=null,this.a0=Point.Bk}CP(t,i,e,s,n){const o=Point.H(this.gt.x,this.gt.y);let r=o.x,l=o.y;if(this.h0!==null){let h=Point.a();h=this.h0.getDocumentPoint(Spot.TopLeft,h),r=h.x-this.a0.x/this.scale,l=h.y-this.a0.y/this.scale,s=Spot.None,Point.o(h)}if(n||this.scrollMode===1){s.isSpot()&&(i>t.width&&(r=t.x+(s.x*t.width+s.offsetX)-(s.x*i-s.offsetX)),e>t.height&&(l=t.y+(s.y*t.height+s.offsetY)-(s.y*e-s.offsetY)));const h=this.Xf,a=i-t.width;if(it.left?r=t.left:rt.top?l=t.top:ls.part,s=>s.canSelect());if(e instanceof Part)return e}else{const e=this.DS(t,s=>s.part);if(e instanceof Part)return e}return null}findObjectAt(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Di();const s=this.Jt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}DS(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Di();const s=this.Jt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible||n.isTemporary)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}findPartsAt(t,i,e){return i===void 0&&(i=!0),this.fR(t,s=>s.part,i?s=>s instanceof Part&&s.canSelect():null,e)}fR(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Di();const n=this.Jt.iteratorBackwards;for(;n.next();){const o=n.value;!o.visible||o.isTemporary||o.findObjectsAt(t,i,e,s)}return s}findObjectsAt(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Di();const n=this.Jt.iteratorBackwards;for(;n.next();){const o=n.value;o.visible&&o.findObjectsAt(t,i,e,s)}return s}findPartsIn(t,i,e,s){return i===void 0&&(i=!1),e===void 0&&(e=!0),this.cR(t,null,n=>n instanceof Part&&(!e||n.canSelect()),i,s)}findObjectsIn(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Di();const o=this.Jt.iteratorBackwards;for(;o.next();){const r=o.value;r.visible&&r.findObjectsIn(t,i,e,s,n)}return n}IS(t,i,e,s,n,o){const r=new GSet;this.Di();const l=this.Jt.iteratorBackwards;for(;l.next();){const h=l.value;h.visible&&h.IS(t,i,e,s,r,n,o)}return r}cR(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Di();const o=this.Jt.iteratorBackwards;for(;o.next();){const r=o.value;!r.visible||r.isTemporary||r.findObjectsIn(t,i,e,s,n)}return n}findPartsNear(t,i,e,s,n){return e===void 0&&(e=!0),s===void 0&&(s=!0),this.uR(t,i,null,o=>o instanceof Part&&(!s||o.canSelect()),e,n)}findObjectsNear(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Di();const r=this.Jt.iteratorBackwards;for(;r.next();){const l=r.value;l.visible&&l.findObjectsNear(t,i,e,s,n,o)}return o}uR(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Di();const r=this.Jt.iteratorBackwards;for(;r.next();){const l=r.value;!l.visible||l.isTemporary||l.findObjectsNear(t,i,e,s,n,o)}return o}acceptEvent(t){return this.Jf(t,t instanceof MouseEvent)}Jf(t,i){const e=this.jr;this.jr=this.ta,this.ta=e,e.diagram=this,e.event=t,i?this.c0(t,e):(e.viewPoint=this.jr.viewPoint,e.documentPoint=this.jr.documentPoint);let s=0;const n=t;return n.ctrlKey&&(s+=1),n.altKey&&(s+=2),n.shiftKey&&(s+=4),n.metaKey&&(s+=8),e.modifiers=s,e.button=n.button,n.buttons!==void 0&&(e.buttons=n.buttons),Util.cr&&n.button===0&&n.ctrlKey&&(e.button=2),e.down=!1,e.up=!1,e.clickCount=1,e.delta=0,e.handled=!1,e.bubbles=!1,e.timestamp=t.timeStamp,e.isMultiTouch=!1,e.targetDiagram=this.NP(t,t.target),e.targetObject=null,e}NP(t,i){if(i===null)return null;const e=Diagram.He.get(i);if(e)return e;let s=t.path;if(!s&&typeof t.composedPath=="function"&&(s=t.composedPath()),s&&s[0]){const n=Diagram.He.get(s[0]);if(n)return n}return null}_F(t,i,e){const s=this.PP(t,!0,!1,!1,!0,e);return this.c0(i,s),s.targetDiagram=this.NP(t,t.target),s.targetObject=null,e||s.clone(this.i0),s}tR(t,i,e){const s=this.PP(t,!1,!1,!1,!1,e);let n=root.document.elementFromPoint(i.clientX,i.clientY)||null;n!==null&&n.shadowRoot!==void 0&&n.shadowRoot!==null&&(n=n.shadowRoot.elementFromPoint(i.clientX,i.clientY));let o=this,r=t;if(n){const l=Diagram.He.get(n);l&&(r=i,o=l)}return s.targetDiagram=o,this.c0(r,s),s.targetObject=null,s}PP(t,i,e,s,n,o){const r=this.jr;this.jr=this.ta,this.ta=r,r.diagram=this,r.clickCount=1,r.delta=0;let l=0;return t.ctrlKey&&(l+=1),t.altKey&&(l+=2),t.shiftKey&&(l+=4),t.metaKey&&(l+=8),r.modifiers=l,r.event=t,r.timestamp=t.timeStamp,r.button=e?this.firstInput.button:t.button,r.buttons=t.buttons,Util.cr&&t.button===0&&t.ctrlKey&&(r.button=2),r.down=i,r.up=e,r.handled=s,r.bubbles=n,r.isMultiTouch=o,r}aa(t,i){return t.bubbles?(Debug&&Debug.handleMessages&&Util.ht("NOT handled "+i.type+" "+t.toString()),!0):(Debug&&Debug.handleMessages&&Util.ht("handled "+i.type+" "+this.currentTool.name+" "+t.toString()),i.stopPropagation!==void 0&&i.stopPropagation(),i.cancelable!==!1&&i.preventDefault(),i.cancelBubble=!0,!1)}nR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.Jf(t,!1);return e.key=t.key,e.code=t.code,e.down=!0,i.doKeyDown(),i.aa(e,t)}oR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.Jf(t,!1);return e.key=t.key,e.code=t.code,e.up=!0,i.doKeyUp(),i.aa(e,t)}eR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.Jf(t,!0);return i.mouseEnter!==null&&i.mouseEnter(e),i.currentTool.standardMouseOver(),i.aa(e,t)}sR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.Jf(t,!0);return i.mouseLeave!==null&&i.mouseLeave(e),i.aa(e,t)}getMouse(t){const i=this.xt;if(i===null)return new Point(0,0);const e=i.getBoundingClientRect(),s=(t.clientX-e.left)*(this.Ct/e.width),n=(t.clientY-e.top)*(this.At/e.height);return new Point(s,n).Ye(this.O)}c0(t,i){const e=this.xt;let s=0,n=0;if(e!==null){const r=e.getBoundingClientRect();s=(t.clientX-r.left)*(this.Ct/r.width),n=(t.clientY-r.top)*(this.At/r.height)}i.viewPoint.e(s,n);const o=Point.H(s,n);this.O.ns(o),i.documentPoint.c(o),Point.o(o)}LC(t,i,e){let s;if(this.sa[0]!==null)s=this.sa[i];else return;const n=this.xt;if(n!==null){const o=n.getBoundingClientRect();e.e((s.clientX-o.left)*(this.Ct/o.width),(s.clientY-o.top)*(this.At/o.height))}}invalidateDocumentBounds(){this.ia||(this.ia=!0,this.requestUpdate(!1))}dR(){this.ks||this.Di(),this.ensureBounds()}redraw(){this.$t||this.ks||(this.T(),this.maybeUpdate())}isUpdateRequested(){return this.Ar}delayInitialization(t){t===void 0&&(t=null);const i=this.animationManager,e=i.isEnabled;i.stopAnimation(),i.isEnabled=!1,this.Sr(),this.io=!1,this.fx=new Point(NaN,NaN),i.isEnabled=e,this.ks=!0;const s=this;t!==null&&Util.zh(()=>{s.ks=!1,i.El("Model"),t(s)},1)}requestUpdate(t){if(t===void 0&&(t=!1),this.Ar===!0||this.$t||t===!1&&this.ks)return;this.Ar=!0;const i=this;root.requestAnimationFrame(()=>{i.Ar&&i.maybeUpdate()})}maybeUpdate(){this.Yu&&!this.Ar||(this.Yu&&(this.Yu=!1),this.Sr())}AP(t,i){!this.Gu||this.$t||this.animationManager.defaultAnimation.isAnimating||this.NA()||(t&&this.Di(),i&&this.Gs(!1))}Sr(t){if(this.ks||(this.Ar=!1,this.Ot===null&&!this.Hu.isReal()))return;this.ks=!0;const i=this.animationManager,e=this.Wu;if(!i.isAnimating&&e.length!==0){const f=e.h,c=f.length;for(let u=0;u0&&(s.each(f=>f.LP()),s.clear());let n=!1,o=!1;i.defaultAnimation.isAnimating&&(o=!0,n=this.skipsUndoManager,this.skipsUndoManager=!0),i.Si||this.RM(),t||this.AP(!1,!0);const r=!this.undoManager.isUndoingRedoing&&(this.Pl||this.vf.count!==0&&this.Rr.size!==0),l=!this.io||this.Wr;this.Di(!0);let h=!1;(l||r)&&(this.io?this.TP(!this.Uf,r):(this.startTransaction("Initial Layout"),i.isEnabled===!1&&i.stopAnimation(),this.TP(!1,r)),h=l),this.Uf=!1,this.Pl=!1,this.Di(),this.os!==null&&(this.os.visible&&!this._m&&(this.Zr(),this._m=!0),!this.os.visible&&this._m&&(this._m=!1)),this.qx||this.dR(),t||this.AP(!0,!1);let a=!1;if(h){const f=Rect.a();f.c(this.viewportBounds),this.io||(this.io=!0,a=!0,this.skipsUndoManager||(this.undoManager.Uw=!0),this.undoManager.Gw=!0,this.gR()),this.mR(),this.Di(!1),t||this.AP(!0,!0),Rect.o(f)}else if(i.Ff&&i.ax){if(this.Fr!==1)this.scale=this.Zu(this.Fr);else if(this.Jl!==1)this.scale=this.Zu(this.Jl);else{const f=this.initialScale;isFinite(f)&&f>0&&(this.scale=f)}this.Gs(!0)}h&&a&&this.commitTransaction("Initial Layout"),t||this.Ji(this.ei),o&&(this.skipsUndoManager=n),this.ks=!1}get Kh(){return this.io}gR(){if(this.Fr!==1)this.scale=this.Zu(this.Fr);else if(this.Jl!==1)this.scale=this.Zu(this.Jl);else{const i=this.initialScale;isFinite(i)&&i>0&&(this.scale=i)}this.Gs(!0);const t=this.Jt.h;this.Us(t,t.length,this,this.viewportBounds),this.B("InitialLayoutCompleted"),this.fx.c(this.gt),this.Zr()}mR(){this.B("LayoutCompleted")}u0(t){this.Qn.add(t)}addInvalidRoute(t){this.Bo?this.Qh.add(t):this.Rr.add(t)}Di(t){if(this.Qn.size!==0&&!(!this.ks&&this.animationManager.isTicking)){if(this.ks||(this.Pl=!0),t){this.AA(this.Qn);return}for(let i=0;i<23&&this.Qn.size!==0;i++){const e=new Set(this.Qn);this.Qn.clear(),this.LP(e,this.Qn),Debug&&i===22&&Util.ht("failure to validate parts")}this.nodes.each(i=>{i instanceof Group&&i.LA(!1)})}}AA(t,i){for(const e of t)!e.Ae()||e instanceof Group||(e.$r()?(e.wt(1/0,1/0),e.qt()):i&&i.add(e));for(const e of t)if(e instanceof Group){if(!e.isVisible())continue;this.T1(e)}}LP(t,i){this.AA(t,i);for(const e of t){if(!(e instanceof Link))continue;const s=e;s.isVisible()&&(s.$r()?(s.wt(1/0,1/0),s.qt()):i.add(s))}for(const e of t)e instanceof Adornment&&e.isVisible()&&(e.$r()?(e.wt(1/0,1/0),e.qt()):i.add(e))}d0(t){const i=t instanceof Diagram,e=i?t.links:t.memberParts,s=this.Qn;if(i)this.Di(!0);else{for(;e.next();){const n=e.value;s.has(n)&&(!n.Ae()||n instanceof Group||n.$r()&&(n.wt(1/0,1/0),n.qt()))}for(e.reset();e.next();){const n=e.value;if(s.has(n)&&n instanceof Group){if(!n.isVisible())continue;this.T1(n)}}e.reset()}for(;e.next();){const n=e.value;n instanceof Link&&s.has(n)&&n.isVisible()&&n.$r()&&(n.wt(1/0,1/0),n.qt())}}T1(t){const i=Util.at(),e=Util.at(),s=t.memberParts;for(;s.next();){const o=s.value;o.isVisible()&&(o instanceof Group?(o.Xo()||o.rs()||o.nh())&&this.T1(o):o instanceof Link?o.fromNode===t||o.toNode===t?e.push(o):i.push(o):(o.wt(1/0,1/0),o.qt()))}let n=i.length;for(let o=0;ob.Vu())}else for(let x=0;x0){const a=n.substring(0,h);e?o=t.findObject(a):(o=t[a],o==null&&(o=t.toolManager[a])),Util.Mt(o)?r=n.substring(h+1):Util.n("Unable to find object named: "+a+" in "+t.toString()+" when trying to set property: "+n)}}if(r[0]!=="_"&&!Util.yw(o,r))if(s&&r==="ModelChanged"){t.addModelChangedListener(i[r]);continue}else if(s&&r==="Changed"){t.addChangedListener(i[r]);continue}else if(s&&Util.yw(t.toolManager,r))o=t.toolManager;else if(s&&t.TA(r)){t.addDiagramListener(r,i[r]);continue}else if(t instanceof Model&&r==="Changed"){t.addChangedListener(i[r]);continue}else Util.n('Trying to set undefined property "'+r+'" on object: '+o.toString());const l=i[n];o[r]=l,r[0]==="_"&&o instanceof GraphObject&&o.addCopyProperty(r)}}rA(){if(this.th.count!==0&&!(this.undoManager.transactionLevel>1)){for(;this.th.count>0;){const t=this.th;this.th=new GMap;const i=t.iterator;for(;i.next();){const e=i.key;e.invalidateOtherJumpOvers(i.value),e.le()}}this.T()}}T(t){if(t===void 0)this.Ge=!0,this.requestUpdate();else{const i=this.viewportBounds;t.isReal()&&i.intersectsRect(t)&&(this.Ge=!0,this.requestUpdate())}this.B("InvalidateDraw")}invalidateViewport(t,i){if(this.Ge===!0)return;if(this.Ge=!0,this.Gf==="svg"){this.maybeUpdate();return}this.getRenderingHint("temporaryPixelRatio")===!0?(this.jw(),this.maybeUpdate(),this.NS(!0)):this.maybeUpdate()}fa(){this.Gu=!0}sh(){this.Hf=!0}g0(){this.Xu!==!1&&(this.Xu=!1,this.MA(this.Ct,this.At))}MA(t,i){this.eh();const e=this.Gi,s=t*e,n=i*e;this.xt.resize(s,n,t,i)&&(this.Ge=!0,this.ei.clearContextCache(!0))}NA(){const t=this.xt;if(t===null||this.Hu.isReal())return!0;const i=this.Ct,e=this.At,s=this.Ot;let n=!1,o=this.to?this.yi:0,r=this.xn?this.yi:0,l=s.clientWidth||i+o,h=s.clientHeight||e+r;const a=this.viewportBounds,f=a.x,c=a.y,u=a.width,d=a.height;if((l!==i+o||h!==e+r)&&(this.to=!1,this.xn=!1,o=0,r=0,this.Ct=l,this.At=h,this.Xu=!0,n=!0,this.eh()),!this.io||!this.viewportBounds.isReal())return!0;const m=this.g1,g=this.m1;if(this.Gu=!1,!n&&!this.to&&!this.xn&&!this.Ku&&!this.Uu)return!0;const p=this.documentBounds;let y=0,x=0,k=0,b=0;const S=a.width,M=a.height,A=this.Xf;this.contentAlignment.isSpot()?(p.width>S&&(y=A.left,x=A.right),p.height>M&&(k=A.top,b=A.bottom)):(y=A.left,x=A.right,k=A.top,b=A.bottom);const C=p.width+y+x,P=p.height+k+b,N=this.scale,T=N;let L=C>l/N,D=P>h/N;if(!n&&!this.to&&!this.xn&&!L&&!D)return!0;const F=p.x-y,R=a.x,I=p.right+x;let O=a.right+o;const V=p.y-k,K=a.y,B=p.bottom+b;let X=a.bottom+r,z="1px",G="1px";if(this.scrollMode===1&&(L||D)){if(L&&this.hasHorizontalScrollbar&&this.allowHorizontalScroll){let Y=1;F+1O+1&&(Y=Math.max((I-O)*N+this.Ct,Y)),S+o+1X+1&&(Y=Math.max((B-X)*N+this.At,Y)),M+r+1O+1&&(v=Math.max((I-O)*N+this.Ct,v)),S+1X+1&&(v=Math.max((B-X)*N+Y,v)),M+1O+1&&(J=this.position.x*N)),this.vu)switch(this.Cx){case"negative":J=-(m.scrollWidth-J-m.clientWidth);break;case"reverse":J=m.scrollWidth-J-m.clientWidth;break}if(m.scrollLeft=J,this.hasVerticalScrollbar&&this.allowVerticalScroll&&(M+1X+1&&(m.scrollTop=this.position.y*N)),l=this.Ct,h=this.At,m.style.width=l+(this.to?this.yi:0)+"px",m.style.height=h+(this.xn?this.yi:0)+"px",i!==l||e!==h||this.animationManager.Si){const Y=Rect.H(f,c,u,d);return this.onViewportBoundsChanged(Y,this.viewportBounds,T,n),Rect.o(Y),!1}return!0}add(t){Util.s(t,Part,Diagram,"add:part");const i=t.diagram;if(i===this)return;i!==null&&Util.n("Cannot add part "+t.toString()+" to "+this.toString()+". It is already a part of "+i.toString());let e=this.findLayer(t.layerName);if(e===null&&(e=this.findLayer("")),e===null&&Util.n('Cannot add a Part when unable find a Layer named "'+t.layerName+'" and there is no default Layer'),t.layer===e)return;const s=e.$h(99999999,t,t.diagram===this);s>=0&&this.raiseChangedEvent(3,"parts",e,null,t,null,s),e.isTemporary||this.invalidateDocumentBounds(),t.invalidateLayout(1);const n=t.layerChanged;n!==null&&n(t,null,e)}$h(t){this.partManager.$h(t);const i=this;t.Qr(s=>i.DA(s)),t.data||t.Yo(),t.hasPlaceholder()&&t.u(),t.data!==null&&t.Qr(s=>i.partManager.FP(s,null)),(t.rs()===!0||t.nh()===!0)&&this.u0(t),t.FA(!0,this),t.RA()?(t.actualBounds.isReal()&&this.T(t.Zh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.T(t.Zh(t.actualBounds)),this.requestUpdate()}oe(t){t.clearAdornments(),this.partManager.oe(t);const i=this;t.data!==null&&t.Qr(s=>i.partManager.RP(s,i)),this.Qn.delete(t),t instanceof Link&&this.Rr.delete(t),t.RA()?(t.actualBounds.isReal()&&this.T(t.Zh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.T(t.Zh(t.actualBounds)),this.requestUpdate()}remove(t){Util.s(t,Part,Diagram,"remove:part"),this.IP(t,!0)}IP(t,i){const e=t.layer;if(e===null||e.diagram!==this)return;t.isSelected=!1,t.isHighlighted=!1,t.invalidateLayout(2),i&&t.Zf();const s=e.oe(-1,t,!1);s>=0&&this.raiseChangedEvent(4,"parts",e,t,null,s,null);const n=t.layerChanged;n!==null&&n(t,e,null)}removeParts(t,i){if(i===void 0&&(i=!1),Array.isArray(t)){const e=t.length;for(let s=0;s=0&&i.elt(e).isTemporary;)e--;return i.insertAt(e+1,t),this.Ai!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,e+1),this.T(),this.invalidateDocumentBounds(),this}addLayerBefore(t,i){this.OP(t,i),t.Oo(this);const e=this.Jt,s=e.indexOf(t);s>=0&&(e.delete(t),this.Ai!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;o=0&&(e.delete(t),this.Ai!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;othis.maxScale&&(i=this.maxScale);const f=Point.H(this.gt.x+l/t-l/i,this.gt.y+h/t-h/i);this.position=f,Point.o(f),this.rt=i,this.eh(),this.$t=!1,this.onViewportBoundsChanged(n,this.viewportBounds,t,!1),this.Gs(!1),e.nA(t,this.rt),this.T()}aR(){const t=this.Jt.h;for(let i=0;i{r.isAvoiding&&r.actualBounds.intersectsRect(i)&&r.invalidateRoute()})}Zr(t){const i=this.os;if(i===null||!i.visible||i.layer===null)return;const e=t!==void 0?t:this.a1;if(!e.isReal())return;const s=e.width,n=e.height;if(i.scale=1,i.angle=0,i.layer.isViewportAligned)i.width=s*this.scale,i.height=n*this.scale,i.part.alignment=Spot.TopLeft;else{i.Mi===null&&(i.Mi=new GridPanelSettings);const o=i.Mi.$f;if(!o.isReal())return;i.width=s+o.width*2,i.height=n+o.height*2;const r=Point.a();Geo.Gg(e.x,e.y,0,0,o.width,o.height,r),r.offset(-o.width,-o.height),i.part.location=r,Point.o(r)}}clearSelection(t){t===void 0&&(t=!1);const i=this.selection;if(i.count===0)return;t||this.B("ChangingSelection",i);const e=i.toArray(),s=e.length;for(let n=0;n1)&&(this.B("ChangingSelection",this.selection),this.clearSelection(!0),t.isSelected=!0,this.B("ChangedSelection",this.selection)))}selectCollection(t){if(this.B("ChangingSelection",this.selection),this.clearSelection(!0),Array.isArray(t)){const i=t.length;for(let e=0;e0){const i=t.toArray(),e=i.length;for(let s=0;s1)&&(this.clearHighlighteds(),t.isHighlighted=!0))}highlightCollection(t){const i=new GSet().addAll(t),s=this.highlighteds.copy().removeAll(i).iterator;for(;s.next();){const o=s.value;o.isHighlighted=!1}const n=i.iterator;for(;n.next();){const o=n.value;o instanceof Part||Util.n("Diagram.highlightCollection given something that is not a Part: "+o),o.isHighlighted=!0}}scroll(t,i,e){e===void 0&&(e=1);const s=i==="up"||i==="down";let n=0;const o=Point.a();if(t==="pixel")n=e;else if(t==="line")n=e*(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange);else if(t==="page"){let l=s?this.viewportBounds.height:this.viewportBounds.width;if(l*=this.scale,l!==0){const h=Math.max(l-(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange),0);n=e*h}}else if(t==="document"){const l=this.documentBounds,h=this.viewportBounds;i==="up"?this.position=o.e(h.x,l.y):i==="left"?this.position=o.e(l.x,h.y):i==="down"?this.position=o.e(h.x,l.bottom-h.height):i==="right"&&(this.position=o.e(l.right-h.width,h.y)),Point.o(o);return}else Util.n("scrolling unit must be 'pixel', 'line', 'page', or 'document', not: "+t);n/=this.scale;const r=this.position;i==="up"?this.position=o.e(r.x,r.y-n):i==="down"?this.position=o.e(r.x,r.y+n):i==="left"?this.position=o.e(r.x-n,r.y):i==="right"?this.position=o.e(r.x+n,r.y):Util.n("scrolling direction must be 'up', 'down', 'left', or 'right', not: "+i),Point.o(o)}scrollToRect(t){const i=this.viewportBounds;if(i.containsRect(t))return;const e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}centerRect(t){const i=this.viewportBounds,e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}transformDocToView(t){return t.copy().O(this.O)}transformViewToDoc(t){return t.copy().Ye(this.O)}EF(t){return t.Ye(this.O)}static None=1;static Uniform=2;static UniformToFill=3;static CycleAll=1;static CycleNotDirected=2;static CycleNotDirectedFast=3;static CycleNotUndirected=4;static CycleDestinationTree=5;static CycleSourceTree=6;static DocumentScroll=1;static InfiniteScroll=2;static TreeParentCollapsed=1;static AllParentsCollapsed=2;static AnyParentsCollapsed=3;get opacity(){return this._t}set opacity(t){const i=this._t;i!==t&&(Util.t(t,"number",Diagram,"opacity"),(t<0||t>1)&&Util.G(t,"0 <= value <= 1",Diagram,"opacity"),this._t=t,this.i("opacity",i,t),this.T())}get validCycle(){return this.Yx}set validCycle(t){const i=this.Yx;i!==t&&(Util.tt(t,CycleMode,"CycleMode"),this.Yx=t,this.i("validCycle",i,t))}get layers(){return this.Jt.iterator}get isModelReadOnly(){const t=this.Ai;return t===null?!1:t.isReadOnly}set isModelReadOnly(t){const i=this.Ai;i!==null&&(i.isReadOnly=t)}get isReadOnly(){return this.zo}set isReadOnly(t){const i=this.zo;i!==t&&(Util.t(t,"boolean",Diagram,"isReadOnly"),this.zo=t,this.i("isReadOnly",i,t))}get isEnabled(){return this.Xi}set isEnabled(t){const i=this.Xi;i!==t&&(Util.t(t,"boolean",Diagram,"isEnabled"),this.Xi=t,this.i("isEnabled",i,t))}get allowClipboard(){return this.Wx}set allowClipboard(t){const i=this.Wx;i!==t&&(Util.t(t,"boolean",Diagram,"allowClipboard"),this.Wx=t,this.i("allowClipboard",i,t))}get allowCopy(){return this.Bl}set allowCopy(t){const i=this.Bl;i!==t&&(Util.t(t,"boolean",Diagram,"allowCopy"),this.Bl=t,this.i("allowCopy",i,t))}get allowDelete(){return this.Vl}set allowDelete(t){const i=this.Vl;i!==t&&(Util.t(t,"boolean",Diagram,"allowDelete"),this.Vl=t,this.i("allowDelete",i,t))}get allowDragOut(){return this.vx}set allowDragOut(t){const i=this.vx;i!==t&&(Util.t(t,"boolean",Diagram,"allowDragOut"),this.vx=t,this.i("allowDragOut",i,t))}get allowDrop(){return this.Jx}set allowDrop(t){const i=this.Jx;i!==t&&(Util.t(t,"boolean",Diagram,"allowDrop"),this.Jx=t,this.i("allowDrop",i,t))}get allowTextEdit(){return this.zl}set allowTextEdit(t){const i=this.zl;i!==t&&(Util.t(t,"boolean",Diagram,"allowTextEdit"),this.zl=t,this.i("allowTextEdit",i,t))}get allowGroup(){return this.Xl}set allowGroup(t){const i=this.Xl;i!==t&&(Util.t(t,"boolean",Diagram,"allowGroup"),this.Xl=t,this.i("allowGroup",i,t))}get allowUngroup(){return this.Yl}set allowUngroup(t){const i=this.Yl;i!==t&&(Util.t(t,"boolean",Diagram,"allowUngroup"),this.Yl=t,this.i("allowUngroup",i,t))}get allowInsert(){return this.Zx}set allowInsert(t){const i=this.Zx;i!==t&&(Util.t(t,"boolean",Diagram,"allowInsert"),this.Zx=t,this.i("allowInsert",i,t))}get allowLink(){return this.Kl}set allowLink(t){const i=this.Kl;i!==t&&(Util.t(t,"boolean",Diagram,"allowLink"),this.Kl=t,this.i("allowLink",i,t))}get allowRelink(){return this.Ul}set allowRelink(t){const i=this.Ul;i!==t&&(Util.t(t,"boolean",Diagram,"allowRelink"),this.Ul=t,this.i("allowRelink",i,t))}get allowMove(){return this.Gl}set allowMove(t){const i=this.Gl;i!==t&&(Util.t(t,"boolean",Diagram,"allowMove"),this.Gl=t,this.i("allowMove",i,t))}get allowReshape(){return this.Hl}set allowReshape(t){const i=this.Hl;i!==t&&(Util.t(t,"boolean",Diagram,"allowReshape"),this.Hl=t,this.i("allowReshape",i,t))}get allowResize(){return this.ql}set allowResize(t){const i=this.ql;i!==t&&(Util.t(t,"boolean",Diagram,"allowResize"),this.ql=t,this.i("allowResize",i,t))}get allowRotate(){return this.jl}set allowRotate(t){const i=this.jl;i!==t&&(Util.t(t,"boolean",Diagram,"allowRotate"),this.jl=t,this.i("allowRotate",i,t))}get allowSelect(){return this.Wl}set allowSelect(t){const i=this.Wl;i!==t&&(Util.t(t,"boolean",Diagram,"allowSelect"),this.Wl=t,this.i("allowSelect",i,t))}get allowUndo(){return this.$x}set allowUndo(t){const i=this.$x;i!==t&&(Util.t(t,"boolean",Diagram,"allowUndo"),this.$x=t,this.i("allowUndo",i,t))}get allowZoom(){return this.Qx}set allowZoom(t){const i=this.Qx;i!==t&&(Util.t(t,"boolean",Diagram,"allowZoom"),this.Qx=t,this.i("allowZoom",i,t))}get hasVerticalScrollbar(){return this.Uu}set hasVerticalScrollbar(t){const i=this.Uu;i!==t&&(Util.t(t,"boolean",Diagram,"hasVerticalScrollbar"),this.Uu=t,this.fa(),this.T(),this.i("hasVerticalScrollbar",i,t),this.Gs(!1))}get hasHorizontalScrollbar(){return this.Ku}set hasHorizontalScrollbar(t){const i=this.Ku;i!==t&&(Util.t(t,"boolean",Diagram,"hasHorizontalScrollbar"),this.Ku=t,this.fa(),this.T(),this.i("hasHorizontalScrollbar",i,t),this.Gs(!1))}get allowHorizontalScroll(){return this._x}set allowHorizontalScroll(t){const i=this._x;i!==t&&(Util.t(t,"boolean",Diagram,"allowHorizontalScroll"),this._x=t,this.i("allowHorizontalScroll",i,t),this.Gs(!1))}get allowVerticalScroll(){return this.t1}set allowVerticalScroll(t){const i=this.t1;i!==t&&(Util.t(t,"boolean",Diagram,"allowVerticalScroll"),this.t1=t,this.i("allowVerticalScroll",i,t),this.Gs(!1))}get scrollHorizontalLineChange(){return this.i1}set scrollHorizontalLineChange(t){const i=this.i1;i!==t&&(Util.t(t,"number",Diagram,"scrollHorizontalLineChange"),t<0&&Util.G(t,">= 0",Diagram,"scrollHorizontalLineChange"),this.i1=t,this.i("scrollHorizontalLineChange",i,t))}get scrollVerticalLineChange(){return this.e1}set scrollVerticalLineChange(t){const i=this.e1;i!==t&&(Util.t(t,"number",Diagram,"scrollVerticalLineChange"),t<0&&Util.G(t,">= 0",Diagram,"scrollVerticalLineChange"),this.e1=t,this.i("scrollVerticalLineChange",i,t))}get lastInput(){return this.ta}set lastInput(t){Debug&&Util.s(t,InputEvent,Diagram,"lastInput"),this.ta=t}get previousInput(){return this.jr}set previousInput(t){Debug&&Util.s(t,InputEvent,Diagram,"previousInput"),this.jr=t}get firstInput(){return this.i0}set firstInput(t){Debug&&Util.s(t,InputEvent,Diagram,"firstInput"),this.i0=t}get currentCursor(){return this.Kx}set currentCursor(t){if(t===""&&(t=this.vm),this.Kx!==t){Util.t(t,"string",Diagram,"currentCursor");const e=this.xt,s=this.Ot;if(e===null||s===null)return;this.Kx=t;const n=e.style.cursor;e.style.cursor=t,s.style.cursor=t,e.style.cursor===n&&(e.style.cursor="-webkit-"+t,s.style.cursor="-webkit-"+t,e.style.cursor===n&&(e.style.cursor="-moz-"+t,s.style.cursor="-moz-"+t,e.style.cursor===n&&(e.style.cursor=t,s.style.cursor=t)))}}get defaultCursor(){return this.vm}set defaultCursor(t){t===""&&(t="auto");const i=this.vm;i!==t&&(Util.t(t,"string",Diagram,"defaultCursor"),this.vm=t,this.i("defaultCursor",i,t))}get click(){return this.Or}set click(t){const i=this.Or;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"click"),this.Or=t,this.i("click",i,t))}get doubleClick(){return this.Er}set doubleClick(t){const i=this.Er;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"doubleClick"),this.Er=t,this.i("doubleClick",i,t))}get contextClick(){return this.Br}set contextClick(t){const i=this.Br;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"contextClick"),this.Br=t,this.i("contextClick",i,t))}get mouseOver(){return this.Vr}set mouseOver(t){const i=this.Vr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseOver"),this.Vr=t,this.i("mouseOver",i,t))}get mouseHover(){return this.zr}set mouseHover(t){const i=this.zr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseHover"),this.zr=t,this.i("mouseHover",i,t))}get mouseHold(){return this.Xr}set mouseHold(t){const i=this.Xr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseHold"),this.Xr=t,this.i("mouseHold",i,t))}get mouseDragOver(){return this.Ux}set mouseDragOver(t){const i=this.Ux;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseDragOver"),this.Ux=t,this.i("mouseDragOver",i,t))}get mouseDrop(){return this.Yr}set mouseDrop(t){const i=this.Yr;i!==t&&(Debug&&t!==null&&Util.t(t,"function",Diagram,"mouseDrop"),this.Yr=t,this.i("mouseDrop",i,t))}get handlesDragDropForTopLevelParts(){return this.Gx}set handlesDragDropForTopLevelParts(t){const i=this.Gx;i!==t&&(Util.t(t,"boolean",Diagram,"handlesDragDropForTopLevelParts"),this.Gx=t,this.i("handlesDragDropForTopLevelParts",i,t))}get mouseEnter(){return this.Kr}set mouseEnter(t){const i=this.Kr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseEnter"),this.Kr=t,this.i("mouseEnter",i,t))}get mouseLeave(){return this.Ur}set mouseLeave(t){const i=this.Ur;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseLeave"),this.Ur=t,this.i("mouseLeave",i,t))}get toolTip(){return this.Gr}set toolTip(t){const i=this.Gr;i!==t&&(Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("Diagram.toolTip must be an Adornment or HTMLInfo."),this.Gr=t,this.i("toolTip",i,t))}get contextMenu(){return this.Hr}set contextMenu(t){const i=this.Hr;i!==t&&(Debug&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("Diagram.contextMenu must be an Adornment or HTMLInfo."),this.Hr=t,this.i("contextMenu",i,t))}get commandHandler(){return this.tP}set commandHandler(t){this.tP!==t&&(this.tP=t,t.Oo(this))}get toolManager(){return this.$M}set toolManager(t){this.$M!==t&&(Util.s(t,ToolManager,Diagram,"toolManager"),this.$M=t,t.diagram=this)}get defaultTool(){return this.QM}set defaultTool(t){const i=this.QM;i!==t&&(Util.s(t,Tool,Diagram,"defaultTool"),this.QM=t,t.diagram=this,this.currentTool===i&&(this.currentTool=t))}get currentTool(){return this._M}set currentTool(t){const i=this._M;i&&(i.isActive&&i.doDeactivate(),i.cancelWaitAfter(),i.doStop()),t===null&&(t=this.defaultTool),t!==null&&(Util.s(t,Tool,Diagram,"currentTool"),this._M=t,t.diagram=this,t.doStart())}get selection(){return this.lP}get maxSelectionCount(){return this.h1}set maxSelectionCount(t){const i=this.h1;if(i!==t)if(Util.t(t,"number",Diagram,"maxSelectionCount"),t>=0&&!isNaN(t)){if(this.h1=t,this.i("maxSelectionCount",i,t),!this.undoManager.isUndoingRedoing){const e=this.selection.count-t;if(e>0){this.B("ChangingSelection",this.selection);const s=this.selection.toArray();for(let n=0;n= 0",Diagram,"maxSelectionCount")}get nodeSelectionAdornmentTemplate(){return this.Qm}set nodeSelectionAdornmentTemplate(t){const i=this.Qm;i!==t&&(Util.s(t,Adornment,Diagram,"nodeSelectionAdornmentTemplate"),this.Qm=t,this.i("nodeSelectionAdornmentTemplate",i,t))}get groupSelectionAdornmentTemplate(){return this.c1}set groupSelectionAdornmentTemplate(t){const i=this.c1;i!==t&&(Util.s(t,Adornment,Diagram,"groupSelectionAdornmentTemplate"),this.c1=t,this.i("groupSelectionAdornmentTemplate",i,t))}get linkSelectionAdornmentTemplate(){return this.u1}set linkSelectionAdornmentTemplate(t){const i=this.u1;i!==t&&(Util.s(t,Adornment,Diagram,"linkSelectionAdornmentTemplate"),this.u1=t,this.i("linkSelectionAdornmentTemplate",i,t))}get highlighteds(){return this.hP}get isModified(){const t=this.undoManager;return t.isEnabled?t.currentTransaction!==null?!0:this.qu&&this.zs!==t.historyIndex:this.qu}set isModified(t){if(this.qu!==t){Util.t(t,"boolean",Diagram,"isModified"),this.qu=t;const e=this.undoManager;!t&&e.isEnabled&&(this.zs=e.historyIndex),t||this.YA()}}YA(){const t=this.isModified;this.oP!==t&&(this.oP=t,this.B("Modified"))}get model(){return this.Ai}set model(t){const i=this.Ai;if(i!==t){Util.s(t,Model,Diagram,"model"),this.currentTool.doCancel(),i&&i.undoManager!==t.undoManager&&i.undoManager.isInTransaction&&Util.n("Do not replace a Diagram.model while a transaction is in progress."),this.animationManager.stopAnimation(!0);const e=this.kA(!0);this.io=!1,this.Yu=!0,this.zs=-2,this.Ar=!1;const s=this.$t;this.$t=!0,this.animationManager.El("Model"),i&&(this._n!==null&&this._n.each(n=>i.removeChangedListener(n)),i.removeChangedListener(this.nP)),this.Ai=t,this.partManager=this.wR(this.Ai.type),this.initializePartManager(this.partManager);for(let n=0;nt.addChangedListener(n)),this.$t=s,this.invalidateDocumentBounds(),this.$t||this.T(),i&&t.undoManager.copyProperties(i.undoManager)}}get themeManager(){return this.C1}set themeManager(t){const i=this.C1;i!==t&&(Util.s(t,ThemeManager,Model,"themeManager"),i!==null&&i.removeDiagram(this),this.C1=t,t!==null&&t.addDiagram(this))}initializePartManager(t){}static SP(t,i){Diagram.mA.set(t,i)}static get licenseKey(){return Diagram.BP.last()}static set licenseKey(t){Diagram.BP.add(t.replace(/\s/g,""))}static get version(){return Diagram.xR}static BP=new List;static xR="3.0.12";wR(t){const i=Diagram.mA.get(t);return i!==null?new i:new PartManager}get j(){return this.eP}set j(t){this.eP=t}get Mx(){return this.uA}bR(t){if(t.model!==this.model)return;const i=t.change,e=t.propertyName;if(i===1&&e[0]==="S"){if(e==="StartingFirstTransaction"){const s=this,n=this.toolManager;n.mouseDownTools.each(o=>o.diagram=s),n.mouseMoveTools.each(o=>o.diagram=s),n.mouseUpTools.each(o=>o.diagram=s),this.routers.each(o=>o.diagram=s),!this.ks&&!this.io&&(this.Uf=!0,this.Yu&&(this.Ar=!0))}else if(e==="StartingUndo"||e==="StartingRedo"){const s=this.animationManager;this.skipsUndoManager||(s.defaultAnimation.isAnimating&&s.stopAnimation(),s.getBundleAnimation().isAnimating&&s.getBundleAnimation().stop()),this.B("ChangingSelection",this.selection)}else if(e==="StartedTransaction"){const s=this.animationManager;s.defaultAnimation.isAnimating&&!this.skipsUndoManager&&s.stopAnimation()}return}if(this.j){this.j=!1;try{if(t.modelChange===""&&i===1){(e==="FinishedUndo"||e==="FinishedRedo")&&(this.B("ChangedSelection",this.selection),this.Di());const s=this.animationManager;e==="RolledBackTransaction"&&s.stopAnimation(),this.rA(),this.Uf=!0,this.maybeUpdate(),(this.undoManager.transactionLevel===0||this.undoManager.transactionLevel===1)&&s.FM(),e==="CommittedTransaction"&&this.undoManager.isJustDiscarded&&(this.zs=Math.min(this.zs,this.undoManager.historyIndex-1)),(e==="CommittedTransaction"||e==="RolledBackTransaction")&&this.undoManager.Gw&&setTimeout(()=>{this.isModified=!1},1);const n=t.isTransactionFinished;if(n&&(this.YA(),this.Mx.clear(),this.animationManager.xF()),!this.Hx&&n&&this.lastInput.targetDiagram){this.Hx=!0;const o=this;Util.zh(()=>{o.currentTool.standardMouseOver(),o.Hx=!1},10)}}}finally{this.j=!0}}}get pe(){return this.iP}set pe(t){this.iP=t}get kf(){return this.qx}set kf(t){this.qx=t}DA(t){const i=t.D.h;for(const e of i)e instanceof Picture&&this.VP(e)}VP(t){const i=t.element;if(i===null||!(i instanceof HTMLImageElement)||(i.ls instanceof GSet&&i.ls.add(this),t.kR(),!i.y0))return;const e=i.getAttribute("src")||"",s=this._l.get(e);if(s===null){Picture.KA(t,i);const n=[];n.push(t),this._l.set(e,n)}else{for(let n=0;n0)&&Util.n("defaultScale must be larger than zero, not: "+t),this.e0=t}get autoScale(){return this.Jl}set autoScale(t){const i=this.Jl;i!==t&&(Util.tt(t,AutoScale,"AutoScale"),this.Jl=t,this.i("autoScale",i,t),t!==1&&this.Gs(!1))}get initialAutoScale(){return this.Fr}set initialAutoScale(t){const i=this.Fr;i!==t&&(Util.tt(t,AutoScale,"AutoScale"),this.Fr=t,this.i("initialAutoScale",i,t))}get initialViewportSpot(){return this.Vx}set initialViewportSpot(t){const i=this.Vx;i!==t&&(Util.s(t,Spot,Diagram,"initialViewportSpot"),t.isSpot()||Util.n("initialViewportSpot must be a specific Spot: "+t),this.Vx=t,this.i("initialViewportSpot",i,t))}get initialDocumentSpot(){return this.Bx}set initialDocumentSpot(t){const i=this.Bx;i!==t&&(Util.s(t,Spot,Diagram,"initialDocumentSpot"),t.isSpot()||Util.n("initialViewportSpot must be a specific Spot: "+t),this.Bx=t,this.i("initialDocumentSpot",i,t))}get minScale(){return this.Tx}set minScale(t){Util.r(t,Diagram,"minScale");const i=this.Tx;i!==t&&(t>0?(this.Tx=t,this.i("minScale",i,t),t>this.scale&&(this.scale=t)):Util.G(t,"> 0",Diagram,"minScale"))}get maxScale(){return this.Dx}set maxScale(t){Util.r(t,Diagram,"maxScale");const i=this.Dx;i!==t&&(t>0?(this.Dx=t,this.i("maxScale",i,t),t 0",Diagram,"maxScale"))}get zoomPoint(){return this.Fx}set zoomPoint(t){this.Fx.equals(t)||(Util.s(t,Point,Diagram,"zoomPoint"),t=t.L(),this.Fx=t)}get contentAlignment(){return this.Yf}set contentAlignment(t){const i=this.Yf;i.equals(t)||(Util.s(t,Spot,Diagram,"contentAlignment"),t=t.L(),this.Yf=t,this.i("contentAlignment",i,t),this.Gs(!1))}get initialContentAlignment(){return this.qm}set initialContentAlignment(t){const i=this.qm;i.equals(t)||(Util.s(t,Spot,Diagram,"initialContentAlignment"),t=t.L(),this.qm=t,this.i("initialContentAlignment",i,t))}get padding(){return this.ii}set padding(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Diagram,"padding");const i=this.ii;i.equals(t)||(t=t.L(),this.ii=t,this.invalidateDocumentBounds(),this.i("padding",i,t))}get partManager(){return this.dP}set partManager(t){const i=this.dP;i!==t&&(Util.s(t,PartManager,Diagram,"partManager"),t.diagram!==null&&Util.n("Cannot share PartManagers between Diagrams: "+t.toString()),i&&i.Oo(null),this.dP=t,t.Oo(this))}get nodes(){return this.partManager.nodes.iterator}get links(){return this.partManager.links.iterator}get parts(){return this.partManager.parts.iterator}findTopLevelNodesAndLinks(){const t=new GSet,i=this.nodes;for(;i.next();){const s=i.value;s.isTopLevel&&t.add(s)}const e=this.links;for(;e.next();){const s=e.value;s.isTopLevel&&t.add(s)}return t.iterator}findTopLevelGroups(){return this.vr.iterator}get routers(){return this.vf}doLinkRouting(t){this.Bo=!0;const i=this.vf.h;for(let e=0;e0){const l=this.computePartsBounds(n.memberParts,!1);l.inflate(20,20),s.I1(l)}const o=Rect.a(),r=n.memberParts;for(;r.next();){const l=r.value;l instanceof Node&&this.GP(l,e,o)}Rect.o(o)}s.ua=n,s.YP=e,s.Ko=!1}else t&&s.WA();return s}get avoidanceCellSize(){return this.aP}set avoidanceCellSize(t){this.Zl=null,this.aP=new Size(Math.max(1,t.width),Math.max(1,t.height))}get avoidanceLimit(){return this.fP}set avoidanceLimit(t){this.fP=Math.max(1,t)}jA(t){return t.canAvoid()?t:t.containingGroup!==null?this.jA(t.containingGroup):null}GP(t,i,e){if(t===i||!t.isVisible())return;const s=t.canAvoid();if(s){const n=t.getAvoidableRect(e);this.Zl.PR(n.x,n.y,n.width,n.height)}if(t instanceof Group&&(!s||t.avoidableMembers)){const n=t.memberParts;for(;n.next();){const o=n.value;o instanceof Node&&this.GP(o,i,e)}}}HP(t){this.Zl!==null&&!this.Zl.Ko&&(t===void 0||t.canAvoid())&&(this.Zl.Ko=!0)}get autoScrollInterval(){return this.jm}set autoScrollInterval(t){const i=this.jm;Util.r(t,Diagram,"autoScrollInterval"),i!==t&&(this.jm=t,this.i("autoScrollInterval",i,t))}get autoScrollRegion(){return this.Wm}set autoScrollRegion(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Diagram,"autoScrollRegion");const i=this.Wm;i.equals(t)||(t=t.L(),this.Wm=t,this.invalidateDocumentBounds(),this.i("autoScrollRegion",i,t))}doAutoScroll(t){this.t0.c(t),this.computeAutoScrollPosition(this.t0).equalsApprox(this.position)?this.stopAutoScroll():this.vA()}vA(){if(this.Kf!==-1)return;const t=this.jm,i=this;this.Kf=Util.zh(()=>{if(i.Kf===-1||(i.stopAutoScroll(),i.lastInput.event===null))return;const s=i.computeAutoScrollPosition(i.t0);if(s.equalsApprox(i.position))return;i.position=s,i.lastInput.documentPoint=i.transformViewToDoc(i.t0),i.doMouseMove(),i.ia=!0;const n=Rect.a();i.computeBounds(n),n.unionRect(i.documentBounds),i.UA(n),Rect.o(n),i.Ge=!0,i.maybeUpdate(),i.vA()},t)}stopAutoScroll(){this.Kf!==-1&&(Util.Kg(this.Kf),this.Kf=-1)}computeAutoScrollPosition(t){let i=this.position;const e=this.Wm;if(e.top<=0&&e.left<=0&&e.right<=0&&e.bottom<=0)return i;const s=this.viewportBounds,n=this.scale,o=Rect.H(0,0,s.width*n,s.height*n),r=Point.H(0,0);if(t.x>=o.x&&t.xo.x+o.width-e.right&&this.allowHorizontalScroll){let l=Math.max(this.scrollHorizontalLineChange,1);l=l|0,r.x+=l,t.x>o.x+o.width-e.right/2&&(r.x+=l),t.x>o.x+o.width-e.right/4&&(r.x+=4*l)}if(t.y>=o.y&&t.yo.y+o.height-e.bottom&&this.allowVerticalScroll){let l=Math.max(this.scrollVerticalLineChange,1);l=l|0,r.y+=l,t.y>o.y+o.height-e.bottom/2&&(r.y+=l),t.y>o.y+o.height-e.bottom/4&&(r.y+=4*l)}return r.equalsApprox(Point.Lo)||(i=new Point(i.x+r.x/n,i.y+r.y/n)),Rect.o(o),Point.o(r),i}makeSvg(t){this.Ql.has("SVG")||this.addRenderer("SVG",new SVGSurface(this,root.document));const i=new SVGSurface(this,root.document,!0);t===void 0&&(t={});const e=this;function s(n,o){const r=e.JA(n,"SVG",i),l=r!==null?r.svg:null;return typeof o=="function"?(o(l),null):l}return this.ZA(s,t)}makeSVG(t){return this.makeSvg(t)}addRenderer(t,i){this.Ql.set(t,i)}removeRenderer(t){this.Ql.delete(t)}cacheGroupExternalLinks(t){this.kP=t,t||this.nodes.each(i=>{i instanceof Group&&(i.x0=null)})}ZA(t,i){const e=i.callback;let s=!0;const o=this._l.iterator;for(;o.next();)if(!o.value[0].bn){s=!1;break}if(typeof e!="function"||s)return t(i,e,this);const r=this;function l(){const f=+new Date;for(s=!0,o.reset();o.next();)if(!o.value[0].bn){s=!1;break}if(s||f-a>h){t(i,e,r);return}root.requestAnimationFrame(l)}const h=i.callbackTimeout||300,a=+new Date;return root.requestAnimationFrame(()=>l()),null}makeImage(t){return Diagram.isUsingDOM()?(t===void 0&&(t={}),t.returnType="Image",this.makeImageData(t)):null}makeImageData(t){return t===void 0&&(t={}),this.ZA(this.NR,t)}static img="image";NR(t,i,e){const s=e.JA(t,"canvas",null);if(s===null)return null;const n=s.Y.canvas;let o=null;if(n!==null){let r=t.returnType;switch(r===void 0?r="string":r=r.toLowerCase(),r){case Diagram.img+"data":o=s.getImageData(0,0,n.width,n.height);break;case Diagram.img:const h=(t.document||document).createElement("img");h.src=n.toDataURL(t.type,t.details),o=h;break;case"blob":{const a=n;return typeof i!="function"&&(o="",Util.n('Error: Diagram.makeImageData called with "returnType: toBlob", but no required "callback" function property defined.')),typeof a.toBlob=="function"?(a.toBlob(i,t.type,t.details),"toBlob"):(i(null),null)}case"string":default:o=n.toDataURL(t.type,t.details)}}return typeof i=="function"?(i(o),null):o}static $A=!1;JA(t,i,e){if(this.animationManager.stopAnimation(),this.maybeUpdate(),this.xt===null)return null;typeof t!="object"&&Util.n("properties argument must be an Object.");let n=!1,o=t.size||null,r=t.scale||null;t.scale!==void 0&&isNaN(t.scale)&&(r="NaN");let l=t.maxSize;t.maxSize===void 0&&(n=!0,i==="SVG"?l=new Size(1/0,1/0):l=new Size(2e3,2e3));const h=t.position||null;let a=t.parts||null;Array.isArray(a)&&(a=new List(a));let f=t.padding===void 0?1:t.padding;const c=t.background||null;let u=t.omitTemporary;u===void 0&&(u=!0);const d=t.document||document,m=t.elementFinished||null;let g=t.showTemporary;g===void 0&&(g=!u);let p=t.showGrid;p===void 0&&(p=g),o!==null&&isNaN(o.width)&&isNaN(o.height)&&(o=null),typeof f=="number"?f=new Margin(f):f instanceof Margin||Util.n("MakeImage padding must be a Margin or a number."),f.left=Math.max(f.left,0),f.right=Math.max(f.right,0),f.top=Math.max(f.top,0),f.bottom=Math.max(f.bottom,0),this.ei.clearContextCache(!0);const y=new CanvasSurface(null,d,void 0,!0),x=y.di;if(!(o||r||a||h))return y.width=this.Ct+Math.ceil(f.left+f.right),y.height=this.At+Math.ceil(f.top+f.bottom),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.da=d,e.$u=m,this.D1(e.di,f,new Size(y.width,y.height),this.rt,this.gt,a,c,g,p),e.di):(this.ju=!1,this.D1(x,f,new Size(y.width,y.height),this.rt,this.gt,a,c,g,p),this.ju=!0,y.di);const k=this.e0,b=this.documentBounds.copy();if(b.subtractMargin(this.ii),g){const L=this.Jt.h,D=L.length;for(let F=0;Fk?(r=k,N=b.width,T=b.height):(N=l.width,T=l.height)):(N=b.width*r,T=b.height*r):(r=k,N=b.width,T=b.height),f!==null?(N+=M,T+=A):f=new Margin(0),l!==null){let L=l.width,D=l.height;i!=="SVG"&&n&&!Diagram.$A&&Debug&&(N>L||T>D)&&(Util.ht("Diagram.makeImage(data): Diagram width or height is larger than the default max size. ("+Math.ceil(N)+"x"+Math.ceil(T)+" vs 2000x2000) Consider increasing the max size."),Diagram.$A=!0),isNaN(L)&&(L=2e3),isNaN(D)&&(D=2e3),isFinite(L)&&(N=Math.min(N,L)),isFinite(D)&&(T=Math.min(T,D))}return y.width=Math.ceil(N),y.height=Math.ceil(T),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.da=d,e.$u=m,this.D1(e.di,f,new Size(Math.ceil(N),Math.ceil(T)),r,S,a,c,g,p),e.di):(this.ju=!1,this.D1(x,f,new Size(Math.ceil(N),Math.ceil(T)),r,S,a,c,g,p),this.ju=!0,y.di)}static Ju=null;static QA="5da73c80a36555d4038e4972187c3cae51fd22";static ww=!1;static Hk=()=>{if(Diagram.QA[5]===void 0&&(Transform.prototype.ns=Transform.prototype.Nw),!Diagram.isUsingDOM())return;const t=root.document.createElement("canvas"),i=t.getContext("2d"),e=Util.Fs("7ca11abfd022028846");i[e]=Util.Fs("398c3597c01238");const s="7ca11abfd7330390",n=[Diagram.QA,Util.ww+"4ae6247590da4bb21c324ba3a84e385776",Transform.Hk+"fb236cdfda5de14c134ba1a95a2d4c7cc6f93c1387",Geo.za],o=10,r=0;for(let l=1;l<5;l++)i[Util.Fs(s)](Util.Fs(n[l-1]),o,l*15+r);i[e]=Util.Fs("39f046ebb36e4b");for(let l=1;l<5;l++)i[Util.Fs(s)](Util.Fs(n[l-1]),o,l*15+r);(n.length!==4||n[0][0]!=="5"||n[3][0]!=="7")&&(Transform.prototype.ns=Transform.prototype.Nw),Diagram.Ju=t}}class DiagramHelper{_A;tL;qP;De;constructor(t){if(this._A=null,this.tL="63ad05bbe23a1786468a4c741b6d2",this.qP="@onz",this.tL===this._tk){this.qP=!0,this.De=this.qP;return}this.De=null}CR(t,i){let e="f";const s=root[Util.Fs("76a715b2f73f148a")][Util.Fs("72ba13b5")]||"",n=Util.Fs;if(this.De=!0,!Diagram.isUsingDOM())return;let o=Diagram[n("76a115b6ed251eaf4692")];if(!o){const l=s[n("76ad18b4f73e")];for(let a=s[n("73a612b6fb191d")](n("35e7"))+2;a=0&&ha[0]||h[0]===a[0]&&h[1]>=a[1]))continue;const f="73a612b6fb191d",c=root[n("74a900bae4370f8b51")][n("6fbb13a1c2311e8a57")].toLowerCase(),u=c[n(f)](n("3aad1ab6e022098b4dc4")),d=n(l[2]);if(u>-1){const P=c[n(f)](d.toLowerCase()+"/");if(this.De=!(P>-1&&P=0&&g-1),!this.De))return;const p=root[Util.Fs("76a715b2f73f148a")][Util.Fs("69ad17a1e03e")],y=p[n(f)](n("7fb002b6ed25128b4da25b2e"));if(y>-1&&(this.De=!(p[n(f)](d)>y),!this.De))return;const x=d;if(x[0]!=="#")continue;const k=root.document.createElement("div");let b=l[0].replace(/[A-Za-z]/g,"");for(;b.length<4;)b+="9";const S=b;b=b.substring(b.length-4);let M="";const A=["gsh","gsf"],C=["Header","Background","Display","Feedback"];if(M+=A[parseInt(b.substring(0,1),10)%2],M+=C[parseInt(b.substring(0,1),10)%4],k[n("79a417a0f0181a8946")]=M,root.document[n("78a712aa")]){root.document[n("78a712aa")][n("7bb806b6ed32388c4a875b")](k);const P=root.getComputedStyle(k).getPropertyValue(n("78a704b7e62456904c9b12701b6532a8")),N=root.getComputedStyle(k).getPropertyValue(n("75b817b0ea2202"));if(root.document[n("78a712aa")][n("68ad1bbcf533388c4a875b")](k),!P)continue;const T=root[n("77a902b0eb1b1e804a8a")],L="0."+parseInt(S,10)%100;if(N===L||P.indexOf(parseInt(x[1]+x[2],16))!==-1&&P.indexOf(parseInt(x[3]+x[4],16))!==-1){this.De=!1;return}else if(T&&T(n("32ae19a1e0331fc94084537c067a67fa59f1386b89d006")).matches){M="."+M;for(let D=0;D{const s=this.observed;if(s===null)return;const n=s.viewportBounds,o=this.lastInput.documentPoint;s.position=new Point(o.x-n.width/2,o.y-n.height/2)},this.vP=s=>{this.invalidateDocumentBounds(),this.k0()},this.JP=s=>{this.observed!==null&&(this.invalidateDocumentBounds(),this.T())},this.z1=s=>{this.updateDelay<1?this.T():this.b0||(this.b0=!0,setTimeout(()=>this.redraw(),this.updateDelay))},this.ZP=s=>{this.observed!==null&&this.k0()},this.autoScale=2,this.$t=!1,i&&Object.assign(this,i),this}setupRouters(){}computePixelRatio(){return 1}redraw(){this.b0&&this.updateDelay>=1&&(this.b0=!1,this.AR()),super.redraw()}Ji(){if(this.Ot===null&&Util.n("No div specified"),this.xt===null&&Util.n("No canvas specified"),this.xt instanceof SVGSurface||(this.box.jM(),!this.Ge))return;const t=this.observed;if(t===null||t.animationManager.defaultAnimation.isAnimating||!t.Kh)return;this.g0();const i=this.xt,e=this.ei;if(e.clearContextCache(!0),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,i.width,i.height),this.updateDelay<1)this.eL();else if(this._f!==null){e.drawImage(this._f.Vt,0,0);const o=this.O;e.scale(this.Gi,this.Gi),e.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),e.commitTransform()}const s=this.Jt.h,n=s.length;for(let o=0;on.canDelete())}t.removeParts(i,!0),t.B("SelectionDeleted",i)}finally{t.commitTransaction("Delete"),t.B("ChangedSelection",t.selection),t.currentCursor=""}}canDeleteSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowDelete||t.selection.count===0)}copySelection(){const t=this.diagram;try{const i=new GSet,e=t.selection.iterator;for(;e.next();){const s=e.value;Part.lh(i,s,!0,this.copiesTree?1/0:0,this.copiesConnectedLinks,n=>n.canCopy())}this.copyToClipboard(i)}finally{}}canCopySelection(){const t=this.diagram;return!(!t.allowCopy||!t.allowClipboard||t.selection.count===0)}cutSelection(){this.copySelection(),this.deleteSelection()}canCutSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowCopy||!t.allowDelete||!t.allowClipboard||t.selection.count===0)}copyToClipboard(t){const i=this.diagram;let e=null;if(t===null)Diagram.bA();else{const s=i.model;let n=!1,o=!1,r=null;try{s.Pf()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.Sf()||s.Qu())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=i.copyParts(t,null,!0)}finally{s.Pf()&&(s.copiesParentKeyOfNodeData=n),(s.Sf()||s.Qu())&&(s.copiesGroupKeyOfNodeData=o),e=new List,e.addAll(r.iteratorValues),Diagram.f0=e,Diagram.A1=i.model.dataFormat}}i.B("ClipboardChanged",e)}pasteFromClipboard(){const t=new GSet,i=Diagram.f0;if(i===null)return t;const e=this.diagram;if(Diagram.A1!==e.model.dataFormat)return t;const s=e.model;let n=!1,o=!1,r=null;try{s.Pf()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.Sf()||s.Qu())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=e.copyParts(i,e,!1)}finally{s.Pf()&&(s.copiesParentKeyOfNodeData=n),(s.Sf()||s.Qu())&&(s.copiesGroupKeyOfNodeData=o);const l=r.iterator;for(;l.next();){const h=l.value,a=l.key;h.location.isReal()||(a.location.isReal()?h.location=a.location:!h.position.isReal()&&a.position.isReal()&&(h.position=a.position)),t.add(h)}}return t}pasteSelection(t){t===void 0&&(t=null);const i=this.diagram;try{i.currentCursor="wait",i.B("ChangingSelection",i.selection),i.startTransaction("Paste");const e=this.pasteFromClipboard();e.count>0&&i.clearSelection(!0);const s=e.iterator;for(;s.next();){const n=s.value;n.isSelected=!0}if(t!==null){const n=i.computePartsBounds(i.selection);if(n.isReal()){const o=this.computeEffectiveCollection(i.selection,i.M1);i.LS(o,new Point(t.x-n.centerX,t.y-n.centerY),i.M1,!1)}}i.B("ClipboardPasted",e)}finally{i.commitTransaction("Paste"),i.B("ChangedSelection",i.selection),i.currentCursor=""}}canPasteSelection(t){const i=this.diagram;return!(i.isReadOnly||i.isModelReadOnly||!i.allowInsert||!i.allowClipboard||Diagram.f0===null||Diagram.f0.count===0||Diagram.A1!==i.model.dataFormat)}undo(){this.diagram.undoManager.undo()}canUndo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canUndo()}redo(){this.diagram.undoManager.redo()}canRedo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canRedo()}decreaseZoom(t){t===void 0&&(t=1/this.zoomFactor),Util.r(t,CommandHandler,"decreaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canDecreaseZoom(t){t===void 0&&(t=1/this.zoomFactor),Util.r(t,CommandHandler,"canDecreaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}increaseZoom(t){t===void 0&&(t=this.zoomFactor),Util.r(t,CommandHandler,"increaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canIncreaseZoom(t){t===void 0&&(t=this.zoomFactor),Util.r(t,CommandHandler,"canIncreaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}resetZoom(t){t===void 0&&(t=this.defaultScale),Util.r(t,CommandHandler,"resetZoom:newscale");const i=this.diagram;ti.maxScale||(i.scale=t)}canResetZoom(t){t===void 0&&(t=this.defaultScale),Util.r(t,CommandHandler,"canResetZoom:newscale");const i=this.diagram;return ti.maxScale?!1:i.allowZoom}zoomToFit(){const t=this.diagram,i=t.animationManager;i.stopAnimation(),t.redraw();const e=t.position,s=t.scale;i.El("Zoom To Fit"),this.isZoomToFitRestoreEnabled&&s===this.Y1&&!isNaN(this.X1)&&t.documentBounds.equals(this.K1)?(t.scale=this.X1,t.position=this.h2,this.Y1=NaN,this.K1=Rect.kw):(this.X1=s,this.h2=e.copy(),t.zoomToFit(),this.Y1=t.scale,this.K1=t.documentBounds.copy()),i.FM()}canZoomToFit(){return this.diagram.allowZoom}scrollToPart(t){t===void 0&&(t=null),t!==null&&Util.s(t,Part,CommandHandler,"part");const i=this.diagram;if(i.ensureBounds(),t===null){try{this.Uo!==null&&(this.Uo.next()?t=this.Uo.value:this.Uo=null)}catch{this.Uo=null}t===null&&(i.highlighteds.count>0?this.Uo=i.highlighteds.iterator:i.selection.count>0&&(this.Uo=i.selection.iterator),this.Uo!==null&&this.Uo.next()&&(t=this.Uo.value))}if(t!==null){const e=i.animationManager;e.El("Scroll To Part");const s=this.scrollToPartPause;if(s>0){const n=this.tc(t,[t]);if(n.length===1)i.startTransaction(),i.centerRect(t.actualBounds),i.commitTransaction("Scroll To Part");else{const o=()=>{i.startTransaction();let l=n.pop();for(;n.length>0&&l instanceof Node&&l.isTreeExpanded&&(!(l instanceof Group)||l.isSubGraphExpanded);)l=n.pop();n.length>0?(l instanceof Part&&i.scrollToRect(l.actualBounds),l instanceof Node&&!l.isTreeExpanded&&(l.isTreeExpanded=!0),l instanceof Group&&!l.isSubGraphExpanded&&(l.isSubGraphExpanded=!0)):(l instanceof Part&&i.centerRect(l.actualBounds),i.removeDiagramListener("LayoutCompleted",r)),i.commitTransaction("Scroll To Part")},r=()=>{Util.zh(o,(e.isEnabled?e.duration:0)+s)};i.addDiagramListener("LayoutCompleted",r),o()}}else{const n=i.position.copy();i.centerRect(t.actualBounds),n.equalsApprox(i.position)&&e.stopAnimation()}}}tc(t,i){if(t.isVisible())return i;if(t instanceof Adornment)this.tc(t.adornedPart,i);else if(t instanceof Link){const e=t.fromNode;e!==null&&this.tc(e,i);const s=t.toNode;s!==null&&this.tc(s,i)}else{if(t instanceof Node){const s=t.labeledLink;s!==null&&this.tc(s,i);const n=t.findTreeParentNode();n!==null&&(!n.isTreeExpanded&&!n.wasTreeExpanded&&i.push(n),this.tc(n,i))}const e=t.containingGroup;e!==null&&(!e.isSubGraphExpanded&&!e.wasSubGraphExpanded&&i.push(e),this.tc(e,i))}return i}canScrollToPart(t){if(t===void 0&&(t=null),t!==null&&!(t instanceof Part))return!1;const i=this.diagram;return i.selection.count===0&&i.highlighteds.count===0?!1:i.allowHorizontalScroll&&i.allowVerticalScroll}collapseTree(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse Tree";try{i.startTransaction(e),i.animationManager.El(e);const n=new List;if(t!==null&&t.isTreeExpanded)t.collapseTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&r.isTreeExpanded&&(r.collapseTree(),n.add(r))}}i.B("TreeCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||!t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(!s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}expandTree(t){t===void 0&&(t=null);const i=this.diagram,e="Expand Tree";try{i.startTransaction(e),i.animationManager.El(e);const n=new List;if(t!==null&&!t.isTreeExpanded)t.expandTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&(r.isTreeExpanded||(r.expandTree(),n.add(r)))}}i.B("TreeExpanded",n)}finally{i.commitTransaction(e)}}canExpandTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}groupSelection(){const t=this.diagram,i=t.model;if(!i.ga())return;const e=this.archetypeGroupData;if(e===null)return;let s=null;try{t.currentCursor="wait",t.B("ChangingSelection",t.selection),t.startTransaction("Group");const n=new List,o=t.selection.iterator;for(;o.next();){const h=o.value;h.Ae()&&h.canGroup()&&n.add(h)}const r=new List,l=n.iterator;for(;l.next();){const h=l.value;let a=!1;const f=n.iterator;for(;f.next();){const c=f.value;if(h.isMemberOf(c)){a=!0;break}}a||r.add(h)}if(r.count>0){let h=r.first().containingGroup;if(h!==null)for(;h!==null;){let a=!1;const f=r.iterator;for(;f.next();)if(!f.value.isMemberOf(h)){a=!0;break}if(a)h=h.containingGroup;else break}if(e instanceof Group)e.ci(),s=e.copy(),s!==null&&t.add(s);else if(i.isGroupForData(e)){const a=i.copyNodeData(e);Util.Mt(a)&&(i.addNodeData(a),s=t.findNodeForData(a))}if(s!==null){h!==null&&this.isValidMember(h,s)&&(s.containingGroup=h);const a=r.iterator;for(;a.next();){const f=a.value;this.isValidMember(s,f)&&(f.containingGroup=s)}t.clearSelection(!0),s.isSelected=!0}}t.B("SelectionGrouped",s)}finally{t.commitTransaction("Group"),t.B("ChangedSelection",t.selection),t.currentCursor=""}}canGroupSelection(){const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowGroup||!t.model.ga()||this.archetypeGroupData===null)return!1;const e=t.selection.iterator;for(;e.next();){const s=e.value;if(s.Ae()&&s.canGroup())return!0}return!1}c2(t){const i=Util.at();if(Array.isArray(t))t.forEach(n=>{n instanceof Link||n instanceof Part&&i.push(n)});else{const n=t.iterator;for(;n.next();){const o=n.value;o instanceof Link||o instanceof Part&&i.push(o)}}const e=new GSet,s=i.length;for(let n=0;n0){i.clearSelection(!0);const o=s.iterator;for(;o.next();){const r=o.value;r.expandSubGraph();const l=r.containingGroup,h=l!==null&&l.data!==null?e.getKeyForNodeData(l.data):void 0;n.addAll(r.memberParts);const a=n.iterator;for(;a.next();){const f=a.value;if(f.isSelected=!0,f instanceof Link)continue;const c=f.data;c!==null?e.setGroupForData(c,h):f.containingGroup=l}i.remove(r)}}i.B("SelectionUngrouped",s,n)}finally{i.commitTransaction("Ungroup"),i.B("ChangedSelection",i.selection),i.currentCursor=""}}canUngroupSelection(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowDelete||!i.allowUngroup||!i.model.ga())return!1;if(t!==null){if(!(t instanceof Group))return!1;if(t.canUngroup())return!0}else{const s=i.selection.iterator;for(;s.next();){const n=s.value;if(n instanceof Group&&n.canUngroup())return!0}}return!1}addTopLevelParts(t,i){const e=this.c2(t);let s=!0;const n=e.iterator;for(;n.next();){const o=n.value;o.containingGroup!==null&&(!i||this.isValidMember(null,o)?o.containingGroup=null:s=!1)}return s}collapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse SubGraph";try{i.startTransaction(e),i.animationManager.El(e);const n=new List;if(t!==null&&t.isSubGraphExpanded)t.collapseSubGraph(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&r.isSubGraphExpanded&&(r.collapseSubGraph(),n.add(r))}}i.B("SubGraphCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||!t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&s.isSubGraphExpanded)return!0}}return!1}expandSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Expand SubGraph",s=new List;try{if(i.startTransaction(e),i.animationManager.El(e),t!==null&&!t.isSubGraphExpanded)t.expandSubGraph(),s.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&(r.isSubGraphExpanded||(r.expandSubGraph(),s.add(r)))}}i.B("SubGraphExpanded",s)}finally{for(const n of s)this.sL(i,n);t&&this.sL(i,t),i.commitTransaction(e)}}sL(t,i){for(const e of i.memberParts)e instanceof Node&&t.Of(e,i)}canExpandSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&!s.isSubGraphExpanded)return!0}}return!1}editTextBlock(t){t===void 0&&(t=null),t!==null&&Util.s(t,TextBlock,CommandHandler,"editTextBlock");const i=this.diagram,e=i.toolManager.findTool("TextEditing");if(e!==null){if(t===null){let s=null;const n=i.selection.iterator;for(;n.next();){const o=n.value;if(o.canEdit()){s=o;break}}if(s===null)return;t=s.findInVisualTree(o=>o instanceof TextBlock&&o.editable)}t!==null&&(i.currentTool=null,e.textBlock=t,i.currentTool=e)}}canEditTextBlock(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowTextEdit||i.toolManager.findTool("TextEditing")===null)return!1;if(t!==null){if(!(t instanceof TextBlock))return!1;const e=t.part;if(e!==null&&e.canEdit())return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s.canEdit()&&(t=s.findInVisualTree(n=>n instanceof TextBlock&&n.editable),t!==null))return!0}}return!1}showContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");if(e===null)return;t===void 0&&(i.selection.count>0?t=i.selection.first():t=i);const s=e.findObjectWithContextMenu(t);if(s!==null){const n=i.lastInput;let o=null;if(s instanceof GraphObject)o=s.getDocumentPoint(Spot.Center);else if(!i.viewportBounds.containsPoint(n.documentPoint)){const r=i.viewportBounds;o=new Point(r.x+r.width/2,r.y+r.height/2)}if(o!==null){const r=new InputEvent;r.diagram=i,r.viewPoint=i.transformDocToView(o),r.documentPoint=o,r.button=2,r.up=!0,i.lastInput=r}i.currentTool=e,e.openMenu(!1,s)}}canShowContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");return!(e===null||(t===void 0&&(i.selection.count>0?t=i.selection.first():t=i),e.findObjectWithContextMenu(t)===null))}get copiesClipboardData(){return this.$P}set copiesClipboardData(t){Util.t(t,"boolean",CommandHandler,"copiesClipboardData"),this.$P=t}get copiesConnectedLinks(){return this.QP}set copiesConnectedLinks(t){Util.t(t,"boolean",CommandHandler,"copiesConnectedLinks"),this.QP=t}get deletesConnectedLinks(){return this._P}set deletesConnectedLinks(t){Util.t(t,"boolean",CommandHandler,"deletesConnectedLinks"),this._P=t}get copiesTree(){return this.t2}set copiesTree(t){Util.t(t,"boolean",CommandHandler,"copiesTree"),this.t2=t}get deletesTree(){return this.i2}set deletesTree(t){Util.t(t,"boolean",CommandHandler,"deletesTree"),this.i2=t}get copiesParentKey(){return this.e2}set copiesParentKey(t){Util.t(t,"boolean",CommandHandler,"copiesParentKey"),this.e2=t}get copiesGroupKey(){return this.s2}set copiesGroupKey(t){Util.t(t,"boolean",CommandHandler,"copiesGroupKey"),this.s2=t}get archetypeGroupData(){return this.o2}set archetypeGroupData(t){t!==null&&Util.t(t,"object",CommandHandler,"archetypeGroupData");const i=this.diagram;if(Debug){const e=i.model;e.ga()&&!(t instanceof Group)&&!e.isGroupForData(t)&&Util.n("CommandHandler.archetypeGroupData must be either a Group or a data object for which GraphLinksModel.isGroupForNodeData is true: "+t)}this.o2=t}get memberValidation(){return this.rh}set memberValidation(t){t!==null&&Util.t(t,"function",CommandHandler,"memberValidation"),this.rh=t}get defaultScale(){return this.diagram.defaultScale}set defaultScale(t){this.diagram.defaultScale=t}get zoomFactor(){return this.l2}set zoomFactor(t){Util.r(t,CommandHandler,"zoomFactor"),t>1||Util.n("zoomFactor must be larger than 1.0, not: "+t),this.l2=t}get isZoomToFitRestoreEnabled(){return this.a2}set isZoomToFitRestoreEnabled(t){Util.t(t,"boolean",CommandHandler,"isZoomToFitRestoreEnabled"),this.a2=t}get scrollToPartPause(){return this.f2}set scrollToPartPause(t){Util.r(t,CommandHandler,"scrollToPartPause"),this.f2=t}computeEffectiveCollection(t,i){const e=this.diagram,s=e.toolManager.findTool("Dragging"),n=e.currentTool===s;i===void 0&&(i=e.p0());const o=new GMap;if(t===null)return o;let r=t.iterator;for(;r.next();){const l=r.value;e._r(o,l,n,i)}if(e.draggedLink!==null&&i.dragsLink)return o;for(r=t.iterator;r.next();){const l=r.value;if(l instanceof Link){const h=l.fromNode;if(h!==null&&!o.has(h))o.delete(l);else{const a=l.toNode;a!==null&&!o.has(a)&&o.delete(l)}}}return o}}var Stretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Vertical=4]="Vertical",w[w.Horizontal=5]="Horizontal",w[w.Fill=2]="Fill",w))(Stretch||{}),Orientation=(w=>(w[w.None=0]="None",w[w.Along=21]="Along",w[w.Plus90=22]="Plus90",w[w.Minus90=23]="Minus90",w[w.Opposite=24]="Opposite",w[w.Upright=25]="Upright",w[w.Plus90Upright=26]="Plus90Upright",w[w.Minus90Upright=27]="Minus90Upright",w[w.Upright45=28]="Upright45",w))(Orientation||{}),Flip=(w=>(w[w.None=0]="None",w[w.Vertical=1]="Vertical",w[w.Horizontal=2]="Horizontal",w[w.Both=3]="Both",w))(Flip||{});class GraphObject{l;_u;td;Go;g;hh;Z;gt;he;_t;ed;Hs;Ft;qe;il;ah;Pi;ma;rt;jt;el;Fi;Hi;sd;ai;ic;Ut;hi;sl;U1;fh;nd;constructor(){GSet.vi(this),this.l=30723,this._t=1,this.ed="",this.Hs=null,this.Ft=null,this.gt=new Point(NaN,NaN).w(),this.qe=Size.xw,this.il=new Transform,this.ah=new Transform,this.Pi=null,this.ma=1,this.rt=1,this.jt=0,this.el=Margin.Hg,this.he=new Rect(NaN,NaN,NaN,NaN).w(),this.Fi=new Rect(NaN,NaN,NaN,NaN).w(),this.Hi=new Rect(0,0,NaN,NaN).w(),this.sd=null,this._u=null,this.Z=null,this.ai=Spot.Default,this.ic=Spot.Default,this.td=0,this.Go=0,this.Ut=null,this.g=null,this.hh=null,this.hi=null,this.U1=null,this.fh=null,this.sl=null,this.nd=null}cloneProtected(t){t.l=(this.l|2048|4096)&-32769,t._t=this._t,t.ed=this.ed,t.Ft=this.Ft,t.gt.c(this.gt),t.qe=this.qe.L(),this.Pi!==null?t.Pi=this.Pi.copy():t.Pi=null,t.rt=this.rt,t.jt=this.jt,t.el=this.el.L(),t.he.c(this.he),t.Fi.c(this.Fi),t.Hi.c(this.Hi),t._u=this._u,this.Z!==null&&(t.Z=this.Z.copy()),t.ai=this.ai.L(),t.ic=this.ic.L(),t.td=this.td,t.Go=this.Go,this.Ut!==null&&(t.Ut=this.Ut.copy()),this.g!==null&&(this.g.wi?t.g=this.g:t.g=this.g.copy()),this.hh!==null&&(t.hh=this.hh.slice()),this.hi!==null&&(t.hi=this.hi.copy())}addCopyProperty(t){let i=this.hh;if(!Array.isArray(i))i=[],this.hh=i;else for(let e=0;e{d.data!==null&&d.u2()&&d.updateTargetBindings(i)})}}}}SF(t){this.nd.delete(t)}Yo(){if(this.diagram===null)return;if(this.findBindingPanel()===null&&this.Ri!==null){const i=this.Ri.iterator;for(;i.next();){const e=i.value;if(!e.isToTheme)continue;let s=null;const n=e.sourceName;e.isToObject&&(s=this.nL(n));let o=this;const r=e.targetId;r!==-1&&(o=this.S0(r),o===null)||(n==="/"?s=o.part:n==="."?s=o:n===".."&&(s=o.panel),e.updateTarget(o,s))}}}Sa(t,i){const e=this.findBindingPanel();if(e!==null){const s=this.Ri.iterator;for(;s.next();){const n=s.value;let o=null;if(n.isToObject){if(o=n.oL(e,this),o===null)continue;n.updateSource(this,o,i,null)}else if(n.isToModel){const r=t.diagram;r!==null&&!r.pe&&n.updateSource(this,r.model.modelData,i,e)}else if(!n.isToTheme){const r=e.data;if(r===null)continue;const l=t.diagram;l!==null&&!l.pe&&n.updateSource(this,r,i,e)}if(o===this){const r=n.targetId,l=e.S0(r);l!==null&&n.updateTarget(l,o,i)}}}}S0(t){return this.eo===t?this:null}nL(t){let i;return t===""?i=this:t==="/"?i=this:t==="."?i=this:t===".."?i=this:(i=this.part.findObject(t),i===null&&Debug&&Util.ht("Binding error: missing GraphObject named "+t+" in "+this.part.toString())),i}get eo(){return this.g!==null?this.g.eo:-1}set eo(t){this.eo!==t&&(this.g===null&&(this.g=new GraphObjectTemplateSettings),this.g.eo=t)}get Ri(){return this.g!==null?this.g.Ri:null}set Ri(t){this.Ri!==t&&(this.g===null&&(this.g=new GraphObjectTemplateSettings),this.g.Ri=t)}get so(){return this.g!==null?this.g.so:null}set so(t){this.so!==t&&(this.g===null&&(this.g=new GraphObjectTemplateSettings),this.g.so=t)}raiseChanged(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}i(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}no(t,i,e,s){const n=this.he;if(n.e(t,i,e,s),this.rt!==1||this.jt!==0){this.Pi===null&&(this.Pi=new Transform);const o=this.Pi;o.Vi(),this.M0(o,t,i,e,s),o.Cw(n)}}rL(t,i,e){return this.pickable===!1?!1:(e.af(this.O),i?this.intersectsRect(t,e):this.containedInRect(t,e))}lL(t,i,e){if(this.pickable===!1)return!1;const s=this.naturalBounds,n=t.distanceSquaredPoint(i);return e?Point.distanceLineSegmentSquared(t.x,t.y,0,0,0,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,0,s.height,s.width,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,s.height,s.width,0)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,0,0,0)<=n:t.distanceSquared(0,0)<=n&&t.distanceSquared(0,s.height)<=n&&t.distanceSquared(s.width,0)<=n&&t.distanceSquared(s.width,s.height)<=n}kn(){return!0}containsPoint(t){Debug&&Util.s(t,Point,GraphObject,"containsPoint:p");const i=Point.a();i.c(t),this.O.Pt(i);const e=this.actualBounds;if(!e.isReal())return Point.o(i),!1;const s=this.diagram;if(s!==null&&s.o0){const o=s.getInputOption("extraTouchThreshold"),r=s.getInputOption("extraTouchArea"),l=r/2,h=this.naturalBounds,a=this.getDocumentScale()*s.scale,f=1/a;if(h.width*ae&&(c=t),isFinite(i)&&i>s&&(u=i);break;case 5:isFinite(t)&&t>e&&(c=t),u=0,d&&(i=1/0);break;case 4:isFinite(i)&&i>s&&(u=i),c=0,d&&(t=1/0);break}const g=this.maxSize,p=this.minSize;c>g.width&&p.widthg.height&&p.heightu.height||this.xi>u.width)&&(r=!0)}}}r?this.l|=256:this.l&=-257,this.Fi.isReal()||Util.n("Non-real actualBounds has been set. Object "+this+", actualBounds: "+this.Fi.toString()),this.hd(o,this.Fi),this.oo(!1),Rect.o(o)}dh(t,i,e,s){}commonArrange(t,i,e,s){if(this.Fi.e(t,i,e,s),this.desiredSize.isReal())return;const n=this.he,o=this.el,r=o.right+o.left,l=o.top+o.bottom,h=n.width+r,a=n.height+l;e+=r,s+=l;let f=this.qs(!0);switch(h===e&&a===s&&(f=0),f){case 0:(h>e||a>s)&&(this.ye(!0),this.wt(h>e?e:h,a>s?s:a,0,0));break;case 2:this.ye(!0),this.wt(e,s,0,0);break;case 5:this.ye(!0),this.wt(e,a,0,0);break;case 4:this.ye(!0),this.wt(h,s,0,0);break}}hd(t,i){const e=this.part;e!==null&&e.diagram!==null&&((e.selectionObject===this||e.resizeObject===this||e.rotateObject===this)&&e.d2(!0),this.T(),!t.equalsApproxClose(i)&&(e.gh(),this.A0(e)))}A0(t){this.portId!==null&&(t.d2(!0),t instanceof Node&&t.hL(this))}get shadowVisible(){return this.g!==null?this.g.L0:null}set shadowVisible(t){const i=this.shadowVisible;i!==t&&(Debug&&t!==null&&Util.t(t,"boolean",GraphObject,"shadowVisible"),this.Zt(),this.g.L0=t,this.hs(!0),this.T(),this.i("shadowVisible",i,t))}DR(t,i){const e=this.naturalBounds,s=this.ah,n=s.m11,o=s.m21,r=s.dx,l=s.m12,h=s.m22,a=s.dy;let f=0,c=0,u=f,d=c;f=u*n+d*o+r,c=u*l+d*h+a;let m=f,g=c,p=0,y=0;u=e.width+i,d=0,f=u*n+d*o+r,c=u*l+d*h+a;let x=Math.min(m,f),k=Math.min(g,c);p=Math.max(m+p,f)-x,y=Math.max(g+y,c)-k,m=x,g=k,u=e.width+i,d=e.height+i,f=u*n+d*o+r,c=u*l+d*h+a,x=Math.min(m,f),k=Math.min(g,c),p=Math.max(m+p,f)-x,y=Math.max(g+y,c)-k,m=x,g=k,u=0,d=e.height+i,f=u*n+d*o+r,c=u*l+d*h+a,x=Math.min(m,f),k=Math.min(g,c),p=Math.max(m+p,f)-x,y=Math.max(g+y,c)-k,m=x,g=k;const b=t.viewportBounds,S=b.x,M=b.y,A=b.width,C=b.height;return m>A+S||S>p+m||g>C+M||M>y+g}Ji(t,i){if(this.FR(t,i)||!this.visible)return;const e=this.opacity;if(e===0)return;let s=1;e!==1&&(s=t.globalAlpha,t.globalAlpha=s*e);let n="";this.filter!==""&&(n=t.filter,t.filter=this.filter);const o=this.O,r=this.panel;this.P0()===!0&&this.G1();const l=this.part;let h=!1,a=0;if(l&&i.getRenderingHint("drawShadows")&&(h=l.isShadowed,h)){const g=l.shadowOffset;a=Math.max(g.y,g.x)*i.scale*i.Gi}const f=this instanceof Panel&&this.nl(),c=this.Fi;if(f&&(this.aL(h,t,!1,r),this.RR(t,i),this.fL(h,t,!1,r),this.cL(h,t,!1)),f||!f&&(c.width===0||c.height===0||isNaN(c.x)||isNaN(c.y))){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}const u=this.js();if(!i.ea&&u&&this.DR(i,a)){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}let d=(this.l&256)!==0;if(t.clipInsteadOfFill&&(d=!1),this instanceof TextBlock&&(t.font=this.font),d){const g=r.kn()?r.naturalBounds:r.actualBounds;let p=Math.max(c.x,g.x),y=Math.max(c.y,g.y),x=Math.min(c.right,g.right)-p,k=Math.min(c.bottom,g.bottom)-y;const b=this.hi;if(b!==null&&(p=b.x,y=b.y,x=b.width,k=b.height),p>c.width+c.x||c.x>g.width+g.x){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}t.save(),t.beginPath(),t.rect(p,y,x,k),t.clip()}if(u){if(!l.isVisible()){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}if(h){const g=l.shadowOffset;t.shadowsSet(g.x*i.scale*this.scale*i.Gi,g.y*i.scale*this.scale*i.Gi,l.shadowBlur),t.shadowsOn(),t.shadowColor=l.shadowColor}}const m=this.naturalBounds;if(t.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.aL(h,t,u,r),this.Ft!==null&&(t.commitTransform(),this.H1(t,m,c)),this.fL(h,t,u,r),this.mh(t,i),this.cL(h,t,u),d&&(t.restore(),t.clearContextCache(this instanceof Panel)),!o.Gk()){const g=1/(o.m11*o.m22-o.m12*o.m21);t.transform(o.m22*g,-o.m12*g,-o.m21*g,o.m11*g,g*(o.m21*o.dy-o.m22*o.dx),g*(o.m12*o.dx-o.m11*o.dy))}e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n)}aL(t,i,e,s){t&&this.shadowVisible===!0?i.shadowsOn():t&&this.shadowVisible===!1&&i.shadowsOff(),t&&this.q1(s)&&this.shadowVisible===null&&i.shadowsOff()}fL(t,i,e,s){t&&(this.Ft!==null||this.q1(s))?(this.j1(!0),this.shadowVisible===null&&i.shadowsOff()):this.j1(!1)}cL(t,i,e){t&&this.g2()===!0&&i.shadowsOn(),e&&t&&i.shadowsOff()}IR(t,i,e){const s=this.part;let n=!1;s&&t.getRenderingHint("drawShadows")&&(n=s.isShadowed),i.clipInsteadOfFill&&(n=!1),this.js()&&n&&i.shadowsOn(),n&&this.shadowVisible===!0?i.shadowsOn():n&&this.shadowVisible===!1&&i.shadowsOff();const o=this.panel;if(n&&this.q1(o)&&this.shadowVisible===null&&i.shadowsOff(),i.ol){const r=t.computePixelRatio(),l=`drop-shadow(${i.shadowOffsetX/r}px ${i.shadowOffsetY/r}px ${i.shadowBlur/r/2}px ${i.shadowColor})`;this.background!==null&&e.Ft.setAttributeNS(null,"filter",l)}return n&&(this.Ft!==null||this.q1(o))?(this.j1(!0),this.shadowVisible===null&&i.shadowsOff()):this.j1(!1),n}OR(t,i,e,s){if(e.ol){const n=i.computePixelRatio(),o=`drop-shadow(${e.shadowOffsetX/n}px ${e.shadowOffsetY/n}px ${e.shadowBlur/n/2}px ${e.shadowColor})`;this.m2(t,o)}s&&this.g2()===!0&&e.shadowsOn(),this.js()&&e.shadowsOff()}q1(t){return t===null?!1:(t.nl()&&(t=t.panel),t.g2()||(t.type===Panel.Auto||t.type===Panel.Spot)&&t.findMainElement()!==this)}m2(t,i){}H1(t,i,e){const s=this.N0(),n=i.x,o=i.y,r=i.width+s,l=i.height+s;this.wn(t,this.Ft,!0,!1,i,e),this.Ft instanceof Brush&&this.Ft.type===3?(t.beginPath(),t.rect(n-s/2,o-s/2,r,l),t.fillContext(this.Ft,!1,null)):t.fillRect(n-s/2,o-s/2,r,l)}uL(t,i){let e=t.ER(this);const s=t.fh!==null?t.fh:t.svg;if(e!==-1)if(e===0)if(s.Ft)s.Ft.after(i);else if(t.type===Panel.Table){const n=s.getElementsByClassName("gojs-ts"),o=n.length!==0?n[0]:null;o!==null&&o.after(i)}else s.prepend(i);else{for(;e!==0&&!t.elt(e-1).isVisibleObject();)e--;if(e===0)s.prepend(i);else{const n=t.elt(e-1).svg;n!==null?n.after(i):s.appendChild(i)}}}FR(t,i){if(!(t instanceof SVGContext))return!1;if(!this.visible||this.opacity===0)return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;if(this.js()&&!this.isVisible())return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;const e=this.panel,s=this.ad(t);if(this.oc(t,i,s))return this.dL(this.svg),this.svg.parentElement!==null?(this.js()&&(t.lastDrawnPart=this.svg),!0):(this.js()?(t.lastDrawnPart!==null?t.lastDrawnPart.after(this.svg):t.diagramGroup.prepend(this.svg),t.lastDrawnPart=this.svg):e&&this.uL(e,this.svg),!0);if(this.js()&&this.isShadowed){const m=this.shadowOffset;t.shadowsSet(m.x*i.scale*this.scale*i.Gi,m.y*i.scale*this.scale*i.Gi,this.shadowBlur),t.shadowsOn(),t.shadowColor=this.shadowColor}this instanceof TextBlock&&(t.font=this.font),t.currentElement=null;const n=this.O,o=this instanceof Panel,r=this instanceof Panel?this.nl():!1,l=this.svg;this.P0()===!0&&this.G1();const h=this.Fi;if(t.setCurrentTransform(1,0,0,1,0,0),t.outerGroup=!1,s)if(t.outerGroup=!0,o&&r)t.newGroup(1,0,0,1,0,0),this.svg=t.lastCreatedElement;else if(o&&this.isClipping){const m=this.findMainElement();let g=0,p=0;m!==null&&(g=m.actualBounds.x,p=m.actualBounds.y),t.newGroup(n.m11,n.m12,n.m21,n.m22,n.dx+g,n.dy+p),this.svg=t.lastCreatedElement,m!==null&&t.createOrUpdateClipGroup(this,m.actualBounds),t.currentElement=t.lastCreatedElement}else o?(t.newGroup(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.svg=t.lastCreatedElement):t.newGroup(1,0,0,1,0,0);const a=this.naturalBounds;o||t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.background!==null&&(o?(r&&t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.H1(t,a,h),r&&t.setCurrentTransform(1,0,0,1,0,0)):(t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.H1(t,a,h)),t.currentElement.Ft=t.lastCreatedElement,t.currentElement.prepend(t.lastCreatedElement));const f=this.IR(i,t,t.currentElement);this.mh(t,i),o&&t.endGroup(),t.outerGroup&&t.endGroup();const c=t.surface.$u,u=o?this.svg:t.currentElement;if(!o&&l!==null&&u!==l&&l.parentNode===this.panel.svg){const m=this.svg.getAttribute("filter");return m!==null&&u.setAttribute("filter",m),this.svg.replaceWith(u),this.svg=u,u!==null&&this.T0(t,e,h,u),t.gL(l),!0}if(this.svg=u,c!==null&&u===null&&t.dummyGroup(),u===null)return!0;this.T0(t,e,h,u),this.OR(u,i,t,f);const d=this.js()?this.opacity*t.globalAlpha:this.opacity;if(d!==1&&u.setAttributeNS(null,"opacity",d.toString()),this.filter!==""&&u.setAttributeNS(null,"filter",this.filter),this.js()){if(l!==null&&u!==l&&l.parentNode===t.diagramGroup){const m=l.getAttribute("filter");m!==null&&u.setAttribute("filter",m),l.replaceWith(u)}else t.lastDrawnPart?t.lastDrawnPart.after(u):t.diagramGroup.prepend(u);t.lastDrawnPart=u}else e!==null&&this.uL(e,u);return c!==null&&c(this,u),this.dL(u),!0}dL(t){const i=this,e=t.dataset;i instanceof GraphObject&&(i.portId!==null&&(e.portId=i.portId),i instanceof Panel&&(isNaN(i.itemIndex)||(e.itemIndex=i.itemIndex.toString()),i instanceof Part&&(e.className=Util.hn(i),i.key!==void 0&&(e.key=i.key.toString()),i.containingGroup!==null&&(e.group=i.containingGroup.key.toString()),i instanceof Link&&(i.fromNode!==null&&i.fromNode.key!==void 0&&(e.fromKey=i.fromNode.key.toString()),i.fromPortId!==""&&(e.fromPortId=i.fromPortId),i.toNode!==null&&i.toNode.key!==void 0&&(e.toKey=i.toNode.key.toString()),i.toPortId!==""&&(e.toPortId=i.toPortId)))))}T0(t,i,e,s){let n=(this.l&256)!==0;if(t.clipInsteadOfFill&&(n=!1),!n){s.removeAttributeNS(null,"clip-path"),t.gL(s);return}const o=i.kn()?i.naturalBounds:i.actualBounds;let r=Math.max(e.x,o.x),l=Math.max(e.y,o.y),h=Math.min(e.right,o.right)-r,a=Math.min(e.bottom,o.bottom)-l;const f=this.hi;f!==null&&(r=f.x,l=f.y,h=f.width,a=f.height);const c=t.BR(s);if(c===null){const u="CLIP"+GSet.fu++,d={id:u},m=t.makeElement("clipPath",d),g=t.makeElement("rect",{x:r,y:l,width:h,height:a});if(this instanceof Panel){const p=this.O.copy().Pw();g.setAttribute("transform",`matrix(${p.m11}, ${p.m12}, ${p.m21}, ${p.m22}, ${p.dx}, ${p.dy})`)}m.appendChild(g),t.svg.appendChild(m),s.setAttributeNS(null,"clip-path","url(#"+u+")")}else{const u=c.firstElementChild;u.setAttribute("x",r.toString()),u.setAttribute("y",l.toString()),u.setAttribute("width",h.toString()),u.setAttribute("height",a.toString())}}VR(){if(this.svg===null)return;const t=this.svg.innerHTML.match(/url\(#((CLIP|GRAD).+?)\)/g),i=this.svg.ownerDocument;if(t!==null)for(const e of t){const s=i.getElementById(e.split("#")[1].slice(0,-1));s!==null&&s.remove()}this.svg.remove()}RR(t,i){const e=this.Fi,s=this.Hi,n=this.Ft;n!==null&&t.commitTransform(),n!==null&&(this.wn(t,n,!0,!1,s,e),n instanceof Brush&&n.type===3?(t.beginPath(),t.rect(e.x,e.y,e.width,e.height),t.fillContext(n,!1,null)):t.fillRect(e.x,e.y,e.width,e.height)),this.mh(t,i)}mh(t,i){}D0(){this.hs(!0)}oc(t,i,e){const s=this.svg;if(this.zR()){if(this.D0(),this.hs(!1),s===null)return!1;const f=this.svg.getAttribute("clip-path");if(f!==null&&f.includes("url")){const c=t.svg.getElementById(f.split("#")[1].slice(0,-1));c!==null&&c.remove()}return!1}if(s===null)return!1;if(!this.visible)return s.remove(),!1;if(s.nodeName!=="g"&&e||s.nodeName==="g"&&!e)return!1;const n=this.O,o="matrix("+n.m11+", "+n.m12+", "+n.m21+", "+n.m22+", "+n.dx+", "+n.dy+")",r=this instanceof Panel,l=r?this.nl():!1;if(!(r&&l))if(this instanceof Picture){const f=this.W1;t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),f!==null&&t.amendImageTransform(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7]),e?s.lastElementChild.setAttributeNS(null,"transform",t.getCurrentTransform()):s.setAttributeNS(null,"transform",t.getCurrentTransform())}else if(e&&!r)if(this instanceof Shape){const f=s.getElementsByTagName("path");for(let c=0;c=.1;){if(g){for(l=o[d++%h],l-=r;l<0;)l+=o[d++%h],m=!m;g=!1}else l=o[d++%h];l>u&&(l=u);let p=Math.sqrt(l*l/(1+c*c));a<0&&(p=-p),i+=p,e+=c*p,m?t.lineTo(i,e):t.moveTo(i,e),u-=l,m=!m}}wn(t,i,e,s,n,o){let r=1,l=1;if(typeof i=="string"){e?t.fillStyle=i:t.strokeStyle=i;return}else if(i.type===1){e?t.fillStyle=i.color:t.strokeStyle=i.color;return}let h;const a=this.N0();r=n.width,l=n.height,s?(r=o.width,l=o.height):e||(r+=a,l+=a);const f=t instanceof CanvasSurfaceContext;if(f&&i.Sn&&(i.type===4||i.rc===r&&i.v1===l))h=i.Sn;else{let c=0,u=0,d=0,m=0,g=0,p=0,y=0,x=0;if(s?(y=o.x,x=o.y):e||(y-=a/2,x-=a/2),c=i.start.x*r+i.start.offsetX+y,u=i.start.y*l+i.start.offsetY+x,d=i.end.x*r+i.end.offsetX+y,m=i.end.y*l+i.end.offsetY+x,i.type===2)h=t.createLinearGradient(c,u,d,m);else if(i.type===3)p=isNaN(i.endRadius)?Math.max(r,l)/2:i.endRadius,isNaN(i.startRadius)?(g=0,p=Math.max(r,l)/2):g=i.startRadius,h=t.createRadialGradient(c,u,g,d,m,p);else if(i.type===4)try{h=t.createPattern(i.pattern,"repeat")}catch{h=null}else Util.Bi(i.type,"Brush type");if(i.type!==4){const k=i.colorStops;if(k!==null){const b=k.iterator;for(;b.next();)h.addColorStop(b.key,b.value)}}if(f&&(i.Sn=h,h!==null&&(i.rc=r,i.v1=l),h===null&&i.type===4&&i.rc!==-1)){i.rc=-1;const k=this.diagram;k!==null&&i.rc===-1&&Util.zh(()=>{k.redraw()},600)}}e?t.fillStyle=h:t.strokeStyle=h}isContainedBy(t){return t instanceof Panel?this.XR(this,t):!1}XR(t,i){if(t===i||i===null)return!1;let e=t.panel;for(;e!==null;){if(e===i)return!0;e=e.panel}return!1}isVisibleObject(){if(!this.visible)return!1;const t=this.panel;return t!==null?t.isVisibleObject():!0}isEnabledObject(){let t=this instanceof Panel?this:this.panel;for(;t!==null&&t.isEnabled;)t=t.panel;return t===null}get enabledChanged(){return this.g!==null?this.g.F0:null}set enabledChanged(t){const i=this.enabledChanged;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"enabledChanged"),this.Zt(),this.g.F0=t,this.i("enabledChanged",i,t))}G1(){if(this.J1()===!0){const t=this.il;if(t.Vi(),!this.Fi.isReal()||!this.he.isReal()){this.fd(!1);return}if(t.Es(this.Fi.x-this.he.x,this.Fi.y-this.he.y),this.scale!==1||this.angle!==0){const i=this.naturalBounds;this.M0(t,i.x,i.y,i.width,i.height)}this.fd(!1),this.Ma(!0)}if(this.P0()===!0){const t=this.panel;if(t===null)this.ah.set(this.il),this.ma=this.scale;else if(t.Ks!==null){const i=this.ah;i.Vi(),t.kn()?i.af(t.ah):t.panel!==null&&i.af(t.panel.ah),i.af(this.il),this.ma=this.scale*t.ma}this.Ma(!1)}}M0(t,i,e,s,n){if(this.rt!==1&&t.rt(this.rt),this.jt===0)return;const o=Point.a();o.setSpot(i,e,s,n,Spot.Center),t.ms(this.jt,o.x,o.y),Point.o(o)}u(t){if(this.Xo())return;t===void 0&&(t=!1),this.ye(!0),this.oo(!0);const i=this.panel;i!==null&&!t&&i.u()}lc(){this.Xo()||(this.ye(!0),this.oo(!0))}hc(t){if(this.rs())return;const i=this.panel;!t&&i!==null&&i.u(),this.oo(!0)}ld(){this.J1()===!1&&(this.fd(!0),this.Ma(!0))}p2(){this.Ma(!0)}T(){const t=this.part;t!==null&&t.T()}qs(t){const i=this.stretch,e=this.panel;if(e===null)return this.qo(i===1?0:i,t);if(e.type===Panel.Table)return this.R0(e.getRowDefinition(this.row),e.getColumnDefinition(this.column),t);if(e.type===Panel.Auto&&e.findMainElement()===this)return this.qo(2,t);if(i===1){if(e.type===Panel.Spot&&e.findMainElement()===this)return this.qo(2,t);const s=e.defaultStretch;return s===1?this.qo(0,t):this.qo(s,t)}return this.qo(i,t)}R0(t,i,e){const s=this.stretch;if(s!==1)return this.qo(s,e);let n=null,o=null;switch(t.stretch){case 1:case 5:break;case 4:o=!0;break;case 2:o=!0;break}switch(i.stretch){case 1:case 4:break;case 5:n=!0;break;case 2:n=!0;break}const r=this.panel.defaultStretch;return n===null&&(n=r===5||r===2),o===null&&(o=r===4||r===2),n===!0&&o===!0?this.qo(2,e):n===!0?this.qo(5,e):o===!0?this.qo(4,e):this.qo(0,e)}qo(t,i){if(i)return t;if(t===0)return 0;const e=this.desiredSize;if(e.isReal())return 0;const s=!isNaN(e.width),n=!isNaN(e.height),o=this.angle;if(s)if(o!==90&&o!==270){if(t===5)return 0;if(t===2)return 4}else{if(t===4)return 0;if(t===2)return 5}if(n)if(o!==90&&o!==270){if(t===4)return 0;if(t===2)return 5}else{if(t===5)return 0;if(t===2)return 4}return t}get segmentOrientation(){return this.Ut!==null?this.Ut.I0:0}set segmentOrientation(t){const i=this.segmentOrientation;i!==t&&(Debug&&Util.tt(t,Orientation,"Orientation"),this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.I0=t,this.u(),this.i("segmentOrientation",i,t),t===0&&(this.angle=0))}YR(){this.segmentOrientation=21}get segmentIndex(){return this.Ut!==null?this.Ut.O0:-1/0}set segmentIndex(t){Debug&&Util.t(t,"number",GraphObject,"segmentIndex"),t=Math.round(t);const i=this.segmentIndex;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.O0=t,this.u(),this.i("segmentIndex",i,t))}get segmentFraction(){return this.Ut!==null?this.Ut.E0:0}set segmentFraction(t){Debug&&Util.t(t,"number",GraphObject,"segmentFraction"),isNaN(t)||t<0?t=0:t>1&&(t=1);const i=this.segmentFraction;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.E0=t,this.u(),this.i("segmentFraction",i,t))}get segmentOffset(){return this.Ut!==null?this.Ut.B0:Point.Lo}set segmentOffset(t){const i=this.segmentOffset;i.equals(t)||(Debug&&Util.s(t,Point,GraphObject,"segmentOffset"),t=t.L(),this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.B0=t,this.u(),this.i("segmentOffset",i,t))}get stretch(){return this.g!==null?this.g.ro:1}set stretch(t){const i=this.stretch;i!==t&&(this.Zt(),this.g.ro=t,this.u(),this.i("stretch",i,t))}get name(){return this.g!==null?this.g.Tt:""}set name(t){const i=this.name;i!==t&&(Debug&&Util.t(t,"string",GraphObject,"name"),this.Zt(),this.g.Tt=t,this.part!==null&&this.part.V0(),this.i("name",i,t))}get opacity(){return this._t}set opacity(t){const i=this._t;if(i!==t){Util.t(t,"number",GraphObject,"opacity"),(t<0||t>1)&&Util.G(t,"0 <= value <= 1",GraphObject,"opacity"),this._t=t,this.i("opacity",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.T(s.Zh(s.actualBounds))}}get filter(){return this.ed}set filter(t){Debug&&Util.t(t,"string",GraphObject,"filter");const i=this.ed;if(i!==t){this.ed=t,this.hs(!0),this.i("filter",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.T(s.Zh(s.actualBounds))}}get visible(){return(this.l&1)!==0}set visible(t){const i=(this.l&1)!==0;if(i!==t){Debug&&Util.t(t,"boolean",GraphObject,"visible"),this.l=this.l^1,this.i("visible",i,t);const e=this.panel;e!==null?e.u():this.js()&&this.Ki(t),this.T(),this.mL()}}get pickable(){return(this.l&2)!==0}set pickable(t){const i=(this.l&2)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"pickable"),this.l=this.l^2,this.i("pickable",i,t))}get fromLinkableDuplicates(){return(this.l&4)!==0}set fromLinkableDuplicates(t){const i=(this.l&4)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"fromLinkableDuplicates"),this.l=this.l^4,this.i("fromLinkableDuplicates",i,t))}get fromLinkableSelfNode(){return(this.l&8)!==0}set fromLinkableSelfNode(t){const i=(this.l&8)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"fromLinkableSelfNode"),this.l=this.l^8,this.i("fromLinkableSelfNode",i,t))}get toLinkableDuplicates(){return(this.l&16)!==0}set toLinkableDuplicates(t){const i=(this.l&16)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"toLinkableDuplicates"),this.l=this.l^16,this.i("toLinkableDuplicates",i,t))}get toLinkableSelfNode(){return(this.l&32)!==0}set toLinkableSelfNode(t){const i=(this.l&32)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"toLinkableSelfNode"),this.l=this.l^32,this.i("toLinkableSelfNode",i,t))}get isPanelMain(){return(this.l&64)!==0}set isPanelMain(t){const i=(this.l&64)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"isPanelMain"),this.l=this.l^64,this.u(),this.i("isPanelMain",i,t))}get isActionable(){return(this.l&128)!==0}set isActionable(t){const i=(this.l&128)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"isActionable"),this.l=this.l^128,this.i("isActionable",i,t))}get background(){return this.Ft}set background(t){const i=this.Ft;i!==t&&(t!==null&&Brush.cd(t,"GraphObject.background"),t instanceof Brush&&t.w(),this.Ft=t,this.T(),this.i("background",i,t))}g2(){return(this.l&512)!==0}j1(t){t?this.l|=512:this.l&=-513}sc(){return(this.l&1024)!==0}w2(t){t?this.l|=1024:this.l&=-1025}J1(){return(this.l&2048)!==0}fd(t){t?this.l|=2048:this.l&=-2049}P0(){return(this.l&4096)!==0}Ma(t){t?this.l|=4096:this.l&=-4097}Xo(){return(this.l&8192)!==0}ye(t){t?this.l|=8192:this.l&=-8193}rs(){return(this.l&16384)!==0}oo(t){t?this.l|=16384:this.l&=-16385}zR(){return(this.l&32768)!==0}hs(t){t?this.l|=32768:this.l&=-32769}get part(){if(this.js())return this;if(this.sl!==null)return this.sl;let t=this;for(t=t.panel;t;){if(t instanceof Part)return this.sl=t,t;t=t.panel}return null}get svg(){return this.U1}set svg(t){this.U1=t}Vu(){this.svg=null}get panel(){return this.Hs}Pa(t){this.Hs=t,this.svg!==null&&this.svg.remove()}get layer(){const t=this.part;return t!==null?t.layer:null}get diagram(){const t=this.part;return t!==null?t.diagram:null}get position(){return this.gt}set position(t){Debug&&Util.s(t,Point,GraphObject,"position");const i=t.x,e=t.y,s=this.gt,n=s.x,o=s.y;n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e))?(t=t.copy(),this.b2(t,n,o)&&this.i("position",new Point(n,o),t)):this.k2()}k2(){}b2(t,i,e){return this.gt=t,this.hc(),!0}Lf(t,i,e){this.gt.x===t&&this.gt.y===i||(this.gt.e(t,i),this.ld())}get actualBounds(){return this.Fi}get scale(){return this.rt}set scale(t){const i=this.rt;i!==t&&(Debug&&Util.r(t,GraphObject,"scale"),t<=0&&Util.n("GraphObject.scale for "+this+" must be greater than zero, not: "+t),this.rt=t,this.u(),this.i("scale",i,t))}get angle(){return this.jt}set angle(t){const i=this.jt;if(i!==t){if(Debug&&Util.r(t,GraphObject,"angle"),t=t%360,t<0&&(t+=360),i===t)return;this.jt=t,this.mL(),this.u(),this.i("angle",i,t)}}get desiredSize(){return this.qe}set desiredSize(t){Debug&&Util.s(t,Size,GraphObject,"desiredSize");const i=t.width,e=t.height,s=this.qe,n=s.width,o=s.height;if((n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e)))&&(t=t.L(),this.qe=t,this.u(),this instanceof Shape&&this.le(),this.i("desiredSize",s,t),this.sc())){const r=this.part;r!==null&&(this.Sa(r,"width"),this.Sa(r,"height"))}}get width(){return this.qe.width}set width(t){const i=this.qe.width;if(i!==t&&(!isNaN(i)||!isNaN(t))){Debug&&Util.t(t,"number",GraphObject,"width");const e=this.qe,s=new Size(t,this.qe.height).w();if(this.qe=s,this.u(),this instanceof Shape&&this.le(),this.i("desiredSize",e,s),this.sc()){const n=this.part;n!==null&&this.Sa(n,"width")}}}get height(){return this.qe.height}set height(t){const i=this.qe.height;if(i!==t&&(!isNaN(i)||!isNaN(t))){Debug&&Util.t(t,"number",GraphObject,"height");const e=this.qe,s=new Size(this.qe.width,t).w();if(this.qe=s,this.u(),this instanceof Shape&&this.le(),this.i("desiredSize",e,s),this.sc()){const n=this.part;n!==null&&this.Sa(n,"height")}}}get minSize(){return this.g!==null?this.g.Pr:Size.hf}set minSize(t){const i=this.minSize;i.equals(t)||(Debug&&Util.s(t,Size,GraphObject,"minSize"),t=t.copy(),isNaN(t.width)&&(t.width=0),isNaN(t.height)&&(t.height=0),t.w(),this.Zt(),this.g.Pr=t,this.u(),this.i("minSize",i,t))}get maxSize(){return this.g!==null?this.g.Nr:Size.Xk}set maxSize(t){const i=this.maxSize;i.equals(t)||(Debug&&Util.s(t,Size,GraphObject,"maxSize"),t=t.copy(),isNaN(t.width)&&(t.width=1/0),isNaN(t.height)&&(t.height=1/0),t.w(),this.Zt(),this.g.Nr=t,this.u(),this.i("maxSize",i,t))}get measuredBounds(){return this.he}get naturalBounds(){return this.Hi}N0(){return 0}get margin(){return this.el}set margin(t){typeof t=="number"?t=new Margin(t):Debug&&Util.s(t,Margin,GraphObject,"margin");const i=this.el;i.equals(t)||(t=t.L(),this.el=t,this.u(),this.i("margin",i,t))}get O(){return this.J1()===!0&&this.G1(),this.il}get Ks(){return this.P0()===!0&&this.G1(),this.ah}trigger(t,i,e){let s=null;return typeof t=="string"?s=new AnimationTrigger(t,i,e):s=t,s.Ce=this,this.Ss===null&&(this.Ss=new GMap),this.Ss.set(s.propertyName,s),this}get Ss(){return this.g!==null?this.g.Ss:null}set Ss(t){this.Ss!==t&&(this.Zt(),this.g.Ss=t)}get Mr(){return this.g!==null?this.g.Mr:0}set Mr(t){this.Mr!==t&&(this.Zt(),this.g.Mr=t)}get alignment(){return this.ai}set alignment(t){const i=this.ai;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"alignment"),t.isNoSpot()&&!t.isDefault()&&Util.n("GraphObject.alignment for "+this+" must be a real Spot or Spot.Default, not: "+t),t=t.L(),this.ai=t,this.hc(),this.i("alignment",i,t))}get column(){return this.Go}set column(t){Debug&&Util.r(t,GraphObject,"column"),t=Math.round(t);const i=this.Go;i!==t&&(t<0&&Util.G(t,">= 0",GraphObject,"column"),this.Go=t,this.u(),this.i("column",i,t),this.svg!==null&&this.svg.remove())}get columnSpan(){return this.g!==null?this.g.z0:1}set columnSpan(t){Debug&&Util.t(t,"number",GraphObject,"columnSpan"),t=Math.round(t);const i=this.columnSpan;i!==t&&(t<1&&Util.G(t,">= 1",GraphObject,"columnSpan"),this.Zt(),this.g.z0=t,this.u(),this.i("columnSpan",i,t))}get row(){return this.td}set row(t){Debug&&Util.r(t,GraphObject,"row"),t=Math.round(t);const i=this.td;i!==t&&(t<0&&Util.G(t,">= 0",GraphObject,"row"),this.td=t,this.u(),this.i("row",i,t),this.svg!==null&&this.svg.remove())}get rowSpan(){return this.g!==null?this.g.X0:1}set rowSpan(t){Debug&&Util.t(t,"number",GraphObject,"rowSpan"),t=Math.round(t);const i=this.rowSpan;i!==t&&(t<1&&Util.G(t,">= 1",GraphObject,"rowSpan"),this.Zt(),this.g.X0=t,this.u(),this.i("rowSpan",i,t))}get spanAllocation(){return this.g!==null?this.g.Y0:null}set spanAllocation(t){const i=this.spanAllocation;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"spanAllocation"),this.Zt(),this.g.Y0=t,this.u(),this.i("spanAllocation",i,t))}get alignmentFocus(){return this.ic}set alignmentFocus(t){const i=this.ic;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"alignmentFocus"),Debug&&t.isNoSpot()&&!t.isDefault()&&!(t.isNone()&&this instanceof Node)&&Util.n("GraphObject.alignmentFocus must be a real Spot or Spot.Default, not: "+t),t=t.L(),this.ic=t,this.u(),this.i("alignmentFocus",i,t))}get portId(){return this._u}set portId(t){const i=this._u;if(i!==t){Debug&&t!==null&&Util.t(t,"string",GraphObject,"portId");const e=this.part;e!==null&&!(e instanceof Node)&&Util.n("Cannot set portID on a Link: "+t);const s=e;i!==null&&s!==null&&s.S2(this),this._u=t,t!==null&&s!==null&&(s.Mn=!0,s.pL(this)),this.i("portId",i,t)}}Na(){const t=this.part;if(t instanceof Node&&(this.portId!==null||this===t.port)){const i=t.diagram;i!==null&&!i.undoManager.isUndoingRedoing&&t.hL(this)}}mL(){const t=this.diagram;t===null||t.undoManager.isUndoingRedoing||(this instanceof Panel?this instanceof Node?this.invalidateConnectedLinks():this.walkVisualTreeFrom(this,i=>{i.Na()}):this.Na())}get toSpot(){return this.Z!==null?this.Z.ya:Spot.None}set toSpot(t){const i=this.toSpot;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"toSpot"),t=t.L(),this.je(),this.Z.ya=t,this.i("toSpot",i,t),this.Na())}get toEndSegmentLength(){return this.Z!==null?this.Z.xa:10}set toEndSegmentLength(t){const i=this.toEndSegmentLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"toEndSegmentLength"),t<0&&Util.G(t,">= 0",GraphObject,"toEndSegmentLength"),this.je(),this.Z.xa=t,this.i("toEndSegmentLength",i,t),this.Na())}get toShortLength(){return this.Z!==null?this.Z.ka:0}set toShortLength(t){const i=this.toShortLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"toShortLength"),this.je(),this.Z.ka=t,this.i("toShortLength",i,t),this.Na())}get toLinkable(){return this.Z!==null?this.Z.K0:null}set toLinkable(t){const i=this.toLinkable;i!==t&&(Debug&&t!==null&&Util.t(t,"boolean",GraphObject,"toLinkable"),this.je(),this.Z.K0=t,this.i("toLinkable",i,t))}get toMaxLinks(){return this.Z!==null?this.Z.U0:1/0}set toMaxLinks(t){const i=this.toMaxLinks;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"toMaxLinks"),t<0&&Util.G(t,">= 0",GraphObject,"toMaxLinks"),this.je(),this.Z.U0=t,this.i("toMaxLinks",i,t))}get fromSpot(){return this.Z!==null?this.Z.pa:Spot.None}set fromSpot(t){const i=this.fromSpot;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"fromSpot"),t=t.L(),this.je(),this.Z.pa=t,this.i("fromSpot",i,t),this.Na())}get fromEndSegmentLength(){return this.Z!==null?this.Z.wa:10}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"fromEndSegmentLength"),t<0&&Util.G(t,">= 0",GraphObject,"fromEndSegmentLength"),this.je(),this.Z.wa=t,this.i("fromEndSegmentLength",i,t),this.Na())}get fromShortLength(){return this.Z!==null?this.Z.ba:0}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"fromShortLength"),this.je(),this.Z.ba=t,this.i("fromShortLength",i,t),this.Na())}get fromLinkable(){return this.Z!==null?this.Z.G0:null}set fromLinkable(t){const i=this.fromLinkable;i!==t&&(Debug&&t!==null&&Util.t(t,"boolean",GraphObject,"fromLinkable"),this.je(),this.Z.G0=t,this.i("fromLinkable",i,t))}get fromMaxLinks(){return this.Z!==null?this.Z.H0:1/0}set fromMaxLinks(t){const i=this.fromMaxLinks;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"fromMaxLinks"),t<0&&Util.G(t,">= 0",GraphObject,"fromMaxLinks"),this.je(),this.Z.H0=t,this.i("fromMaxLinks",i,t))}get cursor(){return this.g!==null?this.g.Al:""}set cursor(t){const i=this.cursor;i!==t&&(Util.t(t,"string",GraphObject,"cursor"),this.Zt(),this.g.Al=t,this.i("cursor",i,t))}get click(){return this.g!==null?this.g.Or:null}set click(t){const i=this.click;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"click"),this.Zt(),this.g.Or=t,this.i("click",i,t))}get doubleClick(){return this.g!==null?this.g.Er:null}set doubleClick(t){const i=this.doubleClick;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"doubleClick"),this.Zt(),this.g.Er=t,this.i("doubleClick",i,t))}get contextClick(){return this.g!==null?this.g.Br:null}set contextClick(t){const i=this.contextClick;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"contextClick"),this.Zt(),this.g.Br=t,this.i("contextClick",i,t))}get mouseEnter(){return this.g!==null?this.g.Kr:null}set mouseEnter(t){const i=this.mouseEnter;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseEnter"),this.Zt(),this.g.Kr=t,this.i("mouseEnter",i,t))}get mouseLeave(){return this.g!==null?this.g.Ur:null}set mouseLeave(t){const i=this.mouseLeave;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseLeave"),this.Zt(),this.g.Ur=t,this.i("mouseLeave",i,t))}get mouseOver(){return this.g!==null?this.g.Vr:null}set mouseOver(t){const i=this.mouseOver;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseOver"),this.Zt(),this.g.Vr=t,this.i("mouseOver",i,t))}get mouseHover(){return this.g!==null?this.g.zr:null}set mouseHover(t){const i=this.mouseHover;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseHover"),this.Zt(),this.g.zr=t,this.i("mouseHover",i,t))}get mouseHold(){return this.g!==null?this.g.Xr:null}set mouseHold(t){const i=this.mouseHold;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseHold"),this.Zt(),this.g.Xr=t,this.i("mouseHold",i,t))}get mouseDragEnter(){return this.g!==null?this.g.q0:null}set mouseDragEnter(t){const i=this.mouseDragEnter;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseDragEnter"),this.Zt(),this.g.q0=t,this.i("mouseDragEnter",i,t))}get mouseDragLeave(){return this.g!==null?this.g.j0:null}set mouseDragLeave(t){const i=this.mouseDragLeave;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseDragLeave"),this.Zt(),this.g.j0=t,this.i("mouseDragLeave",i,t))}get mouseDrop(){return this.g!==null?this.g.Yr:null}set mouseDrop(t){const i=this.mouseDrop;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseDrop"),this.Zt(),this.g.Yr=t,this.i("mouseDrop",i,t))}get actionDown(){return this.g!==null?this.g.W0:null}set actionDown(t){const i=this.actionDown;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionDown"),this.Zt(),this.g.W0=t,this.i("actionDown",i,t))}get actionMove(){return this.g!==null?this.g.v0:null}set actionMove(t){const i=this.actionMove;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionMove"),this.Zt(),this.g.v0=t,this.i("actionMove",i,t))}get actionUp(){return this.g!==null?this.g.J0:null}set actionUp(t){const i=this.actionUp;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionUp"),this.Zt(),this.g.J0=t,this.i("actionUp",i,t))}get actionCancel(){return this.g!==null?this.g.Z0:null}set actionCancel(t){const i=this.actionCancel;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionCancel"),this.Zt(),this.g.Z0=t,this.i("actionCancel",i,t))}get toolTip(){return this.g!==null?this.g.Gr:null}set toolTip(t){const i=this.toolTip;i!==t&&(Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("GraphObject.toolTip must be an Adornment or HTMLInfo."),this.Zt(),this.g.Gr=t,this.i("toolTip",i,t))}get contextMenu(){return this.g!==null?this.g.Hr:null}set contextMenu(t){const i=this.contextMenu;i!==t&&(Debug&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("GraphObject.contextMenu must be an Adornment or HTMLInfo."),this.Zt(),this.g.Hr=t,this.i("contextMenu",i,t))}findBindingPanel(){let t=this instanceof Panel?this:this.panel;for(;t!==null;){if(t.M2())return t;t=t.panel}return null}bind(t,i,e,s){return this.ac(t,i,e,s),this}bindTwoWay(t,i,e,s){return this.ac(t,i,e,s).makeTwoWay(),this}bindModel(t,i,e,s){return this.ac(t,i,e,s).ofModel(),this}bindObject(t,i,e,s,n){return this.ac(t,i,e,s).ofObject(n),this}theme(t,i,e,s,n){return this.ph(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.ph(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.ph(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.ph(t,i,e,s,n).ofModel(),this}ac(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.$0(n),n}ph(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.$0(o),o}$0(t){t.Ce=this;const i=this.findBindingPanel();i!==null&&i.yL()&&Util.n("Cannot add a Binding to a template that has already been copied: "+t),this.Ri===null&&(this.Ri=new List),this.Ri.add(t)}set(t){if(Debug)for(const i in t)(i.startsWith("_")||i.indexOf(".")!==-1)&&Util.n("Property with underscore or period passed to GraphObject.set. Did you mean to use GraphObject.attach?");return Object.assign(this,t),this}attach(t){return GraphObject.P2(this,t),this}apply(t){return t(this),this}setProperties(t){return Diagram.m0(this,t),this}static build(t,i,...e){const s=GraphObject.Q0.get(t);if(typeof s=="function"){const n=s([t].concat(e));if(n instanceof GraphObject)return i&&n.setProperties(i),n}Util.n('GraphObject.build invoked object builder "'+t+'", but it did not return an Object')}static make(t,...i){let e=arguments,s=null,n=null;if(typeof t=="function")n=t;else if(typeof t=="string"){const r=GraphObject.Q0.get(t);typeof r=="function"?(e=Array.prototype.slice.call(e),s=r(e),Util.Mt(s)||Util.n('GraphObject.make invoked object builder "'+t+'", but it did not return an Object')):n=root.go[t]}s===null&&((n==null||!n.constructor)&&Util.n("GraphObject.make requires a class function or GoJS class name or name of an object builder, not: "+t),s=new n);let o=1;if(s instanceof Diagram&&e.length>1){const r=s,l=e[1];(typeof l=="string"||l instanceof HTMLDivElement)&&(r.MP(l),o++)}for(let r=o;r{const i="#f5f5f5",e="#737373",s="#d4d4d4",n="#737373",o="#a3a3a3",r=2.76142374915397,l=2.761423749153969,h=new Panel(Panel.Auto,{isActionable:!0,enabledChanged:(a,f)=>{if(a instanceof Panel){const c=a.findObject("ButtonBorder");c!==null&&(f?(a._buttonFillDisabled=c.fill,c.fill=a._buttonFillNormal):(a._buttonFillNormal=c.fill,c.fill=a._buttonFillDisabled))}},cursor:"pointer"}).attach({_buttonFillNormal:i,_buttonStrokeNormal:e,_buttonFillOver:s,_buttonStrokeOver:n,_buttonFillDisabled:o}).add(new Shape("RoundedRectangle",{name:"ButtonBorder",spot1:new Spot(0,0,r,l),spot2:new Spot(1,1,-r,-l),parameter1:2,fill:i,stroke:e}));return h.mouseEnter=(a,f,c)=>{if(!f.isEnabledObject()||!(f instanceof Panel))return;const u=f.findObject("ButtonBorder");u instanceof Shape&&(f._buttonFillNormal=u.fill,u.fill=f._buttonFillOver,f._buttonStrokeNormal=u.stroke,u.stroke=f._buttonStrokeOver)},h.mouseLeave=(a,f,c)=>{if(!f.isEnabledObject()||!(f instanceof Panel))return;const u=f.findObject("ButtonBorder");u instanceof Shape&&(u.fill=f._buttonFillNormal,u.stroke=f._buttonStrokeNormal)},h}),GraphObject.defineBuilder("TreeExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_treeExpandedFigure:"MinusLine",_treeCollapsedFigure:"PlusLine",visible:!1}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.du}).bindObject("figure","isTreeExpanded",(e,s)=>{const n=s.panel;return e?n._treeExpandedFigure:n._treeCollapsedFigure})),i.bindObject("visible","isTreeLeaf",e=>!e),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Node))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isTreeExpanded){if(!r.canCollapseTree(n))return}else if(!r.canExpandTree(n))return;e.handled=!0,n.isTreeExpanded?r.collapseTree(n):r.expandTree(n)},i}),GraphObject.defineBuilder("SubGraphExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_subGraphExpandedFigure:"MinusLine",_subGraphCollapsedFigure:"PlusLine"}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.du}).bindObject("figure","isSubGraphExpanded",(e,s)=>{const n=s.panel;return e?n._subGraphExpandedFigure:n._subGraphCollapsedFigure})),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Group))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isSubGraphExpanded){if(!r.canCollapseSubGraph(n))return}else if(!r.canExpandSubGraph(n))return;e.handled=!0,n.isSubGraphExpanded?r.collapseSubGraph(n):r.expandSubGraph(n)},i}),GraphObject.defineBuilder("ToolTip",t=>new Adornment(Panel.Auto,{isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).add(new Shape("RoundedRectangle",{name:"Border",parameter1:1,fill:"#f5f5f5",strokeWidth:0,spot1:new Spot(0,0,4,6),spot2:new Spot(1,1,-4,-4)}))),GraphObject.defineBuilder("ContextMenu",t=>new Adornment(Panel.Vertical,{background:"#f5f5f5",isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).bindObject("background","",i=>i.adornedPart!==null&&i.hasPlaceholder()?null:"#f5f5f5")),GraphObject.defineBuilder("ContextMenuButton",t=>{const i=GraphObject.build("Button");i.stretch=5;const e=i.findObject("ButtonBorder");return e instanceof Shape&&(e.figure="Rectangle",e.strokeWidth=0,e.spot1=new Spot(0,0,4,6),e.spot2=new Spot(1,1,-4,-4)),i}),GraphObject.defineBuilder("PanelExpanderButton",t=>{const i=GraphObject.takeBuilderArgument(t,"COLLAPSIBLE"),e=GraphObject.build("Button");e.attach({_buttonExpandedFigure:"M0 0 M0 6 L4 2 8 6 M8 8",_buttonCollapsedFigure:"M0 0 M0 2 L4 6 8 2 M8 8",_buttonFillNormal:"rgba(0, 0, 0, 0)",_buttonStrokeNormal:null,_buttonFillOver:"rgba(0, 0, 0, .2)",_buttonStrokeOver:null}),e.add(new Shape({name:"ButtonIcon",strokeWidth:2}).bindObject("geometryString","visible",n=>n?e._buttonExpandedFigure:e._buttonCollapsedFigure,void 0,i));const s=e.findObject("ButtonBorder");return s instanceof Shape&&(s.stroke=null,s.fill="rgba(0, 0, 0, 0)"),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=o.diagram;if(r===null||r.isReadOnly)return;let l=o.findBindingPanel();if(l===null&&(l=o.part),l!==null){const h=l.findObject(i);h!==null&&(n.handled=!0,r.startTransaction("Collapse/Expand Panel"),h.visible=!h.visible,r.commitTransaction("Collapse/Expand Panel"))}},e}),GraphObject.defineBuilder("CheckBoxButton",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("Button",{desiredSize:new Size(14,14)});e.attach({"ButtonBorder.spot1":new Spot(0,0,1,1),"ButtonBorder.spot2":new Spot(1,1,-1,-1)});const s=new Shape({name:"ButtonIcon",geometryString:"M0 0 M0 8.85 L4.9 13.75 16.2 2.45 M16.2 16.2",strokeWidth:2,stretch:2,geometryStretch:6,visible:!1});return i!==""&&s.bindTwoWay("visible",i),e.add(s),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=n.diagram;if(r===null||r.isReadOnly||i!==""&&r.model.isReadOnly)return;n.handled=!0;const l=o.findObject("ButtonIcon");r.startTransaction("checkbox"),l!==null&&(l.visible=!l.visible),typeof o._doClick=="function"&&o._doClick(n,o),r.commitTransaction("checkbox")},e}),GraphObject.defineBuilder("CheckBox",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("CheckBoxButton",{name:"Button",isActionable:!1,margin:new Margin(0,1,0,0)},i),s=new Panel("Horizontal",{isActionable:!0,cursor:e.cursor,margin:new Margin(1),mouseEnter:e.mouseEnter,mouseLeave:e.mouseLeave,click:e.click}).attach({_buttonFillNormal:e._buttonFillNormal,_buttonStrokeNormal:e._buttonStrokeNormal,_buttonFillOver:e._buttonFillOver,_buttonStrokeOver:e._buttonStrokeOver,_buttonFillDisabled:e._buttonFillDisabled,_buttonClick:e.click});return s.add(e),e.mouseEnter=null,e.mouseLeave=null,e.click=null,s})}}class GraphObjectTemplateSettings{wi;Tt;eo;Ri;so;Ws;Al;Or;Er;Br;Kr;Ur;Vr;zr;Xr;q0;j0;Yr;W0;v0;J0;Z0;Gr;Hr;F0;Y0;Ss;Pr;Nr;ro;X0;z0;Mr;L0;_0;tp;constructor(){this.wi=!1,this.Tt="",this.eo=-1,this.Ri=null,this.so=null,this.Ws=null,this.Al="",this.Or=null,this.Er=null,this.Br=null,this.Kr=null,this.Ur=null,this.Vr=null,this.zr=null,this.Xr=null,this.q0=null,this.j0=null,this.Yr=null,this.W0=null,this.v0=null,this.J0=null,this.Z0=null,this.Gr=null,this.Hr=null,this.F0=null,this.Y0=null,this.Ss=null,this.Pr=Size.hf,this.Nr=Size.Xk,this.ro=1,this.X0=1,this.z0=1,this.Mr=0,this.L0=null,this._0=null,this.tp="category"}copy(){const t=new GraphObjectTemplateSettings;return t.Tt=this.Tt,t.eo=this.eo,t.Ri=this.Ri,t.Ws=this.Ws,t.Al=this.Al,t.Or=this.Or,t.Er=this.Er,t.Br=this.Br,t.Kr=this.Kr,t.Ur=this.Ur,t.Vr=this.Vr,t.zr=this.zr,t.Xr=this.Xr,t.q0=this.q0,t.j0=this.j0,t.Yr=this.Yr,t.W0=this.W0,t.v0=this.v0,t.J0=this.J0,t.Z0=this.Z0,t.Gr=this.Gr,t.Hr=this.Hr,t.F0=this.F0,t.Y0=this.Y0,t.Ss=this.Ss,t.Pr=this.Pr.L(),t.Nr=this.Nr.L(),t.ro=this.ro,t.X0=this.X0,t.z0=this.z0,t.Mr=this.Mr,t.L0=this.L0,t._0=this._0,t.tp=this.tp,t}}class STransform{m;constructor(){this.m=[1,0,0,1,0,0]}copy(){const t=new STransform;return t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5],t}translate(t,i){this.m[4]+=this.m[0]*t+this.m[2]*i,this.m[5]+=this.m[1]*t+this.m[3]*i}scale(t,i){this.m[0]*=t,this.m[1]*=t,this.m[2]*=i,this.m[3]*=i}rotate(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return;this.translate(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m[0]*s+this.m[2]*n,r=this.m[1]*s+this.m[3]*n,l=this.m[0]*-n+this.m[2]*s,h=this.m[1]*-n+this.m[3]*s;this.m[0]=o,this.m[1]=r,this.m[2]=l,this.m[3]=h,this.translate(-i,-e)}}class SGradient{type;x1;y1;r1;x2;y2;r2;colors;pattern;constructor(t){this.type=t,this.x1=0,this.y1=0,this.r1=0,this.x2=0,this.y2=0,this.r2=0,this.colors=[],this.pattern=null}addColorStop(t,i){this.colors.push({offset:t,color:i})}}class SVGSurface{Vt;di;da;$u;N2;constructor(t,i,e){const s=i===void 0?root.document:i;this.da=s,this.N2="http://www.w3.org/2000/svg";const n="http://www.w3.org/2000/xmlns/";s!==void 0&&(this.Vt=this.makeElement("svg",{width:"1px",height:"1px",viewBox:"0 0 1 1"}),this.style.display="block",this.style.letterSpacing="normal",this.style.wordSpacing="normal",e||(this.style.position="absolute"),this.Vt.setAttributeNS(n,"xmlns",this.N2),this.Vt.setAttributeNS(n,"xmlns:xlink","http://www.w3.org/1999/xlink")),this.$u=null,this.di=new SVGContext(this,e)}resize(t,i,e,s){return this.width!==t||this.height!==i?(this.width=t,this.height=i,this.style.width=e+"px",this.style.height=s+"px",this.Vt.setAttributeNS(null,"width",e+"px"),this.Vt.setAttributeNS(null,"height",s+"px"),this.Vt.setAttributeNS(null,"viewBox","0 0 "+e+" "+s),this.di.C2.firstElementChild.setAttributeNS(null,"width",e+"px"),this.di.C2.firstElementChild.setAttributeNS(null,"height",s+"px"),!0):!1}makeElement(t,i,e){const s=this.da.createElementNS(this.N2,t);if(Util.Mt(i))for(const n in i)s.setAttributeNS(n==="href"?"http://www.w3.org/1999/xlink":"",n,i[n]);return e!==void 0&&(s.textContent=e),s}getBoundingClientRect(){return this.Vt.getBoundingClientRect()}focus(){this.Vt.focus()}get width(){return this.Vt.width.baseVal.value}set width(t){this.Vt.setAttribute("width",t+"px")}get height(){return this.Vt.height.baseVal.value}set height(t){this.Vt.setAttribute("height",t+"px")}dispose(){this.da=null}get style(){return this.Vt.style}}class SVGContext{fc;cc;Pn;Ii;We;fillStyle;font;globalAlpha;lineCap;lineDashOffset;lineJoin;lineWidth;miterLimit;shadowBlur;shadowColor;shadowOffsetX;shadowOffsetY;strokeStyle;textAlign;imageSmoothingEnabled;clipInsteadOfFill;lastCreatedElement;uc;dc;surface;svg;C2;wL;$1;jo;yh;Ca;currentElement;clipPathGroup;diagramGroup;lastDrawnPart;currentPath;outerGroup;pathAttributes;ol;Tr;filter;partClipRect;constructor(t,i){this.surface=t,this.svg=t.Vt,this.uc=[],this.dc=[],this.fillStyle="#000000",this.font="10px sans-serif",this.globalAlpha=1,this.lineCap="butt",this.lineDashOffset=0,this.lineJoin="miter",this.lineWidth=1,this.miterLimit=10,this.shadowBlur=0,this.shadowColor="rgba(0, 0, 0, 0)",this.shadowOffsetX=0,this.shadowOffsetY=0,this.ol=!1,this.strokeStyle="#000000",this.textAlign="start",this.clipInsteadOfFill=!1,this.fc=0,this.cc=0,this.Pn=0,this.lastCreatedElement=null,this.currentElement=null,this.Ii=[],this.pathAttributes={},this.$1=!1,this.jo=null,this.yh=0,this.We=new STransform,this.clipPathGroup=this.newGroup2(),this.diagramGroup=this.newGroup2("gojs-diagram"),this.lastDrawnPart=null,this.currentPath=null;const e=GSet.fu++,s=this.makeElement("clipPath",{id:"mainClip"+e}),n={x:0,y:0,width:t.width,height:t.height};s.appendChild(this.makeElement("rect",n)),this.C2=s,this.svg.appendChild(this.clipPathGroup),this.clipPathGroup.appendChild(this.diagramGroup),this.svg.appendChild(s),this.clipPathGroup.setAttributeNS(null,"clip-path","url(#mainClip"+e+")"),this.wL={},this.Tr=!!i,this.filter="",this.partClipRect=null}setDiagramPosScale(t,i,e,s,n,o){this.diagramGroup===void 0?this.newGroup(t,i,e,s,n,o):this.diagramGroup.setAttribute("transform","matrix("+t+", "+i+", "+e+", "+s+", "+n+", "+o+")")}resetInnerSVG(){this.diagramGroup!==null&&(this.diagramGroup.innerHTML="")}arc(t,i,e,s,n,o,r,l){const h=2*Math.PI,a=1e-6,f=h-a,c=e*Math.cos(s),u=e*Math.sin(s),d=t+c,m=i+u,g=o?0:1;let p=o?s-n:n-s;(Math.abs(r-d)>a||Math.abs(l-m)>a)&&this.Ii.push(["L",d,+m]),p<0&&(p=p%h+h),p>f?(this.Ii.push(["A",e,e,0,1,g,t-c,i-u]),this.Ii.push(["A",e,e,0,1,g,d,m])):p>a&&this.Ii.push(["A",e,e,0,+(p>=Math.PI),g,t+e*Math.cos(n),i+e*Math.sin(n)])}beginPath(){this.Ii=[],this.pathAttributes={stroke:"none",fill:"none"}}endPath(t){this.HR(this.Ii,this.We,t||0)}bezierCurveTo(t,i,e,s,n,o){this.Ii.push(["C",t,i,e,s,n,o])}clearRect(t,i,e,s){}clip(){this.pathAttributes.clipPath=!0}closePath(){this.Ii.push(["z"])}createLinearGradient(t,i,e,s){const n=new SGradient("linear");return n.x1=t,n.y1=i,n.x2=e,n.y2=s,n}createPattern(t,i){let e="";t instanceof HTMLCanvasElement&&(e=t.toDataURL()),t instanceof HTMLImageElement&&(e=t.getAttribute("src"));const s=this.wL;if(s[e])return"url(#"+s[e]+")";const n="PATTERN"+GSet.fu++,o={width:t.width,height:t.height,id:n,patternUnits:"userSpaceOnUse"},r={x:0,y:0,width:t.width,height:t.height,href:e},l=this.makeElement("pattern",o);return l.appendChild(this.makeElement(Diagram.img,r)),this.svg.appendChild(l),s[e]=n,"url(#"+n+")"}createRadialGradient(t,i,e,s,n,o){const r=new SGradient("radial");return r.x1=t,r.y1=i,r.r1=e,r.x2=s,r.y2=n,r.r2=o,r}amendImageTransform(t,i,e,s,n,o,r,l){const h=r/e,a=l/s;(n!==0||o!==0)&&this.We.translate(n,o),(h!==1||a!==1)&&this.We.scale(h,a),(t!==0||i!==0)&&this.We.translate(-t,-i)}drawImage(t,i,e,s,n,o,r,l,h){let a="";t instanceof HTMLCanvasElement&&(a=t.toDataURL()),t instanceof HTMLImageElement&&(a=t.getAttribute("src"));const f=t instanceof HTMLImageElement?t.naturalWidth:t.width,c=t instanceof HTMLImageElement?t.naturalHeight:t.height;s===void 0&&(o=i,r=e,l=s=f,h=n=c),s=s||0,n=n||0,o=o||0,r=r||0,l=l||0,h=h||0,this.amendImageTransform(i,e,s,n,o,r,l,h);const u={x:0,y:0,width:f||s,height:c||n,href:a};!Geo.q(s,l)||!Geo.q(n,h)?u.preserveAspectRatio="none":a.toLowerCase().indexOf(".svg")===-1&&a.toLowerCase().indexOf("data:image/svg")===-1&&(u.preserveAspectRatio="xMidYMid slice"),(i!==0||e!==0||s!==f||n!==c)&&(s+=i,n+=e,u["clip-path"]=`path('M ${i},${e} L ${s} ${e} L ${s} ${n} L ${i} ${n} z')`),this.processCommon(Diagram.img,u,this.We),this.ud(Diagram.img,u)}fill(t,i){t&&(this.pathAttributes["fill-rule"]="evenodd"),this.setFill(this.pathAttributes)}fillContext(t,i,e){this.clipInsteadOfFill?this.clip():this.fill(i,e)}createOrUpdateClipGroup(t,i){const e=this.newGroup(1,0,0,1,-i.x,-i.y);e.setAttributeNS(null,"class","spotClip"),t.fh=e}fillRect(t,i,e,s){this.addRect("fill",[t,i,e,s],this.We)}fillBackground(t,i,e,s){const n={x:t,y:i,width:e,height:s};this.processCommon("fill",n,this.We),this.setFill(n),this.svg.prepend(this.makeElement("rect",n))}fillText(t,i,e){this.addText("fill",[t,i,e],this.We)}lineTo(t,i){this.Ii.push(["L",t,i])}moveTo(t,i){this.Ii.push(["M",t,i])}quadraticCurveTo(t,i,e,s){this.Ii.push(["Q",t,i,e,s])}rect(t,i,e,s){this.Ii.push(["M",t,i],["L",t+e,i],["L",t+e,i+s],["L",t,i+s],["z"])}restore(){this.We=this.uc.pop(),this.Ii=this.uc.pop();const t=this.uc.pop();this.fillStyle=t.fillStyle,this.font=t.font,this.globalAlpha=t.globalAlpha,this.lineCap=t.lineCap,this.lineDashOffset=t.lineDashOffset,this.lineJoin=t.lineJoin,this.lineWidth=t.lineWidth,this.miterLimit=t.miterLimit,this.shadowBlur=t.shadowBlur,this.shadowColor=t.shadowColor,this.shadowOffsetX=t.shadowOffsetX,this.shadowOffsetY=t.shadowOffsetY,this.strokeStyle=t.strokeStyle,this.textAlign=t.textAlign,this.partClipRect=t.partClipRect}save(){const t={fillStyle:this.fillStyle,font:this.font,globalAlpha:this.globalAlpha,lineCap:this.lineCap,lineDashOffset:this.lineDashOffset,lineJoin:this.lineJoin,lineWidth:this.lineWidth,miterLimit:this.miterLimit,shadowBlur:this.shadowBlur,shadowColor:this.shadowColor,shadowOffsetX:this.shadowOffsetX,shadowOffsetY:this.shadowOffsetY,strokeStyle:this.strokeStyle,textAlign:this.textAlign,partClipRect:this.partClipRect};this.uc.push(t);const i=[];for(let e=0;eh.offset>a.offset?1:-1);for(let h=0;h1&&this.dc[this.dc.length-2].setAttributeNS(null,"clip-path",'path("'+s+'") view-box');return}if(n.d=s,this.processCommon("",n,i),this.currentPath!==null){const r=this.currentPath;if(r.nodeName!=="g")for(const l in n)l!=="transform"&&r.setAttributeNS(null,l,n[l]);else{const l=r.getElementsByTagName("path");for(const h in n)h!=="transform"&&l[e].setAttributeNS(null,h,n[h])}}else this.ud("path",n)}BR(t){const i=t.getAttribute("clip-path");return i===null?null:this.svg.getElementById(i.split("#")[1].slice(0,-1))}gL(t){const i=t.getAttribute("clip-path");if(i===null)return;const e=this.svg.getElementById(i.split("#")[1].slice(0,-1));e!==null&&e.remove()}qR(t){const i=[];for(let e=0;es?(this.scale(s/n,1),this.translate((n-s)/2,0)):s>n&&(this.scale(1,n/s),this.translate(0,(s-n)/2)),this.fillOrClip(i,e),n>s?(this.translate(-(n-s)/2,0),this.scale(1/(s/n),1)):s>n&&(this.translate(0,-(s-n)/2),this.scale(1,1/(n/s))),!0}strokeContext(){this.clipInsteadOfFill||this.stroke()}fillOrClip(t,i){this.clipInsteadOfFill?this.clip(i):this.fill(t,i)}shadowsSet(t,i,e){this.fc=t,this.cc=i,this.Pn=e}shadowsOff(){this.ol=!1,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0}shadowsOn(){this.ol=!0,this.shadowOffsetX=this.fc,this.shadowOffsetY=this.cc,this.shadowBlur=this.Pn}enableDash(t,i){const e=this.Y;e.setLineDash!==void 0&&(e.setLineDash(t),e.lineDashOffset=i)}disableDash(){const t=this.Y;t.setLineDash!==void 0&&(t.setLineDash(CanvasSurfaceContext.EmptyArray),t.lineDashOffset=0)}clearContextCache(t){t&&(this.Q1=""),this._1="",this.tb=""}removePartFromView(t){}static EmptyArray=Object.freeze([])}var BrushType=(w=>(w[w.Solid=1]="Solid",w[w.Linear=2]="Linear",w[w.Radial=3]="Radial",w[w.Pattern=4]="Pattern",w))(BrushType||{}),ColorSpace=(w=>(w[w.Lab=1]="Lab",w[w.HSL=2]="HSL",w[w.Oklch=3]="Oklch",w))(ColorSpace||{});class ColorNumbers{n0;n1;n2;n3;constructor(){this.n0=0,this.n1=0,this.n2=0,this.n3=0}}class Brush{f;it;Aa;li;xs;ip;ep;Nn;sp;Sn;rc;v1;constructor(t,i){if(GSet.vi(this),this.f=!1,t===void 0)this.it=1,this.Aa="black";else if(typeof t=="string"){const s=Util.Xh(BrushType,t);s!==null?(this.it=s,this.Aa="black"):(this.it=1,Debug&&!Brush.isValidColor(t)&&Util.n('Color "'+t+'" is not a valid color string for Brush constructor'),this.Aa=t)}else Debug&&Util.tt(t,BrushType,"BrushType"),this.it=t,this.Aa="black";const e=this.it;if(e===2?(this.li=Spot.TopCenter,this.xs=Spot.BottomCenter):e===3?(this.li=Spot.Center,this.xs=Spot.Center):(this.li=Spot.None,this.xs=Spot.None),this.ip=0,this.ep=NaN,this.Nn=null,this.sp=null,this.Sn=null,this.rc=0,this.v1=0,i){const s={};for(const n in i)isFinite(parseFloat(n))?this.addColorStop(parseFloat(n),i[n]):s[n]=i[n];Object.assign(this,s)}}copy(){const t=new Brush;return t.it=this.it,t.Aa=this.Aa,t.li=this.li.L(),t.xs=this.xs.L(),t.ip=this.ip,t.ep=this.ep,this.Nn!==null&&(t.Nn=this.Nn.copy()),t.sp=this.sp,t}w(){return this.f=!0,this.Nn!==null&&this.Nn.w(),this}ft(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this.Nn!==null&&this.Nn.ft(),this}fi(t){t in BrushType?this.type=t:Util.ur(this,t)}toString(){let t="Brush(";if(this.type===1)t+=this.color;else if(this.type===2?t+="Linear ":this.type===3?t+="Radial ":this.type===4?t+="Pattern ":t+="(unknown) ",t+=this.start+" "+this.end,this.colorStops!==null){const i=this.colorStops.iterator;for(;i.next();){const e=i.key,s=i.value;t+=" "+e+":"+s}}return t+=")",t}addColorStop(t,i){return this.f&&Util.F(this),(typeof t!="number"||!isFinite(t)||t>1||t<0)&&Util.G(t,"0 <= loc <= 1",Brush,"addColorStop:loc"),Util.t(i,"string",Brush,"addColorStop:color"),Debug&&!Brush.isValidColor(i)&&Util.n('Color "'+i+'" is not a valid color string for Brush.addColorStop'),this.Nn===null&&(this.Nn=new GMap),this.Nn.set(t,i),this.it===1&&(this.type=2),this.Sn=null,this}get type(){return this.it}set type(t){this.f&&Util.F(this,t),Util.tt(t,BrushType,"BrushType"),this.it=t,this.start.isNoSpot()&&(t===2?this.start=Spot.TopCenter:t===3&&(this.start=Spot.Center)),this.end.isNoSpot()&&(t===2?this.end=Spot.BottomCenter:t===3&&(this.end=Spot.Center)),this.Sn=null}get color(){return this.Aa}set color(t){this.f&&Util.F(this,t),Debug&&!Brush.isValidColor(t)&&Util.n('Color "'+t+'" is not a valid color string for Brush.color'),this.Aa=t,this.Sn=null}get start(){return this.li}set start(t){this.f&&Util.F(this,t),Util.s(t,Spot,Brush,"start"),this.li=t.L(),this.Sn=null}get end(){return this.xs}set end(t){this.f&&Util.F(this,t),Util.s(t,Spot,Brush,"end"),this.xs=t.L(),this.Sn=null}get startRadius(){return this.ip}set startRadius(t){this.f&&Util.F(this,t),Util.r(t,Brush,"startRadius"),t<0&&Util.G(t,">= zero",Brush,"startRadius"),this.ip=t,this.Sn=null}get endRadius(){return this.ep}set endRadius(t){this.f&&Util.F(this,t),Util.r(t,Brush,"endRadius"),t<0&&Util.G(t,">= zero",Brush,"endRadius"),this.ep=t,this.Sn=null}get colorStops(){return this.Nn}set colorStops(t){this.f&&Util.F(this,t),Debug&&Util.s(t,GMap,Brush,"colorStops"),this.Nn=t,this.Sn=null}get pattern(){return this.sp}set pattern(t){this.f&&Util.F(this,t),this.sp=t,this.Sn=null}static randomColor(t,i){t===void 0&&(t=128),Debug&&(Util.r(t,Brush,"randomColor:min"),(t<0||t>255)&&Util.G(t,"0 <= min <= 255",Brush,"randomColor:min")),i===void 0&&(i=Math.max(t,255)),Debug&&(Util.r(i,Brush,"randomColor:max"),(i255)&&Util.G(i,"min <= max <= 255",Brush,"randomColor:max"));const e=Math.abs(i-t);let s=Math.floor(t+Math.random()*e).toString(16),n=Math.floor(t+Math.random()*e).toString(16),o=Math.floor(t+Math.random()*e).toString(16);return s.length<2&&(s="0"+s),n.length<2&&(n="0"+n),o.length<2&&(o="0"+o),"#"+s+n+o}static isValidColor(t){return root.CSS?root.CSS.supports("color",t):!0}static lighten(t){return Brush.lightenBy(t)}lightenBy(t,i){this.f&&Util.F(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Eo(this.color),this.color=Brush.dd(e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Eo(n.value),this.addColorStop(n.key,Brush.dd(e,s))}return this}static lightenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Eo(t),Brush.dd(s,n)}static darken(t){return Brush.darkenBy(t)}darkenBy(t,i){this.f&&Util.F(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Eo(this.color),this.color=Brush.dd(-e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Eo(n.value),this.addColorStop(n.key,Brush.dd(-e,s))}return this}static darkenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Eo(t),Brush.dd(-s,n)}static mix(t,i,e){Brush.Eo(t);const s=Brush.W.n0,n=Brush.W.n1,o=Brush.W.n2,r=Brush.W.n3;Brush.Eo(i),e===void 0&&(e=.5);const l=Math.round((Brush.W.n0-s)*e+s),h=Math.round((Brush.W.n1-n)*e+n),a=Math.round((Brush.W.n2-o)*e+o),f=Math.round((Brush.W.n3-r)*e+r);return`rgba(${l}, ${h}, ${a}, ${f})`}isDark(){if(this.type===1)return Brush.isDark(this.color);if((this.type===2||this.type===3)&&this.colorStops!==null){const t=this.colorStops;if(this.type===3)return Brush.isDark(t.first().value);if(t.get(.5)!==null)return Brush.isDark(t.get(.5));if(t.count===2){const l=t.toArray();return Brush.isDark(Brush.mix(l[0].value,l[1].value))}const i=t.iterator;let e=-1,s=-1,n=1,o=1;for(;i.next();){const l=i.key,h=Math.abs(.5-i.key);n>o&&h=n&&hs){let l=e;e=s,s=l,l=n,n=o,o=l}const r=s-e;return Brush.isDark(Brush.mix(t.get(e),t.get(s),1-o/r))}return!1}static isDark(t){return t?t instanceof Brush?t.isDark():(Brush.Eo(t),(299*Brush.W.n0+587*Brush.W.n1+114*Brush.W.n2)/1e3<128):!1}static dd(t,i){switch(i){case 1:return Brush.jR(),Brush.lo.n0=Math.min(100,Math.max(0,Brush.lo.n0+100*t)),Brush.WR(),"rgba("+Brush.W.n0+", "+Brush.W.n1+", "+Brush.W.n2+", "+Brush.W.n3+")";case 2:return Brush.UM(),Brush.Yi.n2=Math.min(100,Math.max(0,Brush.Yi.n2+100*t)),"hsla("+Brush.Yi.n0+", "+Brush.Yi.n1+"%, "+Brush.Yi.n2+"%, "+Brush.Yi.n3+")";case 3:return Brush.vR(),Brush.ho.n0=Math.min(100,Math.max(0,Brush.ho.n0+100*t)),Brush.JR(),"rgba("+Brush.W.n0+", "+Brush.W.n1+", "+Brush.W.n2+", "+Brush.W.n3+")";default:Util.n("Unknown color space: "+i)}}static Eo(t){const i=Brush.rl;if(i===null)return;i.clearRect(0,0,1,1),i.fillStyle="#000000";const e=i.fillStyle;if(i.fillStyle=t,i.fillStyle!==e){i.fillRect(0,0,1,1);const s=i.getImageData(0,0,1,1).data;Brush.W.n0=s[0],Brush.W.n1=s[1],Brush.W.n2=s[2],Brush.W.n3=s[3]/255}else{i.fillStyle="#FFFFFF";const s=i.fillStyle;i.fillStyle=t,i.fillStyle===s&&Debug&&Util.n('Color "'+t+'" is not a valid color string for RGBA color conversion'),Brush.W.n0=0,Brush.W.n1=0,Brush.W.n2=0,Brush.W.n3=1}}static UM(){const t=Brush.W.n0/255,i=Brush.W.n1/255,e=Brush.W.n2/255,s=Math.max(t,i,e),n=Math.min(t,i,e),o=s-n;let r,l;const h=(s+n)/2;if(o===0)r=l=0;else{switch(s){case t:r=(i-e)/o%6;break;case i:r=(e-t)/o+2;break;case e:r=(t-i)/o+4;break}r*=60,r<0&&(r+=360),l=o/(1-Math.abs(2*h-1))}Brush.Yi.n0=Math.round(r),Brush.Yi.n1=Math.round(l*100),Brush.Yi.n2=Math.round(h*100),Brush.Yi.n3=Brush.W.n3}static gE(){const t=Brush.Yi.n0,i=Brush.Yi.n1/100,e=Brush.Yi.n2/100;let s,n,o;const r=(1-Math.abs(2*e-1))*i,l=t/60,h=r*(1-Math.abs(l%2-1));l>=0&&l<1?(s=r,n=h,o=0):l>=1&&l<2?(s=h,n=r,o=0):l>=2&&l<3?(s=0,n=r,o=h):l>=3&&l<4?(s=0,n=h,o=r):l>=4&&l<5?(s=h,n=0,o=r):l>=5&&l<6&&(s=r,n=0,o=h);const a=e-.5*r;s+=a,n+=a,o+=a,Brush.W.n0=Math.round(s*255),Brush.W.n1=Math.round(n*255),Brush.W.n2=Math.round(o*255),Brush.W.n3=Brush.Yi.n3}static jR(){Brush.xL(),Brush.ZR()}static WR(){Brush.$R(),Brush.bL()}static A2(t){return t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}static L2(t){return t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055}static xL(){const t=Brush.A2(Brush.W.n0),i=Brush.A2(Brush.W.n1),e=Brush.A2(Brush.W.n2);Brush.zt.n0=.4124564*t+.3575761*i+.1804375*e,Brush.zt.n1=.2126729*t+.7151522*i+.072175*e,Brush.zt.n2=.0193339*t+.119192*i+.9503041*e,Brush.zt.n3=Brush.W.n3}static bL(){const t=3.2404542*Brush.zt.n0+-1.5371385*Brush.zt.n1+-.4985314*Brush.zt.n2,i=-.969266*Brush.zt.n0+1.8760108*Brush.zt.n1+.041556*Brush.zt.n2,e=.0556434*Brush.zt.n0+-.2040259*Brush.zt.n1+1.0572252*Brush.zt.n2;Brush.W.n0=Brush.L2(t)*255,Brush.W.n1=Brush.L2(i)*255,Brush.W.n2=Brush.L2(e)*255,Brush.W.n3=Brush.zt.n3,Brush.W.n0=Math.round(Brush.W.n0),Brush.W.n0>255?Brush.W.n0=255:Brush.W.n0<0&&(Brush.W.n0=0),Brush.W.n1=Math.round(Brush.W.n1),Brush.W.n1>255?Brush.W.n1=255:Brush.W.n1<0&&(Brush.W.n1=0),Brush.W.n2=Math.round(Brush.W.n2),Brush.W.n2>255?Brush.W.n2=255:Brush.W.n2<0&&(Brush.W.n2=0)}static T2=216/24389;static ib=24389/27;static gd=[95.047,100,108.883];static D2(t){return t>Brush.T2?Math.pow(t,1/3):(Brush.ib*t+16)/116}static ZR(){const t=Brush.D2(Brush.zt.n0*100/Brush.gd[0]),i=Brush.D2(Brush.zt.n1*100/Brush.gd[1]),e=Brush.D2(Brush.zt.n2*100/Brush.gd[2]);Brush.lo.n0=116*i-16,Brush.lo.n1=500*(t-i),Brush.lo.n2=200*(i-e),Brush.lo.n3=Brush.zt.n3}static kL(t){const i=t*t*t;return i>Brush.T2?i:(116*t-16)/Brush.ib}static $R(){const t=(Brush.lo.n0+16)/116,i=Brush.lo.n1/500+t,e=t-Brush.lo.n2/200;Brush.zt.n0=Brush.gd[0]/100*Brush.kL(i),Brush.zt.n1=Brush.gd[1]/100*(Brush.lo.n0>Brush.ib*Brush.T2?Math.pow(t,3):Brush.lo.n0/Brush.ib),Brush.zt.n2=Brush.gd[2]/100*Brush.kL(e),Brush.zt.n3=Brush.lo.n3}static QR(){let t=.8190224*Brush.zt.n0+.3619062*Brush.zt.n1+-.1288737*Brush.zt.n2,i=.03298366*Brush.zt.n0+.9292868*Brush.zt.n1+.03614466*Brush.zt.n2,e=.04817719*Brush.zt.n0+.2642395*Brush.zt.n1+.6335478*Brush.zt.n2;t=Math.cbrt(t),i=Math.cbrt(i),e=Math.cbrt(e),Brush.gi.n0=.2104542*t+.7936177*i+-.004072046*e,Brush.gi.n1=1.977998*t+-2.428592*i+.4505937*e,Brush.gi.n2=.02590403*t+.7827717*i+-.8086757*e,Brush.gi.n3=Brush.zt.n3,Brush.gi.n0*=100}static _R(){Brush.gi.n0/=100;let t=.9999999*Brush.gi.n0+.3963377*Brush.gi.n1+.2158037*Brush.gi.n2,i=1.000000009*Brush.gi.n0+-.1055613*Brush.gi.n1+-.06385417*Brush.gi.n2,e=1.00000005*Brush.gi.n0+-.08948418*Brush.gi.n1+-1.291485*Brush.gi.n2;t=t**3,i=i**3,e=e**3,Brush.zt.n0=1.2268798*t+-.5578149*i+.281391*e,Brush.zt.n1=-.04057576*t+1.112286*i+-.07171106*e,Brush.zt.n2=-.07637294*t+-.4214933*i+1.586924*e,Brush.zt.n3=Brush.gi.n3}static tI(){const t=Math.atan2(Brush.gi.n2,Brush.gi.n1)*180/Math.PI;Brush.ho.n0=Brush.gi.n0,Brush.ho.n1=Math.sqrt(Brush.gi.n1**2+Brush.gi.n2**2),Brush.ho.n2=t>=0?t:t+360,Brush.ho.n3=Brush.gi.n3}static iI(){Brush.gi.n0=Brush.ho.n0,Brush.gi.n1=Brush.ho.n1*Math.cos(Brush.ho.n2*Math.PI/180),Brush.gi.n2=Brush.ho.n1*Math.sin(Brush.ho.n2*Math.PI/180),Brush.gi.n3=Brush.ho.n3}static vR(){Brush.xL(),Brush.QR(),Brush.tI()}static JR(){Brush.iI(),Brush._R(),Brush.bL()}static cd(t,i){typeof t=="string"?Debug&&!Brush.isValidColor(t)&&Util.n('Color "'+t+'" is not a valid color string for '+i):t instanceof Brush||Util.n("Value for "+i+" must be a color string or a Brush, not "+t)}static Solid=1;static Linear=2;static Radial=3;static Pattern=4;static Lab=1;static HSL=2;static rl=Diagram.isUsingDOM()?new CanvasSurface(null,void 0,{willReadFrequently:!0}).di:null;static W=new ColorNumbers;static Yi=new ColorNumbers;static zt=new ColorNumbers;static lo=new ColorNumbers;static gi=new ColorNumbers;static ho=new ColorNumbers}class PanelLayout{Tt="Base";static Layouts=new GMap;static definePanelLayout(t,i){i.name=t,PanelLayout.Layouts.set(t,i)}get name(){return this.Tt}set name(t){this.Tt=t}constructor(){}get classType(){return Panel}measure(t,i,e,s,n,o,r){}measureElement(t,i,e,s,n){t.wt(i,e,s,n)}arrange(t,i,e){}arrangeElement(t,i,e,s,n,o){t.qt(i,e,s,n,o)}remeasureObject(t){t.lc()}Ji(t,i,e){}}class PanelLayoutPosition extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=s.length,h=t.Wo();for(let a=0;a0&&(P=Math.max(Math.abs(k.x*o+k.offsetX-(M.x*o+M.offsetX))-g,0)),r>0&&(N=Math.max(Math.abs(k.y*r+k.offsetY-(M.y*r+M.offsetY))-g,0));const T=Size.a();T.e(0,0);const L=t.Wo();for(let I=0;I1,ot=it.columnSpan>1;(ft||ot)&&!(Uy&&(P=Math.max(y-gt,0)),b.Zi=b.Zi+P,b.actual=b.lt+P,y=Math.max(y-(P+(mt?gt:0)),0)}if(it.columnSpan===1&&(N===0||N===4)){b=t.getColumnDefinition(H);const gt=b.computeEffectiveSpacing(),mt=b.lt===0;P=Math.max(ut-b.actual,0),P+(mt?gt:0)>p&&(P=Math.max(p-gt,0)),b.Zi=b.Zi+P,b.actual=b.lt+P,p=Math.max(p-(P+(mt?gt:0)),0)}(ft||ot)&&it.lc()}}}Util.nt(c);let L=0,D=0;l=t.columnCount;for(let U=0;U=t.rowCount);$++)b=t.getRowDefinition(E.row+$),P=0,N===2||N===4?P=Math.max(b.minimum,X[E.row+$]===0?b.maximum:Math.min(X[E.row+$],b.maximum)):P=Math.max(b.minimum,isNaN(b.xe)?b.maximum:Math.min(b.xe,b.maximum)),B.height+=P,_+=b.minimum;for(let $=1;$=t.columnCount);$++)b=t.getColumnDefinition(E.column+$),P=0,N===2||N===5?P=Math.max(b.minimum,z[E.column+$]===0?b.maximum:Math.min(z[E.column+$],b.maximum)):P=Math.max(b.minimum,isNaN(b.xe)?b.maximum:Math.min(b.xe,b.maximum)),B.width+=P,et+=b.minimum;K.width+=B.width,K.height+=B.height;const tt=E.margin,it=tt.right+tt.left,ft=tt.top+tt.bottom;E.wt(K.width,K.height,et,_);const ot=E.measuredBounds,lt=Math.max(ot.width+it,0),st=Math.max(ot.height+ft,0);let nt=0;for(let $=0;$=t.rowCount);$++)b=t.getRowDefinition(E.row+$),nt+=b.total||0;if(nt=t.rowCount);at++){b=t.getRowDefinition(E.row+at);const ut=b.lt||0,dt=rt(E,b,ct);Debug&&typeof dt!="number"&&Util.n(E+" spanAllocation does not return a number: "+dt),b.actual=Math.min(b.maximum,ut+dt),b.lt!==ut&&($-=b.lt-ut)}}for(;$>0;){const rt=b.lt||0;if(isNaN(b.height)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+$),b.lt!==rt&&($-=b.lt-rt)),b.index===0)break;b=t.getRowDefinition(b.index-1)}}let ht=0;for(let $=0;$=t.columnCount);$++)b=t.getColumnDefinition(E.column+$),ht+=b.total||0;if(ht=t.columnCount);at++){b=t.getColumnDefinition(E.column+at);const ut=b.lt||0,dt=rt(E,b,ct);Debug&&typeof dt!="number"&&Util.n(E+" spanAllocation does not return a number: "+dt),b.actual=Math.min(b.maximum,ut+dt),b.lt!==ut&&($-=b.lt-ut)}}for(;$>0;){const rt=b.lt||0;if(isNaN(b.width)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+$),b.lt!==rt&&($-=b.lt-rt)),b.index===0)break;b=t.getColumnDefinition(b.index-1)}}}Util.nt(u),Size.o(B),Size.o(K),X!==void 0&&Util.nt(X),z!==void 0&&Util.nt(z);let G=0,q=0;const j=t.desiredSize,J=t.maxSize;N=t.qs(!0),L=0,D=0;let Y=0,v=0;l=t.columnCount;for(let U=0;U0){for(;p!==f&&(u[p]===void 0||u[p].lt===0);)p++;p=Math.max(Math.min(p,f-1),0),m=-u[p].position}let y=Math.min(t.leftIndex,c-1);if(d.length>0){for(;y!==c&&(d[y]===void 0||d[y].lt===0);)y++;y=Math.max(Math.min(y,c-1),0),g=-d[y].position}let x=0,k=0;for(;x!==f&&u[x]===void 0;)x++;for(;k!==f&&d[k]===void 0;)k++;const b=t.part;let S=t.getRowDefinition(x),M=t.getColumnDefinition(k);for(let C=0;C=t.rowCount);st++){const nt=t.getRowDefinition(C+st);nt.lt!==0&&(A.height+=nt.total)}for(let st=1;st=t.columnCount);st++){const nt=t.getColumnDefinition(N+st);nt.lt!==0&&(A.width+=nt.total)}const O=T.lt+A.width,V=P.lt+A.height;let K=h,B=a;const X=O,z=V,G=h,q=a;let j=O,J=V;h+O>e.width&&(j=Math.max(e.width-h,0)),a+V>e.height&&(J=Math.max(e.height-a,0));let Y=R.alignment,v=0,W=0,Q=0,U=0;if(Y.isDefault()){Y=t.defaultAlignment,Y.isSpot()||(Y=Spot.Center),v=Y.x,W=Y.y,Q=Y.offsetX,U=Y.offsetY;const st=T.alignment,nt=P.alignment;st.isSpot()&&(v=st.x,Q=st.offsetX),nt.isSpot()&&(W=nt.y,U=nt.offsetY)}else v=Y.x,W=Y.y,Q=Y.offsetX,U=Y.offsetY;(isNaN(v)||isNaN(W))&&(v=.5,W=.5,Q=0,U=0);let E=I.width,H=I.height;const Z=R.margin,et=Z.left+Z.right,_=Z.top+Z.bottom,tt=R.R0(P,T,!1);isNaN(R.desiredSize.width)&&(tt===2||tt===5)&&(E=Math.max(O-et,0)),isNaN(R.desiredSize.height)&&(tt===2||tt===4)&&(H=Math.max(V-_,0));const it=R.maxSize,ft=R.minSize;E=Math.min(it.width,E),H=Math.min(it.height,H),E=Math.max(ft.width,E),H=Math.max(ft.height,H);const ot=E+et,lt=H+_;K+=X*v-ot*v+Q+Z.left,B+=z*W-lt*W+U+Z.top,R.visible&&(Rect.contains(G,q,j,J,K,B,I.width,I.height)?R.qt(K,B,E,H):R.qt(K,B,E,H,new Rect(G,q,j,J)))}}}Size.o(A);for(let C=0;C0&&(b.figure==="LineV"||b.figure==="LineH")){if(i.lineWidth=b.strokeWidth,t.wn(i,b.stroke,!1,!1,l,h),i.beginPath(),b.figure==="LineV"){const D=Math.floor((m-o)/o);for(let F=D;F<=D+c;F++){const R=F*o+m;0<=R&&R<=a&&this.sb(F,S,A,N)&&(i.moveTo(R,0),i.lineTo(R,f))}}else if(b.figure==="LineH"){const D=Math.floor((g-r)/r);for(let F=D;F<=D+u;F++){const R=F*r+g;0<=R&&R<=f&&this.sb(F,S,A,N)&&(i.moveTo(0,R),i.lineTo(a,R))}}i.stroke(),i.endPath()}else if(b.fill!==null){if(t.wn(i,b.fill,!0,!1,l,h),b.figure==="BarV"){let D=b.width;isNaN(D)&&(D=o);const F=Math.floor((m-o)/o);for(let R=F;R<=F+c;R++){const I=R*o+m;0<=I+D&&I<=a&&this.sb(R,S,A,N)&&i.fillRect(I,0,D,f)}}else if(b.figure==="BarH"){let D=b.height;isNaN(D)&&(D=r);const F=Math.floor((g-r)/r);for(let R=F;R<=F+u;R++){const I=R*r+g;0<=I+D&&I<=f&&this.sb(R,S,A,N)&&i.fillRect(0,I,a,D)}}}T&&i.disableDash(),C!==1&&(i.globalAlpha=P)}}sb(t,i,e,s){if(i<0)return t%i===e;if(t%i!==e)return!1;const n=s.length;for(let o=0;ol&&r.push(d)}}t.Mi.np=i}O2(t){return t==="LineV"||t==="BarV"}eI(t){let i=1,e=1;const s=t.D.h,n=s.length;for(let l=0;l=g){const Y=Point.a();f.ML(Y),O=f.midAngle,L!==0&&(I=f.computeAngle(A,L,O),A.jt=I,A.ye(!0),A.oo(!0)),F=Y.x-u.x,R=Y.y-u.y,Point.o(Y)}else{let Y,v,W=0;if(P>=0?(Y=m.elt(P),v=P0?m.elt(W-1):Y),O=0,Y.equalsApprox(v)){let Q,U;P>=0?(Q=P>0?m.elt(P-1):Y,U=P1?m.elt(W-2):v);const E=Q.distanceSquaredPoint(Y),H=v.distanceSquaredPoint(U);E>H+10?O=P>=0?Q.directionPoint(Y):Y.directionPoint(Q):H>E+10?O=P>=0?v.directionPoint(U):U.directionPoint(v):O=P>=0?Q.directionPoint(U):U.directionPoint(Q)}else O=P>=0?Y.directionPoint(v):v.directionPoint(Y);L!==0&&(I=f.computeAngle(A,L,O),A.jt=I,A.ye(!0),A.oo(!0)),F=Y.x+(v.x-Y.x)*N-u.x,R=Y.y+(v.y-Y.y)*N-u.y}A.wt(1/0,1/0,0,0),C=A.measuredBounds;const V=A.naturalBounds;let K=0;A instanceof Shape&&(K=A.strokeWidth);const B=V.width+K,X=V.height+K;k.Vi(),k.Es(-C.x,-C.y),k.rt(A.scale,A.scale),k.ms(L===0?A.angle:O,B/2,X/2),(L===22||L===26)&&k.ms(90,B/2,X/2),(L===23||L===27)&&k.ms(-90,B/2,X/2),L===28&&(O>45&&O<135||O>225&&O<315)&&k.ms(-O,B/2,X/2);const z=new Rect(0,0,B,X);b.setRectSpot(z,T),k.Pt(b);const G=-b.x+K/2*A.scale,q=-b.y+K/2*A.scale;S.c(D);const j=isNaN(D.x),J=isNaN(D.y);if(j||J){const Y=B/2+3,v=X/2+3,W=O>=45&&O<=135,Q=O>=225&&O<=315;L===0&&(W||Q)?(S.x=J?Y:D.y,S.y=j?v:D.x,W?P>=0||isNaN(P)&&N<.5||j&&(S.y=-v):Q&&((P>=0||isNaN(P)&&N<.5)&&j&&(S.y=-v),J&&(S.x=-Y))):(j&&(P>=0||isNaN(P)&&N<.5?S.x=Y:S.x=-Y),J&&(S.y=-v),S.rotate(O))}else S.rotate(O);F+=S.x,R+=S.y,z.e(F+G,R+q,C.width,C.height),x.push(z),d.unionRect(z)}if(h!==null){const M=h.labelNodes;for(;M.next();)M.value.wt(1/0,1/0)}t.vo=d,t.position.e(u.x+d.x,u.y+d.y),n.Kn(d.width||0,d.height||0),Transform.o(k),Point.o(b),Point.o(S)}arrange(t,i,e){const s=i.length;if(!(t instanceof Adornment||t instanceof Link))return;let n=t,o=null;t instanceof Adornment&&(o=t,n=o.adornedPart);const r=t,l=t instanceof Adornment?null:n.path,h=t.gc;if(h.length!==0){let u=0;if(l!==null&&u=2&&r instanceof Link){const u=r.labelNodes;for(;u.next();){const d=u.value;r.oI(d,f,a)}}o!==null?o.md(!1):n.md(!1);const c=t.PL(Point.a());t.location.e(t.position.x+c.x,t.position.y+c.y),Point.o(c)}measureLinkPath(t,i,e,s){if(s.Xo()===!1)return;let n=s.strokeWidth;if(n===0&&t instanceof Adornment&&t.type===Panel.Link&&t.adornedObject instanceof Shape&&(n=t.adornedObject.strokeWidth),n=n*s.rt,t instanceof Link&&t.mt!==null){const o=t.geometry.bounds;s.no(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else if(t instanceof Adornment&&t.adornedPart.mt!==null){const o=t.adornedPart.mt.bounds;s.no(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else s.no(-(n/2),-(n/2),i+n,e+n);s.rI(),s.ye(!1)}}PanelLayout.definePanelLayout("Link",new PanelLayoutLink);class PanelLayoutGraduated extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=t.findMainElement();t.Ze=[];const h=l.margin,a=h.right+h.left,f=h.top+h.bottom;l.wt(i,e,o,r);const c=l.measuredBounds,u=c.width,d=c.height,m=Math.max(u+a,0),g=Math.max(d+f,0),p=new Rect(-h.left,-h.top,m,g);t.Ze.push(p),n.c(p),this.determineGraduatedMarks(t,l);const y=t.Ms;if(y===null)return;const x=s.length;for(let k=0;k45&&c<135||c>225&&c<315)&&S.ms(-c,k/2,b/2);const M=Rect.H(0,0,k,b),A=Point.a();A.setRectSpot(M,o),S.Pt(A);const C=-A.x,P=-A.y,N=Point.a();N.c(l),isNaN(N.x)&&(N.x=k/2+3),isNaN(N.y)&&(N.y=-(b/2+3)),N.rotate(c),a+=N.x+C,f+=N.y+P;const T=new Rect(a,f,y.width,y.height),L=new Rect(y.x,y.y,y.width,y.height),D=new Rect(x.x,x.y,x.width,x.height);p.labelAngle=u,p.lineCount=n.lineCount,p.lines=n.getMetrics(),p.actualBounds=T,p.measuredBounds=L,p.naturalBounds=D,g===0?h.c(T):h.unionRect(T),Point.o(N),Point.o(A),Rect.o(M),Transform.o(S)}t.Ze!==null&&t.Ze.push(h),s.unionNoCheck(h.x,h.y,h.width,h.height)}determineGraduatedMarks(t,i){const e=i.geometry,s=i.strokeWidth,n=e.flattenedSegments,o=e.flattenedLengths,r=e.flattenedTotalLength,l=n.length;let h=0,a=0;const f=Util.at();for(let x=0;xt.graduatedMin+P){const F=Math.floor((N-t.graduatedMin)/P);N-=F*P}const T=c[x],L=N,D=t.graduatedMax*1e-6;for(let F=1;N<=t.graduatedMax+D;F++){if(this.hI(t,N-t.graduatedTickBase,T)&&(N>t.graduatedMax&&(N=t.graduatedMax),(k.graduatedSkip===null||k instanceof TextBlock&&!k.graduatedSkip(N,k)||k instanceof Shape&&!k.graduatedSkip(N,k))&&(m=(N-t.graduatedMin)*r/t.graduatedRange,m>r&&(m=r),g<=m&&m<=p))){let R=f[A][C],I=o[A][C];for(;AM&&C.4995)return t;let o=t;if(i<.5?n>0?o=s[n-1]:Geo.q(e[0],e[e.length-2])&&Geo.q(e[1],e[e.length-1])&&(o=s[s.length-1]):i>.5&&(n+1180&&(t.9995)return(t+o)/2%360;if(r<10){const l=1-Math.abs(.5-i);return(t*l+o*(1-l))%360}}return t}lI(t){if(t.as===null){const i=[],e=t.D.h,s=e.length;for(let n=0;nl&&r.push(f)}}t.as=i}return t.as}hI(t,i,e){const s=e.length;for(let n=0;n-l)return!1}return!0}Ji(t,i,e){const s=e.ea;e.ea=!0;const n=t.naturalBounds,o=n.width,r=n.height,l=i instanceof SVGContext;i.save(),i.beginPath(),i.rect(-1,-1,o+1,r+1),i.clip(),i.endPath();const h=t.findMainElement();h.Ji(i,e);let a=t.getDocumentScale()*e.scale;a<=0&&(a=1);const f=h.actualBounds,c=t.D.h,u=t.Ms,d=c.length;for(let m=0;m(w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ViewboxStretch||{});class Panel extends GraphObject{it;D;ii;pd;vn;ll;ao;vo;B2;V;yd;ut;Mi;si;wd;xh;vs;constructor(t,i){if(super(),this.it=null,t===void 0)this.it=Panel.Position;else if(typeof t=="string"){const e=PanelLayout.Layouts.get(t);e!==null&&(this.it=e)}else t instanceof PanelLayout?this.it=t:t&&(this.it=Panel.Position,i=t);this.it===null&&Util.n("Panel type not specified or PanelLayout not loaded: "+t),this.l|=4194304|(this.it===Panel.Grid?1048576:0),this.D=new List,this.ii=Margin.Hg,this.pd=Spot.Default,this.vn=1,this.ll=null,this.ao="",this.vo=new Rect(NaN,NaN,NaN,NaN),this.B2=null,this.V=null,this.yd=6,this.Mi=null,this.ut=null,this.si=null,this.wd=NaN,this.xh=null,this.vs=null,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.it=this.it,t.ii=this.ii.L(),t.pd=this.pd.L(),t.vn=this.vn,t.ao=this.ao,t.vo.c(this.vo),this.V!==null&&(t.V=this.V.copy(t)),t.yd=this.yd,this.ut!==null&&(t.ut=this.ut.copy()),this.Mi!==null&&(t.Mi=this.Mi.copy()),t.si=this.si,t.wd=this.wd,t.xh=this.xh}Ho(t){super.Ho(t),t.D=this.D;const i=t.D.h,e=i.length;for(let s=0;s= 0",Panel,"padding"),t=new Margin(t)):(Util.s(t,Margin,Panel,"padding"),t.left<0&&Util.G(t.left,">= 0",Panel,"padding:value.left"),t.right<0&&Util.G(t.right,">= 0",Panel,"padding:value.right"),t.top<0&&Util.G(t.top,">= 0",Panel,"padding:value.top"),t.bottom<0&&Util.G(t.bottom,">= 0",Panel,"padding:value.bottom"));const i=this.ii;i.equals(t)||(t=t.L(),this.ii=t,this.u(),this.i("padding",i,t))}get defaultAlignment(){return this.pd}set defaultAlignment(t){const i=this.pd;i.equals(t)||(Debug&&Util.s(t,Spot,Panel,"defaultAlignment"),t=t.L(),this.pd=t,this.u(),this.i("defaultAlignment",i,t))}get defaultStretch(){return this.vn}set defaultStretch(t){const i=this.vn;i!==t&&(this.vn=t,this.u(),this.i("defaultStretch",i,t))}get defaultSeparatorPadding(){return this.V!==null?this.V.op:Margin.Hg}set defaultSeparatorPadding(t){typeof t=="number"?t=new Margin(t):Debug&&Util.s(t,Margin,Panel,"defaultSeparatorPadding");const i=this.defaultSeparatorPadding;i.equals(t)||(t=t.L(),this.V===null&&(this.V=new TablePanelSettings),this.V.op=t,this.u(),this.i("defaultSeparatorPadding",i,t))}get defaultRowSeparatorStroke(){return this.V!==null?this.V.rp:null}set defaultRowSeparatorStroke(t){const i=this.defaultRowSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.w(),this.V===null&&(this.V=new TablePanelSettings),this.V.rp=t,this.T(),this.i("defaultRowSeparatorStroke",i,t))}get defaultRowSeparatorStrokeWidth(){return this.V!==null?this.V.lp:1}set defaultRowSeparatorStrokeWidth(t){const i=this.defaultRowSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.V===null&&(this.V=new TablePanelSettings),this.V.lp=t,this.u(),this.i("defaultRowSeparatorStrokeWidth",i,t))}get defaultRowSeparatorDashArray(){return this.V!==null?this.V.hp:null}set defaultRowSeparatorDashArray(t){const i=this.defaultRowSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Bi(t,"Array",Panel,"defaultRowSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("defaultRowSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.V===null&&(this.V=new TablePanelSettings),this.V.hp=t,this.T(),this.i("defaultRowSeparatorDashArray",i,t)}}get defaultColumnSeparatorStroke(){return this.V!==null?this.V.ap:null}set defaultColumnSeparatorStroke(t){const i=this.defaultColumnSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.w(),this.V===null&&(this.V=new TablePanelSettings),this.V.ap=t,this.T(),this.i("defaultColumnSeparatorStroke",i,t))}get defaultColumnSeparatorStrokeWidth(){return this.V!==null?this.V.fp:1}set defaultColumnSeparatorStrokeWidth(t){const i=this.defaultColumnSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.V===null&&(this.V=new TablePanelSettings),this.V.fp=t,this.u(),this.i("defaultColumnSeparatorStrokeWidth",i,t))}get defaultColumnSeparatorDashArray(){return this.V!==null?this.V.cp:null}set defaultColumnSeparatorDashArray(t){const i=this.defaultColumnSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Bi(t,"Array",Panel,"defaultColumnSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("defaultColumnSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.V===null&&(this.V=new TablePanelSettings),this.V.cp=t,this.T(),this.i("defaultColumnSeparatorDashArray",i,t)}}get wh(){return this.V!==null?this.V.wh:null}set wh(t){this.V===null&&(this.V=new TablePanelSettings),this.V.wh=t}get viewboxStretch(){return this.yd}set viewboxStretch(t){const i=this.yd;i!==t&&(this.yd=t,this.u(),this.i("viewboxStretch",i,t))}get gridCellSize(){return this.Mi!==null?this.Mi.xd:Size.hC}set gridCellSize(t){this.Mi===null&&(this.Mi=new GridPanelSettings);const i=this.Mi.xd;if(!i.equals(t)){(!t.isReal()||t.width===0||t.height===0)&&Util.n("Invalid Panel.gridCellSize: "+t),this.Mi.xd=t.L();const e=this.diagram;e!==null&&this===e.grid&&e.Zr(),this.T(),this.i("gridCellSize",i,t)}}get gridOrigin(){return this.Mi!==null?this.Mi.bd:Point.Lo}set gridOrigin(t){this.Mi===null&&(this.Mi=new GridPanelSettings);const i=this.Mi.bd;if(!i.equals(t)){t.isReal()||Util.n("Invalid Panel.gridOrigin: "+t),this.Mi.bd=t.L();const e=this.diagram;e!==null&&this===e.grid&&e.Zr(),this.T(),this.i("gridOrigin",i,t)}}get graduatedMin(){return this.ut!==null?this.ut.dp:0}set graduatedMin(t){Util.r(t,Panel,"graduatedMin");const i=this.graduatedMin;if(i!==t&&(this.ut===null&&(this.ut=new GradPanelSettings),this.ut.dp=t,this.u(),this.i("graduatedMin",i,t),this.sc())){const e=this.part;e!==null&&this.Sa(e,"graduatedRange")}}get graduatedMax(){return this.ut!==null?this.ut.gp:100}set graduatedMax(t){Util.r(t,Panel,"graduatedMax");const i=this.graduatedMax;if(i!==t&&(this.ut===null&&(this.ut=new GradPanelSettings),this.ut.gp=t,this.u(),this.i("graduatedMax",i,t),this.sc())){const e=this.part;e!==null&&this.Sa(e,"graduatedRange")}}get graduatedRange(){return this.graduatedMax-this.graduatedMin}get graduatedTickUnit(){return this.ut!==null?this.ut.mp:10}set graduatedTickUnit(t){Util.r(t,Panel,"graduatedTickUnit");const i=this.graduatedTickUnit;i!==t&&t>0&&(this.ut===null&&(this.ut=new GradPanelSettings),this.ut.mp=t,this.u(),this.i("graduatedTickUnit",i,t))}get graduatedTickBase(){return this.ut!==null?this.ut.pp:0}set graduatedTickBase(t){Util.r(t,Panel,"graduatedTickBase");const i=this.graduatedTickBase;i!==t&&(this.ut===null&&(this.ut=new GradPanelSettings),this.ut.pp=t,this.u(),this.i("graduatedTickBase",i,t))}get Ms(){return this.ut!==null?this.ut.Ms:null}set Ms(t){this.ut!==null?this.ut.Ms=t:t!==null&&(this.ut=new GradPanelSettings,this.ut.Ms=t)}get Ze(){return this.ut!==null?this.ut.Ze:null}set Ze(t){this.ut!==null?this.ut.Ze=t:t!==null&&(this.ut=new GradPanelSettings,this.ut.Ze=t)}get as(){return this.ut!==null?this.ut.as:null}set as(t){this.ut!==null?this.ut.as=t:t!==null&&(this.ut=new GradPanelSettings,this.ut.as=t)}get Le(){return this.ut!==null?this.ut.Le:null}set Le(t){this.ut!==null?this.ut.Le=t:t!==null&&(this.ut=new GradPanelSettings,this.ut.Le=t)}A0(t){super.A0(t);const i=this.D.h,e=i.length;for(let s=0;s0?this.ve:null,s=this.columnCount>0?this.Je:null;e!==null&&this.nb(t,i,!0,e,!0),s!==null&&this.nb(t,i,!1,s,!0),e!==null&&this.CL(t,!0,e),s!==null&&this.CL(t,!1,s),e!==null&&this.nb(t,i,!0,e,!1),s!==null&&this.nb(t,i,!1,s,!1)}CL(t,i,e){const s=e.length,n=this.actualBounds,o=this.naturalBounds;let r=!0;for(let l=0;lo.height)continue}else if(h.position>o.width)continue;let a=h.separatorStrokeWidth;isNaN(a)&&(a=i?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let f=h.separatorStroke;if(f===null&&(f=i?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),a===0||f===null)continue;this.wn(t,f,!1,!1,o,n);let c=!1,u=h.separatorDashArray;u===null&&(u=i?this.defaultRowSeparatorDashArray:this.defaultColumnSeparatorDashArray),u!==null&&(c=!0,t.enableDash(u,0)),t.beginPath();const d=h.position+a;i?d>o.height&&(a-=d-o.height):d>o.width&&(a-=d-o.width);let m=h.position+a/2;t.lineWidth=a;const g=this.ii;if(i){m+=g.top;const p=g.left,y=o.width-g.right;t.moveTo(p,m),t.lineTo(y,m)}else{m+=g.left;const p=g.top,y=o.height-g.bottom;t.moveTo(m,p),t.lineTo(m,y)}t.stroke(),t.endPath(),c&&t.disableDash()}}nb(t,i,e,s,n){const o=s.length,r=this.actualBounds,l=this.naturalBounds,h=this.AL(!0),a=this.AL(!1);for(let f=0;fu)continue;let d=c.computeEffectiveSpacing(),m=c.separatorStrokeWidth;isNaN(m)&&(m=e?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let g=c.separatorStroke;g===null&&(g=e?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),(g===null||c.index===(e?h:a))&&(m=0),d-=m;const p=c.position+m;let y=d+c.actual;if(p+y>u&&(y=u-p),y<=0)continue;const x=this.ii;this.wn(t,c.background,!0,!1,l,r),e?t.fillRect(x.left,p+x.top,r.width-(x.left+x.right),y):t.fillRect(p+x.left,x.top,y,r.height-(x.top+x.bottom))}}AL(t){const i=t?this.rowCount:this.columnCount;for(let e=0;ex&&n.set(P),Point.o(P)),Point.o(M),o&&n.O(r),k}}Vu(){const t=this.D.h,i=t.length;for(let e=0;ee||h>s)&&(this.u(),this.wt(l>e?e:l,h>s?s:h,0,0));break;case 2:this.u(!0),this.wt(e+f,s+c,0,0);break;case 5:this.u(!0),this.wt(e+f,h+c,0,0);break;case 4:this.u(!0),this.wt(l+f,s+c,0,0);break}}this.it.arrange(this,n,this.vo)}uh(t){const i=this.naturalBounds,e=this.Wo();if(Rect.contains(0,0,i.width,i.height,t.x,t.y)){const s=this.D.h,n=s.length,o=Point.H(0,0);for(let r=n;r--;){const l=s[r];if(!(!l.visible&&l!==e)&&(o.set(t).Ye(l.O),l.containsPoint(o)))return Point.o(o),!0}return Point.o(o),this.Ft!==null}return!1}S0(t){if(this.eo===t)return this;const i=this.D.h,e=i.length;for(let s=0;sd.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;let m=c;const g=c instanceof Panel?c:null,p=Transform.a();p.set(r),(g!==null?g.Ym(t,i,e,s,n,p):m.rL(t,s,p))&&(i!==null&&(m=i(m)),m!==null&&(e===null||e(m))&&n.add(m)),Transform.o(p)}}return o===void 0&&Transform.o(r),s}return o===void 0&&Transform.o(r),!1}z2(t,i,e){const s=this.D.h,n=s.length;for(let o=n;o--;){const r=s[o];if(!r.visible)continue;const l=r.actualBounds,h=this.naturalBounds;if(l.x>h.width||l.y>h.height||l.x+l.width<0||l.y+l.height<0)continue;r instanceof Panel&&r.z2(t,i,e);let a=r;t!==null&&(a=t(a)),a!==null&&(i===null||i(a))&&e.add(a)}}aA(t,i,e,s,n,o){if(this.pickable===!1)return!1;e===void 0&&(e=null),s===void 0&&(s=null);const r=this.naturalBounds,l=this.kn(),h=l?t:Point.H(t.x,t.y).Ye(this.O),a=l?i:Point.H(i.x,i.y).Ye(this.O),f=h.distanceSquaredPoint(a),c=h.x>0&&h.x0&&h.yS.width||b.y>S.height||b.x+b.width<0||b.y+b.height<0))continue;if(k.kn()){const C=k.O;d.set(t).Ye(C),m.set(i).Ye(C)}else d.set(t),m.set(i);let M=k;const A=k instanceof Panel?k:null;(A!==null?A.aA(d,m,e,s,n,o):M.lL(d,m,n))&&(e!==null&&(M=e(M)),M!==null&&(s===null||s(M))&&o.add(M))}Point.o(d),Point.o(m)}return n?c:u}return!1}R2(t){let i=null;if(t instanceof Shape){i=t.spot1,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot1)}return i===null&&(i=Spot.TopLeft),i}I2(t){let i=null;if(t instanceof Shape){i=t.spot2,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot2)}return i===null&&(i=Spot.BottomRight),i}add(...t){for(let i=0;i=s.count&&t>=s.count)return;s.removeAt(r),n=r}else Util.n("element "+i.toString()+" has panel "+e.toString()+" but is not contained by it.")}(t<0||t>s.count)&&(t=s.count),s.insertAt(t,i),(t===0||i.isPanelMain)&&(this.ll=null),this.Xo()||this.u(),i.u(!1),i.portId!==null?this.Mn=!0:i instanceof Panel&&i.Mn===!0&&(this.Mn=!0),this.as=null,this.isEnabledObject()||this.ob(i,!1);const o=this.part;if(o!==null){o.V0(),o.pc(),this.Mn&&o instanceof Node&&(o.Mn=!0),o.Mn&&o instanceof Node&&(o.ae=null);const r=this.diagram;if(r!==null&&r.undoManager.isUndoingRedoing)return;n!==-1&&o.raiseChangedEvent(4,"elements",this,i,null,n,null),o.raiseChangedEvent(3,"elements",this,null,i,null,t)}}get Mn(){return(this.l&8388608)!==0}set Mn(t){(this.l&8388608)!==0!==t&&(this.l=this.l^8388608)}u2(){return(this.l&16777216)!==0}X2(t){t?this.l|=16777216:this.l&=-16777217}gI(t){t.Pa(this),t.sl=null;const i=this.D,e=i.count;i.insertAt(e,t);const s=this.part;if(s!==null){s.V0(),t.portId!==null&&s instanceof Node&&(s.Mn=!0);const n=this.diagram;if(n!==null&&n.undoManager.isUndoingRedoing)return;s.raiseChangedEvent(3,"elements",this,null,t,null,e)}}ER(t){const i=this.D.h,e=i.length;let s=-1;for(let n=0;n=0&&this.oe(t,!0)}oe(t,i){const e=this.D,s=e.elt(t);if(s.sl=null,s.Pa(null),this.vs!==null){const o=s.data;typeof o=="object"&&this.vs.delete(o)}e.removeAt(t),this.ye(!1),this.u(),this.ll===s&&(this.ll=null),this.as=null;const n=this.part;if(n!==null){n.V0(),n.pc(),n.invalidateAdornments(),n instanceof Node&&(s instanceof Panel?s.walkVisualTreeFrom(s,(r,l)=>n.S2(l,i)):n.S2(s,i));const o=this.diagram;if(o!==null&&o.undoManager.isUndoingRedoing)return;n.raiseChangedEvent(4,"elements",this,s,null,t,null)}}get ve(){return this.V===null&&(this.V=new TablePanelSettings),this.V.ve}get rowCount(){return this.V===null?0:this.ve.length}getRowDefinition(t){Debug&&Util.r(t,Panel,"getRowDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"getRowDefinition:idx"),t=Math.round(t);const i=this.ve;if(i[t]===void 0){const e=new RowColumnDefinition;e.Pa(this),e.isRow=!0,e.index=t,i[t]=e,this.raiseChangedEvent(3,"rowdefs",this,null,e,null,t)}return i[t]}removeRowDefinition(t){if(Debug&&Util.r(t,Panel,"removeRowDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"removeRowDefinition:idx"),this.rowCount===0)return;t=Math.round(t);const i=this.ve,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"rowdefs",this,e,null,t,null),this.u()}}VA(t,i){const e=this.ve;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.u()}}get Je(){return this.V===null&&(this.V=new TablePanelSettings),this.V.Je}get columnCount(){return this.V===null?0:this.Je.length}getColumnDefinition(t){Debug&&Util.r(t,Panel,"getColumnDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"getColumnDefinition:idx"),t=Math.round(t);const i=this.Je;if(i[t]===void 0){const e=new RowColumnDefinition;e.Pa(this),e.isRow=!1,e.index=t,i[t]=e,this.raiseChangedEvent(3,"coldefs",this,null,e,null,t)}return i[t]}removeColumnDefinition(t){if(Debug&&Util.r(t,Panel,"removeColumnDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"removeColumnDefinition:idx"),this.columnCount===0)return;t=Math.round(t);const i=this.Je,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"coldefs",this,e,null,t,null),this.u()}}zA(t,i){const e=this.Je;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.u()}}addRowColumnDefinition(t){let i=null;return t.isRow?i=this.getRowDefinition(t.index):t.isRow||(i=this.getColumnDefinition(t.index)),i&&i.Z1(t),this}addRowDefinition(t,i){const e=this.getRowDefinition(t);return e&&e.Z1(new RowColumnDefinition(i)),this}addColumnDefinition(t,i){const e=this.getColumnDefinition(t);return e&&e.Z1(new RowColumnDefinition(i)),this}get rowSizing(){return this.V!==null?this.V.wp:3}set rowSizing(t){const i=this.rowSizing;i!==t&&(Debug&&t!==3&&t!==2&&Util.n("Panel.rowSizing must be ProportionalExtra or None, not: "+t),this.V===null&&(this.V=new TablePanelSettings),this.V.wp=t,this.u(),this.i("rowSizing",i,t))}get columnSizing(){return this.V!==null?this.V.xp:3}set columnSizing(t){const i=this.columnSizing;i!==t&&(Debug&&t!==3&&t!==2&&Util.n("Panel.columnSizing must be ProportionalExtra or None, not: "+t),this.V===null&&(this.V=new TablePanelSettings),this.V.xp=t,this.u(),this.i("columnSizing",i,t))}get topIndex(){return this.V!==null?this.V.bp:0}set topIndex(t){const i=this.topIndex;i!==t&&((!isFinite(t)||t<0)&&Util.n("Panel.topIndex must be greater than zero and a real number, not: "+t),this.V===null&&(this.V=new TablePanelSettings),this.V.bp=t,this.u(),this.i("topIndex",i,t))}get leftIndex(){return this.V!==null?this.V.kp:0}set leftIndex(t){const i=this.leftIndex;i!==t&&((!isFinite(t)||t<0)&&Util.n("Panel.leftIndex must be greater than zero and a real number, not: "+t),this.V===null&&(this.V=new TablePanelSettings),this.V.kp=t,this.u(),this.i("leftIndex",i,t))}findRowForLocalY(t){if(t<0||this.type!==Panel.Table||this.rowCount===0)return-1;let i=0;const e=this.ve,s=e.length;let n=this.topIndex;for(;n{o.ch();const r=o.Ri;if(r!==null){o.w2(!1);const l=r.iterator;for(;l.next();){const h=l.value;h.mode===2&&o.w2(!0);const a=h.sourceName;if(h.isToObject){a==="/"&&n.X2(!0);const f=h.oL(n,o);f!==null&&(i.add(f),f.so===null&&(f.so=new List),f.so.add(h))}t.add(h)}}if(o instanceof Panel&&o.type===Panel.Table){if(o.rowCount>0){const l=o.ve,h=l.length;for(let a=0;a0){const l=o.Je,h=l.length;for(let a=0;a0&&o instanceof Panel){const h=r.substring(0,l),a=r.substring(l+1),f=o.findObject(h);f!==null?(o=f,n.targetProperty=a):(Util.ht('Warning: unable to find GraphObject named "'+h+'" for Binding: '+n.toString()),o=null)}if(o instanceof RowColumnDefinition){const h=GSet.gs(o.panel);n.targetId=h===void 0?-1:h,o.panel.eo=n.targetId}else if(o instanceof GraphObject){const h=GSet.gs(o);n.targetId=h===void 0?-1:h,o.eo=n.targetId}else Util.n("Unknown type of binding target: "+o);n.check(o)}}return t.w(),this instanceof Part&&(this.Ae()&&this.ensureBounds(),Debug&&!Panel.RL&&this.walkVisualTreeFrom(this,(n,o)=>{if(o instanceof Panel&&(o.type===Panel.Auto||o.type===Panel.Spot||o.type===Panel.Graduated)&&o.elements.count<=1&&!(o instanceof Part)){let r=!1;if(o.elements.count===1&&(r=o.itemArray!==null,!r)){for(s=t.iterator;s.next();)if(s.value.targetProperty==="itemArray"){r=!0;break}}r||(Util.ht("Auto, Spot, or Graduated Panel should not have zero or one elements: "+o.toString()+" in "+n.toString()),Panel.RL=!0)}})),this}static RL=!1;copyTemplate(t){t===void 0&&(t=!1);const i=this.copy();return i.mI(e=>{e instanceof Panel&&(e.Ws=null,e.si=null);const s=e.Ri;s!==null&&(e.Ri=null,s.each(o=>e.bind(o.copy())));const n=e.Ss;n!==null&&(e.Ss=null,n.each(o=>e.trigger(o.value.copy())))}),t&&i.ci(),i}updateTargetBindings(t){const i=this.Ws;if(i===null)return;t===void 0&&(t="");const e=i.iterator;for(;e.next();){const s=e.value,n=this.IL(s,t);if(n===null)continue;const{data:o,elt:r}=n;s.isToTheme&&this.diagram===null||r!==void 0&&s.updateTarget(r,o)}}Yo(){if(this.diagram!==null)if(this.M2()){const t=this.Ws.iterator;for(;t.next();){const i=t.value;if(!i.isToTheme)continue;const e=this.IL(i);if(e===null)continue;const{data:s,elt:n}=e;n!==void 0&&i.updateTarget(n,s)}}else{const t=this.D.h,i=t.length;for(let e=0;e0;let r=0;for(;n0){const i=this.D.elt(0);if(i.isPanelMain&&i instanceof Panel&&i.nl())return 1}return 0}rebuildItemElements(){const t=this.yp();for(;this.D.length>t;)this.oe(this.D.length-1,!1);this.OL(null,this.itemArray)}OL(t,i){const e=this.yp(),s=i;if(s===null||s.length===0){for(;this.D.length>e;)this.oe(this.D.length-1,!1);return}if(this.D.length<=e){const n=s.length;for(let o=0;o(w[w.Default=1]="Default",w[w.None=2]="None",w[w.ProportionalExtra=3]="ProportionalExtra",w))(Sizing||{});class RowColumnDefinition{Hs;Sp;Bt;La;Ta;ai;gt;Sd;ro;Jo;Md;Pd;Da;Ft;Nd;Js;lt;Zi;xe;constructor(t){GSet.vi(this),this.Hs=null,this.Sp=!0,this.Bt=0,this.xe=NaN,this.La=0,this.Ta=1/0,this.ai=Spot.Default,this.lt=0,this.Zi=0,this.gt=0,this.Js=null,this.Sd=1,this.ro=1,this.Jo=null,this.Md=null,this.Pd=NaN,this.Da=null,this.Ft=null,this.Nd=!1,t&&(Object.assign(this,t),t.column!==void 0?(this.isRow=!1,this.index=t.column):t.row!==void 0&&(this.isRow=!0,this.index=t.row))}copy(){const t=new RowColumnDefinition;return t.Sp=this.Sp,t.Bt=this.Bt,t.xe=this.xe,t.La=this.La,t.Ta=this.Ta,t.ai=this.ai,t.lt=this.lt,t.Zi=this.Zi,t.gt=this.gt,t.ro=this.ro,t.Sd=this.Sd,this.Jo===null?t.Jo=null:t.Jo=this.Jo.L(),t.Md=this.Md,t.Pd=this.Pd,t.Da=null,this.Da!==null&&(t.separatorDashArray=this.separatorDashArray.slice()),t.Ft=this.Ft,t.Nd=this.Nd,t.Js=this.Js,t}Z1(t){t.isRow?this.height=t.height:this.width=t.width,this.minimum=t.minimum,this.maximum=t.maximum,this.alignment=t.alignment,this.stretch=t.stretch,this.sizing=t.sizing,this.Jo=t.separatorPadding===null?null:t.separatorPadding.L(),this.separatorStroke=t.separatorStroke,this.separatorStrokeWidth=t.separatorStrokeWidth,this.Da=null,t.separatorDashArray&&(this.Da=t.separatorDashArray.slice()),this.background=t.background,this.coversSeparators=t.coversSeparators,this.Js=t.Js}fi(t){t in Sizing?this.sizing=t:Util.ur(this,t)}toString(){return"RowColumnDefinition "+(this.isRow?"(Row ":"(Column ")+this.index+") #"+GSet.gs(this)}static Default=1;static None=2;static ProportionalExtra=3;Pa(t){this.Hs=t}computeEffectiveSpacingTop(t){let i=0;const e=this.Hs;if(this.index!==t){let n=this.separatorStroke;n===null&&e!==null&&(n=this.isRow?e.defaultRowSeparatorStroke:e.defaultColumnSeparatorStroke),n!==null&&(i=this.separatorStrokeWidth,isNaN(i)&&(e!==null?i=this.isRow?e.defaultRowSeparatorStrokeWidth:e.defaultColumnSeparatorStrokeWidth:i=0))}let s=this.Jo;if(s===null)if(e!==null)s=e.defaultSeparatorPadding;else return i;return i+(this.isRow?s.top:s.left)}computeEffectiveSpacing(){let t=0;const i=this.Hs;let e=0;const s=this.isRow;if(i!==null&&i.type===Panel.Table){const o=s?i.ve.length:i.Je.length;for(let r=0;r= 0",RowColumnDefinition,"height"),this.xe=t,this.actual=this.lt,this.panel!==null&&this.panel.u(),this.i("height",i,t))}get width(){return this.xe}set width(t){const i=this.xe;i!==t&&(Debug&&Util.t(t,"number",RowColumnDefinition,"width"),t<0&&Util.G(t,">= 0",RowColumnDefinition,"width"),this.xe=t,this.actual=this.lt,this.panel!==null&&this.panel.u(),this.i("width",i,t))}get minimum(){return this.La}set minimum(t){const i=this.La;i!==t&&(Debug&&Util.t(t,"number",RowColumnDefinition,"minimum"),(t<0||!isFinite(t))&&Util.G(t,">= 0",RowColumnDefinition,"minimum"),this.La=t,this.actual=this.lt,this.panel!==null&&this.panel.u(),this.i("minimum",i,t))}get maximum(){return this.Ta}set maximum(t){const i=this.Ta;i!==t&&(Debug&&Util.t(t,"number",RowColumnDefinition,"maximum"),t<0&&Util.G(t,">= 0",RowColumnDefinition,"maximum"),this.Ta=t,this.actual=this.lt,this.panel!==null&&this.panel.u(),this.i("maximum",i,t))}get alignment(){return this.ai}set alignment(t){const i=this.ai;i.equals(t)||(Debug&&Util.s(t,Spot,RowColumnDefinition,"alignment"),this.ai=t.L(),this.panel!==null&&this.panel.u(),this.i("alignment",i,t))}get stretch(){return this.ro}set stretch(t){const i=this.ro;i!==t&&(this.ro=t,this.panel!==null&&this.panel.u(),this.i("stretch",i,t))}get separatorPadding(){return this.Jo}set separatorPadding(t){typeof t=="number"?t=new Margin(t):t!==null&&Debug&&Util.s(t,Margin,RowColumnDefinition,"separatorPadding");const i=this.Jo;(t===null||i===null||!i.equals(t))&&(t!==null&&(t=t.L()),this.Jo=t,this.panel!==null&&this.panel.u(),this.i("separatorPadding",i,t))}get separatorStroke(){return this.Md}set separatorStroke(t){const i=this.Md;i!==t&&(t!==null&&Brush.cd(t,"RowColumnDefinition.separatorStroke"),t instanceof Brush&&t.w(),this.Md=t,this.panel!==null&&this.panel.u(),this.i("separatorStroke",i,t))}get separatorStrokeWidth(){return this.Pd}set separatorStrokeWidth(t){const i=this.Pd;i!==t&&(this.Pd=t,this.panel!==null&&this.panel.u(),this.i("separatorStrokeWidth",i,t))}get separatorDashArray(){return this.Da}set separatorDashArray(t){const i=this.Da;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Bi(t,"Array",RowColumnDefinition,"separatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("separatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.Da=t,this.panel!==null&&this.panel.T(),this.i("separatorDashArray",i,t)}}get background(){return this.Ft}set background(t){const i=this.Ft;i!==t&&(t!==null&&Brush.cd(t,"RowColumnDefinition.background"),t instanceof Brush&&t.w(),this.Ft=t,this.panel!==null&&this.panel.T(),this.i("background",i,t))}get coversSeparators(){return this.Nd}set coversSeparators(t){const i=this.Nd;i!==t&&(Util.t(t,"boolean",RowColumnDefinition,"coversSeparators"),this.Nd=t,this.panel!==null&&this.panel.T(),this.i("coversSeparators",i,t))}get sizing(){return this.Sd}set sizing(t){const i=this.Sd;i!==t&&(Debug&&Util.tt(t,Sizing,"Sizing"),this.Sd=t,this.panel!==null&&this.panel.u(),this.i("sizing",i,t))}eb(){if(this.sizing===1){const t=this.Hs;return this.isRow?t.rowSizing:t.columnSizing}return this.sizing}get actual(){return this.lt}set actual(t){isNaN(this.xe)?this.lt=Math.max(Math.min(this.Ta,t),this.La):this.lt=Math.max(Math.min(this.Ta,this.xe),this.La)}get measured(){return this.Zi}set measured(t){this.Zi=t}get total(){return this.lt+this.computeEffectiveSpacing()}get position(){return this.gt}set position(t){this.gt=t}bind(t,i,e,s){return this.ac(t,i,e,s),this}bindTwoWay(t,i,e,s){const n=this.ac(t,i,e,s);return s===void 0&&n.makeTwoWay(),this}theme(t,i,e,s,n){return this.ph(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.ph(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.ph(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.ph(t,i,e,s,n).ofModel(),this}ac(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.$0(n),n}ph(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.$0(o),o}$0(t){t.Ce=this;const i=this.panel;if(i!==null){const e=i.findBindingPanel();e!==null&&e.yL()&&Util.n("Cannot add a Binding to a RowColumnDefinition that is already frozen: "+t+" on "+i)}this.Js===null&&(this.Js=new List),this.Js.add(t)}}class Shape extends GraphObject{mt;Ps;Cd;Fa;$i;Zo;jo;Rt;Ad;Ld;_;constructor(t,i){super(),this.mt=null,this.Ps=null,this.Cd="None",this.Fa="black",this.$i="black",this.Zo=1,this.jo=null,this.Rt=null,this.Ad=NaN,this.Ld=NaN,this._=null,typeof t=="string"?this.figure=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.mt=this.mt,t.Ps=this.Ps,t.Cd=this.Cd,t.Fa=this.Fa,t.$i=this.$i,t.Zo=this.Zo,this.jo!==null&&(t.jo=this.jo.slice()),this.Rt!==null&&(this.Rt.wi?t.Rt=this.Rt:t.Rt=this.Rt.copy()),t.Ad=this.Ad,t.Ld=this.Ld,this._!==null&&(t._=this._.copy())}Ra(){this.Rt===null?this.Rt=new ShapeTemplateSettings:this.Rt.wi&&(this.Rt=this.Rt.copy())}ch(){super.ch(),this.Rt!==null&&(this.Rt.wi=!0)}fi(t){t in GeometryStretch?this.geometryStretch=t:super.fi(t)}toString(){return"Shape("+(this.figure!=="None"?this.figure:this.toArrow!=="None"?this.toArrow:this.fromArrow)+")#"+GSet.gs(this)}SI(t,i){const e=this.pathPattern;e.wt(1/0,1/0);const s=e.measuredBounds;e.qt(0,0,s.width,s.height);const n=this.geometry;t.save(),t.beginPath();const o=Util.at();if(n.type===1)o.push(n.startX),o.push(n.startY),o.push(n.endX),o.push(n.endY),this.Td(t,i,o,e);else if(n.type===4){const r=n.figures.iterator;for(;r.next();){const l=r.value;o.length=0,o.push(l.startX),o.push(l.startY);let h=l.startX,a=l.startY,f=h,c=a;const u=l.segments.h,d=u.length;for(let m=0;m=.1;){if(P===0&&(M?(b=k,b-=S,y-=S,M=!1):b=k,b===0&&(b=1)),b>y){b=y,Util.nt(x);return}b>p?(P=b-p,b=p):P=0;let N=Math.sqrt(b*b/(1+m*m));if(u<0&&(N=-N),h+=N,a+=m*N,t.translate(h,a),t.rotate(g),t.translate(-(r/2),-(l/2)),P===0&&s.mh(t,i),t.translate(r/2,l/2),t.rotate(-g),t.translate(-h,-a),y-=b,p-=b,P!==0){if(A++,A===x.length){Util.nt(x);return}C=x[A],u=C[0],g=C[1],m=C[2],p=C[3],b=P}}Util.nt(x)}mh(t,i){const e=t instanceof SVGContext;let s=this.$i;const n=this.Fa;if(s===null&&n===null)return;const o=this.mt;if(o===null)return;t.commitTransform();const r=this.actualBounds,l=this.naturalBounds;n!==null&&this.wn(t,n,!0,!1,l,r);const h=this.part;let a=this.Zo;s!==null&&a===0&&h!==null&&(this.isPanelMain||h.findMainElement()===this)&&(a=h.NI()),a===0&&(s=null),s!==null&&a!==0&&(this.wn(t,s,!1,!1,l,r),t.lineWidth=a,t.lineJoin=this.strokeJoin,t.lineCap=this.strokeCap,t.miterLimit=this.strokeMiterLimit);let f=!1;h&&i.getRenderingHint("drawShadows")&&(f=h.isShadowed),t.ol===!1&&(f=!1);let c=!0;s!==null&&(n===null||n==="transparent")&&(c=!1);let u=!1;const d=this.strokeDashArray;if(d!==null&&(u=!0,t.enableDash(d,this.strokeDashOffset)),o.type===1)t.beginPath(),t.moveTo(o.startX,o.startY),t.lineTo(o.endX,o.endY),s!==null&&t.strokeContext(),t.endPath();else if(o.type===2){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.min(m,p),k=Math.min(g,y),b=Math.abs(p-m),S=Math.abs(y-g);t.beginPath(),t.rect(x,k,b,S),n!==null&&t.fillContext(n,!1,null),s!==null&&(c&&f&&t.shadowsOff(),t.strokeContext(),c&&f&&t.shadowsOn()),t.endPath()}else if(o.type===3){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.abs(p-m)/2,k=Math.abs(y-g)/2,b=Math.min(m,p)+x,S=Math.min(g,y)+k;t.beginPath(),t.moveTo(b,S-k),t.bezierCurveTo(b+Geo.Un*x,S-k,b+x,S-Geo.Un*k,b+x,S),t.bezierCurveTo(b+x,S+Geo.Un*k,b+Geo.Un*x,S+k,b,S+k),t.bezierCurveTo(b-Geo.Un*x,S+k,b-x,S+Geo.Un*k,b-x,S),t.bezierCurveTo(b-x,S-Geo.Un*k,b-Geo.Un*x,S-k,b,S-k),t.closePath(),n!==null&&t.fillContext(n,!1,null),s!==null&&(c&&f&&t.shadowsOff(),t.strokeContext(),c&&f&&t.shadowsOn()),t.endPath()}else if(o.type===4){const m=o.figures,g=m.length;for(let p=0;p1||this.pathPattern!==null?!0:super.ad(t)}m2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("path");for(let s=0;s1,i);Util.n("Unknown Geometry type: "+e.type)}}rd(t,i,e,s){const n=this.desiredSize,o=this.Zo;t=Math.max(t,0),i=Math.max(i,0);let r;if(this.Ps!==null)r=this.geometry.bounds;else{const g=this.figure;let p=Shape.G2[g];if(p===void 0){let y=Geo.qn[g];typeof y=="string"&&(y=Geo.qn[y]),typeof y=="function"?(p=y(null,100,100),Shape.G2[g]=p):Util.n("Unsupported Figure: "+g)}r=p.bounds}let l=r.width,h=r.height,a=r.width,f=r.height;switch(this.qs(!0)){case 0:e=0,s=0;break;case 2:a=Math.max(t-o,0),f=Math.max(i-o,0);break;case 5:a=Math.max(t-o,0),s=0;break;case 4:e=0,f=Math.max(i-o,0);break}isFinite(n.width)&&(a=n.width),isFinite(n.height)&&(f=n.height);const u=this.maxSize,d=this.minSize;e=Math.max(e-o,d.width),s=Math.max(s-o,d.height),a=Math.min(u.width,a),f=Math.min(u.height,f),a=isFinite(a)?Math.max(e,a):Math.max(l,e),f=isFinite(f)?Math.max(s,f):Math.max(h,s);const m=this.lM();switch(m){case 0:break;case 2:l=a,h=f;break;case 6:{let g=Math.min(a/l,f/h);isFinite(g)||(g=1),l=l*g,h=h*g;break}default:Util.n(m+" is not a valid geometryStretch.")}if(this.Ps!==null){l===0&&(l=.001),h===0&&(h=.001);const p=(this.Ps!==null?this.Ps:this.mt).ZD(l,h);Debug&&p.w(),this.mt=p}else(this.mt===null||!Geo.q(this.mt.cf,t-o)||!Geo.q(this.mt.uf,i-o))&&(this.mt=Shape.CI(this,l,h));r=this.mt.bounds,t===1/0||i===1/0?this.no(r.x-o/2,r.y-o/2,t===0&&l===0?0:r.width+o,i===0&&h===0?0:r.height+o):this.no(-(o/2),-(o/2),a+o,f+o),n.isReal()?(a=n.width,f=n.height,a=Math.min(u.width,a),f=Math.min(u.height,f),a=Math.max(d.width,a),f=Math.max(d.height,f),this.Hi.e(0,0,a,f)):this.Hi.c(r)}lM(){const t=this.geometryStretch;return this.Ps!==null?t===1?2:t:t===1?Shape.G2[this.figure].defaultStretch:t}dh(t,i,e,s){this.commonArrange(t,i,e,s)}getNearestIntersectionPoint(t,i,e){return this.nc(t.x,t.y,i.x,i.y,e)}nc(t,i,e,s,n){const o=this.O,r=1/(o.m11*o.m22-o.m12*o.m21),l=o.m22*r,h=-o.m12*r,a=-o.m21*r,f=o.m11*r,c=r*(o.m21*o.dy-o.m22*o.dx),u=r*(o.m12*o.dx-o.m11*o.dy),d=t*l+i*a+c,m=t*h+i*f+u,g=e*l+s*a+c,p=e*h+s*f+u,y=this.Zo/2;let x=this.mt;x===null&&(this.wt(1/0,1/0),x=this.mt);const k=x.bounds;let b=!1;if(x.type===1)if(this.strokeWidth<=1.5)b=Geo.Hn(x.startX,x.startY,x.endX,x.endY,d,m,g,p,n);else{let S=0,M=0;if(x.startX===x.endX)S=y,M=0;else{const T=(x.endY-x.startY)/(x.endX-x.startX);M=y/Math.sqrt(1+T*T),S=M*T}const A=Util.at();let C=new Point;Geo.Hn(x.startX+S,x.startY+M,x.endX+S,x.endY+M,d,m,g,p,C)&&A.push(C),C=new Point,Geo.Hn(x.startX-S,x.startY-M,x.endX-S,x.endY-M,d,m,g,p,C)&&A.push(C),C=new Point,Geo.Hn(x.startX+S,x.startY+M,x.startX-S,x.startY-M,d,m,g,p,C)&&A.push(C),C=new Point,Geo.Hn(x.endX+S,x.endY+M,x.endX-S,x.endY-M,d,m,g,p,C)&&A.push(C);const P=A.length;if(P===0)return Util.nt(A),!1;b=!0;let N=1/0;for(let T=0;T0&&k.contains(D,F)&&(P.x=D,P.y=F,this.containsPoint(P)))for(N!==0&&Math.abs(N)<.5?(T*=.5/N,N=.5):T!==0&&Math.abs(T)<.5&&(N*=.5/T,T=.5),D-=N,F-=T;k.contains(D,F);)D-=N,F-=T;const R=.6;n.x=g,n.y=p;for(let K=0;Ke?t-e:e-t)<(i>s?i-s:s-i)){const c=ic||Geo.q(h.y,c))&&(h.yc||Geo.q(h.x,c))&&(h.x=a&&h<=f}else{let a=0,f=0;return s=a&&l<=f}}TI(t,i){if(this.containedInRect(t,i)||i===void 0&&(i=this.O,t.containsRect(this.actualBounds)))return!0;const e=t.left,s=t.right,n=t.top,o=t.bottom,r=Point.a(),l=Point.a(),h=Point.a(),a=Transform.a();a.set(i),a.mC(this.O),a.Pw(),l.x=s,l.y=n,l.O(a),r.x=e,r.y=n,r.O(a);let f=!1;return this.Ia(r,l,h)?f=!0:(r.x=s,r.y=o,r.O(a),this.Ia(r,l,h)?f=!0:(l.x=e,l.y=o,l.O(a),this.Ia(r,l,h)?f=!0:(r.x=e,r.y=n,r.O(a),this.Ia(r,l,h)&&(f=!0)))),Transform.o(a),Point.o(r),Point.o(l),Point.o(h),f}lL(t,i,e){if(e&&this.fill!==null&&this.uh(t,!0))return!0;let s=t.distanceSquaredPoint(i);const n=s;this.strokeWidth>1.5&&(s=this.strokeWidth/2+Math.sqrt(s),s*=s);let o=this.mt;if(o===null&&(this.wt(1/0,1/0),o=this.mt,o===null))return!1;if(!e){const c=o.bounds,u=c.x,d=c.y,m=c.x+c.width,g=c.y+c.height;if(Point.distanceSquared(t.x,t.y,u,d)<=s&&Point.distanceSquared(t.x,t.y,m,d)<=s&&Point.distanceSquared(t.x,t.y,u,g)<=s&&Point.distanceSquared(t.x,t.y,m,g)<=s)return!0}function r(c,u){const d=c.length;for(let m=0;ms)return!0;return!1}const l=o.startX,h=o.startY,a=o.endX,f=o.endY;if(o.type===1){const c=Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,f),u=(a-l)*(t.x-l)+(f-h)*(t.y-h),d=(l-a)*(t.x-a)+(h-f)*(t.y-f),m=u>=0&&d>=0?s:n;return c<=m}else if(o.type===2){let c=!1;return e&&(c=Point.distanceLineSegmentSquared(t.x,t.y,l,h,l,f)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,h)<=s||Point.distanceLineSegmentSquared(t.x,t.y,a,h,a,f)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,f,a,f)<=s),c}else if(o.type===3){const c=(l+a)/2,u=(h+f)/2,d=t.x-c,m=t.y-u,g=Math.abs(a-l)/2,p=Math.abs(f-h)/2;if(g===0||p===0)return Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,f)<=s;if(e){const y=Geo.KD(g,p,d,m);return y*y<=s}else return!(Point.distanceSquared(d,m,-g,0)>=s||Point.distanceSquared(d,m,0,-p)>=s||Point.distanceSquared(d,m,0,p)>=s||Point.distanceSquared(d,m,g,0)>=s)}else if(o.type===4){const c=o.bounds,u=c.x,d=c.y,m=c.x+c.width,g=c.y+c.height;if(t.x>m&&t.xg&&t.ys&&Point.distanceLineSegmentSquared(t.x,t.y,u,d,m,d)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,u,g)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,m,d)>s)return!1;const p=Math.sqrt(s);if(e){if(this.fill===null?o.CC(t.x,t.y,p):o.vk(t,p,!0,!1))return!0}else{const y=o.figures;for(let x=0;xs)return!1;const M=k.segments.h,A=M.length;for(let C=0;Cs)return!1;break;case 3:{const N=Util.at();Geo.Gn(b,S,P.point1X,P.point1Y,P.point2X,P.point2Y,P.endX,P.endY,.8,N);const T=r(N,t);if(Util.nt(N),T||(b=P.endX,S=P.endY,t.distanceSquared(b,S)>s))return!1;break}case 4:{const N=Util.at();Geo.qg(b,S,P.point1X,P.point1Y,P.endX,P.endY,.8,N);const T=r(N,t);if(Util.nt(N),T||(b=P.endX,S=P.endY,t.distanceSquared(b,S)>s))return!1;break}case 5:case 6:{const N=P.type===5?P.To(k):P.Yh(k,b,S),T=N.length;if(T===0){if(b=P.type===5?P.centerX:P.endX,S=P.type===5?P.centerY:P.endY,t.distanceSquared(b,S)>s)return!1;break}let L=null;const D=Util.at();for(let F=0;F=0){this.Zo=t,this.u();const e=this.part;e!==null&&e.pc(),this.i("strokeWidth",i,t)}else Util.G(t,"value >= 0",Shape,"strokeWidth:value")}N0(){return this.Zo}get strokeCap(){return this.Rt!==null?this.Rt.Mp:"butt"}set strokeCap(t){const i=this.strokeCap;i!==t&&(typeof t=="string"&&(t==="butt"||t==="round"||t==="square")?(this.Ra(),this.Rt.Mp=t,this.T(),this.i("strokeCap",i,t)):Util.G(t,'"butt", "round", or "square"',Shape,"strokeCap"))}get strokeJoin(){return this.Rt!==null?this.Rt.Pp:"miter"}set strokeJoin(t){const i=this.strokeJoin;i!==t&&(typeof t=="string"&&(t==="miter"||t==="bevel"||t==="round")?(this.Ra(),this.Rt.Pp=t,this.T(),this.i("strokeJoin",i,t)):Util.G(t,'"miter", "bevel", or "round"',Shape,"strokeJoin"))}get strokeMiterLimit(){return this.Rt!==null?this.Rt.Np:10}set strokeMiterLimit(t){const i=this.strokeMiterLimit;if(i!==t)if(Debug&&Util.r(t,Shape,"strokeMiterLimit"),t>=1){this.Ra(),this.Rt.Np=t,this.T();const e=this.part;e!==null&&e.pc(),this.i("strokeMiterLimit",i,t)}else Debug&&Util.G(t,"value >= 1",Shape,"strokeWidth:value")}get strokeDashArray(){return this.jo}set strokeDashArray(t){const i=this.jo;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Bi(t,"Array",Shape,"strokeDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("strokeDashArray:value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.jo=t,this.T(),this.i("strokeDashArray",i,t)}}get strokeDashOffset(){return this.Rt!==null?this.Rt.yh:0}set strokeDashOffset(t){const i=this.strokeDashOffset;i!==t&&(Debug&&Util.r(t,Shape,"strokeDashOffset"),t>=0&&(this.Ra(),this.Rt.yh=t,this.T(),this.i("strokeDashOffset",i,t)))}get figure(){return this.Cd}set figure(t){const i=this.Cd;if(i!==t){Debug&&Util.t(t,"string",Shape,"figure");let e=Geo.qn[t];if(typeof e=="function"?e=t:(e=Geo.qn[t.toLowerCase()],e||Util.n("Unknown Shape.figure: "+t)),i!==e){const s=this.part;s!==null&&s.pc(),this.Cd=e,this.Ps=null,this.le(),this.u(),this.i("figure",i,e)}}}get toArrow(){return this.Ut!==null?this.Ut.Cp:"None"}set toArrow(t){const i=this.toArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){Debug&&Util.t(t,"string",Shape,"toArrow");const e=Shape.VL(t);e===null?Util.n("Unknown Shape.toArrow: "+t):i!==e&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.Cp=e,this.Ps=null,this.le(),this.u(),this.zL(e),this.i("toArrow",i,e))}}get fromArrow(){return this.Ut!==null?this.Ut.Ap:"None"}set fromArrow(t){const i=this.fromArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){Debug&&Util.t(t,"string",Shape,"fromArrow");const e=Shape.VL(t);e===null?Util.n("Unknown Shape.fromArrow: "+t):i!==e&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.Ap=e,this.Ps=null,this.le(),this.u(),this.zL(e),this.i("fromArrow",i,e))}}zL(t){const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;this.YR();const e=Spot.MiddleRight;this.toArrow!=="None"?(this.segmentIndex=-1,this.alignmentFocus=e):this.fromArrow!=="None"&&(this.segmentIndex=0,this.alignmentFocus=new Spot(1-e.x,e.y))}get spot1(){return this.Rt!==null?this.Rt.jn:Spot.Default}set spot1(t){Util.s(t,Spot,Shape,"spot1");const i=this.spot1;i.equals(t)||(t=t.L(),this.Ra(),this.Rt.jn=t,this.u(),this.i("spot1",i,t))}get spot2(){return this.Rt!==null?this.Rt.Wn:Spot.Default}set spot2(t){Util.s(t,Spot,Shape,"spot2");const i=this.spot2;i.equals(t)||(t=t.L(),this.Ra(),this.Rt.Wn=t,this.u(),this.i("spot2",i,t))}get parameter1(){return this.Ad}set parameter1(t){const i=this.Ad;i!==t&&(this.Ad=t,this.le(),this.u(),this.i("parameter1",i,t))}get parameter2(){return this.Ld}set parameter2(t){const i=this.Ld;i!==t&&(this.Ld=t,this.le(),this.u(),this.i("parameter2",i,t))}get naturalBounds(){return this.Hi}rI(){const t=this.desiredSize;if(!t.isReal()&&this.mt!==null){const i=this.mt.bounds;this.Hi.c(i)}else this.Hi.e(0,0,t.width,t.height)}get pathPattern(){return this.Rt!==null?this.Rt.Lp:null}set pathPattern(t){const i=this.pathPattern;i!==t&&(Debug&&t!==null&&Util.s(t,GraphObject,Shape,"pathPattern"),this.Ra(),this.Rt.Lp=t,this.T(),this.i("pathPattern",i,t))}get geometryStretch(){return this.Rt!==null?this.Rt.Tp:1}set geometryStretch(t){const i=this.geometryStretch;i!==t&&(Util.tt(t,GeometryStretch,"GeometryStretch"),this.Ra(),this.Rt.Tp=t,this.u(),this.i("geometryStretch",i,t))}get interval(){return this._!==null?this._.wc:1}set interval(t){const i=this.interval;if(Debug&&Util.r(t,Shape,"interval"),t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this._===null&&(this._=new GradElementSettings),this._.wc=t;const e=this.diagram;e!==null&&this.panel===e.grid&&e.Zr(),this.u();const s=this.panel;s!==null&&(s.as=null),this.i("interval",i,t)}}get graduatedStart(){return this._!==null?this._.xc:0}set graduatedStart(t){const i=this.graduatedStart;Debug&&Util.r(t,Shape,"graduatedStart"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.xc=t,this.u(),this.i("graduatedStart",i,t))}get graduatedEnd(){return this._!==null?this._.bc:1}set graduatedEnd(t){const i=this.graduatedEnd;Debug&&Util.r(t,Shape,"graduatedEnd"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.bc=t,this.u(),this.i("graduatedEnd",i,t))}get graduatedSkip(){return this._!==null?this._.kc:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.t(t,"function",Shape,"graduatedSkip"),this._===null&&(this._=new GradElementSettings),this._.kc=t,this.u(),this.i("graduatedSkip",i,t))}static CI(t,i,e){let n=null;if(t.toArrow!=="None")n=Shape.fo[t.toArrow];else if(t.fromArrow!=="None")n=Shape.fo[t.fromArrow];else{let o=Geo.qn[t.figure];typeof o=="string"&&(o=Geo.qn[o]),o===void 0&&Util.n("Unknown Shape.figure: "+t.figure),n=o(t,i,e),n.cf=i,n.uf=e}if(n===null){const o=Geo.qn.Rectangle;typeof o=="function"&&(n=o(t,i,e))}return Debug&&(n.bounds.width>i+1e-5||n.bounds.height>e+1e-5)&&Util.n('Geometry made with figure "'+t.figure+'" has bounds '+n.bounds.toString()+" that are too large for the given size ("+i+","+e+"). See documentation for Shape.defineFigureGenerator."),n}static getFigureGenerators(){const t=new GMap;for(const i in Geo.qn){if(i===i.toLowerCase())continue;const e=Geo.qn[i];t.set(i,e)}return t.w(),t}static defineFigureGenerator(t,i){Util.t(t,"string",Shape,"defineFigureGenerator:name"),typeof i=="string"?Debug&&(i===""||!Geo.qn[i])&&Util.n("Shape.defineFigureGenerator synonym must not be empty or None or not a defined figure name: "+i):Util.t(i,"function",Shape,"defineFigureGenerator:func");const e=t.toLowerCase();Debug&&(t===""||t===e)&&Util.n("Shape.defineFigureGenerator name must not be empty or all-lower-case: "+t);const s=Geo.qn;s[t]=i,s[e]=t}static getArrowheadGeometries(){const t=new GMap;for(const i in Geo.Jg)if(Shape.fo[i]===void 0){const e=Geometry.parse(Geo.Jg[i],!1);Shape.fo[i]=e;const s=i.toLowerCase();s!==i&&(Shape.fo[s]=i)}for(const i in Shape.fo){if(i===i.toLowerCase())continue;const e=Shape.fo[i];e instanceof Geometry&&t.set(i,e)}return t.w(),t}static defineArrowheadGeometry(t,i){Util.t(t,"string",Shape,"defineArrowheadGeometry:name");let e=null;typeof i=="string"?(Util.t(i,"string",Shape,"defineArrowheadGeometry:pathstr"),e=Geometry.parse(i,!1)):(Util.s(i,Geometry,Shape,"defineArrowheadGeometry:pathstr"),e=i);const s=t.toLowerCase();(Debug&&t===""||s==="none"||t===s)&&Util.n("Shape.defineArrowheadGeometry name must not be empty or None or all-lower-case: "+t);const n=Shape.fo;n[t]=e,n[s]=t}static fo=new PropertyCollection;static G2=new PropertyCollection;static VL(t){let i=Shape.fo[t];if(i===void 0){const e=t.toLowerCase();if(e==="none")return"None";if(i=Shape.fo[e],i===void 0){let s=null;for(const n in Geo.Jg)if(n.toLowerCase()===e){s=n;break}if(s!==null){const n=Geometry.parse(Geo.Jg[s],!1);return Shape.fo[s]=n,e!==s&&(Shape.fo[e]=s),s}}}return typeof i=="string"?i:i instanceof Geometry?t:null}}class ShapeTemplateSettings{wi;Mp;Pp;Np;yh;Lp;Tp;jn;Wn;constructor(){this.wi=!1,this.Mp="butt",this.Pp="miter",this.Np=10,this.yh=0,this.Lp=null,this.Tp=1,this.jn=Spot.Default,this.Wn=Spot.Default}copy(){const t=new ShapeTemplateSettings;return t.Mp=this.Mp,t.Pp=this.Pp,t.Np=this.Np,t.yh=this.yh,t.Lp=this.Lp,t.Tp=this.Tp,t.jn=this.jn.L(),t.Wn=this.Wn.L(),t}}var Wrap=(w=>(w[w.None=0]="None",w[w.Fit=1]="Fit",w[w.DesiredSize=2]="DesiredSize",w[w.BreakAll=3]="BreakAll",w))(Wrap||{}),TextOverflow=(w=>(w[w.Clip=0]="Clip",w[w.Ellipsis=1]="Ellipsis",w))(TextOverflow||{}),TextFormat=(w=>(w[w.Trim=0]="Trim",w[w.None=1]="None",w))(TextFormat||{});class TextBlock extends GraphObject{ui;$i;Cn;Fe;xi;C0;Dd;_;$;Ol;co;An;Re;Oi;Ln;constructor(t,i){return super(),this.l|=2097152,this.ui="",this.$i="black",this.Cn="13px sans-serif",this.Fe=0,this.xi=0,this.C0=0,this.Dd=null,this._=null,this.$=null,this.Ol=0,this.co=null,this.An=0,this.Re=null,this.Oi=null,this.Ln=null,typeof t=="string"?this.text=t:t&&Object.assign(this,t),i&&Object.assign(this,i),this}cloneProtected(t){super.cloneProtected(t),t.ui=this.ui,t.$i=this.$i,t.Cn=this.Cn,t.Fe=this.Fe,t.xi=this.xi,t.C0=this.C0,t.Dd=this.Dd,this._!==null&&(t._=this._.copy()),this.$!==null&&(this.$.wi?t.$=this.$:t.$=this.$.copy()),t.Ol=this.Ol,t.co=this.co,t.An=this.An,t.Re=this.Re,t.Oi=this.Oi,t.Ln=this.Ln}Tn(){this.$===null?this.$=new TextBlockTemplateSettings:this.$.wi&&(this.$=this.$.copy())}ch(){super.ch(),this.$!==null&&(this.$.wi=!0)}dI(t){this.l=t.l|2048|4096,this._t=t.opacity,this.Ft=t.background,this.qe=t.desiredSize.L(),this.minSize=t.minSize.L(),this.maxSize=t.maxSize.L(),t.Pi!==null?this.Pi=t.Pi.copy():this.Pi=null,this.rt=t.scale,this.jt=t.angle,this.stretch=t.stretch,this.el=t.margin.L(),this.ai=t.alignment.L(),this.ic=t.alignmentFocus.L(),this.segmentFraction=t.segmentFraction,this.segmentOffset=t.segmentOffset.L(),this.segmentOrientation=t.segmentOrientation,t.hi!==null&&(this.hi=t.hi.copy()),this.shadowVisible=t.shadowVisible,this.ui=t.ui,this.$i=t.$i,this.Cn=t.Cn,this._!==null&&(this._=t._.copy()),t.$!==null&&(t.$.wi?this.$=t.$:this.$=t.$.copy()),this.Ol=t.Ol}cI(t){if(this.ui=t.text||"",this.jt=t.labelAngle||0,this.Fe=t.lineCount||0,this.DI(t.lines),t.naturalBounds&&(this.Hi=t.naturalBounds),t.actualBounds){const i=t.actualBounds;this.qt(i.x,i.y,i.width,i.height)}}fi(t){t in Wrap?this.wrap=t:super.fi(t)}toString(){return this.ui.length>22?'TextBlock("'+this.ui.substring(0,20)+'"...)':'TextBlock("'+this.ui+'")'}static getEllipsis(){return TextBlock.Dp}static setEllipsis(t){TextBlock.Dp=t,TextBlock.ab=new PropertyCollection,TextBlock.H2=0}static getBaseline(){return TextBlock.fb}static setBaseline(t){TextBlock.fb=t}static fb=null;static getUnderline(){return TextBlock.cb}static setUnderline(t){TextBlock.cb=t}static cb=null;static None=0;static WrapFit=1;static WrapDesiredSize=2;static WrapBreakAll=3;static OverflowClip=0;static OverflowEllipsis=1;static FormatTrim=0;static FormatNone=1;u(){super.u()}get font(){return this.Cn}set font(t){const i=this.Cn;i!==t&&(Debug&&(Util.t(t,"string",TextBlock,"font"),TextBlock.isValidFont(t)||Util.n('Not a valid font: "'+t+'"')),this.Cn=t,this.co=null,this.u(),this.i("font",i,t))}static isValidFont(t){return root.CSS?root.CSS.supports("font",t):!0}get text(){return this.ui}set text(t){const i=this.ui;t!=null?t=t.toString():t="",i!==t&&(this.ui=t,this.u(),this.i("text",i,t),this.hs(!0))}get textAlign(){return this.$!==null?this.$.Fp:"start"}set textAlign(t){const i=this.textAlign;i!==t&&(Debug&&Util.t(t,"string",TextBlock,"textAlign"),t==="start"||t==="end"||t==="left"||t==="right"||t==="center"?(this.Tn(),this.$.Fp=t,this.T(),this.i("textAlign",i,t)):Debug&&Util.G(t,'"start", "end", "left", "right", or "center"',TextBlock,"textAlign"))}get flip(){return this.$!==null?this.$.uo:0}set flip(t){const i=this.flip;i!==t&&(Util.tt(t,Flip,"Flip"),this.Tn(),this.$.uo=t,this.T(),this.i("flip",i,t))}get verticalAlignment(){return this.$!==null?this.$.hl:Spot.Top}set verticalAlignment(t){const i=this.verticalAlignment;i.equals(t)||(Debug&&(Util.s(t,Spot,TextBlock,"verticalAlignment"),t.isNoSpot()&&Util.n("TextBlock.verticalAlignment for "+this+" must be a real Spot, not:"+t)),t=t.L(),this.Tn(),this.$.hl=t,this.hc(),this.i("verticalAlignment",i,t))}get naturalBounds(){if(!this.Hi.isReal()){const t=Size.a();this.q2(this.ui,999999,t);let i=t.width;Size.o(t);let e=this.XL(i);const s=this.desiredSize;isNaN(s.width)||(i=s.width),isNaN(s.height)||(e=s.height),this.Hi.Kn(i,e)}return this.Hi}get isMultiline(){return(this.l&2097152)!==0}set isMultiline(t){const i=(this.l&2097152)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"isMultiline"),this.l=this.l^2097152,this.u(),this.i("isMultiline",i,t))}get isUnderline(){return(this.l&4194304)!==0}set isUnderline(t){const i=(this.l&4194304)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"isUnderline"),this.l=this.l^4194304,this.hs(!0),this.T(),this.i("isUnderline",i,t))}get isStrikethrough(){return(this.l&8388608)!==0}set isStrikethrough(t){const i=(this.l&8388608)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"isStrikethrough"),this.l=this.l^8388608,this.hs(!0),this.T(),this.i("isStrikethrough",i,t))}get wrap(){return this.$!==null?this.$.Rp:2}set wrap(t){const i=this.wrap;i!==t&&(Debug&&Util.tt(t,Wrap,"Wrap"),this.Tn(),this.$.Rp=t,this.u(),this.i("wrap",i,t))}get overflow(){return this.$!==null?this.$.Ip:0}set overflow(t){const i=this.overflow;i!==t&&(Debug&&Util.tt(t,TextOverflow,"Overflow"),this.Tn(),this.$.Ip=t,this.u(),this.i("overflow",i,t))}get isOverflowed(){return(this.l&16777216)!==0}j2(t){t?this.l|=16777216:this.l&=-16777217}get stroke(){return this.$i}set stroke(t){const i=this.$i;i!==t&&(t!==null&&Brush.cd(t,"TextBlock.stroke"),t instanceof Brush&&t.w(),this.$i=t,this.T(),this.i("stroke",i,t))}get lineCount(){return this.Fe}get lineHeight(){return this.Op()}get editable(){return(this.l&1048576)!==0}set editable(t){const i=(this.l&1048576)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"editable"),this.l=this.l^1048576,this.i("editable",i,t))}get E2(){return(this.l&33554432)!==0}set E2(t){this.l=this.l^33554432}get textEditor(){return this.$!==null?this.$.Ep:null}set textEditor(t){const i=this.textEditor;i!==t&&(Debug&&!(t instanceof HTMLInfo)&&Util.n("TextBlock.textEditor must be an HTMLInfo."),this.Tn(),this.$.Ep=t,this.i("textEditor",i,t))}get errorFunction(){return this.$!==null?this.$.fs:null}set errorFunction(t){const i=this.errorFunction;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"errorFunction"),this.Tn(),this.$.fs=t,this.i("errorFunction",i,t))}get interval(){return this._!==null?this._.wc:1}set interval(t){const i=this.interval;if(Debug&&Util.r(t,TextBlock,"interval"),t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this._===null&&(this._=new GradElementSettings),this._.wc=t,this.u();const e=this.panel;e!==null&&(e.as=null),this.i("interval",i,t)}}get graduatedStart(){return this._!==null?this._.xc:0}set graduatedStart(t){const i=this.graduatedStart;Debug&&Util.r(t,TextBlock,"graduatedStart"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.xc=t,this.u(),this.i("graduatedStart",i,t))}get graduatedEnd(){return this._!==null?this._.bc:1}set graduatedEnd(t){const i=this.graduatedEnd;Debug&&Util.r(t,TextBlock,"graduatedEnd"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.bc=t,this.u(),this.i("graduatedEnd",i,t))}get graduatedFunction(){return this._!==null?this._.Bp:null}set graduatedFunction(t){const i=this.graduatedFunction;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"graduatedFunction"),this._===null&&(this._=new GradElementSettings),this._.Bp=t,this.u(),this.i("graduatedFunction",i,t))}get graduatedSkip(){return this._!==null?this._.kc:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"graduatedSkip"),this._===null&&(this._=new GradElementSettings),this._.kc=t,this.u(),this.i("graduatedSkip",i,t))}mh(t,i){if(this.$i===null||this.ui.length===0||this.Cn===null)return;const e=this.naturalBounds,s=this.actualBounds,n=e.width,o=e.height,r=this.Op();let l=t.textAlign=this.textAlign;const h=i.vu;l==="start"?l=h?"right":"left":l==="end"&&(l=h?"left":"right");const a=this.isUnderline,f=this.isStrikethrough;this.wn(t,this.$i,!0,!1,e,s),(a||f)&&this.wn(t,this.$i,!1,!1,e,s);const c=0;let u=0;const d=n;let m=!1;i.ei===t&&!(i.ei instanceof SVGContext)&&!this.E2&&i.getRenderingHint("textGreeking")===!0&&r*this.ma*i.scale<3&&(m=!0);const g=this.spacingAbove,p=this.spacingBelow;switch(this.flip){case 0:break;case 2:t.translate(n,0),t.scale(-1,1);break;case 1:t.translate(0,o),t.scale(1,-1);break;case 3:t.translate(n,o),t.scale(-1,-1);break}t.commitTransform();const y=this.Fe,k=(g+r+p)*y;if(o>k){const b=this.verticalAlignment;u=b.y*o-b.y*k+b.offsetY}if(y===1&&this.Ln!==null){let b=this.xi;b>d&&(b=d),u+=g,this.YL(this.Ln,t,c,u,d,r,b,m,l,a,f)}else if(this.Re!==null&&this.Oi!==null)for(let b=0;bd&&(S=d),u+=g,this.YL(this.Oi[b],t,c,u,d,r,S,m,l,a,f),u+=r+p}switch(this.flip){case 0:break;case 2:t.scale(-1,1),t.translate(-n,0);break;case 1:t.scale(1,-1),t.translate(0,-o);break;case 3:t.scale(-1,-1),t.translate(-n,-o);break}}YL(t,i,e,s,n,o,r,l,h,a,f){let c=0;if(l){h==="left"?c=0:h==="right"?c=n-r:h==="center"&&(c=(n-r)/2);const m=i.globalAlpha;i.globalAlpha=m/2,i.fillRect(e+c,s+o/4,r,o/2),i.globalAlpha=m;return}h==="left"?c=0:h==="right"?c=n:h==="center"&&(c=n/2);const u=TextBlock.fb!==null?TextBlock.fb(this,o):o*.75;i.fillText(t,e+c,s+u);let d=o/20|0;if(d===0&&(d=1),h==="right"?c-=r:h==="center"&&(c-=r/2),a){const m=TextBlock.cb!==null?TextBlock.cb(this,o):o*.8;this.KL(e+c,s+m,e+c+r,s+m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}if(f){let m=s+o-o/2.2|0;d%2!==0&&(m+=.5),this.KL(e+c,m,e+c+r,m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}}KL(t,i,e,s,n,o){o.beginPath(),o.lineWidth=n,o.moveTo(t,i),o.lineTo(e,s),o.stroke(),o.endPath()}oc(t,i,e){if(!super.oc(t,i,e))return!1;if(this.wn(t,this.$i,!0,!1,this.naturalBounds,this.actualBounds),e){if(this.svg.getElementsByTagName("text").length===0)return!0;const n=this.svg.getElementsByClassName("gojs-td");for(let o=0;o1||this.isUnderline||this.isStrikethrough?!0:super.ad(t)}m2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("text");for(let s=0;sthis.maxLines&&(this.l|=16777216))}q2(t,i,e){const s=this.formatting===0;s&&(t=t.trim());let n=0,o=0,r=0;const l=this.Cn,h=this.spacingAbove+this.spacingBelow,a=Math.max(0,this.Op()+h),f=this.overflow===1?this.GL(l):0;if(this.Fe>=this.maxLines){e!==null&&e.e(0,a);return}let c=t;if(this.wrap===0){if(this.An=1,o=this.getStringWidth(t),f===0||o<=i){this.xi=Math.max(this.xi,o),this.Dn(t,this.xi),e!==null&&e.e(o,a);return}let d=this.Fd(c);c=c.substring(d.length);let m=this.Fd(c);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,c=c.substring(m.length),m=this.Fd(c),r=o;let g=d+m;s&&(g=g.trim()),o=this.getStringWidth(g)}for(s&&(m=m.trim()),d+=m,i=Math.max(1,i-f);this.getStringWidth(d)>i&&d.length>1;)d=d.substring(0,d.length-1);this.j2(!0),d+=TextBlock.Dp,r=this.getStringWidth(d),this.xi=r,this.Dn(d,r),e!==null&&e.e(r,a);return}let u=0;for(c.length===0&&(u=1,this.Dn(c,0));c.length>0;){let d=this.Fd(c);for(c=c.substring(d.length);this.getStringWidth(d)>i;){let p=1;for(o=this.getStringWidth(d.substring(0,p)),r=0;o<=i;)p++,r=o,o=this.getStringWidth(d.substring(0,p));let y=0;p===1?(y=o,n=Math.max(n,o)):(y=r,n=Math.max(n,r)),p--,p<1&&(p=1);const x=d.substring(0,p);if(this.Dn(x,y),u++,d=d.substring(p),this.Fe+u>this.maxLines)break}let m=this.Fd(c);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,c=c.substring(m.length),m=this.Fd(c),r=o;let p=d+m;s&&(p=p.trim()),o=this.getStringWidth(p)}if(s&&(d=d.trim()),d==="")continue;d[d.length-1]==="\xAD"&&(d=d.substring(0,d.length-1)+"\u2010");let g=0;if(m.length===0?(g=o,n=Math.max(n,o)):(r=this.getStringWidth(d),g=r,n=Math.max(n,r)),this.Dn(d,g),u++,this.Fe+u>this.maxLines)break}this.An=Math.min(this.maxLines,u),this.xi=Math.max(this.xi,n),e!==null&&e.e(this.xi,a*this.An)}OI(t,i){if(this.xi===0||this.Re===null||this.Oi===null||this.overflow!==1)return;const e=this.Cn,s=this.overflow===1?this.GL(e):0,n=this.spacingAbove+this.spacingBelow,o=Math.max(0,this.Op()+n),r=Math.min(this.maxLines-1,Math.max(Math.floor(i/o+.01)-1,0));if(r+1>=this.Oi.length)return;this.j2(!0);let l=this.Oi[r];const h=Math.max(1,t-s);for(;this.getStringWidth(l)>h&&l.length>1;)l=l.substring(0,l.length-1);l+=TextBlock.Dp;const a=this.getStringWidth(l);this.Oi[r]=l,this.Oi=this.Oi.slice(0,r+1),this.Re[r]=a,this.Re=this.Re.slice(0,r+1),this.An=this.Oi.length,this.xi=Math.max(this.xi,a),this.Fe=this.An,this.Fe===1&&(this.Ln=this.Oi[0])}Fd(t){if(this.wrap===3)return t.substring(0,1);let i=t.length,e=0;const s=TextBlock.EI;for(;e=t.length?t:t.substring(0,e)}getStringWidth(t){return TextBlock.rl===null?t.length*8:TextBlock.rl.measureText(t).width}Op(){if(this.co!==null)return this.co;const t=this.Cn;let i=0;return TextBlock.rl===null?(i=16,this.co=i,i):(TextBlock.W2[t]!==void 0&&TextBlock.HL<5e3?i=TextBlock.W2[t]:(i=TextBlock.rl.measureText("M").width*1.3,TextBlock.W2[t]=i,TextBlock.HL++),this.co=i,i)}GL(t){if(TextBlock.rl===null)return 6;let i=0;return TextBlock.ab[t]!==void 0&&TextBlock.H2<5e3?i=TextBlock.ab[t]:(i=TextBlock.rl.measureText(TextBlock.Dp).width,TextBlock.ab[t]=i,TextBlock.H2++),i}ub(t,i){return t.indexOf(` `,i)}XL(t){let i=this.ui.replace(/\r\n/g,` `).replace(/\r/g,` -`);const e=this.spacingAbove+this.spacingBelow,s=Math.max(0,this.Op()+e);if(i.length===0)return this.xi=0,this.Fe=1,s;if(!this.isMultiline){const h=this.ub(i,0);h>=0&&(i=i.substring(0,h))}let n=0;this.Fe=0;let o=0,r=-1,l=!1;for(;!l;){if(r=this.ub(i,o),r===-1&&(r=i.length,l=!0),o<=r){const h=i.substring(o,r);if(this.wrap!==0){this.An=0;const a=Size.a();this.W2(h,t,a),n+=a.height,Size.o(a),this.Fe+=this.An}else this.W2(h,t,null),n+=s,this.Fe++;this.Fe===this.maxLines&&(l=!0)}o=r+1}return this.C0=n,n}OI(){let t=this.ui.replace(/\r\n/g,` +`);const e=this.spacingAbove+this.spacingBelow,s=Math.max(0,this.Op()+e);if(i.length===0)return this.xi=0,this.Fe=1,s;if(!this.isMultiline){const h=this.ub(i,0);h>=0&&(i=i.substring(0,h))}let n=0;this.Fe=0;let o=0,r=-1,l=!1;for(;!l;){if(r=this.ub(i,o),r===-1&&(r=i.length,l=!0),o<=r){const h=i.substring(o,r);if(this.wrap!==0){this.An=0;const a=Size.a();this.q2(h,t,a),n+=a.height,Size.o(a),this.Fe+=this.An}else this.q2(h,t,null),n+=s,this.Fe++;this.Fe===this.maxLines&&(l=!0)}o=r+1}return this.C0=n,n}II(){let t=this.ui.replace(/\r\n/g,` `).replace(/\r/g,` -`);if(t.length===0)return 8;if(this.isMultiline){let i=0,e=0,s=!1;for(;!s;){let n=this.ub(t,e);n===-1&&(n=t.length,s=!0);let o=t.substring(e,n);this.formatting===0&&(o=o.trim()),i=Math.max(i,this.getStringWidth(o)),e=n+1}return i}else{const i=this.ub(t,0);return i>=0&&(t=t.substring(0,i)),this.getStringWidth(t)}}get textValidation(){return this.$!==null?this.$.Il:null}set textValidation(t){const i=this.textValidation;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"textValidation"),this.Tn(),this.$.Il=t,this.i("textValidation",i,t))}get textEdited(){return this.$!==null?this.$.Bp:null}set textEdited(t){const i=this.textEdited;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"textEdited"),this.Tn(),this.$.Bp=t,this.i("textEdited",i,t))}get spacingAbove(){return this.$!==null?this.$.zp:0}set spacingAbove(t){const i=this.spacingAbove;i!==t&&(Debug&&Util.t(t,"number",TextBlock,"spacingAbove"),this.Tn(),this.$.zp=t,this.u(),this.i("spacingAbove",i,t))}get spacingBelow(){return this.$!==null?this.$.Xp:0}set spacingBelow(t){const i=this.spacingBelow;i!==t&&(Debug&&Util.t(t,"number",TextBlock,"spacingBelow"),this.Tn(),this.$.Xp=t,this.u(),this.i("spacingBelow",i,t))}get formatting(){return this.$!==null?this.$.Yp:0}set formatting(t){const i=this.formatting;i!==t&&(Util.tt(t,TextFormat,"formatting"),this.Tn(),this.$.Yp=t,this.u(),this.i("formatting",i,t))}get maxLines(){return this.$!==null?this.$.Kp:1/0}set maxLines(t){const i=this.maxLines;i!==t&&(Debug&&Util.t(t,"number",TextBlock,"maxLines"),t=Math.floor(t),t<=0&&Util.G(t,"> 0",TextBlock,"maxLines"),this.Tn(),this.$.Kp=t,this.u(),this.i("maxLines",i,t))}getMetrics(){return[this.xi,this.Ol,this.co,this.An,this.Re,this.Oi,this.Ln]}FI(t){t!==void 0&&(this.xi=t[0],this.Ol=t[1],this.co=t[2],this.An=t[3],this.Re=t[4],this.Oi=t[5],this.Ln=t[6])}get metrics(){return{arrSize:this.Re!==null?this.Re:[this.xi],arrText:this.Oi!==null?this.Oi:[this.Ln],maxLineWidth:this.xi,fontHeight:this.co}}get choices(){return this.Fd}set choices(t){const i=this.Fd;i!==t&&(Debug&&t!==null&&!Array.isArray(t)&&Util.Vi(t,"Array",TextBlock,"choices:value"),this.Fd=t,this.i("choices",i,t))}static VI=new RegExp("[ \u200B\xAD]");static J2=new PropertyCollection;static HL=0;static ab=new PropertyCollection;static j2=0;static Dp="...";static UL="";static rl=Diagram.isUsingDOM()?new CanvasSurface(null).di:null}class TextBlockTemplateSettings{wi;fs;uo;Yp;Kp;Ip;zp;Xp;Fp;Bp;Ep;Il;hl;Rp;constructor(){this.wi=!1,this.fs=null,this.uo=0,this.Yp=0,this.Kp=1/0,this.Ip=0,this.zp=0,this.Xp=0,this.Fp="start",this.Bp=null,this.Ep=null,this.Il=null,this.hl=Spot.Top,this.Rp=2}copy(){const t=new TextBlockTemplateSettings;return t.fs=this.fs,t.uo=this.uo,t.Yp=this.Yp,t.Kp=this.Kp,t.Ip=this.Ip,t.zp=this.zp,t.Xp=this.Xp,t.Fp=this.Fp,t.Bp=this.Bp,t.Ep=this.Ep,t.Il=this.Il,t.hl=this.hl,t.Rp=this.Rp,t}}class GradElementSettings{yc;wc;xc;Vp;bc;constructor(){this.yc=1,this.wc=0,this.xc=1,this.Vp=null,this.bc=null}copy(){const t=new GradElementSettings;return t.yc=this.yc,t.wc=this.wc,t.xc=this.xc,t.Vp=this.Vp,t.bc=this.bc,t}}var ImageStretch=(w=>(w[w.None=0]="None",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ImageStretch||{});class Picture extends GraphObject{al;St;fl;kc;fs;cl;Sc;uo;Mc;Pc;W1;constructor(t,i){super(),this.l|=2097152,this.al=null,this.St="",this.fl=Rect.BD,this.kc=2,this.fs=null,this.cl=null,this.Sc=Spot.Center,this.uo=0,this.Mc=null,this.Pc=null,this.W1=null,typeof t=="string"?this.source=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.St=this.St,t.element=this.al,t.fl=this.fl.L(),t.kc=this.kc,t.uo=this.uo,t.fs=this.fs,t.cl=this.cl,t.Sc=this.Sc.L(),t.Pc=this.Pc}fi(t){t in ImageStretch?this.imageStretch=t:super.fi(t)}toString(){return"Picture("+this.source+")#"+GSet.gs(this)}get Nc(){return(this.l&1048576)!==0}set Nc(t){this.Nc!==t&&(this.l=this.l^1048576)}get Ia(){return(this.l&2097152)!==0}set Ia(t){this.Ia!==t&&(this.l=this.l^2097152)}get bn(){return(this.l&4194304)!==0}set bn(t){this.bn!==t&&(this.l=this.l^4194304)}static clearCache(t){t===void 0&&(t=""),Util.t(t,"string",Picture,"clearCache:url"),t!==""?Picture.Up[t]&&(delete Picture.Up[t],Picture.db--):(Picture.Up=new PropertyCollection,Picture.db=0)}static UA(t,i){i.qL||(i.gb=e=>{Picture.BI(i,e),t.desiredSize.isReal()||(t.pe(!1),t.u())},i.mb=e=>Picture.zI(i,e),i.addEventListener("load",i.gb),i.addEventListener("error",i.mb),i.qL=!0)}static NR(t){t.gb&&t.removeEventListener("load",t.gb),t.mb&&t.removeEventListener("error",t.mb),delete t.gb,delete t.mb,delete t.qL}get element(){return this.al}set element(t){const i=this.al;if(this.hs(!0),i!==t){this.Nc=t instanceof HTMLCanvasElement;const e=t instanceof HTMLImageElement;t!==null&&!(e||t instanceof HTMLVideoElement||this.Nc)&&Util.n("Picture.element must be an instance of Image, Canvas, or Video, not: "+t);const s=this.diagram;s!==null&&s.zP(this),this.al=t,t!==null&&e&&t.ls===void 0&&(t.ls=new GSet),s!==null&&e&&s.BP(this),this.i("element",i,t),this.T()}}MR(){const t=this.al;if(t===null)return;const i=this.desiredSize.isReal();(this.Nc||t.complete===!0)&&(t.w0&&(t.Gp instanceof Event&&this.fs!==null?this.fs(this,t.Gp):t.bn===!0&&!t.Gp&&this.cl!==null&&t.Z2&&this.cl(this,t.Z2)),t.bn=!0),t.bn&&i&&this.diagram!==null&&this.diagram.vu.add(this)}XI(){if(this.al===null){this.Mc=!1;return}const t=new CanvasSurface(null).di;try{t.drawImage(this.al,0,0)}catch(i){Debug&&this.Ia&&Util.at(i.toString()),this.Ia=!1}try{t.getImageData(0,0,1,1).data[3]&&(this.Mc=!1),this.Mc=!1}catch{this.Mc=!0}}get source(){return this.St}set source(t){const i=this.St;if(i!==t){this.hs(!0),Util.t(t,"string",Picture,"source"),this.St=t;let e=Picture.Up;if(!Diagram.isUsingDOM()){this.i("source",i,t);return}let s=null;if(e[t]!==void 0)s=e[t];else if(t!==""){Picture.db>30&&(Picture.clearCache(),e=Picture.Up),s=Util.ln("img"),s.w0=!0,Picture.UA(this,s);const n=this.Pc;n!==null&&(s.crossOrigin=n(this)),s.src=t,e[t]=s,Picture.db++}this.element=s,s!==null&&s.__goCache===void 0&&(s.__goCache=new PictureCacheArray),this.u(),this.T(),this.i("source",i,t)}}static BI(t,i){t.bn=!0,t.Gp=!1;let e;const s=t.ls.copy();if(s==null)return;const n=s.iterator;for(;n.next();){const o=n.value;o.T();const r=t.getAttribute("src")||"",l=o._l.get(r);if(l===null)continue;const h=l.length;for(let a=0;a=o.width&&(r=r+p.offsetX+(d*p.x-o.width*p.x)),m>=o.height&&(l=l+p.offsetY+(m*p.y-o.height*p.y)),a=Math.min(o.width,d),f=Math.min(o.height,m);break;case 2:d=o.width,m=o.height;break;case 6:case 7:let L=0;g===6?(L=Math.min(o.height/m,o.width/d),d*=L,m*=L):g===7&&(L=Math.max(o.height/m,o.width/d),d*=L,m*=L,d>=o.width&&(r=(r+p.offsetX+(d*p.x-o.width*p.x)/d)*a),m>=o.height&&(l=(l+p.offsetY+(m*p.y-o.height*p.y)/m)*f),a*=1/(d/o.width),f*=1/(m/o.height),d=o.width,m=o.height);break}const y=a*f,x=this.getDocumentScale()*i.scale,k=d*x,b=m*x,S=k*b,M=y/S,A=e.__goCache;let C=null;const P=Picture.YI;if(!n){if(e.bn&&A!==void 0&&S>4&&M>P*P){A.Yt===null&&(A.jL(4,c,u,e),A.jL(16,c,u,e));const L=A.Yt,D=L.length;for(let F=0;F0){const f=this.Yt[this.Yt.length-1];h=f.St,a=f.Id}o.setTransform(r*a,0,0,r*a,0,0),o.commitTransform(),o.drawImage(h,0,0),this.Yt.push(l)}}class PictureCacheInstance{St;Id;constructor(t,i){this.St=t,this.Id=i}}class GeoStream{Ci;im;constructor(){this.im=new Geometry,this.Ci=null}Bi(t){t!==null?(t.ct(),this.im=t,t.figures.clear()):this.im=new Geometry,this.Ci=null}wu(t,i,e,s,n,o){if(s!==void 0&&s===!0){const r=new PathSegment(1);r.endX=t,r.endY=i,this.Ci.segments.add(r)}else this.Ci=new PathFigure,this.Ci.startX=t,this.Ci.startY=i,this.Ci.isFilled=e,this.Ci.isEvenOdd=o||!1,this.im.figures.add(this.Ci);n!==void 0&&(this.Ci.isShadowed=n)}WD(){const t=this.Ci.segments.length;t>0&&this.Ci.segments.elt(t-1).close()}vD(){this.Ci.segments.length>0&&(this.Ci.isFilled=!0)}JD(t){this.Ci.isShadowed=t}pE(t){this.Ci.isEvenOdd=t}HD(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(1);s.endX=t,s.endY=i,e&&s.close(),this.Ci.segments.add(s)}yr(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(2);s.endX=t,s.endY=i,e&&s.close(),this.Ci.segments.add(s)}wr(t,i,e,s,n,o,r){r===void 0&&(r=!1);const l=new PathSegment(3);l.point1X=t,l.point1Y=i,l.point2X=e,l.point2Y=s,l.endX=n,l.endY=o,r&&l.close(),this.Ci.segments.add(l)}Fw(t,i,e,s,n){n===void 0&&(n=!1);const o=new PathSegment(4);o.point1X=t,o.point1Y=i,o.endX=e,o.endY=s,n&&o.close(),this.Ci.segments.add(o)}qD(t,i,e,s,n,o,r){o===void 0&&(o=0),r===void 0&&(r=!1);const l=new PathSegment(5);l.startAngle=t,l.sweepAngle=i,l.centerX=e,l.centerY=s,l.radiusX=n,o!==0?l.radiusY=o:l.radiusY=n,r&&l.close(),this.Ci.segments.add(l)}jD(t,i,e,s,n,o,r,l){l===void 0&&(l=!1);const h=new PathSegment(6,o,r,t,i,e,s,n);l&&h.close(),this.Ci.segments.add(h)}static $2=null;static PC(t){const i=GeoStream.$2;if(i!==null)return GeoStream.$2=null,i.Bi(t),i;{const e=new GeoStream;return e.Bi(t),e}}static NC(t){GeoStream.$2=t}}{const w=function(n,o){const r=n.toLowerCase(),l=Geo.qn;l[n]=o,l[r]=n};w("Rectangle",(n,o,r)=>{const l="r"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,Geo.pr{const l="s"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,h.defaultStretch=6,Geo.pr{(isNaN(l)||l<0)&&(l=5),isNaN(h)&&(h=15);const a="rr"+o+","+r+","+l+","+h;let f=Geo.mr[a];if(f!==void 0)return f;let c=l;(h&1)===1?(c=Math.min(c,(h&2)===2?o/3:o),c=Math.min(c,(h&8)===8?r/3:r)):c=0;const u=new PathFigure(c,0,!0);f=new Geometry().add(u);const d=Spot.TopLeft.copy(),m=Spot.BottomRight.copy();if((h&2)===2){let g=l;g=Math.min(g,(h&1)===1?o/3:o),g=Math.min(g,(h&4)===4?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,o-g,0)).add(new PathSegment(3,o,g,o-p,0,o,p)),d.offsetY=p,m.offsetX=-p}else u.add(new PathSegment(2,o,0));if((h&4)===4){let g=l;g=Math.min(g,(h&8)===8?o/3:o),g=Math.min(g,(h&2)===2?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,o,r-g)).add(new PathSegment(3,o-g,r,o,r-p,o-p,r)),m.offsetX=-p,m.offsetY=-p}else u.add(new PathSegment(2,o,r));if((h&8)===8){let g=l;g=Math.min(g,(h&4)===4?o/3:o),g=Math.min(g,(h&1)===1?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,g,r)).add(new PathSegment(3,0,r-g,p,r,0,r-p)),d.offsetX=p,m.offsetY=-p}else u.add(new PathSegment(2,0,r));if((h&1)===1){const g=c*Geo.Un;u.add(new PathSegment(2,0,c)).add(new PathSegment(3,c,0,0,g,g,0).close()),d.offsetX=g,d.offsetY=g}else u.add(new PathSegment(2,0,0).close());return f.spot1=d,f.spot2=m,Geo.pr{const l=n?n.parameter1:NaN,h=n?n.parameter2:NaN;return t(n,o,r,l,h)}),w("Border","RoundedRectangle"),w("RoundedTopRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,3)}),w("RoundedBottomRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,12)}),w("RoundedLeftRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,9)}),w("RoundedRightRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,6)}),w("Ellipse",(n,o,r)=>{const l="e"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Kk,h.spot2=Spot.Uk,Geo.pr{const l="c"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Kk,h.spot2=Spot.Uk,h.defaultStretch=6,Geo.prnew Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,.5*r)).add(new PathSegment(2,0,r).close())).setSpots(0,.25,.5,.75)),w("TriangleDown",(n,o,r)=>new Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,0)).add(new PathSegment(2,.5*o,r).close())).setSpots(.25,0,.75,.5)),w("TriangleLeft",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,o,0).close())).setSpots(.5,.25,1,.75)),w("TriangleUp",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,r)).add(new PathSegment(2,.5*o,0).close())).setSpots(.25,.5,.75,1)),w("Triangle","TriangleUp"),w("Diamond",(n,o,r)=>new Geometry().add(new PathFigure(.5*o,0).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,.5*o,r)).add(new PathSegment(2,o,.5*r).close())).setSpots(.25,.25,.75,.75)),w("LineH",(n,o,r)=>{const l=new Geometry(1);return l.startX=0,l.startY=r/2,l.endX=o,l.endY=r/2,l}),w("LineV",(n,o,r)=>{const l=new Geometry(1);return l.startX=o/2,l.startY=0,l.endX=o/2,l.endY=r,l}),w("None","Rectangle"),w("BarH","Rectangle"),w("BarV","Rectangle"),w("MinusLine","LineH"),w("PlusLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r/2,!1).add(new PathSegment(2,o,r/2)).add(new PathSegment(1,o/2,0)).add(new PathSegment(2,o/2,r)))),w("XLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r,!1).add(new PathSegment(2,o,0)).add(new PathSegment(1,0,0)).add(new PathSegment(2,o,r)))),w("LineRight",(n,o,r)=>new Geometry().add(new PathFigure(.25*o,0,!1).add(new PathSegment(2,.75*o,.5*r)).add(new PathSegment(2,.25*o,r)))),w("LineDown",(n,o,r)=>new Geometry().add(new PathFigure(0,.25*r,!1).add(new PathSegment(2,.5*o,.75*r)).add(new PathSegment(2,o,.25*r)))),w("LineLeft",(n,o,r)=>new Geometry().add(new PathFigure(.75*o,0,!1).add(new PathSegment(2,.25*o,.5*r)).add(new PathSegment(2,.75*o,r)))),w("LineUp",(n,o,r)=>new Geometry().add(new PathFigure(0,.75*r,!1).add(new PathSegment(2,.5*o,.25*r)).add(new PathSegment(2,o,.75*r)))),w("Capsule",(n,o,r)=>{const l=new Geometry;if(or){const h=new PathFigure(r/2,0,!0);return l.add(h),h.add(new PathSegment(2,o-r/2,0)),h.add(new PathSegment(5,270,180,o-r/2,r/2,r/2,r/2)),h.add(new PathSegment(2,r/2,r)),h.add(new PathSegment(5,90,180,r/2,r/2,r/2,r/2)),l.spot1=new Spot(0,.156,r*.156,0),l.spot2=new Spot(1,.844,-r*.156,0),l}else return l.type=3,l.endX=o,l.endY=r,l.spot1=Spot.Kk,l.spot2=Spot.Uk,l});const i=(n,o)=>new PathFigure(n,o,!1,!1),e=(n,o,r)=>n.add(new PathSegment(2,o,r)),s=(n,o,r)=>n.add(new PathSegment(1,o,r));w("Borders",(n,o,r)=>{let l=n?n.parameter1:NaN;isNaN(l)?l=10:l=l&15;const h=new Geometry;let a;return l===10?(a=i(o,0),e(a,o,r),s(a,0,r),e(a,0,0)):l===5?(a=i(0,0),e(a,o,0),s(a,o,r),e(a,0,r)):l===1?(a=i(0,0),e(a,o,0),s(a,o,r)):l===2?(a=i(o,0),e(a,o,r)):l===4?(a=i(o,r),e(a,0,r)):l===8?(a=i(0,r),e(a,0,0),s(a,o,r)):l===3?(a=i(0,0),e(a,o,0),e(a,o,r)):l===6?(a=i(o,0),e(a,o,r),e(a,0,r)):l===12?(a=i(o,r),e(a,0,r),e(a,0,0)):l===9?(a=i(0,r),e(a,0,0),e(a,o,0)):l===7?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r)):l===14?(a=i(o,0),e(a,o,r),e(a,0,r),e(a,0,0)):l===13?(a=i(o,r),e(a,0,r),e(a,0,0),e(a,o,0)):l===11?(a=i(0,r),e(a,0,0),e(a,o,0),e(a,o,r)):l===15?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r),a.add(new PathSegment(2,0,0).close())):(a=i(0,0),s(a,o,r)),h.add(a),h})}Geo.Zg={"":"",Standard:"F1 m 0,0 l 8,4 -8,4 2,-4 z",Backward:"F1 m 8,0 l -2,4 2,4 -8,-4 z",Triangle:"F1 m 0,0 l 8,4.62 -8,4.62 z",BackwardTriangle:"F1 m 8,4 l 0,4 -8,-4 8,-4 0,4 z",Boomerang:"F1 m 0,0 l 8,4 -8,4 4,-4 -4,-4 z",BackwardBoomerang:"F1 m 8,0 l -8,4 8,4 -4,-4 4,-4 z",SidewaysV:"m 0,0 l 8,4 -8,4 0,-1 6,-3 -6,-3 0,-1 z",BackwardV:"m 8,0 l -8,4 8,4 0,-1 -6,-3 6,-3 0,-1 z",OpenTriangle:"m 0,0 l 8,4 -8,4",BackwardOpenTriangle:"m 8,0 l -8,4 8,4",OpenTriangleLine:"m 0,0 l 8,4 -8,4 m 8.5,0 l 0,-8",BackwardOpenTriangleLine:"m 8,0 l -8,4 8,4 m -8.5,0 l 0,-8",OpenTriangleTop:"m 0,0 l 8,4 m 0,4",BackwardOpenTriangleTop:"m 8,0 l -8,4 m 0,4",OpenTriangleBottom:"m 0,8 l 8,-4",BackwardOpenTriangleBottom:"m 0,4 l 8,4",HalfTriangleTop:"F1 m 0,0 l 0,4 8,0 z m 0,8",BackwardHalfTriangleTop:"F1 m 8,0 l 0,4 -8,0 z m 0,8",HalfTriangleBottom:"F1 m 0,4 l 0,4 8,-4 z",BackwardHalfTriangleBottom:"F1 m 8,4 l 0,4 -8,-4 z",ForwardSemiCircle:"m 4,0 b 270 180 0 4 4",BackwardSemiCircle:"m 4,8 b 90 180 0 -4 4",Feather:"m 0,0 l 3,4 -3,4",BackwardFeather:"m 3,0 l -3,4 3,4",DoubleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardDoubleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4",TripleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardTripleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4 m 3,-8 l -3,4 3,4",ForwardSlash:"m 0,8 l 5,-8",BackSlash:"m 0,0 l 5,8",DoubleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8",DoubleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8",TripleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8 m -2,8 l 4,-8",TripleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8 m -2,-8 l 4,8",Fork:"m 0,4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4",LineFork:"m 0,0 l 0,8 m 0,-4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardLineFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4 m 8,-8 l 0,8",CircleFork:"F1 m 6,4 b 0 360 -3 0 3 z m 0,0 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 6,0 b 0 360 -3 0 3",CircleLineFork:"F1 m 6,4 b 0 360 -3 0 3 z m 1,-4 l 0,8 m 0,-4 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleLineFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 0,-4 l 0,8 m 7,-4 b 0 360 -3 0 3",Circle:"F1 m 8,4 b 0 360 -4 0 4 z",Block:"F1 m 0,0 l 0,8 8,0 0,-8 z",StretchedDiamond:"F1 m 0,3 l 5,-3 5,3 -5,3 -5,-3 z",Diamond:"F1 m 0,4 l 4,-4 4,4 -4,4 -4,-4 z",Chevron:"F1 m 0,0 l 5,0 3,4 -3,4 -5,0 3,-4 -3,-4 z",StretchedChevron:"F1 m 0,0 l 8,0 3,4 -3,4 -8,0 3,-4 -3,-4 z",NormalArrow:"F1 m 0,2 l 4,0 0,-2 4,4 -4,4 0,-2 -4,0 z",X:"m 0,0 l 8,8 m 0,-8 l -8,8",TailedNormalArrow:"F1 m 0,0 l 2,0 1,2 3,0 0,-2 2,4 -2,4 0,-2 -3,0 -1,2 -2,0 1,-4 -1,-4 z",DoubleTriangle:"F1 m 0,0 l 4,4 -4,4 0,-8 z m 4,0 l 4,4 -4,4 0,-8 z",BigEndArrow:"F1 m 0,0 l 5,2 0,-2 3,4 -3,4 0,-2 -5,2 0,-8 z",ConcaveTailArrow:"F1 m 0,2 h 4 v -2 l 4,4 -4,4 v -2 h -4 l 2,-2 -2,-2 z",RoundedTriangle:"F1 m 0,1 a 1,1 0 0 1 1,-1 l 7,3 a 0.5,1 0 0 1 0,2 l -7,3 a 1,1 0 0 1 -1,-1 l 0,-6 z",SimpleArrow:"F1 m 1,2 l -1,-2 2,0 1,2 -1,2 -2,0 1,-2 5,0 0,-2 2,2 -2,2 0,-2 z",AccelerationArrow:"F1 m 0,0 l 0,8 0.2,0 0,-8 -0.2,0 z m 2,0 l 0,8 1,0 0,-8 -1,0 z m 3,0 l 2,0 2,4 -2,4 -2,0 0,-8 z",BoxArrow:"F1 m 0,0 l 4,0 0,2 2,0 0,-2 2,4 -2,4 0,-2 -2,0 0,2 -4,0 0,-8 z",TriangleLine:"F1 m 8,4 l -8,-4 0,8 8,-4 z m 0.5,4 l 0,-8",CircleEndedArrow:"F1 m 10,4 l -2,-3 0,2 -2,0 0,2 2,0 0,2 2,-3 z m -4,0 b 0 360 -3 0 3 z",DynamicWidthArrow:"F1 m 0,3 l 2,0 2,-1 2,-2 2,4 -2,4 -2,-2 -2,-1 -2,0 0,-2 z",EquilibriumArrow:"m 0,3 l 8,0 -3,-3 m 3,5 l -8,0 3,3",FastForward:"F1 m 0,0 l 3.5,4 0,-4 3.5,4 0,-4 1,0 0,8 -1,0 0,-4 -3.5,4 0,-4 -3.5,4 0,-8 z",Kite:"F1 m 0,4 l 2,-4 6,4 -6,4 -2,-4 z",HalfArrowTop:"F1 m 0,0 l 4,4 4,0 -8,-4 z m 0,8",HalfArrowBottom:"F1 m 0,8 l 4,-4 4,0 -8,4 z",OpposingDirectionDoubleArrow:"F1 m 0,4 l 2,-4 0,2 4,0 0,-2 2,4 -2,4 0,-2 -4,0 0,2 -2,-4 z",PartialDoubleTriangle:"F1 m 0,0 4,3 0,-3 4,4 -4,4 0,-3 -4,3 0,-8 z",LineCircle:"F1 m 0,0 l 0,8 m 7 -4 b 0 360 -3 0 3 z",DoubleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",TripleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",CircleLine:"F1 m 6 4 b 0 360 -3 0 3 z m 1,-4 l 0,8",DiamondCircle:"F1 m 8,4 l -4,4 -4,-4 4,-4 4,4 m 8,0 b 0 360 -4 0 4 z",PlusCircle:"F1 m 8,4 b 0 360 -4 0 4 l -8 0 z m -4 -4 l 0 8",OpenRightTriangleTop:"m 8,0 l 0,4 -8,0 m 0,4",OpenRightTriangleBottom:"m 8,8 l 0,-4 -8,0",Line:"m 0,0 l 0,8",DoubleLine:"m 0,0 l 0,8 m 2,0 l 0,-8",TripleLine:"m 0,0 l 0,8 m 2,0 l 0,-8 m 2,0 l 0,8",PentagonArrow:"F1 m 8,4 l -4,-4 -4,0 0,8 4,0 4,-4 z"};var LayoutConditions=(w=>(w[w.None=0]="None",w[w.Added=1]="Added",w[w.Removed=2]="Removed",w[w.Shown=4]="Shown",w[w.Hidden=8]="Hidden",w[w.NodeSized=16]="NodeSized",w[w.GroupLayout=32]="GroupLayout",w[w.NodeReplaced=64]="NodeReplaced",w[w.Standard=127]="Standard",w[w.All=16777215]="All",w))(LayoutConditions||{});class Part extends Panel{N;$o;E;ul;dl;Qo;ui;_o;xh;Zs;tr;Od;qM;WL;Hp;qp;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.N=2408959,this.$o="",this.E=null,this.ul="",this.dl=null,this.Qo=null,this.ui="",this._o=null,this.xh=null,this.Zs=new Point(NaN,NaN).w(),this.tr=null,this.Od=NaN,this.qM=-1,this.WL=new Rect,this.Hp=null,this.qp=NaN,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.N=this.N&-4097|16384|32768,t.$o=this.$o,this.E!==null&&(this.E.wi?t.E=this.E:t.E=this.E.copy()),t.ul=this.ul,t.Qo=null,t.ui=this.ui,t.Zs.c(this.Zs),t.Od=this.Od}Ho(t){super.Ho(t),t.dh(),t.dl=null,t.tr=null,t.Hp=null}toString(){let t=Util.hn(this.constructor)+"#"+GSet.gs(this);return this.data!==null&&(t+="("+Util.toString(this.data)+")"),t}static LayoutNone=0;static LayoutAdded=1;static LayoutRemoved=2;static LayoutShown=4;static LayoutHidden=8;static LayoutNodeSized=16;static LayoutGroupLayout=32;static LayoutNodeReplaced=64;static LayoutStandard=127;static LayoutAll=16777215;Qi(){this.E===null?this.E=new PartTemplateSettings:this.E.wi&&(this.E=this.E.copy())}fh(){super.fh(),this.E!==null&&(this.E.wi=!0)}ic(t,i,e,s,n,o,r){const l=this.diagram;l!==null&&(t===3&&i==="elements"?n instanceof Panel?n.Qr(h=>{l.partManager.FP(h,l)}):n instanceof Picture&&l.BP(n):t===4&&i==="elements"&&(n instanceof Panel?n.Qr(h=>l.partManager.RP(h,l)):n instanceof Picture&&l.zP(n)),l.raiseChangedEvent(t,i,e,s,n,o,r))}updateTargetBindings(t){if(super.updateTargetBindings(t),this.data===null)return;const i=this.D.h,e=i.length;for(let n=0;n{r.data!==null&&r.updateTargetBindings()})}const s=this.adornments;for(;s.next();)s.value.updateTargetBindings(t)}Yo(){if(super.Yo(),this.N2()){const i=this.D.h,e=i.length;for(let s=0;so.Yo())}}const t=this.adornments;for(;t.next();)t.value.Yo()}updateRelationshipsFromData(){this.data!==null&&this.diagram?.partManager.updateRelationshipsFromData(this)}get key(){const t=this.diagram;if(t!==null)return t.model.getKeyForNodeData(this.data)}get adornments(){return this.Qo===null?EmptyIterator.instance:this.Qo.iteratorValues}findAdornment(t){Debug&&Util.t(t,"string",Part,"findAdornment:category");const i=this.Qo;return i===null?null:i.get(t)}addAdornment(t,i){if(i===null)return;Debug&&(Util.t(t,"string",Part,"addAdornment:category"),Util.s(i,Adornment,Part,"addAdornment:ad"));let e=null,s=this.Qo;if(s!==null&&(e=s.get(t)),e!==i){if(e!==null){const o=e.diagram;o!==null&&o.remove(e)}s===null&&(s=new GMap,this.Qo=s),i.$o!==t&&(i.category=t),s.set(t,i);const n=this.diagram;if(n!==null){n.add(i);const o=i.adornedObject;if(o!==null){const r=o.findBindingPanel();r!==null&&(i.data=r.data)}}}}removeAdornment(t){Debug&&Util.t(t,"string",Part,"removeAdornment:category");const i=this.Qo;if(i===null)return;const e=i.get(t);if(e!==null){const s=e.diagram;s!==null&&(s.remove(e),e.data=null)}i.delete(t),i.count===0&&(this.Qo=null)}clearAdornments(){const t=this.Qo;if(t===null)return;const i=Util.ft(),e=t.iterator;for(;e.next();){const n=e.key;i.push(n)}const s=i.length;for(let n=0;n{e.isEnabled&&e.updateAdornments(i)}),t.toolManager.updateAdornments(i)}GM(t){this._o=t,t===null&&this.zR()}get layer(){return this._o}get diagram(){const t=this._o;return t==null?null:t.diagram}get layerName(){return this.ul}set layerName(t){const i=this.ul;if(i===t)return;Util.t(t,"string",Part,"layerName");let e=this.diagram;if(e!==null&&(e.findLayer(t)===null||e.partManager.addsToTemporaryLayer))return;this.ul=t,e!==null&&e.invalidateDocumentBounds(),this.i("layerName",i,t);const s=this.layer;if(s===null||s.name===t||(e=s.diagram,e===null))return;const n=e.findLayer(t);if(n===null||n===s)return;let o=s.ne(-1,this,!0);o>=0&&e.raiseChangedEvent(4,"parts",s,this,null,o,!0),o=n.Zh(99999999,this,!0),s.visible!==n.visible&&this.Ki(n.visible),o>=0&&e.raiseChangedEvent(3,"parts",n,null,this,!0,o);const r=this.layerChanged;if(r===null)return;const l=e.j;e.j=!0,r(this,s,n),e.j=l}get layerChanged(){return this.E!==null?this.E.jp:null}set layerChanged(t){const i=this.layerChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"layerChanged"),this.Qi(),this.E.jp=t,this.i("layerChanged",i,t))}get zOrder(){return this.Od}set zOrder(t){const i=this.Od;if(i===t)return;Util.t(t,"number",Part,"zOrder"),this.Od=t;const e=this.layer;e!==null&&e.Nx(-1,this),this.i("zOrder",i,t);const s=this.diagram;s!==null&&s.T()}GI(){const t=this.layer;t!==null&&t.Nx(-1,this)}pb(){if(this.nh()!==!1)return;this.Q2(!0),this.hd();const t=this.diagram;t!==null&&(t.d0(this),t.requestUpdate())}ZL(){if(this.N|=2097152,this.nh()===!1)return;const t=this.position,i=this.location;(!i.isReal()||!t.isReal())&&this.$L(t,i);const e=this.Fi,s=Rect.a().c(e);e.ct(),e.x=t.x,e.y=t.y,e.w(),this.ad(s,e),Rect.o(s),this.Q2(!1)}no(t,i,e,s){const n=this.le;n.e(t,i,e,s),this.Pi===null&&(this.Pi=new Transform);const o=this.Pi;o.Bi(),this.P0(o,t,i,e,s),this.Pi=o,o.Gk()||o.Cw(n)}P0(t,i,e,s,n){if(this.lt!==1&&t.lt(this.lt),this.jt===0)return;let o=Spot.Center;this.locationSpot.isSpot()&&(o=this.locationSpot);const r=Point.a();if(this.locationObject!==this){const l=this.locationObject,h=l.naturalBounds;r.setSpot(h.x,h.y,h.width,h.height,o),l.Pi!==null&&l.Pi.Pt(r),r.offset(-l.measuredBounds.x,-l.measuredBounds.y);let a=l.panel;for(;a!==null&&a!==this;)a.Pi!==null&&a.Pi.Pt(r),r.offset(-a.measuredBounds.x,-a.measuredBounds.y),a=a.panel}else r.setSpot(i,e,s,n,o);t.ms(this.jt,r.x,r.y),Point.o(r)}get locationObject(){if(this.tr===null)if(this instanceof Adornment&&this.type!==Panel.Link&&this.hasPlaceholder())this.tr=this.placeholder;else{const t=this.locationObjectName;if(t!==""){const i=this.findObject(t);i!==null?this.tr=i:this.tr=this}else this.tr=this}return this.tr.visible?this.tr:this}get minLocation(){return this.E!==null?this.E.Wp:Point.rC}set minLocation(t){const i=this.minLocation;i.equals(t)||(Debug&&Util.s(t,Point,Part,"minLocation"),t=t.L(),this.Qi(),this.E.Wp=t,this.i("minLocation",i,t))}get maxLocation(){return this.E!==null?this.E.vp:Point.lC}set maxLocation(t){const i=this.maxLocation;i.equals(t)||(Debug&&Util.s(t,Point,Part,"maxLocation"),t=t.L(),this.Qi(),this.E.vp=t,this.i("maxLocation",i,t))}get locationObjectName(){return this.E!==null?this.E.Jp:""}set locationObjectName(t){const i=this.locationObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"locationObjectName"),this.Qi(),this.E.Jp=t,this.tr=null,this.u(),this.i("locationObjectName",i,t))}get locationSpot(){return this.E!==null?this.E.Zp:Spot.TopLeft}set locationSpot(t){const i=this.locationSpot;i.equals(t)||(Debug&&(Util.s(t,Spot,Part,"locationSpot"),t.isSpot()||Util.n("Part.locationSpot must be a specific Spot value, not: "+t)),t=t.L(),this.Qi(),this.E.Zp=t,this.u(),this.i("locationSpot",i,t))}move(t,i){i===!0?this.location=t:this.position=t}moveTo(t,i,e){const s=Point.H(t,i);this.move(s,e),Point.o(s)}isVisible(){if(!this.visible)return!1;const t=this.layer;if(t!==null){if(!t.visible)return!1;const e=t.diagram;if(e!==null&&e.animationManager.ux(this))return!0}const i=this.containingGroup;return!(i!==null&&(!i.isSubGraphExpanded||!i.isVisible()))}Ki(t){const i=this.diagram;t?(this.invalidateLayout(4),this.invalidateAdornments(),i!==null&&i.d0(this)):(this.invalidateLayout(8),this.clearAdornments()),this.dh(),i!==null&&(i.invalidateDocumentBounds(),i.T())}findObject(t){if(this.name===t)return this;let i=this.Hp;if(i===null&&(this.Hp=i=new GMap),i.get(t)!==null)return i.get(t);const e=super.findObject(t);return e!==null?(i.set(t,e),e):(i.set(t,null),null)}V0(){this.Hp=null}getRelativePoint(t,i,e){e===void 0&&(e=new Point);const s=i.isNoSpot()?Spot.Center:i,n=t.naturalBounds;if(e.e(n.width*s.x+s.offsetX,n.height*s.y+s.offsetY),t===null||t===this)return e;t.O.Pt(e);let o=t.panel;for(;o!==null&&o!==this;)o.O.Pt(e),o=o.panel;return this.Pi!==null&&this.Pi.Pt(e),e.offset(-this.le.x,-this.le.y),e}getDocumentBounds(t){return t===void 0&&(t=new Rect),t.c(this.actualBounds)}ensureBounds(){this.wt(1/0,1/0),this.qt()}PL(t){const i=this.locationSpot,e=this.locationObject;let s=e.naturalBounds;s.isReal()||(s=Rect.kw);const n=e instanceof Shape?e.strokeWidth:0;if(t.setSpot(0,0,s.width+n,s.height+n,i),e!==this){t.offset(-n/2,-n/2),e.O.Pt(t);let o=e.panel;for(;o!==null&&o!==this;)o.O.Pt(t),o=o.panel}return this.Pi!==null&&this.Pi.Pt(t),t.offset(-this.le.x,-this.le.y),t}Jh(t,i){const e=i===void 0?this.WL:i,s=this.HI(),n=s*2;if(!this.isShadowed)return e.e(t.x-1-s,t.y-1-s,t.width+2+n,t.height+2+n),e;let o=t.x,r=t.y,l=t.width,h=t.height;const a=this.shadowBlur,f=this.shadowOffset;return l+=a,h+=a,o-=a/2,r-=a/2,f.x>0?l+=f.x:(o+=f.x,l-=f.x),f.y>0?h+=f.y:(r+=f.y,h-=f.y),e.e(o-1,r-1,l+2,h+2),e}CI(){return this.type===Panel.Link&&this instanceof Adornment&&this.category==="Selection"&&this.adornedObject instanceof Shape&&this.adornedPart.findMainElement()===this.adornedObject?this.adornedObject.strokeWidth:0}HI(){return isNaN(this.qp)&&(this.qp=this.FL()),this.qp}mc(){this.qp=NaN}qt(){if(this.rs()===!1){this.ZL();return}this.oo(!1);const t=this.Fi,i=Rect.a();i.c(t);const e=this.Tl();this.uh(0,0,this.le.width,this.le.height);const s=this.position;this.$L(s,this.location),t.ct(),t.x=s.x,t.y=s.y,t.w(),this.ad(i,t),i.equals(t)?this.Us(e):this.Ae()&&(!Geo.p(i.width,t.width)||!Geo.p(i.height,t.height))&&this.qM>=0&&this.invalidateLayout(16),Rect.o(i),this.Q2(!1)}ad(t,i){const e=this.diagram;if(e===null)return;let s=!1;if(e.ta===!1&&t.isReal()){const n=Rect.a();n.c(e.documentBounds),n.subtractMargin(e.padding),t.x>n.x&&t.y>n.y&&t.rightn.x&&i.y>n.y&&i.right=o)return}}this.N=this.N^4096;let s=!1;if(e!==null){s=e.skipsUndoManager,e.skipsUndoManager=!0;const o=e.selection;o.ct(),t?o.add(this):o.delete(this),o.w()}this.i("isSelected",i,t),this.invalidateAdornments();const n=this.selectionChanged;n!==null&&n(this),e!==null&&(e.requestUpdate(),e.skipsUndoManager=s)}}get isHighlighted(){return(this.N&524288)!==0}set isHighlighted(t){const i=(this.N&524288)!==0;if(i!==t){Debug&&Util.t(t,"boolean",Part,"isHighlighted"),this.N=this.N^524288;const e=this.diagram;if(e!==null){const n=e.highlighteds;n.ct(),t?n.add(this):n.delete(this),n.w()}this.i("isHighlighted",i,t),this.T();const s=this.highlightedChanged;s!==null&&s(this)}}get isShadowed(){return(this.N&8192)!==0}set isShadowed(t){const i=(this.N&8192)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Part,"isShadowed"),this.N=this.N^8192,this.hs(!0),this.i("isShadowed",i,t),this.T())}vL(){return(this.N&16384)!==0}JL(t){t?this.N|=16384:this.N&=-16385}nh(){return(this.N&32768)!==0}Q2(t){t?this.N|=32768:this.N&=-32769}qI(){return(this.N&65536)!==0}g2(t){t?this.N|=65536:this.N&=-65537}Tl(){return(this.N&131072)!==0}Us(t){t?this.N|=131072:this.N&=-131073}eT(){return(this.N&1048576)!==0}yb(t){t?this.N|=1048576:this.N&=-1048577}get isAnimated(){return(this.N&262144)!==0}set isAnimated(t){const i=(this.N&262144)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Part,"isAnimated"),this.N=this.N^262144,this.i("isAnimated",i,t))}get highlightedChanged(){return this.E!==null?this.E.$p:null}set highlightedChanged(t){const i=this.highlightedChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"highlightedChanged"),this.Qi(),this.E.$p=t,this.i("highlightedChanged",i,t))}get selectionObjectName(){return this.E!==null?this.E.Qp:""}set selectionObjectName(t){const i=this.selectionObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"selectionObjectName"),this.Qi(),this.E.Qp=t,this.dl=null,this.i("selectionObjectName",i,t))}get selectionAdornmentTemplate(){return this.E!==null?this.E._p:null}set selectionAdornmentTemplate(t){const i=this.selectionAdornmentTemplate;i!==t&&(Debug&&Util.s(t,Adornment,Part,"selectionAdornmentTemplate"),this.Qi(),this.E._p=t,this.i("selectionAdornmentTemplate",i,t))}get selectionObject(){if(this.dl===null){const t=this.selectionObjectName;if(t!==null&&t!==""){const i=this.findObject(t);i!==null?this.dl=i:this.dl=this}else if(this instanceof Link){const i=this.path;i!==null?this.dl=i:this.dl=this}else this.dl=this}return this.dl}get selectionChanged(){return this.E!==null?this.E.ty:null}set selectionChanged(t){const i=this.selectionChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"selectionChanged"),this.Qi(),this.E.ty=t,this.i("selectionChanged",i,t))}get resizeAdornmentTemplate(){return this.E!==null?this.E.iy:null}set resizeAdornmentTemplate(t){const i=this.resizeAdornmentTemplate;i!==t&&(Debug&&Util.s(t,Adornment,Part,"resizeAdornmentTemplate"),this.Qi(),this.E.iy=t,this.i("resizeAdornmentTemplate",i,t))}get resizeObjectName(){return this.E!==null?this.E.ey:""}set resizeObjectName(t){const i=this.resizeObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"resizeObjectName"),this.Qi(),this.E.ey=t,this.i("resizeObjectName",i,t))}get resizeObject(){const t=this.resizeObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get resizeCellSize(){return this.E!==null?this.E.sy:Size.xw}set resizeCellSize(t){const i=this.resizeCellSize;i.equals(t)||(Debug&&Util.s(t,Size,Part,"resizeCellSize"),t=t.L(),this.Qi(),this.E.sy=t,this.i("resizeCellSize",i,t))}get rotateAdornmentTemplate(){return this.E!==null?this.E.ny:null}set rotateAdornmentTemplate(t){const i=this.rotateAdornmentTemplate;i!==t&&(Debug&&Util.s(t,Adornment,Part,"rotateAdornmentTemplate"),this.Qi(),this.E.ny=t,this.i("rotateAdornmentTemplate",i,t))}get rotateObjectName(){return this.E!==null?this.E.oy:""}set rotateObjectName(t){const i=this.rotateObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"rotateObjectName"),this.Qi(),this.E.oy=t,this.i("rotateObjectName",i,t))}get rotateObject(){const t=this.rotateObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get rotationSpot(){return this.E!==null?this.E.ry:Spot.Default}set rotationSpot(t){const i=this.rotationSpot;i.equals(t)||(Debug&&(Util.s(t,Spot,Part,"rotationSpot"),t!==Spot.Default&&!t.isSpot()&&Util.n("Part.rotationSpot must be a specific Spot value or Spot.Default, not: "+t)),t=t.L(),this.Qi(),this.E.ry=t,this.i("rotationSpot",i,t))}get text(){return this.ui}set text(t){const i=this.ui;i!==t&&(Debug&&Util.t(t,"string",Part,"text"),this.ui=t,this.i("text",i,t))}get containingGroup(){return this.xh}set containingGroup(t){if(this.Ae()){const i=this.xh;if(i!==t){Debug&&t!==null&&Util.s(t,Group,Part,"containingGroup"),t!==null&&(this===t||t.isMemberOf(this))&&(this===t&&Util.n("Cannot make a Group a member of itself: "+this.toString()),Util.n("Cannot make a Group indirectly contain itself: "+this.toString()+" already contains "+t.toString())),this.invalidateLayout(2);const e=this.diagram;if(i!==null?i.tN(this):this instanceof Group&&e!==null&&e.vr.delete(this),this.xh=t,t!==null?t.iN(this):this instanceof Group&&e!==null&&e.vr.add(this),this.invalidateLayout(1),e!==null&&e.j){const n=this.data,o=e.model;if(n!==null&&o.da()){const r=t!==null?t.data:null;o.setGroupForData(n,o.getKeyForNodeData(r))}}const s=this.containingGroupChanged;if(s!==null){let n=!0;e!==null&&(n=e.j,e.j=!0),s(this,i,t),e!==null&&(e.j=n)}if(this instanceof Group){const n=new GSet;Part.lh(n,this,!0,0,!0);const o=n.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=r.linksConnected;for(;l.next();)l.value.Ed()}}}if(this instanceof Node){const n=this.linksConnected;for(;n.next();)n.value.Ed();const o=this.labeledLink;o!==null&&o.Ed()}this.i("containingGroup",i,t),t!==null&&t.GI()}}else Util.n("cannot set the Part.containingGroup of a Link or Adornment")}dh(){const t=this.containingGroup;t!==null&&(t.hasPlaceholder()&&t.placeholder.u(),t.u(),t.invalidateConnectedLinks())}T(){const t=this.diagram;t!==null&&!this.rs()&&!this.nh()&&this.isVisible()&&this.Fi.isReal()&&t.T(this.Jh(this.Fi))}u(){if(this.Xo())return;super.u();const t=this.diagram;t!==null&&(t.d0(this),this instanceof Node&&this.labeledLink!==null&&this.labeledLink.lc(),t.requestUpdate(!0))}lc(t){if(this.rs())return;const i=this.diagram;i!==null&&(i.d0(this),this instanceof Node&&this.invalidateConnectedLinks(),i.requestUpdate()),this.oo(!0)}Hm(t){if(!t){const i=this.xh;i!==null&&i.iN(this)}}qm(t){if(!t){const i=this.xh;i!==null&&i.tN(this)}}Jf(){const t=this.data;if(t!==null){const i=this.diagram;if(i!==null){const e=i.model;e!==null&&e.removeNodeData(t)}}}get containingGroupChanged(){return this.E!==null?this.E.ly:null}set containingGroupChanged(t){const i=this.containingGroupChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"containingGroupChanged"),this.Qi(),this.E.ly=t,this.i("containingGroupChanged",i,t))}findSubGraphLevel(){return this.eN(this)}eN(t){const i=t.containingGroup;if(i!==null)return 1+this.eN(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.eN(e)}return 0}findTopLevelPart(){return this.sN(this)}sN(t){const i=t.containingGroup;if(i!==null)return this.sN(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.sN(e)}return t}get isTopLevel(){return!(this.containingGroup!==null||this instanceof Node&&this.labeledLink!==null)}isMemberOf(t){return t instanceof Group?this.nN(this,t):!1}nN(t,i){if(t===i||i===null)return!1;const e=t.containingGroup;if(e!==null&&(e===i||this.nN(e,i)))return!0;if(t instanceof Node){const s=t.labeledLink;if(s!==null)return this.nN(s,i)}return!1}findCommonContainingGroup(t){if(t===null)return null;if(Debug&&Util.s(t,Part,Part,"findCommonContainingGroup:other"),this===t)return this.containingGroup;let i=this;for(;i!==null;){if(i instanceof Group&&i.yb(!0),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}let e=null;for(i=t;i!==null;){if(i.eT()){e=i;break}if(i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}for(i=this;i!==null;){if(i instanceof Group&&i.yb(!1),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}return e}get layoutConditions(){return this.E!==null?this.E.hy:127}set layoutConditions(t){const i=this.layoutConditions;i!==t&&(Debug&&Util.t(t,"number",Part,"layoutConditions"),this.Qi(),this.E.hy=t,this.i("layoutConditions",i,t))}canLayout(){if(!this.isLayoutPositioned||!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary||this instanceof Node&&this.isLinkLabel)}WI(t){if(!this.isLayoutPositioned||!(t&this.layoutConditions))return!1;const i=this.layer;if(i!==null&&i.isTemporary||this instanceof Node&&this.isLinkLabel)return!1;const e=this.diagram;return!(e!==null&&e.undoManager.isUndoingRedoing)}invalidateLayout(t){if(t===void 0&&(t=16777215),!this.WI(t))return;const i=this.xh;if(i!==null){const e=i.layout;e!==null?e.invalidateLayout():i.invalidateLayout(t)}else{const e=this.diagram;if(e!==null){const s=e.layout;s!==null&&s.invalidateLayout()}}}IA(){if(!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary)}static lh(t,i,e,s,n,o){if(o===void 0&&(o=null),!t.has(i)&&!(o!==null&&!o(i))&&!(i instanceof Adornment)){if(t.add(i),i instanceof Node){if(e&&i instanceof Group){const r=i.memberParts;for(;r.next();){const l=r.value;Part.lh(t,l,e,s,n,o)}}if(n!==!1){const r=i.linksConnected;for(;r.next();){const l=r.value;if(t.has(l))continue;const h=l.fromNode,a=l.toNode,f=h===null||t.has(h),c=a===null||t.has(a);(n?f&&c:f||c)&&Part.lh(t,l,e,s,n,o)}}if(s>1){const r=i.findTreeChildrenNodes();for(;r.next();){const l=r.value;Part.lh(t,l,e,s-1,n,o)}}}else if(i instanceof Link){const r=i.labelNodes;for(;r.next();){const l=r.value;Part.lh(t,l,e,s,n,o)}}}}get dragComputation(){return this.E!==null?this.E.ay:null}set dragComputation(t){const i=this.dragComputation;i!==t&&(t!==null&&Util.t(t,"function",Part,"dragComputation"),this.Qi(),this.E.ay=t,this.i("dragComputation",i,t))}get shadowOffset(){return this.E!==null?this.E.fy:Point.hC}set shadowOffset(t){const i=this.shadowOffset;i.equals(t)||(Debug&&Util.s(t,Point,Part,"shadowOffset"),t=t.L(),this.Qi(),this.E.fy=t,this.T(),this.i("shadowOffset",i,t))}get shadowColor(){return this.E!==null?this.E.cy:"gray"}set shadowColor(t){const i=this.shadowColor;i!==t&&(Debug&&Util.t(t,"string",Part,"shadowColor"),this.Qi(),this.E.cy=t,this.T(),this.i("shadowColor",i,t))}get shadowBlur(){return this.E!==null?this.E.Pn:4}set shadowBlur(t){const i=this.shadowBlur;i!==t&&(Debug&&Util.t(t,"number",Part,"shadowBlur"),this.Qi(),this.E.Pn=t,this.T(),this.i("shadowBlur",i,t))}}class PartTemplateSettings{wi;jp;ly;_p;Qp;ty;$p;iy;ey;sy;ny;oy;ry;Jp;Zp;Wp;vp;ay;hy;fy;cy;Pn;constructor(){this.wi=!1,this.jp=null,this.ly=null,this._p=null,this.Qp="",this.ty=null,this.$p=null,this.iy=null,this.ey="",this.sy=Size.xw,this.ny=null,this.oy="",this.ry=Spot.Default,this.Jp="",this.Zp=Spot.TopLeft,this.Wp=Point.rC,this.vp=Point.lC,this.ay=null,this.hy=127,this.fy=Point.hC,this.cy="gray",this.Pn=4}copy(){const t=new PartTemplateSettings;return t.jp=this.jp,t.ly=this.ly,t._p=this._p,t.Qp=this.Qp,t.ty=this.ty,t.$p=this.$p,t.iy=this.iy,t.ey=this.ey,t.sy=this.sy.L(),t.ny=this.ny,t.oy=this.oy,t.ry=this.ry.L(),t.Jp=this.Jp,t.Zp=this.Zp.L(),t.Wp=this.Wp.L(),t.vp=this.vp.L(),t.ay=this.ay,t.hy=this.hy,t.fy=this.fy.L(),t.cy=this.cy,t.Pn=this.Pn,t}}class Adornment extends Part{ys;Et;sM;nM;dc;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.N&=-257,this.ul="Adornment",this.ys=null,this.sM=0,this.nM=!1,this.Et=null,this.dc=null,i&&Object.assign(this,i)}toString(){const t=this.adornedPart;return"Adornment("+this.category+")"+(t!==null?t.toString():"")}updateRelationshipsFromData(){}pd(t){const i=this.adornedObject,e=i?.part;if(!(e instanceof Link)||!(i instanceof Shape))return;const s=e.path;let n=s.geometry;e.pd(t),n=s.geometry;const o=this.D.h,r=o.length;for(let l=0;lh instanceof Placeholder);l instanceof Placeholder&&(this.Et===null?this.Et=l:Debug&&this.Et!==l&&Util.n("Cannot insert a second Placeholder into the visual tree of an Adornment."))}}else t===4&&i==="elements"&&this.Et!==null&&(s===this.Et?this.Et=null:s instanceof Panel&&this.Et.isContainedBy(s)&&(this.Et=null));super.ic(t,i,e,s,n,o,r)}updateAdornments(){}Jf(){}}var PortSpreading=(w=>(w[w.None=0]="None",w[w.Evenly=1]="Evenly",w[w.Packed=2]="Packed",w))(PortSpreading||{});class Node extends Part{z;bt;Cc;gl;bh;he;ni;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.z=13,this.bt=null,this.ni=new List,this.Cc=null,this.gl=null,this.he=null,this.bh=!1,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.z=this.z,this.bt!==null&&(this.bt.wi?t.bt=this.bt:t.bt=this.bt.copy())}Ho(t){super.Ho(t),t.invalidateConnectedLinks(),t.gl=this.gl,t.he=null}static SpreadingNone=0;static SpreadingEvenly=1;static SpreadingPacked=2;ml(){this.bt===null?this.bt=new NodeTemplateSettings:this.bt.wi&&(this.bt=this.bt.copy())}fh(){super.fh(),this.bt!==null&&(this.bt.wi=!0)}sT(t){t!==null&&(this.gl===null&&(this.gl=new GSet),this.gl.add(t))}nT(t){t!==null&&this.gl!==null&&this.gl.delete(t)}oT(t,i,e){if(t===null||this.gl===null)return null;const s=this.gl.iterator;for(;s.next();){const n=s.value;if(n.uy===this&&n.wb===t&&n.oN===i&&n.rN===e||n.uy===t&&n.wb===this&&n.oN===e&&n.rN===i)return n}return null}invalidateLinkBundle(t,i,e){i==null&&(i=""),e==null&&(e="");const s=this.oT(t,i,e);s!==null&&s.Vd()}ic(t,i,e,s,n,o,r){t===3&&i==="elements"?this.he=null:t===4&&i==="elements"&&(this.he=null),super.ic(t,i,e,s,n,o,r)}invalidateConnectedLinks(t){const i=this.linksConnected;for(;i.next();){const e=i.value;t!==void 0&&t.has(e)||(this.xe(e.fromPort),this.xe(e.toPort),e.invalidateRoute())}}aL(t){const i=this.linksConnected;for(;i.next();){const e=i.value;e.fromPort!==t&&e.toPort!==t||(this.xe(e.fromPort),this.xe(e.toPort),e.invalidateRoute())}}xe(t){if(t===null)return;const i=t.nd;i!==null&&i.Vd();const e=t.part,s=e.containingGroup;s!==null&&!e.isVisible()&&s.xe(s.port)}$r(){return!0}get portSpreading(){return this.bt!==null?this.bt.gy:1}set portSpreading(t){const i=this.portSpreading;if(i!==t){Debug&&t!==0&&t!==1&&t!==2&&Util.n("Node.portSpreading can only be set to PortSpreading.None, PortSpreading.Evenly, or PortSpreading.Packed, not: "+t),this.ml(),this.bt.gy=t,this.i("portSpreading",i,t);const e=this.diagram;if(e!==null&&e.undoManager.isUndoingRedoing)return;this.invalidateConnectedLinks()}}get avoidable(){return(this.z&8)!==0}set avoidable(t){const i=(this.z&8)!==0;if(i!==t){Debug&&Util.t(t,"boolean",Node,"avoidable"),this.z=this.z^8;const e=this.diagram;e!==null&&e.HP(this),this.i("avoidable",i,t)}}get avoidableMargin(){return this.bt!==null?this.bt.my:Margin.gC}set avoidableMargin(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Node,"avoidableMargin");const i=this.avoidableMargin;if(!i.equals(t)){t=t.L(),this.ml(),this.bt.my=t;const e=this.diagram;e!==null&&e.HP(this),this.i("avoidableMargin",i,t)}}canAvoid(){return this.avoidable&&!this.isLinkLabel}getAvoidableRect(t){return t.set(this.actualBounds),t.addMargin(this.avoidableMargin),t}findVisibleNode(){let t=this;for(;t!==null&&!t.isVisible();)t=t.containingGroup;return t}isVisible(){if(!super.isVisible())return!1;let t=!0,i=1;const e=this.diagram;if(e!==null){if(e.animationManager.ux(this))return!0;t=e.isTreePathToChildren,i=e.treeCollapsePolicy}if(i===1){const n=this.findTreeParentNode();if(n!==null&&!n.isTreeExpanded)return!1}else if(i===2){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&h.isTreeExpanded){r=!0;break}}}if(o&&!r)return!1}else if(i===3){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&!h.isTreeExpanded){r=!0;break}}}if(o&&r)return!1}const s=this.labeledLink;return s!==null?s.isVisible():!0}Ki(t){super.Ki(t);const i=this.linksConnected;for(;i.next();){const e=i.value;if(t&&this.containingGroup!==null){const s=e.getOtherNode(this);s!==null&&!s.isMemberOf(this.containingGroup)&&e.invalidateRoute()}e.Ki(t)}}get linksConnected(){return this.ni.iterator}findExternalTreeLinksConnected(){const t=new GSet,i=new GSet;return this.rT(this,t,i),i.iterator}rT(t,i,e){if(t===null||i.has(t))return;i.add(t);let s=!0;const n=this.diagram;n!==null&&(s=n.isTreePathToChildren),t.linksConnected.each(o=>{o.isTreeLink?(s?o.fromNode===t:o.toNode===t)&&this.rT(s?o.toNode:o.fromNode,i,e):e.add(o)})}findLinksConnected(t){if(t===void 0&&(t=null),t===null)return this.ni.iterator;Debug&&Util.t(t,"string",Node,"findLinksConnected:pid");const i=new ListIterator(this.ni),e=this;return i.predicate=s=>s.fromNode===e&&s.fromPortId===t||s.toNode===e&&s.toPortId===t,i}findLinksOutOf(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findLinksOutOf:pid");const i=new ListIterator(this.ni),e=this;return i.predicate=s=>s.fromNode!==e?!1:t===null?!0:s.fromPortId===t,i}findLinksInto(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findLinksInto:pid");const i=new ListIterator(this.ni),e=this;return i.predicate=s=>s.toNode!==e?!1:t===null?!0:s.toPortId===t,i}findNodesConnected(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findNodesConnected:pid");let i=null,e=null;const s=this.ni.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this){if(t===null||n.fromPortId===t){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}else if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesOutOf(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findNodesOutOf:pid");let i=null,e=null;const s=this.ni.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this&&(t===null||n.fromPortId===t)){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesInto(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findNodesInto:pid");let i=null,e=null;const s=this.ni.iterator;for(;s.next();){const n=s.value;if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findLinksBetween(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),Debug&&(Util.s(t,Node,Node,"findLinksBetween:othernode"),i!==null&&Util.t(i,"string",Node,"findLinksBetween:pid"),e!==null&&Util.t(e,"string",Node,"findLinksBetween:otherpid"));const s=new ListIterator(this.ni),n=this;return s.predicate=o=>o.fromNode===n&&o.toNode===t&&(i===null||o.fromPortId===i)&&(e===null||o.toPortId===e)||o.fromNode===t&&o.toNode===n&&(e===null||o.fromPortId===e)&&(i===null||o.toPortId===i),s}findLinksTo(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),Debug&&(Util.s(t,Node,Node,"findLinksTo:othernode"),i!==null&&Util.t(i,"string",Node,"findLinksTo:pid"),e!==null&&Util.t(e,"string",Node,"findLinksTo:otherpid"));const s=new ListIterator(this.ni),n=this;return s.predicate=o=>!(o.fromNode!==n||o.toNode!==t||i!==null&&o.fromPortId!==i||e!==null&&o.toPortId!==e),s}get linkConnected(){return this.bt!==null?this.bt.py:null}set linkConnected(t){const i=this.linkConnected;i!==t&&(t!==null&&Util.t(t,"function",Node,"linkConnected"),this.ml(),this.bt.py=t,this.i("linkConnected",i,t))}get linkDisconnected(){return this.bt!==null?this.bt.yy:null}set linkDisconnected(t){const i=this.linkDisconnected;i!==t&&(t!==null&&Util.t(t,"function",Node,"linkDisconnected"),this.ml(),this.bt.yy=t,this.i("linkDisconnected",i,t))}get linkValidation(){return this.bt!==null?this.bt.Ll:null}set linkValidation(t){const i=this.linkValidation;i!==t&&(t!==null&&Util.t(t,"function",Node,"linkValidation"),this.ml(),this.bt.Ll=t,this.i("linkValidation",i,t))}xb(t,i){this.xe(i);const e=this.ni.has(t);if(e||this.ni.add(t),!e||t.fromNode===t.toNode){const s=this.linkConnected;if(s!==null){let n=!0;const o=this.diagram;o!==null&&(n=o.j,o.j=!0),s(this,t,i),o!==null&&(o.j=n)}}if(!e){if(!t.isTreeLink)return;const s=t.fromNode,n=t.toNode;if(s!==null&&n!==null&&s!==n){let o=!0;const r=this.diagram;r!==null&&(o=r.isTreePathToChildren);const l=o?n:s,h=o?s:n;if(l.bh||(l.bh=h),h.isTreeLeaf){if(r!==null&&r.undoManager.isUndoingRedoing)return;o?s===h&&(h.isTreeLeaf=!1):n===h&&(h.isTreeLeaf=!1)}}}}bb(t,i){this.xe(i);const e=this.ni.delete(t);let s=null;if(e||t.toNode===t.fromNode){const n=this.linkDisconnected;if(s=this.diagram,n!==null){let o=!0;s!==null&&(o=s.j,s.j=!0),n(this,t,i),s!==null&&(s.j=o)}}if(e){if(!t.isTreeLink)return;let n=!0;s!==null&&(n=s.isTreePathToChildren);const o=n?t.toNode:t.fromNode,r=n?t.fromNode:t.toNode;if(o!==null&&(o.bh=!1),r!==null&&!r.isTreeLeaf)if(r.ni.count===0){if(r.bh=null,s!==null&&s.undoManager.isUndoingRedoing)return;r.isTreeLeaf=!0}else r.x0()}}x0(){if(this.bh=!1,this.ni.count===0)return;let t=!0;const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;i!==null&&(t=i.isTreePathToChildren);const e=this.ni.iterator;for(;e.next();){const s=e.value;if(s.isTreeLink){if(t){if(s.fromNode===this){this.isTreeLeaf=!1;return}}else if(s.toNode===this){this.isTreeLeaf=!1;return}}}this.isTreeLeaf=!0}updateRelationshipsFromData(){const t=this.diagram;t!==null&&t.partManager.updateRelationshipsFromData(this)}Hm(t){if(super.Hm(t),!t){this.x0();const i=this.Cc;i!==null&&i.lT(this)}}qm(t){if(super.qm(t),!t){const i=this.Cc;i!==null&&i.hT(this)}}Jf(){if(this.ni.count>0){const t=this.diagram;if(t!==null){const i=t.commandHandler!==null?t.commandHandler.deletesConnectedLinks:!0,s=this.ni.copy().iterator;for(;s.next();){const n=s.value;i?t.remove(n):(n.fromNode===this&&(n.fromNode=null),n.toNode===this&&(n.toNode=null))}}}this.labeledLink=null,super.Jf()}get isLinkLabel(){return this.Cc!==null}get labeledLink(){return this.Cc}set labeledLink(t){const i=this.Cc;if(i!==t){Debug&&t!==null&&Util.s(t,Link,Node,"labeledLink");const e=this.diagram,s=this.data;if(i!==null){if(i.hT(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=i.data,o=e.model;if(n!==null&&o.Oa()){const r=o.getKeyForNodeData(s);r!==void 0&&o.removeLabelKeyForLinkData(n,r)}}this.containingGroup=null}if(this.Cc=t,t!==null){if(t.lT(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=t.data,o=e.model;if(n!==null&&o.Oa()){const r=o.getKeyForNodeData(s);r!==void 0&&o.addLabelKeyForLinkData(n,r)}}this.containingGroup=t.containingGroup}this.lc(),this.i("labeledLink",i,t)}}findVisiblePort(t){let i=t;for(;i!==null&&(!i.actualBounds.isReal()||!i.isVisibleObject());)i=i.panel;return i===null?this.port:i}findPort(t){if(Debug&&Util.t(t,"string",Node,"findPort:pid"),this.he===null){if(t===""&&this.Mn===!1)return this;this.aT()}let i=this.he.get(t);return i!==null||t!==""&&(i=this.he.get(""),i!==null)?i:this}get port(){return this.findPort("")}get ports(){return this.he===null&&this.aT(),this.he.iteratorValues}aT(){this.he===null?this.he=new GMap:this.he.clear(),this.walkVisualTreeFrom(this,(t,i)=>t.yL(i)),this.he.count===0&&this.he.set("",this)}yL(t){const i=t.portId;i!==null&&this.he!==null&&this.he.set(i,t)}P2(t,i){const e=t.portId;if(e!==null){this.he!==null&&this.he.delete(e);const s=this.diagram;if(s!==null&&i){let n=null;const o=this.findLinksConnected(e);for(;o.next();){const r=o.value;n===null&&(n=Util.ft()),n.push(r)}if(n!==null){for(let r=0;r!(!n.isTreeLink||n.fromNode!==s):e.predicate=n=>!(!n.isTreeLink||n.toNode!==s),e}findTreeChildrenNodes(){let t=!0;const i=this.diagram;i!==null&&(t=i.isTreePathToChildren);let e=null,s=null;const n=this.ni.iterator;if(t)for(;n.next();){const o=n.value;if(o.isTreeLink&&o.fromNode===this){const r=o.toNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}else for(;n.next();){const o=n.value;if(o.isTreeLink&&o.toNode===this){const r=o.fromNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}return e!==null?e.iterator:s!==null?new SingletonIterator(s):EmptyIterator.instance}findTreeParts(t){t===void 0&&(t=1/0),Util.t(t,"number",Node,"findTreeParts:level");const i=new GSet;return Part.lh(i,this,!1,t,!0),i}collapseTree(t){t===void 0&&(t=1),Util.r(t,Node,"collapseTree:level"),t<1&&(t=1);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.fT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}fT(t,i,e,s,n,o){if(e>1){const r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);h!==null&&h!==this&&!t.has(h)&&(t.add(h),h.fT(t,i,e-1,s,n,o))}}else this.cT(t,i,s,n,o)}cT(t,i,e,s,n){const o=s===this?!0:this.isTreeExpanded,r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);if(h!==null&&h!==this){const a=t.has(h);if(a||t.add(h),o){const f=i?h.findNodesInto():h.findNodesOutOf(),c=this;f.all(u=>u===c||!u.isTreeExpanded)&&e.Of(h,s),h.dh(),h.Ki(!1)}h.isTreeExpanded&&(h.wasTreeExpanded=h.isTreeExpanded,a||h.cT(t,i,e,s,n))}}this.isTreeExpanded=!1}expandTree(t){t===void 0&&(t=2),Util.r(t,Node,"expandTree:level"),t<2&&(t=2);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.uT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}uT(t,i,e,s,n,o){const r=n===this?!1:this.isTreeExpanded,l=i?this.findLinksOutOf():this.findLinksInto();for(;l.next();){const h=l.value;if(!h.isTreeLink)continue;r||h.Te||h.invalidateRoute();const a=h.getOtherNode(this);if(a!==null&&a!==this&&!t.has(a)){if(t.add(a),!r){a.Ki(!0),a.dh();const f=i?a.findNodesInto():a.findNodesOutOf(),c=this;f.all(u=>u===c||!u.isTreeExpanded)&&s.If(a,n)}(e>2||a.wasTreeExpanded)&&(a.wasTreeExpanded=!1,a.uT(t,i,e-1,s,n,o))}}this.isTreeExpanded=!0}get isTreeExpanded(){return(this.z&1)!==0}set isTreeExpanded(t){const i=(this.z&1)!==0;if(i!==t){Debug&&Util.t(t,"boolean",Node,"isTreeExpanded"),this.z=this.z^1;const e=this.diagram;this.i("isTreeExpanded",i,t);const s=this.treeExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.j,e.j=!0),s(this),e!==null&&(e.j=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.Ki(t);return}t?this.expandTree():this.collapseTree()}}get wasTreeExpanded(){return(this.z&2)!==0}set wasTreeExpanded(t){const i=(this.z&2)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Node,"wasTreeExpanded"),this.z=this.z^2,this.i("wasTreeExpanded",i,t))}get treeExpandedChanged(){return this.bt!==null?this.bt.wy:null}set treeExpandedChanged(t){const i=this.treeExpandedChanged;i!==t&&(t!==null&&Util.t(t,"function",Node,"treeExpandedChanged"),this.ml(),this.bt.wy=t,this.i("treeExpandedChanged",i,t))}get isTreeLeaf(){return(this.z&4)!==0}set isTreeLeaf(t){const i=(this.z&4)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Node,"isTreeLeaf"),this.z=this.z^4,this.i("isTreeLeaf",i,t))}get isTreeRoot(){return this.findTreeParentLink()===null}}class NodeTemplateSettings{wi;py;yy;Ll;wy;my;gy;xy;by;rh;ky;constructor(){this.wi=!1,this.py=null,this.yy=null,this.Ll=null,this.wy=null,this.my=Margin.gC,this.gy=1,this.xy=null,this.by=null,this.rh=null,this.ky=null}copy(){const t=new NodeTemplateSettings;return t.py=this.py,t.yy=this.yy,t.Ll=this.Ll,t.wy=this.wy,t.my=this.my.L(),t.gy=this.gy,t.xy=this.xy,t.by=this.by,t.rh=this.rh,t.ky=this.ky,t}}var LinkAdjusting=(w=>(w[w.None=0]="None",w[w.End=17]="End",w[w.Scale=18]="Scale",w[w.Stretch=19]="Stretch",w))(LinkAdjusting||{}),Routing=(w=>(w[w.Normal=1]="Normal",w[w.Orthogonal=2]="Orthogonal",w[w.AvoidsNodes=6]="AvoidsNodes",w[w.AvoidsNodesStraight=7]="AvoidsNodesStraight",w))(Routing||{}),Curve=(w=>(w[w.None=0]="None",w[w.Bezier=9]="Bezier",w[w.JumpGap=10]="JumpGap",w[w.JumpOver=11]="JumpOver",w))(Curve||{});class Link extends Part{Dt;go;mo;Bd;po;yo;zd;Ac;Xd;Yd;Kd;Ea;Ud;$s;Ni;Ie;Lr;Lc;ir;lN;hN;kb;aN;fN;Sy;Sb;yt;er;static Va=null;static Ba=null;dc;cN;uN;constructor(t){super(Panel.Link),this.Dt=8,this.go=null,this.mo="",this.Bd=null,this.po=null,this.yo="",this.zd=null,this.Ac=0,this.Xd=0,this.Yd=0,this.Kd=NaN,this.Ea=1,this.Ud=.5,this.$s=null,this.Ni=new List().w(),this.Ie=null,this.Lr=null,this.Lc=new Rect,this.yt=new Geometry,this.ir=null,this.er=null,this.lN=null,this.hN=null,this.cN=0,this.uN=0,this.kb=new Point,this.aN=null,this.fN=null,this.Sy=null,this.Sb=NaN,this.Z=null,this.dc=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Dt=this.Dt&-113,t.mo=this.mo,t.Bd=this.Bd,t.yo=this.yo,t.zd=this.zd,t.Ac=this.Ac,t.Xd=this.Xd,t.Yd=this.Yd,t.Kd=this.Kd,t.Ea=this.Ea,t.Ud=this.Ud,this.Z!==null&&(t.Z=this.Z.copy())}Ho(t){super.Ho(t),this.mo=t.mo,this.yo=t.yo,t.Ie=null,t.invalidateRoute(),t.er=this.er;const i=t.fromPort;i!==null&&t.fromNode.xe(i);const e=t.toPort;e!==null&&t.toNode.xe(e)}fi(t){t in Routing||t in Curve||t in LinkAdjusting?Link.dN(t)?this.routing=t:t===9||t===10||t===11?this.curve=t:t===17||t===18||t===19?this.adjusting=t:t===1||t===0||Util.n("Unknown Link enum value for a Link property: "+t):super.fi(t)}static Normal=1;static Orthogonal=2;static AvoidsNodes=6;static AvoidsNodesStraight=7;static None=0;static Bezier=9;static JumpGap=10;static JumpOver=11;static End=17;static Scale=18;static Stretch=19;static OrientAlong=21;static OrientPlus90=22;static OrientMinus90=23;static OrientOpposite=24;static OrientUpright=25;static OrientPlus90Upright=26;static OrientMinus90Upright=27;static OrientUpright45=28;static JI=8;static ZI=16;static $I=14;static za=8;je(){this.Z===null&&(this.Z=new LinkSettings)}rI(t,i,e){const s=t.segmentIndex,n=t.segmentFraction;let o=t.alignmentFocus;const r=t.segmentOrientation,l=t.segmentOffset;let h=0,a=0,f=0,c=0;if(isNaN(s)){const C=this.yt,P=Util.ft();C.getPointAndAngleAlongPath(n,P);const N=Point.H(P[0],P[1]);if(N.add(this.getPoint(0)),C.type===1)N.offset(-C.startX,-C.startY);else{const T=C.figures.first();N.offset(-T.startX,-T.startY)}c=P[2],r!==0&&(f=this.computeAngle(t,r,c),t.angle=f),h=N.x,a=N.y,Point.o(N),Util.nt(P)}else if(s<-i||s>=i){const C=Point.a();this.ML(C),c=this.midAngle,r!==0&&(f=this.computeAngle(t,r,c),t.angle=f),h=C.x,a=C.y,Point.o(C)}else{let C,P,N=0;if(s>=0?(C=e.h[s],P=s0?e.h[N-1]:C),C.equalsApprox(P)){let T,L;s>=0?(T=s>0?e.h[s-1]:C,L=s1?e.h[N-2]:P);const D=T.distanceSquaredPoint(C),F=P.distanceSquaredPoint(L);D>F+10?c=s>=0?T.directionPoint(C):C.directionPoint(T):F>D+10?c=s>=0?P.directionPoint(L):L.directionPoint(P):c=s>=0?T.directionPoint(L):L.directionPoint(T)}else c=s>=0?C.directionPoint(P):P.directionPoint(C);r!==0&&(f=this.computeAngle(t,r,c),t.angle=f),h=C.x+(P.x-C.x)*n,a=C.y+(P.y-C.y)*n}if(o.isNone()){t.location=new Point(h,a);return}else o.isNoSpot()&&(o=Spot.Center);const u=Transform.a();u.Bi(),u.lt(t.scale,t.scale),u.ms(t.angle,0,0);const d=t.naturalBounds,m=Rect.H(0,0,d.width,d.height),g=Point.a();g.setRectSpot(m,o),u.Pt(g);let p=-g.x,y=-g.y;const x=d.width,k=d.height,b=Point.a();b.c(l);const S=isNaN(l.x),M=isNaN(l.y);if(S||M){const C=x/2+3,P=k/2+3,N=c>=45&&c<=135,T=c>=225&&c<=315;r===0&&(N||T)?(b.x=M?C:l.y,b.y=S?P:l.x,N?s>=0||isNaN(s)&&n<.5||S&&(b.y=-P):T&&((s>=0||isNaN(s)&&n<.5)&&S&&(b.y=-P),M&&(b.x=-C))):(S&&(s>=0||isNaN(s)&&n<.5?b.x=C:b.x=-C),M&&(b.y=-P),b.rotate(c))}else b.rotate(c);h+=b.x,a+=b.y,u.Cw(m),p+=m.x,y+=m.y;const A=Point.H(h+p,a+y);t.move(A),Point.o(A),Point.o(b),Point.o(g),Rect.o(m),Transform.o(u)}$r(){let t=this.fromNode;if(t!==null){const e=t.findVisibleNode();if(e!==null&&(t=e),t.rs()||t.nh())return!1}let i=this.toNode;if(i!==null){const e=i.findVisibleNode();if(e!==null&&(i=e),i.rs()||i.nh())return!1}return!0}S2(t,i,e){return!1}M2(){}Ae(){return!1}computeAngle(t,i,e){return Link.computeAngle(i,e)}static computeAngle(t,i){let e=0;switch(t){default:case 0:e=0;break;case 21:e=i;break;case 22:e=i+90;break;case 23:e=i-90;break;case 24:e=i+180;break;case 25:e=Geo.Jg(i),e>90&&e<270&&(e-=180);break;case 26:e=Geo.Jg(i+90),e>90&&e<270&&(e-=180);break;case 27:e=Geo.Jg(i-90),e>90&&e<270&&(e-=180);break;case 28:if(e=Geo.Jg(i),e>45&&e<135||e>225&&e<315)return 0;e>90&&e<270&&(e-=180);break}return Geo.Jg(e)}get fromNode(){return this.go}set fromNode(t){const i=this.go;if(i!==t){Debug&&t!==null&&Util.s(t,Node,Link,"fromNode");const e=this.fromPort;i!==null&&(this.po!==i&&i.bb(this,e),this.My(),this.invalidateLayout(2)),this.go=t,t!==null&&this.Ki(t.isVisible()),this.ir=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.j&&s.partManager.setFromNodeForLink(this,t,i);const n=this.fromPort,o=this.fromPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.j,s.j=!0),o(this,e,n),s!==null&&(s.j=r)}t!==null&&(this.po!==t&&t.xb(this,n),this.Py(),this.invalidateLayout(1)),this.i("fromNode",i,t),this.Ed()}}get fromPortId(){return this.mo}set fromPortId(t){const i=this.mo;if(i!==t){Debug&&Util.t(t,"string",Link,"fromPortId");const e=this.fromPort;e!==null&&this.fromNode.xe(e),this.My(),this.mo=t;const s=this.fromPort;s!==null&&this.fromNode.xe(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Oa()&&r.setFromPortIdForLinkData(o,t)}if(e!==s){this.ir=null,this.invalidateRoute();const o=this.fromPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.j,n.j=!0),o(this,e,s),n!==null&&(n.j=r)}}this.Py(),this.i("fromPortId",i,t)}}get fromPort(){const t=this.go;if(t===null)return null;const i=this.mo;return t.findPort(i)}get fromPortChanged(){return this.Bd}set fromPortChanged(t){const i=this.Bd;i!==t&&(t!==null&&Util.t(t,"function",Link,"fromPortChanged"),this.Bd=t,this.i("fromPortChanged",i,t))}get toNode(){return this.po}set toNode(t){const i=this.po;if(i!==t){Debug&&t!==null&&Util.s(t,Node,Link,"toNode");const e=this.toPort;i!==null&&(this.go!==i&&i.bb(this,e),this.My(),this.invalidateLayout(2)),this.po=t,t!==null&&this.Ki(t.isVisible()),this.ir=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.j&&s.partManager.setToNodeForLink(this,t,i);const n=this.toPort,o=this.toPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.j,s.j=!0),o(this,e,n),s!==null&&(s.j=r)}t!==null&&(this.go!==t&&t.xb(this,n),this.Py(),this.invalidateLayout(1)),this.i("toNode",i,t),this.Ed()}}get toPortId(){return this.yo}set toPortId(t){const i=this.yo;if(i!==t){Debug&&Util.t(t,"string",Link,"toPortId");const e=this.toPort;e!==null&&this.toNode.xe(e),this.My(),this.yo=t;const s=this.toPort;s!==null&&this.toNode.xe(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Oa()&&r.setToPortIdForLinkData(o,t)}if(e!==s){this.ir=null,this.invalidateRoute();const o=this.toPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.j,n.j=!0),o(this,e,s),n!==null&&(n.j=r)}}this.Py(),this.i("toPortId",i,t)}}get toPort(){const t=this.po;if(t===null)return null;const i=this.yo;return t.findPort(i)}get toPortChanged(){return this.zd}set toPortChanged(t){const i=this.zd;i!==t&&(t!==null&&Util.t(t,"function",Link,"toPortChanged"),this.zd=t,this.i("toPortChanged",i,t))}get fromSpot(){return this.Z!==null?this.Z.ma:Spot.Default}set fromSpot(t){const i=this.fromSpot;if(!i.equals(t)){if(Debug&&Util.s(t,Spot,Link,"fromSpot"),t=t.L(),this.je(),this.Z.ma=t,this.i("fromSpot",i,t),i.isSide()||t.isSide()){const e=this.fromNode;e!==null&&e.xe(this.fromPort)}this.invalidateRoute()}}get fromEndSegmentLength(){return this.Z!==null?this.Z.ya:NaN}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;i!==t&&(Debug&&Util.t(t,"number",Link,"fromEndSegmentLength"),t<0&&Util.G(t,">= 0",Link,"fromEndSegmentLength"),this.je(),this.Z.ya=t,this.i("fromEndSegmentLength",i,t),this.invalidateRoute())}get fromShortLength(){return this.Z!==null?this.Z.xa:NaN}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(Debug&&Util.t(t,"number",Link,"fromShortLength"),this.je(),this.Z.xa=t,this.re(),this.i("fromShortLength",i,t))}get toSpot(){return this.Z!==null?this.Z.pa:Spot.Default}set toSpot(t){const i=this.toSpot;if(!i.equals(t)){if(Debug&&Util.s(t,Spot,Link,"toSpot"),t=t.L(),this.je(),this.Z.pa=t,this.i("toSpot",i,t),i.isSide()||t.isSide()){const e=this.toNode;e!==null&&e.xe(this.toPort)}this.invalidateRoute()}}get toEndSegmentLength(){return this.Z!==null?this.Z.wa:NaN}set toEndSegmentLength(t){const i=this.toEndSegmentLength;i!==t&&(Debug&&Util.t(t,"number",Link,"toEndSegmentLength"),t<0&&Util.G(t,">= 0",Link,"toEndSegmentLength"),this.je(),this.Z.wa=t,this.i("toEndSegmentLength",i,t),this.invalidateRoute())}get toShortLength(){return this.Z!==null?this.Z.ba:NaN}set toShortLength(t){const i=this.toShortLength;i!==t&&(Debug&&Util.t(t,"number",Link,"toShortLength"),this.je(),this.Z.ba=t,this.re(),this.i("toShortLength",i,t))}Ed(){const t=this.fromNode,i=this.toNode;let e=null;if(t!==null?i!==null?e=t.findCommonContainingGroup(i):e=t.containingGroup:i!==null?e=i.containingGroup:e=null,this.QI(e),this.isLabeledLink){const s=this.labelNodes;for(;s.next();){const n=s.value;n.containingGroup=e}}}QI(t){const i=this.xh;if(i!==t){i!==null&&i.tN(this),this.xh=t,t!==null&&t.iN(this);const e=this.containingGroupChanged;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.j,n.j=!0),e(this,i,t),n!==null&&(n.j=s)}this.Te&&(this.aN===i||this.fN===i)&&this.invalidateRoute()}}dh(){const t=this.containingGroup;t!==null&&this.fromNode!==t&&this.toNode!==t&&t.computesBoundsIncludingLinks&&super.dh()}getOtherNode(t){Debug&&Util.s(t,Node,Link,"getOtherNode:node");const i=this.fromNode;return t===i?this.toNode:i}getOtherPort(t){Debug&&Util.s(t,GraphObject,Link,"getOtherPort:port");const i=this.fromPort;return t===i?this.toPort:i}get isLabeledLink(){return this.$s===null?!1:this.$s.count>0}get labelNodes(){return this.$s===null?EmptyIterator.instance:this.$s.iterator}lT(t){this.$s===null&&(this.$s=new GSet),this.$s.add(t),this.u()}hT(t){this.$s!==null&&(this.$s.delete(t),this.u())}Hm(t){if(super.Hm(t),this.Xa()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.go;let e=null;i!==null&&(e=this.fromPort,i.xb(this,e));const s=this.po;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.xb(this,n)),this.Py()}}qm(t){if(super.qm(t),this.Xa()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.go;let e=null;i!==null&&(e=this.fromPort,i.bb(this,e));const s=this.po;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.bb(this,n)),this.My()}}Jf(){if(this.Te=!0,this.$s!==null){const i=this.diagram;if(i!==null){const s=this.$s.copy().iterator;for(;s.next();){const n=s.value;i.remove(n)}}}if(this.data!==null){const i=this.diagram;i!==null&&i.partManager.gN(this)}}updateRelationshipsFromData(){if(this.data===null)return;const i=this.diagram;i!==null&&i.partManager.updateRelationshipsFromData(this)}move(t,i){const e=i?this.location:this.position;let s=e.x;isNaN(s)&&(s=0);let n=e.y;isNaN(n)&&(n=0);const o=t.x-s,r=t.y-n;if(i===!0)super.move(t,!1);else{const h=Point.H(e.x+o,e.y+r);super.move(h,!1),Point.o(h)}this.kr(o,r);const l=this.labelNodes;for(;l.next();){const h=l.value,a=h.position;h.moveTo(a.x+o,a.y+r)}}get relinkableFrom(){return(this.Dt&1)!==0}set relinkableFrom(t){const i=(this.Dt&1)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"relinkableFrom"),this.Dt=this.Dt^1,this.i("relinkableFrom",i,t),this.invalidateAdornments())}get relinkableTo(){return(this.Dt&2)!==0}set relinkableTo(t){const i=(this.Dt&2)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"relinkableTo"),this.Dt=this.Dt^2,this.i("relinkableTo",i,t),this.invalidateAdornments())}canRelinkFrom(){if(!this.relinkableFrom)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}canRelinkTo(){if(!this.relinkableTo)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}get resegmentable(){return(this.Dt&4)!==0}set resegmentable(t){const i=(this.Dt&4)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"resegmentable"),this.Dt=this.Dt^4,this.i("resegmentable",i,t),this.invalidateAdornments())}get isTreeLink(){return(this.Dt&8)!==0}set isTreeLink(t){const i=(this.Dt&8)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"isTreeLink"),this.Dt=this.Dt^8,this.i("isTreeLink",i,t),this.fromNode!==null&&this.fromNode.x0(),this.toNode!==null&&this.toNode.x0())}get path(){const t=this.findMainElement();return t instanceof Shape?t:null}get routeBounds(){return this.updateRoute(),this._I(this.Lc)}_I(t){let i=1/0,e=1/0;const s=this.pointsCount;if(s===0)return t.e(NaN,NaN,0,0),t;if(s===1){const n=this.getPoint(0);i=Math.min(n.x,i),e=Math.min(n.y,e),t.e(n.x,n.y,0,0)}else if(s===2){const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o)}else if(this.computeCurve()===9&&s>=3&&!this.isOrthogonal){let n=this.getPoint(0);if(i=n.x,e=n.y,t.e(i,e,0,0),s===3){const o=this.getPoint(1);i=Math.min(o.x,i),e=Math.min(o.y,e);const r=this.getPoint(2);i=Math.min(r.x,i),e=Math.min(r.y,e),Geo.mu(n.x,n.y,o.x,o.y,o.x,o.y,r.x,r.y,.5,t)}else for(let o=3;o=s&&(o=s-1);const l=this.getPoint(o-1),h=this.getPoint(o);Geo.mu(n.x,n.y,r.x,r.y,l.x,l.y,h.x,h.y,.5,t),i=Math.min(h.x,i),e=Math.min(h.y,e),n=h}}else{const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o);for(let r=2;r=15||this.computeCurve()===9)){this.yt.getPointAlongPath(.5,t),t.add(this.getPoint(0));const a=this.yt.figures.first();return t.offset(-a.startX,-a.startY),t}if(this.computeCurve()===9){if(i===3){const c=this.getPoint(0),u=this.getPoint(1),d=this.getPoint(2);return Geo.bC(c.x,c.y,u.x,u.y,u.x,u.y,d.x,d.y,t),t}const a=(i-1)/3|0,f=(a/2|0)*3;if(a%2===1){const c=this.getPoint(f),u=this.getPoint(f+1),d=this.getPoint(f+2),m=this.getPoint(f+3);return Geo.bC(c.x,c.y,u.x,u.y,d.x,d.y,m.x,m.y,t),t}else return t.c(this.getPoint(f)),t}const e=this.flattenedLengths,s=this.flattenedTotalLength;let n=0,o=0,r=0;for(;ns/2));)n+=r,o++;const l=this.getPoint(o),h=this.getPoint(o+1);if(Math.abs(l.x-h.x)<1)l.y>h.y?t.e(l.x,l.y-(s/2-n)):t.e(l.x,l.y+(s/2-n));else if(Math.abs(l.y-h.y)<1)l.x>h.x?t.e(l.x-(s/2-n),l.y):t.e(l.x+(s/2-n),l.y);else{const a=(s/2-n)/r,f=a*(h.x-l.x),c=a*(h.y-l.y);t.e(l.x+f,l.y+c)}return t}get midAngle(){return this.updateRoute(),this.computeMidAngle()}computeMidAngle(){const t=this.pointsCount;if(t<2)return NaN;if(t===2){const h=this.getPoint(0),a=this.getPoint(1);return h.directionPoint(a)}if(this.isOrthogonal&&(this.computeCorner()>=15||this.computeCurve()===9))return this.yt.getAngleAlongPath(.5);if(this.computeCurve()===9&&t>=4){const h=(t-1)/3|0;let a=(h/2|0)*3;if(h%2===1){a=Math.floor(a);const f=this.getPoint(a),c=this.getPoint(a+1),u=this.getPoint(a+2),d=this.getPoint(a+3);return Geo.YD(f.x,f.y,c.x,c.y,u.x,u.y,d.x,d.y)}else if(a>0&&a+1e/2));)s+=o,n++;const r=this.getPoint(n),l=this.getPoint(n+1);if(Math.abs(r.x-l.x)<1&&Math.abs(r.y-l.y)<1){if(n>0&&n+2l.y?270:90;if(Math.abs(r.y-l.y)<1)return r.x>l.x?180:0}return r.directionPoint(l)}tO(){if(this.Sy===null){this.Te||this.Mb();const t=this.Sy=[];this.iO(t)}}get flattenedLengths(){return this.tO(),this.Sy}get flattenedTotalLength(){let t=this.Sb;if(isNaN(t)){const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=3){let g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e);m=this.adjustPoints(0,g,o-1,p),m&&(g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e),this.adjustPoints(0,g,o-1,p))}m||(this.clearPoints(),u?this.eO(i,e,r,s,n,l):this.sO(i,e,r,s,n,l))}else{const m=this.isAvoiding;d&&(c&&m||f)&&this.clearPoints();const g=f?this.computeCurviness():0,p=this.getLinkPoint(i,e,r,!0,c,s,n);let y=0,x=0,k=0;if(c||!h||f){let N=this.computeEndSegmentLength(i,e,r,!0);if(k=this.getLinkDirection(i,e,p,r,!0,c,s,n),f&&(h||r.equals(l)||!c&&r.x+l.x===1&&r.y+l.y===1)&&(k-=c?90:30,g<0&&(k-=180)),k<0?k+=360:k>=360&&(k-=360),f&&(N+=Math.abs(g)*(c?1:2)),k===0?y=N:k===90?x=N:k===180?y=-N:k===270?x=-N:(y=N*Math.cos(k*Math.PI/180),x=N*Math.sin(k*Math.PI/180)),r.isNoSpot()&&f){const T=e.getDocumentPoint(Spot.Center,Point.a()),L=Point.H(T.x+y*1e3,T.y+x*1e3);this.getLinkPointFromPoint(i,e,T,L,!0,p),Point.o(T),Point.o(L)}}const b=this.getLinkPoint(s,n,l,!1,c,i,e);let S=0,M=0,A=0;if(c||!a||f){let N=this.computeEndSegmentLength(s,n,l,!1);if(A=this.getLinkDirection(s,n,b,l,!1,c,i,e),f&&(a||r.equals(l)||!c&&r.x+l.x===1&&r.y+l.y===1)&&(A+=c?0:30,g<0&&(A+=180)),A<0?A+=360:A>=360&&(A-=360),f&&(N+=Math.abs(g)*(c?1:2)),A===0?S=N:A===90?M=N:A===180?S=-N:A===270?M=-N:(S=N*Math.cos(A*Math.PI/180),M=N*Math.sin(A*Math.PI/180)),l.isNoSpot()&&f){const T=n.getDocumentPoint(Spot.Center,Point.a()),L=Point.H(T.x+S*1e3,T.y+M*1e3);this.getLinkPointFromPoint(s,n,T,L,!1,b),Point.o(T),Point.o(L)}}let C=p;(c||!h||f)&&(C=new Point(p.x+y,p.y+x));let P=b;(c||!a||f)&&(P=new Point(b.x+S,b.y+M)),!d&&!c&&h&&o>3&&this.adjustPoints(0,p,o-2,P)?this.setPoint(o-1,b):!d&&!c&&a&&o>3&&this.adjustPoints(1,C,o-1,b)?this.setPoint(0,p):!d&&(c?o>=6:o>4)&&this.adjustPoints(1,C,o-2,P)?(this.setPoint(0,p),this.setPoint(o-1,b)):(this.clearPoints(),this.addPoint(p),(c||!h||f)&&this.addPoint(C),c&&this.addOrthoPoints(C,k,P,A,i,s),(c||!a||f)&&this.addPoint(P),this.addPoint(b))}return t.addInvalidRoute(this),!0}pN(t,i){return Math.abs(i.x-t.x)>Math.abs(i.y-t.y)?(i.x>=t.x?i.x=t.x+9e9:i.x=t.x-9e9,i.y=t.y):(i.y>=t.y?i.y=t.y+9e9:i.y=t.y-9e9,i.x=t.x),i}getLinkPointFromPoint(t,i,e,s,n,o){if(o===void 0&&(o=new Point),t===null||i===null)return o.c(e),o;if(!t.isVisible()){const u=t.findVisibleNode();u!==null&&u!==t&&(t=u,i=t.port)}let r=0,l=0,h=0,a=0,f=null,c=i.panel;if(c!==null&&!c.kn()&&(c=c.panel),c===null)r=s.x,l=s.y,h=e.x,a=e.y;else{f=c.Ks;const u=1/(f.m11*f.m22-f.m12*f.m21),d=f.m22*u,m=-f.m12*u,g=-f.m21*u,p=f.m11*u,y=u*(f.m21*f.dy-f.m22*f.dx),x=u*(f.m12*f.dx-f.m11*f.dy);r=s.x*d+s.y*g+y,l=s.x*m+s.y*p+x,h=e.x*d+e.y*g+y,a=e.x*m+e.y*p+x}return i.sc(r,l,h,a,o),f!==null&&o.O(f),o}nO(t,i){const e=t.nd;return e!==null?e.dT(i):null}Nb(t){let i=t.nd;return i===null&&(i=new Knot,i.sr=t,i.ye=t.part,t.nd=i),i.dT(this)}getLinkPoint(t,i,e,s,n,o,r,l){if(l===void 0&&(l=new Point),e.isSpot()&&!this.Gd(e))return i.getDocumentPoint(e,l),l;if(e.isSide()){const f=this.Nb(i);if(f!==null){const c=f.Hd;if(l.c(c),n&&this.routing===7){const u=this.Nb(r);if(u!==null&&f.Tc=g.y&&y.y<=g.y+g.height?l.y=y.y:(e.includesSide(Spot.TopSide)||e.includesSide(Spot.BottomSide))&&y.x>=g.x&&y.x<=g.x+g.width&&(l.x=y.x),Point.o(d),Point.o(m)}}return l}}const h=i.getDocumentPoint(this.Cb(e,s),Point.a());let a=null;if(this.pointsCount>(n?6:2))a=s?this.getPoint(1):this.getPoint(this.pointsCount-2),n&&(a=this.pN(h,a.copy()));else{const f=this.computeSpot(!s,r),c=Point.a();a=r.getDocumentPoint(this.Cb(f,!s),c),n&&(a=this.pN(h,a)),Point.o(c)}return this.getLinkPointFromPoint(t,i,h,a,s,l),Point.o(h),l}getLinkDirection(t,i,e,s,n,o,r,l){let h=this.oO(t,i,e,s,n,o,r,l);if(r&&s.isNoSpot()&&r.isMemberOf(t)&&(h+=180,h>=360&&(h-=360)),this.Gd(s))return h;const a=i.getDocumentAngle();return a===0||(45<=a&&a<135?h+=90:135<=a&&a<225?h+=180:225<=a&&a<315&&(h+=270),h>=360&&(h-=360)),h}oO(t,i,e,s,n,o,r,l){if(s.isSpot())return s.x>s.y?s.x>1-s.y?0:s.x<1-s.y?270:315:s.x1-s.y?90:s.x<1-s.y?180:135:s.x<.5?225:s.x>.5?45:0;if(s.isSide()){const c=this.Nb(i);if(c!==null)switch(c.be){case 1:return 270;case 2:return 180;default:case 4:return 0;case 8:return 90}}const h=i.getDocumentPoint(Spot.Center,Point.a());let a=null;if(this.pointsCount>(o?6:2))a=n?this.getPoint(1):this.getPoint(this.pointsCount-2),o?a=this.pN(h,a.copy()):a=e;else{const c=Point.a();a=l.getDocumentPoint(Spot.Center,c),Point.o(c)}let f=0;return Math.abs(a.x-h.x)>Math.abs(a.y-h.y)?a.x>=h.x?f=0:f=180:a.y>=h.y?f=90:f=270,Point.o(h),f}computeEndSegmentLength(t,i,e,s){if(i!==null&&e.isSide()){const o=this.Nb(i);if(o!==null)return o.Ab}let n=NaN;return s?n=this.fromEndSegmentLength:n=this.toEndSegmentLength,i!==null&&isNaN(n)&&(s?n=i.fromEndSegmentLength:n=i.toEndSegmentLength),isNaN(n)&&(n=10),n}computeSpot(t,i){return i===void 0&&(i=null),t?this.rO(i||this.fromPort):this.lO(i||this.toPort)}rO(t){if(t===null)return Spot.Center;let i=this.fromSpot;return i.isDefault()&&(i=t.fromSpot),i===Spot.Default?Spot.None:i}lO(t){if(t===null)return Spot.Center;let i=this.toSpot;return i.isDefault()&&(i=t.toSpot),i===Spot.Default?Spot.None:i}Gd(t){return t===Spot.None||t.x===.5&&t.y===.5}Cb(t,i){return t.x===.5&&t.y===.5?t:Spot.Center}computeOtherPoint(t,i){if(this.computeAdjusting()!==0&&this.pointsCount>4)return this.computeMidPoint(new Point);{const e=this.nO(i,this);return e!==null?e.Hd:i.getDocumentPoint(Spot.Center)}}computeShortLength(t){if(t){let i=this.fromShortLength;if(isNaN(i)){const e=this.fromPort;e!==null&&(i=e.fromShortLength)}return isNaN(i)?0:i}else{let i=this.toShortLength;if(isNaN(i)){const e=this.toPort;e!==null&&(i=e.toShortLength)}return isNaN(i)?0:i}}Km(t,i,e,s,n,o){if(this.pickable===!1)return!1;i===void 0&&(i=null),e===void 0&&(e=null);let r=o;if(o===void 0&&(r=Transform.a(),r.Bi()),r.hf(this.O),this.containedInRect(t,r))return this.Y2(i,e,n),o===void 0&&Transform.o(r),!0;if(this.intersectsRect(t,r)){let l=!1;if(!this.gc){const h=this.D.h,a=h.length;for(let f=a;f--;){const c=h[f];if(!c.visible&&c!==this.locationObject)continue;const u=c.actualBounds,d=this.naturalBounds;if(u.x>d.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;const m=c,g=Transform.a();if(g.set(r),m instanceof Panel?l=m.Km(t,i,e,s,n,g):this.path===m?m instanceof Shape&&(l=m.TI(t,s,g)):l=m.lL(t,s,g),l){let p=m;i!==null&&(p=i(m)),p&&(e===null||e(p))&&n.add(p)}Transform.o(g)}}return o===void 0&&Transform.o(r),l||this.background!==null}return o===void 0&&Transform.o(r),!1}get isOrthogonal(){return(this.Ea&2)===2}static dN(t){return(t&2)===2}get isAvoiding(){return(this.Ea&4)===4}computeCurve(){if(this.ir===null){const t=this.fromPort,i=t!==null&&t===this.toPort,e=this.isOrthogonal;this.ir=i&&!e}return this.ir?9:this.curve}computeCorner(){if(this.curve===9)return 0;let t=this.corner;return(isNaN(t)||t<0)&&(t=10),t}findMidLabel(){const t=this.path,i=this.D.h,e=i.length;for(let n=0;n0?g-=c:g+=c;else{const p=-h/a;let y=Math.sqrt(c*c/(p*p+1));f<0&&(y=-y),m=(a<0?-1:1)*y+u,g=p*(m-u)+d}this.addPoint(r),this.addPointAt(m,g),this.addPoint(l)}else{this.addPoint(r),this.addPoint(l);const h=Rect.a();i.getDocumentBounds(h);const a=h.containsPoint(l);n.getDocumentBounds(h);const f=h.containsPoint(r);if(a||f){const c=i.getDocumentPoint(this.Cb(e,!0),new Point);this.setPoint(0,this.getLinkPointFromPoint(t,i,c,l,!0,c));const u=n.getDocumentPoint(this.Cb(o,!1),new Point);this.setPoint(1,this.getLinkPointFromPoint(s,n,u,r,!1,u))}Rect.o(h)}}eO(t,i,e,s,n,o){const r=this.getLinkPoint(t,i,e,!0,!1,s,n),l=this.getLinkPoint(s,n,o,!1,!1,t,i),h=l.x-r.x,a=l.y-r.y,f=this.computeCurviness();let c=0,u=0,d=r.x+h/3,m=r.y+a/3,g=d,p=m;Geo.p(a,0)?h>0?p-=f:p+=f:(c=-h/a,u=Math.sqrt(f*f/(c*c+1)),f<0&&(u=-u),g=(a<0?-1:1)*u+d,p=c*(g-d)+m),d=r.x+2*h/3,m=r.y+2*a/3;let y=d,x=m;Geo.p(a,0)?h>0?x-=f:x+=f:(y=(a<0?-1:1)*u+d,x=c*(y-d)+m),this.clearPoints(),this.addPoint(r),this.addPointAt(g,p),this.addPointAt(y,x),this.addPoint(l),this.setPoint(0,this.getLinkPoint(t,i,e,!0,!1,s,n)),this.setPoint(3,this.getLinkPoint(s,n,o,!1,!1,t,i))}adjustPoints(t,i,e,s){let n=this.computeAdjusting();if(this.isOrthogonal){if(n===18)return!1;n===19&&(n=17)}switch(n){case 18:return this.hO(t,i,e,s);case 19:return this.aO(t,i,e,s);case 17:return this.fO(t,i,e,s);default:return!1}}hO(t,i,e,s){const n=this.getPoint(t),o=this.getPoint(e);if(n.equalsApprox(i)&&o.equalsApprox(s))return!0;const r=n.x,l=n.y,h=o.x,a=o.y;let f=h-r,c=a-l;const u=Math.sqrt(f*f+c*c);if(Geo.q(u,0))return!0;let d=0;Geo.q(f,0)?c<0?d=-Math.PI/2:d=Math.PI/2:(d=Math.atan(c/Math.abs(f)),f<0&&(d=Math.PI-d));const m=i.x,g=i.y,p=s.x,y=s.y,x=p-m,k=y-g,b=Math.sqrt(x*x+k*k);let S=0;Geo.q(x,0)?k<0?S=-Math.PI/2:S=Math.PI/2:(S=Math.atan(k/Math.abs(x)),x<0&&(S=Math.PI-S));const M=b/u,A=S-d;this.setPoint(t,i);for(let C=t+1;C0&&(C=-C);const P=c+S*(d-c),N=u+S*(m-u);if(g!==0){const T=P+C/p,L=N-(T-P)/g;this.setPointAt(y,T,L)}else this.setPointAt(y,P,N+C)}return this.setPoint(e,s),!0}fO(t,i,e,s){if(this.isOrthogonal){let n=this.getPoint(t),o=this.getPoint(t+1),r=this.getPoint(t+2),l=o.x,h=o.y;const a=l,f=h;Geo.p(n.y,o.y)?Geo.p(o.x,r.x)?h=i.y:Geo.p(o.y,r.y)&&(l=i.x):Geo.p(n.x,o.x)&&(Geo.p(o.y,r.y)?l=i.x:Geo.p(o.x,r.x)&&(h=i.y)),this.setPointAt(t+1,l,h),n=this.getPoint(e),o=this.getPoint(e-1),r=this.getPoint(e-2);let c=o.x,u=o.y;const d=c,m=u;if(Geo.p(n.y,o.y)?Geo.p(o.x,r.x)?u=s.y:Geo.p(o.y,r.y)&&(c=s.x):Geo.p(n.x,o.x)&&(Geo.p(o.y,r.y)?c=s.x:Geo.p(o.x,r.x)&&(u=s.y)),this.setPointAt(e-1,c,u),this.VA())return this.setPointAt(t+1,a,f),this.setPointAt(e-1,d,m),!1}return this.setPoint(t,i),this.setPoint(e,s),!0}addOrthoPoints(t,i,e,s,n,o){i<0?i+=360:i>=360&&(i-=360),s<0?s+=360:s>=360&&(s-=360);const f=s;i>=315||i<45?i=0:45<=i&&i<135?i=90:135<=i&&i<225?i=180:i=270,s>=315||s<45?s=0:45<=s&&s<135?s=90:135<=s&&s<225?s=180:s=270;const c=t,u=e,d=n.actualBounds.copy(),m=o.actualBounds.copy();if(!d.isReal()||!m.isReal())return;d.inflate(Link.za,Link.za),m.inflate(Link.za,Link.za),d.unionPoint(t),m.unionPoint(e);const g=Point.a(),p=Point.a();i===0?u.x>c.x||s===270&&u.yc.x||s===90&&u.y>c.y&&m.right>c.x?(g.e(u.x,c.y),p.e(u.x,(c.y+u.y)/2),s===180?(g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1),p.x=g.x,p.y=u.y):s===270&&u.yc.y?(c.xm.bottom)?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):g.x=m.right,p.x=g.x,p.y=u.y):s===0&&c.xm.top&&c.yd.bottom)&&(s===180&&(m.containsPoint(c)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):u.yc.y&&(s===180||s===270)&&(g.y=this.computeMidOrthoPosition(c.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=d.left&&u.x<=c.x||c.x<=m.right&&c.x>=u.x?(s===90||s===270)&&(g.e(Math.max((c.x+u.x)/2,c.x),c.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yc.y&&m.leftc.y?(c.x>m.right?g.x=this.computeMidOrthoPosition(c.x,c.y,m.right,u.y,!1):c.x>m.left&&(s===270&&c.ym.bottom)?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):g.x=m.left,p.x=g.x,p.y=u.y):s===180&&c.x>m.right&&c.y>m.top&&c.yd.bottom)&&(s===0&&(m.containsPoint(c)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):u.yc.y&&(s===0||s===270)&&(g.y=this.computeMidOrthoPosition(c.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=c.x||c.x>=m.left&&c.x<=u.x?(s===90||s===270)&&(g.e(Math.min((c.x+u.x)/2,c.x),c.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yc.y||s===180&&u.xc.y||s===0&&u.x>c.x&&m.bottom>c.y?(g.e(c.x,u.y),p.e((c.x+u.x)/2,u.y),s===270?(g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0),p.x=u.x,p.y=g.y):s===180&&u.xc.x?(c.ym.right)?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):g.y=m.bottom,p.x=u.x,p.y=g.y):s===90&&c.ym.left&&c.xd.right)&&(s===270&&(m.containsPoint(c)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):u.xc.x&&(s===270||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,c.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=d.top&&u.y<=c.y||c.y<=m.bottom&&c.y>=u.y?(s===0||s===180)&&(g.e(c.x,Math.max((c.y+u.y)/2,c.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.xc.x&&m.top=c.x?(c.y>m.bottom?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,m.bottom,!0):c.y>m.top&&(s===180&&c.xm.right)?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):g.y=m.top,p.x=u.x,p.y=g.y):s===270&&c.y>m.bottom&&c.x>m.left&&c.xd.right)&&(s===90&&(m.containsPoint(c)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):u.xc.x&&(s===90||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,c.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=c.y||c.y>=m.top&&c.y<=u.y?(s===0||s===180)&&(g.e(c.x,Math.min((c.y+u.y)/2,c.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.x=3&&!Geo.q(this.smoothness,0))if(i===3){let f=this.getPoint(1);n=Math.min(r.x,f.x),o=Math.min(r.y,f.y),f=this.getPoint(2),n=Math.min(n,f.x),o=Math.min(o,f.y)}else if(this.isOrthogonal){for(let f=0;f=i&&(f=i-1);const c=this.getPoint(f);l.x=Math.min(c.x,l.x),l.y=Math.min(c.y,l.y)}n=l.x,o=l.y}else{for(let f=0;f=3&&!Geo.q(this.smoothness,0))if(i===3){const c=this.getPoint(1),u=c.x-n,d=c.y-o;let m=this.getPoint(2).copy();m.x-=n,m.y-=o,this.computeShortLength(!1)!==0&&(m=this.Dc(m,!1,l)),f.wr(u,d,u,d,m.x,m.y)}else if(this.isOrthogonal){const c=Point.H(n,o),u=Point.a();u.c(this.getPoint(1));const d=Point.H(n,o),m=Point.H(n,o);let g=this.getPoint(0),p=null;const y=this.smoothness/3;for(let S=1;S=i&&(c=i-1);const d=this.getPoint(c-1);let m=this.getPoint(c);c===i-1&&this.computeShortLength(!1)!==0&&(m=this.Dc(m.copy(),!1,Point.Lo)),f.wr(u.x-n,u.y-o,d.x-n,d.y-o,m.x-n,m.y-o)}else{const c=Point.a();c.c(this.getPoint(0));const u=Point.a();u.c(c);const d=this.computeCorner();let m=1,g=0;for(;m1);let p=this.getPoint(m);if(m>=i-1){if(!c.equals(p))this.computeShortLength(!1)!==0&&(p=this.Dc(p.copy(),!1,Point.Lo)),this.Dn(f,-n,-o,c,p,e);else if(g===0)for(m=1;mr?c>a?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):c>a?(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.q(r,h)&&Geo.q(a,c)&&(a>l?f>h?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):f>h?(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.q(r,h)&&Geo.q(h,f)||Geo.q(l,a)&&Geo.q(a,c)){const m=.5*(r+f),g=.5*(l+c);n.x=m,n.y=g,o.x=m,o.y=g}}Dc(t,i,e){const s=this.pointsCount;if(s<2)return t;if(i){const n=this.getPoint(1),o=n.x-e.x,r=n.y-e.y,l=this.Lb(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!0);a>h&&(a=h);const f=a*(o-t.x)/l,c=a*(r-t.y)/l;t.x+=f,t.y+=c}else{const n=this.getPoint(s-2),o=n.x-e.x,r=n.y-e.y,l=this.Lb(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!1);a>h&&(a=h);const f=a*(t.x-o)/l,c=a*(t.y-r)/l;t.x-=f,t.y-=c}return t}yN(t,i,e){const s=this.pointsCount;let n=t;for(;Geo.q(t.x,n.x)&&Geo.q(t.y,n.y);){if(i>=s)return s-1;n=this.getPoint(i++)}if(!Geo.q(t.x,n.x)&&!Geo.q(t.y,n.y))return i-1;let o=n;for(;Geo.q(t.x,n.x)&&Geo.q(n.x,o.x)&&(!e||(t.y>=n.y?n.y>=o.y:n.y<=o.y))||Geo.q(t.y,n.y)&&Geo.q(n.y,o.y)&&(!e||(t.x>=n.x?n.x>=o.x:n.x<=o.x));){if(i>=s)return s-1;o=this.getPoint(i++)}return i-2}dO(t,i,e,s,n,o,r,l,h,a){if(Geo.p(s.y,n.y)&&Geo.p(n.x,o.x)){let f=Math.min(h,Math.abs(n.x-l.x)/2);const c=Math.min(f,Math.abs(o.y-n.y)/2);if(f=c,Geo.p(f,0)){this.Dn(t,i,e,s,n,a),r.c(n);return}let u=n.x;const d=n.y,m=u;let g=d;n.x>s.x?(u=n.x-f,o.y>n.y?g=n.y+c:g=n.y-c):(u=n.x+f,o.y>n.y?g=n.y+c:g=n.y-c);const p=Point.H(u,d);this.Dn(t,i,e,s,p,a),Point.o(p),t.Fw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else if(Geo.p(s.x,n.x)&&Geo.p(n.y,o.y)){let f=Math.min(h,Math.abs(n.y-l.y)/2);const c=Math.min(f,Math.abs(o.x-n.x)/2);if(f=c,Geo.p(c,0)){this.Dn(t,i,e,s,n,a),r.c(n);return}const u=n.x;let d=n.y,m=u;const g=d;n.y>s.y?(d=n.y-f,o.x>n.x?m=n.x+c:m=n.x-c):(d=n.y+f,o.x>n.x?m=n.x+c:m=n.x-c);const p=Point.H(u,d);this.Dn(t,i,e,s,p,a),Point.o(p),t.Fw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else this.Dn(t,i,e,s,n,a),r.c(n)}computeJumpLength(){return 10}Dn(t,i,e,s,n,o){if(o||!this.Xa())t.yr(n.x+i,n.y+e);else{const r=this.computeJumpLength(),l=r/2,h=[];let a=0;this.isVisible()&&(a=this.gO(s,n,h));let f=s.x,c=s.y;if(a>0){if(Geo.p(s.y,n.y))if(s.x=0;){const d=Math.min(s.x,Math.max(h[u--]+l,n.x+r));t.yr(d+i,n.y+e),f=d+i,c=n.y+e;let m=Math.max(d-r,n.x);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.x);else break}const g=n.y-r+e,p=m+i,y=n.y+e;this.curve===10?t.wu(p,y,!1,!1):t.wr(f,g,p,g,p,y),f=p,c=y}}else if(Geo.p(s.x,n.x))if(s.y=0;){const d=Math.min(s.y,Math.max(h[u--]+l,n.y+r));t.yr(n.x+i,d+e),f=n.x+i,c=d+e;let m=Math.max(d-r,n.y);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.y);else break}const g=n.x-r+i,p=n.x+i,y=m+e;this.curve===10?t.wu(p,y,!1,!1):t.wr(g,c,g,y,p,y),f=p,c=y}}}t.yr(n.x+i,n.y+e)}}gO(t,i,e){const s=this.diagram;if(s===null||t.equals(i))return 0;const n=s.layers;for(;n.next();){const o=n.value;if(o!==null&&o.visible){const r=o.HM(),l=r.length;for(let h=0;h0&&e.sort((u,d)=>u-d),e.length;if(!a.isVisible()||!a.Xa())continue;const f=a.routeBounds;if(!f.isReal()||!this.routeBounds.intersectsRect(f)||this.usesSamePort(a))continue;const c=a.path;c!==null&&c.isVisibleObject()&&this.mO(t,i,e,a)}}}return e.length>0&&e.sort((o,r)=>o-r),e.length}mO(t,i,e,s){const n=Geo.p(t.y,i.y),o=s.pointsCount;let r=s.getPoint(0);const l=Point.a();for(let h=1;hr.x&&f.x>=a.x||a.xr.y&&f.y>=a.y||a.yf&&Math.min(a,c)o&&!Geo.p(a,c))return n.x=o,n.y=f,!0}else if(Geo.p(r,h)&&Geo.p(a,c)&&Math.min(o,l)a&&Math.min(f,u)r&&!Geo.p(f,u))return n.x=a,n.y=r,!0;return n.x=0,n.y=0,!1}get firstPickIndex(){return this.pointsCount<=2?0:this.isOrthogonal||!this.Gd(this.computeSpot(!0))?1:0}get lastPickIndex(){const t=this.pointsCount;return t===0?0:t<=2?t-1:this.isOrthogonal||!this.Gd(this.computeSpot(!1))?t-2:t-1}Xa(){const t=this.curve;return t===11||t===10}Pb(t){if(t||this.Xa()){const i=this.diagram;i!==null&&!i.animationManager.isTicking&&!i.th.has(this)&&(this.Lc.width!==0||this.Lc.height!==0)&&i.th.set(this,this.Lc.copy())}}invalidateOtherJumpOvers(t){const i=this.layer;if(i===null||!i.visible||i.isTemporary)return;const e=i.diagram;if(e===null||e.animationManager.isTicking)return;let s=!1;const n=e.layers;for(;n.next();){const o=n.value;if(o.visible){if(o===i){s=!0;let r=!1;const l=o.HM(),h=l.length;for(let a=0;a0&&e>0){const s=this.getPoint(0),n=t.getPoint(0);if(s.equalsApprox(n))return!0;const o=this.getPoint(i-1),r=t.getPoint(e-1);if(o.equalsApprox(r)||s.equalsApprox(r)||o.equalsApprox(n))return!0}else if(this.fromNode===t.fromNode||this.toNode===t.toNode||this.fromNode===t.toNode||this.toNode===t.fromNode)return!0;return!1}isVisible(){if(!super.isVisible())return!1;const t=this.containingGroup;let i=!0;const e=this.diagram;e!==null&&(i=e.isTreePathToChildren);const s=this.fromNode;if(s!==null){if(this.isTreeLink&&i&&!s.isTreeExpanded)return!1;if(s===t)return!0;let o=s;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=s.findVisibleNode();if(r===null||r===t)return!1}const n=this.toNode;if(n!==null){if(this.isTreeLink&&!i&&!n.isTreeExpanded)return!1;if(n===t)return!0;let o=n;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=n.findVisibleNode();if(r===null||r===t)return!1}return!0}Ki(t){if(super.Ki(t),t&&this.Pb(!1),this.er!==null&&this.er.Vd(),this.$s!==null){const e=this.$s.iterator;for(;e.next();)e.value.Ki(t)}}get adjusting(){return this.Ac}set adjusting(t){const i=this.Ac;i!==t&&(Debug&&t!==0&&t!==17&&t!==18&&t!==19&&Util.n("Link.adjusting can only be set to None, End, Scale, or Stretch, not: "+t),this.Ac=t,this.i("adjusting",i,t))}computeAdjusting(){return this.isAvoiding&&this.diagram!==null&&this.diagram.animationManager.defaultAnimation.isAnimating?17:this.Ac}get corner(){return this.Xd}set corner(t){const i=this.Xd;i!==t&&(Debug&&Util.t(t,"number",Link,"corner"),this.Xd=t,this.re(),this.i("corner",i,t))}get curve(){return this.Yd}set curve(t){const i=this.Yd;i!==t&&(Debug&&t!==0&&t!==9&&t!==10&&t!==11&&Util.n("Link.curve can only be set to None, Bezier, JumpGap, or JumpOver, not: "+t),this.Yd=t,this.invalidateRoute(),this.re(),this.Pb(i===10||i===11||t===10||t===11),this.i("curve",i,t))}get curviness(){return this.Kd}set curviness(t){const i=this.Kd;i!==t&&(Debug&&Util.t(t,"number",Link,"curviness"),this.Kd=t,this.invalidateRoute(),this.re(),this.i("curviness",i,t))}get routing(){return this.Ea}set routing(t){const i=this.Ea;i!==t&&(Debug&&t!==1&&t!==2&&t!==6&&t!==7&&Util.n("Link.routing can only be set to Normal, Orthogonal, AvoidsNodes, not: "+t),this.Ea=t,this.isAvoiding&&this.diagram!==null&&(this.diagram.$m=!0),this.ir=null,this.invalidateRoute(),this.Pb(Link.dN(i)||Link.dN(t)),this.i("routing",i,t))}get smoothness(){return this.Ud}set smoothness(t){const i=this.Ud;i!==t&&(Debug&&Util.t(t,"number",Link,"smoothness"),this.Ud=t,this.re(),this.i("smoothness",i,t))}Py(){const t=this.go;if(t===null)return;const i=this.po;if(i===null||!isNaN(this.curviness))return;const e=this.mo,s=this.yo;let n=null,o=null;const r=t.ni.h,l=r.length;for(let h=0;h=0&&(Util.rf(t.Qs,i),t.Vd())}}Dl(){return!0}get key(){const t=this.diagram;if(!(t===null||!t.model.Oa()))return t.model.getKeyForLinkData(this.data)}}class LinkBundle{Ko;Xs;uy;oN;wb;rN;Qs;constructor(t,i,e,s){GSet.vi(this),this.Ko=!1,this.Xs=!1,this.uy=t,this.oN=i,this.wb=e,this.rN=s,this.Qs=[]}Vd(){if(!this.Ko){const t=this.Qs;if(t.length>0){const i=t[0].diagram;i!==null&&(i.mP.add(this),this.Xs=i.undoManager.isUndoingRedoing)}}this.Ko=!0}LP(){if(this.Ko){this.Ko=!1;const t=this.Qs;if(t.length>0){const i=t[0],e=i.diagram,s=e===null||e.Yh&&!this.Xs;this.Xs=!1,i.arrangeBundledLinks(t,s),t.length===1&&(i.er=null,t.length=0)}t.length===0&&(this.uy.nT(this),this.wb.nT(this))}}}class PositionArray{ae;fe;Ya;Ka;bi;ki;Yt;Sh;Mh;ca;YP;Ko;Cy;$f;KP;UP;constructor(t){GSet.vi(this),this.ca=null,this.YP=null,this.Ko=!0,this.Cy=!1,this.ae=1,this.fe=1,this.Ya=-1,this.Ka=-1,this.bi=t.width,this.ki=t.height,this.Yt=null,this.Sh=0,this.Mh=0,this.$f=11,this.KP=this.$f*2,this.UP=this.$f*2}static _s=0;static Ua=1;static qd=999999;static wN=PositionArray.qd+1;static xN=PositionArray.qd+2;I1(t){if(t.width<=0||t.height<=0)return;const i=t.x,e=t.y,s=t.x+t.width,n=t.y+t.height;this.ae=Math.floor((i-this.bi)/this.bi)*this.bi,this.fe=Math.floor((e-this.ki)/this.ki)*this.ki,this.Ya=Math.ceil((s+2*this.bi)/this.bi)*this.bi,this.Ka=Math.ceil((n+2*this.ki)/this.ki)*this.ki;const o=1+(Math.ceil((this.Ya-this.ae)/this.bi)|0),r=1+(Math.ceil((this.Ka-this.fe)/this.ki)|0);if(this.Yt===null||this.Sh0&&t!==this.bi&&(this.bi=t,this.I1(this.bounds))}get cellHeight(){return this.ki}set cellHeight(t){t>0&&t!==this.ki&&(this.ki=t,this.I1(this.bounds))}jd(t,i){return this.ae<=t&&t<=this.Ya&&this.fe<=i&&i<=this.Ka}wo(t,i){if(!this.jd(t,i))return PositionArray.wN;t-=this.ae,t/=this.bi,i-=this.fe,i/=this.ki;const e=t|0,s=i|0;return this.Yt[e][s]}CR(t,i,e,s){if(!this.jd(t,i))return;const n=(t-this.ae)/this.bi|0,o=(i-this.fe)/this.ki|0,r=(t+e-this.ae)/this.bi|0,l=(i+s-this.fe)/this.ki|0,h=Math.min(r,this.Sh),a=Math.min(l,this.Mh);for(let f=n;f<=h;f++){const c=this.Yt[f];if(c.fill)c.fill(PositionArray._s,o,a+1);else for(let u=o;u<=a;u++)c[u]=PositionArray._s}}yO(t){if(this.Yt!==null)for(let i=0;i<=this.Sh;i++){const e=this.Yt[i];if(e.fill)e.fill(t);else for(let s=0;s<=this.Mh;s++)e[s]=t}}vA(){if(this.Yt!==null)for(let t=0;t<=this.Sh;t++){const i=this.Yt[t];for(let e=0;e<=this.Mh;e++)i[e]>=PositionArray.Ua&&(i[e]=PositionArray.wN)}}wO(t,i){return this.wo(t,i)===PositionArray._s}isUnoccupied(t,i,e,s){if(t>this.Ya||t+ethis.Ka||i+sthis.Ya||ithis.Ka||ethis.Ka||ithis.Ya||e=PositionArray.Ua&&h=a)break;this.Yt[t][i]=h,h+=1,s?i+=e:t+=e}return s?i:t}xo(t,i,e,s,n,o,r,l){if(to||il)return;const h=this.xO(t,i,e,s,n,o,r,l);if(s)if(e>0)for(let a=i+e;ah;a+=e)this.xo(t,a,1,!s,n,o,r,l),this.xo(t,a,-1,!s,n,o,r,l);else if(e>0)for(let a=t+e;ah;a+=e)this.xo(a,i,1,!s,n,o,r,l),this.xo(a,i,-1,!s,n,o,r,l)}Tb(t,i,e,s,n,o,r,l,h,a){let f=t|0,c=i|0,u=PositionArray._s,d=PositionArray.Ua;for(this.Yt[f][c]=d;u===PositionArray._s&&f>r&&fh&&cr&&fh&&c=0;I-=2){F=L[I+2],R=L[I+3];const O=L[I],B=L[I+1];for(;O>F?F++:OR?R++:Bs)d--;else break;else if(m>n)m--;else break;const g=f[d][m];if(g===0||g===PositionArray.xN)break;c=d,u=m}for(;;){let d=e,m=c,g=u;e===0?gn&&(d=270,g--):e===90?ms&&(d=180,m--):e===180?gn&&(d=270,g--):ms&&(d=180,m--);const p=f[m][g];if(d!==e&&p!==0&&p!==PositionArray.xN){if(o.push(c),o.push(u),this.pT(c,u,d,s,n,o))return!0;o.pop(),o.pop()}if(f[c][u]=PositionArray.xN,e===0){if(c===t)return!1;c--}else if(e===90){if(u===i)return!1;u--}else if(e===180){if(c===t)return!1;c++}else{if(u===i)return!1;u++}}}}class Knot{ye;sr;cs;Wd;constructor(){GSet.vi(this),this.ye=null,this.sr=null,this.cs=[],this.Wd=!1}toString(){const t=this.cs;let i=this.ye.toString()+" "+t.length.toString()+":";for(let e=0;e180?270:90;case 6:return o>90&&o<=270?180:0}const r=Math.atan2(t.height,t.width)*180/Math.PI;switch(n){case 3:return o>r&&o<=180+r?180:270;case 5:return o>180-r&&o<=360-r?270:0;case 12:return o>r&&o<=180+r?90:0;case 10:return o>180-r&&o<=360-r?180:90;case 7:return o>90&&o<=180+r?180:o>180+r&&o<=360-r?270:0;case 13:return o>180&&o<=360-r?270:o>r&&o<=180?90:0;case 14:return o>r&&o<=180-r?90:o>180-r&&o<=270?180:0;case 11:return o>180-r&&o<=180+r?180:o>180+r?270:90}return s&&n!==15&&(o-=15,o<0&&(o+=360)),o>r&&o<180-r?90:o>=180-r&&o<=180+r?180:o>180+r&&o<360-r?270:0}Vd(){this.cs.length=0}dT(t){let i=this.cs;i.length===0&&(this.kO(),i=this.cs);for(let e=0;e=360&&(M-=360);const A=this.bO(h,y,M,g.isOrthogonal);let C=0;A===0?(C=4,M>180&&(M-=360)):A===90?(C=8,M>270&&(M-=360)):A===180?C=2:(C=1,M<90&&(M+=360));let P=this.cs[o];P===void 0?(P=new LinkInfo(g,M,C),this.cs[o]=P):(P.$e=g,P.jt=M,P.be=C),P.Fb.set(S),o++}Point.o(a),this.SO();const u=this.cs.length;let d=-1,m=0;for(o=0;o=0;o--){const g=this.cs[o];g!==void 0&&(g.be!==d&&(d=g.be,m=g.vd+1),g.Tc=m)}this.MO(this.cs),this.PO(this.cs),this.Wd=t,Rect.o(h)}return this.cs}NO(t,i){return t===i?0:t===null?-1:i===null?1:t.bei.be?1:t.jti.jt?1:0}SO(){this.cs.sort(Knot.prototype.NO)}MO(t){const i=this.sr,e=this.ye.portSpreading,s=Point.a(),n=Point.a(),o=Point.a(),r=Point.a();i.getDocumentPoint(Spot.TopLeft,s),i.getDocumentPoint(Spot.TopRight,n),i.getDocumentPoint(Spot.BottomRight,o),i.getDocumentPoint(Spot.BottomLeft,r);let l=0,h=0,a=0,f=0;if(e===2)for(let x=0;xMath.abs(p)?(d=Math.abs(p)/a,a=Math.abs(p)):d=1;break;case 2:f>Math.abs(y)?(d=Math.abs(y)/f,f=Math.abs(y)):d=1;break;case 1:l>Math.abs(p)?(d=Math.abs(p)/l,l=Math.abs(p)):d=1;break;default:case 4:h>Math.abs(y)?(d=Math.abs(y)/h,h=Math.abs(y)):d=1;break}u=0}const b=k.Hd;if(e===2){let S=k.$e.computeThickness();switch(S*=d,b.set(m),c){case 8:b.x=m.x+p/2+a/2-u-S/2;break;case 2:b.y=m.y+y/2+f/2-u-S/2;break;case 1:b.x=m.x+p/2-l/2+u+S/2;break;default:case 4:b.y=m.y+y/2-h/2+u+S/2;break}u+=S}else{let S=.5;e===1&&(S=(k.vd+1)/(k.Tc+1)),b.x=m.x+p*S,b.y=m.y+y*S}}Point.o(s),Point.o(n),Point.o(o),Point.o(r)}PO(t){for(let i=0;ie instanceof Placeholder);i instanceof Placeholder?t.Et=i:t.Et=null,this.oe!==null?(t.oe=this.oe.copy(),t.oe.group=t):(t.oe!==null&&(t.oe.group=null),t.oe=null),this.hi!==null&&(t.hi=this.hi.copy())}Ho(t){super.Ho(t);const i=t.findSubGraphParts(),e=t.memberParts;for(;e.next();){const s=e.value;if(s.u(),s.invalidateLayout(8),s.clearAdornments(),s instanceof Node)s.invalidateConnectedLinks(i);else if(s instanceof Link){const n=s.labelNodes;for(;n.next();)n.value.invalidateConnectedLinks(i)}}}ic(t,i,e,s,n,o,r){if(t===3&&i==="elements"){if(n instanceof Placeholder)this.Et===null?this.Et=n:this.Et!==n&&Util.n("Cannot insert a second Placeholder into the visual tree of a Group.");else if(n instanceof Panel){const l=n.findInVisualTree(h=>h instanceof Placeholder);l instanceof Placeholder&&(this.Et===null?this.Et=l:this.Et!==l&&Util.n("Cannot insert a second Placeholder into the visual tree of a Group."))}}else t===4&&i==="elements"&&this.Et!==null&&(s===this.Et?this.Et=null:s instanceof Panel&&this.Et.isContainedBy(s)&&(this.Et=null));super.ic(t,i,e,s,n,o,r)}ad(t,i){if(super.ad(t,i),this.isClipping&&this.type!==Panel.Spot&&this.isSubGraphExpanded){let e=this.resizeObject;e instanceof Panel&&(e=e.findMainElement()),this.hi===null&&(this.hi=new Rect),e.getDocumentBounds(this.hi),e instanceof Shape&&this.hi.inflate(-e.strokeWidth,-e.strokeWidth)}}uh(t,i,e,s){this.hasPlaceholder()&&(this.tr=this.placeholder),super.uh(t,i,e,s)}ensureBounds(){this.isSubGraphExpanded&&this.memberParts.each(i=>{i.ensureBounds()}),super.ensureBounds()}$r(){if(!super.$r())return!1;const t=this.memberParts;for(;t.next();){const i=t.value;if(i instanceof Node){if(!i.isVisible())continue;if(i.rs())return!1}else if(i instanceof Link){if(!i.isVisible())continue;if(i.rs()&&i.fromNode!==this&&i.toNode!==this)return!1}}return!0}hasPlaceholder(){return this.Et!==null&&this.Et.isVisibleObject()&&this.isSubGraphExpanded}get placeholder(){return this.Et}get computesBoundsAfterDrag(){return(this.z&2048)!==0}set computesBoundsAfterDrag(t){const i=(this.z&2048)!==0;i!==t&&(Util.t(t,"boolean",Group,"computesBoundsAfterDrag"),this.z=this.z^2048,this.i("computesBoundsAfterDrag",i,t))}get computesBoundsIncludingLinks(){return(this.z&4096)!==0}set computesBoundsIncludingLinks(t){Util.t(t,"boolean",Group,"computesBoundsIncludingLinks");const i=(this.z&4096)!==0;i!==t&&(this.z=this.z^4096,this.i("computesBoundsIncludingLinks",i,t))}get computesBoundsIncludingLocation(){return(this.z&8192)!==0}set computesBoundsIncludingLocation(t){Util.t(t,"boolean",Group,"computesBoundsIncludingLocation");const i=(this.z&8192)!==0;i!==t&&(this.z=this.z^8192,this.i("computesBoundsIncludingLocation",i,t))}get handlesDragDropForMembers(){return(this.z&16384)!==0}set handlesDragDropForMembers(t){Util.t(t,"boolean",Group,"handlesDragDropForMembers");const i=(this.z&16384)!==0;i!==t&&(this.z=this.z^16384,this.i("handlesDragDropForMembers",i,t))}get avoidableMembers(){return(this.z&131072)!==0}set avoidableMembers(t){Util.t(t,"boolean",Group,"avoidableMembers");const i=(this.z&131072)!==0;i!==t&&(this.z=this.z^131072,this.i("avoidableMembers",i,t))}get memberParts(){return this.Jd.iterator}iN(t){if(this.Jd.add(t)){t instanceof Group&&this.fa.add(t);const e=this.memberAdded;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.j,n.j=!0),e(this,t),n!==null&&(n.j=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ki(!1)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.Et;i===null&&(i=this),i.u()}tN(t){if(this.Jd.delete(t)){t instanceof Group&&this.fa.delete(t);const e=this.memberRemoved;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.j,n.j=!0),e(this,t),n!==null&&(n.j=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ki(!0)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.Et;i===null&&(i=this),i.u()}Jf(){if(this.Jd.count>0){const t=this.diagram;if(t!==null){const e=this.Jd.copy().iterator;for(;e.next();){const s=e.value;t.remove(s)}}}super.Jf()}get layout(){return this.oe}set layout(t){const i=this.oe;if(i!==t){t!==null&&(Util.s(t,Layout,Group,"layout"),t.diagram!==null&&t.diagram.layout===t&&Util.n("A layout cannot be both the Diagram.layout and a Group.layout: "+t)),i!==null&&(i.diagram=null,i.group=null),this.oe=t;const e=this.diagram;t!==null&&(t.diagram=e,t.group=this),e!==null&&(e.Wr=!0),this.i("layout",i,t),e!==null&&e.requestUpdate()}}get memberAdded(){return this.bt!==null?this.bt.xy:null}set memberAdded(t){const i=this.memberAdded;i!==t&&(t!==null&&Util.t(t,"function",Group,"memberAdded"),this.ml(),this.bt.xy=t,this.i("memberAdded",i,t))}get memberRemoved(){return this.bt!==null?this.bt.by:null}set memberRemoved(t){const i=this.memberRemoved;i!==t&&(t!==null&&Util.t(t,"function",Group,"memberRemoved"),this.ml(),this.bt.by=t,this.i("memberRemoved",i,t))}get memberValidation(){return this.bt!==null?this.bt.rh:null}set memberValidation(t){const i=this.memberValidation;i!==t&&(t!==null&&Util.t(t,"function",Group,"memberValidation"),this.ml(),this.bt.rh=t,this.i("memberValidation",i,t))}canAddMembers(t){const i=this.diagram;if(i===null)return!1;const e=i.commandHandler,n=e.c2(t).iterator;for(;n.next();){const o=n.value;if(!e.isValidMember(this,o))return!1}return!0}addMembers(t,i){const e=this.diagram;if(e===null)return!1;const s=e.commandHandler,n=s.c2(t);let o=!0;const r=n.iterator;for(;r.next();){const l=r.value;!i||s.isValidMember(this,l)?l.containingGroup=this:o=!1}return o}get ungroupable(){return(this.z&256)!==0}set ungroupable(t){const i=(this.z&256)!==0;i!==t&&(Util.t(t,"boolean",Group,"ungroupable"),this.z=this.z^256,this.i("ungroupable",i,t))}canUngroup(){if(!this.ungroupable)return!1;const t=this.layer;if(t===null||!t.allowUngroup)return!1;const i=t.diagram;return!(i!==null&&!i.allowUngroup)}invalidateConnectedLinks(t){const i=this.AO();if(super.invalidateConnectedLinks(t),i)return;this.TA(!0);const e=this.findExternalLinksConnected();for(;e.next();){const s=e.value;if(t!==void 0&&t.has(s))continue;const n=s.fromNode;if(n!==null&&n!==this&&n.isMemberOf(this)&&!n.isVisible())n.xe(s.fromPort),n.xe(s.toPort),s.invalidateRoute();else{const o=s.toNode;o!==null&&o!==this&&o.isMemberOf(this)&&!o.isVisible()&&(o.xe(s.fromPort),o.xe(s.toPort),s.invalidateRoute())}}}findExternalLinksConnected(){const t=this.diagram!==null&&this.diagram.kP;if(t&&this.b0!==null)return this.b0.iterator;const i=this.findSubGraphParts();i.add(this);const e=new GSet,s=i.iterator;for(;s.next();){const n=s.value;if(!(n instanceof Node))continue;const o=n.linksConnected;for(;o.next();){const r=o.value;i.has(r)||e.add(r)}}return t&&(this.b0=e),e.iterator}findExternalNodesConnected(){const t=this.findSubGraphParts();t.add(this);const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;if(!(s instanceof Node))continue;const n=s.linksConnected;for(;n.next();){const o=n.value,r=o.fromNode;r!==null&&(!t.has(r)||r===this)&&i.add(r);const l=o.toNode;l!==null&&(!t.has(l)||l===this)&&i.add(l)}}return i.iterator}yE(){function t(e,s){e!==null&&(s.add(e),t(e.containingGroup,s))}const i=new GSet;return t(this,i),i}findSubGraphParts(){const t=new GSet;return Part.lh(t,this,!0,0,!0),t.delete(this),t}Ki(t){super.Ki(t);const i=this.memberParts;for(;i.next();)i.value.Ki(t)}collapseSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.yT(i,t,this),t.isCollapsingExpanding=!1}yT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ki(!1),n instanceof Group&&n.isSubGraphExpanded&&(n.wasSubGraphExpanded=n.isSubGraphExpanded,n.yT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t),i.Of(n,e);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!1}expandSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.wT(i,t,this),t.isCollapsingExpanding=!1}wT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ki(!0),n instanceof Group&&n.wasSubGraphExpanded&&(n.wasSubGraphExpanded=!1,n.wT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!0}get isSubGraphExpanded(){return(this.z&512)!==0}set isSubGraphExpanded(t){const i=(this.z&512)!==0;if(i!==t){Util.t(t,"boolean",Group,"isSubGraphExpanded"),this.z=this.z^512;const e=this.diagram;this.i("isSubGraphExpanded",i,t);const s=this.subGraphExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.j,e.j=!0),s(this),e!==null&&(e.j=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.Et!==null&&this.Et.u(),this.memberParts.each(n=>n.updateAdornments());return}t?this.expandSubGraph():this.collapseSubGraph()}}get wasSubGraphExpanded(){return(this.z&1024)!==0}set wasSubGraphExpanded(t){const i=(this.z&1024)!==0;i!==t&&(Util.t(t,"boolean",Group,"wasSubGraphExpanded"),this.z=this.z^1024,this.i("wasSubGraphExpanded",i,t))}get subGraphExpandedChanged(){return this.bt!==null?this.bt.ky:null}set subGraphExpandedChanged(t){const i=this.subGraphExpandedChanged;i!==t&&(t!==null&&Util.t(t,"function",Group,"subGraphExpandedChanged"),this.ml(),this.bt.ky=t,this.i("subGraphExpandedChanged",i,t))}move(t,i){i===void 0&&(i=!1);const e=i?this.location:this.position,s=e.x,n=e.y,o=t.x,r=t.y;if((s===o||isNaN(s)&&isNaN(o))&&(n===r||isNaN(n)&&isNaN(r)))return;const l=o-(isNaN(s)?0:s),h=r-(isNaN(n)?0:n),a=Point.a();super.move(t,i);const f=new GSet,u=this.findSubGraphParts().iterator;for(;u.next();){const d=u.value;d instanceof Link&&(d.suspendsRouting&&f.add(d),!(!d.Te&&(d.fromNode===this||d.toNode===this))&&(d.suspendsRouting=!0))}for(u.reset();u.next();){const d=u.value;if(d.Dl()||d instanceof Node&&d.isLinkLabel)continue;const m=d.position,g=d.location;m.isReal()?(a.x=m.x+l,a.y=m.y+h,d.position=a):g.isReal()&&(a.x=g.x+l,a.y=g.y+h,d.location=a)}for(u.reset();u.next();){const d=u.value;if(!(d instanceof Link)||(d.suspendsRouting=f.has(d),!d.Te&&(d.fromNode===this||d.toNode===this)))continue;const m=d.position;a.x=m.x+l,a.y=m.y+h,a.isReal()?d.move(a):d.invalidateRoute()}Point.o(a)}AO(){return(this.z&65536)!==0}TA(t){(this.z&65536)!==0!==t&&(this.z=this.z^65536)}get tl(){return(this.z&32768)!==0}set tl(t){(this.z&32768)!==0!==t&&(this.z=this.z^32768)}}class Placeholder extends GraphObject{ii;Zd;constructor(t){super(),this.ii=Margin.qg,this.Zd=new Rect(NaN,NaN,NaN,NaN),t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.ii=this.ii.L(),t.Zd=this.Zd.copy()}ch(t){if(this.background===null)return!1;const i=this.naturalBounds;return Rect.contains(0,0,i.width,i.height,t.x,t.y)}ld(t,i,e,s){const n=this.part;if((n===null||!(n instanceof Group)&&!(n instanceof Adornment))&&Util.n("Placeholder is not inside a Group or Adornment."),n instanceof Group){const o=this.computeBorder(this.Zd),r=this.minSize,l=isFinite(r.width)?Math.max(r.width,o.width):o.width,h=isFinite(r.height)?Math.max(r.height,o.height):o.height,a=this.Hi;a.Kn(l||0,h||0),this.no(0,0,a.width,a.height);const f=n.memberParts;let c=!1;for(;f.next();)if(f.value.isVisible()){c=!0;break}const u=n.diagram;if(c&&u!==null&&!u.animationManager.OM(n)&&!isNaN(o.x)&&!isNaN(o.y)){const d=Point.a();d.setRectSpot(o,n.locationSpot),n.location=d,Point.o(d)}}else{const o=n,r=this.Hi,l=this.ii,h=l.left+l.right,a=l.top+l.bottom,f=o.adornedObject,c=f.getDocumentAngle();o.angle=c;let u=0;f instanceof Shape&&(u=f.strokeWidth);const d=f.getDocumentScale(),m=f.naturalBounds,g=(m.width+u)*d,p=(m.height+u)*d;if(o.type!==Panel.Link){const y=o.category==="Selection"?Spot.TopLeft:o.locationSpot,x=f.getDocumentPoint(y,Point.a());o.location=x,Point.o(x)}if(!isNaN(g)&&!isNaN(p))r.Kn(g+h||0,p+a||0),this.no(-l.left,-l.top,r.width,r.height);else{const y=f.getDocumentPoint(Spot.TopLeft,Point.a()),x=Rect.H(y.x,y.y,0,0);x.unionPoint(f.getDocumentPoint(Spot.BottomRight,y)),x.unionPoint(f.getDocumentPoint(Spot.TopRight,y)),x.unionPoint(f.getDocumentPoint(Spot.BottomLeft,y)),r.Kn(x.width+h||0,x.height+a||0),this.no(-l.left,-l.top,r.width,r.height),Point.o(y),Rect.o(x)}}}uh(t,i,e,s){this.actualBounds.e(t,i,e,s)}computeBorder(t){const i=this.part,e=i.diagram,s=e===null||!e.animationManager.isAnimating;if(e!==null&&i instanceof Group&&!i.layer.isTemporary&&i.computesBoundsAfterDrag&&this.Zd.isReal()){const l=e.toolManager.findTool("Dragging");if(l===e.currentTool){const h=l.computeBorder(i,this.Zd,t);if(h!==null)return h}}const n=Rect.a(),o=this.computeMemberBounds(n),r=this.ii;return i instanceof Group&&!i.isSubGraphExpanded?t.e(o.x-r.left,o.y-r.top,0,0):t.e(o.x-r.left,o.y-r.top,Math.max(o.width+r.left+r.right,0),Math.max(o.height+r.top+r.bottom,0)),Rect.o(n),s&&i instanceof Group&&i.computesBoundsIncludingLocation&&i.location.isReal()&&t.unionPoint(i.location),t}computeMemberBounds(t){if(!(this.part instanceof Group))return t.e(0,0,0,0),t;const i=this.part;let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=i.memberParts;for(;r.next();){const l=r.value;if(!l.isVisible()||l instanceof Link&&(!i.computesBoundsIncludingLinks||l.Xo()||l.fromNode===i||l.toNode===i))continue;const h=l.actualBounds;h.leftn&&(n=h.right),h.bottom>o&&(o=h.bottom)}if(!isFinite(e)||!isFinite(s)){const l=i.location;t.e(l.x,l.y,0,0)}else t.e(e,s,n-e,o-s);return t}get padding(){return this.ii}set padding(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Placeholder,"padding");const i=this.ii;i.equals(t)||(t=t.L(),this.ii=t,this.i("padding",i,t),this.u())}}class Layout{b;ca;$d;Cr;Qd;_d;Vo;pl;tg;ig;bo;constructor(t){GSet.vi(this),this.b=null,this.ca=null,this.$d=!0,this.Cr=!0,this.Qd=!1,this._d=new Point(0,0).w(),this.Vo=!0,this.pl=null,this.tg=null,this.ig=!1,this.bo=null,t&&Object.assign(this,t)}cloneProtected(t){t.$d=this.$d,t.Cr=this.Cr,t.Qd=this.Qd,t._d.c(this._d),t.Vo=this.Vo,t.pl=this.pl,t.tg=this.tg,t.ig=!0}copy(){const t=new this.constructor;return this.cloneProtected(t),t}fi(t){Util.ur(this,t)}toString(){let t=Util.hn(this.constructor);return t+="(",this.group!==null&&(t+=" in "+this.group),this.diagram!==null&&(t+=" for "+this.diagram),t+=")",t}get diagram(){return this.b}set diagram(t){t!==null&&Util.s(t,Diagram,Layout,"diagram"),this.b=t}get group(){return this.ca}set group(t){this.ca!==t&&(t!==null&&Util.s(t,Group,Layout,"group"),this.ca=t,t!==null&&(this.b=t.diagram))}get isOngoing(){return this.$d}set isOngoing(t){this.$d!==t&&(Util.t(t,"boolean",Layout,"isOngoing"),this.$d=t)}get isInitial(){return this.Cr}set isInitial(t){Util.t(t,"boolean",Layout,"isInitial"),this.Cr=t,t||(this.ig=!0)}get isViewportSized(){return this.Qd}set isViewportSized(t){this.Qd!==t&&(Util.t(t,"boolean",Layout,"isViewportSized"),this.Qd=t,t&&this.invalidateLayout())}get isRouting(){return this.Vo}set isRouting(t){this.Vo!==t&&(Util.t(t,"boolean",Layout,"isRouting"),this.Vo=t)}get isRealtime(){return this.pl}set isRealtime(t){this.pl!==t&&(t!==null&&Util.t(t,"boolean",Layout,"isRealtime"),this.pl=t)}get isValidLayout(){return this.ig}set isValidLayout(t){if(this.ig!==t&&(Util.t(t,"boolean",Layout,"isValidLayout"),this.ig=t,!t)){const i=this.diagram;i!==null&&(i.Wr=!0)}}invalidateLayout(){if(this.isValidLayout){const t=this.diagram;if(t===null||t.undoManager.isUndoingRedoing)return;const i=t.animationManager;if(i.isTicking)return;i.defaultAnimation.isAnimating&&i.stopAnimation(),(this.isOngoing&&t.Yh||this.isInitial&&!t.Yh)&&(this.isValidLayout=!1,t.requestUpdate())}}get network(){return this.bo}set network(t){this.bo!==t&&(t!==null&&Util.s(t,LayoutNetwork,Layout,"network"),this.bo=t,t!==null&&(t.layout=this))}createNetwork(){return new LayoutNetwork(this)}makeNetwork(t){const i=this.createNetwork();return t instanceof Diagram?(i.addParts(t.nodes,!0),i.addParts(t.links,!0)):t instanceof Group?i.addParts(t.memberParts):i.addParts(t.iterator),i}updateParts(){this.isValidLayout=!0;let t=this.diagram;if(t===null&&this.network!==null){const i=this.network.vertexes.iterator;for(;i.next();){const s=i.value.node;if(s!==null&&(t=s.diagram,t!==null))break}}try{t!==null&&t.startTransaction("Layout"),this.commitLayout()}finally{t!==null&&t.commitTransaction("Layout")}}commitLayout(){if(this.network===null)return;const t=this.network.vertexes.iterator;for(;t.next();)t.value.commit();if(this.isRouting){const i=this.network.edges.iterator;for(;i.next();)i.value.commit()}}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts");const i=new GSet;if(t instanceof Diagram?(this.Ph(i,t.nodes,!0,this.tl,!0,!1,!0),this.Ph(i,t.parts,!0,this.tl,!0,!1,!0)):t instanceof Group?this.Ph(i,t.memberParts,!1,this.tl,!0,!1,!0):i.addAll(t.iterator),i.count>0){const s=this.diagram;s!==null&&s.startTransaction("Layout"),this.doMinimalNoNetworkLayout(i),s!==null&&s.commitTransaction("Layout")}this.isValidLayout=!0}doMinimalNoNetworkLayout(t){const i=t.count,e=Math.ceil(Math.sqrt(i));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const s=this.arrangementOrigin.x,n=this.arrangementOrigin.y;let o=s,r=n,l=0,h=0;const a=t.iterator;for(;a.next();){const f=a.value;f.ensureBounds();const c=f.measuredBounds,u=c.width,d=c.height;f.moveTo(o,r),f instanceof Group&&(f.tl=!1),o+=Math.max(u,50)+20,h=Math.max(h,Math.max(d,50)),l>=e-1?(l=0,o=s,r+=h+20,h=0):l++}}doMinimalNetworkLayout(){const t=this.network.vertexes.count,i=Math.ceil(Math.sqrt(t));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const e=this.arrangementOrigin.x,s=this.arrangementOrigin.y;let n=e,o=s,r=0,l=0;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value.node;if(a===null||a instanceof Link||(a.ensureBounds(),!this.tl(a)))continue;const f=a.measuredBounds,c=f.width,u=f.height;a.moveTo(n,o),a instanceof Group&&(a.tl=!1),n+=Math.max(c,50)+20,l=Math.max(l,Math.max(u,50)),r>=i-1?(r=0,n=e,o+=l+20,l=0):r++}}tl(t){return!!(!t.location.isReal()&&!t.position.isReal()||t instanceof Group&&t.tl)}Ph(t,i,e,s,n,o,r){const l=i.iterator;for(;l.next();){const h=l.value;if(!(e&&!h.isTopLevel)&&!(s!==null&&!s(h))&&h.canLayout())if(n&&h instanceof Node){if(h.isLinkLabel)continue;h instanceof Group&&h.layout===null?this.Ph(t,h.memberParts,!1,s,n,o,r):(h.ensureBounds(),t.add(h))}else o&&h instanceof Link?t.add(h):r&&h.Ae()&&!(h instanceof Node)&&(h.ensureBounds(),t.add(h))}}getLayoutBounds(t,i){const e=this.boundsComputation;return e!==null?(i||(i=new Rect),e(t,this,i)):!i&&t.margin.equalTo(0,0,0,0)?t.actualBounds:(i||(i=new Rect),i.set(t.actualBounds),i.addMargin(t.margin),i)}get boundsComputation(){return this.tg}set boundsComputation(t){this.tg!==t&&(t!==null&&Util.t(t,"function",Layout,"boundsComputation"),this.tg=t,this.invalidateLayout())}collectParts(t){const i=new GSet;return t instanceof Diagram?(this.Ph(i,t.nodes,!0,null,!0,!0,!0),this.Ph(i,t.links,!0,null,!0,!0,!0),this.Ph(i,t.parts,!0,null,!0,!0,!0)):t instanceof Group?this.Ph(i,t.memberParts,!1,null,!0,!0,!0):this.Ph(i,t.iterator,!1,null,!0,!0,!0),i}get arrangementOrigin(){return this._d}set arrangementOrigin(t){Util.s(t,Point,Layout,"arrangementOrigin"),this._d.equals(t)||(this._d.c(t),this.invalidateLayout())}initialOrigin(t){const i=this.group;if(i!==null)if(i.hasPlaceholder()){const e=i.placeholder,s=e.getDocumentPoint(Spot.TopLeft);(isNaN(s.x)||isNaN(s.y))&&s.set(t);const n=e.padding;return s.x+=n.left,s.y+=n.top,s}else{const e=i.position.copy();return(isNaN(e.x)||isNaN(e.y))&&e.set(t),e}return t}}class LayoutNetwork{oe;ko;Fn;Ay;Ly;constructor(t){GSet.vi(this),Debug&&!t&&Util.n("LayoutNetwork constructor requires non-null Layout argument"),this.oe=t,this.ko=new GSet,this.Fn=new GSet,this.Ay=new GMap,this.Ly=new GMap}clear(){if(this.ko){const t=this.ko.iterator;for(;t.next();)t.value.clear()}if(this.Fn){const t=this.Fn.iterator;for(;t.next();)t.value.clear()}this.ko=new GSet,this.Fn=new GSet,this.Ay=new GMap,this.Ly=new GMap}toString(t){t===void 0&&(t=0);let i="LayoutNetwork"+(this.layout!==null?"("+this.layout.toString()+")":"");if(t<=0)return i;if(i+=" vertexes: "+this.ko.count+" edges: "+this.Fn.count,t>1){const e=this.ko.iterator;for(;e.next();){const n=e.value;i+=` +`);if(t.length===0)return 8;if(this.isMultiline){let i=0,e=0,s=!1;for(;!s;){let n=this.ub(t,e);n===-1&&(n=t.length,s=!0);let o=t.substring(e,n);this.formatting===0&&(o=o.trim()),i=Math.max(i,this.getStringWidth(o)),e=n+1}return i}else{const i=this.ub(t,0);return i>=0&&(t=t.substring(0,i)),this.getStringWidth(t)}}get textValidation(){return this.$!==null?this.$.Il:null}set textValidation(t){const i=this.textValidation;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"textValidation"),this.Tn(),this.$.Il=t,this.i("textValidation",i,t))}get textEdited(){return this.$!==null?this.$.Vp:null}set textEdited(t){const i=this.textEdited;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"textEdited"),this.Tn(),this.$.Vp=t,this.i("textEdited",i,t))}get spacingAbove(){return this.$!==null?this.$.zp:0}set spacingAbove(t){const i=this.spacingAbove;i!==t&&(Debug&&Util.t(t,"number",TextBlock,"spacingAbove"),this.Tn(),this.$.zp=t,this.u(),this.i("spacingAbove",i,t))}get spacingBelow(){return this.$!==null?this.$.Xp:0}set spacingBelow(t){const i=this.spacingBelow;i!==t&&(Debug&&Util.t(t,"number",TextBlock,"spacingBelow"),this.Tn(),this.$.Xp=t,this.u(),this.i("spacingBelow",i,t))}get formatting(){return this.$!==null?this.$.Yp:0}set formatting(t){const i=this.formatting;i!==t&&(Util.tt(t,TextFormat,"formatting"),this.Tn(),this.$.Yp=t,this.u(),this.i("formatting",i,t))}get maxLines(){return this.$!==null?this.$.Kp:1/0}set maxLines(t){const i=this.maxLines;i!==t&&(Debug&&Util.t(t,"number",TextBlock,"maxLines"),t=Math.floor(t),t<=0&&Util.G(t,"> 0",TextBlock,"maxLines"),this.Tn(),this.$.Kp=t,this.u(),this.i("maxLines",i,t))}getMetrics(){return[this.xi,this.Ol,this.co,this.An,this.Re,this.Oi,this.Ln]}DI(t){t!==void 0&&(this.xi=t[0],this.Ol=t[1],this.co=t[2],this.An=t[3],this.Re=t[4],this.Oi=t[5],this.Ln=t[6])}get metrics(){return{arrSize:this.Re!==null?this.Re:[this.xi],arrText:this.Oi!==null?this.Oi:[this.Ln],maxLineWidth:this.xi,fontHeight:this.co}}get choices(){return this.Dd}set choices(t){const i=this.Dd;i!==t&&(Debug&&t!==null&&!Array.isArray(t)&&Util.Bi(t,"Array",TextBlock,"choices:value"),this.Dd=t,this.i("choices",i,t))}static EI=new RegExp("[ \u200B\xAD]");static W2=new PropertyCollection;static HL=0;static ab=new PropertyCollection;static H2=0;static Dp="...";static UL="";static rl=Diagram.isUsingDOM()?new CanvasSurface(null).di:null}class TextBlockTemplateSettings{wi;fs;uo;Yp;Kp;Ip;zp;Xp;Fp;Vp;Ep;Il;hl;Rp;constructor(){this.wi=!1,this.fs=null,this.uo=0,this.Yp=0,this.Kp=1/0,this.Ip=0,this.zp=0,this.Xp=0,this.Fp="start",this.Vp=null,this.Ep=null,this.Il=null,this.hl=Spot.Top,this.Rp=2}copy(){const t=new TextBlockTemplateSettings;return t.fs=this.fs,t.uo=this.uo,t.Yp=this.Yp,t.Kp=this.Kp,t.Ip=this.Ip,t.zp=this.zp,t.Xp=this.Xp,t.Fp=this.Fp,t.Vp=this.Vp,t.Ep=this.Ep,t.Il=this.Il,t.hl=this.hl,t.Rp=this.Rp,t}}class GradElementSettings{wc;xc;bc;Bp;kc;constructor(){this.wc=1,this.xc=0,this.bc=1,this.Bp=null,this.kc=null}copy(){const t=new GradElementSettings;return t.wc=this.wc,t.xc=this.xc,t.bc=this.bc,t.Bp=this.Bp,t.kc=this.kc,t}}var ImageStretch=(w=>(w[w.None=0]="None",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ImageStretch||{});class Picture extends GraphObject{al;St;fl;Sc;fs;cl;Mc;uo;Pc;Nc;W1;constructor(t,i){super(),this.l|=2097152,this.al=null,this.St="",this.fl=Rect.BD,this.Sc=2,this.fs=null,this.cl=null,this.Mc=Spot.Center,this.uo=0,this.Pc=null,this.Nc=null,this.W1=null,typeof t=="string"?this.source=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.St=this.St,t.element=this.al,t.fl=this.fl.L(),t.Sc=this.Sc,t.uo=this.uo,t.fs=this.fs,t.cl=this.cl,t.Mc=this.Mc.L(),t.Nc=this.Nc}fi(t){t in ImageStretch?this.imageStretch=t:super.fi(t)}toString(){return"Picture("+this.source+")#"+GSet.gs(this)}get Cc(){return(this.l&1048576)!==0}set Cc(t){this.Cc!==t&&(this.l=this.l^1048576)}get Oa(){return(this.l&2097152)!==0}set Oa(t){this.Oa!==t&&(this.l=this.l^2097152)}get bn(){return(this.l&4194304)!==0}set bn(t){this.bn!==t&&(this.l=this.l^4194304)}static clearCache(t){t===void 0&&(t=""),Util.t(t,"string",Picture,"clearCache:url"),t!==""?Picture.Up[t]&&(delete Picture.Up[t],Picture.db--):(Picture.Up=new PropertyCollection,Picture.db=0)}static KA(t,i){i.qL||(i.gb=e=>{Picture.BI(i,e),t.desiredSize.isReal()||(t.ye(!1),t.u())},i.mb=e=>Picture.VI(i,e),i.addEventListener("load",i.gb),i.addEventListener("error",i.mb),i.qL=!0)}static MR(t){t.gb&&t.removeEventListener("load",t.gb),t.mb&&t.removeEventListener("error",t.mb),delete t.gb,delete t.mb,delete t.qL}get element(){return this.al}set element(t){const i=this.al;if(this.hs(!0),i!==t){this.Cc=t instanceof HTMLCanvasElement;const e=t instanceof HTMLImageElement;t!==null&&!(e||t instanceof HTMLVideoElement||this.Cc)&&Util.n("Picture.element must be an instance of Image, Canvas, or Video, not: "+t);const s=this.diagram;s!==null&&s.zP(this),this.al=t,t!==null&&e&&t.ls===void 0&&(t.ls=new GSet),s!==null&&e&&s.VP(this),this.i("element",i,t),this.T()}}kR(){const t=this.al;if(t===null)return;const i=this.desiredSize.isReal();(this.Cc||t.complete===!0)&&(t.y0&&(t.Gp instanceof Event&&this.fs!==null?this.fs(this,t.Gp):t.bn===!0&&!t.Gp&&this.cl!==null&&t.v2&&this.cl(this,t.v2)),t.bn=!0),t.bn&&i&&this.diagram!==null&&this.diagram.Wu.add(this)}zI(){if(this.al===null){this.Pc=!1;return}const t=new CanvasSurface(null).di;try{t.drawImage(this.al,0,0)}catch(i){Debug&&this.Oa&&Util.ht(i.toString()),this.Oa=!1}try{t.getImageData(0,0,1,1).data[3]&&(this.Pc=!1),this.Pc=!1}catch{this.Pc=!0}}get source(){return this.St}set source(t){const i=this.St;if(i!==t){this.hs(!0),Util.t(t,"string",Picture,"source"),this.St=t;let e=Picture.Up;if(!Diagram.isUsingDOM()){this.i("source",i,t);return}let s=null;if(e[t]!==void 0)s=e[t];else if(t!==""){Picture.db>30&&(Picture.clearCache(),e=Picture.Up),s=Util.ln("img"),s.y0=!0,Picture.KA(this,s);const n=this.Nc;n!==null&&(s.crossOrigin=n(this)),s.src=t,e[t]=s,Picture.db++}this.element=s,s!==null&&s.__goCache===void 0&&(s.__goCache=new PictureCacheArray),this.u(),this.T(),this.i("source",i,t)}}static BI(t,i){t.bn=!0,t.Gp=!1;let e;const s=t.ls.copy();if(s==null)return;const n=s.iterator;for(;n.next();){const o=n.value;o.T();const r=t.getAttribute("src")||"",l=o._l.get(r);if(l===null)continue;const h=l.length;for(let a=0;a=o.width&&(r=r+p.offsetX+(d*p.x-o.width*p.x)),m>=o.height&&(l=l+p.offsetY+(m*p.y-o.height*p.y)),a=Math.min(o.width,d),f=Math.min(o.height,m);break;case 2:d=o.width,m=o.height;break;case 6:case 7:let L=0;g===6?(L=Math.min(o.height/m,o.width/d),d*=L,m*=L):g===7&&(L=Math.max(o.height/m,o.width/d),d*=L,m*=L,d>=o.width&&(r=(r+p.offsetX+(d*p.x-o.width*p.x)/d)*a),m>=o.height&&(l=(l+p.offsetY+(m*p.y-o.height*p.y)/m)*f),a*=1/(d/o.width),f*=1/(m/o.height),d=o.width,m=o.height);break}const y=a*f,x=this.getDocumentScale()*i.scale,k=d*x,b=m*x,S=k*b,M=y/S,A=e.__goCache;let C=null;const P=Picture.XI;if(!n){if(e.bn&&A!==void 0&&S>4&&M>P*P){A.Yt===null&&(A.jL(4,c,u,e),A.jL(16,c,u,e));const L=A.Yt,D=L.length;for(let F=0;F0){const f=this.Yt[this.Yt.length-1];h=f.St,a=f.Rd}o.setTransform(r*a,0,0,r*a,0,0),o.commitTransform(),o.drawImage(h,0,0),this.Yt.push(l)}}class PictureCacheInstance{St;Rd;constructor(t,i){this.St=t,this.Rd=i}}class GeoStream{Ci;tm;constructor(){this.tm=new Geometry,this.Ci=null}Vi(t){t!==null?(t.ft(),this.tm=t,t.figures.clear()):this.tm=new Geometry,this.Ci=null}yu(t,i,e,s,n,o){if(s!==void 0&&s===!0){const r=new PathSegment(1);r.endX=t,r.endY=i,this.Ci.segments.add(r)}else this.Ci=new PathFigure,this.Ci.startX=t,this.Ci.startY=i,this.Ci.isFilled=e,this.Ci.isEvenOdd=o||!1,this.tm.figures.add(this.Ci);n!==void 0&&(this.Ci.isShadowed=n)}jD(){const t=this.Ci.segments.length;t>0&&this.Ci.segments.elt(t-1).close()}WD(){this.Ci.segments.length>0&&(this.Ci.isFilled=!0)}vD(t){this.Ci.isShadowed=t}mE(t){this.Ci.isEvenOdd=t}GD(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(1);s.endX=t,s.endY=i,e&&s.close(),this.Ci.segments.add(s)}yr(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(2);s.endX=t,s.endY=i,e&&s.close(),this.Ci.segments.add(s)}wr(t,i,e,s,n,o,r){r===void 0&&(r=!1);const l=new PathSegment(3);l.point1X=t,l.point1Y=i,l.point2X=e,l.point2Y=s,l.endX=n,l.endY=o,r&&l.close(),this.Ci.segments.add(l)}Fw(t,i,e,s,n){n===void 0&&(n=!1);const o=new PathSegment(4);o.point1X=t,o.point1Y=i,o.endX=e,o.endY=s,n&&o.close(),this.Ci.segments.add(o)}HD(t,i,e,s,n,o,r){o===void 0&&(o=0),r===void 0&&(r=!1);const l=new PathSegment(5);l.startAngle=t,l.sweepAngle=i,l.centerX=e,l.centerY=s,l.radiusX=n,o!==0?l.radiusY=o:l.radiusY=n,r&&l.close(),this.Ci.segments.add(l)}qD(t,i,e,s,n,o,r,l){l===void 0&&(l=!1);const h=new PathSegment(6,o,r,t,i,e,s,n);l&&h.close(),this.Ci.segments.add(h)}static J2=null;static SC(t){const i=GeoStream.J2;if(i!==null)return GeoStream.J2=null,i.Vi(t),i;{const e=new GeoStream;return e.Vi(t),e}}static MC(t){GeoStream.J2=t}}{const w=function(n,o){const r=n.toLowerCase(),l=Geo.qn;l[n]=o,l[r]=n};w("Rectangle",(n,o,r)=>{const l="r"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,Geo.pr{const l="s"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,h.defaultStretch=6,Geo.pr{(isNaN(l)||l<0)&&(l=5),isNaN(h)&&(h=15);const a="rr"+o+","+r+","+l+","+h;let f=Geo.mr[a];if(f!==void 0)return f;let c=l;(h&1)===1?(c=Math.min(c,(h&2)===2?o/3:o),c=Math.min(c,(h&8)===8?r/3:r)):c=0;const u=new PathFigure(c,0,!0);f=new Geometry().add(u);const d=Spot.TopLeft.copy(),m=Spot.BottomRight.copy();if((h&2)===2){let g=l;g=Math.min(g,(h&1)===1?o/3:o),g=Math.min(g,(h&4)===4?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,o-g,0)).add(new PathSegment(3,o,g,o-p,0,o,p)),d.offsetY=p,m.offsetX=-p}else u.add(new PathSegment(2,o,0));if((h&4)===4){let g=l;g=Math.min(g,(h&8)===8?o/3:o),g=Math.min(g,(h&2)===2?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,o,r-g)).add(new PathSegment(3,o-g,r,o,r-p,o-p,r)),m.offsetX=-p,m.offsetY=-p}else u.add(new PathSegment(2,o,r));if((h&8)===8){let g=l;g=Math.min(g,(h&4)===4?o/3:o),g=Math.min(g,(h&1)===1?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,g,r)).add(new PathSegment(3,0,r-g,p,r,0,r-p)),d.offsetX=p,m.offsetY=-p}else u.add(new PathSegment(2,0,r));if((h&1)===1){const g=c*Geo.Un;u.add(new PathSegment(2,0,c)).add(new PathSegment(3,c,0,0,g,g,0).close()),d.offsetX=g,d.offsetY=g}else u.add(new PathSegment(2,0,0).close());return f.spot1=d,f.spot2=m,Geo.pr{const l=n?n.parameter1:NaN,h=n?n.parameter2:NaN;return t(n,o,r,l,h)}),w("Border","RoundedRectangle"),w("RoundedTopRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,3)}),w("RoundedBottomRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,12)}),w("RoundedLeftRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,9)}),w("RoundedRightRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,6)}),w("Ellipse",(n,o,r)=>{const l="e"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Kk,h.spot2=Spot.Uk,Geo.pr{const l="c"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Kk,h.spot2=Spot.Uk,h.defaultStretch=6,Geo.prnew Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,.5*r)).add(new PathSegment(2,0,r).close())).setSpots(0,.25,.5,.75)),w("TriangleDown",(n,o,r)=>new Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,0)).add(new PathSegment(2,.5*o,r).close())).setSpots(.25,0,.75,.5)),w("TriangleLeft",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,o,0).close())).setSpots(.5,.25,1,.75)),w("TriangleUp",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,r)).add(new PathSegment(2,.5*o,0).close())).setSpots(.25,.5,.75,1)),w("Triangle","TriangleUp"),w("Diamond",(n,o,r)=>new Geometry().add(new PathFigure(.5*o,0).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,.5*o,r)).add(new PathSegment(2,o,.5*r).close())).setSpots(.25,.25,.75,.75)),w("LineH",(n,o,r)=>{const l=new Geometry(1);return l.startX=0,l.startY=r/2,l.endX=o,l.endY=r/2,l}),w("LineV",(n,o,r)=>{const l=new Geometry(1);return l.startX=o/2,l.startY=0,l.endX=o/2,l.endY=r,l}),w("None","Rectangle"),w("BarH","Rectangle"),w("BarV","Rectangle"),w("MinusLine","LineH"),w("PlusLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r/2,!1).add(new PathSegment(2,o,r/2)).add(new PathSegment(1,o/2,0)).add(new PathSegment(2,o/2,r)))),w("XLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r,!1).add(new PathSegment(2,o,0)).add(new PathSegment(1,0,0)).add(new PathSegment(2,o,r)))),w("LineRight",(n,o,r)=>new Geometry().add(new PathFigure(.25*o,0,!1).add(new PathSegment(2,.75*o,.5*r)).add(new PathSegment(2,.25*o,r)))),w("LineDown",(n,o,r)=>new Geometry().add(new PathFigure(0,.25*r,!1).add(new PathSegment(2,.5*o,.75*r)).add(new PathSegment(2,o,.25*r)))),w("LineLeft",(n,o,r)=>new Geometry().add(new PathFigure(.75*o,0,!1).add(new PathSegment(2,.25*o,.5*r)).add(new PathSegment(2,.75*o,r)))),w("LineUp",(n,o,r)=>new Geometry().add(new PathFigure(0,.75*r,!1).add(new PathSegment(2,.5*o,.25*r)).add(new PathSegment(2,o,.75*r)))),w("Capsule",(n,o,r)=>{const l=new Geometry;if(or){const h=r/2,a=new PathFigure(h,0,!0);l.add(a),a.add(new PathSegment(2,o-h,0)),a.add(new PathSegment(5,270,180,o-h,h,h,h)),a.add(new PathSegment(2,h,r)),a.add(new PathSegment(5,90,180,h,h,h,h));const f=isFinite(n.parameter1)?n.parameter1:r*.156;return l.spot1=new Spot(0,0,f,0),l.spot2=new Spot(1,1,-f,0),l}else return l.type=3,l.endX=o,l.endY=r,l.spot1=Spot.Kk,l.spot2=Spot.Uk,l});const i=(n,o)=>new PathFigure(n,o,!1,!1),e=(n,o,r)=>n.add(new PathSegment(2,o,r)),s=(n,o,r)=>n.add(new PathSegment(1,o,r));w("Borders",(n,o,r)=>{let l=n?n.parameter1:NaN;isNaN(l)?l=10:l=l&15;const h=new Geometry;let a;return l===10?(a=i(o,0),e(a,o,r),s(a,0,r),e(a,0,0)):l===5?(a=i(0,0),e(a,o,0),s(a,o,r),e(a,0,r)):l===1?(a=i(0,0),e(a,o,0),s(a,o,r)):l===2?(a=i(o,0),e(a,o,r)):l===4?(a=i(o,r),e(a,0,r)):l===8?(a=i(0,r),e(a,0,0),s(a,o,r)):l===3?(a=i(0,0),e(a,o,0),e(a,o,r)):l===6?(a=i(o,0),e(a,o,r),e(a,0,r)):l===12?(a=i(o,r),e(a,0,r),e(a,0,0)):l===9?(a=i(0,r),e(a,0,0),e(a,o,0)):l===7?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r)):l===14?(a=i(o,0),e(a,o,r),e(a,0,r),e(a,0,0)):l===13?(a=i(o,r),e(a,0,r),e(a,0,0),e(a,o,0)):l===11?(a=i(0,r),e(a,0,0),e(a,o,0),e(a,o,r)):l===15?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r),a.add(new PathSegment(2,0,0).close())):(a=i(0,0),s(a,o,r)),h.add(a),h})}Geo.Jg={"":"",Standard:"F1 m 0,0 l 8,4 -8,4 2,-4 z",Backward:"F1 m 8,0 l -2,4 2,4 -8,-4 z",Triangle:"F1 m 0,0 l 8,4.62 -8,4.62 z",BackwardTriangle:"F1 m 8,4 l 0,4 -8,-4 8,-4 0,4 z",Boomerang:"F1 m 0,0 l 8,4 -8,4 4,-4 -4,-4 z",BackwardBoomerang:"F1 m 8,0 l -8,4 8,4 -4,-4 4,-4 z",SidewaysV:"m 0,0 l 8,4 -8,4 0,-1 6,-3 -6,-3 0,-1 z",BackwardV:"m 8,0 l -8,4 8,4 0,-1 -6,-3 6,-3 0,-1 z",OpenTriangle:"m 0,0 l 8,4 -8,4",BackwardOpenTriangle:"m 8,0 l -8,4 8,4",OpenTriangleLine:"m 0,0 l 8,4 -8,4 m 8.5,0 l 0,-8",BackwardOpenTriangleLine:"m 8,0 l -8,4 8,4 m -8.5,0 l 0,-8",OpenTriangleTop:"m 0,0 l 8,4 m 0,4",BackwardOpenTriangleTop:"m 8,0 l -8,4 m 0,4",OpenTriangleBottom:"m 0,8 l 8,-4",BackwardOpenTriangleBottom:"m 0,4 l 8,4",HalfTriangleTop:"F1 m 0,0 l 0,4 8,0 z m 0,8",BackwardHalfTriangleTop:"F1 m 8,0 l 0,4 -8,0 z m 0,8",HalfTriangleBottom:"F1 m 0,4 l 0,4 8,-4 z",BackwardHalfTriangleBottom:"F1 m 8,4 l 0,4 -8,-4 z",ForwardSemiCircle:"m 4,0 b 270 180 0 4 4",BackwardSemiCircle:"m 4,8 b 90 180 0 -4 4",Feather:"m 0,0 l 3,4 -3,4",BackwardFeather:"m 3,0 l -3,4 3,4",DoubleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardDoubleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4",TripleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardTripleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4 m 3,-8 l -3,4 3,4",ForwardSlash:"m 0,8 l 5,-8",BackSlash:"m 0,0 l 5,8",DoubleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8",DoubleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8",TripleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8 m -2,8 l 4,-8",TripleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8 m -2,-8 l 4,8",Fork:"m 0,4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4",LineFork:"m 0,0 l 0,8 m 0,-4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardLineFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4 m 8,-8 l 0,8",CircleFork:"F1 m 6,4 b 0 360 -3 0 3 z m 0,0 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 6,0 b 0 360 -3 0 3",CircleLineFork:"F1 m 6,4 b 0 360 -3 0 3 z m 1,-4 l 0,8 m 0,-4 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleLineFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 0,-4 l 0,8 m 7,-4 b 0 360 -3 0 3",Circle:"F1 m 8,4 b 0 360 -4 0 4 z",Block:"F1 m 0,0 l 0,8 8,0 0,-8 z",StretchedDiamond:"F1 m 0,3 l 5,-3 5,3 -5,3 -5,-3 z",Diamond:"F1 m 0,4 l 4,-4 4,4 -4,4 -4,-4 z",Chevron:"F1 m 0,0 l 5,0 3,4 -3,4 -5,0 3,-4 -3,-4 z",StretchedChevron:"F1 m 0,0 l 8,0 3,4 -3,4 -8,0 3,-4 -3,-4 z",NormalArrow:"F1 m 0,2 l 4,0 0,-2 4,4 -4,4 0,-2 -4,0 z",X:"m 0,0 l 8,8 m 0,-8 l -8,8",TailedNormalArrow:"F1 m 0,0 l 2,0 1,2 3,0 0,-2 2,4 -2,4 0,-2 -3,0 -1,2 -2,0 1,-4 -1,-4 z",DoubleTriangle:"F1 m 0,0 l 4,4 -4,4 0,-8 z m 4,0 l 4,4 -4,4 0,-8 z",BigEndArrow:"F1 m 0,0 l 5,2 0,-2 3,4 -3,4 0,-2 -5,2 0,-8 z",ConcaveTailArrow:"F1 m 0,2 h 4 v -2 l 4,4 -4,4 v -2 h -4 l 2,-2 -2,-2 z",RoundedTriangle:"F1 m 0,1 a 1,1 0 0 1 1,-1 l 7,3 a 0.5,1 0 0 1 0,2 l -7,3 a 1,1 0 0 1 -1,-1 l 0,-6 z",SimpleArrow:"F1 m 1,2 l -1,-2 2,0 1,2 -1,2 -2,0 1,-2 5,0 0,-2 2,2 -2,2 0,-2 z",AccelerationArrow:"F1 m 0,0 l 0,8 0.2,0 0,-8 -0.2,0 z m 2,0 l 0,8 1,0 0,-8 -1,0 z m 3,0 l 2,0 2,4 -2,4 -2,0 0,-8 z",BoxArrow:"F1 m 0,0 l 4,0 0,2 2,0 0,-2 2,4 -2,4 0,-2 -2,0 0,2 -4,0 0,-8 z",TriangleLine:"F1 m 8,4 l -8,-4 0,8 8,-4 z m 0.5,4 l 0,-8",CircleEndedArrow:"F1 m 10,4 l -2,-3 0,2 -2,0 0,2 2,0 0,2 2,-3 z m -4,0 b 0 360 -3 0 3 z",DynamicWidthArrow:"F1 m 0,3 l 2,0 2,-1 2,-2 2,4 -2,4 -2,-2 -2,-1 -2,0 0,-2 z",EquilibriumArrow:"m 0,3 l 8,0 -3,-3 m 3,5 l -8,0 3,3",FastForward:"F1 m 0,0 l 3.5,4 0,-4 3.5,4 0,-4 1,0 0,8 -1,0 0,-4 -3.5,4 0,-4 -3.5,4 0,-8 z",Kite:"F1 m 0,4 l 2,-4 6,4 -6,4 -2,-4 z",HalfArrowTop:"F1 m 0,0 l 4,4 4,0 -8,-4 z m 0,8",HalfArrowBottom:"F1 m 0,8 l 4,-4 4,0 -8,4 z",OpposingDirectionDoubleArrow:"F1 m 0,4 l 2,-4 0,2 4,0 0,-2 2,4 -2,4 0,-2 -4,0 0,2 -2,-4 z",PartialDoubleTriangle:"F1 m 0,0 4,3 0,-3 4,4 -4,4 0,-3 -4,3 0,-8 z",LineCircle:"F1 m 0,0 l 0,8 m 7 -4 b 0 360 -3 0 3 z",DoubleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",TripleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",CircleLine:"F1 m 6 4 b 0 360 -3 0 3 z m 1,-4 l 0,8",DiamondCircle:"F1 m 8,4 l -4,4 -4,-4 4,-4 4,4 m 8,0 b 0 360 -4 0 4 z",PlusCircle:"F1 m 8,4 b 0 360 -4 0 4 l -8 0 z m -4 -4 l 0 8",OpenRightTriangleTop:"m 8,0 l 0,4 -8,0 m 0,4",OpenRightTriangleBottom:"m 8,8 l 0,-4 -8,0",Line:"m 0,0 l 0,8",DoubleLine:"m 0,0 l 0,8 m 2,0 l 0,-8",TripleLine:"m 0,0 l 0,8 m 2,0 l 0,-8 m 2,0 l 0,8",PentagonArrow:"F1 m 8,4 l -4,-4 -4,0 0,8 4,0 4,-4 z"};var LayoutConditions=(w=>(w[w.None=0]="None",w[w.Added=1]="Added",w[w.Removed=2]="Removed",w[w.Shown=4]="Shown",w[w.Hidden=8]="Hidden",w[w.NodeSized=16]="NodeSized",w[w.GroupLayout=32]="GroupLayout",w[w.NodeReplaced=64]="NodeReplaced",w[w.Standard=127]="Standard",w[w.All=16777215]="All",w))(LayoutConditions||{});class Part extends Panel{N;$o;E;ul;dl;Qo;ui;_o;bh;Zs;tr;Id;qM;WL;Hp;qp;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.N=2408959,this.$o="",this.E=null,this.ul="",this.dl=null,this.Qo=null,this.ui="",this._o=null,this.bh=null,this.Zs=new Point(NaN,NaN).w(),this.tr=null,this.Id=NaN,this.qM=-1,this.WL=new Rect,this.Hp=null,this.qp=NaN,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.N=this.N&-4097|16384|32768,t.$o=this.$o,this.E!==null&&(this.E.wi?t.E=this.E:t.E=this.E.copy()),t.ul=this.ul,t.Qo=null,t.ui=this.ui,t.Zs.c(this.Zs),t.Id=this.Id}Ho(t){super.Ho(t),t.gh(),t.dl=null,t.tr=null,t.Hp=null}toString(){let t=Util.hn(this.constructor)+"#"+GSet.gs(this);return this.data!==null&&(t+="("+Util.toString(this.data)+")"),t}static LayoutNone=0;static LayoutAdded=1;static LayoutRemoved=2;static LayoutShown=4;static LayoutHidden=8;static LayoutNodeSized=16;static LayoutGroupLayout=32;static LayoutNodeReplaced=64;static LayoutStandard=127;static LayoutAll=16777215;Qi(){this.E===null?this.E=new PartTemplateSettings:this.E.wi&&(this.E=this.E.copy())}ch(){super.ch(),this.E!==null&&(this.E.wi=!0)}ec(t,i,e,s,n,o,r){const l=this.diagram;l!==null&&(t===3&&i==="elements"?n instanceof Panel?n.Qr(h=>{l.partManager.FP(h,l)}):n instanceof Picture&&l.VP(n):t===4&&i==="elements"&&(n instanceof Panel?n.Qr(h=>l.partManager.RP(h,l)):n instanceof Picture&&l.zP(n)),l.raiseChangedEvent(t,i,e,s,n,o,r))}updateTargetBindings(t){if(super.updateTargetBindings(t),this.data===null)return;const i=this.D.h,e=i.length;for(let n=0;n{r.data!==null&&r.updateTargetBindings()})}const s=this.adornments;for(;s.next();)s.value.updateTargetBindings(t)}Yo(){if(super.Yo(),this.M2()){const i=this.D.h,e=i.length;for(let s=0;so.Yo())}}const t=this.adornments;for(;t.next();)t.value.Yo()}updateRelationshipsFromData(){this.data!==null&&this.diagram?.partManager.updateRelationshipsFromData(this)}get key(){const t=this.diagram;if(t!==null)return t.model.getKeyForNodeData(this.data)}get adornments(){return this.Qo===null?EmptyIterator.instance:this.Qo.iteratorValues}findAdornment(t){Debug&&Util.t(t,"string",Part,"findAdornment:category");const i=this.Qo;return i===null?null:i.get(t)}addAdornment(t,i){if(i===null)return;Debug&&(Util.t(t,"string",Part,"addAdornment:category"),Util.s(i,Adornment,Part,"addAdornment:ad"));let e=null,s=this.Qo;if(s!==null&&(e=s.get(t)),e!==i){if(e!==null){const o=e.diagram;o!==null&&o.remove(e)}s===null&&(s=new GMap,this.Qo=s),i.$o!==t&&(i.category=t),s.set(t,i);const n=this.diagram;if(n!==null){n.add(i);const o=i.adornedObject;if(o!==null){const r=o.findBindingPanel();r!==null&&(i.data=r.data)}}}}removeAdornment(t){Debug&&Util.t(t,"string",Part,"removeAdornment:category");const i=this.Qo;if(i===null)return;const e=i.get(t);if(e!==null){const s=e.diagram;s!==null&&(s.remove(e),e.data=null)}i.delete(t),i.count===0&&(this.Qo=null)}clearAdornments(){const t=this.Qo;if(t===null)return;const i=Util.at(),e=t.iterator;for(;e.next();){const n=e.key;i.push(n)}const s=i.length;for(let n=0;n{e.isEnabled&&e.updateAdornments(i)}),t.toolManager.updateAdornments(i)}GM(t){this._o=t,t===null&&this.VR()}get layer(){return this._o}get diagram(){const t=this._o;return t==null?null:t.diagram}get layerName(){return this.ul}set layerName(t){const i=this.ul;if(i===t)return;Util.t(t,"string",Part,"layerName");let e=this.diagram;if(e!==null&&(e.findLayer(t)===null||e.partManager.addsToTemporaryLayer))return;this.ul=t,e!==null&&e.invalidateDocumentBounds(),this.i("layerName",i,t);const s=this.layer;if(s===null||s.name===t||(e=s.diagram,e===null))return;const n=e.findLayer(t);if(n===null||n===s)return;let o=s.oe(-1,this,!0);o>=0&&e.raiseChangedEvent(4,"parts",s,this,null,o,!0),o=n.$h(99999999,this,!0),s.visible!==n.visible&&this.Ki(n.visible),o>=0&&e.raiseChangedEvent(3,"parts",n,null,this,!0,o);const r=this.layerChanged;if(r===null)return;const l=e.j;e.j=!0,r(this,s,n),e.j=l}get layerChanged(){return this.E!==null?this.E.jp:null}set layerChanged(t){const i=this.layerChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"layerChanged"),this.Qi(),this.E.jp=t,this.i("layerChanged",i,t))}get zOrder(){return this.Id}set zOrder(t){const i=this.Id;if(i===t)return;Util.t(t,"number",Part,"zOrder"),this.Id=t;const e=this.layer;e!==null&&e.Nx(-1,this),this.i("zOrder",i,t);const s=this.diagram;s!==null&&s.T()}UI(){const t=this.layer;t!==null&&t.Nx(-1,this)}pb(){if(this.nh()!==!1)return;this.Z2(!0),this.ld();const t=this.diagram;t!==null&&(t.u0(this),t.requestUpdate())}ZL(){if(this.N|=2097152,this.nh()===!1)return;const t=this.position,i=this.location;(!i.isReal()||!t.isReal())&&this.$L(t,i);const e=this.Fi,s=Rect.a().c(e);e.ft(),e.x=t.x,e.y=t.y,e.w(),this.hd(s,e),Rect.o(s),this.Z2(!1)}no(t,i,e,s){const n=this.he;n.e(t,i,e,s),this.Pi===null&&(this.Pi=new Transform);const o=this.Pi;o.Vi(),this.M0(o,t,i,e,s),this.Pi=o,o.Gk()||o.Cw(n)}M0(t,i,e,s,n){if(this.rt!==1&&t.rt(this.rt),this.jt===0)return;let o=Spot.Center;this.locationSpot.isSpot()&&(o=this.locationSpot);const r=Point.a();if(this.locationObject!==this){const l=this.locationObject,h=l.naturalBounds;r.setSpot(h.x,h.y,h.width,h.height,o),l.Pi!==null&&l.Pi.Pt(r),r.offset(-l.measuredBounds.x,-l.measuredBounds.y);let a=l.panel;for(;a!==null&&a!==this;)a.Pi!==null&&a.Pi.Pt(r),r.offset(-a.measuredBounds.x,-a.measuredBounds.y),a=a.panel}else r.setSpot(i,e,s,n,o);t.ms(this.jt,r.x,r.y),Point.o(r)}get locationObject(){if(this.tr===null)if(this instanceof Adornment&&this.type!==Panel.Link&&this.hasPlaceholder())this.tr=this.placeholder;else{const t=this.locationObjectName;if(t!==""){const i=this.findObject(t);i!==null?this.tr=i:this.tr=this}else this.tr=this}return this.tr.visible?this.tr:this}get minLocation(){return this.E!==null?this.E.Wp:Point.nC}set minLocation(t){const i=this.minLocation;i.equals(t)||(Debug&&Util.s(t,Point,Part,"minLocation"),t=t.L(),this.Qi(),this.E.Wp=t,this.i("minLocation",i,t))}get maxLocation(){return this.E!==null?this.E.vp:Point.oC}set maxLocation(t){const i=this.maxLocation;i.equals(t)||(Debug&&Util.s(t,Point,Part,"maxLocation"),t=t.L(),this.Qi(),this.E.vp=t,this.i("maxLocation",i,t))}get locationObjectName(){return this.E!==null?this.E.Jp:""}set locationObjectName(t){const i=this.locationObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"locationObjectName"),this.Qi(),this.E.Jp=t,this.tr=null,this.u(),this.i("locationObjectName",i,t))}get locationSpot(){return this.E!==null?this.E.Zp:Spot.TopLeft}set locationSpot(t){const i=this.locationSpot;i.equals(t)||(Debug&&(Util.s(t,Spot,Part,"locationSpot"),t.isSpot()||Util.n("Part.locationSpot must be a specific Spot value, not: "+t)),t=t.L(),this.Qi(),this.E.Zp=t,this.u(),this.i("locationSpot",i,t))}move(t,i){i===!0?this.location=t:this.position=t}moveTo(t,i,e){const s=Point.H(t,i);this.move(s,e),Point.o(s)}isVisible(){if(!this.visible)return!1;const t=this.layer;if(t!==null){if(!t.visible)return!1;const e=t.diagram;if(e!==null&&e.animationManager.ux(this))return!0}const i=this.containingGroup;return!(i!==null&&(!i.isSubGraphExpanded||!i.isVisible()))}Ki(t){const i=this.diagram;t?(this.invalidateLayout(4),this.invalidateAdornments(),i!==null&&i.u0(this)):(this.invalidateLayout(8),this.clearAdornments()),this.gh(),i!==null&&(i.invalidateDocumentBounds(),i.T())}findObject(t){if(this.name===t)return this;let i=this.Hp;if(i===null&&(this.Hp=i=new GMap),i.get(t)!==null)return i.get(t);const e=super.findObject(t);return e!==null?(i.set(t,e),e):(i.set(t,null),null)}V0(){this.Hp=null}getRelativePoint(t,i,e){e===void 0&&(e=new Point);const s=i.isNoSpot()?Spot.Center:i,n=t.naturalBounds;if(e.e(n.width*s.x+s.offsetX,n.height*s.y+s.offsetY),t===null||t===this)return e;t.O.Pt(e);let o=t.panel;for(;o!==null&&o!==this;)o.O.Pt(e),o=o.panel;return this.Pi!==null&&this.Pi.Pt(e),e.offset(-this.he.x,-this.he.y),e}getDocumentBounds(t){return t===void 0&&(t=new Rect),t.c(this.actualBounds)}ensureBounds(){this.wt(1/0,1/0),this.qt()}PL(t){const i=this.locationSpot,e=this.locationObject;let s=e.naturalBounds;s.isReal()||(s=Rect.kw);const n=e instanceof Shape?e.strokeWidth:0;if(t.setSpot(0,0,s.width+n,s.height+n,i),e!==this){t.offset(-n/2,-n/2),e.O.Pt(t);let o=e.panel;for(;o!==null&&o!==this;)o.O.Pt(t),o=o.panel}return this.Pi!==null&&this.Pi.Pt(t),t.offset(-this.he.x,-this.he.y),t}Zh(t,i){const e=i===void 0?this.WL:i,s=this.GI(),n=s*2;if(!this.isShadowed)return e.e(t.x-1-s,t.y-1-s,t.width+2+n,t.height+2+n),e;let o=t.x,r=t.y,l=t.width,h=t.height;const a=this.shadowBlur,f=this.shadowOffset;return l+=a,h+=a,o-=a/2,r-=a/2,f.x>0?l+=f.x:(o+=f.x,l-=f.x),f.y>0?h+=f.y:(r+=f.y,h-=f.y),e.e(o-1,r-1,l+2,h+2),e}NI(){return this.type===Panel.Link&&this instanceof Adornment&&this.category==="Selection"&&this.adornedObject instanceof Shape&&this.adornedPart.findMainElement()===this.adornedObject?this.adornedObject.strokeWidth:0}GI(){return isNaN(this.qp)&&(this.qp=this.FL()),this.qp}pc(){this.qp=NaN}qt(){if(this.rs()===!1){this.ZL();return}this.oo(!1);const t=this.Fi,i=Rect.a();i.c(t);const e=this.Tl();this.dh(0,0,this.he.width,this.he.height);const s=this.position;this.$L(s,this.location),t.ft(),t.x=s.x,t.y=s.y,t.w(),this.hd(i,t),i.equals(t)?this.Us(e):this.Ae()&&(!Geo.p(i.width,t.width)||!Geo.p(i.height,t.height))&&this.qM>=0&&this.invalidateLayout(16),Rect.o(i),this.Z2(!1)}hd(t,i){const e=this.diagram;if(e===null)return;let s=!1;if(e.ia===!1&&t.isReal()){const n=Rect.a();n.c(e.documentBounds),n.subtractMargin(e.padding),t.x>n.x&&t.y>n.y&&t.rightn.x&&i.y>n.y&&i.right=o)return}}this.N=this.N^4096;let s=!1;if(e!==null){s=e.skipsUndoManager,e.skipsUndoManager=!0;const o=e.selection;o.ft(),t?o.add(this):o.delete(this),o.w()}this.i("isSelected",i,t),this.invalidateAdornments();const n=this.selectionChanged;n!==null&&n(this),e!==null&&(e.requestUpdate(),e.skipsUndoManager=s)}}get isHighlighted(){return(this.N&524288)!==0}set isHighlighted(t){const i=(this.N&524288)!==0;if(i!==t){Debug&&Util.t(t,"boolean",Part,"isHighlighted"),this.N=this.N^524288;const e=this.diagram;if(e!==null){const n=e.highlighteds;n.ft(),t?n.add(this):n.delete(this),n.w()}this.i("isHighlighted",i,t),this.T();const s=this.highlightedChanged;s!==null&&s(this)}}get isShadowed(){return(this.N&8192)!==0}set isShadowed(t){const i=(this.N&8192)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Part,"isShadowed"),this.N=this.N^8192,this.hs(!0),this.i("isShadowed",i,t),this.T())}vL(){return(this.N&16384)!==0}JL(t){t?this.N|=16384:this.N&=-16385}nh(){return(this.N&32768)!==0}Z2(t){t?this.N|=32768:this.N&=-32769}HI(){return(this.N&65536)!==0}d2(t){t?this.N|=65536:this.N&=-65537}Tl(){return(this.N&131072)!==0}Us(t){t?this.N|=131072:this.N&=-131073}eT(){return(this.N&1048576)!==0}yb(t){t?this.N|=1048576:this.N&=-1048577}get isAnimated(){return(this.N&262144)!==0}set isAnimated(t){const i=(this.N&262144)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Part,"isAnimated"),this.N=this.N^262144,this.i("isAnimated",i,t))}get highlightedChanged(){return this.E!==null?this.E.$p:null}set highlightedChanged(t){const i=this.highlightedChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"highlightedChanged"),this.Qi(),this.E.$p=t,this.i("highlightedChanged",i,t))}get selectionObjectName(){return this.E!==null?this.E.Qp:""}set selectionObjectName(t){const i=this.selectionObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"selectionObjectName"),this.Qi(),this.E.Qp=t,this.dl=null,this.i("selectionObjectName",i,t))}get selectionAdornmentTemplate(){return this.E!==null?this.E._p:null}set selectionAdornmentTemplate(t){const i=this.selectionAdornmentTemplate;i!==t&&(Debug&&Util.s(t,Adornment,Part,"selectionAdornmentTemplate"),this.Qi(),this.E._p=t,this.i("selectionAdornmentTemplate",i,t))}get selectionObject(){if(this.dl===null){const t=this.selectionObjectName;if(t!==null&&t!==""){const i=this.findObject(t);i!==null?this.dl=i:this.dl=this}else if(this instanceof Link){const i=this.path;i!==null?this.dl=i:this.dl=this}else this.dl=this}return this.dl}get selectionChanged(){return this.E!==null?this.E.ty:null}set selectionChanged(t){const i=this.selectionChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"selectionChanged"),this.Qi(),this.E.ty=t,this.i("selectionChanged",i,t))}get resizeAdornmentTemplate(){return this.E!==null?this.E.iy:null}set resizeAdornmentTemplate(t){const i=this.resizeAdornmentTemplate;i!==t&&(Debug&&Util.s(t,Adornment,Part,"resizeAdornmentTemplate"),this.Qi(),this.E.iy=t,this.i("resizeAdornmentTemplate",i,t))}get resizeObjectName(){return this.E!==null?this.E.ey:""}set resizeObjectName(t){const i=this.resizeObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"resizeObjectName"),this.Qi(),this.E.ey=t,this.i("resizeObjectName",i,t))}get resizeObject(){const t=this.resizeObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get resizeCellSize(){return this.E!==null?this.E.sy:Size.xw}set resizeCellSize(t){const i=this.resizeCellSize;i.equals(t)||(Debug&&Util.s(t,Size,Part,"resizeCellSize"),t=t.L(),this.Qi(),this.E.sy=t,this.i("resizeCellSize",i,t))}get rotateAdornmentTemplate(){return this.E!==null?this.E.ny:null}set rotateAdornmentTemplate(t){const i=this.rotateAdornmentTemplate;i!==t&&(Debug&&Util.s(t,Adornment,Part,"rotateAdornmentTemplate"),this.Qi(),this.E.ny=t,this.i("rotateAdornmentTemplate",i,t))}get rotateObjectName(){return this.E!==null?this.E.oy:""}set rotateObjectName(t){const i=this.rotateObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"rotateObjectName"),this.Qi(),this.E.oy=t,this.i("rotateObjectName",i,t))}get rotateObject(){const t=this.rotateObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get rotationSpot(){return this.E!==null?this.E.ry:Spot.Default}set rotationSpot(t){const i=this.rotationSpot;i.equals(t)||(Debug&&(Util.s(t,Spot,Part,"rotationSpot"),t!==Spot.Default&&!t.isSpot()&&Util.n("Part.rotationSpot must be a specific Spot value or Spot.Default, not: "+t)),t=t.L(),this.Qi(),this.E.ry=t,this.i("rotationSpot",i,t))}get text(){return this.ui}set text(t){const i=this.ui;i!==t&&(Debug&&Util.t(t,"string",Part,"text"),this.ui=t,this.i("text",i,t))}get containingGroup(){return this.bh}set containingGroup(t){if(this.Ae()){const i=this.bh;if(i!==t){Debug&&t!==null&&Util.s(t,Group,Part,"containingGroup"),t!==null&&(this===t||t.isMemberOf(this))&&(this===t&&Util.n("Cannot make a Group a member of itself: "+this.toString()),Util.n("Cannot make a Group indirectly contain itself: "+this.toString()+" already contains "+t.toString())),this.invalidateLayout(2);const e=this.diagram;if(i!==null?i.Q2(this):this instanceof Group&&e!==null&&e.vr.delete(this),this.bh=t,t!==null?t._2(this):this instanceof Group&&e!==null&&e.vr.add(this),this.invalidateLayout(1),e!==null&&e.j){const n=this.data,o=e.model;if(n!==null&&o.ga()){const r=t!==null?t.data:null;o.setGroupForData(n,o.getKeyForNodeData(r))}}const s=this.containingGroupChanged;if(s!==null){let n=!0;e!==null&&(n=e.j,e.j=!0),s(this,i,t),e!==null&&(e.j=n)}if(this instanceof Group){const n=new GSet;Part.lh(n,this,!0,0,!0);const o=n.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=r.linksConnected;for(;l.next();)l.value.Od()}}}if(this instanceof Node){const n=this.linksConnected;for(;n.next();)n.value.Od();const o=this.labeledLink;o!==null&&o.Od()}this.i("containingGroup",i,t),t!==null&&t.UI()}}else Util.n("cannot set the Part.containingGroup of a Link or Adornment")}gh(){const t=this.containingGroup;t!==null&&(t.hasPlaceholder()&&t.placeholder.u(),t.u(),t.invalidateConnectedLinks())}T(){const t=this.diagram;t!==null&&!this.rs()&&!this.nh()&&this.isVisible()&&this.Fi.isReal()&&t.T(this.Zh(this.Fi))}u(){if(this.Xo())return;super.u();const t=this.diagram;t!==null&&(t.u0(this),this instanceof Node&&this.labeledLink!==null&&this.labeledLink.hc(),t.requestUpdate(!0))}hc(t){if(this.rs())return;const i=this.diagram;i!==null&&(i.u0(this),this instanceof Node&&this.invalidateConnectedLinks(),i.requestUpdate()),this.oo(!0)}Gm(t){if(!t){const i=this.bh;i!==null&&i._2(this)}}Hm(t){if(!t){const i=this.bh;i!==null&&i.Q2(this)}}Zf(){const t=this.data;if(t!==null){const i=this.diagram;if(i!==null){const e=i.model;e!==null&&e.removeNodeData(t)}}}get containingGroupChanged(){return this.E!==null?this.E.ly:null}set containingGroupChanged(t){const i=this.containingGroupChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"containingGroupChanged"),this.Qi(),this.E.ly=t,this.i("containingGroupChanged",i,t))}findSubGraphLevel(){return this.tN(this)}tN(t){const i=t.containingGroup;if(i!==null)return 1+this.tN(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.tN(e)}return 0}findTopLevelPart(){return this.iN(this)}iN(t){const i=t.containingGroup;if(i!==null)return this.iN(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.iN(e)}return t}get isTopLevel(){return!(this.containingGroup!==null||this instanceof Node&&this.labeledLink!==null)}isMemberOf(t){return t instanceof Group?this.eN(this,t):!1}eN(t,i){if(t===i||i===null)return!1;const e=t.containingGroup;if(e!==null&&(e===i||this.eN(e,i)))return!0;if(t instanceof Node){const s=t.labeledLink;if(s!==null)return this.eN(s,i)}return!1}findCommonContainingGroup(t){if(t===null)return null;if(Debug&&Util.s(t,Part,Part,"findCommonContainingGroup:other"),this===t)return this.containingGroup;let i=this;for(;i!==null;){if(i instanceof Group&&i.yb(!0),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}let e=null;for(i=t;i!==null;){if(i.eT()){e=i;break}if(i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}for(i=this;i!==null;){if(i instanceof Group&&i.yb(!1),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}return e}get layoutConditions(){return this.E!==null?this.E.hy:127}set layoutConditions(t){const i=this.layoutConditions;i!==t&&(Debug&&Util.t(t,"number",Part,"layoutConditions"),this.Qi(),this.E.hy=t,this.i("layoutConditions",i,t))}canLayout(){if(!this.isLayoutPositioned||!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary||this instanceof Node&&this.isLinkLabel)}jI(t){if(!this.isLayoutPositioned||!(t&this.layoutConditions))return!1;const i=this.layer;if(i!==null&&i.isTemporary||this instanceof Node&&this.isLinkLabel)return!1;const e=this.diagram;return!(e!==null&&e.undoManager.isUndoingRedoing)}invalidateLayout(t){if(t===void 0&&(t=16777215),!this.jI(t))return;const i=this.bh;if(i!==null){const e=i.layout;e!==null?e.invalidateLayout():i.invalidateLayout(t)}else{const e=this.diagram;if(e!==null){const s=e.layout;s!==null&&s.invalidateLayout()}}}RA(){if(!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary)}static lh(t,i,e,s,n,o){if(o===void 0&&(o=null),!t.has(i)&&!(o!==null&&!o(i))&&!(i instanceof Adornment)){if(t.add(i),i instanceof Node){if(e&&i instanceof Group){const r=i.memberParts;for(;r.next();){const l=r.value;Part.lh(t,l,e,s,n,o)}}if(n!==!1){const r=i.linksConnected;for(;r.next();){const l=r.value;if(t.has(l))continue;const h=l.fromNode,a=l.toNode,f=h===null||t.has(h),c=a===null||t.has(a);(n?f&&c:f||c)&&Part.lh(t,l,e,s,n,o)}}if(s>1){const r=i.findTreeChildrenNodes();for(;r.next();){const l=r.value;Part.lh(t,l,e,s-1,n,o)}}}else if(i instanceof Link){const r=i.labelNodes;for(;r.next();){const l=r.value;Part.lh(t,l,e,s,n,o)}}}}get dragComputation(){return this.E!==null?this.E.ay:null}set dragComputation(t){const i=this.dragComputation;i!==t&&(t!==null&&Util.t(t,"function",Part,"dragComputation"),this.Qi(),this.E.ay=t,this.i("dragComputation",i,t))}get shadowOffset(){return this.E!==null?this.E.fy:Point.rC}set shadowOffset(t){const i=this.shadowOffset;i.equals(t)||(Debug&&Util.s(t,Point,Part,"shadowOffset"),t=t.L(),this.Qi(),this.E.fy=t,this.T(),this.i("shadowOffset",i,t))}get shadowColor(){return this.E!==null?this.E.cy:"gray"}set shadowColor(t){const i=this.shadowColor;i!==t&&(Debug&&Util.t(t,"string",Part,"shadowColor"),this.Qi(),this.E.cy=t,this.T(),this.i("shadowColor",i,t))}get shadowBlur(){return this.E!==null?this.E.Pn:4}set shadowBlur(t){const i=this.shadowBlur;i!==t&&(Debug&&Util.t(t,"number",Part,"shadowBlur"),this.Qi(),this.E.Pn=t,this.T(),this.i("shadowBlur",i,t))}}class PartTemplateSettings{wi;jp;ly;_p;Qp;ty;$p;iy;ey;sy;ny;oy;ry;Jp;Zp;Wp;vp;ay;hy;fy;cy;Pn;constructor(){this.wi=!1,this.jp=null,this.ly=null,this._p=null,this.Qp="",this.ty=null,this.$p=null,this.iy=null,this.ey="",this.sy=Size.xw,this.ny=null,this.oy="",this.ry=Spot.Default,this.Jp="",this.Zp=Spot.TopLeft,this.Wp=Point.nC,this.vp=Point.oC,this.ay=null,this.hy=127,this.fy=Point.rC,this.cy="gray",this.Pn=4}copy(){const t=new PartTemplateSettings;return t.jp=this.jp,t.ly=this.ly,t._p=this._p,t.Qp=this.Qp,t.ty=this.ty,t.$p=this.$p,t.iy=this.iy,t.ey=this.ey,t.sy=this.sy.L(),t.ny=this.ny,t.oy=this.oy,t.ry=this.ry.L(),t.Jp=this.Jp,t.Zp=this.Zp.L(),t.Wp=this.Wp.L(),t.vp=this.vp.L(),t.ay=this.ay,t.hy=this.hy,t.fy=this.fy.L(),t.cy=this.cy,t.Pn=this.Pn,t}}class Adornment extends Part{ys;Et;sM;nM;gc;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.N&=-257,this.ul="Adornment",this.ys=null,this.sM=0,this.nM=!1,this.Et=null,this.gc=null,i&&Object.assign(this,i)}toString(){const t=this.adornedPart;return"Adornment("+this.category+")"+(t!==null?t.toString():"")}updateRelationshipsFromData(){}md(t){const i=this.adornedObject,e=i?.part;if(!(e instanceof Link)||!(i instanceof Shape))return;const s=e.path;let n=s.geometry;e.md(t),n=s.geometry;const o=this.D.h,r=o.length;for(let l=0;lh instanceof Placeholder);l instanceof Placeholder&&(this.Et===null?this.Et=l:Debug&&this.Et!==l&&Util.n("Cannot insert a second Placeholder into the visual tree of an Adornment."))}}else t===4&&i==="elements"&&this.Et!==null&&(s===this.Et?this.Et=null:s instanceof Panel&&this.Et.isContainedBy(s)&&(this.Et=null));super.ec(t,i,e,s,n,o,r)}updateAdornments(){}Zf(){}}var PortSpreading=(w=>(w[w.None=0]="None",w[w.Evenly=1]="Evenly",w[w.Packed=2]="Packed",w))(PortSpreading||{});class Node extends Part{z;bt;Ac;gl;kh;ae;ni;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.z=13,this.bt=null,this.ni=new List,this.Ac=null,this.gl=null,this.ae=null,this.kh=!1,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.z=this.z,this.bt!==null&&(this.bt.wi?t.bt=this.bt:t.bt=this.bt.copy())}Ho(t){super.Ho(t),t.invalidateConnectedLinks(),t.gl=this.gl,t.ae=null}static SpreadingNone=0;static SpreadingEvenly=1;static SpreadingPacked=2;ml(){this.bt===null?this.bt=new NodeTemplateSettings:this.bt.wi&&(this.bt=this.bt.copy())}ch(){super.ch(),this.bt!==null&&(this.bt.wi=!0)}sT(t){t!==null&&(this.gl===null&&(this.gl=new GSet),this.gl.add(t))}nT(t){t!==null&&this.gl!==null&&this.gl.delete(t)}oT(t,i,e){if(t===null||this.gl===null)return null;const s=this.gl.iterator;for(;s.next();){const n=s.value;if(n.uy===this&&n.wb===t&&n.sN===i&&n.nN===e||n.uy===t&&n.wb===this&&n.sN===e&&n.nN===i)return n}return null}invalidateLinkBundle(t,i,e){i==null&&(i=""),e==null&&(e="");const s=this.oT(t,i,e);s!==null&&s.Ed()}ec(t,i,e,s,n,o,r){t===3&&i==="elements"?this.ae=null:t===4&&i==="elements"&&(this.ae=null),super.ec(t,i,e,s,n,o,r)}invalidateConnectedLinks(t){const i=this.linksConnected;for(;i.next();){const e=i.value;t!==void 0&&t.has(e)||(this._i(e.fromPort),this._i(e.toPort),e.invalidateRoute())}}hL(t){const i=this.linksConnected;for(;i.next();){const e=i.value;e.fromPort!==t&&e.toPort!==t||(this._i(e.fromPort),this._i(e.toPort),e.invalidateRoute())}}_i(t){if(t===null)return;const i=t.sd;i!==null&&i.Ed();const e=t.part,s=e.containingGroup;s!==null&&!e.isVisible()&&s._i(s.port)}$r(){return!0}get portSpreading(){return this.bt!==null?this.bt.gy:1}set portSpreading(t){const i=this.portSpreading;if(i!==t){Debug&&t!==0&&t!==1&&t!==2&&Util.n("Node.portSpreading can only be set to PortSpreading.None, PortSpreading.Evenly, or PortSpreading.Packed, not: "+t),this.ml(),this.bt.gy=t,this.i("portSpreading",i,t);const e=this.diagram;if(e!==null&&e.undoManager.isUndoingRedoing)return;this.invalidateConnectedLinks()}}get avoidable(){return(this.z&8)!==0}set avoidable(t){const i=(this.z&8)!==0;if(i!==t){Debug&&Util.t(t,"boolean",Node,"avoidable"),this.z=this.z^8;const e=this.diagram;e!==null&&e.HP(this),this.i("avoidable",i,t)}}get avoidableMargin(){return this.bt!==null?this.bt.my:Margin.uC}set avoidableMargin(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Node,"avoidableMargin");const i=this.avoidableMargin;if(!i.equals(t)){t=t.L(),this.ml(),this.bt.my=t;const e=this.diagram;e!==null&&e.HP(this),this.i("avoidableMargin",i,t)}}canAvoid(){return this.avoidable&&!this.isLinkLabel}getAvoidableRect(t){return t.set(this.actualBounds),t.addMargin(this.avoidableMargin),t}findVisibleNode(){let t=this;for(;t!==null&&!t.isVisible();)t=t.containingGroup;return t}isVisible(){if(!super.isVisible())return!1;let t=!0,i=1;const e=this.diagram;if(e!==null){if(e.animationManager.ux(this))return!0;t=e.isTreePathToChildren,i=e.treeCollapsePolicy}if(i===1){const n=this.findTreeParentNode();if(n!==null&&!n.isTreeExpanded)return!1}else if(i===2){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&h.isTreeExpanded){r=!0;break}}}if(o&&!r)return!1}else if(i===3){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&!h.isTreeExpanded){r=!0;break}}}if(o&&r)return!1}const s=this.labeledLink;return s!==null?s.isVisible():!0}Ki(t){super.Ki(t);const i=this.linksConnected;for(;i.next();){const e=i.value;if(t&&this.containingGroup!==null){const s=e.getOtherNode(this);s!==null&&!s.isMemberOf(this.containingGroup)&&e.invalidateRoute()}e.Ki(t)}}get linksConnected(){return this.ni.iterator}findExternalTreeLinksConnected(){const t=new GSet,i=new GSet;return this.rT(this,t,i),i.iterator}rT(t,i,e){if(t===null||i.has(t))return;i.add(t);let s=!0;const n=this.diagram;n!==null&&(s=n.isTreePathToChildren),t.linksConnected.each(o=>{o.isTreeLink?(s?o.fromNode===t:o.toNode===t)&&this.rT(s?o.toNode:o.fromNode,i,e):e.add(o)})}findLinksConnected(t){if(t===void 0&&(t=null),t===null)return this.ni.iterator;Debug&&Util.t(t,"string",Node,"findLinksConnected:pid");const i=new ListIterator(this.ni),e=this;return i.predicate=s=>s.fromNode===e&&s.fromPortId===t||s.toNode===e&&s.toPortId===t,i}findLinksOutOf(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findLinksOutOf:pid");const i=new ListIterator(this.ni),e=this;return i.predicate=s=>s.fromNode!==e?!1:t===null?!0:s.fromPortId===t,i}findLinksInto(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findLinksInto:pid");const i=new ListIterator(this.ni),e=this;return i.predicate=s=>s.toNode!==e?!1:t===null?!0:s.toPortId===t,i}findNodesConnected(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findNodesConnected:pid");let i=null,e=null;const s=this.ni.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this){if(t===null||n.fromPortId===t){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}else if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesOutOf(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findNodesOutOf:pid");let i=null,e=null;const s=this.ni.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this&&(t===null||n.fromPortId===t)){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesInto(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findNodesInto:pid");let i=null,e=null;const s=this.ni.iterator;for(;s.next();){const n=s.value;if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findLinksBetween(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),Debug&&(Util.s(t,Node,Node,"findLinksBetween:othernode"),i!==null&&Util.t(i,"string",Node,"findLinksBetween:pid"),e!==null&&Util.t(e,"string",Node,"findLinksBetween:otherpid"));const s=new ListIterator(this.ni),n=this;return s.predicate=o=>o.fromNode===n&&o.toNode===t&&(i===null||o.fromPortId===i)&&(e===null||o.toPortId===e)||o.fromNode===t&&o.toNode===n&&(e===null||o.fromPortId===e)&&(i===null||o.toPortId===i),s}findLinksTo(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),Debug&&(Util.s(t,Node,Node,"findLinksTo:othernode"),i!==null&&Util.t(i,"string",Node,"findLinksTo:pid"),e!==null&&Util.t(e,"string",Node,"findLinksTo:otherpid"));const s=new ListIterator(this.ni),n=this;return s.predicate=o=>!(o.fromNode!==n||o.toNode!==t||i!==null&&o.fromPortId!==i||e!==null&&o.toPortId!==e),s}get linkConnected(){return this.bt!==null?this.bt.py:null}set linkConnected(t){const i=this.linkConnected;i!==t&&(t!==null&&Util.t(t,"function",Node,"linkConnected"),this.ml(),this.bt.py=t,this.i("linkConnected",i,t))}get linkDisconnected(){return this.bt!==null?this.bt.yy:null}set linkDisconnected(t){const i=this.linkDisconnected;i!==t&&(t!==null&&Util.t(t,"function",Node,"linkDisconnected"),this.ml(),this.bt.yy=t,this.i("linkDisconnected",i,t))}get linkValidation(){return this.bt!==null?this.bt.Ll:null}set linkValidation(t){const i=this.linkValidation;i!==t&&(t!==null&&Util.t(t,"function",Node,"linkValidation"),this.ml(),this.bt.Ll=t,this.i("linkValidation",i,t))}xb(t,i){this._i(i);const e=this.ni.has(t);if(e||this.ni.add(t),!e||t.fromNode===t.toNode){const s=this.linkConnected;if(s!==null){let n=!0;const o=this.diagram;o!==null&&(n=o.j,o.j=!0),s(this,t,i),o!==null&&(o.j=n)}}if(!e){if(!t.isTreeLink)return;const s=t.fromNode,n=t.toNode;if(s!==null&&n!==null&&s!==n){let o=!0;const r=this.diagram;r!==null&&(o=r.isTreePathToChildren);const l=o?n:s,h=o?s:n;if(l.kh||(l.kh=h),h.isTreeLeaf){if(r!==null&&r.undoManager.isUndoingRedoing)return;o?s===h&&(h.isTreeLeaf=!1):n===h&&(h.isTreeLeaf=!1)}}}}bb(t,i){this._i(i);const e=this.ni.delete(t);let s=null;if(e||t.toNode===t.fromNode){const n=this.linkDisconnected;if(s=this.diagram,n!==null){let o=!0;s!==null&&(o=s.j,s.j=!0),n(this,t,i),s!==null&&(s.j=o)}}if(e){if(!t.isTreeLink)return;let n=!0;s!==null&&(n=s.isTreePathToChildren);const o=n?t.toNode:t.fromNode,r=n?t.fromNode:t.toNode;if(o!==null&&(o.kh=!1),r!==null&&!r.isTreeLeaf)if(r.ni.count===0){if(r.kh=null,s!==null&&s.undoManager.isUndoingRedoing)return;r.isTreeLeaf=!0}else r.w0()}}w0(){if(this.kh=!1,this.ni.count===0)return;let t=!0;const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;i!==null&&(t=i.isTreePathToChildren);const e=this.ni.iterator;for(;e.next();){const s=e.value;if(s.isTreeLink){if(t){if(s.fromNode===this){this.isTreeLeaf=!1;return}}else if(s.toNode===this){this.isTreeLeaf=!1;return}}}this.isTreeLeaf=!0}updateRelationshipsFromData(){const t=this.diagram;t!==null&&t.partManager.updateRelationshipsFromData(this)}Gm(t){if(super.Gm(t),!t){this.w0();const i=this.Ac;i!==null&&i.lT(this)}}Hm(t){if(super.Hm(t),!t){const i=this.Ac;i!==null&&i.hT(this)}}Zf(){if(this.ni.count>0){const t=this.diagram;if(t!==null){const i=t.commandHandler!==null?t.commandHandler.deletesConnectedLinks:!0,s=this.ni.copy().iterator;for(;s.next();){const n=s.value;i?t.remove(n):(n.fromNode===this&&(n.fromNode=null),n.toNode===this&&(n.toNode=null))}}}this.labeledLink=null,super.Zf()}get isLinkLabel(){return this.Ac!==null}get labeledLink(){return this.Ac}set labeledLink(t){const i=this.Ac;if(i!==t){Debug&&t!==null&&Util.s(t,Link,Node,"labeledLink");const e=this.diagram,s=this.data;if(i!==null){if(i.hT(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=i.data,o=e.model;if(n!==null&&o.Ea()){const r=o.getKeyForNodeData(s);r!==void 0&&o.removeLabelKeyForLinkData(n,r)}}this.containingGroup=null}if(this.Ac=t,t!==null){if(t.lT(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=t.data,o=e.model;if(n!==null&&o.Ea()){const r=o.getKeyForNodeData(s);r!==void 0&&o.addLabelKeyForLinkData(n,r)}}this.containingGroup=t.containingGroup}this.hc(),this.i("labeledLink",i,t)}}findVisiblePort(t){let i=t;for(;i!==null&&(!i.actualBounds.isReal()||!i.isVisibleObject());)i=i.panel;return i===null?this.port:i}findPort(t){if(Debug&&Util.t(t,"string",Node,"findPort:pid"),this.ae===null){if(t===""&&this.Mn===!1)return this;this.aT()}let i=this.ae.get(t);return i!==null||t!==""&&(i=this.ae.get(""),i!==null)?i:this}get port(){return this.findPort("")}get ports(){return this.ae===null&&this.aT(),this.ae.iteratorValues}aT(){this.ae===null?this.ae=new GMap:this.ae.clear(),this.walkVisualTreeFrom(this,(t,i)=>t.pL(i)),this.ae.count===0&&this.ae.set("",this)}pL(t){const i=t.portId;i!==null&&this.ae!==null&&this.ae.set(i,t)}S2(t,i){const e=t.portId;if(e!==null){this.ae!==null&&this.ae.delete(e);const s=this.diagram;if(s!==null&&i){let n=null;const o=this.findLinksConnected(e);for(;o.next();){const r=o.value;n===null&&(n=Util.at()),n.push(r)}if(n!==null){for(let r=0;r!(!n.isTreeLink||n.fromNode!==s):e.predicate=n=>!(!n.isTreeLink||n.toNode!==s),e}findTreeChildrenNodes(){let t=!0;const i=this.diagram;i!==null&&(t=i.isTreePathToChildren);let e=null,s=null;const n=this.ni.iterator;if(t)for(;n.next();){const o=n.value;if(o.isTreeLink&&o.fromNode===this){const r=o.toNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}else for(;n.next();){const o=n.value;if(o.isTreeLink&&o.toNode===this){const r=o.fromNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}return e!==null?e.iterator:s!==null?new SingletonIterator(s):EmptyIterator.instance}findTreeParts(t){t===void 0&&(t=1/0),Util.t(t,"number",Node,"findTreeParts:level");const i=new GSet;return Part.lh(i,this,!1,t,!0),i}collapseTree(t){t===void 0&&(t=1),Util.r(t,Node,"collapseTree:level"),t<1&&(t=1);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.fT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}fT(t,i,e,s,n,o){if(e>1){const r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);h!==null&&h!==this&&!t.has(h)&&(t.add(h),h.fT(t,i,e-1,s,n,o))}}else this.cT(t,i,s,n,o)}cT(t,i,e,s,n){const o=s===this?!0:this.isTreeExpanded,r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);if(h!==null&&h!==this){const a=t.has(h);if(a||t.add(h),o){const f=i?h.findNodesInto():h.findNodesOutOf(),c=this;f.all(u=>u===c||!u.isTreeExpanded)&&e.Ef(h,s),h.gh(),h.Ki(!1)}h.isTreeExpanded&&(h.wasTreeExpanded=h.isTreeExpanded,a||h.cT(t,i,e,s,n))}}this.isTreeExpanded=!1}expandTree(t){t===void 0&&(t=2),Util.r(t,Node,"expandTree:level"),t<2&&(t=2);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.uT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}uT(t,i,e,s,n,o){const r=n===this?!1:this.isTreeExpanded,l=i?this.findLinksOutOf():this.findLinksInto();for(;l.next();){const h=l.value;if(!h.isTreeLink)continue;r||h.Te||h.invalidateRoute();const a=h.getOtherNode(this);if(a!==null&&a!==this&&!t.has(a)){if(t.add(a),!r){a.Ki(!0),a.gh();const f=i?a.findNodesInto():a.findNodesOutOf(),c=this;f.all(u=>u===c||!u.isTreeExpanded)&&s.Of(a,n)}(e>2||a.wasTreeExpanded)&&(a.wasTreeExpanded=!1,a.uT(t,i,e-1,s,n,o))}}this.isTreeExpanded=!0}get isTreeExpanded(){return(this.z&1)!==0}set isTreeExpanded(t){const i=(this.z&1)!==0;if(i!==t){Debug&&Util.t(t,"boolean",Node,"isTreeExpanded"),this.z=this.z^1;const e=this.diagram;this.i("isTreeExpanded",i,t);const s=this.treeExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.j,e.j=!0),s(this),e!==null&&(e.j=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.Ki(t);return}t?this.expandTree():this.collapseTree()}}get wasTreeExpanded(){return(this.z&2)!==0}set wasTreeExpanded(t){const i=(this.z&2)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Node,"wasTreeExpanded"),this.z=this.z^2,this.i("wasTreeExpanded",i,t))}get treeExpandedChanged(){return this.bt!==null?this.bt.wy:null}set treeExpandedChanged(t){const i=this.treeExpandedChanged;i!==t&&(t!==null&&Util.t(t,"function",Node,"treeExpandedChanged"),this.ml(),this.bt.wy=t,this.i("treeExpandedChanged",i,t))}get isTreeLeaf(){return(this.z&4)!==0}set isTreeLeaf(t){const i=(this.z&4)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Node,"isTreeLeaf"),this.z=this.z^4,this.i("isTreeLeaf",i,t))}get isTreeRoot(){return this.findTreeParentLink()===null}}class NodeTemplateSettings{wi;py;yy;Ll;wy;my;gy;xy;by;rh;ky;constructor(){this.wi=!1,this.py=null,this.yy=null,this.Ll=null,this.wy=null,this.my=Margin.uC,this.gy=1,this.xy=null,this.by=null,this.rh=null,this.ky=null}copy(){const t=new NodeTemplateSettings;return t.py=this.py,t.yy=this.yy,t.Ll=this.Ll,t.wy=this.wy,t.my=this.my.L(),t.gy=this.gy,t.xy=this.xy,t.by=this.by,t.rh=this.rh,t.ky=this.ky,t}}var LinkAdjusting=(w=>(w[w.None=0]="None",w[w.End=17]="End",w[w.Scale=18]="Scale",w[w.Stretch=19]="Stretch",w))(LinkAdjusting||{}),Routing=(w=>(w[w.Normal=1]="Normal",w[w.Orthogonal=2]="Orthogonal",w[w.AvoidsNodes=6]="AvoidsNodes",w[w.AvoidsNodesStraight=7]="AvoidsNodesStraight",w))(Routing||{}),Curve=(w=>(w[w.None=0]="None",w[w.Bezier=9]="Bezier",w[w.JumpGap=10]="JumpGap",w[w.JumpOver=11]="JumpOver",w))(Curve||{});class Link extends Part{Dt;go;mo;Bd;po;yo;Vd;Lc;zd;Xd;Yd;Ba;Kd;$s;Ni;Ie;Lr;Tc;ir;oN;rN;kb;lN;hN;Sy;Sb;mt;er;static Va=null;static za=null;gc;aN;fN;constructor(t){super(Panel.Link),this.Dt=8,this.go=null,this.mo="",this.Bd=null,this.po=null,this.yo="",this.Vd=null,this.Lc=0,this.zd=0,this.Xd=0,this.Yd=NaN,this.Ba=1,this.Kd=.5,this.$s=null,this.Ni=new List().w(),this.Ie=null,this.Lr=null,this.Tc=new Rect,this.mt=new Geometry,this.ir=null,this.er=null,this.oN=null,this.rN=null,this.aN=0,this.fN=0,this.kb=new Point,this.lN=null,this.hN=null,this.Sy=null,this.Sb=NaN,this.Z=null,this.gc=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Dt=this.Dt&-113,t.mo=this.mo,t.Bd=this.Bd,t.yo=this.yo,t.Vd=this.Vd,t.Lc=this.Lc,t.zd=this.zd,t.Xd=this.Xd,t.Yd=this.Yd,t.Ba=this.Ba,t.Kd=this.Kd,this.Z!==null&&(t.Z=this.Z.copy())}Ho(t){super.Ho(t),this.mo=t.mo,this.yo=t.yo,t.Ie=null,t.invalidateRoute(),t.er=this.er;const i=t.fromPort;i!==null&&t.fromNode._i(i);const e=t.toPort;e!==null&&t.toNode._i(e)}fi(t){t in Routing||t in Curve||t in LinkAdjusting?Link.cN(t)?this.routing=t:t===9||t===10||t===11?this.curve=t:t===17||t===18||t===19?this.adjusting=t:t===1||t===0||Util.n("Unknown Link enum value for a Link property: "+t):super.fi(t)}static Normal=1;static Orthogonal=2;static AvoidsNodes=6;static AvoidsNodesStraight=7;static None=0;static Bezier=9;static JumpGap=10;static JumpOver=11;static End=17;static Scale=18;static Stretch=19;static OrientAlong=21;static OrientPlus90=22;static OrientMinus90=23;static OrientOpposite=24;static OrientUpright=25;static OrientPlus90Upright=26;static OrientMinus90Upright=27;static OrientUpright45=28;static vI=8;static JI=16;static ZI=14;static Xa=8;je(){this.Z===null&&(this.Z=new LinkSettings)}oI(t,i,e){const s=t.segmentIndex,n=t.segmentFraction;let o=t.alignmentFocus;const r=t.segmentOrientation,l=t.segmentOffset;let h=0,a=0,f=0,c=0;if(isNaN(s)){const C=this.mt,P=Util.at();C.getPointAndAngleAlongPath(n,P);const N=Point.H(P[0],P[1]);if(N.add(this.getPoint(0)),C.type===1)N.offset(-C.startX,-C.startY);else{const T=C.figures.first();N.offset(-T.startX,-T.startY)}c=P[2],r!==0&&(f=this.computeAngle(t,r,c),t.angle=f),h=N.x,a=N.y,Point.o(N),Util.nt(P)}else if(s<-i||s>=i){const C=Point.a();this.ML(C),c=this.midAngle,r!==0&&(f=this.computeAngle(t,r,c),t.angle=f),h=C.x,a=C.y,Point.o(C)}else{let C,P,N=0;if(s>=0?(C=e.h[s],P=s0?e.h[N-1]:C),C.equalsApprox(P)){let T,L;s>=0?(T=s>0?e.h[s-1]:C,L=s1?e.h[N-2]:P);const D=T.distanceSquaredPoint(C),F=P.distanceSquaredPoint(L);D>F+10?c=s>=0?T.directionPoint(C):C.directionPoint(T):F>D+10?c=s>=0?P.directionPoint(L):L.directionPoint(P):c=s>=0?T.directionPoint(L):L.directionPoint(T)}else c=s>=0?C.directionPoint(P):P.directionPoint(C);r!==0&&(f=this.computeAngle(t,r,c),t.angle=f),h=C.x+(P.x-C.x)*n,a=C.y+(P.y-C.y)*n}if(o.isNone()){t.location=new Point(h,a);return}else o.isNoSpot()&&(o=Spot.Center);const u=Transform.a();u.Vi(),u.rt(t.scale,t.scale),u.ms(t.angle,0,0);const d=t.naturalBounds,m=Rect.H(0,0,d.width,d.height),g=Point.a();g.setRectSpot(m,o),u.Pt(g);let p=-g.x,y=-g.y;const x=d.width,k=d.height,b=Point.a();b.c(l);const S=isNaN(l.x),M=isNaN(l.y);if(S||M){const C=x/2+3,P=k/2+3,N=c>=45&&c<=135,T=c>=225&&c<=315;r===0&&(N||T)?(b.x=M?C:l.y,b.y=S?P:l.x,N?s>=0||isNaN(s)&&n<.5||S&&(b.y=-P):T&&((s>=0||isNaN(s)&&n<.5)&&S&&(b.y=-P),M&&(b.x=-C))):(S&&(s>=0||isNaN(s)&&n<.5?b.x=C:b.x=-C),M&&(b.y=-P),b.rotate(c))}else b.rotate(c);h+=b.x,a+=b.y,u.Cw(m),p+=m.x,y+=m.y;const A=Point.H(h+p,a+y);t.move(A),Point.o(A),Point.o(b),Point.o(g),Rect.o(m),Transform.o(u)}$r(){let t=this.fromNode;if(t!==null){const e=t.findVisibleNode();if(e!==null&&(t=e),t.rs()||t.nh())return!1}let i=this.toNode;if(i!==null){const e=i.findVisibleNode();if(e!==null&&(i=e),i.rs()||i.nh())return!1}return!0}b2(t,i,e){return!1}k2(){}Ae(){return!1}computeAngle(t,i,e){return Link.computeAngle(i,e)}static computeAngle(t,i){let e=0;switch(t){default:case 0:e=0;break;case 21:e=i;break;case 22:e=i+90;break;case 23:e=i-90;break;case 24:e=i+180;break;case 25:e=Geo.vg(i),e>90&&e<270&&(e-=180);break;case 26:e=Geo.vg(i+90),e>90&&e<270&&(e-=180);break;case 27:e=Geo.vg(i-90),e>90&&e<270&&(e-=180);break;case 28:if(e=Geo.vg(i),e>45&&e<135||e>225&&e<315)return 0;e>90&&e<270&&(e-=180);break}return Geo.vg(e)}get fromNode(){return this.go}set fromNode(t){const i=this.go;if(i!==t){Debug&&t!==null&&Util.s(t,Node,Link,"fromNode");const e=this.fromPort;i!==null&&(this.po!==i&&i.bb(this,e),this.My(),this.invalidateLayout(2)),this.go=t,t!==null&&this.Ki(t.isVisible()),this.ir=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.j&&s.partManager.setFromNodeForLink(this,t,i);const n=this.fromPort,o=this.fromPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.j,s.j=!0),o(this,e,n),s!==null&&(s.j=r)}t!==null&&(this.po!==t&&t.xb(this,n),this.Py(),this.invalidateLayout(1)),this.i("fromNode",i,t),this.Od()}}get fromPortId(){return this.mo}set fromPortId(t){const i=this.mo;if(i!==t){Debug&&Util.t(t,"string",Link,"fromPortId");const e=this.fromPort;e!==null&&this.fromNode._i(e),this.My(),this.mo=t;const s=this.fromPort;s!==null&&this.fromNode._i(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Ea()&&r.setFromPortIdForLinkData(o,t)}if(e!==s){this.ir=null,this.invalidateRoute();const o=this.fromPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.j,n.j=!0),o(this,e,s),n!==null&&(n.j=r)}}this.Py(),this.i("fromPortId",i,t)}}get fromPort(){const t=this.go;if(t===null)return null;const i=this.mo;return t.findPort(i)}get fromPortChanged(){return this.Bd}set fromPortChanged(t){const i=this.Bd;i!==t&&(t!==null&&Util.t(t,"function",Link,"fromPortChanged"),this.Bd=t,this.i("fromPortChanged",i,t))}get toNode(){return this.po}set toNode(t){const i=this.po;if(i!==t){Debug&&t!==null&&Util.s(t,Node,Link,"toNode");const e=this.toPort;i!==null&&(this.go!==i&&i.bb(this,e),this.My(),this.invalidateLayout(2)),this.po=t,t!==null&&this.Ki(t.isVisible()),this.ir=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.j&&s.partManager.setToNodeForLink(this,t,i);const n=this.toPort,o=this.toPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.j,s.j=!0),o(this,e,n),s!==null&&(s.j=r)}t!==null&&(this.go!==t&&t.xb(this,n),this.Py(),this.invalidateLayout(1)),this.i("toNode",i,t),this.Od()}}get toPortId(){return this.yo}set toPortId(t){const i=this.yo;if(i!==t){Debug&&Util.t(t,"string",Link,"toPortId");const e=this.toPort;e!==null&&this.toNode._i(e),this.My(),this.yo=t;const s=this.toPort;s!==null&&this.toNode._i(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Ea()&&r.setToPortIdForLinkData(o,t)}if(e!==s){this.ir=null,this.invalidateRoute();const o=this.toPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.j,n.j=!0),o(this,e,s),n!==null&&(n.j=r)}}this.Py(),this.i("toPortId",i,t)}}get toPort(){const t=this.po;if(t===null)return null;const i=this.yo;return t.findPort(i)}get toPortChanged(){return this.Vd}set toPortChanged(t){const i=this.Vd;i!==t&&(t!==null&&Util.t(t,"function",Link,"toPortChanged"),this.Vd=t,this.i("toPortChanged",i,t))}get fromSpot(){return this.Z!==null?this.Z.pa:Spot.Default}set fromSpot(t){const i=this.fromSpot;if(!i.equals(t)){if(Debug&&Util.s(t,Spot,Link,"fromSpot"),t=t.L(),this.je(),this.Z.pa=t,this.i("fromSpot",i,t),i.isSide()||t.isSide()){const e=this.fromNode;e!==null&&e._i(this.fromPort)}this.invalidateRoute()}}get fromEndSegmentLength(){return this.Z!==null?this.Z.wa:NaN}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;if(i!==t){if(Debug&&Util.t(t,"number",Link,"fromEndSegmentLength"),t<0&&Util.G(t,">= 0",Link,"fromEndSegmentLength"),this.je(),this.Z.wa=t,this.i("fromEndSegmentLength",i,t),this.computeSpot(!0,this.fromPort).isSide()){const e=this.fromNode;e!==null&&e._i(this.fromPort)}this.invalidateRoute()}}get fromShortLength(){return this.Z!==null?this.Z.ba:NaN}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(Debug&&Util.t(t,"number",Link,"fromShortLength"),this.je(),this.Z.ba=t,this.le(),this.i("fromShortLength",i,t))}get toSpot(){return this.Z!==null?this.Z.ya:Spot.Default}set toSpot(t){const i=this.toSpot;if(!i.equals(t)){if(Debug&&Util.s(t,Spot,Link,"toSpot"),t=t.L(),this.je(),this.Z.ya=t,this.i("toSpot",i,t),i.isSide()||t.isSide()){const e=this.toNode;e!==null&&e._i(this.toPort)}this.invalidateRoute()}}get toEndSegmentLength(){return this.Z!==null?this.Z.xa:NaN}set toEndSegmentLength(t){const i=this.toEndSegmentLength;if(i!==t){if(Debug&&Util.t(t,"number",Link,"toEndSegmentLength"),t<0&&Util.G(t,">= 0",Link,"toEndSegmentLength"),this.je(),this.Z.xa=t,this.i("toEndSegmentLength",i,t),this.computeSpot(!1,this.toPort).isSide()){const e=this.toNode;e!==null&&e._i(this.toPort)}this.invalidateRoute()}}get toShortLength(){return this.Z!==null?this.Z.ka:NaN}set toShortLength(t){const i=this.toShortLength;i!==t&&(Debug&&Util.t(t,"number",Link,"toShortLength"),this.je(),this.Z.ka=t,this.le(),this.i("toShortLength",i,t))}Od(){const t=this.fromNode,i=this.toNode;let e=null;if(t!==null?i!==null?e=t.findCommonContainingGroup(i):e=t.containingGroup:i!==null?e=i.containingGroup:e=null,this.$I(e),this.isLabeledLink){const s=this.labelNodes;for(;s.next();){const n=s.value;n.containingGroup=e}}}$I(t){const i=this.bh;if(i!==t){i!==null&&i.Q2(this),this.bh=t,t!==null&&t._2(this);const e=this.containingGroupChanged;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.j,n.j=!0),e(this,i,t),n!==null&&(n.j=s)}this.Te&&(this.lN===i||this.hN===i)&&this.invalidateRoute()}}gh(){const t=this.containingGroup;t!==null&&this.fromNode!==t&&this.toNode!==t&&t.computesBoundsIncludingLinks&&super.gh()}getOtherNode(t){Debug&&Util.s(t,Node,Link,"getOtherNode:node");const i=this.fromNode;return t===i?this.toNode:i}getOtherPort(t){Debug&&Util.s(t,GraphObject,Link,"getOtherPort:port");const i=this.fromPort;return t===i?this.toPort:i}get isLabeledLink(){return this.$s===null?!1:this.$s.count>0}get labelNodes(){return this.$s===null?EmptyIterator.instance:this.$s.iterator}lT(t){this.$s===null&&(this.$s=new GSet),this.$s.add(t),this.u()}hT(t){this.$s!==null&&(this.$s.delete(t),this.u())}Gm(t){if(super.Gm(t),this.Ya()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.go;let e=null;i!==null&&(e=this.fromPort,i.xb(this,e));const s=this.po;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.xb(this,n)),this.Py()}}Hm(t){if(super.Hm(t),this.Ya()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.go;let e=null;i!==null&&(e=this.fromPort,i.bb(this,e));const s=this.po;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.bb(this,n)),this.My()}}Zf(){if(this.Te=!0,this.$s!==null){const i=this.diagram;if(i!==null){const s=this.$s.copy().iterator;for(;s.next();){const n=s.value;i.remove(n)}}}if(this.data!==null){const i=this.diagram;i!==null&&i.partManager.uN(this)}}updateRelationshipsFromData(){if(this.data===null)return;const i=this.diagram;i!==null&&i.partManager.updateRelationshipsFromData(this)}move(t,i){const e=i?this.location:this.position;let s=e.x;isNaN(s)&&(s=0);let n=e.y;isNaN(n)&&(n=0);const o=t.x-s,r=t.y-n;if(i===!0)super.move(t,!1);else{const h=Point.H(e.x+o,e.y+r);super.move(h,!1),Point.o(h)}this.kr(o,r);const l=this.labelNodes;for(;l.next();){const h=l.value,a=h.position;h.moveTo(a.x+o,a.y+r)}}get relinkableFrom(){return(this.Dt&1)!==0}set relinkableFrom(t){const i=(this.Dt&1)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"relinkableFrom"),this.Dt=this.Dt^1,this.i("relinkableFrom",i,t),this.invalidateAdornments())}get relinkableTo(){return(this.Dt&2)!==0}set relinkableTo(t){const i=(this.Dt&2)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"relinkableTo"),this.Dt=this.Dt^2,this.i("relinkableTo",i,t),this.invalidateAdornments())}canRelinkFrom(){if(!this.relinkableFrom)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}canRelinkTo(){if(!this.relinkableTo)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}get resegmentable(){return(this.Dt&4)!==0}set resegmentable(t){const i=(this.Dt&4)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"resegmentable"),this.Dt=this.Dt^4,this.i("resegmentable",i,t),this.invalidateAdornments())}get isTreeLink(){return(this.Dt&8)!==0}set isTreeLink(t){const i=(this.Dt&8)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"isTreeLink"),this.Dt=this.Dt^8,this.i("isTreeLink",i,t),this.fromNode!==null&&this.fromNode.w0(),this.toNode!==null&&this.toNode.w0())}get path(){const t=this.findMainElement();return t instanceof Shape?t:null}get routeBounds(){return this.updateRoute(),this.QI(this.Tc)}QI(t){let i=1/0,e=1/0;const s=this.pointsCount;if(s===0)return t.e(NaN,NaN,0,0),t;if(s===1){const n=this.getPoint(0);i=Math.min(n.x,i),e=Math.min(n.y,e),t.e(n.x,n.y,0,0)}else if(s===2){const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o)}else if(this.computeCurve()===9&&s>=3&&!this.isOrthogonal){let n=this.getPoint(0);if(i=n.x,e=n.y,t.e(i,e,0,0),s===3){const o=this.getPoint(1);i=Math.min(o.x,i),e=Math.min(o.y,e);const r=this.getPoint(2);i=Math.min(r.x,i),e=Math.min(r.y,e),Geo.gu(n.x,n.y,o.x,o.y,o.x,o.y,r.x,r.y,.5,t)}else for(let o=3;o=s&&(o=s-1);const l=this.getPoint(o-1),h=this.getPoint(o);Geo.gu(n.x,n.y,r.x,r.y,l.x,l.y,h.x,h.y,.5,t),i=Math.min(h.x,i),e=Math.min(h.y,e),n=h}}else{const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o);for(let r=2;r=15||this.computeCurve()===9)){this.mt.getPointAlongPath(.5,t),t.add(this.getPoint(0));const a=this.mt.figures.first();return t.offset(-a.startX,-a.startY),t}if(this.computeCurve()===9){if(i===3){const c=this.getPoint(0),u=this.getPoint(1),d=this.getPoint(2);return Geo.wC(c.x,c.y,u.x,u.y,u.x,u.y,d.x,d.y,t),t}const a=(i-1)/3|0,f=(a/2|0)*3;if(a%2===1){const c=this.getPoint(f),u=this.getPoint(f+1),d=this.getPoint(f+2),m=this.getPoint(f+3);return Geo.wC(c.x,c.y,u.x,u.y,d.x,d.y,m.x,m.y,t),t}else return t.c(this.getPoint(f)),t}const e=this.flattenedLengths,s=this.flattenedTotalLength;let n=0,o=0,r=0;for(;ns/2));)n+=r,o++;const l=this.getPoint(o),h=this.getPoint(o+1);if(Math.abs(l.x-h.x)<1)l.y>h.y?t.e(l.x,l.y-(s/2-n)):t.e(l.x,l.y+(s/2-n));else if(Math.abs(l.y-h.y)<1)l.x>h.x?t.e(l.x-(s/2-n),l.y):t.e(l.x+(s/2-n),l.y);else{const a=(s/2-n)/r,f=a*(h.x-l.x),c=a*(h.y-l.y);t.e(l.x+f,l.y+c)}return t}get midAngle(){return this.updateRoute(),this.computeMidAngle()}computeMidAngle(){const t=this.pointsCount;if(t<2)return NaN;if(t===2){const h=this.getPoint(0),a=this.getPoint(1);return h.directionPoint(a)}if(this.isOrthogonal&&(this.computeCorner()>=15||this.computeCurve()===9))return this.mt.getAngleAlongPath(.5);if(this.computeCurve()===9&&t>=4){const h=(t-1)/3|0;let a=(h/2|0)*3;if(h%2===1){a=Math.floor(a);const f=this.getPoint(a),c=this.getPoint(a+1),u=this.getPoint(a+2),d=this.getPoint(a+3);return Geo.XD(f.x,f.y,c.x,c.y,u.x,u.y,d.x,d.y)}else if(a>0&&a+1e/2));)s+=o,n++;const r=this.getPoint(n),l=this.getPoint(n+1);if(Math.abs(r.x-l.x)<1&&Math.abs(r.y-l.y)<1){if(n>0&&n+2l.y?270:90;if(Math.abs(r.y-l.y)<1)return r.x>l.x?180:0}return r.directionPoint(l)}_I(){if(this.Sy===null){this.Te||this.Mb();const t=this.Sy=[];this.tO(t)}}get flattenedLengths(){return this._I(),this.Sy}get flattenedTotalLength(){let t=this.Sb;if(isNaN(t)){const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=3){let g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e);m=this.adjustPoints(0,g,o-1,p),m&&(g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e),this.adjustPoints(0,g,o-1,p))}m||(this.clearPoints(),u?this.iO(i,e,r,s,n,l):this.eO(i,e,r,s,n,l))}else{const m=this.isAvoiding;d&&(c&&m||f)&&this.clearPoints();const g=f?this.computeCurviness():0,p=this.getLinkPoint(i,e,r,!0,c,s,n);let y=0,x=0,k=0;if(c||!h||f){let N=this.computeEndSegmentLength(i,e,r,!0);if(k=this.getLinkDirection(i,e,p,r,!0,c,s,n),f&&(h||r.equals(l)||!c&&r.x+l.x===1&&r.y+l.y===1)&&(k-=c?90:30,g<0&&(k-=180)),k<0?k+=360:k>=360&&(k-=360),f&&(N+=Math.abs(g)*(c?1:2)),k===0?y=N:k===90?x=N:k===180?y=-N:k===270?x=-N:(y=N*Math.cos(k*Math.PI/180),x=N*Math.sin(k*Math.PI/180)),r.isNoSpot()&&f){const T=e.getDocumentPoint(Spot.Center,Point.a()),L=Point.H(T.x+y*1e3,T.y+x*1e3);this.getLinkPointFromPoint(i,e,T,L,!0,p),Point.o(T),Point.o(L)}}const b=this.getLinkPoint(s,n,l,!1,c,i,e);let S=0,M=0,A=0;if(c||!a||f){let N=this.computeEndSegmentLength(s,n,l,!1);if(A=this.getLinkDirection(s,n,b,l,!1,c,i,e),f&&(a||r.equals(l)||!c&&r.x+l.x===1&&r.y+l.y===1)&&(A+=c?0:30,g<0&&(A+=180)),A<0?A+=360:A>=360&&(A-=360),f&&(N+=Math.abs(g)*(c?1:2)),A===0?S=N:A===90?M=N:A===180?S=-N:A===270?M=-N:(S=N*Math.cos(A*Math.PI/180),M=N*Math.sin(A*Math.PI/180)),l.isNoSpot()&&f){const T=n.getDocumentPoint(Spot.Center,Point.a()),L=Point.H(T.x+S*1e3,T.y+M*1e3);this.getLinkPointFromPoint(s,n,T,L,!1,b),Point.o(T),Point.o(L)}}let C=p;(c||!h||f)&&(C=new Point(p.x+y,p.y+x));let P=b;(c||!a||f)&&(P=new Point(b.x+S,b.y+M)),!d&&!c&&h&&o>3&&this.adjustPoints(0,p,o-2,P)?this.setPoint(o-1,b):!d&&!c&&a&&o>3&&this.adjustPoints(1,C,o-1,b)?this.setPoint(0,p):!d&&(c?o>=6:o>4)&&this.adjustPoints(1,C,o-2,P)?(this.setPoint(0,p),this.setPoint(o-1,b)):(this.clearPoints(),this.addPoint(p),(c||!h||f)&&this.addPoint(C),c&&this.addOrthoPoints(C,k,P,A,i,s),(c||!a||f)&&this.addPoint(P),this.addPoint(b))}return t.addInvalidRoute(this),!0}gN(t,i){return Math.abs(i.x-t.x)>Math.abs(i.y-t.y)?(i.x>=t.x?i.x=t.x+9e9:i.x=t.x-9e9,i.y=t.y):(i.y>=t.y?i.y=t.y+9e9:i.y=t.y-9e9,i.x=t.x),i}getLinkPointFromPoint(t,i,e,s,n,o){if(o===void 0&&(o=new Point),t===null||i===null)return o.c(e),o;if(!t.isVisible()){const u=t.findVisibleNode();u!==null&&u!==t&&(t=u,i=t.port)}let r=0,l=0,h=0,a=0,f=null,c=i.panel;if(c!==null&&!c.kn()&&(c=c.panel),c===null)r=s.x,l=s.y,h=e.x,a=e.y;else{f=c.Ks;const u=1/(f.m11*f.m22-f.m12*f.m21),d=f.m22*u,m=-f.m12*u,g=-f.m21*u,p=f.m11*u,y=u*(f.m21*f.dy-f.m22*f.dx),x=u*(f.m12*f.dx-f.m11*f.dy);r=s.x*d+s.y*g+y,l=s.x*m+s.y*p+x,h=e.x*d+e.y*g+y,a=e.x*m+e.y*p+x}return i.nc(r,l,h,a,o),f!==null&&o.O(f),o}sO(t,i){const e=t.sd;return e!==null?e.dT(i):null}Nb(t){let i=t.sd;return i===null&&(i=new Knot,i.sr=t,i.we=t.part,t.sd=i),i.dT(this)}getLinkPoint(t,i,e,s,n,o,r,l){if(l===void 0&&(l=new Point),e.isSpot()&&!this.Ud(e))return i.getDocumentPoint(e,l),l;if(e.isSide()){const f=this.Nb(i);if(f!==null){const c=f.Gd;if(l.c(c),n&&this.routing===7){const u=this.Nb(r);if(u!==null&&f.Dc=g.y&&y.y<=g.y+g.height?l.y=y.y:(e.includesSide(Spot.TopSide)||e.includesSide(Spot.BottomSide))&&y.x>=g.x&&y.x<=g.x+g.width&&(l.x=y.x),Point.o(d),Point.o(m)}}return l}}const h=i.getDocumentPoint(this.Cb(e,s),Point.a());let a=null;if(this.pointsCount>(n?6:2))a=s?this.getPoint(1):this.getPoint(this.pointsCount-2),n&&(a=this.gN(h,a.copy()));else{const f=this.computeSpot(!s,r),c=Point.a();a=r.getDocumentPoint(this.Cb(f,!s),c),n&&(a=this.gN(h,a)),Point.o(c)}return this.getLinkPointFromPoint(t,i,h,a,s,l),Point.o(h),l}getLinkDirection(t,i,e,s,n,o,r,l){let h=this.nO(t,i,e,s,n,o,r,l);if(r&&s.isNoSpot()&&r.isMemberOf(t)&&(h+=180,h>=360&&(h-=360)),this.Ud(s))return h;const a=i.getDocumentAngle();return a===0||(45<=a&&a<135?h+=90:135<=a&&a<225?h+=180:225<=a&&a<315&&(h+=270),h>=360&&(h-=360)),h}nO(t,i,e,s,n,o,r,l){if(s.isSpot())return s.x>s.y?s.x>1-s.y?0:s.x<1-s.y?270:315:s.x1-s.y?90:s.x<1-s.y?180:135:s.x<.5?225:s.x>.5?45:0;if(s.isSide()){const c=this.Nb(i);if(c!==null)switch(c.be){case 1:return 270;case 2:return 180;default:case 4:return 0;case 8:return 90}}const h=i.getDocumentPoint(Spot.Center,Point.a());let a=null;if(this.pointsCount>(o?6:2))a=n?this.getPoint(1):this.getPoint(this.pointsCount-2),o?a=this.gN(h,a.copy()):a=e;else{const c=Point.a();a=l.getDocumentPoint(Spot.Center,c),Point.o(c)}let f=0;return Math.abs(a.x-h.x)>Math.abs(a.y-h.y)?a.x>=h.x?f=0:f=180:a.y>=h.y?f=90:f=270,Point.o(h),f}computeEndSegmentLength(t,i,e,s){if(i!==null&&e.isSide()){const o=this.Nb(i);if(o!==null)return o.Ab}let n=NaN;return s?n=this.fromEndSegmentLength:n=this.toEndSegmentLength,i!==null&&isNaN(n)&&(s?n=i.fromEndSegmentLength:n=i.toEndSegmentLength),isNaN(n)&&(n=10),n}computeSpot(t,i){return i===void 0&&(i=null),t?this.oO(i||this.fromPort):this.rO(i||this.toPort)}oO(t){if(t===null)return Spot.Center;let i=this.fromSpot;return i.isDefault()&&(i=t.fromSpot),i===Spot.Default?Spot.None:i}rO(t){if(t===null)return Spot.Center;let i=this.toSpot;return i.isDefault()&&(i=t.toSpot),i===Spot.Default?Spot.None:i}Ud(t){return t===Spot.None||t.x===.5&&t.y===.5}Cb(t,i){return t.x===.5&&t.y===.5?t:Spot.Center}computeOtherPoint(t,i){if(this.computeAdjusting()!==0&&this.pointsCount>4)return this.computeMidPoint(new Point);{const e=this.sO(i,this);return e!==null?e.Gd:i.getDocumentPoint(Spot.Center)}}computeShortLength(t){if(t){let i=this.fromShortLength;if(isNaN(i)){const e=this.fromPort;e!==null&&(i=e.fromShortLength)}return isNaN(i)?0:i}else{let i=this.toShortLength;if(isNaN(i)){const e=this.toPort;e!==null&&(i=e.toShortLength)}return isNaN(i)?0:i}}Ym(t,i,e,s,n,o){if(this.pickable===!1)return!1;i===void 0&&(i=null),e===void 0&&(e=null);let r=o;if(o===void 0&&(r=Transform.a(),r.Vi()),r.af(this.O),this.containedInRect(t,r))return this.z2(i,e,n),o===void 0&&Transform.o(r),!0;if(this.intersectsRect(t,r)){let l=!1;if(!this.mc){const h=this.D.h,a=h.length;for(let f=a;f--;){const c=h[f];if(!c.visible&&c!==this.locationObject)continue;const u=c.actualBounds,d=this.naturalBounds;if(u.x>d.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;const m=c,g=Transform.a();if(g.set(r),m instanceof Panel?l=m.Ym(t,i,e,s,n,g):this.path===m?m instanceof Shape&&(l=m.LI(t,s,g)):l=m.rL(t,s,g),l){let p=m;i!==null&&(p=i(m)),p&&(e===null||e(p))&&n.add(p)}Transform.o(g)}}return o===void 0&&Transform.o(r),l||this.background!==null}return o===void 0&&Transform.o(r),!1}get isOrthogonal(){return(this.Ba&2)===2}static cN(t){return(t&2)===2}get isAvoiding(){return(this.Ba&4)===4}computeCurve(){if(this.ir===null){const t=this.fromPort,i=t!==null&&t===this.toPort,e=this.isOrthogonal;this.ir=i&&!e}return this.ir?9:this.curve}computeCorner(){if(this.curve===9)return 0;let t=this.corner;return(isNaN(t)||t<0)&&(t=10),t}findMidLabel(){const t=this.path,i=this.D.h,e=i.length;for(let n=0;n0?g-=c:g+=c;else{const p=-h/a;let y=Math.sqrt(c*c/(p*p+1));f<0&&(y=-y),m=(a<0?-1:1)*y+u,g=p*(m-u)+d}this.addPoint(r),this.addPointAt(m,g),this.addPoint(l)}else{this.addPoint(r),this.addPoint(l);const h=Rect.a();i.getDocumentBounds(h);const a=h.containsPoint(l);n.getDocumentBounds(h);const f=h.containsPoint(r);if(a||f){const c=i.getDocumentPoint(this.Cb(e,!0),new Point);this.setPoint(0,this.getLinkPointFromPoint(t,i,c,l,!0,c));const u=n.getDocumentPoint(this.Cb(o,!1),new Point);this.setPoint(1,this.getLinkPointFromPoint(s,n,u,r,!1,u))}Rect.o(h)}}iO(t,i,e,s,n,o){const r=this.getLinkPoint(t,i,e,!0,!1,s,n),l=this.getLinkPoint(s,n,o,!1,!1,t,i),h=l.x-r.x,a=l.y-r.y,f=this.computeCurviness();let c=0,u=0,d=r.x+h/3,m=r.y+a/3,g=d,p=m;Geo.p(a,0)?h>0?p-=f:p+=f:(c=-h/a,u=Math.sqrt(f*f/(c*c+1)),f<0&&(u=-u),g=(a<0?-1:1)*u+d,p=c*(g-d)+m),d=r.x+2*h/3,m=r.y+2*a/3;let y=d,x=m;Geo.p(a,0)?h>0?x-=f:x+=f:(y=(a<0?-1:1)*u+d,x=c*(y-d)+m),this.clearPoints(),this.addPoint(r),this.addPointAt(g,p),this.addPointAt(y,x),this.addPoint(l),this.setPoint(0,this.getLinkPoint(t,i,e,!0,!1,s,n)),this.setPoint(3,this.getLinkPoint(s,n,o,!1,!1,t,i))}adjustPoints(t,i,e,s){let n=this.computeAdjusting();if(this.isOrthogonal){if(n===18)return!1;n===19&&(n=17)}switch(n){case 18:return this.lO(t,i,e,s);case 19:return this.hO(t,i,e,s);case 17:return this.aO(t,i,e,s);default:return!1}}lO(t,i,e,s){const n=this.getPoint(t),o=this.getPoint(e);if(n.equalsApprox(i)&&o.equalsApprox(s))return!0;const r=n.x,l=n.y,h=o.x,a=o.y;let f=h-r,c=a-l;const u=Math.sqrt(f*f+c*c);if(Geo.q(u,0))return!0;let d=0;Geo.q(f,0)?c<0?d=-Math.PI/2:d=Math.PI/2:(d=Math.atan(c/Math.abs(f)),f<0&&(d=Math.PI-d));const m=i.x,g=i.y,p=s.x,y=s.y,x=p-m,k=y-g,b=Math.sqrt(x*x+k*k);let S=0;Geo.q(x,0)?k<0?S=-Math.PI/2:S=Math.PI/2:(S=Math.atan(k/Math.abs(x)),x<0&&(S=Math.PI-S));const M=b/u,A=S-d;this.setPoint(t,i);for(let C=t+1;C0&&(C=-C);const P=c+S*(d-c),N=u+S*(m-u);if(g!==0){const T=P+C/p,L=N-(T-P)/g;this.setPointAt(y,T,L)}else this.setPointAt(y,P,N+C)}return this.setPoint(e,s),!0}aO(t,i,e,s){if(this.isOrthogonal){let n=this.getPoint(t),o=this.getPoint(t+1),r=this.getPoint(t+2),l=o.x,h=o.y;const a=l,f=h;Geo.p(n.y,o.y)?Geo.p(o.x,r.x)?h=i.y:Geo.p(o.y,r.y)&&(l=i.x):Geo.p(n.x,o.x)&&(Geo.p(o.y,r.y)?l=i.x:Geo.p(o.x,r.x)&&(h=i.y)),this.setPointAt(t+1,l,h),n=this.getPoint(e),o=this.getPoint(e-1),r=this.getPoint(e-2);let c=o.x,u=o.y;const d=c,m=u;if(Geo.p(n.y,o.y)?Geo.p(o.x,r.x)?u=s.y:Geo.p(o.y,r.y)&&(c=s.x):Geo.p(n.x,o.x)&&(Geo.p(o.y,r.y)?c=s.x:Geo.p(o.x,r.x)&&(u=s.y)),this.setPointAt(e-1,c,u),this.EA())return this.setPointAt(t+1,a,f),this.setPointAt(e-1,d,m),!1}return this.setPoint(t,i),this.setPoint(e,s),!0}addOrthoPoints(t,i,e,s,n,o){i<0?i+=360:i>=360&&(i-=360),s<0?s+=360:s>=360&&(s-=360);const f=s;i>=315||i<45?i=0:45<=i&&i<135?i=90:135<=i&&i<225?i=180:i=270,s>=315||s<45?s=0:45<=s&&s<135?s=90:135<=s&&s<225?s=180:s=270;const c=t,u=e,d=n.actualBounds.copy(),m=o.actualBounds.copy();if(!d.isReal()||!m.isReal())return;d.inflate(Link.Xa,Link.Xa),m.inflate(Link.Xa,Link.Xa),d.unionPoint(t),m.unionPoint(e);const g=Point.a(),p=Point.a();i===0?u.x>c.x||s===270&&u.yc.x||s===90&&u.y>c.y&&m.right>c.x?(g.e(u.x,c.y),p.e(u.x,(c.y+u.y)/2),s===180?(g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1),p.x=g.x,p.y=u.y):s===270&&u.yc.y?(c.xm.bottom)?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):g.x=m.right,p.x=g.x,p.y=u.y):s===0&&c.xm.top&&c.yd.bottom)&&(s===180&&(m.containsPoint(c)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):u.yc.y&&(s===180||s===270)&&(g.y=this.computeMidOrthoPosition(c.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=d.left&&u.x<=c.x||c.x<=m.right&&c.x>=u.x?(s===90||s===270)&&(g.e(Math.max((c.x+u.x)/2,c.x),c.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yc.y&&m.leftc.y?(c.x>m.right?g.x=this.computeMidOrthoPosition(c.x,c.y,m.right,u.y,!1):c.x>m.left&&(s===270&&c.ym.bottom)?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):g.x=m.left,p.x=g.x,p.y=u.y):s===180&&c.x>m.right&&c.y>m.top&&c.yd.bottom)&&(s===0&&(m.containsPoint(c)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):u.yc.y&&(s===0||s===270)&&(g.y=this.computeMidOrthoPosition(c.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=c.x||c.x>=m.left&&c.x<=u.x?(s===90||s===270)&&(g.e(Math.min((c.x+u.x)/2,c.x),c.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yc.y||s===180&&u.xc.y||s===0&&u.x>c.x&&m.bottom>c.y?(g.e(c.x,u.y),p.e((c.x+u.x)/2,u.y),s===270?(g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0),p.x=u.x,p.y=g.y):s===180&&u.xc.x?(c.ym.right)?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):g.y=m.bottom,p.x=u.x,p.y=g.y):s===90&&c.ym.left&&c.xd.right)&&(s===270&&(m.containsPoint(c)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):u.xc.x&&(s===270||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,c.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=d.top&&u.y<=c.y||c.y<=m.bottom&&c.y>=u.y?(s===0||s===180)&&(g.e(c.x,Math.max((c.y+u.y)/2,c.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.xc.x&&m.top=c.x?(c.y>m.bottom?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,m.bottom,!0):c.y>m.top&&(s===180&&c.xm.right)?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):g.y=m.top,p.x=u.x,p.y=g.y):s===270&&c.y>m.bottom&&c.x>m.left&&c.xd.right)&&(s===90&&(m.containsPoint(c)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):u.xc.x&&(s===90||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,c.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=c.y||c.y>=m.top&&c.y<=u.y?(s===0||s===180)&&(g.e(c.x,Math.min((c.y+u.y)/2,c.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.x=3&&!Geo.q(this.smoothness,0))if(i===3){let f=this.getPoint(1);n=Math.min(r.x,f.x),o=Math.min(r.y,f.y),f=this.getPoint(2),n=Math.min(n,f.x),o=Math.min(o,f.y)}else if(this.isOrthogonal){for(let f=0;f=i&&(f=i-1);const c=this.getPoint(f);l.x=Math.min(c.x,l.x),l.y=Math.min(c.y,l.y)}n=l.x,o=l.y}else{for(let f=0;f=3&&!Geo.q(this.smoothness,0))if(i===3){const c=this.getPoint(1),u=c.x-n,d=c.y-o;let m=this.getPoint(2).copy();m.x-=n,m.y-=o,this.computeShortLength(!1)!==0&&(m=this.Fc(m,!1,l)),f.wr(u,d,u,d,m.x,m.y)}else if(this.isOrthogonal){const c=Point.H(n,o),u=Point.a();u.c(this.getPoint(1));const d=Point.H(n,o),m=Point.H(n,o);let g=this.getPoint(0),p=null;const y=this.smoothness/3;for(let S=1;S=i&&(c=i-1);const d=this.getPoint(c-1);let m=this.getPoint(c);c===i-1&&this.computeShortLength(!1)!==0&&(m=this.Fc(m.copy(),!1,Point.Lo)),f.wr(u.x-n,u.y-o,d.x-n,d.y-o,m.x-n,m.y-o)}else{const c=Point.a();c.c(this.getPoint(0));const u=Point.a();u.c(c);const d=this.computeCorner();let m=1,g=0;for(;m1);let p=this.getPoint(m);if(m>=i-1){if(!c.equals(p))this.computeShortLength(!1)!==0&&(p=this.Fc(p.copy(),!1,Point.Lo)),this.Dn(f,-n,-o,c,p,e);else if(g===0)for(m=1;mr?c>a?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):c>a?(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.q(r,h)&&Geo.q(a,c)&&(a>l?f>h?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):f>h?(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.q(r,h)&&Geo.q(h,f)||Geo.q(l,a)&&Geo.q(a,c)){const m=.5*(r+f),g=.5*(l+c);n.x=m,n.y=g,o.x=m,o.y=g}}Fc(t,i,e){const s=this.pointsCount;if(s<2)return t;if(i){const n=this.getPoint(1),o=n.x-e.x,r=n.y-e.y,l=this.Lb(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!0);a>h&&(a=h);const f=a*(o-t.x)/l,c=a*(r-t.y)/l;t.x+=f,t.y+=c}else{const n=this.getPoint(s-2),o=n.x-e.x,r=n.y-e.y,l=this.Lb(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!1);a>h&&(a=h);const f=a*(t.x-o)/l,c=a*(t.y-r)/l;t.x-=f,t.y-=c}return t}mN(t,i,e){const s=this.pointsCount;let n=t;for(;Geo.q(t.x,n.x)&&Geo.q(t.y,n.y);){if(i>=s)return s-1;n=this.getPoint(i++)}if(!Geo.q(t.x,n.x)&&!Geo.q(t.y,n.y))return i-1;let o=n;for(;Geo.q(t.x,n.x)&&Geo.q(n.x,o.x)&&(!e||(t.y>=n.y?n.y>=o.y:n.y<=o.y))||Geo.q(t.y,n.y)&&Geo.q(n.y,o.y)&&(!e||(t.x>=n.x?n.x>=o.x:n.x<=o.x));){if(i>=s)return s-1;o=this.getPoint(i++)}return i-2}uO(t,i,e,s,n,o,r,l,h,a){if(Geo.p(s.y,n.y)&&Geo.p(n.x,o.x)){let f=Math.min(h,Math.abs(n.x-l.x)/2);const c=Math.min(f,Math.abs(o.y-n.y)/2);if(f=c,Geo.p(f,0)){this.Dn(t,i,e,s,n,a),r.c(n);return}let u=n.x;const d=n.y,m=u;let g=d;n.x>s.x?(u=n.x-f,o.y>n.y?g=n.y+c:g=n.y-c):(u=n.x+f,o.y>n.y?g=n.y+c:g=n.y-c);const p=Point.H(u,d);this.Dn(t,i,e,s,p,a),Point.o(p),t.Fw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else if(Geo.p(s.x,n.x)&&Geo.p(n.y,o.y)){let f=Math.min(h,Math.abs(n.y-l.y)/2);const c=Math.min(f,Math.abs(o.x-n.x)/2);if(f=c,Geo.p(c,0)){this.Dn(t,i,e,s,n,a),r.c(n);return}const u=n.x;let d=n.y,m=u;const g=d;n.y>s.y?(d=n.y-f,o.x>n.x?m=n.x+c:m=n.x-c):(d=n.y+f,o.x>n.x?m=n.x+c:m=n.x-c);const p=Point.H(u,d);this.Dn(t,i,e,s,p,a),Point.o(p),t.Fw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else this.Dn(t,i,e,s,n,a),r.c(n)}computeJumpLength(){return 10}Dn(t,i,e,s,n,o){if(o||!this.Ya())t.yr(n.x+i,n.y+e);else{const r=this.computeJumpLength(),l=r/2,h=[];let a=0;this.isVisible()&&(a=this.dO(s,n,h));let f=s.x,c=s.y;if(a>0){if(Geo.p(s.y,n.y))if(s.x=0;){const d=Math.min(s.x,Math.max(h[u--]+l,n.x+r));t.yr(d+i,n.y+e),f=d+i,c=n.y+e;let m=Math.max(d-r,n.x);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.x);else break}const g=n.y-r+e,p=m+i,y=n.y+e;this.curve===10?t.yu(p,y,!1,!1):t.wr(f,g,p,g,p,y),f=p,c=y}}else if(Geo.p(s.x,n.x))if(s.y=0;){const d=Math.min(s.y,Math.max(h[u--]+l,n.y+r));t.yr(n.x+i,d+e),f=n.x+i,c=d+e;let m=Math.max(d-r,n.y);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.y);else break}const g=n.x-r+i,p=n.x+i,y=m+e;this.curve===10?t.yu(p,y,!1,!1):t.wr(g,c,g,y,p,y),f=p,c=y}}}t.yr(n.x+i,n.y+e)}}dO(t,i,e){const s=this.diagram;if(s===null||t.equals(i))return 0;const n=s.layers;for(;n.next();){const o=n.value;if(o!==null&&o.visible){const r=o.HM(),l=r.length;for(let h=0;h0&&e.sort((u,d)=>u-d),e.length;if(!a.isVisible()||!a.Ya())continue;const f=a.routeBounds;if(!f.isReal()||!this.routeBounds.intersectsRect(f)||this.usesSamePort(a))continue;const c=a.path;c!==null&&c.isVisibleObject()&&this.gO(t,i,e,a)}}}return e.length>0&&e.sort((o,r)=>o-r),e.length}gO(t,i,e,s){const n=Geo.p(t.y,i.y),o=s.pointsCount;let r=s.getPoint(0);const l=Point.a();for(let h=1;hr.x&&f.x>=a.x||a.xr.y&&f.y>=a.y||a.yf&&Math.min(a,c)o&&!Geo.p(a,c))return n.x=o,n.y=f,!0}else if(Geo.p(r,h)&&Geo.p(a,c)&&Math.min(o,l)a&&Math.min(f,u)r&&!Geo.p(f,u))return n.x=a,n.y=r,!0;return n.x=0,n.y=0,!1}get firstPickIndex(){return this.pointsCount<=2?0:this.isOrthogonal||!this.Ud(this.computeSpot(!0))?1:0}get lastPickIndex(){const t=this.pointsCount;return t===0?0:t<=2?t-1:this.isOrthogonal||!this.Ud(this.computeSpot(!1))?t-2:t-1}Ya(){const t=this.curve;return t===11||t===10}Pb(t){if(t||this.Ya()){const i=this.diagram;i!==null&&!i.animationManager.isTicking&&!i.th.has(this)&&(this.Tc.width!==0||this.Tc.height!==0)&&i.th.set(this,this.Tc.copy())}}invalidateOtherJumpOvers(t){const i=this.layer;if(i===null||!i.visible||i.isTemporary)return;const e=i.diagram;if(e===null||e.animationManager.isTicking)return;let s=!1;const n=e.layers;for(;n.next();){const o=n.value;if(o.visible){if(o===i){s=!0;let r=!1;const l=o.HM(),h=l.length;for(let a=0;a0&&e>0){const s=this.getPoint(0),n=t.getPoint(0);if(s.equalsApprox(n))return!0;const o=this.getPoint(i-1),r=t.getPoint(e-1);if(o.equalsApprox(r)||s.equalsApprox(r)||o.equalsApprox(n))return!0}else if(this.fromNode===t.fromNode||this.toNode===t.toNode||this.fromNode===t.toNode||this.toNode===t.fromNode)return!0;return!1}isVisible(){if(!super.isVisible())return!1;const t=this.containingGroup;let i=!0;const e=this.diagram;e!==null&&(i=e.isTreePathToChildren);const s=this.fromNode;if(s!==null){if(this.isTreeLink&&i&&!s.isTreeExpanded)return!1;if(s===t)return!0;let o=s;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=s.findVisibleNode();if(r===null||r===t)return!1}const n=this.toNode;if(n!==null){if(this.isTreeLink&&!i&&!n.isTreeExpanded)return!1;if(n===t)return!0;let o=n;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=n.findVisibleNode();if(r===null||r===t)return!1}return!0}Ki(t){if(super.Ki(t),t&&this.Pb(!1),this.er!==null&&this.er.Ed(),this.$s!==null){const e=this.$s.iterator;for(;e.next();)e.value.Ki(t)}}get adjusting(){return this.Lc}set adjusting(t){const i=this.Lc;i!==t&&(Debug&&t!==0&&t!==17&&t!==18&&t!==19&&Util.n("Link.adjusting can only be set to None, End, Scale, or Stretch, not: "+t),this.Lc=t,this.i("adjusting",i,t))}computeAdjusting(){return this.isAvoiding&&this.diagram!==null&&this.diagram.animationManager.defaultAnimation.isAnimating?17:this.Lc}get corner(){return this.zd}set corner(t){const i=this.zd;i!==t&&(Debug&&Util.t(t,"number",Link,"corner"),this.zd=t,this.le(),this.i("corner",i,t))}get curve(){return this.Xd}set curve(t){const i=this.Xd;i!==t&&(Debug&&t!==0&&t!==9&&t!==10&&t!==11&&Util.n("Link.curve can only be set to None, Bezier, JumpGap, or JumpOver, not: "+t),this.Xd=t,this.invalidateRoute(),this.le(),this.Pb(i===10||i===11||t===10||t===11),this.i("curve",i,t))}get curviness(){return this.Yd}set curviness(t){const i=this.Yd;i!==t&&(Debug&&Util.t(t,"number",Link,"curviness"),this.Yd=t,this.invalidateRoute(),this.le(),this.i("curviness",i,t))}get routing(){return this.Ba}set routing(t){const i=this.Ba;i!==t&&(Debug&&t!==1&&t!==2&&t!==6&&t!==7&&Util.n("Link.routing can only be set to Normal, Orthogonal, AvoidsNodes, not: "+t),this.Ba=t,this.isAvoiding&&this.diagram!==null&&(this.diagram.Zm=!0),this.ir=null,this.invalidateRoute(),this.Pb(Link.cN(i)||Link.cN(t)),this.i("routing",i,t))}get smoothness(){return this.Kd}set smoothness(t){const i=this.Kd;i!==t&&(Debug&&Util.t(t,"number",Link,"smoothness"),this.Kd=t,this.le(),this.i("smoothness",i,t))}Py(){const t=this.go;if(t===null)return;const i=this.po;if(i===null||!isNaN(this.curviness))return;const e=this.mo,s=this.yo;let n=null,o=null;const r=t.ni.h,l=r.length;for(let h=0;h=0&&(Util.lf(t.Qs,i),t.Ed())}}Dl(){return!0}get key(){const t=this.diagram;if(!(t===null||!t.model.Ea()))return t.model.getKeyForLinkData(this.data)}}class LinkBundle{Ko;Xs;uy;sN;wb;nN;Qs;constructor(t,i,e,s){GSet.vi(this),this.Ko=!1,this.Xs=!1,this.uy=t,this.sN=i,this.wb=e,this.nN=s,this.Qs=[]}Ed(){if(!this.Ko){const t=this.Qs;if(t.length>0){const i=t[0].diagram;i!==null&&(i.mP.add(this),this.Xs=i.undoManager.isUndoingRedoing)}}this.Ko=!0}LP(){if(this.Ko){this.Ko=!1;const t=this.Qs;if(t.length>0){const i=t[0],e=i.diagram,s=e===null||e.Kh&&!this.Xs;this.Xs=!1,i.arrangeBundledLinks(t,s),t.length===1&&(i.er=null,t.length=0)}t.length===0&&(this.uy.nT(this),this.wb.nT(this))}}}class PositionArray{fe;ce;Ka;Ua;bi;ki;Yt;Mh;Ph;ua;YP;Ko;Cy;Qf;KP;UP;constructor(t){GSet.vi(this),this.ua=null,this.YP=null,this.Ko=!0,this.Cy=!1,this.fe=1,this.ce=1,this.Ka=-1,this.Ua=-1,this.bi=t.width,this.ki=t.height,this.Yt=null,this.Mh=0,this.Ph=0,this.Qf=11,this.KP=this.Qf*2,this.UP=this.Qf*2}static _s=0;static Ga=1;static Hd=999999;static pN=PositionArray.Hd+1;static yN=PositionArray.Hd+2;I1(t){if(t.width<=0||t.height<=0)return;const i=t.x,e=t.y,s=t.x+t.width,n=t.y+t.height;this.fe=Math.floor((i-this.bi)/this.bi)*this.bi,this.ce=Math.floor((e-this.ki)/this.ki)*this.ki,this.Ka=Math.ceil((s+2*this.bi)/this.bi)*this.bi,this.Ua=Math.ceil((n+2*this.ki)/this.ki)*this.ki;const o=1+(Math.ceil((this.Ka-this.fe)/this.bi)|0),r=1+(Math.ceil((this.Ua-this.ce)/this.ki)|0);if(this.Yt===null||this.Mh0&&t!==this.bi&&(this.bi=t,this.I1(this.bounds))}get cellHeight(){return this.ki}set cellHeight(t){t>0&&t!==this.ki&&(this.ki=t,this.I1(this.bounds))}qd(t,i){return this.fe<=t&&t<=this.Ka&&this.ce<=i&&i<=this.Ua}wo(t,i){if(!this.qd(t,i))return PositionArray.pN;t-=this.fe,t/=this.bi,i-=this.ce,i/=this.ki;const e=t|0,s=i|0;return this.Yt[e][s]}PR(t,i,e,s){if(!this.qd(t,i))return;const n=(t-this.fe)/this.bi|0,o=(i-this.ce)/this.ki|0,r=(t+e-this.fe)/this.bi|0,l=(i+s-this.ce)/this.ki|0,h=Math.min(r,this.Mh),a=Math.min(l,this.Ph);for(let f=n;f<=h;f++){const c=this.Yt[f];if(c.fill)c.fill(PositionArray._s,o,a+1);else for(let u=o;u<=a;u++)c[u]=PositionArray._s}}pO(t){if(this.Yt!==null)for(let i=0;i<=this.Mh;i++){const e=this.Yt[i];if(e.fill)e.fill(t);else for(let s=0;s<=this.Ph;s++)e[s]=t}}WA(){if(this.Yt!==null)for(let t=0;t<=this.Mh;t++){const i=this.Yt[t];for(let e=0;e<=this.Ph;e++)i[e]>=PositionArray.Ga&&(i[e]=PositionArray.pN)}}yO(t,i){return this.wo(t,i)===PositionArray._s}isUnoccupied(t,i,e,s){if(t>this.Ka||t+ethis.Ua||i+sthis.Ka||ithis.Ua||ethis.Ua||ithis.Ka||e=PositionArray.Ga&&h=a)break;this.Yt[t][i]=h,h+=1,s?i+=e:t+=e}return s?i:t}xo(t,i,e,s,n,o,r,l){if(to||il)return;const h=this.wO(t,i,e,s,n,o,r,l);if(s)if(e>0)for(let a=i+e;ah;a+=e)this.xo(t,a,1,!s,n,o,r,l),this.xo(t,a,-1,!s,n,o,r,l);else if(e>0)for(let a=t+e;ah;a+=e)this.xo(a,i,1,!s,n,o,r,l),this.xo(a,i,-1,!s,n,o,r,l)}Tb(t,i,e,s,n,o,r,l,h,a){let f=t|0,c=i|0,u=PositionArray._s,d=PositionArray.Ga;for(this.Yt[f][c]=d;u===PositionArray._s&&f>r&&fh&&cr&&fh&&c=0;I-=2){F=L[I+2],R=L[I+3];const O=L[I],V=L[I+1];for(;O>F?F++:OR?R++:Vs)d--;else break;else if(m>n)m--;else break;const g=f[d][m];if(g===0||g===PositionArray.yN)break;c=d,u=m}for(;;){let d=e,m=c,g=u;e===0?gn&&(d=270,g--):e===90?ms&&(d=180,m--):e===180?gn&&(d=270,g--):ms&&(d=180,m--);const p=f[m][g];if(d!==e&&p!==0&&p!==PositionArray.yN){if(o.push(c),o.push(u),this.pT(c,u,d,s,n,o))return!0;o.pop(),o.pop()}if(f[c][u]=PositionArray.yN,e===0){if(c===t)return!1;c--}else if(e===90){if(u===i)return!1;u--}else if(e===180){if(c===t)return!1;c++}else{if(u===i)return!1;u++}}}}class Knot{we;sr;cs;jd;constructor(){GSet.vi(this),this.we=null,this.sr=null,this.cs=[],this.jd=!1}toString(){const t=this.cs;let i=this.we.toString()+" "+t.length.toString()+":";for(let e=0;e180?270:90;case 6:return o>90&&o<=270?180:0}const r=Math.atan2(t.height,t.width)*180/Math.PI;switch(n){case 3:return o>r&&o<=180+r?180:270;case 5:return o>180-r&&o<=360-r?270:0;case 12:return o>r&&o<=180+r?90:0;case 10:return o>180-r&&o<=360-r?180:90;case 7:return o>90&&o<=180+r?180:o>180+r&&o<=360-r?270:0;case 13:return o>180&&o<=360-r?270:o>r&&o<=180?90:0;case 14:return o>r&&o<=180-r?90:o>180-r&&o<=270?180:0;case 11:return o>180-r&&o<=180+r?180:o>180+r?270:90}return s&&n!==15&&(o-=15,o<0&&(o+=360)),o>r&&o<180-r?90:o>=180-r&&o<=180+r?180:o>180+r&&o<360-r?270:0}Ed(){this.cs.length=0}dT(t){let i=this.cs;i.length===0&&(this.bO(),i=this.cs);for(let e=0;e=360&&(M-=360);const A=this.xO(h,y,M,g.isOrthogonal);let C=0;A===0?(C=4,M>180&&(M-=360)):A===90?(C=8,M>270&&(M-=360)):A===180?C=2:(C=1,M<90&&(M+=360));let P=this.cs[o];P===void 0?(P=new LinkInfo(g,M,C),this.cs[o]=P):(P.$e=g,P.jt=M,P.be=C),P.Fb.set(S),o++}Point.o(a),this.kO();const u=this.cs.length;let d=-1,m=0;for(o=0;o=0;o--){const g=this.cs[o];g!==void 0&&(g.be!==d&&(d=g.be,m=g.Wd+1),g.Dc=m)}this.SO(this.cs),this.MO(this.cs),this.jd=t,Rect.o(h)}return this.cs}PO(t,i){return t===i?0:t===null?-1:i===null?1:t.bei.be?1:t.jti.jt?1:0}kO(){this.cs.sort(Knot.prototype.PO)}SO(t){const i=this.sr,e=this.we.portSpreading,s=Point.a(),n=Point.a(),o=Point.a(),r=Point.a();i.getDocumentPoint(Spot.TopLeft,s),i.getDocumentPoint(Spot.TopRight,n),i.getDocumentPoint(Spot.BottomRight,o),i.getDocumentPoint(Spot.BottomLeft,r);let l=0,h=0,a=0,f=0;if(e===2)for(let x=0;xMath.abs(p)?(d=Math.abs(p)/a,a=Math.abs(p)):d=1;break;case 2:f>Math.abs(y)?(d=Math.abs(y)/f,f=Math.abs(y)):d=1;break;case 1:l>Math.abs(p)?(d=Math.abs(p)/l,l=Math.abs(p)):d=1;break;default:case 4:h>Math.abs(y)?(d=Math.abs(y)/h,h=Math.abs(y)):d=1;break}u=0}const b=k.Gd;if(e===2){let S=k.$e.computeThickness();switch(S*=d,b.set(m),c){case 8:b.x=m.x+p/2+a/2-u-S/2;break;case 2:b.y=m.y+y/2+f/2-u-S/2;break;case 1:b.x=m.x+p/2-l/2+u+S/2;break;default:case 4:b.y=m.y+y/2-h/2+u+S/2;break}u+=S}else{let S=.5;e===1&&(S=(k.Wd+1)/(k.Dc+1)),b.x=m.x+p*S,b.y=m.y+y*S}}Point.o(s),Point.o(n),Point.o(o),Point.o(r)}MO(t){for(let i=0;ie instanceof Placeholder);i instanceof Placeholder?t.Et=i:t.Et=null,this.re!==null?(t.re=this.re.copy(),t.re.group=t):(t.re!==null&&(t.re.group=null),t.re=null),this.hi!==null&&(t.hi=this.hi.copy())}Ho(t){super.Ho(t);const i=t.findSubGraphParts(),e=t.memberParts;for(;e.next();){const s=e.value;if(s.u(),s.invalidateLayout(8),s.clearAdornments(),s instanceof Node)s.invalidateConnectedLinks(i);else if(s instanceof Link){const n=s.labelNodes;for(;n.next();)n.value.invalidateConnectedLinks(i)}}}ec(t,i,e,s,n,o,r){if(t===3&&i==="elements"){if(n instanceof Placeholder)this.Et===null?this.Et=n:this.Et!==n&&Util.n("Cannot insert a second Placeholder into the visual tree of a Group.");else if(n instanceof Panel){const l=n.findInVisualTree(h=>h instanceof Placeholder);l instanceof Placeholder&&(this.Et===null?this.Et=l:this.Et!==l&&Util.n("Cannot insert a second Placeholder into the visual tree of a Group."))}}else t===4&&i==="elements"&&this.Et!==null&&(s===this.Et?this.Et=null:s instanceof Panel&&this.Et.isContainedBy(s)&&(this.Et=null));super.ec(t,i,e,s,n,o,r)}hd(t,i){if(super.hd(t,i),this.isClipping&&this.type!==Panel.Spot&&this.isSubGraphExpanded){let e=this.resizeObject;e instanceof Panel&&(e=e.findMainElement()),this.hi===null&&(this.hi=new Rect),e.getDocumentBounds(this.hi),e instanceof Shape&&this.hi.inflate(-e.strokeWidth,-e.strokeWidth)}}dh(t,i,e,s){this.hasPlaceholder()&&(this.tr=this.placeholder),super.dh(t,i,e,s)}ensureBounds(){this.isSubGraphExpanded&&this.memberParts.each(i=>{i.ensureBounds()}),super.ensureBounds()}$r(){if(!super.$r())return!1;const t=this.memberParts;for(;t.next();){const i=t.value;if(i instanceof Node){if(!i.isVisible())continue;if(i.rs())return!1}else if(i instanceof Link){if(!i.isVisible())continue;if(i.rs()&&i.fromNode!==this&&i.toNode!==this)return!1}}return!0}hasPlaceholder(){return this.Et!==null&&this.Et.isVisibleObject()&&this.isSubGraphExpanded}get placeholder(){return this.Et}get computesBoundsAfterDrag(){return(this.z&2048)!==0}set computesBoundsAfterDrag(t){const i=(this.z&2048)!==0;i!==t&&(Util.t(t,"boolean",Group,"computesBoundsAfterDrag"),this.z=this.z^2048,this.i("computesBoundsAfterDrag",i,t))}get computesBoundsIncludingLinks(){return(this.z&4096)!==0}set computesBoundsIncludingLinks(t){Util.t(t,"boolean",Group,"computesBoundsIncludingLinks");const i=(this.z&4096)!==0;i!==t&&(this.z=this.z^4096,this.i("computesBoundsIncludingLinks",i,t))}get computesBoundsIncludingLocation(){return(this.z&8192)!==0}set computesBoundsIncludingLocation(t){Util.t(t,"boolean",Group,"computesBoundsIncludingLocation");const i=(this.z&8192)!==0;i!==t&&(this.z=this.z^8192,this.i("computesBoundsIncludingLocation",i,t))}get handlesDragDropForMembers(){return(this.z&16384)!==0}set handlesDragDropForMembers(t){Util.t(t,"boolean",Group,"handlesDragDropForMembers");const i=(this.z&16384)!==0;i!==t&&(this.z=this.z^16384,this.i("handlesDragDropForMembers",i,t))}get avoidableMembers(){return(this.z&131072)!==0}set avoidableMembers(t){Util.t(t,"boolean",Group,"avoidableMembers");const i=(this.z&131072)!==0;i!==t&&(this.z=this.z^131072,this.i("avoidableMembers",i,t))}get memberParts(){return this.vd.iterator}_2(t){if(this.vd.add(t)){t instanceof Group&&this.ca.add(t);const e=this.memberAdded;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.j,n.j=!0),e(this,t),n!==null&&(n.j=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ki(!1)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.Et;i===null&&(i=this),i.u()}Q2(t){if(this.vd.delete(t)){t instanceof Group&&this.ca.delete(t);const e=this.memberRemoved;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.j,n.j=!0),e(this,t),n!==null&&(n.j=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ki(!0)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.Et;i===null&&(i=this),i.u()}Zf(){if(this.vd.count>0){const t=this.diagram;if(t!==null){const e=this.vd.copy().iterator;for(;e.next();){const s=e.value;t.remove(s)}}}super.Zf()}get layout(){return this.re}set layout(t){const i=this.re;if(i!==t){t!==null&&(Util.s(t,Layout,Group,"layout"),t.diagram!==null&&t.diagram.layout===t&&Util.n("A layout cannot be both the Diagram.layout and a Group.layout: "+t)),i!==null&&(i.diagram=null,i.group=null),this.re=t;const e=this.diagram;t!==null&&(t.diagram=e,t.group=this),e!==null&&(e.Wr=!0),this.i("layout",i,t),e!==null&&e.requestUpdate()}}get memberAdded(){return this.bt!==null?this.bt.xy:null}set memberAdded(t){const i=this.memberAdded;i!==t&&(t!==null&&Util.t(t,"function",Group,"memberAdded"),this.ml(),this.bt.xy=t,this.i("memberAdded",i,t))}get memberRemoved(){return this.bt!==null?this.bt.by:null}set memberRemoved(t){const i=this.memberRemoved;i!==t&&(t!==null&&Util.t(t,"function",Group,"memberRemoved"),this.ml(),this.bt.by=t,this.i("memberRemoved",i,t))}get memberValidation(){return this.bt!==null?this.bt.rh:null}set memberValidation(t){const i=this.memberValidation;i!==t&&(t!==null&&Util.t(t,"function",Group,"memberValidation"),this.ml(),this.bt.rh=t,this.i("memberValidation",i,t))}canAddMembers(t){const i=this.diagram;if(i===null)return!1;const e=i.commandHandler,n=e.c2(t).iterator;for(;n.next();){const o=n.value;if(!e.isValidMember(this,o))return!1}return!0}addMembers(t,i){const e=this.diagram;if(e===null)return!1;const s=e.commandHandler,n=s.c2(t);let o=!0;const r=n.iterator;for(;r.next();){const l=r.value;!i||s.isValidMember(this,l)?l.containingGroup=this:o=!1}return o}get ungroupable(){return(this.z&256)!==0}set ungroupable(t){const i=(this.z&256)!==0;i!==t&&(Util.t(t,"boolean",Group,"ungroupable"),this.z=this.z^256,this.i("ungroupable",i,t))}canUngroup(){if(!this.ungroupable)return!1;const t=this.layer;if(t===null||!t.allowUngroup)return!1;const i=t.diagram;return!(i!==null&&!i.allowUngroup)}invalidateConnectedLinks(t){const i=this.CO();if(super.invalidateConnectedLinks(t),i)return;this.LA(!0);const e=this.findExternalLinksConnected();for(;e.next();){const s=e.value;if(t!==void 0&&t.has(s))continue;const n=s.fromNode;if(n!==null&&n!==this&&n.isMemberOf(this)&&!n.isVisible())n._i(s.fromPort),n._i(s.toPort),s.invalidateRoute();else{const o=s.toNode;o!==null&&o!==this&&o.isMemberOf(this)&&!o.isVisible()&&(o._i(s.fromPort),o._i(s.toPort),s.invalidateRoute())}}}findExternalLinksConnected(){const t=this.diagram!==null&&this.diagram.kP;if(t&&this.x0!==null)return this.x0.iterator;const i=this.findSubGraphParts();i.add(this);const e=new GSet,s=i.iterator;for(;s.next();){const n=s.value;if(!(n instanceof Node))continue;const o=n.linksConnected;for(;o.next();){const r=o.value;i.has(r)||e.add(r)}}return t&&(this.x0=e),e.iterator}findExternalNodesConnected(){const t=this.findSubGraphParts();t.add(this);const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;if(!(s instanceof Node))continue;const n=s.linksConnected;for(;n.next();){const o=n.value,r=o.fromNode;r!==null&&(!t.has(r)||r===this)&&i.add(r);const l=o.toNode;l!==null&&(!t.has(l)||l===this)&&i.add(l)}}return i.iterator}pE(){function t(e,s){e!==null&&(s.add(e),t(e.containingGroup,s))}const i=new GSet;return t(this,i),i}findSubGraphParts(){const t=new GSet;return Part.lh(t,this,!0,0,!0),t.delete(this),t}Ki(t){super.Ki(t);const i=this.memberParts;for(;i.next();)i.value.Ki(t)}collapseSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.yT(i,t,this),t.isCollapsingExpanding=!1}yT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ki(!1),n instanceof Group&&n.isSubGraphExpanded&&(n.wasSubGraphExpanded=n.isSubGraphExpanded,n.yT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t),i.Ef(n,e);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!1}expandSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.wT(i,t,this),t.isCollapsingExpanding=!1}wT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ki(!0),n instanceof Group&&n.wasSubGraphExpanded&&(n.wasSubGraphExpanded=!1,n.wT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!0}get isSubGraphExpanded(){return(this.z&512)!==0}set isSubGraphExpanded(t){const i=(this.z&512)!==0;if(i!==t){Util.t(t,"boolean",Group,"isSubGraphExpanded"),this.z=this.z^512;const e=this.diagram;this.i("isSubGraphExpanded",i,t);const s=this.subGraphExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.j,e.j=!0),s(this),e!==null&&(e.j=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.Et!==null&&this.Et.u(),this.memberParts.each(n=>n.updateAdornments());return}t?this.expandSubGraph():this.collapseSubGraph()}}get wasSubGraphExpanded(){return(this.z&1024)!==0}set wasSubGraphExpanded(t){const i=(this.z&1024)!==0;i!==t&&(Util.t(t,"boolean",Group,"wasSubGraphExpanded"),this.z=this.z^1024,this.i("wasSubGraphExpanded",i,t))}get subGraphExpandedChanged(){return this.bt!==null?this.bt.ky:null}set subGraphExpandedChanged(t){const i=this.subGraphExpandedChanged;i!==t&&(t!==null&&Util.t(t,"function",Group,"subGraphExpandedChanged"),this.ml(),this.bt.ky=t,this.i("subGraphExpandedChanged",i,t))}move(t,i){i===void 0&&(i=!1);const e=i?this.location:this.position,s=e.x,n=e.y,o=t.x,r=t.y;if((s===o||isNaN(s)&&isNaN(o))&&(n===r||isNaN(n)&&isNaN(r)))return;const l=o-(isNaN(s)?0:s),h=r-(isNaN(n)?0:n),a=Point.a();super.move(t,i);const f=new GSet,u=this.findSubGraphParts().iterator;for(;u.next();){const d=u.value;d instanceof Link&&(d.suspendsRouting&&f.add(d),!(!d.Te&&(d.fromNode===this||d.toNode===this))&&(d.suspendsRouting=!0))}for(u.reset();u.next();){const d=u.value;if(d.Dl()||d instanceof Node&&d.isLinkLabel)continue;const m=d.position,g=d.location;m.isReal()?(a.x=m.x+l,a.y=m.y+h,d.position=a):g.isReal()&&(a.x=g.x+l,a.y=g.y+h,d.location=a)}for(u.reset();u.next();){const d=u.value;if(!(d instanceof Link)||(d.suspendsRouting=f.has(d),!d.Te&&(d.fromNode===this||d.toNode===this)))continue;const m=d.position;a.x=m.x+l,a.y=m.y+h,a.isReal()?d.move(a):d.invalidateRoute()}Point.o(a)}CO(){return(this.z&65536)!==0}LA(t){(this.z&65536)!==0!==t&&(this.z=this.z^65536)}get tl(){return(this.z&32768)!==0}set tl(t){(this.z&32768)!==0!==t&&(this.z=this.z^32768)}}class Placeholder extends GraphObject{ii;Jd;constructor(t){super(),this.ii=Margin.Hg,this.Jd=new Rect(NaN,NaN,NaN,NaN),t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.ii=this.ii.L(),t.Jd=this.Jd.copy()}uh(t){if(this.background===null)return!1;const i=this.naturalBounds;return Rect.contains(0,0,i.width,i.height,t.x,t.y)}rd(t,i,e,s){const n=this.part;if((n===null||!(n instanceof Group)&&!(n instanceof Adornment))&&Util.n("Placeholder is not inside a Group or Adornment."),n instanceof Group){const o=this.computeBorder(this.Jd),r=this.minSize,l=isFinite(r.width)?Math.max(r.width,o.width):o.width,h=isFinite(r.height)?Math.max(r.height,o.height):o.height,a=this.Hi;a.Kn(l||0,h||0),this.no(0,0,a.width,a.height);const f=n.memberParts;let c=!1;for(;f.next();)if(f.value.isVisible()){c=!0;break}const u=n.diagram;if(c&&u!==null&&!u.animationManager.OM(n)&&!isNaN(o.x)&&!isNaN(o.y)){const d=Point.a();d.setRectSpot(o,n.locationSpot),n.location=d,Point.o(d)}}else{const o=n,r=this.Hi,l=this.ii,h=l.left+l.right,a=l.top+l.bottom,f=o.adornedObject,c=f.getDocumentAngle();o.angle=c;let u=0;f instanceof Shape&&(u=f.strokeWidth);const d=f.getDocumentScale(),m=f.naturalBounds,g=(m.width+u)*d,p=(m.height+u)*d;if(o.type!==Panel.Link){const y=o.category==="Selection"?Spot.TopLeft:o.locationSpot,x=f.getDocumentPoint(y,Point.a());o.location=x,Point.o(x)}if(!isNaN(g)&&!isNaN(p))r.Kn(g+h||0,p+a||0),this.no(-l.left,-l.top,r.width,r.height);else{const y=f.getDocumentPoint(Spot.TopLeft,Point.a()),x=Rect.H(y.x,y.y,0,0);x.unionPoint(f.getDocumentPoint(Spot.BottomRight,y)),x.unionPoint(f.getDocumentPoint(Spot.TopRight,y)),x.unionPoint(f.getDocumentPoint(Spot.BottomLeft,y)),r.Kn(x.width+h||0,x.height+a||0),this.no(-l.left,-l.top,r.width,r.height),Point.o(y),Rect.o(x)}}}dh(t,i,e,s){this.actualBounds.e(t,i,e,s)}computeBorder(t){const i=this.part,e=i.diagram,s=e===null||!e.animationManager.isAnimating;if(e!==null&&i instanceof Group&&!i.layer.isTemporary&&i.computesBoundsAfterDrag&&this.Jd.isReal()){const l=e.toolManager.findTool("Dragging");if(l===e.currentTool){const h=l.computeBorder(i,this.Jd,t);if(h!==null)return h}}const n=Rect.a(),o=this.computeMemberBounds(n),r=this.ii;return i instanceof Group&&!i.isSubGraphExpanded?t.e(o.x-r.left,o.y-r.top,0,0):t.e(o.x-r.left,o.y-r.top,Math.max(o.width+r.left+r.right,0),Math.max(o.height+r.top+r.bottom,0)),Rect.o(n),s&&i instanceof Group&&i.computesBoundsIncludingLocation&&i.location.isReal()&&t.unionPoint(i.location),t}computeMemberBounds(t){if(!(this.part instanceof Group))return t.e(0,0,0,0),t;const i=this.part;let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=i.memberParts;for(;r.next();){const l=r.value;if(!l.isVisible()||l instanceof Link&&(!i.computesBoundsIncludingLinks||l.Xo()||l.fromNode===i||l.toNode===i))continue;const h=l.actualBounds;h.leftn&&(n=h.right),h.bottom>o&&(o=h.bottom)}if(!isFinite(e)||!isFinite(s)){const l=i.location;t.e(l.x,l.y,0,0)}else t.e(e,s,n-e,o-s);return t}get padding(){return this.ii}set padding(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Placeholder,"padding");const i=this.ii;i.equals(t)||(t=t.L(),this.ii=t,this.i("padding",i,t),this.u())}}class Layout{b;ua;Zd;Cr;$d;Qd;Bo;pl;_d;tg;bo;constructor(t){GSet.vi(this),this.b=null,this.ua=null,this.Zd=!0,this.Cr=!0,this.$d=!1,this.Qd=new Point(0,0).w(),this.Bo=!0,this.pl=null,this._d=null,this.tg=!1,this.bo=null,t&&Object.assign(this,t)}cloneProtected(t){t.Zd=this.Zd,t.Cr=this.Cr,t.$d=this.$d,t.Qd.c(this.Qd),t.Bo=this.Bo,t.pl=this.pl,t._d=this._d,t.tg=!0}copy(){const t=new this.constructor;return this.cloneProtected(t),t}fi(t){Util.ur(this,t)}toString(){let t=Util.hn(this.constructor);return t+="(",this.group!==null&&(t+=" in "+this.group),this.diagram!==null&&(t+=" for "+this.diagram),t+=")",t}get diagram(){return this.b}set diagram(t){t!==null&&Util.s(t,Diagram,Layout,"diagram"),this.b=t}get group(){return this.ua}set group(t){this.ua!==t&&(t!==null&&Util.s(t,Group,Layout,"group"),this.ua=t,t!==null&&(this.b=t.diagram))}get isOngoing(){return this.Zd}set isOngoing(t){this.Zd!==t&&(Util.t(t,"boolean",Layout,"isOngoing"),this.Zd=t)}get isInitial(){return this.Cr}set isInitial(t){Util.t(t,"boolean",Layout,"isInitial"),this.Cr=t,t||(this.tg=!0)}get isViewportSized(){return this.$d}set isViewportSized(t){this.$d!==t&&(Util.t(t,"boolean",Layout,"isViewportSized"),this.$d=t,t&&this.invalidateLayout())}get isRouting(){return this.Bo}set isRouting(t){this.Bo!==t&&(Util.t(t,"boolean",Layout,"isRouting"),this.Bo=t)}get isRealtime(){return this.pl}set isRealtime(t){this.pl!==t&&(t!==null&&Util.t(t,"boolean",Layout,"isRealtime"),this.pl=t)}get isValidLayout(){return this.tg}set isValidLayout(t){if(this.tg!==t&&(Util.t(t,"boolean",Layout,"isValidLayout"),this.tg=t,!t)){const i=this.diagram;i!==null&&(i.Wr=!0)}}invalidateLayout(){if(this.isValidLayout){const t=this.diagram;if(t===null||t.undoManager.isUndoingRedoing)return;const i=t.animationManager;if(i.isTicking)return;i.defaultAnimation.isAnimating&&i.stopAnimation(),(this.isOngoing&&t.Kh||this.isInitial&&!t.Kh)&&(this.isValidLayout=!1,t.requestUpdate())}}get network(){return this.bo}set network(t){this.bo!==t&&(t!==null&&Util.s(t,LayoutNetwork,Layout,"network"),this.bo=t,t!==null&&(t.layout=this))}createNetwork(){return new LayoutNetwork(this)}makeNetwork(t){const i=this.createNetwork();return t instanceof Diagram?(i.addParts(t.nodes,!0),i.addParts(t.links,!0)):t instanceof Group?i.addParts(t.memberParts):i.addParts(t.iterator),i}updateParts(){this.isValidLayout=!0;let t=this.diagram;if(t===null&&this.network!==null){const i=this.network.vertexes.iterator;for(;i.next();){const s=i.value.node;if(s!==null&&(t=s.diagram,t!==null))break}}try{t!==null&&t.startTransaction("Layout"),this.commitLayout()}finally{t!==null&&t.commitTransaction("Layout")}}commitLayout(){if(this.network===null)return;const t=this.network.vertexes.iterator;for(;t.next();)t.value.commit();if(this.isRouting){const i=this.network.edges.iterator;for(;i.next();)i.value.commit()}}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts");const i=new GSet;if(t instanceof Diagram?(this.Nh(i,t.nodes,!0,this.tl,!0,!1,!0),this.Nh(i,t.parts,!0,this.tl,!0,!1,!0)):t instanceof Group?this.Nh(i,t.memberParts,!1,this.tl,!0,!1,!0):i.addAll(t.iterator),i.count>0){const s=this.diagram;s!==null&&s.startTransaction("Layout"),this.doMinimalNoNetworkLayout(i),s!==null&&s.commitTransaction("Layout")}this.isValidLayout=!0}doMinimalNoNetworkLayout(t){const i=t.count,e=Math.ceil(Math.sqrt(i));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const s=this.arrangementOrigin.x,n=this.arrangementOrigin.y;let o=s,r=n,l=0,h=0;const a=t.iterator;for(;a.next();){const f=a.value;f.ensureBounds();const c=f.measuredBounds,u=c.width,d=c.height;f.moveTo(o,r),f instanceof Group&&(f.tl=!1),o+=Math.max(u,50)+20,h=Math.max(h,Math.max(d,50)),l>=e-1?(l=0,o=s,r+=h+20,h=0):l++}}doMinimalNetworkLayout(){const t=this.network.vertexes.count,i=Math.ceil(Math.sqrt(t));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const e=this.arrangementOrigin.x,s=this.arrangementOrigin.y;let n=e,o=s,r=0,l=0;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value.node;if(a===null||a instanceof Link||(a.ensureBounds(),!this.tl(a)))continue;const f=a.measuredBounds,c=f.width,u=f.height;a.moveTo(n,o),a instanceof Group&&(a.tl=!1),n+=Math.max(c,50)+20,l=Math.max(l,Math.max(u,50)),r>=i-1?(r=0,n=e,o+=l+20,l=0):r++}}tl(t){return!!(!t.location.isReal()&&!t.position.isReal()||t instanceof Group&&t.tl)}Nh(t,i,e,s,n,o,r){const l=i.iterator;for(;l.next();){const h=l.value;if(!(e&&!h.isTopLevel)&&!(s!==null&&!s(h))&&h.canLayout())if(n&&h instanceof Node){if(h.isLinkLabel)continue;h instanceof Group&&h.layout===null?this.Nh(t,h.memberParts,!1,s,n,o,r):(h.ensureBounds(),t.add(h))}else o&&h instanceof Link?t.add(h):r&&h.Ae()&&!(h instanceof Node)&&(h.ensureBounds(),t.add(h))}}getLayoutBounds(t,i){const e=this.boundsComputation;return e!==null?(i||(i=new Rect),e(t,this,i)):!i&&t.margin.equalTo(0,0,0,0)?t.actualBounds:(i||(i=new Rect),i.set(t.actualBounds),i.addMargin(t.margin),i)}get boundsComputation(){return this._d}set boundsComputation(t){this._d!==t&&(t!==null&&Util.t(t,"function",Layout,"boundsComputation"),this._d=t,this.invalidateLayout())}collectParts(t){const i=new GSet;return t instanceof Diagram?(this.Nh(i,t.nodes,!0,null,!0,!0,!0),this.Nh(i,t.links,!0,null,!0,!0,!0),this.Nh(i,t.parts,!0,null,!0,!0,!0)):t instanceof Group?this.Nh(i,t.memberParts,!1,null,!0,!0,!0):this.Nh(i,t.iterator,!1,null,!0,!0,!0),i}get arrangementOrigin(){return this.Qd}set arrangementOrigin(t){Util.s(t,Point,Layout,"arrangementOrigin"),this.Qd.equals(t)||(this.Qd.c(t),this.invalidateLayout())}initialOrigin(t){const i=this.group;if(i!==null)if(i.hasPlaceholder()){const e=i.placeholder,s=e.getDocumentPoint(Spot.TopLeft);(isNaN(s.x)||isNaN(s.y))&&s.set(t);const n=e.padding;return s.x+=n.left,s.y+=n.top,s}else{const e=i.position.copy();return(isNaN(e.x)||isNaN(e.y))&&e.set(t),e}return t}}class LayoutNetwork{re;ko;Fn;Ay;Ly;constructor(t){GSet.vi(this),Debug&&!t&&Util.n("LayoutNetwork constructor requires non-null Layout argument"),this.re=t,this.ko=new GSet,this.Fn=new GSet,this.Ay=new GMap,this.Ly=new GMap}clear(){if(this.ko){const t=this.ko.iterator;for(;t.next();)t.value.clear()}if(this.Fn){const t=this.Fn.iterator;for(;t.next();)t.value.clear()}this.ko=new GSet,this.Fn=new GSet,this.Ay=new GMap,this.Ly=new GMap}toString(t){t===void 0&&(t=0);let i="LayoutNetwork"+(this.layout!==null?"("+this.layout.toString()+")":"");if(t<=0)return i;if(i+=" vertexes: "+this.ko.count+" edges: "+this.Fn.count,t>1){const e=this.ko.iterator;for(;e.next();){const n=e.value;i+=` `+n.toString(t-1)}const s=this.Fn.iterator;for(;s.next();){const n=s.value;i+=` - `+n.toString(t-1)}}return i}get layout(){return this.oe}set layout(t){t!==null&&(this.oe=t)}get vertexes(){return this.ko}get edges(){return this.Fn}createVertex(){return new LayoutVertex(this)}createEdge(){return new LayoutEdge(this)}addParts(t,i,e){if(t===null)return;i===void 0&&(i=!1),Util.t(i,"boolean",LayoutNetwork,"addParts:toplevelonly"),e===void 0&&(e=null),e===null&&(e=n=>{if(n instanceof Node)return!n.isLinkLabel;if(n instanceof Link){const o=n.fromNode;if(o===null||o.isLinkLabel)return!1;const r=n.toNode;return!(r===null||r.isLinkLabel)}return!1});const s=t.iterator;for(;s.next();){const n=s.value;if(n instanceof Node&&!(i&&!n.isTopLevel)&&n.canLayout()&&e(n))if(n instanceof Group&&n.layout===null)this.addParts(n.memberParts,!1);else{if(this.findVertex(n)!==null)continue;const o=this.createVertex();o.node=n,this.addVertex(o)}}for(s.reset();s.next();){const n=s.value;if(!(n instanceof Link)||i&&!n.isTopLevel||!n.canLayout()||!e(n)||this.findEdge(n)!==null)continue;const o=n.fromNode,r=n.toNode;if(o===null||r===null||o===r)continue;const l=this.findGroupVertex(o),h=this.findGroupVertex(r);this.linkVertexes(l,h,n)}}findGroupVertex(t){if(t===null)return null;const i=t.findVisibleNode();if(i===null)return null;let e=this.findVertex(i);if(e!==null)return e;let s=i.containingGroup;for(;s!==null;){if(e=this.findVertex(s),e!==null)return e;s=s.containingGroup}return null}addVertex(t){if(t===null)return;Debug&&Util.s(t,LayoutVertex,LayoutNetwork,"addVertex:vertex"),this.ko.add(t);const i=t.node;i!==null&&this.Ay.set(i,t),t.network=this}addNode(t){if(t===null)return null;Debug&&Util.s(t,Node,LayoutNetwork,"addNode:node");let i=this.findVertex(t);return i===null&&(i=this.createVertex(),i.node=t,this.addVertex(i)),i}deleteVertex(t){if(t!==null&&(Debug&&Util.s(t,LayoutVertex,LayoutNetwork,"deleteVertex:vertex"),this.xT(t))){let i=t.nr;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}i=t.or;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}}}xT(t){if(t===null)return!1;const i=this.ko.delete(t);if(i){const e=t.node;e!==null&&this.Ay.delete(e)}return i}deleteNode(t){if(t===null)return;Debug&&Util.s(t,Node,LayoutNetwork,"deleteNode:node");const i=this.findVertex(t);i!==null&&this.deleteVertex(i)}findVertex(t){return t===null?null:(Debug&&Util.s(t,Node,LayoutNetwork,"findVertex:node"),this.Ay.get(t))}addEdge(t){if(t===null)return;Debug&&Util.s(t,LayoutEdge,LayoutNetwork,"addEdge:edge"),this.bN(t);const i=t.toVertex;i!==null&&i.addSourceEdge(t);const e=t.fromVertex;e!==null&&e.addDestinationEdge(t)}bN(t){if(t===null)return;this.Fn.add(t);const i=t.link;i!==null&&this.findEdge(i)===null&&this.Ly.set(i,t),t.network=this}addLink(t){if(t===null)return null;Debug&&Util.s(t,Link,LayoutNetwork,"addLink:link");const i=t.fromNode,e=t.toNode;let s=this.findEdge(t);return s===null?(s=this.createEdge(),s.link=t,i!==null&&(s.fromVertex=this.addNode(i)),e!==null&&(s.toVertex=this.addNode(e)),this.addEdge(s)):(i!==null?s.fromVertex=this.addNode(i):s.fromVertex=null,e!==null?s.toVertex=this.addNode(e):s.toVertex=null),s}deleteEdge(t){if(t===null)return;Debug&&Util.s(t,LayoutEdge,LayoutNetwork,"deleteEdge:edge");const i=t.toVertex;i!==null&&i.deleteSourceEdge(t);const e=t.fromVertex;e!==null&&e.deleteDestinationEdge(t),this.kN(t)}kN(t){if(t===null)return!1;const i=this.Fn.delete(t);if(i){const e=t.link;e!==null&&this.Ly.delete(e)}return i}deleteLink(t){if(t===null)return;Debug&&Util.s(t,Link,LayoutNetwork,"deleteLink:link");const i=this.findEdge(t);i!==null&&this.deleteEdge(i)}findEdge(t){return t===null?null:(Debug&&Util.s(t,Link,LayoutNetwork,"findEdge:link"),this.Ly.get(t))}linkVertexes(t,i,e){if(t===null||i===null)return null;if(Debug&&(Util.s(t,LayoutVertex,LayoutNetwork,"linkVertexes:fromVertex"),Util.s(i,LayoutVertex,LayoutNetwork,"linkVertexes:toVertex"),e!==null&&Util.s(e,Link,LayoutNetwork,"linkVertexes:link")),t.network===this&&i.network===this){const s=this.createEdge();return s.link=e,s.fromVertex=t,s.toVertex=i,this.addEdge(s),s}return null}reverseEdge(t){if(t===null)return;Debug&&Util.s(t,LayoutEdge,LayoutNetwork,"reverseEdge:edge");const i=t.fromVertex,e=t.toVertex;i===null||e===null||(i.deleteDestinationEdge(t),e.deleteSourceEdge(t),t.reverseEdge(),i.addSourceEdge(t),e.addDestinationEdge(t))}deleteSelfEdges(){const t=Util.ft(),i=this.Fn.iterator;for(;i.next();){const s=i.value;s.fromVertex===s.toVertex&&t.push(s)}const e=t.length;for(let s=0;s0||t.or.count>0)}splitIntoSubNetworks(t){t===void 0&&(t=!0),t&&(this.deleteArtificialVertexes(),this.deleteUselessEdges(),this.deleteSelfEdges());const i=new List;let e=!0;for(;e;){e=!1;const s=this.ko.iterator;for(;s.next();){const n=s.value;if(this.isSingleton(n))continue;const o=this.layout.createNetwork();i.add(o),this.LO(o,n),e=!0;break}}return i.sort((s,n)=>s===null||n===null||s===n?0:n.vertexes.count-s.vertexes.count),i}LO(t,i){if(i===null)return;const e=new List;for(e.add(i);e.count>0;){const s=e.first();if(e.removeAt(0),s.network===t)continue;this.xT(s),t.addVertex(s);let n=s.sourceEdges;for(;n.next();){const o=n.value;o.network!==t&&(this.kN(o),t.bN(o),e.add(o.fromVertex))}for(n=s.destinationEdges;n.next();){const o=n.value;o.network!==t&&(this.kN(o),t.bN(o),e.add(o.toVertex))}}}findAllParts(){const t=new GSet,i=this.ko.iterator;for(;i.next();){const s=i.value;t.add(s.node)}const e=this.Fn.iterator;for(;e.next();){const s=e.value;t.add(s.link)}return t}}class LayoutVertex{bo;si;ye;Oe;Qe;nr;or;constructor(t){GSet.vi(this),Debug&&!t&&Util.n("LayoutVertex constructor requires non-null LayoutNetwork argument"),this.bo=t,this.Oe=new Rect(0,0,10,10).w(),this.Qe=new Point(5,5).w(),this.si=null,this.ye=null,this.nr=new List,this.or=new List}clear(){this.si=null,this.ye=null,this.nr=new List,this.or=new List}toString(t){t===void 0&&(t=0);let i="LayoutVertex#"+GSet.gs(this);if(t>0&&(i+=this.node!==null?"("+this.node.toString()+")":"",t>1)){let e="",s=!0,n=this.nr.iterator;for(;n.next();){const r=n.value;s?s=!1:e+=",",e+=r.toString(0)}let o="";for(s=!0,n=this.or.iterator;n.next();){const r=n.value;s?s=!1:o+=",",o+=r.toString(0)}i+=" sources: "+e+" destinations: "+o}return i}get So(){return this.nr.nC}get rr(){return this.or.nC}get data(){return this.si}set data(t){if(this.si=t,t!==null&&t.bounds){const i=t.bounds,e=i.x,s=i.y,n=i.width,o=i.height;this.Qe.e(n/2,o/2),this.Oe.e(e,s,n,o)}}get node(){return this.ye}set node(t){if(this.ye!==t){Debug&&t!==null&&Util.s(t,Node,LayoutVertex,"node"),this.ye=t,t.ensureBounds();const i=this.network.layout,e=Rect.a(),s=i.getLayoutBounds(t,e);let n=s.x,o=s.y;const r=s.width,l=s.height;if(isNaN(n)&&(n=0),isNaN(o)&&(o=0),this.Oe.e(n,o,r,l),Rect.o(e),!(t instanceof Group)){const h=t.locationObject.getDocumentPoint(Spot.Center);if(h.isReal()){this.Qe.e(h.x-n,h.y-o);return}}this.Qe.e(r/2,l/2)}}get bounds(){return this.Oe}set bounds(t){this.Oe.equals(t)||(Debug&&Util.s(t,Rect,LayoutVertex,"bounds"),this.Oe.c(t))}get focus(){return this.Qe}set focus(t){this.Qe.equals(t)||(Debug&&Util.s(t,Point,LayoutVertex,"focus"),this.Qe.c(t))}get centerX(){return this.Oe.x+this.Qe.x}set centerX(t){const i=this.Oe;i.x+this.Qe.x!==t&&(Debug&&Util.r(t,LayoutVertex,"centerX"),i.ct(),i.x=t-this.Qe.x,i.w())}get centerY(){return this.Oe.y+this.Qe.y}set centerY(t){const i=this.Oe;i.y+this.Qe.y!==t&&(Debug&&Util.r(t,LayoutVertex,"centerY"),i.ct(),i.y=t-this.Qe.y,i.w())}get focusX(){return this.Qe.x}set focusX(t){const i=this.Qe;i.x!==t&&(i.ct(),i.x=t,i.w())}get focusY(){return this.Qe.y}set focusY(t){const i=this.Qe;i.y!==t&&(i.ct(),i.y=t,i.w())}get x(){return this.Oe.x}set x(t){const i=this.Oe;i.x!==t&&(i.ct(),i.x=t,i.w())}get y(){return this.Oe.y}set y(t){const i=this.Oe;i.y!==t&&(i.ct(),i.y=t,i.w())}get width(){return this.Oe.width}set width(t){const i=this.Oe;i.width!==t&&(i.ct(),i.width=t,i.w())}get height(){return this.Oe.height}set height(t){const i=this.Oe;i.height!==t&&(i.ct(),i.height=t,i.w())}commit(){const t=this.si;if(t!==null){const e=this.bounds,s=t.bounds;Util.Mt(s)?(s.x=e.x,s.y=e.y,s.width=e.width,s.height=e.height):t.bounds=e.copy();return}const i=this.node;if(i!==null){const e=this.bounds;if(!(i instanceof Group)){const s=Rect.a();i.ensureBounds();const n=this.network.layout.getLayoutBounds(i,s),o=i.locationObject.getDocumentPoint(Spot.Center);if(n.isReal()&&o.isReal()){i.moveTo(e.x+this.focusX-(o.x-n.x)+i.margin.left,e.y+this.focusY-(o.y-n.y+i.margin.top)),Rect.o(s);return}Rect.o(s)}i.moveTo(e.x+i.margin.left,e.y+i.margin.top)}}addSourceEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"addSourceEdge:edge"),this.nr.has(t)||this.nr.add(t))}deleteSourceEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"deleteSourceEdge:edge"),this.nr.delete(t))}addDestinationEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"addDestinationEdge:edge"),this.or.has(t)||this.or.add(t))}deleteDestinationEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"deleteDestinationEdge:edge"),this.or.delete(t))}get network(){return this.bo}set network(t){Debug&&Util.s(t,LayoutNetwork,LayoutVertex,"network"),this.bo=t}get sourceVertexes(){const t=new GSet,i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}return t.iterator}get destinationVertexes(){const t=new GSet,i=this.destinationEdges;for(;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get vertexes(){const t=new GSet;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get sourceEdges(){return this.nr.iterator}get destinationEdges(){return this.or.iterator}get edges(){const t=new List;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e)}return t.iterator}get edgesCount(){return this.nr.count+this.or.count}static standardComparer(t,i){Debug&&Util.s(t,LayoutVertex,LayoutVertex,"standardComparer:m"),Debug&&Util.s(i,LayoutVertex,LayoutVertex,"standardComparer:n");const e=t.ye,s=i.ye;if(e)if(s){const n=e.text,o=s.text;return no?1:0}else return 1;else return s!==null?-1:0}static smartComparer(t,i){if(Debug&&Util.s(t,LayoutVertex,LayoutVertex,"smartComparer:m"),Debug&&Util.s(i,LayoutVertex,LayoutVertex,"smartComparer:n"),t!==null)if(i!==null){const e=t.ye,s=i.ye;if(e!==null)if(s!==null){const n=e.text.toLocaleLowerCase(),o=s.text.toLocaleLowerCase(),r=n.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),l=o.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let h=0;for(;h0&&(i+=this.$e!==null?"("+this.$e.toString()+")":"",t>1&&(i+=" "+(this._e?this._e.toString():"null")+" --> "+(this.ts?this.ts.toString():"null"))),i}reverseEdge(){const t=this._e;this._e=this.ts,this.ts=t}commit(){}getOtherVertex(t){return Debug&&Util.s(t,LayoutVertex,LayoutEdge,"getOtherVertex:v"),this.ts===t?this._e:this._e===t?this.ts:null}get network(){return this.bo}set network(t){Debug&&Util.s(t,LayoutNetwork,LayoutEdge,"network"),this.bo=t}get data(){return this.si}set data(t){this.si!==t&&(Debug&&t!==null&&Util.t(t,"object",LayoutEdge,"data"),this.si=t)}get link(){return this.$e}set link(t){this.$e!==t&&(Debug&&t!==null&&Util.s(t,Link,LayoutEdge,"link"),this.$e=t)}get fromVertex(){return this._e}set fromVertex(t){this._e!==t&&(Debug&&t!==null&&Util.s(t,LayoutVertex,LayoutEdge,"fromVertex"),this._e=t)}get toVertex(){return this.ts}set toVertex(t){this.ts!==t&&(Debug&&t!==null&&Util.s(t,LayoutVertex,LayoutEdge,"toVertex"),this.ts=t)}}var GridAlignment=(w=>(w[w.Position=0]="Position",w[w.Location=1]="Location",w))(GridAlignment||{}),GridArrangement=(w=>(w[w.LeftToRight=10]="LeftToRight",w[w.RightToLeft=11]="RightToLeft",w))(GridArrangement||{}),GridSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w))(GridSorting||{});class GridLayout extends Layout{eg;sg;Ro;Rn;ai;qi;ke;Se;constructor(t){super(),this.isViewportSized=!0,this.eg=NaN,this.sg=NaN,this.Ro=new Size(NaN,NaN).w(),this.Rn=new Size(10,10).w(),this.ai=1,this.qi=10,this.ke=22,this.Se=GridLayout.standardComparer,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.eg=this.eg,t.sg=this.sg,t.Ro.c(this.Ro),t.Rn.c(this.Rn),t.ai=this.ai,t.qi=this.qi,t.ke=this.ke,t.Se=this.Se}fi(t){t in GridSorting?this.sorting=t:t in GridArrangement?this.arrangement=t:t in GridAlignment?this.alignment=t:super.fi(t)}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.collectParts(t),e=this.diagram,n=i.copy().iterator;for(;n.next();){const m=n.value;if(m.Dl()&&(m.fromNode!==null||m.toNode!==null)){i.delete(m);continue}if(m.ensureBounds(),m instanceof Group){const g=m.memberParts;for(;g.next();){const p=g.value;i.delete(p)}}}const o=i.toArray();if(o.length===0)return;switch(this.sorting){case 20:break;case 21:o.reverse();break;case 22:o.sort(this.comparer);break;case 23:o.sort(this.comparer),o.reverse();break}let r=this.wrappingColumn;isNaN(r)&&(r=0);let l=this.wrappingWidth;if(isNaN(l)&&e!==null){const m=e.viewportBounds,g=e.padding;l=Math.max(m.width-g.left-g.right,0)}else l=Math.max(this.wrappingWidth,0);r<=0&&l<=0&&(r=1);let h=this.spacing.width;isFinite(h)||(h=0);let a=this.spacing.height;isFinite(a)||(a=0),e!==null&&e.startTransaction("Layout");const f=[];switch(this.alignment){case 0:this.TO(o,l,r,h,a,f);break;case 1:this.DO(o,l,r,h,a,f);break}let c=0,u=0,d=0;for(let m=0;m0&&m>e-1||i>0&&m>0&&A-f>i)&&(o.push(new Rect(0,d,i+s,g)),m=0,u=f,d+=g,g=0),g=Math.max(g,M);let C=0;switch(a){case 11:C=-x.width;break;default:C=0;break}switch(y.moveTo(u+C+y.margin.left,d+y.margin.top),a){case 11:u-=S;break;default:u+=S;break}m++}o.push(new Rect(0,d,i+s,g)),Rect.o(r)}DO(t,i,e,s,n,o){const r=Rect.a();let l=Math.max(this.cellSize.width,1),h=0,a=0,f=0;const c=Point.a();for(let C=0;C=h&&(i-=h);let x=0,k=0;const b=Math.max(this.cellSize.height,1);f=0;let S=0,M=!0;const A=Point.a();for(let C=0;C0)switch(u){case 11:{let D=(g-d-(N.width-T.x))/l;Geo.q(Math.round(D),D)?D=Math.round(D):D=Math.floor(D),g=D*l+d;break}default:{let D=(g-d+T.x)/l;Geo.q(Math.round(D),D)?D=Math.round(D):D=Math.ceil(D),g=D*l+d;break}}else switch(u){case 11:x=g+T.x+N.width;break;default:x=g-T.x;break}let L=0;switch(u){case 11:L=-(g+T.x)+x;break;default:L=g+N.width-T.x-x;break}if(e>0&&y>e-1||i>0&&y>0&&L>i){o.push(new Rect(0,M?p-f:p,i+s,S+f+n));for(let D=0;Dk&&(P.width+=P.x-k,P.x=k)}Rect.o(r)}commitLayers(t,i){}get wrappingWidth(){return this.eg}set wrappingWidth(t){this.eg!==t&&(Util.t(t,"number",GridLayout,"wrappingWidth"),(t>0||isNaN(t))&&(this.eg=t,this.isViewportSized=isNaN(t),this.invalidateLayout()))}get wrappingColumn(){return this.sg}set wrappingColumn(t){this.sg!==t&&(Util.t(t,"number",GridLayout,"wrappingColumn"),(t>0||isNaN(t))&&(this.sg=t,this.invalidateLayout()))}get cellSize(){return this.Ro}set cellSize(t){Util.s(t,Size,GridLayout,"cellSize"),this.Ro.equals(t)||(this.Ro.c(t),this.invalidateLayout())}get spacing(){return this.Rn}set spacing(t){Util.s(t,Size,GridLayout,"spacing"),this.Rn.equals(t)||(this.Rn.c(t),this.invalidateLayout())}get alignment(){return this.ai}set alignment(t){this.ai!==t&&(Util.tt(t,GridAlignment,"GridAlignment"),(t===1||t===0)&&(this.ai=t,this.invalidateLayout()))}get arrangement(){return this.qi}set arrangement(t){this.qi!==t&&(Util.tt(t,GridArrangement,"GridArrangement"),(t===10||t===11)&&(this.qi=t,this.invalidateLayout()))}get sorting(){return this.ke}set sorting(t){this.ke!==t&&(Util.tt(t,GridSorting,"GridSorting"),(t===20||t===21||t===22||t===23)&&(this.ke=t,this.invalidateLayout()))}get comparer(){return this.Se}set comparer(t){this.Se!==t&&(Util.t(t,"function",GridLayout,"comparer"),this.Se=t,this.invalidateLayout())}static standardComparer(t,i){Debug&&Util.s(t,Part,GridLayout,"standardComparer:a"),Debug&&Util.s(i,Part,GridLayout,"standardComparer:b");const e=t.text,s=i.text;return es?1:0}static smartComparer(t,i){if(Debug&&Util.s(t,Part,GridLayout,"standardComparer:a"),Debug&&Util.s(i,Part,GridLayout,"standardComparer:b"),t!==null)if(i!==null){const e=t.text.toLocaleLowerCase(),s=i.text.toLocaleLowerCase(),n=e.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),o=s.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let r=0;for(;r{e.containsNodeData(s)&&this.MT(s,!1)}),t.forEach(s=>{e.containsNodeData(s)&&this.Rb(s)}),i!==!1&&this.diagram.R1(!1)}MT(t,i){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.Mo.has(t))return null;i===void 0&&(i=!0);const e=this.FO(t);return e!==null&&i&&this.Rb(t),e}FO(t){if(t==null||this.b.undoManager.isUndoingRedoing||this.Mo.has(t))return null;const i=this.RO(t),e=this.findTemplateForNodeData(t,i);if(e!==null){e.ci();const s=e.copy();if(s!==null){const n=this.diagram.me;return this.diagram.me=!0,s.$o=i,s.si=t,this.Ty&&(s.ul="Tool"),this.diagram.add(s),s.si=null,s.data=t,this.diagram.me=n,s}}return null}insertLink(t,i,e,s){return null}Rb(t){}RO(t){return this.b.model.getCategoryForNodeData(t)}static PT=!1;static NT=!1;findTemplateForNodeData(t,i){const e=this.b,s=e.model,n=s.da()&&s.isGroupForData(t);let o=null;return n?(o=e.groupTemplateMap.get(i),o===null&&(o=e.groupTemplateMap.get(""),o===null&&(PartManager.NT||(PartManager.NT=!0,Util.at('No Group template found for category "'+i+'"'),Util.at(" Using default group template")),o=e.gP))):(o=e.nodeTemplateMap.get(i),o===null&&(o=e.nodeTemplateMap.get(""),o===null&&(PartManager.PT||(PartManager.PT=!0,Util.at('No Node template found for category "'+i+'"'),Util.at(" Using default node template")),o=e.cP))),o}getLinkCategoryForData(t){return""}setLinkCategoryForData(t,i){}setFromNodeForLink(t,i,e){}setToNodeForLink(t,i,e){}static CT=!1;findLinkTemplateForCategory(t){const i=this.b;let e=i.linkTemplateMap.get(t);return e===null&&(e=i.linkTemplateMap.get(""),e===null&&(PartManager.CT||(PartManager.CT=!0,Util.at('No Link template found for category "'+t+'"'),Util.at(" Using default link template")),e=i.uP)),e}xI(t,i,e){t instanceof Link?(i!==null&&this.kT(i,t),e!==null&&this.bT(e,t)):t instanceof Part&&(i!==null&&this.Mo.delete(i),e!==null&&this.Mo.set(e,t))}ST(){const t=this.diagram.model;this.MN(t.nodeDataArray)}MN(t){t.forEach(i=>{this.Ib(i)})}Ib(t){const i=this.findPartForData(t);i!==null&&(this.diagram.IP(i,!1),this.PN(i))}PN(t){}gN(t){}findPartForKey(t){if(t==null)return null;const i=this.b.model.findNodeDataForKey(t);return i!==null?this.Mo.get(i):null}findNodeForKey(t){if(t==null)return null;const i=this.b.model.findNodeDataForKey(t);if(i===null)return null;const e=this.Mo.get(i);return e instanceof Node?e:null}findLinkForKey(t){return null}findPartForData(t){if(t===null)return null;let i=this.Mo.get(t);return i!==null||(i=this.yl.get(t)),i}findNodeForData(t){if(t===null)return null;const i=this.Mo.get(t);return i instanceof Node?i:null}findLinkForData(t,i){return t===null?null:this.yl.get(t)}findNodesByExample(...t){const i=new GSet,e=this.ng.iterator;for(;e.next();){const s=e.value,n=s.data;if(n!==null)for(let o=0;o{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),this.parts.each(o=>{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),s.forEach(o=>t.LT(o,!1));for(let o=0;o0){for(let o=0;oi.FA(s));const e=t.wh;if(Array.isArray(e)){const s=this.Ga.get(e);if(s===null){const n=[];n.push(t),this.Ga.set(e,n)}else{for(let n=0;ni.PR(s));const e=t.wh;if(Array.isArray(e)){const s=this.Ga.get(e);if(s!==null){for(let n=0;n0&&i.removeParts(l,!1),h.count>0){const f=h.iterator;for(;f.next();){const c=f.key,u=f.value;s.set(c,u)}}}if(i!==null&&this.b!==null){const o=i.model,r=o.afterCopyFunction;if(r!==null){const l=new GMap;s.each(a=>{a.key.data!==null&&l.set(a.key.data,a.value.data)});const h=this.b.model;r(l,o,h)}}const n=s.iterator;for(;n.next();)n.value.updateTargetBindings();return s}Ob(t,i,e,s){if(t===null||s&&!t.canCopy())return null;if(e.has(t))return e.get(t);const n=this.CN(t,i);if(!(n instanceof Part))return null;if(n.isSelected=!1,n.isHighlighted=!1,e.set(t,n),t instanceof Node){const o=t.linksConnected;for(;o.next();){const r=o.value;if(r.fromNode===t){const l=e.get(r);l!==null&&(l.fromNode=n)}if(r.toNode===t){const l=e.get(r);l!==null&&(l.toNode=n)}}if(t instanceof Group&&n instanceof Group){const r=t.memberParts;for(;r.next();){const l=r.value,h=this.Ob(l,i,e,s);h instanceof Link||h!==null&&(h.containingGroup=n)}}}else if(t instanceof Link&&n instanceof Link){const o=t.fromNode;if(o!==null){const h=e.get(o);h!==null&&(n.fromNode=h)}const r=t.toNode;if(r!==null){const h=e.get(r);h!==null&&(n.toNode=h)}const l=t.labelNodes;for(;l.next();){const h=l.value,a=this.Ob(h,i,e,s);a!==null&&a instanceof Node&&(a.labeledLink=n)}}return n}CN(t,i){let e=null;const s=t.data;if(s!==null&&i!==null){const n=i.model;if(!(t instanceof Link)){const o=n.copyNodeData(s);Util.Mt(o)&&(n.addNodeData(o),e=i.findPartForData(o))}}else if(t.ci(),e=t.copy(),e!==null){const n=this.b;if(i!==null)i.add(e);else if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const o=n.model;let r=null;e instanceof Link||(r=o.copyNodeData(s)),Util.Mt(r)&&(e.data=r)}}return e}get nodes(){return this.ng}get links(){return this.Qs}get parts(){return this.It}get diagram(){return this.b}get addsToTemporaryLayer(){return this.Ty}set addsToTemporaryLayer(t){this.Ty=t}get preservesRebuildLocations(){return this.SN}set preservesRebuildLocations(t){this.SN=t}}class GraphLinksPartManager extends PartManager{EP(){const t=this.diagram.model;this.Dy(t.nodeDataArray),this.FT(t.linkDataArray)}Dy(t){super.Dy(t,!1);const i=this.links.iterator;for(;i.next();)i.value.Ed();this.diagram.R1(!1)}FT(t){t.forEach(i=>{this.RT(i)}),this.diagram.R1(!1)}RT(t){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.yl.has(t))return null;const i=this.getLinkCategoryForData(t),e=this.findLinkTemplateForCategory(i);if(e!==null){e.ci();const s=e.copy();if(s!==null){const n=this.diagram.me;this.diagram.me=!0,s.$o=i,s.si=t;const o=this.diagram.model,r=o.Eb(t,!0);r!==""&&(s.fromPortId=r);const l=o.Ee(t,!0);if(l!==void 0){const c=this.findNodeForKey(l);c instanceof Node&&(s.fromNode=c)}const h=o.Eb(t,!1);h!==""&&(s.toPortId=h);const a=o.Ee(t,!1);if(a!==void 0){const c=this.findNodeForKey(a);c instanceof Node&&(s.toNode=c)}const f=o.getLabelKeysForLinkData(t);return Array.isArray(f)&&f.forEach(c=>{const u=this.findNodeForKey(c);u!==null&&(u.labeledLink=s)}),this.Ty&&(s.ul="Tool"),this.diagram.add(s),s.si=null,s.data=t,this.diagram.me=n,s}}return null}ST(){const t=this.diagram.model;this.IT(t.linkDataArray),this.MN(t.nodeDataArray)}IT(t){t.forEach(i=>{this.Ib(i)})}getLinkCategoryForData(t){return this.diagram.model.getCategoryForLinkData(t)}setLinkCategoryForData(t,i){return this.diagram.model.setCategoryForLinkData(t,i)}setFromNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setFromKeyForLinkData(t.data,e.getKeyForNodeData(s))}setToNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setToKeyForLinkData(t.data,e.getKeyForNodeData(s))}gN(t){this.diagram.model.removeLinkData(t.data)}findPartForKey(t){const i=super.findPartForKey(t);if(i===null){const s=this.diagram.model.findLinkDataForKey(t);if(s!==null)return this.yl.get(s)}return i}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findLinkDataForKey(t);return e!==null?this.yl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.j){i.j=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="linkFromKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.fromNode=l}}else if(s==="linkToKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.toNode=l}}else if(s==="linkFromPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.fromPortId=r)}}else if(s==="linkToPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.toPortId=r)}}else if(s==="nodeGroupKey"){const n=t.object,o=this.findPartForData(n);if(o!==null){const r=t.newValue;if(r!==void 0){const l=this.findNodeForKey(r);l instanceof Group?o.containingGroup=l:o.containingGroup=null}else o.containingGroup=null}}else if(s==="linkLabelKeys"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.oldValue,l=t.newValue;Array.isArray(r)&&r.forEach(h=>{if(l.indexOf(h)>=0)return;const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=null)}),Array.isArray(l)&&l.forEach(h=>{const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=o)})}}else if(s==="linkCategory"){const n=t.object,o=this.findLinkForData(n),r=t.newValue;o!==null&&typeof r=="string"&&(o.category=r)}else if(s==="linkDataArray"){const n=t.oldValue;this.IT(n);const o=t.newValue;this.FT(o)}i.isModified=!0}else if(e===3){const n=t.newValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.RT(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=t.object,r=this.findLinkForData(o),l=this.findNodeForKey(n);r!==null&&l!==null&&(l.labeledLink=r)}i.isModified=!0}else if(e===4){const n=t.oldValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.Ib(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=this.findNodeForKey(n);o!==null&&(o.labeledLink=null)}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&(n==="linkFromKeyProperty"||n==="linkToKeyProperty"||n==="linkFromPortIdProperty"||n==="linkToPortIdProperty"||n==="linkLabelKeysProperty"||n==="nodeIsGroupProperty"||n==="nodeGroupKeyProperty"||n==="linkCategoryProperty")&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.j=!0}}}DT(){const t=this.diagram.model,i=new GSet,e=t.linkDataArray;e.forEach(n=>{i.add(n)});const s=[];this.links.each(n=>{n.data!==null&&!i.has(n.data)&&s.push(n.data)}),s.forEach(n=>{t.OT(n,!1)}),e.forEach(n=>{this.findLinkForData(n)===null&&t.ET(n,!1)})}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Link){let n=s.Ee(i,!0),o=e.findNodeForKey(n);t.fromNode=o,n=s.Ee(i,!1),o=e.findNodeForKey(n),t.toNode=o;const r=s.getLabelKeysForLinkData(i);if(r.length>0||t.labelNodes.count>0){if(r.length===1&&t.labelNodes.count===1){const c=r[0],u=t.labelNodes.first();if(s.getKeyForNodeData(u.data)===c)return}const l=new GSet().addAll(r),h=new GSet;t.labelNodes.each(c=>{if(c.data!==null){const u=s.getKeyForNodeData(c.data);u!==void 0&&h.add(u)}});const a=h.copy();a.removeAll(l);const f=l.copy();if(f.removeAll(h),a.count>0||f.count>0){const c=t;a.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink===c&&(d.labeledLink=null)}),f.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink!==c&&(d.labeledLink=c)})}}}else if(!(t instanceof Adornment)){const n=s.getGroupKeyForNodeData(i),o=e.findPartForKey(n);(o===null||o instanceof Group)&&(t.containingGroup=o)}}Rb(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Ry(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)){if(n instanceof Group&&i.getGroupKeyForNodeData(l)===e){const h=this.findPartForData(l);h!==null&&(h.containingGroup=n)}}else{const h=this.findLinkForData(l);if(h!==null&&n instanceof Node){i.Ee(l,!0)===e&&(h.fromNode=n),i.Ee(l,!1)===e&&(h.toNode=n);const a=i.getLabelKeysForLinkData(l);Array.isArray(a)&&a.some(f=>f===e?(n.labeledLink=h,!0):!1)}}}i.tn(e)}const o=i.getGroupKeyForNodeData(t);if(o!==void 0){const r=this.findNodeForKey(o);r instanceof Group&&(n.containingGroup=r)}}}PN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data);if(e!==void 0){const s=t.linksConnected;for(;s.next();){const n=s.value;i.en(e,n.data)}if(t.isLinkLabel){const n=t.labeledLink;n!==null&&i.en(e,n.data)}if(t instanceof Group){const n=t.memberParts;for(;n.next();){const r=n.value.data;i.containsNodeData(r)&&i.en(e,r)}}}}}CN(t,i){let e=super.CN(t,i);if(t instanceof Link){const s=t.data;if(s!==null&&i!==null){const n=i.model,o=n.copyLinkData(s);typeof o=="object"&&o!==null&&(n.addLinkData(o),e=i.findLinkForData(o))}else if(e!==null){const n=this.diagram;if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const r=n.model.copyLinkData(s);typeof r=="object"&&r!==null&&(e.data=r)}}}return e}insertLink(t,i,e,s){const n=this.diagram,o=n.model,r=n.toolManager.findTool("Linking");let l="";t!==null&&(i===null&&(i=t),l=i.portId,l===null&&(l=""));let h="";e!==null&&(s===null&&(s=e),h=s.portId,h===null&&(h=""));const a=r.archetypeLinkData;if(a instanceof Link){a.ci();const f=a.copy();if(f!==null){f.fromNode=t,f.fromPortId=l,f.toNode=e,f.toPortId=h,n.add(f);const c=r.archetypeLabelNodeData;if(c instanceof Node){c.ci();const u=c.copy();u!==null&&(u.labeledLink=f,n.add(u))}return f}}else if(a!==null){const f=o.copyLinkData(a);if(typeof f=="object"&&f!==null){t!==null&&o.og(f,o.getKeyForNodeData(t.data),!0),o.rg(f,l,!0),e!==null&&o.og(f,o.getKeyForNodeData(e.data),!1),o.rg(f,h,!1),o.addLinkData(f);const c=r.archetypeLabelNodeData;if(c!==null&&!(c instanceof Node)){const d=o.copyNodeData(c);if(typeof d=="object"&&d!==null){o.addNodeData(d);const m=o.getKeyForNodeData(d);m!==void 0&&o.addLabelKeyForLinkData(f,m)}}return n.findLinkForData(f)}}return null}}class TreePartManager extends PartManager{Nh=null;Vb(t,i){if(t===null||i===null||i.findTreeParentLink()!==null)return null;const e=this.diagram.toolManager.findTool("Linking");let s=t,n=i;if(this.diagram.isTreePathToChildren){if(e!==null&&e.Au(s,n,null,!0))return null}else if(s=i,n=t,e!==null&&e.Au(s,n,null,!0))return null;const o=this.getLinkCategoryForData(i.data),r=this.findLinkTemplateForCategory(o);if(r!==null){r.ci();const l=r.copy();if(l!==null){const h=this.diagram.me;return this.diagram.me=!0,l.$o=o,l.si=i.data,l.fromNode=s,l.toNode=n,this.diagram.add(l),l.si=null,l.data=i.data,this.diagram.me=h,l}}return null}getLinkCategoryForData(t){return this.diagram.model.getParentLinkCategoryForNodeData(t)}setLinkCategoryForData(t,i){this.diagram.model.setParentLinkCategoryForNodeData(t,i)}setFromNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren)s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n));else{const o=this.Nh;this.Nh=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.toNode!==null?t.toNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Nh=o}}setToNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren){const o=this.Nh;this.Nh=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.fromNode!==null?t.fromNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Nh=o}else s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n))}gN(t){this.diagram.model.setParentKeyForNodeData(t.data,void 0)}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findNodeDataForKey(t);return e!==null?this.yl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.j){i.j=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="nodeParentKey"){const n=t.object,o=t.newValue,r=this.findNodeForKey(o),l=this.findNodeForData(n);if(this.Nh!==null)r!==null&&(this.Nh.data=n,this.Nh.category=this.getLinkCategoryForData(n));else if(l!==null){const h=l.findTreeParentLink();h!==null?r===null?i.remove(h):i.isTreePathToChildren?h.fromNode=r:h.toNode=r:this.Vb(r,l)}}else if(s==="parentLinkCategory"){const n=t.object,o=this.findNodeForData(n),r=t.newValue;if(o!==null&&typeof r=="string"){const l=o.findTreeParentLink();l!==null&&(l.category=r)}}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&n==="nodeParentKeyProperty"&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.j=!0}}}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Node){const n=s.getParentKeyForNodeData(i),o=e.findNodeForKey(n),r=t.findTreeParentNode();if(o!==r){const l=t.findTreeParentLink();o!==null?l!==null?e.isTreePathToChildren?l.fromNode=o:l.toNode=o:this.Vb(o,t):l!==null&&e.IP(l,!1)}}}Fy(t,i){if(super.Fy(t,i),typeof i=="string"&&this.findPartForData(t)!==null){const s=this.findLinkForData(t);s!==null&&s.updateTargetBindings(i)}}Rb(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Ry(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)&&n instanceof Node&&i.getParentKeyForNodeData(l)===e){const h=this.findNodeForData(l);this.Vb(n,h)}}i.tn(e)}const o=i.getParentKeyForNodeData(t);if(o!==void 0&&n instanceof Node){const r=this.findNodeForKey(o);this.Vb(r,n)}}}PN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data),s=this.findLinkForData(t.data);if(s!==null){s.isSelected=!1,s.isHighlighted=!1;const r=s.layer;if(r!==null){const l=r.ne(-1,s,!1);l>=0&&this.diagram.raiseChangedEvent(4,"parts",r,s,null,l,null);const h=s.layerChanged;h!==null&&h(s,r,null)}}const n=this.diagram.isTreePathToChildren,o=t.linksConnected;for(;o.next();){const r=o.value,h=(n?r.toNode:r.fromNode).data;i.containsNodeData(h)&&i.en(e,h)}}}insertLink(t,i,e,s){const n=this.diagram.model;let o=t,r=e;if(this.diagram.isTreePathToChildren||(o=e,r=t),o!==null&&r!==null){const l=o.data,h=r.data;return n.setParentKeyForNodeData(h,n.getKeyForNodeData(l)),r.findTreeParentLink()}return null}}var BindingMode=(w=>(w[w.OneWay=1]="OneWay",w[w.TwoWay=2]="TwoWay",w))(BindingMode||{});class Binding{l;AN;Ha;Fc;Ch;Rc;Ic;Oc;Bb;Ce;Sd;pc;constructor(t,i,e,s){GSet.vi(this),t===void 0?t="":Util.t(t,"string",Binding,"constructor:targetprop"),i===void 0?i=t:Util.t(i,"string",Binding,"constructor:sourceprop"),e===void 0?e=null:e!==null&&Util.t(e,"function",Binding,"constructor:conv"),this.AN=-1,this.Ce=null,this.Ha=t,this.Sd=0,this.pc=0,this.Fc=null,this.Ch=i,this.Rc=e,s===void 0?(this.Ic=1,this.Oc=null):(this.Ic=2,this.Oc=s),this.Bb=new GSet,this.l=2}copy(){const t=new this.constructor;return this.cloneProtected(t),t}cloneProtected(t){t.Ha=this.Ha,t.Sd=this.Sd,t.pc=this.pc,t.Fc=this.Fc,t.Ch=this.Ch,t.Rc=this.Rc,t.Ic=this.Ic,t.Oc=this.Oc,t.l=this.l&-2}static OneWay=1;static TwoWay=2;static parseEnum(t,i){return Util.t(t,"function",Binding,"parseEnum:ctor"),e=>{let s=parseInt(e);return isNaN(s)&&(s=Util.zh(t,e),s===null)?i:s}}fi(t){t in BindingMode?this.mode=t:Util.ur(this,t)}static toString(t){return Util.toString(t)}toString(){return"Binding("+this.targetProperty+":"+this.sourceProperty+(this.targetId!==-1?" "+this.targetId:"")+" "+BindingMode[this.mode]+")"}w(){return this.l=this.l|1,this}ct(){return this.l=this.l&-2,this}get targetId(){return this.AN}set targetId(t){this.f&&Util.F(this),Util.t(t,"number",Binding,"targetId"),this.AN=t}get targetProperty(){return this.Ha}set targetProperty(t){this.f&&Util.F(this),Util.t(t,"string",Binding,"targetProperty"),this.Ha=t}get sourceProperty(){return this.Ch}set sourceProperty(t){this.f&&Util.F(this),Util.t(t,"string",Binding,"sourceProperty"),this.Ch=t}get f(){return(this.l&1)!==0}get isToData(){return(this.l&2)!==0}get isToObject(){return(this.l&4)!==0}get isToModel(){return(this.l&8)!==0}get isToTheme(){return(this.l&16)!==0}get LN(){return this.isToTheme&&!(this.isToData||this.isToObject||this.isToModel)}rd(){return!1}get sourceName(){return this.Fc}set sourceName(t){this.f&&Util.F(this),t!==null&&Util.t(t,"string",Binding,"sourceName"),this.Fc=t,t!==null?this.l=this.l&-3|4:this.l=this.l|2}get converter(){return this.Rc}set converter(t){this.f&&Util.F(this),t!==null&&Util.t(t,"function",Binding,"converter"),this.Rc=t}get backConverter(){return this.Oc}set backConverter(t){this.f&&Util.F(this),t!==null&&Util.t(t,"function",Binding,"backConverter"),this.Oc=t}get mode(){return this.Ic}set mode(t){this.f&&Util.F(this),this.isToTheme&&t===2&&Util.n("Theme Bindings cannot be TwoWay."),Util.tt(t,BindingMode,"BindingMode"),this.Ic=t}makeTwoWay(t){return this.isToTheme&&Util.n("Theme Bindings cannot be TwoWay."),this.mode=2,t&&(Util.t(t,"function",Binding,"makeTwoWay"),this.backConverter=t),this}ofObject(t){return this.f&&Util.F(this),t===void 0&&(t=""),Debug&&Util.t(t,"string",Binding,"ofObject:srcname"),this.sourceName=t,this}ofModel(){return this.f&&Util.F(this),this.l=this.l&-3&-5|8,this.Fc=null,this}rL(t,i){const e=this.sourceName;let s=null;return e===null||e===""?s=t:e==="/"?s=i.part:e==="."?s=i:e===".."?s=i.panel:s=t.findObject(e),s}check(t){const i=this.Ha,e=this.Ch,s=this.Rc;(this.rd()&&s===null&&this.Ah===null&&i===""||s===null&&i==="")&&Util.at("Binding error: target property is the empty string: "+this.toString()),this.rd()&&this.LN&&e===""&&s===null&&this.Ah===null&&Util.at("Binding error: theme bindings require a source property when not using a converter: "+this.toString()),t&&typeof i=="string"&&(typeof t.setAttribute!="function"&&i.length>0&&i[0]!=="_"&&!Util.yw(t,i)?Util.at("Binding error: undefined target property: "+i+" on "+t.toString()):i==="name"&&t instanceof GraphObject&&Util.at("Binding error: cannot modify GraphObject.name on "+t.toString()))}updateTarget(t,i,e){const s=this.Ch;if(e!==void 0&&s!==""&&s!==e)return;const n=this.Ha,o=this.Rc;let r=i;if(s!==""&&!this.LN&&(r=Model.Xt(i,s)),r===void 0)return;const l=t.diagram?.themeManager??t.panel?.diagram?.themeManager;if(o===null){if(n!==""){if(this.rd()&&(r=this.VT(l,r,t,n),r===void 0))return;Model.ut(t,n,r)}}else try{if(n!==""){let h=o(r,t);if(Debug&&h===void 0&&Util.at('Binding warning: conversion function returned undefined when setting target property "'+n+'" on '+t.toString()+", function is: "+o),this.rd()&&(h=this.VT(l,h,t,n),h===void 0))return;Model.ut(t,n,h)}else o(r,t)}catch(h){Debug&&Util.at("Binding error: "+h.toString()+' setting target property "'+n+'" on '+t.toString()+" with conversion function: "+o)}}updateSource(t,i,e,s){if(this.Ic!==2)return;const n=this.Ha;if(e!==void 0&&n!==e)return;const o=this.Ch,r=this.Oc;let l=t;if(n!==""&&(l=Model.Xt(t,n)),l!==void 0&&!this.Bb.has(t))try{this.Bb.add(t);const h=s!==null?s.diagram:null,a=h!==null?h.model:null;if(r===null){if(o!=="")a!==null?(Debug&&a.nodeKeyProperty===o&&a.containsNodeData(i)&&Util.at("Binding error: cannot have TwoWay Binding on node data key property: "+this.toString()),a.setDataProperty(i,o,l)):Model.ut(i,o,l);else if(a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const f=s.itemIndex,c=s.panel.itemArray;a.removeArrayItem(c,f),a.insertArrayItem(c,f,l)}}else try{if(o!==""){const f=r(l,i,a);a!==null?(Debug&&(a.nodeKeyProperty===o&&a.containsNodeData(i)&&Util.at("Binding error: cannot have TwoWay Binding on node data key property: "+this.toString()),f===void 0&&Util.at(`Binding warning: conversion function returned undefined when setting source property "${o}" on ${i.toString()}, function is: ${r}`)),a.setDataProperty(i,o,f)):Model.ut(i,o,f)}else{const f=r(l,i,a);if(f!==void 0&&a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const c=s.itemIndex,u=s.panel.itemArray;a.removeArrayItem(u,c),a.insertArrayItem(u,c,f)}}}catch(f){Debug&&Util.at("Binding error: "+f.toString()+' setting source property "'+o+'" on '+i.toString()+" with conversion function: "+r)}}finally{this.Bb.delete(t)}}}class ThemeBinding extends Binding{Iy;Ah;qa;constructor(t,i,e,s,n){super(t,i,s),e==null&&(e=""),n===void 0&&(n=null),this.Iy=e,this.Ah=n,this.qa=null,this.l=16}cloneProtected(t){super.cloneProtected(t),t.Iy=this.Iy,t.Ah=this.Ah,t.qa=this.qa}rd(){return!0}get themeSource(){return this.Iy}set themeSource(t){this.f&&Util.F(this),t!==null&&Util.t(t,"string",ThemeBinding,"themeSource"),this.Iy=t,this.qa=null,t!==null?this.l=this.l|16:this.l=this.l&-17}get themeConverter(){return this.Ah}set themeConverter(t){this.f&&Util.F(this),t!==null&&Util.t(t,"function",ThemeBinding,"themeConverter"),this.Ah=t}ofData(){return this.f&&Util.F(this),this.l=this.l|2,this.Fc=null,this}VT(t,i,e,s){if(!t||(this.LN&&(i=this.Ch),!i&&i!==0))return;let n=this.themeSource;this.qa!==null?n=this.qa:typeof n=="string"&&n.includes(".")&&(this.qa=n.split("."),n=this.qa);let o=t.findValue(i,n,s);return o===void 0&&Util.at(`Theme warning: ${i} could not be found when setting target property ${s}.`),typeof this.Ah=="function"&&(o=this.Ah(o,e)),o}}class Model{Tt;lg;zo;zb;Me;Ec;Vc;hg;ag;fg;cg;ja;lr;Xb;Bo;Yb;oi;Lh;ug=new GSet;dg=new GSet;Oy;constructor(t,i){if(GSet.vi(this),this.Tt="",this.lg="",this.zo=!1,this.zb={},this.Me=[],this.oi=new GMap,this.Lh="key",this.Ec=null,this.Vc=null,this.hg=!1,this.ag=!1,this.fg=!1,this.cg=null,this.ja="category",this.lr=new GMap,this.Oy=100,this.Xb=new List,this.Bo=!1,this.Yb=null,this.undoManager=new UndoManager,t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){t.Tt=this.Tt,t.lg=this.lg,t.zo=this.zo,t.Lh=this.Lh,t.Ec=this.Ec,t.Vc=this.Vc,t.hg=this.hg,t.ag=this.ag,t.fg=this.fg,t.Oy=this.Oy,t.cg=this.cg,t.ja=this.ja}copy(){const t=new this.constructor;return this.cloneProtected(t),t}clear(){this.Me=[],this.oi.clear(),this.lr.clear(),this.undoManager.clear()}toString(t){if(t===void 0&&(t=0),t>1)return this.toJson();{let i=(this.name!==""?this.name:"")+" Model";if(t>0){i+=` - node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n{if(u.model===e){if(u.modelChange==="nodeDataArray")u.change===3?n.add(u.newValue):u.change===4&&r.add(u.oldValue);else if(e.containsNodeData(u.object))o.add(u.object);else if(u.change===2&&(e.modelData===u.object||u.propertyName==="modelData"))s=!0;else if(u.object!==null)if(l&&l.has(u.object))l.get(u.object).each(m=>{e.containsNodeData(m)&&o.add(m)});else{if(u.object instanceof Model||e.Oa()&&e.containsLinkData(u.object))return;e.zT(u.object).each(m=>{o.add(m)})}}});const h=this.dg;h.clear(),n.each(u=>{h.add(e.getKeyForNodeData(u)),i||o.add(u)});const a=this.ug;a.clear(),r.each(u=>{a.add(e.getKeyForNodeData(u)),i&&o.add(u)});const f=e.cloneDeep(o.toArray());let c=null;return s&&(c===null&&(c={}),c.modelData=this.cloneDeep(this.modelData)),h.count>0&&(c===null&&(c={}),i?c.removedNodeKeys=h.toArray():c.insertedNodeKeys=h.toArray()),f.length>0&&(c===null&&(c={}),c.modifiedNodeData=f),a.count>0&&(c===null&&(c={}),i?c.insertedNodeKeys=a.toArray():c.removedNodeKeys=a.toArray()),a.clear(),h.clear(),c}cloneDeep(t){return this.gg(t,!0)}gg(t,i,e,s,n){if(!Util.Mt(t))return t;n||(n=[]);const o=Object.isExtensible(t);if(e||(e=new GMap),o){const h=e.get(t);if(h)return h}else{s||(s=new GMap);const h=s.iterator;for(;h.next();){const a=h.key;if(h.value===t){const c=e.get(a);if(c)return c}}}function r(h,a){if(o)h.__gohashid===void 0&&n.push(h),e.set(h,a);else{const f=GSet.cu++;e.set(f,a),s.set(f,t)}}let l;if(Array.isArray(t)){l=[],r(t,l);for(let h=0;h{delete h.__gohashid}),l}Ve(t){return JSON.stringify(t).replace(/[\u007F-\uFFFF]/g,e=>{const s="0000"+e.charCodeAt(0).toString(16);return"\\u"+s.substring(s.length-4)})}mg(){let t="";return this.name!==""&&(t+=`, - "name": `+this.Ve(this.name)),this.dataFormat!==""&&(t+=`, - "dataFormat": `+this.Ve(this.dataFormat)),this.isReadOnly&&(t+=`, + `+n.toString(t-1)}}return i}get layout(){return this.re}set layout(t){t!==null&&(this.re=t)}get vertexes(){return this.ko}get edges(){return this.Fn}createVertex(){return new LayoutVertex(this)}createEdge(){return new LayoutEdge(this)}addParts(t,i,e){if(t===null)return;i===void 0&&(i=!1),Util.t(i,"boolean",LayoutNetwork,"addParts:toplevelonly"),e===void 0&&(e=null),e===null&&(e=n=>{if(n instanceof Node)return!n.isLinkLabel;if(n instanceof Link){const o=n.fromNode;if(o===null||o.isLinkLabel)return!1;const r=n.toNode;return!(r===null||r.isLinkLabel)}return!1});const s=t.iterator;for(;s.next();){const n=s.value;if(n instanceof Node&&!(i&&!n.isTopLevel)&&n.canLayout()&&e(n))if(n instanceof Group&&n.layout===null)this.addParts(n.memberParts,!1);else{if(this.findVertex(n)!==null)continue;const o=this.createVertex();o.node=n,this.addVertex(o)}}for(s.reset();s.next();){const n=s.value;if(!(n instanceof Link)||i&&!n.isTopLevel||!n.canLayout()||!e(n)||this.findEdge(n)!==null)continue;const o=n.fromNode,r=n.toNode;if(o===null||r===null||o===r)continue;const l=this.findGroupVertex(o),h=this.findGroupVertex(r);this.linkVertexes(l,h,n)}}findGroupVertex(t){if(t===null)return null;const i=t.findVisibleNode();if(i===null)return null;let e=this.findVertex(i);if(e!==null)return e;let s=i.containingGroup;for(;s!==null;){if(e=this.findVertex(s),e!==null)return e;s=s.containingGroup}return null}addVertex(t){if(t===null)return;Debug&&Util.s(t,LayoutVertex,LayoutNetwork,"addVertex:vertex"),this.ko.add(t);const i=t.node;i!==null&&this.Ay.set(i,t),t.network=this}addNode(t){if(t===null)return null;Debug&&Util.s(t,Node,LayoutNetwork,"addNode:node");let i=this.findVertex(t);return i===null&&(i=this.createVertex(),i.node=t,this.addVertex(i)),i}deleteVertex(t){if(t!==null&&(Debug&&Util.s(t,LayoutVertex,LayoutNetwork,"deleteVertex:vertex"),this.xT(t))){let i=t.nr;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}i=t.or;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}}}xT(t){if(t===null)return!1;const i=this.ko.delete(t);if(i){const e=t.node;e!==null&&this.Ay.delete(e)}return i}deleteNode(t){if(t===null)return;Debug&&Util.s(t,Node,LayoutNetwork,"deleteNode:node");const i=this.findVertex(t);i!==null&&this.deleteVertex(i)}findVertex(t){return t===null?null:(Debug&&Util.s(t,Node,LayoutNetwork,"findVertex:node"),this.Ay.get(t))}addEdge(t){if(t===null)return;Debug&&Util.s(t,LayoutEdge,LayoutNetwork,"addEdge:edge"),this.wN(t);const i=t.toVertex;i!==null&&i.addSourceEdge(t);const e=t.fromVertex;e!==null&&e.addDestinationEdge(t)}wN(t){if(t===null)return;this.Fn.add(t);const i=t.link;i!==null&&this.findEdge(i)===null&&this.Ly.set(i,t),t.network=this}addLink(t){if(t===null)return null;Debug&&Util.s(t,Link,LayoutNetwork,"addLink:link");const i=t.fromNode,e=t.toNode;let s=this.findEdge(t);return s===null?(s=this.createEdge(),s.link=t,i!==null&&(s.fromVertex=this.addNode(i)),e!==null&&(s.toVertex=this.addNode(e)),this.addEdge(s)):(i!==null?s.fromVertex=this.addNode(i):s.fromVertex=null,e!==null?s.toVertex=this.addNode(e):s.toVertex=null),s}deleteEdge(t){if(t===null)return;Debug&&Util.s(t,LayoutEdge,LayoutNetwork,"deleteEdge:edge");const i=t.toVertex;i!==null&&i.deleteSourceEdge(t);const e=t.fromVertex;e!==null&&e.deleteDestinationEdge(t),this.xN(t)}xN(t){if(t===null)return!1;const i=this.Fn.delete(t);if(i){const e=t.link;e!==null&&this.Ly.delete(e)}return i}deleteLink(t){if(t===null)return;Debug&&Util.s(t,Link,LayoutNetwork,"deleteLink:link");const i=this.findEdge(t);i!==null&&this.deleteEdge(i)}findEdge(t){return t===null?null:(Debug&&Util.s(t,Link,LayoutNetwork,"findEdge:link"),this.Ly.get(t))}linkVertexes(t,i,e){if(t===null||i===null)return null;if(Debug&&(Util.s(t,LayoutVertex,LayoutNetwork,"linkVertexes:fromVertex"),Util.s(i,LayoutVertex,LayoutNetwork,"linkVertexes:toVertex"),e!==null&&Util.s(e,Link,LayoutNetwork,"linkVertexes:link")),t.network===this&&i.network===this){const s=this.createEdge();return s.link=e,s.fromVertex=t,s.toVertex=i,this.addEdge(s),s}return null}reverseEdge(t){if(t===null)return;Debug&&Util.s(t,LayoutEdge,LayoutNetwork,"reverseEdge:edge");const i=t.fromVertex,e=t.toVertex;i===null||e===null||(i.deleteDestinationEdge(t),e.deleteSourceEdge(t),t.reverseEdge(),i.addSourceEdge(t),e.addDestinationEdge(t))}deleteSelfEdges(){const t=Util.at(),i=this.Fn.iterator;for(;i.next();){const s=i.value;s.fromVertex===s.toVertex&&t.push(s)}const e=t.length;for(let s=0;s0||t.or.count>0)}splitIntoSubNetworks(t){t===void 0&&(t=!0),t&&(this.deleteArtificialVertexes(),this.deleteUselessEdges(),this.deleteSelfEdges());const i=new List;let e=!0;for(;e;){e=!1;const s=this.ko.iterator;for(;s.next();){const n=s.value;if(this.isSingleton(n))continue;const o=this.layout.createNetwork();i.add(o),this.AO(o,n),e=!0;break}}return i.sort((s,n)=>s===null||n===null||s===n?0:n.vertexes.count-s.vertexes.count),i}AO(t,i){if(i===null)return;const e=new List;for(e.add(i);e.count>0;){const s=e.first();if(e.removeAt(0),s.network===t)continue;this.xT(s),t.addVertex(s);let n=s.sourceEdges;for(;n.next();){const o=n.value;o.network!==t&&(this.xN(o),t.wN(o),e.add(o.fromVertex))}for(n=s.destinationEdges;n.next();){const o=n.value;o.network!==t&&(this.xN(o),t.wN(o),e.add(o.toVertex))}}}findAllParts(){const t=new GSet,i=this.ko.iterator;for(;i.next();){const s=i.value;t.add(s.node)}const e=this.Fn.iterator;for(;e.next();){const s=e.value;t.add(s.link)}return t}}class LayoutVertex{bo;si;we;Oe;Qe;nr;or;constructor(t){GSet.vi(this),Debug&&!t&&Util.n("LayoutVertex constructor requires non-null LayoutNetwork argument"),this.bo=t,this.Oe=new Rect(0,0,10,10).w(),this.Qe=new Point(5,5).w(),this.si=null,this.we=null,this.nr=new List,this.or=new List}clear(){this.si=null,this.we=null,this.nr=new List,this.or=new List}toString(t){t===void 0&&(t=0);let i="LayoutVertex#"+GSet.gs(this);if(t>0&&(i+=this.node!==null?"("+this.node.toString()+")":"",t>1)){let e="",s=!0,n=this.nr.iterator;for(;n.next();){const r=n.value;s?s=!1:e+=",",e+=r.toString(0)}let o="";for(s=!0,n=this.or.iterator;n.next();){const r=n.value;s?s=!1:o+=",",o+=r.toString(0)}i+=" sources: "+e+" destinations: "+o}return i}get So(){return this.nr.eC}get rr(){return this.or.eC}get data(){return this.si}set data(t){if(this.si=t,t!==null&&t.bounds){const i=t.bounds,e=i.x,s=i.y,n=i.width,o=i.height;this.Qe.e(n/2,o/2),this.Oe.e(e,s,n,o)}}get node(){return this.we}set node(t){if(this.we!==t){Debug&&t!==null&&Util.s(t,Node,LayoutVertex,"node"),this.we=t,t.ensureBounds();const i=this.network.layout,e=Rect.a(),s=i.getLayoutBounds(t,e);let n=s.x,o=s.y;const r=s.width,l=s.height;if(isNaN(n)&&(n=0),isNaN(o)&&(o=0),this.Oe.e(n,o,r,l),Rect.o(e),!(t instanceof Group)){const h=t.locationObject.getDocumentPoint(Spot.Center);if(h.isReal()){this.Qe.e(h.x-n,h.y-o);return}}this.Qe.e(r/2,l/2)}}get bounds(){return this.Oe}set bounds(t){this.Oe.equals(t)||(Debug&&Util.s(t,Rect,LayoutVertex,"bounds"),this.Oe.c(t))}get focus(){return this.Qe}set focus(t){this.Qe.equals(t)||(Debug&&Util.s(t,Point,LayoutVertex,"focus"),this.Qe.c(t))}get centerX(){return this.Oe.x+this.Qe.x}set centerX(t){const i=this.Oe;i.x+this.Qe.x!==t&&(Debug&&Util.r(t,LayoutVertex,"centerX"),i.ft(),i.x=t-this.Qe.x,i.w())}get centerY(){return this.Oe.y+this.Qe.y}set centerY(t){const i=this.Oe;i.y+this.Qe.y!==t&&(Debug&&Util.r(t,LayoutVertex,"centerY"),i.ft(),i.y=t-this.Qe.y,i.w())}get focusX(){return this.Qe.x}set focusX(t){const i=this.Qe;i.x!==t&&(i.ft(),i.x=t,i.w())}get focusY(){return this.Qe.y}set focusY(t){const i=this.Qe;i.y!==t&&(i.ft(),i.y=t,i.w())}get x(){return this.Oe.x}set x(t){const i=this.Oe;i.x!==t&&(i.ft(),i.x=t,i.w())}get y(){return this.Oe.y}set y(t){const i=this.Oe;i.y!==t&&(i.ft(),i.y=t,i.w())}get width(){return this.Oe.width}set width(t){const i=this.Oe;i.width!==t&&(i.ft(),i.width=t,i.w())}get height(){return this.Oe.height}set height(t){const i=this.Oe;i.height!==t&&(i.ft(),i.height=t,i.w())}commit(){const t=this.si;if(t!==null){const e=this.bounds,s=t.bounds;Util.Mt(s)?(s.x=e.x,s.y=e.y,s.width=e.width,s.height=e.height):t.bounds=e.copy();return}const i=this.node;if(i!==null){const e=this.bounds;if(!(i instanceof Group)){const s=Rect.a();i.ensureBounds();const n=this.network.layout.getLayoutBounds(i,s),o=i.locationObject.getDocumentPoint(Spot.Center);if(n.isReal()&&o.isReal()){i.moveTo(e.x+this.focusX-(o.x-n.x)+i.margin.left,e.y+this.focusY-(o.y-n.y+i.margin.top)),Rect.o(s);return}Rect.o(s)}i.moveTo(e.x+i.margin.left,e.y+i.margin.top)}}addSourceEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"addSourceEdge:edge"),this.nr.has(t)||this.nr.add(t))}deleteSourceEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"deleteSourceEdge:edge"),this.nr.delete(t))}addDestinationEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"addDestinationEdge:edge"),this.or.has(t)||this.or.add(t))}deleteDestinationEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"deleteDestinationEdge:edge"),this.or.delete(t))}get network(){return this.bo}set network(t){Debug&&Util.s(t,LayoutNetwork,LayoutVertex,"network"),this.bo=t}get sourceVertexes(){const t=new GSet,i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}return t.iterator}get destinationVertexes(){const t=new GSet,i=this.destinationEdges;for(;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get vertexes(){const t=new GSet;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get sourceEdges(){return this.nr.iterator}get destinationEdges(){return this.or.iterator}get edges(){const t=new List;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e)}return t.iterator}get edgesCount(){return this.nr.count+this.or.count}static standardComparer(t,i){Debug&&Util.s(t,LayoutVertex,LayoutVertex,"standardComparer:m"),Debug&&Util.s(i,LayoutVertex,LayoutVertex,"standardComparer:n");const e=t.we,s=i.we;if(e)if(s){const n=e.text,o=s.text;return no?1:0}else return 1;else return s!==null?-1:0}static smartComparer(t,i){if(Debug&&Util.s(t,LayoutVertex,LayoutVertex,"smartComparer:m"),Debug&&Util.s(i,LayoutVertex,LayoutVertex,"smartComparer:n"),t!==null)if(i!==null){const e=t.we,s=i.we;if(e!==null)if(s!==null){const n=e.text.toLocaleLowerCase(),o=s.text.toLocaleLowerCase(),r=n.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),l=o.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let h=0;for(;h0&&(i+=this.$e!==null?"("+this.$e.toString()+")":"",t>1&&(i+=" "+(this._e?this._e.toString():"null")+" --> "+(this.ts?this.ts.toString():"null"))),i}reverseEdge(){const t=this._e;this._e=this.ts,this.ts=t}commit(){}getOtherVertex(t){return Debug&&Util.s(t,LayoutVertex,LayoutEdge,"getOtherVertex:v"),this.ts===t?this._e:this._e===t?this.ts:null}get network(){return this.bo}set network(t){Debug&&Util.s(t,LayoutNetwork,LayoutEdge,"network"),this.bo=t}get data(){return this.si}set data(t){this.si!==t&&(Debug&&t!==null&&Util.t(t,"object",LayoutEdge,"data"),this.si=t)}get link(){return this.$e}set link(t){this.$e!==t&&(Debug&&t!==null&&Util.s(t,Link,LayoutEdge,"link"),this.$e=t)}get fromVertex(){return this._e}set fromVertex(t){this._e!==t&&(Debug&&t!==null&&Util.s(t,LayoutVertex,LayoutEdge,"fromVertex"),this._e=t)}get toVertex(){return this.ts}set toVertex(t){this.ts!==t&&(Debug&&t!==null&&Util.s(t,LayoutVertex,LayoutEdge,"toVertex"),this.ts=t)}}var GridAlignment=(w=>(w[w.Position=0]="Position",w[w.Location=1]="Location",w))(GridAlignment||{}),GridArrangement=(w=>(w[w.LeftToRight=10]="LeftToRight",w[w.RightToLeft=11]="RightToLeft",w))(GridArrangement||{}),GridSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w))(GridSorting||{});class GridLayout extends Layout{ig;eg;Ro;Rn;ai;qi;ke;Se;constructor(t){super(),this.isViewportSized=!0,this.ig=NaN,this.eg=NaN,this.Ro=new Size(NaN,NaN).w(),this.Rn=new Size(10,10).w(),this.ai=1,this.qi=10,this.ke=22,this.Se=GridLayout.standardComparer,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.ig=this.ig,t.eg=this.eg,t.Ro.c(this.Ro),t.Rn.c(this.Rn),t.ai=this.ai,t.qi=this.qi,t.ke=this.ke,t.Se=this.Se}fi(t){t in GridSorting?this.sorting=t:t in GridArrangement?this.arrangement=t:t in GridAlignment?this.alignment=t:super.fi(t)}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.collectParts(t),e=this.diagram,n=i.copy().iterator;for(;n.next();){const m=n.value;if(m.Dl()&&(m.fromNode!==null||m.toNode!==null)){i.delete(m);continue}if(m.ensureBounds(),m instanceof Group){const g=m.memberParts;for(;g.next();){const p=g.value;i.delete(p)}}}const o=i.toArray();if(o.length===0)return;switch(this.sorting){case 20:break;case 21:o.reverse();break;case 22:o.sort(this.comparer);break;case 23:o.sort(this.comparer),o.reverse();break}let r=this.wrappingColumn;isNaN(r)&&(r=0);let l=this.wrappingWidth;if(isNaN(l)&&e!==null){const m=e.viewportBounds,g=e.padding;l=Math.max(m.width-g.left-g.right,0)}else l=Math.max(this.wrappingWidth,0);r<=0&&l<=0&&(r=1);let h=this.spacing.width;isFinite(h)||(h=0);let a=this.spacing.height;isFinite(a)||(a=0),e!==null&&e.startTransaction("Layout");const f=[];switch(this.alignment){case 0:this.LO(o,l,r,h,a,f);break;case 1:this.TO(o,l,r,h,a,f);break}let c=0,u=0,d=0;for(let m=0;m0&&m>e-1||i>0&&m>0&&A-f>i)&&(o.push(new Rect(0,d,i+s,g)),m=0,u=f,d+=g,g=0),g=Math.max(g,M);let C=0;switch(a){case 11:C=-x.width;break;default:C=0;break}switch(y.moveTo(u+C+y.margin.left,d+y.margin.top),a){case 11:u-=S;break;default:u+=S;break}m++}o.push(new Rect(0,d,i+s,g)),Rect.o(r)}TO(t,i,e,s,n,o){const r=Rect.a();let l=Math.max(this.cellSize.width,1),h=0,a=0,f=0;const c=Point.a();for(let C=0;C=h&&(i-=h);let x=0,k=0;const b=Math.max(this.cellSize.height,1);f=0;let S=0,M=!0;const A=Point.a();for(let C=0;C0)switch(u){case 11:{let D=(g-d-(N.width-T.x))/l;Geo.q(Math.round(D),D)?D=Math.round(D):D=Math.floor(D),g=D*l+d;break}default:{let D=(g-d+T.x)/l;Geo.q(Math.round(D),D)?D=Math.round(D):D=Math.ceil(D),g=D*l+d;break}}else switch(u){case 11:x=g+T.x+N.width;break;default:x=g-T.x;break}let L=0;switch(u){case 11:L=-(g+T.x)+x;break;default:L=g+N.width-T.x-x;break}if(e>0&&y>e-1||i>0&&y>0&&L>i){o.push(new Rect(0,M?p-f:p,i+s,S+f+n));for(let D=0;Dk&&(P.width+=P.x-k,P.x=k)}Rect.o(r)}commitLayers(t,i){}get wrappingWidth(){return this.ig}set wrappingWidth(t){this.ig!==t&&(Util.t(t,"number",GridLayout,"wrappingWidth"),(t>0||isNaN(t))&&(this.ig=t,this.isViewportSized=isNaN(t),this.invalidateLayout()))}get wrappingColumn(){return this.eg}set wrappingColumn(t){this.eg!==t&&(Util.t(t,"number",GridLayout,"wrappingColumn"),(t>0||isNaN(t))&&(this.eg=t,this.invalidateLayout()))}get cellSize(){return this.Ro}set cellSize(t){Util.s(t,Size,GridLayout,"cellSize"),this.Ro.equals(t)||(this.Ro.c(t),this.invalidateLayout())}get spacing(){return this.Rn}set spacing(t){Util.s(t,Size,GridLayout,"spacing"),this.Rn.equals(t)||(this.Rn.c(t),this.invalidateLayout())}get alignment(){return this.ai}set alignment(t){this.ai!==t&&(Util.tt(t,GridAlignment,"GridAlignment"),(t===1||t===0)&&(this.ai=t,this.invalidateLayout()))}get arrangement(){return this.qi}set arrangement(t){this.qi!==t&&(Util.tt(t,GridArrangement,"GridArrangement"),(t===10||t===11)&&(this.qi=t,this.invalidateLayout()))}get sorting(){return this.ke}set sorting(t){this.ke!==t&&(Util.tt(t,GridSorting,"GridSorting"),(t===20||t===21||t===22||t===23)&&(this.ke=t,this.invalidateLayout()))}get comparer(){return this.Se}set comparer(t){this.Se!==t&&(Util.t(t,"function",GridLayout,"comparer"),this.Se=t,this.invalidateLayout())}static standardComparer(t,i){Debug&&Util.s(t,Part,GridLayout,"standardComparer:a"),Debug&&Util.s(i,Part,GridLayout,"standardComparer:b");const e=t.text,s=i.text;return es?1:0}static smartComparer(t,i){if(Debug&&Util.s(t,Part,GridLayout,"standardComparer:a"),Debug&&Util.s(i,Part,GridLayout,"standardComparer:b"),t!==null)if(i!==null){const e=t.text.toLocaleLowerCase(),s=i.text.toLocaleLowerCase(),n=e.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),o=s.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let r=0;for(;r{e.containsNodeData(s)&&this.MT(s,!1)}),t.forEach(s=>{e.containsNodeData(s)&&this.Rb(s)}),i!==!1&&this.diagram.R1(!1)}MT(t,i){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.Mo.has(t))return null;i===void 0&&(i=!0);const e=this.DO(t);return e!==null&&i&&this.Rb(t),e}DO(t){if(t==null||this.b.undoManager.isUndoingRedoing||this.Mo.has(t))return null;const i=this.FO(t),e=this.findTemplateForNodeData(t,i);if(e!==null){e.ci();const s=e.copy();if(s!==null){const n=this.diagram.pe;return this.diagram.pe=!0,s.$o=i,s.si=t,this.Ty&&(s.ul="Tool"),this.diagram.add(s),s.si=null,s.data=t,this.diagram.pe=n,s}}return null}insertLink(t,i,e,s){return null}Rb(t){}FO(t){return this.b.model.getCategoryForNodeData(t)}static PT=!1;static NT=!1;findTemplateForNodeData(t,i){const e=this.b,s=e.model,n=s.ga()&&s.isGroupForData(t);let o=null;return n?(o=e.groupTemplateMap.get(i),o===null&&(o=e.groupTemplateMap.get(""),o===null&&(PartManager.NT||(PartManager.NT=!0,Util.ht('No Group template found for category "'+i+'"'),Util.ht(" Using default group template")),o=e.gP))):(o=e.nodeTemplateMap.get(i),o===null&&(o=e.nodeTemplateMap.get(""),o===null&&(PartManager.PT||(PartManager.PT=!0,Util.ht('No Node template found for category "'+i+'"'),Util.ht(" Using default node template")),o=e.cP))),o}getLinkCategoryForData(t){return""}setLinkCategoryForData(t,i){}setFromNodeForLink(t,i,e){}setToNodeForLink(t,i,e){}static CT=!1;findLinkTemplateForCategory(t){const i=this.b;let e=i.linkTemplateMap.get(t);return e===null&&(e=i.linkTemplateMap.get(""),e===null&&(PartManager.CT||(PartManager.CT=!0,Util.ht('No Link template found for category "'+t+'"'),Util.ht(" Using default link template")),e=i.uP)),e}wI(t,i,e){t instanceof Link?(i!==null&&this.kT(i,t),e!==null&&this.bT(e,t)):t instanceof Part&&(i!==null&&this.Mo.delete(i),e!==null&&this.Mo.set(e,t))}ST(){const t=this.diagram.model;this.kN(t.nodeDataArray)}kN(t){t.forEach(i=>{this.Ib(i)})}Ib(t){const i=this.findPartForData(t);i!==null&&(this.diagram.IP(i,!1),this.SN(i))}SN(t){}uN(t){}findPartForKey(t){if(t==null)return null;const i=this.b.model.findNodeDataForKey(t);return i!==null?this.Mo.get(i):null}findNodeForKey(t){if(t==null)return null;const i=this.b.model.findNodeDataForKey(t);if(i===null)return null;const e=this.Mo.get(i);return e instanceof Node?e:null}findLinkForKey(t){return null}findPartForData(t){if(t===null)return null;let i=this.Mo.get(t);return i!==null||(i=this.yl.get(t)),i}findNodeForData(t){if(t===null)return null;const i=this.Mo.get(t);return i instanceof Node?i:null}findLinkForData(t,i){return t===null?null:this.yl.get(t)}findNodesByExample(...t){const i=new GSet,e=this.sg.iterator;for(;e.next();){const s=e.value,n=s.data;if(n!==null)for(let o=0;o{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),this.parts.each(o=>{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),s.forEach(o=>t.LT(o,!1));for(let o=0;o0){for(let o=0;oi.DA(s));const e=t.xh;if(Array.isArray(e)){const s=this.Ha.get(e);if(s===null){const n=[];n.push(t),this.Ha.set(e,n)}else{for(let n=0;ni.SR(s));const e=t.xh;if(Array.isArray(e)){const s=this.Ha.get(e);if(s!==null){for(let n=0;n0&&i.removeParts(l,!1),h.count>0){const f=h.iterator;for(;f.next();){const c=f.key,u=f.value;s.set(c,u)}}}if(i!==null&&this.b!==null){const o=i.model,r=o.afterCopyFunction;if(r!==null){const l=new GMap;s.each(a=>{a.key.data!==null&&l.set(a.key.data,a.value.data)});const h=this.b.model;r(l,o,h)}}const n=s.iterator;for(;n.next();)n.value.updateTargetBindings();return s}Ob(t,i,e,s){if(t===null||s&&!t.canCopy())return null;if(e.has(t))return e.get(t);const n=this.PN(t,i);if(!(n instanceof Part))return null;if(n.isSelected=!1,n.isHighlighted=!1,e.set(t,n),t instanceof Node){const o=t.linksConnected;for(;o.next();){const r=o.value;if(r.fromNode===t){const l=e.get(r);l!==null&&(l.fromNode=n)}if(r.toNode===t){const l=e.get(r);l!==null&&(l.toNode=n)}}if(t instanceof Group&&n instanceof Group){const r=t.memberParts;for(;r.next();){const l=r.value,h=this.Ob(l,i,e,s);h instanceof Link||h!==null&&(h.containingGroup=n)}}}else if(t instanceof Link&&n instanceof Link){const o=t.fromNode;if(o!==null){const h=e.get(o);h!==null&&(n.fromNode=h)}const r=t.toNode;if(r!==null){const h=e.get(r);h!==null&&(n.toNode=h)}const l=t.labelNodes;for(;l.next();){const h=l.value,a=this.Ob(h,i,e,s);a!==null&&a instanceof Node&&(a.labeledLink=n)}}return n}PN(t,i){let e=null;const s=t.data;if(s!==null&&i!==null){const n=i.model;if(!(t instanceof Link)){const o=n.copyNodeData(s);Util.Mt(o)&&(n.addNodeData(o),e=i.findPartForData(o))}}else if(t.ci(),e=t.copy(),e!==null){const n=this.b;if(i!==null)i.add(e);else if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const o=n.model;let r=null;e instanceof Link||(r=o.copyNodeData(s)),Util.Mt(r)&&(e.data=r)}}return e}get nodes(){return this.sg}get links(){return this.Qs}get parts(){return this.It}get diagram(){return this.b}get addsToTemporaryLayer(){return this.Ty}set addsToTemporaryLayer(t){this.Ty=t}get preservesRebuildLocations(){return this.bN}set preservesRebuildLocations(t){this.bN=t}}class GraphLinksPartManager extends PartManager{EP(){const t=this.diagram.model;this.Dy(t.nodeDataArray),this.FT(t.linkDataArray)}Dy(t){super.Dy(t,!1);const i=this.links.iterator;for(;i.next();)i.value.Od();this.diagram.R1(!1)}FT(t){t.forEach(i=>{this.RT(i)}),this.diagram.R1(!1)}RT(t){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.yl.has(t))return null;const i=this.getLinkCategoryForData(t),e=this.findLinkTemplateForCategory(i);if(e!==null){e.ci();const s=e.copy();if(s!==null){const n=this.diagram.pe;this.diagram.pe=!0,s.$o=i,s.si=t;const o=this.diagram.model,r=o.Eb(t,!0);r!==""&&(s.fromPortId=r);const l=o.Ee(t,!0);if(l!==void 0){const c=this.findNodeForKey(l);c instanceof Node&&(s.fromNode=c)}const h=o.Eb(t,!1);h!==""&&(s.toPortId=h);const a=o.Ee(t,!1);if(a!==void 0){const c=this.findNodeForKey(a);c instanceof Node&&(s.toNode=c)}const f=o.getLabelKeysForLinkData(t);return Array.isArray(f)&&f.forEach(c=>{const u=this.findNodeForKey(c);u!==null&&(u.labeledLink=s)}),this.Ty&&(s.ul="Tool"),this.diagram.add(s),s.si=null,s.data=t,this.diagram.pe=n,s}}return null}ST(){const t=this.diagram.model;this.IT(t.linkDataArray),this.kN(t.nodeDataArray)}IT(t){t.forEach(i=>{this.Ib(i)})}getLinkCategoryForData(t){return this.diagram.model.getCategoryForLinkData(t)}setLinkCategoryForData(t,i){return this.diagram.model.setCategoryForLinkData(t,i)}setFromNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setFromKeyForLinkData(t.data,e.getKeyForNodeData(s))}setToNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setToKeyForLinkData(t.data,e.getKeyForNodeData(s))}uN(t){this.diagram.model.removeLinkData(t.data)}findPartForKey(t){const i=super.findPartForKey(t);if(i===null){const s=this.diagram.model.findLinkDataForKey(t);if(s!==null)return this.yl.get(s)}return i}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findLinkDataForKey(t);return e!==null?this.yl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.j){i.j=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="linkFromKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.fromNode=l}}else if(s==="linkToKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.toNode=l}}else if(s==="linkFromPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.fromPortId=r)}}else if(s==="linkToPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.toPortId=r)}}else if(s==="nodeGroupKey"){const n=t.object,o=this.findPartForData(n);if(o!==null){const r=t.newValue;if(r!==void 0){const l=this.findNodeForKey(r);l instanceof Group?o.containingGroup=l:o.containingGroup=null}else o.containingGroup=null}}else if(s==="linkLabelKeys"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.oldValue,l=t.newValue;Array.isArray(r)&&r.forEach(h=>{if(l.indexOf(h)>=0)return;const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=null)}),Array.isArray(l)&&l.forEach(h=>{const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=o)})}}else if(s==="linkCategory"){const n=t.object,o=this.findLinkForData(n),r=t.newValue;o!==null&&typeof r=="string"&&(o.category=r)}else if(s==="linkDataArray"){const n=t.oldValue;this.IT(n);const o=t.newValue;this.FT(o)}i.isModified=!0}else if(e===3){const n=t.newValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.RT(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=t.object,r=this.findLinkForData(o),l=this.findNodeForKey(n);r!==null&&l!==null&&(l.labeledLink=r)}i.isModified=!0}else if(e===4){const n=t.oldValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.Ib(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=this.findNodeForKey(n);o!==null&&(o.labeledLink=null)}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&(n==="linkFromKeyProperty"||n==="linkToKeyProperty"||n==="linkFromPortIdProperty"||n==="linkToPortIdProperty"||n==="linkLabelKeysProperty"||n==="nodeIsGroupProperty"||n==="nodeGroupKeyProperty"||n==="linkCategoryProperty")&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.j=!0}}}DT(){const t=this.diagram.model,i=new GSet,e=t.linkDataArray;e.forEach(n=>{i.add(n)});const s=[];this.links.each(n=>{n.data!==null&&!i.has(n.data)&&s.push(n.data)}),s.forEach(n=>{t.OT(n,!1)}),e.forEach(n=>{this.findLinkForData(n)===null&&t.ET(n,!1)})}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Link){let n=s.Ee(i,!0),o=e.findNodeForKey(n);t.fromNode=o,n=s.Ee(i,!1),o=e.findNodeForKey(n),t.toNode=o;const r=s.getLabelKeysForLinkData(i);if(r.length>0||t.labelNodes.count>0){if(r.length===1&&t.labelNodes.count===1){const c=r[0],u=t.labelNodes.first();if(s.getKeyForNodeData(u.data)===c)return}const l=new GSet().addAll(r),h=new GSet;t.labelNodes.each(c=>{if(c.data!==null){const u=s.getKeyForNodeData(c.data);u!==void 0&&h.add(u)}});const a=h.copy();a.removeAll(l);const f=l.copy();if(f.removeAll(h),a.count>0||f.count>0){const c=t;a.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink===c&&(d.labeledLink=null)}),f.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink!==c&&(d.labeledLink=c)})}}}else if(!(t instanceof Adornment)){const n=s.getGroupKeyForNodeData(i),o=e.findPartForKey(n);(o===null||o instanceof Group)&&(t.containingGroup=o)}}Rb(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Ry(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)){if(n instanceof Group&&i.getGroupKeyForNodeData(l)===e){const h=this.findPartForData(l);h!==null&&(h.containingGroup=n)}}else{const h=this.findLinkForData(l);if(h!==null&&n instanceof Node){i.Ee(l,!0)===e&&(h.fromNode=n),i.Ee(l,!1)===e&&(h.toNode=n);const a=i.getLabelKeysForLinkData(l);Array.isArray(a)&&a.some(f=>f===e?(n.labeledLink=h,!0):!1)}}}i.tn(e)}const o=i.getGroupKeyForNodeData(t);if(o!==void 0){const r=this.findNodeForKey(o);r instanceof Group&&(n.containingGroup=r)}}}SN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data);if(e!==void 0){const s=t.linksConnected;for(;s.next();){const n=s.value;i.en(e,n.data)}if(t.isLinkLabel){const n=t.labeledLink;n!==null&&i.en(e,n.data)}if(t instanceof Group){const n=t.memberParts;for(;n.next();){const r=n.value.data;i.containsNodeData(r)&&i.en(e,r)}}}}}PN(t,i){let e=super.PN(t,i);if(t instanceof Link){const s=t.data;if(s!==null&&i!==null){const n=i.model,o=n.copyLinkData(s);typeof o=="object"&&o!==null&&(n.addLinkData(o),e=i.findLinkForData(o))}else if(e!==null){const n=this.diagram;if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const r=n.model.copyLinkData(s);typeof r=="object"&&r!==null&&(e.data=r)}}}return e}insertLink(t,i,e,s){const n=this.diagram,o=n.model,r=n.toolManager.findTool("Linking");let l="";t!==null&&(i===null&&(i=t),l=i.portId,l===null&&(l=""));let h="";e!==null&&(s===null&&(s=e),h=s.portId,h===null&&(h=""));const a=r.archetypeLinkData;if(a instanceof Link){a.ci();const f=a.copy();if(f!==null){f.fromNode=t,f.fromPortId=l,f.toNode=e,f.toPortId=h,n.add(f);const c=r.archetypeLabelNodeData;if(c instanceof Node){c.ci();const u=c.copy();u!==null&&(u.labeledLink=f,n.add(u))}return f}}else if(a!==null){const f=o.copyLinkData(a);if(typeof f=="object"&&f!==null){t!==null&&o.ng(f,o.getKeyForNodeData(t.data),!0),o.og(f,l,!0),e!==null&&o.ng(f,o.getKeyForNodeData(e.data),!1),o.og(f,h,!1),o.addLinkData(f);const c=r.archetypeLabelNodeData;if(c!==null&&!(c instanceof Node)){const d=o.copyNodeData(c);if(typeof d=="object"&&d!==null){o.addNodeData(d);const m=o.getKeyForNodeData(d);m!==void 0&&o.addLabelKeyForLinkData(f,m)}}return n.findLinkForData(f)}}return null}}class TreePartManager extends PartManager{Ch=null;Bb(t,i){if(t===null||i===null||i.findTreeParentLink()!==null)return null;const e=this.diagram.toolManager.findTool("Linking");let s=t,n=i;if(this.diagram.isTreePathToChildren){if(e!==null&&e.Cu(s,n,null,!0))return null}else if(s=i,n=t,e!==null&&e.Cu(s,n,null,!0))return null;const o=this.getLinkCategoryForData(i.data),r=this.findLinkTemplateForCategory(o);if(r!==null){r.ci();const l=r.copy();if(l!==null){const h=this.diagram.pe;return this.diagram.pe=!0,l.$o=o,l.si=i.data,l.fromNode=s,l.toNode=n,this.diagram.add(l),l.si=null,l.data=i.data,this.diagram.pe=h,l}}return null}getLinkCategoryForData(t){return this.diagram.model.getParentLinkCategoryForNodeData(t)}setLinkCategoryForData(t,i){this.diagram.model.setParentLinkCategoryForNodeData(t,i)}setFromNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren)s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n));else{const o=this.Ch;this.Ch=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.toNode!==null?t.toNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Ch=o}}setToNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren){const o=this.Ch;this.Ch=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.fromNode!==null?t.fromNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Ch=o}else s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n))}uN(t){this.diagram.model.setParentKeyForNodeData(t.data,void 0)}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findNodeDataForKey(t);return e!==null?this.yl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.j){i.j=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="nodeParentKey"){const n=t.object,o=t.newValue,r=this.findNodeForKey(o),l=this.findNodeForData(n);if(this.Ch!==null)r!==null&&(this.Ch.data=n,this.Ch.category=this.getLinkCategoryForData(n));else if(l!==null){const h=l.findTreeParentLink();h!==null?r===null?i.remove(h):i.isTreePathToChildren?h.fromNode=r:h.toNode=r:this.Bb(r,l)}}else if(s==="parentLinkCategory"){const n=t.object,o=this.findNodeForData(n),r=t.newValue;if(o!==null&&typeof r=="string"){const l=o.findTreeParentLink();l!==null&&(l.category=r)}}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&n==="nodeParentKeyProperty"&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.j=!0}}}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Node){const n=s.getParentKeyForNodeData(i),o=e.findNodeForKey(n),r=t.findTreeParentNode();if(o!==r){const l=t.findTreeParentLink();o!==null?l!==null?e.isTreePathToChildren?l.fromNode=o:l.toNode=o:this.Bb(o,t):l!==null&&e.IP(l,!1)}}}Fy(t,i){if(super.Fy(t,i),typeof i=="string"&&this.findPartForData(t)!==null){const s=this.findLinkForData(t);s!==null&&s.updateTargetBindings(i)}}Rb(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Ry(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)&&n instanceof Node&&i.getParentKeyForNodeData(l)===e){const h=this.findNodeForData(l);this.Bb(n,h)}}i.tn(e)}const o=i.getParentKeyForNodeData(t);if(o!==void 0&&n instanceof Node){const r=this.findNodeForKey(o);this.Bb(r,n)}}}SN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data),s=this.findLinkForData(t.data);if(s!==null){s.isSelected=!1,s.isHighlighted=!1;const r=s.layer;if(r!==null){const l=r.oe(-1,s,!1);l>=0&&this.diagram.raiseChangedEvent(4,"parts",r,s,null,l,null);const h=s.layerChanged;h!==null&&h(s,r,null)}}const n=this.diagram.isTreePathToChildren,o=t.linksConnected;for(;o.next();){const r=o.value,h=(n?r.toNode:r.fromNode).data;i.containsNodeData(h)&&i.en(e,h)}}}insertLink(t,i,e,s){const n=this.diagram.model;let o=t,r=e;if(this.diagram.isTreePathToChildren||(o=e,r=t),o!==null&&r!==null){const l=o.data,h=r.data;return n.setParentKeyForNodeData(h,n.getKeyForNodeData(l)),r.findTreeParentLink()}return null}}var BindingMode=(w=>(w[w.OneWay=1]="OneWay",w[w.TwoWay=2]="TwoWay",w))(BindingMode||{});class Binding{l;NN;qa;Rc;Ah;Ic;Oc;Ec;Vb;Ce;kd;yc;constructor(t,i,e,s){GSet.vi(this),t===void 0?t="":Util.t(t,"string",Binding,"constructor:targetprop"),i===void 0?i=t:Util.t(i,"string",Binding,"constructor:sourceprop"),e===void 0?e=null:e!==null&&Util.t(e,"function",Binding,"constructor:conv"),this.NN=-1,this.Ce=null,this.qa=t,this.kd=0,this.yc=0,this.Rc=null,this.Ah=i,this.Ic=e,s===void 0?(this.Oc=1,this.Ec=null):(this.Oc=2,this.Ec=s),this.Vb=new GSet,this.l=2}copy(){const t=new this.constructor;return this.cloneProtected(t),t}cloneProtected(t){t.qa=this.qa,t.kd=this.kd,t.yc=this.yc,t.Rc=this.Rc,t.Ah=this.Ah,t.Ic=this.Ic,t.Oc=this.Oc,t.Ec=this.Ec,t.l=this.l&-2}static OneWay=1;static TwoWay=2;static parseEnum(t,i){return Util.t(t,"function",Binding,"parseEnum:ctor"),e=>{let s=parseInt(e);return isNaN(s)&&(s=Util.Xh(t,e),s===null)?i:s}}fi(t){t in BindingMode?this.mode=t:Util.ur(this,t)}static toString(t){return Util.toString(t)}toString(){return"Binding("+this.targetProperty+":"+this.sourceProperty+(this.targetId!==-1?" "+this.targetId:"")+" "+BindingMode[this.mode]+")"}w(){return this.l=this.l|1,this}ft(){return this.l=this.l&-2,this}get targetId(){return this.NN}set targetId(t){this.f&&Util.F(this),Util.t(t,"number",Binding,"targetId"),this.NN=t}get targetProperty(){return this.qa}set targetProperty(t){this.f&&Util.F(this),Util.t(t,"string",Binding,"targetProperty"),this.qa=t}get sourceProperty(){return this.Ah}set sourceProperty(t){this.f&&Util.F(this),Util.t(t,"string",Binding,"sourceProperty"),this.Ah=t}get f(){return(this.l&1)!==0}get isToData(){return(this.l&2)!==0}get isToObject(){return(this.l&4)!==0}get isToModel(){return(this.l&8)!==0}get isToTheme(){return(this.l&16)!==0}get CN(){return this.isToTheme&&!(this.isToData||this.isToObject||this.isToModel)}od(){return!1}get sourceName(){return this.Rc}set sourceName(t){this.f&&Util.F(this),t!==null&&Util.t(t,"string",Binding,"sourceName"),this.Rc=t,t!==null?this.l=this.l&-3|4:this.l=this.l|2}get converter(){return this.Ic}set converter(t){this.f&&Util.F(this),t!==null&&Util.t(t,"function",Binding,"converter"),this.Ic=t}get backConverter(){return this.Ec}set backConverter(t){this.f&&Util.F(this),t!==null&&Util.t(t,"function",Binding,"backConverter"),this.Ec=t}get mode(){return this.Oc}set mode(t){this.f&&Util.F(this),this.isToTheme&&t===2&&Util.n("Theme Bindings cannot be TwoWay."),Util.tt(t,BindingMode,"BindingMode"),this.Oc=t}makeTwoWay(t){return this.isToTheme&&Util.n("Theme Bindings cannot be TwoWay."),this.mode=2,t&&(Util.t(t,"function",Binding,"makeTwoWay"),this.backConverter=t),this}ofObject(t){return this.f&&Util.F(this),t===void 0&&(t=""),Debug&&Util.t(t,"string",Binding,"ofObject:srcname"),this.sourceName=t,this}ofModel(){return this.f&&Util.F(this),this.l=this.l&-3&-5|8,this.Rc=null,this}oL(t,i){const e=this.sourceName;let s=null;return e===null||e===""?s=t:e==="/"?s=i.part:e==="."?s=i:e===".."?s=i.panel:s=t.findObject(e),s}check(t){const i=this.qa,e=this.Ah,s=this.Ic;(this.od()&&s===null&&this.Lh===null&&i===""||s===null&&i==="")&&Util.ht("Binding error: target property is the empty string: "+this.toString()),this.od()&&this.CN&&e===""&&s===null&&this.Lh===null&&Util.ht("Binding error: theme bindings require a source property when not using a converter: "+this.toString()),t&&typeof i=="string"&&(typeof t.setAttribute!="function"&&i.length>0&&i[0]!=="_"&&!Util.yw(t,i)?Util.ht("Binding error: undefined target property: "+i+" on "+t.toString()):i==="name"&&t instanceof GraphObject&&Util.ht("Binding error: cannot modify GraphObject.name on "+t.toString()))}updateTarget(t,i,e){const s=this.Ah;if(e!==void 0&&s!==""&&s!==e)return;const n=this.qa,o=this.Ic;let r=i;if(s!==""&&!this.CN&&(r=Model.Xt(i,s)),r===void 0)return;const l=t.diagram?.themeManager??t.panel?.diagram?.themeManager;if(o===null){if(n!==""){if(this.od()&&(r=this.BT(l,r,t,n),r===void 0))return;Model.ct(t,n,r)}}else try{if(n!==""){let h=o(r,t);if(Debug&&h===void 0&&Util.ht('Binding warning: conversion function returned undefined when setting target property "'+n+'" on '+t.toString()+", function is: "+o),this.od()&&(h=this.BT(l,h,t,n),h===void 0))return;Model.ct(t,n,h)}else o(r,t)}catch(h){Debug&&Util.ht("Binding error: "+h.toString()+' setting target property "'+n+'" on '+t.toString()+" with conversion function: "+o)}}updateSource(t,i,e,s){if(this.Oc!==2)return;const n=this.qa;if(e!==void 0&&n!==e)return;const o=this.Ah,r=this.Ec;let l=t;if(n!==""&&(l=Model.Xt(t,n)),l!==void 0&&!this.Vb.has(t))try{this.Vb.add(t);const h=s!==null?s.diagram:null,a=h!==null?h.model:null;if(r===null){if(o!=="")a!==null?(Debug&&a.nodeKeyProperty===o&&a.containsNodeData(i)&&Util.ht("Binding error: cannot have TwoWay Binding on node data key property: "+this.toString()),a.setDataProperty(i,o,l)):Model.ct(i,o,l);else if(a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const f=s.itemIndex,c=s.panel.itemArray;a.removeArrayItem(c,f),a.insertArrayItem(c,f,l)}}else try{if(o!==""){const f=r(l,i,a);a!==null?(Debug&&(a.nodeKeyProperty===o&&a.containsNodeData(i)&&Util.ht("Binding error: cannot have TwoWay Binding on node data key property: "+this.toString()),f===void 0&&Util.ht(`Binding warning: conversion function returned undefined when setting source property "${o}" on ${i.toString()}, function is: ${r}`)),a.setDataProperty(i,o,f)):Model.ct(i,o,f)}else{const f=r(l,i,a);if(f!==void 0&&a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const c=s.itemIndex,u=s.panel.itemArray;a.removeArrayItem(u,c),a.insertArrayItem(u,c,f)}}}catch(f){Debug&&Util.ht("Binding error: "+f.toString()+' setting source property "'+o+'" on '+i.toString()+" with conversion function: "+r)}}finally{this.Vb.delete(t)}}}class ThemeBinding extends Binding{Iy;Lh;ja;constructor(t,i,e,s,n){super(t,i,s),e==null&&(e=""),n===void 0&&(n=null),this.Iy=e,this.Lh=n,this.ja=null,this.l=16}cloneProtected(t){super.cloneProtected(t),t.Iy=this.Iy,t.Lh=this.Lh,t.ja=this.ja}od(){return!0}get themeSource(){return this.Iy}set themeSource(t){this.f&&Util.F(this),t!==null&&Util.t(t,"string",ThemeBinding,"themeSource"),this.Iy=t,this.ja=null,t!==null?this.l=this.l|16:this.l=this.l&-17}get themeConverter(){return this.Lh}set themeConverter(t){this.f&&Util.F(this),t!==null&&Util.t(t,"function",ThemeBinding,"themeConverter"),this.Lh=t}ofData(){return this.f&&Util.F(this),this.l=this.l|2,this.Rc=null,this}BT(t,i,e,s){if(!t||(this.CN&&(i=this.Ah),!i&&i!==0))return;let n=this.themeSource;this.ja!==null?n=this.ja:typeof n=="string"&&n.includes(".")&&(this.ja=n.split("."),n=this.ja);let o=t.findValue(i,n,s);return o===void 0&&Util.ht(`Theme warning: ${i} could not be found when setting target property ${s}.`),typeof this.Lh=="function"&&(o=this.Lh(o,e)),o}}class Model{Tt;rg;zo;zb;Me;Bc;Vc;lg;hg;ag;fg;Wa;lr;Xb;Vo;Yb;oi;Th;cg=new GSet;ug=new GSet;Oy;constructor(t,i){if(GSet.vi(this),this.Tt="",this.rg="",this.zo=!1,this.zb={},this.Me=[],this.oi=new GMap,this.Th="key",this.Bc=null,this.Vc=null,this.lg=!1,this.hg=!1,this.ag=!1,this.fg=null,this.Wa="category",this.lr=new GMap,this.Oy=100,this.Xb=new List,this.Vo=!1,this.Yb=null,this.undoManager=new UndoManager,t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){t.Tt=this.Tt,t.rg=this.rg,t.zo=this.zo,t.Th=this.Th,t.Bc=this.Bc,t.Vc=this.Vc,t.lg=this.lg,t.hg=this.hg,t.ag=this.ag,t.Oy=this.Oy,t.fg=this.fg,t.Wa=this.Wa}copy(){const t=new this.constructor;return this.cloneProtected(t),t}clear(){this.Me=[],this.oi.clear(),this.lr.clear(),this.undoManager.clear()}toString(t){if(t===void 0&&(t=0),t>1)return this.toJson();{let i=(this.name!==""?this.name:"")+" Model";if(t>0){i+=` + node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n{if(u.model===e){if(u.modelChange==="nodeDataArray")u.change===3?n.add(u.newValue):u.change===4&&r.add(u.oldValue);else if(e.containsNodeData(u.object))o.add(u.object);else if(u.change===2&&(e.modelData===u.object||u.propertyName==="modelData"))s=!0;else if(u.object!==null)if(l&&l.has(u.object))l.get(u.object).each(m=>{e.containsNodeData(m)&&o.add(m)});else{if(u.object instanceof Model||e.Ea()&&e.containsLinkData(u.object))return;e.zT(u.object).each(m=>{o.add(m)})}}});const h=this.ug;h.clear(),n.each(u=>{h.add(e.getKeyForNodeData(u)),i||o.add(u)});const a=this.cg;a.clear(),r.each(u=>{a.add(e.getKeyForNodeData(u)),i&&o.add(u)});const f=e.cloneDeep(o.toArray());let c=null;return s&&(c===null&&(c={}),c.modelData=this.cloneDeep(this.modelData)),h.count>0&&(c===null&&(c={}),i?c.removedNodeKeys=h.toArray():c.insertedNodeKeys=h.toArray()),f.length>0&&(c===null&&(c={}),c.modifiedNodeData=f),a.count>0&&(c===null&&(c={}),i?c.insertedNodeKeys=a.toArray():c.removedNodeKeys=a.toArray()),a.clear(),h.clear(),c}cloneDeep(t){return this.dg(t,!0)}dg(t,i,e,s,n){if(!Util.Mt(t))return t;n||(n=[]);const o=Object.isExtensible(t);if(e||(e=new GMap),o){const h=e.get(t);if(h)return h}else{s||(s=new GMap);const h=s.iterator;for(;h.next();){const a=h.key;if(h.value===t){const c=e.get(a);if(c)return c}}}function r(h,a){if(o)h.__gohashid===void 0&&n.push(h),e.set(h,a);else{const f=GSet.fu++;e.set(f,a),s.set(f,t)}}let l;if(Array.isArray(t)){l=[],r(t,l);for(let h=0;h{delete h.__gohashid}),l}Be(t){return JSON.stringify(t).replace(/[\u007F-\uFFFF]/g,e=>{const s="0000"+e.charCodeAt(0).toString(16);return"\\u"+s.substring(s.length-4)})}gg(){let t="";return this.name!==""&&(t+=`, + "name": `+this.Be(this.name)),this.dataFormat!==""&&(t+=`, + "dataFormat": `+this.Be(this.dataFormat)),this.isReadOnly&&(t+=`, "isReadOnly": `+this.isReadOnly),this.nodeKeyProperty!=="key"&&typeof this.nodeKeyProperty=="string"&&(t+=`, - "nodeKeyProperty": `+this.Ve(this.nodeKeyProperty)),this.copiesArrays&&(t+=`, + "nodeKeyProperty": `+this.Be(this.nodeKeyProperty)),this.copiesArrays&&(t+=`, "copiesArrays": true`),this.copiesArrayObjects&&(t+=`, "copiesArrayObjects": true`),this.copiesKey&&(t+=`, "copiesKey": true`),this.pointsDigits!==100&&(t+=`, "pointsDigits": `+this.pointsDigits.toString()),this.nodeCategoryProperty!=="category"&&typeof this.nodeCategoryProperty=="string"&&(t+=`, - "nodeCategoryProperty": `+this.Ve(this.nodeCategoryProperty)),t}Ey(t){t.name&&(this.name=t.name),t.dataFormat&&(this.dataFormat=t.dataFormat),t.isReadOnly&&(this.isReadOnly=!0),t.nodeKeyProperty&&(this.nodeKeyProperty=t.nodeKeyProperty),t.copiesArrays&&(this.copiesArrays=!0),t.copiesArrayObjects&&(this.copiesArrayObjects=!0),t.copiesKey!==void 0&&(this.copiesKey=t.copiesKey),t.pointsDigits!==void 0&&(this.pointsDigits=parseInt(t.pointsDigits)),t.nodeCategoryProperty&&(this.nodeCategoryProperty=t.nodeCategoryProperty)}XT(){const t=this.modelData;return`, - "modelData": `+this.YT(t)}KT(t){const i=t.modelData;Util.Mt(i)&&(this.replaceJsonObjects(i),this.modelData=i)}DN(){const t=this.modelData;let i=!1;for(const s in t)if(!this.Kb(t,s,t[s])){i=!0;break}let e="";return i&&(e=this.XT()),e+`, - "nodeDataArray": `+this.Th(this.nodeDataArray,!0)}FN(t){this.KT(t);const i=t.nodeDataArray;Array.isArray(i)&&(this.replaceJsonObjects(i),this.nodeDataArray=i)}RN(t,i,e){if(t===i)return!0;if(typeof t!=typeof i||typeof t=="function"||typeof i=="function")return!1;if(Array.isArray(t)&&Array.isArray(i)){if(e.get(t)===i)return!0;if(e.set(t,i),t.length!==i.length)return!1;for(let s=0;s{const o=n.part;if(!o)return;const r=o.data;if(s===r)return;let l=i.get(s);l===null?(l=new GSet,l.add(r),i.set(s,l)):l.add(r)};i===null&&(i=new GMap,t.changes.each(s=>{if(s.diagram!==null){const n=s.change;if(n===2){const o=s.object.panel;if(o){const r=o.data;r&&e(r,o)}}else if(n===3||n===4){const o=s.object,r=o.itemArray;r&&e(r,o)}}}),this.Wa=i)}zT(t){const i=new GSet;for(let e=0;e{if(c.model===e){if(c.modelChange==="nodeDataArray")c.change===3?n.add(c.newValue):c.change===4&&r.add(c.oldValue);else if(e.containsNodeData(c.object))o.add(c.object);else if(c.change===2&&(e.modelData===c.object||c.propertyName==="modelData"))s=!0;else if(c.object!==null)if(l&&l.has(c.object))l.get(c.object).each(d=>{e.containsNodeData(d)&&o.add(d)});else{if(c.object instanceof Model||e.Oa()&&e.containsLinkData(c.object))return;e.zT(c.object).each(d=>{o.add(d)})}}});const h=this.dg;h.clear(),n.each(c=>{h.add(e.getKeyForNodeData(c)),i||o.add(c)});const a=this.ug;a.clear(),r.each(c=>{a.add(e.getKeyForNodeData(c)),i&&o.add(c)});let f="";return s&&(f+=this.XT()),h.count>0&&(f+=(i?this.GT:this.UT)+this.Th(h.toArray(),!0)),o.count>0&&(f+=this.EO+this.Th(o.toArray(),!0)),a.count>0&&(f+=(i?this.UT:this.GT)+this.Th(a.toArray(),!0)),a.clear(),h.clear(),f}Vy(t){(t.name!==void 0&&t.name!==this.name||t.dataFormat!==void 0&&t.dataFormat!==this.dataFormat||t.isReadOnly!==void 0&&t.isReadOnly!==this.isReadOnly||t.nodeKeyProperty!==void 0&&t.nodeKeyProperty!==this.nodeKeyProperty||t.copiesArrays!==void 0&&t.copiesArrays!==this.copiesArrays||t.copiesArrayObjects!==void 0&&t.copiesArrayObjects!==this.copiesArrayObjects||t.copiesKey!==void 0&&t.copiesKey!==this.copiesKey||t.nodeCategoryProperty!==void 0&&t.nodeCategoryProperty!==this.nodeCategoryProperty)&&Util.n("applyIncrementalJson cannot change Model properties"),this.KT(t);const i=t.insertedNodeKeys,e=t.modifiedNodeData,s=new GMap;if(Array.isArray(e))for(let o=0;o1&&s.add(` + "removedNodeKeys": `;va=null;VT(t){let i=this.va;const e=(s,n)=>{const o=n.part;if(!o)return;const r=o.data;if(s===r)return;let l=i.get(s);l===null?(l=new GSet,l.add(r),i.set(s,l)):l.add(r)};i===null&&(i=new GMap,t.changes.each(s=>{if(s.diagram!==null){const n=s.change;if(n===2){const o=s.object.panel;if(o){const r=o.data;r&&e(r,o)}}else if(n===3||n===4){const o=s.object,r=o.itemArray;r&&e(r,o)}}}),this.va=i)}zT(t){const i=new GSet;for(let e=0;e{if(c.model===e){if(c.modelChange==="nodeDataArray")c.change===3?n.add(c.newValue):c.change===4&&r.add(c.oldValue);else if(e.containsNodeData(c.object))o.add(c.object);else if(c.change===2&&(e.modelData===c.object||c.propertyName==="modelData"))s=!0;else if(c.object!==null)if(l&&l.has(c.object))l.get(c.object).each(d=>{e.containsNodeData(d)&&o.add(d)});else{if(c.object instanceof Model||e.Ea()&&e.containsLinkData(c.object))return;e.zT(c.object).each(d=>{o.add(d)})}}});const h=this.ug;h.clear(),n.each(c=>{h.add(e.getKeyForNodeData(c)),i||o.add(c)});const a=this.cg;a.clear(),r.each(c=>{a.add(e.getKeyForNodeData(c)),i&&o.add(c)});let f="";return s&&(f+=this.XT()),h.count>0&&(f+=(i?this.GT:this.UT)+this.Dh(h.toArray(),!0)),o.count>0&&(f+=this.OO+this.Dh(o.toArray(),!0)),a.count>0&&(f+=(i?this.UT:this.GT)+this.Dh(a.toArray(),!0)),a.clear(),h.clear(),f}By(t){(t.name!==void 0&&t.name!==this.name||t.dataFormat!==void 0&&t.dataFormat!==this.dataFormat||t.isReadOnly!==void 0&&t.isReadOnly!==this.isReadOnly||t.nodeKeyProperty!==void 0&&t.nodeKeyProperty!==this.nodeKeyProperty||t.copiesArrays!==void 0&&t.copiesArrays!==this.copiesArrays||t.copiesArrayObjects!==void 0&&t.copiesArrayObjects!==this.copiesArrayObjects||t.copiesKey!==void 0&&t.copiesKey!==this.copiesKey||t.nodeCategoryProperty!==void 0&&t.nodeCategoryProperty!==this.nodeCategoryProperty)&&Util.n("applyIncrementalJson cannot change Model properties"),this.KT(t);const i=t.insertedNodeKeys,e=t.modifiedNodeData,s=new GMap;if(Array.isArray(e))for(let o=0;o1&&s.add(` `);for(let n=0;n0&&(s.add(","),i&&s.add(` `)),s.add(this.writeJsonValue(o)))}return i&&e>1&&s.add(` -`),s.add("]"),s.toString()}Kb(t,i,e){return e===void 0||i==="__gohashid"||i[0]==="_"||typeof e=="function"}ji(t){return isNaN(t)?"NaN":t===1/0?"9e9999":t===-1/0?"-9e9999":t}YT(t){const i=t;if(i instanceof Point)t={class:"go.Point",x:this.ji(i.x),y:this.ji(i.y)};else if(i instanceof Size)t={class:"go.Size",width:this.ji(i.width),height:this.ji(i.height)};else if(i instanceof Rect)t={class:"go.Rect",x:this.ji(i.x),y:this.ji(i.y),width:this.ji(i.width),height:this.ji(i.height)};else if(i instanceof Margin)t={class:"go.Margin",top:this.ji(i.top),right:this.ji(i.right),bottom:this.ji(i.bottom),left:this.ji(i.left)};else if(i instanceof Spot)i.isSpot()?t={class:"go.Spot",x:this.ji(i.x),y:this.ji(i.y),offsetX:this.ji(i.offsetX),offsetY:this.ji(i.offsetY)}:t={class:"go.Spot",enum:i.toString()};else if(i instanceof Brush){if(t={class:"go.Brush",type:BrushType[i.type]},i.type===1?t.color=i.color:(i.type===2||i.type===3)&&(t.start=i.start,t.end=i.end,i.type===3&&(i.startRadius!==0&&(t.startRadius=this.ji(i.startRadius)),isNaN(i.endRadius)||(t.endRadius=this.ji(i.endRadius)))),i.colorStops!==null){const n={},o=i.colorStops.iterator;for(;o.next();){const r=o.key,l=o.value;n[r]=l}t.colorStops=n}}else if(i instanceof Geometry)t={class:"go.Geometry",type:GeometryType[i.type]},i.startX!==0&&(t.startX=this.ji(i.startX)),i.startY!==0&&(t.startY=this.ji(i.startY)),i.endX!==0&&(t.endX=this.ji(i.endX)),i.endY!==0&&(t.endY=this.ji(i.endY)),i.spot1.equals(Spot.TopLeft)||(t.spot1=i.spot1),i.spot2.equals(Spot.BottomRight)||(t.spot2=i.spot2),i.type===4&&(t.path=Geometry.stringify(i));else if(Model.Gb(Util.hn(i))!==null)return Util.at("ERROR: trying to convert a GraphObject or Diagram or Model or Tool or Layout or UndoManager or other unknown data type into JSON text: "+i.toString()),"{}";let e="{",s=!0;for(const n in t){const o=Model.Xt(t,n);if(!this.Kb(t,n,o))if(s?s=!1:e+=",",e+=this.Ve(n)+":",n==="points"&&o instanceof List){const r=o;let l="[";const h=r.iterator;for(;h.next();){const a=h.value;l.length>1&&(l+=","),l+=this.HT(a.x),l+=",",l+=this.HT(a.y)}l+="]",e+=l}else e+=this.writeJsonValue(o)}return e+="}",e}HT(t){if(t===1/0)return"9e9999";if(t===-1/0)return"-9e9999";if(isNaN(t))return"0";const i=this.pointsDigits;return i>16?t.toString():t.toFixed(i)}get pointsDigits(){return this.Oy}set pointsDigits(t){t<0?t=0:t>100&&(t=100),this.Oy=t}Wi(t){return typeof t=="number"?t:t==="NaN"?NaN:t==="9e9999"?1/0:t==="-9e9999"?-1/0:parseFloat(t)}BO(t){if(typeof t!="object")return t;let i=t.class||"";if(typeof i!="string"||i==="")return t;if(i==="NaN")return NaN;if(i==="Date")return new Date(t.value);if(i.indexOf("go.")!==0)return t;i=i.substring(3);let e=t;if(i==="Point")e=new Point(this.Wi(t.x),this.Wi(t.y));else if(i==="Size")e=new Size(this.Wi(t.width),this.Wi(t.height));else if(i==="Rect")e=new Rect(this.Wi(t.x),this.Wi(t.y),this.Wi(t.width),this.Wi(t.height));else if(i==="Margin")e=new Margin(this.Wi(t.top),this.Wi(t.right),this.Wi(t.bottom),this.Wi(t.left));else if(i==="Spot")typeof t.enum=="string"?e=Spot.parse(t.enum):e=new Spot(this.Wi(t.x),this.Wi(t.y),this.Wi(t.offsetX),this.Wi(t.offsetY));else if(i==="Brush"){const s=new Brush;s.type=Util.zh(BrushType,t.type)??1,typeof t.color=="string"&&(s.color=t.color),t.start instanceof Spot&&(s.start=t.start),t.end instanceof Spot&&(s.end=t.end),typeof t.startRadius=="number"&&(s.startRadius=this.Wi(t.startRadius)),typeof t.endRadius=="number"&&(s.endRadius=this.Wi(t.endRadius));const n=t.colorStops;if(Util.Mt(n))for(const o in n){const r=parseFloat(o);s.addColorStop(r,n[o])}e=s}else if(i==="Geometry"){let s=null;typeof t.path=="string"?s=Geometry.parse(t.path):s=new Geometry,s.type=Util.zh(GeometryType,t.type)??1,typeof t.startX=="number"&&(s.startX=this.Wi(t.startX)),typeof t.startY=="number"&&(s.startY=this.Wi(t.startY)),typeof t.endX=="number"&&(s.endX=this.Wi(t.endX)),typeof t.endY=="number"&&(s.endY=this.Wi(t.endY)),t.spot1 instanceof Spot&&(s.spot1=t.spot1),t.spot2 instanceof Spot&&(s.spot2=t.spot2),e=s}else if(i==="EnumValue"){let s=t.classType;s.indexOf("go.")===0&&(s=s.substring(3));const n=Model.Gb(s);typeof n=="function"&&(e=Util.zh(n,t.name))}return e}get name(){return this.Tt}set name(t){const i=this.Tt;i!==t&&(Util.t(t,"string",Model,"name"),this.Tt=t,this.i("name",i,t))}get dataFormat(){return this.lg}set dataFormat(t){const i=this.lg;i!==t&&(Util.t(t,"string",Model,"dataFormat"),this.lg=t,this.i("dataFormat",i,t))}get isReadOnly(){return this.zo}set isReadOnly(t){const i=this.zo;i!==t&&(Util.t(t,"boolean",Model,"isReadOnly"),this.zo=t,this.i("isReadOnly",i,t))}get modelData(){return this.zb}set modelData(t){const i=this.zb;i!==t&&(Util.t(t,"object",Model,"modelData"),this.zb=t,this.i("modelData",i,t),this.updateTargetBindings(t))}addChangedListener(t){return Util.t(t,"function",Model,"addChangedListener:listener"),this.Xb.add(t),this}removeChangedListener(t){Util.t(t,"function",Model,"removeChangedListener:listener"),this.Xb.delete(t)}Hw(t){this.skipsUndoManager||this.undoManager.handleChanged(t);const i=this.Xb,e=i.length;for(let s=0;s0&&Util.n("Cannot set Model.nodeKeyProperty when there is existing node data"),this.Lh=t,this.i("nodeKeyProperty",i,t))}In(t,i,e){typeof t!="string"&&typeof t!="function"&&Util.Vi(t,"string or function",i,e)}getKeyForNodeData(t){if(t===null)return;const i=this.Lh;if(i==="")return;const e=Model.Xt(t,i);if(e!==void 0){if(this.isKeyType(e))return e;Util.n("Key value for node data "+t+" is not a number or a string: "+e)}}setKeyForNodeData(t,i){if((i==null||!this.isKeyType(i))&&Util.Vi(i,"number or string",Model,"setKeyForNodeData:key"),t===null)return;const e=this.Lh;if(e==="")return;if(!this.containsNodeData(t)){Model.ut(t,e,i);return}const s=Model.Xt(t,e);if(s!==i){if(this.findNodeDataForKey(i)!==null)return;Model.ut(t,e,i),s!==void 0&&this.oi.delete(s),this.oi.set(i,t),this.Kt("nodeKey",2,e,t,s,i),typeof e=="string"&&this.updateTargetBindings(t,e),this.By(s,i)}}get makeUniqueKeyFunction(){return this.Ec}set makeUniqueKeyFunction(t){const i=this.Ec;i!==t&&(t!==null&&Util.t(t,"function",Model,"makeUniqueKeyFunction"),this.Ec=t,this.i("makeUniqueKeyFunction",i,t))}isKeyType(t){return typeof t=="number"||typeof t=="string"}containsNodeData(t){if(t===null)return!1;const i=this.getKeyForNodeData(t);return i===void 0?!1:this.oi.get(i)===t}findNodeDataForKey(t){return t===null&&Util.n("Model.findNodeDataForKey:key must not be null"),t===void 0||!this.isKeyType(t)?null:this.oi.get(t)}get nodeDataArray(){return this.Me}set nodeDataArray(t){const i=this.Me;if(i!==t){Util.Gg(t,Model,"nodeDataArray"),this.oi.clear(),this.ON();const e=t.length;for(let o=0;o=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" GraphLinksModel";if(t>0){i+=` +`),s.add("]"),s.toString()}Kb(t,i,e){return e===void 0||i==="__gohashid"||i[0]==="_"||typeof e=="function"}ji(t){return isNaN(t)?"NaN":t===1/0?"9e9999":t===-1/0?"-9e9999":t}YT(t){const i=t;if(i instanceof Point)t={class:"go.Point",x:this.ji(i.x),y:this.ji(i.y)};else if(i instanceof Size)t={class:"go.Size",width:this.ji(i.width),height:this.ji(i.height)};else if(i instanceof Rect)t={class:"go.Rect",x:this.ji(i.x),y:this.ji(i.y),width:this.ji(i.width),height:this.ji(i.height)};else if(i instanceof Margin)t={class:"go.Margin",top:this.ji(i.top),right:this.ji(i.right),bottom:this.ji(i.bottom),left:this.ji(i.left)};else if(i instanceof Spot)i.isSpot()?t={class:"go.Spot",x:this.ji(i.x),y:this.ji(i.y),offsetX:this.ji(i.offsetX),offsetY:this.ji(i.offsetY)}:t={class:"go.Spot",enum:i.toString()};else if(i instanceof Brush){if(t={class:"go.Brush",type:BrushType[i.type]},i.type===1?t.color=i.color:(i.type===2||i.type===3)&&(t.start=i.start,t.end=i.end,i.type===3&&(i.startRadius!==0&&(t.startRadius=this.ji(i.startRadius)),isNaN(i.endRadius)||(t.endRadius=this.ji(i.endRadius)))),i.colorStops!==null){const n={},o=i.colorStops.iterator;for(;o.next();){const r=o.key,l=o.value;n[r]=l}t.colorStops=n}}else if(i instanceof Geometry)t={class:"go.Geometry",type:GeometryType[i.type]},i.startX!==0&&(t.startX=this.ji(i.startX)),i.startY!==0&&(t.startY=this.ji(i.startY)),i.endX!==0&&(t.endX=this.ji(i.endX)),i.endY!==0&&(t.endY=this.ji(i.endY)),i.spot1.equals(Spot.TopLeft)||(t.spot1=i.spot1),i.spot2.equals(Spot.BottomRight)||(t.spot2=i.spot2),i.type===4&&(t.path=Geometry.stringify(i));else if(Model.Gb(Util.hn(i))!==null)return Util.ht("ERROR: trying to convert a GraphObject or Diagram or Model or Tool or Layout or UndoManager or other unknown data type into JSON text: "+i.toString()),"{}";let e="{",s=!0;for(const n in t){const o=Model.Xt(t,n);if(!this.Kb(t,n,o))if(s?s=!1:e+=",",e+=this.Be(n)+":",n==="points"&&o instanceof List){const r=o;let l="[";const h=r.iterator;for(;h.next();){const a=h.value;l.length>1&&(l+=","),l+=this.HT(a.x),l+=",",l+=this.HT(a.y)}l+="]",e+=l}else e+=this.writeJsonValue(o)}return e+="}",e}HT(t){if(t===1/0)return"9e9999";if(t===-1/0)return"-9e9999";if(isNaN(t))return"0";const i=this.pointsDigits;return i>16?t.toString():t.toFixed(i)}get pointsDigits(){return this.Oy}set pointsDigits(t){t<0?t=0:t>100&&(t=100),this.Oy=t}Wi(t){return typeof t=="number"?t:t==="NaN"?NaN:t==="9e9999"?1/0:t==="-9e9999"?-1/0:parseFloat(t)}BO(t){if(typeof t!="object")return t;let i=t.class||"";if(typeof i!="string"||i==="")return t;if(i==="NaN")return NaN;if(i==="Date")return new Date(t.value);if(i.indexOf("go.")!==0)return t;i=i.substring(3);let e=t;if(i==="Point")e=new Point(this.Wi(t.x),this.Wi(t.y));else if(i==="Size")e=new Size(this.Wi(t.width),this.Wi(t.height));else if(i==="Rect")e=new Rect(this.Wi(t.x),this.Wi(t.y),this.Wi(t.width),this.Wi(t.height));else if(i==="Margin")e=new Margin(this.Wi(t.top),this.Wi(t.right),this.Wi(t.bottom),this.Wi(t.left));else if(i==="Spot")typeof t.enum=="string"?e=Spot.parse(t.enum):e=new Spot(this.Wi(t.x),this.Wi(t.y),this.Wi(t.offsetX),this.Wi(t.offsetY));else if(i==="Brush"){const s=new Brush;s.type=Util.Xh(BrushType,t.type)??1,typeof t.color=="string"&&(s.color=t.color),t.start instanceof Spot&&(s.start=t.start),t.end instanceof Spot&&(s.end=t.end),typeof t.startRadius=="number"&&(s.startRadius=this.Wi(t.startRadius)),typeof t.endRadius=="number"&&(s.endRadius=this.Wi(t.endRadius));const n=t.colorStops;if(Util.Mt(n))for(const o in n){const r=parseFloat(o);s.addColorStop(r,n[o])}e=s}else if(i==="Geometry"){let s=null;typeof t.path=="string"?s=Geometry.parse(t.path):s=new Geometry,s.type=Util.Xh(GeometryType,t.type)??1,typeof t.startX=="number"&&(s.startX=this.Wi(t.startX)),typeof t.startY=="number"&&(s.startY=this.Wi(t.startY)),typeof t.endX=="number"&&(s.endX=this.Wi(t.endX)),typeof t.endY=="number"&&(s.endY=this.Wi(t.endY)),t.spot1 instanceof Spot&&(s.spot1=t.spot1),t.spot2 instanceof Spot&&(s.spot2=t.spot2),e=s}else if(i==="EnumValue"){let s=t.classType;s.indexOf("go.")===0&&(s=s.substring(3));const n=Model.Gb(s);typeof n=="function"&&(e=Util.Xh(n,t.name))}return e}get name(){return this.Tt}set name(t){const i=this.Tt;i!==t&&(Util.t(t,"string",Model,"name"),this.Tt=t,this.i("name",i,t))}get dataFormat(){return this.rg}set dataFormat(t){const i=this.rg;i!==t&&(Util.t(t,"string",Model,"dataFormat"),this.rg=t,this.i("dataFormat",i,t))}get isReadOnly(){return this.zo}set isReadOnly(t){const i=this.zo;i!==t&&(Util.t(t,"boolean",Model,"isReadOnly"),this.zo=t,this.i("isReadOnly",i,t))}get modelData(){return this.zb}set modelData(t){const i=this.zb;i!==t&&(Util.t(t,"object",Model,"modelData"),this.zb=t,this.i("modelData",i,t),this.updateTargetBindings(t))}addChangedListener(t){return Util.t(t,"function",Model,"addChangedListener:listener"),this.Xb.add(t),this}removeChangedListener(t){Util.t(t,"function",Model,"removeChangedListener:listener"),this.Xb.delete(t)}Hw(t){this.skipsUndoManager||this.undoManager.handleChanged(t);const i=this.Xb,e=i.length;for(let s=0;s0&&Util.n("Cannot set Model.nodeKeyProperty when there is existing node data"),this.Th=t,this.i("nodeKeyProperty",i,t))}In(t,i,e){typeof t!="string"&&typeof t!="function"&&Util.Bi(t,"string or function",i,e)}getKeyForNodeData(t){if(t===null)return;const i=this.Th;if(i==="")return;const e=Model.Xt(t,i);if(e!==void 0){if(this.isKeyType(e))return e;Util.n("Key value for node data "+t+" is not a number or a string: "+e)}}setKeyForNodeData(t,i){if((i==null||!this.isKeyType(i))&&Util.Bi(i,"number or string",Model,"setKeyForNodeData:key"),t===null)return;const e=this.Th;if(e==="")return;if(!this.containsNodeData(t)){Model.ct(t,e,i);return}const s=Model.Xt(t,e);if(s!==i){if(this.findNodeDataForKey(i)!==null)return;Model.ct(t,e,i),s!==void 0&&this.oi.delete(s),this.oi.set(i,t),this.Kt("nodeKey",2,e,t,s,i),typeof e=="string"&&this.updateTargetBindings(t,e),this.Vy(s,i)}}get makeUniqueKeyFunction(){return this.Bc}set makeUniqueKeyFunction(t){const i=this.Bc;i!==t&&(t!==null&&Util.t(t,"function",Model,"makeUniqueKeyFunction"),this.Bc=t,this.i("makeUniqueKeyFunction",i,t))}isKeyType(t){return typeof t=="number"||typeof t=="string"}containsNodeData(t){if(t===null)return!1;const i=this.getKeyForNodeData(t);return i===void 0?!1:this.oi.get(i)===t}findNodeDataForKey(t){return t===null&&Util.n("Model.findNodeDataForKey:key must not be null"),t===void 0||!this.isKeyType(t)?null:this.oi.get(t)}get nodeDataArray(){return this.Me}set nodeDataArray(t){const i=this.Me;if(i!==t){Util.Ug(t,Model,"nodeDataArray"),this.oi.clear(),this.RN();const e=t.length;for(let o=0;o=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" GraphLinksModel";if(t>0){i+=` node data:`;let e=this.nodeDataArray,s=e.length,n=0;for(n=0;n"+this.Ee(o,!1)}}return i}}TN(t,i){if(this.linkKeyProperty===""){const c=this.skipsUndoManager;this.skipsUndoManager=!0,this.linkKeyProperty="key",this.skipsUndoManager=c}let e=super.TN(t,i);const s=this,n=new GSet,o=new GSet,r=new GSet,l=this.Wa;t.changes.each(c=>{if(c.model===s){if(c.modelChange==="linkDataArray")c.change===3?n.add(c.newValue):c.change===4&&r.add(c.oldValue);else if(s.containsLinkData(c.object))o.add(c.object);else if(c.object!==null)if(c.object!==null&&l&&l.has(c.object))l.get(c.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(c.object instanceof Model||s.containsNodeData(c.object))return;s.jT(c.object).each(d=>o.add(d))}}});const h=this.dg;h.clear(),n.each(c=>{h.add(s.getKeyForLinkData(c)),i||o.add(c)});const a=this.ug;a.clear(),r.each(c=>{a.add(s.getKeyForLinkData(c)),i&&o.add(c)});const f=s.cloneDeep(o.toArray());return h.count>0&&(e===null&&(e={}),i?e.removedLinkKeys=h.toArray():e.insertedLinkKeys=h.toArray()),f.length>0&&(e===null&&(e={}),e.modifiedLinkData=f),a.count>0&&(e===null&&(e={}),i?e.insertedLinkKeys=a.toArray():e.removedLinkKeys=a.toArray()),a.clear(),h.clear(),e}mg(){const t=super.mg();let i="";return this.linkCategoryProperty!=="category"&&typeof this.linkCategoryProperty=="string"&&(i+=`, - "linkCategoryProperty": `+this.Ve(this.linkCategoryProperty)),this.linkKeyProperty!==""&&typeof this.linkKeyProperty=="string"&&(i+=`, - "linkKeyProperty": `+this.Ve(this.linkKeyProperty)),this.linkFromKeyProperty!=="from"&&typeof this.linkFromKeyProperty=="string"&&(i+=`, - "linkFromKeyProperty": `+this.Ve(this.linkFromKeyProperty)),this.linkToKeyProperty!=="to"&&typeof this.linkToKeyProperty=="string"&&(i+=`, - "linkToKeyProperty": `+this.Ve(this.linkToKeyProperty)),this.linkFromPortIdProperty!==""&&typeof this.linkFromPortIdProperty=="string"&&(i+=`, - "linkFromPortIdProperty": `+this.Ve(this.linkFromPortIdProperty)),this.linkToPortIdProperty!==""&&typeof this.linkToPortIdProperty=="string"&&(i+=`, - "linkToPortIdProperty": `+this.Ve(this.linkToPortIdProperty)),this.linkLabelKeysProperty!==""&&typeof this.linkLabelKeysProperty=="string"&&(i+=`, - "linkLabelKeysProperty": `+this.Ve(this.linkLabelKeysProperty)),this.nodeIsGroupProperty!=="isGroup"&&typeof this.nodeIsGroupProperty=="string"&&(i+=`, - "nodeIsGroupProperty": `+this.Ve(this.nodeIsGroupProperty)),this.nodeGroupKeyProperty!=="group"&&typeof this.nodeGroupKeyProperty=="string"&&(i+=`, - "nodeGroupKeyProperty": `+this.Ve(this.nodeGroupKeyProperty)),t+i}Ey(t){super.Ey(t),t.linkKeyProperty&&(this.linkKeyProperty=t.linkKeyProperty),t.linkFromKeyProperty&&(this.linkFromKeyProperty=t.linkFromKeyProperty),t.linkToKeyProperty&&(this.linkToKeyProperty=t.linkToKeyProperty),t.linkFromPortIdProperty&&(this.linkFromPortIdProperty=t.linkFromPortIdProperty),t.linkToPortIdProperty&&(this.linkToPortIdProperty=t.linkToPortIdProperty),t.linkCategoryProperty&&(this.linkCategoryProperty=t.linkCategoryProperty),t.linkLabelKeysProperty&&(this.linkLabelKeysProperty=t.linkLabelKeysProperty),t.nodeIsGroupProperty&&(this.nodeIsGroupProperty=t.nodeIsGroupProperty),t.nodeGroupKeyProperty&&(this.nodeGroupKeyProperty=t.nodeGroupKeyProperty)}DN(){const t=super.DN(),i=`, - "linkDataArray": `+this.Th(this.linkDataArray,!0);return t+i}FN(t){super.FN(t);const i=t.linkDataArray;Array.isArray(i)&&(this.replaceJsonObjects(i),this.linkDataArray=i)}WT=`, - "insertedLinkKeys": `;XO=`, + link data:`,e=this.linkDataArray,s=e.length,n=0;n"+this.Ee(o,!1)}}return i}}AN(t,i){if(this.linkKeyProperty===""){const c=this.skipsUndoManager;this.skipsUndoManager=!0,this.linkKeyProperty="key",this.skipsUndoManager=c}let e=super.AN(t,i);const s=this,n=new GSet,o=new GSet,r=new GSet,l=this.va;t.changes.each(c=>{if(c.model===s){if(c.modelChange==="linkDataArray")c.change===3?n.add(c.newValue):c.change===4&&r.add(c.oldValue);else if(s.containsLinkData(c.object))o.add(c.object);else if(c.object!==null)if(c.object!==null&&l&&l.has(c.object))l.get(c.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(c.object instanceof Model||s.containsNodeData(c.object))return;s.jT(c.object).each(d=>o.add(d))}}});const h=this.ug;h.clear(),n.each(c=>{h.add(s.getKeyForLinkData(c)),i||o.add(c)});const a=this.cg;a.clear(),r.each(c=>{a.add(s.getKeyForLinkData(c)),i&&o.add(c)});const f=s.cloneDeep(o.toArray());return h.count>0&&(e===null&&(e={}),i?e.removedLinkKeys=h.toArray():e.insertedLinkKeys=h.toArray()),f.length>0&&(e===null&&(e={}),e.modifiedLinkData=f),a.count>0&&(e===null&&(e={}),i?e.insertedLinkKeys=a.toArray():e.removedLinkKeys=a.toArray()),a.clear(),h.clear(),e}gg(){const t=super.gg();let i="";return this.linkCategoryProperty!=="category"&&typeof this.linkCategoryProperty=="string"&&(i+=`, + "linkCategoryProperty": `+this.Be(this.linkCategoryProperty)),this.linkKeyProperty!==""&&typeof this.linkKeyProperty=="string"&&(i+=`, + "linkKeyProperty": `+this.Be(this.linkKeyProperty)),this.linkFromKeyProperty!=="from"&&typeof this.linkFromKeyProperty=="string"&&(i+=`, + "linkFromKeyProperty": `+this.Be(this.linkFromKeyProperty)),this.linkToKeyProperty!=="to"&&typeof this.linkToKeyProperty=="string"&&(i+=`, + "linkToKeyProperty": `+this.Be(this.linkToKeyProperty)),this.linkFromPortIdProperty!==""&&typeof this.linkFromPortIdProperty=="string"&&(i+=`, + "linkFromPortIdProperty": `+this.Be(this.linkFromPortIdProperty)),this.linkToPortIdProperty!==""&&typeof this.linkToPortIdProperty=="string"&&(i+=`, + "linkToPortIdProperty": `+this.Be(this.linkToPortIdProperty)),this.linkLabelKeysProperty!==""&&typeof this.linkLabelKeysProperty=="string"&&(i+=`, + "linkLabelKeysProperty": `+this.Be(this.linkLabelKeysProperty)),this.nodeIsGroupProperty!=="isGroup"&&typeof this.nodeIsGroupProperty=="string"&&(i+=`, + "nodeIsGroupProperty": `+this.Be(this.nodeIsGroupProperty)),this.nodeGroupKeyProperty!=="group"&&typeof this.nodeGroupKeyProperty=="string"&&(i+=`, + "nodeGroupKeyProperty": `+this.Be(this.nodeGroupKeyProperty)),t+i}Ey(t){super.Ey(t),t.linkKeyProperty&&(this.linkKeyProperty=t.linkKeyProperty),t.linkFromKeyProperty&&(this.linkFromKeyProperty=t.linkFromKeyProperty),t.linkToKeyProperty&&(this.linkToKeyProperty=t.linkToKeyProperty),t.linkFromPortIdProperty&&(this.linkFromPortIdProperty=t.linkFromPortIdProperty),t.linkToPortIdProperty&&(this.linkToPortIdProperty=t.linkToPortIdProperty),t.linkCategoryProperty&&(this.linkCategoryProperty=t.linkCategoryProperty),t.linkLabelKeysProperty&&(this.linkLabelKeysProperty=t.linkLabelKeysProperty),t.nodeIsGroupProperty&&(this.nodeIsGroupProperty=t.nodeIsGroupProperty),t.nodeGroupKeyProperty&&(this.nodeGroupKeyProperty=t.nodeGroupKeyProperty)}LN(){const t=super.LN(),i=`, + "linkDataArray": `+this.Dh(this.linkDataArray,!0);return t+i}TN(t){super.TN(t);const i=t.linkDataArray;Array.isArray(i)&&(this.replaceJsonObjects(i),this.linkDataArray=i)}WT=`, + "insertedLinkKeys": `;zO=`, "modifiedLinkData": `;vT=`, - "removedLinkKeys": `;jT(t){const i=new GSet;for(let e=0;e{if(c.model===s){if(c.modelChange==="linkDataArray")c.change===3?n.add(c.newValue):c.change===4&&r.add(c.oldValue);else if(s.containsLinkData(c.object))o.add(c.object);else if(c.object!==null)if(c.object!==null&&l&&l.has(c.object))l.get(c.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(c.object instanceof Model||s.containsNodeData(c.object))return;s.jT(c.object).each(d=>o.add(d))}}});const h=this.dg;h.clear(),n.each(c=>{h.add(s.getKeyForLinkData(c)),i||o.add(c)});const a=this.ug;a.clear(),r.each(c=>{a.add(s.getKeyForLinkData(c)),i&&o.add(c)});let f=e;return h.count>0&&(f+=(i?this.vT:this.WT)+this.Th(h.toArray(),!0)),o.count>0&&(f+=this.XO+this.Th(o.toArray(),!0)),a.count>0&&(f+=(i?this.WT:this.vT)+this.Th(a.toArray(),!0)),a.clear(),h.clear(),f}Vy(t){(t.linkCategoryProperty!==void 0&&t.linkCategoryProperty!==this.linkCategoryProperty||t.linkKeyProperty!==void 0&&t.linkKeyProperty!==this.linkKeyProperty||t.linkFromKeyProperty!==void 0&&t.linkFromKeyProperty!==this.linkFromKeyProperty||t.linkToKeyProperty!==void 0&&t.linkToKeyProperty!==this.linkToKeyProperty||t.linkFromPortIdProperty!==void 0&&t.linkFromPortIdProperty!==this.linkFromPortIdProperty||t.linkToPortIdProperty!==void 0&&t.linkToPortIdProperty!==this.linkToPortIdProperty||t.linkLabelKeysProperty!==void 0&&t.linkLabelKeysProperty!==this.linkLabelKeysProperty||t.nodeIsGroupProperty!==void 0&&t.nodeIsGroupProperty!==this.nodeIsGroupProperty||t.nodeGroupKeyProperty!==void 0&&t.nodeGroupKeyProperty!==this.nodeGroupKeyProperty)&&Util.n("applyIncrementalJson cannot change Model properties"),super.Vy(t);const i=t.insertedLinkKeys;if(Array.isArray(i)){const n=i.length;for(let o=0;o=0&&s.splice(e,1)):s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue));return}}else if(t.change===4){let e=t.oldParam;if(t.modelChange==="linkDataArray"){const s=t.oldValue;if(Util.Mt(s)&&typeof e=="number"){const n=this.getKeyForLinkData(s);i?(this.hr.add(s),this.is[e]!==s&&this.is.splice(e,0,s),n!==void 0&&this.mi.set(n,s)):(this.hr.delete(s),this.is[e]===s&&this.is.splice(e,1),n!==void 0&&this.mi.delete(n))}return}else if(t.modelChange==="linkLabelKeys"){const s=this.getLabelKeysForLinkData(t.object);Array.isArray(s)&&typeof e=="number"&&(i?s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue):(e=s.indexOf(t.newValue),e>=0&&s.splice(e,1)));return}}super.changeState(t,i)}}get archetypeNodeData(){return this.Fl}set archetypeNodeData(t){const i=this.Fl;i!==t&&(t!==null&&Util.t(t,"object",GraphLinksModel,"archetypeNodeData"),this.Fl=t,this.i("archetypeNodeData",i,t))}EN(t){if(t===void 0)return;const i=this.Fl;if(i!==null){let e=this.findNodeDataForKey(t);e===null&&(e=this.copyNodeData(i),Model.ut(e,this.nodeKeyProperty,t),this.addNodeData(e))}return t}get linkFromKeyProperty(){return this.Po}set linkFromKeyProperty(t){const i=this.Po;i!==t&&(this.In(t,GraphLinksModel,"linkFromKeyProperty"),this.Po=t,this.i("linkFromKeyProperty",i,t))}getFromKeyForLinkData(t){return this.Ee(t,!0)}setFromKeyForLinkData(t,i){this.og(t,i,!0)}get linkToKeyProperty(){return this.No}set linkToKeyProperty(t){const i=this.No;i!==t&&(this.In(t,GraphLinksModel,"linkToKeyProperty"),this.No=t,this.i("linkToKeyProperty",i,t))}getToKeyForLinkData(t){return this.Ee(t,!1)}setToKeyForLinkData(t,i){this.og(t,i,!1)}Ee(t,i){if(t===null)return;const e=i?this.Po:this.No;if(e==="")return;const s=Model.Xt(t,e);if(s!==void 0){if(this.isKeyType(s))return s;Util.n((i?"FromKey":"ToKey")+" value for link data "+t+" is not a number or a string: "+s)}}og(t,i,e){if(i===null&&(i=void 0),i!==void 0&&!this.isKeyType(i)&&Util.Vi(i,"number or string",GraphLinksModel,e?"setFromKeyForLinkData:key":"setToKeyForLinkData:key"),t===null)return;const s=e?this.Po:this.No;if(s==="")return;if(i=this.EN(i),!this.containsLinkData(t)){Model.ut(t,s,i);return}const n=Model.Xt(t,s);n!==i&&(this.tn(n,t),Model.ut(t,s,i),this.findNodeDataForKey(i)===null&&this.en(i,t),this.Kt(e?"linkFromKey":"linkToKey",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkFromPortIdProperty(){return this.va}set linkFromPortIdProperty(t){const i=this.va;i!==t&&(this.In(t,GraphLinksModel,"linkFromPortIdProperty"),Debug&&(t===this.linkFromKeyProperty||t===this.linkToKeyProperty)&&Util.n("linkFromPortIdProperty name must not be the same as the GraphLinksModel.linkFromKeyProperty or linkToKeyProperty: "+t),this.va=t,this.i("linkFromPortIdProperty",i,t))}getFromPortIdForLinkData(t){return this.Eb(t,!0)}setFromPortIdForLinkData(t,i){this.rg(t,i,!0)}get linkToPortIdProperty(){return this.Ja}set linkToPortIdProperty(t){const i=this.Ja;i!==t&&(this.In(t,GraphLinksModel,"linkToPortIdProperty"),Debug&&(t===this.linkFromKeyProperty||t===this.linkToKeyProperty)&&Util.n("linkFromPortIdProperty name must not be the same as the GraphLinksModel.linkFromKeyProperty or linkToKeyProperty: "+t),this.Ja=t,this.i("linkToPortIdProperty",i,t))}getToPortIdForLinkData(t){return this.Eb(t,!1)}setToPortIdForLinkData(t,i){this.rg(t,i,!1)}Eb(t,i){if(t===null)return"";const e=i?this.va:this.Ja;if(e==="")return"";const s=Model.Xt(t,e);return s===void 0?"":s}rg(t,i,e){if(Util.t(i,"string",GraphLinksModel,e?"setFromPortIdForLinkData:portname":"setToPortIdForLinkData:portname"),t===null)return;const s=e?this.va:this.Ja;if(s==="")return;if(!this.containsLinkData(t)){Model.ut(t,s,i);return}let n=Model.Xt(t,s);n===void 0&&(n=""),n!==i&&(Model.ut(t,s,i),this.Kt(e?"linkFromPortId":"linkToPortId",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkLabelKeysProperty(){return this.sn}set linkLabelKeysProperty(t){const i=this.sn;i!==t&&(this.In(t,GraphLinksModel,"linkLabelKeysProperty"),this.sn=t,this.i("linkLabelKeysProperty",i,t))}getLabelKeysForLinkData(t){if(t===null)return GraphLinksModel.EmptyArray;const i=this.sn;if(i==="")return GraphLinksModel.EmptyArray;const e=Model.Xt(t,i);return e===void 0?GraphLinksModel.EmptyArray:e}setLabelKeysForLinkData(t,i){if(Util.Gg(i,GraphLinksModel,"setLabelKeysForLinkData:arr"),t===null)return;const e=this.sn;if(e==="")return;if(!this.containsLinkData(t)){Model.ut(t,e,i);return}let s=Model.Xt(t,e);if(s===void 0&&(s=GraphLinksModel.EmptyArray),s!==i){if(Array.isArray(s)){const o=s.length;for(let r=0;r=0)return;n=s.length,s.push(i),this.containsLinkData(t)&&(this.findNodeDataForKey(i)===null&&this.en(i,t),this.Kt("linkLabelKeys",3,e,t,null,i,null,n))}else Util.n(e+" property is not an Array; cannot addLabelKeyForLinkData: "+t)}removeLabelKeyForLinkData(t,i){if(i==null||(this.isKeyType(i)||Util.Vi(i,"number or string",GraphLinksModel,"removeLabelKeyForLinkData:key"),t===null))return;const e=this.sn;if(e==="")return;const s=Model.Xt(t,e);if(Array.isArray(s)){const n=s.indexOf(i);if(n<0)return;s.splice(n,1),this.containsLinkData(t)&&(this.tn(i,t),this.Kt("linkLabelKeys",4,e,t,i,null,n,null))}else s!==void 0&&Util.n(e+" property is not an Array; cannot removeLabelKeyforLinkData: "+t)}get linkDataArray(){return this.is}set linkDataArray(t){const i=this.is;if(i!==t){Util.Gg(t,GraphLinksModel,"linkDataArray"),this.mi.clear();const e=t.length;for(let n=0;nnew GraphLinksModel,Model.initDiagramModel=Model.initDiagramModel=()=>new GraphLinksModel;class TreeModel extends Model{En;bg;$a;constructor(t,i){if(super(),this.En="parent",this.bg=!1,this.$a="parentLinkCategory",t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){super.cloneProtected(t),t.En=this.En,t.bg=this.bg,t.$a=this.$a}toString(t){if(t===void 0&&(t=0),t>=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" TreeModel";if(t>0){i+=` - node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n(w[w.ConstantSpacing=0]="ConstantSpacing",w[w.ConstantDistance=1]="ConstantDistance",w[w.ConstantAngle=2]="ConstantAngle",w[w.Packed=3]="Packed",w))(CircularArrangement||{}),CircularDirection=(w=>(w[w.Clockwise=10]="Clockwise",w[w.Counterclockwise=11]="Counterclockwise",w[w.BidirectionalLeft=12]="BidirectionalLeft",w[w.BidirectionalRight=13]="BidirectionalRight",w))(CircularDirection||{}),CircularSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w[w.Optimized=24]="Optimized",w))(CircularSorting||{}),CircularNodeDiameterFormula=(w=>(w[w.Pythagorean=30]="Pythagorean",w[w.Circular=31]="Circular",w))(CircularNodeDiameterFormula||{});class CircularLayout extends Layout{ce;Yc;qb;kg;jb;Fh;zN;XN;YN;Ns;Xy;Yy;Qa;Ky;ZT;Sg;Mg;Pg;Kc;qi;C;ke;Se;Rn;Ng;constructor(t){super(),this.ce=0,this.Yc=0,this.qb=0,this.kg=360,this.jb=0,this.Fh=0,this.zN=new Point,this.XN=30,this.YN=0,this.Ns=0,this.Xy=0,this.Yy=new VertexArrangement,this.Qa=0,this.Ky=0,this.ZT=600,this.Sg=NaN,this.Mg=1,this.Pg=0,this.Kc=360,this.qi=0,this.C=10,this.ke=24,this.Se=LayoutVertex.standardComparer,this.Rn=6,this.Ng=30,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Sg=this.Sg,t.Mg=this.Mg,t.Pg=this.Pg,t.Kc=this.Kc,t.qi=this.qi,t.C=this.C,t.ke=this.ke,t.Se=this.Se,t.Rn=this.Rn,t.Ng=this.Ng}fi(t){t in CircularSorting?this.sorting=t:t in CircularDirection?this.direction=t:t in CircularArrangement?this.arrangement=t:t in CircularNodeDiameterFormula?this.nodeDiameterFormula=t:super.fi(t)}createNetwork(){return new CircularNetwork(this)}UO(t,i,e){t=this.GO(t);let s=this.jb,n=this.XN,o=this.ce,r=this.Yc,l=this.qb,h=this.kg,a=this.Fh,f=this.YN,c=this.Ns,u=this.Xy;if(s=this.arrangement,n=this.nodeDiameterFormula,o=this.radius,(!isFinite(o)||o<=0)&&(o=NaN),r=this.aspectRatio,(!isFinite(r)||r<=0)&&(r=1),l=this.startAngle,isFinite(l)||(l=0),h=this.sweepAngle,(!isFinite(h)||h>360||h<1)&&(h=360),a=this.spacing,isFinite(a)||(a=NaN),s===3&&n===31?s=0:s===3&&n!==31&&(n=31,s=this.arrangement),(this.direction===12||this.direction===13)&&this.sorting!==24){for(let g=0;!(g>=t.length||(i.add(t.elt(g)),g+1>=t.length));g+=2)e.add(t.elt(g+1));this.direction===12?(this.arrangement===3&&i.reverse(),t=new List,t.addAll(i),t.addAll(e)):(this.arrangement===3&&e.reverse(),t=new List,t.addAll(e),t.addAll(i))}const d=t.length;f=0;let m=0;for(let g=0;g1?(o=y,c=o*r):(c=y,o=c)}else o=this.Wb(u*(h>=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180)}else o=this.Wb(f+(h>=360?d:d-1)*(s!==3?a:a*1.6),r,l*Math.PI/180,h*Math.PI/180);c=o*r}else{c=o*r;const g=this.KN(o,c,l*Math.PI/180,h*Math.PI/180);if(isNaN(a))s===0&&(a=(g-f)/(h>=360?d:d-1));else if(s===0){const p=(g-f)/(h>=360?d:d-1);p=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180),c=o*r):a=p}else{let p=-1/0;for(let k=0;k=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180);x>o?(o=x,c=o*r,u=y):u=g/(h>=360?d:d-1)}}return this.jb=s,this.XN=n,this.ce=o,this.Yc=r,this.qb=l,this.kg=h,this.Fh=a,this.YN=f,this.Ns=c,this.Xy=u,t}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.network.vertexes;if(i.count<=1){if(i.count===1){const u=i.first();u.centerX=0,u.centerY=0}this.updateParts(),this.network=null,this.isValidLayout=!0;return}let e=new List;e.addAll(i.iterator);const s=new List,n=new List;e=this.UO(e,s,n);const o=this.jb,r=this.ce,l=this.qb,h=this.kg,a=this.Fh,f=this.Ns,c=this.Xy;if((this.direction===12||this.direction===13)&&o===3)this.$T(e,h,l-h/2,10);else if(this.direction===12||this.direction===13){let u=0;switch(o){case 1:u=this.vb(r,f,l,c)*180/Math.PI;break;case 0:{let d=0,m=0;const g=s.first();g!==null&&(d=g.Rh(Math.PI/2));const p=n.first();p!==null&&(m=p.Rh(Math.PI/2)),u=this.vb(r,f,l,a+(d+m)/2)*180/Math.PI;break}case 2:u=h/e.length;break}if(this.direction===12){switch(o){case 1:this.Uy(s,h/2,l,11);break;case 0:this.Gy(s,h/2,l,11);break;case 2:this.Hy(s,h/2,l,11);break}switch(o){case 1:this.Uy(n,h/2,l+u,10);break;case 0:this.Gy(n,h/2,l+u,10);break;case 2:this.Hy(n,h/2,l+u,10);break}}else{switch(o){case 1:this.Uy(n,h/2,l,11);break;case 0:this.Gy(n,h/2,l,11);break;case 2:this.Hy(n,h/2,l,11);break}switch(o){case 1:this.Uy(s,h/2,l+u,10);break;case 0:this.Gy(s,h/2,l+u,10);break;case 2:this.Hy(s,h/2,l+u,10);break}}}else switch(o){case 1:this.Uy(e,h,l,this.direction);break;case 0:this.Gy(e,h,l,this.direction);break;case 2:this.Hy(e,h,l,this.direction);break;case 3:this.$T(e,h,l,this.direction);break}this.updateParts(),this.network=null,this.isValidLayout=!0}Hy(t,i,e,s){const n=this.kg,o=this.ce,r=this.Ns,l=e*Math.PI/180,h=i*Math.PI/180,a=t.length;for(let f=0;f=360?a:a-1):-(f*h)/a),u=t.elt(f),d=o*Math.tan(c)/r,m=Math.sqrt((o*o+r*r*d*d)/(1+d*d));u.centerX=m*Math.cos(c),u.centerY=m*Math.sin(c),u.actualAngle=c*180/Math.PI}}Gy(t,i,e,s){const n=this.ce,o=this.Ns,r=this.Fh;let l=e*Math.PI/180;const h=t.length;for(let a=0;a180&&(n-=360),n*=Math.PI/180,this.Ky=n,this.QT(t,i,e,s)}else this._T(t,i,e,s);this.Yy.commit(t)}_T(t,i,e,s){const n=this.ce,o=this.Ns,r=this.Fh,l=this.Yc;let h=n*Math.cos(e*Math.PI/180),a=o*Math.sin(e*Math.PI/180);const f=t.toArray();if(f.length===3){f[0].centerX=n,f[0].centerY=0,f[1].centerX=f[0].centerX-f[0].width/2-f[1].width/2-r,f[1].y=f[0].y,f[2].centerX=(f[0].centerX+f[1].centerX)/2,f[2].y=f[0].y-f[2].height-r;return}else if(f.length===4){f[0].centerX=n,f[0].centerY=0,f[2].centerX=-f[0].centerX,f[2].centerY=f[0].centerY,f[1].centerX=0,f[1].y=Math.min(f[0].y,f[2].y)-f[1].height-r,f[3].centerX=0,f[3].y=Math.max(f[0].y+f[0].height+r,f[2].y+f[2].height+r);return}const c=Point.a();for(let b=0;b=f.length-1));b++)this.tD(h,a,f,b,s,c)||this.iD(h,a,f,b,s,c),h=c.x,a=c.y;if(Point.o(c),this.Qa++,this.Qa>23)return;const u=f[0].centerX,d=f[0].centerY,m=f[f.length-1].centerX,g=f[f.length-1].centerY;let p=Math.abs(u-m)-((f[0].width+f[f.length-1].width)/2+r);const y=Math.abs(d-g)-((f[0].height+f[f.length-1].height)/2+r);let x=0;if(Math.abs(y)<1){const b=Math.abs(u-m),S=(f[0].width+f[f.length-1].width)/2;b0?x=y:Math.abs(p)<1?x=0:x=p;let k=!1;Math.abs(m)>Math.abs(g)?k=m>0!=d>g:k=g>0!=u1&&(this.Qa<8?this.ce-=x/(2*Math.PI):f.length<5&&x>10?this.ce/=2:this.ce-=x>0?1.7:-2.3,this.Ns=this.ce*l,this._T(t,i,e,s))}QT(t,i,e,s){const n=this.ce,o=this.Ns,r=this.Yc;let l=n*Math.cos(e*Math.PI/180),h=o*Math.sin(e*Math.PI/180);const a=Point.a(),f=t.toArray();for(let m=0;m=f.length-1));m++)this.tD(l,h,f,m,s,a)||this.iD(l,h,f,m,s,a),l=a.x,h=a.y;if(Point.o(a),this.Qa++,this.Qa>23)return;const c=Math.atan2(h,l);let u=s===10?this.Ky-c:c-this.Ky;u=Math.abs(u)1&&(this.Qa<8?this.ce-=d/(2*Math.PI):this.ce-=d>0?1.7:-2.3,this.Ns=this.ce*r,this.QT(t,i,e,s))}tD(t,i,e,s,n,o){const r=this.Fh,l=this.ce,h=this.Ns;let a=0,f=0;const c=(e[s].width+e[s+1].width)/2+r;let u=!1;if(i>=0!=(n===10)){if(a=t+c,a>l){if(a=t-c,a<-l)return o.x=a,o.y=f,!1;u=!0}}else if(a=t-c,a<-l){if(a=t+c,a>l)return o.x=a,o.y=f,!1;u=!0}return f=Math.sqrt(1-Math.min(1,a*a/(l*l)))*h,i<0!==u&&(f=-f),Math.abs(i-f)>(e[s].height+e[s+1].height)/2?(o.x=a,o.y=f,!1):(o.x=a,o.y=f,!0)}iD(t,i,e,s,n,o){const r=this.Fh,l=this.ce,h=this.Ns;let a=0,f=0;const c=(e[s].height+e[s+1].height)/2+r;let u=!1;if(t>=0!=(n===10)){if(f=i-c,f<-h){if(f=i+c,f>h)return o.x=a,o.y=f,!1;u=!0}}else if(f=i+c,f>h){if(f=i-c,f<-h)return o.x=a,o.y=f,!1;u=!0}return a=Math.sqrt(1-Math.min(1,f*f/(h*h)))*l,t<0!==u&&(a=-a),Math.abs(t-a)>(e[s].width+e[s+1].width)/2?(o.x=a,o.y=f,!1):(o.x=a,o.y=f,!0)}commitLayout(){this.commitNodes(),this.isRouting&&this.commitLinks()}commitNodes(){const t=this.group!==null&&this.group.hasPlaceholder(),i=t?this.group.location.copy():null;let e=this.actualCenter;t?e=new Point(0,0):(e.x=this.arrangementOrigin.x+this.ce,e.y=this.arrangementOrigin.y+this.Ns);const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;n.x+=e.x,n.y+=e.y,n.commit()}if(t){this.group.ensureBounds();const n=this.group.position.copy(),o=this.group.location.copy(),r=i.subtract(o.subtract(n));this.group.move(r),this.zN=r.subtract(n)}}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}KN(t,i,e,s){const n=this.ZT;if(Math.abs(this.Yc-1)<.001)return e!==void 0&&s!==void 0?s*t:2*Math.PI*t;const o=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let r=0,l=0;e!==void 0&&s!==void 0?l=s/(n+1):l=Math.PI/(2*(n+1));let h=0;for(let a=0;a<=n;a++){e!==void 0&&s!==void 0?h=e+a*s/n:h=a*Math.PI/(2*n);const f=Math.sin(h);r+=Math.sqrt(1-o*o*f*f)*l}return e!==void 0&&s!==void 0?(t>i?t:i)*r:4*(t>i?t:i)*r}Wb(t,i,e,s){let n=0;return e!==void 0&&s!==void 0?n=this.KN(1,i,e,s):n=this.KN(1,i),t/n}vb(t,i,e,s){if(Math.abs(this.Yc-1)<.001)return s/t;const n=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let o=0;const r=2*Math.PI/(this.network.vertexes.count*700);t>i&&(e+=Math.PI/2);for(let l=0;;l++){const h=e+l*r,a=Math.sin(h);if(o+=(t>i?t:i)*Math.sqrt(1-n*n*a*a)*r,o>=s)return l*r}}GO(t){switch(this.sorting){case 20:break;case 21:t.reverse();break;case 22:t.sort(this.comparer);break;case 23:t.sort(this.comparer),t.reverse();break;case 24:return this.jO(this.WO(t));default:Util.n("Invalid sorting type.")}return t}WO(t){const i=[];for(let s=0;sn&&(n=u,o=f)}else for(let f=0;fn&&(n=c,o=f)}e.add(t.elt(o)),i[o]=-1;const r=t.elt(o);let l=0;const h=r.sourceEdges;for(;h.next();){const c=h.value.fromVertex;l=t.indexOf(c),!(l<0)&&i[l]>=0&&i[l]++}const a=r.destinationEdges;for(;a.next();){const c=a.value.toVertex;l=t.indexOf(c),!(l<0)&&i[l]>=0&&i[l]++}}return e}jO(t){const i=[];for(let c=0;c=0){const C=Math.abs(x-(A>=x?A+1:A));b+=C=x&&M++,A>=x&&A++,M>A){const C=A;A=M,M=C}A-M<(s.length+2)/2==(M=0&&(n.push(c),o.push(x))}h++}let a=!1;const f=s.length;for(;;){a=!0;for(let c=0;c=0){let g=0;for(let p=0;pm?x-m:m-x,b=f-k;g+=xb?1:-1}s.splice(g<0?m:m+1,0,u),r.splice(c,1),c--}else a=!1}if(a)break;s.push(r[0]),r.splice(0,1)}for(let c=0;c0||isNaN(t))&&(this.Sg=t,this.invalidateLayout()))}get aspectRatio(){return this.Mg}set aspectRatio(t){this.Mg!==t&&(Util.t(t,"number",CircularLayout,"aspectRatio"),t>0&&(this.Mg=t,this.invalidateLayout()))}get startAngle(){return this.Pg}set startAngle(t){this.Pg!==t&&(Util.t(t,"number",CircularLayout,"startAngle"),this.Pg=t,this.invalidateLayout())}get sweepAngle(){return this.Kc}set sweepAngle(t){this.Kc!==t&&(Util.t(t,"number",CircularLayout,"sweepAngle"),t>0&&t<=360?this.Kc=t:this.Kc=360,this.invalidateLayout())}get arrangement(){return this.qi}set arrangement(t){this.qi!==t&&(Util.tt(t,CircularArrangement,"CircularArrangement"),(t===3||t===0||t===1||t===2)&&(this.qi=t,this.invalidateLayout()))}get direction(){return this.C}set direction(t){this.C!==t&&(Util.tt(t,CircularDirection,"CircularDirection"),(t===10||t===11||t===12||t===13)&&(this.C=t,this.invalidateLayout()))}get sorting(){return this.ke}set sorting(t){this.ke!==t&&(Util.tt(t,CircularSorting,"CircularSorting"),this.ke=t,this.invalidateLayout())}get comparer(){return this.Se}set comparer(t){this.Se!==t&&(Util.t(t,"function",CircularLayout,"comparer"),this.Se=t,this.invalidateLayout())}get spacing(){return this.Rn}set spacing(t){this.Rn!==t&&(Util.t(t,"number",CircularLayout,"spacing"),this.Rn=t,this.invalidateLayout())}get nodeDiameterFormula(){return this.Ng}set nodeDiameterFormula(t){this.Ng!==t&&(Util.tt(t,CircularNodeDiameterFormula,"CircularNodeDiameterFormula"),(t===30||t===31)&&(this.Ng=t,this.invalidateLayout()))}get actualXRadius(){return this.ce}get actualYRadius(){return this.Ns}get actualSpacing(){return this.Fh}get actualCenter(){return this.zN}static ConstantSpacing=0;static ConstantDistance=1;static ConstantAngle=2;static Packed=3;static Clockwise=10;static Counterclockwise=11;static BidirectionalLeft=12;static BidirectionalRight=13;static Forwards=20;static Reverse=21;static Ascending=22;static Descending=23;static Optimized=24;static Pythagorean=30;static Circular=31}class VertexArrangement{Uc;_a;Gc;constructor(){this.Uc=-1/0,this._a=null,this.Gc=null}HO(t,i){if(t>0&&this.Uc<0||Math.abs(t)0)){this.Uc=t,this._a=[],this.Gc=[];for(let e=0;e0){for(this.network.deleteSelfEdges(),i=this.network.vertexes.iterator;i.next();){const o=i.value;o.charge=this.electricalCharge(o),o.mass=this.gravitationalMass(o)}const s=this.network.edges.iterator;for(;s.next();){const o=s.value;o.stiffness=this.springStiffness(o),o.length=this.springLength(o)}if(this.UN(),this.Ih=0,this.needsPrelayout()){const o=this.network,r=o.splitIntoSubNetworks(!1);let l=r.iterator;for(;l.next();){const h=l.value;this.doConnectedSubnetLayout(h)}for(l=r.iterator,this.JO(l,o),l=r.iterator;l.next();){const h=l.value,a=h.vertexes.iterator;for(;a.next();){const c=a.value;o.addVertex(c)}const f=h.edges.iterator;for(;f.next();){const c=f.value;o.addEdge(c)}}}else this.eD(this.network,this.maxIterations);this.updateParts()}this.maxIterations=e,this.isValidLayout=!0}needsPrelayout(){if(this.network.vertexes.count<3)return!1;let t=0,i=0;const e=this.network.vertexes.first().bounds,s=this.network.vertexes.iterator;for(;s.next();){const n=s.value,o=n.bounds;if(isNaN(n.x)||isNaN(n.y)||o.intersectsRect(e)&&(t++,t>2))return!0;if(i>10)return!1;i++}return!1}doConnectedSubnetLayout(t){let i=t.vertexes.iterator;for(;i.next();){const l=i.value;l.hierarchicalVertexes.add(l)}let e=t,s=this.Jc;if(isNaN(s)&&(s=t.edges.count/t.vertexes.count),sMath.max(100,Math.sqrt(s*t.vertexes.count));)e=this.coarsenNetwork(e);let n=0;i=e.vertexes.iterator;let o=this.randomNumberGenerator;for(o===null&&(this.randomNumberGenerator=o=new RandomNumberGenerator(0));i.next();){i.value.idInCluster=n++;const l=10*(o.random()-.5),h=10*(o.random()-.5);this.isFixed(i.value)||(i.value.x=l,i.value.y=h);const a=i.value.hierarchicalVertexes.iterator;for(;a.next();)this.isFixed(a.value)||(a.value.x=l,a.value.y=h)}const r=this.computePairwiseDistances(e);this.ZO(e,r,this.maxPrelayoutIterations,t.vertexes.count),this.eD(t,this.maxIterations)}computePairwiseDistances(t){const i=t.vertexes.count,e=new Array(i);for(let r=0;r0;){const l=o.shift(),h=l.vertexes.iterator;for(;h.next();){const a=h.value;n.has(a.idInCluster)||(n.set(a.idInCluster,n.get(l.idInCluster)+1),o.push(a))}}for(let l=0;l=0;m--)if(t[m].y>f.y&&t[m].x-f.xf.x&&t[m].y-f.ya+c){const u=s+o-h,d=n-a-c;return Geo.Aw(u*u+d*d)}else if(n+rh+f)if(n>a+c){const u=s-h-f,d=n-a-c;return Geo.Aw(u*u+d*d)}else if(n+ra+c?n-(a+c):n+rr-o;l?i.sort((m,g)=>m===null||g===null||m===g?0:m.centerX-g.centerX):i.sort((m,g)=>m===null||g===null||m===g?0:m.centerY-g.centerY);const h=this.Hc;let a=0,f=0,c=0;for(let m=0;mh||C-x>h){if(l)break;continue}if(k-P>h||P-k>h){if(!l)break;continue}const N=this.GN(g,S),T=2*g.charge,L=2*S.charge;if(N>1)a=T*L/(N*N),f=a*(x-C)/N,c=a*(k-P)/N;else{let D=this.randomNumberGenerator;D===null&&(this.randomNumberGenerator=D=new RandomNumberGenerator(0));const F=D.random(),R=D.random();if(x>C)f=Math.abs(S.bounds.right-g.bounds.x),f=T*L*(1+f)*F;else if(xP)c=Math.abs(S.bounds.bottom-g.bounds.y),c=T*L*(1+c)*R;else if(x1&&(a=.1*m.stiffness*(P-m.length),f=a*.5*(g.width+p.height)*(k-A)/P,c=a*.5*(g.width+p.height)*(b-C)/P),g.forceX-=f,g.forceY-=c,p.forceX+=f,p.forceY+=c}let d=0;for(let m=0;mthis.epsilonDistance*this.epsilonDistance}ZO(t,i,e,s){Debug&&Util.r(e,ForceDirectedLayout,"performIterations:num");const n=this.Ih+e,o=Math.sqrt(s);this.qy=this.tf*t.vertexes.count;const r=t.vertexes.toArray();let l=0,h=0,a=0;for(;this.Ih0){r[f].forceX=this.qy*r[f].forceX/c,r[f].forceY=this.qy*r[f].forceY/c,this.isFixed(r[f])||(r[f].x+=r[f].forceX,r[f].y+=r[f].forceY);const u=r[f].hierarchicalVertexes.iterator;for(;u.next();){const d=u.value;this.isFixed(d)||(d.centerX+=r[f].forceX,d.centerY+=r[f].forceY)}}l+=c*c}if(l>=h){if(a++,a>=5)break}else a=0;this.qy*=.95}}moveVertex(t){let i=t.forceX,e=t.forceY;const s=this.moveLimit;return i<-s?i=-s:i>s&&(i=s),e<-s?e=-s:e>s&&(e=s),t.centerX+=i,t.centerY+=e,i*i+e*e}shouldInteract(t,i){return!0}moveFixedVertex(t){}commitLayout(){this.jy(),this.commitNodes(),this.isRouting&&this.commitLinks()}jy(){if(!this.setsPortSpots)return;const t=this.network.edges.iterator;for(;t.next();){const e=t.value.link;e!==null&&(e.fromSpot=Spot.Default,e.toSpot=Spot.Default)}}commitNodes(){let t=0,i=0;if(this.arrangesToOrigin){const n=Rect.a();this.Rw(this.network,n);const o=this.arrangementOrigin;t=o.x-n.x,i=o.y-n.y,Rect.o(n)}const e=Rect.a(),s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;(t!==0||i!==0)&&(e.c(n.bounds),e.x+=t,e.y+=i,n.bounds=e),n.commit()}Rect.o(e)}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}springStiffness(t){const i=t.stiffness;return isNaN(i)?this.qc:i}springLength(t){const i=t.length;return isNaN(i)?this.jc:i}electricalCharge(t){const i=t.charge;return isNaN(i)?this.Wc:i}electricalFieldX(t,i){return 0}electricalFieldY(t,i){return 0}gravitationalMass(t){const i=t.mass;return isNaN(i)?this.vc:i}gravitationalFieldX(t,i){return 0}gravitationalFieldY(t,i){return 0}isFixed(t){return t.isFixed}get currentIteration(){return this.Ih}get arrangementSpacing(){return this.Cs}set arrangementSpacing(t){Util.s(t,Size,ForceDirectedLayout,"arrangementSpacing"),this.Cs.equals(t)||(this.Cs.c(t),this.invalidateLayout())}get arrangesToOrigin(){return this.Cg}set arrangesToOrigin(t){this.Cg!==t&&(Util.t(t,"boolean",ForceDirectedLayout,"arrangesToOrigin"),this.Cg=t,this.invalidateLayout())}get setsPortSpots(){return this.Vn}set setsPortSpots(t){this.Vn!==t&&(Util.t(t,"boolean",ForceDirectedLayout,"setsPortSpots"),this.Vn=t,this.invalidateLayout())}get comments(){return this.Be}set comments(t){this.Be!==t&&(Util.t(t,"boolean",ForceDirectedLayout,"comments"),this.Be=t,this.invalidateLayout())}get maxPrelayoutIterations(){return this.Ag}set maxPrelayoutIterations(t){this.Ag!==t&&(Util.t(t,"number",ForceDirectedLayout,"maxPrelayoutIterations"),t>=0&&(this.Ag=t,this.invalidateLayout()))}get maxIterations(){return this.Lg}set maxIterations(t){this.Lg!==t&&(Util.t(t,"number",ForceDirectedLayout,"maxIterations"),t>=0&&(this.Lg=t,this.invalidateLayout()))}get epsilonDistance(){return this.Tg}set epsilonDistance(t){this.Tg!==t&&(Util.t(t,"number",ForceDirectedLayout,"epsilonDistance"),t>0&&(this.Tg=t,this.invalidateLayout()))}get infinityDistance(){return this.Hc}set infinityDistance(t){this.Hc!==t&&(Util.t(t,"number",ForceDirectedLayout,"infinityDistance"),t>1&&(this.Hc=t,this.invalidateLayout()))}get moveLimit(){return this.Dg}set moveLimit(t){this.Dg!==t&&(Util.t(t,"number",ForceDirectedLayout,"moveLimit"),this.Dg=t,this.invalidateLayout())}get randomNumberGenerator(){return this.Fg}set randomNumberGenerator(t){this.Fg!==t&&(t!==null&&typeof t.random!="function"&&Util.n('ForceDirectedLayout.randomNumberGenerator must have a "random()" function on it: '+t),this.Fg=t)}get defaultSpringStiffness(){return this.qc}set defaultSpringStiffness(t){this.qc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultSpringStiffness"),this.qc=t,this.invalidateLayout())}get defaultSpringLength(){return this.jc}set defaultSpringLength(t){this.jc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultSpringLength"),this.jc=t,this.invalidateLayout())}get defaultElectricalCharge(){return this.Wc}set defaultElectricalCharge(t){this.Wc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultElectricalCharge"),this.Wc=t,this.invalidateLayout())}get defaultGravitationalMass(){return this.vc}set defaultGravitationalMass(t){this.vc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultGravitationalMass"),this.vc=t,this.invalidateLayout())}get defaultCommentSpringLength(){return this.Rg}set defaultCommentSpringLength(t){this.Rg!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultCommentSpringLength"),this.Rg=t,this.invalidateLayout())}get defaultCommentElectricalCharge(){return this.Ig}set defaultCommentElectricalCharge(t){this.Ig!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultCommentElectricalCharge"),this.Ig=t,this.invalidateLayout())}get prelayoutQuality(){return this.Jc}set prelayoutQuality(t){this.Jc!==t&&(Util.t(t,"number",ForceDirectedLayout,"prelayoutQuality"),this.Jc=t,this.invalidateLayout())}get prelayoutSpread(){return this.tf}set prelayoutSpread(t){this.tf!==t&&(Util.t(t,"number",ForceDirectedLayout,"prelayoutSpread"),this.tf=t,this.invalidateLayout())}}class ForceDirectedNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new ForceDirectedVertex(this)}createEdge(){return new ForceDirectedEdge(this)}}class ForceDirectedVertex extends LayoutVertex{Zb;$b;Qb;_b;tk;hierarchicalVertexes;idInCluster;constructor(t){super(t),this.Zb=!1,this.$b=NaN,this.Qb=NaN,this._b=0,this.tk=0,this.hierarchicalVertexes=new List,this.idInCluster=-1}get isFixed(){return this.Zb}set isFixed(t){this.Zb!==t&&(Util.t(t,"boolean",ForceDirectedVertex,"isFixed"),this.Zb=t)}get charge(){return this.$b}set charge(t){this.$b!==t&&(Util.t(t,"number",ForceDirectedVertex,"charge"),this.$b=t)}get mass(){return this.Qb}set mass(t){this.Qb!==t&&(Util.t(t,"number",ForceDirectedVertex,"mass"),this.Qb=t)}get forceX(){return this._b}set forceX(t){this._b!==t&&(Util.t(t,"number",ForceDirectedVertex,"forceX"),this._b=t)}get forceY(){return this.tk}set forceY(t){this.tk!==t&&(Util.t(t,"number",ForceDirectedVertex,"forceY"),this.tk=t)}}class ForceDirectedEdge extends LayoutEdge{ik;ek;constructor(t){super(t),this.ik=NaN,this.ek=NaN}get stiffness(){return this.ik}set stiffness(t){this.ik!==t&&(Util.t(t,"number",ForceDirectedEdge,"stiffness"),this.ik=t)}get length(){return this.ek}set length(t){this.ek!==t&&(Util.t(t,"number",ForceDirectedEdge,"length"),this.ek=t)}}class RandomNumberGenerator{I;R;Q;M;A;seed;constructor(t){t===void 0&&(t=42),this.seed=t,this.A=48271,this.M=2147483647,this.Q=this.M/this.A,this.R=this.M%this.A,this.I=1/this.M,this.random()}random(){const t=this.seed/this.Q,i=this.seed%this.Q,e=this.A*i-this.R*t;return e>0?this.seed=e:this.seed=e+this.M,this.seed*this.I}}var LayeredDigraphCycleRemove=(w=>(w[w.DepthFirst=0]="DepthFirst",w[w.Greedy=1]="Greedy",w[w.FromLayers=2]="FromLayers",w))(LayeredDigraphCycleRemove||{}),LayeredDigraphLayering=(w=>(w[w.OptimalLinkLength=10]="OptimalLinkLength",w[w.LongestPathSink=11]="LongestPathSink",w[w.LongestPathSource=12]="LongestPathSource",w))(LayeredDigraphLayering||{}),LayeredDigraphInit=(w=>(w[w.DepthFirstOut=20]="DepthFirstOut",w[w.DepthFirstIn=21]="DepthFirstIn",w[w.Naive=22]="Naive",w))(LayeredDigraphInit||{}),LayeredDigraphAggressive=(w=>(w[w.None=30]="None",w[w.Less=31]="Less",w[w.More=32]="More",w))(LayeredDigraphAggressive||{}),LayeredDigraphPack=(w=>(w[w.None=0]="None",w[w.Expand=1]="Expand",w[w.Straighten=2]="Straighten",w[w.Median=4]="Median",w[w.MaybeExpand=8]="MaybeExpand",w[w.All=15]="All",w))(LayeredDigraphPack||{}),LayeredDigraphAlign=(w=>(w[w.None=0]="None",w[w.UpperLeft=1]="UpperLeft",w[w.UpperRight=2]="UpperRight",w[w.LowerLeft=4]="LowerLeft",w[w.LowerRight=8]="LowerRight",w[w.All=15]="All",w))(LayeredDigraphAlign||{});class LayeredDigraphLayout extends Layout{As;_i;C;Zc;$c;Qc;ef;_c;ar;tu;Vn;Lt;Wy;Wt;Og;Ls;pi;nn;Ts;Ds;Gt;Eg;sf;Vg;on;iu;fr;Bn;zn;HN;constructor(t){super(),this.As=25,this._i=25,this.C=0,this.Zc=0,this.$c=10,this.Qc=20,this.ef=4,this._c=31,this.ar=15,this.tu=10,this.Vn=!0,this.Lt=-1,this.Wy=-1,this.Wt=-1,this.Og=0,this.Ls=0,this.pi=null,this.nn=null,this.Ts=null,this.Ds=null,this.Gt=null,this.Eg=0,this.sf=null,this.Vg=null,this.on=0,this.iu=null,this.fr=new Point,this.Bn=[],this.Bn.length=100,this.zn=15,this.HN=0,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.As=this.As,t._i=this._i,t.C=this.C,t.Zc=this.Zc,t.$c=this.$c,t.Qc=this.Qc,t.ef=this.ef,t._c=this._c,t.ar=this.ar,t.tu=this.tu,t.Vn=this.Vn,t.zn=this.zn}fi(t){t in LayeredDigraphAggressive?this.aggressiveOption=t:t in LayeredDigraphCycleRemove?this.cycleRemoveOption=t:t in LayeredDigraphInit?this.initializeOption=t:t in LayeredDigraphLayering?this.layeringOption=t:super.fi(t)}createNetwork(){return new LayeredDigraphNetwork(this)}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin),this.QO(),this.network.vertexes.count>0&&(this.network.deleteSelfEdges(),this.cycleRemoveOption!==2&&this.removeCycles(),this._O(),this.cycleRemoveOption===2&&this.removeCycles(),this.t3(),this.i3(),this.e3(),this.reduceCrossings(),this.straightenAndPack(),this.updateParts()),this.network=null,this.isValidLayout=!0}linkMinLength(t){return 1}linkLengthWeight(t){return 1}linkStraightenWeight(t){const i=t.fromVertex.node||t.fromVertex.data,e=t.toVertex.node||t.toVertex.data;return i===null&&e===null?8:i===null||e===null?4:1}nodeMinLayerSpace(t,i){return t.node===null&&t.data===null?0:this.C===90||this.C===270?i?t.focus.y+10:t.bounds.height-t.focus.y+10:i?t.focus.x+10:t.bounds.width-t.focus.x+10}nodeMinColumnSpace(t,i){if(t.node===null&&t.data===null)return 0;const e=i?t.sk:t.nk;if(e!==null)return e;const s=this.C;return s===90||s===270?i?t.sk=t.focus.x/this._i+1|0:t.nk=(t.bounds.width-t.focus.x)/this._i+1|0:i?t.sk=t.focus.y/this._i+1|0:t.nk=(t.bounds.height-t.focus.y)/this._i+1|0}te(){this.sf===null&&(this.sf=[]);let t=0;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;this.sf[t]=e.layer,t++,this.sf[t]=e.column,t++,this.sf[t]=e.index,t++}return this.sf}es(t){let i=0;const e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;s.layer=t[i],i++,s.column=t[i],i++,s.index=t[i],i++}}nD(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"crossingMatrix:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"crossingMatrix:direction"));const e=this.Oh(t),s=this.pi[t];(this.Vg===null||this.Vg.length=0){for(f=e[o].So,c=0;ck||d===k&&g>S)&&r++,bd||k===d&&S>g)&&r++)}if(i<=0){for(f=e[o].rr,c=0;ck||d===k&&m>b)&&r++,Sd||k===d&&b>m)&&r++)}for(n[o*s+o]=r,a=o+1;a=0){for(p=e[o].So,M=e[a].So,c=0;c=0&&(h=s[r].rr);let a,f=0,c=0;if(l!==null)for(let u=0;u=0&&(h=r.rr);let a=0,f=0;const c=r.near;c!==null&&c.layer===r.layer&&(a+=c.column-1,f++);let u;if(l!==null)for(let d=0;d=0&&(h=r.rr);let a=0;const f=[],c=r.near;c!==null&&c.layer===r.layer&&(f[a]=c.column-1,a++);let u;if(l!==null)for(let d=0;dm-g);const d=a>>1;a&1?n[o]=f[d]:n[o]=f[d-1]+f[d]>>1}}return this.Eh(t,e),n}Zy(t,i,e,s,n){if(t.component===e){t.component=i;let o=0,r=0;if(s){const l=t.destinationEdges;for(;l.next();){const h=l.value,a=h.toVertex;o=t.layer-a.layer,r=this.linkMinLength(h),o===r&&this.Zy(a,i,e,s,n)}}if(n){const l=t.sourceEdges;for(;l.next();){const h=l.value,a=h.fromVertex;o=a.layer-t.layer,r=this.linkMinLength(h),o===r&&this.Zy(a,i,e,s,n)}}}}qN(t,i,e,s,n){if(t.component===e){if(t.component=i,s){const o=t.destinationEdges;for(;o.next();){const l=o.value.toVertex;this.qN(l,i,e,s,n)}}if(n){const o=t.sourceEdges;for(;o.next();){const l=o.value.fromVertex;this.qN(l,i,e,s,n)}}}}removeCycles(){const t=this.network.edges.iterator;for(;t.next();){const i=t.value;i.rev=!1}switch(this.Zc){default:case 1:this.o3();break;case 0:this.r3();break;case 2:this.l3();break}}l3(){const t=this.network,i=t.vertexes.iterator;let e=1/0;for(;i.next();){const s=i.value;e=Math.min(e,s.layer)}if(e<1/0){if(e<0)for(i.reset();i.next();){const r=i.value;r.layer-=e}const s=[];for(i.reset();i.next();){const r=i.value,l=s[r.layer];l===void 0?s[r.layer]=[r]:l.push(r)}let n=0;for(let r=0;r0)for(let h=0;hh.index&&(t.reverseEdge(r),r.rev=!0)}}h3(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.ie)return e}return null}rD(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.ie){let s=!0;const n=e.destinationEdges;for(;n.next();)if(n.value.toVertex.ie){s=!1;break}if(s)return e}}return null}lD(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.ie){let s=!0;const n=e.sourceEdges;for(;n.next();)if(n.value.fromVertex.ie){s=!1;break}if(s)return e}}return null}a3(t){let i=null,e=0;const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;if(n.ie){let o=0;const r=n.destinationEdges;for(;r.next();)r.value.toVertex.ie&&o++;let l=0;const h=n.sourceEdges;for(;h.next();)h.value.fromVertex.ie&&l++;(i===null||ef&&this.Zy(h,e,-1,!0,!1)}for(this.Zy(t,s,-1,!0,!0);t.component!==e;){let r=0,l=1/0,h=0,a=null;const f=this.network.vertexes.iterator;for(;f.next();){const c=f.value;if(c.component===s){let u=0,d=!1;const m=c.So;o=m.length;for(let p=0;p0){for(i.reset();i.next();){const c=i.value;c.component===s&&(c.layer+=l)}t.component=e}else a.component=e}}d3(t){const i=this.network.vertexes.iterator;for(;i.next();){const n=i.value;n.component=-1}const e=0,s=1;for(this.Zy(t,s,-1,!0,!1);t.component!==e;){let n=0,o=1/0,r=0,l=null;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value;if(a.component===s){let f=0,c=!1;const u=a.So;let d=u.length;for(let g=0;gr)&&!c&&(l=a,r=f)}}if(n<0){for(i.reset();i.next();){const a=i.value;a.component===s&&(a.layer-=o)}t.component=e}else l.component=e}}t3(){const t=this.network,i=[],e=t.edges.iterator;for(;e.next();){const s=e.value;s.valid=!1,i.push(s)}for(let s=0;sb&&c>0){for(n.valid=!1,y=t.createVertex(),y.node=null,y.rk=2,y.layer=c-1,x&&kb&&c>0;)y=t.createVertex(),y.node=null,y.rk=3,y.layer=c-1,x&&kt[this.Ls]&&(this.Wy=t[e]-1,this.Ls=e),t[e]{o.index=this.pi[s],this.pi[s]++})}}y3(){let t=null;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;if(e.near&&(t===null&&(t=new Map),e.layer===e.near.layer)){const s=t.get(e.near)||[];s.push(e),t.set(e.near,s)}}for(let e=this.Lt;e>=0;e--)for(i.reset();i.next();){const s=i.value;s.layer===e&&s.index===-1&&this.gD(s,t)}}gD(t,i){if(t.near)return;const e=t.layer;if(t.index=this.pi[e],this.pi[e]++,i){const o=i.get(t);Array.isArray(o)&&o.forEach(r=>{r.index=this.pi[e],this.pi[e]++})}const s=t.rr;let n=!0;for(;n;){n=!1;for(let o=0;ol.portFromColOffset&&(n=!0,s[o]=l,s[o+1]=r)}}for(let o=0;o{a.index=this.pi[e],this.pi[e]++})}const s=t.So;let n=!0,o=0;for(;n;)for(n=!1,o=0;oa.portToColOffset&&(n=!0,s[o]=a,s[o+1]=h)}let r,l;for(o=0;o=0;s--)this.hk(s,-1),this.us(s,-1,!1,-1);n=this.countCrossings(),n=0;s--)this.hk(s,0),this.us(s,0,!1,0);n=this.countCrossings(),n=0;r--)for(l=0;l<=r;l++){for(o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,1,!1,1)||o;for(n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,-1,!1,-1)||o;for(n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,0,!1,0)||o;for(n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,0,!1,0)||o;n>=t?this.es(i):(t=n,i=this.te())}break;default:case 31:for(r=this.Lt,l=0,h=t+1;(a=this.countCrossings())=l;s--)o=this.us(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,1,!1,1)||o;for(n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,-1,!1,-1)||o;for(n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,0,!1,0)||o;for(n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,0,!1,0)||o;n>=t?this.es(i):(t=n,i=this.te())}break}this.es(i)}hk(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"medianBarycenterCrossingReduction:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"medianBarycenterCrossingReduction:direction"));let e=0,s=!1;const n=this.Oh(t),o=this.pi[t],r=this.oD(t,i),l=this.Jy(t,i);for(e=0;e0)for(h=[],l=0;ll+1&&(m+=4*(I-l),g+=4*(I-(l+1)))}}const V=n[l].destinationEdges.iterator;if(e&&s>=0)for(;V.next();){const W=V.value;O=W.toVertex,W.valid&&O.layer!==t&&(N=this.linkStraightenWeight(W),T=W.portFromColOffset,L=W.portToColOffset,F=O.column,C+=(Math.abs(p+T-(F+L))+1)*N,P+=(Math.abs(A+T-(F+L))+1)*N)}for(V.reset();V.next();){const W=V.value;if(O=W.toVertex,W.valid&&O.layer===t){for(B=0;Bl+1&&(m+=4*(I-(l+1)),g+=4*(I-l))}}const z=n[l+1].destinationEdges.iterator;if(e&&s>=0)for(;z.next();){const W=z.value;O=W.toVertex,W.valid&&O.layer!==t&&(N=this.linkStraightenWeight(W),T=W.portFromColOffset,L=W.portToColOffset,F=O.column,C+=(Math.abs(y+T-(F+L))+1)*N,P+=(Math.abs(M+T-(F+L))+1)*N)}for(z.reset();z.next();){const W=z.value;if(O=W.toVertex,W.valid&&O.layer===t){for(B=0;B1e3&&s&&(e=!1),e){const n=[];let o=0;for(o=0;o<=this.Lt;o++)n[o]=0;let r=0;const l=this.network.vertexes.iterator;for(;l.next();){const a=l.value;t=a.layer,r=a.column;const f=this.nodeMinColumnSpace(a,!1);n[t]=Math.max(n[t],r+f)}const h=8;for(l.reset();l.next();){const a=l.value;t=a.layer,r=a.column,a.column=((this.Wt-n[t])*h>>1)+r*h}this.Wt*=h}if(this.ar&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Bg(t,-1)||i;i=this.Bg(this.Ls,0)||i,n++}}if(this.ar&4){for(t=this.Ls+1;t<=this.Lt;t++)this.WN(t,1);for(t=this.Ls-1;t>=0;t--)this.WN(t,-1);this.WN(this.Ls,0)}if(e&&(this.pD(-1),this.pD(1)),this.ar&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Bg(t,0)||i;n++}}}Bg(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"bendStraighten:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"bendStraighten:direction"));let e=!1;for(;this.b3(t,i);)e=!0;return e}b3(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"shiftbendStraighten:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"shiftbendStraighten:direction"));let e=0;const s=this.Oh(t),n=this.pi[t],o=this.Jy(t,-1);if(i>0)for(e=0;ef+this.nodeMinColumnSpace(s[e-1],!1)?u=a-1:u=a;let d=0;e+1>=n||s[e+1].column-a-1>c+this.nodeMinColumnSpace(s[e+1],!0)?d=a+1:d=a;let m=0,g=0,p=0,y=0,x=0,k=0;if(i<=0){const P=s[e].sourceEdges.iterator;for(;P.next();){const N=P.value,T=N.fromVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const L=T.column;m+=(Math.abs(a+k-(L+x))+1)*y,g+=(Math.abs(u+k-(L+x))+1)*y,p+=(Math.abs(d+k-(L+x))+1)*y}}}if(i>=0){const P=s[e].destinationEdges.iterator;for(;P.next();){const N=P.value,T=N.toVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const L=T.column;m+=(Math.abs(a+x-(L+k))+1)*y,g+=(Math.abs(u+x-(L+k))+1)*y,p+=(Math.abs(d+x-(L+k))+1)*y}}}let b=0,S=0,M=0;const A=o[s[e].index],C=r[s[e].index];A!==-1&&(b+=Math.abs(A-a),S+=Math.abs(A-u),M+=Math.abs(A-d)),C!==-1&&(b+=Math.abs(C-a),S+=Math.abs(C-u),M+=Math.abs(C-d)),g=r[e]?u=p:g<=r[e]&&(u=g)),u!==a&&(l=!0,h=!0,s[e].column=u)}return this.Eh(t,s),this.vy(),l}k3(){for(let t=0;t<=this.Wt;t++)for(;this.S3(t,1););this.vy()}S3(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"packAux:column"),Util.r(i,LayeredDigraphLayout,"packAux:direction"));let e=!0;const s=this.network.vertexes.iterator;for(;s.next();){const o=s.value,r=this.nodeMinColumnSpace(o,!0),l=this.nodeMinColumnSpace(o,!1);if(o.column-r<=t&&o.column+l>=t){e=!1;break}}let n=!1;if(e){if(i>0)for(s.reset();s.next();){const o=s.value;o.column>t&&(o.column-=1,n=!0)}if(i<0)for(s.reset();s.next();){const o=s.value;o.column0&&(e=t+1),i<0&&(e=t-1);let s=0;const n=[],o=[];for(s=0;s<=this.Lt;s++)n[s]=!1,o[s]=!1;const r=this.network.vertexes.iterator;for(;r.next();){const a=r.value,f=a.column-this.nodeMinColumnSpace(a,!0),c=a.column+this.nodeMinColumnSpace(a,!1);f<=t&&c>=t&&(n[a.layer]=!0),f<=e&&c>=e&&(o[a.layer]=!0)}let l=!0,h=!1;for(s=0;s<=this.Lt;s++)l=l&&!(n[s]&&o[s]);if(l){if(i>0)for(r.reset();r.next();){const a=r.value;a.column>t&&(a.column-=1,h=!0)}if(i<0)for(r.reset();r.next();){const a=r.value;a.column0)for(i=0;i<=this.Wt;i++)for(e=this.te(),s=this.ok(!0),n=s+1;ss?this.es(e):o=0;i--)for(e=this.te(),s=this.ok(!0),n=s+1;ss?this.es(e):o0)for(e.reset();e.next();){const f=e.value;f.column-this.nodeMinColumnSpace(f,!0)<=t&&(f.component=this.on)}if(i<0)for(e.reset();e.next();){const f=e.value;f.column+this.nodeMinColumnSpace(f,!1)>=t&&(f.component=this.on)}for(this.on++,e.reset();e.next();){const f=e.value;f.component===-1&&(this.qN(f,this.on,-1,!0,!0),this.on++)}let s=0;const n=[];for(s=0;s0)for(let c=0;c0;c--)o[f*(this.Wt+1)+c]!==-1&&o[f*(this.Wt+1)+c-1]!==-1&&o[f*(this.Wt+1)+c]!==o[f*(this.Wt+1)+c-1]&&(n[o[f*(this.Wt+1)+c]*this.on+o[f*(this.Wt+1)+c-1]]=!0)}const r=[];for(s=0;s0)for(e.reset();e.next();){const f=e.value;r[f.component]&&(f.column-=1,a=!0)}if(i<0)for(e.reset();e.next();){const f=e.value;r[f.component]&&(f.column+=1,a=!0)}return a}x3(){const t=Util.ft(),i=this.iu.length;for(let u=0;u<=i;u++)t[u]=[];const e=this.network.vertexes.iterator;for(;e.next();){const u=e.value,d=i-u.layer,m=t[d];m[u.index]=u}const s=new GSet;this.N3(t,s);let n=null,o=null,r=null,l=null;const h=(this.zn&1)!==0,a=(this.zn&2)!==0,f=(this.zn&4)!==0,c=(this.zn&8)!==0;h&&(this.hl(t,s,!0),n=this.ak(t,!0,!1)),t.reverse(),f&&(this.hl(t,s,!1),r=this.ak(t,!1,!1));for(const u of t)u.reverse();c&&(this.hl(t,s,!1),l=this.ak(t,!1,!0)),t.reverse(),a&&(this.hl(t,s,!0),o=this.ak(t,!0,!0)),Util.nt(t),this.C3(n,o,r,l),this.network.vertexes.each(u=>{const d=u,m=Util.ft();h&&m.push(n.get(d)),a&&m.push(o.get(d)),f&&m.push(r.get(d)),c&&m.push(l.get(d)),m.sort((k,b)=>k-b);const g=m.length,p=Math.floor((g-1)/2),y=Math.ceil((g-1)/2),x=(m[p]+m[y])/2;Util.nt(m),d.ue=x})}N3(t,i){const e=t.length;for(let s=1;sc)&&i.add(m)}o++}n=c}}}}A3(t){if(t.node===null){const i=t.getProperSourceVertexes();if(i.length>0)return i[0].node===null}return!1}hl(t,i,e){this.L3(t);for(const s of t){let n=-1;for(const o of s){const r=e?o.getProperSourceVertexes():o.getProperDestinationVertexes(),l=r.length;if(l>0){r.sort((a,f)=>a.Vh-f.Vh);const h=(l-1)/2;for(let a=Math.floor(h),f=Math.ceil(h);a<=f;a++)if(o.Xn===o){const c=r[a];let u;e?u=c.getDestinationEdge(o):u=o.getDestinationEdge(c),!i.has(u)&&n0){const f=this.bD(a,t),c=s?f.width:f.height,u=a.ss.su+a.ue+a.Yn-(f.ue+f.Yn+c+this.columnSpacing);f.ss.su=Math.min(f.ss.su,u)}h=a.Vh+1}while(l0){const s=this.bD(e,i),n=s.nf;this.xD(n,i),t.ss===t&&(t.ss=n.ss);const o=this.C===90||this.C===270?s.width:s.height;if(t.ss===n.ss){const r=n.ue+s.Yn+o-e.Yn+this.columnSpacing;t.ue=Math.max(t.ue,r)}}e=e.Xn}while(e!==t);for(;e.Xn!==t;)e=e.Xn,e.ue=t.ue,e.ss=t.ss}bD(t,i){const e=t.wD,s=t.Vh;return s<1&&Util.n("Could not determine previous vertex in layer"),i[e][s-1]}C3(...t){let i=-1;const e=Util.ft(),s=Util.ft();let n=1/0;for(let o=0;o<4;o++){if(!t[o])continue;const r=this.D3(t[o],e,s,o);r{r.set(h.key,h.value+l)})}Util.nt(e),Util.nt(s)}D3(t,i,e,s){if(!t||t.count===0)return i[s]=0,e[s]=0,1/0;let n=1/0,o=-1/0;return t.each(r=>{const l=r.key,h=r.value,a=this.C===90||this.C===270?l.width:l.height;ho&&(o=h+a)}),i[s]=n,e[s]=o,o-n}commitLayout(){this.jy(),this.commitNodes(),this.vN(),this.isRouting&&this.commitLinks()}jy(){if(!this.setsPortSpots)return;const t=this.lk(!0),i=this.lk(!1),e=this.network.edges.iterator;for(;e.next();){const n=e.value.link;n!==null&&(n.fromSpot=t,n.toSpot=i)}}lk(t){return this.C===270?t?Spot.MiddleTop:Spot.MiddleBottom:this.C===90?t?Spot.MiddleBottom:Spot.MiddleTop:this.C===180?t?Spot.MiddleLeft:Spot.MiddleRight:t?Spot.MiddleRight:Spot.MiddleLeft}commitNodes(){this.nn=[],this.Ts=[],this.Ds=[],this.Gt=[];for(let d=0;d<=this.Lt;d++)this.nn[d]=0,this.Ts[d]=0,this.Ds[d]=0,this.Gt[d]=0;const t=this.network.vertexes.iterator;for(;t.next();){const d=t.value,m=d.layer;this.nn[m]=Math.max(this.nn[m],this.nodeMinLayerSpace(d,!0)),this.Ts[m]=Math.max(this.Ts[m],this.nodeMinLayerSpace(d,!1))}let i=0;const e=this.As;for(let d=0;d<=this.Lt;d++){let m=e;this.nn[d]+this.Ts[d]<=0&&(m=0),d>0&&(i+=m/2),this.C===90||this.C===0?(i+=this.Ts[d],this.Ds[d]=i,i+=this.nn[d]):(i+=this.nn[d],this.Ds[d]=i,i+=this.Ts[d]),d=0;n--)this.C===270?n===0?e.push(new Rect(0,0,s,Math.abs(this.Gt[0]))):e.push(new Rect(0,this.Gt[n-1],s,Math.abs(this.Gt[n-1]-this.Gt[n]))):this.C===90?n===0?e.push(new Rect(0,this.Gt[0],s,Math.abs(this.Gt[0]-t))):e.push(new Rect(0,this.Gt[n],s,Math.abs(this.Gt[n-1]-this.Gt[n]))):this.C===180?n===0?e.push(new Rect(0,0,Math.abs(this.Gt[0]),s)):e.push(new Rect(this.Gt[n-1],0,Math.abs(this.Gt[n-1]-this.Gt[n]),s)):n===0?e.push(new Rect(this.Gt[0],0,Math.abs(this.Gt[0]-t),s)):e.push(new Rect(this.Gt[n],0,Math.abs(this.Gt[n-1]-this.Gt[n]),s));this.commitLayers(e,this.fr)}commitLayers(t,i){}commitLinks(){const t=this.network.edges.iterator;let i;for(;t.next();)i=t.value.link,i!==null&&(i.startRoute(),i.clearPoints(),i.commitRoute());for(t.reset();t.next();)i=t.value.link,i!==null&&i.updateRoute();for(t.reset();t.next();){const e=t.value;if(i=e.link,i===null||i.pointsCount===0)continue;i.startRoute();const s=i;let n=s.fromNode,o=s.toNode,r=s.fromPort,l=s.toPort;if(n!==null){const N=n.findVisibleNode();N!==null&&N!==n&&(n=N,r=N.port)}if(o!==null){const N=o.findVisibleNode();N!==null&&N!==o&&(o=N,l=N.port)}const h=i.computeSpot(!0,r),a=i.computeSpot(!1,l);let f=e.fromVertex,c=e.toVertex;if(e.valid){if(i.curve===9&&i.pointsCount===4)if(f.column===c.column&&this.alignOption===0){const N=i.getLinkPoint(n,r,h,!0,!1,o,l),T=i.getLinkPoint(o,l,a,!1,!1,n,r);N.isReal()||N.set(n.actualBounds.center),T.isReal()||T.set(o.actualBounds.center),i.clearPoints(),i.addPointAt(N.x,N.y),i.addPointAt((2*N.x+T.x)/3,(2*N.y+T.y)/3),i.addPointAt((N.x+2*T.x)/3,(N.y+2*T.y)/3),i.addPointAt(T.x,T.y)}else{let N=!1,T=!1;if(r!==null&&h===Spot.None&&(N=!0),l!==null&&a===Spot.None&&(T=!0),N||T){let L=null;N&&(L=i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0),L.isReal()||L.set(n.actualBounds.center),i.setPointAt(0,L.x,L.y));let D=null;if(T&&(D=i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(0),!1),D.isReal()||D.set(o.actualBounds.center),i.setPointAt(3,D.x,D.y)),L){const F=i.getPoint(2);i.setPointAt(1,(L.x*2+F.x)/3,(L.y*2+F.y)/3)}if(D){const F=i.getPoint(1);i.setPointAt(2,(D.x*2+F.x)/3,(D.y*2+F.y)/3)}}}i.commitRoute();continue}if(f.layer===c.layer){i.commitRoute();continue}let u=!1,d=!1;const m=this.As;let g=0,p=i.firstPickIndex+1;if(i.isOrthogonal)d=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3);else if(i.curve===9)u=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3),g===4&&(p=2);else{g=i.pointsCount;const N=h===Spot.None,T=a===Spot.None;g>2&&N&&T?i.points.removeRange(1,g-2):g>3&&N&&!T?i.points.removeRange(1,g-3):g>3&&!N&&T?i.points.removeRange(2,g-2):g>4&&!N&&!T&&i.points.removeRange(2,g-3)}let y,x,k=0,b=0,S=0,M=0,A=0,C=0,P=0;if(e.rev){let N=0;for(;c!==null&&f!==c;){y=null,x=null;const T=c.sourceEdges.iterator;for(;T.next();){const L=T.value;if(L.link===e.link&&(y=L.fromVertex,x=L.toVertex,y.node===null))break}if(y===null)break;if(y!==f)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=y.centerX,M=y.centerY,d)this.C===180||this.C===0?p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,k,M)):(x!==null?x.centerY:b)!==M&&(A=this.Gt[y.layer-1]+this.fr.x,i.insertPointAt(p++,A,b),i.insertPointAt(p++,A,M)):p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,S,b)):(x!==null?x.centerX:k)!==S&&(A=this.Gt[y.layer-1]+this.fr.y,i.insertPointAt(p++,k,A),i.insertPointAt(p++,S,A));else if(p===i.firstPickIndex+1)if(C=Math.max(10,this.nn[c.layer]),P=Math.max(10,this.Ts[c.layer]),u)this.C===180?S<=c.bounds.x?(N=c.bounds.x,i.insertPointAt(p++,N-C,M),i.insertPointAt(p++,N,M),i.insertPointAt(p++,N+P,M)):(i.insertPointAt(p++,S-C,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S+P,M)):this.C===90?M>=c.bounds.bottom?(N=c.bounds.y+c.bounds.height,i.insertPointAt(p++,S,N+P),i.insertPointAt(p++,S,N),i.insertPointAt(p++,S,N-C)):(i.insertPointAt(p++,S,M+P),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M-C)):this.C===270?M<=c.bounds.y?(N=c.bounds.y,i.insertPointAt(p++,S,N-C),i.insertPointAt(p++,S,N),i.insertPointAt(p++,S,N+P)):(i.insertPointAt(p++,S,M-C),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M+P)):this.C===0&&(S>=c.bounds.right?(N=c.bounds.x+c.bounds.width,i.insertPointAt(p++,N+P,M),i.insertPointAt(p++,N,M),i.insertPointAt(p++,N-C,M)):(i.insertPointAt(p++,S+P,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S-C,M)));else{i.insertPointAt(p++,k,b);let L=0;this.C===180||this.C===0?((this.C===180?S>=c.bounds.right:S<=c.bounds.x)&&(L=(this.C===0?-C:P)/2),i.insertPointAt(p++,k+L,M)):((this.C===270?M>=c.bounds.bottom:M<=c.bounds.y)&&(L=(this.C===90?-C:P)/2),i.insertPointAt(p++,S,b+L)),i.insertPointAt(p++,S,M)}else C=Math.max(10,this.nn[y.layer]),P=Math.max(10,this.Ts[y.layer]),u?this.C===180?(i.insertPointAt(p++,S-C-m,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S+P+m,M)):this.C===90?(i.insertPointAt(p++,S,M+P+m),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M-C-m)):this.C===270?(i.insertPointAt(p++,S,M-C-m),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M+P+m)):(i.insertPointAt(p++,S+P+m,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S-C-m,M)):(this.C===180||this.C===90||this.C,i.insertPointAt(p++,S,M));c=y}if(l===null||h!==Spot.None||d)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=i.getPoint(p).x,M=i.getPoint(p).y,d){const T=this.Ts[f.layer];let L=0;this.C===180||this.C===0?(L=b,L>=f.bounds.y&&L<=f.bounds.bottom&&(this.C===180?S>=f.bounds.x:S<=f.bounds.right)&&(N=f.centerX+(this.C===180?-T:T),L=f.bounds.x&&L<=f.bounds.right&&(this.C===270?M>=f.bounds.y:M<=f.bounds.bottom)&&(N=f.centerY+(this.C===270?-T:T),L=f.bounds.x?(N=f.bounds.x+f.bounds.width,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N+P,b)):this.C===90&&M<=f.bounds.bottom?(N=f.bounds.y,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N-C)):this.C===270&&M>=f.bounds.y?(N=f.bounds.y+f.bounds.height,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N+P)):this.C===0&&S<=f.bounds.right&&(N=f.bounds.x,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N-C,b));else{C=Math.max(10,this.nn[f.layer]),P=Math.max(10,this.Ts[f.layer]);let T=0;this.C===180||this.C===0?((this.C===180?S<=f.bounds.x:S>=f.bounds.right)&&(T=(this.C===0?P:-C)/2),i.insertPointAt(p++,S+T,b)):((this.C===270?M<=f.bounds.y:M>=f.bounds.bottom)&&(T=(this.C===90?P:-C)/2),i.insertPointAt(p++,k,M+T)),i.insertPointAt(p++,S,M)}}else{for(;f!==null&&f!==c;){y=null,x=null;const N=f.destinationEdges.iterator;for(;N.next();){const T=N.value;if(T.link===e.link&&(y=T.toVertex,x=T.fromVertex,x.node!==null&&(x=null),y.node===null))break}if(y===null)break;y!==c&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=y.centerX,M=y.centerY,d?this.C===180||this.C===0?(x!==null?x.centerY:b)!==M&&(A=this.Gt[y.layer]+this.fr.x,p===i.firstPickIndex+1&&(this.C===0?A=Math.max(A,k):A=Math.min(A,k)),i.insertPointAt(p++,A,b),i.insertPointAt(p++,A,M)):(x!==null?x.centerX:k)!==S&&(A=this.Gt[y.layer]+this.fr.y,p===i.firstPickIndex+1&&(this.C===90?A=Math.max(A,b):A=Math.min(A,b)),i.insertPointAt(p++,k,A),i.insertPointAt(p++,S,A)):(C=Math.max(10,this.nn[y.layer]),P=Math.max(10,this.Ts[y.layer]),u?this.C===180?(i.insertPointAt(p++,S+P+m,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S-C-m,M)):this.C===90?(i.insertPointAt(p++,S,M-C-m),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M+P+m)):this.C===270?(i.insertPointAt(p++,S,M+P+m),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M-C-m)):(i.insertPointAt(p++,S-C-m,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S+P+m,M)):this.C===180?(i.insertPointAt(p++,S+P,M),i.insertPointAt(p++,S-C,M)):this.C===90?(i.insertPointAt(p++,S,M-C),i.insertPointAt(p++,S,M+P)):this.C===270?(i.insertPointAt(p++,S,M+P),i.insertPointAt(p++,S,M-C)):(i.insertPointAt(p++,S-C,M),i.insertPointAt(p++,S+P,M)))),f=y}d&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=i.getPoint(p).x,M=i.getPoint(p).y,this.C===180||this.C===0?b!==M&&(this.C===0?A=Math.min(Math.max((S+k)/2,this.Gt[c.layer]+this.fr.x),S):A=Math.max(Math.min((S+k)/2,this.Gt[c.layer]+this.fr.x),S),i.insertPointAt(p++,A,b),i.insertPointAt(p++,A,M)):k!==S&&(this.C===90?A=Math.min(Math.max((M+b)/2,this.Gt[c.layer]+this.fr.y),M):A=Math.max(Math.min((M+b)/2,this.Gt[c.layer]+this.fr.y),M),i.insertPointAt(p++,k,A),i.insertPointAt(p++,S,A)))}if(s!==null&&u&&i.pointsCount>=4){if(r!==null){const N=h===Spot.None?i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0):i.getPoint(0);if(h===Spot.None){const T=i.getPoint(2),L=i.getPoint(3);this.direction===90||this.direction===270?(i.setPointAt(1,(N.x+T.x)/2,T.y),i.setPointAt(2,L.x,(T.y+L.y)/2)):(i.setPointAt(1,T.x,(N.y+T.y)/2),i.setPointAt(2,(T.x+L.x)/2,L.y))}N.isReal()||N.set(n.actualBounds.center),i.setPointAt(0,N.x,N.y)}if(l!==null){const N=a===Spot.None?i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(i.pointsCount-4),!1):i.getPoint(i.pointsCount-1);if(a===Spot.None){const T=i.getPoint(i.pointsCount-3),L=i.getPoint(i.pointsCount-4);this.direction===90||this.direction===270?(i.setPointAt(i.pointsCount-2,(N.x+T.x)/2,T.y),i.setPointAt(i.pointsCount-2,L.x,(T.y+L.y)/2)):(i.setPointAt(i.pointsCount-2,T.x,(N.y+T.y)/2),i.setPointAt(i.pointsCount-3,(T.x+L.x)/2,L.y))}N.isReal()||N.set(o.actualBounds.center),i.setPointAt(i.pointsCount-1,N.x,N.y)}}i.commitRoute(),e.commit()}}QO(){this.Wy=-1,this.Og=0,this.Ls=0,this.sf=null,this.Vg=null,this.iu=null;for(let t=0;t=this.Bn.length){const n=[];for(let o=0;o=0&&(this.As=t,this.invalidateLayout()))}get columnSpacing(){return this._i}set columnSpacing(t){this._i!==t&&(Util.t(t,"number",LayeredDigraphLayout,"columnSpacing"),t>0&&(this._i=t,this.invalidateLayout()))}get direction(){return this.C}set direction(t){this.C!==t&&(Util.t(t,"number",LayeredDigraphLayout,"direction"),t===0||t===90||t===180||t===270?(this.C=t,this.invalidateLayout()):Util.n("LayeredDigraphLayout.direction must be 0, 90, 180, or 270"))}get cycleRemoveOption(){return this.Zc}set cycleRemoveOption(t){this.Zc!==t&&(Util.tt(t,LayeredDigraphCycleRemove,"LayeredDigraphCycleRemove"),(t===1||t===0||t===2)&&(this.Zc=t,this.invalidateLayout()))}get layeringOption(){return this.$c}set layeringOption(t){this.$c!==t&&(Util.tt(t,LayeredDigraphLayering,"LayeredDigraphLayering"),(t===10||t===11||t===12)&&(this.$c=t,this.invalidateLayout()))}get initializeOption(){return this.Qc}set initializeOption(t){this.Qc!==t&&(Util.tt(t,LayeredDigraphInit,"LayeredDigraphInit"),(t===20||t===21||t===22)&&(this.Qc=t,this.invalidateLayout()))}get iterations(){return this.ef}set iterations(t){this.ef!==t&&(Util.r(t,LayeredDigraphNetwork,"iterations"),t>=0&&(this.ef=t,this.invalidateLayout()))}get aggressiveOption(){return this._c}set aggressiveOption(t){this._c!==t&&(Util.tt(t,LayeredDigraphAggressive,"LayeredDigraphAggressive"),(t===30||t===31||t===32)&&(this._c=t,this.invalidateLayout()))}get packOption(){return this.ar}set packOption(t){this.ar!==t&&(Util.t(t,"number",LayeredDigraphLayout,"packOption"),t>=0&&t<8&&(this.ar=t,this.invalidateLayout()))}get packIterations(){return this.tu}set packIterations(t){this.tu=t}get alignOption(){return this.zn}set alignOption(t){this.zn!==t&&(Util.t(t,"number",LayeredDigraphLayout,"align"),t>=0&&t<16&&(this.zn=t,this.invalidateLayout()))}get setsPortSpots(){return this.Vn}set setsPortSpots(t){this.Vn!==t&&(Util.t(t,"boolean",LayeredDigraphLayout,"setsPortSpots"),this.Vn=t,this.invalidateLayout())}get maxLayer(){return this.Lt}get maxIndex(){return this.Wy}get maxColumn(){return this.Wt}get minIndexLayer(){return this.Og}get maxIndexLayer(){return this.Ls}static CycleDepthFirst=0;static CycleGreedy=1;static CycleFromLayers=2;static LayerOptimalLinkLength=10;static LayerLongestPathSink=11;static LayerLongestPathSource=12;static InitDepthFirstOut=20;static InitDepthFirstIn=21;static InitNaive=22;static AggressiveNone=30;static AggressiveLess=31;static AggressiveMore=32;static PackNone=0;static PackExpand=1;static PackStraighten=2;static PackMedian=4;static PackAll=15;static AlignNone=0;static AlignUpperLeft=1;static AlignUpperRight=2;static AlignLowerLeft=4;static AlignLowerRight=8;static AlignAll=15}class SegInfo{_o;F3;b1;R3;I3;Vt;$e;O3;constructor(){this._o=0,this.F3=0,this.b1=0,this.R3=0,this.I3=0,this.Vt=0,this.$e=null,this.O3=0}}class LayeredDigraphNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new LayeredDigraphVertex(this)}createEdge(){return new LayeredDigraphEdge(this)}}class LayeredDigraphVertex extends LayoutVertex{_o;Go;Vt;fk;ck;ie;eu;$n;rk;sk;nk;nf;Xn;wD;Vh;ss;su;ue;Yn;$y=null;Qy=null;_y=null;tw=null;constructor(t){super(t),this._o=-1,this.Go=-1,this.Vt=-1,this.fk=NaN,this.ck=null,this.ie=!1,this.eu=NaN,this.$n=NaN,this.rk=0,this.sk=null,this.nk=null}static kD(t,i){return t.index-i.index}getProperSourceEdges(){if(!this._y){const t=[];for(const i of this.So){const e=i;e.valid&&t.push(e)}this._y=t}return this._y}getProperDestinationEdges(){if(!this.tw){const t=[];for(const i of this.rr){const e=i;e.valid&&t.push(e)}this.tw=t}return this.tw}getDestinationEdge(t){const i=this.getProperDestinationEdges();for(const e of i)if(e.toVertex===t)return e;Util.n("Unable to find destination edge to given vertex")}getProperSourceVertexes(){if(!this.$y){const t=[];for(const i of this.So){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.fromVertex)}t.sort(LayeredDigraphVertex.kD),this.$y=t}return this.$y}getProperDestinationVertexes(){if(!this.Qy){const t=[];for(const i of this.rr){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.toVertex)}t.sort(LayeredDigraphVertex.kD),this.Qy=t}return this.Qy}addSourceEdge(t){super.addSourceEdge(t),this.$y=null,this._y=null}deleteSourceEdge(t){super.deleteSourceEdge(t),this.$y=null,this._y=null}addDestinationEdge(t){super.addDestinationEdge(t),this.Qy=null,this.tw=null}deleteDestinationEdge(t){super.deleteDestinationEdge(t),this.Qy=null,this.tw=null}get layer(){return this._o}set layer(t){this._o!==t&&(Util.t(t,"number",LayeredDigraphVertex,"layer"),this._o=t)}get column(){return this.Go}set column(t){this.Go!==t&&(Util.t(t,"number",LayeredDigraphVertex,"column"),this.Go=t)}get index(){return this.Vt}set index(t){this.Vt!==t&&(Util.t(t,"number",LayeredDigraphVertex,"index"),this.Vt=t)}get component(){return this.fk}set component(t){this.fk!==t&&(Util.t(t,"number",LayeredDigraphVertex,"component"),this.fk=t)}get near(){return this.ck}set near(t){this.ck!==t&&(Debug&&t!==null&&Util.s(t,LayeredDigraphVertex,LayeredDigraphVertex,"near"),this.ck=t)}}class LayeredDigraphEdge extends LayoutEdge{ie;uk;dk;gk;mk;pk;yk;constructor(t){super(t),this.ie=!1,this.uk=!1,this.dk=!1,this.gk=NaN,this.mk=NaN,this.pk=0,this.yk=0}get fromVertex(){return this._e}set fromVertex(t){this._e!==t&&(Debug&&t!==null&&Util.s(t,LayeredDigraphVertex,LayeredDigraphEdge,"fromVertex"),this._e=t)}get toVertex(){return this.ts}set toVertex(t){this.ts!==t&&(Debug&&t!==null&&Util.s(t,LayeredDigraphVertex,LayeredDigraphEdge,"toVertex"),this.ts=t)}get valid(){return this.ie}set valid(t){this.ie!==t&&(Util.t(t,"boolean",LayeredDigraphEdge,"valid"),this.ie=t)}get rev(){return this.uk}set rev(t){this.uk!==t&&(Util.t(t,"boolean",LayeredDigraphEdge,"rev"),this.uk=t)}get forest(){return this.dk}set forest(t){this.dk!==t&&(Util.t(t,"boolean",LayeredDigraphEdge,"forest"),this.dk=t)}get portFromPos(){return this.gk}set portFromPos(t){this.gk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portFromPos"),this.gk=t)}get portToPos(){return this.mk}set portToPos(t){this.mk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portToPos"),this.mk=t)}get portFromColOffset(){return this.pk}set portFromColOffset(t){this.pk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portFromColOffset"),this.pk=t)}get portToColOffset(){return this.yk}set portToColOffset(t){this.yk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portToColOffset"),this.yk=t)}}var TreePath=(w=>(w[w.Default=0]="Default",w[w.Destination=1]="Destination",w[w.Source=2]="Source",w))(TreePath||{}),TreeSorting=(w=>(w[w.Forwards=10]="Forwards",w[w.Reverse=11]="Reverse",w[w.Ascending=12]="Ascending",w[w.Descending=13]="Descending",w))(TreeSorting||{}),TreeAlignment=(w=>(w[w.CenterSubtrees=20]="CenterSubtrees",w[w.CenterChildren=21]="CenterChildren",w[w.Start=22]="Start",w[w.End=23]="End",w[w.Bus=24]="Bus",w[w.BusBranching=25]="BusBranching",w[w.TopLeftBus=26]="TopLeftBus",w[w.BottomRightBus=27]="BottomRightBus",w[w.Custom=28]="Custom",w))(TreeAlignment||{}),TreeCompaction=(w=>(w[w.None=30]="None",w[w.Block=31]="Block",w))(TreeCompaction||{}),TreeStyle=(w=>(w[w.Layered=40]="Layered",w[w.LastParents=41]="LastParents",w[w.Alternating=42]="Alternating",w[w.RootOnly=43]="RootOnly",w))(TreeStyle||{}),TreeArrangement=(w=>(w[w.Vertical=50]="Vertical",w[w.Horizontal=51]="Horizontal",w[w.FixedRoots=52]="FixedRoots",w))(TreeArrangement||{}),TreeLayerStyle=(w=>(w[w.Individual=60]="Individual",w[w.Siblings=61]="Siblings",w[w.Uniform=62]="Uniform",w))(TreeLayerStyle||{});class TreeLayout extends Layout{Ei;Ii;nu;zg;JN;Be;qi;Cs;K;U;wk;ds;constructor(t){super(),this.Ei=new GSet,this.Ii=0,this.ds=1,this.nu=40,this.zg=60,this.JN=[],this.Be=!0,this.qi=50,this.Cs=new Size(10,10).w();const i=new TreeNetwork(this);this.K=new TreeVertex(i),this.U=new TreeVertex(i),this.wk=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Ii=this.Ii,t.nu=this.nu,t.zg=this.zg,t.Be=this.Be,t.qi=this.qi,t.Cs.c(this.Cs),t.K.copyInheritedPropertiesFrom(this.K),t.U.copyInheritedPropertiesFrom(this.U)}fi(t){t in TreeAlignment?this.alignment=t:t in TreeArrangement?this.arrangement=t:t in TreeCompaction?this.compaction=t:t in TreePath?this.path=t:t in TreeSorting?this.sorting=t:t in TreeStyle?this.treeStyle=t:super.fi(t)}createNetwork(){return new TreeNetwork(this)}makeNetwork(t){const i=this.createNetwork(),e=s=>{if(s instanceof Node)return!s.isLinkLabel&&s.category!=="Comment";if(s instanceof Link){const n=s.fromNode;if(n===null||n.isLinkLabel||n.category==="Comment")return!1;const o=s.toNode;return!(o===null||o.isLinkLabel||o.category==="Comment")}return!1};return t instanceof Diagram?(i.addParts(t.nodes,!0,e),i.addParts(t.links,!0,e)):t instanceof Group?i.addParts(t.memberParts,!1,e):i.addParts(t.iterator,!1,e),i}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.network===null&&(this.network=this.makeNetwork(t)),this.arrangement!==52&&(this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin));let i=this.diagram;i===null&&t instanceof Diagram&&(i=t),this.path===0&&i!==null?this.ds=i.isTreePathToChildren?1:2:this.ds=this.path===0?1:this.path,this.network.vertexes.count>0&&(this.E3(),this.V3(),this.B3(),this.z3(),this.UN(),this.X3(),this.arrangeTrees(),this.updateParts()),this.network=null,this.Ei=new GSet,this.isValidLayout=!0}E3(){this.network.deleteSelfEdges();const t=this.network.vertexes.iterator;for(;t.next();){const n=t.value;n.initialized=!1,n.level=0,n.parent=null,n.children=[]}if(this.Ei.count>0){const n=new GSet,o=this.Ei.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=this.network.findVertex(r);l!==null&&n.add(l)}else r instanceof TreeVertex&&n.add(r)}this.Ei=n}this.Ei.count===0&&this.findRoots();const i=this.Ei.copy().iterator;for(;i.next();){const n=i.value;n.initialized||(n.initialized=!0,this.ZN(n))}let e=this.network.vertexes,s=null;for(;s=this.Y3(e),s.count>0;){const n=this.SD(s);n!==null&&this.Ei.add(n),n.initialized=!0,this.ZN(n),e=s}}Y3(t){const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;s.initialized||i.add(s)}return i}findRoots(){const t=this.network.vertexes,i=t.iterator;for(;i.next();){const e=i.value;switch(this.ds){case 1:e.sourceEdges.count===0&&this.Ei.add(e);break;case 2:e.destinationEdges.count===0&&this.Ei.add(e);break;default:Util.n("Unhandled path value "+this.ds.toString())}}if(this.Ei.count===0){const e=this.SD(t);e!==null&&this.Ei.add(e)}}SD(t){let i=999999,e=null;const s=t.iterator;for(;s.next();){const n=s.value;switch(this.ds){case 1:n.sourceEdges.count0){const s=new List,n=t.destinationVertexes;for(;n.next();){const o=n.value;this.MD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;case 2:if(t.sourceEdges.count>0){const s=new List,n=t.sourceVertexes;for(;n.next();){const o=n.value;this.MD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;default:Util.n("Unhandled path value"+this.ds.toString())}const i=t.children,e=i.length;for(let s=0;st.level?!1:(this.U3(i.parent,i),!0):!0}K3(t,i){if(i===null)return!1;Debug&&Util.s(t,TreeVertex,TreeLayout,"isAncestor:a"),Debug&&Util.s(i,TreeVertex,TreeLayout,"isAncestor:b");let e=i.parent;for(;e!==null&&e!==t;)e=e.parent;return e===t}U3(t,i){if(t===null||i===null)return;Debug&&Util.s(t,TreeVertex,TreeLayout,"removeChild:p"),Debug&&Util.s(i,TreeVertex,TreeLayout,"removeChild:c");const e=t.children;let s=0;for(let n=0;n0){const n=new Array(e.length-s);let o=0;for(let r=0;r0?s+1:0}G3(t){switch(Debug&&Util.s(t,TreeVertex,TreeLayout,"mom:v"),this.nu){default:case 40:return t.parent!==null?t.parent:this.K;case 43:return t.parent===null?this.K:t.parent.parent===null?this.U:t.parent;case 42:return t.parent!==null?t.parent.parent!==null?t.parent.parent:this.U:this.K;case 41:{let i=!0;if(t.childrenCount===0)i=!1;else{const e=t.children,s=e.length;for(let n=0;n0){i=!1;break}}return i&&t.parent!==null?this.U:t.parent!==null?t.parent:this.K}}}initializeTreeVertexValues(t){Debug&&Util.s(t,TreeVertex,TreeLayout,"initializeTreeVertexValues:v");const i=this.G3(t);if(t.copyInheritedPropertiesFrom(i),t.parent!==null&&t.parent.alignment===25){let e=t.angle;const s=t.parent.children;let n=0;for(;n135&&!l||a&&c)if(t.commentMargin>=0){g.e(t.bounds.x-t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleLeft,S.toSpot=Spot.MiddleRight}}else{g.e(t.bounds.x+t.focus.x*2-t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleRight,S.toSpot=Spot.MiddleLeft}}else if(t.commentMargin>=0){g.e(t.bounds.x+t.focus.x*2+t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleRight,S.toSpot=Spot.MiddleLeft}}else{g.e(t.bounds.x+t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleLeft,S.toSpot=Spot.MiddleRight}}t.commentSpacing>=0?u+=k.height+t.commentSpacing:u+=t.commentSpacing-k.height}else{if(o>135&&!l||!a&&c)if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y-t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleTop,S.toSpot=Spot.MiddleBottom}}else{g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2-t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleBottom,S.toSpot=Spot.MiddleTop}}else if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2+t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleBottom,S.toSpot=Spot.MiddleTop}}else{g.e(t.bounds.x+u,t.bounds.y+t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleTop,S.toSpot=Spot.MiddleBottom}}t.commentSpacing>=0?u+=k.width+t.commentSpacing:u+=t.commentSpacing-k.width}}Point.o(g);const p=u-t.commentSpacing-(h?e.height:e.width);if(this.ds===1){const y=t.destinationEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.fromEndSegmentLength=p>0?p:NaN)}}else{const y=t.sourceEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.toEndSegmentLength=p>0?p:NaN)}}}}X3(){if(this.layerStyle===62){const i=[];let e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;let n=s.parent;n===null&&(n=s);const o=n.angle===0||n.angle===180;let r=i[s.level];r===void 0&&(r=0),i[s.level]=Math.max(r,o?s.width:s.height)}for(let s=0;s=0)for(let o=0;o135&&n.reverse(),this.iw(r))if(o>1)for(let R=0;R0&&P>0&&M+u+O.width>f&&(M135?-b-g:b+g);const B=P===0?m:u;this.xk(I,0,A),I.X.e(M+B,A),k=Math.max(k,M+B+O.width),b=Math.max(b,S+(C===0?0:g)+O.height),M+=B+O.width}else{f>0&&P>0&&A+u+O.height>f&&(A135?-k-g:k+g);const B=P===0?m:u;this.xk(I,M,0),I.X.e(M,A+B),b=Math.max(b,A+B+O.height),k=Math.max(k,S+(C===0?0:g)+O.width),A+=B+O.height}P++}C>0&&(e?(b+=Math.max(0,c),M0&&(h||this.lu(t,p,0,0,o-1),k+=p)):(k+=Math.max(0,c),A0&&(h||this.lu(t,0,p,0,o-1),b+=p)));let D=0,F=0;switch(r){case 20:e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;break;default:case 21:if(C>0)e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;else{const I=o;if(e){const O=n[0].X.x+n[0].rt.x,B=n[I-1].X.x+n[I-1].rt.x+n[I-1].focus.x*2;D+=O+(B-O)/2-t.focus.x-d/2}else{const O=n[0].X.y+n[0].rt.y,B=n[I-1].X.y+n[I-1].rt.y+n[I-1].focus.y*2;F+=O+(B-O)/2-t.focus.y-d/2}}break;case 22:e?(D-=d,k+=d):(F-=d,b+=d);break;case 23:e?(D+=k-t.width+d,k+=d):(F+=b-t.height+d,b+=d);break;case 24:case 25:e?o>1?D+=T+u/2-t.focus.x:D+=n[0].focus.x-t.focus.x+n[0].rt.x:o>1?F+=T+u/2-t.focus.y:F+=n[0].focus.y-t.focus.y+n[0].rt.y;break;case 26:e?D+=k+u/2-t.focus.x:F+=b+u/2-t.focus.y;break;case 27:break;case 28:const R=this.customAlignment(t,D,F,k,b);D=R[0],F=R[1],k=R[2],b=R[3];break}for(let R=0;R135?(a?-b:-I.kt.height)+I.rt.y-c:x+c+I.rt.y)):I.X.e(I.X.x+(i>135?(a?-k:-I.kt.width)+I.rt.x-c:y+c+I.rt.x),I.X.y+I.rt.y-F)}e?(k=this.QN(t,k,D),D<0&&(D=0),i>135&&(F+=b+c),b=Math.max(Math.max(b,x),b+x+c)):(i>135&&(D+=k+c),k=Math.max(Math.max(k,y),k+y+c),b=this._N(t,b,F),F<0&&(F=0)),t.rt.e(D,F),t.kt.e(k,b)}customAlignment(t,i,e,s,n){return[i,e,s,n]}LD(t,i,e,s,n,o){Debug&&Util.s(t,TreeVertex,TreeLayout,"layoutBusChildrenPosDir:v");const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.kt.width,o=p.kt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,f=this.orthoAngle(t)===90;let c=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.kt,k=c===0?0:h;if(f){const b=this.computeBusNodeSpacing(y)-l;y.X.e(e-(x.width+b),d+k),n=Math.max(n,x.width+b),o=Math.max(o,d+k+x.height),d+=k+x.height}else{const b=this.computeBusNodeSpacing(y)-l;y.X.e(u+k,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,u+k+x.width),u+=k+x.width}c++}c=0;const m=u,g=d;f?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.kt,x=this.computeBusLastRowSpacing(p,f?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(f){p.X.e(e+l/2-p.focus.x-p.rt.x,o+x);const k=e+l/2-p.focus.x-p.rt.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.max(g,d)+x+y.height),p.X.x<0&&(e=this.bk(t,p.X.x,!1,e,l))}else{p.X.e(n+x,e+l/2-p.focus.y-p.rt.y),n=Math.max(n,Math.max(m,u)+x+y.width);const k=e+l/2-p.focus.y-p.rt.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.X.y<0&&(e=this.bk(t,p.X.y,!0,e,l))}}return new Rect(e,0,n,o)}TD(t,i,e,s,n,o){Debug&&Util.s(t,TreeVertex,TreeLayout,"layoutBusChildrenNegDir:v");const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.kt.width,o=p.kt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,f=this.orthoAngle(t)===270;let c=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.kt,k=c===0?0:h;if(f){const b=this.computeBusNodeSpacing(y)-l;d-=k+x.height,y.X.e(e-(x.width+b),d),n=Math.max(n,x.width+b),o=Math.max(o,Math.abs(d))}else{const b=this.computeBusNodeSpacing(y)-l;u-=k+x.width,y.X.e(u,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,Math.abs(u))}c++}c=0;const m=u,g=d;f?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.kt,x=this.computeBusLastRowSpacing(p,f?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(f){p.X.e(e+l/2-p.focus.x-p.rt.x,-o-y.height-x);const k=e+l/2-p.focus.x-p.rt.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.abs(Math.min(g,d))+x+y.height),p.X.x<0&&(e=this.bk(t,p.X.x,!1,e,l))}else{p.X.e(-n-y.width-x,e+l/2-p.focus.y-p.rt.y),n=Math.max(n,Math.abs(Math.min(m,u))+x+y.width);const k=e+l/2-p.focus.y-p.rt.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.X.y<0&&(e=this.bk(t,p.X.y,!0,e,l))}}for(let p=0;ps&&(s=e+t.width),e<0&&(s-=e),s;case 22:return t.width>i?t.width:i;case 23:return t.focus.x*2>i?t.width:i+t.width-t.focus.x*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.width);return Math.max(t.width,o-n);case 26:return t.width-t.focus.x+t.nodeSpacing/2+i;case 27:return Math.max(t.width,t.focus.x+t.nodeSpacing/2+i);default:return i}}_N(t,i,e){switch(Debug&&Util.s(t,TreeVertex,TreeLayout,"calculateSubheight:v"),t.alignment){case 21:case 20:let s=i;return e+t.height>s&&(s=e+t.height),e<0&&(s-=e),s;case 22:return t.height>i?t.height:i;case 23:return t.focus.y*2>i?t.height:i+t.height-t.focus.y*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.height);return Math.max(t.height,o-n);case 26:return t.height-t.focus.y+t.nodeSpacing/2+i;case 27:return Math.max(t.height,t.focus.y+t.nodeSpacing/2+i);default:return i}}tC(t,i,e){switch(Debug&&Util.tt(t,TreeAlignment,"TreeAlignment"),t){case 20:i/=2,e/=2;break;case 21:i/=2,e/=2;break;case 22:i=0,e=0;break;case 23:break;default:Util.n("Unhandled alignment value "+t.toString())}return new Point(i,e)}of(t,i,e,s,n,o){Debug&&Util.s(t,TreeVertex,TreeLayout,"shiftRelPosAlign:v"),Debug&&Util.tt(i,TreeAlignment,"TreeAlignment");const r=this.tC(i,e,s);this.lu(t,r.x,r.y,n,o)}lu(t,i,e,s,n){if(Debug&&Util.s(t,TreeVertex,TreeLayout,"shiftRelPos:v"),i===0&&e===0)return;const o=t.children;for(let r=s;r<=n;r++){const h=o[r].X;h.x+=i,h.y+=e}}xk(t,i,e){Debug&&(Util.s(t,TreeVertex,TreeLayout,"recordMidPoints:v"),Util.t(i,"number",TreeLayout,"recordMidPoints:x"),Util.t(e,"number",TreeLayout,"recordMidPoints:y"));const s=t.parent;switch(this.ds){case 1:{const n=t.sourceEdges;for(;n.next();){const o=n.value;o.fromVertex===s&&o.relativePoint.e(i,e)}break}case 2:{const n=t.destinationEdges;for(;n.next();){const o=n.value;o.toVertex===s&&o.relativePoint.e(i,e)}break}default:Util.n("Unhandled path value "+this.ds.toString())}}H3(t){if(Debug&&Util.s(t,TreeVertex,TreeLayout,"layoutTreeBlock:v"),t.childrenCount===0){const z=t.parent;let G=!1,q=0,j=21;z!==null&&(q=z.angle,j=z.alignment,G=this.isBusAlignment(j));const J=this.$N(t);t.X.e(0,0),t.kt.e(t.width,t.height),t.parent!==null&&t.comments!==null&&((q===180||q===270)&&!G||J)?q===180&&!G||(q===90||q===270)&&J?t.rt.e(t.width-t.focus.x*2,0):t.rt.e(0,t.height-t.focus.y*2):t.rt.e(0,0),t.Xg=null,t.Yg=null;return}const i=this.orthoAngle(t),e=i===90||i===270;let s=0;const n=t.children,o=n.length;for(let z=0;z135&&n.reverse(),this.iw(r))if(o>1)for(let z=0;z0&&L>0&&P+u+q.width>f&&(P135?-k-m:k+m),this.xk(G,0,N);let j=0;if(L===0)S=G.Xg,M=G.Yg,A=q.width,C=q.height,(S===null||M===null||i!==this.orthoAngle(G))&&(S=this.de(2),M=this.de(2),S[0].e(0,0),S[1].e(0,C),M[0].e(A,0),M[1].e(A,C));else{const J=Util.ft(),Y=this.DD(t,G,S,M,A,C,J);j=Y.x,S=J[0],M=J[1],A=Y.width,C=Y.height,Util.nt(J),P0&&L>0&&N+u+q.height>f&&(N135?-x-m:x+m),this.xk(G,P,0);let j=0;if(L===0)S=G.Xg,M=G.Yg,A=q.width,C=q.height,(S===null||M===null||i!==this.orthoAngle(G))&&(S=this.de(2),M=this.de(2),S[0].e(0,0),S[1].e(A,0),M[0].e(0,C),M[1].e(A,C));else{const J=Util.ft(),Y=this.DD(t,G,S,M,A,C,J);j=Y.x,S=J[0],M=J[1],A=Y.width,C=Y.height,Util.nt(J),N0&&(e?(k+=Math.max(0,c),P0&&(h||this.lu(t,g,0,0,o-1),x+=g)):(x+=Math.max(0,c),N0&&(h||this.lu(t,0,g,0,o-1),k+=g)));let I=0,O=0;switch(r){case 20:e?I+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;break;default:case 21:if(T>0)e?I+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;else{const G=o;if(e){const q=n[0].X.x+n[0].rt.x,j=n[G-1].X.x+n[G-1].rt.x+n[G-1].focus.x*2;I+=q+(j-q)/2-t.focus.x-d/2}else{const q=n[0].X.y+n[0].rt.y,j=n[G-1].X.y+n[G-1].rt.y+n[G-1].focus.y*2;O+=q+(j-q)/2-t.focus.y-d/2}}break;case 22:e?(I-=d,x+=d):(O-=d,k+=d);break;case 23:e?(I+=x-t.width+d,x+=d):(O+=k-t.height+d,k+=d);break;case 24:e?o>1?I+=F+u/2-t.focus.x:I+=n[0].focus.x-t.focus.x+n[0].rt.x:o>1?O+=F+u/2-t.focus.y:O+=n[0].focus.y-t.focus.y+n[0].rt.y;break;case 26:e?I+=x+u/2-t.focus.x:O+=k+u/2-t.focus.y;break;case 27:break;case 28:const z=this.customAlignment(t,I,O,x,k);I=z[0],O=z[1],x=z[2],k=z[3];break}for(let z=0;z135?(a?-k:-G.kt.height)+G.rt.y-c:y+c+G.rt.y)):G.X.e(G.X.x+(i>135?(a?-x:-G.kt.width)+G.rt.x-c:p+c+G.rt.x),G.X.y+G.rt.y-O)}let B=0,K=0;if(a)e?(x=this.QN(t,x,I),I<0&&(I=0),i>135&&(O+=k+c),k+=y+c,r===27&&(B+=u/2+t.focus.x),K+=y+c):(i>135&&(I+=x+c),x+=p+c,k=this._N(t,k,O),O<0&&(O=0),r===27&&(K+=u/2+t.focus.y),B+=p+c);else if(e){if(t.comments===null){if(p>x){const z=this.tC(r,p-x,0);B=z.x,K=z.y,x=p,I=0}}else x=this.QN(t,x,I);I<0&&(B-=I,I=0),i>135&&(O+=k+c),k=Math.max(Math.max(k,y),k+y+c),K+=y+c}else{if(i>135&&(I+=x+c),x=Math.max(Math.max(x,p),x+p+c),t.comments===null){if(y>k){const z=this.tC(r,0,y-k);B=z.x,K=z.y,k=y,O=0}}else k=this._N(t,k,O);O<0&&(K-=O,O=0),B+=p+c}let V,X;if(T>0)V=this.de(4),X=this.de(4),e?(V[2].e(0,y+c),V[3].e(V[2].x,k),X[2].e(x,V[2].y),X[3].e(X[2].x,V[3].y)):(V[2].e(p+c,0),V[3].e(x,V[2].y),X[2].e(V[2].x,k),X[3].e(V[3].x,X[2].y));else{V=this.de(S.length+2),X=this.de(M.length+2);for(let z=0;zV[0].x?V[2].c(V[1]):V[1].c(V[2])),V[3].yV[0].x?V[3].c(V[2]):V[2].c(V[3])),X[0].e(I+p,0),X[1].e(X[0].x,y),X[2].yV[0].y?V[2].c(V[1]):V[1].c(V[2])),V[3].xV[0].y?V[3].c(V[2]):V[2].c(V[3])),X[0].e(0,O+y),X[1].e(p,X[0].y),X[2].xl;){const a=i[o++];s[r++].e(a.x,a.y+e)}const h=this.de(r);for(n=0;nl;){const a=i[o++];s[r++].e(a.x+e,a.y)}const h=this.de(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.de(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.de(r);for(n=0;nh&&r.xr.x&&ha&&r.yr.y&&a0){const n=Math.min(1,t.layerSpacingParentOverlap);s-=e?t.height*n:t.width*n}return s<(e?-t.height:-t.width)&&(s=e?-t.height:-t.width),s}computeNodeIndent(t){Debug&&Util.s(t,TreeVertex,TreeLayout,"computeNodeIndent:v");const i=this.orthoAngle(t),e=i===90||i===270;let s=t.nodeIndent;if(t.nodeIndentPastParent>0){const n=Math.min(1,t.nodeIndentPastParent);s+=e?t.width*n:t.height*n}return s=Math.max(0,s),s}get roots(){return this.Ei}set roots(t){this.Ei!==t&&(Util.s(t,GSet,TreeLayout,"roots"),this.Ei=t,this.invalidateLayout())}get path(){return this.Ii}set path(t){this.Ii!==t&&(Util.tt(t,TreePath,"TreePath"),this.Ii=t,this.invalidateLayout())}get treeStyle(){return this.nu}set treeStyle(t){this.nu!==t&&(Util.tt(t,TreeStyle,"TreeStyle"),(t===40||t===42||t===41||t===43)&&(this.nu=t,this.invalidateLayout()))}get layerStyle(){return this.zg}set layerStyle(t){this.zg!==t&&(Util.tt(t,TreeLayerStyle,"TreeLayerStyle"),(t===60||t===61||t===62)&&(this.zg=t,this.invalidateLayout()))}get comments(){return this.Be}set comments(t){this.Be!==t&&(Util.t(t,"boolean",TreeLayout,"comments"),this.Be=t,this.invalidateLayout())}get arrangement(){return this.qi}set arrangement(t){this.qi!==t&&(Util.tt(t,TreeArrangement,"TreeArrangement"),(t===50||t===51||t===52)&&(this.qi=t,this.invalidateLayout()))}get arrangementSpacing(){return this.Cs}set arrangementSpacing(t){Util.s(t,Size,TreeLayout,"arrangementSpacing"),this.Cs.equals(t)||(this.Cs.c(t),this.invalidateLayout())}get rootDefaults(){return this.K}set rootDefaults(t){this.K!==t&&(Util.s(t,TreeVertex,TreeLayout,"rootDefaults"),this.K=t,this.invalidateLayout())}get alternateDefaults(){return this.U}set alternateDefaults(t){this.U!==t&&(Util.s(t,TreeVertex,TreeLayout,"alternateDefaults"),this.U=t,this.invalidateLayout())}get sorting(){return this.K.sorting}set sorting(t){this.K.sorting!==t&&(Util.tt(t,TreeSorting,"TreeSorting"),this.K.sorting=t,this.invalidateLayout())}get comparer(){return this.K.comparer}set comparer(t){this.K.comparer!==t&&(Util.t(t,"function",TreeLayout,"comparer"),this.K.comparer=t,this.invalidateLayout())}get angle(){return this.K.angle}set angle(t){this.K.angle!==t&&(Util.t(t,"number",TreeLayout,"angle"),t===0||t===90||t===180||t===270?(this.K.angle=t,this.invalidateLayout()):Util.n("TreeLayout.angle must be 0, 90, 180, or 270"))}get alignment(){return this.K.alignment}set alignment(t){this.K.alignment!==t&&(Util.tt(t,TreeAlignment,"TreeAlignment"),this.K.alignment=t,this.invalidateLayout())}get nodeIndent(){return this.K.nodeIndent}set nodeIndent(t){this.K.nodeIndent!==t&&(Util.t(t,"number",TreeLayout,"nodeIndent"),t>=0&&(this.K.nodeIndent=t,this.invalidateLayout()))}get nodeIndentPastParent(){return this.K.nodeIndentPastParent}set nodeIndentPastParent(t){this.K.nodeIndentPastParent!==t&&(Util.t(t,"number",TreeLayout,"nodeIndentPastParent"),t>=0&&t<=1&&(this.K.nodeIndentPastParent=t,this.invalidateLayout()))}get nodeSpacing(){return this.K.nodeSpacing}set nodeSpacing(t){this.K.nodeSpacing!==t&&(Util.t(t,"number",TreeLayout,"nodeSpacing"),this.K.nodeSpacing=t,this.invalidateLayout())}get layerSpacing(){return this.K.layerSpacing}set layerSpacing(t){this.K.layerSpacing!==t&&(Util.t(t,"number",TreeLayout,"layerSpacing"),this.K.layerSpacing=t,this.invalidateLayout())}get layerSpacingParentOverlap(){return this.K.layerSpacingParentOverlap}set layerSpacingParentOverlap(t){this.K.layerSpacingParentOverlap!==t&&(Util.t(t,"number",TreeLayout,"layerSpacingParentOverlap"),t>=0&&t<=1&&(this.K.layerSpacingParentOverlap=t,this.invalidateLayout()))}get compaction(){return this.K.compaction}set compaction(t){this.K.compaction!==t&&(Util.tt(t,TreeCompaction,"TreeCompaction"),(t===30||t===31)&&(this.K.compaction=t,this.invalidateLayout()))}get breadthLimit(){return this.K.breadthLimit}set breadthLimit(t){this.K.breadthLimit!==t&&(Util.t(t,"number",TreeLayout,"breadthLimit"),t>=0&&(this.K.breadthLimit=t,this.invalidateLayout()))}get rowSpacing(){return this.K.rowSpacing}set rowSpacing(t){this.K.rowSpacing!==t&&(Util.t(t,"number",TreeLayout,"rowSpacing"),this.K.rowSpacing=t,this.invalidateLayout())}get rowIndent(){return this.K.rowIndent}set rowIndent(t){this.K.rowIndent!==t&&(Util.t(t,"number",TreeLayout,"rowIndent"),t>=0&&(this.K.rowIndent=t,this.invalidateLayout()))}get commentSpacing(){return this.K.commentSpacing}set commentSpacing(t){this.K.commentSpacing!==t&&(Util.t(t,"number",TreeLayout,"commentSpacing"),this.K.commentSpacing=t,this.invalidateLayout())}get commentMargin(){return this.K.commentMargin}set commentMargin(t){this.K.commentMargin!==t&&(Util.t(t,"number",TreeLayout,"commentMargin"),this.K.commentMargin=t,this.invalidateLayout())}get setsPortSpot(){return this.K.setsPortSpot}set setsPortSpot(t){this.K.setsPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"setsPortSpot"),this.K.setsPortSpot=t,this.invalidateLayout())}get portSpot(){return this.K.portSpot}set portSpot(t){Util.s(t,Spot,TreeLayout,"portSpot"),this.K.portSpot.equals(t)||(this.K.portSpot=t,this.invalidateLayout())}get setsChildPortSpot(){return this.K.setsChildPortSpot}set setsChildPortSpot(t){this.K.setsChildPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"setsChildPortSpot"),this.K.setsChildPortSpot=t,this.invalidateLayout())}get childPortSpot(){return this.K.childPortSpot}set childPortSpot(t){Util.s(t,Spot,TreeLayout,"childPortSpot"),this.K.childPortSpot.equals(t)||(this.K.childPortSpot=t,this.invalidateLayout())}get alternateSorting(){return this.U.sorting}set alternateSorting(t){this.U.sorting!==t&&(Util.tt(t,TreeSorting,"TreeSorting"),this.U.sorting=t,this.invalidateLayout())}get alternateComparer(){return this.U.comparer}set alternateComparer(t){this.U.comparer!==t&&(Util.t(t,"function",TreeLayout,"alternateComparer"),this.U.comparer=t,this.invalidateLayout())}get alternateAngle(){return this.U.angle}set alternateAngle(t){this.U.angle!==t&&(Util.t(t,"number",TreeLayout,"alternateAngle"),(t===0||t===90||t===180||t===270)&&(this.U.angle=t,this.invalidateLayout()))}get alternateAlignment(){return this.U.alignment}set alternateAlignment(t){this.U.alignment!==t&&(Util.tt(t,TreeAlignment,"TreeAlignment"),this.U.alignment=t,this.invalidateLayout())}get alternateNodeIndent(){return this.U.nodeIndent}set alternateNodeIndent(t){this.U.nodeIndent!==t&&(Util.t(t,"number",TreeLayout,"alternateNodeIndent"),t>=0&&(this.U.nodeIndent=t,this.invalidateLayout()))}get alternateNodeIndentPastParent(){return this.U.nodeIndentPastParent}set alternateNodeIndentPastParent(t){this.U.nodeIndentPastParent!==t&&(Util.t(t,"number",TreeLayout,"alternateNodeIndentPastParent"),t>=0&&t<=1&&(this.U.nodeIndentPastParent=t,this.invalidateLayout()))}get alternateNodeSpacing(){return this.U.nodeSpacing}set alternateNodeSpacing(t){this.U.nodeSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateNodeSpacing"),this.U.nodeSpacing=t,this.invalidateLayout())}get alternateLayerSpacing(){return this.U.layerSpacing}set alternateLayerSpacing(t){this.U.layerSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateLayerSpacing"),this.U.layerSpacing=t,this.invalidateLayout())}get alternateLayerSpacingParentOverlap(){return this.U.layerSpacingParentOverlap}set alternateLayerSpacingParentOverlap(t){this.U.layerSpacingParentOverlap!==t&&(Util.t(t,"number",TreeLayout,"alternateLayerSpacingParentOverlap"),t>=0&&t<=1&&(this.U.layerSpacingParentOverlap=t,this.invalidateLayout()))}get alternateCompaction(){return this.U.compaction}set alternateCompaction(t){this.U.compaction!==t&&(Util.tt(t,TreeCompaction,"TreeCompaction"),(t===30||t===31)&&(this.U.compaction=t,this.invalidateLayout()))}get alternateBreadthLimit(){return this.U.breadthLimit}set alternateBreadthLimit(t){this.U.breadthLimit!==t&&(Util.t(t,"number",TreeLayout,"alternateBreadthLimit"),t>=0&&(this.U.breadthLimit=t,this.invalidateLayout()))}get alternateRowSpacing(){return this.U.rowSpacing}set alternateRowSpacing(t){this.U.rowSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateRowSpacing"),this.U.rowSpacing=t,this.invalidateLayout())}get alternateRowIndent(){return this.U.rowIndent}set alternateRowIndent(t){this.U.rowIndent!==t&&(Util.t(t,"number",TreeLayout,"alternateRowIndent"),t>=0&&(this.U.rowIndent=t,this.invalidateLayout()))}get alternateCommentSpacing(){return this.U.commentSpacing}set alternateCommentSpacing(t){this.U.commentSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateCommentSpacing"),this.U.commentSpacing=t,this.invalidateLayout())}get alternateCommentMargin(){return this.U.commentMargin}set alternateCommentMargin(t){this.U.commentMargin!==t&&(Util.t(t,"number",TreeLayout,"alternateCommentMargin"),this.U.commentMargin=t,this.invalidateLayout())}get alternateSetsPortSpot(){return this.U.setsPortSpot}set alternateSetsPortSpot(t){this.U.setsPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"alternateSetsPortSpot"),this.U.setsPortSpot=t,this.invalidateLayout())}get alternatePortSpot(){return this.U.portSpot}set alternatePortSpot(t){Util.s(t,Spot,TreeLayout,"alternatePortSpot"),this.U.portSpot.equals(t)||(this.U.portSpot=t,this.invalidateLayout())}get alternateSetsChildPortSpot(){return this.U.setsChildPortSpot}set alternateSetsChildPortSpot(t){this.U.setsChildPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"alternateSetsChildPortSpot"),this.U.setsChildPortSpot=t,this.invalidateLayout())}get alternateChildPortSpot(){return this.U.childPortSpot}set alternateChildPortSpot(t){Util.s(t,Spot,TreeLayout,"alternateChildPortSpot"),this.U.childPortSpot.equals(t)||(this.U.childPortSpot=t,this.invalidateLayout())}static PathDefault=0;static PathDestination=1;static PathSource=2;static SortingForwards=10;static SortingReverse=11;static SortingAscending=12;static SortingDescending=13;static AlignmentCenterSubtrees=20;static AlignmentCenterChildren=21;static AlignmentStart=22;static AlignmentEnd=23;static AlignmentBus=24;static AlignmentBusBranching=25;static AlignmentTopLeftBus=26;static AlignmentBottomRightBus=27;static CompactionNone=30;static CompactionBlock=31;static StyleLayered=40;static StyleLastParents=41;static StyleAlternating=42;static StyleRootOnly=43;static ArrangementVertical=50;static ArrangementHorizontal=51;static ArrangementFixedRoots=52;static LayerIndividual=60;static LayerSiblings=61;static LayerUniform=62}class TreeNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new TreeVertex(this)}createEdge(){return new TreeEdge(this)}}class TreeVertex extends LayoutVertex{X;kt;rt;Sk;Mk;Pk;Nk;Ck;Ak;Lk;Be;RD;ou;ru;Xg;Yg;ke;Se;jt;ai;ew;sw;nw;As;ow;rw;lw;hw;aw;fw;cw;uw;dw;gw;mw;constructor(t){super(t),this.Sk=!1,this.Mk=null,this.Pk=[],this.Nk=0,this.Ck=0,this.Ak=0,this.Lk=0,this.Be=null,this.X=new Point(0,0),this.kt=new Size(0,0),this.rt=new Point(0,0),this.RD=!1,this.ou=!1,this.ru=!1,this.Xg=null,this.Yg=null,this.ke=10,this.Se=LayoutVertex.standardComparer,this.jt=0,this.ai=21,this.ew=0,this.sw=0,this.nw=20,this.As=50,this.ow=0,this.rw=31,this.lw=0,this.hw=25,this.aw=10,this.fw=10,this.cw=20,this.uw=!0,this.dw=Spot.Default,this.gw=!0,this.mw=Spot.Default}copyInheritedPropertiesFrom(t){t!==null&&(this.ke=t.sorting,this.Se=t.comparer,this.jt=t.angle,this.ai=t.alignment,this.ew=t.nodeIndent,this.sw=t.nodeIndentPastParent,this.nw=t.nodeSpacing,this.As=t.layerSpacing,this.ow=t.layerSpacingParentOverlap,this.rw=t.compaction,this.lw=t.breadthLimit,this.hw=t.rowSpacing,this.aw=t.rowIndent,this.fw=t.commentSpacing,this.cw=t.commentMargin,this.uw=t.setsPortSpot,this.dw=t.portSpot,this.gw=t.setsChildPortSpot,this.mw=t.childPortSpot)}get initialized(){return this.Sk}set initialized(t){this.Sk!==t&&(Util.t(t,"boolean",TreeVertex,"initialized"),this.Sk=t)}get parent(){return this.Mk}set parent(t){this.Mk!==t&&(Debug&&t!==null&&Util.s(t,TreeVertex,TreeVertex,"parent"),this.Mk=t)}get children(){return this.Pk}set children(t){if(this.Pk!==t){if(t!==null&&!Array.isArray(t)&&Util.Vi(t,"Array",TreeVertex,"children:value"),t!==null){const i=t.length;for(let e=0;e4;)t.removePoint(2);u=t.getPoint(1),d=t.getPoint(2)}else{for(c=1;t.pointsCount>3;)t.removePoint(1);u=t.getPoint(0),d=t.getPoint(t.pointsCount-1)}const m=t.getPoint(t.pointsCount-1);let g=0;r===0?(e.alignment===23?(g=o.bottom+n.y,n.y===0&&u.y>m.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.xm.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.x{const i=t.matches?"dark":"light";i!==this.Kg&&(this.Kg=i,this.Fk==="system"&&this.pw())};constructor(t){t&&Object.assign(this,t),t?.themeMap||(this.hu.set("light",{colors:{...Themes.Light.colors},fonts:{...Themes.Light.fonts},numbers:{...Themes.Light.numbers},margins:{...Themes.Light.margins},arrowheads:{...Themes.Light.arrowheads}}),this.hu.set("dark",{colors:{...Themes.Dark.colors},fonts:{...Themes.Dark.fonts},numbers:{...Themes.Dark.numbers},margins:{...Themes.Dark.margins},arrowheads:{...Themes.Dark.arrowheads}})),root.matchMedia&&(this.Kg=root.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}get themeMap(){return this.hu}set themeMap(t){this.hu!==t&&(this.hu=t,this.pw())}get defaultTheme(){return this.Dk}set defaultTheme(t){this.Dk!==t&&(Util.t(t,"string",ThemeManager,"defaultTheme"),this.Dk=t,this.pw())}get currentTheme(){return this.Fk}set currentTheme(t){this.Fk!==t&&(Util.t(t,"string",ThemeManager,"currentTheme"),this.Fk=t,this.pw())}get changesDivBackground(){return this.Rk}set changesDivBackground(t){if(this.Rk!==t&&(this.Rk=t,t))for(const e of this.ls)e.setDivBackground(this.findValue("div","","fill")),e.V("ThemeChanged",this)}get preferredColorScheme(){return this.Kg}addDiagram(t){return this.ls.add(t),this.eC(t),this}removeDiagram(t){return this.ls.delete(t),this.eC(t),this}vF(){this.ls.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.addEventListener("change",this.ID)}JF(){this.ls.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.removeEventListener("change",this.ID)}set(t,i){t===""&&(t=this.Dk),t==="system"&&(t=this.Kg);let e=this.hu.get(t);return e?e=this.OD(e,i):e=i,this.hu.set(t,e),this.pw(),this}findValue(t,i,e){return this.getValue(this.findTheme(this.currentTheme),t,i,e)||this.getValue(this.findTheme(this.defaultTheme),t,i,e)}getValue(t,i,e,s){if(!t)return;e==null&&(e="");let n=t;const o=l=>{if(n===void 0||l==="")return;if(typeof l=="number"||!(Array.isArray(l)||l.includes(".")))return n[l];const h=Array.isArray(l)?l:l.split(".");for(let a=0;a{if(!(e!==""&&(n=o(e),n===void 0)))return Array.isArray(n)&&typeof i=="number"?n=n[i%n.length]:n=o(i),n};if(n=r(),n===void 0&&typeof s=="string"&&s.length>0){let l=t.targetPropertyMap?.get(s);if(l?n=t[l]:(l=ThemeManager._3.get(s),n=l?t[l]:t.colors),n=r(),n!==void 0)return n}return n}findTheme(t){return this.themeMap.get(t==="system"?this.Kg:t)}eC(t){const i=t.skipsUndoManager;t.skipsUndoManager=!0,t.updateAllThemeBindings(),this.Rk&&t.setDivBackground(this.findValue("div","","fill")),t.skipsUndoManager=i,t.V("ThemeChanged",this)}pw(){for(const t of this.ls)this.eC(t)}OD(t,i){for(const e in i)if(Util.yw(i,e))try{i[e].constructor===Object?t[e]=this.OD(t[e]??{},i[e]):t[e]=i[e]}catch{delete t[e]}return t}static _3=new Map([["background","colors"],["defaultColumnSeparatorStroke","colors"],["defaultRowSeparatorStroke","colors"],["shadowColor","colors"],["fill","colors"],["stroke","colors"],["font","fonts"],["angle","numbers"],["fromEndSegmentLength","numbers"],["fromShortLength","numbers"],["height","numbers"],["opacity","numbers"],["scale","numbers"],["toEndSegmentLength","numbers"],["toShortLength","numbers"],["width","numbers"],["defaultColumnSeparatorStrokeWidth","numbers"],["defaultRowSeparatorStrokeWidth","numbers"],["shadowBlur","numbers"],["corner","numbers"],["curviness","numbers"],["smoothness","numbers"],["parameter1","numbers"],["parameter2","numbers"],["strokeWidth","numbers"],["strokeDashOffset","numbers"],["maxLines","numbers"],["spacingAbove","numbers"],["spacingBelow","numbers"],["position","points"],["shadowOffset","points"],["desiredSize","sizes"],["maxSize","sizes"],["minSize","sizes"],["margin","margins"],["defaultSeparatorPadding","margins"],["padding","margins"],["alignment","spots"],["alignmentFocus","spots"],["fromSpot","spots"],["toSpot","spots"],["defaultAlignment","spots"],["spot1","spots"],["spot2","spots"],["verticalAlignment","spots"],["imageAlignment","spots"],["fromArrow","arrowheads"],["toArrow","arrowheads"]])}class Router{Tt;b;Xi;pl;constructor(){this.b=Diagram.Mm(),this.Tt="",this.Xi=!0,this.pl=!0}get name(){return this.Tt}set name(t){this.Tt=t}get isEnabled(){return this.Xi}set isEnabled(t){this.Xi=t}get isRealtime(){return this.pl}set isRealtime(t){this.pl=t}get diagram(){return this.b}set diagram(t){this.b!==t&&(this.b=t,t.Pl=!0,t.requestUpdate())}invalidateRouter(){this.b!==null&&(this.b.Pl=!0,this.b.requestUpdate())}canRoute(t){if(!this.isEnabled)return!1;const i=this.diagram;return!(i&&(!this.isRealtime&&i.Pu||i.animationManager.isTicking))}routeLinks(t,i){}toString(){return this.name!==""?this.name+" Router":Util.hn(this.constructor)}}class AvoidsNodesRouter extends Router{constructor(t){super(),this.name="AvoidsNodes",t&&Object.assign(this,t)}canRoute(t){return(t instanceof Diagram?t.$m:t.diagram.$m)?super.canRoute(t):!1}routeLinks(t,i){const e=i instanceof Diagram?null:i,s=t.iterator,n=this.diagram.getPositions(!0,e,null);for(;s.next();){const o=s.value;if(!o.isAvoiding||i&&o.containingGroup!==e||o.toNode===null||o.fromNode===null||o.pointsCount<4)continue;o.startRoute();const r=o.pointsCount,l=o.getPoint(1),h=o.getPoint(r-2),a=o.fromNode.actualBounds.copy();a.inflate(Link.za,Link.za),a.unionPoint(o.getPoint(0));const f=o.toNode.actualBounds.copy();f.inflate(Link.za,Link.za),f.unionPoint(o.getPoint(r-1)),this.tE(o,a,f,n)&&this.iE(o,l,o.cN,h,o.uN,a,f,n),o.commitRoute()}}tE(t,i,e,s){const n=t.diagram,o=t.pointsCount;if(n===null||t.fromNode===t.toNode||t.layer.isTemporary||i.containsPoint(t.getPoint(o-1))&&!t.toNode.isMemberOf(t.fromNode)||e.containsPoint(t.getPoint(0))&&!t.fromNode.isMemberOf(t.toNode)||!t.isOrthogonal)return!1;if(t.segmentIndex===17)return!0;const r=t.getPoint(1),l=t.getPoint(o-2),h=t.getPoint(2);if(!s.isUnoccupied(Math.min(r.x,h.x),Math.min(r.y,h.y),Math.abs(r.x-h.x),Math.abs(r.y-h.y)))return!0;for(let f=2;f=PositionArray.qd&&(l.vA(),d.inflate(l.cellWidth*l.KP,l.cellHeight*l.UP),l.mT(i,e,s,n,d,!1),m=l.wo(s.x,s.y)),!l.Cy&&mPositionArray.Ua&&i.wo(g,p)!==u-1&&(i.wo(d-f,m)===u-1?(n=180,g=d-f,p=m):i.wo(d+f,m)===u-1?(n=0,g=d+f,p=m):i.wo(d,m-c)===u-1?(n=270,g=d,p=m-c):i.wo(d,m+c)===u-1&&(n=90,g=d,p=m+c));u>PositionArray.Ua&&i.wo(g,p)===u-1;)d=g,m=p,n===0?g+=f:n===90?p+=c:n===180?g-=f:p-=c,u-=1;if(o?u>PositionArray.Ua&&(n===180||n===0?d=Math.floor(d/f)*f+f/2:(n===90||n===270)&&(m=Math.floor(m/c)*c+c/2)):(d=Math.floor(d/f)*f+f/2,m=Math.floor(m/c)*c+c/2),u>PositionArray.Ua){let y=n,x=d,k=m;if(n===0?(y=90,k+=c):n===90?(y=180,x-=f):n===180?(y=270,k-=c):n===270&&(y=0,x+=f),i.wo(x,k)===u-1)this.sC(t,i,x,k,y,!1);else{let S=d,M=m;n===0?(y=270,M-=c):n===90?(y=0,S+=f):n===180?(y=90,M+=c):n===270&&(y=180,S-=f),i.wo(S,M)===u-1&&this.sC(t,i,S,M,y,!1)}}t.insertPointAt(t.pointsCount-2,d,m)}}ToolManager.prototype.initializeStandardTools=function(){this.ti("Action",new ActionTool,this.mouseDownTools),this.ti("Relinking",new RelinkingTool,this.mouseDownTools),this.ti("LinkReshaping",new LinkReshapingTool,this.mouseDownTools),this.ti("Rotating",new RotatingTool,this.mouseDownTools),this.ti("Resizing",new ResizingTool,this.mouseDownTools),this.ti("Linking",new LinkingTool,this.mouseMoveTools),this.ti("Dragging",new DraggingTool,this.mouseMoveTools),this.ti("DragSelecting",new DragSelectingTool,this.mouseMoveTools),this.ti("Panning",new PanningTool,this.mouseMoveTools),this.ti("ContextMenu",new ContextMenuTool,this.mouseUpTools),this.ti("TextEditing",new TextEditingTool,this.mouseUpTools),this.ti("ClickCreating",new ClickCreatingTool,this.mouseUpTools),this.ti("ClickSelecting",new ClickSelectingTool,this.mouseUpTools)},Diagram.SP("GraphLinksModel",GraphLinksPartManager),Diagram.SP("TreeModel",TreePartManager);const oldGo=root.go,go={get version(){return Diagram.version},Group,List,Set:GSet,Map:GMap,Point,Size,Rect,Margin,Spot,Geometry,PathFigure,PathSegment,InputEvent,DiagramEvent,ChangedEvent,Model,GraphLinksModel,TreeModel,Binding,ThemeBinding,Transaction,UndoManager,CommandHandler,Tool,DraggingTool,DraggingInfo,DraggingOptions,LinkingBaseTool,LinkingTool,RelinkingTool,LinkReshapingTool,ResizingTool,RotatingTool,ClickSelectingTool,ActionTool,ClickCreatingTool,HTMLInfo,ContextMenuTool,DragSelectingTool,PanningTool,TextEditingTool,ToolManager,Animation,AnimationManager,AnimationTrigger,Layer,Diagram,Palette,Overview,Brush,GraphObject,Panel,RowColumnDefinition,Shape,TextBlock,Picture,Part,Adornment,Node,Link,Placeholder,Layout,LayoutNetwork,LayoutVertex,LayoutEdge,GridLayout,PanelLayout,CircularLayout,CircularNetwork,CircularVertex,CircularEdge,ForceDirectedLayout,ForceDirectedNetwork,ForceDirectedVertex,ForceDirectedEdge,LayeredDigraphLayout,LayeredDigraphNetwork,LayeredDigraphVertex,LayeredDigraphEdge,TreeLayout,TreeNetwork,TreeVertex,TreeEdge,Themes,ThemeManager,Router,AnimationStyle,AutoScale,CycleMode,Flip,TextFormat,ImageStretch,LayoutConditions,LinkAdjusting,Curve,Routing,Orientation,TextOverflow,PortSpreading,ScrollMode,CollapsePolicy,Sizing,TriggerStart,Stretch,ViewboxStretch,Wrap,BrushType,ColorSpace,GeometryStretch,GeometryType,SegmentType,BindingMode,ChangeType,CircularArrangement,CircularDirection,CircularNodeDiameterFormula,CircularSorting,GridAlignment,GridArrangement,GridSorting,LayeredDigraphAggressive,LayeredDigraphAlign,LayeredDigraphCycleRemove,LayeredDigraphInit,LayeredDigraphLayering,LayeredDigraphPack,TreeAlignment,TreeArrangement,TreeCompaction,TreeLayerStyle,TreePath,TreeSorting,TreeStyle,GestureMode,LinkingDirection,ReshapingBehavior,TextEditingAccept,TextEditingStarting,TextEditingState,WheelMode};typeof oldGo=="object"&&oldGo.version&&Util.at("WARNING: a `go` object on the root object is already defined. "+("Debug"in oldGo?"debug ":"")+"version: "+oldGo.version+", replaced with version: "+go.version),Diagram.prototype.go=go,root.go=go,go.Debug=Debug,Debug.attachReadonlyWarnings(go); + "removedLinkKeys": `;jT(t){const i=new GSet;for(let e=0;e{if(c.model===s){if(c.modelChange==="linkDataArray")c.change===3?n.add(c.newValue):c.change===4&&r.add(c.oldValue);else if(s.containsLinkData(c.object))o.add(c.object);else if(c.object!==null)if(c.object!==null&&l&&l.has(c.object))l.get(c.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(c.object instanceof Model||s.containsNodeData(c.object))return;s.jT(c.object).each(d=>o.add(d))}}});const h=this.ug;h.clear(),n.each(c=>{h.add(s.getKeyForLinkData(c)),i||o.add(c)});const a=this.cg;a.clear(),r.each(c=>{a.add(s.getKeyForLinkData(c)),i&&o.add(c)});let f=e;return h.count>0&&(f+=(i?this.vT:this.WT)+this.Dh(h.toArray(),!0)),o.count>0&&(f+=this.zO+this.Dh(o.toArray(),!0)),a.count>0&&(f+=(i?this.WT:this.vT)+this.Dh(a.toArray(),!0)),a.clear(),h.clear(),f}By(t){(t.linkCategoryProperty!==void 0&&t.linkCategoryProperty!==this.linkCategoryProperty||t.linkKeyProperty!==void 0&&t.linkKeyProperty!==this.linkKeyProperty||t.linkFromKeyProperty!==void 0&&t.linkFromKeyProperty!==this.linkFromKeyProperty||t.linkToKeyProperty!==void 0&&t.linkToKeyProperty!==this.linkToKeyProperty||t.linkFromPortIdProperty!==void 0&&t.linkFromPortIdProperty!==this.linkFromPortIdProperty||t.linkToPortIdProperty!==void 0&&t.linkToPortIdProperty!==this.linkToPortIdProperty||t.linkLabelKeysProperty!==void 0&&t.linkLabelKeysProperty!==this.linkLabelKeysProperty||t.nodeIsGroupProperty!==void 0&&t.nodeIsGroupProperty!==this.nodeIsGroupProperty||t.nodeGroupKeyProperty!==void 0&&t.nodeGroupKeyProperty!==this.nodeGroupKeyProperty)&&Util.n("applyIncrementalJson cannot change Model properties"),super.By(t);const i=t.insertedLinkKeys;if(Array.isArray(i)){const n=i.length;for(let o=0;o=0&&s.splice(e,1)):s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue));return}}else if(t.change===4){let e=t.oldParam;if(t.modelChange==="linkDataArray"){const s=t.oldValue;if(Util.Mt(s)&&typeof e=="number"){const n=this.getKeyForLinkData(s);i?(this.hr.add(s),this.is[e]!==s&&this.is.splice(e,0,s),n!==void 0&&this.mi.set(n,s)):(this.hr.delete(s),this.is[e]===s&&this.is.splice(e,1),n!==void 0&&this.mi.delete(n))}return}else if(t.modelChange==="linkLabelKeys"){const s=this.getLabelKeysForLinkData(t.object);Array.isArray(s)&&typeof e=="number"&&(i?s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue):(e=s.indexOf(t.newValue),e>=0&&s.splice(e,1)));return}}super.changeState(t,i)}}get archetypeNodeData(){return this.Fl}set archetypeNodeData(t){const i=this.Fl;i!==t&&(t!==null&&Util.t(t,"object",GraphLinksModel,"archetypeNodeData"),this.Fl=t,this.i("archetypeNodeData",i,t))}IN(t){if(t===void 0)return;const i=this.Fl;if(i!==null){let e=this.findNodeDataForKey(t);e===null&&(e=this.copyNodeData(i),Model.ct(e,this.nodeKeyProperty,t),this.addNodeData(e))}return t}get linkFromKeyProperty(){return this.Po}set linkFromKeyProperty(t){const i=this.Po;i!==t&&(this.In(t,GraphLinksModel,"linkFromKeyProperty"),this.Po=t,this.i("linkFromKeyProperty",i,t))}getFromKeyForLinkData(t){return this.Ee(t,!0)}setFromKeyForLinkData(t,i){this.ng(t,i,!0)}get linkToKeyProperty(){return this.No}set linkToKeyProperty(t){const i=this.No;i!==t&&(this.In(t,GraphLinksModel,"linkToKeyProperty"),this.No=t,this.i("linkToKeyProperty",i,t))}getToKeyForLinkData(t){return this.Ee(t,!1)}setToKeyForLinkData(t,i){this.ng(t,i,!1)}Ee(t,i){if(t===null)return;const e=i?this.Po:this.No;if(e==="")return;const s=Model.Xt(t,e);if(s!==void 0){if(this.isKeyType(s))return s;Util.n((i?"FromKey":"ToKey")+" value for link data "+t+" is not a number or a string: "+s)}}ng(t,i,e){if(i===null&&(i=void 0),i!==void 0&&!this.isKeyType(i)&&Util.Bi(i,"number or string",GraphLinksModel,e?"setFromKeyForLinkData:key":"setToKeyForLinkData:key"),t===null)return;const s=e?this.Po:this.No;if(s==="")return;if(i=this.IN(i),!this.containsLinkData(t)){Model.ct(t,s,i);return}const n=Model.Xt(t,s);n!==i&&(this.tn(n,t),Model.ct(t,s,i),this.findNodeDataForKey(i)===null&&this.en(i,t),this.Kt(e?"linkFromKey":"linkToKey",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkFromPortIdProperty(){return this.Ja}set linkFromPortIdProperty(t){const i=this.Ja;i!==t&&(this.In(t,GraphLinksModel,"linkFromPortIdProperty"),Debug&&(t===this.linkFromKeyProperty||t===this.linkToKeyProperty)&&Util.n("linkFromPortIdProperty name must not be the same as the GraphLinksModel.linkFromKeyProperty or linkToKeyProperty: "+t),this.Ja=t,this.i("linkFromPortIdProperty",i,t))}getFromPortIdForLinkData(t){return this.Eb(t,!0)}setFromPortIdForLinkData(t,i){this.og(t,i,!0)}get linkToPortIdProperty(){return this.Za}set linkToPortIdProperty(t){const i=this.Za;i!==t&&(this.In(t,GraphLinksModel,"linkToPortIdProperty"),Debug&&(t===this.linkFromKeyProperty||t===this.linkToKeyProperty)&&Util.n("linkFromPortIdProperty name must not be the same as the GraphLinksModel.linkFromKeyProperty or linkToKeyProperty: "+t),this.Za=t,this.i("linkToPortIdProperty",i,t))}getToPortIdForLinkData(t){return this.Eb(t,!1)}setToPortIdForLinkData(t,i){this.og(t,i,!1)}Eb(t,i){if(t===null)return"";const e=i?this.Ja:this.Za;if(e==="")return"";const s=Model.Xt(t,e);return s===void 0?"":s}og(t,i,e){if(Util.t(i,"string",GraphLinksModel,e?"setFromPortIdForLinkData:portname":"setToPortIdForLinkData:portname"),t===null)return;const s=e?this.Ja:this.Za;if(s==="")return;if(!this.containsLinkData(t)){Model.ct(t,s,i);return}let n=Model.Xt(t,s);n===void 0&&(n=""),n!==i&&(Model.ct(t,s,i),this.Kt(e?"linkFromPortId":"linkToPortId",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkLabelKeysProperty(){return this.sn}set linkLabelKeysProperty(t){const i=this.sn;i!==t&&(this.In(t,GraphLinksModel,"linkLabelKeysProperty"),this.sn=t,this.i("linkLabelKeysProperty",i,t))}getLabelKeysForLinkData(t){if(t===null)return GraphLinksModel.EmptyArray;const i=this.sn;if(i==="")return GraphLinksModel.EmptyArray;const e=Model.Xt(t,i);return e===void 0?GraphLinksModel.EmptyArray:e}setLabelKeysForLinkData(t,i){if(Util.Ug(i,GraphLinksModel,"setLabelKeysForLinkData:arr"),t===null)return;const e=this.sn;if(e==="")return;if(!this.containsLinkData(t)){Model.ct(t,e,i);return}let s=Model.Xt(t,e);if(s===void 0&&(s=GraphLinksModel.EmptyArray),s!==i){if(Array.isArray(s)){const o=s.length;for(let r=0;r=0)return;n=s.length,s.push(i),this.containsLinkData(t)&&(this.findNodeDataForKey(i)===null&&this.en(i,t),this.Kt("linkLabelKeys",3,e,t,null,i,null,n))}else Util.n(e+" property is not an Array; cannot addLabelKeyForLinkData: "+t)}removeLabelKeyForLinkData(t,i){if(i==null||(this.isKeyType(i)||Util.Bi(i,"number or string",GraphLinksModel,"removeLabelKeyForLinkData:key"),t===null))return;const e=this.sn;if(e==="")return;const s=Model.Xt(t,e);if(Array.isArray(s)){const n=s.indexOf(i);if(n<0)return;s.splice(n,1),this.containsLinkData(t)&&(this.tn(i,t),this.Kt("linkLabelKeys",4,e,t,i,null,n,null))}else s!==void 0&&Util.n(e+" property is not an Array; cannot removeLabelKeyforLinkData: "+t)}get linkDataArray(){return this.is}set linkDataArray(t){const i=this.is;if(i!==t){Util.Ug(t,GraphLinksModel,"linkDataArray"),this.mi.clear();const e=t.length;for(let n=0;nnew GraphLinksModel,Model.initDiagramModel=Model.initDiagramModel=()=>new GraphLinksModel;class TreeModel extends Model{En;xg;Qa;constructor(t,i){if(super(),this.En="parent",this.xg=!1,this.Qa="parentLinkCategory",t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){super.cloneProtected(t),t.En=this.En,t.xg=this.xg,t.Qa=this.Qa}toString(t){if(t===void 0&&(t=0),t>=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" TreeModel";if(t>0){i+=` + node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n(w[w.ConstantSpacing=0]="ConstantSpacing",w[w.ConstantDistance=1]="ConstantDistance",w[w.ConstantAngle=2]="ConstantAngle",w[w.Packed=3]="Packed",w))(CircularArrangement||{}),CircularDirection=(w=>(w[w.Clockwise=10]="Clockwise",w[w.Counterclockwise=11]="Counterclockwise",w[w.BidirectionalLeft=12]="BidirectionalLeft",w[w.BidirectionalRight=13]="BidirectionalRight",w))(CircularDirection||{}),CircularSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w[w.Optimized=24]="Optimized",w))(CircularSorting||{}),CircularNodeDiameterFormula=(w=>(w[w.Pythagorean=30]="Pythagorean",w[w.Circular=31]="Circular",w))(CircularNodeDiameterFormula||{});class CircularLayout extends Layout{ue;Kc;qb;bg;jb;Rh;BN;VN;zN;Ns;Xy;Yy;_a;Ky;ZT;kg;Sg;Mg;Uc;qi;C;ke;Se;Rn;Pg;constructor(t){super(),this.ue=0,this.Kc=0,this.qb=0,this.bg=360,this.jb=0,this.Rh=0,this.BN=new Point,this.VN=30,this.zN=0,this.Ns=0,this.Xy=0,this.Yy=new VertexArrangement,this._a=0,this.Ky=0,this.ZT=600,this.kg=NaN,this.Sg=1,this.Mg=0,this.Uc=360,this.qi=0,this.C=10,this.ke=24,this.Se=LayoutVertex.standardComparer,this.Rn=6,this.Pg=30,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.kg=this.kg,t.Sg=this.Sg,t.Mg=this.Mg,t.Uc=this.Uc,t.qi=this.qi,t.C=this.C,t.ke=this.ke,t.Se=this.Se,t.Rn=this.Rn,t.Pg=this.Pg}fi(t){t in CircularSorting?this.sorting=t:t in CircularDirection?this.direction=t:t in CircularArrangement?this.arrangement=t:t in CircularNodeDiameterFormula?this.nodeDiameterFormula=t:super.fi(t)}createNetwork(){return new CircularNetwork(this)}KO(t,i,e){t=this.UO(t);let s=this.jb,n=this.VN,o=this.ue,r=this.Kc,l=this.qb,h=this.bg,a=this.Rh,f=this.zN,c=this.Ns,u=this.Xy;if(s=this.arrangement,n=this.nodeDiameterFormula,o=this.radius,(!isFinite(o)||o<=0)&&(o=NaN),r=this.aspectRatio,(!isFinite(r)||r<=0)&&(r=1),l=this.startAngle,isFinite(l)||(l=0),h=this.sweepAngle,(!isFinite(h)||h>360||h<1)&&(h=360),a=this.spacing,isFinite(a)||(a=NaN),s===3&&n===31?s=0:s===3&&n!==31&&(n=31,s=this.arrangement),(this.direction===12||this.direction===13)&&this.sorting!==24){for(let g=0;!(g>=t.length||(i.add(t.elt(g)),g+1>=t.length));g+=2)e.add(t.elt(g+1));this.direction===12?(this.arrangement===3&&i.reverse(),t=new List,t.addAll(i),t.addAll(e)):(this.arrangement===3&&e.reverse(),t=new List,t.addAll(e),t.addAll(i))}const d=t.length;f=0;let m=0;for(let g=0;g1?(o=y,c=o*r):(c=y,o=c)}else o=this.Wb(u*(h>=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180)}else o=this.Wb(f+(h>=360?d:d-1)*(s!==3?a:a*1.6),r,l*Math.PI/180,h*Math.PI/180);c=o*r}else{c=o*r;const g=this.XN(o,c,l*Math.PI/180,h*Math.PI/180);if(isNaN(a))s===0&&(a=(g-f)/(h>=360?d:d-1));else if(s===0){const p=(g-f)/(h>=360?d:d-1);p=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180),c=o*r):a=p}else{let p=-1/0;for(let k=0;k=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180);x>o?(o=x,c=o*r,u=y):u=g/(h>=360?d:d-1)}}return this.jb=s,this.VN=n,this.ue=o,this.Kc=r,this.qb=l,this.bg=h,this.Rh=a,this.zN=f,this.Ns=c,this.Xy=u,t}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.network.vertexes;if(i.count<=1){if(i.count===1){const u=i.first();u.centerX=0,u.centerY=0}this.updateParts(),this.network=null,this.isValidLayout=!0;return}let e=new List;e.addAll(i.iterator);const s=new List,n=new List;e=this.KO(e,s,n);const o=this.jb,r=this.ue,l=this.qb,h=this.bg,a=this.Rh,f=this.Ns,c=this.Xy;if((this.direction===12||this.direction===13)&&o===3)this.$T(e,h,l-h/2,10);else if(this.direction===12||this.direction===13){let u=0;switch(o){case 1:u=this.vb(r,f,l,c)*180/Math.PI;break;case 0:{let d=0,m=0;const g=s.first();g!==null&&(d=g.Ih(Math.PI/2));const p=n.first();p!==null&&(m=p.Ih(Math.PI/2)),u=this.vb(r,f,l,a+(d+m)/2)*180/Math.PI;break}case 2:u=h/e.length;break}if(this.direction===12){switch(o){case 1:this.Uy(s,h/2,l,11);break;case 0:this.Gy(s,h/2,l,11);break;case 2:this.Hy(s,h/2,l,11);break}switch(o){case 1:this.Uy(n,h/2,l+u,10);break;case 0:this.Gy(n,h/2,l+u,10);break;case 2:this.Hy(n,h/2,l+u,10);break}}else{switch(o){case 1:this.Uy(n,h/2,l,11);break;case 0:this.Gy(n,h/2,l,11);break;case 2:this.Hy(n,h/2,l,11);break}switch(o){case 1:this.Uy(s,h/2,l+u,10);break;case 0:this.Gy(s,h/2,l+u,10);break;case 2:this.Hy(s,h/2,l+u,10);break}}}else switch(o){case 1:this.Uy(e,h,l,this.direction);break;case 0:this.Gy(e,h,l,this.direction);break;case 2:this.Hy(e,h,l,this.direction);break;case 3:this.$T(e,h,l,this.direction);break}this.updateParts(),this.network=null,this.isValidLayout=!0}Hy(t,i,e,s){const n=this.bg,o=this.ue,r=this.Ns,l=e*Math.PI/180,h=i*Math.PI/180,a=t.length;for(let f=0;f=360?a:a-1):-(f*h)/a),u=t.elt(f),d=o*Math.tan(c)/r,m=Math.sqrt((o*o+r*r*d*d)/(1+d*d));u.centerX=m*Math.cos(c),u.centerY=m*Math.sin(c),u.actualAngle=c*180/Math.PI}}Gy(t,i,e,s){const n=this.ue,o=this.Ns,r=this.Rh;let l=e*Math.PI/180;const h=t.length;for(let a=0;a180&&(n-=360),n*=Math.PI/180,this.Ky=n,this.QT(t,i,e,s)}else this._T(t,i,e,s);this.Yy.commit(t)}_T(t,i,e,s){const n=this.ue,o=this.Ns,r=this.Rh,l=this.Kc;let h=n*Math.cos(e*Math.PI/180),a=o*Math.sin(e*Math.PI/180);const f=t.toArray();if(f.length===3){f[0].centerX=n,f[0].centerY=0,f[1].centerX=f[0].centerX-f[0].width/2-f[1].width/2-r,f[1].y=f[0].y,f[2].centerX=(f[0].centerX+f[1].centerX)/2,f[2].y=f[0].y-f[2].height-r;return}else if(f.length===4){f[0].centerX=n,f[0].centerY=0,f[2].centerX=-f[0].centerX,f[2].centerY=f[0].centerY,f[1].centerX=0,f[1].y=Math.min(f[0].y,f[2].y)-f[1].height-r,f[3].centerX=0,f[3].y=Math.max(f[0].y+f[0].height+r,f[2].y+f[2].height+r);return}const c=Point.a();for(let b=0;b=f.length-1));b++)this.tD(h,a,f,b,s,c)||this.iD(h,a,f,b,s,c),h=c.x,a=c.y;if(Point.o(c),this._a++,this._a>23)return;const u=f[0].centerX,d=f[0].centerY,m=f[f.length-1].centerX,g=f[f.length-1].centerY;let p=Math.abs(u-m)-((f[0].width+f[f.length-1].width)/2+r);const y=Math.abs(d-g)-((f[0].height+f[f.length-1].height)/2+r);let x=0;if(Math.abs(y)<1){const b=Math.abs(u-m),S=(f[0].width+f[f.length-1].width)/2;b0?x=y:Math.abs(p)<1?x=0:x=p;let k=!1;Math.abs(m)>Math.abs(g)?k=m>0!=d>g:k=g>0!=u1&&(this._a<8?this.ue-=x/(2*Math.PI):f.length<5&&x>10?this.ue/=2:this.ue-=x>0?1.7:-2.3,this.Ns=this.ue*l,this._T(t,i,e,s))}QT(t,i,e,s){const n=this.ue,o=this.Ns,r=this.Kc;let l=n*Math.cos(e*Math.PI/180),h=o*Math.sin(e*Math.PI/180);const a=Point.a(),f=t.toArray();for(let m=0;m=f.length-1));m++)this.tD(l,h,f,m,s,a)||this.iD(l,h,f,m,s,a),l=a.x,h=a.y;if(Point.o(a),this._a++,this._a>23)return;const c=Math.atan2(h,l);let u=s===10?this.Ky-c:c-this.Ky;u=Math.abs(u)1&&(this._a<8?this.ue-=d/(2*Math.PI):this.ue-=d>0?1.7:-2.3,this.Ns=this.ue*r,this.QT(t,i,e,s))}tD(t,i,e,s,n,o){const r=this.Rh,l=this.ue,h=this.Ns;let a=0,f=0;const c=(e[s].width+e[s+1].width)/2+r;let u=!1;if(i>=0!=(n===10)){if(a=t+c,a>l){if(a=t-c,a<-l)return o.x=a,o.y=f,!1;u=!0}}else if(a=t-c,a<-l){if(a=t+c,a>l)return o.x=a,o.y=f,!1;u=!0}return f=Math.sqrt(1-Math.min(1,a*a/(l*l)))*h,i<0!==u&&(f=-f),Math.abs(i-f)>(e[s].height+e[s+1].height)/2?(o.x=a,o.y=f,!1):(o.x=a,o.y=f,!0)}iD(t,i,e,s,n,o){const r=this.Rh,l=this.ue,h=this.Ns;let a=0,f=0;const c=(e[s].height+e[s+1].height)/2+r;let u=!1;if(t>=0!=(n===10)){if(f=i-c,f<-h){if(f=i+c,f>h)return o.x=a,o.y=f,!1;u=!0}}else if(f=i+c,f>h){if(f=i-c,f<-h)return o.x=a,o.y=f,!1;u=!0}return a=Math.sqrt(1-Math.min(1,f*f/(h*h)))*l,t<0!==u&&(a=-a),Math.abs(t-a)>(e[s].width+e[s+1].width)/2?(o.x=a,o.y=f,!1):(o.x=a,o.y=f,!0)}commitLayout(){this.commitNodes(),this.isRouting&&this.commitLinks()}commitNodes(){const t=this.group!==null&&this.group.hasPlaceholder(),i=t?this.group.location.copy():null;let e=this.actualCenter;t?e=new Point(0,0):(e.x=this.arrangementOrigin.x+this.ue,e.y=this.arrangementOrigin.y+this.Ns);const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;n.x+=e.x,n.y+=e.y,n.commit()}if(t){this.group.ensureBounds();const n=this.group.position.copy(),o=this.group.location.copy(),r=i.subtract(o.subtract(n));this.group.move(r),this.BN=r.subtract(n)}}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}XN(t,i,e,s){const n=this.ZT;if(Math.abs(this.Kc-1)<.001)return e!==void 0&&s!==void 0?s*t:2*Math.PI*t;const o=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let r=0,l=0;e!==void 0&&s!==void 0?l=s/(n+1):l=Math.PI/(2*(n+1));let h=0;for(let a=0;a<=n;a++){e!==void 0&&s!==void 0?h=e+a*s/n:h=a*Math.PI/(2*n);const f=Math.sin(h);r+=Math.sqrt(1-o*o*f*f)*l}return e!==void 0&&s!==void 0?(t>i?t:i)*r:4*(t>i?t:i)*r}Wb(t,i,e,s){let n=0;return e!==void 0&&s!==void 0?n=this.XN(1,i,e,s):n=this.XN(1,i),t/n}vb(t,i,e,s){if(Math.abs(this.Kc-1)<.001)return s/t;const n=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let o=0;const r=2*Math.PI/(this.network.vertexes.count*700);t>i&&(e+=Math.PI/2);for(let l=0;;l++){const h=e+l*r,a=Math.sin(h);if(o+=(t>i?t:i)*Math.sqrt(1-n*n*a*a)*r,o>=s)return l*r}}UO(t){switch(this.sorting){case 20:break;case 21:t.reverse();break;case 22:t.sort(this.comparer);break;case 23:t.sort(this.comparer),t.reverse();break;case 24:return this.qO(this.jO(t));default:Util.n("Invalid sorting type.")}return t}jO(t){const i=[];for(let s=0;sn&&(n=u,o=f)}else for(let f=0;fn&&(n=c,o=f)}e.add(t.elt(o)),i[o]=-1;const r=t.elt(o);let l=0;const h=r.sourceEdges;for(;h.next();){const c=h.value.fromVertex;l=t.indexOf(c),!(l<0)&&i[l]>=0&&i[l]++}const a=r.destinationEdges;for(;a.next();){const c=a.value.toVertex;l=t.indexOf(c),!(l<0)&&i[l]>=0&&i[l]++}}return e}qO(t){const i=[];for(let c=0;c=0){const C=Math.abs(x-(A>=x?A+1:A));b+=C=x&&M++,A>=x&&A++,M>A){const C=A;A=M,M=C}A-M<(s.length+2)/2==(M=0&&(n.push(c),o.push(x))}h++}let a=!1;const f=s.length;for(;;){a=!0;for(let c=0;c=0){let g=0;for(let p=0;pm?x-m:m-x,b=f-k;g+=xb?1:-1}s.splice(g<0?m:m+1,0,u),r.splice(c,1),c--}else a=!1}if(a)break;s.push(r[0]),r.splice(0,1)}for(let c=0;c0||isNaN(t))&&(this.kg=t,this.invalidateLayout()))}get aspectRatio(){return this.Sg}set aspectRatio(t){this.Sg!==t&&(Util.t(t,"number",CircularLayout,"aspectRatio"),t>0&&(this.Sg=t,this.invalidateLayout()))}get startAngle(){return this.Mg}set startAngle(t){this.Mg!==t&&(Util.t(t,"number",CircularLayout,"startAngle"),this.Mg=t,this.invalidateLayout())}get sweepAngle(){return this.Uc}set sweepAngle(t){this.Uc!==t&&(Util.t(t,"number",CircularLayout,"sweepAngle"),t>0&&t<=360?this.Uc=t:this.Uc=360,this.invalidateLayout())}get arrangement(){return this.qi}set arrangement(t){this.qi!==t&&(Util.tt(t,CircularArrangement,"CircularArrangement"),(t===3||t===0||t===1||t===2)&&(this.qi=t,this.invalidateLayout()))}get direction(){return this.C}set direction(t){this.C!==t&&(Util.tt(t,CircularDirection,"CircularDirection"),(t===10||t===11||t===12||t===13)&&(this.C=t,this.invalidateLayout()))}get sorting(){return this.ke}set sorting(t){this.ke!==t&&(Util.tt(t,CircularSorting,"CircularSorting"),this.ke=t,this.invalidateLayout())}get comparer(){return this.Se}set comparer(t){this.Se!==t&&(Util.t(t,"function",CircularLayout,"comparer"),this.Se=t,this.invalidateLayout())}get spacing(){return this.Rn}set spacing(t){this.Rn!==t&&(Util.t(t,"number",CircularLayout,"spacing"),this.Rn=t,this.invalidateLayout())}get nodeDiameterFormula(){return this.Pg}set nodeDiameterFormula(t){this.Pg!==t&&(Util.tt(t,CircularNodeDiameterFormula,"CircularNodeDiameterFormula"),(t===30||t===31)&&(this.Pg=t,this.invalidateLayout()))}get actualXRadius(){return this.ue}get actualYRadius(){return this.Ns}get actualSpacing(){return this.Rh}get actualCenter(){return this.BN}static ConstantSpacing=0;static ConstantDistance=1;static ConstantAngle=2;static Packed=3;static Clockwise=10;static Counterclockwise=11;static BidirectionalLeft=12;static BidirectionalRight=13;static Forwards=20;static Reverse=21;static Ascending=22;static Descending=23;static Optimized=24;static Pythagorean=30;static Circular=31}class VertexArrangement{Gc;tf;Hc;constructor(){this.Gc=-1/0,this.tf=null,this.Hc=null}GO(t,i){if(t>0&&this.Gc<0||Math.abs(t)0)){this.Gc=t,this.tf=[],this.Hc=[];for(let e=0;e0){for(this.network.deleteSelfEdges(),i=this.network.vertexes.iterator;i.next();){const o=i.value;o.charge=this.electricalCharge(o),o.mass=this.gravitationalMass(o)}const s=this.network.edges.iterator;for(;s.next();){const o=s.value;o.stiffness=this.springStiffness(o),o.length=this.springLength(o)}if(this.YN(),this.Oh=0,this.needsPrelayout()){const o=this.network,r=o.splitIntoSubNetworks(!1);let l=r.iterator;for(;l.next();){const h=l.value;this.doConnectedSubnetLayout(h)}for(l=r.iterator,this.vO(l,o),l=r.iterator;l.next();){const h=l.value,a=h.vertexes.iterator;for(;a.next();){const c=a.value;o.addVertex(c)}const f=h.edges.iterator;for(;f.next();){const c=f.value;o.addEdge(c)}}}else this.eD(this.network,this.maxIterations);this.updateParts()}this.maxIterations=e,this.isValidLayout=!0}needsPrelayout(){if(this.network.vertexes.count<3)return!1;let t=0,i=0;const e=this.network.vertexes.first().bounds,s=this.network.vertexes.iterator;for(;s.next();){const n=s.value,o=n.bounds;if(isNaN(n.x)||isNaN(n.y)||o.intersectsRect(e)&&(t++,t>2))return!0;if(i>10)return!1;i++}return!1}doConnectedSubnetLayout(t){let i=t.vertexes.iterator;for(;i.next();){const l=i.value;l.hierarchicalVertexes.add(l)}let e=t,s=this.Zc;if(isNaN(s)&&(s=t.edges.count/t.vertexes.count),sMath.max(100,Math.sqrt(s*t.vertexes.count));)e=this.coarsenNetwork(e);let n=0;i=e.vertexes.iterator;let o=this.randomNumberGenerator;for(o===null&&(this.randomNumberGenerator=o=new RandomNumberGenerator(0));i.next();){i.value.idInCluster=n++;const l=10*(o.random()-.5),h=10*(o.random()-.5);this.isFixed(i.value)||(i.value.x=l,i.value.y=h);const a=i.value.hierarchicalVertexes.iterator;for(;a.next();)this.isFixed(a.value)||(a.value.x=l,a.value.y=h)}const r=this.computePairwiseDistances(e);this.JO(e,r,this.maxPrelayoutIterations,t.vertexes.count),this.eD(t,this.maxIterations)}computePairwiseDistances(t){const i=t.vertexes.count,e=new Array(i);for(let r=0;r0;){const l=o.shift(),h=l.vertexes.iterator;for(;h.next();){const a=h.value;n.has(a.idInCluster)||(n.set(a.idInCluster,n.get(l.idInCluster)+1),o.push(a))}}for(let l=0;l=0;m--)if(t[m].y>f.y&&t[m].x-f.xf.x&&t[m].y-f.ya+c){const u=s+o-h,d=n-a-c;return Geo.Aw(u*u+d*d)}else if(n+rh+f)if(n>a+c){const u=s-h-f,d=n-a-c;return Geo.Aw(u*u+d*d)}else if(n+ra+c?n-(a+c):n+rr-o;l?i.sort((m,g)=>m===null||g===null||m===g?0:m.centerX-g.centerX):i.sort((m,g)=>m===null||g===null||m===g?0:m.centerY-g.centerY);const h=this.qc;let a=0,f=0,c=0;for(let m=0;mh||C-x>h){if(l)break;continue}if(k-P>h||P-k>h){if(!l)break;continue}const N=this.KN(g,S),T=2*g.charge,L=2*S.charge;if(N>1)a=T*L/(N*N),f=a*(x-C)/N,c=a*(k-P)/N;else{let D=this.randomNumberGenerator;D===null&&(this.randomNumberGenerator=D=new RandomNumberGenerator(0));const F=D.random(),R=D.random();if(x>C)f=Math.abs(S.bounds.right-g.bounds.x),f=T*L*(1+f)*F;else if(xP)c=Math.abs(S.bounds.bottom-g.bounds.y),c=T*L*(1+c)*R;else if(x1&&(a=.1*m.stiffness*(P-m.length),f=a*.5*(g.width+p.height)*(k-A)/P,c=a*.5*(g.width+p.height)*(b-C)/P),g.forceX-=f,g.forceY-=c,p.forceX+=f,p.forceY+=c}let d=0;for(let m=0;mthis.epsilonDistance*this.epsilonDistance}JO(t,i,e,s){Debug&&Util.r(e,ForceDirectedLayout,"performIterations:num");const n=this.Oh+e,o=Math.sqrt(s);this.qy=this.ef*t.vertexes.count;const r=t.vertexes.toArray();let l=0,h=0,a=0;for(;this.Oh0){r[f].forceX=this.qy*r[f].forceX/c,r[f].forceY=this.qy*r[f].forceY/c,this.isFixed(r[f])||(r[f].x+=r[f].forceX,r[f].y+=r[f].forceY);const u=r[f].hierarchicalVertexes.iterator;for(;u.next();){const d=u.value;this.isFixed(d)||(d.centerX+=r[f].forceX,d.centerY+=r[f].forceY)}}l+=c*c}if(l>=h){if(a++,a>=5)break}else a=0;this.qy*=.95}}moveVertex(t){let i=t.forceX,e=t.forceY;const s=this.moveLimit;return i<-s?i=-s:i>s&&(i=s),e<-s?e=-s:e>s&&(e=s),t.centerX+=i,t.centerY+=e,i*i+e*e}shouldInteract(t,i){return!0}moveFixedVertex(t){}commitLayout(){this.jy(),this.commitNodes(),this.isRouting&&this.commitLinks()}jy(){if(!this.setsPortSpots)return;const t=this.network.edges.iterator;for(;t.next();){const e=t.value.link;e!==null&&(e.fromSpot=Spot.Default,e.toSpot=Spot.Default)}}commitNodes(){let t=0,i=0;if(this.arrangesToOrigin){const n=Rect.a();this.Rw(this.network,n);const o=this.arrangementOrigin;t=o.x-n.x,i=o.y-n.y,Rect.o(n)}const e=Rect.a(),s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;(t!==0||i!==0)&&(e.c(n.bounds),e.x+=t,e.y+=i,n.bounds=e),n.commit()}Rect.o(e)}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}springStiffness(t){const i=t.stiffness;return isNaN(i)?this.jc:i}springLength(t){const i=t.length;return isNaN(i)?this.Wc:i}electricalCharge(t){const i=t.charge;return isNaN(i)?this.vc:i}electricalFieldX(t,i){return 0}electricalFieldY(t,i){return 0}gravitationalMass(t){const i=t.mass;return isNaN(i)?this.Jc:i}gravitationalFieldX(t,i){return 0}gravitationalFieldY(t,i){return 0}isFixed(t){return t.isFixed}get currentIteration(){return this.Oh}get arrangementSpacing(){return this.Cs}set arrangementSpacing(t){Util.s(t,Size,ForceDirectedLayout,"arrangementSpacing"),this.Cs.equals(t)||(this.Cs.c(t),this.invalidateLayout())}get arrangesToOrigin(){return this.Ng}set arrangesToOrigin(t){this.Ng!==t&&(Util.t(t,"boolean",ForceDirectedLayout,"arrangesToOrigin"),this.Ng=t,this.invalidateLayout())}get setsPortSpots(){return this.Bn}set setsPortSpots(t){this.Bn!==t&&(Util.t(t,"boolean",ForceDirectedLayout,"setsPortSpots"),this.Bn=t,this.invalidateLayout())}get comments(){return this.Ve}set comments(t){this.Ve!==t&&(Util.t(t,"boolean",ForceDirectedLayout,"comments"),this.Ve=t,this.invalidateLayout())}get maxPrelayoutIterations(){return this.Cg}set maxPrelayoutIterations(t){this.Cg!==t&&(Util.t(t,"number",ForceDirectedLayout,"maxPrelayoutIterations"),t>=0&&(this.Cg=t,this.invalidateLayout()))}get maxIterations(){return this.Ag}set maxIterations(t){this.Ag!==t&&(Util.t(t,"number",ForceDirectedLayout,"maxIterations"),t>=0&&(this.Ag=t,this.invalidateLayout()))}get epsilonDistance(){return this.Lg}set epsilonDistance(t){this.Lg!==t&&(Util.t(t,"number",ForceDirectedLayout,"epsilonDistance"),t>0&&(this.Lg=t,this.invalidateLayout()))}get infinityDistance(){return this.qc}set infinityDistance(t){this.qc!==t&&(Util.t(t,"number",ForceDirectedLayout,"infinityDistance"),t>1&&(this.qc=t,this.invalidateLayout()))}get moveLimit(){return this.Tg}set moveLimit(t){this.Tg!==t&&(Util.t(t,"number",ForceDirectedLayout,"moveLimit"),this.Tg=t,this.invalidateLayout())}get randomNumberGenerator(){return this.Dg}set randomNumberGenerator(t){this.Dg!==t&&(t!==null&&typeof t.random!="function"&&Util.n('ForceDirectedLayout.randomNumberGenerator must have a "random()" function on it: '+t),this.Dg=t)}get defaultSpringStiffness(){return this.jc}set defaultSpringStiffness(t){this.jc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultSpringStiffness"),this.jc=t,this.invalidateLayout())}get defaultSpringLength(){return this.Wc}set defaultSpringLength(t){this.Wc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultSpringLength"),this.Wc=t,this.invalidateLayout())}get defaultElectricalCharge(){return this.vc}set defaultElectricalCharge(t){this.vc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultElectricalCharge"),this.vc=t,this.invalidateLayout())}get defaultGravitationalMass(){return this.Jc}set defaultGravitationalMass(t){this.Jc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultGravitationalMass"),this.Jc=t,this.invalidateLayout())}get defaultCommentSpringLength(){return this.Fg}set defaultCommentSpringLength(t){this.Fg!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultCommentSpringLength"),this.Fg=t,this.invalidateLayout())}get defaultCommentElectricalCharge(){return this.Rg}set defaultCommentElectricalCharge(t){this.Rg!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultCommentElectricalCharge"),this.Rg=t,this.invalidateLayout())}get prelayoutQuality(){return this.Zc}set prelayoutQuality(t){this.Zc!==t&&(Util.t(t,"number",ForceDirectedLayout,"prelayoutQuality"),this.Zc=t,this.invalidateLayout())}get prelayoutSpread(){return this.ef}set prelayoutSpread(t){this.ef!==t&&(Util.t(t,"number",ForceDirectedLayout,"prelayoutSpread"),this.ef=t,this.invalidateLayout())}}class ForceDirectedNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new ForceDirectedVertex(this)}createEdge(){return new ForceDirectedEdge(this)}}class ForceDirectedVertex extends LayoutVertex{Zb;$b;Qb;_b;tk;hierarchicalVertexes;idInCluster;constructor(t){super(t),this.Zb=!1,this.$b=NaN,this.Qb=NaN,this._b=0,this.tk=0,this.hierarchicalVertexes=new List,this.idInCluster=-1}get isFixed(){return this.Zb}set isFixed(t){this.Zb!==t&&(Util.t(t,"boolean",ForceDirectedVertex,"isFixed"),this.Zb=t)}get charge(){return this.$b}set charge(t){this.$b!==t&&(Util.t(t,"number",ForceDirectedVertex,"charge"),this.$b=t)}get mass(){return this.Qb}set mass(t){this.Qb!==t&&(Util.t(t,"number",ForceDirectedVertex,"mass"),this.Qb=t)}get forceX(){return this._b}set forceX(t){this._b!==t&&(Util.t(t,"number",ForceDirectedVertex,"forceX"),this._b=t)}get forceY(){return this.tk}set forceY(t){this.tk!==t&&(Util.t(t,"number",ForceDirectedVertex,"forceY"),this.tk=t)}}class ForceDirectedEdge extends LayoutEdge{ik;ek;constructor(t){super(t),this.ik=NaN,this.ek=NaN}get stiffness(){return this.ik}set stiffness(t){this.ik!==t&&(Util.t(t,"number",ForceDirectedEdge,"stiffness"),this.ik=t)}get length(){return this.ek}set length(t){this.ek!==t&&(Util.t(t,"number",ForceDirectedEdge,"length"),this.ek=t)}}class RandomNumberGenerator{I;R;Q;M;A;seed;constructor(t){t===void 0&&(t=42),this.seed=t,this.A=48271,this.M=2147483647,this.Q=this.M/this.A,this.R=this.M%this.A,this.I=1/this.M,this.random()}random(){const t=this.seed/this.Q,i=this.seed%this.Q,e=this.A*i-this.R*t;return e>0?this.seed=e:this.seed=e+this.M,this.seed*this.I}}var LayeredDigraphCycleRemove=(w=>(w[w.DepthFirst=0]="DepthFirst",w[w.Greedy=1]="Greedy",w[w.FromLayers=2]="FromLayers",w))(LayeredDigraphCycleRemove||{}),LayeredDigraphLayering=(w=>(w[w.OptimalLinkLength=10]="OptimalLinkLength",w[w.LongestPathSink=11]="LongestPathSink",w[w.LongestPathSource=12]="LongestPathSource",w))(LayeredDigraphLayering||{}),LayeredDigraphInit=(w=>(w[w.DepthFirstOut=20]="DepthFirstOut",w[w.DepthFirstIn=21]="DepthFirstIn",w[w.Naive=22]="Naive",w))(LayeredDigraphInit||{}),LayeredDigraphAggressive=(w=>(w[w.None=30]="None",w[w.Less=31]="Less",w[w.More=32]="More",w))(LayeredDigraphAggressive||{}),LayeredDigraphPack=(w=>(w[w.None=0]="None",w[w.Expand=1]="Expand",w[w.Straighten=2]="Straighten",w[w.Median=4]="Median",w[w.MaybeExpand=8]="MaybeExpand",w[w.All=15]="All",w))(LayeredDigraphPack||{}),LayeredDigraphAlign=(w=>(w[w.None=0]="None",w[w.UpperLeft=1]="UpperLeft",w[w.UpperRight=2]="UpperRight",w[w.LowerLeft=4]="LowerLeft",w[w.LowerRight=8]="LowerRight",w[w.All=15]="All",w))(LayeredDigraphAlign||{});class LayeredDigraphLayout extends Layout{As;te;C;$c;Qc;_c;sf;tu;ar;iu;Bn;Lt;Wy;Wt;Ig;Ls;pi;nn;Ts;Ds;Gt;Og;nf;Eg;on;eu;fr;Vn;zn;UN;constructor(t){super(),this.As=25,this.te=25,this.C=0,this.$c=0,this.Qc=10,this._c=20,this.sf=4,this.tu=31,this.ar=15,this.iu=10,this.Bn=!0,this.Lt=-1,this.Wy=-1,this.Wt=-1,this.Ig=0,this.Ls=0,this.pi=null,this.nn=null,this.Ts=null,this.Ds=null,this.Gt=null,this.Og=0,this.nf=null,this.Eg=null,this.on=0,this.eu=null,this.fr=new Point,this.Vn=[],this.Vn.length=100,this.zn=15,this.UN=0,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.As=this.As,t.te=this.te,t.C=this.C,t.$c=this.$c,t.Qc=this.Qc,t._c=this._c,t.sf=this.sf,t.tu=this.tu,t.ar=this.ar,t.iu=this.iu,t.Bn=this.Bn,t.zn=this.zn}fi(t){t in LayeredDigraphAggressive?this.aggressiveOption=t:t in LayeredDigraphCycleRemove?this.cycleRemoveOption=t:t in LayeredDigraphInit?this.initializeOption=t:t in LayeredDigraphLayering?this.layeringOption=t:super.fi(t)}createNetwork(){return new LayeredDigraphNetwork(this)}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin),this.$O(),this.network.vertexes.count>0&&(this.network.deleteSelfEdges(),this.cycleRemoveOption!==2&&this.removeCycles(),this.QO(),this.cycleRemoveOption===2&&this.removeCycles(),this._O(),this.t3(),this.i3(),this.reduceCrossings(),this.straightenAndPack(),this.updateParts()),this.network=null,this.isValidLayout=!0}linkMinLength(t){return 1}linkLengthWeight(t){return 1}linkStraightenWeight(t){const i=t.fromVertex.node||t.fromVertex.data,e=t.toVertex.node||t.toVertex.data;return i===null&&e===null?8:i===null||e===null?4:1}nodeMinLayerSpace(t,i){return t.node===null&&t.data===null?0:this.C===90||this.C===270?i?t.focus.y+10:t.bounds.height-t.focus.y+10:i?t.focus.x+10:t.bounds.width-t.focus.x+10}nodeMinColumnSpace(t,i){if(t.node===null&&t.data===null)return 0;const e=i?t.sk:t.nk;if(e!==null)return e;const s=this.C;return s===90||s===270?i?t.sk=t.focus.x/this.te+1|0:t.nk=(t.bounds.width-t.focus.x)/this.te+1|0:i?t.sk=t.focus.y/this.te+1|0:t.nk=(t.bounds.height-t.focus.y)/this.te+1|0}ie(){this.nf===null&&(this.nf=[]);let t=0;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;this.nf[t]=e.layer,t++,this.nf[t]=e.column,t++,this.nf[t]=e.index,t++}return this.nf}es(t){let i=0;const e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;s.layer=t[i],i++,s.column=t[i],i++,s.index=t[i],i++}}nD(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"crossingMatrix:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"crossingMatrix:direction"));const e=this.Eh(t),s=this.pi[t];(this.Eg===null||this.Eg.length=0){for(f=e[o].So,c=0;ck||d===k&&g>S)&&r++,bd||k===d&&S>g)&&r++)}if(i<=0){for(f=e[o].rr,c=0;ck||d===k&&m>b)&&r++,Sd||k===d&&b>m)&&r++)}for(n[o*s+o]=r,a=o+1;a=0){for(p=e[o].So,M=e[a].So,c=0;c=0&&(h=s[r].rr);let a,f=0,c=0;if(l!==null)for(let u=0;u=0&&(h=r.rr);let a=0,f=0;const c=r.near;c!==null&&c.layer===r.layer&&(a+=c.column-1,f++);let u;if(l!==null)for(let d=0;d=0&&(h=r.rr);let a=0;const f=[],c=r.near;c!==null&&c.layer===r.layer&&(f[a]=c.column-1,a++);let u;if(l!==null)for(let d=0;dm-g);const d=a>>1;a&1?n[o]=f[d]:n[o]=f[d-1]+f[d]>>1}}return this.Bh(t,e),n}Zy(t,i,e,s,n){if(t.component===e){t.component=i;let o=0,r=0;if(s){const l=t.destinationEdges;for(;l.next();){const h=l.value,a=h.toVertex;o=t.layer-a.layer,r=this.linkMinLength(h),o===r&&this.Zy(a,i,e,s,n)}}if(n){const l=t.sourceEdges;for(;l.next();){const h=l.value,a=h.fromVertex;o=a.layer-t.layer,r=this.linkMinLength(h),o===r&&this.Zy(a,i,e,s,n)}}}}GN(t,i,e,s,n){if(t.component===e){if(t.component=i,s){const o=t.destinationEdges;for(;o.next();){const l=o.value.toVertex;this.GN(l,i,e,s,n)}}if(n){const o=t.sourceEdges;for(;o.next();){const l=o.value.fromVertex;this.GN(l,i,e,s,n)}}}}removeCycles(){const t=this.network.edges.iterator;for(;t.next();){const i=t.value;i.rev=!1}switch(this.$c){default:case 1:this.s3();break;case 0:this.o3();break;case 2:this.r3();break}}r3(){const t=this.network,i=t.vertexes.iterator;let e=1/0;for(;i.next();){const s=i.value;e=Math.min(e,s.layer)}if(e<1/0){if(e<0)for(i.reset();i.next();){const r=i.value;r.layer-=e}const s=[];for(i.reset();i.next();){const r=i.value,l=s[r.layer];l===void 0?s[r.layer]=[r]:l.push(r)}let n=0;for(let r=0;r0)for(let h=0;hh.index&&(t.reverseEdge(r),r.rev=!0)}}l3(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.ee)return e}return null}rD(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.ee){let s=!0;const n=e.destinationEdges;for(;n.next();)if(n.value.toVertex.ee){s=!1;break}if(s)return e}}return null}lD(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.ee){let s=!0;const n=e.sourceEdges;for(;n.next();)if(n.value.fromVertex.ee){s=!1;break}if(s)return e}}return null}h3(t){let i=null,e=0;const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;if(n.ee){let o=0;const r=n.destinationEdges;for(;r.next();)r.value.toVertex.ee&&o++;let l=0;const h=n.sourceEdges;for(;h.next();)h.value.fromVertex.ee&&l++;(i===null||ef&&this.Zy(h,e,-1,!0,!1)}for(this.Zy(t,s,-1,!0,!0);t.component!==e;){let r=0,l=1/0,h=0,a=null;const f=this.network.vertexes.iterator;for(;f.next();){const c=f.value;if(c.component===s){let u=0,d=!1;const m=c.So;o=m.length;for(let p=0;p0){for(i.reset();i.next();){const c=i.value;c.component===s&&(c.layer+=l)}t.component=e}else a.component=e}}u3(t){const i=this.network.vertexes.iterator;for(;i.next();){const n=i.value;n.component=-1}const e=0,s=1;for(this.Zy(t,s,-1,!0,!1);t.component!==e;){let n=0,o=1/0,r=0,l=null;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value;if(a.component===s){let f=0,c=!1;const u=a.So;let d=u.length;for(let g=0;gr)&&!c&&(l=a,r=f)}}if(n<0){for(i.reset();i.next();){const a=i.value;a.component===s&&(a.layer-=o)}t.component=e}else l.component=e}}_O(){const t=this.network,i=[],e=t.edges.iterator;for(;e.next();){const s=e.value;s.valid=!1,i.push(s)}for(let s=0;sb&&c>0){for(n.valid=!1,y=t.createVertex(),y.node=null,y.rk=2,y.layer=c-1,x&&kb&&c>0;)y=t.createVertex(),y.node=null,y.rk=3,y.layer=c-1,x&&kt[this.Ls]&&(this.Wy=t[e]-1,this.Ls=e),t[e]{o.index=this.pi[s],this.pi[s]++})}}p3(){let t=null;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;if(e.near&&(t===null&&(t=new Map),e.layer===e.near.layer)){const s=t.get(e.near)||[];s.push(e),t.set(e.near,s)}}for(let e=this.Lt;e>=0;e--)for(i.reset();i.next();){const s=i.value;s.layer===e&&s.index===-1&&this.gD(s,t)}}gD(t,i){if(t.near)return;const e=t.layer;if(t.index=this.pi[e],this.pi[e]++,i){const o=i.get(t);Array.isArray(o)&&o.forEach(r=>{r.index=this.pi[e],this.pi[e]++})}const s=t.rr;let n=!0;for(;n;){n=!1;for(let o=0;ol.portFromColOffset&&(n=!0,s[o]=l,s[o+1]=r)}}for(let o=0;o{a.index=this.pi[e],this.pi[e]++})}const s=t.So;let n=!0,o=0;for(;n;)for(n=!1,o=0;oa.portToColOffset&&(n=!0,s[o]=a,s[o+1]=h)}let r,l;for(o=0;o=0;s--)this.hk(s,-1),this.us(s,-1,!1,-1);n=this.countCrossings(),n=0;s--)this.hk(s,0),this.us(s,0,!1,0);n=this.countCrossings(),n=0;r--)for(l=0;l<=r;l++){for(o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,1,!1,1)||o;for(n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,-1,!1,-1)||o;for(n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,0,!1,0)||o;for(n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,0,!1,0)||o;n>=t?this.es(i):(t=n,i=this.ie())}break;default:case 31:for(r=this.Lt,l=0,h=t+1;(a=this.countCrossings())=l;s--)o=this.us(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,1,!1,1)||o;for(n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,-1,!1,-1)||o;for(n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,0,!1,0)||o;for(n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,0,!1,0)||o;n>=t?this.es(i):(t=n,i=this.ie())}break}this.es(i)}hk(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"medianBarycenterCrossingReduction:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"medianBarycenterCrossingReduction:direction"));let e=0,s=!1;const n=this.Eh(t),o=this.pi[t],r=this.oD(t,i),l=this.Jy(t,i);for(e=0;e0)for(h=[],l=0;ll+1&&(m+=4*(I-l),g+=4*(I-(l+1)))}}const B=n[l].destinationEdges.iterator;if(e&&s>=0)for(;B.next();){const W=B.value;O=W.toVertex,W.valid&&O.layer!==t&&(N=this.linkStraightenWeight(W),T=W.portFromColOffset,L=W.portToColOffset,F=O.column,C+=(Math.abs(p+T-(F+L))+1)*N,P+=(Math.abs(A+T-(F+L))+1)*N)}for(B.reset();B.next();){const W=B.value;if(O=W.toVertex,W.valid&&O.layer===t){for(V=0;Vl+1&&(m+=4*(I-(l+1)),g+=4*(I-l))}}const z=n[l+1].destinationEdges.iterator;if(e&&s>=0)for(;z.next();){const W=z.value;O=W.toVertex,W.valid&&O.layer!==t&&(N=this.linkStraightenWeight(W),T=W.portFromColOffset,L=W.portToColOffset,F=O.column,C+=(Math.abs(y+T-(F+L))+1)*N,P+=(Math.abs(M+T-(F+L))+1)*N)}for(z.reset();z.next();){const W=z.value;if(O=W.toVertex,W.valid&&O.layer===t){for(V=0;V1e3&&s&&(e=!1),e){const n=[];let o=0;for(o=0;o<=this.Lt;o++)n[o]=0;let r=0;const l=this.network.vertexes.iterator;for(;l.next();){const a=l.value;t=a.layer,r=a.column;const f=this.nodeMinColumnSpace(a,!1);n[t]=Math.max(n[t],r+f)}const h=8;for(l.reset();l.next();){const a=l.value;t=a.layer,r=a.column,a.column=((this.Wt-n[t])*h>>1)+r*h}this.Wt*=h}if(this.ar&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Bg(t,-1)||i;i=this.Bg(this.Ls,0)||i,n++}}if(this.ar&4){for(t=this.Ls+1;t<=this.Lt;t++)this.qN(t,1);for(t=this.Ls-1;t>=0;t--)this.qN(t,-1);this.qN(this.Ls,0)}if(e&&(this.pD(-1),this.pD(1)),this.ar&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Bg(t,0)||i;n++}}}Bg(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"bendStraighten:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"bendStraighten:direction"));let e=!1;for(;this.x3(t,i);)e=!0;return e}x3(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"shiftbendStraighten:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"shiftbendStraighten:direction"));let e=0;const s=this.Eh(t),n=this.pi[t],o=this.Jy(t,-1);if(i>0)for(e=0;ef+this.nodeMinColumnSpace(s[e-1],!1)?u=a-1:u=a;let d=0;e+1>=n||s[e+1].column-a-1>c+this.nodeMinColumnSpace(s[e+1],!0)?d=a+1:d=a;let m=0,g=0,p=0,y=0,x=0,k=0;if(i<=0){const P=s[e].sourceEdges.iterator;for(;P.next();){const N=P.value,T=N.fromVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const L=T.column;m+=(Math.abs(a+k-(L+x))+1)*y,g+=(Math.abs(u+k-(L+x))+1)*y,p+=(Math.abs(d+k-(L+x))+1)*y}}}if(i>=0){const P=s[e].destinationEdges.iterator;for(;P.next();){const N=P.value,T=N.toVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const L=T.column;m+=(Math.abs(a+x-(L+k))+1)*y,g+=(Math.abs(u+x-(L+k))+1)*y,p+=(Math.abs(d+x-(L+k))+1)*y}}}let b=0,S=0,M=0;const A=o[s[e].index],C=r[s[e].index];A!==-1&&(b+=Math.abs(A-a),S+=Math.abs(A-u),M+=Math.abs(A-d)),C!==-1&&(b+=Math.abs(C-a),S+=Math.abs(C-u),M+=Math.abs(C-d)),g=r[e]?u=p:g<=r[e]&&(u=g)),u!==a&&(l=!0,h=!0,s[e].column=u)}return this.Bh(t,s),this.vy(),l}b3(){for(let t=0;t<=this.Wt;t++)for(;this.k3(t,1););this.vy()}k3(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"packAux:column"),Util.r(i,LayeredDigraphLayout,"packAux:direction"));let e=!0;const s=this.network.vertexes.iterator;for(;s.next();){const o=s.value,r=this.nodeMinColumnSpace(o,!0),l=this.nodeMinColumnSpace(o,!1);if(o.column-r<=t&&o.column+l>=t){e=!1;break}}let n=!1;if(e){if(i>0)for(s.reset();s.next();){const o=s.value;o.column>t&&(o.column-=1,n=!0)}if(i<0)for(s.reset();s.next();){const o=s.value;o.column0&&(e=t+1),i<0&&(e=t-1);let s=0;const n=[],o=[];for(s=0;s<=this.Lt;s++)n[s]=!1,o[s]=!1;const r=this.network.vertexes.iterator;for(;r.next();){const a=r.value,f=a.column-this.nodeMinColumnSpace(a,!0),c=a.column+this.nodeMinColumnSpace(a,!1);f<=t&&c>=t&&(n[a.layer]=!0),f<=e&&c>=e&&(o[a.layer]=!0)}let l=!0,h=!1;for(s=0;s<=this.Lt;s++)l=l&&!(n[s]&&o[s]);if(l){if(i>0)for(r.reset();r.next();){const a=r.value;a.column>t&&(a.column-=1,h=!0)}if(i<0)for(r.reset();r.next();){const a=r.value;a.column0)for(i=0;i<=this.Wt;i++)for(e=this.ie(),s=this.ok(!0),n=s+1;ss?this.es(e):o=0;i--)for(e=this.ie(),s=this.ok(!0),n=s+1;ss?this.es(e):o0)for(e.reset();e.next();){const f=e.value;f.column-this.nodeMinColumnSpace(f,!0)<=t&&(f.component=this.on)}if(i<0)for(e.reset();e.next();){const f=e.value;f.column+this.nodeMinColumnSpace(f,!1)>=t&&(f.component=this.on)}for(this.on++,e.reset();e.next();){const f=e.value;f.component===-1&&(this.GN(f,this.on,-1,!0,!0),this.on++)}let s=0;const n=[];for(s=0;s0)for(let c=0;c0;c--)o[f*(this.Wt+1)+c]!==-1&&o[f*(this.Wt+1)+c-1]!==-1&&o[f*(this.Wt+1)+c]!==o[f*(this.Wt+1)+c-1]&&(n[o[f*(this.Wt+1)+c]*this.on+o[f*(this.Wt+1)+c-1]]=!0)}const r=[];for(s=0;s0)for(e.reset();e.next();){const f=e.value;r[f.component]&&(f.column-=1,a=!0)}if(i<0)for(e.reset();e.next();){const f=e.value;r[f.component]&&(f.column+=1,a=!0)}return a}w3(){const t=Util.at(),i=this.eu.length;for(let u=0;u<=i;u++)t[u]=[];const e=this.network.vertexes.iterator;for(;e.next();){const u=e.value,d=i-u.layer,m=t[d];m[u.index]=u}const s=new GSet;this.P3(t,s);let n=null,o=null,r=null,l=null;const h=(this.zn&1)!==0,a=(this.zn&2)!==0,f=(this.zn&4)!==0,c=(this.zn&8)!==0;h&&(this.hl(t,s,!0),n=this.ak(t,!0,!1)),t.reverse(),f&&(this.hl(t,s,!1),r=this.ak(t,!1,!1));for(const u of t)u.reverse();c&&(this.hl(t,s,!1),l=this.ak(t,!1,!0)),t.reverse(),a&&(this.hl(t,s,!0),o=this.ak(t,!0,!0)),Util.nt(t),this.N3(n,o,r,l),this.network.vertexes.each(u=>{const d=u,m=Util.at();h&&m.push(n.get(d)),a&&m.push(o.get(d)),f&&m.push(r.get(d)),c&&m.push(l.get(d)),m.sort((k,b)=>k-b);const g=m.length,p=Math.floor((g-1)/2),y=Math.ceil((g-1)/2),x=(m[p]+m[y])/2;Util.nt(m),d.de=x})}P3(t,i){const e=t.length;for(let s=1;sc)&&i.add(m)}o++}n=c}}}}C3(t){if(t.node===null){const i=t.getProperSourceVertexes();if(i.length>0)return i[0].node===null}return!1}hl(t,i,e){this.A3(t);for(const s of t){let n=-1;for(const o of s){const r=e?o.getProperSourceVertexes():o.getProperDestinationVertexes(),l=r.length;if(l>0){r.sort((a,f)=>a.Vh-f.Vh);const h=(l-1)/2;for(let a=Math.floor(h),f=Math.ceil(h);a<=f;a++)if(o.Xn===o){const c=r[a];let u;e?u=c.getDestinationEdge(o):u=o.getDestinationEdge(c),!i.has(u)&&n0){const f=this.bD(a,t),c=s?f.width:f.height,u=a.ss.nu+a.de+a.Yn-(f.de+f.Yn+c+this.columnSpacing);f.ss.nu=Math.min(f.ss.nu,u)}h=a.Vh+1}while(l0){const s=this.bD(e,i),n=s.of;this.xD(n,i),t.ss===t&&(t.ss=n.ss);const o=this.C===90||this.C===270?s.width:s.height;if(t.ss===n.ss){const r=n.de+s.Yn+o-e.Yn+this.columnSpacing;t.de=Math.max(t.de,r)}}e=e.Xn}while(e!==t);for(;e.Xn!==t;)e=e.Xn,e.de=t.de,e.ss=t.ss}bD(t,i){const e=t.wD,s=t.Vh;return s<1&&Util.n("Could not determine previous vertex in layer"),i[e][s-1]}N3(...t){let i=-1;const e=Util.at(),s=Util.at();let n=1/0;for(let o=0;o<4;o++){if(!t[o])continue;const r=this.T3(t[o],e,s,o);r{r.set(h.key,h.value+l)})}Util.nt(e),Util.nt(s)}T3(t,i,e,s){if(!t||t.count===0)return i[s]=0,e[s]=0,1/0;let n=1/0,o=-1/0;return t.each(r=>{const l=r.key,h=r.value,a=this.C===90||this.C===270?l.width:l.height;ho&&(o=h+a)}),i[s]=n,e[s]=o,o-n}commitLayout(){this.jy(),this.commitNodes(),this.jN(),this.isRouting&&this.commitLinks()}jy(){if(!this.setsPortSpots)return;const t=this.lk(!0),i=this.lk(!1),e=this.network.edges.iterator;for(;e.next();){const n=e.value.link;n!==null&&(n.fromSpot=t,n.toSpot=i)}}lk(t){return this.C===270?t?Spot.MiddleTop:Spot.MiddleBottom:this.C===90?t?Spot.MiddleBottom:Spot.MiddleTop:this.C===180?t?Spot.MiddleLeft:Spot.MiddleRight:t?Spot.MiddleRight:Spot.MiddleLeft}commitNodes(){this.nn=[],this.Ts=[],this.Ds=[],this.Gt=[];for(let d=0;d<=this.Lt;d++)this.nn[d]=0,this.Ts[d]=0,this.Ds[d]=0,this.Gt[d]=0;const t=this.network.vertexes.iterator;for(;t.next();){const d=t.value,m=d.layer;this.nn[m]=Math.max(this.nn[m],this.nodeMinLayerSpace(d,!0)),this.Ts[m]=Math.max(this.Ts[m],this.nodeMinLayerSpace(d,!1))}let i=0;const e=this.As;for(let d=0;d<=this.Lt;d++){let m=e;this.nn[d]+this.Ts[d]<=0&&(m=0),d>0&&(i+=m/2),this.C===90||this.C===0?(i+=this.Ts[d],this.Ds[d]=i,i+=this.nn[d]):(i+=this.nn[d],this.Ds[d]=i,i+=this.Ts[d]),d=0;n--)this.C===270?n===0?e.push(new Rect(0,0,s,Math.abs(this.Gt[0]))):e.push(new Rect(0,this.Gt[n-1],s,Math.abs(this.Gt[n-1]-this.Gt[n]))):this.C===90?n===0?e.push(new Rect(0,this.Gt[0],s,Math.abs(this.Gt[0]-t))):e.push(new Rect(0,this.Gt[n],s,Math.abs(this.Gt[n-1]-this.Gt[n]))):this.C===180?n===0?e.push(new Rect(0,0,Math.abs(this.Gt[0]),s)):e.push(new Rect(this.Gt[n-1],0,Math.abs(this.Gt[n-1]-this.Gt[n]),s)):n===0?e.push(new Rect(this.Gt[0],0,Math.abs(this.Gt[0]-t),s)):e.push(new Rect(this.Gt[n],0,Math.abs(this.Gt[n-1]-this.Gt[n]),s));this.commitLayers(e,this.fr)}commitLayers(t,i){}commitLinks(){const t=this.network.edges.iterator;let i;for(;t.next();)i=t.value.link,i!==null&&(i.startRoute(),i.clearPoints(),i.commitRoute());for(t.reset();t.next();)i=t.value.link,i!==null&&i.updateRoute();for(t.reset();t.next();){const e=t.value;if(i=e.link,i===null||i.pointsCount===0)continue;i.startRoute();const s=i;let n=s.fromNode,o=s.toNode,r=s.fromPort,l=s.toPort;if(n!==null){const N=n.findVisibleNode();N!==null&&N!==n&&(n=N,r=N.port)}if(o!==null){const N=o.findVisibleNode();N!==null&&N!==o&&(o=N,l=N.port)}const h=i.computeSpot(!0,r),a=i.computeSpot(!1,l);let f=e.fromVertex,c=e.toVertex;if(e.valid){if(i.curve===9&&i.pointsCount===4)if(f.column===c.column&&this.alignOption===0){const N=i.getLinkPoint(n,r,h,!0,!1,o,l),T=i.getLinkPoint(o,l,a,!1,!1,n,r);N.isReal()||N.set(n.actualBounds.center),T.isReal()||T.set(o.actualBounds.center),i.clearPoints(),i.addPointAt(N.x,N.y),i.addPointAt((2*N.x+T.x)/3,(2*N.y+T.y)/3),i.addPointAt((N.x+2*T.x)/3,(N.y+2*T.y)/3),i.addPointAt(T.x,T.y)}else{let N=!1,T=!1;if(r!==null&&h===Spot.None&&(N=!0),l!==null&&a===Spot.None&&(T=!0),N||T){let L=null;N&&(L=i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0),L.isReal()||L.set(n.actualBounds.center),i.setPointAt(0,L.x,L.y));let D=null;if(T&&(D=i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(0),!1),D.isReal()||D.set(o.actualBounds.center),i.setPointAt(3,D.x,D.y)),L){const F=i.getPoint(2);i.setPointAt(1,(L.x*2+F.x)/3,(L.y*2+F.y)/3)}if(D){const F=i.getPoint(1);i.setPointAt(2,(D.x*2+F.x)/3,(D.y*2+F.y)/3)}}}i.commitRoute();continue}if(f.layer===c.layer){i.commitRoute();continue}let u=!1,d=!1;const m=this.As;let g=0,p=i.firstPickIndex+1;if(i.isOrthogonal)d=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3);else if(i.curve===9)u=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3),g===4&&(p=2);else{g=i.pointsCount;const N=h===Spot.None,T=a===Spot.None;g>2&&N&&T?i.points.removeRange(1,g-2):g>3&&N&&!T?i.points.removeRange(1,g-3):g>3&&!N&&T?i.points.removeRange(2,g-2):g>4&&!N&&!T&&i.points.removeRange(2,g-3)}let y,x,k=0,b=0,S=0,M=0,A=0,C=0,P=0;if(e.rev){let N=0;for(;c!==null&&f!==c;){y=null,x=null;const T=c.sourceEdges.iterator;for(;T.next();){const L=T.value;if(L.link===e.link&&(y=L.fromVertex,x=L.toVertex,y.node===null))break}if(y===null)break;if(y!==f)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=y.centerX,M=y.centerY,d)this.C===180||this.C===0?p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,k,M)):(x!==null?x.centerY:b)!==M&&(A=this.Gt[y.layer-1]+this.fr.x,i.insertPointAt(p++,A,b),i.insertPointAt(p++,A,M)):p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,S,b)):(x!==null?x.centerX:k)!==S&&(A=this.Gt[y.layer-1]+this.fr.y,i.insertPointAt(p++,k,A),i.insertPointAt(p++,S,A));else if(p===i.firstPickIndex+1)if(C=Math.max(10,this.nn[c.layer]),P=Math.max(10,this.Ts[c.layer]),u)this.C===180?S<=c.bounds.x?(N=c.bounds.x,i.insertPointAt(p++,N-C,M),i.insertPointAt(p++,N,M),i.insertPointAt(p++,N+P,M)):(i.insertPointAt(p++,S-C,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S+P,M)):this.C===90?M>=c.bounds.bottom?(N=c.bounds.y+c.bounds.height,i.insertPointAt(p++,S,N+P),i.insertPointAt(p++,S,N),i.insertPointAt(p++,S,N-C)):(i.insertPointAt(p++,S,M+P),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M-C)):this.C===270?M<=c.bounds.y?(N=c.bounds.y,i.insertPointAt(p++,S,N-C),i.insertPointAt(p++,S,N),i.insertPointAt(p++,S,N+P)):(i.insertPointAt(p++,S,M-C),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M+P)):this.C===0&&(S>=c.bounds.right?(N=c.bounds.x+c.bounds.width,i.insertPointAt(p++,N+P,M),i.insertPointAt(p++,N,M),i.insertPointAt(p++,N-C,M)):(i.insertPointAt(p++,S+P,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S-C,M)));else{i.insertPointAt(p++,k,b);let L=0;this.C===180||this.C===0?((this.C===180?S>=c.bounds.right:S<=c.bounds.x)&&(L=(this.C===0?-C:P)/2),i.insertPointAt(p++,k+L,M)):((this.C===270?M>=c.bounds.bottom:M<=c.bounds.y)&&(L=(this.C===90?-C:P)/2),i.insertPointAt(p++,S,b+L)),i.insertPointAt(p++,S,M)}else C=Math.max(10,this.nn[y.layer]),P=Math.max(10,this.Ts[y.layer]),u?this.C===180?(i.insertPointAt(p++,S-C-m,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S+P+m,M)):this.C===90?(i.insertPointAt(p++,S,M+P+m),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M-C-m)):this.C===270?(i.insertPointAt(p++,S,M-C-m),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M+P+m)):(i.insertPointAt(p++,S+P+m,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S-C-m,M)):(this.C===180||this.C===90||this.C,i.insertPointAt(p++,S,M));c=y}if(l===null||h!==Spot.None||d)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=i.getPoint(p).x,M=i.getPoint(p).y,d){const T=this.Ts[f.layer];let L=0;this.C===180||this.C===0?(L=b,L>=f.bounds.y&&L<=f.bounds.bottom&&(this.C===180?S>=f.bounds.x:S<=f.bounds.right)&&(N=f.centerX+(this.C===180?-T:T),L=f.bounds.x&&L<=f.bounds.right&&(this.C===270?M>=f.bounds.y:M<=f.bounds.bottom)&&(N=f.centerY+(this.C===270?-T:T),L=f.bounds.x?(N=f.bounds.x+f.bounds.width,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N+P,b)):this.C===90&&M<=f.bounds.bottom?(N=f.bounds.y,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N-C)):this.C===270&&M>=f.bounds.y?(N=f.bounds.y+f.bounds.height,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N+P)):this.C===0&&S<=f.bounds.right&&(N=f.bounds.x,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N-C,b));else{C=Math.max(10,this.nn[f.layer]),P=Math.max(10,this.Ts[f.layer]);let T=0;this.C===180||this.C===0?((this.C===180?S<=f.bounds.x:S>=f.bounds.right)&&(T=(this.C===0?P:-C)/2),i.insertPointAt(p++,S+T,b)):((this.C===270?M<=f.bounds.y:M>=f.bounds.bottom)&&(T=(this.C===90?P:-C)/2),i.insertPointAt(p++,k,M+T)),i.insertPointAt(p++,S,M)}}else{for(;f!==null&&f!==c;){y=null,x=null;const N=f.destinationEdges.iterator;for(;N.next();){const T=N.value;if(T.link===e.link&&(y=T.toVertex,x=T.fromVertex,x.node!==null&&(x=null),y.node===null))break}if(y===null)break;y!==c&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=y.centerX,M=y.centerY,d?this.C===180||this.C===0?(x!==null?x.centerY:b)!==M&&(A=this.Gt[y.layer]+this.fr.x,p===i.firstPickIndex+1&&(this.C===0?A=Math.max(A,k):A=Math.min(A,k)),i.insertPointAt(p++,A,b),i.insertPointAt(p++,A,M)):(x!==null?x.centerX:k)!==S&&(A=this.Gt[y.layer]+this.fr.y,p===i.firstPickIndex+1&&(this.C===90?A=Math.max(A,b):A=Math.min(A,b)),i.insertPointAt(p++,k,A),i.insertPointAt(p++,S,A)):(C=Math.max(10,this.nn[y.layer]),P=Math.max(10,this.Ts[y.layer]),u?this.C===180?(i.insertPointAt(p++,S+P+m,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S-C-m,M)):this.C===90?(i.insertPointAt(p++,S,M-C-m),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M+P+m)):this.C===270?(i.insertPointAt(p++,S,M+P+m),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M-C-m)):(i.insertPointAt(p++,S-C-m,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S+P+m,M)):this.C===180?(i.insertPointAt(p++,S+P,M),i.insertPointAt(p++,S-C,M)):this.C===90?(i.insertPointAt(p++,S,M-C),i.insertPointAt(p++,S,M+P)):this.C===270?(i.insertPointAt(p++,S,M+P),i.insertPointAt(p++,S,M-C)):(i.insertPointAt(p++,S-C,M),i.insertPointAt(p++,S+P,M)))),f=y}d&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=i.getPoint(p).x,M=i.getPoint(p).y,this.C===180||this.C===0?b!==M&&(this.C===0?A=Math.min(Math.max((S+k)/2,this.Gt[c.layer]+this.fr.x),S):A=Math.max(Math.min((S+k)/2,this.Gt[c.layer]+this.fr.x),S),i.insertPointAt(p++,A,b),i.insertPointAt(p++,A,M)):k!==S&&(this.C===90?A=Math.min(Math.max((M+b)/2,this.Gt[c.layer]+this.fr.y),M):A=Math.max(Math.min((M+b)/2,this.Gt[c.layer]+this.fr.y),M),i.insertPointAt(p++,k,A),i.insertPointAt(p++,S,A)))}if(s!==null&&u&&i.pointsCount>=4){if(r!==null){const N=h===Spot.None?i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0):i.getPoint(0);if(h===Spot.None){const T=i.getPoint(2),L=i.getPoint(3);this.direction===90||this.direction===270?(i.setPointAt(1,(N.x+T.x)/2,T.y),i.setPointAt(2,L.x,(T.y+L.y)/2)):(i.setPointAt(1,T.x,(N.y+T.y)/2),i.setPointAt(2,(T.x+L.x)/2,L.y))}N.isReal()||N.set(n.actualBounds.center),i.setPointAt(0,N.x,N.y)}if(l!==null){const N=a===Spot.None?i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(i.pointsCount-4),!1):i.getPoint(i.pointsCount-1);if(a===Spot.None){const T=i.getPoint(i.pointsCount-3),L=i.getPoint(i.pointsCount-4);this.direction===90||this.direction===270?(i.setPointAt(i.pointsCount-2,(N.x+T.x)/2,T.y),i.setPointAt(i.pointsCount-2,L.x,(T.y+L.y)/2)):(i.setPointAt(i.pointsCount-2,T.x,(N.y+T.y)/2),i.setPointAt(i.pointsCount-3,(T.x+L.x)/2,L.y))}N.isReal()||N.set(o.actualBounds.center),i.setPointAt(i.pointsCount-1,N.x,N.y)}}i.commitRoute(),e.commit()}}$O(){this.Wy=-1,this.Ig=0,this.Ls=0,this.nf=null,this.Eg=null,this.eu=null;for(let t=0;t=this.Vn.length){const n=[];for(let o=0;o=0&&(this.As=t,this.invalidateLayout()))}get columnSpacing(){return this.te}set columnSpacing(t){this.te!==t&&(Util.t(t,"number",LayeredDigraphLayout,"columnSpacing"),t>0&&(this.te=t,this.invalidateLayout()))}get direction(){return this.C}set direction(t){this.C!==t&&(Util.t(t,"number",LayeredDigraphLayout,"direction"),t===0||t===90||t===180||t===270?(this.C=t,this.invalidateLayout()):Util.n("LayeredDigraphLayout.direction must be 0, 90, 180, or 270"))}get cycleRemoveOption(){return this.$c}set cycleRemoveOption(t){this.$c!==t&&(Util.tt(t,LayeredDigraphCycleRemove,"LayeredDigraphCycleRemove"),(t===1||t===0||t===2)&&(this.$c=t,this.invalidateLayout()))}get layeringOption(){return this.Qc}set layeringOption(t){this.Qc!==t&&(Util.tt(t,LayeredDigraphLayering,"LayeredDigraphLayering"),(t===10||t===11||t===12)&&(this.Qc=t,this.invalidateLayout()))}get initializeOption(){return this._c}set initializeOption(t){this._c!==t&&(Util.tt(t,LayeredDigraphInit,"LayeredDigraphInit"),(t===20||t===21||t===22)&&(this._c=t,this.invalidateLayout()))}get iterations(){return this.sf}set iterations(t){this.sf!==t&&(Util.r(t,LayeredDigraphNetwork,"iterations"),t>=0&&(this.sf=t,this.invalidateLayout()))}get aggressiveOption(){return this.tu}set aggressiveOption(t){this.tu!==t&&(Util.tt(t,LayeredDigraphAggressive,"LayeredDigraphAggressive"),(t===30||t===31||t===32)&&(this.tu=t,this.invalidateLayout()))}get packOption(){return this.ar}set packOption(t){this.ar!==t&&(Util.t(t,"number",LayeredDigraphLayout,"packOption"),t>=0&&t<8&&(this.ar=t,this.invalidateLayout()))}get packIterations(){return this.iu}set packIterations(t){this.iu=t}get alignOption(){return this.zn}set alignOption(t){this.zn!==t&&(Util.t(t,"number",LayeredDigraphLayout,"align"),t>=0&&t<16&&(this.zn=t,this.invalidateLayout()))}get setsPortSpots(){return this.Bn}set setsPortSpots(t){this.Bn!==t&&(Util.t(t,"boolean",LayeredDigraphLayout,"setsPortSpots"),this.Bn=t,this.invalidateLayout())}get maxLayer(){return this.Lt}get maxIndex(){return this.Wy}get maxColumn(){return this.Wt}get minIndexLayer(){return this.Ig}get maxIndexLayer(){return this.Ls}static CycleDepthFirst=0;static CycleGreedy=1;static CycleFromLayers=2;static LayerOptimalLinkLength=10;static LayerLongestPathSink=11;static LayerLongestPathSource=12;static InitDepthFirstOut=20;static InitDepthFirstIn=21;static InitNaive=22;static AggressiveNone=30;static AggressiveLess=31;static AggressiveMore=32;static PackNone=0;static PackExpand=1;static PackStraighten=2;static PackMedian=4;static PackAll=15;static AlignNone=0;static AlignUpperLeft=1;static AlignUpperRight=2;static AlignLowerLeft=4;static AlignLowerRight=8;static AlignAll=15}class SegInfo{_o;D3;b1;F3;R3;Bt;$e;I3;constructor(){this._o=0,this.D3=0,this.b1=0,this.F3=0,this.R3=0,this.Bt=0,this.$e=null,this.I3=0}}class LayeredDigraphNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new LayeredDigraphVertex(this)}createEdge(){return new LayeredDigraphEdge(this)}}class LayeredDigraphVertex extends LayoutVertex{_o;Go;Bt;fk;ck;ee;su;$n;rk;sk;nk;of;Xn;wD;Vh;ss;nu;de;Yn;$y=null;Qy=null;_y=null;tw=null;constructor(t){super(t),this._o=-1,this.Go=-1,this.Bt=-1,this.fk=NaN,this.ck=null,this.ee=!1,this.su=NaN,this.$n=NaN,this.rk=0,this.sk=null,this.nk=null}static kD(t,i){return t.index-i.index}getProperSourceEdges(){if(!this._y){const t=[];for(const i of this.So){const e=i;e.valid&&t.push(e)}this._y=t}return this._y}getProperDestinationEdges(){if(!this.tw){const t=[];for(const i of this.rr){const e=i;e.valid&&t.push(e)}this.tw=t}return this.tw}getDestinationEdge(t){const i=this.getProperDestinationEdges();for(const e of i)if(e.toVertex===t)return e;Util.n("Unable to find destination edge to given vertex")}getProperSourceVertexes(){if(!this.$y){const t=[];for(const i of this.So){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.fromVertex)}t.sort(LayeredDigraphVertex.kD),this.$y=t}return this.$y}getProperDestinationVertexes(){if(!this.Qy){const t=[];for(const i of this.rr){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.toVertex)}t.sort(LayeredDigraphVertex.kD),this.Qy=t}return this.Qy}addSourceEdge(t){super.addSourceEdge(t),this.$y=null,this._y=null}deleteSourceEdge(t){super.deleteSourceEdge(t),this.$y=null,this._y=null}addDestinationEdge(t){super.addDestinationEdge(t),this.Qy=null,this.tw=null}deleteDestinationEdge(t){super.deleteDestinationEdge(t),this.Qy=null,this.tw=null}get layer(){return this._o}set layer(t){this._o!==t&&(Util.t(t,"number",LayeredDigraphVertex,"layer"),this._o=t)}get column(){return this.Go}set column(t){this.Go!==t&&(Util.t(t,"number",LayeredDigraphVertex,"column"),this.Go=t)}get index(){return this.Bt}set index(t){this.Bt!==t&&(Util.t(t,"number",LayeredDigraphVertex,"index"),this.Bt=t)}get component(){return this.fk}set component(t){this.fk!==t&&(Util.t(t,"number",LayeredDigraphVertex,"component"),this.fk=t)}get near(){return this.ck}set near(t){this.ck!==t&&(Debug&&t!==null&&Util.s(t,LayeredDigraphVertex,LayeredDigraphVertex,"near"),this.ck=t)}}class LayeredDigraphEdge extends LayoutEdge{ee;uk;dk;gk;mk;pk;yk;constructor(t){super(t),this.ee=!1,this.uk=!1,this.dk=!1,this.gk=NaN,this.mk=NaN,this.pk=0,this.yk=0}get fromVertex(){return this._e}set fromVertex(t){this._e!==t&&(Debug&&t!==null&&Util.s(t,LayeredDigraphVertex,LayeredDigraphEdge,"fromVertex"),this._e=t)}get toVertex(){return this.ts}set toVertex(t){this.ts!==t&&(Debug&&t!==null&&Util.s(t,LayeredDigraphVertex,LayeredDigraphEdge,"toVertex"),this.ts=t)}get valid(){return this.ee}set valid(t){this.ee!==t&&(Util.t(t,"boolean",LayeredDigraphEdge,"valid"),this.ee=t)}get rev(){return this.uk}set rev(t){this.uk!==t&&(Util.t(t,"boolean",LayeredDigraphEdge,"rev"),this.uk=t)}get forest(){return this.dk}set forest(t){this.dk!==t&&(Util.t(t,"boolean",LayeredDigraphEdge,"forest"),this.dk=t)}get portFromPos(){return this.gk}set portFromPos(t){this.gk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portFromPos"),this.gk=t)}get portToPos(){return this.mk}set portToPos(t){this.mk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portToPos"),this.mk=t)}get portFromColOffset(){return this.pk}set portFromColOffset(t){this.pk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portFromColOffset"),this.pk=t)}get portToColOffset(){return this.yk}set portToColOffset(t){this.yk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portToColOffset"),this.yk=t)}}var TreePath=(w=>(w[w.Default=0]="Default",w[w.Destination=1]="Destination",w[w.Source=2]="Source",w))(TreePath||{}),TreeSorting=(w=>(w[w.Forwards=10]="Forwards",w[w.Reverse=11]="Reverse",w[w.Ascending=12]="Ascending",w[w.Descending=13]="Descending",w))(TreeSorting||{}),TreeAlignment=(w=>(w[w.CenterSubtrees=20]="CenterSubtrees",w[w.CenterChildren=21]="CenterChildren",w[w.Start=22]="Start",w[w.End=23]="End",w[w.Bus=24]="Bus",w[w.BusBranching=25]="BusBranching",w[w.TopLeftBus=26]="TopLeftBus",w[w.BottomRightBus=27]="BottomRightBus",w[w.Custom=28]="Custom",w))(TreeAlignment||{}),TreeCompaction=(w=>(w[w.None=30]="None",w[w.Block=31]="Block",w))(TreeCompaction||{}),TreeStyle=(w=>(w[w.Layered=40]="Layered",w[w.LastParents=41]="LastParents",w[w.Alternating=42]="Alternating",w[w.RootOnly=43]="RootOnly",w))(TreeStyle||{}),TreeArrangement=(w=>(w[w.Vertical=50]="Vertical",w[w.Horizontal=51]="Horizontal",w[w.FixedRoots=52]="FixedRoots",w))(TreeArrangement||{}),TreeLayerStyle=(w=>(w[w.Individual=60]="Individual",w[w.Siblings=61]="Siblings",w[w.Uniform=62]="Uniform",w))(TreeLayerStyle||{});class TreeLayout extends Layout{Ei;Ii;ou;Vg;WN;Ve;qi;Cs;K;U;wk;ds;constructor(t){super(),this.Ei=new GSet,this.Ii=0,this.ds=1,this.ou=40,this.Vg=60,this.WN=[],this.Ve=!0,this.qi=50,this.Cs=new Size(10,10).w();const i=new TreeNetwork(this);this.K=new TreeVertex(i),this.U=new TreeVertex(i),this.wk=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Ii=this.Ii,t.ou=this.ou,t.Vg=this.Vg,t.Ve=this.Ve,t.qi=this.qi,t.Cs.c(this.Cs),t.K.copyInheritedPropertiesFrom(this.K),t.U.copyInheritedPropertiesFrom(this.U)}fi(t){t in TreeAlignment?this.alignment=t:t in TreeArrangement?this.arrangement=t:t in TreeCompaction?this.compaction=t:t in TreePath?this.path=t:t in TreeSorting?this.sorting=t:t in TreeStyle?this.treeStyle=t:super.fi(t)}createNetwork(){return new TreeNetwork(this)}makeNetwork(t){const i=this.createNetwork(),e=s=>{if(s instanceof Node)return!s.isLinkLabel&&s.category!=="Comment";if(s instanceof Link){const n=s.fromNode;if(n===null||n.isLinkLabel||n.category==="Comment")return!1;const o=s.toNode;return!(o===null||o.isLinkLabel||o.category==="Comment")}return!1};return t instanceof Diagram?(i.addParts(t.nodes,!0,e),i.addParts(t.links,!0,e)):t instanceof Group?i.addParts(t.memberParts,!1,e):i.addParts(t.iterator,!1,e),i}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.network===null&&(this.network=this.makeNetwork(t)),this.arrangement!==52&&(this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin));let i=this.diagram;i===null&&t instanceof Diagram&&(i=t),this.path===0&&i!==null?this.ds=i.isTreePathToChildren?1:2:this.ds=this.path===0?1:this.path,this.network.vertexes.count>0&&(this.O3(),this.E3(),this.B3(),this.V3(),this.YN(),this.z3(),this.arrangeTrees(),this.updateParts()),this.network=null,this.Ei=new GSet,this.isValidLayout=!0}O3(){this.network.deleteSelfEdges();const t=this.network.vertexes.iterator;for(;t.next();){const n=t.value;n.initialized=!1,n.level=0,n.parent=null,n.children=[]}if(this.Ei.count>0){const n=new GSet,o=this.Ei.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=this.network.findVertex(r);l!==null&&n.add(l)}else r instanceof TreeVertex&&n.add(r)}this.Ei=n}this.Ei.count===0&&this.findRoots();const i=this.Ei.copy().iterator;for(;i.next();){const n=i.value;n.initialized||(n.initialized=!0,this.vN(n))}let e=this.network.vertexes,s=null;for(;s=this.X3(e),s.count>0;){const n=this.SD(s);n!==null&&this.Ei.add(n),n.initialized=!0,this.vN(n),e=s}}X3(t){const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;s.initialized||i.add(s)}return i}findRoots(){const t=this.network.vertexes,i=t.iterator;for(;i.next();){const e=i.value;switch(this.ds){case 1:e.sourceEdges.count===0&&this.Ei.add(e);break;case 2:e.destinationEdges.count===0&&this.Ei.add(e);break;default:Util.n("Unhandled path value "+this.ds.toString())}}if(this.Ei.count===0){const e=this.SD(t);e!==null&&this.Ei.add(e)}}SD(t){let i=999999,e=null;const s=t.iterator;for(;s.next();){const n=s.value;switch(this.ds){case 1:n.sourceEdges.count0){const s=new List,n=t.destinationVertexes;for(;n.next();){const o=n.value;this.MD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;case 2:if(t.sourceEdges.count>0){const s=new List,n=t.sourceVertexes;for(;n.next();){const o=n.value;this.MD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;default:Util.n("Unhandled path value"+this.ds.toString())}const i=t.children,e=i.length;for(let s=0;st.level?!1:(this.K3(i.parent,i),!0):!0}Y3(t,i){if(i===null)return!1;Debug&&Util.s(t,TreeVertex,TreeLayout,"isAncestor:a"),Debug&&Util.s(i,TreeVertex,TreeLayout,"isAncestor:b");let e=i.parent;for(;e!==null&&e!==t;)e=e.parent;return e===t}K3(t,i){if(t===null||i===null)return;Debug&&Util.s(t,TreeVertex,TreeLayout,"removeChild:p"),Debug&&Util.s(i,TreeVertex,TreeLayout,"removeChild:c");const e=t.children;let s=0;for(let n=0;n0){const n=new Array(e.length-s);let o=0;for(let r=0;r0?s+1:0}U3(t){switch(Debug&&Util.s(t,TreeVertex,TreeLayout,"mom:v"),this.ou){default:case 40:return t.parent!==null?t.parent:this.K;case 43:return t.parent===null?this.K:t.parent.parent===null?this.U:t.parent;case 42:return t.parent!==null?t.parent.parent!==null?t.parent.parent:this.U:this.K;case 41:{let i=!0;if(t.childrenCount===0)i=!1;else{const e=t.children,s=e.length;for(let n=0;n0){i=!1;break}}return i&&t.parent!==null?this.U:t.parent!==null?t.parent:this.K}}}initializeTreeVertexValues(t){Debug&&Util.s(t,TreeVertex,TreeLayout,"initializeTreeVertexValues:v");const i=this.U3(t);if(t.copyInheritedPropertiesFrom(i),t.parent!==null&&t.parent.alignment===25){let e=t.angle;const s=t.parent.children;let n=0;for(;n135&&!l||a&&c)if(t.commentMargin>=0){g.e(t.bounds.x-t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleLeft,S.toSpot=Spot.MiddleRight}}else{g.e(t.bounds.x+t.focus.x*2-t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleRight,S.toSpot=Spot.MiddleLeft}}else if(t.commentMargin>=0){g.e(t.bounds.x+t.focus.x*2+t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleRight,S.toSpot=Spot.MiddleLeft}}else{g.e(t.bounds.x+t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleLeft,S.toSpot=Spot.MiddleRight}}t.commentSpacing>=0?u+=k.height+t.commentSpacing:u+=t.commentSpacing-k.height}else{if(o>135&&!l||!a&&c)if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y-t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleTop,S.toSpot=Spot.MiddleBottom}}else{g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2-t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleBottom,S.toSpot=Spot.MiddleTop}}else if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2+t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleBottom,S.toSpot=Spot.MiddleTop}}else{g.e(t.bounds.x+u,t.bounds.y+t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleTop,S.toSpot=Spot.MiddleBottom}}t.commentSpacing>=0?u+=k.width+t.commentSpacing:u+=t.commentSpacing-k.width}}Point.o(g);const p=u-t.commentSpacing-(h?e.height:e.width);if(this.ds===1){const y=t.destinationEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.fromEndSegmentLength=p>0?p:NaN)}}else{const y=t.sourceEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.toEndSegmentLength=p>0?p:NaN)}}}}z3(){if(this.layerStyle===62){const i=[];let e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;let n=s.parent;n===null&&(n=s);const o=n.angle===0||n.angle===180;let r=i[s.level];r===void 0&&(r=0),i[s.level]=Math.max(r,o?s.width:s.height)}for(let s=0;s=0)for(let o=0;o135&&n.reverse(),this.iw(r))if(o>1)for(let R=0;R0&&P>0&&M+u+O.width>f&&(M135?-b-g:b+g);const V=P===0?m:u;this.xk(I,0,A),I.X.e(M+V,A),k=Math.max(k,M+V+O.width),b=Math.max(b,S+(C===0?0:g)+O.height),M+=V+O.width}else{f>0&&P>0&&A+u+O.height>f&&(A135?-k-g:k+g);const V=P===0?m:u;this.xk(I,M,0),I.X.e(M,A+V),b=Math.max(b,A+V+O.height),k=Math.max(k,S+(C===0?0:g)+O.width),A+=V+O.height}P++}C>0&&(e?(b+=Math.max(0,c),M0&&(h||this.ru(t,p,0,0,o-1),k+=p)):(k+=Math.max(0,c),A0&&(h||this.ru(t,0,p,0,o-1),b+=p)));let D=0,F=0;switch(r){case 20:e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;break;default:case 21:if(C>0)e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;else{const I=o;if(e){const O=n[0].X.x+n[0].yt.x,V=n[I-1].X.x+n[I-1].yt.x+n[I-1].focus.x*2;D+=O+(V-O)/2-t.focus.x-d/2}else{const O=n[0].X.y+n[0].yt.y,V=n[I-1].X.y+n[I-1].yt.y+n[I-1].focus.y*2;F+=O+(V-O)/2-t.focus.y-d/2}}break;case 22:e?(D-=d,k+=d):(F-=d,b+=d);break;case 23:e?(D+=k-t.width+d,k+=d):(F+=b-t.height+d,b+=d);break;case 24:case 25:e?o>1?D+=T+u/2-t.focus.x:D+=n[0].focus.x-t.focus.x+n[0].yt.x:o>1?F+=T+u/2-t.focus.y:F+=n[0].focus.y-t.focus.y+n[0].yt.y;break;case 26:e?D+=k+u/2-t.focus.x:F+=b+u/2-t.focus.y;break;case 27:break;case 28:const R=this.customAlignment(t,D,F,k,b);D=R[0],F=R[1],k=R[2],b=R[3];break}for(let R=0;R135?(a?-b:-I.kt.height)+I.yt.y-c:x+c+I.yt.y)):I.X.e(I.X.x+(i>135?(a?-k:-I.kt.width)+I.yt.x-c:y+c+I.yt.x),I.X.y+I.yt.y-F)}e?(k=this.ZN(t,k,D),D<0&&(D=0),i>135&&(F+=b+c),b=Math.max(Math.max(b,x),b+x+c)):(i>135&&(D+=k+c),k=Math.max(Math.max(k,y),k+y+c),b=this.$N(t,b,F),F<0&&(F=0)),t.yt.e(D,F),t.kt.e(k,b)}customAlignment(t,i,e,s,n){return[i,e,s,n]}LD(t,i,e,s,n,o){Debug&&Util.s(t,TreeVertex,TreeLayout,"layoutBusChildrenPosDir:v");const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.kt.width,o=p.kt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,f=this.orthoAngle(t)===90;let c=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.kt,k=c===0?0:h;if(f){const b=this.computeBusNodeSpacing(y)-l;y.X.e(e-(x.width+b),d+k),n=Math.max(n,x.width+b),o=Math.max(o,d+k+x.height),d+=k+x.height}else{const b=this.computeBusNodeSpacing(y)-l;y.X.e(u+k,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,u+k+x.width),u+=k+x.width}c++}c=0;const m=u,g=d;f?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.kt,x=this.computeBusLastRowSpacing(p,f?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(f){p.X.e(e+l/2-p.focus.x-p.yt.x,o+x);const k=e+l/2-p.focus.x-p.yt.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.max(g,d)+x+y.height),p.X.x<0&&(e=this.bk(t,p.X.x,!1,e,l))}else{p.X.e(n+x,e+l/2-p.focus.y-p.yt.y),n=Math.max(n,Math.max(m,u)+x+y.width);const k=e+l/2-p.focus.y-p.yt.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.X.y<0&&(e=this.bk(t,p.X.y,!0,e,l))}}return new Rect(e,0,n,o)}TD(t,i,e,s,n,o){Debug&&Util.s(t,TreeVertex,TreeLayout,"layoutBusChildrenNegDir:v");const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.kt.width,o=p.kt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,f=this.orthoAngle(t)===270;let c=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.kt,k=c===0?0:h;if(f){const b=this.computeBusNodeSpacing(y)-l;d-=k+x.height,y.X.e(e-(x.width+b),d),n=Math.max(n,x.width+b),o=Math.max(o,Math.abs(d))}else{const b=this.computeBusNodeSpacing(y)-l;u-=k+x.width,y.X.e(u,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,Math.abs(u))}c++}c=0;const m=u,g=d;f?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.kt,x=this.computeBusLastRowSpacing(p,f?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(f){p.X.e(e+l/2-p.focus.x-p.yt.x,-o-y.height-x);const k=e+l/2-p.focus.x-p.yt.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.abs(Math.min(g,d))+x+y.height),p.X.x<0&&(e=this.bk(t,p.X.x,!1,e,l))}else{p.X.e(-n-y.width-x,e+l/2-p.focus.y-p.yt.y),n=Math.max(n,Math.abs(Math.min(m,u))+x+y.width);const k=e+l/2-p.focus.y-p.yt.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.X.y<0&&(e=this.bk(t,p.X.y,!0,e,l))}}for(let p=0;ps&&(s=e+t.width),e<0&&(s-=e),s;case 22:return t.width>i?t.width:i;case 23:return t.focus.x*2>i?t.width:i+t.width-t.focus.x*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.width);return Math.max(t.width,o-n);case 26:return t.width-t.focus.x+t.nodeSpacing/2+i;case 27:return Math.max(t.width,t.focus.x+t.nodeSpacing/2+i);default:return i}}$N(t,i,e){switch(Debug&&Util.s(t,TreeVertex,TreeLayout,"calculateSubheight:v"),t.alignment){case 21:case 20:let s=i;return e+t.height>s&&(s=e+t.height),e<0&&(s-=e),s;case 22:return t.height>i?t.height:i;case 23:return t.focus.y*2>i?t.height:i+t.height-t.focus.y*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.height);return Math.max(t.height,o-n);case 26:return t.height-t.focus.y+t.nodeSpacing/2+i;case 27:return Math.max(t.height,t.focus.y+t.nodeSpacing/2+i);default:return i}}QN(t,i,e){switch(Debug&&Util.tt(t,TreeAlignment,"TreeAlignment"),t){case 20:i/=2,e/=2;break;case 21:i/=2,e/=2;break;case 22:i=0,e=0;break;case 23:break;default:Util.n("Unhandled alignment value "+t.toString())}return new Point(i,e)}rf(t,i,e,s,n,o){Debug&&Util.s(t,TreeVertex,TreeLayout,"shiftRelPosAlign:v"),Debug&&Util.tt(i,TreeAlignment,"TreeAlignment");const r=this.QN(i,e,s);this.ru(t,r.x,r.y,n,o)}ru(t,i,e,s,n){if(Debug&&Util.s(t,TreeVertex,TreeLayout,"shiftRelPos:v"),i===0&&e===0)return;const o=t.children;for(let r=s;r<=n;r++){const h=o[r].X;h.x+=i,h.y+=e}}xk(t,i,e){Debug&&(Util.s(t,TreeVertex,TreeLayout,"recordMidPoints:v"),Util.t(i,"number",TreeLayout,"recordMidPoints:x"),Util.t(e,"number",TreeLayout,"recordMidPoints:y"));const s=t.parent;switch(this.ds){case 1:{const n=t.sourceEdges;for(;n.next();){const o=n.value;o.fromVertex===s&&o.relativePoint.e(i,e)}break}case 2:{const n=t.destinationEdges;for(;n.next();){const o=n.value;o.toVertex===s&&o.relativePoint.e(i,e)}break}default:Util.n("Unhandled path value "+this.ds.toString())}}G3(t){if(Debug&&Util.s(t,TreeVertex,TreeLayout,"layoutTreeBlock:v"),t.childrenCount===0){const z=t.parent;let G=!1,q=0,j=21;z!==null&&(q=z.angle,j=z.alignment,G=this.isBusAlignment(j));const J=this.JN(t);t.X.e(0,0),t.kt.e(t.width,t.height),t.parent!==null&&t.comments!==null&&((q===180||q===270)&&!G||J)?q===180&&!G||(q===90||q===270)&&J?t.yt.e(t.width-t.focus.x*2,0):t.yt.e(0,t.height-t.focus.y*2):t.yt.e(0,0),t.zg=null,t.Xg=null;return}const i=this.orthoAngle(t),e=i===90||i===270;let s=0;const n=t.children,o=n.length;for(let z=0;z135&&n.reverse(),this.iw(r))if(o>1)for(let z=0;z0&&L>0&&P+u+q.width>f&&(P135?-k-m:k+m),this.xk(G,0,N);let j=0;if(L===0)S=G.zg,M=G.Xg,A=q.width,C=q.height,(S===null||M===null||i!==this.orthoAngle(G))&&(S=this.ge(2),M=this.ge(2),S[0].e(0,0),S[1].e(0,C),M[0].e(A,0),M[1].e(A,C));else{const J=Util.at(),Y=this.DD(t,G,S,M,A,C,J);j=Y.x,S=J[0],M=J[1],A=Y.width,C=Y.height,Util.nt(J),P0&&L>0&&N+u+q.height>f&&(N135?-x-m:x+m),this.xk(G,P,0);let j=0;if(L===0)S=G.zg,M=G.Xg,A=q.width,C=q.height,(S===null||M===null||i!==this.orthoAngle(G))&&(S=this.ge(2),M=this.ge(2),S[0].e(0,0),S[1].e(A,0),M[0].e(0,C),M[1].e(A,C));else{const J=Util.at(),Y=this.DD(t,G,S,M,A,C,J);j=Y.x,S=J[0],M=J[1],A=Y.width,C=Y.height,Util.nt(J),N0&&(e?(k+=Math.max(0,c),P0&&(h||this.ru(t,g,0,0,o-1),x+=g)):(x+=Math.max(0,c),N0&&(h||this.ru(t,0,g,0,o-1),k+=g)));let I=0,O=0;switch(r){case 20:e?I+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;break;default:case 21:if(T>0)e?I+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;else{const G=o;if(e){const q=n[0].X.x+n[0].yt.x,j=n[G-1].X.x+n[G-1].yt.x+n[G-1].focus.x*2;I+=q+(j-q)/2-t.focus.x-d/2}else{const q=n[0].X.y+n[0].yt.y,j=n[G-1].X.y+n[G-1].yt.y+n[G-1].focus.y*2;O+=q+(j-q)/2-t.focus.y-d/2}}break;case 22:e?(I-=d,x+=d):(O-=d,k+=d);break;case 23:e?(I+=x-t.width+d,x+=d):(O+=k-t.height+d,k+=d);break;case 24:e?o>1?I+=F+u/2-t.focus.x:I+=n[0].focus.x-t.focus.x+n[0].yt.x:o>1?O+=F+u/2-t.focus.y:O+=n[0].focus.y-t.focus.y+n[0].yt.y;break;case 26:e?I+=x+u/2-t.focus.x:O+=k+u/2-t.focus.y;break;case 27:break;case 28:const z=this.customAlignment(t,I,O,x,k);I=z[0],O=z[1],x=z[2],k=z[3];break}for(let z=0;z135?(a?-k:-G.kt.height)+G.yt.y-c:y+c+G.yt.y)):G.X.e(G.X.x+(i>135?(a?-x:-G.kt.width)+G.yt.x-c:p+c+G.yt.x),G.X.y+G.yt.y-O)}let V=0,K=0;if(a)e?(x=this.ZN(t,x,I),I<0&&(I=0),i>135&&(O+=k+c),k+=y+c,r===27&&(V+=u/2+t.focus.x),K+=y+c):(i>135&&(I+=x+c),x+=p+c,k=this.$N(t,k,O),O<0&&(O=0),r===27&&(K+=u/2+t.focus.y),V+=p+c);else if(e){if(t.comments===null){if(p>x){const z=this.QN(r,p-x,0);V=z.x,K=z.y,x=p,I=0}}else x=this.ZN(t,x,I);I<0&&(V-=I,I=0),i>135&&(O+=k+c),k=Math.max(Math.max(k,y),k+y+c),K+=y+c}else{if(i>135&&(I+=x+c),x=Math.max(Math.max(x,p),x+p+c),t.comments===null){if(y>k){const z=this.QN(r,0,y-k);V=z.x,K=z.y,k=y,O=0}}else k=this.$N(t,k,O);O<0&&(K-=O,O=0),V+=p+c}let B,X;if(T>0)B=this.ge(4),X=this.ge(4),e?(B[2].e(0,y+c),B[3].e(B[2].x,k),X[2].e(x,B[2].y),X[3].e(X[2].x,B[3].y)):(B[2].e(p+c,0),B[3].e(x,B[2].y),X[2].e(B[2].x,k),X[3].e(B[3].x,X[2].y));else{B=this.ge(S.length+2),X=this.ge(M.length+2);for(let z=0;zB[0].x?B[2].c(B[1]):B[1].c(B[2])),B[3].yB[0].x?B[3].c(B[2]):B[2].c(B[3])),X[0].e(I+p,0),X[1].e(X[0].x,y),X[2].yB[0].y?B[2].c(B[1]):B[1].c(B[2])),B[3].xB[0].y?B[3].c(B[2]):B[2].c(B[3])),X[0].e(0,O+y),X[1].e(p,X[0].y),X[2].xl;){const a=i[o++];s[r++].e(a.x,a.y+e)}const h=this.ge(r);for(n=0;nl;){const a=i[o++];s[r++].e(a.x+e,a.y)}const h=this.ge(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.ge(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.ge(r);for(n=0;nh&&r.xr.x&&ha&&r.yr.y&&a0){const n=Math.min(1,t.layerSpacingParentOverlap);s-=e?t.height*n:t.width*n}return s<(e?-t.height:-t.width)&&(s=e?-t.height:-t.width),s}computeNodeIndent(t){Debug&&Util.s(t,TreeVertex,TreeLayout,"computeNodeIndent:v");const i=this.orthoAngle(t),e=i===90||i===270;let s=t.nodeIndent;if(t.nodeIndentPastParent>0){const n=Math.min(1,t.nodeIndentPastParent);s+=e?t.width*n:t.height*n}return s=Math.max(0,s),s}get roots(){return this.Ei}set roots(t){this.Ei!==t&&(Util.s(t,GSet,TreeLayout,"roots"),this.Ei=t,this.invalidateLayout())}get path(){return this.Ii}set path(t){this.Ii!==t&&(Util.tt(t,TreePath,"TreePath"),this.Ii=t,this.invalidateLayout())}get treeStyle(){return this.ou}set treeStyle(t){this.ou!==t&&(Util.tt(t,TreeStyle,"TreeStyle"),(t===40||t===42||t===41||t===43)&&(this.ou=t,this.invalidateLayout()))}get layerStyle(){return this.Vg}set layerStyle(t){this.Vg!==t&&(Util.tt(t,TreeLayerStyle,"TreeLayerStyle"),(t===60||t===61||t===62)&&(this.Vg=t,this.invalidateLayout()))}get comments(){return this.Ve}set comments(t){this.Ve!==t&&(Util.t(t,"boolean",TreeLayout,"comments"),this.Ve=t,this.invalidateLayout())}get arrangement(){return this.qi}set arrangement(t){this.qi!==t&&(Util.tt(t,TreeArrangement,"TreeArrangement"),(t===50||t===51||t===52)&&(this.qi=t,this.invalidateLayout()))}get arrangementSpacing(){return this.Cs}set arrangementSpacing(t){Util.s(t,Size,TreeLayout,"arrangementSpacing"),this.Cs.equals(t)||(this.Cs.c(t),this.invalidateLayout())}get rootDefaults(){return this.K}set rootDefaults(t){this.K!==t&&(Util.s(t,TreeVertex,TreeLayout,"rootDefaults"),this.K=t,this.invalidateLayout())}get alternateDefaults(){return this.U}set alternateDefaults(t){this.U!==t&&(Util.s(t,TreeVertex,TreeLayout,"alternateDefaults"),this.U=t,this.invalidateLayout())}get sorting(){return this.K.sorting}set sorting(t){this.K.sorting!==t&&(Util.tt(t,TreeSorting,"TreeSorting"),this.K.sorting=t,this.invalidateLayout())}get comparer(){return this.K.comparer}set comparer(t){this.K.comparer!==t&&(Util.t(t,"function",TreeLayout,"comparer"),this.K.comparer=t,this.invalidateLayout())}get angle(){return this.K.angle}set angle(t){this.K.angle!==t&&(Util.t(t,"number",TreeLayout,"angle"),t===0||t===90||t===180||t===270?(this.K.angle=t,this.invalidateLayout()):Util.n("TreeLayout.angle must be 0, 90, 180, or 270"))}get alignment(){return this.K.alignment}set alignment(t){this.K.alignment!==t&&(Util.tt(t,TreeAlignment,"TreeAlignment"),this.K.alignment=t,this.invalidateLayout())}get nodeIndent(){return this.K.nodeIndent}set nodeIndent(t){this.K.nodeIndent!==t&&(Util.t(t,"number",TreeLayout,"nodeIndent"),t>=0&&(this.K.nodeIndent=t,this.invalidateLayout()))}get nodeIndentPastParent(){return this.K.nodeIndentPastParent}set nodeIndentPastParent(t){this.K.nodeIndentPastParent!==t&&(Util.t(t,"number",TreeLayout,"nodeIndentPastParent"),t>=0&&t<=1&&(this.K.nodeIndentPastParent=t,this.invalidateLayout()))}get nodeSpacing(){return this.K.nodeSpacing}set nodeSpacing(t){this.K.nodeSpacing!==t&&(Util.t(t,"number",TreeLayout,"nodeSpacing"),this.K.nodeSpacing=t,this.invalidateLayout())}get layerSpacing(){return this.K.layerSpacing}set layerSpacing(t){this.K.layerSpacing!==t&&(Util.t(t,"number",TreeLayout,"layerSpacing"),this.K.layerSpacing=t,this.invalidateLayout())}get layerSpacingParentOverlap(){return this.K.layerSpacingParentOverlap}set layerSpacingParentOverlap(t){this.K.layerSpacingParentOverlap!==t&&(Util.t(t,"number",TreeLayout,"layerSpacingParentOverlap"),t>=0&&t<=1&&(this.K.layerSpacingParentOverlap=t,this.invalidateLayout()))}get compaction(){return this.K.compaction}set compaction(t){this.K.compaction!==t&&(Util.tt(t,TreeCompaction,"TreeCompaction"),(t===30||t===31)&&(this.K.compaction=t,this.invalidateLayout()))}get breadthLimit(){return this.K.breadthLimit}set breadthLimit(t){this.K.breadthLimit!==t&&(Util.t(t,"number",TreeLayout,"breadthLimit"),t>=0&&(this.K.breadthLimit=t,this.invalidateLayout()))}get rowSpacing(){return this.K.rowSpacing}set rowSpacing(t){this.K.rowSpacing!==t&&(Util.t(t,"number",TreeLayout,"rowSpacing"),this.K.rowSpacing=t,this.invalidateLayout())}get rowIndent(){return this.K.rowIndent}set rowIndent(t){this.K.rowIndent!==t&&(Util.t(t,"number",TreeLayout,"rowIndent"),t>=0&&(this.K.rowIndent=t,this.invalidateLayout()))}get commentSpacing(){return this.K.commentSpacing}set commentSpacing(t){this.K.commentSpacing!==t&&(Util.t(t,"number",TreeLayout,"commentSpacing"),this.K.commentSpacing=t,this.invalidateLayout())}get commentMargin(){return this.K.commentMargin}set commentMargin(t){this.K.commentMargin!==t&&(Util.t(t,"number",TreeLayout,"commentMargin"),this.K.commentMargin=t,this.invalidateLayout())}get setsPortSpot(){return this.K.setsPortSpot}set setsPortSpot(t){this.K.setsPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"setsPortSpot"),this.K.setsPortSpot=t,this.invalidateLayout())}get portSpot(){return this.K.portSpot}set portSpot(t){Util.s(t,Spot,TreeLayout,"portSpot"),this.K.portSpot.equals(t)||(this.K.portSpot=t,this.invalidateLayout())}get setsChildPortSpot(){return this.K.setsChildPortSpot}set setsChildPortSpot(t){this.K.setsChildPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"setsChildPortSpot"),this.K.setsChildPortSpot=t,this.invalidateLayout())}get childPortSpot(){return this.K.childPortSpot}set childPortSpot(t){Util.s(t,Spot,TreeLayout,"childPortSpot"),this.K.childPortSpot.equals(t)||(this.K.childPortSpot=t,this.invalidateLayout())}get alternateSorting(){return this.U.sorting}set alternateSorting(t){this.U.sorting!==t&&(Util.tt(t,TreeSorting,"TreeSorting"),this.U.sorting=t,this.invalidateLayout())}get alternateComparer(){return this.U.comparer}set alternateComparer(t){this.U.comparer!==t&&(Util.t(t,"function",TreeLayout,"alternateComparer"),this.U.comparer=t,this.invalidateLayout())}get alternateAngle(){return this.U.angle}set alternateAngle(t){this.U.angle!==t&&(Util.t(t,"number",TreeLayout,"alternateAngle"),(t===0||t===90||t===180||t===270)&&(this.U.angle=t,this.invalidateLayout()))}get alternateAlignment(){return this.U.alignment}set alternateAlignment(t){this.U.alignment!==t&&(Util.tt(t,TreeAlignment,"TreeAlignment"),this.U.alignment=t,this.invalidateLayout())}get alternateNodeIndent(){return this.U.nodeIndent}set alternateNodeIndent(t){this.U.nodeIndent!==t&&(Util.t(t,"number",TreeLayout,"alternateNodeIndent"),t>=0&&(this.U.nodeIndent=t,this.invalidateLayout()))}get alternateNodeIndentPastParent(){return this.U.nodeIndentPastParent}set alternateNodeIndentPastParent(t){this.U.nodeIndentPastParent!==t&&(Util.t(t,"number",TreeLayout,"alternateNodeIndentPastParent"),t>=0&&t<=1&&(this.U.nodeIndentPastParent=t,this.invalidateLayout()))}get alternateNodeSpacing(){return this.U.nodeSpacing}set alternateNodeSpacing(t){this.U.nodeSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateNodeSpacing"),this.U.nodeSpacing=t,this.invalidateLayout())}get alternateLayerSpacing(){return this.U.layerSpacing}set alternateLayerSpacing(t){this.U.layerSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateLayerSpacing"),this.U.layerSpacing=t,this.invalidateLayout())}get alternateLayerSpacingParentOverlap(){return this.U.layerSpacingParentOverlap}set alternateLayerSpacingParentOverlap(t){this.U.layerSpacingParentOverlap!==t&&(Util.t(t,"number",TreeLayout,"alternateLayerSpacingParentOverlap"),t>=0&&t<=1&&(this.U.layerSpacingParentOverlap=t,this.invalidateLayout()))}get alternateCompaction(){return this.U.compaction}set alternateCompaction(t){this.U.compaction!==t&&(Util.tt(t,TreeCompaction,"TreeCompaction"),(t===30||t===31)&&(this.U.compaction=t,this.invalidateLayout()))}get alternateBreadthLimit(){return this.U.breadthLimit}set alternateBreadthLimit(t){this.U.breadthLimit!==t&&(Util.t(t,"number",TreeLayout,"alternateBreadthLimit"),t>=0&&(this.U.breadthLimit=t,this.invalidateLayout()))}get alternateRowSpacing(){return this.U.rowSpacing}set alternateRowSpacing(t){this.U.rowSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateRowSpacing"),this.U.rowSpacing=t,this.invalidateLayout())}get alternateRowIndent(){return this.U.rowIndent}set alternateRowIndent(t){this.U.rowIndent!==t&&(Util.t(t,"number",TreeLayout,"alternateRowIndent"),t>=0&&(this.U.rowIndent=t,this.invalidateLayout()))}get alternateCommentSpacing(){return this.U.commentSpacing}set alternateCommentSpacing(t){this.U.commentSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateCommentSpacing"),this.U.commentSpacing=t,this.invalidateLayout())}get alternateCommentMargin(){return this.U.commentMargin}set alternateCommentMargin(t){this.U.commentMargin!==t&&(Util.t(t,"number",TreeLayout,"alternateCommentMargin"),this.U.commentMargin=t,this.invalidateLayout())}get alternateSetsPortSpot(){return this.U.setsPortSpot}set alternateSetsPortSpot(t){this.U.setsPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"alternateSetsPortSpot"),this.U.setsPortSpot=t,this.invalidateLayout())}get alternatePortSpot(){return this.U.portSpot}set alternatePortSpot(t){Util.s(t,Spot,TreeLayout,"alternatePortSpot"),this.U.portSpot.equals(t)||(this.U.portSpot=t,this.invalidateLayout())}get alternateSetsChildPortSpot(){return this.U.setsChildPortSpot}set alternateSetsChildPortSpot(t){this.U.setsChildPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"alternateSetsChildPortSpot"),this.U.setsChildPortSpot=t,this.invalidateLayout())}get alternateChildPortSpot(){return this.U.childPortSpot}set alternateChildPortSpot(t){Util.s(t,Spot,TreeLayout,"alternateChildPortSpot"),this.U.childPortSpot.equals(t)||(this.U.childPortSpot=t,this.invalidateLayout())}static PathDefault=0;static PathDestination=1;static PathSource=2;static SortingForwards=10;static SortingReverse=11;static SortingAscending=12;static SortingDescending=13;static AlignmentCenterSubtrees=20;static AlignmentCenterChildren=21;static AlignmentStart=22;static AlignmentEnd=23;static AlignmentBus=24;static AlignmentBusBranching=25;static AlignmentTopLeftBus=26;static AlignmentBottomRightBus=27;static CompactionNone=30;static CompactionBlock=31;static StyleLayered=40;static StyleLastParents=41;static StyleAlternating=42;static StyleRootOnly=43;static ArrangementVertical=50;static ArrangementHorizontal=51;static ArrangementFixedRoots=52;static LayerIndividual=60;static LayerSiblings=61;static LayerUniform=62}class TreeNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new TreeVertex(this)}createEdge(){return new TreeEdge(this)}}class TreeVertex extends LayoutVertex{X;kt;yt;Sk;Mk;Pk;Nk;Ck;Ak;Lk;Ve;zg;Xg;ke;Se;jt;ai;ew;sw;nw;As;ow;rw;lw;hw;aw;fw;cw;uw;dw;gw;mw;constructor(t){super(t),this.Sk=!1,this.Mk=null,this.Pk=[],this.Nk=0,this.Ck=0,this.Ak=0,this.Lk=0,this.Ve=null,this.X=new Point(0,0),this.kt=new Size(0,0),this.yt=new Point(0,0),this.zg=null,this.Xg=null,this.ke=10,this.Se=LayoutVertex.standardComparer,this.jt=0,this.ai=21,this.ew=0,this.sw=0,this.nw=20,this.As=50,this.ow=0,this.rw=31,this.lw=0,this.hw=25,this.aw=10,this.fw=10,this.cw=20,this.uw=!0,this.dw=Spot.Default,this.gw=!0,this.mw=Spot.Default}copyInheritedPropertiesFrom(t){t!==null&&(this.ke=t.sorting,this.Se=t.comparer,this.jt=t.angle,this.ai=t.alignment,this.ew=t.nodeIndent,this.sw=t.nodeIndentPastParent,this.nw=t.nodeSpacing,this.As=t.layerSpacing,this.ow=t.layerSpacingParentOverlap,this.rw=t.compaction,this.lw=t.breadthLimit,this.hw=t.rowSpacing,this.aw=t.rowIndent,this.fw=t.commentSpacing,this.cw=t.commentMargin,this.uw=t.setsPortSpot,this.dw=t.portSpot,this.gw=t.setsChildPortSpot,this.mw=t.childPortSpot)}get initialized(){return this.Sk}set initialized(t){this.Sk!==t&&(Util.t(t,"boolean",TreeVertex,"initialized"),this.Sk=t)}get parent(){return this.Mk}set parent(t){this.Mk!==t&&(Debug&&t!==null&&Util.s(t,TreeVertex,TreeVertex,"parent"),this.Mk=t)}get children(){return this.Pk}set children(t){if(this.Pk!==t){if(t!==null&&!Array.isArray(t)&&Util.Bi(t,"Array",TreeVertex,"children:value"),t!==null){const i=t.length;for(let e=0;e4;)t.removePoint(2);u=t.getPoint(1),d=t.getPoint(2)}else{for(c=1;t.pointsCount>3;)t.removePoint(1);u=t.getPoint(0),d=t.getPoint(t.pointsCount-1)}const m=t.getPoint(t.pointsCount-1);let g=0;r===0?(e.alignment===23?(g=o.bottom+n.y,n.y===0&&u.y>m.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.xm.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.x{const i=t.matches?"dark":"light";i!==this.Yg&&(this.Yg=i,this.Fk==="system"&&this.pw())};constructor(t){t&&Object.assign(this,t),t?.themeMap||(this.lu.set("light",{colors:{...Themes.Light.colors},fonts:{...Themes.Light.fonts},numbers:{...Themes.Light.numbers},margins:{...Themes.Light.margins},arrowheads:{...Themes.Light.arrowheads}}),this.lu.set("dark",{colors:{...Themes.Dark.colors},fonts:{...Themes.Dark.fonts},numbers:{...Themes.Dark.numbers},margins:{...Themes.Dark.margins},arrowheads:{...Themes.Dark.arrowheads}})),root.matchMedia&&(this.Yg=root.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}get themeMap(){return this.lu}set themeMap(t){this.lu!==t&&(this.lu=t,this.pw())}get defaultTheme(){return this.Dk}set defaultTheme(t){this.Dk!==t&&(Util.t(t,"string",ThemeManager,"defaultTheme"),this.Dk=t,this.pw())}get currentTheme(){return this.Fk}set currentTheme(t){this.Fk!==t&&(Util.t(t,"string",ThemeManager,"currentTheme"),this.Fk=t,this.pw())}get changesDivBackground(){return this.Rk}set changesDivBackground(t){if(this.Rk!==t&&(this.Rk=t,t))for(const e of this.ls)e.setDivBackground(this.findValue("div","","fill")),e.B("ThemeChanged",this)}get preferredColorScheme(){return this.Yg}addDiagram(t){return this.ls.add(t),this.tC(t),this}removeDiagram(t){return this.ls.delete(t),this.tC(t),this}WF(){this.ls.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.addEventListener("change",this.RD)}vF(){this.ls.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.removeEventListener("change",this.RD)}set(t,i){t===""&&(t=this.Dk),t==="system"&&(t=this.Yg);let e=this.lu.get(t);return e?e=this.ID(e,i):e=i,this.lu.set(t,e),this.pw(),this}findValue(t,i,e){return this.getValue(this.findTheme(this.currentTheme),t,i,e)||this.getValue(this.findTheme(this.defaultTheme),t,i,e)}getValue(t,i,e,s){if(!t)return;e==null&&(e="");let n=t;const o=l=>{if(n===void 0||l==="")return;if(typeof l=="number"||!(Array.isArray(l)||l.includes(".")))return n[l];const h=Array.isArray(l)?l:l.split(".");for(let a=0;a{if(!(e!==""&&(n=o(e),n===void 0)))return Array.isArray(n)&&typeof i=="number"?n=n[i%n.length]:n=o(i),n};if(n=r(),n===void 0&&typeof s=="string"&&s.length>0){let l=t.targetPropertyMap?.get(s);if(l?n=t[l]:(l=ThemeManager.Q3.get(s),n=l?t[l]:t.colors),n=r(),n!==void 0)return n}return n}findTheme(t){return this.themeMap.get(t==="system"?this.Yg:t)}tC(t){const i=t.skipsUndoManager;t.skipsUndoManager=!0,t.updateAllThemeBindings(),this.Rk&&t.setDivBackground(this.findValue("div","","fill")),t.skipsUndoManager=i,t.B("ThemeChanged",this)}pw(){for(const t of this.ls)this.tC(t)}ID(t,i){for(const e in i)if(Util.yw(i,e))try{i[e].constructor===Object?t[e]=this.ID(t[e]??{},i[e]):t[e]=i[e]}catch{delete t[e]}return t}static Q3=new Map([["background","colors"],["defaultColumnSeparatorStroke","colors"],["defaultRowSeparatorStroke","colors"],["shadowColor","colors"],["fill","colors"],["stroke","colors"],["font","fonts"],["angle","numbers"],["fromEndSegmentLength","numbers"],["fromShortLength","numbers"],["height","numbers"],["opacity","numbers"],["scale","numbers"],["toEndSegmentLength","numbers"],["toShortLength","numbers"],["width","numbers"],["defaultColumnSeparatorStrokeWidth","numbers"],["defaultRowSeparatorStrokeWidth","numbers"],["shadowBlur","numbers"],["corner","numbers"],["curviness","numbers"],["smoothness","numbers"],["parameter1","numbers"],["parameter2","numbers"],["strokeWidth","numbers"],["strokeDashOffset","numbers"],["maxLines","numbers"],["spacingAbove","numbers"],["spacingBelow","numbers"],["position","points"],["shadowOffset","points"],["desiredSize","sizes"],["maxSize","sizes"],["minSize","sizes"],["margin","margins"],["defaultSeparatorPadding","margins"],["padding","margins"],["alignment","spots"],["alignmentFocus","spots"],["fromSpot","spots"],["toSpot","spots"],["defaultAlignment","spots"],["spot1","spots"],["spot2","spots"],["verticalAlignment","spots"],["imageAlignment","spots"],["fromArrow","arrowheads"],["toArrow","arrowheads"]])}class Router{Tt;b;Xi;pl;constructor(){this.b=Diagram.Sm(),this.Tt="",this.Xi=!0,this.pl=!0}get name(){return this.Tt}set name(t){this.Tt=t}get isEnabled(){return this.Xi}set isEnabled(t){this.Xi=t}get isRealtime(){return this.pl}set isRealtime(t){this.pl=t}get diagram(){return this.b}set diagram(t){this.b!==t&&(this.b=t,t.Pl=!0,t.requestUpdate())}invalidateRouter(){this.b!==null&&(this.b.Pl=!0,this.b.requestUpdate())}canRoute(t){if(!this.isEnabled)return!1;const i=this.diagram;return!(i&&(!this.isRealtime&&i.Mu||i.animationManager.isTicking))}routeLinks(t,i){}toString(){return this.name!==""?this.name+" Router":Util.hn(this.constructor)}}class AvoidsNodesRouter extends Router{constructor(t){super(),this.name="AvoidsNodes",t&&Object.assign(this,t)}canRoute(t){return(t instanceof Diagram?t.Zm:t.diagram.Zm)?super.canRoute(t):!1}routeLinks(t,i){i=i instanceof Diagram?null:i;const e=t.iterator,s=this.diagram.getPositions(!0,i,null);for(;e.next();){const n=e.value;if(!n.isAvoiding||i&&n.containingGroup!==i||n.toNode===null||n.fromNode===null||n.pointsCount<4)continue;n.startRoute();const o=n.pointsCount,r=n.getPoint(1),l=n.getPoint(o-2),h=n.fromNode.actualBounds.copy();h.inflate(Link.Xa,Link.Xa),h.unionPoint(n.getPoint(0));const a=n.toNode.actualBounds.copy();a.inflate(Link.Xa,Link.Xa),a.unionPoint(n.getPoint(o-1)),this._3(n,h,a,s)&&this.tE(n,r,n.aN,l,n.fN,h,a,s),n.commitRoute()}}_3(t,i,e,s){const n=t.diagram,o=t.pointsCount;if(n===null||t.fromNode===t.toNode||t.layer.isTemporary||i.containsPoint(t.getPoint(o-1))&&!t.toNode.isMemberOf(t.fromNode)||e.containsPoint(t.getPoint(0))&&!t.fromNode.isMemberOf(t.toNode)||!t.isOrthogonal)return!1;if(t.segmentIndex===17)return!0;const r=t.getPoint(1),l=t.getPoint(o-2),h=t.getPoint(2);if(!s.isUnoccupied(Math.min(r.x,h.x),Math.min(r.y,h.y),Math.abs(r.x-h.x),Math.abs(r.y-h.y)))return!0;for(let f=2;f=PositionArray.Hd&&(l.WA(),d.inflate(l.cellWidth*l.KP,l.cellHeight*l.UP),l.mT(i,e,s,n,d,!1),m=l.wo(s.x,s.y)),!l.Cy&&mPositionArray.Ga&&i.wo(g,p)!==u-1&&(i.wo(d-f,m)===u-1?(n=180,g=d-f,p=m):i.wo(d+f,m)===u-1?(n=0,g=d+f,p=m):i.wo(d,m-c)===u-1?(n=270,g=d,p=m-c):i.wo(d,m+c)===u-1&&(n=90,g=d,p=m+c));u>PositionArray.Ga&&i.wo(g,p)===u-1;)d=g,m=p,n===0?g+=f:n===90?p+=c:n===180?g-=f:p-=c,u-=1;if(o?u>PositionArray.Ga&&(n===180||n===0?d=Math.floor(d/f)*f+f/2:(n===90||n===270)&&(m=Math.floor(m/c)*c+c/2)):(d=Math.floor(d/f)*f+f/2,m=Math.floor(m/c)*c+c/2),u>PositionArray.Ga){let y=n,x=d,k=m;if(n===0?(y=90,k+=c):n===90?(y=180,x-=f):n===180?(y=270,k-=c):n===270&&(y=0,x+=f),i.wo(x,k)===u-1)this.iC(t,i,x,k,y,!1);else{let S=d,M=m;n===0?(y=270,M-=c):n===90?(y=0,S+=f):n===180?(y=90,M+=c):n===270&&(y=180,S-=f),i.wo(S,M)===u-1&&this.iC(t,i,S,M,y,!1)}}t.insertPointAt(t.pointsCount-2,d,m)}}ToolManager.prototype.initializeStandardTools=function(){this.ti("Action",new ActionTool,this.mouseDownTools),this.ti("Relinking",new RelinkingTool,this.mouseDownTools),this.ti("LinkReshaping",new LinkReshapingTool,this.mouseDownTools),this.ti("Rotating",new RotatingTool,this.mouseDownTools),this.ti("Resizing",new ResizingTool,this.mouseDownTools),this.ti("Linking",new LinkingTool,this.mouseMoveTools),this.ti("Dragging",new DraggingTool,this.mouseMoveTools),this.ti("DragSelecting",new DragSelectingTool,this.mouseMoveTools),this.ti("Panning",new PanningTool,this.mouseMoveTools),this.ti("ContextMenu",new ContextMenuTool,this.mouseUpTools),this.ti("TextEditing",new TextEditingTool,this.mouseUpTools),this.ti("ClickCreating",new ClickCreatingTool,this.mouseUpTools),this.ti("ClickSelecting",new ClickSelectingTool,this.mouseUpTools)},Diagram.SP("GraphLinksModel",GraphLinksPartManager),Diagram.SP("TreeModel",TreePartManager);const oldGo=root.go,go={get version(){return Diagram.version},Group,List,Set:GSet,Map:GMap,Point,Size,Rect,Margin,Spot,Geometry,PathFigure,PathSegment,InputEvent,DiagramEvent,ChangedEvent,Model,GraphLinksModel,TreeModel,Binding,ThemeBinding,Transaction,UndoManager,CommandHandler,Tool,DraggingTool,DraggingInfo,DraggingOptions,LinkingBaseTool,LinkingTool,RelinkingTool,LinkReshapingTool,ResizingTool,RotatingTool,ClickSelectingTool,ActionTool,ClickCreatingTool,HTMLInfo,ContextMenuTool,DragSelectingTool,PanningTool,TextEditingTool,ToolManager,Animation,AnimationManager,AnimationTrigger,Layer,Diagram,Palette,Overview,Brush,GraphObject,Panel,RowColumnDefinition,Shape,TextBlock,Picture,Part,Adornment,Node,Link,Placeholder,Layout,LayoutNetwork,LayoutVertex,LayoutEdge,GridLayout,PanelLayout,CircularLayout,CircularNetwork,CircularVertex,CircularEdge,ForceDirectedLayout,ForceDirectedNetwork,ForceDirectedVertex,ForceDirectedEdge,LayeredDigraphLayout,LayeredDigraphNetwork,LayeredDigraphVertex,LayeredDigraphEdge,TreeLayout,TreeNetwork,TreeVertex,TreeEdge,Themes,ThemeManager,Router,AnimationStyle,AutoScale,CycleMode,Flip,TextFormat,ImageStretch,LayoutConditions,LinkAdjusting,Curve,Routing,Orientation,TextOverflow,PortSpreading,ScrollMode,CollapsePolicy,Sizing,TriggerStart,Stretch,ViewboxStretch,Wrap,BrushType,ColorSpace,GeometryStretch,GeometryType,SegmentType,BindingMode,ChangeType,CircularArrangement,CircularDirection,CircularNodeDiameterFormula,CircularSorting,GridAlignment,GridArrangement,GridSorting,LayeredDigraphAggressive,LayeredDigraphAlign,LayeredDigraphCycleRemove,LayeredDigraphInit,LayeredDigraphLayering,LayeredDigraphPack,TreeAlignment,TreeArrangement,TreeCompaction,TreeLayerStyle,TreePath,TreeSorting,TreeStyle,GestureMode,LinkingDirection,ReshapingBehavior,TextEditingAccept,TextEditingStarting,TextEditingState,WheelMode};typeof oldGo=="object"&&oldGo.version&&Util.ht("WARNING: a `go` object on the root object is already defined. "+("Debug"in oldGo?"debug ":"")+"version: "+oldGo.version+", replaced with version: "+go.version),Diagram.prototype.go=go,root.go=go,go.Debug=Debug,Debug.attachReadonlyWarnings(go); })(); "function"===typeof define&&define.amd&&define("undefined"!==typeof global?global.go:self.go); 'undefined'!==typeof module&&'object'===typeof module.exports&&(module.exports='undefined'!==typeof global?global.go:self.go); diff --git a/release/go-debug.mjs b/release/go-debug.mjs index 37a7e5a7a..614e1a749 100644 --- a/release/go-debug.mjs +++ b/release/go-debug.mjs @@ -1,62 +1,62 @@ /* - * GoJS v3.0.11 JavaScript Library for HTML Diagrams, https://gojs.net + * GoJS v3.0.12 JavaScript Library for HTML Diagrams, https://gojs.net * GoJS and Northwoods Software are registered trademarks of Northwoods Software Corporation, https://nwoods.com. * Copyright (C) 1998-2024 by Northwoods Software Corporation. All Rights Reserved. - * THIS SOFTWARE IS LICENSED. THE LICENSE AGREEMENT IS AT: https://gojs.net/3.0.11/license.html. + * THIS SOFTWARE IS LICENSED. THE LICENSE AGREEMENT IS AT: https://gojs.net/3.0.12/license.html. * DO NOT MODIFY THIS FILE. DO NOT DISTRIBUTE A MODIFIED COPY OF THE CONTENTS OF THIS FILE. */ -(function() {const root=typeof globalThis=="object"&&globalThis||typeof global=="object"&&global.global===global&&global||typeof self=="object"&&self.self===self&&self||{};root.requestAnimationFrame===void 0&&(root.setImmediate===void 0?root.requestAnimationFrame=w=>root.setTimeout(w,0):root.requestAnimationFrame=root.setImmediate);const Debug={boundsInfoEnabled:!1,drawLocationsEnabled:!1,drawClipEnabled:!1,drawLinkpointsEnabled:!1,nodeInspector:!1,handleMessages:!1,drawFrames:!1,defaultDiagram:null,trace:function(w){root.console&&root.console.log(w)},drawDiagramBounds(w,t,i,e){w.strokeStyle="red",w.fillStyle="red",w.font="8px sans-serif",w.beginPath(),w.moveTo(-10,0),w.lineTo(10,0),w.moveTo(0,-10),w.lineTo(0,10),w.stroke(),w.setTransform(1,0,0,1,0,0),w.scale(i,i),w.transform(t.m11,t.m12,t.m21,t.m22,t.dx,t.dy),w.lineWidth=2,w.beginPath(),w.moveTo(e.left,e.top+20),w.lineTo(e.left,e.top),w.lineTo(e.left+20,e.top),w.moveTo(e.right,e.bottom-20),w.lineTo(e.right,e.bottom),w.lineTo(e.right-20,e.bottom),w.stroke(),w.fillText("DB: "+Math.round(e.x)+", "+Math.round(e.y)+", "+Math.round(e.width)+", "+Math.round(e.height),e.left,e.top-5)},attachReadonlyWarnings:function(w){for(const t in w){if(t==="licenseKey")continue;const i=w[t];if(i.prototype===void 0)continue;const e=Object.getOwnPropertyNames(i.prototype);for(let s=0;s{s=-1,e||t.apply(n,o)},i),e&&!s&&t.apply(n,o)}}static Bh(t,i){return root.setTimeout(t,i)}static Ug(t){root.clearTimeout(t)}static ln(t){return root.document.createElement(t)}static n(t){throw new Error(t)}static F(t,i){let e="The object is frozen, so its properties cannot be set: "+t.toString();i!==void 0&&(e+=" to value: "+i),Util.n(e)}static s(t,i,e,s){if(!(t instanceof i)){let n=Util.au(e);s!==void 0&&(n+="."+s),Util.Vi(t,i,n)}}static t(t,i,e,s){if(typeof t!==i){let n=Util.au(e);s!==void 0&&(n+="."+s),Util.Vi(t,i,n)}}static r(t,i,e){if(typeof t!="number"||!isFinite(t)){let s=Util.au(i);e!==void 0&&(s+="."+e),Util.n(s+" must be a real number type, and not NaN or Infinity: "+t)}}static tt(t,i,e){t in i||Util.n(`${t} is not a valid value in enumeration: ${e}`)}static Vi(t,i,e,s){const n=" value is not an instance of "+Util.au(i)+": ";let o=Util.au(e);s!==void 0&&(o+="."+s),typeof t=="string"&&(t='"'+t+'"'),Util.n(o+n+t)}static G(t,i,e,s){let n=Util.au(e);s!==void 0&&(n+="."+s),Util.n(n+" is not in the range "+i+": "+t)}static ze(t){Util.n("Collection was modified during iteration: "+t.toString()+` +(function() {const root=typeof globalThis=="object"&&globalThis||typeof global=="object"&&global.global===global&&global||typeof self=="object"&&self.self===self&&self||{};root.requestAnimationFrame===void 0&&(root.setImmediate===void 0?root.requestAnimationFrame=w=>root.setTimeout(w,0):root.requestAnimationFrame=root.setImmediate);const Debug={boundsInfoEnabled:!1,drawLocationsEnabled:!1,drawClipEnabled:!1,drawLinkpointsEnabled:!1,nodeInspector:!1,handleMessages:!1,drawFrames:!1,defaultDiagram:null,trace:function(w){root.console&&root.console.log(w)},drawDiagramBounds(w,t,i,e){w.strokeStyle="red",w.fillStyle="red",w.font="8px sans-serif",w.beginPath(),w.moveTo(-10,0),w.lineTo(10,0),w.moveTo(0,-10),w.lineTo(0,10),w.stroke(),w.setTransform(1,0,0,1,0,0),w.scale(i,i),w.transform(t.m11,t.m12,t.m21,t.m22,t.dx,t.dy),w.lineWidth=2,w.beginPath(),w.moveTo(e.left,e.top+20),w.lineTo(e.left,e.top),w.lineTo(e.left+20,e.top),w.moveTo(e.right,e.bottom-20),w.lineTo(e.right,e.bottom),w.lineTo(e.right-20,e.bottom),w.stroke(),w.fillText("DB: "+Math.round(e.x)+", "+Math.round(e.y)+", "+Math.round(e.width)+", "+Math.round(e.height),e.left,e.top-5)},attachReadonlyWarnings:function(w){for(const t in w){if(t==="licenseKey")continue;const i=w[t];if(i.prototype===void 0)continue;const e=Object.getOwnPropertyNames(i.prototype);for(let s=0;s{s=-1,e||t.apply(n,o)},i),e&&!s&&t.apply(n,o)}}static zh(t,i){return root.setTimeout(t,i)}static Kg(t){root.clearTimeout(t)}static ln(t){return root.document.createElement(t)}static n(t){throw new Error(t)}static F(t,i){let e="The object is frozen, so its properties cannot be set: "+t.toString();i!==void 0&&(e+=" to value: "+i),Util.n(e)}static s(t,i,e,s){if(!(t instanceof i)){let n=Util.hu(e);s!==void 0&&(n+="."+s),Util.Bi(t,i,n)}}static t(t,i,e,s){if(typeof t!==i){let n=Util.hu(e);s!==void 0&&(n+="."+s),Util.Bi(t,i,n)}}static r(t,i,e){if(typeof t!="number"||!isFinite(t)){let s=Util.hu(i);e!==void 0&&(s+="."+e),Util.n(s+" must be a real number type, and not NaN or Infinity: "+t)}}static tt(t,i,e){t in i||Util.n(`${t} is not a valid value in enumeration: ${e}`)}static Bi(t,i,e,s){const n=" value is not an instance of "+Util.hu(i)+": ";let o=Util.hu(e);s!==void 0&&(o+="."+s),typeof t=="string"&&(t='"'+t+'"'),Util.n(o+n+t)}static G(t,i,e,s){let n=Util.hu(e);s!==void 0&&(n+="."+s),Util.n(n+" is not in the range "+i+": "+t)}static ze(t){Util.n("Collection was modified during iteration: "+t.toString()+` Perhaps you should iterate over a copy of the collection, - or you could collect items to be removed from the collection after the iteration.`)}static ur(t,i){Util.n("No property to set for this enum value: "+i+" on "+t.toString())}static at(t){root.console&&root.console.log(t)}static Mt(t){return typeof t=="object"&&t!==null}static Gg(t,i,e){Array.isArray(t)||Util.Vi(t,"Array",i,e)}static fu(t,i,e){Array.isArray(t)?i>=t.length?t.push(e):t.splice(i,0,e):Util.n("Cannot insert an object into an HTMLCollection or NodeList: "+e+" at "+i)}static rf(t,i){Array.isArray(t)?i>=t.length?t.pop():t.splice(i,1):Util.n("Cannot remove an object from an HTMLCollection or NodeList at "+i)}static Ok=[];static ft(){const t=Util.Ok.pop();return t===void 0?[]:t}static nt(t){t.length=0,Util.Ok.push(t)}static eE=Object.freeze([]);static au(t){return t===null?"*":typeof t=="string"?t:typeof t=="function"?t.name:""}static hn(t){return typeof t=="function"?t.className?t.className:t.name:Util.Mt(t)&&t.constructor?Util.hn(t.constructor):typeof t}static zh(t,i){return i==null||i===""?null:Util.Mt(t)&&i in t||t[i]?t[i]:null}static toString(t){let i=t;return Util.Mt(t)&&(t.text?i=t.text:t.name?i=t.name:t.key!==void 0?i=t.key:t.id!==void 0?i=t.id:t.constructor===Object&&(t.Text?i=t.Text:t.Name?i=t.Name:t.Key!==void 0?i=t.Key:t.Id!==void 0?i=t.Id:t.ID!==void 0&&(i=t.ID))),i===void 0?"undefined":i===null?"null":i.toString()}static yw(t,i){if(t.hasOwnProperty(i))return!0;let e=Object.getPrototypeOf(t);for(;e&&e!==Function;){if(e.hasOwnProperty(i))return!0;const s=e.sE;if(s&&s[i])return!0;e=Object.getPrototypeOf(e)}return!1}static ED(t){const i=[];let e=0;for(e=0;e<256;e++)i[e]=e;let s=0,n=0;for(e=0;e<256;e++)s=(s+i[e]+119)%256,n=i[e],i[e]=i[s],i[s]=n;e=0,s=0;let o="";for(let r=0;r>4)+i.charAt(r&15)]=String.fromCharCode(r);t.length%2&&(t="0"+t);const s=[];let n=0;for(let r=0;r0){const n=i[0];return this.key=0,this.value=n,n}else return null}any(t){const i=this.Qt;i.dr=null;const e=i.gt;this.Vt=-1;const s=i.h,n=s.length,o=this.Rs;for(let r=0;r=0?(this.key=i,this.value=t.h[i],!0):(this.wl(),!1)}hasNext(){return this.next()}first(){const t=this.Qt;this.vt=t.gt;const i=t.h,e=i.length-1;if(this.Vt=e,e>=0){const s=i[e];return this.key=e,this.value=s,s}else return null}any(t){const i=this.Qt;i.gr=null;const e=i.gt,s=i.h,n=s.length;this.Vt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(t(r))return!0;i.gt!==e&&Util.ze(i)}return!1}all(t){const i=this.Qt;i.gr=null;const e=i.gt,s=i.h,n=s.length;this.Vt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(!t(r))return!1;i.gt!==e&&Util.ze(i)}return!0}each(t){const i=this.Qt;i.gr=null;const e=i.gt,s=i.h,n=s.length;this.Vt=n;for(let o=n-1;o>=0;o--){const r=s[o];t(r),i.gt!==e&&Util.ze(i)}return this}map(t){const i=this.Qt;i.gr=null;const e=i.gt,s=[],n=i.h,o=n.length;this.Vt=o;for(let l=o-1;l>=0;l--){const h=n[l];s.push(t(h)),i.gt!==e&&Util.ze(i)}const r=new List;return r.h=s,r.Xe(),r.iterator}filter(t){const i=this.Qt;i.gr=null;const e=i.gt,s=[],n=i.h,o=n.length;this.Vt=o;for(let l=o-1;l>=0;l--){const h=n[l];t(h)&&s.push(h),i.gt!==e&&Util.ze(i)}const r=new List;return r.h=s,r.Xe(),r.iterator}get count(){return this.Qt.h.length}wl(){this.key=-1,this.value=null,this.vt=-1,this.Qt.gr=this}toString(){return"ListIteratorBackwards("+this.Vt+"/"+this.Qt.count+")"}}class List{f;h;gt;dr;gr;constructor(t){GSet.vi(this),this.f=!1,this.h=[],this.gt=0,this.dr=null,this.gr=null,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.h.values()}Xe(){let t=this.gt;t++,t>999999999&&(t=0),this.gt=t}w(){return this.f=!0,this}ct(){return this.f=!1,this}toString(){return"List()#"+GSet.gs(this)}add(t){return this.f&&Util.F(this,t),this.h.push(t),this.Xe(),this}push(t){this.add(t)}addAll(t){if(t===null)return this;this.f&&Util.F(this);const i=this.h;if(Array.isArray(t)){const e=t.length;for(let s=0;s=i.length)&&Util.G(t,"0 <= i < length",List,"elt:i"),i[t]}get(t){return this.elt(t)}setElt(t,i){Debug&&Util.r(t,List,"setElt:i");const e=this.h;(t<0||t>=e.length)&&Util.G(t,"0 <= i < length",List,"setElt:i"),this.f&&Util.F(this,t),e[t]=i}set(t,i){this.setElt(t,i)}first(){const t=this.h;return t.length===0?null:t[0]}last(){const t=this.h,i=t.length;return i>0?t[i-1]:null}pop(){this.f&&Util.F(this);const t=this.h;return t.length>0?t.pop():null}any(t){const i=this.h,e=this.gt,s=i.length;for(let n=0;n= 0",List,"insertAt:i"),this.f&&Util.F(this,t);const e=this.h;t>=e.length?e.push(i):e.splice(t,0,i),this.Xe()}remove(t){return this.delete(t)}delete(t){if(t===null)return!1;this.f&&Util.F(this,t);const i=this.h,e=i.indexOf(t);return e===-1?!1:(e===i.length-1?i.pop():i.splice(e,1),this.Xe(),!0)}removeAt(t){Debug&&Util.r(t,List,"removeAt:i");const i=this.h;(t<0||t>=i.length)&&Util.G(t,"0 <= i < length",List,"removeAt:i"),this.f&&Util.F(this,t),t===i.length-1?i.pop():i.splice(t,1),this.Xe()}removeRange(t,i){Debug&&(Util.r(t,List,"removeRange:from"),Util.r(i,List,"removeRange:to"));const e=this.h,s=e.length;if(t<0)t=0;else if(t>=s)return this;if(i<0)return this;if(i>=s&&(i=s-1),t>i)return this;this.f&&Util.F(this);let n=t,o=i+1;for(;o0&&(t.h=Array.prototype.slice.call(i)),t}toArray(){const t=this.h,i=this.count,e=new Array(i);for(let s=0;s=n-1)&&Util.G(i,"0 <= from < length",List,"sortRange:from"),o===2){const r=s[i],l=s[i+1];return t(r,l)>0&&(s[i]=l,s[i+1]=r,this.Xe()),this}if(i===0)if(e>=n)s.sort(t);else{const r=s.slice(0,e);r.sort(t);for(let l=0;l=n){const r=s.slice(i);r.sort(t);for(let l=i;li.add(t(e))),i.iterator}filter(t){const i=new List;return this.Ao.k.forEach(e=>{t(e)&&i.add(e)}),i.iterator}get count(){return this.Ao.count}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"SetIterator"}}class GSet{f;k;constructor(t){this.f=!1,this.k=new Set,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.k.values()}values(){return this.k.values()}w(){return this.f=!0,this}ct(){return this.f=!1,this}toString(){return"Set()#"+GSet.gs(this)}add(t){return t===null?this:(this.k.add(t),this)}addAll(t){if(t===null)return this;if(Array.isArray(t)){const i=t.length;for(let e=0;et.add(i)),t}toArray(){return Array.from(this.k)}toList(){const t=new List;return this.k.forEach(i=>t.add(i)),t}get count(){return this.k.size}get size(){return this.k.size}get iterator(){return this.k.size<=0?EmptyIterator.instance:new SetIterator(this)}entries(){return this.k.entries()}keys(){return this.k.keys()}forEach(t,i){return this.k.forEach(t,i)}static cu=1;static vi(t){t.__gohashid=GSet.cu++}static gs(t){return t.__gohashid}}class MapKeySetIterator{it;ri;constructor(t){this.it=t,this.ri=t.k.keys()}[Symbol.iterator](){return this.it.k.keys()}key;value;get iterator(){return this}reset(){const t=this.it;this.ri=t.k.keys()}next(){const t=this.ri.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.it.k.size===0?null:(this.ri=this.it.k.keys(),this.ri.next().value)}any(t){for(const i of this.it.k)if(t(i[0]))return!0;return!1}all(t){for(const i of this.it.k)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.it.k)t(i[0]);return this}map(t){const i=this.it,e=new List;for(const s of i.k)e.add(t(s[0]));return e.iterator}filter(t){const i=this.it,e=new List;for(const s of i.k){const n=s[0];t(n)&&e.add(n)}return e.iterator}get count(){return this.it.size}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"MapKeySetIterator"}}class MapKeySet extends GSet{it;constructor(t){super(),GSet.vi(this),this.f=!0,this.it=t}[Symbol.iterator](){return this.k.keys()}values(){return this.k.keys()}w(){return this}ct(){return this}toString(){return"MapKeySet("+this.it.toString()+")"}add(t){Util.n("This Set is read-only: "+this.toString())}has(t){return this.it.has(t)}contains(t){return this.has(t)}delete(t){Util.n("This Set is read-only: "+this.toString())}remove(t){return this.delete(t)}clear(){Util.n("This Set is read-only: "+this.toString())}first(){return this.it.k.size===0?null:this.it.k.keys().next().value}any(t){for(const i of this.it.k)if(t(i[0]))return!0;return!1}all(t){for(const i of this.it.k)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.it.k)t(i[0]);return this}map(t){const i=new GSet;for(const e of this.it.k)i.add(t(e[0]));return i}filter(t){const i=new GSet;for(const e of this.it.k){const s=e[0];t(s)&&i.add(s)}return i}copy(){return new MapKeySet(this.it)}toSet(){const t=new GSet,i=this.it.k;for(const e of i)t.add(e[0]);return t}toArray(){const t=this.it.k,i=new Array(t.size);let e=0;for(const s of t)i[e]=s[0],e++;return i}toList(){const t=new List,i=this.it.k;for(const e of i)t.add(e[0]);return t}get count(){return this.it.size}get size(){return this.it.size}get iterator(){return this.it.size<=0?EmptyIterator.instance:new MapKeySetIterator(this.it)}}class MapValueSetIterator{it;ri;constructor(t){this.it=t,this.ri=t.k.values()}[Symbol.iterator](){return this.it.k.values()}key;value;get iterator(){return this}reset(){const t=this.it;this.ri=t.k.values()}next(){const t=this.ri.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.it.k.size===0?null:(this.ri=this.it.k.values(),this.ri.next().value)}any(t){for(const i of this.it.k)if(t(i[1]))return!0;return!1}all(t){for(const i of this.it.k)if(!t(i[1]))return!1;return!0}each(t){for(const i of this.it.k)t(i[1]);return this}map(t){const i=this.it,e=new List;for(const s of i.k)e.add(t(s[1]));return e.iterator}filter(t){const i=this.it,e=new List;for(const s of i.k){const n=s[1];t(n)&&e.add(n)}return e.iterator}get count(){return this.it.size}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"MapValueSetIterator"}}class KeyValuePair{constructor(t,i){this.key=t,this.value=i}toString(){return"{"+this.key+":"+this.value+"}"}key;value}class MapIterator{it;ri;constructor(t){this.it=t,this.ri=t.k.entries()}[Symbol.iterator](){return this.it.k.entries()}key;value;get iterator(){return this}reset(){const t=this.it;this.ri=t.k.entries()}next(){const t=this.ri.next();return t.done?(this.key=null,this.value=null,!1):(this.key=t.value[0],this.value=t.value[1],!0)}hasNext(){return this.next()}first(){if(this.it.k.size===0)return null;this.ri=this.it.k.entries();const t=this.ri.next().value;return this.key=t[0],this.value=t[1],new KeyValuePair(t[0],t[1])}any(t){return this.it.any(t)}all(t){return this.it.all(t)}each(t){return this.it.each(t),this}map(t){const i=new List;let e=null;return this.it.k.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),i.add(t(e))}),i.iterator}filter(t){const i=new List;let e=null;return this.it.k.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),t(e)&&(i.add(e),e=null)}),i.iterator}get count(){return this.it.size}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"MapIterator"}}class GMap{f;k;constructor(t){GSet.vi(this),this.f=!1,this.k=new Map,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.k.entries()}entries(){return this.k.entries()}w(){return this.f=!0,this}ct(){return this.f=!1,this}toString(){return"Map()#"+GSet.gs(this)}set(t,i){return this.f&&Util.F(this,t),this.k.set(t,i),this}add(t,i){return this.set(t,i)}addAll(t){if(t===null)return this;if(this.f&&Util.F(this),Array.isArray(t)){const i=t.length;for(let e=0;ei.x.toFixed(t)+" "+i.y.toFixed(t)}toString(){return"Point("+this.x+","+this.y+")"}equals(t){return t instanceof Point?this.S===t.x&&this.P===t.y:!1}equalTo(t,i){return this.S===t&&this.P===i}equalsApprox(t){return Geo.p(this.S,t.x)&&Geo.p(this.P,t.y)}add(t){return Debug&&(Util.s(t,Point,Point,"add:p"),this.et()),this.S+=t.x,this.P+=t.y,this}subtract(t){return Debug&&(Util.s(t,Point,Point,"subtract:p"),this.et()),this.S-=t.x,this.P-=t.y,this}offset(t,i){return Debug&&(Util.r(t,Point,"offset:dx"),Util.r(i,Point,"offset:dy"),this.et()),this.S+=t,this.P+=i,this}rotate(t){if(Debug&&(Util.r(t,Point,"rotate:angle"),this.et()),t===0)return this;const i=this.S,e=this.P;if(i===0&&e===0)return this;let s=0,n=0;if(t>=360?t-=360:t<0&&(t+=360),t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const o=t*Math.PI/180;s=Math.cos(o),n=Math.sin(o)}return this.S=s*i-n*e,this.P=n*i+s*e,this}scale(t,i){return Debug&&(Util.r(t,Point,"scale:sx"),Util.r(i,Point,"scale:sy"),this.et()),this.S*=t,this.P*=i,this}distanceSquaredPoint(t){Debug&&Util.s(t,Point,Point,"distanceSquaredPoint:p");const i=t.x-this.S,e=t.y-this.P;return i*i+e*e}distanceSquared(t,i){Debug&&(Util.r(t,Point,"distanceSquared:px"),Util.r(i,Point,"distanceSquared:py"));const e=t-this.S,s=i-this.P;return e*e+s*s}normalize(){Debug&&this.et();const t=this.S,i=this.P,e=Math.sqrt(t*t+i*i);return e>0&&(this.S=t/e,this.P=i/e),this}directionPoint(t){return Debug&&Util.s(t,Point,Point,"directionPoint:p"),this.oC(t.x-this.S,t.y-this.P)}direction(t,i){return Debug&&(Util.r(t,Point,"direction:px"),Util.r(i,Point,"direction:py")),this.oC(t-this.S,i-this.P)}oC(t,i){if(t===0)return i>0?90:i<0?270:0;if(i===0)return t>0?0:180;{if(isNaN(t)||isNaN(i))return 0;let e=Math.atan(Math.abs(i/t))*180/Math.PI;return t<0?i<0?e+=180:e=180-e:i<0&&(e=360-e),e}}static compareWithLineSegment(t,i,e,s,n,o){return Debug&&(Util.r(t,Point,"compareWithLineSegment:a1x"),Util.r(i,Point,"compareWithLineSegment:a1y"),Util.r(e,Point,"compareWithLineSegment:a2x"),Util.r(s,Point,"compareWithLineSegment:a2y"),Util.r(n,Point,"compareWithLineSegment:b1x"),Util.r(o,Point,"compareWithLineSegment:b1y")),Geo.uu(t,i,e,s,n,o)}compareWithLineSegmentPoint(t,i){return Debug&&(Util.s(t,Point,Point,"compareWithLineSegmentPoint:p"),Util.s(i,Point,Point,"compareWithLineSegmentPoint:q")),Geo.uu(t.x,t.y,i.x,i.y,this.x,this.y)}static intersectingLineSegments(t,i,e,s,n,o,r,l){return Debug&&(Util.r(t,Point,"intersectingLineSegments:a1x"),Util.r(i,Point,"intersectingLineSegments:a1y"),Util.r(e,Point,"intersectingLineSegments:a2x"),Util.r(s,Point,"intersectingLineSegments:a2y"),Util.r(n,Point,"intersectingLineSegments:b1x"),Util.r(o,Point,"intersectingLineSegments:b1y"),Util.r(r,Point,"intersectingLineSegments:b2x"),Util.r(l,Point,"intersectingLineSegments:b2y")),Geo.du(t,i,e,s,n,o,r,l)}projectOntoLineSegment(t,i,e,s){return Debug&&(Util.r(t,Point,"projectOntoLineSegment:px"),Util.r(i,Point,"projectOntoLineSegment:py"),Util.r(e,Point,"projectOntoLineSegment:qx"),Util.r(s,Point,"projectOntoLineSegment:qy")),Geo.xl(t,i,e,s,this.S,this.P,this),this}projectOntoLineSegmentPoint(t,i){return Debug&&(Util.s(t,Point,Point,"projectOntoLineSegmentPoint:p"),Util.s(i,Point,Point,"projectOntoLineSegmentPoint:q")),Geo.xl(t.x,t.y,i.x,i.y,this.S,this.P,this),this}snapToGrid(t,i,e,s){return Debug&&(Util.r(t,Point,"snapToGrid:originx"),Util.r(i,Point,"snapToGrid:originy"),Util.r(e,Point,"snapToGrid:cellwidth"),Util.r(s,Point,"snapToGrid:cellheight")),Geo.Hg(this.S,this.P,t,i,e,s,this),this}snapToGridPoint(t,i){return Debug&&(Util.s(t,Point,Point,"snapToGridPoint:p"),Util.s(i,Size,Point,"snapToGridPoint:q")),Geo.Hg(this.S,this.P,t.x,t.y,i.width,i.height,this),this}setRectSpot(t,i){return Debug&&(Util.s(t,Rect,Point,"setRectSpot:r"),Util.s(i,Spot,Point,"setRectSpot:spot"),this.et()),this.S=t.x+i.x*t.width+i.offsetX,this.P=t.y+i.y*t.height+i.offsetY,this}setSpot(t,i,e,s,n){return Debug&&(Util.r(t,Point,"setSpot:x"),Util.r(i,Point,"setSpot:y"),Util.r(e,Point,"setSpot:w"),Util.r(s,Point,"setSpot:h"),(e<0||s<0)&&Util.n("Point.setSpot:Width and height cannot be negative"),Util.s(n,Spot,Point,"setSpot:spot"),this.et()),this.S=t+n.x*e+n.offsetX,this.P=i+n.y*s+n.offsetY,this}O(t){return t.Pt(this),this}Ye(t){return t.ns(this),this}static distanceLineSegmentSquared(t,i,e,s,n,o){Debug&&(Util.r(t,Point,"distanceLineSegmentSquared:px"),Util.r(i,Point,"distanceLineSegmentSquared:py"),Util.r(e,Point,"distanceLineSegmentSquared:ax"),Util.r(s,Point,"distanceLineSegmentSquared:ay"),Util.r(n,Point,"distanceLineSegmentSquared:bx"),Util.r(o,Point,"distanceLineSegmentSquared:by"));let r=n-e,l=o-s;const h=r*r+l*l,a=e-t,f=s-i,c=-a*r-f*l;if(c<=0||c>=h)return r=n-t,l=o-i,Math.min(a*a+f*f,r*r+l*l);{const u=r*f-l*a;return u*u/h}}static distanceSquared(t,i,e,s){Debug&&(Util.r(t,Point,"distanceSquared:px"),Util.r(i,Point,"distanceSquared:py"),Util.r(e,Point,"distanceSquared:qx"),Util.r(s,Point,"distanceSquared:qy"));const n=e-t,o=s-i;return n*n+o*o}static direction(t,i,e,s){Debug&&(Util.r(t,Point,"direction:px"),Util.r(i,Point,"direction:py"),Util.r(e,Point,"direction:qx"),Util.r(s,Point,"direction:qy"));const n=e-t,o=s-i;if(n===0)return o>0?90:o<0?270:0;if(o===0)return n>0?0:180;{if(isNaN(n)||isNaN(o))return 0;let r=Math.atan(Math.abs(o/n))*180/Math.PI;return n<0?o<0?r+=180:r=180-r:o<0&&(r=360-r),r}}get x(){return this.S}set x(t){Debug&&(Util.t(t,"number",Point,"x"),this.et(t)),this.S=t}get y(){return this.P}set y(t){Debug&&(Util.t(t,"number",Point,"y"),this.et(t)),this.P=t}isReal(){return isFinite(this.x)&&isFinite(this.y)}static Lo=new Point(0,0).ot();static rC=new Point(-1/0,-1/0).ot();static lC=new Point(1/0,1/0).ot();static hC=new Point(6,6).ot();static Vk=new Point(NaN,NaN).ot();static Bk=[];static a(){const t=Point.Bk.pop();return t===void 0?new Point:t}static H(t,i){const e=Point.Bk.pop();return e===void 0?new Point(t,i):(e.x=t,e.y=i,e)}static o(t){Point.Bk.push(t)}}class Size{v;J;f;constructor(t,i){t===void 0?(this.v=0,this.J=0):typeof t=="number"&&(t>=0||isNaN(t))&&typeof i=="number"&&(i>=0||isNaN(i))?(this.v=t,this.J=i):Util.n("Invalid arguments to Size constructor: "+t+", "+i),this.f=!1}c(t){return this.v=t.v,this.J=t.J,this}e(t,i){return this.v=t,this.J=i,this}setTo(t,i){return Debug&&(Util.t(t,"number",Size,"setTo:w"),Util.t(i,"number",Size,"setTo:h"),t<0&&Util.G(t,">= 0",Size,"setTo:w"),i<0&&Util.G(i,">= 0",Size,"setTo:h"),this.et()),this.v=t,this.J=i,this}set(t){return Debug&&(Util.s(t,Size,Size,"set:s"),this.et()),this.v=t.v,this.J=t.J,this}copy(){const t=new Size;return t.v=this.v,t.J=this.J,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ct(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}et(t){if(Debug&&this.f){let i="The Size is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;return n=i[e++],n&&(o=parseFloat(n)),new Size(s,o)}else return new Size}static stringify(t){return Debug&&Util.s(t,Size),t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.t(t,"number",Size,"stringifyFixed:digits"),i=>i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Size("+this.width+","+this.height+")"}equals(t){return t instanceof Size?this.v===t.width&&this.J===t.height:!1}equalTo(t,i){return this.v===t&&this.J===i}equalsApprox(t){return Geo.p(this.v,t.width)&&Geo.p(this.J,t.height)}inflate(t,i){Debug&&(Util.r(t,Size,"inflate:w"),Util.r(i,Size,"inflate:h"));const e=this.width+t;this.v=e>=0?e:0;const s=this.height+i;return this.J=s>=0?s:0,this}get width(){return this.v}set width(t){Debug&&(Util.t(t,"number",Size,"width"),this.et(t)),t<0&&Util.G(t,">= 0",Size,"width"),this.v=t}get height(){return this.J}set height(t){Debug&&(Util.t(t,"number",Size,"height"),this.et(t)),t<0&&Util.G(t,">= 0",Size,"height"),this.J=t}isReal(){return isFinite(this.width)&&isFinite(this.height)}static lf=new Size(0,0).ot();static zk=new Size(1,1).ot();static aC=new Size(6,6).ot();static gu=new Size(8,8).ot();static fC=new Size(10,10).ot();static Xk=new Size(1/0,1/0).ot();static xw=new Size(NaN,NaN).ot();static cC=[];static a(){const t=Size.cC.pop();return t===void 0?new Size:t}static o(t){Size.cC.push(t)}}class Rect{S;P;v;J;f;constructor(t,i,e,s){if(t===void 0)this.S=0,this.P=0,this.v=0,this.J=0;else if(typeof t=="number"&&typeof i=="number"&&typeof e=="number"&&(e>=0||isNaN(e))&&typeof s=="number"&&(s>=0||isNaN(s)))this.S=t,this.P=i,this.v=e,this.J=s;else if(t instanceof Point){const n=t.x,o=t.y;if(i instanceof Point){const r=i.x,l=i.y;this.S=Math.min(n,r),this.P=Math.min(o,l),this.v=Math.abs(n-r),this.J=Math.abs(o-l)}else i instanceof Size?(this.S=n,this.P=o,this.v=i.width,this.J=i.height):Util.n("Incorrect second argument supplied to Rect constructor "+i)}else Util.n("Invalid arguments to Rect constructor: "+t+", "+i+", "+e+", "+s);this.f=!1}c(t){return this.S=t.S,this.P=t.P,this.v=t.v,this.J=t.J,this}e(t,i,e,s){return this.S=t,this.P=i,this.v=e,this.J=s,this}Kn(t,i){return this.v=t,this.J=i,this}setTo(t,i,e,s){return Debug&&(Util.t(t,"number",Rect,"setTo:x"),Util.t(i,"number",Rect,"setTo:y"),Util.t(e,"number",Rect,"setTo:w"),Util.t(s,"number",Rect,"setTo:h"),e<0&&Util.G(e,">= 0",Rect,"setTo:w"),s<0&&Util.G(s,">= 0",Rect,"setTo:h"),this.et()),this.S=t,this.P=i,this.v=e,this.J=s,this}set(t){return Debug&&(Util.s(t,Rect,Rect,"set:r"),this.et()),this.S=t.S,this.P=t.P,this.v=t.v,this.J=t.J,this}setPoint(t){return Debug&&(Util.s(t,Point,Rect,"setPoint:p"),this.et()),this.S=t.x,this.P=t.y,this}setSize(t){return Debug&&(Util.s(t,Size,Rect,"setSize:s"),this.et()),this.v=t.width,this.J=t.height,this}copy(){const t=new Rect;return t.S=this.S,t.P=this.P,t.v=this.v,t.J=this.J,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ct(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}et(t){if(Debug&&this.f){let i="The Rect is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),new Rect(s,o,r,l)}else return new Rect}static stringify(t){return Debug&&Util.s(t,Rect),t.x.toString()+" "+t.y.toString()+" "+t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.t(t,"number",Rect,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Rect("+this.x+","+this.y+","+this.width+","+this.height+")"}equals(t){return t instanceof Rect?this.S===t.x&&this.P===t.y&&this.v===t.width&&this.J===t.height:!1}equalTo(t,i,e,s){return this.S===t&&this.P===i&&this.v===e&&this.J===s}equalsApprox(t){return Geo.p(this.S,t.x)&&Geo.p(this.P,t.y)&&Geo.p(this.v,t.width)&&Geo.p(this.J,t.height)}equalsApproxTo(t,i,e,s){return Geo.p(this.S,t)&&Geo.p(this.P,i)&&Geo.p(this.v,e)&&Geo.p(this.J,s)}equalsApproxClose(t){return Geo.q(this.S,t.x)&&Geo.q(this.P,t.y)&&Geo.q(this.v,t.width)&&Geo.q(this.J,t.height)}containsPoint(t){return Debug&&Util.s(t,Point,Rect,"containsPoint:p"),this.S<=t.x&&this.S+this.v>=t.x&&this.P<=t.y&&this.P+this.J>=t.y}containsRect(t){return Debug&&Util.s(t,Rect,Rect,"containsRect:r"),this.S<=t.x&&t.x+t.width<=this.S+this.v&&this.P<=t.y&&t.y+t.height<=this.P+this.J}contains(t,i,e,s){return Debug?(Util.r(t,Rect,"contains:x"),Util.r(i,Rect,"contains:y"),e===void 0?e=0:Util.r(e,Rect,"contains:w"),s===void 0?s=0:Util.r(s,Rect,"contains:h"),(e<0||s<0)&&Util.n("Rect.contains:Width and height cannot be negative")):(e===void 0&&(e=0),s===void 0&&(s=0)),this.S<=t&&t+e<=this.S+this.v&&this.P<=i&&i+s<=this.P+this.J}offset(t,i){return Debug&&(Util.r(t,Rect,"offset:dx"),Util.r(i,Rect,"offset:dy"),this.et()),this.S+=t,this.P+=i,this}inflate(t,i){return Debug&&(Util.r(t,Rect,"inflate:w"),Util.r(i,Rect,"inflate:h")),this.bw(i,t,i,t)}addMargin(t){return Debug&&Util.s(t,Margin,Rect,"addMargin:m"),this.bw(t.top,t.right,t.bottom,t.left)}subtractMargin(t){return Debug&&Util.s(t,Margin,Rect,"subtractMargin:m"),this.bw(-t.top,-t.right,-t.bottom,-t.left)}grow(t,i,e,s){return Debug&&(Util.r(t,Rect,"grow:t"),Util.r(i,Rect,"grow:r"),Util.r(e,Rect,"grow:b"),Util.r(s,Rect,"grow:l")),this.bw(t,i,e,s)}bw(t,i,e,s){Debug&&this.et();const n=this.v;i+s<=-n?(this.S+=n/2,this.v=0):(this.S-=s,this.v+=i+s);const o=this.J;return t+e<=-o?(this.P+=o/2,this.J=0):(this.P-=t,this.J+=t+e),this}intersectRect(t){return Debug&&Util.s(t,Rect,Rect,"intersectRect:r"),this.uC(t.x,t.y,t.width,t.height)}intersect(t,i,e,s){return Debug&&(Util.r(t,Rect,"intersect:x"),Util.r(i,Rect,"intersect:y"),Util.r(e,Rect,"intersect:w"),Util.r(s,Rect,"intersect:h"),(e<0||s<0)&&Util.n("Rect.intersect:Width and height cannot be negative")),this.uC(t,i,e,s)}uC(t,i,e,s){Debug&&this.et();const n=Math.max(this.S,t),o=Math.max(this.P,i),r=Math.min(this.S+this.v,t+e),l=Math.min(this.P+this.J,i+s);return this.S=n,this.P=o,this.v=Math.max(0,r-n),this.J=Math.max(0,l-o),this}intersectsRect(t){return Debug&&Util.s(t,Rect,Rect,"intersectsRect:r"),this.intersects(t.x,t.y,t.width,t.height)}intersects(t,i,e,s){Debug&&(Util.r(t,Rect,"intersects:x"),Util.r(i,Rect,"intersects:y"),Util.r(t,Rect,"intersects:w"),Util.r(i,Rect,"intersects:h"),(e<0||s<0)&&Util.n("Rect.intersects:Width and height cannot be negative"));let n=this.v;const o=this.S;if(n!==1/0&&e!==1/0&&(n+=o,e+=t,isNaN(e)||isNaN(n)||o>e||t>n))return!1;let r=this.J;const l=this.P;return!(r!==1/0&&s!==1/0&&(r+=l,s+=i,isNaN(s)||isNaN(r)||l>s||i>r))}intersectsRectPlus(t,i){let e=this.v,s=t.width+i+i;const n=this.S,o=t.x-i;if(e+=n,s+=o,n>s||o>e)return!1;let r=this.J,l=t.height+i+i;const h=this.P,a=t.y-i;return r+=h,l+=a,!(h>l||a>r)}unionPoint(t){return Debug&&Util.s(t,Point,Rect,"unionPoint:p"),this.unionNoCheck(t.x,t.y,0,0)}unionRect(t){return Debug&&Util.s(t,Rect,Rect,"unionRect:r"),this.unionNoCheck(t.S,t.P,t.v,t.J)}union(t,i,e,s){return Debug?(Util.r(t,Rect,"union:x"),Util.r(i,Rect,"union:y"),e===void 0?e=0:Util.r(e,Rect,"union:w"),s===void 0?s=0:Util.r(s,Rect,"union:h"),(e<0||s<0)&&Util.n("Rect.union:Width and height cannot be negative"),this.et()):(e===void 0&&(e=0),s===void 0&&(s=0)),this.unionNoCheck(t,i,e,s)}unionNoCheck(t,i,e,s){const n=Math.min(this.S,t),o=Math.min(this.P,i),r=Math.max(this.S+this.v,t+e),l=Math.max(this.P+this.J,i+s);return this.S=n,this.P=o,this.v=r-n,this.J=l-o,this}setSpot(t,i,e){return Debug&&(Util.r(t,Rect,"setSpot:x"),Util.r(i,Rect,"setSpot:y"),Util.s(e,Spot,Rect,"setSpot:spot"),this.et()),this.S=t-e.offsetX-e.x*this.v,this.P=i-e.offsetY-e.y*this.J,this}static contains(t,i,e,s,n,o,r,l){return Debug?(Util.r(t,Rect,"contains:rx"),Util.r(i,Rect,"contains:ry"),Util.r(e,Rect,"contains:rw"),Util.r(s,Rect,"contains:rh"),Util.r(n,Rect,"contains:x"),Util.r(o,Rect,"contains:y"),r===void 0?r=0:Util.r(r,Rect,"contains:w"),l===void 0?l=0:Util.r(l,Rect,"contains:h"),(e<0||s<0||r<0||l<0)&&Util.n("Rect.contains:Width and height cannot be negative")):(r===void 0&&(r=0),l===void 0&&(l=0)),t<=n&&n+r<=t+e&&i<=o&&o+l<=i+s}static intersects(t,i,e,s,n,o,r,l){Debug&&(Util.r(t,Rect,"intersects:rx"),Util.r(i,Rect,"intersects:ry"),Util.r(e,Rect,"intersects:rw"),Util.r(s,Rect,"intersects:rh"),Util.r(n,Rect,"intersects:x"),Util.r(o,Rect,"intersects:y"),Util.r(r,Rect,"intersects:w"),Util.r(l,Rect,"intersects:h"),(e<0||s<0||r<0||l<0)&&Util.n("Rect.intersects:Width and height cannot be negative"));let h=e,a=r;const f=t,c=n;if(h+=f,a+=c,f>a||c>h)return!1;let u=s,d=l;const m=i,g=o;return u+=m,d+=g,!(m>d||g>u)}static intersectsLineSegment(t,i,e,s,n,o,r,l){return Debug&&(Util.r(t,Rect,"intersectsLineSegment:x"),Util.r(i,Rect,"intersectsLineSegment:y"),Util.r(e,Rect,"intersectsLineSegment:w"),Util.r(s,Rect,"intersectsLineSegment:h"),Util.r(n,Rect,"intersectsLineSegment:p1x"),Util.r(o,Rect,"intersectsLineSegment:p1y"),Util.r(r,Rect,"intersectsLineSegment:p2x"),Util.r(l,Rect,"intersectsLineSegment:p2y"),(e<0||s<0)&&Util.n("Rect.intersectsLineSegment: width and height cannot be negative")),Geo.dC(t,i,e,s,n,o,r,l)}get x(){return this.S}set x(t){Debug&&(Util.t(t,"number",Rect,"x"),this.et(t)),this.S=t}get y(){return this.P}set y(t){Debug&&(Util.t(t,"number",Rect,"y"),this.et(t)),this.P=t}get width(){return this.v}set width(t){Debug&&(Util.t(t,"number",Rect,"width"),this.et(t)),t<0&&Util.G(t,">= 0",Rect,"width"),this.v=t}get height(){return this.J}set height(t){Debug&&(Util.t(t,"number",Rect,"height"),this.et(t)),t<0&&Util.G(t,">= 0",Rect,"height"),this.J=t}get left(){return this.S}set left(t){Debug&&(Util.t(t,"number",Rect,"left"),this.et(t)),this.S=t}get top(){return this.P}set top(t){Debug&&(Util.t(t,"number",Rect,"top"),this.et(t)),this.P=t}get right(){return this.S+this.v}set right(t){Debug&&(Util.r(t,Rect,"right"),this.et(t)),this.S+=t-(this.S+this.v)}get bottom(){return this.P+this.J}set bottom(t){Debug&&(Util.r(t,Rect,"top"),this.et(t)),this.P+=t-(this.P+this.J)}get position(){return new Point(this.S,this.P)}set position(t){Debug&&(Util.s(t,Point,Rect,"position"),this.et(t)),this.S=t.x,this.P=t.y}get size(){return new Size(this.v,this.J)}set size(t){Debug&&(Util.s(t,Size,Rect,"size"),this.et(t)),this.v=t.width,this.J=t.height}get center(){return new Point(this.S+this.v/2,this.P+this.J/2)}set center(t){Debug&&(Util.s(t,Point,Rect,"center"),this.et(t)),this.S=t.x-this.v/2,this.P=t.y-this.J/2}get centerX(){return this.S+this.v/2}set centerX(t){Debug&&(Util.r(t,Rect,"centerX"),this.et(t)),this.S=t-this.v/2}get centerY(){return this.P+this.J/2}set centerY(t){Debug&&(Util.r(t,Rect,"centerY"),this.et(t)),this.P=t-this.J/2}isReal(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)}isEmpty(){return this.width===0&&this.height===0}static kw=new Rect(0,0,0,0).ot();static BD=new Rect(NaN,NaN,NaN,NaN).ot();static Yk=[];static a(){const t=Rect.Yk.pop();return t===void 0?new Rect:t}static H(t,i,e,s){const n=Rect.Yk.pop();return n===void 0?new Rect(t,i,e,s):n.e(t,i,e,s)}static o(t){Rect.Yk.push(t)}}class Margin{an;fn;cn;un;f;constructor(t,i,e,s){t===void 0?(this.an=0,this.fn=0,this.cn=0,this.un=0):i===void 0?(i=t,e=t,s=t,this.top=t,this.right=i,this.bottom=e,this.left=s):e===void 0?(e=t,s=i,this.top=t,this.right=i,this.bottom=e,this.left=s):s!==void 0?(this.top=t,this.right=i,this.bottom=e,this.left=s):Util.n("Invalid arguments to Margin constructor: "+t+", "+i+", "+e+", "+s),this.f=!1}c(t){return this.an=t.an,this.fn=t.fn,this.cn=t.cn,this.un=t.un,this}setTo(t,i,e,s){return Debug&&(Util.t(t,"number",Margin,"setTo:t"),Util.t(i,"number",Margin,"setTo:r"),Util.t(e,"number",Margin,"setTo:b"),Util.t(s,"number",Margin,"setTo:l"),this.et()),this.an=t,this.fn=i,this.cn=e,this.un=s,this}set(t){return Debug&&(Util.s(t,Margin,Margin,"assign:m"),this.et()),this.an=t.an,this.fn=t.fn,this.cn=t.cn,this.un=t.un,this}copy(){const t=new Margin;return t.an=this.an,t.fn=this.fn,t.cn=this.cn,t.un=this.un,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ct(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}et(t){if(Debug&&this.f){let i="The Margin is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=NaN;for(;i[e]==="";)e++;let n=i[e++];if(n&&(s=parseFloat(n)),isNaN(s))return new Margin;let o=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(o=parseFloat(n)),isNaN(o))return new Margin(s);let r=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(r=parseFloat(n)),isNaN(r))return new Margin(s,o);let l=NaN;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),isNaN(l)?new Margin(s,o):new Margin(s,o,r,l)}else return new Margin}static stringify(t){return Debug&&Util.s(t,Margin),t.top.toString()+" "+t.right.toString()+" "+t.bottom.toString()+" "+t.left.toString()}static stringifyFixed(t){return Util.t(t,"number",Margin,"stringifyFixed:digits"),i=>i.top.toFixed(t)+" "+i.right.toFixed(t)+" "+i.bottom.toFixed(t)+" "+i.left.toFixed(t)}toString(){return"Margin("+this.top+","+this.right+","+this.bottom+","+this.left+")"}equals(t){return t instanceof Margin?this.an===t.top&&this.fn===t.right&&this.cn===t.bottom&&this.un===t.left:!1}equalTo(t,i,e,s){return this.an===t&&this.fn===i&&this.cn===e&&this.un===s}equalsApprox(t){return Geo.p(this.an,t.top)&&Geo.p(this.fn,t.right)&&Geo.p(this.cn,t.bottom)&&Geo.p(this.un,t.left)}get top(){return this.an}set top(t){Debug&&(Util.r(t,Margin,"top"),this.et(t)),this.an=t}get right(){return this.fn}set right(t){Debug&&(Util.r(t,Margin,"right"),this.et(t)),this.fn=t}get bottom(){return this.cn}set bottom(t){Debug&&(Util.r(t,Margin,"bottom"),this.et(t)),this.cn=t}get left(){return this.un}set left(t){Debug&&(Util.r(t,Margin,"left"),this.et(t)),this.un=t}isReal(){return isFinite(this.top)&&isFinite(this.right)&&isFinite(this.bottom)&&isFinite(this.left)}static qg=new Margin(0,0,0,0).ot();static gC=new Margin(2,2,2,2).ot();static mC=[];static a(){const t=Margin.mC.pop();return t===void 0?new Margin:t}static o(t){Margin.mC.push(t)}}class Spot{S;P;Is;Os;f;constructor(t,i,e,s){t===void 0?(this.S=0,this.P=0,this.Is=0,this.Os=0):(i===void 0&&(i=0),e===void 0&&(e=0),s===void 0&&(s=0),this.x=t,this.y=i,this.offsetX=e,this.offsetY=s),this.f=!1}c(t){return this.S=t.S,this.P=t.P,this.Is=t.Is,this.Os=t.Os,this}setTo(t,i,e,s){return Debug&&(this.Sw(t,"setTo:x"),this.Sw(i,"setTo:y"),this.Mw(e,"setTo:offx"),this.Mw(s,"setTo:offy"),this.et()),this.S=t,this.P=i,this.Is=e,this.Os=s,this}set(t){return Debug&&(Util.s(t,Spot,Spot,"set:s"),this.et()),this.S=t.S,this.P=t.P,this.Is=t.Is,this.Os=t.Os,this}copy(){const t=new Spot;return t.S=this.S,t.P=this.P,t.Is=this.Is,t.Os=this.Os,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ct(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}et(t){if(Debug&&this.f){let i="The Spot is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}Ke(t){return this.S=NaN,this.P=NaN,this.Is=t,this}Sw(t,i){(isNaN(t)||t>1||t<0)&&Util.G(t,"0 <= "+i+" <= 1",Spot,i)}Mw(t,i){(isNaN(t)||t===1/0||t===-1/0)&&Util.G(t,"real number, not NaN or Infinity",Spot,i)}static parse(t){if(typeof t=="string"){if(t=t.trim(),t==="None")return Spot.None;if(t==="TopLeft")return Spot.TopLeft;if(t==="Top"||t==="TopCenter"||t==="MiddleTop")return Spot.TopCenter;if(t==="TopRight")return Spot.TopRight;if(t==="Left"||t==="LeftCenter"||t==="MiddleLeft")return Spot.LeftCenter;if(t==="Center")return Spot.Center;if(t==="Right"||t==="RightCenter"||t==="MiddleRight")return Spot.RightCenter;if(t==="BottomLeft")return Spot.BottomLeft;if(t==="Bottom"||t==="BottomCenter"||t==="MiddleBottom")return Spot.BottomCenter;if(t==="BottomRight")return Spot.BottomRight;if(t==="TopSide")return Spot.TopSide;if(t==="LeftSide")return Spot.LeftSide;if(t==="RightSide")return Spot.RightSide;if(t==="BottomSide")return Spot.BottomSide;if(t==="TopBottomSides")return Spot.TopBottomSides;if(t==="LeftRightSides")return Spot.LeftRightSides;if(t==="TopLeftSides")return Spot.TopLeftSides;if(t==="TopRightSides")return Spot.TopRightSides;if(t==="BottomLeftSides")return Spot.BottomLeftSides;if(t==="BottomRightSides")return Spot.BottomRightSides;if(t==="NotTopSide")return Spot.NotTopSide;if(t==="NotLeftSide")return Spot.NotLeftSide;if(t==="NotRightSide")return Spot.NotRightSide;if(t==="NotBottomSide")return Spot.NotBottomSide;if(t==="AllSides")return Spot.AllSides;if(t==="Default")return Spot.Default;const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n!==void 0&&n.length>0&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n!==void 0&&n.length>0&&(l=parseFloat(n)),new Spot(s,o,r,l)}else return new Spot}static stringify(t){return Debug&&Util.s(t,Spot),t.isSpot()?t.x.toString()+" "+t.y.toString()+" "+t.offsetX.toString()+" "+t.offsetY.toString():t.toString()}static stringifyFixed(t){return Util.t(t,"number",Spot,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.offsetX.toFixed(t)+" "+i.offsetY.toFixed(t)}toString(){return this.isSpot()?this.Is===0&&this.Os===0?"Spot("+this.x+","+this.y+")":"Spot("+this.x+","+this.y+","+this.offsetX+","+this.offsetY+")":this.equals(Spot.None)?"None":this.equals(Spot.TopLeft)?"TopLeft":this.equals(Spot.TopCenter)?"Top":this.equals(Spot.TopRight)?"TopRight":this.equals(Spot.LeftCenter)?"Left":this.equals(Spot.Center)?"Center":this.equals(Spot.RightCenter)?"Right":this.equals(Spot.BottomLeft)?"BottomLeft":this.equals(Spot.BottomCenter)?"Bottom":this.equals(Spot.BottomRight)?"BottomRight":this.equals(Spot.TopSide)?"TopSide":this.equals(Spot.LeftSide)?"LeftSide":this.equals(Spot.RightSide)?"RightSide":this.equals(Spot.BottomSide)?"BottomSide":this.equals(Spot.TopBottomSides)?"TopBottomSides":this.equals(Spot.LeftRightSides)?"LeftRightSides":this.equals(Spot.TopLeftSides)?"TopLeftSides":this.equals(Spot.TopRightSides)?"TopRightSides":this.equals(Spot.BottomLeftSides)?"BottomLeftSides":this.equals(Spot.BottomRightSides)?"BottomRightSides":this.equals(Spot.NotTopSide)?"NotTopSide":this.equals(Spot.NotLeftSide)?"NotLeftSide":this.equals(Spot.NotRightSide)?"NotRightSide":this.equals(Spot.NotBottomSide)?"NotBottomSide":this.equals(Spot.AllSides)?"AllSides":this.equals(Spot.Default)?"Default":"None"}equals(t){return t instanceof Spot?(this.S===t.x||isNaN(this.S)&&isNaN(t.x))&&(this.P===t.y||isNaN(this.P)&&isNaN(t.y))&&this.Is===t.offsetX&&this.Os===t.offsetY:!1}opposite(){return new Spot(.5-(this.S-.5),.5-(this.P-.5),-this.Is,-this.Os)}includesSide(t){if(!this.isSide())return!1;if(!t.isSide())if(t.equals(Spot.Left))t=Spot.LeftSide;else if(t.equals(Spot.Right))t=Spot.RightSide;else if(t.equals(Spot.Top))t=Spot.TopSide;else if(t.equals(Spot.Bottom))t=Spot.BottomSide;else return!1;const i=this.Os,e=t.offsetY;return(i&e)===e}get x(){return this.S}set x(t){Debug&&(this.Sw(t,"x"),this.et(t)),this.S=t}get y(){return this.P}set y(t){Debug&&(this.Sw(t,"y"),this.et(t)),this.P=t}get offsetX(){return this.Is}set offsetX(t){Debug&&(this.Mw(t,"offsetX"),this.et(t)),this.Is=t}get offsetY(){return this.Os}set offsetY(t){Debug&&(this.Mw(t,"offsetY"),this.et(t)),this.Os=t}isSpot(){return!isNaN(this.x)&&!isNaN(this.y)}isNoSpot(){return isNaN(this.x)||isNaN(this.y)}isSide(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===1&&this.offsetY!==0}isNone(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===0&&this.offsetY===0}isDefault(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===-1&&this.offsetY===0}static None=new Spot(0,0,0,0).Ke(0).ot();static Default=new Spot(0,0,-1,0).Ke(-1).ot();static TopLeft=new Spot(0,0,0,0).ot();static TopCenter=new Spot(.5,0,0,0).ot();static TopRight=new Spot(1,0,0,0).ot();static LeftCenter=new Spot(0,.5,0,0).ot();static Center=new Spot(.5,.5,0,0).ot();static RightCenter=new Spot(1,.5,0,0).ot();static BottomLeft=new Spot(0,1,0,0).ot();static BottomCenter=new Spot(.5,1,0,0).ot();static BottomRight=new Spot(1,1,0,0).ot();static MiddleTop=Spot.TopCenter;static MiddleLeft=Spot.LeftCenter;static MiddleRight=Spot.RightCenter;static MiddleBottom=Spot.BottomCenter;static Top=Spot.TopCenter;static Left=Spot.LeftCenter;static Right=Spot.RightCenter;static Bottom=Spot.BottomCenter;static TopSide=new Spot(0,0,1,1).Ke(1).ot();static LeftSide=new Spot(0,0,1,2).Ke(1).ot();static RightSide=new Spot(0,0,1,4).Ke(1).ot();static BottomSide=new Spot(0,0,1,8).Ke(1).ot();static TopBottomSides=new Spot(0,0,1,9).Ke(1).ot();static LeftRightSides=new Spot(0,0,1,6).Ke(1).ot();static TopLeftSides=new Spot(0,0,1,3).Ke(1).ot();static TopRightSides=new Spot(0,0,1,5).Ke(1).ot();static BottomLeftSides=new Spot(0,0,1,10).Ke(1).ot();static BottomRightSides=new Spot(0,0,1,12).Ke(1).ot();static NotTopSide=new Spot(0,0,1,14).Ke(1).ot();static NotLeftSide=new Spot(0,0,1,13).Ke(1).ot();static NotRightSide=new Spot(0,0,1,11).Ke(1).ot();static NotBottomSide=new Spot(0,0,1,7).Ke(1).ot();static AllSides=new Spot(0,0,1,15).Ke(1).ot();static Kk=new Spot(.156,.156).ot();static Uk=new Spot(.844,.844).ot();static pC=[];static a(){const t=Spot.pC.pop();return t===void 0?new Spot:t}static o(t){Spot.pC.push(t)}}class Transform{m11;m12;m21;m22;dx;dy;constructor(){this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0}set(t){return this.m11=t.m11,this.m12=t.m12,this.m21=t.m21,this.m22=t.m22,this.dx=t.dx,this.dy=t.dy,this}setTo(t,i,e,s,n,o){return this.m11=t,this.m12=i,this.m21=e,this.m22=s,this.dx=n,this.dy=o,this}copy(){const t=new Transform;return t.m11=this.m11,t.m12=this.m12,t.m21=this.m21,t.m22=this.m22,t.dx=this.dx,t.dy=this.dy,t}toString(){return"Transform("+this.m11+","+this.m12+","+this.m21+","+this.m22+","+this.dx+","+this.dy+")"}equals(t){return this.m11===t.m11&&this.m12===t.m12&&this.m21===t.m21&&this.m22===t.m22&&this.dx===t.dx&&this.dy===t.dy}Gk(){return this.dx===0&&this.dy===0&&this.m11===1&&this.m12===0&&this.m21===0&&this.m22===1}Bi(){return this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0,this}hf(t){const i=this.m11*t.m11+this.m21*t.m12,e=this.m12*t.m11+this.m22*t.m12,s=this.m11*t.m21+this.m21*t.m22,n=this.m12*t.m21+this.m22*t.m22;return this.dx=this.m11*t.dx+this.m21*t.dy+this.dx,this.dy=this.m12*t.dx+this.m22*t.dy+this.dy,this.m11=i,this.m12=e,this.m21=s,this.m22=n,this}yC(t){const i=1/(t.m11*t.m22-t.m12*t.m21),e=t.m22*i,s=-t.m12*i,n=-t.m21*i,o=t.m11*i,r=i*(t.m21*t.dy-t.m22*t.dx),l=i*(t.m12*t.dx-t.m11*t.dy),h=this.m11*e+this.m21*s,a=this.m12*e+this.m22*s,f=this.m11*n+this.m21*o,c=this.m12*n+this.m22*o;return this.dx=this.m11*r+this.m21*l+this.dx,this.dy=this.m12*r+this.m22*l+this.dy,this.m11=h,this.m12=a,this.m21=f,this.m22=c,this}Pw(){const t=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*t,e=-this.m12*t,s=-this.m21*t,n=this.m11*t,o=t*(this.m21*this.dy-this.m22*this.dx),r=t*(this.m12*this.dx-this.m11*this.dy);return this.m11=i,this.m12=e,this.m21=s,this.m22=n,this.dx=o,this.dy=r,this}ms(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return this;this.Es(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m11*s+this.m21*n,r=this.m12*s+this.m22*n,l=this.m11*-n+this.m21*s,h=this.m12*-n+this.m22*s;return this.m11=o,this.m12=r,this.m21=l,this.m22=h,this.Es(-i,-e),this}Es(t,i){return this.dx+=this.m11*t+this.m21*i,this.dy+=this.m12*t+this.m22*i,this}lt(t,i){return i===void 0&&(i=t),this.m11*=t,this.m12*=t,this.m21*=i,this.m22*=i,this}zD(){if(this.m11===1&&this.m12===0)return 0;let t=Math.atan2(this.m12,this.m11)*180/Math.PI;return t<0&&(t+=360),t}Pt(t){const i=t.x,e=t.y;return t.e(i*this.m11+e*this.m21+this.dx,i*this.m12+e*this.m22+this.dy)}ns(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=t.x-this.dx,l=t.y-this.dy;return t.e(r*e+l*n,r*s+l*o)}Nw(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=i*(this.m21*this.dy-this.m22*this.dx),l=i*(this.m12*this.dx-this.m11*this.dy),h=t.x*1.25,a=t.y*1.2;return t.e(h*e+a*n+r,h*s+a*o+l)}Cw(t){const i=t.x,e=t.y,s=i+t.width,n=e+t.height,o=this.m11,r=this.m12,l=this.m21,h=this.m22,a=this.dx,f=this.dy,c=i*o+e*l+a,u=i*r+e*h+f,d=s*o+e*l+a,m=s*r+e*h+f,g=i*o+n*l+a,p=i*r+n*h+f,y=s*o+n*l+a,x=s*r+n*h+f;let k=c,b=c,S=u,M=u;return k=Math.min(k,d),b=Math.max(b,d),S=Math.min(S,m),M=Math.max(M,m),k=Math.min(k,g),b=Math.max(b,g),S=Math.min(S,p),M=Math.max(M,p),k=Math.min(k,y),b=Math.max(b,y),S=Math.min(S,x),M=Math.max(M,x),t.e(k,S,b-k,M-S),t}static wC=[];static a(){const t=Transform.wC.pop();return t===void 0?new Transform:t}static o(t){Transform.wC.push(t)}static Hk="54a702f3e53909c447824c6706603faf4c"}const Geo={XD:"7da71ca0ad381e90",Un:4*((Math.sqrt(2)-1)/3),xC:null,Aw:w=>{if(w<=0)return 0;let t=Geo.xC;if(t===null){t=[];for(let i=0;i<=2e3;i++)t[i]=Math.sqrt(i);Geo.xC=t}if(w<1){const i=1/w;return i<=2e3?1/t[i|0]:Math.sqrt(w)}else return w<=2e3?t[w|0]:Math.sqrt(w)},p:(w,t)=>{const i=w-t;return i<.5&&i>-.5},q:(w,t)=>{const i=w-t;return i<5e-8&&i>-5e-8},zi:(w,t,i,e,s,n,o)=>{s<=0&&(s=1e-6);let r=0,l=0,h=0,a=0;if(wu-d)if(w-i>s||i-w>s){const g=(e-t)/(i-w)*(n-w)+t;if(g-s<=o&&o<=g+s)return!0}else return!0;else if(t-e>s||e-t>s){const g=(i-w)/(e-t)*(o-t)+w;if(g-s<=n&&n<=g+s)return!0}else return!0}return!1},Lw:(w,t,i,e,s,n,o,r,l,h,a,f)=>{if(!Geo.zi(w,t,o,r,f,i,e)||!Geo.zi(w,t,o,r,f,s,n)){const c=(w+i)/2,u=(t+e)/2,d=(i+s)/2,m=(e+n)/2,g=(s+o)/2,p=(n+r)/2,y=(c+d)/2,x=(u+m)/2,k=(d+g)/2,b=(m+p)/2,S=(y+k)/2,M=(x+b)/2;return Geo.Lw(w,t,c,u,y,x,S,M,l,h,a,f)||Geo.Lw(S,M,k,b,g,p,o,r,l,h,a,f)}else return Geo.zi(w,t,o,r,f,h,a)},bC:(w,t,i,e,s,n,o,r,l)=>{const h=(w+i)/2,a=(t+e)/2,f=(i+s)/2,c=(e+n)/2,u=(s+o)/2,d=(n+r)/2,m=(h+f)/2,g=(a+c)/2,p=(f+u)/2,y=(c+d)/2;return l.e((m+p)/2,(g+y)/2),l},YD:(w,t,i,e,s,n,o,r)=>{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,f=(e+n)/2,c=(s+o)/2,u=(n+r)/2,d=(l+a)/2,m=(h+f)/2,g=(a+c)/2,p=(f+u)/2;return Point.direction(d,m,g,p)},mu:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.zi(w,t,o,r,l,i,e)||!Geo.zi(w,t,o,r,l,s,n)){const a=(w+i)/2,f=(t+e)/2,c=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+c)/2,p=(f+u)/2,y=(c+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.mu(w,t,a,f,g,p,k,b,l,h),Geo.mu(k,b,y,x,d,m,o,r,l,h)}else h.unionNoCheck(w,t,0,0),h.unionNoCheck(o,r,0,0);return h},Gn:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.zi(w,t,o,r,l,i,e)||!Geo.zi(w,t,o,r,l,s,n)){const a=(w+i)/2,f=(t+e)/2,c=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+c)/2,p=(f+u)/2,y=(c+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.Gn(w,t,a,f,g,p,k,b,l,h),Geo.Gn(k,b,y,x,d,m,o,r,l,h)}else h.length===0&&(h.push(w),h.push(t)),h.push(o),h.push(r);return h},qk:(w,t,i,e,s,n,o,r,l,h)=>{if(Geo.zi(w,t,s,n,h,i,e))return Geo.zi(w,t,s,n,h,r,l);{const a=(w+i)/2,f=(t+e)/2,c=(i+s)/2,u=(e+n)/2,d=(a+c)/2,m=(f+u)/2;return Geo.qk(w,t,a,f,d,m,o,r,l,h)||Geo.qk(d,m,c,u,s,n,o,r,l,h)}},nE:(w,t,i,e,s,n,o)=>{const r=(w+i)/2,l=(t+e)/2,h=(i+s)/2,a=(e+n)/2;return o.e((r+h)/2,(l+a)/2),o},jk:(w,t,i,e,s,n,o,r)=>{if(Geo.zi(w,t,s,n,o,i,e))r.unionNoCheck(w,t,0,0),r.unionNoCheck(s,n,0,0);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,f=(e+n)/2,c=(l+a)/2,u=(h+f)/2;Geo.jk(w,t,l,h,c,u,o,r),Geo.jk(c,u,a,f,s,n,o,r)}return r},jg:(w,t,i,e,s,n,o,r)=>{if(Geo.zi(w,t,s,n,o,i,e))r.length===0&&(r.push(w),r.push(t)),r.push(s),r.push(n);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,f=(e+n)/2,c=(l+a)/2,u=(h+f)/2;Geo.jg(w,t,l,h,c,u,o,r),Geo.jg(c,u,a,f,s,n,o,r)}return r},Wg:(w,t,i,e,s,n,o,r,l,h,a,f,c,u)=>{if(!Geo.zi(w,t,o,r,c,i,e)||!Geo.zi(w,t,o,r,c,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,S=(g+y)/2,M=(p+x)/2,A=(k+S)/2,C=(b+M)/2;let P=1/0,N=!1,T=0,L=0;if(Geo.Wg(w,t,d,m,k,b,A,C,l,h,a,f,c,u)){const D=(u.x-l)*(u.x-l)+(u.y-h)*(u.y-h);D{let u=0;if(!Geo.zi(w,t,o,r,c,i,e)||!Geo.zi(w,t,o,r,c,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,S=(g+y)/2,M=(p+x)/2,A=(k+S)/2,C=(b+M)/2;u+=Geo.vg(w,t,d,m,k,b,A,C,l,h,a,f,c),u+=Geo.vg(A,C,S,M,y,x,o,r,l,h,a,f,c)}else{const d=(w-o)*(h-f)-(t-r)*(l-a);if(d===0)return u;const m=((w*r-t*o)*(l-a)-(w-o)*(l*f-h*a))/d,g=((w*r-t*o)*(h-f)-(t-r)*(l*f-h*a))/d;if(m>=a)return u;let p=0,y=0;if((l>a?l-a:a-l)<(h>f?h-f:f-h)){if(ty)return u}else if(wy)return u;d>0?u++:d<0&&u--}return u},xl:(w,t,i,e,s,n,o)=>{if(Geo.q(w,i)){let r=0,l=0;tl?(o.e(w,l),!1):(o.e(w,h),!0)}else if(Geo.q(t,e)){let r=0,l=0;wl?(o.e(l,t),!1):(o.e(h,t),!0)}else{const r=(i-w)*(i-w)+(e-t)*(e-t),l=((w-s)*(w-i)+(t-n)*(t-e))/r;if(l<-5e-6)return o.e(w,t),!1;if(l>1.000005)return o.e(i,e),!1;{const h=w+l*(i-w),a=t+l*(e-t);return o.e(h,a),!0}}},Hn:(w,t,i,e,s,n,o,r,l)=>{if(Geo.p(w,i)&&Geo.p(t,e))return l.e(w,t),!1;if(Geo.q(s,o)){if(Geo.q(w,i))return Geo.xl(w,t,i,e,s,n,l),!1;{const a=(e-t)/(i-w)*(s-w)+t;return Geo.xl(w,t,i,e,s,a,l)}}else{const h=(r-n)/(o-s);if(Geo.q(w,i)){const a=h*(w-s)+n;let f=0,c=0;return tc?(l.e(w,c),!1):(l.e(w,a),!0)}else{const a=(e-t)/(i-w);if(Geo.q(h,a))return Geo.xl(w,t,i,e,s,n,l),!1;{const f=(a*w-h*s+n-t)/(a-h);if(Geo.q(a,0)){let c=0,u=0;return wu?(l.e(u,t),!1):(l.e(f,t),!0)}else{const c=a*(f-w)+t;return Geo.xl(w,t,i,e,f,c,l)}}}}},oE:(w,t,i,e,s)=>Geo.Hn(i.x,i.y,e.x,e.y,w.x,w.y,t.x,t.y,s),rE:(w,t,i,e,s,n,o,r,l,h)=>{let a=1/0;function f(S,M){const A=(S-w)*(S-w)+(M-t)*(M-t);Aw?i-w:w-i)<.5){const S=1-(i-k)*(i-k)/(y*y);if(S<0)return l;const M=Math.sqrt(S),A=x*M+b,C=-x*M+b;f(i,A),f(i,C)}else{const S=(e-t)/(i-w),M=1/(y*y)+S*S/(x*x),A=2*S*(t-S*w)/(x*x)-2*S*b/(x*x)-2*k/(y*y),C=2*S*w*b/(x*x)-2*t*b/(x*x)+b*b/(x*x)+k*k/(y*y)-1+(t-S*w)*(t-S*w)/(x*x),P=A*A-4*M*C;if(P<0)return l;const N=Math.sqrt(P),T=(-A+N)/(2*M);f(T,S*T-S*w+t);const L=(-A-N)/(2*M);f(L,S*L-S*w+t)}return l},bl:(w,t,i,e,s,n,o,r,l)=>{let h=1e21,a=w,f=t;if(Geo.Hn(w,t,w,e,s,n,o,r,l)){const c=(l.x-s)*(l.x-s)+(l.y-n)*(l.y-n);cGeo.dC(w.x,w.y,w.width,w.height,t.x,t.y,i.x,i.y),dC:(w,t,i,e,s,n,o,r)=>{const l=w,h=w+i,a=t,f=t+e;if(s===o){let c=0,u=0;return n=a}if(n===r){let c=0,u=0;return s=l}return!!(Rect.contains(w,t,i,e,s,n)||Rect.contains(w,t,i,e,o,r)||Geo.du(l,a,h,a,s,n,o,r)||Geo.du(h,a,h,f,s,n,o,r)||Geo.du(h,f,l,f,s,n,o,r)||Geo.du(l,f,l,a,s,n,o,r))},du:(w,t,i,e,s,n,o,r)=>w===i&&t===e&&s===o&&n===r?w===s&&t===n:Geo.uu(w,t,i,e,s,n)*Geo.uu(w,t,i,e,o,r)<=0&&Geo.uu(s,n,o,r,w,t)*Geo.uu(s,n,o,r,i,e)<=0,uu:(w,t,i,e,s,n)=>{const o=i-w,r=e-t;let l=s-w,h=n-t,a=l*r-h*o;return a===0&&(a=l*o+h*r,a>0&&(l-=o,h-=r,a=l*o+h*r,a<0&&(a=0))),a},Jg:w=>(w<0&&(w+=360),w>=360&&(w-=360),w),kC:(w,t,i,e,s,n)=>{const o=Math.PI;n||(e=e*(o/180),s=s*(o/180));const r=e>s?-1:1,l=1e-5,h=o*2,a=[],f=o/2;let c=e,u=Math.min(h,Math.abs(s-e));if(ul;){const d=c+r*Math.min(u,f);a.push(Geo.KD(i,c,d,w,t)),u-=Math.abs(d-c),c=d}return a},KD:(w,t,i,e,s)=>{const n=(i-t)/2,o=w*Math.cos(n),r=w*Math.sin(n),l=o,h=-r,a=l*l+h*h,f=a+l*o+h*r,c=4/3*(Math.sqrt(2*a*f)-f)/(l*r-h*o),u=l-c*h,d=h+c*l,m=u,g=-d,p=n+t,y=Math.cos(p),x=Math.sin(p);return[e+w*Math.cos(t),s+w*Math.sin(t),e+u*y-d*x,s+u*x+d*y,e+m*y-g*x,s+m*x+g*y,e+w*Math.cos(i),s+w*Math.sin(i)]},Hg:(w,t,i,e,s,n,o)=>{const r=s,l=n,h=Math.floor((w-i)/r)*r+i,a=Math.floor((t-e)/l)*l+e;let f=h;h+r-w{let i=Math.max(w,t),e=Math.min(w,t),s=1,n=1;do s=i%e,n=e,i=e,e=s;while(s>0);return n},UD:(w,t,i,e)=>{const s=i<0,n=e<0;let o=0,r=0,l=0;w{let o=0;if(e>0)if(i>0){const r=w*w,l=t*t,h=w*i,a=t*e;let f=-l+a,c=-l+Math.sqrt(h*h+a*a),u=f;const d=9999999999;for(let p=0;p0)f=u;else if(k<0)c=u;else break}s=r*i/(u+r),n=l*e/(u+l);const m=s-i,g=n-e;o=Math.sqrt(m*m+g*g)}else s=0,n=t,o=Math.abs(e-t);else{const r=w*w-t*t,l=w*i;if(l(w[w.Line=1]="Line",w[w.Rectangle=2]="Rectangle",w[w.Ellipse=3]="Ellipse",w[w.Path=4]="Path",w))(GeometryType||{}),GeometryStretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w))(GeometryStretch||{});class Geometry{l;Qg;_g;af;pu;yu;jn;Wn;vn;st;Pe;Ne;ee;se;Vs;ff;cf;constructor(t){Debug&&arguments.length>1&&Util.n("Geometry constructor can take at most one optional argument, the Geometry type."),GSet.vi(this),this.l=2,t===void 0?t=4:Debug&&Util.tt(t,GeometryType,"GeometryType"),this.st=t,this.Pe=0,this.Ne=0,this.ee=0,this.se=0,t===4?this.Vs=new List:this.Vs=Geometry.Dw,this.Qg=this.Vs.gt,this._g=new Rect().w(),this.af=null,this.pu=null,this.yu=NaN,this.jn=Spot.TopLeft,this.Wn=Spot.BottomRight,this.ff=NaN,this.cf=NaN,this.vn=2}copy(){const t=new Geometry;if(t.l=this.l&-2,t.st=this.st,t.Pe=this.Pe,t.Ne=this.Ne,t.ee=this.ee,t.se=this.se,this.st===4){const i=this.Vs.h,e=t.Vs;for(let s=0;si.toString(t)}fi(t){t in GeometryType?this.type=t:Util.ur(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e;switch(this.type){case 1:return t<0?"M"+this.startX.toString()+" "+this.startY.toString()+"L"+this.endX.toString()+" "+this.endY.toString():"M"+i(this.startX)+" "+i(this.startY)+"L"+i(this.endX)+" "+i(this.endY);case 2:return e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0?"M"+e.x.toString()+" "+e.y.toString()+"H"+e.right.toString()+"V"+e.bottom.toString()+"H"+e.left.toString()+"z":"M"+i(e.x)+" "+i(e.y)+"H"+i(e.right)+"V"+i(e.bottom)+"H"+i(e.left)+"z";case 3:if(e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0){const r=e.left.toString()+" "+(e.y+e.height/2).toString(),l=e.right.toString()+" "+(e.y+e.height/2).toString();return"M"+r+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+l+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+r}else{const r=i(e.left)+" "+i(e.y+e.height/2),l=i(e.right)+" "+i(e.y+e.height/2);return"M"+r+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+l+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+r}case 4:let s="";const n=this.figures.h,o=n.length;for(let r=0;r0&&(s+=" x "),l.isFilled&&(s+="F "),s+=l.toString(t)}return s;default:return GeometryType[this.type]}}static fillPath(t){typeof t!="string"&&Util.Vi(t,"string",Geometry,"fillPath:str");const i=t.split(/[Xx]/),e=i.length;let s="";for(let n=0;n=k-1||o[r+1].match(N)!==null?!0:(u=!1,!1)}function m(){return r++,o[r]}function g(L){let D=parseFloat(m()),F=parseFloat(m());l===l.toLowerCase()&&(D=c.x+D,F=c.y+F),L.e(D,F)}function p(){return g(c),c}function y(){return g(f),f}function x(){const L=h.toLowerCase();return L==="c"||L==="s"||L==="q"||L==="t"?new Point(2*c.x-f.x,2*c.y-f.y):new Point(c.x,c.y)}const k=o.length,b=GeoStream.PC(null);let S=!1,M=!1,A=!1,C=!0,P=null;const N=new RegExp("["+Geometry.tm+"]");for(;!(r>=k-1);){if(h=l,l=m(),l==="")continue;u=!0;let L=!1;switch(l.toUpperCase()){case"X":C=!0,S=!1,M=!1;break;case"M":for(P=p(),b.Ci===null||C===!0?(b.wu(P.x,P.y,S,!1,!M,A),C=!1):b.HD(P.x,P.y),a.c(c);!d();)P=p(),b.yr(P.x,P.y);break;case"L":for(;!d();)P=p(),b.yr(P.x,P.y);u&&(L=!0);break;case"H":for(;!d();)c.e((l===l.toLowerCase()?c.x:0)+parseFloat(m()),c.y),b.yr(c.x,c.y);break;case"V":for(;!d();)c.e(c.x,(l===l.toLowerCase()?c.y:0)+parseFloat(m())),b.yr(c.x,c.y);u&&(L=!0);break;case"C":for(;!d();){const D=new Point;g(D);const F=y(),R=p();b.wr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(L=!0);break;case"S":for(;!d();){const D=x(),F=y(),R=p();b.wr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(L=!0);break;case"Q":for(;!d();){const D=y(),F=p();b.Fw(D.x,D.y,F.x,F.y)}u&&(L=!0);break;case"T":for(;!d();){const D=x();f.c(D);const F=p();b.Fw(D.x,D.y,F.x,F.y),f.c(F)}u&&(L=!0);break;case"B":for(;!d();){const D=parseFloat(m()),F=parseFloat(m());let R=parseFloat(m()),I=parseFloat(m());const O=parseFloat(m());let B=O,K=!1;d()||(B=parseFloat(m()),d()||(K=parseFloat(m())!==0)),l===l.toLowerCase()&&(R+=c.x,I+=c.y),b.qD(D,F,R,I,O,B,K)}u&&(L=!0);break;case"A":for(;!d();){const D=Math.abs(parseFloat(m())),F=Math.abs(parseFloat(m())),R=parseFloat(m());let I=!1,O=!1,B=0,K=0;const V=m();V.length===1?(I=!!parseFloat(V),O=!!parseFloat(m()),B=parseFloat(m()),K=parseFloat(m())):V.length===2?(I=!!parseFloat(V[0]),O=!!parseFloat(V[1]),B=parseFloat(m()),K=parseFloat(m())):(I=!!parseFloat(V[0]),O=!!parseFloat(V[1]),B=parseFloat(V.slice(2)),K=parseFloat(m())),l===l.toLowerCase()&&(B=c.x+B,K=c.y+K),c.e(B,K),b.jD(D,F,R,I,O,B,K)}u&&(L=!0);break;case"Z":b.WD(),c.c(a);break;case"F":{let D="",F=1;for(;o[r+F];){if(o[r+F]==="0"){A=!0,F++;continue}if(o[r+F].match(/[Uu]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?S=!0:b.vD();break}case"U":{let D="",F=1;for(;o[r+F];){if(o[r+F].match(/[Ff]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?M=!0:b.JD(!1);break}default:if(l==="0"||l==="1")break;Util.at("Unknown geometry command: "+l);break}if(L){Util.at(`Bad geometry command: ${l}, next token: ${m()}, -string: ${t}`);break}}const T=b.im;if(GeoStream.NC(b),i){const L=T.figures.iterator;for(;L.next();){const D=L.value;D.isFilled=!0}}return T}static CC(t,i){const e=t.length,s=Point.a();for(let n=0;n=t)return 0;if((n>r?n-r:r-n)<(o>l?o-l:l-o)){if(ol)return 0}else if(fo)return 0}else if(nr)return 0}else if(an)return 0;return h>0?1:-1}LC(t,i,e){const s=this.figures.h,n=s.length;for(let o=0;o1&&(t=1),i===void 0&&(i=new Point),this.type===1)return i.e(this.startX+t*(this.endX-this.startX),this.startY+t*(this.endY-this.startY)),i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[c*2],y=g[c*2+1],x=g[c*2+2],k=g[c*2+3];return i.e(p+(x-p)*m,y+(k-y)*m),i}l+=u}}return i}getAngleAlongPath(t){if(t<0?t=0:t>1&&(t=1),this.type===1)return Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI;const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=i.length,o=s*t;let r=0;for(let l=0;l=o){const u=i[l],d=u[f*2],m=u[f*2+1],g=u[f*2+2],p=u[f*2+3];return Math.abs(g-d)<1&&Math.abs(p-m)<1?0:Math.abs(g-d)<1?p-m>=0?90:270:Math.abs(p-m)<1?g-d>=0?0:180:Math.atan2(p-m,g-d)*180/Math.PI}r+=c}}return NaN}getPointAndAngleAlongPath(t,i){if(t<0?t=0:t>1&&(t=1),i===void 0&&(i=[]),i.length=3,this.type===1)return i[0]=this.startX+t*(this.endX-this.startX),i[1]=this.startY+t*(this.endY-this.startY),i[2]=Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI,i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[c*2],y=g[c*2+1],x=g[c*2+2],k=g[c*2+3];i[0]=p+(x-p)*m,i[1]=y+(k-y)*m;let b;return Math.abs(x-p)<1&&Math.abs(k-y)<1?b=0:Math.abs(x-p)<1?b=k-y>=0?90:270:Math.abs(k-y)<1?b=x-p>=0?0:180:b=Math.atan2(k-y,x-p)*180/Math.PI,i[2]=b,i}l+=u}}return i}getFractionForPoint(t){if(this.type===1){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=t.x,r=t.y;let l=0,h=0;if(i===s)return e=h?h===e?0:1:Math.abs(r-e)/(h-l);if(e===n)return i=h?h===i?0:1:Math.abs(o-i)/(h-l);{const a=(s-i)*(s-i)+(n-e)*(n-e),f=Point.a();Geo.xl(i,e,s,n,o,r,f);const c=f.x,u=f.y;return Point.o(f),Math.sqrt(((c-i)*(c-i)+(u-e)*(u-e))/a)}}}else if(this.type===2){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=s-i,r=n-e,l=o*2+r*2;let h=t.x,a=t.y;h=Math.min(Math.max(h,i),s),a=Math.min(Math.max(a,e),n);const f=Math.abs(h-i),c=Math.abs(h-s),u=Math.abs(a-e),d=Math.abs(a-n),m=Math.min(f,c,u,d);if(m===u)return h/l;if(m===c)return(o+a)/l;if(m===d)return(o*2+r-h)/l;if(m===f)return(o*2+r*2-a)/l}}else{const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=Point.a();let o=1/0,r=0,l=0;const h=i.length;let a=0,f=0;for(let u=0;u1?1:c}return 0}get flattenedSegments(){return this.TC(),this.af}TC(){if(this.af===null){const t=this.af=[],i=this.pu=[];this.QD(t,i)}}get flattenedLengths(){return this.TC(),this.pu}get flattenedTotalLength(){let t=this.yu;if(isNaN(t)){if(this.type===1){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=Math.sqrt(i*i+e*e)}else if(this.type===2){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=i*2+e*2}else{const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=4&&(t.push(e),i.push(this.Zk(e))),e=[],e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY,h=r,a=l;break;case 2:e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY;break;case 3:Geo.Gn(r,l,d.point1X,d.point1Y,d.point2X,d.point2Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 4:Geo.jg(r,l,d.point1X,d.point1Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 5:{const m=d.To(o),g=m.length;if(g===0){e.push(d.centerX),e.push(d.centerY),r=d.centerX,l=d.centerY;break}for(let p=0;p=4&&(t.push(e),i.push(this.Zk(e)))}}}get type(){return this.st}set type(t){this.st!==t&&(Debug&&Util.tt(t,GeometryType,"GeometryType"),this.f&&Util.F(this,t),this.st=t,t===4?this.Vs=new List:(Geometry.Dw===null&&(Geometry.Dw=new List().w()),this.Vs=Geometry.Dw),this.Nt=!0)}get startX(){return this.Pe}set startX(t){this.Pe!==t&&(Debug&&Util.r(t,Geometry,"startX"),this.f&&Util.F(this,t),this.Pe=t,this.Nt=!0)}get startY(){return this.Ne}set startY(t){this.Ne!==t&&(Debug&&Util.r(t,Geometry,"startY"),this.f&&Util.F(this,t),this.Ne=t,this.Nt=!0)}get endX(){return this.ee}set endX(t){this.ee!==t&&(Debug&&Util.r(t,Geometry,"endX"),this.f&&Util.F(this,t),this.ee=t,this.Nt=!0)}get endY(){return this.se}set endY(t){this.se!==t&&(Debug&&Util.r(t,Geometry,"endY"),this.f&&Util.F(this,t),this.se=t,this.Nt=!0)}get figures(){return this.Vs}set figures(t){this.Vs!==t&&(Debug&&Util.s(t,List,Geometry,"figures"),this.f&&Util.F(this,t),this.Vs=t,this.Nt=!0)}add(t){return this.Vs.add(t),this}setSpots(t,i,e,s,n,o,r,l){return this.f&&Util.F(this),this.jn=new Spot(t,i,n,o).w(),this.Wn=new Spot(e,s,r,l).w(),this}get spot1(){return this.jn}set spot1(t){Debug&&Util.s(t,Spot,Geometry,"spot1"),this.f&&Util.F(this,t),this.jn=t.L()}get spot2(){return this.Wn}set spot2(t){Debug&&Util.s(t,Spot,Geometry,"spot2"),this.f&&Util.F(this,t),this.Wn=t.L()}get defaultStretch(){return this.vn}set defaultStretch(t){this.vn=t}get bounds(){return this.Wk()&&this.Rw(),this._g}}Geometry.stringify=Geometry.stringify,Geometry.stringifyFixed=Geometry.stringifyFixed,Geometry.fillPath=Geometry.fillPath,Geometry.parse=Geometry.parse;class PathFigure{l;Pe;Ne;uf;em;Ue;constructor(t,i,e,s,n){e===void 0&&(e=!0),s===void 0&&(s=!0),n===void 0&&(n=!1),this.l=2|(e?4:0)|(s?8:0)|(n?16:0),t!==void 0?(Debug&&Util.r(t,PathFigure,"sx"),this.Pe=t):this.Pe=0,i!==void 0?(Debug&&Util.r(i,PathFigure,"sy"),this.Ne=i):this.Ne=0,this.uf=new List,this.em=this.uf.gt,this.Ue=null}copy(){const t=new PathFigure;t.l=this.l&-2,t.Pe=this.Pe,t.Ne=this.Ne;const i=this.uf.h,e=i.length,s=t.uf;for(let n=0;no===0?"0":o.toFixed(t);i="M"+n(this.startX)+" "+n(this.startY)}const e=this.segments.h,s=e.length;for(let n=0;n(w[w.Move=1]="Move",w[w.Line=2]="Line",w[w.Bezier=3]="Bezier",w[w.QuadraticBezier=4]="QuadraticBezier",w[w.Arc=5]="Arc",w[w.SvgArc=6]="SvgArc",w))(SegmentType||{});class PathSegment{st;l;ee;se;dn;kl;Sl;xr;Bs;constructor(t,i,e,s,n,o,r,l){if(GSet.vi(this),t===void 0?t=2:Debug&&Util.tt(t,SegmentType,"SegmentType"),this.st=t,this.l=2,i!==void 0?(Debug&&Util.r(i,PathSegment,"ex"),this.ee=i):this.ee=0,e!==void 0?(Debug&&Util.r(e,PathSegment,"ey"),this.se=e):this.se=0,s===void 0&&(s=0),n===void 0&&(n=0),o===void 0&&(o=0),r===void 0&&(r=0),t===6){let h=o;h=h%360,h<0&&(h+=360),this.dn=h,this.kl=0,Debug&&Util.r(s,PathSegment,"x1"),this.Sl=Math.max(s,0),Debug&&Util.r(n,PathSegment,"y1"),this.xr=Math.max(n,0),typeof r=="boolean"?r&&(this.isLargeArc=!0):typeof r=="number"&&r&&(this.isLargeArc=!0),l&&(this.isClockwiseArc=!0)}else Debug&&Util.r(s,PathSegment,"x1"),this.dn=s,Debug&&Util.r(n,PathSegment,"y1"),this.kl=n,Debug&&Util.r(o,PathSegment,"x2"),t===5&&(o=Math.max(o,0)),this.Sl=o,typeof r=="number"?(t===5&&(r=Math.max(r,0)),this.xr=r):this.xr=0;this.Bs=null}copy(){const t=new PathSegment;return t.st=this.st,t.l=this.l&-2,t.ee=this.ee,t.se=this.se,t.dn=this.dn,t.kl=this.kl,t.Sl=this.Sl,t.xr=this.xr,t}equalsApprox(t){if(!(t instanceof PathSegment)||this.type!==t.type||this.isClosed!==t.isClosed)return!1;switch(this.type){case 1:case 2:return Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY);case 3:return Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY)&&Geo.p(this.point1X,t.point1X)&&Geo.p(this.point1Y,t.point1Y)&&Geo.p(this.point2X,t.point2X)&&Geo.p(this.point2Y,t.point2Y);case 4:return Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY)&&Geo.p(this.point1X,t.point1X)&&Geo.p(this.point1Y,t.point1Y);case 5:return Geo.p(this.startAngle,t.startAngle)&&Geo.p(this.sweepAngle,t.sweepAngle)&&Geo.p(this.centerX,t.centerX)&&Geo.p(this.centerY,t.centerY)&&Geo.p(this.radiusX,t.radiusX)&&Geo.p(this.radiusY,t.radiusY);case 6:return this.isClockwiseArc===t.isClockwiseArc&&this.isLargeArc===t.isLargeArc&&Geo.p(this.xAxisRotation,t.xAxisRotation)&&Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY)&&Geo.p(this.radiusX,t.radiusX)&&Geo.p(this.radiusY,t.radiusY);default:return!1}}fi(t){t in SegmentType?this.type=t:Util.ur(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e="";switch(this.type){case 1:t<0?e="M"+this.endX.toString()+" "+this.endY.toString():e="M"+i(this.endX)+" "+i(this.endY);break;case 2:t<0?e="L"+this.endX.toString()+" "+this.endY.toString():e="L"+i(this.endX)+" "+i(this.endY);break;case 3:t<0?e="C"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.point2X.toString()+" "+this.point2Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="C"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.point2X)+" "+i(this.point2Y)+" "+i(this.endX)+" "+i(this.endY);break;case 4:t<0?e="Q"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="Q"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.endX)+" "+i(this.endY);break;case 5:t<0?e="B"+this.startAngle.toString()+" "+this.sweepAngle.toString()+" "+this.centerX.toString()+" "+this.centerY.toString()+" "+this.radiusX.toString()+" "+this.radiusY.toString():e="B"+i(this.startAngle)+" "+i(this.sweepAngle)+" "+i(this.centerX)+" "+i(this.centerY)+" "+i(this.radiusX)+" "+i(this.radiusY);break;case 6:t<0?e="A"+this.radiusX.toString()+" "+this.radiusY.toString()+" "+this.xAxisRotation.toString()+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+this.endX.toString()+" "+this.endY.toString():e="A"+i(this.radiusX)+" "+i(this.radiusY)+" "+i(this.xAxisRotation)+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+i(this.endX)+" "+i(this.endY);break;default:e=SegmentType[this.type]}return e+(this.isClosed?"z":"")}static Move=1;static Line=2;static Bezier=3;static QuadraticBezier=4;static Arc=5;static SvgArc=6;get f(){return(this.l&1)!==0}set f(t){t?this.l|=1:this.l&=-2}get Nt(){return(this.l&2)!==0}set Nt(t){t?this.l|=2:this.l&=-3}w(){return this.f=!0,this}ct(){return this.f=!1,this}close(){return this.isClosed=!0,this}To(t){if(this.Bs!==null&&t.Nt===!1)return this.Bs;const i=this.radiusX;let e=this.radiusY;if(e===void 0&&(e=i),i===0||e===0)return this.Bs=[],this.Bs;const s=this.dn,n=this.kl,o=Geo.kC(0,0,i1&&(o*=Math.sqrt(p),r*=Math.sqrt(p));let y=(h===a?-1:1)*Math.sqrt((o*o*r*r-o*o*g*g-r*r*m*m)/(o*o*g*g+r*r*m*m));isNaN(y)&&(y=0);let x=y*o*g/r,k=y*-r*m/o;isNaN(x)&&(x=0),isNaN(k)&&(k=0);const b=(s+f)/2+u*x-d*k,S=(n+c)/2+d*x+u*k,M=(X,z)=>Math.sqrt(X*X+z*z),A=(X,z,G,q)=>(X*G+z*q)/(M(X,z)*M(G,q)),C=(X,z,G,q)=>(X*q=1&&(F=0),!a&&F>0&&(F=F-2*Math.PI),a&&F<0&&(F=F+2*Math.PI);const I=o>r?o:r,O=o>r?1:o/r,B=o>r?r/o:1,K=Geo.kC(0,0,I,P,P+F,!0),V=Transform.a();return V.Bi(),V.Es(b,S),V.ms(this.dn,0,0),V.lt(O,B),Geometry.CC(K,V),Transform.o(V),this.Bs=K,this.Bs}get isClosed(){return(this.l&8)!==0}set isClosed(t){this.isClosed!==t&&(t?this.l|=8:this.l&=-9,this.Nt=!0)}get type(){return this.st}set type(t){Debug&&Util.tt(t,SegmentType,"SegmentType"),this.f&&Util.F(this,t),this.st=t,this.Nt=!0}get endX(){return this.ee}set endX(t){Debug&&Util.r(t,PathSegment,"endX"),this.f&&Util.F(this,t),this.ee=t,this.Nt=!0}get endY(){return this.se}set endY(t){Debug&&Util.r(t,PathSegment,"endY"),this.f&&Util.F(this,t),this.se=t,this.Nt=!0}get point1X(){return this.dn}set point1X(t){Debug&&Util.r(t,PathSegment,"point1X"),this.f&&Util.F(this,t),this.dn=t,this.Nt=!0}get point1Y(){return this.kl}set point1Y(t){Debug&&Util.r(t,PathSegment,"point1Y"),this.f&&Util.F(this,t),this.kl=t,this.Nt=!0}get point2X(){return this.Sl}set point2X(t){Debug&&Util.r(t,PathSegment,"point2X"),this.f&&Util.F(this,t),this.Sl=t,this.Nt=!0}get point2Y(){return this.xr}set point2Y(t){Debug&&Util.r(t,PathSegment,"point2Y"),this.f&&Util.F(this,t),this.xr=t,this.Nt=!0}get centerX(){return this.dn}set centerX(t){Debug&&Util.r(t,PathSegment,"centerX"),this.f&&Util.F(this,t),this.dn=t,this.Nt=!0}get centerY(){return this.kl}set centerY(t){Debug&&Util.r(t,PathSegment,"centerY"),this.f&&Util.F(this,t),this.kl=t,this.Nt=!0}get radiusX(){return this.Sl}set radiusX(t){Debug&&Util.r(t,PathSegment,"radiusX"),t<0&&Util.G(t,">= zero",PathSegment,"radiusX"),this.f&&Util.F(this,t),this.Sl=t,this.Nt=!0}get radiusY(){return this.xr}set radiusY(t){Debug&&Util.r(t,PathSegment,"radiusY"),t<0&&Util.G(t,">= zero",PathSegment,"radiusY"),this.f&&Util.F(this,t),this.xr=t,this.Nt=!0}get startAngle(){return this.ee}set startAngle(t){Debug&&Util.r(t,PathSegment,"startAngle"),this.f&&Util.F(this,t),t=t%360,t<0&&(t+=360),this.ee=t,this.Nt=!0}get sweepAngle(){return this.se}set sweepAngle(t){Debug&&Util.r(t,PathSegment,"sweepAngle"),this.f&&Util.F(this,t),t>360&&(t=360),t<-360&&(t=-360),this.se=t,this.Nt=!0}get isClockwiseArc(){return(this.l&4)!==0}set isClockwiseArc(t){this.f&&Util.F(this,t),t?this.l|=4:this.l&=-5,this.Nt=!0}get isLargeArc(){return(this.l&16)!==0}set isLargeArc(t){this.f&&Util.F(this,t),t?this.l|=16:this.l&=-17,this.Nt=!0}get xAxisRotation(){return this.dn}set xAxisRotation(t){Debug&&Util.r(t,PathSegment,"xAxisRotation"),this.f&&Util.F(this,t),t=t%360,t<0&&(t+=360),this.dn=t,this.Nt=!0}}class InputEvent{b;Ow;Ew;sm;nm;om;rm;lm;hm;am;fm;cm;um;dm;Do;gm;mm;pm;Ce;constructor(){this.b=null,this.Ow=new Point(0,0).w(),this.Ew=new Point(0,0).w(),this.sm=0,this.nm=0,this.om=1,this.rm="",this.lm="",this.hm=!1,this.am=!1,this.fm=0,this.cm=0,this.um=!1,this.dm=!1,this.Do=!1,this.gm=null,this.mm=0,this.pm=null,this.Ce=null}copy(){const t=new InputEvent;return this.clone(t)}clone(t){return t.b=this.b,t.Ow.c(this.viewPoint),t.Ew.c(this.documentPoint),t.sm=this.sm,t.nm=this.nm,t.om=this.om,t.rm=this.rm,t.lm=this.lm,t.hm=this.hm,t.am=this.am,t.fm=this.fm,t.cm=this.cm,t.um=this.um,t.dm=this.dm,t.Do=this.Do,t.gm=this.gm,t.mm=this.mm,t.pm=this.pm,t.Ce=this.Ce,t}toString(){let t="^";return this.modifiers!==0&&(t+="M:"+this.modifiers),this.button!==0&&(t+="B:"+this.button),this.key!==""&&(t+="K:"+this.key),this.clickCount!==0&&(t+="C:"+this.clickCount),this.delta!==0&&(t+="D:"+this.delta),this.handled&&(t+="h"),this.bubbles&&(t+="b"),this.documentPoint!==null&&(t+="@"+this.documentPoint.toString()),t}get diagram(){return this.b}set diagram(t){this.b=t}get viewPoint(){return this.Ow}set viewPoint(t){Util.s(t,Point,InputEvent,"viewPoint"),this.Ow.c(t)}get documentPoint(){return this.Ew}set documentPoint(t){Util.s(t,Point,InputEvent,"documentPoint"),this.Ew.c(t)}getMultiTouchViewPoint(t,i){const e=this.diagram;return e===null||e.DC(this.event,t,i),i}getMultiTouchDocumentPoint(t,i){const e=this.diagram;return e===null||(e.DC(this.event,t,i),i.c(e.transformViewToDoc(i))),i}get modifiers(){return this.sm}set modifiers(t){this.sm=t}get button(){return this.nm}set button(t){if(this.nm=t,this.event===null)switch(t){case 0:this.buttons=1;return;case 1:this.buttons=4;return;case 2:this.buttons=2;return}}get buttons(){return this.om}set buttons(t){this.om=t}get key(){return this.rm}set key(t){this.rm=t}get code(){return this.lm}set code(t){this.lm=t}get down(){return this.hm}set down(t){this.hm=t}get up(){return this.am}set up(t){this.am=t}get clickCount(){return this.fm}set clickCount(t){this.fm=t}get delta(){return this.cm}set delta(t){this.cm=t}get isMultiTouch(){return this.um}set isMultiTouch(t){this.um=t}get handled(){return this.dm}set handled(t){this.dm=t}get bubbles(){return this.Do}set bubbles(t){this.Do=t}get event(){return this.gm}set event(t){this.gm=t}get isTouchEvent(){const t=this.event;return t===null?!1:t.pointerType==="touch"||t.pointerType==="pen"}get timestamp(){return this.mm}set timestamp(t){this.mm=t}get targetDiagram(){return this.pm}set targetDiagram(t){this.pm=t}get targetObject(){return this.Ce}set targetObject(t){this.Ce=t}get control(){return(this.modifiers&1)!==0}set control(t){this.modifiers=t?this.modifiers|1:this.modifiers&-2}get shift(){return(this.modifiers&4)!==0}set shift(t){this.modifiers=t?this.modifiers|4:this.modifiers&-5}get alt(){return(this.modifiers&2)!==0}set alt(t){this.modifiers=t?this.modifiers|2:this.modifiers&-3}get meta(){return(this.modifiers&8)!==0}set meta(t){this.modifiers=t?this.modifiers|8:this.modifiers&-9}get left(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===0:(this.buttons&1)!==0}set left(t){t?this.buttons|=1:this.buttons&=-2}get right(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===2:(this.buttons&2)!==0}set right(t){t?this.buttons|=2:this.buttons&=-3}get middle(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===1:(this.buttons&4)!==0}set middle(t){t?this.buttons|=4:this.buttons&=-5}get commandKey(){const t=this.code,i=this.key;return"cxvyzagCXVYZAG".includes(i)?i.toLowerCase():t==="KeyC"?"c":t==="KeyX"?"x":t==="KeyV"?"v":t==="KeyY"?"y":t==="KeyZ"?"z":t==="KeyA"?"a":t==="KeyG"?"g":t!==""?t:i}}class DiagramEvent{b;Tt;ym;wm;constructor(){this.b=null,this.Tt="",this.ym=null,this.wm=null}copy(){const t=new DiagramEvent;return t.b=this.b,t.Tt=this.Tt,t.ym=this.ym,t.wm=this.wm,t}toString(){let t="*"+this.name;return this.subject!==null&&(t+=":"+this.subject.toString()),this.parameter!==null&&(t+="("+this.parameter.toString()+")"),t}get diagram(){return this.b}set diagram(t){this.b=t}get name(){return this.Tt}set name(t){this.Tt=t}get subject(){return this.ym}set subject(t){this.ym=t}get parameter(){return this.wm}set parameter(t){this.wm=t}}var ChangeType=(w=>(w[w.Transaction=1]="Transaction",w[w.Property=2]="Property",w[w.Insert=3]="Insert",w[w.Remove=4]="Remove",w))(ChangeType||{});class ChangedEvent{xu;xm;gn;Ai;b;bu;df;gf;mf;pf;constructor(){this.xu=2,this.xm="",this.gn="",this.Ai=null,this.b=null,this.bu=null,this.df=null,this.gf=null,this.mf=null,this.pf=null}static Transaction=1;static Property=2;static Insert=3;static Remove=4;clear(){this.Ai=null,this.b=null,this.bu=null,this.df=null,this.gf=null,this.mf=null,this.pf=null}copy(){const t=new ChangedEvent;t.xu=this.xu,t.xm=this.xm,t.gn=this.gn,t.Ai=this.Ai,t.b=this.b,t.bu=this.bu;let i=this.df;return Util.Mt(i)&&typeof i.copyFrozen=="function"?t.df=i.copyFrozen():t.df=i,i=this.gf,Util.Mt(i)&&typeof i.copyFrozen=="function"?t.gf=i.copyFrozen():t.gf=i,i=this.mf,Util.Mt(i)&&typeof i.copyFrozen=="function"?t.mf=i.copyFrozen():t.mf=i,i=this.pf,Util.Mt(i)&&typeof i.copyFrozen=="function"?t.pf=i.copyFrozen():t.pf=i,t}fi(t){t in ChangeType?this.change=t:Util.ur(this,t)}toString(){let t="";return this.change===1?t+="* ":this.change===2?t+=this.model!==null?"!m":"!d":t+=(this.model!==null?"!m":"!d")+this.change,this.propertyName&&typeof this.propertyName=="string"&&(t+=" "+this.propertyName),this.modelChange&&this.modelChange!==this.propertyName&&(t+=" "+this.modelChange),t+=": ",this.change===1?this.oldValue!==null&&(t+=" "+this.oldValue):(this.object!==null&&(t+=Util.toString(this.object)),this.oldValue!==null&&(t+=" old: "+Util.toString(this.oldValue)),this.oldParam!==null&&(t+=" "+this.oldParam),this.newValue!==null&&(t+=" new: "+Util.toString(this.newValue)),this.newParam!==null&&(t+=" "+this.newParam)),t}getValue(t){return t?this.oldValue:this.newValue}getParam(t){return t?this.oldParam:this.newParam}canUndo(){return this.model!==null||this.diagram!==null}undo(){this.canUndo()&&(this.model!==null?this.model.changeState(this,!0):this.diagram!==null&&this.diagram.FC(this,!0))}canRedo(){return this.model!==null||this.diagram!==null}redo(){this.canRedo()&&(this.model!==null?this.model.changeState(this,!1):this.diagram!==null&&this.diagram.FC(this,!1))}get model(){return this.Ai}set model(t){this.Ai=t}get diagram(){return this.b}set diagram(t){this.b=t}get change(){return this.xu}set change(t){this.xu=t}get modelChange(){return this.xm}set modelChange(t){Debug&&Util.t(t,"string",ChangedEvent,"modelChange"),this.xm=t}get propertyName(){return this.gn}set propertyName(t){Debug&&typeof t!="string"&&Util.t(t,"function",ChangedEvent,"propertyName"),this.gn=t}get isTransactionFinished(){return this.xu===1&&(this.gn==="CommittedTransaction"||this.gn==="FinishedUndo"||this.gn==="FinishedRedo")}get object(){return this.bu}set object(t){this.bu=t}get oldValue(){return this.df}set oldValue(t){this.df=t}get oldParam(){return this.gf}set oldParam(t){this.gf=t}get newValue(){return this.mf}set newValue(t){this.mf=t}get newParam(){return this.pf}set newParam(t){this.pf=t}}class Transaction{RC;Tt;$k;constructor(){this.RC=new List().w(),this.Tt="",this.$k=!1}toString(t){let i="Transaction: "+this.name+" "+this.changes.count.toString()+(this.isComplete?"":", incomplete");if(t!==void 0&&t>0){const e=this.changes.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),t.w()}canUndo(){return this.isComplete}undo(){if(this.canUndo())for(let t=this.changes.count-1;t>=0;t--){const i=this.changes.elt(t);i!==null&&i.undo()}}canRedo(){return this.isComplete}redo(){if(!this.canRedo())return;const t=this.changes.count;for(let i=0;i=t;e--){const s=i.elt(e);s!==null&&s.undo(),i.ct(),i.removeAt(e)}i.w()}optimize(){if(!this.isComplete)return;const t=this.changes;t.ct();const i=new GMap;for(let s=0;s0&&t.setElt(r,null),o.set(n.propertyName,s))}let e=0;for(let s=0;se&&t.setElt(e,n),e++)}for(;t.length>e;)t.pop();t.w()}get changes(){return this.RC}get name(){return this.Tt}set name(t){this.Tt=t}get isComplete(){return this.$k}set isComplete(t){this.$k=t}}class UndoManager{Vw;Xi;IC;zs;Qk;bm;Jn;Bw;_k;mn;yf;zw;Xs;Xw;Yw;km;Kw;constructor(t){this.Vw=new GSet,this.Xi=!1,this.IC=new List().w(),this.zs=-1,this.Qk=999,this.Xs=!1,this.bm=null,this.Jn=0,this.Bw=!1,Debug&&(this.Bw=!0),this._k=23,this.mn=new List().w(),this.yf=new List,this.zw=!0,this.Xw=!1,this.Yw=!1,this.km=!1,this.Kw=!1,t&&Object.assign(this,t)}toString(t){let i="UndoManager "+this.historyIndex+"<"+this.history.count+"<="+this.maxHistoryLength;i+="[";let e=this.nestedTransactionNames.count;for(let s=0;s0&&(i+=" "),i+=this.nestedTransactionNames.elt(s);if(i+="]",t!==void 0&&t>0){e=this.history.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),this.zs=-1,t.w(),this.Xs=!1,this.bm=null,this.Jn=0,this.mn.ct(),this.mn.clear(),this.mn.w(),this.yf.clear(),this.Xw=!1,this.Yw=!1,this.km=!1,this.Kw=!1}copyProperties(t){this.isEnabled=t.isEnabled,this.maxHistoryLength=t.maxHistoryLength,this.ku=t.ku}addModel(t){this.Vw.add(t)}removeModel(t){this.Vw.delete(t)}startTransaction(t){if(t===void 0&&(t=""),t===null&&(t=""),this.isUndoingRedoing)return!1;this.zw===!0&&(this.zw=!1,this.Jn++,this.Ml||this.i("StartingFirstTransaction",t,this.currentTransaction),this.Jn>0&&this.Jn--),this.isEnabled&&(this.mn.ct(),this.mn.add(t),this.mn.w(),this.currentTransaction===null?this.yf.add(0):this.yf.add(this.currentTransaction.changes.count)),this.Jn++;const i=this.transactionLevel===1;return i&&(this.Ml||this.i("StartedTransaction",t,this.currentTransaction)),i}commitTransaction(t){return t===void 0&&(t=""),this.OC(!0,t)}rollbackTransaction(){return this.OC(!1,"")}OC(t,i){if(this.isUndoingRedoing)return!1;this.ku&&this.transactionLevel<1&&Util.at("Ending transaction without having started a transaction: "+i);const e=this.transactionLevel===1;let s=this.currentTransaction;e&&t&&(this.Ml||this.i("CommittingTransaction",i,s));let n=0;if(this.transactionLevel>0&&(this.Jn--,this.isEnabled)){const o=this.mn.count;o>0&&(i===""&&(i=this.mn.elt(0)),this.mn.ct(),this.mn.removeAt(o-1),this.mn.w());const r=this.yf.count;r>0&&(n=this.yf.elt(r-1),this.yf.removeAt(r-1))}if(e){if(t){if(this.km=!1,s===null&&i!==""&&(s=this.currentTransaction),this.isEnabled&&s!==null){const o=s;o.isComplete||(o.isComplete=!0,o.name=i),this.discardHistoryAfterIndex();const r=this.history;r.ct();const l=this.maxHistoryLength;if(l>=0){if(l===0)r.clear();else if(r.count>=l){const h=r.elt(0);h!==null&&h.clear(),r.removeAt(0),this.zs--}}l!==0&&(r.count===0||r.get(r.count-1)!==o)&&(r.add(o),this.zs++),r.w(),s=o}this.Ml||this.i("CommittedTransaction",i,s)}else{this.Xs=!0;try{this.isEnabled&&s!==null&&(s.isComplete=!0,s.undo())}finally{this.Ml||this.i("RolledBackTransaction",i,s),this.Xs=!1}s!==null&&s.clear()}return this.bm=null,this.Uw&&this.clear(),this.Uw=!1,this.Gw=!1,!0}else return this.isEnabled&&!t&&s!==null&&s._D(n),!1}discardHistoryAfterIndex(){if(this.isUndoingRedoing||!this.canRedo())return;const t=this.history;t.ct();for(let i=t.count-1;i>this.historyIndex;i--){const e=t.elt(i);e!==null&&e.clear(),t.removeAt(i),this.km=!0}t.w()}lE(t){this.Jn+=t,this.Jn<0&&(this.Jn=0)}canUndo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToUndo;return!!(t!==null&&t.canUndo())}undo(){if(!this.canUndo())return;const t=this.transactionToUndo;try{this.Xs=!0,this.i("StartingUndo","Undo",t),this.zs--,t.undo()}catch(i){Util.at("undo error: "+i.toString())}finally{this.i("FinishedUndo","Undo",t),this.Xs=!1}}canRedo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToRedo;return!!(t!==null&&t.canRedo())}redo(){if(!this.canRedo())return;const t=this.transactionToRedo;try{this.Xs=!0,this.i("StartingRedo","Redo",t),this.zs++,t.redo()}catch(i){Util.at("redo error: "+i.toString())}finally{this.i("FinishedRedo","Redo",t),this.Xs=!1}}i(t,i,e){e===void 0&&(e=null);const s=new ChangedEvent;s.change=1,s.propertyName=t,s.object=e,s.oldValue=i;const n=this.models;for(;n.next();){const o=n.value;s.model=o,o.Hw(s)}}handleChanged(t){if(this.isEnabled&&!this.isUndoingRedoing&&!this.skipsEvent(t)){let i=this.currentTransaction;i===null&&(i=new Transaction,this.bm=i);const e=t.copy(),s=i.changes;if(s.ct(),s.add(e),s.w(),this.ku&&this._k>0&&this.transactionLevel<=0&&!this.zw){const n=t.diagram;if(n!==null&&n.Yh===!1)return;Util.at("Change not within a transaction: "+e.toString()),this._k--}}}skipsEvent(t){if(t===null||t.change===1)return!0;const i=t.object;if(i===null)return!1;if(i.layer!==void 0){const e=i.layer;if(e!==null&&e.isTemporary)return!0}else if(i.isTemporary)return!0;return!1}get models(){return this.Vw.iterator}get isEnabled(){return this.Xi}set isEnabled(t){this.Xi=t}get transactionToUndo(){return this.historyIndex>=0&&this.historyIndex<=this.history.count-1?this.history.elt(this.historyIndex):null}get transactionToRedo(){return this.historyIndex0}get ku(){return this.Bw}set ku(t){this.Bw=t}get nestedTransactionNames(){return this.mn}get Uw(){return this.Xw}set Uw(t){this.Xw=t}get Gw(){return this.Yw}set Gw(t){this.Yw=t}get Ml(){return this.Kw}set Ml(t){this.Kw=t}get isJustDiscarded(){return this.km}}class Tool{b;Tt;Xi;tS;iS;Sm;EC;constructor(){GSet.vi(this),this.b=Diagram.Mm(),this.Tt="",this.Xi=!0,this.tS=!1,this.iS=null,this.EC=new InputEvent,this.Sm=-1}get diagram(){return this.b}set diagram(t){t instanceof Diagram&&(this.b=t)}toString(){return this.name!==""?this.name+" Tool":Util.hn(this.constructor)}updateAdornments(t){}canStart(){return this.isEnabled}doStart(){}doActivate(){this.isActive=!0}doDeactivate(){this.isActive=!1}doStop(){}doCancel(){this.transactionResult=null,this.stopTool()}stopTool(){const t=this.diagram;t.currentTool===this&&(t.currentTool=null,t.currentCursor="")}doMouseDown(){!this.isActive&&this.canStart()&&this.doActivate()}doMouseMove(){}doMouseUp(){this.stopTool()}doMouseWheel(){}canStartMultiTouch(){return!0}standardPinchZoomStart(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.H(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.H(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.o(e),Point.o(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){t.eS=t.scale;const n=s.x-e.x,o=s.y-e.y,r=Math.sqrt(n*n+o*o);t.sS=r,i.bubbles=!1}Point.o(e),Point.o(s)}standardPinchZoomMove(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.H(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.H(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.o(e),Point.o(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){const n=s.x-e.x,o=s.y-e.y,l=Math.sqrt(n*n+o*o)/t.sS,h=new Point((Math.min(s.x,e.x)+Math.max(s.x,e.x))/2,(Math.min(s.y,e.y)+Math.max(s.y,e.y))/2),a=t.eS*l,f=t.commandHandler;if(a!==t.scale&&f.canResetZoom(a)){const c=t.zoomPoint;t.zoomPoint=h,f.resetZoom(a),t.zoomPoint=c}i.bubbles=!1}Point.o(e),Point.o(s)}doKeyDown(){this.diagram.lastInput.code==="Escape"&&this.doCancel()}doKeyUp(){}startTransaction(t){return t===void 0&&(t=this.name),this.transactionResult=null,this.diagram.startTransaction(t)}stopTransaction(){const t=this.diagram;return this.transactionResult===null?t.rollbackTransaction():t.commitTransaction(this.transactionResult)}standardMouseSelect(){const t=this.diagram;if(!t.allowSelect)return;const i=t.lastInput,e=t.findPartAt(i.documentPoint,!1);if(e!==null){if(Util.cr?i.meta:i.control){t.V("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!s.isSelected),t.V("ChangedSelection",t.selection)}else if(i.shift){if(!e.isSelected){t.V("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!0),t.V("ChangedSelection",t.selection)}}else if(!e.isSelected){let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&t.select(s)}}else i.left&&!(Util.cr?i.meta:i.control)&&!i.shift&&t.clearSelection()}standardMouseClick(t,i){t===void 0&&(t=null),i===void 0&&(i=o=>!o.layer.isTemporary);const e=this.diagram,s=e.lastInput,n=e.findObjectAt(s.documentPoint,t,i);return s.targetObject=n,this.tF(n,s,e),s.handled}tF(t,i,e){if(i.handled=!1,t!==null&&!t.isEnabledObject())return;let s=0;i.left?i.clickCount===1?s=1:i.clickCount===2?s=2:s=1:i.right&&i.clickCount===1&&(s=3);let n="ObjectSingleClicked";if(t!==null){switch(s){case 1:n="ObjectSingleClicked";break;case 2:n="ObjectDoubleClicked";break;case 3:n="ObjectContextClicked";break}s!==0&&e.V(n,t)}else{switch(s){case 1:n="BackgroundSingleClicked";break;case 2:n="BackgroundDoubleClicked";break;case 3:n="BackgroundContextClicked";break}s!==0&&e.V(n)}if(t!==null)for(;t!==null;){let o=null;switch(s){case 1:o=t.click;break;case 2:o=t.doubleClick?t.doubleClick:t.click;break;case 3:o=t.contextClick;break}if(o!==null&&(o(i,t),i.handled))break;t=t.panel}else{let o=null;switch(s){case 1:o=e.click;break;case 2:o=e.doubleClick?e.doubleClick:e.click;break;case 3:o=e.contextClick;break}o!==null&&o(i)}}standardMouseOver(){const t=this.diagram,i=t.lastInput;if(t.animationManager.Si===!0)return;const e=t.skipsUndoManager;t.skipsUndoManager=!0;let s=t.viewportBounds.containsPoint(i.documentPoint)?t.findObjectAt(i.documentPoint,null,null):null;i.event&&(i.event.type==="pointercancel"||i.event.type==="pointerout")&&(s=null),i.targetObject=s;let n=!1;if(s!==t.wf){let o=t.wf;const r=o;for(t.wf=s,this.doCurrentObjectChanged(o,s),i.handled=!1;o!==null;){const l=o.mouseLeave;if(l!==null&&(s===o||s!==null&&s.isContainedBy(o)||(l(i,o,s),n=!0,i.handled)))break;o=o.panel}for(o=r,i.handled=!1;s!==null;){const l=s.mouseEnter;if(l!==null&&(o===s||o!==null&&o.isContainedBy(s)||(l(i,s,o),n=!0,i.handled)))break;s=s.panel}s=t.wf}if(s!==null){let o=s,r="";for(;o!==null&&(r=o.cursor,r==="");)o=o.panel;for(t.currentCursor=r,i.handled=!1,o=s;o!==null;){const l=o.mouseOver;if(l!==null&&(l(i,o),n=!0,i.handled))break;o=o.panel}}else{this.doUpdateCursor(null);const o=t.mouseOver;o!==null&&(o(i),n=!0)}n&&t.requestUpdate(),t.skipsUndoManager=e}doUpdateCursor(t){const i=this.diagram;i&&(i.currentCursor="")}doCurrentObjectChanged(t,i){}standardMouseWheel(){const t=this.diagram,i=t.lastInput;let e=i.delta;if(e===0||!t.documentBounds.isReal())return;const s=t.commandHandler,n=t.toolManager.mouseWheelBehavior;if(s!==null&&(n===2&&!i.shift||n===1&&i.control)){if(e>0?s.canIncreaseZoom():s.canDecreaseZoom()){const o=t.zoomPoint;t.zoomPoint=i.viewPoint,e>0?s.increaseZoom():s.decreaseZoom(),t.zoomPoint=o}i.bubbles=!1}else if(n===2&&i.shift||n===1&&!i.control){const o=t.position.copy(),r=i.event,l=r.deltaMode;let h=r.deltaX,a=r.deltaY,f="pixel";if((h!==0||a!==0)&&!i.shift){switch(l){case 0:f="pixel";break;case 1:f="line";break;case 2:f="page";break}if(h!==0&&t.allowHorizontalScroll){const c=t.scrollHorizontalLineChange;h=h*(c/16),t.scroll(f,h>0?"right":"left",Math.abs(h))}if(a!==0&&t.allowVerticalScroll){const c=t.scrollVerticalLineChange;a=a*(c/16),t.scroll(f,a>0?"down":"up",Math.abs(a))}}else!i.shift&&t.allowVerticalScroll?(e=e*3*t.scrollVerticalLineChange,t.scroll(f,e>0?"up":"down",Math.abs(e))):i.shift&&t.allowHorizontalScroll&&(e=e*3*t.scrollHorizontalLineChange,t.scroll(f,e>0?"left":"right",Math.abs(e)));this.doWheelChange(t,o,i)}}doWheelChange(t,i,e){(!t.position.equals(i)||e.event.wheelDeltaX!==0)&&(e.bubbles=!1)}standardWaitAfter(t,i){Debug&&Util.t(t,"number",Tool,"standardWaitAfter:delay"),i===void 0&&(i=this.diagram.lastInput),this.cancelWaitAfter();const e=this,s=i.clone(this.EC);this.Sm=Util.Bh(()=>e.doWaitAfter(s),t)}cancelWaitAfter(){this.Sm!==-1&&Util.Ug(this.Sm),this.Sm=-1}doWaitAfter(t){}findToolHandleAt(t,i){const s=this.diagram.findObjectAt(t,n=>{for(;n!==null&&!(n.panel instanceof Adornment);)n=n.panel;return n});return s===null?null:s.part.category===i?s:null}isBeyondDragSize(t,i){const e=this.diagram;t===void 0&&(t=e.firstInput.viewPoint),i===void 0&&(i=e.lastInput.viewPoint);const s=e.toolManager.dragSize;let n=s.width,o=s.height;return e.firstInput.isTouchEvent&&(n+=6,o+=6),Math.abs(i.x-t.x)>n||Math.abs(i.y-t.y)>o}get name(){return this.Tt}set name(t){Util.t(t,"string",Tool,"name"),this.Tt=t}get isEnabled(){return this.Xi}set isEnabled(t){Util.t(t,"boolean",Tool,"isEnabled"),this.Xi=t}get isActive(){return this.tS}set isActive(t){Util.t(t,"boolean",Tool,"isActive"),this.tS=t}get transactionResult(){return this.iS}set transactionResult(t){t!==null&&Util.t(t,"string",Tool,"transactionResult"),this.iS=t}}var WheelMode=(w=>(w[w.Scroll=1]="Scroll",w[w.Zoom=2]="Zoom",w[w.None=3]="None",w))(WheelMode||{}),GestureMode=(w=>(w[w.Zoom=1]="Zoom",w[w.Cancel=2]="Cancel",w[w.None=3]="None",w))(GestureMode||{});class ToolManager extends Tool{VC;BC;zC;nS;oS;rS;lS;hS;aS;fS;Pm;Kh;constructor(t){super(),this.name="ToolManager",this.VC=new List,this.BC=new List,this.zC=new List,this.nS=850,this.oS=850,this.rS=new Size(2,2).ot(),this.lS=5e3,this.hS=1,this.aS=1,this.fS=null,this.Pm=null,this.Kh=-1,t&&Object.assign(this,t)}static WheelScroll=1;static WheelZoom=2;static WheelNone=3;static GestureZoom=1;static GestureCancel=2;static GestureNone=3;get mouseWheelBehavior(){return this.hS}set mouseWheelBehavior(t){Util.tt(t,WheelMode,"WheelMode"),this.hS=t}get gestureBehavior(){return this.aS}set gestureBehavior(t){Util.tt(t,GestureMode,"GestureMode"),this.aS=t}initializeStandardTools(){}updateAdornments(t){const i=this.currentToolTip;if(i instanceof Adornment&&this.Pm===t){const e=i.adornedObject;(t!==null?e.part===t:e===null)?this.showToolTip(i,e):this.hideToolTip()}}doMouseDown(){const t=this.diagram,i=t.lastInput;if(i.isTouchEvent&&this.gestureBehavior===2&&(i.bubbles=!1),i.isMultiTouch){if(this.cancelWaitAfter(),this.gestureBehavior===3){i.bubbles=!0;return}if(this.gestureBehavior===2)return;if(t.currentTool.canStartMultiTouch()){t.currentTool.standardPinchZoomStart();return}}const e=t.undoManager;Debug&&e.ku&&e.transactionLevel!==0&&Util.at("WARNING: In ToolManager.doMouseDown: UndoManager.transactionLevel is not zero");const s=this.mouseDownTools.length;for(let n=0;n0&&s!==1/0){const n=this;this.Kh=Util.Bh(()=>n.hideToolTip(),s)}}positionToolTip(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom?n.y-=o.height+5/s.scale:n.y+=20/s.scale,n.y30&&t.jw(),t.Ww(this.draggedParts),t.Pu=!0,this.startTransaction("Drag"),this.startPoint=t.firstInput.documentPoint,t.isMouseCaptured=!0,t.allowDragOut&&this.eF()}MS(t){if(this.dragsLink){const i=this.diagram;if(!i.allowRelink)return;i.model.kf()&&t.count===1&&t.first()instanceof Link?(this.draggedLink=t.first(),this.draggedLink.canRelinkFrom()&&this.draggedLink.canRelinkTo()&&this.draggedLink.clearAdornments(),this.pn=i.toolManager.findTool("Relinking"),this.pn===null&&(this.pn=new RelinkingTool,this.pn.diagram=i),this.pn.originalLink=this.draggedLink):(this.draggedLink=null,this.pn=null)}}computeEffectiveCollection(t,i){return this.diagram.commandHandler.computeEffectiveCollection(t,i)}Ys(t){return t===void 0?new DraggingInfo(Point.Lo):this.isGridSnapEnabled?new DraggingInfo(new Point(Math.round(t.x*1e3)/1e3,Math.round(t.y*1e3)/1e3)):new DraggingInfo(t.copy())}doDeactivate(){this.isActive=!1;const t=this.diagram;this.diagram.layout.isRealtime=this.SS,t.Pu=!1,t.Pl=!0,t.cacheGroupExternalLinks(!1),t.stopAutoScroll(),this.PS(),t.Cm(this.draggedParts),this.Mu=null,this.currentPart=null,this.draggedParts=null,this.isDragOutStarted=!1,this.Su=!1,DraggingTool.sF(),this.YC(),this.xf.e(NaN,NaN),DraggingTool.Gh!==null&&(DraggingTool.Gh.currentCursor=""),DraggingTool.Gh=null,DraggingTool.St=null,this.Nl(),t.isMouseCaptured=!1,t.currentCursor="",t.bf=!1,this.stopTransaction(),t.NS(!0)}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}PS(){const t=this.diagram,i=t.skipsUndoManager;t.skipsUndoManager=!0;const e=t.lastInput;this.KC(e,null),t.skipsUndoManager=i,this.br.length=0}UC(){this.Nl(),this.CS();const t=this.diagram;this.xf.isReal()&&(t.position=this.xf),t.stopAutoScroll()}doCancel(){this.Nl(),this.CS();const t=this.diagram;this.xf.isReal()&&(t.position=this.xf),this.stopTool()}doKeyDown(){const t=this.diagram,i=t.lastInput;this.isActive&&(i.code==="Escape"?this.doCancel():i.code!==t.previousInput.code&&this.doMouseMove())}doKeyUp(){this.isActive&&this.doMouseMove()}nF(t,i){let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=t.iterator;for(;r.next();){const l=r.value;if(!l.isVisible())continue;const h=l.location,a=h.x,f=h.y;isNaN(a)||isNaN(f)||(an&&(n=a),f>o&&(o=f))}return e===1/0?i.e(0,0,0,0):i.e(e,s,n-e,o-s),i}AS(t){if(this.copiedParts!==null)return;const i=this.diagram;if(t&&(i.isReadOnly||i.isModelReadOnly)||this.draggedParts===null)return;const e=i.undoManager;e.isEnabled&&e.isInTransaction?e.currentTransaction!==null&&e.currentTransaction.changes.count>0&&(i.undoManager.rollbackTransaction(),i.startTransaction("Drag")):this.CS(),i.skipsUndoManager=!t,i.partManager.addsToTemporaryLayer=!t,this.startPoint=i.firstInput.documentPoint;const s=this.copiesEffectiveCollection?this.draggedParts.toKeySet():i.selection,n=i.copyParts(s,i,!0),o=new GMap,r=this.draggedParts.iterator;for(;r.next();){const h=r.key;if(h.Ae()&&h.canCopy()){const a=n.get(h);if(a===null)continue;a.location=h.location,a.ensureBounds(),o.set(a,this.Ys(a.location))}}const l=n.iterator;for(;l.next();){const h=l.value;h instanceof Link&&h.canCopy()&&o.set(h,this.Ys())}if(this.copiedParts=o,this.MS(o.toKeySet()),this.draggedLink!==null){const h=this.draggedLink,a=h.routeBounds;h.kr(this.startPoint.x-(a.x+a.width/2),this.startPoint.y-(a.y+a.height/2))}this.doUpdateCursor(null)}Nl(){const t=this.diagram;if(this.copiedParts!==null){if(t.removeParts(this.copiedParts.toKeySet(),!1),this.copiedParts=null,this.draggedParts!==null){const i=this.draggedParts.iterator;for(;i.next();)if(i.key instanceof Link){const s=i.value;s.point=new Point(0,0)}}this.doUpdateCursor(null)}t.skipsUndoManager=!1,t.partManager.addsToTemporaryLayer=!1,this.startPoint=t.firstInput.documentPoint}YC(){this.draggedLink!==null&&(this.dragsLink&&this.pn!==null&&(this.pn.stopDraggingMouseMove(),this.pn.originalLink=null),this.draggedLink=null,this.pn=null)}Sf(t,i){const e=this.diagram,s=this.startPoint,n=Point.a();n.c(e.lastInput.documentPoint),this.moveParts(t,n.subtract(s),i),Point.o(n),e.getRenderingHint("temporaryPixelRatio")===!0&&e.Cl===null&&e.avgSpf>30&&(e.jw(),e.Nu())}moveParts(t,i,e){e===void 0&&(e=!1);const s=this.diagram;s!==null&&s.LS(t,i,this.dragOptions,e)}CS(){if(this.draggedParts===null)return;const t=this.diagram;let i=this.draggedParts.iterator;for(;i.next();){const e=i.key;e.Ae()&&(e.location=i.value.point)}for(i=this.draggedParts.iterator;i.next();){const e=i.key;if(e instanceof Link&&e.suspendsRouting){const s=i.value.point;this.draggedParts.set(e,this.Ys()),e.kr(-s.x,-s.y)}}t.maybeUpdate()}oF(t){if(t===null)return!0;const i=t.part;return!!(i===null||i instanceof Adornment||i.layer.isTemporary||this.draggedParts&&this.draggedParts.has(i)||this.copiedParts&&this.copiedParts.has(i))}TS(t){const i=this.diagram;this.dragsLink&&(this.draggedLink!==null&&(this.draggedLink.fromNode=null,this.draggedLink.toNode=null),this.GC(!1));const e=this.findDragOverObject(t),s=i.lastInput;s.targetObject=e,this.doUpdateCursor(e);const n=i.skipsUndoManager;let o=!1;try{if(i.skipsUndoManager=!0,o=this.KC(s,e),!this.isActive&&DraggingTool.St===null)return;const r=e!==null?e.part:null;if(r===null||i.handlesDragDropForTopLevelParts&&r.isTopLevel&&!(r instanceof Group)){const l=i.mouseDragOver;l!==null&&(l(s),o=!0)}if(!this.isActive&&DraggingTool.St===null||(this.doDragOver(t,e),!this.isActive&&DraggingTool.St===null))return}finally{i.skipsUndoManager=n,o&&i.maybeUpdate()}this.Mu=e,!i.isReadOnly&&(i.allowMove||i.allowCopy)&&(i.allowHorizontalScroll||i.allowVerticalScroll)&&i.doAutoScroll(s.viewPoint)}findDragOverObject(t){return this.diagram.DS(t,null,i=>!this.oF(i))}doUpdateCursor(t){const i=this.diagram;(t===null||this.Mu!==t)&&(!this.diagram.currentTool.isActive||this.mayCopy()?i.currentCursor=this.copyCursor:this.mayMove()?i.currentCursor=this.moveCursor:this.mayDragOut()&&(i.currentCursor=this.nodropCursor))}KC(t,i){let e=!1,s=this.br.length;const n=s>0?this.br[0]:null;if(i===n)return!1;t.handled=!1;for(let r=0;rs.findValidLinkablePort(a,i)),r=Point.a();let l=1/0,h=null;for(const a=o.iterator;a.next();){const f=a.value;if(f.part===null)continue;const u=f.getDocumentPoint(Spot.Center,r),d=t.distanceSquaredPoint(u);dh.suspendsRouting=!1)}if(this.doDropOnto(t,e),!this.isActive&&DraggingTool.St===null)return;const o=Rect.a(),r=i.selection.iterator;for(;r.next();){const l=r.value;l instanceof Node&&this.lF(i,l,o)}Rect.o(o)}rF(t,i){const e=this.diagram,s=i.part;if(e.handlesDragDropForTopLevelParts&&s.isTopLevel&&!(s instanceof Group)){const n=e.mouseDrop;n!==null&&n(t)}}lF(t,i,e){if(!i.canAvoid())return;let s=!1;e=i.getAvoidableRect(e),t.viewportBounds.containsRect(e)&&(s=!0);const n=this.copiedParts||this.draggedParts,o=t.IS(e,l=>l.part,l=>l instanceof Link,!0,l=>l instanceof Link,s);if(o.count===0)return;const r=o.iterator;for(;r.next();){const l=r.value;n.has(l)&&n.has(i)||!l.isMemberOf(i)&&l.isAvoiding&&l.invalidateRoute()}}doDropOnto(t,i){}doMouseMove(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseMove(i.event,i.documentPoint,i.targetDiagram))return;this.currentPart!==null&&this.draggedParts!==null&&(this.mayCopy()?(this.AS(!1),t.Ww(this.copiedParts),this.Sf(this.copiedParts,!1),t.Cm(this.copiedParts)):this.mayMove()?(this.Nl(),this.Sf(this.draggedParts,!0)):this.mayDragOut()?(this.AS(!1),this.Sf(this.copiedParts,!1)):this.Nl(),this.TS(t.lastInput.documentPoint))}doMouseUp(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseUp(i.event,i.documentPoint,i.targetDiagram))return;let e=!1;const s=this.mayCopy();if(s&&this.copiedParts!==null?(this.Nl(),this.AS(!0),t.Ww(this.copiedParts),this.Sf(this.copiedParts,!1),t.Cm(this.copiedParts),this.copiedParts!==null&&(t.V("ChangingSelection",t.selection),t.clearSelection(!0),this.copiedParts.iteratorKeys.each(n=>{n.isSelected=!0}))):(e=!0,this.Nl(),this.mayMove()&&(this.Sf(this.draggedParts,!0),this.TS(t.lastInput.documentPoint))),this.Su=!0,this.jC(t.lastInput.documentPoint),this.isActive){const n=s?this.copiedParts.toKeySet():this.draggedParts.toKeySet();this.copiedParts=null,e&&this.hF(),t.invalidateDocumentBounds(),t.Cm(this.draggedParts),this.transactionResult=s?"Copy":"Move",t.V(s?"SelectionCopied":"SelectionMoved",n)}this.stopTool(),s&&t.V("ChangedSelection",t.selection)}simulatedMouseMove(t,i,e){if(DraggingTool.St===null)return!1;const s=DraggingTool.St.diagram;e instanceof Diagram||(e=null);const n=DraggingTool.Gh;if(e!==n){if(n!==null&&n!==s){n.stopAutoScroll(),DraggingTool.St.isDragOutStarted=!1;const r=n.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDragLeave()}if(DraggingTool.Gh=e,e!==null&&e!==s){DraggingTool.St.UC();const r=e.toolManager.findTool("Dragging");r!==null&&(r.WC(),r.doSimulatedDragEnter())}this.doUpdateCursor(null)}if(e===null||e===s||!e.allowDrop||e.isReadOnly||!e.allowInsert)return!1;const o=e.toolManager.findTool("Dragging");if(o!==null){let r=i;t!==null&&(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),r=e.getMouse(t)),e.lastInput.documentPoint=r,e.lastInput.viewPoint=e.transformDocToView(r),e.lastInput.down=!1,e.lastInput.up=!1,o.doSimulatedDragOver()}return!0}simulatedMouseUp(t,i,e){if(DraggingTool.St===null)return!1;const s=DraggingTool.Gh,n=DraggingTool.St.diagram;if(e===null)return DraggingTool.St.doCancel(),!0;if(e!==s){const o=s.toolManager.findTool("Dragging");if(s!==null&&s!==n&&o!==null)return s.stopAutoScroll(),DraggingTool.St.isDragOutStarted=!1,o.doSimulatedDragLeave(),!1;DraggingTool.Gh=e;const r=e.toolManager.findTool("Dragging");r!==null&&(DraggingTool.St.UC(),r.WC(),r.doSimulatedDragEnter())}if(e!==this.diagram){let o=i;t!==null?(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),o=e.getMouse(t)):o===null&&(o=new Point),e.lastInput.documentPoint=o,e.lastInput.viewPoint=e.transformDocToView(o),e.lastInput.down=!1,e.lastInput.up=!0;const r=e.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDrop();const l=DraggingTool.St;if(l!==null){const h=l.mayCopy();l.transactionResult=h?"Copy":"Move",l.stopTool()}return!0}return!1}hF(){if(this.draggedParts===null)return;const t=this.draggedParts.iterator;for(;t.next();){const i=t.key;if(i instanceof Node){const e=i.containingGroup;e!==null&&e.hasPlaceholder()&&!this.draggedParts.has(e)&&e.placeholder.u()}}}mayCopy(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowCopy||!(Util.cr?t.lastInput.alt:t.lastInput.control))return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayDragOut(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(!t.allowDragOut||!t.allowCopy||t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayMove(){const t=this.diagram;if(t.isReadOnly||!t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canMove())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canMove())}WC(){DraggingTool.vw.has(this)||DraggingTool.vw.add(this)}static sF(){if(DraggingTool.vw.count>0){const t=DraggingTool.vw,i=t.length;for(let e=0;e{n.isSelected=!0,s.add(n)})),this.jC(t.lastInput.documentPoint),t.invalidateDocumentBounds(),this.copiedParts!==null&&(this.transactionResult="ExternalCopy"),this.copiedParts=null,t.doFocus(),t.bf=!1,t.V("ExternalObjectsDropped",s,e),this.stopTransaction(),t.V("ChangedSelection",t.selection)}t.animationManager.Cu=!1}vC(t,i,e){if(this.copiedParts!==null)return;const s=this.diagram;if(s.isReadOnly||s.isModelReadOnly)return;s.skipsUndoManager=!i,s.partManager.addsToTemporaryLayer=!i,this.startPoint=e.documentPoint;const n=s.copyParts(t,s,!0),o=Rect.a();this.nF(t,o);const r=o.x+o.width/2,l=o.y+o.height/2;Rect.o(o);const h=this.Nm,a=new GMap,f=Point.a(),c=t.iterator;for(;c.next();){const d=c.value;if(d instanceof Link&&d.canCopy()){const m=n.get(d);if(m===null)continue;m.points=d.points,m.kr(h.x-r,h.y-l),m.suspendsRouting=!0,a.set(m,this.Ys())}}const u=t.iterator;for(;u.next();){const d=u.value;if(d.Ae()&&d.canCopy()){const m=n.get(d);if(m===null)continue;const g=d.location;f.e(h.x-(r-g.x),h.y-(l-g.y)),m.location=f,m.ensureBounds(),a.set(m,this.Ys(f))}}if(Point.o(f),this.copiedParts=a,this.MS(a.toKeySet()),this.draggedLink!==null){const d=this.draggedLink,m=d.routeBounds;d.kr(this.startPoint.x-(m.x+m.width/2),this.startPoint.y-(m.y+m.height/2))}this.doUpdateCursor(null)}eF(){this.isDragOutStarted=!0,this.Su=!1,DraggingTool.St=this,DraggingTool.Gh=this.diagram,this.doSimulatedDragOut()}doSimulatedDragOut(){const t=this.diagram;t.bf=!1,!this.mayCopy()&&!this.mayMove()?t.currentCursor=this.nodropCursor:t.currentCursor="",this.Mu=null}computeMove(t,i,e,s){const n=this.diagram;return n!==null?n.computeMove(t,i,this.dragOptions,s):new Point}static vw=new List;static St=null;static Gh=null}ToolManager.prototype.doCancel=function(){DraggingTool.St!==null&&DraggingTool.St.doCancel(),Tool.prototype.doCancel.call(this)};class LinkingBaseTool extends Tool{OS;ES;Al;VS;BS;Hh;zS;qh;XS;YS;KS;US;GS;HS;JC;qS;Ll;jS;constructor(){super(),this.OS=100,this.ES=!1,this.Al="pointer",this.VS=new Link({layerName:"Tool"}).add(new Shape({isPanelMain:!0,stroke:"blue"}).theme("stroke","tempLink"),new Shape({toArrow:"Standard",fill:"blue",stroke:"blue"}).theme("fill","tempLink").theme("stroke","tempLink")).ci(),this.Hh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.zk}).theme("stroke","tempPort"),this.BS=new Node({selectable:!1,layerName:"Tool"}).add(this.Hh).ci(),this.qh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.zk}).theme("stroke","tempPort"),this.zS=new Node({selectable:!1,layerName:"Tool"}).add(this.qh).ci(),this.XS=null,this.YS=null,this.KS=null,this.US=null,this.GS=null,this.HS=!0,this.JC=new GMap,this.qS=null,this.Ll=null,this.jS=null}doStop(){this.diagram.stopAutoScroll(),this.originalLink=null,this.originalFromNode=null,this.originalFromPort=null,this.originalToNode=null,this.originalToPort=null,this.validPortsCache.clear(),this.targetPort=null}get portGravity(){return this.OS}set portGravity(t){Util.t(t,"number",LinkingBaseTool,"portGravity"),t>=0&&(this.OS=t)}get isUnconnectedLinkValid(){return this.ES}set isUnconnectedLinkValid(t){Util.t(t,"boolean",LinkingBaseTool,"isUnconnectedLinkValid"),this.ES=t}get linkingCursor(){return this.Al}set linkingCursor(t){this.Al=t}get temporaryLink(){return this.VS}set temporaryLink(t){Util.s(t,Link,LinkingBaseTool,"temporaryLink"),t.ci(),this.VS=t}get temporaryFromNode(){return this.BS}set temporaryFromNode(t){Util.s(t,Node,LinkingBaseTool,"temporaryFromNode"),t.ci(),this.BS=t,t&&(this.Hh=t.port)}get temporaryFromPort(){return this.Hh}set temporaryFromPort(t){if(Util.s(t,GraphObject,LinkingBaseTool,"temporaryFromPort"),this.Hh!==null){const i=this.Hh.panel;if(i!==null){const e=i.D.indexOf(this.Hh);i.removeAt(e),i.insertAt(e,t)}}this.Hh=t}get temporaryToNode(){return this.zS}set temporaryToNode(t){Util.s(t,Node,LinkingBaseTool,"temporaryToNode"),t.ci(),this.zS=t,t&&(this.qh=t.port)}get temporaryToPort(){return this.qh}set temporaryToPort(t){if(Util.s(t,GraphObject,LinkingBaseTool,"temporaryToPort"),this.qh!==null){const i=this.qh.panel;if(i!==null){const e=i.D.indexOf(this.qh);i.removeAt(e),i.insertAt(e,t)}}this.qh=t}get originalLink(){return this.XS}set originalLink(t){t!==null&&Util.s(t,Link,LinkingBaseTool,"originalLink"),this.XS=t}get originalFromNode(){return this.YS}set originalFromNode(t){t!==null&&Util.s(t,Node,LinkingBaseTool,"originalFromNode"),this.YS=t}get originalFromPort(){return this.KS}set originalFromPort(t){t!==null&&Util.s(t,GraphObject,LinkingBaseTool,"originalFromPort"),this.KS=t}get originalToNode(){return this.US}set originalToNode(t){t!==null&&Util.s(t,Node,LinkingBaseTool,"originalToNode"),this.US=t}get originalToPort(){return this.GS}set originalToPort(t){t!==null&&Util.s(t,GraphObject,LinkingBaseTool,"originalToPort"),this.GS=t}get isForwards(){return this.HS}set isForwards(t){this.HS=t}get validPortsCache(){return this.JC}get targetPort(){return this.qS}set targetPort(t){t!==null&&Util.s(t,GraphObject,LinkingBaseTool,"targetPort"),this.qS=t}copyPortProperties(t,i,e,s,n){if(t===null||i===null||e===null||s===null)return;const o=i.getDocumentScale(),r=Size.a();r.width=i.naturalBounds.width*o,r.height=i.naturalBounds.height*o,s.desiredSize=r,Size.o(r),n?(s.toSpot=i.toSpot,s.toEndSegmentLength=i.toEndSegmentLength):(s.fromSpot=i.fromSpot,s.fromEndSegmentLength=i.fromEndSegmentLength),e.locationSpot=Spot.Center;const l=Point.a();e.location=i.getDocumentPoint(Spot.Center,l),Point.o(l),s.angle=i.getDocumentAngle(),this.portTargeted!==null&&this.portTargeted(t,i,e,s,n)}setNoTargetPortProperties(t,i,e){i!==null&&(i.desiredSize=Size.zk,i.fromSpot=Spot.None,i.toSpot=Spot.None),t!==null&&(t.location=this.diagram.lastInput.documentPoint),this.portTargeted!==null&&this.portTargeted(null,null,t,i,e)}doMouseDown(){this.isActive&&this.doMouseMove()}doMouseMove(){if(this.isActive){const t=this.diagram;if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null&&this.targetPort.part instanceof Node){const i=this.targetPort.part;this.isForwards?this.copyPortProperties(i,this.targetPort,this.temporaryToNode,this.temporaryToPort,!0):this.copyPortProperties(i,this.targetPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else this.isForwards?this.setNoTargetPortProperties(this.temporaryToNode,this.temporaryToPort,!0):this.setNoTargetPortProperties(this.temporaryFromNode,this.temporaryFromPort,!1);(t.allowHorizontalScroll||t.allowVerticalScroll)&&t.doAutoScroll(t.lastInput.viewPoint)}}findValidLinkablePort(t,i){if(t===null)return null;const e=t.part;if(!(e instanceof Node))return null;for(;t!==null;){const s=i?t.toLinkable:t.fromLinkable;if(s===!0&&(t.portId!==null||t instanceof Node)&&(i?this.isValidTo(e,t):this.isValidFrom(e,t)))return t;if(s===!1)return null;t=t.panel}return null}findTargetPort(t){const i=this.diagram,e=i.lastInput.documentPoint;let s=this.portGravity;s<=0&&(s=.1);const n=this,o=i.findObjectsNear(e,s,a=>n.findValidLinkablePort(a,t),null,!0);let r=1/0,l=null;const h=o.iterator;for(;h.next();){const a=h.value,f=a.part;if(!(f instanceof Node))continue;const c=a.getDocumentPoint(Spot.Center,Point.a()),u=e.x-c.x,d=e.y-c.y;Point.o(c);const m=u*u+d*d;if(m=e)return!1}return!0}isValidTo(t,i){if(t===null||i===null)return this.isUnconnectedLinkValid;if(this.diagram.currentTool===this&&(t.layer!==null&&!t.layer.allowLink||i.toLinkable!==!0))return!1;const e=i.toMaxLinks;if(e<1/0){if(this.originalLink!==null&&t===this.originalToNode&&i===this.originalToPort)return!0;let s=i.portId;if(s===null&&(s=""),t.findLinksInto(s).count>=e)return!1}return!0}isInSameNode(t,i){if(t===null||i===null)return!1;if(t===i)return!0;const e=t.part,s=i.part;return e!==null&&e===s}isLinked(t,i){if(t===null||i===null)return!1;const e=t.part;if(!(e instanceof Node))return!1;let s=t.portId;s===null&&(s="");const n=i.part;if(!(n instanceof Node))return!1;let o=i.portId;o===null&&(o="");const r=n.findLinksInto(o);for(;r.next();){const l=r.value;if(l.fromNode===e&&l.fromPortId===s)return!0}return!1}isValidLink(t,i,e,s){if(!this.isValidFrom(t,i)||!this.isValidTo(e,s)||i!==null&&s!==null&&(!(i.fromLinkableSelfNode&&s.toLinkableSelfNode)&&this.isInSameNode(i,s)||!(i.fromLinkableDuplicates&&s.toLinkableDuplicates)&&this.isLinked(i,s))||this.originalLink!==null&&(t!==null&&this.isLabelDependentOnLink(t,this.originalLink)||e!==null&&this.isLabelDependentOnLink(e,this.originalLink))||t!==null&&e!==null&&(t.data===null&&e.data!==null||t.data!==null&&e.data===null)||!this.isValidCycle(t,e,this.originalLink))return!1;let n;return t!==null&&(n=t.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))||e!==null&&(n=e.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))?!1:(n=this.linkValidation,n!==null?n(t,i,e,s,this.originalLink):!0)}isLabelDependentOnLink(t,i){if(t===null)return!1;const e=t.labeledLink;if(e===null)return!1;if(e===i)return!0;const s=new GSet;return s.add(t),this.WS(e,i,s)}WS(t,i,e){if(t===i)return!0;const s=t.fromNode;if(s!==null&&s.isLinkLabel&&(e.add(s),this.WS(s.labeledLink,i,e)))return!0;const n=t.toNode;return!!(n!==null&&n.isLinkLabel&&(e.add(n),this.WS(n.labeledLink,i,e)))}isValidCycle(t,i,e){if(e===void 0&&(e=null),t===null||i===null)return this.isUnconnectedLinkValid;const s=this.diagram;let n=1;if(s&&(s.model.Mf()?n=s.isTreePathToChildren?5:6:n=s.validCycle),n===1)return!0;if(n===5){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=i.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.toNode===i)return!1}return!this.Au(t,i,e,!0)}else if(n===6){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=t.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.fromNode===t)return!1}return!this.Au(t,i,e,!0)}else{if(n===2)return!this.aF(t,i,e);if(n===3)return!this.Au(t,i,e,!1);if(n===4)return!this.fF(t,i,e)}return!0}Au(t,i,e,s){if(t===i)return!0;if(t===null||i===null)return!1;const n=t.linksConnected;for(;n.next();){const o=n.value;if(o===e||s&&!o.isTreeLink||o.toNode!==t)continue;const r=o.fromNode;if(r!==t&&this.Au(r,i,e,s))return!0}return!1}aF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.ZC(s,t,i,e)}ZC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s||o.toNode!==i)continue;const r=o.fromNode;if(r!==i&&this.ZC(t,r,e,s))return!0}return!1}fF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.$C(s,t,i,e)}$C(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s)continue;const r=o.fromNode,l=o.toNode,h=r===i?l:r;if(h!==i&&this.$C(t,h,e,s))return!0}return!1}get linkValidation(){return this.Ll}set linkValidation(t){t!==null&&Util.t(t,"function",LinkingBaseTool,"linkValidation"),this.Ll=t}get portTargeted(){return this.jS}set portTargeted(t){t!==null&&Util.t(t,"function",LinkingBaseTool,"portTargeted"),this.jS=t}}var LinkingDirection=(w=>(w[w.Either=1]="Either",w[w.ForwardsOnly=2]="ForwardsOnly",w[w.BackwardsOnly=3]="BackwardsOnly",w))(LinkingDirection||{});class LinkingTool extends LinkingBaseTool{vS;JS;C;ZS;constructor(t){super(),this.name="Linking",this.vS={},this.JS=null,this.C=1,this.ZS=null,t&&Object.assign(this,t)}static Either=1;static ForwardsOnly=2;static BackwardsOnly=3;get archetypeLinkData(){return this.vS}set archetypeLinkData(t){t!==null&&Util.t(t,"object",LinkingTool,"archetypeLinkData"),t instanceof GraphObject&&Util.s(t,Link,LinkingTool,"archetypeLinkData"),this.vS=t}get archetypeLabelNodeData(){return this.JS}set archetypeLabelNodeData(t){t!==null&&Util.t(t,"object",LinkingTool,"archetypeLabelNodeData"),t instanceof GraphObject&&Util.s(t,Node,LinkingTool,"archetypeLabelNodeData"),this.JS=t}get direction(){return this.C}set direction(t){Util.tt(t,LinkingDirection,"LinkingDirection"),this.C=t}get startObject(){return this.ZS}set startObject(t){t!==null&&Util.s(t,GraphObject,LinkingTool,"startObject"),this.ZS=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||t.isModelReadOnly||!t.allowLink||!t.model.Jw()||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize()?!1:this.findLinkablePort()!==null}findLinkablePort(){const t=this.diagram;let i=this.startObject;if(i===null&&(i=t.findObjectAt(t.firstInput.documentPoint,null,null)),i===null)return null;const e=i.part;if(!(e instanceof Node))return null;const s=this.direction;if(s===1||s===2){const n=this.findValidLinkablePort(i,!1);if(n!==null)return this.isForwards=!0,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!1))return this.isForwards=!0,o}}if(s===1||s===3){const n=this.findValidLinkablePort(i,!0);if(n!==null)return this.isForwards=!1,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!0))return this.isForwards=!1,o}}return null}doActivate(){const t=this.diagram,i=this.findLinkablePort();if(i===null){this.stopTool();return}if(this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.isForwards){this.temporaryToNode!==null&&(this.temporaryToNode.location=t.lastInput.documentPoint),this.originalFromPort=i;const e=this.originalFromPort.part;e instanceof Node&&(this.originalFromNode=e),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else{this.temporaryFromNode!==null&&(this.temporaryFromNode.location=t.lastInput.documentPoint),this.originalToPort=i;const e=this.originalToPort.part;e instanceof Node&&(this.originalToNode=e),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0)}t.add(this.temporaryFromNode),this.temporaryFromNode&&this.temporaryFromNode.ensureBounds(),t.add(this.temporaryToNode),this.temporaryToNode&&this.temporaryToNode.ensureBounds(),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.temporaryLink.isTreeLink=this.isNewTreeLink(),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.startObject=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=null,e=null,s=null,n=null,o=null;try{this.targetPort=this.findTargetPort(this.isForwards);const r=this.targetPort;if(r!==null){const l=r.part;l instanceof Node&&(this.isForwards?(this.originalFromNode!==null&&(i=this.originalFromNode,e=this.originalFromPort),s=l,n=r):(i=l,e=r,this.originalToNode!==null&&(s=this.originalToNode,n=this.originalToPort)))}else this.isForwards?this.originalFromNode!==null&&this.isUnconnectedLinkValid&&(i=this.originalFromNode,e=this.originalFromPort):this.originalToNode!==null&&this.isUnconnectedLinkValid&&(s=this.originalToNode,n=this.originalToPort);i!==null||s!==null?(o=this.insertLink(i,e,s,n),o!==null?(r===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint),t.allowSelect&&(t.V("ChangingSelection",t.selection),t.clearSelection(!0),o.isSelected=!0),this.transactionResult=this.name,t.V("LinkDrawn",o)):this.doNoLink(i,e,s,n)):this.isForwards?this.doNoLink(this.originalFromNode,this.originalFromPort,null,null):this.doNoLink(null,null,this.originalToNode,this.originalToPort)}finally{this.stopTool(),o&&t.allowSelect&&t.V("ChangedSelection",t.selection)}}}isNewTreeLink(){const t=this.archetypeLinkData;if(t===null)return!0;if(t instanceof Link)return t.isTreeLink;const i=this.diagram;if(i===null)return!0;const e=i.partManager.getLinkCategoryForData(t),s=i.partManager.findLinkTemplateForCategory(e);return s!==null?s.isTreeLink:!0}insertLink(t,i,e,s){return this.diagram.partManager.insertLink(t,i,e,s)}doNoLink(t,i,e,s){}}class RelinkingTool extends LinkingBaseTool{$S;QS;ps;_S;constructor(t){super(),this.name="Relinking",this.$S=new Shape("Diamond",{desiredSize:Size.gu,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:0}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.QS=new Shape("Diamond",{desiredSize:Size.gu,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:-1}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.ps=null,this._S=new Rect,t&&Object.assign(this,t)}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i="RelinkFrom",e=null;if(t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkFrom()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null&&(e=this.makeAdornment(s,!1),t.addAdornment(i,e)))}if(e===null&&t.removeAdornment(i),i="RelinkTo",e=null,t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkTo()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null?(e=this.makeAdornment(s,!0),t.addAdornment(i,e)):e.u())}e===null&&t.removeAdornment(i)}makeAdornment(t,i){const e=new Adornment;e.type=Panel.Link;const s=i?this.toHandleArchetype:this.fromHandleArchetype;return s!==null&&e.add(s.copy().Am()),e.adornedObject=t,e}get fromHandleArchetype(){return this.$S}set fromHandleArchetype(t){t!==null&&Util.s(t,GraphObject,RelinkingTool,"fromHandleArchetype"),this.$S=t}get toHandleArchetype(){return this.QS}set toHandleArchetype(t){t!==null&&Util.s(t,GraphObject,RelinkingTool,"toHandleArchetype"),this.QS=t}get handle(){return this.ps}set handle(t){if(t!==null&&(Util.s(t,GraphObject,RelinkingTool,"handle"),!(t.part instanceof Adornment)))throw new Error("new handle is not in an Adornment: "+t);this.ps=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowRelink||!t.model.Jw()||!t.lastInput.left)return!1;let e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom");return e===null&&(e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo")),e!==null}doActivate(){const t=this.diagram;if(this.originalLink===null){let i=this.handle;if(i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom"),i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo"))),i===null)return;const e=i.part;if(!(e instanceof Adornment)||!(e.adornedPart instanceof Link))return;this.handle=i,this.isForwards=e===null||e.category==="RelinkTo",this.originalLink=e.adornedPart}this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.originalFromPort=this.originalLink.fromPort,this.originalFromNode=this.originalLink.fromNode,this.originalToPort=this.originalLink.toPort,this.originalToNode=this.originalLink.toNode,this._S.set(this.originalLink.actualBounds),this.originalLink!==null&&this.originalLink.pointsCount>0&&(this.originalLink.fromNode===null&&(this.temporaryFromPort!==null&&(this.temporaryFromPort.desiredSize=Size.lf),this.temporaryFromNode!==null&&(this.temporaryFromNode.location=this.originalLink.getPoint(0))),this.originalLink.toNode===null&&(this.temporaryToPort!==null&&(this.temporaryToPort.desiredSize=Size.lf),this.temporaryToNode!==null&&(this.temporaryToNode.location=this.originalLink.getPoint(this.originalLink.pointsCount-1)))),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0),t.add(this.temporaryFromNode),t.add(this.temporaryToNode),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.copyLinkProperties(this.originalLink,this.temporaryLink),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}copyLinkProperties(t,i){if(t===null||i===null)return;i.adjusting=t.adjusting,i.corner=t.corner;let e=t.curve;(e===11||e===10)&&(e=0),i.curve=e,i.curviness=t.curviness,i.isTreeLink=t.isTreeLink,i.points=t.points,i.routing=t.routing,i.smoothness=t.smoothness,i.fromSpot=t.fromSpot,i.fromEndSegmentLength=t.fromEndSegmentLength,i.fromShortLength=t.fromShortLength,i.toSpot=t.toSpot,i.toEndSegmentLength=t.toEndSegmentLength,i.toShortLength=t.toShortLength}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.handle=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=this.originalFromNode,e=this.originalFromPort,s=this.originalToNode,n=this.originalToPort,o=this.originalLink;try{if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null){const r=this.targetPort.part;r instanceof Node&&(this.isForwards?(s=r,n=this.targetPort):(i=r,e=this.targetPort))}else this.isUnconnectedLinkValid?this.isForwards?(s=null,n=null):(i=null,e=null):o=null;o!==null?(this.reconnectLink(o,this.isForwards?s:i,this.isForwards?n:e,this.isForwards),this.targetPort===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint,o.invalidateRoute()),this.transactionResult=this.name,t.V("LinkRelinked",o,this.isForwards?this.originalToPort:this.originalFromPort)):this.doNoRelink(this.originalLink,this.isForwards),this.originalLink.invalidateOtherJumpOvers(this._S)}finally{this.stopTool()}}}reconnectLink(t,i,e,s){const n=e!==null&&e.portId!==null?e.portId:"";return s?(t.toNode=i,t.toPortId=n):(t.fromNode=i,t.fromPortId=n),!0}doNoRelink(t,i){}doDraggingMouseMove(t,i,e,s){t!==null?(this.copyPortProperties(t,i,this.temporaryFromNode,this.temporaryFromPort,!1),this.diagram.add(this.temporaryFromNode)):this.diagram.remove(this.temporaryFromNode),e!==null?(this.copyPortProperties(e,s,this.temporaryToNode,this.temporaryToPort,!0),this.diagram.add(this.temporaryToNode)):this.diagram.remove(this.temporaryToNode)}stopDraggingMouseMove(){this.diagram.remove(this.temporaryFromNode),this.diagram.remove(this.temporaryToNode)}}var ReshapingBehavior=(w=>(w[w.None=0]="None",w[w.Horizontal=1]="Horizontal",w[w.Vertical=2]="Vertical",w[w.All=3]="All",w))(ReshapingBehavior||{});class LinkReshapingTool extends Tool{Fo;tM;iM;ps;Zw;eM;Lm;constructor(t){super(),this.name="LinkReshaping",this.Fo=new Shape("Rectangle",{desiredSize:Size.aC,fill:"lightblue",stroke:"dodgerblue"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.tM=new Shape("Diamond",{desiredSize:Size.gu,fill:"lightblue",stroke:"dodgerblue",cursor:"move"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.iM=3,this.ps=null,this.Zw=null,this.eM=new Point,this.Lm=new List,t&&Object.assign(this,t)}static None=0;static Horizontal=1;static Vertical=2;static All=3;getReshapingBehavior(t){return t?t.Mr:0}setReshapingBehavior(t,i){t.Mr=i}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i=null;if(t.isSelected&&!this.diagram.isReadOnly){const e=t.path;e!==null&&t.canReshape()&&t.actualBounds.isReal()&&t.isVisible()&&e.actualBounds.isReal()&&e.isVisibleObject()&&(i=t.findAdornment(this.name),(i===null||i.sM!==t.pointsCount||i.nM!==t.resegmentable)&&(i=this.makeAdornment(e),i!==null&&(i.sM=t.pointsCount,i.nM=t.resegmentable,t.addAdornment(this.name,i))))}i===null&&t.removeAdornment(this.name)}makeAdornment(t){const i=t.part,e=i.points,s=i.pointsCount,n=i.isOrthogonal;let o=null;if(e!==null&&s>1){o=new Adornment,o.type=Panel.Link;const r=i.firstPickIndex,l=i.lastPickIndex,h=n?1:0;if(i.resegmentable&&i.computeCurve()!==9)for(let a=r+h;ae.firstPickIndex+1&&s0))this.cF(t,i);else if(t instanceof Panel){const e=t.elements;for(;e.next();){const s=e.value;this.updateResizeHandles(s,i)}}}}cF(t,i){let e=t.alignment;e.isNoSpot()&&(e=Spot.Center);let s=i;if(e.x<=0)e.y<=0?s+=225:e.y>=1?s+=135:s+=180;else if(e.x>=1)e.y<=0?s+=315:e.y>=1&&(s+=45);else if(e.y<=0)s+=270;else if(e.y>=1)s+=90;else return;s<0?s+=360:s>=360&&(s-=360),s<22.5?t.cursor="e-resize":s<67.5?t.cursor="se-resize":s<112.5?t.cursor="s-resize":s<157.5?t.cursor="sw-resize":s<202.5?t.cursor="w-resize":s<247.5?t.cursor="nw-resize":s<292.5?t.cursor="n-resize":s<337.5?t.cursor="ne-resize":t.cursor="e-resize"}get handleArchetype(){return this.Fo}set handleArchetype(t){t!==null&&Util.s(t,GraphObject,ResizingTool,"handleArchetype"),this.Fo=t}get handle(){return this.ps}set handle(t){if(t!==null&&(Util.s(t,GraphObject,ResizingTool,"handle"),!(t.part instanceof Adornment)))throw new Error("new handle is not in an Adornment: "+t);this.ps=t}get adornedObject(){return this.ys}set adornedObject(t){if(t!==null&&(Util.s(t,GraphObject,ResizingTool,"handle"),t.part instanceof Adornment))throw new Error("new handle must not be in an Adornment: "+t);this.ys=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowResize||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle!==null&&(this.adornedObject=this.handle.part.adornedObject,this.adornedObject!==null&&(t.isMouseCaptured=!0,t.animationManager.stopAnimation(),t.Pu=!0,this.startTransaction(this.name),this.Tm.set(this.adornedObject.getDocumentPoint(this.handle.alignment.opposite())),this.Nf.set(this.adornedObject.part.location),this.rM.set(this.adornedObject.desiredSize),this._w=this.computeCellSize(),this.$w=this.computeMinSize(),this.Qw=this.computeMaxSize(),this.isActive=!0))}doDeactivate(){const t=this.diagram;t.Pu=!1,t.Pl=!0,this.stopTransaction(),this.handle=null,this.ys=null,t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){this.adornedObject!==null&&(this.adornedObject.desiredSize=this.originalDesiredSize,this.adornedObject.part.location=this.originalLocation),this.stopTool()}doMouseMove(){const t=this.diagram;if(!this.isActive)return;const i=this.$w,e=this.Qw,s=this._w,n=t.lastInput.documentPoint,o=this.adornedObject.getLocalPoint(n,Point.a()),r=this.computeReshape(),l=this.computeResize(o,this.handle.alignment,i,e,s,r);this.resize(l),t.maybeUpdate(),Point.o(o)}doMouseUp(){const t=this.diagram;if(this.isActive){const i=this.$w,e=this.Qw,s=this._w,n=this.adornedObject.getLocalPoint(t.lastInput.documentPoint,Point.a()),o=this.computeReshape(),r=this.computeResize(n,this.handle.alignment,i,e,s,o);this.resize(r),Point.o(n),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.V("PartResized",this.adornedObject,this.originalDesiredSize)}this.stopTool()}resize(t){const i=this.diagram,e=this.adornedObject;if(e===null)return;e.desiredSize=t.size;const s=e.part;s.ensureBounds();const n=e.getDocumentPoint(this.handle.alignment.opposite());if(s instanceof Group){const o=new List;o.add(s);let r;!this.dragsMembers&&!s.hasPlaceholder()&&(r=new DraggingOptions,r.dragsMembers=!1),i.moveParts(o,this.oppositePoint.copy().subtract(n),!0,r)}else s.location=s.location.copy().subtract(n).add(this.oppositePoint);i.maybeUpdate()}computeResize(t,i,e,s,n,o){i.isNoSpot()&&(i=Spot.Center);const r=this.adornedObject.naturalBounds,l=r.x,h=r.y,a=r.x+r.width,f=r.y+r.height;let c=1;if(!o){let m=r.width,g=r.height;m<=0&&(m=1),g<=0&&(g=1),c=g/m}const u=Point.a();Geo.Hg(t.x,t.y,l,h,n.width,n.height,u);const d=r.copy();return i.x<=0?i.y<=0?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.y=Math.max(u.y,f-s.height),d.y=Math.min(d.y,f-e.height),d.height=Math.max(f-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width),d.x=a-d.width,d.y=f-d.height)):i.y>=1?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width),d.x=a-d.width)):(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=a-d.x,o||(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c,d.y=h+.5*(f-h-d.height))):i.x>=1?i.y<=0?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.y=Math.max(u.y,f-s.height),d.y=Math.min(d.y,f-e.height),d.height=Math.max(f-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width),d.y=f-d.height)):i.y>=1?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width))):(d.width=Math.max(Math.min(u.x-l,s.width),e.width),o||(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c,d.y=h+.5*(f-h-d.height))):i.y<=0?(d.y=Math.max(u.y,f-s.height),d.y=Math.min(d.y,f-e.height),d.height=f-d.y,o||(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width,d.x=l+.5*(a-l-d.width))):i.y>=1&&(d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width,d.x=l+.5*(a-l-d.width))),Point.o(u),d}computeReshape(){let t=0;return this.adornedObject instanceof Shape&&(t=this.adornedObject.lM()),!(t===6||this.diagram.lastInput.shift)}computeMinSize(){const t=this.adornedObject.minSize.copy(),i=this.minSize;return!isNaN(i.width)&&i.width>t.width&&(t.width=i.width),!isNaN(i.height)&&i.height>t.height&&(t.height=i.height),t}computeMaxSize(){const t=this.adornedObject.maxSize.copy(),i=this.maxSize;return!isNaN(i.width)&&i.width0&&(t.width=n.width),!isNaN(n.height)&&n.height>0&&(t.height=n.height)}let e=this.cellSize;isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height);const s=this.diagram;if((isNaN(t.width)||isNaN(t.height))&&s){const n=s.grid;n!==null&&n.visible&&this.isGridSnapEnabled&&(e=n.gridCellSize,isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height))}return(isNaN(t.width)||t.width===0||t.width===1/0)&&(t.width=1),(isNaN(t.height)||t.height===0||t.height===1/0)&&(t.height=1),t}get minSize(){return this.Pr}set minSize(t){if(Util.s(t,Size,ResizingTool,"minSize"),!this.Pr.equals(t)){let e=t.width;isNaN(e)&&(e=0);let s=t.height;isNaN(s)&&(s=0),this.Pr.e(e,s)}}get maxSize(){return this.Nr}set maxSize(t){if(Util.s(t,Size,ResizingTool,"maxSize"),!this.Nr.equals(t)){let e=t.width;isNaN(e)&&(e=1/0);let s=t.height;isNaN(s)&&(s=1/0),this.Nr.e(e,s)}}get cellSize(){return this.Ro}set cellSize(t){Util.s(t,Size,ResizingTool,"cellSize"),this.Ro.equals(t)||this.Ro.c(t)}get isGridSnapEnabled(){return this.Pf}set isGridSnapEnabled(t){Util.t(t,"boolean",ResizingTool,"isGridSnapEnabled"),this.Pf=t}get dragsMembers(){return this.oM}set dragsMembers(t){Util.t(t,"boolean",ResizingTool,"dragsMembers"),this.oM=t}get oppositePoint(){return this.Tm}set oppositePoint(t){Util.s(t,Point,ResizingTool,"oppositePoint"),this.Tm.equals(t)||this.Tm.c(t)}get originalDesiredSize(){return this.rM}get originalLocation(){return this.Nf}}class RotatingTool extends Tool{hM;aM;ys;Fo;ps;fM;Dm;Nf;cM;uM;constructor(t){super(),this.name="Rotating",this.hM=45,this.aM=2,this.Nf=new Point,this.ys=null,this.Fo=new Shape("Ellipse",{desiredSize:Size.gu,fill:"lightblue",stroke:"dodgerblue",strokeWidth:1,cursor:"pointer"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.ps=null,this.fM=0,this.Dm=new Point(NaN,NaN),this.cM=0,this.uM=50,t&&Object.assign(this,t)}updateAdornments(t){if(t!==null){if(t.Dl()){const i=t.rotateObject;if(i===t||i===t.path||i.isPanelMain)return}if(t.isSelected&&!this.diagram.isReadOnly){const i=t.rotateObject;if(i!==null&&t.canRotate()&&t.actualBounds.isReal()&&t.isVisible()&&i.actualBounds.isReal()&&i.isVisibleObject()){let e=t.findAdornment(this.name);if((e===null||e.adornedObject!==i)&&(e=this.makeAdornment(i)),e!==null){e.angle=i.getDocumentAngle(),e.hasPlaceholder()||(e.location=this.computeAdornmentLocation(i)),t.addAdornment(this.name,e);return}}}t.removeAdornment(this.name)}}makeAdornment(t){let i=null;const e=t.part.rotateAdornmentTemplate;if(e===null){i=new Adornment,i.type=Panel.Position,i.locationSpot=Spot.Center;const s=this.handleArchetype;s!==null&&i.add(s.copy().Am())}else if(e.ci(),i=e.copy(),i===null)return null;return i.adornedObject=t,i}get handleArchetype(){return this.Fo}set handleArchetype(t){t!==null&&Util.s(t,GraphObject,RotatingTool,"handleArchetype"),this.Fo=t}get handle(){return this.ps}set handle(t){if(t!==null&&(Util.s(t,GraphObject,RotatingTool,"handle"),!(t.part instanceof Adornment)))throw new Error("new handle is not in an Adornment: "+t);this.ps=t}get adornedObject(){return this.ys}set adornedObject(t){if(t!==null&&(Util.s(t,GraphObject,RotatingTool,"handle"),t.part instanceof Adornment))throw new Error("new handle must not be in an Adornment: "+t);this.ys=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowRotate||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;if(this.adornedObject===null){if(this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle===null)return;this.adornedObject=this.handle.part.adornedObject}this.adornedObject!==null&&(t.isMouseCaptured=!0,t.delaysLayout=!0,this.startTransaction(this.name),this.fM=this.adornedObject.angle,this.Dm=this.computeRotationPoint(this.adornedObject),this.Nf=this.adornedObject.part.location.copy(),this.isActive=!0)}computeRotationPoint(t){const i=t.part,e=i.locationObject;return i.rotationSpot.isSpot()?t.getDocumentPoint(i.rotationSpot):t===i||t===e?e.getDocumentPoint(i.locationSpot):t.getDocumentPoint(Spot.Center)}computeAdornmentLocation(t){let i=this.rotationPoint;i.isReal()||(i=this.computeRotationPoint(t));const e=t.getLocalPoint(i);let s=this.handleAngle;s<0?s+=360:s>=360&&(s-=360),s=Math.round(Math.round(s/45)*45);const n=this.handleDistance;return s===0?e.x=t.naturalBounds.width+n:s===45?(e.x=t.naturalBounds.width+n,e.y=t.naturalBounds.height+n):s===90?e.y=t.naturalBounds.height+n:s===135?(e.x=-n,e.y=t.naturalBounds.height+n):s===180?e.x=-n:s===225?(e.x=-n,e.y=-n):s===270?e.y=-n:s===315&&(e.x=t.naturalBounds.width+n,e.y=-n),t.getDocumentPoint(e)}doDeactivate(){const t=this.diagram;this.stopTransaction(),this.handle=null,this.ys=null,this.Dm=new Point(NaN,NaN),t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){const t=this.diagram;t.delaysLayout=!1,this.rotate(this.originalAngle),this.stopTool()}doMouseMove(){const t=this.diagram;if(this.isActive){const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i)}}doMouseUp(){const t=this.diagram;if(this.isActive){t.delaysLayout=!1;const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.V("PartRotated",this.adornedObject,this.originalAngle)}this.stopTool()}rotate(t){Debug&&Util.r(t,RotatingTool,"rotate:newangle");const i=this.adornedObject;if(i===null)return;i.angle=t;const e=i.part;e.ensureBounds();const s=e.locationObject,n=e.rotateObject;if(s===n||s.isContainedBy(n)){const o=this.Nf.copy();e.location=o.subtract(this.rotationPoint).rotate(t-this.originalAngle).add(this.rotationPoint)}this.diagram.maybeUpdate()}computeRotate(t){let i=this.rotationPoint.directionPoint(t)-this.handleAngle;const e=this.adornedObject.panel;e!==null&&(i-=e.getDocumentAngle()),i>=360?i-=360:i<0&&(i+=360);const s=Math.min(Math.abs(this.snapAngleMultiple),180),n=Math.min(Math.abs(this.snapAngleEpsilon),s/2);return!this.diagram.lastInput.shift&&s>0&&n>0&&(i%ss-n&&(i=(Math.floor(i/s)+1)*s)),i>=360?i-=360:i<0&&(i+=360),i}get snapAngleMultiple(){return this.hM}set snapAngleMultiple(t){Util.t(t,"number",RotatingTool,"snapAngleMultiple"),this.hM=t}get snapAngleEpsilon(){return this.aM}set snapAngleEpsilon(t){Util.t(t,"number",RotatingTool,"snapAngleEpsilon"),this.aM=t}get originalAngle(){return this.fM}get rotationPoint(){return this.Dm}set rotationPoint(t){this.Dm=t.copy()}get handleAngle(){return this.cM}set handleAngle(t){Util.t(t,"number",RotatingTool,"handleAngle"),this.cM=t}get handleDistance(){return this.uM}set handleDistance(t){Util.t(t,"number",RotatingTool,"handleDistance"),this.uM=t}}class ClickSelectingTool extends Tool{constructor(t){super(),this.name="ClickSelecting",t&&Object.assign(this,t)}canStart(){return!(!this.isEnabled||this.isBeyondDragSize())}doMouseUp(){this.isActive&&(this.standardMouseSelect(),this.standardMouseClick()||this.diagram.lastInput.isTouchEvent&&this.diagram.toolManager.doToolTip()),this.stopTool()}}class ActionTool extends Tool{Cf;constructor(t){super(),this.name="Action",this.Cf=null,t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram,i=t.lastInput,e=t.findObjectAt(i.documentPoint,s=>{for(;s.panel!==null;){if(s.isActionable)return s;s=s.panel}return s});return e!==null&&e.isActionable?(this.Cf=e,t.wf=t.findObjectAt(i.documentPoint,null,null),!0):!1}doMouseDown(){if(!this.isActive)this.canStart()&&this.doActivate();else{const i=this.diagram.lastInput,e=this.Cf;if(e===null)return;i.targetObject=e,e.actionDown!==null&&e.actionDown(i,e)}}doMouseMove(){if(this.isActive){const i=this.diagram.lastInput,e=this.Cf;if(e===null)return;i.targetObject=e,e.actionMove!==null&&e.actionMove(i,e)}}doMouseUp(){if(this.isActive){const i=this.diagram.lastInput,e=this.Cf;if(e===null)return;i.targetObject=e,e.actionUp!==null&&e.actionUp(i,e),this.standardMouseClick(s=>{for(;s.panel!==null;){if(s.isActionable&&s===e)return s;s=s.panel}return s},s=>s===e)}this.stopTool()}doCancel(){const i=this.diagram.lastInput,e=this.Cf;e!==null&&(i.targetObject=e,e.actionCancel!==null&&e.actionCancel(i,e),this.stopTool())}doStop(){this.Cf=null}}class ClickCreatingTool extends Tool{Fl;dM;Pf;gM;constructor(t){super(),this.name="ClickCreating",this.Fl=null,this.dM=!0,this.Pf=!1,this.gM=new Point(0,0),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled||this.archetypeNodeData===null)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.lastInput.left||this.isBeyondDragSize())return!1;if(this.isDoubleClick){if(t.lastInput.clickCount===1&&(this.gM=t.lastInput.viewPoint.copy()),t.lastInput.clickCount!==2||this.isBeyondDragSize(this.gM))return!1}else if(t.lastInput.clickCount!==1)return!1;return!(t.currentTool!==this&&t.findPartAt(t.lastInput.documentPoint,!0)!==null)}doMouseUp(){const t=this.diagram;this.isActive&&this.insertPart(t.lastInput.documentPoint),this.stopTool()}insertPart(t){const i=this.diagram,e=this.archetypeNodeData;if(e===null)return null;let s=null;try{if(i.V("ChangingSelection",i.selection),this.startTransaction(this.name),e instanceof Part)e.Ae()&&(e.ci(),s=e.copy(),s!==null&&i.add(s));else if(e!==null){const n=i.model.copyNodeData(e);Util.Mt(n)&&(i.model.addNodeData(n),s=i.findPartForData(n))}if(s!==null){const n=Point.H(t.x,t.y);this.isGridSnapEnabled&&this.diagram.mM(s,t,n),s.location=n,i.allowSelect&&(i.clearSelection(!0),s.isSelected=!0),Point.o(n)}i.invalidateDocumentBounds(),this.transactionResult=this.name,i.V("PartCreated",s)}finally{this.stopTransaction(),i.V("ChangedSelection",i.selection)}return s}get archetypeNodeData(){return this.Fl}set archetypeNodeData(t){t!==null&&Util.t(t,"object",ClickCreatingTool,"archetypeNodeData"),this.Fl=t}get isDoubleClick(){return this.dM}set isDoubleClick(t){Util.t(t,"boolean",ClickCreatingTool,"isDoubleClick"),this.dM=t}get isGridSnapEnabled(){return this.Pf}set isGridSnapEnabled(t){Util.t(t,"boolean",ClickCreatingTool,"isGridSnapEnabled"),this.Pf=t}}class DragSelectingTool extends Tool{Uh;pM;Rl;constructor(t){super(),this.name="DragSelecting",this.Uh=175,this.pM=!1,this.Rl=new Part({layerName:"Tool",selectable:!1}).add(new Shape("Rectangle",{name:"SHAPE",fill:null,stroke:"magenta"}).theme("stroke","dragSelect")).ci(),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(!t.allowSelect)return!1;const i=t.lastInput;return!(!i.left||t.currentTool!==this&&(!this.isBeyondDragSize()||i.timestamp-t.firstInput.timestamp{const e=i.diagram;e!==null&&e.Li(root.document,"scroll",i.yM,!1),i.stopTool()},t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return!(!t.allowHorizontalScroll&&!t.allowVerticalScroll||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize())}doActivate(){const t=this.diagram;this.Do?(t.lastInput.bubbles=!0,t.Ht(root.document,"scroll",this.yM,!1)):(t.currentCursor="move",t.isMouseCaptured=!0,this.tx.c(t.position)),this.isActive=!0}doDeactivate(){const t=this.diagram;t.currentCursor="",t.isMouseCaptured=!1,this.isActive=!1}doCancel(){const t=this.diagram;t.position=this.tx,t.isMouseCaptured=!1,this.stopTool()}doMouseMove(){this._C()}doMouseUp(){this._C(),this.stopTool()}_C(){const t=this.diagram;if(this.isActive&&t){if(this.Do){t.lastInput.bubbles=!0;return}const i=t.position,e=t.firstInput.documentPoint,s=t.lastInput.documentPoint;let n=i.x+e.x-s.x,o=i.y+e.y-s.y;t.allowHorizontalScroll||(n=i.x),t.allowVerticalScroll||(o=i.y),t.position=this.QC.e(n,o)}}get bubbles(){return this.Do}set bubbles(t){Util.t(t,"boolean",PanningTool,"bubbles"),this.Do=t}get originalPosition(){return this.tx}}class HTMLInfo{ix;ex;wM;xM;constructor(t){this.ix=null,this.ex=null,this.wM=null,this.xM=null,t&&Object.assign(this,t)}get mainElement(){return this.wM}set mainElement(t){t!==null&&Util.s(t,HTMLElement,HTMLInfo,"mainElement"),this.wM=t}get show(){return this.ix}set show(t){this.ix!==t&&(t!==null&&Util.t(t,"function",HTMLInfo,"show"),this.ix=t)}get hide(){return this.ex}set hide(t){this.ex!==t&&(t!==null&&Util.t(t,"function",HTMLInfo,"hide"),this.ex=t)}get valueFunction(){return this.xM}set valueFunction(t){this.xM=t}}class ContextMenuButtonInfo{ui;Fm;Lf;constructor(t,i,e){this.ui=t,this.Fm=i,this.Lf=e}}class ContextMenuTool extends Tool{bM;sx;kM;SM;nx;ox;Rm;constructor(t){super(),this.name="ContextMenu",this.bM=null,this.sx=null,this.kM=null,this.SM=new Point,this.nx=null,this.Rm=!1;const i=this;this.ox=()=>i.stopTool(),t&&Object.assign(this,t)}uF(){const t=new HTMLInfo;t.show=(r,l,h)=>h.showDefaultContextMenu(),t.hide=(r,l)=>l.hideDefaultContextMenu(),ContextMenuTool.Lu=t;const i=this;this.ox=()=>i.stopTool();const e=Util.ln("div"),s=Util.ln("div");e.style.cssText="top: 0px;z-index:10002;position: fixed;display: none;text-align: center;left: 25%;width: 50%;background-color: #F5F5F5;padding: 16px;border: 16px solid #444;border-radius: 10px;margin-top: 10px",s.style.cssText="z-index:10001;position: fixed;display: none;top: 0;left: 0;width: 100%;height: 100%;background-color: black;opacity: 0.8;";const n=Util.ln("style");root.document.getElementsByTagName("head")[0].appendChild(n),n.sheet.insertRule(".goCXul { list-style: none; }",0),n.sheet.insertRule(".goCXli {font:700 1.5em Helvetica, Arial, sans-serif;position: relative;min-width: 60px; }",0),n.sheet.insertRule(".goCXa {color: #444;display: inline-block;padding: 4px;text-decoration: none;margin: 2px;border: 1px solid gray;border-radius: 10px; }",0);const o=this.diagram;o!==null&&(o.Ht(e,"contextmenu",ContextMenuTool.jh,!1),o.Ht(e,"selectstart",ContextMenuTool.jh,!1),o.Ht(s,"contextmenu",ContextMenuTool.jh,!1)),e.className="goCXforeground",s.className="goCXbackground",root.document.body&&(root.document.body.appendChild(e),root.document.body.appendChild(s)),ContextMenuTool.Im=e,ContextMenuTool.Om=s,ContextMenuTool.MM=!0}static Lu=null;static MM=!1;static Om=null;static Im=null;static jh(t){return t.preventDefault(),!1}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return this.isBeyondDragSize()||!t.lastInput.right||t.lastInput.clickCount>1?!1:!!(t.lastInput.isTouchEvent&&this.defaultTouchContextMenu!==null||this.findObjectWithContextMenu()!==null)}doStart(){const t=this.diagram;this.SM.set(t.firstInput.documentPoint)}doStop(){this.hideContextMenu(),this.currentObject=null,this.Rm=!1}findObjectWithContextMenu(t){t===void 0&&(t=null);const i=this.diagram,e=i.lastInput;let s=null;if(t instanceof Diagram||(t instanceof GraphObject?s=t:s=i.findObjectAt(e.documentPoint,null,n=>!n.layer.isTemporary)),s!==null){let n=s;for(;n!==null;){if(n.contextMenu!==null)return n;n=n.panel}if(i.lastInput.isTouchEvent&&this.defaultTouchContextMenu)return s.part}else if(i.contextMenu!==null)return i;return null}doActivate(){}doMouseDown(){if(super.doMouseDown(),this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doMouseDown(),t.doDeactivate())}this.diagram.toolManager.mouseDownTools.has(this)&&this.doContextClick()}doMouseUp(){if(this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doCancel(),t.doDeactivate())}this.doContextClick()}doContextClick(){const t=this.diagram;if(!this.isActive)this.canStart()&&(this.openMenu(!0),this.isActive||this.stopTool());else{const i=this.currentContextMenu;if(i===null)return;let e=null;i instanceof HTMLInfo||(e=t.findObjectAt(t.lastInput.documentPoint,null,null),e!==null&&e.isContainedBy(i)&&this.standardMouseClick(null,null)),this.maybeStopTool(e)}}maybeStopTool(t){this.stopTool(),this.canStart()&&(this.diagram.currentTool=this,this.doMouseUp())}openMenu(t,i){if(i===void 0&&(i=null),this.Rm)return;this.Rm=!0,t&&this.standardMouseSelect();const e=this.standardMouseClick();if(this.Rm=!1,!e){this.isActive=!0;const s=ContextMenuTool.Lu;if(i===null&&(i=this.findObjectWithContextMenu()),i!==null){const n=i.contextMenu;n!==null?(this.currentObject=i instanceof GraphObject?i:null,this.showContextMenu(n,this.currentObject)):s!==null&&this.showContextMenu(s,this.currentObject)}else s!==null&&this.showContextMenu(s,null);this.currentContextMenu instanceof Adornment&&!this.currentContextMenu.visible&&this.stopTool()}}doMouseMove(){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.doMouseMove(),this.isActive&&this.diagram.toolManager.doMouseMove()}showContextMenu(t,i){Debug&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("showContextMenu:contextMenu must be an Adornment or HTMLInfo."),i!==null&&Util.s(i,GraphObject,ContextMenuTool,"showContextMenu:obj");const e=this.diagram;if(t!==this.currentContextMenu&&this.hideContextMenu(),t instanceof Adornment){const s=t;s.layerName="Tool",s.selectable=!1,s.scale=1/e.scale,s.category=this.name,s.hasPlaceholder()&&(s.placeholder.scale=e.scale);const n=s.diagram;n!==null&&n!==e&&n.remove(s),e.add(s),i!==null?s.adornedObject=i:s.data=e.model,s.ensureBounds(),this.positionContextMenu(s,i)}else t instanceof HTMLInfo&&t.show(i,e,this);this.currentContextMenu=t}positionContextMenu(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom&&(n.y-=o.height+5/s.scale),n.ye.commandHandler.copySelection(),e=>e.commandHandler.canCopySelection())),i.add(new ContextMenuButtonInfo("Cut",e=>e.commandHandler.cutSelection(),e=>e.commandHandler.canCutSelection())),i.add(new ContextMenuButtonInfo("Delete",e=>e.commandHandler.deleteSelection(),e=>e.commandHandler.canDeleteSelection())),i.add(new ContextMenuButtonInfo("Paste",e=>e.commandHandler.pasteSelection(t.mouseDownPoint),e=>e.commandHandler.canPasteSelection(t.mouseDownPoint))),i.add(new ContextMenuButtonInfo("Select All",e=>e.commandHandler.selectAll(),e=>e.commandHandler.canSelectAll())),i.add(new ContextMenuButtonInfo("Undo",e=>e.commandHandler.undo(),e=>e.commandHandler.canUndo())),i.add(new ContextMenuButtonInfo("Redo",e=>e.commandHandler.redo(),e=>e.commandHandler.canRedo())),i.add(new ContextMenuButtonInfo("Scroll To Part",e=>e.commandHandler.scrollToPart(),e=>e.commandHandler.canScrollToPart())),i.add(new ContextMenuButtonInfo("Zoom To Fit",e=>e.commandHandler.zoomToFit(),e=>e.commandHandler.canZoomToFit())),i.add(new ContextMenuButtonInfo("Reset Zoom",e=>e.commandHandler.resetZoom(),e=>e.commandHandler.canResetZoom())),i.add(new ContextMenuButtonInfo("Group Selection",e=>e.commandHandler.groupSelection(),e=>e.commandHandler.canGroupSelection())),i.add(new ContextMenuButtonInfo("Ungroup Selection",e=>e.commandHandler.ungroupSelection(),e=>e.commandHandler.canUngroupSelection())),i.add(new ContextMenuButtonInfo("Edit Text",e=>e.commandHandler.editTextBlock(),e=>e.commandHandler.canEditTextBlock())),i}showDefaultContextMenu(){const t=this.diagram;this.nx===null&&(this.nx=this.dF()),ContextMenuTool.Im.innerHTML="",ContextMenuTool.Om.addEventListener("pointerdown",this.ox,!1);const i=this,e=Util.ln("ul");e.className="goCXul",ContextMenuTool.Im.appendChild(e),e.innerHTML="";const s=this.nx.iterator;for(;s.next();){const n=s.value,o=n.Fm,r=n.Lf;if(typeof o!="function"||typeof r=="function"&&!r(t))continue;const l=Util.ln("li");l.className="goCXli";const h=Util.ln("a");h.className="goCXa",h.href="#",h.Fm=n.Fm,h.addEventListener("pointerdown",function(a){return this.Fm(t),i.stopTool(),a.preventDefault(),!1},!1),h.textContent=n.ui,l.appendChild(h),e.appendChild(l)}ContextMenuTool.Im.style.display="block",ContextMenuTool.Om.style.display="block"}hideDefaultContextMenu(){if(this.currentContextMenu===null||this.currentContextMenu!==ContextMenuTool.Lu)return;ContextMenuTool.Im.style.display="none",ContextMenuTool.Om.style.display="none";const t=this.diagram;t!==null&&t.Li(ContextMenuTool.Om,"pointerdown",this.ox,!1),this.currentContextMenu=null}get currentContextMenu(){return this.bM}set currentContextMenu(t){Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("ContextMenuTool.currentContextMenu must be an Adornment or HTMLInfo."),this.bM=t,this.sx=t instanceof Adornment?t.adornedPart:null}get defaultTouchContextMenu(){return ContextMenuTool.MM===!1&&ContextMenuTool.Lu===null&&Diagram.isUsingDOM()&&this.uF(),ContextMenuTool.Lu}set defaultTouchContextMenu(t){Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("ContextMenuTool.defaultTouchContextMenu must be an Adornment or HTMLInfo."),t===null&&(ContextMenuTool.MM=!0),ContextMenuTool.Lu=t}get currentObject(){return this.kM}set currentObject(t){t!==null&&Util.s(t,GraphObject,ContextMenuTool,"currentObject"),this.kM=t}get mouseDownPoint(){return this.SM}}var TextEditingAccept=(w=>(w[w.LostFocus=1]="LostFocus",w[w.MouseDown=2]="MouseDown",w[w.Tab=3]="Tab",w[w.Enter=4]="Enter",w))(TextEditingAccept||{}),TextEditingStarting=(w=>(w[w.SingleClick=1]="SingleClick",w[w.SingleClickSelected=2]="SingleClickSelected",w[w.DoubleClick=3]="DoubleClick",w))(TextEditingStarting||{}),TextEditingState=(w=>(w[w.None=1]="None",w[w.Active=2]="Active",w[w.Editing=3]="Editing",w[w.Validating=4]="Validating",w[w.Invalid=5]="Invalid",w[w.Validated=6]="Validated",w))(TextEditingState||{});class TextEditingTool extends Tool{Le;PM;NM;Il;vt;CM;AM;LM;rx;lx;constructor(t){super(),this.name="TextEditing",this.Le=new TextBlock,this.PM=null,this.NM=2,this.Il=null,this.vt=1,this.CM=1,this.AM=!0,this.LM=null,this.rx=new HTMLInfo,this.lx=null,this.gF(this.rx),t&&Object.assign(this,t)}static LostFocus=1;static MouseDown=2;static Tab=3;static Enter=4;static SingleClick=1;static SingleClickSelected=2;static DoubleClick=3;static StateNone=1;static StateActive=2;static StateEditing=3;static StateValidating=4;static StateInvalid=5;static StateValidated=6;gF(t){if(!Diagram.isUsingDOM())return;const i=Util.ln("textarea");this.lx=i;const e=this;i.addEventListener("input",function(s){if(e.textBlock===null)return;const n=e.measureTemporaryTextBlock(this.value),o=this.textScale;this.style.width=20+Math.max(e.textBlock.measuredBounds.width,n.measuredBounds.width)*o+"px",this.rows=Math.max(e.textBlock.lineCount,n.lineCount)},!1),i.addEventListener("keydown",function(s){if(s.isComposing||e.textBlock===null)return;const n=s.key;if(n==="Enter"){e.textBlock.isMultiline===!1&&s.preventDefault(),e.acceptText(4);return}else if(n==="Tab"){e.acceptText(3),s.preventDefault();return}else n==="Escape"&&(e.doCancel(),e.diagram!==null&&e.diagram.doFocus())},!1),i.addEventListener("focus",function(s){e.mF(s)},!1),i.addEventListener("blur",function(s){e.pF(s)},!1),t.valueFunction=()=>i.value,t.mainElement=i,t.show=(s,n,o)=>{if(!(s instanceof TextBlock&&o instanceof TextEditingTool))return;if(o.state===5){i.style.border="3px solid red",i.focus();return}const r=s.getDocumentPoint(Spot.Center),l=n.position,h=n.scale;let a=s.getDocumentScale()*h;a{s.div.removeChild(i)}}get textBlock(){return this.PM}set textBlock(t){t!==null&&Util.s(t,TextBlock,TextEditingTool,"textBlock"),this.PM=t}get currentTextEditor(){return this.LM}set currentTextEditor(t){this.LM=t}get defaultTextEditor(){return this.rx}set defaultTextEditor(t){Debug&&!(t instanceof HTMLInfo)&&Util.n("TextEditingTool.defaultTextEditor must be an HTMLInfo."),this.rx=t}get starting(){return this.NM}set starting(t){Util.tt(t,TextEditingStarting,"TextEditingStarting"),this.NM=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t===null||t.isReadOnly||TextEditingTool.Tf&&TextEditingTool.Tf!==this&&(TextEditingTool.Tf.acceptText(2),TextEditingTool.Tf&&TextEditingTool.Tf!==this)||!t.lastInput.left||this.isBeyondDragSize())return!1;const i=t.lastInput.documentPoint,e=t.findObjectAt(i);if(e===null||!(e instanceof TextBlock)||!e.editable||!e.part.canEdit())return!1;const s=e.part;return!(s===null||this.starting===2&&!s.isSelected||this.starting===3&&t.lastInput.clickCount<2)}doStart(){TextEditingTool.Tf=this,this.textBlock!==null&&this.doActivate()}doActivate(){if(this.isActive)return;const t=this.diagram;if(t===null)return;let i=this.textBlock;if(i===null&&(i=t.findObjectAt(t.lastInput.documentPoint)),i===null||!(i instanceof TextBlock)||(this.textBlock=i,i.part===null))return;t.animationManager.stopAnimation(),this.isActive=!0,this.vt=2;let s=this.defaultTextEditor;i.textEditor!==null&&(s=i.textEditor),this.Le=this.textBlock.copy();const n=new Rect(this.textBlock.getDocumentPoint(Spot.TopLeft),this.textBlock.getDocumentPoint(Spot.BottomRight));t.scrollToRect(n),s.show(i,t,this),this.currentTextEditor=s}doCancel(){this.stopTool()}doMouseUp(){this.canStart()&&this.doActivate()}doMouseDown(){this.isActive&&this.acceptText(2)}acceptText(t){switch(t){case 2:this.vt===6?this.currentTextEditor instanceof HTMLElement&&this.currentTextEditor.focus():(this.vt===2||this.vt===5||this.vt===3)&&(this.vt=4,this.tA());break;case 1:case 4:case 3:if(t===4&&this.textBlock.isMultiline===!0)return;(this.vt===2||this.vt===5||this.vt===3)&&(this.vt=4,this.tA());break}}tA(){const t=this.textBlock,i=this.diagram,e=this.currentTextEditor;if(t!==null&&e!==null){const s=t.text;let n="";if(e.valueFunction!==null&&(n=e.valueFunction()),!this.isValidText(t,s,n)){this.vt=5,this.doError(s,n);return}this.startTransaction(this.name),this.vt=6,this.transactionResult=this.name,t.text=n,this.doSuccess(s,n),i!==null&&i.V("TextEdited",t,s),this.stopTransaction(),this.stopTool(),i!==null&&i.doFocus()}}doError(t,i){const e=this.textBlock;e.errorFunction!==null&&e.errorFunction(this,t,i);const s=this.currentTextEditor;s&&s.show(e,this.diagram,this)}doSuccess(t,i){const e=this.textBlock;e.textEdited!==null&&e.textEdited(e,t,i)}doDeactivate(){const t=this.diagram;t!==null&&(this.vt=1,this.currentTextEditor!==null&&this.currentTextEditor.hide(t,this),this.textBlock=null,this.isActive=!1)}doStop(){TextEditingTool.Tf=null}mF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this.lx;this.vt===2&&(this.vt=3),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}pF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this.lx;typeof i.focus=="function"&&i.focus(),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}isValidText(t,i,e){Util.s(t,TextBlock,TextEditingTool,"isValidText:textblock");const s=this.textValidation;if(s!==null&&!s(t,i,e))return!1;const n=t.textValidation;return!(n!==null&&!n(t,i,e))}get textValidation(){return this.Il}set textValidation(t){t!==null&&Util.t(t,"function",TextEditingTool,"textValidation"),this.Il=t}get minimumEditorScale(){return this.CM}set minimumEditorScale(t){t!==null&&Util.t(t,"number",TextEditingTool,"minimumEditorScale"),this.CM=t}get selectsTextOnActivate(){return this.AM}set selectsTextOnActivate(t){t!==null&&Util.t(t,"boolean",TextEditingTool,"selectsTextOnActivate"),this.AM=t}get state(){return this.vt}set state(t){this.vt!==t&&(Util.tt(t,TextEditingState,"TextEditingState"),this.vt=t)}measureTemporaryTextBlock(t){const i=this.Le;return i.text=t,i.wt(this.textBlock.Ol,1/0),i}static Tf=null}var AnimationStyle=(w=>(w[w.Default=1]="Default",w[w.AnimateLocations=2]="AnimateLocations",w[w.None=3]="None",w))(AnimationStyle||{});class AnimationManager{b;Ti;Xi;Cr;Zn;Io;TM;DM;Em;Si;Df;yn;Vm;Wh;hx;Bm;ax;Ff;Cu;zm;constructor(t){this.b=Diagram.Mm(),this.Ti=!1,this.Em=!1,this.Si=!1,this.Df=!1,this.ax=!0,this.Ff=1,this.Cu=!1,this.Xi=!0,this.Cr=!0,this.Io=600,this.TM=!1,this.DM=!1,this.Zn=new GSet,this.yn=new Animation,this.Vm=new Animation,this.yn.ws=this,this.Wh=new GSet,this.hx=new GSet,this.Bm=new GSet,this.zm=new GSet,t&&Object.assign(this,t)}Oo(t){this.b=t}aE(){return this.b}canStart(t){return!0}El(t){return!this.Xi||!this.canStart(t)?!1:(this.Zn.add(t),this.defaultAnimation.isAnimating&&this.stopAnimation(),this.b.Di(),this.Si=!0,!0)}getBundleAnimation(){return this.Vm}FM(){if(!this.Xi||(this.Vm.ge.count>0&&this.Vm.start(),!this.Si))return;const t=this.yn,i=this.b,e=this.Zn.has("Model");if(e&&(this.Df=!0,this.Ff===1?(t.isViewportUnconstrained=!0,t.ge.clear(),t.add(i,"position",i.position.copy().offset(0,-200),i.position),t.add(i,"opacity",0,1)):this.Ff===3&&t.ge.clear(),this.Ff===2&&i.fx.equals(i.mt)?this.ax=!0:this.ax=!1,i.V("InitialAnimationStarting",this)),e&&!this.Cr||t.ge.count===0){this.Zn.clear(),this.Si=!1,t.ge.clear(),t.cx(i),this.Df=!1,i.T();return}this.Zn.clear(),i.Ar=!1;const s=t.ge.get(i);i.autoScale!==1&&s!==null&&(delete s.li.scale,delete s.xs.scale);const n=this;root.requestAnimationFrame(()=>{n.Si===!1||t.Ti||(i.getRenderingHint("temporaryPixelRatio")&&i.jw(),i.RM(),n.Si=!1,t.start(),t.Ti&&(n.Tu(),i.invalidateDocumentBounds(),t.iA(0),i.Sr(!0),n.Du(),i.V("AnimationStarting",n)))})}IM(){return this.Zn.has("Trigger")&&this.Zn.count===1}eA(t,i,e,s){this.isTicking||this.IM()||t instanceof Link&&(t.fromNode!==null||t.toNode!==null)||this.yn.add(t,"position",i,e,s)}ux(t){return this.yn.ux(t)}OM(t){return this.yn.OM(t)}yF(t){const i=this.Wh,e=this;function s(){if(e.Bm.count>0&&(i.addAll(e.Bm),e.Bm.clear(),e.Ti=!0),e.Ti===!1||i.count===0)return;e.hx.addAll(i);const n=e.hx.iterator;for(;n.next();){const o=n.value;o.Ti!==!1&&(o.wF()?o.sA(!1):o.Rf=!0)}if(e.hx.clear(),e.Ti===!1){root.requestAnimationFrame(s);return}e.Tu(),e.b.Sr(),e.Du(),root.requestAnimationFrame(s)}this.Ti?this.xF(t):(this.Ti=!0,i.add(t),root.requestAnimationFrame(()=>s()))}xF(t){this.Bm.add(t)}bF(){const t=this.Wh.iterator;for(;t.next();)t.value.Rf=!1}Tu(){if(this.Em)return;const t=this.b;this.TM=t.skipsUndoManager,this.DM=t.me,t.skipsUndoManager=!0,t.me=!0,this.Em=!0}Du(){const t=this.b;t.skipsUndoManager=this.TM,t.me=this.DM,this.Em=!1}stopAnimation(t){const i=this.yn;if(this.Si===!0&&(this.Si=!1,this.Df=!1,this.Zn.clear(),i.kF()&&this.b.requestUpdate()),!this.Ti){i.ge.clear(),i.cx(this.b);return}if(i.Fu(!0),i.cx(null),t===!0){const e=this.Wh.toArray();for(let s=0;s{!i.isAnimating&&i.runCount===1/0&&i.start()})}get duration(){return this.Io}set duration(t){Util.t(t,"number",AnimationManager,"duration"),t<1&&Util.G(t,">= 1",AnimationManager,"duration"),this.Io=t}get isAnimating(){return this.Ti}get isTicking(){return this.Em}get isInitial(){return this.Cr}set isInitial(t){Util.t(t,"boolean",AnimationManager,"isInitial"),this.Cr=t}get defaultAnimation(){return this.yn}get activeAnimations(){return this.Wh}get initialAnimationStyle(){return this.Ff}set initialAnimationStyle(t){Debug&&Util.tt(t,AnimationStyle,"AnimationStyle"),this.Ff=t}static gx=new GMap;static defineAnimationEffect(t,i){AnimationManager.gx.set(t,i)}static BM(t,i,e,s,n){t===null&&(t=[0,0,0,0]),i===null&&(i=[0,0,0,0]);let o=t[0],r=t[1];const l=t[2],h=t[3];let a=i[0],f=i[1];const c=i[2],u=i[3];l===0||l===100?(o=a,r=f):(c===0||c===100)&&(a=o,f=r),Math.abs(a-o)>180&&(a>o?o+=360:a+=360);const d=n(e,o,a-o,s)%360,m=n(e,r,f-r,s),g=n(e,l,c-l,s),p=n(e,h,u-h,s);return"hsla("+d+", "+m+"%, "+g+"%, "+p+")"}static{const t=AnimationManager.gx,i=(e,s,n,o,r,l)=>{e.position=new Point(o(r,s.x,n.x-s.x,l),o(r,s.y,n.y-s.y,l))};t.set("position:diagram",i),t.set("position",i),t.set("position:part",(e,s,n,o,r,l)=>{r{r{r{const h=e.actualBounds,a=n.actualBounds,f=a.x+a.width/2-h.width/2,c=a.y+a.height/2-h.height/2;r{e.desiredSize=new Size(o(r,s.width,n.width-s.width,l),o(r,s.height,n.height-s.height,l))}),t.set("width",(e,s,n,o,r,l)=>{e.width=o(r,s,n-s,l)}),t.set("height",(e,s,n,o,r,l)=>{e.height=o(r,s,n-s,l)}),t.set("fill",(e,s,n,o,r,l)=>{e.fill=AnimationManager.BM(s,n,r,l,o)}),t.set("stroke",(e,s,n,o,r,l)=>{e.stroke=AnimationManager.BM(s,n,r,l,o)}),t.set("strokeWidth",(e,s,n,o,r,l)=>{e.strokeWidth=o(r,s,n-s,l)}),t.set("strokeDashOffset",(e,s,n,o,r,l)=>{e.strokeDashOffset=o(r,s,n-s,l)}),t.set("background",(e,s,n,o,r,l)=>{e.background=AnimationManager.BM(s,n,r,l,o)}),t.set("opacity",(e,s,n,o,r,l)=>{e.opacity=o(r,s,n-s,l)}),t.set("scale",(e,s,n,o,r,l)=>{e.scale=o(r,s,n-s,l)}),t.set("angle",(e,s,n,o,r,l)=>{e.angle=o(r,s,n-s,l)})}static Default=1;static AnimateLocations=2;static None=3}class Animation{mx;Xm;Ti;Ru;Io;bs;lA;Ef;ge;px;li;$n;Iu;Vf;yx;wx;Rf;zM;xx;ws;b;XM;YM;KM;constructor(t){this.b=null,this.ws=null,this.zM=null,this.xx=null,this.XM=!1,this.Ti=!1,this.Rf=!1,this.li=0,this.$n=0,this.mx=Animation.EaseInOutQuad,this.Xm=Animation.EaseInOutQuad,this.Iu=!1,this.Vf=!1,this.yx=1,this.wx=0,this.Io=NaN,this.bs=NaN,this.YM=0,this.Ru=null,this.lA=Point.Lo,this.ge=new GMap,this.px=new GMap,this.Ef=new GSet,this.KM=1,t&&Object.assign(this,t)}suspend(){this.Rf=!0}advanceTo(t,i){i&&(this.Rf=!1),this.Iu&&t>=this.bs&&(this.Vf=!0,t=t-this.bs),this.YM=t,this.sA(!0),this.ws.Tu(),this.b.Sr(),this.ws.Du(),this.b.redraw()}cx(t){if(this.px.clear(),this.Vf=!1,this.wx=0,this.bs=NaN,this.Ef.count>0&&this.Ef.clear(),t!==null){const i=t.links;for(;i.next();)i.value.Lr=null}}kF(){return this.ge.count>0}start(){if(this.ge.count===0)return this;if(this.Ti)return this;let t=this.b;const i=this.ge.iterator;for(;i.next();){const s=i.key;t===null&&(s instanceof Diagram?t=s:s instanceof GraphObject&&(t=s.diagram))}if(t!==null)this.b=t,this.ws=t.animationManager;else return this;const e=this.ws;return e.isEnabled===!1?this:(this.bs=isNaN(this.Io)?e.duration:this.Io,this.Xm=this.mx,e.Df&&e.Ff===1&&this===e.defaultAnimation&&(this.Xm=Animation.EaseOutExpo,this.bs=isNaN(this.Io)?e.duration===600?900:e.duration:this.Io),this.KM=t.scrollMode,this.isViewportUnconstrained&&(t.vh=2),e.Tu(),this.Ef.each(s=>{s.data=null,t.add(s)}),e.Du(),this.Ti=!0,this.li=+new Date,this.$n=this.li+this.bs,e.yF(this),this)}addTemporaryPart(t,i){return t.Ae()?(Debug&&(i===void 0&&Util.n("addTemporaryPart: Required Diagram argument missing"),t.diagram===i&&Util.n("addTemporaryPart: Part already in Diagram, did you mean to pass in a copy?"),this.b!==null&&this.b!==i&&Util.n("addTemporaryPart: A different Diagram is already associated with this Animation: "+this.b.toString())),this.Ef.add(t),this.b=i,this):this}add(t,i,e,s,n){if(this.b===null&&(t instanceof Diagram?this.b=t:t instanceof GraphObject&&t.diagram!==null&&(this.b=t.diagram)),t instanceof Part){if(!t.isAnimated)return this;i==="position"&&(i="position:part")}return this.EM(t,i,e,s,n),this}EM(t,i,e,s,n){const o=this.ge;let r,l,h;if(t instanceof Diagram&&i==="position"&&(i="position:diagram"),(i==="fill"||i==="stroke"||i==="background")&&(Brush.Eo(e),Brush.UM(),e=[Brush.Yi.n0,Brush.Yi.n1,Brush.Yi.n2,Brush.Yi.n3],Brush.Eo(s),Brush.UM(),s=[Brush.Yi.n0,Brush.Yi.n1,Brush.Yi.n2,Brush.Yi.n3]),o.has(t))r=o.get(t),l=r.li,h=r.xs,l[i]===void 0&&(l[i]=this.Ou(e)),h[i]=this.Ou(s);else{if(i==="position"&&e.equalsApprox(s))return;l={},h={},l[i]=this.Ou(e),h[i]=this.Ou(s),r=new AnimationState(l,h,n),o.set(t,r)}const a=l[i];a instanceof Point&&!a.isReal()&&a.c(this.lA),n&&i.indexOf("position:")===0&&t instanceof Part?r.bx.location=this.Ou(t.location):n&&(r.bx[i]=this.Ou(e))}Ou(t){return t instanceof Point||t instanceof Size?t.copy():t}SF(t){const i=this.ge;if(i.has(t)){const e=i.get(t);e.kx=!0}}ux(t){if(!this.Ti)return!1;const i=this.ge.get(t);return i!==null&&i.kx}OM(t){if(!this.Ti)return!1;const i=this.ge.get(t);return i!==null&&!!(i.li.position||i.li["position:part"]||i.li.location)}wF(){if(this.Ef.count>0)return!0;const t=this.ge.iterator;for(;t.next();){const i=t.key;if(i instanceof GraphObject&&i.diagram!==null||i instanceof Diagram)return!0}return!1}sA(t){if(this.Rf&&!t)return;const i=this.ws;if(this.Ti===!1)return;const e=+new Date;let s=e>this.$n?this.bs:e-this.li;t&&(s=this.YM,sthis.$n&&(this.Iu&&!this.Vf?(this.li=+new Date,this.$n=this.li+this.bs,this.Vf=!0):this.Fu(!1))}iA(t){const i=this.bs,e=this.ge.iterator,s=this.Vf;for(;e.next();){const n=e.key;if(n instanceof GraphObject&&n.diagram===null)continue;const o=e.value,r=s?o.xs:o.li,l=s?o.li:o.xs,h=AnimationManager.gx;for(const a in l)a==="position"&&(l["position:placeholder"]||l["position:nodeCollapse"])||h.get(a)!==null&&h.get(a)(n,r[a],l[a],this.Xm,t,i,this)}}stop(){return this.Ti?(this.Fu(!0),this):this}Fu(t){if(this.xx!==null&&this.xx.MF(this.zM),!this.Ti)return;const i=this.b,e=this.ws;e.Df=!1,this.Ti=!1,this.Rf=!1,e.Tu();const s=this.ge,n=this.Ef.iterator;for(;n.next();)i.remove(n.value);const o=this.Iu,r=s.iterator,l=AnimationManager.gx;for(;r.next();){const a=r.key,f=r.value,c=o?f.xs:f.li,u=o?f.li:f.xs,d=f.bx;for(const m in u)if(l.get(m)!==null){let g=m;f.Sx&&(g==="position:nodeCollapse"||g==="position:placeholder")&&(g="position"),l.get(g)(a,c[m],d[m]!==void 0?d[m]:f.Sx?c[m]:u[m],this.Xm,this.bs,this.bs,this)}f.Sx&&d.location!==void 0&&a instanceof Part&&(a.location=d.location),f.kx&&a instanceof Part&&a.Ki(!1)}this.wx++;const h=!t&&this.yx>this.wx;if(!h&&(this===e.Vm||this===e.defaultAnimation)&&this.ge.clear(),i.Mx.clear(),i.NS(!1),i.invalidateDocumentBounds(),i.T(),i.Sr(!0),e.defaultAnimation===this){const a=e.zm.iterator;for(;a.next();)a.value.PF();e.zm.clear()}if(i.Sr(!0),this.isViewportUnconstrained&&(i.scrollMode=this.KM),e.Du(),h){this.Vf=!1,this.start();return}this.cx(null),e.Fu(this),this.Ru&&this.Ru(this),i.requestUpdate()}If(t,i){const e=i.actualBounds;let s=null;if(i instanceof Group&&(s=i.placeholder),s!==null&&s.visible){const n=s.getDocumentPoint(Spot.TopLeft),o=s.padding;n.x+=o.left,n.y+=o.top,this.add(t,"position",n,t.position,!1)}else this.add(t,"position",new Point(e.x+e.width/2,e.y+e.height/2),t.position,!1);this.add(t,"scale",.01,t.scale,!1),t instanceof Group&&this.NF(t,i)}NF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.If(s,i)}}Of(t,i){if(!t.isVisible())return;let e=null;if(i instanceof Group&&(e=i.placeholder),e!==null&&e.visible){const s=e.getDocumentPoint(Spot.TopLeft),n=e.padding;s.x+=n.left,s.y+=n.top,this.add(t,"position:placeholder",t.position,s,!0)}else this.add(t,"position:nodeCollapse",t.position,i,!0);this.add(t,"scale",t.scale,.01,!0),this.SF(t),t instanceof Group&&this.CF(t,i)}CF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Of(s,i)}}get duration(){return this.Io}set duration(t){Util.t(t,"number",Animation,"duration"),t<1&&Util.G(t,">= 1",Animation,"duration"),this.Io=t}get reversible(){return this.Iu}set reversible(t){this.Iu=t}get runCount(){return this.yx}set runCount(t){t>0?this.yx=t:Util.n("Animation.runCount value must be a positive integer.")}get finished(){return this.Ru}set finished(t){this.Ru!==t&&(t!==null&&Util.t(t,"function",Animation,"finished"),this.Ru=t)}get easing(){return this.mx}set easing(t){this.mx=t}get isViewportUnconstrained(){return this.XM}set isViewportUnconstrained(t){this.XM=t}get isAnimating(){return this.Ti}getTemporaryState(t){let i=this.px.get(t);return i===null&&(i={},this.px.set(t,i)),i}static EaseLinear=(t,i,e,s)=>e*t/s+i;static EaseInOutQuad=(t,i,e,s)=>(t/=s/2,t<1?e/2*t*t+i:-e/2*(--t*(t-2)-1)+i);static EaseInQuad=(t,i,e,s)=>e*(t/=s)*t+i;static EaseOutQuad=(t,i,e,s)=>-e*(t/=s)*(t-2)+i;static EaseInExpo=(t,i,e,s)=>t===0?i:e*Math.pow(2,10*(t/s-1))+i;static EaseOutExpo=(t,i,e,s)=>t===s?i+e:e*(-Math.pow(2,-10*t/s)+1)+i}class AnimationState{li;xs;bx;Sx;kx;constructor(t,i,e){this.li=t,this.xs=i,this.bx={},this.Sx=e,this.kx=!1}}var TriggerStart=(w=>(w[w.Default=1]="Default",w[w.Immediate=2]="Immediate",w[w.Bundled=3]="Bundled",w))(TriggerStart||{});class AnimationTrigger{Ce;gn;Eu;Bf;constructor(t,i,e){e&&Debug&&Util.tt(e,TriggerStart,"TriggerStart"),this.Ce=null,this.gn=t,this.Eu=e||1,this.Bf=null,i!==void 0&&(this.Bf=i,e===void 0&&(this.Eu=2))}copy(){const t=new AnimationTrigger(this.gn);t.Eu=this.Eu;const i=this.Bf;if(i!==null){const e={};i.duration!==void 0&&(e.duration=i.duration),i.finished!==void 0&&(e.finished=i.finished),i.easing!==void 0&&(e.easing=i.easing),t.Bf=e}return t}get propertyName(){return this.gn}set propertyName(t){this.gn=t}get animationSettings(){return this.Bf}set animationSettings(t){this.Bf=t}AF(t){const i=this.Bf;i!==null&&(i.duration&&(t.duration=i.duration),i.finished&&(t.finished=i.finished),i.easing&&(t.easing=i.easing))}get startCondition(){return this.Eu}set startCondition(t){Debug&&Util.tt(t,TriggerStart,"TriggerStart"),this.Eu=t}static Default=1;static Immediate=2;static Bundled=3}class Layer{b;Tt;_t;Tr;Vl;Bl;zl;Xl;Yl;Kl;Ul;Gl;Hl;ql;jl;Wl;Lf;vl;Px;Ym;Vu;It;constructor(t){GSet.vi(this),this.b=null,this.It=new List,this.Tt="",this._t=1,this.Tr=!1,this.Vl=!0,this.Bl=!0,this.zl=!0,this.Xl=!0,this.Yl=!0,this.Kl=!0,this.Ul=!0,this.Gl=!0,this.Hl=!0,this.ql=!0,this.jl=!0,this.Wl=!0,this.Lf=!0,this.vl=!0,this.Px=!0,this.Ym=!1,this.Vu=[],t&&Object.assign(this,t)}LF(){const t=this.It;for(let i=0;i0&&(h+=e+" Parts "),s>0&&(h+=s+" Nodes "),n>0&&(h+=n+" Groups "),o>0&&(h+=o+" Links "),r>0&&(h+=r+" Adornments "),t>1){const a=this.It.iterator;for(;a.next();){const f=a.value;h+=` - `+f.toString();const c=f.data;c!==null&&GSet.gs(c)&&(h+=" #"+GSet.gs(c)),f instanceof Node?h+=" "+Util.toString(c):f instanceof Link&&(h+=" "+Util.toString(f.fromNode)+" "+Util.toString(f.toNode))}}return i+" "+this.It.count+": "+h}findObjectAt(t,i,e){if(i===void 0&&(i=null),e===void 0&&(e=null),this.vl===!1)return null;Debug&&!t.isReal()&&Util.n("findObjectAt: Point must have a real value, not: "+t.toString());let s=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(s=!0);const n=Point.a(),o=this.It.h,r=o.length;for(let l=r;l--;){const h=o[l];if(s===!0&&h.Tl()===!1||!h.isVisible())continue;n.c(t),n.Ye(h.Ks);let a=h.hA(n,i,e);if(a!==null&&(i!==null&&(a=i(a)),a!==null&&(e===null||e(a))))return Point.o(n),a}return Point.o(n),null}findObjectsAt(t,i,e,s){if(i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.vl===!1)return s;Debug&&!t.isReal()&&Util.n("findObjectsAt: Point must have a real value, not: "+t.toString());let n=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(n=!0);const o=Point.a(),r=this.It.h,l=r.length;for(let h=l;h--;){const a=r[h];if(n===!0&&a.Tl()===!1||!a.isVisible())continue;o.c(t),o.Ye(a.Ks);let f=a;a.aA(o,i,e,s)&&(i!==null&&(f=i(f)),f!==null&&(e===null||e(f))&&s.add(f))}return Point.o(o),s}findObjectsIn(t,i,e,s,n){if(i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.vl===!1)return n;Debug&&!t.isReal()&&Util.n("findObjectsIn: Rect must have a real value, not: "+t.toString());let o=!1;this.diagram!==null&&this.diagram.viewportBounds.containsRect(t)&&(o=!0);const r=this.It.h,l=r.length;for(let h=l;h--;){const a=r[h];if(o===!0&&a.Tl()===!1||!a.isVisible())continue;let f=a;a.Km(t,i,e,s,n)&&(i!==null&&(f=i(f)),f!==null&&(e===null||e(f))&&n.add(f))}return n}IS(t,i,e,s,n,o,r){if(this.vl===!1)return n;const l=this.It.h,h=l.length;for(let a=h;a--;){const f=l[a];if(r===!0&&f.Tl()===!1||!o(f)||!f.isVisible())continue;let c=f;f.Km(t,i,e,s,n)&&(i!==null&&(c=i(c)),c!==null&&(e===null||e(c))&&n.add(c))}return n}findObjectsNear(t,i,e,s,n,o){if(e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.vl===!1)return o;Debug&&!t.isReal()&&Util.n("findObjectsNear: Point must have a real value, not: "+t.toString());let r=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(r=!0);const l=Point.a(),h=Point.a(),a=this.It.h,f=a.length;for(let c=f;c--;){const u=a[c];if(r===!0&&u.Tl()===!1||!u.isVisible())continue;l.c(t),l.Ye(u.Ks),h.e(t.x+i,t.y),h.Ye(u.Ks);let d=u;u.fA(l,h,e,s,n,o)&&(e!==null&&(d=e(d)),d!==null&&(s===null||s(d))&&o.add(d))}return Point.o(l),Point.o(h),o}HM(){return this.It.h}Us(t,i){if(!this.visible)return;const e=this.It.h,s=e.length;if(s===0)return;const n=Util.ft(),o=Util.ft();for(let r=0;r0&&o.push(l))}for(let r=0;re.Gm||a.height*n>e.Gm?i.Ji(t,e):this.RF(t,i),f&&(t.restore(),t.clearContextCache(!0))}RF(t,i){const e=i.actualBounds,s=i.naturalBounds;if(e.width===0||e.height===0||isNaN(e.x)||isNaN(e.y)||!i.isVisible())return;const n=i.O;if(i.background===null){i.wn(t,"rgba(0,0,0,0.3)",!0,!1,s,e),t.fillRect(e.x,e.y,e.width,e.height);return}if(t.transform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),i.wn(t,i.background,!0,!1,s,e),t.fillRect(0,0,s.width/2,s.height/2),!n.Gk()){const o=1/(n.m11*n.m22-n.m12*n.m21);t.transform(n.m22*o,-n.m12*o,-n.m21*o,n.m11*o,o*(n.m21*n.dy-n.m22*n.dx),o*(n.m12*n.dx-n.m11*n.dy))}}FF(t,i,e,s){const n=2/s,o=4/s;for(let r=0;r=s.count)t=s.count;else if(s.elt(t)===i)return-1;s.insertAt(t,i),i.Hm(e);const n=this.diagram;return n!==null&&(e?n.T():n.Zh(i)),this.Nx(t,i),t}ne(t,i,e){if(!e&&i.layer!==this&&i.layer!==null)return i.layer.ne(t,i,e);const s=this.It;if(t<0||t>=s.length){if(t=s.indexOf(i),t<0)return-1}else if(s.elt(t)!==i&&(t=s.indexOf(i),t<0))return-1;i.qm(e),s.removeAt(t);const n=this.diagram;return n!==null&&(e?n.T():n.ne(i)),i.GM(null),t}Nx(t,i){t=this.IF(t,i),i instanceof Group&&this.OF(t,i),i.svg!==null&&i.svg.remove()}IF(t,i){const e=i.zOrder;if(isNaN(e))return t;const s=this.It,n=s.count;if(n<=1)return t;if(t<0&&(t=s.indexOf(i)),t<0)return-1;let o=t-1,r=NaN;for(;o>=0&&(r=s.elt(o).zOrder,!!isNaN(r));)o--;let l=t+1,h=NaN;for(;le)for(;;){if(o===-1||r<=e)return o++,o===t?t:(s.removeAt(t),s.insertAt(o,i),o);for(r=NaN;--o>=0&&(r=s.elt(o).zOrder,!!isNaN(r)););}else if(!isNaN(h)&&h=e)return l--,l===t?t:(s.removeAt(t),s.insertAt(l,i),l);for(h=NaN;++l=0)||e<0&&r.containingGroup===i&&(e=o,t>=0))break}if(!(e<0)&&e1)&&Util.G(t,"0 <= value <= 1",Layer,"opacity"),this._t=t;const e=this.diagram;e!==null&&e.T(),this.i("opacity",i,t)}}get isViewportAligned(){return this.Ym}set isViewportAligned(t){const i=this.Ym;i!==t&&(this.Ym=t,this.diagram&&(this.uA(),this.diagram.T()),this.i("isViewportAligned",i,t),t&&(this.isInDocumentBounds=!1))}uA(){if(!this.Ym)return;const t=this.diagram,i=this.It.h,e=i.length,s=t.Ct,n=t.At;for(let o=0;o(w[w.None=1]="None",w[w.Uniform=2]="Uniform",w[w.UniformToFill=3]="UniformToFill",w))(AutoScale||{}),CycleMode=(w=>(w[w.All=1]="All",w[w.NotDirected=2]="NotDirected",w[w.NotDirectedFast=3]="NotDirectedFast",w[w.NotUndirected=4]="NotUndirected",w[w.DestinationTree=5]="DestinationTree",w[w.SourceTree=6]="SourceTree",w))(CycleMode||{}),ScrollMode=(w=>(w[w.Document=1]="Document",w[w.Infinite=2]="Infinite",w))(ScrollMode||{}),CollapsePolicy=(w=>(w[w.TreeParent=1]="TreeParent",w[w.AllParents=2]="AllParents",w[w.AnyParents=3]="AnyParents",w))(CollapsePolicy||{});class Diagram{ws;yi;WM;Cx;Dr;Xu;Ax;Lx;Tx;Dx;Fx;Rx;zf;vh;Ix;Ox;Ex;Jl;Xf;Fr;jm;Vx;Bx;Yu;Qn;Rr;$h;Vo;Wm;Yf;vm;Kf;Ku;Ir;_n;vM;JM;zx;Xx;ZM;Yx;$M;QM;_M;Kx;Jm;Or;Er;Vr;Br;zr;Xr;Ux;Yr;Gx;Kr;Ur;Gr;Hr;Hx;tP;Bo;iP;qx;jx;eP;Ai;sP;nP;oP;zs;zo;Xi;Wx;Vl;Bl;vx;Jx;zl;Xl;Yl;Zx;Kl;Ul;Gl;Hl;ql;jl;Wl;$x;Qx;rP;Uu;Gu;_x;t1;i1;e1;Zm;s1;o1;l1;ii;lP;h1;hP;Hu;xn;to;oe;io;dA;Zl;aP;fP;$m;a1;qu;Qm;f1;qr;$l;Qh;cP;uP;_m;c1;u1;os;t0;i0;ju;Ql;Uf;e0;jr;_h;dP;s0;$t;O;Ge;Ar;Ui;ks;gP;_l;Wr;Pl;vr;ta;Gf;mP;Wu;ia;vu;Jt;th;mt;lt;Ju;Ct;At;xt;Hf;qw;d1;ea;qf;g1;m1;p1;BF;zF;Gi;Cl;Gm;o0;pP;yP;gA;r0;XF;YF;KF;w1;UF;GF;HF;sa;mA;ih;na;oa;ra;la;Nu;jh;ei;Ot;jf;eS;sS;wf;_t;static b1=null;static pA=new GMap;static wP;static xP=null;Pu;k1;S1;M1;P1;N1;l0;bP;h0;a0;f0;fx;kP;C1;Wf;constructor(t,i){if(Diagram.ww||(Diagram.Hk(),Diagram.ww=!0),GSet.vi(this),Diagram.yA(this),this.$t=!0,this.Ot=null,this.Ct=0,this.At=0,this.xt=null,Diagram.isUsingDOM()){const s=this,n=()=>{s.Li(root.document,"DOMContentLoaded",n,!1),s.setRTL()};root.document.body!==null?this.setRTL():s.Ht(root.document,"DOMContentLoaded",n,!1)}this.Hf=null,Diagram.SP("Model",PartManager);const e=this;return this.sP=s=>e.partManager.doModelDataChanged(s),this.nP=s=>e.partManager.doModelChanged(s),this.g1=null,this.m1=null,this.wA(),this.model=Model.initDiagramModel(),this.C1=null,this.themeManager=new ThemeManager,this.Bo=!0,this.xA(),this.layout=new Layout,this.Bo=!1,this.XF=null,this.YF=null,this.KF=null,this.w1=null,this.UF=null,this.GF=null,this.HF=null,this.sa=null,this.mA=null,this.ih=null,this.na=null,this.oa=null,this.ra=null,this.la=null,this.Nu=()=>{},this.jh=null,this.ju=!1,this.jf=new DiagramHelper(this),t!==void 0&&(typeof t=="string"||root.Element&&t instanceof Element?this.MP(t):i=t),i&&this.setProperties(i),this.$t=!1,this.requestUpdate(),this}iF(){return this.xt!==null}get renderer(){return this.Uf}set renderer(t){if(this instanceof Overview)return;t===""&&(t="default");const i=t.toLowerCase(),e=this.Uf;if(i===e)return;this.Uf=i;let s=null;i==="default"||i==="canvas"?(s=this.Ql.get("svg"),s!==null&&s.Bt.remove(),this.xt&&(this.ei=this.xt.di),this.ei.clearContextCache(!0)):i==="svg"?(this.Ql.has("svg")?s=this.Ql.get("svg"):(s=new SVGSurface(this,root.document),this.addRenderer("svg",s)),this.div!==null&&this.div.appendChild(s.Bt),this.ei=s.di,this.xt&&(this.xt.di.setTransform(this.Gi,0,0,this.Gi,0,0),this.xt.di.clearRect(0,0,this.Ct,this.At))):i==="debug"&&(this.Ql.has("SVG")||(s=new SVGSurface(this,root.document),this.addRenderer("SVG",s),s.Bt.style.backgroundColor="whitesmoke",this.div!==null&&this.div.after(s.Bt))),this.$t||this.redraw()}wA(){this.Wf=new List,this.setupRouters(),this.ws=new AnimationManager,this.ws.Oo(this),this.yi=17,this.WM=!1,this.Ju=!1,this.Cx="default",this.Jt=new List,this.Ql=new GMap,this.Uf="default",this.resetRenderingHints(),this.qF(),this._t=1,this.mt=new Point(NaN,NaN).w(),this.fx=new Point(NaN,NaN),this.lt=1,this.s0=1,this.Ax=new Point(NaN,NaN).w(),this.Lx=NaN,this.Tx=1e-4,this.Dx=100,this.O=new Transform,this.Fx=new Point(NaN,NaN).w(),this.Rx=new Rect(NaN,NaN,NaN,NaN).w(),this.zf=new Margin(0,0,0,0).w(),this.vh=1,this.Ix=!1,this.Ox=null,this.Ex=null,this.Jl=1,this.Xf=Spot.Default,this.Fr=1,this.jm=Spot.Default,this.Vx=Spot.None,this.Bx=Spot.None,this.Ge=!0,this.Yu=!1,this.Qn=new Set,this.Rr=new GSet,this.$h=new GSet,this.Vo=!1,this.th=new GMap,this.Wu=!0,this.Wm=250,this.Yf=-1,this.vm=new Margin(16,16,16,16).w(),this.Ar=!1,this.Kf=!1,this.Ku=!0,this.e0=new InputEvent,this.e0.diagram=this,this.jr=new InputEvent,this.jr.diagram=this,this._h=new InputEvent,this._h.diagram=this,this.Ir=null,this._n=null,this.qw=!1,this.jF(),this.vr=new GSet,this.zx=!0,this.Xx=1,this.ZM=!1,this.Yx=1,this.Kx="auto",this.Jm="auto",this.Or=null,this.Er=null,this.Vr=null,this.Br=null,this.zr=null,this.Xr=null,this.Ux=null,this.Yr=null,this.Gx=!1,this.Kr=null,this.Ur=null,this.Gr=null,this.Hr=null,this.Hx=!1,this.d1={},this.ea=[null,null],this.Bo=!1,this.iP=!1,this.qx=!1,this.jx=!1,this.eP=!0,this.ks=!1,this.ia=!1,this.oP=!0,this.zs=-2,this._l=new GMap,this.vu=new List,this.zo=!1,this.Xi=!0,this.Wx=!0,this.Vl=!0,this.Bl=!0,this.vx=!1,this.Jx=!0,this.zl=!0,this.Xl=!0,this.Yl=!0,this.Zx=!0,this.Kl=!0,this.Ul=!0,this.Gl=!0,this.Hl=!0,this.ql=!0,this.jl=!0,this.Wl=!0,this.$x=!0,this.Qx=!0,this.rP=!1,this.qf=!1,this.Uu=!0,this.Gu=!0,this._x=!0,this.t1=!0,this.i1=16,this.e1=16,this.Zm=!1,this.s1=!1,this.o1=0,this.l1=0,this.ii=new Margin(5).w(),this.lP=new GSet().w(),this.h1=999999999,this.hP=new GSet().w(),this.ta=!0,this.Hu=!0,this.Gf=!0,this.xn=!1,this.to=!1,this.Wr=!0,this.Pl=!1,this.io=!1,this.dA=new GSet,this.mP=new GSet,this.Zl=null,this.aP=new Size(8,8),this.fP=999,this.$m=!1,this.eS=1,this.sS=0,this.Ui={scale:1,position:new Point,bounds:new Rect,canvasSize:new Size,newCanvasSize:new Size,isScroll:!1},this.Ui.canvasSize=this.Ui.canvasSize,this.Ui.newCanvasSize=this.Ui.newCanvasSize,this.Ui.isScroll=!1,this.a1=new Rect(NaN,NaN,NaN,NaN).w(),this.qu=new Size(NaN,NaN).w(),this.Qm=new Rect(NaN,NaN,NaN,NaN).w(),this.f1=!1,this.WF(),this.os=null,this.t0=!1,this.wf=null,this.partManager=new PartManager,this.toolManager=new ToolManager,this.toolManager.initializeStandardTools(),this.defaultTool=this.toolManager,this.currentTool=this.defaultTool,this.S1=null,this.M1=new DraggingOptions,this.P1=null,this.N1=null,this.k1=!1,this.Pu=!1,this.commandHandler=new CommandHandler,this.a0=null,this.f0=Point.Vk,this.kP=!1,this.Gi=1,this.Cl=null,this.Gm=1,this.l0=0,this.bP=[0,0,0,0,0],this.h0=0,this.o0=1,this.pP=0,this.yP=new Point,this.gA=500,this.i0=new Point,this.r0=!1}static bA=root.document!==void 0;static isUsingDOM(){return Diagram.bA}static useDOM(t){Diagram.bA=t?root.document!==void 0:!1}static He=new WeakMap;clear(){this.animationManager.stopAnimation(),this.model.clear(),Diagram.kA(),this.SA(!1),this.vu.clear(),this.MA(),this.Zl=null,this.invalidateDocumentBounds(),this.ensureBounds(),this.T()}SA(t){this.animationManager.stopAnimation(!0),this.lP=new GSet().w(),this.hP=new GSet().w();const i=this.skipsUndoManager,e=this.Ai!==null&&this.Ai!==void 0;e&&(this.skipsUndoManager=!0);let s=null;this.os!==null&&(s=this.os.part,s!==null&&this.remove(s));const n=[],o=this.Jt.length;if(t){for(let r=0;rt?new Margin(t/2):1.5)),this.c1=this._m,this.u1=new Adornment(Panel.Link).add(new Shape({isPanelMain:!0,fill:null,stroke:"dodgerblue",strokeWidth:3}).theme("stroke","selection").theme("strokeWidth","selection"))}setRTL(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);const e=Util.ln("div");e.dir="rtl",e.style.cssText="font-size: 14px; width: 1px; height: 1px; position: absolute; top: -1000px; overflow: scroll;",e.textContent="A",i.appendChild(e);let s="reverse";e.scrollLeft>0?s="default":(e.scrollLeft=1,e.scrollLeft===0&&(s="negative")),i.removeChild(e),this.Cx=s}setScrollWidth(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);let e=0;if(Diagram.isUsingDOM()){let s=Diagram.xP,n=Diagram.wP;s===null&&(Diagram.xP=Util.ln("p"),s=Diagram.xP,s.style.width="100%",s.style.height="200px",s.style.boxSizing="content-box",Diagram.wP=Util.ln("div"),n=Diagram.wP,n.style.position="absolute",n.style.visibility="hidden",n.style.width="200px",n.style.height="150px",n.style.boxSizing="content-box",n.appendChild(s)),n.style.overflow="hidden",i.appendChild(n);const o=s.offsetWidth;n.style.overflow="scroll";let r=s.offsetWidth;o===r&&(r=n.clientWidth),i.removeChild(n),e=o-r,e===0&&!Util.cr&&(e=11)}this.yi=e,this.WM=!0}fi(t){t in AutoScale?this.autoScale=t:Util.ur(this,t)}toString(t){t===void 0&&(t=0);let i="";this.div&&this.div.id&&(i=this.div.id);let e='Diagram "'+i+'"';if(t<=0)return e;const s=this.Jt.iterator;for(;s.next();){const n=s.value;e+=` - `+n.toString(t-1)}return e}static yA(t){Diagram.b1=t}static Mm(){return Diagram.b1}static fromDiv(t){let i=t;if(typeof t=="string"&&(i=root.document.getElementById(t)),i instanceof HTMLDivElement){const e=Diagram.He.get(i);if(e)return e}return null}get div(){return this.Ot}set div(t){if(t!==null&&Util.s(t,HTMLDivElement,Diagram,"div"),this.Ot!==t){const i=this.Ot;if(i!==null){if(Diagram.He.delete(i),i.goDiagram=void 0,i.go=void 0,i.innerHTML="",this.xt!==null){const s=this.xt.Bt;this.Li(s,"pointermove",this.na,!1),this.Li(s,"pointerdown",this.ih,!1),this.Li(s,"pointerup",this.oa,!1),this.Li(s,"pointerout",this.ra,!1),this.Li(s,"pointercancel",this.la,!1),this.xt.dispose()}this.Hf&&(this.Hf.disconnect(),this.Hf=null);const e=this.toolManager;e!==null&&(e.mouseDownTools.each(s=>s.cancelWaitAfter()),e.mouseMoveTools.each(s=>s.cancelWaitAfter()),e.mouseUpTools.each(s=>s.cancelWaitAfter())),e.cancelWaitAfter(),this.currentTool.doCancel(),this.xt=null,this.Li(root,"resize",this.w1,!1),this.Li(root,"wheel",this.sa,!0),Diagram.Mm()===this&&Diagram.yA(null)}else this.ih===null&&(this.io=!1);if(this.Ot=null,t!==null){const e=Diagram.He.get(t);e&&(e.div=null),this.MP(t),this.Nu(),this.themeManager&&this.themeManager.vF()}else this.themeManager&&this.themeManager.JF()}}setupRouters(){this.Wf.push(new AvoidsNodesRouter)}MP(t){const i=this;if(!Diagram.isUsingDOM())return;t==null&&Util.n("Diagram setup requires an argument DIV."),i.Ot!==null&&Util.n("Diagram has already completed setup."),typeof t=="string"?i.Ot=root.document.getElementById(t):t instanceof HTMLDivElement?i.Ot=t:Util.n("No DIV or DIV id supplied: "+t),i.Ot===null&&Util.n("Invalid DIV id; could not get element with id: "+t);const e=Diagram.He.get(i.Ot);if(e&&e!==this&&Util.n("Invalid div id; div already has a Diagram associated with it."),!i.Hf&&root.ResizeObserver){const f=root.ResizeObserver,c=Util.Ik(()=>i.requestUpdate(),250,!1);i.Hf=new f(()=>c()),i.Hf.observe(i.Ot)}root.getComputedStyle(i.Ot,null).position==="static"&&(i.Ot.style.position="relative");let s=5;const n="rgba(2"+s+"5, 255, 255, 0)";s--,i.Ot.style["-webkit-tap-highlight-color"]=n,i.Ot.innerHTML="",Diagram.He.set(i.Ot,i),i.Ot.goDiagram=i,i.Ot.go=root.go;const o=new CanvasSurface(i);o.style!==void 0&&(o.style.position="absolute",o.style.top="0px",o.style.left="0px",root.getComputedStyle(i.Ot,null).getPropertyValue("direction")==="rtl"&&(i.Ju=!0),o.style.zIndex="2",o.style.userSelect="none",o.style.MozUserSelect="none",o.style.touchAction="none",o.style.letterSpacing="normal !important",o.style.wordSpacing="normal !important",o.style.lang="unknown"),i.xt=o,i.ei=o.di;const r=i.ei;i.Gi=i.computePixelRatio(),i.viewSize.isReal()||(i.Ct=i.Ot.clientWidth||1,i.At=i.Ot.clientHeight||1),i.PA(i.Ct,i.At);const l=i;i.Ot.insertBefore(o.Bt,i.Ot.firstChild);const h=new CanvasSurface(null);if(h.width=1,h.height=1,i.BF=h,i.zF=h.di,Diagram.isUsingDOM()){const f=Util.ln("div"),c=Util.ln("div");f.style.position="absolute",f.style.overflow="auto",f.style.width=i.Ct+"px",f.style.height=i.At+"px",f.style.zIndex="1",c.style.position="absolute",c.style.width="1px",c.style.height="1px",i.Ot.appendChild(f),f.appendChild(c),f.onscroll=Diagram.ZF,f.addEventListener("pointerdown",Diagram.$F),f.b=i,f.QF=!0,f._F=!0,i.g1=f,i.m1=c}i.Nu=Util.Ik(()=>{i.Cl=null,i.T()},300,!1),i.w1=Util.Ik(()=>{i.RM()},250,!1),i.jh=f=>(f.preventDefault(),!1),i.sa=f=>{if(!l.isEnabled)return;const c=l.vf(f,!0);c.bubbles=!0;let u=0,d=0;c.delta=0,f.deltaX!==void 0?(f.deltaX!==0&&(u=f.deltaX>0?1:-1),f.deltaY!==0&&(d=f.deltaY>0?1:-1),c.delta=Math.abs(f.deltaX)>Math.abs(f.deltaY)?-u:-d):f.wheelDeltaX!==void 0?(f.wheelDeltaX!==0&&(u=f.wheelDeltaX>0?-1:1),f.wheelDeltaY!==0&&(d=f.wheelDeltaY>0?-1:1),c.delta=Math.abs(f.wheelDeltaX)>Math.abs(f.wheelDeltaY)?-u:-d):f.wheelDelta!==void 0&&f.wheelDelta!==0&&(c.delta=f.wheelDelta>0?1:-1),l.doMouseWheel(),l.ha(c,f)},i.mA=f=>{if(!l.isEnabled)return;i.qf=!1,l.vf(f,!0);const c=l.currentTool;c.cancelWaitAfter(),c.standardMouseOver()},i.ih=f=>{if(!l.isEnabled)return;i.qf=!0;const c=l.d1;c[f.pointerId]===void 0&&(c[f.pointerId]=f);const u=l.ea;let d=!1;if(u[0]!==null&&(u[0].pointerId===f.pointerId||u[0].pointerType!==f.pointerType))u[0]=f;else if(u[1]!==null&&u[1].pointerId===f.pointerId)u[1]=f,d=!0;else if(u[0]===null)u[0]=f;else if(u[1]===null)u[1]=f,d=!0;else{f.preventDefault();return}const m=f.pointerType==="touch"||f.pointerType==="pen";m&&(l.qw=!1,l.r0=!0);const g=l.tR(f,f,d),p=l.yP,y=m?25:10;if(f.timeStamp-l.pPy||Math.abs(p.y-f.screenY)>y)?l.o0++:l.o0=1,g.clickCount=l.o0,l.pP=f.timeStamp,l.yP.setTo(f.screenX,f.screenY),l.doMouseDown(),f.button===1){f.preventDefault();return}l.ha(g,f)},i.na=f=>{if(!l.isEnabled)return;i.qf=!0;const c=l.ea;if(c[0]!==null&&(c[0].pointerId===f.pointerId||c[0].pointerType!==f.pointerType))c[0]=f;else if(c[1]!==null&&c[1].pointerId===f.pointerId){c[1]=f;return}else if(c[0]===null)c[0]=f;else return;if(c[0].pointerId!==f.pointerId)return;const u=l.iR(f,f,c[1]!==null);l.doMouseMove(),l.ha(u,f)},i.oa=f=>{if(!l.isEnabled)return;i.qf=!0;const c=f.pointerType==="touch"||f.pointerType==="pen",u=l.d1;if(c&&l.qw){delete u[f.pointerId],f.preventDefault();return}const d=l.ea;if(d[0]!==null&&(d[0].pointerId===f.pointerId||d[0].pointerType!==f.pointerType))d[0]=null;else if(d[1]!==null&&d[1].pointerId===f.pointerId){d[1]=null;return}else return;const m=l.PP(f,!1,!0,!1,!0,!1);let g=root.document.elementFromPoint(f.clientX,f.clientY)||null;g!==null&&g.shadowRoot!==void 0&&g.shadowRoot!==null&&(g=g.shadowRoot.elementFromPoint(f.clientX,f.clientY)),g!==null&&g.b instanceof Diagram&&g.b!==l&&g.b.u0(f,m),g===null&&(g=f.target),l.u0(f,m),m.clickCount=l.o0,m.targetDiagram=l.NP(f,g),m.targetObject=null,l.doMouseUp(),l.ha(m,f),c&&(l.r0=!1)},i.ra=f=>{if(!l.isEnabled)return;i.qf=!1;const c=l.d1;c[f.pointerId]&&delete c[f.pointerId];const u=l.ea;if(u[0]!==null&&u[0].pointerId===f.pointerId&&(u[0]=null),u[1]!==null&&u[1].pointerId===f.pointerId&&(u[1]=null),f.pointerType==="touch"||f.pointerType==="pen")return;const d=l.currentTool;d.cancelWaitAfter(),d.standardMouseOver()},i.la=f=>{const c=l.ea;c[0]!==null&&c[0].pointerId===f.pointerId?(c[0]=null,l.r0=!1):c[1]!==null&&c[1].pointerId===f.pointerId&&(c[1]=null)};const a=r;if(i.p1=a.Y[Util.Fs("7eba17a4ca3b1a8346")][Util.Fs("78a118b7")](a.Y,Diagram.Zu,s,s),r.clearContextCache(!0),i.eR(),this.Uf==="svg"){const f=this.Ql.get("svg");this.Ot.appendChild(f.Bt),this.ei=f.di}}addEventListener(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}Ht(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}removeEventListener(t,i,e,s){t.removeEventListener(i,e,{capture:s})}Li(t,i,e,s){t.removeEventListener(i,e,{capture:s})}eR(){const t=this;let i=this.xt.Bt;i instanceof HTMLCanvasElement||(i=t.div),this.Ht(i,"pointerdown",t.ih,!1),this.Ht(i,"pointermove",t.na,!1),this.Ht(i,"pointerup",t.oa,!1),this.Ht(i,"pointerout",t.ra,!1),this.Ht(i,"pointercancel",t.la,!1),this.Ht(i,"pointerenter",t.sR,!1),this.Ht(i,"pointerleave",t.nR,!1),this.Ht(i,"wheel",t.sa,!1),this.Ht(i,"keydown",t.oR,!1),this.Ht(i,"keyup",t.rR,!1),this.Ht(i,"blur",t.lR,!1),this.Ht(i,"focus",t.hR,!1),this.Ht(i,"selectstart",e=>(e.preventDefault(),!1),!1),this.Ht(i,"contextmenu",e=>(e.preventDefault(),!1),!1),this.Ht(root,"resize",t.w1,!1)}jw(){this.l0>30&&(this.Cl=1)}NS(t){this.Cl!==null&&(this.Cl=null,t&&this.Nu(),Debug&&Debug.drawFrames||(this.l0=0,this.bP=[0,0,0,0,0],this.h0=0))}computePixelRatio(){return this.Cl!==null?this.Cl:root.devicePixelRatio||1}get avgSpf(){return this.l0}doMouseDown(){this.currentTool.doMouseDown()}doMouseMove(){this.currentTool.doMouseMove()}doMouseUp(){this.currentTool.doMouseUp()}doMouseWheel(){this.currentTool.doMouseWheel()}doKeyDown(){this.currentTool.doKeyDown()}doKeyUp(){this.currentTool.doKeyUp()}doFocus(){this.focus()}focus(){if(this.xt)if(this.scrollsPageOnFocus)this.xt.focus();else{const t=root.scrollX,i=root.scrollY;this.xt.focus(),root.scrollTo(t,i)}}hR(t){const i=Diagram.He.get(this);i&&i.V("GainedFocus")}lR(t){const i=Diagram.He.get(this);i&&i.V("LostFocus")}RM(){if(this.xt===null)return;const i=this.Ot;if(i===null||i.clientWidth===0||i.clientHeight===0)return;this.WM||this.setScrollWidth();const e=this.to?this.yi:0,s=this.xn?this.yi:0,n=this.Gi;if(this.Gi=this.computePixelRatio(),this.Gi!==n&&(this.Yu=!0,this.requestUpdate()),i.clientWidth!==this.Ct+e||i.clientHeight!==this.At+s){this.aa(),this.Ge=!0;const o=this.layout;o!==null&&o.isViewportSized&&this.autoScale===1&&(this.Kf=!0,o.invalidateLayout()),this.ks||this.requestUpdate()}}xA(){let t=0,i=new Layer;i.name="Grid",i.allowSelect=!1,i.pickable=!1,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="ViewportBackground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="Background",this.Jr(i,t++),i=new Layer,i.name="",this.Jr(i,t++),i=new Layer,i.name="Foreground",this.Jr(i,t++),i=new Layer,i.name="ViewportForeground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="Adornment",i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="Tool",i.isTemporary=!0,i.isInDocumentBounds=!0,this.Jr(i,t++)}NA(){const t=new Panel(Panel.Grid,{name:"GRID"}).add(new Shape("LineH",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineV",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineH",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineH",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor")),i=new Part({layerName:"Grid",zOrder:0,isInDocumentBounds:!1,isAnimated:!1,pickable:!1,locationObjectName:"GRID"}).add(t);return this.add(i),this.partManager.parts.delete(i),t.visible=!1,t}static ZF(){const t=Diagram.He.get(this.parentElement||this);if(t){if(t.s1){t.s1=!1;return}if(!t.isEnabled){t.CA();return}t.diagramScroll(this)}}static $F(t){if(!this.b.isEnabled){this.b.updateScroll();return}this.b.o1=t.target.scrollTop,this.b.l1=t.target.scrollLeft}diagramScroll(t){if(this.xt===null)return;const i=this.g1,e=this.m1;this.Zm=!0;let s=this.documentBounds,n=this.viewportBounds;const o=this.zf;let r=s.x-o.left,l=s.y-o.top;const h=s.width+o.left+o.right,a=s.height+o.top+o.bottom;let f=s.right+o.right,c=s.bottom+o.bottom,u=n.x,d=n.y;const m=n.width,g=n.height;let p=n.right,y=n.bottom;const x=this.scale;let k,b=t.scrollLeft;if(this.Ju)switch(this.Cx){case"negative":b=b+t.scrollWidth-t.clientWidth;break;case"reverse":b=t.scrollWidth-b-t.clientWidth;break}const S=b;if(mp)){const M=i.scrollWidth-this.Ct;this.position=k.e(-M+S-this.Ct/x+f,this.position.y)}if(t._F&&this.allowVerticalScroll&&(ly)){const M=i.scrollHeight-this.At;this.position=k.e(this.position.x,-M+t.scrollTop-this.At/x+c)}Point.o(k),this.sh(),this.Zm=!1,this.Hu=!1,s=this.documentBounds,n=this.viewportBounds,f=s.right,p=n.right,c=s.bottom,y=n.bottom,r=s.x,u=n.x,l=s.y,d=n.y,m>=h&&r>=u&&f<=p&&(e.style.width="1px"),g>=a&&l>=d&&c<=y&&(e.style.height="1px")}computeBounds(t){return t===void 0&&(t=new Rect),this.Di(),this.AA(t)}AA(t){if(this.fixedBounds.isReal())return t.c(this.fixedBounds),t.addMargin(this.ii),t;let i=!0;const e=this.Jt.h,s=e.length;for(let n=0;ni&&(a=i),athis.maxScale&&(a=this.maxScale),a):t===3?(a=0,h>l?a=(r-this.yi)/n:a=(o-this.yi)/s,a>i&&(a=i),athis.maxScale&&(a=this.maxScale),a):this.scale}zoomToFit(){const t=this.vh;this.vh=1,this.scale=this.$u(2),t!==1&&(this.Gs(!1),this.CP(this.documentBounds,this.Ct/this.lt,this.At/this.lt,this.Xf,!1)),this.vh=t}zoomToRect(t,i){i===void 0&&(i=2);const e=t.width,s=t.height;if(e===0||s===0||isNaN(e)&&isNaN(s))return;let n=1;if(i===2||i===3)if(isNaN(e))n=this.viewportBounds.height*this.scale/s;else if(isNaN(s))n=this.viewportBounds.width*this.scale/e;else{const o=this.Ct,r=this.At;i===3?r/s>o/e?n=(r-(this.xn?this.yi:0))/s:n=(o-(this.to?this.yi:0))/e:n=Math.min(r/s,o/e)}this.scale=n,this.position=new Point(t.x,t.y)}get aR(){return this.$t}set aR(t){this.$t=t}alignDocument(t,i){this.ensureBounds();const e=this.documentBounds,s=this.viewportBounds;this.position=new Point(e.x+(t.x*e.width+t.offsetX)-(i.x*s.width-i.offsetX),e.y+(t.y*e.height+t.offsetY)-(i.y*s.height-i.offsetY))}focusObject(t){if(t instanceof GraphObject){this.a0=t;const i=Point.a();this.f0=this.transformDocToView(t.getDocumentPoint(Spot.TopLeft,i)),Point.o(i)}else this.a0=null,this.f0=Point.Vk}CP(t,i,e,s,n){const o=Point.H(this.mt.x,this.mt.y);let r=o.x,l=o.y;if(this.a0!==null){let h=Point.a();h=this.a0.getDocumentPoint(Spot.TopLeft,h),r=h.x-this.f0.x/this.scale,l=h.y-this.f0.y/this.scale,s=Spot.None,Point.o(h)}if(n||this.scrollMode===1){s.isSpot()&&(i>t.width&&(r=t.x+(s.x*t.width+s.offsetX)-(s.x*i-s.offsetX)),e>t.height&&(l=t.y+(s.y*t.height+s.offsetY)-(s.y*e-s.offsetY)));const h=this.zf,a=i-t.width;if(it.left?r=t.left:rt.top?l=t.top:ls.part,s=>s.canSelect());if(e instanceof Part)return e}else{const e=this.DS(t,s=>s.part);if(e instanceof Part)return e}return null}findObjectAt(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Di();const s=this.Jt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}DS(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Di();const s=this.Jt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible||n.isTemporary)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}findPartsAt(t,i,e){return i===void 0&&(i=!0),this.cR(t,s=>s.part,i?s=>s instanceof Part&&s.canSelect():null,e)}cR(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Di();const n=this.Jt.iteratorBackwards;for(;n.next();){const o=n.value;!o.visible||o.isTemporary||o.findObjectsAt(t,i,e,s)}return s}findObjectsAt(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Di();const n=this.Jt.iteratorBackwards;for(;n.next();){const o=n.value;o.visible&&o.findObjectsAt(t,i,e,s)}return s}findPartsIn(t,i,e,s){return i===void 0&&(i=!1),e===void 0&&(e=!0),this.uR(t,null,n=>n instanceof Part&&(!e||n.canSelect()),i,s)}findObjectsIn(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Di();const o=this.Jt.iteratorBackwards;for(;o.next();){const r=o.value;r.visible&&r.findObjectsIn(t,i,e,s,n)}return n}IS(t,i,e,s,n,o){const r=new GSet;this.Di();const l=this.Jt.iteratorBackwards;for(;l.next();){const h=l.value;h.visible&&h.IS(t,i,e,s,r,n,o)}return r}uR(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Di();const o=this.Jt.iteratorBackwards;for(;o.next();){const r=o.value;!r.visible||r.isTemporary||r.findObjectsIn(t,i,e,s,n)}return n}findPartsNear(t,i,e,s,n){return e===void 0&&(e=!0),s===void 0&&(s=!0),this.dR(t,i,null,o=>o instanceof Part&&(!s||o.canSelect()),e,n)}findObjectsNear(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Di();const r=this.Jt.iteratorBackwards;for(;r.next();){const l=r.value;l.visible&&l.findObjectsNear(t,i,e,s,n,o)}return o}dR(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Di();const r=this.Jt.iteratorBackwards;for(;r.next();){const l=r.value;!l.visible||l.isTemporary||l.findObjectsNear(t,i,e,s,n,o)}return o}acceptEvent(t){return this.vf(t,t instanceof MouseEvent)}vf(t,i){const e=this.jr;this.jr=this._h,this._h=e,e.diagram=this,e.event=t,i?this.u0(t,e):(e.viewPoint=this.jr.viewPoint,e.documentPoint=this.jr.documentPoint);let s=0;const n=t;return n.ctrlKey&&(s+=1),n.altKey&&(s+=2),n.shiftKey&&(s+=4),n.metaKey&&(s+=8),e.modifiers=s,e.button=n.button,n.buttons!==void 0&&(e.buttons=n.buttons),Util.cr&&n.button===0&&n.ctrlKey&&(e.button=2),e.down=!1,e.up=!1,e.clickCount=1,e.delta=0,e.handled=!1,e.bubbles=!1,e.timestamp=t.timeStamp,e.isMultiTouch=!1,e.targetDiagram=this.NP(t,t.target),e.targetObject=null,e}NP(t,i){if(i===null)return null;const e=Diagram.He.get(i);if(e)return e;let s=t.path;if(!s&&typeof t.composedPath=="function"&&(s=t.composedPath()),s&&s[0]){const n=Diagram.He.get(s[0]);if(n)return n}return null}tR(t,i,e){const s=this.PP(t,!0,!1,!1,!0,e);return this.u0(i,s),s.targetDiagram=this.NP(t,t.target),s.targetObject=null,e||s.clone(this.e0),s}iR(t,i,e){const s=this.PP(t,!1,!1,!1,!1,e);let n=root.document.elementFromPoint(i.clientX,i.clientY)||null;n!==null&&n.shadowRoot!==void 0&&n.shadowRoot!==null&&(n=n.shadowRoot.elementFromPoint(i.clientX,i.clientY));let o=this,r=t;if(n){const l=Diagram.He.get(n);l&&(r=i,o=l)}return s.targetDiagram=o,this.u0(r,s),s.targetObject=null,s}PP(t,i,e,s,n,o){const r=this.jr;this.jr=this._h,this._h=r,r.diagram=this,r.clickCount=1,r.delta=0;let l=0;return t.ctrlKey&&(l+=1),t.altKey&&(l+=2),t.shiftKey&&(l+=4),t.metaKey&&(l+=8),r.modifiers=l,r.event=t,r.timestamp=t.timeStamp,r.button=e?this.firstInput.button:t.button,r.buttons=t.buttons,Util.cr&&t.button===0&&t.ctrlKey&&(r.button=2),r.down=i,r.up=e,r.handled=s,r.bubbles=n,r.isMultiTouch=o,r}ha(t,i){return t.bubbles?(Debug&&Debug.handleMessages&&Util.at("NOT handled "+i.type+" "+t.toString()),!0):(Debug&&Debug.handleMessages&&Util.at("handled "+i.type+" "+this.currentTool.name+" "+t.toString()),i.stopPropagation!==void 0&&i.stopPropagation(),i.cancelable!==!1&&i.preventDefault(),i.cancelBubble=!0,!1)}oR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.vf(t,!1);return e.key=t.key,e.code=t.code,e.down=!0,i.doKeyDown(),i.ha(e,t)}rR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.vf(t,!1);return e.key=t.key,e.code=t.code,e.up=!0,i.doKeyUp(),i.ha(e,t)}sR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.vf(t,!0);return i.mouseEnter!==null&&i.mouseEnter(e),i.currentTool.standardMouseOver(),i.ha(e,t)}nR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.vf(t,!0);return i.mouseLeave!==null&&i.mouseLeave(e),i.ha(e,t)}getMouse(t){const i=this.xt;if(i===null)return new Point(0,0);const e=i.getBoundingClientRect(),s=(t.clientX-e.left)*(this.Ct/e.width),n=(t.clientY-e.top)*(this.At/e.height);return new Point(s,n).Ye(this.O)}u0(t,i){const e=this.xt;let s=0,n=0;if(e!==null){const r=e.getBoundingClientRect();s=(t.clientX-r.left)*(this.Ct/r.width),n=(t.clientY-r.top)*(this.At/r.height)}i.viewPoint.e(s,n);const o=Point.H(s,n);this.O.ns(o),i.documentPoint.c(o),Point.o(o)}DC(t,i,e){let s;if(this.ea[0]!==null)s=this.ea[i];else return;const n=this.xt;if(n!==null){const o=n.getBoundingClientRect();e.e((s.clientX-o.left)*(this.Ct/o.width),(s.clientY-o.top)*(this.At/o.height))}}invalidateDocumentBounds(){this.ta||(this.ta=!0,this.requestUpdate(!1))}gR(){this.ks||this.Di(),this.ensureBounds()}redraw(){this.$t||this.ks||(this.T(),this.maybeUpdate())}isUpdateRequested(){return this.Ar}delayInitialization(t){t===void 0&&(t=null);const i=this.animationManager,e=i.isEnabled;i.stopAnimation(),i.isEnabled=!1,this.Sr(),this.io=!1,this.fx=new Point(NaN,NaN),i.isEnabled=e,this.ks=!0;const s=this;t!==null&&Util.Bh(()=>{s.ks=!1,i.El("Model"),t(s)},1)}requestUpdate(t){if(t===void 0&&(t=!1),this.Ar===!0||this.$t||t===!1&&this.ks)return;this.Ar=!0;const i=this;root.requestAnimationFrame(()=>{i.Ar&&i.maybeUpdate()})}maybeUpdate(){this.Ku&&!this.Ar||(this.Ku&&(this.Ku=!1),this.Sr())}AP(t,i){!this.Hu||this.$t||this.animationManager.defaultAnimation.isAnimating||this.CA()||(t&&this.Di(),i&&this.Gs(!1))}Sr(t){if(this.ks||(this.Ar=!1,this.Ot===null&&!this.qu.isReal()))return;this.ks=!0;const i=this.animationManager,e=this.vu;if(!i.isAnimating&&e.length!==0){const f=e.h,c=f.length;for(let u=0;u0&&(s.each(f=>f.LP()),s.clear());let n=!1,o=!1;i.defaultAnimation.isAnimating&&(o=!0,n=this.skipsUndoManager,this.skipsUndoManager=!0),i.Si||this.RM(),t||this.AP(!1,!0);const r=!this.undoManager.isUndoingRedoing&&(this.Pl||this.Wf.count!==0&&this.Rr.size!==0),l=!this.io||this.Wr;this.Di(!0);let h=!1;(l||r)&&(this.io?this.TP(!this.Kf,r):(this.startTransaction("Initial Layout"),i.isEnabled===!1&&i.stopAnimation(),this.TP(!1,r)),h=l),this.Kf=!1,this.Pl=!1,this.Di(),this.os!==null&&(this.os.visible&&!this.t0&&(this.Zr(),this.t0=!0),!this.os.visible&&this.t0&&(this.t0=!1)),this.qx||this.gR(),t||this.AP(!0,!1);let a=!1;if(h){const f=Rect.a();f.c(this.viewportBounds),this.io||(this.io=!0,a=!0,this.skipsUndoManager||(this.undoManager.Uw=!0),this.undoManager.Gw=!0,this.mR()),this.pR(),this.Di(!1),t||this.AP(!0,!0),Rect.o(f)}else if(i.Df&&i.ax){if(this.Fr!==1)this.scale=this.$u(this.Fr);else if(this.Jl!==1)this.scale=this.$u(this.Jl);else{const f=this.initialScale;isFinite(f)&&f>0&&(this.scale=f)}this.Gs(!0)}h&&a&&this.commitTransaction("Initial Layout"),t||this.Ji(this.ei),o&&(this.skipsUndoManager=n),this.ks=!1}get Yh(){return this.io}mR(){if(this.Fr!==1)this.scale=this.$u(this.Fr);else if(this.Jl!==1)this.scale=this.$u(this.Jl);else{const i=this.initialScale;isFinite(i)&&i>0&&(this.scale=i)}this.Gs(!0);const t=this.Jt.h;this.Us(t,t.length,this,this.viewportBounds),this.V("InitialLayoutCompleted"),this.fx.c(this.mt),this.Zr()}pR(){this.V("LayoutCompleted")}d0(t){this.Qn.add(t)}addInvalidRoute(t){this.Vo?this.$h.add(t):this.Rr.add(t)}Di(t){if(this.Qn.size!==0&&!(!this.ks&&this.animationManager.isTicking)){if(this.ks||(this.Pl=!0),t){this.LA(this.Qn);return}for(let i=0;i<23&&this.Qn.size!==0;i++){const e=new Set(this.Qn);this.Qn.clear(),this.LP(e,this.Qn),Debug&&i===22&&Util.at("failure to validate parts")}this.nodes.each(i=>{i instanceof Group&&i.TA(!1)})}}LA(t,i){for(const e of t)!e.Ae()||e instanceof Group||(e.$r()?(e.wt(1/0,1/0),e.qt()):i&&i.add(e));for(const e of t)if(e instanceof Group){if(!e.isVisible())continue;this.T1(e)}}LP(t,i){this.LA(t,i);for(const e of t){if(!(e instanceof Link))continue;const s=e;s.isVisible()&&(s.$r()?(s.wt(1/0,1/0),s.qt()):i.add(s))}for(const e of t)e instanceof Adornment&&e.isVisible()&&(e.$r()?(e.wt(1/0,1/0),e.qt()):i.add(e))}g0(t){const i=t instanceof Diagram,e=i?t.links:t.memberParts,s=this.Qn;if(i)this.Di(!0);else{for(;e.next();){const n=e.value;s.has(n)&&(!n.Ae()||n instanceof Group||n.$r()&&(n.wt(1/0,1/0),n.qt()))}for(e.reset();e.next();){const n=e.value;if(s.has(n)&&n instanceof Group){if(!n.isVisible())continue;this.T1(n)}}e.reset()}for(;e.next();){const n=e.value;n instanceof Link&&s.has(n)&&n.isVisible()&&n.$r()&&(n.wt(1/0,1/0),n.qt())}}T1(t){const i=Util.ft(),e=Util.ft(),s=t.memberParts;for(;s.next();){const o=s.value;o.isVisible()&&(o instanceof Group?(o.Xo()||o.rs()||o.nh())&&this.T1(o):o instanceof Link?o.fromNode===t||o.toNode===t?e.push(o):i.push(o):(o.wt(1/0,1/0),o.qt()))}let n=i.length;for(let o=0;ob.zu())}else for(let x=0;x0){const a=n.substring(0,h);e?o=t.findObject(a):(o=t[a],o==null&&(o=t.toolManager[a])),Util.Mt(o)?r=n.substring(h+1):Util.n("Unable to find object named: "+a+" in "+t.toString()+" when trying to set property: "+n)}}if(r[0]!=="_"&&!Util.yw(o,r))if(s&&r==="ModelChanged"){t.addModelChangedListener(i[r]);continue}else if(s&&r==="Changed"){t.addChangedListener(i[r]);continue}else if(s&&Util.yw(t.toolManager,r))o=t.toolManager;else if(s&&t.DA(r)){t.addDiagramListener(r,i[r]);continue}else if(t instanceof Model&&r==="Changed"){t.addChangedListener(i[r]);continue}else Util.n('Trying to set undefined property "'+r+'" on object: '+o.toString());const l=i[n];o[r]=l,r[0]==="_"&&o instanceof GraphObject&&o.addCopyProperty(r)}}xR(){if(this.th.count!==0&&!(this.undoManager.transactionLevel>1)){for(;this.th.count>0;){const t=this.th;this.th=new GMap;const i=t.iterator;for(;i.next();){const e=i.key;e.invalidateOtherJumpOvers(i.value),e.re()}}this.T()}}T(t){if(t===void 0)this.Ge=!0,this.requestUpdate();else{const i=this.viewportBounds;t.isReal()&&i.intersectsRect(t)&&(this.Ge=!0,this.requestUpdate())}this.V("InvalidateDraw")}invalidateViewport(t,i){if(this.Ge===!0)return;if(this.Ge=!0,this.Uf==="svg"){this.maybeUpdate();return}this.getRenderingHint("temporaryPixelRatio")===!0?(this.jw(),this.maybeUpdate(),this.NS(!0)):this.maybeUpdate()}aa(){this.Hu=!0}sh(){this.Gf=!0}m0(){this.Yu!==!1&&(this.Yu=!1,this.PA(this.Ct,this.At))}PA(t,i){this.eh();const e=this.Gi,s=t*e,n=i*e;this.xt.resize(s,n,t,i)&&(this.Ge=!0,this.ei.clearContextCache(!0))}CA(){const t=this.xt;if(t===null||this.qu.isReal())return!0;const i=this.Ct,e=this.At,s=this.Ot;let n=!1,o=this.to?this.yi:0,r=this.xn?this.yi:0,l=s.clientWidth||i+o,h=s.clientHeight||e+r;const a=this.viewportBounds,f=a.x,c=a.y,u=a.width,d=a.height;if((l!==i+o||h!==e+r)&&(this.to=!1,this.xn=!1,o=0,r=0,this.Ct=l,this.At=h,this.Yu=!0,n=!0,this.eh()),!this.io||!this.viewportBounds.isReal())return!0;const m=this.g1,g=this.m1;if(this.Hu=!1,!n&&!this.to&&!this.xn&&!this.Uu&&!this.Gu)return!0;const p=this.documentBounds;let y=0,x=0,k=0,b=0;const S=a.width,M=a.height,A=this.zf;this.contentAlignment.isSpot()?(p.width>S&&(y=A.left,x=A.right),p.height>M&&(k=A.top,b=A.bottom)):(y=A.left,x=A.right,k=A.top,b=A.bottom);const C=p.width+y+x,P=p.height+k+b,N=this.scale,T=N;let L=C>l/N,D=P>h/N;if(!n&&!this.to&&!this.xn&&!L&&!D)return!0;const F=p.x-y,R=a.x,I=p.right+x;let O=a.right+o;const B=p.y-k,K=a.y,V=p.bottom+b;let X=a.bottom+r,z="1px",G="1px";if(this.scrollMode===1&&(L||D)){if(L&&this.hasHorizontalScrollbar&&this.allowHorizontalScroll){let Y=1;F+1O+1&&(Y=Math.max((I-O)*N+this.Ct,Y)),S+o+1X+1&&(Y=Math.max((V-X)*N+this.At,Y)),M+r+1O+1&&(v=Math.max((I-O)*N+this.Ct,v)),S+1X+1&&(v=Math.max((V-X)*N+Y,v)),M+1O+1&&(J=this.position.x*N)),this.Ju)switch(this.Cx){case"negative":J=-(m.scrollWidth-J-m.clientWidth);break;case"reverse":J=m.scrollWidth-J-m.clientWidth;break}if(m.scrollLeft=J,this.hasVerticalScrollbar&&this.allowVerticalScroll&&(M+1X+1&&(m.scrollTop=this.position.y*N)),l=this.Ct,h=this.At,m.style.width=l+(this.to?this.yi:0)+"px",m.style.height=h+(this.xn?this.yi:0)+"px",i!==l||e!==h||this.animationManager.Si){const Y=Rect.H(f,c,u,d);return this.onViewportBoundsChanged(Y,this.viewportBounds,T,n),Rect.o(Y),!1}return!0}add(t){Util.s(t,Part,Diagram,"add:part");const i=t.diagram;if(i===this)return;i!==null&&Util.n("Cannot add part "+t.toString()+" to "+this.toString()+". It is already a part of "+i.toString());let e=this.findLayer(t.layerName);if(e===null&&(e=this.findLayer("")),e===null&&Util.n('Cannot add a Part when unable find a Layer named "'+t.layerName+'" and there is no default Layer'),t.layer===e)return;const s=e.Zh(99999999,t,t.diagram===this);s>=0&&this.raiseChangedEvent(3,"parts",e,null,t,null,s),e.isTemporary||this.invalidateDocumentBounds(),t.invalidateLayout(1);const n=t.layerChanged;n!==null&&n(t,null,e)}Zh(t){this.partManager.Zh(t);const i=this;t.Qr(s=>i.FA(s)),t.data||t.Yo(),t.hasPlaceholder()&&t.u(),t.data!==null&&t.Qr(s=>i.partManager.FP(s,null)),(t.rs()===!0||t.nh()===!0)&&this.d0(t),t.RA(!0,this),t.IA()?(t.actualBounds.isReal()&&this.T(t.Jh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.T(t.Jh(t.actualBounds)),this.requestUpdate()}ne(t){t.clearAdornments(),this.partManager.ne(t);const i=this;t.data!==null&&t.Qr(s=>i.partManager.RP(s,i)),this.Qn.delete(t),t instanceof Link&&this.Rr.delete(t),t.IA()?(t.actualBounds.isReal()&&this.T(t.Jh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.T(t.Jh(t.actualBounds)),this.requestUpdate()}remove(t){Util.s(t,Part,Diagram,"remove:part"),this.IP(t,!0)}IP(t,i){const e=t.layer;if(e===null||e.diagram!==this)return;t.isSelected=!1,t.isHighlighted=!1,t.invalidateLayout(2),i&&t.Jf();const s=e.ne(-1,t,!1);s>=0&&this.raiseChangedEvent(4,"parts",e,t,null,s,null);const n=t.layerChanged;n!==null&&n(t,e,null)}removeParts(t,i){if(i===void 0&&(i=!1),Array.isArray(t)){const e=t.length;for(let s=0;s=0&&i.elt(e).isTemporary;)e--;return i.insertAt(e+1,t),this.Ai!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,e+1),this.T(),this.invalidateDocumentBounds(),this}addLayerBefore(t,i){this.OP(t,i),t.Oo(this);const e=this.Jt,s=e.indexOf(t);s>=0&&(e.delete(t),this.Ai!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;o=0&&(e.delete(t),this.Ai!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;othis.maxScale&&(i=this.maxScale);const f=Point.H(this.mt.x+l/t-l/i,this.mt.y+h/t-h/i);this.position=f,Point.o(f),this.lt=i,this.eh(),this.$t=!1,this.onViewportBoundsChanged(n,this.viewportBounds,t,!1),this.Gs(!1),e.rA(t,this.lt),this.T()}fR(){const t=this.Jt.h;for(let i=0;i{r.isAvoiding&&r.actualBounds.intersectsRect(i)&&r.invalidateRoute()})}Zr(t){const i=this.os;if(i===null||!i.visible||i.layer===null)return;const e=t!==void 0?t:this.a1;if(!e.isReal())return;const s=e.width,n=e.height;if(i.scale=1,i.angle=0,i.layer.isViewportAligned)i.width=s*this.scale,i.height=n*this.scale,i.part.alignment=Spot.TopLeft;else{i.Mi===null&&(i.Mi=new GridPanelSettings);const o=i.Mi.Zf;if(!o.isReal())return;i.width=s+o.width*2,i.height=n+o.height*2;const r=Point.a();Geo.Hg(e.x,e.y,0,0,o.width,o.height,r),r.offset(-o.width,-o.height),i.part.location=r,Point.o(r)}}clearSelection(t){t===void 0&&(t=!1);const i=this.selection;if(i.count===0)return;t||this.V("ChangingSelection",i);const e=i.toArray(),s=e.length;for(let n=0;n1)&&(this.V("ChangingSelection",this.selection),this.clearSelection(!0),t.isSelected=!0,this.V("ChangedSelection",this.selection)))}selectCollection(t){if(this.V("ChangingSelection",this.selection),this.clearSelection(!0),Array.isArray(t)){const i=t.length;for(let e=0;e0){const i=t.toArray(),e=i.length;for(let s=0;s1)&&(this.clearHighlighteds(),t.isHighlighted=!0))}highlightCollection(t){const i=new GSet().addAll(t),s=this.highlighteds.copy().removeAll(i).iterator;for(;s.next();){const o=s.value;o.isHighlighted=!1}const n=i.iterator;for(;n.next();){const o=n.value;o instanceof Part||Util.n("Diagram.highlightCollection given something that is not a Part: "+o),o.isHighlighted=!0}}scroll(t,i,e){e===void 0&&(e=1);const s=i==="up"||i==="down";let n=0;const o=Point.a();if(t==="pixel")n=e;else if(t==="line")n=e*(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange);else if(t==="page"){let l=s?this.viewportBounds.height:this.viewportBounds.width;if(l*=this.scale,l!==0){const h=Math.max(l-(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange),0);n=e*h}}else if(t==="document"){const l=this.documentBounds,h=this.viewportBounds;i==="up"?this.position=o.e(h.x,l.y):i==="left"?this.position=o.e(l.x,h.y):i==="down"?this.position=o.e(h.x,l.bottom-h.height):i==="right"&&(this.position=o.e(l.right-h.width,h.y)),Point.o(o);return}else Util.n("scrolling unit must be 'pixel', 'line', 'page', or 'document', not: "+t);n/=this.scale;const r=this.position;i==="up"?this.position=o.e(r.x,r.y-n):i==="down"?this.position=o.e(r.x,r.y+n):i==="left"?this.position=o.e(r.x-n,r.y):i==="right"?this.position=o.e(r.x+n,r.y):Util.n("scrolling direction must be 'up', 'down', 'left', or 'right', not: "+i),Point.o(o)}scrollToRect(t){const i=this.viewportBounds;if(i.containsRect(t))return;const e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}centerRect(t){const i=this.viewportBounds,e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}transformDocToView(t){return t.copy().O(this.O)}transformViewToDoc(t){return t.copy().Ye(this.O)}VF(t){return t.Ye(this.O)}static None=1;static Uniform=2;static UniformToFill=3;static CycleAll=1;static CycleNotDirected=2;static CycleNotDirectedFast=3;static CycleNotUndirected=4;static CycleDestinationTree=5;static CycleSourceTree=6;static DocumentScroll=1;static InfiniteScroll=2;static TreeParentCollapsed=1;static AllParentsCollapsed=2;static AnyParentsCollapsed=3;get opacity(){return this._t}set opacity(t){const i=this._t;i!==t&&(Util.t(t,"number",Diagram,"opacity"),(t<0||t>1)&&Util.G(t,"0 <= value <= 1",Diagram,"opacity"),this._t=t,this.i("opacity",i,t),this.T())}get validCycle(){return this.Yx}set validCycle(t){const i=this.Yx;i!==t&&(Util.tt(t,CycleMode,"CycleMode"),this.Yx=t,this.i("validCycle",i,t))}get layers(){return this.Jt.iterator}get isModelReadOnly(){const t=this.Ai;return t===null?!1:t.isReadOnly}set isModelReadOnly(t){const i=this.Ai;i!==null&&(i.isReadOnly=t)}get isReadOnly(){return this.zo}set isReadOnly(t){const i=this.zo;i!==t&&(Util.t(t,"boolean",Diagram,"isReadOnly"),this.zo=t,this.i("isReadOnly",i,t))}get isEnabled(){return this.Xi}set isEnabled(t){const i=this.Xi;i!==t&&(Util.t(t,"boolean",Diagram,"isEnabled"),this.Xi=t,this.i("isEnabled",i,t))}get allowClipboard(){return this.Wx}set allowClipboard(t){const i=this.Wx;i!==t&&(Util.t(t,"boolean",Diagram,"allowClipboard"),this.Wx=t,this.i("allowClipboard",i,t))}get allowCopy(){return this.Vl}set allowCopy(t){const i=this.Vl;i!==t&&(Util.t(t,"boolean",Diagram,"allowCopy"),this.Vl=t,this.i("allowCopy",i,t))}get allowDelete(){return this.Bl}set allowDelete(t){const i=this.Bl;i!==t&&(Util.t(t,"boolean",Diagram,"allowDelete"),this.Bl=t,this.i("allowDelete",i,t))}get allowDragOut(){return this.vx}set allowDragOut(t){const i=this.vx;i!==t&&(Util.t(t,"boolean",Diagram,"allowDragOut"),this.vx=t,this.i("allowDragOut",i,t))}get allowDrop(){return this.Jx}set allowDrop(t){const i=this.Jx;i!==t&&(Util.t(t,"boolean",Diagram,"allowDrop"),this.Jx=t,this.i("allowDrop",i,t))}get allowTextEdit(){return this.zl}set allowTextEdit(t){const i=this.zl;i!==t&&(Util.t(t,"boolean",Diagram,"allowTextEdit"),this.zl=t,this.i("allowTextEdit",i,t))}get allowGroup(){return this.Xl}set allowGroup(t){const i=this.Xl;i!==t&&(Util.t(t,"boolean",Diagram,"allowGroup"),this.Xl=t,this.i("allowGroup",i,t))}get allowUngroup(){return this.Yl}set allowUngroup(t){const i=this.Yl;i!==t&&(Util.t(t,"boolean",Diagram,"allowUngroup"),this.Yl=t,this.i("allowUngroup",i,t))}get allowInsert(){return this.Zx}set allowInsert(t){const i=this.Zx;i!==t&&(Util.t(t,"boolean",Diagram,"allowInsert"),this.Zx=t,this.i("allowInsert",i,t))}get allowLink(){return this.Kl}set allowLink(t){const i=this.Kl;i!==t&&(Util.t(t,"boolean",Diagram,"allowLink"),this.Kl=t,this.i("allowLink",i,t))}get allowRelink(){return this.Ul}set allowRelink(t){const i=this.Ul;i!==t&&(Util.t(t,"boolean",Diagram,"allowRelink"),this.Ul=t,this.i("allowRelink",i,t))}get allowMove(){return this.Gl}set allowMove(t){const i=this.Gl;i!==t&&(Util.t(t,"boolean",Diagram,"allowMove"),this.Gl=t,this.i("allowMove",i,t))}get allowReshape(){return this.Hl}set allowReshape(t){const i=this.Hl;i!==t&&(Util.t(t,"boolean",Diagram,"allowReshape"),this.Hl=t,this.i("allowReshape",i,t))}get allowResize(){return this.ql}set allowResize(t){const i=this.ql;i!==t&&(Util.t(t,"boolean",Diagram,"allowResize"),this.ql=t,this.i("allowResize",i,t))}get allowRotate(){return this.jl}set allowRotate(t){const i=this.jl;i!==t&&(Util.t(t,"boolean",Diagram,"allowRotate"),this.jl=t,this.i("allowRotate",i,t))}get allowSelect(){return this.Wl}set allowSelect(t){const i=this.Wl;i!==t&&(Util.t(t,"boolean",Diagram,"allowSelect"),this.Wl=t,this.i("allowSelect",i,t))}get allowUndo(){return this.$x}set allowUndo(t){const i=this.$x;i!==t&&(Util.t(t,"boolean",Diagram,"allowUndo"),this.$x=t,this.i("allowUndo",i,t))}get allowZoom(){return this.Qx}set allowZoom(t){const i=this.Qx;i!==t&&(Util.t(t,"boolean",Diagram,"allowZoom"),this.Qx=t,this.i("allowZoom",i,t))}get hasVerticalScrollbar(){return this.Gu}set hasVerticalScrollbar(t){const i=this.Gu;i!==t&&(Util.t(t,"boolean",Diagram,"hasVerticalScrollbar"),this.Gu=t,this.aa(),this.T(),this.i("hasVerticalScrollbar",i,t),this.Gs(!1))}get hasHorizontalScrollbar(){return this.Uu}set hasHorizontalScrollbar(t){const i=this.Uu;i!==t&&(Util.t(t,"boolean",Diagram,"hasHorizontalScrollbar"),this.Uu=t,this.aa(),this.T(),this.i("hasHorizontalScrollbar",i,t),this.Gs(!1))}get allowHorizontalScroll(){return this._x}set allowHorizontalScroll(t){const i=this._x;i!==t&&(Util.t(t,"boolean",Diagram,"allowHorizontalScroll"),this._x=t,this.i("allowHorizontalScroll",i,t),this.Gs(!1))}get allowVerticalScroll(){return this.t1}set allowVerticalScroll(t){const i=this.t1;i!==t&&(Util.t(t,"boolean",Diagram,"allowVerticalScroll"),this.t1=t,this.i("allowVerticalScroll",i,t),this.Gs(!1))}get scrollHorizontalLineChange(){return this.i1}set scrollHorizontalLineChange(t){const i=this.i1;i!==t&&(Util.t(t,"number",Diagram,"scrollHorizontalLineChange"),t<0&&Util.G(t,">= 0",Diagram,"scrollHorizontalLineChange"),this.i1=t,this.i("scrollHorizontalLineChange",i,t))}get scrollVerticalLineChange(){return this.e1}set scrollVerticalLineChange(t){const i=this.e1;i!==t&&(Util.t(t,"number",Diagram,"scrollVerticalLineChange"),t<0&&Util.G(t,">= 0",Diagram,"scrollVerticalLineChange"),this.e1=t,this.i("scrollVerticalLineChange",i,t))}get lastInput(){return this._h}set lastInput(t){Debug&&Util.s(t,InputEvent,Diagram,"lastInput"),this._h=t}get previousInput(){return this.jr}set previousInput(t){Debug&&Util.s(t,InputEvent,Diagram,"previousInput"),this.jr=t}get firstInput(){return this.e0}set firstInput(t){Debug&&Util.s(t,InputEvent,Diagram,"firstInput"),this.e0=t}get currentCursor(){return this.Kx}set currentCursor(t){if(t===""&&(t=this.Jm),this.Kx!==t){Util.t(t,"string",Diagram,"currentCursor");const e=this.xt,s=this.Ot;if(e===null||s===null)return;this.Kx=t;const n=e.style.cursor;e.style.cursor=t,s.style.cursor=t,e.style.cursor===n&&(e.style.cursor="-webkit-"+t,s.style.cursor="-webkit-"+t,e.style.cursor===n&&(e.style.cursor="-moz-"+t,s.style.cursor="-moz-"+t,e.style.cursor===n&&(e.style.cursor=t,s.style.cursor=t)))}}get defaultCursor(){return this.Jm}set defaultCursor(t){t===""&&(t="auto");const i=this.Jm;i!==t&&(Util.t(t,"string",Diagram,"defaultCursor"),this.Jm=t,this.i("defaultCursor",i,t))}get click(){return this.Or}set click(t){const i=this.Or;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"click"),this.Or=t,this.i("click",i,t))}get doubleClick(){return this.Er}set doubleClick(t){const i=this.Er;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"doubleClick"),this.Er=t,this.i("doubleClick",i,t))}get contextClick(){return this.Vr}set contextClick(t){const i=this.Vr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"contextClick"),this.Vr=t,this.i("contextClick",i,t))}get mouseOver(){return this.Br}set mouseOver(t){const i=this.Br;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseOver"),this.Br=t,this.i("mouseOver",i,t))}get mouseHover(){return this.zr}set mouseHover(t){const i=this.zr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseHover"),this.zr=t,this.i("mouseHover",i,t))}get mouseHold(){return this.Xr}set mouseHold(t){const i=this.Xr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseHold"),this.Xr=t,this.i("mouseHold",i,t))}get mouseDragOver(){return this.Ux}set mouseDragOver(t){const i=this.Ux;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseDragOver"),this.Ux=t,this.i("mouseDragOver",i,t))}get mouseDrop(){return this.Yr}set mouseDrop(t){const i=this.Yr;i!==t&&(Debug&&t!==null&&Util.t(t,"function",Diagram,"mouseDrop"),this.Yr=t,this.i("mouseDrop",i,t))}get handlesDragDropForTopLevelParts(){return this.Gx}set handlesDragDropForTopLevelParts(t){const i=this.Gx;i!==t&&(Util.t(t,"boolean",Diagram,"handlesDragDropForTopLevelParts"),this.Gx=t,this.i("handlesDragDropForTopLevelParts",i,t))}get mouseEnter(){return this.Kr}set mouseEnter(t){const i=this.Kr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseEnter"),this.Kr=t,this.i("mouseEnter",i,t))}get mouseLeave(){return this.Ur}set mouseLeave(t){const i=this.Ur;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseLeave"),this.Ur=t,this.i("mouseLeave",i,t))}get toolTip(){return this.Gr}set toolTip(t){const i=this.Gr;i!==t&&(Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("Diagram.toolTip must be an Adornment or HTMLInfo."),this.Gr=t,this.i("toolTip",i,t))}get contextMenu(){return this.Hr}set contextMenu(t){const i=this.Hr;i!==t&&(Debug&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("Diagram.contextMenu must be an Adornment or HTMLInfo."),this.Hr=t,this.i("contextMenu",i,t))}get commandHandler(){return this.tP}set commandHandler(t){this.tP!==t&&(this.tP=t,t.Oo(this))}get toolManager(){return this.$M}set toolManager(t){this.$M!==t&&(Util.s(t,ToolManager,Diagram,"toolManager"),this.$M=t,t.diagram=this)}get defaultTool(){return this.QM}set defaultTool(t){const i=this.QM;i!==t&&(Util.s(t,Tool,Diagram,"defaultTool"),this.QM=t,t.diagram=this,this.currentTool===i&&(this.currentTool=t))}get currentTool(){return this._M}set currentTool(t){const i=this._M;i&&(i.isActive&&i.doDeactivate(),i.cancelWaitAfter(),i.doStop()),t===null&&(t=this.defaultTool),t!==null&&(Util.s(t,Tool,Diagram,"currentTool"),this._M=t,t.diagram=this,t.doStart())}get selection(){return this.lP}get maxSelectionCount(){return this.h1}set maxSelectionCount(t){const i=this.h1;if(i!==t)if(Util.t(t,"number",Diagram,"maxSelectionCount"),t>=0&&!isNaN(t)){if(this.h1=t,this.i("maxSelectionCount",i,t),!this.undoManager.isUndoingRedoing){const e=this.selection.count-t;if(e>0){this.V("ChangingSelection",this.selection);const s=this.selection.toArray();for(let n=0;n= 0",Diagram,"maxSelectionCount")}get nodeSelectionAdornmentTemplate(){return this._m}set nodeSelectionAdornmentTemplate(t){const i=this._m;i!==t&&(Util.s(t,Adornment,Diagram,"nodeSelectionAdornmentTemplate"),this._m=t,this.i("nodeSelectionAdornmentTemplate",i,t))}get groupSelectionAdornmentTemplate(){return this.c1}set groupSelectionAdornmentTemplate(t){const i=this.c1;i!==t&&(Util.s(t,Adornment,Diagram,"groupSelectionAdornmentTemplate"),this.c1=t,this.i("groupSelectionAdornmentTemplate",i,t))}get linkSelectionAdornmentTemplate(){return this.u1}set linkSelectionAdornmentTemplate(t){const i=this.u1;i!==t&&(Util.s(t,Adornment,Diagram,"linkSelectionAdornmentTemplate"),this.u1=t,this.i("linkSelectionAdornmentTemplate",i,t))}get highlighteds(){return this.hP}get isModified(){const t=this.undoManager;return t.isEnabled?t.currentTransaction!==null?!0:this.ju&&this.zs!==t.historyIndex:this.ju}set isModified(t){if(this.ju!==t){Util.t(t,"boolean",Diagram,"isModified"),this.ju=t;const e=this.undoManager;!t&&e.isEnabled&&(this.zs=e.historyIndex),t||this.KA()}}KA(){const t=this.isModified;this.oP!==t&&(this.oP=t,this.V("Modified"))}get model(){return this.Ai}set model(t){const i=this.Ai;if(i!==t){Util.s(t,Model,Diagram,"model"),this.currentTool.doCancel(),i&&i.undoManager!==t.undoManager&&i.undoManager.isInTransaction&&Util.n("Do not replace a Diagram.model while a transaction is in progress."),this.animationManager.stopAnimation(!0);const e=this.SA(!0);this.io=!1,this.Ku=!0,this.zs=-2,this.Ar=!1;const s=this.$t;this.$t=!0,this.animationManager.El("Model"),i&&(this._n!==null&&this._n.each(n=>i.removeChangedListener(n)),i.removeChangedListener(this.nP)),this.Ai=t,this.partManager=this.bR(this.Ai.type),this.initializePartManager(this.partManager);for(let n=0;nt.addChangedListener(n)),this.$t=s,this.invalidateDocumentBounds(),this.$t||this.T(),i&&t.undoManager.copyProperties(i.undoManager)}}get themeManager(){return this.C1}set themeManager(t){const i=this.C1;i!==t&&(Util.s(t,ThemeManager,Model,"themeManager"),i!==null&&i.removeDiagram(this),this.C1=t,t!==null&&t.addDiagram(this))}initializePartManager(t){}static SP(t,i){Diagram.pA.set(t,i)}static get licenseKey(){return Diagram.VP.last()}static set licenseKey(t){Diagram.VP.add(t.replace(/\s/g,""))}static get version(){return Diagram.kR}static VP=new List;static kR="3.0.11";bR(t){const i=Diagram.pA.get(t);return i!==null?new i:new PartManager}get j(){return this.eP}set j(t){this.eP=t}get Mx(){return this.dA}SR(t){if(t.model!==this.model)return;const i=t.change,e=t.propertyName;if(i===1&&e[0]==="S"){if(e==="StartingFirstTransaction"){const s=this,n=this.toolManager;n.mouseDownTools.each(o=>o.diagram=s),n.mouseMoveTools.each(o=>o.diagram=s),n.mouseUpTools.each(o=>o.diagram=s),this.routers.each(o=>o.diagram=s),!this.ks&&!this.io&&(this.Kf=!0,this.Ku&&(this.Ar=!0))}else if(e==="StartingUndo"||e==="StartingRedo"){const s=this.animationManager;this.skipsUndoManager||(s.defaultAnimation.isAnimating&&s.stopAnimation(),s.getBundleAnimation().isAnimating&&s.getBundleAnimation().stop()),this.V("ChangingSelection",this.selection)}else if(e==="StartedTransaction"){const s=this.animationManager;s.defaultAnimation.isAnimating&&!this.skipsUndoManager&&s.stopAnimation()}return}if(this.j){this.j=!1;try{if(t.modelChange===""&&i===1){(e==="FinishedUndo"||e==="FinishedRedo")&&(this.V("ChangedSelection",this.selection),this.Di());const s=this.animationManager;e==="RolledBackTransaction"&&s.stopAnimation(),this.xR(),this.Kf=!0,this.maybeUpdate(),(this.undoManager.transactionLevel===0||this.undoManager.transactionLevel===1)&&s.FM(),e==="CommittedTransaction"&&this.undoManager.isJustDiscarded&&(this.zs=Math.min(this.zs,this.undoManager.historyIndex-1)),(e==="CommittedTransaction"||e==="RolledBackTransaction")&&this.undoManager.Gw&&setTimeout(()=>{this.isModified=!1},1);const n=t.isTransactionFinished;if(n&&(this.KA(),this.Mx.clear(),this.animationManager.bF()),!this.Hx&&n&&this.lastInput.targetDiagram){this.Hx=!0;const o=this;Util.Bh(()=>{o.currentTool.standardMouseOver(),o.Hx=!1},10)}}}finally{this.j=!0}}}get me(){return this.iP}set me(t){this.iP=t}get bf(){return this.qx}set bf(t){this.qx=t}FA(t){const i=t.D.h;for(const e of i)e instanceof Picture&&this.BP(e)}BP(t){const i=t.element;if(i===null||!(i instanceof HTMLImageElement)||(i.ls instanceof GSet&&i.ls.add(this),t.MR(),!i.w0))return;const e=i.getAttribute("src")||"",s=this._l.get(e);if(s===null){Picture.UA(t,i);const n=[];n.push(t),this._l.set(e,n)}else{for(let n=0;n0)&&Util.n("defaultScale must be larger than zero, not: "+t),this.s0=t}get autoScale(){return this.Jl}set autoScale(t){const i=this.Jl;i!==t&&(Util.tt(t,AutoScale,"AutoScale"),this.Jl=t,this.i("autoScale",i,t),t!==1&&this.Gs(!1))}get initialAutoScale(){return this.Fr}set initialAutoScale(t){const i=this.Fr;i!==t&&(Util.tt(t,AutoScale,"AutoScale"),this.Fr=t,this.i("initialAutoScale",i,t))}get initialViewportSpot(){return this.Bx}set initialViewportSpot(t){const i=this.Bx;i!==t&&(Util.s(t,Spot,Diagram,"initialViewportSpot"),t.isSpot()||Util.n("initialViewportSpot must be a specific Spot: "+t),this.Bx=t,this.i("initialViewportSpot",i,t))}get initialDocumentSpot(){return this.Vx}set initialDocumentSpot(t){const i=this.Vx;i!==t&&(Util.s(t,Spot,Diagram,"initialDocumentSpot"),t.isSpot()||Util.n("initialViewportSpot must be a specific Spot: "+t),this.Vx=t,this.i("initialDocumentSpot",i,t))}get minScale(){return this.Tx}set minScale(t){Util.r(t,Diagram,"minScale");const i=this.Tx;i!==t&&(t>0?(this.Tx=t,this.i("minScale",i,t),t>this.scale&&(this.scale=t)):Util.G(t,"> 0",Diagram,"minScale"))}get maxScale(){return this.Dx}set maxScale(t){Util.r(t,Diagram,"maxScale");const i=this.Dx;i!==t&&(t>0?(this.Dx=t,this.i("maxScale",i,t),t 0",Diagram,"maxScale"))}get zoomPoint(){return this.Fx}set zoomPoint(t){this.Fx.equals(t)||(Util.s(t,Point,Diagram,"zoomPoint"),t=t.L(),this.Fx=t)}get contentAlignment(){return this.Xf}set contentAlignment(t){const i=this.Xf;i.equals(t)||(Util.s(t,Spot,Diagram,"contentAlignment"),t=t.L(),this.Xf=t,this.i("contentAlignment",i,t),this.Gs(!1))}get initialContentAlignment(){return this.jm}set initialContentAlignment(t){const i=this.jm;i.equals(t)||(Util.s(t,Spot,Diagram,"initialContentAlignment"),t=t.L(),this.jm=t,this.i("initialContentAlignment",i,t))}get padding(){return this.ii}set padding(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Diagram,"padding");const i=this.ii;i.equals(t)||(t=t.L(),this.ii=t,this.invalidateDocumentBounds(),this.i("padding",i,t))}get partManager(){return this.dP}set partManager(t){const i=this.dP;i!==t&&(Util.s(t,PartManager,Diagram,"partManager"),t.diagram!==null&&Util.n("Cannot share PartManagers between Diagrams: "+t.toString()),i&&i.Oo(null),this.dP=t,t.Oo(this))}get nodes(){return this.partManager.nodes.iterator}get links(){return this.partManager.links.iterator}get parts(){return this.partManager.parts.iterator}findTopLevelNodesAndLinks(){const t=new GSet,i=this.nodes;for(;i.next();){const s=i.value;s.isTopLevel&&t.add(s)}const e=this.links;for(;e.next();){const s=e.value;s.isTopLevel&&t.add(s)}return t.iterator}findTopLevelGroups(){return this.vr.iterator}get routers(){return this.Wf}doLinkRouting(t){this.Vo=!0;const i=this.Wf.h;for(let e=0;e0){const l=this.computePartsBounds(n.memberParts,!1);l.inflate(20,20),s.I1(l)}const o=Rect.a(),r=n.memberParts;for(;r.next();){const l=r.value;l instanceof Node&&this.GP(l,e,o)}Rect.o(o)}s.ca=n,s.YP=e,s.Ko=!1}else t&&s.vA();return s}get avoidanceCellSize(){return this.aP}set avoidanceCellSize(t){this.Zl=null,this.aP=new Size(Math.max(1,t.width),Math.max(1,t.height))}get avoidanceLimit(){return this.fP}set avoidanceLimit(t){this.fP=Math.max(1,t)}WA(t){return t.canAvoid()?t:t.containingGroup!==null?this.WA(t.containingGroup):null}GP(t,i,e){if(t===i||!t.isVisible())return;const s=t.canAvoid();if(s){const n=t.getAvoidableRect(e);this.Zl.CR(n.x,n.y,n.width,n.height)}if(t instanceof Group&&(!s||t.avoidableMembers)){const n=t.memberParts;for(;n.next();){const o=n.value;o instanceof Node&&this.GP(o,i,e)}}}HP(t){this.Zl!==null&&!this.Zl.Ko&&(t===void 0||t.canAvoid())&&(this.Zl.Ko=!0)}get autoScrollInterval(){return this.Wm}set autoScrollInterval(t){const i=this.Wm;Util.r(t,Diagram,"autoScrollInterval"),i!==t&&(this.Wm=t,this.i("autoScrollInterval",i,t))}get autoScrollRegion(){return this.vm}set autoScrollRegion(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Diagram,"autoScrollRegion");const i=this.vm;i.equals(t)||(t=t.L(),this.vm=t,this.invalidateDocumentBounds(),this.i("autoScrollRegion",i,t))}doAutoScroll(t){this.i0.c(t),this.computeAutoScrollPosition(this.i0).equalsApprox(this.position)?this.stopAutoScroll():this.JA()}JA(){if(this.Yf!==-1)return;const t=this.Wm,i=this;this.Yf=Util.Bh(()=>{if(i.Yf===-1||(i.stopAutoScroll(),i.lastInput.event===null))return;const s=i.computeAutoScrollPosition(i.i0);if(s.equalsApprox(i.position))return;i.position=s,i.lastInput.documentPoint=i.transformViewToDoc(i.i0),i.doMouseMove(),i.ta=!0;const n=Rect.a();i.computeBounds(n),n.unionRect(i.documentBounds),i.GA(n),Rect.o(n),i.Ge=!0,i.maybeUpdate(),i.JA()},t)}stopAutoScroll(){this.Yf!==-1&&(Util.Ug(this.Yf),this.Yf=-1)}computeAutoScrollPosition(t){let i=this.position;const e=this.vm;if(e.top<=0&&e.left<=0&&e.right<=0&&e.bottom<=0)return i;const s=this.viewportBounds,n=this.scale,o=Rect.H(0,0,s.width*n,s.height*n),r=Point.H(0,0);if(t.x>=o.x&&t.xo.x+o.width-e.right&&this.allowHorizontalScroll){let l=Math.max(this.scrollHorizontalLineChange,1);l=l|0,r.x+=l,t.x>o.x+o.width-e.right/2&&(r.x+=l),t.x>o.x+o.width-e.right/4&&(r.x+=4*l)}if(t.y>=o.y&&t.yo.y+o.height-e.bottom&&this.allowVerticalScroll){let l=Math.max(this.scrollVerticalLineChange,1);l=l|0,r.y+=l,t.y>o.y+o.height-e.bottom/2&&(r.y+=l),t.y>o.y+o.height-e.bottom/4&&(r.y+=4*l)}return r.equalsApprox(Point.Lo)||(i=new Point(i.x+r.x/n,i.y+r.y/n)),Rect.o(o),Point.o(r),i}makeSvg(t){this.Ql.has("SVG")||this.addRenderer("SVG",new SVGSurface(this,root.document));const i=new SVGSurface(this,root.document,!0);t===void 0&&(t={});const e=this;function s(n,o){const r=e.ZA(n,"SVG",i),l=r!==null?r.svg:null;return typeof o=="function"?(o(l),null):l}return this.$A(s,t)}makeSVG(t){return this.makeSvg(t)}addRenderer(t,i){this.Ql.set(t,i)}removeRenderer(t){this.Ql.delete(t)}cacheGroupExternalLinks(t){this.kP=t,t||this.nodes.each(i=>{i instanceof Group&&(i.b0=null)})}$A(t,i){const e=i.callback;let s=!0;const o=this._l.iterator;for(;o.next();)if(!o.value[0].bn){s=!1;break}if(typeof e!="function"||s)return t(i,e,this);const r=this;function l(){const f=+new Date;for(s=!0,o.reset();o.next();)if(!o.value[0].bn){s=!1;break}if(s||f-a>h){t(i,e,r);return}root.requestAnimationFrame(l)}const h=i.callbackTimeout||300,a=+new Date;return root.requestAnimationFrame(()=>l()),null}makeImage(t){return Diagram.isUsingDOM()?(t===void 0&&(t={}),t.returnType="Image",this.makeImageData(t)):null}makeImageData(t){return t===void 0&&(t={}),this.$A(this.AR,t)}static img="image";AR(t,i,e){const s=e.ZA(t,"canvas",null);if(s===null)return null;const n=s.Y.canvas;let o=null;if(n!==null){let r=t.returnType;switch(r===void 0?r="string":r=r.toLowerCase(),r){case Diagram.img+"data":o=s.getImageData(0,0,n.width,n.height);break;case Diagram.img:const h=(t.document||document).createElement("img");h.src=n.toDataURL(t.type,t.details),o=h;break;case"blob":{const a=n;return typeof i!="function"&&(o="",Util.n('Error: Diagram.makeImageData called with "returnType: toBlob", but no required "callback" function property defined.')),typeof a.toBlob=="function"?(a.toBlob(i,t.type,t.details),"toBlob"):(i(null),null)}case"string":default:o=n.toDataURL(t.type,t.details)}}return typeof i=="function"?(i(o),null):o}static QA=!1;ZA(t,i,e){if(this.animationManager.stopAnimation(),this.maybeUpdate(),this.xt===null)return null;typeof t!="object"&&Util.n("properties argument must be an Object.");let n=!1,o=t.size||null,r=t.scale||null;t.scale!==void 0&&isNaN(t.scale)&&(r="NaN");let l=t.maxSize;t.maxSize===void 0&&(n=!0,i==="SVG"?l=new Size(1/0,1/0):l=new Size(2e3,2e3));const h=t.position||null;let a=t.parts||null;Array.isArray(a)&&(a=new List(a));let f=t.padding===void 0?1:t.padding;const c=t.background||null;let u=t.omitTemporary;u===void 0&&(u=!0);const d=t.document||document,m=t.elementFinished||null;let g=t.showTemporary;g===void 0&&(g=!u);let p=t.showGrid;p===void 0&&(p=g),o!==null&&isNaN(o.width)&&isNaN(o.height)&&(o=null),typeof f=="number"?f=new Margin(f):f instanceof Margin||Util.n("MakeImage padding must be a Margin or a number."),f.left=Math.max(f.left,0),f.right=Math.max(f.right,0),f.top=Math.max(f.top,0),f.bottom=Math.max(f.bottom,0),this.ei.clearContextCache(!0);const y=new CanvasSurface(null,d,void 0,!0),x=y.di;if(!(o||r||a||h))return y.width=this.Ct+Math.ceil(f.left+f.right),y.height=this.At+Math.ceil(f.top+f.bottom),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.ua=d,e.Qu=m,this.D1(e.di,f,new Size(y.width,y.height),this.lt,this.mt,a,c,g,p),e.di):(this.Wu=!1,this.D1(x,f,new Size(y.width,y.height),this.lt,this.mt,a,c,g,p),this.Wu=!0,y.di);const k=this.s0,b=this.documentBounds.copy();if(b.subtractMargin(this.ii),g){const L=this.Jt.h,D=L.length;for(let F=0;Fk?(r=k,N=b.width,T=b.height):(N=l.width,T=l.height)):(N=b.width*r,T=b.height*r):(r=k,N=b.width,T=b.height),f!==null?(N+=M,T+=A):f=new Margin(0),l!==null){let L=l.width,D=l.height;i!=="SVG"&&n&&!Diagram.QA&&Debug&&(N>L||T>D)&&(Util.at("Diagram.makeImage(data): Diagram width or height is larger than the default max size. ("+Math.ceil(N)+"x"+Math.ceil(T)+" vs 2000x2000) Consider increasing the max size."),Diagram.QA=!0),isNaN(L)&&(L=2e3),isNaN(D)&&(D=2e3),isFinite(L)&&(N=Math.min(N,L)),isFinite(D)&&(T=Math.min(T,D))}return y.width=Math.ceil(N),y.height=Math.ceil(T),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.ua=d,e.Qu=m,this.D1(e.di,f,new Size(Math.ceil(N),Math.ceil(T)),r,S,a,c,g,p),e.di):(this.Wu=!1,this.D1(x,f,new Size(Math.ceil(N),Math.ceil(T)),r,S,a,c,g,p),this.Wu=!0,y.di)}static Zu=null;static _A="5da73c80a36555d4038e4972187c3cae51fd22";static ww=!1;static Hk=()=>{if(Diagram._A[5]===void 0&&(Transform.prototype.ns=Transform.prototype.Nw),!Diagram.isUsingDOM())return;const t=root.document.createElement("canvas"),i=t.getContext("2d"),e=Util.Fs("7ca11abfd022028846");i[e]=Util.Fs("398c3597c01238");const s="7ca11abfd7330390",n=[Diagram._A,Util.ww+"4ae6247590da4bb21c324ba3a84e385776",Transform.Hk+"fb236cdfda5de14c134ba1a95a2d4c7cc6f93c1387",Geo.za],o=10,r=0;for(let l=1;l<5;l++)i[Util.Fs(s)](Util.Fs(n[l-1]),o,l*15+r);i[e]=Util.Fs("39f046ebb36e4b");for(let l=1;l<5;l++)i[Util.Fs(s)](Util.Fs(n[l-1]),o,l*15+r);(n.length!==4||n[0][0]!=="5"||n[3][0]!=="7")&&(Transform.prototype.ns=Transform.prototype.Nw),Diagram.Zu=t}}class DiagramHelper{tL;iL;qP;De;constructor(t){if(this.tL=null,this.iL="63ad05bbe23a1786468a4c741b6d2",this.qP="@onz",this.iL===this._tk){this.qP=!0,this.De=this.qP;return}this.De=null}LR(t,i){let e="f";const s=root[Util.Fs("76a715b2f73f148a")][Util.Fs("72ba13b5")]||"",n=Util.Fs;if(this.De=!0,!Diagram.isUsingDOM())return;let o=Diagram[n("76a115b6ed251eaf4692")];if(!o){const l=s[n("76ad18b4f73e")];for(let a=s[n("73a612b6fb191d")](n("35e7"))+2;a=0&&ha[0]||h[0]===a[0]&&h[1]>=a[1]))continue;const f="73a612b6fb191d",c=root[n("74a900bae4370f8b51")][n("6fbb13a1c2311e8a57")].toLowerCase(),u=c[n(f)](n("3aad1ab6e022098b4dc4")),d=n(l[2]);if(u>-1){const P=c[n(f)](d.toLowerCase()+"/");if(this.De=!(P>-1&&P=0&&g-1),!this.De))return;const p=root[Util.Fs("76a715b2f73f148a")][Util.Fs("69ad17a1e03e")],y=p[n(f)](n("7fb002b6ed25128b4da25b2e"));if(y>-1&&(this.De=!(p[n(f)](d)>y),!this.De))return;const x=d;if(x[0]!=="#")continue;const k=root.document.createElement("div");let b=l[0].replace(/[A-Za-z]/g,"");for(;b.length<4;)b+="9";const S=b;b=b.substring(b.length-4);let M="";const A=["gsh","gsf"],C=["Header","Background","Display","Feedback"];if(M+=A[parseInt(b.substring(0,1),10)%2],M+=C[parseInt(b.substring(0,1),10)%4],k[n("79a417a0f0181a8946")]=M,root.document[n("78a712aa")]){root.document[n("78a712aa")][n("7bb806b6ed32388c4a875b")](k);const P=root.getComputedStyle(k).getPropertyValue(n("78a704b7e62456904c9b12701b6532a8")),N=root.getComputedStyle(k).getPropertyValue(n("75b817b0ea2202"));if(root.document[n("78a712aa")][n("68ad1bbcf533388c4a875b")](k),!P)continue;const T=root[n("77a902b0eb1b1e804a8a")],L="0."+parseInt(S,10)%100;if(N===L||P.indexOf(parseInt(x[1]+x[2],16))!==-1&&P.indexOf(parseInt(x[3]+x[4],16))!==-1){this.De=!1;return}else if(T&&T(n("32ae19a1e0331fc94084537c067a67fa59f1386b89d006")).matches){M="."+M;for(let D=0;D{const s=this.observed;if(s===null)return;const n=s.viewportBounds,o=this.lastInput.documentPoint;s.position=new Point(o.x-n.width/2,o.y-n.height/2)},this.vP=s=>{this.invalidateDocumentBounds(),this.S0()},this.JP=s=>{this.observed!==null&&(this.invalidateDocumentBounds(),this.T())},this.z1=s=>{this.updateDelay<1?this.T():this.k0||(this.k0=!0,setTimeout(()=>this.redraw(),this.updateDelay))},this.ZP=s=>{this.observed!==null&&this.S0()},this.autoScale=2,this.$t=!1,i&&Object.assign(this,i),this}setupRouters(){}computePixelRatio(){return 1}redraw(){this.k0&&this.updateDelay>=1&&(this.k0=!1,this.TR()),super.redraw()}Ji(){if(this.Ot===null&&Util.n("No div specified"),this.xt===null&&Util.n("No canvas specified"),this.xt instanceof SVGSurface||(this.box.jM(),!this.Ge))return;const t=this.observed;if(t===null||t.animationManager.defaultAnimation.isAnimating||!t.Yh)return;this.m0();const i=this.xt,e=this.ei;if(e.clearContextCache(!0),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,i.width,i.height),this.updateDelay<1)this.sL();else if(this.Qf!==null){e.drawImage(this.Qf.Bt,0,0);const o=this.O;e.scale(this.Gi,this.Gi),e.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),e.commitTransform()}const s=this.Jt.h,n=s.length;for(let o=0;on.canDelete())}t.removeParts(i,!0),t.V("SelectionDeleted",i)}finally{t.commitTransaction("Delete"),t.V("ChangedSelection",t.selection),t.currentCursor=""}}canDeleteSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowDelete||t.selection.count===0)}copySelection(){const t=this.diagram;try{const i=new GSet,e=t.selection.iterator;for(;e.next();){const s=e.value;Part.lh(i,s,!0,this.copiesTree?1/0:0,this.copiesConnectedLinks,n=>n.canCopy())}this.copyToClipboard(i)}finally{}}canCopySelection(){const t=this.diagram;return!(!t.allowCopy||!t.allowClipboard||t.selection.count===0)}cutSelection(){this.copySelection(),this.deleteSelection()}canCutSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowCopy||!t.allowDelete||!t.allowClipboard||t.selection.count===0)}copyToClipboard(t){const i=this.diagram;let e=null;if(t===null)Diagram.kA();else{const s=i.model;let n=!1,o=!1,r=null;try{s.Mf()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.kf()||s._u())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=i.copyParts(t,null,!0)}finally{s.Mf()&&(s.copiesParentKeyOfNodeData=n),(s.kf()||s._u())&&(s.copiesGroupKeyOfNodeData=o),e=new List,e.addAll(r.iteratorValues),Diagram.c0=e,Diagram.A1=i.model.dataFormat}}i.V("ClipboardChanged",e)}pasteFromClipboard(){const t=new GSet,i=Diagram.c0;if(i===null)return t;const e=this.diagram;if(Diagram.A1!==e.model.dataFormat)return t;const s=e.model;let n=!1,o=!1,r=null;try{s.Mf()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.kf()||s._u())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=e.copyParts(i,e,!1)}finally{s.Mf()&&(s.copiesParentKeyOfNodeData=n),(s.kf()||s._u())&&(s.copiesGroupKeyOfNodeData=o);const l=r.iterator;for(;l.next();){const h=l.value,a=l.key;h.location.isReal()||(a.location.isReal()?h.location=a.location:!h.position.isReal()&&a.position.isReal()&&(h.position=a.position)),t.add(h)}}return t}pasteSelection(t){t===void 0&&(t=null);const i=this.diagram;try{i.currentCursor="wait",i.V("ChangingSelection",i.selection),i.startTransaction("Paste");const e=this.pasteFromClipboard();e.count>0&&i.clearSelection(!0);const s=e.iterator;for(;s.next();){const n=s.value;n.isSelected=!0}if(t!==null){const n=i.computePartsBounds(i.selection);if(n.isReal()){const o=this.computeEffectiveCollection(i.selection,i.M1);i.LS(o,new Point(t.x-n.centerX,t.y-n.centerY),i.M1,!1)}}i.V("ClipboardPasted",e)}finally{i.commitTransaction("Paste"),i.V("ChangedSelection",i.selection),i.currentCursor=""}}canPasteSelection(t){const i=this.diagram;return!(i.isReadOnly||i.isModelReadOnly||!i.allowInsert||!i.allowClipboard||Diagram.c0===null||Diagram.c0.count===0||Diagram.A1!==i.model.dataFormat)}undo(){this.diagram.undoManager.undo()}canUndo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canUndo()}redo(){this.diagram.undoManager.redo()}canRedo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canRedo()}decreaseZoom(t){t===void 0&&(t=1/this.zoomFactor),Util.r(t,CommandHandler,"decreaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canDecreaseZoom(t){t===void 0&&(t=1/this.zoomFactor),Util.r(t,CommandHandler,"canDecreaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}increaseZoom(t){t===void 0&&(t=this.zoomFactor),Util.r(t,CommandHandler,"increaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canIncreaseZoom(t){t===void 0&&(t=this.zoomFactor),Util.r(t,CommandHandler,"canIncreaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}resetZoom(t){t===void 0&&(t=this.defaultScale),Util.r(t,CommandHandler,"resetZoom:newscale");const i=this.diagram;ti.maxScale||(i.scale=t)}canResetZoom(t){t===void 0&&(t=this.defaultScale),Util.r(t,CommandHandler,"canResetZoom:newscale");const i=this.diagram;return ti.maxScale?!1:i.allowZoom}zoomToFit(){const t=this.diagram,i=t.animationManager;i.stopAnimation(),t.redraw();const e=t.position,s=t.scale;i.El("Zoom To Fit"),this.isZoomToFitRestoreEnabled&&s===this.Y1&&!isNaN(this.X1)&&t.documentBounds.equals(this.K1)?(t.scale=this.X1,t.position=this.h2,this.Y1=NaN,this.K1=Rect.kw):(this.X1=s,this.h2=e.copy(),t.zoomToFit(),this.Y1=t.scale,this.K1=t.documentBounds.copy()),i.FM()}canZoomToFit(){return this.diagram.allowZoom}scrollToPart(t){t===void 0&&(t=null),t!==null&&Util.s(t,Part,CommandHandler,"part");const i=this.diagram;if(i.ensureBounds(),t===null){try{this.Uo!==null&&(this.Uo.next()?t=this.Uo.value:this.Uo=null)}catch{this.Uo=null}t===null&&(i.highlighteds.count>0?this.Uo=i.highlighteds.iterator:i.selection.count>0&&(this.Uo=i.selection.iterator),this.Uo!==null&&this.Uo.next()&&(t=this.Uo.value))}if(t!==null){const e=i.animationManager;e.El("Scroll To Part");const s=this.scrollToPartPause;if(s>0){const n=this._f(t,[t]);if(n.length===1)i.startTransaction(),i.centerRect(t.actualBounds),i.commitTransaction("Scroll To Part");else{const o=()=>{i.startTransaction();let l=n.pop();for(;n.length>0&&l instanceof Node&&l.isTreeExpanded&&(!(l instanceof Group)||l.isSubGraphExpanded);)l=n.pop();n.length>0?(l instanceof Part&&i.scrollToRect(l.actualBounds),l instanceof Node&&!l.isTreeExpanded&&(l.isTreeExpanded=!0),l instanceof Group&&!l.isSubGraphExpanded&&(l.isSubGraphExpanded=!0)):(l instanceof Part&&i.centerRect(l.actualBounds),i.removeDiagramListener("LayoutCompleted",r)),i.commitTransaction("Scroll To Part")},r=()=>{Util.Bh(o,(e.isEnabled?e.duration:0)+s)};i.addDiagramListener("LayoutCompleted",r),o()}}else{const n=i.position.copy();i.centerRect(t.actualBounds),n.equalsApprox(i.position)&&e.stopAnimation()}}}_f(t,i){if(t.isVisible())return i;if(t instanceof Adornment)this._f(t.adornedPart,i);else if(t instanceof Link){const e=t.fromNode;e!==null&&this._f(e,i);const s=t.toNode;s!==null&&this._f(s,i)}else{if(t instanceof Node){const s=t.labeledLink;s!==null&&this._f(s,i);const n=t.findTreeParentNode();n!==null&&(!n.isTreeExpanded&&!n.wasTreeExpanded&&i.push(n),this._f(n,i))}const e=t.containingGroup;e!==null&&(!e.isSubGraphExpanded&&!e.wasSubGraphExpanded&&i.push(e),this._f(e,i))}return i}canScrollToPart(t){if(t===void 0&&(t=null),t!==null&&!(t instanceof Part))return!1;const i=this.diagram;return i.selection.count===0&&i.highlighteds.count===0?!1:i.allowHorizontalScroll&&i.allowVerticalScroll}collapseTree(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse Tree";try{i.startTransaction(e),i.animationManager.El(e);const n=new List;if(t!==null&&t.isTreeExpanded)t.collapseTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&r.isTreeExpanded&&(r.collapseTree(),n.add(r))}}i.V("TreeCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||!t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(!s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}expandTree(t){t===void 0&&(t=null);const i=this.diagram,e="Expand Tree";try{i.startTransaction(e),i.animationManager.El(e);const n=new List;if(t!==null&&!t.isTreeExpanded)t.expandTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&(r.isTreeExpanded||(r.expandTree(),n.add(r)))}}i.V("TreeExpanded",n)}finally{i.commitTransaction(e)}}canExpandTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}groupSelection(){const t=this.diagram,i=t.model;if(!i.da())return;const e=this.archetypeGroupData;if(e===null)return;let s=null;try{t.currentCursor="wait",t.V("ChangingSelection",t.selection),t.startTransaction("Group");const n=new List,o=t.selection.iterator;for(;o.next();){const h=o.value;h.Ae()&&h.canGroup()&&n.add(h)}const r=new List,l=n.iterator;for(;l.next();){const h=l.value;let a=!1;const f=n.iterator;for(;f.next();){const c=f.value;if(h.isMemberOf(c)){a=!0;break}}a||r.add(h)}if(r.count>0){let h=r.first().containingGroup;if(h!==null)for(;h!==null;){let a=!1;const f=r.iterator;for(;f.next();)if(!f.value.isMemberOf(h)){a=!0;break}if(a)h=h.containingGroup;else break}if(e instanceof Group)e.ci(),s=e.copy(),s!==null&&t.add(s);else if(i.isGroupForData(e)){const a=i.copyNodeData(e);Util.Mt(a)&&(i.addNodeData(a),s=t.findNodeForData(a))}if(s!==null){h!==null&&this.isValidMember(h,s)&&(s.containingGroup=h);const a=r.iterator;for(;a.next();){const f=a.value;this.isValidMember(s,f)&&(f.containingGroup=s)}t.clearSelection(!0),s.isSelected=!0}}t.V("SelectionGrouped",s)}finally{t.commitTransaction("Group"),t.V("ChangedSelection",t.selection),t.currentCursor=""}}canGroupSelection(){const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowGroup||!t.model.da()||this.archetypeGroupData===null)return!1;const e=t.selection.iterator;for(;e.next();){const s=e.value;if(s.Ae()&&s.canGroup())return!0}return!1}c2(t){const i=Util.ft();if(Array.isArray(t))t.forEach(n=>{n instanceof Link||n instanceof Part&&i.push(n)});else{const n=t.iterator;for(;n.next();){const o=n.value;o instanceof Link||o instanceof Part&&i.push(o)}}const e=new GSet,s=i.length;for(let n=0;n0){i.clearSelection(!0);const o=s.iterator;for(;o.next();){const r=o.value;r.expandSubGraph();const l=r.containingGroup,h=l!==null&&l.data!==null?e.getKeyForNodeData(l.data):void 0;n.addAll(r.memberParts);const a=n.iterator;for(;a.next();){const f=a.value;if(f.isSelected=!0,f instanceof Link)continue;const c=f.data;c!==null?e.setGroupForData(c,h):f.containingGroup=l}i.remove(r)}}i.V("SelectionUngrouped",s,n)}finally{i.commitTransaction("Ungroup"),i.V("ChangedSelection",i.selection),i.currentCursor=""}}canUngroupSelection(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowDelete||!i.allowUngroup||!i.model.da())return!1;if(t!==null){if(!(t instanceof Group))return!1;if(t.canUngroup())return!0}else{const s=i.selection.iterator;for(;s.next();){const n=s.value;if(n instanceof Group&&n.canUngroup())return!0}}return!1}addTopLevelParts(t,i){const e=this.c2(t);let s=!0;const n=e.iterator;for(;n.next();){const o=n.value;o.containingGroup!==null&&(!i||this.isValidMember(null,o)?o.containingGroup=null:s=!1)}return s}collapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse SubGraph";try{i.startTransaction(e),i.animationManager.El(e);const n=new List;if(t!==null&&t.isSubGraphExpanded)t.collapseSubGraph(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&r.isSubGraphExpanded&&(r.collapseSubGraph(),n.add(r))}}i.V("SubGraphCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||!t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&s.isSubGraphExpanded)return!0}}return!1}expandSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Expand SubGraph",s=new List;try{if(i.startTransaction(e),i.animationManager.El(e),t!==null&&!t.isSubGraphExpanded)t.expandSubGraph(),s.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&(r.isSubGraphExpanded||(r.expandSubGraph(),s.add(r)))}}i.V("SubGraphExpanded",s)}finally{for(const n of s)this.nL(i,n);t&&this.nL(i,t),i.commitTransaction(e)}}nL(t,i){for(const e of i.memberParts)e instanceof Node&&t.If(e,i)}canExpandSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&!s.isSubGraphExpanded)return!0}}return!1}editTextBlock(t){t===void 0&&(t=null),t!==null&&Util.s(t,TextBlock,CommandHandler,"editTextBlock");const i=this.diagram,e=i.toolManager.findTool("TextEditing");if(e!==null){if(t===null){let s=null;const n=i.selection.iterator;for(;n.next();){const o=n.value;if(o.canEdit()){s=o;break}}if(s===null)return;t=s.findInVisualTree(o=>o instanceof TextBlock&&o.editable)}t!==null&&(i.currentTool=null,e.textBlock=t,i.currentTool=e)}}canEditTextBlock(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowTextEdit||i.toolManager.findTool("TextEditing")===null)return!1;if(t!==null){if(!(t instanceof TextBlock))return!1;const e=t.part;if(e!==null&&e.canEdit())return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s.canEdit()&&(t=s.findInVisualTree(n=>n instanceof TextBlock&&n.editable),t!==null))return!0}}return!1}showContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");if(e===null)return;t===void 0&&(i.selection.count>0?t=i.selection.first():t=i);const s=e.findObjectWithContextMenu(t);if(s!==null){const n=i.lastInput;let o=null;if(s instanceof GraphObject)o=s.getDocumentPoint(Spot.Center);else if(!i.viewportBounds.containsPoint(n.documentPoint)){const r=i.viewportBounds;o=new Point(r.x+r.width/2,r.y+r.height/2)}if(o!==null){const r=new InputEvent;r.diagram=i,r.viewPoint=i.transformDocToView(o),r.documentPoint=o,r.button=2,r.up=!0,i.lastInput=r}i.currentTool=e,e.openMenu(!1,s)}}canShowContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");return!(e===null||(t===void 0&&(i.selection.count>0?t=i.selection.first():t=i),e.findObjectWithContextMenu(t)===null))}get copiesClipboardData(){return this.$P}set copiesClipboardData(t){Util.t(t,"boolean",CommandHandler,"copiesClipboardData"),this.$P=t}get copiesConnectedLinks(){return this.QP}set copiesConnectedLinks(t){Util.t(t,"boolean",CommandHandler,"copiesConnectedLinks"),this.QP=t}get deletesConnectedLinks(){return this._P}set deletesConnectedLinks(t){Util.t(t,"boolean",CommandHandler,"deletesConnectedLinks"),this._P=t}get copiesTree(){return this.t2}set copiesTree(t){Util.t(t,"boolean",CommandHandler,"copiesTree"),this.t2=t}get deletesTree(){return this.i2}set deletesTree(t){Util.t(t,"boolean",CommandHandler,"deletesTree"),this.i2=t}get copiesParentKey(){return this.e2}set copiesParentKey(t){Util.t(t,"boolean",CommandHandler,"copiesParentKey"),this.e2=t}get copiesGroupKey(){return this.s2}set copiesGroupKey(t){Util.t(t,"boolean",CommandHandler,"copiesGroupKey"),this.s2=t}get archetypeGroupData(){return this.o2}set archetypeGroupData(t){t!==null&&Util.t(t,"object",CommandHandler,"archetypeGroupData");const i=this.diagram;if(Debug){const e=i.model;e.da()&&!(t instanceof Group)&&!e.isGroupForData(t)&&Util.n("CommandHandler.archetypeGroupData must be either a Group or a data object for which GraphLinksModel.isGroupForNodeData is true: "+t)}this.o2=t}get memberValidation(){return this.rh}set memberValidation(t){t!==null&&Util.t(t,"function",CommandHandler,"memberValidation"),this.rh=t}get defaultScale(){return this.diagram.defaultScale}set defaultScale(t){this.diagram.defaultScale=t}get zoomFactor(){return this.l2}set zoomFactor(t){Util.r(t,CommandHandler,"zoomFactor"),t>1||Util.n("zoomFactor must be larger than 1.0, not: "+t),this.l2=t}get isZoomToFitRestoreEnabled(){return this.a2}set isZoomToFitRestoreEnabled(t){Util.t(t,"boolean",CommandHandler,"isZoomToFitRestoreEnabled"),this.a2=t}get scrollToPartPause(){return this.f2}set scrollToPartPause(t){Util.r(t,CommandHandler,"scrollToPartPause"),this.f2=t}computeEffectiveCollection(t,i){const e=this.diagram,s=e.toolManager.findTool("Dragging"),n=e.currentTool===s;i===void 0&&(i=e.y0());const o=new GMap;if(t===null)return o;let r=t.iterator;for(;r.next();){const l=r.value;e._r(o,l,n,i)}if(e.draggedLink!==null&&i.dragsLink)return o;for(r=t.iterator;r.next();){const l=r.value;if(l instanceof Link){const h=l.fromNode;if(h!==null&&!o.has(h))o.delete(l);else{const a=l.toNode;a!==null&&!o.has(a)&&o.delete(l)}}}return o}}var Stretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Vertical=4]="Vertical",w[w.Horizontal=5]="Horizontal",w[w.Fill=2]="Fill",w))(Stretch||{}),Orientation=(w=>(w[w.None=0]="None",w[w.Along=21]="Along",w[w.Plus90=22]="Plus90",w[w.Minus90=23]="Minus90",w[w.Opposite=24]="Opposite",w[w.Upright=25]="Upright",w[w.Plus90Upright=26]="Plus90Upright",w[w.Minus90Upright=27]="Minus90Upright",w[w.Upright45=28]="Upright45",w))(Orientation||{}),Flip=(w=>(w[w.None=0]="None",w[w.Vertical=1]="Vertical",w[w.Horizontal=2]="Horizontal",w[w.Both=3]="Both",w))(Flip||{});class GraphObject{l;td;ed;Go;g;hh;Z;mt;le;_t;sd;Hs;Ft;qe;il;ah;Pi;ga;lt;jt;el;Fi;Hi;nd;ai;tc;Ut;hi;sl;u2;od;constructor(){GSet.vi(this),this.l=30723,this._t=1,this.sd="",this.Hs=null,this.Ft=null,this.mt=new Point(NaN,NaN).w(),this.qe=Size.xw,this.il=new Transform,this.ah=new Transform,this.Pi=null,this.ga=1,this.lt=1,this.jt=0,this.el=Margin.qg,this.le=new Rect(NaN,NaN,NaN,NaN).w(),this.Fi=new Rect(NaN,NaN,NaN,NaN).w(),this.Hi=new Rect(0,0,NaN,NaN).w(),this.nd=null,this.td=null,this.Z=null,this.ai=Spot.Default,this.tc=Spot.Default,this.ed=0,this.Go=0,this.Ut=null,this.g=null,this.hh=null,this.hi=null,this.u2=null,this.sl=null,this.od=null}cloneProtected(t){t.l=(this.l|2048|4096)&-32769,t._t=this._t,t.sd=this.sd,t.Ft=this.Ft,t.mt.c(this.mt),t.qe=this.qe.L(),this.Pi!==null?t.Pi=this.Pi.copy():t.Pi=null,t.lt=this.lt,t.jt=this.jt,t.el=this.el.L(),t.le.c(this.le),t.Fi.c(this.Fi),t.Hi.c(this.Hi),t.td=this.td,this.Z!==null&&(t.Z=this.Z.copy()),t.ai=this.ai.L(),t.tc=this.tc.L(),t.ed=this.ed,t.Go=this.Go,this.Ut!==null&&(t.Ut=this.Ut.copy()),this.g!==null&&(this.g.wi?t.g=this.g:t.g=this.g.copy()),this.hh!==null&&(t.hh=this.hh.slice()),this.hi!==null&&(t.hi=this.hi.copy())}addCopyProperty(t){let i=this.hh;if(!Array.isArray(i))i=[],this.hh=i;else for(let e=0;e{d.data!==null&&d.d2()&&d.updateTargetBindings(i)})}}}}MF(t){this.od.delete(t)}Yo(){if(this.diagram===null)return;if(this.findBindingPanel()===null&&this.Ri!==null){const i=this.Ri.iterator;for(;i.next();){const e=i.value;if(!e.isToTheme)continue;let s=null;const n=e.sourceName;e.isToObject&&(s=this.oL(n));let o=this;const r=e.targetId;r!==-1&&(o=this.M0(r),o===null)||(n==="/"?s=o.part:n==="."?s=o:n===".."&&(s=o.panel),e.updateTarget(o,s))}}}ka(t,i){const e=this.findBindingPanel();if(e!==null){const s=this.Ri.iterator;for(;s.next();){const n=s.value;let o=null;if(n.isToObject){if(o=n.rL(e,this),o===null)continue;n.updateSource(this,o,i,null)}else if(n.isToModel){const r=t.diagram;r!==null&&!r.me&&n.updateSource(this,r.model.modelData,i,e)}else if(!n.isToTheme){const r=e.data;if(r===null)continue;const l=t.diagram;l!==null&&!l.me&&n.updateSource(this,r,i,e)}if(o===this){const r=n.targetId,l=e.M0(r);l!==null&&n.updateTarget(l,o,i)}}}}M0(t){return this.eo===t?this:null}oL(t){let i;return t===""?i=this:t==="/"?i=this:t==="."?i=this:t===".."?i=this:(i=this.part.findObject(t),i===null&&Debug&&Util.at("Binding error: missing GraphObject named "+t+" in "+this.part.toString())),i}get eo(){return this.g!==null?this.g.eo:-1}set eo(t){this.eo!==t&&(this.g===null&&(this.g=new GraphObjectTemplateSettings),this.g.eo=t)}get Ri(){return this.g!==null?this.g.Ri:null}set Ri(t){this.Ri!==t&&(this.g===null&&(this.g=new GraphObjectTemplateSettings),this.g.Ri=t)}get so(){return this.g!==null?this.g.so:null}set so(t){this.so!==t&&(this.g===null&&(this.g=new GraphObjectTemplateSettings),this.g.so=t)}raiseChanged(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}i(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}no(t,i,e,s){const n=this.le;if(n.e(t,i,e,s),this.lt!==1||this.jt!==0){this.Pi===null&&(this.Pi=new Transform);const o=this.Pi;o.Bi(),this.P0(o,t,i,e,s),o.Cw(n)}}lL(t,i,e){return this.pickable===!1?!1:(e.hf(this.O),i?this.intersectsRect(t,e):this.containedInRect(t,e))}hL(t,i,e){if(this.pickable===!1)return!1;const s=this.naturalBounds,n=t.distanceSquaredPoint(i);return e?Point.distanceLineSegmentSquared(t.x,t.y,0,0,0,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,0,s.height,s.width,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,s.height,s.width,0)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,0,0,0)<=n:t.distanceSquared(0,0)<=n&&t.distanceSquared(0,s.height)<=n&&t.distanceSquared(s.width,0)<=n&&t.distanceSquared(s.width,s.height)<=n}kn(){return!0}containsPoint(t){Debug&&Util.s(t,Point,GraphObject,"containsPoint:p");const i=Point.a();i.c(t),this.O.Pt(i);const e=this.actualBounds;if(!e.isReal())return Point.o(i),!1;const s=this.diagram;if(s!==null&&s.r0){const o=s.getInputOption("extraTouchThreshold"),r=s.getInputOption("extraTouchArea"),l=r/2,h=this.naturalBounds,a=this.getDocumentScale()*s.scale,f=1/a;if(h.width*ae&&(c=t),isFinite(i)&&i>s&&(u=i);break;case 5:isFinite(t)&&t>e&&(c=t),u=0,d&&(i=1/0);break;case 4:isFinite(i)&&i>s&&(u=i),c=0,d&&(t=1/0);break}const g=this.maxSize,p=this.minSize;c>g.width&&p.widthg.height&&p.heightu.height||this.xi>u.width)&&(r=!0)}}}r?this.l|=256:this.l&=-257,this.Fi.isReal()||Util.n("Non-real actualBounds has been set. Object "+this+", actualBounds: "+this.Fi.toString()),this.ad(o,this.Fi),this.oo(!1),Rect.o(o)}uh(t,i,e,s){}commonArrange(t,i,e,s){if(this.Fi.e(t,i,e,s),this.desiredSize.isReal())return;const n=this.le,o=this.el,r=o.right+o.left,l=o.top+o.bottom,h=n.width+r,a=n.height+l;e+=r,s+=l;let f=this.qs(!0);switch(h===e&&a===s&&(f=0),f){case 0:(h>e||a>s)&&(this.pe(!0),this.wt(h>e?e:h,a>s?s:a,0,0));break;case 2:this.pe(!0),this.wt(e,s,0,0);break;case 5:this.pe(!0),this.wt(e,a,0,0);break;case 4:this.pe(!0),this.wt(h,s,0,0);break}}ad(t,i){const e=this.part;e!==null&&e.diagram!==null&&((e.selectionObject===this||e.resizeObject===this||e.rotateObject===this)&&e.g2(!0),this.T(),!t.equalsApproxClose(i)&&(e.dh(),this.A0(e)))}A0(t){this.portId!==null&&(t.g2(!0),t instanceof Node&&t.aL(this))}get shadowVisible(){return this.g!==null?this.g.L0:null}set shadowVisible(t){const i=this.shadowVisible;i!==t&&(Debug&&t!==null&&Util.t(t,"boolean",GraphObject,"shadowVisible"),this.Zt(),this.g.L0=t,this.hs(!0),this.T(),this.i("shadowVisible",i,t))}RR(t,i){const e=this.naturalBounds,s=this.ah,n=s.m11,o=s.m21,r=s.dx,l=s.m12,h=s.m22,a=s.dy;let f=0,c=0,u=f,d=c;f=u*n+d*o+r,c=u*l+d*h+a;let m=f,g=c,p=0,y=0;u=e.width+i,d=0,f=u*n+d*o+r,c=u*l+d*h+a;let x=Math.min(m,f),k=Math.min(g,c);p=Math.max(m+p,f)-x,y=Math.max(g+y,c)-k,m=x,g=k,u=e.width+i,d=e.height+i,f=u*n+d*o+r,c=u*l+d*h+a,x=Math.min(m,f),k=Math.min(g,c),p=Math.max(m+p,f)-x,y=Math.max(g+y,c)-k,m=x,g=k,u=0,d=e.height+i,f=u*n+d*o+r,c=u*l+d*h+a,x=Math.min(m,f),k=Math.min(g,c),p=Math.max(m+p,f)-x,y=Math.max(g+y,c)-k,m=x,g=k;const b=t.viewportBounds,S=b.x,M=b.y,A=b.width,C=b.height;return m>A+S||S>p+m||g>C+M||M>y+g}Ji(t,i){if(this.IR(t,i)||!this.visible)return;const e=this.opacity;if(e===0)return;let s=1;e!==1&&(s=t.globalAlpha,t.globalAlpha=s*e);let n="";this.filter!==""&&(n=t.filter,t.filter=this.filter);const o=this.O,r=this.panel;this.N0()===!0&&this.G1();const l=this.part;let h=!1,a=0;if(l&&i.getRenderingHint("drawShadows")&&(h=l.isShadowed,h)){const g=l.shadowOffset;a=Math.max(g.y,g.x)*i.scale*i.Gi}const f=this instanceof Panel&&this.nl(),c=this.Fi;if(f&&(this.fL(h,t,!1,r),this.OR(t,i),this.cL(h,t,!1,r),this.uL(h,t,!1)),f||!f&&(c.width===0||c.height===0||isNaN(c.x)||isNaN(c.y))){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}const u=this.js();if(!i.ia&&u&&this.RR(i,a)){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}let d=(this.l&256)!==0;if(t.clipInsteadOfFill&&(d=!1),this instanceof TextBlock&&(t.font=this.font),d){const g=r.kn()?r.naturalBounds:r.actualBounds;let p=Math.max(c.x,g.x),y=Math.max(c.y,g.y),x=Math.min(c.right,g.right)-p,k=Math.min(c.bottom,g.bottom)-y;const b=this.hi;if(b!==null&&(p=b.x,y=b.y,x=b.width,k=b.height),p>c.width+c.x||c.x>g.width+g.x){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}t.save(),t.beginPath(),t.rect(p,y,x,k),t.clip()}if(u){if(!l.isVisible()){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}if(h){const g=l.shadowOffset;t.shadowsSet(g.x*i.scale*this.scale*i.Gi,g.y*i.scale*this.scale*i.Gi,l.shadowBlur),t.shadowsOn(),t.shadowColor=l.shadowColor}}const m=this.naturalBounds;if(t.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.fL(h,t,u,r),this.Ft!==null&&(t.commitTransform(),this.H1(t,m,c)),this.cL(h,t,u,r),this.gh(t,i),this.uL(h,t,u),d&&(t.restore(),t.clearContextCache(this instanceof Panel)),!o.Gk()){const g=1/(o.m11*o.m22-o.m12*o.m21);t.transform(o.m22*g,-o.m12*g,-o.m21*g,o.m11*g,g*(o.m21*o.dy-o.m22*o.dx),g*(o.m12*o.dx-o.m11*o.dy))}e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n)}fL(t,i,e,s){t&&this.shadowVisible===!0?i.shadowsOn():t&&this.shadowVisible===!1&&i.shadowsOff(),t&&this.q1(s)&&this.shadowVisible===null&&i.shadowsOff()}cL(t,i,e,s){t&&(this.Ft!==null||this.q1(s))?(this.j1(!0),this.shadowVisible===null&&i.shadowsOff()):this.j1(!1)}uL(t,i,e){t&&this.m2()===!0&&i.shadowsOn(),e&&t&&i.shadowsOff()}ER(t,i,e){const s=this.part;let n=!1;s&&t.getRenderingHint("drawShadows")&&(n=s.isShadowed),i.clipInsteadOfFill&&(n=!1),this.js()&&n&&i.shadowsOn(),n&&this.shadowVisible===!0?i.shadowsOn():n&&this.shadowVisible===!1&&i.shadowsOff();const o=this.panel;if(n&&this.q1(o)&&this.shadowVisible===null&&i.shadowsOff(),i.ol){const r=t.computePixelRatio(),l=`drop-shadow(${i.shadowOffsetX/r}px ${i.shadowOffsetY/r}px ${i.shadowBlur/r/2}px ${i.shadowColor})`;this.background!==null&&e.Ft.setAttributeNS(null,"filter",l)}return n&&(this.Ft!==null||this.q1(o))?(this.j1(!0),this.shadowVisible===null&&i.shadowsOff()):this.j1(!1),n}VR(t,i,e,s){if(e.ol){const n=i.computePixelRatio(),o=`drop-shadow(${e.shadowOffsetX/n}px ${e.shadowOffsetY/n}px ${e.shadowBlur/n/2}px ${e.shadowColor})`;this.p2(t,o)}s&&this.m2()===!0&&e.shadowsOn(),this.js()&&e.shadowsOff()}q1(t){return t===null?!1:(t.nl()&&(t=t.panel),t.m2()||(t.type===Panel.Auto||t.type===Panel.Spot)&&t.findMainElement()!==this)}p2(t,i){}H1(t,i,e){const s=this.U1(),n=i.x,o=i.y,r=i.width+s,l=i.height+s;this.wn(t,this.Ft,!0,!1,i,e),this.Ft instanceof Brush&&this.Ft.type===3?(t.beginPath(),t.rect(n-s/2,o-s/2,r,l),t.fillContext(this.Ft,!1,null)):t.fillRect(n-s/2,o-s/2,r,l)}dL(t,i){let e=t.BR(this);if(e!==-1)if(e===0)if(t.svg.Ft)t.svg.Ft.after(i);else if(t.type===Panel.Table){const s=t.svg.getElementsByClassName("gojs-ts"),n=s.length!==0?s[0]:null;n!==null&&n.after(i)}else t.svg.prepend(i);else{for(;e!==0&&!t.elt(e-1).isVisibleObject();)e--;if(e===0)t.svg.prepend(i);else{const s=t.elt(e-1).svg;s!==null?s.after(i):t.svg.appendChild(i)}}}IR(t,i){if(!(t instanceof SVGContext))return!1;if(!this.visible||this.opacity===0)return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;if(this.js()&&!this.isVisible())return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;const e=this.panel,s=this.fd(t);if(this.nc(t,i,s))return this.gL(this.svg),this.svg.parentElement!==null?(this.js()&&(t.lastDrawnPart=this.svg),!0):(this.js()?(t.lastDrawnPart!==null?t.lastDrawnPart.after(this.svg):t.diagramGroup.prepend(this.svg),t.lastDrawnPart=this.svg):e&&this.dL(e,this.svg),!0);if(this.js()&&this.isShadowed){const m=this.shadowOffset;t.shadowsSet(m.x*i.scale*this.scale*i.Gi,m.y*i.scale*this.scale*i.Gi,this.shadowBlur),t.shadowsOn(),t.shadowColor=this.shadowColor}this instanceof TextBlock&&(t.font=this.font),t.currentElement=null;const n=this.O,o=this instanceof Panel,r=this instanceof Panel?this.nl():!1,l=this.svg;this.N0()===!0&&this.G1();const h=this.Fi;t.setCurrentTransform(1,0,0,1,0,0),t.outerGroup=!1,s&&(t.outerGroup=!0,o&&r?(t.newGroup(1,0,0,1,0,0),this.svg=t.lastCreatedElement):o?(t.newGroup(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.svg=t.lastCreatedElement):t.newGroup(1,0,0,1,0,0));const a=this.naturalBounds;o||t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.background!==null&&(o?(r&&t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.H1(t,a,h),r&&t.setCurrentTransform(1,0,0,1,0,0)):(t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.H1(t,a,h)),t.currentElement.Ft=t.lastCreatedElement,t.currentElement.prepend(t.lastCreatedElement));const f=this.ER(i,t,t.currentElement);this.gh(t,i),o&&t.endGroup(),t.outerGroup&&t.endGroup();const c=t.surface.Qu,u=o?this.svg:t.currentElement;if(!o&&l!==null&&u!==l&&l.parentNode===this.panel.svg){const m=this.svg.getAttribute("filter");return m!==null&&u.setAttribute("filter",m),this.svg.replaceWith(u),this.svg=u,u!==null&&this.T0(t,e,h,u),this.mL(t,l),!0}if(this.svg=u,c!==null&&u===null&&t.dummyGroup(),u===null)return!0;this.T0(t,e,h,u),this.VR(u,i,t,f);const d=this.js()?this.opacity*t.globalAlpha:this.opacity;if(d!==1&&u.setAttributeNS(null,"opacity",d.toString()),this.filter!==""&&u.setAttributeNS(null,"filter",this.filter),this.js()){if(l!==null&&u!==l&&l.parentNode===t.diagramGroup){const m=l.getAttribute("filter");m!==null&&u.setAttribute("filter",m),l.replaceWith(u)}else t.lastDrawnPart?t.lastDrawnPart.after(u):t.diagramGroup.prepend(u);t.lastDrawnPart=u}else e!==null&&this.dL(e,u);return c!==null&&c(this,u),this.gL(u),!0}gL(t){const i=this,e=t.dataset;i instanceof GraphObject&&(i.portId!==null&&(e.portId=i.portId),i instanceof Panel&&(isNaN(i.itemIndex)||(e.itemIndex=i.itemIndex.toString()),i instanceof Part&&(e.className=Util.hn(i),i.key!==void 0&&(e.key=i.key.toString()),i.containingGroup!==null&&(e.group=i.containingGroup.key.toString()),i instanceof Link&&(i.fromNode!==null&&i.fromNode.key!==void 0&&(e.fromKey=i.fromNode.key.toString()),i.fromPortId!==""&&(e.fromPortId=i.fromPortId),i.toNode!==null&&i.toNode.key!==void 0&&(e.toKey=i.toNode.key.toString()),i.toPortId!==""&&(e.toPortId=i.toPortId)))))}T0(t,i,e,s){let n=(this.l&256)!==0;if(t.clipInsteadOfFill&&(n=!1),!n){s.removeAttributeNS(null,"clip-path"),this.mL(t,s);return}const o=i.kn()?i.naturalBounds:i.actualBounds;let r=Math.max(e.x,o.x),l=Math.max(e.y,o.y),h=Math.min(e.right,o.right)-r,a=Math.min(e.bottom,o.bottom)-l;const f=this.hi;f!==null&&(r=f.x,l=f.y,h=f.width,a=f.height);const c=s.getAttribute("clip-path");let u=null;if(c!==null&&(u=t.svg.getElementById(c.split("#")[1].slice(0,-1))),u===null){const d="CLIP"+GSet.cu++,m={id:d},g=t.makeElement("clipPath",m),p=t.makeElement("rect",{x:r,y:l,width:h,height:a});if(this instanceof Panel){const y=this.O.copy().Pw();p.setAttribute("transform",`matrix(${y.m11}, ${y.m12}, ${y.m21}, ${y.m22}, ${y.dx}, ${y.dy})`)}g.appendChild(p),t.svg.appendChild(g),s.setAttributeNS(null,"clip-path","url(#"+d+")")}else{const d=u.firstElementChild;d.setAttribute("x",r.toString()),d.setAttribute("y",l.toString()),d.setAttribute("width",h.toString()),d.setAttribute("height",a.toString())}}mL(t,i){const e=i.getAttribute("clip-path");if(e===null)return;const s=t.svg.getElementById(e.split("#")[1].slice(0,-1));s!==null&&s.remove()}zR(){if(this.svg===null)return;const t=this.svg.innerHTML.match(/url\(#((CLIP|GRAD).+?)\)/g),i=this.svg.ownerDocument;if(t!==null)for(const e of t){const s=i.getElementById(e.split("#")[1].slice(0,-1));s!==null&&s.remove()}this.svg.remove()}OR(t,i){const e=this.Fi,s=this.Hi,n=this.Ft;n!==null&&t.commitTransform(),n!==null&&(this.wn(t,n,!0,!1,s,e),n instanceof Brush&&n.type===3?(t.beginPath(),t.rect(e.x,e.y,e.width,e.height),t.fillContext(n,!1,null)):t.fillRect(e.x,e.y,e.width,e.height)),this.gh(t,i)}gh(t,i){}w2(){this.hs(!0)}nc(t,i,e){const s=this.svg;if(this.XR()){if(this.w2(),this.hs(!1),s===null)return!1;const a=this.svg.getAttribute("clip-path");if(a!==null){const f=t.svg.getElementById(a.split("#")[1].slice(0,-1));f!==null&&f.remove()}return!1}if(s===null)return!1;if(!this.visible)return s.remove(),!1;if(s.nodeName!=="g"&&e||s.nodeName==="g"&&!e)return!1;const n=this.O,o="matrix("+n.m11+", "+n.m12+", "+n.m21+", "+n.m22+", "+n.dx+", "+n.dy+")",r=this instanceof Panel,l=this instanceof Panel?this.nl():!1;if(!(r&&l))if(this instanceof Picture){const a=this.W1;t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),a!==null&&t.amendImageTransform(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]),e?s.lastElementChild.setAttributeNS(null,"transform",t.getCurrentTransform()):s.setAttributeNS(null,"transform",t.getCurrentTransform())}else if(e&&!(this instanceof Panel))if(this instanceof Shape){const a=s.getElementsByTagName("path");for(let f=0;f=.1;){if(g){for(l=o[d++%h],l-=r;l<0;)l+=o[d++%h],m=!m;g=!1}else l=o[d++%h];l>u&&(l=u);let p=Math.sqrt(l*l/(1+c*c));a<0&&(p=-p),i+=p,e+=c*p,m?t.lineTo(i,e):t.moveTo(i,e),u-=l,m=!m}}wn(t,i,e,s,n,o){let r=1,l=1;if(typeof i=="string"){e?t.fillStyle=i:t.strokeStyle=i;return}else if(i.type===1){e?t.fillStyle=i.color:t.strokeStyle=i.color;return}let h;const a=this.U1();r=n.width,l=n.height,s?(r=o.width,l=o.height):e||(r+=a,l+=a);const f=t instanceof CanvasSurfaceContext;if(f&&i.Sn&&(i.type===4||i.oc===r&&i.v1===l))h=i.Sn;else{let c=0,u=0,d=0,m=0,g=0,p=0,y=0,x=0;if(s?(y=o.x,x=o.y):e||(y-=a/2,x-=a/2),c=i.start.x*r+i.start.offsetX+y,u=i.start.y*l+i.start.offsetY+x,d=i.end.x*r+i.end.offsetX+y,m=i.end.y*l+i.end.offsetY+x,i.type===2)h=t.createLinearGradient(c,u,d,m);else if(i.type===3)p=isNaN(i.endRadius)?Math.max(r,l)/2:i.endRadius,isNaN(i.startRadius)?(g=0,p=Math.max(r,l)/2):g=i.startRadius,h=t.createRadialGradient(c,u,g,d,m,p);else if(i.type===4)try{h=t.createPattern(i.pattern,"repeat")}catch{h=null}else Util.Vi(i.type,"Brush type");if(i.type!==4){const k=i.colorStops;if(k!==null){const b=k.iterator;for(;b.next();)h.addColorStop(b.key,b.value)}}if(f&&(i.Sn=h,h!==null&&(i.oc=r,i.v1=l),h===null&&i.type===4&&i.oc!==-1)){i.oc=-1;const k=this.diagram;k!==null&&i.oc===-1&&Util.Bh(()=>{k.redraw()},600)}}e?t.fillStyle=h:t.strokeStyle=h}isContainedBy(t){return t instanceof Panel?this.YR(this,t):!1}YR(t,i){if(t===i||i===null)return!1;let e=t.panel;for(;e!==null;){if(e===i)return!0;e=e.panel}return!1}isVisibleObject(){if(!this.visible)return!1;const t=this.panel;return t!==null?t.isVisibleObject():!0}isEnabledObject(){let t=this instanceof Panel?this:this.panel;for(;t!==null&&t.isEnabled;)t=t.panel;return t===null}get enabledChanged(){return this.g!==null?this.g.D0:null}set enabledChanged(t){const i=this.enabledChanged;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"enabledChanged"),this.Zt(),this.g.D0=t,this.i("enabledChanged",i,t))}G1(){if(this.J1()===!0){const t=this.il;if(t.Bi(),!this.Fi.isReal()||!this.le.isReal()){this.cd(!1);return}if(t.Es(this.Fi.x-this.le.x,this.Fi.y-this.le.y),this.scale!==1||this.angle!==0){const i=this.naturalBounds;this.P0(t,i.x,i.y,i.width,i.height)}this.cd(!1),this.Sa(!0)}if(this.N0()===!0){const t=this.panel;if(t===null)this.ah.set(this.il),this.ga=this.scale;else if(t.Ks!==null){const i=this.ah;i.Bi(),t.kn()?i.hf(t.ah):t.panel!==null&&i.hf(t.panel.ah),i.hf(this.il),this.ga=this.scale*t.ga}this.Sa(!1)}}P0(t,i,e,s,n){if(this.lt!==1&&t.lt(this.lt),this.jt===0)return;const o=Point.a();o.setSpot(i,e,s,n,Spot.Center),t.ms(this.jt,o.x,o.y),Point.o(o)}u(t){if(this.Xo())return;t===void 0&&(t=!1),this.pe(!0),this.oo(!0);const i=this.panel;i!==null&&!t&&i.u()}rc(){this.Xo()||(this.pe(!0),this.oo(!0))}lc(t){if(this.rs())return;const i=this.panel;!t&&i!==null&&i.u(),this.oo(!0)}hd(){this.J1()===!1&&(this.cd(!0),this.Sa(!0))}b2(){this.Sa(!0)}T(){const t=this.part;t!==null&&t.T()}qs(t){const i=this.stretch,e=this.panel;if(e===null)return this.qo(i===1?0:i,t);if(e.type===Panel.Table)return this.F0(e.getRowDefinition(this.row),e.getColumnDefinition(this.column),t);if(e.type===Panel.Auto&&e.findMainElement()===this)return this.qo(2,t);if(i===1){if(e.type===Panel.Spot&&e.findMainElement()===this)return this.qo(2,t);const s=e.defaultStretch;return s===1?this.qo(0,t):this.qo(s,t)}return this.qo(i,t)}F0(t,i,e){const s=this.stretch;if(s!==1)return this.qo(s,e);let n=null,o=null;switch(t.stretch){case 1:case 5:break;case 4:o=!0;break;case 2:o=!0;break}switch(i.stretch){case 1:case 4:break;case 5:n=!0;break;case 2:n=!0;break}const r=this.panel.defaultStretch;return n===null&&(n=r===5||r===2),o===null&&(o=r===4||r===2),n===!0&&o===!0?this.qo(2,e):n===!0?this.qo(5,e):o===!0?this.qo(4,e):this.qo(0,e)}qo(t,i){if(i)return t;if(t===0)return 0;const e=this.desiredSize;if(e.isReal())return 0;const s=!isNaN(e.width),n=!isNaN(e.height),o=this.angle;if(s)if(o!==90&&o!==270){if(t===5)return 0;if(t===2)return 4}else{if(t===4)return 0;if(t===2)return 5}if(n)if(o!==90&&o!==270){if(t===4)return 0;if(t===2)return 5}else{if(t===5)return 0;if(t===2)return 4}return t}get segmentOrientation(){return this.Ut!==null?this.Ut.R0:0}set segmentOrientation(t){const i=this.segmentOrientation;i!==t&&(Debug&&Util.tt(t,Orientation,"Orientation"),this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.R0=t,this.u(),this.i("segmentOrientation",i,t),t===0&&(this.angle=0))}KR(){this.segmentOrientation=21}get segmentIndex(){return this.Ut!==null?this.Ut.I0:-1/0}set segmentIndex(t){Debug&&Util.t(t,"number",GraphObject,"segmentIndex"),t=Math.round(t);const i=this.segmentIndex;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.I0=t,this.u(),this.i("segmentIndex",i,t))}get segmentFraction(){return this.Ut!==null?this.Ut.O0:0}set segmentFraction(t){Debug&&Util.t(t,"number",GraphObject,"segmentFraction"),isNaN(t)||t<0?t=0:t>1&&(t=1);const i=this.segmentFraction;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.O0=t,this.u(),this.i("segmentFraction",i,t))}get segmentOffset(){return this.Ut!==null?this.Ut.E0:Point.Lo}set segmentOffset(t){const i=this.segmentOffset;i.equals(t)||(Debug&&Util.s(t,Point,GraphObject,"segmentOffset"),t=t.L(),this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.E0=t,this.u(),this.i("segmentOffset",i,t))}get stretch(){return this.g!==null?this.g.ro:1}set stretch(t){const i=this.stretch;i!==t&&(this.Zt(),this.g.ro=t,this.u(),this.i("stretch",i,t))}get name(){return this.g!==null?this.g.Tt:""}set name(t){const i=this.name;i!==t&&(Debug&&Util.t(t,"string",GraphObject,"name"),this.Zt(),this.g.Tt=t,this.part!==null&&this.part.V0(),this.i("name",i,t))}get opacity(){return this._t}set opacity(t){const i=this._t;if(i!==t){Util.t(t,"number",GraphObject,"opacity"),(t<0||t>1)&&Util.G(t,"0 <= value <= 1",GraphObject,"opacity"),this._t=t,this.i("opacity",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.T(s.Jh(s.actualBounds))}}get filter(){return this.sd}set filter(t){Debug&&Util.t(t,"string",GraphObject,"filter");const i=this.sd;if(i!==t){this.sd=t,this.hs(!0),this.i("filter",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.T(s.Jh(s.actualBounds))}}get visible(){return(this.l&1)!==0}set visible(t){const i=(this.l&1)!==0;if(i!==t){Debug&&Util.t(t,"boolean",GraphObject,"visible"),this.l=this.l^1,this.i("visible",i,t);const e=this.panel;e!==null?e.u():this.js()&&this.Ki(t),this.T(),this.pL()}}get pickable(){return(this.l&2)!==0}set pickable(t){const i=(this.l&2)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"pickable"),this.l=this.l^2,this.i("pickable",i,t))}get fromLinkableDuplicates(){return(this.l&4)!==0}set fromLinkableDuplicates(t){const i=(this.l&4)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"fromLinkableDuplicates"),this.l=this.l^4,this.i("fromLinkableDuplicates",i,t))}get fromLinkableSelfNode(){return(this.l&8)!==0}set fromLinkableSelfNode(t){const i=(this.l&8)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"fromLinkableSelfNode"),this.l=this.l^8,this.i("fromLinkableSelfNode",i,t))}get toLinkableDuplicates(){return(this.l&16)!==0}set toLinkableDuplicates(t){const i=(this.l&16)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"toLinkableDuplicates"),this.l=this.l^16,this.i("toLinkableDuplicates",i,t))}get toLinkableSelfNode(){return(this.l&32)!==0}set toLinkableSelfNode(t){const i=(this.l&32)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"toLinkableSelfNode"),this.l=this.l^32,this.i("toLinkableSelfNode",i,t))}get isPanelMain(){return(this.l&64)!==0}set isPanelMain(t){const i=(this.l&64)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"isPanelMain"),this.l=this.l^64,this.u(),this.i("isPanelMain",i,t))}get isActionable(){return(this.l&128)!==0}set isActionable(t){const i=(this.l&128)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"isActionable"),this.l=this.l^128,this.i("isActionable",i,t))}get background(){return this.Ft}set background(t){const i=this.Ft;i!==t&&(t!==null&&Brush.ud(t,"GraphObject.background"),t instanceof Brush&&t.w(),this.Ft=t,this.T(),this.i("background",i,t))}m2(){return(this.l&512)!==0}j1(t){t?this.l|=512:this.l&=-513}ec(){return(this.l&1024)!==0}k2(t){t?this.l|=1024:this.l&=-1025}J1(){return(this.l&2048)!==0}cd(t){t?this.l|=2048:this.l&=-2049}N0(){return(this.l&4096)!==0}Sa(t){t?this.l|=4096:this.l&=-4097}Xo(){return(this.l&8192)!==0}pe(t){t?this.l|=8192:this.l&=-8193}rs(){return(this.l&16384)!==0}oo(t){t?this.l|=16384:this.l&=-16385}XR(){return(this.l&32768)!==0}hs(t){t?this.l|=32768:this.l&=-32769}get part(){if(this.js())return this;if(this.sl!==null)return this.sl;let t=this;for(t=t.panel;t;){if(t instanceof Part)return this.sl=t,t;t=t.panel}return null}get svg(){return this.u2}set svg(t){this.u2=t}zu(){this.svg=null}get panel(){return this.Hs}Ma(t){this.Hs=t,this.svg!==null&&this.svg.remove()}get layer(){const t=this.part;return t!==null?t.layer:null}get diagram(){const t=this.part;return t!==null?t.diagram:null}get position(){return this.mt}set position(t){Debug&&Util.s(t,Point,GraphObject,"position");const i=t.x,e=t.y,s=this.mt,n=s.x,o=s.y;n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e))?(t=t.copy(),this.S2(t,n,o)&&this.i("position",new Point(n,o),t)):this.M2()}M2(){}S2(t,i,e){return this.mt=t,this.lc(),!0}Af(t,i,e){this.mt.x===t&&this.mt.y===i||(this.mt.e(t,i),this.hd())}get actualBounds(){return this.Fi}get scale(){return this.lt}set scale(t){const i=this.lt;i!==t&&(Debug&&Util.r(t,GraphObject,"scale"),t<=0&&Util.n("GraphObject.scale for "+this+" must be greater than zero, not: "+t),this.lt=t,this.u(),this.i("scale",i,t))}get angle(){return this.jt}set angle(t){const i=this.jt;if(i!==t){if(Debug&&Util.r(t,GraphObject,"angle"),t=t%360,t<0&&(t+=360),i===t)return;this.jt=t,this.pL(),this.u(),this.i("angle",i,t)}}get desiredSize(){return this.qe}set desiredSize(t){Debug&&Util.s(t,Size,GraphObject,"desiredSize");const i=t.width,e=t.height,s=this.qe,n=s.width,o=s.height;if((n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e)))&&(t=t.L(),this.qe=t,this.u(),this instanceof Shape&&this.re(),this.i("desiredSize",s,t),this.ec())){const r=this.part;r!==null&&(this.ka(r,"width"),this.ka(r,"height"))}}get width(){return this.qe.width}set width(t){const i=this.qe.width;if(i!==t&&(!isNaN(i)||!isNaN(t))){Debug&&Util.t(t,"number",GraphObject,"width");const e=this.qe,s=new Size(t,this.qe.height).w();if(this.qe=s,this.u(),this instanceof Shape&&this.re(),this.i("desiredSize",e,s),this.ec()){const n=this.part;n!==null&&this.ka(n,"width")}}}get height(){return this.qe.height}set height(t){const i=this.qe.height;if(i!==t&&(!isNaN(i)||!isNaN(t))){Debug&&Util.t(t,"number",GraphObject,"height");const e=this.qe,s=new Size(this.qe.width,t).w();if(this.qe=s,this.u(),this instanceof Shape&&this.re(),this.i("desiredSize",e,s),this.ec()){const n=this.part;n!==null&&this.ka(n,"height")}}}get minSize(){return this.g!==null?this.g.Pr:Size.lf}set minSize(t){const i=this.minSize;i.equals(t)||(Debug&&Util.s(t,Size,GraphObject,"minSize"),t=t.copy(),isNaN(t.width)&&(t.width=0),isNaN(t.height)&&(t.height=0),t.w(),this.Zt(),this.g.Pr=t,this.u(),this.i("minSize",i,t))}get maxSize(){return this.g!==null?this.g.Nr:Size.Xk}set maxSize(t){const i=this.maxSize;i.equals(t)||(Debug&&Util.s(t,Size,GraphObject,"maxSize"),t=t.copy(),isNaN(t.width)&&(t.width=1/0),isNaN(t.height)&&(t.height=1/0),t.w(),this.Zt(),this.g.Nr=t,this.u(),this.i("maxSize",i,t))}get measuredBounds(){return this.le}get naturalBounds(){return this.Hi}U1(){return 0}get margin(){return this.el}set margin(t){typeof t=="number"?t=new Margin(t):Debug&&Util.s(t,Margin,GraphObject,"margin");const i=this.el;i.equals(t)||(t=t.L(),this.el=t,this.u(),this.i("margin",i,t))}get O(){return this.J1()===!0&&this.G1(),this.il}get Ks(){return this.N0()===!0&&this.G1(),this.ah}trigger(t,i,e){let s=null;return typeof t=="string"?s=new AnimationTrigger(t,i,e):s=t,s.Ce=this,this.Ss===null&&(this.Ss=new GMap),this.Ss.set(s.propertyName,s),this}get Ss(){return this.g!==null?this.g.Ss:null}set Ss(t){this.Ss!==t&&(this.Zt(),this.g.Ss=t)}get Mr(){return this.g!==null?this.g.Mr:0}set Mr(t){this.Mr!==t&&(this.Zt(),this.g.Mr=t)}get alignment(){return this.ai}set alignment(t){const i=this.ai;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"alignment"),t.isNoSpot()&&!t.isDefault()&&Util.n("GraphObject.alignment for "+this+" must be a real Spot or Spot.Default, not: "+t),t=t.L(),this.ai=t,this.lc(),this.i("alignment",i,t))}get column(){return this.Go}set column(t){Debug&&Util.r(t,GraphObject,"column"),t=Math.round(t);const i=this.Go;i!==t&&(t<0&&Util.G(t,">= 0",GraphObject,"column"),this.Go=t,this.u(),this.i("column",i,t),this.svg!==null&&this.svg.remove())}get columnSpan(){return this.g!==null?this.g.B0:1}set columnSpan(t){Debug&&Util.t(t,"number",GraphObject,"columnSpan"),t=Math.round(t);const i=this.columnSpan;i!==t&&(t<1&&Util.G(t,">= 1",GraphObject,"columnSpan"),this.Zt(),this.g.B0=t,this.u(),this.i("columnSpan",i,t))}get row(){return this.ed}set row(t){Debug&&Util.r(t,GraphObject,"row"),t=Math.round(t);const i=this.ed;i!==t&&(t<0&&Util.G(t,">= 0",GraphObject,"row"),this.ed=t,this.u(),this.i("row",i,t),this.svg!==null&&this.svg.remove())}get rowSpan(){return this.g!==null?this.g.z0:1}set rowSpan(t){Debug&&Util.t(t,"number",GraphObject,"rowSpan"),t=Math.round(t);const i=this.rowSpan;i!==t&&(t<1&&Util.G(t,">= 1",GraphObject,"rowSpan"),this.Zt(),this.g.z0=t,this.u(),this.i("rowSpan",i,t))}get spanAllocation(){return this.g!==null?this.g.X0:null}set spanAllocation(t){const i=this.spanAllocation;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"spanAllocation"),this.Zt(),this.g.X0=t,this.u(),this.i("spanAllocation",i,t))}get alignmentFocus(){return this.tc}set alignmentFocus(t){const i=this.tc;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"alignmentFocus"),Debug&&t.isNoSpot()&&!t.isDefault()&&!(t.isNone()&&this instanceof Node)&&Util.n("GraphObject.alignmentFocus must be a real Spot or Spot.Default, not: "+t),t=t.L(),this.tc=t,this.u(),this.i("alignmentFocus",i,t))}get portId(){return this.td}set portId(t){const i=this.td;if(i!==t){Debug&&t!==null&&Util.t(t,"string",GraphObject,"portId");const e=this.part;e!==null&&!(e instanceof Node)&&Util.n("Cannot set portID on a Link: "+t);const s=e;i!==null&&s!==null&&s.P2(this),this.td=t,t!==null&&s!==null&&(s.Mn=!0,s.yL(this)),this.i("portId",i,t)}}Pa(){const t=this.part;if(t instanceof Node&&(this.portId!==null||this===t.port)){const i=t.diagram;i!==null&&!i.undoManager.isUndoingRedoing&&t.aL(this)}}pL(){const t=this.diagram;t===null||t.undoManager.isUndoingRedoing||(this instanceof Panel?this instanceof Node?this.invalidateConnectedLinks():this.walkVisualTreeFrom(this,i=>{i.Pa()}):this.Pa())}get toSpot(){return this.Z!==null?this.Z.pa:Spot.None}set toSpot(t){const i=this.toSpot;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"toSpot"),t=t.L(),this.je(),this.Z.pa=t,this.i("toSpot",i,t),this.Pa())}get toEndSegmentLength(){return this.Z!==null?this.Z.wa:10}set toEndSegmentLength(t){const i=this.toEndSegmentLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"toEndSegmentLength"),t<0&&Util.G(t,">= 0",GraphObject,"toEndSegmentLength"),this.je(),this.Z.wa=t,this.i("toEndSegmentLength",i,t),this.Pa())}get toShortLength(){return this.Z!==null?this.Z.ba:0}set toShortLength(t){const i=this.toShortLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"toShortLength"),this.je(),this.Z.ba=t,this.i("toShortLength",i,t),this.Pa())}get toLinkable(){return this.Z!==null?this.Z.Y0:null}set toLinkable(t){const i=this.toLinkable;i!==t&&(Debug&&t!==null&&Util.t(t,"boolean",GraphObject,"toLinkable"),this.je(),this.Z.Y0=t,this.i("toLinkable",i,t))}get toMaxLinks(){return this.Z!==null?this.Z.K0:1/0}set toMaxLinks(t){const i=this.toMaxLinks;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"toMaxLinks"),t<0&&Util.G(t,">= 0",GraphObject,"toMaxLinks"),this.je(),this.Z.K0=t,this.i("toMaxLinks",i,t))}get fromSpot(){return this.Z!==null?this.Z.ma:Spot.None}set fromSpot(t){const i=this.fromSpot;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"fromSpot"),t=t.L(),this.je(),this.Z.ma=t,this.i("fromSpot",i,t),this.Pa())}get fromEndSegmentLength(){return this.Z!==null?this.Z.ya:10}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"fromEndSegmentLength"),t<0&&Util.G(t,">= 0",GraphObject,"fromEndSegmentLength"),this.je(),this.Z.ya=t,this.i("fromEndSegmentLength",i,t),this.Pa())}get fromShortLength(){return this.Z!==null?this.Z.xa:0}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"fromShortLength"),this.je(),this.Z.xa=t,this.i("fromShortLength",i,t),this.Pa())}get fromLinkable(){return this.Z!==null?this.Z.U0:null}set fromLinkable(t){const i=this.fromLinkable;i!==t&&(Debug&&t!==null&&Util.t(t,"boolean",GraphObject,"fromLinkable"),this.je(),this.Z.U0=t,this.i("fromLinkable",i,t))}get fromMaxLinks(){return this.Z!==null?this.Z.G0:1/0}set fromMaxLinks(t){const i=this.fromMaxLinks;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"fromMaxLinks"),t<0&&Util.G(t,">= 0",GraphObject,"fromMaxLinks"),this.je(),this.Z.G0=t,this.i("fromMaxLinks",i,t))}get cursor(){return this.g!==null?this.g.Al:""}set cursor(t){const i=this.cursor;i!==t&&(Util.t(t,"string",GraphObject,"cursor"),this.Zt(),this.g.Al=t,this.i("cursor",i,t))}get click(){return this.g!==null?this.g.Or:null}set click(t){const i=this.click;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"click"),this.Zt(),this.g.Or=t,this.i("click",i,t))}get doubleClick(){return this.g!==null?this.g.Er:null}set doubleClick(t){const i=this.doubleClick;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"doubleClick"),this.Zt(),this.g.Er=t,this.i("doubleClick",i,t))}get contextClick(){return this.g!==null?this.g.Vr:null}set contextClick(t){const i=this.contextClick;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"contextClick"),this.Zt(),this.g.Vr=t,this.i("contextClick",i,t))}get mouseEnter(){return this.g!==null?this.g.Kr:null}set mouseEnter(t){const i=this.mouseEnter;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseEnter"),this.Zt(),this.g.Kr=t,this.i("mouseEnter",i,t))}get mouseLeave(){return this.g!==null?this.g.Ur:null}set mouseLeave(t){const i=this.mouseLeave;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseLeave"),this.Zt(),this.g.Ur=t,this.i("mouseLeave",i,t))}get mouseOver(){return this.g!==null?this.g.Br:null}set mouseOver(t){const i=this.mouseOver;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseOver"),this.Zt(),this.g.Br=t,this.i("mouseOver",i,t))}get mouseHover(){return this.g!==null?this.g.zr:null}set mouseHover(t){const i=this.mouseHover;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseHover"),this.Zt(),this.g.zr=t,this.i("mouseHover",i,t))}get mouseHold(){return this.g!==null?this.g.Xr:null}set mouseHold(t){const i=this.mouseHold;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseHold"),this.Zt(),this.g.Xr=t,this.i("mouseHold",i,t))}get mouseDragEnter(){return this.g!==null?this.g.H0:null}set mouseDragEnter(t){const i=this.mouseDragEnter;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseDragEnter"),this.Zt(),this.g.H0=t,this.i("mouseDragEnter",i,t))}get mouseDragLeave(){return this.g!==null?this.g.q0:null}set mouseDragLeave(t){const i=this.mouseDragLeave;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseDragLeave"),this.Zt(),this.g.q0=t,this.i("mouseDragLeave",i,t))}get mouseDrop(){return this.g!==null?this.g.Yr:null}set mouseDrop(t){const i=this.mouseDrop;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseDrop"),this.Zt(),this.g.Yr=t,this.i("mouseDrop",i,t))}get actionDown(){return this.g!==null?this.g.j0:null}set actionDown(t){const i=this.actionDown;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionDown"),this.Zt(),this.g.j0=t,this.i("actionDown",i,t))}get actionMove(){return this.g!==null?this.g.W0:null}set actionMove(t){const i=this.actionMove;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionMove"),this.Zt(),this.g.W0=t,this.i("actionMove",i,t))}get actionUp(){return this.g!==null?this.g.v0:null}set actionUp(t){const i=this.actionUp;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionUp"),this.Zt(),this.g.v0=t,this.i("actionUp",i,t))}get actionCancel(){return this.g!==null?this.g.J0:null}set actionCancel(t){const i=this.actionCancel;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionCancel"),this.Zt(),this.g.J0=t,this.i("actionCancel",i,t))}get toolTip(){return this.g!==null?this.g.Gr:null}set toolTip(t){const i=this.toolTip;i!==t&&(Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("GraphObject.toolTip must be an Adornment or HTMLInfo."),this.Zt(),this.g.Gr=t,this.i("toolTip",i,t))}get contextMenu(){return this.g!==null?this.g.Hr:null}set contextMenu(t){const i=this.contextMenu;i!==t&&(Debug&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("GraphObject.contextMenu must be an Adornment or HTMLInfo."),this.Zt(),this.g.Hr=t,this.i("contextMenu",i,t))}findBindingPanel(){let t=this instanceof Panel?this:this.panel;for(;t!==null;){if(t.N2())return t;t=t.panel}return null}bind(t,i,e,s){return this.hc(t,i,e,s),this}bindTwoWay(t,i,e,s){return this.hc(t,i,e,s).makeTwoWay(),this}bindModel(t,i,e,s){return this.hc(t,i,e,s).ofModel(),this}bindObject(t,i,e,s,n){return this.hc(t,i,e,s).ofObject(n),this}theme(t,i,e,s,n){return this.mh(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.mh(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.mh(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.mh(t,i,e,s,n).ofModel(),this}hc(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.Z0(n),n}mh(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.Z0(o),o}Z0(t){t.Ce=this;const i=this.findBindingPanel();i!==null&&i.wL()&&Util.n("Cannot add a Binding to a template that has already been copied: "+t),this.Ri===null&&(this.Ri=new List),this.Ri.add(t)}set(t){if(Debug)for(const i in t)(i.startsWith("_")||i.indexOf(".")!==-1)&&Util.n("Property with underscore or period passed to GraphObject.set. Did you mean to use GraphObject.attach?");return Object.assign(this,t),this}attach(t){return GraphObject.C2(this,t),this}apply(t){return t(this),this}setProperties(t){return Diagram.p0(this,t),this}static build(t,i,...e){const s=GraphObject.$0.get(t);if(typeof s=="function"){const n=s([t].concat(e));if(n instanceof GraphObject)return i&&n.setProperties(i),n}Util.n('GraphObject.build invoked object builder "'+t+'", but it did not return an Object')}static make(t,...i){let e=arguments,s=null,n=null;if(typeof t=="function")n=t;else if(typeof t=="string"){const r=GraphObject.$0.get(t);typeof r=="function"?(e=Array.prototype.slice.call(e),s=r(e),Util.Mt(s)||Util.n('GraphObject.make invoked object builder "'+t+'", but it did not return an Object')):n=root.go[t]}s===null&&((n==null||!n.constructor)&&Util.n("GraphObject.make requires a class function or GoJS class name or name of an object builder, not: "+t),s=new n);let o=1;if(s instanceof Diagram&&e.length>1){const r=s,l=e[1];(typeof l=="string"||l instanceof HTMLDivElement)&&(r.MP(l),o++)}for(let r=o;r{const i="#f5f5f5",e="#737373",s="#d4d4d4",n="#737373",o="#a3a3a3",r=2.76142374915397,l=2.761423749153969,h=new Panel(Panel.Auto,{isActionable:!0,enabledChanged:(a,f)=>{if(a instanceof Panel){const c=a.findObject("ButtonBorder");c!==null&&(f?(a._buttonFillDisabled=c.fill,c.fill=a._buttonFillNormal):(a._buttonFillNormal=c.fill,c.fill=a._buttonFillDisabled))}},cursor:"pointer"}).attach({_buttonFillNormal:i,_buttonStrokeNormal:e,_buttonFillOver:s,_buttonStrokeOver:n,_buttonFillDisabled:o}).add(new Shape("RoundedRectangle",{name:"ButtonBorder",spot1:new Spot(0,0,r,l),spot2:new Spot(1,1,-r,-l),parameter1:2,fill:i,stroke:e}));return h.mouseEnter=(a,f,c)=>{if(!f.isEnabledObject()||!(f instanceof Panel))return;const u=f.findObject("ButtonBorder");u instanceof Shape&&(f._buttonFillNormal=u.fill,u.fill=f._buttonFillOver,f._buttonStrokeNormal=u.stroke,u.stroke=f._buttonStrokeOver)},h.mouseLeave=(a,f,c)=>{if(!f.isEnabledObject()||!(f instanceof Panel))return;const u=f.findObject("ButtonBorder");u instanceof Shape&&(u.fill=f._buttonFillNormal,u.stroke=f._buttonStrokeNormal)},h}),GraphObject.defineBuilder("TreeExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_treeExpandedFigure:"MinusLine",_treeCollapsedFigure:"PlusLine",visible:!1}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.gu}).bindObject("figure","isTreeExpanded",(e,s)=>{const n=s.panel;return e?n._treeExpandedFigure:n._treeCollapsedFigure})),i.bindObject("visible","isTreeLeaf",e=>!e),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Node))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isTreeExpanded){if(!r.canCollapseTree(n))return}else if(!r.canExpandTree(n))return;e.handled=!0,n.isTreeExpanded?r.collapseTree(n):r.expandTree(n)},i}),GraphObject.defineBuilder("SubGraphExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_subGraphExpandedFigure:"MinusLine",_subGraphCollapsedFigure:"PlusLine"}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.gu}).bindObject("figure","isSubGraphExpanded",(e,s)=>{const n=s.panel;return e?n._subGraphExpandedFigure:n._subGraphCollapsedFigure})),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Group))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isSubGraphExpanded){if(!r.canCollapseSubGraph(n))return}else if(!r.canExpandSubGraph(n))return;e.handled=!0,n.isSubGraphExpanded?r.collapseSubGraph(n):r.expandSubGraph(n)},i}),GraphObject.defineBuilder("ToolTip",t=>new Adornment(Panel.Auto,{isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).add(new Shape("RoundedRectangle",{name:"Border",parameter1:1,fill:"#f5f5f5",strokeWidth:0,spot1:new Spot(0,0,4,6),spot2:new Spot(1,1,-4,-4)}))),GraphObject.defineBuilder("ContextMenu",t=>new Adornment(Panel.Vertical,{background:"#f5f5f5",isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).bindObject("background","",i=>i.adornedPart!==null&&i.hasPlaceholder()?null:"#f5f5f5")),GraphObject.defineBuilder("ContextMenuButton",t=>{const i=GraphObject.build("Button");i.stretch=5;const e=i.findObject("ButtonBorder");return e instanceof Shape&&(e.figure="Rectangle",e.strokeWidth=0,e.spot1=new Spot(0,0,4,6),e.spot2=new Spot(1,1,-4,-4)),i}),GraphObject.defineBuilder("PanelExpanderButton",t=>{const i=GraphObject.takeBuilderArgument(t,"COLLAPSIBLE"),e=GraphObject.build("Button");e.attach({_buttonExpandedFigure:"M0 0 M0 6 L4 2 8 6 M8 8",_buttonCollapsedFigure:"M0 0 M0 2 L4 6 8 2 M8 8",_buttonFillNormal:"rgba(0, 0, 0, 0)",_buttonStrokeNormal:null,_buttonFillOver:"rgba(0, 0, 0, .2)",_buttonStrokeOver:null}),e.add(new Shape({name:"ButtonIcon",strokeWidth:2}).bindObject("geometryString","visible",n=>n?e._buttonExpandedFigure:e._buttonCollapsedFigure,void 0,i));const s=e.findObject("ButtonBorder");return s instanceof Shape&&(s.stroke=null,s.fill="rgba(0, 0, 0, 0)"),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=o.diagram;if(r===null||r.isReadOnly)return;let l=o.findBindingPanel();if(l===null&&(l=o.part),l!==null){const h=l.findObject(i);h!==null&&(n.handled=!0,r.startTransaction("Collapse/Expand Panel"),h.visible=!h.visible,r.commitTransaction("Collapse/Expand Panel"))}},e}),GraphObject.defineBuilder("CheckBoxButton",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("Button",{desiredSize:new Size(14,14)});e.attach({"ButtonBorder.spot1":new Spot(0,0,1,1),"ButtonBorder.spot2":new Spot(1,1,-1,-1)});const s=new Shape({name:"ButtonIcon",geometryString:"M0 0 M0 8.85 L4.9 13.75 16.2 2.45 M16.2 16.2",strokeWidth:2,stretch:2,geometryStretch:6,visible:!1});return i!==""&&s.bindTwoWay("visible",i),e.add(s),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=n.diagram;if(r===null||r.isReadOnly||i!==""&&r.model.isReadOnly)return;n.handled=!0;const l=o.findObject("ButtonIcon");r.startTransaction("checkbox"),l!==null&&(l.visible=!l.visible),typeof o._doClick=="function"&&o._doClick(n,o),r.commitTransaction("checkbox")},e}),GraphObject.defineBuilder("CheckBox",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("CheckBoxButton",{name:"Button",isActionable:!1,margin:new Margin(0,1,0,0)},i),s=new Panel("Horizontal",{isActionable:!0,cursor:e.cursor,margin:new Margin(1),mouseEnter:e.mouseEnter,mouseLeave:e.mouseLeave,click:e.click}).attach({_buttonFillNormal:e._buttonFillNormal,_buttonStrokeNormal:e._buttonStrokeNormal,_buttonFillOver:e._buttonFillOver,_buttonStrokeOver:e._buttonStrokeOver,_buttonFillDisabled:e._buttonFillDisabled,_buttonClick:e.click});return s.add(e),e.mouseEnter=null,e.mouseLeave=null,e.click=null,s})}}class GraphObjectTemplateSettings{wi;Tt;eo;Ri;so;Ws;Al;Or;Er;Vr;Kr;Ur;Br;zr;Xr;H0;q0;Yr;j0;W0;v0;J0;Gr;Hr;D0;X0;Ss;Pr;Nr;ro;z0;B0;Mr;L0;Q0;_0;constructor(){this.wi=!1,this.Tt="",this.eo=-1,this.Ri=null,this.so=null,this.Ws=null,this.Al="",this.Or=null,this.Er=null,this.Vr=null,this.Kr=null,this.Ur=null,this.Br=null,this.zr=null,this.Xr=null,this.H0=null,this.q0=null,this.Yr=null,this.j0=null,this.W0=null,this.v0=null,this.J0=null,this.Gr=null,this.Hr=null,this.D0=null,this.X0=null,this.Ss=null,this.Pr=Size.lf,this.Nr=Size.Xk,this.ro=1,this.z0=1,this.B0=1,this.Mr=0,this.L0=null,this.Q0=null,this._0="category"}copy(){const t=new GraphObjectTemplateSettings;return t.Tt=this.Tt,t.eo=this.eo,t.Ri=this.Ri,t.Ws=this.Ws,t.Al=this.Al,t.Or=this.Or,t.Er=this.Er,t.Vr=this.Vr,t.Kr=this.Kr,t.Ur=this.Ur,t.Br=this.Br,t.zr=this.zr,t.Xr=this.Xr,t.H0=this.H0,t.q0=this.q0,t.Yr=this.Yr,t.j0=this.j0,t.W0=this.W0,t.v0=this.v0,t.J0=this.J0,t.Gr=this.Gr,t.Hr=this.Hr,t.D0=this.D0,t.X0=this.X0,t.Ss=this.Ss,t.Pr=this.Pr.L(),t.Nr=this.Nr.L(),t.ro=this.ro,t.z0=this.z0,t.B0=this.B0,t.Mr=this.Mr,t.L0=this.L0,t.Q0=this.Q0,t._0=this._0,t}}class STransform{m;constructor(){this.m=[1,0,0,1,0,0]}copy(){const t=new STransform;return t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5],t}translate(t,i){this.m[4]+=this.m[0]*t+this.m[2]*i,this.m[5]+=this.m[1]*t+this.m[3]*i}scale(t,i){this.m[0]*=t,this.m[1]*=t,this.m[2]*=i,this.m[3]*=i}rotate(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return;this.translate(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m[0]*s+this.m[2]*n,r=this.m[1]*s+this.m[3]*n,l=this.m[0]*-n+this.m[2]*s,h=this.m[1]*-n+this.m[3]*s;this.m[0]=o,this.m[1]=r,this.m[2]=l,this.m[3]=h,this.translate(-i,-e)}}class SGradient{type;x1;y1;r1;x2;y2;r2;colors;pattern;constructor(t){this.type=t,this.x1=0,this.y1=0,this.r1=0,this.x2=0,this.y2=0,this.r2=0,this.colors=[],this.pattern=null}addColorStop(t,i){this.colors.push({offset:t,color:i})}}class SVGSurface{Bt;di;ua;Qu;A2;constructor(t,i,e){const s=i===void 0?root.document:i;this.ua=s,this.A2="http://www.w3.org/2000/svg";const n="http://www.w3.org/2000/xmlns/";s!==void 0&&(this.Bt=this.makeElement("svg",{width:"1px",height:"1px",viewBox:"0 0 1 1"}),this.style.display="block",this.style.letterSpacing="normal",this.style.wordSpacing="normal",e||(this.style.position="absolute"),this.Bt.setAttributeNS(n,"xmlns",this.A2),this.Bt.setAttributeNS(n,"xmlns:xlink","http://www.w3.org/1999/xlink")),this.Qu=null,this.di=new SVGContext(this,e)}resize(t,i,e,s){return this.width!==t||this.height!==i?(this.width=t,this.height=i,this.style.width=e+"px",this.style.height=s+"px",this.Bt.setAttributeNS(null,"width",e+"px"),this.Bt.setAttributeNS(null,"height",s+"px"),this.Bt.setAttributeNS(null,"viewBox","0 0 "+e+" "+s),this.di.L2.firstElementChild.setAttributeNS(null,"width",e+"px"),this.di.L2.firstElementChild.setAttributeNS(null,"height",s+"px"),!0):!1}makeElement(t,i,e){const s=this.ua.createElementNS(this.A2,t);if(Util.Mt(i))for(const n in i)s.setAttributeNS(n==="href"?"http://www.w3.org/1999/xlink":"",n,i[n]);return e!==void 0&&(s.textContent=e),s}getBoundingClientRect(){return this.Bt.getBoundingClientRect()}focus(){this.Bt.focus()}get width(){return this.Bt.width.baseVal.value}set width(t){this.Bt.setAttribute("width",t+"px")}get height(){return this.Bt.height.baseVal.value}set height(t){this.Bt.setAttribute("height",t+"px")}dispose(){this.ua=null}get style(){return this.Bt.style}}class SVGContext{ac;fc;Pn;Ii;We;fillStyle;font;globalAlpha;lineCap;lineDashOffset;lineJoin;lineWidth;miterLimit;shadowBlur;shadowColor;shadowOffsetX;shadowOffsetY;strokeStyle;textAlign;imageSmoothingEnabled;clipInsteadOfFill;lastCreatedElement;cc;uc;surface;svg;L2;xL;$1;jo;ph;Na;currentElement;clipPathGroup;diagramGroup;lastDrawnPart;currentPath;outerGroup;pathAttributes;ol;Tr;filter;partClipRect;constructor(t,i){this.surface=t,this.svg=t.Bt,this.cc=[],this.uc=[],this.fillStyle="#000000",this.font="10px sans-serif",this.globalAlpha=1,this.lineCap="butt",this.lineDashOffset=0,this.lineJoin="miter",this.lineWidth=1,this.miterLimit=10,this.shadowBlur=0,this.shadowColor="rgba(0, 0, 0, 0)",this.shadowOffsetX=0,this.shadowOffsetY=0,this.ol=!1,this.strokeStyle="#000000",this.textAlign="start",this.clipInsteadOfFill=!1,this.ac=0,this.fc=0,this.Pn=0,this.lastCreatedElement=null,this.currentElement=null,this.Ii=[],this.pathAttributes={},this.$1=!1,this.jo=null,this.ph=0,this.We=new STransform,this.clipPathGroup=this.newGroup2(),this.diagramGroup=this.newGroup2("gojs-diagram"),this.lastDrawnPart=null,this.currentPath=null;const e=GSet.cu++,s=this.makeElement("clipPath",{id:"mainClip"+e}),n={x:0,y:0,width:t.width,height:t.height};s.appendChild(this.makeElement("rect",n)),this.L2=s,this.svg.appendChild(this.clipPathGroup),this.clipPathGroup.appendChild(this.diagramGroup),this.svg.appendChild(s),this.clipPathGroup.setAttributeNS(null,"clip-path","url(#mainClip"+e+")"),this.xL={},this.Tr=!!i,this.filter="",this.partClipRect=null}setDiagramPosScale(t,i,e,s,n,o){this.diagramGroup===void 0?this.newGroup(t,i,e,s,n,o):this.diagramGroup.setAttribute("transform","matrix("+t+", "+i+", "+e+", "+s+", "+n+", "+o+")")}resetInnerSVG(){this.diagramGroup!==null&&(this.diagramGroup.innerHTML="")}arc(t,i,e,s,n,o,r,l){const h=2*Math.PI,a=1e-6,f=h-a,c=e*Math.cos(s),u=e*Math.sin(s),d=t+c,m=i+u,g=o?0:1;let p=o?s-n:n-s;(Math.abs(r-d)>a||Math.abs(l-m)>a)&&this.Ii.push(["L",d,+m]),p<0&&(p=p%h+h),p>f?(this.Ii.push(["A",e,e,0,1,g,t-c,i-u]),this.Ii.push(["A",e,e,0,1,g,d,m])):p>a&&this.Ii.push(["A",e,e,0,+(p>=Math.PI),g,t+e*Math.cos(n),i+e*Math.sin(n)])}beginPath(){this.Ii=[],this.pathAttributes={stroke:"none",fill:"none"}}endPath(t){this.qR(this.Ii,this.We,t||0)}bezierCurveTo(t,i,e,s,n,o){this.Ii.push(["C",t,i,e,s,n,o])}clearRect(t,i,e,s){}clip(){this.pathAttributes.clipPath=!0}closePath(){this.Ii.push(["z"])}createLinearGradient(t,i,e,s){const n=new SGradient("linear");return n.x1=t,n.y1=i,n.x2=e,n.y2=s,n}createPattern(t,i){let e="";t instanceof HTMLCanvasElement&&(e=t.toDataURL()),t instanceof HTMLImageElement&&(e=t.getAttribute("src"));const s=this.xL;if(s[e])return"url(#"+s[e]+")";const n="PATTERN"+GSet.cu++,o={width:t.width,height:t.height,id:n,patternUnits:"userSpaceOnUse"},r={x:0,y:0,width:t.width,height:t.height,href:e},l=this.makeElement("pattern",o);return l.appendChild(this.makeElement(Diagram.img,r)),this.svg.appendChild(l),s[e]=n,"url(#"+n+")"}createRadialGradient(t,i,e,s,n,o){const r=new SGradient("radial");return r.x1=t,r.y1=i,r.r1=e,r.x2=s,r.y2=n,r.r2=o,r}amendImageTransform(t,i,e,s,n,o,r,l){const h=r/e,a=l/s;(n!==0||o!==0)&&this.We.translate(n,o),(h!==1||a!==1)&&this.We.scale(h,a),(t!==0||i!==0)&&this.We.translate(-t,-i)}drawImage(t,i,e,s,n,o,r,l,h){let a="";t instanceof HTMLCanvasElement&&(a=t.toDataURL()),t instanceof HTMLImageElement&&(a=t.getAttribute("src"));const f=t instanceof HTMLImageElement?t.naturalWidth:t.width,c=t instanceof HTMLImageElement?t.naturalHeight:t.height;s===void 0&&(o=i,r=e,l=s=f,h=n=c),s=s||0,n=n||0,o=o||0,r=r||0,l=l||0,h=h||0,this.amendImageTransform(i,e,s,n,o,r,l,h);const u={x:0,y:0,width:f||s,height:c||n,href:a};!Geo.q(s,l)||!Geo.q(n,h)?u.preserveAspectRatio="none":a.toLowerCase().indexOf(".svg")===-1&&a.toLowerCase().indexOf("data:image/svg")===-1&&(u.preserveAspectRatio="xMidYMid slice"),(i!==0||e!==0||s!==f||n!==c)&&(s+=i,n+=e,u["clip-path"]=`path('M ${i},${e} L ${s} ${e} L ${s} ${n} L ${i} ${n} z')`),this.processCommon(Diagram.img,u,this.We),this.dd(Diagram.img,u)}fill(t,i){t&&(this.pathAttributes["fill-rule"]="evenodd"),this.setFill(this.pathAttributes)}fillContext(t,i,e){this.clipInsteadOfFill?this.clip():this.fill(i,e)}fillRect(t,i,e,s){this.addRect("fill",[t,i,e,s],this.We)}fillBackground(t,i,e,s){const n={x:t,y:i,width:e,height:s};this.processCommon("fill",n,this.We),this.setFill(n),this.svg.prepend(this.makeElement("rect",n))}fillText(t,i,e){this.addText("fill",[t,i,e],this.We)}lineTo(t,i){this.Ii.push(["L",t,i])}moveTo(t,i){this.Ii.push(["M",t,i])}quadraticCurveTo(t,i,e,s){this.Ii.push(["Q",t,i,e,s])}rect(t,i,e,s){this.Ii.push(["M",t,i],["L",t+e,i],["L",t+e,i+s],["L",t,i+s],["z"])}restore(){this.We=this.cc.pop(),this.Ii=this.cc.pop();const t=this.cc.pop();this.fillStyle=t.fillStyle,this.font=t.font,this.globalAlpha=t.globalAlpha,this.lineCap=t.lineCap,this.lineDashOffset=t.lineDashOffset,this.lineJoin=t.lineJoin,this.lineWidth=t.lineWidth,this.miterLimit=t.miterLimit,this.shadowBlur=t.shadowBlur,this.shadowColor=t.shadowColor,this.shadowOffsetX=t.shadowOffsetX,this.shadowOffsetY=t.shadowOffsetY,this.strokeStyle=t.strokeStyle,this.textAlign=t.textAlign,this.partClipRect=t.partClipRect}save(){const t={fillStyle:this.fillStyle,font:this.font,globalAlpha:this.globalAlpha,lineCap:this.lineCap,lineDashOffset:this.lineDashOffset,lineJoin:this.lineJoin,lineWidth:this.lineWidth,miterLimit:this.miterLimit,shadowBlur:this.shadowBlur,shadowColor:this.shadowColor,shadowOffsetX:this.shadowOffsetX,shadowOffsetY:this.shadowOffsetY,strokeStyle:this.strokeStyle,textAlign:this.textAlign,partClipRect:this.partClipRect};this.cc.push(t);const i=[];for(let e=0;eh.offset>a.offset?1:-1);for(let h=0;h0&&this.uc[this.uc.length-1].setAttributeNS(null,"clip-path",'path("'+s+'")');return}if(n.d=s,this.processCommon("",n,i),this.currentPath!==null){const r=this.currentPath;if(r.nodeName!=="g")for(const l in n)l!=="transform"&&r.setAttributeNS(null,l,n[l]);else{const l=r.getElementsByTagName("path");for(const h in n)h!=="transform"&&l[e].setAttributeNS(null,h,n[h])}}else this.dd("path",n)}jR(t){const i=[];for(let e=0;es?(this.scale(s/n,1),this.translate((n-s)/2,0)):s>n&&(this.scale(1,n/s),this.translate(0,(s-n)/2)),this.fillOrClip(i,e),n>s?(this.translate(-(n-s)/2,0),this.scale(1/(s/n),1)):s>n&&(this.translate(0,-(s-n)/2),this.scale(1,1/(n/s))),!0}strokeContext(){this.tp||this.stroke()}fillOrClip(t,i){this.tp?this.clip(i):this.fill(t,i)}get clipInsteadOfFill(){return this.tp}set clipInsteadOfFill(t){this.tp=t}shadowsSet(t,i,e){this.ac=t,this.fc=i,this.Pn=e}shadowsOff(){this.ol=!1,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0}shadowsOn(){this.ol=!0,this.shadowOffsetX=this.ac,this.shadowOffsetY=this.fc,this.shadowBlur=this.Pn}enableDash(t,i){const e=this.Y;e.setLineDash!==void 0&&(e.setLineDash(t),e.lineDashOffset=i)}disableDash(){const t=this.Y;t.setLineDash!==void 0&&(t.setLineDash(CanvasSurfaceContext.EmptyArray),t.lineDashOffset=0)}clearContextCache(t){t&&(this.Q1=""),this._1="",this.tb=""}removePartFromView(t){}static EmptyArray=Object.freeze([])}var BrushType=(w=>(w[w.Solid=1]="Solid",w[w.Linear=2]="Linear",w[w.Radial=3]="Radial",w[w.Pattern=4]="Pattern",w))(BrushType||{}),ColorSpace=(w=>(w[w.Lab=1]="Lab",w[w.HSL=2]="HSL",w[w.Oklch=3]="Oklch",w))(ColorSpace||{});class ColorNumbers{n0;n1;n2;n3;constructor(){this.n0=0,this.n1=0,this.n2=0,this.n3=0}}class Brush{f;st;Ca;li;xs;ip;ep;Nn;sp;Sn;oc;v1;constructor(t,i){if(GSet.vi(this),this.f=!1,t===void 0)this.st=1,this.Ca="black";else if(typeof t=="string"){const s=Util.zh(BrushType,t);s!==null?(this.st=s,this.Ca="black"):(this.st=1,Debug&&!Brush.isValidColor(t)&&Util.n('Color "'+t+'" is not a valid color string for Brush constructor'),this.Ca=t)}else Debug&&Util.tt(t,BrushType,"BrushType"),this.st=t,this.Ca="black";const e=this.st;if(e===2?(this.li=Spot.TopCenter,this.xs=Spot.BottomCenter):e===3?(this.li=Spot.Center,this.xs=Spot.Center):(this.li=Spot.None,this.xs=Spot.None),this.ip=0,this.ep=NaN,this.Nn=null,this.sp=null,this.Sn=null,this.oc=0,this.v1=0,i){const s={};for(const n in i)isFinite(parseFloat(n))?this.addColorStop(parseFloat(n),i[n]):s[n]=i[n];Object.assign(this,s)}}copy(){const t=new Brush;return t.st=this.st,t.Ca=this.Ca,t.li=this.li.L(),t.xs=this.xs.L(),t.ip=this.ip,t.ep=this.ep,this.Nn!==null&&(t.Nn=this.Nn.copy()),t.sp=this.sp,t}w(){return this.f=!0,this.Nn!==null&&this.Nn.w(),this}ct(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this.Nn!==null&&this.Nn.ct(),this}fi(t){t in BrushType?this.type=t:Util.ur(this,t)}toString(){let t="Brush(";if(this.type===1)t+=this.color;else if(this.type===2?t+="Linear ":this.type===3?t+="Radial ":this.type===4?t+="Pattern ":t+="(unknown) ",t+=this.start+" "+this.end,this.colorStops!==null){const i=this.colorStops.iterator;for(;i.next();){const e=i.key,s=i.value;t+=" "+e+":"+s}}return t+=")",t}addColorStop(t,i){return this.f&&Util.F(this),(typeof t!="number"||!isFinite(t)||t>1||t<0)&&Util.G(t,"0 <= loc <= 1",Brush,"addColorStop:loc"),Util.t(i,"string",Brush,"addColorStop:color"),Debug&&!Brush.isValidColor(i)&&Util.n('Color "'+i+'" is not a valid color string for Brush.addColorStop'),this.Nn===null&&(this.Nn=new GMap),this.Nn.set(t,i),this.st===1&&(this.type=2),this.Sn=null,this}get type(){return this.st}set type(t){this.f&&Util.F(this,t),Util.tt(t,BrushType,"BrushType"),this.st=t,this.start.isNoSpot()&&(t===2?this.start=Spot.TopCenter:t===3&&(this.start=Spot.Center)),this.end.isNoSpot()&&(t===2?this.end=Spot.BottomCenter:t===3&&(this.end=Spot.Center)),this.Sn=null}get color(){return this.Ca}set color(t){this.f&&Util.F(this,t),Debug&&!Brush.isValidColor(t)&&Util.n('Color "'+t+'" is not a valid color string for Brush.color'),this.Ca=t,this.Sn=null}get start(){return this.li}set start(t){this.f&&Util.F(this,t),Util.s(t,Spot,Brush,"start"),this.li=t.L(),this.Sn=null}get end(){return this.xs}set end(t){this.f&&Util.F(this,t),Util.s(t,Spot,Brush,"end"),this.xs=t.L(),this.Sn=null}get startRadius(){return this.ip}set startRadius(t){this.f&&Util.F(this,t),Util.r(t,Brush,"startRadius"),t<0&&Util.G(t,">= zero",Brush,"startRadius"),this.ip=t,this.Sn=null}get endRadius(){return this.ep}set endRadius(t){this.f&&Util.F(this,t),Util.r(t,Brush,"endRadius"),t<0&&Util.G(t,">= zero",Brush,"endRadius"),this.ep=t,this.Sn=null}get colorStops(){return this.Nn}set colorStops(t){this.f&&Util.F(this,t),Debug&&Util.s(t,GMap,Brush,"colorStops"),this.Nn=t,this.Sn=null}get pattern(){return this.sp}set pattern(t){this.f&&Util.F(this,t),this.sp=t,this.Sn=null}static randomColor(t,i){t===void 0&&(t=128),Debug&&(Util.r(t,Brush,"randomColor:min"),(t<0||t>255)&&Util.G(t,"0 <= min <= 255",Brush,"randomColor:min")),i===void 0&&(i=Math.max(t,255)),Debug&&(Util.r(i,Brush,"randomColor:max"),(i255)&&Util.G(i,"min <= max <= 255",Brush,"randomColor:max"));const e=Math.abs(i-t);let s=Math.floor(t+Math.random()*e).toString(16),n=Math.floor(t+Math.random()*e).toString(16),o=Math.floor(t+Math.random()*e).toString(16);return s.length<2&&(s="0"+s),n.length<2&&(n="0"+n),o.length<2&&(o="0"+o),"#"+s+n+o}static isValidColor(t){return root.CSS?root.CSS.supports("color",t):!0}static lighten(t){return Brush.lightenBy(t)}lightenBy(t,i){this.f&&Util.F(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Eo(this.color),this.color=Brush.gd(e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Eo(n.value),this.addColorStop(n.key,Brush.gd(e,s))}return this}static lightenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Eo(t),Brush.gd(s,n)}static darken(t){return Brush.darkenBy(t)}darkenBy(t,i){this.f&&Util.F(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Eo(this.color),this.color=Brush.gd(-e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Eo(n.value),this.addColorStop(n.key,Brush.gd(-e,s))}return this}static darkenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Eo(t),Brush.gd(-s,n)}static mix(t,i,e){Brush.Eo(t);const s=Brush.W.n0,n=Brush.W.n1,o=Brush.W.n2,r=Brush.W.n3;Brush.Eo(i),e===void 0&&(e=.5);const l=Math.round((Brush.W.n0-s)*e+s),h=Math.round((Brush.W.n1-n)*e+n),a=Math.round((Brush.W.n2-o)*e+o),f=Math.round((Brush.W.n3-r)*e+r);return`rgba(${l}, ${h}, ${a}, ${f})`}isDark(){if(this.type===1)return Brush.isDark(this.color);if((this.type===2||this.type===3)&&this.colorStops!==null){const t=this.colorStops;if(this.type===3)return Brush.isDark(t.first().value);if(t.get(.5)!==null)return Brush.isDark(t.get(.5));if(t.count===2){const l=t.toArray();return Brush.isDark(Brush.mix(l[0].value,l[1].value))}const i=t.iterator;let e=-1,s=-1,n=1,o=1;for(;i.next();){const l=i.key,h=Math.abs(.5-i.key);n>o&&h=n&&hs){let l=e;e=s,s=l,l=n,n=o,o=l}const r=s-e;return Brush.isDark(Brush.mix(t.get(e),t.get(s),1-o/r))}return!1}static isDark(t){return t?t instanceof Brush?t.isDark():(Brush.Eo(t),(299*Brush.W.n0+587*Brush.W.n1+114*Brush.W.n2)/1e3<128):!1}static gd(t,i){switch(i){case 1:return Brush.WR(),Brush.lo.n0=Math.min(100,Math.max(0,Brush.lo.n0+100*t)),Brush.vR(),"rgba("+Brush.W.n0+", "+Brush.W.n1+", "+Brush.W.n2+", "+Brush.W.n3+")";case 2:return Brush.UM(),Brush.Yi.n2=Math.min(100,Math.max(0,Brush.Yi.n2+100*t)),"hsla("+Brush.Yi.n0+", "+Brush.Yi.n1+"%, "+Brush.Yi.n2+"%, "+Brush.Yi.n3+")";case 3:return Brush.JR(),Brush.ho.n0=Math.min(100,Math.max(0,Brush.ho.n0+100*t)),Brush.ZR(),"rgba("+Brush.W.n0+", "+Brush.W.n1+", "+Brush.W.n2+", "+Brush.W.n3+")";default:Util.n("Unknown color space: "+i)}}static Eo(t){const i=Brush.rl;if(i===null)return;i.clearRect(0,0,1,1),i.fillStyle="#000000";const e=i.fillStyle;if(i.fillStyle=t,i.fillStyle!==e){i.fillRect(0,0,1,1);const s=i.getImageData(0,0,1,1).data;Brush.W.n0=s[0],Brush.W.n1=s[1],Brush.W.n2=s[2],Brush.W.n3=s[3]/255}else{i.fillStyle="#FFFFFF";const s=i.fillStyle;i.fillStyle=t,i.fillStyle===s&&Debug&&Util.n('Color "'+t+'" is not a valid color string for RGBA color conversion'),Brush.W.n0=0,Brush.W.n1=0,Brush.W.n2=0,Brush.W.n3=1}}static UM(){const t=Brush.W.n0/255,i=Brush.W.n1/255,e=Brush.W.n2/255,s=Math.max(t,i,e),n=Math.min(t,i,e),o=s-n;let r,l;const h=(s+n)/2;if(o===0)r=l=0;else{switch(s){case t:r=(i-e)/o%6;break;case i:r=(e-t)/o+2;break;case e:r=(t-i)/o+4;break}r*=60,r<0&&(r+=360),l=o/(1-Math.abs(2*h-1))}Brush.Yi.n0=Math.round(r),Brush.Yi.n1=Math.round(l*100),Brush.Yi.n2=Math.round(h*100),Brush.Yi.n3=Brush.W.n3}static mE(){const t=Brush.Yi.n0,i=Brush.Yi.n1/100,e=Brush.Yi.n2/100;let s,n,o;const r=(1-Math.abs(2*e-1))*i,l=t/60,h=r*(1-Math.abs(l%2-1));l>=0&&l<1?(s=r,n=h,o=0):l>=1&&l<2?(s=h,n=r,o=0):l>=2&&l<3?(s=0,n=r,o=h):l>=3&&l<4?(s=0,n=h,o=r):l>=4&&l<5?(s=h,n=0,o=r):l>=5&&l<6&&(s=r,n=0,o=h);const a=e-.5*r;s+=a,n+=a,o+=a,Brush.W.n0=Math.round(s*255),Brush.W.n1=Math.round(n*255),Brush.W.n2=Math.round(o*255),Brush.W.n3=Brush.Yi.n3}static WR(){Brush.bL(),Brush.$R()}static vR(){Brush.QR(),Brush.kL()}static T2(t){return t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}static D2(t){return t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055}static bL(){const t=Brush.T2(Brush.W.n0),i=Brush.T2(Brush.W.n1),e=Brush.T2(Brush.W.n2);Brush.zt.n0=.4124564*t+.3575761*i+.1804375*e,Brush.zt.n1=.2126729*t+.7151522*i+.072175*e,Brush.zt.n2=.0193339*t+.119192*i+.9503041*e,Brush.zt.n3=Brush.W.n3}static kL(){const t=3.2404542*Brush.zt.n0+-1.5371385*Brush.zt.n1+-.4985314*Brush.zt.n2,i=-.969266*Brush.zt.n0+1.8760108*Brush.zt.n1+.041556*Brush.zt.n2,e=.0556434*Brush.zt.n0+-.2040259*Brush.zt.n1+1.0572252*Brush.zt.n2;Brush.W.n0=Brush.D2(t)*255,Brush.W.n1=Brush.D2(i)*255,Brush.W.n2=Brush.D2(e)*255,Brush.W.n3=Brush.zt.n3,Brush.W.n0=Math.round(Brush.W.n0),Brush.W.n0>255?Brush.W.n0=255:Brush.W.n0<0&&(Brush.W.n0=0),Brush.W.n1=Math.round(Brush.W.n1),Brush.W.n1>255?Brush.W.n1=255:Brush.W.n1<0&&(Brush.W.n1=0),Brush.W.n2=Math.round(Brush.W.n2),Brush.W.n2>255?Brush.W.n2=255:Brush.W.n2<0&&(Brush.W.n2=0)}static F2=216/24389;static ib=24389/27;static md=[95.047,100,108.883];static R2(t){return t>Brush.F2?Math.pow(t,1/3):(Brush.ib*t+16)/116}static $R(){const t=Brush.R2(Brush.zt.n0*100/Brush.md[0]),i=Brush.R2(Brush.zt.n1*100/Brush.md[1]),e=Brush.R2(Brush.zt.n2*100/Brush.md[2]);Brush.lo.n0=116*i-16,Brush.lo.n1=500*(t-i),Brush.lo.n2=200*(i-e),Brush.lo.n3=Brush.zt.n3}static SL(t){const i=t*t*t;return i>Brush.F2?i:(116*t-16)/Brush.ib}static QR(){const t=(Brush.lo.n0+16)/116,i=Brush.lo.n1/500+t,e=t-Brush.lo.n2/200;Brush.zt.n0=Brush.md[0]/100*Brush.SL(i),Brush.zt.n1=Brush.md[1]/100*(Brush.lo.n0>Brush.ib*Brush.F2?Math.pow(t,3):Brush.lo.n0/Brush.ib),Brush.zt.n2=Brush.md[2]/100*Brush.SL(e),Brush.zt.n3=Brush.lo.n3}static _R(){let t=.8190224*Brush.zt.n0+.3619062*Brush.zt.n1+-.1288737*Brush.zt.n2,i=.03298366*Brush.zt.n0+.9292868*Brush.zt.n1+.03614466*Brush.zt.n2,e=.04817719*Brush.zt.n0+.2642395*Brush.zt.n1+.6335478*Brush.zt.n2;t=Math.cbrt(t),i=Math.cbrt(i),e=Math.cbrt(e),Brush.gi.n0=.2104542*t+.7936177*i+-.004072046*e,Brush.gi.n1=1.977998*t+-2.428592*i+.4505937*e,Brush.gi.n2=.02590403*t+.7827717*i+-.8086757*e,Brush.gi.n3=Brush.zt.n3,Brush.gi.n0*=100}static tI(){Brush.gi.n0/=100;let t=.9999999*Brush.gi.n0+.3963377*Brush.gi.n1+.2158037*Brush.gi.n2,i=1.000000009*Brush.gi.n0+-.1055613*Brush.gi.n1+-.06385417*Brush.gi.n2,e=1.00000005*Brush.gi.n0+-.08948418*Brush.gi.n1+-1.291485*Brush.gi.n2;t=t**3,i=i**3,e=e**3,Brush.zt.n0=1.2268798*t+-.5578149*i+.281391*e,Brush.zt.n1=-.04057576*t+1.112286*i+-.07171106*e,Brush.zt.n2=-.07637294*t+-.4214933*i+1.586924*e,Brush.zt.n3=Brush.gi.n3}static iI(){const t=Math.atan2(Brush.gi.n2,Brush.gi.n1)*180/Math.PI;Brush.ho.n0=Brush.gi.n0,Brush.ho.n1=Math.sqrt(Brush.gi.n1**2+Brush.gi.n2**2),Brush.ho.n2=t>=0?t:t+360,Brush.ho.n3=Brush.gi.n3}static eI(){Brush.gi.n0=Brush.ho.n0,Brush.gi.n1=Brush.ho.n1*Math.cos(Brush.ho.n2*Math.PI/180),Brush.gi.n2=Brush.ho.n1*Math.sin(Brush.ho.n2*Math.PI/180),Brush.gi.n3=Brush.ho.n3}static JR(){Brush.bL(),Brush._R(),Brush.iI()}static ZR(){Brush.eI(),Brush.tI(),Brush.kL()}static ud(t,i){typeof t=="string"?Debug&&!Brush.isValidColor(t)&&Util.n('Color "'+t+'" is not a valid color string for '+i):t instanceof Brush||Util.n("Value for "+i+" must be a color string or a Brush, not "+t)}static Solid=1;static Linear=2;static Radial=3;static Pattern=4;static Lab=1;static HSL=2;static rl=Diagram.isUsingDOM()?new CanvasSurface(null,void 0,{willReadFrequently:!0}).di:null;static W=new ColorNumbers;static Yi=new ColorNumbers;static zt=new ColorNumbers;static lo=new ColorNumbers;static gi=new ColorNumbers;static ho=new ColorNumbers}class PanelLayout{Tt="Base";static Layouts=new GMap;static definePanelLayout(t,i){i.name=t,PanelLayout.Layouts.set(t,i)}get name(){return this.Tt}set name(t){this.Tt=t}constructor(){}get classType(){return Panel}measure(t,i,e,s,n,o,r){}measureElement(t,i,e,s,n){t.wt(i,e,s,n)}arrange(t,i,e){}arrangeElement(t,i,e,s,n,o){t.qt(i,e,s,n,o)}remeasureObject(t){t.rc()}Ji(t,i,e){}}class PanelLayoutPosition extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=s.length,h=t.Wo();for(let a=0;a0&&(P=Math.max(Math.abs(k.x*o+k.offsetX-(M.x*o+M.offsetX))-g,0)),r>0&&(N=Math.max(Math.abs(k.y*r+k.offsetY-(M.y*r+M.offsetY))-g,0));const T=Size.a();T.e(0,0);const L=t.Wo();for(let I=0;I1,ot=it.columnSpan>1;(ft||ot)&&!(Uy&&(P=Math.max(y-gt,0)),b.Zi=b.Zi+P,b.actual=b.ht+P,y=Math.max(y-(P+(mt?gt:0)),0)}if(it.columnSpan===1&&(N===0||N===4)){b=t.getColumnDefinition(H);const gt=b.computeEffectiveSpacing(),mt=b.ht===0;P=Math.max(ut-b.actual,0),P+(mt?gt:0)>p&&(P=Math.max(p-gt,0)),b.Zi=b.Zi+P,b.actual=b.ht+P,p=Math.max(p-(P+(mt?gt:0)),0)}(ft||ot)&&it.rc()}}}Util.nt(c);let L=0,D=0;l=t.columnCount;for(let U=0;U=t.rowCount);$++)b=t.getRowDefinition(E.row+$),P=0,N===2||N===4?P=Math.max(b.minimum,X[E.row+$]===0?b.maximum:Math.min(X[E.row+$],b.maximum)):P=Math.max(b.minimum,isNaN(b.we)?b.maximum:Math.min(b.we,b.maximum)),V.height+=P,_+=b.minimum;for(let $=1;$=t.columnCount);$++)b=t.getColumnDefinition(E.column+$),P=0,N===2||N===5?P=Math.max(b.minimum,z[E.column+$]===0?b.maximum:Math.min(z[E.column+$],b.maximum)):P=Math.max(b.minimum,isNaN(b.we)?b.maximum:Math.min(b.we,b.maximum)),V.width+=P,et+=b.minimum;K.width+=V.width,K.height+=V.height;const tt=E.margin,it=tt.right+tt.left,ft=tt.top+tt.bottom;E.wt(K.width,K.height,et,_);const ot=E.measuredBounds,lt=Math.max(ot.width+it,0),st=Math.max(ot.height+ft,0);let nt=0;for(let $=0;$=t.rowCount);$++)b=t.getRowDefinition(E.row+$),nt+=b.total||0;if(nt=t.rowCount);at++){b=t.getRowDefinition(E.row+at);const ut=b.ht||0,dt=rt(E,b,ct);Debug&&typeof dt!="number"&&Util.n(E+" spanAllocation does not return a number: "+dt),b.actual=Math.min(b.maximum,ut+dt),b.ht!==ut&&($-=b.ht-ut)}}for(;$>0;){const rt=b.ht||0;if(isNaN(b.height)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+$),b.ht!==rt&&($-=b.ht-rt)),b.index===0)break;b=t.getRowDefinition(b.index-1)}}let ht=0;for(let $=0;$=t.columnCount);$++)b=t.getColumnDefinition(E.column+$),ht+=b.total||0;if(ht=t.columnCount);at++){b=t.getColumnDefinition(E.column+at);const ut=b.ht||0,dt=rt(E,b,ct);Debug&&typeof dt!="number"&&Util.n(E+" spanAllocation does not return a number: "+dt),b.actual=Math.min(b.maximum,ut+dt),b.ht!==ut&&($-=b.ht-ut)}}for(;$>0;){const rt=b.ht||0;if(isNaN(b.width)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+$),b.ht!==rt&&($-=b.ht-rt)),b.index===0)break;b=t.getColumnDefinition(b.index-1)}}}Util.nt(u),Size.o(V),Size.o(K),X!==void 0&&Util.nt(X),z!==void 0&&Util.nt(z);let G=0,q=0;const j=t.desiredSize,J=t.maxSize;N=t.qs(!0),L=0,D=0;let Y=0,v=0;l=t.columnCount;for(let U=0;U0){for(;p!==f&&(u[p]===void 0||u[p].ht===0);)p++;p=Math.max(Math.min(p,f-1),0),m=-u[p].position}let y=Math.min(t.leftIndex,c-1);if(d.length>0){for(;y!==c&&(d[y]===void 0||d[y].ht===0);)y++;y=Math.max(Math.min(y,c-1),0),g=-d[y].position}let x=0,k=0;for(;x!==f&&u[x]===void 0;)x++;for(;k!==f&&d[k]===void 0;)k++;const b=t.part;let S=t.getRowDefinition(x),M=t.getColumnDefinition(k);for(let C=0;C=t.rowCount);st++){const nt=t.getRowDefinition(C+st);nt.ht!==0&&(A.height+=nt.total)}for(let st=1;st=t.columnCount);st++){const nt=t.getColumnDefinition(N+st);nt.ht!==0&&(A.width+=nt.total)}const O=T.ht+A.width,B=P.ht+A.height;let K=h,V=a;const X=O,z=B,G=h,q=a;let j=O,J=B;h+O>e.width&&(j=Math.max(e.width-h,0)),a+B>e.height&&(J=Math.max(e.height-a,0));let Y=R.alignment,v=0,W=0,Q=0,U=0;if(Y.isDefault()){Y=t.defaultAlignment,Y.isSpot()||(Y=Spot.Center),v=Y.x,W=Y.y,Q=Y.offsetX,U=Y.offsetY;const st=T.alignment,nt=P.alignment;st.isSpot()&&(v=st.x,Q=st.offsetX),nt.isSpot()&&(W=nt.y,U=nt.offsetY)}else v=Y.x,W=Y.y,Q=Y.offsetX,U=Y.offsetY;(isNaN(v)||isNaN(W))&&(v=.5,W=.5,Q=0,U=0);let E=I.width,H=I.height;const Z=R.margin,et=Z.left+Z.right,_=Z.top+Z.bottom,tt=R.F0(P,T,!1);isNaN(R.desiredSize.width)&&(tt===2||tt===5)&&(E=Math.max(O-et,0)),isNaN(R.desiredSize.height)&&(tt===2||tt===4)&&(H=Math.max(B-_,0));const it=R.maxSize,ft=R.minSize;E=Math.min(it.width,E),H=Math.min(it.height,H),E=Math.max(ft.width,E),H=Math.max(ft.height,H);const ot=E+et,lt=H+_;K+=X*v-ot*v+Q+Z.left,V+=z*W-lt*W+U+Z.top,R.visible&&(Rect.contains(G,q,j,J,K,V,I.width,I.height)?R.qt(K,V,E,H):R.qt(K,V,E,H,new Rect(G,q,j,J)))}}}Size.o(A);for(let C=0;C0&&(b.figure==="LineV"||b.figure==="LineH")){if(i.lineWidth=b.strokeWidth,t.wn(i,b.stroke,!1,!1,l,h),i.beginPath(),b.figure==="LineV"){const D=Math.floor((m-o)/o);for(let F=D;F<=D+c;F++){const R=F*o+m;0<=R&&R<=a&&this.sb(F,S,A,N)&&(i.moveTo(R,0),i.lineTo(R,f))}}else if(b.figure==="LineH"){const D=Math.floor((g-r)/r);for(let F=D;F<=D+u;F++){const R=F*r+g;0<=R&&R<=f&&this.sb(F,S,A,N)&&(i.moveTo(0,R),i.lineTo(a,R))}}i.stroke(),i.endPath()}else if(b.fill!==null){if(t.wn(i,b.fill,!0,!1,l,h),b.figure==="BarV"){let D=b.width;isNaN(D)&&(D=o);const F=Math.floor((m-o)/o);for(let R=F;R<=F+c;R++){const I=R*o+m;0<=I+D&&I<=a&&this.sb(R,S,A,N)&&i.fillRect(I,0,D,f)}}else if(b.figure==="BarH"){let D=b.height;isNaN(D)&&(D=r);const F=Math.floor((g-r)/r);for(let R=F;R<=F+u;R++){const I=R*r+g;0<=I+D&&I<=f&&this.sb(R,S,A,N)&&i.fillRect(0,I,a,D)}}}T&&i.disableDash(),C!==1&&(i.globalAlpha=P)}}sb(t,i,e,s){if(i<0)return t%i===e;if(t%i!==e)return!1;const n=s.length;for(let o=0;ol&&r.push(d)}}t.Mi.np=i}V2(t){return t==="LineV"||t==="BarV"}sI(t){let i=1,e=1;const s=t.D.h,n=s.length;for(let l=0;l=g){const Y=Point.a();f.ML(Y),O=f.midAngle,L!==0&&(I=f.computeAngle(A,L,O),A.jt=I,A.pe(!0),A.oo(!0)),F=Y.x-u.x,R=Y.y-u.y,Point.o(Y)}else{let Y,v,W=0;if(P>=0?(Y=m.elt(P),v=P0?m.elt(W-1):Y),O=0,Y.equalsApprox(v)){let Q,U;P>=0?(Q=P>0?m.elt(P-1):Y,U=P1?m.elt(W-2):v);const E=Q.distanceSquaredPoint(Y),H=v.distanceSquaredPoint(U);E>H+10?O=P>=0?Q.directionPoint(Y):Y.directionPoint(Q):H>E+10?O=P>=0?v.directionPoint(U):U.directionPoint(v):O=P>=0?Q.directionPoint(U):U.directionPoint(Q)}else O=P>=0?Y.directionPoint(v):v.directionPoint(Y);L!==0&&(I=f.computeAngle(A,L,O),A.jt=I,A.pe(!0),A.oo(!0)),F=Y.x+(v.x-Y.x)*N-u.x,R=Y.y+(v.y-Y.y)*N-u.y}A.wt(1/0,1/0,0,0),C=A.measuredBounds;const B=A.naturalBounds;let K=0;A instanceof Shape&&(K=A.strokeWidth);const V=B.width+K,X=B.height+K;k.Bi(),k.Es(-C.x,-C.y),k.lt(A.scale,A.scale),k.ms(L===0?A.angle:O,V/2,X/2),(L===22||L===26)&&k.ms(90,V/2,X/2),(L===23||L===27)&&k.ms(-90,V/2,X/2),L===28&&(O>45&&O<135||O>225&&O<315)&&k.ms(-O,V/2,X/2);const z=new Rect(0,0,V,X);b.setRectSpot(z,T),k.Pt(b);const G=-b.x+K/2*A.scale,q=-b.y+K/2*A.scale;S.c(D);const j=isNaN(D.x),J=isNaN(D.y);if(j||J){const Y=V/2+3,v=X/2+3,W=O>=45&&O<=135,Q=O>=225&&O<=315;L===0&&(W||Q)?(S.x=J?Y:D.y,S.y=j?v:D.x,W?P>=0||isNaN(P)&&N<.5||j&&(S.y=-v):Q&&((P>=0||isNaN(P)&&N<.5)&&j&&(S.y=-v),J&&(S.x=-Y))):(j&&(P>=0||isNaN(P)&&N<.5?S.x=Y:S.x=-Y),J&&(S.y=-v),S.rotate(O))}else S.rotate(O);F+=S.x,R+=S.y,z.e(F+G,R+q,C.width,C.height),x.push(z),d.unionRect(z)}if(h!==null){const M=h.labelNodes;for(;M.next();)M.value.wt(1/0,1/0)}t.vo=d,t.position.e(u.x+d.x,u.y+d.y),n.Kn(d.width||0,d.height||0),Transform.o(k),Point.o(b),Point.o(S)}arrange(t,i,e){const s=i.length;if(!(t instanceof Adornment||t instanceof Link))return;let n=t,o=null;t instanceof Adornment&&(o=t,n=o.adornedPart);const r=t,l=t instanceof Adornment?null:n.path,h=t.dc;if(h.length!==0){let u=0;if(l!==null&&u=2&&r instanceof Link){const u=r.labelNodes;for(;u.next();){const d=u.value;r.rI(d,f,a)}}o!==null?o.pd(!1):n.pd(!1);const c=t.PL(Point.a());t.location.e(t.position.x+c.x,t.position.y+c.y),Point.o(c)}measureLinkPath(t,i,e,s){if(s.Xo()===!1)return;let n=s.strokeWidth;if(n===0&&t instanceof Adornment&&t.type===Panel.Link&&t.adornedObject instanceof Shape&&(n=t.adornedObject.strokeWidth),n=n*s.lt,t instanceof Link&&t.yt!==null){const o=t.geometry.bounds;s.no(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else if(t instanceof Adornment&&t.adornedPart.yt!==null){const o=t.adornedPart.yt.bounds;s.no(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else s.no(-(n/2),-(n/2),i+n,e+n);s.lI(),s.pe(!1)}}PanelLayout.definePanelLayout("Link",new PanelLayoutLink);class PanelLayoutGraduated extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=t.findMainElement();t.Ze=[];const h=l.margin,a=h.right+h.left,f=h.top+h.bottom;l.wt(i,e,o,r);const c=l.measuredBounds,u=c.width,d=c.height,m=Math.max(u+a,0),g=Math.max(d+f,0),p=new Rect(-h.left,-h.top,m,g);t.Ze.push(p),n.c(p),this.determineGraduatedMarks(t,l);const y=t.Ms;if(y===null)return;const x=s.length;for(let k=0;k45&&c<135||c>225&&c<315)&&S.ms(-c,k/2,b/2);const M=Rect.H(0,0,k,b),A=Point.a();A.setRectSpot(M,o),S.Pt(A);const C=-A.x,P=-A.y,N=Point.a();N.c(l),isNaN(N.x)&&(N.x=k/2+3),isNaN(N.y)&&(N.y=-(b/2+3)),N.rotate(c),a+=N.x+C,f+=N.y+P;const T=new Rect(a,f,y.width,y.height),L=new Rect(y.x,y.y,y.width,y.height),D=new Rect(x.x,x.y,x.width,x.height);p.labelAngle=u,p.lineCount=n.lineCount,p.lines=n.getMetrics(),p.actualBounds=T,p.measuredBounds=L,p.naturalBounds=D,g===0?h.c(T):h.unionRect(T),Point.o(N),Point.o(A),Rect.o(M),Transform.o(S)}t.Ze!==null&&t.Ze.push(h),s.unionNoCheck(h.x,h.y,h.width,h.height)}determineGraduatedMarks(t,i){const e=i.geometry,s=i.strokeWidth,n=e.flattenedSegments,o=e.flattenedLengths,r=e.flattenedTotalLength,l=n.length;let h=0,a=0;const f=Util.ft();for(let x=0;xt.graduatedMin+P){const F=Math.floor((N-t.graduatedMin)/P);N-=F*P}const T=c[x],L=N,D=t.graduatedMax*1e-6;for(let F=1;N<=t.graduatedMax+D;F++){if(this.aI(t,N-t.graduatedTickBase,T)&&(N>t.graduatedMax&&(N=t.graduatedMax),(k.graduatedSkip===null||k instanceof TextBlock&&!k.graduatedSkip(N,k)||k instanceof Shape&&!k.graduatedSkip(N,k))&&(m=(N-t.graduatedMin)*r/t.graduatedRange,m>r&&(m=r),g<=m&&m<=p))){let R=f[A][C],I=o[A][C];for(;AM&&C.4995)return t;let o=t;if(i<.5?n>0?o=s[n-1]:Geo.q(e[0],e[e.length-2])&&Geo.q(e[1],e[e.length-1])&&(o=s[s.length-1]):i>.5&&(n+1180&&(t.9995)return(t+o)/2%360;if(r<10){const l=1-Math.abs(.5-i);return(t*l+o*(1-l))%360}}return t}hI(t){if(t.as===null){const i=[],e=t.D.h,s=e.length;for(let n=0;nl&&r.push(f)}}t.as=i}return t.as}aI(t,i,e){const s=e.length;for(let n=0;n-l)return!1}return!0}Ji(t,i,e){const s=e.ia;e.ia=!0;const n=t.naturalBounds,o=n.width,r=n.height,l=i instanceof SVGContext;i.save(),i.beginPath(),i.rect(-1,-1,o+1,r+1),i.clip(),i.endPath();const h=t.findMainElement();h.Ji(i,e);let a=t.getDocumentScale()*e.scale;a<=0&&(a=1);const f=h.actualBounds,c=t.D.h,u=t.Ms,d=c.length;for(let m=0;m(w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ViewboxStretch||{});class Panel extends GraphObject{st;D;ii;yd;vn;ll;ao;vo;z2;B;wd;dt;Mi;si;xd;wh;vs;constructor(t,i){if(super(),this.st=null,t===void 0)this.st=Panel.Position;else if(typeof t=="string"){const e=PanelLayout.Layouts.get(t);e!==null&&(this.st=e)}else t instanceof PanelLayout?this.st=t:t&&(this.st=Panel.Position,i=t);this.st===null&&Util.n("Panel type not specified or PanelLayout not loaded: "+t),this.l|=4194304|(this.st===Panel.Grid?1048576:0),this.D=new List,this.ii=Margin.qg,this.yd=Spot.Default,this.vn=1,this.ll=null,this.ao="",this.vo=new Rect(NaN,NaN,NaN,NaN),this.z2=null,this.B=null,this.wd=6,this.Mi=null,this.dt=null,this.si=null,this.xd=NaN,this.wh=null,this.vs=null,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.st=this.st,t.ii=this.ii.L(),t.yd=this.yd.L(),t.vn=this.vn,t.ao=this.ao,t.vo.c(this.vo),this.B!==null&&(t.B=this.B.copy(t)),t.wd=this.wd,this.dt!==null&&(t.dt=this.dt.copy()),this.Mi!==null&&(t.Mi=this.Mi.copy()),t.si=this.si,t.xd=this.xd,t.wh=this.wh}Ho(t){super.Ho(t),t.D=this.D;const i=t.D.h,e=i.length;for(let s=0;s= 0",Panel,"padding"),t=new Margin(t)):(Util.s(t,Margin,Panel,"padding"),t.left<0&&Util.G(t.left,">= 0",Panel,"padding:value.left"),t.right<0&&Util.G(t.right,">= 0",Panel,"padding:value.right"),t.top<0&&Util.G(t.top,">= 0",Panel,"padding:value.top"),t.bottom<0&&Util.G(t.bottom,">= 0",Panel,"padding:value.bottom"));const i=this.ii;i.equals(t)||(t=t.L(),this.ii=t,this.u(),this.i("padding",i,t))}get defaultAlignment(){return this.yd}set defaultAlignment(t){const i=this.yd;i.equals(t)||(Debug&&Util.s(t,Spot,Panel,"defaultAlignment"),t=t.L(),this.yd=t,this.u(),this.i("defaultAlignment",i,t))}get defaultStretch(){return this.vn}set defaultStretch(t){const i=this.vn;i!==t&&(this.vn=t,this.u(),this.i("defaultStretch",i,t))}get defaultSeparatorPadding(){return this.B!==null?this.B.op:Margin.qg}set defaultSeparatorPadding(t){typeof t=="number"?t=new Margin(t):Debug&&Util.s(t,Margin,Panel,"defaultSeparatorPadding");const i=this.defaultSeparatorPadding;i.equals(t)||(t=t.L(),this.B===null&&(this.B=new TablePanelSettings),this.B.op=t,this.u(),this.i("defaultSeparatorPadding",i,t))}get defaultRowSeparatorStroke(){return this.B!==null?this.B.rp:null}set defaultRowSeparatorStroke(t){const i=this.defaultRowSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.w(),this.B===null&&(this.B=new TablePanelSettings),this.B.rp=t,this.T(),this.i("defaultRowSeparatorStroke",i,t))}get defaultRowSeparatorStrokeWidth(){return this.B!==null?this.B.lp:1}set defaultRowSeparatorStrokeWidth(t){const i=this.defaultRowSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.B===null&&(this.B=new TablePanelSettings),this.B.lp=t,this.u(),this.i("defaultRowSeparatorStrokeWidth",i,t))}get defaultRowSeparatorDashArray(){return this.B!==null?this.B.hp:null}set defaultRowSeparatorDashArray(t){const i=this.defaultRowSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Vi(t,"Array",Panel,"defaultRowSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("defaultRowSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.B===null&&(this.B=new TablePanelSettings),this.B.hp=t,this.T(),this.i("defaultRowSeparatorDashArray",i,t)}}get defaultColumnSeparatorStroke(){return this.B!==null?this.B.ap:null}set defaultColumnSeparatorStroke(t){const i=this.defaultColumnSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.w(),this.B===null&&(this.B=new TablePanelSettings),this.B.ap=t,this.T(),this.i("defaultColumnSeparatorStroke",i,t))}get defaultColumnSeparatorStrokeWidth(){return this.B!==null?this.B.fp:1}set defaultColumnSeparatorStrokeWidth(t){const i=this.defaultColumnSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.B===null&&(this.B=new TablePanelSettings),this.B.fp=t,this.u(),this.i("defaultColumnSeparatorStrokeWidth",i,t))}get defaultColumnSeparatorDashArray(){return this.B!==null?this.B.cp:null}set defaultColumnSeparatorDashArray(t){const i=this.defaultColumnSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Vi(t,"Array",Panel,"defaultColumnSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("defaultColumnSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.B===null&&(this.B=new TablePanelSettings),this.B.cp=t,this.T(),this.i("defaultColumnSeparatorDashArray",i,t)}}get yh(){return this.B!==null?this.B.yh:null}set yh(t){this.B===null&&(this.B=new TablePanelSettings),this.B.yh=t}get viewboxStretch(){return this.wd}set viewboxStretch(t){const i=this.wd;i!==t&&(this.wd=t,this.u(),this.i("viewboxStretch",i,t))}get gridCellSize(){return this.Mi!==null?this.Mi.bd:Size.fC}set gridCellSize(t){this.Mi===null&&(this.Mi=new GridPanelSettings);const i=this.Mi.bd;if(!i.equals(t)){(!t.isReal()||t.width===0||t.height===0)&&Util.n("Invalid Panel.gridCellSize: "+t),this.Mi.bd=t.L();const e=this.diagram;e!==null&&this===e.grid&&e.Zr(),this.T(),this.i("gridCellSize",i,t)}}get gridOrigin(){return this.Mi!==null?this.Mi.kd:Point.Lo}set gridOrigin(t){this.Mi===null&&(this.Mi=new GridPanelSettings);const i=this.Mi.kd;if(!i.equals(t)){t.isReal()||Util.n("Invalid Panel.gridOrigin: "+t),this.Mi.kd=t.L();const e=this.diagram;e!==null&&this===e.grid&&e.Zr(),this.T(),this.i("gridOrigin",i,t)}}get graduatedMin(){return this.dt!==null?this.dt.dp:0}set graduatedMin(t){Util.r(t,Panel,"graduatedMin");const i=this.graduatedMin;if(i!==t&&(this.dt===null&&(this.dt=new GradPanelSettings),this.dt.dp=t,this.u(),this.i("graduatedMin",i,t),this.ec())){const e=this.part;e!==null&&this.ka(e,"graduatedRange")}}get graduatedMax(){return this.dt!==null?this.dt.gp:100}set graduatedMax(t){Util.r(t,Panel,"graduatedMax");const i=this.graduatedMax;if(i!==t&&(this.dt===null&&(this.dt=new GradPanelSettings),this.dt.gp=t,this.u(),this.i("graduatedMax",i,t),this.ec())){const e=this.part;e!==null&&this.ka(e,"graduatedRange")}}get graduatedRange(){return this.graduatedMax-this.graduatedMin}get graduatedTickUnit(){return this.dt!==null?this.dt.mp:10}set graduatedTickUnit(t){Util.r(t,Panel,"graduatedTickUnit");const i=this.graduatedTickUnit;i!==t&&t>0&&(this.dt===null&&(this.dt=new GradPanelSettings),this.dt.mp=t,this.u(),this.i("graduatedTickUnit",i,t))}get graduatedTickBase(){return this.dt!==null?this.dt.pp:0}set graduatedTickBase(t){Util.r(t,Panel,"graduatedTickBase");const i=this.graduatedTickBase;i!==t&&(this.dt===null&&(this.dt=new GradPanelSettings),this.dt.pp=t,this.u(),this.i("graduatedTickBase",i,t))}get Ms(){return this.dt!==null?this.dt.Ms:null}set Ms(t){this.dt!==null?this.dt.Ms=t:t!==null&&(this.dt=new GradPanelSettings,this.dt.Ms=t)}get Ze(){return this.dt!==null?this.dt.Ze:null}set Ze(t){this.dt!==null?this.dt.Ze=t:t!==null&&(this.dt=new GradPanelSettings,this.dt.Ze=t)}get as(){return this.dt!==null?this.dt.as:null}set as(t){this.dt!==null?this.dt.as=t:t!==null&&(this.dt=new GradPanelSettings,this.dt.as=t)}get Le(){return this.dt!==null?this.dt.Le:null}set Le(t){this.dt!==null?this.dt.Le=t:t!==null&&(this.dt=new GradPanelSettings,this.dt.Le=t)}A0(t){super.A0(t);const i=this.D.h,e=i.length;for(let s=0;s0?this.ve:null,s=this.columnCount>0?this.Je:null;e!==null&&this.nb(t,i,!0,e,!0),s!==null&&this.nb(t,i,!1,s,!0),e!==null&&this.CL(t,!0,e),s!==null&&this.CL(t,!1,s),e!==null&&this.nb(t,i,!0,e,!1),s!==null&&this.nb(t,i,!1,s,!1)}CL(t,i,e){const s=e.length,n=this.actualBounds,o=this.naturalBounds;let r=!0;for(let l=0;lo.height)continue}else if(h.position>o.width)continue;let a=h.separatorStrokeWidth;isNaN(a)&&(a=i?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let f=h.separatorStroke;if(f===null&&(f=i?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),a===0||f===null)continue;this.wn(t,f,!1,!1,o,n);let c=!1,u=h.separatorDashArray;u===null&&(u=i?this.defaultRowSeparatorDashArray:this.defaultColumnSeparatorDashArray),u!==null&&(c=!0,t.enableDash(u,0)),t.beginPath();const d=h.position+a;i?d>o.height&&(a-=d-o.height):d>o.width&&(a-=d-o.width);let m=h.position+a/2;t.lineWidth=a;const g=this.ii;if(i){m+=g.top;const p=g.left,y=o.width-g.right;t.moveTo(p,m),t.lineTo(y,m)}else{m+=g.left;const p=g.top,y=o.height-g.bottom;t.moveTo(m,p),t.lineTo(m,y)}t.stroke(),t.endPath(),c&&t.disableDash()}}nb(t,i,e,s,n){const o=s.length,r=this.actualBounds,l=this.naturalBounds,h=this.AL(!0),a=this.AL(!1);for(let f=0;fu)continue;let d=c.computeEffectiveSpacing(),m=c.separatorStrokeWidth;isNaN(m)&&(m=e?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let g=c.separatorStroke;g===null&&(g=e?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),(g===null||c.index===(e?h:a))&&(m=0),d-=m;const p=c.position+m;let y=d+c.actual;if(p+y>u&&(y=u-p),y<=0)continue;const x=this.ii;this.wn(t,c.background,!0,!1,l,r),e?t.fillRect(x.left,p+x.top,r.width-(x.left+x.right),y):t.fillRect(p+x.left,x.top,y,r.height-(x.top+x.bottom))}}AL(t){const i=t?this.rowCount:this.columnCount;for(let e=0;ex&&n.set(P),Point.o(P)),Point.o(M),o&&n.O(r),k}}zu(){const t=this.D.h,i=t.length;for(let e=0;ee||h>s)&&(this.u(),this.wt(l>e?e:l,h>s?s:h,0,0));break;case 2:this.u(!0),this.wt(e+f,s+c,0,0);break;case 5:this.u(!0),this.wt(e+f,h+c,0,0);break;case 4:this.u(!0),this.wt(l+f,s+c,0,0);break}}this.st.arrange(this,n,this.vo)}ch(t){const i=this.naturalBounds,e=this.Wo();if(Rect.contains(0,0,i.width,i.height,t.x,t.y)){const s=this.D.h,n=s.length,o=Point.H(0,0);for(let r=n;r--;){const l=s[r];if(!(!l.visible&&l!==e)&&(o.set(t).Ye(l.O),l.containsPoint(o)))return Point.o(o),!0}return Point.o(o),this.Ft!==null}return!1}M0(t){if(this.eo===t)return this;const i=this.D.h,e=i.length;for(let s=0;sd.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;let m=c;const g=c instanceof Panel?c:null,p=Transform.a();p.set(r),(g!==null?g.Km(t,i,e,s,n,p):m.lL(t,s,p))&&(i!==null&&(m=i(m)),m!==null&&(e===null||e(m))&&n.add(m)),Transform.o(p)}}return o===void 0&&Transform.o(r),s}return o===void 0&&Transform.o(r),!1}Y2(t,i,e){const s=this.D.h,n=s.length;for(let o=n;o--;){const r=s[o];if(!r.visible)continue;const l=r.actualBounds,h=this.naturalBounds;if(l.x>h.width||l.y>h.height||l.x+l.width<0||l.y+l.height<0)continue;r instanceof Panel&&r.Y2(t,i,e);let a=r;t!==null&&(a=t(a)),a!==null&&(i===null||i(a))&&e.add(a)}}fA(t,i,e,s,n,o){if(this.pickable===!1)return!1;e===void 0&&(e=null),s===void 0&&(s=null);const r=this.naturalBounds,l=this.kn(),h=l?t:Point.H(t.x,t.y).Ye(this.O),a=l?i:Point.H(i.x,i.y).Ye(this.O),f=h.distanceSquaredPoint(a),c=h.x>0&&h.x0&&h.yS.width||b.y>S.height||b.x+b.width<0||b.y+b.height<0))continue;if(k.kn()){const C=k.O;d.set(t).Ye(C),m.set(i).Ye(C)}else d.set(t),m.set(i);let M=k;const A=k instanceof Panel?k:null;(A!==null?A.fA(d,m,e,s,n,o):M.hL(d,m,n))&&(e!==null&&(M=e(M)),M!==null&&(s===null||s(M))&&o.add(M))}Point.o(d),Point.o(m)}return n?c:u}return!1}O2(t){let i=null;if(t instanceof Shape){i=t.spot1,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot1)}return i===null&&(i=Spot.TopLeft),i}E2(t){let i=null;if(t instanceof Shape){i=t.spot2,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot2)}return i===null&&(i=Spot.BottomRight),i}add(...t){for(let i=0;i=s.count&&t>=s.count)return;s.removeAt(r),n=r}else Util.n("element "+i.toString()+" has panel "+e.toString()+" but is not contained by it.")}(t<0||t>s.count)&&(t=s.count),s.insertAt(t,i),(t===0||i.isPanelMain)&&(this.ll=null),this.Xo()||this.u(),i.u(!1),i.portId!==null?this.Mn=!0:i instanceof Panel&&i.Mn===!0&&(this.Mn=!0),this.as=null,this.isEnabledObject()||this.ob(i,!1);const o=this.part;if(o!==null){o.V0(),o.mc(),this.Mn&&o instanceof Node&&(o.Mn=!0),o.Mn&&o instanceof Node&&(o.he=null);const r=this.diagram;if(r!==null&&r.undoManager.isUndoingRedoing)return;n!==-1&&o.raiseChangedEvent(4,"elements",this,i,null,n,null),o.raiseChangedEvent(3,"elements",this,null,i,null,t)}}get Mn(){return(this.l&8388608)!==0}set Mn(t){(this.l&8388608)!==0!==t&&(this.l=this.l^8388608)}d2(){return(this.l&16777216)!==0}K2(t){t?this.l|=16777216:this.l&=-16777217}mI(t){t.Ma(this),t.sl=null;const i=this.D,e=i.count;i.insertAt(e,t);const s=this.part;if(s!==null){s.V0(),t.portId!==null&&s instanceof Node&&(s.Mn=!0);const n=this.diagram;if(n!==null&&n.undoManager.isUndoingRedoing)return;s.raiseChangedEvent(3,"elements",this,null,t,null,e)}}BR(t){const i=this.D.h,e=i.length;let s=-1;for(let n=0;n=0&&this.ne(t,!0)}ne(t,i){const e=this.D,s=e.elt(t);if(s.sl=null,s.Ma(null),this.vs!==null){const o=s.data;typeof o=="object"&&this.vs.delete(o)}e.removeAt(t),this.pe(!1),this.u(),this.ll===s&&(this.ll=null),this.as=null;const n=this.part;if(n!==null){n.V0(),n.mc(),n.invalidateAdornments(),n instanceof Node&&(s instanceof Panel?s.walkVisualTreeFrom(s,(r,l)=>n.P2(l,i)):n.P2(s,i));const o=this.diagram;if(o!==null&&o.undoManager.isUndoingRedoing)return;n.raiseChangedEvent(4,"elements",this,s,null,t,null)}}get ve(){return this.B===null&&(this.B=new TablePanelSettings),this.B.ve}get rowCount(){return this.B===null?0:this.ve.length}getRowDefinition(t){Debug&&Util.r(t,Panel,"getRowDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"getRowDefinition:idx"),t=Math.round(t);const i=this.ve;if(i[t]===void 0){const e=new RowColumnDefinition;e.Ma(this),e.isRow=!0,e.index=t,i[t]=e,this.raiseChangedEvent(3,"rowdefs",this,null,e,null,t)}return i[t]}removeRowDefinition(t){if(Debug&&Util.r(t,Panel,"removeRowDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"removeRowDefinition:idx"),this.rowCount===0)return;t=Math.round(t);const i=this.ve,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"rowdefs",this,e,null,t,null),this.u()}}zA(t,i){const e=this.ve;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.u()}}get Je(){return this.B===null&&(this.B=new TablePanelSettings),this.B.Je}get columnCount(){return this.B===null?0:this.Je.length}getColumnDefinition(t){Debug&&Util.r(t,Panel,"getColumnDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"getColumnDefinition:idx"),t=Math.round(t);const i=this.Je;if(i[t]===void 0){const e=new RowColumnDefinition;e.Ma(this),e.isRow=!1,e.index=t,i[t]=e,this.raiseChangedEvent(3,"coldefs",this,null,e,null,t)}return i[t]}removeColumnDefinition(t){if(Debug&&Util.r(t,Panel,"removeColumnDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"removeColumnDefinition:idx"),this.columnCount===0)return;t=Math.round(t);const i=this.Je,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"coldefs",this,e,null,t,null),this.u()}}XA(t,i){const e=this.Je;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.u()}}addRowColumnDefinition(t){let i=null;return t.isRow?i=this.getRowDefinition(t.index):t.isRow||(i=this.getColumnDefinition(t.index)),i&&i.Z1(t),this}addRowDefinition(t,i){const e=this.getRowDefinition(t);return e&&e.Z1(new RowColumnDefinition(i)),this}addColumnDefinition(t,i){const e=this.getColumnDefinition(t);return e&&e.Z1(new RowColumnDefinition(i)),this}get rowSizing(){return this.B!==null?this.B.wp:3}set rowSizing(t){const i=this.rowSizing;i!==t&&(Debug&&t!==3&&t!==2&&Util.n("Panel.rowSizing must be ProportionalExtra or None, not: "+t),this.B===null&&(this.B=new TablePanelSettings),this.B.wp=t,this.u(),this.i("rowSizing",i,t))}get columnSizing(){return this.B!==null?this.B.xp:3}set columnSizing(t){const i=this.columnSizing;i!==t&&(Debug&&t!==3&&t!==2&&Util.n("Panel.columnSizing must be ProportionalExtra or None, not: "+t),this.B===null&&(this.B=new TablePanelSettings),this.B.xp=t,this.u(),this.i("columnSizing",i,t))}get topIndex(){return this.B!==null?this.B.bp:0}set topIndex(t){const i=this.topIndex;i!==t&&((!isFinite(t)||t<0)&&Util.n("Panel.topIndex must be greater than zero and a real number, not: "+t),this.B===null&&(this.B=new TablePanelSettings),this.B.bp=t,this.u(),this.i("topIndex",i,t))}get leftIndex(){return this.B!==null?this.B.kp:0}set leftIndex(t){const i=this.leftIndex;i!==t&&((!isFinite(t)||t<0)&&Util.n("Panel.leftIndex must be greater than zero and a real number, not: "+t),this.B===null&&(this.B=new TablePanelSettings),this.B.kp=t,this.u(),this.i("leftIndex",i,t))}findRowForLocalY(t){if(t<0||this.type!==Panel.Table||this.rowCount===0)return-1;let i=0;const e=this.ve,s=e.length;let n=this.topIndex;for(;n{o.fh();const r=o.Ri;if(r!==null){o.k2(!1);const l=r.iterator;for(;l.next();){const h=l.value;h.mode===2&&o.k2(!0);const a=h.sourceName;if(h.isToObject){a==="/"&&n.K2(!0);const f=h.rL(n,o);f!==null&&(i.add(f),f.so===null&&(f.so=new List),f.so.add(h))}t.add(h)}}if(o instanceof Panel&&o.type===Panel.Table){if(o.rowCount>0){const l=o.ve,h=l.length;for(let a=0;a0){const l=o.Je,h=l.length;for(let a=0;a0&&o instanceof Panel){const h=r.substring(0,l),a=r.substring(l+1),f=o.findObject(h);f!==null?(o=f,n.targetProperty=a):(Util.at('Warning: unable to find GraphObject named "'+h+'" for Binding: '+n.toString()),o=null)}if(o instanceof RowColumnDefinition){const h=GSet.gs(o.panel);n.targetId=h===void 0?-1:h,o.panel.eo=n.targetId}else if(o instanceof GraphObject){const h=GSet.gs(o);n.targetId=h===void 0?-1:h,o.eo=n.targetId}else Util.n("Unknown type of binding target: "+o);n.check(o)}}return t.w(),this instanceof Part&&(this.Ae()&&this.ensureBounds(),Debug&&!Panel.RL&&this.walkVisualTreeFrom(this,(n,o)=>{if(o instanceof Panel&&(o.type===Panel.Auto||o.type===Panel.Spot||o.type===Panel.Graduated)&&o.elements.count<=1&&!(o instanceof Part)){let r=!1;if(o.elements.count===1&&(r=o.itemArray!==null,!r)){for(s=t.iterator;s.next();)if(s.value.targetProperty==="itemArray"){r=!0;break}}r||(Util.at("Auto, Spot, or Graduated Panel should not have zero or one elements: "+o.toString()+" in "+n.toString()),Panel.RL=!0)}})),this}static RL=!1;copyTemplate(t){t===void 0&&(t=!1);const i=this.copy();return i.pI(e=>{e instanceof Panel&&(e.Ws=null,e.si=null);const s=e.Ri;s!==null&&(e.Ri=null,s.each(o=>e.bind(o.copy())));const n=e.Ss;n!==null&&(e.Ss=null,n.each(o=>e.trigger(o.value.copy())))}),t&&i.ci(),i}updateTargetBindings(t){const i=this.Ws;if(i===null)return;t===void 0&&(t="");const e=i.iterator;for(;e.next();){const s=e.value,n=this.IL(s,t);if(n===null)continue;const{data:o,elt:r}=n;s.isToTheme&&this.diagram===null||r!==void 0&&s.updateTarget(r,o)}}Yo(){if(this.diagram!==null)if(this.N2()){const t=this.Ws.iterator;for(;t.next();){const i=t.value;if(!i.isToTheme)continue;const e=this.IL(i);if(e===null)continue;const{data:s,elt:n}=e;n!==void 0&&i.updateTarget(n,s)}}else{const t=this.D.h,i=t.length;for(let e=0;e0;let r=0;for(;n0){const i=this.D.elt(0);if(i.isPanelMain&&i instanceof Panel&&i.nl())return 1}return 0}rebuildItemElements(){const t=this.yp();for(;this.D.length>t;)this.ne(this.D.length-1,!1);this.OL(null,this.itemArray)}OL(t,i){const e=this.yp(),s=i;if(s===null||s.length===0){for(;this.D.length>e;)this.ne(this.D.length-1,!1);return}if(this.D.length<=e){const n=s.length;for(let o=0;o(w[w.Default=1]="Default",w[w.None=2]="None",w[w.ProportionalExtra=3]="ProportionalExtra",w))(Sizing||{});class RowColumnDefinition{Hs;Sp;Vt;Aa;La;ai;mt;Md;ro;Jo;Pd;Nd;Ta;Ft;Cd;Js;ht;Zi;we;constructor(t){GSet.vi(this),this.Hs=null,this.Sp=!0,this.Vt=0,this.we=NaN,this.Aa=0,this.La=1/0,this.ai=Spot.Default,this.ht=0,this.Zi=0,this.mt=0,this.Js=null,this.Md=1,this.ro=1,this.Jo=null,this.Pd=null,this.Nd=NaN,this.Ta=null,this.Ft=null,this.Cd=!1,t&&(Object.assign(this,t),t.column!==void 0?(this.isRow=!1,this.index=t.column):t.row!==void 0&&(this.isRow=!0,this.index=t.row))}copy(){const t=new RowColumnDefinition;return t.Sp=this.Sp,t.Vt=this.Vt,t.we=this.we,t.Aa=this.Aa,t.La=this.La,t.ai=this.ai,t.ht=this.ht,t.Zi=this.Zi,t.mt=this.mt,t.ro=this.ro,t.Md=this.Md,this.Jo===null?t.Jo=null:t.Jo=this.Jo.L(),t.Pd=this.Pd,t.Nd=this.Nd,t.Ta=null,this.Ta!==null&&(t.separatorDashArray=this.separatorDashArray.slice()),t.Ft=this.Ft,t.Cd=this.Cd,t.Js=this.Js,t}Z1(t){t.isRow?this.height=t.height:this.width=t.width,this.minimum=t.minimum,this.maximum=t.maximum,this.alignment=t.alignment,this.stretch=t.stretch,this.sizing=t.sizing,this.Jo=t.separatorPadding===null?null:t.separatorPadding.L(),this.separatorStroke=t.separatorStroke,this.separatorStrokeWidth=t.separatorStrokeWidth,this.Ta=null,t.separatorDashArray&&(this.Ta=t.separatorDashArray.slice()),this.background=t.background,this.coversSeparators=t.coversSeparators,this.Js=t.Js}fi(t){t in Sizing?this.sizing=t:Util.ur(this,t)}toString(){return"RowColumnDefinition "+(this.isRow?"(Row ":"(Column ")+this.index+") #"+GSet.gs(this)}static Default=1;static None=2;static ProportionalExtra=3;Ma(t){this.Hs=t}computeEffectiveSpacingTop(t){let i=0;const e=this.Hs;if(this.index!==t){let n=this.separatorStroke;n===null&&e!==null&&(n=this.isRow?e.defaultRowSeparatorStroke:e.defaultColumnSeparatorStroke),n!==null&&(i=this.separatorStrokeWidth,isNaN(i)&&(e!==null?i=this.isRow?e.defaultRowSeparatorStrokeWidth:e.defaultColumnSeparatorStrokeWidth:i=0))}let s=this.Jo;if(s===null)if(e!==null)s=e.defaultSeparatorPadding;else return i;return i+(this.isRow?s.top:s.left)}computeEffectiveSpacing(){let t=0;const i=this.Hs;let e=0;const s=this.isRow;if(i!==null&&i.type===Panel.Table){const o=s?i.ve.length:i.Je.length;for(let r=0;r= 0",RowColumnDefinition,"height"),this.we=t,this.actual=this.ht,this.panel!==null&&this.panel.u(),this.i("height",i,t))}get width(){return this.we}set width(t){const i=this.we;i!==t&&(Debug&&Util.t(t,"number",RowColumnDefinition,"width"),t<0&&Util.G(t,">= 0",RowColumnDefinition,"width"),this.we=t,this.actual=this.ht,this.panel!==null&&this.panel.u(),this.i("width",i,t))}get minimum(){return this.Aa}set minimum(t){const i=this.Aa;i!==t&&(Debug&&Util.t(t,"number",RowColumnDefinition,"minimum"),(t<0||!isFinite(t))&&Util.G(t,">= 0",RowColumnDefinition,"minimum"),this.Aa=t,this.actual=this.ht,this.panel!==null&&this.panel.u(),this.i("minimum",i,t))}get maximum(){return this.La}set maximum(t){const i=this.La;i!==t&&(Debug&&Util.t(t,"number",RowColumnDefinition,"maximum"),t<0&&Util.G(t,">= 0",RowColumnDefinition,"maximum"),this.La=t,this.actual=this.ht,this.panel!==null&&this.panel.u(),this.i("maximum",i,t))}get alignment(){return this.ai}set alignment(t){const i=this.ai;i.equals(t)||(Debug&&Util.s(t,Spot,RowColumnDefinition,"alignment"),this.ai=t.L(),this.panel!==null&&this.panel.u(),this.i("alignment",i,t))}get stretch(){return this.ro}set stretch(t){const i=this.ro;i!==t&&(this.ro=t,this.panel!==null&&this.panel.u(),this.i("stretch",i,t))}get separatorPadding(){return this.Jo}set separatorPadding(t){typeof t=="number"?t=new Margin(t):t!==null&&Debug&&Util.s(t,Margin,RowColumnDefinition,"separatorPadding");const i=this.Jo;(t===null||i===null||!i.equals(t))&&(t!==null&&(t=t.L()),this.Jo=t,this.panel!==null&&this.panel.u(),this.i("separatorPadding",i,t))}get separatorStroke(){return this.Pd}set separatorStroke(t){const i=this.Pd;i!==t&&(t!==null&&Brush.ud(t,"RowColumnDefinition.separatorStroke"),t instanceof Brush&&t.w(),this.Pd=t,this.panel!==null&&this.panel.u(),this.i("separatorStroke",i,t))}get separatorStrokeWidth(){return this.Nd}set separatorStrokeWidth(t){const i=this.Nd;i!==t&&(this.Nd=t,this.panel!==null&&this.panel.u(),this.i("separatorStrokeWidth",i,t))}get separatorDashArray(){return this.Ta}set separatorDashArray(t){const i=this.Ta;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Vi(t,"Array",RowColumnDefinition,"separatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("separatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.Ta=t,this.panel!==null&&this.panel.T(),this.i("separatorDashArray",i,t)}}get background(){return this.Ft}set background(t){const i=this.Ft;i!==t&&(t!==null&&Brush.ud(t,"RowColumnDefinition.background"),t instanceof Brush&&t.w(),this.Ft=t,this.panel!==null&&this.panel.T(),this.i("background",i,t))}get coversSeparators(){return this.Cd}set coversSeparators(t){const i=this.Cd;i!==t&&(Util.t(t,"boolean",RowColumnDefinition,"coversSeparators"),this.Cd=t,this.panel!==null&&this.panel.T(),this.i("coversSeparators",i,t))}get sizing(){return this.Md}set sizing(t){const i=this.Md;i!==t&&(Debug&&Util.tt(t,Sizing,"Sizing"),this.Md=t,this.panel!==null&&this.panel.u(),this.i("sizing",i,t))}eb(){if(this.sizing===1){const t=this.Hs;return this.isRow?t.rowSizing:t.columnSizing}return this.sizing}get actual(){return this.ht}set actual(t){isNaN(this.we)?this.ht=Math.max(Math.min(this.La,t),this.Aa):this.ht=Math.max(Math.min(this.La,this.we),this.Aa)}get measured(){return this.Zi}set measured(t){this.Zi=t}get total(){return this.ht+this.computeEffectiveSpacing()}get position(){return this.mt}set position(t){this.mt=t}bind(t,i,e,s){return this.hc(t,i,e,s),this}bindTwoWay(t,i,e,s){const n=this.hc(t,i,e,s);return s===void 0&&n.makeTwoWay(),this}theme(t,i,e,s,n){return this.mh(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.mh(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.mh(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.mh(t,i,e,s,n).ofModel(),this}hc(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.Z0(n),n}mh(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.Z0(o),o}Z0(t){t.Ce=this;const i=this.panel;if(i!==null){const e=i.findBindingPanel();e!==null&&e.wL()&&Util.n("Cannot add a Binding to a RowColumnDefinition that is already frozen: "+t+" on "+i)}this.Js===null&&(this.Js=new List),this.Js.add(t)}}class Shape extends GraphObject{yt;Ps;Ad;Da;$i;Zo;jo;Rt;Ld;Td;_;constructor(t,i){super(),this.yt=null,this.Ps=null,this.Ad="None",this.Da="black",this.$i="black",this.Zo=1,this.jo=null,this.Rt=null,this.Ld=NaN,this.Td=NaN,this._=null,typeof t=="string"?this.figure=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.yt=this.yt,t.Ps=this.Ps,t.Ad=this.Ad,t.Da=this.Da,t.$i=this.$i,t.Zo=this.Zo,this.jo!==null&&(t.jo=this.jo.slice()),this.Rt!==null&&(this.Rt.wi?t.Rt=this.Rt:t.Rt=this.Rt.copy()),t.Ld=this.Ld,t.Td=this.Td,this._!==null&&(t._=this._.copy())}Fa(){this.Rt===null?this.Rt=new ShapeTemplateSettings:this.Rt.wi&&(this.Rt=this.Rt.copy())}fh(){super.fh(),this.Rt!==null&&(this.Rt.wi=!0)}fi(t){t in GeometryStretch?this.geometryStretch=t:super.fi(t)}toString(){return"Shape("+(this.figure!=="None"?this.figure:this.toArrow!=="None"?this.toArrow:this.fromArrow)+")#"+GSet.gs(this)}MI(t,i){const e=this.pathPattern;e.wt(1/0,1/0);const s=e.measuredBounds;e.qt(0,0,s.width,s.height);const n=this.geometry;t.save(),t.beginPath();const o=Util.ft();if(n.type===1)o.push(n.startX),o.push(n.startY),o.push(n.endX),o.push(n.endY),this.Dd(t,i,o,e);else if(n.type===4){const r=n.figures.iterator;for(;r.next();){const l=r.value;o.length=0,o.push(l.startX),o.push(l.startY);let h=l.startX,a=l.startY,f=h,c=a;const u=l.segments.h,d=u.length;for(let m=0;m=.1;){if(P===0&&(M?(b=k,b-=S,y-=S,M=!1):b=k,b===0&&(b=1)),b>y){b=y,Util.nt(x);return}b>p?(P=b-p,b=p):P=0;let N=Math.sqrt(b*b/(1+m*m));if(u<0&&(N=-N),h+=N,a+=m*N,t.translate(h,a),t.rotate(g),t.translate(-(r/2),-(l/2)),P===0&&s.gh(t,i),t.translate(r/2,l/2),t.rotate(-g),t.translate(-h,-a),y-=b,p-=b,P!==0){if(A++,A===x.length){Util.nt(x);return}C=x[A],u=C[0],g=C[1],m=C[2],p=C[3],b=P}}Util.nt(x)}gh(t,i){const e=t instanceof SVGContext;let s=this.$i;const n=this.Da;if(s===null&&n===null)return;const o=this.yt;if(o===null)return;t.commitTransform();const r=this.actualBounds,l=this.naturalBounds;n!==null&&this.wn(t,n,!0,!1,l,r);const h=this.part;let a=this.Zo;s!==null&&a===0&&h!==null&&(this.isPanelMain||h.findMainElement()===this)&&(a=h.CI()),a===0&&(s=null),s!==null&&a!==0&&(this.wn(t,s,!1,!1,l,r),t.lineWidth=a,t.lineJoin=this.strokeJoin,t.lineCap=this.strokeCap,t.miterLimit=this.strokeMiterLimit);let f=!1;h&&i.getRenderingHint("drawShadows")&&(f=h.isShadowed),t.ol===!1&&(f=!1);let c=!0;s!==null&&(n===null||n==="transparent")&&(c=!1);let u=!1;const d=this.strokeDashArray;if(d!==null&&(u=!0,t.enableDash(d,this.strokeDashOffset)),o.type===1)t.beginPath(),t.moveTo(o.startX,o.startY),t.lineTo(o.endX,o.endY),s!==null&&t.strokeContext(),t.endPath();else if(o.type===2){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.min(m,p),k=Math.min(g,y),b=Math.abs(p-m),S=Math.abs(y-g);t.beginPath(),t.rect(x,k,b,S),n!==null&&t.fillContext(n,!1,null),s!==null&&(c&&f&&t.shadowsOff(),t.strokeContext(),c&&f&&t.shadowsOn()),t.endPath()}else if(o.type===3){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.abs(p-m)/2,k=Math.abs(y-g)/2,b=Math.min(m,p)+x,S=Math.min(g,y)+k;t.beginPath(),t.moveTo(b,S-k),t.bezierCurveTo(b+Geo.Un*x,S-k,b+x,S-Geo.Un*k,b+x,S),t.bezierCurveTo(b+x,S+Geo.Un*k,b+Geo.Un*x,S+k,b,S+k),t.bezierCurveTo(b-Geo.Un*x,S+k,b-x,S+Geo.Un*k,b-x,S),t.bezierCurveTo(b-x,S-Geo.Un*k,b-Geo.Un*x,S-k,b,S-k),t.closePath(),n!==null&&t.fillContext(n,!1,null),s!==null&&(c&&f&&t.shadowsOff(),t.strokeContext(),c&&f&&t.shadowsOn()),t.endPath()}else if(o.type===4){const m=o.figures,g=m.length;for(let p=0;p1||this.pathPattern!==null?!0:super.fd(t)}p2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("path");for(let s=0;s1,i);Util.n("Unknown Geometry type: "+e.type)}}ld(t,i,e,s){const n=this.desiredSize,o=this.Zo;t=Math.max(t,0),i=Math.max(i,0);let r;if(this.Ps!==null)r=this.geometry.bounds;else{const g=this.figure;let p=Shape.q2[g];if(p===void 0){let y=Geo.qn[g];typeof y=="string"&&(y=Geo.qn[y]),typeof y=="function"?(p=y(null,100,100),Shape.q2[g]=p):Util.n("Unsupported Figure: "+g)}r=p.bounds}let l=r.width,h=r.height,a=r.width,f=r.height;switch(this.qs(!0)){case 0:e=0,s=0;break;case 2:a=Math.max(t-o,0),f=Math.max(i-o,0);break;case 5:a=Math.max(t-o,0),s=0;break;case 4:e=0,f=Math.max(i-o,0);break}isFinite(n.width)&&(a=n.width),isFinite(n.height)&&(f=n.height);const u=this.maxSize,d=this.minSize;e=Math.max(e-o,d.width),s=Math.max(s-o,d.height),a=Math.min(u.width,a),f=Math.min(u.height,f),a=isFinite(a)?Math.max(e,a):Math.max(l,e),f=isFinite(f)?Math.max(s,f):Math.max(h,s);const m=this.lM();switch(m){case 0:break;case 2:l=a,h=f;break;case 6:{let g=Math.min(a/l,f/h);isFinite(g)||(g=1),l=l*g,h=h*g;break}default:Util.n(m+" is not a valid geometryStretch.")}if(this.Ps!==null){l===0&&(l=.001),h===0&&(h=.001);const p=(this.Ps!==null?this.Ps:this.yt).$D(l,h);Debug&&p.w(),this.yt=p}else(this.yt===null||!Geo.q(this.yt.ff,t-o)||!Geo.q(this.yt.cf,i-o))&&(this.yt=Shape.AI(this,l,h));r=this.yt.bounds,t===1/0||i===1/0?this.no(r.x-o/2,r.y-o/2,t===0&&l===0?0:r.width+o,i===0&&h===0?0:r.height+o):this.no(-(o/2),-(o/2),a+o,f+o),n.isReal()?(a=n.width,f=n.height,a=Math.min(u.width,a),f=Math.min(u.height,f),a=Math.max(d.width,a),f=Math.max(d.height,f),this.Hi.e(0,0,a,f)):this.Hi.c(r)}lM(){const t=this.geometryStretch;return this.Ps!==null?t===1?2:t:t===1?Shape.q2[this.figure].defaultStretch:t}uh(t,i,e,s){this.commonArrange(t,i,e,s)}getNearestIntersectionPoint(t,i,e){return this.sc(t.x,t.y,i.x,i.y,e)}sc(t,i,e,s,n){const o=this.O,r=1/(o.m11*o.m22-o.m12*o.m21),l=o.m22*r,h=-o.m12*r,a=-o.m21*r,f=o.m11*r,c=r*(o.m21*o.dy-o.m22*o.dx),u=r*(o.m12*o.dx-o.m11*o.dy),d=t*l+i*a+c,m=t*h+i*f+u,g=e*l+s*a+c,p=e*h+s*f+u,y=this.Zo/2;let x=this.yt;x===null&&(this.wt(1/0,1/0),x=this.yt);const k=x.bounds;let b=!1;if(x.type===1)if(this.strokeWidth<=1.5)b=Geo.Hn(x.startX,x.startY,x.endX,x.endY,d,m,g,p,n);else{let S=0,M=0;if(x.startX===x.endX)S=y,M=0;else{const T=(x.endY-x.startY)/(x.endX-x.startX);M=y/Math.sqrt(1+T*T),S=M*T}const A=Util.ft();let C=new Point;Geo.Hn(x.startX+S,x.startY+M,x.endX+S,x.endY+M,d,m,g,p,C)&&A.push(C),C=new Point,Geo.Hn(x.startX-S,x.startY-M,x.endX-S,x.endY-M,d,m,g,p,C)&&A.push(C),C=new Point,Geo.Hn(x.startX+S,x.startY+M,x.startX-S,x.startY-M,d,m,g,p,C)&&A.push(C),C=new Point,Geo.Hn(x.endX+S,x.endY+M,x.endX-S,x.endY-M,d,m,g,p,C)&&A.push(C);const P=A.length;if(P===0)return Util.nt(A),!1;b=!0;let N=1/0;for(let T=0;T0&&k.contains(D,F)&&(P.x=D,P.y=F,this.containsPoint(P)))for(N!==0&&Math.abs(N)<.5?(T*=.5/N,N=.5):T!==0&&Math.abs(T)<.5&&(N*=.5/T,T=.5),D-=N,F-=T;k.contains(D,F);)D-=N,F-=T;const R=.6;n.x=g,n.y=p;for(let K=0;Ke?t-e:e-t)<(i>s?i-s:s-i)){const c=ic||Geo.q(h.y,c))&&(h.yc||Geo.q(h.x,c))&&(h.x=a&&h<=f}else{let a=0,f=0;return s=a&&l<=f}}DI(t,i){if(this.containedInRect(t,i)||i===void 0&&(i=this.O,t.containsRect(this.actualBounds)))return!0;const e=t.left,s=t.right,n=t.top,o=t.bottom,r=Point.a(),l=Point.a(),h=Point.a(),a=Transform.a();a.set(i),a.yC(this.O),a.Pw(),l.x=s,l.y=n,l.O(a),r.x=e,r.y=n,r.O(a);let f=!1;return this.Ra(r,l,h)?f=!0:(r.x=s,r.y=o,r.O(a),this.Ra(r,l,h)?f=!0:(l.x=e,l.y=o,l.O(a),this.Ra(r,l,h)?f=!0:(r.x=e,r.y=n,r.O(a),this.Ra(r,l,h)&&(f=!0)))),Transform.o(a),Point.o(r),Point.o(l),Point.o(h),f}hL(t,i,e){if(e&&this.fill!==null&&this.ch(t,!0))return!0;let s=t.distanceSquaredPoint(i);const n=s;this.strokeWidth>1.5&&(s=this.strokeWidth/2+Math.sqrt(s),s*=s);let o=this.yt;if(o===null&&(this.wt(1/0,1/0),o=this.yt,o===null))return!1;if(!e){const c=o.bounds,u=c.x,d=c.y,m=c.x+c.width,g=c.y+c.height;if(Point.distanceSquared(t.x,t.y,u,d)<=s&&Point.distanceSquared(t.x,t.y,m,d)<=s&&Point.distanceSquared(t.x,t.y,u,g)<=s&&Point.distanceSquared(t.x,t.y,m,g)<=s)return!0}function r(c,u){const d=c.length;for(let m=0;ms)return!0;return!1}const l=o.startX,h=o.startY,a=o.endX,f=o.endY;if(o.type===1){const c=Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,f),u=(a-l)*(t.x-l)+(f-h)*(t.y-h),d=(l-a)*(t.x-a)+(h-f)*(t.y-f),m=u>=0&&d>=0?s:n;return c<=m}else if(o.type===2){let c=!1;return e&&(c=Point.distanceLineSegmentSquared(t.x,t.y,l,h,l,f)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,h)<=s||Point.distanceLineSegmentSquared(t.x,t.y,a,h,a,f)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,f,a,f)<=s),c}else if(o.type===3){const c=(l+a)/2,u=(h+f)/2,d=t.x-c,m=t.y-u,g=Math.abs(a-l)/2,p=Math.abs(f-h)/2;if(g===0||p===0)return Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,f)<=s;if(e){const y=Geo.UD(g,p,d,m);return y*y<=s}else return!(Point.distanceSquared(d,m,-g,0)>=s||Point.distanceSquared(d,m,0,-p)>=s||Point.distanceSquared(d,m,0,p)>=s||Point.distanceSquared(d,m,g,0)>=s)}else if(o.type===4){const c=o.bounds,u=c.x,d=c.y,m=c.x+c.width,g=c.y+c.height;if(t.x>m&&t.xg&&t.ys&&Point.distanceLineSegmentSquared(t.x,t.y,u,d,m,d)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,u,g)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,m,d)>s)return!1;const p=Math.sqrt(s);if(e){if(this.fill===null?o.LC(t.x,t.y,p):o.vk(t,p,!0,!1))return!0}else{const y=o.figures;for(let x=0;xs)return!1;const M=k.segments.h,A=M.length;for(let C=0;Cs)return!1;break;case 3:{const N=Util.ft();Geo.Gn(b,S,P.point1X,P.point1Y,P.point2X,P.point2Y,P.endX,P.endY,.8,N);const T=r(N,t);if(Util.nt(N),T||(b=P.endX,S=P.endY,t.distanceSquared(b,S)>s))return!1;break}case 4:{const N=Util.ft();Geo.jg(b,S,P.point1X,P.point1Y,P.endX,P.endY,.8,N);const T=r(N,t);if(Util.nt(N),T||(b=P.endX,S=P.endY,t.distanceSquared(b,S)>s))return!1;break}case 5:case 6:{const N=P.type===5?P.To(k):P.Xh(k,b,S),T=N.length;if(T===0){if(b=P.type===5?P.centerX:P.endX,S=P.type===5?P.centerY:P.endY,t.distanceSquared(b,S)>s)return!1;break}let L=null;const D=Util.ft();for(let F=0;F=0){this.Zo=t,this.u();const e=this.part;e!==null&&e.mc(),this.i("strokeWidth",i,t)}else Util.G(t,"value >= 0",Shape,"strokeWidth:value")}U1(){return this.Zo}get strokeCap(){return this.Rt!==null?this.Rt.Mp:"butt"}set strokeCap(t){const i=this.strokeCap;i!==t&&(typeof t=="string"&&(t==="butt"||t==="round"||t==="square")?(this.Fa(),this.Rt.Mp=t,this.T(),this.i("strokeCap",i,t)):Util.G(t,'"butt", "round", or "square"',Shape,"strokeCap"))}get strokeJoin(){return this.Rt!==null?this.Rt.Pp:"miter"}set strokeJoin(t){const i=this.strokeJoin;i!==t&&(typeof t=="string"&&(t==="miter"||t==="bevel"||t==="round")?(this.Fa(),this.Rt.Pp=t,this.T(),this.i("strokeJoin",i,t)):Util.G(t,'"miter", "bevel", or "round"',Shape,"strokeJoin"))}get strokeMiterLimit(){return this.Rt!==null?this.Rt.Np:10}set strokeMiterLimit(t){const i=this.strokeMiterLimit;if(i!==t)if(Debug&&Util.r(t,Shape,"strokeMiterLimit"),t>=1){this.Fa(),this.Rt.Np=t,this.T();const e=this.part;e!==null&&e.mc(),this.i("strokeMiterLimit",i,t)}else Debug&&Util.G(t,"value >= 1",Shape,"strokeWidth:value")}get strokeDashArray(){return this.jo}set strokeDashArray(t){const i=this.jo;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Vi(t,"Array",Shape,"strokeDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("strokeDashArray:value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.jo=t,this.T(),this.i("strokeDashArray",i,t)}}get strokeDashOffset(){return this.Rt!==null?this.Rt.ph:0}set strokeDashOffset(t){const i=this.strokeDashOffset;i!==t&&(Debug&&Util.r(t,Shape,"strokeDashOffset"),t>=0&&(this.Fa(),this.Rt.ph=t,this.T(),this.i("strokeDashOffset",i,t)))}get figure(){return this.Ad}set figure(t){const i=this.Ad;if(i!==t){Debug&&Util.t(t,"string",Shape,"figure");let e=Geo.qn[t];if(typeof e=="function"?e=t:(e=Geo.qn[t.toLowerCase()],e||Util.n("Unknown Shape.figure: "+t)),i!==e){const s=this.part;s!==null&&s.mc(),this.Ad=e,this.Ps=null,this.re(),this.u(),this.i("figure",i,e)}}}get toArrow(){return this.Ut!==null?this.Ut.Cp:"None"}set toArrow(t){const i=this.toArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){Debug&&Util.t(t,"string",Shape,"toArrow");const e=Shape.BL(t);e===null?Util.n("Unknown Shape.toArrow: "+t):i!==e&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.Cp=e,this.Ps=null,this.re(),this.u(),this.zL(e),this.i("toArrow",i,e))}}get fromArrow(){return this.Ut!==null?this.Ut.Ap:"None"}set fromArrow(t){const i=this.fromArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){Debug&&Util.t(t,"string",Shape,"fromArrow");const e=Shape.BL(t);e===null?Util.n("Unknown Shape.fromArrow: "+t):i!==e&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.Ap=e,this.Ps=null,this.re(),this.u(),this.zL(e),this.i("fromArrow",i,e))}}zL(t){const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;this.KR();const e=Spot.MiddleRight;this.toArrow!=="None"?(this.segmentIndex=-1,this.alignmentFocus=e):this.fromArrow!=="None"&&(this.segmentIndex=0,this.alignmentFocus=new Spot(1-e.x,e.y))}get spot1(){return this.Rt!==null?this.Rt.jn:Spot.Default}set spot1(t){Util.s(t,Spot,Shape,"spot1");const i=this.spot1;i.equals(t)||(t=t.L(),this.Fa(),this.Rt.jn=t,this.u(),this.i("spot1",i,t))}get spot2(){return this.Rt!==null?this.Rt.Wn:Spot.Default}set spot2(t){Util.s(t,Spot,Shape,"spot2");const i=this.spot2;i.equals(t)||(t=t.L(),this.Fa(),this.Rt.Wn=t,this.u(),this.i("spot2",i,t))}get parameter1(){return this.Ld}set parameter1(t){const i=this.Ld;i!==t&&(this.Ld=t,this.re(),this.u(),this.i("parameter1",i,t))}get parameter2(){return this.Td}set parameter2(t){const i=this.Td;i!==t&&(this.Td=t,this.re(),this.u(),this.i("parameter2",i,t))}get naturalBounds(){return this.Hi}lI(){const t=this.desiredSize;if(!t.isReal()&&this.yt!==null){const i=this.yt.bounds;this.Hi.c(i)}else this.Hi.e(0,0,t.width,t.height)}get pathPattern(){return this.Rt!==null?this.Rt.Lp:null}set pathPattern(t){const i=this.pathPattern;i!==t&&(Debug&&t!==null&&Util.s(t,GraphObject,Shape,"pathPattern"),this.Fa(),this.Rt.Lp=t,this.T(),this.i("pathPattern",i,t))}get geometryStretch(){return this.Rt!==null?this.Rt.Tp:1}set geometryStretch(t){const i=this.geometryStretch;i!==t&&(Util.tt(t,GeometryStretch,"GeometryStretch"),this.Fa(),this.Rt.Tp=t,this.u(),this.i("geometryStretch",i,t))}get interval(){return this._!==null?this._.yc:1}set interval(t){const i=this.interval;if(Debug&&Util.r(t,Shape,"interval"),t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this._===null&&(this._=new GradElementSettings),this._.yc=t;const e=this.diagram;e!==null&&this.panel===e.grid&&e.Zr(),this.u();const s=this.panel;s!==null&&(s.as=null),this.i("interval",i,t)}}get graduatedStart(){return this._!==null?this._.wc:0}set graduatedStart(t){const i=this.graduatedStart;Debug&&Util.r(t,Shape,"graduatedStart"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.wc=t,this.u(),this.i("graduatedStart",i,t))}get graduatedEnd(){return this._!==null?this._.xc:1}set graduatedEnd(t){const i=this.graduatedEnd;Debug&&Util.r(t,Shape,"graduatedEnd"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.xc=t,this.u(),this.i("graduatedEnd",i,t))}get graduatedSkip(){return this._!==null?this._.bc:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.t(t,"function",Shape,"graduatedSkip"),this._===null&&(this._=new GradElementSettings),this._.bc=t,this.u(),this.i("graduatedSkip",i,t))}static AI(t,i,e){let n=null;if(t.toArrow!=="None")n=Shape.fo[t.toArrow];else if(t.fromArrow!=="None")n=Shape.fo[t.fromArrow];else{let o=Geo.qn[t.figure];typeof o=="string"&&(o=Geo.qn[o]),o===void 0&&Util.n("Unknown Shape.figure: "+t.figure),n=o(t,i,e),n.ff=i,n.cf=e}if(n===null){const o=Geo.qn.Rectangle;typeof o=="function"&&(n=o(t,i,e))}return Debug&&(n.bounds.width>i+1e-5||n.bounds.height>e+1e-5)&&Util.n('Geometry made with figure "'+t.figure+'" has bounds '+n.bounds.toString()+" that are too large for the given size ("+i+","+e+"). See documentation for Shape.defineFigureGenerator."),n}static getFigureGenerators(){const t=new GMap;for(const i in Geo.qn){if(i===i.toLowerCase())continue;const e=Geo.qn[i];t.set(i,e)}return t.w(),t}static defineFigureGenerator(t,i){Util.t(t,"string",Shape,"defineFigureGenerator:name"),typeof i=="string"?Debug&&(i===""||!Geo.qn[i])&&Util.n("Shape.defineFigureGenerator synonym must not be empty or None or not a defined figure name: "+i):Util.t(i,"function",Shape,"defineFigureGenerator:func");const e=t.toLowerCase();Debug&&(t===""||t===e)&&Util.n("Shape.defineFigureGenerator name must not be empty or all-lower-case: "+t);const s=Geo.qn;s[t]=i,s[e]=t}static getArrowheadGeometries(){const t=new GMap;for(const i in Geo.Zg)if(Shape.fo[i]===void 0){const e=Geometry.parse(Geo.Zg[i],!1);Shape.fo[i]=e;const s=i.toLowerCase();s!==i&&(Shape.fo[s]=i)}for(const i in Shape.fo){if(i===i.toLowerCase())continue;const e=Shape.fo[i];e instanceof Geometry&&t.set(i,e)}return t.w(),t}static defineArrowheadGeometry(t,i){Util.t(t,"string",Shape,"defineArrowheadGeometry:name");let e=null;typeof i=="string"?(Util.t(i,"string",Shape,"defineArrowheadGeometry:pathstr"),e=Geometry.parse(i,!1)):(Util.s(i,Geometry,Shape,"defineArrowheadGeometry:pathstr"),e=i);const s=t.toLowerCase();(Debug&&t===""||s==="none"||t===s)&&Util.n("Shape.defineArrowheadGeometry name must not be empty or None or all-lower-case: "+t);const n=Shape.fo;n[t]=e,n[s]=t}static fo=new PropertyCollection;static q2=new PropertyCollection;static BL(t){let i=Shape.fo[t];if(i===void 0){const e=t.toLowerCase();if(e==="none")return"None";if(i=Shape.fo[e],i===void 0){let s=null;for(const n in Geo.Zg)if(n.toLowerCase()===e){s=n;break}if(s!==null){const n=Geometry.parse(Geo.Zg[s],!1);return Shape.fo[s]=n,e!==s&&(Shape.fo[e]=s),s}}}return typeof i=="string"?i:i instanceof Geometry?t:null}}class ShapeTemplateSettings{wi;Mp;Pp;Np;ph;Lp;Tp;jn;Wn;constructor(){this.wi=!1,this.Mp="butt",this.Pp="miter",this.Np=10,this.ph=0,this.Lp=null,this.Tp=1,this.jn=Spot.Default,this.Wn=Spot.Default}copy(){const t=new ShapeTemplateSettings;return t.Mp=this.Mp,t.Pp=this.Pp,t.Np=this.Np,t.ph=this.ph,t.Lp=this.Lp,t.Tp=this.Tp,t.jn=this.jn.L(),t.Wn=this.Wn.L(),t}}var Wrap=(w=>(w[w.None=0]="None",w[w.Fit=1]="Fit",w[w.DesiredSize=2]="DesiredSize",w[w.BreakAll=3]="BreakAll",w))(Wrap||{}),TextOverflow=(w=>(w[w.Clip=0]="Clip",w[w.Ellipsis=1]="Ellipsis",w))(TextOverflow||{}),TextFormat=(w=>(w[w.Trim=0]="Trim",w[w.None=1]="None",w))(TextFormat||{});class TextBlock extends GraphObject{ui;$i;Cn;Fe;xi;C0;Fd;_;$;Ol;co;An;Re;Oi;Ln;constructor(t,i){return super(),this.l|=2097152,this.ui="",this.$i="black",this.Cn="13px sans-serif",this.Fe=0,this.xi=0,this.C0=0,this.Fd=null,this._=null,this.$=null,this.Ol=0,this.co=null,this.An=0,this.Re=null,this.Oi=null,this.Ln=null,typeof t=="string"?this.text=t:t&&Object.assign(this,t),i&&Object.assign(this,i),this}cloneProtected(t){super.cloneProtected(t),t.ui=this.ui,t.$i=this.$i,t.Cn=this.Cn,t.Fe=this.Fe,t.xi=this.xi,t.C0=this.C0,t.Fd=this.Fd,this._!==null&&(t._=this._.copy()),this.$!==null&&(this.$.wi?t.$=this.$:t.$=this.$.copy()),t.Ol=this.Ol,t.co=this.co,t.An=this.An,t.Re=this.Re,t.Oi=this.Oi,t.Ln=this.Ln}Tn(){this.$===null?this.$=new TextBlockTemplateSettings:this.$.wi&&(this.$=this.$.copy())}fh(){super.fh(),this.$!==null&&(this.$.wi=!0)}gI(t){this.l=t.l|2048|4096,this._t=t.opacity,this.Ft=t.background,this.qe=t.desiredSize.L(),this.minSize=t.minSize.L(),this.maxSize=t.maxSize.L(),t.Pi!==null?this.Pi=t.Pi.copy():this.Pi=null,this.lt=t.scale,this.jt=t.angle,this.stretch=t.stretch,this.el=t.margin.L(),this.ai=t.alignment.L(),this.tc=t.alignmentFocus.L(),this.segmentFraction=t.segmentFraction,this.segmentOffset=t.segmentOffset.L(),this.segmentOrientation=t.segmentOrientation,t.hi!==null&&(this.hi=t.hi.copy()),this.shadowVisible=t.shadowVisible,this.ui=t.ui,this.$i=t.$i,this.Cn=t.Cn,this._!==null&&(this._=t._.copy()),t.$!==null&&(t.$.wi?this.$=t.$:this.$=t.$.copy()),this.Ol=t.Ol}uI(t){if(this.ui=t.text||"",this.jt=t.labelAngle||0,this.Fe=t.lineCount||0,this.FI(t.lines),t.naturalBounds&&(this.Hi=t.naturalBounds),t.actualBounds){const i=t.actualBounds;this.qt(i.x,i.y,i.width,i.height)}}fi(t){t in Wrap?this.wrap=t:super.fi(t)}toString(){return this.ui.length>22?'TextBlock("'+this.ui.substring(0,20)+'"...)':'TextBlock("'+this.ui+'")'}static getEllipsis(){return TextBlock.Dp}static setEllipsis(t){TextBlock.Dp=t,TextBlock.ab=new PropertyCollection,TextBlock.j2=0}static getBaseline(){return TextBlock.fb}static setBaseline(t){TextBlock.fb=t}static fb=null;static getUnderline(){return TextBlock.cb}static setUnderline(t){TextBlock.cb=t}static cb=null;static None=0;static WrapFit=1;static WrapDesiredSize=2;static WrapBreakAll=3;static OverflowClip=0;static OverflowEllipsis=1;static FormatTrim=0;static FormatNone=1;u(){super.u()}get font(){return this.Cn}set font(t){const i=this.Cn;i!==t&&(Debug&&(Util.t(t,"string",TextBlock,"font"),TextBlock.isValidFont(t)||Util.n('Not a valid font: "'+t+'"')),this.Cn=t,this.co=null,this.u(),this.i("font",i,t))}static isValidFont(t){return root.CSS?root.CSS.supports("font",t):!0}get text(){return this.ui}set text(t){const i=this.ui;t!=null?t=t.toString():t="",i!==t&&(this.ui=t,this.u(),this.i("text",i,t),this.hs(!0))}get textAlign(){return this.$!==null?this.$.Fp:"start"}set textAlign(t){const i=this.textAlign;i!==t&&(Debug&&Util.t(t,"string",TextBlock,"textAlign"),t==="start"||t==="end"||t==="left"||t==="right"||t==="center"?(this.Tn(),this.$.Fp=t,this.T(),this.i("textAlign",i,t)):Debug&&Util.G(t,'"start", "end", "left", "right", or "center"',TextBlock,"textAlign"))}get flip(){return this.$!==null?this.$.uo:0}set flip(t){const i=this.flip;i!==t&&(Util.tt(t,Flip,"Flip"),this.Tn(),this.$.uo=t,this.T(),this.i("flip",i,t))}get verticalAlignment(){return this.$!==null?this.$.hl:Spot.Top}set verticalAlignment(t){const i=this.verticalAlignment;i.equals(t)||(Debug&&(Util.s(t,Spot,TextBlock,"verticalAlignment"),t.isNoSpot()&&Util.n("TextBlock.verticalAlignment for "+this+" must be a real Spot, not:"+t)),t=t.L(),this.Tn(),this.$.hl=t,this.lc(),this.i("verticalAlignment",i,t))}get naturalBounds(){if(!this.Hi.isReal()){const t=Size.a();this.W2(this.ui,999999,t);let i=t.width;Size.o(t);let e=this.XL(i);const s=this.desiredSize;isNaN(s.width)||(i=s.width),isNaN(s.height)||(e=s.height),this.Hi.Kn(i,e)}return this.Hi}get isMultiline(){return(this.l&2097152)!==0}set isMultiline(t){const i=(this.l&2097152)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"isMultiline"),this.l=this.l^2097152,this.u(),this.i("isMultiline",i,t))}get isUnderline(){return(this.l&4194304)!==0}set isUnderline(t){const i=(this.l&4194304)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"isUnderline"),this.l=this.l^4194304,this.hs(!0),this.T(),this.i("isUnderline",i,t))}get isStrikethrough(){return(this.l&8388608)!==0}set isStrikethrough(t){const i=(this.l&8388608)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"isStrikethrough"),this.l=this.l^8388608,this.hs(!0),this.T(),this.i("isStrikethrough",i,t))}get wrap(){return this.$!==null?this.$.Rp:2}set wrap(t){const i=this.wrap;i!==t&&(Debug&&Util.tt(t,Wrap,"Wrap"),this.Tn(),this.$.Rp=t,this.u(),this.i("wrap",i,t))}get overflow(){return this.$!==null?this.$.Ip:0}set overflow(t){const i=this.overflow;i!==t&&(Debug&&Util.tt(t,TextOverflow,"Overflow"),this.Tn(),this.$.Ip=t,this.u(),this.i("overflow",i,t))}get isOverflowed(){return(this.l&16777216)!==0}v2(t){t?this.l|=16777216:this.l&=-16777217}get stroke(){return this.$i}set stroke(t){const i=this.$i;i!==t&&(t!==null&&Brush.ud(t,"TextBlock.stroke"),t instanceof Brush&&t.w(),this.$i=t,this.T(),this.i("stroke",i,t))}get lineCount(){return this.Fe}get lineHeight(){return this.Op()}get editable(){return(this.l&1048576)!==0}set editable(t){const i=(this.l&1048576)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"editable"),this.l=this.l^1048576,this.i("editable",i,t))}get B2(){return(this.l&33554432)!==0}set B2(t){this.l=this.l^33554432}get textEditor(){return this.$!==null?this.$.Ep:null}set textEditor(t){const i=this.textEditor;i!==t&&(Debug&&!(t instanceof HTMLInfo)&&Util.n("TextBlock.textEditor must be an HTMLInfo."),this.Tn(),this.$.Ep=t,this.i("textEditor",i,t))}get errorFunction(){return this.$!==null?this.$.fs:null}set errorFunction(t){const i=this.errorFunction;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"errorFunction"),this.Tn(),this.$.fs=t,this.i("errorFunction",i,t))}get interval(){return this._!==null?this._.yc:1}set interval(t){const i=this.interval;if(Debug&&Util.r(t,TextBlock,"interval"),t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this._===null&&(this._=new GradElementSettings),this._.yc=t,this.u();const e=this.panel;e!==null&&(e.as=null),this.i("interval",i,t)}}get graduatedStart(){return this._!==null?this._.wc:0}set graduatedStart(t){const i=this.graduatedStart;Debug&&Util.r(t,TextBlock,"graduatedStart"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.wc=t,this.u(),this.i("graduatedStart",i,t))}get graduatedEnd(){return this._!==null?this._.xc:1}set graduatedEnd(t){const i=this.graduatedEnd;Debug&&Util.r(t,TextBlock,"graduatedEnd"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.xc=t,this.u(),this.i("graduatedEnd",i,t))}get graduatedFunction(){return this._!==null?this._.Vp:null}set graduatedFunction(t){const i=this.graduatedFunction;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"graduatedFunction"),this._===null&&(this._=new GradElementSettings),this._.Vp=t,this.u(),this.i("graduatedFunction",i,t))}get graduatedSkip(){return this._!==null?this._.bc:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"graduatedSkip"),this._===null&&(this._=new GradElementSettings),this._.bc=t,this.u(),this.i("graduatedSkip",i,t))}gh(t,i){if(this.$i===null||this.ui.length===0||this.Cn===null)return;const e=this.naturalBounds,s=this.actualBounds,n=e.width,o=e.height,r=this.Op();let l=t.textAlign=this.textAlign;const h=i.Ju;l==="start"?l=h?"right":"left":l==="end"&&(l=h?"left":"right");const a=this.isUnderline,f=this.isStrikethrough;this.wn(t,this.$i,!0,!1,e,s),(a||f)&&this.wn(t,this.$i,!1,!1,e,s);const c=0;let u=0;const d=n;let m=!1;i.ei===t&&!(i.ei instanceof SVGContext)&&!this.B2&&i.getRenderingHint("textGreeking")===!0&&r*this.ga*i.scale<3&&(m=!0);const g=this.spacingAbove,p=this.spacingBelow;switch(this.flip){case 0:break;case 2:t.translate(n,0),t.scale(-1,1);break;case 1:t.translate(0,o),t.scale(1,-1);break;case 3:t.translate(n,o),t.scale(-1,-1);break}t.commitTransform();const y=this.Fe,k=(g+r+p)*y;if(o>k){const b=this.verticalAlignment;u=b.y*o-b.y*k+b.offsetY}if(y===1&&this.Ln!==null){let b=this.xi;b>d&&(b=d),u+=g,this.YL(this.Ln,t,c,u,d,r,b,m,l,a,f)}else if(this.Re!==null&&this.Oi!==null)for(let b=0;bd&&(S=d),u+=g,this.YL(this.Oi[b],t,c,u,d,r,S,m,l,a,f),u+=r+p}switch(this.flip){case 0:break;case 2:t.scale(-1,1),t.translate(-n,0);break;case 1:t.scale(1,-1),t.translate(0,-o);break;case 3:t.scale(-1,-1),t.translate(-n,-o);break}}YL(t,i,e,s,n,o,r,l,h,a,f){let c=0;if(l){h==="left"?c=0:h==="right"?c=n-r:h==="center"&&(c=(n-r)/2);const m=i.globalAlpha;i.globalAlpha=m/2,i.fillRect(e+c,s+o/4,r,o/2),i.globalAlpha=m;return}h==="left"?c=0:h==="right"?c=n:h==="center"&&(c=n/2);const u=TextBlock.fb!==null?TextBlock.fb(this,o):o*.75;i.fillText(t,e+c,s+u);let d=o/20|0;if(d===0&&(d=1),h==="right"?c-=r:h==="center"&&(c-=r/2),a){const m=TextBlock.cb!==null?TextBlock.cb(this,o):o*.8;this.KL(e+c,s+m,e+c+r,s+m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}if(f){let m=s+o-o/2.2|0;d%2!==0&&(m+=.5),this.KL(e+c,m,e+c+r,m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}}KL(t,i,e,s,n,o){o.beginPath(),o.lineWidth=n,o.moveTo(t,i),o.lineTo(e,s),o.stroke(),o.endPath()}nc(t,i,e){if(!super.nc(t,i,e))return!1;if(this.wn(t,this.$i,!0,!1,this.naturalBounds,this.actualBounds),e){if(this.svg.getElementsByTagName("text").length===0)return!0;const n=this.svg.getElementsByClassName("gojs-td");for(let o=0;o1||this.isUnderline||this.isStrikethrough?!0:super.fd(t)}p2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("text");for(let s=0;sthis.maxLines&&(this.l|=16777216))}W2(t,i,e){const s=this.formatting===0;s&&(t=t.trim());let n=0,o=0,r=0;const l=this.Cn,h=this.spacingAbove+this.spacingBelow,a=Math.max(0,this.Op()+h),f=this.overflow===1?this.GL(l):0;if(this.Fe>=this.maxLines){e!==null&&e.e(0,a);return}let c=t;if(this.wrap===0){if(this.An=1,o=this.getStringWidth(t),f===0||o<=i){this.xi=Math.max(this.xi,o),this.Dn(t,this.xi),e!==null&&e.e(o,a);return}let d=this.Rd(c);c=c.substring(d.length);let m=this.Rd(c);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,c=c.substring(m.length),m=this.Rd(c),r=o;let g=d+m;s&&(g=g.trim()),o=this.getStringWidth(g)}for(s&&(m=m.trim()),d+=m,i=Math.max(1,i-f);this.getStringWidth(d)>i&&d.length>1;)d=d.substring(0,d.length-1);this.v2(!0),d+=TextBlock.Dp,r=this.getStringWidth(d),this.xi=r,this.Dn(d,r),e!==null&&e.e(r,a);return}let u=0;for(c.length===0&&(u=1,this.Dn(c,0));c.length>0;){let d=this.Rd(c);for(c=c.substring(d.length);this.getStringWidth(d)>i;){let p=1;for(o=this.getStringWidth(d.substring(0,p)),r=0;o<=i;)p++,r=o,o=this.getStringWidth(d.substring(0,p));let y=0;p===1?(y=o,n=Math.max(n,o)):(y=r,n=Math.max(n,r)),p--,p<1&&(p=1);const x=d.substring(0,p);if(this.Dn(x,y),u++,d=d.substring(p),this.Fe+u>this.maxLines)break}let m=this.Rd(c);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,c=c.substring(m.length),m=this.Rd(c),r=o;let p=d+m;s&&(p=p.trim()),o=this.getStringWidth(p)}if(s&&(d=d.trim()),d==="")continue;d[d.length-1]==="\xAD"&&(d=d.substring(0,d.length-1)+"\u2010");let g=0;if(m.length===0?(g=o,n=Math.max(n,o)):(r=this.getStringWidth(d),g=r,n=Math.max(n,r)),this.Dn(d,g),u++,this.Fe+u>this.maxLines)break}this.An=Math.min(this.maxLines,u),this.xi=Math.max(this.xi,n),e!==null&&e.e(this.xi,a*this.An)}EI(t,i){if(this.xi===0||this.Re===null||this.Oi===null||this.overflow!==1)return;const e=this.Cn,s=this.overflow===1?this.GL(e):0,n=this.spacingAbove+this.spacingBelow,o=Math.max(0,this.Op()+n),r=Math.min(this.maxLines-1,Math.max(Math.floor(i/o+.01)-1,0));if(r+1>=this.Oi.length)return;this.v2(!0);let l=this.Oi[r];const h=Math.max(1,t-s);for(;this.getStringWidth(l)>h&&l.length>1;)l=l.substring(0,l.length-1);l+=TextBlock.Dp;const a=this.getStringWidth(l);this.Oi[r]=l,this.Oi=this.Oi.slice(0,r+1),this.Re[r]=a,this.Re=this.Re.slice(0,r+1),this.An=this.Oi.length,this.xi=Math.max(this.xi,a),this.Fe=this.An,this.Fe===1&&(this.Ln=this.Oi[0])}Rd(t){if(this.wrap===3)return t.substring(0,1);let i=t.length,e=0;const s=TextBlock.VI;for(;e=t.length?t:t.substring(0,e)}getStringWidth(t){return TextBlock.rl===null?t.length*8:TextBlock.rl.measureText(t).width}Op(){if(this.co!==null)return this.co;const t=this.Cn;let i=0;return TextBlock.rl===null?(i=16,this.co=i,i):(TextBlock.J2[t]!==void 0&&TextBlock.HL<5e3?i=TextBlock.J2[t]:(i=TextBlock.rl.measureText("M").width*1.3,TextBlock.J2[t]=i,TextBlock.HL++),this.co=i,i)}GL(t){if(TextBlock.rl===null)return 6;let i=0;return TextBlock.ab[t]!==void 0&&TextBlock.j2<5e3?i=TextBlock.ab[t]:(i=TextBlock.rl.measureText(TextBlock.Dp).width,TextBlock.ab[t]=i,TextBlock.j2++),i}ub(t,i){return t.indexOf(` + or you could collect items to be removed from the collection after the iteration.`)}static ur(t,i){Util.n("No property to set for this enum value: "+i+" on "+t.toString())}static ht(t){root.console&&root.console.log(t)}static Mt(t){return typeof t=="object"&&t!==null}static Ug(t,i,e){Array.isArray(t)||Util.Bi(t,"Array",i,e)}static au(t,i,e){Array.isArray(t)?i>=t.length?t.push(e):t.splice(i,0,e):Util.n("Cannot insert an object into an HTMLCollection or NodeList: "+e+" at "+i)}static lf(t,i){Array.isArray(t)?i>=t.length?t.pop():t.splice(i,1):Util.n("Cannot remove an object from an HTMLCollection or NodeList at "+i)}static Ok=[];static at(){const t=Util.Ok.pop();return t===void 0?[]:t}static nt(t){t.length=0,Util.Ok.push(t)}static iE=Object.freeze([]);static hu(t){return t===null?"*":typeof t=="string"?t:typeof t=="function"?t.name:""}static hn(t){return typeof t=="function"?t.className?t.className:t.name:Util.Mt(t)&&t.constructor?Util.hn(t.constructor):typeof t}static Xh(t,i){return i==null||i===""?null:Util.Mt(t)&&i in t||t[i]?t[i]:null}static toString(t){let i=t;return Util.Mt(t)&&(t.text?i=t.text:t.name?i=t.name:t.key!==void 0?i=t.key:t.id!==void 0?i=t.id:t.constructor===Object&&(t.Text?i=t.Text:t.Name?i=t.Name:t.Key!==void 0?i=t.Key:t.Id!==void 0?i=t.Id:t.ID!==void 0&&(i=t.ID))),i===void 0?"undefined":i===null?"null":i.toString()}static yw(t,i){if(t.hasOwnProperty(i))return!0;let e=Object.getPrototypeOf(t);for(;e&&e!==Function;){if(e.hasOwnProperty(i))return!0;const s=e.eE;if(s&&s[i])return!0;e=Object.getPrototypeOf(e)}return!1}static OD(t){const i=[];let e=0;for(e=0;e<256;e++)i[e]=e;let s=0,n=0;for(e=0;e<256;e++)s=(s+i[e]+119)%256,n=i[e],i[e]=i[s],i[s]=n;e=0,s=0;let o="";for(let r=0;r>4)+i.charAt(r&15)]=String.fromCharCode(r);t.length%2&&(t="0"+t);const s=[];let n=0;for(let r=0;r0){const n=i[0];return this.key=0,this.value=n,n}else return null}any(t){const i=this.Qt;i.dr=null;const e=i.dt;this.Bt=-1;const s=i.h,n=s.length,o=this.Rs;for(let r=0;r=0?(this.key=i,this.value=t.h[i],!0):(this.wl(),!1)}hasNext(){return this.next()}first(){const t=this.Qt;this.vt=t.dt;const i=t.h,e=i.length-1;if(this.Bt=e,e>=0){const s=i[e];return this.key=e,this.value=s,s}else return null}any(t){const i=this.Qt;i.gr=null;const e=i.dt,s=i.h,n=s.length;this.Bt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(t(r))return!0;i.dt!==e&&Util.ze(i)}return!1}all(t){const i=this.Qt;i.gr=null;const e=i.dt,s=i.h,n=s.length;this.Bt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(!t(r))return!1;i.dt!==e&&Util.ze(i)}return!0}each(t){const i=this.Qt;i.gr=null;const e=i.dt,s=i.h,n=s.length;this.Bt=n;for(let o=n-1;o>=0;o--){const r=s[o];t(r),i.dt!==e&&Util.ze(i)}return this}map(t){const i=this.Qt;i.gr=null;const e=i.dt,s=[],n=i.h,o=n.length;this.Bt=o;for(let l=o-1;l>=0;l--){const h=n[l];s.push(t(h)),i.dt!==e&&Util.ze(i)}const r=new List;return r.h=s,r.Xe(),r.iterator}filter(t){const i=this.Qt;i.gr=null;const e=i.dt,s=[],n=i.h,o=n.length;this.Bt=o;for(let l=o-1;l>=0;l--){const h=n[l];t(h)&&s.push(h),i.dt!==e&&Util.ze(i)}const r=new List;return r.h=s,r.Xe(),r.iterator}get count(){return this.Qt.h.length}wl(){this.key=-1,this.value=null,this.vt=-1,this.Qt.gr=this}toString(){return"ListIteratorBackwards("+this.Bt+"/"+this.Qt.count+")"}}class List{f;h;dt;dr;gr;constructor(t){GSet.vi(this),this.f=!1,this.h=[],this.dt=0,this.dr=null,this.gr=null,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.h.values()}Xe(){let t=this.dt;t++,t>999999999&&(t=0),this.dt=t}w(){return this.f=!0,this}ft(){return this.f=!1,this}toString(){return"List()#"+GSet.gs(this)}add(t){return this.f&&Util.F(this,t),this.h.push(t),this.Xe(),this}push(t){this.add(t)}addAll(t){if(t===null)return this;this.f&&Util.F(this);const i=this.h;if(Array.isArray(t)){const e=t.length;for(let s=0;s=i.length)&&Util.G(t,"0 <= i < length",List,"elt:i"),i[t]}get(t){return this.elt(t)}setElt(t,i){Debug&&Util.r(t,List,"setElt:i");const e=this.h;(t<0||t>=e.length)&&Util.G(t,"0 <= i < length",List,"setElt:i"),this.f&&Util.F(this,t),e[t]=i}set(t,i){this.setElt(t,i)}first(){const t=this.h;return t.length===0?null:t[0]}last(){const t=this.h,i=t.length;return i>0?t[i-1]:null}pop(){this.f&&Util.F(this);const t=this.h;return t.length>0?t.pop():null}any(t){const i=this.h,e=this.dt,s=i.length;for(let n=0;n= 0",List,"insertAt:i"),this.f&&Util.F(this,t);const e=this.h;t>=e.length?e.push(i):e.splice(t,0,i),this.Xe()}remove(t){return this.delete(t)}delete(t){if(t===null)return!1;this.f&&Util.F(this,t);const i=this.h,e=i.indexOf(t);return e===-1?!1:(e===i.length-1?i.pop():i.splice(e,1),this.Xe(),!0)}removeAt(t){Debug&&Util.r(t,List,"removeAt:i");const i=this.h;(t<0||t>=i.length)&&Util.G(t,"0 <= i < length",List,"removeAt:i"),this.f&&Util.F(this,t),t===i.length-1?i.pop():i.splice(t,1),this.Xe()}removeRange(t,i){Debug&&(Util.r(t,List,"removeRange:from"),Util.r(i,List,"removeRange:to"));const e=this.h,s=e.length;if(t<0)t=0;else if(t>=s)return this;if(i<0)return this;if(i>=s&&(i=s-1),t>i)return this;this.f&&Util.F(this);let n=t,o=i+1;for(;o0&&(t.h=Array.prototype.slice.call(i)),t}toArray(){const t=this.h,i=this.count,e=new Array(i);for(let s=0;s=n-1)&&Util.G(i,"0 <= from < length",List,"sortRange:from"),o===2){const r=s[i],l=s[i+1];return t(r,l)>0&&(s[i]=l,s[i+1]=r,this.Xe()),this}if(i===0)if(e>=n)s.sort(t);else{const r=s.slice(0,e);r.sort(t);for(let l=0;l=n){const r=s.slice(i);r.sort(t);for(let l=i;li.add(t(e))),i.iterator}filter(t){const i=new List;return this.Ao.k.forEach(e=>{t(e)&&i.add(e)}),i.iterator}get count(){return this.Ao.count}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"SetIterator"}}class GSet{f;k;constructor(t){this.f=!1,this.k=new Set,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.k.values()}values(){return this.k.values()}w(){return this.f=!0,this}ft(){return this.f=!1,this}toString(){return"Set()#"+GSet.gs(this)}add(t){return t===null?this:(this.k.add(t),this)}addAll(t){if(t===null)return this;if(Array.isArray(t)){const i=t.length;for(let e=0;et.add(i)),t}toArray(){return Array.from(this.k)}toList(){const t=new List;return this.k.forEach(i=>t.add(i)),t}get count(){return this.k.size}get size(){return this.k.size}get iterator(){return this.k.size<=0?EmptyIterator.instance:new SetIterator(this)}entries(){return this.k.entries()}keys(){return this.k.keys()}forEach(t,i){return this.k.forEach(t,i)}static fu=1;static vi(t){t.__gohashid=GSet.fu++}static gs(t){return t.__gohashid}}class MapKeySetIterator{et;ri;constructor(t){this.et=t,this.ri=t.k.keys()}[Symbol.iterator](){return this.et.k.keys()}key;value;get iterator(){return this}reset(){const t=this.et;this.ri=t.k.keys()}next(){const t=this.ri.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.et.k.size===0?null:(this.ri=this.et.k.keys(),this.ri.next().value)}any(t){for(const i of this.et.k)if(t(i[0]))return!0;return!1}all(t){for(const i of this.et.k)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.et.k)t(i[0]);return this}map(t){const i=this.et,e=new List;for(const s of i.k)e.add(t(s[0]));return e.iterator}filter(t){const i=this.et,e=new List;for(const s of i.k){const n=s[0];t(n)&&e.add(n)}return e.iterator}get count(){return this.et.size}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"MapKeySetIterator"}}class MapKeySet extends GSet{et;constructor(t){super(),GSet.vi(this),this.f=!0,this.et=t}[Symbol.iterator](){return this.k.keys()}values(){return this.k.keys()}w(){return this}ft(){return this}toString(){return"MapKeySet("+this.et.toString()+")"}add(t){Util.n("This Set is read-only: "+this.toString())}has(t){return this.et.has(t)}contains(t){return this.has(t)}delete(t){Util.n("This Set is read-only: "+this.toString())}remove(t){return this.delete(t)}clear(){Util.n("This Set is read-only: "+this.toString())}first(){return this.et.k.size===0?null:this.et.k.keys().next().value}any(t){for(const i of this.et.k)if(t(i[0]))return!0;return!1}all(t){for(const i of this.et.k)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.et.k)t(i[0]);return this}map(t){const i=new GSet;for(const e of this.et.k)i.add(t(e[0]));return i}filter(t){const i=new GSet;for(const e of this.et.k){const s=e[0];t(s)&&i.add(s)}return i}copy(){return new MapKeySet(this.et)}toSet(){const t=new GSet,i=this.et.k;for(const e of i)t.add(e[0]);return t}toArray(){const t=this.et.k,i=new Array(t.size);let e=0;for(const s of t)i[e]=s[0],e++;return i}toList(){const t=new List,i=this.et.k;for(const e of i)t.add(e[0]);return t}get count(){return this.et.size}get size(){return this.et.size}get iterator(){return this.et.size<=0?EmptyIterator.instance:new MapKeySetIterator(this.et)}}class MapValueSetIterator{et;ri;constructor(t){this.et=t,this.ri=t.k.values()}[Symbol.iterator](){return this.et.k.values()}key;value;get iterator(){return this}reset(){const t=this.et;this.ri=t.k.values()}next(){const t=this.ri.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.et.k.size===0?null:(this.ri=this.et.k.values(),this.ri.next().value)}any(t){for(const i of this.et.k)if(t(i[1]))return!0;return!1}all(t){for(const i of this.et.k)if(!t(i[1]))return!1;return!0}each(t){for(const i of this.et.k)t(i[1]);return this}map(t){const i=this.et,e=new List;for(const s of i.k)e.add(t(s[1]));return e.iterator}filter(t){const i=this.et,e=new List;for(const s of i.k){const n=s[1];t(n)&&e.add(n)}return e.iterator}get count(){return this.et.size}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"MapValueSetIterator"}}class KeyValuePair{constructor(t,i){this.key=t,this.value=i}toString(){return"{"+this.key+":"+this.value+"}"}key;value}class MapIterator{et;ri;constructor(t){this.et=t,this.ri=t.k.entries()}[Symbol.iterator](){return this.et.k.entries()}key;value;get iterator(){return this}reset(){const t=this.et;this.ri=t.k.entries()}next(){const t=this.ri.next();return t.done?(this.key=null,this.value=null,!1):(this.key=t.value[0],this.value=t.value[1],!0)}hasNext(){return this.next()}first(){if(this.et.k.size===0)return null;this.ri=this.et.k.entries();const t=this.ri.next().value;return this.key=t[0],this.value=t[1],new KeyValuePair(t[0],t[1])}any(t){return this.et.any(t)}all(t){return this.et.all(t)}each(t){return this.et.each(t),this}map(t){const i=new List;let e=null;return this.et.k.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),i.add(t(e))}),i.iterator}filter(t){const i=new List;let e=null;return this.et.k.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),t(e)&&(i.add(e),e=null)}),i.iterator}get count(){return this.et.size}wl(){this.key=null,this.value=null,this.ri=null}toString(){return"MapIterator"}}class GMap{f;k;constructor(t){GSet.vi(this),this.f=!1,this.k=new Map,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.k.entries()}entries(){return this.k.entries()}w(){return this.f=!0,this}ft(){return this.f=!1,this}toString(){return"Map()#"+GSet.gs(this)}set(t,i){return this.f&&Util.F(this,t),this.k.set(t,i),this}add(t,i){return this.set(t,i)}addAll(t){if(t===null)return this;if(this.f&&Util.F(this),Array.isArray(t)){const i=t.length;for(let e=0;ei.x.toFixed(t)+" "+i.y.toFixed(t)}toString(){return"Point("+this.x+","+this.y+")"}equals(t){return t instanceof Point?this.S===t.x&&this.P===t.y:!1}equalTo(t,i){return this.S===t&&this.P===i}equalsApprox(t){return Geo.p(this.S,t.x)&&Geo.p(this.P,t.y)}add(t){return Debug&&(Util.s(t,Point,Point,"add:p"),this.st()),this.S+=t.x,this.P+=t.y,this}subtract(t){return Debug&&(Util.s(t,Point,Point,"subtract:p"),this.st()),this.S-=t.x,this.P-=t.y,this}offset(t,i){return Debug&&(Util.r(t,Point,"offset:dx"),Util.r(i,Point,"offset:dy"),this.st()),this.S+=t,this.P+=i,this}rotate(t){if(Debug&&(Util.r(t,Point,"rotate:angle"),this.st()),t===0)return this;const i=this.S,e=this.P;if(i===0&&e===0)return this;let s=0,n=0;if(t>=360?t-=360:t<0&&(t+=360),t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const o=t*Math.PI/180;s=Math.cos(o),n=Math.sin(o)}return this.S=s*i-n*e,this.P=n*i+s*e,this}scale(t,i){return Debug&&(Util.r(t,Point,"scale:sx"),Util.r(i,Point,"scale:sy"),this.st()),this.S*=t,this.P*=i,this}distanceSquaredPoint(t){Debug&&Util.s(t,Point,Point,"distanceSquaredPoint:p");const i=t.x-this.S,e=t.y-this.P;return i*i+e*e}distanceSquared(t,i){Debug&&(Util.r(t,Point,"distanceSquared:px"),Util.r(i,Point,"distanceSquared:py"));const e=t-this.S,s=i-this.P;return e*e+s*s}normalize(){Debug&&this.st();const t=this.S,i=this.P,e=Math.sqrt(t*t+i*i);return e>0&&(this.S=t/e,this.P=i/e),this}directionPoint(t){return Debug&&Util.s(t,Point,Point,"directionPoint:p"),this.sC(t.x-this.S,t.y-this.P)}direction(t,i){return Debug&&(Util.r(t,Point,"direction:px"),Util.r(i,Point,"direction:py")),this.sC(t-this.S,i-this.P)}sC(t,i){if(t===0)return i>0?90:i<0?270:0;if(i===0)return t>0?0:180;{if(isNaN(t)||isNaN(i))return 0;let e=Math.atan(Math.abs(i/t))*180/Math.PI;return t<0?i<0?e+=180:e=180-e:i<0&&(e=360-e),e}}static compareWithLineSegment(t,i,e,s,n,o){return Debug&&(Util.r(t,Point,"compareWithLineSegment:a1x"),Util.r(i,Point,"compareWithLineSegment:a1y"),Util.r(e,Point,"compareWithLineSegment:a2x"),Util.r(s,Point,"compareWithLineSegment:a2y"),Util.r(n,Point,"compareWithLineSegment:b1x"),Util.r(o,Point,"compareWithLineSegment:b1y")),Geo.cu(t,i,e,s,n,o)}compareWithLineSegmentPoint(t,i){return Debug&&(Util.s(t,Point,Point,"compareWithLineSegmentPoint:p"),Util.s(i,Point,Point,"compareWithLineSegmentPoint:q")),Geo.cu(t.x,t.y,i.x,i.y,this.x,this.y)}static intersectingLineSegments(t,i,e,s,n,o,r,l){return Debug&&(Util.r(t,Point,"intersectingLineSegments:a1x"),Util.r(i,Point,"intersectingLineSegments:a1y"),Util.r(e,Point,"intersectingLineSegments:a2x"),Util.r(s,Point,"intersectingLineSegments:a2y"),Util.r(n,Point,"intersectingLineSegments:b1x"),Util.r(o,Point,"intersectingLineSegments:b1y"),Util.r(r,Point,"intersectingLineSegments:b2x"),Util.r(l,Point,"intersectingLineSegments:b2y")),Geo.uu(t,i,e,s,n,o,r,l)}projectOntoLineSegment(t,i,e,s){return Debug&&(Util.r(t,Point,"projectOntoLineSegment:px"),Util.r(i,Point,"projectOntoLineSegment:py"),Util.r(e,Point,"projectOntoLineSegment:qx"),Util.r(s,Point,"projectOntoLineSegment:qy")),Geo.xl(t,i,e,s,this.S,this.P,this),this}projectOntoLineSegmentPoint(t,i){return Debug&&(Util.s(t,Point,Point,"projectOntoLineSegmentPoint:p"),Util.s(i,Point,Point,"projectOntoLineSegmentPoint:q")),Geo.xl(t.x,t.y,i.x,i.y,this.S,this.P,this),this}snapToGrid(t,i,e,s){return Debug&&(Util.r(t,Point,"snapToGrid:originx"),Util.r(i,Point,"snapToGrid:originy"),Util.r(e,Point,"snapToGrid:cellwidth"),Util.r(s,Point,"snapToGrid:cellheight")),Geo.Gg(this.S,this.P,t,i,e,s,this),this}snapToGridPoint(t,i){return Debug&&(Util.s(t,Point,Point,"snapToGridPoint:p"),Util.s(i,Size,Point,"snapToGridPoint:q")),Geo.Gg(this.S,this.P,t.x,t.y,i.width,i.height,this),this}setRectSpot(t,i){return Debug&&(Util.s(t,Rect,Point,"setRectSpot:r"),Util.s(i,Spot,Point,"setRectSpot:spot"),this.st()),this.S=t.x+i.x*t.width+i.offsetX,this.P=t.y+i.y*t.height+i.offsetY,this}setSpot(t,i,e,s,n){return Debug&&(Util.r(t,Point,"setSpot:x"),Util.r(i,Point,"setSpot:y"),Util.r(e,Point,"setSpot:w"),Util.r(s,Point,"setSpot:h"),(e<0||s<0)&&Util.n("Point.setSpot:Width and height cannot be negative"),Util.s(n,Spot,Point,"setSpot:spot"),this.st()),this.S=t+n.x*e+n.offsetX,this.P=i+n.y*s+n.offsetY,this}O(t){return t.Pt(this),this}Ye(t){return t.ns(this),this}static distanceLineSegmentSquared(t,i,e,s,n,o){Debug&&(Util.r(t,Point,"distanceLineSegmentSquared:px"),Util.r(i,Point,"distanceLineSegmentSquared:py"),Util.r(e,Point,"distanceLineSegmentSquared:ax"),Util.r(s,Point,"distanceLineSegmentSquared:ay"),Util.r(n,Point,"distanceLineSegmentSquared:bx"),Util.r(o,Point,"distanceLineSegmentSquared:by"));let r=n-e,l=o-s;const h=r*r+l*l,a=e-t,f=s-i,c=-a*r-f*l;if(c<=0||c>=h)return r=n-t,l=o-i,Math.min(a*a+f*f,r*r+l*l);{const u=r*f-l*a;return u*u/h}}static distanceSquared(t,i,e,s){Debug&&(Util.r(t,Point,"distanceSquared:px"),Util.r(i,Point,"distanceSquared:py"),Util.r(e,Point,"distanceSquared:qx"),Util.r(s,Point,"distanceSquared:qy"));const n=e-t,o=s-i;return n*n+o*o}static direction(t,i,e,s){Debug&&(Util.r(t,Point,"direction:px"),Util.r(i,Point,"direction:py"),Util.r(e,Point,"direction:qx"),Util.r(s,Point,"direction:qy"));const n=e-t,o=s-i;if(n===0)return o>0?90:o<0?270:0;if(o===0)return n>0?0:180;{if(isNaN(n)||isNaN(o))return 0;let r=Math.atan(Math.abs(o/n))*180/Math.PI;return n<0?o<0?r+=180:r=180-r:o<0&&(r=360-r),r}}get x(){return this.S}set x(t){Debug&&(Util.t(t,"number",Point,"x"),this.st(t)),this.S=t}get y(){return this.P}set y(t){Debug&&(Util.t(t,"number",Point,"y"),this.st(t)),this.P=t}isReal(){return isFinite(this.x)&&isFinite(this.y)}static Lo=new Point(0,0).ot();static nC=new Point(-1/0,-1/0).ot();static oC=new Point(1/0,1/0).ot();static rC=new Point(6,6).ot();static Bk=new Point(NaN,NaN).ot();static Vk=[];static a(){const t=Point.Vk.pop();return t===void 0?new Point:t}static H(t,i){const e=Point.Vk.pop();return e===void 0?new Point(t,i):(e.x=t,e.y=i,e)}static o(t){Point.Vk.push(t)}}class Size{v;J;f;constructor(t,i){t===void 0?(this.v=0,this.J=0):typeof t=="number"&&(t>=0||isNaN(t))&&typeof i=="number"&&(i>=0||isNaN(i))?(this.v=t,this.J=i):Util.n("Invalid arguments to Size constructor: "+t+", "+i),this.f=!1}c(t){return this.v=t.v,this.J=t.J,this}e(t,i){return this.v=t,this.J=i,this}setTo(t,i){return Debug&&(Util.t(t,"number",Size,"setTo:w"),Util.t(i,"number",Size,"setTo:h"),t<0&&Util.G(t,">= 0",Size,"setTo:w"),i<0&&Util.G(i,">= 0",Size,"setTo:h"),this.st()),this.v=t,this.J=i,this}set(t){return Debug&&(Util.s(t,Size,Size,"set:s"),this.st()),this.v=t.v,this.J=t.J,this}copy(){const t=new Size;return t.v=this.v,t.J=this.J,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ft(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}st(t){if(Debug&&this.f){let i="The Size is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;return n=i[e++],n&&(o=parseFloat(n)),new Size(s,o)}else return new Size}static stringify(t){return Debug&&Util.s(t,Size),t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.t(t,"number",Size,"stringifyFixed:digits"),i=>i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Size("+this.width+","+this.height+")"}equals(t){return t instanceof Size?this.v===t.width&&this.J===t.height:!1}equalTo(t,i){return this.v===t&&this.J===i}equalsApprox(t){return Geo.p(this.v,t.width)&&Geo.p(this.J,t.height)}inflate(t,i){Debug&&(Util.r(t,Size,"inflate:w"),Util.r(i,Size,"inflate:h"));const e=this.width+t;this.v=e>=0?e:0;const s=this.height+i;return this.J=s>=0?s:0,this}get width(){return this.v}set width(t){Debug&&(Util.t(t,"number",Size,"width"),this.st(t)),t<0&&Util.G(t,">= 0",Size,"width"),this.v=t}get height(){return this.J}set height(t){Debug&&(Util.t(t,"number",Size,"height"),this.st(t)),t<0&&Util.G(t,">= 0",Size,"height"),this.J=t}isReal(){return isFinite(this.width)&&isFinite(this.height)}static hf=new Size(0,0).ot();static zk=new Size(1,1).ot();static lC=new Size(6,6).ot();static du=new Size(8,8).ot();static hC=new Size(10,10).ot();static Xk=new Size(1/0,1/0).ot();static xw=new Size(NaN,NaN).ot();static aC=[];static a(){const t=Size.aC.pop();return t===void 0?new Size:t}static o(t){Size.aC.push(t)}}class Rect{S;P;v;J;f;constructor(t,i,e,s){if(t===void 0)this.S=0,this.P=0,this.v=0,this.J=0;else if(typeof t=="number"&&typeof i=="number"&&typeof e=="number"&&(e>=0||isNaN(e))&&typeof s=="number"&&(s>=0||isNaN(s)))this.S=t,this.P=i,this.v=e,this.J=s;else if(t instanceof Point){const n=t.x,o=t.y;if(i instanceof Point){const r=i.x,l=i.y;this.S=Math.min(n,r),this.P=Math.min(o,l),this.v=Math.abs(n-r),this.J=Math.abs(o-l)}else i instanceof Size?(this.S=n,this.P=o,this.v=i.width,this.J=i.height):Util.n("Incorrect second argument supplied to Rect constructor "+i)}else Util.n("Invalid arguments to Rect constructor: "+t+", "+i+", "+e+", "+s);this.f=!1}c(t){return this.S=t.S,this.P=t.P,this.v=t.v,this.J=t.J,this}e(t,i,e,s){return this.S=t,this.P=i,this.v=e,this.J=s,this}Kn(t,i){return this.v=t,this.J=i,this}setTo(t,i,e,s){return Debug&&(Util.t(t,"number",Rect,"setTo:x"),Util.t(i,"number",Rect,"setTo:y"),Util.t(e,"number",Rect,"setTo:w"),Util.t(s,"number",Rect,"setTo:h"),e<0&&Util.G(e,">= 0",Rect,"setTo:w"),s<0&&Util.G(s,">= 0",Rect,"setTo:h"),this.st()),this.S=t,this.P=i,this.v=e,this.J=s,this}set(t){return Debug&&(Util.s(t,Rect,Rect,"set:r"),this.st()),this.S=t.S,this.P=t.P,this.v=t.v,this.J=t.J,this}setPoint(t){return Debug&&(Util.s(t,Point,Rect,"setPoint:p"),this.st()),this.S=t.x,this.P=t.y,this}setSize(t){return Debug&&(Util.s(t,Size,Rect,"setSize:s"),this.st()),this.v=t.width,this.J=t.height,this}copy(){const t=new Rect;return t.S=this.S,t.P=this.P,t.v=this.v,t.J=this.J,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ft(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}st(t){if(Debug&&this.f){let i="The Rect is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),new Rect(s,o,r,l)}else return new Rect}static stringify(t){return Debug&&Util.s(t,Rect),t.x.toString()+" "+t.y.toString()+" "+t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.t(t,"number",Rect,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Rect("+this.x+","+this.y+","+this.width+","+this.height+")"}equals(t){return t instanceof Rect?this.S===t.x&&this.P===t.y&&this.v===t.width&&this.J===t.height:!1}equalTo(t,i,e,s){return this.S===t&&this.P===i&&this.v===e&&this.J===s}equalsApprox(t){return Geo.p(this.S,t.x)&&Geo.p(this.P,t.y)&&Geo.p(this.v,t.width)&&Geo.p(this.J,t.height)}equalsApproxTo(t,i,e,s){return Geo.p(this.S,t)&&Geo.p(this.P,i)&&Geo.p(this.v,e)&&Geo.p(this.J,s)}equalsApproxClose(t){return Geo.q(this.S,t.x)&&Geo.q(this.P,t.y)&&Geo.q(this.v,t.width)&&Geo.q(this.J,t.height)}containsPoint(t){return Debug&&Util.s(t,Point,Rect,"containsPoint:p"),this.S<=t.x&&this.S+this.v>=t.x&&this.P<=t.y&&this.P+this.J>=t.y}containsRect(t){return Debug&&Util.s(t,Rect,Rect,"containsRect:r"),this.S<=t.x&&t.x+t.width<=this.S+this.v&&this.P<=t.y&&t.y+t.height<=this.P+this.J}contains(t,i,e,s){return Debug?(Util.r(t,Rect,"contains:x"),Util.r(i,Rect,"contains:y"),e===void 0?e=0:Util.r(e,Rect,"contains:w"),s===void 0?s=0:Util.r(s,Rect,"contains:h"),(e<0||s<0)&&Util.n("Rect.contains:Width and height cannot be negative")):(e===void 0&&(e=0),s===void 0&&(s=0)),this.S<=t&&t+e<=this.S+this.v&&this.P<=i&&i+s<=this.P+this.J}offset(t,i){return Debug&&(Util.r(t,Rect,"offset:dx"),Util.r(i,Rect,"offset:dy"),this.st()),this.S+=t,this.P+=i,this}inflate(t,i){return Debug&&(Util.r(t,Rect,"inflate:w"),Util.r(i,Rect,"inflate:h")),this.bw(i,t,i,t)}addMargin(t){return Debug&&Util.s(t,Margin,Rect,"addMargin:m"),this.bw(t.top,t.right,t.bottom,t.left)}subtractMargin(t){return Debug&&Util.s(t,Margin,Rect,"subtractMargin:m"),this.bw(-t.top,-t.right,-t.bottom,-t.left)}grow(t,i,e,s){return Debug&&(Util.r(t,Rect,"grow:t"),Util.r(i,Rect,"grow:r"),Util.r(e,Rect,"grow:b"),Util.r(s,Rect,"grow:l")),this.bw(t,i,e,s)}bw(t,i,e,s){Debug&&this.st();const n=this.v;i+s<=-n?(this.S+=n/2,this.v=0):(this.S-=s,this.v+=i+s);const o=this.J;return t+e<=-o?(this.P+=o/2,this.J=0):(this.P-=t,this.J+=t+e),this}intersectRect(t){return Debug&&Util.s(t,Rect,Rect,"intersectRect:r"),this.fC(t.x,t.y,t.width,t.height)}intersect(t,i,e,s){return Debug&&(Util.r(t,Rect,"intersect:x"),Util.r(i,Rect,"intersect:y"),Util.r(e,Rect,"intersect:w"),Util.r(s,Rect,"intersect:h"),(e<0||s<0)&&Util.n("Rect.intersect:Width and height cannot be negative")),this.fC(t,i,e,s)}fC(t,i,e,s){Debug&&this.st();const n=Math.max(this.S,t),o=Math.max(this.P,i),r=Math.min(this.S+this.v,t+e),l=Math.min(this.P+this.J,i+s);return this.S=n,this.P=o,this.v=Math.max(0,r-n),this.J=Math.max(0,l-o),this}intersectsRect(t){return Debug&&Util.s(t,Rect,Rect,"intersectsRect:r"),this.intersects(t.x,t.y,t.width,t.height)}intersects(t,i,e,s){Debug&&(Util.r(t,Rect,"intersects:x"),Util.r(i,Rect,"intersects:y"),Util.r(t,Rect,"intersects:w"),Util.r(i,Rect,"intersects:h"),(e<0||s<0)&&Util.n("Rect.intersects:Width and height cannot be negative"));let n=this.v;const o=this.S;if(n!==1/0&&e!==1/0&&(n+=o,e+=t,isNaN(e)||isNaN(n)||o>e||t>n))return!1;let r=this.J;const l=this.P;return!(r!==1/0&&s!==1/0&&(r+=l,s+=i,isNaN(s)||isNaN(r)||l>s||i>r))}intersectsRectPlus(t,i){let e=this.v,s=t.width+i+i;const n=this.S,o=t.x-i;if(e+=n,s+=o,n>s||o>e)return!1;let r=this.J,l=t.height+i+i;const h=this.P,a=t.y-i;return r+=h,l+=a,!(h>l||a>r)}unionPoint(t){return Debug&&Util.s(t,Point,Rect,"unionPoint:p"),this.unionNoCheck(t.x,t.y,0,0)}unionRect(t){return Debug&&Util.s(t,Rect,Rect,"unionRect:r"),this.unionNoCheck(t.S,t.P,t.v,t.J)}union(t,i,e,s){return Debug?(Util.r(t,Rect,"union:x"),Util.r(i,Rect,"union:y"),e===void 0?e=0:Util.r(e,Rect,"union:w"),s===void 0?s=0:Util.r(s,Rect,"union:h"),(e<0||s<0)&&Util.n("Rect.union:Width and height cannot be negative"),this.st()):(e===void 0&&(e=0),s===void 0&&(s=0)),this.unionNoCheck(t,i,e,s)}unionNoCheck(t,i,e,s){const n=Math.min(this.S,t),o=Math.min(this.P,i),r=Math.max(this.S+this.v,t+e),l=Math.max(this.P+this.J,i+s);return this.S=n,this.P=o,this.v=r-n,this.J=l-o,this}setSpot(t,i,e){return Debug&&(Util.r(t,Rect,"setSpot:x"),Util.r(i,Rect,"setSpot:y"),Util.s(e,Spot,Rect,"setSpot:spot"),this.st()),this.S=t-e.offsetX-e.x*this.v,this.P=i-e.offsetY-e.y*this.J,this}static contains(t,i,e,s,n,o,r,l){return Debug?(Util.r(t,Rect,"contains:rx"),Util.r(i,Rect,"contains:ry"),Util.r(e,Rect,"contains:rw"),Util.r(s,Rect,"contains:rh"),Util.r(n,Rect,"contains:x"),Util.r(o,Rect,"contains:y"),r===void 0?r=0:Util.r(r,Rect,"contains:w"),l===void 0?l=0:Util.r(l,Rect,"contains:h"),(e<0||s<0||r<0||l<0)&&Util.n("Rect.contains:Width and height cannot be negative")):(r===void 0&&(r=0),l===void 0&&(l=0)),t<=n&&n+r<=t+e&&i<=o&&o+l<=i+s}static intersects(t,i,e,s,n,o,r,l){Debug&&(Util.r(t,Rect,"intersects:rx"),Util.r(i,Rect,"intersects:ry"),Util.r(e,Rect,"intersects:rw"),Util.r(s,Rect,"intersects:rh"),Util.r(n,Rect,"intersects:x"),Util.r(o,Rect,"intersects:y"),Util.r(r,Rect,"intersects:w"),Util.r(l,Rect,"intersects:h"),(e<0||s<0||r<0||l<0)&&Util.n("Rect.intersects:Width and height cannot be negative"));let h=e,a=r;const f=t,c=n;if(h+=f,a+=c,f>a||c>h)return!1;let u=s,d=l;const m=i,g=o;return u+=m,d+=g,!(m>d||g>u)}static intersectsLineSegment(t,i,e,s,n,o,r,l){return Debug&&(Util.r(t,Rect,"intersectsLineSegment:x"),Util.r(i,Rect,"intersectsLineSegment:y"),Util.r(e,Rect,"intersectsLineSegment:w"),Util.r(s,Rect,"intersectsLineSegment:h"),Util.r(n,Rect,"intersectsLineSegment:p1x"),Util.r(o,Rect,"intersectsLineSegment:p1y"),Util.r(r,Rect,"intersectsLineSegment:p2x"),Util.r(l,Rect,"intersectsLineSegment:p2y"),(e<0||s<0)&&Util.n("Rect.intersectsLineSegment: width and height cannot be negative")),Geo.cC(t,i,e,s,n,o,r,l)}get x(){return this.S}set x(t){Debug&&(Util.t(t,"number",Rect,"x"),this.st(t)),this.S=t}get y(){return this.P}set y(t){Debug&&(Util.t(t,"number",Rect,"y"),this.st(t)),this.P=t}get width(){return this.v}set width(t){Debug&&(Util.t(t,"number",Rect,"width"),this.st(t)),t<0&&Util.G(t,">= 0",Rect,"width"),this.v=t}get height(){return this.J}set height(t){Debug&&(Util.t(t,"number",Rect,"height"),this.st(t)),t<0&&Util.G(t,">= 0",Rect,"height"),this.J=t}get left(){return this.S}set left(t){Debug&&(Util.t(t,"number",Rect,"left"),this.st(t)),this.S=t}get top(){return this.P}set top(t){Debug&&(Util.t(t,"number",Rect,"top"),this.st(t)),this.P=t}get right(){return this.S+this.v}set right(t){Debug&&(Util.r(t,Rect,"right"),this.st(t)),this.S+=t-(this.S+this.v)}get bottom(){return this.P+this.J}set bottom(t){Debug&&(Util.r(t,Rect,"top"),this.st(t)),this.P+=t-(this.P+this.J)}get position(){return new Point(this.S,this.P)}set position(t){Debug&&(Util.s(t,Point,Rect,"position"),this.st(t)),this.S=t.x,this.P=t.y}get size(){return new Size(this.v,this.J)}set size(t){Debug&&(Util.s(t,Size,Rect,"size"),this.st(t)),this.v=t.width,this.J=t.height}get center(){return new Point(this.S+this.v/2,this.P+this.J/2)}set center(t){Debug&&(Util.s(t,Point,Rect,"center"),this.st(t)),this.S=t.x-this.v/2,this.P=t.y-this.J/2}get centerX(){return this.S+this.v/2}set centerX(t){Debug&&(Util.r(t,Rect,"centerX"),this.st(t)),this.S=t-this.v/2}get centerY(){return this.P+this.J/2}set centerY(t){Debug&&(Util.r(t,Rect,"centerY"),this.st(t)),this.P=t-this.J/2}isReal(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)}isEmpty(){return this.width===0&&this.height===0}static kw=new Rect(0,0,0,0).ot();static BD=new Rect(NaN,NaN,NaN,NaN).ot();static Yk=[];static a(){const t=Rect.Yk.pop();return t===void 0?new Rect:t}static H(t,i,e,s){const n=Rect.Yk.pop();return n===void 0?new Rect(t,i,e,s):n.e(t,i,e,s)}static o(t){Rect.Yk.push(t)}}class Margin{an;fn;cn;un;f;constructor(t,i,e,s){t===void 0?(this.an=0,this.fn=0,this.cn=0,this.un=0):i===void 0?(i=t,e=t,s=t,this.top=t,this.right=i,this.bottom=e,this.left=s):e===void 0?(e=t,s=i,this.top=t,this.right=i,this.bottom=e,this.left=s):s!==void 0?(this.top=t,this.right=i,this.bottom=e,this.left=s):Util.n("Invalid arguments to Margin constructor: "+t+", "+i+", "+e+", "+s),this.f=!1}c(t){return this.an=t.an,this.fn=t.fn,this.cn=t.cn,this.un=t.un,this}setTo(t,i,e,s){return Debug&&(Util.t(t,"number",Margin,"setTo:t"),Util.t(i,"number",Margin,"setTo:r"),Util.t(e,"number",Margin,"setTo:b"),Util.t(s,"number",Margin,"setTo:l"),this.st()),this.an=t,this.fn=i,this.cn=e,this.un=s,this}set(t){return Debug&&(Util.s(t,Margin,Margin,"assign:m"),this.st()),this.an=t.an,this.fn=t.fn,this.cn=t.cn,this.un=t.un,this}copy(){const t=new Margin;return t.an=this.an,t.fn=this.fn,t.cn=this.cn,t.un=this.un,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ft(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}st(t){if(Debug&&this.f){let i="The Margin is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=NaN;for(;i[e]==="";)e++;let n=i[e++];if(n&&(s=parseFloat(n)),isNaN(s))return new Margin;let o=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(o=parseFloat(n)),isNaN(o))return new Margin(s);let r=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(r=parseFloat(n)),isNaN(r))return new Margin(s,o);let l=NaN;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),isNaN(l)?new Margin(s,o):new Margin(s,o,r,l)}else return new Margin}static stringify(t){return Debug&&Util.s(t,Margin),t.top.toString()+" "+t.right.toString()+" "+t.bottom.toString()+" "+t.left.toString()}static stringifyFixed(t){return Util.t(t,"number",Margin,"stringifyFixed:digits"),i=>i.top.toFixed(t)+" "+i.right.toFixed(t)+" "+i.bottom.toFixed(t)+" "+i.left.toFixed(t)}toString(){return"Margin("+this.top+","+this.right+","+this.bottom+","+this.left+")"}equals(t){return t instanceof Margin?this.an===t.top&&this.fn===t.right&&this.cn===t.bottom&&this.un===t.left:!1}equalTo(t,i,e,s){return this.an===t&&this.fn===i&&this.cn===e&&this.un===s}equalsApprox(t){return Geo.p(this.an,t.top)&&Geo.p(this.fn,t.right)&&Geo.p(this.cn,t.bottom)&&Geo.p(this.un,t.left)}get top(){return this.an}set top(t){Debug&&(Util.r(t,Margin,"top"),this.st(t)),this.an=t}get right(){return this.fn}set right(t){Debug&&(Util.r(t,Margin,"right"),this.st(t)),this.fn=t}get bottom(){return this.cn}set bottom(t){Debug&&(Util.r(t,Margin,"bottom"),this.st(t)),this.cn=t}get left(){return this.un}set left(t){Debug&&(Util.r(t,Margin,"left"),this.st(t)),this.un=t}isReal(){return isFinite(this.top)&&isFinite(this.right)&&isFinite(this.bottom)&&isFinite(this.left)}static Hg=new Margin(0,0,0,0).ot();static uC=new Margin(2,2,2,2).ot();static dC=[];static a(){const t=Margin.dC.pop();return t===void 0?new Margin:t}static o(t){Margin.dC.push(t)}}class Spot{S;P;Is;Os;f;constructor(t,i,e,s){t===void 0?(this.S=0,this.P=0,this.Is=0,this.Os=0):(i===void 0&&(i=0),e===void 0&&(e=0),s===void 0&&(s=0),this.x=t,this.y=i,this.offsetX=e,this.offsetY=s),this.f=!1}c(t){return this.S=t.S,this.P=t.P,this.Is=t.Is,this.Os=t.Os,this}setTo(t,i,e,s){return Debug&&(this.Sw(t,"setTo:x"),this.Sw(i,"setTo:y"),this.Mw(e,"setTo:offx"),this.Mw(s,"setTo:offy"),this.st()),this.S=t,this.P=i,this.Is=e,this.Os=s,this}set(t){return Debug&&(Util.s(t,Spot,Spot,"set:s"),this.st()),this.S=t.S,this.P=t.P,this.Is=t.Is,this.Os=t.Os,this}copy(){const t=new Spot;return t.S=this.S,t.P=this.P,t.Is=this.Is,t.Os=this.Os,t}ot(){return this.f=!0,Object.freeze(this),this}L(){return this.f||Object.isFrozen(this)?this:this.copy().w()}w(){return this.f=!0,this}ft(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this}st(t){if(Debug&&this.f){let i="The Spot is frozen, so its properties cannot be set: "+this.toString();t!==void 0&&(i+=" to value: "+t),Util.n(i)}}Ke(t){return this.S=NaN,this.P=NaN,this.Is=t,this}Sw(t,i){(isNaN(t)||t>1||t<0)&&Util.G(t,"0 <= "+i+" <= 1",Spot,i)}Mw(t,i){(isNaN(t)||t===1/0||t===-1/0)&&Util.G(t,"real number, not NaN or Infinity",Spot,i)}static parse(t){if(typeof t=="string"){if(t=t.trim(),t==="None")return Spot.None;if(t==="TopLeft")return Spot.TopLeft;if(t==="Top"||t==="TopCenter"||t==="MiddleTop")return Spot.TopCenter;if(t==="TopRight")return Spot.TopRight;if(t==="Left"||t==="LeftCenter"||t==="MiddleLeft")return Spot.LeftCenter;if(t==="Center")return Spot.Center;if(t==="Right"||t==="RightCenter"||t==="MiddleRight")return Spot.RightCenter;if(t==="BottomLeft")return Spot.BottomLeft;if(t==="Bottom"||t==="BottomCenter"||t==="MiddleBottom")return Spot.BottomCenter;if(t==="BottomRight")return Spot.BottomRight;if(t==="TopSide")return Spot.TopSide;if(t==="LeftSide")return Spot.LeftSide;if(t==="RightSide")return Spot.RightSide;if(t==="BottomSide")return Spot.BottomSide;if(t==="TopBottomSides")return Spot.TopBottomSides;if(t==="LeftRightSides")return Spot.LeftRightSides;if(t==="TopLeftSides")return Spot.TopLeftSides;if(t==="TopRightSides")return Spot.TopRightSides;if(t==="BottomLeftSides")return Spot.BottomLeftSides;if(t==="BottomRightSides")return Spot.BottomRightSides;if(t==="NotTopSide")return Spot.NotTopSide;if(t==="NotLeftSide")return Spot.NotLeftSide;if(t==="NotRightSide")return Spot.NotRightSide;if(t==="NotBottomSide")return Spot.NotBottomSide;if(t==="AllSides")return Spot.AllSides;if(t==="Default")return Spot.Default;const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n!==void 0&&n.length>0&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n!==void 0&&n.length>0&&(l=parseFloat(n)),new Spot(s,o,r,l)}else return new Spot}static stringify(t){return Debug&&Util.s(t,Spot),t.isSpot()?t.x.toString()+" "+t.y.toString()+" "+t.offsetX.toString()+" "+t.offsetY.toString():t.toString()}static stringifyFixed(t){return Util.t(t,"number",Spot,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.offsetX.toFixed(t)+" "+i.offsetY.toFixed(t)}toString(){return this.isSpot()?this.Is===0&&this.Os===0?"Spot("+this.x+","+this.y+")":"Spot("+this.x+","+this.y+","+this.offsetX+","+this.offsetY+")":this.equals(Spot.None)?"None":this.equals(Spot.TopLeft)?"TopLeft":this.equals(Spot.TopCenter)?"Top":this.equals(Spot.TopRight)?"TopRight":this.equals(Spot.LeftCenter)?"Left":this.equals(Spot.Center)?"Center":this.equals(Spot.RightCenter)?"Right":this.equals(Spot.BottomLeft)?"BottomLeft":this.equals(Spot.BottomCenter)?"Bottom":this.equals(Spot.BottomRight)?"BottomRight":this.equals(Spot.TopSide)?"TopSide":this.equals(Spot.LeftSide)?"LeftSide":this.equals(Spot.RightSide)?"RightSide":this.equals(Spot.BottomSide)?"BottomSide":this.equals(Spot.TopBottomSides)?"TopBottomSides":this.equals(Spot.LeftRightSides)?"LeftRightSides":this.equals(Spot.TopLeftSides)?"TopLeftSides":this.equals(Spot.TopRightSides)?"TopRightSides":this.equals(Spot.BottomLeftSides)?"BottomLeftSides":this.equals(Spot.BottomRightSides)?"BottomRightSides":this.equals(Spot.NotTopSide)?"NotTopSide":this.equals(Spot.NotLeftSide)?"NotLeftSide":this.equals(Spot.NotRightSide)?"NotRightSide":this.equals(Spot.NotBottomSide)?"NotBottomSide":this.equals(Spot.AllSides)?"AllSides":this.equals(Spot.Default)?"Default":"None"}equals(t){return t instanceof Spot?(this.S===t.x||isNaN(this.S)&&isNaN(t.x))&&(this.P===t.y||isNaN(this.P)&&isNaN(t.y))&&this.Is===t.offsetX&&this.Os===t.offsetY:!1}opposite(){return new Spot(.5-(this.S-.5),.5-(this.P-.5),-this.Is,-this.Os)}includesSide(t){if(!this.isSide())return!1;if(!t.isSide())if(t.equals(Spot.Left))t=Spot.LeftSide;else if(t.equals(Spot.Right))t=Spot.RightSide;else if(t.equals(Spot.Top))t=Spot.TopSide;else if(t.equals(Spot.Bottom))t=Spot.BottomSide;else return!1;const i=this.Os,e=t.offsetY;return(i&e)===e}get x(){return this.S}set x(t){Debug&&(this.Sw(t,"x"),this.st(t)),this.S=t}get y(){return this.P}set y(t){Debug&&(this.Sw(t,"y"),this.st(t)),this.P=t}get offsetX(){return this.Is}set offsetX(t){Debug&&(this.Mw(t,"offsetX"),this.st(t)),this.Is=t}get offsetY(){return this.Os}set offsetY(t){Debug&&(this.Mw(t,"offsetY"),this.st(t)),this.Os=t}isSpot(){return!isNaN(this.x)&&!isNaN(this.y)}isNoSpot(){return isNaN(this.x)||isNaN(this.y)}isSide(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===1&&this.offsetY!==0}isNone(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===0&&this.offsetY===0}isDefault(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===-1&&this.offsetY===0}static None=new Spot(0,0,0,0).Ke(0).ot();static Default=new Spot(0,0,-1,0).Ke(-1).ot();static TopLeft=new Spot(0,0,0,0).ot();static TopCenter=new Spot(.5,0,0,0).ot();static TopRight=new Spot(1,0,0,0).ot();static LeftCenter=new Spot(0,.5,0,0).ot();static Center=new Spot(.5,.5,0,0).ot();static RightCenter=new Spot(1,.5,0,0).ot();static BottomLeft=new Spot(0,1,0,0).ot();static BottomCenter=new Spot(.5,1,0,0).ot();static BottomRight=new Spot(1,1,0,0).ot();static MiddleTop=Spot.TopCenter;static MiddleLeft=Spot.LeftCenter;static MiddleRight=Spot.RightCenter;static MiddleBottom=Spot.BottomCenter;static Top=Spot.TopCenter;static Left=Spot.LeftCenter;static Right=Spot.RightCenter;static Bottom=Spot.BottomCenter;static TopSide=new Spot(0,0,1,1).Ke(1).ot();static LeftSide=new Spot(0,0,1,2).Ke(1).ot();static RightSide=new Spot(0,0,1,4).Ke(1).ot();static BottomSide=new Spot(0,0,1,8).Ke(1).ot();static TopBottomSides=new Spot(0,0,1,9).Ke(1).ot();static LeftRightSides=new Spot(0,0,1,6).Ke(1).ot();static TopLeftSides=new Spot(0,0,1,3).Ke(1).ot();static TopRightSides=new Spot(0,0,1,5).Ke(1).ot();static BottomLeftSides=new Spot(0,0,1,10).Ke(1).ot();static BottomRightSides=new Spot(0,0,1,12).Ke(1).ot();static NotTopSide=new Spot(0,0,1,14).Ke(1).ot();static NotLeftSide=new Spot(0,0,1,13).Ke(1).ot();static NotRightSide=new Spot(0,0,1,11).Ke(1).ot();static NotBottomSide=new Spot(0,0,1,7).Ke(1).ot();static AllSides=new Spot(0,0,1,15).Ke(1).ot();static Kk=new Spot(.156,.156).ot();static Uk=new Spot(.844,.844).ot();static gC=[];static a(){const t=Spot.gC.pop();return t===void 0?new Spot:t}static o(t){Spot.gC.push(t)}}class Transform{m11;m12;m21;m22;dx;dy;constructor(){this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0}set(t){return this.m11=t.m11,this.m12=t.m12,this.m21=t.m21,this.m22=t.m22,this.dx=t.dx,this.dy=t.dy,this}setTo(t,i,e,s,n,o){return this.m11=t,this.m12=i,this.m21=e,this.m22=s,this.dx=n,this.dy=o,this}copy(){const t=new Transform;return t.m11=this.m11,t.m12=this.m12,t.m21=this.m21,t.m22=this.m22,t.dx=this.dx,t.dy=this.dy,t}toString(){return"Transform("+this.m11+","+this.m12+","+this.m21+","+this.m22+","+this.dx+","+this.dy+")"}equals(t){return this.m11===t.m11&&this.m12===t.m12&&this.m21===t.m21&&this.m22===t.m22&&this.dx===t.dx&&this.dy===t.dy}Gk(){return this.dx===0&&this.dy===0&&this.m11===1&&this.m12===0&&this.m21===0&&this.m22===1}Vi(){return this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0,this}af(t){const i=this.m11*t.m11+this.m21*t.m12,e=this.m12*t.m11+this.m22*t.m12,s=this.m11*t.m21+this.m21*t.m22,n=this.m12*t.m21+this.m22*t.m22;return this.dx=this.m11*t.dx+this.m21*t.dy+this.dx,this.dy=this.m12*t.dx+this.m22*t.dy+this.dy,this.m11=i,this.m12=e,this.m21=s,this.m22=n,this}mC(t){const i=1/(t.m11*t.m22-t.m12*t.m21),e=t.m22*i,s=-t.m12*i,n=-t.m21*i,o=t.m11*i,r=i*(t.m21*t.dy-t.m22*t.dx),l=i*(t.m12*t.dx-t.m11*t.dy),h=this.m11*e+this.m21*s,a=this.m12*e+this.m22*s,f=this.m11*n+this.m21*o,c=this.m12*n+this.m22*o;return this.dx=this.m11*r+this.m21*l+this.dx,this.dy=this.m12*r+this.m22*l+this.dy,this.m11=h,this.m12=a,this.m21=f,this.m22=c,this}Pw(){const t=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*t,e=-this.m12*t,s=-this.m21*t,n=this.m11*t,o=t*(this.m21*this.dy-this.m22*this.dx),r=t*(this.m12*this.dx-this.m11*this.dy);return this.m11=i,this.m12=e,this.m21=s,this.m22=n,this.dx=o,this.dy=r,this}ms(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return this;this.Es(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m11*s+this.m21*n,r=this.m12*s+this.m22*n,l=this.m11*-n+this.m21*s,h=this.m12*-n+this.m22*s;return this.m11=o,this.m12=r,this.m21=l,this.m22=h,this.Es(-i,-e),this}Es(t,i){return this.dx+=this.m11*t+this.m21*i,this.dy+=this.m12*t+this.m22*i,this}rt(t,i){return i===void 0&&(i=t),this.m11*=t,this.m12*=t,this.m21*=i,this.m22*=i,this}VD(){if(this.m11===1&&this.m12===0)return 0;let t=Math.atan2(this.m12,this.m11)*180/Math.PI;return t<0&&(t+=360),t}Pt(t){const i=t.x,e=t.y;return t.e(i*this.m11+e*this.m21+this.dx,i*this.m12+e*this.m22+this.dy)}ns(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=t.x-this.dx,l=t.y-this.dy;return t.e(r*e+l*n,r*s+l*o)}Nw(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=i*(this.m21*this.dy-this.m22*this.dx),l=i*(this.m12*this.dx-this.m11*this.dy),h=t.x*1.25,a=t.y*1.2;return t.e(h*e+a*n+r,h*s+a*o+l)}Cw(t){const i=t.x,e=t.y,s=i+t.width,n=e+t.height,o=this.m11,r=this.m12,l=this.m21,h=this.m22,a=this.dx,f=this.dy,c=i*o+e*l+a,u=i*r+e*h+f,d=s*o+e*l+a,m=s*r+e*h+f,g=i*o+n*l+a,p=i*r+n*h+f,y=s*o+n*l+a,x=s*r+n*h+f;let k=c,b=c,S=u,M=u;return k=Math.min(k,d),b=Math.max(b,d),S=Math.min(S,m),M=Math.max(M,m),k=Math.min(k,g),b=Math.max(b,g),S=Math.min(S,p),M=Math.max(M,p),k=Math.min(k,y),b=Math.max(b,y),S=Math.min(S,x),M=Math.max(M,x),t.e(k,S,b-k,M-S),t}static pC=[];static a(){const t=Transform.pC.pop();return t===void 0?new Transform:t}static o(t){Transform.pC.push(t)}static Hk="54a702f3e53909c447824c6706603faf4c"}const Geo={zD:"7da71ca0ad381e90",Un:4*((Math.sqrt(2)-1)/3),yC:null,Aw:w=>{if(w<=0)return 0;let t=Geo.yC;if(t===null){t=[];for(let i=0;i<=2e3;i++)t[i]=Math.sqrt(i);Geo.yC=t}if(w<1){const i=1/w;return i<=2e3?1/t[i|0]:Math.sqrt(w)}else return w<=2e3?t[w|0]:Math.sqrt(w)},p:(w,t)=>{const i=w-t;return i<.5&&i>-.5},q:(w,t)=>{const i=w-t;return i<5e-8&&i>-5e-8},zi:(w,t,i,e,s,n,o)=>{s<=0&&(s=1e-6);let r=0,l=0,h=0,a=0;if(wu-d)if(w-i>s||i-w>s){const g=(e-t)/(i-w)*(n-w)+t;if(g-s<=o&&o<=g+s)return!0}else return!0;else if(t-e>s||e-t>s){const g=(i-w)/(e-t)*(o-t)+w;if(g-s<=n&&n<=g+s)return!0}else return!0}return!1},Lw:(w,t,i,e,s,n,o,r,l,h,a,f)=>{if(!Geo.zi(w,t,o,r,f,i,e)||!Geo.zi(w,t,o,r,f,s,n)){const c=(w+i)/2,u=(t+e)/2,d=(i+s)/2,m=(e+n)/2,g=(s+o)/2,p=(n+r)/2,y=(c+d)/2,x=(u+m)/2,k=(d+g)/2,b=(m+p)/2,S=(y+k)/2,M=(x+b)/2;return Geo.Lw(w,t,c,u,y,x,S,M,l,h,a,f)||Geo.Lw(S,M,k,b,g,p,o,r,l,h,a,f)}else return Geo.zi(w,t,o,r,f,h,a)},wC:(w,t,i,e,s,n,o,r,l)=>{const h=(w+i)/2,a=(t+e)/2,f=(i+s)/2,c=(e+n)/2,u=(s+o)/2,d=(n+r)/2,m=(h+f)/2,g=(a+c)/2,p=(f+u)/2,y=(c+d)/2;return l.e((m+p)/2,(g+y)/2),l},XD:(w,t,i,e,s,n,o,r)=>{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,f=(e+n)/2,c=(s+o)/2,u=(n+r)/2,d=(l+a)/2,m=(h+f)/2,g=(a+c)/2,p=(f+u)/2;return Point.direction(d,m,g,p)},gu:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.zi(w,t,o,r,l,i,e)||!Geo.zi(w,t,o,r,l,s,n)){const a=(w+i)/2,f=(t+e)/2,c=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+c)/2,p=(f+u)/2,y=(c+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.gu(w,t,a,f,g,p,k,b,l,h),Geo.gu(k,b,y,x,d,m,o,r,l,h)}else h.unionNoCheck(w,t,0,0),h.unionNoCheck(o,r,0,0);return h},Gn:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.zi(w,t,o,r,l,i,e)||!Geo.zi(w,t,o,r,l,s,n)){const a=(w+i)/2,f=(t+e)/2,c=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+c)/2,p=(f+u)/2,y=(c+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.Gn(w,t,a,f,g,p,k,b,l,h),Geo.Gn(k,b,y,x,d,m,o,r,l,h)}else h.length===0&&(h.push(w),h.push(t)),h.push(o),h.push(r);return h},qk:(w,t,i,e,s,n,o,r,l,h)=>{if(Geo.zi(w,t,s,n,h,i,e))return Geo.zi(w,t,s,n,h,r,l);{const a=(w+i)/2,f=(t+e)/2,c=(i+s)/2,u=(e+n)/2,d=(a+c)/2,m=(f+u)/2;return Geo.qk(w,t,a,f,d,m,o,r,l,h)||Geo.qk(d,m,c,u,s,n,o,r,l,h)}},sE:(w,t,i,e,s,n,o)=>{const r=(w+i)/2,l=(t+e)/2,h=(i+s)/2,a=(e+n)/2;return o.e((r+h)/2,(l+a)/2),o},jk:(w,t,i,e,s,n,o,r)=>{if(Geo.zi(w,t,s,n,o,i,e))r.unionNoCheck(w,t,0,0),r.unionNoCheck(s,n,0,0);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,f=(e+n)/2,c=(l+a)/2,u=(h+f)/2;Geo.jk(w,t,l,h,c,u,o,r),Geo.jk(c,u,a,f,s,n,o,r)}return r},qg:(w,t,i,e,s,n,o,r)=>{if(Geo.zi(w,t,s,n,o,i,e))r.length===0&&(r.push(w),r.push(t)),r.push(s),r.push(n);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,f=(e+n)/2,c=(l+a)/2,u=(h+f)/2;Geo.qg(w,t,l,h,c,u,o,r),Geo.qg(c,u,a,f,s,n,o,r)}return r},jg:(w,t,i,e,s,n,o,r,l,h,a,f,c,u)=>{if(!Geo.zi(w,t,o,r,c,i,e)||!Geo.zi(w,t,o,r,c,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,S=(g+y)/2,M=(p+x)/2,A=(k+S)/2,C=(b+M)/2;let P=1/0,N=!1,T=0,L=0;if(Geo.jg(w,t,d,m,k,b,A,C,l,h,a,f,c,u)){const D=(u.x-l)*(u.x-l)+(u.y-h)*(u.y-h);D{let u=0;if(!Geo.zi(w,t,o,r,c,i,e)||!Geo.zi(w,t,o,r,c,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,S=(g+y)/2,M=(p+x)/2,A=(k+S)/2,C=(b+M)/2;u+=Geo.Wg(w,t,d,m,k,b,A,C,l,h,a,f,c),u+=Geo.Wg(A,C,S,M,y,x,o,r,l,h,a,f,c)}else{const d=(w-o)*(h-f)-(t-r)*(l-a);if(d===0)return u;const m=((w*r-t*o)*(l-a)-(w-o)*(l*f-h*a))/d,g=((w*r-t*o)*(h-f)-(t-r)*(l*f-h*a))/d;if(m>=a)return u;let p=0,y=0;if((l>a?l-a:a-l)<(h>f?h-f:f-h)){if(ty)return u}else if(wy)return u;d>0?u++:d<0&&u--}return u},xl:(w,t,i,e,s,n,o)=>{if(Geo.q(w,i)){let r=0,l=0;tl?(o.e(w,l),!1):(o.e(w,h),!0)}else if(Geo.q(t,e)){let r=0,l=0;wl?(o.e(l,t),!1):(o.e(h,t),!0)}else{const r=(i-w)*(i-w)+(e-t)*(e-t),l=((w-s)*(w-i)+(t-n)*(t-e))/r;if(l<-5e-6)return o.e(w,t),!1;if(l>1.000005)return o.e(i,e),!1;{const h=w+l*(i-w),a=t+l*(e-t);return o.e(h,a),!0}}},Hn:(w,t,i,e,s,n,o,r,l)=>{if(Geo.p(w,i)&&Geo.p(t,e))return l.e(w,t),!1;if(Geo.q(s,o)){if(Geo.q(w,i))return Geo.xl(w,t,i,e,s,n,l),!1;{const a=(e-t)/(i-w)*(s-w)+t;return Geo.xl(w,t,i,e,s,a,l)}}else{const h=(r-n)/(o-s);if(Geo.q(w,i)){const a=h*(w-s)+n;let f=0,c=0;return tc?(l.e(w,c),!1):(l.e(w,a),!0)}else{const a=(e-t)/(i-w);if(Geo.q(h,a))return Geo.xl(w,t,i,e,s,n,l),!1;{const f=(a*w-h*s+n-t)/(a-h);if(Geo.q(a,0)){let c=0,u=0;return wu?(l.e(u,t),!1):(l.e(f,t),!0)}else{const c=a*(f-w)+t;return Geo.xl(w,t,i,e,f,c,l)}}}}},nE:(w,t,i,e,s)=>Geo.Hn(i.x,i.y,e.x,e.y,w.x,w.y,t.x,t.y,s),oE:(w,t,i,e,s,n,o,r,l,h)=>{let a=1/0;function f(S,M){const A=(S-w)*(S-w)+(M-t)*(M-t);Aw?i-w:w-i)<.5){const S=1-(i-k)*(i-k)/(y*y);if(S<0)return l;const M=Math.sqrt(S),A=x*M+b,C=-x*M+b;f(i,A),f(i,C)}else{const S=(e-t)/(i-w),M=1/(y*y)+S*S/(x*x),A=2*S*(t-S*w)/(x*x)-2*S*b/(x*x)-2*k/(y*y),C=2*S*w*b/(x*x)-2*t*b/(x*x)+b*b/(x*x)+k*k/(y*y)-1+(t-S*w)*(t-S*w)/(x*x),P=A*A-4*M*C;if(P<0)return l;const N=Math.sqrt(P),T=(-A+N)/(2*M);f(T,S*T-S*w+t);const L=(-A-N)/(2*M);f(L,S*L-S*w+t)}return l},bl:(w,t,i,e,s,n,o,r,l)=>{let h=1e21,a=w,f=t;if(Geo.Hn(w,t,w,e,s,n,o,r,l)){const c=(l.x-s)*(l.x-s)+(l.y-n)*(l.y-n);cGeo.cC(w.x,w.y,w.width,w.height,t.x,t.y,i.x,i.y),cC:(w,t,i,e,s,n,o,r)=>{const l=w,h=w+i,a=t,f=t+e;if(s===o){let c=0,u=0;return n=a}if(n===r){let c=0,u=0;return s=l}return!!(Rect.contains(w,t,i,e,s,n)||Rect.contains(w,t,i,e,o,r)||Geo.uu(l,a,h,a,s,n,o,r)||Geo.uu(h,a,h,f,s,n,o,r)||Geo.uu(h,f,l,f,s,n,o,r)||Geo.uu(l,f,l,a,s,n,o,r))},uu:(w,t,i,e,s,n,o,r)=>w===i&&t===e&&s===o&&n===r?w===s&&t===n:Geo.cu(w,t,i,e,s,n)*Geo.cu(w,t,i,e,o,r)<=0&&Geo.cu(s,n,o,r,w,t)*Geo.cu(s,n,o,r,i,e)<=0,cu:(w,t,i,e,s,n)=>{const o=i-w,r=e-t;let l=s-w,h=n-t,a=l*r-h*o;return a===0&&(a=l*o+h*r,a>0&&(l-=o,h-=r,a=l*o+h*r,a<0&&(a=0))),a},vg:w=>(w<0&&(w+=360),w>=360&&(w-=360),w),xC:(w,t,i,e,s,n)=>{const o=Math.PI;n||(e=e*(o/180),s=s*(o/180));const r=e>s?-1:1,l=1e-5,h=o*2,a=[],f=o/2;let c=e,u=Math.min(h,Math.abs(s-e));if(ul;){const d=c+r*Math.min(u,f);a.push(Geo.YD(i,c,d,w,t)),u-=Math.abs(d-c),c=d}return a},YD:(w,t,i,e,s)=>{const n=(i-t)/2,o=w*Math.cos(n),r=w*Math.sin(n),l=o,h=-r,a=l*l+h*h,f=a+l*o+h*r,c=4/3*(Math.sqrt(2*a*f)-f)/(l*r-h*o),u=l-c*h,d=h+c*l,m=u,g=-d,p=n+t,y=Math.cos(p),x=Math.sin(p);return[e+w*Math.cos(t),s+w*Math.sin(t),e+u*y-d*x,s+u*x+d*y,e+m*y-g*x,s+m*x+g*y,e+w*Math.cos(i),s+w*Math.sin(i)]},Gg:(w,t,i,e,s,n,o)=>{const r=s,l=n,h=Math.floor((w-i)/r)*r+i,a=Math.floor((t-e)/l)*l+e;let f=h;h+r-w{let i=Math.max(w,t),e=Math.min(w,t),s=1,n=1;do s=i%e,n=e,i=e,e=s;while(s>0);return n},KD:(w,t,i,e)=>{const s=i<0,n=e<0;let o=0,r=0,l=0;w{let o=0;if(e>0)if(i>0){const r=w*w,l=t*t,h=w*i,a=t*e;let f=-l+a,c=-l+Math.sqrt(h*h+a*a),u=f;const d=9999999999;for(let p=0;p0)f=u;else if(k<0)c=u;else break}s=r*i/(u+r),n=l*e/(u+l);const m=s-i,g=n-e;o=Math.sqrt(m*m+g*g)}else s=0,n=t,o=Math.abs(e-t);else{const r=w*w-t*t,l=w*i;if(l(w[w.Line=1]="Line",w[w.Rectangle=2]="Rectangle",w[w.Ellipse=3]="Ellipse",w[w.Path=4]="Path",w))(GeometryType||{}),GeometryStretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w))(GeometryStretch||{});class Geometry{l;$g;Qg;ff;mu;pu;jn;Wn;vn;it;Pe;Ne;se;ne;Bs;cf;uf;constructor(t){Debug&&arguments.length>1&&Util.n("Geometry constructor can take at most one optional argument, the Geometry type."),GSet.vi(this),this.l=2,t===void 0?t=4:Debug&&Util.tt(t,GeometryType,"GeometryType"),this.it=t,this.Pe=0,this.Ne=0,this.se=0,this.ne=0,t===4?this.Bs=new List:this.Bs=Geometry.Dw,this.$g=this.Bs.dt,this.Qg=new Rect().w(),this.ff=null,this.mu=null,this.pu=NaN,this.jn=Spot.TopLeft,this.Wn=Spot.BottomRight,this.cf=NaN,this.uf=NaN,this.vn=2}copy(){const t=new Geometry;if(t.l=this.l&-2,t.it=this.it,t.Pe=this.Pe,t.Ne=this.Ne,t.se=this.se,t.ne=this.ne,this.it===4){const i=this.Bs.h,e=t.Bs;for(let s=0;si.toString(t)}fi(t){t in GeometryType?this.type=t:Util.ur(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e;switch(this.type){case 1:return t<0?"M"+this.startX.toString()+" "+this.startY.toString()+"L"+this.endX.toString()+" "+this.endY.toString():"M"+i(this.startX)+" "+i(this.startY)+"L"+i(this.endX)+" "+i(this.endY);case 2:return e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0?"M"+e.x.toString()+" "+e.y.toString()+"H"+e.right.toString()+"V"+e.bottom.toString()+"H"+e.left.toString()+"z":"M"+i(e.x)+" "+i(e.y)+"H"+i(e.right)+"V"+i(e.bottom)+"H"+i(e.left)+"z";case 3:if(e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0){const r=e.left.toString()+" "+(e.y+e.height/2).toString(),l=e.right.toString()+" "+(e.y+e.height/2).toString();return"M"+r+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+l+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+r}else{const r=i(e.left)+" "+i(e.y+e.height/2),l=i(e.right)+" "+i(e.y+e.height/2);return"M"+r+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+l+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+r}case 4:let s="";const n=this.figures.h,o=n.length;for(let r=0;r0&&(s+=" x "),l.isFilled&&(s+="F "),s+=l.toString(t)}return s;default:return GeometryType[this.type]}}static fillPath(t){typeof t!="string"&&Util.Bi(t,"string",Geometry,"fillPath:str");const i=t.split(/[Xx]/),e=i.length;let s="";for(let n=0;n=k-1||o[r+1].match(N)!==null?!0:(u=!1,!1)}function m(){return r++,o[r]}function g(L){let D=parseFloat(m()),F=parseFloat(m());l===l.toLowerCase()&&(D=c.x+D,F=c.y+F),L.e(D,F)}function p(){return g(c),c}function y(){return g(f),f}function x(){const L=h.toLowerCase();return L==="c"||L==="s"||L==="q"||L==="t"?new Point(2*c.x-f.x,2*c.y-f.y):new Point(c.x,c.y)}const k=o.length,b=GeoStream.SC(null);let S=!1,M=!1,A=!1,C=!0,P=null;const N=new RegExp("["+Geometry._g+"]");for(;!(r>=k-1);){if(h=l,l=m(),l==="")continue;u=!0;let L=!1;switch(l.toUpperCase()){case"X":C=!0,S=!1,M=!1;break;case"M":for(P=p(),b.Ci===null||C===!0?(b.yu(P.x,P.y,S,!1,!M,A),C=!1):b.GD(P.x,P.y),a.c(c);!d();)P=p(),b.yr(P.x,P.y);break;case"L":for(;!d();)P=p(),b.yr(P.x,P.y);u&&(L=!0);break;case"H":for(;!d();)c.e((l===l.toLowerCase()?c.x:0)+parseFloat(m()),c.y),b.yr(c.x,c.y);break;case"V":for(;!d();)c.e(c.x,(l===l.toLowerCase()?c.y:0)+parseFloat(m())),b.yr(c.x,c.y);u&&(L=!0);break;case"C":for(;!d();){const D=new Point;g(D);const F=y(),R=p();b.wr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(L=!0);break;case"S":for(;!d();){const D=x(),F=y(),R=p();b.wr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(L=!0);break;case"Q":for(;!d();){const D=y(),F=p();b.Fw(D.x,D.y,F.x,F.y)}u&&(L=!0);break;case"T":for(;!d();){const D=x();f.c(D);const F=p();b.Fw(D.x,D.y,F.x,F.y),f.c(F)}u&&(L=!0);break;case"B":for(;!d();){const D=parseFloat(m()),F=parseFloat(m());let R=parseFloat(m()),I=parseFloat(m());const O=parseFloat(m());let V=O,K=!1;d()||(V=parseFloat(m()),d()||(K=parseFloat(m())!==0)),l===l.toLowerCase()&&(R+=c.x,I+=c.y),b.HD(D,F,R,I,O,V,K)}u&&(L=!0);break;case"A":for(;!d();){const D=Math.abs(parseFloat(m())),F=Math.abs(parseFloat(m())),R=parseFloat(m());let I=!1,O=!1,V=0,K=0;const B=m();B.length===1?(I=!!parseFloat(B),O=!!parseFloat(m()),V=parseFloat(m()),K=parseFloat(m())):B.length===2?(I=!!parseFloat(B[0]),O=!!parseFloat(B[1]),V=parseFloat(m()),K=parseFloat(m())):(I=!!parseFloat(B[0]),O=!!parseFloat(B[1]),V=parseFloat(B.slice(2)),K=parseFloat(m())),l===l.toLowerCase()&&(V=c.x+V,K=c.y+K),c.e(V,K),b.qD(D,F,R,I,O,V,K)}u&&(L=!0);break;case"Z":b.jD(),c.c(a);break;case"F":{let D="",F=1;for(;o[r+F];){if(o[r+F]==="0"){A=!0,F++;continue}if(o[r+F].match(/[Uu]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?S=!0:b.WD();break}case"U":{let D="",F=1;for(;o[r+F];){if(o[r+F].match(/[Ff]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?M=!0:b.vD(!1);break}default:if(l==="0"||l==="1")break;Util.ht("Unknown geometry command: "+l);break}if(L){Util.ht(`Bad geometry command: ${l}, next token: ${m()}, +string: ${t}`);break}}const T=b.tm;if(GeoStream.MC(b),i){const L=T.figures.iterator;for(;L.next();){const D=L.value;D.isFilled=!0}}return T}static PC(t,i){const e=t.length,s=Point.a();for(let n=0;n=t)return 0;if((n>r?n-r:r-n)<(o>l?o-l:l-o)){if(ol)return 0}else if(fo)return 0}else if(nr)return 0}else if(an)return 0;return h>0?1:-1}CC(t,i,e){const s=this.figures.h,n=s.length;for(let o=0;o1&&(t=1),i===void 0&&(i=new Point),this.type===1)return i.e(this.startX+t*(this.endX-this.startX),this.startY+t*(this.endY-this.startY)),i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[c*2],y=g[c*2+1],x=g[c*2+2],k=g[c*2+3];return i.e(p+(x-p)*m,y+(k-y)*m),i}l+=u}}return i}getAngleAlongPath(t){if(t<0?t=0:t>1&&(t=1),this.type===1)return Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI;const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=i.length,o=s*t;let r=0;for(let l=0;l=o){const u=i[l],d=u[f*2],m=u[f*2+1],g=u[f*2+2],p=u[f*2+3];return Math.abs(g-d)<1&&Math.abs(p-m)<1?0:Math.abs(g-d)<1?p-m>=0?90:270:Math.abs(p-m)<1?g-d>=0?0:180:Math.atan2(p-m,g-d)*180/Math.PI}r+=c}}return NaN}getPointAndAngleAlongPath(t,i){if(t<0?t=0:t>1&&(t=1),i===void 0&&(i=[]),i.length=3,this.type===1)return i[0]=this.startX+t*(this.endX-this.startX),i[1]=this.startY+t*(this.endY-this.startY),i[2]=Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI,i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[c*2],y=g[c*2+1],x=g[c*2+2],k=g[c*2+3];i[0]=p+(x-p)*m,i[1]=y+(k-y)*m;let b;return Math.abs(x-p)<1&&Math.abs(k-y)<1?b=0:Math.abs(x-p)<1?b=k-y>=0?90:270:Math.abs(k-y)<1?b=x-p>=0?0:180:b=Math.atan2(k-y,x-p)*180/Math.PI,i[2]=b,i}l+=u}}return i}getFractionForPoint(t){if(this.type===1){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=t.x,r=t.y;let l=0,h=0;if(i===s)return e=h?h===e?0:1:Math.abs(r-e)/(h-l);if(e===n)return i=h?h===i?0:1:Math.abs(o-i)/(h-l);{const a=(s-i)*(s-i)+(n-e)*(n-e),f=Point.a();Geo.xl(i,e,s,n,o,r,f);const c=f.x,u=f.y;return Point.o(f),Math.sqrt(((c-i)*(c-i)+(u-e)*(u-e))/a)}}}else if(this.type===2){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=s-i,r=n-e,l=o*2+r*2;let h=t.x,a=t.y;h=Math.min(Math.max(h,i),s),a=Math.min(Math.max(a,e),n);const f=Math.abs(h-i),c=Math.abs(h-s),u=Math.abs(a-e),d=Math.abs(a-n),m=Math.min(f,c,u,d);if(m===u)return h/l;if(m===c)return(o+a)/l;if(m===d)return(o*2+r-h)/l;if(m===f)return(o*2+r*2-a)/l}}else{const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=Point.a();let o=1/0,r=0,l=0;const h=i.length;let a=0,f=0;for(let u=0;u1?1:c}return 0}get flattenedSegments(){return this.AC(),this.ff}AC(){if(this.ff===null){const t=this.ff=[],i=this.mu=[];this.$D(t,i)}}get flattenedLengths(){return this.AC(),this.mu}get flattenedTotalLength(){let t=this.pu;if(isNaN(t)){if(this.type===1){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=Math.sqrt(i*i+e*e)}else if(this.type===2){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=i*2+e*2}else{const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=4&&(t.push(e),i.push(this.Zk(e))),e=[],e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY,h=r,a=l;break;case 2:e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY;break;case 3:Geo.Gn(r,l,d.point1X,d.point1Y,d.point2X,d.point2Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 4:Geo.qg(r,l,d.point1X,d.point1Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 5:{const m=d.To(o),g=m.length;if(g===0){e.push(d.centerX),e.push(d.centerY),r=d.centerX,l=d.centerY;break}for(let p=0;p=4&&(t.push(e),i.push(this.Zk(e)))}}}get type(){return this.it}set type(t){this.it!==t&&(Debug&&Util.tt(t,GeometryType,"GeometryType"),this.f&&Util.F(this,t),this.it=t,t===4?this.Bs=new List:(Geometry.Dw===null&&(Geometry.Dw=new List().w()),this.Bs=Geometry.Dw),this.Nt=!0)}get startX(){return this.Pe}set startX(t){this.Pe!==t&&(Debug&&Util.r(t,Geometry,"startX"),this.f&&Util.F(this,t),this.Pe=t,this.Nt=!0)}get startY(){return this.Ne}set startY(t){this.Ne!==t&&(Debug&&Util.r(t,Geometry,"startY"),this.f&&Util.F(this,t),this.Ne=t,this.Nt=!0)}get endX(){return this.se}set endX(t){this.se!==t&&(Debug&&Util.r(t,Geometry,"endX"),this.f&&Util.F(this,t),this.se=t,this.Nt=!0)}get endY(){return this.ne}set endY(t){this.ne!==t&&(Debug&&Util.r(t,Geometry,"endY"),this.f&&Util.F(this,t),this.ne=t,this.Nt=!0)}get figures(){return this.Bs}set figures(t){this.Bs!==t&&(Debug&&Util.s(t,List,Geometry,"figures"),this.f&&Util.F(this,t),this.Bs=t,this.Nt=!0)}add(t){return this.Bs.add(t),this}setSpots(t,i,e,s,n,o,r,l){return this.f&&Util.F(this),this.jn=new Spot(t,i,n,o).w(),this.Wn=new Spot(e,s,r,l).w(),this}get spot1(){return this.jn}set spot1(t){Debug&&Util.s(t,Spot,Geometry,"spot1"),this.f&&Util.F(this,t),this.jn=t.L()}get spot2(){return this.Wn}set spot2(t){Debug&&Util.s(t,Spot,Geometry,"spot2"),this.f&&Util.F(this,t),this.Wn=t.L()}get defaultStretch(){return this.vn}set defaultStretch(t){this.vn=t}get bounds(){return this.Wk()&&this.Rw(),this.Qg}}Geometry.stringify=Geometry.stringify,Geometry.stringifyFixed=Geometry.stringifyFixed,Geometry.fillPath=Geometry.fillPath,Geometry.parse=Geometry.parse;class PathFigure{l;Pe;Ne;df;im;Ue;constructor(t,i,e,s,n){e===void 0&&(e=!0),s===void 0&&(s=!0),n===void 0&&(n=!1),this.l=2|(e?4:0)|(s?8:0)|(n?16:0),t!==void 0?(Debug&&Util.r(t,PathFigure,"sx"),this.Pe=t):this.Pe=0,i!==void 0?(Debug&&Util.r(i,PathFigure,"sy"),this.Ne=i):this.Ne=0,this.df=new List,this.im=this.df.dt,this.Ue=null}copy(){const t=new PathFigure;t.l=this.l&-2,t.Pe=this.Pe,t.Ne=this.Ne;const i=this.df.h,e=i.length,s=t.df;for(let n=0;no===0?"0":o.toFixed(t);i="M"+n(this.startX)+" "+n(this.startY)}const e=this.segments.h,s=e.length;for(let n=0;n(w[w.Move=1]="Move",w[w.Line=2]="Line",w[w.Bezier=3]="Bezier",w[w.QuadraticBezier=4]="QuadraticBezier",w[w.Arc=5]="Arc",w[w.SvgArc=6]="SvgArc",w))(SegmentType||{});class PathSegment{it;l;se;ne;dn;kl;Sl;xr;Vs;constructor(t,i,e,s,n,o,r,l){if(GSet.vi(this),t===void 0?t=2:Debug&&Util.tt(t,SegmentType,"SegmentType"),this.it=t,this.l=2,i!==void 0?(Debug&&Util.r(i,PathSegment,"ex"),this.se=i):this.se=0,e!==void 0?(Debug&&Util.r(e,PathSegment,"ey"),this.ne=e):this.ne=0,s===void 0&&(s=0),n===void 0&&(n=0),o===void 0&&(o=0),r===void 0&&(r=0),t===6){let h=o;h=h%360,h<0&&(h+=360),this.dn=h,this.kl=0,Debug&&Util.r(s,PathSegment,"x1"),this.Sl=Math.max(s,0),Debug&&Util.r(n,PathSegment,"y1"),this.xr=Math.max(n,0),typeof r=="boolean"?r&&(this.isLargeArc=!0):typeof r=="number"&&r&&(this.isLargeArc=!0),l&&(this.isClockwiseArc=!0)}else Debug&&Util.r(s,PathSegment,"x1"),this.dn=s,Debug&&Util.r(n,PathSegment,"y1"),this.kl=n,Debug&&Util.r(o,PathSegment,"x2"),t===5&&(o=Math.max(o,0)),this.Sl=o,typeof r=="number"?(t===5&&(r=Math.max(r,0)),this.xr=r):this.xr=0;this.Vs=null}copy(){const t=new PathSegment;return t.it=this.it,t.l=this.l&-2,t.se=this.se,t.ne=this.ne,t.dn=this.dn,t.kl=this.kl,t.Sl=this.Sl,t.xr=this.xr,t}equalsApprox(t){if(!(t instanceof PathSegment)||this.type!==t.type||this.isClosed!==t.isClosed)return!1;switch(this.type){case 1:case 2:return Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY);case 3:return Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY)&&Geo.p(this.point1X,t.point1X)&&Geo.p(this.point1Y,t.point1Y)&&Geo.p(this.point2X,t.point2X)&&Geo.p(this.point2Y,t.point2Y);case 4:return Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY)&&Geo.p(this.point1X,t.point1X)&&Geo.p(this.point1Y,t.point1Y);case 5:return Geo.p(this.startAngle,t.startAngle)&&Geo.p(this.sweepAngle,t.sweepAngle)&&Geo.p(this.centerX,t.centerX)&&Geo.p(this.centerY,t.centerY)&&Geo.p(this.radiusX,t.radiusX)&&Geo.p(this.radiusY,t.radiusY);case 6:return this.isClockwiseArc===t.isClockwiseArc&&this.isLargeArc===t.isLargeArc&&Geo.p(this.xAxisRotation,t.xAxisRotation)&&Geo.p(this.endX,t.endX)&&Geo.p(this.endY,t.endY)&&Geo.p(this.radiusX,t.radiusX)&&Geo.p(this.radiusY,t.radiusY);default:return!1}}fi(t){t in SegmentType?this.type=t:Util.ur(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e="";switch(this.type){case 1:t<0?e="M"+this.endX.toString()+" "+this.endY.toString():e="M"+i(this.endX)+" "+i(this.endY);break;case 2:t<0?e="L"+this.endX.toString()+" "+this.endY.toString():e="L"+i(this.endX)+" "+i(this.endY);break;case 3:t<0?e="C"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.point2X.toString()+" "+this.point2Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="C"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.point2X)+" "+i(this.point2Y)+" "+i(this.endX)+" "+i(this.endY);break;case 4:t<0?e="Q"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="Q"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.endX)+" "+i(this.endY);break;case 5:t<0?e="B"+this.startAngle.toString()+" "+this.sweepAngle.toString()+" "+this.centerX.toString()+" "+this.centerY.toString()+" "+this.radiusX.toString()+" "+this.radiusY.toString():e="B"+i(this.startAngle)+" "+i(this.sweepAngle)+" "+i(this.centerX)+" "+i(this.centerY)+" "+i(this.radiusX)+" "+i(this.radiusY);break;case 6:t<0?e="A"+this.radiusX.toString()+" "+this.radiusY.toString()+" "+this.xAxisRotation.toString()+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+this.endX.toString()+" "+this.endY.toString():e="A"+i(this.radiusX)+" "+i(this.radiusY)+" "+i(this.xAxisRotation)+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+i(this.endX)+" "+i(this.endY);break;default:e=SegmentType[this.type]}return e+(this.isClosed?"z":"")}static Move=1;static Line=2;static Bezier=3;static QuadraticBezier=4;static Arc=5;static SvgArc=6;get f(){return(this.l&1)!==0}set f(t){t?this.l|=1:this.l&=-2}get Nt(){return(this.l&2)!==0}set Nt(t){t?this.l|=2:this.l&=-3}w(){return this.f=!0,this}ft(){return this.f=!1,this}close(){return this.isClosed=!0,this}To(t){if(this.Vs!==null&&t.Nt===!1)return this.Vs;const i=this.radiusX;let e=this.radiusY;if(e===void 0&&(e=i),i===0||e===0)return this.Vs=[],this.Vs;const s=this.dn,n=this.kl,o=Geo.xC(0,0,i1&&(o*=Math.sqrt(p),r*=Math.sqrt(p));let y=(h===a?-1:1)*Math.sqrt((o*o*r*r-o*o*g*g-r*r*m*m)/(o*o*g*g+r*r*m*m));isNaN(y)&&(y=0);let x=y*o*g/r,k=y*-r*m/o;isNaN(x)&&(x=0),isNaN(k)&&(k=0);const b=(s+f)/2+u*x-d*k,S=(n+c)/2+d*x+u*k,M=(X,z)=>Math.sqrt(X*X+z*z),A=(X,z,G,q)=>(X*G+z*q)/(M(X,z)*M(G,q)),C=(X,z,G,q)=>(X*q=1&&(F=0),!a&&F>0&&(F=F-2*Math.PI),a&&F<0&&(F=F+2*Math.PI);const I=o>r?o:r,O=o>r?1:o/r,V=o>r?r/o:1,K=Geo.xC(0,0,I,P,P+F,!0),B=Transform.a();return B.Vi(),B.Es(b,S),B.ms(this.dn,0,0),B.rt(O,V),Geometry.PC(K,B),Transform.o(B),this.Vs=K,this.Vs}get isClosed(){return(this.l&8)!==0}set isClosed(t){this.isClosed!==t&&(t?this.l|=8:this.l&=-9,this.Nt=!0)}get type(){return this.it}set type(t){Debug&&Util.tt(t,SegmentType,"SegmentType"),this.f&&Util.F(this,t),this.it=t,this.Nt=!0}get endX(){return this.se}set endX(t){Debug&&Util.r(t,PathSegment,"endX"),this.f&&Util.F(this,t),this.se=t,this.Nt=!0}get endY(){return this.ne}set endY(t){Debug&&Util.r(t,PathSegment,"endY"),this.f&&Util.F(this,t),this.ne=t,this.Nt=!0}get point1X(){return this.dn}set point1X(t){Debug&&Util.r(t,PathSegment,"point1X"),this.f&&Util.F(this,t),this.dn=t,this.Nt=!0}get point1Y(){return this.kl}set point1Y(t){Debug&&Util.r(t,PathSegment,"point1Y"),this.f&&Util.F(this,t),this.kl=t,this.Nt=!0}get point2X(){return this.Sl}set point2X(t){Debug&&Util.r(t,PathSegment,"point2X"),this.f&&Util.F(this,t),this.Sl=t,this.Nt=!0}get point2Y(){return this.xr}set point2Y(t){Debug&&Util.r(t,PathSegment,"point2Y"),this.f&&Util.F(this,t),this.xr=t,this.Nt=!0}get centerX(){return this.dn}set centerX(t){Debug&&Util.r(t,PathSegment,"centerX"),this.f&&Util.F(this,t),this.dn=t,this.Nt=!0}get centerY(){return this.kl}set centerY(t){Debug&&Util.r(t,PathSegment,"centerY"),this.f&&Util.F(this,t),this.kl=t,this.Nt=!0}get radiusX(){return this.Sl}set radiusX(t){Debug&&Util.r(t,PathSegment,"radiusX"),t<0&&Util.G(t,">= zero",PathSegment,"radiusX"),this.f&&Util.F(this,t),this.Sl=t,this.Nt=!0}get radiusY(){return this.xr}set radiusY(t){Debug&&Util.r(t,PathSegment,"radiusY"),t<0&&Util.G(t,">= zero",PathSegment,"radiusY"),this.f&&Util.F(this,t),this.xr=t,this.Nt=!0}get startAngle(){return this.se}set startAngle(t){Debug&&Util.r(t,PathSegment,"startAngle"),this.f&&Util.F(this,t),t=t%360,t<0&&(t+=360),this.se=t,this.Nt=!0}get sweepAngle(){return this.ne}set sweepAngle(t){Debug&&Util.r(t,PathSegment,"sweepAngle"),this.f&&Util.F(this,t),t>360&&(t=360),t<-360&&(t=-360),this.ne=t,this.Nt=!0}get isClockwiseArc(){return(this.l&4)!==0}set isClockwiseArc(t){this.f&&Util.F(this,t),t?this.l|=4:this.l&=-5,this.Nt=!0}get isLargeArc(){return(this.l&16)!==0}set isLargeArc(t){this.f&&Util.F(this,t),t?this.l|=16:this.l&=-17,this.Nt=!0}get xAxisRotation(){return this.dn}set xAxisRotation(t){Debug&&Util.r(t,PathSegment,"xAxisRotation"),this.f&&Util.F(this,t),t=t%360,t<0&&(t+=360),this.dn=t,this.Nt=!0}}class InputEvent{b;Ow;Ew;em;sm;nm;om;rm;lm;hm;am;fm;cm;um;Do;dm;gm;mm;Ce;constructor(){this.b=null,this.Ow=new Point(0,0).w(),this.Ew=new Point(0,0).w(),this.em=0,this.sm=0,this.nm=1,this.om="",this.rm="",this.lm=!1,this.hm=!1,this.am=0,this.fm=0,this.cm=!1,this.um=!1,this.Do=!1,this.dm=null,this.gm=0,this.mm=null,this.Ce=null}copy(){const t=new InputEvent;return this.clone(t)}clone(t){return t.b=this.b,t.Ow.c(this.viewPoint),t.Ew.c(this.documentPoint),t.em=this.em,t.sm=this.sm,t.nm=this.nm,t.om=this.om,t.rm=this.rm,t.lm=this.lm,t.hm=this.hm,t.am=this.am,t.fm=this.fm,t.cm=this.cm,t.um=this.um,t.Do=this.Do,t.dm=this.dm,t.gm=this.gm,t.mm=this.mm,t.Ce=this.Ce,t}toString(){let t="^";return this.modifiers!==0&&(t+="M:"+this.modifiers),this.button!==0&&(t+="B:"+this.button),this.key!==""&&(t+="K:"+this.key),this.clickCount!==0&&(t+="C:"+this.clickCount),this.delta!==0&&(t+="D:"+this.delta),this.handled&&(t+="h"),this.bubbles&&(t+="b"),this.documentPoint!==null&&(t+="@"+this.documentPoint.toString()),t}get diagram(){return this.b}set diagram(t){this.b=t}get viewPoint(){return this.Ow}set viewPoint(t){Util.s(t,Point,InputEvent,"viewPoint"),this.Ow.c(t)}get documentPoint(){return this.Ew}set documentPoint(t){Util.s(t,Point,InputEvent,"documentPoint"),this.Ew.c(t)}getMultiTouchViewPoint(t,i){const e=this.diagram;return e===null||e.LC(this.event,t,i),i}getMultiTouchDocumentPoint(t,i){const e=this.diagram;return e===null||(e.LC(this.event,t,i),i.c(e.transformViewToDoc(i))),i}get modifiers(){return this.em}set modifiers(t){this.em=t}get button(){return this.sm}set button(t){if(this.sm=t,this.event===null)switch(t){case 0:this.buttons=1;return;case 1:this.buttons=4;return;case 2:this.buttons=2;return}}get buttons(){return this.nm}set buttons(t){this.nm=t}get key(){return this.om}set key(t){this.om=t}get code(){return this.rm}set code(t){this.rm=t}get down(){return this.lm}set down(t){this.lm=t}get up(){return this.hm}set up(t){this.hm=t}get clickCount(){return this.am}set clickCount(t){this.am=t}get delta(){return this.fm}set delta(t){this.fm=t}get isMultiTouch(){return this.cm}set isMultiTouch(t){this.cm=t}get handled(){return this.um}set handled(t){this.um=t}get bubbles(){return this.Do}set bubbles(t){this.Do=t}get event(){return this.dm}set event(t){this.dm=t}get isTouchEvent(){const t=this.event;return t===null?!1:t.pointerType==="touch"||t.pointerType==="pen"}get timestamp(){return this.gm}set timestamp(t){this.gm=t}get targetDiagram(){return this.mm}set targetDiagram(t){this.mm=t}get targetObject(){return this.Ce}set targetObject(t){this.Ce=t}get control(){return(this.modifiers&1)!==0}set control(t){this.modifiers=t?this.modifiers|1:this.modifiers&-2}get shift(){return(this.modifiers&4)!==0}set shift(t){this.modifiers=t?this.modifiers|4:this.modifiers&-5}get alt(){return(this.modifiers&2)!==0}set alt(t){this.modifiers=t?this.modifiers|2:this.modifiers&-3}get meta(){return(this.modifiers&8)!==0}set meta(t){this.modifiers=t?this.modifiers|8:this.modifiers&-9}get left(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===0:(this.buttons&1)!==0}set left(t){t?this.buttons|=1:this.buttons&=-2}get right(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===2:(this.buttons&2)!==0}set right(t){t?this.buttons|=2:this.buttons&=-3}get middle(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===1:(this.buttons&4)!==0}set middle(t){t?this.buttons|=4:this.buttons&=-5}get commandKey(){const t=this.code,i=this.key;return"cxvyzagCXVYZAG".includes(i)?i.toLowerCase():t==="KeyC"?"c":t==="KeyX"?"x":t==="KeyV"?"v":t==="KeyY"?"y":t==="KeyZ"?"z":t==="KeyA"?"a":t==="KeyG"?"g":t!==""?t:i}}class DiagramEvent{b;Tt;pm;ym;constructor(){this.b=null,this.Tt="",this.pm=null,this.ym=null}copy(){const t=new DiagramEvent;return t.b=this.b,t.Tt=this.Tt,t.pm=this.pm,t.ym=this.ym,t}toString(){let t="*"+this.name;return this.subject!==null&&(t+=":"+this.subject.toString()),this.parameter!==null&&(t+="("+this.parameter.toString()+")"),t}get diagram(){return this.b}set diagram(t){this.b=t}get name(){return this.Tt}set name(t){this.Tt=t}get subject(){return this.pm}set subject(t){this.pm=t}get parameter(){return this.ym}set parameter(t){this.ym=t}}var ChangeType=(w=>(w[w.Transaction=1]="Transaction",w[w.Property=2]="Property",w[w.Insert=3]="Insert",w[w.Remove=4]="Remove",w))(ChangeType||{});class ChangedEvent{wu;wm;gn;Ai;b;xu;gf;mf;pf;yf;constructor(){this.wu=2,this.wm="",this.gn="",this.Ai=null,this.b=null,this.xu=null,this.gf=null,this.mf=null,this.pf=null,this.yf=null}static Transaction=1;static Property=2;static Insert=3;static Remove=4;clear(){this.Ai=null,this.b=null,this.xu=null,this.gf=null,this.mf=null,this.pf=null,this.yf=null}copy(){const t=new ChangedEvent;t.wu=this.wu,t.wm=this.wm,t.gn=this.gn,t.Ai=this.Ai,t.b=this.b,t.xu=this.xu;let i=this.gf;return Util.Mt(i)&&typeof i.copyFrozen=="function"?t.gf=i.copyFrozen():t.gf=i,i=this.mf,Util.Mt(i)&&typeof i.copyFrozen=="function"?t.mf=i.copyFrozen():t.mf=i,i=this.pf,Util.Mt(i)&&typeof i.copyFrozen=="function"?t.pf=i.copyFrozen():t.pf=i,i=this.yf,Util.Mt(i)&&typeof i.copyFrozen=="function"?t.yf=i.copyFrozen():t.yf=i,t}fi(t){t in ChangeType?this.change=t:Util.ur(this,t)}toString(){let t="";return this.change===1?t+="* ":this.change===2?t+=this.model!==null?"!m":"!d":t+=(this.model!==null?"!m":"!d")+this.change,this.propertyName&&typeof this.propertyName=="string"&&(t+=" "+this.propertyName),this.modelChange&&this.modelChange!==this.propertyName&&(t+=" "+this.modelChange),t+=": ",this.change===1?this.oldValue!==null&&(t+=" "+this.oldValue):(this.object!==null&&(t+=Util.toString(this.object)),this.oldValue!==null&&(t+=" old: "+Util.toString(this.oldValue)),this.oldParam!==null&&(t+=" "+this.oldParam),this.newValue!==null&&(t+=" new: "+Util.toString(this.newValue)),this.newParam!==null&&(t+=" "+this.newParam)),t}getValue(t){return t?this.oldValue:this.newValue}getParam(t){return t?this.oldParam:this.newParam}canUndo(){return this.model!==null||this.diagram!==null}undo(){this.canUndo()&&(this.model!==null?this.model.changeState(this,!0):this.diagram!==null&&this.diagram.TC(this,!0))}canRedo(){return this.model!==null||this.diagram!==null}redo(){this.canRedo()&&(this.model!==null?this.model.changeState(this,!1):this.diagram!==null&&this.diagram.TC(this,!1))}get model(){return this.Ai}set model(t){this.Ai=t}get diagram(){return this.b}set diagram(t){this.b=t}get change(){return this.wu}set change(t){this.wu=t}get modelChange(){return this.wm}set modelChange(t){Debug&&Util.t(t,"string",ChangedEvent,"modelChange"),this.wm=t}get propertyName(){return this.gn}set propertyName(t){Debug&&typeof t!="string"&&Util.t(t,"function",ChangedEvent,"propertyName"),this.gn=t}get isTransactionFinished(){return this.wu===1&&(this.gn==="CommittedTransaction"||this.gn==="FinishedUndo"||this.gn==="FinishedRedo")}get object(){return this.xu}set object(t){this.xu=t}get oldValue(){return this.gf}set oldValue(t){this.gf=t}get oldParam(){return this.mf}set oldParam(t){this.mf=t}get newValue(){return this.pf}set newValue(t){this.pf=t}get newParam(){return this.yf}set newParam(t){this.yf=t}}class Transaction{DC;Tt;$k;constructor(){this.DC=new List().w(),this.Tt="",this.$k=!1}toString(t){let i="Transaction: "+this.name+" "+this.changes.count.toString()+(this.isComplete?"":", incomplete");if(t!==void 0&&t>0){const e=this.changes.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),t.w()}canUndo(){return this.isComplete}undo(){if(this.canUndo())for(let t=this.changes.count-1;t>=0;t--){const i=this.changes.elt(t);i!==null&&i.undo()}}canRedo(){return this.isComplete}redo(){if(!this.canRedo())return;const t=this.changes.count;for(let i=0;i=t;e--){const s=i.elt(e);s!==null&&s.undo(),i.ft(),i.removeAt(e)}i.w()}optimize(){if(!this.isComplete)return;const t=this.changes;t.ft();const i=new GMap;for(let s=0;s0&&t.setElt(r,null),o.set(n.propertyName,s))}let e=0;for(let s=0;se&&t.setElt(e,n),e++)}for(;t.length>e;)t.pop();t.w()}get changes(){return this.DC}get name(){return this.Tt}set name(t){this.Tt=t}get isComplete(){return this.$k}set isComplete(t){this.$k=t}}class UndoManager{Bw;Xi;FC;zs;Qk;xm;Jn;Vw;_k;mn;wf;zw;Xs;Xw;Yw;bm;Kw;constructor(t){this.Bw=new GSet,this.Xi=!1,this.FC=new List().w(),this.zs=-1,this.Qk=999,this.Xs=!1,this.xm=null,this.Jn=0,this.Vw=!1,Debug&&(this.Vw=!0),this._k=23,this.mn=new List().w(),this.wf=new List,this.zw=!0,this.Xw=!1,this.Yw=!1,this.bm=!1,this.Kw=!1,t&&Object.assign(this,t)}toString(t){let i="UndoManager "+this.historyIndex+"<"+this.history.count+"<="+this.maxHistoryLength;i+="[";let e=this.nestedTransactionNames.count;for(let s=0;s0&&(i+=" "),i+=this.nestedTransactionNames.elt(s);if(i+="]",t!==void 0&&t>0){e=this.history.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),this.zs=-1,t.w(),this.Xs=!1,this.xm=null,this.Jn=0,this.mn.ft(),this.mn.clear(),this.mn.w(),this.wf.clear(),this.Xw=!1,this.Yw=!1,this.bm=!1,this.Kw=!1}copyProperties(t){this.isEnabled=t.isEnabled,this.maxHistoryLength=t.maxHistoryLength,this.bu=t.bu}addModel(t){this.Bw.add(t)}removeModel(t){this.Bw.delete(t)}startTransaction(t){if(t===void 0&&(t=""),t===null&&(t=""),this.isUndoingRedoing)return!1;this.zw===!0&&(this.zw=!1,this.Jn++,this.Ml||this.i("StartingFirstTransaction",t,this.currentTransaction),this.Jn>0&&this.Jn--),this.isEnabled&&(this.mn.ft(),this.mn.add(t),this.mn.w(),this.currentTransaction===null?this.wf.add(0):this.wf.add(this.currentTransaction.changes.count)),this.Jn++;const i=this.transactionLevel===1;return i&&(this.Ml||this.i("StartedTransaction",t,this.currentTransaction)),i}commitTransaction(t){return t===void 0&&(t=""),this.RC(!0,t)}rollbackTransaction(){return this.RC(!1,"")}RC(t,i){if(this.isUndoingRedoing)return!1;this.bu&&this.transactionLevel<1&&Util.ht("Ending transaction without having started a transaction: "+i);const e=this.transactionLevel===1;let s=this.currentTransaction;e&&t&&(this.Ml||this.i("CommittingTransaction",i,s));let n=0;if(this.transactionLevel>0&&(this.Jn--,this.isEnabled)){const o=this.mn.count;o>0&&(i===""&&(i=this.mn.elt(0)),this.mn.ft(),this.mn.removeAt(o-1),this.mn.w());const r=this.wf.count;r>0&&(n=this.wf.elt(r-1),this.wf.removeAt(r-1))}if(e){if(t){if(this.bm=!1,s===null&&i!==""&&(s=this.currentTransaction),this.isEnabled&&s!==null){const o=s;o.isComplete||(o.isComplete=!0,o.name=i),this.discardHistoryAfterIndex();const r=this.history;r.ft();const l=this.maxHistoryLength;if(l>=0){if(l===0)r.clear();else if(r.count>=l){const h=r.elt(0);h!==null&&h.clear(),r.removeAt(0),this.zs--}}l!==0&&(r.count===0||r.get(r.count-1)!==o)&&(r.add(o),this.zs++),r.w(),s=o}this.Ml||this.i("CommittedTransaction",i,s)}else{this.Xs=!0;try{this.isEnabled&&s!==null&&(s.isComplete=!0,s.undo())}finally{this.Ml||this.i("RolledBackTransaction",i,s),this.Xs=!1}s!==null&&s.clear()}return this.xm=null,this.Uw&&this.clear(),this.Uw=!1,this.Gw=!1,!0}else return this.isEnabled&&!t&&s!==null&&s.QD(n),!1}discardHistoryAfterIndex(){if(this.isUndoingRedoing||!this.canRedo())return;const t=this.history;t.ft();for(let i=t.count-1;i>this.historyIndex;i--){const e=t.elt(i);e!==null&&e.clear(),t.removeAt(i),this.bm=!0}t.w()}rE(t){this.Jn+=t,this.Jn<0&&(this.Jn=0)}canUndo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToUndo;return!!(t!==null&&t.canUndo())}undo(){if(!this.canUndo())return;const t=this.transactionToUndo;try{this.Xs=!0,this.i("StartingUndo","Undo",t),this.zs--,t.undo()}catch(i){Util.ht("undo error: "+i.toString())}finally{this.i("FinishedUndo","Undo",t),this.Xs=!1}}canRedo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToRedo;return!!(t!==null&&t.canRedo())}redo(){if(!this.canRedo())return;const t=this.transactionToRedo;try{this.Xs=!0,this.i("StartingRedo","Redo",t),this.zs++,t.redo()}catch(i){Util.ht("redo error: "+i.toString())}finally{this.i("FinishedRedo","Redo",t),this.Xs=!1}}i(t,i,e){e===void 0&&(e=null);const s=new ChangedEvent;s.change=1,s.propertyName=t,s.object=e,s.oldValue=i;const n=this.models;for(;n.next();){const o=n.value;s.model=o,o.Hw(s)}}handleChanged(t){if(this.isEnabled&&!this.isUndoingRedoing&&!this.skipsEvent(t)){let i=this.currentTransaction;i===null&&(i=new Transaction,this.xm=i);const e=t.copy(),s=i.changes;if(s.ft(),s.add(e),s.w(),this.bu&&this._k>0&&this.transactionLevel<=0&&!this.zw){const n=t.diagram;if(n!==null&&n.Kh===!1)return;Util.ht("Change not within a transaction: "+e.toString()),this._k--}}}skipsEvent(t){if(t===null||t.change===1)return!0;const i=t.object;if(i===null)return!1;if(i.layer!==void 0){const e=i.layer;if(e!==null&&e.isTemporary)return!0}else if(i.isTemporary)return!0;return!1}get models(){return this.Bw.iterator}get isEnabled(){return this.Xi}set isEnabled(t){this.Xi=t}get transactionToUndo(){return this.historyIndex>=0&&this.historyIndex<=this.history.count-1?this.history.elt(this.historyIndex):null}get transactionToRedo(){return this.historyIndex0}get bu(){return this.Vw}set bu(t){this.Vw=t}get nestedTransactionNames(){return this.mn}get Uw(){return this.Xw}set Uw(t){this.Xw=t}get Gw(){return this.Yw}set Gw(t){this.Yw=t}get Ml(){return this.Kw}set Ml(t){this.Kw=t}get isJustDiscarded(){return this.bm}}class Tool{b;Tt;Xi;tS;iS;km;IC;constructor(){GSet.vi(this),this.b=Diagram.Sm(),this.Tt="",this.Xi=!0,this.tS=!1,this.iS=null,this.IC=new InputEvent,this.km=-1}get diagram(){return this.b}set diagram(t){t instanceof Diagram&&(this.b=t)}toString(){return this.name!==""?this.name+" Tool":Util.hn(this.constructor)}updateAdornments(t){}canStart(){return this.isEnabled}doStart(){}doActivate(){this.isActive=!0}doDeactivate(){this.isActive=!1}doStop(){}doCancel(){this.transactionResult=null,this.stopTool()}stopTool(){const t=this.diagram;t.currentTool===this&&(t.currentTool=null,t.currentCursor="")}doMouseDown(){!this.isActive&&this.canStart()&&this.doActivate()}doMouseMove(){}doMouseUp(){this.stopTool()}doMouseWheel(){}canStartMultiTouch(){return!0}standardPinchZoomStart(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.H(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.H(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.o(e),Point.o(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){t.eS=t.scale;const n=s.x-e.x,o=s.y-e.y,r=Math.sqrt(n*n+o*o);t.sS=r,i.bubbles=!1}Point.o(e),Point.o(s)}standardPinchZoomMove(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.H(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.H(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.o(e),Point.o(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){const n=s.x-e.x,o=s.y-e.y,l=Math.sqrt(n*n+o*o)/t.sS,h=new Point((Math.min(s.x,e.x)+Math.max(s.x,e.x))/2,(Math.min(s.y,e.y)+Math.max(s.y,e.y))/2),a=t.eS*l,f=t.commandHandler;if(a!==t.scale&&f.canResetZoom(a)){const c=t.zoomPoint;t.zoomPoint=h,f.resetZoom(a),t.zoomPoint=c}i.bubbles=!1}Point.o(e),Point.o(s)}doKeyDown(){this.diagram.lastInput.code==="Escape"&&this.doCancel()}doKeyUp(){}startTransaction(t){return t===void 0&&(t=this.name),this.transactionResult=null,this.diagram.startTransaction(t)}stopTransaction(){const t=this.diagram;return this.transactionResult===null?t.rollbackTransaction():t.commitTransaction(this.transactionResult)}standardMouseSelect(){const t=this.diagram;if(!t.allowSelect)return;const i=t.lastInput,e=t.findPartAt(i.documentPoint,!1);if(e!==null){if(Util.cr?i.meta:i.control){t.B("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!s.isSelected),t.B("ChangedSelection",t.selection)}else if(i.shift){if(!e.isSelected){t.B("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!0),t.B("ChangedSelection",t.selection)}}else if(!e.isSelected){let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&t.select(s)}}else i.left&&!(Util.cr?i.meta:i.control)&&!i.shift&&t.clearSelection()}standardMouseClick(t,i){t===void 0&&(t=null),i===void 0&&(i=o=>!o.layer.isTemporary);const e=this.diagram,s=e.lastInput,n=e.findObjectAt(s.documentPoint,t,i);return s.targetObject=n,this._D(n,s,e),s.handled}_D(t,i,e){if(i.handled=!1,t!==null&&!t.isEnabledObject())return;let s=0;i.left?i.clickCount===1?s=1:i.clickCount===2?s=2:s=1:i.right&&i.clickCount===1&&(s=3);let n="ObjectSingleClicked";if(t!==null){switch(s){case 1:n="ObjectSingleClicked";break;case 2:n="ObjectDoubleClicked";break;case 3:n="ObjectContextClicked";break}s!==0&&e.B(n,t)}else{switch(s){case 1:n="BackgroundSingleClicked";break;case 2:n="BackgroundDoubleClicked";break;case 3:n="BackgroundContextClicked";break}s!==0&&e.B(n)}if(t!==null)for(;t!==null;){let o=null;switch(s){case 1:o=t.click;break;case 2:o=t.doubleClick?t.doubleClick:t.click;break;case 3:o=t.contextClick;break}if(o!==null&&(o(i,t),i.handled))break;t=t.panel}else{let o=null;switch(s){case 1:o=e.click;break;case 2:o=e.doubleClick?e.doubleClick:e.click;break;case 3:o=e.contextClick;break}o!==null&&o(i)}}standardMouseOver(){const t=this.diagram,i=t.lastInput;if(t.animationManager.Si===!0)return;const e=t.skipsUndoManager;t.skipsUndoManager=!0;let s=t.viewportBounds.containsPoint(i.documentPoint)?t.findObjectAt(i.documentPoint,null,null):null;i.event&&(i.event.type==="pointercancel"||i.event.type==="pointerout")&&(s=null),i.targetObject=s;let n=!1;if(s!==t.xf){let o=t.xf;const r=o;for(t.xf=s,this.doCurrentObjectChanged(o,s),i.handled=!1;o!==null;){const l=o.mouseLeave;if(l!==null&&(s===o||s!==null&&s.isContainedBy(o)||(l(i,o,s),n=!0,i.handled)))break;o=o.panel}for(o=r,i.handled=!1;s!==null;){const l=s.mouseEnter;if(l!==null&&(o===s||o!==null&&o.isContainedBy(s)||(l(i,s,o),n=!0,i.handled)))break;s=s.panel}s=t.xf}if(s!==null){let o=s,r="";for(;o!==null&&(r=o.cursor,r==="");)o=o.panel;for(t.currentCursor=r,i.handled=!1,o=s;o!==null;){const l=o.mouseOver;if(l!==null&&(l(i,o),n=!0,i.handled))break;o=o.panel}}else{this.doUpdateCursor(null);const o=t.mouseOver;o!==null&&(o(i),n=!0)}n&&t.requestUpdate(),t.skipsUndoManager=e}doUpdateCursor(t){const i=this.diagram;i&&(i.currentCursor="")}doCurrentObjectChanged(t,i){}standardMouseWheel(){const t=this.diagram,i=t.lastInput;let e=i.delta;if(e===0||!t.documentBounds.isReal())return;const s=t.commandHandler,n=t.toolManager.mouseWheelBehavior;if(s!==null&&(n===2&&!i.shift||n===1&&i.control)){if(e>0?s.canIncreaseZoom():s.canDecreaseZoom()){const o=t.zoomPoint;t.zoomPoint=i.viewPoint,e>0?s.increaseZoom():s.decreaseZoom(),t.zoomPoint=o}i.bubbles=!1}else if(n===2&&i.shift||n===1&&!i.control){const o=t.position.copy(),r=i.event,l=r.deltaMode;let h=r.deltaX,a=r.deltaY,f="pixel";if((h!==0||a!==0)&&!i.shift){switch(l){case 0:f="pixel";break;case 1:f="line";break;case 2:f="page";break}if(h!==0&&t.allowHorizontalScroll){const c=t.scrollHorizontalLineChange;h=h*(c/16),t.scroll(f,h>0?"right":"left",Math.abs(h))}if(a!==0&&t.allowVerticalScroll){const c=t.scrollVerticalLineChange;a=a*(c/16),t.scroll(f,a>0?"down":"up",Math.abs(a))}}else!i.shift&&t.allowVerticalScroll?(e=e*3*t.scrollVerticalLineChange,t.scroll(f,e>0?"up":"down",Math.abs(e))):i.shift&&t.allowHorizontalScroll&&(e=e*3*t.scrollHorizontalLineChange,t.scroll(f,e>0?"left":"right",Math.abs(e)));this.doWheelChange(t,o,i)}}doWheelChange(t,i,e){(!t.position.equals(i)||e.event.wheelDeltaX!==0)&&(e.bubbles=!1)}standardWaitAfter(t,i){Debug&&Util.t(t,"number",Tool,"standardWaitAfter:delay"),i===void 0&&(i=this.diagram.lastInput),this.cancelWaitAfter();const e=this,s=i.clone(this.IC);this.km=Util.zh(()=>e.doWaitAfter(s),t)}cancelWaitAfter(){this.km!==-1&&Util.Kg(this.km),this.km=-1}doWaitAfter(t){}findToolHandleAt(t,i){const s=this.diagram.findObjectAt(t,n=>{for(;n!==null&&!(n.panel instanceof Adornment);)n=n.panel;return n});return s===null?null:s.part.category===i?s:null}isBeyondDragSize(t,i){const e=this.diagram;t===void 0&&(t=e.firstInput.viewPoint),i===void 0&&(i=e.lastInput.viewPoint);const s=e.toolManager.dragSize;let n=s.width,o=s.height;return e.firstInput.isTouchEvent&&(n+=6,o+=6),Math.abs(i.x-t.x)>n||Math.abs(i.y-t.y)>o}get name(){return this.Tt}set name(t){Util.t(t,"string",Tool,"name"),this.Tt=t}get isEnabled(){return this.Xi}set isEnabled(t){Util.t(t,"boolean",Tool,"isEnabled"),this.Xi=t}get isActive(){return this.tS}set isActive(t){Util.t(t,"boolean",Tool,"isActive"),this.tS=t}get transactionResult(){return this.iS}set transactionResult(t){t!==null&&Util.t(t,"string",Tool,"transactionResult"),this.iS=t}}var WheelMode=(w=>(w[w.Scroll=1]="Scroll",w[w.Zoom=2]="Zoom",w[w.None=3]="None",w))(WheelMode||{}),GestureMode=(w=>(w[w.Zoom=1]="Zoom",w[w.Cancel=2]="Cancel",w[w.None=3]="None",w))(GestureMode||{});class ToolManager extends Tool{OC;EC;BC;nS;oS;rS;lS;hS;aS;fS;Mm;Uh;constructor(t){super(),this.name="ToolManager",this.OC=new List,this.EC=new List,this.BC=new List,this.nS=850,this.oS=850,this.rS=new Size(2,2).ot(),this.lS=5e3,this.hS=1,this.aS=1,this.fS=null,this.Mm=null,this.Uh=-1,t&&Object.assign(this,t)}static WheelScroll=1;static WheelZoom=2;static WheelNone=3;static GestureZoom=1;static GestureCancel=2;static GestureNone=3;get mouseWheelBehavior(){return this.hS}set mouseWheelBehavior(t){Util.tt(t,WheelMode,"WheelMode"),this.hS=t}get gestureBehavior(){return this.aS}set gestureBehavior(t){Util.tt(t,GestureMode,"GestureMode"),this.aS=t}initializeStandardTools(){}updateAdornments(t){const i=this.currentToolTip;if(i instanceof Adornment&&this.Mm===t){const e=i.adornedObject;(t!==null?e.part===t:e===null)?this.showToolTip(i,e):this.hideToolTip()}}doMouseDown(){const t=this.diagram,i=t.lastInput;if(i.isTouchEvent&&this.gestureBehavior===2&&(i.bubbles=!1),i.isMultiTouch){if(this.cancelWaitAfter(),this.gestureBehavior===3){i.bubbles=!0;return}if(this.gestureBehavior===2)return;if(t.currentTool.canStartMultiTouch()){t.currentTool.standardPinchZoomStart();return}}const e=t.undoManager;Debug&&e.bu&&e.transactionLevel!==0&&Util.ht("WARNING: In ToolManager.doMouseDown: UndoManager.transactionLevel is not zero");const s=this.mouseDownTools.length;for(let n=0;n0&&s!==1/0){const n=this;this.Uh=Util.zh(()=>n.hideToolTip(),s)}}positionToolTip(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom?n.y-=o.height+5/s.scale:n.y+=20/s.scale,n.y30&&t.jw(),t.Ww(this.draggedParts),t.Mu=!0,this.startTransaction("Drag"),this.startPoint=t.firstInput.documentPoint,t.isMouseCaptured=!0,t.allowDragOut&&this.iF()}MS(t){if(this.dragsLink){const i=this.diagram;if(!i.allowRelink)return;i.model.Sf()&&t.count===1&&t.first()instanceof Link?(this.draggedLink=t.first(),this.draggedLink.canRelinkFrom()&&this.draggedLink.canRelinkTo()&&this.draggedLink.clearAdornments(),this.pn=i.toolManager.findTool("Relinking"),this.pn===null&&(this.pn=new RelinkingTool,this.pn.diagram=i),this.pn.originalLink=this.draggedLink):(this.draggedLink=null,this.pn=null)}}computeEffectiveCollection(t,i){return this.diagram.commandHandler.computeEffectiveCollection(t,i)}Ys(t){return t===void 0?new DraggingInfo(Point.Lo):this.isGridSnapEnabled?new DraggingInfo(new Point(Math.round(t.x*1e3)/1e3,Math.round(t.y*1e3)/1e3)):new DraggingInfo(t.copy())}doDeactivate(){this.isActive=!1;const t=this.diagram;this.diagram.layout.isRealtime=this.SS,t.Mu=!1,t.Pl=!0,t.cacheGroupExternalLinks(!1),t.stopAutoScroll(),this.PS(),t.Nm(this.draggedParts),this.Su=null,this.currentPart=null,this.draggedParts=null,this.isDragOutStarted=!1,this.ku=!1,DraggingTool.eF(),this.zC(),this.bf.e(NaN,NaN),DraggingTool.Hh!==null&&(DraggingTool.Hh.currentCursor=""),DraggingTool.Hh=null,DraggingTool.St=null,this.Nl(),t.isMouseCaptured=!1,t.currentCursor="",t.kf=!1,this.stopTransaction(),t.NS(!0)}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}PS(){const t=this.diagram,i=t.skipsUndoManager;t.skipsUndoManager=!0;const e=t.lastInput;this.XC(e,null),t.skipsUndoManager=i,this.br.length=0}YC(){this.Nl(),this.CS();const t=this.diagram;this.bf.isReal()&&(t.position=this.bf),t.stopAutoScroll()}doCancel(){this.Nl(),this.CS();const t=this.diagram;this.bf.isReal()&&(t.position=this.bf),this.stopTool()}doKeyDown(){const t=this.diagram,i=t.lastInput;this.isActive&&(i.code==="Escape"?this.doCancel():i.code!==t.previousInput.code&&this.doMouseMove())}doKeyUp(){this.isActive&&this.doMouseMove()}sF(t,i){let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=t.iterator;for(;r.next();){const l=r.value;if(!l.isVisible())continue;const h=l.location,a=h.x,f=h.y;isNaN(a)||isNaN(f)||(an&&(n=a),f>o&&(o=f))}return e===1/0?i.e(0,0,0,0):i.e(e,s,n-e,o-s),i}AS(t){if(this.copiedParts!==null)return;const i=this.diagram;if(t&&(i.isReadOnly||i.isModelReadOnly)||this.draggedParts===null)return;const e=i.undoManager;e.isEnabled&&e.isInTransaction?e.currentTransaction!==null&&e.currentTransaction.changes.count>0&&(i.undoManager.rollbackTransaction(),i.startTransaction("Drag")):this.CS(),i.skipsUndoManager=!t,i.partManager.addsToTemporaryLayer=!t,this.startPoint=i.firstInput.documentPoint;const s=this.copiesEffectiveCollection?this.draggedParts.toKeySet():i.selection,n=i.copyParts(s,i,!0),o=new GMap,r=this.draggedParts.iterator;for(;r.next();){const h=r.key;if(h.Ae()&&h.canCopy()){const a=n.get(h);if(a===null)continue;a.location=h.location,a.ensureBounds(),o.set(a,this.Ys(a.location))}}const l=n.iterator;for(;l.next();){const h=l.value;h instanceof Link&&h.canCopy()&&o.set(h,this.Ys())}if(this.copiedParts=o,this.MS(o.toKeySet()),this.draggedLink!==null){const h=this.draggedLink,a=h.routeBounds;h.kr(this.startPoint.x-(a.x+a.width/2),this.startPoint.y-(a.y+a.height/2))}this.doUpdateCursor(null)}Nl(){const t=this.diagram;if(this.copiedParts!==null){if(t.removeParts(this.copiedParts.toKeySet(),!1),this.copiedParts=null,this.draggedParts!==null){const i=this.draggedParts.iterator;for(;i.next();)if(i.key instanceof Link){const s=i.value;s.point=new Point(0,0)}}this.doUpdateCursor(null)}t.skipsUndoManager=!1,t.partManager.addsToTemporaryLayer=!1,this.startPoint=t.firstInput.documentPoint}zC(){this.draggedLink!==null&&(this.dragsLink&&this.pn!==null&&(this.pn.stopDraggingMouseMove(),this.pn.originalLink=null),this.draggedLink=null,this.pn=null)}Mf(t,i){const e=this.diagram,s=this.startPoint,n=Point.a();n.c(e.lastInput.documentPoint),this.moveParts(t,n.subtract(s),i),Point.o(n),e.getRenderingHint("temporaryPixelRatio")===!0&&e.Cl===null&&e.avgSpf>30&&(e.jw(),e.Pu())}moveParts(t,i,e){e===void 0&&(e=!1);const s=this.diagram;s!==null&&s.LS(t,i,this.dragOptions,e)}CS(){if(this.draggedParts===null)return;const t=this.diagram;let i=this.draggedParts.iterator;for(;i.next();){const e=i.key;e.Ae()&&(e.location=i.value.point)}for(i=this.draggedParts.iterator;i.next();){const e=i.key;if(e instanceof Link&&e.suspendsRouting){const s=i.value.point;this.draggedParts.set(e,this.Ys()),e.kr(-s.x,-s.y)}}t.maybeUpdate()}nF(t){if(t===null)return!0;const i=t.part;return!!(i===null||i instanceof Adornment||i.layer.isTemporary||this.draggedParts&&this.draggedParts.has(i)||this.copiedParts&&this.copiedParts.has(i))}TS(t){const i=this.diagram;this.dragsLink&&(this.draggedLink!==null&&(this.draggedLink.fromNode=null,this.draggedLink.toNode=null),this.KC(!1));const e=this.findDragOverObject(t),s=i.lastInput;s.targetObject=e,this.doUpdateCursor(e);const n=i.skipsUndoManager;let o=!1;try{if(i.skipsUndoManager=!0,o=this.XC(s,e),!this.isActive&&DraggingTool.St===null)return;const r=e!==null?e.part:null;if(r===null||i.handlesDragDropForTopLevelParts&&r.isTopLevel&&!(r instanceof Group)){const l=i.mouseDragOver;l!==null&&(l(s),o=!0)}if(!this.isActive&&DraggingTool.St===null||(this.doDragOver(t,e),!this.isActive&&DraggingTool.St===null))return}finally{i.skipsUndoManager=n,o&&i.maybeUpdate()}this.Su=e,!i.isReadOnly&&(i.allowMove||i.allowCopy)&&(i.allowHorizontalScroll||i.allowVerticalScroll)&&i.doAutoScroll(s.viewPoint)}findDragOverObject(t){return this.diagram.DS(t,null,i=>!this.nF(i))}doUpdateCursor(t){const i=this.diagram;(t===null||this.Su!==t)&&(!this.diagram.currentTool.isActive||this.mayCopy()?i.currentCursor=this.copyCursor:this.mayMove()?i.currentCursor=this.moveCursor:this.mayDragOut()&&(i.currentCursor=this.nodropCursor))}XC(t,i){let e=!1,s=this.br.length;const n=s>0?this.br[0]:null;if(i===n)return!1;t.handled=!1;for(let r=0;rs.findValidLinkablePort(a,i)),r=Point.a();let l=1/0,h=null;for(const a=o.iterator;a.next();){const f=a.value;if(f.part===null)continue;const u=f.getDocumentPoint(Spot.Center,r),d=t.distanceSquaredPoint(u);dh.suspendsRouting=!1)}if(this.doDropOnto(t,e),!this.isActive&&DraggingTool.St===null)return;const o=Rect.a(),r=i.selection.iterator;for(;r.next();){const l=r.value;l instanceof Node&&this.rF(i,l,o)}Rect.o(o)}oF(t,i){const e=this.diagram,s=i.part;if(e.handlesDragDropForTopLevelParts&&s.isTopLevel&&!(s instanceof Group)){const n=e.mouseDrop;n!==null&&n(t)}}rF(t,i,e){if(!i.canAvoid())return;let s=!1;e=i.getAvoidableRect(e),t.viewportBounds.containsRect(e)&&(s=!0);const n=this.copiedParts||this.draggedParts,o=t.IS(e,l=>l.part,l=>l instanceof Link,!0,l=>l instanceof Link,s);if(o.count===0)return;const r=o.iterator;for(;r.next();){const l=r.value;n.has(l)&&n.has(i)||!l.isMemberOf(i)&&l.isAvoiding&&l.invalidateRoute()}}doDropOnto(t,i){}doMouseMove(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseMove(i.event,i.documentPoint,i.targetDiagram))return;this.currentPart!==null&&this.draggedParts!==null&&(this.mayCopy()?(this.AS(!1),t.Ww(this.copiedParts),this.Mf(this.copiedParts,!1),t.Nm(this.copiedParts)):this.mayMove()?(this.Nl(),this.Mf(this.draggedParts,!0)):this.mayDragOut()?(this.AS(!1),this.Mf(this.copiedParts,!1)):this.Nl(),this.TS(t.lastInput.documentPoint))}doMouseUp(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseUp(i.event,i.documentPoint,i.targetDiagram))return;let e=!1;const s=this.mayCopy();if(s&&this.copiedParts!==null?(this.Nl(),this.AS(!0),t.Ww(this.copiedParts),this.Mf(this.copiedParts,!1),t.Nm(this.copiedParts),this.copiedParts!==null&&(t.B("ChangingSelection",t.selection),t.clearSelection(!0),this.copiedParts.iteratorKeys.each(n=>{n.isSelected=!0}))):(e=!0,this.Nl(),this.mayMove()&&(this.Mf(this.draggedParts,!0),this.TS(t.lastInput.documentPoint))),this.ku=!0,this.HC(t.lastInput.documentPoint),this.isActive){const n=s?this.copiedParts.toKeySet():this.draggedParts.toKeySet();this.copiedParts=null,e&&this.lF(),t.invalidateDocumentBounds(),t.Nm(this.draggedParts),this.transactionResult=s?"Copy":"Move",t.B(s?"SelectionCopied":"SelectionMoved",n)}this.stopTool(),s&&t.B("ChangedSelection",t.selection)}simulatedMouseMove(t,i,e){if(DraggingTool.St===null)return!1;const s=DraggingTool.St.diagram;e instanceof Diagram||(e=null);const n=DraggingTool.Hh;if(e!==n){if(n!==null&&n!==s){n.stopAutoScroll(),DraggingTool.St.isDragOutStarted=!1;const r=n.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDragLeave()}if(DraggingTool.Hh=e,e!==null&&e!==s){DraggingTool.St.YC();const r=e.toolManager.findTool("Dragging");r!==null&&(r.qC(),r.doSimulatedDragEnter())}this.doUpdateCursor(null)}if(e===null||e===s||!e.allowDrop||e.isReadOnly||!e.allowInsert)return!1;const o=e.toolManager.findTool("Dragging");if(o!==null){let r=i;t!==null&&(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),r=e.getMouse(t)),e.lastInput.documentPoint=r,e.lastInput.viewPoint=e.transformDocToView(r),e.lastInput.down=!1,e.lastInput.up=!1,o.doSimulatedDragOver()}return!0}simulatedMouseUp(t,i,e){if(DraggingTool.St===null)return!1;const s=DraggingTool.Hh,n=DraggingTool.St.diagram;if(e===null)return DraggingTool.St.doCancel(),!0;if(e!==s){const o=s.toolManager.findTool("Dragging");if(s!==null&&s!==n&&o!==null)return s.stopAutoScroll(),DraggingTool.St.isDragOutStarted=!1,o.doSimulatedDragLeave(),!1;DraggingTool.Hh=e;const r=e.toolManager.findTool("Dragging");r!==null&&(DraggingTool.St.YC(),r.qC(),r.doSimulatedDragEnter())}if(e!==this.diagram){let o=i;t!==null?(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),o=e.getMouse(t)):o===null&&(o=new Point),e.lastInput.documentPoint=o,e.lastInput.viewPoint=e.transformDocToView(o),e.lastInput.down=!1,e.lastInput.up=!0;const r=e.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDrop();const l=DraggingTool.St;if(l!==null){const h=l.mayCopy();l.transactionResult=h?"Copy":"Move",l.stopTool()}return!0}return!1}lF(){if(this.draggedParts===null)return;const t=this.draggedParts.iterator;for(;t.next();){const i=t.key;if(i instanceof Node){const e=i.containingGroup;e!==null&&e.hasPlaceholder()&&!this.draggedParts.has(e)&&e.placeholder.u()}}}mayCopy(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowCopy||!(Util.cr?t.lastInput.alt:t.lastInput.control))return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayDragOut(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(!t.allowDragOut||!t.allowCopy||t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayMove(){const t=this.diagram;if(t.isReadOnly||!t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canMove())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canMove())}qC(){DraggingTool.vw.has(this)||DraggingTool.vw.add(this)}static eF(){if(DraggingTool.vw.count>0){const t=DraggingTool.vw,i=t.length;for(let e=0;e{n.isSelected=!0,s.add(n)})),this.HC(t.lastInput.documentPoint),t.invalidateDocumentBounds(),this.copiedParts!==null&&(this.transactionResult="ExternalCopy"),this.copiedParts=null,t.doFocus(),t.kf=!1,t.B("ExternalObjectsDropped",s,e),this.stopTransaction(),t.B("ChangedSelection",t.selection)}t.animationManager.Nu=!1}jC(t,i,e){if(this.copiedParts!==null)return;const s=this.diagram;if(s.isReadOnly||s.isModelReadOnly)return;s.skipsUndoManager=!i,s.partManager.addsToTemporaryLayer=!i,this.startPoint=e.documentPoint;const n=s.copyParts(t,s,!0),o=Rect.a();this.sF(t,o);const r=o.x+o.width/2,l=o.y+o.height/2;Rect.o(o);const h=this.Pm,a=new GMap,f=Point.a(),c=t.iterator;for(;c.next();){const d=c.value;if(d instanceof Link&&d.canCopy()){const m=n.get(d);if(m===null)continue;m.points=d.points,m.kr(h.x-r,h.y-l),m.suspendsRouting=!0,a.set(m,this.Ys())}}const u=t.iterator;for(;u.next();){const d=u.value;if(d.Ae()&&d.canCopy()){const m=n.get(d);if(m===null)continue;const g=d.location;f.e(h.x-(r-g.x),h.y-(l-g.y)),m.location=f,m.ensureBounds(),a.set(m,this.Ys(f))}}if(Point.o(f),this.copiedParts=a,this.MS(a.toKeySet()),this.draggedLink!==null){const d=this.draggedLink,m=d.routeBounds;d.kr(this.startPoint.x-(m.x+m.width/2),this.startPoint.y-(m.y+m.height/2))}this.doUpdateCursor(null)}iF(){this.isDragOutStarted=!0,this.ku=!1,DraggingTool.St=this,DraggingTool.Hh=this.diagram,this.doSimulatedDragOut()}doSimulatedDragOut(){const t=this.diagram;t.kf=!1,!this.mayCopy()&&!this.mayMove()?t.currentCursor=this.nodropCursor:t.currentCursor="",this.Su=null}computeMove(t,i,e,s){const n=this.diagram;return n!==null?n.computeMove(t,i,this.dragOptions,s):new Point}static vw=new List;static St=null;static Hh=null}ToolManager.prototype.doCancel=function(){DraggingTool.St!==null&&DraggingTool.St.doCancel(),Tool.prototype.doCancel.call(this)};class LinkingBaseTool extends Tool{OS;ES;Al;BS;VS;qh;zS;jh;XS;YS;KS;US;GS;HS;WC;qS;Ll;jS;constructor(){super(),this.OS=100,this.ES=!1,this.Al="pointer",this.BS=new Link({layerName:"Tool"}).add(new Shape({isPanelMain:!0,stroke:"blue"}).theme("stroke","tempLink"),new Shape({toArrow:"Standard",fill:"blue",stroke:"blue"}).theme("fill","tempLink").theme("stroke","tempLink")).ci(),this.qh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.zk}).theme("stroke","tempPort"),this.VS=new Node({selectable:!1,layerName:"Tool"}).add(this.qh).ci(),this.jh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.zk}).theme("stroke","tempPort"),this.zS=new Node({selectable:!1,layerName:"Tool"}).add(this.jh).ci(),this.XS=null,this.YS=null,this.KS=null,this.US=null,this.GS=null,this.HS=!0,this.WC=new GMap,this.qS=null,this.Ll=null,this.jS=null}doStop(){this.diagram.stopAutoScroll(),this.originalLink=null,this.originalFromNode=null,this.originalFromPort=null,this.originalToNode=null,this.originalToPort=null,this.validPortsCache.clear(),this.targetPort=null}get portGravity(){return this.OS}set portGravity(t){Util.t(t,"number",LinkingBaseTool,"portGravity"),t>=0&&(this.OS=t)}get isUnconnectedLinkValid(){return this.ES}set isUnconnectedLinkValid(t){Util.t(t,"boolean",LinkingBaseTool,"isUnconnectedLinkValid"),this.ES=t}get linkingCursor(){return this.Al}set linkingCursor(t){this.Al=t}get temporaryLink(){return this.BS}set temporaryLink(t){Util.s(t,Link,LinkingBaseTool,"temporaryLink"),t.ci(),this.BS=t}get temporaryFromNode(){return this.VS}set temporaryFromNode(t){Util.s(t,Node,LinkingBaseTool,"temporaryFromNode"),t.ci(),this.VS=t,t&&(this.qh=t.port)}get temporaryFromPort(){return this.qh}set temporaryFromPort(t){if(Util.s(t,GraphObject,LinkingBaseTool,"temporaryFromPort"),this.qh!==null){const i=this.qh.panel;if(i!==null){const e=i.D.indexOf(this.qh);i.removeAt(e),i.insertAt(e,t)}}this.qh=t}get temporaryToNode(){return this.zS}set temporaryToNode(t){Util.s(t,Node,LinkingBaseTool,"temporaryToNode"),t.ci(),this.zS=t,t&&(this.jh=t.port)}get temporaryToPort(){return this.jh}set temporaryToPort(t){if(Util.s(t,GraphObject,LinkingBaseTool,"temporaryToPort"),this.jh!==null){const i=this.jh.panel;if(i!==null){const e=i.D.indexOf(this.jh);i.removeAt(e),i.insertAt(e,t)}}this.jh=t}get originalLink(){return this.XS}set originalLink(t){t!==null&&Util.s(t,Link,LinkingBaseTool,"originalLink"),this.XS=t}get originalFromNode(){return this.YS}set originalFromNode(t){t!==null&&Util.s(t,Node,LinkingBaseTool,"originalFromNode"),this.YS=t}get originalFromPort(){return this.KS}set originalFromPort(t){t!==null&&Util.s(t,GraphObject,LinkingBaseTool,"originalFromPort"),this.KS=t}get originalToNode(){return this.US}set originalToNode(t){t!==null&&Util.s(t,Node,LinkingBaseTool,"originalToNode"),this.US=t}get originalToPort(){return this.GS}set originalToPort(t){t!==null&&Util.s(t,GraphObject,LinkingBaseTool,"originalToPort"),this.GS=t}get isForwards(){return this.HS}set isForwards(t){this.HS=t}get validPortsCache(){return this.WC}get targetPort(){return this.qS}set targetPort(t){t!==null&&Util.s(t,GraphObject,LinkingBaseTool,"targetPort"),this.qS=t}copyPortProperties(t,i,e,s,n){if(t===null||i===null||e===null||s===null)return;const o=i.getDocumentScale(),r=Size.a();r.width=i.naturalBounds.width*o,r.height=i.naturalBounds.height*o,s.desiredSize=r,Size.o(r),n?(s.toSpot=i.toSpot,s.toEndSegmentLength=i.toEndSegmentLength):(s.fromSpot=i.fromSpot,s.fromEndSegmentLength=i.fromEndSegmentLength),e.locationSpot=Spot.Center;const l=Point.a();e.location=i.getDocumentPoint(Spot.Center,l),Point.o(l),s.angle=i.getDocumentAngle(),this.portTargeted!==null&&this.portTargeted(t,i,e,s,n)}setNoTargetPortProperties(t,i,e){i!==null&&(i.desiredSize=Size.zk,i.fromSpot=Spot.None,i.toSpot=Spot.None),t!==null&&(t.location=this.diagram.lastInput.documentPoint),this.portTargeted!==null&&this.portTargeted(null,null,t,i,e)}doMouseDown(){this.isActive&&this.doMouseMove()}doMouseMove(){if(this.isActive){const t=this.diagram;if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null&&this.targetPort.part instanceof Node){const i=this.targetPort.part;this.isForwards?this.copyPortProperties(i,this.targetPort,this.temporaryToNode,this.temporaryToPort,!0):this.copyPortProperties(i,this.targetPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else this.isForwards?this.setNoTargetPortProperties(this.temporaryToNode,this.temporaryToPort,!0):this.setNoTargetPortProperties(this.temporaryFromNode,this.temporaryFromPort,!1);(t.allowHorizontalScroll||t.allowVerticalScroll)&&t.doAutoScroll(t.lastInput.viewPoint)}}findValidLinkablePort(t,i){if(t===null)return null;const e=t.part;if(!(e instanceof Node))return null;for(;t!==null;){const s=i?t.toLinkable:t.fromLinkable;if(s===!0&&(t.portId!==null||t instanceof Node)&&(i?this.isValidTo(e,t):this.isValidFrom(e,t)))return t;if(s===!1)return null;t=t.panel}return null}findTargetPort(t){const i=this.diagram,e=i.lastInput.documentPoint;let s=this.portGravity;s<=0&&(s=.1);const n=this,o=i.findObjectsNear(e,s,a=>n.findValidLinkablePort(a,t),null,!0);let r=1/0,l=null;const h=o.iterator;for(;h.next();){const a=h.value,f=a.part;if(!(f instanceof Node))continue;const c=a.getDocumentPoint(Spot.Center,Point.a()),u=e.x-c.x,d=e.y-c.y;Point.o(c);const m=u*u+d*d;if(m=e)return!1}return!0}isValidTo(t,i){if(t===null||i===null)return this.isUnconnectedLinkValid;if(this.diagram.currentTool===this&&(t.layer!==null&&!t.layer.allowLink||i.toLinkable!==!0))return!1;const e=i.toMaxLinks;if(e<1/0){if(this.originalLink!==null&&t===this.originalToNode&&i===this.originalToPort)return!0;let s=i.portId;if(s===null&&(s=""),t.findLinksInto(s).count>=e)return!1}return!0}isInSameNode(t,i){if(t===null||i===null)return!1;if(t===i)return!0;const e=t.part,s=i.part;return e!==null&&e===s}isLinked(t,i){if(t===null||i===null)return!1;const e=t.part;if(!(e instanceof Node))return!1;let s=t.portId;s===null&&(s="");const n=i.part;if(!(n instanceof Node))return!1;let o=i.portId;o===null&&(o="");const r=n.findLinksInto(o);for(;r.next();){const l=r.value;if(l.fromNode===e&&l.fromPortId===s)return!0}return!1}isValidLink(t,i,e,s){if(!this.isValidFrom(t,i)||!this.isValidTo(e,s)||i!==null&&s!==null&&(!(i.fromLinkableSelfNode&&s.toLinkableSelfNode)&&this.isInSameNode(i,s)||!(i.fromLinkableDuplicates&&s.toLinkableDuplicates)&&this.isLinked(i,s))||this.originalLink!==null&&(t!==null&&this.isLabelDependentOnLink(t,this.originalLink)||e!==null&&this.isLabelDependentOnLink(e,this.originalLink))||t!==null&&e!==null&&(t.data===null&&e.data!==null||t.data!==null&&e.data===null)||!this.isValidCycle(t,e,this.originalLink))return!1;let n;return t!==null&&(n=t.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))||e!==null&&(n=e.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))?!1:(n=this.linkValidation,n!==null?n(t,i,e,s,this.originalLink):!0)}isLabelDependentOnLink(t,i){if(t===null)return!1;const e=t.labeledLink;if(e===null)return!1;if(e===i)return!0;const s=new GSet;return s.add(t),this.WS(e,i,s)}WS(t,i,e){if(t===i)return!0;const s=t.fromNode;if(s!==null&&s.isLinkLabel&&(e.add(s),this.WS(s.labeledLink,i,e)))return!0;const n=t.toNode;return!!(n!==null&&n.isLinkLabel&&(e.add(n),this.WS(n.labeledLink,i,e)))}isValidCycle(t,i,e){if(e===void 0&&(e=null),t===null||i===null)return this.isUnconnectedLinkValid;const s=this.diagram;let n=1;if(s&&(s.model.Pf()?n=s.isTreePathToChildren?5:6:n=s.validCycle),n===1)return!0;if(n===5){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=i.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.toNode===i)return!1}return!this.Cu(t,i,e,!0)}else if(n===6){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=t.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.fromNode===t)return!1}return!this.Cu(t,i,e,!0)}else{if(n===2)return!this.hF(t,i,e);if(n===3)return!this.Cu(t,i,e,!1);if(n===4)return!this.aF(t,i,e)}return!0}Cu(t,i,e,s){if(t===i)return!0;if(t===null||i===null)return!1;const n=t.linksConnected;for(;n.next();){const o=n.value;if(o===e||s&&!o.isTreeLink||o.toNode!==t)continue;const r=o.fromNode;if(r!==t&&this.Cu(r,i,e,s))return!0}return!1}hF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.vC(s,t,i,e)}vC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s||o.toNode!==i)continue;const r=o.fromNode;if(r!==i&&this.vC(t,r,e,s))return!0}return!1}aF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.JC(s,t,i,e)}JC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s)continue;const r=o.fromNode,l=o.toNode,h=r===i?l:r;if(h!==i&&this.JC(t,h,e,s))return!0}return!1}get linkValidation(){return this.Ll}set linkValidation(t){t!==null&&Util.t(t,"function",LinkingBaseTool,"linkValidation"),this.Ll=t}get portTargeted(){return this.jS}set portTargeted(t){t!==null&&Util.t(t,"function",LinkingBaseTool,"portTargeted"),this.jS=t}}var LinkingDirection=(w=>(w[w.Either=1]="Either",w[w.ForwardsOnly=2]="ForwardsOnly",w[w.BackwardsOnly=3]="BackwardsOnly",w))(LinkingDirection||{});class LinkingTool extends LinkingBaseTool{vS;JS;C;ZS;constructor(t){super(),this.name="Linking",this.vS={},this.JS=null,this.C=1,this.ZS=null,t&&Object.assign(this,t)}static Either=1;static ForwardsOnly=2;static BackwardsOnly=3;get archetypeLinkData(){return this.vS}set archetypeLinkData(t){t!==null&&Util.t(t,"object",LinkingTool,"archetypeLinkData"),t instanceof GraphObject&&Util.s(t,Link,LinkingTool,"archetypeLinkData"),this.vS=t}get archetypeLabelNodeData(){return this.JS}set archetypeLabelNodeData(t){t!==null&&Util.t(t,"object",LinkingTool,"archetypeLabelNodeData"),t instanceof GraphObject&&Util.s(t,Node,LinkingTool,"archetypeLabelNodeData"),this.JS=t}get direction(){return this.C}set direction(t){Util.tt(t,LinkingDirection,"LinkingDirection"),this.C=t}get startObject(){return this.ZS}set startObject(t){t!==null&&Util.s(t,GraphObject,LinkingTool,"startObject"),this.ZS=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||t.isModelReadOnly||!t.allowLink||!t.model.Jw()||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize()?!1:this.findLinkablePort()!==null}findLinkablePort(){const t=this.diagram;let i=this.startObject;if(i===null&&(i=t.findObjectAt(t.firstInput.documentPoint,null,null)),i===null)return null;const e=i.part;if(!(e instanceof Node))return null;const s=this.direction;if(s===1||s===2){const n=this.findValidLinkablePort(i,!1);if(n!==null)return this.isForwards=!0,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!1))return this.isForwards=!0,o}}if(s===1||s===3){const n=this.findValidLinkablePort(i,!0);if(n!==null)return this.isForwards=!1,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!0))return this.isForwards=!1,o}}return null}doActivate(){const t=this.diagram,i=this.findLinkablePort();if(i===null){this.stopTool();return}if(this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.isForwards){this.temporaryToNode!==null&&(this.temporaryToNode.location=t.lastInput.documentPoint),this.originalFromPort=i;const e=this.originalFromPort.part;e instanceof Node&&(this.originalFromNode=e),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else{this.temporaryFromNode!==null&&(this.temporaryFromNode.location=t.lastInput.documentPoint),this.originalToPort=i;const e=this.originalToPort.part;e instanceof Node&&(this.originalToNode=e),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0)}t.add(this.temporaryFromNode),this.temporaryFromNode&&this.temporaryFromNode.ensureBounds(),t.add(this.temporaryToNode),this.temporaryToNode&&this.temporaryToNode.ensureBounds(),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.temporaryLink.isTreeLink=this.isNewTreeLink(),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.startObject=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=null,e=null,s=null,n=null,o=null;try{this.targetPort=this.findTargetPort(this.isForwards);const r=this.targetPort;if(r!==null){const l=r.part;l instanceof Node&&(this.isForwards?(this.originalFromNode!==null&&(i=this.originalFromNode,e=this.originalFromPort),s=l,n=r):(i=l,e=r,this.originalToNode!==null&&(s=this.originalToNode,n=this.originalToPort)))}else this.isForwards?this.originalFromNode!==null&&this.isUnconnectedLinkValid&&(i=this.originalFromNode,e=this.originalFromPort):this.originalToNode!==null&&this.isUnconnectedLinkValid&&(s=this.originalToNode,n=this.originalToPort);i!==null||s!==null?(o=this.insertLink(i,e,s,n),o!==null?(r===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint),t.allowSelect&&(t.B("ChangingSelection",t.selection),t.clearSelection(!0),o.isSelected=!0),this.transactionResult=this.name,t.B("LinkDrawn",o)):this.doNoLink(i,e,s,n)):this.isForwards?this.doNoLink(this.originalFromNode,this.originalFromPort,null,null):this.doNoLink(null,null,this.originalToNode,this.originalToPort)}finally{this.stopTool(),o&&t.allowSelect&&t.B("ChangedSelection",t.selection)}}}isNewTreeLink(){const t=this.archetypeLinkData;if(t===null)return!0;if(t instanceof Link)return t.isTreeLink;const i=this.diagram;if(i===null)return!0;const e=i.partManager.getLinkCategoryForData(t),s=i.partManager.findLinkTemplateForCategory(e);return s!==null?s.isTreeLink:!0}insertLink(t,i,e,s){return this.diagram.partManager.insertLink(t,i,e,s)}doNoLink(t,i,e,s){}}class RelinkingTool extends LinkingBaseTool{$S;QS;ps;_S;constructor(t){super(),this.name="Relinking",this.$S=new Shape("Diamond",{desiredSize:Size.du,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:0}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.QS=new Shape("Diamond",{desiredSize:Size.du,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:-1}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.ps=null,this._S=new Rect,t&&Object.assign(this,t)}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i="RelinkFrom",e=null;if(t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkFrom()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null&&(e=this.makeAdornment(s,!1),t.addAdornment(i,e)))}if(e===null&&t.removeAdornment(i),i="RelinkTo",e=null,t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkTo()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null?(e=this.makeAdornment(s,!0),t.addAdornment(i,e)):e.u())}e===null&&t.removeAdornment(i)}makeAdornment(t,i){const e=new Adornment;e.type=Panel.Link;const s=i?this.toHandleArchetype:this.fromHandleArchetype;return s!==null&&e.add(s.copy().Cm()),e.adornedObject=t,e}get fromHandleArchetype(){return this.$S}set fromHandleArchetype(t){t!==null&&Util.s(t,GraphObject,RelinkingTool,"fromHandleArchetype"),this.$S=t}get toHandleArchetype(){return this.QS}set toHandleArchetype(t){t!==null&&Util.s(t,GraphObject,RelinkingTool,"toHandleArchetype"),this.QS=t}get handle(){return this.ps}set handle(t){if(t!==null&&(Util.s(t,GraphObject,RelinkingTool,"handle"),!(t.part instanceof Adornment)))throw new Error("new handle is not in an Adornment: "+t);this.ps=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowRelink||!t.model.Jw()||!t.lastInput.left)return!1;let e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom");return e===null&&(e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo")),e!==null}doActivate(){const t=this.diagram;if(this.originalLink===null){let i=this.handle;if(i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom"),i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo"))),i===null)return;const e=i.part;if(!(e instanceof Adornment)||!(e.adornedPart instanceof Link))return;this.handle=i,this.isForwards=e===null||e.category==="RelinkTo",this.originalLink=e.adornedPart}this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.originalFromPort=this.originalLink.fromPort,this.originalFromNode=this.originalLink.fromNode,this.originalToPort=this.originalLink.toPort,this.originalToNode=this.originalLink.toNode,this._S.set(this.originalLink.actualBounds),this.originalLink!==null&&this.originalLink.pointsCount>0&&(this.originalLink.fromNode===null&&(this.temporaryFromPort!==null&&(this.temporaryFromPort.desiredSize=Size.hf),this.temporaryFromNode!==null&&(this.temporaryFromNode.location=this.originalLink.getPoint(0))),this.originalLink.toNode===null&&(this.temporaryToPort!==null&&(this.temporaryToPort.desiredSize=Size.hf),this.temporaryToNode!==null&&(this.temporaryToNode.location=this.originalLink.getPoint(this.originalLink.pointsCount-1)))),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0),t.add(this.temporaryFromNode),t.add(this.temporaryToNode),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.copyLinkProperties(this.originalLink,this.temporaryLink),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}copyLinkProperties(t,i){if(t===null||i===null)return;i.adjusting=t.adjusting,i.corner=t.corner;let e=t.curve;(e===11||e===10)&&(e=0),i.curve=e,i.curviness=t.curviness,i.isTreeLink=t.isTreeLink,i.points=t.points,i.routing=t.routing,i.smoothness=t.smoothness,i.fromSpot=t.fromSpot,i.fromEndSegmentLength=t.fromEndSegmentLength,i.fromShortLength=t.fromShortLength,i.toSpot=t.toSpot,i.toEndSegmentLength=t.toEndSegmentLength,i.toShortLength=t.toShortLength}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.handle=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=this.originalFromNode,e=this.originalFromPort,s=this.originalToNode,n=this.originalToPort,o=this.originalLink;try{if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null){const r=this.targetPort.part;r instanceof Node&&(this.isForwards?(s=r,n=this.targetPort):(i=r,e=this.targetPort))}else this.isUnconnectedLinkValid?this.isForwards?(s=null,n=null):(i=null,e=null):o=null;o!==null?(this.reconnectLink(o,this.isForwards?s:i,this.isForwards?n:e,this.isForwards),this.targetPort===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint,o.invalidateRoute()),this.transactionResult=this.name,t.B("LinkRelinked",o,this.isForwards?this.originalToPort:this.originalFromPort)):this.doNoRelink(this.originalLink,this.isForwards),this.originalLink.invalidateOtherJumpOvers(this._S)}finally{this.stopTool()}}}reconnectLink(t,i,e,s){const n=e!==null&&e.portId!==null?e.portId:"";return s?(t.toNode=i,t.toPortId=n):(t.fromNode=i,t.fromPortId=n),!0}doNoRelink(t,i){}doDraggingMouseMove(t,i,e,s){t!==null?(this.copyPortProperties(t,i,this.temporaryFromNode,this.temporaryFromPort,!1),this.diagram.add(this.temporaryFromNode)):this.diagram.remove(this.temporaryFromNode),e!==null?(this.copyPortProperties(e,s,this.temporaryToNode,this.temporaryToPort,!0),this.diagram.add(this.temporaryToNode)):this.diagram.remove(this.temporaryToNode)}stopDraggingMouseMove(){this.diagram.remove(this.temporaryFromNode),this.diagram.remove(this.temporaryToNode)}}var ReshapingBehavior=(w=>(w[w.None=0]="None",w[w.Horizontal=1]="Horizontal",w[w.Vertical=2]="Vertical",w[w.All=3]="All",w))(ReshapingBehavior||{});class LinkReshapingTool extends Tool{Fo;tM;iM;ps;Zw;eM;Am;constructor(t){super(),this.name="LinkReshaping",this.Fo=new Shape("Rectangle",{desiredSize:Size.lC,fill:"lightblue",stroke:"dodgerblue"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.tM=new Shape("Diamond",{desiredSize:Size.du,fill:"lightblue",stroke:"dodgerblue",cursor:"move"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.iM=3,this.ps=null,this.Zw=null,this.eM=new Point,this.Am=new List,t&&Object.assign(this,t)}static None=0;static Horizontal=1;static Vertical=2;static All=3;getReshapingBehavior(t){return t?t.Mr:0}setReshapingBehavior(t,i){t.Mr=i}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i=null;if(t.isSelected&&!this.diagram.isReadOnly){const e=t.path;e!==null&&t.canReshape()&&t.actualBounds.isReal()&&t.isVisible()&&e.actualBounds.isReal()&&e.isVisibleObject()&&(i=t.findAdornment(this.name),(i===null||i.sM!==t.pointsCount||i.nM!==t.resegmentable)&&(i=this.makeAdornment(e),i!==null&&(i.sM=t.pointsCount,i.nM=t.resegmentable,t.addAdornment(this.name,i))))}i===null&&t.removeAdornment(this.name)}makeAdornment(t){const i=t.part,e=i.points,s=i.pointsCount,n=i.isOrthogonal;let o=null;if(e!==null&&s>1){o=new Adornment,o.type=Panel.Link;const r=i.firstPickIndex,l=i.lastPickIndex,h=n?1:0;if(i.resegmentable&&i.computeCurve()!==9)for(let a=r+h;ae.firstPickIndex+1&&s0))this.fF(t,i);else if(t instanceof Panel){const e=t.elements;for(;e.next();){const s=e.value;this.updateResizeHandles(s,i)}}}}fF(t,i){let e=t.alignment;e.isNoSpot()&&(e=Spot.Center);let s=i;if(e.x<=0)e.y<=0?s+=225:e.y>=1?s+=135:s+=180;else if(e.x>=1)e.y<=0?s+=315:e.y>=1&&(s+=45);else if(e.y<=0)s+=270;else if(e.y>=1)s+=90;else return;s<0?s+=360:s>=360&&(s-=360),s<22.5?t.cursor="e-resize":s<67.5?t.cursor="se-resize":s<112.5?t.cursor="s-resize":s<157.5?t.cursor="sw-resize":s<202.5?t.cursor="w-resize":s<247.5?t.cursor="nw-resize":s<292.5?t.cursor="n-resize":s<337.5?t.cursor="ne-resize":t.cursor="e-resize"}get handleArchetype(){return this.Fo}set handleArchetype(t){t!==null&&Util.s(t,GraphObject,ResizingTool,"handleArchetype"),this.Fo=t}get handle(){return this.ps}set handle(t){if(t!==null&&(Util.s(t,GraphObject,ResizingTool,"handle"),!(t.part instanceof Adornment)))throw new Error("new handle is not in an Adornment: "+t);this.ps=t}get adornedObject(){return this.ys}set adornedObject(t){if(t!==null&&(Util.s(t,GraphObject,ResizingTool,"handle"),t.part instanceof Adornment))throw new Error("new handle must not be in an Adornment: "+t);this.ys=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowResize||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle!==null&&(this.adornedObject=this.handle.part.adornedObject,this.adornedObject!==null&&(t.isMouseCaptured=!0,t.animationManager.stopAnimation(),t.Mu=!0,this.startTransaction(this.name),this.Lm.set(this.adornedObject.getDocumentPoint(this.handle.alignment.opposite())),this.Cf.set(this.adornedObject.part.location),this.rM.set(this.adornedObject.desiredSize),this._w=this.computeCellSize(),this.$w=this.computeMinSize(),this.Qw=this.computeMaxSize(),this.isActive=!0))}doDeactivate(){const t=this.diagram;t.Mu=!1,t.Pl=!0,this.stopTransaction(),this.handle=null,this.ys=null,t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){this.adornedObject!==null&&(this.adornedObject.desiredSize=this.originalDesiredSize,this.adornedObject.part.location=this.originalLocation),this.stopTool()}doMouseMove(){const t=this.diagram;if(!this.isActive)return;const i=this.$w,e=this.Qw,s=this._w,n=t.lastInput.documentPoint,o=this.adornedObject.getLocalPoint(n,Point.a()),r=this.computeReshape(),l=this.computeResize(o,this.handle.alignment,i,e,s,r);this.resize(l),t.maybeUpdate(),Point.o(o)}doMouseUp(){const t=this.diagram;if(this.isActive){const i=this.$w,e=this.Qw,s=this._w,n=this.adornedObject.getLocalPoint(t.lastInput.documentPoint,Point.a()),o=this.computeReshape(),r=this.computeResize(n,this.handle.alignment,i,e,s,o);this.resize(r),Point.o(n),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.B("PartResized",this.adornedObject,this.originalDesiredSize)}this.stopTool()}resize(t){const i=this.diagram,e=this.adornedObject;if(e===null)return;e.desiredSize=t.size;const s=e.part;s.ensureBounds();const n=e.getDocumentPoint(this.handle.alignment.opposite());if(s instanceof Group){const o=new List;o.add(s);let r;!this.dragsMembers&&!s.hasPlaceholder()&&(r=new DraggingOptions,r.dragsMembers=!1),i.moveParts(o,this.oppositePoint.copy().subtract(n),!0,r)}else s.location=s.location.copy().subtract(n).add(this.oppositePoint);i.maybeUpdate()}computeResize(t,i,e,s,n,o){i.isNoSpot()&&(i=Spot.Center);const r=this.adornedObject.naturalBounds,l=r.x,h=r.y,a=r.x+r.width,f=r.y+r.height;let c=1;if(!o){let m=r.width,g=r.height;m<=0&&(m=1),g<=0&&(g=1),c=g/m}const u=Point.a();Geo.Gg(t.x,t.y,l,h,n.width,n.height,u);const d=r.copy();return i.x<=0?i.y<=0?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.y=Math.max(u.y,f-s.height),d.y=Math.min(d.y,f-e.height),d.height=Math.max(f-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width),d.x=a-d.width,d.y=f-d.height)):i.y>=1?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width),d.x=a-d.width)):(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=a-d.x,o||(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c,d.y=h+.5*(f-h-d.height))):i.x>=1?i.y<=0?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.y=Math.max(u.y,f-s.height),d.y=Math.min(d.y,f-e.height),d.height=Math.max(f-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width),d.y=f-d.height)):i.y>=1?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c):(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width))):(d.width=Math.max(Math.min(u.x-l,s.width),e.width),o||(d.height=Math.max(Math.min(c*d.width,s.height),e.height),d.width=d.height/c,d.y=h+.5*(f-h-d.height))):i.y<=0?(d.y=Math.max(u.y,f-s.height),d.y=Math.min(d.y,f-e.height),d.height=f-d.y,o||(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width,d.x=l+.5*(a-l-d.width))):i.y>=1&&(d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.width=Math.max(Math.min(d.height/c,s.width),e.width),d.height=c*d.width,d.x=l+.5*(a-l-d.width))),Point.o(u),d}computeReshape(){let t=0;return this.adornedObject instanceof Shape&&(t=this.adornedObject.lM()),!(t===6||this.diagram.lastInput.shift)}computeMinSize(){const t=this.adornedObject.minSize.copy(),i=this.minSize;return!isNaN(i.width)&&i.width>t.width&&(t.width=i.width),!isNaN(i.height)&&i.height>t.height&&(t.height=i.height),t}computeMaxSize(){const t=this.adornedObject.maxSize.copy(),i=this.maxSize;return!isNaN(i.width)&&i.width0&&(t.width=n.width),!isNaN(n.height)&&n.height>0&&(t.height=n.height)}let e=this.cellSize;isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height);const s=this.diagram;if((isNaN(t.width)||isNaN(t.height))&&s){const n=s.grid;n!==null&&n.visible&&this.isGridSnapEnabled&&(e=n.gridCellSize,isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height))}return(isNaN(t.width)||t.width===0||t.width===1/0)&&(t.width=1),(isNaN(t.height)||t.height===0||t.height===1/0)&&(t.height=1),t}get minSize(){return this.Pr}set minSize(t){if(Util.s(t,Size,ResizingTool,"minSize"),!this.Pr.equals(t)){let e=t.width;isNaN(e)&&(e=0);let s=t.height;isNaN(s)&&(s=0),this.Pr.e(e,s)}}get maxSize(){return this.Nr}set maxSize(t){if(Util.s(t,Size,ResizingTool,"maxSize"),!this.Nr.equals(t)){let e=t.width;isNaN(e)&&(e=1/0);let s=t.height;isNaN(s)&&(s=1/0),this.Nr.e(e,s)}}get cellSize(){return this.Ro}set cellSize(t){Util.s(t,Size,ResizingTool,"cellSize"),this.Ro.equals(t)||this.Ro.c(t)}get isGridSnapEnabled(){return this.Nf}set isGridSnapEnabled(t){Util.t(t,"boolean",ResizingTool,"isGridSnapEnabled"),this.Nf=t}get dragsMembers(){return this.oM}set dragsMembers(t){Util.t(t,"boolean",ResizingTool,"dragsMembers"),this.oM=t}get oppositePoint(){return this.Lm}set oppositePoint(t){Util.s(t,Point,ResizingTool,"oppositePoint"),this.Lm.equals(t)||this.Lm.c(t)}get originalDesiredSize(){return this.rM}get originalLocation(){return this.Cf}}class RotatingTool extends Tool{hM;aM;ys;Fo;ps;fM;Tm;Cf;cM;uM;constructor(t){super(),this.name="Rotating",this.hM=45,this.aM=2,this.Cf=new Point,this.ys=null,this.Fo=new Shape("Ellipse",{desiredSize:Size.du,fill:"lightblue",stroke:"dodgerblue",strokeWidth:1,cursor:"pointer"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.ps=null,this.fM=0,this.Tm=new Point(NaN,NaN),this.cM=0,this.uM=50,t&&Object.assign(this,t)}updateAdornments(t){if(t!==null){if(t.Dl()){const i=t.rotateObject;if(i===t||i===t.path||i.isPanelMain)return}if(t.isSelected&&!this.diagram.isReadOnly){const i=t.rotateObject;if(i!==null&&t.canRotate()&&t.actualBounds.isReal()&&t.isVisible()&&i.actualBounds.isReal()&&i.isVisibleObject()){let e=t.findAdornment(this.name);if((e===null||e.adornedObject!==i)&&(e=this.makeAdornment(i)),e!==null){e.angle=i.getDocumentAngle(),e.hasPlaceholder()||(e.location=this.computeAdornmentLocation(i)),t.addAdornment(this.name,e);return}}}t.removeAdornment(this.name)}}makeAdornment(t){let i=null;const e=t.part.rotateAdornmentTemplate;if(e===null){i=new Adornment,i.type=Panel.Position,i.locationSpot=Spot.Center;const s=this.handleArchetype;s!==null&&i.add(s.copy().Cm())}else if(e.ci(),i=e.copy(),i===null)return null;return i.adornedObject=t,i}get handleArchetype(){return this.Fo}set handleArchetype(t){t!==null&&Util.s(t,GraphObject,RotatingTool,"handleArchetype"),this.Fo=t}get handle(){return this.ps}set handle(t){if(t!==null&&(Util.s(t,GraphObject,RotatingTool,"handle"),!(t.part instanceof Adornment)))throw new Error("new handle is not in an Adornment: "+t);this.ps=t}get adornedObject(){return this.ys}set adornedObject(t){if(t!==null&&(Util.s(t,GraphObject,RotatingTool,"handle"),t.part instanceof Adornment))throw new Error("new handle must not be in an Adornment: "+t);this.ys=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowRotate||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;if(this.adornedObject===null){if(this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle===null)return;this.adornedObject=this.handle.part.adornedObject}this.adornedObject!==null&&(t.isMouseCaptured=!0,t.delaysLayout=!0,this.startTransaction(this.name),this.fM=this.adornedObject.angle,this.Tm=this.computeRotationPoint(this.adornedObject),this.Cf=this.adornedObject.part.location.copy(),this.isActive=!0)}computeRotationPoint(t){const i=t.part,e=i.locationObject;return i.rotationSpot.isSpot()?t.getDocumentPoint(i.rotationSpot):t===i||t===e?e.getDocumentPoint(i.locationSpot):t.getDocumentPoint(Spot.Center)}computeAdornmentLocation(t){let i=this.rotationPoint;i.isReal()||(i=this.computeRotationPoint(t));const e=t.getLocalPoint(i);let s=this.handleAngle;s<0?s+=360:s>=360&&(s-=360),s=Math.round(Math.round(s/45)*45);const n=this.handleDistance;return s===0?e.x=t.naturalBounds.width+n:s===45?(e.x=t.naturalBounds.width+n,e.y=t.naturalBounds.height+n):s===90?e.y=t.naturalBounds.height+n:s===135?(e.x=-n,e.y=t.naturalBounds.height+n):s===180?e.x=-n:s===225?(e.x=-n,e.y=-n):s===270?e.y=-n:s===315&&(e.x=t.naturalBounds.width+n,e.y=-n),t.getDocumentPoint(e)}doDeactivate(){const t=this.diagram;this.stopTransaction(),this.handle=null,this.ys=null,this.Tm=new Point(NaN,NaN),t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){const t=this.diagram;t.delaysLayout=!1,this.rotate(this.originalAngle),this.stopTool()}doMouseMove(){const t=this.diagram;if(this.isActive){const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i)}}doMouseUp(){const t=this.diagram;if(this.isActive){t.delaysLayout=!1;const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.B("PartRotated",this.adornedObject,this.originalAngle)}this.stopTool()}rotate(t){Debug&&Util.r(t,RotatingTool,"rotate:newangle");const i=this.adornedObject;if(i===null)return;i.angle=t;const e=i.part;e.ensureBounds();const s=e.locationObject,n=e.rotateObject;if(s===n||s.isContainedBy(n)){const o=this.Cf.copy();e.location=o.subtract(this.rotationPoint).rotate(t-this.originalAngle).add(this.rotationPoint)}this.diagram.maybeUpdate()}computeRotate(t){let i=this.rotationPoint.directionPoint(t)-this.handleAngle;const e=this.adornedObject.panel;e!==null&&(i-=e.getDocumentAngle()),i>=360?i-=360:i<0&&(i+=360);const s=Math.min(Math.abs(this.snapAngleMultiple),180),n=Math.min(Math.abs(this.snapAngleEpsilon),s/2);return!this.diagram.lastInput.shift&&s>0&&n>0&&(i%ss-n&&(i=(Math.floor(i/s)+1)*s)),i>=360?i-=360:i<0&&(i+=360),i}get snapAngleMultiple(){return this.hM}set snapAngleMultiple(t){Util.t(t,"number",RotatingTool,"snapAngleMultiple"),this.hM=t}get snapAngleEpsilon(){return this.aM}set snapAngleEpsilon(t){Util.t(t,"number",RotatingTool,"snapAngleEpsilon"),this.aM=t}get originalAngle(){return this.fM}get rotationPoint(){return this.Tm}set rotationPoint(t){this.Tm=t.copy()}get handleAngle(){return this.cM}set handleAngle(t){Util.t(t,"number",RotatingTool,"handleAngle"),this.cM=t}get handleDistance(){return this.uM}set handleDistance(t){Util.t(t,"number",RotatingTool,"handleDistance"),this.uM=t}}class ClickSelectingTool extends Tool{constructor(t){super(),this.name="ClickSelecting",t&&Object.assign(this,t)}canStart(){return!(!this.isEnabled||this.isBeyondDragSize())}doMouseUp(){this.isActive&&(this.standardMouseSelect(),this.standardMouseClick()||this.diagram.lastInput.isTouchEvent&&this.diagram.toolManager.doToolTip()),this.stopTool()}}class ActionTool extends Tool{Af;constructor(t){super(),this.name="Action",this.Af=null,t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram,i=t.lastInput,e=t.findObjectAt(i.documentPoint,s=>{for(;s.panel!==null;){if(s.isActionable)return s;s=s.panel}return s});return e!==null&&e.isActionable?(this.Af=e,t.xf=t.findObjectAt(i.documentPoint,null,null),!0):!1}doMouseDown(){if(!this.isActive)this.canStart()&&this.doActivate();else{const i=this.diagram.lastInput,e=this.Af;if(e===null)return;i.targetObject=e,e.actionDown!==null&&e.actionDown(i,e)}}doMouseMove(){if(this.isActive){const i=this.diagram.lastInput,e=this.Af;if(e===null)return;i.targetObject=e,e.actionMove!==null&&e.actionMove(i,e)}}doMouseUp(){if(this.isActive){const i=this.diagram.lastInput,e=this.Af;if(e===null)return;i.targetObject=e,e.actionUp!==null&&e.actionUp(i,e),this.standardMouseClick(s=>{for(;s.panel!==null;){if(s.isActionable&&s===e)return s;s=s.panel}return s},s=>s===e)}this.stopTool()}doCancel(){const i=this.diagram.lastInput,e=this.Af;e!==null&&(i.targetObject=e,e.actionCancel!==null&&e.actionCancel(i,e),this.stopTool())}doStop(){this.Af=null}}class ClickCreatingTool extends Tool{Fl;dM;Nf;gM;constructor(t){super(),this.name="ClickCreating",this.Fl=null,this.dM=!0,this.Nf=!1,this.gM=new Point(0,0),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled||this.archetypeNodeData===null)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.lastInput.left||this.isBeyondDragSize())return!1;if(this.isDoubleClick){if(t.lastInput.clickCount===1&&(this.gM=t.lastInput.viewPoint.copy()),t.lastInput.clickCount!==2||this.isBeyondDragSize(this.gM))return!1}else if(t.lastInput.clickCount!==1)return!1;return!(t.currentTool!==this&&t.findPartAt(t.lastInput.documentPoint,!0)!==null)}doMouseUp(){const t=this.diagram;this.isActive&&this.insertPart(t.lastInput.documentPoint),this.stopTool()}insertPart(t){const i=this.diagram,e=this.archetypeNodeData;if(e===null)return null;let s=null;try{if(i.B("ChangingSelection",i.selection),this.startTransaction(this.name),e instanceof Part)e.Ae()&&(e.ci(),s=e.copy(),s!==null&&i.add(s));else if(e!==null){const n=i.model.copyNodeData(e);Util.Mt(n)&&(i.model.addNodeData(n),s=i.findPartForData(n))}if(s!==null){const n=Point.H(t.x,t.y);this.isGridSnapEnabled&&this.diagram.mM(s,t,n),s.location=n,i.allowSelect&&(i.clearSelection(!0),s.isSelected=!0),Point.o(n)}i.invalidateDocumentBounds(),this.transactionResult=this.name,i.B("PartCreated",s)}finally{this.stopTransaction(),i.B("ChangedSelection",i.selection)}return s}get archetypeNodeData(){return this.Fl}set archetypeNodeData(t){t!==null&&Util.t(t,"object",ClickCreatingTool,"archetypeNodeData"),this.Fl=t}get isDoubleClick(){return this.dM}set isDoubleClick(t){Util.t(t,"boolean",ClickCreatingTool,"isDoubleClick"),this.dM=t}get isGridSnapEnabled(){return this.Nf}set isGridSnapEnabled(t){Util.t(t,"boolean",ClickCreatingTool,"isGridSnapEnabled"),this.Nf=t}}class DragSelectingTool extends Tool{Gh;pM;Rl;constructor(t){super(),this.name="DragSelecting",this.Gh=175,this.pM=!1,this.Rl=new Part({layerName:"Tool",selectable:!1}).add(new Shape("Rectangle",{name:"SHAPE",fill:null,stroke:"magenta"}).theme("stroke","dragSelect")).ci(),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(!t.allowSelect)return!1;const i=t.lastInput;return!(!i.left||t.currentTool!==this&&(!this.isBeyondDragSize()||i.timestamp-t.firstInput.timestamp{const e=i.diagram;e!==null&&e.Li(root.document,"scroll",i.yM,!1),i.stopTool()},t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return!(!t.allowHorizontalScroll&&!t.allowVerticalScroll||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize())}doActivate(){const t=this.diagram;this.Do?(t.lastInput.bubbles=!0,t.Ht(root.document,"scroll",this.yM,!1)):(t.currentCursor="move",t.isMouseCaptured=!0,this.tx.c(t.position)),this.isActive=!0}doDeactivate(){const t=this.diagram;t.currentCursor="",t.isMouseCaptured=!1,this.isActive=!1}doCancel(){const t=this.diagram;t.position=this.tx,t.isMouseCaptured=!1,this.stopTool()}doMouseMove(){this.$C()}doMouseUp(){this.$C(),this.stopTool()}$C(){const t=this.diagram;if(this.isActive&&t){if(this.Do){t.lastInput.bubbles=!0;return}const i=t.position,e=t.firstInput.documentPoint,s=t.lastInput.documentPoint;let n=i.x+e.x-s.x,o=i.y+e.y-s.y;t.allowHorizontalScroll||(n=i.x),t.allowVerticalScroll||(o=i.y),t.position=this.ZC.e(n,o)}}get bubbles(){return this.Do}set bubbles(t){Util.t(t,"boolean",PanningTool,"bubbles"),this.Do=t}get originalPosition(){return this.tx}}class HTMLInfo{ix;ex;wM;xM;constructor(t){this.ix=null,this.ex=null,this.wM=null,this.xM=null,t&&Object.assign(this,t)}get mainElement(){return this.wM}set mainElement(t){t!==null&&Util.s(t,HTMLElement,HTMLInfo,"mainElement"),this.wM=t}get show(){return this.ix}set show(t){this.ix!==t&&(t!==null&&Util.t(t,"function",HTMLInfo,"show"),this.ix=t)}get hide(){return this.ex}set hide(t){this.ex!==t&&(t!==null&&Util.t(t,"function",HTMLInfo,"hide"),this.ex=t)}get valueFunction(){return this.xM}set valueFunction(t){this.xM=t}}class ContextMenuButtonInfo{ui;Dm;Tf;constructor(t,i,e){this.ui=t,this.Dm=i,this.Tf=e}}class ContextMenuTool extends Tool{bM;sx;kM;SM;nx;ox;Fm;constructor(t){super(),this.name="ContextMenu",this.bM=null,this.sx=null,this.kM=null,this.SM=new Point,this.nx=null,this.Fm=!1;const i=this;this.ox=()=>i.stopTool(),t&&Object.assign(this,t)}cF(){const t=new HTMLInfo;t.show=(r,l,h)=>h.showDefaultContextMenu(),t.hide=(r,l)=>l.hideDefaultContextMenu(),ContextMenuTool.Au=t;const i=this;this.ox=()=>i.stopTool();const e=Util.ln("div"),s=Util.ln("div");e.style.cssText="top: 0px;z-index:10002;position: fixed;display: none;text-align: center;left: 25%;width: 50%;background-color: #F5F5F5;padding: 16px;border: 16px solid #444;border-radius: 10px;margin-top: 10px",s.style.cssText="z-index:10001;position: fixed;display: none;top: 0;left: 0;width: 100%;height: 100%;background-color: black;opacity: 0.8;";const n=Util.ln("style");root.document.getElementsByTagName("head")[0].appendChild(n),n.sheet.insertRule(".goCXul { list-style: none; }",0),n.sheet.insertRule(".goCXli {font:700 1.5em Helvetica, Arial, sans-serif;position: relative;min-width: 60px; }",0),n.sheet.insertRule(".goCXa {color: #444;display: inline-block;padding: 4px;text-decoration: none;margin: 2px;border: 1px solid gray;border-radius: 10px; }",0);const o=this.diagram;o!==null&&(o.Ht(e,"contextmenu",ContextMenuTool.Wh,!1),o.Ht(e,"selectstart",ContextMenuTool.Wh,!1),o.Ht(s,"contextmenu",ContextMenuTool.Wh,!1)),e.className="goCXforeground",s.className="goCXbackground",root.document.body&&(root.document.body.appendChild(e),root.document.body.appendChild(s)),ContextMenuTool.Rm=e,ContextMenuTool.Im=s,ContextMenuTool.MM=!0}static Au=null;static MM=!1;static Im=null;static Rm=null;static Wh(t){return t.preventDefault(),!1}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return this.isBeyondDragSize()||!t.lastInput.right||t.lastInput.clickCount>1?!1:!!(t.lastInput.isTouchEvent&&this.defaultTouchContextMenu!==null||this.findObjectWithContextMenu()!==null)}doStart(){const t=this.diagram;this.SM.set(t.firstInput.documentPoint)}doStop(){this.hideContextMenu(),this.currentObject=null,this.Fm=!1}findObjectWithContextMenu(t){t===void 0&&(t=null);const i=this.diagram,e=i.lastInput;let s=null;if(t instanceof Diagram||(t instanceof GraphObject?s=t:s=i.findObjectAt(e.documentPoint,null,n=>!n.layer.isTemporary)),s!==null){let n=s;for(;n!==null;){if(n.contextMenu!==null)return n;n=n.panel}if(i.lastInput.isTouchEvent&&this.defaultTouchContextMenu)return s.part}else if(i.contextMenu!==null)return i;return null}doActivate(){}doMouseDown(){if(super.doMouseDown(),this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doMouseDown(),t.doDeactivate())}this.diagram.toolManager.mouseDownTools.has(this)&&this.doContextClick()}doMouseUp(){if(this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doCancel(),t.doDeactivate())}this.doContextClick()}doContextClick(){const t=this.diagram;if(!this.isActive)this.canStart()&&(this.openMenu(!0),this.isActive||this.stopTool());else{const i=this.currentContextMenu;if(i===null)return;let e=null;i instanceof HTMLInfo||(e=t.findObjectAt(t.lastInput.documentPoint,null,null),e!==null&&e.isContainedBy(i)&&this.standardMouseClick(null,null)),this.maybeStopTool(e)}}maybeStopTool(t){this.stopTool(),this.canStart()&&(this.diagram.currentTool=this,this.doMouseUp())}openMenu(t,i){if(i===void 0&&(i=null),this.Fm)return;this.Fm=!0,t&&this.standardMouseSelect();const e=this.standardMouseClick();if(this.Fm=!1,!e){this.isActive=!0;const s=ContextMenuTool.Au;if(i===null&&(i=this.findObjectWithContextMenu()),i!==null){const n=i.contextMenu;n!==null?(this.currentObject=i instanceof GraphObject?i:null,this.showContextMenu(n,this.currentObject)):s!==null&&this.showContextMenu(s,this.currentObject)}else s!==null&&this.showContextMenu(s,null);this.currentContextMenu instanceof Adornment&&!this.currentContextMenu.visible&&this.stopTool()}}doMouseMove(){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.doMouseMove(),this.isActive&&this.diagram.toolManager.doMouseMove()}showContextMenu(t,i){Debug&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("showContextMenu:contextMenu must be an Adornment or HTMLInfo."),i!==null&&Util.s(i,GraphObject,ContextMenuTool,"showContextMenu:obj");const e=this.diagram;if(t!==this.currentContextMenu&&this.hideContextMenu(),t instanceof Adornment){const s=t;s.layerName="Tool",s.selectable=!1,s.scale=1/e.scale,s.category=this.name,s.hasPlaceholder()&&(s.placeholder.scale=e.scale);const n=s.diagram;n!==null&&n!==e&&n.remove(s),e.add(s),i!==null?s.adornedObject=i:s.data=e.model,s.ensureBounds(),this.positionContextMenu(s,i)}else t instanceof HTMLInfo&&t.show(i,e,this);this.currentContextMenu=t}positionContextMenu(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom&&(n.y-=o.height+5/s.scale),n.ye.commandHandler.copySelection(),e=>e.commandHandler.canCopySelection())),i.add(new ContextMenuButtonInfo("Cut",e=>e.commandHandler.cutSelection(),e=>e.commandHandler.canCutSelection())),i.add(new ContextMenuButtonInfo("Delete",e=>e.commandHandler.deleteSelection(),e=>e.commandHandler.canDeleteSelection())),i.add(new ContextMenuButtonInfo("Paste",e=>e.commandHandler.pasteSelection(t.mouseDownPoint),e=>e.commandHandler.canPasteSelection(t.mouseDownPoint))),i.add(new ContextMenuButtonInfo("Select All",e=>e.commandHandler.selectAll(),e=>e.commandHandler.canSelectAll())),i.add(new ContextMenuButtonInfo("Undo",e=>e.commandHandler.undo(),e=>e.commandHandler.canUndo())),i.add(new ContextMenuButtonInfo("Redo",e=>e.commandHandler.redo(),e=>e.commandHandler.canRedo())),i.add(new ContextMenuButtonInfo("Scroll To Part",e=>e.commandHandler.scrollToPart(),e=>e.commandHandler.canScrollToPart())),i.add(new ContextMenuButtonInfo("Zoom To Fit",e=>e.commandHandler.zoomToFit(),e=>e.commandHandler.canZoomToFit())),i.add(new ContextMenuButtonInfo("Reset Zoom",e=>e.commandHandler.resetZoom(),e=>e.commandHandler.canResetZoom())),i.add(new ContextMenuButtonInfo("Group Selection",e=>e.commandHandler.groupSelection(),e=>e.commandHandler.canGroupSelection())),i.add(new ContextMenuButtonInfo("Ungroup Selection",e=>e.commandHandler.ungroupSelection(),e=>e.commandHandler.canUngroupSelection())),i.add(new ContextMenuButtonInfo("Edit Text",e=>e.commandHandler.editTextBlock(),e=>e.commandHandler.canEditTextBlock())),i}showDefaultContextMenu(){const t=this.diagram;this.nx===null&&(this.nx=this.uF()),ContextMenuTool.Rm.innerHTML="",ContextMenuTool.Im.addEventListener("pointerdown",this.ox,!1);const i=this,e=Util.ln("ul");e.className="goCXul",ContextMenuTool.Rm.appendChild(e),e.innerHTML="";const s=this.nx.iterator;for(;s.next();){const n=s.value,o=n.Dm,r=n.Tf;if(typeof o!="function"||typeof r=="function"&&!r(t))continue;const l=Util.ln("li");l.className="goCXli";const h=Util.ln("a");h.className="goCXa",h.href="#",h.Dm=n.Dm,h.addEventListener("pointerdown",function(a){return this.Dm(t),i.stopTool(),a.preventDefault(),!1},!1),h.textContent=n.ui,l.appendChild(h),e.appendChild(l)}ContextMenuTool.Rm.style.display="block",ContextMenuTool.Im.style.display="block"}hideDefaultContextMenu(){if(this.currentContextMenu===null||this.currentContextMenu!==ContextMenuTool.Au)return;ContextMenuTool.Rm.style.display="none",ContextMenuTool.Im.style.display="none";const t=this.diagram;t!==null&&t.Li(ContextMenuTool.Im,"pointerdown",this.ox,!1),this.currentContextMenu=null}get currentContextMenu(){return this.bM}set currentContextMenu(t){Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("ContextMenuTool.currentContextMenu must be an Adornment or HTMLInfo."),this.bM=t,this.sx=t instanceof Adornment?t.adornedPart:null}get defaultTouchContextMenu(){return ContextMenuTool.MM===!1&&ContextMenuTool.Au===null&&Diagram.isUsingDOM()&&this.cF(),ContextMenuTool.Au}set defaultTouchContextMenu(t){Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("ContextMenuTool.defaultTouchContextMenu must be an Adornment or HTMLInfo."),t===null&&(ContextMenuTool.MM=!0),ContextMenuTool.Au=t}get currentObject(){return this.kM}set currentObject(t){t!==null&&Util.s(t,GraphObject,ContextMenuTool,"currentObject"),this.kM=t}get mouseDownPoint(){return this.SM}}var TextEditingAccept=(w=>(w[w.LostFocus=1]="LostFocus",w[w.MouseDown=2]="MouseDown",w[w.Tab=3]="Tab",w[w.Enter=4]="Enter",w))(TextEditingAccept||{}),TextEditingStarting=(w=>(w[w.SingleClick=1]="SingleClick",w[w.SingleClickSelected=2]="SingleClickSelected",w[w.DoubleClick=3]="DoubleClick",w))(TextEditingStarting||{}),TextEditingState=(w=>(w[w.None=1]="None",w[w.Active=2]="Active",w[w.Editing=3]="Editing",w[w.Validating=4]="Validating",w[w.Invalid=5]="Invalid",w[w.Validated=6]="Validated",w))(TextEditingState||{});class TextEditingTool extends Tool{Le;PM;NM;Il;vt;CM;AM;LM;rx;lx;constructor(t){super(),this.name="TextEditing",this.Le=new TextBlock,this.PM=null,this.NM=2,this.Il=null,this.vt=1,this.CM=1,this.AM=!0,this.LM=null,this.rx=new HTMLInfo,this.lx=null,this.dF(this.rx),t&&Object.assign(this,t)}static LostFocus=1;static MouseDown=2;static Tab=3;static Enter=4;static SingleClick=1;static SingleClickSelected=2;static DoubleClick=3;static StateNone=1;static StateActive=2;static StateEditing=3;static StateValidating=4;static StateInvalid=5;static StateValidated=6;dF(t){if(!Diagram.isUsingDOM())return;const i=Util.ln("textarea");this.lx=i;const e=this;i.addEventListener("input",function(s){if(e.textBlock===null)return;const n=e.measureTemporaryTextBlock(this.value),o=this.textScale;this.style.width=20+Math.max(e.textBlock.measuredBounds.width,n.measuredBounds.width)*o+"px",this.rows=Math.max(e.textBlock.lineCount,n.lineCount)},!1),i.addEventListener("keydown",function(s){if(s.isComposing||e.textBlock===null)return;const n=s.key;if(n==="Enter"){e.textBlock.isMultiline===!1&&s.preventDefault(),e.acceptText(4);return}else if(n==="Tab"){e.acceptText(3),s.preventDefault();return}else n==="Escape"&&(e.doCancel(),e.diagram!==null&&e.diagram.doFocus())},!1),i.addEventListener("focus",function(s){e.gF(s)},!1),i.addEventListener("blur",function(s){e.mF(s)},!1),t.valueFunction=()=>i.value,t.mainElement=i,t.show=(s,n,o)=>{if(!(s instanceof TextBlock&&o instanceof TextEditingTool))return;if(o.state===5){i.style.border="3px solid red",i.focus();return}const r=s.getDocumentPoint(Spot.Center),l=n.position,h=n.scale;let a=s.getDocumentScale()*h;a{s.div.removeChild(i)}}get textBlock(){return this.PM}set textBlock(t){t!==null&&Util.s(t,TextBlock,TextEditingTool,"textBlock"),this.PM=t}get currentTextEditor(){return this.LM}set currentTextEditor(t){this.LM=t}get defaultTextEditor(){return this.rx}set defaultTextEditor(t){Debug&&!(t instanceof HTMLInfo)&&Util.n("TextEditingTool.defaultTextEditor must be an HTMLInfo."),this.rx=t}get starting(){return this.NM}set starting(t){Util.tt(t,TextEditingStarting,"TextEditingStarting"),this.NM=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t===null||t.isReadOnly||TextEditingTool.Df&&TextEditingTool.Df!==this&&(TextEditingTool.Df.acceptText(2),TextEditingTool.Df&&TextEditingTool.Df!==this)||!t.lastInput.left||this.isBeyondDragSize())return!1;const i=t.lastInput.documentPoint,e=t.findObjectAt(i);if(e===null||!(e instanceof TextBlock)||!e.editable||!e.part.canEdit())return!1;const s=e.part;return!(s===null||this.starting===2&&!s.isSelected||this.starting===3&&t.lastInput.clickCount<2)}doStart(){TextEditingTool.Df=this,this.textBlock!==null&&this.doActivate()}doActivate(){if(this.isActive)return;const t=this.diagram;if(t===null)return;let i=this.textBlock;if(i===null&&(i=t.findObjectAt(t.lastInput.documentPoint)),i===null||!(i instanceof TextBlock)||(this.textBlock=i,i.part===null))return;t.animationManager.stopAnimation(),this.isActive=!0,this.vt=2;let s=this.defaultTextEditor;i.textEditor!==null&&(s=i.textEditor),this.Le=this.textBlock.copy();const n=new Rect(this.textBlock.getDocumentPoint(Spot.TopLeft),this.textBlock.getDocumentPoint(Spot.BottomRight));t.scrollToRect(n),s.show(i,t,this),this.currentTextEditor=s}doCancel(){this.stopTool()}doMouseUp(){this.canStart()&&this.doActivate()}doMouseDown(){this.isActive&&this.acceptText(2)}acceptText(t){switch(t){case 2:this.vt===6?this.currentTextEditor instanceof HTMLElement&&this.currentTextEditor.focus():(this.vt===2||this.vt===5||this.vt===3)&&(this.vt=4,this.QC());break;case 1:case 4:case 3:if(t===4&&this.textBlock.isMultiline===!0)return;(this.vt===2||this.vt===5||this.vt===3)&&(this.vt=4,this.QC());break}}QC(){const t=this.textBlock,i=this.diagram,e=this.currentTextEditor;if(t!==null&&e!==null){const s=t.text;let n="";if(e.valueFunction!==null&&(n=e.valueFunction()),!this.isValidText(t,s,n)){this.vt=5,this.doError(s,n);return}this.startTransaction(this.name),this.vt=6,this.transactionResult=this.name,t.text=n,this.doSuccess(s,n),i!==null&&i.B("TextEdited",t,s),this.stopTransaction(),this.stopTool(),i!==null&&i.doFocus()}}doError(t,i){const e=this.textBlock;e.errorFunction!==null&&e.errorFunction(this,t,i);const s=this.currentTextEditor;s&&s.show(e,this.diagram,this)}doSuccess(t,i){const e=this.textBlock;e.textEdited!==null&&e.textEdited(e,t,i)}doDeactivate(){const t=this.diagram;t!==null&&(this.vt=1,this.currentTextEditor!==null&&this.currentTextEditor.hide(t,this),this.textBlock=null,this.isActive=!1)}doStop(){TextEditingTool.Df=null}gF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this.lx;this.vt===2&&(this.vt=3),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}mF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this.lx;typeof i.focus=="function"&&i.focus(),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}isValidText(t,i,e){Util.s(t,TextBlock,TextEditingTool,"isValidText:textblock");const s=this.textValidation;if(s!==null&&!s(t,i,e))return!1;const n=t.textValidation;return!(n!==null&&!n(t,i,e))}get textValidation(){return this.Il}set textValidation(t){t!==null&&Util.t(t,"function",TextEditingTool,"textValidation"),this.Il=t}get minimumEditorScale(){return this.CM}set minimumEditorScale(t){t!==null&&Util.t(t,"number",TextEditingTool,"minimumEditorScale"),this.CM=t}get selectsTextOnActivate(){return this.AM}set selectsTextOnActivate(t){t!==null&&Util.t(t,"boolean",TextEditingTool,"selectsTextOnActivate"),this.AM=t}get state(){return this.vt}set state(t){this.vt!==t&&(Util.tt(t,TextEditingState,"TextEditingState"),this.vt=t)}measureTemporaryTextBlock(t){const i=this.Le;return i.text=t,i.wt(this.textBlock.Ol,1/0),i}static Df=null}var AnimationStyle=(w=>(w[w.Default=1]="Default",w[w.AnimateLocations=2]="AnimateLocations",w[w.None=3]="None",w))(AnimationStyle||{});class AnimationManager{b;Ti;Xi;Cr;Zn;Io;TM;DM;Om;Si;Ff;yn;Em;vh;hx;Bm;ax;Rf;Nu;Vm;constructor(t){this.b=Diagram.Sm(),this.Ti=!1,this.Om=!1,this.Si=!1,this.Ff=!1,this.ax=!0,this.Rf=1,this.Nu=!1,this.Xi=!0,this.Cr=!0,this.Io=600,this.TM=!1,this.DM=!1,this.Zn=new GSet,this.yn=new Animation,this.Em=new Animation,this.yn.ws=this,this.vh=new GSet,this.hx=new GSet,this.Bm=new GSet,this.Vm=new GSet,t&&Object.assign(this,t)}Oo(t){this.b=t}hE(){return this.b}canStart(t){return!0}El(t){return!this.Xi||!this.canStart(t)?!1:(this.Zn.add(t),this.defaultAnimation.isAnimating&&this.stopAnimation(),this.b.Di(),this.Si=!0,!0)}getBundleAnimation(){return this.Em}FM(){if(!this.Xi||(this.Em.me.count>0&&this.Em.start(),!this.Si))return;const t=this.yn,i=this.b,e=this.Zn.has("Model");if(e&&(this.Ff=!0,this.Rf===1?(t.isViewportUnconstrained=!0,t.me.clear(),t.add(i,"position",i.position.copy().offset(0,-200),i.position),t.add(i,"opacity",0,1)):this.Rf===3&&t.me.clear(),this.Rf===2&&i.fx.equals(i.gt)?this.ax=!0:this.ax=!1,i.B("InitialAnimationStarting",this)),e&&!this.Cr||t.me.count===0){this.Zn.clear(),this.Si=!1,t.me.clear(),t.cx(i),this.Ff=!1,i.T();return}this.Zn.clear(),i.Ar=!1;const s=t.me.get(i);i.autoScale!==1&&s!==null&&(delete s.li.scale,delete s.xs.scale);const n=this;root.requestAnimationFrame(()=>{n.Si===!1||t.Ti||(i.getRenderingHint("temporaryPixelRatio")&&i.jw(),i.RM(),n.Si=!1,t.start(),t.Ti&&(n.Lu(),i.invalidateDocumentBounds(),t._C(0),i.Sr(!0),n.Tu(),i.B("AnimationStarting",n)))})}IM(){return this.Zn.has("Trigger")&&this.Zn.count===1}tA(t,i,e,s){this.isTicking||this.IM()||t instanceof Link&&(t.fromNode!==null||t.toNode!==null)||this.yn.add(t,"position",i,e,s)}ux(t){return this.yn.ux(t)}OM(t){return this.yn.OM(t)}pF(t){const i=this.vh,e=this;function s(){if(e.Bm.count>0&&(i.addAll(e.Bm),e.Bm.clear(),e.Ti=!0),e.Ti===!1||i.count===0)return;e.hx.addAll(i);const n=e.hx.iterator;for(;n.next();){const o=n.value;o.Ti!==!1&&(o.yF()?o.iA(!1):o.If=!0)}if(e.hx.clear(),e.Ti===!1){root.requestAnimationFrame(s);return}e.Lu(),e.b.Sr(),e.Tu(),root.requestAnimationFrame(s)}this.Ti?this.wF(t):(this.Ti=!0,i.add(t),root.requestAnimationFrame(()=>s()))}wF(t){this.Bm.add(t)}xF(){const t=this.vh.iterator;for(;t.next();)t.value.If=!1}Lu(){if(this.Om)return;const t=this.b;this.TM=t.skipsUndoManager,this.DM=t.pe,t.skipsUndoManager=!0,t.pe=!0,this.Om=!0}Tu(){const t=this.b;t.skipsUndoManager=this.TM,t.pe=this.DM,this.Om=!1}stopAnimation(t){const i=this.yn;if(this.Si===!0&&(this.Si=!1,this.Ff=!1,this.Zn.clear(),i.bF()&&this.b.requestUpdate()),!this.Ti){i.me.clear(),i.cx(this.b);return}if(i.Du(!0),i.cx(null),t===!0){const e=this.vh.toArray();for(let s=0;s{!i.isAnimating&&i.runCount===1/0&&i.start()})}get duration(){return this.Io}set duration(t){Util.t(t,"number",AnimationManager,"duration"),t<1&&Util.G(t,">= 1",AnimationManager,"duration"),this.Io=t}get isAnimating(){return this.Ti}get isTicking(){return this.Om}get isInitial(){return this.Cr}set isInitial(t){Util.t(t,"boolean",AnimationManager,"isInitial"),this.Cr=t}get defaultAnimation(){return this.yn}get activeAnimations(){return this.vh}get initialAnimationStyle(){return this.Rf}set initialAnimationStyle(t){Debug&&Util.tt(t,AnimationStyle,"AnimationStyle"),this.Rf=t}static gx=new GMap;static defineAnimationEffect(t,i){AnimationManager.gx.set(t,i)}static VM(t,i,e,s,n){t===null&&(t=[0,0,0,0]),i===null&&(i=[0,0,0,0]);let o=t[0],r=t[1];const l=t[2],h=t[3];let a=i[0],f=i[1];const c=i[2],u=i[3];l===0||l===100?(o=a,r=f):(c===0||c===100)&&(a=o,f=r),Math.abs(a-o)>180&&(a>o?o+=360:a+=360);const d=n(e,o,a-o,s)%360,m=n(e,r,f-r,s),g=n(e,l,c-l,s),p=n(e,h,u-h,s);return"hsla("+d+", "+m+"%, "+g+"%, "+p+")"}static{const t=AnimationManager.gx,i=(e,s,n,o,r,l)=>{e.position=new Point(o(r,s.x,n.x-s.x,l),o(r,s.y,n.y-s.y,l))};t.set("position:diagram",i),t.set("position",i),t.set("position:part",(e,s,n,o,r,l)=>{r{r{r{const h=e.actualBounds,a=n.actualBounds,f=a.x+a.width/2-h.width/2,c=a.y+a.height/2-h.height/2;r{e.desiredSize=new Size(o(r,s.width,n.width-s.width,l),o(r,s.height,n.height-s.height,l))}),t.set("width",(e,s,n,o,r,l)=>{e.width=o(r,s,n-s,l)}),t.set("height",(e,s,n,o,r,l)=>{e.height=o(r,s,n-s,l)}),t.set("fill",(e,s,n,o,r,l)=>{e.fill=AnimationManager.VM(s,n,r,l,o)}),t.set("stroke",(e,s,n,o,r,l)=>{e.stroke=AnimationManager.VM(s,n,r,l,o)}),t.set("strokeWidth",(e,s,n,o,r,l)=>{e.strokeWidth=o(r,s,n-s,l)}),t.set("strokeDashOffset",(e,s,n,o,r,l)=>{e.strokeDashOffset=o(r,s,n-s,l)}),t.set("background",(e,s,n,o,r,l)=>{e.background=AnimationManager.VM(s,n,r,l,o)}),t.set("opacity",(e,s,n,o,r,l)=>{e.opacity=o(r,s,n-s,l)}),t.set("scale",(e,s,n,o,r,l)=>{e.scale=o(r,s,n-s,l)}),t.set("angle",(e,s,n,o,r,l)=>{e.angle=o(r,s,n-s,l)})}static Default=1;static AnimateLocations=2;static None=3}class Animation{mx;zm;Ti;Fu;Io;bs;oA;Bf;me;px;li;$n;Ru;Vf;yx;wx;If;zM;xx;ws;b;XM;YM;KM;constructor(t){this.b=null,this.ws=null,this.zM=null,this.xx=null,this.XM=!1,this.Ti=!1,this.If=!1,this.li=0,this.$n=0,this.mx=Animation.EaseInOutQuad,this.zm=Animation.EaseInOutQuad,this.Ru=!1,this.Vf=!1,this.yx=1,this.wx=0,this.Io=NaN,this.bs=NaN,this.YM=0,this.Fu=null,this.oA=Point.Lo,this.me=new GMap,this.px=new GMap,this.Bf=new GSet,this.KM=1,t&&Object.assign(this,t)}suspend(){this.If=!0}advanceTo(t,i){i&&(this.If=!1),this.Ru&&t>=this.bs&&(this.Vf=!0,t=t-this.bs),this.YM=t,this.iA(!0),this.ws.Lu(),this.b.Sr(),this.ws.Tu(),this.b.redraw()}cx(t){if(this.px.clear(),this.Vf=!1,this.wx=0,this.bs=NaN,this.Bf.count>0&&this.Bf.clear(),t!==null){const i=t.links;for(;i.next();)i.value.Lr=null}}bF(){return this.me.count>0}start(){if(this.me.count===0)return this;if(this.Ti)return this;let t=this.b;const i=this.me.iterator;for(;i.next();){const s=i.key;t===null&&(s instanceof Diagram?t=s:s instanceof GraphObject&&(t=s.diagram))}if(t!==null)this.b=t,this.ws=t.animationManager;else return this;const e=this.ws;return e.isEnabled===!1?this:(this.bs=isNaN(this.Io)?e.duration:this.Io,this.zm=this.mx,e.Ff&&e.Rf===1&&this===e.defaultAnimation&&(this.zm=Animation.EaseOutExpo,this.bs=isNaN(this.Io)?e.duration===600?900:e.duration:this.Io),this.KM=t.scrollMode,this.isViewportUnconstrained&&(t.Jh=2),e.Lu(),this.Bf.each(s=>{s.data=null,t.add(s)}),e.Tu(),this.Ti=!0,this.li=+new Date,this.$n=this.li+this.bs,e.pF(this),this)}addTemporaryPart(t,i){return t.Ae()?(Debug&&(i===void 0&&Util.n("addTemporaryPart: Required Diagram argument missing"),t.diagram===i&&Util.n("addTemporaryPart: Part already in Diagram, did you mean to pass in a copy?"),this.b!==null&&this.b!==i&&Util.n("addTemporaryPart: A different Diagram is already associated with this Animation: "+this.b.toString())),this.Bf.add(t),this.b=i,this):this}add(t,i,e,s,n){if(this.b===null&&(t instanceof Diagram?this.b=t:t instanceof GraphObject&&t.diagram!==null&&(this.b=t.diagram)),t instanceof Part){if(!t.isAnimated)return this;i==="position"&&(i="position:part")}return this.EM(t,i,e,s,n),this}EM(t,i,e,s,n){const o=this.me;let r,l,h;if(t instanceof Diagram&&i==="position"&&(i="position:diagram"),(i==="fill"||i==="stroke"||i==="background")&&(Brush.Eo(e),Brush.UM(),e=[Brush.Yi.n0,Brush.Yi.n1,Brush.Yi.n2,Brush.Yi.n3],Brush.Eo(s),Brush.UM(),s=[Brush.Yi.n0,Brush.Yi.n1,Brush.Yi.n2,Brush.Yi.n3]),o.has(t))r=o.get(t),l=r.li,h=r.xs,l[i]===void 0&&(l[i]=this.Iu(e)),h[i]=this.Iu(s);else{if(i==="position"&&e.equalsApprox(s))return;l={},h={},l[i]=this.Iu(e),h[i]=this.Iu(s),r=new AnimationState(l,h,n),o.set(t,r)}const a=l[i];a instanceof Point&&!a.isReal()&&a.c(this.oA),n&&i.indexOf("position:")===0&&t instanceof Part?r.bx.location=this.Iu(t.location):n&&(r.bx[i]=this.Iu(e))}Iu(t){return t instanceof Point||t instanceof Size?t.copy():t}kF(t){const i=this.me;if(i.has(t)){const e=i.get(t);e.kx=!0}}ux(t){if(!this.Ti)return!1;const i=this.me.get(t);return i!==null&&i.kx}OM(t){if(!this.Ti)return!1;const i=this.me.get(t);return i!==null&&!!(i.li.position||i.li["position:part"]||i.li.location)}yF(){if(this.Bf.count>0)return!0;const t=this.me.iterator;for(;t.next();){const i=t.key;if(i instanceof GraphObject&&i.diagram!==null||i instanceof Diagram)return!0}return!1}iA(t){if(this.If&&!t)return;const i=this.ws;if(this.Ti===!1)return;const e=+new Date;let s=e>this.$n?this.bs:e-this.li;t&&(s=this.YM,sthis.$n&&(this.Ru&&!this.Vf?(this.li=+new Date,this.$n=this.li+this.bs,this.Vf=!0):this.Du(!1))}_C(t){const i=this.bs,e=this.me.iterator,s=this.Vf;for(;e.next();){const n=e.key;if(n instanceof GraphObject&&n.diagram===null)continue;const o=e.value,r=s?o.xs:o.li,l=s?o.li:o.xs,h=AnimationManager.gx;for(const a in l)a==="position"&&(l["position:placeholder"]||l["position:nodeCollapse"])||h.get(a)!==null&&h.get(a)(n,r[a],l[a],this.zm,t,i,this)}}stop(){return this.Ti?(this.Du(!0),this):this}Du(t){if(this.xx!==null&&this.xx.SF(this.zM),!this.Ti)return;const i=this.b,e=this.ws;e.Ff=!1,this.Ti=!1,this.If=!1,e.Lu();const s=this.me,n=this.Bf.iterator;for(;n.next();)i.remove(n.value);const o=this.Ru,r=s.iterator,l=AnimationManager.gx;for(;r.next();){const a=r.key,f=r.value,c=o?f.xs:f.li,u=o?f.li:f.xs,d=f.bx;for(const m in u)if(l.get(m)!==null){let g=m;f.Sx&&(g==="position:nodeCollapse"||g==="position:placeholder")&&(g="position"),l.get(g)(a,c[m],d[m]!==void 0?d[m]:f.Sx?c[m]:u[m],this.zm,this.bs,this.bs,this)}f.Sx&&d.location!==void 0&&a instanceof Part&&(a.location=d.location),f.kx&&a instanceof Part&&a.Ki(!1)}this.wx++;const h=!t&&this.yx>this.wx;if(!h&&(this===e.Em||this===e.defaultAnimation)&&this.me.clear(),i.Mx.clear(),i.NS(!1),i.invalidateDocumentBounds(),i.T(),i.Sr(!0),e.defaultAnimation===this){const a=e.Vm.iterator;for(;a.next();)a.value.MF();e.Vm.clear()}if(i.Sr(!0),this.isViewportUnconstrained&&(i.scrollMode=this.KM),e.Tu(),h){this.Vf=!1,this.start();return}this.cx(null),i.rA(),e.Du(this),this.Fu&&this.Fu(this),i.requestUpdate()}Of(t,i){const e=i.actualBounds;let s=null;if(i instanceof Group&&(s=i.placeholder),s!==null&&s.visible){const n=s.getDocumentPoint(Spot.TopLeft),o=s.padding;n.x+=o.left,n.y+=o.top,this.add(t,"position",n,t.position,!1)}else this.add(t,"position",new Point(e.x+e.width/2,e.y+e.height/2),t.position,!1);this.add(t,"scale",.01,t.scale,!1),t instanceof Group&&this.PF(t,i)}PF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Of(s,i)}}Ef(t,i){if(!t.isVisible())return;let e=null;if(i instanceof Group&&(e=i.placeholder),e!==null&&e.visible){const s=e.getDocumentPoint(Spot.TopLeft),n=e.padding;s.x+=n.left,s.y+=n.top,this.add(t,"position:placeholder",t.position,s,!0)}else this.add(t,"position:nodeCollapse",t.position,i,!0);this.add(t,"scale",t.scale,.01,!0),this.kF(t),t instanceof Group&&this.NF(t,i)}NF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Ef(s,i)}}get duration(){return this.Io}set duration(t){Util.t(t,"number",Animation,"duration"),t<1&&Util.G(t,">= 1",Animation,"duration"),this.Io=t}get reversible(){return this.Ru}set reversible(t){this.Ru=t}get runCount(){return this.yx}set runCount(t){t>0?this.yx=t:Util.n("Animation.runCount value must be a positive integer.")}get finished(){return this.Fu}set finished(t){this.Fu!==t&&(t!==null&&Util.t(t,"function",Animation,"finished"),this.Fu=t)}get easing(){return this.mx}set easing(t){this.mx=t}get isViewportUnconstrained(){return this.XM}set isViewportUnconstrained(t){this.XM=t}get isAnimating(){return this.Ti}getTemporaryState(t){let i=this.px.get(t);return i===null&&(i={},this.px.set(t,i)),i}static EaseLinear=(t,i,e,s)=>e*t/s+i;static EaseInOutQuad=(t,i,e,s)=>(t/=s/2,t<1?e/2*t*t+i:-e/2*(--t*(t-2)-1)+i);static EaseInQuad=(t,i,e,s)=>e*(t/=s)*t+i;static EaseOutQuad=(t,i,e,s)=>-e*(t/=s)*(t-2)+i;static EaseInExpo=(t,i,e,s)=>t===0?i:e*Math.pow(2,10*(t/s-1))+i;static EaseOutExpo=(t,i,e,s)=>t===s?i+e:e*(-Math.pow(2,-10*t/s)+1)+i}class AnimationState{li;xs;bx;Sx;kx;constructor(t,i,e){this.li=t,this.xs=i,this.bx={},this.Sx=e,this.kx=!1}}var TriggerStart=(w=>(w[w.Default=1]="Default",w[w.Immediate=2]="Immediate",w[w.Bundled=3]="Bundled",w))(TriggerStart||{});class AnimationTrigger{Ce;gn;Ou;zf;constructor(t,i,e){e&&Debug&&Util.tt(e,TriggerStart,"TriggerStart"),this.Ce=null,this.gn=t,this.Ou=e||1,this.zf=null,i!==void 0&&(this.zf=i,e===void 0&&(this.Ou=2))}copy(){const t=new AnimationTrigger(this.gn);t.Ou=this.Ou;const i=this.zf;if(i!==null){const e={};i.duration!==void 0&&(e.duration=i.duration),i.finished!==void 0&&(e.finished=i.finished),i.easing!==void 0&&(e.easing=i.easing),t.zf=e}return t}get propertyName(){return this.gn}set propertyName(t){this.gn=t}get animationSettings(){return this.zf}set animationSettings(t){this.zf=t}CF(t){const i=this.zf;i!==null&&(i.duration&&(t.duration=i.duration),i.finished&&(t.finished=i.finished),i.easing&&(t.easing=i.easing))}get startCondition(){return this.Ou}set startCondition(t){Debug&&Util.tt(t,TriggerStart,"TriggerStart"),this.Ou=t}static Default=1;static Immediate=2;static Bundled=3}class Layer{b;Tt;_t;Tr;Bl;Vl;zl;Xl;Yl;Kl;Ul;Gl;Hl;ql;jl;Wl;Tf;vl;Px;Xm;Eu;It;constructor(t){GSet.vi(this),this.b=null,this.It=new List,this.Tt="",this._t=1,this.Tr=!1,this.Bl=!0,this.Vl=!0,this.zl=!0,this.Xl=!0,this.Yl=!0,this.Kl=!0,this.Ul=!0,this.Gl=!0,this.Hl=!0,this.ql=!0,this.jl=!0,this.Wl=!0,this.Tf=!0,this.vl=!0,this.Px=!0,this.Xm=!1,this.Eu=[],t&&Object.assign(this,t)}AF(){const t=this.It;for(let i=0;i0&&(h+=e+" Parts "),s>0&&(h+=s+" Nodes "),n>0&&(h+=n+" Groups "),o>0&&(h+=o+" Links "),r>0&&(h+=r+" Adornments "),t>1){const a=this.It.iterator;for(;a.next();){const f=a.value;h+=` + `+f.toString();const c=f.data;c!==null&&GSet.gs(c)&&(h+=" #"+GSet.gs(c)),f instanceof Node?h+=" "+Util.toString(c):f instanceof Link&&(h+=" "+Util.toString(f.fromNode)+" "+Util.toString(f.toNode))}}return i+" "+this.It.count+": "+h}findObjectAt(t,i,e){if(i===void 0&&(i=null),e===void 0&&(e=null),this.vl===!1)return null;Debug&&!t.isReal()&&Util.n("findObjectAt: Point must have a real value, not: "+t.toString());let s=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(s=!0);const n=Point.a(),o=this.It.h,r=o.length;for(let l=r;l--;){const h=o[l];if(s===!0&&h.Tl()===!1||!h.isVisible())continue;n.c(t),n.Ye(h.Ks);let a=h.lA(n,i,e);if(a!==null&&(i!==null&&(a=i(a)),a!==null&&(e===null||e(a))))return Point.o(n),a}return Point.o(n),null}findObjectsAt(t,i,e,s){if(i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.vl===!1)return s;Debug&&!t.isReal()&&Util.n("findObjectsAt: Point must have a real value, not: "+t.toString());let n=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(n=!0);const o=Point.a(),r=this.It.h,l=r.length;for(let h=l;h--;){const a=r[h];if(n===!0&&a.Tl()===!1||!a.isVisible())continue;o.c(t),o.Ye(a.Ks);let f=a;a.hA(o,i,e,s)&&(i!==null&&(f=i(f)),f!==null&&(e===null||e(f))&&s.add(f))}return Point.o(o),s}findObjectsIn(t,i,e,s,n){if(i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.vl===!1)return n;Debug&&!t.isReal()&&Util.n("findObjectsIn: Rect must have a real value, not: "+t.toString());let o=!1;this.diagram!==null&&this.diagram.viewportBounds.containsRect(t)&&(o=!0);const r=this.It.h,l=r.length;for(let h=l;h--;){const a=r[h];if(o===!0&&a.Tl()===!1||!a.isVisible())continue;let f=a;a.Ym(t,i,e,s,n)&&(i!==null&&(f=i(f)),f!==null&&(e===null||e(f))&&n.add(f))}return n}IS(t,i,e,s,n,o,r){if(this.vl===!1)return n;const l=this.It.h,h=l.length;for(let a=h;a--;){const f=l[a];if(r===!0&&f.Tl()===!1||!o(f)||!f.isVisible())continue;let c=f;f.Ym(t,i,e,s,n)&&(i!==null&&(c=i(c)),c!==null&&(e===null||e(c))&&n.add(c))}return n}findObjectsNear(t,i,e,s,n,o){if(e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.vl===!1)return o;Debug&&!t.isReal()&&Util.n("findObjectsNear: Point must have a real value, not: "+t.toString());let r=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(r=!0);const l=Point.a(),h=Point.a(),a=this.It.h,f=a.length;for(let c=f;c--;){const u=a[c];if(r===!0&&u.Tl()===!1||!u.isVisible())continue;l.c(t),l.Ye(u.Ks),h.e(t.x+i,t.y),h.Ye(u.Ks);let d=u;u.aA(l,h,e,s,n,o)&&(e!==null&&(d=e(d)),d!==null&&(s===null||s(d))&&o.add(d))}return Point.o(l),Point.o(h),o}HM(){return this.It.h}Us(t,i){if(!this.visible)return;const e=this.It.h,s=e.length;if(s===0)return;const n=Util.at(),o=Util.at();for(let r=0;r0&&o.push(l))}for(let r=0;re.Um||a.height*n>e.Um?i.Ji(t,e):this.FF(t,i),f&&(t.restore(),t.clearContextCache(!0))}FF(t,i){const e=i.actualBounds,s=i.naturalBounds;if(e.width===0||e.height===0||isNaN(e.x)||isNaN(e.y)||!i.isVisible())return;const n=i.O;if(i.background===null){i.wn(t,"rgba(0,0,0,0.3)",!0,!1,s,e),t.fillRect(e.x,e.y,e.width,e.height);return}if(t.transform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),i.wn(t,i.background,!0,!1,s,e),t.fillRect(0,0,s.width/2,s.height/2),!n.Gk()){const o=1/(n.m11*n.m22-n.m12*n.m21);t.transform(n.m22*o,-n.m12*o,-n.m21*o,n.m11*o,o*(n.m21*n.dy-n.m22*n.dx),o*(n.m12*n.dx-n.m11*n.dy))}}DF(t,i,e,s){const n=2/s,o=4/s;for(let r=0;r=s.count)t=s.count;else if(s.elt(t)===i)return-1;s.insertAt(t,i),i.Gm(e);const n=this.diagram;return n!==null&&(e?n.T():n.$h(i)),this.Nx(t,i),t}oe(t,i,e){if(!e&&i.layer!==this&&i.layer!==null)return i.layer.oe(t,i,e);const s=this.It;if(t<0||t>=s.length){if(t=s.indexOf(i),t<0)return-1}else if(s.elt(t)!==i&&(t=s.indexOf(i),t<0))return-1;i.Hm(e),s.removeAt(t);const n=this.diagram;return n!==null&&(e?n.T():n.oe(i)),i.GM(null),t}Nx(t,i){t=this.RF(t,i),i instanceof Group&&this.IF(t,i),i.svg!==null&&i.svg.remove()}RF(t,i){const e=i.zOrder;if(isNaN(e))return t;const s=this.It,n=s.count;if(n<=1)return t;if(t<0&&(t=s.indexOf(i)),t<0)return-1;let o=t-1,r=NaN;for(;o>=0&&(r=s.elt(o).zOrder,!!isNaN(r));)o--;let l=t+1,h=NaN;for(;le)for(;;){if(o===-1||r<=e)return o++,o===t?t:(s.removeAt(t),s.insertAt(o,i),o);for(r=NaN;--o>=0&&(r=s.elt(o).zOrder,!!isNaN(r)););}else if(!isNaN(h)&&h=e)return l--,l===t?t:(s.removeAt(t),s.insertAt(l,i),l);for(h=NaN;++l=0)||e<0&&r.containingGroup===i&&(e=o,t>=0))break}if(!(e<0)&&e1)&&Util.G(t,"0 <= value <= 1",Layer,"opacity"),this._t=t;const e=this.diagram;e!==null&&e.T(),this.i("opacity",i,t)}}get isViewportAligned(){return this.Xm}set isViewportAligned(t){const i=this.Xm;i!==t&&(this.Xm=t,this.diagram&&(this.cA(),this.diagram.T()),this.i("isViewportAligned",i,t),t&&(this.isInDocumentBounds=!1))}cA(){if(!this.Xm)return;const t=this.diagram,i=this.It.h,e=i.length,s=t.Ct,n=t.At;for(let o=0;o(w[w.None=1]="None",w[w.Uniform=2]="Uniform",w[w.UniformToFill=3]="UniformToFill",w))(AutoScale||{}),CycleMode=(w=>(w[w.All=1]="All",w[w.NotDirected=2]="NotDirected",w[w.NotDirectedFast=3]="NotDirectedFast",w[w.NotUndirected=4]="NotUndirected",w[w.DestinationTree=5]="DestinationTree",w[w.SourceTree=6]="SourceTree",w))(CycleMode||{}),ScrollMode=(w=>(w[w.Document=1]="Document",w[w.Infinite=2]="Infinite",w))(ScrollMode||{}),CollapsePolicy=(w=>(w[w.TreeParent=1]="TreeParent",w[w.AllParents=2]="AllParents",w[w.AnyParents=3]="AnyParents",w))(CollapsePolicy||{});class Diagram{ws;yi;WM;Cx;Dr;zu;Ax;Lx;Tx;Dx;Fx;Rx;Xf;Jh;Ix;Ox;Ex;Jl;Yf;Fr;qm;Bx;Vx;Xu;Qn;Rr;Qh;Bo;jm;Kf;Wm;Uf;Yu;Ir;_n;vM;JM;zx;Xx;ZM;Yx;$M;QM;_M;Kx;vm;Or;Er;Br;Vr;zr;Xr;Ux;Yr;Gx;Kr;Ur;Gr;Hr;Hx;tP;Vo;iP;qx;jx;eP;Ai;sP;nP;oP;zs;zo;Xi;Wx;Bl;Vl;vx;Jx;zl;Xl;Yl;Zx;Kl;Ul;Gl;Hl;ql;jl;Wl;$x;Qx;rP;Ku;Uu;_x;t1;i1;e1;Jm;s1;o1;l1;ii;lP;h1;hP;Gu;xn;to;re;io;uA;Zl;aP;fP;Zm;a1;Hu;$m;f1;qr;$l;_h;cP;uP;Qm;c1;u1;os;_m;t0;qu;Ql;Gf;i0;jr;ta;dP;e0;$t;O;Ge;Ar;Ui;ks;gP;_l;Wr;Pl;vr;ia;Hf;mP;ju;ea;Wu;Jt;th;gt;rt;vu;Ct;At;xt;qf;qw;d1;sa;jf;g1;m1;p1;BF;VF;Gi;Cl;Um;s0;pP;yP;dA;o0;zF;XF;YF;w1;KF;UF;GF;na;gA;ih;oa;ra;la;ha;Pu;Wh;ei;Ot;Wf;eS;sS;xf;_t;static b1=null;static mA=new GMap;static wP;static xP=null;Mu;k1;S1;M1;P1;N1;r0;bP;l0;h0;a0;fx;kP;C1;vf;constructor(t,i){if(Diagram.ww||(Diagram.Hk(),Diagram.ww=!0),GSet.vi(this),Diagram.pA(this),this.$t=!0,this.Ot=null,this.Ct=0,this.At=0,this.xt=null,Diagram.isUsingDOM()){const s=this,n=()=>{s.Li(root.document,"DOMContentLoaded",n,!1),s.setRTL()};root.document.body!==null?this.setRTL():s.Ht(root.document,"DOMContentLoaded",n,!1)}this.qf=null,Diagram.SP("Model",PartManager);const e=this;return this.sP=s=>e.partManager.doModelDataChanged(s),this.nP=s=>e.partManager.doModelChanged(s),this.g1=null,this.m1=null,this.yA(),this.model=Model.initDiagramModel(),this.C1=null,this.themeManager=new ThemeManager,this.Vo=!0,this.wA(),this.layout=new Layout,this.Vo=!1,this.zF=null,this.XF=null,this.YF=null,this.w1=null,this.KF=null,this.UF=null,this.GF=null,this.na=null,this.gA=null,this.ih=null,this.oa=null,this.ra=null,this.la=null,this.ha=null,this.Pu=()=>{},this.Wh=null,this.qu=!1,this.Wf=new DiagramHelper(this),t!==void 0&&(typeof t=="string"||root.Element&&t instanceof Element?this.MP(t):i=t),i&&this.setProperties(i),this.$t=!1,this.requestUpdate(),this}tF(){return this.xt!==null}get renderer(){return this.Gf}set renderer(t){if(this instanceof Overview)return;t===""&&(t="default");const i=t.toLowerCase(),e=this.Gf;if(i===e)return;this.Gf=i;let s=null;i==="default"||i==="canvas"?(s=this.Ql.get("svg"),s!==null&&s.Vt.remove(),this.xt&&(this.ei=this.xt.di),this.ei.clearContextCache(!0)):i==="svg"?(this.Ql.has("svg")?s=this.Ql.get("svg"):(s=new SVGSurface(this,root.document),this.addRenderer("svg",s)),this.div!==null&&this.div.appendChild(s.Vt),this.ei=s.di,this.xt&&(this.xt.di.setTransform(this.Gi,0,0,this.Gi,0,0),this.xt.di.clearRect(0,0,this.Ct,this.At))):i==="debug"&&(this.Ql.has("SVG")||(s=new SVGSurface(this,root.document),this.addRenderer("SVG",s),s.Vt.style.backgroundColor="whitesmoke",this.div!==null&&this.div.after(s.Vt))),this.$t||this.redraw()}yA(){this.vf=new List,this.setupRouters(),this.ws=new AnimationManager,this.ws.Oo(this),this.yi=17,this.WM=!1,this.vu=!1,this.Cx="default",this.Jt=new List,this.Ql=new GMap,this.Gf="default",this.resetRenderingHints(),this.HF(),this._t=1,this.gt=new Point(NaN,NaN).w(),this.fx=new Point(NaN,NaN),this.rt=1,this.e0=1,this.Ax=new Point(NaN,NaN).w(),this.Lx=NaN,this.Tx=1e-4,this.Dx=100,this.O=new Transform,this.Fx=new Point(NaN,NaN).w(),this.Rx=new Rect(NaN,NaN,NaN,NaN).w(),this.Xf=new Margin(0,0,0,0).w(),this.Jh=1,this.Ix=!1,this.Ox=null,this.Ex=null,this.Jl=1,this.Yf=Spot.Default,this.Fr=1,this.qm=Spot.Default,this.Bx=Spot.None,this.Vx=Spot.None,this.Ge=!0,this.Xu=!1,this.Qn=new Set,this.Rr=new GSet,this.Qh=new GSet,this.Bo=!1,this.th=new GMap,this.ju=!0,this.jm=250,this.Kf=-1,this.Wm=new Margin(16,16,16,16).w(),this.Ar=!1,this.Uf=!1,this.Yu=!0,this.i0=new InputEvent,this.i0.diagram=this,this.jr=new InputEvent,this.jr.diagram=this,this.ta=new InputEvent,this.ta.diagram=this,this.Ir=null,this._n=null,this.qw=!1,this.qF(),this.vr=new GSet,this.zx=!0,this.Xx=1,this.ZM=!1,this.Yx=1,this.Kx="auto",this.vm="auto",this.Or=null,this.Er=null,this.Br=null,this.Vr=null,this.zr=null,this.Xr=null,this.Ux=null,this.Yr=null,this.Gx=!1,this.Kr=null,this.Ur=null,this.Gr=null,this.Hr=null,this.Hx=!1,this.d1={},this.sa=[null,null],this.Vo=!1,this.iP=!1,this.qx=!1,this.jx=!1,this.eP=!0,this.ks=!1,this.ea=!1,this.oP=!0,this.zs=-2,this._l=new GMap,this.Wu=new List,this.zo=!1,this.Xi=!0,this.Wx=!0,this.Bl=!0,this.Vl=!0,this.vx=!1,this.Jx=!0,this.zl=!0,this.Xl=!0,this.Yl=!0,this.Zx=!0,this.Kl=!0,this.Ul=!0,this.Gl=!0,this.Hl=!0,this.ql=!0,this.jl=!0,this.Wl=!0,this.$x=!0,this.Qx=!0,this.rP=!1,this.jf=!1,this.Ku=!0,this.Uu=!0,this._x=!0,this.t1=!0,this.i1=16,this.e1=16,this.Jm=!1,this.s1=!1,this.o1=0,this.l1=0,this.ii=new Margin(5).w(),this.lP=new GSet().w(),this.h1=999999999,this.hP=new GSet().w(),this.ia=!0,this.Gu=!0,this.Hf=!0,this.xn=!1,this.to=!1,this.Wr=!0,this.Pl=!1,this.io=!1,this.uA=new GSet,this.mP=new GSet,this.Zl=null,this.aP=new Size(8,8),this.fP=999,this.Zm=!1,this.eS=1,this.sS=0,this.Ui={scale:1,position:new Point,bounds:new Rect,canvasSize:new Size,newCanvasSize:new Size,isScroll:!1},this.Ui.canvasSize=this.Ui.canvasSize,this.Ui.newCanvasSize=this.Ui.newCanvasSize,this.Ui.isScroll=!1,this.a1=new Rect(NaN,NaN,NaN,NaN).w(),this.Hu=new Size(NaN,NaN).w(),this.$m=new Rect(NaN,NaN,NaN,NaN).w(),this.f1=!1,this.jF(),this.os=null,this._m=!1,this.xf=null,this.partManager=new PartManager,this.toolManager=new ToolManager,this.toolManager.initializeStandardTools(),this.defaultTool=this.toolManager,this.currentTool=this.defaultTool,this.S1=null,this.M1=new DraggingOptions,this.P1=null,this.N1=null,this.k1=!1,this.Mu=!1,this.commandHandler=new CommandHandler,this.h0=null,this.a0=Point.Bk,this.kP=!1,this.Gi=1,this.Cl=null,this.Um=1,this.r0=0,this.bP=[0,0,0,0,0],this.l0=0,this.s0=1,this.pP=0,this.yP=new Point,this.dA=500,this.t0=new Point,this.o0=!1}static xA=root.document!==void 0;static isUsingDOM(){return Diagram.xA}static useDOM(t){Diagram.xA=t?root.document!==void 0:!1}static He=new WeakMap;clear(){this.animationManager.stopAnimation(),this.model.clear(),Diagram.bA(),this.kA(!1),this.Wu.clear(),this.SA(),this.Zl=null,this.invalidateDocumentBounds(),this.ensureBounds(),this.T()}kA(t){this.animationManager.stopAnimation(!0),this.lP=new GSet().w(),this.hP=new GSet().w();const i=this.skipsUndoManager,e=this.Ai!==null&&this.Ai!==void 0;e&&(this.skipsUndoManager=!0);let s=null;this.os!==null&&(s=this.os.part,s!==null&&this.remove(s));const n=[],o=this.Jt.length;if(t){for(let r=0;rt?new Margin(t/2):1.5)),this.c1=this.Qm,this.u1=new Adornment(Panel.Link).add(new Shape({isPanelMain:!0,fill:null,stroke:"dodgerblue",strokeWidth:3}).theme("stroke","selection").theme("strokeWidth","selection"))}setRTL(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);const e=Util.ln("div");e.dir="rtl",e.style.cssText="font-size: 14px; width: 1px; height: 1px; position: absolute; top: -1000px; overflow: scroll;",e.textContent="A",i.appendChild(e);let s="reverse";e.scrollLeft>0?s="default":(e.scrollLeft=1,e.scrollLeft===0&&(s="negative")),i.removeChild(e),this.Cx=s}setScrollWidth(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);let e=0;if(Diagram.isUsingDOM()){let s=Diagram.xP,n=Diagram.wP;s===null&&(Diagram.xP=Util.ln("p"),s=Diagram.xP,s.style.width="100%",s.style.height="200px",s.style.boxSizing="content-box",Diagram.wP=Util.ln("div"),n=Diagram.wP,n.style.position="absolute",n.style.visibility="hidden",n.style.width="200px",n.style.height="150px",n.style.boxSizing="content-box",n.appendChild(s)),n.style.overflow="hidden",i.appendChild(n);const o=s.offsetWidth;n.style.overflow="scroll";let r=s.offsetWidth;o===r&&(r=n.clientWidth),i.removeChild(n),e=o-r,e===0&&!Util.cr&&(e=11)}this.yi=e,this.WM=!0}fi(t){t in AutoScale?this.autoScale=t:Util.ur(this,t)}toString(t){t===void 0&&(t=0);let i="";this.div&&this.div.id&&(i=this.div.id);let e='Diagram "'+i+'"';if(t<=0)return e;const s=this.Jt.iterator;for(;s.next();){const n=s.value;e+=` + `+n.toString(t-1)}return e}static pA(t){Diagram.b1=t}static Sm(){return Diagram.b1}static fromDiv(t){let i=t;if(typeof t=="string"&&(i=root.document.getElementById(t)),i instanceof HTMLDivElement){const e=Diagram.He.get(i);if(e)return e}return null}get div(){return this.Ot}set div(t){if(t!==null&&Util.s(t,HTMLDivElement,Diagram,"div"),this.Ot!==t){const i=this.Ot;if(i!==null){if(Diagram.He.delete(i),i.goDiagram=void 0,i.go=void 0,i.innerHTML="",this.xt!==null){const s=this.xt.Vt;this.Li(s,"pointermove",this.oa,!1),this.Li(s,"pointerdown",this.ih,!1),this.Li(s,"pointerup",this.ra,!1),this.Li(s,"pointerout",this.la,!1),this.Li(s,"pointercancel",this.ha,!1),this.xt.dispose()}this.qf&&(this.qf.disconnect(),this.qf=null);const e=this.toolManager;e!==null&&(e.mouseDownTools.each(s=>s.cancelWaitAfter()),e.mouseMoveTools.each(s=>s.cancelWaitAfter()),e.mouseUpTools.each(s=>s.cancelWaitAfter())),e.cancelWaitAfter(),this.currentTool.doCancel(),this.xt=null,this.Li(root,"resize",this.w1,!1),this.Li(root,"wheel",this.na,!0),Diagram.Sm()===this&&Diagram.pA(null)}else this.ih===null&&(this.io=!1);if(this.Ot=null,t!==null){const e=Diagram.He.get(t);e&&(e.div=null),this.MP(t),this.Pu(),this.themeManager&&this.themeManager.WF()}else this.themeManager&&this.themeManager.vF()}}setupRouters(){this.vf.push(new AvoidsNodesRouter)}MP(t){const i=this;if(!Diagram.isUsingDOM())return;t==null&&Util.n("Diagram setup requires an argument DIV."),i.Ot!==null&&Util.n("Diagram has already completed setup."),typeof t=="string"?i.Ot=root.document.getElementById(t):t instanceof HTMLDivElement?i.Ot=t:Util.n("No DIV or DIV id supplied: "+t),i.Ot===null&&Util.n("Invalid DIV id; could not get element with id: "+t);const e=Diagram.He.get(i.Ot);if(e&&e!==this&&Util.n("Invalid div id; div already has a Diagram associated with it."),!i.qf&&root.ResizeObserver){const f=root.ResizeObserver,c=Util.Ik(()=>i.requestUpdate(),250,!1);i.qf=new f(()=>c()),i.qf.observe(i.Ot)}root.getComputedStyle(i.Ot,null).position==="static"&&(i.Ot.style.position="relative");let s=5;const n="rgba(2"+s+"5, 255, 255, 0)";s--,i.Ot.style["-webkit-tap-highlight-color"]=n,i.Ot.innerHTML="",Diagram.He.set(i.Ot,i),i.Ot.goDiagram=i,i.Ot.go=root.go;const o=new CanvasSurface(i);o.style!==void 0&&(o.style.position="absolute",o.style.top="0px",o.style.left="0px",root.getComputedStyle(i.Ot,null).getPropertyValue("direction")==="rtl"&&(i.vu=!0),o.style.zIndex="2",o.style.userSelect="none",o.style.MozUserSelect="none",o.style.touchAction="none",o.style.letterSpacing="normal !important",o.style.wordSpacing="normal !important",o.style.lang="unknown"),i.xt=o,i.ei=o.di;const r=i.ei;i.Gi=i.computePixelRatio(),i.viewSize.isReal()||(i.Ct=i.Ot.clientWidth||1,i.At=i.Ot.clientHeight||1),i.MA(i.Ct,i.At);const l=i;i.Ot.insertBefore(o.Vt,i.Ot.firstChild);const h=new CanvasSurface(null);if(h.width=1,h.height=1,i.BF=h,i.VF=h.di,Diagram.isUsingDOM()){const f=Util.ln("div"),c=Util.ln("div");f.style.position="absolute",f.style.overflow="auto",f.style.width=i.Ct+"px",f.style.height=i.At+"px",f.style.zIndex="1",c.style.position="absolute",c.style.width="1px",c.style.height="1px",i.Ot.appendChild(f),f.appendChild(c),f.onscroll=Diagram.JF,f.addEventListener("pointerdown",Diagram.ZF),f.b=i,f.$F=!0,f.QF=!0,i.g1=f,i.m1=c}i.Pu=Util.Ik(()=>{i.Cl=null,i.T()},300,!1),i.w1=Util.Ik(()=>{i.RM()},250,!1),i.Wh=f=>(f.preventDefault(),!1),i.na=f=>{if(!l.isEnabled)return;const c=l.Jf(f,!0);c.bubbles=!0;let u=0,d=0;c.delta=0,f.deltaX!==void 0?(f.deltaX!==0&&(u=f.deltaX>0?1:-1),f.deltaY!==0&&(d=f.deltaY>0?1:-1),c.delta=Math.abs(f.deltaX)>Math.abs(f.deltaY)?-u:-d):f.wheelDeltaX!==void 0?(f.wheelDeltaX!==0&&(u=f.wheelDeltaX>0?-1:1),f.wheelDeltaY!==0&&(d=f.wheelDeltaY>0?-1:1),c.delta=Math.abs(f.wheelDeltaX)>Math.abs(f.wheelDeltaY)?-u:-d):f.wheelDelta!==void 0&&f.wheelDelta!==0&&(c.delta=f.wheelDelta>0?1:-1),l.doMouseWheel(),l.aa(c,f)},i.gA=f=>{if(!l.isEnabled)return;i.jf=!1,l.Jf(f,!0);const c=l.currentTool;c.cancelWaitAfter(),c.standardMouseOver()},i.ih=f=>{if(!l.isEnabled)return;i.jf=!0;const c=l.d1;c[f.pointerId]===void 0&&(c[f.pointerId]=f);const u=l.sa;let d=!1;if(u[0]!==null&&(u[0].pointerId===f.pointerId||u[0].pointerType!==f.pointerType))u[0]=f;else if(u[1]!==null&&u[1].pointerId===f.pointerId)u[1]=f,d=!0;else if(u[0]===null)u[0]=f;else if(u[1]===null)u[1]=f,d=!0;else{f.preventDefault();return}const m=f.pointerType==="touch"||f.pointerType==="pen";m&&(l.qw=!1,l.o0=!0);const g=l._F(f,f,d),p=l.yP,y=m?25:10;if(f.timeStamp-l.pPy||Math.abs(p.y-f.screenY)>y)?l.s0++:l.s0=1,g.clickCount=l.s0,l.pP=f.timeStamp,l.yP.setTo(f.screenX,f.screenY),l.doMouseDown(),f.button===1){f.preventDefault();return}l.aa(g,f)},i.oa=f=>{if(!l.isEnabled)return;i.jf=!0;const c=l.sa;if(c[0]!==null&&(c[0].pointerId===f.pointerId||c[0].pointerType!==f.pointerType))c[0]=f;else if(c[1]!==null&&c[1].pointerId===f.pointerId){c[1]=f;return}else if(c[0]===null)c[0]=f;else return;if(c[0].pointerId!==f.pointerId)return;const u=l.tR(f,f,c[1]!==null);l.doMouseMove(),l.aa(u,f)},i.ra=f=>{if(!l.isEnabled)return;i.jf=!0;const c=f.pointerType==="touch"||f.pointerType==="pen",u=l.d1;if(c&&l.qw){delete u[f.pointerId],f.preventDefault();return}const d=l.sa;if(d[0]!==null&&(d[0].pointerId===f.pointerId||d[0].pointerType!==f.pointerType))d[0]=null;else if(d[1]!==null&&d[1].pointerId===f.pointerId){d[1]=null;return}else return;const m=l.PP(f,!1,!0,!1,!0,!1);let g=root.document.elementFromPoint(f.clientX,f.clientY)||null;g!==null&&g.shadowRoot!==void 0&&g.shadowRoot!==null&&(g=g.shadowRoot.elementFromPoint(f.clientX,f.clientY)),g!==null&&g.b instanceof Diagram&&g.b!==l&&g.b.c0(f,m),g===null&&(g=f.target),l.c0(f,m),m.clickCount=l.s0,m.targetDiagram=l.NP(f,g),m.targetObject=null,l.doMouseUp(),l.aa(m,f),c&&(l.o0=!1)},i.la=f=>{if(!l.isEnabled)return;i.jf=!1;const c=l.d1;c[f.pointerId]&&delete c[f.pointerId];const u=l.sa;if(u[0]!==null&&u[0].pointerId===f.pointerId&&(u[0]=null),u[1]!==null&&u[1].pointerId===f.pointerId&&(u[1]=null),f.pointerType==="touch"||f.pointerType==="pen")return;const d=l.currentTool;d.cancelWaitAfter(),d.standardMouseOver()},i.ha=f=>{const c=l.sa;c[0]!==null&&c[0].pointerId===f.pointerId?(c[0]=null,l.o0=!1):c[1]!==null&&c[1].pointerId===f.pointerId&&(c[1]=null)};const a=r;if(i.p1=a.Y[Util.Fs("7eba17a4ca3b1a8346")][Util.Fs("78a118b7")](a.Y,Diagram.Ju,s,s),r.clearContextCache(!0),i.iR(),this.Gf==="svg"){const f=this.Ql.get("svg");this.Ot.appendChild(f.Vt),this.ei=f.di}}addEventListener(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}Ht(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}removeEventListener(t,i,e,s){t.removeEventListener(i,e,{capture:s})}Li(t,i,e,s){t.removeEventListener(i,e,{capture:s})}iR(){const t=this;let i=this.xt.Vt;i instanceof HTMLCanvasElement||(i=t.div),this.Ht(i,"pointerdown",t.ih,!1),this.Ht(i,"pointermove",t.oa,!1),this.Ht(i,"pointerup",t.ra,!1),this.Ht(i,"pointerout",t.la,!1),this.Ht(i,"pointercancel",t.ha,!1),this.Ht(i,"pointerenter",t.eR,!1),this.Ht(i,"pointerleave",t.sR,!1),this.Ht(i,"wheel",t.na,!1),this.Ht(i,"keydown",t.nR,!1),this.Ht(i,"keyup",t.oR,!1),this.Ht(i,"blur",t.rR,!1),this.Ht(i,"focus",t.lR,!1),this.Ht(i,"selectstart",e=>(e.preventDefault(),!1),!1),this.Ht(i,"contextmenu",e=>(e.preventDefault(),!1),!1),this.Ht(root,"resize",t.w1,!1)}jw(){this.r0>30&&(this.Cl=1)}NS(t){this.Cl!==null&&(this.Cl=null,t&&this.Pu(),Debug&&Debug.drawFrames||(this.r0=0,this.bP=[0,0,0,0,0],this.l0=0))}computePixelRatio(){return this.Cl!==null?this.Cl:root.devicePixelRatio||1}get avgSpf(){return this.r0}doMouseDown(){this.currentTool.doMouseDown()}doMouseMove(){this.currentTool.doMouseMove()}doMouseUp(){this.currentTool.doMouseUp()}doMouseWheel(){this.currentTool.doMouseWheel()}doKeyDown(){this.currentTool.doKeyDown()}doKeyUp(){this.currentTool.doKeyUp()}doFocus(){this.focus()}focus(){if(this.xt)if(this.scrollsPageOnFocus)this.xt.focus();else{const t=root.scrollX,i=root.scrollY;this.xt.focus(),root.scrollTo(t,i)}}lR(t){const i=Diagram.He.get(this);i&&i.B("GainedFocus")}rR(t){const i=Diagram.He.get(this);i&&i.B("LostFocus")}RM(){if(this.xt===null)return;const i=this.Ot;if(i===null||i.clientWidth===0||i.clientHeight===0)return;this.WM||this.setScrollWidth();const e=this.to?this.yi:0,s=this.xn?this.yi:0,n=this.Gi;if(this.Gi=this.computePixelRatio(),this.Gi!==n&&(this.Xu=!0,this.requestUpdate()),i.clientWidth!==this.Ct+e||i.clientHeight!==this.At+s){this.fa(),this.Ge=!0;const o=this.layout;o!==null&&o.isViewportSized&&this.autoScale===1&&(this.Uf=!0,o.invalidateLayout()),this.ks||this.requestUpdate()}}wA(){let t=0,i=new Layer;i.name="Grid",i.allowSelect=!1,i.pickable=!1,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="ViewportBackground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="Background",this.Jr(i,t++),i=new Layer,i.name="",this.Jr(i,t++),i=new Layer,i.name="Foreground",this.Jr(i,t++),i=new Layer,i.name="ViewportForeground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="Adornment",i.isTemporary=!0,i.isInDocumentBounds=!1,this.Jr(i,t++),i=new Layer,i.name="Tool",i.isTemporary=!0,i.isInDocumentBounds=!0,this.Jr(i,t++)}PA(){const t=new Panel(Panel.Grid,{name:"GRID"}).add(new Shape("LineH",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineV",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineH",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineH",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor")),i=new Part({layerName:"Grid",zOrder:0,isInDocumentBounds:!1,isAnimated:!1,pickable:!1,locationObjectName:"GRID"}).add(t);return this.add(i),this.partManager.parts.delete(i),t.visible=!1,t}static JF(){const t=Diagram.He.get(this.parentElement||this);if(t){if(t.s1){t.s1=!1;return}if(!t.isEnabled){t.NA();return}t.diagramScroll(this)}}static ZF(t){if(!this.b.isEnabled){this.b.updateScroll();return}this.b.o1=t.target.scrollTop,this.b.l1=t.target.scrollLeft}diagramScroll(t){if(this.xt===null)return;const i=this.g1,e=this.m1;this.Jm=!0;let s=this.documentBounds,n=this.viewportBounds;const o=this.Xf;let r=s.x-o.left,l=s.y-o.top;const h=s.width+o.left+o.right,a=s.height+o.top+o.bottom;let f=s.right+o.right,c=s.bottom+o.bottom,u=n.x,d=n.y;const m=n.width,g=n.height;let p=n.right,y=n.bottom;const x=this.scale;let k,b=t.scrollLeft;if(this.vu)switch(this.Cx){case"negative":b=b+t.scrollWidth-t.clientWidth;break;case"reverse":b=t.scrollWidth-b-t.clientWidth;break}const S=b;if(mp)){const M=i.scrollWidth-this.Ct;this.position=k.e(-M+S-this.Ct/x+f,this.position.y)}if(t.QF&&this.allowVerticalScroll&&(ly)){const M=i.scrollHeight-this.At;this.position=k.e(this.position.x,-M+t.scrollTop-this.At/x+c)}Point.o(k),this.sh(),this.Jm=!1,this.Gu=!1,s=this.documentBounds,n=this.viewportBounds,f=s.right,p=n.right,c=s.bottom,y=n.bottom,r=s.x,u=n.x,l=s.y,d=n.y,m>=h&&r>=u&&f<=p&&(e.style.width="1px"),g>=a&&l>=d&&c<=y&&(e.style.height="1px")}computeBounds(t){return t===void 0&&(t=new Rect),this.Di(),this.CA(t)}CA(t){if(this.fixedBounds.isReal())return t.c(this.fixedBounds),t.addMargin(this.ii),t;let i=!0;const e=this.Jt.h,s=e.length;for(let n=0;ni&&(a=i),athis.maxScale&&(a=this.maxScale),a):t===3?(a=0,h>l?a=(r-this.yi)/n:a=(o-this.yi)/s,a>i&&(a=i),athis.maxScale&&(a=this.maxScale),a):this.scale}zoomToFit(){const t=this.Jh;this.Jh=1,this.scale=this.Zu(2),t!==1&&(this.Gs(!1),this.CP(this.documentBounds,this.Ct/this.rt,this.At/this.rt,this.Yf,!1)),this.Jh=t}zoomToRect(t,i){i===void 0&&(i=2);const e=t.width,s=t.height;if(e===0||s===0||isNaN(e)&&isNaN(s))return;let n=1;if(i===2||i===3)if(isNaN(e))n=this.viewportBounds.height*this.scale/s;else if(isNaN(s))n=this.viewportBounds.width*this.scale/e;else{const o=this.Ct,r=this.At;i===3?r/s>o/e?n=(r-(this.xn?this.yi:0))/s:n=(o-(this.to?this.yi:0))/e:n=Math.min(r/s,o/e)}this.scale=n,this.position=new Point(t.x,t.y)}get hR(){return this.$t}set hR(t){this.$t=t}alignDocument(t,i){this.ensureBounds();const e=this.documentBounds,s=this.viewportBounds;this.position=new Point(e.x+(t.x*e.width+t.offsetX)-(i.x*s.width-i.offsetX),e.y+(t.y*e.height+t.offsetY)-(i.y*s.height-i.offsetY))}focusObject(t){if(t instanceof GraphObject){this.h0=t;const i=Point.a();this.a0=this.transformDocToView(t.getDocumentPoint(Spot.TopLeft,i)),Point.o(i)}else this.h0=null,this.a0=Point.Bk}CP(t,i,e,s,n){const o=Point.H(this.gt.x,this.gt.y);let r=o.x,l=o.y;if(this.h0!==null){let h=Point.a();h=this.h0.getDocumentPoint(Spot.TopLeft,h),r=h.x-this.a0.x/this.scale,l=h.y-this.a0.y/this.scale,s=Spot.None,Point.o(h)}if(n||this.scrollMode===1){s.isSpot()&&(i>t.width&&(r=t.x+(s.x*t.width+s.offsetX)-(s.x*i-s.offsetX)),e>t.height&&(l=t.y+(s.y*t.height+s.offsetY)-(s.y*e-s.offsetY)));const h=this.Xf,a=i-t.width;if(it.left?r=t.left:rt.top?l=t.top:ls.part,s=>s.canSelect());if(e instanceof Part)return e}else{const e=this.DS(t,s=>s.part);if(e instanceof Part)return e}return null}findObjectAt(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Di();const s=this.Jt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}DS(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Di();const s=this.Jt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible||n.isTemporary)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}findPartsAt(t,i,e){return i===void 0&&(i=!0),this.fR(t,s=>s.part,i?s=>s instanceof Part&&s.canSelect():null,e)}fR(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Di();const n=this.Jt.iteratorBackwards;for(;n.next();){const o=n.value;!o.visible||o.isTemporary||o.findObjectsAt(t,i,e,s)}return s}findObjectsAt(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Di();const n=this.Jt.iteratorBackwards;for(;n.next();){const o=n.value;o.visible&&o.findObjectsAt(t,i,e,s)}return s}findPartsIn(t,i,e,s){return i===void 0&&(i=!1),e===void 0&&(e=!0),this.cR(t,null,n=>n instanceof Part&&(!e||n.canSelect()),i,s)}findObjectsIn(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Di();const o=this.Jt.iteratorBackwards;for(;o.next();){const r=o.value;r.visible&&r.findObjectsIn(t,i,e,s,n)}return n}IS(t,i,e,s,n,o){const r=new GSet;this.Di();const l=this.Jt.iteratorBackwards;for(;l.next();){const h=l.value;h.visible&&h.IS(t,i,e,s,r,n,o)}return r}cR(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Di();const o=this.Jt.iteratorBackwards;for(;o.next();){const r=o.value;!r.visible||r.isTemporary||r.findObjectsIn(t,i,e,s,n)}return n}findPartsNear(t,i,e,s,n){return e===void 0&&(e=!0),s===void 0&&(s=!0),this.uR(t,i,null,o=>o instanceof Part&&(!s||o.canSelect()),e,n)}findObjectsNear(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Di();const r=this.Jt.iteratorBackwards;for(;r.next();){const l=r.value;l.visible&&l.findObjectsNear(t,i,e,s,n,o)}return o}uR(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Di();const r=this.Jt.iteratorBackwards;for(;r.next();){const l=r.value;!l.visible||l.isTemporary||l.findObjectsNear(t,i,e,s,n,o)}return o}acceptEvent(t){return this.Jf(t,t instanceof MouseEvent)}Jf(t,i){const e=this.jr;this.jr=this.ta,this.ta=e,e.diagram=this,e.event=t,i?this.c0(t,e):(e.viewPoint=this.jr.viewPoint,e.documentPoint=this.jr.documentPoint);let s=0;const n=t;return n.ctrlKey&&(s+=1),n.altKey&&(s+=2),n.shiftKey&&(s+=4),n.metaKey&&(s+=8),e.modifiers=s,e.button=n.button,n.buttons!==void 0&&(e.buttons=n.buttons),Util.cr&&n.button===0&&n.ctrlKey&&(e.button=2),e.down=!1,e.up=!1,e.clickCount=1,e.delta=0,e.handled=!1,e.bubbles=!1,e.timestamp=t.timeStamp,e.isMultiTouch=!1,e.targetDiagram=this.NP(t,t.target),e.targetObject=null,e}NP(t,i){if(i===null)return null;const e=Diagram.He.get(i);if(e)return e;let s=t.path;if(!s&&typeof t.composedPath=="function"&&(s=t.composedPath()),s&&s[0]){const n=Diagram.He.get(s[0]);if(n)return n}return null}_F(t,i,e){const s=this.PP(t,!0,!1,!1,!0,e);return this.c0(i,s),s.targetDiagram=this.NP(t,t.target),s.targetObject=null,e||s.clone(this.i0),s}tR(t,i,e){const s=this.PP(t,!1,!1,!1,!1,e);let n=root.document.elementFromPoint(i.clientX,i.clientY)||null;n!==null&&n.shadowRoot!==void 0&&n.shadowRoot!==null&&(n=n.shadowRoot.elementFromPoint(i.clientX,i.clientY));let o=this,r=t;if(n){const l=Diagram.He.get(n);l&&(r=i,o=l)}return s.targetDiagram=o,this.c0(r,s),s.targetObject=null,s}PP(t,i,e,s,n,o){const r=this.jr;this.jr=this.ta,this.ta=r,r.diagram=this,r.clickCount=1,r.delta=0;let l=0;return t.ctrlKey&&(l+=1),t.altKey&&(l+=2),t.shiftKey&&(l+=4),t.metaKey&&(l+=8),r.modifiers=l,r.event=t,r.timestamp=t.timeStamp,r.button=e?this.firstInput.button:t.button,r.buttons=t.buttons,Util.cr&&t.button===0&&t.ctrlKey&&(r.button=2),r.down=i,r.up=e,r.handled=s,r.bubbles=n,r.isMultiTouch=o,r}aa(t,i){return t.bubbles?(Debug&&Debug.handleMessages&&Util.ht("NOT handled "+i.type+" "+t.toString()),!0):(Debug&&Debug.handleMessages&&Util.ht("handled "+i.type+" "+this.currentTool.name+" "+t.toString()),i.stopPropagation!==void 0&&i.stopPropagation(),i.cancelable!==!1&&i.preventDefault(),i.cancelBubble=!0,!1)}nR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.Jf(t,!1);return e.key=t.key,e.code=t.code,e.down=!0,i.doKeyDown(),i.aa(e,t)}oR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.Jf(t,!1);return e.key=t.key,e.code=t.code,e.up=!0,i.doKeyUp(),i.aa(e,t)}eR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.Jf(t,!0);return i.mouseEnter!==null&&i.mouseEnter(e),i.currentTool.standardMouseOver(),i.aa(e,t)}sR(t){const i=Diagram.He.get(this);if(!i||!i.isEnabled)return!1;const e=i.Jf(t,!0);return i.mouseLeave!==null&&i.mouseLeave(e),i.aa(e,t)}getMouse(t){const i=this.xt;if(i===null)return new Point(0,0);const e=i.getBoundingClientRect(),s=(t.clientX-e.left)*(this.Ct/e.width),n=(t.clientY-e.top)*(this.At/e.height);return new Point(s,n).Ye(this.O)}c0(t,i){const e=this.xt;let s=0,n=0;if(e!==null){const r=e.getBoundingClientRect();s=(t.clientX-r.left)*(this.Ct/r.width),n=(t.clientY-r.top)*(this.At/r.height)}i.viewPoint.e(s,n);const o=Point.H(s,n);this.O.ns(o),i.documentPoint.c(o),Point.o(o)}LC(t,i,e){let s;if(this.sa[0]!==null)s=this.sa[i];else return;const n=this.xt;if(n!==null){const o=n.getBoundingClientRect();e.e((s.clientX-o.left)*(this.Ct/o.width),(s.clientY-o.top)*(this.At/o.height))}}invalidateDocumentBounds(){this.ia||(this.ia=!0,this.requestUpdate(!1))}dR(){this.ks||this.Di(),this.ensureBounds()}redraw(){this.$t||this.ks||(this.T(),this.maybeUpdate())}isUpdateRequested(){return this.Ar}delayInitialization(t){t===void 0&&(t=null);const i=this.animationManager,e=i.isEnabled;i.stopAnimation(),i.isEnabled=!1,this.Sr(),this.io=!1,this.fx=new Point(NaN,NaN),i.isEnabled=e,this.ks=!0;const s=this;t!==null&&Util.zh(()=>{s.ks=!1,i.El("Model"),t(s)},1)}requestUpdate(t){if(t===void 0&&(t=!1),this.Ar===!0||this.$t||t===!1&&this.ks)return;this.Ar=!0;const i=this;root.requestAnimationFrame(()=>{i.Ar&&i.maybeUpdate()})}maybeUpdate(){this.Yu&&!this.Ar||(this.Yu&&(this.Yu=!1),this.Sr())}AP(t,i){!this.Gu||this.$t||this.animationManager.defaultAnimation.isAnimating||this.NA()||(t&&this.Di(),i&&this.Gs(!1))}Sr(t){if(this.ks||(this.Ar=!1,this.Ot===null&&!this.Hu.isReal()))return;this.ks=!0;const i=this.animationManager,e=this.Wu;if(!i.isAnimating&&e.length!==0){const f=e.h,c=f.length;for(let u=0;u0&&(s.each(f=>f.LP()),s.clear());let n=!1,o=!1;i.defaultAnimation.isAnimating&&(o=!0,n=this.skipsUndoManager,this.skipsUndoManager=!0),i.Si||this.RM(),t||this.AP(!1,!0);const r=!this.undoManager.isUndoingRedoing&&(this.Pl||this.vf.count!==0&&this.Rr.size!==0),l=!this.io||this.Wr;this.Di(!0);let h=!1;(l||r)&&(this.io?this.TP(!this.Uf,r):(this.startTransaction("Initial Layout"),i.isEnabled===!1&&i.stopAnimation(),this.TP(!1,r)),h=l),this.Uf=!1,this.Pl=!1,this.Di(),this.os!==null&&(this.os.visible&&!this._m&&(this.Zr(),this._m=!0),!this.os.visible&&this._m&&(this._m=!1)),this.qx||this.dR(),t||this.AP(!0,!1);let a=!1;if(h){const f=Rect.a();f.c(this.viewportBounds),this.io||(this.io=!0,a=!0,this.skipsUndoManager||(this.undoManager.Uw=!0),this.undoManager.Gw=!0,this.gR()),this.mR(),this.Di(!1),t||this.AP(!0,!0),Rect.o(f)}else if(i.Ff&&i.ax){if(this.Fr!==1)this.scale=this.Zu(this.Fr);else if(this.Jl!==1)this.scale=this.Zu(this.Jl);else{const f=this.initialScale;isFinite(f)&&f>0&&(this.scale=f)}this.Gs(!0)}h&&a&&this.commitTransaction("Initial Layout"),t||this.Ji(this.ei),o&&(this.skipsUndoManager=n),this.ks=!1}get Kh(){return this.io}gR(){if(this.Fr!==1)this.scale=this.Zu(this.Fr);else if(this.Jl!==1)this.scale=this.Zu(this.Jl);else{const i=this.initialScale;isFinite(i)&&i>0&&(this.scale=i)}this.Gs(!0);const t=this.Jt.h;this.Us(t,t.length,this,this.viewportBounds),this.B("InitialLayoutCompleted"),this.fx.c(this.gt),this.Zr()}mR(){this.B("LayoutCompleted")}u0(t){this.Qn.add(t)}addInvalidRoute(t){this.Bo?this.Qh.add(t):this.Rr.add(t)}Di(t){if(this.Qn.size!==0&&!(!this.ks&&this.animationManager.isTicking)){if(this.ks||(this.Pl=!0),t){this.AA(this.Qn);return}for(let i=0;i<23&&this.Qn.size!==0;i++){const e=new Set(this.Qn);this.Qn.clear(),this.LP(e,this.Qn),Debug&&i===22&&Util.ht("failure to validate parts")}this.nodes.each(i=>{i instanceof Group&&i.LA(!1)})}}AA(t,i){for(const e of t)!e.Ae()||e instanceof Group||(e.$r()?(e.wt(1/0,1/0),e.qt()):i&&i.add(e));for(const e of t)if(e instanceof Group){if(!e.isVisible())continue;this.T1(e)}}LP(t,i){this.AA(t,i);for(const e of t){if(!(e instanceof Link))continue;const s=e;s.isVisible()&&(s.$r()?(s.wt(1/0,1/0),s.qt()):i.add(s))}for(const e of t)e instanceof Adornment&&e.isVisible()&&(e.$r()?(e.wt(1/0,1/0),e.qt()):i.add(e))}d0(t){const i=t instanceof Diagram,e=i?t.links:t.memberParts,s=this.Qn;if(i)this.Di(!0);else{for(;e.next();){const n=e.value;s.has(n)&&(!n.Ae()||n instanceof Group||n.$r()&&(n.wt(1/0,1/0),n.qt()))}for(e.reset();e.next();){const n=e.value;if(s.has(n)&&n instanceof Group){if(!n.isVisible())continue;this.T1(n)}}e.reset()}for(;e.next();){const n=e.value;n instanceof Link&&s.has(n)&&n.isVisible()&&n.$r()&&(n.wt(1/0,1/0),n.qt())}}T1(t){const i=Util.at(),e=Util.at(),s=t.memberParts;for(;s.next();){const o=s.value;o.isVisible()&&(o instanceof Group?(o.Xo()||o.rs()||o.nh())&&this.T1(o):o instanceof Link?o.fromNode===t||o.toNode===t?e.push(o):i.push(o):(o.wt(1/0,1/0),o.qt()))}let n=i.length;for(let o=0;ob.Vu())}else for(let x=0;x0){const a=n.substring(0,h);e?o=t.findObject(a):(o=t[a],o==null&&(o=t.toolManager[a])),Util.Mt(o)?r=n.substring(h+1):Util.n("Unable to find object named: "+a+" in "+t.toString()+" when trying to set property: "+n)}}if(r[0]!=="_"&&!Util.yw(o,r))if(s&&r==="ModelChanged"){t.addModelChangedListener(i[r]);continue}else if(s&&r==="Changed"){t.addChangedListener(i[r]);continue}else if(s&&Util.yw(t.toolManager,r))o=t.toolManager;else if(s&&t.TA(r)){t.addDiagramListener(r,i[r]);continue}else if(t instanceof Model&&r==="Changed"){t.addChangedListener(i[r]);continue}else Util.n('Trying to set undefined property "'+r+'" on object: '+o.toString());const l=i[n];o[r]=l,r[0]==="_"&&o instanceof GraphObject&&o.addCopyProperty(r)}}rA(){if(this.th.count!==0&&!(this.undoManager.transactionLevel>1)){for(;this.th.count>0;){const t=this.th;this.th=new GMap;const i=t.iterator;for(;i.next();){const e=i.key;e.invalidateOtherJumpOvers(i.value),e.le()}}this.T()}}T(t){if(t===void 0)this.Ge=!0,this.requestUpdate();else{const i=this.viewportBounds;t.isReal()&&i.intersectsRect(t)&&(this.Ge=!0,this.requestUpdate())}this.B("InvalidateDraw")}invalidateViewport(t,i){if(this.Ge===!0)return;if(this.Ge=!0,this.Gf==="svg"){this.maybeUpdate();return}this.getRenderingHint("temporaryPixelRatio")===!0?(this.jw(),this.maybeUpdate(),this.NS(!0)):this.maybeUpdate()}fa(){this.Gu=!0}sh(){this.Hf=!0}g0(){this.Xu!==!1&&(this.Xu=!1,this.MA(this.Ct,this.At))}MA(t,i){this.eh();const e=this.Gi,s=t*e,n=i*e;this.xt.resize(s,n,t,i)&&(this.Ge=!0,this.ei.clearContextCache(!0))}NA(){const t=this.xt;if(t===null||this.Hu.isReal())return!0;const i=this.Ct,e=this.At,s=this.Ot;let n=!1,o=this.to?this.yi:0,r=this.xn?this.yi:0,l=s.clientWidth||i+o,h=s.clientHeight||e+r;const a=this.viewportBounds,f=a.x,c=a.y,u=a.width,d=a.height;if((l!==i+o||h!==e+r)&&(this.to=!1,this.xn=!1,o=0,r=0,this.Ct=l,this.At=h,this.Xu=!0,n=!0,this.eh()),!this.io||!this.viewportBounds.isReal())return!0;const m=this.g1,g=this.m1;if(this.Gu=!1,!n&&!this.to&&!this.xn&&!this.Ku&&!this.Uu)return!0;const p=this.documentBounds;let y=0,x=0,k=0,b=0;const S=a.width,M=a.height,A=this.Xf;this.contentAlignment.isSpot()?(p.width>S&&(y=A.left,x=A.right),p.height>M&&(k=A.top,b=A.bottom)):(y=A.left,x=A.right,k=A.top,b=A.bottom);const C=p.width+y+x,P=p.height+k+b,N=this.scale,T=N;let L=C>l/N,D=P>h/N;if(!n&&!this.to&&!this.xn&&!L&&!D)return!0;const F=p.x-y,R=a.x,I=p.right+x;let O=a.right+o;const V=p.y-k,K=a.y,B=p.bottom+b;let X=a.bottom+r,z="1px",G="1px";if(this.scrollMode===1&&(L||D)){if(L&&this.hasHorizontalScrollbar&&this.allowHorizontalScroll){let Y=1;F+1O+1&&(Y=Math.max((I-O)*N+this.Ct,Y)),S+o+1X+1&&(Y=Math.max((B-X)*N+this.At,Y)),M+r+1O+1&&(v=Math.max((I-O)*N+this.Ct,v)),S+1X+1&&(v=Math.max((B-X)*N+Y,v)),M+1O+1&&(J=this.position.x*N)),this.vu)switch(this.Cx){case"negative":J=-(m.scrollWidth-J-m.clientWidth);break;case"reverse":J=m.scrollWidth-J-m.clientWidth;break}if(m.scrollLeft=J,this.hasVerticalScrollbar&&this.allowVerticalScroll&&(M+1X+1&&(m.scrollTop=this.position.y*N)),l=this.Ct,h=this.At,m.style.width=l+(this.to?this.yi:0)+"px",m.style.height=h+(this.xn?this.yi:0)+"px",i!==l||e!==h||this.animationManager.Si){const Y=Rect.H(f,c,u,d);return this.onViewportBoundsChanged(Y,this.viewportBounds,T,n),Rect.o(Y),!1}return!0}add(t){Util.s(t,Part,Diagram,"add:part");const i=t.diagram;if(i===this)return;i!==null&&Util.n("Cannot add part "+t.toString()+" to "+this.toString()+". It is already a part of "+i.toString());let e=this.findLayer(t.layerName);if(e===null&&(e=this.findLayer("")),e===null&&Util.n('Cannot add a Part when unable find a Layer named "'+t.layerName+'" and there is no default Layer'),t.layer===e)return;const s=e.$h(99999999,t,t.diagram===this);s>=0&&this.raiseChangedEvent(3,"parts",e,null,t,null,s),e.isTemporary||this.invalidateDocumentBounds(),t.invalidateLayout(1);const n=t.layerChanged;n!==null&&n(t,null,e)}$h(t){this.partManager.$h(t);const i=this;t.Qr(s=>i.DA(s)),t.data||t.Yo(),t.hasPlaceholder()&&t.u(),t.data!==null&&t.Qr(s=>i.partManager.FP(s,null)),(t.rs()===!0||t.nh()===!0)&&this.u0(t),t.FA(!0,this),t.RA()?(t.actualBounds.isReal()&&this.T(t.Zh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.T(t.Zh(t.actualBounds)),this.requestUpdate()}oe(t){t.clearAdornments(),this.partManager.oe(t);const i=this;t.data!==null&&t.Qr(s=>i.partManager.RP(s,i)),this.Qn.delete(t),t instanceof Link&&this.Rr.delete(t),t.RA()?(t.actualBounds.isReal()&&this.T(t.Zh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.T(t.Zh(t.actualBounds)),this.requestUpdate()}remove(t){Util.s(t,Part,Diagram,"remove:part"),this.IP(t,!0)}IP(t,i){const e=t.layer;if(e===null||e.diagram!==this)return;t.isSelected=!1,t.isHighlighted=!1,t.invalidateLayout(2),i&&t.Zf();const s=e.oe(-1,t,!1);s>=0&&this.raiseChangedEvent(4,"parts",e,t,null,s,null);const n=t.layerChanged;n!==null&&n(t,e,null)}removeParts(t,i){if(i===void 0&&(i=!1),Array.isArray(t)){const e=t.length;for(let s=0;s=0&&i.elt(e).isTemporary;)e--;return i.insertAt(e+1,t),this.Ai!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,e+1),this.T(),this.invalidateDocumentBounds(),this}addLayerBefore(t,i){this.OP(t,i),t.Oo(this);const e=this.Jt,s=e.indexOf(t);s>=0&&(e.delete(t),this.Ai!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;o=0&&(e.delete(t),this.Ai!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;othis.maxScale&&(i=this.maxScale);const f=Point.H(this.gt.x+l/t-l/i,this.gt.y+h/t-h/i);this.position=f,Point.o(f),this.rt=i,this.eh(),this.$t=!1,this.onViewportBoundsChanged(n,this.viewportBounds,t,!1),this.Gs(!1),e.nA(t,this.rt),this.T()}aR(){const t=this.Jt.h;for(let i=0;i{r.isAvoiding&&r.actualBounds.intersectsRect(i)&&r.invalidateRoute()})}Zr(t){const i=this.os;if(i===null||!i.visible||i.layer===null)return;const e=t!==void 0?t:this.a1;if(!e.isReal())return;const s=e.width,n=e.height;if(i.scale=1,i.angle=0,i.layer.isViewportAligned)i.width=s*this.scale,i.height=n*this.scale,i.part.alignment=Spot.TopLeft;else{i.Mi===null&&(i.Mi=new GridPanelSettings);const o=i.Mi.$f;if(!o.isReal())return;i.width=s+o.width*2,i.height=n+o.height*2;const r=Point.a();Geo.Gg(e.x,e.y,0,0,o.width,o.height,r),r.offset(-o.width,-o.height),i.part.location=r,Point.o(r)}}clearSelection(t){t===void 0&&(t=!1);const i=this.selection;if(i.count===0)return;t||this.B("ChangingSelection",i);const e=i.toArray(),s=e.length;for(let n=0;n1)&&(this.B("ChangingSelection",this.selection),this.clearSelection(!0),t.isSelected=!0,this.B("ChangedSelection",this.selection)))}selectCollection(t){if(this.B("ChangingSelection",this.selection),this.clearSelection(!0),Array.isArray(t)){const i=t.length;for(let e=0;e0){const i=t.toArray(),e=i.length;for(let s=0;s1)&&(this.clearHighlighteds(),t.isHighlighted=!0))}highlightCollection(t){const i=new GSet().addAll(t),s=this.highlighteds.copy().removeAll(i).iterator;for(;s.next();){const o=s.value;o.isHighlighted=!1}const n=i.iterator;for(;n.next();){const o=n.value;o instanceof Part||Util.n("Diagram.highlightCollection given something that is not a Part: "+o),o.isHighlighted=!0}}scroll(t,i,e){e===void 0&&(e=1);const s=i==="up"||i==="down";let n=0;const o=Point.a();if(t==="pixel")n=e;else if(t==="line")n=e*(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange);else if(t==="page"){let l=s?this.viewportBounds.height:this.viewportBounds.width;if(l*=this.scale,l!==0){const h=Math.max(l-(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange),0);n=e*h}}else if(t==="document"){const l=this.documentBounds,h=this.viewportBounds;i==="up"?this.position=o.e(h.x,l.y):i==="left"?this.position=o.e(l.x,h.y):i==="down"?this.position=o.e(h.x,l.bottom-h.height):i==="right"&&(this.position=o.e(l.right-h.width,h.y)),Point.o(o);return}else Util.n("scrolling unit must be 'pixel', 'line', 'page', or 'document', not: "+t);n/=this.scale;const r=this.position;i==="up"?this.position=o.e(r.x,r.y-n):i==="down"?this.position=o.e(r.x,r.y+n):i==="left"?this.position=o.e(r.x-n,r.y):i==="right"?this.position=o.e(r.x+n,r.y):Util.n("scrolling direction must be 'up', 'down', 'left', or 'right', not: "+i),Point.o(o)}scrollToRect(t){const i=this.viewportBounds;if(i.containsRect(t))return;const e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}centerRect(t){const i=this.viewportBounds,e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}transformDocToView(t){return t.copy().O(this.O)}transformViewToDoc(t){return t.copy().Ye(this.O)}EF(t){return t.Ye(this.O)}static None=1;static Uniform=2;static UniformToFill=3;static CycleAll=1;static CycleNotDirected=2;static CycleNotDirectedFast=3;static CycleNotUndirected=4;static CycleDestinationTree=5;static CycleSourceTree=6;static DocumentScroll=1;static InfiniteScroll=2;static TreeParentCollapsed=1;static AllParentsCollapsed=2;static AnyParentsCollapsed=3;get opacity(){return this._t}set opacity(t){const i=this._t;i!==t&&(Util.t(t,"number",Diagram,"opacity"),(t<0||t>1)&&Util.G(t,"0 <= value <= 1",Diagram,"opacity"),this._t=t,this.i("opacity",i,t),this.T())}get validCycle(){return this.Yx}set validCycle(t){const i=this.Yx;i!==t&&(Util.tt(t,CycleMode,"CycleMode"),this.Yx=t,this.i("validCycle",i,t))}get layers(){return this.Jt.iterator}get isModelReadOnly(){const t=this.Ai;return t===null?!1:t.isReadOnly}set isModelReadOnly(t){const i=this.Ai;i!==null&&(i.isReadOnly=t)}get isReadOnly(){return this.zo}set isReadOnly(t){const i=this.zo;i!==t&&(Util.t(t,"boolean",Diagram,"isReadOnly"),this.zo=t,this.i("isReadOnly",i,t))}get isEnabled(){return this.Xi}set isEnabled(t){const i=this.Xi;i!==t&&(Util.t(t,"boolean",Diagram,"isEnabled"),this.Xi=t,this.i("isEnabled",i,t))}get allowClipboard(){return this.Wx}set allowClipboard(t){const i=this.Wx;i!==t&&(Util.t(t,"boolean",Diagram,"allowClipboard"),this.Wx=t,this.i("allowClipboard",i,t))}get allowCopy(){return this.Bl}set allowCopy(t){const i=this.Bl;i!==t&&(Util.t(t,"boolean",Diagram,"allowCopy"),this.Bl=t,this.i("allowCopy",i,t))}get allowDelete(){return this.Vl}set allowDelete(t){const i=this.Vl;i!==t&&(Util.t(t,"boolean",Diagram,"allowDelete"),this.Vl=t,this.i("allowDelete",i,t))}get allowDragOut(){return this.vx}set allowDragOut(t){const i=this.vx;i!==t&&(Util.t(t,"boolean",Diagram,"allowDragOut"),this.vx=t,this.i("allowDragOut",i,t))}get allowDrop(){return this.Jx}set allowDrop(t){const i=this.Jx;i!==t&&(Util.t(t,"boolean",Diagram,"allowDrop"),this.Jx=t,this.i("allowDrop",i,t))}get allowTextEdit(){return this.zl}set allowTextEdit(t){const i=this.zl;i!==t&&(Util.t(t,"boolean",Diagram,"allowTextEdit"),this.zl=t,this.i("allowTextEdit",i,t))}get allowGroup(){return this.Xl}set allowGroup(t){const i=this.Xl;i!==t&&(Util.t(t,"boolean",Diagram,"allowGroup"),this.Xl=t,this.i("allowGroup",i,t))}get allowUngroup(){return this.Yl}set allowUngroup(t){const i=this.Yl;i!==t&&(Util.t(t,"boolean",Diagram,"allowUngroup"),this.Yl=t,this.i("allowUngroup",i,t))}get allowInsert(){return this.Zx}set allowInsert(t){const i=this.Zx;i!==t&&(Util.t(t,"boolean",Diagram,"allowInsert"),this.Zx=t,this.i("allowInsert",i,t))}get allowLink(){return this.Kl}set allowLink(t){const i=this.Kl;i!==t&&(Util.t(t,"boolean",Diagram,"allowLink"),this.Kl=t,this.i("allowLink",i,t))}get allowRelink(){return this.Ul}set allowRelink(t){const i=this.Ul;i!==t&&(Util.t(t,"boolean",Diagram,"allowRelink"),this.Ul=t,this.i("allowRelink",i,t))}get allowMove(){return this.Gl}set allowMove(t){const i=this.Gl;i!==t&&(Util.t(t,"boolean",Diagram,"allowMove"),this.Gl=t,this.i("allowMove",i,t))}get allowReshape(){return this.Hl}set allowReshape(t){const i=this.Hl;i!==t&&(Util.t(t,"boolean",Diagram,"allowReshape"),this.Hl=t,this.i("allowReshape",i,t))}get allowResize(){return this.ql}set allowResize(t){const i=this.ql;i!==t&&(Util.t(t,"boolean",Diagram,"allowResize"),this.ql=t,this.i("allowResize",i,t))}get allowRotate(){return this.jl}set allowRotate(t){const i=this.jl;i!==t&&(Util.t(t,"boolean",Diagram,"allowRotate"),this.jl=t,this.i("allowRotate",i,t))}get allowSelect(){return this.Wl}set allowSelect(t){const i=this.Wl;i!==t&&(Util.t(t,"boolean",Diagram,"allowSelect"),this.Wl=t,this.i("allowSelect",i,t))}get allowUndo(){return this.$x}set allowUndo(t){const i=this.$x;i!==t&&(Util.t(t,"boolean",Diagram,"allowUndo"),this.$x=t,this.i("allowUndo",i,t))}get allowZoom(){return this.Qx}set allowZoom(t){const i=this.Qx;i!==t&&(Util.t(t,"boolean",Diagram,"allowZoom"),this.Qx=t,this.i("allowZoom",i,t))}get hasVerticalScrollbar(){return this.Uu}set hasVerticalScrollbar(t){const i=this.Uu;i!==t&&(Util.t(t,"boolean",Diagram,"hasVerticalScrollbar"),this.Uu=t,this.fa(),this.T(),this.i("hasVerticalScrollbar",i,t),this.Gs(!1))}get hasHorizontalScrollbar(){return this.Ku}set hasHorizontalScrollbar(t){const i=this.Ku;i!==t&&(Util.t(t,"boolean",Diagram,"hasHorizontalScrollbar"),this.Ku=t,this.fa(),this.T(),this.i("hasHorizontalScrollbar",i,t),this.Gs(!1))}get allowHorizontalScroll(){return this._x}set allowHorizontalScroll(t){const i=this._x;i!==t&&(Util.t(t,"boolean",Diagram,"allowHorizontalScroll"),this._x=t,this.i("allowHorizontalScroll",i,t),this.Gs(!1))}get allowVerticalScroll(){return this.t1}set allowVerticalScroll(t){const i=this.t1;i!==t&&(Util.t(t,"boolean",Diagram,"allowVerticalScroll"),this.t1=t,this.i("allowVerticalScroll",i,t),this.Gs(!1))}get scrollHorizontalLineChange(){return this.i1}set scrollHorizontalLineChange(t){const i=this.i1;i!==t&&(Util.t(t,"number",Diagram,"scrollHorizontalLineChange"),t<0&&Util.G(t,">= 0",Diagram,"scrollHorizontalLineChange"),this.i1=t,this.i("scrollHorizontalLineChange",i,t))}get scrollVerticalLineChange(){return this.e1}set scrollVerticalLineChange(t){const i=this.e1;i!==t&&(Util.t(t,"number",Diagram,"scrollVerticalLineChange"),t<0&&Util.G(t,">= 0",Diagram,"scrollVerticalLineChange"),this.e1=t,this.i("scrollVerticalLineChange",i,t))}get lastInput(){return this.ta}set lastInput(t){Debug&&Util.s(t,InputEvent,Diagram,"lastInput"),this.ta=t}get previousInput(){return this.jr}set previousInput(t){Debug&&Util.s(t,InputEvent,Diagram,"previousInput"),this.jr=t}get firstInput(){return this.i0}set firstInput(t){Debug&&Util.s(t,InputEvent,Diagram,"firstInput"),this.i0=t}get currentCursor(){return this.Kx}set currentCursor(t){if(t===""&&(t=this.vm),this.Kx!==t){Util.t(t,"string",Diagram,"currentCursor");const e=this.xt,s=this.Ot;if(e===null||s===null)return;this.Kx=t;const n=e.style.cursor;e.style.cursor=t,s.style.cursor=t,e.style.cursor===n&&(e.style.cursor="-webkit-"+t,s.style.cursor="-webkit-"+t,e.style.cursor===n&&(e.style.cursor="-moz-"+t,s.style.cursor="-moz-"+t,e.style.cursor===n&&(e.style.cursor=t,s.style.cursor=t)))}}get defaultCursor(){return this.vm}set defaultCursor(t){t===""&&(t="auto");const i=this.vm;i!==t&&(Util.t(t,"string",Diagram,"defaultCursor"),this.vm=t,this.i("defaultCursor",i,t))}get click(){return this.Or}set click(t){const i=this.Or;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"click"),this.Or=t,this.i("click",i,t))}get doubleClick(){return this.Er}set doubleClick(t){const i=this.Er;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"doubleClick"),this.Er=t,this.i("doubleClick",i,t))}get contextClick(){return this.Br}set contextClick(t){const i=this.Br;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"contextClick"),this.Br=t,this.i("contextClick",i,t))}get mouseOver(){return this.Vr}set mouseOver(t){const i=this.Vr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseOver"),this.Vr=t,this.i("mouseOver",i,t))}get mouseHover(){return this.zr}set mouseHover(t){const i=this.zr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseHover"),this.zr=t,this.i("mouseHover",i,t))}get mouseHold(){return this.Xr}set mouseHold(t){const i=this.Xr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseHold"),this.Xr=t,this.i("mouseHold",i,t))}get mouseDragOver(){return this.Ux}set mouseDragOver(t){const i=this.Ux;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseDragOver"),this.Ux=t,this.i("mouseDragOver",i,t))}get mouseDrop(){return this.Yr}set mouseDrop(t){const i=this.Yr;i!==t&&(Debug&&t!==null&&Util.t(t,"function",Diagram,"mouseDrop"),this.Yr=t,this.i("mouseDrop",i,t))}get handlesDragDropForTopLevelParts(){return this.Gx}set handlesDragDropForTopLevelParts(t){const i=this.Gx;i!==t&&(Util.t(t,"boolean",Diagram,"handlesDragDropForTopLevelParts"),this.Gx=t,this.i("handlesDragDropForTopLevelParts",i,t))}get mouseEnter(){return this.Kr}set mouseEnter(t){const i=this.Kr;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseEnter"),this.Kr=t,this.i("mouseEnter",i,t))}get mouseLeave(){return this.Ur}set mouseLeave(t){const i=this.Ur;i!==t&&(t!==null&&Util.t(t,"function",Diagram,"mouseLeave"),this.Ur=t,this.i("mouseLeave",i,t))}get toolTip(){return this.Gr}set toolTip(t){const i=this.Gr;i!==t&&(Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("Diagram.toolTip must be an Adornment or HTMLInfo."),this.Gr=t,this.i("toolTip",i,t))}get contextMenu(){return this.Hr}set contextMenu(t){const i=this.Hr;i!==t&&(Debug&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("Diagram.contextMenu must be an Adornment or HTMLInfo."),this.Hr=t,this.i("contextMenu",i,t))}get commandHandler(){return this.tP}set commandHandler(t){this.tP!==t&&(this.tP=t,t.Oo(this))}get toolManager(){return this.$M}set toolManager(t){this.$M!==t&&(Util.s(t,ToolManager,Diagram,"toolManager"),this.$M=t,t.diagram=this)}get defaultTool(){return this.QM}set defaultTool(t){const i=this.QM;i!==t&&(Util.s(t,Tool,Diagram,"defaultTool"),this.QM=t,t.diagram=this,this.currentTool===i&&(this.currentTool=t))}get currentTool(){return this._M}set currentTool(t){const i=this._M;i&&(i.isActive&&i.doDeactivate(),i.cancelWaitAfter(),i.doStop()),t===null&&(t=this.defaultTool),t!==null&&(Util.s(t,Tool,Diagram,"currentTool"),this._M=t,t.diagram=this,t.doStart())}get selection(){return this.lP}get maxSelectionCount(){return this.h1}set maxSelectionCount(t){const i=this.h1;if(i!==t)if(Util.t(t,"number",Diagram,"maxSelectionCount"),t>=0&&!isNaN(t)){if(this.h1=t,this.i("maxSelectionCount",i,t),!this.undoManager.isUndoingRedoing){const e=this.selection.count-t;if(e>0){this.B("ChangingSelection",this.selection);const s=this.selection.toArray();for(let n=0;n= 0",Diagram,"maxSelectionCount")}get nodeSelectionAdornmentTemplate(){return this.Qm}set nodeSelectionAdornmentTemplate(t){const i=this.Qm;i!==t&&(Util.s(t,Adornment,Diagram,"nodeSelectionAdornmentTemplate"),this.Qm=t,this.i("nodeSelectionAdornmentTemplate",i,t))}get groupSelectionAdornmentTemplate(){return this.c1}set groupSelectionAdornmentTemplate(t){const i=this.c1;i!==t&&(Util.s(t,Adornment,Diagram,"groupSelectionAdornmentTemplate"),this.c1=t,this.i("groupSelectionAdornmentTemplate",i,t))}get linkSelectionAdornmentTemplate(){return this.u1}set linkSelectionAdornmentTemplate(t){const i=this.u1;i!==t&&(Util.s(t,Adornment,Diagram,"linkSelectionAdornmentTemplate"),this.u1=t,this.i("linkSelectionAdornmentTemplate",i,t))}get highlighteds(){return this.hP}get isModified(){const t=this.undoManager;return t.isEnabled?t.currentTransaction!==null?!0:this.qu&&this.zs!==t.historyIndex:this.qu}set isModified(t){if(this.qu!==t){Util.t(t,"boolean",Diagram,"isModified"),this.qu=t;const e=this.undoManager;!t&&e.isEnabled&&(this.zs=e.historyIndex),t||this.YA()}}YA(){const t=this.isModified;this.oP!==t&&(this.oP=t,this.B("Modified"))}get model(){return this.Ai}set model(t){const i=this.Ai;if(i!==t){Util.s(t,Model,Diagram,"model"),this.currentTool.doCancel(),i&&i.undoManager!==t.undoManager&&i.undoManager.isInTransaction&&Util.n("Do not replace a Diagram.model while a transaction is in progress."),this.animationManager.stopAnimation(!0);const e=this.kA(!0);this.io=!1,this.Yu=!0,this.zs=-2,this.Ar=!1;const s=this.$t;this.$t=!0,this.animationManager.El("Model"),i&&(this._n!==null&&this._n.each(n=>i.removeChangedListener(n)),i.removeChangedListener(this.nP)),this.Ai=t,this.partManager=this.wR(this.Ai.type),this.initializePartManager(this.partManager);for(let n=0;nt.addChangedListener(n)),this.$t=s,this.invalidateDocumentBounds(),this.$t||this.T(),i&&t.undoManager.copyProperties(i.undoManager)}}get themeManager(){return this.C1}set themeManager(t){const i=this.C1;i!==t&&(Util.s(t,ThemeManager,Model,"themeManager"),i!==null&&i.removeDiagram(this),this.C1=t,t!==null&&t.addDiagram(this))}initializePartManager(t){}static SP(t,i){Diagram.mA.set(t,i)}static get licenseKey(){return Diagram.BP.last()}static set licenseKey(t){Diagram.BP.add(t.replace(/\s/g,""))}static get version(){return Diagram.xR}static BP=new List;static xR="3.0.12";wR(t){const i=Diagram.mA.get(t);return i!==null?new i:new PartManager}get j(){return this.eP}set j(t){this.eP=t}get Mx(){return this.uA}bR(t){if(t.model!==this.model)return;const i=t.change,e=t.propertyName;if(i===1&&e[0]==="S"){if(e==="StartingFirstTransaction"){const s=this,n=this.toolManager;n.mouseDownTools.each(o=>o.diagram=s),n.mouseMoveTools.each(o=>o.diagram=s),n.mouseUpTools.each(o=>o.diagram=s),this.routers.each(o=>o.diagram=s),!this.ks&&!this.io&&(this.Uf=!0,this.Yu&&(this.Ar=!0))}else if(e==="StartingUndo"||e==="StartingRedo"){const s=this.animationManager;this.skipsUndoManager||(s.defaultAnimation.isAnimating&&s.stopAnimation(),s.getBundleAnimation().isAnimating&&s.getBundleAnimation().stop()),this.B("ChangingSelection",this.selection)}else if(e==="StartedTransaction"){const s=this.animationManager;s.defaultAnimation.isAnimating&&!this.skipsUndoManager&&s.stopAnimation()}return}if(this.j){this.j=!1;try{if(t.modelChange===""&&i===1){(e==="FinishedUndo"||e==="FinishedRedo")&&(this.B("ChangedSelection",this.selection),this.Di());const s=this.animationManager;e==="RolledBackTransaction"&&s.stopAnimation(),this.rA(),this.Uf=!0,this.maybeUpdate(),(this.undoManager.transactionLevel===0||this.undoManager.transactionLevel===1)&&s.FM(),e==="CommittedTransaction"&&this.undoManager.isJustDiscarded&&(this.zs=Math.min(this.zs,this.undoManager.historyIndex-1)),(e==="CommittedTransaction"||e==="RolledBackTransaction")&&this.undoManager.Gw&&setTimeout(()=>{this.isModified=!1},1);const n=t.isTransactionFinished;if(n&&(this.YA(),this.Mx.clear(),this.animationManager.xF()),!this.Hx&&n&&this.lastInput.targetDiagram){this.Hx=!0;const o=this;Util.zh(()=>{o.currentTool.standardMouseOver(),o.Hx=!1},10)}}}finally{this.j=!0}}}get pe(){return this.iP}set pe(t){this.iP=t}get kf(){return this.qx}set kf(t){this.qx=t}DA(t){const i=t.D.h;for(const e of i)e instanceof Picture&&this.VP(e)}VP(t){const i=t.element;if(i===null||!(i instanceof HTMLImageElement)||(i.ls instanceof GSet&&i.ls.add(this),t.kR(),!i.y0))return;const e=i.getAttribute("src")||"",s=this._l.get(e);if(s===null){Picture.KA(t,i);const n=[];n.push(t),this._l.set(e,n)}else{for(let n=0;n0)&&Util.n("defaultScale must be larger than zero, not: "+t),this.e0=t}get autoScale(){return this.Jl}set autoScale(t){const i=this.Jl;i!==t&&(Util.tt(t,AutoScale,"AutoScale"),this.Jl=t,this.i("autoScale",i,t),t!==1&&this.Gs(!1))}get initialAutoScale(){return this.Fr}set initialAutoScale(t){const i=this.Fr;i!==t&&(Util.tt(t,AutoScale,"AutoScale"),this.Fr=t,this.i("initialAutoScale",i,t))}get initialViewportSpot(){return this.Vx}set initialViewportSpot(t){const i=this.Vx;i!==t&&(Util.s(t,Spot,Diagram,"initialViewportSpot"),t.isSpot()||Util.n("initialViewportSpot must be a specific Spot: "+t),this.Vx=t,this.i("initialViewportSpot",i,t))}get initialDocumentSpot(){return this.Bx}set initialDocumentSpot(t){const i=this.Bx;i!==t&&(Util.s(t,Spot,Diagram,"initialDocumentSpot"),t.isSpot()||Util.n("initialViewportSpot must be a specific Spot: "+t),this.Bx=t,this.i("initialDocumentSpot",i,t))}get minScale(){return this.Tx}set minScale(t){Util.r(t,Diagram,"minScale");const i=this.Tx;i!==t&&(t>0?(this.Tx=t,this.i("minScale",i,t),t>this.scale&&(this.scale=t)):Util.G(t,"> 0",Diagram,"minScale"))}get maxScale(){return this.Dx}set maxScale(t){Util.r(t,Diagram,"maxScale");const i=this.Dx;i!==t&&(t>0?(this.Dx=t,this.i("maxScale",i,t),t 0",Diagram,"maxScale"))}get zoomPoint(){return this.Fx}set zoomPoint(t){this.Fx.equals(t)||(Util.s(t,Point,Diagram,"zoomPoint"),t=t.L(),this.Fx=t)}get contentAlignment(){return this.Yf}set contentAlignment(t){const i=this.Yf;i.equals(t)||(Util.s(t,Spot,Diagram,"contentAlignment"),t=t.L(),this.Yf=t,this.i("contentAlignment",i,t),this.Gs(!1))}get initialContentAlignment(){return this.qm}set initialContentAlignment(t){const i=this.qm;i.equals(t)||(Util.s(t,Spot,Diagram,"initialContentAlignment"),t=t.L(),this.qm=t,this.i("initialContentAlignment",i,t))}get padding(){return this.ii}set padding(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Diagram,"padding");const i=this.ii;i.equals(t)||(t=t.L(),this.ii=t,this.invalidateDocumentBounds(),this.i("padding",i,t))}get partManager(){return this.dP}set partManager(t){const i=this.dP;i!==t&&(Util.s(t,PartManager,Diagram,"partManager"),t.diagram!==null&&Util.n("Cannot share PartManagers between Diagrams: "+t.toString()),i&&i.Oo(null),this.dP=t,t.Oo(this))}get nodes(){return this.partManager.nodes.iterator}get links(){return this.partManager.links.iterator}get parts(){return this.partManager.parts.iterator}findTopLevelNodesAndLinks(){const t=new GSet,i=this.nodes;for(;i.next();){const s=i.value;s.isTopLevel&&t.add(s)}const e=this.links;for(;e.next();){const s=e.value;s.isTopLevel&&t.add(s)}return t.iterator}findTopLevelGroups(){return this.vr.iterator}get routers(){return this.vf}doLinkRouting(t){this.Bo=!0;const i=this.vf.h;for(let e=0;e0){const l=this.computePartsBounds(n.memberParts,!1);l.inflate(20,20),s.I1(l)}const o=Rect.a(),r=n.memberParts;for(;r.next();){const l=r.value;l instanceof Node&&this.GP(l,e,o)}Rect.o(o)}s.ua=n,s.YP=e,s.Ko=!1}else t&&s.WA();return s}get avoidanceCellSize(){return this.aP}set avoidanceCellSize(t){this.Zl=null,this.aP=new Size(Math.max(1,t.width),Math.max(1,t.height))}get avoidanceLimit(){return this.fP}set avoidanceLimit(t){this.fP=Math.max(1,t)}jA(t){return t.canAvoid()?t:t.containingGroup!==null?this.jA(t.containingGroup):null}GP(t,i,e){if(t===i||!t.isVisible())return;const s=t.canAvoid();if(s){const n=t.getAvoidableRect(e);this.Zl.PR(n.x,n.y,n.width,n.height)}if(t instanceof Group&&(!s||t.avoidableMembers)){const n=t.memberParts;for(;n.next();){const o=n.value;o instanceof Node&&this.GP(o,i,e)}}}HP(t){this.Zl!==null&&!this.Zl.Ko&&(t===void 0||t.canAvoid())&&(this.Zl.Ko=!0)}get autoScrollInterval(){return this.jm}set autoScrollInterval(t){const i=this.jm;Util.r(t,Diagram,"autoScrollInterval"),i!==t&&(this.jm=t,this.i("autoScrollInterval",i,t))}get autoScrollRegion(){return this.Wm}set autoScrollRegion(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Diagram,"autoScrollRegion");const i=this.Wm;i.equals(t)||(t=t.L(),this.Wm=t,this.invalidateDocumentBounds(),this.i("autoScrollRegion",i,t))}doAutoScroll(t){this.t0.c(t),this.computeAutoScrollPosition(this.t0).equalsApprox(this.position)?this.stopAutoScroll():this.vA()}vA(){if(this.Kf!==-1)return;const t=this.jm,i=this;this.Kf=Util.zh(()=>{if(i.Kf===-1||(i.stopAutoScroll(),i.lastInput.event===null))return;const s=i.computeAutoScrollPosition(i.t0);if(s.equalsApprox(i.position))return;i.position=s,i.lastInput.documentPoint=i.transformViewToDoc(i.t0),i.doMouseMove(),i.ia=!0;const n=Rect.a();i.computeBounds(n),n.unionRect(i.documentBounds),i.UA(n),Rect.o(n),i.Ge=!0,i.maybeUpdate(),i.vA()},t)}stopAutoScroll(){this.Kf!==-1&&(Util.Kg(this.Kf),this.Kf=-1)}computeAutoScrollPosition(t){let i=this.position;const e=this.Wm;if(e.top<=0&&e.left<=0&&e.right<=0&&e.bottom<=0)return i;const s=this.viewportBounds,n=this.scale,o=Rect.H(0,0,s.width*n,s.height*n),r=Point.H(0,0);if(t.x>=o.x&&t.xo.x+o.width-e.right&&this.allowHorizontalScroll){let l=Math.max(this.scrollHorizontalLineChange,1);l=l|0,r.x+=l,t.x>o.x+o.width-e.right/2&&(r.x+=l),t.x>o.x+o.width-e.right/4&&(r.x+=4*l)}if(t.y>=o.y&&t.yo.y+o.height-e.bottom&&this.allowVerticalScroll){let l=Math.max(this.scrollVerticalLineChange,1);l=l|0,r.y+=l,t.y>o.y+o.height-e.bottom/2&&(r.y+=l),t.y>o.y+o.height-e.bottom/4&&(r.y+=4*l)}return r.equalsApprox(Point.Lo)||(i=new Point(i.x+r.x/n,i.y+r.y/n)),Rect.o(o),Point.o(r),i}makeSvg(t){this.Ql.has("SVG")||this.addRenderer("SVG",new SVGSurface(this,root.document));const i=new SVGSurface(this,root.document,!0);t===void 0&&(t={});const e=this;function s(n,o){const r=e.JA(n,"SVG",i),l=r!==null?r.svg:null;return typeof o=="function"?(o(l),null):l}return this.ZA(s,t)}makeSVG(t){return this.makeSvg(t)}addRenderer(t,i){this.Ql.set(t,i)}removeRenderer(t){this.Ql.delete(t)}cacheGroupExternalLinks(t){this.kP=t,t||this.nodes.each(i=>{i instanceof Group&&(i.x0=null)})}ZA(t,i){const e=i.callback;let s=!0;const o=this._l.iterator;for(;o.next();)if(!o.value[0].bn){s=!1;break}if(typeof e!="function"||s)return t(i,e,this);const r=this;function l(){const f=+new Date;for(s=!0,o.reset();o.next();)if(!o.value[0].bn){s=!1;break}if(s||f-a>h){t(i,e,r);return}root.requestAnimationFrame(l)}const h=i.callbackTimeout||300,a=+new Date;return root.requestAnimationFrame(()=>l()),null}makeImage(t){return Diagram.isUsingDOM()?(t===void 0&&(t={}),t.returnType="Image",this.makeImageData(t)):null}makeImageData(t){return t===void 0&&(t={}),this.ZA(this.NR,t)}static img="image";NR(t,i,e){const s=e.JA(t,"canvas",null);if(s===null)return null;const n=s.Y.canvas;let o=null;if(n!==null){let r=t.returnType;switch(r===void 0?r="string":r=r.toLowerCase(),r){case Diagram.img+"data":o=s.getImageData(0,0,n.width,n.height);break;case Diagram.img:const h=(t.document||document).createElement("img");h.src=n.toDataURL(t.type,t.details),o=h;break;case"blob":{const a=n;return typeof i!="function"&&(o="",Util.n('Error: Diagram.makeImageData called with "returnType: toBlob", but no required "callback" function property defined.')),typeof a.toBlob=="function"?(a.toBlob(i,t.type,t.details),"toBlob"):(i(null),null)}case"string":default:o=n.toDataURL(t.type,t.details)}}return typeof i=="function"?(i(o),null):o}static $A=!1;JA(t,i,e){if(this.animationManager.stopAnimation(),this.maybeUpdate(),this.xt===null)return null;typeof t!="object"&&Util.n("properties argument must be an Object.");let n=!1,o=t.size||null,r=t.scale||null;t.scale!==void 0&&isNaN(t.scale)&&(r="NaN");let l=t.maxSize;t.maxSize===void 0&&(n=!0,i==="SVG"?l=new Size(1/0,1/0):l=new Size(2e3,2e3));const h=t.position||null;let a=t.parts||null;Array.isArray(a)&&(a=new List(a));let f=t.padding===void 0?1:t.padding;const c=t.background||null;let u=t.omitTemporary;u===void 0&&(u=!0);const d=t.document||document,m=t.elementFinished||null;let g=t.showTemporary;g===void 0&&(g=!u);let p=t.showGrid;p===void 0&&(p=g),o!==null&&isNaN(o.width)&&isNaN(o.height)&&(o=null),typeof f=="number"?f=new Margin(f):f instanceof Margin||Util.n("MakeImage padding must be a Margin or a number."),f.left=Math.max(f.left,0),f.right=Math.max(f.right,0),f.top=Math.max(f.top,0),f.bottom=Math.max(f.bottom,0),this.ei.clearContextCache(!0);const y=new CanvasSurface(null,d,void 0,!0),x=y.di;if(!(o||r||a||h))return y.width=this.Ct+Math.ceil(f.left+f.right),y.height=this.At+Math.ceil(f.top+f.bottom),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.da=d,e.$u=m,this.D1(e.di,f,new Size(y.width,y.height),this.rt,this.gt,a,c,g,p),e.di):(this.ju=!1,this.D1(x,f,new Size(y.width,y.height),this.rt,this.gt,a,c,g,p),this.ju=!0,y.di);const k=this.e0,b=this.documentBounds.copy();if(b.subtractMargin(this.ii),g){const L=this.Jt.h,D=L.length;for(let F=0;Fk?(r=k,N=b.width,T=b.height):(N=l.width,T=l.height)):(N=b.width*r,T=b.height*r):(r=k,N=b.width,T=b.height),f!==null?(N+=M,T+=A):f=new Margin(0),l!==null){let L=l.width,D=l.height;i!=="SVG"&&n&&!Diagram.$A&&Debug&&(N>L||T>D)&&(Util.ht("Diagram.makeImage(data): Diagram width or height is larger than the default max size. ("+Math.ceil(N)+"x"+Math.ceil(T)+" vs 2000x2000) Consider increasing the max size."),Diagram.$A=!0),isNaN(L)&&(L=2e3),isNaN(D)&&(D=2e3),isFinite(L)&&(N=Math.min(N,L)),isFinite(D)&&(T=Math.min(T,D))}return y.width=Math.ceil(N),y.height=Math.ceil(T),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.da=d,e.$u=m,this.D1(e.di,f,new Size(Math.ceil(N),Math.ceil(T)),r,S,a,c,g,p),e.di):(this.ju=!1,this.D1(x,f,new Size(Math.ceil(N),Math.ceil(T)),r,S,a,c,g,p),this.ju=!0,y.di)}static Ju=null;static QA="5da73c80a36555d4038e4972187c3cae51fd22";static ww=!1;static Hk=()=>{if(Diagram.QA[5]===void 0&&(Transform.prototype.ns=Transform.prototype.Nw),!Diagram.isUsingDOM())return;const t=root.document.createElement("canvas"),i=t.getContext("2d"),e=Util.Fs("7ca11abfd022028846");i[e]=Util.Fs("398c3597c01238");const s="7ca11abfd7330390",n=[Diagram.QA,Util.ww+"4ae6247590da4bb21c324ba3a84e385776",Transform.Hk+"fb236cdfda5de14c134ba1a95a2d4c7cc6f93c1387",Geo.za],o=10,r=0;for(let l=1;l<5;l++)i[Util.Fs(s)](Util.Fs(n[l-1]),o,l*15+r);i[e]=Util.Fs("39f046ebb36e4b");for(let l=1;l<5;l++)i[Util.Fs(s)](Util.Fs(n[l-1]),o,l*15+r);(n.length!==4||n[0][0]!=="5"||n[3][0]!=="7")&&(Transform.prototype.ns=Transform.prototype.Nw),Diagram.Ju=t}}class DiagramHelper{_A;tL;qP;De;constructor(t){if(this._A=null,this.tL="63ad05bbe23a1786468a4c741b6d2",this.qP="@onz",this.tL===this._tk){this.qP=!0,this.De=this.qP;return}this.De=null}CR(t,i){let e="f";const s=root[Util.Fs("76a715b2f73f148a")][Util.Fs("72ba13b5")]||"",n=Util.Fs;if(this.De=!0,!Diagram.isUsingDOM())return;let o=Diagram[n("76a115b6ed251eaf4692")];if(!o){const l=s[n("76ad18b4f73e")];for(let a=s[n("73a612b6fb191d")](n("35e7"))+2;a=0&&ha[0]||h[0]===a[0]&&h[1]>=a[1]))continue;const f="73a612b6fb191d",c=root[n("74a900bae4370f8b51")][n("6fbb13a1c2311e8a57")].toLowerCase(),u=c[n(f)](n("3aad1ab6e022098b4dc4")),d=n(l[2]);if(u>-1){const P=c[n(f)](d.toLowerCase()+"/");if(this.De=!(P>-1&&P=0&&g-1),!this.De))return;const p=root[Util.Fs("76a715b2f73f148a")][Util.Fs("69ad17a1e03e")],y=p[n(f)](n("7fb002b6ed25128b4da25b2e"));if(y>-1&&(this.De=!(p[n(f)](d)>y),!this.De))return;const x=d;if(x[0]!=="#")continue;const k=root.document.createElement("div");let b=l[0].replace(/[A-Za-z]/g,"");for(;b.length<4;)b+="9";const S=b;b=b.substring(b.length-4);let M="";const A=["gsh","gsf"],C=["Header","Background","Display","Feedback"];if(M+=A[parseInt(b.substring(0,1),10)%2],M+=C[parseInt(b.substring(0,1),10)%4],k[n("79a417a0f0181a8946")]=M,root.document[n("78a712aa")]){root.document[n("78a712aa")][n("7bb806b6ed32388c4a875b")](k);const P=root.getComputedStyle(k).getPropertyValue(n("78a704b7e62456904c9b12701b6532a8")),N=root.getComputedStyle(k).getPropertyValue(n("75b817b0ea2202"));if(root.document[n("78a712aa")][n("68ad1bbcf533388c4a875b")](k),!P)continue;const T=root[n("77a902b0eb1b1e804a8a")],L="0."+parseInt(S,10)%100;if(N===L||P.indexOf(parseInt(x[1]+x[2],16))!==-1&&P.indexOf(parseInt(x[3]+x[4],16))!==-1){this.De=!1;return}else if(T&&T(n("32ae19a1e0331fc94084537c067a67fa59f1386b89d006")).matches){M="."+M;for(let D=0;D{const s=this.observed;if(s===null)return;const n=s.viewportBounds,o=this.lastInput.documentPoint;s.position=new Point(o.x-n.width/2,o.y-n.height/2)},this.vP=s=>{this.invalidateDocumentBounds(),this.k0()},this.JP=s=>{this.observed!==null&&(this.invalidateDocumentBounds(),this.T())},this.z1=s=>{this.updateDelay<1?this.T():this.b0||(this.b0=!0,setTimeout(()=>this.redraw(),this.updateDelay))},this.ZP=s=>{this.observed!==null&&this.k0()},this.autoScale=2,this.$t=!1,i&&Object.assign(this,i),this}setupRouters(){}computePixelRatio(){return 1}redraw(){this.b0&&this.updateDelay>=1&&(this.b0=!1,this.AR()),super.redraw()}Ji(){if(this.Ot===null&&Util.n("No div specified"),this.xt===null&&Util.n("No canvas specified"),this.xt instanceof SVGSurface||(this.box.jM(),!this.Ge))return;const t=this.observed;if(t===null||t.animationManager.defaultAnimation.isAnimating||!t.Kh)return;this.g0();const i=this.xt,e=this.ei;if(e.clearContextCache(!0),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,i.width,i.height),this.updateDelay<1)this.eL();else if(this._f!==null){e.drawImage(this._f.Vt,0,0);const o=this.O;e.scale(this.Gi,this.Gi),e.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),e.commitTransform()}const s=this.Jt.h,n=s.length;for(let o=0;on.canDelete())}t.removeParts(i,!0),t.B("SelectionDeleted",i)}finally{t.commitTransaction("Delete"),t.B("ChangedSelection",t.selection),t.currentCursor=""}}canDeleteSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowDelete||t.selection.count===0)}copySelection(){const t=this.diagram;try{const i=new GSet,e=t.selection.iterator;for(;e.next();){const s=e.value;Part.lh(i,s,!0,this.copiesTree?1/0:0,this.copiesConnectedLinks,n=>n.canCopy())}this.copyToClipboard(i)}finally{}}canCopySelection(){const t=this.diagram;return!(!t.allowCopy||!t.allowClipboard||t.selection.count===0)}cutSelection(){this.copySelection(),this.deleteSelection()}canCutSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowCopy||!t.allowDelete||!t.allowClipboard||t.selection.count===0)}copyToClipboard(t){const i=this.diagram;let e=null;if(t===null)Diagram.bA();else{const s=i.model;let n=!1,o=!1,r=null;try{s.Pf()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.Sf()||s.Qu())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=i.copyParts(t,null,!0)}finally{s.Pf()&&(s.copiesParentKeyOfNodeData=n),(s.Sf()||s.Qu())&&(s.copiesGroupKeyOfNodeData=o),e=new List,e.addAll(r.iteratorValues),Diagram.f0=e,Diagram.A1=i.model.dataFormat}}i.B("ClipboardChanged",e)}pasteFromClipboard(){const t=new GSet,i=Diagram.f0;if(i===null)return t;const e=this.diagram;if(Diagram.A1!==e.model.dataFormat)return t;const s=e.model;let n=!1,o=!1,r=null;try{s.Pf()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.Sf()||s.Qu())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=e.copyParts(i,e,!1)}finally{s.Pf()&&(s.copiesParentKeyOfNodeData=n),(s.Sf()||s.Qu())&&(s.copiesGroupKeyOfNodeData=o);const l=r.iterator;for(;l.next();){const h=l.value,a=l.key;h.location.isReal()||(a.location.isReal()?h.location=a.location:!h.position.isReal()&&a.position.isReal()&&(h.position=a.position)),t.add(h)}}return t}pasteSelection(t){t===void 0&&(t=null);const i=this.diagram;try{i.currentCursor="wait",i.B("ChangingSelection",i.selection),i.startTransaction("Paste");const e=this.pasteFromClipboard();e.count>0&&i.clearSelection(!0);const s=e.iterator;for(;s.next();){const n=s.value;n.isSelected=!0}if(t!==null){const n=i.computePartsBounds(i.selection);if(n.isReal()){const o=this.computeEffectiveCollection(i.selection,i.M1);i.LS(o,new Point(t.x-n.centerX,t.y-n.centerY),i.M1,!1)}}i.B("ClipboardPasted",e)}finally{i.commitTransaction("Paste"),i.B("ChangedSelection",i.selection),i.currentCursor=""}}canPasteSelection(t){const i=this.diagram;return!(i.isReadOnly||i.isModelReadOnly||!i.allowInsert||!i.allowClipboard||Diagram.f0===null||Diagram.f0.count===0||Diagram.A1!==i.model.dataFormat)}undo(){this.diagram.undoManager.undo()}canUndo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canUndo()}redo(){this.diagram.undoManager.redo()}canRedo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canRedo()}decreaseZoom(t){t===void 0&&(t=1/this.zoomFactor),Util.r(t,CommandHandler,"decreaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canDecreaseZoom(t){t===void 0&&(t=1/this.zoomFactor),Util.r(t,CommandHandler,"canDecreaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}increaseZoom(t){t===void 0&&(t=this.zoomFactor),Util.r(t,CommandHandler,"increaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canIncreaseZoom(t){t===void 0&&(t=this.zoomFactor),Util.r(t,CommandHandler,"canIncreaseZoom:factor");const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}resetZoom(t){t===void 0&&(t=this.defaultScale),Util.r(t,CommandHandler,"resetZoom:newscale");const i=this.diagram;ti.maxScale||(i.scale=t)}canResetZoom(t){t===void 0&&(t=this.defaultScale),Util.r(t,CommandHandler,"canResetZoom:newscale");const i=this.diagram;return ti.maxScale?!1:i.allowZoom}zoomToFit(){const t=this.diagram,i=t.animationManager;i.stopAnimation(),t.redraw();const e=t.position,s=t.scale;i.El("Zoom To Fit"),this.isZoomToFitRestoreEnabled&&s===this.Y1&&!isNaN(this.X1)&&t.documentBounds.equals(this.K1)?(t.scale=this.X1,t.position=this.h2,this.Y1=NaN,this.K1=Rect.kw):(this.X1=s,this.h2=e.copy(),t.zoomToFit(),this.Y1=t.scale,this.K1=t.documentBounds.copy()),i.FM()}canZoomToFit(){return this.diagram.allowZoom}scrollToPart(t){t===void 0&&(t=null),t!==null&&Util.s(t,Part,CommandHandler,"part");const i=this.diagram;if(i.ensureBounds(),t===null){try{this.Uo!==null&&(this.Uo.next()?t=this.Uo.value:this.Uo=null)}catch{this.Uo=null}t===null&&(i.highlighteds.count>0?this.Uo=i.highlighteds.iterator:i.selection.count>0&&(this.Uo=i.selection.iterator),this.Uo!==null&&this.Uo.next()&&(t=this.Uo.value))}if(t!==null){const e=i.animationManager;e.El("Scroll To Part");const s=this.scrollToPartPause;if(s>0){const n=this.tc(t,[t]);if(n.length===1)i.startTransaction(),i.centerRect(t.actualBounds),i.commitTransaction("Scroll To Part");else{const o=()=>{i.startTransaction();let l=n.pop();for(;n.length>0&&l instanceof Node&&l.isTreeExpanded&&(!(l instanceof Group)||l.isSubGraphExpanded);)l=n.pop();n.length>0?(l instanceof Part&&i.scrollToRect(l.actualBounds),l instanceof Node&&!l.isTreeExpanded&&(l.isTreeExpanded=!0),l instanceof Group&&!l.isSubGraphExpanded&&(l.isSubGraphExpanded=!0)):(l instanceof Part&&i.centerRect(l.actualBounds),i.removeDiagramListener("LayoutCompleted",r)),i.commitTransaction("Scroll To Part")},r=()=>{Util.zh(o,(e.isEnabled?e.duration:0)+s)};i.addDiagramListener("LayoutCompleted",r),o()}}else{const n=i.position.copy();i.centerRect(t.actualBounds),n.equalsApprox(i.position)&&e.stopAnimation()}}}tc(t,i){if(t.isVisible())return i;if(t instanceof Adornment)this.tc(t.adornedPart,i);else if(t instanceof Link){const e=t.fromNode;e!==null&&this.tc(e,i);const s=t.toNode;s!==null&&this.tc(s,i)}else{if(t instanceof Node){const s=t.labeledLink;s!==null&&this.tc(s,i);const n=t.findTreeParentNode();n!==null&&(!n.isTreeExpanded&&!n.wasTreeExpanded&&i.push(n),this.tc(n,i))}const e=t.containingGroup;e!==null&&(!e.isSubGraphExpanded&&!e.wasSubGraphExpanded&&i.push(e),this.tc(e,i))}return i}canScrollToPart(t){if(t===void 0&&(t=null),t!==null&&!(t instanceof Part))return!1;const i=this.diagram;return i.selection.count===0&&i.highlighteds.count===0?!1:i.allowHorizontalScroll&&i.allowVerticalScroll}collapseTree(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse Tree";try{i.startTransaction(e),i.animationManager.El(e);const n=new List;if(t!==null&&t.isTreeExpanded)t.collapseTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&r.isTreeExpanded&&(r.collapseTree(),n.add(r))}}i.B("TreeCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||!t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(!s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}expandTree(t){t===void 0&&(t=null);const i=this.diagram,e="Expand Tree";try{i.startTransaction(e),i.animationManager.El(e);const n=new List;if(t!==null&&!t.isTreeExpanded)t.expandTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&(r.isTreeExpanded||(r.expandTree(),n.add(r)))}}i.B("TreeExpanded",n)}finally{i.commitTransaction(e)}}canExpandTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}groupSelection(){const t=this.diagram,i=t.model;if(!i.ga())return;const e=this.archetypeGroupData;if(e===null)return;let s=null;try{t.currentCursor="wait",t.B("ChangingSelection",t.selection),t.startTransaction("Group");const n=new List,o=t.selection.iterator;for(;o.next();){const h=o.value;h.Ae()&&h.canGroup()&&n.add(h)}const r=new List,l=n.iterator;for(;l.next();){const h=l.value;let a=!1;const f=n.iterator;for(;f.next();){const c=f.value;if(h.isMemberOf(c)){a=!0;break}}a||r.add(h)}if(r.count>0){let h=r.first().containingGroup;if(h!==null)for(;h!==null;){let a=!1;const f=r.iterator;for(;f.next();)if(!f.value.isMemberOf(h)){a=!0;break}if(a)h=h.containingGroup;else break}if(e instanceof Group)e.ci(),s=e.copy(),s!==null&&t.add(s);else if(i.isGroupForData(e)){const a=i.copyNodeData(e);Util.Mt(a)&&(i.addNodeData(a),s=t.findNodeForData(a))}if(s!==null){h!==null&&this.isValidMember(h,s)&&(s.containingGroup=h);const a=r.iterator;for(;a.next();){const f=a.value;this.isValidMember(s,f)&&(f.containingGroup=s)}t.clearSelection(!0),s.isSelected=!0}}t.B("SelectionGrouped",s)}finally{t.commitTransaction("Group"),t.B("ChangedSelection",t.selection),t.currentCursor=""}}canGroupSelection(){const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowGroup||!t.model.ga()||this.archetypeGroupData===null)return!1;const e=t.selection.iterator;for(;e.next();){const s=e.value;if(s.Ae()&&s.canGroup())return!0}return!1}c2(t){const i=Util.at();if(Array.isArray(t))t.forEach(n=>{n instanceof Link||n instanceof Part&&i.push(n)});else{const n=t.iterator;for(;n.next();){const o=n.value;o instanceof Link||o instanceof Part&&i.push(o)}}const e=new GSet,s=i.length;for(let n=0;n0){i.clearSelection(!0);const o=s.iterator;for(;o.next();){const r=o.value;r.expandSubGraph();const l=r.containingGroup,h=l!==null&&l.data!==null?e.getKeyForNodeData(l.data):void 0;n.addAll(r.memberParts);const a=n.iterator;for(;a.next();){const f=a.value;if(f.isSelected=!0,f instanceof Link)continue;const c=f.data;c!==null?e.setGroupForData(c,h):f.containingGroup=l}i.remove(r)}}i.B("SelectionUngrouped",s,n)}finally{i.commitTransaction("Ungroup"),i.B("ChangedSelection",i.selection),i.currentCursor=""}}canUngroupSelection(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowDelete||!i.allowUngroup||!i.model.ga())return!1;if(t!==null){if(!(t instanceof Group))return!1;if(t.canUngroup())return!0}else{const s=i.selection.iterator;for(;s.next();){const n=s.value;if(n instanceof Group&&n.canUngroup())return!0}}return!1}addTopLevelParts(t,i){const e=this.c2(t);let s=!0;const n=e.iterator;for(;n.next();){const o=n.value;o.containingGroup!==null&&(!i||this.isValidMember(null,o)?o.containingGroup=null:s=!1)}return s}collapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse SubGraph";try{i.startTransaction(e),i.animationManager.El(e);const n=new List;if(t!==null&&t.isSubGraphExpanded)t.collapseSubGraph(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&r.isSubGraphExpanded&&(r.collapseSubGraph(),n.add(r))}}i.B("SubGraphCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||!t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&s.isSubGraphExpanded)return!0}}return!1}expandSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Expand SubGraph",s=new List;try{if(i.startTransaction(e),i.animationManager.El(e),t!==null&&!t.isSubGraphExpanded)t.expandSubGraph(),s.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&(r.isSubGraphExpanded||(r.expandSubGraph(),s.add(r)))}}i.B("SubGraphExpanded",s)}finally{for(const n of s)this.sL(i,n);t&&this.sL(i,t),i.commitTransaction(e)}}sL(t,i){for(const e of i.memberParts)e instanceof Node&&t.Of(e,i)}canExpandSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&!s.isSubGraphExpanded)return!0}}return!1}editTextBlock(t){t===void 0&&(t=null),t!==null&&Util.s(t,TextBlock,CommandHandler,"editTextBlock");const i=this.diagram,e=i.toolManager.findTool("TextEditing");if(e!==null){if(t===null){let s=null;const n=i.selection.iterator;for(;n.next();){const o=n.value;if(o.canEdit()){s=o;break}}if(s===null)return;t=s.findInVisualTree(o=>o instanceof TextBlock&&o.editable)}t!==null&&(i.currentTool=null,e.textBlock=t,i.currentTool=e)}}canEditTextBlock(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowTextEdit||i.toolManager.findTool("TextEditing")===null)return!1;if(t!==null){if(!(t instanceof TextBlock))return!1;const e=t.part;if(e!==null&&e.canEdit())return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s.canEdit()&&(t=s.findInVisualTree(n=>n instanceof TextBlock&&n.editable),t!==null))return!0}}return!1}showContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");if(e===null)return;t===void 0&&(i.selection.count>0?t=i.selection.first():t=i);const s=e.findObjectWithContextMenu(t);if(s!==null){const n=i.lastInput;let o=null;if(s instanceof GraphObject)o=s.getDocumentPoint(Spot.Center);else if(!i.viewportBounds.containsPoint(n.documentPoint)){const r=i.viewportBounds;o=new Point(r.x+r.width/2,r.y+r.height/2)}if(o!==null){const r=new InputEvent;r.diagram=i,r.viewPoint=i.transformDocToView(o),r.documentPoint=o,r.button=2,r.up=!0,i.lastInput=r}i.currentTool=e,e.openMenu(!1,s)}}canShowContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");return!(e===null||(t===void 0&&(i.selection.count>0?t=i.selection.first():t=i),e.findObjectWithContextMenu(t)===null))}get copiesClipboardData(){return this.$P}set copiesClipboardData(t){Util.t(t,"boolean",CommandHandler,"copiesClipboardData"),this.$P=t}get copiesConnectedLinks(){return this.QP}set copiesConnectedLinks(t){Util.t(t,"boolean",CommandHandler,"copiesConnectedLinks"),this.QP=t}get deletesConnectedLinks(){return this._P}set deletesConnectedLinks(t){Util.t(t,"boolean",CommandHandler,"deletesConnectedLinks"),this._P=t}get copiesTree(){return this.t2}set copiesTree(t){Util.t(t,"boolean",CommandHandler,"copiesTree"),this.t2=t}get deletesTree(){return this.i2}set deletesTree(t){Util.t(t,"boolean",CommandHandler,"deletesTree"),this.i2=t}get copiesParentKey(){return this.e2}set copiesParentKey(t){Util.t(t,"boolean",CommandHandler,"copiesParentKey"),this.e2=t}get copiesGroupKey(){return this.s2}set copiesGroupKey(t){Util.t(t,"boolean",CommandHandler,"copiesGroupKey"),this.s2=t}get archetypeGroupData(){return this.o2}set archetypeGroupData(t){t!==null&&Util.t(t,"object",CommandHandler,"archetypeGroupData");const i=this.diagram;if(Debug){const e=i.model;e.ga()&&!(t instanceof Group)&&!e.isGroupForData(t)&&Util.n("CommandHandler.archetypeGroupData must be either a Group or a data object for which GraphLinksModel.isGroupForNodeData is true: "+t)}this.o2=t}get memberValidation(){return this.rh}set memberValidation(t){t!==null&&Util.t(t,"function",CommandHandler,"memberValidation"),this.rh=t}get defaultScale(){return this.diagram.defaultScale}set defaultScale(t){this.diagram.defaultScale=t}get zoomFactor(){return this.l2}set zoomFactor(t){Util.r(t,CommandHandler,"zoomFactor"),t>1||Util.n("zoomFactor must be larger than 1.0, not: "+t),this.l2=t}get isZoomToFitRestoreEnabled(){return this.a2}set isZoomToFitRestoreEnabled(t){Util.t(t,"boolean",CommandHandler,"isZoomToFitRestoreEnabled"),this.a2=t}get scrollToPartPause(){return this.f2}set scrollToPartPause(t){Util.r(t,CommandHandler,"scrollToPartPause"),this.f2=t}computeEffectiveCollection(t,i){const e=this.diagram,s=e.toolManager.findTool("Dragging"),n=e.currentTool===s;i===void 0&&(i=e.p0());const o=new GMap;if(t===null)return o;let r=t.iterator;for(;r.next();){const l=r.value;e._r(o,l,n,i)}if(e.draggedLink!==null&&i.dragsLink)return o;for(r=t.iterator;r.next();){const l=r.value;if(l instanceof Link){const h=l.fromNode;if(h!==null&&!o.has(h))o.delete(l);else{const a=l.toNode;a!==null&&!o.has(a)&&o.delete(l)}}}return o}}var Stretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Vertical=4]="Vertical",w[w.Horizontal=5]="Horizontal",w[w.Fill=2]="Fill",w))(Stretch||{}),Orientation=(w=>(w[w.None=0]="None",w[w.Along=21]="Along",w[w.Plus90=22]="Plus90",w[w.Minus90=23]="Minus90",w[w.Opposite=24]="Opposite",w[w.Upright=25]="Upright",w[w.Plus90Upright=26]="Plus90Upright",w[w.Minus90Upright=27]="Minus90Upright",w[w.Upright45=28]="Upright45",w))(Orientation||{}),Flip=(w=>(w[w.None=0]="None",w[w.Vertical=1]="Vertical",w[w.Horizontal=2]="Horizontal",w[w.Both=3]="Both",w))(Flip||{});class GraphObject{l;_u;td;Go;g;hh;Z;gt;he;_t;ed;Hs;Ft;qe;il;ah;Pi;ma;rt;jt;el;Fi;Hi;sd;ai;ic;Ut;hi;sl;U1;fh;nd;constructor(){GSet.vi(this),this.l=30723,this._t=1,this.ed="",this.Hs=null,this.Ft=null,this.gt=new Point(NaN,NaN).w(),this.qe=Size.xw,this.il=new Transform,this.ah=new Transform,this.Pi=null,this.ma=1,this.rt=1,this.jt=0,this.el=Margin.Hg,this.he=new Rect(NaN,NaN,NaN,NaN).w(),this.Fi=new Rect(NaN,NaN,NaN,NaN).w(),this.Hi=new Rect(0,0,NaN,NaN).w(),this.sd=null,this._u=null,this.Z=null,this.ai=Spot.Default,this.ic=Spot.Default,this.td=0,this.Go=0,this.Ut=null,this.g=null,this.hh=null,this.hi=null,this.U1=null,this.fh=null,this.sl=null,this.nd=null}cloneProtected(t){t.l=(this.l|2048|4096)&-32769,t._t=this._t,t.ed=this.ed,t.Ft=this.Ft,t.gt.c(this.gt),t.qe=this.qe.L(),this.Pi!==null?t.Pi=this.Pi.copy():t.Pi=null,t.rt=this.rt,t.jt=this.jt,t.el=this.el.L(),t.he.c(this.he),t.Fi.c(this.Fi),t.Hi.c(this.Hi),t._u=this._u,this.Z!==null&&(t.Z=this.Z.copy()),t.ai=this.ai.L(),t.ic=this.ic.L(),t.td=this.td,t.Go=this.Go,this.Ut!==null&&(t.Ut=this.Ut.copy()),this.g!==null&&(this.g.wi?t.g=this.g:t.g=this.g.copy()),this.hh!==null&&(t.hh=this.hh.slice()),this.hi!==null&&(t.hi=this.hi.copy())}addCopyProperty(t){let i=this.hh;if(!Array.isArray(i))i=[],this.hh=i;else for(let e=0;e{d.data!==null&&d.u2()&&d.updateTargetBindings(i)})}}}}SF(t){this.nd.delete(t)}Yo(){if(this.diagram===null)return;if(this.findBindingPanel()===null&&this.Ri!==null){const i=this.Ri.iterator;for(;i.next();){const e=i.value;if(!e.isToTheme)continue;let s=null;const n=e.sourceName;e.isToObject&&(s=this.nL(n));let o=this;const r=e.targetId;r!==-1&&(o=this.S0(r),o===null)||(n==="/"?s=o.part:n==="."?s=o:n===".."&&(s=o.panel),e.updateTarget(o,s))}}}Sa(t,i){const e=this.findBindingPanel();if(e!==null){const s=this.Ri.iterator;for(;s.next();){const n=s.value;let o=null;if(n.isToObject){if(o=n.oL(e,this),o===null)continue;n.updateSource(this,o,i,null)}else if(n.isToModel){const r=t.diagram;r!==null&&!r.pe&&n.updateSource(this,r.model.modelData,i,e)}else if(!n.isToTheme){const r=e.data;if(r===null)continue;const l=t.diagram;l!==null&&!l.pe&&n.updateSource(this,r,i,e)}if(o===this){const r=n.targetId,l=e.S0(r);l!==null&&n.updateTarget(l,o,i)}}}}S0(t){return this.eo===t?this:null}nL(t){let i;return t===""?i=this:t==="/"?i=this:t==="."?i=this:t===".."?i=this:(i=this.part.findObject(t),i===null&&Debug&&Util.ht("Binding error: missing GraphObject named "+t+" in "+this.part.toString())),i}get eo(){return this.g!==null?this.g.eo:-1}set eo(t){this.eo!==t&&(this.g===null&&(this.g=new GraphObjectTemplateSettings),this.g.eo=t)}get Ri(){return this.g!==null?this.g.Ri:null}set Ri(t){this.Ri!==t&&(this.g===null&&(this.g=new GraphObjectTemplateSettings),this.g.Ri=t)}get so(){return this.g!==null?this.g.so:null}set so(t){this.so!==t&&(this.g===null&&(this.g=new GraphObjectTemplateSettings),this.g.so=t)}raiseChanged(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}i(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}no(t,i,e,s){const n=this.he;if(n.e(t,i,e,s),this.rt!==1||this.jt!==0){this.Pi===null&&(this.Pi=new Transform);const o=this.Pi;o.Vi(),this.M0(o,t,i,e,s),o.Cw(n)}}rL(t,i,e){return this.pickable===!1?!1:(e.af(this.O),i?this.intersectsRect(t,e):this.containedInRect(t,e))}lL(t,i,e){if(this.pickable===!1)return!1;const s=this.naturalBounds,n=t.distanceSquaredPoint(i);return e?Point.distanceLineSegmentSquared(t.x,t.y,0,0,0,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,0,s.height,s.width,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,s.height,s.width,0)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,0,0,0)<=n:t.distanceSquared(0,0)<=n&&t.distanceSquared(0,s.height)<=n&&t.distanceSquared(s.width,0)<=n&&t.distanceSquared(s.width,s.height)<=n}kn(){return!0}containsPoint(t){Debug&&Util.s(t,Point,GraphObject,"containsPoint:p");const i=Point.a();i.c(t),this.O.Pt(i);const e=this.actualBounds;if(!e.isReal())return Point.o(i),!1;const s=this.diagram;if(s!==null&&s.o0){const o=s.getInputOption("extraTouchThreshold"),r=s.getInputOption("extraTouchArea"),l=r/2,h=this.naturalBounds,a=this.getDocumentScale()*s.scale,f=1/a;if(h.width*ae&&(c=t),isFinite(i)&&i>s&&(u=i);break;case 5:isFinite(t)&&t>e&&(c=t),u=0,d&&(i=1/0);break;case 4:isFinite(i)&&i>s&&(u=i),c=0,d&&(t=1/0);break}const g=this.maxSize,p=this.minSize;c>g.width&&p.widthg.height&&p.heightu.height||this.xi>u.width)&&(r=!0)}}}r?this.l|=256:this.l&=-257,this.Fi.isReal()||Util.n("Non-real actualBounds has been set. Object "+this+", actualBounds: "+this.Fi.toString()),this.hd(o,this.Fi),this.oo(!1),Rect.o(o)}dh(t,i,e,s){}commonArrange(t,i,e,s){if(this.Fi.e(t,i,e,s),this.desiredSize.isReal())return;const n=this.he,o=this.el,r=o.right+o.left,l=o.top+o.bottom,h=n.width+r,a=n.height+l;e+=r,s+=l;let f=this.qs(!0);switch(h===e&&a===s&&(f=0),f){case 0:(h>e||a>s)&&(this.ye(!0),this.wt(h>e?e:h,a>s?s:a,0,0));break;case 2:this.ye(!0),this.wt(e,s,0,0);break;case 5:this.ye(!0),this.wt(e,a,0,0);break;case 4:this.ye(!0),this.wt(h,s,0,0);break}}hd(t,i){const e=this.part;e!==null&&e.diagram!==null&&((e.selectionObject===this||e.resizeObject===this||e.rotateObject===this)&&e.d2(!0),this.T(),!t.equalsApproxClose(i)&&(e.gh(),this.A0(e)))}A0(t){this.portId!==null&&(t.d2(!0),t instanceof Node&&t.hL(this))}get shadowVisible(){return this.g!==null?this.g.L0:null}set shadowVisible(t){const i=this.shadowVisible;i!==t&&(Debug&&t!==null&&Util.t(t,"boolean",GraphObject,"shadowVisible"),this.Zt(),this.g.L0=t,this.hs(!0),this.T(),this.i("shadowVisible",i,t))}DR(t,i){const e=this.naturalBounds,s=this.ah,n=s.m11,o=s.m21,r=s.dx,l=s.m12,h=s.m22,a=s.dy;let f=0,c=0,u=f,d=c;f=u*n+d*o+r,c=u*l+d*h+a;let m=f,g=c,p=0,y=0;u=e.width+i,d=0,f=u*n+d*o+r,c=u*l+d*h+a;let x=Math.min(m,f),k=Math.min(g,c);p=Math.max(m+p,f)-x,y=Math.max(g+y,c)-k,m=x,g=k,u=e.width+i,d=e.height+i,f=u*n+d*o+r,c=u*l+d*h+a,x=Math.min(m,f),k=Math.min(g,c),p=Math.max(m+p,f)-x,y=Math.max(g+y,c)-k,m=x,g=k,u=0,d=e.height+i,f=u*n+d*o+r,c=u*l+d*h+a,x=Math.min(m,f),k=Math.min(g,c),p=Math.max(m+p,f)-x,y=Math.max(g+y,c)-k,m=x,g=k;const b=t.viewportBounds,S=b.x,M=b.y,A=b.width,C=b.height;return m>A+S||S>p+m||g>C+M||M>y+g}Ji(t,i){if(this.FR(t,i)||!this.visible)return;const e=this.opacity;if(e===0)return;let s=1;e!==1&&(s=t.globalAlpha,t.globalAlpha=s*e);let n="";this.filter!==""&&(n=t.filter,t.filter=this.filter);const o=this.O,r=this.panel;this.P0()===!0&&this.G1();const l=this.part;let h=!1,a=0;if(l&&i.getRenderingHint("drawShadows")&&(h=l.isShadowed,h)){const g=l.shadowOffset;a=Math.max(g.y,g.x)*i.scale*i.Gi}const f=this instanceof Panel&&this.nl(),c=this.Fi;if(f&&(this.aL(h,t,!1,r),this.RR(t,i),this.fL(h,t,!1,r),this.cL(h,t,!1)),f||!f&&(c.width===0||c.height===0||isNaN(c.x)||isNaN(c.y))){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}const u=this.js();if(!i.ea&&u&&this.DR(i,a)){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}let d=(this.l&256)!==0;if(t.clipInsteadOfFill&&(d=!1),this instanceof TextBlock&&(t.font=this.font),d){const g=r.kn()?r.naturalBounds:r.actualBounds;let p=Math.max(c.x,g.x),y=Math.max(c.y,g.y),x=Math.min(c.right,g.right)-p,k=Math.min(c.bottom,g.bottom)-y;const b=this.hi;if(b!==null&&(p=b.x,y=b.y,x=b.width,k=b.height),p>c.width+c.x||c.x>g.width+g.x){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}t.save(),t.beginPath(),t.rect(p,y,x,k),t.clip()}if(u){if(!l.isVisible()){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}if(h){const g=l.shadowOffset;t.shadowsSet(g.x*i.scale*this.scale*i.Gi,g.y*i.scale*this.scale*i.Gi,l.shadowBlur),t.shadowsOn(),t.shadowColor=l.shadowColor}}const m=this.naturalBounds;if(t.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.aL(h,t,u,r),this.Ft!==null&&(t.commitTransform(),this.H1(t,m,c)),this.fL(h,t,u,r),this.mh(t,i),this.cL(h,t,u),d&&(t.restore(),t.clearContextCache(this instanceof Panel)),!o.Gk()){const g=1/(o.m11*o.m22-o.m12*o.m21);t.transform(o.m22*g,-o.m12*g,-o.m21*g,o.m11*g,g*(o.m21*o.dy-o.m22*o.dx),g*(o.m12*o.dx-o.m11*o.dy))}e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n)}aL(t,i,e,s){t&&this.shadowVisible===!0?i.shadowsOn():t&&this.shadowVisible===!1&&i.shadowsOff(),t&&this.q1(s)&&this.shadowVisible===null&&i.shadowsOff()}fL(t,i,e,s){t&&(this.Ft!==null||this.q1(s))?(this.j1(!0),this.shadowVisible===null&&i.shadowsOff()):this.j1(!1)}cL(t,i,e){t&&this.g2()===!0&&i.shadowsOn(),e&&t&&i.shadowsOff()}IR(t,i,e){const s=this.part;let n=!1;s&&t.getRenderingHint("drawShadows")&&(n=s.isShadowed),i.clipInsteadOfFill&&(n=!1),this.js()&&n&&i.shadowsOn(),n&&this.shadowVisible===!0?i.shadowsOn():n&&this.shadowVisible===!1&&i.shadowsOff();const o=this.panel;if(n&&this.q1(o)&&this.shadowVisible===null&&i.shadowsOff(),i.ol){const r=t.computePixelRatio(),l=`drop-shadow(${i.shadowOffsetX/r}px ${i.shadowOffsetY/r}px ${i.shadowBlur/r/2}px ${i.shadowColor})`;this.background!==null&&e.Ft.setAttributeNS(null,"filter",l)}return n&&(this.Ft!==null||this.q1(o))?(this.j1(!0),this.shadowVisible===null&&i.shadowsOff()):this.j1(!1),n}OR(t,i,e,s){if(e.ol){const n=i.computePixelRatio(),o=`drop-shadow(${e.shadowOffsetX/n}px ${e.shadowOffsetY/n}px ${e.shadowBlur/n/2}px ${e.shadowColor})`;this.m2(t,o)}s&&this.g2()===!0&&e.shadowsOn(),this.js()&&e.shadowsOff()}q1(t){return t===null?!1:(t.nl()&&(t=t.panel),t.g2()||(t.type===Panel.Auto||t.type===Panel.Spot)&&t.findMainElement()!==this)}m2(t,i){}H1(t,i,e){const s=this.N0(),n=i.x,o=i.y,r=i.width+s,l=i.height+s;this.wn(t,this.Ft,!0,!1,i,e),this.Ft instanceof Brush&&this.Ft.type===3?(t.beginPath(),t.rect(n-s/2,o-s/2,r,l),t.fillContext(this.Ft,!1,null)):t.fillRect(n-s/2,o-s/2,r,l)}uL(t,i){let e=t.ER(this);const s=t.fh!==null?t.fh:t.svg;if(e!==-1)if(e===0)if(s.Ft)s.Ft.after(i);else if(t.type===Panel.Table){const n=s.getElementsByClassName("gojs-ts"),o=n.length!==0?n[0]:null;o!==null&&o.after(i)}else s.prepend(i);else{for(;e!==0&&!t.elt(e-1).isVisibleObject();)e--;if(e===0)s.prepend(i);else{const n=t.elt(e-1).svg;n!==null?n.after(i):s.appendChild(i)}}}FR(t,i){if(!(t instanceof SVGContext))return!1;if(!this.visible||this.opacity===0)return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;if(this.js()&&!this.isVisible())return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;const e=this.panel,s=this.ad(t);if(this.oc(t,i,s))return this.dL(this.svg),this.svg.parentElement!==null?(this.js()&&(t.lastDrawnPart=this.svg),!0):(this.js()?(t.lastDrawnPart!==null?t.lastDrawnPart.after(this.svg):t.diagramGroup.prepend(this.svg),t.lastDrawnPart=this.svg):e&&this.uL(e,this.svg),!0);if(this.js()&&this.isShadowed){const m=this.shadowOffset;t.shadowsSet(m.x*i.scale*this.scale*i.Gi,m.y*i.scale*this.scale*i.Gi,this.shadowBlur),t.shadowsOn(),t.shadowColor=this.shadowColor}this instanceof TextBlock&&(t.font=this.font),t.currentElement=null;const n=this.O,o=this instanceof Panel,r=this instanceof Panel?this.nl():!1,l=this.svg;this.P0()===!0&&this.G1();const h=this.Fi;if(t.setCurrentTransform(1,0,0,1,0,0),t.outerGroup=!1,s)if(t.outerGroup=!0,o&&r)t.newGroup(1,0,0,1,0,0),this.svg=t.lastCreatedElement;else if(o&&this.isClipping){const m=this.findMainElement();let g=0,p=0;m!==null&&(g=m.actualBounds.x,p=m.actualBounds.y),t.newGroup(n.m11,n.m12,n.m21,n.m22,n.dx+g,n.dy+p),this.svg=t.lastCreatedElement,m!==null&&t.createOrUpdateClipGroup(this,m.actualBounds),t.currentElement=t.lastCreatedElement}else o?(t.newGroup(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.svg=t.lastCreatedElement):t.newGroup(1,0,0,1,0,0);const a=this.naturalBounds;o||t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.background!==null&&(o?(r&&t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.H1(t,a,h),r&&t.setCurrentTransform(1,0,0,1,0,0)):(t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.H1(t,a,h)),t.currentElement.Ft=t.lastCreatedElement,t.currentElement.prepend(t.lastCreatedElement));const f=this.IR(i,t,t.currentElement);this.mh(t,i),o&&t.endGroup(),t.outerGroup&&t.endGroup();const c=t.surface.$u,u=o?this.svg:t.currentElement;if(!o&&l!==null&&u!==l&&l.parentNode===this.panel.svg){const m=this.svg.getAttribute("filter");return m!==null&&u.setAttribute("filter",m),this.svg.replaceWith(u),this.svg=u,u!==null&&this.T0(t,e,h,u),t.gL(l),!0}if(this.svg=u,c!==null&&u===null&&t.dummyGroup(),u===null)return!0;this.T0(t,e,h,u),this.OR(u,i,t,f);const d=this.js()?this.opacity*t.globalAlpha:this.opacity;if(d!==1&&u.setAttributeNS(null,"opacity",d.toString()),this.filter!==""&&u.setAttributeNS(null,"filter",this.filter),this.js()){if(l!==null&&u!==l&&l.parentNode===t.diagramGroup){const m=l.getAttribute("filter");m!==null&&u.setAttribute("filter",m),l.replaceWith(u)}else t.lastDrawnPart?t.lastDrawnPart.after(u):t.diagramGroup.prepend(u);t.lastDrawnPart=u}else e!==null&&this.uL(e,u);return c!==null&&c(this,u),this.dL(u),!0}dL(t){const i=this,e=t.dataset;i instanceof GraphObject&&(i.portId!==null&&(e.portId=i.portId),i instanceof Panel&&(isNaN(i.itemIndex)||(e.itemIndex=i.itemIndex.toString()),i instanceof Part&&(e.className=Util.hn(i),i.key!==void 0&&(e.key=i.key.toString()),i.containingGroup!==null&&(e.group=i.containingGroup.key.toString()),i instanceof Link&&(i.fromNode!==null&&i.fromNode.key!==void 0&&(e.fromKey=i.fromNode.key.toString()),i.fromPortId!==""&&(e.fromPortId=i.fromPortId),i.toNode!==null&&i.toNode.key!==void 0&&(e.toKey=i.toNode.key.toString()),i.toPortId!==""&&(e.toPortId=i.toPortId)))))}T0(t,i,e,s){let n=(this.l&256)!==0;if(t.clipInsteadOfFill&&(n=!1),!n){s.removeAttributeNS(null,"clip-path"),t.gL(s);return}const o=i.kn()?i.naturalBounds:i.actualBounds;let r=Math.max(e.x,o.x),l=Math.max(e.y,o.y),h=Math.min(e.right,o.right)-r,a=Math.min(e.bottom,o.bottom)-l;const f=this.hi;f!==null&&(r=f.x,l=f.y,h=f.width,a=f.height);const c=t.BR(s);if(c===null){const u="CLIP"+GSet.fu++,d={id:u},m=t.makeElement("clipPath",d),g=t.makeElement("rect",{x:r,y:l,width:h,height:a});if(this instanceof Panel){const p=this.O.copy().Pw();g.setAttribute("transform",`matrix(${p.m11}, ${p.m12}, ${p.m21}, ${p.m22}, ${p.dx}, ${p.dy})`)}m.appendChild(g),t.svg.appendChild(m),s.setAttributeNS(null,"clip-path","url(#"+u+")")}else{const u=c.firstElementChild;u.setAttribute("x",r.toString()),u.setAttribute("y",l.toString()),u.setAttribute("width",h.toString()),u.setAttribute("height",a.toString())}}VR(){if(this.svg===null)return;const t=this.svg.innerHTML.match(/url\(#((CLIP|GRAD).+?)\)/g),i=this.svg.ownerDocument;if(t!==null)for(const e of t){const s=i.getElementById(e.split("#")[1].slice(0,-1));s!==null&&s.remove()}this.svg.remove()}RR(t,i){const e=this.Fi,s=this.Hi,n=this.Ft;n!==null&&t.commitTransform(),n!==null&&(this.wn(t,n,!0,!1,s,e),n instanceof Brush&&n.type===3?(t.beginPath(),t.rect(e.x,e.y,e.width,e.height),t.fillContext(n,!1,null)):t.fillRect(e.x,e.y,e.width,e.height)),this.mh(t,i)}mh(t,i){}D0(){this.hs(!0)}oc(t,i,e){const s=this.svg;if(this.zR()){if(this.D0(),this.hs(!1),s===null)return!1;const f=this.svg.getAttribute("clip-path");if(f!==null&&f.includes("url")){const c=t.svg.getElementById(f.split("#")[1].slice(0,-1));c!==null&&c.remove()}return!1}if(s===null)return!1;if(!this.visible)return s.remove(),!1;if(s.nodeName!=="g"&&e||s.nodeName==="g"&&!e)return!1;const n=this.O,o="matrix("+n.m11+", "+n.m12+", "+n.m21+", "+n.m22+", "+n.dx+", "+n.dy+")",r=this instanceof Panel,l=r?this.nl():!1;if(!(r&&l))if(this instanceof Picture){const f=this.W1;t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),f!==null&&t.amendImageTransform(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7]),e?s.lastElementChild.setAttributeNS(null,"transform",t.getCurrentTransform()):s.setAttributeNS(null,"transform",t.getCurrentTransform())}else if(e&&!r)if(this instanceof Shape){const f=s.getElementsByTagName("path");for(let c=0;c=.1;){if(g){for(l=o[d++%h],l-=r;l<0;)l+=o[d++%h],m=!m;g=!1}else l=o[d++%h];l>u&&(l=u);let p=Math.sqrt(l*l/(1+c*c));a<0&&(p=-p),i+=p,e+=c*p,m?t.lineTo(i,e):t.moveTo(i,e),u-=l,m=!m}}wn(t,i,e,s,n,o){let r=1,l=1;if(typeof i=="string"){e?t.fillStyle=i:t.strokeStyle=i;return}else if(i.type===1){e?t.fillStyle=i.color:t.strokeStyle=i.color;return}let h;const a=this.N0();r=n.width,l=n.height,s?(r=o.width,l=o.height):e||(r+=a,l+=a);const f=t instanceof CanvasSurfaceContext;if(f&&i.Sn&&(i.type===4||i.rc===r&&i.v1===l))h=i.Sn;else{let c=0,u=0,d=0,m=0,g=0,p=0,y=0,x=0;if(s?(y=o.x,x=o.y):e||(y-=a/2,x-=a/2),c=i.start.x*r+i.start.offsetX+y,u=i.start.y*l+i.start.offsetY+x,d=i.end.x*r+i.end.offsetX+y,m=i.end.y*l+i.end.offsetY+x,i.type===2)h=t.createLinearGradient(c,u,d,m);else if(i.type===3)p=isNaN(i.endRadius)?Math.max(r,l)/2:i.endRadius,isNaN(i.startRadius)?(g=0,p=Math.max(r,l)/2):g=i.startRadius,h=t.createRadialGradient(c,u,g,d,m,p);else if(i.type===4)try{h=t.createPattern(i.pattern,"repeat")}catch{h=null}else Util.Bi(i.type,"Brush type");if(i.type!==4){const k=i.colorStops;if(k!==null){const b=k.iterator;for(;b.next();)h.addColorStop(b.key,b.value)}}if(f&&(i.Sn=h,h!==null&&(i.rc=r,i.v1=l),h===null&&i.type===4&&i.rc!==-1)){i.rc=-1;const k=this.diagram;k!==null&&i.rc===-1&&Util.zh(()=>{k.redraw()},600)}}e?t.fillStyle=h:t.strokeStyle=h}isContainedBy(t){return t instanceof Panel?this.XR(this,t):!1}XR(t,i){if(t===i||i===null)return!1;let e=t.panel;for(;e!==null;){if(e===i)return!0;e=e.panel}return!1}isVisibleObject(){if(!this.visible)return!1;const t=this.panel;return t!==null?t.isVisibleObject():!0}isEnabledObject(){let t=this instanceof Panel?this:this.panel;for(;t!==null&&t.isEnabled;)t=t.panel;return t===null}get enabledChanged(){return this.g!==null?this.g.F0:null}set enabledChanged(t){const i=this.enabledChanged;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"enabledChanged"),this.Zt(),this.g.F0=t,this.i("enabledChanged",i,t))}G1(){if(this.J1()===!0){const t=this.il;if(t.Vi(),!this.Fi.isReal()||!this.he.isReal()){this.fd(!1);return}if(t.Es(this.Fi.x-this.he.x,this.Fi.y-this.he.y),this.scale!==1||this.angle!==0){const i=this.naturalBounds;this.M0(t,i.x,i.y,i.width,i.height)}this.fd(!1),this.Ma(!0)}if(this.P0()===!0){const t=this.panel;if(t===null)this.ah.set(this.il),this.ma=this.scale;else if(t.Ks!==null){const i=this.ah;i.Vi(),t.kn()?i.af(t.ah):t.panel!==null&&i.af(t.panel.ah),i.af(this.il),this.ma=this.scale*t.ma}this.Ma(!1)}}M0(t,i,e,s,n){if(this.rt!==1&&t.rt(this.rt),this.jt===0)return;const o=Point.a();o.setSpot(i,e,s,n,Spot.Center),t.ms(this.jt,o.x,o.y),Point.o(o)}u(t){if(this.Xo())return;t===void 0&&(t=!1),this.ye(!0),this.oo(!0);const i=this.panel;i!==null&&!t&&i.u()}lc(){this.Xo()||(this.ye(!0),this.oo(!0))}hc(t){if(this.rs())return;const i=this.panel;!t&&i!==null&&i.u(),this.oo(!0)}ld(){this.J1()===!1&&(this.fd(!0),this.Ma(!0))}p2(){this.Ma(!0)}T(){const t=this.part;t!==null&&t.T()}qs(t){const i=this.stretch,e=this.panel;if(e===null)return this.qo(i===1?0:i,t);if(e.type===Panel.Table)return this.R0(e.getRowDefinition(this.row),e.getColumnDefinition(this.column),t);if(e.type===Panel.Auto&&e.findMainElement()===this)return this.qo(2,t);if(i===1){if(e.type===Panel.Spot&&e.findMainElement()===this)return this.qo(2,t);const s=e.defaultStretch;return s===1?this.qo(0,t):this.qo(s,t)}return this.qo(i,t)}R0(t,i,e){const s=this.stretch;if(s!==1)return this.qo(s,e);let n=null,o=null;switch(t.stretch){case 1:case 5:break;case 4:o=!0;break;case 2:o=!0;break}switch(i.stretch){case 1:case 4:break;case 5:n=!0;break;case 2:n=!0;break}const r=this.panel.defaultStretch;return n===null&&(n=r===5||r===2),o===null&&(o=r===4||r===2),n===!0&&o===!0?this.qo(2,e):n===!0?this.qo(5,e):o===!0?this.qo(4,e):this.qo(0,e)}qo(t,i){if(i)return t;if(t===0)return 0;const e=this.desiredSize;if(e.isReal())return 0;const s=!isNaN(e.width),n=!isNaN(e.height),o=this.angle;if(s)if(o!==90&&o!==270){if(t===5)return 0;if(t===2)return 4}else{if(t===4)return 0;if(t===2)return 5}if(n)if(o!==90&&o!==270){if(t===4)return 0;if(t===2)return 5}else{if(t===5)return 0;if(t===2)return 4}return t}get segmentOrientation(){return this.Ut!==null?this.Ut.I0:0}set segmentOrientation(t){const i=this.segmentOrientation;i!==t&&(Debug&&Util.tt(t,Orientation,"Orientation"),this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.I0=t,this.u(),this.i("segmentOrientation",i,t),t===0&&(this.angle=0))}YR(){this.segmentOrientation=21}get segmentIndex(){return this.Ut!==null?this.Ut.O0:-1/0}set segmentIndex(t){Debug&&Util.t(t,"number",GraphObject,"segmentIndex"),t=Math.round(t);const i=this.segmentIndex;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.O0=t,this.u(),this.i("segmentIndex",i,t))}get segmentFraction(){return this.Ut!==null?this.Ut.E0:0}set segmentFraction(t){Debug&&Util.t(t,"number",GraphObject,"segmentFraction"),isNaN(t)||t<0?t=0:t>1&&(t=1);const i=this.segmentFraction;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.E0=t,this.u(),this.i("segmentFraction",i,t))}get segmentOffset(){return this.Ut!==null?this.Ut.B0:Point.Lo}set segmentOffset(t){const i=this.segmentOffset;i.equals(t)||(Debug&&Util.s(t,Point,GraphObject,"segmentOffset"),t=t.L(),this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.B0=t,this.u(),this.i("segmentOffset",i,t))}get stretch(){return this.g!==null?this.g.ro:1}set stretch(t){const i=this.stretch;i!==t&&(this.Zt(),this.g.ro=t,this.u(),this.i("stretch",i,t))}get name(){return this.g!==null?this.g.Tt:""}set name(t){const i=this.name;i!==t&&(Debug&&Util.t(t,"string",GraphObject,"name"),this.Zt(),this.g.Tt=t,this.part!==null&&this.part.V0(),this.i("name",i,t))}get opacity(){return this._t}set opacity(t){const i=this._t;if(i!==t){Util.t(t,"number",GraphObject,"opacity"),(t<0||t>1)&&Util.G(t,"0 <= value <= 1",GraphObject,"opacity"),this._t=t,this.i("opacity",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.T(s.Zh(s.actualBounds))}}get filter(){return this.ed}set filter(t){Debug&&Util.t(t,"string",GraphObject,"filter");const i=this.ed;if(i!==t){this.ed=t,this.hs(!0),this.i("filter",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.T(s.Zh(s.actualBounds))}}get visible(){return(this.l&1)!==0}set visible(t){const i=(this.l&1)!==0;if(i!==t){Debug&&Util.t(t,"boolean",GraphObject,"visible"),this.l=this.l^1,this.i("visible",i,t);const e=this.panel;e!==null?e.u():this.js()&&this.Ki(t),this.T(),this.mL()}}get pickable(){return(this.l&2)!==0}set pickable(t){const i=(this.l&2)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"pickable"),this.l=this.l^2,this.i("pickable",i,t))}get fromLinkableDuplicates(){return(this.l&4)!==0}set fromLinkableDuplicates(t){const i=(this.l&4)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"fromLinkableDuplicates"),this.l=this.l^4,this.i("fromLinkableDuplicates",i,t))}get fromLinkableSelfNode(){return(this.l&8)!==0}set fromLinkableSelfNode(t){const i=(this.l&8)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"fromLinkableSelfNode"),this.l=this.l^8,this.i("fromLinkableSelfNode",i,t))}get toLinkableDuplicates(){return(this.l&16)!==0}set toLinkableDuplicates(t){const i=(this.l&16)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"toLinkableDuplicates"),this.l=this.l^16,this.i("toLinkableDuplicates",i,t))}get toLinkableSelfNode(){return(this.l&32)!==0}set toLinkableSelfNode(t){const i=(this.l&32)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"toLinkableSelfNode"),this.l=this.l^32,this.i("toLinkableSelfNode",i,t))}get isPanelMain(){return(this.l&64)!==0}set isPanelMain(t){const i=(this.l&64)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"isPanelMain"),this.l=this.l^64,this.u(),this.i("isPanelMain",i,t))}get isActionable(){return(this.l&128)!==0}set isActionable(t){const i=(this.l&128)!==0;i!==t&&(Debug&&Util.t(t,"boolean",GraphObject,"isActionable"),this.l=this.l^128,this.i("isActionable",i,t))}get background(){return this.Ft}set background(t){const i=this.Ft;i!==t&&(t!==null&&Brush.cd(t,"GraphObject.background"),t instanceof Brush&&t.w(),this.Ft=t,this.T(),this.i("background",i,t))}g2(){return(this.l&512)!==0}j1(t){t?this.l|=512:this.l&=-513}sc(){return(this.l&1024)!==0}w2(t){t?this.l|=1024:this.l&=-1025}J1(){return(this.l&2048)!==0}fd(t){t?this.l|=2048:this.l&=-2049}P0(){return(this.l&4096)!==0}Ma(t){t?this.l|=4096:this.l&=-4097}Xo(){return(this.l&8192)!==0}ye(t){t?this.l|=8192:this.l&=-8193}rs(){return(this.l&16384)!==0}oo(t){t?this.l|=16384:this.l&=-16385}zR(){return(this.l&32768)!==0}hs(t){t?this.l|=32768:this.l&=-32769}get part(){if(this.js())return this;if(this.sl!==null)return this.sl;let t=this;for(t=t.panel;t;){if(t instanceof Part)return this.sl=t,t;t=t.panel}return null}get svg(){return this.U1}set svg(t){this.U1=t}Vu(){this.svg=null}get panel(){return this.Hs}Pa(t){this.Hs=t,this.svg!==null&&this.svg.remove()}get layer(){const t=this.part;return t!==null?t.layer:null}get diagram(){const t=this.part;return t!==null?t.diagram:null}get position(){return this.gt}set position(t){Debug&&Util.s(t,Point,GraphObject,"position");const i=t.x,e=t.y,s=this.gt,n=s.x,o=s.y;n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e))?(t=t.copy(),this.b2(t,n,o)&&this.i("position",new Point(n,o),t)):this.k2()}k2(){}b2(t,i,e){return this.gt=t,this.hc(),!0}Lf(t,i,e){this.gt.x===t&&this.gt.y===i||(this.gt.e(t,i),this.ld())}get actualBounds(){return this.Fi}get scale(){return this.rt}set scale(t){const i=this.rt;i!==t&&(Debug&&Util.r(t,GraphObject,"scale"),t<=0&&Util.n("GraphObject.scale for "+this+" must be greater than zero, not: "+t),this.rt=t,this.u(),this.i("scale",i,t))}get angle(){return this.jt}set angle(t){const i=this.jt;if(i!==t){if(Debug&&Util.r(t,GraphObject,"angle"),t=t%360,t<0&&(t+=360),i===t)return;this.jt=t,this.mL(),this.u(),this.i("angle",i,t)}}get desiredSize(){return this.qe}set desiredSize(t){Debug&&Util.s(t,Size,GraphObject,"desiredSize");const i=t.width,e=t.height,s=this.qe,n=s.width,o=s.height;if((n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e)))&&(t=t.L(),this.qe=t,this.u(),this instanceof Shape&&this.le(),this.i("desiredSize",s,t),this.sc())){const r=this.part;r!==null&&(this.Sa(r,"width"),this.Sa(r,"height"))}}get width(){return this.qe.width}set width(t){const i=this.qe.width;if(i!==t&&(!isNaN(i)||!isNaN(t))){Debug&&Util.t(t,"number",GraphObject,"width");const e=this.qe,s=new Size(t,this.qe.height).w();if(this.qe=s,this.u(),this instanceof Shape&&this.le(),this.i("desiredSize",e,s),this.sc()){const n=this.part;n!==null&&this.Sa(n,"width")}}}get height(){return this.qe.height}set height(t){const i=this.qe.height;if(i!==t&&(!isNaN(i)||!isNaN(t))){Debug&&Util.t(t,"number",GraphObject,"height");const e=this.qe,s=new Size(this.qe.width,t).w();if(this.qe=s,this.u(),this instanceof Shape&&this.le(),this.i("desiredSize",e,s),this.sc()){const n=this.part;n!==null&&this.Sa(n,"height")}}}get minSize(){return this.g!==null?this.g.Pr:Size.hf}set minSize(t){const i=this.minSize;i.equals(t)||(Debug&&Util.s(t,Size,GraphObject,"minSize"),t=t.copy(),isNaN(t.width)&&(t.width=0),isNaN(t.height)&&(t.height=0),t.w(),this.Zt(),this.g.Pr=t,this.u(),this.i("minSize",i,t))}get maxSize(){return this.g!==null?this.g.Nr:Size.Xk}set maxSize(t){const i=this.maxSize;i.equals(t)||(Debug&&Util.s(t,Size,GraphObject,"maxSize"),t=t.copy(),isNaN(t.width)&&(t.width=1/0),isNaN(t.height)&&(t.height=1/0),t.w(),this.Zt(),this.g.Nr=t,this.u(),this.i("maxSize",i,t))}get measuredBounds(){return this.he}get naturalBounds(){return this.Hi}N0(){return 0}get margin(){return this.el}set margin(t){typeof t=="number"?t=new Margin(t):Debug&&Util.s(t,Margin,GraphObject,"margin");const i=this.el;i.equals(t)||(t=t.L(),this.el=t,this.u(),this.i("margin",i,t))}get O(){return this.J1()===!0&&this.G1(),this.il}get Ks(){return this.P0()===!0&&this.G1(),this.ah}trigger(t,i,e){let s=null;return typeof t=="string"?s=new AnimationTrigger(t,i,e):s=t,s.Ce=this,this.Ss===null&&(this.Ss=new GMap),this.Ss.set(s.propertyName,s),this}get Ss(){return this.g!==null?this.g.Ss:null}set Ss(t){this.Ss!==t&&(this.Zt(),this.g.Ss=t)}get Mr(){return this.g!==null?this.g.Mr:0}set Mr(t){this.Mr!==t&&(this.Zt(),this.g.Mr=t)}get alignment(){return this.ai}set alignment(t){const i=this.ai;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"alignment"),t.isNoSpot()&&!t.isDefault()&&Util.n("GraphObject.alignment for "+this+" must be a real Spot or Spot.Default, not: "+t),t=t.L(),this.ai=t,this.hc(),this.i("alignment",i,t))}get column(){return this.Go}set column(t){Debug&&Util.r(t,GraphObject,"column"),t=Math.round(t);const i=this.Go;i!==t&&(t<0&&Util.G(t,">= 0",GraphObject,"column"),this.Go=t,this.u(),this.i("column",i,t),this.svg!==null&&this.svg.remove())}get columnSpan(){return this.g!==null?this.g.z0:1}set columnSpan(t){Debug&&Util.t(t,"number",GraphObject,"columnSpan"),t=Math.round(t);const i=this.columnSpan;i!==t&&(t<1&&Util.G(t,">= 1",GraphObject,"columnSpan"),this.Zt(),this.g.z0=t,this.u(),this.i("columnSpan",i,t))}get row(){return this.td}set row(t){Debug&&Util.r(t,GraphObject,"row"),t=Math.round(t);const i=this.td;i!==t&&(t<0&&Util.G(t,">= 0",GraphObject,"row"),this.td=t,this.u(),this.i("row",i,t),this.svg!==null&&this.svg.remove())}get rowSpan(){return this.g!==null?this.g.X0:1}set rowSpan(t){Debug&&Util.t(t,"number",GraphObject,"rowSpan"),t=Math.round(t);const i=this.rowSpan;i!==t&&(t<1&&Util.G(t,">= 1",GraphObject,"rowSpan"),this.Zt(),this.g.X0=t,this.u(),this.i("rowSpan",i,t))}get spanAllocation(){return this.g!==null?this.g.Y0:null}set spanAllocation(t){const i=this.spanAllocation;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"spanAllocation"),this.Zt(),this.g.Y0=t,this.u(),this.i("spanAllocation",i,t))}get alignmentFocus(){return this.ic}set alignmentFocus(t){const i=this.ic;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"alignmentFocus"),Debug&&t.isNoSpot()&&!t.isDefault()&&!(t.isNone()&&this instanceof Node)&&Util.n("GraphObject.alignmentFocus must be a real Spot or Spot.Default, not: "+t),t=t.L(),this.ic=t,this.u(),this.i("alignmentFocus",i,t))}get portId(){return this._u}set portId(t){const i=this._u;if(i!==t){Debug&&t!==null&&Util.t(t,"string",GraphObject,"portId");const e=this.part;e!==null&&!(e instanceof Node)&&Util.n("Cannot set portID on a Link: "+t);const s=e;i!==null&&s!==null&&s.S2(this),this._u=t,t!==null&&s!==null&&(s.Mn=!0,s.pL(this)),this.i("portId",i,t)}}Na(){const t=this.part;if(t instanceof Node&&(this.portId!==null||this===t.port)){const i=t.diagram;i!==null&&!i.undoManager.isUndoingRedoing&&t.hL(this)}}mL(){const t=this.diagram;t===null||t.undoManager.isUndoingRedoing||(this instanceof Panel?this instanceof Node?this.invalidateConnectedLinks():this.walkVisualTreeFrom(this,i=>{i.Na()}):this.Na())}get toSpot(){return this.Z!==null?this.Z.ya:Spot.None}set toSpot(t){const i=this.toSpot;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"toSpot"),t=t.L(),this.je(),this.Z.ya=t,this.i("toSpot",i,t),this.Na())}get toEndSegmentLength(){return this.Z!==null?this.Z.xa:10}set toEndSegmentLength(t){const i=this.toEndSegmentLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"toEndSegmentLength"),t<0&&Util.G(t,">= 0",GraphObject,"toEndSegmentLength"),this.je(),this.Z.xa=t,this.i("toEndSegmentLength",i,t),this.Na())}get toShortLength(){return this.Z!==null?this.Z.ka:0}set toShortLength(t){const i=this.toShortLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"toShortLength"),this.je(),this.Z.ka=t,this.i("toShortLength",i,t),this.Na())}get toLinkable(){return this.Z!==null?this.Z.K0:null}set toLinkable(t){const i=this.toLinkable;i!==t&&(Debug&&t!==null&&Util.t(t,"boolean",GraphObject,"toLinkable"),this.je(),this.Z.K0=t,this.i("toLinkable",i,t))}get toMaxLinks(){return this.Z!==null?this.Z.U0:1/0}set toMaxLinks(t){const i=this.toMaxLinks;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"toMaxLinks"),t<0&&Util.G(t,">= 0",GraphObject,"toMaxLinks"),this.je(),this.Z.U0=t,this.i("toMaxLinks",i,t))}get fromSpot(){return this.Z!==null?this.Z.pa:Spot.None}set fromSpot(t){const i=this.fromSpot;i.equals(t)||(Debug&&Util.s(t,Spot,GraphObject,"fromSpot"),t=t.L(),this.je(),this.Z.pa=t,this.i("fromSpot",i,t),this.Na())}get fromEndSegmentLength(){return this.Z!==null?this.Z.wa:10}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"fromEndSegmentLength"),t<0&&Util.G(t,">= 0",GraphObject,"fromEndSegmentLength"),this.je(),this.Z.wa=t,this.i("fromEndSegmentLength",i,t),this.Na())}get fromShortLength(){return this.Z!==null?this.Z.ba:0}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"fromShortLength"),this.je(),this.Z.ba=t,this.i("fromShortLength",i,t),this.Na())}get fromLinkable(){return this.Z!==null?this.Z.G0:null}set fromLinkable(t){const i=this.fromLinkable;i!==t&&(Debug&&t!==null&&Util.t(t,"boolean",GraphObject,"fromLinkable"),this.je(),this.Z.G0=t,this.i("fromLinkable",i,t))}get fromMaxLinks(){return this.Z!==null?this.Z.H0:1/0}set fromMaxLinks(t){const i=this.fromMaxLinks;i!==t&&(Debug&&Util.t(t,"number",GraphObject,"fromMaxLinks"),t<0&&Util.G(t,">= 0",GraphObject,"fromMaxLinks"),this.je(),this.Z.H0=t,this.i("fromMaxLinks",i,t))}get cursor(){return this.g!==null?this.g.Al:""}set cursor(t){const i=this.cursor;i!==t&&(Util.t(t,"string",GraphObject,"cursor"),this.Zt(),this.g.Al=t,this.i("cursor",i,t))}get click(){return this.g!==null?this.g.Or:null}set click(t){const i=this.click;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"click"),this.Zt(),this.g.Or=t,this.i("click",i,t))}get doubleClick(){return this.g!==null?this.g.Er:null}set doubleClick(t){const i=this.doubleClick;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"doubleClick"),this.Zt(),this.g.Er=t,this.i("doubleClick",i,t))}get contextClick(){return this.g!==null?this.g.Br:null}set contextClick(t){const i=this.contextClick;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"contextClick"),this.Zt(),this.g.Br=t,this.i("contextClick",i,t))}get mouseEnter(){return this.g!==null?this.g.Kr:null}set mouseEnter(t){const i=this.mouseEnter;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseEnter"),this.Zt(),this.g.Kr=t,this.i("mouseEnter",i,t))}get mouseLeave(){return this.g!==null?this.g.Ur:null}set mouseLeave(t){const i=this.mouseLeave;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseLeave"),this.Zt(),this.g.Ur=t,this.i("mouseLeave",i,t))}get mouseOver(){return this.g!==null?this.g.Vr:null}set mouseOver(t){const i=this.mouseOver;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseOver"),this.Zt(),this.g.Vr=t,this.i("mouseOver",i,t))}get mouseHover(){return this.g!==null?this.g.zr:null}set mouseHover(t){const i=this.mouseHover;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseHover"),this.Zt(),this.g.zr=t,this.i("mouseHover",i,t))}get mouseHold(){return this.g!==null?this.g.Xr:null}set mouseHold(t){const i=this.mouseHold;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseHold"),this.Zt(),this.g.Xr=t,this.i("mouseHold",i,t))}get mouseDragEnter(){return this.g!==null?this.g.q0:null}set mouseDragEnter(t){const i=this.mouseDragEnter;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseDragEnter"),this.Zt(),this.g.q0=t,this.i("mouseDragEnter",i,t))}get mouseDragLeave(){return this.g!==null?this.g.j0:null}set mouseDragLeave(t){const i=this.mouseDragLeave;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseDragLeave"),this.Zt(),this.g.j0=t,this.i("mouseDragLeave",i,t))}get mouseDrop(){return this.g!==null?this.g.Yr:null}set mouseDrop(t){const i=this.mouseDrop;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"mouseDrop"),this.Zt(),this.g.Yr=t,this.i("mouseDrop",i,t))}get actionDown(){return this.g!==null?this.g.W0:null}set actionDown(t){const i=this.actionDown;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionDown"),this.Zt(),this.g.W0=t,this.i("actionDown",i,t))}get actionMove(){return this.g!==null?this.g.v0:null}set actionMove(t){const i=this.actionMove;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionMove"),this.Zt(),this.g.v0=t,this.i("actionMove",i,t))}get actionUp(){return this.g!==null?this.g.J0:null}set actionUp(t){const i=this.actionUp;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionUp"),this.Zt(),this.g.J0=t,this.i("actionUp",i,t))}get actionCancel(){return this.g!==null?this.g.Z0:null}set actionCancel(t){const i=this.actionCancel;i!==t&&(t!==null&&Util.t(t,"function",GraphObject,"actionCancel"),this.Zt(),this.g.Z0=t,this.i("actionCancel",i,t))}get toolTip(){return this.g!==null?this.g.Gr:null}set toolTip(t){const i=this.toolTip;i!==t&&(Debug&&t!==null&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("GraphObject.toolTip must be an Adornment or HTMLInfo."),this.Zt(),this.g.Gr=t,this.i("toolTip",i,t))}get contextMenu(){return this.g!==null?this.g.Hr:null}set contextMenu(t){const i=this.contextMenu;i!==t&&(Debug&&!(t instanceof Adornment||t instanceof HTMLInfo)&&Util.n("GraphObject.contextMenu must be an Adornment or HTMLInfo."),this.Zt(),this.g.Hr=t,this.i("contextMenu",i,t))}findBindingPanel(){let t=this instanceof Panel?this:this.panel;for(;t!==null;){if(t.M2())return t;t=t.panel}return null}bind(t,i,e,s){return this.ac(t,i,e,s),this}bindTwoWay(t,i,e,s){return this.ac(t,i,e,s).makeTwoWay(),this}bindModel(t,i,e,s){return this.ac(t,i,e,s).ofModel(),this}bindObject(t,i,e,s,n){return this.ac(t,i,e,s).ofObject(n),this}theme(t,i,e,s,n){return this.ph(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.ph(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.ph(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.ph(t,i,e,s,n).ofModel(),this}ac(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.$0(n),n}ph(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.$0(o),o}$0(t){t.Ce=this;const i=this.findBindingPanel();i!==null&&i.yL()&&Util.n("Cannot add a Binding to a template that has already been copied: "+t),this.Ri===null&&(this.Ri=new List),this.Ri.add(t)}set(t){if(Debug)for(const i in t)(i.startsWith("_")||i.indexOf(".")!==-1)&&Util.n("Property with underscore or period passed to GraphObject.set. Did you mean to use GraphObject.attach?");return Object.assign(this,t),this}attach(t){return GraphObject.P2(this,t),this}apply(t){return t(this),this}setProperties(t){return Diagram.m0(this,t),this}static build(t,i,...e){const s=GraphObject.Q0.get(t);if(typeof s=="function"){const n=s([t].concat(e));if(n instanceof GraphObject)return i&&n.setProperties(i),n}Util.n('GraphObject.build invoked object builder "'+t+'", but it did not return an Object')}static make(t,...i){let e=arguments,s=null,n=null;if(typeof t=="function")n=t;else if(typeof t=="string"){const r=GraphObject.Q0.get(t);typeof r=="function"?(e=Array.prototype.slice.call(e),s=r(e),Util.Mt(s)||Util.n('GraphObject.make invoked object builder "'+t+'", but it did not return an Object')):n=root.go[t]}s===null&&((n==null||!n.constructor)&&Util.n("GraphObject.make requires a class function or GoJS class name or name of an object builder, not: "+t),s=new n);let o=1;if(s instanceof Diagram&&e.length>1){const r=s,l=e[1];(typeof l=="string"||l instanceof HTMLDivElement)&&(r.MP(l),o++)}for(let r=o;r{const i="#f5f5f5",e="#737373",s="#d4d4d4",n="#737373",o="#a3a3a3",r=2.76142374915397,l=2.761423749153969,h=new Panel(Panel.Auto,{isActionable:!0,enabledChanged:(a,f)=>{if(a instanceof Panel){const c=a.findObject("ButtonBorder");c!==null&&(f?(a._buttonFillDisabled=c.fill,c.fill=a._buttonFillNormal):(a._buttonFillNormal=c.fill,c.fill=a._buttonFillDisabled))}},cursor:"pointer"}).attach({_buttonFillNormal:i,_buttonStrokeNormal:e,_buttonFillOver:s,_buttonStrokeOver:n,_buttonFillDisabled:o}).add(new Shape("RoundedRectangle",{name:"ButtonBorder",spot1:new Spot(0,0,r,l),spot2:new Spot(1,1,-r,-l),parameter1:2,fill:i,stroke:e}));return h.mouseEnter=(a,f,c)=>{if(!f.isEnabledObject()||!(f instanceof Panel))return;const u=f.findObject("ButtonBorder");u instanceof Shape&&(f._buttonFillNormal=u.fill,u.fill=f._buttonFillOver,f._buttonStrokeNormal=u.stroke,u.stroke=f._buttonStrokeOver)},h.mouseLeave=(a,f,c)=>{if(!f.isEnabledObject()||!(f instanceof Panel))return;const u=f.findObject("ButtonBorder");u instanceof Shape&&(u.fill=f._buttonFillNormal,u.stroke=f._buttonStrokeNormal)},h}),GraphObject.defineBuilder("TreeExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_treeExpandedFigure:"MinusLine",_treeCollapsedFigure:"PlusLine",visible:!1}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.du}).bindObject("figure","isTreeExpanded",(e,s)=>{const n=s.panel;return e?n._treeExpandedFigure:n._treeCollapsedFigure})),i.bindObject("visible","isTreeLeaf",e=>!e),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Node))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isTreeExpanded){if(!r.canCollapseTree(n))return}else if(!r.canExpandTree(n))return;e.handled=!0,n.isTreeExpanded?r.collapseTree(n):r.expandTree(n)},i}),GraphObject.defineBuilder("SubGraphExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_subGraphExpandedFigure:"MinusLine",_subGraphCollapsedFigure:"PlusLine"}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.du}).bindObject("figure","isSubGraphExpanded",(e,s)=>{const n=s.panel;return e?n._subGraphExpandedFigure:n._subGraphCollapsedFigure})),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Group))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isSubGraphExpanded){if(!r.canCollapseSubGraph(n))return}else if(!r.canExpandSubGraph(n))return;e.handled=!0,n.isSubGraphExpanded?r.collapseSubGraph(n):r.expandSubGraph(n)},i}),GraphObject.defineBuilder("ToolTip",t=>new Adornment(Panel.Auto,{isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).add(new Shape("RoundedRectangle",{name:"Border",parameter1:1,fill:"#f5f5f5",strokeWidth:0,spot1:new Spot(0,0,4,6),spot2:new Spot(1,1,-4,-4)}))),GraphObject.defineBuilder("ContextMenu",t=>new Adornment(Panel.Vertical,{background:"#f5f5f5",isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).bindObject("background","",i=>i.adornedPart!==null&&i.hasPlaceholder()?null:"#f5f5f5")),GraphObject.defineBuilder("ContextMenuButton",t=>{const i=GraphObject.build("Button");i.stretch=5;const e=i.findObject("ButtonBorder");return e instanceof Shape&&(e.figure="Rectangle",e.strokeWidth=0,e.spot1=new Spot(0,0,4,6),e.spot2=new Spot(1,1,-4,-4)),i}),GraphObject.defineBuilder("PanelExpanderButton",t=>{const i=GraphObject.takeBuilderArgument(t,"COLLAPSIBLE"),e=GraphObject.build("Button");e.attach({_buttonExpandedFigure:"M0 0 M0 6 L4 2 8 6 M8 8",_buttonCollapsedFigure:"M0 0 M0 2 L4 6 8 2 M8 8",_buttonFillNormal:"rgba(0, 0, 0, 0)",_buttonStrokeNormal:null,_buttonFillOver:"rgba(0, 0, 0, .2)",_buttonStrokeOver:null}),e.add(new Shape({name:"ButtonIcon",strokeWidth:2}).bindObject("geometryString","visible",n=>n?e._buttonExpandedFigure:e._buttonCollapsedFigure,void 0,i));const s=e.findObject("ButtonBorder");return s instanceof Shape&&(s.stroke=null,s.fill="rgba(0, 0, 0, 0)"),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=o.diagram;if(r===null||r.isReadOnly)return;let l=o.findBindingPanel();if(l===null&&(l=o.part),l!==null){const h=l.findObject(i);h!==null&&(n.handled=!0,r.startTransaction("Collapse/Expand Panel"),h.visible=!h.visible,r.commitTransaction("Collapse/Expand Panel"))}},e}),GraphObject.defineBuilder("CheckBoxButton",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("Button",{desiredSize:new Size(14,14)});e.attach({"ButtonBorder.spot1":new Spot(0,0,1,1),"ButtonBorder.spot2":new Spot(1,1,-1,-1)});const s=new Shape({name:"ButtonIcon",geometryString:"M0 0 M0 8.85 L4.9 13.75 16.2 2.45 M16.2 16.2",strokeWidth:2,stretch:2,geometryStretch:6,visible:!1});return i!==""&&s.bindTwoWay("visible",i),e.add(s),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=n.diagram;if(r===null||r.isReadOnly||i!==""&&r.model.isReadOnly)return;n.handled=!0;const l=o.findObject("ButtonIcon");r.startTransaction("checkbox"),l!==null&&(l.visible=!l.visible),typeof o._doClick=="function"&&o._doClick(n,o),r.commitTransaction("checkbox")},e}),GraphObject.defineBuilder("CheckBox",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("CheckBoxButton",{name:"Button",isActionable:!1,margin:new Margin(0,1,0,0)},i),s=new Panel("Horizontal",{isActionable:!0,cursor:e.cursor,margin:new Margin(1),mouseEnter:e.mouseEnter,mouseLeave:e.mouseLeave,click:e.click}).attach({_buttonFillNormal:e._buttonFillNormal,_buttonStrokeNormal:e._buttonStrokeNormal,_buttonFillOver:e._buttonFillOver,_buttonStrokeOver:e._buttonStrokeOver,_buttonFillDisabled:e._buttonFillDisabled,_buttonClick:e.click});return s.add(e),e.mouseEnter=null,e.mouseLeave=null,e.click=null,s})}}class GraphObjectTemplateSettings{wi;Tt;eo;Ri;so;Ws;Al;Or;Er;Br;Kr;Ur;Vr;zr;Xr;q0;j0;Yr;W0;v0;J0;Z0;Gr;Hr;F0;Y0;Ss;Pr;Nr;ro;X0;z0;Mr;L0;_0;tp;constructor(){this.wi=!1,this.Tt="",this.eo=-1,this.Ri=null,this.so=null,this.Ws=null,this.Al="",this.Or=null,this.Er=null,this.Br=null,this.Kr=null,this.Ur=null,this.Vr=null,this.zr=null,this.Xr=null,this.q0=null,this.j0=null,this.Yr=null,this.W0=null,this.v0=null,this.J0=null,this.Z0=null,this.Gr=null,this.Hr=null,this.F0=null,this.Y0=null,this.Ss=null,this.Pr=Size.hf,this.Nr=Size.Xk,this.ro=1,this.X0=1,this.z0=1,this.Mr=0,this.L0=null,this._0=null,this.tp="category"}copy(){const t=new GraphObjectTemplateSettings;return t.Tt=this.Tt,t.eo=this.eo,t.Ri=this.Ri,t.Ws=this.Ws,t.Al=this.Al,t.Or=this.Or,t.Er=this.Er,t.Br=this.Br,t.Kr=this.Kr,t.Ur=this.Ur,t.Vr=this.Vr,t.zr=this.zr,t.Xr=this.Xr,t.q0=this.q0,t.j0=this.j0,t.Yr=this.Yr,t.W0=this.W0,t.v0=this.v0,t.J0=this.J0,t.Z0=this.Z0,t.Gr=this.Gr,t.Hr=this.Hr,t.F0=this.F0,t.Y0=this.Y0,t.Ss=this.Ss,t.Pr=this.Pr.L(),t.Nr=this.Nr.L(),t.ro=this.ro,t.X0=this.X0,t.z0=this.z0,t.Mr=this.Mr,t.L0=this.L0,t._0=this._0,t.tp=this.tp,t}}class STransform{m;constructor(){this.m=[1,0,0,1,0,0]}copy(){const t=new STransform;return t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5],t}translate(t,i){this.m[4]+=this.m[0]*t+this.m[2]*i,this.m[5]+=this.m[1]*t+this.m[3]*i}scale(t,i){this.m[0]*=t,this.m[1]*=t,this.m[2]*=i,this.m[3]*=i}rotate(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return;this.translate(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m[0]*s+this.m[2]*n,r=this.m[1]*s+this.m[3]*n,l=this.m[0]*-n+this.m[2]*s,h=this.m[1]*-n+this.m[3]*s;this.m[0]=o,this.m[1]=r,this.m[2]=l,this.m[3]=h,this.translate(-i,-e)}}class SGradient{type;x1;y1;r1;x2;y2;r2;colors;pattern;constructor(t){this.type=t,this.x1=0,this.y1=0,this.r1=0,this.x2=0,this.y2=0,this.r2=0,this.colors=[],this.pattern=null}addColorStop(t,i){this.colors.push({offset:t,color:i})}}class SVGSurface{Vt;di;da;$u;N2;constructor(t,i,e){const s=i===void 0?root.document:i;this.da=s,this.N2="http://www.w3.org/2000/svg";const n="http://www.w3.org/2000/xmlns/";s!==void 0&&(this.Vt=this.makeElement("svg",{width:"1px",height:"1px",viewBox:"0 0 1 1"}),this.style.display="block",this.style.letterSpacing="normal",this.style.wordSpacing="normal",e||(this.style.position="absolute"),this.Vt.setAttributeNS(n,"xmlns",this.N2),this.Vt.setAttributeNS(n,"xmlns:xlink","http://www.w3.org/1999/xlink")),this.$u=null,this.di=new SVGContext(this,e)}resize(t,i,e,s){return this.width!==t||this.height!==i?(this.width=t,this.height=i,this.style.width=e+"px",this.style.height=s+"px",this.Vt.setAttributeNS(null,"width",e+"px"),this.Vt.setAttributeNS(null,"height",s+"px"),this.Vt.setAttributeNS(null,"viewBox","0 0 "+e+" "+s),this.di.C2.firstElementChild.setAttributeNS(null,"width",e+"px"),this.di.C2.firstElementChild.setAttributeNS(null,"height",s+"px"),!0):!1}makeElement(t,i,e){const s=this.da.createElementNS(this.N2,t);if(Util.Mt(i))for(const n in i)s.setAttributeNS(n==="href"?"http://www.w3.org/1999/xlink":"",n,i[n]);return e!==void 0&&(s.textContent=e),s}getBoundingClientRect(){return this.Vt.getBoundingClientRect()}focus(){this.Vt.focus()}get width(){return this.Vt.width.baseVal.value}set width(t){this.Vt.setAttribute("width",t+"px")}get height(){return this.Vt.height.baseVal.value}set height(t){this.Vt.setAttribute("height",t+"px")}dispose(){this.da=null}get style(){return this.Vt.style}}class SVGContext{fc;cc;Pn;Ii;We;fillStyle;font;globalAlpha;lineCap;lineDashOffset;lineJoin;lineWidth;miterLimit;shadowBlur;shadowColor;shadowOffsetX;shadowOffsetY;strokeStyle;textAlign;imageSmoothingEnabled;clipInsteadOfFill;lastCreatedElement;uc;dc;surface;svg;C2;wL;$1;jo;yh;Ca;currentElement;clipPathGroup;diagramGroup;lastDrawnPart;currentPath;outerGroup;pathAttributes;ol;Tr;filter;partClipRect;constructor(t,i){this.surface=t,this.svg=t.Vt,this.uc=[],this.dc=[],this.fillStyle="#000000",this.font="10px sans-serif",this.globalAlpha=1,this.lineCap="butt",this.lineDashOffset=0,this.lineJoin="miter",this.lineWidth=1,this.miterLimit=10,this.shadowBlur=0,this.shadowColor="rgba(0, 0, 0, 0)",this.shadowOffsetX=0,this.shadowOffsetY=0,this.ol=!1,this.strokeStyle="#000000",this.textAlign="start",this.clipInsteadOfFill=!1,this.fc=0,this.cc=0,this.Pn=0,this.lastCreatedElement=null,this.currentElement=null,this.Ii=[],this.pathAttributes={},this.$1=!1,this.jo=null,this.yh=0,this.We=new STransform,this.clipPathGroup=this.newGroup2(),this.diagramGroup=this.newGroup2("gojs-diagram"),this.lastDrawnPart=null,this.currentPath=null;const e=GSet.fu++,s=this.makeElement("clipPath",{id:"mainClip"+e}),n={x:0,y:0,width:t.width,height:t.height};s.appendChild(this.makeElement("rect",n)),this.C2=s,this.svg.appendChild(this.clipPathGroup),this.clipPathGroup.appendChild(this.diagramGroup),this.svg.appendChild(s),this.clipPathGroup.setAttributeNS(null,"clip-path","url(#mainClip"+e+")"),this.wL={},this.Tr=!!i,this.filter="",this.partClipRect=null}setDiagramPosScale(t,i,e,s,n,o){this.diagramGroup===void 0?this.newGroup(t,i,e,s,n,o):this.diagramGroup.setAttribute("transform","matrix("+t+", "+i+", "+e+", "+s+", "+n+", "+o+")")}resetInnerSVG(){this.diagramGroup!==null&&(this.diagramGroup.innerHTML="")}arc(t,i,e,s,n,o,r,l){const h=2*Math.PI,a=1e-6,f=h-a,c=e*Math.cos(s),u=e*Math.sin(s),d=t+c,m=i+u,g=o?0:1;let p=o?s-n:n-s;(Math.abs(r-d)>a||Math.abs(l-m)>a)&&this.Ii.push(["L",d,+m]),p<0&&(p=p%h+h),p>f?(this.Ii.push(["A",e,e,0,1,g,t-c,i-u]),this.Ii.push(["A",e,e,0,1,g,d,m])):p>a&&this.Ii.push(["A",e,e,0,+(p>=Math.PI),g,t+e*Math.cos(n),i+e*Math.sin(n)])}beginPath(){this.Ii=[],this.pathAttributes={stroke:"none",fill:"none"}}endPath(t){this.HR(this.Ii,this.We,t||0)}bezierCurveTo(t,i,e,s,n,o){this.Ii.push(["C",t,i,e,s,n,o])}clearRect(t,i,e,s){}clip(){this.pathAttributes.clipPath=!0}closePath(){this.Ii.push(["z"])}createLinearGradient(t,i,e,s){const n=new SGradient("linear");return n.x1=t,n.y1=i,n.x2=e,n.y2=s,n}createPattern(t,i){let e="";t instanceof HTMLCanvasElement&&(e=t.toDataURL()),t instanceof HTMLImageElement&&(e=t.getAttribute("src"));const s=this.wL;if(s[e])return"url(#"+s[e]+")";const n="PATTERN"+GSet.fu++,o={width:t.width,height:t.height,id:n,patternUnits:"userSpaceOnUse"},r={x:0,y:0,width:t.width,height:t.height,href:e},l=this.makeElement("pattern",o);return l.appendChild(this.makeElement(Diagram.img,r)),this.svg.appendChild(l),s[e]=n,"url(#"+n+")"}createRadialGradient(t,i,e,s,n,o){const r=new SGradient("radial");return r.x1=t,r.y1=i,r.r1=e,r.x2=s,r.y2=n,r.r2=o,r}amendImageTransform(t,i,e,s,n,o,r,l){const h=r/e,a=l/s;(n!==0||o!==0)&&this.We.translate(n,o),(h!==1||a!==1)&&this.We.scale(h,a),(t!==0||i!==0)&&this.We.translate(-t,-i)}drawImage(t,i,e,s,n,o,r,l,h){let a="";t instanceof HTMLCanvasElement&&(a=t.toDataURL()),t instanceof HTMLImageElement&&(a=t.getAttribute("src"));const f=t instanceof HTMLImageElement?t.naturalWidth:t.width,c=t instanceof HTMLImageElement?t.naturalHeight:t.height;s===void 0&&(o=i,r=e,l=s=f,h=n=c),s=s||0,n=n||0,o=o||0,r=r||0,l=l||0,h=h||0,this.amendImageTransform(i,e,s,n,o,r,l,h);const u={x:0,y:0,width:f||s,height:c||n,href:a};!Geo.q(s,l)||!Geo.q(n,h)?u.preserveAspectRatio="none":a.toLowerCase().indexOf(".svg")===-1&&a.toLowerCase().indexOf("data:image/svg")===-1&&(u.preserveAspectRatio="xMidYMid slice"),(i!==0||e!==0||s!==f||n!==c)&&(s+=i,n+=e,u["clip-path"]=`path('M ${i},${e} L ${s} ${e} L ${s} ${n} L ${i} ${n} z')`),this.processCommon(Diagram.img,u,this.We),this.ud(Diagram.img,u)}fill(t,i){t&&(this.pathAttributes["fill-rule"]="evenodd"),this.setFill(this.pathAttributes)}fillContext(t,i,e){this.clipInsteadOfFill?this.clip():this.fill(i,e)}createOrUpdateClipGroup(t,i){const e=this.newGroup(1,0,0,1,-i.x,-i.y);e.setAttributeNS(null,"class","spotClip"),t.fh=e}fillRect(t,i,e,s){this.addRect("fill",[t,i,e,s],this.We)}fillBackground(t,i,e,s){const n={x:t,y:i,width:e,height:s};this.processCommon("fill",n,this.We),this.setFill(n),this.svg.prepend(this.makeElement("rect",n))}fillText(t,i,e){this.addText("fill",[t,i,e],this.We)}lineTo(t,i){this.Ii.push(["L",t,i])}moveTo(t,i){this.Ii.push(["M",t,i])}quadraticCurveTo(t,i,e,s){this.Ii.push(["Q",t,i,e,s])}rect(t,i,e,s){this.Ii.push(["M",t,i],["L",t+e,i],["L",t+e,i+s],["L",t,i+s],["z"])}restore(){this.We=this.uc.pop(),this.Ii=this.uc.pop();const t=this.uc.pop();this.fillStyle=t.fillStyle,this.font=t.font,this.globalAlpha=t.globalAlpha,this.lineCap=t.lineCap,this.lineDashOffset=t.lineDashOffset,this.lineJoin=t.lineJoin,this.lineWidth=t.lineWidth,this.miterLimit=t.miterLimit,this.shadowBlur=t.shadowBlur,this.shadowColor=t.shadowColor,this.shadowOffsetX=t.shadowOffsetX,this.shadowOffsetY=t.shadowOffsetY,this.strokeStyle=t.strokeStyle,this.textAlign=t.textAlign,this.partClipRect=t.partClipRect}save(){const t={fillStyle:this.fillStyle,font:this.font,globalAlpha:this.globalAlpha,lineCap:this.lineCap,lineDashOffset:this.lineDashOffset,lineJoin:this.lineJoin,lineWidth:this.lineWidth,miterLimit:this.miterLimit,shadowBlur:this.shadowBlur,shadowColor:this.shadowColor,shadowOffsetX:this.shadowOffsetX,shadowOffsetY:this.shadowOffsetY,strokeStyle:this.strokeStyle,textAlign:this.textAlign,partClipRect:this.partClipRect};this.uc.push(t);const i=[];for(let e=0;eh.offset>a.offset?1:-1);for(let h=0;h1&&this.dc[this.dc.length-2].setAttributeNS(null,"clip-path",'path("'+s+'") view-box');return}if(n.d=s,this.processCommon("",n,i),this.currentPath!==null){const r=this.currentPath;if(r.nodeName!=="g")for(const l in n)l!=="transform"&&r.setAttributeNS(null,l,n[l]);else{const l=r.getElementsByTagName("path");for(const h in n)h!=="transform"&&l[e].setAttributeNS(null,h,n[h])}}else this.ud("path",n)}BR(t){const i=t.getAttribute("clip-path");return i===null?null:this.svg.getElementById(i.split("#")[1].slice(0,-1))}gL(t){const i=t.getAttribute("clip-path");if(i===null)return;const e=this.svg.getElementById(i.split("#")[1].slice(0,-1));e!==null&&e.remove()}qR(t){const i=[];for(let e=0;es?(this.scale(s/n,1),this.translate((n-s)/2,0)):s>n&&(this.scale(1,n/s),this.translate(0,(s-n)/2)),this.fillOrClip(i,e),n>s?(this.translate(-(n-s)/2,0),this.scale(1/(s/n),1)):s>n&&(this.translate(0,-(s-n)/2),this.scale(1,1/(n/s))),!0}strokeContext(){this.clipInsteadOfFill||this.stroke()}fillOrClip(t,i){this.clipInsteadOfFill?this.clip(i):this.fill(t,i)}shadowsSet(t,i,e){this.fc=t,this.cc=i,this.Pn=e}shadowsOff(){this.ol=!1,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0}shadowsOn(){this.ol=!0,this.shadowOffsetX=this.fc,this.shadowOffsetY=this.cc,this.shadowBlur=this.Pn}enableDash(t,i){const e=this.Y;e.setLineDash!==void 0&&(e.setLineDash(t),e.lineDashOffset=i)}disableDash(){const t=this.Y;t.setLineDash!==void 0&&(t.setLineDash(CanvasSurfaceContext.EmptyArray),t.lineDashOffset=0)}clearContextCache(t){t&&(this.Q1=""),this._1="",this.tb=""}removePartFromView(t){}static EmptyArray=Object.freeze([])}var BrushType=(w=>(w[w.Solid=1]="Solid",w[w.Linear=2]="Linear",w[w.Radial=3]="Radial",w[w.Pattern=4]="Pattern",w))(BrushType||{}),ColorSpace=(w=>(w[w.Lab=1]="Lab",w[w.HSL=2]="HSL",w[w.Oklch=3]="Oklch",w))(ColorSpace||{});class ColorNumbers{n0;n1;n2;n3;constructor(){this.n0=0,this.n1=0,this.n2=0,this.n3=0}}class Brush{f;it;Aa;li;xs;ip;ep;Nn;sp;Sn;rc;v1;constructor(t,i){if(GSet.vi(this),this.f=!1,t===void 0)this.it=1,this.Aa="black";else if(typeof t=="string"){const s=Util.Xh(BrushType,t);s!==null?(this.it=s,this.Aa="black"):(this.it=1,Debug&&!Brush.isValidColor(t)&&Util.n('Color "'+t+'" is not a valid color string for Brush constructor'),this.Aa=t)}else Debug&&Util.tt(t,BrushType,"BrushType"),this.it=t,this.Aa="black";const e=this.it;if(e===2?(this.li=Spot.TopCenter,this.xs=Spot.BottomCenter):e===3?(this.li=Spot.Center,this.xs=Spot.Center):(this.li=Spot.None,this.xs=Spot.None),this.ip=0,this.ep=NaN,this.Nn=null,this.sp=null,this.Sn=null,this.rc=0,this.v1=0,i){const s={};for(const n in i)isFinite(parseFloat(n))?this.addColorStop(parseFloat(n),i[n]):s[n]=i[n];Object.assign(this,s)}}copy(){const t=new Brush;return t.it=this.it,t.Aa=this.Aa,t.li=this.li.L(),t.xs=this.xs.L(),t.ip=this.ip,t.ep=this.ep,this.Nn!==null&&(t.Nn=this.Nn.copy()),t.sp=this.sp,t}w(){return this.f=!0,this.Nn!==null&&this.Nn.w(),this}ft(){return Object.isFrozen(this)&&Util.n("cannot thaw constant: "+this),this.f=!1,this.Nn!==null&&this.Nn.ft(),this}fi(t){t in BrushType?this.type=t:Util.ur(this,t)}toString(){let t="Brush(";if(this.type===1)t+=this.color;else if(this.type===2?t+="Linear ":this.type===3?t+="Radial ":this.type===4?t+="Pattern ":t+="(unknown) ",t+=this.start+" "+this.end,this.colorStops!==null){const i=this.colorStops.iterator;for(;i.next();){const e=i.key,s=i.value;t+=" "+e+":"+s}}return t+=")",t}addColorStop(t,i){return this.f&&Util.F(this),(typeof t!="number"||!isFinite(t)||t>1||t<0)&&Util.G(t,"0 <= loc <= 1",Brush,"addColorStop:loc"),Util.t(i,"string",Brush,"addColorStop:color"),Debug&&!Brush.isValidColor(i)&&Util.n('Color "'+i+'" is not a valid color string for Brush.addColorStop'),this.Nn===null&&(this.Nn=new GMap),this.Nn.set(t,i),this.it===1&&(this.type=2),this.Sn=null,this}get type(){return this.it}set type(t){this.f&&Util.F(this,t),Util.tt(t,BrushType,"BrushType"),this.it=t,this.start.isNoSpot()&&(t===2?this.start=Spot.TopCenter:t===3&&(this.start=Spot.Center)),this.end.isNoSpot()&&(t===2?this.end=Spot.BottomCenter:t===3&&(this.end=Spot.Center)),this.Sn=null}get color(){return this.Aa}set color(t){this.f&&Util.F(this,t),Debug&&!Brush.isValidColor(t)&&Util.n('Color "'+t+'" is not a valid color string for Brush.color'),this.Aa=t,this.Sn=null}get start(){return this.li}set start(t){this.f&&Util.F(this,t),Util.s(t,Spot,Brush,"start"),this.li=t.L(),this.Sn=null}get end(){return this.xs}set end(t){this.f&&Util.F(this,t),Util.s(t,Spot,Brush,"end"),this.xs=t.L(),this.Sn=null}get startRadius(){return this.ip}set startRadius(t){this.f&&Util.F(this,t),Util.r(t,Brush,"startRadius"),t<0&&Util.G(t,">= zero",Brush,"startRadius"),this.ip=t,this.Sn=null}get endRadius(){return this.ep}set endRadius(t){this.f&&Util.F(this,t),Util.r(t,Brush,"endRadius"),t<0&&Util.G(t,">= zero",Brush,"endRadius"),this.ep=t,this.Sn=null}get colorStops(){return this.Nn}set colorStops(t){this.f&&Util.F(this,t),Debug&&Util.s(t,GMap,Brush,"colorStops"),this.Nn=t,this.Sn=null}get pattern(){return this.sp}set pattern(t){this.f&&Util.F(this,t),this.sp=t,this.Sn=null}static randomColor(t,i){t===void 0&&(t=128),Debug&&(Util.r(t,Brush,"randomColor:min"),(t<0||t>255)&&Util.G(t,"0 <= min <= 255",Brush,"randomColor:min")),i===void 0&&(i=Math.max(t,255)),Debug&&(Util.r(i,Brush,"randomColor:max"),(i255)&&Util.G(i,"min <= max <= 255",Brush,"randomColor:max"));const e=Math.abs(i-t);let s=Math.floor(t+Math.random()*e).toString(16),n=Math.floor(t+Math.random()*e).toString(16),o=Math.floor(t+Math.random()*e).toString(16);return s.length<2&&(s="0"+s),n.length<2&&(n="0"+n),o.length<2&&(o="0"+o),"#"+s+n+o}static isValidColor(t){return root.CSS?root.CSS.supports("color",t):!0}static lighten(t){return Brush.lightenBy(t)}lightenBy(t,i){this.f&&Util.F(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Eo(this.color),this.color=Brush.dd(e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Eo(n.value),this.addColorStop(n.key,Brush.dd(e,s))}return this}static lightenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Eo(t),Brush.dd(s,n)}static darken(t){return Brush.darkenBy(t)}darkenBy(t,i){this.f&&Util.F(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Eo(this.color),this.color=Brush.dd(-e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Eo(n.value),this.addColorStop(n.key,Brush.dd(-e,s))}return this}static darkenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Eo(t),Brush.dd(-s,n)}static mix(t,i,e){Brush.Eo(t);const s=Brush.W.n0,n=Brush.W.n1,o=Brush.W.n2,r=Brush.W.n3;Brush.Eo(i),e===void 0&&(e=.5);const l=Math.round((Brush.W.n0-s)*e+s),h=Math.round((Brush.W.n1-n)*e+n),a=Math.round((Brush.W.n2-o)*e+o),f=Math.round((Brush.W.n3-r)*e+r);return`rgba(${l}, ${h}, ${a}, ${f})`}isDark(){if(this.type===1)return Brush.isDark(this.color);if((this.type===2||this.type===3)&&this.colorStops!==null){const t=this.colorStops;if(this.type===3)return Brush.isDark(t.first().value);if(t.get(.5)!==null)return Brush.isDark(t.get(.5));if(t.count===2){const l=t.toArray();return Brush.isDark(Brush.mix(l[0].value,l[1].value))}const i=t.iterator;let e=-1,s=-1,n=1,o=1;for(;i.next();){const l=i.key,h=Math.abs(.5-i.key);n>o&&h=n&&hs){let l=e;e=s,s=l,l=n,n=o,o=l}const r=s-e;return Brush.isDark(Brush.mix(t.get(e),t.get(s),1-o/r))}return!1}static isDark(t){return t?t instanceof Brush?t.isDark():(Brush.Eo(t),(299*Brush.W.n0+587*Brush.W.n1+114*Brush.W.n2)/1e3<128):!1}static dd(t,i){switch(i){case 1:return Brush.jR(),Brush.lo.n0=Math.min(100,Math.max(0,Brush.lo.n0+100*t)),Brush.WR(),"rgba("+Brush.W.n0+", "+Brush.W.n1+", "+Brush.W.n2+", "+Brush.W.n3+")";case 2:return Brush.UM(),Brush.Yi.n2=Math.min(100,Math.max(0,Brush.Yi.n2+100*t)),"hsla("+Brush.Yi.n0+", "+Brush.Yi.n1+"%, "+Brush.Yi.n2+"%, "+Brush.Yi.n3+")";case 3:return Brush.vR(),Brush.ho.n0=Math.min(100,Math.max(0,Brush.ho.n0+100*t)),Brush.JR(),"rgba("+Brush.W.n0+", "+Brush.W.n1+", "+Brush.W.n2+", "+Brush.W.n3+")";default:Util.n("Unknown color space: "+i)}}static Eo(t){const i=Brush.rl;if(i===null)return;i.clearRect(0,0,1,1),i.fillStyle="#000000";const e=i.fillStyle;if(i.fillStyle=t,i.fillStyle!==e){i.fillRect(0,0,1,1);const s=i.getImageData(0,0,1,1).data;Brush.W.n0=s[0],Brush.W.n1=s[1],Brush.W.n2=s[2],Brush.W.n3=s[3]/255}else{i.fillStyle="#FFFFFF";const s=i.fillStyle;i.fillStyle=t,i.fillStyle===s&&Debug&&Util.n('Color "'+t+'" is not a valid color string for RGBA color conversion'),Brush.W.n0=0,Brush.W.n1=0,Brush.W.n2=0,Brush.W.n3=1}}static UM(){const t=Brush.W.n0/255,i=Brush.W.n1/255,e=Brush.W.n2/255,s=Math.max(t,i,e),n=Math.min(t,i,e),o=s-n;let r,l;const h=(s+n)/2;if(o===0)r=l=0;else{switch(s){case t:r=(i-e)/o%6;break;case i:r=(e-t)/o+2;break;case e:r=(t-i)/o+4;break}r*=60,r<0&&(r+=360),l=o/(1-Math.abs(2*h-1))}Brush.Yi.n0=Math.round(r),Brush.Yi.n1=Math.round(l*100),Brush.Yi.n2=Math.round(h*100),Brush.Yi.n3=Brush.W.n3}static gE(){const t=Brush.Yi.n0,i=Brush.Yi.n1/100,e=Brush.Yi.n2/100;let s,n,o;const r=(1-Math.abs(2*e-1))*i,l=t/60,h=r*(1-Math.abs(l%2-1));l>=0&&l<1?(s=r,n=h,o=0):l>=1&&l<2?(s=h,n=r,o=0):l>=2&&l<3?(s=0,n=r,o=h):l>=3&&l<4?(s=0,n=h,o=r):l>=4&&l<5?(s=h,n=0,o=r):l>=5&&l<6&&(s=r,n=0,o=h);const a=e-.5*r;s+=a,n+=a,o+=a,Brush.W.n0=Math.round(s*255),Brush.W.n1=Math.round(n*255),Brush.W.n2=Math.round(o*255),Brush.W.n3=Brush.Yi.n3}static jR(){Brush.xL(),Brush.ZR()}static WR(){Brush.$R(),Brush.bL()}static A2(t){return t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}static L2(t){return t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055}static xL(){const t=Brush.A2(Brush.W.n0),i=Brush.A2(Brush.W.n1),e=Brush.A2(Brush.W.n2);Brush.zt.n0=.4124564*t+.3575761*i+.1804375*e,Brush.zt.n1=.2126729*t+.7151522*i+.072175*e,Brush.zt.n2=.0193339*t+.119192*i+.9503041*e,Brush.zt.n3=Brush.W.n3}static bL(){const t=3.2404542*Brush.zt.n0+-1.5371385*Brush.zt.n1+-.4985314*Brush.zt.n2,i=-.969266*Brush.zt.n0+1.8760108*Brush.zt.n1+.041556*Brush.zt.n2,e=.0556434*Brush.zt.n0+-.2040259*Brush.zt.n1+1.0572252*Brush.zt.n2;Brush.W.n0=Brush.L2(t)*255,Brush.W.n1=Brush.L2(i)*255,Brush.W.n2=Brush.L2(e)*255,Brush.W.n3=Brush.zt.n3,Brush.W.n0=Math.round(Brush.W.n0),Brush.W.n0>255?Brush.W.n0=255:Brush.W.n0<0&&(Brush.W.n0=0),Brush.W.n1=Math.round(Brush.W.n1),Brush.W.n1>255?Brush.W.n1=255:Brush.W.n1<0&&(Brush.W.n1=0),Brush.W.n2=Math.round(Brush.W.n2),Brush.W.n2>255?Brush.W.n2=255:Brush.W.n2<0&&(Brush.W.n2=0)}static T2=216/24389;static ib=24389/27;static gd=[95.047,100,108.883];static D2(t){return t>Brush.T2?Math.pow(t,1/3):(Brush.ib*t+16)/116}static ZR(){const t=Brush.D2(Brush.zt.n0*100/Brush.gd[0]),i=Brush.D2(Brush.zt.n1*100/Brush.gd[1]),e=Brush.D2(Brush.zt.n2*100/Brush.gd[2]);Brush.lo.n0=116*i-16,Brush.lo.n1=500*(t-i),Brush.lo.n2=200*(i-e),Brush.lo.n3=Brush.zt.n3}static kL(t){const i=t*t*t;return i>Brush.T2?i:(116*t-16)/Brush.ib}static $R(){const t=(Brush.lo.n0+16)/116,i=Brush.lo.n1/500+t,e=t-Brush.lo.n2/200;Brush.zt.n0=Brush.gd[0]/100*Brush.kL(i),Brush.zt.n1=Brush.gd[1]/100*(Brush.lo.n0>Brush.ib*Brush.T2?Math.pow(t,3):Brush.lo.n0/Brush.ib),Brush.zt.n2=Brush.gd[2]/100*Brush.kL(e),Brush.zt.n3=Brush.lo.n3}static QR(){let t=.8190224*Brush.zt.n0+.3619062*Brush.zt.n1+-.1288737*Brush.zt.n2,i=.03298366*Brush.zt.n0+.9292868*Brush.zt.n1+.03614466*Brush.zt.n2,e=.04817719*Brush.zt.n0+.2642395*Brush.zt.n1+.6335478*Brush.zt.n2;t=Math.cbrt(t),i=Math.cbrt(i),e=Math.cbrt(e),Brush.gi.n0=.2104542*t+.7936177*i+-.004072046*e,Brush.gi.n1=1.977998*t+-2.428592*i+.4505937*e,Brush.gi.n2=.02590403*t+.7827717*i+-.8086757*e,Brush.gi.n3=Brush.zt.n3,Brush.gi.n0*=100}static _R(){Brush.gi.n0/=100;let t=.9999999*Brush.gi.n0+.3963377*Brush.gi.n1+.2158037*Brush.gi.n2,i=1.000000009*Brush.gi.n0+-.1055613*Brush.gi.n1+-.06385417*Brush.gi.n2,e=1.00000005*Brush.gi.n0+-.08948418*Brush.gi.n1+-1.291485*Brush.gi.n2;t=t**3,i=i**3,e=e**3,Brush.zt.n0=1.2268798*t+-.5578149*i+.281391*e,Brush.zt.n1=-.04057576*t+1.112286*i+-.07171106*e,Brush.zt.n2=-.07637294*t+-.4214933*i+1.586924*e,Brush.zt.n3=Brush.gi.n3}static tI(){const t=Math.atan2(Brush.gi.n2,Brush.gi.n1)*180/Math.PI;Brush.ho.n0=Brush.gi.n0,Brush.ho.n1=Math.sqrt(Brush.gi.n1**2+Brush.gi.n2**2),Brush.ho.n2=t>=0?t:t+360,Brush.ho.n3=Brush.gi.n3}static iI(){Brush.gi.n0=Brush.ho.n0,Brush.gi.n1=Brush.ho.n1*Math.cos(Brush.ho.n2*Math.PI/180),Brush.gi.n2=Brush.ho.n1*Math.sin(Brush.ho.n2*Math.PI/180),Brush.gi.n3=Brush.ho.n3}static vR(){Brush.xL(),Brush.QR(),Brush.tI()}static JR(){Brush.iI(),Brush._R(),Brush.bL()}static cd(t,i){typeof t=="string"?Debug&&!Brush.isValidColor(t)&&Util.n('Color "'+t+'" is not a valid color string for '+i):t instanceof Brush||Util.n("Value for "+i+" must be a color string or a Brush, not "+t)}static Solid=1;static Linear=2;static Radial=3;static Pattern=4;static Lab=1;static HSL=2;static rl=Diagram.isUsingDOM()?new CanvasSurface(null,void 0,{willReadFrequently:!0}).di:null;static W=new ColorNumbers;static Yi=new ColorNumbers;static zt=new ColorNumbers;static lo=new ColorNumbers;static gi=new ColorNumbers;static ho=new ColorNumbers}class PanelLayout{Tt="Base";static Layouts=new GMap;static definePanelLayout(t,i){i.name=t,PanelLayout.Layouts.set(t,i)}get name(){return this.Tt}set name(t){this.Tt=t}constructor(){}get classType(){return Panel}measure(t,i,e,s,n,o,r){}measureElement(t,i,e,s,n){t.wt(i,e,s,n)}arrange(t,i,e){}arrangeElement(t,i,e,s,n,o){t.qt(i,e,s,n,o)}remeasureObject(t){t.lc()}Ji(t,i,e){}}class PanelLayoutPosition extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=s.length,h=t.Wo();for(let a=0;a0&&(P=Math.max(Math.abs(k.x*o+k.offsetX-(M.x*o+M.offsetX))-g,0)),r>0&&(N=Math.max(Math.abs(k.y*r+k.offsetY-(M.y*r+M.offsetY))-g,0));const T=Size.a();T.e(0,0);const L=t.Wo();for(let I=0;I1,ot=it.columnSpan>1;(ft||ot)&&!(Uy&&(P=Math.max(y-gt,0)),b.Zi=b.Zi+P,b.actual=b.lt+P,y=Math.max(y-(P+(mt?gt:0)),0)}if(it.columnSpan===1&&(N===0||N===4)){b=t.getColumnDefinition(H);const gt=b.computeEffectiveSpacing(),mt=b.lt===0;P=Math.max(ut-b.actual,0),P+(mt?gt:0)>p&&(P=Math.max(p-gt,0)),b.Zi=b.Zi+P,b.actual=b.lt+P,p=Math.max(p-(P+(mt?gt:0)),0)}(ft||ot)&&it.lc()}}}Util.nt(c);let L=0,D=0;l=t.columnCount;for(let U=0;U=t.rowCount);$++)b=t.getRowDefinition(E.row+$),P=0,N===2||N===4?P=Math.max(b.minimum,X[E.row+$]===0?b.maximum:Math.min(X[E.row+$],b.maximum)):P=Math.max(b.minimum,isNaN(b.xe)?b.maximum:Math.min(b.xe,b.maximum)),B.height+=P,_+=b.minimum;for(let $=1;$=t.columnCount);$++)b=t.getColumnDefinition(E.column+$),P=0,N===2||N===5?P=Math.max(b.minimum,z[E.column+$]===0?b.maximum:Math.min(z[E.column+$],b.maximum)):P=Math.max(b.minimum,isNaN(b.xe)?b.maximum:Math.min(b.xe,b.maximum)),B.width+=P,et+=b.minimum;K.width+=B.width,K.height+=B.height;const tt=E.margin,it=tt.right+tt.left,ft=tt.top+tt.bottom;E.wt(K.width,K.height,et,_);const ot=E.measuredBounds,lt=Math.max(ot.width+it,0),st=Math.max(ot.height+ft,0);let nt=0;for(let $=0;$=t.rowCount);$++)b=t.getRowDefinition(E.row+$),nt+=b.total||0;if(nt=t.rowCount);at++){b=t.getRowDefinition(E.row+at);const ut=b.lt||0,dt=rt(E,b,ct);Debug&&typeof dt!="number"&&Util.n(E+" spanAllocation does not return a number: "+dt),b.actual=Math.min(b.maximum,ut+dt),b.lt!==ut&&($-=b.lt-ut)}}for(;$>0;){const rt=b.lt||0;if(isNaN(b.height)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+$),b.lt!==rt&&($-=b.lt-rt)),b.index===0)break;b=t.getRowDefinition(b.index-1)}}let ht=0;for(let $=0;$=t.columnCount);$++)b=t.getColumnDefinition(E.column+$),ht+=b.total||0;if(ht=t.columnCount);at++){b=t.getColumnDefinition(E.column+at);const ut=b.lt||0,dt=rt(E,b,ct);Debug&&typeof dt!="number"&&Util.n(E+" spanAllocation does not return a number: "+dt),b.actual=Math.min(b.maximum,ut+dt),b.lt!==ut&&($-=b.lt-ut)}}for(;$>0;){const rt=b.lt||0;if(isNaN(b.width)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+$),b.lt!==rt&&($-=b.lt-rt)),b.index===0)break;b=t.getColumnDefinition(b.index-1)}}}Util.nt(u),Size.o(B),Size.o(K),X!==void 0&&Util.nt(X),z!==void 0&&Util.nt(z);let G=0,q=0;const j=t.desiredSize,J=t.maxSize;N=t.qs(!0),L=0,D=0;let Y=0,v=0;l=t.columnCount;for(let U=0;U0){for(;p!==f&&(u[p]===void 0||u[p].lt===0);)p++;p=Math.max(Math.min(p,f-1),0),m=-u[p].position}let y=Math.min(t.leftIndex,c-1);if(d.length>0){for(;y!==c&&(d[y]===void 0||d[y].lt===0);)y++;y=Math.max(Math.min(y,c-1),0),g=-d[y].position}let x=0,k=0;for(;x!==f&&u[x]===void 0;)x++;for(;k!==f&&d[k]===void 0;)k++;const b=t.part;let S=t.getRowDefinition(x),M=t.getColumnDefinition(k);for(let C=0;C=t.rowCount);st++){const nt=t.getRowDefinition(C+st);nt.lt!==0&&(A.height+=nt.total)}for(let st=1;st=t.columnCount);st++){const nt=t.getColumnDefinition(N+st);nt.lt!==0&&(A.width+=nt.total)}const O=T.lt+A.width,V=P.lt+A.height;let K=h,B=a;const X=O,z=V,G=h,q=a;let j=O,J=V;h+O>e.width&&(j=Math.max(e.width-h,0)),a+V>e.height&&(J=Math.max(e.height-a,0));let Y=R.alignment,v=0,W=0,Q=0,U=0;if(Y.isDefault()){Y=t.defaultAlignment,Y.isSpot()||(Y=Spot.Center),v=Y.x,W=Y.y,Q=Y.offsetX,U=Y.offsetY;const st=T.alignment,nt=P.alignment;st.isSpot()&&(v=st.x,Q=st.offsetX),nt.isSpot()&&(W=nt.y,U=nt.offsetY)}else v=Y.x,W=Y.y,Q=Y.offsetX,U=Y.offsetY;(isNaN(v)||isNaN(W))&&(v=.5,W=.5,Q=0,U=0);let E=I.width,H=I.height;const Z=R.margin,et=Z.left+Z.right,_=Z.top+Z.bottom,tt=R.R0(P,T,!1);isNaN(R.desiredSize.width)&&(tt===2||tt===5)&&(E=Math.max(O-et,0)),isNaN(R.desiredSize.height)&&(tt===2||tt===4)&&(H=Math.max(V-_,0));const it=R.maxSize,ft=R.minSize;E=Math.min(it.width,E),H=Math.min(it.height,H),E=Math.max(ft.width,E),H=Math.max(ft.height,H);const ot=E+et,lt=H+_;K+=X*v-ot*v+Q+Z.left,B+=z*W-lt*W+U+Z.top,R.visible&&(Rect.contains(G,q,j,J,K,B,I.width,I.height)?R.qt(K,B,E,H):R.qt(K,B,E,H,new Rect(G,q,j,J)))}}}Size.o(A);for(let C=0;C0&&(b.figure==="LineV"||b.figure==="LineH")){if(i.lineWidth=b.strokeWidth,t.wn(i,b.stroke,!1,!1,l,h),i.beginPath(),b.figure==="LineV"){const D=Math.floor((m-o)/o);for(let F=D;F<=D+c;F++){const R=F*o+m;0<=R&&R<=a&&this.sb(F,S,A,N)&&(i.moveTo(R,0),i.lineTo(R,f))}}else if(b.figure==="LineH"){const D=Math.floor((g-r)/r);for(let F=D;F<=D+u;F++){const R=F*r+g;0<=R&&R<=f&&this.sb(F,S,A,N)&&(i.moveTo(0,R),i.lineTo(a,R))}}i.stroke(),i.endPath()}else if(b.fill!==null){if(t.wn(i,b.fill,!0,!1,l,h),b.figure==="BarV"){let D=b.width;isNaN(D)&&(D=o);const F=Math.floor((m-o)/o);for(let R=F;R<=F+c;R++){const I=R*o+m;0<=I+D&&I<=a&&this.sb(R,S,A,N)&&i.fillRect(I,0,D,f)}}else if(b.figure==="BarH"){let D=b.height;isNaN(D)&&(D=r);const F=Math.floor((g-r)/r);for(let R=F;R<=F+u;R++){const I=R*r+g;0<=I+D&&I<=f&&this.sb(R,S,A,N)&&i.fillRect(0,I,a,D)}}}T&&i.disableDash(),C!==1&&(i.globalAlpha=P)}}sb(t,i,e,s){if(i<0)return t%i===e;if(t%i!==e)return!1;const n=s.length;for(let o=0;ol&&r.push(d)}}t.Mi.np=i}O2(t){return t==="LineV"||t==="BarV"}eI(t){let i=1,e=1;const s=t.D.h,n=s.length;for(let l=0;l=g){const Y=Point.a();f.ML(Y),O=f.midAngle,L!==0&&(I=f.computeAngle(A,L,O),A.jt=I,A.ye(!0),A.oo(!0)),F=Y.x-u.x,R=Y.y-u.y,Point.o(Y)}else{let Y,v,W=0;if(P>=0?(Y=m.elt(P),v=P0?m.elt(W-1):Y),O=0,Y.equalsApprox(v)){let Q,U;P>=0?(Q=P>0?m.elt(P-1):Y,U=P1?m.elt(W-2):v);const E=Q.distanceSquaredPoint(Y),H=v.distanceSquaredPoint(U);E>H+10?O=P>=0?Q.directionPoint(Y):Y.directionPoint(Q):H>E+10?O=P>=0?v.directionPoint(U):U.directionPoint(v):O=P>=0?Q.directionPoint(U):U.directionPoint(Q)}else O=P>=0?Y.directionPoint(v):v.directionPoint(Y);L!==0&&(I=f.computeAngle(A,L,O),A.jt=I,A.ye(!0),A.oo(!0)),F=Y.x+(v.x-Y.x)*N-u.x,R=Y.y+(v.y-Y.y)*N-u.y}A.wt(1/0,1/0,0,0),C=A.measuredBounds;const V=A.naturalBounds;let K=0;A instanceof Shape&&(K=A.strokeWidth);const B=V.width+K,X=V.height+K;k.Vi(),k.Es(-C.x,-C.y),k.rt(A.scale,A.scale),k.ms(L===0?A.angle:O,B/2,X/2),(L===22||L===26)&&k.ms(90,B/2,X/2),(L===23||L===27)&&k.ms(-90,B/2,X/2),L===28&&(O>45&&O<135||O>225&&O<315)&&k.ms(-O,B/2,X/2);const z=new Rect(0,0,B,X);b.setRectSpot(z,T),k.Pt(b);const G=-b.x+K/2*A.scale,q=-b.y+K/2*A.scale;S.c(D);const j=isNaN(D.x),J=isNaN(D.y);if(j||J){const Y=B/2+3,v=X/2+3,W=O>=45&&O<=135,Q=O>=225&&O<=315;L===0&&(W||Q)?(S.x=J?Y:D.y,S.y=j?v:D.x,W?P>=0||isNaN(P)&&N<.5||j&&(S.y=-v):Q&&((P>=0||isNaN(P)&&N<.5)&&j&&(S.y=-v),J&&(S.x=-Y))):(j&&(P>=0||isNaN(P)&&N<.5?S.x=Y:S.x=-Y),J&&(S.y=-v),S.rotate(O))}else S.rotate(O);F+=S.x,R+=S.y,z.e(F+G,R+q,C.width,C.height),x.push(z),d.unionRect(z)}if(h!==null){const M=h.labelNodes;for(;M.next();)M.value.wt(1/0,1/0)}t.vo=d,t.position.e(u.x+d.x,u.y+d.y),n.Kn(d.width||0,d.height||0),Transform.o(k),Point.o(b),Point.o(S)}arrange(t,i,e){const s=i.length;if(!(t instanceof Adornment||t instanceof Link))return;let n=t,o=null;t instanceof Adornment&&(o=t,n=o.adornedPart);const r=t,l=t instanceof Adornment?null:n.path,h=t.gc;if(h.length!==0){let u=0;if(l!==null&&u=2&&r instanceof Link){const u=r.labelNodes;for(;u.next();){const d=u.value;r.oI(d,f,a)}}o!==null?o.md(!1):n.md(!1);const c=t.PL(Point.a());t.location.e(t.position.x+c.x,t.position.y+c.y),Point.o(c)}measureLinkPath(t,i,e,s){if(s.Xo()===!1)return;let n=s.strokeWidth;if(n===0&&t instanceof Adornment&&t.type===Panel.Link&&t.adornedObject instanceof Shape&&(n=t.adornedObject.strokeWidth),n=n*s.rt,t instanceof Link&&t.mt!==null){const o=t.geometry.bounds;s.no(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else if(t instanceof Adornment&&t.adornedPart.mt!==null){const o=t.adornedPart.mt.bounds;s.no(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else s.no(-(n/2),-(n/2),i+n,e+n);s.rI(),s.ye(!1)}}PanelLayout.definePanelLayout("Link",new PanelLayoutLink);class PanelLayoutGraduated extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=t.findMainElement();t.Ze=[];const h=l.margin,a=h.right+h.left,f=h.top+h.bottom;l.wt(i,e,o,r);const c=l.measuredBounds,u=c.width,d=c.height,m=Math.max(u+a,0),g=Math.max(d+f,0),p=new Rect(-h.left,-h.top,m,g);t.Ze.push(p),n.c(p),this.determineGraduatedMarks(t,l);const y=t.Ms;if(y===null)return;const x=s.length;for(let k=0;k45&&c<135||c>225&&c<315)&&S.ms(-c,k/2,b/2);const M=Rect.H(0,0,k,b),A=Point.a();A.setRectSpot(M,o),S.Pt(A);const C=-A.x,P=-A.y,N=Point.a();N.c(l),isNaN(N.x)&&(N.x=k/2+3),isNaN(N.y)&&(N.y=-(b/2+3)),N.rotate(c),a+=N.x+C,f+=N.y+P;const T=new Rect(a,f,y.width,y.height),L=new Rect(y.x,y.y,y.width,y.height),D=new Rect(x.x,x.y,x.width,x.height);p.labelAngle=u,p.lineCount=n.lineCount,p.lines=n.getMetrics(),p.actualBounds=T,p.measuredBounds=L,p.naturalBounds=D,g===0?h.c(T):h.unionRect(T),Point.o(N),Point.o(A),Rect.o(M),Transform.o(S)}t.Ze!==null&&t.Ze.push(h),s.unionNoCheck(h.x,h.y,h.width,h.height)}determineGraduatedMarks(t,i){const e=i.geometry,s=i.strokeWidth,n=e.flattenedSegments,o=e.flattenedLengths,r=e.flattenedTotalLength,l=n.length;let h=0,a=0;const f=Util.at();for(let x=0;xt.graduatedMin+P){const F=Math.floor((N-t.graduatedMin)/P);N-=F*P}const T=c[x],L=N,D=t.graduatedMax*1e-6;for(let F=1;N<=t.graduatedMax+D;F++){if(this.hI(t,N-t.graduatedTickBase,T)&&(N>t.graduatedMax&&(N=t.graduatedMax),(k.graduatedSkip===null||k instanceof TextBlock&&!k.graduatedSkip(N,k)||k instanceof Shape&&!k.graduatedSkip(N,k))&&(m=(N-t.graduatedMin)*r/t.graduatedRange,m>r&&(m=r),g<=m&&m<=p))){let R=f[A][C],I=o[A][C];for(;AM&&C.4995)return t;let o=t;if(i<.5?n>0?o=s[n-1]:Geo.q(e[0],e[e.length-2])&&Geo.q(e[1],e[e.length-1])&&(o=s[s.length-1]):i>.5&&(n+1180&&(t.9995)return(t+o)/2%360;if(r<10){const l=1-Math.abs(.5-i);return(t*l+o*(1-l))%360}}return t}lI(t){if(t.as===null){const i=[],e=t.D.h,s=e.length;for(let n=0;nl&&r.push(f)}}t.as=i}return t.as}hI(t,i,e){const s=e.length;for(let n=0;n-l)return!1}return!0}Ji(t,i,e){const s=e.ea;e.ea=!0;const n=t.naturalBounds,o=n.width,r=n.height,l=i instanceof SVGContext;i.save(),i.beginPath(),i.rect(-1,-1,o+1,r+1),i.clip(),i.endPath();const h=t.findMainElement();h.Ji(i,e);let a=t.getDocumentScale()*e.scale;a<=0&&(a=1);const f=h.actualBounds,c=t.D.h,u=t.Ms,d=c.length;for(let m=0;m(w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ViewboxStretch||{});class Panel extends GraphObject{it;D;ii;pd;vn;ll;ao;vo;B2;V;yd;ut;Mi;si;wd;xh;vs;constructor(t,i){if(super(),this.it=null,t===void 0)this.it=Panel.Position;else if(typeof t=="string"){const e=PanelLayout.Layouts.get(t);e!==null&&(this.it=e)}else t instanceof PanelLayout?this.it=t:t&&(this.it=Panel.Position,i=t);this.it===null&&Util.n("Panel type not specified or PanelLayout not loaded: "+t),this.l|=4194304|(this.it===Panel.Grid?1048576:0),this.D=new List,this.ii=Margin.Hg,this.pd=Spot.Default,this.vn=1,this.ll=null,this.ao="",this.vo=new Rect(NaN,NaN,NaN,NaN),this.B2=null,this.V=null,this.yd=6,this.Mi=null,this.ut=null,this.si=null,this.wd=NaN,this.xh=null,this.vs=null,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.it=this.it,t.ii=this.ii.L(),t.pd=this.pd.L(),t.vn=this.vn,t.ao=this.ao,t.vo.c(this.vo),this.V!==null&&(t.V=this.V.copy(t)),t.yd=this.yd,this.ut!==null&&(t.ut=this.ut.copy()),this.Mi!==null&&(t.Mi=this.Mi.copy()),t.si=this.si,t.wd=this.wd,t.xh=this.xh}Ho(t){super.Ho(t),t.D=this.D;const i=t.D.h,e=i.length;for(let s=0;s= 0",Panel,"padding"),t=new Margin(t)):(Util.s(t,Margin,Panel,"padding"),t.left<0&&Util.G(t.left,">= 0",Panel,"padding:value.left"),t.right<0&&Util.G(t.right,">= 0",Panel,"padding:value.right"),t.top<0&&Util.G(t.top,">= 0",Panel,"padding:value.top"),t.bottom<0&&Util.G(t.bottom,">= 0",Panel,"padding:value.bottom"));const i=this.ii;i.equals(t)||(t=t.L(),this.ii=t,this.u(),this.i("padding",i,t))}get defaultAlignment(){return this.pd}set defaultAlignment(t){const i=this.pd;i.equals(t)||(Debug&&Util.s(t,Spot,Panel,"defaultAlignment"),t=t.L(),this.pd=t,this.u(),this.i("defaultAlignment",i,t))}get defaultStretch(){return this.vn}set defaultStretch(t){const i=this.vn;i!==t&&(this.vn=t,this.u(),this.i("defaultStretch",i,t))}get defaultSeparatorPadding(){return this.V!==null?this.V.op:Margin.Hg}set defaultSeparatorPadding(t){typeof t=="number"?t=new Margin(t):Debug&&Util.s(t,Margin,Panel,"defaultSeparatorPadding");const i=this.defaultSeparatorPadding;i.equals(t)||(t=t.L(),this.V===null&&(this.V=new TablePanelSettings),this.V.op=t,this.u(),this.i("defaultSeparatorPadding",i,t))}get defaultRowSeparatorStroke(){return this.V!==null?this.V.rp:null}set defaultRowSeparatorStroke(t){const i=this.defaultRowSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.w(),this.V===null&&(this.V=new TablePanelSettings),this.V.rp=t,this.T(),this.i("defaultRowSeparatorStroke",i,t))}get defaultRowSeparatorStrokeWidth(){return this.V!==null?this.V.lp:1}set defaultRowSeparatorStrokeWidth(t){const i=this.defaultRowSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.V===null&&(this.V=new TablePanelSettings),this.V.lp=t,this.u(),this.i("defaultRowSeparatorStrokeWidth",i,t))}get defaultRowSeparatorDashArray(){return this.V!==null?this.V.hp:null}set defaultRowSeparatorDashArray(t){const i=this.defaultRowSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Bi(t,"Array",Panel,"defaultRowSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("defaultRowSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.V===null&&(this.V=new TablePanelSettings),this.V.hp=t,this.T(),this.i("defaultRowSeparatorDashArray",i,t)}}get defaultColumnSeparatorStroke(){return this.V!==null?this.V.ap:null}set defaultColumnSeparatorStroke(t){const i=this.defaultColumnSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.w(),this.V===null&&(this.V=new TablePanelSettings),this.V.ap=t,this.T(),this.i("defaultColumnSeparatorStroke",i,t))}get defaultColumnSeparatorStrokeWidth(){return this.V!==null?this.V.fp:1}set defaultColumnSeparatorStrokeWidth(t){const i=this.defaultColumnSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.V===null&&(this.V=new TablePanelSettings),this.V.fp=t,this.u(),this.i("defaultColumnSeparatorStrokeWidth",i,t))}get defaultColumnSeparatorDashArray(){return this.V!==null?this.V.cp:null}set defaultColumnSeparatorDashArray(t){const i=this.defaultColumnSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Bi(t,"Array",Panel,"defaultColumnSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("defaultColumnSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.V===null&&(this.V=new TablePanelSettings),this.V.cp=t,this.T(),this.i("defaultColumnSeparatorDashArray",i,t)}}get wh(){return this.V!==null?this.V.wh:null}set wh(t){this.V===null&&(this.V=new TablePanelSettings),this.V.wh=t}get viewboxStretch(){return this.yd}set viewboxStretch(t){const i=this.yd;i!==t&&(this.yd=t,this.u(),this.i("viewboxStretch",i,t))}get gridCellSize(){return this.Mi!==null?this.Mi.xd:Size.hC}set gridCellSize(t){this.Mi===null&&(this.Mi=new GridPanelSettings);const i=this.Mi.xd;if(!i.equals(t)){(!t.isReal()||t.width===0||t.height===0)&&Util.n("Invalid Panel.gridCellSize: "+t),this.Mi.xd=t.L();const e=this.diagram;e!==null&&this===e.grid&&e.Zr(),this.T(),this.i("gridCellSize",i,t)}}get gridOrigin(){return this.Mi!==null?this.Mi.bd:Point.Lo}set gridOrigin(t){this.Mi===null&&(this.Mi=new GridPanelSettings);const i=this.Mi.bd;if(!i.equals(t)){t.isReal()||Util.n("Invalid Panel.gridOrigin: "+t),this.Mi.bd=t.L();const e=this.diagram;e!==null&&this===e.grid&&e.Zr(),this.T(),this.i("gridOrigin",i,t)}}get graduatedMin(){return this.ut!==null?this.ut.dp:0}set graduatedMin(t){Util.r(t,Panel,"graduatedMin");const i=this.graduatedMin;if(i!==t&&(this.ut===null&&(this.ut=new GradPanelSettings),this.ut.dp=t,this.u(),this.i("graduatedMin",i,t),this.sc())){const e=this.part;e!==null&&this.Sa(e,"graduatedRange")}}get graduatedMax(){return this.ut!==null?this.ut.gp:100}set graduatedMax(t){Util.r(t,Panel,"graduatedMax");const i=this.graduatedMax;if(i!==t&&(this.ut===null&&(this.ut=new GradPanelSettings),this.ut.gp=t,this.u(),this.i("graduatedMax",i,t),this.sc())){const e=this.part;e!==null&&this.Sa(e,"graduatedRange")}}get graduatedRange(){return this.graduatedMax-this.graduatedMin}get graduatedTickUnit(){return this.ut!==null?this.ut.mp:10}set graduatedTickUnit(t){Util.r(t,Panel,"graduatedTickUnit");const i=this.graduatedTickUnit;i!==t&&t>0&&(this.ut===null&&(this.ut=new GradPanelSettings),this.ut.mp=t,this.u(),this.i("graduatedTickUnit",i,t))}get graduatedTickBase(){return this.ut!==null?this.ut.pp:0}set graduatedTickBase(t){Util.r(t,Panel,"graduatedTickBase");const i=this.graduatedTickBase;i!==t&&(this.ut===null&&(this.ut=new GradPanelSettings),this.ut.pp=t,this.u(),this.i("graduatedTickBase",i,t))}get Ms(){return this.ut!==null?this.ut.Ms:null}set Ms(t){this.ut!==null?this.ut.Ms=t:t!==null&&(this.ut=new GradPanelSettings,this.ut.Ms=t)}get Ze(){return this.ut!==null?this.ut.Ze:null}set Ze(t){this.ut!==null?this.ut.Ze=t:t!==null&&(this.ut=new GradPanelSettings,this.ut.Ze=t)}get as(){return this.ut!==null?this.ut.as:null}set as(t){this.ut!==null?this.ut.as=t:t!==null&&(this.ut=new GradPanelSettings,this.ut.as=t)}get Le(){return this.ut!==null?this.ut.Le:null}set Le(t){this.ut!==null?this.ut.Le=t:t!==null&&(this.ut=new GradPanelSettings,this.ut.Le=t)}A0(t){super.A0(t);const i=this.D.h,e=i.length;for(let s=0;s0?this.ve:null,s=this.columnCount>0?this.Je:null;e!==null&&this.nb(t,i,!0,e,!0),s!==null&&this.nb(t,i,!1,s,!0),e!==null&&this.CL(t,!0,e),s!==null&&this.CL(t,!1,s),e!==null&&this.nb(t,i,!0,e,!1),s!==null&&this.nb(t,i,!1,s,!1)}CL(t,i,e){const s=e.length,n=this.actualBounds,o=this.naturalBounds;let r=!0;for(let l=0;lo.height)continue}else if(h.position>o.width)continue;let a=h.separatorStrokeWidth;isNaN(a)&&(a=i?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let f=h.separatorStroke;if(f===null&&(f=i?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),a===0||f===null)continue;this.wn(t,f,!1,!1,o,n);let c=!1,u=h.separatorDashArray;u===null&&(u=i?this.defaultRowSeparatorDashArray:this.defaultColumnSeparatorDashArray),u!==null&&(c=!0,t.enableDash(u,0)),t.beginPath();const d=h.position+a;i?d>o.height&&(a-=d-o.height):d>o.width&&(a-=d-o.width);let m=h.position+a/2;t.lineWidth=a;const g=this.ii;if(i){m+=g.top;const p=g.left,y=o.width-g.right;t.moveTo(p,m),t.lineTo(y,m)}else{m+=g.left;const p=g.top,y=o.height-g.bottom;t.moveTo(m,p),t.lineTo(m,y)}t.stroke(),t.endPath(),c&&t.disableDash()}}nb(t,i,e,s,n){const o=s.length,r=this.actualBounds,l=this.naturalBounds,h=this.AL(!0),a=this.AL(!1);for(let f=0;fu)continue;let d=c.computeEffectiveSpacing(),m=c.separatorStrokeWidth;isNaN(m)&&(m=e?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let g=c.separatorStroke;g===null&&(g=e?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),(g===null||c.index===(e?h:a))&&(m=0),d-=m;const p=c.position+m;let y=d+c.actual;if(p+y>u&&(y=u-p),y<=0)continue;const x=this.ii;this.wn(t,c.background,!0,!1,l,r),e?t.fillRect(x.left,p+x.top,r.width-(x.left+x.right),y):t.fillRect(p+x.left,x.top,y,r.height-(x.top+x.bottom))}}AL(t){const i=t?this.rowCount:this.columnCount;for(let e=0;ex&&n.set(P),Point.o(P)),Point.o(M),o&&n.O(r),k}}Vu(){const t=this.D.h,i=t.length;for(let e=0;ee||h>s)&&(this.u(),this.wt(l>e?e:l,h>s?s:h,0,0));break;case 2:this.u(!0),this.wt(e+f,s+c,0,0);break;case 5:this.u(!0),this.wt(e+f,h+c,0,0);break;case 4:this.u(!0),this.wt(l+f,s+c,0,0);break}}this.it.arrange(this,n,this.vo)}uh(t){const i=this.naturalBounds,e=this.Wo();if(Rect.contains(0,0,i.width,i.height,t.x,t.y)){const s=this.D.h,n=s.length,o=Point.H(0,0);for(let r=n;r--;){const l=s[r];if(!(!l.visible&&l!==e)&&(o.set(t).Ye(l.O),l.containsPoint(o)))return Point.o(o),!0}return Point.o(o),this.Ft!==null}return!1}S0(t){if(this.eo===t)return this;const i=this.D.h,e=i.length;for(let s=0;sd.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;let m=c;const g=c instanceof Panel?c:null,p=Transform.a();p.set(r),(g!==null?g.Ym(t,i,e,s,n,p):m.rL(t,s,p))&&(i!==null&&(m=i(m)),m!==null&&(e===null||e(m))&&n.add(m)),Transform.o(p)}}return o===void 0&&Transform.o(r),s}return o===void 0&&Transform.o(r),!1}z2(t,i,e){const s=this.D.h,n=s.length;for(let o=n;o--;){const r=s[o];if(!r.visible)continue;const l=r.actualBounds,h=this.naturalBounds;if(l.x>h.width||l.y>h.height||l.x+l.width<0||l.y+l.height<0)continue;r instanceof Panel&&r.z2(t,i,e);let a=r;t!==null&&(a=t(a)),a!==null&&(i===null||i(a))&&e.add(a)}}aA(t,i,e,s,n,o){if(this.pickable===!1)return!1;e===void 0&&(e=null),s===void 0&&(s=null);const r=this.naturalBounds,l=this.kn(),h=l?t:Point.H(t.x,t.y).Ye(this.O),a=l?i:Point.H(i.x,i.y).Ye(this.O),f=h.distanceSquaredPoint(a),c=h.x>0&&h.x0&&h.yS.width||b.y>S.height||b.x+b.width<0||b.y+b.height<0))continue;if(k.kn()){const C=k.O;d.set(t).Ye(C),m.set(i).Ye(C)}else d.set(t),m.set(i);let M=k;const A=k instanceof Panel?k:null;(A!==null?A.aA(d,m,e,s,n,o):M.lL(d,m,n))&&(e!==null&&(M=e(M)),M!==null&&(s===null||s(M))&&o.add(M))}Point.o(d),Point.o(m)}return n?c:u}return!1}R2(t){let i=null;if(t instanceof Shape){i=t.spot1,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot1)}return i===null&&(i=Spot.TopLeft),i}I2(t){let i=null;if(t instanceof Shape){i=t.spot2,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot2)}return i===null&&(i=Spot.BottomRight),i}add(...t){for(let i=0;i=s.count&&t>=s.count)return;s.removeAt(r),n=r}else Util.n("element "+i.toString()+" has panel "+e.toString()+" but is not contained by it.")}(t<0||t>s.count)&&(t=s.count),s.insertAt(t,i),(t===0||i.isPanelMain)&&(this.ll=null),this.Xo()||this.u(),i.u(!1),i.portId!==null?this.Mn=!0:i instanceof Panel&&i.Mn===!0&&(this.Mn=!0),this.as=null,this.isEnabledObject()||this.ob(i,!1);const o=this.part;if(o!==null){o.V0(),o.pc(),this.Mn&&o instanceof Node&&(o.Mn=!0),o.Mn&&o instanceof Node&&(o.ae=null);const r=this.diagram;if(r!==null&&r.undoManager.isUndoingRedoing)return;n!==-1&&o.raiseChangedEvent(4,"elements",this,i,null,n,null),o.raiseChangedEvent(3,"elements",this,null,i,null,t)}}get Mn(){return(this.l&8388608)!==0}set Mn(t){(this.l&8388608)!==0!==t&&(this.l=this.l^8388608)}u2(){return(this.l&16777216)!==0}X2(t){t?this.l|=16777216:this.l&=-16777217}gI(t){t.Pa(this),t.sl=null;const i=this.D,e=i.count;i.insertAt(e,t);const s=this.part;if(s!==null){s.V0(),t.portId!==null&&s instanceof Node&&(s.Mn=!0);const n=this.diagram;if(n!==null&&n.undoManager.isUndoingRedoing)return;s.raiseChangedEvent(3,"elements",this,null,t,null,e)}}ER(t){const i=this.D.h,e=i.length;let s=-1;for(let n=0;n=0&&this.oe(t,!0)}oe(t,i){const e=this.D,s=e.elt(t);if(s.sl=null,s.Pa(null),this.vs!==null){const o=s.data;typeof o=="object"&&this.vs.delete(o)}e.removeAt(t),this.ye(!1),this.u(),this.ll===s&&(this.ll=null),this.as=null;const n=this.part;if(n!==null){n.V0(),n.pc(),n.invalidateAdornments(),n instanceof Node&&(s instanceof Panel?s.walkVisualTreeFrom(s,(r,l)=>n.S2(l,i)):n.S2(s,i));const o=this.diagram;if(o!==null&&o.undoManager.isUndoingRedoing)return;n.raiseChangedEvent(4,"elements",this,s,null,t,null)}}get ve(){return this.V===null&&(this.V=new TablePanelSettings),this.V.ve}get rowCount(){return this.V===null?0:this.ve.length}getRowDefinition(t){Debug&&Util.r(t,Panel,"getRowDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"getRowDefinition:idx"),t=Math.round(t);const i=this.ve;if(i[t]===void 0){const e=new RowColumnDefinition;e.Pa(this),e.isRow=!0,e.index=t,i[t]=e,this.raiseChangedEvent(3,"rowdefs",this,null,e,null,t)}return i[t]}removeRowDefinition(t){if(Debug&&Util.r(t,Panel,"removeRowDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"removeRowDefinition:idx"),this.rowCount===0)return;t=Math.round(t);const i=this.ve,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"rowdefs",this,e,null,t,null),this.u()}}VA(t,i){const e=this.ve;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.u()}}get Je(){return this.V===null&&(this.V=new TablePanelSettings),this.V.Je}get columnCount(){return this.V===null?0:this.Je.length}getColumnDefinition(t){Debug&&Util.r(t,Panel,"getColumnDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"getColumnDefinition:idx"),t=Math.round(t);const i=this.Je;if(i[t]===void 0){const e=new RowColumnDefinition;e.Pa(this),e.isRow=!1,e.index=t,i[t]=e,this.raiseChangedEvent(3,"coldefs",this,null,e,null,t)}return i[t]}removeColumnDefinition(t){if(Debug&&Util.r(t,Panel,"removeColumnDefinition:idx"),t<0&&Util.G(t,">= 0",Panel,"removeColumnDefinition:idx"),this.columnCount===0)return;t=Math.round(t);const i=this.Je,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"coldefs",this,e,null,t,null),this.u()}}zA(t,i){const e=this.Je;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.u()}}addRowColumnDefinition(t){let i=null;return t.isRow?i=this.getRowDefinition(t.index):t.isRow||(i=this.getColumnDefinition(t.index)),i&&i.Z1(t),this}addRowDefinition(t,i){const e=this.getRowDefinition(t);return e&&e.Z1(new RowColumnDefinition(i)),this}addColumnDefinition(t,i){const e=this.getColumnDefinition(t);return e&&e.Z1(new RowColumnDefinition(i)),this}get rowSizing(){return this.V!==null?this.V.wp:3}set rowSizing(t){const i=this.rowSizing;i!==t&&(Debug&&t!==3&&t!==2&&Util.n("Panel.rowSizing must be ProportionalExtra or None, not: "+t),this.V===null&&(this.V=new TablePanelSettings),this.V.wp=t,this.u(),this.i("rowSizing",i,t))}get columnSizing(){return this.V!==null?this.V.xp:3}set columnSizing(t){const i=this.columnSizing;i!==t&&(Debug&&t!==3&&t!==2&&Util.n("Panel.columnSizing must be ProportionalExtra or None, not: "+t),this.V===null&&(this.V=new TablePanelSettings),this.V.xp=t,this.u(),this.i("columnSizing",i,t))}get topIndex(){return this.V!==null?this.V.bp:0}set topIndex(t){const i=this.topIndex;i!==t&&((!isFinite(t)||t<0)&&Util.n("Panel.topIndex must be greater than zero and a real number, not: "+t),this.V===null&&(this.V=new TablePanelSettings),this.V.bp=t,this.u(),this.i("topIndex",i,t))}get leftIndex(){return this.V!==null?this.V.kp:0}set leftIndex(t){const i=this.leftIndex;i!==t&&((!isFinite(t)||t<0)&&Util.n("Panel.leftIndex must be greater than zero and a real number, not: "+t),this.V===null&&(this.V=new TablePanelSettings),this.V.kp=t,this.u(),this.i("leftIndex",i,t))}findRowForLocalY(t){if(t<0||this.type!==Panel.Table||this.rowCount===0)return-1;let i=0;const e=this.ve,s=e.length;let n=this.topIndex;for(;n{o.ch();const r=o.Ri;if(r!==null){o.w2(!1);const l=r.iterator;for(;l.next();){const h=l.value;h.mode===2&&o.w2(!0);const a=h.sourceName;if(h.isToObject){a==="/"&&n.X2(!0);const f=h.oL(n,o);f!==null&&(i.add(f),f.so===null&&(f.so=new List),f.so.add(h))}t.add(h)}}if(o instanceof Panel&&o.type===Panel.Table){if(o.rowCount>0){const l=o.ve,h=l.length;for(let a=0;a0){const l=o.Je,h=l.length;for(let a=0;a0&&o instanceof Panel){const h=r.substring(0,l),a=r.substring(l+1),f=o.findObject(h);f!==null?(o=f,n.targetProperty=a):(Util.ht('Warning: unable to find GraphObject named "'+h+'" for Binding: '+n.toString()),o=null)}if(o instanceof RowColumnDefinition){const h=GSet.gs(o.panel);n.targetId=h===void 0?-1:h,o.panel.eo=n.targetId}else if(o instanceof GraphObject){const h=GSet.gs(o);n.targetId=h===void 0?-1:h,o.eo=n.targetId}else Util.n("Unknown type of binding target: "+o);n.check(o)}}return t.w(),this instanceof Part&&(this.Ae()&&this.ensureBounds(),Debug&&!Panel.RL&&this.walkVisualTreeFrom(this,(n,o)=>{if(o instanceof Panel&&(o.type===Panel.Auto||o.type===Panel.Spot||o.type===Panel.Graduated)&&o.elements.count<=1&&!(o instanceof Part)){let r=!1;if(o.elements.count===1&&(r=o.itemArray!==null,!r)){for(s=t.iterator;s.next();)if(s.value.targetProperty==="itemArray"){r=!0;break}}r||(Util.ht("Auto, Spot, or Graduated Panel should not have zero or one elements: "+o.toString()+" in "+n.toString()),Panel.RL=!0)}})),this}static RL=!1;copyTemplate(t){t===void 0&&(t=!1);const i=this.copy();return i.mI(e=>{e instanceof Panel&&(e.Ws=null,e.si=null);const s=e.Ri;s!==null&&(e.Ri=null,s.each(o=>e.bind(o.copy())));const n=e.Ss;n!==null&&(e.Ss=null,n.each(o=>e.trigger(o.value.copy())))}),t&&i.ci(),i}updateTargetBindings(t){const i=this.Ws;if(i===null)return;t===void 0&&(t="");const e=i.iterator;for(;e.next();){const s=e.value,n=this.IL(s,t);if(n===null)continue;const{data:o,elt:r}=n;s.isToTheme&&this.diagram===null||r!==void 0&&s.updateTarget(r,o)}}Yo(){if(this.diagram!==null)if(this.M2()){const t=this.Ws.iterator;for(;t.next();){const i=t.value;if(!i.isToTheme)continue;const e=this.IL(i);if(e===null)continue;const{data:s,elt:n}=e;n!==void 0&&i.updateTarget(n,s)}}else{const t=this.D.h,i=t.length;for(let e=0;e0;let r=0;for(;n0){const i=this.D.elt(0);if(i.isPanelMain&&i instanceof Panel&&i.nl())return 1}return 0}rebuildItemElements(){const t=this.yp();for(;this.D.length>t;)this.oe(this.D.length-1,!1);this.OL(null,this.itemArray)}OL(t,i){const e=this.yp(),s=i;if(s===null||s.length===0){for(;this.D.length>e;)this.oe(this.D.length-1,!1);return}if(this.D.length<=e){const n=s.length;for(let o=0;o(w[w.Default=1]="Default",w[w.None=2]="None",w[w.ProportionalExtra=3]="ProportionalExtra",w))(Sizing||{});class RowColumnDefinition{Hs;Sp;Bt;La;Ta;ai;gt;Sd;ro;Jo;Md;Pd;Da;Ft;Nd;Js;lt;Zi;xe;constructor(t){GSet.vi(this),this.Hs=null,this.Sp=!0,this.Bt=0,this.xe=NaN,this.La=0,this.Ta=1/0,this.ai=Spot.Default,this.lt=0,this.Zi=0,this.gt=0,this.Js=null,this.Sd=1,this.ro=1,this.Jo=null,this.Md=null,this.Pd=NaN,this.Da=null,this.Ft=null,this.Nd=!1,t&&(Object.assign(this,t),t.column!==void 0?(this.isRow=!1,this.index=t.column):t.row!==void 0&&(this.isRow=!0,this.index=t.row))}copy(){const t=new RowColumnDefinition;return t.Sp=this.Sp,t.Bt=this.Bt,t.xe=this.xe,t.La=this.La,t.Ta=this.Ta,t.ai=this.ai,t.lt=this.lt,t.Zi=this.Zi,t.gt=this.gt,t.ro=this.ro,t.Sd=this.Sd,this.Jo===null?t.Jo=null:t.Jo=this.Jo.L(),t.Md=this.Md,t.Pd=this.Pd,t.Da=null,this.Da!==null&&(t.separatorDashArray=this.separatorDashArray.slice()),t.Ft=this.Ft,t.Nd=this.Nd,t.Js=this.Js,t}Z1(t){t.isRow?this.height=t.height:this.width=t.width,this.minimum=t.minimum,this.maximum=t.maximum,this.alignment=t.alignment,this.stretch=t.stretch,this.sizing=t.sizing,this.Jo=t.separatorPadding===null?null:t.separatorPadding.L(),this.separatorStroke=t.separatorStroke,this.separatorStrokeWidth=t.separatorStrokeWidth,this.Da=null,t.separatorDashArray&&(this.Da=t.separatorDashArray.slice()),this.background=t.background,this.coversSeparators=t.coversSeparators,this.Js=t.Js}fi(t){t in Sizing?this.sizing=t:Util.ur(this,t)}toString(){return"RowColumnDefinition "+(this.isRow?"(Row ":"(Column ")+this.index+") #"+GSet.gs(this)}static Default=1;static None=2;static ProportionalExtra=3;Pa(t){this.Hs=t}computeEffectiveSpacingTop(t){let i=0;const e=this.Hs;if(this.index!==t){let n=this.separatorStroke;n===null&&e!==null&&(n=this.isRow?e.defaultRowSeparatorStroke:e.defaultColumnSeparatorStroke),n!==null&&(i=this.separatorStrokeWidth,isNaN(i)&&(e!==null?i=this.isRow?e.defaultRowSeparatorStrokeWidth:e.defaultColumnSeparatorStrokeWidth:i=0))}let s=this.Jo;if(s===null)if(e!==null)s=e.defaultSeparatorPadding;else return i;return i+(this.isRow?s.top:s.left)}computeEffectiveSpacing(){let t=0;const i=this.Hs;let e=0;const s=this.isRow;if(i!==null&&i.type===Panel.Table){const o=s?i.ve.length:i.Je.length;for(let r=0;r= 0",RowColumnDefinition,"height"),this.xe=t,this.actual=this.lt,this.panel!==null&&this.panel.u(),this.i("height",i,t))}get width(){return this.xe}set width(t){const i=this.xe;i!==t&&(Debug&&Util.t(t,"number",RowColumnDefinition,"width"),t<0&&Util.G(t,">= 0",RowColumnDefinition,"width"),this.xe=t,this.actual=this.lt,this.panel!==null&&this.panel.u(),this.i("width",i,t))}get minimum(){return this.La}set minimum(t){const i=this.La;i!==t&&(Debug&&Util.t(t,"number",RowColumnDefinition,"minimum"),(t<0||!isFinite(t))&&Util.G(t,">= 0",RowColumnDefinition,"minimum"),this.La=t,this.actual=this.lt,this.panel!==null&&this.panel.u(),this.i("minimum",i,t))}get maximum(){return this.Ta}set maximum(t){const i=this.Ta;i!==t&&(Debug&&Util.t(t,"number",RowColumnDefinition,"maximum"),t<0&&Util.G(t,">= 0",RowColumnDefinition,"maximum"),this.Ta=t,this.actual=this.lt,this.panel!==null&&this.panel.u(),this.i("maximum",i,t))}get alignment(){return this.ai}set alignment(t){const i=this.ai;i.equals(t)||(Debug&&Util.s(t,Spot,RowColumnDefinition,"alignment"),this.ai=t.L(),this.panel!==null&&this.panel.u(),this.i("alignment",i,t))}get stretch(){return this.ro}set stretch(t){const i=this.ro;i!==t&&(this.ro=t,this.panel!==null&&this.panel.u(),this.i("stretch",i,t))}get separatorPadding(){return this.Jo}set separatorPadding(t){typeof t=="number"?t=new Margin(t):t!==null&&Debug&&Util.s(t,Margin,RowColumnDefinition,"separatorPadding");const i=this.Jo;(t===null||i===null||!i.equals(t))&&(t!==null&&(t=t.L()),this.Jo=t,this.panel!==null&&this.panel.u(),this.i("separatorPadding",i,t))}get separatorStroke(){return this.Md}set separatorStroke(t){const i=this.Md;i!==t&&(t!==null&&Brush.cd(t,"RowColumnDefinition.separatorStroke"),t instanceof Brush&&t.w(),this.Md=t,this.panel!==null&&this.panel.u(),this.i("separatorStroke",i,t))}get separatorStrokeWidth(){return this.Pd}set separatorStrokeWidth(t){const i=this.Pd;i!==t&&(this.Pd=t,this.panel!==null&&this.panel.u(),this.i("separatorStrokeWidth",i,t))}get separatorDashArray(){return this.Da}set separatorDashArray(t){const i=this.Da;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Bi(t,"Array",RowColumnDefinition,"separatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("separatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.Da=t,this.panel!==null&&this.panel.T(),this.i("separatorDashArray",i,t)}}get background(){return this.Ft}set background(t){const i=this.Ft;i!==t&&(t!==null&&Brush.cd(t,"RowColumnDefinition.background"),t instanceof Brush&&t.w(),this.Ft=t,this.panel!==null&&this.panel.T(),this.i("background",i,t))}get coversSeparators(){return this.Nd}set coversSeparators(t){const i=this.Nd;i!==t&&(Util.t(t,"boolean",RowColumnDefinition,"coversSeparators"),this.Nd=t,this.panel!==null&&this.panel.T(),this.i("coversSeparators",i,t))}get sizing(){return this.Sd}set sizing(t){const i=this.Sd;i!==t&&(Debug&&Util.tt(t,Sizing,"Sizing"),this.Sd=t,this.panel!==null&&this.panel.u(),this.i("sizing",i,t))}eb(){if(this.sizing===1){const t=this.Hs;return this.isRow?t.rowSizing:t.columnSizing}return this.sizing}get actual(){return this.lt}set actual(t){isNaN(this.xe)?this.lt=Math.max(Math.min(this.Ta,t),this.La):this.lt=Math.max(Math.min(this.Ta,this.xe),this.La)}get measured(){return this.Zi}set measured(t){this.Zi=t}get total(){return this.lt+this.computeEffectiveSpacing()}get position(){return this.gt}set position(t){this.gt=t}bind(t,i,e,s){return this.ac(t,i,e,s),this}bindTwoWay(t,i,e,s){const n=this.ac(t,i,e,s);return s===void 0&&n.makeTwoWay(),this}theme(t,i,e,s,n){return this.ph(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.ph(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.ph(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.ph(t,i,e,s,n).ofModel(),this}ac(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.$0(n),n}ph(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.$0(o),o}$0(t){t.Ce=this;const i=this.panel;if(i!==null){const e=i.findBindingPanel();e!==null&&e.yL()&&Util.n("Cannot add a Binding to a RowColumnDefinition that is already frozen: "+t+" on "+i)}this.Js===null&&(this.Js=new List),this.Js.add(t)}}class Shape extends GraphObject{mt;Ps;Cd;Fa;$i;Zo;jo;Rt;Ad;Ld;_;constructor(t,i){super(),this.mt=null,this.Ps=null,this.Cd="None",this.Fa="black",this.$i="black",this.Zo=1,this.jo=null,this.Rt=null,this.Ad=NaN,this.Ld=NaN,this._=null,typeof t=="string"?this.figure=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.mt=this.mt,t.Ps=this.Ps,t.Cd=this.Cd,t.Fa=this.Fa,t.$i=this.$i,t.Zo=this.Zo,this.jo!==null&&(t.jo=this.jo.slice()),this.Rt!==null&&(this.Rt.wi?t.Rt=this.Rt:t.Rt=this.Rt.copy()),t.Ad=this.Ad,t.Ld=this.Ld,this._!==null&&(t._=this._.copy())}Ra(){this.Rt===null?this.Rt=new ShapeTemplateSettings:this.Rt.wi&&(this.Rt=this.Rt.copy())}ch(){super.ch(),this.Rt!==null&&(this.Rt.wi=!0)}fi(t){t in GeometryStretch?this.geometryStretch=t:super.fi(t)}toString(){return"Shape("+(this.figure!=="None"?this.figure:this.toArrow!=="None"?this.toArrow:this.fromArrow)+")#"+GSet.gs(this)}SI(t,i){const e=this.pathPattern;e.wt(1/0,1/0);const s=e.measuredBounds;e.qt(0,0,s.width,s.height);const n=this.geometry;t.save(),t.beginPath();const o=Util.at();if(n.type===1)o.push(n.startX),o.push(n.startY),o.push(n.endX),o.push(n.endY),this.Td(t,i,o,e);else if(n.type===4){const r=n.figures.iterator;for(;r.next();){const l=r.value;o.length=0,o.push(l.startX),o.push(l.startY);let h=l.startX,a=l.startY,f=h,c=a;const u=l.segments.h,d=u.length;for(let m=0;m=.1;){if(P===0&&(M?(b=k,b-=S,y-=S,M=!1):b=k,b===0&&(b=1)),b>y){b=y,Util.nt(x);return}b>p?(P=b-p,b=p):P=0;let N=Math.sqrt(b*b/(1+m*m));if(u<0&&(N=-N),h+=N,a+=m*N,t.translate(h,a),t.rotate(g),t.translate(-(r/2),-(l/2)),P===0&&s.mh(t,i),t.translate(r/2,l/2),t.rotate(-g),t.translate(-h,-a),y-=b,p-=b,P!==0){if(A++,A===x.length){Util.nt(x);return}C=x[A],u=C[0],g=C[1],m=C[2],p=C[3],b=P}}Util.nt(x)}mh(t,i){const e=t instanceof SVGContext;let s=this.$i;const n=this.Fa;if(s===null&&n===null)return;const o=this.mt;if(o===null)return;t.commitTransform();const r=this.actualBounds,l=this.naturalBounds;n!==null&&this.wn(t,n,!0,!1,l,r);const h=this.part;let a=this.Zo;s!==null&&a===0&&h!==null&&(this.isPanelMain||h.findMainElement()===this)&&(a=h.NI()),a===0&&(s=null),s!==null&&a!==0&&(this.wn(t,s,!1,!1,l,r),t.lineWidth=a,t.lineJoin=this.strokeJoin,t.lineCap=this.strokeCap,t.miterLimit=this.strokeMiterLimit);let f=!1;h&&i.getRenderingHint("drawShadows")&&(f=h.isShadowed),t.ol===!1&&(f=!1);let c=!0;s!==null&&(n===null||n==="transparent")&&(c=!1);let u=!1;const d=this.strokeDashArray;if(d!==null&&(u=!0,t.enableDash(d,this.strokeDashOffset)),o.type===1)t.beginPath(),t.moveTo(o.startX,o.startY),t.lineTo(o.endX,o.endY),s!==null&&t.strokeContext(),t.endPath();else if(o.type===2){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.min(m,p),k=Math.min(g,y),b=Math.abs(p-m),S=Math.abs(y-g);t.beginPath(),t.rect(x,k,b,S),n!==null&&t.fillContext(n,!1,null),s!==null&&(c&&f&&t.shadowsOff(),t.strokeContext(),c&&f&&t.shadowsOn()),t.endPath()}else if(o.type===3){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.abs(p-m)/2,k=Math.abs(y-g)/2,b=Math.min(m,p)+x,S=Math.min(g,y)+k;t.beginPath(),t.moveTo(b,S-k),t.bezierCurveTo(b+Geo.Un*x,S-k,b+x,S-Geo.Un*k,b+x,S),t.bezierCurveTo(b+x,S+Geo.Un*k,b+Geo.Un*x,S+k,b,S+k),t.bezierCurveTo(b-Geo.Un*x,S+k,b-x,S+Geo.Un*k,b-x,S),t.bezierCurveTo(b-x,S-Geo.Un*k,b-Geo.Un*x,S-k,b,S-k),t.closePath(),n!==null&&t.fillContext(n,!1,null),s!==null&&(c&&f&&t.shadowsOff(),t.strokeContext(),c&&f&&t.shadowsOn()),t.endPath()}else if(o.type===4){const m=o.figures,g=m.length;for(let p=0;p1||this.pathPattern!==null?!0:super.ad(t)}m2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("path");for(let s=0;s1,i);Util.n("Unknown Geometry type: "+e.type)}}rd(t,i,e,s){const n=this.desiredSize,o=this.Zo;t=Math.max(t,0),i=Math.max(i,0);let r;if(this.Ps!==null)r=this.geometry.bounds;else{const g=this.figure;let p=Shape.G2[g];if(p===void 0){let y=Geo.qn[g];typeof y=="string"&&(y=Geo.qn[y]),typeof y=="function"?(p=y(null,100,100),Shape.G2[g]=p):Util.n("Unsupported Figure: "+g)}r=p.bounds}let l=r.width,h=r.height,a=r.width,f=r.height;switch(this.qs(!0)){case 0:e=0,s=0;break;case 2:a=Math.max(t-o,0),f=Math.max(i-o,0);break;case 5:a=Math.max(t-o,0),s=0;break;case 4:e=0,f=Math.max(i-o,0);break}isFinite(n.width)&&(a=n.width),isFinite(n.height)&&(f=n.height);const u=this.maxSize,d=this.minSize;e=Math.max(e-o,d.width),s=Math.max(s-o,d.height),a=Math.min(u.width,a),f=Math.min(u.height,f),a=isFinite(a)?Math.max(e,a):Math.max(l,e),f=isFinite(f)?Math.max(s,f):Math.max(h,s);const m=this.lM();switch(m){case 0:break;case 2:l=a,h=f;break;case 6:{let g=Math.min(a/l,f/h);isFinite(g)||(g=1),l=l*g,h=h*g;break}default:Util.n(m+" is not a valid geometryStretch.")}if(this.Ps!==null){l===0&&(l=.001),h===0&&(h=.001);const p=(this.Ps!==null?this.Ps:this.mt).ZD(l,h);Debug&&p.w(),this.mt=p}else(this.mt===null||!Geo.q(this.mt.cf,t-o)||!Geo.q(this.mt.uf,i-o))&&(this.mt=Shape.CI(this,l,h));r=this.mt.bounds,t===1/0||i===1/0?this.no(r.x-o/2,r.y-o/2,t===0&&l===0?0:r.width+o,i===0&&h===0?0:r.height+o):this.no(-(o/2),-(o/2),a+o,f+o),n.isReal()?(a=n.width,f=n.height,a=Math.min(u.width,a),f=Math.min(u.height,f),a=Math.max(d.width,a),f=Math.max(d.height,f),this.Hi.e(0,0,a,f)):this.Hi.c(r)}lM(){const t=this.geometryStretch;return this.Ps!==null?t===1?2:t:t===1?Shape.G2[this.figure].defaultStretch:t}dh(t,i,e,s){this.commonArrange(t,i,e,s)}getNearestIntersectionPoint(t,i,e){return this.nc(t.x,t.y,i.x,i.y,e)}nc(t,i,e,s,n){const o=this.O,r=1/(o.m11*o.m22-o.m12*o.m21),l=o.m22*r,h=-o.m12*r,a=-o.m21*r,f=o.m11*r,c=r*(o.m21*o.dy-o.m22*o.dx),u=r*(o.m12*o.dx-o.m11*o.dy),d=t*l+i*a+c,m=t*h+i*f+u,g=e*l+s*a+c,p=e*h+s*f+u,y=this.Zo/2;let x=this.mt;x===null&&(this.wt(1/0,1/0),x=this.mt);const k=x.bounds;let b=!1;if(x.type===1)if(this.strokeWidth<=1.5)b=Geo.Hn(x.startX,x.startY,x.endX,x.endY,d,m,g,p,n);else{let S=0,M=0;if(x.startX===x.endX)S=y,M=0;else{const T=(x.endY-x.startY)/(x.endX-x.startX);M=y/Math.sqrt(1+T*T),S=M*T}const A=Util.at();let C=new Point;Geo.Hn(x.startX+S,x.startY+M,x.endX+S,x.endY+M,d,m,g,p,C)&&A.push(C),C=new Point,Geo.Hn(x.startX-S,x.startY-M,x.endX-S,x.endY-M,d,m,g,p,C)&&A.push(C),C=new Point,Geo.Hn(x.startX+S,x.startY+M,x.startX-S,x.startY-M,d,m,g,p,C)&&A.push(C),C=new Point,Geo.Hn(x.endX+S,x.endY+M,x.endX-S,x.endY-M,d,m,g,p,C)&&A.push(C);const P=A.length;if(P===0)return Util.nt(A),!1;b=!0;let N=1/0;for(let T=0;T0&&k.contains(D,F)&&(P.x=D,P.y=F,this.containsPoint(P)))for(N!==0&&Math.abs(N)<.5?(T*=.5/N,N=.5):T!==0&&Math.abs(T)<.5&&(N*=.5/T,T=.5),D-=N,F-=T;k.contains(D,F);)D-=N,F-=T;const R=.6;n.x=g,n.y=p;for(let K=0;Ke?t-e:e-t)<(i>s?i-s:s-i)){const c=ic||Geo.q(h.y,c))&&(h.yc||Geo.q(h.x,c))&&(h.x=a&&h<=f}else{let a=0,f=0;return s=a&&l<=f}}TI(t,i){if(this.containedInRect(t,i)||i===void 0&&(i=this.O,t.containsRect(this.actualBounds)))return!0;const e=t.left,s=t.right,n=t.top,o=t.bottom,r=Point.a(),l=Point.a(),h=Point.a(),a=Transform.a();a.set(i),a.mC(this.O),a.Pw(),l.x=s,l.y=n,l.O(a),r.x=e,r.y=n,r.O(a);let f=!1;return this.Ia(r,l,h)?f=!0:(r.x=s,r.y=o,r.O(a),this.Ia(r,l,h)?f=!0:(l.x=e,l.y=o,l.O(a),this.Ia(r,l,h)?f=!0:(r.x=e,r.y=n,r.O(a),this.Ia(r,l,h)&&(f=!0)))),Transform.o(a),Point.o(r),Point.o(l),Point.o(h),f}lL(t,i,e){if(e&&this.fill!==null&&this.uh(t,!0))return!0;let s=t.distanceSquaredPoint(i);const n=s;this.strokeWidth>1.5&&(s=this.strokeWidth/2+Math.sqrt(s),s*=s);let o=this.mt;if(o===null&&(this.wt(1/0,1/0),o=this.mt,o===null))return!1;if(!e){const c=o.bounds,u=c.x,d=c.y,m=c.x+c.width,g=c.y+c.height;if(Point.distanceSquared(t.x,t.y,u,d)<=s&&Point.distanceSquared(t.x,t.y,m,d)<=s&&Point.distanceSquared(t.x,t.y,u,g)<=s&&Point.distanceSquared(t.x,t.y,m,g)<=s)return!0}function r(c,u){const d=c.length;for(let m=0;ms)return!0;return!1}const l=o.startX,h=o.startY,a=o.endX,f=o.endY;if(o.type===1){const c=Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,f),u=(a-l)*(t.x-l)+(f-h)*(t.y-h),d=(l-a)*(t.x-a)+(h-f)*(t.y-f),m=u>=0&&d>=0?s:n;return c<=m}else if(o.type===2){let c=!1;return e&&(c=Point.distanceLineSegmentSquared(t.x,t.y,l,h,l,f)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,h)<=s||Point.distanceLineSegmentSquared(t.x,t.y,a,h,a,f)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,f,a,f)<=s),c}else if(o.type===3){const c=(l+a)/2,u=(h+f)/2,d=t.x-c,m=t.y-u,g=Math.abs(a-l)/2,p=Math.abs(f-h)/2;if(g===0||p===0)return Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,f)<=s;if(e){const y=Geo.KD(g,p,d,m);return y*y<=s}else return!(Point.distanceSquared(d,m,-g,0)>=s||Point.distanceSquared(d,m,0,-p)>=s||Point.distanceSquared(d,m,0,p)>=s||Point.distanceSquared(d,m,g,0)>=s)}else if(o.type===4){const c=o.bounds,u=c.x,d=c.y,m=c.x+c.width,g=c.y+c.height;if(t.x>m&&t.xg&&t.ys&&Point.distanceLineSegmentSquared(t.x,t.y,u,d,m,d)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,u,g)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,m,d)>s)return!1;const p=Math.sqrt(s);if(e){if(this.fill===null?o.CC(t.x,t.y,p):o.vk(t,p,!0,!1))return!0}else{const y=o.figures;for(let x=0;xs)return!1;const M=k.segments.h,A=M.length;for(let C=0;Cs)return!1;break;case 3:{const N=Util.at();Geo.Gn(b,S,P.point1X,P.point1Y,P.point2X,P.point2Y,P.endX,P.endY,.8,N);const T=r(N,t);if(Util.nt(N),T||(b=P.endX,S=P.endY,t.distanceSquared(b,S)>s))return!1;break}case 4:{const N=Util.at();Geo.qg(b,S,P.point1X,P.point1Y,P.endX,P.endY,.8,N);const T=r(N,t);if(Util.nt(N),T||(b=P.endX,S=P.endY,t.distanceSquared(b,S)>s))return!1;break}case 5:case 6:{const N=P.type===5?P.To(k):P.Yh(k,b,S),T=N.length;if(T===0){if(b=P.type===5?P.centerX:P.endX,S=P.type===5?P.centerY:P.endY,t.distanceSquared(b,S)>s)return!1;break}let L=null;const D=Util.at();for(let F=0;F=0){this.Zo=t,this.u();const e=this.part;e!==null&&e.pc(),this.i("strokeWidth",i,t)}else Util.G(t,"value >= 0",Shape,"strokeWidth:value")}N0(){return this.Zo}get strokeCap(){return this.Rt!==null?this.Rt.Mp:"butt"}set strokeCap(t){const i=this.strokeCap;i!==t&&(typeof t=="string"&&(t==="butt"||t==="round"||t==="square")?(this.Ra(),this.Rt.Mp=t,this.T(),this.i("strokeCap",i,t)):Util.G(t,'"butt", "round", or "square"',Shape,"strokeCap"))}get strokeJoin(){return this.Rt!==null?this.Rt.Pp:"miter"}set strokeJoin(t){const i=this.strokeJoin;i!==t&&(typeof t=="string"&&(t==="miter"||t==="bevel"||t==="round")?(this.Ra(),this.Rt.Pp=t,this.T(),this.i("strokeJoin",i,t)):Util.G(t,'"miter", "bevel", or "round"',Shape,"strokeJoin"))}get strokeMiterLimit(){return this.Rt!==null?this.Rt.Np:10}set strokeMiterLimit(t){const i=this.strokeMiterLimit;if(i!==t)if(Debug&&Util.r(t,Shape,"strokeMiterLimit"),t>=1){this.Ra(),this.Rt.Np=t,this.T();const e=this.part;e!==null&&e.pc(),this.i("strokeMiterLimit",i,t)}else Debug&&Util.G(t,"value >= 1",Shape,"strokeWidth:value")}get strokeDashArray(){return this.jo}set strokeDashArray(t){const i=this.jo;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.Bi(t,"Array",Shape,"strokeDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.n("strokeDashArray:value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.jo=t,this.T(),this.i("strokeDashArray",i,t)}}get strokeDashOffset(){return this.Rt!==null?this.Rt.yh:0}set strokeDashOffset(t){const i=this.strokeDashOffset;i!==t&&(Debug&&Util.r(t,Shape,"strokeDashOffset"),t>=0&&(this.Ra(),this.Rt.yh=t,this.T(),this.i("strokeDashOffset",i,t)))}get figure(){return this.Cd}set figure(t){const i=this.Cd;if(i!==t){Debug&&Util.t(t,"string",Shape,"figure");let e=Geo.qn[t];if(typeof e=="function"?e=t:(e=Geo.qn[t.toLowerCase()],e||Util.n("Unknown Shape.figure: "+t)),i!==e){const s=this.part;s!==null&&s.pc(),this.Cd=e,this.Ps=null,this.le(),this.u(),this.i("figure",i,e)}}}get toArrow(){return this.Ut!==null?this.Ut.Cp:"None"}set toArrow(t){const i=this.toArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){Debug&&Util.t(t,"string",Shape,"toArrow");const e=Shape.VL(t);e===null?Util.n("Unknown Shape.toArrow: "+t):i!==e&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.Cp=e,this.Ps=null,this.le(),this.u(),this.zL(e),this.i("toArrow",i,e))}}get fromArrow(){return this.Ut!==null?this.Ut.Ap:"None"}set fromArrow(t){const i=this.fromArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){Debug&&Util.t(t,"string",Shape,"fromArrow");const e=Shape.VL(t);e===null?Util.n("Unknown Shape.fromArrow: "+t):i!==e&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.Ap=e,this.Ps=null,this.le(),this.u(),this.zL(e),this.i("fromArrow",i,e))}}zL(t){const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;this.YR();const e=Spot.MiddleRight;this.toArrow!=="None"?(this.segmentIndex=-1,this.alignmentFocus=e):this.fromArrow!=="None"&&(this.segmentIndex=0,this.alignmentFocus=new Spot(1-e.x,e.y))}get spot1(){return this.Rt!==null?this.Rt.jn:Spot.Default}set spot1(t){Util.s(t,Spot,Shape,"spot1");const i=this.spot1;i.equals(t)||(t=t.L(),this.Ra(),this.Rt.jn=t,this.u(),this.i("spot1",i,t))}get spot2(){return this.Rt!==null?this.Rt.Wn:Spot.Default}set spot2(t){Util.s(t,Spot,Shape,"spot2");const i=this.spot2;i.equals(t)||(t=t.L(),this.Ra(),this.Rt.Wn=t,this.u(),this.i("spot2",i,t))}get parameter1(){return this.Ad}set parameter1(t){const i=this.Ad;i!==t&&(this.Ad=t,this.le(),this.u(),this.i("parameter1",i,t))}get parameter2(){return this.Ld}set parameter2(t){const i=this.Ld;i!==t&&(this.Ld=t,this.le(),this.u(),this.i("parameter2",i,t))}get naturalBounds(){return this.Hi}rI(){const t=this.desiredSize;if(!t.isReal()&&this.mt!==null){const i=this.mt.bounds;this.Hi.c(i)}else this.Hi.e(0,0,t.width,t.height)}get pathPattern(){return this.Rt!==null?this.Rt.Lp:null}set pathPattern(t){const i=this.pathPattern;i!==t&&(Debug&&t!==null&&Util.s(t,GraphObject,Shape,"pathPattern"),this.Ra(),this.Rt.Lp=t,this.T(),this.i("pathPattern",i,t))}get geometryStretch(){return this.Rt!==null?this.Rt.Tp:1}set geometryStretch(t){const i=this.geometryStretch;i!==t&&(Util.tt(t,GeometryStretch,"GeometryStretch"),this.Ra(),this.Rt.Tp=t,this.u(),this.i("geometryStretch",i,t))}get interval(){return this._!==null?this._.wc:1}set interval(t){const i=this.interval;if(Debug&&Util.r(t,Shape,"interval"),t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this._===null&&(this._=new GradElementSettings),this._.wc=t;const e=this.diagram;e!==null&&this.panel===e.grid&&e.Zr(),this.u();const s=this.panel;s!==null&&(s.as=null),this.i("interval",i,t)}}get graduatedStart(){return this._!==null?this._.xc:0}set graduatedStart(t){const i=this.graduatedStart;Debug&&Util.r(t,Shape,"graduatedStart"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.xc=t,this.u(),this.i("graduatedStart",i,t))}get graduatedEnd(){return this._!==null?this._.bc:1}set graduatedEnd(t){const i=this.graduatedEnd;Debug&&Util.r(t,Shape,"graduatedEnd"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.bc=t,this.u(),this.i("graduatedEnd",i,t))}get graduatedSkip(){return this._!==null?this._.kc:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.t(t,"function",Shape,"graduatedSkip"),this._===null&&(this._=new GradElementSettings),this._.kc=t,this.u(),this.i("graduatedSkip",i,t))}static CI(t,i,e){let n=null;if(t.toArrow!=="None")n=Shape.fo[t.toArrow];else if(t.fromArrow!=="None")n=Shape.fo[t.fromArrow];else{let o=Geo.qn[t.figure];typeof o=="string"&&(o=Geo.qn[o]),o===void 0&&Util.n("Unknown Shape.figure: "+t.figure),n=o(t,i,e),n.cf=i,n.uf=e}if(n===null){const o=Geo.qn.Rectangle;typeof o=="function"&&(n=o(t,i,e))}return Debug&&(n.bounds.width>i+1e-5||n.bounds.height>e+1e-5)&&Util.n('Geometry made with figure "'+t.figure+'" has bounds '+n.bounds.toString()+" that are too large for the given size ("+i+","+e+"). See documentation for Shape.defineFigureGenerator."),n}static getFigureGenerators(){const t=new GMap;for(const i in Geo.qn){if(i===i.toLowerCase())continue;const e=Geo.qn[i];t.set(i,e)}return t.w(),t}static defineFigureGenerator(t,i){Util.t(t,"string",Shape,"defineFigureGenerator:name"),typeof i=="string"?Debug&&(i===""||!Geo.qn[i])&&Util.n("Shape.defineFigureGenerator synonym must not be empty or None or not a defined figure name: "+i):Util.t(i,"function",Shape,"defineFigureGenerator:func");const e=t.toLowerCase();Debug&&(t===""||t===e)&&Util.n("Shape.defineFigureGenerator name must not be empty or all-lower-case: "+t);const s=Geo.qn;s[t]=i,s[e]=t}static getArrowheadGeometries(){const t=new GMap;for(const i in Geo.Jg)if(Shape.fo[i]===void 0){const e=Geometry.parse(Geo.Jg[i],!1);Shape.fo[i]=e;const s=i.toLowerCase();s!==i&&(Shape.fo[s]=i)}for(const i in Shape.fo){if(i===i.toLowerCase())continue;const e=Shape.fo[i];e instanceof Geometry&&t.set(i,e)}return t.w(),t}static defineArrowheadGeometry(t,i){Util.t(t,"string",Shape,"defineArrowheadGeometry:name");let e=null;typeof i=="string"?(Util.t(i,"string",Shape,"defineArrowheadGeometry:pathstr"),e=Geometry.parse(i,!1)):(Util.s(i,Geometry,Shape,"defineArrowheadGeometry:pathstr"),e=i);const s=t.toLowerCase();(Debug&&t===""||s==="none"||t===s)&&Util.n("Shape.defineArrowheadGeometry name must not be empty or None or all-lower-case: "+t);const n=Shape.fo;n[t]=e,n[s]=t}static fo=new PropertyCollection;static G2=new PropertyCollection;static VL(t){let i=Shape.fo[t];if(i===void 0){const e=t.toLowerCase();if(e==="none")return"None";if(i=Shape.fo[e],i===void 0){let s=null;for(const n in Geo.Jg)if(n.toLowerCase()===e){s=n;break}if(s!==null){const n=Geometry.parse(Geo.Jg[s],!1);return Shape.fo[s]=n,e!==s&&(Shape.fo[e]=s),s}}}return typeof i=="string"?i:i instanceof Geometry?t:null}}class ShapeTemplateSettings{wi;Mp;Pp;Np;yh;Lp;Tp;jn;Wn;constructor(){this.wi=!1,this.Mp="butt",this.Pp="miter",this.Np=10,this.yh=0,this.Lp=null,this.Tp=1,this.jn=Spot.Default,this.Wn=Spot.Default}copy(){const t=new ShapeTemplateSettings;return t.Mp=this.Mp,t.Pp=this.Pp,t.Np=this.Np,t.yh=this.yh,t.Lp=this.Lp,t.Tp=this.Tp,t.jn=this.jn.L(),t.Wn=this.Wn.L(),t}}var Wrap=(w=>(w[w.None=0]="None",w[w.Fit=1]="Fit",w[w.DesiredSize=2]="DesiredSize",w[w.BreakAll=3]="BreakAll",w))(Wrap||{}),TextOverflow=(w=>(w[w.Clip=0]="Clip",w[w.Ellipsis=1]="Ellipsis",w))(TextOverflow||{}),TextFormat=(w=>(w[w.Trim=0]="Trim",w[w.None=1]="None",w))(TextFormat||{});class TextBlock extends GraphObject{ui;$i;Cn;Fe;xi;C0;Dd;_;$;Ol;co;An;Re;Oi;Ln;constructor(t,i){return super(),this.l|=2097152,this.ui="",this.$i="black",this.Cn="13px sans-serif",this.Fe=0,this.xi=0,this.C0=0,this.Dd=null,this._=null,this.$=null,this.Ol=0,this.co=null,this.An=0,this.Re=null,this.Oi=null,this.Ln=null,typeof t=="string"?this.text=t:t&&Object.assign(this,t),i&&Object.assign(this,i),this}cloneProtected(t){super.cloneProtected(t),t.ui=this.ui,t.$i=this.$i,t.Cn=this.Cn,t.Fe=this.Fe,t.xi=this.xi,t.C0=this.C0,t.Dd=this.Dd,this._!==null&&(t._=this._.copy()),this.$!==null&&(this.$.wi?t.$=this.$:t.$=this.$.copy()),t.Ol=this.Ol,t.co=this.co,t.An=this.An,t.Re=this.Re,t.Oi=this.Oi,t.Ln=this.Ln}Tn(){this.$===null?this.$=new TextBlockTemplateSettings:this.$.wi&&(this.$=this.$.copy())}ch(){super.ch(),this.$!==null&&(this.$.wi=!0)}dI(t){this.l=t.l|2048|4096,this._t=t.opacity,this.Ft=t.background,this.qe=t.desiredSize.L(),this.minSize=t.minSize.L(),this.maxSize=t.maxSize.L(),t.Pi!==null?this.Pi=t.Pi.copy():this.Pi=null,this.rt=t.scale,this.jt=t.angle,this.stretch=t.stretch,this.el=t.margin.L(),this.ai=t.alignment.L(),this.ic=t.alignmentFocus.L(),this.segmentFraction=t.segmentFraction,this.segmentOffset=t.segmentOffset.L(),this.segmentOrientation=t.segmentOrientation,t.hi!==null&&(this.hi=t.hi.copy()),this.shadowVisible=t.shadowVisible,this.ui=t.ui,this.$i=t.$i,this.Cn=t.Cn,this._!==null&&(this._=t._.copy()),t.$!==null&&(t.$.wi?this.$=t.$:this.$=t.$.copy()),this.Ol=t.Ol}cI(t){if(this.ui=t.text||"",this.jt=t.labelAngle||0,this.Fe=t.lineCount||0,this.DI(t.lines),t.naturalBounds&&(this.Hi=t.naturalBounds),t.actualBounds){const i=t.actualBounds;this.qt(i.x,i.y,i.width,i.height)}}fi(t){t in Wrap?this.wrap=t:super.fi(t)}toString(){return this.ui.length>22?'TextBlock("'+this.ui.substring(0,20)+'"...)':'TextBlock("'+this.ui+'")'}static getEllipsis(){return TextBlock.Dp}static setEllipsis(t){TextBlock.Dp=t,TextBlock.ab=new PropertyCollection,TextBlock.H2=0}static getBaseline(){return TextBlock.fb}static setBaseline(t){TextBlock.fb=t}static fb=null;static getUnderline(){return TextBlock.cb}static setUnderline(t){TextBlock.cb=t}static cb=null;static None=0;static WrapFit=1;static WrapDesiredSize=2;static WrapBreakAll=3;static OverflowClip=0;static OverflowEllipsis=1;static FormatTrim=0;static FormatNone=1;u(){super.u()}get font(){return this.Cn}set font(t){const i=this.Cn;i!==t&&(Debug&&(Util.t(t,"string",TextBlock,"font"),TextBlock.isValidFont(t)||Util.n('Not a valid font: "'+t+'"')),this.Cn=t,this.co=null,this.u(),this.i("font",i,t))}static isValidFont(t){return root.CSS?root.CSS.supports("font",t):!0}get text(){return this.ui}set text(t){const i=this.ui;t!=null?t=t.toString():t="",i!==t&&(this.ui=t,this.u(),this.i("text",i,t),this.hs(!0))}get textAlign(){return this.$!==null?this.$.Fp:"start"}set textAlign(t){const i=this.textAlign;i!==t&&(Debug&&Util.t(t,"string",TextBlock,"textAlign"),t==="start"||t==="end"||t==="left"||t==="right"||t==="center"?(this.Tn(),this.$.Fp=t,this.T(),this.i("textAlign",i,t)):Debug&&Util.G(t,'"start", "end", "left", "right", or "center"',TextBlock,"textAlign"))}get flip(){return this.$!==null?this.$.uo:0}set flip(t){const i=this.flip;i!==t&&(Util.tt(t,Flip,"Flip"),this.Tn(),this.$.uo=t,this.T(),this.i("flip",i,t))}get verticalAlignment(){return this.$!==null?this.$.hl:Spot.Top}set verticalAlignment(t){const i=this.verticalAlignment;i.equals(t)||(Debug&&(Util.s(t,Spot,TextBlock,"verticalAlignment"),t.isNoSpot()&&Util.n("TextBlock.verticalAlignment for "+this+" must be a real Spot, not:"+t)),t=t.L(),this.Tn(),this.$.hl=t,this.hc(),this.i("verticalAlignment",i,t))}get naturalBounds(){if(!this.Hi.isReal()){const t=Size.a();this.q2(this.ui,999999,t);let i=t.width;Size.o(t);let e=this.XL(i);const s=this.desiredSize;isNaN(s.width)||(i=s.width),isNaN(s.height)||(e=s.height),this.Hi.Kn(i,e)}return this.Hi}get isMultiline(){return(this.l&2097152)!==0}set isMultiline(t){const i=(this.l&2097152)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"isMultiline"),this.l=this.l^2097152,this.u(),this.i("isMultiline",i,t))}get isUnderline(){return(this.l&4194304)!==0}set isUnderline(t){const i=(this.l&4194304)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"isUnderline"),this.l=this.l^4194304,this.hs(!0),this.T(),this.i("isUnderline",i,t))}get isStrikethrough(){return(this.l&8388608)!==0}set isStrikethrough(t){const i=(this.l&8388608)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"isStrikethrough"),this.l=this.l^8388608,this.hs(!0),this.T(),this.i("isStrikethrough",i,t))}get wrap(){return this.$!==null?this.$.Rp:2}set wrap(t){const i=this.wrap;i!==t&&(Debug&&Util.tt(t,Wrap,"Wrap"),this.Tn(),this.$.Rp=t,this.u(),this.i("wrap",i,t))}get overflow(){return this.$!==null?this.$.Ip:0}set overflow(t){const i=this.overflow;i!==t&&(Debug&&Util.tt(t,TextOverflow,"Overflow"),this.Tn(),this.$.Ip=t,this.u(),this.i("overflow",i,t))}get isOverflowed(){return(this.l&16777216)!==0}j2(t){t?this.l|=16777216:this.l&=-16777217}get stroke(){return this.$i}set stroke(t){const i=this.$i;i!==t&&(t!==null&&Brush.cd(t,"TextBlock.stroke"),t instanceof Brush&&t.w(),this.$i=t,this.T(),this.i("stroke",i,t))}get lineCount(){return this.Fe}get lineHeight(){return this.Op()}get editable(){return(this.l&1048576)!==0}set editable(t){const i=(this.l&1048576)!==0;i!==t&&(Debug&&Util.t(t,"boolean",TextBlock,"editable"),this.l=this.l^1048576,this.i("editable",i,t))}get E2(){return(this.l&33554432)!==0}set E2(t){this.l=this.l^33554432}get textEditor(){return this.$!==null?this.$.Ep:null}set textEditor(t){const i=this.textEditor;i!==t&&(Debug&&!(t instanceof HTMLInfo)&&Util.n("TextBlock.textEditor must be an HTMLInfo."),this.Tn(),this.$.Ep=t,this.i("textEditor",i,t))}get errorFunction(){return this.$!==null?this.$.fs:null}set errorFunction(t){const i=this.errorFunction;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"errorFunction"),this.Tn(),this.$.fs=t,this.i("errorFunction",i,t))}get interval(){return this._!==null?this._.wc:1}set interval(t){const i=this.interval;if(Debug&&Util.r(t,TextBlock,"interval"),t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this._===null&&(this._=new GradElementSettings),this._.wc=t,this.u();const e=this.panel;e!==null&&(e.as=null),this.i("interval",i,t)}}get graduatedStart(){return this._!==null?this._.xc:0}set graduatedStart(t){const i=this.graduatedStart;Debug&&Util.r(t,TextBlock,"graduatedStart"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.xc=t,this.u(),this.i("graduatedStart",i,t))}get graduatedEnd(){return this._!==null?this._.bc:1}set graduatedEnd(t){const i=this.graduatedEnd;Debug&&Util.r(t,TextBlock,"graduatedEnd"),i!==t&&(t<0?t=0:t>1&&(t=1),this._===null&&(this._=new GradElementSettings),this._.bc=t,this.u(),this.i("graduatedEnd",i,t))}get graduatedFunction(){return this._!==null?this._.Bp:null}set graduatedFunction(t){const i=this.graduatedFunction;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"graduatedFunction"),this._===null&&(this._=new GradElementSettings),this._.Bp=t,this.u(),this.i("graduatedFunction",i,t))}get graduatedSkip(){return this._!==null?this._.kc:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"graduatedSkip"),this._===null&&(this._=new GradElementSettings),this._.kc=t,this.u(),this.i("graduatedSkip",i,t))}mh(t,i){if(this.$i===null||this.ui.length===0||this.Cn===null)return;const e=this.naturalBounds,s=this.actualBounds,n=e.width,o=e.height,r=this.Op();let l=t.textAlign=this.textAlign;const h=i.vu;l==="start"?l=h?"right":"left":l==="end"&&(l=h?"left":"right");const a=this.isUnderline,f=this.isStrikethrough;this.wn(t,this.$i,!0,!1,e,s),(a||f)&&this.wn(t,this.$i,!1,!1,e,s);const c=0;let u=0;const d=n;let m=!1;i.ei===t&&!(i.ei instanceof SVGContext)&&!this.E2&&i.getRenderingHint("textGreeking")===!0&&r*this.ma*i.scale<3&&(m=!0);const g=this.spacingAbove,p=this.spacingBelow;switch(this.flip){case 0:break;case 2:t.translate(n,0),t.scale(-1,1);break;case 1:t.translate(0,o),t.scale(1,-1);break;case 3:t.translate(n,o),t.scale(-1,-1);break}t.commitTransform();const y=this.Fe,k=(g+r+p)*y;if(o>k){const b=this.verticalAlignment;u=b.y*o-b.y*k+b.offsetY}if(y===1&&this.Ln!==null){let b=this.xi;b>d&&(b=d),u+=g,this.YL(this.Ln,t,c,u,d,r,b,m,l,a,f)}else if(this.Re!==null&&this.Oi!==null)for(let b=0;bd&&(S=d),u+=g,this.YL(this.Oi[b],t,c,u,d,r,S,m,l,a,f),u+=r+p}switch(this.flip){case 0:break;case 2:t.scale(-1,1),t.translate(-n,0);break;case 1:t.scale(1,-1),t.translate(0,-o);break;case 3:t.scale(-1,-1),t.translate(-n,-o);break}}YL(t,i,e,s,n,o,r,l,h,a,f){let c=0;if(l){h==="left"?c=0:h==="right"?c=n-r:h==="center"&&(c=(n-r)/2);const m=i.globalAlpha;i.globalAlpha=m/2,i.fillRect(e+c,s+o/4,r,o/2),i.globalAlpha=m;return}h==="left"?c=0:h==="right"?c=n:h==="center"&&(c=n/2);const u=TextBlock.fb!==null?TextBlock.fb(this,o):o*.75;i.fillText(t,e+c,s+u);let d=o/20|0;if(d===0&&(d=1),h==="right"?c-=r:h==="center"&&(c-=r/2),a){const m=TextBlock.cb!==null?TextBlock.cb(this,o):o*.8;this.KL(e+c,s+m,e+c+r,s+m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}if(f){let m=s+o-o/2.2|0;d%2!==0&&(m+=.5),this.KL(e+c,m,e+c+r,m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}}KL(t,i,e,s,n,o){o.beginPath(),o.lineWidth=n,o.moveTo(t,i),o.lineTo(e,s),o.stroke(),o.endPath()}oc(t,i,e){if(!super.oc(t,i,e))return!1;if(this.wn(t,this.$i,!0,!1,this.naturalBounds,this.actualBounds),e){if(this.svg.getElementsByTagName("text").length===0)return!0;const n=this.svg.getElementsByClassName("gojs-td");for(let o=0;o1||this.isUnderline||this.isStrikethrough?!0:super.ad(t)}m2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("text");for(let s=0;sthis.maxLines&&(this.l|=16777216))}q2(t,i,e){const s=this.formatting===0;s&&(t=t.trim());let n=0,o=0,r=0;const l=this.Cn,h=this.spacingAbove+this.spacingBelow,a=Math.max(0,this.Op()+h),f=this.overflow===1?this.GL(l):0;if(this.Fe>=this.maxLines){e!==null&&e.e(0,a);return}let c=t;if(this.wrap===0){if(this.An=1,o=this.getStringWidth(t),f===0||o<=i){this.xi=Math.max(this.xi,o),this.Dn(t,this.xi),e!==null&&e.e(o,a);return}let d=this.Fd(c);c=c.substring(d.length);let m=this.Fd(c);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,c=c.substring(m.length),m=this.Fd(c),r=o;let g=d+m;s&&(g=g.trim()),o=this.getStringWidth(g)}for(s&&(m=m.trim()),d+=m,i=Math.max(1,i-f);this.getStringWidth(d)>i&&d.length>1;)d=d.substring(0,d.length-1);this.j2(!0),d+=TextBlock.Dp,r=this.getStringWidth(d),this.xi=r,this.Dn(d,r),e!==null&&e.e(r,a);return}let u=0;for(c.length===0&&(u=1,this.Dn(c,0));c.length>0;){let d=this.Fd(c);for(c=c.substring(d.length);this.getStringWidth(d)>i;){let p=1;for(o=this.getStringWidth(d.substring(0,p)),r=0;o<=i;)p++,r=o,o=this.getStringWidth(d.substring(0,p));let y=0;p===1?(y=o,n=Math.max(n,o)):(y=r,n=Math.max(n,r)),p--,p<1&&(p=1);const x=d.substring(0,p);if(this.Dn(x,y),u++,d=d.substring(p),this.Fe+u>this.maxLines)break}let m=this.Fd(c);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,c=c.substring(m.length),m=this.Fd(c),r=o;let p=d+m;s&&(p=p.trim()),o=this.getStringWidth(p)}if(s&&(d=d.trim()),d==="")continue;d[d.length-1]==="\xAD"&&(d=d.substring(0,d.length-1)+"\u2010");let g=0;if(m.length===0?(g=o,n=Math.max(n,o)):(r=this.getStringWidth(d),g=r,n=Math.max(n,r)),this.Dn(d,g),u++,this.Fe+u>this.maxLines)break}this.An=Math.min(this.maxLines,u),this.xi=Math.max(this.xi,n),e!==null&&e.e(this.xi,a*this.An)}OI(t,i){if(this.xi===0||this.Re===null||this.Oi===null||this.overflow!==1)return;const e=this.Cn,s=this.overflow===1?this.GL(e):0,n=this.spacingAbove+this.spacingBelow,o=Math.max(0,this.Op()+n),r=Math.min(this.maxLines-1,Math.max(Math.floor(i/o+.01)-1,0));if(r+1>=this.Oi.length)return;this.j2(!0);let l=this.Oi[r];const h=Math.max(1,t-s);for(;this.getStringWidth(l)>h&&l.length>1;)l=l.substring(0,l.length-1);l+=TextBlock.Dp;const a=this.getStringWidth(l);this.Oi[r]=l,this.Oi=this.Oi.slice(0,r+1),this.Re[r]=a,this.Re=this.Re.slice(0,r+1),this.An=this.Oi.length,this.xi=Math.max(this.xi,a),this.Fe=this.An,this.Fe===1&&(this.Ln=this.Oi[0])}Fd(t){if(this.wrap===3)return t.substring(0,1);let i=t.length,e=0;const s=TextBlock.EI;for(;e=t.length?t:t.substring(0,e)}getStringWidth(t){return TextBlock.rl===null?t.length*8:TextBlock.rl.measureText(t).width}Op(){if(this.co!==null)return this.co;const t=this.Cn;let i=0;return TextBlock.rl===null?(i=16,this.co=i,i):(TextBlock.W2[t]!==void 0&&TextBlock.HL<5e3?i=TextBlock.W2[t]:(i=TextBlock.rl.measureText("M").width*1.3,TextBlock.W2[t]=i,TextBlock.HL++),this.co=i,i)}GL(t){if(TextBlock.rl===null)return 6;let i=0;return TextBlock.ab[t]!==void 0&&TextBlock.H2<5e3?i=TextBlock.ab[t]:(i=TextBlock.rl.measureText(TextBlock.Dp).width,TextBlock.ab[t]=i,TextBlock.H2++),i}ub(t,i){return t.indexOf(` `,i)}XL(t){let i=this.ui.replace(/\r\n/g,` `).replace(/\r/g,` -`);const e=this.spacingAbove+this.spacingBelow,s=Math.max(0,this.Op()+e);if(i.length===0)return this.xi=0,this.Fe=1,s;if(!this.isMultiline){const h=this.ub(i,0);h>=0&&(i=i.substring(0,h))}let n=0;this.Fe=0;let o=0,r=-1,l=!1;for(;!l;){if(r=this.ub(i,o),r===-1&&(r=i.length,l=!0),o<=r){const h=i.substring(o,r);if(this.wrap!==0){this.An=0;const a=Size.a();this.W2(h,t,a),n+=a.height,Size.o(a),this.Fe+=this.An}else this.W2(h,t,null),n+=s,this.Fe++;this.Fe===this.maxLines&&(l=!0)}o=r+1}return this.C0=n,n}OI(){let t=this.ui.replace(/\r\n/g,` +`);const e=this.spacingAbove+this.spacingBelow,s=Math.max(0,this.Op()+e);if(i.length===0)return this.xi=0,this.Fe=1,s;if(!this.isMultiline){const h=this.ub(i,0);h>=0&&(i=i.substring(0,h))}let n=0;this.Fe=0;let o=0,r=-1,l=!1;for(;!l;){if(r=this.ub(i,o),r===-1&&(r=i.length,l=!0),o<=r){const h=i.substring(o,r);if(this.wrap!==0){this.An=0;const a=Size.a();this.q2(h,t,a),n+=a.height,Size.o(a),this.Fe+=this.An}else this.q2(h,t,null),n+=s,this.Fe++;this.Fe===this.maxLines&&(l=!0)}o=r+1}return this.C0=n,n}II(){let t=this.ui.replace(/\r\n/g,` `).replace(/\r/g,` -`);if(t.length===0)return 8;if(this.isMultiline){let i=0,e=0,s=!1;for(;!s;){let n=this.ub(t,e);n===-1&&(n=t.length,s=!0);let o=t.substring(e,n);this.formatting===0&&(o=o.trim()),i=Math.max(i,this.getStringWidth(o)),e=n+1}return i}else{const i=this.ub(t,0);return i>=0&&(t=t.substring(0,i)),this.getStringWidth(t)}}get textValidation(){return this.$!==null?this.$.Il:null}set textValidation(t){const i=this.textValidation;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"textValidation"),this.Tn(),this.$.Il=t,this.i("textValidation",i,t))}get textEdited(){return this.$!==null?this.$.Bp:null}set textEdited(t){const i=this.textEdited;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"textEdited"),this.Tn(),this.$.Bp=t,this.i("textEdited",i,t))}get spacingAbove(){return this.$!==null?this.$.zp:0}set spacingAbove(t){const i=this.spacingAbove;i!==t&&(Debug&&Util.t(t,"number",TextBlock,"spacingAbove"),this.Tn(),this.$.zp=t,this.u(),this.i("spacingAbove",i,t))}get spacingBelow(){return this.$!==null?this.$.Xp:0}set spacingBelow(t){const i=this.spacingBelow;i!==t&&(Debug&&Util.t(t,"number",TextBlock,"spacingBelow"),this.Tn(),this.$.Xp=t,this.u(),this.i("spacingBelow",i,t))}get formatting(){return this.$!==null?this.$.Yp:0}set formatting(t){const i=this.formatting;i!==t&&(Util.tt(t,TextFormat,"formatting"),this.Tn(),this.$.Yp=t,this.u(),this.i("formatting",i,t))}get maxLines(){return this.$!==null?this.$.Kp:1/0}set maxLines(t){const i=this.maxLines;i!==t&&(Debug&&Util.t(t,"number",TextBlock,"maxLines"),t=Math.floor(t),t<=0&&Util.G(t,"> 0",TextBlock,"maxLines"),this.Tn(),this.$.Kp=t,this.u(),this.i("maxLines",i,t))}getMetrics(){return[this.xi,this.Ol,this.co,this.An,this.Re,this.Oi,this.Ln]}FI(t){t!==void 0&&(this.xi=t[0],this.Ol=t[1],this.co=t[2],this.An=t[3],this.Re=t[4],this.Oi=t[5],this.Ln=t[6])}get metrics(){return{arrSize:this.Re!==null?this.Re:[this.xi],arrText:this.Oi!==null?this.Oi:[this.Ln],maxLineWidth:this.xi,fontHeight:this.co}}get choices(){return this.Fd}set choices(t){const i=this.Fd;i!==t&&(Debug&&t!==null&&!Array.isArray(t)&&Util.Vi(t,"Array",TextBlock,"choices:value"),this.Fd=t,this.i("choices",i,t))}static VI=new RegExp("[ \u200B\xAD]");static J2=new PropertyCollection;static HL=0;static ab=new PropertyCollection;static j2=0;static Dp="...";static UL="";static rl=Diagram.isUsingDOM()?new CanvasSurface(null).di:null}class TextBlockTemplateSettings{wi;fs;uo;Yp;Kp;Ip;zp;Xp;Fp;Bp;Ep;Il;hl;Rp;constructor(){this.wi=!1,this.fs=null,this.uo=0,this.Yp=0,this.Kp=1/0,this.Ip=0,this.zp=0,this.Xp=0,this.Fp="start",this.Bp=null,this.Ep=null,this.Il=null,this.hl=Spot.Top,this.Rp=2}copy(){const t=new TextBlockTemplateSettings;return t.fs=this.fs,t.uo=this.uo,t.Yp=this.Yp,t.Kp=this.Kp,t.Ip=this.Ip,t.zp=this.zp,t.Xp=this.Xp,t.Fp=this.Fp,t.Bp=this.Bp,t.Ep=this.Ep,t.Il=this.Il,t.hl=this.hl,t.Rp=this.Rp,t}}class GradElementSettings{yc;wc;xc;Vp;bc;constructor(){this.yc=1,this.wc=0,this.xc=1,this.Vp=null,this.bc=null}copy(){const t=new GradElementSettings;return t.yc=this.yc,t.wc=this.wc,t.xc=this.xc,t.Vp=this.Vp,t.bc=this.bc,t}}var ImageStretch=(w=>(w[w.None=0]="None",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ImageStretch||{});class Picture extends GraphObject{al;St;fl;kc;fs;cl;Sc;uo;Mc;Pc;W1;constructor(t,i){super(),this.l|=2097152,this.al=null,this.St="",this.fl=Rect.BD,this.kc=2,this.fs=null,this.cl=null,this.Sc=Spot.Center,this.uo=0,this.Mc=null,this.Pc=null,this.W1=null,typeof t=="string"?this.source=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.St=this.St,t.element=this.al,t.fl=this.fl.L(),t.kc=this.kc,t.uo=this.uo,t.fs=this.fs,t.cl=this.cl,t.Sc=this.Sc.L(),t.Pc=this.Pc}fi(t){t in ImageStretch?this.imageStretch=t:super.fi(t)}toString(){return"Picture("+this.source+")#"+GSet.gs(this)}get Nc(){return(this.l&1048576)!==0}set Nc(t){this.Nc!==t&&(this.l=this.l^1048576)}get Ia(){return(this.l&2097152)!==0}set Ia(t){this.Ia!==t&&(this.l=this.l^2097152)}get bn(){return(this.l&4194304)!==0}set bn(t){this.bn!==t&&(this.l=this.l^4194304)}static clearCache(t){t===void 0&&(t=""),Util.t(t,"string",Picture,"clearCache:url"),t!==""?Picture.Up[t]&&(delete Picture.Up[t],Picture.db--):(Picture.Up=new PropertyCollection,Picture.db=0)}static UA(t,i){i.qL||(i.gb=e=>{Picture.BI(i,e),t.desiredSize.isReal()||(t.pe(!1),t.u())},i.mb=e=>Picture.zI(i,e),i.addEventListener("load",i.gb),i.addEventListener("error",i.mb),i.qL=!0)}static NR(t){t.gb&&t.removeEventListener("load",t.gb),t.mb&&t.removeEventListener("error",t.mb),delete t.gb,delete t.mb,delete t.qL}get element(){return this.al}set element(t){const i=this.al;if(this.hs(!0),i!==t){this.Nc=t instanceof HTMLCanvasElement;const e=t instanceof HTMLImageElement;t!==null&&!(e||t instanceof HTMLVideoElement||this.Nc)&&Util.n("Picture.element must be an instance of Image, Canvas, or Video, not: "+t);const s=this.diagram;s!==null&&s.zP(this),this.al=t,t!==null&&e&&t.ls===void 0&&(t.ls=new GSet),s!==null&&e&&s.BP(this),this.i("element",i,t),this.T()}}MR(){const t=this.al;if(t===null)return;const i=this.desiredSize.isReal();(this.Nc||t.complete===!0)&&(t.w0&&(t.Gp instanceof Event&&this.fs!==null?this.fs(this,t.Gp):t.bn===!0&&!t.Gp&&this.cl!==null&&t.Z2&&this.cl(this,t.Z2)),t.bn=!0),t.bn&&i&&this.diagram!==null&&this.diagram.vu.add(this)}XI(){if(this.al===null){this.Mc=!1;return}const t=new CanvasSurface(null).di;try{t.drawImage(this.al,0,0)}catch(i){Debug&&this.Ia&&Util.at(i.toString()),this.Ia=!1}try{t.getImageData(0,0,1,1).data[3]&&(this.Mc=!1),this.Mc=!1}catch{this.Mc=!0}}get source(){return this.St}set source(t){const i=this.St;if(i!==t){this.hs(!0),Util.t(t,"string",Picture,"source"),this.St=t;let e=Picture.Up;if(!Diagram.isUsingDOM()){this.i("source",i,t);return}let s=null;if(e[t]!==void 0)s=e[t];else if(t!==""){Picture.db>30&&(Picture.clearCache(),e=Picture.Up),s=Util.ln("img"),s.w0=!0,Picture.UA(this,s);const n=this.Pc;n!==null&&(s.crossOrigin=n(this)),s.src=t,e[t]=s,Picture.db++}this.element=s,s!==null&&s.__goCache===void 0&&(s.__goCache=new PictureCacheArray),this.u(),this.T(),this.i("source",i,t)}}static BI(t,i){t.bn=!0,t.Gp=!1;let e;const s=t.ls.copy();if(s==null)return;const n=s.iterator;for(;n.next();){const o=n.value;o.T();const r=t.getAttribute("src")||"",l=o._l.get(r);if(l===null)continue;const h=l.length;for(let a=0;a=o.width&&(r=r+p.offsetX+(d*p.x-o.width*p.x)),m>=o.height&&(l=l+p.offsetY+(m*p.y-o.height*p.y)),a=Math.min(o.width,d),f=Math.min(o.height,m);break;case 2:d=o.width,m=o.height;break;case 6:case 7:let L=0;g===6?(L=Math.min(o.height/m,o.width/d),d*=L,m*=L):g===7&&(L=Math.max(o.height/m,o.width/d),d*=L,m*=L,d>=o.width&&(r=(r+p.offsetX+(d*p.x-o.width*p.x)/d)*a),m>=o.height&&(l=(l+p.offsetY+(m*p.y-o.height*p.y)/m)*f),a*=1/(d/o.width),f*=1/(m/o.height),d=o.width,m=o.height);break}const y=a*f,x=this.getDocumentScale()*i.scale,k=d*x,b=m*x,S=k*b,M=y/S,A=e.__goCache;let C=null;const P=Picture.YI;if(!n){if(e.bn&&A!==void 0&&S>4&&M>P*P){A.Yt===null&&(A.jL(4,c,u,e),A.jL(16,c,u,e));const L=A.Yt,D=L.length;for(let F=0;F0){const f=this.Yt[this.Yt.length-1];h=f.St,a=f.Id}o.setTransform(r*a,0,0,r*a,0,0),o.commitTransform(),o.drawImage(h,0,0),this.Yt.push(l)}}class PictureCacheInstance{St;Id;constructor(t,i){this.St=t,this.Id=i}}class GeoStream{Ci;im;constructor(){this.im=new Geometry,this.Ci=null}Bi(t){t!==null?(t.ct(),this.im=t,t.figures.clear()):this.im=new Geometry,this.Ci=null}wu(t,i,e,s,n,o){if(s!==void 0&&s===!0){const r=new PathSegment(1);r.endX=t,r.endY=i,this.Ci.segments.add(r)}else this.Ci=new PathFigure,this.Ci.startX=t,this.Ci.startY=i,this.Ci.isFilled=e,this.Ci.isEvenOdd=o||!1,this.im.figures.add(this.Ci);n!==void 0&&(this.Ci.isShadowed=n)}WD(){const t=this.Ci.segments.length;t>0&&this.Ci.segments.elt(t-1).close()}vD(){this.Ci.segments.length>0&&(this.Ci.isFilled=!0)}JD(t){this.Ci.isShadowed=t}pE(t){this.Ci.isEvenOdd=t}HD(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(1);s.endX=t,s.endY=i,e&&s.close(),this.Ci.segments.add(s)}yr(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(2);s.endX=t,s.endY=i,e&&s.close(),this.Ci.segments.add(s)}wr(t,i,e,s,n,o,r){r===void 0&&(r=!1);const l=new PathSegment(3);l.point1X=t,l.point1Y=i,l.point2X=e,l.point2Y=s,l.endX=n,l.endY=o,r&&l.close(),this.Ci.segments.add(l)}Fw(t,i,e,s,n){n===void 0&&(n=!1);const o=new PathSegment(4);o.point1X=t,o.point1Y=i,o.endX=e,o.endY=s,n&&o.close(),this.Ci.segments.add(o)}qD(t,i,e,s,n,o,r){o===void 0&&(o=0),r===void 0&&(r=!1);const l=new PathSegment(5);l.startAngle=t,l.sweepAngle=i,l.centerX=e,l.centerY=s,l.radiusX=n,o!==0?l.radiusY=o:l.radiusY=n,r&&l.close(),this.Ci.segments.add(l)}jD(t,i,e,s,n,o,r,l){l===void 0&&(l=!1);const h=new PathSegment(6,o,r,t,i,e,s,n);l&&h.close(),this.Ci.segments.add(h)}static $2=null;static PC(t){const i=GeoStream.$2;if(i!==null)return GeoStream.$2=null,i.Bi(t),i;{const e=new GeoStream;return e.Bi(t),e}}static NC(t){GeoStream.$2=t}}{const w=function(n,o){const r=n.toLowerCase(),l=Geo.qn;l[n]=o,l[r]=n};w("Rectangle",(n,o,r)=>{const l="r"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,Geo.pr{const l="s"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,h.defaultStretch=6,Geo.pr{(isNaN(l)||l<0)&&(l=5),isNaN(h)&&(h=15);const a="rr"+o+","+r+","+l+","+h;let f=Geo.mr[a];if(f!==void 0)return f;let c=l;(h&1)===1?(c=Math.min(c,(h&2)===2?o/3:o),c=Math.min(c,(h&8)===8?r/3:r)):c=0;const u=new PathFigure(c,0,!0);f=new Geometry().add(u);const d=Spot.TopLeft.copy(),m=Spot.BottomRight.copy();if((h&2)===2){let g=l;g=Math.min(g,(h&1)===1?o/3:o),g=Math.min(g,(h&4)===4?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,o-g,0)).add(new PathSegment(3,o,g,o-p,0,o,p)),d.offsetY=p,m.offsetX=-p}else u.add(new PathSegment(2,o,0));if((h&4)===4){let g=l;g=Math.min(g,(h&8)===8?o/3:o),g=Math.min(g,(h&2)===2?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,o,r-g)).add(new PathSegment(3,o-g,r,o,r-p,o-p,r)),m.offsetX=-p,m.offsetY=-p}else u.add(new PathSegment(2,o,r));if((h&8)===8){let g=l;g=Math.min(g,(h&4)===4?o/3:o),g=Math.min(g,(h&1)===1?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,g,r)).add(new PathSegment(3,0,r-g,p,r,0,r-p)),d.offsetX=p,m.offsetY=-p}else u.add(new PathSegment(2,0,r));if((h&1)===1){const g=c*Geo.Un;u.add(new PathSegment(2,0,c)).add(new PathSegment(3,c,0,0,g,g,0).close()),d.offsetX=g,d.offsetY=g}else u.add(new PathSegment(2,0,0).close());return f.spot1=d,f.spot2=m,Geo.pr{const l=n?n.parameter1:NaN,h=n?n.parameter2:NaN;return t(n,o,r,l,h)}),w("Border","RoundedRectangle"),w("RoundedTopRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,3)}),w("RoundedBottomRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,12)}),w("RoundedLeftRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,9)}),w("RoundedRightRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,6)}),w("Ellipse",(n,o,r)=>{const l="e"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Kk,h.spot2=Spot.Uk,Geo.pr{const l="c"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Kk,h.spot2=Spot.Uk,h.defaultStretch=6,Geo.prnew Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,.5*r)).add(new PathSegment(2,0,r).close())).setSpots(0,.25,.5,.75)),w("TriangleDown",(n,o,r)=>new Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,0)).add(new PathSegment(2,.5*o,r).close())).setSpots(.25,0,.75,.5)),w("TriangleLeft",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,o,0).close())).setSpots(.5,.25,1,.75)),w("TriangleUp",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,r)).add(new PathSegment(2,.5*o,0).close())).setSpots(.25,.5,.75,1)),w("Triangle","TriangleUp"),w("Diamond",(n,o,r)=>new Geometry().add(new PathFigure(.5*o,0).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,.5*o,r)).add(new PathSegment(2,o,.5*r).close())).setSpots(.25,.25,.75,.75)),w("LineH",(n,o,r)=>{const l=new Geometry(1);return l.startX=0,l.startY=r/2,l.endX=o,l.endY=r/2,l}),w("LineV",(n,o,r)=>{const l=new Geometry(1);return l.startX=o/2,l.startY=0,l.endX=o/2,l.endY=r,l}),w("None","Rectangle"),w("BarH","Rectangle"),w("BarV","Rectangle"),w("MinusLine","LineH"),w("PlusLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r/2,!1).add(new PathSegment(2,o,r/2)).add(new PathSegment(1,o/2,0)).add(new PathSegment(2,o/2,r)))),w("XLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r,!1).add(new PathSegment(2,o,0)).add(new PathSegment(1,0,0)).add(new PathSegment(2,o,r)))),w("LineRight",(n,o,r)=>new Geometry().add(new PathFigure(.25*o,0,!1).add(new PathSegment(2,.75*o,.5*r)).add(new PathSegment(2,.25*o,r)))),w("LineDown",(n,o,r)=>new Geometry().add(new PathFigure(0,.25*r,!1).add(new PathSegment(2,.5*o,.75*r)).add(new PathSegment(2,o,.25*r)))),w("LineLeft",(n,o,r)=>new Geometry().add(new PathFigure(.75*o,0,!1).add(new PathSegment(2,.25*o,.5*r)).add(new PathSegment(2,.75*o,r)))),w("LineUp",(n,o,r)=>new Geometry().add(new PathFigure(0,.75*r,!1).add(new PathSegment(2,.5*o,.25*r)).add(new PathSegment(2,o,.75*r)))),w("Capsule",(n,o,r)=>{const l=new Geometry;if(or){const h=new PathFigure(r/2,0,!0);return l.add(h),h.add(new PathSegment(2,o-r/2,0)),h.add(new PathSegment(5,270,180,o-r/2,r/2,r/2,r/2)),h.add(new PathSegment(2,r/2,r)),h.add(new PathSegment(5,90,180,r/2,r/2,r/2,r/2)),l.spot1=new Spot(0,.156,r*.156,0),l.spot2=new Spot(1,.844,-r*.156,0),l}else return l.type=3,l.endX=o,l.endY=r,l.spot1=Spot.Kk,l.spot2=Spot.Uk,l});const i=(n,o)=>new PathFigure(n,o,!1,!1),e=(n,o,r)=>n.add(new PathSegment(2,o,r)),s=(n,o,r)=>n.add(new PathSegment(1,o,r));w("Borders",(n,o,r)=>{let l=n?n.parameter1:NaN;isNaN(l)?l=10:l=l&15;const h=new Geometry;let a;return l===10?(a=i(o,0),e(a,o,r),s(a,0,r),e(a,0,0)):l===5?(a=i(0,0),e(a,o,0),s(a,o,r),e(a,0,r)):l===1?(a=i(0,0),e(a,o,0),s(a,o,r)):l===2?(a=i(o,0),e(a,o,r)):l===4?(a=i(o,r),e(a,0,r)):l===8?(a=i(0,r),e(a,0,0),s(a,o,r)):l===3?(a=i(0,0),e(a,o,0),e(a,o,r)):l===6?(a=i(o,0),e(a,o,r),e(a,0,r)):l===12?(a=i(o,r),e(a,0,r),e(a,0,0)):l===9?(a=i(0,r),e(a,0,0),e(a,o,0)):l===7?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r)):l===14?(a=i(o,0),e(a,o,r),e(a,0,r),e(a,0,0)):l===13?(a=i(o,r),e(a,0,r),e(a,0,0),e(a,o,0)):l===11?(a=i(0,r),e(a,0,0),e(a,o,0),e(a,o,r)):l===15?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r),a.add(new PathSegment(2,0,0).close())):(a=i(0,0),s(a,o,r)),h.add(a),h})}Geo.Zg={"":"",Standard:"F1 m 0,0 l 8,4 -8,4 2,-4 z",Backward:"F1 m 8,0 l -2,4 2,4 -8,-4 z",Triangle:"F1 m 0,0 l 8,4.62 -8,4.62 z",BackwardTriangle:"F1 m 8,4 l 0,4 -8,-4 8,-4 0,4 z",Boomerang:"F1 m 0,0 l 8,4 -8,4 4,-4 -4,-4 z",BackwardBoomerang:"F1 m 8,0 l -8,4 8,4 -4,-4 4,-4 z",SidewaysV:"m 0,0 l 8,4 -8,4 0,-1 6,-3 -6,-3 0,-1 z",BackwardV:"m 8,0 l -8,4 8,4 0,-1 -6,-3 6,-3 0,-1 z",OpenTriangle:"m 0,0 l 8,4 -8,4",BackwardOpenTriangle:"m 8,0 l -8,4 8,4",OpenTriangleLine:"m 0,0 l 8,4 -8,4 m 8.5,0 l 0,-8",BackwardOpenTriangleLine:"m 8,0 l -8,4 8,4 m -8.5,0 l 0,-8",OpenTriangleTop:"m 0,0 l 8,4 m 0,4",BackwardOpenTriangleTop:"m 8,0 l -8,4 m 0,4",OpenTriangleBottom:"m 0,8 l 8,-4",BackwardOpenTriangleBottom:"m 0,4 l 8,4",HalfTriangleTop:"F1 m 0,0 l 0,4 8,0 z m 0,8",BackwardHalfTriangleTop:"F1 m 8,0 l 0,4 -8,0 z m 0,8",HalfTriangleBottom:"F1 m 0,4 l 0,4 8,-4 z",BackwardHalfTriangleBottom:"F1 m 8,4 l 0,4 -8,-4 z",ForwardSemiCircle:"m 4,0 b 270 180 0 4 4",BackwardSemiCircle:"m 4,8 b 90 180 0 -4 4",Feather:"m 0,0 l 3,4 -3,4",BackwardFeather:"m 3,0 l -3,4 3,4",DoubleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardDoubleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4",TripleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardTripleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4 m 3,-8 l -3,4 3,4",ForwardSlash:"m 0,8 l 5,-8",BackSlash:"m 0,0 l 5,8",DoubleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8",DoubleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8",TripleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8 m -2,8 l 4,-8",TripleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8 m -2,-8 l 4,8",Fork:"m 0,4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4",LineFork:"m 0,0 l 0,8 m 0,-4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardLineFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4 m 8,-8 l 0,8",CircleFork:"F1 m 6,4 b 0 360 -3 0 3 z m 0,0 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 6,0 b 0 360 -3 0 3",CircleLineFork:"F1 m 6,4 b 0 360 -3 0 3 z m 1,-4 l 0,8 m 0,-4 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleLineFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 0,-4 l 0,8 m 7,-4 b 0 360 -3 0 3",Circle:"F1 m 8,4 b 0 360 -4 0 4 z",Block:"F1 m 0,0 l 0,8 8,0 0,-8 z",StretchedDiamond:"F1 m 0,3 l 5,-3 5,3 -5,3 -5,-3 z",Diamond:"F1 m 0,4 l 4,-4 4,4 -4,4 -4,-4 z",Chevron:"F1 m 0,0 l 5,0 3,4 -3,4 -5,0 3,-4 -3,-4 z",StretchedChevron:"F1 m 0,0 l 8,0 3,4 -3,4 -8,0 3,-4 -3,-4 z",NormalArrow:"F1 m 0,2 l 4,0 0,-2 4,4 -4,4 0,-2 -4,0 z",X:"m 0,0 l 8,8 m 0,-8 l -8,8",TailedNormalArrow:"F1 m 0,0 l 2,0 1,2 3,0 0,-2 2,4 -2,4 0,-2 -3,0 -1,2 -2,0 1,-4 -1,-4 z",DoubleTriangle:"F1 m 0,0 l 4,4 -4,4 0,-8 z m 4,0 l 4,4 -4,4 0,-8 z",BigEndArrow:"F1 m 0,0 l 5,2 0,-2 3,4 -3,4 0,-2 -5,2 0,-8 z",ConcaveTailArrow:"F1 m 0,2 h 4 v -2 l 4,4 -4,4 v -2 h -4 l 2,-2 -2,-2 z",RoundedTriangle:"F1 m 0,1 a 1,1 0 0 1 1,-1 l 7,3 a 0.5,1 0 0 1 0,2 l -7,3 a 1,1 0 0 1 -1,-1 l 0,-6 z",SimpleArrow:"F1 m 1,2 l -1,-2 2,0 1,2 -1,2 -2,0 1,-2 5,0 0,-2 2,2 -2,2 0,-2 z",AccelerationArrow:"F1 m 0,0 l 0,8 0.2,0 0,-8 -0.2,0 z m 2,0 l 0,8 1,0 0,-8 -1,0 z m 3,0 l 2,0 2,4 -2,4 -2,0 0,-8 z",BoxArrow:"F1 m 0,0 l 4,0 0,2 2,0 0,-2 2,4 -2,4 0,-2 -2,0 0,2 -4,0 0,-8 z",TriangleLine:"F1 m 8,4 l -8,-4 0,8 8,-4 z m 0.5,4 l 0,-8",CircleEndedArrow:"F1 m 10,4 l -2,-3 0,2 -2,0 0,2 2,0 0,2 2,-3 z m -4,0 b 0 360 -3 0 3 z",DynamicWidthArrow:"F1 m 0,3 l 2,0 2,-1 2,-2 2,4 -2,4 -2,-2 -2,-1 -2,0 0,-2 z",EquilibriumArrow:"m 0,3 l 8,0 -3,-3 m 3,5 l -8,0 3,3",FastForward:"F1 m 0,0 l 3.5,4 0,-4 3.5,4 0,-4 1,0 0,8 -1,0 0,-4 -3.5,4 0,-4 -3.5,4 0,-8 z",Kite:"F1 m 0,4 l 2,-4 6,4 -6,4 -2,-4 z",HalfArrowTop:"F1 m 0,0 l 4,4 4,0 -8,-4 z m 0,8",HalfArrowBottom:"F1 m 0,8 l 4,-4 4,0 -8,4 z",OpposingDirectionDoubleArrow:"F1 m 0,4 l 2,-4 0,2 4,0 0,-2 2,4 -2,4 0,-2 -4,0 0,2 -2,-4 z",PartialDoubleTriangle:"F1 m 0,0 4,3 0,-3 4,4 -4,4 0,-3 -4,3 0,-8 z",LineCircle:"F1 m 0,0 l 0,8 m 7 -4 b 0 360 -3 0 3 z",DoubleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",TripleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",CircleLine:"F1 m 6 4 b 0 360 -3 0 3 z m 1,-4 l 0,8",DiamondCircle:"F1 m 8,4 l -4,4 -4,-4 4,-4 4,4 m 8,0 b 0 360 -4 0 4 z",PlusCircle:"F1 m 8,4 b 0 360 -4 0 4 l -8 0 z m -4 -4 l 0 8",OpenRightTriangleTop:"m 8,0 l 0,4 -8,0 m 0,4",OpenRightTriangleBottom:"m 8,8 l 0,-4 -8,0",Line:"m 0,0 l 0,8",DoubleLine:"m 0,0 l 0,8 m 2,0 l 0,-8",TripleLine:"m 0,0 l 0,8 m 2,0 l 0,-8 m 2,0 l 0,8",PentagonArrow:"F1 m 8,4 l -4,-4 -4,0 0,8 4,0 4,-4 z"};var LayoutConditions=(w=>(w[w.None=0]="None",w[w.Added=1]="Added",w[w.Removed=2]="Removed",w[w.Shown=4]="Shown",w[w.Hidden=8]="Hidden",w[w.NodeSized=16]="NodeSized",w[w.GroupLayout=32]="GroupLayout",w[w.NodeReplaced=64]="NodeReplaced",w[w.Standard=127]="Standard",w[w.All=16777215]="All",w))(LayoutConditions||{});class Part extends Panel{N;$o;E;ul;dl;Qo;ui;_o;xh;Zs;tr;Od;qM;WL;Hp;qp;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.N=2408959,this.$o="",this.E=null,this.ul="",this.dl=null,this.Qo=null,this.ui="",this._o=null,this.xh=null,this.Zs=new Point(NaN,NaN).w(),this.tr=null,this.Od=NaN,this.qM=-1,this.WL=new Rect,this.Hp=null,this.qp=NaN,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.N=this.N&-4097|16384|32768,t.$o=this.$o,this.E!==null&&(this.E.wi?t.E=this.E:t.E=this.E.copy()),t.ul=this.ul,t.Qo=null,t.ui=this.ui,t.Zs.c(this.Zs),t.Od=this.Od}Ho(t){super.Ho(t),t.dh(),t.dl=null,t.tr=null,t.Hp=null}toString(){let t=Util.hn(this.constructor)+"#"+GSet.gs(this);return this.data!==null&&(t+="("+Util.toString(this.data)+")"),t}static LayoutNone=0;static LayoutAdded=1;static LayoutRemoved=2;static LayoutShown=4;static LayoutHidden=8;static LayoutNodeSized=16;static LayoutGroupLayout=32;static LayoutNodeReplaced=64;static LayoutStandard=127;static LayoutAll=16777215;Qi(){this.E===null?this.E=new PartTemplateSettings:this.E.wi&&(this.E=this.E.copy())}fh(){super.fh(),this.E!==null&&(this.E.wi=!0)}ic(t,i,e,s,n,o,r){const l=this.diagram;l!==null&&(t===3&&i==="elements"?n instanceof Panel?n.Qr(h=>{l.partManager.FP(h,l)}):n instanceof Picture&&l.BP(n):t===4&&i==="elements"&&(n instanceof Panel?n.Qr(h=>l.partManager.RP(h,l)):n instanceof Picture&&l.zP(n)),l.raiseChangedEvent(t,i,e,s,n,o,r))}updateTargetBindings(t){if(super.updateTargetBindings(t),this.data===null)return;const i=this.D.h,e=i.length;for(let n=0;n{r.data!==null&&r.updateTargetBindings()})}const s=this.adornments;for(;s.next();)s.value.updateTargetBindings(t)}Yo(){if(super.Yo(),this.N2()){const i=this.D.h,e=i.length;for(let s=0;so.Yo())}}const t=this.adornments;for(;t.next();)t.value.Yo()}updateRelationshipsFromData(){this.data!==null&&this.diagram?.partManager.updateRelationshipsFromData(this)}get key(){const t=this.diagram;if(t!==null)return t.model.getKeyForNodeData(this.data)}get adornments(){return this.Qo===null?EmptyIterator.instance:this.Qo.iteratorValues}findAdornment(t){Debug&&Util.t(t,"string",Part,"findAdornment:category");const i=this.Qo;return i===null?null:i.get(t)}addAdornment(t,i){if(i===null)return;Debug&&(Util.t(t,"string",Part,"addAdornment:category"),Util.s(i,Adornment,Part,"addAdornment:ad"));let e=null,s=this.Qo;if(s!==null&&(e=s.get(t)),e!==i){if(e!==null){const o=e.diagram;o!==null&&o.remove(e)}s===null&&(s=new GMap,this.Qo=s),i.$o!==t&&(i.category=t),s.set(t,i);const n=this.diagram;if(n!==null){n.add(i);const o=i.adornedObject;if(o!==null){const r=o.findBindingPanel();r!==null&&(i.data=r.data)}}}}removeAdornment(t){Debug&&Util.t(t,"string",Part,"removeAdornment:category");const i=this.Qo;if(i===null)return;const e=i.get(t);if(e!==null){const s=e.diagram;s!==null&&(s.remove(e),e.data=null)}i.delete(t),i.count===0&&(this.Qo=null)}clearAdornments(){const t=this.Qo;if(t===null)return;const i=Util.ft(),e=t.iterator;for(;e.next();){const n=e.key;i.push(n)}const s=i.length;for(let n=0;n{e.isEnabled&&e.updateAdornments(i)}),t.toolManager.updateAdornments(i)}GM(t){this._o=t,t===null&&this.zR()}get layer(){return this._o}get diagram(){const t=this._o;return t==null?null:t.diagram}get layerName(){return this.ul}set layerName(t){const i=this.ul;if(i===t)return;Util.t(t,"string",Part,"layerName");let e=this.diagram;if(e!==null&&(e.findLayer(t)===null||e.partManager.addsToTemporaryLayer))return;this.ul=t,e!==null&&e.invalidateDocumentBounds(),this.i("layerName",i,t);const s=this.layer;if(s===null||s.name===t||(e=s.diagram,e===null))return;const n=e.findLayer(t);if(n===null||n===s)return;let o=s.ne(-1,this,!0);o>=0&&e.raiseChangedEvent(4,"parts",s,this,null,o,!0),o=n.Zh(99999999,this,!0),s.visible!==n.visible&&this.Ki(n.visible),o>=0&&e.raiseChangedEvent(3,"parts",n,null,this,!0,o);const r=this.layerChanged;if(r===null)return;const l=e.j;e.j=!0,r(this,s,n),e.j=l}get layerChanged(){return this.E!==null?this.E.jp:null}set layerChanged(t){const i=this.layerChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"layerChanged"),this.Qi(),this.E.jp=t,this.i("layerChanged",i,t))}get zOrder(){return this.Od}set zOrder(t){const i=this.Od;if(i===t)return;Util.t(t,"number",Part,"zOrder"),this.Od=t;const e=this.layer;e!==null&&e.Nx(-1,this),this.i("zOrder",i,t);const s=this.diagram;s!==null&&s.T()}GI(){const t=this.layer;t!==null&&t.Nx(-1,this)}pb(){if(this.nh()!==!1)return;this.Q2(!0),this.hd();const t=this.diagram;t!==null&&(t.d0(this),t.requestUpdate())}ZL(){if(this.N|=2097152,this.nh()===!1)return;const t=this.position,i=this.location;(!i.isReal()||!t.isReal())&&this.$L(t,i);const e=this.Fi,s=Rect.a().c(e);e.ct(),e.x=t.x,e.y=t.y,e.w(),this.ad(s,e),Rect.o(s),this.Q2(!1)}no(t,i,e,s){const n=this.le;n.e(t,i,e,s),this.Pi===null&&(this.Pi=new Transform);const o=this.Pi;o.Bi(),this.P0(o,t,i,e,s),this.Pi=o,o.Gk()||o.Cw(n)}P0(t,i,e,s,n){if(this.lt!==1&&t.lt(this.lt),this.jt===0)return;let o=Spot.Center;this.locationSpot.isSpot()&&(o=this.locationSpot);const r=Point.a();if(this.locationObject!==this){const l=this.locationObject,h=l.naturalBounds;r.setSpot(h.x,h.y,h.width,h.height,o),l.Pi!==null&&l.Pi.Pt(r),r.offset(-l.measuredBounds.x,-l.measuredBounds.y);let a=l.panel;for(;a!==null&&a!==this;)a.Pi!==null&&a.Pi.Pt(r),r.offset(-a.measuredBounds.x,-a.measuredBounds.y),a=a.panel}else r.setSpot(i,e,s,n,o);t.ms(this.jt,r.x,r.y),Point.o(r)}get locationObject(){if(this.tr===null)if(this instanceof Adornment&&this.type!==Panel.Link&&this.hasPlaceholder())this.tr=this.placeholder;else{const t=this.locationObjectName;if(t!==""){const i=this.findObject(t);i!==null?this.tr=i:this.tr=this}else this.tr=this}return this.tr.visible?this.tr:this}get minLocation(){return this.E!==null?this.E.Wp:Point.rC}set minLocation(t){const i=this.minLocation;i.equals(t)||(Debug&&Util.s(t,Point,Part,"minLocation"),t=t.L(),this.Qi(),this.E.Wp=t,this.i("minLocation",i,t))}get maxLocation(){return this.E!==null?this.E.vp:Point.lC}set maxLocation(t){const i=this.maxLocation;i.equals(t)||(Debug&&Util.s(t,Point,Part,"maxLocation"),t=t.L(),this.Qi(),this.E.vp=t,this.i("maxLocation",i,t))}get locationObjectName(){return this.E!==null?this.E.Jp:""}set locationObjectName(t){const i=this.locationObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"locationObjectName"),this.Qi(),this.E.Jp=t,this.tr=null,this.u(),this.i("locationObjectName",i,t))}get locationSpot(){return this.E!==null?this.E.Zp:Spot.TopLeft}set locationSpot(t){const i=this.locationSpot;i.equals(t)||(Debug&&(Util.s(t,Spot,Part,"locationSpot"),t.isSpot()||Util.n("Part.locationSpot must be a specific Spot value, not: "+t)),t=t.L(),this.Qi(),this.E.Zp=t,this.u(),this.i("locationSpot",i,t))}move(t,i){i===!0?this.location=t:this.position=t}moveTo(t,i,e){const s=Point.H(t,i);this.move(s,e),Point.o(s)}isVisible(){if(!this.visible)return!1;const t=this.layer;if(t!==null){if(!t.visible)return!1;const e=t.diagram;if(e!==null&&e.animationManager.ux(this))return!0}const i=this.containingGroup;return!(i!==null&&(!i.isSubGraphExpanded||!i.isVisible()))}Ki(t){const i=this.diagram;t?(this.invalidateLayout(4),this.invalidateAdornments(),i!==null&&i.d0(this)):(this.invalidateLayout(8),this.clearAdornments()),this.dh(),i!==null&&(i.invalidateDocumentBounds(),i.T())}findObject(t){if(this.name===t)return this;let i=this.Hp;if(i===null&&(this.Hp=i=new GMap),i.get(t)!==null)return i.get(t);const e=super.findObject(t);return e!==null?(i.set(t,e),e):(i.set(t,null),null)}V0(){this.Hp=null}getRelativePoint(t,i,e){e===void 0&&(e=new Point);const s=i.isNoSpot()?Spot.Center:i,n=t.naturalBounds;if(e.e(n.width*s.x+s.offsetX,n.height*s.y+s.offsetY),t===null||t===this)return e;t.O.Pt(e);let o=t.panel;for(;o!==null&&o!==this;)o.O.Pt(e),o=o.panel;return this.Pi!==null&&this.Pi.Pt(e),e.offset(-this.le.x,-this.le.y),e}getDocumentBounds(t){return t===void 0&&(t=new Rect),t.c(this.actualBounds)}ensureBounds(){this.wt(1/0,1/0),this.qt()}PL(t){const i=this.locationSpot,e=this.locationObject;let s=e.naturalBounds;s.isReal()||(s=Rect.kw);const n=e instanceof Shape?e.strokeWidth:0;if(t.setSpot(0,0,s.width+n,s.height+n,i),e!==this){t.offset(-n/2,-n/2),e.O.Pt(t);let o=e.panel;for(;o!==null&&o!==this;)o.O.Pt(t),o=o.panel}return this.Pi!==null&&this.Pi.Pt(t),t.offset(-this.le.x,-this.le.y),t}Jh(t,i){const e=i===void 0?this.WL:i,s=this.HI(),n=s*2;if(!this.isShadowed)return e.e(t.x-1-s,t.y-1-s,t.width+2+n,t.height+2+n),e;let o=t.x,r=t.y,l=t.width,h=t.height;const a=this.shadowBlur,f=this.shadowOffset;return l+=a,h+=a,o-=a/2,r-=a/2,f.x>0?l+=f.x:(o+=f.x,l-=f.x),f.y>0?h+=f.y:(r+=f.y,h-=f.y),e.e(o-1,r-1,l+2,h+2),e}CI(){return this.type===Panel.Link&&this instanceof Adornment&&this.category==="Selection"&&this.adornedObject instanceof Shape&&this.adornedPart.findMainElement()===this.adornedObject?this.adornedObject.strokeWidth:0}HI(){return isNaN(this.qp)&&(this.qp=this.FL()),this.qp}mc(){this.qp=NaN}qt(){if(this.rs()===!1){this.ZL();return}this.oo(!1);const t=this.Fi,i=Rect.a();i.c(t);const e=this.Tl();this.uh(0,0,this.le.width,this.le.height);const s=this.position;this.$L(s,this.location),t.ct(),t.x=s.x,t.y=s.y,t.w(),this.ad(i,t),i.equals(t)?this.Us(e):this.Ae()&&(!Geo.p(i.width,t.width)||!Geo.p(i.height,t.height))&&this.qM>=0&&this.invalidateLayout(16),Rect.o(i),this.Q2(!1)}ad(t,i){const e=this.diagram;if(e===null)return;let s=!1;if(e.ta===!1&&t.isReal()){const n=Rect.a();n.c(e.documentBounds),n.subtractMargin(e.padding),t.x>n.x&&t.y>n.y&&t.rightn.x&&i.y>n.y&&i.right=o)return}}this.N=this.N^4096;let s=!1;if(e!==null){s=e.skipsUndoManager,e.skipsUndoManager=!0;const o=e.selection;o.ct(),t?o.add(this):o.delete(this),o.w()}this.i("isSelected",i,t),this.invalidateAdornments();const n=this.selectionChanged;n!==null&&n(this),e!==null&&(e.requestUpdate(),e.skipsUndoManager=s)}}get isHighlighted(){return(this.N&524288)!==0}set isHighlighted(t){const i=(this.N&524288)!==0;if(i!==t){Debug&&Util.t(t,"boolean",Part,"isHighlighted"),this.N=this.N^524288;const e=this.diagram;if(e!==null){const n=e.highlighteds;n.ct(),t?n.add(this):n.delete(this),n.w()}this.i("isHighlighted",i,t),this.T();const s=this.highlightedChanged;s!==null&&s(this)}}get isShadowed(){return(this.N&8192)!==0}set isShadowed(t){const i=(this.N&8192)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Part,"isShadowed"),this.N=this.N^8192,this.hs(!0),this.i("isShadowed",i,t),this.T())}vL(){return(this.N&16384)!==0}JL(t){t?this.N|=16384:this.N&=-16385}nh(){return(this.N&32768)!==0}Q2(t){t?this.N|=32768:this.N&=-32769}qI(){return(this.N&65536)!==0}g2(t){t?this.N|=65536:this.N&=-65537}Tl(){return(this.N&131072)!==0}Us(t){t?this.N|=131072:this.N&=-131073}eT(){return(this.N&1048576)!==0}yb(t){t?this.N|=1048576:this.N&=-1048577}get isAnimated(){return(this.N&262144)!==0}set isAnimated(t){const i=(this.N&262144)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Part,"isAnimated"),this.N=this.N^262144,this.i("isAnimated",i,t))}get highlightedChanged(){return this.E!==null?this.E.$p:null}set highlightedChanged(t){const i=this.highlightedChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"highlightedChanged"),this.Qi(),this.E.$p=t,this.i("highlightedChanged",i,t))}get selectionObjectName(){return this.E!==null?this.E.Qp:""}set selectionObjectName(t){const i=this.selectionObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"selectionObjectName"),this.Qi(),this.E.Qp=t,this.dl=null,this.i("selectionObjectName",i,t))}get selectionAdornmentTemplate(){return this.E!==null?this.E._p:null}set selectionAdornmentTemplate(t){const i=this.selectionAdornmentTemplate;i!==t&&(Debug&&Util.s(t,Adornment,Part,"selectionAdornmentTemplate"),this.Qi(),this.E._p=t,this.i("selectionAdornmentTemplate",i,t))}get selectionObject(){if(this.dl===null){const t=this.selectionObjectName;if(t!==null&&t!==""){const i=this.findObject(t);i!==null?this.dl=i:this.dl=this}else if(this instanceof Link){const i=this.path;i!==null?this.dl=i:this.dl=this}else this.dl=this}return this.dl}get selectionChanged(){return this.E!==null?this.E.ty:null}set selectionChanged(t){const i=this.selectionChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"selectionChanged"),this.Qi(),this.E.ty=t,this.i("selectionChanged",i,t))}get resizeAdornmentTemplate(){return this.E!==null?this.E.iy:null}set resizeAdornmentTemplate(t){const i=this.resizeAdornmentTemplate;i!==t&&(Debug&&Util.s(t,Adornment,Part,"resizeAdornmentTemplate"),this.Qi(),this.E.iy=t,this.i("resizeAdornmentTemplate",i,t))}get resizeObjectName(){return this.E!==null?this.E.ey:""}set resizeObjectName(t){const i=this.resizeObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"resizeObjectName"),this.Qi(),this.E.ey=t,this.i("resizeObjectName",i,t))}get resizeObject(){const t=this.resizeObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get resizeCellSize(){return this.E!==null?this.E.sy:Size.xw}set resizeCellSize(t){const i=this.resizeCellSize;i.equals(t)||(Debug&&Util.s(t,Size,Part,"resizeCellSize"),t=t.L(),this.Qi(),this.E.sy=t,this.i("resizeCellSize",i,t))}get rotateAdornmentTemplate(){return this.E!==null?this.E.ny:null}set rotateAdornmentTemplate(t){const i=this.rotateAdornmentTemplate;i!==t&&(Debug&&Util.s(t,Adornment,Part,"rotateAdornmentTemplate"),this.Qi(),this.E.ny=t,this.i("rotateAdornmentTemplate",i,t))}get rotateObjectName(){return this.E!==null?this.E.oy:""}set rotateObjectName(t){const i=this.rotateObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"rotateObjectName"),this.Qi(),this.E.oy=t,this.i("rotateObjectName",i,t))}get rotateObject(){const t=this.rotateObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get rotationSpot(){return this.E!==null?this.E.ry:Spot.Default}set rotationSpot(t){const i=this.rotationSpot;i.equals(t)||(Debug&&(Util.s(t,Spot,Part,"rotationSpot"),t!==Spot.Default&&!t.isSpot()&&Util.n("Part.rotationSpot must be a specific Spot value or Spot.Default, not: "+t)),t=t.L(),this.Qi(),this.E.ry=t,this.i("rotationSpot",i,t))}get text(){return this.ui}set text(t){const i=this.ui;i!==t&&(Debug&&Util.t(t,"string",Part,"text"),this.ui=t,this.i("text",i,t))}get containingGroup(){return this.xh}set containingGroup(t){if(this.Ae()){const i=this.xh;if(i!==t){Debug&&t!==null&&Util.s(t,Group,Part,"containingGroup"),t!==null&&(this===t||t.isMemberOf(this))&&(this===t&&Util.n("Cannot make a Group a member of itself: "+this.toString()),Util.n("Cannot make a Group indirectly contain itself: "+this.toString()+" already contains "+t.toString())),this.invalidateLayout(2);const e=this.diagram;if(i!==null?i.tN(this):this instanceof Group&&e!==null&&e.vr.delete(this),this.xh=t,t!==null?t.iN(this):this instanceof Group&&e!==null&&e.vr.add(this),this.invalidateLayout(1),e!==null&&e.j){const n=this.data,o=e.model;if(n!==null&&o.da()){const r=t!==null?t.data:null;o.setGroupForData(n,o.getKeyForNodeData(r))}}const s=this.containingGroupChanged;if(s!==null){let n=!0;e!==null&&(n=e.j,e.j=!0),s(this,i,t),e!==null&&(e.j=n)}if(this instanceof Group){const n=new GSet;Part.lh(n,this,!0,0,!0);const o=n.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=r.linksConnected;for(;l.next();)l.value.Ed()}}}if(this instanceof Node){const n=this.linksConnected;for(;n.next();)n.value.Ed();const o=this.labeledLink;o!==null&&o.Ed()}this.i("containingGroup",i,t),t!==null&&t.GI()}}else Util.n("cannot set the Part.containingGroup of a Link or Adornment")}dh(){const t=this.containingGroup;t!==null&&(t.hasPlaceholder()&&t.placeholder.u(),t.u(),t.invalidateConnectedLinks())}T(){const t=this.diagram;t!==null&&!this.rs()&&!this.nh()&&this.isVisible()&&this.Fi.isReal()&&t.T(this.Jh(this.Fi))}u(){if(this.Xo())return;super.u();const t=this.diagram;t!==null&&(t.d0(this),this instanceof Node&&this.labeledLink!==null&&this.labeledLink.lc(),t.requestUpdate(!0))}lc(t){if(this.rs())return;const i=this.diagram;i!==null&&(i.d0(this),this instanceof Node&&this.invalidateConnectedLinks(),i.requestUpdate()),this.oo(!0)}Hm(t){if(!t){const i=this.xh;i!==null&&i.iN(this)}}qm(t){if(!t){const i=this.xh;i!==null&&i.tN(this)}}Jf(){const t=this.data;if(t!==null){const i=this.diagram;if(i!==null){const e=i.model;e!==null&&e.removeNodeData(t)}}}get containingGroupChanged(){return this.E!==null?this.E.ly:null}set containingGroupChanged(t){const i=this.containingGroupChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"containingGroupChanged"),this.Qi(),this.E.ly=t,this.i("containingGroupChanged",i,t))}findSubGraphLevel(){return this.eN(this)}eN(t){const i=t.containingGroup;if(i!==null)return 1+this.eN(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.eN(e)}return 0}findTopLevelPart(){return this.sN(this)}sN(t){const i=t.containingGroup;if(i!==null)return this.sN(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.sN(e)}return t}get isTopLevel(){return!(this.containingGroup!==null||this instanceof Node&&this.labeledLink!==null)}isMemberOf(t){return t instanceof Group?this.nN(this,t):!1}nN(t,i){if(t===i||i===null)return!1;const e=t.containingGroup;if(e!==null&&(e===i||this.nN(e,i)))return!0;if(t instanceof Node){const s=t.labeledLink;if(s!==null)return this.nN(s,i)}return!1}findCommonContainingGroup(t){if(t===null)return null;if(Debug&&Util.s(t,Part,Part,"findCommonContainingGroup:other"),this===t)return this.containingGroup;let i=this;for(;i!==null;){if(i instanceof Group&&i.yb(!0),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}let e=null;for(i=t;i!==null;){if(i.eT()){e=i;break}if(i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}for(i=this;i!==null;){if(i instanceof Group&&i.yb(!1),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}return e}get layoutConditions(){return this.E!==null?this.E.hy:127}set layoutConditions(t){const i=this.layoutConditions;i!==t&&(Debug&&Util.t(t,"number",Part,"layoutConditions"),this.Qi(),this.E.hy=t,this.i("layoutConditions",i,t))}canLayout(){if(!this.isLayoutPositioned||!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary||this instanceof Node&&this.isLinkLabel)}WI(t){if(!this.isLayoutPositioned||!(t&this.layoutConditions))return!1;const i=this.layer;if(i!==null&&i.isTemporary||this instanceof Node&&this.isLinkLabel)return!1;const e=this.diagram;return!(e!==null&&e.undoManager.isUndoingRedoing)}invalidateLayout(t){if(t===void 0&&(t=16777215),!this.WI(t))return;const i=this.xh;if(i!==null){const e=i.layout;e!==null?e.invalidateLayout():i.invalidateLayout(t)}else{const e=this.diagram;if(e!==null){const s=e.layout;s!==null&&s.invalidateLayout()}}}IA(){if(!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary)}static lh(t,i,e,s,n,o){if(o===void 0&&(o=null),!t.has(i)&&!(o!==null&&!o(i))&&!(i instanceof Adornment)){if(t.add(i),i instanceof Node){if(e&&i instanceof Group){const r=i.memberParts;for(;r.next();){const l=r.value;Part.lh(t,l,e,s,n,o)}}if(n!==!1){const r=i.linksConnected;for(;r.next();){const l=r.value;if(t.has(l))continue;const h=l.fromNode,a=l.toNode,f=h===null||t.has(h),c=a===null||t.has(a);(n?f&&c:f||c)&&Part.lh(t,l,e,s,n,o)}}if(s>1){const r=i.findTreeChildrenNodes();for(;r.next();){const l=r.value;Part.lh(t,l,e,s-1,n,o)}}}else if(i instanceof Link){const r=i.labelNodes;for(;r.next();){const l=r.value;Part.lh(t,l,e,s,n,o)}}}}get dragComputation(){return this.E!==null?this.E.ay:null}set dragComputation(t){const i=this.dragComputation;i!==t&&(t!==null&&Util.t(t,"function",Part,"dragComputation"),this.Qi(),this.E.ay=t,this.i("dragComputation",i,t))}get shadowOffset(){return this.E!==null?this.E.fy:Point.hC}set shadowOffset(t){const i=this.shadowOffset;i.equals(t)||(Debug&&Util.s(t,Point,Part,"shadowOffset"),t=t.L(),this.Qi(),this.E.fy=t,this.T(),this.i("shadowOffset",i,t))}get shadowColor(){return this.E!==null?this.E.cy:"gray"}set shadowColor(t){const i=this.shadowColor;i!==t&&(Debug&&Util.t(t,"string",Part,"shadowColor"),this.Qi(),this.E.cy=t,this.T(),this.i("shadowColor",i,t))}get shadowBlur(){return this.E!==null?this.E.Pn:4}set shadowBlur(t){const i=this.shadowBlur;i!==t&&(Debug&&Util.t(t,"number",Part,"shadowBlur"),this.Qi(),this.E.Pn=t,this.T(),this.i("shadowBlur",i,t))}}class PartTemplateSettings{wi;jp;ly;_p;Qp;ty;$p;iy;ey;sy;ny;oy;ry;Jp;Zp;Wp;vp;ay;hy;fy;cy;Pn;constructor(){this.wi=!1,this.jp=null,this.ly=null,this._p=null,this.Qp="",this.ty=null,this.$p=null,this.iy=null,this.ey="",this.sy=Size.xw,this.ny=null,this.oy="",this.ry=Spot.Default,this.Jp="",this.Zp=Spot.TopLeft,this.Wp=Point.rC,this.vp=Point.lC,this.ay=null,this.hy=127,this.fy=Point.hC,this.cy="gray",this.Pn=4}copy(){const t=new PartTemplateSettings;return t.jp=this.jp,t.ly=this.ly,t._p=this._p,t.Qp=this.Qp,t.ty=this.ty,t.$p=this.$p,t.iy=this.iy,t.ey=this.ey,t.sy=this.sy.L(),t.ny=this.ny,t.oy=this.oy,t.ry=this.ry.L(),t.Jp=this.Jp,t.Zp=this.Zp.L(),t.Wp=this.Wp.L(),t.vp=this.vp.L(),t.ay=this.ay,t.hy=this.hy,t.fy=this.fy.L(),t.cy=this.cy,t.Pn=this.Pn,t}}class Adornment extends Part{ys;Et;sM;nM;dc;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.N&=-257,this.ul="Adornment",this.ys=null,this.sM=0,this.nM=!1,this.Et=null,this.dc=null,i&&Object.assign(this,i)}toString(){const t=this.adornedPart;return"Adornment("+this.category+")"+(t!==null?t.toString():"")}updateRelationshipsFromData(){}pd(t){const i=this.adornedObject,e=i?.part;if(!(e instanceof Link)||!(i instanceof Shape))return;const s=e.path;let n=s.geometry;e.pd(t),n=s.geometry;const o=this.D.h,r=o.length;for(let l=0;lh instanceof Placeholder);l instanceof Placeholder&&(this.Et===null?this.Et=l:Debug&&this.Et!==l&&Util.n("Cannot insert a second Placeholder into the visual tree of an Adornment."))}}else t===4&&i==="elements"&&this.Et!==null&&(s===this.Et?this.Et=null:s instanceof Panel&&this.Et.isContainedBy(s)&&(this.Et=null));super.ic(t,i,e,s,n,o,r)}updateAdornments(){}Jf(){}}var PortSpreading=(w=>(w[w.None=0]="None",w[w.Evenly=1]="Evenly",w[w.Packed=2]="Packed",w))(PortSpreading||{});class Node extends Part{z;bt;Cc;gl;bh;he;ni;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.z=13,this.bt=null,this.ni=new List,this.Cc=null,this.gl=null,this.he=null,this.bh=!1,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.z=this.z,this.bt!==null&&(this.bt.wi?t.bt=this.bt:t.bt=this.bt.copy())}Ho(t){super.Ho(t),t.invalidateConnectedLinks(),t.gl=this.gl,t.he=null}static SpreadingNone=0;static SpreadingEvenly=1;static SpreadingPacked=2;ml(){this.bt===null?this.bt=new NodeTemplateSettings:this.bt.wi&&(this.bt=this.bt.copy())}fh(){super.fh(),this.bt!==null&&(this.bt.wi=!0)}sT(t){t!==null&&(this.gl===null&&(this.gl=new GSet),this.gl.add(t))}nT(t){t!==null&&this.gl!==null&&this.gl.delete(t)}oT(t,i,e){if(t===null||this.gl===null)return null;const s=this.gl.iterator;for(;s.next();){const n=s.value;if(n.uy===this&&n.wb===t&&n.oN===i&&n.rN===e||n.uy===t&&n.wb===this&&n.oN===e&&n.rN===i)return n}return null}invalidateLinkBundle(t,i,e){i==null&&(i=""),e==null&&(e="");const s=this.oT(t,i,e);s!==null&&s.Vd()}ic(t,i,e,s,n,o,r){t===3&&i==="elements"?this.he=null:t===4&&i==="elements"&&(this.he=null),super.ic(t,i,e,s,n,o,r)}invalidateConnectedLinks(t){const i=this.linksConnected;for(;i.next();){const e=i.value;t!==void 0&&t.has(e)||(this.xe(e.fromPort),this.xe(e.toPort),e.invalidateRoute())}}aL(t){const i=this.linksConnected;for(;i.next();){const e=i.value;e.fromPort!==t&&e.toPort!==t||(this.xe(e.fromPort),this.xe(e.toPort),e.invalidateRoute())}}xe(t){if(t===null)return;const i=t.nd;i!==null&&i.Vd();const e=t.part,s=e.containingGroup;s!==null&&!e.isVisible()&&s.xe(s.port)}$r(){return!0}get portSpreading(){return this.bt!==null?this.bt.gy:1}set portSpreading(t){const i=this.portSpreading;if(i!==t){Debug&&t!==0&&t!==1&&t!==2&&Util.n("Node.portSpreading can only be set to PortSpreading.None, PortSpreading.Evenly, or PortSpreading.Packed, not: "+t),this.ml(),this.bt.gy=t,this.i("portSpreading",i,t);const e=this.diagram;if(e!==null&&e.undoManager.isUndoingRedoing)return;this.invalidateConnectedLinks()}}get avoidable(){return(this.z&8)!==0}set avoidable(t){const i=(this.z&8)!==0;if(i!==t){Debug&&Util.t(t,"boolean",Node,"avoidable"),this.z=this.z^8;const e=this.diagram;e!==null&&e.HP(this),this.i("avoidable",i,t)}}get avoidableMargin(){return this.bt!==null?this.bt.my:Margin.gC}set avoidableMargin(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Node,"avoidableMargin");const i=this.avoidableMargin;if(!i.equals(t)){t=t.L(),this.ml(),this.bt.my=t;const e=this.diagram;e!==null&&e.HP(this),this.i("avoidableMargin",i,t)}}canAvoid(){return this.avoidable&&!this.isLinkLabel}getAvoidableRect(t){return t.set(this.actualBounds),t.addMargin(this.avoidableMargin),t}findVisibleNode(){let t=this;for(;t!==null&&!t.isVisible();)t=t.containingGroup;return t}isVisible(){if(!super.isVisible())return!1;let t=!0,i=1;const e=this.diagram;if(e!==null){if(e.animationManager.ux(this))return!0;t=e.isTreePathToChildren,i=e.treeCollapsePolicy}if(i===1){const n=this.findTreeParentNode();if(n!==null&&!n.isTreeExpanded)return!1}else if(i===2){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&h.isTreeExpanded){r=!0;break}}}if(o&&!r)return!1}else if(i===3){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&!h.isTreeExpanded){r=!0;break}}}if(o&&r)return!1}const s=this.labeledLink;return s!==null?s.isVisible():!0}Ki(t){super.Ki(t);const i=this.linksConnected;for(;i.next();){const e=i.value;if(t&&this.containingGroup!==null){const s=e.getOtherNode(this);s!==null&&!s.isMemberOf(this.containingGroup)&&e.invalidateRoute()}e.Ki(t)}}get linksConnected(){return this.ni.iterator}findExternalTreeLinksConnected(){const t=new GSet,i=new GSet;return this.rT(this,t,i),i.iterator}rT(t,i,e){if(t===null||i.has(t))return;i.add(t);let s=!0;const n=this.diagram;n!==null&&(s=n.isTreePathToChildren),t.linksConnected.each(o=>{o.isTreeLink?(s?o.fromNode===t:o.toNode===t)&&this.rT(s?o.toNode:o.fromNode,i,e):e.add(o)})}findLinksConnected(t){if(t===void 0&&(t=null),t===null)return this.ni.iterator;Debug&&Util.t(t,"string",Node,"findLinksConnected:pid");const i=new ListIterator(this.ni),e=this;return i.predicate=s=>s.fromNode===e&&s.fromPortId===t||s.toNode===e&&s.toPortId===t,i}findLinksOutOf(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findLinksOutOf:pid");const i=new ListIterator(this.ni),e=this;return i.predicate=s=>s.fromNode!==e?!1:t===null?!0:s.fromPortId===t,i}findLinksInto(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findLinksInto:pid");const i=new ListIterator(this.ni),e=this;return i.predicate=s=>s.toNode!==e?!1:t===null?!0:s.toPortId===t,i}findNodesConnected(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findNodesConnected:pid");let i=null,e=null;const s=this.ni.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this){if(t===null||n.fromPortId===t){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}else if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesOutOf(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findNodesOutOf:pid");let i=null,e=null;const s=this.ni.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this&&(t===null||n.fromPortId===t)){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesInto(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findNodesInto:pid");let i=null,e=null;const s=this.ni.iterator;for(;s.next();){const n=s.value;if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findLinksBetween(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),Debug&&(Util.s(t,Node,Node,"findLinksBetween:othernode"),i!==null&&Util.t(i,"string",Node,"findLinksBetween:pid"),e!==null&&Util.t(e,"string",Node,"findLinksBetween:otherpid"));const s=new ListIterator(this.ni),n=this;return s.predicate=o=>o.fromNode===n&&o.toNode===t&&(i===null||o.fromPortId===i)&&(e===null||o.toPortId===e)||o.fromNode===t&&o.toNode===n&&(e===null||o.fromPortId===e)&&(i===null||o.toPortId===i),s}findLinksTo(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),Debug&&(Util.s(t,Node,Node,"findLinksTo:othernode"),i!==null&&Util.t(i,"string",Node,"findLinksTo:pid"),e!==null&&Util.t(e,"string",Node,"findLinksTo:otherpid"));const s=new ListIterator(this.ni),n=this;return s.predicate=o=>!(o.fromNode!==n||o.toNode!==t||i!==null&&o.fromPortId!==i||e!==null&&o.toPortId!==e),s}get linkConnected(){return this.bt!==null?this.bt.py:null}set linkConnected(t){const i=this.linkConnected;i!==t&&(t!==null&&Util.t(t,"function",Node,"linkConnected"),this.ml(),this.bt.py=t,this.i("linkConnected",i,t))}get linkDisconnected(){return this.bt!==null?this.bt.yy:null}set linkDisconnected(t){const i=this.linkDisconnected;i!==t&&(t!==null&&Util.t(t,"function",Node,"linkDisconnected"),this.ml(),this.bt.yy=t,this.i("linkDisconnected",i,t))}get linkValidation(){return this.bt!==null?this.bt.Ll:null}set linkValidation(t){const i=this.linkValidation;i!==t&&(t!==null&&Util.t(t,"function",Node,"linkValidation"),this.ml(),this.bt.Ll=t,this.i("linkValidation",i,t))}xb(t,i){this.xe(i);const e=this.ni.has(t);if(e||this.ni.add(t),!e||t.fromNode===t.toNode){const s=this.linkConnected;if(s!==null){let n=!0;const o=this.diagram;o!==null&&(n=o.j,o.j=!0),s(this,t,i),o!==null&&(o.j=n)}}if(!e){if(!t.isTreeLink)return;const s=t.fromNode,n=t.toNode;if(s!==null&&n!==null&&s!==n){let o=!0;const r=this.diagram;r!==null&&(o=r.isTreePathToChildren);const l=o?n:s,h=o?s:n;if(l.bh||(l.bh=h),h.isTreeLeaf){if(r!==null&&r.undoManager.isUndoingRedoing)return;o?s===h&&(h.isTreeLeaf=!1):n===h&&(h.isTreeLeaf=!1)}}}}bb(t,i){this.xe(i);const e=this.ni.delete(t);let s=null;if(e||t.toNode===t.fromNode){const n=this.linkDisconnected;if(s=this.diagram,n!==null){let o=!0;s!==null&&(o=s.j,s.j=!0),n(this,t,i),s!==null&&(s.j=o)}}if(e){if(!t.isTreeLink)return;let n=!0;s!==null&&(n=s.isTreePathToChildren);const o=n?t.toNode:t.fromNode,r=n?t.fromNode:t.toNode;if(o!==null&&(o.bh=!1),r!==null&&!r.isTreeLeaf)if(r.ni.count===0){if(r.bh=null,s!==null&&s.undoManager.isUndoingRedoing)return;r.isTreeLeaf=!0}else r.x0()}}x0(){if(this.bh=!1,this.ni.count===0)return;let t=!0;const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;i!==null&&(t=i.isTreePathToChildren);const e=this.ni.iterator;for(;e.next();){const s=e.value;if(s.isTreeLink){if(t){if(s.fromNode===this){this.isTreeLeaf=!1;return}}else if(s.toNode===this){this.isTreeLeaf=!1;return}}}this.isTreeLeaf=!0}updateRelationshipsFromData(){const t=this.diagram;t!==null&&t.partManager.updateRelationshipsFromData(this)}Hm(t){if(super.Hm(t),!t){this.x0();const i=this.Cc;i!==null&&i.lT(this)}}qm(t){if(super.qm(t),!t){const i=this.Cc;i!==null&&i.hT(this)}}Jf(){if(this.ni.count>0){const t=this.diagram;if(t!==null){const i=t.commandHandler!==null?t.commandHandler.deletesConnectedLinks:!0,s=this.ni.copy().iterator;for(;s.next();){const n=s.value;i?t.remove(n):(n.fromNode===this&&(n.fromNode=null),n.toNode===this&&(n.toNode=null))}}}this.labeledLink=null,super.Jf()}get isLinkLabel(){return this.Cc!==null}get labeledLink(){return this.Cc}set labeledLink(t){const i=this.Cc;if(i!==t){Debug&&t!==null&&Util.s(t,Link,Node,"labeledLink");const e=this.diagram,s=this.data;if(i!==null){if(i.hT(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=i.data,o=e.model;if(n!==null&&o.Oa()){const r=o.getKeyForNodeData(s);r!==void 0&&o.removeLabelKeyForLinkData(n,r)}}this.containingGroup=null}if(this.Cc=t,t!==null){if(t.lT(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=t.data,o=e.model;if(n!==null&&o.Oa()){const r=o.getKeyForNodeData(s);r!==void 0&&o.addLabelKeyForLinkData(n,r)}}this.containingGroup=t.containingGroup}this.lc(),this.i("labeledLink",i,t)}}findVisiblePort(t){let i=t;for(;i!==null&&(!i.actualBounds.isReal()||!i.isVisibleObject());)i=i.panel;return i===null?this.port:i}findPort(t){if(Debug&&Util.t(t,"string",Node,"findPort:pid"),this.he===null){if(t===""&&this.Mn===!1)return this;this.aT()}let i=this.he.get(t);return i!==null||t!==""&&(i=this.he.get(""),i!==null)?i:this}get port(){return this.findPort("")}get ports(){return this.he===null&&this.aT(),this.he.iteratorValues}aT(){this.he===null?this.he=new GMap:this.he.clear(),this.walkVisualTreeFrom(this,(t,i)=>t.yL(i)),this.he.count===0&&this.he.set("",this)}yL(t){const i=t.portId;i!==null&&this.he!==null&&this.he.set(i,t)}P2(t,i){const e=t.portId;if(e!==null){this.he!==null&&this.he.delete(e);const s=this.diagram;if(s!==null&&i){let n=null;const o=this.findLinksConnected(e);for(;o.next();){const r=o.value;n===null&&(n=Util.ft()),n.push(r)}if(n!==null){for(let r=0;r!(!n.isTreeLink||n.fromNode!==s):e.predicate=n=>!(!n.isTreeLink||n.toNode!==s),e}findTreeChildrenNodes(){let t=!0;const i=this.diagram;i!==null&&(t=i.isTreePathToChildren);let e=null,s=null;const n=this.ni.iterator;if(t)for(;n.next();){const o=n.value;if(o.isTreeLink&&o.fromNode===this){const r=o.toNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}else for(;n.next();){const o=n.value;if(o.isTreeLink&&o.toNode===this){const r=o.fromNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}return e!==null?e.iterator:s!==null?new SingletonIterator(s):EmptyIterator.instance}findTreeParts(t){t===void 0&&(t=1/0),Util.t(t,"number",Node,"findTreeParts:level");const i=new GSet;return Part.lh(i,this,!1,t,!0),i}collapseTree(t){t===void 0&&(t=1),Util.r(t,Node,"collapseTree:level"),t<1&&(t=1);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.fT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}fT(t,i,e,s,n,o){if(e>1){const r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);h!==null&&h!==this&&!t.has(h)&&(t.add(h),h.fT(t,i,e-1,s,n,o))}}else this.cT(t,i,s,n,o)}cT(t,i,e,s,n){const o=s===this?!0:this.isTreeExpanded,r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);if(h!==null&&h!==this){const a=t.has(h);if(a||t.add(h),o){const f=i?h.findNodesInto():h.findNodesOutOf(),c=this;f.all(u=>u===c||!u.isTreeExpanded)&&e.Of(h,s),h.dh(),h.Ki(!1)}h.isTreeExpanded&&(h.wasTreeExpanded=h.isTreeExpanded,a||h.cT(t,i,e,s,n))}}this.isTreeExpanded=!1}expandTree(t){t===void 0&&(t=2),Util.r(t,Node,"expandTree:level"),t<2&&(t=2);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.uT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}uT(t,i,e,s,n,o){const r=n===this?!1:this.isTreeExpanded,l=i?this.findLinksOutOf():this.findLinksInto();for(;l.next();){const h=l.value;if(!h.isTreeLink)continue;r||h.Te||h.invalidateRoute();const a=h.getOtherNode(this);if(a!==null&&a!==this&&!t.has(a)){if(t.add(a),!r){a.Ki(!0),a.dh();const f=i?a.findNodesInto():a.findNodesOutOf(),c=this;f.all(u=>u===c||!u.isTreeExpanded)&&s.If(a,n)}(e>2||a.wasTreeExpanded)&&(a.wasTreeExpanded=!1,a.uT(t,i,e-1,s,n,o))}}this.isTreeExpanded=!0}get isTreeExpanded(){return(this.z&1)!==0}set isTreeExpanded(t){const i=(this.z&1)!==0;if(i!==t){Debug&&Util.t(t,"boolean",Node,"isTreeExpanded"),this.z=this.z^1;const e=this.diagram;this.i("isTreeExpanded",i,t);const s=this.treeExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.j,e.j=!0),s(this),e!==null&&(e.j=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.Ki(t);return}t?this.expandTree():this.collapseTree()}}get wasTreeExpanded(){return(this.z&2)!==0}set wasTreeExpanded(t){const i=(this.z&2)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Node,"wasTreeExpanded"),this.z=this.z^2,this.i("wasTreeExpanded",i,t))}get treeExpandedChanged(){return this.bt!==null?this.bt.wy:null}set treeExpandedChanged(t){const i=this.treeExpandedChanged;i!==t&&(t!==null&&Util.t(t,"function",Node,"treeExpandedChanged"),this.ml(),this.bt.wy=t,this.i("treeExpandedChanged",i,t))}get isTreeLeaf(){return(this.z&4)!==0}set isTreeLeaf(t){const i=(this.z&4)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Node,"isTreeLeaf"),this.z=this.z^4,this.i("isTreeLeaf",i,t))}get isTreeRoot(){return this.findTreeParentLink()===null}}class NodeTemplateSettings{wi;py;yy;Ll;wy;my;gy;xy;by;rh;ky;constructor(){this.wi=!1,this.py=null,this.yy=null,this.Ll=null,this.wy=null,this.my=Margin.gC,this.gy=1,this.xy=null,this.by=null,this.rh=null,this.ky=null}copy(){const t=new NodeTemplateSettings;return t.py=this.py,t.yy=this.yy,t.Ll=this.Ll,t.wy=this.wy,t.my=this.my.L(),t.gy=this.gy,t.xy=this.xy,t.by=this.by,t.rh=this.rh,t.ky=this.ky,t}}var LinkAdjusting=(w=>(w[w.None=0]="None",w[w.End=17]="End",w[w.Scale=18]="Scale",w[w.Stretch=19]="Stretch",w))(LinkAdjusting||{}),Routing=(w=>(w[w.Normal=1]="Normal",w[w.Orthogonal=2]="Orthogonal",w[w.AvoidsNodes=6]="AvoidsNodes",w[w.AvoidsNodesStraight=7]="AvoidsNodesStraight",w))(Routing||{}),Curve=(w=>(w[w.None=0]="None",w[w.Bezier=9]="Bezier",w[w.JumpGap=10]="JumpGap",w[w.JumpOver=11]="JumpOver",w))(Curve||{});class Link extends Part{Dt;go;mo;Bd;po;yo;zd;Ac;Xd;Yd;Kd;Ea;Ud;$s;Ni;Ie;Lr;Lc;ir;lN;hN;kb;aN;fN;Sy;Sb;yt;er;static Va=null;static Ba=null;dc;cN;uN;constructor(t){super(Panel.Link),this.Dt=8,this.go=null,this.mo="",this.Bd=null,this.po=null,this.yo="",this.zd=null,this.Ac=0,this.Xd=0,this.Yd=0,this.Kd=NaN,this.Ea=1,this.Ud=.5,this.$s=null,this.Ni=new List().w(),this.Ie=null,this.Lr=null,this.Lc=new Rect,this.yt=new Geometry,this.ir=null,this.er=null,this.lN=null,this.hN=null,this.cN=0,this.uN=0,this.kb=new Point,this.aN=null,this.fN=null,this.Sy=null,this.Sb=NaN,this.Z=null,this.dc=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Dt=this.Dt&-113,t.mo=this.mo,t.Bd=this.Bd,t.yo=this.yo,t.zd=this.zd,t.Ac=this.Ac,t.Xd=this.Xd,t.Yd=this.Yd,t.Kd=this.Kd,t.Ea=this.Ea,t.Ud=this.Ud,this.Z!==null&&(t.Z=this.Z.copy())}Ho(t){super.Ho(t),this.mo=t.mo,this.yo=t.yo,t.Ie=null,t.invalidateRoute(),t.er=this.er;const i=t.fromPort;i!==null&&t.fromNode.xe(i);const e=t.toPort;e!==null&&t.toNode.xe(e)}fi(t){t in Routing||t in Curve||t in LinkAdjusting?Link.dN(t)?this.routing=t:t===9||t===10||t===11?this.curve=t:t===17||t===18||t===19?this.adjusting=t:t===1||t===0||Util.n("Unknown Link enum value for a Link property: "+t):super.fi(t)}static Normal=1;static Orthogonal=2;static AvoidsNodes=6;static AvoidsNodesStraight=7;static None=0;static Bezier=9;static JumpGap=10;static JumpOver=11;static End=17;static Scale=18;static Stretch=19;static OrientAlong=21;static OrientPlus90=22;static OrientMinus90=23;static OrientOpposite=24;static OrientUpright=25;static OrientPlus90Upright=26;static OrientMinus90Upright=27;static OrientUpright45=28;static JI=8;static ZI=16;static $I=14;static za=8;je(){this.Z===null&&(this.Z=new LinkSettings)}rI(t,i,e){const s=t.segmentIndex,n=t.segmentFraction;let o=t.alignmentFocus;const r=t.segmentOrientation,l=t.segmentOffset;let h=0,a=0,f=0,c=0;if(isNaN(s)){const C=this.yt,P=Util.ft();C.getPointAndAngleAlongPath(n,P);const N=Point.H(P[0],P[1]);if(N.add(this.getPoint(0)),C.type===1)N.offset(-C.startX,-C.startY);else{const T=C.figures.first();N.offset(-T.startX,-T.startY)}c=P[2],r!==0&&(f=this.computeAngle(t,r,c),t.angle=f),h=N.x,a=N.y,Point.o(N),Util.nt(P)}else if(s<-i||s>=i){const C=Point.a();this.ML(C),c=this.midAngle,r!==0&&(f=this.computeAngle(t,r,c),t.angle=f),h=C.x,a=C.y,Point.o(C)}else{let C,P,N=0;if(s>=0?(C=e.h[s],P=s0?e.h[N-1]:C),C.equalsApprox(P)){let T,L;s>=0?(T=s>0?e.h[s-1]:C,L=s1?e.h[N-2]:P);const D=T.distanceSquaredPoint(C),F=P.distanceSquaredPoint(L);D>F+10?c=s>=0?T.directionPoint(C):C.directionPoint(T):F>D+10?c=s>=0?P.directionPoint(L):L.directionPoint(P):c=s>=0?T.directionPoint(L):L.directionPoint(T)}else c=s>=0?C.directionPoint(P):P.directionPoint(C);r!==0&&(f=this.computeAngle(t,r,c),t.angle=f),h=C.x+(P.x-C.x)*n,a=C.y+(P.y-C.y)*n}if(o.isNone()){t.location=new Point(h,a);return}else o.isNoSpot()&&(o=Spot.Center);const u=Transform.a();u.Bi(),u.lt(t.scale,t.scale),u.ms(t.angle,0,0);const d=t.naturalBounds,m=Rect.H(0,0,d.width,d.height),g=Point.a();g.setRectSpot(m,o),u.Pt(g);let p=-g.x,y=-g.y;const x=d.width,k=d.height,b=Point.a();b.c(l);const S=isNaN(l.x),M=isNaN(l.y);if(S||M){const C=x/2+3,P=k/2+3,N=c>=45&&c<=135,T=c>=225&&c<=315;r===0&&(N||T)?(b.x=M?C:l.y,b.y=S?P:l.x,N?s>=0||isNaN(s)&&n<.5||S&&(b.y=-P):T&&((s>=0||isNaN(s)&&n<.5)&&S&&(b.y=-P),M&&(b.x=-C))):(S&&(s>=0||isNaN(s)&&n<.5?b.x=C:b.x=-C),M&&(b.y=-P),b.rotate(c))}else b.rotate(c);h+=b.x,a+=b.y,u.Cw(m),p+=m.x,y+=m.y;const A=Point.H(h+p,a+y);t.move(A),Point.o(A),Point.o(b),Point.o(g),Rect.o(m),Transform.o(u)}$r(){let t=this.fromNode;if(t!==null){const e=t.findVisibleNode();if(e!==null&&(t=e),t.rs()||t.nh())return!1}let i=this.toNode;if(i!==null){const e=i.findVisibleNode();if(e!==null&&(i=e),i.rs()||i.nh())return!1}return!0}S2(t,i,e){return!1}M2(){}Ae(){return!1}computeAngle(t,i,e){return Link.computeAngle(i,e)}static computeAngle(t,i){let e=0;switch(t){default:case 0:e=0;break;case 21:e=i;break;case 22:e=i+90;break;case 23:e=i-90;break;case 24:e=i+180;break;case 25:e=Geo.Jg(i),e>90&&e<270&&(e-=180);break;case 26:e=Geo.Jg(i+90),e>90&&e<270&&(e-=180);break;case 27:e=Geo.Jg(i-90),e>90&&e<270&&(e-=180);break;case 28:if(e=Geo.Jg(i),e>45&&e<135||e>225&&e<315)return 0;e>90&&e<270&&(e-=180);break}return Geo.Jg(e)}get fromNode(){return this.go}set fromNode(t){const i=this.go;if(i!==t){Debug&&t!==null&&Util.s(t,Node,Link,"fromNode");const e=this.fromPort;i!==null&&(this.po!==i&&i.bb(this,e),this.My(),this.invalidateLayout(2)),this.go=t,t!==null&&this.Ki(t.isVisible()),this.ir=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.j&&s.partManager.setFromNodeForLink(this,t,i);const n=this.fromPort,o=this.fromPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.j,s.j=!0),o(this,e,n),s!==null&&(s.j=r)}t!==null&&(this.po!==t&&t.xb(this,n),this.Py(),this.invalidateLayout(1)),this.i("fromNode",i,t),this.Ed()}}get fromPortId(){return this.mo}set fromPortId(t){const i=this.mo;if(i!==t){Debug&&Util.t(t,"string",Link,"fromPortId");const e=this.fromPort;e!==null&&this.fromNode.xe(e),this.My(),this.mo=t;const s=this.fromPort;s!==null&&this.fromNode.xe(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Oa()&&r.setFromPortIdForLinkData(o,t)}if(e!==s){this.ir=null,this.invalidateRoute();const o=this.fromPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.j,n.j=!0),o(this,e,s),n!==null&&(n.j=r)}}this.Py(),this.i("fromPortId",i,t)}}get fromPort(){const t=this.go;if(t===null)return null;const i=this.mo;return t.findPort(i)}get fromPortChanged(){return this.Bd}set fromPortChanged(t){const i=this.Bd;i!==t&&(t!==null&&Util.t(t,"function",Link,"fromPortChanged"),this.Bd=t,this.i("fromPortChanged",i,t))}get toNode(){return this.po}set toNode(t){const i=this.po;if(i!==t){Debug&&t!==null&&Util.s(t,Node,Link,"toNode");const e=this.toPort;i!==null&&(this.go!==i&&i.bb(this,e),this.My(),this.invalidateLayout(2)),this.po=t,t!==null&&this.Ki(t.isVisible()),this.ir=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.j&&s.partManager.setToNodeForLink(this,t,i);const n=this.toPort,o=this.toPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.j,s.j=!0),o(this,e,n),s!==null&&(s.j=r)}t!==null&&(this.go!==t&&t.xb(this,n),this.Py(),this.invalidateLayout(1)),this.i("toNode",i,t),this.Ed()}}get toPortId(){return this.yo}set toPortId(t){const i=this.yo;if(i!==t){Debug&&Util.t(t,"string",Link,"toPortId");const e=this.toPort;e!==null&&this.toNode.xe(e),this.My(),this.yo=t;const s=this.toPort;s!==null&&this.toNode.xe(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Oa()&&r.setToPortIdForLinkData(o,t)}if(e!==s){this.ir=null,this.invalidateRoute();const o=this.toPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.j,n.j=!0),o(this,e,s),n!==null&&(n.j=r)}}this.Py(),this.i("toPortId",i,t)}}get toPort(){const t=this.po;if(t===null)return null;const i=this.yo;return t.findPort(i)}get toPortChanged(){return this.zd}set toPortChanged(t){const i=this.zd;i!==t&&(t!==null&&Util.t(t,"function",Link,"toPortChanged"),this.zd=t,this.i("toPortChanged",i,t))}get fromSpot(){return this.Z!==null?this.Z.ma:Spot.Default}set fromSpot(t){const i=this.fromSpot;if(!i.equals(t)){if(Debug&&Util.s(t,Spot,Link,"fromSpot"),t=t.L(),this.je(),this.Z.ma=t,this.i("fromSpot",i,t),i.isSide()||t.isSide()){const e=this.fromNode;e!==null&&e.xe(this.fromPort)}this.invalidateRoute()}}get fromEndSegmentLength(){return this.Z!==null?this.Z.ya:NaN}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;i!==t&&(Debug&&Util.t(t,"number",Link,"fromEndSegmentLength"),t<0&&Util.G(t,">= 0",Link,"fromEndSegmentLength"),this.je(),this.Z.ya=t,this.i("fromEndSegmentLength",i,t),this.invalidateRoute())}get fromShortLength(){return this.Z!==null?this.Z.xa:NaN}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(Debug&&Util.t(t,"number",Link,"fromShortLength"),this.je(),this.Z.xa=t,this.re(),this.i("fromShortLength",i,t))}get toSpot(){return this.Z!==null?this.Z.pa:Spot.Default}set toSpot(t){const i=this.toSpot;if(!i.equals(t)){if(Debug&&Util.s(t,Spot,Link,"toSpot"),t=t.L(),this.je(),this.Z.pa=t,this.i("toSpot",i,t),i.isSide()||t.isSide()){const e=this.toNode;e!==null&&e.xe(this.toPort)}this.invalidateRoute()}}get toEndSegmentLength(){return this.Z!==null?this.Z.wa:NaN}set toEndSegmentLength(t){const i=this.toEndSegmentLength;i!==t&&(Debug&&Util.t(t,"number",Link,"toEndSegmentLength"),t<0&&Util.G(t,">= 0",Link,"toEndSegmentLength"),this.je(),this.Z.wa=t,this.i("toEndSegmentLength",i,t),this.invalidateRoute())}get toShortLength(){return this.Z!==null?this.Z.ba:NaN}set toShortLength(t){const i=this.toShortLength;i!==t&&(Debug&&Util.t(t,"number",Link,"toShortLength"),this.je(),this.Z.ba=t,this.re(),this.i("toShortLength",i,t))}Ed(){const t=this.fromNode,i=this.toNode;let e=null;if(t!==null?i!==null?e=t.findCommonContainingGroup(i):e=t.containingGroup:i!==null?e=i.containingGroup:e=null,this.QI(e),this.isLabeledLink){const s=this.labelNodes;for(;s.next();){const n=s.value;n.containingGroup=e}}}QI(t){const i=this.xh;if(i!==t){i!==null&&i.tN(this),this.xh=t,t!==null&&t.iN(this);const e=this.containingGroupChanged;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.j,n.j=!0),e(this,i,t),n!==null&&(n.j=s)}this.Te&&(this.aN===i||this.fN===i)&&this.invalidateRoute()}}dh(){const t=this.containingGroup;t!==null&&this.fromNode!==t&&this.toNode!==t&&t.computesBoundsIncludingLinks&&super.dh()}getOtherNode(t){Debug&&Util.s(t,Node,Link,"getOtherNode:node");const i=this.fromNode;return t===i?this.toNode:i}getOtherPort(t){Debug&&Util.s(t,GraphObject,Link,"getOtherPort:port");const i=this.fromPort;return t===i?this.toPort:i}get isLabeledLink(){return this.$s===null?!1:this.$s.count>0}get labelNodes(){return this.$s===null?EmptyIterator.instance:this.$s.iterator}lT(t){this.$s===null&&(this.$s=new GSet),this.$s.add(t),this.u()}hT(t){this.$s!==null&&(this.$s.delete(t),this.u())}Hm(t){if(super.Hm(t),this.Xa()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.go;let e=null;i!==null&&(e=this.fromPort,i.xb(this,e));const s=this.po;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.xb(this,n)),this.Py()}}qm(t){if(super.qm(t),this.Xa()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.go;let e=null;i!==null&&(e=this.fromPort,i.bb(this,e));const s=this.po;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.bb(this,n)),this.My()}}Jf(){if(this.Te=!0,this.$s!==null){const i=this.diagram;if(i!==null){const s=this.$s.copy().iterator;for(;s.next();){const n=s.value;i.remove(n)}}}if(this.data!==null){const i=this.diagram;i!==null&&i.partManager.gN(this)}}updateRelationshipsFromData(){if(this.data===null)return;const i=this.diagram;i!==null&&i.partManager.updateRelationshipsFromData(this)}move(t,i){const e=i?this.location:this.position;let s=e.x;isNaN(s)&&(s=0);let n=e.y;isNaN(n)&&(n=0);const o=t.x-s,r=t.y-n;if(i===!0)super.move(t,!1);else{const h=Point.H(e.x+o,e.y+r);super.move(h,!1),Point.o(h)}this.kr(o,r);const l=this.labelNodes;for(;l.next();){const h=l.value,a=h.position;h.moveTo(a.x+o,a.y+r)}}get relinkableFrom(){return(this.Dt&1)!==0}set relinkableFrom(t){const i=(this.Dt&1)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"relinkableFrom"),this.Dt=this.Dt^1,this.i("relinkableFrom",i,t),this.invalidateAdornments())}get relinkableTo(){return(this.Dt&2)!==0}set relinkableTo(t){const i=(this.Dt&2)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"relinkableTo"),this.Dt=this.Dt^2,this.i("relinkableTo",i,t),this.invalidateAdornments())}canRelinkFrom(){if(!this.relinkableFrom)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}canRelinkTo(){if(!this.relinkableTo)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}get resegmentable(){return(this.Dt&4)!==0}set resegmentable(t){const i=(this.Dt&4)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"resegmentable"),this.Dt=this.Dt^4,this.i("resegmentable",i,t),this.invalidateAdornments())}get isTreeLink(){return(this.Dt&8)!==0}set isTreeLink(t){const i=(this.Dt&8)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"isTreeLink"),this.Dt=this.Dt^8,this.i("isTreeLink",i,t),this.fromNode!==null&&this.fromNode.x0(),this.toNode!==null&&this.toNode.x0())}get path(){const t=this.findMainElement();return t instanceof Shape?t:null}get routeBounds(){return this.updateRoute(),this._I(this.Lc)}_I(t){let i=1/0,e=1/0;const s=this.pointsCount;if(s===0)return t.e(NaN,NaN,0,0),t;if(s===1){const n=this.getPoint(0);i=Math.min(n.x,i),e=Math.min(n.y,e),t.e(n.x,n.y,0,0)}else if(s===2){const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o)}else if(this.computeCurve()===9&&s>=3&&!this.isOrthogonal){let n=this.getPoint(0);if(i=n.x,e=n.y,t.e(i,e,0,0),s===3){const o=this.getPoint(1);i=Math.min(o.x,i),e=Math.min(o.y,e);const r=this.getPoint(2);i=Math.min(r.x,i),e=Math.min(r.y,e),Geo.mu(n.x,n.y,o.x,o.y,o.x,o.y,r.x,r.y,.5,t)}else for(let o=3;o=s&&(o=s-1);const l=this.getPoint(o-1),h=this.getPoint(o);Geo.mu(n.x,n.y,r.x,r.y,l.x,l.y,h.x,h.y,.5,t),i=Math.min(h.x,i),e=Math.min(h.y,e),n=h}}else{const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o);for(let r=2;r=15||this.computeCurve()===9)){this.yt.getPointAlongPath(.5,t),t.add(this.getPoint(0));const a=this.yt.figures.first();return t.offset(-a.startX,-a.startY),t}if(this.computeCurve()===9){if(i===3){const c=this.getPoint(0),u=this.getPoint(1),d=this.getPoint(2);return Geo.bC(c.x,c.y,u.x,u.y,u.x,u.y,d.x,d.y,t),t}const a=(i-1)/3|0,f=(a/2|0)*3;if(a%2===1){const c=this.getPoint(f),u=this.getPoint(f+1),d=this.getPoint(f+2),m=this.getPoint(f+3);return Geo.bC(c.x,c.y,u.x,u.y,d.x,d.y,m.x,m.y,t),t}else return t.c(this.getPoint(f)),t}const e=this.flattenedLengths,s=this.flattenedTotalLength;let n=0,o=0,r=0;for(;ns/2));)n+=r,o++;const l=this.getPoint(o),h=this.getPoint(o+1);if(Math.abs(l.x-h.x)<1)l.y>h.y?t.e(l.x,l.y-(s/2-n)):t.e(l.x,l.y+(s/2-n));else if(Math.abs(l.y-h.y)<1)l.x>h.x?t.e(l.x-(s/2-n),l.y):t.e(l.x+(s/2-n),l.y);else{const a=(s/2-n)/r,f=a*(h.x-l.x),c=a*(h.y-l.y);t.e(l.x+f,l.y+c)}return t}get midAngle(){return this.updateRoute(),this.computeMidAngle()}computeMidAngle(){const t=this.pointsCount;if(t<2)return NaN;if(t===2){const h=this.getPoint(0),a=this.getPoint(1);return h.directionPoint(a)}if(this.isOrthogonal&&(this.computeCorner()>=15||this.computeCurve()===9))return this.yt.getAngleAlongPath(.5);if(this.computeCurve()===9&&t>=4){const h=(t-1)/3|0;let a=(h/2|0)*3;if(h%2===1){a=Math.floor(a);const f=this.getPoint(a),c=this.getPoint(a+1),u=this.getPoint(a+2),d=this.getPoint(a+3);return Geo.YD(f.x,f.y,c.x,c.y,u.x,u.y,d.x,d.y)}else if(a>0&&a+1e/2));)s+=o,n++;const r=this.getPoint(n),l=this.getPoint(n+1);if(Math.abs(r.x-l.x)<1&&Math.abs(r.y-l.y)<1){if(n>0&&n+2l.y?270:90;if(Math.abs(r.y-l.y)<1)return r.x>l.x?180:0}return r.directionPoint(l)}tO(){if(this.Sy===null){this.Te||this.Mb();const t=this.Sy=[];this.iO(t)}}get flattenedLengths(){return this.tO(),this.Sy}get flattenedTotalLength(){let t=this.Sb;if(isNaN(t)){const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=3){let g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e);m=this.adjustPoints(0,g,o-1,p),m&&(g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e),this.adjustPoints(0,g,o-1,p))}m||(this.clearPoints(),u?this.eO(i,e,r,s,n,l):this.sO(i,e,r,s,n,l))}else{const m=this.isAvoiding;d&&(c&&m||f)&&this.clearPoints();const g=f?this.computeCurviness():0,p=this.getLinkPoint(i,e,r,!0,c,s,n);let y=0,x=0,k=0;if(c||!h||f){let N=this.computeEndSegmentLength(i,e,r,!0);if(k=this.getLinkDirection(i,e,p,r,!0,c,s,n),f&&(h||r.equals(l)||!c&&r.x+l.x===1&&r.y+l.y===1)&&(k-=c?90:30,g<0&&(k-=180)),k<0?k+=360:k>=360&&(k-=360),f&&(N+=Math.abs(g)*(c?1:2)),k===0?y=N:k===90?x=N:k===180?y=-N:k===270?x=-N:(y=N*Math.cos(k*Math.PI/180),x=N*Math.sin(k*Math.PI/180)),r.isNoSpot()&&f){const T=e.getDocumentPoint(Spot.Center,Point.a()),L=Point.H(T.x+y*1e3,T.y+x*1e3);this.getLinkPointFromPoint(i,e,T,L,!0,p),Point.o(T),Point.o(L)}}const b=this.getLinkPoint(s,n,l,!1,c,i,e);let S=0,M=0,A=0;if(c||!a||f){let N=this.computeEndSegmentLength(s,n,l,!1);if(A=this.getLinkDirection(s,n,b,l,!1,c,i,e),f&&(a||r.equals(l)||!c&&r.x+l.x===1&&r.y+l.y===1)&&(A+=c?0:30,g<0&&(A+=180)),A<0?A+=360:A>=360&&(A-=360),f&&(N+=Math.abs(g)*(c?1:2)),A===0?S=N:A===90?M=N:A===180?S=-N:A===270?M=-N:(S=N*Math.cos(A*Math.PI/180),M=N*Math.sin(A*Math.PI/180)),l.isNoSpot()&&f){const T=n.getDocumentPoint(Spot.Center,Point.a()),L=Point.H(T.x+S*1e3,T.y+M*1e3);this.getLinkPointFromPoint(s,n,T,L,!1,b),Point.o(T),Point.o(L)}}let C=p;(c||!h||f)&&(C=new Point(p.x+y,p.y+x));let P=b;(c||!a||f)&&(P=new Point(b.x+S,b.y+M)),!d&&!c&&h&&o>3&&this.adjustPoints(0,p,o-2,P)?this.setPoint(o-1,b):!d&&!c&&a&&o>3&&this.adjustPoints(1,C,o-1,b)?this.setPoint(0,p):!d&&(c?o>=6:o>4)&&this.adjustPoints(1,C,o-2,P)?(this.setPoint(0,p),this.setPoint(o-1,b)):(this.clearPoints(),this.addPoint(p),(c||!h||f)&&this.addPoint(C),c&&this.addOrthoPoints(C,k,P,A,i,s),(c||!a||f)&&this.addPoint(P),this.addPoint(b))}return t.addInvalidRoute(this),!0}pN(t,i){return Math.abs(i.x-t.x)>Math.abs(i.y-t.y)?(i.x>=t.x?i.x=t.x+9e9:i.x=t.x-9e9,i.y=t.y):(i.y>=t.y?i.y=t.y+9e9:i.y=t.y-9e9,i.x=t.x),i}getLinkPointFromPoint(t,i,e,s,n,o){if(o===void 0&&(o=new Point),t===null||i===null)return o.c(e),o;if(!t.isVisible()){const u=t.findVisibleNode();u!==null&&u!==t&&(t=u,i=t.port)}let r=0,l=0,h=0,a=0,f=null,c=i.panel;if(c!==null&&!c.kn()&&(c=c.panel),c===null)r=s.x,l=s.y,h=e.x,a=e.y;else{f=c.Ks;const u=1/(f.m11*f.m22-f.m12*f.m21),d=f.m22*u,m=-f.m12*u,g=-f.m21*u,p=f.m11*u,y=u*(f.m21*f.dy-f.m22*f.dx),x=u*(f.m12*f.dx-f.m11*f.dy);r=s.x*d+s.y*g+y,l=s.x*m+s.y*p+x,h=e.x*d+e.y*g+y,a=e.x*m+e.y*p+x}return i.sc(r,l,h,a,o),f!==null&&o.O(f),o}nO(t,i){const e=t.nd;return e!==null?e.dT(i):null}Nb(t){let i=t.nd;return i===null&&(i=new Knot,i.sr=t,i.ye=t.part,t.nd=i),i.dT(this)}getLinkPoint(t,i,e,s,n,o,r,l){if(l===void 0&&(l=new Point),e.isSpot()&&!this.Gd(e))return i.getDocumentPoint(e,l),l;if(e.isSide()){const f=this.Nb(i);if(f!==null){const c=f.Hd;if(l.c(c),n&&this.routing===7){const u=this.Nb(r);if(u!==null&&f.Tc=g.y&&y.y<=g.y+g.height?l.y=y.y:(e.includesSide(Spot.TopSide)||e.includesSide(Spot.BottomSide))&&y.x>=g.x&&y.x<=g.x+g.width&&(l.x=y.x),Point.o(d),Point.o(m)}}return l}}const h=i.getDocumentPoint(this.Cb(e,s),Point.a());let a=null;if(this.pointsCount>(n?6:2))a=s?this.getPoint(1):this.getPoint(this.pointsCount-2),n&&(a=this.pN(h,a.copy()));else{const f=this.computeSpot(!s,r),c=Point.a();a=r.getDocumentPoint(this.Cb(f,!s),c),n&&(a=this.pN(h,a)),Point.o(c)}return this.getLinkPointFromPoint(t,i,h,a,s,l),Point.o(h),l}getLinkDirection(t,i,e,s,n,o,r,l){let h=this.oO(t,i,e,s,n,o,r,l);if(r&&s.isNoSpot()&&r.isMemberOf(t)&&(h+=180,h>=360&&(h-=360)),this.Gd(s))return h;const a=i.getDocumentAngle();return a===0||(45<=a&&a<135?h+=90:135<=a&&a<225?h+=180:225<=a&&a<315&&(h+=270),h>=360&&(h-=360)),h}oO(t,i,e,s,n,o,r,l){if(s.isSpot())return s.x>s.y?s.x>1-s.y?0:s.x<1-s.y?270:315:s.x1-s.y?90:s.x<1-s.y?180:135:s.x<.5?225:s.x>.5?45:0;if(s.isSide()){const c=this.Nb(i);if(c!==null)switch(c.be){case 1:return 270;case 2:return 180;default:case 4:return 0;case 8:return 90}}const h=i.getDocumentPoint(Spot.Center,Point.a());let a=null;if(this.pointsCount>(o?6:2))a=n?this.getPoint(1):this.getPoint(this.pointsCount-2),o?a=this.pN(h,a.copy()):a=e;else{const c=Point.a();a=l.getDocumentPoint(Spot.Center,c),Point.o(c)}let f=0;return Math.abs(a.x-h.x)>Math.abs(a.y-h.y)?a.x>=h.x?f=0:f=180:a.y>=h.y?f=90:f=270,Point.o(h),f}computeEndSegmentLength(t,i,e,s){if(i!==null&&e.isSide()){const o=this.Nb(i);if(o!==null)return o.Ab}let n=NaN;return s?n=this.fromEndSegmentLength:n=this.toEndSegmentLength,i!==null&&isNaN(n)&&(s?n=i.fromEndSegmentLength:n=i.toEndSegmentLength),isNaN(n)&&(n=10),n}computeSpot(t,i){return i===void 0&&(i=null),t?this.rO(i||this.fromPort):this.lO(i||this.toPort)}rO(t){if(t===null)return Spot.Center;let i=this.fromSpot;return i.isDefault()&&(i=t.fromSpot),i===Spot.Default?Spot.None:i}lO(t){if(t===null)return Spot.Center;let i=this.toSpot;return i.isDefault()&&(i=t.toSpot),i===Spot.Default?Spot.None:i}Gd(t){return t===Spot.None||t.x===.5&&t.y===.5}Cb(t,i){return t.x===.5&&t.y===.5?t:Spot.Center}computeOtherPoint(t,i){if(this.computeAdjusting()!==0&&this.pointsCount>4)return this.computeMidPoint(new Point);{const e=this.nO(i,this);return e!==null?e.Hd:i.getDocumentPoint(Spot.Center)}}computeShortLength(t){if(t){let i=this.fromShortLength;if(isNaN(i)){const e=this.fromPort;e!==null&&(i=e.fromShortLength)}return isNaN(i)?0:i}else{let i=this.toShortLength;if(isNaN(i)){const e=this.toPort;e!==null&&(i=e.toShortLength)}return isNaN(i)?0:i}}Km(t,i,e,s,n,o){if(this.pickable===!1)return!1;i===void 0&&(i=null),e===void 0&&(e=null);let r=o;if(o===void 0&&(r=Transform.a(),r.Bi()),r.hf(this.O),this.containedInRect(t,r))return this.Y2(i,e,n),o===void 0&&Transform.o(r),!0;if(this.intersectsRect(t,r)){let l=!1;if(!this.gc){const h=this.D.h,a=h.length;for(let f=a;f--;){const c=h[f];if(!c.visible&&c!==this.locationObject)continue;const u=c.actualBounds,d=this.naturalBounds;if(u.x>d.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;const m=c,g=Transform.a();if(g.set(r),m instanceof Panel?l=m.Km(t,i,e,s,n,g):this.path===m?m instanceof Shape&&(l=m.TI(t,s,g)):l=m.lL(t,s,g),l){let p=m;i!==null&&(p=i(m)),p&&(e===null||e(p))&&n.add(p)}Transform.o(g)}}return o===void 0&&Transform.o(r),l||this.background!==null}return o===void 0&&Transform.o(r),!1}get isOrthogonal(){return(this.Ea&2)===2}static dN(t){return(t&2)===2}get isAvoiding(){return(this.Ea&4)===4}computeCurve(){if(this.ir===null){const t=this.fromPort,i=t!==null&&t===this.toPort,e=this.isOrthogonal;this.ir=i&&!e}return this.ir?9:this.curve}computeCorner(){if(this.curve===9)return 0;let t=this.corner;return(isNaN(t)||t<0)&&(t=10),t}findMidLabel(){const t=this.path,i=this.D.h,e=i.length;for(let n=0;n0?g-=c:g+=c;else{const p=-h/a;let y=Math.sqrt(c*c/(p*p+1));f<0&&(y=-y),m=(a<0?-1:1)*y+u,g=p*(m-u)+d}this.addPoint(r),this.addPointAt(m,g),this.addPoint(l)}else{this.addPoint(r),this.addPoint(l);const h=Rect.a();i.getDocumentBounds(h);const a=h.containsPoint(l);n.getDocumentBounds(h);const f=h.containsPoint(r);if(a||f){const c=i.getDocumentPoint(this.Cb(e,!0),new Point);this.setPoint(0,this.getLinkPointFromPoint(t,i,c,l,!0,c));const u=n.getDocumentPoint(this.Cb(o,!1),new Point);this.setPoint(1,this.getLinkPointFromPoint(s,n,u,r,!1,u))}Rect.o(h)}}eO(t,i,e,s,n,o){const r=this.getLinkPoint(t,i,e,!0,!1,s,n),l=this.getLinkPoint(s,n,o,!1,!1,t,i),h=l.x-r.x,a=l.y-r.y,f=this.computeCurviness();let c=0,u=0,d=r.x+h/3,m=r.y+a/3,g=d,p=m;Geo.p(a,0)?h>0?p-=f:p+=f:(c=-h/a,u=Math.sqrt(f*f/(c*c+1)),f<0&&(u=-u),g=(a<0?-1:1)*u+d,p=c*(g-d)+m),d=r.x+2*h/3,m=r.y+2*a/3;let y=d,x=m;Geo.p(a,0)?h>0?x-=f:x+=f:(y=(a<0?-1:1)*u+d,x=c*(y-d)+m),this.clearPoints(),this.addPoint(r),this.addPointAt(g,p),this.addPointAt(y,x),this.addPoint(l),this.setPoint(0,this.getLinkPoint(t,i,e,!0,!1,s,n)),this.setPoint(3,this.getLinkPoint(s,n,o,!1,!1,t,i))}adjustPoints(t,i,e,s){let n=this.computeAdjusting();if(this.isOrthogonal){if(n===18)return!1;n===19&&(n=17)}switch(n){case 18:return this.hO(t,i,e,s);case 19:return this.aO(t,i,e,s);case 17:return this.fO(t,i,e,s);default:return!1}}hO(t,i,e,s){const n=this.getPoint(t),o=this.getPoint(e);if(n.equalsApprox(i)&&o.equalsApprox(s))return!0;const r=n.x,l=n.y,h=o.x,a=o.y;let f=h-r,c=a-l;const u=Math.sqrt(f*f+c*c);if(Geo.q(u,0))return!0;let d=0;Geo.q(f,0)?c<0?d=-Math.PI/2:d=Math.PI/2:(d=Math.atan(c/Math.abs(f)),f<0&&(d=Math.PI-d));const m=i.x,g=i.y,p=s.x,y=s.y,x=p-m,k=y-g,b=Math.sqrt(x*x+k*k);let S=0;Geo.q(x,0)?k<0?S=-Math.PI/2:S=Math.PI/2:(S=Math.atan(k/Math.abs(x)),x<0&&(S=Math.PI-S));const M=b/u,A=S-d;this.setPoint(t,i);for(let C=t+1;C0&&(C=-C);const P=c+S*(d-c),N=u+S*(m-u);if(g!==0){const T=P+C/p,L=N-(T-P)/g;this.setPointAt(y,T,L)}else this.setPointAt(y,P,N+C)}return this.setPoint(e,s),!0}fO(t,i,e,s){if(this.isOrthogonal){let n=this.getPoint(t),o=this.getPoint(t+1),r=this.getPoint(t+2),l=o.x,h=o.y;const a=l,f=h;Geo.p(n.y,o.y)?Geo.p(o.x,r.x)?h=i.y:Geo.p(o.y,r.y)&&(l=i.x):Geo.p(n.x,o.x)&&(Geo.p(o.y,r.y)?l=i.x:Geo.p(o.x,r.x)&&(h=i.y)),this.setPointAt(t+1,l,h),n=this.getPoint(e),o=this.getPoint(e-1),r=this.getPoint(e-2);let c=o.x,u=o.y;const d=c,m=u;if(Geo.p(n.y,o.y)?Geo.p(o.x,r.x)?u=s.y:Geo.p(o.y,r.y)&&(c=s.x):Geo.p(n.x,o.x)&&(Geo.p(o.y,r.y)?c=s.x:Geo.p(o.x,r.x)&&(u=s.y)),this.setPointAt(e-1,c,u),this.VA())return this.setPointAt(t+1,a,f),this.setPointAt(e-1,d,m),!1}return this.setPoint(t,i),this.setPoint(e,s),!0}addOrthoPoints(t,i,e,s,n,o){i<0?i+=360:i>=360&&(i-=360),s<0?s+=360:s>=360&&(s-=360);const f=s;i>=315||i<45?i=0:45<=i&&i<135?i=90:135<=i&&i<225?i=180:i=270,s>=315||s<45?s=0:45<=s&&s<135?s=90:135<=s&&s<225?s=180:s=270;const c=t,u=e,d=n.actualBounds.copy(),m=o.actualBounds.copy();if(!d.isReal()||!m.isReal())return;d.inflate(Link.za,Link.za),m.inflate(Link.za,Link.za),d.unionPoint(t),m.unionPoint(e);const g=Point.a(),p=Point.a();i===0?u.x>c.x||s===270&&u.yc.x||s===90&&u.y>c.y&&m.right>c.x?(g.e(u.x,c.y),p.e(u.x,(c.y+u.y)/2),s===180?(g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1),p.x=g.x,p.y=u.y):s===270&&u.yc.y?(c.xm.bottom)?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):g.x=m.right,p.x=g.x,p.y=u.y):s===0&&c.xm.top&&c.yd.bottom)&&(s===180&&(m.containsPoint(c)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):u.yc.y&&(s===180||s===270)&&(g.y=this.computeMidOrthoPosition(c.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=d.left&&u.x<=c.x||c.x<=m.right&&c.x>=u.x?(s===90||s===270)&&(g.e(Math.max((c.x+u.x)/2,c.x),c.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yc.y&&m.leftc.y?(c.x>m.right?g.x=this.computeMidOrthoPosition(c.x,c.y,m.right,u.y,!1):c.x>m.left&&(s===270&&c.ym.bottom)?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):g.x=m.left,p.x=g.x,p.y=u.y):s===180&&c.x>m.right&&c.y>m.top&&c.yd.bottom)&&(s===0&&(m.containsPoint(c)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):u.yc.y&&(s===0||s===270)&&(g.y=this.computeMidOrthoPosition(c.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=c.x||c.x>=m.left&&c.x<=u.x?(s===90||s===270)&&(g.e(Math.min((c.x+u.x)/2,c.x),c.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yc.y||s===180&&u.xc.y||s===0&&u.x>c.x&&m.bottom>c.y?(g.e(c.x,u.y),p.e((c.x+u.x)/2,u.y),s===270?(g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0),p.x=u.x,p.y=g.y):s===180&&u.xc.x?(c.ym.right)?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):g.y=m.bottom,p.x=u.x,p.y=g.y):s===90&&c.ym.left&&c.xd.right)&&(s===270&&(m.containsPoint(c)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):u.xc.x&&(s===270||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,c.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=d.top&&u.y<=c.y||c.y<=m.bottom&&c.y>=u.y?(s===0||s===180)&&(g.e(c.x,Math.max((c.y+u.y)/2,c.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.xc.x&&m.top=c.x?(c.y>m.bottom?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,m.bottom,!0):c.y>m.top&&(s===180&&c.xm.right)?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):g.y=m.top,p.x=u.x,p.y=g.y):s===270&&c.y>m.bottom&&c.x>m.left&&c.xd.right)&&(s===90&&(m.containsPoint(c)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):u.xc.x&&(s===90||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,c.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=c.y||c.y>=m.top&&c.y<=u.y?(s===0||s===180)&&(g.e(c.x,Math.min((c.y+u.y)/2,c.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.x=3&&!Geo.q(this.smoothness,0))if(i===3){let f=this.getPoint(1);n=Math.min(r.x,f.x),o=Math.min(r.y,f.y),f=this.getPoint(2),n=Math.min(n,f.x),o=Math.min(o,f.y)}else if(this.isOrthogonal){for(let f=0;f=i&&(f=i-1);const c=this.getPoint(f);l.x=Math.min(c.x,l.x),l.y=Math.min(c.y,l.y)}n=l.x,o=l.y}else{for(let f=0;f=3&&!Geo.q(this.smoothness,0))if(i===3){const c=this.getPoint(1),u=c.x-n,d=c.y-o;let m=this.getPoint(2).copy();m.x-=n,m.y-=o,this.computeShortLength(!1)!==0&&(m=this.Dc(m,!1,l)),f.wr(u,d,u,d,m.x,m.y)}else if(this.isOrthogonal){const c=Point.H(n,o),u=Point.a();u.c(this.getPoint(1));const d=Point.H(n,o),m=Point.H(n,o);let g=this.getPoint(0),p=null;const y=this.smoothness/3;for(let S=1;S=i&&(c=i-1);const d=this.getPoint(c-1);let m=this.getPoint(c);c===i-1&&this.computeShortLength(!1)!==0&&(m=this.Dc(m.copy(),!1,Point.Lo)),f.wr(u.x-n,u.y-o,d.x-n,d.y-o,m.x-n,m.y-o)}else{const c=Point.a();c.c(this.getPoint(0));const u=Point.a();u.c(c);const d=this.computeCorner();let m=1,g=0;for(;m1);let p=this.getPoint(m);if(m>=i-1){if(!c.equals(p))this.computeShortLength(!1)!==0&&(p=this.Dc(p.copy(),!1,Point.Lo)),this.Dn(f,-n,-o,c,p,e);else if(g===0)for(m=1;mr?c>a?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):c>a?(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.q(r,h)&&Geo.q(a,c)&&(a>l?f>h?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):f>h?(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.q(r,h)&&Geo.q(h,f)||Geo.q(l,a)&&Geo.q(a,c)){const m=.5*(r+f),g=.5*(l+c);n.x=m,n.y=g,o.x=m,o.y=g}}Dc(t,i,e){const s=this.pointsCount;if(s<2)return t;if(i){const n=this.getPoint(1),o=n.x-e.x,r=n.y-e.y,l=this.Lb(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!0);a>h&&(a=h);const f=a*(o-t.x)/l,c=a*(r-t.y)/l;t.x+=f,t.y+=c}else{const n=this.getPoint(s-2),o=n.x-e.x,r=n.y-e.y,l=this.Lb(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!1);a>h&&(a=h);const f=a*(t.x-o)/l,c=a*(t.y-r)/l;t.x-=f,t.y-=c}return t}yN(t,i,e){const s=this.pointsCount;let n=t;for(;Geo.q(t.x,n.x)&&Geo.q(t.y,n.y);){if(i>=s)return s-1;n=this.getPoint(i++)}if(!Geo.q(t.x,n.x)&&!Geo.q(t.y,n.y))return i-1;let o=n;for(;Geo.q(t.x,n.x)&&Geo.q(n.x,o.x)&&(!e||(t.y>=n.y?n.y>=o.y:n.y<=o.y))||Geo.q(t.y,n.y)&&Geo.q(n.y,o.y)&&(!e||(t.x>=n.x?n.x>=o.x:n.x<=o.x));){if(i>=s)return s-1;o=this.getPoint(i++)}return i-2}dO(t,i,e,s,n,o,r,l,h,a){if(Geo.p(s.y,n.y)&&Geo.p(n.x,o.x)){let f=Math.min(h,Math.abs(n.x-l.x)/2);const c=Math.min(f,Math.abs(o.y-n.y)/2);if(f=c,Geo.p(f,0)){this.Dn(t,i,e,s,n,a),r.c(n);return}let u=n.x;const d=n.y,m=u;let g=d;n.x>s.x?(u=n.x-f,o.y>n.y?g=n.y+c:g=n.y-c):(u=n.x+f,o.y>n.y?g=n.y+c:g=n.y-c);const p=Point.H(u,d);this.Dn(t,i,e,s,p,a),Point.o(p),t.Fw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else if(Geo.p(s.x,n.x)&&Geo.p(n.y,o.y)){let f=Math.min(h,Math.abs(n.y-l.y)/2);const c=Math.min(f,Math.abs(o.x-n.x)/2);if(f=c,Geo.p(c,0)){this.Dn(t,i,e,s,n,a),r.c(n);return}const u=n.x;let d=n.y,m=u;const g=d;n.y>s.y?(d=n.y-f,o.x>n.x?m=n.x+c:m=n.x-c):(d=n.y+f,o.x>n.x?m=n.x+c:m=n.x-c);const p=Point.H(u,d);this.Dn(t,i,e,s,p,a),Point.o(p),t.Fw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else this.Dn(t,i,e,s,n,a),r.c(n)}computeJumpLength(){return 10}Dn(t,i,e,s,n,o){if(o||!this.Xa())t.yr(n.x+i,n.y+e);else{const r=this.computeJumpLength(),l=r/2,h=[];let a=0;this.isVisible()&&(a=this.gO(s,n,h));let f=s.x,c=s.y;if(a>0){if(Geo.p(s.y,n.y))if(s.x=0;){const d=Math.min(s.x,Math.max(h[u--]+l,n.x+r));t.yr(d+i,n.y+e),f=d+i,c=n.y+e;let m=Math.max(d-r,n.x);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.x);else break}const g=n.y-r+e,p=m+i,y=n.y+e;this.curve===10?t.wu(p,y,!1,!1):t.wr(f,g,p,g,p,y),f=p,c=y}}else if(Geo.p(s.x,n.x))if(s.y=0;){const d=Math.min(s.y,Math.max(h[u--]+l,n.y+r));t.yr(n.x+i,d+e),f=n.x+i,c=d+e;let m=Math.max(d-r,n.y);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.y);else break}const g=n.x-r+i,p=n.x+i,y=m+e;this.curve===10?t.wu(p,y,!1,!1):t.wr(g,c,g,y,p,y),f=p,c=y}}}t.yr(n.x+i,n.y+e)}}gO(t,i,e){const s=this.diagram;if(s===null||t.equals(i))return 0;const n=s.layers;for(;n.next();){const o=n.value;if(o!==null&&o.visible){const r=o.HM(),l=r.length;for(let h=0;h0&&e.sort((u,d)=>u-d),e.length;if(!a.isVisible()||!a.Xa())continue;const f=a.routeBounds;if(!f.isReal()||!this.routeBounds.intersectsRect(f)||this.usesSamePort(a))continue;const c=a.path;c!==null&&c.isVisibleObject()&&this.mO(t,i,e,a)}}}return e.length>0&&e.sort((o,r)=>o-r),e.length}mO(t,i,e,s){const n=Geo.p(t.y,i.y),o=s.pointsCount;let r=s.getPoint(0);const l=Point.a();for(let h=1;hr.x&&f.x>=a.x||a.xr.y&&f.y>=a.y||a.yf&&Math.min(a,c)o&&!Geo.p(a,c))return n.x=o,n.y=f,!0}else if(Geo.p(r,h)&&Geo.p(a,c)&&Math.min(o,l)a&&Math.min(f,u)r&&!Geo.p(f,u))return n.x=a,n.y=r,!0;return n.x=0,n.y=0,!1}get firstPickIndex(){return this.pointsCount<=2?0:this.isOrthogonal||!this.Gd(this.computeSpot(!0))?1:0}get lastPickIndex(){const t=this.pointsCount;return t===0?0:t<=2?t-1:this.isOrthogonal||!this.Gd(this.computeSpot(!1))?t-2:t-1}Xa(){const t=this.curve;return t===11||t===10}Pb(t){if(t||this.Xa()){const i=this.diagram;i!==null&&!i.animationManager.isTicking&&!i.th.has(this)&&(this.Lc.width!==0||this.Lc.height!==0)&&i.th.set(this,this.Lc.copy())}}invalidateOtherJumpOvers(t){const i=this.layer;if(i===null||!i.visible||i.isTemporary)return;const e=i.diagram;if(e===null||e.animationManager.isTicking)return;let s=!1;const n=e.layers;for(;n.next();){const o=n.value;if(o.visible){if(o===i){s=!0;let r=!1;const l=o.HM(),h=l.length;for(let a=0;a0&&e>0){const s=this.getPoint(0),n=t.getPoint(0);if(s.equalsApprox(n))return!0;const o=this.getPoint(i-1),r=t.getPoint(e-1);if(o.equalsApprox(r)||s.equalsApprox(r)||o.equalsApprox(n))return!0}else if(this.fromNode===t.fromNode||this.toNode===t.toNode||this.fromNode===t.toNode||this.toNode===t.fromNode)return!0;return!1}isVisible(){if(!super.isVisible())return!1;const t=this.containingGroup;let i=!0;const e=this.diagram;e!==null&&(i=e.isTreePathToChildren);const s=this.fromNode;if(s!==null){if(this.isTreeLink&&i&&!s.isTreeExpanded)return!1;if(s===t)return!0;let o=s;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=s.findVisibleNode();if(r===null||r===t)return!1}const n=this.toNode;if(n!==null){if(this.isTreeLink&&!i&&!n.isTreeExpanded)return!1;if(n===t)return!0;let o=n;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=n.findVisibleNode();if(r===null||r===t)return!1}return!0}Ki(t){if(super.Ki(t),t&&this.Pb(!1),this.er!==null&&this.er.Vd(),this.$s!==null){const e=this.$s.iterator;for(;e.next();)e.value.Ki(t)}}get adjusting(){return this.Ac}set adjusting(t){const i=this.Ac;i!==t&&(Debug&&t!==0&&t!==17&&t!==18&&t!==19&&Util.n("Link.adjusting can only be set to None, End, Scale, or Stretch, not: "+t),this.Ac=t,this.i("adjusting",i,t))}computeAdjusting(){return this.isAvoiding&&this.diagram!==null&&this.diagram.animationManager.defaultAnimation.isAnimating?17:this.Ac}get corner(){return this.Xd}set corner(t){const i=this.Xd;i!==t&&(Debug&&Util.t(t,"number",Link,"corner"),this.Xd=t,this.re(),this.i("corner",i,t))}get curve(){return this.Yd}set curve(t){const i=this.Yd;i!==t&&(Debug&&t!==0&&t!==9&&t!==10&&t!==11&&Util.n("Link.curve can only be set to None, Bezier, JumpGap, or JumpOver, not: "+t),this.Yd=t,this.invalidateRoute(),this.re(),this.Pb(i===10||i===11||t===10||t===11),this.i("curve",i,t))}get curviness(){return this.Kd}set curviness(t){const i=this.Kd;i!==t&&(Debug&&Util.t(t,"number",Link,"curviness"),this.Kd=t,this.invalidateRoute(),this.re(),this.i("curviness",i,t))}get routing(){return this.Ea}set routing(t){const i=this.Ea;i!==t&&(Debug&&t!==1&&t!==2&&t!==6&&t!==7&&Util.n("Link.routing can only be set to Normal, Orthogonal, AvoidsNodes, not: "+t),this.Ea=t,this.isAvoiding&&this.diagram!==null&&(this.diagram.$m=!0),this.ir=null,this.invalidateRoute(),this.Pb(Link.dN(i)||Link.dN(t)),this.i("routing",i,t))}get smoothness(){return this.Ud}set smoothness(t){const i=this.Ud;i!==t&&(Debug&&Util.t(t,"number",Link,"smoothness"),this.Ud=t,this.re(),this.i("smoothness",i,t))}Py(){const t=this.go;if(t===null)return;const i=this.po;if(i===null||!isNaN(this.curviness))return;const e=this.mo,s=this.yo;let n=null,o=null;const r=t.ni.h,l=r.length;for(let h=0;h=0&&(Util.rf(t.Qs,i),t.Vd())}}Dl(){return!0}get key(){const t=this.diagram;if(!(t===null||!t.model.Oa()))return t.model.getKeyForLinkData(this.data)}}class LinkBundle{Ko;Xs;uy;oN;wb;rN;Qs;constructor(t,i,e,s){GSet.vi(this),this.Ko=!1,this.Xs=!1,this.uy=t,this.oN=i,this.wb=e,this.rN=s,this.Qs=[]}Vd(){if(!this.Ko){const t=this.Qs;if(t.length>0){const i=t[0].diagram;i!==null&&(i.mP.add(this),this.Xs=i.undoManager.isUndoingRedoing)}}this.Ko=!0}LP(){if(this.Ko){this.Ko=!1;const t=this.Qs;if(t.length>0){const i=t[0],e=i.diagram,s=e===null||e.Yh&&!this.Xs;this.Xs=!1,i.arrangeBundledLinks(t,s),t.length===1&&(i.er=null,t.length=0)}t.length===0&&(this.uy.nT(this),this.wb.nT(this))}}}class PositionArray{ae;fe;Ya;Ka;bi;ki;Yt;Sh;Mh;ca;YP;Ko;Cy;$f;KP;UP;constructor(t){GSet.vi(this),this.ca=null,this.YP=null,this.Ko=!0,this.Cy=!1,this.ae=1,this.fe=1,this.Ya=-1,this.Ka=-1,this.bi=t.width,this.ki=t.height,this.Yt=null,this.Sh=0,this.Mh=0,this.$f=11,this.KP=this.$f*2,this.UP=this.$f*2}static _s=0;static Ua=1;static qd=999999;static wN=PositionArray.qd+1;static xN=PositionArray.qd+2;I1(t){if(t.width<=0||t.height<=0)return;const i=t.x,e=t.y,s=t.x+t.width,n=t.y+t.height;this.ae=Math.floor((i-this.bi)/this.bi)*this.bi,this.fe=Math.floor((e-this.ki)/this.ki)*this.ki,this.Ya=Math.ceil((s+2*this.bi)/this.bi)*this.bi,this.Ka=Math.ceil((n+2*this.ki)/this.ki)*this.ki;const o=1+(Math.ceil((this.Ya-this.ae)/this.bi)|0),r=1+(Math.ceil((this.Ka-this.fe)/this.ki)|0);if(this.Yt===null||this.Sh0&&t!==this.bi&&(this.bi=t,this.I1(this.bounds))}get cellHeight(){return this.ki}set cellHeight(t){t>0&&t!==this.ki&&(this.ki=t,this.I1(this.bounds))}jd(t,i){return this.ae<=t&&t<=this.Ya&&this.fe<=i&&i<=this.Ka}wo(t,i){if(!this.jd(t,i))return PositionArray.wN;t-=this.ae,t/=this.bi,i-=this.fe,i/=this.ki;const e=t|0,s=i|0;return this.Yt[e][s]}CR(t,i,e,s){if(!this.jd(t,i))return;const n=(t-this.ae)/this.bi|0,o=(i-this.fe)/this.ki|0,r=(t+e-this.ae)/this.bi|0,l=(i+s-this.fe)/this.ki|0,h=Math.min(r,this.Sh),a=Math.min(l,this.Mh);for(let f=n;f<=h;f++){const c=this.Yt[f];if(c.fill)c.fill(PositionArray._s,o,a+1);else for(let u=o;u<=a;u++)c[u]=PositionArray._s}}yO(t){if(this.Yt!==null)for(let i=0;i<=this.Sh;i++){const e=this.Yt[i];if(e.fill)e.fill(t);else for(let s=0;s<=this.Mh;s++)e[s]=t}}vA(){if(this.Yt!==null)for(let t=0;t<=this.Sh;t++){const i=this.Yt[t];for(let e=0;e<=this.Mh;e++)i[e]>=PositionArray.Ua&&(i[e]=PositionArray.wN)}}wO(t,i){return this.wo(t,i)===PositionArray._s}isUnoccupied(t,i,e,s){if(t>this.Ya||t+ethis.Ka||i+sthis.Ya||ithis.Ka||ethis.Ka||ithis.Ya||e=PositionArray.Ua&&h=a)break;this.Yt[t][i]=h,h+=1,s?i+=e:t+=e}return s?i:t}xo(t,i,e,s,n,o,r,l){if(to||il)return;const h=this.xO(t,i,e,s,n,o,r,l);if(s)if(e>0)for(let a=i+e;ah;a+=e)this.xo(t,a,1,!s,n,o,r,l),this.xo(t,a,-1,!s,n,o,r,l);else if(e>0)for(let a=t+e;ah;a+=e)this.xo(a,i,1,!s,n,o,r,l),this.xo(a,i,-1,!s,n,o,r,l)}Tb(t,i,e,s,n,o,r,l,h,a){let f=t|0,c=i|0,u=PositionArray._s,d=PositionArray.Ua;for(this.Yt[f][c]=d;u===PositionArray._s&&f>r&&fh&&cr&&fh&&c=0;I-=2){F=L[I+2],R=L[I+3];const O=L[I],B=L[I+1];for(;O>F?F++:OR?R++:Bs)d--;else break;else if(m>n)m--;else break;const g=f[d][m];if(g===0||g===PositionArray.xN)break;c=d,u=m}for(;;){let d=e,m=c,g=u;e===0?gn&&(d=270,g--):e===90?ms&&(d=180,m--):e===180?gn&&(d=270,g--):ms&&(d=180,m--);const p=f[m][g];if(d!==e&&p!==0&&p!==PositionArray.xN){if(o.push(c),o.push(u),this.pT(c,u,d,s,n,o))return!0;o.pop(),o.pop()}if(f[c][u]=PositionArray.xN,e===0){if(c===t)return!1;c--}else if(e===90){if(u===i)return!1;u--}else if(e===180){if(c===t)return!1;c++}else{if(u===i)return!1;u++}}}}class Knot{ye;sr;cs;Wd;constructor(){GSet.vi(this),this.ye=null,this.sr=null,this.cs=[],this.Wd=!1}toString(){const t=this.cs;let i=this.ye.toString()+" "+t.length.toString()+":";for(let e=0;e180?270:90;case 6:return o>90&&o<=270?180:0}const r=Math.atan2(t.height,t.width)*180/Math.PI;switch(n){case 3:return o>r&&o<=180+r?180:270;case 5:return o>180-r&&o<=360-r?270:0;case 12:return o>r&&o<=180+r?90:0;case 10:return o>180-r&&o<=360-r?180:90;case 7:return o>90&&o<=180+r?180:o>180+r&&o<=360-r?270:0;case 13:return o>180&&o<=360-r?270:o>r&&o<=180?90:0;case 14:return o>r&&o<=180-r?90:o>180-r&&o<=270?180:0;case 11:return o>180-r&&o<=180+r?180:o>180+r?270:90}return s&&n!==15&&(o-=15,o<0&&(o+=360)),o>r&&o<180-r?90:o>=180-r&&o<=180+r?180:o>180+r&&o<360-r?270:0}Vd(){this.cs.length=0}dT(t){let i=this.cs;i.length===0&&(this.kO(),i=this.cs);for(let e=0;e=360&&(M-=360);const A=this.bO(h,y,M,g.isOrthogonal);let C=0;A===0?(C=4,M>180&&(M-=360)):A===90?(C=8,M>270&&(M-=360)):A===180?C=2:(C=1,M<90&&(M+=360));let P=this.cs[o];P===void 0?(P=new LinkInfo(g,M,C),this.cs[o]=P):(P.$e=g,P.jt=M,P.be=C),P.Fb.set(S),o++}Point.o(a),this.SO();const u=this.cs.length;let d=-1,m=0;for(o=0;o=0;o--){const g=this.cs[o];g!==void 0&&(g.be!==d&&(d=g.be,m=g.vd+1),g.Tc=m)}this.MO(this.cs),this.PO(this.cs),this.Wd=t,Rect.o(h)}return this.cs}NO(t,i){return t===i?0:t===null?-1:i===null?1:t.bei.be?1:t.jti.jt?1:0}SO(){this.cs.sort(Knot.prototype.NO)}MO(t){const i=this.sr,e=this.ye.portSpreading,s=Point.a(),n=Point.a(),o=Point.a(),r=Point.a();i.getDocumentPoint(Spot.TopLeft,s),i.getDocumentPoint(Spot.TopRight,n),i.getDocumentPoint(Spot.BottomRight,o),i.getDocumentPoint(Spot.BottomLeft,r);let l=0,h=0,a=0,f=0;if(e===2)for(let x=0;xMath.abs(p)?(d=Math.abs(p)/a,a=Math.abs(p)):d=1;break;case 2:f>Math.abs(y)?(d=Math.abs(y)/f,f=Math.abs(y)):d=1;break;case 1:l>Math.abs(p)?(d=Math.abs(p)/l,l=Math.abs(p)):d=1;break;default:case 4:h>Math.abs(y)?(d=Math.abs(y)/h,h=Math.abs(y)):d=1;break}u=0}const b=k.Hd;if(e===2){let S=k.$e.computeThickness();switch(S*=d,b.set(m),c){case 8:b.x=m.x+p/2+a/2-u-S/2;break;case 2:b.y=m.y+y/2+f/2-u-S/2;break;case 1:b.x=m.x+p/2-l/2+u+S/2;break;default:case 4:b.y=m.y+y/2-h/2+u+S/2;break}u+=S}else{let S=.5;e===1&&(S=(k.vd+1)/(k.Tc+1)),b.x=m.x+p*S,b.y=m.y+y*S}}Point.o(s),Point.o(n),Point.o(o),Point.o(r)}PO(t){for(let i=0;ie instanceof Placeholder);i instanceof Placeholder?t.Et=i:t.Et=null,this.oe!==null?(t.oe=this.oe.copy(),t.oe.group=t):(t.oe!==null&&(t.oe.group=null),t.oe=null),this.hi!==null&&(t.hi=this.hi.copy())}Ho(t){super.Ho(t);const i=t.findSubGraphParts(),e=t.memberParts;for(;e.next();){const s=e.value;if(s.u(),s.invalidateLayout(8),s.clearAdornments(),s instanceof Node)s.invalidateConnectedLinks(i);else if(s instanceof Link){const n=s.labelNodes;for(;n.next();)n.value.invalidateConnectedLinks(i)}}}ic(t,i,e,s,n,o,r){if(t===3&&i==="elements"){if(n instanceof Placeholder)this.Et===null?this.Et=n:this.Et!==n&&Util.n("Cannot insert a second Placeholder into the visual tree of a Group.");else if(n instanceof Panel){const l=n.findInVisualTree(h=>h instanceof Placeholder);l instanceof Placeholder&&(this.Et===null?this.Et=l:this.Et!==l&&Util.n("Cannot insert a second Placeholder into the visual tree of a Group."))}}else t===4&&i==="elements"&&this.Et!==null&&(s===this.Et?this.Et=null:s instanceof Panel&&this.Et.isContainedBy(s)&&(this.Et=null));super.ic(t,i,e,s,n,o,r)}ad(t,i){if(super.ad(t,i),this.isClipping&&this.type!==Panel.Spot&&this.isSubGraphExpanded){let e=this.resizeObject;e instanceof Panel&&(e=e.findMainElement()),this.hi===null&&(this.hi=new Rect),e.getDocumentBounds(this.hi),e instanceof Shape&&this.hi.inflate(-e.strokeWidth,-e.strokeWidth)}}uh(t,i,e,s){this.hasPlaceholder()&&(this.tr=this.placeholder),super.uh(t,i,e,s)}ensureBounds(){this.isSubGraphExpanded&&this.memberParts.each(i=>{i.ensureBounds()}),super.ensureBounds()}$r(){if(!super.$r())return!1;const t=this.memberParts;for(;t.next();){const i=t.value;if(i instanceof Node){if(!i.isVisible())continue;if(i.rs())return!1}else if(i instanceof Link){if(!i.isVisible())continue;if(i.rs()&&i.fromNode!==this&&i.toNode!==this)return!1}}return!0}hasPlaceholder(){return this.Et!==null&&this.Et.isVisibleObject()&&this.isSubGraphExpanded}get placeholder(){return this.Et}get computesBoundsAfterDrag(){return(this.z&2048)!==0}set computesBoundsAfterDrag(t){const i=(this.z&2048)!==0;i!==t&&(Util.t(t,"boolean",Group,"computesBoundsAfterDrag"),this.z=this.z^2048,this.i("computesBoundsAfterDrag",i,t))}get computesBoundsIncludingLinks(){return(this.z&4096)!==0}set computesBoundsIncludingLinks(t){Util.t(t,"boolean",Group,"computesBoundsIncludingLinks");const i=(this.z&4096)!==0;i!==t&&(this.z=this.z^4096,this.i("computesBoundsIncludingLinks",i,t))}get computesBoundsIncludingLocation(){return(this.z&8192)!==0}set computesBoundsIncludingLocation(t){Util.t(t,"boolean",Group,"computesBoundsIncludingLocation");const i=(this.z&8192)!==0;i!==t&&(this.z=this.z^8192,this.i("computesBoundsIncludingLocation",i,t))}get handlesDragDropForMembers(){return(this.z&16384)!==0}set handlesDragDropForMembers(t){Util.t(t,"boolean",Group,"handlesDragDropForMembers");const i=(this.z&16384)!==0;i!==t&&(this.z=this.z^16384,this.i("handlesDragDropForMembers",i,t))}get avoidableMembers(){return(this.z&131072)!==0}set avoidableMembers(t){Util.t(t,"boolean",Group,"avoidableMembers");const i=(this.z&131072)!==0;i!==t&&(this.z=this.z^131072,this.i("avoidableMembers",i,t))}get memberParts(){return this.Jd.iterator}iN(t){if(this.Jd.add(t)){t instanceof Group&&this.fa.add(t);const e=this.memberAdded;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.j,n.j=!0),e(this,t),n!==null&&(n.j=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ki(!1)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.Et;i===null&&(i=this),i.u()}tN(t){if(this.Jd.delete(t)){t instanceof Group&&this.fa.delete(t);const e=this.memberRemoved;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.j,n.j=!0),e(this,t),n!==null&&(n.j=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ki(!0)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.Et;i===null&&(i=this),i.u()}Jf(){if(this.Jd.count>0){const t=this.diagram;if(t!==null){const e=this.Jd.copy().iterator;for(;e.next();){const s=e.value;t.remove(s)}}}super.Jf()}get layout(){return this.oe}set layout(t){const i=this.oe;if(i!==t){t!==null&&(Util.s(t,Layout,Group,"layout"),t.diagram!==null&&t.diagram.layout===t&&Util.n("A layout cannot be both the Diagram.layout and a Group.layout: "+t)),i!==null&&(i.diagram=null,i.group=null),this.oe=t;const e=this.diagram;t!==null&&(t.diagram=e,t.group=this),e!==null&&(e.Wr=!0),this.i("layout",i,t),e!==null&&e.requestUpdate()}}get memberAdded(){return this.bt!==null?this.bt.xy:null}set memberAdded(t){const i=this.memberAdded;i!==t&&(t!==null&&Util.t(t,"function",Group,"memberAdded"),this.ml(),this.bt.xy=t,this.i("memberAdded",i,t))}get memberRemoved(){return this.bt!==null?this.bt.by:null}set memberRemoved(t){const i=this.memberRemoved;i!==t&&(t!==null&&Util.t(t,"function",Group,"memberRemoved"),this.ml(),this.bt.by=t,this.i("memberRemoved",i,t))}get memberValidation(){return this.bt!==null?this.bt.rh:null}set memberValidation(t){const i=this.memberValidation;i!==t&&(t!==null&&Util.t(t,"function",Group,"memberValidation"),this.ml(),this.bt.rh=t,this.i("memberValidation",i,t))}canAddMembers(t){const i=this.diagram;if(i===null)return!1;const e=i.commandHandler,n=e.c2(t).iterator;for(;n.next();){const o=n.value;if(!e.isValidMember(this,o))return!1}return!0}addMembers(t,i){const e=this.diagram;if(e===null)return!1;const s=e.commandHandler,n=s.c2(t);let o=!0;const r=n.iterator;for(;r.next();){const l=r.value;!i||s.isValidMember(this,l)?l.containingGroup=this:o=!1}return o}get ungroupable(){return(this.z&256)!==0}set ungroupable(t){const i=(this.z&256)!==0;i!==t&&(Util.t(t,"boolean",Group,"ungroupable"),this.z=this.z^256,this.i("ungroupable",i,t))}canUngroup(){if(!this.ungroupable)return!1;const t=this.layer;if(t===null||!t.allowUngroup)return!1;const i=t.diagram;return!(i!==null&&!i.allowUngroup)}invalidateConnectedLinks(t){const i=this.AO();if(super.invalidateConnectedLinks(t),i)return;this.TA(!0);const e=this.findExternalLinksConnected();for(;e.next();){const s=e.value;if(t!==void 0&&t.has(s))continue;const n=s.fromNode;if(n!==null&&n!==this&&n.isMemberOf(this)&&!n.isVisible())n.xe(s.fromPort),n.xe(s.toPort),s.invalidateRoute();else{const o=s.toNode;o!==null&&o!==this&&o.isMemberOf(this)&&!o.isVisible()&&(o.xe(s.fromPort),o.xe(s.toPort),s.invalidateRoute())}}}findExternalLinksConnected(){const t=this.diagram!==null&&this.diagram.kP;if(t&&this.b0!==null)return this.b0.iterator;const i=this.findSubGraphParts();i.add(this);const e=new GSet,s=i.iterator;for(;s.next();){const n=s.value;if(!(n instanceof Node))continue;const o=n.linksConnected;for(;o.next();){const r=o.value;i.has(r)||e.add(r)}}return t&&(this.b0=e),e.iterator}findExternalNodesConnected(){const t=this.findSubGraphParts();t.add(this);const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;if(!(s instanceof Node))continue;const n=s.linksConnected;for(;n.next();){const o=n.value,r=o.fromNode;r!==null&&(!t.has(r)||r===this)&&i.add(r);const l=o.toNode;l!==null&&(!t.has(l)||l===this)&&i.add(l)}}return i.iterator}yE(){function t(e,s){e!==null&&(s.add(e),t(e.containingGroup,s))}const i=new GSet;return t(this,i),i}findSubGraphParts(){const t=new GSet;return Part.lh(t,this,!0,0,!0),t.delete(this),t}Ki(t){super.Ki(t);const i=this.memberParts;for(;i.next();)i.value.Ki(t)}collapseSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.yT(i,t,this),t.isCollapsingExpanding=!1}yT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ki(!1),n instanceof Group&&n.isSubGraphExpanded&&(n.wasSubGraphExpanded=n.isSubGraphExpanded,n.yT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t),i.Of(n,e);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!1}expandSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.wT(i,t,this),t.isCollapsingExpanding=!1}wT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ki(!0),n instanceof Group&&n.wasSubGraphExpanded&&(n.wasSubGraphExpanded=!1,n.wT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!0}get isSubGraphExpanded(){return(this.z&512)!==0}set isSubGraphExpanded(t){const i=(this.z&512)!==0;if(i!==t){Util.t(t,"boolean",Group,"isSubGraphExpanded"),this.z=this.z^512;const e=this.diagram;this.i("isSubGraphExpanded",i,t);const s=this.subGraphExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.j,e.j=!0),s(this),e!==null&&(e.j=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.Et!==null&&this.Et.u(),this.memberParts.each(n=>n.updateAdornments());return}t?this.expandSubGraph():this.collapseSubGraph()}}get wasSubGraphExpanded(){return(this.z&1024)!==0}set wasSubGraphExpanded(t){const i=(this.z&1024)!==0;i!==t&&(Util.t(t,"boolean",Group,"wasSubGraphExpanded"),this.z=this.z^1024,this.i("wasSubGraphExpanded",i,t))}get subGraphExpandedChanged(){return this.bt!==null?this.bt.ky:null}set subGraphExpandedChanged(t){const i=this.subGraphExpandedChanged;i!==t&&(t!==null&&Util.t(t,"function",Group,"subGraphExpandedChanged"),this.ml(),this.bt.ky=t,this.i("subGraphExpandedChanged",i,t))}move(t,i){i===void 0&&(i=!1);const e=i?this.location:this.position,s=e.x,n=e.y,o=t.x,r=t.y;if((s===o||isNaN(s)&&isNaN(o))&&(n===r||isNaN(n)&&isNaN(r)))return;const l=o-(isNaN(s)?0:s),h=r-(isNaN(n)?0:n),a=Point.a();super.move(t,i);const f=new GSet,u=this.findSubGraphParts().iterator;for(;u.next();){const d=u.value;d instanceof Link&&(d.suspendsRouting&&f.add(d),!(!d.Te&&(d.fromNode===this||d.toNode===this))&&(d.suspendsRouting=!0))}for(u.reset();u.next();){const d=u.value;if(d.Dl()||d instanceof Node&&d.isLinkLabel)continue;const m=d.position,g=d.location;m.isReal()?(a.x=m.x+l,a.y=m.y+h,d.position=a):g.isReal()&&(a.x=g.x+l,a.y=g.y+h,d.location=a)}for(u.reset();u.next();){const d=u.value;if(!(d instanceof Link)||(d.suspendsRouting=f.has(d),!d.Te&&(d.fromNode===this||d.toNode===this)))continue;const m=d.position;a.x=m.x+l,a.y=m.y+h,a.isReal()?d.move(a):d.invalidateRoute()}Point.o(a)}AO(){return(this.z&65536)!==0}TA(t){(this.z&65536)!==0!==t&&(this.z=this.z^65536)}get tl(){return(this.z&32768)!==0}set tl(t){(this.z&32768)!==0!==t&&(this.z=this.z^32768)}}class Placeholder extends GraphObject{ii;Zd;constructor(t){super(),this.ii=Margin.qg,this.Zd=new Rect(NaN,NaN,NaN,NaN),t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.ii=this.ii.L(),t.Zd=this.Zd.copy()}ch(t){if(this.background===null)return!1;const i=this.naturalBounds;return Rect.contains(0,0,i.width,i.height,t.x,t.y)}ld(t,i,e,s){const n=this.part;if((n===null||!(n instanceof Group)&&!(n instanceof Adornment))&&Util.n("Placeholder is not inside a Group or Adornment."),n instanceof Group){const o=this.computeBorder(this.Zd),r=this.minSize,l=isFinite(r.width)?Math.max(r.width,o.width):o.width,h=isFinite(r.height)?Math.max(r.height,o.height):o.height,a=this.Hi;a.Kn(l||0,h||0),this.no(0,0,a.width,a.height);const f=n.memberParts;let c=!1;for(;f.next();)if(f.value.isVisible()){c=!0;break}const u=n.diagram;if(c&&u!==null&&!u.animationManager.OM(n)&&!isNaN(o.x)&&!isNaN(o.y)){const d=Point.a();d.setRectSpot(o,n.locationSpot),n.location=d,Point.o(d)}}else{const o=n,r=this.Hi,l=this.ii,h=l.left+l.right,a=l.top+l.bottom,f=o.adornedObject,c=f.getDocumentAngle();o.angle=c;let u=0;f instanceof Shape&&(u=f.strokeWidth);const d=f.getDocumentScale(),m=f.naturalBounds,g=(m.width+u)*d,p=(m.height+u)*d;if(o.type!==Panel.Link){const y=o.category==="Selection"?Spot.TopLeft:o.locationSpot,x=f.getDocumentPoint(y,Point.a());o.location=x,Point.o(x)}if(!isNaN(g)&&!isNaN(p))r.Kn(g+h||0,p+a||0),this.no(-l.left,-l.top,r.width,r.height);else{const y=f.getDocumentPoint(Spot.TopLeft,Point.a()),x=Rect.H(y.x,y.y,0,0);x.unionPoint(f.getDocumentPoint(Spot.BottomRight,y)),x.unionPoint(f.getDocumentPoint(Spot.TopRight,y)),x.unionPoint(f.getDocumentPoint(Spot.BottomLeft,y)),r.Kn(x.width+h||0,x.height+a||0),this.no(-l.left,-l.top,r.width,r.height),Point.o(y),Rect.o(x)}}}uh(t,i,e,s){this.actualBounds.e(t,i,e,s)}computeBorder(t){const i=this.part,e=i.diagram,s=e===null||!e.animationManager.isAnimating;if(e!==null&&i instanceof Group&&!i.layer.isTemporary&&i.computesBoundsAfterDrag&&this.Zd.isReal()){const l=e.toolManager.findTool("Dragging");if(l===e.currentTool){const h=l.computeBorder(i,this.Zd,t);if(h!==null)return h}}const n=Rect.a(),o=this.computeMemberBounds(n),r=this.ii;return i instanceof Group&&!i.isSubGraphExpanded?t.e(o.x-r.left,o.y-r.top,0,0):t.e(o.x-r.left,o.y-r.top,Math.max(o.width+r.left+r.right,0),Math.max(o.height+r.top+r.bottom,0)),Rect.o(n),s&&i instanceof Group&&i.computesBoundsIncludingLocation&&i.location.isReal()&&t.unionPoint(i.location),t}computeMemberBounds(t){if(!(this.part instanceof Group))return t.e(0,0,0,0),t;const i=this.part;let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=i.memberParts;for(;r.next();){const l=r.value;if(!l.isVisible()||l instanceof Link&&(!i.computesBoundsIncludingLinks||l.Xo()||l.fromNode===i||l.toNode===i))continue;const h=l.actualBounds;h.leftn&&(n=h.right),h.bottom>o&&(o=h.bottom)}if(!isFinite(e)||!isFinite(s)){const l=i.location;t.e(l.x,l.y,0,0)}else t.e(e,s,n-e,o-s);return t}get padding(){return this.ii}set padding(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Placeholder,"padding");const i=this.ii;i.equals(t)||(t=t.L(),this.ii=t,this.i("padding",i,t),this.u())}}class Layout{b;ca;$d;Cr;Qd;_d;Vo;pl;tg;ig;bo;constructor(t){GSet.vi(this),this.b=null,this.ca=null,this.$d=!0,this.Cr=!0,this.Qd=!1,this._d=new Point(0,0).w(),this.Vo=!0,this.pl=null,this.tg=null,this.ig=!1,this.bo=null,t&&Object.assign(this,t)}cloneProtected(t){t.$d=this.$d,t.Cr=this.Cr,t.Qd=this.Qd,t._d.c(this._d),t.Vo=this.Vo,t.pl=this.pl,t.tg=this.tg,t.ig=!0}copy(){const t=new this.constructor;return this.cloneProtected(t),t}fi(t){Util.ur(this,t)}toString(){let t=Util.hn(this.constructor);return t+="(",this.group!==null&&(t+=" in "+this.group),this.diagram!==null&&(t+=" for "+this.diagram),t+=")",t}get diagram(){return this.b}set diagram(t){t!==null&&Util.s(t,Diagram,Layout,"diagram"),this.b=t}get group(){return this.ca}set group(t){this.ca!==t&&(t!==null&&Util.s(t,Group,Layout,"group"),this.ca=t,t!==null&&(this.b=t.diagram))}get isOngoing(){return this.$d}set isOngoing(t){this.$d!==t&&(Util.t(t,"boolean",Layout,"isOngoing"),this.$d=t)}get isInitial(){return this.Cr}set isInitial(t){Util.t(t,"boolean",Layout,"isInitial"),this.Cr=t,t||(this.ig=!0)}get isViewportSized(){return this.Qd}set isViewportSized(t){this.Qd!==t&&(Util.t(t,"boolean",Layout,"isViewportSized"),this.Qd=t,t&&this.invalidateLayout())}get isRouting(){return this.Vo}set isRouting(t){this.Vo!==t&&(Util.t(t,"boolean",Layout,"isRouting"),this.Vo=t)}get isRealtime(){return this.pl}set isRealtime(t){this.pl!==t&&(t!==null&&Util.t(t,"boolean",Layout,"isRealtime"),this.pl=t)}get isValidLayout(){return this.ig}set isValidLayout(t){if(this.ig!==t&&(Util.t(t,"boolean",Layout,"isValidLayout"),this.ig=t,!t)){const i=this.diagram;i!==null&&(i.Wr=!0)}}invalidateLayout(){if(this.isValidLayout){const t=this.diagram;if(t===null||t.undoManager.isUndoingRedoing)return;const i=t.animationManager;if(i.isTicking)return;i.defaultAnimation.isAnimating&&i.stopAnimation(),(this.isOngoing&&t.Yh||this.isInitial&&!t.Yh)&&(this.isValidLayout=!1,t.requestUpdate())}}get network(){return this.bo}set network(t){this.bo!==t&&(t!==null&&Util.s(t,LayoutNetwork,Layout,"network"),this.bo=t,t!==null&&(t.layout=this))}createNetwork(){return new LayoutNetwork(this)}makeNetwork(t){const i=this.createNetwork();return t instanceof Diagram?(i.addParts(t.nodes,!0),i.addParts(t.links,!0)):t instanceof Group?i.addParts(t.memberParts):i.addParts(t.iterator),i}updateParts(){this.isValidLayout=!0;let t=this.diagram;if(t===null&&this.network!==null){const i=this.network.vertexes.iterator;for(;i.next();){const s=i.value.node;if(s!==null&&(t=s.diagram,t!==null))break}}try{t!==null&&t.startTransaction("Layout"),this.commitLayout()}finally{t!==null&&t.commitTransaction("Layout")}}commitLayout(){if(this.network===null)return;const t=this.network.vertexes.iterator;for(;t.next();)t.value.commit();if(this.isRouting){const i=this.network.edges.iterator;for(;i.next();)i.value.commit()}}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts");const i=new GSet;if(t instanceof Diagram?(this.Ph(i,t.nodes,!0,this.tl,!0,!1,!0),this.Ph(i,t.parts,!0,this.tl,!0,!1,!0)):t instanceof Group?this.Ph(i,t.memberParts,!1,this.tl,!0,!1,!0):i.addAll(t.iterator),i.count>0){const s=this.diagram;s!==null&&s.startTransaction("Layout"),this.doMinimalNoNetworkLayout(i),s!==null&&s.commitTransaction("Layout")}this.isValidLayout=!0}doMinimalNoNetworkLayout(t){const i=t.count,e=Math.ceil(Math.sqrt(i));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const s=this.arrangementOrigin.x,n=this.arrangementOrigin.y;let o=s,r=n,l=0,h=0;const a=t.iterator;for(;a.next();){const f=a.value;f.ensureBounds();const c=f.measuredBounds,u=c.width,d=c.height;f.moveTo(o,r),f instanceof Group&&(f.tl=!1),o+=Math.max(u,50)+20,h=Math.max(h,Math.max(d,50)),l>=e-1?(l=0,o=s,r+=h+20,h=0):l++}}doMinimalNetworkLayout(){const t=this.network.vertexes.count,i=Math.ceil(Math.sqrt(t));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const e=this.arrangementOrigin.x,s=this.arrangementOrigin.y;let n=e,o=s,r=0,l=0;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value.node;if(a===null||a instanceof Link||(a.ensureBounds(),!this.tl(a)))continue;const f=a.measuredBounds,c=f.width,u=f.height;a.moveTo(n,o),a instanceof Group&&(a.tl=!1),n+=Math.max(c,50)+20,l=Math.max(l,Math.max(u,50)),r>=i-1?(r=0,n=e,o+=l+20,l=0):r++}}tl(t){return!!(!t.location.isReal()&&!t.position.isReal()||t instanceof Group&&t.tl)}Ph(t,i,e,s,n,o,r){const l=i.iterator;for(;l.next();){const h=l.value;if(!(e&&!h.isTopLevel)&&!(s!==null&&!s(h))&&h.canLayout())if(n&&h instanceof Node){if(h.isLinkLabel)continue;h instanceof Group&&h.layout===null?this.Ph(t,h.memberParts,!1,s,n,o,r):(h.ensureBounds(),t.add(h))}else o&&h instanceof Link?t.add(h):r&&h.Ae()&&!(h instanceof Node)&&(h.ensureBounds(),t.add(h))}}getLayoutBounds(t,i){const e=this.boundsComputation;return e!==null?(i||(i=new Rect),e(t,this,i)):!i&&t.margin.equalTo(0,0,0,0)?t.actualBounds:(i||(i=new Rect),i.set(t.actualBounds),i.addMargin(t.margin),i)}get boundsComputation(){return this.tg}set boundsComputation(t){this.tg!==t&&(t!==null&&Util.t(t,"function",Layout,"boundsComputation"),this.tg=t,this.invalidateLayout())}collectParts(t){const i=new GSet;return t instanceof Diagram?(this.Ph(i,t.nodes,!0,null,!0,!0,!0),this.Ph(i,t.links,!0,null,!0,!0,!0),this.Ph(i,t.parts,!0,null,!0,!0,!0)):t instanceof Group?this.Ph(i,t.memberParts,!1,null,!0,!0,!0):this.Ph(i,t.iterator,!1,null,!0,!0,!0),i}get arrangementOrigin(){return this._d}set arrangementOrigin(t){Util.s(t,Point,Layout,"arrangementOrigin"),this._d.equals(t)||(this._d.c(t),this.invalidateLayout())}initialOrigin(t){const i=this.group;if(i!==null)if(i.hasPlaceholder()){const e=i.placeholder,s=e.getDocumentPoint(Spot.TopLeft);(isNaN(s.x)||isNaN(s.y))&&s.set(t);const n=e.padding;return s.x+=n.left,s.y+=n.top,s}else{const e=i.position.copy();return(isNaN(e.x)||isNaN(e.y))&&e.set(t),e}return t}}class LayoutNetwork{oe;ko;Fn;Ay;Ly;constructor(t){GSet.vi(this),Debug&&!t&&Util.n("LayoutNetwork constructor requires non-null Layout argument"),this.oe=t,this.ko=new GSet,this.Fn=new GSet,this.Ay=new GMap,this.Ly=new GMap}clear(){if(this.ko){const t=this.ko.iterator;for(;t.next();)t.value.clear()}if(this.Fn){const t=this.Fn.iterator;for(;t.next();)t.value.clear()}this.ko=new GSet,this.Fn=new GSet,this.Ay=new GMap,this.Ly=new GMap}toString(t){t===void 0&&(t=0);let i="LayoutNetwork"+(this.layout!==null?"("+this.layout.toString()+")":"");if(t<=0)return i;if(i+=" vertexes: "+this.ko.count+" edges: "+this.Fn.count,t>1){const e=this.ko.iterator;for(;e.next();){const n=e.value;i+=` +`);if(t.length===0)return 8;if(this.isMultiline){let i=0,e=0,s=!1;for(;!s;){let n=this.ub(t,e);n===-1&&(n=t.length,s=!0);let o=t.substring(e,n);this.formatting===0&&(o=o.trim()),i=Math.max(i,this.getStringWidth(o)),e=n+1}return i}else{const i=this.ub(t,0);return i>=0&&(t=t.substring(0,i)),this.getStringWidth(t)}}get textValidation(){return this.$!==null?this.$.Il:null}set textValidation(t){const i=this.textValidation;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"textValidation"),this.Tn(),this.$.Il=t,this.i("textValidation",i,t))}get textEdited(){return this.$!==null?this.$.Vp:null}set textEdited(t){const i=this.textEdited;i!==t&&(t!==null&&Util.t(t,"function",TextBlock,"textEdited"),this.Tn(),this.$.Vp=t,this.i("textEdited",i,t))}get spacingAbove(){return this.$!==null?this.$.zp:0}set spacingAbove(t){const i=this.spacingAbove;i!==t&&(Debug&&Util.t(t,"number",TextBlock,"spacingAbove"),this.Tn(),this.$.zp=t,this.u(),this.i("spacingAbove",i,t))}get spacingBelow(){return this.$!==null?this.$.Xp:0}set spacingBelow(t){const i=this.spacingBelow;i!==t&&(Debug&&Util.t(t,"number",TextBlock,"spacingBelow"),this.Tn(),this.$.Xp=t,this.u(),this.i("spacingBelow",i,t))}get formatting(){return this.$!==null?this.$.Yp:0}set formatting(t){const i=this.formatting;i!==t&&(Util.tt(t,TextFormat,"formatting"),this.Tn(),this.$.Yp=t,this.u(),this.i("formatting",i,t))}get maxLines(){return this.$!==null?this.$.Kp:1/0}set maxLines(t){const i=this.maxLines;i!==t&&(Debug&&Util.t(t,"number",TextBlock,"maxLines"),t=Math.floor(t),t<=0&&Util.G(t,"> 0",TextBlock,"maxLines"),this.Tn(),this.$.Kp=t,this.u(),this.i("maxLines",i,t))}getMetrics(){return[this.xi,this.Ol,this.co,this.An,this.Re,this.Oi,this.Ln]}DI(t){t!==void 0&&(this.xi=t[0],this.Ol=t[1],this.co=t[2],this.An=t[3],this.Re=t[4],this.Oi=t[5],this.Ln=t[6])}get metrics(){return{arrSize:this.Re!==null?this.Re:[this.xi],arrText:this.Oi!==null?this.Oi:[this.Ln],maxLineWidth:this.xi,fontHeight:this.co}}get choices(){return this.Dd}set choices(t){const i=this.Dd;i!==t&&(Debug&&t!==null&&!Array.isArray(t)&&Util.Bi(t,"Array",TextBlock,"choices:value"),this.Dd=t,this.i("choices",i,t))}static EI=new RegExp("[ \u200B\xAD]");static W2=new PropertyCollection;static HL=0;static ab=new PropertyCollection;static H2=0;static Dp="...";static UL="";static rl=Diagram.isUsingDOM()?new CanvasSurface(null).di:null}class TextBlockTemplateSettings{wi;fs;uo;Yp;Kp;Ip;zp;Xp;Fp;Vp;Ep;Il;hl;Rp;constructor(){this.wi=!1,this.fs=null,this.uo=0,this.Yp=0,this.Kp=1/0,this.Ip=0,this.zp=0,this.Xp=0,this.Fp="start",this.Vp=null,this.Ep=null,this.Il=null,this.hl=Spot.Top,this.Rp=2}copy(){const t=new TextBlockTemplateSettings;return t.fs=this.fs,t.uo=this.uo,t.Yp=this.Yp,t.Kp=this.Kp,t.Ip=this.Ip,t.zp=this.zp,t.Xp=this.Xp,t.Fp=this.Fp,t.Vp=this.Vp,t.Ep=this.Ep,t.Il=this.Il,t.hl=this.hl,t.Rp=this.Rp,t}}class GradElementSettings{wc;xc;bc;Bp;kc;constructor(){this.wc=1,this.xc=0,this.bc=1,this.Bp=null,this.kc=null}copy(){const t=new GradElementSettings;return t.wc=this.wc,t.xc=this.xc,t.bc=this.bc,t.Bp=this.Bp,t.kc=this.kc,t}}var ImageStretch=(w=>(w[w.None=0]="None",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ImageStretch||{});class Picture extends GraphObject{al;St;fl;Sc;fs;cl;Mc;uo;Pc;Nc;W1;constructor(t,i){super(),this.l|=2097152,this.al=null,this.St="",this.fl=Rect.BD,this.Sc=2,this.fs=null,this.cl=null,this.Mc=Spot.Center,this.uo=0,this.Pc=null,this.Nc=null,this.W1=null,typeof t=="string"?this.source=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.St=this.St,t.element=this.al,t.fl=this.fl.L(),t.Sc=this.Sc,t.uo=this.uo,t.fs=this.fs,t.cl=this.cl,t.Mc=this.Mc.L(),t.Nc=this.Nc}fi(t){t in ImageStretch?this.imageStretch=t:super.fi(t)}toString(){return"Picture("+this.source+")#"+GSet.gs(this)}get Cc(){return(this.l&1048576)!==0}set Cc(t){this.Cc!==t&&(this.l=this.l^1048576)}get Oa(){return(this.l&2097152)!==0}set Oa(t){this.Oa!==t&&(this.l=this.l^2097152)}get bn(){return(this.l&4194304)!==0}set bn(t){this.bn!==t&&(this.l=this.l^4194304)}static clearCache(t){t===void 0&&(t=""),Util.t(t,"string",Picture,"clearCache:url"),t!==""?Picture.Up[t]&&(delete Picture.Up[t],Picture.db--):(Picture.Up=new PropertyCollection,Picture.db=0)}static KA(t,i){i.qL||(i.gb=e=>{Picture.BI(i,e),t.desiredSize.isReal()||(t.ye(!1),t.u())},i.mb=e=>Picture.VI(i,e),i.addEventListener("load",i.gb),i.addEventListener("error",i.mb),i.qL=!0)}static MR(t){t.gb&&t.removeEventListener("load",t.gb),t.mb&&t.removeEventListener("error",t.mb),delete t.gb,delete t.mb,delete t.qL}get element(){return this.al}set element(t){const i=this.al;if(this.hs(!0),i!==t){this.Cc=t instanceof HTMLCanvasElement;const e=t instanceof HTMLImageElement;t!==null&&!(e||t instanceof HTMLVideoElement||this.Cc)&&Util.n("Picture.element must be an instance of Image, Canvas, or Video, not: "+t);const s=this.diagram;s!==null&&s.zP(this),this.al=t,t!==null&&e&&t.ls===void 0&&(t.ls=new GSet),s!==null&&e&&s.VP(this),this.i("element",i,t),this.T()}}kR(){const t=this.al;if(t===null)return;const i=this.desiredSize.isReal();(this.Cc||t.complete===!0)&&(t.y0&&(t.Gp instanceof Event&&this.fs!==null?this.fs(this,t.Gp):t.bn===!0&&!t.Gp&&this.cl!==null&&t.v2&&this.cl(this,t.v2)),t.bn=!0),t.bn&&i&&this.diagram!==null&&this.diagram.Wu.add(this)}zI(){if(this.al===null){this.Pc=!1;return}const t=new CanvasSurface(null).di;try{t.drawImage(this.al,0,0)}catch(i){Debug&&this.Oa&&Util.ht(i.toString()),this.Oa=!1}try{t.getImageData(0,0,1,1).data[3]&&(this.Pc=!1),this.Pc=!1}catch{this.Pc=!0}}get source(){return this.St}set source(t){const i=this.St;if(i!==t){this.hs(!0),Util.t(t,"string",Picture,"source"),this.St=t;let e=Picture.Up;if(!Diagram.isUsingDOM()){this.i("source",i,t);return}let s=null;if(e[t]!==void 0)s=e[t];else if(t!==""){Picture.db>30&&(Picture.clearCache(),e=Picture.Up),s=Util.ln("img"),s.y0=!0,Picture.KA(this,s);const n=this.Nc;n!==null&&(s.crossOrigin=n(this)),s.src=t,e[t]=s,Picture.db++}this.element=s,s!==null&&s.__goCache===void 0&&(s.__goCache=new PictureCacheArray),this.u(),this.T(),this.i("source",i,t)}}static BI(t,i){t.bn=!0,t.Gp=!1;let e;const s=t.ls.copy();if(s==null)return;const n=s.iterator;for(;n.next();){const o=n.value;o.T();const r=t.getAttribute("src")||"",l=o._l.get(r);if(l===null)continue;const h=l.length;for(let a=0;a=o.width&&(r=r+p.offsetX+(d*p.x-o.width*p.x)),m>=o.height&&(l=l+p.offsetY+(m*p.y-o.height*p.y)),a=Math.min(o.width,d),f=Math.min(o.height,m);break;case 2:d=o.width,m=o.height;break;case 6:case 7:let L=0;g===6?(L=Math.min(o.height/m,o.width/d),d*=L,m*=L):g===7&&(L=Math.max(o.height/m,o.width/d),d*=L,m*=L,d>=o.width&&(r=(r+p.offsetX+(d*p.x-o.width*p.x)/d)*a),m>=o.height&&(l=(l+p.offsetY+(m*p.y-o.height*p.y)/m)*f),a*=1/(d/o.width),f*=1/(m/o.height),d=o.width,m=o.height);break}const y=a*f,x=this.getDocumentScale()*i.scale,k=d*x,b=m*x,S=k*b,M=y/S,A=e.__goCache;let C=null;const P=Picture.XI;if(!n){if(e.bn&&A!==void 0&&S>4&&M>P*P){A.Yt===null&&(A.jL(4,c,u,e),A.jL(16,c,u,e));const L=A.Yt,D=L.length;for(let F=0;F0){const f=this.Yt[this.Yt.length-1];h=f.St,a=f.Rd}o.setTransform(r*a,0,0,r*a,0,0),o.commitTransform(),o.drawImage(h,0,0),this.Yt.push(l)}}class PictureCacheInstance{St;Rd;constructor(t,i){this.St=t,this.Rd=i}}class GeoStream{Ci;tm;constructor(){this.tm=new Geometry,this.Ci=null}Vi(t){t!==null?(t.ft(),this.tm=t,t.figures.clear()):this.tm=new Geometry,this.Ci=null}yu(t,i,e,s,n,o){if(s!==void 0&&s===!0){const r=new PathSegment(1);r.endX=t,r.endY=i,this.Ci.segments.add(r)}else this.Ci=new PathFigure,this.Ci.startX=t,this.Ci.startY=i,this.Ci.isFilled=e,this.Ci.isEvenOdd=o||!1,this.tm.figures.add(this.Ci);n!==void 0&&(this.Ci.isShadowed=n)}jD(){const t=this.Ci.segments.length;t>0&&this.Ci.segments.elt(t-1).close()}WD(){this.Ci.segments.length>0&&(this.Ci.isFilled=!0)}vD(t){this.Ci.isShadowed=t}mE(t){this.Ci.isEvenOdd=t}GD(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(1);s.endX=t,s.endY=i,e&&s.close(),this.Ci.segments.add(s)}yr(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(2);s.endX=t,s.endY=i,e&&s.close(),this.Ci.segments.add(s)}wr(t,i,e,s,n,o,r){r===void 0&&(r=!1);const l=new PathSegment(3);l.point1X=t,l.point1Y=i,l.point2X=e,l.point2Y=s,l.endX=n,l.endY=o,r&&l.close(),this.Ci.segments.add(l)}Fw(t,i,e,s,n){n===void 0&&(n=!1);const o=new PathSegment(4);o.point1X=t,o.point1Y=i,o.endX=e,o.endY=s,n&&o.close(),this.Ci.segments.add(o)}HD(t,i,e,s,n,o,r){o===void 0&&(o=0),r===void 0&&(r=!1);const l=new PathSegment(5);l.startAngle=t,l.sweepAngle=i,l.centerX=e,l.centerY=s,l.radiusX=n,o!==0?l.radiusY=o:l.radiusY=n,r&&l.close(),this.Ci.segments.add(l)}qD(t,i,e,s,n,o,r,l){l===void 0&&(l=!1);const h=new PathSegment(6,o,r,t,i,e,s,n);l&&h.close(),this.Ci.segments.add(h)}static J2=null;static SC(t){const i=GeoStream.J2;if(i!==null)return GeoStream.J2=null,i.Vi(t),i;{const e=new GeoStream;return e.Vi(t),e}}static MC(t){GeoStream.J2=t}}{const w=function(n,o){const r=n.toLowerCase(),l=Geo.qn;l[n]=o,l[r]=n};w("Rectangle",(n,o,r)=>{const l="r"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,Geo.pr{const l="s"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,h.defaultStretch=6,Geo.pr{(isNaN(l)||l<0)&&(l=5),isNaN(h)&&(h=15);const a="rr"+o+","+r+","+l+","+h;let f=Geo.mr[a];if(f!==void 0)return f;let c=l;(h&1)===1?(c=Math.min(c,(h&2)===2?o/3:o),c=Math.min(c,(h&8)===8?r/3:r)):c=0;const u=new PathFigure(c,0,!0);f=new Geometry().add(u);const d=Spot.TopLeft.copy(),m=Spot.BottomRight.copy();if((h&2)===2){let g=l;g=Math.min(g,(h&1)===1?o/3:o),g=Math.min(g,(h&4)===4?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,o-g,0)).add(new PathSegment(3,o,g,o-p,0,o,p)),d.offsetY=p,m.offsetX=-p}else u.add(new PathSegment(2,o,0));if((h&4)===4){let g=l;g=Math.min(g,(h&8)===8?o/3:o),g=Math.min(g,(h&2)===2?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,o,r-g)).add(new PathSegment(3,o-g,r,o,r-p,o-p,r)),m.offsetX=-p,m.offsetY=-p}else u.add(new PathSegment(2,o,r));if((h&8)===8){let g=l;g=Math.min(g,(h&4)===4?o/3:o),g=Math.min(g,(h&1)===1?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,g,r)).add(new PathSegment(3,0,r-g,p,r,0,r-p)),d.offsetX=p,m.offsetY=-p}else u.add(new PathSegment(2,0,r));if((h&1)===1){const g=c*Geo.Un;u.add(new PathSegment(2,0,c)).add(new PathSegment(3,c,0,0,g,g,0).close()),d.offsetX=g,d.offsetY=g}else u.add(new PathSegment(2,0,0).close());return f.spot1=d,f.spot2=m,Geo.pr{const l=n?n.parameter1:NaN,h=n?n.parameter2:NaN;return t(n,o,r,l,h)}),w("Border","RoundedRectangle"),w("RoundedTopRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,3)}),w("RoundedBottomRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,12)}),w("RoundedLeftRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,9)}),w("RoundedRightRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,6)}),w("Ellipse",(n,o,r)=>{const l="e"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Kk,h.spot2=Spot.Uk,Geo.pr{const l="c"+o+","+r;let h=Geo.mr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Kk,h.spot2=Spot.Uk,h.defaultStretch=6,Geo.prnew Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,.5*r)).add(new PathSegment(2,0,r).close())).setSpots(0,.25,.5,.75)),w("TriangleDown",(n,o,r)=>new Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,0)).add(new PathSegment(2,.5*o,r).close())).setSpots(.25,0,.75,.5)),w("TriangleLeft",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,o,0).close())).setSpots(.5,.25,1,.75)),w("TriangleUp",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,r)).add(new PathSegment(2,.5*o,0).close())).setSpots(.25,.5,.75,1)),w("Triangle","TriangleUp"),w("Diamond",(n,o,r)=>new Geometry().add(new PathFigure(.5*o,0).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,.5*o,r)).add(new PathSegment(2,o,.5*r).close())).setSpots(.25,.25,.75,.75)),w("LineH",(n,o,r)=>{const l=new Geometry(1);return l.startX=0,l.startY=r/2,l.endX=o,l.endY=r/2,l}),w("LineV",(n,o,r)=>{const l=new Geometry(1);return l.startX=o/2,l.startY=0,l.endX=o/2,l.endY=r,l}),w("None","Rectangle"),w("BarH","Rectangle"),w("BarV","Rectangle"),w("MinusLine","LineH"),w("PlusLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r/2,!1).add(new PathSegment(2,o,r/2)).add(new PathSegment(1,o/2,0)).add(new PathSegment(2,o/2,r)))),w("XLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r,!1).add(new PathSegment(2,o,0)).add(new PathSegment(1,0,0)).add(new PathSegment(2,o,r)))),w("LineRight",(n,o,r)=>new Geometry().add(new PathFigure(.25*o,0,!1).add(new PathSegment(2,.75*o,.5*r)).add(new PathSegment(2,.25*o,r)))),w("LineDown",(n,o,r)=>new Geometry().add(new PathFigure(0,.25*r,!1).add(new PathSegment(2,.5*o,.75*r)).add(new PathSegment(2,o,.25*r)))),w("LineLeft",(n,o,r)=>new Geometry().add(new PathFigure(.75*o,0,!1).add(new PathSegment(2,.25*o,.5*r)).add(new PathSegment(2,.75*o,r)))),w("LineUp",(n,o,r)=>new Geometry().add(new PathFigure(0,.75*r,!1).add(new PathSegment(2,.5*o,.25*r)).add(new PathSegment(2,o,.75*r)))),w("Capsule",(n,o,r)=>{const l=new Geometry;if(or){const h=r/2,a=new PathFigure(h,0,!0);l.add(a),a.add(new PathSegment(2,o-h,0)),a.add(new PathSegment(5,270,180,o-h,h,h,h)),a.add(new PathSegment(2,h,r)),a.add(new PathSegment(5,90,180,h,h,h,h));const f=isFinite(n.parameter1)?n.parameter1:r*.156;return l.spot1=new Spot(0,0,f,0),l.spot2=new Spot(1,1,-f,0),l}else return l.type=3,l.endX=o,l.endY=r,l.spot1=Spot.Kk,l.spot2=Spot.Uk,l});const i=(n,o)=>new PathFigure(n,o,!1,!1),e=(n,o,r)=>n.add(new PathSegment(2,o,r)),s=(n,o,r)=>n.add(new PathSegment(1,o,r));w("Borders",(n,o,r)=>{let l=n?n.parameter1:NaN;isNaN(l)?l=10:l=l&15;const h=new Geometry;let a;return l===10?(a=i(o,0),e(a,o,r),s(a,0,r),e(a,0,0)):l===5?(a=i(0,0),e(a,o,0),s(a,o,r),e(a,0,r)):l===1?(a=i(0,0),e(a,o,0),s(a,o,r)):l===2?(a=i(o,0),e(a,o,r)):l===4?(a=i(o,r),e(a,0,r)):l===8?(a=i(0,r),e(a,0,0),s(a,o,r)):l===3?(a=i(0,0),e(a,o,0),e(a,o,r)):l===6?(a=i(o,0),e(a,o,r),e(a,0,r)):l===12?(a=i(o,r),e(a,0,r),e(a,0,0)):l===9?(a=i(0,r),e(a,0,0),e(a,o,0)):l===7?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r)):l===14?(a=i(o,0),e(a,o,r),e(a,0,r),e(a,0,0)):l===13?(a=i(o,r),e(a,0,r),e(a,0,0),e(a,o,0)):l===11?(a=i(0,r),e(a,0,0),e(a,o,0),e(a,o,r)):l===15?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r),a.add(new PathSegment(2,0,0).close())):(a=i(0,0),s(a,o,r)),h.add(a),h})}Geo.Jg={"":"",Standard:"F1 m 0,0 l 8,4 -8,4 2,-4 z",Backward:"F1 m 8,0 l -2,4 2,4 -8,-4 z",Triangle:"F1 m 0,0 l 8,4.62 -8,4.62 z",BackwardTriangle:"F1 m 8,4 l 0,4 -8,-4 8,-4 0,4 z",Boomerang:"F1 m 0,0 l 8,4 -8,4 4,-4 -4,-4 z",BackwardBoomerang:"F1 m 8,0 l -8,4 8,4 -4,-4 4,-4 z",SidewaysV:"m 0,0 l 8,4 -8,4 0,-1 6,-3 -6,-3 0,-1 z",BackwardV:"m 8,0 l -8,4 8,4 0,-1 -6,-3 6,-3 0,-1 z",OpenTriangle:"m 0,0 l 8,4 -8,4",BackwardOpenTriangle:"m 8,0 l -8,4 8,4",OpenTriangleLine:"m 0,0 l 8,4 -8,4 m 8.5,0 l 0,-8",BackwardOpenTriangleLine:"m 8,0 l -8,4 8,4 m -8.5,0 l 0,-8",OpenTriangleTop:"m 0,0 l 8,4 m 0,4",BackwardOpenTriangleTop:"m 8,0 l -8,4 m 0,4",OpenTriangleBottom:"m 0,8 l 8,-4",BackwardOpenTriangleBottom:"m 0,4 l 8,4",HalfTriangleTop:"F1 m 0,0 l 0,4 8,0 z m 0,8",BackwardHalfTriangleTop:"F1 m 8,0 l 0,4 -8,0 z m 0,8",HalfTriangleBottom:"F1 m 0,4 l 0,4 8,-4 z",BackwardHalfTriangleBottom:"F1 m 8,4 l 0,4 -8,-4 z",ForwardSemiCircle:"m 4,0 b 270 180 0 4 4",BackwardSemiCircle:"m 4,8 b 90 180 0 -4 4",Feather:"m 0,0 l 3,4 -3,4",BackwardFeather:"m 3,0 l -3,4 3,4",DoubleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardDoubleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4",TripleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardTripleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4 m 3,-8 l -3,4 3,4",ForwardSlash:"m 0,8 l 5,-8",BackSlash:"m 0,0 l 5,8",DoubleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8",DoubleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8",TripleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8 m -2,8 l 4,-8",TripleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8 m -2,-8 l 4,8",Fork:"m 0,4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4",LineFork:"m 0,0 l 0,8 m 0,-4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardLineFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4 m 8,-8 l 0,8",CircleFork:"F1 m 6,4 b 0 360 -3 0 3 z m 0,0 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 6,0 b 0 360 -3 0 3",CircleLineFork:"F1 m 6,4 b 0 360 -3 0 3 z m 1,-4 l 0,8 m 0,-4 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleLineFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 0,-4 l 0,8 m 7,-4 b 0 360 -3 0 3",Circle:"F1 m 8,4 b 0 360 -4 0 4 z",Block:"F1 m 0,0 l 0,8 8,0 0,-8 z",StretchedDiamond:"F1 m 0,3 l 5,-3 5,3 -5,3 -5,-3 z",Diamond:"F1 m 0,4 l 4,-4 4,4 -4,4 -4,-4 z",Chevron:"F1 m 0,0 l 5,0 3,4 -3,4 -5,0 3,-4 -3,-4 z",StretchedChevron:"F1 m 0,0 l 8,0 3,4 -3,4 -8,0 3,-4 -3,-4 z",NormalArrow:"F1 m 0,2 l 4,0 0,-2 4,4 -4,4 0,-2 -4,0 z",X:"m 0,0 l 8,8 m 0,-8 l -8,8",TailedNormalArrow:"F1 m 0,0 l 2,0 1,2 3,0 0,-2 2,4 -2,4 0,-2 -3,0 -1,2 -2,0 1,-4 -1,-4 z",DoubleTriangle:"F1 m 0,0 l 4,4 -4,4 0,-8 z m 4,0 l 4,4 -4,4 0,-8 z",BigEndArrow:"F1 m 0,0 l 5,2 0,-2 3,4 -3,4 0,-2 -5,2 0,-8 z",ConcaveTailArrow:"F1 m 0,2 h 4 v -2 l 4,4 -4,4 v -2 h -4 l 2,-2 -2,-2 z",RoundedTriangle:"F1 m 0,1 a 1,1 0 0 1 1,-1 l 7,3 a 0.5,1 0 0 1 0,2 l -7,3 a 1,1 0 0 1 -1,-1 l 0,-6 z",SimpleArrow:"F1 m 1,2 l -1,-2 2,0 1,2 -1,2 -2,0 1,-2 5,0 0,-2 2,2 -2,2 0,-2 z",AccelerationArrow:"F1 m 0,0 l 0,8 0.2,0 0,-8 -0.2,0 z m 2,0 l 0,8 1,0 0,-8 -1,0 z m 3,0 l 2,0 2,4 -2,4 -2,0 0,-8 z",BoxArrow:"F1 m 0,0 l 4,0 0,2 2,0 0,-2 2,4 -2,4 0,-2 -2,0 0,2 -4,0 0,-8 z",TriangleLine:"F1 m 8,4 l -8,-4 0,8 8,-4 z m 0.5,4 l 0,-8",CircleEndedArrow:"F1 m 10,4 l -2,-3 0,2 -2,0 0,2 2,0 0,2 2,-3 z m -4,0 b 0 360 -3 0 3 z",DynamicWidthArrow:"F1 m 0,3 l 2,0 2,-1 2,-2 2,4 -2,4 -2,-2 -2,-1 -2,0 0,-2 z",EquilibriumArrow:"m 0,3 l 8,0 -3,-3 m 3,5 l -8,0 3,3",FastForward:"F1 m 0,0 l 3.5,4 0,-4 3.5,4 0,-4 1,0 0,8 -1,0 0,-4 -3.5,4 0,-4 -3.5,4 0,-8 z",Kite:"F1 m 0,4 l 2,-4 6,4 -6,4 -2,-4 z",HalfArrowTop:"F1 m 0,0 l 4,4 4,0 -8,-4 z m 0,8",HalfArrowBottom:"F1 m 0,8 l 4,-4 4,0 -8,4 z",OpposingDirectionDoubleArrow:"F1 m 0,4 l 2,-4 0,2 4,0 0,-2 2,4 -2,4 0,-2 -4,0 0,2 -2,-4 z",PartialDoubleTriangle:"F1 m 0,0 4,3 0,-3 4,4 -4,4 0,-3 -4,3 0,-8 z",LineCircle:"F1 m 0,0 l 0,8 m 7 -4 b 0 360 -3 0 3 z",DoubleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",TripleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",CircleLine:"F1 m 6 4 b 0 360 -3 0 3 z m 1,-4 l 0,8",DiamondCircle:"F1 m 8,4 l -4,4 -4,-4 4,-4 4,4 m 8,0 b 0 360 -4 0 4 z",PlusCircle:"F1 m 8,4 b 0 360 -4 0 4 l -8 0 z m -4 -4 l 0 8",OpenRightTriangleTop:"m 8,0 l 0,4 -8,0 m 0,4",OpenRightTriangleBottom:"m 8,8 l 0,-4 -8,0",Line:"m 0,0 l 0,8",DoubleLine:"m 0,0 l 0,8 m 2,0 l 0,-8",TripleLine:"m 0,0 l 0,8 m 2,0 l 0,-8 m 2,0 l 0,8",PentagonArrow:"F1 m 8,4 l -4,-4 -4,0 0,8 4,0 4,-4 z"};var LayoutConditions=(w=>(w[w.None=0]="None",w[w.Added=1]="Added",w[w.Removed=2]="Removed",w[w.Shown=4]="Shown",w[w.Hidden=8]="Hidden",w[w.NodeSized=16]="NodeSized",w[w.GroupLayout=32]="GroupLayout",w[w.NodeReplaced=64]="NodeReplaced",w[w.Standard=127]="Standard",w[w.All=16777215]="All",w))(LayoutConditions||{});class Part extends Panel{N;$o;E;ul;dl;Qo;ui;_o;bh;Zs;tr;Id;qM;WL;Hp;qp;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.N=2408959,this.$o="",this.E=null,this.ul="",this.dl=null,this.Qo=null,this.ui="",this._o=null,this.bh=null,this.Zs=new Point(NaN,NaN).w(),this.tr=null,this.Id=NaN,this.qM=-1,this.WL=new Rect,this.Hp=null,this.qp=NaN,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.N=this.N&-4097|16384|32768,t.$o=this.$o,this.E!==null&&(this.E.wi?t.E=this.E:t.E=this.E.copy()),t.ul=this.ul,t.Qo=null,t.ui=this.ui,t.Zs.c(this.Zs),t.Id=this.Id}Ho(t){super.Ho(t),t.gh(),t.dl=null,t.tr=null,t.Hp=null}toString(){let t=Util.hn(this.constructor)+"#"+GSet.gs(this);return this.data!==null&&(t+="("+Util.toString(this.data)+")"),t}static LayoutNone=0;static LayoutAdded=1;static LayoutRemoved=2;static LayoutShown=4;static LayoutHidden=8;static LayoutNodeSized=16;static LayoutGroupLayout=32;static LayoutNodeReplaced=64;static LayoutStandard=127;static LayoutAll=16777215;Qi(){this.E===null?this.E=new PartTemplateSettings:this.E.wi&&(this.E=this.E.copy())}ch(){super.ch(),this.E!==null&&(this.E.wi=!0)}ec(t,i,e,s,n,o,r){const l=this.diagram;l!==null&&(t===3&&i==="elements"?n instanceof Panel?n.Qr(h=>{l.partManager.FP(h,l)}):n instanceof Picture&&l.VP(n):t===4&&i==="elements"&&(n instanceof Panel?n.Qr(h=>l.partManager.RP(h,l)):n instanceof Picture&&l.zP(n)),l.raiseChangedEvent(t,i,e,s,n,o,r))}updateTargetBindings(t){if(super.updateTargetBindings(t),this.data===null)return;const i=this.D.h,e=i.length;for(let n=0;n{r.data!==null&&r.updateTargetBindings()})}const s=this.adornments;for(;s.next();)s.value.updateTargetBindings(t)}Yo(){if(super.Yo(),this.M2()){const i=this.D.h,e=i.length;for(let s=0;so.Yo())}}const t=this.adornments;for(;t.next();)t.value.Yo()}updateRelationshipsFromData(){this.data!==null&&this.diagram?.partManager.updateRelationshipsFromData(this)}get key(){const t=this.diagram;if(t!==null)return t.model.getKeyForNodeData(this.data)}get adornments(){return this.Qo===null?EmptyIterator.instance:this.Qo.iteratorValues}findAdornment(t){Debug&&Util.t(t,"string",Part,"findAdornment:category");const i=this.Qo;return i===null?null:i.get(t)}addAdornment(t,i){if(i===null)return;Debug&&(Util.t(t,"string",Part,"addAdornment:category"),Util.s(i,Adornment,Part,"addAdornment:ad"));let e=null,s=this.Qo;if(s!==null&&(e=s.get(t)),e!==i){if(e!==null){const o=e.diagram;o!==null&&o.remove(e)}s===null&&(s=new GMap,this.Qo=s),i.$o!==t&&(i.category=t),s.set(t,i);const n=this.diagram;if(n!==null){n.add(i);const o=i.adornedObject;if(o!==null){const r=o.findBindingPanel();r!==null&&(i.data=r.data)}}}}removeAdornment(t){Debug&&Util.t(t,"string",Part,"removeAdornment:category");const i=this.Qo;if(i===null)return;const e=i.get(t);if(e!==null){const s=e.diagram;s!==null&&(s.remove(e),e.data=null)}i.delete(t),i.count===0&&(this.Qo=null)}clearAdornments(){const t=this.Qo;if(t===null)return;const i=Util.at(),e=t.iterator;for(;e.next();){const n=e.key;i.push(n)}const s=i.length;for(let n=0;n{e.isEnabled&&e.updateAdornments(i)}),t.toolManager.updateAdornments(i)}GM(t){this._o=t,t===null&&this.VR()}get layer(){return this._o}get diagram(){const t=this._o;return t==null?null:t.diagram}get layerName(){return this.ul}set layerName(t){const i=this.ul;if(i===t)return;Util.t(t,"string",Part,"layerName");let e=this.diagram;if(e!==null&&(e.findLayer(t)===null||e.partManager.addsToTemporaryLayer))return;this.ul=t,e!==null&&e.invalidateDocumentBounds(),this.i("layerName",i,t);const s=this.layer;if(s===null||s.name===t||(e=s.diagram,e===null))return;const n=e.findLayer(t);if(n===null||n===s)return;let o=s.oe(-1,this,!0);o>=0&&e.raiseChangedEvent(4,"parts",s,this,null,o,!0),o=n.$h(99999999,this,!0),s.visible!==n.visible&&this.Ki(n.visible),o>=0&&e.raiseChangedEvent(3,"parts",n,null,this,!0,o);const r=this.layerChanged;if(r===null)return;const l=e.j;e.j=!0,r(this,s,n),e.j=l}get layerChanged(){return this.E!==null?this.E.jp:null}set layerChanged(t){const i=this.layerChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"layerChanged"),this.Qi(),this.E.jp=t,this.i("layerChanged",i,t))}get zOrder(){return this.Id}set zOrder(t){const i=this.Id;if(i===t)return;Util.t(t,"number",Part,"zOrder"),this.Id=t;const e=this.layer;e!==null&&e.Nx(-1,this),this.i("zOrder",i,t);const s=this.diagram;s!==null&&s.T()}UI(){const t=this.layer;t!==null&&t.Nx(-1,this)}pb(){if(this.nh()!==!1)return;this.Z2(!0),this.ld();const t=this.diagram;t!==null&&(t.u0(this),t.requestUpdate())}ZL(){if(this.N|=2097152,this.nh()===!1)return;const t=this.position,i=this.location;(!i.isReal()||!t.isReal())&&this.$L(t,i);const e=this.Fi,s=Rect.a().c(e);e.ft(),e.x=t.x,e.y=t.y,e.w(),this.hd(s,e),Rect.o(s),this.Z2(!1)}no(t,i,e,s){const n=this.he;n.e(t,i,e,s),this.Pi===null&&(this.Pi=new Transform);const o=this.Pi;o.Vi(),this.M0(o,t,i,e,s),this.Pi=o,o.Gk()||o.Cw(n)}M0(t,i,e,s,n){if(this.rt!==1&&t.rt(this.rt),this.jt===0)return;let o=Spot.Center;this.locationSpot.isSpot()&&(o=this.locationSpot);const r=Point.a();if(this.locationObject!==this){const l=this.locationObject,h=l.naturalBounds;r.setSpot(h.x,h.y,h.width,h.height,o),l.Pi!==null&&l.Pi.Pt(r),r.offset(-l.measuredBounds.x,-l.measuredBounds.y);let a=l.panel;for(;a!==null&&a!==this;)a.Pi!==null&&a.Pi.Pt(r),r.offset(-a.measuredBounds.x,-a.measuredBounds.y),a=a.panel}else r.setSpot(i,e,s,n,o);t.ms(this.jt,r.x,r.y),Point.o(r)}get locationObject(){if(this.tr===null)if(this instanceof Adornment&&this.type!==Panel.Link&&this.hasPlaceholder())this.tr=this.placeholder;else{const t=this.locationObjectName;if(t!==""){const i=this.findObject(t);i!==null?this.tr=i:this.tr=this}else this.tr=this}return this.tr.visible?this.tr:this}get minLocation(){return this.E!==null?this.E.Wp:Point.nC}set minLocation(t){const i=this.minLocation;i.equals(t)||(Debug&&Util.s(t,Point,Part,"minLocation"),t=t.L(),this.Qi(),this.E.Wp=t,this.i("minLocation",i,t))}get maxLocation(){return this.E!==null?this.E.vp:Point.oC}set maxLocation(t){const i=this.maxLocation;i.equals(t)||(Debug&&Util.s(t,Point,Part,"maxLocation"),t=t.L(),this.Qi(),this.E.vp=t,this.i("maxLocation",i,t))}get locationObjectName(){return this.E!==null?this.E.Jp:""}set locationObjectName(t){const i=this.locationObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"locationObjectName"),this.Qi(),this.E.Jp=t,this.tr=null,this.u(),this.i("locationObjectName",i,t))}get locationSpot(){return this.E!==null?this.E.Zp:Spot.TopLeft}set locationSpot(t){const i=this.locationSpot;i.equals(t)||(Debug&&(Util.s(t,Spot,Part,"locationSpot"),t.isSpot()||Util.n("Part.locationSpot must be a specific Spot value, not: "+t)),t=t.L(),this.Qi(),this.E.Zp=t,this.u(),this.i("locationSpot",i,t))}move(t,i){i===!0?this.location=t:this.position=t}moveTo(t,i,e){const s=Point.H(t,i);this.move(s,e),Point.o(s)}isVisible(){if(!this.visible)return!1;const t=this.layer;if(t!==null){if(!t.visible)return!1;const e=t.diagram;if(e!==null&&e.animationManager.ux(this))return!0}const i=this.containingGroup;return!(i!==null&&(!i.isSubGraphExpanded||!i.isVisible()))}Ki(t){const i=this.diagram;t?(this.invalidateLayout(4),this.invalidateAdornments(),i!==null&&i.u0(this)):(this.invalidateLayout(8),this.clearAdornments()),this.gh(),i!==null&&(i.invalidateDocumentBounds(),i.T())}findObject(t){if(this.name===t)return this;let i=this.Hp;if(i===null&&(this.Hp=i=new GMap),i.get(t)!==null)return i.get(t);const e=super.findObject(t);return e!==null?(i.set(t,e),e):(i.set(t,null),null)}V0(){this.Hp=null}getRelativePoint(t,i,e){e===void 0&&(e=new Point);const s=i.isNoSpot()?Spot.Center:i,n=t.naturalBounds;if(e.e(n.width*s.x+s.offsetX,n.height*s.y+s.offsetY),t===null||t===this)return e;t.O.Pt(e);let o=t.panel;for(;o!==null&&o!==this;)o.O.Pt(e),o=o.panel;return this.Pi!==null&&this.Pi.Pt(e),e.offset(-this.he.x,-this.he.y),e}getDocumentBounds(t){return t===void 0&&(t=new Rect),t.c(this.actualBounds)}ensureBounds(){this.wt(1/0,1/0),this.qt()}PL(t){const i=this.locationSpot,e=this.locationObject;let s=e.naturalBounds;s.isReal()||(s=Rect.kw);const n=e instanceof Shape?e.strokeWidth:0;if(t.setSpot(0,0,s.width+n,s.height+n,i),e!==this){t.offset(-n/2,-n/2),e.O.Pt(t);let o=e.panel;for(;o!==null&&o!==this;)o.O.Pt(t),o=o.panel}return this.Pi!==null&&this.Pi.Pt(t),t.offset(-this.he.x,-this.he.y),t}Zh(t,i){const e=i===void 0?this.WL:i,s=this.GI(),n=s*2;if(!this.isShadowed)return e.e(t.x-1-s,t.y-1-s,t.width+2+n,t.height+2+n),e;let o=t.x,r=t.y,l=t.width,h=t.height;const a=this.shadowBlur,f=this.shadowOffset;return l+=a,h+=a,o-=a/2,r-=a/2,f.x>0?l+=f.x:(o+=f.x,l-=f.x),f.y>0?h+=f.y:(r+=f.y,h-=f.y),e.e(o-1,r-1,l+2,h+2),e}NI(){return this.type===Panel.Link&&this instanceof Adornment&&this.category==="Selection"&&this.adornedObject instanceof Shape&&this.adornedPart.findMainElement()===this.adornedObject?this.adornedObject.strokeWidth:0}GI(){return isNaN(this.qp)&&(this.qp=this.FL()),this.qp}pc(){this.qp=NaN}qt(){if(this.rs()===!1){this.ZL();return}this.oo(!1);const t=this.Fi,i=Rect.a();i.c(t);const e=this.Tl();this.dh(0,0,this.he.width,this.he.height);const s=this.position;this.$L(s,this.location),t.ft(),t.x=s.x,t.y=s.y,t.w(),this.hd(i,t),i.equals(t)?this.Us(e):this.Ae()&&(!Geo.p(i.width,t.width)||!Geo.p(i.height,t.height))&&this.qM>=0&&this.invalidateLayout(16),Rect.o(i),this.Z2(!1)}hd(t,i){const e=this.diagram;if(e===null)return;let s=!1;if(e.ia===!1&&t.isReal()){const n=Rect.a();n.c(e.documentBounds),n.subtractMargin(e.padding),t.x>n.x&&t.y>n.y&&t.rightn.x&&i.y>n.y&&i.right=o)return}}this.N=this.N^4096;let s=!1;if(e!==null){s=e.skipsUndoManager,e.skipsUndoManager=!0;const o=e.selection;o.ft(),t?o.add(this):o.delete(this),o.w()}this.i("isSelected",i,t),this.invalidateAdornments();const n=this.selectionChanged;n!==null&&n(this),e!==null&&(e.requestUpdate(),e.skipsUndoManager=s)}}get isHighlighted(){return(this.N&524288)!==0}set isHighlighted(t){const i=(this.N&524288)!==0;if(i!==t){Debug&&Util.t(t,"boolean",Part,"isHighlighted"),this.N=this.N^524288;const e=this.diagram;if(e!==null){const n=e.highlighteds;n.ft(),t?n.add(this):n.delete(this),n.w()}this.i("isHighlighted",i,t),this.T();const s=this.highlightedChanged;s!==null&&s(this)}}get isShadowed(){return(this.N&8192)!==0}set isShadowed(t){const i=(this.N&8192)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Part,"isShadowed"),this.N=this.N^8192,this.hs(!0),this.i("isShadowed",i,t),this.T())}vL(){return(this.N&16384)!==0}JL(t){t?this.N|=16384:this.N&=-16385}nh(){return(this.N&32768)!==0}Z2(t){t?this.N|=32768:this.N&=-32769}HI(){return(this.N&65536)!==0}d2(t){t?this.N|=65536:this.N&=-65537}Tl(){return(this.N&131072)!==0}Us(t){t?this.N|=131072:this.N&=-131073}eT(){return(this.N&1048576)!==0}yb(t){t?this.N|=1048576:this.N&=-1048577}get isAnimated(){return(this.N&262144)!==0}set isAnimated(t){const i=(this.N&262144)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Part,"isAnimated"),this.N=this.N^262144,this.i("isAnimated",i,t))}get highlightedChanged(){return this.E!==null?this.E.$p:null}set highlightedChanged(t){const i=this.highlightedChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"highlightedChanged"),this.Qi(),this.E.$p=t,this.i("highlightedChanged",i,t))}get selectionObjectName(){return this.E!==null?this.E.Qp:""}set selectionObjectName(t){const i=this.selectionObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"selectionObjectName"),this.Qi(),this.E.Qp=t,this.dl=null,this.i("selectionObjectName",i,t))}get selectionAdornmentTemplate(){return this.E!==null?this.E._p:null}set selectionAdornmentTemplate(t){const i=this.selectionAdornmentTemplate;i!==t&&(Debug&&Util.s(t,Adornment,Part,"selectionAdornmentTemplate"),this.Qi(),this.E._p=t,this.i("selectionAdornmentTemplate",i,t))}get selectionObject(){if(this.dl===null){const t=this.selectionObjectName;if(t!==null&&t!==""){const i=this.findObject(t);i!==null?this.dl=i:this.dl=this}else if(this instanceof Link){const i=this.path;i!==null?this.dl=i:this.dl=this}else this.dl=this}return this.dl}get selectionChanged(){return this.E!==null?this.E.ty:null}set selectionChanged(t){const i=this.selectionChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"selectionChanged"),this.Qi(),this.E.ty=t,this.i("selectionChanged",i,t))}get resizeAdornmentTemplate(){return this.E!==null?this.E.iy:null}set resizeAdornmentTemplate(t){const i=this.resizeAdornmentTemplate;i!==t&&(Debug&&Util.s(t,Adornment,Part,"resizeAdornmentTemplate"),this.Qi(),this.E.iy=t,this.i("resizeAdornmentTemplate",i,t))}get resizeObjectName(){return this.E!==null?this.E.ey:""}set resizeObjectName(t){const i=this.resizeObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"resizeObjectName"),this.Qi(),this.E.ey=t,this.i("resizeObjectName",i,t))}get resizeObject(){const t=this.resizeObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get resizeCellSize(){return this.E!==null?this.E.sy:Size.xw}set resizeCellSize(t){const i=this.resizeCellSize;i.equals(t)||(Debug&&Util.s(t,Size,Part,"resizeCellSize"),t=t.L(),this.Qi(),this.E.sy=t,this.i("resizeCellSize",i,t))}get rotateAdornmentTemplate(){return this.E!==null?this.E.ny:null}set rotateAdornmentTemplate(t){const i=this.rotateAdornmentTemplate;i!==t&&(Debug&&Util.s(t,Adornment,Part,"rotateAdornmentTemplate"),this.Qi(),this.E.ny=t,this.i("rotateAdornmentTemplate",i,t))}get rotateObjectName(){return this.E!==null?this.E.oy:""}set rotateObjectName(t){const i=this.rotateObjectName;i!==t&&(Debug&&Util.t(t,"string",Part,"rotateObjectName"),this.Qi(),this.E.oy=t,this.i("rotateObjectName",i,t))}get rotateObject(){const t=this.rotateObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get rotationSpot(){return this.E!==null?this.E.ry:Spot.Default}set rotationSpot(t){const i=this.rotationSpot;i.equals(t)||(Debug&&(Util.s(t,Spot,Part,"rotationSpot"),t!==Spot.Default&&!t.isSpot()&&Util.n("Part.rotationSpot must be a specific Spot value or Spot.Default, not: "+t)),t=t.L(),this.Qi(),this.E.ry=t,this.i("rotationSpot",i,t))}get text(){return this.ui}set text(t){const i=this.ui;i!==t&&(Debug&&Util.t(t,"string",Part,"text"),this.ui=t,this.i("text",i,t))}get containingGroup(){return this.bh}set containingGroup(t){if(this.Ae()){const i=this.bh;if(i!==t){Debug&&t!==null&&Util.s(t,Group,Part,"containingGroup"),t!==null&&(this===t||t.isMemberOf(this))&&(this===t&&Util.n("Cannot make a Group a member of itself: "+this.toString()),Util.n("Cannot make a Group indirectly contain itself: "+this.toString()+" already contains "+t.toString())),this.invalidateLayout(2);const e=this.diagram;if(i!==null?i.Q2(this):this instanceof Group&&e!==null&&e.vr.delete(this),this.bh=t,t!==null?t._2(this):this instanceof Group&&e!==null&&e.vr.add(this),this.invalidateLayout(1),e!==null&&e.j){const n=this.data,o=e.model;if(n!==null&&o.ga()){const r=t!==null?t.data:null;o.setGroupForData(n,o.getKeyForNodeData(r))}}const s=this.containingGroupChanged;if(s!==null){let n=!0;e!==null&&(n=e.j,e.j=!0),s(this,i,t),e!==null&&(e.j=n)}if(this instanceof Group){const n=new GSet;Part.lh(n,this,!0,0,!0);const o=n.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=r.linksConnected;for(;l.next();)l.value.Od()}}}if(this instanceof Node){const n=this.linksConnected;for(;n.next();)n.value.Od();const o=this.labeledLink;o!==null&&o.Od()}this.i("containingGroup",i,t),t!==null&&t.UI()}}else Util.n("cannot set the Part.containingGroup of a Link or Adornment")}gh(){const t=this.containingGroup;t!==null&&(t.hasPlaceholder()&&t.placeholder.u(),t.u(),t.invalidateConnectedLinks())}T(){const t=this.diagram;t!==null&&!this.rs()&&!this.nh()&&this.isVisible()&&this.Fi.isReal()&&t.T(this.Zh(this.Fi))}u(){if(this.Xo())return;super.u();const t=this.diagram;t!==null&&(t.u0(this),this instanceof Node&&this.labeledLink!==null&&this.labeledLink.hc(),t.requestUpdate(!0))}hc(t){if(this.rs())return;const i=this.diagram;i!==null&&(i.u0(this),this instanceof Node&&this.invalidateConnectedLinks(),i.requestUpdate()),this.oo(!0)}Gm(t){if(!t){const i=this.bh;i!==null&&i._2(this)}}Hm(t){if(!t){const i=this.bh;i!==null&&i.Q2(this)}}Zf(){const t=this.data;if(t!==null){const i=this.diagram;if(i!==null){const e=i.model;e!==null&&e.removeNodeData(t)}}}get containingGroupChanged(){return this.E!==null?this.E.ly:null}set containingGroupChanged(t){const i=this.containingGroupChanged;i!==t&&(t!==null&&Util.t(t,"function",Part,"containingGroupChanged"),this.Qi(),this.E.ly=t,this.i("containingGroupChanged",i,t))}findSubGraphLevel(){return this.tN(this)}tN(t){const i=t.containingGroup;if(i!==null)return 1+this.tN(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.tN(e)}return 0}findTopLevelPart(){return this.iN(this)}iN(t){const i=t.containingGroup;if(i!==null)return this.iN(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.iN(e)}return t}get isTopLevel(){return!(this.containingGroup!==null||this instanceof Node&&this.labeledLink!==null)}isMemberOf(t){return t instanceof Group?this.eN(this,t):!1}eN(t,i){if(t===i||i===null)return!1;const e=t.containingGroup;if(e!==null&&(e===i||this.eN(e,i)))return!0;if(t instanceof Node){const s=t.labeledLink;if(s!==null)return this.eN(s,i)}return!1}findCommonContainingGroup(t){if(t===null)return null;if(Debug&&Util.s(t,Part,Part,"findCommonContainingGroup:other"),this===t)return this.containingGroup;let i=this;for(;i!==null;){if(i instanceof Group&&i.yb(!0),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}let e=null;for(i=t;i!==null;){if(i.eT()){e=i;break}if(i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}for(i=this;i!==null;){if(i instanceof Group&&i.yb(!1),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}return e}get layoutConditions(){return this.E!==null?this.E.hy:127}set layoutConditions(t){const i=this.layoutConditions;i!==t&&(Debug&&Util.t(t,"number",Part,"layoutConditions"),this.Qi(),this.E.hy=t,this.i("layoutConditions",i,t))}canLayout(){if(!this.isLayoutPositioned||!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary||this instanceof Node&&this.isLinkLabel)}jI(t){if(!this.isLayoutPositioned||!(t&this.layoutConditions))return!1;const i=this.layer;if(i!==null&&i.isTemporary||this instanceof Node&&this.isLinkLabel)return!1;const e=this.diagram;return!(e!==null&&e.undoManager.isUndoingRedoing)}invalidateLayout(t){if(t===void 0&&(t=16777215),!this.jI(t))return;const i=this.bh;if(i!==null){const e=i.layout;e!==null?e.invalidateLayout():i.invalidateLayout(t)}else{const e=this.diagram;if(e!==null){const s=e.layout;s!==null&&s.invalidateLayout()}}}RA(){if(!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary)}static lh(t,i,e,s,n,o){if(o===void 0&&(o=null),!t.has(i)&&!(o!==null&&!o(i))&&!(i instanceof Adornment)){if(t.add(i),i instanceof Node){if(e&&i instanceof Group){const r=i.memberParts;for(;r.next();){const l=r.value;Part.lh(t,l,e,s,n,o)}}if(n!==!1){const r=i.linksConnected;for(;r.next();){const l=r.value;if(t.has(l))continue;const h=l.fromNode,a=l.toNode,f=h===null||t.has(h),c=a===null||t.has(a);(n?f&&c:f||c)&&Part.lh(t,l,e,s,n,o)}}if(s>1){const r=i.findTreeChildrenNodes();for(;r.next();){const l=r.value;Part.lh(t,l,e,s-1,n,o)}}}else if(i instanceof Link){const r=i.labelNodes;for(;r.next();){const l=r.value;Part.lh(t,l,e,s,n,o)}}}}get dragComputation(){return this.E!==null?this.E.ay:null}set dragComputation(t){const i=this.dragComputation;i!==t&&(t!==null&&Util.t(t,"function",Part,"dragComputation"),this.Qi(),this.E.ay=t,this.i("dragComputation",i,t))}get shadowOffset(){return this.E!==null?this.E.fy:Point.rC}set shadowOffset(t){const i=this.shadowOffset;i.equals(t)||(Debug&&Util.s(t,Point,Part,"shadowOffset"),t=t.L(),this.Qi(),this.E.fy=t,this.T(),this.i("shadowOffset",i,t))}get shadowColor(){return this.E!==null?this.E.cy:"gray"}set shadowColor(t){const i=this.shadowColor;i!==t&&(Debug&&Util.t(t,"string",Part,"shadowColor"),this.Qi(),this.E.cy=t,this.T(),this.i("shadowColor",i,t))}get shadowBlur(){return this.E!==null?this.E.Pn:4}set shadowBlur(t){const i=this.shadowBlur;i!==t&&(Debug&&Util.t(t,"number",Part,"shadowBlur"),this.Qi(),this.E.Pn=t,this.T(),this.i("shadowBlur",i,t))}}class PartTemplateSettings{wi;jp;ly;_p;Qp;ty;$p;iy;ey;sy;ny;oy;ry;Jp;Zp;Wp;vp;ay;hy;fy;cy;Pn;constructor(){this.wi=!1,this.jp=null,this.ly=null,this._p=null,this.Qp="",this.ty=null,this.$p=null,this.iy=null,this.ey="",this.sy=Size.xw,this.ny=null,this.oy="",this.ry=Spot.Default,this.Jp="",this.Zp=Spot.TopLeft,this.Wp=Point.nC,this.vp=Point.oC,this.ay=null,this.hy=127,this.fy=Point.rC,this.cy="gray",this.Pn=4}copy(){const t=new PartTemplateSettings;return t.jp=this.jp,t.ly=this.ly,t._p=this._p,t.Qp=this.Qp,t.ty=this.ty,t.$p=this.$p,t.iy=this.iy,t.ey=this.ey,t.sy=this.sy.L(),t.ny=this.ny,t.oy=this.oy,t.ry=this.ry.L(),t.Jp=this.Jp,t.Zp=this.Zp.L(),t.Wp=this.Wp.L(),t.vp=this.vp.L(),t.ay=this.ay,t.hy=this.hy,t.fy=this.fy.L(),t.cy=this.cy,t.Pn=this.Pn,t}}class Adornment extends Part{ys;Et;sM;nM;gc;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.N&=-257,this.ul="Adornment",this.ys=null,this.sM=0,this.nM=!1,this.Et=null,this.gc=null,i&&Object.assign(this,i)}toString(){const t=this.adornedPart;return"Adornment("+this.category+")"+(t!==null?t.toString():"")}updateRelationshipsFromData(){}md(t){const i=this.adornedObject,e=i?.part;if(!(e instanceof Link)||!(i instanceof Shape))return;const s=e.path;let n=s.geometry;e.md(t),n=s.geometry;const o=this.D.h,r=o.length;for(let l=0;lh instanceof Placeholder);l instanceof Placeholder&&(this.Et===null?this.Et=l:Debug&&this.Et!==l&&Util.n("Cannot insert a second Placeholder into the visual tree of an Adornment."))}}else t===4&&i==="elements"&&this.Et!==null&&(s===this.Et?this.Et=null:s instanceof Panel&&this.Et.isContainedBy(s)&&(this.Et=null));super.ec(t,i,e,s,n,o,r)}updateAdornments(){}Zf(){}}var PortSpreading=(w=>(w[w.None=0]="None",w[w.Evenly=1]="Evenly",w[w.Packed=2]="Packed",w))(PortSpreading||{});class Node extends Part{z;bt;Ac;gl;kh;ae;ni;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.z=13,this.bt=null,this.ni=new List,this.Ac=null,this.gl=null,this.ae=null,this.kh=!1,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.z=this.z,this.bt!==null&&(this.bt.wi?t.bt=this.bt:t.bt=this.bt.copy())}Ho(t){super.Ho(t),t.invalidateConnectedLinks(),t.gl=this.gl,t.ae=null}static SpreadingNone=0;static SpreadingEvenly=1;static SpreadingPacked=2;ml(){this.bt===null?this.bt=new NodeTemplateSettings:this.bt.wi&&(this.bt=this.bt.copy())}ch(){super.ch(),this.bt!==null&&(this.bt.wi=!0)}sT(t){t!==null&&(this.gl===null&&(this.gl=new GSet),this.gl.add(t))}nT(t){t!==null&&this.gl!==null&&this.gl.delete(t)}oT(t,i,e){if(t===null||this.gl===null)return null;const s=this.gl.iterator;for(;s.next();){const n=s.value;if(n.uy===this&&n.wb===t&&n.sN===i&&n.nN===e||n.uy===t&&n.wb===this&&n.sN===e&&n.nN===i)return n}return null}invalidateLinkBundle(t,i,e){i==null&&(i=""),e==null&&(e="");const s=this.oT(t,i,e);s!==null&&s.Ed()}ec(t,i,e,s,n,o,r){t===3&&i==="elements"?this.ae=null:t===4&&i==="elements"&&(this.ae=null),super.ec(t,i,e,s,n,o,r)}invalidateConnectedLinks(t){const i=this.linksConnected;for(;i.next();){const e=i.value;t!==void 0&&t.has(e)||(this._i(e.fromPort),this._i(e.toPort),e.invalidateRoute())}}hL(t){const i=this.linksConnected;for(;i.next();){const e=i.value;e.fromPort!==t&&e.toPort!==t||(this._i(e.fromPort),this._i(e.toPort),e.invalidateRoute())}}_i(t){if(t===null)return;const i=t.sd;i!==null&&i.Ed();const e=t.part,s=e.containingGroup;s!==null&&!e.isVisible()&&s._i(s.port)}$r(){return!0}get portSpreading(){return this.bt!==null?this.bt.gy:1}set portSpreading(t){const i=this.portSpreading;if(i!==t){Debug&&t!==0&&t!==1&&t!==2&&Util.n("Node.portSpreading can only be set to PortSpreading.None, PortSpreading.Evenly, or PortSpreading.Packed, not: "+t),this.ml(),this.bt.gy=t,this.i("portSpreading",i,t);const e=this.diagram;if(e!==null&&e.undoManager.isUndoingRedoing)return;this.invalidateConnectedLinks()}}get avoidable(){return(this.z&8)!==0}set avoidable(t){const i=(this.z&8)!==0;if(i!==t){Debug&&Util.t(t,"boolean",Node,"avoidable"),this.z=this.z^8;const e=this.diagram;e!==null&&e.HP(this),this.i("avoidable",i,t)}}get avoidableMargin(){return this.bt!==null?this.bt.my:Margin.uC}set avoidableMargin(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Node,"avoidableMargin");const i=this.avoidableMargin;if(!i.equals(t)){t=t.L(),this.ml(),this.bt.my=t;const e=this.diagram;e!==null&&e.HP(this),this.i("avoidableMargin",i,t)}}canAvoid(){return this.avoidable&&!this.isLinkLabel}getAvoidableRect(t){return t.set(this.actualBounds),t.addMargin(this.avoidableMargin),t}findVisibleNode(){let t=this;for(;t!==null&&!t.isVisible();)t=t.containingGroup;return t}isVisible(){if(!super.isVisible())return!1;let t=!0,i=1;const e=this.diagram;if(e!==null){if(e.animationManager.ux(this))return!0;t=e.isTreePathToChildren,i=e.treeCollapsePolicy}if(i===1){const n=this.findTreeParentNode();if(n!==null&&!n.isTreeExpanded)return!1}else if(i===2){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&h.isTreeExpanded){r=!0;break}}}if(o&&!r)return!1}else if(i===3){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&!h.isTreeExpanded){r=!0;break}}}if(o&&r)return!1}const s=this.labeledLink;return s!==null?s.isVisible():!0}Ki(t){super.Ki(t);const i=this.linksConnected;for(;i.next();){const e=i.value;if(t&&this.containingGroup!==null){const s=e.getOtherNode(this);s!==null&&!s.isMemberOf(this.containingGroup)&&e.invalidateRoute()}e.Ki(t)}}get linksConnected(){return this.ni.iterator}findExternalTreeLinksConnected(){const t=new GSet,i=new GSet;return this.rT(this,t,i),i.iterator}rT(t,i,e){if(t===null||i.has(t))return;i.add(t);let s=!0;const n=this.diagram;n!==null&&(s=n.isTreePathToChildren),t.linksConnected.each(o=>{o.isTreeLink?(s?o.fromNode===t:o.toNode===t)&&this.rT(s?o.toNode:o.fromNode,i,e):e.add(o)})}findLinksConnected(t){if(t===void 0&&(t=null),t===null)return this.ni.iterator;Debug&&Util.t(t,"string",Node,"findLinksConnected:pid");const i=new ListIterator(this.ni),e=this;return i.predicate=s=>s.fromNode===e&&s.fromPortId===t||s.toNode===e&&s.toPortId===t,i}findLinksOutOf(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findLinksOutOf:pid");const i=new ListIterator(this.ni),e=this;return i.predicate=s=>s.fromNode!==e?!1:t===null?!0:s.fromPortId===t,i}findLinksInto(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findLinksInto:pid");const i=new ListIterator(this.ni),e=this;return i.predicate=s=>s.toNode!==e?!1:t===null?!0:s.toPortId===t,i}findNodesConnected(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findNodesConnected:pid");let i=null,e=null;const s=this.ni.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this){if(t===null||n.fromPortId===t){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}else if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesOutOf(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findNodesOutOf:pid");let i=null,e=null;const s=this.ni.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this&&(t===null||n.fromPortId===t)){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesInto(t){t===void 0&&(t=null),Debug&&t!==null&&Util.t(t,"string",Node,"findNodesInto:pid");let i=null,e=null;const s=this.ni.iterator;for(;s.next();){const n=s.value;if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findLinksBetween(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),Debug&&(Util.s(t,Node,Node,"findLinksBetween:othernode"),i!==null&&Util.t(i,"string",Node,"findLinksBetween:pid"),e!==null&&Util.t(e,"string",Node,"findLinksBetween:otherpid"));const s=new ListIterator(this.ni),n=this;return s.predicate=o=>o.fromNode===n&&o.toNode===t&&(i===null||o.fromPortId===i)&&(e===null||o.toPortId===e)||o.fromNode===t&&o.toNode===n&&(e===null||o.fromPortId===e)&&(i===null||o.toPortId===i),s}findLinksTo(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),Debug&&(Util.s(t,Node,Node,"findLinksTo:othernode"),i!==null&&Util.t(i,"string",Node,"findLinksTo:pid"),e!==null&&Util.t(e,"string",Node,"findLinksTo:otherpid"));const s=new ListIterator(this.ni),n=this;return s.predicate=o=>!(o.fromNode!==n||o.toNode!==t||i!==null&&o.fromPortId!==i||e!==null&&o.toPortId!==e),s}get linkConnected(){return this.bt!==null?this.bt.py:null}set linkConnected(t){const i=this.linkConnected;i!==t&&(t!==null&&Util.t(t,"function",Node,"linkConnected"),this.ml(),this.bt.py=t,this.i("linkConnected",i,t))}get linkDisconnected(){return this.bt!==null?this.bt.yy:null}set linkDisconnected(t){const i=this.linkDisconnected;i!==t&&(t!==null&&Util.t(t,"function",Node,"linkDisconnected"),this.ml(),this.bt.yy=t,this.i("linkDisconnected",i,t))}get linkValidation(){return this.bt!==null?this.bt.Ll:null}set linkValidation(t){const i=this.linkValidation;i!==t&&(t!==null&&Util.t(t,"function",Node,"linkValidation"),this.ml(),this.bt.Ll=t,this.i("linkValidation",i,t))}xb(t,i){this._i(i);const e=this.ni.has(t);if(e||this.ni.add(t),!e||t.fromNode===t.toNode){const s=this.linkConnected;if(s!==null){let n=!0;const o=this.diagram;o!==null&&(n=o.j,o.j=!0),s(this,t,i),o!==null&&(o.j=n)}}if(!e){if(!t.isTreeLink)return;const s=t.fromNode,n=t.toNode;if(s!==null&&n!==null&&s!==n){let o=!0;const r=this.diagram;r!==null&&(o=r.isTreePathToChildren);const l=o?n:s,h=o?s:n;if(l.kh||(l.kh=h),h.isTreeLeaf){if(r!==null&&r.undoManager.isUndoingRedoing)return;o?s===h&&(h.isTreeLeaf=!1):n===h&&(h.isTreeLeaf=!1)}}}}bb(t,i){this._i(i);const e=this.ni.delete(t);let s=null;if(e||t.toNode===t.fromNode){const n=this.linkDisconnected;if(s=this.diagram,n!==null){let o=!0;s!==null&&(o=s.j,s.j=!0),n(this,t,i),s!==null&&(s.j=o)}}if(e){if(!t.isTreeLink)return;let n=!0;s!==null&&(n=s.isTreePathToChildren);const o=n?t.toNode:t.fromNode,r=n?t.fromNode:t.toNode;if(o!==null&&(o.kh=!1),r!==null&&!r.isTreeLeaf)if(r.ni.count===0){if(r.kh=null,s!==null&&s.undoManager.isUndoingRedoing)return;r.isTreeLeaf=!0}else r.w0()}}w0(){if(this.kh=!1,this.ni.count===0)return;let t=!0;const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;i!==null&&(t=i.isTreePathToChildren);const e=this.ni.iterator;for(;e.next();){const s=e.value;if(s.isTreeLink){if(t){if(s.fromNode===this){this.isTreeLeaf=!1;return}}else if(s.toNode===this){this.isTreeLeaf=!1;return}}}this.isTreeLeaf=!0}updateRelationshipsFromData(){const t=this.diagram;t!==null&&t.partManager.updateRelationshipsFromData(this)}Gm(t){if(super.Gm(t),!t){this.w0();const i=this.Ac;i!==null&&i.lT(this)}}Hm(t){if(super.Hm(t),!t){const i=this.Ac;i!==null&&i.hT(this)}}Zf(){if(this.ni.count>0){const t=this.diagram;if(t!==null){const i=t.commandHandler!==null?t.commandHandler.deletesConnectedLinks:!0,s=this.ni.copy().iterator;for(;s.next();){const n=s.value;i?t.remove(n):(n.fromNode===this&&(n.fromNode=null),n.toNode===this&&(n.toNode=null))}}}this.labeledLink=null,super.Zf()}get isLinkLabel(){return this.Ac!==null}get labeledLink(){return this.Ac}set labeledLink(t){const i=this.Ac;if(i!==t){Debug&&t!==null&&Util.s(t,Link,Node,"labeledLink");const e=this.diagram,s=this.data;if(i!==null){if(i.hT(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=i.data,o=e.model;if(n!==null&&o.Ea()){const r=o.getKeyForNodeData(s);r!==void 0&&o.removeLabelKeyForLinkData(n,r)}}this.containingGroup=null}if(this.Ac=t,t!==null){if(t.lT(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=t.data,o=e.model;if(n!==null&&o.Ea()){const r=o.getKeyForNodeData(s);r!==void 0&&o.addLabelKeyForLinkData(n,r)}}this.containingGroup=t.containingGroup}this.hc(),this.i("labeledLink",i,t)}}findVisiblePort(t){let i=t;for(;i!==null&&(!i.actualBounds.isReal()||!i.isVisibleObject());)i=i.panel;return i===null?this.port:i}findPort(t){if(Debug&&Util.t(t,"string",Node,"findPort:pid"),this.ae===null){if(t===""&&this.Mn===!1)return this;this.aT()}let i=this.ae.get(t);return i!==null||t!==""&&(i=this.ae.get(""),i!==null)?i:this}get port(){return this.findPort("")}get ports(){return this.ae===null&&this.aT(),this.ae.iteratorValues}aT(){this.ae===null?this.ae=new GMap:this.ae.clear(),this.walkVisualTreeFrom(this,(t,i)=>t.pL(i)),this.ae.count===0&&this.ae.set("",this)}pL(t){const i=t.portId;i!==null&&this.ae!==null&&this.ae.set(i,t)}S2(t,i){const e=t.portId;if(e!==null){this.ae!==null&&this.ae.delete(e);const s=this.diagram;if(s!==null&&i){let n=null;const o=this.findLinksConnected(e);for(;o.next();){const r=o.value;n===null&&(n=Util.at()),n.push(r)}if(n!==null){for(let r=0;r!(!n.isTreeLink||n.fromNode!==s):e.predicate=n=>!(!n.isTreeLink||n.toNode!==s),e}findTreeChildrenNodes(){let t=!0;const i=this.diagram;i!==null&&(t=i.isTreePathToChildren);let e=null,s=null;const n=this.ni.iterator;if(t)for(;n.next();){const o=n.value;if(o.isTreeLink&&o.fromNode===this){const r=o.toNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}else for(;n.next();){const o=n.value;if(o.isTreeLink&&o.toNode===this){const r=o.fromNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}return e!==null?e.iterator:s!==null?new SingletonIterator(s):EmptyIterator.instance}findTreeParts(t){t===void 0&&(t=1/0),Util.t(t,"number",Node,"findTreeParts:level");const i=new GSet;return Part.lh(i,this,!1,t,!0),i}collapseTree(t){t===void 0&&(t=1),Util.r(t,Node,"collapseTree:level"),t<1&&(t=1);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.fT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}fT(t,i,e,s,n,o){if(e>1){const r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);h!==null&&h!==this&&!t.has(h)&&(t.add(h),h.fT(t,i,e-1,s,n,o))}}else this.cT(t,i,s,n,o)}cT(t,i,e,s,n){const o=s===this?!0:this.isTreeExpanded,r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);if(h!==null&&h!==this){const a=t.has(h);if(a||t.add(h),o){const f=i?h.findNodesInto():h.findNodesOutOf(),c=this;f.all(u=>u===c||!u.isTreeExpanded)&&e.Ef(h,s),h.gh(),h.Ki(!1)}h.isTreeExpanded&&(h.wasTreeExpanded=h.isTreeExpanded,a||h.cT(t,i,e,s,n))}}this.isTreeExpanded=!1}expandTree(t){t===void 0&&(t=2),Util.r(t,Node,"expandTree:level"),t<2&&(t=2);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.uT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}uT(t,i,e,s,n,o){const r=n===this?!1:this.isTreeExpanded,l=i?this.findLinksOutOf():this.findLinksInto();for(;l.next();){const h=l.value;if(!h.isTreeLink)continue;r||h.Te||h.invalidateRoute();const a=h.getOtherNode(this);if(a!==null&&a!==this&&!t.has(a)){if(t.add(a),!r){a.Ki(!0),a.gh();const f=i?a.findNodesInto():a.findNodesOutOf(),c=this;f.all(u=>u===c||!u.isTreeExpanded)&&s.Of(a,n)}(e>2||a.wasTreeExpanded)&&(a.wasTreeExpanded=!1,a.uT(t,i,e-1,s,n,o))}}this.isTreeExpanded=!0}get isTreeExpanded(){return(this.z&1)!==0}set isTreeExpanded(t){const i=(this.z&1)!==0;if(i!==t){Debug&&Util.t(t,"boolean",Node,"isTreeExpanded"),this.z=this.z^1;const e=this.diagram;this.i("isTreeExpanded",i,t);const s=this.treeExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.j,e.j=!0),s(this),e!==null&&(e.j=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.Ki(t);return}t?this.expandTree():this.collapseTree()}}get wasTreeExpanded(){return(this.z&2)!==0}set wasTreeExpanded(t){const i=(this.z&2)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Node,"wasTreeExpanded"),this.z=this.z^2,this.i("wasTreeExpanded",i,t))}get treeExpandedChanged(){return this.bt!==null?this.bt.wy:null}set treeExpandedChanged(t){const i=this.treeExpandedChanged;i!==t&&(t!==null&&Util.t(t,"function",Node,"treeExpandedChanged"),this.ml(),this.bt.wy=t,this.i("treeExpandedChanged",i,t))}get isTreeLeaf(){return(this.z&4)!==0}set isTreeLeaf(t){const i=(this.z&4)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Node,"isTreeLeaf"),this.z=this.z^4,this.i("isTreeLeaf",i,t))}get isTreeRoot(){return this.findTreeParentLink()===null}}class NodeTemplateSettings{wi;py;yy;Ll;wy;my;gy;xy;by;rh;ky;constructor(){this.wi=!1,this.py=null,this.yy=null,this.Ll=null,this.wy=null,this.my=Margin.uC,this.gy=1,this.xy=null,this.by=null,this.rh=null,this.ky=null}copy(){const t=new NodeTemplateSettings;return t.py=this.py,t.yy=this.yy,t.Ll=this.Ll,t.wy=this.wy,t.my=this.my.L(),t.gy=this.gy,t.xy=this.xy,t.by=this.by,t.rh=this.rh,t.ky=this.ky,t}}var LinkAdjusting=(w=>(w[w.None=0]="None",w[w.End=17]="End",w[w.Scale=18]="Scale",w[w.Stretch=19]="Stretch",w))(LinkAdjusting||{}),Routing=(w=>(w[w.Normal=1]="Normal",w[w.Orthogonal=2]="Orthogonal",w[w.AvoidsNodes=6]="AvoidsNodes",w[w.AvoidsNodesStraight=7]="AvoidsNodesStraight",w))(Routing||{}),Curve=(w=>(w[w.None=0]="None",w[w.Bezier=9]="Bezier",w[w.JumpGap=10]="JumpGap",w[w.JumpOver=11]="JumpOver",w))(Curve||{});class Link extends Part{Dt;go;mo;Bd;po;yo;Vd;Lc;zd;Xd;Yd;Ba;Kd;$s;Ni;Ie;Lr;Tc;ir;oN;rN;kb;lN;hN;Sy;Sb;mt;er;static Va=null;static za=null;gc;aN;fN;constructor(t){super(Panel.Link),this.Dt=8,this.go=null,this.mo="",this.Bd=null,this.po=null,this.yo="",this.Vd=null,this.Lc=0,this.zd=0,this.Xd=0,this.Yd=NaN,this.Ba=1,this.Kd=.5,this.$s=null,this.Ni=new List().w(),this.Ie=null,this.Lr=null,this.Tc=new Rect,this.mt=new Geometry,this.ir=null,this.er=null,this.oN=null,this.rN=null,this.aN=0,this.fN=0,this.kb=new Point,this.lN=null,this.hN=null,this.Sy=null,this.Sb=NaN,this.Z=null,this.gc=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Dt=this.Dt&-113,t.mo=this.mo,t.Bd=this.Bd,t.yo=this.yo,t.Vd=this.Vd,t.Lc=this.Lc,t.zd=this.zd,t.Xd=this.Xd,t.Yd=this.Yd,t.Ba=this.Ba,t.Kd=this.Kd,this.Z!==null&&(t.Z=this.Z.copy())}Ho(t){super.Ho(t),this.mo=t.mo,this.yo=t.yo,t.Ie=null,t.invalidateRoute(),t.er=this.er;const i=t.fromPort;i!==null&&t.fromNode._i(i);const e=t.toPort;e!==null&&t.toNode._i(e)}fi(t){t in Routing||t in Curve||t in LinkAdjusting?Link.cN(t)?this.routing=t:t===9||t===10||t===11?this.curve=t:t===17||t===18||t===19?this.adjusting=t:t===1||t===0||Util.n("Unknown Link enum value for a Link property: "+t):super.fi(t)}static Normal=1;static Orthogonal=2;static AvoidsNodes=6;static AvoidsNodesStraight=7;static None=0;static Bezier=9;static JumpGap=10;static JumpOver=11;static End=17;static Scale=18;static Stretch=19;static OrientAlong=21;static OrientPlus90=22;static OrientMinus90=23;static OrientOpposite=24;static OrientUpright=25;static OrientPlus90Upright=26;static OrientMinus90Upright=27;static OrientUpright45=28;static vI=8;static JI=16;static ZI=14;static Xa=8;je(){this.Z===null&&(this.Z=new LinkSettings)}oI(t,i,e){const s=t.segmentIndex,n=t.segmentFraction;let o=t.alignmentFocus;const r=t.segmentOrientation,l=t.segmentOffset;let h=0,a=0,f=0,c=0;if(isNaN(s)){const C=this.mt,P=Util.at();C.getPointAndAngleAlongPath(n,P);const N=Point.H(P[0],P[1]);if(N.add(this.getPoint(0)),C.type===1)N.offset(-C.startX,-C.startY);else{const T=C.figures.first();N.offset(-T.startX,-T.startY)}c=P[2],r!==0&&(f=this.computeAngle(t,r,c),t.angle=f),h=N.x,a=N.y,Point.o(N),Util.nt(P)}else if(s<-i||s>=i){const C=Point.a();this.ML(C),c=this.midAngle,r!==0&&(f=this.computeAngle(t,r,c),t.angle=f),h=C.x,a=C.y,Point.o(C)}else{let C,P,N=0;if(s>=0?(C=e.h[s],P=s0?e.h[N-1]:C),C.equalsApprox(P)){let T,L;s>=0?(T=s>0?e.h[s-1]:C,L=s1?e.h[N-2]:P);const D=T.distanceSquaredPoint(C),F=P.distanceSquaredPoint(L);D>F+10?c=s>=0?T.directionPoint(C):C.directionPoint(T):F>D+10?c=s>=0?P.directionPoint(L):L.directionPoint(P):c=s>=0?T.directionPoint(L):L.directionPoint(T)}else c=s>=0?C.directionPoint(P):P.directionPoint(C);r!==0&&(f=this.computeAngle(t,r,c),t.angle=f),h=C.x+(P.x-C.x)*n,a=C.y+(P.y-C.y)*n}if(o.isNone()){t.location=new Point(h,a);return}else o.isNoSpot()&&(o=Spot.Center);const u=Transform.a();u.Vi(),u.rt(t.scale,t.scale),u.ms(t.angle,0,0);const d=t.naturalBounds,m=Rect.H(0,0,d.width,d.height),g=Point.a();g.setRectSpot(m,o),u.Pt(g);let p=-g.x,y=-g.y;const x=d.width,k=d.height,b=Point.a();b.c(l);const S=isNaN(l.x),M=isNaN(l.y);if(S||M){const C=x/2+3,P=k/2+3,N=c>=45&&c<=135,T=c>=225&&c<=315;r===0&&(N||T)?(b.x=M?C:l.y,b.y=S?P:l.x,N?s>=0||isNaN(s)&&n<.5||S&&(b.y=-P):T&&((s>=0||isNaN(s)&&n<.5)&&S&&(b.y=-P),M&&(b.x=-C))):(S&&(s>=0||isNaN(s)&&n<.5?b.x=C:b.x=-C),M&&(b.y=-P),b.rotate(c))}else b.rotate(c);h+=b.x,a+=b.y,u.Cw(m),p+=m.x,y+=m.y;const A=Point.H(h+p,a+y);t.move(A),Point.o(A),Point.o(b),Point.o(g),Rect.o(m),Transform.o(u)}$r(){let t=this.fromNode;if(t!==null){const e=t.findVisibleNode();if(e!==null&&(t=e),t.rs()||t.nh())return!1}let i=this.toNode;if(i!==null){const e=i.findVisibleNode();if(e!==null&&(i=e),i.rs()||i.nh())return!1}return!0}b2(t,i,e){return!1}k2(){}Ae(){return!1}computeAngle(t,i,e){return Link.computeAngle(i,e)}static computeAngle(t,i){let e=0;switch(t){default:case 0:e=0;break;case 21:e=i;break;case 22:e=i+90;break;case 23:e=i-90;break;case 24:e=i+180;break;case 25:e=Geo.vg(i),e>90&&e<270&&(e-=180);break;case 26:e=Geo.vg(i+90),e>90&&e<270&&(e-=180);break;case 27:e=Geo.vg(i-90),e>90&&e<270&&(e-=180);break;case 28:if(e=Geo.vg(i),e>45&&e<135||e>225&&e<315)return 0;e>90&&e<270&&(e-=180);break}return Geo.vg(e)}get fromNode(){return this.go}set fromNode(t){const i=this.go;if(i!==t){Debug&&t!==null&&Util.s(t,Node,Link,"fromNode");const e=this.fromPort;i!==null&&(this.po!==i&&i.bb(this,e),this.My(),this.invalidateLayout(2)),this.go=t,t!==null&&this.Ki(t.isVisible()),this.ir=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.j&&s.partManager.setFromNodeForLink(this,t,i);const n=this.fromPort,o=this.fromPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.j,s.j=!0),o(this,e,n),s!==null&&(s.j=r)}t!==null&&(this.po!==t&&t.xb(this,n),this.Py(),this.invalidateLayout(1)),this.i("fromNode",i,t),this.Od()}}get fromPortId(){return this.mo}set fromPortId(t){const i=this.mo;if(i!==t){Debug&&Util.t(t,"string",Link,"fromPortId");const e=this.fromPort;e!==null&&this.fromNode._i(e),this.My(),this.mo=t;const s=this.fromPort;s!==null&&this.fromNode._i(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Ea()&&r.setFromPortIdForLinkData(o,t)}if(e!==s){this.ir=null,this.invalidateRoute();const o=this.fromPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.j,n.j=!0),o(this,e,s),n!==null&&(n.j=r)}}this.Py(),this.i("fromPortId",i,t)}}get fromPort(){const t=this.go;if(t===null)return null;const i=this.mo;return t.findPort(i)}get fromPortChanged(){return this.Bd}set fromPortChanged(t){const i=this.Bd;i!==t&&(t!==null&&Util.t(t,"function",Link,"fromPortChanged"),this.Bd=t,this.i("fromPortChanged",i,t))}get toNode(){return this.po}set toNode(t){const i=this.po;if(i!==t){Debug&&t!==null&&Util.s(t,Node,Link,"toNode");const e=this.toPort;i!==null&&(this.go!==i&&i.bb(this,e),this.My(),this.invalidateLayout(2)),this.po=t,t!==null&&this.Ki(t.isVisible()),this.ir=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.j&&s.partManager.setToNodeForLink(this,t,i);const n=this.toPort,o=this.toPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.j,s.j=!0),o(this,e,n),s!==null&&(s.j=r)}t!==null&&(this.go!==t&&t.xb(this,n),this.Py(),this.invalidateLayout(1)),this.i("toNode",i,t),this.Od()}}get toPortId(){return this.yo}set toPortId(t){const i=this.yo;if(i!==t){Debug&&Util.t(t,"string",Link,"toPortId");const e=this.toPort;e!==null&&this.toNode._i(e),this.My(),this.yo=t;const s=this.toPort;s!==null&&this.toNode._i(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Ea()&&r.setToPortIdForLinkData(o,t)}if(e!==s){this.ir=null,this.invalidateRoute();const o=this.toPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.j,n.j=!0),o(this,e,s),n!==null&&(n.j=r)}}this.Py(),this.i("toPortId",i,t)}}get toPort(){const t=this.po;if(t===null)return null;const i=this.yo;return t.findPort(i)}get toPortChanged(){return this.Vd}set toPortChanged(t){const i=this.Vd;i!==t&&(t!==null&&Util.t(t,"function",Link,"toPortChanged"),this.Vd=t,this.i("toPortChanged",i,t))}get fromSpot(){return this.Z!==null?this.Z.pa:Spot.Default}set fromSpot(t){const i=this.fromSpot;if(!i.equals(t)){if(Debug&&Util.s(t,Spot,Link,"fromSpot"),t=t.L(),this.je(),this.Z.pa=t,this.i("fromSpot",i,t),i.isSide()||t.isSide()){const e=this.fromNode;e!==null&&e._i(this.fromPort)}this.invalidateRoute()}}get fromEndSegmentLength(){return this.Z!==null?this.Z.wa:NaN}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;if(i!==t){if(Debug&&Util.t(t,"number",Link,"fromEndSegmentLength"),t<0&&Util.G(t,">= 0",Link,"fromEndSegmentLength"),this.je(),this.Z.wa=t,this.i("fromEndSegmentLength",i,t),this.computeSpot(!0,this.fromPort).isSide()){const e=this.fromNode;e!==null&&e._i(this.fromPort)}this.invalidateRoute()}}get fromShortLength(){return this.Z!==null?this.Z.ba:NaN}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(Debug&&Util.t(t,"number",Link,"fromShortLength"),this.je(),this.Z.ba=t,this.le(),this.i("fromShortLength",i,t))}get toSpot(){return this.Z!==null?this.Z.ya:Spot.Default}set toSpot(t){const i=this.toSpot;if(!i.equals(t)){if(Debug&&Util.s(t,Spot,Link,"toSpot"),t=t.L(),this.je(),this.Z.ya=t,this.i("toSpot",i,t),i.isSide()||t.isSide()){const e=this.toNode;e!==null&&e._i(this.toPort)}this.invalidateRoute()}}get toEndSegmentLength(){return this.Z!==null?this.Z.xa:NaN}set toEndSegmentLength(t){const i=this.toEndSegmentLength;if(i!==t){if(Debug&&Util.t(t,"number",Link,"toEndSegmentLength"),t<0&&Util.G(t,">= 0",Link,"toEndSegmentLength"),this.je(),this.Z.xa=t,this.i("toEndSegmentLength",i,t),this.computeSpot(!1,this.toPort).isSide()){const e=this.toNode;e!==null&&e._i(this.toPort)}this.invalidateRoute()}}get toShortLength(){return this.Z!==null?this.Z.ka:NaN}set toShortLength(t){const i=this.toShortLength;i!==t&&(Debug&&Util.t(t,"number",Link,"toShortLength"),this.je(),this.Z.ka=t,this.le(),this.i("toShortLength",i,t))}Od(){const t=this.fromNode,i=this.toNode;let e=null;if(t!==null?i!==null?e=t.findCommonContainingGroup(i):e=t.containingGroup:i!==null?e=i.containingGroup:e=null,this.$I(e),this.isLabeledLink){const s=this.labelNodes;for(;s.next();){const n=s.value;n.containingGroup=e}}}$I(t){const i=this.bh;if(i!==t){i!==null&&i.Q2(this),this.bh=t,t!==null&&t._2(this);const e=this.containingGroupChanged;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.j,n.j=!0),e(this,i,t),n!==null&&(n.j=s)}this.Te&&(this.lN===i||this.hN===i)&&this.invalidateRoute()}}gh(){const t=this.containingGroup;t!==null&&this.fromNode!==t&&this.toNode!==t&&t.computesBoundsIncludingLinks&&super.gh()}getOtherNode(t){Debug&&Util.s(t,Node,Link,"getOtherNode:node");const i=this.fromNode;return t===i?this.toNode:i}getOtherPort(t){Debug&&Util.s(t,GraphObject,Link,"getOtherPort:port");const i=this.fromPort;return t===i?this.toPort:i}get isLabeledLink(){return this.$s===null?!1:this.$s.count>0}get labelNodes(){return this.$s===null?EmptyIterator.instance:this.$s.iterator}lT(t){this.$s===null&&(this.$s=new GSet),this.$s.add(t),this.u()}hT(t){this.$s!==null&&(this.$s.delete(t),this.u())}Gm(t){if(super.Gm(t),this.Ya()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.go;let e=null;i!==null&&(e=this.fromPort,i.xb(this,e));const s=this.po;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.xb(this,n)),this.Py()}}Hm(t){if(super.Hm(t),this.Ya()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.go;let e=null;i!==null&&(e=this.fromPort,i.bb(this,e));const s=this.po;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.bb(this,n)),this.My()}}Zf(){if(this.Te=!0,this.$s!==null){const i=this.diagram;if(i!==null){const s=this.$s.copy().iterator;for(;s.next();){const n=s.value;i.remove(n)}}}if(this.data!==null){const i=this.diagram;i!==null&&i.partManager.uN(this)}}updateRelationshipsFromData(){if(this.data===null)return;const i=this.diagram;i!==null&&i.partManager.updateRelationshipsFromData(this)}move(t,i){const e=i?this.location:this.position;let s=e.x;isNaN(s)&&(s=0);let n=e.y;isNaN(n)&&(n=0);const o=t.x-s,r=t.y-n;if(i===!0)super.move(t,!1);else{const h=Point.H(e.x+o,e.y+r);super.move(h,!1),Point.o(h)}this.kr(o,r);const l=this.labelNodes;for(;l.next();){const h=l.value,a=h.position;h.moveTo(a.x+o,a.y+r)}}get relinkableFrom(){return(this.Dt&1)!==0}set relinkableFrom(t){const i=(this.Dt&1)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"relinkableFrom"),this.Dt=this.Dt^1,this.i("relinkableFrom",i,t),this.invalidateAdornments())}get relinkableTo(){return(this.Dt&2)!==0}set relinkableTo(t){const i=(this.Dt&2)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"relinkableTo"),this.Dt=this.Dt^2,this.i("relinkableTo",i,t),this.invalidateAdornments())}canRelinkFrom(){if(!this.relinkableFrom)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}canRelinkTo(){if(!this.relinkableTo)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}get resegmentable(){return(this.Dt&4)!==0}set resegmentable(t){const i=(this.Dt&4)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"resegmentable"),this.Dt=this.Dt^4,this.i("resegmentable",i,t),this.invalidateAdornments())}get isTreeLink(){return(this.Dt&8)!==0}set isTreeLink(t){const i=(this.Dt&8)!==0;i!==t&&(Debug&&Util.t(t,"boolean",Link,"isTreeLink"),this.Dt=this.Dt^8,this.i("isTreeLink",i,t),this.fromNode!==null&&this.fromNode.w0(),this.toNode!==null&&this.toNode.w0())}get path(){const t=this.findMainElement();return t instanceof Shape?t:null}get routeBounds(){return this.updateRoute(),this.QI(this.Tc)}QI(t){let i=1/0,e=1/0;const s=this.pointsCount;if(s===0)return t.e(NaN,NaN,0,0),t;if(s===1){const n=this.getPoint(0);i=Math.min(n.x,i),e=Math.min(n.y,e),t.e(n.x,n.y,0,0)}else if(s===2){const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o)}else if(this.computeCurve()===9&&s>=3&&!this.isOrthogonal){let n=this.getPoint(0);if(i=n.x,e=n.y,t.e(i,e,0,0),s===3){const o=this.getPoint(1);i=Math.min(o.x,i),e=Math.min(o.y,e);const r=this.getPoint(2);i=Math.min(r.x,i),e=Math.min(r.y,e),Geo.gu(n.x,n.y,o.x,o.y,o.x,o.y,r.x,r.y,.5,t)}else for(let o=3;o=s&&(o=s-1);const l=this.getPoint(o-1),h=this.getPoint(o);Geo.gu(n.x,n.y,r.x,r.y,l.x,l.y,h.x,h.y,.5,t),i=Math.min(h.x,i),e=Math.min(h.y,e),n=h}}else{const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o);for(let r=2;r=15||this.computeCurve()===9)){this.mt.getPointAlongPath(.5,t),t.add(this.getPoint(0));const a=this.mt.figures.first();return t.offset(-a.startX,-a.startY),t}if(this.computeCurve()===9){if(i===3){const c=this.getPoint(0),u=this.getPoint(1),d=this.getPoint(2);return Geo.wC(c.x,c.y,u.x,u.y,u.x,u.y,d.x,d.y,t),t}const a=(i-1)/3|0,f=(a/2|0)*3;if(a%2===1){const c=this.getPoint(f),u=this.getPoint(f+1),d=this.getPoint(f+2),m=this.getPoint(f+3);return Geo.wC(c.x,c.y,u.x,u.y,d.x,d.y,m.x,m.y,t),t}else return t.c(this.getPoint(f)),t}const e=this.flattenedLengths,s=this.flattenedTotalLength;let n=0,o=0,r=0;for(;ns/2));)n+=r,o++;const l=this.getPoint(o),h=this.getPoint(o+1);if(Math.abs(l.x-h.x)<1)l.y>h.y?t.e(l.x,l.y-(s/2-n)):t.e(l.x,l.y+(s/2-n));else if(Math.abs(l.y-h.y)<1)l.x>h.x?t.e(l.x-(s/2-n),l.y):t.e(l.x+(s/2-n),l.y);else{const a=(s/2-n)/r,f=a*(h.x-l.x),c=a*(h.y-l.y);t.e(l.x+f,l.y+c)}return t}get midAngle(){return this.updateRoute(),this.computeMidAngle()}computeMidAngle(){const t=this.pointsCount;if(t<2)return NaN;if(t===2){const h=this.getPoint(0),a=this.getPoint(1);return h.directionPoint(a)}if(this.isOrthogonal&&(this.computeCorner()>=15||this.computeCurve()===9))return this.mt.getAngleAlongPath(.5);if(this.computeCurve()===9&&t>=4){const h=(t-1)/3|0;let a=(h/2|0)*3;if(h%2===1){a=Math.floor(a);const f=this.getPoint(a),c=this.getPoint(a+1),u=this.getPoint(a+2),d=this.getPoint(a+3);return Geo.XD(f.x,f.y,c.x,c.y,u.x,u.y,d.x,d.y)}else if(a>0&&a+1e/2));)s+=o,n++;const r=this.getPoint(n),l=this.getPoint(n+1);if(Math.abs(r.x-l.x)<1&&Math.abs(r.y-l.y)<1){if(n>0&&n+2l.y?270:90;if(Math.abs(r.y-l.y)<1)return r.x>l.x?180:0}return r.directionPoint(l)}_I(){if(this.Sy===null){this.Te||this.Mb();const t=this.Sy=[];this.tO(t)}}get flattenedLengths(){return this._I(),this.Sy}get flattenedTotalLength(){let t=this.Sb;if(isNaN(t)){const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=3){let g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e);m=this.adjustPoints(0,g,o-1,p),m&&(g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e),this.adjustPoints(0,g,o-1,p))}m||(this.clearPoints(),u?this.iO(i,e,r,s,n,l):this.eO(i,e,r,s,n,l))}else{const m=this.isAvoiding;d&&(c&&m||f)&&this.clearPoints();const g=f?this.computeCurviness():0,p=this.getLinkPoint(i,e,r,!0,c,s,n);let y=0,x=0,k=0;if(c||!h||f){let N=this.computeEndSegmentLength(i,e,r,!0);if(k=this.getLinkDirection(i,e,p,r,!0,c,s,n),f&&(h||r.equals(l)||!c&&r.x+l.x===1&&r.y+l.y===1)&&(k-=c?90:30,g<0&&(k-=180)),k<0?k+=360:k>=360&&(k-=360),f&&(N+=Math.abs(g)*(c?1:2)),k===0?y=N:k===90?x=N:k===180?y=-N:k===270?x=-N:(y=N*Math.cos(k*Math.PI/180),x=N*Math.sin(k*Math.PI/180)),r.isNoSpot()&&f){const T=e.getDocumentPoint(Spot.Center,Point.a()),L=Point.H(T.x+y*1e3,T.y+x*1e3);this.getLinkPointFromPoint(i,e,T,L,!0,p),Point.o(T),Point.o(L)}}const b=this.getLinkPoint(s,n,l,!1,c,i,e);let S=0,M=0,A=0;if(c||!a||f){let N=this.computeEndSegmentLength(s,n,l,!1);if(A=this.getLinkDirection(s,n,b,l,!1,c,i,e),f&&(a||r.equals(l)||!c&&r.x+l.x===1&&r.y+l.y===1)&&(A+=c?0:30,g<0&&(A+=180)),A<0?A+=360:A>=360&&(A-=360),f&&(N+=Math.abs(g)*(c?1:2)),A===0?S=N:A===90?M=N:A===180?S=-N:A===270?M=-N:(S=N*Math.cos(A*Math.PI/180),M=N*Math.sin(A*Math.PI/180)),l.isNoSpot()&&f){const T=n.getDocumentPoint(Spot.Center,Point.a()),L=Point.H(T.x+S*1e3,T.y+M*1e3);this.getLinkPointFromPoint(s,n,T,L,!1,b),Point.o(T),Point.o(L)}}let C=p;(c||!h||f)&&(C=new Point(p.x+y,p.y+x));let P=b;(c||!a||f)&&(P=new Point(b.x+S,b.y+M)),!d&&!c&&h&&o>3&&this.adjustPoints(0,p,o-2,P)?this.setPoint(o-1,b):!d&&!c&&a&&o>3&&this.adjustPoints(1,C,o-1,b)?this.setPoint(0,p):!d&&(c?o>=6:o>4)&&this.adjustPoints(1,C,o-2,P)?(this.setPoint(0,p),this.setPoint(o-1,b)):(this.clearPoints(),this.addPoint(p),(c||!h||f)&&this.addPoint(C),c&&this.addOrthoPoints(C,k,P,A,i,s),(c||!a||f)&&this.addPoint(P),this.addPoint(b))}return t.addInvalidRoute(this),!0}gN(t,i){return Math.abs(i.x-t.x)>Math.abs(i.y-t.y)?(i.x>=t.x?i.x=t.x+9e9:i.x=t.x-9e9,i.y=t.y):(i.y>=t.y?i.y=t.y+9e9:i.y=t.y-9e9,i.x=t.x),i}getLinkPointFromPoint(t,i,e,s,n,o){if(o===void 0&&(o=new Point),t===null||i===null)return o.c(e),o;if(!t.isVisible()){const u=t.findVisibleNode();u!==null&&u!==t&&(t=u,i=t.port)}let r=0,l=0,h=0,a=0,f=null,c=i.panel;if(c!==null&&!c.kn()&&(c=c.panel),c===null)r=s.x,l=s.y,h=e.x,a=e.y;else{f=c.Ks;const u=1/(f.m11*f.m22-f.m12*f.m21),d=f.m22*u,m=-f.m12*u,g=-f.m21*u,p=f.m11*u,y=u*(f.m21*f.dy-f.m22*f.dx),x=u*(f.m12*f.dx-f.m11*f.dy);r=s.x*d+s.y*g+y,l=s.x*m+s.y*p+x,h=e.x*d+e.y*g+y,a=e.x*m+e.y*p+x}return i.nc(r,l,h,a,o),f!==null&&o.O(f),o}sO(t,i){const e=t.sd;return e!==null?e.dT(i):null}Nb(t){let i=t.sd;return i===null&&(i=new Knot,i.sr=t,i.we=t.part,t.sd=i),i.dT(this)}getLinkPoint(t,i,e,s,n,o,r,l){if(l===void 0&&(l=new Point),e.isSpot()&&!this.Ud(e))return i.getDocumentPoint(e,l),l;if(e.isSide()){const f=this.Nb(i);if(f!==null){const c=f.Gd;if(l.c(c),n&&this.routing===7){const u=this.Nb(r);if(u!==null&&f.Dc=g.y&&y.y<=g.y+g.height?l.y=y.y:(e.includesSide(Spot.TopSide)||e.includesSide(Spot.BottomSide))&&y.x>=g.x&&y.x<=g.x+g.width&&(l.x=y.x),Point.o(d),Point.o(m)}}return l}}const h=i.getDocumentPoint(this.Cb(e,s),Point.a());let a=null;if(this.pointsCount>(n?6:2))a=s?this.getPoint(1):this.getPoint(this.pointsCount-2),n&&(a=this.gN(h,a.copy()));else{const f=this.computeSpot(!s,r),c=Point.a();a=r.getDocumentPoint(this.Cb(f,!s),c),n&&(a=this.gN(h,a)),Point.o(c)}return this.getLinkPointFromPoint(t,i,h,a,s,l),Point.o(h),l}getLinkDirection(t,i,e,s,n,o,r,l){let h=this.nO(t,i,e,s,n,o,r,l);if(r&&s.isNoSpot()&&r.isMemberOf(t)&&(h+=180,h>=360&&(h-=360)),this.Ud(s))return h;const a=i.getDocumentAngle();return a===0||(45<=a&&a<135?h+=90:135<=a&&a<225?h+=180:225<=a&&a<315&&(h+=270),h>=360&&(h-=360)),h}nO(t,i,e,s,n,o,r,l){if(s.isSpot())return s.x>s.y?s.x>1-s.y?0:s.x<1-s.y?270:315:s.x1-s.y?90:s.x<1-s.y?180:135:s.x<.5?225:s.x>.5?45:0;if(s.isSide()){const c=this.Nb(i);if(c!==null)switch(c.be){case 1:return 270;case 2:return 180;default:case 4:return 0;case 8:return 90}}const h=i.getDocumentPoint(Spot.Center,Point.a());let a=null;if(this.pointsCount>(o?6:2))a=n?this.getPoint(1):this.getPoint(this.pointsCount-2),o?a=this.gN(h,a.copy()):a=e;else{const c=Point.a();a=l.getDocumentPoint(Spot.Center,c),Point.o(c)}let f=0;return Math.abs(a.x-h.x)>Math.abs(a.y-h.y)?a.x>=h.x?f=0:f=180:a.y>=h.y?f=90:f=270,Point.o(h),f}computeEndSegmentLength(t,i,e,s){if(i!==null&&e.isSide()){const o=this.Nb(i);if(o!==null)return o.Ab}let n=NaN;return s?n=this.fromEndSegmentLength:n=this.toEndSegmentLength,i!==null&&isNaN(n)&&(s?n=i.fromEndSegmentLength:n=i.toEndSegmentLength),isNaN(n)&&(n=10),n}computeSpot(t,i){return i===void 0&&(i=null),t?this.oO(i||this.fromPort):this.rO(i||this.toPort)}oO(t){if(t===null)return Spot.Center;let i=this.fromSpot;return i.isDefault()&&(i=t.fromSpot),i===Spot.Default?Spot.None:i}rO(t){if(t===null)return Spot.Center;let i=this.toSpot;return i.isDefault()&&(i=t.toSpot),i===Spot.Default?Spot.None:i}Ud(t){return t===Spot.None||t.x===.5&&t.y===.5}Cb(t,i){return t.x===.5&&t.y===.5?t:Spot.Center}computeOtherPoint(t,i){if(this.computeAdjusting()!==0&&this.pointsCount>4)return this.computeMidPoint(new Point);{const e=this.sO(i,this);return e!==null?e.Gd:i.getDocumentPoint(Spot.Center)}}computeShortLength(t){if(t){let i=this.fromShortLength;if(isNaN(i)){const e=this.fromPort;e!==null&&(i=e.fromShortLength)}return isNaN(i)?0:i}else{let i=this.toShortLength;if(isNaN(i)){const e=this.toPort;e!==null&&(i=e.toShortLength)}return isNaN(i)?0:i}}Ym(t,i,e,s,n,o){if(this.pickable===!1)return!1;i===void 0&&(i=null),e===void 0&&(e=null);let r=o;if(o===void 0&&(r=Transform.a(),r.Vi()),r.af(this.O),this.containedInRect(t,r))return this.z2(i,e,n),o===void 0&&Transform.o(r),!0;if(this.intersectsRect(t,r)){let l=!1;if(!this.mc){const h=this.D.h,a=h.length;for(let f=a;f--;){const c=h[f];if(!c.visible&&c!==this.locationObject)continue;const u=c.actualBounds,d=this.naturalBounds;if(u.x>d.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;const m=c,g=Transform.a();if(g.set(r),m instanceof Panel?l=m.Ym(t,i,e,s,n,g):this.path===m?m instanceof Shape&&(l=m.LI(t,s,g)):l=m.rL(t,s,g),l){let p=m;i!==null&&(p=i(m)),p&&(e===null||e(p))&&n.add(p)}Transform.o(g)}}return o===void 0&&Transform.o(r),l||this.background!==null}return o===void 0&&Transform.o(r),!1}get isOrthogonal(){return(this.Ba&2)===2}static cN(t){return(t&2)===2}get isAvoiding(){return(this.Ba&4)===4}computeCurve(){if(this.ir===null){const t=this.fromPort,i=t!==null&&t===this.toPort,e=this.isOrthogonal;this.ir=i&&!e}return this.ir?9:this.curve}computeCorner(){if(this.curve===9)return 0;let t=this.corner;return(isNaN(t)||t<0)&&(t=10),t}findMidLabel(){const t=this.path,i=this.D.h,e=i.length;for(let n=0;n0?g-=c:g+=c;else{const p=-h/a;let y=Math.sqrt(c*c/(p*p+1));f<0&&(y=-y),m=(a<0?-1:1)*y+u,g=p*(m-u)+d}this.addPoint(r),this.addPointAt(m,g),this.addPoint(l)}else{this.addPoint(r),this.addPoint(l);const h=Rect.a();i.getDocumentBounds(h);const a=h.containsPoint(l);n.getDocumentBounds(h);const f=h.containsPoint(r);if(a||f){const c=i.getDocumentPoint(this.Cb(e,!0),new Point);this.setPoint(0,this.getLinkPointFromPoint(t,i,c,l,!0,c));const u=n.getDocumentPoint(this.Cb(o,!1),new Point);this.setPoint(1,this.getLinkPointFromPoint(s,n,u,r,!1,u))}Rect.o(h)}}iO(t,i,e,s,n,o){const r=this.getLinkPoint(t,i,e,!0,!1,s,n),l=this.getLinkPoint(s,n,o,!1,!1,t,i),h=l.x-r.x,a=l.y-r.y,f=this.computeCurviness();let c=0,u=0,d=r.x+h/3,m=r.y+a/3,g=d,p=m;Geo.p(a,0)?h>0?p-=f:p+=f:(c=-h/a,u=Math.sqrt(f*f/(c*c+1)),f<0&&(u=-u),g=(a<0?-1:1)*u+d,p=c*(g-d)+m),d=r.x+2*h/3,m=r.y+2*a/3;let y=d,x=m;Geo.p(a,0)?h>0?x-=f:x+=f:(y=(a<0?-1:1)*u+d,x=c*(y-d)+m),this.clearPoints(),this.addPoint(r),this.addPointAt(g,p),this.addPointAt(y,x),this.addPoint(l),this.setPoint(0,this.getLinkPoint(t,i,e,!0,!1,s,n)),this.setPoint(3,this.getLinkPoint(s,n,o,!1,!1,t,i))}adjustPoints(t,i,e,s){let n=this.computeAdjusting();if(this.isOrthogonal){if(n===18)return!1;n===19&&(n=17)}switch(n){case 18:return this.lO(t,i,e,s);case 19:return this.hO(t,i,e,s);case 17:return this.aO(t,i,e,s);default:return!1}}lO(t,i,e,s){const n=this.getPoint(t),o=this.getPoint(e);if(n.equalsApprox(i)&&o.equalsApprox(s))return!0;const r=n.x,l=n.y,h=o.x,a=o.y;let f=h-r,c=a-l;const u=Math.sqrt(f*f+c*c);if(Geo.q(u,0))return!0;let d=0;Geo.q(f,0)?c<0?d=-Math.PI/2:d=Math.PI/2:(d=Math.atan(c/Math.abs(f)),f<0&&(d=Math.PI-d));const m=i.x,g=i.y,p=s.x,y=s.y,x=p-m,k=y-g,b=Math.sqrt(x*x+k*k);let S=0;Geo.q(x,0)?k<0?S=-Math.PI/2:S=Math.PI/2:(S=Math.atan(k/Math.abs(x)),x<0&&(S=Math.PI-S));const M=b/u,A=S-d;this.setPoint(t,i);for(let C=t+1;C0&&(C=-C);const P=c+S*(d-c),N=u+S*(m-u);if(g!==0){const T=P+C/p,L=N-(T-P)/g;this.setPointAt(y,T,L)}else this.setPointAt(y,P,N+C)}return this.setPoint(e,s),!0}aO(t,i,e,s){if(this.isOrthogonal){let n=this.getPoint(t),o=this.getPoint(t+1),r=this.getPoint(t+2),l=o.x,h=o.y;const a=l,f=h;Geo.p(n.y,o.y)?Geo.p(o.x,r.x)?h=i.y:Geo.p(o.y,r.y)&&(l=i.x):Geo.p(n.x,o.x)&&(Geo.p(o.y,r.y)?l=i.x:Geo.p(o.x,r.x)&&(h=i.y)),this.setPointAt(t+1,l,h),n=this.getPoint(e),o=this.getPoint(e-1),r=this.getPoint(e-2);let c=o.x,u=o.y;const d=c,m=u;if(Geo.p(n.y,o.y)?Geo.p(o.x,r.x)?u=s.y:Geo.p(o.y,r.y)&&(c=s.x):Geo.p(n.x,o.x)&&(Geo.p(o.y,r.y)?c=s.x:Geo.p(o.x,r.x)&&(u=s.y)),this.setPointAt(e-1,c,u),this.EA())return this.setPointAt(t+1,a,f),this.setPointAt(e-1,d,m),!1}return this.setPoint(t,i),this.setPoint(e,s),!0}addOrthoPoints(t,i,e,s,n,o){i<0?i+=360:i>=360&&(i-=360),s<0?s+=360:s>=360&&(s-=360);const f=s;i>=315||i<45?i=0:45<=i&&i<135?i=90:135<=i&&i<225?i=180:i=270,s>=315||s<45?s=0:45<=s&&s<135?s=90:135<=s&&s<225?s=180:s=270;const c=t,u=e,d=n.actualBounds.copy(),m=o.actualBounds.copy();if(!d.isReal()||!m.isReal())return;d.inflate(Link.Xa,Link.Xa),m.inflate(Link.Xa,Link.Xa),d.unionPoint(t),m.unionPoint(e);const g=Point.a(),p=Point.a();i===0?u.x>c.x||s===270&&u.yc.x||s===90&&u.y>c.y&&m.right>c.x?(g.e(u.x,c.y),p.e(u.x,(c.y+u.y)/2),s===180?(g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1),p.x=g.x,p.y=u.y):s===270&&u.yc.y?(c.xm.bottom)?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):g.x=m.right,p.x=g.x,p.y=u.y):s===0&&c.xm.top&&c.yd.bottom)&&(s===180&&(m.containsPoint(c)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):u.yc.y&&(s===180||s===270)&&(g.y=this.computeMidOrthoPosition(c.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=d.left&&u.x<=c.x||c.x<=m.right&&c.x>=u.x?(s===90||s===270)&&(g.e(Math.max((c.x+u.x)/2,c.x),c.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yc.y&&m.leftc.y?(c.x>m.right?g.x=this.computeMidOrthoPosition(c.x,c.y,m.right,u.y,!1):c.x>m.left&&(s===270&&c.ym.bottom)?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):g.x=m.left,p.x=g.x,p.y=u.y):s===180&&c.x>m.right&&c.y>m.top&&c.yd.bottom)&&(s===0&&(m.containsPoint(c)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):u.yc.y&&(s===0||s===270)&&(g.y=this.computeMidOrthoPosition(c.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=c.x||c.x>=m.left&&c.x<=u.x?(s===90||s===270)&&(g.e(Math.min((c.x+u.x)/2,c.x),c.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yc.y||s===180&&u.xc.y||s===0&&u.x>c.x&&m.bottom>c.y?(g.e(c.x,u.y),p.e((c.x+u.x)/2,u.y),s===270?(g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0),p.x=u.x,p.y=g.y):s===180&&u.xc.x?(c.ym.right)?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):g.y=m.bottom,p.x=u.x,p.y=g.y):s===90&&c.ym.left&&c.xd.right)&&(s===270&&(m.containsPoint(c)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):u.xc.x&&(s===270||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,c.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=d.top&&u.y<=c.y||c.y<=m.bottom&&c.y>=u.y?(s===0||s===180)&&(g.e(c.x,Math.max((c.y+u.y)/2,c.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.xc.x&&m.top=c.x?(c.y>m.bottom?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,m.bottom,!0):c.y>m.top&&(s===180&&c.xm.right)?g.y=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!0):g.y=m.top,p.x=u.x,p.y=g.y):s===270&&c.y>m.bottom&&c.x>m.left&&c.xd.right)&&(s===90&&(m.containsPoint(c)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(c.x,c.y,u.x,u.y,!1):u.xc.x&&(s===90||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,c.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=c.y||c.y>=m.top&&c.y<=u.y?(s===0||s===180)&&(g.e(c.x,Math.min((c.y+u.y)/2,c.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.x=3&&!Geo.q(this.smoothness,0))if(i===3){let f=this.getPoint(1);n=Math.min(r.x,f.x),o=Math.min(r.y,f.y),f=this.getPoint(2),n=Math.min(n,f.x),o=Math.min(o,f.y)}else if(this.isOrthogonal){for(let f=0;f=i&&(f=i-1);const c=this.getPoint(f);l.x=Math.min(c.x,l.x),l.y=Math.min(c.y,l.y)}n=l.x,o=l.y}else{for(let f=0;f=3&&!Geo.q(this.smoothness,0))if(i===3){const c=this.getPoint(1),u=c.x-n,d=c.y-o;let m=this.getPoint(2).copy();m.x-=n,m.y-=o,this.computeShortLength(!1)!==0&&(m=this.Fc(m,!1,l)),f.wr(u,d,u,d,m.x,m.y)}else if(this.isOrthogonal){const c=Point.H(n,o),u=Point.a();u.c(this.getPoint(1));const d=Point.H(n,o),m=Point.H(n,o);let g=this.getPoint(0),p=null;const y=this.smoothness/3;for(let S=1;S=i&&(c=i-1);const d=this.getPoint(c-1);let m=this.getPoint(c);c===i-1&&this.computeShortLength(!1)!==0&&(m=this.Fc(m.copy(),!1,Point.Lo)),f.wr(u.x-n,u.y-o,d.x-n,d.y-o,m.x-n,m.y-o)}else{const c=Point.a();c.c(this.getPoint(0));const u=Point.a();u.c(c);const d=this.computeCorner();let m=1,g=0;for(;m1);let p=this.getPoint(m);if(m>=i-1){if(!c.equals(p))this.computeShortLength(!1)!==0&&(p=this.Fc(p.copy(),!1,Point.Lo)),this.Dn(f,-n,-o,c,p,e);else if(g===0)for(m=1;mr?c>a?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):c>a?(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.q(r,h)&&Geo.q(a,c)&&(a>l?f>h?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):f>h?(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.q(r,h)&&Geo.q(h,f)||Geo.q(l,a)&&Geo.q(a,c)){const m=.5*(r+f),g=.5*(l+c);n.x=m,n.y=g,o.x=m,o.y=g}}Fc(t,i,e){const s=this.pointsCount;if(s<2)return t;if(i){const n=this.getPoint(1),o=n.x-e.x,r=n.y-e.y,l=this.Lb(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!0);a>h&&(a=h);const f=a*(o-t.x)/l,c=a*(r-t.y)/l;t.x+=f,t.y+=c}else{const n=this.getPoint(s-2),o=n.x-e.x,r=n.y-e.y,l=this.Lb(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!1);a>h&&(a=h);const f=a*(t.x-o)/l,c=a*(t.y-r)/l;t.x-=f,t.y-=c}return t}mN(t,i,e){const s=this.pointsCount;let n=t;for(;Geo.q(t.x,n.x)&&Geo.q(t.y,n.y);){if(i>=s)return s-1;n=this.getPoint(i++)}if(!Geo.q(t.x,n.x)&&!Geo.q(t.y,n.y))return i-1;let o=n;for(;Geo.q(t.x,n.x)&&Geo.q(n.x,o.x)&&(!e||(t.y>=n.y?n.y>=o.y:n.y<=o.y))||Geo.q(t.y,n.y)&&Geo.q(n.y,o.y)&&(!e||(t.x>=n.x?n.x>=o.x:n.x<=o.x));){if(i>=s)return s-1;o=this.getPoint(i++)}return i-2}uO(t,i,e,s,n,o,r,l,h,a){if(Geo.p(s.y,n.y)&&Geo.p(n.x,o.x)){let f=Math.min(h,Math.abs(n.x-l.x)/2);const c=Math.min(f,Math.abs(o.y-n.y)/2);if(f=c,Geo.p(f,0)){this.Dn(t,i,e,s,n,a),r.c(n);return}let u=n.x;const d=n.y,m=u;let g=d;n.x>s.x?(u=n.x-f,o.y>n.y?g=n.y+c:g=n.y-c):(u=n.x+f,o.y>n.y?g=n.y+c:g=n.y-c);const p=Point.H(u,d);this.Dn(t,i,e,s,p,a),Point.o(p),t.Fw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else if(Geo.p(s.x,n.x)&&Geo.p(n.y,o.y)){let f=Math.min(h,Math.abs(n.y-l.y)/2);const c=Math.min(f,Math.abs(o.x-n.x)/2);if(f=c,Geo.p(c,0)){this.Dn(t,i,e,s,n,a),r.c(n);return}const u=n.x;let d=n.y,m=u;const g=d;n.y>s.y?(d=n.y-f,o.x>n.x?m=n.x+c:m=n.x-c):(d=n.y+f,o.x>n.x?m=n.x+c:m=n.x-c);const p=Point.H(u,d);this.Dn(t,i,e,s,p,a),Point.o(p),t.Fw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else this.Dn(t,i,e,s,n,a),r.c(n)}computeJumpLength(){return 10}Dn(t,i,e,s,n,o){if(o||!this.Ya())t.yr(n.x+i,n.y+e);else{const r=this.computeJumpLength(),l=r/2,h=[];let a=0;this.isVisible()&&(a=this.dO(s,n,h));let f=s.x,c=s.y;if(a>0){if(Geo.p(s.y,n.y))if(s.x=0;){const d=Math.min(s.x,Math.max(h[u--]+l,n.x+r));t.yr(d+i,n.y+e),f=d+i,c=n.y+e;let m=Math.max(d-r,n.x);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.x);else break}const g=n.y-r+e,p=m+i,y=n.y+e;this.curve===10?t.yu(p,y,!1,!1):t.wr(f,g,p,g,p,y),f=p,c=y}}else if(Geo.p(s.x,n.x))if(s.y=0;){const d=Math.min(s.y,Math.max(h[u--]+l,n.y+r));t.yr(n.x+i,d+e),f=n.x+i,c=d+e;let m=Math.max(d-r,n.y);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.y);else break}const g=n.x-r+i,p=n.x+i,y=m+e;this.curve===10?t.yu(p,y,!1,!1):t.wr(g,c,g,y,p,y),f=p,c=y}}}t.yr(n.x+i,n.y+e)}}dO(t,i,e){const s=this.diagram;if(s===null||t.equals(i))return 0;const n=s.layers;for(;n.next();){const o=n.value;if(o!==null&&o.visible){const r=o.HM(),l=r.length;for(let h=0;h0&&e.sort((u,d)=>u-d),e.length;if(!a.isVisible()||!a.Ya())continue;const f=a.routeBounds;if(!f.isReal()||!this.routeBounds.intersectsRect(f)||this.usesSamePort(a))continue;const c=a.path;c!==null&&c.isVisibleObject()&&this.gO(t,i,e,a)}}}return e.length>0&&e.sort((o,r)=>o-r),e.length}gO(t,i,e,s){const n=Geo.p(t.y,i.y),o=s.pointsCount;let r=s.getPoint(0);const l=Point.a();for(let h=1;hr.x&&f.x>=a.x||a.xr.y&&f.y>=a.y||a.yf&&Math.min(a,c)o&&!Geo.p(a,c))return n.x=o,n.y=f,!0}else if(Geo.p(r,h)&&Geo.p(a,c)&&Math.min(o,l)a&&Math.min(f,u)r&&!Geo.p(f,u))return n.x=a,n.y=r,!0;return n.x=0,n.y=0,!1}get firstPickIndex(){return this.pointsCount<=2?0:this.isOrthogonal||!this.Ud(this.computeSpot(!0))?1:0}get lastPickIndex(){const t=this.pointsCount;return t===0?0:t<=2?t-1:this.isOrthogonal||!this.Ud(this.computeSpot(!1))?t-2:t-1}Ya(){const t=this.curve;return t===11||t===10}Pb(t){if(t||this.Ya()){const i=this.diagram;i!==null&&!i.animationManager.isTicking&&!i.th.has(this)&&(this.Tc.width!==0||this.Tc.height!==0)&&i.th.set(this,this.Tc.copy())}}invalidateOtherJumpOvers(t){const i=this.layer;if(i===null||!i.visible||i.isTemporary)return;const e=i.diagram;if(e===null||e.animationManager.isTicking)return;let s=!1;const n=e.layers;for(;n.next();){const o=n.value;if(o.visible){if(o===i){s=!0;let r=!1;const l=o.HM(),h=l.length;for(let a=0;a0&&e>0){const s=this.getPoint(0),n=t.getPoint(0);if(s.equalsApprox(n))return!0;const o=this.getPoint(i-1),r=t.getPoint(e-1);if(o.equalsApprox(r)||s.equalsApprox(r)||o.equalsApprox(n))return!0}else if(this.fromNode===t.fromNode||this.toNode===t.toNode||this.fromNode===t.toNode||this.toNode===t.fromNode)return!0;return!1}isVisible(){if(!super.isVisible())return!1;const t=this.containingGroup;let i=!0;const e=this.diagram;e!==null&&(i=e.isTreePathToChildren);const s=this.fromNode;if(s!==null){if(this.isTreeLink&&i&&!s.isTreeExpanded)return!1;if(s===t)return!0;let o=s;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=s.findVisibleNode();if(r===null||r===t)return!1}const n=this.toNode;if(n!==null){if(this.isTreeLink&&!i&&!n.isTreeExpanded)return!1;if(n===t)return!0;let o=n;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=n.findVisibleNode();if(r===null||r===t)return!1}return!0}Ki(t){if(super.Ki(t),t&&this.Pb(!1),this.er!==null&&this.er.Ed(),this.$s!==null){const e=this.$s.iterator;for(;e.next();)e.value.Ki(t)}}get adjusting(){return this.Lc}set adjusting(t){const i=this.Lc;i!==t&&(Debug&&t!==0&&t!==17&&t!==18&&t!==19&&Util.n("Link.adjusting can only be set to None, End, Scale, or Stretch, not: "+t),this.Lc=t,this.i("adjusting",i,t))}computeAdjusting(){return this.isAvoiding&&this.diagram!==null&&this.diagram.animationManager.defaultAnimation.isAnimating?17:this.Lc}get corner(){return this.zd}set corner(t){const i=this.zd;i!==t&&(Debug&&Util.t(t,"number",Link,"corner"),this.zd=t,this.le(),this.i("corner",i,t))}get curve(){return this.Xd}set curve(t){const i=this.Xd;i!==t&&(Debug&&t!==0&&t!==9&&t!==10&&t!==11&&Util.n("Link.curve can only be set to None, Bezier, JumpGap, or JumpOver, not: "+t),this.Xd=t,this.invalidateRoute(),this.le(),this.Pb(i===10||i===11||t===10||t===11),this.i("curve",i,t))}get curviness(){return this.Yd}set curviness(t){const i=this.Yd;i!==t&&(Debug&&Util.t(t,"number",Link,"curviness"),this.Yd=t,this.invalidateRoute(),this.le(),this.i("curviness",i,t))}get routing(){return this.Ba}set routing(t){const i=this.Ba;i!==t&&(Debug&&t!==1&&t!==2&&t!==6&&t!==7&&Util.n("Link.routing can only be set to Normal, Orthogonal, AvoidsNodes, not: "+t),this.Ba=t,this.isAvoiding&&this.diagram!==null&&(this.diagram.Zm=!0),this.ir=null,this.invalidateRoute(),this.Pb(Link.cN(i)||Link.cN(t)),this.i("routing",i,t))}get smoothness(){return this.Kd}set smoothness(t){const i=this.Kd;i!==t&&(Debug&&Util.t(t,"number",Link,"smoothness"),this.Kd=t,this.le(),this.i("smoothness",i,t))}Py(){const t=this.go;if(t===null)return;const i=this.po;if(i===null||!isNaN(this.curviness))return;const e=this.mo,s=this.yo;let n=null,o=null;const r=t.ni.h,l=r.length;for(let h=0;h=0&&(Util.lf(t.Qs,i),t.Ed())}}Dl(){return!0}get key(){const t=this.diagram;if(!(t===null||!t.model.Ea()))return t.model.getKeyForLinkData(this.data)}}class LinkBundle{Ko;Xs;uy;sN;wb;nN;Qs;constructor(t,i,e,s){GSet.vi(this),this.Ko=!1,this.Xs=!1,this.uy=t,this.sN=i,this.wb=e,this.nN=s,this.Qs=[]}Ed(){if(!this.Ko){const t=this.Qs;if(t.length>0){const i=t[0].diagram;i!==null&&(i.mP.add(this),this.Xs=i.undoManager.isUndoingRedoing)}}this.Ko=!0}LP(){if(this.Ko){this.Ko=!1;const t=this.Qs;if(t.length>0){const i=t[0],e=i.diagram,s=e===null||e.Kh&&!this.Xs;this.Xs=!1,i.arrangeBundledLinks(t,s),t.length===1&&(i.er=null,t.length=0)}t.length===0&&(this.uy.nT(this),this.wb.nT(this))}}}class PositionArray{fe;ce;Ka;Ua;bi;ki;Yt;Mh;Ph;ua;YP;Ko;Cy;Qf;KP;UP;constructor(t){GSet.vi(this),this.ua=null,this.YP=null,this.Ko=!0,this.Cy=!1,this.fe=1,this.ce=1,this.Ka=-1,this.Ua=-1,this.bi=t.width,this.ki=t.height,this.Yt=null,this.Mh=0,this.Ph=0,this.Qf=11,this.KP=this.Qf*2,this.UP=this.Qf*2}static _s=0;static Ga=1;static Hd=999999;static pN=PositionArray.Hd+1;static yN=PositionArray.Hd+2;I1(t){if(t.width<=0||t.height<=0)return;const i=t.x,e=t.y,s=t.x+t.width,n=t.y+t.height;this.fe=Math.floor((i-this.bi)/this.bi)*this.bi,this.ce=Math.floor((e-this.ki)/this.ki)*this.ki,this.Ka=Math.ceil((s+2*this.bi)/this.bi)*this.bi,this.Ua=Math.ceil((n+2*this.ki)/this.ki)*this.ki;const o=1+(Math.ceil((this.Ka-this.fe)/this.bi)|0),r=1+(Math.ceil((this.Ua-this.ce)/this.ki)|0);if(this.Yt===null||this.Mh0&&t!==this.bi&&(this.bi=t,this.I1(this.bounds))}get cellHeight(){return this.ki}set cellHeight(t){t>0&&t!==this.ki&&(this.ki=t,this.I1(this.bounds))}qd(t,i){return this.fe<=t&&t<=this.Ka&&this.ce<=i&&i<=this.Ua}wo(t,i){if(!this.qd(t,i))return PositionArray.pN;t-=this.fe,t/=this.bi,i-=this.ce,i/=this.ki;const e=t|0,s=i|0;return this.Yt[e][s]}PR(t,i,e,s){if(!this.qd(t,i))return;const n=(t-this.fe)/this.bi|0,o=(i-this.ce)/this.ki|0,r=(t+e-this.fe)/this.bi|0,l=(i+s-this.ce)/this.ki|0,h=Math.min(r,this.Mh),a=Math.min(l,this.Ph);for(let f=n;f<=h;f++){const c=this.Yt[f];if(c.fill)c.fill(PositionArray._s,o,a+1);else for(let u=o;u<=a;u++)c[u]=PositionArray._s}}pO(t){if(this.Yt!==null)for(let i=0;i<=this.Mh;i++){const e=this.Yt[i];if(e.fill)e.fill(t);else for(let s=0;s<=this.Ph;s++)e[s]=t}}WA(){if(this.Yt!==null)for(let t=0;t<=this.Mh;t++){const i=this.Yt[t];for(let e=0;e<=this.Ph;e++)i[e]>=PositionArray.Ga&&(i[e]=PositionArray.pN)}}yO(t,i){return this.wo(t,i)===PositionArray._s}isUnoccupied(t,i,e,s){if(t>this.Ka||t+ethis.Ua||i+sthis.Ka||ithis.Ua||ethis.Ua||ithis.Ka||e=PositionArray.Ga&&h=a)break;this.Yt[t][i]=h,h+=1,s?i+=e:t+=e}return s?i:t}xo(t,i,e,s,n,o,r,l){if(to||il)return;const h=this.wO(t,i,e,s,n,o,r,l);if(s)if(e>0)for(let a=i+e;ah;a+=e)this.xo(t,a,1,!s,n,o,r,l),this.xo(t,a,-1,!s,n,o,r,l);else if(e>0)for(let a=t+e;ah;a+=e)this.xo(a,i,1,!s,n,o,r,l),this.xo(a,i,-1,!s,n,o,r,l)}Tb(t,i,e,s,n,o,r,l,h,a){let f=t|0,c=i|0,u=PositionArray._s,d=PositionArray.Ga;for(this.Yt[f][c]=d;u===PositionArray._s&&f>r&&fh&&cr&&fh&&c=0;I-=2){F=L[I+2],R=L[I+3];const O=L[I],V=L[I+1];for(;O>F?F++:OR?R++:Vs)d--;else break;else if(m>n)m--;else break;const g=f[d][m];if(g===0||g===PositionArray.yN)break;c=d,u=m}for(;;){let d=e,m=c,g=u;e===0?gn&&(d=270,g--):e===90?ms&&(d=180,m--):e===180?gn&&(d=270,g--):ms&&(d=180,m--);const p=f[m][g];if(d!==e&&p!==0&&p!==PositionArray.yN){if(o.push(c),o.push(u),this.pT(c,u,d,s,n,o))return!0;o.pop(),o.pop()}if(f[c][u]=PositionArray.yN,e===0){if(c===t)return!1;c--}else if(e===90){if(u===i)return!1;u--}else if(e===180){if(c===t)return!1;c++}else{if(u===i)return!1;u++}}}}class Knot{we;sr;cs;jd;constructor(){GSet.vi(this),this.we=null,this.sr=null,this.cs=[],this.jd=!1}toString(){const t=this.cs;let i=this.we.toString()+" "+t.length.toString()+":";for(let e=0;e180?270:90;case 6:return o>90&&o<=270?180:0}const r=Math.atan2(t.height,t.width)*180/Math.PI;switch(n){case 3:return o>r&&o<=180+r?180:270;case 5:return o>180-r&&o<=360-r?270:0;case 12:return o>r&&o<=180+r?90:0;case 10:return o>180-r&&o<=360-r?180:90;case 7:return o>90&&o<=180+r?180:o>180+r&&o<=360-r?270:0;case 13:return o>180&&o<=360-r?270:o>r&&o<=180?90:0;case 14:return o>r&&o<=180-r?90:o>180-r&&o<=270?180:0;case 11:return o>180-r&&o<=180+r?180:o>180+r?270:90}return s&&n!==15&&(o-=15,o<0&&(o+=360)),o>r&&o<180-r?90:o>=180-r&&o<=180+r?180:o>180+r&&o<360-r?270:0}Ed(){this.cs.length=0}dT(t){let i=this.cs;i.length===0&&(this.bO(),i=this.cs);for(let e=0;e=360&&(M-=360);const A=this.xO(h,y,M,g.isOrthogonal);let C=0;A===0?(C=4,M>180&&(M-=360)):A===90?(C=8,M>270&&(M-=360)):A===180?C=2:(C=1,M<90&&(M+=360));let P=this.cs[o];P===void 0?(P=new LinkInfo(g,M,C),this.cs[o]=P):(P.$e=g,P.jt=M,P.be=C),P.Fb.set(S),o++}Point.o(a),this.kO();const u=this.cs.length;let d=-1,m=0;for(o=0;o=0;o--){const g=this.cs[o];g!==void 0&&(g.be!==d&&(d=g.be,m=g.Wd+1),g.Dc=m)}this.SO(this.cs),this.MO(this.cs),this.jd=t,Rect.o(h)}return this.cs}PO(t,i){return t===i?0:t===null?-1:i===null?1:t.bei.be?1:t.jti.jt?1:0}kO(){this.cs.sort(Knot.prototype.PO)}SO(t){const i=this.sr,e=this.we.portSpreading,s=Point.a(),n=Point.a(),o=Point.a(),r=Point.a();i.getDocumentPoint(Spot.TopLeft,s),i.getDocumentPoint(Spot.TopRight,n),i.getDocumentPoint(Spot.BottomRight,o),i.getDocumentPoint(Spot.BottomLeft,r);let l=0,h=0,a=0,f=0;if(e===2)for(let x=0;xMath.abs(p)?(d=Math.abs(p)/a,a=Math.abs(p)):d=1;break;case 2:f>Math.abs(y)?(d=Math.abs(y)/f,f=Math.abs(y)):d=1;break;case 1:l>Math.abs(p)?(d=Math.abs(p)/l,l=Math.abs(p)):d=1;break;default:case 4:h>Math.abs(y)?(d=Math.abs(y)/h,h=Math.abs(y)):d=1;break}u=0}const b=k.Gd;if(e===2){let S=k.$e.computeThickness();switch(S*=d,b.set(m),c){case 8:b.x=m.x+p/2+a/2-u-S/2;break;case 2:b.y=m.y+y/2+f/2-u-S/2;break;case 1:b.x=m.x+p/2-l/2+u+S/2;break;default:case 4:b.y=m.y+y/2-h/2+u+S/2;break}u+=S}else{let S=.5;e===1&&(S=(k.Wd+1)/(k.Dc+1)),b.x=m.x+p*S,b.y=m.y+y*S}}Point.o(s),Point.o(n),Point.o(o),Point.o(r)}MO(t){for(let i=0;ie instanceof Placeholder);i instanceof Placeholder?t.Et=i:t.Et=null,this.re!==null?(t.re=this.re.copy(),t.re.group=t):(t.re!==null&&(t.re.group=null),t.re=null),this.hi!==null&&(t.hi=this.hi.copy())}Ho(t){super.Ho(t);const i=t.findSubGraphParts(),e=t.memberParts;for(;e.next();){const s=e.value;if(s.u(),s.invalidateLayout(8),s.clearAdornments(),s instanceof Node)s.invalidateConnectedLinks(i);else if(s instanceof Link){const n=s.labelNodes;for(;n.next();)n.value.invalidateConnectedLinks(i)}}}ec(t,i,e,s,n,o,r){if(t===3&&i==="elements"){if(n instanceof Placeholder)this.Et===null?this.Et=n:this.Et!==n&&Util.n("Cannot insert a second Placeholder into the visual tree of a Group.");else if(n instanceof Panel){const l=n.findInVisualTree(h=>h instanceof Placeholder);l instanceof Placeholder&&(this.Et===null?this.Et=l:this.Et!==l&&Util.n("Cannot insert a second Placeholder into the visual tree of a Group."))}}else t===4&&i==="elements"&&this.Et!==null&&(s===this.Et?this.Et=null:s instanceof Panel&&this.Et.isContainedBy(s)&&(this.Et=null));super.ec(t,i,e,s,n,o,r)}hd(t,i){if(super.hd(t,i),this.isClipping&&this.type!==Panel.Spot&&this.isSubGraphExpanded){let e=this.resizeObject;e instanceof Panel&&(e=e.findMainElement()),this.hi===null&&(this.hi=new Rect),e.getDocumentBounds(this.hi),e instanceof Shape&&this.hi.inflate(-e.strokeWidth,-e.strokeWidth)}}dh(t,i,e,s){this.hasPlaceholder()&&(this.tr=this.placeholder),super.dh(t,i,e,s)}ensureBounds(){this.isSubGraphExpanded&&this.memberParts.each(i=>{i.ensureBounds()}),super.ensureBounds()}$r(){if(!super.$r())return!1;const t=this.memberParts;for(;t.next();){const i=t.value;if(i instanceof Node){if(!i.isVisible())continue;if(i.rs())return!1}else if(i instanceof Link){if(!i.isVisible())continue;if(i.rs()&&i.fromNode!==this&&i.toNode!==this)return!1}}return!0}hasPlaceholder(){return this.Et!==null&&this.Et.isVisibleObject()&&this.isSubGraphExpanded}get placeholder(){return this.Et}get computesBoundsAfterDrag(){return(this.z&2048)!==0}set computesBoundsAfterDrag(t){const i=(this.z&2048)!==0;i!==t&&(Util.t(t,"boolean",Group,"computesBoundsAfterDrag"),this.z=this.z^2048,this.i("computesBoundsAfterDrag",i,t))}get computesBoundsIncludingLinks(){return(this.z&4096)!==0}set computesBoundsIncludingLinks(t){Util.t(t,"boolean",Group,"computesBoundsIncludingLinks");const i=(this.z&4096)!==0;i!==t&&(this.z=this.z^4096,this.i("computesBoundsIncludingLinks",i,t))}get computesBoundsIncludingLocation(){return(this.z&8192)!==0}set computesBoundsIncludingLocation(t){Util.t(t,"boolean",Group,"computesBoundsIncludingLocation");const i=(this.z&8192)!==0;i!==t&&(this.z=this.z^8192,this.i("computesBoundsIncludingLocation",i,t))}get handlesDragDropForMembers(){return(this.z&16384)!==0}set handlesDragDropForMembers(t){Util.t(t,"boolean",Group,"handlesDragDropForMembers");const i=(this.z&16384)!==0;i!==t&&(this.z=this.z^16384,this.i("handlesDragDropForMembers",i,t))}get avoidableMembers(){return(this.z&131072)!==0}set avoidableMembers(t){Util.t(t,"boolean",Group,"avoidableMembers");const i=(this.z&131072)!==0;i!==t&&(this.z=this.z^131072,this.i("avoidableMembers",i,t))}get memberParts(){return this.vd.iterator}_2(t){if(this.vd.add(t)){t instanceof Group&&this.ca.add(t);const e=this.memberAdded;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.j,n.j=!0),e(this,t),n!==null&&(n.j=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ki(!1)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.Et;i===null&&(i=this),i.u()}Q2(t){if(this.vd.delete(t)){t instanceof Group&&this.ca.delete(t);const e=this.memberRemoved;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.j,n.j=!0),e(this,t),n!==null&&(n.j=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ki(!0)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.Et;i===null&&(i=this),i.u()}Zf(){if(this.vd.count>0){const t=this.diagram;if(t!==null){const e=this.vd.copy().iterator;for(;e.next();){const s=e.value;t.remove(s)}}}super.Zf()}get layout(){return this.re}set layout(t){const i=this.re;if(i!==t){t!==null&&(Util.s(t,Layout,Group,"layout"),t.diagram!==null&&t.diagram.layout===t&&Util.n("A layout cannot be both the Diagram.layout and a Group.layout: "+t)),i!==null&&(i.diagram=null,i.group=null),this.re=t;const e=this.diagram;t!==null&&(t.diagram=e,t.group=this),e!==null&&(e.Wr=!0),this.i("layout",i,t),e!==null&&e.requestUpdate()}}get memberAdded(){return this.bt!==null?this.bt.xy:null}set memberAdded(t){const i=this.memberAdded;i!==t&&(t!==null&&Util.t(t,"function",Group,"memberAdded"),this.ml(),this.bt.xy=t,this.i("memberAdded",i,t))}get memberRemoved(){return this.bt!==null?this.bt.by:null}set memberRemoved(t){const i=this.memberRemoved;i!==t&&(t!==null&&Util.t(t,"function",Group,"memberRemoved"),this.ml(),this.bt.by=t,this.i("memberRemoved",i,t))}get memberValidation(){return this.bt!==null?this.bt.rh:null}set memberValidation(t){const i=this.memberValidation;i!==t&&(t!==null&&Util.t(t,"function",Group,"memberValidation"),this.ml(),this.bt.rh=t,this.i("memberValidation",i,t))}canAddMembers(t){const i=this.diagram;if(i===null)return!1;const e=i.commandHandler,n=e.c2(t).iterator;for(;n.next();){const o=n.value;if(!e.isValidMember(this,o))return!1}return!0}addMembers(t,i){const e=this.diagram;if(e===null)return!1;const s=e.commandHandler,n=s.c2(t);let o=!0;const r=n.iterator;for(;r.next();){const l=r.value;!i||s.isValidMember(this,l)?l.containingGroup=this:o=!1}return o}get ungroupable(){return(this.z&256)!==0}set ungroupable(t){const i=(this.z&256)!==0;i!==t&&(Util.t(t,"boolean",Group,"ungroupable"),this.z=this.z^256,this.i("ungroupable",i,t))}canUngroup(){if(!this.ungroupable)return!1;const t=this.layer;if(t===null||!t.allowUngroup)return!1;const i=t.diagram;return!(i!==null&&!i.allowUngroup)}invalidateConnectedLinks(t){const i=this.CO();if(super.invalidateConnectedLinks(t),i)return;this.LA(!0);const e=this.findExternalLinksConnected();for(;e.next();){const s=e.value;if(t!==void 0&&t.has(s))continue;const n=s.fromNode;if(n!==null&&n!==this&&n.isMemberOf(this)&&!n.isVisible())n._i(s.fromPort),n._i(s.toPort),s.invalidateRoute();else{const o=s.toNode;o!==null&&o!==this&&o.isMemberOf(this)&&!o.isVisible()&&(o._i(s.fromPort),o._i(s.toPort),s.invalidateRoute())}}}findExternalLinksConnected(){const t=this.diagram!==null&&this.diagram.kP;if(t&&this.x0!==null)return this.x0.iterator;const i=this.findSubGraphParts();i.add(this);const e=new GSet,s=i.iterator;for(;s.next();){const n=s.value;if(!(n instanceof Node))continue;const o=n.linksConnected;for(;o.next();){const r=o.value;i.has(r)||e.add(r)}}return t&&(this.x0=e),e.iterator}findExternalNodesConnected(){const t=this.findSubGraphParts();t.add(this);const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;if(!(s instanceof Node))continue;const n=s.linksConnected;for(;n.next();){const o=n.value,r=o.fromNode;r!==null&&(!t.has(r)||r===this)&&i.add(r);const l=o.toNode;l!==null&&(!t.has(l)||l===this)&&i.add(l)}}return i.iterator}pE(){function t(e,s){e!==null&&(s.add(e),t(e.containingGroup,s))}const i=new GSet;return t(this,i),i}findSubGraphParts(){const t=new GSet;return Part.lh(t,this,!0,0,!0),t.delete(this),t}Ki(t){super.Ki(t);const i=this.memberParts;for(;i.next();)i.value.Ki(t)}collapseSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.yT(i,t,this),t.isCollapsingExpanding=!1}yT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ki(!1),n instanceof Group&&n.isSubGraphExpanded&&(n.wasSubGraphExpanded=n.isSubGraphExpanded,n.yT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t),i.Ef(n,e);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!1}expandSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.wT(i,t,this),t.isCollapsingExpanding=!1}wT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ki(!0),n instanceof Group&&n.wasSubGraphExpanded&&(n.wasSubGraphExpanded=!1,n.wT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!0}get isSubGraphExpanded(){return(this.z&512)!==0}set isSubGraphExpanded(t){const i=(this.z&512)!==0;if(i!==t){Util.t(t,"boolean",Group,"isSubGraphExpanded"),this.z=this.z^512;const e=this.diagram;this.i("isSubGraphExpanded",i,t);const s=this.subGraphExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.j,e.j=!0),s(this),e!==null&&(e.j=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.Et!==null&&this.Et.u(),this.memberParts.each(n=>n.updateAdornments());return}t?this.expandSubGraph():this.collapseSubGraph()}}get wasSubGraphExpanded(){return(this.z&1024)!==0}set wasSubGraphExpanded(t){const i=(this.z&1024)!==0;i!==t&&(Util.t(t,"boolean",Group,"wasSubGraphExpanded"),this.z=this.z^1024,this.i("wasSubGraphExpanded",i,t))}get subGraphExpandedChanged(){return this.bt!==null?this.bt.ky:null}set subGraphExpandedChanged(t){const i=this.subGraphExpandedChanged;i!==t&&(t!==null&&Util.t(t,"function",Group,"subGraphExpandedChanged"),this.ml(),this.bt.ky=t,this.i("subGraphExpandedChanged",i,t))}move(t,i){i===void 0&&(i=!1);const e=i?this.location:this.position,s=e.x,n=e.y,o=t.x,r=t.y;if((s===o||isNaN(s)&&isNaN(o))&&(n===r||isNaN(n)&&isNaN(r)))return;const l=o-(isNaN(s)?0:s),h=r-(isNaN(n)?0:n),a=Point.a();super.move(t,i);const f=new GSet,u=this.findSubGraphParts().iterator;for(;u.next();){const d=u.value;d instanceof Link&&(d.suspendsRouting&&f.add(d),!(!d.Te&&(d.fromNode===this||d.toNode===this))&&(d.suspendsRouting=!0))}for(u.reset();u.next();){const d=u.value;if(d.Dl()||d instanceof Node&&d.isLinkLabel)continue;const m=d.position,g=d.location;m.isReal()?(a.x=m.x+l,a.y=m.y+h,d.position=a):g.isReal()&&(a.x=g.x+l,a.y=g.y+h,d.location=a)}for(u.reset();u.next();){const d=u.value;if(!(d instanceof Link)||(d.suspendsRouting=f.has(d),!d.Te&&(d.fromNode===this||d.toNode===this)))continue;const m=d.position;a.x=m.x+l,a.y=m.y+h,a.isReal()?d.move(a):d.invalidateRoute()}Point.o(a)}CO(){return(this.z&65536)!==0}LA(t){(this.z&65536)!==0!==t&&(this.z=this.z^65536)}get tl(){return(this.z&32768)!==0}set tl(t){(this.z&32768)!==0!==t&&(this.z=this.z^32768)}}class Placeholder extends GraphObject{ii;Jd;constructor(t){super(),this.ii=Margin.Hg,this.Jd=new Rect(NaN,NaN,NaN,NaN),t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.ii=this.ii.L(),t.Jd=this.Jd.copy()}uh(t){if(this.background===null)return!1;const i=this.naturalBounds;return Rect.contains(0,0,i.width,i.height,t.x,t.y)}rd(t,i,e,s){const n=this.part;if((n===null||!(n instanceof Group)&&!(n instanceof Adornment))&&Util.n("Placeholder is not inside a Group or Adornment."),n instanceof Group){const o=this.computeBorder(this.Jd),r=this.minSize,l=isFinite(r.width)?Math.max(r.width,o.width):o.width,h=isFinite(r.height)?Math.max(r.height,o.height):o.height,a=this.Hi;a.Kn(l||0,h||0),this.no(0,0,a.width,a.height);const f=n.memberParts;let c=!1;for(;f.next();)if(f.value.isVisible()){c=!0;break}const u=n.diagram;if(c&&u!==null&&!u.animationManager.OM(n)&&!isNaN(o.x)&&!isNaN(o.y)){const d=Point.a();d.setRectSpot(o,n.locationSpot),n.location=d,Point.o(d)}}else{const o=n,r=this.Hi,l=this.ii,h=l.left+l.right,a=l.top+l.bottom,f=o.adornedObject,c=f.getDocumentAngle();o.angle=c;let u=0;f instanceof Shape&&(u=f.strokeWidth);const d=f.getDocumentScale(),m=f.naturalBounds,g=(m.width+u)*d,p=(m.height+u)*d;if(o.type!==Panel.Link){const y=o.category==="Selection"?Spot.TopLeft:o.locationSpot,x=f.getDocumentPoint(y,Point.a());o.location=x,Point.o(x)}if(!isNaN(g)&&!isNaN(p))r.Kn(g+h||0,p+a||0),this.no(-l.left,-l.top,r.width,r.height);else{const y=f.getDocumentPoint(Spot.TopLeft,Point.a()),x=Rect.H(y.x,y.y,0,0);x.unionPoint(f.getDocumentPoint(Spot.BottomRight,y)),x.unionPoint(f.getDocumentPoint(Spot.TopRight,y)),x.unionPoint(f.getDocumentPoint(Spot.BottomLeft,y)),r.Kn(x.width+h||0,x.height+a||0),this.no(-l.left,-l.top,r.width,r.height),Point.o(y),Rect.o(x)}}}dh(t,i,e,s){this.actualBounds.e(t,i,e,s)}computeBorder(t){const i=this.part,e=i.diagram,s=e===null||!e.animationManager.isAnimating;if(e!==null&&i instanceof Group&&!i.layer.isTemporary&&i.computesBoundsAfterDrag&&this.Jd.isReal()){const l=e.toolManager.findTool("Dragging");if(l===e.currentTool){const h=l.computeBorder(i,this.Jd,t);if(h!==null)return h}}const n=Rect.a(),o=this.computeMemberBounds(n),r=this.ii;return i instanceof Group&&!i.isSubGraphExpanded?t.e(o.x-r.left,o.y-r.top,0,0):t.e(o.x-r.left,o.y-r.top,Math.max(o.width+r.left+r.right,0),Math.max(o.height+r.top+r.bottom,0)),Rect.o(n),s&&i instanceof Group&&i.computesBoundsIncludingLocation&&i.location.isReal()&&t.unionPoint(i.location),t}computeMemberBounds(t){if(!(this.part instanceof Group))return t.e(0,0,0,0),t;const i=this.part;let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=i.memberParts;for(;r.next();){const l=r.value;if(!l.isVisible()||l instanceof Link&&(!i.computesBoundsIncludingLinks||l.Xo()||l.fromNode===i||l.toNode===i))continue;const h=l.actualBounds;h.leftn&&(n=h.right),h.bottom>o&&(o=h.bottom)}if(!isFinite(e)||!isFinite(s)){const l=i.location;t.e(l.x,l.y,0,0)}else t.e(e,s,n-e,o-s);return t}get padding(){return this.ii}set padding(t){typeof t=="number"?t=new Margin(t):Util.s(t,Margin,Placeholder,"padding");const i=this.ii;i.equals(t)||(t=t.L(),this.ii=t,this.i("padding",i,t),this.u())}}class Layout{b;ua;Zd;Cr;$d;Qd;Bo;pl;_d;tg;bo;constructor(t){GSet.vi(this),this.b=null,this.ua=null,this.Zd=!0,this.Cr=!0,this.$d=!1,this.Qd=new Point(0,0).w(),this.Bo=!0,this.pl=null,this._d=null,this.tg=!1,this.bo=null,t&&Object.assign(this,t)}cloneProtected(t){t.Zd=this.Zd,t.Cr=this.Cr,t.$d=this.$d,t.Qd.c(this.Qd),t.Bo=this.Bo,t.pl=this.pl,t._d=this._d,t.tg=!0}copy(){const t=new this.constructor;return this.cloneProtected(t),t}fi(t){Util.ur(this,t)}toString(){let t=Util.hn(this.constructor);return t+="(",this.group!==null&&(t+=" in "+this.group),this.diagram!==null&&(t+=" for "+this.diagram),t+=")",t}get diagram(){return this.b}set diagram(t){t!==null&&Util.s(t,Diagram,Layout,"diagram"),this.b=t}get group(){return this.ua}set group(t){this.ua!==t&&(t!==null&&Util.s(t,Group,Layout,"group"),this.ua=t,t!==null&&(this.b=t.diagram))}get isOngoing(){return this.Zd}set isOngoing(t){this.Zd!==t&&(Util.t(t,"boolean",Layout,"isOngoing"),this.Zd=t)}get isInitial(){return this.Cr}set isInitial(t){Util.t(t,"boolean",Layout,"isInitial"),this.Cr=t,t||(this.tg=!0)}get isViewportSized(){return this.$d}set isViewportSized(t){this.$d!==t&&(Util.t(t,"boolean",Layout,"isViewportSized"),this.$d=t,t&&this.invalidateLayout())}get isRouting(){return this.Bo}set isRouting(t){this.Bo!==t&&(Util.t(t,"boolean",Layout,"isRouting"),this.Bo=t)}get isRealtime(){return this.pl}set isRealtime(t){this.pl!==t&&(t!==null&&Util.t(t,"boolean",Layout,"isRealtime"),this.pl=t)}get isValidLayout(){return this.tg}set isValidLayout(t){if(this.tg!==t&&(Util.t(t,"boolean",Layout,"isValidLayout"),this.tg=t,!t)){const i=this.diagram;i!==null&&(i.Wr=!0)}}invalidateLayout(){if(this.isValidLayout){const t=this.diagram;if(t===null||t.undoManager.isUndoingRedoing)return;const i=t.animationManager;if(i.isTicking)return;i.defaultAnimation.isAnimating&&i.stopAnimation(),(this.isOngoing&&t.Kh||this.isInitial&&!t.Kh)&&(this.isValidLayout=!1,t.requestUpdate())}}get network(){return this.bo}set network(t){this.bo!==t&&(t!==null&&Util.s(t,LayoutNetwork,Layout,"network"),this.bo=t,t!==null&&(t.layout=this))}createNetwork(){return new LayoutNetwork(this)}makeNetwork(t){const i=this.createNetwork();return t instanceof Diagram?(i.addParts(t.nodes,!0),i.addParts(t.links,!0)):t instanceof Group?i.addParts(t.memberParts):i.addParts(t.iterator),i}updateParts(){this.isValidLayout=!0;let t=this.diagram;if(t===null&&this.network!==null){const i=this.network.vertexes.iterator;for(;i.next();){const s=i.value.node;if(s!==null&&(t=s.diagram,t!==null))break}}try{t!==null&&t.startTransaction("Layout"),this.commitLayout()}finally{t!==null&&t.commitTransaction("Layout")}}commitLayout(){if(this.network===null)return;const t=this.network.vertexes.iterator;for(;t.next();)t.value.commit();if(this.isRouting){const i=this.network.edges.iterator;for(;i.next();)i.value.commit()}}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts");const i=new GSet;if(t instanceof Diagram?(this.Nh(i,t.nodes,!0,this.tl,!0,!1,!0),this.Nh(i,t.parts,!0,this.tl,!0,!1,!0)):t instanceof Group?this.Nh(i,t.memberParts,!1,this.tl,!0,!1,!0):i.addAll(t.iterator),i.count>0){const s=this.diagram;s!==null&&s.startTransaction("Layout"),this.doMinimalNoNetworkLayout(i),s!==null&&s.commitTransaction("Layout")}this.isValidLayout=!0}doMinimalNoNetworkLayout(t){const i=t.count,e=Math.ceil(Math.sqrt(i));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const s=this.arrangementOrigin.x,n=this.arrangementOrigin.y;let o=s,r=n,l=0,h=0;const a=t.iterator;for(;a.next();){const f=a.value;f.ensureBounds();const c=f.measuredBounds,u=c.width,d=c.height;f.moveTo(o,r),f instanceof Group&&(f.tl=!1),o+=Math.max(u,50)+20,h=Math.max(h,Math.max(d,50)),l>=e-1?(l=0,o=s,r+=h+20,h=0):l++}}doMinimalNetworkLayout(){const t=this.network.vertexes.count,i=Math.ceil(Math.sqrt(t));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const e=this.arrangementOrigin.x,s=this.arrangementOrigin.y;let n=e,o=s,r=0,l=0;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value.node;if(a===null||a instanceof Link||(a.ensureBounds(),!this.tl(a)))continue;const f=a.measuredBounds,c=f.width,u=f.height;a.moveTo(n,o),a instanceof Group&&(a.tl=!1),n+=Math.max(c,50)+20,l=Math.max(l,Math.max(u,50)),r>=i-1?(r=0,n=e,o+=l+20,l=0):r++}}tl(t){return!!(!t.location.isReal()&&!t.position.isReal()||t instanceof Group&&t.tl)}Nh(t,i,e,s,n,o,r){const l=i.iterator;for(;l.next();){const h=l.value;if(!(e&&!h.isTopLevel)&&!(s!==null&&!s(h))&&h.canLayout())if(n&&h instanceof Node){if(h.isLinkLabel)continue;h instanceof Group&&h.layout===null?this.Nh(t,h.memberParts,!1,s,n,o,r):(h.ensureBounds(),t.add(h))}else o&&h instanceof Link?t.add(h):r&&h.Ae()&&!(h instanceof Node)&&(h.ensureBounds(),t.add(h))}}getLayoutBounds(t,i){const e=this.boundsComputation;return e!==null?(i||(i=new Rect),e(t,this,i)):!i&&t.margin.equalTo(0,0,0,0)?t.actualBounds:(i||(i=new Rect),i.set(t.actualBounds),i.addMargin(t.margin),i)}get boundsComputation(){return this._d}set boundsComputation(t){this._d!==t&&(t!==null&&Util.t(t,"function",Layout,"boundsComputation"),this._d=t,this.invalidateLayout())}collectParts(t){const i=new GSet;return t instanceof Diagram?(this.Nh(i,t.nodes,!0,null,!0,!0,!0),this.Nh(i,t.links,!0,null,!0,!0,!0),this.Nh(i,t.parts,!0,null,!0,!0,!0)):t instanceof Group?this.Nh(i,t.memberParts,!1,null,!0,!0,!0):this.Nh(i,t.iterator,!1,null,!0,!0,!0),i}get arrangementOrigin(){return this.Qd}set arrangementOrigin(t){Util.s(t,Point,Layout,"arrangementOrigin"),this.Qd.equals(t)||(this.Qd.c(t),this.invalidateLayout())}initialOrigin(t){const i=this.group;if(i!==null)if(i.hasPlaceholder()){const e=i.placeholder,s=e.getDocumentPoint(Spot.TopLeft);(isNaN(s.x)||isNaN(s.y))&&s.set(t);const n=e.padding;return s.x+=n.left,s.y+=n.top,s}else{const e=i.position.copy();return(isNaN(e.x)||isNaN(e.y))&&e.set(t),e}return t}}class LayoutNetwork{re;ko;Fn;Ay;Ly;constructor(t){GSet.vi(this),Debug&&!t&&Util.n("LayoutNetwork constructor requires non-null Layout argument"),this.re=t,this.ko=new GSet,this.Fn=new GSet,this.Ay=new GMap,this.Ly=new GMap}clear(){if(this.ko){const t=this.ko.iterator;for(;t.next();)t.value.clear()}if(this.Fn){const t=this.Fn.iterator;for(;t.next();)t.value.clear()}this.ko=new GSet,this.Fn=new GSet,this.Ay=new GMap,this.Ly=new GMap}toString(t){t===void 0&&(t=0);let i="LayoutNetwork"+(this.layout!==null?"("+this.layout.toString()+")":"");if(t<=0)return i;if(i+=" vertexes: "+this.ko.count+" edges: "+this.Fn.count,t>1){const e=this.ko.iterator;for(;e.next();){const n=e.value;i+=` `+n.toString(t-1)}const s=this.Fn.iterator;for(;s.next();){const n=s.value;i+=` - `+n.toString(t-1)}}return i}get layout(){return this.oe}set layout(t){t!==null&&(this.oe=t)}get vertexes(){return this.ko}get edges(){return this.Fn}createVertex(){return new LayoutVertex(this)}createEdge(){return new LayoutEdge(this)}addParts(t,i,e){if(t===null)return;i===void 0&&(i=!1),Util.t(i,"boolean",LayoutNetwork,"addParts:toplevelonly"),e===void 0&&(e=null),e===null&&(e=n=>{if(n instanceof Node)return!n.isLinkLabel;if(n instanceof Link){const o=n.fromNode;if(o===null||o.isLinkLabel)return!1;const r=n.toNode;return!(r===null||r.isLinkLabel)}return!1});const s=t.iterator;for(;s.next();){const n=s.value;if(n instanceof Node&&!(i&&!n.isTopLevel)&&n.canLayout()&&e(n))if(n instanceof Group&&n.layout===null)this.addParts(n.memberParts,!1);else{if(this.findVertex(n)!==null)continue;const o=this.createVertex();o.node=n,this.addVertex(o)}}for(s.reset();s.next();){const n=s.value;if(!(n instanceof Link)||i&&!n.isTopLevel||!n.canLayout()||!e(n)||this.findEdge(n)!==null)continue;const o=n.fromNode,r=n.toNode;if(o===null||r===null||o===r)continue;const l=this.findGroupVertex(o),h=this.findGroupVertex(r);this.linkVertexes(l,h,n)}}findGroupVertex(t){if(t===null)return null;const i=t.findVisibleNode();if(i===null)return null;let e=this.findVertex(i);if(e!==null)return e;let s=i.containingGroup;for(;s!==null;){if(e=this.findVertex(s),e!==null)return e;s=s.containingGroup}return null}addVertex(t){if(t===null)return;Debug&&Util.s(t,LayoutVertex,LayoutNetwork,"addVertex:vertex"),this.ko.add(t);const i=t.node;i!==null&&this.Ay.set(i,t),t.network=this}addNode(t){if(t===null)return null;Debug&&Util.s(t,Node,LayoutNetwork,"addNode:node");let i=this.findVertex(t);return i===null&&(i=this.createVertex(),i.node=t,this.addVertex(i)),i}deleteVertex(t){if(t!==null&&(Debug&&Util.s(t,LayoutVertex,LayoutNetwork,"deleteVertex:vertex"),this.xT(t))){let i=t.nr;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}i=t.or;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}}}xT(t){if(t===null)return!1;const i=this.ko.delete(t);if(i){const e=t.node;e!==null&&this.Ay.delete(e)}return i}deleteNode(t){if(t===null)return;Debug&&Util.s(t,Node,LayoutNetwork,"deleteNode:node");const i=this.findVertex(t);i!==null&&this.deleteVertex(i)}findVertex(t){return t===null?null:(Debug&&Util.s(t,Node,LayoutNetwork,"findVertex:node"),this.Ay.get(t))}addEdge(t){if(t===null)return;Debug&&Util.s(t,LayoutEdge,LayoutNetwork,"addEdge:edge"),this.bN(t);const i=t.toVertex;i!==null&&i.addSourceEdge(t);const e=t.fromVertex;e!==null&&e.addDestinationEdge(t)}bN(t){if(t===null)return;this.Fn.add(t);const i=t.link;i!==null&&this.findEdge(i)===null&&this.Ly.set(i,t),t.network=this}addLink(t){if(t===null)return null;Debug&&Util.s(t,Link,LayoutNetwork,"addLink:link");const i=t.fromNode,e=t.toNode;let s=this.findEdge(t);return s===null?(s=this.createEdge(),s.link=t,i!==null&&(s.fromVertex=this.addNode(i)),e!==null&&(s.toVertex=this.addNode(e)),this.addEdge(s)):(i!==null?s.fromVertex=this.addNode(i):s.fromVertex=null,e!==null?s.toVertex=this.addNode(e):s.toVertex=null),s}deleteEdge(t){if(t===null)return;Debug&&Util.s(t,LayoutEdge,LayoutNetwork,"deleteEdge:edge");const i=t.toVertex;i!==null&&i.deleteSourceEdge(t);const e=t.fromVertex;e!==null&&e.deleteDestinationEdge(t),this.kN(t)}kN(t){if(t===null)return!1;const i=this.Fn.delete(t);if(i){const e=t.link;e!==null&&this.Ly.delete(e)}return i}deleteLink(t){if(t===null)return;Debug&&Util.s(t,Link,LayoutNetwork,"deleteLink:link");const i=this.findEdge(t);i!==null&&this.deleteEdge(i)}findEdge(t){return t===null?null:(Debug&&Util.s(t,Link,LayoutNetwork,"findEdge:link"),this.Ly.get(t))}linkVertexes(t,i,e){if(t===null||i===null)return null;if(Debug&&(Util.s(t,LayoutVertex,LayoutNetwork,"linkVertexes:fromVertex"),Util.s(i,LayoutVertex,LayoutNetwork,"linkVertexes:toVertex"),e!==null&&Util.s(e,Link,LayoutNetwork,"linkVertexes:link")),t.network===this&&i.network===this){const s=this.createEdge();return s.link=e,s.fromVertex=t,s.toVertex=i,this.addEdge(s),s}return null}reverseEdge(t){if(t===null)return;Debug&&Util.s(t,LayoutEdge,LayoutNetwork,"reverseEdge:edge");const i=t.fromVertex,e=t.toVertex;i===null||e===null||(i.deleteDestinationEdge(t),e.deleteSourceEdge(t),t.reverseEdge(),i.addSourceEdge(t),e.addDestinationEdge(t))}deleteSelfEdges(){const t=Util.ft(),i=this.Fn.iterator;for(;i.next();){const s=i.value;s.fromVertex===s.toVertex&&t.push(s)}const e=t.length;for(let s=0;s0||t.or.count>0)}splitIntoSubNetworks(t){t===void 0&&(t=!0),t&&(this.deleteArtificialVertexes(),this.deleteUselessEdges(),this.deleteSelfEdges());const i=new List;let e=!0;for(;e;){e=!1;const s=this.ko.iterator;for(;s.next();){const n=s.value;if(this.isSingleton(n))continue;const o=this.layout.createNetwork();i.add(o),this.LO(o,n),e=!0;break}}return i.sort((s,n)=>s===null||n===null||s===n?0:n.vertexes.count-s.vertexes.count),i}LO(t,i){if(i===null)return;const e=new List;for(e.add(i);e.count>0;){const s=e.first();if(e.removeAt(0),s.network===t)continue;this.xT(s),t.addVertex(s);let n=s.sourceEdges;for(;n.next();){const o=n.value;o.network!==t&&(this.kN(o),t.bN(o),e.add(o.fromVertex))}for(n=s.destinationEdges;n.next();){const o=n.value;o.network!==t&&(this.kN(o),t.bN(o),e.add(o.toVertex))}}}findAllParts(){const t=new GSet,i=this.ko.iterator;for(;i.next();){const s=i.value;t.add(s.node)}const e=this.Fn.iterator;for(;e.next();){const s=e.value;t.add(s.link)}return t}}class LayoutVertex{bo;si;ye;Oe;Qe;nr;or;constructor(t){GSet.vi(this),Debug&&!t&&Util.n("LayoutVertex constructor requires non-null LayoutNetwork argument"),this.bo=t,this.Oe=new Rect(0,0,10,10).w(),this.Qe=new Point(5,5).w(),this.si=null,this.ye=null,this.nr=new List,this.or=new List}clear(){this.si=null,this.ye=null,this.nr=new List,this.or=new List}toString(t){t===void 0&&(t=0);let i="LayoutVertex#"+GSet.gs(this);if(t>0&&(i+=this.node!==null?"("+this.node.toString()+")":"",t>1)){let e="",s=!0,n=this.nr.iterator;for(;n.next();){const r=n.value;s?s=!1:e+=",",e+=r.toString(0)}let o="";for(s=!0,n=this.or.iterator;n.next();){const r=n.value;s?s=!1:o+=",",o+=r.toString(0)}i+=" sources: "+e+" destinations: "+o}return i}get So(){return this.nr.nC}get rr(){return this.or.nC}get data(){return this.si}set data(t){if(this.si=t,t!==null&&t.bounds){const i=t.bounds,e=i.x,s=i.y,n=i.width,o=i.height;this.Qe.e(n/2,o/2),this.Oe.e(e,s,n,o)}}get node(){return this.ye}set node(t){if(this.ye!==t){Debug&&t!==null&&Util.s(t,Node,LayoutVertex,"node"),this.ye=t,t.ensureBounds();const i=this.network.layout,e=Rect.a(),s=i.getLayoutBounds(t,e);let n=s.x,o=s.y;const r=s.width,l=s.height;if(isNaN(n)&&(n=0),isNaN(o)&&(o=0),this.Oe.e(n,o,r,l),Rect.o(e),!(t instanceof Group)){const h=t.locationObject.getDocumentPoint(Spot.Center);if(h.isReal()){this.Qe.e(h.x-n,h.y-o);return}}this.Qe.e(r/2,l/2)}}get bounds(){return this.Oe}set bounds(t){this.Oe.equals(t)||(Debug&&Util.s(t,Rect,LayoutVertex,"bounds"),this.Oe.c(t))}get focus(){return this.Qe}set focus(t){this.Qe.equals(t)||(Debug&&Util.s(t,Point,LayoutVertex,"focus"),this.Qe.c(t))}get centerX(){return this.Oe.x+this.Qe.x}set centerX(t){const i=this.Oe;i.x+this.Qe.x!==t&&(Debug&&Util.r(t,LayoutVertex,"centerX"),i.ct(),i.x=t-this.Qe.x,i.w())}get centerY(){return this.Oe.y+this.Qe.y}set centerY(t){const i=this.Oe;i.y+this.Qe.y!==t&&(Debug&&Util.r(t,LayoutVertex,"centerY"),i.ct(),i.y=t-this.Qe.y,i.w())}get focusX(){return this.Qe.x}set focusX(t){const i=this.Qe;i.x!==t&&(i.ct(),i.x=t,i.w())}get focusY(){return this.Qe.y}set focusY(t){const i=this.Qe;i.y!==t&&(i.ct(),i.y=t,i.w())}get x(){return this.Oe.x}set x(t){const i=this.Oe;i.x!==t&&(i.ct(),i.x=t,i.w())}get y(){return this.Oe.y}set y(t){const i=this.Oe;i.y!==t&&(i.ct(),i.y=t,i.w())}get width(){return this.Oe.width}set width(t){const i=this.Oe;i.width!==t&&(i.ct(),i.width=t,i.w())}get height(){return this.Oe.height}set height(t){const i=this.Oe;i.height!==t&&(i.ct(),i.height=t,i.w())}commit(){const t=this.si;if(t!==null){const e=this.bounds,s=t.bounds;Util.Mt(s)?(s.x=e.x,s.y=e.y,s.width=e.width,s.height=e.height):t.bounds=e.copy();return}const i=this.node;if(i!==null){const e=this.bounds;if(!(i instanceof Group)){const s=Rect.a();i.ensureBounds();const n=this.network.layout.getLayoutBounds(i,s),o=i.locationObject.getDocumentPoint(Spot.Center);if(n.isReal()&&o.isReal()){i.moveTo(e.x+this.focusX-(o.x-n.x)+i.margin.left,e.y+this.focusY-(o.y-n.y+i.margin.top)),Rect.o(s);return}Rect.o(s)}i.moveTo(e.x+i.margin.left,e.y+i.margin.top)}}addSourceEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"addSourceEdge:edge"),this.nr.has(t)||this.nr.add(t))}deleteSourceEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"deleteSourceEdge:edge"),this.nr.delete(t))}addDestinationEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"addDestinationEdge:edge"),this.or.has(t)||this.or.add(t))}deleteDestinationEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"deleteDestinationEdge:edge"),this.or.delete(t))}get network(){return this.bo}set network(t){Debug&&Util.s(t,LayoutNetwork,LayoutVertex,"network"),this.bo=t}get sourceVertexes(){const t=new GSet,i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}return t.iterator}get destinationVertexes(){const t=new GSet,i=this.destinationEdges;for(;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get vertexes(){const t=new GSet;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get sourceEdges(){return this.nr.iterator}get destinationEdges(){return this.or.iterator}get edges(){const t=new List;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e)}return t.iterator}get edgesCount(){return this.nr.count+this.or.count}static standardComparer(t,i){Debug&&Util.s(t,LayoutVertex,LayoutVertex,"standardComparer:m"),Debug&&Util.s(i,LayoutVertex,LayoutVertex,"standardComparer:n");const e=t.ye,s=i.ye;if(e)if(s){const n=e.text,o=s.text;return no?1:0}else return 1;else return s!==null?-1:0}static smartComparer(t,i){if(Debug&&Util.s(t,LayoutVertex,LayoutVertex,"smartComparer:m"),Debug&&Util.s(i,LayoutVertex,LayoutVertex,"smartComparer:n"),t!==null)if(i!==null){const e=t.ye,s=i.ye;if(e!==null)if(s!==null){const n=e.text.toLocaleLowerCase(),o=s.text.toLocaleLowerCase(),r=n.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),l=o.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let h=0;for(;h0&&(i+=this.$e!==null?"("+this.$e.toString()+")":"",t>1&&(i+=" "+(this._e?this._e.toString():"null")+" --> "+(this.ts?this.ts.toString():"null"))),i}reverseEdge(){const t=this._e;this._e=this.ts,this.ts=t}commit(){}getOtherVertex(t){return Debug&&Util.s(t,LayoutVertex,LayoutEdge,"getOtherVertex:v"),this.ts===t?this._e:this._e===t?this.ts:null}get network(){return this.bo}set network(t){Debug&&Util.s(t,LayoutNetwork,LayoutEdge,"network"),this.bo=t}get data(){return this.si}set data(t){this.si!==t&&(Debug&&t!==null&&Util.t(t,"object",LayoutEdge,"data"),this.si=t)}get link(){return this.$e}set link(t){this.$e!==t&&(Debug&&t!==null&&Util.s(t,Link,LayoutEdge,"link"),this.$e=t)}get fromVertex(){return this._e}set fromVertex(t){this._e!==t&&(Debug&&t!==null&&Util.s(t,LayoutVertex,LayoutEdge,"fromVertex"),this._e=t)}get toVertex(){return this.ts}set toVertex(t){this.ts!==t&&(Debug&&t!==null&&Util.s(t,LayoutVertex,LayoutEdge,"toVertex"),this.ts=t)}}var GridAlignment=(w=>(w[w.Position=0]="Position",w[w.Location=1]="Location",w))(GridAlignment||{}),GridArrangement=(w=>(w[w.LeftToRight=10]="LeftToRight",w[w.RightToLeft=11]="RightToLeft",w))(GridArrangement||{}),GridSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w))(GridSorting||{});class GridLayout extends Layout{eg;sg;Ro;Rn;ai;qi;ke;Se;constructor(t){super(),this.isViewportSized=!0,this.eg=NaN,this.sg=NaN,this.Ro=new Size(NaN,NaN).w(),this.Rn=new Size(10,10).w(),this.ai=1,this.qi=10,this.ke=22,this.Se=GridLayout.standardComparer,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.eg=this.eg,t.sg=this.sg,t.Ro.c(this.Ro),t.Rn.c(this.Rn),t.ai=this.ai,t.qi=this.qi,t.ke=this.ke,t.Se=this.Se}fi(t){t in GridSorting?this.sorting=t:t in GridArrangement?this.arrangement=t:t in GridAlignment?this.alignment=t:super.fi(t)}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.collectParts(t),e=this.diagram,n=i.copy().iterator;for(;n.next();){const m=n.value;if(m.Dl()&&(m.fromNode!==null||m.toNode!==null)){i.delete(m);continue}if(m.ensureBounds(),m instanceof Group){const g=m.memberParts;for(;g.next();){const p=g.value;i.delete(p)}}}const o=i.toArray();if(o.length===0)return;switch(this.sorting){case 20:break;case 21:o.reverse();break;case 22:o.sort(this.comparer);break;case 23:o.sort(this.comparer),o.reverse();break}let r=this.wrappingColumn;isNaN(r)&&(r=0);let l=this.wrappingWidth;if(isNaN(l)&&e!==null){const m=e.viewportBounds,g=e.padding;l=Math.max(m.width-g.left-g.right,0)}else l=Math.max(this.wrappingWidth,0);r<=0&&l<=0&&(r=1);let h=this.spacing.width;isFinite(h)||(h=0);let a=this.spacing.height;isFinite(a)||(a=0),e!==null&&e.startTransaction("Layout");const f=[];switch(this.alignment){case 0:this.TO(o,l,r,h,a,f);break;case 1:this.DO(o,l,r,h,a,f);break}let c=0,u=0,d=0;for(let m=0;m0&&m>e-1||i>0&&m>0&&A-f>i)&&(o.push(new Rect(0,d,i+s,g)),m=0,u=f,d+=g,g=0),g=Math.max(g,M);let C=0;switch(a){case 11:C=-x.width;break;default:C=0;break}switch(y.moveTo(u+C+y.margin.left,d+y.margin.top),a){case 11:u-=S;break;default:u+=S;break}m++}o.push(new Rect(0,d,i+s,g)),Rect.o(r)}DO(t,i,e,s,n,o){const r=Rect.a();let l=Math.max(this.cellSize.width,1),h=0,a=0,f=0;const c=Point.a();for(let C=0;C=h&&(i-=h);let x=0,k=0;const b=Math.max(this.cellSize.height,1);f=0;let S=0,M=!0;const A=Point.a();for(let C=0;C0)switch(u){case 11:{let D=(g-d-(N.width-T.x))/l;Geo.q(Math.round(D),D)?D=Math.round(D):D=Math.floor(D),g=D*l+d;break}default:{let D=(g-d+T.x)/l;Geo.q(Math.round(D),D)?D=Math.round(D):D=Math.ceil(D),g=D*l+d;break}}else switch(u){case 11:x=g+T.x+N.width;break;default:x=g-T.x;break}let L=0;switch(u){case 11:L=-(g+T.x)+x;break;default:L=g+N.width-T.x-x;break}if(e>0&&y>e-1||i>0&&y>0&&L>i){o.push(new Rect(0,M?p-f:p,i+s,S+f+n));for(let D=0;Dk&&(P.width+=P.x-k,P.x=k)}Rect.o(r)}commitLayers(t,i){}get wrappingWidth(){return this.eg}set wrappingWidth(t){this.eg!==t&&(Util.t(t,"number",GridLayout,"wrappingWidth"),(t>0||isNaN(t))&&(this.eg=t,this.isViewportSized=isNaN(t),this.invalidateLayout()))}get wrappingColumn(){return this.sg}set wrappingColumn(t){this.sg!==t&&(Util.t(t,"number",GridLayout,"wrappingColumn"),(t>0||isNaN(t))&&(this.sg=t,this.invalidateLayout()))}get cellSize(){return this.Ro}set cellSize(t){Util.s(t,Size,GridLayout,"cellSize"),this.Ro.equals(t)||(this.Ro.c(t),this.invalidateLayout())}get spacing(){return this.Rn}set spacing(t){Util.s(t,Size,GridLayout,"spacing"),this.Rn.equals(t)||(this.Rn.c(t),this.invalidateLayout())}get alignment(){return this.ai}set alignment(t){this.ai!==t&&(Util.tt(t,GridAlignment,"GridAlignment"),(t===1||t===0)&&(this.ai=t,this.invalidateLayout()))}get arrangement(){return this.qi}set arrangement(t){this.qi!==t&&(Util.tt(t,GridArrangement,"GridArrangement"),(t===10||t===11)&&(this.qi=t,this.invalidateLayout()))}get sorting(){return this.ke}set sorting(t){this.ke!==t&&(Util.tt(t,GridSorting,"GridSorting"),(t===20||t===21||t===22||t===23)&&(this.ke=t,this.invalidateLayout()))}get comparer(){return this.Se}set comparer(t){this.Se!==t&&(Util.t(t,"function",GridLayout,"comparer"),this.Se=t,this.invalidateLayout())}static standardComparer(t,i){Debug&&Util.s(t,Part,GridLayout,"standardComparer:a"),Debug&&Util.s(i,Part,GridLayout,"standardComparer:b");const e=t.text,s=i.text;return es?1:0}static smartComparer(t,i){if(Debug&&Util.s(t,Part,GridLayout,"standardComparer:a"),Debug&&Util.s(i,Part,GridLayout,"standardComparer:b"),t!==null)if(i!==null){const e=t.text.toLocaleLowerCase(),s=i.text.toLocaleLowerCase(),n=e.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),o=s.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let r=0;for(;r{e.containsNodeData(s)&&this.MT(s,!1)}),t.forEach(s=>{e.containsNodeData(s)&&this.Rb(s)}),i!==!1&&this.diagram.R1(!1)}MT(t,i){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.Mo.has(t))return null;i===void 0&&(i=!0);const e=this.FO(t);return e!==null&&i&&this.Rb(t),e}FO(t){if(t==null||this.b.undoManager.isUndoingRedoing||this.Mo.has(t))return null;const i=this.RO(t),e=this.findTemplateForNodeData(t,i);if(e!==null){e.ci();const s=e.copy();if(s!==null){const n=this.diagram.me;return this.diagram.me=!0,s.$o=i,s.si=t,this.Ty&&(s.ul="Tool"),this.diagram.add(s),s.si=null,s.data=t,this.diagram.me=n,s}}return null}insertLink(t,i,e,s){return null}Rb(t){}RO(t){return this.b.model.getCategoryForNodeData(t)}static PT=!1;static NT=!1;findTemplateForNodeData(t,i){const e=this.b,s=e.model,n=s.da()&&s.isGroupForData(t);let o=null;return n?(o=e.groupTemplateMap.get(i),o===null&&(o=e.groupTemplateMap.get(""),o===null&&(PartManager.NT||(PartManager.NT=!0,Util.at('No Group template found for category "'+i+'"'),Util.at(" Using default group template")),o=e.gP))):(o=e.nodeTemplateMap.get(i),o===null&&(o=e.nodeTemplateMap.get(""),o===null&&(PartManager.PT||(PartManager.PT=!0,Util.at('No Node template found for category "'+i+'"'),Util.at(" Using default node template")),o=e.cP))),o}getLinkCategoryForData(t){return""}setLinkCategoryForData(t,i){}setFromNodeForLink(t,i,e){}setToNodeForLink(t,i,e){}static CT=!1;findLinkTemplateForCategory(t){const i=this.b;let e=i.linkTemplateMap.get(t);return e===null&&(e=i.linkTemplateMap.get(""),e===null&&(PartManager.CT||(PartManager.CT=!0,Util.at('No Link template found for category "'+t+'"'),Util.at(" Using default link template")),e=i.uP)),e}xI(t,i,e){t instanceof Link?(i!==null&&this.kT(i,t),e!==null&&this.bT(e,t)):t instanceof Part&&(i!==null&&this.Mo.delete(i),e!==null&&this.Mo.set(e,t))}ST(){const t=this.diagram.model;this.MN(t.nodeDataArray)}MN(t){t.forEach(i=>{this.Ib(i)})}Ib(t){const i=this.findPartForData(t);i!==null&&(this.diagram.IP(i,!1),this.PN(i))}PN(t){}gN(t){}findPartForKey(t){if(t==null)return null;const i=this.b.model.findNodeDataForKey(t);return i!==null?this.Mo.get(i):null}findNodeForKey(t){if(t==null)return null;const i=this.b.model.findNodeDataForKey(t);if(i===null)return null;const e=this.Mo.get(i);return e instanceof Node?e:null}findLinkForKey(t){return null}findPartForData(t){if(t===null)return null;let i=this.Mo.get(t);return i!==null||(i=this.yl.get(t)),i}findNodeForData(t){if(t===null)return null;const i=this.Mo.get(t);return i instanceof Node?i:null}findLinkForData(t,i){return t===null?null:this.yl.get(t)}findNodesByExample(...t){const i=new GSet,e=this.ng.iterator;for(;e.next();){const s=e.value,n=s.data;if(n!==null)for(let o=0;o{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),this.parts.each(o=>{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),s.forEach(o=>t.LT(o,!1));for(let o=0;o0){for(let o=0;oi.FA(s));const e=t.wh;if(Array.isArray(e)){const s=this.Ga.get(e);if(s===null){const n=[];n.push(t),this.Ga.set(e,n)}else{for(let n=0;ni.PR(s));const e=t.wh;if(Array.isArray(e)){const s=this.Ga.get(e);if(s!==null){for(let n=0;n0&&i.removeParts(l,!1),h.count>0){const f=h.iterator;for(;f.next();){const c=f.key,u=f.value;s.set(c,u)}}}if(i!==null&&this.b!==null){const o=i.model,r=o.afterCopyFunction;if(r!==null){const l=new GMap;s.each(a=>{a.key.data!==null&&l.set(a.key.data,a.value.data)});const h=this.b.model;r(l,o,h)}}const n=s.iterator;for(;n.next();)n.value.updateTargetBindings();return s}Ob(t,i,e,s){if(t===null||s&&!t.canCopy())return null;if(e.has(t))return e.get(t);const n=this.CN(t,i);if(!(n instanceof Part))return null;if(n.isSelected=!1,n.isHighlighted=!1,e.set(t,n),t instanceof Node){const o=t.linksConnected;for(;o.next();){const r=o.value;if(r.fromNode===t){const l=e.get(r);l!==null&&(l.fromNode=n)}if(r.toNode===t){const l=e.get(r);l!==null&&(l.toNode=n)}}if(t instanceof Group&&n instanceof Group){const r=t.memberParts;for(;r.next();){const l=r.value,h=this.Ob(l,i,e,s);h instanceof Link||h!==null&&(h.containingGroup=n)}}}else if(t instanceof Link&&n instanceof Link){const o=t.fromNode;if(o!==null){const h=e.get(o);h!==null&&(n.fromNode=h)}const r=t.toNode;if(r!==null){const h=e.get(r);h!==null&&(n.toNode=h)}const l=t.labelNodes;for(;l.next();){const h=l.value,a=this.Ob(h,i,e,s);a!==null&&a instanceof Node&&(a.labeledLink=n)}}return n}CN(t,i){let e=null;const s=t.data;if(s!==null&&i!==null){const n=i.model;if(!(t instanceof Link)){const o=n.copyNodeData(s);Util.Mt(o)&&(n.addNodeData(o),e=i.findPartForData(o))}}else if(t.ci(),e=t.copy(),e!==null){const n=this.b;if(i!==null)i.add(e);else if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const o=n.model;let r=null;e instanceof Link||(r=o.copyNodeData(s)),Util.Mt(r)&&(e.data=r)}}return e}get nodes(){return this.ng}get links(){return this.Qs}get parts(){return this.It}get diagram(){return this.b}get addsToTemporaryLayer(){return this.Ty}set addsToTemporaryLayer(t){this.Ty=t}get preservesRebuildLocations(){return this.SN}set preservesRebuildLocations(t){this.SN=t}}class GraphLinksPartManager extends PartManager{EP(){const t=this.diagram.model;this.Dy(t.nodeDataArray),this.FT(t.linkDataArray)}Dy(t){super.Dy(t,!1);const i=this.links.iterator;for(;i.next();)i.value.Ed();this.diagram.R1(!1)}FT(t){t.forEach(i=>{this.RT(i)}),this.diagram.R1(!1)}RT(t){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.yl.has(t))return null;const i=this.getLinkCategoryForData(t),e=this.findLinkTemplateForCategory(i);if(e!==null){e.ci();const s=e.copy();if(s!==null){const n=this.diagram.me;this.diagram.me=!0,s.$o=i,s.si=t;const o=this.diagram.model,r=o.Eb(t,!0);r!==""&&(s.fromPortId=r);const l=o.Ee(t,!0);if(l!==void 0){const c=this.findNodeForKey(l);c instanceof Node&&(s.fromNode=c)}const h=o.Eb(t,!1);h!==""&&(s.toPortId=h);const a=o.Ee(t,!1);if(a!==void 0){const c=this.findNodeForKey(a);c instanceof Node&&(s.toNode=c)}const f=o.getLabelKeysForLinkData(t);return Array.isArray(f)&&f.forEach(c=>{const u=this.findNodeForKey(c);u!==null&&(u.labeledLink=s)}),this.Ty&&(s.ul="Tool"),this.diagram.add(s),s.si=null,s.data=t,this.diagram.me=n,s}}return null}ST(){const t=this.diagram.model;this.IT(t.linkDataArray),this.MN(t.nodeDataArray)}IT(t){t.forEach(i=>{this.Ib(i)})}getLinkCategoryForData(t){return this.diagram.model.getCategoryForLinkData(t)}setLinkCategoryForData(t,i){return this.diagram.model.setCategoryForLinkData(t,i)}setFromNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setFromKeyForLinkData(t.data,e.getKeyForNodeData(s))}setToNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setToKeyForLinkData(t.data,e.getKeyForNodeData(s))}gN(t){this.diagram.model.removeLinkData(t.data)}findPartForKey(t){const i=super.findPartForKey(t);if(i===null){const s=this.diagram.model.findLinkDataForKey(t);if(s!==null)return this.yl.get(s)}return i}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findLinkDataForKey(t);return e!==null?this.yl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.j){i.j=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="linkFromKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.fromNode=l}}else if(s==="linkToKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.toNode=l}}else if(s==="linkFromPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.fromPortId=r)}}else if(s==="linkToPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.toPortId=r)}}else if(s==="nodeGroupKey"){const n=t.object,o=this.findPartForData(n);if(o!==null){const r=t.newValue;if(r!==void 0){const l=this.findNodeForKey(r);l instanceof Group?o.containingGroup=l:o.containingGroup=null}else o.containingGroup=null}}else if(s==="linkLabelKeys"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.oldValue,l=t.newValue;Array.isArray(r)&&r.forEach(h=>{if(l.indexOf(h)>=0)return;const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=null)}),Array.isArray(l)&&l.forEach(h=>{const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=o)})}}else if(s==="linkCategory"){const n=t.object,o=this.findLinkForData(n),r=t.newValue;o!==null&&typeof r=="string"&&(o.category=r)}else if(s==="linkDataArray"){const n=t.oldValue;this.IT(n);const o=t.newValue;this.FT(o)}i.isModified=!0}else if(e===3){const n=t.newValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.RT(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=t.object,r=this.findLinkForData(o),l=this.findNodeForKey(n);r!==null&&l!==null&&(l.labeledLink=r)}i.isModified=!0}else if(e===4){const n=t.oldValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.Ib(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=this.findNodeForKey(n);o!==null&&(o.labeledLink=null)}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&(n==="linkFromKeyProperty"||n==="linkToKeyProperty"||n==="linkFromPortIdProperty"||n==="linkToPortIdProperty"||n==="linkLabelKeysProperty"||n==="nodeIsGroupProperty"||n==="nodeGroupKeyProperty"||n==="linkCategoryProperty")&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.j=!0}}}DT(){const t=this.diagram.model,i=new GSet,e=t.linkDataArray;e.forEach(n=>{i.add(n)});const s=[];this.links.each(n=>{n.data!==null&&!i.has(n.data)&&s.push(n.data)}),s.forEach(n=>{t.OT(n,!1)}),e.forEach(n=>{this.findLinkForData(n)===null&&t.ET(n,!1)})}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Link){let n=s.Ee(i,!0),o=e.findNodeForKey(n);t.fromNode=o,n=s.Ee(i,!1),o=e.findNodeForKey(n),t.toNode=o;const r=s.getLabelKeysForLinkData(i);if(r.length>0||t.labelNodes.count>0){if(r.length===1&&t.labelNodes.count===1){const c=r[0],u=t.labelNodes.first();if(s.getKeyForNodeData(u.data)===c)return}const l=new GSet().addAll(r),h=new GSet;t.labelNodes.each(c=>{if(c.data!==null){const u=s.getKeyForNodeData(c.data);u!==void 0&&h.add(u)}});const a=h.copy();a.removeAll(l);const f=l.copy();if(f.removeAll(h),a.count>0||f.count>0){const c=t;a.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink===c&&(d.labeledLink=null)}),f.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink!==c&&(d.labeledLink=c)})}}}else if(!(t instanceof Adornment)){const n=s.getGroupKeyForNodeData(i),o=e.findPartForKey(n);(o===null||o instanceof Group)&&(t.containingGroup=o)}}Rb(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Ry(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)){if(n instanceof Group&&i.getGroupKeyForNodeData(l)===e){const h=this.findPartForData(l);h!==null&&(h.containingGroup=n)}}else{const h=this.findLinkForData(l);if(h!==null&&n instanceof Node){i.Ee(l,!0)===e&&(h.fromNode=n),i.Ee(l,!1)===e&&(h.toNode=n);const a=i.getLabelKeysForLinkData(l);Array.isArray(a)&&a.some(f=>f===e?(n.labeledLink=h,!0):!1)}}}i.tn(e)}const o=i.getGroupKeyForNodeData(t);if(o!==void 0){const r=this.findNodeForKey(o);r instanceof Group&&(n.containingGroup=r)}}}PN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data);if(e!==void 0){const s=t.linksConnected;for(;s.next();){const n=s.value;i.en(e,n.data)}if(t.isLinkLabel){const n=t.labeledLink;n!==null&&i.en(e,n.data)}if(t instanceof Group){const n=t.memberParts;for(;n.next();){const r=n.value.data;i.containsNodeData(r)&&i.en(e,r)}}}}}CN(t,i){let e=super.CN(t,i);if(t instanceof Link){const s=t.data;if(s!==null&&i!==null){const n=i.model,o=n.copyLinkData(s);typeof o=="object"&&o!==null&&(n.addLinkData(o),e=i.findLinkForData(o))}else if(e!==null){const n=this.diagram;if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const r=n.model.copyLinkData(s);typeof r=="object"&&r!==null&&(e.data=r)}}}return e}insertLink(t,i,e,s){const n=this.diagram,o=n.model,r=n.toolManager.findTool("Linking");let l="";t!==null&&(i===null&&(i=t),l=i.portId,l===null&&(l=""));let h="";e!==null&&(s===null&&(s=e),h=s.portId,h===null&&(h=""));const a=r.archetypeLinkData;if(a instanceof Link){a.ci();const f=a.copy();if(f!==null){f.fromNode=t,f.fromPortId=l,f.toNode=e,f.toPortId=h,n.add(f);const c=r.archetypeLabelNodeData;if(c instanceof Node){c.ci();const u=c.copy();u!==null&&(u.labeledLink=f,n.add(u))}return f}}else if(a!==null){const f=o.copyLinkData(a);if(typeof f=="object"&&f!==null){t!==null&&o.og(f,o.getKeyForNodeData(t.data),!0),o.rg(f,l,!0),e!==null&&o.og(f,o.getKeyForNodeData(e.data),!1),o.rg(f,h,!1),o.addLinkData(f);const c=r.archetypeLabelNodeData;if(c!==null&&!(c instanceof Node)){const d=o.copyNodeData(c);if(typeof d=="object"&&d!==null){o.addNodeData(d);const m=o.getKeyForNodeData(d);m!==void 0&&o.addLabelKeyForLinkData(f,m)}}return n.findLinkForData(f)}}return null}}class TreePartManager extends PartManager{Nh=null;Vb(t,i){if(t===null||i===null||i.findTreeParentLink()!==null)return null;const e=this.diagram.toolManager.findTool("Linking");let s=t,n=i;if(this.diagram.isTreePathToChildren){if(e!==null&&e.Au(s,n,null,!0))return null}else if(s=i,n=t,e!==null&&e.Au(s,n,null,!0))return null;const o=this.getLinkCategoryForData(i.data),r=this.findLinkTemplateForCategory(o);if(r!==null){r.ci();const l=r.copy();if(l!==null){const h=this.diagram.me;return this.diagram.me=!0,l.$o=o,l.si=i.data,l.fromNode=s,l.toNode=n,this.diagram.add(l),l.si=null,l.data=i.data,this.diagram.me=h,l}}return null}getLinkCategoryForData(t){return this.diagram.model.getParentLinkCategoryForNodeData(t)}setLinkCategoryForData(t,i){this.diagram.model.setParentLinkCategoryForNodeData(t,i)}setFromNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren)s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n));else{const o=this.Nh;this.Nh=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.toNode!==null?t.toNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Nh=o}}setToNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren){const o=this.Nh;this.Nh=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.fromNode!==null?t.fromNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Nh=o}else s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n))}gN(t){this.diagram.model.setParentKeyForNodeData(t.data,void 0)}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findNodeDataForKey(t);return e!==null?this.yl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.j){i.j=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="nodeParentKey"){const n=t.object,o=t.newValue,r=this.findNodeForKey(o),l=this.findNodeForData(n);if(this.Nh!==null)r!==null&&(this.Nh.data=n,this.Nh.category=this.getLinkCategoryForData(n));else if(l!==null){const h=l.findTreeParentLink();h!==null?r===null?i.remove(h):i.isTreePathToChildren?h.fromNode=r:h.toNode=r:this.Vb(r,l)}}else if(s==="parentLinkCategory"){const n=t.object,o=this.findNodeForData(n),r=t.newValue;if(o!==null&&typeof r=="string"){const l=o.findTreeParentLink();l!==null&&(l.category=r)}}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&n==="nodeParentKeyProperty"&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.j=!0}}}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Node){const n=s.getParentKeyForNodeData(i),o=e.findNodeForKey(n),r=t.findTreeParentNode();if(o!==r){const l=t.findTreeParentLink();o!==null?l!==null?e.isTreePathToChildren?l.fromNode=o:l.toNode=o:this.Vb(o,t):l!==null&&e.IP(l,!1)}}}Fy(t,i){if(super.Fy(t,i),typeof i=="string"&&this.findPartForData(t)!==null){const s=this.findLinkForData(t);s!==null&&s.updateTargetBindings(i)}}Rb(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Ry(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)&&n instanceof Node&&i.getParentKeyForNodeData(l)===e){const h=this.findNodeForData(l);this.Vb(n,h)}}i.tn(e)}const o=i.getParentKeyForNodeData(t);if(o!==void 0&&n instanceof Node){const r=this.findNodeForKey(o);this.Vb(r,n)}}}PN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data),s=this.findLinkForData(t.data);if(s!==null){s.isSelected=!1,s.isHighlighted=!1;const r=s.layer;if(r!==null){const l=r.ne(-1,s,!1);l>=0&&this.diagram.raiseChangedEvent(4,"parts",r,s,null,l,null);const h=s.layerChanged;h!==null&&h(s,r,null)}}const n=this.diagram.isTreePathToChildren,o=t.linksConnected;for(;o.next();){const r=o.value,h=(n?r.toNode:r.fromNode).data;i.containsNodeData(h)&&i.en(e,h)}}}insertLink(t,i,e,s){const n=this.diagram.model;let o=t,r=e;if(this.diagram.isTreePathToChildren||(o=e,r=t),o!==null&&r!==null){const l=o.data,h=r.data;return n.setParentKeyForNodeData(h,n.getKeyForNodeData(l)),r.findTreeParentLink()}return null}}var BindingMode=(w=>(w[w.OneWay=1]="OneWay",w[w.TwoWay=2]="TwoWay",w))(BindingMode||{});class Binding{l;AN;Ha;Fc;Ch;Rc;Ic;Oc;Bb;Ce;Sd;pc;constructor(t,i,e,s){GSet.vi(this),t===void 0?t="":Util.t(t,"string",Binding,"constructor:targetprop"),i===void 0?i=t:Util.t(i,"string",Binding,"constructor:sourceprop"),e===void 0?e=null:e!==null&&Util.t(e,"function",Binding,"constructor:conv"),this.AN=-1,this.Ce=null,this.Ha=t,this.Sd=0,this.pc=0,this.Fc=null,this.Ch=i,this.Rc=e,s===void 0?(this.Ic=1,this.Oc=null):(this.Ic=2,this.Oc=s),this.Bb=new GSet,this.l=2}copy(){const t=new this.constructor;return this.cloneProtected(t),t}cloneProtected(t){t.Ha=this.Ha,t.Sd=this.Sd,t.pc=this.pc,t.Fc=this.Fc,t.Ch=this.Ch,t.Rc=this.Rc,t.Ic=this.Ic,t.Oc=this.Oc,t.l=this.l&-2}static OneWay=1;static TwoWay=2;static parseEnum(t,i){return Util.t(t,"function",Binding,"parseEnum:ctor"),e=>{let s=parseInt(e);return isNaN(s)&&(s=Util.zh(t,e),s===null)?i:s}}fi(t){t in BindingMode?this.mode=t:Util.ur(this,t)}static toString(t){return Util.toString(t)}toString(){return"Binding("+this.targetProperty+":"+this.sourceProperty+(this.targetId!==-1?" "+this.targetId:"")+" "+BindingMode[this.mode]+")"}w(){return this.l=this.l|1,this}ct(){return this.l=this.l&-2,this}get targetId(){return this.AN}set targetId(t){this.f&&Util.F(this),Util.t(t,"number",Binding,"targetId"),this.AN=t}get targetProperty(){return this.Ha}set targetProperty(t){this.f&&Util.F(this),Util.t(t,"string",Binding,"targetProperty"),this.Ha=t}get sourceProperty(){return this.Ch}set sourceProperty(t){this.f&&Util.F(this),Util.t(t,"string",Binding,"sourceProperty"),this.Ch=t}get f(){return(this.l&1)!==0}get isToData(){return(this.l&2)!==0}get isToObject(){return(this.l&4)!==0}get isToModel(){return(this.l&8)!==0}get isToTheme(){return(this.l&16)!==0}get LN(){return this.isToTheme&&!(this.isToData||this.isToObject||this.isToModel)}rd(){return!1}get sourceName(){return this.Fc}set sourceName(t){this.f&&Util.F(this),t!==null&&Util.t(t,"string",Binding,"sourceName"),this.Fc=t,t!==null?this.l=this.l&-3|4:this.l=this.l|2}get converter(){return this.Rc}set converter(t){this.f&&Util.F(this),t!==null&&Util.t(t,"function",Binding,"converter"),this.Rc=t}get backConverter(){return this.Oc}set backConverter(t){this.f&&Util.F(this),t!==null&&Util.t(t,"function",Binding,"backConverter"),this.Oc=t}get mode(){return this.Ic}set mode(t){this.f&&Util.F(this),this.isToTheme&&t===2&&Util.n("Theme Bindings cannot be TwoWay."),Util.tt(t,BindingMode,"BindingMode"),this.Ic=t}makeTwoWay(t){return this.isToTheme&&Util.n("Theme Bindings cannot be TwoWay."),this.mode=2,t&&(Util.t(t,"function",Binding,"makeTwoWay"),this.backConverter=t),this}ofObject(t){return this.f&&Util.F(this),t===void 0&&(t=""),Debug&&Util.t(t,"string",Binding,"ofObject:srcname"),this.sourceName=t,this}ofModel(){return this.f&&Util.F(this),this.l=this.l&-3&-5|8,this.Fc=null,this}rL(t,i){const e=this.sourceName;let s=null;return e===null||e===""?s=t:e==="/"?s=i.part:e==="."?s=i:e===".."?s=i.panel:s=t.findObject(e),s}check(t){const i=this.Ha,e=this.Ch,s=this.Rc;(this.rd()&&s===null&&this.Ah===null&&i===""||s===null&&i==="")&&Util.at("Binding error: target property is the empty string: "+this.toString()),this.rd()&&this.LN&&e===""&&s===null&&this.Ah===null&&Util.at("Binding error: theme bindings require a source property when not using a converter: "+this.toString()),t&&typeof i=="string"&&(typeof t.setAttribute!="function"&&i.length>0&&i[0]!=="_"&&!Util.yw(t,i)?Util.at("Binding error: undefined target property: "+i+" on "+t.toString()):i==="name"&&t instanceof GraphObject&&Util.at("Binding error: cannot modify GraphObject.name on "+t.toString()))}updateTarget(t,i,e){const s=this.Ch;if(e!==void 0&&s!==""&&s!==e)return;const n=this.Ha,o=this.Rc;let r=i;if(s!==""&&!this.LN&&(r=Model.Xt(i,s)),r===void 0)return;const l=t.diagram?.themeManager??t.panel?.diagram?.themeManager;if(o===null){if(n!==""){if(this.rd()&&(r=this.VT(l,r,t,n),r===void 0))return;Model.ut(t,n,r)}}else try{if(n!==""){let h=o(r,t);if(Debug&&h===void 0&&Util.at('Binding warning: conversion function returned undefined when setting target property "'+n+'" on '+t.toString()+", function is: "+o),this.rd()&&(h=this.VT(l,h,t,n),h===void 0))return;Model.ut(t,n,h)}else o(r,t)}catch(h){Debug&&Util.at("Binding error: "+h.toString()+' setting target property "'+n+'" on '+t.toString()+" with conversion function: "+o)}}updateSource(t,i,e,s){if(this.Ic!==2)return;const n=this.Ha;if(e!==void 0&&n!==e)return;const o=this.Ch,r=this.Oc;let l=t;if(n!==""&&(l=Model.Xt(t,n)),l!==void 0&&!this.Bb.has(t))try{this.Bb.add(t);const h=s!==null?s.diagram:null,a=h!==null?h.model:null;if(r===null){if(o!=="")a!==null?(Debug&&a.nodeKeyProperty===o&&a.containsNodeData(i)&&Util.at("Binding error: cannot have TwoWay Binding on node data key property: "+this.toString()),a.setDataProperty(i,o,l)):Model.ut(i,o,l);else if(a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const f=s.itemIndex,c=s.panel.itemArray;a.removeArrayItem(c,f),a.insertArrayItem(c,f,l)}}else try{if(o!==""){const f=r(l,i,a);a!==null?(Debug&&(a.nodeKeyProperty===o&&a.containsNodeData(i)&&Util.at("Binding error: cannot have TwoWay Binding on node data key property: "+this.toString()),f===void 0&&Util.at(`Binding warning: conversion function returned undefined when setting source property "${o}" on ${i.toString()}, function is: ${r}`)),a.setDataProperty(i,o,f)):Model.ut(i,o,f)}else{const f=r(l,i,a);if(f!==void 0&&a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const c=s.itemIndex,u=s.panel.itemArray;a.removeArrayItem(u,c),a.insertArrayItem(u,c,f)}}}catch(f){Debug&&Util.at("Binding error: "+f.toString()+' setting source property "'+o+'" on '+i.toString()+" with conversion function: "+r)}}finally{this.Bb.delete(t)}}}class ThemeBinding extends Binding{Iy;Ah;qa;constructor(t,i,e,s,n){super(t,i,s),e==null&&(e=""),n===void 0&&(n=null),this.Iy=e,this.Ah=n,this.qa=null,this.l=16}cloneProtected(t){super.cloneProtected(t),t.Iy=this.Iy,t.Ah=this.Ah,t.qa=this.qa}rd(){return!0}get themeSource(){return this.Iy}set themeSource(t){this.f&&Util.F(this),t!==null&&Util.t(t,"string",ThemeBinding,"themeSource"),this.Iy=t,this.qa=null,t!==null?this.l=this.l|16:this.l=this.l&-17}get themeConverter(){return this.Ah}set themeConverter(t){this.f&&Util.F(this),t!==null&&Util.t(t,"function",ThemeBinding,"themeConverter"),this.Ah=t}ofData(){return this.f&&Util.F(this),this.l=this.l|2,this.Fc=null,this}VT(t,i,e,s){if(!t||(this.LN&&(i=this.Ch),!i&&i!==0))return;let n=this.themeSource;this.qa!==null?n=this.qa:typeof n=="string"&&n.includes(".")&&(this.qa=n.split("."),n=this.qa);let o=t.findValue(i,n,s);return o===void 0&&Util.at(`Theme warning: ${i} could not be found when setting target property ${s}.`),typeof this.Ah=="function"&&(o=this.Ah(o,e)),o}}class Model{Tt;lg;zo;zb;Me;Ec;Vc;hg;ag;fg;cg;ja;lr;Xb;Bo;Yb;oi;Lh;ug=new GSet;dg=new GSet;Oy;constructor(t,i){if(GSet.vi(this),this.Tt="",this.lg="",this.zo=!1,this.zb={},this.Me=[],this.oi=new GMap,this.Lh="key",this.Ec=null,this.Vc=null,this.hg=!1,this.ag=!1,this.fg=!1,this.cg=null,this.ja="category",this.lr=new GMap,this.Oy=100,this.Xb=new List,this.Bo=!1,this.Yb=null,this.undoManager=new UndoManager,t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){t.Tt=this.Tt,t.lg=this.lg,t.zo=this.zo,t.Lh=this.Lh,t.Ec=this.Ec,t.Vc=this.Vc,t.hg=this.hg,t.ag=this.ag,t.fg=this.fg,t.Oy=this.Oy,t.cg=this.cg,t.ja=this.ja}copy(){const t=new this.constructor;return this.cloneProtected(t),t}clear(){this.Me=[],this.oi.clear(),this.lr.clear(),this.undoManager.clear()}toString(t){if(t===void 0&&(t=0),t>1)return this.toJson();{let i=(this.name!==""?this.name:"")+" Model";if(t>0){i+=` - node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n{if(u.model===e){if(u.modelChange==="nodeDataArray")u.change===3?n.add(u.newValue):u.change===4&&r.add(u.oldValue);else if(e.containsNodeData(u.object))o.add(u.object);else if(u.change===2&&(e.modelData===u.object||u.propertyName==="modelData"))s=!0;else if(u.object!==null)if(l&&l.has(u.object))l.get(u.object).each(m=>{e.containsNodeData(m)&&o.add(m)});else{if(u.object instanceof Model||e.Oa()&&e.containsLinkData(u.object))return;e.zT(u.object).each(m=>{o.add(m)})}}});const h=this.dg;h.clear(),n.each(u=>{h.add(e.getKeyForNodeData(u)),i||o.add(u)});const a=this.ug;a.clear(),r.each(u=>{a.add(e.getKeyForNodeData(u)),i&&o.add(u)});const f=e.cloneDeep(o.toArray());let c=null;return s&&(c===null&&(c={}),c.modelData=this.cloneDeep(this.modelData)),h.count>0&&(c===null&&(c={}),i?c.removedNodeKeys=h.toArray():c.insertedNodeKeys=h.toArray()),f.length>0&&(c===null&&(c={}),c.modifiedNodeData=f),a.count>0&&(c===null&&(c={}),i?c.insertedNodeKeys=a.toArray():c.removedNodeKeys=a.toArray()),a.clear(),h.clear(),c}cloneDeep(t){return this.gg(t,!0)}gg(t,i,e,s,n){if(!Util.Mt(t))return t;n||(n=[]);const o=Object.isExtensible(t);if(e||(e=new GMap),o){const h=e.get(t);if(h)return h}else{s||(s=new GMap);const h=s.iterator;for(;h.next();){const a=h.key;if(h.value===t){const c=e.get(a);if(c)return c}}}function r(h,a){if(o)h.__gohashid===void 0&&n.push(h),e.set(h,a);else{const f=GSet.cu++;e.set(f,a),s.set(f,t)}}let l;if(Array.isArray(t)){l=[],r(t,l);for(let h=0;h{delete h.__gohashid}),l}Ve(t){return JSON.stringify(t).replace(/[\u007F-\uFFFF]/g,e=>{const s="0000"+e.charCodeAt(0).toString(16);return"\\u"+s.substring(s.length-4)})}mg(){let t="";return this.name!==""&&(t+=`, - "name": `+this.Ve(this.name)),this.dataFormat!==""&&(t+=`, - "dataFormat": `+this.Ve(this.dataFormat)),this.isReadOnly&&(t+=`, + `+n.toString(t-1)}}return i}get layout(){return this.re}set layout(t){t!==null&&(this.re=t)}get vertexes(){return this.ko}get edges(){return this.Fn}createVertex(){return new LayoutVertex(this)}createEdge(){return new LayoutEdge(this)}addParts(t,i,e){if(t===null)return;i===void 0&&(i=!1),Util.t(i,"boolean",LayoutNetwork,"addParts:toplevelonly"),e===void 0&&(e=null),e===null&&(e=n=>{if(n instanceof Node)return!n.isLinkLabel;if(n instanceof Link){const o=n.fromNode;if(o===null||o.isLinkLabel)return!1;const r=n.toNode;return!(r===null||r.isLinkLabel)}return!1});const s=t.iterator;for(;s.next();){const n=s.value;if(n instanceof Node&&!(i&&!n.isTopLevel)&&n.canLayout()&&e(n))if(n instanceof Group&&n.layout===null)this.addParts(n.memberParts,!1);else{if(this.findVertex(n)!==null)continue;const o=this.createVertex();o.node=n,this.addVertex(o)}}for(s.reset();s.next();){const n=s.value;if(!(n instanceof Link)||i&&!n.isTopLevel||!n.canLayout()||!e(n)||this.findEdge(n)!==null)continue;const o=n.fromNode,r=n.toNode;if(o===null||r===null||o===r)continue;const l=this.findGroupVertex(o),h=this.findGroupVertex(r);this.linkVertexes(l,h,n)}}findGroupVertex(t){if(t===null)return null;const i=t.findVisibleNode();if(i===null)return null;let e=this.findVertex(i);if(e!==null)return e;let s=i.containingGroup;for(;s!==null;){if(e=this.findVertex(s),e!==null)return e;s=s.containingGroup}return null}addVertex(t){if(t===null)return;Debug&&Util.s(t,LayoutVertex,LayoutNetwork,"addVertex:vertex"),this.ko.add(t);const i=t.node;i!==null&&this.Ay.set(i,t),t.network=this}addNode(t){if(t===null)return null;Debug&&Util.s(t,Node,LayoutNetwork,"addNode:node");let i=this.findVertex(t);return i===null&&(i=this.createVertex(),i.node=t,this.addVertex(i)),i}deleteVertex(t){if(t!==null&&(Debug&&Util.s(t,LayoutVertex,LayoutNetwork,"deleteVertex:vertex"),this.xT(t))){let i=t.nr;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}i=t.or;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}}}xT(t){if(t===null)return!1;const i=this.ko.delete(t);if(i){const e=t.node;e!==null&&this.Ay.delete(e)}return i}deleteNode(t){if(t===null)return;Debug&&Util.s(t,Node,LayoutNetwork,"deleteNode:node");const i=this.findVertex(t);i!==null&&this.deleteVertex(i)}findVertex(t){return t===null?null:(Debug&&Util.s(t,Node,LayoutNetwork,"findVertex:node"),this.Ay.get(t))}addEdge(t){if(t===null)return;Debug&&Util.s(t,LayoutEdge,LayoutNetwork,"addEdge:edge"),this.wN(t);const i=t.toVertex;i!==null&&i.addSourceEdge(t);const e=t.fromVertex;e!==null&&e.addDestinationEdge(t)}wN(t){if(t===null)return;this.Fn.add(t);const i=t.link;i!==null&&this.findEdge(i)===null&&this.Ly.set(i,t),t.network=this}addLink(t){if(t===null)return null;Debug&&Util.s(t,Link,LayoutNetwork,"addLink:link");const i=t.fromNode,e=t.toNode;let s=this.findEdge(t);return s===null?(s=this.createEdge(),s.link=t,i!==null&&(s.fromVertex=this.addNode(i)),e!==null&&(s.toVertex=this.addNode(e)),this.addEdge(s)):(i!==null?s.fromVertex=this.addNode(i):s.fromVertex=null,e!==null?s.toVertex=this.addNode(e):s.toVertex=null),s}deleteEdge(t){if(t===null)return;Debug&&Util.s(t,LayoutEdge,LayoutNetwork,"deleteEdge:edge");const i=t.toVertex;i!==null&&i.deleteSourceEdge(t);const e=t.fromVertex;e!==null&&e.deleteDestinationEdge(t),this.xN(t)}xN(t){if(t===null)return!1;const i=this.Fn.delete(t);if(i){const e=t.link;e!==null&&this.Ly.delete(e)}return i}deleteLink(t){if(t===null)return;Debug&&Util.s(t,Link,LayoutNetwork,"deleteLink:link");const i=this.findEdge(t);i!==null&&this.deleteEdge(i)}findEdge(t){return t===null?null:(Debug&&Util.s(t,Link,LayoutNetwork,"findEdge:link"),this.Ly.get(t))}linkVertexes(t,i,e){if(t===null||i===null)return null;if(Debug&&(Util.s(t,LayoutVertex,LayoutNetwork,"linkVertexes:fromVertex"),Util.s(i,LayoutVertex,LayoutNetwork,"linkVertexes:toVertex"),e!==null&&Util.s(e,Link,LayoutNetwork,"linkVertexes:link")),t.network===this&&i.network===this){const s=this.createEdge();return s.link=e,s.fromVertex=t,s.toVertex=i,this.addEdge(s),s}return null}reverseEdge(t){if(t===null)return;Debug&&Util.s(t,LayoutEdge,LayoutNetwork,"reverseEdge:edge");const i=t.fromVertex,e=t.toVertex;i===null||e===null||(i.deleteDestinationEdge(t),e.deleteSourceEdge(t),t.reverseEdge(),i.addSourceEdge(t),e.addDestinationEdge(t))}deleteSelfEdges(){const t=Util.at(),i=this.Fn.iterator;for(;i.next();){const s=i.value;s.fromVertex===s.toVertex&&t.push(s)}const e=t.length;for(let s=0;s0||t.or.count>0)}splitIntoSubNetworks(t){t===void 0&&(t=!0),t&&(this.deleteArtificialVertexes(),this.deleteUselessEdges(),this.deleteSelfEdges());const i=new List;let e=!0;for(;e;){e=!1;const s=this.ko.iterator;for(;s.next();){const n=s.value;if(this.isSingleton(n))continue;const o=this.layout.createNetwork();i.add(o),this.AO(o,n),e=!0;break}}return i.sort((s,n)=>s===null||n===null||s===n?0:n.vertexes.count-s.vertexes.count),i}AO(t,i){if(i===null)return;const e=new List;for(e.add(i);e.count>0;){const s=e.first();if(e.removeAt(0),s.network===t)continue;this.xT(s),t.addVertex(s);let n=s.sourceEdges;for(;n.next();){const o=n.value;o.network!==t&&(this.xN(o),t.wN(o),e.add(o.fromVertex))}for(n=s.destinationEdges;n.next();){const o=n.value;o.network!==t&&(this.xN(o),t.wN(o),e.add(o.toVertex))}}}findAllParts(){const t=new GSet,i=this.ko.iterator;for(;i.next();){const s=i.value;t.add(s.node)}const e=this.Fn.iterator;for(;e.next();){const s=e.value;t.add(s.link)}return t}}class LayoutVertex{bo;si;we;Oe;Qe;nr;or;constructor(t){GSet.vi(this),Debug&&!t&&Util.n("LayoutVertex constructor requires non-null LayoutNetwork argument"),this.bo=t,this.Oe=new Rect(0,0,10,10).w(),this.Qe=new Point(5,5).w(),this.si=null,this.we=null,this.nr=new List,this.or=new List}clear(){this.si=null,this.we=null,this.nr=new List,this.or=new List}toString(t){t===void 0&&(t=0);let i="LayoutVertex#"+GSet.gs(this);if(t>0&&(i+=this.node!==null?"("+this.node.toString()+")":"",t>1)){let e="",s=!0,n=this.nr.iterator;for(;n.next();){const r=n.value;s?s=!1:e+=",",e+=r.toString(0)}let o="";for(s=!0,n=this.or.iterator;n.next();){const r=n.value;s?s=!1:o+=",",o+=r.toString(0)}i+=" sources: "+e+" destinations: "+o}return i}get So(){return this.nr.eC}get rr(){return this.or.eC}get data(){return this.si}set data(t){if(this.si=t,t!==null&&t.bounds){const i=t.bounds,e=i.x,s=i.y,n=i.width,o=i.height;this.Qe.e(n/2,o/2),this.Oe.e(e,s,n,o)}}get node(){return this.we}set node(t){if(this.we!==t){Debug&&t!==null&&Util.s(t,Node,LayoutVertex,"node"),this.we=t,t.ensureBounds();const i=this.network.layout,e=Rect.a(),s=i.getLayoutBounds(t,e);let n=s.x,o=s.y;const r=s.width,l=s.height;if(isNaN(n)&&(n=0),isNaN(o)&&(o=0),this.Oe.e(n,o,r,l),Rect.o(e),!(t instanceof Group)){const h=t.locationObject.getDocumentPoint(Spot.Center);if(h.isReal()){this.Qe.e(h.x-n,h.y-o);return}}this.Qe.e(r/2,l/2)}}get bounds(){return this.Oe}set bounds(t){this.Oe.equals(t)||(Debug&&Util.s(t,Rect,LayoutVertex,"bounds"),this.Oe.c(t))}get focus(){return this.Qe}set focus(t){this.Qe.equals(t)||(Debug&&Util.s(t,Point,LayoutVertex,"focus"),this.Qe.c(t))}get centerX(){return this.Oe.x+this.Qe.x}set centerX(t){const i=this.Oe;i.x+this.Qe.x!==t&&(Debug&&Util.r(t,LayoutVertex,"centerX"),i.ft(),i.x=t-this.Qe.x,i.w())}get centerY(){return this.Oe.y+this.Qe.y}set centerY(t){const i=this.Oe;i.y+this.Qe.y!==t&&(Debug&&Util.r(t,LayoutVertex,"centerY"),i.ft(),i.y=t-this.Qe.y,i.w())}get focusX(){return this.Qe.x}set focusX(t){const i=this.Qe;i.x!==t&&(i.ft(),i.x=t,i.w())}get focusY(){return this.Qe.y}set focusY(t){const i=this.Qe;i.y!==t&&(i.ft(),i.y=t,i.w())}get x(){return this.Oe.x}set x(t){const i=this.Oe;i.x!==t&&(i.ft(),i.x=t,i.w())}get y(){return this.Oe.y}set y(t){const i=this.Oe;i.y!==t&&(i.ft(),i.y=t,i.w())}get width(){return this.Oe.width}set width(t){const i=this.Oe;i.width!==t&&(i.ft(),i.width=t,i.w())}get height(){return this.Oe.height}set height(t){const i=this.Oe;i.height!==t&&(i.ft(),i.height=t,i.w())}commit(){const t=this.si;if(t!==null){const e=this.bounds,s=t.bounds;Util.Mt(s)?(s.x=e.x,s.y=e.y,s.width=e.width,s.height=e.height):t.bounds=e.copy();return}const i=this.node;if(i!==null){const e=this.bounds;if(!(i instanceof Group)){const s=Rect.a();i.ensureBounds();const n=this.network.layout.getLayoutBounds(i,s),o=i.locationObject.getDocumentPoint(Spot.Center);if(n.isReal()&&o.isReal()){i.moveTo(e.x+this.focusX-(o.x-n.x)+i.margin.left,e.y+this.focusY-(o.y-n.y+i.margin.top)),Rect.o(s);return}Rect.o(s)}i.moveTo(e.x+i.margin.left,e.y+i.margin.top)}}addSourceEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"addSourceEdge:edge"),this.nr.has(t)||this.nr.add(t))}deleteSourceEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"deleteSourceEdge:edge"),this.nr.delete(t))}addDestinationEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"addDestinationEdge:edge"),this.or.has(t)||this.or.add(t))}deleteDestinationEdge(t){t!==null&&(Debug&&Util.s(t,LayoutEdge,LayoutVertex,"deleteDestinationEdge:edge"),this.or.delete(t))}get network(){return this.bo}set network(t){Debug&&Util.s(t,LayoutNetwork,LayoutVertex,"network"),this.bo=t}get sourceVertexes(){const t=new GSet,i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}return t.iterator}get destinationVertexes(){const t=new GSet,i=this.destinationEdges;for(;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get vertexes(){const t=new GSet;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get sourceEdges(){return this.nr.iterator}get destinationEdges(){return this.or.iterator}get edges(){const t=new List;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e)}return t.iterator}get edgesCount(){return this.nr.count+this.or.count}static standardComparer(t,i){Debug&&Util.s(t,LayoutVertex,LayoutVertex,"standardComparer:m"),Debug&&Util.s(i,LayoutVertex,LayoutVertex,"standardComparer:n");const e=t.we,s=i.we;if(e)if(s){const n=e.text,o=s.text;return no?1:0}else return 1;else return s!==null?-1:0}static smartComparer(t,i){if(Debug&&Util.s(t,LayoutVertex,LayoutVertex,"smartComparer:m"),Debug&&Util.s(i,LayoutVertex,LayoutVertex,"smartComparer:n"),t!==null)if(i!==null){const e=t.we,s=i.we;if(e!==null)if(s!==null){const n=e.text.toLocaleLowerCase(),o=s.text.toLocaleLowerCase(),r=n.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),l=o.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let h=0;for(;h0&&(i+=this.$e!==null?"("+this.$e.toString()+")":"",t>1&&(i+=" "+(this._e?this._e.toString():"null")+" --> "+(this.ts?this.ts.toString():"null"))),i}reverseEdge(){const t=this._e;this._e=this.ts,this.ts=t}commit(){}getOtherVertex(t){return Debug&&Util.s(t,LayoutVertex,LayoutEdge,"getOtherVertex:v"),this.ts===t?this._e:this._e===t?this.ts:null}get network(){return this.bo}set network(t){Debug&&Util.s(t,LayoutNetwork,LayoutEdge,"network"),this.bo=t}get data(){return this.si}set data(t){this.si!==t&&(Debug&&t!==null&&Util.t(t,"object",LayoutEdge,"data"),this.si=t)}get link(){return this.$e}set link(t){this.$e!==t&&(Debug&&t!==null&&Util.s(t,Link,LayoutEdge,"link"),this.$e=t)}get fromVertex(){return this._e}set fromVertex(t){this._e!==t&&(Debug&&t!==null&&Util.s(t,LayoutVertex,LayoutEdge,"fromVertex"),this._e=t)}get toVertex(){return this.ts}set toVertex(t){this.ts!==t&&(Debug&&t!==null&&Util.s(t,LayoutVertex,LayoutEdge,"toVertex"),this.ts=t)}}var GridAlignment=(w=>(w[w.Position=0]="Position",w[w.Location=1]="Location",w))(GridAlignment||{}),GridArrangement=(w=>(w[w.LeftToRight=10]="LeftToRight",w[w.RightToLeft=11]="RightToLeft",w))(GridArrangement||{}),GridSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w))(GridSorting||{});class GridLayout extends Layout{ig;eg;Ro;Rn;ai;qi;ke;Se;constructor(t){super(),this.isViewportSized=!0,this.ig=NaN,this.eg=NaN,this.Ro=new Size(NaN,NaN).w(),this.Rn=new Size(10,10).w(),this.ai=1,this.qi=10,this.ke=22,this.Se=GridLayout.standardComparer,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.ig=this.ig,t.eg=this.eg,t.Ro.c(this.Ro),t.Rn.c(this.Rn),t.ai=this.ai,t.qi=this.qi,t.ke=this.ke,t.Se=this.Se}fi(t){t in GridSorting?this.sorting=t:t in GridArrangement?this.arrangement=t:t in GridAlignment?this.alignment=t:super.fi(t)}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.collectParts(t),e=this.diagram,n=i.copy().iterator;for(;n.next();){const m=n.value;if(m.Dl()&&(m.fromNode!==null||m.toNode!==null)){i.delete(m);continue}if(m.ensureBounds(),m instanceof Group){const g=m.memberParts;for(;g.next();){const p=g.value;i.delete(p)}}}const o=i.toArray();if(o.length===0)return;switch(this.sorting){case 20:break;case 21:o.reverse();break;case 22:o.sort(this.comparer);break;case 23:o.sort(this.comparer),o.reverse();break}let r=this.wrappingColumn;isNaN(r)&&(r=0);let l=this.wrappingWidth;if(isNaN(l)&&e!==null){const m=e.viewportBounds,g=e.padding;l=Math.max(m.width-g.left-g.right,0)}else l=Math.max(this.wrappingWidth,0);r<=0&&l<=0&&(r=1);let h=this.spacing.width;isFinite(h)||(h=0);let a=this.spacing.height;isFinite(a)||(a=0),e!==null&&e.startTransaction("Layout");const f=[];switch(this.alignment){case 0:this.LO(o,l,r,h,a,f);break;case 1:this.TO(o,l,r,h,a,f);break}let c=0,u=0,d=0;for(let m=0;m0&&m>e-1||i>0&&m>0&&A-f>i)&&(o.push(new Rect(0,d,i+s,g)),m=0,u=f,d+=g,g=0),g=Math.max(g,M);let C=0;switch(a){case 11:C=-x.width;break;default:C=0;break}switch(y.moveTo(u+C+y.margin.left,d+y.margin.top),a){case 11:u-=S;break;default:u+=S;break}m++}o.push(new Rect(0,d,i+s,g)),Rect.o(r)}TO(t,i,e,s,n,o){const r=Rect.a();let l=Math.max(this.cellSize.width,1),h=0,a=0,f=0;const c=Point.a();for(let C=0;C=h&&(i-=h);let x=0,k=0;const b=Math.max(this.cellSize.height,1);f=0;let S=0,M=!0;const A=Point.a();for(let C=0;C0)switch(u){case 11:{let D=(g-d-(N.width-T.x))/l;Geo.q(Math.round(D),D)?D=Math.round(D):D=Math.floor(D),g=D*l+d;break}default:{let D=(g-d+T.x)/l;Geo.q(Math.round(D),D)?D=Math.round(D):D=Math.ceil(D),g=D*l+d;break}}else switch(u){case 11:x=g+T.x+N.width;break;default:x=g-T.x;break}let L=0;switch(u){case 11:L=-(g+T.x)+x;break;default:L=g+N.width-T.x-x;break}if(e>0&&y>e-1||i>0&&y>0&&L>i){o.push(new Rect(0,M?p-f:p,i+s,S+f+n));for(let D=0;Dk&&(P.width+=P.x-k,P.x=k)}Rect.o(r)}commitLayers(t,i){}get wrappingWidth(){return this.ig}set wrappingWidth(t){this.ig!==t&&(Util.t(t,"number",GridLayout,"wrappingWidth"),(t>0||isNaN(t))&&(this.ig=t,this.isViewportSized=isNaN(t),this.invalidateLayout()))}get wrappingColumn(){return this.eg}set wrappingColumn(t){this.eg!==t&&(Util.t(t,"number",GridLayout,"wrappingColumn"),(t>0||isNaN(t))&&(this.eg=t,this.invalidateLayout()))}get cellSize(){return this.Ro}set cellSize(t){Util.s(t,Size,GridLayout,"cellSize"),this.Ro.equals(t)||(this.Ro.c(t),this.invalidateLayout())}get spacing(){return this.Rn}set spacing(t){Util.s(t,Size,GridLayout,"spacing"),this.Rn.equals(t)||(this.Rn.c(t),this.invalidateLayout())}get alignment(){return this.ai}set alignment(t){this.ai!==t&&(Util.tt(t,GridAlignment,"GridAlignment"),(t===1||t===0)&&(this.ai=t,this.invalidateLayout()))}get arrangement(){return this.qi}set arrangement(t){this.qi!==t&&(Util.tt(t,GridArrangement,"GridArrangement"),(t===10||t===11)&&(this.qi=t,this.invalidateLayout()))}get sorting(){return this.ke}set sorting(t){this.ke!==t&&(Util.tt(t,GridSorting,"GridSorting"),(t===20||t===21||t===22||t===23)&&(this.ke=t,this.invalidateLayout()))}get comparer(){return this.Se}set comparer(t){this.Se!==t&&(Util.t(t,"function",GridLayout,"comparer"),this.Se=t,this.invalidateLayout())}static standardComparer(t,i){Debug&&Util.s(t,Part,GridLayout,"standardComparer:a"),Debug&&Util.s(i,Part,GridLayout,"standardComparer:b");const e=t.text,s=i.text;return es?1:0}static smartComparer(t,i){if(Debug&&Util.s(t,Part,GridLayout,"standardComparer:a"),Debug&&Util.s(i,Part,GridLayout,"standardComparer:b"),t!==null)if(i!==null){const e=t.text.toLocaleLowerCase(),s=i.text.toLocaleLowerCase(),n=e.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),o=s.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let r=0;for(;r{e.containsNodeData(s)&&this.MT(s,!1)}),t.forEach(s=>{e.containsNodeData(s)&&this.Rb(s)}),i!==!1&&this.diagram.R1(!1)}MT(t,i){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.Mo.has(t))return null;i===void 0&&(i=!0);const e=this.DO(t);return e!==null&&i&&this.Rb(t),e}DO(t){if(t==null||this.b.undoManager.isUndoingRedoing||this.Mo.has(t))return null;const i=this.FO(t),e=this.findTemplateForNodeData(t,i);if(e!==null){e.ci();const s=e.copy();if(s!==null){const n=this.diagram.pe;return this.diagram.pe=!0,s.$o=i,s.si=t,this.Ty&&(s.ul="Tool"),this.diagram.add(s),s.si=null,s.data=t,this.diagram.pe=n,s}}return null}insertLink(t,i,e,s){return null}Rb(t){}FO(t){return this.b.model.getCategoryForNodeData(t)}static PT=!1;static NT=!1;findTemplateForNodeData(t,i){const e=this.b,s=e.model,n=s.ga()&&s.isGroupForData(t);let o=null;return n?(o=e.groupTemplateMap.get(i),o===null&&(o=e.groupTemplateMap.get(""),o===null&&(PartManager.NT||(PartManager.NT=!0,Util.ht('No Group template found for category "'+i+'"'),Util.ht(" Using default group template")),o=e.gP))):(o=e.nodeTemplateMap.get(i),o===null&&(o=e.nodeTemplateMap.get(""),o===null&&(PartManager.PT||(PartManager.PT=!0,Util.ht('No Node template found for category "'+i+'"'),Util.ht(" Using default node template")),o=e.cP))),o}getLinkCategoryForData(t){return""}setLinkCategoryForData(t,i){}setFromNodeForLink(t,i,e){}setToNodeForLink(t,i,e){}static CT=!1;findLinkTemplateForCategory(t){const i=this.b;let e=i.linkTemplateMap.get(t);return e===null&&(e=i.linkTemplateMap.get(""),e===null&&(PartManager.CT||(PartManager.CT=!0,Util.ht('No Link template found for category "'+t+'"'),Util.ht(" Using default link template")),e=i.uP)),e}wI(t,i,e){t instanceof Link?(i!==null&&this.kT(i,t),e!==null&&this.bT(e,t)):t instanceof Part&&(i!==null&&this.Mo.delete(i),e!==null&&this.Mo.set(e,t))}ST(){const t=this.diagram.model;this.kN(t.nodeDataArray)}kN(t){t.forEach(i=>{this.Ib(i)})}Ib(t){const i=this.findPartForData(t);i!==null&&(this.diagram.IP(i,!1),this.SN(i))}SN(t){}uN(t){}findPartForKey(t){if(t==null)return null;const i=this.b.model.findNodeDataForKey(t);return i!==null?this.Mo.get(i):null}findNodeForKey(t){if(t==null)return null;const i=this.b.model.findNodeDataForKey(t);if(i===null)return null;const e=this.Mo.get(i);return e instanceof Node?e:null}findLinkForKey(t){return null}findPartForData(t){if(t===null)return null;let i=this.Mo.get(t);return i!==null||(i=this.yl.get(t)),i}findNodeForData(t){if(t===null)return null;const i=this.Mo.get(t);return i instanceof Node?i:null}findLinkForData(t,i){return t===null?null:this.yl.get(t)}findNodesByExample(...t){const i=new GSet,e=this.sg.iterator;for(;e.next();){const s=e.value,n=s.data;if(n!==null)for(let o=0;o{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),this.parts.each(o=>{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),s.forEach(o=>t.LT(o,!1));for(let o=0;o0){for(let o=0;oi.DA(s));const e=t.xh;if(Array.isArray(e)){const s=this.Ha.get(e);if(s===null){const n=[];n.push(t),this.Ha.set(e,n)}else{for(let n=0;ni.SR(s));const e=t.xh;if(Array.isArray(e)){const s=this.Ha.get(e);if(s!==null){for(let n=0;n0&&i.removeParts(l,!1),h.count>0){const f=h.iterator;for(;f.next();){const c=f.key,u=f.value;s.set(c,u)}}}if(i!==null&&this.b!==null){const o=i.model,r=o.afterCopyFunction;if(r!==null){const l=new GMap;s.each(a=>{a.key.data!==null&&l.set(a.key.data,a.value.data)});const h=this.b.model;r(l,o,h)}}const n=s.iterator;for(;n.next();)n.value.updateTargetBindings();return s}Ob(t,i,e,s){if(t===null||s&&!t.canCopy())return null;if(e.has(t))return e.get(t);const n=this.PN(t,i);if(!(n instanceof Part))return null;if(n.isSelected=!1,n.isHighlighted=!1,e.set(t,n),t instanceof Node){const o=t.linksConnected;for(;o.next();){const r=o.value;if(r.fromNode===t){const l=e.get(r);l!==null&&(l.fromNode=n)}if(r.toNode===t){const l=e.get(r);l!==null&&(l.toNode=n)}}if(t instanceof Group&&n instanceof Group){const r=t.memberParts;for(;r.next();){const l=r.value,h=this.Ob(l,i,e,s);h instanceof Link||h!==null&&(h.containingGroup=n)}}}else if(t instanceof Link&&n instanceof Link){const o=t.fromNode;if(o!==null){const h=e.get(o);h!==null&&(n.fromNode=h)}const r=t.toNode;if(r!==null){const h=e.get(r);h!==null&&(n.toNode=h)}const l=t.labelNodes;for(;l.next();){const h=l.value,a=this.Ob(h,i,e,s);a!==null&&a instanceof Node&&(a.labeledLink=n)}}return n}PN(t,i){let e=null;const s=t.data;if(s!==null&&i!==null){const n=i.model;if(!(t instanceof Link)){const o=n.copyNodeData(s);Util.Mt(o)&&(n.addNodeData(o),e=i.findPartForData(o))}}else if(t.ci(),e=t.copy(),e!==null){const n=this.b;if(i!==null)i.add(e);else if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const o=n.model;let r=null;e instanceof Link||(r=o.copyNodeData(s)),Util.Mt(r)&&(e.data=r)}}return e}get nodes(){return this.sg}get links(){return this.Qs}get parts(){return this.It}get diagram(){return this.b}get addsToTemporaryLayer(){return this.Ty}set addsToTemporaryLayer(t){this.Ty=t}get preservesRebuildLocations(){return this.bN}set preservesRebuildLocations(t){this.bN=t}}class GraphLinksPartManager extends PartManager{EP(){const t=this.diagram.model;this.Dy(t.nodeDataArray),this.FT(t.linkDataArray)}Dy(t){super.Dy(t,!1);const i=this.links.iterator;for(;i.next();)i.value.Od();this.diagram.R1(!1)}FT(t){t.forEach(i=>{this.RT(i)}),this.diagram.R1(!1)}RT(t){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.yl.has(t))return null;const i=this.getLinkCategoryForData(t),e=this.findLinkTemplateForCategory(i);if(e!==null){e.ci();const s=e.copy();if(s!==null){const n=this.diagram.pe;this.diagram.pe=!0,s.$o=i,s.si=t;const o=this.diagram.model,r=o.Eb(t,!0);r!==""&&(s.fromPortId=r);const l=o.Ee(t,!0);if(l!==void 0){const c=this.findNodeForKey(l);c instanceof Node&&(s.fromNode=c)}const h=o.Eb(t,!1);h!==""&&(s.toPortId=h);const a=o.Ee(t,!1);if(a!==void 0){const c=this.findNodeForKey(a);c instanceof Node&&(s.toNode=c)}const f=o.getLabelKeysForLinkData(t);return Array.isArray(f)&&f.forEach(c=>{const u=this.findNodeForKey(c);u!==null&&(u.labeledLink=s)}),this.Ty&&(s.ul="Tool"),this.diagram.add(s),s.si=null,s.data=t,this.diagram.pe=n,s}}return null}ST(){const t=this.diagram.model;this.IT(t.linkDataArray),this.kN(t.nodeDataArray)}IT(t){t.forEach(i=>{this.Ib(i)})}getLinkCategoryForData(t){return this.diagram.model.getCategoryForLinkData(t)}setLinkCategoryForData(t,i){return this.diagram.model.setCategoryForLinkData(t,i)}setFromNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setFromKeyForLinkData(t.data,e.getKeyForNodeData(s))}setToNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setToKeyForLinkData(t.data,e.getKeyForNodeData(s))}uN(t){this.diagram.model.removeLinkData(t.data)}findPartForKey(t){const i=super.findPartForKey(t);if(i===null){const s=this.diagram.model.findLinkDataForKey(t);if(s!==null)return this.yl.get(s)}return i}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findLinkDataForKey(t);return e!==null?this.yl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.j){i.j=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="linkFromKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.fromNode=l}}else if(s==="linkToKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.toNode=l}}else if(s==="linkFromPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.fromPortId=r)}}else if(s==="linkToPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.toPortId=r)}}else if(s==="nodeGroupKey"){const n=t.object,o=this.findPartForData(n);if(o!==null){const r=t.newValue;if(r!==void 0){const l=this.findNodeForKey(r);l instanceof Group?o.containingGroup=l:o.containingGroup=null}else o.containingGroup=null}}else if(s==="linkLabelKeys"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.oldValue,l=t.newValue;Array.isArray(r)&&r.forEach(h=>{if(l.indexOf(h)>=0)return;const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=null)}),Array.isArray(l)&&l.forEach(h=>{const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=o)})}}else if(s==="linkCategory"){const n=t.object,o=this.findLinkForData(n),r=t.newValue;o!==null&&typeof r=="string"&&(o.category=r)}else if(s==="linkDataArray"){const n=t.oldValue;this.IT(n);const o=t.newValue;this.FT(o)}i.isModified=!0}else if(e===3){const n=t.newValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.RT(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=t.object,r=this.findLinkForData(o),l=this.findNodeForKey(n);r!==null&&l!==null&&(l.labeledLink=r)}i.isModified=!0}else if(e===4){const n=t.oldValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.Ib(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=this.findNodeForKey(n);o!==null&&(o.labeledLink=null)}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&(n==="linkFromKeyProperty"||n==="linkToKeyProperty"||n==="linkFromPortIdProperty"||n==="linkToPortIdProperty"||n==="linkLabelKeysProperty"||n==="nodeIsGroupProperty"||n==="nodeGroupKeyProperty"||n==="linkCategoryProperty")&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.j=!0}}}DT(){const t=this.diagram.model,i=new GSet,e=t.linkDataArray;e.forEach(n=>{i.add(n)});const s=[];this.links.each(n=>{n.data!==null&&!i.has(n.data)&&s.push(n.data)}),s.forEach(n=>{t.OT(n,!1)}),e.forEach(n=>{this.findLinkForData(n)===null&&t.ET(n,!1)})}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Link){let n=s.Ee(i,!0),o=e.findNodeForKey(n);t.fromNode=o,n=s.Ee(i,!1),o=e.findNodeForKey(n),t.toNode=o;const r=s.getLabelKeysForLinkData(i);if(r.length>0||t.labelNodes.count>0){if(r.length===1&&t.labelNodes.count===1){const c=r[0],u=t.labelNodes.first();if(s.getKeyForNodeData(u.data)===c)return}const l=new GSet().addAll(r),h=new GSet;t.labelNodes.each(c=>{if(c.data!==null){const u=s.getKeyForNodeData(c.data);u!==void 0&&h.add(u)}});const a=h.copy();a.removeAll(l);const f=l.copy();if(f.removeAll(h),a.count>0||f.count>0){const c=t;a.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink===c&&(d.labeledLink=null)}),f.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink!==c&&(d.labeledLink=c)})}}}else if(!(t instanceof Adornment)){const n=s.getGroupKeyForNodeData(i),o=e.findPartForKey(n);(o===null||o instanceof Group)&&(t.containingGroup=o)}}Rb(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Ry(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)){if(n instanceof Group&&i.getGroupKeyForNodeData(l)===e){const h=this.findPartForData(l);h!==null&&(h.containingGroup=n)}}else{const h=this.findLinkForData(l);if(h!==null&&n instanceof Node){i.Ee(l,!0)===e&&(h.fromNode=n),i.Ee(l,!1)===e&&(h.toNode=n);const a=i.getLabelKeysForLinkData(l);Array.isArray(a)&&a.some(f=>f===e?(n.labeledLink=h,!0):!1)}}}i.tn(e)}const o=i.getGroupKeyForNodeData(t);if(o!==void 0){const r=this.findNodeForKey(o);r instanceof Group&&(n.containingGroup=r)}}}SN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data);if(e!==void 0){const s=t.linksConnected;for(;s.next();){const n=s.value;i.en(e,n.data)}if(t.isLinkLabel){const n=t.labeledLink;n!==null&&i.en(e,n.data)}if(t instanceof Group){const n=t.memberParts;for(;n.next();){const r=n.value.data;i.containsNodeData(r)&&i.en(e,r)}}}}}PN(t,i){let e=super.PN(t,i);if(t instanceof Link){const s=t.data;if(s!==null&&i!==null){const n=i.model,o=n.copyLinkData(s);typeof o=="object"&&o!==null&&(n.addLinkData(o),e=i.findLinkForData(o))}else if(e!==null){const n=this.diagram;if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const r=n.model.copyLinkData(s);typeof r=="object"&&r!==null&&(e.data=r)}}}return e}insertLink(t,i,e,s){const n=this.diagram,o=n.model,r=n.toolManager.findTool("Linking");let l="";t!==null&&(i===null&&(i=t),l=i.portId,l===null&&(l=""));let h="";e!==null&&(s===null&&(s=e),h=s.portId,h===null&&(h=""));const a=r.archetypeLinkData;if(a instanceof Link){a.ci();const f=a.copy();if(f!==null){f.fromNode=t,f.fromPortId=l,f.toNode=e,f.toPortId=h,n.add(f);const c=r.archetypeLabelNodeData;if(c instanceof Node){c.ci();const u=c.copy();u!==null&&(u.labeledLink=f,n.add(u))}return f}}else if(a!==null){const f=o.copyLinkData(a);if(typeof f=="object"&&f!==null){t!==null&&o.ng(f,o.getKeyForNodeData(t.data),!0),o.og(f,l,!0),e!==null&&o.ng(f,o.getKeyForNodeData(e.data),!1),o.og(f,h,!1),o.addLinkData(f);const c=r.archetypeLabelNodeData;if(c!==null&&!(c instanceof Node)){const d=o.copyNodeData(c);if(typeof d=="object"&&d!==null){o.addNodeData(d);const m=o.getKeyForNodeData(d);m!==void 0&&o.addLabelKeyForLinkData(f,m)}}return n.findLinkForData(f)}}return null}}class TreePartManager extends PartManager{Ch=null;Bb(t,i){if(t===null||i===null||i.findTreeParentLink()!==null)return null;const e=this.diagram.toolManager.findTool("Linking");let s=t,n=i;if(this.diagram.isTreePathToChildren){if(e!==null&&e.Cu(s,n,null,!0))return null}else if(s=i,n=t,e!==null&&e.Cu(s,n,null,!0))return null;const o=this.getLinkCategoryForData(i.data),r=this.findLinkTemplateForCategory(o);if(r!==null){r.ci();const l=r.copy();if(l!==null){const h=this.diagram.pe;return this.diagram.pe=!0,l.$o=o,l.si=i.data,l.fromNode=s,l.toNode=n,this.diagram.add(l),l.si=null,l.data=i.data,this.diagram.pe=h,l}}return null}getLinkCategoryForData(t){return this.diagram.model.getParentLinkCategoryForNodeData(t)}setLinkCategoryForData(t,i){this.diagram.model.setParentLinkCategoryForNodeData(t,i)}setFromNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren)s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n));else{const o=this.Ch;this.Ch=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.toNode!==null?t.toNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Ch=o}}setToNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren){const o=this.Ch;this.Ch=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.fromNode!==null?t.fromNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Ch=o}else s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n))}uN(t){this.diagram.model.setParentKeyForNodeData(t.data,void 0)}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findNodeDataForKey(t);return e!==null?this.yl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.j){i.j=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="nodeParentKey"){const n=t.object,o=t.newValue,r=this.findNodeForKey(o),l=this.findNodeForData(n);if(this.Ch!==null)r!==null&&(this.Ch.data=n,this.Ch.category=this.getLinkCategoryForData(n));else if(l!==null){const h=l.findTreeParentLink();h!==null?r===null?i.remove(h):i.isTreePathToChildren?h.fromNode=r:h.toNode=r:this.Bb(r,l)}}else if(s==="parentLinkCategory"){const n=t.object,o=this.findNodeForData(n),r=t.newValue;if(o!==null&&typeof r=="string"){const l=o.findTreeParentLink();l!==null&&(l.category=r)}}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&n==="nodeParentKeyProperty"&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.j=!0}}}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Node){const n=s.getParentKeyForNodeData(i),o=e.findNodeForKey(n),r=t.findTreeParentNode();if(o!==r){const l=t.findTreeParentLink();o!==null?l!==null?e.isTreePathToChildren?l.fromNode=o:l.toNode=o:this.Bb(o,t):l!==null&&e.IP(l,!1)}}}Fy(t,i){if(super.Fy(t,i),typeof i=="string"&&this.findPartForData(t)!==null){const s=this.findLinkForData(t);s!==null&&s.updateTargetBindings(i)}}Rb(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Ry(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)&&n instanceof Node&&i.getParentKeyForNodeData(l)===e){const h=this.findNodeForData(l);this.Bb(n,h)}}i.tn(e)}const o=i.getParentKeyForNodeData(t);if(o!==void 0&&n instanceof Node){const r=this.findNodeForKey(o);this.Bb(r,n)}}}SN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data),s=this.findLinkForData(t.data);if(s!==null){s.isSelected=!1,s.isHighlighted=!1;const r=s.layer;if(r!==null){const l=r.oe(-1,s,!1);l>=0&&this.diagram.raiseChangedEvent(4,"parts",r,s,null,l,null);const h=s.layerChanged;h!==null&&h(s,r,null)}}const n=this.diagram.isTreePathToChildren,o=t.linksConnected;for(;o.next();){const r=o.value,h=(n?r.toNode:r.fromNode).data;i.containsNodeData(h)&&i.en(e,h)}}}insertLink(t,i,e,s){const n=this.diagram.model;let o=t,r=e;if(this.diagram.isTreePathToChildren||(o=e,r=t),o!==null&&r!==null){const l=o.data,h=r.data;return n.setParentKeyForNodeData(h,n.getKeyForNodeData(l)),r.findTreeParentLink()}return null}}var BindingMode=(w=>(w[w.OneWay=1]="OneWay",w[w.TwoWay=2]="TwoWay",w))(BindingMode||{});class Binding{l;NN;qa;Rc;Ah;Ic;Oc;Ec;Vb;Ce;kd;yc;constructor(t,i,e,s){GSet.vi(this),t===void 0?t="":Util.t(t,"string",Binding,"constructor:targetprop"),i===void 0?i=t:Util.t(i,"string",Binding,"constructor:sourceprop"),e===void 0?e=null:e!==null&&Util.t(e,"function",Binding,"constructor:conv"),this.NN=-1,this.Ce=null,this.qa=t,this.kd=0,this.yc=0,this.Rc=null,this.Ah=i,this.Ic=e,s===void 0?(this.Oc=1,this.Ec=null):(this.Oc=2,this.Ec=s),this.Vb=new GSet,this.l=2}copy(){const t=new this.constructor;return this.cloneProtected(t),t}cloneProtected(t){t.qa=this.qa,t.kd=this.kd,t.yc=this.yc,t.Rc=this.Rc,t.Ah=this.Ah,t.Ic=this.Ic,t.Oc=this.Oc,t.Ec=this.Ec,t.l=this.l&-2}static OneWay=1;static TwoWay=2;static parseEnum(t,i){return Util.t(t,"function",Binding,"parseEnum:ctor"),e=>{let s=parseInt(e);return isNaN(s)&&(s=Util.Xh(t,e),s===null)?i:s}}fi(t){t in BindingMode?this.mode=t:Util.ur(this,t)}static toString(t){return Util.toString(t)}toString(){return"Binding("+this.targetProperty+":"+this.sourceProperty+(this.targetId!==-1?" "+this.targetId:"")+" "+BindingMode[this.mode]+")"}w(){return this.l=this.l|1,this}ft(){return this.l=this.l&-2,this}get targetId(){return this.NN}set targetId(t){this.f&&Util.F(this),Util.t(t,"number",Binding,"targetId"),this.NN=t}get targetProperty(){return this.qa}set targetProperty(t){this.f&&Util.F(this),Util.t(t,"string",Binding,"targetProperty"),this.qa=t}get sourceProperty(){return this.Ah}set sourceProperty(t){this.f&&Util.F(this),Util.t(t,"string",Binding,"sourceProperty"),this.Ah=t}get f(){return(this.l&1)!==0}get isToData(){return(this.l&2)!==0}get isToObject(){return(this.l&4)!==0}get isToModel(){return(this.l&8)!==0}get isToTheme(){return(this.l&16)!==0}get CN(){return this.isToTheme&&!(this.isToData||this.isToObject||this.isToModel)}od(){return!1}get sourceName(){return this.Rc}set sourceName(t){this.f&&Util.F(this),t!==null&&Util.t(t,"string",Binding,"sourceName"),this.Rc=t,t!==null?this.l=this.l&-3|4:this.l=this.l|2}get converter(){return this.Ic}set converter(t){this.f&&Util.F(this),t!==null&&Util.t(t,"function",Binding,"converter"),this.Ic=t}get backConverter(){return this.Ec}set backConverter(t){this.f&&Util.F(this),t!==null&&Util.t(t,"function",Binding,"backConverter"),this.Ec=t}get mode(){return this.Oc}set mode(t){this.f&&Util.F(this),this.isToTheme&&t===2&&Util.n("Theme Bindings cannot be TwoWay."),Util.tt(t,BindingMode,"BindingMode"),this.Oc=t}makeTwoWay(t){return this.isToTheme&&Util.n("Theme Bindings cannot be TwoWay."),this.mode=2,t&&(Util.t(t,"function",Binding,"makeTwoWay"),this.backConverter=t),this}ofObject(t){return this.f&&Util.F(this),t===void 0&&(t=""),Debug&&Util.t(t,"string",Binding,"ofObject:srcname"),this.sourceName=t,this}ofModel(){return this.f&&Util.F(this),this.l=this.l&-3&-5|8,this.Rc=null,this}oL(t,i){const e=this.sourceName;let s=null;return e===null||e===""?s=t:e==="/"?s=i.part:e==="."?s=i:e===".."?s=i.panel:s=t.findObject(e),s}check(t){const i=this.qa,e=this.Ah,s=this.Ic;(this.od()&&s===null&&this.Lh===null&&i===""||s===null&&i==="")&&Util.ht("Binding error: target property is the empty string: "+this.toString()),this.od()&&this.CN&&e===""&&s===null&&this.Lh===null&&Util.ht("Binding error: theme bindings require a source property when not using a converter: "+this.toString()),t&&typeof i=="string"&&(typeof t.setAttribute!="function"&&i.length>0&&i[0]!=="_"&&!Util.yw(t,i)?Util.ht("Binding error: undefined target property: "+i+" on "+t.toString()):i==="name"&&t instanceof GraphObject&&Util.ht("Binding error: cannot modify GraphObject.name on "+t.toString()))}updateTarget(t,i,e){const s=this.Ah;if(e!==void 0&&s!==""&&s!==e)return;const n=this.qa,o=this.Ic;let r=i;if(s!==""&&!this.CN&&(r=Model.Xt(i,s)),r===void 0)return;const l=t.diagram?.themeManager??t.panel?.diagram?.themeManager;if(o===null){if(n!==""){if(this.od()&&(r=this.BT(l,r,t,n),r===void 0))return;Model.ct(t,n,r)}}else try{if(n!==""){let h=o(r,t);if(Debug&&h===void 0&&Util.ht('Binding warning: conversion function returned undefined when setting target property "'+n+'" on '+t.toString()+", function is: "+o),this.od()&&(h=this.BT(l,h,t,n),h===void 0))return;Model.ct(t,n,h)}else o(r,t)}catch(h){Debug&&Util.ht("Binding error: "+h.toString()+' setting target property "'+n+'" on '+t.toString()+" with conversion function: "+o)}}updateSource(t,i,e,s){if(this.Oc!==2)return;const n=this.qa;if(e!==void 0&&n!==e)return;const o=this.Ah,r=this.Ec;let l=t;if(n!==""&&(l=Model.Xt(t,n)),l!==void 0&&!this.Vb.has(t))try{this.Vb.add(t);const h=s!==null?s.diagram:null,a=h!==null?h.model:null;if(r===null){if(o!=="")a!==null?(Debug&&a.nodeKeyProperty===o&&a.containsNodeData(i)&&Util.ht("Binding error: cannot have TwoWay Binding on node data key property: "+this.toString()),a.setDataProperty(i,o,l)):Model.ct(i,o,l);else if(a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const f=s.itemIndex,c=s.panel.itemArray;a.removeArrayItem(c,f),a.insertArrayItem(c,f,l)}}else try{if(o!==""){const f=r(l,i,a);a!==null?(Debug&&(a.nodeKeyProperty===o&&a.containsNodeData(i)&&Util.ht("Binding error: cannot have TwoWay Binding on node data key property: "+this.toString()),f===void 0&&Util.ht(`Binding warning: conversion function returned undefined when setting source property "${o}" on ${i.toString()}, function is: ${r}`)),a.setDataProperty(i,o,f)):Model.ct(i,o,f)}else{const f=r(l,i,a);if(f!==void 0&&a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const c=s.itemIndex,u=s.panel.itemArray;a.removeArrayItem(u,c),a.insertArrayItem(u,c,f)}}}catch(f){Debug&&Util.ht("Binding error: "+f.toString()+' setting source property "'+o+'" on '+i.toString()+" with conversion function: "+r)}}finally{this.Vb.delete(t)}}}class ThemeBinding extends Binding{Iy;Lh;ja;constructor(t,i,e,s,n){super(t,i,s),e==null&&(e=""),n===void 0&&(n=null),this.Iy=e,this.Lh=n,this.ja=null,this.l=16}cloneProtected(t){super.cloneProtected(t),t.Iy=this.Iy,t.Lh=this.Lh,t.ja=this.ja}od(){return!0}get themeSource(){return this.Iy}set themeSource(t){this.f&&Util.F(this),t!==null&&Util.t(t,"string",ThemeBinding,"themeSource"),this.Iy=t,this.ja=null,t!==null?this.l=this.l|16:this.l=this.l&-17}get themeConverter(){return this.Lh}set themeConverter(t){this.f&&Util.F(this),t!==null&&Util.t(t,"function",ThemeBinding,"themeConverter"),this.Lh=t}ofData(){return this.f&&Util.F(this),this.l=this.l|2,this.Rc=null,this}BT(t,i,e,s){if(!t||(this.CN&&(i=this.Ah),!i&&i!==0))return;let n=this.themeSource;this.ja!==null?n=this.ja:typeof n=="string"&&n.includes(".")&&(this.ja=n.split("."),n=this.ja);let o=t.findValue(i,n,s);return o===void 0&&Util.ht(`Theme warning: ${i} could not be found when setting target property ${s}.`),typeof this.Lh=="function"&&(o=this.Lh(o,e)),o}}class Model{Tt;rg;zo;zb;Me;Bc;Vc;lg;hg;ag;fg;Wa;lr;Xb;Vo;Yb;oi;Th;cg=new GSet;ug=new GSet;Oy;constructor(t,i){if(GSet.vi(this),this.Tt="",this.rg="",this.zo=!1,this.zb={},this.Me=[],this.oi=new GMap,this.Th="key",this.Bc=null,this.Vc=null,this.lg=!1,this.hg=!1,this.ag=!1,this.fg=null,this.Wa="category",this.lr=new GMap,this.Oy=100,this.Xb=new List,this.Vo=!1,this.Yb=null,this.undoManager=new UndoManager,t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){t.Tt=this.Tt,t.rg=this.rg,t.zo=this.zo,t.Th=this.Th,t.Bc=this.Bc,t.Vc=this.Vc,t.lg=this.lg,t.hg=this.hg,t.ag=this.ag,t.Oy=this.Oy,t.fg=this.fg,t.Wa=this.Wa}copy(){const t=new this.constructor;return this.cloneProtected(t),t}clear(){this.Me=[],this.oi.clear(),this.lr.clear(),this.undoManager.clear()}toString(t){if(t===void 0&&(t=0),t>1)return this.toJson();{let i=(this.name!==""?this.name:"")+" Model";if(t>0){i+=` + node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n{if(u.model===e){if(u.modelChange==="nodeDataArray")u.change===3?n.add(u.newValue):u.change===4&&r.add(u.oldValue);else if(e.containsNodeData(u.object))o.add(u.object);else if(u.change===2&&(e.modelData===u.object||u.propertyName==="modelData"))s=!0;else if(u.object!==null)if(l&&l.has(u.object))l.get(u.object).each(m=>{e.containsNodeData(m)&&o.add(m)});else{if(u.object instanceof Model||e.Ea()&&e.containsLinkData(u.object))return;e.zT(u.object).each(m=>{o.add(m)})}}});const h=this.ug;h.clear(),n.each(u=>{h.add(e.getKeyForNodeData(u)),i||o.add(u)});const a=this.cg;a.clear(),r.each(u=>{a.add(e.getKeyForNodeData(u)),i&&o.add(u)});const f=e.cloneDeep(o.toArray());let c=null;return s&&(c===null&&(c={}),c.modelData=this.cloneDeep(this.modelData)),h.count>0&&(c===null&&(c={}),i?c.removedNodeKeys=h.toArray():c.insertedNodeKeys=h.toArray()),f.length>0&&(c===null&&(c={}),c.modifiedNodeData=f),a.count>0&&(c===null&&(c={}),i?c.insertedNodeKeys=a.toArray():c.removedNodeKeys=a.toArray()),a.clear(),h.clear(),c}cloneDeep(t){return this.dg(t,!0)}dg(t,i,e,s,n){if(!Util.Mt(t))return t;n||(n=[]);const o=Object.isExtensible(t);if(e||(e=new GMap),o){const h=e.get(t);if(h)return h}else{s||(s=new GMap);const h=s.iterator;for(;h.next();){const a=h.key;if(h.value===t){const c=e.get(a);if(c)return c}}}function r(h,a){if(o)h.__gohashid===void 0&&n.push(h),e.set(h,a);else{const f=GSet.fu++;e.set(f,a),s.set(f,t)}}let l;if(Array.isArray(t)){l=[],r(t,l);for(let h=0;h{delete h.__gohashid}),l}Be(t){return JSON.stringify(t).replace(/[\u007F-\uFFFF]/g,e=>{const s="0000"+e.charCodeAt(0).toString(16);return"\\u"+s.substring(s.length-4)})}gg(){let t="";return this.name!==""&&(t+=`, + "name": `+this.Be(this.name)),this.dataFormat!==""&&(t+=`, + "dataFormat": `+this.Be(this.dataFormat)),this.isReadOnly&&(t+=`, "isReadOnly": `+this.isReadOnly),this.nodeKeyProperty!=="key"&&typeof this.nodeKeyProperty=="string"&&(t+=`, - "nodeKeyProperty": `+this.Ve(this.nodeKeyProperty)),this.copiesArrays&&(t+=`, + "nodeKeyProperty": `+this.Be(this.nodeKeyProperty)),this.copiesArrays&&(t+=`, "copiesArrays": true`),this.copiesArrayObjects&&(t+=`, "copiesArrayObjects": true`),this.copiesKey&&(t+=`, "copiesKey": true`),this.pointsDigits!==100&&(t+=`, "pointsDigits": `+this.pointsDigits.toString()),this.nodeCategoryProperty!=="category"&&typeof this.nodeCategoryProperty=="string"&&(t+=`, - "nodeCategoryProperty": `+this.Ve(this.nodeCategoryProperty)),t}Ey(t){t.name&&(this.name=t.name),t.dataFormat&&(this.dataFormat=t.dataFormat),t.isReadOnly&&(this.isReadOnly=!0),t.nodeKeyProperty&&(this.nodeKeyProperty=t.nodeKeyProperty),t.copiesArrays&&(this.copiesArrays=!0),t.copiesArrayObjects&&(this.copiesArrayObjects=!0),t.copiesKey!==void 0&&(this.copiesKey=t.copiesKey),t.pointsDigits!==void 0&&(this.pointsDigits=parseInt(t.pointsDigits)),t.nodeCategoryProperty&&(this.nodeCategoryProperty=t.nodeCategoryProperty)}XT(){const t=this.modelData;return`, - "modelData": `+this.YT(t)}KT(t){const i=t.modelData;Util.Mt(i)&&(this.replaceJsonObjects(i),this.modelData=i)}DN(){const t=this.modelData;let i=!1;for(const s in t)if(!this.Kb(t,s,t[s])){i=!0;break}let e="";return i&&(e=this.XT()),e+`, - "nodeDataArray": `+this.Th(this.nodeDataArray,!0)}FN(t){this.KT(t);const i=t.nodeDataArray;Array.isArray(i)&&(this.replaceJsonObjects(i),this.nodeDataArray=i)}RN(t,i,e){if(t===i)return!0;if(typeof t!=typeof i||typeof t=="function"||typeof i=="function")return!1;if(Array.isArray(t)&&Array.isArray(i)){if(e.get(t)===i)return!0;if(e.set(t,i),t.length!==i.length)return!1;for(let s=0;s{const o=n.part;if(!o)return;const r=o.data;if(s===r)return;let l=i.get(s);l===null?(l=new GSet,l.add(r),i.set(s,l)):l.add(r)};i===null&&(i=new GMap,t.changes.each(s=>{if(s.diagram!==null){const n=s.change;if(n===2){const o=s.object.panel;if(o){const r=o.data;r&&e(r,o)}}else if(n===3||n===4){const o=s.object,r=o.itemArray;r&&e(r,o)}}}),this.Wa=i)}zT(t){const i=new GSet;for(let e=0;e{if(c.model===e){if(c.modelChange==="nodeDataArray")c.change===3?n.add(c.newValue):c.change===4&&r.add(c.oldValue);else if(e.containsNodeData(c.object))o.add(c.object);else if(c.change===2&&(e.modelData===c.object||c.propertyName==="modelData"))s=!0;else if(c.object!==null)if(l&&l.has(c.object))l.get(c.object).each(d=>{e.containsNodeData(d)&&o.add(d)});else{if(c.object instanceof Model||e.Oa()&&e.containsLinkData(c.object))return;e.zT(c.object).each(d=>{o.add(d)})}}});const h=this.dg;h.clear(),n.each(c=>{h.add(e.getKeyForNodeData(c)),i||o.add(c)});const a=this.ug;a.clear(),r.each(c=>{a.add(e.getKeyForNodeData(c)),i&&o.add(c)});let f="";return s&&(f+=this.XT()),h.count>0&&(f+=(i?this.GT:this.UT)+this.Th(h.toArray(),!0)),o.count>0&&(f+=this.EO+this.Th(o.toArray(),!0)),a.count>0&&(f+=(i?this.UT:this.GT)+this.Th(a.toArray(),!0)),a.clear(),h.clear(),f}Vy(t){(t.name!==void 0&&t.name!==this.name||t.dataFormat!==void 0&&t.dataFormat!==this.dataFormat||t.isReadOnly!==void 0&&t.isReadOnly!==this.isReadOnly||t.nodeKeyProperty!==void 0&&t.nodeKeyProperty!==this.nodeKeyProperty||t.copiesArrays!==void 0&&t.copiesArrays!==this.copiesArrays||t.copiesArrayObjects!==void 0&&t.copiesArrayObjects!==this.copiesArrayObjects||t.copiesKey!==void 0&&t.copiesKey!==this.copiesKey||t.nodeCategoryProperty!==void 0&&t.nodeCategoryProperty!==this.nodeCategoryProperty)&&Util.n("applyIncrementalJson cannot change Model properties"),this.KT(t);const i=t.insertedNodeKeys,e=t.modifiedNodeData,s=new GMap;if(Array.isArray(e))for(let o=0;o1&&s.add(` + "removedNodeKeys": `;va=null;VT(t){let i=this.va;const e=(s,n)=>{const o=n.part;if(!o)return;const r=o.data;if(s===r)return;let l=i.get(s);l===null?(l=new GSet,l.add(r),i.set(s,l)):l.add(r)};i===null&&(i=new GMap,t.changes.each(s=>{if(s.diagram!==null){const n=s.change;if(n===2){const o=s.object.panel;if(o){const r=o.data;r&&e(r,o)}}else if(n===3||n===4){const o=s.object,r=o.itemArray;r&&e(r,o)}}}),this.va=i)}zT(t){const i=new GSet;for(let e=0;e{if(c.model===e){if(c.modelChange==="nodeDataArray")c.change===3?n.add(c.newValue):c.change===4&&r.add(c.oldValue);else if(e.containsNodeData(c.object))o.add(c.object);else if(c.change===2&&(e.modelData===c.object||c.propertyName==="modelData"))s=!0;else if(c.object!==null)if(l&&l.has(c.object))l.get(c.object).each(d=>{e.containsNodeData(d)&&o.add(d)});else{if(c.object instanceof Model||e.Ea()&&e.containsLinkData(c.object))return;e.zT(c.object).each(d=>{o.add(d)})}}});const h=this.ug;h.clear(),n.each(c=>{h.add(e.getKeyForNodeData(c)),i||o.add(c)});const a=this.cg;a.clear(),r.each(c=>{a.add(e.getKeyForNodeData(c)),i&&o.add(c)});let f="";return s&&(f+=this.XT()),h.count>0&&(f+=(i?this.GT:this.UT)+this.Dh(h.toArray(),!0)),o.count>0&&(f+=this.OO+this.Dh(o.toArray(),!0)),a.count>0&&(f+=(i?this.UT:this.GT)+this.Dh(a.toArray(),!0)),a.clear(),h.clear(),f}By(t){(t.name!==void 0&&t.name!==this.name||t.dataFormat!==void 0&&t.dataFormat!==this.dataFormat||t.isReadOnly!==void 0&&t.isReadOnly!==this.isReadOnly||t.nodeKeyProperty!==void 0&&t.nodeKeyProperty!==this.nodeKeyProperty||t.copiesArrays!==void 0&&t.copiesArrays!==this.copiesArrays||t.copiesArrayObjects!==void 0&&t.copiesArrayObjects!==this.copiesArrayObjects||t.copiesKey!==void 0&&t.copiesKey!==this.copiesKey||t.nodeCategoryProperty!==void 0&&t.nodeCategoryProperty!==this.nodeCategoryProperty)&&Util.n("applyIncrementalJson cannot change Model properties"),this.KT(t);const i=t.insertedNodeKeys,e=t.modifiedNodeData,s=new GMap;if(Array.isArray(e))for(let o=0;o1&&s.add(` `);for(let n=0;n0&&(s.add(","),i&&s.add(` `)),s.add(this.writeJsonValue(o)))}return i&&e>1&&s.add(` -`),s.add("]"),s.toString()}Kb(t,i,e){return e===void 0||i==="__gohashid"||i[0]==="_"||typeof e=="function"}ji(t){return isNaN(t)?"NaN":t===1/0?"9e9999":t===-1/0?"-9e9999":t}YT(t){const i=t;if(i instanceof Point)t={class:"go.Point",x:this.ji(i.x),y:this.ji(i.y)};else if(i instanceof Size)t={class:"go.Size",width:this.ji(i.width),height:this.ji(i.height)};else if(i instanceof Rect)t={class:"go.Rect",x:this.ji(i.x),y:this.ji(i.y),width:this.ji(i.width),height:this.ji(i.height)};else if(i instanceof Margin)t={class:"go.Margin",top:this.ji(i.top),right:this.ji(i.right),bottom:this.ji(i.bottom),left:this.ji(i.left)};else if(i instanceof Spot)i.isSpot()?t={class:"go.Spot",x:this.ji(i.x),y:this.ji(i.y),offsetX:this.ji(i.offsetX),offsetY:this.ji(i.offsetY)}:t={class:"go.Spot",enum:i.toString()};else if(i instanceof Brush){if(t={class:"go.Brush",type:BrushType[i.type]},i.type===1?t.color=i.color:(i.type===2||i.type===3)&&(t.start=i.start,t.end=i.end,i.type===3&&(i.startRadius!==0&&(t.startRadius=this.ji(i.startRadius)),isNaN(i.endRadius)||(t.endRadius=this.ji(i.endRadius)))),i.colorStops!==null){const n={},o=i.colorStops.iterator;for(;o.next();){const r=o.key,l=o.value;n[r]=l}t.colorStops=n}}else if(i instanceof Geometry)t={class:"go.Geometry",type:GeometryType[i.type]},i.startX!==0&&(t.startX=this.ji(i.startX)),i.startY!==0&&(t.startY=this.ji(i.startY)),i.endX!==0&&(t.endX=this.ji(i.endX)),i.endY!==0&&(t.endY=this.ji(i.endY)),i.spot1.equals(Spot.TopLeft)||(t.spot1=i.spot1),i.spot2.equals(Spot.BottomRight)||(t.spot2=i.spot2),i.type===4&&(t.path=Geometry.stringify(i));else if(Model.Gb(Util.hn(i))!==null)return Util.at("ERROR: trying to convert a GraphObject or Diagram or Model or Tool or Layout or UndoManager or other unknown data type into JSON text: "+i.toString()),"{}";let e="{",s=!0;for(const n in t){const o=Model.Xt(t,n);if(!this.Kb(t,n,o))if(s?s=!1:e+=",",e+=this.Ve(n)+":",n==="points"&&o instanceof List){const r=o;let l="[";const h=r.iterator;for(;h.next();){const a=h.value;l.length>1&&(l+=","),l+=this.HT(a.x),l+=",",l+=this.HT(a.y)}l+="]",e+=l}else e+=this.writeJsonValue(o)}return e+="}",e}HT(t){if(t===1/0)return"9e9999";if(t===-1/0)return"-9e9999";if(isNaN(t))return"0";const i=this.pointsDigits;return i>16?t.toString():t.toFixed(i)}get pointsDigits(){return this.Oy}set pointsDigits(t){t<0?t=0:t>100&&(t=100),this.Oy=t}Wi(t){return typeof t=="number"?t:t==="NaN"?NaN:t==="9e9999"?1/0:t==="-9e9999"?-1/0:parseFloat(t)}BO(t){if(typeof t!="object")return t;let i=t.class||"";if(typeof i!="string"||i==="")return t;if(i==="NaN")return NaN;if(i==="Date")return new Date(t.value);if(i.indexOf("go.")!==0)return t;i=i.substring(3);let e=t;if(i==="Point")e=new Point(this.Wi(t.x),this.Wi(t.y));else if(i==="Size")e=new Size(this.Wi(t.width),this.Wi(t.height));else if(i==="Rect")e=new Rect(this.Wi(t.x),this.Wi(t.y),this.Wi(t.width),this.Wi(t.height));else if(i==="Margin")e=new Margin(this.Wi(t.top),this.Wi(t.right),this.Wi(t.bottom),this.Wi(t.left));else if(i==="Spot")typeof t.enum=="string"?e=Spot.parse(t.enum):e=new Spot(this.Wi(t.x),this.Wi(t.y),this.Wi(t.offsetX),this.Wi(t.offsetY));else if(i==="Brush"){const s=new Brush;s.type=Util.zh(BrushType,t.type)??1,typeof t.color=="string"&&(s.color=t.color),t.start instanceof Spot&&(s.start=t.start),t.end instanceof Spot&&(s.end=t.end),typeof t.startRadius=="number"&&(s.startRadius=this.Wi(t.startRadius)),typeof t.endRadius=="number"&&(s.endRadius=this.Wi(t.endRadius));const n=t.colorStops;if(Util.Mt(n))for(const o in n){const r=parseFloat(o);s.addColorStop(r,n[o])}e=s}else if(i==="Geometry"){let s=null;typeof t.path=="string"?s=Geometry.parse(t.path):s=new Geometry,s.type=Util.zh(GeometryType,t.type)??1,typeof t.startX=="number"&&(s.startX=this.Wi(t.startX)),typeof t.startY=="number"&&(s.startY=this.Wi(t.startY)),typeof t.endX=="number"&&(s.endX=this.Wi(t.endX)),typeof t.endY=="number"&&(s.endY=this.Wi(t.endY)),t.spot1 instanceof Spot&&(s.spot1=t.spot1),t.spot2 instanceof Spot&&(s.spot2=t.spot2),e=s}else if(i==="EnumValue"){let s=t.classType;s.indexOf("go.")===0&&(s=s.substring(3));const n=Model.Gb(s);typeof n=="function"&&(e=Util.zh(n,t.name))}return e}get name(){return this.Tt}set name(t){const i=this.Tt;i!==t&&(Util.t(t,"string",Model,"name"),this.Tt=t,this.i("name",i,t))}get dataFormat(){return this.lg}set dataFormat(t){const i=this.lg;i!==t&&(Util.t(t,"string",Model,"dataFormat"),this.lg=t,this.i("dataFormat",i,t))}get isReadOnly(){return this.zo}set isReadOnly(t){const i=this.zo;i!==t&&(Util.t(t,"boolean",Model,"isReadOnly"),this.zo=t,this.i("isReadOnly",i,t))}get modelData(){return this.zb}set modelData(t){const i=this.zb;i!==t&&(Util.t(t,"object",Model,"modelData"),this.zb=t,this.i("modelData",i,t),this.updateTargetBindings(t))}addChangedListener(t){return Util.t(t,"function",Model,"addChangedListener:listener"),this.Xb.add(t),this}removeChangedListener(t){Util.t(t,"function",Model,"removeChangedListener:listener"),this.Xb.delete(t)}Hw(t){this.skipsUndoManager||this.undoManager.handleChanged(t);const i=this.Xb,e=i.length;for(let s=0;s0&&Util.n("Cannot set Model.nodeKeyProperty when there is existing node data"),this.Lh=t,this.i("nodeKeyProperty",i,t))}In(t,i,e){typeof t!="string"&&typeof t!="function"&&Util.Vi(t,"string or function",i,e)}getKeyForNodeData(t){if(t===null)return;const i=this.Lh;if(i==="")return;const e=Model.Xt(t,i);if(e!==void 0){if(this.isKeyType(e))return e;Util.n("Key value for node data "+t+" is not a number or a string: "+e)}}setKeyForNodeData(t,i){if((i==null||!this.isKeyType(i))&&Util.Vi(i,"number or string",Model,"setKeyForNodeData:key"),t===null)return;const e=this.Lh;if(e==="")return;if(!this.containsNodeData(t)){Model.ut(t,e,i);return}const s=Model.Xt(t,e);if(s!==i){if(this.findNodeDataForKey(i)!==null)return;Model.ut(t,e,i),s!==void 0&&this.oi.delete(s),this.oi.set(i,t),this.Kt("nodeKey",2,e,t,s,i),typeof e=="string"&&this.updateTargetBindings(t,e),this.By(s,i)}}get makeUniqueKeyFunction(){return this.Ec}set makeUniqueKeyFunction(t){const i=this.Ec;i!==t&&(t!==null&&Util.t(t,"function",Model,"makeUniqueKeyFunction"),this.Ec=t,this.i("makeUniqueKeyFunction",i,t))}isKeyType(t){return typeof t=="number"||typeof t=="string"}containsNodeData(t){if(t===null)return!1;const i=this.getKeyForNodeData(t);return i===void 0?!1:this.oi.get(i)===t}findNodeDataForKey(t){return t===null&&Util.n("Model.findNodeDataForKey:key must not be null"),t===void 0||!this.isKeyType(t)?null:this.oi.get(t)}get nodeDataArray(){return this.Me}set nodeDataArray(t){const i=this.Me;if(i!==t){Util.Gg(t,Model,"nodeDataArray"),this.oi.clear(),this.ON();const e=t.length;for(let o=0;o=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" GraphLinksModel";if(t>0){i+=` +`),s.add("]"),s.toString()}Kb(t,i,e){return e===void 0||i==="__gohashid"||i[0]==="_"||typeof e=="function"}ji(t){return isNaN(t)?"NaN":t===1/0?"9e9999":t===-1/0?"-9e9999":t}YT(t){const i=t;if(i instanceof Point)t={class:"go.Point",x:this.ji(i.x),y:this.ji(i.y)};else if(i instanceof Size)t={class:"go.Size",width:this.ji(i.width),height:this.ji(i.height)};else if(i instanceof Rect)t={class:"go.Rect",x:this.ji(i.x),y:this.ji(i.y),width:this.ji(i.width),height:this.ji(i.height)};else if(i instanceof Margin)t={class:"go.Margin",top:this.ji(i.top),right:this.ji(i.right),bottom:this.ji(i.bottom),left:this.ji(i.left)};else if(i instanceof Spot)i.isSpot()?t={class:"go.Spot",x:this.ji(i.x),y:this.ji(i.y),offsetX:this.ji(i.offsetX),offsetY:this.ji(i.offsetY)}:t={class:"go.Spot",enum:i.toString()};else if(i instanceof Brush){if(t={class:"go.Brush",type:BrushType[i.type]},i.type===1?t.color=i.color:(i.type===2||i.type===3)&&(t.start=i.start,t.end=i.end,i.type===3&&(i.startRadius!==0&&(t.startRadius=this.ji(i.startRadius)),isNaN(i.endRadius)||(t.endRadius=this.ji(i.endRadius)))),i.colorStops!==null){const n={},o=i.colorStops.iterator;for(;o.next();){const r=o.key,l=o.value;n[r]=l}t.colorStops=n}}else if(i instanceof Geometry)t={class:"go.Geometry",type:GeometryType[i.type]},i.startX!==0&&(t.startX=this.ji(i.startX)),i.startY!==0&&(t.startY=this.ji(i.startY)),i.endX!==0&&(t.endX=this.ji(i.endX)),i.endY!==0&&(t.endY=this.ji(i.endY)),i.spot1.equals(Spot.TopLeft)||(t.spot1=i.spot1),i.spot2.equals(Spot.BottomRight)||(t.spot2=i.spot2),i.type===4&&(t.path=Geometry.stringify(i));else if(Model.Gb(Util.hn(i))!==null)return Util.ht("ERROR: trying to convert a GraphObject or Diagram or Model or Tool or Layout or UndoManager or other unknown data type into JSON text: "+i.toString()),"{}";let e="{",s=!0;for(const n in t){const o=Model.Xt(t,n);if(!this.Kb(t,n,o))if(s?s=!1:e+=",",e+=this.Be(n)+":",n==="points"&&o instanceof List){const r=o;let l="[";const h=r.iterator;for(;h.next();){const a=h.value;l.length>1&&(l+=","),l+=this.HT(a.x),l+=",",l+=this.HT(a.y)}l+="]",e+=l}else e+=this.writeJsonValue(o)}return e+="}",e}HT(t){if(t===1/0)return"9e9999";if(t===-1/0)return"-9e9999";if(isNaN(t))return"0";const i=this.pointsDigits;return i>16?t.toString():t.toFixed(i)}get pointsDigits(){return this.Oy}set pointsDigits(t){t<0?t=0:t>100&&(t=100),this.Oy=t}Wi(t){return typeof t=="number"?t:t==="NaN"?NaN:t==="9e9999"?1/0:t==="-9e9999"?-1/0:parseFloat(t)}BO(t){if(typeof t!="object")return t;let i=t.class||"";if(typeof i!="string"||i==="")return t;if(i==="NaN")return NaN;if(i==="Date")return new Date(t.value);if(i.indexOf("go.")!==0)return t;i=i.substring(3);let e=t;if(i==="Point")e=new Point(this.Wi(t.x),this.Wi(t.y));else if(i==="Size")e=new Size(this.Wi(t.width),this.Wi(t.height));else if(i==="Rect")e=new Rect(this.Wi(t.x),this.Wi(t.y),this.Wi(t.width),this.Wi(t.height));else if(i==="Margin")e=new Margin(this.Wi(t.top),this.Wi(t.right),this.Wi(t.bottom),this.Wi(t.left));else if(i==="Spot")typeof t.enum=="string"?e=Spot.parse(t.enum):e=new Spot(this.Wi(t.x),this.Wi(t.y),this.Wi(t.offsetX),this.Wi(t.offsetY));else if(i==="Brush"){const s=new Brush;s.type=Util.Xh(BrushType,t.type)??1,typeof t.color=="string"&&(s.color=t.color),t.start instanceof Spot&&(s.start=t.start),t.end instanceof Spot&&(s.end=t.end),typeof t.startRadius=="number"&&(s.startRadius=this.Wi(t.startRadius)),typeof t.endRadius=="number"&&(s.endRadius=this.Wi(t.endRadius));const n=t.colorStops;if(Util.Mt(n))for(const o in n){const r=parseFloat(o);s.addColorStop(r,n[o])}e=s}else if(i==="Geometry"){let s=null;typeof t.path=="string"?s=Geometry.parse(t.path):s=new Geometry,s.type=Util.Xh(GeometryType,t.type)??1,typeof t.startX=="number"&&(s.startX=this.Wi(t.startX)),typeof t.startY=="number"&&(s.startY=this.Wi(t.startY)),typeof t.endX=="number"&&(s.endX=this.Wi(t.endX)),typeof t.endY=="number"&&(s.endY=this.Wi(t.endY)),t.spot1 instanceof Spot&&(s.spot1=t.spot1),t.spot2 instanceof Spot&&(s.spot2=t.spot2),e=s}else if(i==="EnumValue"){let s=t.classType;s.indexOf("go.")===0&&(s=s.substring(3));const n=Model.Gb(s);typeof n=="function"&&(e=Util.Xh(n,t.name))}return e}get name(){return this.Tt}set name(t){const i=this.Tt;i!==t&&(Util.t(t,"string",Model,"name"),this.Tt=t,this.i("name",i,t))}get dataFormat(){return this.rg}set dataFormat(t){const i=this.rg;i!==t&&(Util.t(t,"string",Model,"dataFormat"),this.rg=t,this.i("dataFormat",i,t))}get isReadOnly(){return this.zo}set isReadOnly(t){const i=this.zo;i!==t&&(Util.t(t,"boolean",Model,"isReadOnly"),this.zo=t,this.i("isReadOnly",i,t))}get modelData(){return this.zb}set modelData(t){const i=this.zb;i!==t&&(Util.t(t,"object",Model,"modelData"),this.zb=t,this.i("modelData",i,t),this.updateTargetBindings(t))}addChangedListener(t){return Util.t(t,"function",Model,"addChangedListener:listener"),this.Xb.add(t),this}removeChangedListener(t){Util.t(t,"function",Model,"removeChangedListener:listener"),this.Xb.delete(t)}Hw(t){this.skipsUndoManager||this.undoManager.handleChanged(t);const i=this.Xb,e=i.length;for(let s=0;s0&&Util.n("Cannot set Model.nodeKeyProperty when there is existing node data"),this.Th=t,this.i("nodeKeyProperty",i,t))}In(t,i,e){typeof t!="string"&&typeof t!="function"&&Util.Bi(t,"string or function",i,e)}getKeyForNodeData(t){if(t===null)return;const i=this.Th;if(i==="")return;const e=Model.Xt(t,i);if(e!==void 0){if(this.isKeyType(e))return e;Util.n("Key value for node data "+t+" is not a number or a string: "+e)}}setKeyForNodeData(t,i){if((i==null||!this.isKeyType(i))&&Util.Bi(i,"number or string",Model,"setKeyForNodeData:key"),t===null)return;const e=this.Th;if(e==="")return;if(!this.containsNodeData(t)){Model.ct(t,e,i);return}const s=Model.Xt(t,e);if(s!==i){if(this.findNodeDataForKey(i)!==null)return;Model.ct(t,e,i),s!==void 0&&this.oi.delete(s),this.oi.set(i,t),this.Kt("nodeKey",2,e,t,s,i),typeof e=="string"&&this.updateTargetBindings(t,e),this.Vy(s,i)}}get makeUniqueKeyFunction(){return this.Bc}set makeUniqueKeyFunction(t){const i=this.Bc;i!==t&&(t!==null&&Util.t(t,"function",Model,"makeUniqueKeyFunction"),this.Bc=t,this.i("makeUniqueKeyFunction",i,t))}isKeyType(t){return typeof t=="number"||typeof t=="string"}containsNodeData(t){if(t===null)return!1;const i=this.getKeyForNodeData(t);return i===void 0?!1:this.oi.get(i)===t}findNodeDataForKey(t){return t===null&&Util.n("Model.findNodeDataForKey:key must not be null"),t===void 0||!this.isKeyType(t)?null:this.oi.get(t)}get nodeDataArray(){return this.Me}set nodeDataArray(t){const i=this.Me;if(i!==t){Util.Ug(t,Model,"nodeDataArray"),this.oi.clear(),this.RN();const e=t.length;for(let o=0;o=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" GraphLinksModel";if(t>0){i+=` node data:`;let e=this.nodeDataArray,s=e.length,n=0;for(n=0;n"+this.Ee(o,!1)}}return i}}TN(t,i){if(this.linkKeyProperty===""){const c=this.skipsUndoManager;this.skipsUndoManager=!0,this.linkKeyProperty="key",this.skipsUndoManager=c}let e=super.TN(t,i);const s=this,n=new GSet,o=new GSet,r=new GSet,l=this.Wa;t.changes.each(c=>{if(c.model===s){if(c.modelChange==="linkDataArray")c.change===3?n.add(c.newValue):c.change===4&&r.add(c.oldValue);else if(s.containsLinkData(c.object))o.add(c.object);else if(c.object!==null)if(c.object!==null&&l&&l.has(c.object))l.get(c.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(c.object instanceof Model||s.containsNodeData(c.object))return;s.jT(c.object).each(d=>o.add(d))}}});const h=this.dg;h.clear(),n.each(c=>{h.add(s.getKeyForLinkData(c)),i||o.add(c)});const a=this.ug;a.clear(),r.each(c=>{a.add(s.getKeyForLinkData(c)),i&&o.add(c)});const f=s.cloneDeep(o.toArray());return h.count>0&&(e===null&&(e={}),i?e.removedLinkKeys=h.toArray():e.insertedLinkKeys=h.toArray()),f.length>0&&(e===null&&(e={}),e.modifiedLinkData=f),a.count>0&&(e===null&&(e={}),i?e.insertedLinkKeys=a.toArray():e.removedLinkKeys=a.toArray()),a.clear(),h.clear(),e}mg(){const t=super.mg();let i="";return this.linkCategoryProperty!=="category"&&typeof this.linkCategoryProperty=="string"&&(i+=`, - "linkCategoryProperty": `+this.Ve(this.linkCategoryProperty)),this.linkKeyProperty!==""&&typeof this.linkKeyProperty=="string"&&(i+=`, - "linkKeyProperty": `+this.Ve(this.linkKeyProperty)),this.linkFromKeyProperty!=="from"&&typeof this.linkFromKeyProperty=="string"&&(i+=`, - "linkFromKeyProperty": `+this.Ve(this.linkFromKeyProperty)),this.linkToKeyProperty!=="to"&&typeof this.linkToKeyProperty=="string"&&(i+=`, - "linkToKeyProperty": `+this.Ve(this.linkToKeyProperty)),this.linkFromPortIdProperty!==""&&typeof this.linkFromPortIdProperty=="string"&&(i+=`, - "linkFromPortIdProperty": `+this.Ve(this.linkFromPortIdProperty)),this.linkToPortIdProperty!==""&&typeof this.linkToPortIdProperty=="string"&&(i+=`, - "linkToPortIdProperty": `+this.Ve(this.linkToPortIdProperty)),this.linkLabelKeysProperty!==""&&typeof this.linkLabelKeysProperty=="string"&&(i+=`, - "linkLabelKeysProperty": `+this.Ve(this.linkLabelKeysProperty)),this.nodeIsGroupProperty!=="isGroup"&&typeof this.nodeIsGroupProperty=="string"&&(i+=`, - "nodeIsGroupProperty": `+this.Ve(this.nodeIsGroupProperty)),this.nodeGroupKeyProperty!=="group"&&typeof this.nodeGroupKeyProperty=="string"&&(i+=`, - "nodeGroupKeyProperty": `+this.Ve(this.nodeGroupKeyProperty)),t+i}Ey(t){super.Ey(t),t.linkKeyProperty&&(this.linkKeyProperty=t.linkKeyProperty),t.linkFromKeyProperty&&(this.linkFromKeyProperty=t.linkFromKeyProperty),t.linkToKeyProperty&&(this.linkToKeyProperty=t.linkToKeyProperty),t.linkFromPortIdProperty&&(this.linkFromPortIdProperty=t.linkFromPortIdProperty),t.linkToPortIdProperty&&(this.linkToPortIdProperty=t.linkToPortIdProperty),t.linkCategoryProperty&&(this.linkCategoryProperty=t.linkCategoryProperty),t.linkLabelKeysProperty&&(this.linkLabelKeysProperty=t.linkLabelKeysProperty),t.nodeIsGroupProperty&&(this.nodeIsGroupProperty=t.nodeIsGroupProperty),t.nodeGroupKeyProperty&&(this.nodeGroupKeyProperty=t.nodeGroupKeyProperty)}DN(){const t=super.DN(),i=`, - "linkDataArray": `+this.Th(this.linkDataArray,!0);return t+i}FN(t){super.FN(t);const i=t.linkDataArray;Array.isArray(i)&&(this.replaceJsonObjects(i),this.linkDataArray=i)}WT=`, - "insertedLinkKeys": `;XO=`, + link data:`,e=this.linkDataArray,s=e.length,n=0;n"+this.Ee(o,!1)}}return i}}AN(t,i){if(this.linkKeyProperty===""){const c=this.skipsUndoManager;this.skipsUndoManager=!0,this.linkKeyProperty="key",this.skipsUndoManager=c}let e=super.AN(t,i);const s=this,n=new GSet,o=new GSet,r=new GSet,l=this.va;t.changes.each(c=>{if(c.model===s){if(c.modelChange==="linkDataArray")c.change===3?n.add(c.newValue):c.change===4&&r.add(c.oldValue);else if(s.containsLinkData(c.object))o.add(c.object);else if(c.object!==null)if(c.object!==null&&l&&l.has(c.object))l.get(c.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(c.object instanceof Model||s.containsNodeData(c.object))return;s.jT(c.object).each(d=>o.add(d))}}});const h=this.ug;h.clear(),n.each(c=>{h.add(s.getKeyForLinkData(c)),i||o.add(c)});const a=this.cg;a.clear(),r.each(c=>{a.add(s.getKeyForLinkData(c)),i&&o.add(c)});const f=s.cloneDeep(o.toArray());return h.count>0&&(e===null&&(e={}),i?e.removedLinkKeys=h.toArray():e.insertedLinkKeys=h.toArray()),f.length>0&&(e===null&&(e={}),e.modifiedLinkData=f),a.count>0&&(e===null&&(e={}),i?e.insertedLinkKeys=a.toArray():e.removedLinkKeys=a.toArray()),a.clear(),h.clear(),e}gg(){const t=super.gg();let i="";return this.linkCategoryProperty!=="category"&&typeof this.linkCategoryProperty=="string"&&(i+=`, + "linkCategoryProperty": `+this.Be(this.linkCategoryProperty)),this.linkKeyProperty!==""&&typeof this.linkKeyProperty=="string"&&(i+=`, + "linkKeyProperty": `+this.Be(this.linkKeyProperty)),this.linkFromKeyProperty!=="from"&&typeof this.linkFromKeyProperty=="string"&&(i+=`, + "linkFromKeyProperty": `+this.Be(this.linkFromKeyProperty)),this.linkToKeyProperty!=="to"&&typeof this.linkToKeyProperty=="string"&&(i+=`, + "linkToKeyProperty": `+this.Be(this.linkToKeyProperty)),this.linkFromPortIdProperty!==""&&typeof this.linkFromPortIdProperty=="string"&&(i+=`, + "linkFromPortIdProperty": `+this.Be(this.linkFromPortIdProperty)),this.linkToPortIdProperty!==""&&typeof this.linkToPortIdProperty=="string"&&(i+=`, + "linkToPortIdProperty": `+this.Be(this.linkToPortIdProperty)),this.linkLabelKeysProperty!==""&&typeof this.linkLabelKeysProperty=="string"&&(i+=`, + "linkLabelKeysProperty": `+this.Be(this.linkLabelKeysProperty)),this.nodeIsGroupProperty!=="isGroup"&&typeof this.nodeIsGroupProperty=="string"&&(i+=`, + "nodeIsGroupProperty": `+this.Be(this.nodeIsGroupProperty)),this.nodeGroupKeyProperty!=="group"&&typeof this.nodeGroupKeyProperty=="string"&&(i+=`, + "nodeGroupKeyProperty": `+this.Be(this.nodeGroupKeyProperty)),t+i}Ey(t){super.Ey(t),t.linkKeyProperty&&(this.linkKeyProperty=t.linkKeyProperty),t.linkFromKeyProperty&&(this.linkFromKeyProperty=t.linkFromKeyProperty),t.linkToKeyProperty&&(this.linkToKeyProperty=t.linkToKeyProperty),t.linkFromPortIdProperty&&(this.linkFromPortIdProperty=t.linkFromPortIdProperty),t.linkToPortIdProperty&&(this.linkToPortIdProperty=t.linkToPortIdProperty),t.linkCategoryProperty&&(this.linkCategoryProperty=t.linkCategoryProperty),t.linkLabelKeysProperty&&(this.linkLabelKeysProperty=t.linkLabelKeysProperty),t.nodeIsGroupProperty&&(this.nodeIsGroupProperty=t.nodeIsGroupProperty),t.nodeGroupKeyProperty&&(this.nodeGroupKeyProperty=t.nodeGroupKeyProperty)}LN(){const t=super.LN(),i=`, + "linkDataArray": `+this.Dh(this.linkDataArray,!0);return t+i}TN(t){super.TN(t);const i=t.linkDataArray;Array.isArray(i)&&(this.replaceJsonObjects(i),this.linkDataArray=i)}WT=`, + "insertedLinkKeys": `;zO=`, "modifiedLinkData": `;vT=`, - "removedLinkKeys": `;jT(t){const i=new GSet;for(let e=0;e{if(c.model===s){if(c.modelChange==="linkDataArray")c.change===3?n.add(c.newValue):c.change===4&&r.add(c.oldValue);else if(s.containsLinkData(c.object))o.add(c.object);else if(c.object!==null)if(c.object!==null&&l&&l.has(c.object))l.get(c.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(c.object instanceof Model||s.containsNodeData(c.object))return;s.jT(c.object).each(d=>o.add(d))}}});const h=this.dg;h.clear(),n.each(c=>{h.add(s.getKeyForLinkData(c)),i||o.add(c)});const a=this.ug;a.clear(),r.each(c=>{a.add(s.getKeyForLinkData(c)),i&&o.add(c)});let f=e;return h.count>0&&(f+=(i?this.vT:this.WT)+this.Th(h.toArray(),!0)),o.count>0&&(f+=this.XO+this.Th(o.toArray(),!0)),a.count>0&&(f+=(i?this.WT:this.vT)+this.Th(a.toArray(),!0)),a.clear(),h.clear(),f}Vy(t){(t.linkCategoryProperty!==void 0&&t.linkCategoryProperty!==this.linkCategoryProperty||t.linkKeyProperty!==void 0&&t.linkKeyProperty!==this.linkKeyProperty||t.linkFromKeyProperty!==void 0&&t.linkFromKeyProperty!==this.linkFromKeyProperty||t.linkToKeyProperty!==void 0&&t.linkToKeyProperty!==this.linkToKeyProperty||t.linkFromPortIdProperty!==void 0&&t.linkFromPortIdProperty!==this.linkFromPortIdProperty||t.linkToPortIdProperty!==void 0&&t.linkToPortIdProperty!==this.linkToPortIdProperty||t.linkLabelKeysProperty!==void 0&&t.linkLabelKeysProperty!==this.linkLabelKeysProperty||t.nodeIsGroupProperty!==void 0&&t.nodeIsGroupProperty!==this.nodeIsGroupProperty||t.nodeGroupKeyProperty!==void 0&&t.nodeGroupKeyProperty!==this.nodeGroupKeyProperty)&&Util.n("applyIncrementalJson cannot change Model properties"),super.Vy(t);const i=t.insertedLinkKeys;if(Array.isArray(i)){const n=i.length;for(let o=0;o=0&&s.splice(e,1)):s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue));return}}else if(t.change===4){let e=t.oldParam;if(t.modelChange==="linkDataArray"){const s=t.oldValue;if(Util.Mt(s)&&typeof e=="number"){const n=this.getKeyForLinkData(s);i?(this.hr.add(s),this.is[e]!==s&&this.is.splice(e,0,s),n!==void 0&&this.mi.set(n,s)):(this.hr.delete(s),this.is[e]===s&&this.is.splice(e,1),n!==void 0&&this.mi.delete(n))}return}else if(t.modelChange==="linkLabelKeys"){const s=this.getLabelKeysForLinkData(t.object);Array.isArray(s)&&typeof e=="number"&&(i?s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue):(e=s.indexOf(t.newValue),e>=0&&s.splice(e,1)));return}}super.changeState(t,i)}}get archetypeNodeData(){return this.Fl}set archetypeNodeData(t){const i=this.Fl;i!==t&&(t!==null&&Util.t(t,"object",GraphLinksModel,"archetypeNodeData"),this.Fl=t,this.i("archetypeNodeData",i,t))}EN(t){if(t===void 0)return;const i=this.Fl;if(i!==null){let e=this.findNodeDataForKey(t);e===null&&(e=this.copyNodeData(i),Model.ut(e,this.nodeKeyProperty,t),this.addNodeData(e))}return t}get linkFromKeyProperty(){return this.Po}set linkFromKeyProperty(t){const i=this.Po;i!==t&&(this.In(t,GraphLinksModel,"linkFromKeyProperty"),this.Po=t,this.i("linkFromKeyProperty",i,t))}getFromKeyForLinkData(t){return this.Ee(t,!0)}setFromKeyForLinkData(t,i){this.og(t,i,!0)}get linkToKeyProperty(){return this.No}set linkToKeyProperty(t){const i=this.No;i!==t&&(this.In(t,GraphLinksModel,"linkToKeyProperty"),this.No=t,this.i("linkToKeyProperty",i,t))}getToKeyForLinkData(t){return this.Ee(t,!1)}setToKeyForLinkData(t,i){this.og(t,i,!1)}Ee(t,i){if(t===null)return;const e=i?this.Po:this.No;if(e==="")return;const s=Model.Xt(t,e);if(s!==void 0){if(this.isKeyType(s))return s;Util.n((i?"FromKey":"ToKey")+" value for link data "+t+" is not a number or a string: "+s)}}og(t,i,e){if(i===null&&(i=void 0),i!==void 0&&!this.isKeyType(i)&&Util.Vi(i,"number or string",GraphLinksModel,e?"setFromKeyForLinkData:key":"setToKeyForLinkData:key"),t===null)return;const s=e?this.Po:this.No;if(s==="")return;if(i=this.EN(i),!this.containsLinkData(t)){Model.ut(t,s,i);return}const n=Model.Xt(t,s);n!==i&&(this.tn(n,t),Model.ut(t,s,i),this.findNodeDataForKey(i)===null&&this.en(i,t),this.Kt(e?"linkFromKey":"linkToKey",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkFromPortIdProperty(){return this.va}set linkFromPortIdProperty(t){const i=this.va;i!==t&&(this.In(t,GraphLinksModel,"linkFromPortIdProperty"),Debug&&(t===this.linkFromKeyProperty||t===this.linkToKeyProperty)&&Util.n("linkFromPortIdProperty name must not be the same as the GraphLinksModel.linkFromKeyProperty or linkToKeyProperty: "+t),this.va=t,this.i("linkFromPortIdProperty",i,t))}getFromPortIdForLinkData(t){return this.Eb(t,!0)}setFromPortIdForLinkData(t,i){this.rg(t,i,!0)}get linkToPortIdProperty(){return this.Ja}set linkToPortIdProperty(t){const i=this.Ja;i!==t&&(this.In(t,GraphLinksModel,"linkToPortIdProperty"),Debug&&(t===this.linkFromKeyProperty||t===this.linkToKeyProperty)&&Util.n("linkFromPortIdProperty name must not be the same as the GraphLinksModel.linkFromKeyProperty or linkToKeyProperty: "+t),this.Ja=t,this.i("linkToPortIdProperty",i,t))}getToPortIdForLinkData(t){return this.Eb(t,!1)}setToPortIdForLinkData(t,i){this.rg(t,i,!1)}Eb(t,i){if(t===null)return"";const e=i?this.va:this.Ja;if(e==="")return"";const s=Model.Xt(t,e);return s===void 0?"":s}rg(t,i,e){if(Util.t(i,"string",GraphLinksModel,e?"setFromPortIdForLinkData:portname":"setToPortIdForLinkData:portname"),t===null)return;const s=e?this.va:this.Ja;if(s==="")return;if(!this.containsLinkData(t)){Model.ut(t,s,i);return}let n=Model.Xt(t,s);n===void 0&&(n=""),n!==i&&(Model.ut(t,s,i),this.Kt(e?"linkFromPortId":"linkToPortId",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkLabelKeysProperty(){return this.sn}set linkLabelKeysProperty(t){const i=this.sn;i!==t&&(this.In(t,GraphLinksModel,"linkLabelKeysProperty"),this.sn=t,this.i("linkLabelKeysProperty",i,t))}getLabelKeysForLinkData(t){if(t===null)return GraphLinksModel.EmptyArray;const i=this.sn;if(i==="")return GraphLinksModel.EmptyArray;const e=Model.Xt(t,i);return e===void 0?GraphLinksModel.EmptyArray:e}setLabelKeysForLinkData(t,i){if(Util.Gg(i,GraphLinksModel,"setLabelKeysForLinkData:arr"),t===null)return;const e=this.sn;if(e==="")return;if(!this.containsLinkData(t)){Model.ut(t,e,i);return}let s=Model.Xt(t,e);if(s===void 0&&(s=GraphLinksModel.EmptyArray),s!==i){if(Array.isArray(s)){const o=s.length;for(let r=0;r=0)return;n=s.length,s.push(i),this.containsLinkData(t)&&(this.findNodeDataForKey(i)===null&&this.en(i,t),this.Kt("linkLabelKeys",3,e,t,null,i,null,n))}else Util.n(e+" property is not an Array; cannot addLabelKeyForLinkData: "+t)}removeLabelKeyForLinkData(t,i){if(i==null||(this.isKeyType(i)||Util.Vi(i,"number or string",GraphLinksModel,"removeLabelKeyForLinkData:key"),t===null))return;const e=this.sn;if(e==="")return;const s=Model.Xt(t,e);if(Array.isArray(s)){const n=s.indexOf(i);if(n<0)return;s.splice(n,1),this.containsLinkData(t)&&(this.tn(i,t),this.Kt("linkLabelKeys",4,e,t,i,null,n,null))}else s!==void 0&&Util.n(e+" property is not an Array; cannot removeLabelKeyforLinkData: "+t)}get linkDataArray(){return this.is}set linkDataArray(t){const i=this.is;if(i!==t){Util.Gg(t,GraphLinksModel,"linkDataArray"),this.mi.clear();const e=t.length;for(let n=0;nnew GraphLinksModel,Model.initDiagramModel=Model.initDiagramModel=()=>new GraphLinksModel;class TreeModel extends Model{En;bg;$a;constructor(t,i){if(super(),this.En="parent",this.bg=!1,this.$a="parentLinkCategory",t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){super.cloneProtected(t),t.En=this.En,t.bg=this.bg,t.$a=this.$a}toString(t){if(t===void 0&&(t=0),t>=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" TreeModel";if(t>0){i+=` - node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n(w[w.ConstantSpacing=0]="ConstantSpacing",w[w.ConstantDistance=1]="ConstantDistance",w[w.ConstantAngle=2]="ConstantAngle",w[w.Packed=3]="Packed",w))(CircularArrangement||{}),CircularDirection=(w=>(w[w.Clockwise=10]="Clockwise",w[w.Counterclockwise=11]="Counterclockwise",w[w.BidirectionalLeft=12]="BidirectionalLeft",w[w.BidirectionalRight=13]="BidirectionalRight",w))(CircularDirection||{}),CircularSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w[w.Optimized=24]="Optimized",w))(CircularSorting||{}),CircularNodeDiameterFormula=(w=>(w[w.Pythagorean=30]="Pythagorean",w[w.Circular=31]="Circular",w))(CircularNodeDiameterFormula||{});class CircularLayout extends Layout{ce;Yc;qb;kg;jb;Fh;zN;XN;YN;Ns;Xy;Yy;Qa;Ky;ZT;Sg;Mg;Pg;Kc;qi;C;ke;Se;Rn;Ng;constructor(t){super(),this.ce=0,this.Yc=0,this.qb=0,this.kg=360,this.jb=0,this.Fh=0,this.zN=new Point,this.XN=30,this.YN=0,this.Ns=0,this.Xy=0,this.Yy=new VertexArrangement,this.Qa=0,this.Ky=0,this.ZT=600,this.Sg=NaN,this.Mg=1,this.Pg=0,this.Kc=360,this.qi=0,this.C=10,this.ke=24,this.Se=LayoutVertex.standardComparer,this.Rn=6,this.Ng=30,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Sg=this.Sg,t.Mg=this.Mg,t.Pg=this.Pg,t.Kc=this.Kc,t.qi=this.qi,t.C=this.C,t.ke=this.ke,t.Se=this.Se,t.Rn=this.Rn,t.Ng=this.Ng}fi(t){t in CircularSorting?this.sorting=t:t in CircularDirection?this.direction=t:t in CircularArrangement?this.arrangement=t:t in CircularNodeDiameterFormula?this.nodeDiameterFormula=t:super.fi(t)}createNetwork(){return new CircularNetwork(this)}UO(t,i,e){t=this.GO(t);let s=this.jb,n=this.XN,o=this.ce,r=this.Yc,l=this.qb,h=this.kg,a=this.Fh,f=this.YN,c=this.Ns,u=this.Xy;if(s=this.arrangement,n=this.nodeDiameterFormula,o=this.radius,(!isFinite(o)||o<=0)&&(o=NaN),r=this.aspectRatio,(!isFinite(r)||r<=0)&&(r=1),l=this.startAngle,isFinite(l)||(l=0),h=this.sweepAngle,(!isFinite(h)||h>360||h<1)&&(h=360),a=this.spacing,isFinite(a)||(a=NaN),s===3&&n===31?s=0:s===3&&n!==31&&(n=31,s=this.arrangement),(this.direction===12||this.direction===13)&&this.sorting!==24){for(let g=0;!(g>=t.length||(i.add(t.elt(g)),g+1>=t.length));g+=2)e.add(t.elt(g+1));this.direction===12?(this.arrangement===3&&i.reverse(),t=new List,t.addAll(i),t.addAll(e)):(this.arrangement===3&&e.reverse(),t=new List,t.addAll(e),t.addAll(i))}const d=t.length;f=0;let m=0;for(let g=0;g1?(o=y,c=o*r):(c=y,o=c)}else o=this.Wb(u*(h>=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180)}else o=this.Wb(f+(h>=360?d:d-1)*(s!==3?a:a*1.6),r,l*Math.PI/180,h*Math.PI/180);c=o*r}else{c=o*r;const g=this.KN(o,c,l*Math.PI/180,h*Math.PI/180);if(isNaN(a))s===0&&(a=(g-f)/(h>=360?d:d-1));else if(s===0){const p=(g-f)/(h>=360?d:d-1);p=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180),c=o*r):a=p}else{let p=-1/0;for(let k=0;k=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180);x>o?(o=x,c=o*r,u=y):u=g/(h>=360?d:d-1)}}return this.jb=s,this.XN=n,this.ce=o,this.Yc=r,this.qb=l,this.kg=h,this.Fh=a,this.YN=f,this.Ns=c,this.Xy=u,t}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.network.vertexes;if(i.count<=1){if(i.count===1){const u=i.first();u.centerX=0,u.centerY=0}this.updateParts(),this.network=null,this.isValidLayout=!0;return}let e=new List;e.addAll(i.iterator);const s=new List,n=new List;e=this.UO(e,s,n);const o=this.jb,r=this.ce,l=this.qb,h=this.kg,a=this.Fh,f=this.Ns,c=this.Xy;if((this.direction===12||this.direction===13)&&o===3)this.$T(e,h,l-h/2,10);else if(this.direction===12||this.direction===13){let u=0;switch(o){case 1:u=this.vb(r,f,l,c)*180/Math.PI;break;case 0:{let d=0,m=0;const g=s.first();g!==null&&(d=g.Rh(Math.PI/2));const p=n.first();p!==null&&(m=p.Rh(Math.PI/2)),u=this.vb(r,f,l,a+(d+m)/2)*180/Math.PI;break}case 2:u=h/e.length;break}if(this.direction===12){switch(o){case 1:this.Uy(s,h/2,l,11);break;case 0:this.Gy(s,h/2,l,11);break;case 2:this.Hy(s,h/2,l,11);break}switch(o){case 1:this.Uy(n,h/2,l+u,10);break;case 0:this.Gy(n,h/2,l+u,10);break;case 2:this.Hy(n,h/2,l+u,10);break}}else{switch(o){case 1:this.Uy(n,h/2,l,11);break;case 0:this.Gy(n,h/2,l,11);break;case 2:this.Hy(n,h/2,l,11);break}switch(o){case 1:this.Uy(s,h/2,l+u,10);break;case 0:this.Gy(s,h/2,l+u,10);break;case 2:this.Hy(s,h/2,l+u,10);break}}}else switch(o){case 1:this.Uy(e,h,l,this.direction);break;case 0:this.Gy(e,h,l,this.direction);break;case 2:this.Hy(e,h,l,this.direction);break;case 3:this.$T(e,h,l,this.direction);break}this.updateParts(),this.network=null,this.isValidLayout=!0}Hy(t,i,e,s){const n=this.kg,o=this.ce,r=this.Ns,l=e*Math.PI/180,h=i*Math.PI/180,a=t.length;for(let f=0;f=360?a:a-1):-(f*h)/a),u=t.elt(f),d=o*Math.tan(c)/r,m=Math.sqrt((o*o+r*r*d*d)/(1+d*d));u.centerX=m*Math.cos(c),u.centerY=m*Math.sin(c),u.actualAngle=c*180/Math.PI}}Gy(t,i,e,s){const n=this.ce,o=this.Ns,r=this.Fh;let l=e*Math.PI/180;const h=t.length;for(let a=0;a180&&(n-=360),n*=Math.PI/180,this.Ky=n,this.QT(t,i,e,s)}else this._T(t,i,e,s);this.Yy.commit(t)}_T(t,i,e,s){const n=this.ce,o=this.Ns,r=this.Fh,l=this.Yc;let h=n*Math.cos(e*Math.PI/180),a=o*Math.sin(e*Math.PI/180);const f=t.toArray();if(f.length===3){f[0].centerX=n,f[0].centerY=0,f[1].centerX=f[0].centerX-f[0].width/2-f[1].width/2-r,f[1].y=f[0].y,f[2].centerX=(f[0].centerX+f[1].centerX)/2,f[2].y=f[0].y-f[2].height-r;return}else if(f.length===4){f[0].centerX=n,f[0].centerY=0,f[2].centerX=-f[0].centerX,f[2].centerY=f[0].centerY,f[1].centerX=0,f[1].y=Math.min(f[0].y,f[2].y)-f[1].height-r,f[3].centerX=0,f[3].y=Math.max(f[0].y+f[0].height+r,f[2].y+f[2].height+r);return}const c=Point.a();for(let b=0;b=f.length-1));b++)this.tD(h,a,f,b,s,c)||this.iD(h,a,f,b,s,c),h=c.x,a=c.y;if(Point.o(c),this.Qa++,this.Qa>23)return;const u=f[0].centerX,d=f[0].centerY,m=f[f.length-1].centerX,g=f[f.length-1].centerY;let p=Math.abs(u-m)-((f[0].width+f[f.length-1].width)/2+r);const y=Math.abs(d-g)-((f[0].height+f[f.length-1].height)/2+r);let x=0;if(Math.abs(y)<1){const b=Math.abs(u-m),S=(f[0].width+f[f.length-1].width)/2;b0?x=y:Math.abs(p)<1?x=0:x=p;let k=!1;Math.abs(m)>Math.abs(g)?k=m>0!=d>g:k=g>0!=u1&&(this.Qa<8?this.ce-=x/(2*Math.PI):f.length<5&&x>10?this.ce/=2:this.ce-=x>0?1.7:-2.3,this.Ns=this.ce*l,this._T(t,i,e,s))}QT(t,i,e,s){const n=this.ce,o=this.Ns,r=this.Yc;let l=n*Math.cos(e*Math.PI/180),h=o*Math.sin(e*Math.PI/180);const a=Point.a(),f=t.toArray();for(let m=0;m=f.length-1));m++)this.tD(l,h,f,m,s,a)||this.iD(l,h,f,m,s,a),l=a.x,h=a.y;if(Point.o(a),this.Qa++,this.Qa>23)return;const c=Math.atan2(h,l);let u=s===10?this.Ky-c:c-this.Ky;u=Math.abs(u)1&&(this.Qa<8?this.ce-=d/(2*Math.PI):this.ce-=d>0?1.7:-2.3,this.Ns=this.ce*r,this.QT(t,i,e,s))}tD(t,i,e,s,n,o){const r=this.Fh,l=this.ce,h=this.Ns;let a=0,f=0;const c=(e[s].width+e[s+1].width)/2+r;let u=!1;if(i>=0!=(n===10)){if(a=t+c,a>l){if(a=t-c,a<-l)return o.x=a,o.y=f,!1;u=!0}}else if(a=t-c,a<-l){if(a=t+c,a>l)return o.x=a,o.y=f,!1;u=!0}return f=Math.sqrt(1-Math.min(1,a*a/(l*l)))*h,i<0!==u&&(f=-f),Math.abs(i-f)>(e[s].height+e[s+1].height)/2?(o.x=a,o.y=f,!1):(o.x=a,o.y=f,!0)}iD(t,i,e,s,n,o){const r=this.Fh,l=this.ce,h=this.Ns;let a=0,f=0;const c=(e[s].height+e[s+1].height)/2+r;let u=!1;if(t>=0!=(n===10)){if(f=i-c,f<-h){if(f=i+c,f>h)return o.x=a,o.y=f,!1;u=!0}}else if(f=i+c,f>h){if(f=i-c,f<-h)return o.x=a,o.y=f,!1;u=!0}return a=Math.sqrt(1-Math.min(1,f*f/(h*h)))*l,t<0!==u&&(a=-a),Math.abs(t-a)>(e[s].width+e[s+1].width)/2?(o.x=a,o.y=f,!1):(o.x=a,o.y=f,!0)}commitLayout(){this.commitNodes(),this.isRouting&&this.commitLinks()}commitNodes(){const t=this.group!==null&&this.group.hasPlaceholder(),i=t?this.group.location.copy():null;let e=this.actualCenter;t?e=new Point(0,0):(e.x=this.arrangementOrigin.x+this.ce,e.y=this.arrangementOrigin.y+this.Ns);const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;n.x+=e.x,n.y+=e.y,n.commit()}if(t){this.group.ensureBounds();const n=this.group.position.copy(),o=this.group.location.copy(),r=i.subtract(o.subtract(n));this.group.move(r),this.zN=r.subtract(n)}}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}KN(t,i,e,s){const n=this.ZT;if(Math.abs(this.Yc-1)<.001)return e!==void 0&&s!==void 0?s*t:2*Math.PI*t;const o=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let r=0,l=0;e!==void 0&&s!==void 0?l=s/(n+1):l=Math.PI/(2*(n+1));let h=0;for(let a=0;a<=n;a++){e!==void 0&&s!==void 0?h=e+a*s/n:h=a*Math.PI/(2*n);const f=Math.sin(h);r+=Math.sqrt(1-o*o*f*f)*l}return e!==void 0&&s!==void 0?(t>i?t:i)*r:4*(t>i?t:i)*r}Wb(t,i,e,s){let n=0;return e!==void 0&&s!==void 0?n=this.KN(1,i,e,s):n=this.KN(1,i),t/n}vb(t,i,e,s){if(Math.abs(this.Yc-1)<.001)return s/t;const n=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let o=0;const r=2*Math.PI/(this.network.vertexes.count*700);t>i&&(e+=Math.PI/2);for(let l=0;;l++){const h=e+l*r,a=Math.sin(h);if(o+=(t>i?t:i)*Math.sqrt(1-n*n*a*a)*r,o>=s)return l*r}}GO(t){switch(this.sorting){case 20:break;case 21:t.reverse();break;case 22:t.sort(this.comparer);break;case 23:t.sort(this.comparer),t.reverse();break;case 24:return this.jO(this.WO(t));default:Util.n("Invalid sorting type.")}return t}WO(t){const i=[];for(let s=0;sn&&(n=u,o=f)}else for(let f=0;fn&&(n=c,o=f)}e.add(t.elt(o)),i[o]=-1;const r=t.elt(o);let l=0;const h=r.sourceEdges;for(;h.next();){const c=h.value.fromVertex;l=t.indexOf(c),!(l<0)&&i[l]>=0&&i[l]++}const a=r.destinationEdges;for(;a.next();){const c=a.value.toVertex;l=t.indexOf(c),!(l<0)&&i[l]>=0&&i[l]++}}return e}jO(t){const i=[];for(let c=0;c=0){const C=Math.abs(x-(A>=x?A+1:A));b+=C=x&&M++,A>=x&&A++,M>A){const C=A;A=M,M=C}A-M<(s.length+2)/2==(M=0&&(n.push(c),o.push(x))}h++}let a=!1;const f=s.length;for(;;){a=!0;for(let c=0;c=0){let g=0;for(let p=0;pm?x-m:m-x,b=f-k;g+=xb?1:-1}s.splice(g<0?m:m+1,0,u),r.splice(c,1),c--}else a=!1}if(a)break;s.push(r[0]),r.splice(0,1)}for(let c=0;c0||isNaN(t))&&(this.Sg=t,this.invalidateLayout()))}get aspectRatio(){return this.Mg}set aspectRatio(t){this.Mg!==t&&(Util.t(t,"number",CircularLayout,"aspectRatio"),t>0&&(this.Mg=t,this.invalidateLayout()))}get startAngle(){return this.Pg}set startAngle(t){this.Pg!==t&&(Util.t(t,"number",CircularLayout,"startAngle"),this.Pg=t,this.invalidateLayout())}get sweepAngle(){return this.Kc}set sweepAngle(t){this.Kc!==t&&(Util.t(t,"number",CircularLayout,"sweepAngle"),t>0&&t<=360?this.Kc=t:this.Kc=360,this.invalidateLayout())}get arrangement(){return this.qi}set arrangement(t){this.qi!==t&&(Util.tt(t,CircularArrangement,"CircularArrangement"),(t===3||t===0||t===1||t===2)&&(this.qi=t,this.invalidateLayout()))}get direction(){return this.C}set direction(t){this.C!==t&&(Util.tt(t,CircularDirection,"CircularDirection"),(t===10||t===11||t===12||t===13)&&(this.C=t,this.invalidateLayout()))}get sorting(){return this.ke}set sorting(t){this.ke!==t&&(Util.tt(t,CircularSorting,"CircularSorting"),this.ke=t,this.invalidateLayout())}get comparer(){return this.Se}set comparer(t){this.Se!==t&&(Util.t(t,"function",CircularLayout,"comparer"),this.Se=t,this.invalidateLayout())}get spacing(){return this.Rn}set spacing(t){this.Rn!==t&&(Util.t(t,"number",CircularLayout,"spacing"),this.Rn=t,this.invalidateLayout())}get nodeDiameterFormula(){return this.Ng}set nodeDiameterFormula(t){this.Ng!==t&&(Util.tt(t,CircularNodeDiameterFormula,"CircularNodeDiameterFormula"),(t===30||t===31)&&(this.Ng=t,this.invalidateLayout()))}get actualXRadius(){return this.ce}get actualYRadius(){return this.Ns}get actualSpacing(){return this.Fh}get actualCenter(){return this.zN}static ConstantSpacing=0;static ConstantDistance=1;static ConstantAngle=2;static Packed=3;static Clockwise=10;static Counterclockwise=11;static BidirectionalLeft=12;static BidirectionalRight=13;static Forwards=20;static Reverse=21;static Ascending=22;static Descending=23;static Optimized=24;static Pythagorean=30;static Circular=31}class VertexArrangement{Uc;_a;Gc;constructor(){this.Uc=-1/0,this._a=null,this.Gc=null}HO(t,i){if(t>0&&this.Uc<0||Math.abs(t)0)){this.Uc=t,this._a=[],this.Gc=[];for(let e=0;e0){for(this.network.deleteSelfEdges(),i=this.network.vertexes.iterator;i.next();){const o=i.value;o.charge=this.electricalCharge(o),o.mass=this.gravitationalMass(o)}const s=this.network.edges.iterator;for(;s.next();){const o=s.value;o.stiffness=this.springStiffness(o),o.length=this.springLength(o)}if(this.UN(),this.Ih=0,this.needsPrelayout()){const o=this.network,r=o.splitIntoSubNetworks(!1);let l=r.iterator;for(;l.next();){const h=l.value;this.doConnectedSubnetLayout(h)}for(l=r.iterator,this.JO(l,o),l=r.iterator;l.next();){const h=l.value,a=h.vertexes.iterator;for(;a.next();){const c=a.value;o.addVertex(c)}const f=h.edges.iterator;for(;f.next();){const c=f.value;o.addEdge(c)}}}else this.eD(this.network,this.maxIterations);this.updateParts()}this.maxIterations=e,this.isValidLayout=!0}needsPrelayout(){if(this.network.vertexes.count<3)return!1;let t=0,i=0;const e=this.network.vertexes.first().bounds,s=this.network.vertexes.iterator;for(;s.next();){const n=s.value,o=n.bounds;if(isNaN(n.x)||isNaN(n.y)||o.intersectsRect(e)&&(t++,t>2))return!0;if(i>10)return!1;i++}return!1}doConnectedSubnetLayout(t){let i=t.vertexes.iterator;for(;i.next();){const l=i.value;l.hierarchicalVertexes.add(l)}let e=t,s=this.Jc;if(isNaN(s)&&(s=t.edges.count/t.vertexes.count),sMath.max(100,Math.sqrt(s*t.vertexes.count));)e=this.coarsenNetwork(e);let n=0;i=e.vertexes.iterator;let o=this.randomNumberGenerator;for(o===null&&(this.randomNumberGenerator=o=new RandomNumberGenerator(0));i.next();){i.value.idInCluster=n++;const l=10*(o.random()-.5),h=10*(o.random()-.5);this.isFixed(i.value)||(i.value.x=l,i.value.y=h);const a=i.value.hierarchicalVertexes.iterator;for(;a.next();)this.isFixed(a.value)||(a.value.x=l,a.value.y=h)}const r=this.computePairwiseDistances(e);this.ZO(e,r,this.maxPrelayoutIterations,t.vertexes.count),this.eD(t,this.maxIterations)}computePairwiseDistances(t){const i=t.vertexes.count,e=new Array(i);for(let r=0;r0;){const l=o.shift(),h=l.vertexes.iterator;for(;h.next();){const a=h.value;n.has(a.idInCluster)||(n.set(a.idInCluster,n.get(l.idInCluster)+1),o.push(a))}}for(let l=0;l=0;m--)if(t[m].y>f.y&&t[m].x-f.xf.x&&t[m].y-f.ya+c){const u=s+o-h,d=n-a-c;return Geo.Aw(u*u+d*d)}else if(n+rh+f)if(n>a+c){const u=s-h-f,d=n-a-c;return Geo.Aw(u*u+d*d)}else if(n+ra+c?n-(a+c):n+rr-o;l?i.sort((m,g)=>m===null||g===null||m===g?0:m.centerX-g.centerX):i.sort((m,g)=>m===null||g===null||m===g?0:m.centerY-g.centerY);const h=this.Hc;let a=0,f=0,c=0;for(let m=0;mh||C-x>h){if(l)break;continue}if(k-P>h||P-k>h){if(!l)break;continue}const N=this.GN(g,S),T=2*g.charge,L=2*S.charge;if(N>1)a=T*L/(N*N),f=a*(x-C)/N,c=a*(k-P)/N;else{let D=this.randomNumberGenerator;D===null&&(this.randomNumberGenerator=D=new RandomNumberGenerator(0));const F=D.random(),R=D.random();if(x>C)f=Math.abs(S.bounds.right-g.bounds.x),f=T*L*(1+f)*F;else if(xP)c=Math.abs(S.bounds.bottom-g.bounds.y),c=T*L*(1+c)*R;else if(x1&&(a=.1*m.stiffness*(P-m.length),f=a*.5*(g.width+p.height)*(k-A)/P,c=a*.5*(g.width+p.height)*(b-C)/P),g.forceX-=f,g.forceY-=c,p.forceX+=f,p.forceY+=c}let d=0;for(let m=0;mthis.epsilonDistance*this.epsilonDistance}ZO(t,i,e,s){Debug&&Util.r(e,ForceDirectedLayout,"performIterations:num");const n=this.Ih+e,o=Math.sqrt(s);this.qy=this.tf*t.vertexes.count;const r=t.vertexes.toArray();let l=0,h=0,a=0;for(;this.Ih0){r[f].forceX=this.qy*r[f].forceX/c,r[f].forceY=this.qy*r[f].forceY/c,this.isFixed(r[f])||(r[f].x+=r[f].forceX,r[f].y+=r[f].forceY);const u=r[f].hierarchicalVertexes.iterator;for(;u.next();){const d=u.value;this.isFixed(d)||(d.centerX+=r[f].forceX,d.centerY+=r[f].forceY)}}l+=c*c}if(l>=h){if(a++,a>=5)break}else a=0;this.qy*=.95}}moveVertex(t){let i=t.forceX,e=t.forceY;const s=this.moveLimit;return i<-s?i=-s:i>s&&(i=s),e<-s?e=-s:e>s&&(e=s),t.centerX+=i,t.centerY+=e,i*i+e*e}shouldInteract(t,i){return!0}moveFixedVertex(t){}commitLayout(){this.jy(),this.commitNodes(),this.isRouting&&this.commitLinks()}jy(){if(!this.setsPortSpots)return;const t=this.network.edges.iterator;for(;t.next();){const e=t.value.link;e!==null&&(e.fromSpot=Spot.Default,e.toSpot=Spot.Default)}}commitNodes(){let t=0,i=0;if(this.arrangesToOrigin){const n=Rect.a();this.Rw(this.network,n);const o=this.arrangementOrigin;t=o.x-n.x,i=o.y-n.y,Rect.o(n)}const e=Rect.a(),s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;(t!==0||i!==0)&&(e.c(n.bounds),e.x+=t,e.y+=i,n.bounds=e),n.commit()}Rect.o(e)}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}springStiffness(t){const i=t.stiffness;return isNaN(i)?this.qc:i}springLength(t){const i=t.length;return isNaN(i)?this.jc:i}electricalCharge(t){const i=t.charge;return isNaN(i)?this.Wc:i}electricalFieldX(t,i){return 0}electricalFieldY(t,i){return 0}gravitationalMass(t){const i=t.mass;return isNaN(i)?this.vc:i}gravitationalFieldX(t,i){return 0}gravitationalFieldY(t,i){return 0}isFixed(t){return t.isFixed}get currentIteration(){return this.Ih}get arrangementSpacing(){return this.Cs}set arrangementSpacing(t){Util.s(t,Size,ForceDirectedLayout,"arrangementSpacing"),this.Cs.equals(t)||(this.Cs.c(t),this.invalidateLayout())}get arrangesToOrigin(){return this.Cg}set arrangesToOrigin(t){this.Cg!==t&&(Util.t(t,"boolean",ForceDirectedLayout,"arrangesToOrigin"),this.Cg=t,this.invalidateLayout())}get setsPortSpots(){return this.Vn}set setsPortSpots(t){this.Vn!==t&&(Util.t(t,"boolean",ForceDirectedLayout,"setsPortSpots"),this.Vn=t,this.invalidateLayout())}get comments(){return this.Be}set comments(t){this.Be!==t&&(Util.t(t,"boolean",ForceDirectedLayout,"comments"),this.Be=t,this.invalidateLayout())}get maxPrelayoutIterations(){return this.Ag}set maxPrelayoutIterations(t){this.Ag!==t&&(Util.t(t,"number",ForceDirectedLayout,"maxPrelayoutIterations"),t>=0&&(this.Ag=t,this.invalidateLayout()))}get maxIterations(){return this.Lg}set maxIterations(t){this.Lg!==t&&(Util.t(t,"number",ForceDirectedLayout,"maxIterations"),t>=0&&(this.Lg=t,this.invalidateLayout()))}get epsilonDistance(){return this.Tg}set epsilonDistance(t){this.Tg!==t&&(Util.t(t,"number",ForceDirectedLayout,"epsilonDistance"),t>0&&(this.Tg=t,this.invalidateLayout()))}get infinityDistance(){return this.Hc}set infinityDistance(t){this.Hc!==t&&(Util.t(t,"number",ForceDirectedLayout,"infinityDistance"),t>1&&(this.Hc=t,this.invalidateLayout()))}get moveLimit(){return this.Dg}set moveLimit(t){this.Dg!==t&&(Util.t(t,"number",ForceDirectedLayout,"moveLimit"),this.Dg=t,this.invalidateLayout())}get randomNumberGenerator(){return this.Fg}set randomNumberGenerator(t){this.Fg!==t&&(t!==null&&typeof t.random!="function"&&Util.n('ForceDirectedLayout.randomNumberGenerator must have a "random()" function on it: '+t),this.Fg=t)}get defaultSpringStiffness(){return this.qc}set defaultSpringStiffness(t){this.qc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultSpringStiffness"),this.qc=t,this.invalidateLayout())}get defaultSpringLength(){return this.jc}set defaultSpringLength(t){this.jc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultSpringLength"),this.jc=t,this.invalidateLayout())}get defaultElectricalCharge(){return this.Wc}set defaultElectricalCharge(t){this.Wc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultElectricalCharge"),this.Wc=t,this.invalidateLayout())}get defaultGravitationalMass(){return this.vc}set defaultGravitationalMass(t){this.vc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultGravitationalMass"),this.vc=t,this.invalidateLayout())}get defaultCommentSpringLength(){return this.Rg}set defaultCommentSpringLength(t){this.Rg!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultCommentSpringLength"),this.Rg=t,this.invalidateLayout())}get defaultCommentElectricalCharge(){return this.Ig}set defaultCommentElectricalCharge(t){this.Ig!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultCommentElectricalCharge"),this.Ig=t,this.invalidateLayout())}get prelayoutQuality(){return this.Jc}set prelayoutQuality(t){this.Jc!==t&&(Util.t(t,"number",ForceDirectedLayout,"prelayoutQuality"),this.Jc=t,this.invalidateLayout())}get prelayoutSpread(){return this.tf}set prelayoutSpread(t){this.tf!==t&&(Util.t(t,"number",ForceDirectedLayout,"prelayoutSpread"),this.tf=t,this.invalidateLayout())}}class ForceDirectedNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new ForceDirectedVertex(this)}createEdge(){return new ForceDirectedEdge(this)}}class ForceDirectedVertex extends LayoutVertex{Zb;$b;Qb;_b;tk;hierarchicalVertexes;idInCluster;constructor(t){super(t),this.Zb=!1,this.$b=NaN,this.Qb=NaN,this._b=0,this.tk=0,this.hierarchicalVertexes=new List,this.idInCluster=-1}get isFixed(){return this.Zb}set isFixed(t){this.Zb!==t&&(Util.t(t,"boolean",ForceDirectedVertex,"isFixed"),this.Zb=t)}get charge(){return this.$b}set charge(t){this.$b!==t&&(Util.t(t,"number",ForceDirectedVertex,"charge"),this.$b=t)}get mass(){return this.Qb}set mass(t){this.Qb!==t&&(Util.t(t,"number",ForceDirectedVertex,"mass"),this.Qb=t)}get forceX(){return this._b}set forceX(t){this._b!==t&&(Util.t(t,"number",ForceDirectedVertex,"forceX"),this._b=t)}get forceY(){return this.tk}set forceY(t){this.tk!==t&&(Util.t(t,"number",ForceDirectedVertex,"forceY"),this.tk=t)}}class ForceDirectedEdge extends LayoutEdge{ik;ek;constructor(t){super(t),this.ik=NaN,this.ek=NaN}get stiffness(){return this.ik}set stiffness(t){this.ik!==t&&(Util.t(t,"number",ForceDirectedEdge,"stiffness"),this.ik=t)}get length(){return this.ek}set length(t){this.ek!==t&&(Util.t(t,"number",ForceDirectedEdge,"length"),this.ek=t)}}class RandomNumberGenerator{I;R;Q;M;A;seed;constructor(t){t===void 0&&(t=42),this.seed=t,this.A=48271,this.M=2147483647,this.Q=this.M/this.A,this.R=this.M%this.A,this.I=1/this.M,this.random()}random(){const t=this.seed/this.Q,i=this.seed%this.Q,e=this.A*i-this.R*t;return e>0?this.seed=e:this.seed=e+this.M,this.seed*this.I}}var LayeredDigraphCycleRemove=(w=>(w[w.DepthFirst=0]="DepthFirst",w[w.Greedy=1]="Greedy",w[w.FromLayers=2]="FromLayers",w))(LayeredDigraphCycleRemove||{}),LayeredDigraphLayering=(w=>(w[w.OptimalLinkLength=10]="OptimalLinkLength",w[w.LongestPathSink=11]="LongestPathSink",w[w.LongestPathSource=12]="LongestPathSource",w))(LayeredDigraphLayering||{}),LayeredDigraphInit=(w=>(w[w.DepthFirstOut=20]="DepthFirstOut",w[w.DepthFirstIn=21]="DepthFirstIn",w[w.Naive=22]="Naive",w))(LayeredDigraphInit||{}),LayeredDigraphAggressive=(w=>(w[w.None=30]="None",w[w.Less=31]="Less",w[w.More=32]="More",w))(LayeredDigraphAggressive||{}),LayeredDigraphPack=(w=>(w[w.None=0]="None",w[w.Expand=1]="Expand",w[w.Straighten=2]="Straighten",w[w.Median=4]="Median",w[w.MaybeExpand=8]="MaybeExpand",w[w.All=15]="All",w))(LayeredDigraphPack||{}),LayeredDigraphAlign=(w=>(w[w.None=0]="None",w[w.UpperLeft=1]="UpperLeft",w[w.UpperRight=2]="UpperRight",w[w.LowerLeft=4]="LowerLeft",w[w.LowerRight=8]="LowerRight",w[w.All=15]="All",w))(LayeredDigraphAlign||{});class LayeredDigraphLayout extends Layout{As;_i;C;Zc;$c;Qc;ef;_c;ar;tu;Vn;Lt;Wy;Wt;Og;Ls;pi;nn;Ts;Ds;Gt;Eg;sf;Vg;on;iu;fr;Bn;zn;HN;constructor(t){super(),this.As=25,this._i=25,this.C=0,this.Zc=0,this.$c=10,this.Qc=20,this.ef=4,this._c=31,this.ar=15,this.tu=10,this.Vn=!0,this.Lt=-1,this.Wy=-1,this.Wt=-1,this.Og=0,this.Ls=0,this.pi=null,this.nn=null,this.Ts=null,this.Ds=null,this.Gt=null,this.Eg=0,this.sf=null,this.Vg=null,this.on=0,this.iu=null,this.fr=new Point,this.Bn=[],this.Bn.length=100,this.zn=15,this.HN=0,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.As=this.As,t._i=this._i,t.C=this.C,t.Zc=this.Zc,t.$c=this.$c,t.Qc=this.Qc,t.ef=this.ef,t._c=this._c,t.ar=this.ar,t.tu=this.tu,t.Vn=this.Vn,t.zn=this.zn}fi(t){t in LayeredDigraphAggressive?this.aggressiveOption=t:t in LayeredDigraphCycleRemove?this.cycleRemoveOption=t:t in LayeredDigraphInit?this.initializeOption=t:t in LayeredDigraphLayering?this.layeringOption=t:super.fi(t)}createNetwork(){return new LayeredDigraphNetwork(this)}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin),this.QO(),this.network.vertexes.count>0&&(this.network.deleteSelfEdges(),this.cycleRemoveOption!==2&&this.removeCycles(),this._O(),this.cycleRemoveOption===2&&this.removeCycles(),this.t3(),this.i3(),this.e3(),this.reduceCrossings(),this.straightenAndPack(),this.updateParts()),this.network=null,this.isValidLayout=!0}linkMinLength(t){return 1}linkLengthWeight(t){return 1}linkStraightenWeight(t){const i=t.fromVertex.node||t.fromVertex.data,e=t.toVertex.node||t.toVertex.data;return i===null&&e===null?8:i===null||e===null?4:1}nodeMinLayerSpace(t,i){return t.node===null&&t.data===null?0:this.C===90||this.C===270?i?t.focus.y+10:t.bounds.height-t.focus.y+10:i?t.focus.x+10:t.bounds.width-t.focus.x+10}nodeMinColumnSpace(t,i){if(t.node===null&&t.data===null)return 0;const e=i?t.sk:t.nk;if(e!==null)return e;const s=this.C;return s===90||s===270?i?t.sk=t.focus.x/this._i+1|0:t.nk=(t.bounds.width-t.focus.x)/this._i+1|0:i?t.sk=t.focus.y/this._i+1|0:t.nk=(t.bounds.height-t.focus.y)/this._i+1|0}te(){this.sf===null&&(this.sf=[]);let t=0;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;this.sf[t]=e.layer,t++,this.sf[t]=e.column,t++,this.sf[t]=e.index,t++}return this.sf}es(t){let i=0;const e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;s.layer=t[i],i++,s.column=t[i],i++,s.index=t[i],i++}}nD(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"crossingMatrix:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"crossingMatrix:direction"));const e=this.Oh(t),s=this.pi[t];(this.Vg===null||this.Vg.length=0){for(f=e[o].So,c=0;ck||d===k&&g>S)&&r++,bd||k===d&&S>g)&&r++)}if(i<=0){for(f=e[o].rr,c=0;ck||d===k&&m>b)&&r++,Sd||k===d&&b>m)&&r++)}for(n[o*s+o]=r,a=o+1;a=0){for(p=e[o].So,M=e[a].So,c=0;c=0&&(h=s[r].rr);let a,f=0,c=0;if(l!==null)for(let u=0;u=0&&(h=r.rr);let a=0,f=0;const c=r.near;c!==null&&c.layer===r.layer&&(a+=c.column-1,f++);let u;if(l!==null)for(let d=0;d=0&&(h=r.rr);let a=0;const f=[],c=r.near;c!==null&&c.layer===r.layer&&(f[a]=c.column-1,a++);let u;if(l!==null)for(let d=0;dm-g);const d=a>>1;a&1?n[o]=f[d]:n[o]=f[d-1]+f[d]>>1}}return this.Eh(t,e),n}Zy(t,i,e,s,n){if(t.component===e){t.component=i;let o=0,r=0;if(s){const l=t.destinationEdges;for(;l.next();){const h=l.value,a=h.toVertex;o=t.layer-a.layer,r=this.linkMinLength(h),o===r&&this.Zy(a,i,e,s,n)}}if(n){const l=t.sourceEdges;for(;l.next();){const h=l.value,a=h.fromVertex;o=a.layer-t.layer,r=this.linkMinLength(h),o===r&&this.Zy(a,i,e,s,n)}}}}qN(t,i,e,s,n){if(t.component===e){if(t.component=i,s){const o=t.destinationEdges;for(;o.next();){const l=o.value.toVertex;this.qN(l,i,e,s,n)}}if(n){const o=t.sourceEdges;for(;o.next();){const l=o.value.fromVertex;this.qN(l,i,e,s,n)}}}}removeCycles(){const t=this.network.edges.iterator;for(;t.next();){const i=t.value;i.rev=!1}switch(this.Zc){default:case 1:this.o3();break;case 0:this.r3();break;case 2:this.l3();break}}l3(){const t=this.network,i=t.vertexes.iterator;let e=1/0;for(;i.next();){const s=i.value;e=Math.min(e,s.layer)}if(e<1/0){if(e<0)for(i.reset();i.next();){const r=i.value;r.layer-=e}const s=[];for(i.reset();i.next();){const r=i.value,l=s[r.layer];l===void 0?s[r.layer]=[r]:l.push(r)}let n=0;for(let r=0;r0)for(let h=0;hh.index&&(t.reverseEdge(r),r.rev=!0)}}h3(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.ie)return e}return null}rD(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.ie){let s=!0;const n=e.destinationEdges;for(;n.next();)if(n.value.toVertex.ie){s=!1;break}if(s)return e}}return null}lD(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.ie){let s=!0;const n=e.sourceEdges;for(;n.next();)if(n.value.fromVertex.ie){s=!1;break}if(s)return e}}return null}a3(t){let i=null,e=0;const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;if(n.ie){let o=0;const r=n.destinationEdges;for(;r.next();)r.value.toVertex.ie&&o++;let l=0;const h=n.sourceEdges;for(;h.next();)h.value.fromVertex.ie&&l++;(i===null||ef&&this.Zy(h,e,-1,!0,!1)}for(this.Zy(t,s,-1,!0,!0);t.component!==e;){let r=0,l=1/0,h=0,a=null;const f=this.network.vertexes.iterator;for(;f.next();){const c=f.value;if(c.component===s){let u=0,d=!1;const m=c.So;o=m.length;for(let p=0;p0){for(i.reset();i.next();){const c=i.value;c.component===s&&(c.layer+=l)}t.component=e}else a.component=e}}d3(t){const i=this.network.vertexes.iterator;for(;i.next();){const n=i.value;n.component=-1}const e=0,s=1;for(this.Zy(t,s,-1,!0,!1);t.component!==e;){let n=0,o=1/0,r=0,l=null;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value;if(a.component===s){let f=0,c=!1;const u=a.So;let d=u.length;for(let g=0;gr)&&!c&&(l=a,r=f)}}if(n<0){for(i.reset();i.next();){const a=i.value;a.component===s&&(a.layer-=o)}t.component=e}else l.component=e}}t3(){const t=this.network,i=[],e=t.edges.iterator;for(;e.next();){const s=e.value;s.valid=!1,i.push(s)}for(let s=0;sb&&c>0){for(n.valid=!1,y=t.createVertex(),y.node=null,y.rk=2,y.layer=c-1,x&&kb&&c>0;)y=t.createVertex(),y.node=null,y.rk=3,y.layer=c-1,x&&kt[this.Ls]&&(this.Wy=t[e]-1,this.Ls=e),t[e]{o.index=this.pi[s],this.pi[s]++})}}y3(){let t=null;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;if(e.near&&(t===null&&(t=new Map),e.layer===e.near.layer)){const s=t.get(e.near)||[];s.push(e),t.set(e.near,s)}}for(let e=this.Lt;e>=0;e--)for(i.reset();i.next();){const s=i.value;s.layer===e&&s.index===-1&&this.gD(s,t)}}gD(t,i){if(t.near)return;const e=t.layer;if(t.index=this.pi[e],this.pi[e]++,i){const o=i.get(t);Array.isArray(o)&&o.forEach(r=>{r.index=this.pi[e],this.pi[e]++})}const s=t.rr;let n=!0;for(;n;){n=!1;for(let o=0;ol.portFromColOffset&&(n=!0,s[o]=l,s[o+1]=r)}}for(let o=0;o{a.index=this.pi[e],this.pi[e]++})}const s=t.So;let n=!0,o=0;for(;n;)for(n=!1,o=0;oa.portToColOffset&&(n=!0,s[o]=a,s[o+1]=h)}let r,l;for(o=0;o=0;s--)this.hk(s,-1),this.us(s,-1,!1,-1);n=this.countCrossings(),n=0;s--)this.hk(s,0),this.us(s,0,!1,0);n=this.countCrossings(),n=0;r--)for(l=0;l<=r;l++){for(o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,1,!1,1)||o;for(n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,-1,!1,-1)||o;for(n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,0,!1,0)||o;for(n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,0,!1,0)||o;n>=t?this.es(i):(t=n,i=this.te())}break;default:case 31:for(r=this.Lt,l=0,h=t+1;(a=this.countCrossings())=l;s--)o=this.us(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,1,!1,1)||o;for(n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,-1,!1,-1)||o;for(n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,0,!1,0)||o;for(n>=t?this.es(i):(t=n,i=this.te()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,0,!1,0)||o;n>=t?this.es(i):(t=n,i=this.te())}break}this.es(i)}hk(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"medianBarycenterCrossingReduction:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"medianBarycenterCrossingReduction:direction"));let e=0,s=!1;const n=this.Oh(t),o=this.pi[t],r=this.oD(t,i),l=this.Jy(t,i);for(e=0;e0)for(h=[],l=0;ll+1&&(m+=4*(I-l),g+=4*(I-(l+1)))}}const V=n[l].destinationEdges.iterator;if(e&&s>=0)for(;V.next();){const W=V.value;O=W.toVertex,W.valid&&O.layer!==t&&(N=this.linkStraightenWeight(W),T=W.portFromColOffset,L=W.portToColOffset,F=O.column,C+=(Math.abs(p+T-(F+L))+1)*N,P+=(Math.abs(A+T-(F+L))+1)*N)}for(V.reset();V.next();){const W=V.value;if(O=W.toVertex,W.valid&&O.layer===t){for(B=0;Bl+1&&(m+=4*(I-(l+1)),g+=4*(I-l))}}const z=n[l+1].destinationEdges.iterator;if(e&&s>=0)for(;z.next();){const W=z.value;O=W.toVertex,W.valid&&O.layer!==t&&(N=this.linkStraightenWeight(W),T=W.portFromColOffset,L=W.portToColOffset,F=O.column,C+=(Math.abs(y+T-(F+L))+1)*N,P+=(Math.abs(M+T-(F+L))+1)*N)}for(z.reset();z.next();){const W=z.value;if(O=W.toVertex,W.valid&&O.layer===t){for(B=0;B1e3&&s&&(e=!1),e){const n=[];let o=0;for(o=0;o<=this.Lt;o++)n[o]=0;let r=0;const l=this.network.vertexes.iterator;for(;l.next();){const a=l.value;t=a.layer,r=a.column;const f=this.nodeMinColumnSpace(a,!1);n[t]=Math.max(n[t],r+f)}const h=8;for(l.reset();l.next();){const a=l.value;t=a.layer,r=a.column,a.column=((this.Wt-n[t])*h>>1)+r*h}this.Wt*=h}if(this.ar&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Bg(t,-1)||i;i=this.Bg(this.Ls,0)||i,n++}}if(this.ar&4){for(t=this.Ls+1;t<=this.Lt;t++)this.WN(t,1);for(t=this.Ls-1;t>=0;t--)this.WN(t,-1);this.WN(this.Ls,0)}if(e&&(this.pD(-1),this.pD(1)),this.ar&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Bg(t,0)||i;n++}}}Bg(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"bendStraighten:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"bendStraighten:direction"));let e=!1;for(;this.b3(t,i);)e=!0;return e}b3(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"shiftbendStraighten:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"shiftbendStraighten:direction"));let e=0;const s=this.Oh(t),n=this.pi[t],o=this.Jy(t,-1);if(i>0)for(e=0;ef+this.nodeMinColumnSpace(s[e-1],!1)?u=a-1:u=a;let d=0;e+1>=n||s[e+1].column-a-1>c+this.nodeMinColumnSpace(s[e+1],!0)?d=a+1:d=a;let m=0,g=0,p=0,y=0,x=0,k=0;if(i<=0){const P=s[e].sourceEdges.iterator;for(;P.next();){const N=P.value,T=N.fromVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const L=T.column;m+=(Math.abs(a+k-(L+x))+1)*y,g+=(Math.abs(u+k-(L+x))+1)*y,p+=(Math.abs(d+k-(L+x))+1)*y}}}if(i>=0){const P=s[e].destinationEdges.iterator;for(;P.next();){const N=P.value,T=N.toVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const L=T.column;m+=(Math.abs(a+x-(L+k))+1)*y,g+=(Math.abs(u+x-(L+k))+1)*y,p+=(Math.abs(d+x-(L+k))+1)*y}}}let b=0,S=0,M=0;const A=o[s[e].index],C=r[s[e].index];A!==-1&&(b+=Math.abs(A-a),S+=Math.abs(A-u),M+=Math.abs(A-d)),C!==-1&&(b+=Math.abs(C-a),S+=Math.abs(C-u),M+=Math.abs(C-d)),g=r[e]?u=p:g<=r[e]&&(u=g)),u!==a&&(l=!0,h=!0,s[e].column=u)}return this.Eh(t,s),this.vy(),l}k3(){for(let t=0;t<=this.Wt;t++)for(;this.S3(t,1););this.vy()}S3(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"packAux:column"),Util.r(i,LayeredDigraphLayout,"packAux:direction"));let e=!0;const s=this.network.vertexes.iterator;for(;s.next();){const o=s.value,r=this.nodeMinColumnSpace(o,!0),l=this.nodeMinColumnSpace(o,!1);if(o.column-r<=t&&o.column+l>=t){e=!1;break}}let n=!1;if(e){if(i>0)for(s.reset();s.next();){const o=s.value;o.column>t&&(o.column-=1,n=!0)}if(i<0)for(s.reset();s.next();){const o=s.value;o.column0&&(e=t+1),i<0&&(e=t-1);let s=0;const n=[],o=[];for(s=0;s<=this.Lt;s++)n[s]=!1,o[s]=!1;const r=this.network.vertexes.iterator;for(;r.next();){const a=r.value,f=a.column-this.nodeMinColumnSpace(a,!0),c=a.column+this.nodeMinColumnSpace(a,!1);f<=t&&c>=t&&(n[a.layer]=!0),f<=e&&c>=e&&(o[a.layer]=!0)}let l=!0,h=!1;for(s=0;s<=this.Lt;s++)l=l&&!(n[s]&&o[s]);if(l){if(i>0)for(r.reset();r.next();){const a=r.value;a.column>t&&(a.column-=1,h=!0)}if(i<0)for(r.reset();r.next();){const a=r.value;a.column0)for(i=0;i<=this.Wt;i++)for(e=this.te(),s=this.ok(!0),n=s+1;ss?this.es(e):o=0;i--)for(e=this.te(),s=this.ok(!0),n=s+1;ss?this.es(e):o0)for(e.reset();e.next();){const f=e.value;f.column-this.nodeMinColumnSpace(f,!0)<=t&&(f.component=this.on)}if(i<0)for(e.reset();e.next();){const f=e.value;f.column+this.nodeMinColumnSpace(f,!1)>=t&&(f.component=this.on)}for(this.on++,e.reset();e.next();){const f=e.value;f.component===-1&&(this.qN(f,this.on,-1,!0,!0),this.on++)}let s=0;const n=[];for(s=0;s0)for(let c=0;c0;c--)o[f*(this.Wt+1)+c]!==-1&&o[f*(this.Wt+1)+c-1]!==-1&&o[f*(this.Wt+1)+c]!==o[f*(this.Wt+1)+c-1]&&(n[o[f*(this.Wt+1)+c]*this.on+o[f*(this.Wt+1)+c-1]]=!0)}const r=[];for(s=0;s0)for(e.reset();e.next();){const f=e.value;r[f.component]&&(f.column-=1,a=!0)}if(i<0)for(e.reset();e.next();){const f=e.value;r[f.component]&&(f.column+=1,a=!0)}return a}x3(){const t=Util.ft(),i=this.iu.length;for(let u=0;u<=i;u++)t[u]=[];const e=this.network.vertexes.iterator;for(;e.next();){const u=e.value,d=i-u.layer,m=t[d];m[u.index]=u}const s=new GSet;this.N3(t,s);let n=null,o=null,r=null,l=null;const h=(this.zn&1)!==0,a=(this.zn&2)!==0,f=(this.zn&4)!==0,c=(this.zn&8)!==0;h&&(this.hl(t,s,!0),n=this.ak(t,!0,!1)),t.reverse(),f&&(this.hl(t,s,!1),r=this.ak(t,!1,!1));for(const u of t)u.reverse();c&&(this.hl(t,s,!1),l=this.ak(t,!1,!0)),t.reverse(),a&&(this.hl(t,s,!0),o=this.ak(t,!0,!0)),Util.nt(t),this.C3(n,o,r,l),this.network.vertexes.each(u=>{const d=u,m=Util.ft();h&&m.push(n.get(d)),a&&m.push(o.get(d)),f&&m.push(r.get(d)),c&&m.push(l.get(d)),m.sort((k,b)=>k-b);const g=m.length,p=Math.floor((g-1)/2),y=Math.ceil((g-1)/2),x=(m[p]+m[y])/2;Util.nt(m),d.ue=x})}N3(t,i){const e=t.length;for(let s=1;sc)&&i.add(m)}o++}n=c}}}}A3(t){if(t.node===null){const i=t.getProperSourceVertexes();if(i.length>0)return i[0].node===null}return!1}hl(t,i,e){this.L3(t);for(const s of t){let n=-1;for(const o of s){const r=e?o.getProperSourceVertexes():o.getProperDestinationVertexes(),l=r.length;if(l>0){r.sort((a,f)=>a.Vh-f.Vh);const h=(l-1)/2;for(let a=Math.floor(h),f=Math.ceil(h);a<=f;a++)if(o.Xn===o){const c=r[a];let u;e?u=c.getDestinationEdge(o):u=o.getDestinationEdge(c),!i.has(u)&&n0){const f=this.bD(a,t),c=s?f.width:f.height,u=a.ss.su+a.ue+a.Yn-(f.ue+f.Yn+c+this.columnSpacing);f.ss.su=Math.min(f.ss.su,u)}h=a.Vh+1}while(l0){const s=this.bD(e,i),n=s.nf;this.xD(n,i),t.ss===t&&(t.ss=n.ss);const o=this.C===90||this.C===270?s.width:s.height;if(t.ss===n.ss){const r=n.ue+s.Yn+o-e.Yn+this.columnSpacing;t.ue=Math.max(t.ue,r)}}e=e.Xn}while(e!==t);for(;e.Xn!==t;)e=e.Xn,e.ue=t.ue,e.ss=t.ss}bD(t,i){const e=t.wD,s=t.Vh;return s<1&&Util.n("Could not determine previous vertex in layer"),i[e][s-1]}C3(...t){let i=-1;const e=Util.ft(),s=Util.ft();let n=1/0;for(let o=0;o<4;o++){if(!t[o])continue;const r=this.D3(t[o],e,s,o);r{r.set(h.key,h.value+l)})}Util.nt(e),Util.nt(s)}D3(t,i,e,s){if(!t||t.count===0)return i[s]=0,e[s]=0,1/0;let n=1/0,o=-1/0;return t.each(r=>{const l=r.key,h=r.value,a=this.C===90||this.C===270?l.width:l.height;ho&&(o=h+a)}),i[s]=n,e[s]=o,o-n}commitLayout(){this.jy(),this.commitNodes(),this.vN(),this.isRouting&&this.commitLinks()}jy(){if(!this.setsPortSpots)return;const t=this.lk(!0),i=this.lk(!1),e=this.network.edges.iterator;for(;e.next();){const n=e.value.link;n!==null&&(n.fromSpot=t,n.toSpot=i)}}lk(t){return this.C===270?t?Spot.MiddleTop:Spot.MiddleBottom:this.C===90?t?Spot.MiddleBottom:Spot.MiddleTop:this.C===180?t?Spot.MiddleLeft:Spot.MiddleRight:t?Spot.MiddleRight:Spot.MiddleLeft}commitNodes(){this.nn=[],this.Ts=[],this.Ds=[],this.Gt=[];for(let d=0;d<=this.Lt;d++)this.nn[d]=0,this.Ts[d]=0,this.Ds[d]=0,this.Gt[d]=0;const t=this.network.vertexes.iterator;for(;t.next();){const d=t.value,m=d.layer;this.nn[m]=Math.max(this.nn[m],this.nodeMinLayerSpace(d,!0)),this.Ts[m]=Math.max(this.Ts[m],this.nodeMinLayerSpace(d,!1))}let i=0;const e=this.As;for(let d=0;d<=this.Lt;d++){let m=e;this.nn[d]+this.Ts[d]<=0&&(m=0),d>0&&(i+=m/2),this.C===90||this.C===0?(i+=this.Ts[d],this.Ds[d]=i,i+=this.nn[d]):(i+=this.nn[d],this.Ds[d]=i,i+=this.Ts[d]),d=0;n--)this.C===270?n===0?e.push(new Rect(0,0,s,Math.abs(this.Gt[0]))):e.push(new Rect(0,this.Gt[n-1],s,Math.abs(this.Gt[n-1]-this.Gt[n]))):this.C===90?n===0?e.push(new Rect(0,this.Gt[0],s,Math.abs(this.Gt[0]-t))):e.push(new Rect(0,this.Gt[n],s,Math.abs(this.Gt[n-1]-this.Gt[n]))):this.C===180?n===0?e.push(new Rect(0,0,Math.abs(this.Gt[0]),s)):e.push(new Rect(this.Gt[n-1],0,Math.abs(this.Gt[n-1]-this.Gt[n]),s)):n===0?e.push(new Rect(this.Gt[0],0,Math.abs(this.Gt[0]-t),s)):e.push(new Rect(this.Gt[n],0,Math.abs(this.Gt[n-1]-this.Gt[n]),s));this.commitLayers(e,this.fr)}commitLayers(t,i){}commitLinks(){const t=this.network.edges.iterator;let i;for(;t.next();)i=t.value.link,i!==null&&(i.startRoute(),i.clearPoints(),i.commitRoute());for(t.reset();t.next();)i=t.value.link,i!==null&&i.updateRoute();for(t.reset();t.next();){const e=t.value;if(i=e.link,i===null||i.pointsCount===0)continue;i.startRoute();const s=i;let n=s.fromNode,o=s.toNode,r=s.fromPort,l=s.toPort;if(n!==null){const N=n.findVisibleNode();N!==null&&N!==n&&(n=N,r=N.port)}if(o!==null){const N=o.findVisibleNode();N!==null&&N!==o&&(o=N,l=N.port)}const h=i.computeSpot(!0,r),a=i.computeSpot(!1,l);let f=e.fromVertex,c=e.toVertex;if(e.valid){if(i.curve===9&&i.pointsCount===4)if(f.column===c.column&&this.alignOption===0){const N=i.getLinkPoint(n,r,h,!0,!1,o,l),T=i.getLinkPoint(o,l,a,!1,!1,n,r);N.isReal()||N.set(n.actualBounds.center),T.isReal()||T.set(o.actualBounds.center),i.clearPoints(),i.addPointAt(N.x,N.y),i.addPointAt((2*N.x+T.x)/3,(2*N.y+T.y)/3),i.addPointAt((N.x+2*T.x)/3,(N.y+2*T.y)/3),i.addPointAt(T.x,T.y)}else{let N=!1,T=!1;if(r!==null&&h===Spot.None&&(N=!0),l!==null&&a===Spot.None&&(T=!0),N||T){let L=null;N&&(L=i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0),L.isReal()||L.set(n.actualBounds.center),i.setPointAt(0,L.x,L.y));let D=null;if(T&&(D=i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(0),!1),D.isReal()||D.set(o.actualBounds.center),i.setPointAt(3,D.x,D.y)),L){const F=i.getPoint(2);i.setPointAt(1,(L.x*2+F.x)/3,(L.y*2+F.y)/3)}if(D){const F=i.getPoint(1);i.setPointAt(2,(D.x*2+F.x)/3,(D.y*2+F.y)/3)}}}i.commitRoute();continue}if(f.layer===c.layer){i.commitRoute();continue}let u=!1,d=!1;const m=this.As;let g=0,p=i.firstPickIndex+1;if(i.isOrthogonal)d=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3);else if(i.curve===9)u=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3),g===4&&(p=2);else{g=i.pointsCount;const N=h===Spot.None,T=a===Spot.None;g>2&&N&&T?i.points.removeRange(1,g-2):g>3&&N&&!T?i.points.removeRange(1,g-3):g>3&&!N&&T?i.points.removeRange(2,g-2):g>4&&!N&&!T&&i.points.removeRange(2,g-3)}let y,x,k=0,b=0,S=0,M=0,A=0,C=0,P=0;if(e.rev){let N=0;for(;c!==null&&f!==c;){y=null,x=null;const T=c.sourceEdges.iterator;for(;T.next();){const L=T.value;if(L.link===e.link&&(y=L.fromVertex,x=L.toVertex,y.node===null))break}if(y===null)break;if(y!==f)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=y.centerX,M=y.centerY,d)this.C===180||this.C===0?p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,k,M)):(x!==null?x.centerY:b)!==M&&(A=this.Gt[y.layer-1]+this.fr.x,i.insertPointAt(p++,A,b),i.insertPointAt(p++,A,M)):p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,S,b)):(x!==null?x.centerX:k)!==S&&(A=this.Gt[y.layer-1]+this.fr.y,i.insertPointAt(p++,k,A),i.insertPointAt(p++,S,A));else if(p===i.firstPickIndex+1)if(C=Math.max(10,this.nn[c.layer]),P=Math.max(10,this.Ts[c.layer]),u)this.C===180?S<=c.bounds.x?(N=c.bounds.x,i.insertPointAt(p++,N-C,M),i.insertPointAt(p++,N,M),i.insertPointAt(p++,N+P,M)):(i.insertPointAt(p++,S-C,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S+P,M)):this.C===90?M>=c.bounds.bottom?(N=c.bounds.y+c.bounds.height,i.insertPointAt(p++,S,N+P),i.insertPointAt(p++,S,N),i.insertPointAt(p++,S,N-C)):(i.insertPointAt(p++,S,M+P),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M-C)):this.C===270?M<=c.bounds.y?(N=c.bounds.y,i.insertPointAt(p++,S,N-C),i.insertPointAt(p++,S,N),i.insertPointAt(p++,S,N+P)):(i.insertPointAt(p++,S,M-C),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M+P)):this.C===0&&(S>=c.bounds.right?(N=c.bounds.x+c.bounds.width,i.insertPointAt(p++,N+P,M),i.insertPointAt(p++,N,M),i.insertPointAt(p++,N-C,M)):(i.insertPointAt(p++,S+P,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S-C,M)));else{i.insertPointAt(p++,k,b);let L=0;this.C===180||this.C===0?((this.C===180?S>=c.bounds.right:S<=c.bounds.x)&&(L=(this.C===0?-C:P)/2),i.insertPointAt(p++,k+L,M)):((this.C===270?M>=c.bounds.bottom:M<=c.bounds.y)&&(L=(this.C===90?-C:P)/2),i.insertPointAt(p++,S,b+L)),i.insertPointAt(p++,S,M)}else C=Math.max(10,this.nn[y.layer]),P=Math.max(10,this.Ts[y.layer]),u?this.C===180?(i.insertPointAt(p++,S-C-m,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S+P+m,M)):this.C===90?(i.insertPointAt(p++,S,M+P+m),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M-C-m)):this.C===270?(i.insertPointAt(p++,S,M-C-m),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M+P+m)):(i.insertPointAt(p++,S+P+m,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S-C-m,M)):(this.C===180||this.C===90||this.C,i.insertPointAt(p++,S,M));c=y}if(l===null||h!==Spot.None||d)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=i.getPoint(p).x,M=i.getPoint(p).y,d){const T=this.Ts[f.layer];let L=0;this.C===180||this.C===0?(L=b,L>=f.bounds.y&&L<=f.bounds.bottom&&(this.C===180?S>=f.bounds.x:S<=f.bounds.right)&&(N=f.centerX+(this.C===180?-T:T),L=f.bounds.x&&L<=f.bounds.right&&(this.C===270?M>=f.bounds.y:M<=f.bounds.bottom)&&(N=f.centerY+(this.C===270?-T:T),L=f.bounds.x?(N=f.bounds.x+f.bounds.width,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N+P,b)):this.C===90&&M<=f.bounds.bottom?(N=f.bounds.y,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N-C)):this.C===270&&M>=f.bounds.y?(N=f.bounds.y+f.bounds.height,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N+P)):this.C===0&&S<=f.bounds.right&&(N=f.bounds.x,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N-C,b));else{C=Math.max(10,this.nn[f.layer]),P=Math.max(10,this.Ts[f.layer]);let T=0;this.C===180||this.C===0?((this.C===180?S<=f.bounds.x:S>=f.bounds.right)&&(T=(this.C===0?P:-C)/2),i.insertPointAt(p++,S+T,b)):((this.C===270?M<=f.bounds.y:M>=f.bounds.bottom)&&(T=(this.C===90?P:-C)/2),i.insertPointAt(p++,k,M+T)),i.insertPointAt(p++,S,M)}}else{for(;f!==null&&f!==c;){y=null,x=null;const N=f.destinationEdges.iterator;for(;N.next();){const T=N.value;if(T.link===e.link&&(y=T.toVertex,x=T.fromVertex,x.node!==null&&(x=null),y.node===null))break}if(y===null)break;y!==c&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=y.centerX,M=y.centerY,d?this.C===180||this.C===0?(x!==null?x.centerY:b)!==M&&(A=this.Gt[y.layer]+this.fr.x,p===i.firstPickIndex+1&&(this.C===0?A=Math.max(A,k):A=Math.min(A,k)),i.insertPointAt(p++,A,b),i.insertPointAt(p++,A,M)):(x!==null?x.centerX:k)!==S&&(A=this.Gt[y.layer]+this.fr.y,p===i.firstPickIndex+1&&(this.C===90?A=Math.max(A,b):A=Math.min(A,b)),i.insertPointAt(p++,k,A),i.insertPointAt(p++,S,A)):(C=Math.max(10,this.nn[y.layer]),P=Math.max(10,this.Ts[y.layer]),u?this.C===180?(i.insertPointAt(p++,S+P+m,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S-C-m,M)):this.C===90?(i.insertPointAt(p++,S,M-C-m),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M+P+m)):this.C===270?(i.insertPointAt(p++,S,M+P+m),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M-C-m)):(i.insertPointAt(p++,S-C-m,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S+P+m,M)):this.C===180?(i.insertPointAt(p++,S+P,M),i.insertPointAt(p++,S-C,M)):this.C===90?(i.insertPointAt(p++,S,M-C),i.insertPointAt(p++,S,M+P)):this.C===270?(i.insertPointAt(p++,S,M+P),i.insertPointAt(p++,S,M-C)):(i.insertPointAt(p++,S-C,M),i.insertPointAt(p++,S+P,M)))),f=y}d&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=i.getPoint(p).x,M=i.getPoint(p).y,this.C===180||this.C===0?b!==M&&(this.C===0?A=Math.min(Math.max((S+k)/2,this.Gt[c.layer]+this.fr.x),S):A=Math.max(Math.min((S+k)/2,this.Gt[c.layer]+this.fr.x),S),i.insertPointAt(p++,A,b),i.insertPointAt(p++,A,M)):k!==S&&(this.C===90?A=Math.min(Math.max((M+b)/2,this.Gt[c.layer]+this.fr.y),M):A=Math.max(Math.min((M+b)/2,this.Gt[c.layer]+this.fr.y),M),i.insertPointAt(p++,k,A),i.insertPointAt(p++,S,A)))}if(s!==null&&u&&i.pointsCount>=4){if(r!==null){const N=h===Spot.None?i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0):i.getPoint(0);if(h===Spot.None){const T=i.getPoint(2),L=i.getPoint(3);this.direction===90||this.direction===270?(i.setPointAt(1,(N.x+T.x)/2,T.y),i.setPointAt(2,L.x,(T.y+L.y)/2)):(i.setPointAt(1,T.x,(N.y+T.y)/2),i.setPointAt(2,(T.x+L.x)/2,L.y))}N.isReal()||N.set(n.actualBounds.center),i.setPointAt(0,N.x,N.y)}if(l!==null){const N=a===Spot.None?i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(i.pointsCount-4),!1):i.getPoint(i.pointsCount-1);if(a===Spot.None){const T=i.getPoint(i.pointsCount-3),L=i.getPoint(i.pointsCount-4);this.direction===90||this.direction===270?(i.setPointAt(i.pointsCount-2,(N.x+T.x)/2,T.y),i.setPointAt(i.pointsCount-2,L.x,(T.y+L.y)/2)):(i.setPointAt(i.pointsCount-2,T.x,(N.y+T.y)/2),i.setPointAt(i.pointsCount-3,(T.x+L.x)/2,L.y))}N.isReal()||N.set(o.actualBounds.center),i.setPointAt(i.pointsCount-1,N.x,N.y)}}i.commitRoute(),e.commit()}}QO(){this.Wy=-1,this.Og=0,this.Ls=0,this.sf=null,this.Vg=null,this.iu=null;for(let t=0;t=this.Bn.length){const n=[];for(let o=0;o=0&&(this.As=t,this.invalidateLayout()))}get columnSpacing(){return this._i}set columnSpacing(t){this._i!==t&&(Util.t(t,"number",LayeredDigraphLayout,"columnSpacing"),t>0&&(this._i=t,this.invalidateLayout()))}get direction(){return this.C}set direction(t){this.C!==t&&(Util.t(t,"number",LayeredDigraphLayout,"direction"),t===0||t===90||t===180||t===270?(this.C=t,this.invalidateLayout()):Util.n("LayeredDigraphLayout.direction must be 0, 90, 180, or 270"))}get cycleRemoveOption(){return this.Zc}set cycleRemoveOption(t){this.Zc!==t&&(Util.tt(t,LayeredDigraphCycleRemove,"LayeredDigraphCycleRemove"),(t===1||t===0||t===2)&&(this.Zc=t,this.invalidateLayout()))}get layeringOption(){return this.$c}set layeringOption(t){this.$c!==t&&(Util.tt(t,LayeredDigraphLayering,"LayeredDigraphLayering"),(t===10||t===11||t===12)&&(this.$c=t,this.invalidateLayout()))}get initializeOption(){return this.Qc}set initializeOption(t){this.Qc!==t&&(Util.tt(t,LayeredDigraphInit,"LayeredDigraphInit"),(t===20||t===21||t===22)&&(this.Qc=t,this.invalidateLayout()))}get iterations(){return this.ef}set iterations(t){this.ef!==t&&(Util.r(t,LayeredDigraphNetwork,"iterations"),t>=0&&(this.ef=t,this.invalidateLayout()))}get aggressiveOption(){return this._c}set aggressiveOption(t){this._c!==t&&(Util.tt(t,LayeredDigraphAggressive,"LayeredDigraphAggressive"),(t===30||t===31||t===32)&&(this._c=t,this.invalidateLayout()))}get packOption(){return this.ar}set packOption(t){this.ar!==t&&(Util.t(t,"number",LayeredDigraphLayout,"packOption"),t>=0&&t<8&&(this.ar=t,this.invalidateLayout()))}get packIterations(){return this.tu}set packIterations(t){this.tu=t}get alignOption(){return this.zn}set alignOption(t){this.zn!==t&&(Util.t(t,"number",LayeredDigraphLayout,"align"),t>=0&&t<16&&(this.zn=t,this.invalidateLayout()))}get setsPortSpots(){return this.Vn}set setsPortSpots(t){this.Vn!==t&&(Util.t(t,"boolean",LayeredDigraphLayout,"setsPortSpots"),this.Vn=t,this.invalidateLayout())}get maxLayer(){return this.Lt}get maxIndex(){return this.Wy}get maxColumn(){return this.Wt}get minIndexLayer(){return this.Og}get maxIndexLayer(){return this.Ls}static CycleDepthFirst=0;static CycleGreedy=1;static CycleFromLayers=2;static LayerOptimalLinkLength=10;static LayerLongestPathSink=11;static LayerLongestPathSource=12;static InitDepthFirstOut=20;static InitDepthFirstIn=21;static InitNaive=22;static AggressiveNone=30;static AggressiveLess=31;static AggressiveMore=32;static PackNone=0;static PackExpand=1;static PackStraighten=2;static PackMedian=4;static PackAll=15;static AlignNone=0;static AlignUpperLeft=1;static AlignUpperRight=2;static AlignLowerLeft=4;static AlignLowerRight=8;static AlignAll=15}class SegInfo{_o;F3;b1;R3;I3;Vt;$e;O3;constructor(){this._o=0,this.F3=0,this.b1=0,this.R3=0,this.I3=0,this.Vt=0,this.$e=null,this.O3=0}}class LayeredDigraphNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new LayeredDigraphVertex(this)}createEdge(){return new LayeredDigraphEdge(this)}}class LayeredDigraphVertex extends LayoutVertex{_o;Go;Vt;fk;ck;ie;eu;$n;rk;sk;nk;nf;Xn;wD;Vh;ss;su;ue;Yn;$y=null;Qy=null;_y=null;tw=null;constructor(t){super(t),this._o=-1,this.Go=-1,this.Vt=-1,this.fk=NaN,this.ck=null,this.ie=!1,this.eu=NaN,this.$n=NaN,this.rk=0,this.sk=null,this.nk=null}static kD(t,i){return t.index-i.index}getProperSourceEdges(){if(!this._y){const t=[];for(const i of this.So){const e=i;e.valid&&t.push(e)}this._y=t}return this._y}getProperDestinationEdges(){if(!this.tw){const t=[];for(const i of this.rr){const e=i;e.valid&&t.push(e)}this.tw=t}return this.tw}getDestinationEdge(t){const i=this.getProperDestinationEdges();for(const e of i)if(e.toVertex===t)return e;Util.n("Unable to find destination edge to given vertex")}getProperSourceVertexes(){if(!this.$y){const t=[];for(const i of this.So){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.fromVertex)}t.sort(LayeredDigraphVertex.kD),this.$y=t}return this.$y}getProperDestinationVertexes(){if(!this.Qy){const t=[];for(const i of this.rr){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.toVertex)}t.sort(LayeredDigraphVertex.kD),this.Qy=t}return this.Qy}addSourceEdge(t){super.addSourceEdge(t),this.$y=null,this._y=null}deleteSourceEdge(t){super.deleteSourceEdge(t),this.$y=null,this._y=null}addDestinationEdge(t){super.addDestinationEdge(t),this.Qy=null,this.tw=null}deleteDestinationEdge(t){super.deleteDestinationEdge(t),this.Qy=null,this.tw=null}get layer(){return this._o}set layer(t){this._o!==t&&(Util.t(t,"number",LayeredDigraphVertex,"layer"),this._o=t)}get column(){return this.Go}set column(t){this.Go!==t&&(Util.t(t,"number",LayeredDigraphVertex,"column"),this.Go=t)}get index(){return this.Vt}set index(t){this.Vt!==t&&(Util.t(t,"number",LayeredDigraphVertex,"index"),this.Vt=t)}get component(){return this.fk}set component(t){this.fk!==t&&(Util.t(t,"number",LayeredDigraphVertex,"component"),this.fk=t)}get near(){return this.ck}set near(t){this.ck!==t&&(Debug&&t!==null&&Util.s(t,LayeredDigraphVertex,LayeredDigraphVertex,"near"),this.ck=t)}}class LayeredDigraphEdge extends LayoutEdge{ie;uk;dk;gk;mk;pk;yk;constructor(t){super(t),this.ie=!1,this.uk=!1,this.dk=!1,this.gk=NaN,this.mk=NaN,this.pk=0,this.yk=0}get fromVertex(){return this._e}set fromVertex(t){this._e!==t&&(Debug&&t!==null&&Util.s(t,LayeredDigraphVertex,LayeredDigraphEdge,"fromVertex"),this._e=t)}get toVertex(){return this.ts}set toVertex(t){this.ts!==t&&(Debug&&t!==null&&Util.s(t,LayeredDigraphVertex,LayeredDigraphEdge,"toVertex"),this.ts=t)}get valid(){return this.ie}set valid(t){this.ie!==t&&(Util.t(t,"boolean",LayeredDigraphEdge,"valid"),this.ie=t)}get rev(){return this.uk}set rev(t){this.uk!==t&&(Util.t(t,"boolean",LayeredDigraphEdge,"rev"),this.uk=t)}get forest(){return this.dk}set forest(t){this.dk!==t&&(Util.t(t,"boolean",LayeredDigraphEdge,"forest"),this.dk=t)}get portFromPos(){return this.gk}set portFromPos(t){this.gk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portFromPos"),this.gk=t)}get portToPos(){return this.mk}set portToPos(t){this.mk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portToPos"),this.mk=t)}get portFromColOffset(){return this.pk}set portFromColOffset(t){this.pk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portFromColOffset"),this.pk=t)}get portToColOffset(){return this.yk}set portToColOffset(t){this.yk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portToColOffset"),this.yk=t)}}var TreePath=(w=>(w[w.Default=0]="Default",w[w.Destination=1]="Destination",w[w.Source=2]="Source",w))(TreePath||{}),TreeSorting=(w=>(w[w.Forwards=10]="Forwards",w[w.Reverse=11]="Reverse",w[w.Ascending=12]="Ascending",w[w.Descending=13]="Descending",w))(TreeSorting||{}),TreeAlignment=(w=>(w[w.CenterSubtrees=20]="CenterSubtrees",w[w.CenterChildren=21]="CenterChildren",w[w.Start=22]="Start",w[w.End=23]="End",w[w.Bus=24]="Bus",w[w.BusBranching=25]="BusBranching",w[w.TopLeftBus=26]="TopLeftBus",w[w.BottomRightBus=27]="BottomRightBus",w[w.Custom=28]="Custom",w))(TreeAlignment||{}),TreeCompaction=(w=>(w[w.None=30]="None",w[w.Block=31]="Block",w))(TreeCompaction||{}),TreeStyle=(w=>(w[w.Layered=40]="Layered",w[w.LastParents=41]="LastParents",w[w.Alternating=42]="Alternating",w[w.RootOnly=43]="RootOnly",w))(TreeStyle||{}),TreeArrangement=(w=>(w[w.Vertical=50]="Vertical",w[w.Horizontal=51]="Horizontal",w[w.FixedRoots=52]="FixedRoots",w))(TreeArrangement||{}),TreeLayerStyle=(w=>(w[w.Individual=60]="Individual",w[w.Siblings=61]="Siblings",w[w.Uniform=62]="Uniform",w))(TreeLayerStyle||{});class TreeLayout extends Layout{Ei;Ii;nu;zg;JN;Be;qi;Cs;K;U;wk;ds;constructor(t){super(),this.Ei=new GSet,this.Ii=0,this.ds=1,this.nu=40,this.zg=60,this.JN=[],this.Be=!0,this.qi=50,this.Cs=new Size(10,10).w();const i=new TreeNetwork(this);this.K=new TreeVertex(i),this.U=new TreeVertex(i),this.wk=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Ii=this.Ii,t.nu=this.nu,t.zg=this.zg,t.Be=this.Be,t.qi=this.qi,t.Cs.c(this.Cs),t.K.copyInheritedPropertiesFrom(this.K),t.U.copyInheritedPropertiesFrom(this.U)}fi(t){t in TreeAlignment?this.alignment=t:t in TreeArrangement?this.arrangement=t:t in TreeCompaction?this.compaction=t:t in TreePath?this.path=t:t in TreeSorting?this.sorting=t:t in TreeStyle?this.treeStyle=t:super.fi(t)}createNetwork(){return new TreeNetwork(this)}makeNetwork(t){const i=this.createNetwork(),e=s=>{if(s instanceof Node)return!s.isLinkLabel&&s.category!=="Comment";if(s instanceof Link){const n=s.fromNode;if(n===null||n.isLinkLabel||n.category==="Comment")return!1;const o=s.toNode;return!(o===null||o.isLinkLabel||o.category==="Comment")}return!1};return t instanceof Diagram?(i.addParts(t.nodes,!0,e),i.addParts(t.links,!0,e)):t instanceof Group?i.addParts(t.memberParts,!1,e):i.addParts(t.iterator,!1,e),i}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.network===null&&(this.network=this.makeNetwork(t)),this.arrangement!==52&&(this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin));let i=this.diagram;i===null&&t instanceof Diagram&&(i=t),this.path===0&&i!==null?this.ds=i.isTreePathToChildren?1:2:this.ds=this.path===0?1:this.path,this.network.vertexes.count>0&&(this.E3(),this.V3(),this.B3(),this.z3(),this.UN(),this.X3(),this.arrangeTrees(),this.updateParts()),this.network=null,this.Ei=new GSet,this.isValidLayout=!0}E3(){this.network.deleteSelfEdges();const t=this.network.vertexes.iterator;for(;t.next();){const n=t.value;n.initialized=!1,n.level=0,n.parent=null,n.children=[]}if(this.Ei.count>0){const n=new GSet,o=this.Ei.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=this.network.findVertex(r);l!==null&&n.add(l)}else r instanceof TreeVertex&&n.add(r)}this.Ei=n}this.Ei.count===0&&this.findRoots();const i=this.Ei.copy().iterator;for(;i.next();){const n=i.value;n.initialized||(n.initialized=!0,this.ZN(n))}let e=this.network.vertexes,s=null;for(;s=this.Y3(e),s.count>0;){const n=this.SD(s);n!==null&&this.Ei.add(n),n.initialized=!0,this.ZN(n),e=s}}Y3(t){const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;s.initialized||i.add(s)}return i}findRoots(){const t=this.network.vertexes,i=t.iterator;for(;i.next();){const e=i.value;switch(this.ds){case 1:e.sourceEdges.count===0&&this.Ei.add(e);break;case 2:e.destinationEdges.count===0&&this.Ei.add(e);break;default:Util.n("Unhandled path value "+this.ds.toString())}}if(this.Ei.count===0){const e=this.SD(t);e!==null&&this.Ei.add(e)}}SD(t){let i=999999,e=null;const s=t.iterator;for(;s.next();){const n=s.value;switch(this.ds){case 1:n.sourceEdges.count0){const s=new List,n=t.destinationVertexes;for(;n.next();){const o=n.value;this.MD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;case 2:if(t.sourceEdges.count>0){const s=new List,n=t.sourceVertexes;for(;n.next();){const o=n.value;this.MD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;default:Util.n("Unhandled path value"+this.ds.toString())}const i=t.children,e=i.length;for(let s=0;st.level?!1:(this.U3(i.parent,i),!0):!0}K3(t,i){if(i===null)return!1;Debug&&Util.s(t,TreeVertex,TreeLayout,"isAncestor:a"),Debug&&Util.s(i,TreeVertex,TreeLayout,"isAncestor:b");let e=i.parent;for(;e!==null&&e!==t;)e=e.parent;return e===t}U3(t,i){if(t===null||i===null)return;Debug&&Util.s(t,TreeVertex,TreeLayout,"removeChild:p"),Debug&&Util.s(i,TreeVertex,TreeLayout,"removeChild:c");const e=t.children;let s=0;for(let n=0;n0){const n=new Array(e.length-s);let o=0;for(let r=0;r0?s+1:0}G3(t){switch(Debug&&Util.s(t,TreeVertex,TreeLayout,"mom:v"),this.nu){default:case 40:return t.parent!==null?t.parent:this.K;case 43:return t.parent===null?this.K:t.parent.parent===null?this.U:t.parent;case 42:return t.parent!==null?t.parent.parent!==null?t.parent.parent:this.U:this.K;case 41:{let i=!0;if(t.childrenCount===0)i=!1;else{const e=t.children,s=e.length;for(let n=0;n0){i=!1;break}}return i&&t.parent!==null?this.U:t.parent!==null?t.parent:this.K}}}initializeTreeVertexValues(t){Debug&&Util.s(t,TreeVertex,TreeLayout,"initializeTreeVertexValues:v");const i=this.G3(t);if(t.copyInheritedPropertiesFrom(i),t.parent!==null&&t.parent.alignment===25){let e=t.angle;const s=t.parent.children;let n=0;for(;n135&&!l||a&&c)if(t.commentMargin>=0){g.e(t.bounds.x-t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleLeft,S.toSpot=Spot.MiddleRight}}else{g.e(t.bounds.x+t.focus.x*2-t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleRight,S.toSpot=Spot.MiddleLeft}}else if(t.commentMargin>=0){g.e(t.bounds.x+t.focus.x*2+t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleRight,S.toSpot=Spot.MiddleLeft}}else{g.e(t.bounds.x+t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleLeft,S.toSpot=Spot.MiddleRight}}t.commentSpacing>=0?u+=k.height+t.commentSpacing:u+=t.commentSpacing-k.height}else{if(o>135&&!l||!a&&c)if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y-t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleTop,S.toSpot=Spot.MiddleBottom}}else{g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2-t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleBottom,S.toSpot=Spot.MiddleTop}}else if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2+t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleBottom,S.toSpot=Spot.MiddleTop}}else{g.e(t.bounds.x+u,t.bounds.y+t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleTop,S.toSpot=Spot.MiddleBottom}}t.commentSpacing>=0?u+=k.width+t.commentSpacing:u+=t.commentSpacing-k.width}}Point.o(g);const p=u-t.commentSpacing-(h?e.height:e.width);if(this.ds===1){const y=t.destinationEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.fromEndSegmentLength=p>0?p:NaN)}}else{const y=t.sourceEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.toEndSegmentLength=p>0?p:NaN)}}}}X3(){if(this.layerStyle===62){const i=[];let e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;let n=s.parent;n===null&&(n=s);const o=n.angle===0||n.angle===180;let r=i[s.level];r===void 0&&(r=0),i[s.level]=Math.max(r,o?s.width:s.height)}for(let s=0;s=0)for(let o=0;o135&&n.reverse(),this.iw(r))if(o>1)for(let R=0;R0&&P>0&&M+u+O.width>f&&(M135?-b-g:b+g);const B=P===0?m:u;this.xk(I,0,A),I.X.e(M+B,A),k=Math.max(k,M+B+O.width),b=Math.max(b,S+(C===0?0:g)+O.height),M+=B+O.width}else{f>0&&P>0&&A+u+O.height>f&&(A135?-k-g:k+g);const B=P===0?m:u;this.xk(I,M,0),I.X.e(M,A+B),b=Math.max(b,A+B+O.height),k=Math.max(k,S+(C===0?0:g)+O.width),A+=B+O.height}P++}C>0&&(e?(b+=Math.max(0,c),M0&&(h||this.lu(t,p,0,0,o-1),k+=p)):(k+=Math.max(0,c),A0&&(h||this.lu(t,0,p,0,o-1),b+=p)));let D=0,F=0;switch(r){case 20:e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;break;default:case 21:if(C>0)e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;else{const I=o;if(e){const O=n[0].X.x+n[0].rt.x,B=n[I-1].X.x+n[I-1].rt.x+n[I-1].focus.x*2;D+=O+(B-O)/2-t.focus.x-d/2}else{const O=n[0].X.y+n[0].rt.y,B=n[I-1].X.y+n[I-1].rt.y+n[I-1].focus.y*2;F+=O+(B-O)/2-t.focus.y-d/2}}break;case 22:e?(D-=d,k+=d):(F-=d,b+=d);break;case 23:e?(D+=k-t.width+d,k+=d):(F+=b-t.height+d,b+=d);break;case 24:case 25:e?o>1?D+=T+u/2-t.focus.x:D+=n[0].focus.x-t.focus.x+n[0].rt.x:o>1?F+=T+u/2-t.focus.y:F+=n[0].focus.y-t.focus.y+n[0].rt.y;break;case 26:e?D+=k+u/2-t.focus.x:F+=b+u/2-t.focus.y;break;case 27:break;case 28:const R=this.customAlignment(t,D,F,k,b);D=R[0],F=R[1],k=R[2],b=R[3];break}for(let R=0;R135?(a?-b:-I.kt.height)+I.rt.y-c:x+c+I.rt.y)):I.X.e(I.X.x+(i>135?(a?-k:-I.kt.width)+I.rt.x-c:y+c+I.rt.x),I.X.y+I.rt.y-F)}e?(k=this.QN(t,k,D),D<0&&(D=0),i>135&&(F+=b+c),b=Math.max(Math.max(b,x),b+x+c)):(i>135&&(D+=k+c),k=Math.max(Math.max(k,y),k+y+c),b=this._N(t,b,F),F<0&&(F=0)),t.rt.e(D,F),t.kt.e(k,b)}customAlignment(t,i,e,s,n){return[i,e,s,n]}LD(t,i,e,s,n,o){Debug&&Util.s(t,TreeVertex,TreeLayout,"layoutBusChildrenPosDir:v");const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.kt.width,o=p.kt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,f=this.orthoAngle(t)===90;let c=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.kt,k=c===0?0:h;if(f){const b=this.computeBusNodeSpacing(y)-l;y.X.e(e-(x.width+b),d+k),n=Math.max(n,x.width+b),o=Math.max(o,d+k+x.height),d+=k+x.height}else{const b=this.computeBusNodeSpacing(y)-l;y.X.e(u+k,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,u+k+x.width),u+=k+x.width}c++}c=0;const m=u,g=d;f?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.kt,x=this.computeBusLastRowSpacing(p,f?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(f){p.X.e(e+l/2-p.focus.x-p.rt.x,o+x);const k=e+l/2-p.focus.x-p.rt.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.max(g,d)+x+y.height),p.X.x<0&&(e=this.bk(t,p.X.x,!1,e,l))}else{p.X.e(n+x,e+l/2-p.focus.y-p.rt.y),n=Math.max(n,Math.max(m,u)+x+y.width);const k=e+l/2-p.focus.y-p.rt.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.X.y<0&&(e=this.bk(t,p.X.y,!0,e,l))}}return new Rect(e,0,n,o)}TD(t,i,e,s,n,o){Debug&&Util.s(t,TreeVertex,TreeLayout,"layoutBusChildrenNegDir:v");const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.kt.width,o=p.kt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,f=this.orthoAngle(t)===270;let c=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.kt,k=c===0?0:h;if(f){const b=this.computeBusNodeSpacing(y)-l;d-=k+x.height,y.X.e(e-(x.width+b),d),n=Math.max(n,x.width+b),o=Math.max(o,Math.abs(d))}else{const b=this.computeBusNodeSpacing(y)-l;u-=k+x.width,y.X.e(u,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,Math.abs(u))}c++}c=0;const m=u,g=d;f?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.kt,x=this.computeBusLastRowSpacing(p,f?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(f){p.X.e(e+l/2-p.focus.x-p.rt.x,-o-y.height-x);const k=e+l/2-p.focus.x-p.rt.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.abs(Math.min(g,d))+x+y.height),p.X.x<0&&(e=this.bk(t,p.X.x,!1,e,l))}else{p.X.e(-n-y.width-x,e+l/2-p.focus.y-p.rt.y),n=Math.max(n,Math.abs(Math.min(m,u))+x+y.width);const k=e+l/2-p.focus.y-p.rt.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.X.y<0&&(e=this.bk(t,p.X.y,!0,e,l))}}for(let p=0;ps&&(s=e+t.width),e<0&&(s-=e),s;case 22:return t.width>i?t.width:i;case 23:return t.focus.x*2>i?t.width:i+t.width-t.focus.x*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.width);return Math.max(t.width,o-n);case 26:return t.width-t.focus.x+t.nodeSpacing/2+i;case 27:return Math.max(t.width,t.focus.x+t.nodeSpacing/2+i);default:return i}}_N(t,i,e){switch(Debug&&Util.s(t,TreeVertex,TreeLayout,"calculateSubheight:v"),t.alignment){case 21:case 20:let s=i;return e+t.height>s&&(s=e+t.height),e<0&&(s-=e),s;case 22:return t.height>i?t.height:i;case 23:return t.focus.y*2>i?t.height:i+t.height-t.focus.y*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.height);return Math.max(t.height,o-n);case 26:return t.height-t.focus.y+t.nodeSpacing/2+i;case 27:return Math.max(t.height,t.focus.y+t.nodeSpacing/2+i);default:return i}}tC(t,i,e){switch(Debug&&Util.tt(t,TreeAlignment,"TreeAlignment"),t){case 20:i/=2,e/=2;break;case 21:i/=2,e/=2;break;case 22:i=0,e=0;break;case 23:break;default:Util.n("Unhandled alignment value "+t.toString())}return new Point(i,e)}of(t,i,e,s,n,o){Debug&&Util.s(t,TreeVertex,TreeLayout,"shiftRelPosAlign:v"),Debug&&Util.tt(i,TreeAlignment,"TreeAlignment");const r=this.tC(i,e,s);this.lu(t,r.x,r.y,n,o)}lu(t,i,e,s,n){if(Debug&&Util.s(t,TreeVertex,TreeLayout,"shiftRelPos:v"),i===0&&e===0)return;const o=t.children;for(let r=s;r<=n;r++){const h=o[r].X;h.x+=i,h.y+=e}}xk(t,i,e){Debug&&(Util.s(t,TreeVertex,TreeLayout,"recordMidPoints:v"),Util.t(i,"number",TreeLayout,"recordMidPoints:x"),Util.t(e,"number",TreeLayout,"recordMidPoints:y"));const s=t.parent;switch(this.ds){case 1:{const n=t.sourceEdges;for(;n.next();){const o=n.value;o.fromVertex===s&&o.relativePoint.e(i,e)}break}case 2:{const n=t.destinationEdges;for(;n.next();){const o=n.value;o.toVertex===s&&o.relativePoint.e(i,e)}break}default:Util.n("Unhandled path value "+this.ds.toString())}}H3(t){if(Debug&&Util.s(t,TreeVertex,TreeLayout,"layoutTreeBlock:v"),t.childrenCount===0){const z=t.parent;let G=!1,q=0,j=21;z!==null&&(q=z.angle,j=z.alignment,G=this.isBusAlignment(j));const J=this.$N(t);t.X.e(0,0),t.kt.e(t.width,t.height),t.parent!==null&&t.comments!==null&&((q===180||q===270)&&!G||J)?q===180&&!G||(q===90||q===270)&&J?t.rt.e(t.width-t.focus.x*2,0):t.rt.e(0,t.height-t.focus.y*2):t.rt.e(0,0),t.Xg=null,t.Yg=null;return}const i=this.orthoAngle(t),e=i===90||i===270;let s=0;const n=t.children,o=n.length;for(let z=0;z135&&n.reverse(),this.iw(r))if(o>1)for(let z=0;z0&&L>0&&P+u+q.width>f&&(P135?-k-m:k+m),this.xk(G,0,N);let j=0;if(L===0)S=G.Xg,M=G.Yg,A=q.width,C=q.height,(S===null||M===null||i!==this.orthoAngle(G))&&(S=this.de(2),M=this.de(2),S[0].e(0,0),S[1].e(0,C),M[0].e(A,0),M[1].e(A,C));else{const J=Util.ft(),Y=this.DD(t,G,S,M,A,C,J);j=Y.x,S=J[0],M=J[1],A=Y.width,C=Y.height,Util.nt(J),P0&&L>0&&N+u+q.height>f&&(N135?-x-m:x+m),this.xk(G,P,0);let j=0;if(L===0)S=G.Xg,M=G.Yg,A=q.width,C=q.height,(S===null||M===null||i!==this.orthoAngle(G))&&(S=this.de(2),M=this.de(2),S[0].e(0,0),S[1].e(A,0),M[0].e(0,C),M[1].e(A,C));else{const J=Util.ft(),Y=this.DD(t,G,S,M,A,C,J);j=Y.x,S=J[0],M=J[1],A=Y.width,C=Y.height,Util.nt(J),N0&&(e?(k+=Math.max(0,c),P0&&(h||this.lu(t,g,0,0,o-1),x+=g)):(x+=Math.max(0,c),N0&&(h||this.lu(t,0,g,0,o-1),k+=g)));let I=0,O=0;switch(r){case 20:e?I+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;break;default:case 21:if(T>0)e?I+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;else{const G=o;if(e){const q=n[0].X.x+n[0].rt.x,j=n[G-1].X.x+n[G-1].rt.x+n[G-1].focus.x*2;I+=q+(j-q)/2-t.focus.x-d/2}else{const q=n[0].X.y+n[0].rt.y,j=n[G-1].X.y+n[G-1].rt.y+n[G-1].focus.y*2;O+=q+(j-q)/2-t.focus.y-d/2}}break;case 22:e?(I-=d,x+=d):(O-=d,k+=d);break;case 23:e?(I+=x-t.width+d,x+=d):(O+=k-t.height+d,k+=d);break;case 24:e?o>1?I+=F+u/2-t.focus.x:I+=n[0].focus.x-t.focus.x+n[0].rt.x:o>1?O+=F+u/2-t.focus.y:O+=n[0].focus.y-t.focus.y+n[0].rt.y;break;case 26:e?I+=x+u/2-t.focus.x:O+=k+u/2-t.focus.y;break;case 27:break;case 28:const z=this.customAlignment(t,I,O,x,k);I=z[0],O=z[1],x=z[2],k=z[3];break}for(let z=0;z135?(a?-k:-G.kt.height)+G.rt.y-c:y+c+G.rt.y)):G.X.e(G.X.x+(i>135?(a?-x:-G.kt.width)+G.rt.x-c:p+c+G.rt.x),G.X.y+G.rt.y-O)}let B=0,K=0;if(a)e?(x=this.QN(t,x,I),I<0&&(I=0),i>135&&(O+=k+c),k+=y+c,r===27&&(B+=u/2+t.focus.x),K+=y+c):(i>135&&(I+=x+c),x+=p+c,k=this._N(t,k,O),O<0&&(O=0),r===27&&(K+=u/2+t.focus.y),B+=p+c);else if(e){if(t.comments===null){if(p>x){const z=this.tC(r,p-x,0);B=z.x,K=z.y,x=p,I=0}}else x=this.QN(t,x,I);I<0&&(B-=I,I=0),i>135&&(O+=k+c),k=Math.max(Math.max(k,y),k+y+c),K+=y+c}else{if(i>135&&(I+=x+c),x=Math.max(Math.max(x,p),x+p+c),t.comments===null){if(y>k){const z=this.tC(r,0,y-k);B=z.x,K=z.y,k=y,O=0}}else k=this._N(t,k,O);O<0&&(K-=O,O=0),B+=p+c}let V,X;if(T>0)V=this.de(4),X=this.de(4),e?(V[2].e(0,y+c),V[3].e(V[2].x,k),X[2].e(x,V[2].y),X[3].e(X[2].x,V[3].y)):(V[2].e(p+c,0),V[3].e(x,V[2].y),X[2].e(V[2].x,k),X[3].e(V[3].x,X[2].y));else{V=this.de(S.length+2),X=this.de(M.length+2);for(let z=0;zV[0].x?V[2].c(V[1]):V[1].c(V[2])),V[3].yV[0].x?V[3].c(V[2]):V[2].c(V[3])),X[0].e(I+p,0),X[1].e(X[0].x,y),X[2].yV[0].y?V[2].c(V[1]):V[1].c(V[2])),V[3].xV[0].y?V[3].c(V[2]):V[2].c(V[3])),X[0].e(0,O+y),X[1].e(p,X[0].y),X[2].xl;){const a=i[o++];s[r++].e(a.x,a.y+e)}const h=this.de(r);for(n=0;nl;){const a=i[o++];s[r++].e(a.x+e,a.y)}const h=this.de(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.de(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.de(r);for(n=0;nh&&r.xr.x&&ha&&r.yr.y&&a0){const n=Math.min(1,t.layerSpacingParentOverlap);s-=e?t.height*n:t.width*n}return s<(e?-t.height:-t.width)&&(s=e?-t.height:-t.width),s}computeNodeIndent(t){Debug&&Util.s(t,TreeVertex,TreeLayout,"computeNodeIndent:v");const i=this.orthoAngle(t),e=i===90||i===270;let s=t.nodeIndent;if(t.nodeIndentPastParent>0){const n=Math.min(1,t.nodeIndentPastParent);s+=e?t.width*n:t.height*n}return s=Math.max(0,s),s}get roots(){return this.Ei}set roots(t){this.Ei!==t&&(Util.s(t,GSet,TreeLayout,"roots"),this.Ei=t,this.invalidateLayout())}get path(){return this.Ii}set path(t){this.Ii!==t&&(Util.tt(t,TreePath,"TreePath"),this.Ii=t,this.invalidateLayout())}get treeStyle(){return this.nu}set treeStyle(t){this.nu!==t&&(Util.tt(t,TreeStyle,"TreeStyle"),(t===40||t===42||t===41||t===43)&&(this.nu=t,this.invalidateLayout()))}get layerStyle(){return this.zg}set layerStyle(t){this.zg!==t&&(Util.tt(t,TreeLayerStyle,"TreeLayerStyle"),(t===60||t===61||t===62)&&(this.zg=t,this.invalidateLayout()))}get comments(){return this.Be}set comments(t){this.Be!==t&&(Util.t(t,"boolean",TreeLayout,"comments"),this.Be=t,this.invalidateLayout())}get arrangement(){return this.qi}set arrangement(t){this.qi!==t&&(Util.tt(t,TreeArrangement,"TreeArrangement"),(t===50||t===51||t===52)&&(this.qi=t,this.invalidateLayout()))}get arrangementSpacing(){return this.Cs}set arrangementSpacing(t){Util.s(t,Size,TreeLayout,"arrangementSpacing"),this.Cs.equals(t)||(this.Cs.c(t),this.invalidateLayout())}get rootDefaults(){return this.K}set rootDefaults(t){this.K!==t&&(Util.s(t,TreeVertex,TreeLayout,"rootDefaults"),this.K=t,this.invalidateLayout())}get alternateDefaults(){return this.U}set alternateDefaults(t){this.U!==t&&(Util.s(t,TreeVertex,TreeLayout,"alternateDefaults"),this.U=t,this.invalidateLayout())}get sorting(){return this.K.sorting}set sorting(t){this.K.sorting!==t&&(Util.tt(t,TreeSorting,"TreeSorting"),this.K.sorting=t,this.invalidateLayout())}get comparer(){return this.K.comparer}set comparer(t){this.K.comparer!==t&&(Util.t(t,"function",TreeLayout,"comparer"),this.K.comparer=t,this.invalidateLayout())}get angle(){return this.K.angle}set angle(t){this.K.angle!==t&&(Util.t(t,"number",TreeLayout,"angle"),t===0||t===90||t===180||t===270?(this.K.angle=t,this.invalidateLayout()):Util.n("TreeLayout.angle must be 0, 90, 180, or 270"))}get alignment(){return this.K.alignment}set alignment(t){this.K.alignment!==t&&(Util.tt(t,TreeAlignment,"TreeAlignment"),this.K.alignment=t,this.invalidateLayout())}get nodeIndent(){return this.K.nodeIndent}set nodeIndent(t){this.K.nodeIndent!==t&&(Util.t(t,"number",TreeLayout,"nodeIndent"),t>=0&&(this.K.nodeIndent=t,this.invalidateLayout()))}get nodeIndentPastParent(){return this.K.nodeIndentPastParent}set nodeIndentPastParent(t){this.K.nodeIndentPastParent!==t&&(Util.t(t,"number",TreeLayout,"nodeIndentPastParent"),t>=0&&t<=1&&(this.K.nodeIndentPastParent=t,this.invalidateLayout()))}get nodeSpacing(){return this.K.nodeSpacing}set nodeSpacing(t){this.K.nodeSpacing!==t&&(Util.t(t,"number",TreeLayout,"nodeSpacing"),this.K.nodeSpacing=t,this.invalidateLayout())}get layerSpacing(){return this.K.layerSpacing}set layerSpacing(t){this.K.layerSpacing!==t&&(Util.t(t,"number",TreeLayout,"layerSpacing"),this.K.layerSpacing=t,this.invalidateLayout())}get layerSpacingParentOverlap(){return this.K.layerSpacingParentOverlap}set layerSpacingParentOverlap(t){this.K.layerSpacingParentOverlap!==t&&(Util.t(t,"number",TreeLayout,"layerSpacingParentOverlap"),t>=0&&t<=1&&(this.K.layerSpacingParentOverlap=t,this.invalidateLayout()))}get compaction(){return this.K.compaction}set compaction(t){this.K.compaction!==t&&(Util.tt(t,TreeCompaction,"TreeCompaction"),(t===30||t===31)&&(this.K.compaction=t,this.invalidateLayout()))}get breadthLimit(){return this.K.breadthLimit}set breadthLimit(t){this.K.breadthLimit!==t&&(Util.t(t,"number",TreeLayout,"breadthLimit"),t>=0&&(this.K.breadthLimit=t,this.invalidateLayout()))}get rowSpacing(){return this.K.rowSpacing}set rowSpacing(t){this.K.rowSpacing!==t&&(Util.t(t,"number",TreeLayout,"rowSpacing"),this.K.rowSpacing=t,this.invalidateLayout())}get rowIndent(){return this.K.rowIndent}set rowIndent(t){this.K.rowIndent!==t&&(Util.t(t,"number",TreeLayout,"rowIndent"),t>=0&&(this.K.rowIndent=t,this.invalidateLayout()))}get commentSpacing(){return this.K.commentSpacing}set commentSpacing(t){this.K.commentSpacing!==t&&(Util.t(t,"number",TreeLayout,"commentSpacing"),this.K.commentSpacing=t,this.invalidateLayout())}get commentMargin(){return this.K.commentMargin}set commentMargin(t){this.K.commentMargin!==t&&(Util.t(t,"number",TreeLayout,"commentMargin"),this.K.commentMargin=t,this.invalidateLayout())}get setsPortSpot(){return this.K.setsPortSpot}set setsPortSpot(t){this.K.setsPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"setsPortSpot"),this.K.setsPortSpot=t,this.invalidateLayout())}get portSpot(){return this.K.portSpot}set portSpot(t){Util.s(t,Spot,TreeLayout,"portSpot"),this.K.portSpot.equals(t)||(this.K.portSpot=t,this.invalidateLayout())}get setsChildPortSpot(){return this.K.setsChildPortSpot}set setsChildPortSpot(t){this.K.setsChildPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"setsChildPortSpot"),this.K.setsChildPortSpot=t,this.invalidateLayout())}get childPortSpot(){return this.K.childPortSpot}set childPortSpot(t){Util.s(t,Spot,TreeLayout,"childPortSpot"),this.K.childPortSpot.equals(t)||(this.K.childPortSpot=t,this.invalidateLayout())}get alternateSorting(){return this.U.sorting}set alternateSorting(t){this.U.sorting!==t&&(Util.tt(t,TreeSorting,"TreeSorting"),this.U.sorting=t,this.invalidateLayout())}get alternateComparer(){return this.U.comparer}set alternateComparer(t){this.U.comparer!==t&&(Util.t(t,"function",TreeLayout,"alternateComparer"),this.U.comparer=t,this.invalidateLayout())}get alternateAngle(){return this.U.angle}set alternateAngle(t){this.U.angle!==t&&(Util.t(t,"number",TreeLayout,"alternateAngle"),(t===0||t===90||t===180||t===270)&&(this.U.angle=t,this.invalidateLayout()))}get alternateAlignment(){return this.U.alignment}set alternateAlignment(t){this.U.alignment!==t&&(Util.tt(t,TreeAlignment,"TreeAlignment"),this.U.alignment=t,this.invalidateLayout())}get alternateNodeIndent(){return this.U.nodeIndent}set alternateNodeIndent(t){this.U.nodeIndent!==t&&(Util.t(t,"number",TreeLayout,"alternateNodeIndent"),t>=0&&(this.U.nodeIndent=t,this.invalidateLayout()))}get alternateNodeIndentPastParent(){return this.U.nodeIndentPastParent}set alternateNodeIndentPastParent(t){this.U.nodeIndentPastParent!==t&&(Util.t(t,"number",TreeLayout,"alternateNodeIndentPastParent"),t>=0&&t<=1&&(this.U.nodeIndentPastParent=t,this.invalidateLayout()))}get alternateNodeSpacing(){return this.U.nodeSpacing}set alternateNodeSpacing(t){this.U.nodeSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateNodeSpacing"),this.U.nodeSpacing=t,this.invalidateLayout())}get alternateLayerSpacing(){return this.U.layerSpacing}set alternateLayerSpacing(t){this.U.layerSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateLayerSpacing"),this.U.layerSpacing=t,this.invalidateLayout())}get alternateLayerSpacingParentOverlap(){return this.U.layerSpacingParentOverlap}set alternateLayerSpacingParentOverlap(t){this.U.layerSpacingParentOverlap!==t&&(Util.t(t,"number",TreeLayout,"alternateLayerSpacingParentOverlap"),t>=0&&t<=1&&(this.U.layerSpacingParentOverlap=t,this.invalidateLayout()))}get alternateCompaction(){return this.U.compaction}set alternateCompaction(t){this.U.compaction!==t&&(Util.tt(t,TreeCompaction,"TreeCompaction"),(t===30||t===31)&&(this.U.compaction=t,this.invalidateLayout()))}get alternateBreadthLimit(){return this.U.breadthLimit}set alternateBreadthLimit(t){this.U.breadthLimit!==t&&(Util.t(t,"number",TreeLayout,"alternateBreadthLimit"),t>=0&&(this.U.breadthLimit=t,this.invalidateLayout()))}get alternateRowSpacing(){return this.U.rowSpacing}set alternateRowSpacing(t){this.U.rowSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateRowSpacing"),this.U.rowSpacing=t,this.invalidateLayout())}get alternateRowIndent(){return this.U.rowIndent}set alternateRowIndent(t){this.U.rowIndent!==t&&(Util.t(t,"number",TreeLayout,"alternateRowIndent"),t>=0&&(this.U.rowIndent=t,this.invalidateLayout()))}get alternateCommentSpacing(){return this.U.commentSpacing}set alternateCommentSpacing(t){this.U.commentSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateCommentSpacing"),this.U.commentSpacing=t,this.invalidateLayout())}get alternateCommentMargin(){return this.U.commentMargin}set alternateCommentMargin(t){this.U.commentMargin!==t&&(Util.t(t,"number",TreeLayout,"alternateCommentMargin"),this.U.commentMargin=t,this.invalidateLayout())}get alternateSetsPortSpot(){return this.U.setsPortSpot}set alternateSetsPortSpot(t){this.U.setsPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"alternateSetsPortSpot"),this.U.setsPortSpot=t,this.invalidateLayout())}get alternatePortSpot(){return this.U.portSpot}set alternatePortSpot(t){Util.s(t,Spot,TreeLayout,"alternatePortSpot"),this.U.portSpot.equals(t)||(this.U.portSpot=t,this.invalidateLayout())}get alternateSetsChildPortSpot(){return this.U.setsChildPortSpot}set alternateSetsChildPortSpot(t){this.U.setsChildPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"alternateSetsChildPortSpot"),this.U.setsChildPortSpot=t,this.invalidateLayout())}get alternateChildPortSpot(){return this.U.childPortSpot}set alternateChildPortSpot(t){Util.s(t,Spot,TreeLayout,"alternateChildPortSpot"),this.U.childPortSpot.equals(t)||(this.U.childPortSpot=t,this.invalidateLayout())}static PathDefault=0;static PathDestination=1;static PathSource=2;static SortingForwards=10;static SortingReverse=11;static SortingAscending=12;static SortingDescending=13;static AlignmentCenterSubtrees=20;static AlignmentCenterChildren=21;static AlignmentStart=22;static AlignmentEnd=23;static AlignmentBus=24;static AlignmentBusBranching=25;static AlignmentTopLeftBus=26;static AlignmentBottomRightBus=27;static CompactionNone=30;static CompactionBlock=31;static StyleLayered=40;static StyleLastParents=41;static StyleAlternating=42;static StyleRootOnly=43;static ArrangementVertical=50;static ArrangementHorizontal=51;static ArrangementFixedRoots=52;static LayerIndividual=60;static LayerSiblings=61;static LayerUniform=62}class TreeNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new TreeVertex(this)}createEdge(){return new TreeEdge(this)}}class TreeVertex extends LayoutVertex{X;kt;rt;Sk;Mk;Pk;Nk;Ck;Ak;Lk;Be;RD;ou;ru;Xg;Yg;ke;Se;jt;ai;ew;sw;nw;As;ow;rw;lw;hw;aw;fw;cw;uw;dw;gw;mw;constructor(t){super(t),this.Sk=!1,this.Mk=null,this.Pk=[],this.Nk=0,this.Ck=0,this.Ak=0,this.Lk=0,this.Be=null,this.X=new Point(0,0),this.kt=new Size(0,0),this.rt=new Point(0,0),this.RD=!1,this.ou=!1,this.ru=!1,this.Xg=null,this.Yg=null,this.ke=10,this.Se=LayoutVertex.standardComparer,this.jt=0,this.ai=21,this.ew=0,this.sw=0,this.nw=20,this.As=50,this.ow=0,this.rw=31,this.lw=0,this.hw=25,this.aw=10,this.fw=10,this.cw=20,this.uw=!0,this.dw=Spot.Default,this.gw=!0,this.mw=Spot.Default}copyInheritedPropertiesFrom(t){t!==null&&(this.ke=t.sorting,this.Se=t.comparer,this.jt=t.angle,this.ai=t.alignment,this.ew=t.nodeIndent,this.sw=t.nodeIndentPastParent,this.nw=t.nodeSpacing,this.As=t.layerSpacing,this.ow=t.layerSpacingParentOverlap,this.rw=t.compaction,this.lw=t.breadthLimit,this.hw=t.rowSpacing,this.aw=t.rowIndent,this.fw=t.commentSpacing,this.cw=t.commentMargin,this.uw=t.setsPortSpot,this.dw=t.portSpot,this.gw=t.setsChildPortSpot,this.mw=t.childPortSpot)}get initialized(){return this.Sk}set initialized(t){this.Sk!==t&&(Util.t(t,"boolean",TreeVertex,"initialized"),this.Sk=t)}get parent(){return this.Mk}set parent(t){this.Mk!==t&&(Debug&&t!==null&&Util.s(t,TreeVertex,TreeVertex,"parent"),this.Mk=t)}get children(){return this.Pk}set children(t){if(this.Pk!==t){if(t!==null&&!Array.isArray(t)&&Util.Vi(t,"Array",TreeVertex,"children:value"),t!==null){const i=t.length;for(let e=0;e4;)t.removePoint(2);u=t.getPoint(1),d=t.getPoint(2)}else{for(c=1;t.pointsCount>3;)t.removePoint(1);u=t.getPoint(0),d=t.getPoint(t.pointsCount-1)}const m=t.getPoint(t.pointsCount-1);let g=0;r===0?(e.alignment===23?(g=o.bottom+n.y,n.y===0&&u.y>m.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.xm.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.x{const i=t.matches?"dark":"light";i!==this.Kg&&(this.Kg=i,this.Fk==="system"&&this.pw())};constructor(t){t&&Object.assign(this,t),t?.themeMap||(this.hu.set("light",{colors:{...Themes.Light.colors},fonts:{...Themes.Light.fonts},numbers:{...Themes.Light.numbers},margins:{...Themes.Light.margins},arrowheads:{...Themes.Light.arrowheads}}),this.hu.set("dark",{colors:{...Themes.Dark.colors},fonts:{...Themes.Dark.fonts},numbers:{...Themes.Dark.numbers},margins:{...Themes.Dark.margins},arrowheads:{...Themes.Dark.arrowheads}})),root.matchMedia&&(this.Kg=root.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}get themeMap(){return this.hu}set themeMap(t){this.hu!==t&&(this.hu=t,this.pw())}get defaultTheme(){return this.Dk}set defaultTheme(t){this.Dk!==t&&(Util.t(t,"string",ThemeManager,"defaultTheme"),this.Dk=t,this.pw())}get currentTheme(){return this.Fk}set currentTheme(t){this.Fk!==t&&(Util.t(t,"string",ThemeManager,"currentTheme"),this.Fk=t,this.pw())}get changesDivBackground(){return this.Rk}set changesDivBackground(t){if(this.Rk!==t&&(this.Rk=t,t))for(const e of this.ls)e.setDivBackground(this.findValue("div","","fill")),e.V("ThemeChanged",this)}get preferredColorScheme(){return this.Kg}addDiagram(t){return this.ls.add(t),this.eC(t),this}removeDiagram(t){return this.ls.delete(t),this.eC(t),this}vF(){this.ls.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.addEventListener("change",this.ID)}JF(){this.ls.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.removeEventListener("change",this.ID)}set(t,i){t===""&&(t=this.Dk),t==="system"&&(t=this.Kg);let e=this.hu.get(t);return e?e=this.OD(e,i):e=i,this.hu.set(t,e),this.pw(),this}findValue(t,i,e){return this.getValue(this.findTheme(this.currentTheme),t,i,e)||this.getValue(this.findTheme(this.defaultTheme),t,i,e)}getValue(t,i,e,s){if(!t)return;e==null&&(e="");let n=t;const o=l=>{if(n===void 0||l==="")return;if(typeof l=="number"||!(Array.isArray(l)||l.includes(".")))return n[l];const h=Array.isArray(l)?l:l.split(".");for(let a=0;a{if(!(e!==""&&(n=o(e),n===void 0)))return Array.isArray(n)&&typeof i=="number"?n=n[i%n.length]:n=o(i),n};if(n=r(),n===void 0&&typeof s=="string"&&s.length>0){let l=t.targetPropertyMap?.get(s);if(l?n=t[l]:(l=ThemeManager._3.get(s),n=l?t[l]:t.colors),n=r(),n!==void 0)return n}return n}findTheme(t){return this.themeMap.get(t==="system"?this.Kg:t)}eC(t){const i=t.skipsUndoManager;t.skipsUndoManager=!0,t.updateAllThemeBindings(),this.Rk&&t.setDivBackground(this.findValue("div","","fill")),t.skipsUndoManager=i,t.V("ThemeChanged",this)}pw(){for(const t of this.ls)this.eC(t)}OD(t,i){for(const e in i)if(Util.yw(i,e))try{i[e].constructor===Object?t[e]=this.OD(t[e]??{},i[e]):t[e]=i[e]}catch{delete t[e]}return t}static _3=new Map([["background","colors"],["defaultColumnSeparatorStroke","colors"],["defaultRowSeparatorStroke","colors"],["shadowColor","colors"],["fill","colors"],["stroke","colors"],["font","fonts"],["angle","numbers"],["fromEndSegmentLength","numbers"],["fromShortLength","numbers"],["height","numbers"],["opacity","numbers"],["scale","numbers"],["toEndSegmentLength","numbers"],["toShortLength","numbers"],["width","numbers"],["defaultColumnSeparatorStrokeWidth","numbers"],["defaultRowSeparatorStrokeWidth","numbers"],["shadowBlur","numbers"],["corner","numbers"],["curviness","numbers"],["smoothness","numbers"],["parameter1","numbers"],["parameter2","numbers"],["strokeWidth","numbers"],["strokeDashOffset","numbers"],["maxLines","numbers"],["spacingAbove","numbers"],["spacingBelow","numbers"],["position","points"],["shadowOffset","points"],["desiredSize","sizes"],["maxSize","sizes"],["minSize","sizes"],["margin","margins"],["defaultSeparatorPadding","margins"],["padding","margins"],["alignment","spots"],["alignmentFocus","spots"],["fromSpot","spots"],["toSpot","spots"],["defaultAlignment","spots"],["spot1","spots"],["spot2","spots"],["verticalAlignment","spots"],["imageAlignment","spots"],["fromArrow","arrowheads"],["toArrow","arrowheads"]])}class Router{Tt;b;Xi;pl;constructor(){this.b=Diagram.Mm(),this.Tt="",this.Xi=!0,this.pl=!0}get name(){return this.Tt}set name(t){this.Tt=t}get isEnabled(){return this.Xi}set isEnabled(t){this.Xi=t}get isRealtime(){return this.pl}set isRealtime(t){this.pl=t}get diagram(){return this.b}set diagram(t){this.b!==t&&(this.b=t,t.Pl=!0,t.requestUpdate())}invalidateRouter(){this.b!==null&&(this.b.Pl=!0,this.b.requestUpdate())}canRoute(t){if(!this.isEnabled)return!1;const i=this.diagram;return!(i&&(!this.isRealtime&&i.Pu||i.animationManager.isTicking))}routeLinks(t,i){}toString(){return this.name!==""?this.name+" Router":Util.hn(this.constructor)}}class AvoidsNodesRouter extends Router{constructor(t){super(),this.name="AvoidsNodes",t&&Object.assign(this,t)}canRoute(t){return(t instanceof Diagram?t.$m:t.diagram.$m)?super.canRoute(t):!1}routeLinks(t,i){const e=i instanceof Diagram?null:i,s=t.iterator,n=this.diagram.getPositions(!0,e,null);for(;s.next();){const o=s.value;if(!o.isAvoiding||i&&o.containingGroup!==e||o.toNode===null||o.fromNode===null||o.pointsCount<4)continue;o.startRoute();const r=o.pointsCount,l=o.getPoint(1),h=o.getPoint(r-2),a=o.fromNode.actualBounds.copy();a.inflate(Link.za,Link.za),a.unionPoint(o.getPoint(0));const f=o.toNode.actualBounds.copy();f.inflate(Link.za,Link.za),f.unionPoint(o.getPoint(r-1)),this.tE(o,a,f,n)&&this.iE(o,l,o.cN,h,o.uN,a,f,n),o.commitRoute()}}tE(t,i,e,s){const n=t.diagram,o=t.pointsCount;if(n===null||t.fromNode===t.toNode||t.layer.isTemporary||i.containsPoint(t.getPoint(o-1))&&!t.toNode.isMemberOf(t.fromNode)||e.containsPoint(t.getPoint(0))&&!t.fromNode.isMemberOf(t.toNode)||!t.isOrthogonal)return!1;if(t.segmentIndex===17)return!0;const r=t.getPoint(1),l=t.getPoint(o-2),h=t.getPoint(2);if(!s.isUnoccupied(Math.min(r.x,h.x),Math.min(r.y,h.y),Math.abs(r.x-h.x),Math.abs(r.y-h.y)))return!0;for(let f=2;f=PositionArray.qd&&(l.vA(),d.inflate(l.cellWidth*l.KP,l.cellHeight*l.UP),l.mT(i,e,s,n,d,!1),m=l.wo(s.x,s.y)),!l.Cy&&mPositionArray.Ua&&i.wo(g,p)!==u-1&&(i.wo(d-f,m)===u-1?(n=180,g=d-f,p=m):i.wo(d+f,m)===u-1?(n=0,g=d+f,p=m):i.wo(d,m-c)===u-1?(n=270,g=d,p=m-c):i.wo(d,m+c)===u-1&&(n=90,g=d,p=m+c));u>PositionArray.Ua&&i.wo(g,p)===u-1;)d=g,m=p,n===0?g+=f:n===90?p+=c:n===180?g-=f:p-=c,u-=1;if(o?u>PositionArray.Ua&&(n===180||n===0?d=Math.floor(d/f)*f+f/2:(n===90||n===270)&&(m=Math.floor(m/c)*c+c/2)):(d=Math.floor(d/f)*f+f/2,m=Math.floor(m/c)*c+c/2),u>PositionArray.Ua){let y=n,x=d,k=m;if(n===0?(y=90,k+=c):n===90?(y=180,x-=f):n===180?(y=270,k-=c):n===270&&(y=0,x+=f),i.wo(x,k)===u-1)this.sC(t,i,x,k,y,!1);else{let S=d,M=m;n===0?(y=270,M-=c):n===90?(y=0,S+=f):n===180?(y=90,M+=c):n===270&&(y=180,S-=f),i.wo(S,M)===u-1&&this.sC(t,i,S,M,y,!1)}}t.insertPointAt(t.pointsCount-2,d,m)}}ToolManager.prototype.initializeStandardTools=function(){this.ti("Action",new ActionTool,this.mouseDownTools),this.ti("Relinking",new RelinkingTool,this.mouseDownTools),this.ti("LinkReshaping",new LinkReshapingTool,this.mouseDownTools),this.ti("Rotating",new RotatingTool,this.mouseDownTools),this.ti("Resizing",new ResizingTool,this.mouseDownTools),this.ti("Linking",new LinkingTool,this.mouseMoveTools),this.ti("Dragging",new DraggingTool,this.mouseMoveTools),this.ti("DragSelecting",new DragSelectingTool,this.mouseMoveTools),this.ti("Panning",new PanningTool,this.mouseMoveTools),this.ti("ContextMenu",new ContextMenuTool,this.mouseUpTools),this.ti("TextEditing",new TextEditingTool,this.mouseUpTools),this.ti("ClickCreating",new ClickCreatingTool,this.mouseUpTools),this.ti("ClickSelecting",new ClickSelectingTool,this.mouseUpTools)},Diagram.SP("GraphLinksModel",GraphLinksPartManager),Diagram.SP("TreeModel",TreePartManager);const oldGo=root.go,go={get version(){return Diagram.version},Group,List,Set:GSet,Map:GMap,Point,Size,Rect,Margin,Spot,Geometry,PathFigure,PathSegment,InputEvent,DiagramEvent,ChangedEvent,Model,GraphLinksModel,TreeModel,Binding,ThemeBinding,Transaction,UndoManager,CommandHandler,Tool,DraggingTool,DraggingInfo,DraggingOptions,LinkingBaseTool,LinkingTool,RelinkingTool,LinkReshapingTool,ResizingTool,RotatingTool,ClickSelectingTool,ActionTool,ClickCreatingTool,HTMLInfo,ContextMenuTool,DragSelectingTool,PanningTool,TextEditingTool,ToolManager,Animation,AnimationManager,AnimationTrigger,Layer,Diagram,Palette,Overview,Brush,GraphObject,Panel,RowColumnDefinition,Shape,TextBlock,Picture,Part,Adornment,Node,Link,Placeholder,Layout,LayoutNetwork,LayoutVertex,LayoutEdge,GridLayout,PanelLayout,CircularLayout,CircularNetwork,CircularVertex,CircularEdge,ForceDirectedLayout,ForceDirectedNetwork,ForceDirectedVertex,ForceDirectedEdge,LayeredDigraphLayout,LayeredDigraphNetwork,LayeredDigraphVertex,LayeredDigraphEdge,TreeLayout,TreeNetwork,TreeVertex,TreeEdge,Themes,ThemeManager,Router,AnimationStyle,AutoScale,CycleMode,Flip,TextFormat,ImageStretch,LayoutConditions,LinkAdjusting,Curve,Routing,Orientation,TextOverflow,PortSpreading,ScrollMode,CollapsePolicy,Sizing,TriggerStart,Stretch,ViewboxStretch,Wrap,BrushType,ColorSpace,GeometryStretch,GeometryType,SegmentType,BindingMode,ChangeType,CircularArrangement,CircularDirection,CircularNodeDiameterFormula,CircularSorting,GridAlignment,GridArrangement,GridSorting,LayeredDigraphAggressive,LayeredDigraphAlign,LayeredDigraphCycleRemove,LayeredDigraphInit,LayeredDigraphLayering,LayeredDigraphPack,TreeAlignment,TreeArrangement,TreeCompaction,TreeLayerStyle,TreePath,TreeSorting,TreeStyle,GestureMode,LinkingDirection,ReshapingBehavior,TextEditingAccept,TextEditingStarting,TextEditingState,WheelMode};typeof oldGo=="object"&&oldGo.version&&Util.at("WARNING: a `go` object on the root object is already defined. "+("Debug"in oldGo?"debug ":"")+"version: "+oldGo.version+", replaced with version: "+go.version),Diagram.prototype.go=go,root.go=go,go.Debug=Debug,Debug.attachReadonlyWarnings(go); + "removedLinkKeys": `;jT(t){const i=new GSet;for(let e=0;e{if(c.model===s){if(c.modelChange==="linkDataArray")c.change===3?n.add(c.newValue):c.change===4&&r.add(c.oldValue);else if(s.containsLinkData(c.object))o.add(c.object);else if(c.object!==null)if(c.object!==null&&l&&l.has(c.object))l.get(c.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(c.object instanceof Model||s.containsNodeData(c.object))return;s.jT(c.object).each(d=>o.add(d))}}});const h=this.ug;h.clear(),n.each(c=>{h.add(s.getKeyForLinkData(c)),i||o.add(c)});const a=this.cg;a.clear(),r.each(c=>{a.add(s.getKeyForLinkData(c)),i&&o.add(c)});let f=e;return h.count>0&&(f+=(i?this.vT:this.WT)+this.Dh(h.toArray(),!0)),o.count>0&&(f+=this.zO+this.Dh(o.toArray(),!0)),a.count>0&&(f+=(i?this.WT:this.vT)+this.Dh(a.toArray(),!0)),a.clear(),h.clear(),f}By(t){(t.linkCategoryProperty!==void 0&&t.linkCategoryProperty!==this.linkCategoryProperty||t.linkKeyProperty!==void 0&&t.linkKeyProperty!==this.linkKeyProperty||t.linkFromKeyProperty!==void 0&&t.linkFromKeyProperty!==this.linkFromKeyProperty||t.linkToKeyProperty!==void 0&&t.linkToKeyProperty!==this.linkToKeyProperty||t.linkFromPortIdProperty!==void 0&&t.linkFromPortIdProperty!==this.linkFromPortIdProperty||t.linkToPortIdProperty!==void 0&&t.linkToPortIdProperty!==this.linkToPortIdProperty||t.linkLabelKeysProperty!==void 0&&t.linkLabelKeysProperty!==this.linkLabelKeysProperty||t.nodeIsGroupProperty!==void 0&&t.nodeIsGroupProperty!==this.nodeIsGroupProperty||t.nodeGroupKeyProperty!==void 0&&t.nodeGroupKeyProperty!==this.nodeGroupKeyProperty)&&Util.n("applyIncrementalJson cannot change Model properties"),super.By(t);const i=t.insertedLinkKeys;if(Array.isArray(i)){const n=i.length;for(let o=0;o=0&&s.splice(e,1)):s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue));return}}else if(t.change===4){let e=t.oldParam;if(t.modelChange==="linkDataArray"){const s=t.oldValue;if(Util.Mt(s)&&typeof e=="number"){const n=this.getKeyForLinkData(s);i?(this.hr.add(s),this.is[e]!==s&&this.is.splice(e,0,s),n!==void 0&&this.mi.set(n,s)):(this.hr.delete(s),this.is[e]===s&&this.is.splice(e,1),n!==void 0&&this.mi.delete(n))}return}else if(t.modelChange==="linkLabelKeys"){const s=this.getLabelKeysForLinkData(t.object);Array.isArray(s)&&typeof e=="number"&&(i?s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue):(e=s.indexOf(t.newValue),e>=0&&s.splice(e,1)));return}}super.changeState(t,i)}}get archetypeNodeData(){return this.Fl}set archetypeNodeData(t){const i=this.Fl;i!==t&&(t!==null&&Util.t(t,"object",GraphLinksModel,"archetypeNodeData"),this.Fl=t,this.i("archetypeNodeData",i,t))}IN(t){if(t===void 0)return;const i=this.Fl;if(i!==null){let e=this.findNodeDataForKey(t);e===null&&(e=this.copyNodeData(i),Model.ct(e,this.nodeKeyProperty,t),this.addNodeData(e))}return t}get linkFromKeyProperty(){return this.Po}set linkFromKeyProperty(t){const i=this.Po;i!==t&&(this.In(t,GraphLinksModel,"linkFromKeyProperty"),this.Po=t,this.i("linkFromKeyProperty",i,t))}getFromKeyForLinkData(t){return this.Ee(t,!0)}setFromKeyForLinkData(t,i){this.ng(t,i,!0)}get linkToKeyProperty(){return this.No}set linkToKeyProperty(t){const i=this.No;i!==t&&(this.In(t,GraphLinksModel,"linkToKeyProperty"),this.No=t,this.i("linkToKeyProperty",i,t))}getToKeyForLinkData(t){return this.Ee(t,!1)}setToKeyForLinkData(t,i){this.ng(t,i,!1)}Ee(t,i){if(t===null)return;const e=i?this.Po:this.No;if(e==="")return;const s=Model.Xt(t,e);if(s!==void 0){if(this.isKeyType(s))return s;Util.n((i?"FromKey":"ToKey")+" value for link data "+t+" is not a number or a string: "+s)}}ng(t,i,e){if(i===null&&(i=void 0),i!==void 0&&!this.isKeyType(i)&&Util.Bi(i,"number or string",GraphLinksModel,e?"setFromKeyForLinkData:key":"setToKeyForLinkData:key"),t===null)return;const s=e?this.Po:this.No;if(s==="")return;if(i=this.IN(i),!this.containsLinkData(t)){Model.ct(t,s,i);return}const n=Model.Xt(t,s);n!==i&&(this.tn(n,t),Model.ct(t,s,i),this.findNodeDataForKey(i)===null&&this.en(i,t),this.Kt(e?"linkFromKey":"linkToKey",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkFromPortIdProperty(){return this.Ja}set linkFromPortIdProperty(t){const i=this.Ja;i!==t&&(this.In(t,GraphLinksModel,"linkFromPortIdProperty"),Debug&&(t===this.linkFromKeyProperty||t===this.linkToKeyProperty)&&Util.n("linkFromPortIdProperty name must not be the same as the GraphLinksModel.linkFromKeyProperty or linkToKeyProperty: "+t),this.Ja=t,this.i("linkFromPortIdProperty",i,t))}getFromPortIdForLinkData(t){return this.Eb(t,!0)}setFromPortIdForLinkData(t,i){this.og(t,i,!0)}get linkToPortIdProperty(){return this.Za}set linkToPortIdProperty(t){const i=this.Za;i!==t&&(this.In(t,GraphLinksModel,"linkToPortIdProperty"),Debug&&(t===this.linkFromKeyProperty||t===this.linkToKeyProperty)&&Util.n("linkFromPortIdProperty name must not be the same as the GraphLinksModel.linkFromKeyProperty or linkToKeyProperty: "+t),this.Za=t,this.i("linkToPortIdProperty",i,t))}getToPortIdForLinkData(t){return this.Eb(t,!1)}setToPortIdForLinkData(t,i){this.og(t,i,!1)}Eb(t,i){if(t===null)return"";const e=i?this.Ja:this.Za;if(e==="")return"";const s=Model.Xt(t,e);return s===void 0?"":s}og(t,i,e){if(Util.t(i,"string",GraphLinksModel,e?"setFromPortIdForLinkData:portname":"setToPortIdForLinkData:portname"),t===null)return;const s=e?this.Ja:this.Za;if(s==="")return;if(!this.containsLinkData(t)){Model.ct(t,s,i);return}let n=Model.Xt(t,s);n===void 0&&(n=""),n!==i&&(Model.ct(t,s,i),this.Kt(e?"linkFromPortId":"linkToPortId",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkLabelKeysProperty(){return this.sn}set linkLabelKeysProperty(t){const i=this.sn;i!==t&&(this.In(t,GraphLinksModel,"linkLabelKeysProperty"),this.sn=t,this.i("linkLabelKeysProperty",i,t))}getLabelKeysForLinkData(t){if(t===null)return GraphLinksModel.EmptyArray;const i=this.sn;if(i==="")return GraphLinksModel.EmptyArray;const e=Model.Xt(t,i);return e===void 0?GraphLinksModel.EmptyArray:e}setLabelKeysForLinkData(t,i){if(Util.Ug(i,GraphLinksModel,"setLabelKeysForLinkData:arr"),t===null)return;const e=this.sn;if(e==="")return;if(!this.containsLinkData(t)){Model.ct(t,e,i);return}let s=Model.Xt(t,e);if(s===void 0&&(s=GraphLinksModel.EmptyArray),s!==i){if(Array.isArray(s)){const o=s.length;for(let r=0;r=0)return;n=s.length,s.push(i),this.containsLinkData(t)&&(this.findNodeDataForKey(i)===null&&this.en(i,t),this.Kt("linkLabelKeys",3,e,t,null,i,null,n))}else Util.n(e+" property is not an Array; cannot addLabelKeyForLinkData: "+t)}removeLabelKeyForLinkData(t,i){if(i==null||(this.isKeyType(i)||Util.Bi(i,"number or string",GraphLinksModel,"removeLabelKeyForLinkData:key"),t===null))return;const e=this.sn;if(e==="")return;const s=Model.Xt(t,e);if(Array.isArray(s)){const n=s.indexOf(i);if(n<0)return;s.splice(n,1),this.containsLinkData(t)&&(this.tn(i,t),this.Kt("linkLabelKeys",4,e,t,i,null,n,null))}else s!==void 0&&Util.n(e+" property is not an Array; cannot removeLabelKeyforLinkData: "+t)}get linkDataArray(){return this.is}set linkDataArray(t){const i=this.is;if(i!==t){Util.Ug(t,GraphLinksModel,"linkDataArray"),this.mi.clear();const e=t.length;for(let n=0;nnew GraphLinksModel,Model.initDiagramModel=Model.initDiagramModel=()=>new GraphLinksModel;class TreeModel extends Model{En;xg;Qa;constructor(t,i){if(super(),this.En="parent",this.xg=!1,this.Qa="parentLinkCategory",t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){super.cloneProtected(t),t.En=this.En,t.xg=this.xg,t.Qa=this.Qa}toString(t){if(t===void 0&&(t=0),t>=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" TreeModel";if(t>0){i+=` + node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n(w[w.ConstantSpacing=0]="ConstantSpacing",w[w.ConstantDistance=1]="ConstantDistance",w[w.ConstantAngle=2]="ConstantAngle",w[w.Packed=3]="Packed",w))(CircularArrangement||{}),CircularDirection=(w=>(w[w.Clockwise=10]="Clockwise",w[w.Counterclockwise=11]="Counterclockwise",w[w.BidirectionalLeft=12]="BidirectionalLeft",w[w.BidirectionalRight=13]="BidirectionalRight",w))(CircularDirection||{}),CircularSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w[w.Optimized=24]="Optimized",w))(CircularSorting||{}),CircularNodeDiameterFormula=(w=>(w[w.Pythagorean=30]="Pythagorean",w[w.Circular=31]="Circular",w))(CircularNodeDiameterFormula||{});class CircularLayout extends Layout{ue;Kc;qb;bg;jb;Rh;BN;VN;zN;Ns;Xy;Yy;_a;Ky;ZT;kg;Sg;Mg;Uc;qi;C;ke;Se;Rn;Pg;constructor(t){super(),this.ue=0,this.Kc=0,this.qb=0,this.bg=360,this.jb=0,this.Rh=0,this.BN=new Point,this.VN=30,this.zN=0,this.Ns=0,this.Xy=0,this.Yy=new VertexArrangement,this._a=0,this.Ky=0,this.ZT=600,this.kg=NaN,this.Sg=1,this.Mg=0,this.Uc=360,this.qi=0,this.C=10,this.ke=24,this.Se=LayoutVertex.standardComparer,this.Rn=6,this.Pg=30,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.kg=this.kg,t.Sg=this.Sg,t.Mg=this.Mg,t.Uc=this.Uc,t.qi=this.qi,t.C=this.C,t.ke=this.ke,t.Se=this.Se,t.Rn=this.Rn,t.Pg=this.Pg}fi(t){t in CircularSorting?this.sorting=t:t in CircularDirection?this.direction=t:t in CircularArrangement?this.arrangement=t:t in CircularNodeDiameterFormula?this.nodeDiameterFormula=t:super.fi(t)}createNetwork(){return new CircularNetwork(this)}KO(t,i,e){t=this.UO(t);let s=this.jb,n=this.VN,o=this.ue,r=this.Kc,l=this.qb,h=this.bg,a=this.Rh,f=this.zN,c=this.Ns,u=this.Xy;if(s=this.arrangement,n=this.nodeDiameterFormula,o=this.radius,(!isFinite(o)||o<=0)&&(o=NaN),r=this.aspectRatio,(!isFinite(r)||r<=0)&&(r=1),l=this.startAngle,isFinite(l)||(l=0),h=this.sweepAngle,(!isFinite(h)||h>360||h<1)&&(h=360),a=this.spacing,isFinite(a)||(a=NaN),s===3&&n===31?s=0:s===3&&n!==31&&(n=31,s=this.arrangement),(this.direction===12||this.direction===13)&&this.sorting!==24){for(let g=0;!(g>=t.length||(i.add(t.elt(g)),g+1>=t.length));g+=2)e.add(t.elt(g+1));this.direction===12?(this.arrangement===3&&i.reverse(),t=new List,t.addAll(i),t.addAll(e)):(this.arrangement===3&&e.reverse(),t=new List,t.addAll(e),t.addAll(i))}const d=t.length;f=0;let m=0;for(let g=0;g1?(o=y,c=o*r):(c=y,o=c)}else o=this.Wb(u*(h>=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180)}else o=this.Wb(f+(h>=360?d:d-1)*(s!==3?a:a*1.6),r,l*Math.PI/180,h*Math.PI/180);c=o*r}else{c=o*r;const g=this.XN(o,c,l*Math.PI/180,h*Math.PI/180);if(isNaN(a))s===0&&(a=(g-f)/(h>=360?d:d-1));else if(s===0){const p=(g-f)/(h>=360?d:d-1);p=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180),c=o*r):a=p}else{let p=-1/0;for(let k=0;k=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180);x>o?(o=x,c=o*r,u=y):u=g/(h>=360?d:d-1)}}return this.jb=s,this.VN=n,this.ue=o,this.Kc=r,this.qb=l,this.bg=h,this.Rh=a,this.zN=f,this.Ns=c,this.Xy=u,t}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.network.vertexes;if(i.count<=1){if(i.count===1){const u=i.first();u.centerX=0,u.centerY=0}this.updateParts(),this.network=null,this.isValidLayout=!0;return}let e=new List;e.addAll(i.iterator);const s=new List,n=new List;e=this.KO(e,s,n);const o=this.jb,r=this.ue,l=this.qb,h=this.bg,a=this.Rh,f=this.Ns,c=this.Xy;if((this.direction===12||this.direction===13)&&o===3)this.$T(e,h,l-h/2,10);else if(this.direction===12||this.direction===13){let u=0;switch(o){case 1:u=this.vb(r,f,l,c)*180/Math.PI;break;case 0:{let d=0,m=0;const g=s.first();g!==null&&(d=g.Ih(Math.PI/2));const p=n.first();p!==null&&(m=p.Ih(Math.PI/2)),u=this.vb(r,f,l,a+(d+m)/2)*180/Math.PI;break}case 2:u=h/e.length;break}if(this.direction===12){switch(o){case 1:this.Uy(s,h/2,l,11);break;case 0:this.Gy(s,h/2,l,11);break;case 2:this.Hy(s,h/2,l,11);break}switch(o){case 1:this.Uy(n,h/2,l+u,10);break;case 0:this.Gy(n,h/2,l+u,10);break;case 2:this.Hy(n,h/2,l+u,10);break}}else{switch(o){case 1:this.Uy(n,h/2,l,11);break;case 0:this.Gy(n,h/2,l,11);break;case 2:this.Hy(n,h/2,l,11);break}switch(o){case 1:this.Uy(s,h/2,l+u,10);break;case 0:this.Gy(s,h/2,l+u,10);break;case 2:this.Hy(s,h/2,l+u,10);break}}}else switch(o){case 1:this.Uy(e,h,l,this.direction);break;case 0:this.Gy(e,h,l,this.direction);break;case 2:this.Hy(e,h,l,this.direction);break;case 3:this.$T(e,h,l,this.direction);break}this.updateParts(),this.network=null,this.isValidLayout=!0}Hy(t,i,e,s){const n=this.bg,o=this.ue,r=this.Ns,l=e*Math.PI/180,h=i*Math.PI/180,a=t.length;for(let f=0;f=360?a:a-1):-(f*h)/a),u=t.elt(f),d=o*Math.tan(c)/r,m=Math.sqrt((o*o+r*r*d*d)/(1+d*d));u.centerX=m*Math.cos(c),u.centerY=m*Math.sin(c),u.actualAngle=c*180/Math.PI}}Gy(t,i,e,s){const n=this.ue,o=this.Ns,r=this.Rh;let l=e*Math.PI/180;const h=t.length;for(let a=0;a180&&(n-=360),n*=Math.PI/180,this.Ky=n,this.QT(t,i,e,s)}else this._T(t,i,e,s);this.Yy.commit(t)}_T(t,i,e,s){const n=this.ue,o=this.Ns,r=this.Rh,l=this.Kc;let h=n*Math.cos(e*Math.PI/180),a=o*Math.sin(e*Math.PI/180);const f=t.toArray();if(f.length===3){f[0].centerX=n,f[0].centerY=0,f[1].centerX=f[0].centerX-f[0].width/2-f[1].width/2-r,f[1].y=f[0].y,f[2].centerX=(f[0].centerX+f[1].centerX)/2,f[2].y=f[0].y-f[2].height-r;return}else if(f.length===4){f[0].centerX=n,f[0].centerY=0,f[2].centerX=-f[0].centerX,f[2].centerY=f[0].centerY,f[1].centerX=0,f[1].y=Math.min(f[0].y,f[2].y)-f[1].height-r,f[3].centerX=0,f[3].y=Math.max(f[0].y+f[0].height+r,f[2].y+f[2].height+r);return}const c=Point.a();for(let b=0;b=f.length-1));b++)this.tD(h,a,f,b,s,c)||this.iD(h,a,f,b,s,c),h=c.x,a=c.y;if(Point.o(c),this._a++,this._a>23)return;const u=f[0].centerX,d=f[0].centerY,m=f[f.length-1].centerX,g=f[f.length-1].centerY;let p=Math.abs(u-m)-((f[0].width+f[f.length-1].width)/2+r);const y=Math.abs(d-g)-((f[0].height+f[f.length-1].height)/2+r);let x=0;if(Math.abs(y)<1){const b=Math.abs(u-m),S=(f[0].width+f[f.length-1].width)/2;b0?x=y:Math.abs(p)<1?x=0:x=p;let k=!1;Math.abs(m)>Math.abs(g)?k=m>0!=d>g:k=g>0!=u1&&(this._a<8?this.ue-=x/(2*Math.PI):f.length<5&&x>10?this.ue/=2:this.ue-=x>0?1.7:-2.3,this.Ns=this.ue*l,this._T(t,i,e,s))}QT(t,i,e,s){const n=this.ue,o=this.Ns,r=this.Kc;let l=n*Math.cos(e*Math.PI/180),h=o*Math.sin(e*Math.PI/180);const a=Point.a(),f=t.toArray();for(let m=0;m=f.length-1));m++)this.tD(l,h,f,m,s,a)||this.iD(l,h,f,m,s,a),l=a.x,h=a.y;if(Point.o(a),this._a++,this._a>23)return;const c=Math.atan2(h,l);let u=s===10?this.Ky-c:c-this.Ky;u=Math.abs(u)1&&(this._a<8?this.ue-=d/(2*Math.PI):this.ue-=d>0?1.7:-2.3,this.Ns=this.ue*r,this.QT(t,i,e,s))}tD(t,i,e,s,n,o){const r=this.Rh,l=this.ue,h=this.Ns;let a=0,f=0;const c=(e[s].width+e[s+1].width)/2+r;let u=!1;if(i>=0!=(n===10)){if(a=t+c,a>l){if(a=t-c,a<-l)return o.x=a,o.y=f,!1;u=!0}}else if(a=t-c,a<-l){if(a=t+c,a>l)return o.x=a,o.y=f,!1;u=!0}return f=Math.sqrt(1-Math.min(1,a*a/(l*l)))*h,i<0!==u&&(f=-f),Math.abs(i-f)>(e[s].height+e[s+1].height)/2?(o.x=a,o.y=f,!1):(o.x=a,o.y=f,!0)}iD(t,i,e,s,n,o){const r=this.Rh,l=this.ue,h=this.Ns;let a=0,f=0;const c=(e[s].height+e[s+1].height)/2+r;let u=!1;if(t>=0!=(n===10)){if(f=i-c,f<-h){if(f=i+c,f>h)return o.x=a,o.y=f,!1;u=!0}}else if(f=i+c,f>h){if(f=i-c,f<-h)return o.x=a,o.y=f,!1;u=!0}return a=Math.sqrt(1-Math.min(1,f*f/(h*h)))*l,t<0!==u&&(a=-a),Math.abs(t-a)>(e[s].width+e[s+1].width)/2?(o.x=a,o.y=f,!1):(o.x=a,o.y=f,!0)}commitLayout(){this.commitNodes(),this.isRouting&&this.commitLinks()}commitNodes(){const t=this.group!==null&&this.group.hasPlaceholder(),i=t?this.group.location.copy():null;let e=this.actualCenter;t?e=new Point(0,0):(e.x=this.arrangementOrigin.x+this.ue,e.y=this.arrangementOrigin.y+this.Ns);const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;n.x+=e.x,n.y+=e.y,n.commit()}if(t){this.group.ensureBounds();const n=this.group.position.copy(),o=this.group.location.copy(),r=i.subtract(o.subtract(n));this.group.move(r),this.BN=r.subtract(n)}}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}XN(t,i,e,s){const n=this.ZT;if(Math.abs(this.Kc-1)<.001)return e!==void 0&&s!==void 0?s*t:2*Math.PI*t;const o=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let r=0,l=0;e!==void 0&&s!==void 0?l=s/(n+1):l=Math.PI/(2*(n+1));let h=0;for(let a=0;a<=n;a++){e!==void 0&&s!==void 0?h=e+a*s/n:h=a*Math.PI/(2*n);const f=Math.sin(h);r+=Math.sqrt(1-o*o*f*f)*l}return e!==void 0&&s!==void 0?(t>i?t:i)*r:4*(t>i?t:i)*r}Wb(t,i,e,s){let n=0;return e!==void 0&&s!==void 0?n=this.XN(1,i,e,s):n=this.XN(1,i),t/n}vb(t,i,e,s){if(Math.abs(this.Kc-1)<.001)return s/t;const n=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let o=0;const r=2*Math.PI/(this.network.vertexes.count*700);t>i&&(e+=Math.PI/2);for(let l=0;;l++){const h=e+l*r,a=Math.sin(h);if(o+=(t>i?t:i)*Math.sqrt(1-n*n*a*a)*r,o>=s)return l*r}}UO(t){switch(this.sorting){case 20:break;case 21:t.reverse();break;case 22:t.sort(this.comparer);break;case 23:t.sort(this.comparer),t.reverse();break;case 24:return this.qO(this.jO(t));default:Util.n("Invalid sorting type.")}return t}jO(t){const i=[];for(let s=0;sn&&(n=u,o=f)}else for(let f=0;fn&&(n=c,o=f)}e.add(t.elt(o)),i[o]=-1;const r=t.elt(o);let l=0;const h=r.sourceEdges;for(;h.next();){const c=h.value.fromVertex;l=t.indexOf(c),!(l<0)&&i[l]>=0&&i[l]++}const a=r.destinationEdges;for(;a.next();){const c=a.value.toVertex;l=t.indexOf(c),!(l<0)&&i[l]>=0&&i[l]++}}return e}qO(t){const i=[];for(let c=0;c=0){const C=Math.abs(x-(A>=x?A+1:A));b+=C=x&&M++,A>=x&&A++,M>A){const C=A;A=M,M=C}A-M<(s.length+2)/2==(M=0&&(n.push(c),o.push(x))}h++}let a=!1;const f=s.length;for(;;){a=!0;for(let c=0;c=0){let g=0;for(let p=0;pm?x-m:m-x,b=f-k;g+=xb?1:-1}s.splice(g<0?m:m+1,0,u),r.splice(c,1),c--}else a=!1}if(a)break;s.push(r[0]),r.splice(0,1)}for(let c=0;c0||isNaN(t))&&(this.kg=t,this.invalidateLayout()))}get aspectRatio(){return this.Sg}set aspectRatio(t){this.Sg!==t&&(Util.t(t,"number",CircularLayout,"aspectRatio"),t>0&&(this.Sg=t,this.invalidateLayout()))}get startAngle(){return this.Mg}set startAngle(t){this.Mg!==t&&(Util.t(t,"number",CircularLayout,"startAngle"),this.Mg=t,this.invalidateLayout())}get sweepAngle(){return this.Uc}set sweepAngle(t){this.Uc!==t&&(Util.t(t,"number",CircularLayout,"sweepAngle"),t>0&&t<=360?this.Uc=t:this.Uc=360,this.invalidateLayout())}get arrangement(){return this.qi}set arrangement(t){this.qi!==t&&(Util.tt(t,CircularArrangement,"CircularArrangement"),(t===3||t===0||t===1||t===2)&&(this.qi=t,this.invalidateLayout()))}get direction(){return this.C}set direction(t){this.C!==t&&(Util.tt(t,CircularDirection,"CircularDirection"),(t===10||t===11||t===12||t===13)&&(this.C=t,this.invalidateLayout()))}get sorting(){return this.ke}set sorting(t){this.ke!==t&&(Util.tt(t,CircularSorting,"CircularSorting"),this.ke=t,this.invalidateLayout())}get comparer(){return this.Se}set comparer(t){this.Se!==t&&(Util.t(t,"function",CircularLayout,"comparer"),this.Se=t,this.invalidateLayout())}get spacing(){return this.Rn}set spacing(t){this.Rn!==t&&(Util.t(t,"number",CircularLayout,"spacing"),this.Rn=t,this.invalidateLayout())}get nodeDiameterFormula(){return this.Pg}set nodeDiameterFormula(t){this.Pg!==t&&(Util.tt(t,CircularNodeDiameterFormula,"CircularNodeDiameterFormula"),(t===30||t===31)&&(this.Pg=t,this.invalidateLayout()))}get actualXRadius(){return this.ue}get actualYRadius(){return this.Ns}get actualSpacing(){return this.Rh}get actualCenter(){return this.BN}static ConstantSpacing=0;static ConstantDistance=1;static ConstantAngle=2;static Packed=3;static Clockwise=10;static Counterclockwise=11;static BidirectionalLeft=12;static BidirectionalRight=13;static Forwards=20;static Reverse=21;static Ascending=22;static Descending=23;static Optimized=24;static Pythagorean=30;static Circular=31}class VertexArrangement{Gc;tf;Hc;constructor(){this.Gc=-1/0,this.tf=null,this.Hc=null}GO(t,i){if(t>0&&this.Gc<0||Math.abs(t)0)){this.Gc=t,this.tf=[],this.Hc=[];for(let e=0;e0){for(this.network.deleteSelfEdges(),i=this.network.vertexes.iterator;i.next();){const o=i.value;o.charge=this.electricalCharge(o),o.mass=this.gravitationalMass(o)}const s=this.network.edges.iterator;for(;s.next();){const o=s.value;o.stiffness=this.springStiffness(o),o.length=this.springLength(o)}if(this.YN(),this.Oh=0,this.needsPrelayout()){const o=this.network,r=o.splitIntoSubNetworks(!1);let l=r.iterator;for(;l.next();){const h=l.value;this.doConnectedSubnetLayout(h)}for(l=r.iterator,this.vO(l,o),l=r.iterator;l.next();){const h=l.value,a=h.vertexes.iterator;for(;a.next();){const c=a.value;o.addVertex(c)}const f=h.edges.iterator;for(;f.next();){const c=f.value;o.addEdge(c)}}}else this.eD(this.network,this.maxIterations);this.updateParts()}this.maxIterations=e,this.isValidLayout=!0}needsPrelayout(){if(this.network.vertexes.count<3)return!1;let t=0,i=0;const e=this.network.vertexes.first().bounds,s=this.network.vertexes.iterator;for(;s.next();){const n=s.value,o=n.bounds;if(isNaN(n.x)||isNaN(n.y)||o.intersectsRect(e)&&(t++,t>2))return!0;if(i>10)return!1;i++}return!1}doConnectedSubnetLayout(t){let i=t.vertexes.iterator;for(;i.next();){const l=i.value;l.hierarchicalVertexes.add(l)}let e=t,s=this.Zc;if(isNaN(s)&&(s=t.edges.count/t.vertexes.count),sMath.max(100,Math.sqrt(s*t.vertexes.count));)e=this.coarsenNetwork(e);let n=0;i=e.vertexes.iterator;let o=this.randomNumberGenerator;for(o===null&&(this.randomNumberGenerator=o=new RandomNumberGenerator(0));i.next();){i.value.idInCluster=n++;const l=10*(o.random()-.5),h=10*(o.random()-.5);this.isFixed(i.value)||(i.value.x=l,i.value.y=h);const a=i.value.hierarchicalVertexes.iterator;for(;a.next();)this.isFixed(a.value)||(a.value.x=l,a.value.y=h)}const r=this.computePairwiseDistances(e);this.JO(e,r,this.maxPrelayoutIterations,t.vertexes.count),this.eD(t,this.maxIterations)}computePairwiseDistances(t){const i=t.vertexes.count,e=new Array(i);for(let r=0;r0;){const l=o.shift(),h=l.vertexes.iterator;for(;h.next();){const a=h.value;n.has(a.idInCluster)||(n.set(a.idInCluster,n.get(l.idInCluster)+1),o.push(a))}}for(let l=0;l=0;m--)if(t[m].y>f.y&&t[m].x-f.xf.x&&t[m].y-f.ya+c){const u=s+o-h,d=n-a-c;return Geo.Aw(u*u+d*d)}else if(n+rh+f)if(n>a+c){const u=s-h-f,d=n-a-c;return Geo.Aw(u*u+d*d)}else if(n+ra+c?n-(a+c):n+rr-o;l?i.sort((m,g)=>m===null||g===null||m===g?0:m.centerX-g.centerX):i.sort((m,g)=>m===null||g===null||m===g?0:m.centerY-g.centerY);const h=this.qc;let a=0,f=0,c=0;for(let m=0;mh||C-x>h){if(l)break;continue}if(k-P>h||P-k>h){if(!l)break;continue}const N=this.KN(g,S),T=2*g.charge,L=2*S.charge;if(N>1)a=T*L/(N*N),f=a*(x-C)/N,c=a*(k-P)/N;else{let D=this.randomNumberGenerator;D===null&&(this.randomNumberGenerator=D=new RandomNumberGenerator(0));const F=D.random(),R=D.random();if(x>C)f=Math.abs(S.bounds.right-g.bounds.x),f=T*L*(1+f)*F;else if(xP)c=Math.abs(S.bounds.bottom-g.bounds.y),c=T*L*(1+c)*R;else if(x1&&(a=.1*m.stiffness*(P-m.length),f=a*.5*(g.width+p.height)*(k-A)/P,c=a*.5*(g.width+p.height)*(b-C)/P),g.forceX-=f,g.forceY-=c,p.forceX+=f,p.forceY+=c}let d=0;for(let m=0;mthis.epsilonDistance*this.epsilonDistance}JO(t,i,e,s){Debug&&Util.r(e,ForceDirectedLayout,"performIterations:num");const n=this.Oh+e,o=Math.sqrt(s);this.qy=this.ef*t.vertexes.count;const r=t.vertexes.toArray();let l=0,h=0,a=0;for(;this.Oh0){r[f].forceX=this.qy*r[f].forceX/c,r[f].forceY=this.qy*r[f].forceY/c,this.isFixed(r[f])||(r[f].x+=r[f].forceX,r[f].y+=r[f].forceY);const u=r[f].hierarchicalVertexes.iterator;for(;u.next();){const d=u.value;this.isFixed(d)||(d.centerX+=r[f].forceX,d.centerY+=r[f].forceY)}}l+=c*c}if(l>=h){if(a++,a>=5)break}else a=0;this.qy*=.95}}moveVertex(t){let i=t.forceX,e=t.forceY;const s=this.moveLimit;return i<-s?i=-s:i>s&&(i=s),e<-s?e=-s:e>s&&(e=s),t.centerX+=i,t.centerY+=e,i*i+e*e}shouldInteract(t,i){return!0}moveFixedVertex(t){}commitLayout(){this.jy(),this.commitNodes(),this.isRouting&&this.commitLinks()}jy(){if(!this.setsPortSpots)return;const t=this.network.edges.iterator;for(;t.next();){const e=t.value.link;e!==null&&(e.fromSpot=Spot.Default,e.toSpot=Spot.Default)}}commitNodes(){let t=0,i=0;if(this.arrangesToOrigin){const n=Rect.a();this.Rw(this.network,n);const o=this.arrangementOrigin;t=o.x-n.x,i=o.y-n.y,Rect.o(n)}const e=Rect.a(),s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;(t!==0||i!==0)&&(e.c(n.bounds),e.x+=t,e.y+=i,n.bounds=e),n.commit()}Rect.o(e)}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}springStiffness(t){const i=t.stiffness;return isNaN(i)?this.jc:i}springLength(t){const i=t.length;return isNaN(i)?this.Wc:i}electricalCharge(t){const i=t.charge;return isNaN(i)?this.vc:i}electricalFieldX(t,i){return 0}electricalFieldY(t,i){return 0}gravitationalMass(t){const i=t.mass;return isNaN(i)?this.Jc:i}gravitationalFieldX(t,i){return 0}gravitationalFieldY(t,i){return 0}isFixed(t){return t.isFixed}get currentIteration(){return this.Oh}get arrangementSpacing(){return this.Cs}set arrangementSpacing(t){Util.s(t,Size,ForceDirectedLayout,"arrangementSpacing"),this.Cs.equals(t)||(this.Cs.c(t),this.invalidateLayout())}get arrangesToOrigin(){return this.Ng}set arrangesToOrigin(t){this.Ng!==t&&(Util.t(t,"boolean",ForceDirectedLayout,"arrangesToOrigin"),this.Ng=t,this.invalidateLayout())}get setsPortSpots(){return this.Bn}set setsPortSpots(t){this.Bn!==t&&(Util.t(t,"boolean",ForceDirectedLayout,"setsPortSpots"),this.Bn=t,this.invalidateLayout())}get comments(){return this.Ve}set comments(t){this.Ve!==t&&(Util.t(t,"boolean",ForceDirectedLayout,"comments"),this.Ve=t,this.invalidateLayout())}get maxPrelayoutIterations(){return this.Cg}set maxPrelayoutIterations(t){this.Cg!==t&&(Util.t(t,"number",ForceDirectedLayout,"maxPrelayoutIterations"),t>=0&&(this.Cg=t,this.invalidateLayout()))}get maxIterations(){return this.Ag}set maxIterations(t){this.Ag!==t&&(Util.t(t,"number",ForceDirectedLayout,"maxIterations"),t>=0&&(this.Ag=t,this.invalidateLayout()))}get epsilonDistance(){return this.Lg}set epsilonDistance(t){this.Lg!==t&&(Util.t(t,"number",ForceDirectedLayout,"epsilonDistance"),t>0&&(this.Lg=t,this.invalidateLayout()))}get infinityDistance(){return this.qc}set infinityDistance(t){this.qc!==t&&(Util.t(t,"number",ForceDirectedLayout,"infinityDistance"),t>1&&(this.qc=t,this.invalidateLayout()))}get moveLimit(){return this.Tg}set moveLimit(t){this.Tg!==t&&(Util.t(t,"number",ForceDirectedLayout,"moveLimit"),this.Tg=t,this.invalidateLayout())}get randomNumberGenerator(){return this.Dg}set randomNumberGenerator(t){this.Dg!==t&&(t!==null&&typeof t.random!="function"&&Util.n('ForceDirectedLayout.randomNumberGenerator must have a "random()" function on it: '+t),this.Dg=t)}get defaultSpringStiffness(){return this.jc}set defaultSpringStiffness(t){this.jc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultSpringStiffness"),this.jc=t,this.invalidateLayout())}get defaultSpringLength(){return this.Wc}set defaultSpringLength(t){this.Wc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultSpringLength"),this.Wc=t,this.invalidateLayout())}get defaultElectricalCharge(){return this.vc}set defaultElectricalCharge(t){this.vc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultElectricalCharge"),this.vc=t,this.invalidateLayout())}get defaultGravitationalMass(){return this.Jc}set defaultGravitationalMass(t){this.Jc!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultGravitationalMass"),this.Jc=t,this.invalidateLayout())}get defaultCommentSpringLength(){return this.Fg}set defaultCommentSpringLength(t){this.Fg!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultCommentSpringLength"),this.Fg=t,this.invalidateLayout())}get defaultCommentElectricalCharge(){return this.Rg}set defaultCommentElectricalCharge(t){this.Rg!==t&&(Util.t(t,"number",ForceDirectedLayout,"defaultCommentElectricalCharge"),this.Rg=t,this.invalidateLayout())}get prelayoutQuality(){return this.Zc}set prelayoutQuality(t){this.Zc!==t&&(Util.t(t,"number",ForceDirectedLayout,"prelayoutQuality"),this.Zc=t,this.invalidateLayout())}get prelayoutSpread(){return this.ef}set prelayoutSpread(t){this.ef!==t&&(Util.t(t,"number",ForceDirectedLayout,"prelayoutSpread"),this.ef=t,this.invalidateLayout())}}class ForceDirectedNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new ForceDirectedVertex(this)}createEdge(){return new ForceDirectedEdge(this)}}class ForceDirectedVertex extends LayoutVertex{Zb;$b;Qb;_b;tk;hierarchicalVertexes;idInCluster;constructor(t){super(t),this.Zb=!1,this.$b=NaN,this.Qb=NaN,this._b=0,this.tk=0,this.hierarchicalVertexes=new List,this.idInCluster=-1}get isFixed(){return this.Zb}set isFixed(t){this.Zb!==t&&(Util.t(t,"boolean",ForceDirectedVertex,"isFixed"),this.Zb=t)}get charge(){return this.$b}set charge(t){this.$b!==t&&(Util.t(t,"number",ForceDirectedVertex,"charge"),this.$b=t)}get mass(){return this.Qb}set mass(t){this.Qb!==t&&(Util.t(t,"number",ForceDirectedVertex,"mass"),this.Qb=t)}get forceX(){return this._b}set forceX(t){this._b!==t&&(Util.t(t,"number",ForceDirectedVertex,"forceX"),this._b=t)}get forceY(){return this.tk}set forceY(t){this.tk!==t&&(Util.t(t,"number",ForceDirectedVertex,"forceY"),this.tk=t)}}class ForceDirectedEdge extends LayoutEdge{ik;ek;constructor(t){super(t),this.ik=NaN,this.ek=NaN}get stiffness(){return this.ik}set stiffness(t){this.ik!==t&&(Util.t(t,"number",ForceDirectedEdge,"stiffness"),this.ik=t)}get length(){return this.ek}set length(t){this.ek!==t&&(Util.t(t,"number",ForceDirectedEdge,"length"),this.ek=t)}}class RandomNumberGenerator{I;R;Q;M;A;seed;constructor(t){t===void 0&&(t=42),this.seed=t,this.A=48271,this.M=2147483647,this.Q=this.M/this.A,this.R=this.M%this.A,this.I=1/this.M,this.random()}random(){const t=this.seed/this.Q,i=this.seed%this.Q,e=this.A*i-this.R*t;return e>0?this.seed=e:this.seed=e+this.M,this.seed*this.I}}var LayeredDigraphCycleRemove=(w=>(w[w.DepthFirst=0]="DepthFirst",w[w.Greedy=1]="Greedy",w[w.FromLayers=2]="FromLayers",w))(LayeredDigraphCycleRemove||{}),LayeredDigraphLayering=(w=>(w[w.OptimalLinkLength=10]="OptimalLinkLength",w[w.LongestPathSink=11]="LongestPathSink",w[w.LongestPathSource=12]="LongestPathSource",w))(LayeredDigraphLayering||{}),LayeredDigraphInit=(w=>(w[w.DepthFirstOut=20]="DepthFirstOut",w[w.DepthFirstIn=21]="DepthFirstIn",w[w.Naive=22]="Naive",w))(LayeredDigraphInit||{}),LayeredDigraphAggressive=(w=>(w[w.None=30]="None",w[w.Less=31]="Less",w[w.More=32]="More",w))(LayeredDigraphAggressive||{}),LayeredDigraphPack=(w=>(w[w.None=0]="None",w[w.Expand=1]="Expand",w[w.Straighten=2]="Straighten",w[w.Median=4]="Median",w[w.MaybeExpand=8]="MaybeExpand",w[w.All=15]="All",w))(LayeredDigraphPack||{}),LayeredDigraphAlign=(w=>(w[w.None=0]="None",w[w.UpperLeft=1]="UpperLeft",w[w.UpperRight=2]="UpperRight",w[w.LowerLeft=4]="LowerLeft",w[w.LowerRight=8]="LowerRight",w[w.All=15]="All",w))(LayeredDigraphAlign||{});class LayeredDigraphLayout extends Layout{As;te;C;$c;Qc;_c;sf;tu;ar;iu;Bn;Lt;Wy;Wt;Ig;Ls;pi;nn;Ts;Ds;Gt;Og;nf;Eg;on;eu;fr;Vn;zn;UN;constructor(t){super(),this.As=25,this.te=25,this.C=0,this.$c=0,this.Qc=10,this._c=20,this.sf=4,this.tu=31,this.ar=15,this.iu=10,this.Bn=!0,this.Lt=-1,this.Wy=-1,this.Wt=-1,this.Ig=0,this.Ls=0,this.pi=null,this.nn=null,this.Ts=null,this.Ds=null,this.Gt=null,this.Og=0,this.nf=null,this.Eg=null,this.on=0,this.eu=null,this.fr=new Point,this.Vn=[],this.Vn.length=100,this.zn=15,this.UN=0,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.As=this.As,t.te=this.te,t.C=this.C,t.$c=this.$c,t.Qc=this.Qc,t._c=this._c,t.sf=this.sf,t.tu=this.tu,t.ar=this.ar,t.iu=this.iu,t.Bn=this.Bn,t.zn=this.zn}fi(t){t in LayeredDigraphAggressive?this.aggressiveOption=t:t in LayeredDigraphCycleRemove?this.cycleRemoveOption=t:t in LayeredDigraphInit?this.initializeOption=t:t in LayeredDigraphLayering?this.layeringOption=t:super.fi(t)}createNetwork(){return new LayeredDigraphNetwork(this)}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin),this.$O(),this.network.vertexes.count>0&&(this.network.deleteSelfEdges(),this.cycleRemoveOption!==2&&this.removeCycles(),this.QO(),this.cycleRemoveOption===2&&this.removeCycles(),this._O(),this.t3(),this.i3(),this.reduceCrossings(),this.straightenAndPack(),this.updateParts()),this.network=null,this.isValidLayout=!0}linkMinLength(t){return 1}linkLengthWeight(t){return 1}linkStraightenWeight(t){const i=t.fromVertex.node||t.fromVertex.data,e=t.toVertex.node||t.toVertex.data;return i===null&&e===null?8:i===null||e===null?4:1}nodeMinLayerSpace(t,i){return t.node===null&&t.data===null?0:this.C===90||this.C===270?i?t.focus.y+10:t.bounds.height-t.focus.y+10:i?t.focus.x+10:t.bounds.width-t.focus.x+10}nodeMinColumnSpace(t,i){if(t.node===null&&t.data===null)return 0;const e=i?t.sk:t.nk;if(e!==null)return e;const s=this.C;return s===90||s===270?i?t.sk=t.focus.x/this.te+1|0:t.nk=(t.bounds.width-t.focus.x)/this.te+1|0:i?t.sk=t.focus.y/this.te+1|0:t.nk=(t.bounds.height-t.focus.y)/this.te+1|0}ie(){this.nf===null&&(this.nf=[]);let t=0;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;this.nf[t]=e.layer,t++,this.nf[t]=e.column,t++,this.nf[t]=e.index,t++}return this.nf}es(t){let i=0;const e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;s.layer=t[i],i++,s.column=t[i],i++,s.index=t[i],i++}}nD(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"crossingMatrix:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"crossingMatrix:direction"));const e=this.Eh(t),s=this.pi[t];(this.Eg===null||this.Eg.length=0){for(f=e[o].So,c=0;ck||d===k&&g>S)&&r++,bd||k===d&&S>g)&&r++)}if(i<=0){for(f=e[o].rr,c=0;ck||d===k&&m>b)&&r++,Sd||k===d&&b>m)&&r++)}for(n[o*s+o]=r,a=o+1;a=0){for(p=e[o].So,M=e[a].So,c=0;c=0&&(h=s[r].rr);let a,f=0,c=0;if(l!==null)for(let u=0;u=0&&(h=r.rr);let a=0,f=0;const c=r.near;c!==null&&c.layer===r.layer&&(a+=c.column-1,f++);let u;if(l!==null)for(let d=0;d=0&&(h=r.rr);let a=0;const f=[],c=r.near;c!==null&&c.layer===r.layer&&(f[a]=c.column-1,a++);let u;if(l!==null)for(let d=0;dm-g);const d=a>>1;a&1?n[o]=f[d]:n[o]=f[d-1]+f[d]>>1}}return this.Bh(t,e),n}Zy(t,i,e,s,n){if(t.component===e){t.component=i;let o=0,r=0;if(s){const l=t.destinationEdges;for(;l.next();){const h=l.value,a=h.toVertex;o=t.layer-a.layer,r=this.linkMinLength(h),o===r&&this.Zy(a,i,e,s,n)}}if(n){const l=t.sourceEdges;for(;l.next();){const h=l.value,a=h.fromVertex;o=a.layer-t.layer,r=this.linkMinLength(h),o===r&&this.Zy(a,i,e,s,n)}}}}GN(t,i,e,s,n){if(t.component===e){if(t.component=i,s){const o=t.destinationEdges;for(;o.next();){const l=o.value.toVertex;this.GN(l,i,e,s,n)}}if(n){const o=t.sourceEdges;for(;o.next();){const l=o.value.fromVertex;this.GN(l,i,e,s,n)}}}}removeCycles(){const t=this.network.edges.iterator;for(;t.next();){const i=t.value;i.rev=!1}switch(this.$c){default:case 1:this.s3();break;case 0:this.o3();break;case 2:this.r3();break}}r3(){const t=this.network,i=t.vertexes.iterator;let e=1/0;for(;i.next();){const s=i.value;e=Math.min(e,s.layer)}if(e<1/0){if(e<0)for(i.reset();i.next();){const r=i.value;r.layer-=e}const s=[];for(i.reset();i.next();){const r=i.value,l=s[r.layer];l===void 0?s[r.layer]=[r]:l.push(r)}let n=0;for(let r=0;r0)for(let h=0;hh.index&&(t.reverseEdge(r),r.rev=!0)}}l3(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.ee)return e}return null}rD(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.ee){let s=!0;const n=e.destinationEdges;for(;n.next();)if(n.value.toVertex.ee){s=!1;break}if(s)return e}}return null}lD(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.ee){let s=!0;const n=e.sourceEdges;for(;n.next();)if(n.value.fromVertex.ee){s=!1;break}if(s)return e}}return null}h3(t){let i=null,e=0;const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;if(n.ee){let o=0;const r=n.destinationEdges;for(;r.next();)r.value.toVertex.ee&&o++;let l=0;const h=n.sourceEdges;for(;h.next();)h.value.fromVertex.ee&&l++;(i===null||ef&&this.Zy(h,e,-1,!0,!1)}for(this.Zy(t,s,-1,!0,!0);t.component!==e;){let r=0,l=1/0,h=0,a=null;const f=this.network.vertexes.iterator;for(;f.next();){const c=f.value;if(c.component===s){let u=0,d=!1;const m=c.So;o=m.length;for(let p=0;p0){for(i.reset();i.next();){const c=i.value;c.component===s&&(c.layer+=l)}t.component=e}else a.component=e}}u3(t){const i=this.network.vertexes.iterator;for(;i.next();){const n=i.value;n.component=-1}const e=0,s=1;for(this.Zy(t,s,-1,!0,!1);t.component!==e;){let n=0,o=1/0,r=0,l=null;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value;if(a.component===s){let f=0,c=!1;const u=a.So;let d=u.length;for(let g=0;gr)&&!c&&(l=a,r=f)}}if(n<0){for(i.reset();i.next();){const a=i.value;a.component===s&&(a.layer-=o)}t.component=e}else l.component=e}}_O(){const t=this.network,i=[],e=t.edges.iterator;for(;e.next();){const s=e.value;s.valid=!1,i.push(s)}for(let s=0;sb&&c>0){for(n.valid=!1,y=t.createVertex(),y.node=null,y.rk=2,y.layer=c-1,x&&kb&&c>0;)y=t.createVertex(),y.node=null,y.rk=3,y.layer=c-1,x&&kt[this.Ls]&&(this.Wy=t[e]-1,this.Ls=e),t[e]{o.index=this.pi[s],this.pi[s]++})}}p3(){let t=null;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;if(e.near&&(t===null&&(t=new Map),e.layer===e.near.layer)){const s=t.get(e.near)||[];s.push(e),t.set(e.near,s)}}for(let e=this.Lt;e>=0;e--)for(i.reset();i.next();){const s=i.value;s.layer===e&&s.index===-1&&this.gD(s,t)}}gD(t,i){if(t.near)return;const e=t.layer;if(t.index=this.pi[e],this.pi[e]++,i){const o=i.get(t);Array.isArray(o)&&o.forEach(r=>{r.index=this.pi[e],this.pi[e]++})}const s=t.rr;let n=!0;for(;n;){n=!1;for(let o=0;ol.portFromColOffset&&(n=!0,s[o]=l,s[o+1]=r)}}for(let o=0;o{a.index=this.pi[e],this.pi[e]++})}const s=t.So;let n=!0,o=0;for(;n;)for(n=!1,o=0;oa.portToColOffset&&(n=!0,s[o]=a,s[o+1]=h)}let r,l;for(o=0;o=0;s--)this.hk(s,-1),this.us(s,-1,!1,-1);n=this.countCrossings(),n=0;s--)this.hk(s,0),this.us(s,0,!1,0);n=this.countCrossings(),n=0;r--)for(l=0;l<=r;l++){for(o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,1,!1,1)||o;for(n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,-1,!1,-1)||o;for(n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,0,!1,0)||o;for(n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,0,!1,0)||o;n>=t?this.es(i):(t=n,i=this.ie())}break;default:case 31:for(r=this.Lt,l=0,h=t+1;(a=this.countCrossings())=l;s--)o=this.us(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,1,!1,1)||o;for(n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,-1,!1,-1)||o;for(n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.us(s,0,!1,0)||o;for(n>=t?this.es(i):(t=n,i=this.ie()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.us(s,0,!1,0)||o;n>=t?this.es(i):(t=n,i=this.ie())}break}this.es(i)}hk(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"medianBarycenterCrossingReduction:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"medianBarycenterCrossingReduction:direction"));let e=0,s=!1;const n=this.Eh(t),o=this.pi[t],r=this.oD(t,i),l=this.Jy(t,i);for(e=0;e0)for(h=[],l=0;ll+1&&(m+=4*(I-l),g+=4*(I-(l+1)))}}const B=n[l].destinationEdges.iterator;if(e&&s>=0)for(;B.next();){const W=B.value;O=W.toVertex,W.valid&&O.layer!==t&&(N=this.linkStraightenWeight(W),T=W.portFromColOffset,L=W.portToColOffset,F=O.column,C+=(Math.abs(p+T-(F+L))+1)*N,P+=(Math.abs(A+T-(F+L))+1)*N)}for(B.reset();B.next();){const W=B.value;if(O=W.toVertex,W.valid&&O.layer===t){for(V=0;Vl+1&&(m+=4*(I-(l+1)),g+=4*(I-l))}}const z=n[l+1].destinationEdges.iterator;if(e&&s>=0)for(;z.next();){const W=z.value;O=W.toVertex,W.valid&&O.layer!==t&&(N=this.linkStraightenWeight(W),T=W.portFromColOffset,L=W.portToColOffset,F=O.column,C+=(Math.abs(y+T-(F+L))+1)*N,P+=(Math.abs(M+T-(F+L))+1)*N)}for(z.reset();z.next();){const W=z.value;if(O=W.toVertex,W.valid&&O.layer===t){for(V=0;V1e3&&s&&(e=!1),e){const n=[];let o=0;for(o=0;o<=this.Lt;o++)n[o]=0;let r=0;const l=this.network.vertexes.iterator;for(;l.next();){const a=l.value;t=a.layer,r=a.column;const f=this.nodeMinColumnSpace(a,!1);n[t]=Math.max(n[t],r+f)}const h=8;for(l.reset();l.next();){const a=l.value;t=a.layer,r=a.column,a.column=((this.Wt-n[t])*h>>1)+r*h}this.Wt*=h}if(this.ar&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Bg(t,-1)||i;i=this.Bg(this.Ls,0)||i,n++}}if(this.ar&4){for(t=this.Ls+1;t<=this.Lt;t++)this.qN(t,1);for(t=this.Ls-1;t>=0;t--)this.qN(t,-1);this.qN(this.Ls,0)}if(e&&(this.pD(-1),this.pD(1)),this.ar&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Bg(t,0)||i;n++}}}Bg(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"bendStraighten:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"bendStraighten:direction"));let e=!1;for(;this.x3(t,i);)e=!0;return e}x3(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"shiftbendStraighten:unfixedLayer"),Util.r(i,LayeredDigraphLayout,"shiftbendStraighten:direction"));let e=0;const s=this.Eh(t),n=this.pi[t],o=this.Jy(t,-1);if(i>0)for(e=0;ef+this.nodeMinColumnSpace(s[e-1],!1)?u=a-1:u=a;let d=0;e+1>=n||s[e+1].column-a-1>c+this.nodeMinColumnSpace(s[e+1],!0)?d=a+1:d=a;let m=0,g=0,p=0,y=0,x=0,k=0;if(i<=0){const P=s[e].sourceEdges.iterator;for(;P.next();){const N=P.value,T=N.fromVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const L=T.column;m+=(Math.abs(a+k-(L+x))+1)*y,g+=(Math.abs(u+k-(L+x))+1)*y,p+=(Math.abs(d+k-(L+x))+1)*y}}}if(i>=0){const P=s[e].destinationEdges.iterator;for(;P.next();){const N=P.value,T=N.toVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const L=T.column;m+=(Math.abs(a+x-(L+k))+1)*y,g+=(Math.abs(u+x-(L+k))+1)*y,p+=(Math.abs(d+x-(L+k))+1)*y}}}let b=0,S=0,M=0;const A=o[s[e].index],C=r[s[e].index];A!==-1&&(b+=Math.abs(A-a),S+=Math.abs(A-u),M+=Math.abs(A-d)),C!==-1&&(b+=Math.abs(C-a),S+=Math.abs(C-u),M+=Math.abs(C-d)),g=r[e]?u=p:g<=r[e]&&(u=g)),u!==a&&(l=!0,h=!0,s[e].column=u)}return this.Bh(t,s),this.vy(),l}b3(){for(let t=0;t<=this.Wt;t++)for(;this.k3(t,1););this.vy()}k3(t,i){Debug&&(Util.r(t,LayeredDigraphLayout,"packAux:column"),Util.r(i,LayeredDigraphLayout,"packAux:direction"));let e=!0;const s=this.network.vertexes.iterator;for(;s.next();){const o=s.value,r=this.nodeMinColumnSpace(o,!0),l=this.nodeMinColumnSpace(o,!1);if(o.column-r<=t&&o.column+l>=t){e=!1;break}}let n=!1;if(e){if(i>0)for(s.reset();s.next();){const o=s.value;o.column>t&&(o.column-=1,n=!0)}if(i<0)for(s.reset();s.next();){const o=s.value;o.column0&&(e=t+1),i<0&&(e=t-1);let s=0;const n=[],o=[];for(s=0;s<=this.Lt;s++)n[s]=!1,o[s]=!1;const r=this.network.vertexes.iterator;for(;r.next();){const a=r.value,f=a.column-this.nodeMinColumnSpace(a,!0),c=a.column+this.nodeMinColumnSpace(a,!1);f<=t&&c>=t&&(n[a.layer]=!0),f<=e&&c>=e&&(o[a.layer]=!0)}let l=!0,h=!1;for(s=0;s<=this.Lt;s++)l=l&&!(n[s]&&o[s]);if(l){if(i>0)for(r.reset();r.next();){const a=r.value;a.column>t&&(a.column-=1,h=!0)}if(i<0)for(r.reset();r.next();){const a=r.value;a.column0)for(i=0;i<=this.Wt;i++)for(e=this.ie(),s=this.ok(!0),n=s+1;ss?this.es(e):o=0;i--)for(e=this.ie(),s=this.ok(!0),n=s+1;ss?this.es(e):o0)for(e.reset();e.next();){const f=e.value;f.column-this.nodeMinColumnSpace(f,!0)<=t&&(f.component=this.on)}if(i<0)for(e.reset();e.next();){const f=e.value;f.column+this.nodeMinColumnSpace(f,!1)>=t&&(f.component=this.on)}for(this.on++,e.reset();e.next();){const f=e.value;f.component===-1&&(this.GN(f,this.on,-1,!0,!0),this.on++)}let s=0;const n=[];for(s=0;s0)for(let c=0;c0;c--)o[f*(this.Wt+1)+c]!==-1&&o[f*(this.Wt+1)+c-1]!==-1&&o[f*(this.Wt+1)+c]!==o[f*(this.Wt+1)+c-1]&&(n[o[f*(this.Wt+1)+c]*this.on+o[f*(this.Wt+1)+c-1]]=!0)}const r=[];for(s=0;s0)for(e.reset();e.next();){const f=e.value;r[f.component]&&(f.column-=1,a=!0)}if(i<0)for(e.reset();e.next();){const f=e.value;r[f.component]&&(f.column+=1,a=!0)}return a}w3(){const t=Util.at(),i=this.eu.length;for(let u=0;u<=i;u++)t[u]=[];const e=this.network.vertexes.iterator;for(;e.next();){const u=e.value,d=i-u.layer,m=t[d];m[u.index]=u}const s=new GSet;this.P3(t,s);let n=null,o=null,r=null,l=null;const h=(this.zn&1)!==0,a=(this.zn&2)!==0,f=(this.zn&4)!==0,c=(this.zn&8)!==0;h&&(this.hl(t,s,!0),n=this.ak(t,!0,!1)),t.reverse(),f&&(this.hl(t,s,!1),r=this.ak(t,!1,!1));for(const u of t)u.reverse();c&&(this.hl(t,s,!1),l=this.ak(t,!1,!0)),t.reverse(),a&&(this.hl(t,s,!0),o=this.ak(t,!0,!0)),Util.nt(t),this.N3(n,o,r,l),this.network.vertexes.each(u=>{const d=u,m=Util.at();h&&m.push(n.get(d)),a&&m.push(o.get(d)),f&&m.push(r.get(d)),c&&m.push(l.get(d)),m.sort((k,b)=>k-b);const g=m.length,p=Math.floor((g-1)/2),y=Math.ceil((g-1)/2),x=(m[p]+m[y])/2;Util.nt(m),d.de=x})}P3(t,i){const e=t.length;for(let s=1;sc)&&i.add(m)}o++}n=c}}}}C3(t){if(t.node===null){const i=t.getProperSourceVertexes();if(i.length>0)return i[0].node===null}return!1}hl(t,i,e){this.A3(t);for(const s of t){let n=-1;for(const o of s){const r=e?o.getProperSourceVertexes():o.getProperDestinationVertexes(),l=r.length;if(l>0){r.sort((a,f)=>a.Vh-f.Vh);const h=(l-1)/2;for(let a=Math.floor(h),f=Math.ceil(h);a<=f;a++)if(o.Xn===o){const c=r[a];let u;e?u=c.getDestinationEdge(o):u=o.getDestinationEdge(c),!i.has(u)&&n0){const f=this.bD(a,t),c=s?f.width:f.height,u=a.ss.nu+a.de+a.Yn-(f.de+f.Yn+c+this.columnSpacing);f.ss.nu=Math.min(f.ss.nu,u)}h=a.Vh+1}while(l0){const s=this.bD(e,i),n=s.of;this.xD(n,i),t.ss===t&&(t.ss=n.ss);const o=this.C===90||this.C===270?s.width:s.height;if(t.ss===n.ss){const r=n.de+s.Yn+o-e.Yn+this.columnSpacing;t.de=Math.max(t.de,r)}}e=e.Xn}while(e!==t);for(;e.Xn!==t;)e=e.Xn,e.de=t.de,e.ss=t.ss}bD(t,i){const e=t.wD,s=t.Vh;return s<1&&Util.n("Could not determine previous vertex in layer"),i[e][s-1]}N3(...t){let i=-1;const e=Util.at(),s=Util.at();let n=1/0;for(let o=0;o<4;o++){if(!t[o])continue;const r=this.T3(t[o],e,s,o);r{r.set(h.key,h.value+l)})}Util.nt(e),Util.nt(s)}T3(t,i,e,s){if(!t||t.count===0)return i[s]=0,e[s]=0,1/0;let n=1/0,o=-1/0;return t.each(r=>{const l=r.key,h=r.value,a=this.C===90||this.C===270?l.width:l.height;ho&&(o=h+a)}),i[s]=n,e[s]=o,o-n}commitLayout(){this.jy(),this.commitNodes(),this.jN(),this.isRouting&&this.commitLinks()}jy(){if(!this.setsPortSpots)return;const t=this.lk(!0),i=this.lk(!1),e=this.network.edges.iterator;for(;e.next();){const n=e.value.link;n!==null&&(n.fromSpot=t,n.toSpot=i)}}lk(t){return this.C===270?t?Spot.MiddleTop:Spot.MiddleBottom:this.C===90?t?Spot.MiddleBottom:Spot.MiddleTop:this.C===180?t?Spot.MiddleLeft:Spot.MiddleRight:t?Spot.MiddleRight:Spot.MiddleLeft}commitNodes(){this.nn=[],this.Ts=[],this.Ds=[],this.Gt=[];for(let d=0;d<=this.Lt;d++)this.nn[d]=0,this.Ts[d]=0,this.Ds[d]=0,this.Gt[d]=0;const t=this.network.vertexes.iterator;for(;t.next();){const d=t.value,m=d.layer;this.nn[m]=Math.max(this.nn[m],this.nodeMinLayerSpace(d,!0)),this.Ts[m]=Math.max(this.Ts[m],this.nodeMinLayerSpace(d,!1))}let i=0;const e=this.As;for(let d=0;d<=this.Lt;d++){let m=e;this.nn[d]+this.Ts[d]<=0&&(m=0),d>0&&(i+=m/2),this.C===90||this.C===0?(i+=this.Ts[d],this.Ds[d]=i,i+=this.nn[d]):(i+=this.nn[d],this.Ds[d]=i,i+=this.Ts[d]),d=0;n--)this.C===270?n===0?e.push(new Rect(0,0,s,Math.abs(this.Gt[0]))):e.push(new Rect(0,this.Gt[n-1],s,Math.abs(this.Gt[n-1]-this.Gt[n]))):this.C===90?n===0?e.push(new Rect(0,this.Gt[0],s,Math.abs(this.Gt[0]-t))):e.push(new Rect(0,this.Gt[n],s,Math.abs(this.Gt[n-1]-this.Gt[n]))):this.C===180?n===0?e.push(new Rect(0,0,Math.abs(this.Gt[0]),s)):e.push(new Rect(this.Gt[n-1],0,Math.abs(this.Gt[n-1]-this.Gt[n]),s)):n===0?e.push(new Rect(this.Gt[0],0,Math.abs(this.Gt[0]-t),s)):e.push(new Rect(this.Gt[n],0,Math.abs(this.Gt[n-1]-this.Gt[n]),s));this.commitLayers(e,this.fr)}commitLayers(t,i){}commitLinks(){const t=this.network.edges.iterator;let i;for(;t.next();)i=t.value.link,i!==null&&(i.startRoute(),i.clearPoints(),i.commitRoute());for(t.reset();t.next();)i=t.value.link,i!==null&&i.updateRoute();for(t.reset();t.next();){const e=t.value;if(i=e.link,i===null||i.pointsCount===0)continue;i.startRoute();const s=i;let n=s.fromNode,o=s.toNode,r=s.fromPort,l=s.toPort;if(n!==null){const N=n.findVisibleNode();N!==null&&N!==n&&(n=N,r=N.port)}if(o!==null){const N=o.findVisibleNode();N!==null&&N!==o&&(o=N,l=N.port)}const h=i.computeSpot(!0,r),a=i.computeSpot(!1,l);let f=e.fromVertex,c=e.toVertex;if(e.valid){if(i.curve===9&&i.pointsCount===4)if(f.column===c.column&&this.alignOption===0){const N=i.getLinkPoint(n,r,h,!0,!1,o,l),T=i.getLinkPoint(o,l,a,!1,!1,n,r);N.isReal()||N.set(n.actualBounds.center),T.isReal()||T.set(o.actualBounds.center),i.clearPoints(),i.addPointAt(N.x,N.y),i.addPointAt((2*N.x+T.x)/3,(2*N.y+T.y)/3),i.addPointAt((N.x+2*T.x)/3,(N.y+2*T.y)/3),i.addPointAt(T.x,T.y)}else{let N=!1,T=!1;if(r!==null&&h===Spot.None&&(N=!0),l!==null&&a===Spot.None&&(T=!0),N||T){let L=null;N&&(L=i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0),L.isReal()||L.set(n.actualBounds.center),i.setPointAt(0,L.x,L.y));let D=null;if(T&&(D=i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(0),!1),D.isReal()||D.set(o.actualBounds.center),i.setPointAt(3,D.x,D.y)),L){const F=i.getPoint(2);i.setPointAt(1,(L.x*2+F.x)/3,(L.y*2+F.y)/3)}if(D){const F=i.getPoint(1);i.setPointAt(2,(D.x*2+F.x)/3,(D.y*2+F.y)/3)}}}i.commitRoute();continue}if(f.layer===c.layer){i.commitRoute();continue}let u=!1,d=!1;const m=this.As;let g=0,p=i.firstPickIndex+1;if(i.isOrthogonal)d=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3);else if(i.curve===9)u=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3),g===4&&(p=2);else{g=i.pointsCount;const N=h===Spot.None,T=a===Spot.None;g>2&&N&&T?i.points.removeRange(1,g-2):g>3&&N&&!T?i.points.removeRange(1,g-3):g>3&&!N&&T?i.points.removeRange(2,g-2):g>4&&!N&&!T&&i.points.removeRange(2,g-3)}let y,x,k=0,b=0,S=0,M=0,A=0,C=0,P=0;if(e.rev){let N=0;for(;c!==null&&f!==c;){y=null,x=null;const T=c.sourceEdges.iterator;for(;T.next();){const L=T.value;if(L.link===e.link&&(y=L.fromVertex,x=L.toVertex,y.node===null))break}if(y===null)break;if(y!==f)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=y.centerX,M=y.centerY,d)this.C===180||this.C===0?p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,k,M)):(x!==null?x.centerY:b)!==M&&(A=this.Gt[y.layer-1]+this.fr.x,i.insertPointAt(p++,A,b),i.insertPointAt(p++,A,M)):p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,S,b)):(x!==null?x.centerX:k)!==S&&(A=this.Gt[y.layer-1]+this.fr.y,i.insertPointAt(p++,k,A),i.insertPointAt(p++,S,A));else if(p===i.firstPickIndex+1)if(C=Math.max(10,this.nn[c.layer]),P=Math.max(10,this.Ts[c.layer]),u)this.C===180?S<=c.bounds.x?(N=c.bounds.x,i.insertPointAt(p++,N-C,M),i.insertPointAt(p++,N,M),i.insertPointAt(p++,N+P,M)):(i.insertPointAt(p++,S-C,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S+P,M)):this.C===90?M>=c.bounds.bottom?(N=c.bounds.y+c.bounds.height,i.insertPointAt(p++,S,N+P),i.insertPointAt(p++,S,N),i.insertPointAt(p++,S,N-C)):(i.insertPointAt(p++,S,M+P),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M-C)):this.C===270?M<=c.bounds.y?(N=c.bounds.y,i.insertPointAt(p++,S,N-C),i.insertPointAt(p++,S,N),i.insertPointAt(p++,S,N+P)):(i.insertPointAt(p++,S,M-C),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M+P)):this.C===0&&(S>=c.bounds.right?(N=c.bounds.x+c.bounds.width,i.insertPointAt(p++,N+P,M),i.insertPointAt(p++,N,M),i.insertPointAt(p++,N-C,M)):(i.insertPointAt(p++,S+P,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S-C,M)));else{i.insertPointAt(p++,k,b);let L=0;this.C===180||this.C===0?((this.C===180?S>=c.bounds.right:S<=c.bounds.x)&&(L=(this.C===0?-C:P)/2),i.insertPointAt(p++,k+L,M)):((this.C===270?M>=c.bounds.bottom:M<=c.bounds.y)&&(L=(this.C===90?-C:P)/2),i.insertPointAt(p++,S,b+L)),i.insertPointAt(p++,S,M)}else C=Math.max(10,this.nn[y.layer]),P=Math.max(10,this.Ts[y.layer]),u?this.C===180?(i.insertPointAt(p++,S-C-m,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S+P+m,M)):this.C===90?(i.insertPointAt(p++,S,M+P+m),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M-C-m)):this.C===270?(i.insertPointAt(p++,S,M-C-m),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M+P+m)):(i.insertPointAt(p++,S+P+m,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S-C-m,M)):(this.C===180||this.C===90||this.C,i.insertPointAt(p++,S,M));c=y}if(l===null||h!==Spot.None||d)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=i.getPoint(p).x,M=i.getPoint(p).y,d){const T=this.Ts[f.layer];let L=0;this.C===180||this.C===0?(L=b,L>=f.bounds.y&&L<=f.bounds.bottom&&(this.C===180?S>=f.bounds.x:S<=f.bounds.right)&&(N=f.centerX+(this.C===180?-T:T),L=f.bounds.x&&L<=f.bounds.right&&(this.C===270?M>=f.bounds.y:M<=f.bounds.bottom)&&(N=f.centerY+(this.C===270?-T:T),L=f.bounds.x?(N=f.bounds.x+f.bounds.width,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N+P,b)):this.C===90&&M<=f.bounds.bottom?(N=f.bounds.y,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N-C)):this.C===270&&M>=f.bounds.y?(N=f.bounds.y+f.bounds.height,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N+P)):this.C===0&&S<=f.bounds.right&&(N=f.bounds.x,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N-C,b));else{C=Math.max(10,this.nn[f.layer]),P=Math.max(10,this.Ts[f.layer]);let T=0;this.C===180||this.C===0?((this.C===180?S<=f.bounds.x:S>=f.bounds.right)&&(T=(this.C===0?P:-C)/2),i.insertPointAt(p++,S+T,b)):((this.C===270?M<=f.bounds.y:M>=f.bounds.bottom)&&(T=(this.C===90?P:-C)/2),i.insertPointAt(p++,k,M+T)),i.insertPointAt(p++,S,M)}}else{for(;f!==null&&f!==c;){y=null,x=null;const N=f.destinationEdges.iterator;for(;N.next();){const T=N.value;if(T.link===e.link&&(y=T.toVertex,x=T.fromVertex,x.node!==null&&(x=null),y.node===null))break}if(y===null)break;y!==c&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=y.centerX,M=y.centerY,d?this.C===180||this.C===0?(x!==null?x.centerY:b)!==M&&(A=this.Gt[y.layer]+this.fr.x,p===i.firstPickIndex+1&&(this.C===0?A=Math.max(A,k):A=Math.min(A,k)),i.insertPointAt(p++,A,b),i.insertPointAt(p++,A,M)):(x!==null?x.centerX:k)!==S&&(A=this.Gt[y.layer]+this.fr.y,p===i.firstPickIndex+1&&(this.C===90?A=Math.max(A,b):A=Math.min(A,b)),i.insertPointAt(p++,k,A),i.insertPointAt(p++,S,A)):(C=Math.max(10,this.nn[y.layer]),P=Math.max(10,this.Ts[y.layer]),u?this.C===180?(i.insertPointAt(p++,S+P+m,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S-C-m,M)):this.C===90?(i.insertPointAt(p++,S,M-C-m),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M+P+m)):this.C===270?(i.insertPointAt(p++,S,M+P+m),i.insertPointAt(p++,S,Math.max(M+P-m/2,M)),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,Math.min(M-C+m/2,M)),i.insertPointAt(p++,S,M-C-m)):(i.insertPointAt(p++,S-C-m,M),i.insertPointAt(p++,Math.min(S-C+m/2,S),M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,S,M),i.insertPointAt(p++,Math.max(S+P-m/2,S),M),i.insertPointAt(p++,S+P+m,M)):this.C===180?(i.insertPointAt(p++,S+P,M),i.insertPointAt(p++,S-C,M)):this.C===90?(i.insertPointAt(p++,S,M-C),i.insertPointAt(p++,S,M+P)):this.C===270?(i.insertPointAt(p++,S,M+P),i.insertPointAt(p++,S,M-C)):(i.insertPointAt(p++,S-C,M),i.insertPointAt(p++,S+P,M)))),f=y}d&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,S=i.getPoint(p).x,M=i.getPoint(p).y,this.C===180||this.C===0?b!==M&&(this.C===0?A=Math.min(Math.max((S+k)/2,this.Gt[c.layer]+this.fr.x),S):A=Math.max(Math.min((S+k)/2,this.Gt[c.layer]+this.fr.x),S),i.insertPointAt(p++,A,b),i.insertPointAt(p++,A,M)):k!==S&&(this.C===90?A=Math.min(Math.max((M+b)/2,this.Gt[c.layer]+this.fr.y),M):A=Math.max(Math.min((M+b)/2,this.Gt[c.layer]+this.fr.y),M),i.insertPointAt(p++,k,A),i.insertPointAt(p++,S,A)))}if(s!==null&&u&&i.pointsCount>=4){if(r!==null){const N=h===Spot.None?i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0):i.getPoint(0);if(h===Spot.None){const T=i.getPoint(2),L=i.getPoint(3);this.direction===90||this.direction===270?(i.setPointAt(1,(N.x+T.x)/2,T.y),i.setPointAt(2,L.x,(T.y+L.y)/2)):(i.setPointAt(1,T.x,(N.y+T.y)/2),i.setPointAt(2,(T.x+L.x)/2,L.y))}N.isReal()||N.set(n.actualBounds.center),i.setPointAt(0,N.x,N.y)}if(l!==null){const N=a===Spot.None?i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(i.pointsCount-4),!1):i.getPoint(i.pointsCount-1);if(a===Spot.None){const T=i.getPoint(i.pointsCount-3),L=i.getPoint(i.pointsCount-4);this.direction===90||this.direction===270?(i.setPointAt(i.pointsCount-2,(N.x+T.x)/2,T.y),i.setPointAt(i.pointsCount-2,L.x,(T.y+L.y)/2)):(i.setPointAt(i.pointsCount-2,T.x,(N.y+T.y)/2),i.setPointAt(i.pointsCount-3,(T.x+L.x)/2,L.y))}N.isReal()||N.set(o.actualBounds.center),i.setPointAt(i.pointsCount-1,N.x,N.y)}}i.commitRoute(),e.commit()}}$O(){this.Wy=-1,this.Ig=0,this.Ls=0,this.nf=null,this.Eg=null,this.eu=null;for(let t=0;t=this.Vn.length){const n=[];for(let o=0;o=0&&(this.As=t,this.invalidateLayout()))}get columnSpacing(){return this.te}set columnSpacing(t){this.te!==t&&(Util.t(t,"number",LayeredDigraphLayout,"columnSpacing"),t>0&&(this.te=t,this.invalidateLayout()))}get direction(){return this.C}set direction(t){this.C!==t&&(Util.t(t,"number",LayeredDigraphLayout,"direction"),t===0||t===90||t===180||t===270?(this.C=t,this.invalidateLayout()):Util.n("LayeredDigraphLayout.direction must be 0, 90, 180, or 270"))}get cycleRemoveOption(){return this.$c}set cycleRemoveOption(t){this.$c!==t&&(Util.tt(t,LayeredDigraphCycleRemove,"LayeredDigraphCycleRemove"),(t===1||t===0||t===2)&&(this.$c=t,this.invalidateLayout()))}get layeringOption(){return this.Qc}set layeringOption(t){this.Qc!==t&&(Util.tt(t,LayeredDigraphLayering,"LayeredDigraphLayering"),(t===10||t===11||t===12)&&(this.Qc=t,this.invalidateLayout()))}get initializeOption(){return this._c}set initializeOption(t){this._c!==t&&(Util.tt(t,LayeredDigraphInit,"LayeredDigraphInit"),(t===20||t===21||t===22)&&(this._c=t,this.invalidateLayout()))}get iterations(){return this.sf}set iterations(t){this.sf!==t&&(Util.r(t,LayeredDigraphNetwork,"iterations"),t>=0&&(this.sf=t,this.invalidateLayout()))}get aggressiveOption(){return this.tu}set aggressiveOption(t){this.tu!==t&&(Util.tt(t,LayeredDigraphAggressive,"LayeredDigraphAggressive"),(t===30||t===31||t===32)&&(this.tu=t,this.invalidateLayout()))}get packOption(){return this.ar}set packOption(t){this.ar!==t&&(Util.t(t,"number",LayeredDigraphLayout,"packOption"),t>=0&&t<8&&(this.ar=t,this.invalidateLayout()))}get packIterations(){return this.iu}set packIterations(t){this.iu=t}get alignOption(){return this.zn}set alignOption(t){this.zn!==t&&(Util.t(t,"number",LayeredDigraphLayout,"align"),t>=0&&t<16&&(this.zn=t,this.invalidateLayout()))}get setsPortSpots(){return this.Bn}set setsPortSpots(t){this.Bn!==t&&(Util.t(t,"boolean",LayeredDigraphLayout,"setsPortSpots"),this.Bn=t,this.invalidateLayout())}get maxLayer(){return this.Lt}get maxIndex(){return this.Wy}get maxColumn(){return this.Wt}get minIndexLayer(){return this.Ig}get maxIndexLayer(){return this.Ls}static CycleDepthFirst=0;static CycleGreedy=1;static CycleFromLayers=2;static LayerOptimalLinkLength=10;static LayerLongestPathSink=11;static LayerLongestPathSource=12;static InitDepthFirstOut=20;static InitDepthFirstIn=21;static InitNaive=22;static AggressiveNone=30;static AggressiveLess=31;static AggressiveMore=32;static PackNone=0;static PackExpand=1;static PackStraighten=2;static PackMedian=4;static PackAll=15;static AlignNone=0;static AlignUpperLeft=1;static AlignUpperRight=2;static AlignLowerLeft=4;static AlignLowerRight=8;static AlignAll=15}class SegInfo{_o;D3;b1;F3;R3;Bt;$e;I3;constructor(){this._o=0,this.D3=0,this.b1=0,this.F3=0,this.R3=0,this.Bt=0,this.$e=null,this.I3=0}}class LayeredDigraphNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new LayeredDigraphVertex(this)}createEdge(){return new LayeredDigraphEdge(this)}}class LayeredDigraphVertex extends LayoutVertex{_o;Go;Bt;fk;ck;ee;su;$n;rk;sk;nk;of;Xn;wD;Vh;ss;nu;de;Yn;$y=null;Qy=null;_y=null;tw=null;constructor(t){super(t),this._o=-1,this.Go=-1,this.Bt=-1,this.fk=NaN,this.ck=null,this.ee=!1,this.su=NaN,this.$n=NaN,this.rk=0,this.sk=null,this.nk=null}static kD(t,i){return t.index-i.index}getProperSourceEdges(){if(!this._y){const t=[];for(const i of this.So){const e=i;e.valid&&t.push(e)}this._y=t}return this._y}getProperDestinationEdges(){if(!this.tw){const t=[];for(const i of this.rr){const e=i;e.valid&&t.push(e)}this.tw=t}return this.tw}getDestinationEdge(t){const i=this.getProperDestinationEdges();for(const e of i)if(e.toVertex===t)return e;Util.n("Unable to find destination edge to given vertex")}getProperSourceVertexes(){if(!this.$y){const t=[];for(const i of this.So){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.fromVertex)}t.sort(LayeredDigraphVertex.kD),this.$y=t}return this.$y}getProperDestinationVertexes(){if(!this.Qy){const t=[];for(const i of this.rr){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.toVertex)}t.sort(LayeredDigraphVertex.kD),this.Qy=t}return this.Qy}addSourceEdge(t){super.addSourceEdge(t),this.$y=null,this._y=null}deleteSourceEdge(t){super.deleteSourceEdge(t),this.$y=null,this._y=null}addDestinationEdge(t){super.addDestinationEdge(t),this.Qy=null,this.tw=null}deleteDestinationEdge(t){super.deleteDestinationEdge(t),this.Qy=null,this.tw=null}get layer(){return this._o}set layer(t){this._o!==t&&(Util.t(t,"number",LayeredDigraphVertex,"layer"),this._o=t)}get column(){return this.Go}set column(t){this.Go!==t&&(Util.t(t,"number",LayeredDigraphVertex,"column"),this.Go=t)}get index(){return this.Bt}set index(t){this.Bt!==t&&(Util.t(t,"number",LayeredDigraphVertex,"index"),this.Bt=t)}get component(){return this.fk}set component(t){this.fk!==t&&(Util.t(t,"number",LayeredDigraphVertex,"component"),this.fk=t)}get near(){return this.ck}set near(t){this.ck!==t&&(Debug&&t!==null&&Util.s(t,LayeredDigraphVertex,LayeredDigraphVertex,"near"),this.ck=t)}}class LayeredDigraphEdge extends LayoutEdge{ee;uk;dk;gk;mk;pk;yk;constructor(t){super(t),this.ee=!1,this.uk=!1,this.dk=!1,this.gk=NaN,this.mk=NaN,this.pk=0,this.yk=0}get fromVertex(){return this._e}set fromVertex(t){this._e!==t&&(Debug&&t!==null&&Util.s(t,LayeredDigraphVertex,LayeredDigraphEdge,"fromVertex"),this._e=t)}get toVertex(){return this.ts}set toVertex(t){this.ts!==t&&(Debug&&t!==null&&Util.s(t,LayeredDigraphVertex,LayeredDigraphEdge,"toVertex"),this.ts=t)}get valid(){return this.ee}set valid(t){this.ee!==t&&(Util.t(t,"boolean",LayeredDigraphEdge,"valid"),this.ee=t)}get rev(){return this.uk}set rev(t){this.uk!==t&&(Util.t(t,"boolean",LayeredDigraphEdge,"rev"),this.uk=t)}get forest(){return this.dk}set forest(t){this.dk!==t&&(Util.t(t,"boolean",LayeredDigraphEdge,"forest"),this.dk=t)}get portFromPos(){return this.gk}set portFromPos(t){this.gk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portFromPos"),this.gk=t)}get portToPos(){return this.mk}set portToPos(t){this.mk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portToPos"),this.mk=t)}get portFromColOffset(){return this.pk}set portFromColOffset(t){this.pk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portFromColOffset"),this.pk=t)}get portToColOffset(){return this.yk}set portToColOffset(t){this.yk!==t&&(Util.t(t,"number",LayeredDigraphEdge,"portToColOffset"),this.yk=t)}}var TreePath=(w=>(w[w.Default=0]="Default",w[w.Destination=1]="Destination",w[w.Source=2]="Source",w))(TreePath||{}),TreeSorting=(w=>(w[w.Forwards=10]="Forwards",w[w.Reverse=11]="Reverse",w[w.Ascending=12]="Ascending",w[w.Descending=13]="Descending",w))(TreeSorting||{}),TreeAlignment=(w=>(w[w.CenterSubtrees=20]="CenterSubtrees",w[w.CenterChildren=21]="CenterChildren",w[w.Start=22]="Start",w[w.End=23]="End",w[w.Bus=24]="Bus",w[w.BusBranching=25]="BusBranching",w[w.TopLeftBus=26]="TopLeftBus",w[w.BottomRightBus=27]="BottomRightBus",w[w.Custom=28]="Custom",w))(TreeAlignment||{}),TreeCompaction=(w=>(w[w.None=30]="None",w[w.Block=31]="Block",w))(TreeCompaction||{}),TreeStyle=(w=>(w[w.Layered=40]="Layered",w[w.LastParents=41]="LastParents",w[w.Alternating=42]="Alternating",w[w.RootOnly=43]="RootOnly",w))(TreeStyle||{}),TreeArrangement=(w=>(w[w.Vertical=50]="Vertical",w[w.Horizontal=51]="Horizontal",w[w.FixedRoots=52]="FixedRoots",w))(TreeArrangement||{}),TreeLayerStyle=(w=>(w[w.Individual=60]="Individual",w[w.Siblings=61]="Siblings",w[w.Uniform=62]="Uniform",w))(TreeLayerStyle||{});class TreeLayout extends Layout{Ei;Ii;ou;Vg;WN;Ve;qi;Cs;K;U;wk;ds;constructor(t){super(),this.Ei=new GSet,this.Ii=0,this.ds=1,this.ou=40,this.Vg=60,this.WN=[],this.Ve=!0,this.qi=50,this.Cs=new Size(10,10).w();const i=new TreeNetwork(this);this.K=new TreeVertex(i),this.U=new TreeVertex(i),this.wk=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Ii=this.Ii,t.ou=this.ou,t.Vg=this.Vg,t.Ve=this.Ve,t.qi=this.qi,t.Cs.c(this.Cs),t.K.copyInheritedPropertiesFrom(this.K),t.U.copyInheritedPropertiesFrom(this.U)}fi(t){t in TreeAlignment?this.alignment=t:t in TreeArrangement?this.arrangement=t:t in TreeCompaction?this.compaction=t:t in TreePath?this.path=t:t in TreeSorting?this.sorting=t:t in TreeStyle?this.treeStyle=t:super.fi(t)}createNetwork(){return new TreeNetwork(this)}makeNetwork(t){const i=this.createNetwork(),e=s=>{if(s instanceof Node)return!s.isLinkLabel&&s.category!=="Comment";if(s instanceof Link){const n=s.fromNode;if(n===null||n.isLinkLabel||n.category==="Comment")return!1;const o=s.toNode;return!(o===null||o.isLinkLabel||o.category==="Comment")}return!1};return t instanceof Diagram?(i.addParts(t.nodes,!0,e),i.addParts(t.links,!0,e)):t instanceof Group?i.addParts(t.memberParts,!1,e):i.addParts(t.iterator,!1,e),i}doLayout(t){Debug&&t===null&&Util.n("Layout.doLayout(collection) argument must not be null but a Diagram, a Group, or an Iterable of Parts"),this.network===null&&(this.network=this.makeNetwork(t)),this.arrangement!==52&&(this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin));let i=this.diagram;i===null&&t instanceof Diagram&&(i=t),this.path===0&&i!==null?this.ds=i.isTreePathToChildren?1:2:this.ds=this.path===0?1:this.path,this.network.vertexes.count>0&&(this.O3(),this.E3(),this.B3(),this.V3(),this.YN(),this.z3(),this.arrangeTrees(),this.updateParts()),this.network=null,this.Ei=new GSet,this.isValidLayout=!0}O3(){this.network.deleteSelfEdges();const t=this.network.vertexes.iterator;for(;t.next();){const n=t.value;n.initialized=!1,n.level=0,n.parent=null,n.children=[]}if(this.Ei.count>0){const n=new GSet,o=this.Ei.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=this.network.findVertex(r);l!==null&&n.add(l)}else r instanceof TreeVertex&&n.add(r)}this.Ei=n}this.Ei.count===0&&this.findRoots();const i=this.Ei.copy().iterator;for(;i.next();){const n=i.value;n.initialized||(n.initialized=!0,this.vN(n))}let e=this.network.vertexes,s=null;for(;s=this.X3(e),s.count>0;){const n=this.SD(s);n!==null&&this.Ei.add(n),n.initialized=!0,this.vN(n),e=s}}X3(t){const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;s.initialized||i.add(s)}return i}findRoots(){const t=this.network.vertexes,i=t.iterator;for(;i.next();){const e=i.value;switch(this.ds){case 1:e.sourceEdges.count===0&&this.Ei.add(e);break;case 2:e.destinationEdges.count===0&&this.Ei.add(e);break;default:Util.n("Unhandled path value "+this.ds.toString())}}if(this.Ei.count===0){const e=this.SD(t);e!==null&&this.Ei.add(e)}}SD(t){let i=999999,e=null;const s=t.iterator;for(;s.next();){const n=s.value;switch(this.ds){case 1:n.sourceEdges.count0){const s=new List,n=t.destinationVertexes;for(;n.next();){const o=n.value;this.MD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;case 2:if(t.sourceEdges.count>0){const s=new List,n=t.sourceVertexes;for(;n.next();){const o=n.value;this.MD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;default:Util.n("Unhandled path value"+this.ds.toString())}const i=t.children,e=i.length;for(let s=0;st.level?!1:(this.K3(i.parent,i),!0):!0}Y3(t,i){if(i===null)return!1;Debug&&Util.s(t,TreeVertex,TreeLayout,"isAncestor:a"),Debug&&Util.s(i,TreeVertex,TreeLayout,"isAncestor:b");let e=i.parent;for(;e!==null&&e!==t;)e=e.parent;return e===t}K3(t,i){if(t===null||i===null)return;Debug&&Util.s(t,TreeVertex,TreeLayout,"removeChild:p"),Debug&&Util.s(i,TreeVertex,TreeLayout,"removeChild:c");const e=t.children;let s=0;for(let n=0;n0){const n=new Array(e.length-s);let o=0;for(let r=0;r0?s+1:0}U3(t){switch(Debug&&Util.s(t,TreeVertex,TreeLayout,"mom:v"),this.ou){default:case 40:return t.parent!==null?t.parent:this.K;case 43:return t.parent===null?this.K:t.parent.parent===null?this.U:t.parent;case 42:return t.parent!==null?t.parent.parent!==null?t.parent.parent:this.U:this.K;case 41:{let i=!0;if(t.childrenCount===0)i=!1;else{const e=t.children,s=e.length;for(let n=0;n0){i=!1;break}}return i&&t.parent!==null?this.U:t.parent!==null?t.parent:this.K}}}initializeTreeVertexValues(t){Debug&&Util.s(t,TreeVertex,TreeLayout,"initializeTreeVertexValues:v");const i=this.U3(t);if(t.copyInheritedPropertiesFrom(i),t.parent!==null&&t.parent.alignment===25){let e=t.angle;const s=t.parent.children;let n=0;for(;n135&&!l||a&&c)if(t.commentMargin>=0){g.e(t.bounds.x-t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleLeft,S.toSpot=Spot.MiddleRight}}else{g.e(t.bounds.x+t.focus.x*2-t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleRight,S.toSpot=Spot.MiddleLeft}}else if(t.commentMargin>=0){g.e(t.bounds.x+t.focus.x*2+t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleRight,S.toSpot=Spot.MiddleLeft}}else{g.e(t.bounds.x+t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleLeft,S.toSpot=Spot.MiddleRight}}t.commentSpacing>=0?u+=k.height+t.commentSpacing:u+=t.commentSpacing-k.height}else{if(o>135&&!l||!a&&c)if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y-t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleTop,S.toSpot=Spot.MiddleBottom}}else{g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2-t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleBottom,S.toSpot=Spot.MiddleTop}}else if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2+t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleBottom,S.toSpot=Spot.MiddleTop}}else{g.e(t.bounds.x+u,t.bounds.y+t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const S=b.value;S.fromSpot=Spot.MiddleTop,S.toSpot=Spot.MiddleBottom}}t.commentSpacing>=0?u+=k.width+t.commentSpacing:u+=t.commentSpacing-k.width}}Point.o(g);const p=u-t.commentSpacing-(h?e.height:e.width);if(this.ds===1){const y=t.destinationEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.fromEndSegmentLength=p>0?p:NaN)}}else{const y=t.sourceEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.toEndSegmentLength=p>0?p:NaN)}}}}z3(){if(this.layerStyle===62){const i=[];let e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;let n=s.parent;n===null&&(n=s);const o=n.angle===0||n.angle===180;let r=i[s.level];r===void 0&&(r=0),i[s.level]=Math.max(r,o?s.width:s.height)}for(let s=0;s=0)for(let o=0;o135&&n.reverse(),this.iw(r))if(o>1)for(let R=0;R0&&P>0&&M+u+O.width>f&&(M135?-b-g:b+g);const V=P===0?m:u;this.xk(I,0,A),I.X.e(M+V,A),k=Math.max(k,M+V+O.width),b=Math.max(b,S+(C===0?0:g)+O.height),M+=V+O.width}else{f>0&&P>0&&A+u+O.height>f&&(A135?-k-g:k+g);const V=P===0?m:u;this.xk(I,M,0),I.X.e(M,A+V),b=Math.max(b,A+V+O.height),k=Math.max(k,S+(C===0?0:g)+O.width),A+=V+O.height}P++}C>0&&(e?(b+=Math.max(0,c),M0&&(h||this.ru(t,p,0,0,o-1),k+=p)):(k+=Math.max(0,c),A0&&(h||this.ru(t,0,p,0,o-1),b+=p)));let D=0,F=0;switch(r){case 20:e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;break;default:case 21:if(C>0)e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;else{const I=o;if(e){const O=n[0].X.x+n[0].yt.x,V=n[I-1].X.x+n[I-1].yt.x+n[I-1].focus.x*2;D+=O+(V-O)/2-t.focus.x-d/2}else{const O=n[0].X.y+n[0].yt.y,V=n[I-1].X.y+n[I-1].yt.y+n[I-1].focus.y*2;F+=O+(V-O)/2-t.focus.y-d/2}}break;case 22:e?(D-=d,k+=d):(F-=d,b+=d);break;case 23:e?(D+=k-t.width+d,k+=d):(F+=b-t.height+d,b+=d);break;case 24:case 25:e?o>1?D+=T+u/2-t.focus.x:D+=n[0].focus.x-t.focus.x+n[0].yt.x:o>1?F+=T+u/2-t.focus.y:F+=n[0].focus.y-t.focus.y+n[0].yt.y;break;case 26:e?D+=k+u/2-t.focus.x:F+=b+u/2-t.focus.y;break;case 27:break;case 28:const R=this.customAlignment(t,D,F,k,b);D=R[0],F=R[1],k=R[2],b=R[3];break}for(let R=0;R135?(a?-b:-I.kt.height)+I.yt.y-c:x+c+I.yt.y)):I.X.e(I.X.x+(i>135?(a?-k:-I.kt.width)+I.yt.x-c:y+c+I.yt.x),I.X.y+I.yt.y-F)}e?(k=this.ZN(t,k,D),D<0&&(D=0),i>135&&(F+=b+c),b=Math.max(Math.max(b,x),b+x+c)):(i>135&&(D+=k+c),k=Math.max(Math.max(k,y),k+y+c),b=this.$N(t,b,F),F<0&&(F=0)),t.yt.e(D,F),t.kt.e(k,b)}customAlignment(t,i,e,s,n){return[i,e,s,n]}LD(t,i,e,s,n,o){Debug&&Util.s(t,TreeVertex,TreeLayout,"layoutBusChildrenPosDir:v");const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.kt.width,o=p.kt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,f=this.orthoAngle(t)===90;let c=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.kt,k=c===0?0:h;if(f){const b=this.computeBusNodeSpacing(y)-l;y.X.e(e-(x.width+b),d+k),n=Math.max(n,x.width+b),o=Math.max(o,d+k+x.height),d+=k+x.height}else{const b=this.computeBusNodeSpacing(y)-l;y.X.e(u+k,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,u+k+x.width),u+=k+x.width}c++}c=0;const m=u,g=d;f?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.kt,x=this.computeBusLastRowSpacing(p,f?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(f){p.X.e(e+l/2-p.focus.x-p.yt.x,o+x);const k=e+l/2-p.focus.x-p.yt.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.max(g,d)+x+y.height),p.X.x<0&&(e=this.bk(t,p.X.x,!1,e,l))}else{p.X.e(n+x,e+l/2-p.focus.y-p.yt.y),n=Math.max(n,Math.max(m,u)+x+y.width);const k=e+l/2-p.focus.y-p.yt.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.X.y<0&&(e=this.bk(t,p.X.y,!0,e,l))}}return new Rect(e,0,n,o)}TD(t,i,e,s,n,o){Debug&&Util.s(t,TreeVertex,TreeLayout,"layoutBusChildrenNegDir:v");const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.kt.width,o=p.kt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,f=this.orthoAngle(t)===270;let c=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.kt,k=c===0?0:h;if(f){const b=this.computeBusNodeSpacing(y)-l;d-=k+x.height,y.X.e(e-(x.width+b),d),n=Math.max(n,x.width+b),o=Math.max(o,Math.abs(d))}else{const b=this.computeBusNodeSpacing(y)-l;u-=k+x.width,y.X.e(u,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,Math.abs(u))}c++}c=0;const m=u,g=d;f?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.kt,x=this.computeBusLastRowSpacing(p,f?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(f){p.X.e(e+l/2-p.focus.x-p.yt.x,-o-y.height-x);const k=e+l/2-p.focus.x-p.yt.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.abs(Math.min(g,d))+x+y.height),p.X.x<0&&(e=this.bk(t,p.X.x,!1,e,l))}else{p.X.e(-n-y.width-x,e+l/2-p.focus.y-p.yt.y),n=Math.max(n,Math.abs(Math.min(m,u))+x+y.width);const k=e+l/2-p.focus.y-p.yt.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.X.y<0&&(e=this.bk(t,p.X.y,!0,e,l))}}for(let p=0;ps&&(s=e+t.width),e<0&&(s-=e),s;case 22:return t.width>i?t.width:i;case 23:return t.focus.x*2>i?t.width:i+t.width-t.focus.x*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.width);return Math.max(t.width,o-n);case 26:return t.width-t.focus.x+t.nodeSpacing/2+i;case 27:return Math.max(t.width,t.focus.x+t.nodeSpacing/2+i);default:return i}}$N(t,i,e){switch(Debug&&Util.s(t,TreeVertex,TreeLayout,"calculateSubheight:v"),t.alignment){case 21:case 20:let s=i;return e+t.height>s&&(s=e+t.height),e<0&&(s-=e),s;case 22:return t.height>i?t.height:i;case 23:return t.focus.y*2>i?t.height:i+t.height-t.focus.y*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.height);return Math.max(t.height,o-n);case 26:return t.height-t.focus.y+t.nodeSpacing/2+i;case 27:return Math.max(t.height,t.focus.y+t.nodeSpacing/2+i);default:return i}}QN(t,i,e){switch(Debug&&Util.tt(t,TreeAlignment,"TreeAlignment"),t){case 20:i/=2,e/=2;break;case 21:i/=2,e/=2;break;case 22:i=0,e=0;break;case 23:break;default:Util.n("Unhandled alignment value "+t.toString())}return new Point(i,e)}rf(t,i,e,s,n,o){Debug&&Util.s(t,TreeVertex,TreeLayout,"shiftRelPosAlign:v"),Debug&&Util.tt(i,TreeAlignment,"TreeAlignment");const r=this.QN(i,e,s);this.ru(t,r.x,r.y,n,o)}ru(t,i,e,s,n){if(Debug&&Util.s(t,TreeVertex,TreeLayout,"shiftRelPos:v"),i===0&&e===0)return;const o=t.children;for(let r=s;r<=n;r++){const h=o[r].X;h.x+=i,h.y+=e}}xk(t,i,e){Debug&&(Util.s(t,TreeVertex,TreeLayout,"recordMidPoints:v"),Util.t(i,"number",TreeLayout,"recordMidPoints:x"),Util.t(e,"number",TreeLayout,"recordMidPoints:y"));const s=t.parent;switch(this.ds){case 1:{const n=t.sourceEdges;for(;n.next();){const o=n.value;o.fromVertex===s&&o.relativePoint.e(i,e)}break}case 2:{const n=t.destinationEdges;for(;n.next();){const o=n.value;o.toVertex===s&&o.relativePoint.e(i,e)}break}default:Util.n("Unhandled path value "+this.ds.toString())}}G3(t){if(Debug&&Util.s(t,TreeVertex,TreeLayout,"layoutTreeBlock:v"),t.childrenCount===0){const z=t.parent;let G=!1,q=0,j=21;z!==null&&(q=z.angle,j=z.alignment,G=this.isBusAlignment(j));const J=this.JN(t);t.X.e(0,0),t.kt.e(t.width,t.height),t.parent!==null&&t.comments!==null&&((q===180||q===270)&&!G||J)?q===180&&!G||(q===90||q===270)&&J?t.yt.e(t.width-t.focus.x*2,0):t.yt.e(0,t.height-t.focus.y*2):t.yt.e(0,0),t.zg=null,t.Xg=null;return}const i=this.orthoAngle(t),e=i===90||i===270;let s=0;const n=t.children,o=n.length;for(let z=0;z135&&n.reverse(),this.iw(r))if(o>1)for(let z=0;z0&&L>0&&P+u+q.width>f&&(P135?-k-m:k+m),this.xk(G,0,N);let j=0;if(L===0)S=G.zg,M=G.Xg,A=q.width,C=q.height,(S===null||M===null||i!==this.orthoAngle(G))&&(S=this.ge(2),M=this.ge(2),S[0].e(0,0),S[1].e(0,C),M[0].e(A,0),M[1].e(A,C));else{const J=Util.at(),Y=this.DD(t,G,S,M,A,C,J);j=Y.x,S=J[0],M=J[1],A=Y.width,C=Y.height,Util.nt(J),P0&&L>0&&N+u+q.height>f&&(N135?-x-m:x+m),this.xk(G,P,0);let j=0;if(L===0)S=G.zg,M=G.Xg,A=q.width,C=q.height,(S===null||M===null||i!==this.orthoAngle(G))&&(S=this.ge(2),M=this.ge(2),S[0].e(0,0),S[1].e(A,0),M[0].e(0,C),M[1].e(A,C));else{const J=Util.at(),Y=this.DD(t,G,S,M,A,C,J);j=Y.x,S=J[0],M=J[1],A=Y.width,C=Y.height,Util.nt(J),N0&&(e?(k+=Math.max(0,c),P0&&(h||this.ru(t,g,0,0,o-1),x+=g)):(x+=Math.max(0,c),N0&&(h||this.ru(t,0,g,0,o-1),k+=g)));let I=0,O=0;switch(r){case 20:e?I+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;break;default:case 21:if(T>0)e?I+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;else{const G=o;if(e){const q=n[0].X.x+n[0].yt.x,j=n[G-1].X.x+n[G-1].yt.x+n[G-1].focus.x*2;I+=q+(j-q)/2-t.focus.x-d/2}else{const q=n[0].X.y+n[0].yt.y,j=n[G-1].X.y+n[G-1].yt.y+n[G-1].focus.y*2;O+=q+(j-q)/2-t.focus.y-d/2}}break;case 22:e?(I-=d,x+=d):(O-=d,k+=d);break;case 23:e?(I+=x-t.width+d,x+=d):(O+=k-t.height+d,k+=d);break;case 24:e?o>1?I+=F+u/2-t.focus.x:I+=n[0].focus.x-t.focus.x+n[0].yt.x:o>1?O+=F+u/2-t.focus.y:O+=n[0].focus.y-t.focus.y+n[0].yt.y;break;case 26:e?I+=x+u/2-t.focus.x:O+=k+u/2-t.focus.y;break;case 27:break;case 28:const z=this.customAlignment(t,I,O,x,k);I=z[0],O=z[1],x=z[2],k=z[3];break}for(let z=0;z135?(a?-k:-G.kt.height)+G.yt.y-c:y+c+G.yt.y)):G.X.e(G.X.x+(i>135?(a?-x:-G.kt.width)+G.yt.x-c:p+c+G.yt.x),G.X.y+G.yt.y-O)}let V=0,K=0;if(a)e?(x=this.ZN(t,x,I),I<0&&(I=0),i>135&&(O+=k+c),k+=y+c,r===27&&(V+=u/2+t.focus.x),K+=y+c):(i>135&&(I+=x+c),x+=p+c,k=this.$N(t,k,O),O<0&&(O=0),r===27&&(K+=u/2+t.focus.y),V+=p+c);else if(e){if(t.comments===null){if(p>x){const z=this.QN(r,p-x,0);V=z.x,K=z.y,x=p,I=0}}else x=this.ZN(t,x,I);I<0&&(V-=I,I=0),i>135&&(O+=k+c),k=Math.max(Math.max(k,y),k+y+c),K+=y+c}else{if(i>135&&(I+=x+c),x=Math.max(Math.max(x,p),x+p+c),t.comments===null){if(y>k){const z=this.QN(r,0,y-k);V=z.x,K=z.y,k=y,O=0}}else k=this.$N(t,k,O);O<0&&(K-=O,O=0),V+=p+c}let B,X;if(T>0)B=this.ge(4),X=this.ge(4),e?(B[2].e(0,y+c),B[3].e(B[2].x,k),X[2].e(x,B[2].y),X[3].e(X[2].x,B[3].y)):(B[2].e(p+c,0),B[3].e(x,B[2].y),X[2].e(B[2].x,k),X[3].e(B[3].x,X[2].y));else{B=this.ge(S.length+2),X=this.ge(M.length+2);for(let z=0;zB[0].x?B[2].c(B[1]):B[1].c(B[2])),B[3].yB[0].x?B[3].c(B[2]):B[2].c(B[3])),X[0].e(I+p,0),X[1].e(X[0].x,y),X[2].yB[0].y?B[2].c(B[1]):B[1].c(B[2])),B[3].xB[0].y?B[3].c(B[2]):B[2].c(B[3])),X[0].e(0,O+y),X[1].e(p,X[0].y),X[2].xl;){const a=i[o++];s[r++].e(a.x,a.y+e)}const h=this.ge(r);for(n=0;nl;){const a=i[o++];s[r++].e(a.x+e,a.y)}const h=this.ge(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.ge(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.ge(r);for(n=0;nh&&r.xr.x&&ha&&r.yr.y&&a0){const n=Math.min(1,t.layerSpacingParentOverlap);s-=e?t.height*n:t.width*n}return s<(e?-t.height:-t.width)&&(s=e?-t.height:-t.width),s}computeNodeIndent(t){Debug&&Util.s(t,TreeVertex,TreeLayout,"computeNodeIndent:v");const i=this.orthoAngle(t),e=i===90||i===270;let s=t.nodeIndent;if(t.nodeIndentPastParent>0){const n=Math.min(1,t.nodeIndentPastParent);s+=e?t.width*n:t.height*n}return s=Math.max(0,s),s}get roots(){return this.Ei}set roots(t){this.Ei!==t&&(Util.s(t,GSet,TreeLayout,"roots"),this.Ei=t,this.invalidateLayout())}get path(){return this.Ii}set path(t){this.Ii!==t&&(Util.tt(t,TreePath,"TreePath"),this.Ii=t,this.invalidateLayout())}get treeStyle(){return this.ou}set treeStyle(t){this.ou!==t&&(Util.tt(t,TreeStyle,"TreeStyle"),(t===40||t===42||t===41||t===43)&&(this.ou=t,this.invalidateLayout()))}get layerStyle(){return this.Vg}set layerStyle(t){this.Vg!==t&&(Util.tt(t,TreeLayerStyle,"TreeLayerStyle"),(t===60||t===61||t===62)&&(this.Vg=t,this.invalidateLayout()))}get comments(){return this.Ve}set comments(t){this.Ve!==t&&(Util.t(t,"boolean",TreeLayout,"comments"),this.Ve=t,this.invalidateLayout())}get arrangement(){return this.qi}set arrangement(t){this.qi!==t&&(Util.tt(t,TreeArrangement,"TreeArrangement"),(t===50||t===51||t===52)&&(this.qi=t,this.invalidateLayout()))}get arrangementSpacing(){return this.Cs}set arrangementSpacing(t){Util.s(t,Size,TreeLayout,"arrangementSpacing"),this.Cs.equals(t)||(this.Cs.c(t),this.invalidateLayout())}get rootDefaults(){return this.K}set rootDefaults(t){this.K!==t&&(Util.s(t,TreeVertex,TreeLayout,"rootDefaults"),this.K=t,this.invalidateLayout())}get alternateDefaults(){return this.U}set alternateDefaults(t){this.U!==t&&(Util.s(t,TreeVertex,TreeLayout,"alternateDefaults"),this.U=t,this.invalidateLayout())}get sorting(){return this.K.sorting}set sorting(t){this.K.sorting!==t&&(Util.tt(t,TreeSorting,"TreeSorting"),this.K.sorting=t,this.invalidateLayout())}get comparer(){return this.K.comparer}set comparer(t){this.K.comparer!==t&&(Util.t(t,"function",TreeLayout,"comparer"),this.K.comparer=t,this.invalidateLayout())}get angle(){return this.K.angle}set angle(t){this.K.angle!==t&&(Util.t(t,"number",TreeLayout,"angle"),t===0||t===90||t===180||t===270?(this.K.angle=t,this.invalidateLayout()):Util.n("TreeLayout.angle must be 0, 90, 180, or 270"))}get alignment(){return this.K.alignment}set alignment(t){this.K.alignment!==t&&(Util.tt(t,TreeAlignment,"TreeAlignment"),this.K.alignment=t,this.invalidateLayout())}get nodeIndent(){return this.K.nodeIndent}set nodeIndent(t){this.K.nodeIndent!==t&&(Util.t(t,"number",TreeLayout,"nodeIndent"),t>=0&&(this.K.nodeIndent=t,this.invalidateLayout()))}get nodeIndentPastParent(){return this.K.nodeIndentPastParent}set nodeIndentPastParent(t){this.K.nodeIndentPastParent!==t&&(Util.t(t,"number",TreeLayout,"nodeIndentPastParent"),t>=0&&t<=1&&(this.K.nodeIndentPastParent=t,this.invalidateLayout()))}get nodeSpacing(){return this.K.nodeSpacing}set nodeSpacing(t){this.K.nodeSpacing!==t&&(Util.t(t,"number",TreeLayout,"nodeSpacing"),this.K.nodeSpacing=t,this.invalidateLayout())}get layerSpacing(){return this.K.layerSpacing}set layerSpacing(t){this.K.layerSpacing!==t&&(Util.t(t,"number",TreeLayout,"layerSpacing"),this.K.layerSpacing=t,this.invalidateLayout())}get layerSpacingParentOverlap(){return this.K.layerSpacingParentOverlap}set layerSpacingParentOverlap(t){this.K.layerSpacingParentOverlap!==t&&(Util.t(t,"number",TreeLayout,"layerSpacingParentOverlap"),t>=0&&t<=1&&(this.K.layerSpacingParentOverlap=t,this.invalidateLayout()))}get compaction(){return this.K.compaction}set compaction(t){this.K.compaction!==t&&(Util.tt(t,TreeCompaction,"TreeCompaction"),(t===30||t===31)&&(this.K.compaction=t,this.invalidateLayout()))}get breadthLimit(){return this.K.breadthLimit}set breadthLimit(t){this.K.breadthLimit!==t&&(Util.t(t,"number",TreeLayout,"breadthLimit"),t>=0&&(this.K.breadthLimit=t,this.invalidateLayout()))}get rowSpacing(){return this.K.rowSpacing}set rowSpacing(t){this.K.rowSpacing!==t&&(Util.t(t,"number",TreeLayout,"rowSpacing"),this.K.rowSpacing=t,this.invalidateLayout())}get rowIndent(){return this.K.rowIndent}set rowIndent(t){this.K.rowIndent!==t&&(Util.t(t,"number",TreeLayout,"rowIndent"),t>=0&&(this.K.rowIndent=t,this.invalidateLayout()))}get commentSpacing(){return this.K.commentSpacing}set commentSpacing(t){this.K.commentSpacing!==t&&(Util.t(t,"number",TreeLayout,"commentSpacing"),this.K.commentSpacing=t,this.invalidateLayout())}get commentMargin(){return this.K.commentMargin}set commentMargin(t){this.K.commentMargin!==t&&(Util.t(t,"number",TreeLayout,"commentMargin"),this.K.commentMargin=t,this.invalidateLayout())}get setsPortSpot(){return this.K.setsPortSpot}set setsPortSpot(t){this.K.setsPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"setsPortSpot"),this.K.setsPortSpot=t,this.invalidateLayout())}get portSpot(){return this.K.portSpot}set portSpot(t){Util.s(t,Spot,TreeLayout,"portSpot"),this.K.portSpot.equals(t)||(this.K.portSpot=t,this.invalidateLayout())}get setsChildPortSpot(){return this.K.setsChildPortSpot}set setsChildPortSpot(t){this.K.setsChildPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"setsChildPortSpot"),this.K.setsChildPortSpot=t,this.invalidateLayout())}get childPortSpot(){return this.K.childPortSpot}set childPortSpot(t){Util.s(t,Spot,TreeLayout,"childPortSpot"),this.K.childPortSpot.equals(t)||(this.K.childPortSpot=t,this.invalidateLayout())}get alternateSorting(){return this.U.sorting}set alternateSorting(t){this.U.sorting!==t&&(Util.tt(t,TreeSorting,"TreeSorting"),this.U.sorting=t,this.invalidateLayout())}get alternateComparer(){return this.U.comparer}set alternateComparer(t){this.U.comparer!==t&&(Util.t(t,"function",TreeLayout,"alternateComparer"),this.U.comparer=t,this.invalidateLayout())}get alternateAngle(){return this.U.angle}set alternateAngle(t){this.U.angle!==t&&(Util.t(t,"number",TreeLayout,"alternateAngle"),(t===0||t===90||t===180||t===270)&&(this.U.angle=t,this.invalidateLayout()))}get alternateAlignment(){return this.U.alignment}set alternateAlignment(t){this.U.alignment!==t&&(Util.tt(t,TreeAlignment,"TreeAlignment"),this.U.alignment=t,this.invalidateLayout())}get alternateNodeIndent(){return this.U.nodeIndent}set alternateNodeIndent(t){this.U.nodeIndent!==t&&(Util.t(t,"number",TreeLayout,"alternateNodeIndent"),t>=0&&(this.U.nodeIndent=t,this.invalidateLayout()))}get alternateNodeIndentPastParent(){return this.U.nodeIndentPastParent}set alternateNodeIndentPastParent(t){this.U.nodeIndentPastParent!==t&&(Util.t(t,"number",TreeLayout,"alternateNodeIndentPastParent"),t>=0&&t<=1&&(this.U.nodeIndentPastParent=t,this.invalidateLayout()))}get alternateNodeSpacing(){return this.U.nodeSpacing}set alternateNodeSpacing(t){this.U.nodeSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateNodeSpacing"),this.U.nodeSpacing=t,this.invalidateLayout())}get alternateLayerSpacing(){return this.U.layerSpacing}set alternateLayerSpacing(t){this.U.layerSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateLayerSpacing"),this.U.layerSpacing=t,this.invalidateLayout())}get alternateLayerSpacingParentOverlap(){return this.U.layerSpacingParentOverlap}set alternateLayerSpacingParentOverlap(t){this.U.layerSpacingParentOverlap!==t&&(Util.t(t,"number",TreeLayout,"alternateLayerSpacingParentOverlap"),t>=0&&t<=1&&(this.U.layerSpacingParentOverlap=t,this.invalidateLayout()))}get alternateCompaction(){return this.U.compaction}set alternateCompaction(t){this.U.compaction!==t&&(Util.tt(t,TreeCompaction,"TreeCompaction"),(t===30||t===31)&&(this.U.compaction=t,this.invalidateLayout()))}get alternateBreadthLimit(){return this.U.breadthLimit}set alternateBreadthLimit(t){this.U.breadthLimit!==t&&(Util.t(t,"number",TreeLayout,"alternateBreadthLimit"),t>=0&&(this.U.breadthLimit=t,this.invalidateLayout()))}get alternateRowSpacing(){return this.U.rowSpacing}set alternateRowSpacing(t){this.U.rowSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateRowSpacing"),this.U.rowSpacing=t,this.invalidateLayout())}get alternateRowIndent(){return this.U.rowIndent}set alternateRowIndent(t){this.U.rowIndent!==t&&(Util.t(t,"number",TreeLayout,"alternateRowIndent"),t>=0&&(this.U.rowIndent=t,this.invalidateLayout()))}get alternateCommentSpacing(){return this.U.commentSpacing}set alternateCommentSpacing(t){this.U.commentSpacing!==t&&(Util.t(t,"number",TreeLayout,"alternateCommentSpacing"),this.U.commentSpacing=t,this.invalidateLayout())}get alternateCommentMargin(){return this.U.commentMargin}set alternateCommentMargin(t){this.U.commentMargin!==t&&(Util.t(t,"number",TreeLayout,"alternateCommentMargin"),this.U.commentMargin=t,this.invalidateLayout())}get alternateSetsPortSpot(){return this.U.setsPortSpot}set alternateSetsPortSpot(t){this.U.setsPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"alternateSetsPortSpot"),this.U.setsPortSpot=t,this.invalidateLayout())}get alternatePortSpot(){return this.U.portSpot}set alternatePortSpot(t){Util.s(t,Spot,TreeLayout,"alternatePortSpot"),this.U.portSpot.equals(t)||(this.U.portSpot=t,this.invalidateLayout())}get alternateSetsChildPortSpot(){return this.U.setsChildPortSpot}set alternateSetsChildPortSpot(t){this.U.setsChildPortSpot!==t&&(Util.t(t,"boolean",TreeLayout,"alternateSetsChildPortSpot"),this.U.setsChildPortSpot=t,this.invalidateLayout())}get alternateChildPortSpot(){return this.U.childPortSpot}set alternateChildPortSpot(t){Util.s(t,Spot,TreeLayout,"alternateChildPortSpot"),this.U.childPortSpot.equals(t)||(this.U.childPortSpot=t,this.invalidateLayout())}static PathDefault=0;static PathDestination=1;static PathSource=2;static SortingForwards=10;static SortingReverse=11;static SortingAscending=12;static SortingDescending=13;static AlignmentCenterSubtrees=20;static AlignmentCenterChildren=21;static AlignmentStart=22;static AlignmentEnd=23;static AlignmentBus=24;static AlignmentBusBranching=25;static AlignmentTopLeftBus=26;static AlignmentBottomRightBus=27;static CompactionNone=30;static CompactionBlock=31;static StyleLayered=40;static StyleLastParents=41;static StyleAlternating=42;static StyleRootOnly=43;static ArrangementVertical=50;static ArrangementHorizontal=51;static ArrangementFixedRoots=52;static LayerIndividual=60;static LayerSiblings=61;static LayerUniform=62}class TreeNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new TreeVertex(this)}createEdge(){return new TreeEdge(this)}}class TreeVertex extends LayoutVertex{X;kt;yt;Sk;Mk;Pk;Nk;Ck;Ak;Lk;Ve;zg;Xg;ke;Se;jt;ai;ew;sw;nw;As;ow;rw;lw;hw;aw;fw;cw;uw;dw;gw;mw;constructor(t){super(t),this.Sk=!1,this.Mk=null,this.Pk=[],this.Nk=0,this.Ck=0,this.Ak=0,this.Lk=0,this.Ve=null,this.X=new Point(0,0),this.kt=new Size(0,0),this.yt=new Point(0,0),this.zg=null,this.Xg=null,this.ke=10,this.Se=LayoutVertex.standardComparer,this.jt=0,this.ai=21,this.ew=0,this.sw=0,this.nw=20,this.As=50,this.ow=0,this.rw=31,this.lw=0,this.hw=25,this.aw=10,this.fw=10,this.cw=20,this.uw=!0,this.dw=Spot.Default,this.gw=!0,this.mw=Spot.Default}copyInheritedPropertiesFrom(t){t!==null&&(this.ke=t.sorting,this.Se=t.comparer,this.jt=t.angle,this.ai=t.alignment,this.ew=t.nodeIndent,this.sw=t.nodeIndentPastParent,this.nw=t.nodeSpacing,this.As=t.layerSpacing,this.ow=t.layerSpacingParentOverlap,this.rw=t.compaction,this.lw=t.breadthLimit,this.hw=t.rowSpacing,this.aw=t.rowIndent,this.fw=t.commentSpacing,this.cw=t.commentMargin,this.uw=t.setsPortSpot,this.dw=t.portSpot,this.gw=t.setsChildPortSpot,this.mw=t.childPortSpot)}get initialized(){return this.Sk}set initialized(t){this.Sk!==t&&(Util.t(t,"boolean",TreeVertex,"initialized"),this.Sk=t)}get parent(){return this.Mk}set parent(t){this.Mk!==t&&(Debug&&t!==null&&Util.s(t,TreeVertex,TreeVertex,"parent"),this.Mk=t)}get children(){return this.Pk}set children(t){if(this.Pk!==t){if(t!==null&&!Array.isArray(t)&&Util.Bi(t,"Array",TreeVertex,"children:value"),t!==null){const i=t.length;for(let e=0;e4;)t.removePoint(2);u=t.getPoint(1),d=t.getPoint(2)}else{for(c=1;t.pointsCount>3;)t.removePoint(1);u=t.getPoint(0),d=t.getPoint(t.pointsCount-1)}const m=t.getPoint(t.pointsCount-1);let g=0;r===0?(e.alignment===23?(g=o.bottom+n.y,n.y===0&&u.y>m.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.xm.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.x{const i=t.matches?"dark":"light";i!==this.Yg&&(this.Yg=i,this.Fk==="system"&&this.pw())};constructor(t){t&&Object.assign(this,t),t?.themeMap||(this.lu.set("light",{colors:{...Themes.Light.colors},fonts:{...Themes.Light.fonts},numbers:{...Themes.Light.numbers},margins:{...Themes.Light.margins},arrowheads:{...Themes.Light.arrowheads}}),this.lu.set("dark",{colors:{...Themes.Dark.colors},fonts:{...Themes.Dark.fonts},numbers:{...Themes.Dark.numbers},margins:{...Themes.Dark.margins},arrowheads:{...Themes.Dark.arrowheads}})),root.matchMedia&&(this.Yg=root.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}get themeMap(){return this.lu}set themeMap(t){this.lu!==t&&(this.lu=t,this.pw())}get defaultTheme(){return this.Dk}set defaultTheme(t){this.Dk!==t&&(Util.t(t,"string",ThemeManager,"defaultTheme"),this.Dk=t,this.pw())}get currentTheme(){return this.Fk}set currentTheme(t){this.Fk!==t&&(Util.t(t,"string",ThemeManager,"currentTheme"),this.Fk=t,this.pw())}get changesDivBackground(){return this.Rk}set changesDivBackground(t){if(this.Rk!==t&&(this.Rk=t,t))for(const e of this.ls)e.setDivBackground(this.findValue("div","","fill")),e.B("ThemeChanged",this)}get preferredColorScheme(){return this.Yg}addDiagram(t){return this.ls.add(t),this.tC(t),this}removeDiagram(t){return this.ls.delete(t),this.tC(t),this}WF(){this.ls.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.addEventListener("change",this.RD)}vF(){this.ls.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.removeEventListener("change",this.RD)}set(t,i){t===""&&(t=this.Dk),t==="system"&&(t=this.Yg);let e=this.lu.get(t);return e?e=this.ID(e,i):e=i,this.lu.set(t,e),this.pw(),this}findValue(t,i,e){return this.getValue(this.findTheme(this.currentTheme),t,i,e)||this.getValue(this.findTheme(this.defaultTheme),t,i,e)}getValue(t,i,e,s){if(!t)return;e==null&&(e="");let n=t;const o=l=>{if(n===void 0||l==="")return;if(typeof l=="number"||!(Array.isArray(l)||l.includes(".")))return n[l];const h=Array.isArray(l)?l:l.split(".");for(let a=0;a{if(!(e!==""&&(n=o(e),n===void 0)))return Array.isArray(n)&&typeof i=="number"?n=n[i%n.length]:n=o(i),n};if(n=r(),n===void 0&&typeof s=="string"&&s.length>0){let l=t.targetPropertyMap?.get(s);if(l?n=t[l]:(l=ThemeManager.Q3.get(s),n=l?t[l]:t.colors),n=r(),n!==void 0)return n}return n}findTheme(t){return this.themeMap.get(t==="system"?this.Yg:t)}tC(t){const i=t.skipsUndoManager;t.skipsUndoManager=!0,t.updateAllThemeBindings(),this.Rk&&t.setDivBackground(this.findValue("div","","fill")),t.skipsUndoManager=i,t.B("ThemeChanged",this)}pw(){for(const t of this.ls)this.tC(t)}ID(t,i){for(const e in i)if(Util.yw(i,e))try{i[e].constructor===Object?t[e]=this.ID(t[e]??{},i[e]):t[e]=i[e]}catch{delete t[e]}return t}static Q3=new Map([["background","colors"],["defaultColumnSeparatorStroke","colors"],["defaultRowSeparatorStroke","colors"],["shadowColor","colors"],["fill","colors"],["stroke","colors"],["font","fonts"],["angle","numbers"],["fromEndSegmentLength","numbers"],["fromShortLength","numbers"],["height","numbers"],["opacity","numbers"],["scale","numbers"],["toEndSegmentLength","numbers"],["toShortLength","numbers"],["width","numbers"],["defaultColumnSeparatorStrokeWidth","numbers"],["defaultRowSeparatorStrokeWidth","numbers"],["shadowBlur","numbers"],["corner","numbers"],["curviness","numbers"],["smoothness","numbers"],["parameter1","numbers"],["parameter2","numbers"],["strokeWidth","numbers"],["strokeDashOffset","numbers"],["maxLines","numbers"],["spacingAbove","numbers"],["spacingBelow","numbers"],["position","points"],["shadowOffset","points"],["desiredSize","sizes"],["maxSize","sizes"],["minSize","sizes"],["margin","margins"],["defaultSeparatorPadding","margins"],["padding","margins"],["alignment","spots"],["alignmentFocus","spots"],["fromSpot","spots"],["toSpot","spots"],["defaultAlignment","spots"],["spot1","spots"],["spot2","spots"],["verticalAlignment","spots"],["imageAlignment","spots"],["fromArrow","arrowheads"],["toArrow","arrowheads"]])}class Router{Tt;b;Xi;pl;constructor(){this.b=Diagram.Sm(),this.Tt="",this.Xi=!0,this.pl=!0}get name(){return this.Tt}set name(t){this.Tt=t}get isEnabled(){return this.Xi}set isEnabled(t){this.Xi=t}get isRealtime(){return this.pl}set isRealtime(t){this.pl=t}get diagram(){return this.b}set diagram(t){this.b!==t&&(this.b=t,t.Pl=!0,t.requestUpdate())}invalidateRouter(){this.b!==null&&(this.b.Pl=!0,this.b.requestUpdate())}canRoute(t){if(!this.isEnabled)return!1;const i=this.diagram;return!(i&&(!this.isRealtime&&i.Mu||i.animationManager.isTicking))}routeLinks(t,i){}toString(){return this.name!==""?this.name+" Router":Util.hn(this.constructor)}}class AvoidsNodesRouter extends Router{constructor(t){super(),this.name="AvoidsNodes",t&&Object.assign(this,t)}canRoute(t){return(t instanceof Diagram?t.Zm:t.diagram.Zm)?super.canRoute(t):!1}routeLinks(t,i){i=i instanceof Diagram?null:i;const e=t.iterator,s=this.diagram.getPositions(!0,i,null);for(;e.next();){const n=e.value;if(!n.isAvoiding||i&&n.containingGroup!==i||n.toNode===null||n.fromNode===null||n.pointsCount<4)continue;n.startRoute();const o=n.pointsCount,r=n.getPoint(1),l=n.getPoint(o-2),h=n.fromNode.actualBounds.copy();h.inflate(Link.Xa,Link.Xa),h.unionPoint(n.getPoint(0));const a=n.toNode.actualBounds.copy();a.inflate(Link.Xa,Link.Xa),a.unionPoint(n.getPoint(o-1)),this._3(n,h,a,s)&&this.tE(n,r,n.aN,l,n.fN,h,a,s),n.commitRoute()}}_3(t,i,e,s){const n=t.diagram,o=t.pointsCount;if(n===null||t.fromNode===t.toNode||t.layer.isTemporary||i.containsPoint(t.getPoint(o-1))&&!t.toNode.isMemberOf(t.fromNode)||e.containsPoint(t.getPoint(0))&&!t.fromNode.isMemberOf(t.toNode)||!t.isOrthogonal)return!1;if(t.segmentIndex===17)return!0;const r=t.getPoint(1),l=t.getPoint(o-2),h=t.getPoint(2);if(!s.isUnoccupied(Math.min(r.x,h.x),Math.min(r.y,h.y),Math.abs(r.x-h.x),Math.abs(r.y-h.y)))return!0;for(let f=2;f=PositionArray.Hd&&(l.WA(),d.inflate(l.cellWidth*l.KP,l.cellHeight*l.UP),l.mT(i,e,s,n,d,!1),m=l.wo(s.x,s.y)),!l.Cy&&mPositionArray.Ga&&i.wo(g,p)!==u-1&&(i.wo(d-f,m)===u-1?(n=180,g=d-f,p=m):i.wo(d+f,m)===u-1?(n=0,g=d+f,p=m):i.wo(d,m-c)===u-1?(n=270,g=d,p=m-c):i.wo(d,m+c)===u-1&&(n=90,g=d,p=m+c));u>PositionArray.Ga&&i.wo(g,p)===u-1;)d=g,m=p,n===0?g+=f:n===90?p+=c:n===180?g-=f:p-=c,u-=1;if(o?u>PositionArray.Ga&&(n===180||n===0?d=Math.floor(d/f)*f+f/2:(n===90||n===270)&&(m=Math.floor(m/c)*c+c/2)):(d=Math.floor(d/f)*f+f/2,m=Math.floor(m/c)*c+c/2),u>PositionArray.Ga){let y=n,x=d,k=m;if(n===0?(y=90,k+=c):n===90?(y=180,x-=f):n===180?(y=270,k-=c):n===270&&(y=0,x+=f),i.wo(x,k)===u-1)this.iC(t,i,x,k,y,!1);else{let S=d,M=m;n===0?(y=270,M-=c):n===90?(y=0,S+=f):n===180?(y=90,M+=c):n===270&&(y=180,S-=f),i.wo(S,M)===u-1&&this.iC(t,i,S,M,y,!1)}}t.insertPointAt(t.pointsCount-2,d,m)}}ToolManager.prototype.initializeStandardTools=function(){this.ti("Action",new ActionTool,this.mouseDownTools),this.ti("Relinking",new RelinkingTool,this.mouseDownTools),this.ti("LinkReshaping",new LinkReshapingTool,this.mouseDownTools),this.ti("Rotating",new RotatingTool,this.mouseDownTools),this.ti("Resizing",new ResizingTool,this.mouseDownTools),this.ti("Linking",new LinkingTool,this.mouseMoveTools),this.ti("Dragging",new DraggingTool,this.mouseMoveTools),this.ti("DragSelecting",new DragSelectingTool,this.mouseMoveTools),this.ti("Panning",new PanningTool,this.mouseMoveTools),this.ti("ContextMenu",new ContextMenuTool,this.mouseUpTools),this.ti("TextEditing",new TextEditingTool,this.mouseUpTools),this.ti("ClickCreating",new ClickCreatingTool,this.mouseUpTools),this.ti("ClickSelecting",new ClickSelectingTool,this.mouseUpTools)},Diagram.SP("GraphLinksModel",GraphLinksPartManager),Diagram.SP("TreeModel",TreePartManager);const oldGo=root.go,go={get version(){return Diagram.version},Group,List,Set:GSet,Map:GMap,Point,Size,Rect,Margin,Spot,Geometry,PathFigure,PathSegment,InputEvent,DiagramEvent,ChangedEvent,Model,GraphLinksModel,TreeModel,Binding,ThemeBinding,Transaction,UndoManager,CommandHandler,Tool,DraggingTool,DraggingInfo,DraggingOptions,LinkingBaseTool,LinkingTool,RelinkingTool,LinkReshapingTool,ResizingTool,RotatingTool,ClickSelectingTool,ActionTool,ClickCreatingTool,HTMLInfo,ContextMenuTool,DragSelectingTool,PanningTool,TextEditingTool,ToolManager,Animation,AnimationManager,AnimationTrigger,Layer,Diagram,Palette,Overview,Brush,GraphObject,Panel,RowColumnDefinition,Shape,TextBlock,Picture,Part,Adornment,Node,Link,Placeholder,Layout,LayoutNetwork,LayoutVertex,LayoutEdge,GridLayout,PanelLayout,CircularLayout,CircularNetwork,CircularVertex,CircularEdge,ForceDirectedLayout,ForceDirectedNetwork,ForceDirectedVertex,ForceDirectedEdge,LayeredDigraphLayout,LayeredDigraphNetwork,LayeredDigraphVertex,LayeredDigraphEdge,TreeLayout,TreeNetwork,TreeVertex,TreeEdge,Themes,ThemeManager,Router,AnimationStyle,AutoScale,CycleMode,Flip,TextFormat,ImageStretch,LayoutConditions,LinkAdjusting,Curve,Routing,Orientation,TextOverflow,PortSpreading,ScrollMode,CollapsePolicy,Sizing,TriggerStart,Stretch,ViewboxStretch,Wrap,BrushType,ColorSpace,GeometryStretch,GeometryType,SegmentType,BindingMode,ChangeType,CircularArrangement,CircularDirection,CircularNodeDiameterFormula,CircularSorting,GridAlignment,GridArrangement,GridSorting,LayeredDigraphAggressive,LayeredDigraphAlign,LayeredDigraphCycleRemove,LayeredDigraphInit,LayeredDigraphLayering,LayeredDigraphPack,TreeAlignment,TreeArrangement,TreeCompaction,TreeLayerStyle,TreePath,TreeSorting,TreeStyle,GestureMode,LinkingDirection,ReshapingBehavior,TextEditingAccept,TextEditingStarting,TextEditingState,WheelMode};typeof oldGo=="object"&&oldGo.version&&Util.ht("WARNING: a `go` object on the root object is already defined. "+("Debug"in oldGo?"debug ":"")+"version: "+oldGo.version+", replaced with version: "+go.version),Diagram.prototype.go=go,root.go=go,go.Debug=Debug,Debug.attachReadonlyWarnings(go); })(); diff --git a/release/go-module.d.ts b/release/go-module.d.ts index be8892351..26f5d35f7 100644 --- a/release/go-module.d.ts +++ b/release/go-module.d.ts @@ -1,5 +1,5 @@ /* - * Type definitions for GoJS v3.0.11 + * Type definitions for GoJS v3.0.12 * Project: https://gojs.net * Definitions by: Northwoods Software * Definitions: https://github.com/NorthwoodsSoftware/GoJS @@ -279,7 +279,7 @@ export interface IContext { strokeStyle: string | CanvasGradient | CanvasPattern | SGradient; textAlign: string; imageSmoothingEnabled: boolean; - clipInsteadOfFill: boolean; + /** Only true if a Spot panel has isClipping element */ clipInsteadOfFill: boolean; filter: string; commitTransform(): void; setImageSmoothingEnabled(smooth: boolean): void; @@ -321,6 +321,7 @@ export interface IContext { disableDash(): void; clearContextCache(clearFont: boolean): void; removePartFromView(p: GraphObject): void; + createOrUpdateClipGroup(panel: GraphObject, rect: Rect): void; } /** @@ -17086,7 +17087,7 @@ export abstract class GraphObject { *

              * See the Introduction page on building objects * for usage information and examples of GraphObject.make. - * @param type - a class function or the name of a class in the `go` namespace, + * @param cls - a class function or the name of a class in the `go` namespace, * or one of several predefined kinds of {@link Panel}s: `"Button"`, `"TreeExpanderButton"`, * `"SubGraphExpanderButton"`, or `"ContextMenuButton"`. * @param initializers - zero or more values that initialize the new object, @@ -17239,7 +17240,7 @@ export class Brush { * In addition to Brush properties, this object can also contain color stops in the format: * `{ 0: "#FEC901", 0.2: "#FFFFAA", 1: "#FEA200" }` */ - constructor(type?: BrushType | string, init?: Partial & Record<(number | string), string>>); + constructor(type?: BrushType | string, init?: Partial & Record); /** * Create a copy of this Brush with the same values. */ @@ -18466,8 +18467,9 @@ export class Panel extends GraphObject { set itemCategoryProperty(value: string | ((a: any) => string)); /** * For {@link Spot} Panels: Gets or sets whether this Panel's main element clips instead of fills. - * The main element will not paint its stroke, if it has any. * This assumes that the main element is a Shape. + * The main Shape element will not paint its stroke, if it has any, + * and should have its Shape.strokeWidth set to `0`. * * Since 2.2: For {@link Group}s: Gets or sets whether this Group's Placeholder clips its member nodes. * For compatibility, if the Group is a {@link Spot} Panel, it will not clip its members. @@ -31501,9 +31503,10 @@ export abstract class Router { * An override of this method should return `false` if {@link isEnabled} is false, or return `false` is if a call to the base method is `false`. * * This method is only called by the {@link Diagram}. If using a Router without adding it to a Diagram, this method will never be called. + * @param container A Diagram or Group on which the Router will operate. * @virtual */ - canRoute(coll: Diagram | Group): boolean; + canRoute(container: Diagram | Group): boolean; /** * Route the links for a given collection (Group or Diagram). By default this is called * in a depth-first manner on every Group in the Diagram, and then the Diagram itself. @@ -31519,24 +31522,24 @@ export abstract class Router { * and then the Diagram, you should check the {@link Part.containingGroup} on each Link to ensure it matches: * * ```ts - * public routeLinks(links: Set, coll?: Diagram | Group): void { - * const container = coll instanceof Diagram ? null : coll; + * public routeLinks(links: Set, container?: Diagram | Group): void { + * const container = container instanceof Diagram ? null : container; * const it = links.iterator; * while (it.next()) { * const link = it.value; * // Only operate on links that are in the corresponding collection, if one is given - * if (coll && link.containingGroup !== container) continue; + * if (container && link.containingGroup !== container) continue; * . . . * ``` * * This method should not check the {@link canRoute} predicate. * * @param links The set of links that were recently recomputed, which may need routing. - * @param coll A Diagram or Group on which the Router will operate. + * @param container A Diagram or Group on which the Router will operate. * When calling a router manually, this does not need to be specified. * @virtual */ - routeLinks(links: Set, coll?: Diagram | Group): void; + routeLinks(links: Set, container?: Diagram | Group): void; } /** * The AvoidsNodesRouter is a Router that will modify any Orthogonal {@link Link}s @@ -31562,16 +31565,16 @@ export class AvoidsNodesRouter extends Router { * Determine whether the AvoidsNodesRouter should operate on a given collection. * If no avoiding links are present in the collection, the router will not run. */ - canRoute(coll: Diagram | Group): boolean; + canRoute(container: Diagram | Group): boolean; /** * Route the links. * By default this is called in a depth-first manner on every Group in the Diagram, and then the Diagram itself. * If a layout is warranted for any Group or Diagram, this is called immediately afterwards. * * @param links The set of links that were recently recomputed, which may need routing. - * @param coll A Diagram or Group on which the Router will operate. + * @param container A Diagram or Group on which the Router will operate. */ - routeLinks(links: Set, coll?: Diagram | Group): void; + routeLinks(links: Set, container?: Diagram | Group): void; } diff --git a/release/go-module.js b/release/go-module.js index 4006c3cd4..b58bdc8f2 100644 --- a/release/go-module.js +++ b/release/go-module.js @@ -1,25 +1,25 @@ /* - * GoJS v3.0.11 JavaScript Library for HTML Diagrams, https://gojs.net + * GoJS v3.0.12 JavaScript Library for HTML Diagrams, https://gojs.net * GoJS and Northwoods Software are registered trademarks of Northwoods Software Corporation, https://nwoods.com. * Copyright (C) 1998-2024 by Northwoods Software Corporation. All Rights Reserved. - * THIS SOFTWARE IS LICENSED. THE LICENSE AGREEMENT IS AT: https://gojs.net/3.0.11/license.html. + * THIS SOFTWARE IS LICENSED. THE LICENSE AGREEMENT IS AT: https://gojs.net/3.0.12/license.html. * DO NOT MODIFY THIS FILE. DO NOT DISTRIBUTE A MODIFIED COPY OF THE CONTENTS OF THIS FILE. */ -(function() {const root=typeof globalThis=="object"&&globalThis||typeof global=="object"&&global.global===global&&global||typeof self=="object"&&self.self===self&&self||{};root.requestAnimationFrame===void 0&&(root.setImmediate===void 0?root.requestAnimationFrame=w=>root.setTimeout(w,0):root.requestAnimationFrame=root.setImmediate);class Util{static rr=root.navigator!==void 0&&root.navigator.platform!==void 0&&root.navigator.platform.match(/(iPhone|iPod|iPad|Mac)/i)!==null;static Nk(t,i,e){let s=-1;return function(){const n=this,o=arguments;s!==-1&&Util.Ig(s),s=Util.vh(()=>{s=-1,e||t.apply(n,o)},i),e&&!s&&t.apply(n,o)}}static vh(t,i){return root.setTimeout(t,i)}static Ig(t){root.clearTimeout(t)}static en(t){return root.document.createElement(t)}static o(t){throw new Error(t)}static T(t,i){let e="The object is frozen, so its properties cannot be set: "+t.toString();i!==void 0&&(e+=" to value: "+i),Util.o(e)}static WI(t,i,e,s){}static i(t,i,e,s){}static JI(t,i,e){}static $I(t,i,e){}static we(t,i,e,s){}static _(t,i,e,s){let n=Util.CD(e);s!==void 0&&(n+="."+s),Util.o(n+" is not in the range "+i+": "+t)}static ve(t){}static lr(t,i){}static oi(t){root.console&&root.console.log(t)}static wt(t){return typeof t=="object"&&t!==null}static ZI(t,i,e){}static su(t,i,e){Array.isArray(t)?i>=t.length?t.push(e):t.splice(i,0,e):Util.o("Cannot insert an object into an HTMLCollection or NodeList: "+e+" at "+i)}static _a(t,i){Array.isArray(t)?i>=t.length?t.pop():t.splice(i,1):Util.o("Cannot remove an object from an HTMLCollection or NodeList at "+i)}static Ck=[];static ot(){const t=Util.Ck.pop();return t===void 0?[]:t}static tt(t){t.length=0,Util.Ck.push(t)}static QI=Object.freeze([]);static CD(t){return t===null?"*":typeof t=="string"?t:typeof t=="function"?t.name:""}static sn(t){return typeof t=="function"?t.className?t.className:t.name:Util.wt(t)&&t.constructor?Util.sn(t.constructor):typeof t}static Oh(t,i){return i==null||i===""?null:Util.wt(t)&&i in t||t[i]?t[i]:null}static toString(t){let i=t;return Util.wt(t)&&(t.text?i=t.text:t.name?i=t.name:t.key!==void 0?i=t.key:t.id!==void 0?i=t.id:t.constructor===Object&&(t.Text?i=t.Text:t.Name?i=t.Name:t.Key!==void 0?i=t.Key:t.Id!==void 0?i=t.Id:t.ID!==void 0&&(i=t.ID))),i===void 0?"undefined":i===null?"null":i.toString()}static fw(t,i){if(t.hasOwnProperty(i))return!0;let e=Object.getPrototypeOf(t);for(;e&&e!==Function;){if(e.hasOwnProperty(i))return!0;const s=e._I;if(s&&s[i])return!0;e=Object.getPrototypeOf(e)}return!1}static LD(t){const i=[];let e=0;for(e=0;e<256;e++)i[e]=e;let s=0,n=0;for(e=0;e<256;e++)s=(s+i[e]+119)%256,n=i[e],i[e]=i[s],i[s]=n;e=0,s=0;let o="";for(let r=0;r>4)+i.charAt(r&15)]=String.fromCharCode(r);t.length%2&&(t="0"+t);const s=[];let n=0;for(let r=0;r0){const n=i[0];return this.key=0,this.value=n,n}else return null}any(t){const i=this.qt;i.hr=null;const e=i.at;this.Dt=-1;const s=i.r,n=s.length,o=this.Ls;for(let r=0;r=0?(this.key=i,this.value=t.r[i],!0):(this.gl(),!1)}hasNext(){return this.next()}first(){const t=this.qt;this.Yt=t.at;const i=t.r,e=i.length-1;if(this.Dt=e,e>=0){const s=i[e];return this.key=e,this.value=s,s}else return null}any(t){const i=this.qt;i.ar=null;const e=i.at,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(t(r))return!0;i.at!==e&&Util.ve(i)}return!1}all(t){const i=this.qt;i.ar=null;const e=i.at,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(!t(r))return!1;i.at!==e&&Util.ve(i)}return!0}each(t){const i=this.qt;i.ar=null;const e=i.at,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];t(r),i.at!==e&&Util.ve(i)}return this}map(t){const i=this.qt;i.ar=null;const e=i.at,s=[],n=i.r,o=n.length;this.Dt=o;for(let l=o-1;l>=0;l--){const h=n[l];s.push(t(h)),i.at!==e&&Util.ve(i)}const r=new List;return r.r=s,r.Oe(),r.iterator}filter(t){const i=this.qt;i.ar=null;const e=i.at,s=[],n=i.r,o=n.length;this.Dt=o;for(let l=o-1;l>=0;l--){const h=n[l];t(h)&&s.push(h),i.at!==e&&Util.ve(i)}const r=new List;return r.r=s,r.Oe(),r.iterator}get count(){return this.qt.r.length}gl(){this.key=-1,this.value=null,this.Yt=-1,this.qt.ar=this}toString(){return"ListIteratorBackwards("+this.Dt+"/"+this.qt.count+")"}}class List{h;r;at;hr;ar;constructor(t){GSet.Yi(this),this.h=!1,this.r=[],this.at=0,this.hr=null,this.ar=null,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.r.values()}Oe(){let t=this.at;t++,t>999999999&&(t=0),this.at=t}g(){return this.h=!0,this}rt(){return this.h=!1,this}toString(){return"List()#"+GSet.as(this)}add(t){return this.h&&Util.T(this,t),this.r.push(t),this.Oe(),this}push(t){this.add(t)}addAll(t){if(t===null)return this;this.h&&Util.T(this);const i=this.r;if(Array.isArray(t)){const e=t.length;for(let s=0;s=i.length)&&Util._(t,"0 <= i < length",List,"elt:i"),i[t]}get(t){return this.elt(t)}setElt(t,i){const e=this.r;(t<0||t>=e.length)&&Util._(t,"0 <= i < length",List,"setElt:i"),this.h&&Util.T(this,t),e[t]=i}set(t,i){this.setElt(t,i)}first(){const t=this.r;return t.length===0?null:t[0]}last(){const t=this.r,i=t.length;return i>0?t[i-1]:null}pop(){this.h&&Util.T(this);const t=this.r;return t.length>0?t.pop():null}any(t){const i=this.r,e=this.at,s=i.length;for(let n=0;n= 0",List,"insertAt:i"),this.h&&Util.T(this,t);const e=this.r;t>=e.length?e.push(i):e.splice(t,0,i),this.Oe()}remove(t){return this.delete(t)}delete(t){if(t===null)return!1;this.h&&Util.T(this,t);const i=this.r,e=i.indexOf(t);return e===-1?!1:(e===i.length-1?i.pop():i.splice(e,1),this.Oe(),!0)}removeAt(t){const i=this.r;(t<0||t>=i.length)&&Util._(t,"0 <= i < length",List,"removeAt:i"),this.h&&Util.T(this,t),t===i.length-1?i.pop():i.splice(t,1),this.Oe()}removeRange(t,i){const e=this.r,s=e.length;if(t<0)t=0;else if(t>=s)return this;if(i<0)return this;if(i>=s&&(i=s-1),t>i)return this;this.h&&Util.T(this);let n=t,o=i+1;for(;o0&&(t.r=Array.prototype.slice.call(i)),t}toArray(){const t=this.r,i=this.count,e=new Array(i);for(let s=0;s=n-1)&&Util._(i,"0 <= from < length",List,"sortRange:from"),o===2){const r=s[i],l=s[i+1];return t(r,l)>0&&(s[i]=l,s[i+1]=r,this.Oe()),this}if(i===0)if(e>=n)s.sort(t);else{const r=s.slice(0,e);r.sort(t);for(let l=0;l=n){const r=s.slice(i);r.sort(t);for(let l=i;li.add(t(e))),i.iterator}filter(t){const i=new List;return this.ko.w.forEach(e=>{t(e)&&i.add(e)}),i.iterator}get count(){return this.ko.count}gl(){this.key=null,this.value=null,this.ii=null}toString(){return"SetIterator"}}class GSet{h;w;constructor(t){this.h=!1,this.w=new Set,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.w.values()}values(){return this.w.values()}g(){return this.h=!0,this}rt(){return this.h=!1,this}toString(){return"Set()#"+GSet.as(this)}add(t){return t===null?this:(this.w.add(t),this)}addAll(t){if(t===null)return this;if(Array.isArray(t)){const i=t.length;for(let e=0;et.add(i)),t}toArray(){return Array.from(this.w)}toList(){const t=new List;return this.w.forEach(i=>t.add(i)),t}get count(){return this.w.size}get size(){return this.w.size}get iterator(){return this.w.size<=0?EmptyIterator.instance:new SetIterator(this)}entries(){return this.w.entries()}keys(){return this.w.keys()}forEach(t,i){return this.w.forEach(t,i)}static nu=1;static Yi(t){t.__gohashid=GSet.nu++}static as(t){return t.__gohashid}}class MapKeySetIterator{$;ii;constructor(t){this.$=t,this.ii=t.w.keys()}[Symbol.iterator](){return this.$.w.keys()}key;value;get iterator(){return this}reset(){const t=this.$;this.ii=t.w.keys()}next(){const t=this.ii.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.$.w.size===0?null:(this.ii=this.$.w.keys(),this.ii.next().value)}any(t){for(const i of this.$.w)if(t(i[0]))return!0;return!1}all(t){for(const i of this.$.w)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.$.w)t(i[0]);return this}map(t){const i=this.$,e=new List;for(const s of i.w)e.add(t(s[0]));return e.iterator}filter(t){const i=this.$,e=new List;for(const s of i.w){const n=s[0];t(n)&&e.add(n)}return e.iterator}get count(){return this.$.size}gl(){this.key=null,this.value=null,this.ii=null}toString(){return"MapKeySetIterator"}}class MapKeySet extends GSet{$;constructor(t){super(),GSet.Yi(this),this.h=!0,this.$=t}[Symbol.iterator](){return this.w.keys()}values(){return this.w.keys()}g(){return this}rt(){return this}toString(){return"MapKeySet("+this.$.toString()+")"}add(t){Util.o("This Set is read-only: "+this.toString())}has(t){return this.$.has(t)}contains(t){return this.has(t)}delete(t){Util.o("This Set is read-only: "+this.toString())}remove(t){return this.delete(t)}clear(){Util.o("This Set is read-only: "+this.toString())}first(){return this.$.w.size===0?null:this.$.w.keys().next().value}any(t){for(const i of this.$.w)if(t(i[0]))return!0;return!1}all(t){for(const i of this.$.w)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.$.w)t(i[0]);return this}map(t){const i=new GSet;for(const e of this.$.w)i.add(t(e[0]));return i}filter(t){const i=new GSet;for(const e of this.$.w){const s=e[0];t(s)&&i.add(s)}return i}copy(){return new MapKeySet(this.$)}toSet(){const t=new GSet,i=this.$.w;for(const e of i)t.add(e[0]);return t}toArray(){const t=this.$.w,i=new Array(t.size);let e=0;for(const s of t)i[e]=s[0],e++;return i}toList(){const t=new List,i=this.$.w;for(const e of i)t.add(e[0]);return t}get count(){return this.$.size}get size(){return this.$.size}get iterator(){return this.$.size<=0?EmptyIterator.instance:new MapKeySetIterator(this.$)}}class MapValueSetIterator{$;ii;constructor(t){this.$=t,this.ii=t.w.values()}[Symbol.iterator](){return this.$.w.values()}key;value;get iterator(){return this}reset(){const t=this.$;this.ii=t.w.values()}next(){const t=this.ii.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.$.w.size===0?null:(this.ii=this.$.w.values(),this.ii.next().value)}any(t){for(const i of this.$.w)if(t(i[1]))return!0;return!1}all(t){for(const i of this.$.w)if(!t(i[1]))return!1;return!0}each(t){for(const i of this.$.w)t(i[1]);return this}map(t){const i=this.$,e=new List;for(const s of i.w)e.add(t(s[1]));return e.iterator}filter(t){const i=this.$,e=new List;for(const s of i.w){const n=s[1];t(n)&&e.add(n)}return e.iterator}get count(){return this.$.size}gl(){this.key=null,this.value=null,this.ii=null}toString(){return"MapValueSetIterator"}}class KeyValuePair{constructor(t,i){this.key=t,this.value=i}toString(){return"{"+this.key+":"+this.value+"}"}key;value}class MapIterator{$;ii;constructor(t){this.$=t,this.ii=t.w.entries()}[Symbol.iterator](){return this.$.w.entries()}key;value;get iterator(){return this}reset(){const t=this.$;this.ii=t.w.entries()}next(){const t=this.ii.next();return t.done?(this.key=null,this.value=null,!1):(this.key=t.value[0],this.value=t.value[1],!0)}hasNext(){return this.next()}first(){if(this.$.w.size===0)return null;this.ii=this.$.w.entries();const t=this.ii.next().value;return this.key=t[0],this.value=t[1],new KeyValuePair(t[0],t[1])}any(t){return this.$.any(t)}all(t){return this.$.all(t)}each(t){return this.$.each(t),this}map(t){const i=new List;let e=null;return this.$.w.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),i.add(t(e))}),i.iterator}filter(t){const i=new List;let e=null;return this.$.w.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),t(e)&&(i.add(e),e=null)}),i.iterator}get count(){return this.$.size}gl(){this.key=null,this.value=null,this.ii=null}toString(){return"MapIterator"}}class GMap{h;w;constructor(t){GSet.Yi(this),this.h=!1,this.w=new Map,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.w.entries()}entries(){return this.w.entries()}g(){return this.h=!0,this}rt(){return this.h=!1,this}toString(){return"Map()#"+GSet.as(this)}set(t,i){return this.h&&Util.T(this,t),this.w.set(t,i),this}add(t,i){return this.set(t,i)}addAll(t){if(t===null)return this;if(this.h&&Util.T(this),Array.isArray(t)){const i=t.length;for(let e=0;ei.x.toFixed(t)+" "+i.y.toFixed(t)}toString(){return"Point("+this.x+","+this.y+")"}equals(t){return t instanceof Point?this.b===t.x&&this.k===t.y:!1}equalTo(t,i){return this.b===t&&this.k===i}equalsApprox(t){return Geo.u(this.b,t.x)&&Geo.u(this.k,t.y)}add(t){return this.b+=t.x,this.k+=t.y,this}subtract(t){return this.b-=t.x,this.k-=t.y,this}offset(t,i){return this.b+=t,this.k+=i,this}rotate(t){if(t===0)return this;const i=this.b,e=this.k;if(i===0&&e===0)return this;let s=0,n=0;if(t>=360?t-=360:t<0&&(t+=360),t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const o=t*Math.PI/180;s=Math.cos(o),n=Math.sin(o)}return this.b=s*i-n*e,this.k=n*i+s*e,this}scale(t,i){return this.b*=t,this.k*=i,this}distanceSquaredPoint(t){const i=t.x-this.b,e=t.y-this.k;return i*i+e*e}distanceSquared(t,i){const e=t-this.b,s=i-this.k;return e*e+s*s}normalize(){const t=this.b,i=this.k,e=Math.sqrt(t*t+i*i);return e>0&&(this.b=t/e,this.k=i/e),this}directionPoint(t){return this.ZN(t.x-this.b,t.y-this.k)}direction(t,i){return this.ZN(t-this.b,i-this.k)}ZN(t,i){if(t===0)return i>0?90:i<0?270:0;if(i===0)return t>0?0:180;{if(isNaN(t)||isNaN(i))return 0;let e=Math.atan(Math.abs(i/t))*180/Math.PI;return t<0?i<0?e+=180:e=180-e:i<0&&(e=360-e),e}}static compareWithLineSegment(t,i,e,s,n,o){return Geo.ou(t,i,e,s,n,o)}compareWithLineSegmentPoint(t,i){return Geo.ou(t.x,t.y,i.x,i.y,this.x,this.y)}static intersectingLineSegments(t,i,e,s,n,o,r,l){return Geo.ru(t,i,e,s,n,o,r,l)}projectOntoLineSegment(t,i,e,s){return Geo.ml(t,i,e,s,this.b,this.k,this),this}projectOntoLineSegmentPoint(t,i){return Geo.ml(t.x,t.y,i.x,i.y,this.b,this.k,this),this}snapToGrid(t,i,e,s){return Geo.Eg(this.b,this.k,t,i,e,s,this),this}snapToGridPoint(t,i){return Geo.Eg(this.b,this.k,t.x,t.y,i.width,i.height,this),this}setRectSpot(t,i){return this.b=t.x+i.x*t.width+i.offsetX,this.k=t.y+i.y*t.height+i.offsetY,this}setSpot(t,i,e,s,n){return this.b=t+n.x*e+n.offsetX,this.k=i+n.y*s+n.offsetY,this}D(t){return t.xt(this),this}Ie(t){return t._e(this),this}static distanceLineSegmentSquared(t,i,e,s,n,o){let r=n-e,l=o-s;const h=r*r+l*l,a=e-t,c=s-i,f=-a*r-c*l;if(f<=0||f>=h)return r=n-t,l=o-i,Math.min(a*a+c*c,r*r+l*l);{const u=r*c-l*a;return u*u/h}}static distanceSquared(t,i,e,s){const n=e-t,o=s-i;return n*n+o*o}static direction(t,i,e,s){const n=e-t,o=s-i;if(n===0)return o>0?90:o<0?270:0;if(o===0)return n>0?0:180;{if(isNaN(n)||isNaN(o))return 0;let r=Math.atan(Math.abs(o/n))*180/Math.PI;return n<0?o<0?r+=180:r=180-r:o<0&&(r=360-r),r}}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}isReal(){return isFinite(this.x)&&isFinite(this.y)}static Po=new Point(0,0).it();static QN=new Point(-1/0,-1/0).it();static _N=new Point(1/0,1/0).it();static tC=new Point(6,6).it();static Ak=new Point(NaN,NaN).it();static Tk=[];static l(){const t=Point.Tk.pop();return t===void 0?new Point:t}static X(t,i){const e=Point.Tk.pop();return e===void 0?new Point(t,i):(e.x=t,e.y=i,e)}static s(t){Point.Tk.push(t)}}class Size{j;H;h;constructor(t,i){t===void 0?(this.j=0,this.H=0):typeof t=="number"&&(t>=0||isNaN(t))&&typeof i=="number"&&(i>=0||isNaN(i))?(this.j=t,this.H=i):Util.o("Invalid arguments to Size constructor: "+t+", "+i),this.h=!1}a(t){return this.j=t.j,this.H=t.H,this}e(t,i){return this.j=t,this.H=i,this}setTo(t,i){return this.j=t,this.H=i,this}set(t){return this.j=t.j,this.H=t.H,this}copy(){const t=new Size;return t.j=this.j,t.H=this.H,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}rt(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;return n=i[e++],n&&(o=parseFloat(n)),new Size(s,o)}else return new Size}static stringify(t){return t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.i(t,"number",Size,"stringifyFixed:digits"),i=>i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Size("+this.width+","+this.height+")"}equals(t){return t instanceof Size?this.j===t.width&&this.H===t.height:!1}equalTo(t,i){return this.j===t&&this.H===i}equalsApprox(t){return Geo.u(this.j,t.width)&&Geo.u(this.H,t.height)}inflate(t,i){const e=this.width+t;this.j=e>=0?e:0;const s=this.height+i;return this.H=s>=0?s:0,this}get width(){return this.j}set width(t){t<0&&Util._(t,">= 0",Size,"width"),this.j=t}get height(){return this.H}set height(t){t<0&&Util._(t,">= 0",Size,"height"),this.H=t}isReal(){return isFinite(this.width)&&isFinite(this.height)}static lu=new Size(0,0).it();static Dk=new Size(1,1).it();static iC=new Size(6,6).it();static hu=new Size(8,8).it();static eC=new Size(10,10).it();static sC=new Size(1/0,1/0).it();static gw=new Size(NaN,NaN).it();static nC=[];static l(){const t=Size.nC.pop();return t===void 0?new Size:t}static s(t){Size.nC.push(t)}}class Rect{b;k;j;H;h;constructor(t,i,e,s){if(t===void 0)this.b=0,this.k=0,this.j=0,this.H=0;else if(typeof t=="number"&&typeof i=="number"&&typeof e=="number"&&(e>=0||isNaN(e))&&typeof s=="number"&&(s>=0||isNaN(s)))this.b=t,this.k=i,this.j=e,this.H=s;else if(t instanceof Point){const n=t.x,o=t.y;if(i instanceof Point){const r=i.x,l=i.y;this.b=Math.min(n,r),this.k=Math.min(o,l),this.j=Math.abs(n-r),this.H=Math.abs(o-l)}else i instanceof Size?(this.b=n,this.k=o,this.j=i.width,this.H=i.height):Util.o("Incorrect second argument supplied to Rect constructor "+i)}else Util.o("Invalid arguments to Rect constructor: "+t+", "+i+", "+e+", "+s);this.h=!1}a(t){return this.b=t.b,this.k=t.k,this.j=t.j,this.H=t.H,this}e(t,i,e,s){return this.b=t,this.k=i,this.j=e,this.H=s,this}En(t,i){return this.j=t,this.H=i,this}setTo(t,i,e,s){return this.b=t,this.k=i,this.j=e,this.H=s,this}set(t){return this.b=t.b,this.k=t.k,this.j=t.j,this.H=t.H,this}setPoint(t){return this.b=t.x,this.k=t.y,this}setSize(t){return this.j=t.width,this.H=t.height,this}copy(){const t=new Rect;return t.b=this.b,t.k=this.k,t.j=this.j,t.H=this.H,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}rt(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),new Rect(s,o,r,l)}else return new Rect}static stringify(t){return t.x.toString()+" "+t.y.toString()+" "+t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.i(t,"number",Rect,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Rect("+this.x+","+this.y+","+this.width+","+this.height+")"}equals(t){return t instanceof Rect?this.b===t.x&&this.k===t.y&&this.j===t.width&&this.H===t.height:!1}equalTo(t,i,e,s){return this.b===t&&this.k===i&&this.j===e&&this.H===s}equalsApprox(t){return Geo.u(this.b,t.x)&&Geo.u(this.k,t.y)&&Geo.u(this.j,t.width)&&Geo.u(this.H,t.height)}equalsApproxTo(t,i,e,s){return Geo.u(this.b,t)&&Geo.u(this.k,i)&&Geo.u(this.j,e)&&Geo.u(this.H,s)}equalsApproxClose(t){return Geo.K(this.b,t.x)&&Geo.K(this.k,t.y)&&Geo.K(this.j,t.width)&&Geo.K(this.H,t.height)}containsPoint(t){return this.b<=t.x&&this.b+this.j>=t.x&&this.k<=t.y&&this.k+this.H>=t.y}containsRect(t){return this.b<=t.x&&t.x+t.width<=this.b+this.j&&this.k<=t.y&&t.y+t.height<=this.k+this.H}contains(t,i,e,s){return e===void 0&&(e=0),s===void 0&&(s=0),this.b<=t&&t+e<=this.b+this.j&&this.k<=i&&i+s<=this.k+this.H}offset(t,i){return this.b+=t,this.k+=i,this}inflate(t,i){return this.mw(i,t,i,t)}addMargin(t){return this.mw(t.top,t.right,t.bottom,t.left)}subtractMargin(t){return this.mw(-t.top,-t.right,-t.bottom,-t.left)}grow(t,i,e,s){return this.mw(t,i,e,s)}mw(t,i,e,s){const n=this.j;i+s<=-n?(this.b+=n/2,this.j=0):(this.b-=s,this.j+=i+s);const o=this.H;return t+e<=-o?(this.k+=o/2,this.H=0):(this.k-=t,this.H+=t+e),this}intersectRect(t){return this.oC(t.x,t.y,t.width,t.height)}intersect(t,i,e,s){return this.oC(t,i,e,s)}oC(t,i,e,s){const n=Math.max(this.b,t),o=Math.max(this.k,i),r=Math.min(this.b+this.j,t+e),l=Math.min(this.k+this.H,i+s);return this.b=n,this.k=o,this.j=Math.max(0,r-n),this.H=Math.max(0,l-o),this}intersectsRect(t){return this.intersects(t.x,t.y,t.width,t.height)}intersects(t,i,e,s){let n=this.j;const o=this.b;if(n!==1/0&&e!==1/0&&(n+=o,e+=t,isNaN(e)||isNaN(n)||o>e||t>n))return!1;let r=this.H;const l=this.k;return!(r!==1/0&&s!==1/0&&(r+=l,s+=i,isNaN(s)||isNaN(r)||l>s||i>r))}intersectsRectPlus(t,i){let e=this.j,s=t.width+i+i;const n=this.b,o=t.x-i;if(e+=n,s+=o,n>s||o>e)return!1;let r=this.H,l=t.height+i+i;const h=this.k,a=t.y-i;return r+=h,l+=a,!(h>l||a>r)}unionPoint(t){return this.unionNoCheck(t.x,t.y,0,0)}unionRect(t){return this.unionNoCheck(t.b,t.k,t.j,t.H)}union(t,i,e,s){return e===void 0&&(e=0),s===void 0&&(s=0),this.unionNoCheck(t,i,e,s)}unionNoCheck(t,i,e,s){const n=Math.min(this.b,t),o=Math.min(this.k,i),r=Math.max(this.b+this.j,t+e),l=Math.max(this.k+this.H,i+s);return this.b=n,this.k=o,this.j=r-n,this.H=l-o,this}setSpot(t,i,e){return this.b=t-e.offsetX-e.x*this.j,this.k=i-e.offsetY-e.y*this.H,this}static contains(t,i,e,s,n,o,r,l){return r===void 0&&(r=0),l===void 0&&(l=0),t<=n&&n+r<=t+e&&i<=o&&o+l<=i+s}static intersects(t,i,e,s,n,o,r,l){let h=e,a=r;const c=t,f=n;if(h+=c,a+=f,c>a||f>h)return!1;let u=s,d=l;const m=i,g=o;return u+=m,d+=g,!(m>d||g>u)}static intersectsLineSegment(t,i,e,s,n,o,r,l){return Geo.rC(t,i,e,s,n,o,r,l)}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}get width(){return this.j}set width(t){t<0&&Util._(t,">= 0",Rect,"width"),this.j=t}get height(){return this.H}set height(t){t<0&&Util._(t,">= 0",Rect,"height"),this.H=t}get left(){return this.b}set left(t){this.b=t}get top(){return this.k}set top(t){this.k=t}get right(){return this.b+this.j}set right(t){this.b+=t-(this.b+this.j)}get bottom(){return this.k+this.H}set bottom(t){this.k+=t-(this.k+this.H)}get position(){return new Point(this.b,this.k)}set position(t){this.b=t.x,this.k=t.y}get size(){return new Size(this.j,this.H)}set size(t){this.j=t.width,this.H=t.height}get center(){return new Point(this.b+this.j/2,this.k+this.H/2)}set center(t){this.b=t.x-this.j/2,this.k=t.y-this.H/2}get centerX(){return this.b+this.j/2}set centerX(t){this.b=t-this.j/2}get centerY(){return this.k+this.H/2}set centerY(t){this.k=t-this.H/2}isReal(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)}isEmpty(){return this.width===0&&this.height===0}static pw=new Rect(0,0,0,0).it();static TD=new Rect(NaN,NaN,NaN,NaN).it();static Fk=[];static l(){const t=Rect.Fk.pop();return t===void 0?new Rect:t}static X(t,i,e,s){const n=Rect.Fk.pop();return n===void 0?new Rect(t,i,e,s):n.e(t,i,e,s)}static s(t){Rect.Fk.push(t)}}class Margin{nn;on;rn;ln;h;constructor(t,i,e,s){t===void 0?(this.nn=0,this.on=0,this.rn=0,this.ln=0):i===void 0?(i=t,e=t,s=t,this.top=t,this.right=i,this.bottom=e,this.left=s):e===void 0?(e=t,s=i,this.top=t,this.right=i,this.bottom=e,this.left=s):s!==void 0?(this.top=t,this.right=i,this.bottom=e,this.left=s):Util.o("Invalid arguments to Margin constructor: "+t+", "+i+", "+e+", "+s),this.h=!1}a(t){return this.nn=t.nn,this.on=t.on,this.rn=t.rn,this.ln=t.ln,this}setTo(t,i,e,s){return this.nn=t,this.on=i,this.rn=e,this.ln=s,this}set(t){return this.nn=t.nn,this.on=t.on,this.rn=t.rn,this.ln=t.ln,this}copy(){const t=new Margin;return t.nn=this.nn,t.on=this.on,t.rn=this.rn,t.ln=this.ln,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}rt(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=NaN;for(;i[e]==="";)e++;let n=i[e++];if(n&&(s=parseFloat(n)),isNaN(s))return new Margin;let o=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(o=parseFloat(n)),isNaN(o))return new Margin(s);let r=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(r=parseFloat(n)),isNaN(r))return new Margin(s,o);let l=NaN;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),isNaN(l)?new Margin(s,o):new Margin(s,o,r,l)}else return new Margin}static stringify(t){return t.top.toString()+" "+t.right.toString()+" "+t.bottom.toString()+" "+t.left.toString()}static stringifyFixed(t){return Util.i(t,"number",Margin,"stringifyFixed:digits"),i=>i.top.toFixed(t)+" "+i.right.toFixed(t)+" "+i.bottom.toFixed(t)+" "+i.left.toFixed(t)}toString(){return"Margin("+this.top+","+this.right+","+this.bottom+","+this.left+")"}equals(t){return t instanceof Margin?this.nn===t.top&&this.on===t.right&&this.rn===t.bottom&&this.ln===t.left:!1}equalTo(t,i,e,s){return this.nn===t&&this.on===i&&this.rn===e&&this.ln===s}equalsApprox(t){return Geo.u(this.nn,t.top)&&Geo.u(this.on,t.right)&&Geo.u(this.rn,t.bottom)&&Geo.u(this.ln,t.left)}get top(){return this.nn}set top(t){this.nn=t}get right(){return this.on}set right(t){this.on=t}get bottom(){return this.rn}set bottom(t){this.rn=t}get left(){return this.ln}set left(t){this.ln=t}isReal(){return isFinite(this.top)&&isFinite(this.right)&&isFinite(this.bottom)&&isFinite(this.left)}static Ug=new Margin(0,0,0,0).it();static lC=new Margin(2,2,2,2).it();static hC=[];static l(){const t=Margin.hC.pop();return t===void 0?new Margin:t}static s(t){Margin.hC.push(t)}}class Spot{b;k;As;Ts;h;constructor(t,i,e,s){t===void 0?(this.b=0,this.k=0,this.As=0,this.Ts=0):(i===void 0&&(i=0),e===void 0&&(e=0),s===void 0&&(s=0),this.x=t,this.y=i,this.offsetX=e,this.offsetY=s),this.h=!1}a(t){return this.b=t.b,this.k=t.k,this.As=t.As,this.Ts=t.Ts,this}setTo(t,i,e,s){return this.b=t,this.k=i,this.As=e,this.Ts=s,this}set(t){return this.b=t.b,this.k=t.k,this.As=t.As,this.Ts=t.Ts,this}copy(){const t=new Spot;return t.b=this.b,t.k=this.k,t.As=this.As,t.Ts=this.Ts,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}rt(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}Ee(t){return this.b=NaN,this.k=NaN,this.As=t,this}tE(t,i){(isNaN(t)||t>1||t<0)&&Util._(t,"0 <= "+i+" <= 1",Spot,i)}iE(t,i){(isNaN(t)||t===1/0||t===-1/0)&&Util._(t,"real number, not NaN or Infinity",Spot,i)}static parse(t){if(typeof t=="string"){if(t=t.trim(),t==="None")return Spot.None;if(t==="TopLeft")return Spot.TopLeft;if(t==="Top"||t==="TopCenter"||t==="MiddleTop")return Spot.TopCenter;if(t==="TopRight")return Spot.TopRight;if(t==="Left"||t==="LeftCenter"||t==="MiddleLeft")return Spot.LeftCenter;if(t==="Center")return Spot.Center;if(t==="Right"||t==="RightCenter"||t==="MiddleRight")return Spot.RightCenter;if(t==="BottomLeft")return Spot.BottomLeft;if(t==="Bottom"||t==="BottomCenter"||t==="MiddleBottom")return Spot.BottomCenter;if(t==="BottomRight")return Spot.BottomRight;if(t==="TopSide")return Spot.TopSide;if(t==="LeftSide")return Spot.LeftSide;if(t==="RightSide")return Spot.RightSide;if(t==="BottomSide")return Spot.BottomSide;if(t==="TopBottomSides")return Spot.TopBottomSides;if(t==="LeftRightSides")return Spot.LeftRightSides;if(t==="TopLeftSides")return Spot.TopLeftSides;if(t==="TopRightSides")return Spot.TopRightSides;if(t==="BottomLeftSides")return Spot.BottomLeftSides;if(t==="BottomRightSides")return Spot.BottomRightSides;if(t==="NotTopSide")return Spot.NotTopSide;if(t==="NotLeftSide")return Spot.NotLeftSide;if(t==="NotRightSide")return Spot.NotRightSide;if(t==="NotBottomSide")return Spot.NotBottomSide;if(t==="AllSides")return Spot.AllSides;if(t==="Default")return Spot.Default;const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n!==void 0&&n.length>0&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n!==void 0&&n.length>0&&(l=parseFloat(n)),new Spot(s,o,r,l)}else return new Spot}static stringify(t){return t.isSpot()?t.x.toString()+" "+t.y.toString()+" "+t.offsetX.toString()+" "+t.offsetY.toString():t.toString()}static stringifyFixed(t){return Util.i(t,"number",Spot,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.offsetX.toFixed(t)+" "+i.offsetY.toFixed(t)}toString(){return this.isSpot()?this.As===0&&this.Ts===0?"Spot("+this.x+","+this.y+")":"Spot("+this.x+","+this.y+","+this.offsetX+","+this.offsetY+")":this.equals(Spot.None)?"None":this.equals(Spot.TopLeft)?"TopLeft":this.equals(Spot.TopCenter)?"Top":this.equals(Spot.TopRight)?"TopRight":this.equals(Spot.LeftCenter)?"Left":this.equals(Spot.Center)?"Center":this.equals(Spot.RightCenter)?"Right":this.equals(Spot.BottomLeft)?"BottomLeft":this.equals(Spot.BottomCenter)?"Bottom":this.equals(Spot.BottomRight)?"BottomRight":this.equals(Spot.TopSide)?"TopSide":this.equals(Spot.LeftSide)?"LeftSide":this.equals(Spot.RightSide)?"RightSide":this.equals(Spot.BottomSide)?"BottomSide":this.equals(Spot.TopBottomSides)?"TopBottomSides":this.equals(Spot.LeftRightSides)?"LeftRightSides":this.equals(Spot.TopLeftSides)?"TopLeftSides":this.equals(Spot.TopRightSides)?"TopRightSides":this.equals(Spot.BottomLeftSides)?"BottomLeftSides":this.equals(Spot.BottomRightSides)?"BottomRightSides":this.equals(Spot.NotTopSide)?"NotTopSide":this.equals(Spot.NotLeftSide)?"NotLeftSide":this.equals(Spot.NotRightSide)?"NotRightSide":this.equals(Spot.NotBottomSide)?"NotBottomSide":this.equals(Spot.AllSides)?"AllSides":this.equals(Spot.Default)?"Default":"None"}equals(t){return t instanceof Spot?(this.b===t.x||isNaN(this.b)&&isNaN(t.x))&&(this.k===t.y||isNaN(this.k)&&isNaN(t.y))&&this.As===t.offsetX&&this.Ts===t.offsetY:!1}opposite(){return new Spot(.5-(this.b-.5),.5-(this.k-.5),-this.As,-this.Ts)}includesSide(t){if(!this.isSide())return!1;if(!t.isSide())if(t.equals(Spot.Left))t=Spot.LeftSide;else if(t.equals(Spot.Right))t=Spot.RightSide;else if(t.equals(Spot.Top))t=Spot.TopSide;else if(t.equals(Spot.Bottom))t=Spot.BottomSide;else return!1;const i=this.Ts,e=t.offsetY;return(i&e)===e}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}get offsetX(){return this.As}set offsetX(t){this.As=t}get offsetY(){return this.Ts}set offsetY(t){this.Ts=t}isSpot(){return!isNaN(this.x)&&!isNaN(this.y)}isNoSpot(){return isNaN(this.x)||isNaN(this.y)}isSide(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===1&&this.offsetY!==0}isNone(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===0&&this.offsetY===0}isDefault(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===-1&&this.offsetY===0}static None=new Spot(0,0,0,0).Ee(0).it();static Default=new Spot(0,0,-1,0).Ee(-1).it();static TopLeft=new Spot(0,0,0,0).it();static TopCenter=new Spot(.5,0,0,0).it();static TopRight=new Spot(1,0,0,0).it();static LeftCenter=new Spot(0,.5,0,0).it();static Center=new Spot(.5,.5,0,0).it();static RightCenter=new Spot(1,.5,0,0).it();static BottomLeft=new Spot(0,1,0,0).it();static BottomCenter=new Spot(.5,1,0,0).it();static BottomRight=new Spot(1,1,0,0).it();static MiddleTop=Spot.TopCenter;static MiddleLeft=Spot.LeftCenter;static MiddleRight=Spot.RightCenter;static MiddleBottom=Spot.BottomCenter;static Top=Spot.TopCenter;static Left=Spot.LeftCenter;static Right=Spot.RightCenter;static Bottom=Spot.BottomCenter;static TopSide=new Spot(0,0,1,1).Ee(1).it();static LeftSide=new Spot(0,0,1,2).Ee(1).it();static RightSide=new Spot(0,0,1,4).Ee(1).it();static BottomSide=new Spot(0,0,1,8).Ee(1).it();static TopBottomSides=new Spot(0,0,1,9).Ee(1).it();static LeftRightSides=new Spot(0,0,1,6).Ee(1).it();static TopLeftSides=new Spot(0,0,1,3).Ee(1).it();static TopRightSides=new Spot(0,0,1,5).Ee(1).it();static BottomLeftSides=new Spot(0,0,1,10).Ee(1).it();static BottomRightSides=new Spot(0,0,1,12).Ee(1).it();static NotTopSide=new Spot(0,0,1,14).Ee(1).it();static NotLeftSide=new Spot(0,0,1,13).Ee(1).it();static NotRightSide=new Spot(0,0,1,11).Ee(1).it();static NotBottomSide=new Spot(0,0,1,7).Ee(1).it();static AllSides=new Spot(0,0,1,15).Ee(1).it();static Rk=new Spot(.156,.156).it();static vk=new Spot(.844,.844).it();static aC=[];static l(){const t=Spot.aC.pop();return t===void 0?new Spot:t}static s(t){Spot.aC.push(t)}}class Transform{m11;m12;m21;m22;dx;dy;constructor(){this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0}set(t){return this.m11=t.m11,this.m12=t.m12,this.m21=t.m21,this.m22=t.m22,this.dx=t.dx,this.dy=t.dy,this}setTo(t,i,e,s,n,o){return this.m11=t,this.m12=i,this.m21=e,this.m22=s,this.dx=n,this.dy=o,this}copy(){const t=new Transform;return t.m11=this.m11,t.m12=this.m12,t.m21=this.m21,t.m22=this.m22,t.dx=this.dx,t.dy=this.dy,t}toString(){return"Transform("+this.m11+","+this.m12+","+this.m21+","+this.m22+","+this.dx+","+this.dy+")"}equals(t){return this.m11===t.m11&&this.m12===t.m12&&this.m21===t.m21&&this.m22===t.m22&&this.dx===t.dx&&this.dy===t.dy}Ok(){return this.dx===0&&this.dy===0&&this.m11===1&&this.m12===0&&this.m21===0&&this.m22===1}Ri(){return this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0,this}tc(t){const i=this.m11*t.m11+this.m21*t.m12,e=this.m12*t.m11+this.m22*t.m12,s=this.m11*t.m21+this.m21*t.m22,n=this.m12*t.m21+this.m22*t.m22;return this.dx=this.m11*t.dx+this.m21*t.dy+this.dx,this.dy=this.m12*t.dx+this.m22*t.dy+this.dy,this.m11=i,this.m12=e,this.m21=s,this.m22=n,this}cC(t){const i=1/(t.m11*t.m22-t.m12*t.m21),e=t.m22*i,s=-t.m12*i,n=-t.m21*i,o=t.m11*i,r=i*(t.m21*t.dy-t.m22*t.dx),l=i*(t.m12*t.dx-t.m11*t.dy),h=this.m11*e+this.m21*s,a=this.m12*e+this.m22*s,c=this.m11*n+this.m21*o,f=this.m12*n+this.m22*o;return this.dx=this.m11*r+this.m21*l+this.dx,this.dy=this.m12*r+this.m22*l+this.dy,this.m11=h,this.m12=a,this.m21=c,this.m22=f,this}yw(){const t=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*t,e=-this.m12*t,s=-this.m21*t,n=this.m11*t,o=t*(this.m21*this.dy-this.m22*this.dx),r=t*(this.m12*this.dx-this.m11*this.dy);return this.m11=i,this.m12=e,this.m21=s,this.m22=n,this.dx=o,this.dy=r,this}cs(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return this;this.Ds(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m11*s+this.m21*n,r=this.m12*s+this.m22*n,l=this.m11*-n+this.m21*s,h=this.m12*-n+this.m22*s;return this.m11=o,this.m12=r,this.m21=l,this.m22=h,this.Ds(-i,-e),this}Ds(t,i){return this.dx+=this.m11*t+this.m21*i,this.dy+=this.m12*t+this.m22*i,this}st(t,i){return i===void 0&&(i=t),this.m11*=t,this.m12*=t,this.m21*=i,this.m22*=i,this}DD(){if(this.m11===1&&this.m12===0)return 0;let t=Math.atan2(this.m12,this.m11)*180/Math.PI;return t<0&&(t+=360),t}xt(t){const i=t.x,e=t.y;return t.e(i*this.m11+e*this.m21+this.dx,i*this.m12+e*this.m22+this.dy)}_e(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=t.x-this.dx,l=t.y-this.dy;return t.e(r*e+l*n,r*s+l*o)}ww(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=i*(this.m21*this.dy-this.m22*this.dx),l=i*(this.m12*this.dx-this.m11*this.dy),h=t.x*1.25,a=t.y*1.2;return t.e(h*e+a*n+r,h*s+a*o+l)}xw(t){const i=t.x,e=t.y,s=i+t.width,n=e+t.height,o=this.m11,r=this.m12,l=this.m21,h=this.m22,a=this.dx,c=this.dy,f=i*o+e*l+a,u=i*r+e*h+c,d=s*o+e*l+a,m=s*r+e*h+c,g=i*o+n*l+a,p=i*r+n*h+c,y=s*o+n*l+a,x=s*r+n*h+c;let k=f,b=f,P=u,M=u;return k=Math.min(k,d),b=Math.max(b,d),P=Math.min(P,m),M=Math.max(M,m),k=Math.min(k,g),b=Math.max(b,g),P=Math.min(P,p),M=Math.max(M,p),k=Math.min(k,y),b=Math.max(b,y),P=Math.min(P,x),M=Math.max(M,x),t.e(k,P,b-k,M-P),t}static fC=[];static l(){const t=Transform.fC.pop();return t===void 0?new Transform:t}static s(t){Transform.fC.push(t)}static Ik="54a702f3e53909c447824c6706603faf4c"}const Geo={FD:"7da71ca0ad381e90",Un:4*((Math.sqrt(2)-1)/3),uC:null,bw:w=>{if(w<=0)return 0;let t=Geo.uC;if(t===null){t=[];for(let i=0;i<=2e3;i++)t[i]=Math.sqrt(i);Geo.uC=t}if(w<1){const i=1/w;return i<=2e3?1/t[i|0]:Math.sqrt(w)}else return w<=2e3?t[w|0]:Math.sqrt(w)},u:(w,t)=>{const i=w-t;return i<.5&&i>-.5},K:(w,t)=>{const i=w-t;return i<5e-8&&i>-5e-8},vi:(w,t,i,e,s,n,o)=>{s<=0&&(s=1e-6);let r=0,l=0,h=0,a=0;if(wu-d)if(w-i>s||i-w>s){const g=(e-t)/(i-w)*(n-w)+t;if(g-s<=o&&o<=g+s)return!0}else return!0;else if(t-e>s||e-t>s){const g=(i-w)/(e-t)*(o-t)+w;if(g-s<=n&&n<=g+s)return!0}else return!0}return!1},kw:(w,t,i,e,s,n,o,r,l,h,a,c)=>{if(!Geo.vi(w,t,o,r,c,i,e)||!Geo.vi(w,t,o,r,c,s,n)){const f=(w+i)/2,u=(t+e)/2,d=(i+s)/2,m=(e+n)/2,g=(s+o)/2,p=(n+r)/2,y=(f+d)/2,x=(u+m)/2,k=(d+g)/2,b=(m+p)/2,P=(y+k)/2,M=(x+b)/2;return Geo.kw(w,t,f,u,y,x,P,M,l,h,a,c)||Geo.kw(P,M,k,b,g,p,o,r,l,h,a,c)}else return Geo.vi(w,t,o,r,c,h,a)},dC:(w,t,i,e,s,n,o,r,l)=>{const h=(w+i)/2,a=(t+e)/2,c=(i+s)/2,f=(e+n)/2,u=(s+o)/2,d=(n+r)/2,m=(h+c)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2;return l.e((m+p)/2,(g+y)/2),l},RD:(w,t,i,e,s,n,o,r)=>{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(s+o)/2,u=(n+r)/2,d=(l+a)/2,m=(h+c)/2,g=(a+f)/2,p=(c+u)/2;return Point.direction(d,m,g,p)},au:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.vi(w,t,o,r,l,i,e)||!Geo.vi(w,t,o,r,l,s,n)){const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.au(w,t,a,c,g,p,k,b,l,h),Geo.au(k,b,y,x,d,m,o,r,l,h)}else h.unionNoCheck(w,t,0,0),h.unionNoCheck(o,r,0,0);return h},Bn:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.vi(w,t,o,r,l,i,e)||!Geo.vi(w,t,o,r,l,s,n)){const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.Bn(w,t,a,c,g,p,k,b,l,h),Geo.Bn(k,b,y,x,d,m,o,r,l,h)}else h.length===0&&(h.push(w),h.push(t)),h.push(o),h.push(r);return h},Ek:(w,t,i,e,s,n,o,r,l,h)=>{if(Geo.vi(w,t,s,n,h,i,e))return Geo.vi(w,t,s,n,h,r,l);{const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(a+f)/2,m=(c+u)/2;return Geo.Ek(w,t,a,c,d,m,o,r,l,h)||Geo.Ek(d,m,f,u,s,n,o,r,l,h)}},eE:(w,t,i,e,s,n,o)=>{const r=(w+i)/2,l=(t+e)/2,h=(i+s)/2,a=(e+n)/2;return o.e((r+h)/2,(l+a)/2),o},Uk:(w,t,i,e,s,n,o,r)=>{if(Geo.vi(w,t,s,n,o,i,e))r.unionNoCheck(w,t,0,0),r.unionNoCheck(s,n,0,0);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(l+a)/2,u=(h+c)/2;Geo.Uk(w,t,l,h,f,u,o,r),Geo.Uk(f,u,a,c,s,n,o,r)}return r},Bg:(w,t,i,e,s,n,o,r)=>{if(Geo.vi(w,t,s,n,o,i,e))r.length===0&&(r.push(w),r.push(t)),r.push(s),r.push(n);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(l+a)/2,u=(h+c)/2;Geo.Bg(w,t,l,h,f,u,o,r),Geo.Bg(f,u,a,c,s,n,o,r)}return r},Vg:(w,t,i,e,s,n,o,r,l,h,a,c,f,u)=>{if(!Geo.vi(w,t,o,r,f,i,e)||!Geo.vi(w,t,o,r,f,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,P=(g+y)/2,M=(p+x)/2,L=(k+P)/2,C=(b+M)/2;let S=1/0,N=!1,T=0,A=0;if(Geo.Vg(w,t,d,m,k,b,L,C,l,h,a,c,f,u)){const D=(u.x-l)*(u.x-l)+(u.y-h)*(u.y-h);D{let u=0;if(!Geo.vi(w,t,o,r,f,i,e)||!Geo.vi(w,t,o,r,f,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,P=(g+y)/2,M=(p+x)/2,L=(k+P)/2,C=(b+M)/2;u+=Geo.zg(w,t,d,m,k,b,L,C,l,h,a,c,f),u+=Geo.zg(L,C,P,M,y,x,o,r,l,h,a,c,f)}else{const d=(w-o)*(h-c)-(t-r)*(l-a);if(d===0)return u;const m=((w*r-t*o)*(l-a)-(w-o)*(l*c-h*a))/d,g=((w*r-t*o)*(h-c)-(t-r)*(l*c-h*a))/d;if(m>=a)return u;let p=0,y=0;if((l>a?l-a:a-l)<(h>c?h-c:c-h)){if(ty)return u}else if(wy)return u;d>0?u++:d<0&&u--}return u},ml:(w,t,i,e,s,n,o)=>{if(Geo.K(w,i)){let r=0,l=0;tl?(o.e(w,l),!1):(o.e(w,h),!0)}else if(Geo.K(t,e)){let r=0,l=0;wl?(o.e(l,t),!1):(o.e(h,t),!0)}else{const r=(i-w)*(i-w)+(e-t)*(e-t),l=((w-s)*(w-i)+(t-n)*(t-e))/r;if(l<-5e-6)return o.e(w,t),!1;if(l>1.000005)return o.e(i,e),!1;{const h=w+l*(i-w),a=t+l*(e-t);return o.e(h,a),!0}}},Vn:(w,t,i,e,s,n,o,r,l)=>{if(Geo.u(w,i)&&Geo.u(t,e))return l.e(w,t),!1;if(Geo.K(s,o)){if(Geo.K(w,i))return Geo.ml(w,t,i,e,s,n,l),!1;{const a=(e-t)/(i-w)*(s-w)+t;return Geo.ml(w,t,i,e,s,a,l)}}else{const h=(r-n)/(o-s);if(Geo.K(w,i)){const a=h*(w-s)+n;let c=0,f=0;return tf?(l.e(w,f),!1):(l.e(w,a),!0)}else{const a=(e-t)/(i-w);if(Geo.K(h,a))return Geo.ml(w,t,i,e,s,n,l),!1;{const c=(a*w-h*s+n-t)/(a-h);if(Geo.K(a,0)){let f=0,u=0;return wu?(l.e(u,t),!1):(l.e(c,t),!0)}else{const f=a*(c-w)+t;return Geo.ml(w,t,i,e,c,f,l)}}}}},sE:(w,t,i,e,s)=>Geo.Vn(i.x,i.y,e.x,e.y,w.x,w.y,t.x,t.y,s),nE:(w,t,i,e,s,n,o,r,l,h)=>{let a=1/0;function c(P,M){const L=(P-w)*(P-w)+(M-t)*(M-t);Lw?i-w:w-i)<.5){const P=1-(i-k)*(i-k)/(y*y);if(P<0)return l;const M=Math.sqrt(P),L=x*M+b,C=-x*M+b;c(i,L),c(i,C)}else{const P=(e-t)/(i-w),M=1/(y*y)+P*P/(x*x),L=2*P*(t-P*w)/(x*x)-2*P*b/(x*x)-2*k/(y*y),C=2*P*w*b/(x*x)-2*t*b/(x*x)+b*b/(x*x)+k*k/(y*y)-1+(t-P*w)*(t-P*w)/(x*x),S=L*L-4*M*C;if(S<0)return l;const N=Math.sqrt(S),T=(-L+N)/(2*M);c(T,P*T-P*w+t);const A=(-L-N)/(2*M);c(A,P*A-P*w+t)}return l},pl:(w,t,i,e,s,n,o,r,l)=>{let h=1e21,a=w,c=t;if(Geo.Vn(w,t,w,e,s,n,o,r,l)){const f=(l.x-s)*(l.x-s)+(l.y-n)*(l.y-n);fGeo.rC(w.x,w.y,w.width,w.height,t.x,t.y,i.x,i.y),rC:(w,t,i,e,s,n,o,r)=>{const l=w,h=w+i,a=t,c=t+e;if(s===o){let f=0,u=0;return n=a}if(n===r){let f=0,u=0;return s=l}return!!(Rect.contains(w,t,i,e,s,n)||Rect.contains(w,t,i,e,o,r)||Geo.ru(l,a,h,a,s,n,o,r)||Geo.ru(h,a,h,c,s,n,o,r)||Geo.ru(h,c,l,c,s,n,o,r)||Geo.ru(l,c,l,a,s,n,o,r))},ru:(w,t,i,e,s,n,o,r)=>w===i&&t===e&&s===o&&n===r?w===s&&t===n:Geo.ou(w,t,i,e,s,n)*Geo.ou(w,t,i,e,o,r)<=0&&Geo.ou(s,n,o,r,w,t)*Geo.ou(s,n,o,r,i,e)<=0,ou:(w,t,i,e,s,n)=>{const o=i-w,r=e-t;let l=s-w,h=n-t,a=l*r-h*o;return a===0&&(a=l*o+h*r,a>0&&(l-=o,h-=r,a=l*o+h*r,a<0&&(a=0))),a},Xg:w=>(w<0&&(w+=360),w>=360&&(w-=360),w),gC:(w,t,i,e,s,n)=>{const o=Math.PI;n||(e=e*(o/180),s=s*(o/180));const r=e>s?-1:1,l=1e-5,h=o*2,a=[],c=o/2;let f=e,u=Math.min(h,Math.abs(s-e));if(ul;){const d=f+r*Math.min(u,c);a.push(Geo.vD(i,f,d,w,t)),u-=Math.abs(d-f),f=d}return a},vD:(w,t,i,e,s)=>{const n=(i-t)/2,o=w*Math.cos(n),r=w*Math.sin(n),l=o,h=-r,a=l*l+h*h,c=a+l*o+h*r,f=4/3*(Math.sqrt(2*a*c)-c)/(l*r-h*o),u=l-f*h,d=h+f*l,m=u,g=-d,p=n+t,y=Math.cos(p),x=Math.sin(p);return[e+w*Math.cos(t),s+w*Math.sin(t),e+u*y-d*x,s+u*x+d*y,e+m*y-g*x,s+m*x+g*y,e+w*Math.cos(i),s+w*Math.sin(i)]},Eg:(w,t,i,e,s,n,o)=>{const r=s,l=n,h=Math.floor((w-i)/r)*r+i,a=Math.floor((t-e)/l)*l+e;let c=h;h+r-w{let i=Math.max(w,t),e=Math.min(w,t),s=1,n=1;do s=i%e,n=e,i=e,e=s;while(s>0);return n},OD:(w,t,i,e)=>{const s=i<0,n=e<0;let o=0,r=0,l=0;w{let o=0;if(e>0)if(i>0){const r=w*w,l=t*t,h=w*i,a=t*e;let c=-l+a,f=-l+Math.sqrt(h*h+a*a),u=c;const d=9999999999;for(let p=0;p0)c=u;else if(k<0)f=u;else break}s=r*i/(u+r),n=l*e/(u+l);const m=s-i,g=n-e;o=Math.sqrt(m*m+g*g)}else s=0,n=t,o=Math.abs(e-t);else{const r=w*w-t*t,l=w*i;if(l(w[w.Line=1]="Line",w[w.Rectangle=2]="Rectangle",w[w.Ellipse=3]="Ellipse",w[w.Path=4]="Path",w))(GeometryType||{}),GeometryStretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w))(GeometryStretch||{});class Geometry{n;Gg;jg;ic;cu;fu;zn;Xn;Kn;Z;xe;be;Zi;Qi;Fs;ec;sc;constructor(t){GSet.Yi(this),this.n=2,t===void 0&&(t=4),this.Z=t,this.xe=0,this.be=0,this.Zi=0,this.Qi=0,t===4?this.Fs=new List:this.Fs=Geometry.Mw,this.Gg=this.Fs.at,this.jg=new Rect().g(),this.ic=null,this.cu=null,this.fu=NaN,this.zn=Spot.TopLeft,this.Xn=Spot.BottomRight,this.ec=NaN,this.sc=NaN,this.Kn=2}copy(){const t=new Geometry;if(t.n=this.n&-2,t.Z=this.Z,t.xe=this.xe,t.be=this.be,t.Zi=this.Zi,t.Qi=this.Qi,this.Z===4){const i=this.Fs.r,e=t.Fs;for(let s=0;si.toString(t)}ri(t){t in GeometryType?this.type=t:Util.lr(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e;switch(this.type){case 1:return t<0?"M"+this.startX.toString()+" "+this.startY.toString()+"L"+this.endX.toString()+" "+this.endY.toString():"M"+i(this.startX)+" "+i(this.startY)+"L"+i(this.endX)+" "+i(this.endY);case 2:return e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0?"M"+e.x.toString()+" "+e.y.toString()+"H"+e.right.toString()+"V"+e.bottom.toString()+"H"+e.left.toString()+"z":"M"+i(e.x)+" "+i(e.y)+"H"+i(e.right)+"V"+i(e.bottom)+"H"+i(e.left)+"z";case 3:if(e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0){const r=e.left.toString()+" "+(e.y+e.height/2).toString(),l=e.right.toString()+" "+(e.y+e.height/2).toString();return"M"+r+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+l+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+r}else{const r=i(e.left)+" "+i(e.y+e.height/2),l=i(e.right)+" "+i(e.y+e.height/2);return"M"+r+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+l+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+r}case 4:let s="";const n=this.figures.r,o=n.length;for(let r=0;r0&&(s+=" x "),l.isFilled&&(s+="F "),s+=l.toString(t)}return s;default:return GeometryType[this.type]}}static fillPath(t){typeof t!="string"&&Util.we(t,"string",Geometry,"fillPath:str");const i=t.split(/[Xx]/),e=i.length;let s="";for(let n=0;n=k-1||o[r+1].match(N)!==null?!0:(u=!1,!1)}function m(){return r++,o[r]}function g(A){let D=parseFloat(m()),F=parseFloat(m());l===l.toLowerCase()&&(D=f.x+D,F=f.y+F),A.e(D,F)}function p(){return g(f),f}function y(){return g(c),c}function x(){const A=h.toLowerCase();return A==="c"||A==="s"||A==="q"||A==="t"?new Point(2*f.x-c.x,2*f.y-c.y):new Point(f.x,f.y)}const k=o.length,b=GeoStream.yC(null);let P=!1,M=!1,L=!1,C=!0,S=null;const N=new RegExp("["+Geometry.Hg+"]");for(;!(r>=k-1);){if(h=l,l=m(),l==="")continue;u=!0;let A=!1;switch(l.toUpperCase()){case"X":C=!0,P=!1,M=!1;break;case"M":for(S=p(),b.Pi===null||C===!0?(b.uu(S.x,S.y,P,!1,!M,L),C=!1):b.ED(S.x,S.y),a.a(f);!d();)S=p(),b.ur(S.x,S.y);break;case"L":for(;!d();)S=p(),b.ur(S.x,S.y);u&&(A=!0);break;case"H":for(;!d();)f.e((l===l.toLowerCase()?f.x:0)+parseFloat(m()),f.y),b.ur(f.x,f.y);break;case"V":for(;!d();)f.e(f.x,(l===l.toLowerCase()?f.y:0)+parseFloat(m())),b.ur(f.x,f.y);u&&(A=!0);break;case"C":for(;!d();){const D=new Point;g(D);const F=y(),R=p();b.dr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(A=!0);break;case"S":for(;!d();){const D=x(),F=y(),R=p();b.dr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(A=!0);break;case"Q":for(;!d();){const D=y(),F=p();b.Sw(D.x,D.y,F.x,F.y)}u&&(A=!0);break;case"T":for(;!d();){const D=x();c.a(D);const F=p();b.Sw(D.x,D.y,F.x,F.y),c.a(F)}u&&(A=!0);break;case"B":for(;!d();){const D=parseFloat(m()),F=parseFloat(m());let R=parseFloat(m()),v=parseFloat(m());const O=parseFloat(m());let U=O,X=!1;d()||(U=parseFloat(m()),d()||(X=parseFloat(m())!==0)),l===l.toLowerCase()&&(R+=f.x,v+=f.y),b.UD(D,F,R,v,O,U,X)}u&&(A=!0);break;case"A":for(;!d();){const D=Math.abs(parseFloat(m())),F=Math.abs(parseFloat(m())),R=parseFloat(m());let v=!1,O=!1,U=0,X=0;const E=m();E.length===1?(v=!!parseFloat(E),O=!!parseFloat(m()),U=parseFloat(m()),X=parseFloat(m())):E.length===2?(v=!!parseFloat(E[0]),O=!!parseFloat(E[1]),U=parseFloat(m()),X=parseFloat(m())):(v=!!parseFloat(E[0]),O=!!parseFloat(E[1]),U=parseFloat(E.slice(2)),X=parseFloat(m())),l===l.toLowerCase()&&(U=f.x+U,X=f.y+X),f.e(U,X),b.BD(D,F,R,v,O,U,X)}u&&(A=!0);break;case"Z":b.VD(),f.a(a);break;case"F":{let D="",F=1;for(;o[r+F];){if(o[r+F]==="0"){L=!0,F++;continue}if(o[r+F].match(/[Uu]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?P=!0:b.zD();break}case"U":{let D="",F=1;for(;o[r+F];){if(o[r+F].match(/[Ff]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?M=!0:b.XD(!1);break}default:if(l==="0"||l==="1")break;Util.oi("Unknown geometry command: "+l);break}if(A){Util.oi(`Bad geometry command: ${l}, next token: ${m()}, -string: ${t}`);break}}const T=b.qg;if(GeoStream.wC(b),i){const A=T.figures.iterator;for(;A.next();){const D=A.value;D.isFilled=!0}}return T}static xC(t,i){const e=t.length,s=Point.l();for(let n=0;n=t)return 0;if((n>r?n-r:r-n)<(o>l?o-l:l-o)){if(ol)return 0}else if(co)return 0}else if(nr)return 0}else if(an)return 0;return h>0?1:-1}kC(t,i,e){const s=this.figures.r,n=s.length;for(let o=0;o1&&(t=1),i===void 0&&(i=new Point),this.type===1)return i.e(this.startX+t*(this.endX-this.startX),this.startY+t*(this.endY-this.startY)),i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[f*2],y=g[f*2+1],x=g[f*2+2],k=g[f*2+3];return i.e(p+(x-p)*m,y+(k-y)*m),i}l+=u}}return i}getAngleAlongPath(t){if(t<0?t=0:t>1&&(t=1),this.type===1)return Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI;const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=i.length,o=s*t;let r=0;for(let l=0;l=o){const u=i[l],d=u[c*2],m=u[c*2+1],g=u[c*2+2],p=u[c*2+3];return Math.abs(g-d)<1&&Math.abs(p-m)<1?0:Math.abs(g-d)<1?p-m>=0?90:270:Math.abs(p-m)<1?g-d>=0?0:180:Math.atan2(p-m,g-d)*180/Math.PI}r+=f}}return NaN}getPointAndAngleAlongPath(t,i){if(t<0?t=0:t>1&&(t=1),i===void 0&&(i=[]),i.length=3,this.type===1)return i[0]=this.startX+t*(this.endX-this.startX),i[1]=this.startY+t*(this.endY-this.startY),i[2]=Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI,i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[f*2],y=g[f*2+1],x=g[f*2+2],k=g[f*2+3];i[0]=p+(x-p)*m,i[1]=y+(k-y)*m;let b;return Math.abs(x-p)<1&&Math.abs(k-y)<1?b=0:Math.abs(x-p)<1?b=k-y>=0?90:270:Math.abs(k-y)<1?b=x-p>=0?0:180:b=Math.atan2(k-y,x-p)*180/Math.PI,i[2]=b,i}l+=u}}return i}getFractionForPoint(t){if(this.type===1){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=t.x,r=t.y;let l=0,h=0;if(i===s)return e=h?h===e?0:1:Math.abs(r-e)/(h-l);if(e===n)return i=h?h===i?0:1:Math.abs(o-i)/(h-l);{const a=(s-i)*(s-i)+(n-e)*(n-e),c=Point.l();Geo.ml(i,e,s,n,o,r,c);const f=c.x,u=c.y;return Point.s(c),Math.sqrt(((f-i)*(f-i)+(u-e)*(u-e))/a)}}}else if(this.type===2){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=s-i,r=n-e,l=o*2+r*2;let h=t.x,a=t.y;h=Math.min(Math.max(h,i),s),a=Math.min(Math.max(a,e),n);const c=Math.abs(h-i),f=Math.abs(h-s),u=Math.abs(a-e),d=Math.abs(a-n),m=Math.min(c,f,u,d);if(m===u)return h/l;if(m===f)return(o+a)/l;if(m===d)return(o*2+r-h)/l;if(m===c)return(o*2+r*2-a)/l}}else{const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=Point.l();let o=1/0,r=0,l=0;const h=i.length;let a=0,c=0;for(let u=0;u1?1:f}return 0}get flattenedSegments(){return this.PC(),this.ic}PC(){if(this.ic===null){const t=this.ic=[],i=this.cu=[];this.GD(t,i)}}get flattenedLengths(){return this.PC(),this.cu}get flattenedTotalLength(){let t=this.fu;if(isNaN(t)){if(this.type===1){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=Math.sqrt(i*i+e*e)}else if(this.type===2){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=i*2+e*2}else{const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=4&&(t.push(e),i.push(this.Xk(e))),e=[],e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY,h=r,a=l;break;case 2:e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY;break;case 3:Geo.Bn(r,l,d.point1X,d.point1Y,d.point2X,d.point2Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 4:Geo.Bg(r,l,d.point1X,d.point1Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 5:{const m=d.So(o),g=m.length;if(g===0){e.push(d.centerX),e.push(d.centerY),r=d.centerX,l=d.centerY;break}for(let p=0;p=4&&(t.push(e),i.push(this.Xk(e)))}}}get type(){return this.Z}set type(t){this.Z!==t&&(this.h&&Util.T(this,t),this.Z=t,t===4?this.Fs=new List:(Geometry.Mw===null&&(Geometry.Mw=new List().g()),this.Fs=Geometry.Mw),this.bt=!0)}get startX(){return this.xe}set startX(t){this.xe!==t&&(this.h&&Util.T(this,t),this.xe=t,this.bt=!0)}get startY(){return this.be}set startY(t){this.be!==t&&(this.h&&Util.T(this,t),this.be=t,this.bt=!0)}get endX(){return this.Zi}set endX(t){this.Zi!==t&&(this.h&&Util.T(this,t),this.Zi=t,this.bt=!0)}get endY(){return this.Qi}set endY(t){this.Qi!==t&&(this.h&&Util.T(this,t),this.Qi=t,this.bt=!0)}get figures(){return this.Fs}set figures(t){this.Fs!==t&&(this.h&&Util.T(this,t),this.Fs=t,this.bt=!0)}add(t){return this.Fs.add(t),this}setSpots(t,i,e,s,n,o,r,l){return this.h&&Util.T(this),this.zn=new Spot(t,i,n,o).g(),this.Xn=new Spot(e,s,r,l).g(),this}get spot1(){return this.zn}set spot1(t){this.h&&Util.T(this,t),this.zn=t.N()}get spot2(){return this.Xn}set spot2(t){this.h&&Util.T(this,t),this.Xn=t.N()}get defaultStretch(){return this.Kn}set defaultStretch(t){this.Kn=t}get bounds(){return this.Bk()&&this.Nw(),this.jg}}Geometry.stringify=Geometry.stringify;Geometry.stringifyFixed=Geometry.stringifyFixed;Geometry.fillPath=Geometry.fillPath;Geometry.parse=Geometry.parse;class PathFigure{n;xe;be;nc;Wg;Ue;constructor(t,i,e,s,n){e===void 0&&(e=!0),s===void 0&&(s=!0),n===void 0&&(n=!1),this.n=2|(e?4:0)|(s?8:0)|(n?16:0),t!==void 0?this.xe=t:this.xe=0,i!==void 0?this.be=i:this.be=0,this.nc=new List,this.Wg=this.nc.at,this.Ue=null}copy(){const t=new PathFigure;t.n=this.n&-2,t.xe=this.xe,t.be=this.be;const i=this.nc.r,e=i.length,s=t.nc;for(let n=0;no===0?"0":o.toFixed(t);i="M"+n(this.startX)+" "+n(this.startY)}const e=this.segments.r,s=e.length;for(let n=0;n(w[w.Move=1]="Move",w[w.Line=2]="Line",w[w.Bezier=3]="Bezier",w[w.QuadraticBezier=4]="QuadraticBezier",w[w.Arc=5]="Arc",w[w.SvgArc=6]="SvgArc",w))(SegmentType||{});class PathSegment{Z;n;Zi;Qi;hn;yl;wl;gr;Rs;constructor(t,i,e,s,n,o,r,l){if(GSet.Yi(this),t===void 0&&(t=2),this.Z=t,this.n=2,i!==void 0?this.Zi=i:this.Zi=0,e!==void 0?this.Qi=e:this.Qi=0,s===void 0&&(s=0),n===void 0&&(n=0),o===void 0&&(o=0),r===void 0&&(r=0),t===6){let h=o;h=h%360,h<0&&(h+=360),this.hn=h,this.yl=0,this.wl=Math.max(s,0),this.gr=Math.max(n,0),typeof r=="boolean"?r&&(this.isLargeArc=!0):typeof r=="number"&&r&&(this.isLargeArc=!0),l&&(this.isClockwiseArc=!0)}else this.hn=s,this.yl=n,t===5&&(o=Math.max(o,0)),this.wl=o,typeof r=="number"?(t===5&&(r=Math.max(r,0)),this.gr=r):this.gr=0;this.Rs=null}copy(){const t=new PathSegment;return t.Z=this.Z,t.n=this.n&-2,t.Zi=this.Zi,t.Qi=this.Qi,t.hn=this.hn,t.yl=this.yl,t.wl=this.wl,t.gr=this.gr,t}equalsApprox(t){if(!(t instanceof PathSegment)||this.type!==t.type||this.isClosed!==t.isClosed)return!1;switch(this.type){case 1:case 2:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY);case 3:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.point1X,t.point1X)&&Geo.u(this.point1Y,t.point1Y)&&Geo.u(this.point2X,t.point2X)&&Geo.u(this.point2Y,t.point2Y);case 4:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.point1X,t.point1X)&&Geo.u(this.point1Y,t.point1Y);case 5:return Geo.u(this.startAngle,t.startAngle)&&Geo.u(this.sweepAngle,t.sweepAngle)&&Geo.u(this.centerX,t.centerX)&&Geo.u(this.centerY,t.centerY)&&Geo.u(this.radiusX,t.radiusX)&&Geo.u(this.radiusY,t.radiusY);case 6:return this.isClockwiseArc===t.isClockwiseArc&&this.isLargeArc===t.isLargeArc&&Geo.u(this.xAxisRotation,t.xAxisRotation)&&Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.radiusX,t.radiusX)&&Geo.u(this.radiusY,t.radiusY);default:return!1}}ri(t){t in SegmentType?this.type=t:Util.lr(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e="";switch(this.type){case 1:t<0?e="M"+this.endX.toString()+" "+this.endY.toString():e="M"+i(this.endX)+" "+i(this.endY);break;case 2:t<0?e="L"+this.endX.toString()+" "+this.endY.toString():e="L"+i(this.endX)+" "+i(this.endY);break;case 3:t<0?e="C"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.point2X.toString()+" "+this.point2Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="C"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.point2X)+" "+i(this.point2Y)+" "+i(this.endX)+" "+i(this.endY);break;case 4:t<0?e="Q"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="Q"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.endX)+" "+i(this.endY);break;case 5:t<0?e="B"+this.startAngle.toString()+" "+this.sweepAngle.toString()+" "+this.centerX.toString()+" "+this.centerY.toString()+" "+this.radiusX.toString()+" "+this.radiusY.toString():e="B"+i(this.startAngle)+" "+i(this.sweepAngle)+" "+i(this.centerX)+" "+i(this.centerY)+" "+i(this.radiusX)+" "+i(this.radiusY);break;case 6:t<0?e="A"+this.radiusX.toString()+" "+this.radiusY.toString()+" "+this.xAxisRotation.toString()+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+this.endX.toString()+" "+this.endY.toString():e="A"+i(this.radiusX)+" "+i(this.radiusY)+" "+i(this.xAxisRotation)+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+i(this.endX)+" "+i(this.endY);break;default:e=SegmentType[this.type]}return e+(this.isClosed?"z":"")}static Move=1;static Line=2;static Bezier=3;static QuadraticBezier=4;static Arc=5;static SvgArc=6;get h(){return(this.n&1)!==0}set h(t){t?this.n|=1:this.n&=-2}get bt(){return(this.n&2)!==0}set bt(t){t?this.n|=2:this.n&=-3}g(){return this.h=!0,this}rt(){return this.h=!1,this}close(){return this.isClosed=!0,this}So(t){if(this.Rs!==null&&t.bt===!1)return this.Rs;const i=this.radiusX;let e=this.radiusY;if(e===void 0&&(e=i),i===0||e===0)return this.Rs=[],this.Rs;const s=this.hn,n=this.yl,o=Geo.gC(0,0,i1&&(o*=Math.sqrt(p),r*=Math.sqrt(p));let y=(h===a?-1:1)*Math.sqrt((o*o*r*r-o*o*g*g-r*r*m*m)/(o*o*g*g+r*r*m*m));isNaN(y)&&(y=0);let x=y*o*g/r,k=y*-r*m/o;isNaN(x)&&(x=0),isNaN(k)&&(k=0);const b=(s+c)/2+u*x-d*k,P=(n+f)/2+d*x+u*k,M=(V,B)=>Math.sqrt(V*V+B*B),L=(V,B,Y,G)=>(V*Y+B*G)/(M(V,B)*M(Y,G)),C=(V,B,Y,G)=>(V*G=1&&(F=0),!a&&F>0&&(F=F-2*Math.PI),a&&F<0&&(F=F+2*Math.PI);const v=o>r?o:r,O=o>r?1:o/r,U=o>r?r/o:1,X=Geo.gC(0,0,v,S,S+F,!0),E=Transform.l();return E.Ri(),E.Ds(b,P),E.cs(this.hn,0,0),E.st(O,U),Geometry.xC(X,E),Transform.s(E),this.Rs=X,this.Rs}get isClosed(){return(this.n&8)!==0}set isClosed(t){this.isClosed!==t&&(t?this.n|=8:this.n&=-9,this.bt=!0)}get type(){return this.Z}set type(t){this.h&&Util.T(this,t),this.Z=t,this.bt=!0}get endX(){return this.Zi}set endX(t){this.h&&Util.T(this,t),this.Zi=t,this.bt=!0}get endY(){return this.Qi}set endY(t){this.h&&Util.T(this,t),this.Qi=t,this.bt=!0}get point1X(){return this.hn}set point1X(t){this.h&&Util.T(this,t),this.hn=t,this.bt=!0}get point1Y(){return this.yl}set point1Y(t){this.h&&Util.T(this,t),this.yl=t,this.bt=!0}get point2X(){return this.wl}set point2X(t){this.h&&Util.T(this,t),this.wl=t,this.bt=!0}get point2Y(){return this.gr}set point2Y(t){this.h&&Util.T(this,t),this.gr=t,this.bt=!0}get centerX(){return this.hn}set centerX(t){this.h&&Util.T(this,t),this.hn=t,this.bt=!0}get centerY(){return this.yl}set centerY(t){this.h&&Util.T(this,t),this.yl=t,this.bt=!0}get radiusX(){return this.wl}set radiusX(t){t<0&&Util._(t,">= zero",PathSegment,"radiusX"),this.h&&Util.T(this,t),this.wl=t,this.bt=!0}get radiusY(){return this.gr}set radiusY(t){t<0&&Util._(t,">= zero",PathSegment,"radiusY"),this.h&&Util.T(this,t),this.gr=t,this.bt=!0}get startAngle(){return this.Zi}set startAngle(t){this.h&&Util.T(this,t),t=t%360,t<0&&(t+=360),this.Zi=t,this.bt=!0}get sweepAngle(){return this.Qi}set sweepAngle(t){this.h&&Util.T(this,t),t>360&&(t=360),t<-360&&(t=-360),this.Qi=t,this.bt=!0}get isClockwiseArc(){return(this.n&4)!==0}set isClockwiseArc(t){this.h&&Util.T(this,t),t?this.n|=4:this.n&=-5,this.bt=!0}get isLargeArc(){return(this.n&16)!==0}set isLargeArc(t){this.h&&Util.T(this,t),t?this.n|=16:this.n&=-17,this.bt=!0}get xAxisRotation(){return this.hn}set xAxisRotation(t){this.h&&Util.T(this,t),t=t%360,t<0&&(t+=360),this.hn=t,this.bt=!0}}class InputEvent{p;Lw;Aw;Jg;$g;Zg;Qg;_g;tm;im;em;sm;nm;om;No;rm;lm;hm;ke;constructor(){this.p=null,this.Lw=new Point(0,0).g(),this.Aw=new Point(0,0).g(),this.Jg=0,this.$g=0,this.Zg=1,this.Qg="",this._g="",this.tm=!1,this.im=!1,this.em=0,this.sm=0,this.nm=!1,this.om=!1,this.No=!1,this.rm=null,this.lm=0,this.hm=null,this.ke=null}copy(){const t=new InputEvent;return this.clone(t)}clone(t){return t.p=this.p,t.Lw.a(this.viewPoint),t.Aw.a(this.documentPoint),t.Jg=this.Jg,t.$g=this.$g,t.Zg=this.Zg,t.Qg=this.Qg,t._g=this._g,t.tm=this.tm,t.im=this.im,t.em=this.em,t.sm=this.sm,t.nm=this.nm,t.om=this.om,t.No=this.No,t.rm=this.rm,t.lm=this.lm,t.hm=this.hm,t.ke=this.ke,t}toString(){let t="^";return this.modifiers!==0&&(t+="M:"+this.modifiers),this.button!==0&&(t+="B:"+this.button),this.key!==""&&(t+="K:"+this.key),this.clickCount!==0&&(t+="C:"+this.clickCount),this.delta!==0&&(t+="D:"+this.delta),this.handled&&(t+="h"),this.bubbles&&(t+="b"),this.documentPoint!==null&&(t+="@"+this.documentPoint.toString()),t}get diagram(){return this.p}set diagram(t){this.p=t}get viewPoint(){return this.Lw}set viewPoint(t){this.Lw.a(t)}get documentPoint(){return this.Aw}set documentPoint(t){this.Aw.a(t)}getMultiTouchViewPoint(t,i){const e=this.diagram;return e===null||e.MC(this.event,t,i),i}getMultiTouchDocumentPoint(t,i){const e=this.diagram;return e===null||(e.MC(this.event,t,i),i.a(e.transformViewToDoc(i))),i}get modifiers(){return this.Jg}set modifiers(t){this.Jg=t}get button(){return this.$g}set button(t){if(this.$g=t,this.event===null)switch(t){case 0:this.buttons=1;return;case 1:this.buttons=4;return;case 2:this.buttons=2;return}}get buttons(){return this.Zg}set buttons(t){this.Zg=t}get key(){return this.Qg}set key(t){this.Qg=t}get code(){return this._g}set code(t){this._g=t}get down(){return this.tm}set down(t){this.tm=t}get up(){return this.im}set up(t){this.im=t}get clickCount(){return this.em}set clickCount(t){this.em=t}get delta(){return this.sm}set delta(t){this.sm=t}get isMultiTouch(){return this.nm}set isMultiTouch(t){this.nm=t}get handled(){return this.om}set handled(t){this.om=t}get bubbles(){return this.No}set bubbles(t){this.No=t}get event(){return this.rm}set event(t){this.rm=t}get isTouchEvent(){const t=this.event;return t===null?!1:t.pointerType==="touch"||t.pointerType==="pen"}get timestamp(){return this.lm}set timestamp(t){this.lm=t}get targetDiagram(){return this.hm}set targetDiagram(t){this.hm=t}get targetObject(){return this.ke}set targetObject(t){this.ke=t}get control(){return(this.modifiers&1)!==0}set control(t){this.modifiers=t?this.modifiers|1:this.modifiers&-2}get shift(){return(this.modifiers&4)!==0}set shift(t){this.modifiers=t?this.modifiers|4:this.modifiers&-5}get alt(){return(this.modifiers&2)!==0}set alt(t){this.modifiers=t?this.modifiers|2:this.modifiers&-3}get meta(){return(this.modifiers&8)!==0}set meta(t){this.modifiers=t?this.modifiers|8:this.modifiers&-9}get left(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===0:(this.buttons&1)!==0}set left(t){t?this.buttons|=1:this.buttons&=-2}get right(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===2:(this.buttons&2)!==0}set right(t){t?this.buttons|=2:this.buttons&=-3}get middle(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===1:(this.buttons&4)!==0}set middle(t){t?this.buttons|=4:this.buttons&=-5}get commandKey(){const t=this.code,i=this.key;return"cxvyzagCXVYZAG".includes(i)?i.toLowerCase():t==="KeyC"?"c":t==="KeyX"?"x":t==="KeyV"?"v":t==="KeyY"?"y":t==="KeyZ"?"z":t==="KeyA"?"a":t==="KeyG"?"g":t!==""?t:i}}class DiagramEvent{p;St;am;cm;constructor(){this.p=null,this.St="",this.am=null,this.cm=null}copy(){const t=new DiagramEvent;return t.p=this.p,t.St=this.St,t.am=this.am,t.cm=this.cm,t}toString(){let t="*"+this.name;return this.subject!==null&&(t+=":"+this.subject.toString()),this.parameter!==null&&(t+="("+this.parameter.toString()+")"),t}get diagram(){return this.p}set diagram(t){this.p=t}get name(){return this.St}set name(t){this.St=t}get subject(){return this.am}set subject(t){this.am=t}get parameter(){return this.cm}set parameter(t){this.cm=t}}var ChangeType=(w=>(w[w.Transaction=1]="Transaction",w[w.Property=2]="Property",w[w.Insert=3]="Insert",w[w.Remove=4]="Remove",w))(ChangeType||{});class ChangedEvent{du;fm;an;Mi;p;gu;oc;rc;lc;hc;constructor(){this.du=2,this.fm="",this.an="",this.Mi=null,this.p=null,this.gu=null,this.oc=null,this.rc=null,this.lc=null,this.hc=null}static Transaction=1;static Property=2;static Insert=3;static Remove=4;clear(){this.Mi=null,this.p=null,this.gu=null,this.oc=null,this.rc=null,this.lc=null,this.hc=null}copy(){const t=new ChangedEvent;t.du=this.du,t.fm=this.fm,t.an=this.an,t.Mi=this.Mi,t.p=this.p,t.gu=this.gu;let i=this.oc;return Util.wt(i)&&typeof i.copyFrozen=="function"?t.oc=i.copyFrozen():t.oc=i,i=this.rc,Util.wt(i)&&typeof i.copyFrozen=="function"?t.rc=i.copyFrozen():t.rc=i,i=this.lc,Util.wt(i)&&typeof i.copyFrozen=="function"?t.lc=i.copyFrozen():t.lc=i,i=this.hc,Util.wt(i)&&typeof i.copyFrozen=="function"?t.hc=i.copyFrozen():t.hc=i,t}ri(t){t in ChangeType?this.change=t:Util.lr(this,t)}toString(){let t="";return this.change===1?t+="* ":this.change===2?t+=this.model!==null?"!m":"!d":t+=(this.model!==null?"!m":"!d")+this.change,this.propertyName&&typeof this.propertyName=="string"&&(t+=" "+this.propertyName),this.modelChange&&this.modelChange!==this.propertyName&&(t+=" "+this.modelChange),t+=": ",this.change===1?this.oldValue!==null&&(t+=" "+this.oldValue):(this.object!==null&&(t+=Util.toString(this.object)),this.oldValue!==null&&(t+=" old: "+Util.toString(this.oldValue)),this.oldParam!==null&&(t+=" "+this.oldParam),this.newValue!==null&&(t+=" new: "+Util.toString(this.newValue)),this.newParam!==null&&(t+=" "+this.newParam)),t}getValue(t){return t?this.oldValue:this.newValue}getParam(t){return t?this.oldParam:this.newParam}canUndo(){return this.model!==null||this.diagram!==null}undo(){this.canUndo()&&(this.model!==null?this.model.changeState(this,!0):this.diagram!==null&&this.diagram.SC(this,!0))}canRedo(){return this.model!==null||this.diagram!==null}redo(){this.canRedo()&&(this.model!==null?this.model.changeState(this,!1):this.diagram!==null&&this.diagram.SC(this,!1))}get model(){return this.Mi}set model(t){this.Mi=t}get diagram(){return this.p}set diagram(t){this.p=t}get change(){return this.du}set change(t){this.du=t}get modelChange(){return this.fm}set modelChange(t){this.fm=t}get propertyName(){return this.an}set propertyName(t){this.an=t}get isTransactionFinished(){return this.du===1&&(this.an==="CommittedTransaction"||this.an==="FinishedUndo"||this.an==="FinishedRedo")}get object(){return this.gu}set object(t){this.gu=t}get oldValue(){return this.oc}set oldValue(t){this.oc=t}get oldParam(){return this.rc}set oldParam(t){this.rc=t}get newValue(){return this.lc}set newValue(t){this.lc=t}get newParam(){return this.hc}set newParam(t){this.hc=t}}class Transaction{NC;St;Kk;constructor(){this.NC=new List().g(),this.St="",this.Kk=!1}toString(t){let i="Transaction: "+this.name+" "+this.changes.count.toString()+(this.isComplete?"":", incomplete");if(t!==void 0&&t>0){const e=this.changes.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),t.g()}canUndo(){return this.isComplete}undo(){if(this.canUndo())for(let t=this.changes.count-1;t>=0;t--){const i=this.changes.elt(t);i!==null&&i.undo()}}canRedo(){return this.isComplete}redo(){if(!this.canRedo())return;const t=this.changes.count;for(let i=0;i=t;e--){const s=i.elt(e);s!==null&&s.undo(),i.rt(),i.removeAt(e)}i.g()}optimize(){if(!this.isComplete)return;const t=this.changes;t.rt();const i=new GMap;for(let s=0;s0&&t.setElt(r,null),o.set(n.propertyName,s))}let e=0;for(let s=0;se&&t.setElt(e,n),e++)}for(;t.length>e;)t.pop();t.g()}get changes(){return this.NC}get name(){return this.St}set name(t){this.St=t}get isComplete(){return this.Kk}set isComplete(t){this.Kk=t}}class UndoManager{Tw;Oi;CC;vs;Yk;um;Yn;Gk;jk;cn;ac;Dw;Os;Fw;Rw;dm;vw;constructor(t){this.Tw=new GSet,this.Oi=!1,this.CC=new List().g(),this.vs=-1,this.Yk=999,this.Os=!1,this.um=null,this.Yn=0,this.Gk=!1,this.jk=23,this.cn=new List().g(),this.ac=new List,this.Dw=!0,this.Fw=!1,this.Rw=!1,this.dm=!1,this.vw=!1,t&&Object.assign(this,t)}toString(t){let i="UndoManager "+this.historyIndex+"<"+this.history.count+"<="+this.maxHistoryLength;i+="[";let e=this.nestedTransactionNames.count;for(let s=0;s0&&(i+=" "),i+=this.nestedTransactionNames.elt(s);if(i+="]",t!==void 0&&t>0){e=this.history.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),this.vs=-1,t.g(),this.Os=!1,this.um=null,this.Yn=0,this.cn.rt(),this.cn.clear(),this.cn.g(),this.ac.clear(),this.Fw=!1,this.Rw=!1,this.dm=!1,this.vw=!1}copyProperties(t){this.isEnabled=t.isEnabled,this.maxHistoryLength=t.maxHistoryLength,this.gm=t.gm}addModel(t){this.Tw.add(t)}removeModel(t){this.Tw.delete(t)}startTransaction(t){if(t===void 0&&(t=""),t===null&&(t=""),this.isUndoingRedoing)return!1;this.Dw===!0&&(this.Dw=!1,this.Yn++,this.xl||this.t("StartingFirstTransaction",t,this.currentTransaction),this.Yn>0&&this.Yn--),this.isEnabled&&(this.cn.rt(),this.cn.add(t),this.cn.g(),this.currentTransaction===null?this.ac.add(0):this.ac.add(this.currentTransaction.changes.count)),this.Yn++;const i=this.transactionLevel===1;return i&&(this.xl||this.t("StartedTransaction",t,this.currentTransaction)),i}commitTransaction(t){return t===void 0&&(t=""),this.LC(!0,t)}rollbackTransaction(){return this.LC(!1,"")}LC(t,i){if(this.isUndoingRedoing)return!1;this.gm&&this.transactionLevel<1&&Util.oi("Ending transaction without having started a transaction: "+i);const e=this.transactionLevel===1;let s=this.currentTransaction;e&&t&&(this.xl||this.t("CommittingTransaction",i,s));let n=0;if(this.transactionLevel>0&&(this.Yn--,this.isEnabled)){const o=this.cn.count;o>0&&(i===""&&(i=this.cn.elt(0)),this.cn.rt(),this.cn.removeAt(o-1),this.cn.g());const r=this.ac.count;r>0&&(n=this.ac.elt(r-1),this.ac.removeAt(r-1))}if(e){if(t){if(this.dm=!1,s===null&&i!==""&&(s=this.currentTransaction),this.isEnabled&&s!==null){const o=s;o.isComplete||(o.isComplete=!0,o.name=i),this.discardHistoryAfterIndex();const r=this.history;r.rt();const l=this.maxHistoryLength;if(l>=0){if(l===0)r.clear();else if(r.count>=l){const h=r.elt(0);h!==null&&h.clear(),r.removeAt(0),this.vs--}}l!==0&&(r.count===0||r.get(r.count-1)!==o)&&(r.add(o),this.vs++),r.g(),s=o}this.xl||this.t("CommittedTransaction",i,s)}else{this.Os=!0;try{this.isEnabled&&s!==null&&(s.isComplete=!0,s.undo())}finally{this.xl||this.t("RolledBackTransaction",i,s),this.Os=!1}s!==null&&s.clear()}return this.um=null,this.Ow&&this.clear(),this.Ow=!1,this.Iw=!1,!0}else return this.isEnabled&&!t&&s!==null&&s.jD(n),!1}discardHistoryAfterIndex(){if(this.isUndoingRedoing||!this.canRedo())return;const t=this.history;t.rt();for(let i=t.count-1;i>this.historyIndex;i--){const e=t.elt(i);e!==null&&e.clear(),t.removeAt(i),this.dm=!0}t.g()}oE(t){this.Yn+=t,this.Yn<0&&(this.Yn=0)}canUndo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToUndo;return!!(t!==null&&t.canUndo())}undo(){if(!this.canUndo())return;const t=this.transactionToUndo;try{this.Os=!0,this.t("StartingUndo","Undo",t),this.vs--,t.undo()}catch(i){Util.oi("undo error: "+i.toString())}finally{this.t("FinishedUndo","Undo",t),this.Os=!1}}canRedo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToRedo;return!!(t!==null&&t.canRedo())}redo(){if(!this.canRedo())return;const t=this.transactionToRedo;try{this.Os=!0,this.t("StartingRedo","Redo",t),this.vs++,t.redo()}catch(i){Util.oi("redo error: "+i.toString())}finally{this.t("FinishedRedo","Redo",t),this.Os=!1}}t(t,i,e){e===void 0&&(e=null);const s=new ChangedEvent;s.change=1,s.propertyName=t,s.object=e,s.oldValue=i;const n=this.models;for(;n.next();){const o=n.value;s.model=o,o.Ew(s)}}handleChanged(t){if(this.isEnabled&&!this.isUndoingRedoing&&!this.skipsEvent(t)){let i=this.currentTransaction;i===null&&(i=new Transaction,this.um=i);const e=t.copy(),s=i.changes;if(s.rt(),s.add(e),s.g(),this.gm&&this.jk>0&&this.transactionLevel<=0&&!this.Dw){const n=t.diagram;if(n!==null&&n.Eh===!1)return;Util.oi("Change not within a transaction: "+e.toString()),this.jk--}}}skipsEvent(t){if(t===null||t.change===1)return!0;const i=t.object;if(i===null)return!1;if(i.layer!==void 0){const e=i.layer;if(e!==null&&e.isTemporary)return!0}else if(i.isTemporary)return!0;return!1}get models(){return this.Tw.iterator}get isEnabled(){return this.Oi}set isEnabled(t){this.Oi=t}get transactionToUndo(){return this.historyIndex>=0&&this.historyIndex<=this.history.count-1?this.history.elt(this.historyIndex):null}get transactionToRedo(){return this.historyIndex0}get gm(){return this.Gk}set gm(t){this.Gk=t}get nestedTransactionNames(){return this.cn}get Ow(){return this.Fw}set Ow(t){this.Fw=t}get Iw(){return this.Rw}set Iw(t){this.Rw=t}get xl(){return this.vw}set xl(t){this.vw=t}get isJustDiscarded(){return this.dm}}class Tool{p;St;Oi;Hk;qk;mm;AC;constructor(){GSet.Yi(this),this.p=Diagram.pm(),this.St="",this.Oi=!0,this.Hk=!1,this.qk=null,this.AC=new InputEvent,this.mm=-1}get diagram(){return this.p}set diagram(t){t instanceof Diagram&&(this.p=t)}toString(){return this.name!==""?this.name+" Tool":Util.sn(this.constructor)}updateAdornments(t){}canStart(){return this.isEnabled}doStart(){}doActivate(){this.isActive=!0}doDeactivate(){this.isActive=!1}doStop(){}doCancel(){this.transactionResult=null,this.stopTool()}stopTool(){const t=this.diagram;t.currentTool===this&&(t.currentTool=null,t.currentCursor="")}doMouseDown(){!this.isActive&&this.canStart()&&this.doActivate()}doMouseMove(){}doMouseUp(){this.stopTool()}doMouseWheel(){}canStartMultiTouch(){return!0}standardPinchZoomStart(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.X(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.X(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.s(e),Point.s(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){t.Wk=t.scale;const n=s.x-e.x,o=s.y-e.y,r=Math.sqrt(n*n+o*o);t.Jk=r,i.bubbles=!1}Point.s(e),Point.s(s)}standardPinchZoomMove(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.X(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.X(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.s(e),Point.s(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){const n=s.x-e.x,o=s.y-e.y,l=Math.sqrt(n*n+o*o)/t.Jk,h=new Point((Math.min(s.x,e.x)+Math.max(s.x,e.x))/2,(Math.min(s.y,e.y)+Math.max(s.y,e.y))/2),a=t.Wk*l,c=t.commandHandler;if(a!==t.scale&&c.canResetZoom(a)){const f=t.zoomPoint;t.zoomPoint=h,c.resetZoom(a),t.zoomPoint=f}i.bubbles=!1}Point.s(e),Point.s(s)}doKeyDown(){this.diagram.lastInput.code==="Escape"&&this.doCancel()}doKeyUp(){}startTransaction(t){return t===void 0&&(t=this.name),this.transactionResult=null,this.diagram.startTransaction(t)}stopTransaction(){const t=this.diagram;return this.transactionResult===null?t.rollbackTransaction():t.commitTransaction(this.transactionResult)}standardMouseSelect(){const t=this.diagram;if(!t.allowSelect)return;const i=t.lastInput,e=t.findPartAt(i.documentPoint,!1);if(e!==null){if(Util.rr?i.meta:i.control){t.v("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!s.isSelected),t.v("ChangedSelection",t.selection)}else if(i.shift){if(!e.isSelected){t.v("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!0),t.v("ChangedSelection",t.selection)}}else if(!e.isSelected){let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&t.select(s)}}else i.left&&!(Util.rr?i.meta:i.control)&&!i.shift&&t.clearSelection()}standardMouseClick(t,i){t===void 0&&(t=null),i===void 0&&(i=o=>!o.layer.isTemporary);const e=this.diagram,s=e.lastInput,n=e.findObjectAt(s.documentPoint,t,i);return s.targetObject=n,this.HD(n,s,e),s.handled}HD(t,i,e){if(i.handled=!1,t!==null&&!t.isEnabledObject())return;let s=0;i.left?i.clickCount===1?s=1:i.clickCount===2?s=2:s=1:i.right&&i.clickCount===1&&(s=3);let n="ObjectSingleClicked";if(t!==null){switch(s){case 1:n="ObjectSingleClicked";break;case 2:n="ObjectDoubleClicked";break;case 3:n="ObjectContextClicked";break}s!==0&&e.v(n,t)}else{switch(s){case 1:n="BackgroundSingleClicked";break;case 2:n="BackgroundDoubleClicked";break;case 3:n="BackgroundContextClicked";break}s!==0&&e.v(n)}if(t!==null)for(;t!==null;){let o=null;switch(s){case 1:o=t.click;break;case 2:o=t.doubleClick?t.doubleClick:t.click;break;case 3:o=t.contextClick;break}if(o!==null&&(o(i,t),i.handled))break;t=t.panel}else{let o=null;switch(s){case 1:o=e.click;break;case 2:o=e.doubleClick?e.doubleClick:e.click;break;case 3:o=e.contextClick;break}o!==null&&o(i)}}standardMouseOver(){const t=this.diagram,i=t.lastInput;if(t.animationManager.wi===!0)return;const e=t.skipsUndoManager;t.skipsUndoManager=!0;let s=t.viewportBounds.containsPoint(i.documentPoint)?t.findObjectAt(i.documentPoint,null,null):null;i.event&&(i.event.type==="pointercancel"||i.event.type==="pointerout")&&(s=null),i.targetObject=s;let n=!1;if(s!==t.cc){let o=t.cc;const r=o;for(t.cc=s,this.doCurrentObjectChanged(o,s),i.handled=!1;o!==null;){const l=o.mouseLeave;if(l!==null&&(s===o||s!==null&&s.isContainedBy(o)||(l(i,o,s),n=!0,i.handled)))break;o=o.panel}for(o=r,i.handled=!1;s!==null;){const l=s.mouseEnter;if(l!==null&&(o===s||o!==null&&o.isContainedBy(s)||(l(i,s,o),n=!0,i.handled)))break;s=s.panel}s=t.cc}if(s!==null){let o=s,r="";for(;o!==null&&(r=o.cursor,r==="");)o=o.panel;for(t.currentCursor=r,i.handled=!1,o=s;o!==null;){const l=o.mouseOver;if(l!==null&&(l(i,o),n=!0,i.handled))break;o=o.panel}}else{this.doUpdateCursor(null);const o=t.mouseOver;o!==null&&(o(i),n=!0)}n&&t.requestUpdate(),t.skipsUndoManager=e}doUpdateCursor(t){const i=this.diagram;i&&(i.currentCursor="")}doCurrentObjectChanged(t,i){}standardMouseWheel(){const t=this.diagram,i=t.lastInput;let e=i.delta;if(e===0||!t.documentBounds.isReal())return;const s=t.commandHandler,n=t.toolManager.mouseWheelBehavior;if(s!==null&&(n===2&&!i.shift||n===1&&i.control)){if(e>0?s.canIncreaseZoom():s.canDecreaseZoom()){const o=t.zoomPoint;t.zoomPoint=i.viewPoint,e>0?s.increaseZoom():s.decreaseZoom(),t.zoomPoint=o}i.bubbles=!1}else if(n===2&&i.shift||n===1&&!i.control){const o=t.position.copy(),r=i.event,l=r.deltaMode;let h=r.deltaX,a=r.deltaY,c="pixel";if((h!==0||a!==0)&&!i.shift){switch(l){case 0:c="pixel";break;case 1:c="line";break;case 2:c="page";break}if(h!==0&&t.allowHorizontalScroll){const f=t.scrollHorizontalLineChange;h=h*(f/16),t.scroll(c,h>0?"right":"left",Math.abs(h))}if(a!==0&&t.allowVerticalScroll){const f=t.scrollVerticalLineChange;a=a*(f/16),t.scroll(c,a>0?"down":"up",Math.abs(a))}}else!i.shift&&t.allowVerticalScroll?(e=e*3*t.scrollVerticalLineChange,t.scroll(c,e>0?"up":"down",Math.abs(e))):i.shift&&t.allowHorizontalScroll&&(e=e*3*t.scrollHorizontalLineChange,t.scroll(c,e>0?"left":"right",Math.abs(e)));this.doWheelChange(t,o,i)}}doWheelChange(t,i,e){(!t.position.equals(i)||e.event.wheelDeltaX!==0)&&(e.bubbles=!1)}standardWaitAfter(t,i){i===void 0&&(i=this.diagram.lastInput),this.cancelWaitAfter();const e=this,s=i.clone(this.AC);this.mm=Util.vh(()=>e.doWaitAfter(s),t)}cancelWaitAfter(){this.mm!==-1&&Util.Ig(this.mm),this.mm=-1}doWaitAfter(t){}findToolHandleAt(t,i){const s=this.diagram.findObjectAt(t,n=>{for(;n!==null&&!(n.panel instanceof Adornment);)n=n.panel;return n});return s===null?null:s.part.category===i?s:null}isBeyondDragSize(t,i){const e=this.diagram;t===void 0&&(t=e.firstInput.viewPoint),i===void 0&&(i=e.lastInput.viewPoint);const s=e.toolManager.dragSize;let n=s.width,o=s.height;return e.firstInput.isTouchEvent&&(n+=6,o+=6),Math.abs(i.x-t.x)>n||Math.abs(i.y-t.y)>o}get name(){return this.St}set name(t){Util.i(t,"string",Tool,"name"),this.St=t}get isEnabled(){return this.Oi}set isEnabled(t){Util.i(t,"boolean",Tool,"isEnabled"),this.Oi=t}get isActive(){return this.Hk}set isActive(t){Util.i(t,"boolean",Tool,"isActive"),this.Hk=t}get transactionResult(){return this.qk}set transactionResult(t){t!==null&&Util.i(t,"string",Tool,"transactionResult"),this.qk=t}}var WheelMode=(w=>(w[w.Scroll=1]="Scroll",w[w.Zoom=2]="Zoom",w[w.None=3]="None",w))(WheelMode||{}),GestureMode=(w=>(w[w.Zoom=1]="Zoom",w[w.Cancel=2]="Cancel",w[w.None=3]="None",w))(GestureMode||{});class ToolManager extends Tool{TC;DC;FC;$k;Zk;Qk;_k;tP;iP;eP;ym;Uh;constructor(t){super(),this.name="ToolManager",this.TC=new List,this.DC=new List,this.FC=new List,this.$k=850,this.Zk=850,this.Qk=new Size(2,2).it(),this._k=5e3,this.tP=1,this.iP=1,this.eP=null,this.ym=null,this.Uh=-1,t&&Object.assign(this,t)}static WheelScroll=1;static WheelZoom=2;static WheelNone=3;static GestureZoom=1;static GestureCancel=2;static GestureNone=3;get mouseWheelBehavior(){return this.tP}set mouseWheelBehavior(t){this.tP=t}get gestureBehavior(){return this.iP}set gestureBehavior(t){this.iP=t}initializeStandardTools(){}updateAdornments(t){const i=this.currentToolTip;if(i instanceof Adornment&&this.ym===t){const e=i.adornedObject;(t!==null?e.part===t:e===null)?this.showToolTip(i,e):this.hideToolTip()}}doMouseDown(){const t=this.diagram,i=t.lastInput;if(i.isTouchEvent&&this.gestureBehavior===2&&(i.bubbles=!1),i.isMultiTouch){if(this.cancelWaitAfter(),this.gestureBehavior===3){i.bubbles=!0;return}if(this.gestureBehavior===2)return;if(t.currentTool.canStartMultiTouch()){t.currentTool.standardPinchZoomStart();return}}const e=t.undoManager,s=this.mouseDownTools.length;for(let n=0;n0&&s!==1/0){const n=this;this.Uh=Util.vh(()=>n.hideToolTip(),s)}}positionToolTip(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom?n.y-=o.height+5/s.scale:n.y+=20/s.scale,n.y30&&t.Bw(),t.Vw(this.draggedParts),t.yu=!0,this.startTransaction("Drag"),this.startPoint=t.firstInput.documentPoint,t.isMouseCaptured=!0,t.allowDragOut&&this.WD()}mP(t){if(this.dragsLink){const i=this.diagram;if(!i.allowRelink)return;i.model.dc()&&t.count===1&&t.first()instanceof Link?(this.draggedLink=t.first(),this.draggedLink.canRelinkFrom()&&this.draggedLink.canRelinkTo()&&this.draggedLink.clearAdornments(),this.fn=i.toolManager.findTool("Relinking"),this.fn===null&&(this.fn=new RelinkingTool,this.fn.diagram=i),this.fn.originalLink=this.draggedLink):(this.draggedLink=null,this.fn=null)}}computeEffectiveCollection(t,i){return this.diagram.commandHandler.computeEffectiveCollection(t,i)}Is(t){return t===void 0?new DraggingInfo(Point.Po):this.isGridSnapEnabled?new DraggingInfo(new Point(Math.round(t.x*1e3)/1e3,Math.round(t.y*1e3)/1e3)):new DraggingInfo(t.copy())}doDeactivate(){this.isActive=!1;const t=this.diagram;this.diagram.layout.isRealtime=this.gP,t.yu=!1,t.bl=!0,t.cacheGroupExternalLinks(!1),t.stopAutoScroll(),this.pP(),t.xm(this.draggedParts),this.pu=null,this.currentPart=null,this.draggedParts=null,this.isDragOutStarted=!1,this.mu=!1,DraggingTool.JD(),this.vC(),this.fc.e(NaN,NaN),DraggingTool.Vh!==null&&(DraggingTool.Vh.currentCursor=""),DraggingTool.Vh=null,DraggingTool.yt=null,this.kl(),t.isMouseCaptured=!1,t.currentCursor="",t.uc=!1,this.stopTransaction(),t.yP(!0)}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}pP(){const t=this.diagram,i=t.skipsUndoManager;t.skipsUndoManager=!0;const e=t.lastInput;this.OC(e,null),t.skipsUndoManager=i,this.mr.length=0}IC(){this.kl(),this.wP();const t=this.diagram;this.fc.isReal()&&(t.position=this.fc),t.stopAutoScroll()}doCancel(){this.kl(),this.wP();const t=this.diagram;this.fc.isReal()&&(t.position=this.fc),this.stopTool()}doKeyDown(){const t=this.diagram,i=t.lastInput;this.isActive&&(i.code==="Escape"?this.doCancel():i.code!==t.previousInput.code&&this.doMouseMove())}doKeyUp(){this.isActive&&this.doMouseMove()}$D(t,i){let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=t.iterator;for(;r.next();){const l=r.value;if(!l.isVisible())continue;const h=l.location,a=h.x,c=h.y;isNaN(a)||isNaN(c)||(an&&(n=a),c>o&&(o=c))}return e===1/0?i.e(0,0,0,0):i.e(e,s,n-e,o-s),i}xP(t){if(this.copiedParts!==null)return;const i=this.diagram;if(t&&(i.isReadOnly||i.isModelReadOnly)||this.draggedParts===null)return;const e=i.undoManager;e.isEnabled&&e.isInTransaction?e.currentTransaction!==null&&e.currentTransaction.changes.count>0&&(i.undoManager.rollbackTransaction(),i.startTransaction("Drag")):this.wP(),i.skipsUndoManager=!t,i.partManager.addsToTemporaryLayer=!t,this.startPoint=i.firstInput.documentPoint;const s=this.copiesEffectiveCollection?this.draggedParts.toKeySet():i.selection,n=i.copyParts(s,i,!0),o=new GMap,r=this.draggedParts.iterator;for(;r.next();){const h=r.key;if(h.Pe()&&h.canCopy()){const a=n.get(h);if(a===null)continue;a.location=h.location,a.ensureBounds(),o.set(a,this.Is(a.location))}}const l=n.iterator;for(;l.next();){const h=l.value;h instanceof Link&&h.canCopy()&&o.set(h,this.Is())}if(this.copiedParts=o,this.mP(o.toKeySet()),this.draggedLink!==null){const h=this.draggedLink,a=h.routeBounds;h.pr(this.startPoint.x-(a.x+a.width/2),this.startPoint.y-(a.y+a.height/2))}this.doUpdateCursor(null)}kl(){const t=this.diagram;if(this.copiedParts!==null){if(t.removeParts(this.copiedParts.toKeySet(),!1),this.copiedParts=null,this.draggedParts!==null){const i=this.draggedParts.iterator;for(;i.next();)if(i.key instanceof Link){const s=i.value;s.point=new Point(0,0)}}this.doUpdateCursor(null)}t.skipsUndoManager=!1,t.partManager.addsToTemporaryLayer=!1,this.startPoint=t.firstInput.documentPoint}vC(){this.draggedLink!==null&&(this.dragsLink&&this.fn!==null&&(this.fn.stopDraggingMouseMove(),this.fn.originalLink=null),this.draggedLink=null,this.fn=null)}gc(t,i){const e=this.diagram,s=this.startPoint,n=Point.l();n.a(e.lastInput.documentPoint),this.moveParts(t,n.subtract(s),i),Point.s(n),e.getRenderingHint("temporaryPixelRatio")===!0&&e.Pl===null&&e.avgSpf>30&&(e.Bw(),e.wu())}moveParts(t,i,e){e===void 0&&(e=!1);const s=this.diagram;s!==null&&s.bP(t,i,this.dragOptions,e)}wP(){if(this.draggedParts===null)return;const t=this.diagram;let i=this.draggedParts.iterator;for(;i.next();){const e=i.key;e.Pe()&&(e.location=i.value.point)}for(i=this.draggedParts.iterator;i.next();){const e=i.key;if(e instanceof Link&&e.suspendsRouting){const s=i.value.point;this.draggedParts.set(e,this.Is()),e.pr(-s.x,-s.y)}}t.maybeUpdate()}ZD(t){if(t===null)return!0;const i=t.part;return!!(i===null||i instanceof Adornment||i.layer.isTemporary||this.draggedParts&&this.draggedParts.has(i)||this.copiedParts&&this.copiedParts.has(i))}kP(t){const i=this.diagram;this.dragsLink&&(this.draggedLink!==null&&(this.draggedLink.fromNode=null,this.draggedLink.toNode=null),this.EC(!1));const e=this.findDragOverObject(t),s=i.lastInput;s.targetObject=e,this.doUpdateCursor(e);const n=i.skipsUndoManager;let o=!1;try{if(i.skipsUndoManager=!0,o=this.OC(s,e),!this.isActive&&DraggingTool.yt===null)return;const r=e!==null?e.part:null;if(r===null||i.handlesDragDropForTopLevelParts&&r.isTopLevel&&!(r instanceof Group)){const l=i.mouseDragOver;l!==null&&(l(s),o=!0)}if(!this.isActive&&DraggingTool.yt===null||(this.doDragOver(t,e),!this.isActive&&DraggingTool.yt===null))return}finally{i.skipsUndoManager=n,o&&i.maybeUpdate()}this.pu=e,!i.isReadOnly&&(i.allowMove||i.allowCopy)&&(i.allowHorizontalScroll||i.allowVerticalScroll)&&i.doAutoScroll(s.viewPoint)}findDragOverObject(t){return this.diagram.PP(t,null,i=>!this.ZD(i))}doUpdateCursor(t){const i=this.diagram;(t===null||this.pu!==t)&&(!this.diagram.currentTool.isActive||this.mayCopy()?i.currentCursor=this.copyCursor:this.mayMove()?i.currentCursor=this.moveCursor:this.mayDragOut()&&(i.currentCursor=this.nodropCursor))}OC(t,i){let e=!1,s=this.mr.length;const n=s>0?this.mr[0]:null;if(i===n)return!1;t.handled=!1;for(let r=0;rs.findValidLinkablePort(a,i)),r=Point.l();let l=1/0,h=null;for(const a=o.iterator;a.next();){const c=a.value;if(c.part===null)continue;const u=c.getDocumentPoint(Spot.Center,r),d=t.distanceSquaredPoint(u);dh.suspendsRouting=!1)}if(this.doDropOnto(t,e),!this.isActive&&DraggingTool.yt===null)return;const o=Rect.l(),r=i.selection.iterator;for(;r.next();){const l=r.value;l instanceof Node&&this._D(i,l,o)}Rect.s(o)}QD(t,i){const e=this.diagram,s=i.part;if(e.handlesDragDropForTopLevelParts&&s.isTopLevel&&!(s instanceof Group)){const n=e.mouseDrop;n!==null&&n(t)}}_D(t,i,e){if(!i.canAvoid())return;let s=!1;e=i.getAvoidableRect(e),t.viewportBounds.containsRect(e)&&(s=!0);const n=this.copiedParts||this.draggedParts,o=t.NP(e,l=>l.part,l=>l instanceof Link,!0,l=>l instanceof Link,s);if(o.count===0)return;const r=o.iterator;for(;r.next();){const l=r.value;n.has(l)&&n.has(i)||!l.isMemberOf(i)&&l.isAvoiding&&l.invalidateRoute()}}doDropOnto(t,i){}doMouseMove(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseMove(i.event,i.documentPoint,i.targetDiagram))return;this.currentPart!==null&&this.draggedParts!==null&&(this.mayCopy()?(this.xP(!1),t.Vw(this.copiedParts),this.gc(this.copiedParts,!1),t.xm(this.copiedParts)):this.mayMove()?(this.kl(),this.gc(this.draggedParts,!0)):this.mayDragOut()?(this.xP(!1),this.gc(this.copiedParts,!1)):this.kl(),this.kP(t.lastInput.documentPoint))}doMouseUp(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseUp(i.event,i.documentPoint,i.targetDiagram))return;let e=!1;const s=this.mayCopy();if(s&&this.copiedParts!==null?(this.kl(),this.xP(!0),t.Vw(this.copiedParts),this.gc(this.copiedParts,!1),t.xm(this.copiedParts),this.copiedParts!==null&&(t.v("ChangingSelection",t.selection),t.clearSelection(!0),this.copiedParts.iteratorKeys.each(n=>{n.isSelected=!0}))):(e=!0,this.kl(),this.mayMove()&&(this.gc(this.draggedParts,!0),this.kP(t.lastInput.documentPoint))),this.mu=!0,this.VC(t.lastInput.documentPoint),this.isActive){const n=s?this.copiedParts.toKeySet():this.draggedParts.toKeySet();this.copiedParts=null,e&&this.tF(),t.invalidateDocumentBounds(),t.xm(this.draggedParts),this.transactionResult=s?"Copy":"Move",t.v(s?"SelectionCopied":"SelectionMoved",n)}this.stopTool(),s&&t.v("ChangedSelection",t.selection)}simulatedMouseMove(t,i,e){if(DraggingTool.yt===null)return!1;const s=DraggingTool.yt.diagram;e instanceof Diagram||(e=null);const n=DraggingTool.Vh;if(e!==n){if(n!==null&&n!==s){n.stopAutoScroll(),DraggingTool.yt.isDragOutStarted=!1;const r=n.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDragLeave()}if(DraggingTool.Vh=e,e!==null&&e!==s){DraggingTool.yt.IC();const r=e.toolManager.findTool("Dragging");r!==null&&(r.zC(),r.doSimulatedDragEnter())}this.doUpdateCursor(null)}if(e===null||e===s||!e.allowDrop||e.isReadOnly||!e.allowInsert)return!1;const o=e.toolManager.findTool("Dragging");if(o!==null){let r=i;t!==null&&(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),r=e.getMouse(t)),e.lastInput.documentPoint=r,e.lastInput.viewPoint=e.transformDocToView(r),e.lastInput.down=!1,e.lastInput.up=!1,o.doSimulatedDragOver()}return!0}simulatedMouseUp(t,i,e){if(DraggingTool.yt===null)return!1;const s=DraggingTool.Vh,n=DraggingTool.yt.diagram;if(e===null)return DraggingTool.yt.doCancel(),!0;if(e!==s){const o=s.toolManager.findTool("Dragging");if(s!==null&&s!==n&&o!==null)return s.stopAutoScroll(),DraggingTool.yt.isDragOutStarted=!1,o.doSimulatedDragLeave(),!1;DraggingTool.Vh=e;const r=e.toolManager.findTool("Dragging");r!==null&&(DraggingTool.yt.IC(),r.zC(),r.doSimulatedDragEnter())}if(e!==this.diagram){let o=i;t!==null?(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),o=e.getMouse(t)):o===null&&(o=new Point),e.lastInput.documentPoint=o,e.lastInput.viewPoint=e.transformDocToView(o),e.lastInput.down=!1,e.lastInput.up=!0;const r=e.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDrop();const l=DraggingTool.yt;if(l!==null){const h=l.mayCopy();l.transactionResult=h?"Copy":"Move",l.stopTool()}return!0}return!1}tF(){if(this.draggedParts===null)return;const t=this.draggedParts.iterator;for(;t.next();){const i=t.key;if(i instanceof Node){const e=i.containingGroup;e!==null&&e.hasPlaceholder()&&!this.draggedParts.has(e)&&e.placeholder.c()}}}mayCopy(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowCopy||!(Util.rr?t.lastInput.alt:t.lastInput.control))return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayDragOut(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(!t.allowDragOut||!t.allowCopy||t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayMove(){const t=this.diagram;if(t.isReadOnly||!t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canMove())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canMove())}zC(){DraggingTool.zw.has(this)||DraggingTool.zw.add(this)}static JD(){if(DraggingTool.zw.count>0){const t=DraggingTool.zw,i=t.length;for(let e=0;e{n.isSelected=!0,s.add(n)})),this.VC(t.lastInput.documentPoint),t.invalidateDocumentBounds(),this.copiedParts!==null&&(this.transactionResult="ExternalCopy"),this.copiedParts=null,t.doFocus(),t.uc=!1,t.v("ExternalObjectsDropped",s,e),this.stopTransaction(),t.v("ChangedSelection",t.selection)}t.animationManager.xu=!1}XC(t,i,e){if(this.copiedParts!==null)return;const s=this.diagram;if(s.isReadOnly||s.isModelReadOnly)return;s.skipsUndoManager=!i,s.partManager.addsToTemporaryLayer=!i,this.startPoint=e.documentPoint;const n=s.copyParts(t,s,!0),o=Rect.l();this.$D(t,o);const r=o.x+o.width/2,l=o.y+o.height/2;Rect.s(o);const h=this.wm,a=new GMap,c=Point.l(),f=t.iterator;for(;f.next();){const d=f.value;if(d instanceof Link&&d.canCopy()){const m=n.get(d);if(m===null)continue;m.points=d.points,m.pr(h.x-r,h.y-l),m.suspendsRouting=!0,a.set(m,this.Is())}}const u=t.iterator;for(;u.next();){const d=u.value;if(d.Pe()&&d.canCopy()){const m=n.get(d);if(m===null)continue;const g=d.location;c.e(h.x-(r-g.x),h.y-(l-g.y)),m.location=c,m.ensureBounds(),a.set(m,this.Is(c))}}if(Point.s(c),this.copiedParts=a,this.mP(a.toKeySet()),this.draggedLink!==null){const d=this.draggedLink,m=d.routeBounds;d.pr(this.startPoint.x-(m.x+m.width/2),this.startPoint.y-(m.y+m.height/2))}this.doUpdateCursor(null)}WD(){this.isDragOutStarted=!0,this.mu=!1,DraggingTool.yt=this,DraggingTool.Vh=this.diagram,this.doSimulatedDragOut()}doSimulatedDragOut(){const t=this.diagram;t.uc=!1,!this.mayCopy()&&!this.mayMove()?t.currentCursor=this.nodropCursor:t.currentCursor="",this.pu=null}computeMove(t,i,e,s){const n=this.diagram;return n!==null?n.computeMove(t,i,this.dragOptions,s):new Point}static zw=new List;static yt=null;static Vh=null}ToolManager.prototype.doCancel=function(){DraggingTool.yt!==null&&DraggingTool.yt.doCancel(),Tool.prototype.doCancel.call(this)};class LinkingBaseTool extends Tool{CP;LP;Ml;AP;TP;zh;DP;Xh;FP;RP;vP;OP;IP;EP;KC;UP;Sl;BP;constructor(){super(),this.CP=100,this.LP=!1,this.Ml="pointer",this.AP=new Link({layerName:"Tool"}).add(new Shape({isPanelMain:!0,stroke:"blue"}).theme("stroke","tempLink"),new Shape({toArrow:"Standard",fill:"blue",stroke:"blue"}).theme("fill","tempLink").theme("stroke","tempLink")).li(),this.zh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.Dk}).theme("stroke","tempPort"),this.TP=new Node({selectable:!1,layerName:"Tool"}).add(this.zh).li(),this.Xh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.Dk}).theme("stroke","tempPort"),this.DP=new Node({selectable:!1,layerName:"Tool"}).add(this.Xh).li(),this.FP=null,this.RP=null,this.vP=null,this.OP=null,this.IP=null,this.EP=!0,this.KC=new GMap,this.UP=null,this.Sl=null,this.BP=null}doStop(){this.diagram.stopAutoScroll(),this.originalLink=null,this.originalFromNode=null,this.originalFromPort=null,this.originalToNode=null,this.originalToPort=null,this.validPortsCache.clear(),this.targetPort=null}get portGravity(){return this.CP}set portGravity(t){Util.i(t,"number",LinkingBaseTool,"portGravity"),t>=0&&(this.CP=t)}get isUnconnectedLinkValid(){return this.LP}set isUnconnectedLinkValid(t){Util.i(t,"boolean",LinkingBaseTool,"isUnconnectedLinkValid"),this.LP=t}get linkingCursor(){return this.Ml}set linkingCursor(t){this.Ml=t}get temporaryLink(){return this.AP}set temporaryLink(t){t.li(),this.AP=t}get temporaryFromNode(){return this.TP}set temporaryFromNode(t){t.li(),this.TP=t,t&&(this.zh=t.port)}get temporaryFromPort(){return this.zh}set temporaryFromPort(t){if(this.zh!==null){const i=this.zh.panel;if(i!==null){const e=i.L.indexOf(this.zh);i.removeAt(e),i.insertAt(e,t)}}this.zh=t}get temporaryToNode(){return this.DP}set temporaryToNode(t){t.li(),this.DP=t,t&&(this.Xh=t.port)}get temporaryToPort(){return this.Xh}set temporaryToPort(t){if(this.Xh!==null){const i=this.Xh.panel;if(i!==null){const e=i.L.indexOf(this.Xh);i.removeAt(e),i.insertAt(e,t)}}this.Xh=t}get originalLink(){return this.FP}set originalLink(t){this.FP=t}get originalFromNode(){return this.RP}set originalFromNode(t){this.RP=t}get originalFromPort(){return this.vP}set originalFromPort(t){this.vP=t}get originalToNode(){return this.OP}set originalToNode(t){this.OP=t}get originalToPort(){return this.IP}set originalToPort(t){this.IP=t}get isForwards(){return this.EP}set isForwards(t){this.EP=t}get validPortsCache(){return this.KC}get targetPort(){return this.UP}set targetPort(t){this.UP=t}copyPortProperties(t,i,e,s,n){if(t===null||i===null||e===null||s===null)return;const o=i.getDocumentScale(),r=Size.l();r.width=i.naturalBounds.width*o,r.height=i.naturalBounds.height*o,s.desiredSize=r,Size.s(r),n?(s.toSpot=i.toSpot,s.toEndSegmentLength=i.toEndSegmentLength):(s.fromSpot=i.fromSpot,s.fromEndSegmentLength=i.fromEndSegmentLength),e.locationSpot=Spot.Center;const l=Point.l();e.location=i.getDocumentPoint(Spot.Center,l),Point.s(l),s.angle=i.getDocumentAngle(),this.portTargeted!==null&&this.portTargeted(t,i,e,s,n)}setNoTargetPortProperties(t,i,e){i!==null&&(i.desiredSize=Size.Dk,i.fromSpot=Spot.None,i.toSpot=Spot.None),t!==null&&(t.location=this.diagram.lastInput.documentPoint),this.portTargeted!==null&&this.portTargeted(null,null,t,i,e)}doMouseDown(){this.isActive&&this.doMouseMove()}doMouseMove(){if(this.isActive){const t=this.diagram;if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null&&this.targetPort.part instanceof Node){const i=this.targetPort.part;this.isForwards?this.copyPortProperties(i,this.targetPort,this.temporaryToNode,this.temporaryToPort,!0):this.copyPortProperties(i,this.targetPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else this.isForwards?this.setNoTargetPortProperties(this.temporaryToNode,this.temporaryToPort,!0):this.setNoTargetPortProperties(this.temporaryFromNode,this.temporaryFromPort,!1);(t.allowHorizontalScroll||t.allowVerticalScroll)&&t.doAutoScroll(t.lastInput.viewPoint)}}findValidLinkablePort(t,i){if(t===null)return null;const e=t.part;if(!(e instanceof Node))return null;for(;t!==null;){const s=i?t.toLinkable:t.fromLinkable;if(s===!0&&(t.portId!==null||t instanceof Node)&&(i?this.isValidTo(e,t):this.isValidFrom(e,t)))return t;if(s===!1)return null;t=t.panel}return null}findTargetPort(t){const i=this.diagram,e=i.lastInput.documentPoint;let s=this.portGravity;s<=0&&(s=.1);const n=this,o=i.findObjectsNear(e,s,a=>n.findValidLinkablePort(a,t),null,!0);let r=1/0,l=null;const h=o.iterator;for(;h.next();){const a=h.value,c=a.part;if(!(c instanceof Node))continue;const f=a.getDocumentPoint(Spot.Center,Point.l()),u=e.x-f.x,d=e.y-f.y;Point.s(f);const m=u*u+d*d;if(m=e)return!1}return!0}isValidTo(t,i){if(t===null||i===null)return this.isUnconnectedLinkValid;if(this.diagram.currentTool===this&&(t.layer!==null&&!t.layer.allowLink||i.toLinkable!==!0))return!1;const e=i.toMaxLinks;if(e<1/0){if(this.originalLink!==null&&t===this.originalToNode&&i===this.originalToPort)return!0;let s=i.portId;if(s===null&&(s=""),t.findLinksInto(s).count>=e)return!1}return!0}isInSameNode(t,i){if(t===null||i===null)return!1;if(t===i)return!0;const e=t.part,s=i.part;return e!==null&&e===s}isLinked(t,i){if(t===null||i===null)return!1;const e=t.part;if(!(e instanceof Node))return!1;let s=t.portId;s===null&&(s="");const n=i.part;if(!(n instanceof Node))return!1;let o=i.portId;o===null&&(o="");const r=n.findLinksInto(o);for(;r.next();){const l=r.value;if(l.fromNode===e&&l.fromPortId===s)return!0}return!1}isValidLink(t,i,e,s){if(!this.isValidFrom(t,i)||!this.isValidTo(e,s)||i!==null&&s!==null&&(!(i.fromLinkableSelfNode&&s.toLinkableSelfNode)&&this.isInSameNode(i,s)||!(i.fromLinkableDuplicates&&s.toLinkableDuplicates)&&this.isLinked(i,s))||this.originalLink!==null&&(t!==null&&this.isLabelDependentOnLink(t,this.originalLink)||e!==null&&this.isLabelDependentOnLink(e,this.originalLink))||t!==null&&e!==null&&(t.data===null&&e.data!==null||t.data!==null&&e.data===null)||!this.isValidCycle(t,e,this.originalLink))return!1;let n;return t!==null&&(n=t.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))||e!==null&&(n=e.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))?!1:(n=this.linkValidation,n!==null?n(t,i,e,s,this.originalLink):!0)}isLabelDependentOnLink(t,i){if(t===null)return!1;const e=t.labeledLink;if(e===null)return!1;if(e===i)return!0;const s=new GSet;return s.add(t),this.VP(e,i,s)}VP(t,i,e){if(t===i)return!0;const s=t.fromNode;if(s!==null&&s.isLinkLabel&&(e.add(s),this.VP(s.labeledLink,i,e)))return!0;const n=t.toNode;return!!(n!==null&&n.isLinkLabel&&(e.add(n),this.VP(n.labeledLink,i,e)))}isValidCycle(t,i,e){if(e===void 0&&(e=null),t===null||i===null)return this.isUnconnectedLinkValid;const s=this.diagram;let n=1;if(s&&(s.model.mc()?n=s.isTreePathToChildren?5:6:n=s.validCycle),n===1)return!0;if(n===5){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=i.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.toNode===i)return!1}return!this.bu(t,i,e,!0)}else if(n===6){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=t.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.fromNode===t)return!1}return!this.bu(t,i,e,!0)}else{if(n===2)return!this.iF(t,i,e);if(n===3)return!this.bu(t,i,e,!1);if(n===4)return!this.eF(t,i,e)}return!0}bu(t,i,e,s){if(t===i)return!0;if(t===null||i===null)return!1;const n=t.linksConnected;for(;n.next();){const o=n.value;if(o===e||s&&!o.isTreeLink||o.toNode!==t)continue;const r=o.fromNode;if(r!==t&&this.bu(r,i,e,s))return!0}return!1}iF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.YC(s,t,i,e)}YC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s||o.toNode!==i)continue;const r=o.fromNode;if(r!==i&&this.YC(t,r,e,s))return!0}return!1}eF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.GC(s,t,i,e)}GC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s)continue;const r=o.fromNode,l=o.toNode,h=r===i?l:r;if(h!==i&&this.GC(t,h,e,s))return!0}return!1}get linkValidation(){return this.Sl}set linkValidation(t){t!==null&&Util.i(t,"function",LinkingBaseTool,"linkValidation"),this.Sl=t}get portTargeted(){return this.BP}set portTargeted(t){t!==null&&Util.i(t,"function",LinkingBaseTool,"portTargeted"),this.BP=t}}var LinkingDirection=(w=>(w[w.Either=1]="Either",w[w.ForwardsOnly=2]="ForwardsOnly",w[w.BackwardsOnly=3]="BackwardsOnly",w))(LinkingDirection||{});class LinkingTool extends LinkingBaseTool{zP;XP;S;KP;constructor(t){super(),this.name="Linking",this.zP={},this.XP=null,this.S=1,this.KP=null,t&&Object.assign(this,t)}static Either=1;static ForwardsOnly=2;static BackwardsOnly=3;get archetypeLinkData(){return this.zP}set archetypeLinkData(t){t!==null&&Util.i(t,"object",LinkingTool,"archetypeLinkData"),this.zP=t}get archetypeLabelNodeData(){return this.XP}set archetypeLabelNodeData(t){t!==null&&Util.i(t,"object",LinkingTool,"archetypeLabelNodeData"),this.XP=t}get direction(){return this.S}set direction(t){this.S=t}get startObject(){return this.KP}set startObject(t){this.KP=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||t.isModelReadOnly||!t.allowLink||!t.model.Xw()||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize()?!1:this.findLinkablePort()!==null}findLinkablePort(){const t=this.diagram;let i=this.startObject;if(i===null&&(i=t.findObjectAt(t.firstInput.documentPoint,null,null)),i===null)return null;const e=i.part;if(!(e instanceof Node))return null;const s=this.direction;if(s===1||s===2){const n=this.findValidLinkablePort(i,!1);if(n!==null)return this.isForwards=!0,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!1))return this.isForwards=!0,o}}if(s===1||s===3){const n=this.findValidLinkablePort(i,!0);if(n!==null)return this.isForwards=!1,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!0))return this.isForwards=!1,o}}return null}doActivate(){const t=this.diagram,i=this.findLinkablePort();if(i===null){this.stopTool();return}if(this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.isForwards){this.temporaryToNode!==null&&(this.temporaryToNode.location=t.lastInput.documentPoint),this.originalFromPort=i;const e=this.originalFromPort.part;e instanceof Node&&(this.originalFromNode=e),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else{this.temporaryFromNode!==null&&(this.temporaryFromNode.location=t.lastInput.documentPoint),this.originalToPort=i;const e=this.originalToPort.part;e instanceof Node&&(this.originalToNode=e),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0)}t.add(this.temporaryFromNode),this.temporaryFromNode&&this.temporaryFromNode.ensureBounds(),t.add(this.temporaryToNode),this.temporaryToNode&&this.temporaryToNode.ensureBounds(),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.temporaryLink.isTreeLink=this.isNewTreeLink(),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.startObject=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=null,e=null,s=null,n=null,o=null;try{this.targetPort=this.findTargetPort(this.isForwards);const r=this.targetPort;if(r!==null){const l=r.part;l instanceof Node&&(this.isForwards?(this.originalFromNode!==null&&(i=this.originalFromNode,e=this.originalFromPort),s=l,n=r):(i=l,e=r,this.originalToNode!==null&&(s=this.originalToNode,n=this.originalToPort)))}else this.isForwards?this.originalFromNode!==null&&this.isUnconnectedLinkValid&&(i=this.originalFromNode,e=this.originalFromPort):this.originalToNode!==null&&this.isUnconnectedLinkValid&&(s=this.originalToNode,n=this.originalToPort);i!==null||s!==null?(o=this.insertLink(i,e,s,n),o!==null?(r===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint),t.allowSelect&&(t.v("ChangingSelection",t.selection),t.clearSelection(!0),o.isSelected=!0),this.transactionResult=this.name,t.v("LinkDrawn",o)):this.doNoLink(i,e,s,n)):this.isForwards?this.doNoLink(this.originalFromNode,this.originalFromPort,null,null):this.doNoLink(null,null,this.originalToNode,this.originalToPort)}finally{this.stopTool(),o&&t.allowSelect&&t.v("ChangedSelection",t.selection)}}}isNewTreeLink(){const t=this.archetypeLinkData;if(t===null)return!0;if(t instanceof Link)return t.isTreeLink;const i=this.diagram;if(i===null)return!0;const e=i.partManager.getLinkCategoryForData(t),s=i.partManager.findLinkTemplateForCategory(e);return s!==null?s.isTreeLink:!0}insertLink(t,i,e,s){return this.diagram.partManager.insertLink(t,i,e,s)}doNoLink(t,i,e,s){}}class RelinkingTool extends LinkingBaseTool{YP;GP;fs;jP;constructor(t){super(),this.name="Relinking",this.YP=new Shape("Diamond",{desiredSize:Size.hu,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:0}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.GP=new Shape("Diamond",{desiredSize:Size.hu,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:-1}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.fs=null,this.jP=new Rect,t&&Object.assign(this,t)}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i="RelinkFrom",e=null;if(t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkFrom()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null&&(e=this.makeAdornment(s,!1),t.addAdornment(i,e)))}if(e===null&&t.removeAdornment(i),i="RelinkTo",e=null,t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkTo()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null?(e=this.makeAdornment(s,!0),t.addAdornment(i,e)):e.c())}e===null&&t.removeAdornment(i)}makeAdornment(t,i){const e=new Adornment;e.type=Panel.Link;const s=i?this.toHandleArchetype:this.fromHandleArchetype;return s!==null&&e.add(s.copy().bm()),e.adornedObject=t,e}get fromHandleArchetype(){return this.YP}set fromHandleArchetype(t){this.YP=t}get toHandleArchetype(){return this.GP}set toHandleArchetype(t){this.GP=t}get handle(){return this.fs}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.fs=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowRelink||!t.model.Xw()||!t.lastInput.left)return!1;let e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom");return e===null&&(e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo")),e!==null}doActivate(){const t=this.diagram;if(this.originalLink===null){let i=this.handle;if(i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom"),i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo"))),i===null)return;const e=i.part;if(!(e instanceof Adornment)||!(e.adornedPart instanceof Link))return;this.handle=i,this.isForwards=e===null||e.category==="RelinkTo",this.originalLink=e.adornedPart}this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.originalFromPort=this.originalLink.fromPort,this.originalFromNode=this.originalLink.fromNode,this.originalToPort=this.originalLink.toPort,this.originalToNode=this.originalLink.toNode,this.jP.set(this.originalLink.actualBounds),this.originalLink!==null&&this.originalLink.pointsCount>0&&(this.originalLink.fromNode===null&&(this.temporaryFromPort!==null&&(this.temporaryFromPort.desiredSize=Size.lu),this.temporaryFromNode!==null&&(this.temporaryFromNode.location=this.originalLink.getPoint(0))),this.originalLink.toNode===null&&(this.temporaryToPort!==null&&(this.temporaryToPort.desiredSize=Size.lu),this.temporaryToNode!==null&&(this.temporaryToNode.location=this.originalLink.getPoint(this.originalLink.pointsCount-1)))),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0),t.add(this.temporaryFromNode),t.add(this.temporaryToNode),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.copyLinkProperties(this.originalLink,this.temporaryLink),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}copyLinkProperties(t,i){if(t===null||i===null)return;i.adjusting=t.adjusting,i.corner=t.corner;let e=t.curve;(e===11||e===10)&&(e=0),i.curve=e,i.curviness=t.curviness,i.isTreeLink=t.isTreeLink,i.points=t.points,i.routing=t.routing,i.smoothness=t.smoothness,i.fromSpot=t.fromSpot,i.fromEndSegmentLength=t.fromEndSegmentLength,i.fromShortLength=t.fromShortLength,i.toSpot=t.toSpot,i.toEndSegmentLength=t.toEndSegmentLength,i.toShortLength=t.toShortLength}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.handle=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=this.originalFromNode,e=this.originalFromPort,s=this.originalToNode,n=this.originalToPort,o=this.originalLink;try{if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null){const r=this.targetPort.part;r instanceof Node&&(this.isForwards?(s=r,n=this.targetPort):(i=r,e=this.targetPort))}else this.isUnconnectedLinkValid?this.isForwards?(s=null,n=null):(i=null,e=null):o=null;o!==null?(this.reconnectLink(o,this.isForwards?s:i,this.isForwards?n:e,this.isForwards),this.targetPort===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint,o.invalidateRoute()),this.transactionResult=this.name,t.v("LinkRelinked",o,this.isForwards?this.originalToPort:this.originalFromPort)):this.doNoRelink(this.originalLink,this.isForwards),this.originalLink.invalidateOtherJumpOvers(this.jP)}finally{this.stopTool()}}}reconnectLink(t,i,e,s){const n=e!==null&&e.portId!==null?e.portId:"";return s?(t.toNode=i,t.toPortId=n):(t.fromNode=i,t.fromPortId=n),!0}doNoRelink(t,i){}doDraggingMouseMove(t,i,e,s){t!==null?(this.copyPortProperties(t,i,this.temporaryFromNode,this.temporaryFromPort,!1),this.diagram.add(this.temporaryFromNode)):this.diagram.remove(this.temporaryFromNode),e!==null?(this.copyPortProperties(e,s,this.temporaryToNode,this.temporaryToPort,!0),this.diagram.add(this.temporaryToNode)):this.diagram.remove(this.temporaryToNode)}stopDraggingMouseMove(){this.diagram.remove(this.temporaryFromNode),this.diagram.remove(this.temporaryToNode)}}var ReshapingBehavior=(w=>(w[w.None=0]="None",w[w.Horizontal=1]="Horizontal",w[w.Vertical=2]="Vertical",w[w.All=3]="All",w))(ReshapingBehavior||{});class LinkReshapingTool extends Tool{Co;HP;qP;fs;Kw;WP;km;constructor(t){super(),this.name="LinkReshaping",this.Co=new Shape("Rectangle",{desiredSize:Size.iC,fill:"lightblue",stroke:"dodgerblue"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.HP=new Shape("Diamond",{desiredSize:Size.hu,fill:"lightblue",stroke:"dodgerblue",cursor:"move"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.qP=3,this.fs=null,this.Kw=null,this.WP=new Point,this.km=new List,t&&Object.assign(this,t)}static None=0;static Horizontal=1;static Vertical=2;static All=3;getReshapingBehavior(t){return t?t.wr:0}setReshapingBehavior(t,i){t.wr=i}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i=null;if(t.isSelected&&!this.diagram.isReadOnly){const e=t.path;e!==null&&t.canReshape()&&t.actualBounds.isReal()&&t.isVisible()&&e.actualBounds.isReal()&&e.isVisibleObject()&&(i=t.findAdornment(this.name),(i===null||i.JP!==t.pointsCount||i.$P!==t.resegmentable)&&(i=this.makeAdornment(e),i!==null&&(i.JP=t.pointsCount,i.$P=t.resegmentable,t.addAdornment(this.name,i))))}i===null&&t.removeAdornment(this.name)}makeAdornment(t){const i=t.part,e=i.points,s=i.pointsCount,n=i.isOrthogonal;let o=null;if(e!==null&&s>1){o=new Adornment,o.type=Panel.Link;const r=i.firstPickIndex,l=i.lastPickIndex,h=n?1:0;if(i.resegmentable&&i.computeCurve()!==9)for(let a=r+h;ae.firstPickIndex+1&&s0))this.sF(t,i);else if(t instanceof Panel){const e=t.elements;for(;e.next();){const s=e.value;this.updateResizeHandles(s,i)}}}}sF(t,i){let e=t.alignment;e.isNoSpot()&&(e=Spot.Center);let s=i;if(e.x<=0)e.y<=0?s+=225:e.y>=1?s+=135:s+=180;else if(e.x>=1)e.y<=0?s+=315:e.y>=1&&(s+=45);else if(e.y<=0)s+=270;else if(e.y>=1)s+=90;else return;s<0?s+=360:s>=360&&(s-=360),s<22.5?t.cursor="e-resize":s<67.5?t.cursor="se-resize":s<112.5?t.cursor="s-resize":s<157.5?t.cursor="sw-resize":s<202.5?t.cursor="w-resize":s<247.5?t.cursor="nw-resize":s<292.5?t.cursor="n-resize":s<337.5?t.cursor="ne-resize":t.cursor="e-resize"}get handleArchetype(){return this.Co}set handleArchetype(t){this.Co=t}get handle(){return this.fs}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.fs=t}get adornedObject(){return this.us}set adornedObject(t){if(t!==null&&t.part instanceof Adornment)throw new Error("new handle must not be in an Adornment: "+t);this.us=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowResize||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle!==null&&(this.adornedObject=this.handle.part.adornedObject,this.adornedObject!==null&&(t.isMouseCaptured=!0,t.animationManager.stopAnimation(),t.yu=!0,this.startTransaction(this.name),this.Pm.set(this.adornedObject.getDocumentPoint(this.handle.alignment.opposite())),this.yc.set(this.adornedObject.part.location),this.QP.set(this.adornedObject.desiredSize),this.jw=this.computeCellSize(),this.Yw=this.computeMinSize(),this.Gw=this.computeMaxSize(),this.isActive=!0))}doDeactivate(){const t=this.diagram;t.yu=!1,t.bl=!0,this.stopTransaction(),this.handle=null,this.us=null,t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){this.adornedObject!==null&&(this.adornedObject.desiredSize=this.originalDesiredSize,this.adornedObject.part.location=this.originalLocation),this.stopTool()}doMouseMove(){const t=this.diagram;if(!this.isActive)return;const i=this.Yw,e=this.Gw,s=this.jw,n=t.lastInput.documentPoint,o=this.adornedObject.getLocalPoint(n,Point.l()),r=this.computeReshape(),l=this.computeResize(o,this.handle.alignment,i,e,s,r);this.resize(l),t.maybeUpdate(),Point.s(o)}doMouseUp(){const t=this.diagram;if(this.isActive){const i=this.Yw,e=this.Gw,s=this.jw,n=this.adornedObject.getLocalPoint(t.lastInput.documentPoint,Point.l()),o=this.computeReshape(),r=this.computeResize(n,this.handle.alignment,i,e,s,o);this.resize(r),Point.s(n),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.v("PartResized",this.adornedObject,this.originalDesiredSize)}this.stopTool()}resize(t){const i=this.diagram,e=this.adornedObject;if(e===null)return;e.desiredSize=t.size;const s=e.part;s.ensureBounds();const n=e.getDocumentPoint(this.handle.alignment.opposite());if(s instanceof Group){const o=new List;o.add(s);let r;!this.dragsMembers&&!s.hasPlaceholder()&&(r=new DraggingOptions,r.dragsMembers=!1),i.moveParts(o,this.oppositePoint.copy().subtract(n),!0,r)}else s.location=s.location.copy().subtract(n).add(this.oppositePoint);i.maybeUpdate()}computeResize(t,i,e,s,n,o){i.isNoSpot()&&(i=Spot.Center);const r=this.adornedObject.naturalBounds,l=r.x,h=r.y,a=r.x+r.width,c=r.y+r.height;let f=1;if(!o){let m=r.width,g=r.height;m<=0&&(m=1),g<=0&&(g=1),f=g/m}const u=Point.l();Geo.Eg(t.x,t.y,l,h,n.width,n.height,u);const d=r.copy();return i.x<=0?i.y<=0?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=Math.max(c-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.x=a-d.width,d.y=c-d.height)):i.y>=1?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.x=a-d.width)):(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=a-d.x,o||(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f,d.y=h+.5*(c-h-d.height))):i.x>=1?i.y<=0?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=Math.max(c-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.y=c-d.height)):i.y>=1?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width))):(d.width=Math.max(Math.min(u.x-l,s.width),e.width),o||(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f,d.y=h+.5*(c-h-d.height))):i.y<=0?(d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=c-d.y,o||(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width,d.x=l+.5*(a-l-d.width))):i.y>=1&&(d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width,d.x=l+.5*(a-l-d.width))),Point.s(u),d}computeReshape(){let t=0;return this.adornedObject instanceof Shape&&(t=this.adornedObject._P()),!(t===6||this.diagram.lastInput.shift)}computeMinSize(){const t=this.adornedObject.minSize.copy(),i=this.minSize;return!isNaN(i.width)&&i.width>t.width&&(t.width=i.width),!isNaN(i.height)&&i.height>t.height&&(t.height=i.height),t}computeMaxSize(){const t=this.adornedObject.maxSize.copy(),i=this.maxSize;return!isNaN(i.width)&&i.width0&&(t.width=n.width),!isNaN(n.height)&&n.height>0&&(t.height=n.height)}let e=this.cellSize;isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height);const s=this.diagram;if((isNaN(t.width)||isNaN(t.height))&&s){const n=s.grid;n!==null&&n.visible&&this.isGridSnapEnabled&&(e=n.gridCellSize,isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height))}return(isNaN(t.width)||t.width===0||t.width===1/0)&&(t.width=1),(isNaN(t.height)||t.height===0||t.height===1/0)&&(t.height=1),t}get minSize(){return this.xr}set minSize(t){if(!this.xr.equals(t)){let e=t.width;isNaN(e)&&(e=0);let s=t.height;isNaN(s)&&(s=0),this.xr.e(e,s)}}get maxSize(){return this.br}set maxSize(t){if(!this.br.equals(t)){let e=t.width;isNaN(e)&&(e=1/0);let s=t.height;isNaN(s)&&(s=1/0),this.br.e(e,s)}}get cellSize(){return this.Lo}set cellSize(t){this.Lo.equals(t)||this.Lo.a(t)}get isGridSnapEnabled(){return this.pc}set isGridSnapEnabled(t){Util.i(t,"boolean",ResizingTool,"isGridSnapEnabled"),this.pc=t}get dragsMembers(){return this.ZP}set dragsMembers(t){Util.i(t,"boolean",ResizingTool,"dragsMembers"),this.ZP=t}get oppositePoint(){return this.Pm}set oppositePoint(t){this.Pm.equals(t)||this.Pm.a(t)}get originalDesiredSize(){return this.QP}get originalLocation(){return this.yc}}class RotatingTool extends Tool{tM;iM;us;Co;fs;eM;Mm;yc;sM;nM;constructor(t){super(),this.name="Rotating",this.tM=45,this.iM=2,this.yc=new Point,this.us=null,this.Co=new Shape("Ellipse",{desiredSize:Size.hu,fill:"lightblue",stroke:"dodgerblue",strokeWidth:1,cursor:"pointer"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.fs=null,this.eM=0,this.Mm=new Point(NaN,NaN),this.sM=0,this.nM=50,t&&Object.assign(this,t)}updateAdornments(t){if(t!==null){if(t.Cl()){const i=t.rotateObject;if(i===t||i===t.path||i.isPanelMain)return}if(t.isSelected&&!this.diagram.isReadOnly){const i=t.rotateObject;if(i!==null&&t.canRotate()&&t.actualBounds.isReal()&&t.isVisible()&&i.actualBounds.isReal()&&i.isVisibleObject()){let e=t.findAdornment(this.name);if((e===null||e.adornedObject!==i)&&(e=this.makeAdornment(i)),e!==null){e.angle=i.getDocumentAngle(),e.hasPlaceholder()||(e.location=this.computeAdornmentLocation(i)),t.addAdornment(this.name,e);return}}}t.removeAdornment(this.name)}}makeAdornment(t){let i=null;const e=t.part.rotateAdornmentTemplate;if(e===null){i=new Adornment,i.type=Panel.Position,i.locationSpot=Spot.Center;const s=this.handleArchetype;s!==null&&i.add(s.copy().bm())}else if(e.li(),i=e.copy(),i===null)return null;return i.adornedObject=t,i}get handleArchetype(){return this.Co}set handleArchetype(t){this.Co=t}get handle(){return this.fs}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.fs=t}get adornedObject(){return this.us}set adornedObject(t){if(t!==null&&t.part instanceof Adornment)throw new Error("new handle must not be in an Adornment: "+t);this.us=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowRotate||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;if(this.adornedObject===null){if(this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle===null)return;this.adornedObject=this.handle.part.adornedObject}this.adornedObject!==null&&(t.isMouseCaptured=!0,t.delaysLayout=!0,this.startTransaction(this.name),this.eM=this.adornedObject.angle,this.Mm=this.computeRotationPoint(this.adornedObject),this.yc=this.adornedObject.part.location.copy(),this.isActive=!0)}computeRotationPoint(t){const i=t.part,e=i.locationObject;return i.rotationSpot.isSpot()?t.getDocumentPoint(i.rotationSpot):t===i||t===e?e.getDocumentPoint(i.locationSpot):t.getDocumentPoint(Spot.Center)}computeAdornmentLocation(t){let i=this.rotationPoint;i.isReal()||(i=this.computeRotationPoint(t));const e=t.getLocalPoint(i);let s=this.handleAngle;s<0?s+=360:s>=360&&(s-=360),s=Math.round(Math.round(s/45)*45);const n=this.handleDistance;return s===0?e.x=t.naturalBounds.width+n:s===45?(e.x=t.naturalBounds.width+n,e.y=t.naturalBounds.height+n):s===90?e.y=t.naturalBounds.height+n:s===135?(e.x=-n,e.y=t.naturalBounds.height+n):s===180?e.x=-n:s===225?(e.x=-n,e.y=-n):s===270?e.y=-n:s===315&&(e.x=t.naturalBounds.width+n,e.y=-n),t.getDocumentPoint(e)}doDeactivate(){const t=this.diagram;this.stopTransaction(),this.handle=null,this.us=null,this.Mm=new Point(NaN,NaN),t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){const t=this.diagram;t.delaysLayout=!1,this.rotate(this.originalAngle),this.stopTool()}doMouseMove(){const t=this.diagram;if(this.isActive){const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i)}}doMouseUp(){const t=this.diagram;if(this.isActive){t.delaysLayout=!1;const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.v("PartRotated",this.adornedObject,this.originalAngle)}this.stopTool()}rotate(t){const i=this.adornedObject;if(i===null)return;i.angle=t;const e=i.part;e.ensureBounds();const s=e.locationObject,n=e.rotateObject;if(s===n||s.isContainedBy(n)){const o=this.yc.copy();e.location=o.subtract(this.rotationPoint).rotate(t-this.originalAngle).add(this.rotationPoint)}this.diagram.maybeUpdate()}computeRotate(t){let i=this.rotationPoint.directionPoint(t)-this.handleAngle;const e=this.adornedObject.panel;e!==null&&(i-=e.getDocumentAngle()),i>=360?i-=360:i<0&&(i+=360);const s=Math.min(Math.abs(this.snapAngleMultiple),180),n=Math.min(Math.abs(this.snapAngleEpsilon),s/2);return!this.diagram.lastInput.shift&&s>0&&n>0&&(i%ss-n&&(i=(Math.floor(i/s)+1)*s)),i>=360?i-=360:i<0&&(i+=360),i}get snapAngleMultiple(){return this.tM}set snapAngleMultiple(t){Util.i(t,"number",RotatingTool,"snapAngleMultiple"),this.tM=t}get snapAngleEpsilon(){return this.iM}set snapAngleEpsilon(t){Util.i(t,"number",RotatingTool,"snapAngleEpsilon"),this.iM=t}get originalAngle(){return this.eM}get rotationPoint(){return this.Mm}set rotationPoint(t){this.Mm=t.copy()}get handleAngle(){return this.sM}set handleAngle(t){Util.i(t,"number",RotatingTool,"handleAngle"),this.sM=t}get handleDistance(){return this.nM}set handleDistance(t){Util.i(t,"number",RotatingTool,"handleDistance"),this.nM=t}}class ClickSelectingTool extends Tool{constructor(t){super(),this.name="ClickSelecting",t&&Object.assign(this,t)}canStart(){return!(!this.isEnabled||this.isBeyondDragSize())}doMouseUp(){this.isActive&&(this.standardMouseSelect(),this.standardMouseClick()||this.diagram.lastInput.isTouchEvent&&this.diagram.toolManager.doToolTip()),this.stopTool()}}class ActionTool extends Tool{wc;constructor(t){super(),this.name="Action",this.wc=null,t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram,i=t.lastInput,e=t.findObjectAt(i.documentPoint,s=>{for(;s.panel!==null;){if(s.isActionable)return s;s=s.panel}return s});return e!==null&&e.isActionable?(this.wc=e,t.cc=t.findObjectAt(i.documentPoint,null,null),!0):!1}doMouseDown(){if(!this.isActive)this.canStart()&&this.doActivate();else{const i=this.diagram.lastInput,e=this.wc;if(e===null)return;i.targetObject=e,e.actionDown!==null&&e.actionDown(i,e)}}doMouseMove(){if(this.isActive){const i=this.diagram.lastInput,e=this.wc;if(e===null)return;i.targetObject=e,e.actionMove!==null&&e.actionMove(i,e)}}doMouseUp(){if(this.isActive){const i=this.diagram.lastInput,e=this.wc;if(e===null)return;i.targetObject=e,e.actionUp!==null&&e.actionUp(i,e),this.standardMouseClick(s=>{for(;s.panel!==null;){if(s.isActionable&&s===e)return s;s=s.panel}return s},s=>s===e)}this.stopTool()}doCancel(){const i=this.diagram.lastInput,e=this.wc;e!==null&&(i.targetObject=e,e.actionCancel!==null&&e.actionCancel(i,e),this.stopTool())}doStop(){this.wc=null}}class ClickCreatingTool extends Tool{Ll;oM;pc;rM;constructor(t){super(),this.name="ClickCreating",this.Ll=null,this.oM=!0,this.pc=!1,this.rM=new Point(0,0),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled||this.archetypeNodeData===null)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.lastInput.left||this.isBeyondDragSize())return!1;if(this.isDoubleClick){if(t.lastInput.clickCount===1&&(this.rM=t.lastInput.viewPoint.copy()),t.lastInput.clickCount!==2||this.isBeyondDragSize(this.rM))return!1}else if(t.lastInput.clickCount!==1)return!1;return!(t.currentTool!==this&&t.findPartAt(t.lastInput.documentPoint,!0)!==null)}doMouseUp(){const t=this.diagram;this.isActive&&this.insertPart(t.lastInput.documentPoint),this.stopTool()}insertPart(t){const i=this.diagram,e=this.archetypeNodeData;if(e===null)return null;let s=null;try{if(i.v("ChangingSelection",i.selection),this.startTransaction(this.name),e instanceof Part)e.Pe()&&(e.li(),s=e.copy(),s!==null&&i.add(s));else if(e!==null){const n=i.model.copyNodeData(e);Util.wt(n)&&(i.model.addNodeData(n),s=i.findPartForData(n))}if(s!==null){const n=Point.X(t.x,t.y);this.isGridSnapEnabled&&this.diagram.lM(s,t,n),s.location=n,i.allowSelect&&(i.clearSelection(!0),s.isSelected=!0),Point.s(n)}i.invalidateDocumentBounds(),this.transactionResult=this.name,i.v("PartCreated",s)}finally{this.stopTransaction(),i.v("ChangedSelection",i.selection)}return s}get archetypeNodeData(){return this.Ll}set archetypeNodeData(t){t!==null&&Util.i(t,"object",ClickCreatingTool,"archetypeNodeData"),this.Ll=t}get isDoubleClick(){return this.oM}set isDoubleClick(t){Util.i(t,"boolean",ClickCreatingTool,"isDoubleClick"),this.oM=t}get isGridSnapEnabled(){return this.pc}set isGridSnapEnabled(t){Util.i(t,"boolean",ClickCreatingTool,"isGridSnapEnabled"),this.pc=t}}class DragSelectingTool extends Tool{Bh;hM;Al;constructor(t){super(),this.name="DragSelecting",this.Bh=175,this.hM=!1,this.Al=new Part({layerName:"Tool",selectable:!1}).add(new Shape("Rectangle",{name:"SHAPE",fill:null,stroke:"magenta"}).theme("stroke","dragSelect")).li(),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(!t.allowSelect)return!1;const i=t.lastInput;return!(!i.left||t.currentTool!==this&&(!this.isBeyondDragSize()||i.timestamp-t.firstInput.timestamp{const e=i.diagram;e!==null&&e.Si(root.document,"scroll",i.aM,!1),i.stopTool()},t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return!(!t.allowHorizontalScroll&&!t.allowVerticalScroll||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize())}doActivate(){const t=this.diagram;this.No?(t.lastInput.bubbles=!0,t.Vt(root.document,"scroll",this.aM,!1)):(t.currentCursor="move",t.isMouseCaptured=!0,this.Hw.a(t.position)),this.isActive=!0}doDeactivate(){const t=this.diagram;t.currentCursor="",t.isMouseCaptured=!1,this.isActive=!1}doCancel(){const t=this.diagram;t.position=this.Hw,t.isMouseCaptured=!1,this.stopTool()}doMouseMove(){this.HC()}doMouseUp(){this.HC(),this.stopTool()}HC(){const t=this.diagram;if(this.isActive&&t){if(this.No){t.lastInput.bubbles=!0;return}const i=t.position,e=t.firstInput.documentPoint,s=t.lastInput.documentPoint;let n=i.x+e.x-s.x,o=i.y+e.y-s.y;t.allowHorizontalScroll||(n=i.x),t.allowVerticalScroll||(o=i.y),t.position=this.jC.e(n,o)}}get bubbles(){return this.No}set bubbles(t){Util.i(t,"boolean",PanningTool,"bubbles"),this.No=t}get originalPosition(){return this.Hw}}class HTMLInfo{qw;Ww;cM;fM;constructor(t){this.qw=null,this.Ww=null,this.cM=null,this.fM=null,t&&Object.assign(this,t)}get mainElement(){return this.cM}set mainElement(t){this.cM=t}get show(){return this.qw}set show(t){this.qw!==t&&(t!==null&&Util.i(t,"function",HTMLInfo,"show"),this.qw=t)}get hide(){return this.Ww}set hide(t){this.Ww!==t&&(t!==null&&Util.i(t,"function",HTMLInfo,"hide"),this.Ww=t)}get valueFunction(){return this.fM}set valueFunction(t){this.fM=t}}class ContextMenuButtonInfo{hi;Sm;bc;constructor(t,i,e){this.hi=t,this.Sm=i,this.bc=e}}class ContextMenuTool extends Tool{uM;Jw;dM;gM;$w;Zw;Nm;constructor(t){super(),this.name="ContextMenu",this.uM=null,this.Jw=null,this.dM=null,this.gM=new Point,this.$w=null,this.Nm=!1;const i=this;this.Zw=()=>i.stopTool(),t&&Object.assign(this,t)}nF(){const t=new HTMLInfo;t.show=(r,l,h)=>h.showDefaultContextMenu(),t.hide=(r,l)=>l.hideDefaultContextMenu(),ContextMenuTool.ku=t;const i=this;this.Zw=()=>i.stopTool();const e=Util.en("div"),s=Util.en("div");e.style.cssText="top: 0px;z-index:10002;position: fixed;display: none;text-align: center;left: 25%;width: 50%;background-color: #F5F5F5;padding: 16px;border: 16px solid #444;border-radius: 10px;margin-top: 10px",s.style.cssText="z-index:10001;position: fixed;display: none;top: 0;left: 0;width: 100%;height: 100%;background-color: black;opacity: 0.8;";const n=Util.en("style");root.document.getElementsByTagName("head")[0].appendChild(n),n.sheet.insertRule(".goCXul { list-style: none; }",0),n.sheet.insertRule(".goCXli {font:700 1.5em Helvetica, Arial, sans-serif;position: relative;min-width: 60px; }",0),n.sheet.insertRule(".goCXa {color: #444;display: inline-block;padding: 4px;text-decoration: none;margin: 2px;border: 1px solid gray;border-radius: 10px; }",0);const o=this.diagram;o!==null&&(o.Vt(e,"contextmenu",ContextMenuTool.Kh,!1),o.Vt(e,"selectstart",ContextMenuTool.Kh,!1),o.Vt(s,"contextmenu",ContextMenuTool.Kh,!1)),e.className="goCXforeground",s.className="goCXbackground",root.document.body&&(root.document.body.appendChild(e),root.document.body.appendChild(s)),ContextMenuTool.Cm=e,ContextMenuTool.Lm=s,ContextMenuTool.mM=!0}static ku=null;static mM=!1;static Lm=null;static Cm=null;static Kh(t){return t.preventDefault(),!1}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return this.isBeyondDragSize()||!t.lastInput.right||t.lastInput.clickCount>1?!1:!!(t.lastInput.isTouchEvent&&this.defaultTouchContextMenu!==null||this.findObjectWithContextMenu()!==null)}doStart(){const t=this.diagram;this.gM.set(t.firstInput.documentPoint)}doStop(){this.hideContextMenu(),this.currentObject=null,this.Nm=!1}findObjectWithContextMenu(t){t===void 0&&(t=null);const i=this.diagram,e=i.lastInput;let s=null;if(t instanceof Diagram||(t instanceof GraphObject?s=t:s=i.findObjectAt(e.documentPoint,null,n=>!n.layer.isTemporary)),s!==null){let n=s;for(;n!==null;){if(n.contextMenu!==null)return n;n=n.panel}if(i.lastInput.isTouchEvent&&this.defaultTouchContextMenu)return s.part}else if(i.contextMenu!==null)return i;return null}doActivate(){}doMouseDown(){if(super.doMouseDown(),this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doMouseDown(),t.doDeactivate())}this.diagram.toolManager.mouseDownTools.has(this)&&this.doContextClick()}doMouseUp(){if(this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doCancel(),t.doDeactivate())}this.doContextClick()}doContextClick(){const t=this.diagram;if(!this.isActive)this.canStart()&&(this.openMenu(!0),this.isActive||this.stopTool());else{const i=this.currentContextMenu;if(i===null)return;let e=null;i instanceof HTMLInfo||(e=t.findObjectAt(t.lastInput.documentPoint,null,null),e!==null&&e.isContainedBy(i)&&this.standardMouseClick(null,null)),this.maybeStopTool(e)}}maybeStopTool(t){this.stopTool(),this.canStart()&&(this.diagram.currentTool=this,this.doMouseUp())}openMenu(t,i){if(i===void 0&&(i=null),this.Nm)return;this.Nm=!0,t&&this.standardMouseSelect();const e=this.standardMouseClick();if(this.Nm=!1,!e){this.isActive=!0;const s=ContextMenuTool.ku;if(i===null&&(i=this.findObjectWithContextMenu()),i!==null){const n=i.contextMenu;n!==null?(this.currentObject=i instanceof GraphObject?i:null,this.showContextMenu(n,this.currentObject)):s!==null&&this.showContextMenu(s,this.currentObject)}else s!==null&&this.showContextMenu(s,null);this.currentContextMenu instanceof Adornment&&!this.currentContextMenu.visible&&this.stopTool()}}doMouseMove(){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.doMouseMove(),this.isActive&&this.diagram.toolManager.doMouseMove()}showContextMenu(t,i){const e=this.diagram;if(t!==this.currentContextMenu&&this.hideContextMenu(),t instanceof Adornment){const s=t;s.layerName="Tool",s.selectable=!1,s.scale=1/e.scale,s.category=this.name,s.hasPlaceholder()&&(s.placeholder.scale=e.scale);const n=s.diagram;n!==null&&n!==e&&n.remove(s),e.add(s),i!==null?s.adornedObject=i:s.data=e.model,s.ensureBounds(),this.positionContextMenu(s,i)}else t instanceof HTMLInfo&&t.show(i,e,this);this.currentContextMenu=t}positionContextMenu(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom&&(n.y-=o.height+5/s.scale),n.ye.commandHandler.copySelection(),e=>e.commandHandler.canCopySelection())),i.add(new ContextMenuButtonInfo("Cut",e=>e.commandHandler.cutSelection(),e=>e.commandHandler.canCutSelection())),i.add(new ContextMenuButtonInfo("Delete",e=>e.commandHandler.deleteSelection(),e=>e.commandHandler.canDeleteSelection())),i.add(new ContextMenuButtonInfo("Paste",e=>e.commandHandler.pasteSelection(t.mouseDownPoint),e=>e.commandHandler.canPasteSelection(t.mouseDownPoint))),i.add(new ContextMenuButtonInfo("Select All",e=>e.commandHandler.selectAll(),e=>e.commandHandler.canSelectAll())),i.add(new ContextMenuButtonInfo("Undo",e=>e.commandHandler.undo(),e=>e.commandHandler.canUndo())),i.add(new ContextMenuButtonInfo("Redo",e=>e.commandHandler.redo(),e=>e.commandHandler.canRedo())),i.add(new ContextMenuButtonInfo("Scroll To Part",e=>e.commandHandler.scrollToPart(),e=>e.commandHandler.canScrollToPart())),i.add(new ContextMenuButtonInfo("Zoom To Fit",e=>e.commandHandler.zoomToFit(),e=>e.commandHandler.canZoomToFit())),i.add(new ContextMenuButtonInfo("Reset Zoom",e=>e.commandHandler.resetZoom(),e=>e.commandHandler.canResetZoom())),i.add(new ContextMenuButtonInfo("Group Selection",e=>e.commandHandler.groupSelection(),e=>e.commandHandler.canGroupSelection())),i.add(new ContextMenuButtonInfo("Ungroup Selection",e=>e.commandHandler.ungroupSelection(),e=>e.commandHandler.canUngroupSelection())),i.add(new ContextMenuButtonInfo("Edit Text",e=>e.commandHandler.editTextBlock(),e=>e.commandHandler.canEditTextBlock())),i}showDefaultContextMenu(){const t=this.diagram;this.$w===null&&(this.$w=this.oF()),ContextMenuTool.Cm.innerHTML="",ContextMenuTool.Lm.addEventListener("pointerdown",this.Zw,!1);const i=this,e=Util.en("ul");e.className="goCXul",ContextMenuTool.Cm.appendChild(e),e.innerHTML="";const s=this.$w.iterator;for(;s.next();){const n=s.value,o=n.Sm,r=n.bc;if(typeof o!="function"||typeof r=="function"&&!r(t))continue;const l=Util.en("li");l.className="goCXli";const h=Util.en("a");h.className="goCXa",h.href="#",h.Sm=n.Sm,h.addEventListener("pointerdown",function(a){return this.Sm(t),i.stopTool(),a.preventDefault(),!1},!1),h.textContent=n.hi,l.appendChild(h),e.appendChild(l)}ContextMenuTool.Cm.style.display="block",ContextMenuTool.Lm.style.display="block"}hideDefaultContextMenu(){if(this.currentContextMenu===null||this.currentContextMenu!==ContextMenuTool.ku)return;ContextMenuTool.Cm.style.display="none",ContextMenuTool.Lm.style.display="none";const t=this.diagram;t!==null&&t.Si(ContextMenuTool.Lm,"pointerdown",this.Zw,!1),this.currentContextMenu=null}get currentContextMenu(){return this.uM}set currentContextMenu(t){this.uM=t,this.Jw=t instanceof Adornment?t.adornedPart:null}get defaultTouchContextMenu(){return ContextMenuTool.mM===!1&&ContextMenuTool.ku===null&&Diagram.isUsingDOM()&&this.nF(),ContextMenuTool.ku}set defaultTouchContextMenu(t){t===null&&(ContextMenuTool.mM=!0),ContextMenuTool.ku=t}get currentObject(){return this.dM}set currentObject(t){this.dM=t}get mouseDownPoint(){return this.gM}}var TextEditingAccept=(w=>(w[w.LostFocus=1]="LostFocus",w[w.MouseDown=2]="MouseDown",w[w.Tab=3]="Tab",w[w.Enter=4]="Enter",w))(TextEditingAccept||{}),TextEditingStarting=(w=>(w[w.SingleClick=1]="SingleClick",w[w.SingleClickSelected=2]="SingleClickSelected",w[w.DoubleClick=3]="DoubleClick",w))(TextEditingStarting||{}),TextEditingState=(w=>(w[w.None=1]="None",w[w.Active=2]="Active",w[w.Editing=3]="Editing",w[w.Validating=4]="Validating",w[w.Invalid=5]="Invalid",w[w.Validated=6]="Validated",w))(TextEditingState||{});class TextEditingTool extends Tool{Me;pM;yM;Tl;Yt;wM;xM;bM;Qw;_w;constructor(t){super(),this.name="TextEditing",this.Me=new TextBlock,this.pM=null,this.yM=2,this.Tl=null,this.Yt=1,this.wM=1,this.xM=!0,this.bM=null,this.Qw=new HTMLInfo,this._w=null,this.rF(this.Qw),t&&Object.assign(this,t)}static LostFocus=1;static MouseDown=2;static Tab=3;static Enter=4;static SingleClick=1;static SingleClickSelected=2;static DoubleClick=3;static StateNone=1;static StateActive=2;static StateEditing=3;static StateValidating=4;static StateInvalid=5;static StateValidated=6;rF(t){if(!Diagram.isUsingDOM())return;const i=Util.en("textarea");this._w=i;const e=this;i.addEventListener("input",function(s){if(e.textBlock===null)return;const n=e.measureTemporaryTextBlock(this.value),o=this.textScale;this.style.width=20+Math.max(e.textBlock.measuredBounds.width,n.measuredBounds.width)*o+"px",this.rows=Math.max(e.textBlock.lineCount,n.lineCount)},!1),i.addEventListener("keydown",function(s){if(s.isComposing||e.textBlock===null)return;const n=s.key;if(n==="Enter"){e.textBlock.isMultiline===!1&&s.preventDefault(),e.acceptText(4);return}else if(n==="Tab"){e.acceptText(3),s.preventDefault();return}else n==="Escape"&&(e.doCancel(),e.diagram!==null&&e.diagram.doFocus())},!1),i.addEventListener("focus",function(s){e.lF(s)},!1),i.addEventListener("blur",function(s){e.hF(s)},!1),t.valueFunction=()=>i.value,t.mainElement=i,t.show=(s,n,o)=>{if(!(s instanceof TextBlock&&o instanceof TextEditingTool))return;if(o.state===5){i.style.border="3px solid red",i.focus();return}const r=s.getDocumentPoint(Spot.Center),l=n.position,h=n.scale;let a=s.getDocumentScale()*h;a{s.div.removeChild(i)}}get textBlock(){return this.pM}set textBlock(t){this.pM=t}get currentTextEditor(){return this.bM}set currentTextEditor(t){this.bM=t}get defaultTextEditor(){return this.Qw}set defaultTextEditor(t){this.Qw=t}get starting(){return this.yM}set starting(t){this.yM=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t===null||t.isReadOnly||TextEditingTool.kc&&TextEditingTool.kc!==this&&(TextEditingTool.kc.acceptText(2),TextEditingTool.kc&&TextEditingTool.kc!==this)||!t.lastInput.left||this.isBeyondDragSize())return!1;const i=t.lastInput.documentPoint,e=t.findObjectAt(i);if(e===null||!(e instanceof TextBlock)||!e.editable||!e.part.canEdit())return!1;const s=e.part;return!(s===null||this.starting===2&&!s.isSelected||this.starting===3&&t.lastInput.clickCount<2)}doStart(){TextEditingTool.kc=this,this.textBlock!==null&&this.doActivate()}doActivate(){if(this.isActive)return;const t=this.diagram;if(t===null)return;let i=this.textBlock;if(i===null&&(i=t.findObjectAt(t.lastInput.documentPoint)),i===null||!(i instanceof TextBlock)||(this.textBlock=i,i.part===null))return;t.animationManager.stopAnimation(),this.isActive=!0,this.Yt=2;let s=this.defaultTextEditor;i.textEditor!==null&&(s=i.textEditor),this.Me=this.textBlock.copy();const n=new Rect(this.textBlock.getDocumentPoint(Spot.TopLeft),this.textBlock.getDocumentPoint(Spot.BottomRight));t.scrollToRect(n),s.show(i,t,this),this.currentTextEditor=s}doCancel(){this.stopTool()}doMouseUp(){this.canStart()&&this.doActivate()}doMouseDown(){this.isActive&&this.acceptText(2)}acceptText(t){switch(t){case 2:this.Yt===6?this.currentTextEditor instanceof HTMLElement&&this.currentTextEditor.focus():(this.Yt===2||this.Yt===5||this.Yt===3)&&(this.Yt=4,this.qC());break;case 1:case 4:case 3:if(t===4&&this.textBlock.isMultiline===!0)return;(this.Yt===2||this.Yt===5||this.Yt===3)&&(this.Yt=4,this.qC());break}}qC(){const t=this.textBlock,i=this.diagram,e=this.currentTextEditor;if(t!==null&&e!==null){const s=t.text;let n="";if(e.valueFunction!==null&&(n=e.valueFunction()),!this.isValidText(t,s,n)){this.Yt=5,this.doError(s,n);return}this.startTransaction(this.name),this.Yt=6,this.transactionResult=this.name,t.text=n,this.doSuccess(s,n),i!==null&&i.v("TextEdited",t,s),this.stopTransaction(),this.stopTool(),i!==null&&i.doFocus()}}doError(t,i){const e=this.textBlock;e.errorFunction!==null&&e.errorFunction(this,t,i);const s=this.currentTextEditor;s&&s.show(e,this.diagram,this)}doSuccess(t,i){const e=this.textBlock;e.textEdited!==null&&e.textEdited(e,t,i)}doDeactivate(){const t=this.diagram;t!==null&&(this.Yt=1,this.currentTextEditor!==null&&this.currentTextEditor.hide(t,this),this.textBlock=null,this.isActive=!1)}doStop(){TextEditingTool.kc=null}lF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this._w;this.Yt===2&&(this.Yt=3),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}hF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this._w;typeof i.focus=="function"&&i.focus(),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}isValidText(t,i,e){const s=this.textValidation;if(s!==null&&!s(t,i,e))return!1;const n=t.textValidation;return!(n!==null&&!n(t,i,e))}get textValidation(){return this.Tl}set textValidation(t){t!==null&&Util.i(t,"function",TextEditingTool,"textValidation"),this.Tl=t}get minimumEditorScale(){return this.wM}set minimumEditorScale(t){t!==null&&Util.i(t,"number",TextEditingTool,"minimumEditorScale"),this.wM=t}get selectsTextOnActivate(){return this.xM}set selectsTextOnActivate(t){t!==null&&Util.i(t,"boolean",TextEditingTool,"selectsTextOnActivate"),this.xM=t}get state(){return this.Yt}set state(t){this.Yt!==t&&(this.Yt=t)}measureTemporaryTextBlock(t){const i=this.Me;return i.text=t,i.ut(this.textBlock.Dl,1/0),i}static kc=null}var AnimationStyle=(w=>(w[w.Default=1]="Default",w[w.AnimateLocations=2]="AnimateLocations",w[w.None=3]="None",w))(AnimationStyle||{});class AnimationManager{p;Ni;Oi;kr;Gn;Ao;kM;PM;Am;wi;Pc;un;Tm;Yh;tx;Dm;ix;Mc;xu;Fm;constructor(t){this.p=Diagram.pm(),this.Ni=!1,this.Am=!1,this.wi=!1,this.Pc=!1,this.ix=!0,this.Mc=1,this.xu=!1,this.Oi=!0,this.kr=!0,this.Ao=600,this.kM=!1,this.PM=!1,this.Gn=new GSet,this.un=new Animation,this.Tm=new Animation,this.un.ds=this,this.Yh=new GSet,this.tx=new GSet,this.Dm=new GSet,this.Fm=new GSet,t&&Object.assign(this,t)}To(t){this.p=t}lE(){return this.p}canStart(t){return!0}Fl(t){return!this.Oi||!this.canStart(t)?!1:(this.Gn.add(t),this.defaultAnimation.isAnimating&&this.stopAnimation(),this.p.Ci(),this.wi=!0,!0)}getBundleAnimation(){return this.Tm}MM(){if(!this.Oi||(this.Tm.ae.count>0&&this.Tm.start(),!this.wi))return;const t=this.un,i=this.p,e=this.Gn.has("Model");if(e&&(this.Pc=!0,this.Mc===1?(t.isViewportUnconstrained=!0,t.ae.clear(),t.add(i,"position",i.position.copy().offset(0,-200),i.position),t.add(i,"opacity",0,1)):this.Mc===3&&t.ae.clear(),this.Mc===2&&i.ex.equals(i.ct)?this.ix=!0:this.ix=!1,i.v("InitialAnimationStarting",this)),e&&!this.kr||t.ae.count===0){this.Gn.clear(),this.wi=!1,t.ae.clear(),t.sx(i),this.Pc=!1,i.C();return}this.Gn.clear(),i.Pr=!1;const s=t.ae.get(i);i.autoScale!==1&&s!==null&&(delete s.ei.scale,delete s.gs.scale);const n=this;root.requestAnimationFrame(()=>{n.wi===!1||t.Ni||(i.getRenderingHint("temporaryPixelRatio")&&i.Bw(),i.SM(),n.wi=!1,t.start(),t.Ni&&(n.Pu(),i.invalidateDocumentBounds(),t.WC(0),i.yr(!0),n.Mu(),i.v("AnimationStarting",n)))})}NM(){return this.Gn.has("Trigger")&&this.Gn.count===1}JC(t,i,e,s){this.isTicking||this.NM()||t instanceof Link&&(t.fromNode!==null||t.toNode!==null)||this.un.add(t,"position",i,e,s)}nx(t){return this.un.nx(t)}CM(t){return this.un.CM(t)}aF(t){const i=this.Yh,e=this;function s(){if(e.Dm.count>0&&(i.addAll(e.Dm),e.Dm.clear(),e.Ni=!0),e.Ni===!1||i.count===0)return;e.tx.addAll(i);const n=e.tx.iterator;for(;n.next();){const o=n.value;o.Ni!==!1&&(o.cF()?o.$C(!1):o.Sc=!0)}if(e.tx.clear(),e.Ni===!1){root.requestAnimationFrame(s);return}e.Pu(),e.p.yr(),e.Mu(),root.requestAnimationFrame(s)}this.Ni?this.fF(t):(this.Ni=!0,i.add(t),root.requestAnimationFrame(()=>s()))}fF(t){this.Dm.add(t)}uF(){const t=this.Yh.iterator;for(;t.next();)t.value.Sc=!1}Pu(){if(this.Am)return;const t=this.p;this.kM=t.skipsUndoManager,this.PM=t.ce,t.skipsUndoManager=!0,t.ce=!0,this.Am=!0}Mu(){const t=this.p;t.skipsUndoManager=this.kM,t.ce=this.PM,this.Am=!1}stopAnimation(t){const i=this.un;if(this.wi===!0&&(this.wi=!1,this.Pc=!1,this.Gn.clear(),i.dF()&&this.p.requestUpdate()),!this.Ni){i.ae.clear(),i.sx(this.p);return}if(i.Su(!0),i.sx(null),t===!0){const e=this.Yh.toArray();for(let s=0;s{!i.isAnimating&&i.runCount===1/0&&i.start()})}get duration(){return this.Ao}set duration(t){Util.i(t,"number",AnimationManager,"duration"),t<1&&Util._(t,">= 1",AnimationManager,"duration"),this.Ao=t}get isAnimating(){return this.Ni}get isTicking(){return this.Am}get isInitial(){return this.kr}set isInitial(t){Util.i(t,"boolean",AnimationManager,"isInitial"),this.kr=t}get defaultAnimation(){return this.un}get activeAnimations(){return this.Yh}get initialAnimationStyle(){return this.Mc}set initialAnimationStyle(t){this.Mc=t}static ox=new GMap;static defineAnimationEffect(t,i){AnimationManager.ox.set(t,i)}static TM(t,i,e,s,n){t===null&&(t=[0,0,0,0]),i===null&&(i=[0,0,0,0]);let o=t[0],r=t[1];const l=t[2],h=t[3];let a=i[0],c=i[1];const f=i[2],u=i[3];l===0||l===100?(o=a,r=c):(f===0||f===100)&&(a=o,c=r),Math.abs(a-o)>180&&(a>o?o+=360:a+=360);const d=n(e,o,a-o,s)%360,m=n(e,r,c-r,s),g=n(e,l,f-l,s),p=n(e,h,u-h,s);return"hsla("+d+", "+m+"%, "+g+"%, "+p+")"}static{const t=AnimationManager.ox,i=(e,s,n,o,r,l)=>{e.position=new Point(o(r,s.x,n.x-s.x,l),o(r,s.y,n.y-s.y,l))};t.set("position:diagram",i),t.set("position",i),t.set("position:part",(e,s,n,o,r,l)=>{r{r{r{const h=e.actualBounds,a=n.actualBounds,c=a.x+a.width/2-h.width/2,f=a.y+a.height/2-h.height/2;r{e.desiredSize=new Size(o(r,s.width,n.width-s.width,l),o(r,s.height,n.height-s.height,l))}),t.set("width",(e,s,n,o,r,l)=>{e.width=o(r,s,n-s,l)}),t.set("height",(e,s,n,o,r,l)=>{e.height=o(r,s,n-s,l)}),t.set("fill",(e,s,n,o,r,l)=>{e.fill=AnimationManager.TM(s,n,r,l,o)}),t.set("stroke",(e,s,n,o,r,l)=>{e.stroke=AnimationManager.TM(s,n,r,l,o)}),t.set("strokeWidth",(e,s,n,o,r,l)=>{e.strokeWidth=o(r,s,n-s,l)}),t.set("strokeDashOffset",(e,s,n,o,r,l)=>{e.strokeDashOffset=o(r,s,n-s,l)}),t.set("background",(e,s,n,o,r,l)=>{e.background=AnimationManager.TM(s,n,r,l,o)}),t.set("opacity",(e,s,n,o,r,l)=>{e.opacity=o(r,s,n-s,l)}),t.set("scale",(e,s,n,o,r,l)=>{e.scale=o(r,s,n-s,l)}),t.set("angle",(e,s,n,o,r,l)=>{e.angle=o(r,s,n-s,l)})}static Default=1;static AnimateLocations=2;static None=3}class Animation{rx;Rm;Ni;Nu;Ao;ms;tL;Lc;ae;lx;ei;jn;Cu;Ac;hx;ax;Sc;DM;cx;ds;p;FM;RM;vM;constructor(t){this.p=null,this.ds=null,this.DM=null,this.cx=null,this.FM=!1,this.Ni=!1,this.Sc=!1,this.ei=0,this.jn=0,this.rx=Animation.EaseInOutQuad,this.Rm=Animation.EaseInOutQuad,this.Cu=!1,this.Ac=!1,this.hx=1,this.ax=0,this.Ao=NaN,this.ms=NaN,this.RM=0,this.Nu=null,this.tL=Point.Po,this.ae=new GMap,this.lx=new GMap,this.Lc=new GSet,this.vM=1,t&&Object.assign(this,t)}suspend(){this.Sc=!0}advanceTo(t,i){i&&(this.Sc=!1),this.Cu&&t>=this.ms&&(this.Ac=!0,t=t-this.ms),this.RM=t,this.$C(!0),this.ds.Pu(),this.p.yr(),this.ds.Mu(),this.p.redraw()}sx(t){if(this.lx.clear(),this.Ac=!1,this.ax=0,this.ms=NaN,this.Lc.count>0&&this.Lc.clear(),t!==null){const i=t.links;for(;i.next();)i.value.Mr=null}}dF(){return this.ae.count>0}start(){if(this.ae.count===0)return this;if(this.Ni)return this;let t=this.p;const i=this.ae.iterator;for(;i.next();){const s=i.key;t===null&&(s instanceof Diagram?t=s:s instanceof GraphObject&&(t=s.diagram))}if(t!==null)this.p=t,this.ds=t.animationManager;else return this;const e=this.ds;return e.isEnabled===!1?this:(this.ms=isNaN(this.Ao)?e.duration:this.Ao,this.Rm=this.rx,e.Pc&&e.Mc===1&&this===e.defaultAnimation&&(this.Rm=Animation.EaseOutExpo,this.ms=isNaN(this.Ao)?e.duration===600?900:e.duration:this.Ao),this.vM=t.scrollMode,this.isViewportUnconstrained&&(t.Gh=2),e.Pu(),this.Lc.each(s=>{s.data=null,t.add(s)}),e.Mu(),this.Ni=!0,this.ei=+new Date,this.jn=this.ei+this.ms,e.aF(this),this)}addTemporaryPart(t,i){return t.Pe()?(this.Lc.add(t),this.p=i,this):this}add(t,i,e,s,n){if(this.p===null&&(t instanceof Diagram?this.p=t:t instanceof GraphObject&&t.diagram!==null&&(this.p=t.diagram)),t instanceof Part){if(!t.isAnimated)return this;i==="position"&&(i="position:part")}return this.LM(t,i,e,s,n),this}LM(t,i,e,s,n){const o=this.ae;let r,l,h;if(t instanceof Diagram&&i==="position"&&(i="position:diagram"),(i==="fill"||i==="stroke"||i==="background")&&(Brush.Do(e),Brush.OM(),e=[Brush.Ii.n0,Brush.Ii.n1,Brush.Ii.n2,Brush.Ii.n3],Brush.Do(s),Brush.OM(),s=[Brush.Ii.n0,Brush.Ii.n1,Brush.Ii.n2,Brush.Ii.n3]),o.has(t))r=o.get(t),l=r.ei,h=r.gs,l[i]===void 0&&(l[i]=this.Lu(e)),h[i]=this.Lu(s);else{if(i==="position"&&e.equalsApprox(s))return;l={},h={},l[i]=this.Lu(e),h[i]=this.Lu(s),r=new AnimationState(l,h,n),o.set(t,r)}const a=l[i];a instanceof Point&&!a.isReal()&&a.a(this.tL),n&&i.indexOf("position:")===0&&t instanceof Part?r.fx.location=this.Lu(t.location):n&&(r.fx[i]=this.Lu(e))}Lu(t){return t instanceof Point||t instanceof Size?t.copy():t}gF(t){const i=this.ae;if(i.has(t)){const e=i.get(t);e.ux=!0}}nx(t){if(!this.Ni)return!1;const i=this.ae.get(t);return i!==null&&i.ux}CM(t){if(!this.Ni)return!1;const i=this.ae.get(t);return i!==null&&!!(i.ei.position||i.ei["position:part"]||i.ei.location)}cF(){if(this.Lc.count>0)return!0;const t=this.ae.iterator;for(;t.next();){const i=t.key;if(i instanceof GraphObject&&i.diagram!==null||i instanceof Diagram)return!0}return!1}$C(t){if(this.Sc&&!t)return;const i=this.ds;if(this.Ni===!1)return;const e=+new Date;let s=e>this.jn?this.ms:e-this.ei;t&&(s=this.RM,sthis.jn&&(this.Cu&&!this.Ac?(this.ei=+new Date,this.jn=this.ei+this.ms,this.Ac=!0):this.Su(!1))}WC(t){const i=this.ms,e=this.ae.iterator,s=this.Ac;for(;e.next();){const n=e.key;if(n instanceof GraphObject&&n.diagram===null)continue;const o=e.value,r=s?o.gs:o.ei,l=s?o.ei:o.gs,h=AnimationManager.ox;for(const a in l)a==="position"&&(l["position:placeholder"]||l["position:nodeCollapse"])||h.get(a)!==null&&h.get(a)(n,r[a],l[a],this.Rm,t,i,this)}}stop(){return this.Ni?(this.Su(!0),this):this}Su(t){if(this.cx!==null&&this.cx.mF(this.DM),!this.Ni)return;const i=this.p,e=this.ds;e.Pc=!1,this.Ni=!1,this.Sc=!1,e.Pu();const s=this.ae,n=this.Lc.iterator;for(;n.next();)i.remove(n.value);const o=this.Cu,r=s.iterator,l=AnimationManager.ox;for(;r.next();){const a=r.key,c=r.value,f=o?c.gs:c.ei,u=o?c.ei:c.gs,d=c.fx;for(const m in u)if(l.get(m)!==null){let g=m;c.gx&&(g==="position:nodeCollapse"||g==="position:placeholder")&&(g="position"),l.get(g)(a,f[m],d[m]!==void 0?d[m]:c.gx?f[m]:u[m],this.Rm,this.ms,this.ms,this)}c.gx&&d.location!==void 0&&a instanceof Part&&(a.location=d.location),c.ux&&a instanceof Part&&a.Ei(!1)}this.ax++;const h=!t&&this.hx>this.ax;if(!h&&(this===e.Tm||this===e.defaultAnimation)&&this.ae.clear(),i.mx.clear(),i.yP(!1),i.invalidateDocumentBounds(),i.C(),i.yr(!0),e.defaultAnimation===this){const a=e.Fm.iterator;for(;a.next();)a.value.pF();e.Fm.clear()}if(i.yr(!0),this.isViewportUnconstrained&&(i.scrollMode=this.vM),e.Mu(),h){this.Ac=!1,this.start();return}this.sx(null),e.Su(this),this.Nu&&this.Nu(this),i.requestUpdate()}Nc(t,i){const e=i.actualBounds;let s=null;if(i instanceof Group&&(s=i.placeholder),s!==null&&s.visible){const n=s.getDocumentPoint(Spot.TopLeft),o=s.padding;n.x+=o.left,n.y+=o.top,this.add(t,"position",n,t.position,!1)}else this.add(t,"position",new Point(e.x+e.width/2,e.y+e.height/2),t.position,!1);this.add(t,"scale",.01,t.scale,!1),t instanceof Group&&this.yF(t,i)}yF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Nc(s,i)}}Cc(t,i){if(!t.isVisible())return;let e=null;if(i instanceof Group&&(e=i.placeholder),e!==null&&e.visible){const s=e.getDocumentPoint(Spot.TopLeft),n=e.padding;s.x+=n.left,s.y+=n.top,this.add(t,"position:placeholder",t.position,s,!0)}else this.add(t,"position:nodeCollapse",t.position,i,!0);this.add(t,"scale",t.scale,.01,!0),this.gF(t),t instanceof Group&&this.wF(t,i)}wF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Cc(s,i)}}get duration(){return this.Ao}set duration(t){Util.i(t,"number",Animation,"duration"),t<1&&Util._(t,">= 1",Animation,"duration"),this.Ao=t}get reversible(){return this.Cu}set reversible(t){this.Cu=t}get runCount(){return this.hx}set runCount(t){t>0?this.hx=t:Util.o("Animation.runCount value must be a positive integer.")}get finished(){return this.Nu}set finished(t){this.Nu!==t&&(t!==null&&Util.i(t,"function",Animation,"finished"),this.Nu=t)}get easing(){return this.rx}set easing(t){this.rx=t}get isViewportUnconstrained(){return this.FM}set isViewportUnconstrained(t){this.FM=t}get isAnimating(){return this.Ni}getTemporaryState(t){let i=this.lx.get(t);return i===null&&(i={},this.lx.set(t,i)),i}static EaseLinear=(t,i,e,s)=>e*t/s+i;static EaseInOutQuad=(t,i,e,s)=>(t/=s/2,t<1?e/2*t*t+i:-e/2*(--t*(t-2)-1)+i);static EaseInQuad=(t,i,e,s)=>e*(t/=s)*t+i;static EaseOutQuad=(t,i,e,s)=>-e*(t/=s)*(t-2)+i;static EaseInExpo=(t,i,e,s)=>t===0?i:e*Math.pow(2,10*(t/s-1))+i;static EaseOutExpo=(t,i,e,s)=>t===s?i+e:e*(-Math.pow(2,-10*t/s)+1)+i}class AnimationState{ei;gs;fx;gx;ux;constructor(t,i,e){this.ei=t,this.gs=i,this.fx={},this.gx=e,this.ux=!1}}var TriggerStart=(w=>(w[w.Default=1]="Default",w[w.Immediate=2]="Immediate",w[w.Bundled=3]="Bundled",w))(TriggerStart||{});class AnimationTrigger{ke;an;Au;Tc;constructor(t,i,e){this.ke=null,this.an=t,this.Au=e||1,this.Tc=null,i!==void 0&&(this.Tc=i,e===void 0&&(this.Au=2))}copy(){const t=new AnimationTrigger(this.an);t.Au=this.Au;const i=this.Tc;if(i!==null){const e={};i.duration!==void 0&&(e.duration=i.duration),i.finished!==void 0&&(e.finished=i.finished),i.easing!==void 0&&(e.easing=i.easing),t.Tc=e}return t}get propertyName(){return this.an}set propertyName(t){this.an=t}get animationSettings(){return this.Tc}set animationSettings(t){this.Tc=t}xF(t){const i=this.Tc;i!==null&&(i.duration&&(t.duration=i.duration),i.finished&&(t.finished=i.finished),i.easing&&(t.easing=i.easing))}get startCondition(){return this.Au}set startCondition(t){this.Au=t}static Default=1;static Immediate=2;static Bundled=3}class Layer{p;St;Wt;Sr;Rl;vl;Ol;Il;El;Ul;Bl;Vl;zl;Xl;Kl;Yl;bc;Gl;px;vm;Tu;At;constructor(t){GSet.Yi(this),this.p=null,this.At=new List,this.St="",this.Wt=1,this.Sr=!1,this.Rl=!0,this.vl=!0,this.Ol=!0,this.Il=!0,this.El=!0,this.Ul=!0,this.Bl=!0,this.Vl=!0,this.zl=!0,this.Xl=!0,this.Kl=!0,this.Yl=!0,this.bc=!0,this.Gl=!0,this.px=!0,this.vm=!1,this.Tu=[],t&&Object.assign(this,t)}bF(){const t=this.At;for(let i=0;i0&&(h+=e+" Parts "),s>0&&(h+=s+" Nodes "),n>0&&(h+=n+" Groups "),o>0&&(h+=o+" Links "),r>0&&(h+=r+" Adornments "),t>1){const a=this.At.iterator;for(;a.next();){const c=a.value;h+=` - `+c.toString();const f=c.data;f!==null&&GSet.as(f)&&(h+=" #"+GSet.as(f)),c instanceof Node?h+=" "+Util.toString(f):c instanceof Link&&(h+=" "+Util.toString(c.fromNode)+" "+Util.toString(c.toNode))}}return i+" "+this.At.count+": "+h}findObjectAt(t,i,e){if(i===void 0&&(i=null),e===void 0&&(e=null),this.Gl===!1)return null;let s=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(s=!0);const n=Point.l(),o=this.At.r,r=o.length;for(let l=r;l--;){const h=o[l];if(s===!0&&h.Nl()===!1||!h.isVisible())continue;n.a(t),n.Ie(h.Es);let a=h.iL(n,i,e);if(a!==null&&(i!==null&&(a=i(a)),a!==null&&(e===null||e(a))))return Point.s(n),a}return Point.s(n),null}findObjectsAt(t,i,e,s){if(i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Gl===!1)return s;let n=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(n=!0);const o=Point.l(),r=this.At.r,l=r.length;for(let h=l;h--;){const a=r[h];if(n===!0&&a.Nl()===!1||!a.isVisible())continue;o.a(t),o.Ie(a.Es);let c=a;a.eL(o,i,e,s)&&(i!==null&&(c=i(c)),c!==null&&(e===null||e(c))&&s.add(c))}return Point.s(o),s}findObjectsIn(t,i,e,s,n){if(i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Gl===!1)return n;let o=!1;this.diagram!==null&&this.diagram.viewportBounds.containsRect(t)&&(o=!0);const r=this.At.r,l=r.length;for(let h=l;h--;){const a=r[h];if(o===!0&&a.Nl()===!1||!a.isVisible())continue;let c=a;a.Om(t,i,e,s,n)&&(i!==null&&(c=i(c)),c!==null&&(e===null||e(c))&&n.add(c))}return n}NP(t,i,e,s,n,o,r){if(this.Gl===!1)return n;const l=this.At.r,h=l.length;for(let a=h;a--;){const c=l[a];if(r===!0&&c.Nl()===!1||!o(c)||!c.isVisible())continue;let f=c;c.Om(t,i,e,s,n)&&(i!==null&&(f=i(f)),f!==null&&(e===null||e(f))&&n.add(f))}return n}findObjectsNear(t,i,e,s,n,o){if(e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Gl===!1)return o;let r=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(r=!0);const l=Point.l(),h=Point.l(),a=this.At.r,c=a.length;for(let f=c;f--;){const u=a[f];if(r===!0&&u.Nl()===!1||!u.isVisible())continue;l.a(t),l.Ie(u.Es),h.e(t.x+i,t.y),h.Ie(u.Es);let d=u;u.sL(l,h,e,s,n,o)&&(e!==null&&(d=e(d)),d!==null&&(s===null||s(d))&&o.add(d))}return Point.s(l),Point.s(h),o}EM(){return this.At.r}Us(t,i){if(!this.visible)return;const e=this.At.r,s=e.length;if(s===0)return;const n=Util.ot(),o=Util.ot();for(let r=0;r0&&o.push(l))}for(let r=0;re.Em||a.height*n>e.Em?i.Gi(t,e):this.SF(t,i),c&&(t.restore(),t.clearContextCache(!0))}SF(t,i){const e=i.actualBounds,s=i.naturalBounds;if(e.width===0||e.height===0||isNaN(e.x)||isNaN(e.y)||!i.isVisible())return;const n=i.D;if(i.background===null){i.dn(t,"rgba(0,0,0,0.3)",!0,!1,s,e),t.fillRect(e.x,e.y,e.width,e.height);return}if(t.transform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),i.dn(t,i.background,!0,!1,s,e),t.fillRect(0,0,s.width/2,s.height/2),!n.Ok()){const o=1/(n.m11*n.m22-n.m12*n.m21);t.transform(n.m22*o,-n.m12*o,-n.m21*o,n.m11*o,o*(n.m21*n.dy-n.m22*n.dx),o*(n.m12*n.dx-n.m11*n.dy))}}MF(t,i,e,s){const n=2/s,o=4/s;for(let r=0;r=s.count)t=s.count;else if(s.elt(t)===i)return-1;s.insertAt(t,i),i.Um(e);const n=this.diagram;return n!==null&&(e?n.C():n.Hh(i)),this.yx(t,i),t}_i(t,i,e){if(!e&&i.layer!==this&&i.layer!==null)return i.layer._i(t,i,e);const s=this.At;if(t<0||t>=s.length){if(t=s.indexOf(i),t<0)return-1}else if(s.elt(t)!==i&&(t=s.indexOf(i),t<0))return-1;i.Bm(e),s.removeAt(t);const n=this.diagram;return n!==null&&(e?n.C():n._i(i)),i.IM(null),t}yx(t,i){t=this.NF(t,i),i instanceof Group&&this.CF(t,i),i.svg!==null&&i.svg.remove()}NF(t,i){const e=i.zOrder;if(isNaN(e))return t;const s=this.At,n=s.count;if(n<=1)return t;if(t<0&&(t=s.indexOf(i)),t<0)return-1;let o=t-1,r=NaN;for(;o>=0&&(r=s.elt(o).zOrder,!!isNaN(r));)o--;let l=t+1,h=NaN;for(;le)for(;;){if(o===-1||r<=e)return o++,o===t?t:(s.removeAt(t),s.insertAt(o,i),o);for(r=NaN;--o>=0&&(r=s.elt(o).zOrder,!!isNaN(r)););}else if(!isNaN(h)&&h=e)return l--,l===t?t:(s.removeAt(t),s.insertAt(l,i),l);for(h=NaN;++l=0)||e<0&&r.containingGroup===i&&(e=o,t>=0))break}if(!(e<0)&&e1)&&Util._(t,"0 <= value <= 1",Layer,"opacity"),this.Wt=t;const e=this.diagram;e!==null&&e.C(),this.t("opacity",i,t)}}get isViewportAligned(){return this.vm}set isViewportAligned(t){const i=this.vm;i!==t&&(this.vm=t,this.diagram&&(this.oL(),this.diagram.C()),this.t("isViewportAligned",i,t),t&&(this.isInDocumentBounds=!1))}oL(){if(!this.vm)return;const t=this.diagram,i=this.At.r,e=i.length,s=t.kt,n=t.Pt;for(let o=0;o(w[w.None=1]="None",w[w.Uniform=2]="Uniform",w[w.UniformToFill=3]="UniformToFill",w))(AutoScale||{}),CycleMode=(w=>(w[w.All=1]="All",w[w.NotDirected=2]="NotDirected",w[w.NotDirectedFast=3]="NotDirectedFast",w[w.NotUndirected=4]="NotUndirected",w[w.DestinationTree=5]="DestinationTree",w[w.SourceTree=6]="SourceTree",w))(CycleMode||{}),ScrollMode=(w=>(w[w.Document=1]="Document",w[w.Infinite=2]="Infinite",w))(ScrollMode||{}),CollapsePolicy=(w=>(w[w.TreeParent=1]="TreeParent",w[w.AllParents=2]="AllParents",w[w.AnyParents=3]="AnyParents",w))(CollapsePolicy||{});class Diagram{ds;di;VM;wx;Nr;Ru;xx;bx;kx;Px;Mx;Sx;Dc;Gh;Nx;Cx;Lx;jl;Fc;Cr;Vm;Ax;Tx;vu;Hn;Lr;qh;Fo;zm;Rc;Xm;vc;Ou;Ar;qn;zM;XM;Dx;Fx;KM;Rx;YM;GM;jM;vx;Km;Tr;Dr;Fr;Rr;vr;Or;Ox;Ir;Ix;Er;Ur;Br;Vr;Ex;HM;Ro;qM;Ux;Bx;WM;Mi;JM;$M;ZM;vs;vo;Oi;Vx;Rl;vl;zx;Xx;Ol;Il;El;Kx;Ul;Bl;Vl;zl;Xl;Kl;Yl;Yx;Gx;QM;Iu;Eu;jx;Hx;qx;Wx;Ym;Jx;$x;Zx;$t;_M;Qx;tS;Uu;gn;Wn;te;Jn;rL;Hl;iS;eS;Gm;_x;Bu;jm;tb;zr;ql;Wh;sS;nS;Hm;ib;eb;ts;qm;Wm;Vu;Wl;Oc;Jm;Xr;Jh;oS;$m;Ht;D;Be;Pr;Ui;ps;rS;Jl;Kr;bl;Yr;$h;Ic;lS;zu;Zh;Xu;Gt;$l;ct;st;Ku;kt;Pt;dt;Ec;Uw;sb;Qh;Uc;nb;ob;rb;TF;DF;Bi;Pl;Em;Zm;hS;aS;lL;Qm;FF;RF;vF;lb;OF;IF;EF;_h;hL;Zl;ta;ia;ea;sa;wu;Kh;Zt;Tt;Bc;Wk;Jk;cc;Wt;static hb=null;static aL=new GMap;static cS;static fS=null;yu;ab;cb;fb;ub;db;_m;uS;t0;i0;e0;ex;dS;gb;Vc;constructor(t,i){if(Diagram.uw||(Diagram.Ik(),Diagram.uw=!0),GSet.Yi(this),Diagram.cL(this),this.Ht=!0,this.Tt=null,this.kt=0,this.Pt=0,this.dt=null,Diagram.isUsingDOM()){const s=this,n=()=>{s.Si(root.document,"DOMContentLoaded",n,!1),s.setRTL()};root.document.body!==null?this.setRTL():s.Vt(root.document,"DOMContentLoaded",n,!1)}this.Ec=null,Diagram.gS("Model",PartManager);const e=this;return this.JM=s=>e.partManager.doModelDataChanged(s),this.$M=s=>e.partManager.doModelChanged(s),this.nb=null,this.ob=null,this.fL(),this.model=Model.initDiagramModel(),this.gb=null,this.themeManager=new ThemeManager,this.Ro=!0,this.uL(),this.layout=new Layout,this.Ro=!1,this.FF=null,this.RF=null,this.vF=null,this.lb=null,this.OF=null,this.IF=null,this.EF=null,this._h=null,this.hL=null,this.Zl=null,this.ta=null,this.ia=null,this.ea=null,this.sa=null,this.wu=()=>{},this.Kh=null,this.Vu=!1,this.Bc=new DiagramHelper(this),t!==void 0&&(typeof t=="string"||root.Element&&t instanceof Element?this.mS(t):i=t),i&&this.setProperties(i),this.Ht=!1,this.requestUpdate(),this}qD(){return this.dt!==null}get renderer(){return this.Oc}set renderer(t){if(this instanceof Overview)return;t===""&&(t="default");const i=t.toLowerCase(),e=this.Oc;if(i===e)return;this.Oc=i;let s=null;i==="default"||i==="canvas"?(s=this.Wl.get("svg"),s!==null&&s.Ft.remove(),this.dt&&(this.Zt=this.dt.ai),this.Zt.clearContextCache(!0)):i==="svg"?(this.Wl.has("svg")?s=this.Wl.get("svg"):(s=new SVGSurface(this,root.document),this.addRenderer("svg",s)),this.div!==null&&this.div.appendChild(s.Ft),this.Zt=s.ai,this.dt&&(this.dt.ai.setTransform(this.Bi,0,0,this.Bi,0,0),this.dt.ai.clearRect(0,0,this.kt,this.Pt))):i==="debug"&&(this.Wl.has("SVG")||(s=new SVGSurface(this,root.document),this.addRenderer("SVG",s),s.Ft.style.backgroundColor="whitesmoke",this.div!==null&&this.div.after(s.Ft))),this.Ht||this.redraw()}fL(){this.Vc=new List,this.setupRouters(),this.ds=new AnimationManager,this.ds.To(this),this.di=17,this.VM=!1,this.Ku=!1,this.wx="default",this.Gt=new List,this.Wl=new GMap,this.Oc="default",this.resetRenderingHints(),this.UF(),this.Wt=1,this.ct=new Point(NaN,NaN).g(),this.ex=new Point(NaN,NaN),this.st=1,this.$m=1,this.xx=new Point(NaN,NaN).g(),this.bx=NaN,this.kx=1e-4,this.Px=100,this.D=new Transform,this.Mx=new Point(NaN,NaN).g(),this.Sx=new Rect(NaN,NaN,NaN,NaN).g(),this.Dc=new Margin(0,0,0,0).g(),this.Gh=1,this.Nx=!1,this.Cx=null,this.Lx=null,this.jl=1,this.Fc=Spot.Default,this.Cr=1,this.Vm=Spot.Default,this.Ax=Spot.None,this.Tx=Spot.None,this.Be=!0,this.vu=!1,this.Hn=new Set,this.Lr=new GSet,this.qh=new GSet,this.Fo=!1,this.$l=new GMap,this.zu=!0,this.zm=250,this.Rc=-1,this.Xm=new Margin(16,16,16,16).g(),this.Pr=!1,this.vc=!1,this.Ou=!0,this.Jm=new InputEvent,this.Jm.diagram=this,this.Xr=new InputEvent,this.Xr.diagram=this,this.Jh=new InputEvent,this.Jh.diagram=this,this.Ar=null,this.qn=null,this.Uw=!1,this.BF(),this.Yr=new GSet,this.Dx=!0,this.Fx=1,this.KM=!1,this.Rx=1,this.vx="auto",this.Km="auto",this.Tr=null,this.Dr=null,this.Fr=null,this.Rr=null,this.vr=null,this.Or=null,this.Ox=null,this.Ir=null,this.Ix=!1,this.Er=null,this.Ur=null,this.Br=null,this.Vr=null,this.Ex=!1,this.sb={},this.Qh=[null,null],this.Ro=!1,this.qM=!1,this.Ux=!1,this.Bx=!1,this.WM=!0,this.ps=!1,this.Zh=!1,this.ZM=!0,this.vs=-2,this.Jl=new GMap,this.Xu=new List,this.vo=!1,this.Oi=!0,this.Vx=!0,this.Rl=!0,this.vl=!0,this.zx=!1,this.Xx=!0,this.Ol=!0,this.Il=!0,this.El=!0,this.Kx=!0,this.Ul=!0,this.Bl=!0,this.Vl=!0,this.zl=!0,this.Xl=!0,this.Kl=!0,this.Yl=!0,this.Yx=!0,this.Gx=!0,this.QM=!1,this.Uc=!1,this.Iu=!0,this.Eu=!0,this.jx=!0,this.Hx=!0,this.qx=16,this.Wx=16,this.Ym=!1,this.Jx=!1,this.$x=0,this.Zx=0,this.$t=new Margin(5).g(),this._M=new GSet().g(),this.Qx=999999999,this.tS=new GSet().g(),this.$h=!0,this.Uu=!0,this.Ic=!0,this.gn=!1,this.Wn=!1,this.Kr=!0,this.bl=!1,this.Jn=!1,this.rL=new GSet,this.lS=new GSet,this.Hl=null,this.iS=new Size(8,8),this.eS=999,this.Gm=!1,this.Wk=1,this.Jk=0,this.Ui={scale:1,position:new Point,bounds:new Rect,canvasSize:new Size,newCanvasSize:new Size,isScroll:!1},this.Ui.canvasSize=this.Ui.canvasSize,this.Ui.newCanvasSize=this.Ui.newCanvasSize,this.Ui.isScroll=!1,this._x=new Rect(NaN,NaN,NaN,NaN).g(),this.Bu=new Size(NaN,NaN).g(),this.jm=new Rect(NaN,NaN,NaN,NaN).g(),this.tb=!1,this.VF(),this.ts=null,this.qm=!1,this.cc=null,this.partManager=new PartManager,this.toolManager=new ToolManager,this.toolManager.initializeStandardTools(),this.defaultTool=this.toolManager,this.currentTool=this.defaultTool,this.cb=null,this.fb=new DraggingOptions,this.ub=null,this.db=null,this.ab=!1,this.yu=!1,this.commandHandler=new CommandHandler,this.i0=null,this.e0=Point.Ak,this.dS=!1,this.Bi=1,this.Pl=null,this.Em=1,this._m=0,this.uS=[0,0,0,0,0],this.t0=0,this.Zm=1,this.hS=0,this.aS=new Point,this.lL=500,this.Wm=new Point,this.Qm=!1}static dL=root.document!==void 0;static isUsingDOM(){return Diagram.dL}static useDOM(t){Diagram.dL=t?root.document!==void 0:!1}static Ve=new WeakMap;clear(){this.animationManager.stopAnimation(),this.model.clear(),Diagram.gL(),this.mL(!1),this.Xu.clear(),this.pL(),this.Hl=null,this.invalidateDocumentBounds(),this.ensureBounds(),this.C()}mL(t){this.animationManager.stopAnimation(!0),this._M=new GSet().g(),this.tS=new GSet().g();const i=this.skipsUndoManager,e=this.Mi!==null&&this.Mi!==void 0;e&&(this.skipsUndoManager=!0);let s=null;this.ts!==null&&(s=this.ts.part,s!==null&&this.remove(s));const n=[],o=this.Gt.length;if(t){for(let r=0;rt?new Margin(t/2):1.5)),this.ib=this.Hm,this.eb=new Adornment(Panel.Link).add(new Shape({isPanelMain:!0,fill:null,stroke:"dodgerblue",strokeWidth:3}).theme("stroke","selection").theme("strokeWidth","selection"))}setRTL(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);const e=Util.en("div");e.dir="rtl",e.style.cssText="font-size: 14px; width: 1px; height: 1px; position: absolute; top: -1000px; overflow: scroll;",e.textContent="A",i.appendChild(e);let s="reverse";e.scrollLeft>0?s="default":(e.scrollLeft=1,e.scrollLeft===0&&(s="negative")),i.removeChild(e),this.wx=s}setScrollWidth(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);let e=0;if(Diagram.isUsingDOM()){let s=Diagram.fS,n=Diagram.cS;s===null&&(Diagram.fS=Util.en("p"),s=Diagram.fS,s.style.width="100%",s.style.height="200px",s.style.boxSizing="content-box",Diagram.cS=Util.en("div"),n=Diagram.cS,n.style.position="absolute",n.style.visibility="hidden",n.style.width="200px",n.style.height="150px",n.style.boxSizing="content-box",n.appendChild(s)),n.style.overflow="hidden",i.appendChild(n);const o=s.offsetWidth;n.style.overflow="scroll";let r=s.offsetWidth;o===r&&(r=n.clientWidth),i.removeChild(n),e=o-r,e===0&&!Util.rr&&(e=11)}this.di=e,this.VM=!0}ri(t){t in AutoScale?this.autoScale=t:Util.lr(this,t)}toString(t){t===void 0&&(t=0);let i="";this.div&&this.div.id&&(i=this.div.id);let e='Diagram "'+i+'"';if(t<=0)return e;const s=this.Gt.iterator;for(;s.next();){const n=s.value;e+=` - `+n.toString(t-1)}return e}static cL(t){Diagram.hb=t}static pm(){return Diagram.hb}static fromDiv(t){let i=t;if(typeof t=="string"&&(i=root.document.getElementById(t)),i instanceof HTMLDivElement){const e=Diagram.Ve.get(i);if(e)return e}return null}get div(){return this.Tt}set div(t){if(this.Tt!==t){const i=this.Tt;if(i!==null){if(Diagram.Ve.delete(i),i.goDiagram=void 0,i.go=void 0,i.innerHTML="",this.dt!==null){const s=this.dt.Ft;this.Si(s,"pointermove",this.ta,!1),this.Si(s,"pointerdown",this.Zl,!1),this.Si(s,"pointerup",this.ia,!1),this.Si(s,"pointerout",this.ea,!1),this.Si(s,"pointercancel",this.sa,!1),this.dt.dispose()}this.Ec&&(this.Ec.disconnect(),this.Ec=null);const e=this.toolManager;e!==null&&(e.mouseDownTools.each(s=>s.cancelWaitAfter()),e.mouseMoveTools.each(s=>s.cancelWaitAfter()),e.mouseUpTools.each(s=>s.cancelWaitAfter())),e.cancelWaitAfter(),this.currentTool.doCancel(),this.dt=null,this.Si(root,"resize",this.lb,!1),this.Si(root,"wheel",this._h,!0),Diagram.pm()===this&&Diagram.cL(null)}else this.Zl===null&&(this.Jn=!1);if(this.Tt=null,t!==null){const e=Diagram.Ve.get(t);e&&(e.div=null),this.mS(t),this.wu(),this.themeManager&&this.themeManager.zF()}else this.themeManager&&this.themeManager.XF()}}setupRouters(){this.Vc.push(new AvoidsNodesRouter)}mS(t){const i=this;if(!Diagram.isUsingDOM())return;t==null&&Util.o("Diagram setup requires an argument DIV."),i.Tt!==null&&Util.o("Diagram has already completed setup."),typeof t=="string"?i.Tt=root.document.getElementById(t):t instanceof HTMLDivElement?i.Tt=t:Util.o("No DIV or DIV id supplied: "+t),i.Tt===null&&Util.o("Invalid DIV id; could not get element with id: "+t);const e=Diagram.Ve.get(i.Tt);if(e&&e!==this&&Util.o("Invalid div id; div already has a Diagram associated with it."),!i.Ec&&root.ResizeObserver){const c=root.ResizeObserver,f=Util.Nk(()=>i.requestUpdate(),250,!1);i.Ec=new c(()=>f()),i.Ec.observe(i.Tt)}root.getComputedStyle(i.Tt,null).position==="static"&&(i.Tt.style.position="relative");let s=5;const n="rgba(2"+s+"5, 255, 255, 0)";s--,i.Tt.style["-webkit-tap-highlight-color"]=n,i.Tt.innerHTML="",Diagram.Ve.set(i.Tt,i),i.Tt.goDiagram=i,i.Tt.go=root.go;const o=new CanvasSurface(i);o.style!==void 0&&(o.style.position="absolute",o.style.top="0px",o.style.left="0px",root.getComputedStyle(i.Tt,null).getPropertyValue("direction")==="rtl"&&(i.Ku=!0),o.style.zIndex="2",o.style.userSelect="none",o.style.MozUserSelect="none",o.style.touchAction="none",o.style.letterSpacing="normal !important",o.style.wordSpacing="normal !important",o.style.lang="unknown"),i.dt=o,i.Zt=o.ai;const r=i.Zt;i.Bi=i.computePixelRatio(),i.viewSize.isReal()||(i.kt=i.Tt.clientWidth||1,i.Pt=i.Tt.clientHeight||1),i.yL(i.kt,i.Pt);const l=i;i.Tt.insertBefore(o.Ft,i.Tt.firstChild);const h=new CanvasSurface(null);if(h.width=1,h.height=1,i.TF=h,i.DF=h.ai,Diagram.isUsingDOM()){const c=Util.en("div"),f=Util.en("div");c.style.position="absolute",c.style.overflow="auto",c.style.width=i.kt+"px",c.style.height=i.Pt+"px",c.style.zIndex="1",f.style.position="absolute",f.style.width="1px",f.style.height="1px",i.Tt.appendChild(c),c.appendChild(f),c.onscroll=Diagram.KF,c.addEventListener("pointerdown",Diagram.YF),c.p=i,c.GF=!0,c.jF=!0,i.nb=c,i.ob=f}i.wu=Util.Nk(()=>{i.Pl=null,i.C()},300,!1),i.lb=Util.Nk(()=>{i.SM()},250,!1),i.Kh=c=>(c.preventDefault(),!1),i._h=c=>{if(!l.isEnabled)return;const f=l.zc(c,!0);f.bubbles=!0;let u=0,d=0;f.delta=0,c.deltaX!==void 0?(c.deltaX!==0&&(u=c.deltaX>0?1:-1),c.deltaY!==0&&(d=c.deltaY>0?1:-1),f.delta=Math.abs(c.deltaX)>Math.abs(c.deltaY)?-u:-d):c.wheelDeltaX!==void 0?(c.wheelDeltaX!==0&&(u=c.wheelDeltaX>0?-1:1),c.wheelDeltaY!==0&&(d=c.wheelDeltaY>0?-1:1),f.delta=Math.abs(c.wheelDeltaX)>Math.abs(c.wheelDeltaY)?-u:-d):c.wheelDelta!==void 0&&c.wheelDelta!==0&&(f.delta=c.wheelDelta>0?1:-1),l.doMouseWheel(),l.na(f,c)},i.hL=c=>{if(!l.isEnabled)return;i.Uc=!1,l.zc(c,!0);const f=l.currentTool;f.cancelWaitAfter(),f.standardMouseOver()},i.Zl=c=>{if(!l.isEnabled)return;i.Uc=!0;const f=l.sb;f[c.pointerId]===void 0&&(f[c.pointerId]=c);const u=l.Qh;let d=!1;if(u[0]!==null&&(u[0].pointerId===c.pointerId||u[0].pointerType!==c.pointerType))u[0]=c;else if(u[1]!==null&&u[1].pointerId===c.pointerId)u[1]=c,d=!0;else if(u[0]===null)u[0]=c;else if(u[1]===null)u[1]=c,d=!0;else{c.preventDefault();return}const m=c.pointerType==="touch"||c.pointerType==="pen";m&&(l.Uw=!1,l.Qm=!0);const g=l.HF(c,c,d),p=l.aS,y=m?25:10;if(c.timeStamp-l.hSy||Math.abs(p.y-c.screenY)>y)?l.Zm++:l.Zm=1,g.clickCount=l.Zm,l.hS=c.timeStamp,l.aS.setTo(c.screenX,c.screenY),l.doMouseDown(),c.button===1){c.preventDefault();return}l.na(g,c)},i.ta=c=>{if(!l.isEnabled)return;i.Uc=!0;const f=l.Qh;if(f[0]!==null&&(f[0].pointerId===c.pointerId||f[0].pointerType!==c.pointerType))f[0]=c;else if(f[1]!==null&&f[1].pointerId===c.pointerId){f[1]=c;return}else if(f[0]===null)f[0]=c;else return;if(f[0].pointerId!==c.pointerId)return;const u=l.qF(c,c,f[1]!==null);l.doMouseMove(),l.na(u,c)},i.ia=c=>{if(!l.isEnabled)return;i.Uc=!0;const f=c.pointerType==="touch"||c.pointerType==="pen",u=l.sb;if(f&&l.Uw){delete u[c.pointerId],c.preventDefault();return}const d=l.Qh;if(d[0]!==null&&(d[0].pointerId===c.pointerId||d[0].pointerType!==c.pointerType))d[0]=null;else if(d[1]!==null&&d[1].pointerId===c.pointerId){d[1]=null;return}else return;const m=l.pS(c,!1,!0,!1,!0,!1);let g=root.document.elementFromPoint(c.clientX,c.clientY)||null;g!==null&&g.shadowRoot!==void 0&&g.shadowRoot!==null&&(g=g.shadowRoot.elementFromPoint(c.clientX,c.clientY)),g!==null&&g.p instanceof Diagram&&g.p!==l&&g.p.o0(c,m),g===null&&(g=c.target),l.o0(c,m),m.clickCount=l.Zm,m.targetDiagram=l.yS(c,g),m.targetObject=null,l.doMouseUp(),l.na(m,c),f&&(l.Qm=!1)},i.ea=c=>{if(!l.isEnabled)return;i.Uc=!1;const f=l.sb;f[c.pointerId]&&delete f[c.pointerId];const u=l.Qh;if(u[0]!==null&&u[0].pointerId===c.pointerId&&(u[0]=null),u[1]!==null&&u[1].pointerId===c.pointerId&&(u[1]=null),c.pointerType==="touch"||c.pointerType==="pen")return;const d=l.currentTool;d.cancelWaitAfter(),d.standardMouseOver()},i.sa=c=>{const f=l.Qh;f[0]!==null&&f[0].pointerId===c.pointerId?(f[0]=null,l.Qm=!1):f[1]!==null&&f[1].pointerId===c.pointerId&&(f[1]=null)};const a=r;if(i.rb=a.B[Util.Cs("7eba17a4ca3b1a8346")][Util.Cs("78a118b7")](a.B,Diagram.Yu,s,s),r.clearContextCache(!0),i.WF(),this.Oc==="svg"){const c=this.Wl.get("svg");this.Tt.appendChild(c.Ft),this.Zt=c.ai}}addEventListener(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}Vt(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}removeEventListener(t,i,e,s){t.removeEventListener(i,e,{capture:s})}Si(t,i,e,s){t.removeEventListener(i,e,{capture:s})}WF(){const t=this;let i=this.dt.Ft;i instanceof HTMLCanvasElement||(i=t.div),this.Vt(i,"pointerdown",t.Zl,!1),this.Vt(i,"pointermove",t.ta,!1),this.Vt(i,"pointerup",t.ia,!1),this.Vt(i,"pointerout",t.ea,!1),this.Vt(i,"pointercancel",t.sa,!1),this.Vt(i,"pointerenter",t.JF,!1),this.Vt(i,"pointerleave",t.$F,!1),this.Vt(i,"wheel",t._h,!1),this.Vt(i,"keydown",t.ZF,!1),this.Vt(i,"keyup",t.QF,!1),this.Vt(i,"blur",t._F,!1),this.Vt(i,"focus",t.tR,!1),this.Vt(i,"selectstart",e=>(e.preventDefault(),!1),!1),this.Vt(i,"contextmenu",e=>(e.preventDefault(),!1),!1),this.Vt(root,"resize",t.lb,!1)}Bw(){this._m>30&&(this.Pl=1)}yP(t){this.Pl!==null&&(this.Pl=null,t&&this.wu(),this._m=0,this.uS=[0,0,0,0,0],this.t0=0)}computePixelRatio(){return this.Pl!==null?this.Pl:root.devicePixelRatio||1}get avgSpf(){return this._m}doMouseDown(){this.currentTool.doMouseDown()}doMouseMove(){this.currentTool.doMouseMove()}doMouseUp(){this.currentTool.doMouseUp()}doMouseWheel(){this.currentTool.doMouseWheel()}doKeyDown(){this.currentTool.doKeyDown()}doKeyUp(){this.currentTool.doKeyUp()}doFocus(){this.focus()}focus(){if(this.dt)if(this.scrollsPageOnFocus)this.dt.focus();else{const t=root.scrollX,i=root.scrollY;this.dt.focus(),root.scrollTo(t,i)}}tR(t){const i=Diagram.Ve.get(this);i&&i.v("GainedFocus")}_F(t){const i=Diagram.Ve.get(this);i&&i.v("LostFocus")}SM(){if(this.dt===null)return;const i=this.Tt;if(i===null||i.clientWidth===0||i.clientHeight===0)return;this.VM||this.setScrollWidth();const e=this.Wn?this.di:0,s=this.gn?this.di:0,n=this.Bi;if(this.Bi=this.computePixelRatio(),this.Bi!==n&&(this.vu=!0,this.requestUpdate()),i.clientWidth!==this.kt+e||i.clientHeight!==this.Pt+s){this.oa(),this.Be=!0;const o=this.layout;o!==null&&o.isViewportSized&&this.autoScale===1&&(this.vc=!0,o.invalidateLayout()),this.ps||this.requestUpdate()}}uL(){let t=0,i=new Layer;i.name="Grid",i.allowSelect=!1,i.pickable=!1,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="ViewportBackground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="Background",this.Gr(i,t++),i=new Layer,i.name="",this.Gr(i,t++),i=new Layer,i.name="Foreground",this.Gr(i,t++),i=new Layer,i.name="ViewportForeground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="Adornment",i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="Tool",i.isTemporary=!0,i.isInDocumentBounds=!0,this.Gr(i,t++)}wL(){const t=new Panel(Panel.Grid,{name:"GRID"}).add(new Shape("LineH",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineV",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineH",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineH",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor")),i=new Part({layerName:"Grid",zOrder:0,isInDocumentBounds:!1,isAnimated:!1,pickable:!1,locationObjectName:"GRID"}).add(t);return this.add(i),this.partManager.parts.delete(i),t.visible=!1,t}static KF(){const t=Diagram.Ve.get(this.parentElement||this);if(t){if(t.Jx){t.Jx=!1;return}if(!t.isEnabled){t.xL();return}t.diagramScroll(this)}}static YF(t){if(!this.p.isEnabled){this.p.updateScroll();return}this.p.$x=t.target.scrollTop,this.p.Zx=t.target.scrollLeft}diagramScroll(t){if(this.dt===null)return;const i=this.nb,e=this.ob;this.Ym=!0;let s=this.documentBounds,n=this.viewportBounds;const o=this.Dc;let r=s.x-o.left,l=s.y-o.top;const h=s.width+o.left+o.right,a=s.height+o.top+o.bottom;let c=s.right+o.right,f=s.bottom+o.bottom,u=n.x,d=n.y;const m=n.width,g=n.height;let p=n.right,y=n.bottom;const x=this.scale;let k,b=t.scrollLeft;if(this.Ku)switch(this.wx){case"negative":b=b+t.scrollWidth-t.clientWidth;break;case"reverse":b=t.scrollWidth-b-t.clientWidth;break}const P=b;if(mp)){const M=i.scrollWidth-this.kt;this.position=k.e(-M+P-this.kt/x+c,this.position.y)}if(t.jF&&this.allowVerticalScroll&&(ly)){const M=i.scrollHeight-this.Pt;this.position=k.e(this.position.x,-M+t.scrollTop-this.Pt/x+f)}Point.s(k),this._l(),this.Ym=!1,this.Uu=!1,s=this.documentBounds,n=this.viewportBounds,c=s.right,p=n.right,f=s.bottom,y=n.bottom,r=s.x,u=n.x,l=s.y,d=n.y,m>=h&&r>=u&&c<=p&&(e.style.width="1px"),g>=a&&l>=d&&f<=y&&(e.style.height="1px")}computeBounds(t){return t===void 0&&(t=new Rect),this.Ci(),this.bL(t)}bL(t){if(this.fixedBounds.isReal())return t.a(this.fixedBounds),t.addMargin(this.$t),t;let i=!0;const e=this.Gt.r,s=e.length;for(let n=0;ni&&(a=i),athis.maxScale&&(a=this.maxScale),a):t===3?(a=0,h>l?a=(r-this.di)/n:a=(o-this.di)/s,a>i&&(a=i),athis.maxScale&&(a=this.maxScale),a):this.scale}zoomToFit(){const t=this.Gh;this.Gh=1,this.scale=this.Gu(2),t!==1&&(this.Bs(!1),this.wS(this.documentBounds,this.kt/this.st,this.Pt/this.st,this.Fc,!1)),this.Gh=t}zoomToRect(t,i){i===void 0&&(i=2);const e=t.width,s=t.height;if(e===0||s===0||isNaN(e)&&isNaN(s))return;let n=1;if(i===2||i===3)if(isNaN(e))n=this.viewportBounds.height*this.scale/s;else if(isNaN(s))n=this.viewportBounds.width*this.scale/e;else{const o=this.kt,r=this.Pt;i===3?r/s>o/e?n=(r-(this.gn?this.di:0))/s:n=(o-(this.Wn?this.di:0))/e:n=Math.min(r/s,o/e)}this.scale=n,this.position=new Point(t.x,t.y)}get iR(){return this.Ht}set iR(t){this.Ht=t}alignDocument(t,i){this.ensureBounds();const e=this.documentBounds,s=this.viewportBounds;this.position=new Point(e.x+(t.x*e.width+t.offsetX)-(i.x*s.width-i.offsetX),e.y+(t.y*e.height+t.offsetY)-(i.y*s.height-i.offsetY))}focusObject(t){if(t instanceof GraphObject){this.i0=t;const i=Point.l();this.e0=this.transformDocToView(t.getDocumentPoint(Spot.TopLeft,i)),Point.s(i)}else this.i0=null,this.e0=Point.Ak}wS(t,i,e,s,n){const o=Point.X(this.ct.x,this.ct.y);let r=o.x,l=o.y;if(this.i0!==null){let h=Point.l();h=this.i0.getDocumentPoint(Spot.TopLeft,h),r=h.x-this.e0.x/this.scale,l=h.y-this.e0.y/this.scale,s=Spot.None,Point.s(h)}if(n||this.scrollMode===1){s.isSpot()&&(i>t.width&&(r=t.x+(s.x*t.width+s.offsetX)-(s.x*i-s.offsetX)),e>t.height&&(l=t.y+(s.y*t.height+s.offsetY)-(s.y*e-s.offsetY)));const h=this.Dc,a=i-t.width;if(it.left?r=t.left:rt.top?l=t.top:ls.part,s=>s.canSelect());if(e instanceof Part)return e}else{const e=this.PP(t,s=>s.part);if(e instanceof Part)return e}return null}findObjectAt(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Ci();const s=this.Gt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}PP(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Ci();const s=this.Gt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible||n.isTemporary)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}findPartsAt(t,i,e){return i===void 0&&(i=!0),this.sR(t,s=>s.part,i?s=>s instanceof Part&&s.canSelect():null,e)}sR(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Ci();const n=this.Gt.iteratorBackwards;for(;n.next();){const o=n.value;!o.visible||o.isTemporary||o.findObjectsAt(t,i,e,s)}return s}findObjectsAt(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Ci();const n=this.Gt.iteratorBackwards;for(;n.next();){const o=n.value;o.visible&&o.findObjectsAt(t,i,e,s)}return s}findPartsIn(t,i,e,s){return i===void 0&&(i=!1),e===void 0&&(e=!0),this.nR(t,null,n=>n instanceof Part&&(!e||n.canSelect()),i,s)}findObjectsIn(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Ci();const o=this.Gt.iteratorBackwards;for(;o.next();){const r=o.value;r.visible&&r.findObjectsIn(t,i,e,s,n)}return n}NP(t,i,e,s,n,o){const r=new GSet;this.Ci();const l=this.Gt.iteratorBackwards;for(;l.next();){const h=l.value;h.visible&&h.NP(t,i,e,s,r,n,o)}return r}nR(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Ci();const o=this.Gt.iteratorBackwards;for(;o.next();){const r=o.value;!r.visible||r.isTemporary||r.findObjectsIn(t,i,e,s,n)}return n}findPartsNear(t,i,e,s,n){return e===void 0&&(e=!0),s===void 0&&(s=!0),this.oR(t,i,null,o=>o instanceof Part&&(!s||o.canSelect()),e,n)}findObjectsNear(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Ci();const r=this.Gt.iteratorBackwards;for(;r.next();){const l=r.value;l.visible&&l.findObjectsNear(t,i,e,s,n,o)}return o}oR(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Ci();const r=this.Gt.iteratorBackwards;for(;r.next();){const l=r.value;!l.visible||l.isTemporary||l.findObjectsNear(t,i,e,s,n,o)}return o}acceptEvent(t){return this.zc(t,t instanceof MouseEvent)}zc(t,i){const e=this.Xr;this.Xr=this.Jh,this.Jh=e,e.diagram=this,e.event=t,i?this.o0(t,e):(e.viewPoint=this.Xr.viewPoint,e.documentPoint=this.Xr.documentPoint);let s=0;const n=t;return n.ctrlKey&&(s+=1),n.altKey&&(s+=2),n.shiftKey&&(s+=4),n.metaKey&&(s+=8),e.modifiers=s,e.button=n.button,n.buttons!==void 0&&(e.buttons=n.buttons),Util.rr&&n.button===0&&n.ctrlKey&&(e.button=2),e.down=!1,e.up=!1,e.clickCount=1,e.delta=0,e.handled=!1,e.bubbles=!1,e.timestamp=t.timeStamp,e.isMultiTouch=!1,e.targetDiagram=this.yS(t,t.target),e.targetObject=null,e}yS(t,i){if(i===null)return null;const e=Diagram.Ve.get(i);if(e)return e;let s=t.path;if(!s&&typeof t.composedPath=="function"&&(s=t.composedPath()),s&&s[0]){const n=Diagram.Ve.get(s[0]);if(n)return n}return null}HF(t,i,e){const s=this.pS(t,!0,!1,!1,!0,e);return this.o0(i,s),s.targetDiagram=this.yS(t,t.target),s.targetObject=null,e||s.clone(this.Jm),s}qF(t,i,e){const s=this.pS(t,!1,!1,!1,!1,e);let n=root.document.elementFromPoint(i.clientX,i.clientY)||null;n!==null&&n.shadowRoot!==void 0&&n.shadowRoot!==null&&(n=n.shadowRoot.elementFromPoint(i.clientX,i.clientY));let o=this,r=t;if(n){const l=Diagram.Ve.get(n);l&&(r=i,o=l)}return s.targetDiagram=o,this.o0(r,s),s.targetObject=null,s}pS(t,i,e,s,n,o){const r=this.Xr;this.Xr=this.Jh,this.Jh=r,r.diagram=this,r.clickCount=1,r.delta=0;let l=0;return t.ctrlKey&&(l+=1),t.altKey&&(l+=2),t.shiftKey&&(l+=4),t.metaKey&&(l+=8),r.modifiers=l,r.event=t,r.timestamp=t.timeStamp,r.button=e?this.firstInput.button:t.button,r.buttons=t.buttons,Util.rr&&t.button===0&&t.ctrlKey&&(r.button=2),r.down=i,r.up=e,r.handled=s,r.bubbles=n,r.isMultiTouch=o,r}na(t,i){return t.bubbles?!0:(i.stopPropagation!==void 0&&i.stopPropagation(),i.cancelable!==!1&&i.preventDefault(),i.cancelBubble=!0,!1)}ZF(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.zc(t,!1);return e.key=t.key,e.code=t.code,e.down=!0,i.doKeyDown(),i.na(e,t)}QF(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.zc(t,!1);return e.key=t.key,e.code=t.code,e.up=!0,i.doKeyUp(),i.na(e,t)}JF(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.zc(t,!0);return i.mouseEnter!==null&&i.mouseEnter(e),i.currentTool.standardMouseOver(),i.na(e,t)}$F(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.zc(t,!0);return i.mouseLeave!==null&&i.mouseLeave(e),i.na(e,t)}getMouse(t){const i=this.dt;if(i===null)return new Point(0,0);const e=i.getBoundingClientRect(),s=(t.clientX-e.left)*(this.kt/e.width),n=(t.clientY-e.top)*(this.Pt/e.height);return new Point(s,n).Ie(this.D)}o0(t,i){const e=this.dt;let s=0,n=0;if(e!==null){const r=e.getBoundingClientRect();s=(t.clientX-r.left)*(this.kt/r.width),n=(t.clientY-r.top)*(this.Pt/r.height)}i.viewPoint.e(s,n);const o=Point.X(s,n);this.D._e(o),i.documentPoint.a(o),Point.s(o)}MC(t,i,e){let s;if(this.Qh[0]!==null)s=this.Qh[i];else return;const n=this.dt;if(n!==null){const o=n.getBoundingClientRect();e.e((s.clientX-o.left)*(this.kt/o.width),(s.clientY-o.top)*(this.Pt/o.height))}}invalidateDocumentBounds(){this.$h||(this.$h=!0,this.requestUpdate(!1))}rR(){this.ps||this.Ci(),this.ensureBounds()}redraw(){this.Ht||this.ps||(this.C(),this.maybeUpdate())}isUpdateRequested(){return this.Pr}delayInitialization(t){t===void 0&&(t=null);const i=this.animationManager,e=i.isEnabled;i.stopAnimation(),i.isEnabled=!1,this.yr(),this.Jn=!1,this.ex=new Point(NaN,NaN),i.isEnabled=e,this.ps=!0;const s=this;t!==null&&Util.vh(()=>{s.ps=!1,i.Fl("Model"),t(s)},1)}requestUpdate(t){if(t===void 0&&(t=!1),this.Pr===!0||this.Ht||t===!1&&this.ps)return;this.Pr=!0;const i=this;root.requestAnimationFrame(()=>{i.Pr&&i.maybeUpdate()})}maybeUpdate(){this.Ou&&!this.Pr||(this.Ou&&(this.Ou=!1),this.yr())}xS(t,i){!this.Uu||this.Ht||this.animationManager.defaultAnimation.isAnimating||this.xL()||(t&&this.Ci(),i&&this.Bs(!1))}yr(t){if(this.ps||(this.Pr=!1,this.Tt===null&&!this.Bu.isReal()))return;this.ps=!0;const i=this.animationManager,e=this.Xu;if(!i.isAnimating&&e.length!==0){const c=e.r,f=c.length;for(let u=0;u0&&(s.each(c=>c.bS()),s.clear());let n=!1,o=!1;i.defaultAnimation.isAnimating&&(o=!0,n=this.skipsUndoManager,this.skipsUndoManager=!0),i.wi||this.SM(),t||this.xS(!1,!0);const r=!this.undoManager.isUndoingRedoing&&(this.bl||this.Vc.count!==0&&this.Lr.size!==0),l=!this.Jn||this.Kr;this.Ci(!0);let h=!1;(l||r)&&(this.Jn?this.kS(!this.vc,r):(this.startTransaction("Initial Layout"),i.isEnabled===!1&&i.stopAnimation(),this.kS(!1,r)),h=l),this.vc=!1,this.bl=!1,this.Ci(),this.ts!==null&&(this.ts.visible&&!this.qm&&(this.jr(),this.qm=!0),!this.ts.visible&&this.qm&&(this.qm=!1)),this.Ux||this.rR(),t||this.xS(!0,!1);let a=!1;if(h){const c=Rect.l();c.a(this.viewportBounds),this.Jn||(this.Jn=!0,a=!0,this.skipsUndoManager||(this.undoManager.Ow=!0),this.undoManager.Iw=!0,this.lR()),this.hR(),this.Ci(!1),t||this.xS(!0,!0),Rect.s(c)}else if(i.Pc&&i.ix){if(this.Cr!==1)this.scale=this.Gu(this.Cr);else if(this.jl!==1)this.scale=this.Gu(this.jl);else{const c=this.initialScale;isFinite(c)&&c>0&&(this.scale=c)}this.Bs(!0)}h&&a&&this.commitTransaction("Initial Layout"),t||this.Gi(this.Zt),o&&(this.skipsUndoManager=n),this.ps=!1}get Eh(){return this.Jn}lR(){if(this.Cr!==1)this.scale=this.Gu(this.Cr);else if(this.jl!==1)this.scale=this.Gu(this.jl);else{const i=this.initialScale;isFinite(i)&&i>0&&(this.scale=i)}this.Bs(!0);const t=this.Gt.r;this.Us(t,t.length,this,this.viewportBounds),this.v("InitialLayoutCompleted"),this.ex.a(this.ct),this.jr()}hR(){this.v("LayoutCompleted")}r0(t){this.Hn.add(t)}addInvalidRoute(t){this.Fo?this.qh.add(t):this.Lr.add(t)}Ci(t){if(this.Hn.size!==0&&!(!this.ps&&this.animationManager.isTicking)){if(this.ps||(this.bl=!0),t){this.kL(this.Hn);return}for(let i=0;i<23&&this.Hn.size!==0;i++){const e=new Set(this.Hn);this.Hn.clear(),this.bS(e,this.Hn)}this.nodes.each(i=>{i instanceof Group&&i.PL(!1)})}}kL(t,i){for(const e of t)!e.Pe()||e instanceof Group||(e.Hr()?(e.ut(1/0,1/0),e.zt()):i&&i.add(e));for(const e of t)if(e instanceof Group){if(!e.isVisible())continue;this.yb(e)}}bS(t,i){this.kL(t,i);for(const e of t){if(!(e instanceof Link))continue;const s=e;s.isVisible()&&(s.Hr()?(s.ut(1/0,1/0),s.zt()):i.add(s))}for(const e of t)e instanceof Adornment&&e.isVisible()&&(e.Hr()?(e.ut(1/0,1/0),e.zt()):i.add(e))}l0(t){const i=t instanceof Diagram,e=i?t.links:t.memberParts,s=this.Hn;if(i)this.Ci(!0);else{for(;e.next();){const n=e.value;s.has(n)&&(!n.Pe()||n instanceof Group||n.Hr()&&(n.ut(1/0,1/0),n.zt()))}for(e.reset();e.next();){const n=e.value;if(s.has(n)&&n instanceof Group){if(!n.isVisible())continue;this.yb(n)}}e.reset()}for(;e.next();){const n=e.value;n instanceof Link&&s.has(n)&&n.isVisible()&&n.Hr()&&(n.ut(1/0,1/0),n.zt())}}yb(t){const i=Util.ot(),e=Util.ot(),s=t.memberParts;for(;s.next();){const o=s.value;o.isVisible()&&(o instanceof Group?(o.Oo()||o.is()||o.th())&&this.yb(o):o instanceof Link?o.fromNode===t||o.toNode===t?e.push(o):i.push(o):(o.ut(1/0,1/0),o.zt()))}let n=i.length;for(let o=0;ob.Fu())}else for(let x=0;x0){const a=n.substring(0,h);e?o=t.findObject(a):(o=t[a],o==null&&(o=t.toolManager[a])),Util.wt(o)?r=n.substring(h+1):Util.o("Unable to find object named: "+a+" in "+t.toString()+" when trying to set property: "+n)}}if(r[0]!=="_"&&!Util.fw(o,r))if(s&&r==="ModelChanged"){t.addModelChangedListener(i[r]);continue}else if(s&&r==="Changed"){t.addChangedListener(i[r]);continue}else if(s&&Util.fw(t.toolManager,r))o=t.toolManager;else if(s&&t.ML(r)){t.addDiagramListener(r,i[r]);continue}else if(t instanceof Model&&r==="Changed"){t.addChangedListener(i[r]);continue}else Util.o('Trying to set undefined property "'+r+'" on object: '+o.toString());const l=i[n];o[r]=l,r[0]==="_"&&o instanceof GraphObject&&o.addCopyProperty(r)}}fR(){if(this.$l.count!==0&&!(this.undoManager.transactionLevel>1)){for(;this.$l.count>0;){const t=this.$l;this.$l=new GMap;const i=t.iterator;for(;i.next();){const e=i.key;e.invalidateOtherJumpOvers(i.value),e.ie()}}this.C()}}C(t){if(t===void 0)this.Be=!0,this.requestUpdate();else{const i=this.viewportBounds;t.isReal()&&i.intersectsRect(t)&&(this.Be=!0,this.requestUpdate())}this.v("InvalidateDraw")}invalidateViewport(t,i){if(this.Be===!0)return;if(this.Be=!0,this.Oc==="svg"){this.maybeUpdate();return}this.getRenderingHint("temporaryPixelRatio")===!0?(this.Bw(),this.maybeUpdate(),this.yP(!0)):this.maybeUpdate()}oa(){this.Uu=!0}_l(){this.Ic=!0}h0(){this.vu!==!1&&(this.vu=!1,this.yL(this.kt,this.Pt))}yL(t,i){this.Ql();const e=this.Bi,s=t*e,n=i*e;this.dt.resize(s,n,t,i)&&(this.Be=!0,this.Zt.clearContextCache(!0))}xL(){const t=this.dt;if(t===null||this.Bu.isReal())return!0;const i=this.kt,e=this.Pt,s=this.Tt;let n=!1,o=this.Wn?this.di:0,r=this.gn?this.di:0,l=s.clientWidth||i+o,h=s.clientHeight||e+r;const a=this.viewportBounds,c=a.x,f=a.y,u=a.width,d=a.height;if((l!==i+o||h!==e+r)&&(this.Wn=!1,this.gn=!1,o=0,r=0,this.kt=l,this.Pt=h,this.vu=!0,n=!0,this.Ql()),!this.Jn||!this.viewportBounds.isReal())return!0;const m=this.nb,g=this.ob;if(this.Uu=!1,!n&&!this.Wn&&!this.gn&&!this.Iu&&!this.Eu)return!0;const p=this.documentBounds;let y=0,x=0,k=0,b=0;const P=a.width,M=a.height,L=this.Dc;this.contentAlignment.isSpot()?(p.width>P&&(y=L.left,x=L.right),p.height>M&&(k=L.top,b=L.bottom)):(y=L.left,x=L.right,k=L.top,b=L.bottom);const C=p.width+y+x,S=p.height+k+b,N=this.scale,T=N;let A=C>l/N,D=S>h/N;if(!n&&!this.Wn&&!this.gn&&!A&&!D)return!0;const F=p.x-y,R=a.x,v=p.right+x;let O=a.right+o;const U=p.y-k,X=a.y,E=p.bottom+b;let V=a.bottom+r,B="1px",Y="1px";if(this.scrollMode===1&&(A||D)){if(A&&this.hasHorizontalScrollbar&&this.allowHorizontalScroll){let z=1;F+1O+1&&(z=Math.max((v-O)*N+this.kt,z)),P+o+1V+1&&(z=Math.max((E-V)*N+this.Pt,z)),M+r+1O+1&&(W=Math.max((v-O)*N+this.kt,W)),P+1V+1&&(W=Math.max((E-V)*N+z,W)),M+1O+1&&(J=this.position.x*N)),this.Ku)switch(this.wx){case"negative":J=-(m.scrollWidth-J-m.clientWidth);break;case"reverse":J=m.scrollWidth-J-m.clientWidth;break}if(m.scrollLeft=J,this.hasVerticalScrollbar&&this.allowVerticalScroll&&(M+1V+1&&(m.scrollTop=this.position.y*N)),l=this.kt,h=this.Pt,m.style.width=l+(this.Wn?this.di:0)+"px",m.style.height=h+(this.gn?this.di:0)+"px",i!==l||e!==h||this.animationManager.wi){const z=Rect.X(c,f,u,d);return this.onViewportBoundsChanged(z,this.viewportBounds,T,n),Rect.s(z),!1}return!0}add(t){const i=t.diagram;if(i===this)return;i!==null&&Util.o("Cannot add part "+t.toString()+" to "+this.toString()+". It is already a part of "+i.toString());let e=this.findLayer(t.layerName);if(e===null&&(e=this.findLayer("")),e===null&&Util.o('Cannot add a Part when unable find a Layer named "'+t.layerName+'" and there is no default Layer'),t.layer===e)return;const s=e.Hh(99999999,t,t.diagram===this);s>=0&&this.raiseChangedEvent(3,"parts",e,null,t,null,s),e.isTemporary||this.invalidateDocumentBounds(),t.invalidateLayout(1);const n=t.layerChanged;n!==null&&n(t,null,e)}Hh(t){this.partManager.Hh(t);const i=this;t.qr(s=>i.SL(s)),t.data||t.Io(),t.hasPlaceholder()&&t.c(),t.data!==null&&t.qr(s=>i.partManager.MS(s,null)),(t.is()===!0||t.th()===!0)&&this.r0(t),t.NL(!0,this),t.CL()?(t.actualBounds.isReal()&&this.C(t.jh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.C(t.jh(t.actualBounds)),this.requestUpdate()}_i(t){t.clearAdornments(),this.partManager._i(t);const i=this;t.data!==null&&t.qr(s=>i.partManager.SS(s,i)),this.Hn.delete(t),t instanceof Link&&this.Lr.delete(t),t.CL()?(t.actualBounds.isReal()&&this.C(t.jh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.C(t.jh(t.actualBounds)),this.requestUpdate()}remove(t){this.NS(t,!0)}NS(t,i){const e=t.layer;if(e===null||e.diagram!==this)return;t.isSelected=!1,t.isHighlighted=!1,t.invalidateLayout(2),i&&t.Xc();const s=e._i(-1,t,!1);s>=0&&this.raiseChangedEvent(4,"parts",e,t,null,s,null);const n=t.layerChanged;n!==null&&n(t,e,null)}removeParts(t,i){if(i===void 0&&(i=!1),Array.isArray(t)){const e=t.length;for(let s=0;s=0&&i.elt(e).isTemporary;)e--;return i.insertAt(e+1,t),this.Mi!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,e+1),this.C(),this.invalidateDocumentBounds(),this}addLayerBefore(t,i){this.CS(t,i),t.To(this);const e=this.Gt,s=e.indexOf(t);s>=0&&(e.delete(t),this.Mi!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;o=0&&(e.delete(t),this.Mi!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;othis.maxScale&&(i=this.maxScale);const c=Point.X(this.ct.x+l/t-l/i,this.ct.y+h/t-h/i);this.position=c,Point.s(c),this.st=i,this.Ql(),this.Ht=!1,this.onViewportBoundsChanged(n,this.viewportBounds,t,!1),this.Bs(!1),e._C(t,this.st),this.C()}eR(){const t=this.Gt.r;for(let i=0;i{r.isAvoiding&&r.actualBounds.intersectsRect(i)&&r.invalidateRoute()})}jr(t){const i=this.ts;if(i===null||!i.visible||i.layer===null)return;const e=t!==void 0?t:this._x;if(!e.isReal())return;const s=e.width,n=e.height;if(i.scale=1,i.angle=0,i.layer.isViewportAligned)i.width=s*this.scale,i.height=n*this.scale,i.part.alignment=Spot.TopLeft;else{i.xi===null&&(i.xi=new GridPanelSettings);const o=i.xi.Kc;if(!o.isReal())return;i.width=s+o.width*2,i.height=n+o.height*2;const r=Point.l();Geo.Eg(e.x,e.y,0,0,o.width,o.height,r),r.offset(-o.width,-o.height),i.part.location=r,Point.s(r)}}clearSelection(t){t===void 0&&(t=!1);const i=this.selection;if(i.count===0)return;t||this.v("ChangingSelection",i);const e=i.toArray(),s=e.length;for(let n=0;n1)&&(this.v("ChangingSelection",this.selection),this.clearSelection(!0),t.isSelected=!0,this.v("ChangedSelection",this.selection))}selectCollection(t){if(this.v("ChangingSelection",this.selection),this.clearSelection(!0),Array.isArray(t)){const i=t.length;for(let e=0;e0){const i=t.toArray(),e=i.length;for(let s=0;s1)&&(this.clearHighlighteds(),t.isHighlighted=!0)}highlightCollection(t){const i=new GSet().addAll(t),s=this.highlighteds.copy().removeAll(i).iterator;for(;s.next();){const o=s.value;o.isHighlighted=!1}const n=i.iterator;for(;n.next();){const o=n.value;o instanceof Part||Util.o("Diagram.highlightCollection given something that is not a Part: "+o),o.isHighlighted=!0}}scroll(t,i,e){e===void 0&&(e=1);const s=i==="up"||i==="down";let n=0;const o=Point.l();if(t==="pixel")n=e;else if(t==="line")n=e*(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange);else if(t==="page"){let l=s?this.viewportBounds.height:this.viewportBounds.width;if(l*=this.scale,l!==0){const h=Math.max(l-(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange),0);n=e*h}}else if(t==="document"){const l=this.documentBounds,h=this.viewportBounds;i==="up"?this.position=o.e(h.x,l.y):i==="left"?this.position=o.e(l.x,h.y):i==="down"?this.position=o.e(h.x,l.bottom-h.height):i==="right"&&(this.position=o.e(l.right-h.width,h.y)),Point.s(o);return}else Util.o("scrolling unit must be 'pixel', 'line', 'page', or 'document', not: "+t);n/=this.scale;const r=this.position;i==="up"?this.position=o.e(r.x,r.y-n):i==="down"?this.position=o.e(r.x,r.y+n):i==="left"?this.position=o.e(r.x-n,r.y):i==="right"?this.position=o.e(r.x+n,r.y):Util.o("scrolling direction must be 'up', 'down', 'left', or 'right', not: "+i),Point.s(o)}scrollToRect(t){const i=this.viewportBounds;if(i.containsRect(t))return;const e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}centerRect(t){const i=this.viewportBounds,e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}transformDocToView(t){return t.copy().D(this.D)}transformViewToDoc(t){return t.copy().Ie(this.D)}AF(t){return t.Ie(this.D)}static None=1;static Uniform=2;static UniformToFill=3;static CycleAll=1;static CycleNotDirected=2;static CycleNotDirectedFast=3;static CycleNotUndirected=4;static CycleDestinationTree=5;static CycleSourceTree=6;static DocumentScroll=1;static InfiniteScroll=2;static TreeParentCollapsed=1;static AllParentsCollapsed=2;static AnyParentsCollapsed=3;get opacity(){return this.Wt}set opacity(t){const i=this.Wt;i!==t&&(Util.i(t,"number",Diagram,"opacity"),(t<0||t>1)&&Util._(t,"0 <= value <= 1",Diagram,"opacity"),this.Wt=t,this.t("opacity",i,t),this.C())}get validCycle(){return this.Rx}set validCycle(t){const i=this.Rx;i!==t&&(this.Rx=t,this.t("validCycle",i,t))}get layers(){return this.Gt.iterator}get isModelReadOnly(){const t=this.Mi;return t===null?!1:t.isReadOnly}set isModelReadOnly(t){const i=this.Mi;i!==null&&(i.isReadOnly=t)}get isReadOnly(){return this.vo}set isReadOnly(t){const i=this.vo;i!==t&&(Util.i(t,"boolean",Diagram,"isReadOnly"),this.vo=t,this.t("isReadOnly",i,t))}get isEnabled(){return this.Oi}set isEnabled(t){const i=this.Oi;i!==t&&(Util.i(t,"boolean",Diagram,"isEnabled"),this.Oi=t,this.t("isEnabled",i,t))}get allowClipboard(){return this.Vx}set allowClipboard(t){const i=this.Vx;i!==t&&(Util.i(t,"boolean",Diagram,"allowClipboard"),this.Vx=t,this.t("allowClipboard",i,t))}get allowCopy(){return this.Rl}set allowCopy(t){const i=this.Rl;i!==t&&(Util.i(t,"boolean",Diagram,"allowCopy"),this.Rl=t,this.t("allowCopy",i,t))}get allowDelete(){return this.vl}set allowDelete(t){const i=this.vl;i!==t&&(Util.i(t,"boolean",Diagram,"allowDelete"),this.vl=t,this.t("allowDelete",i,t))}get allowDragOut(){return this.zx}set allowDragOut(t){const i=this.zx;i!==t&&(Util.i(t,"boolean",Diagram,"allowDragOut"),this.zx=t,this.t("allowDragOut",i,t))}get allowDrop(){return this.Xx}set allowDrop(t){const i=this.Xx;i!==t&&(Util.i(t,"boolean",Diagram,"allowDrop"),this.Xx=t,this.t("allowDrop",i,t))}get allowTextEdit(){return this.Ol}set allowTextEdit(t){const i=this.Ol;i!==t&&(Util.i(t,"boolean",Diagram,"allowTextEdit"),this.Ol=t,this.t("allowTextEdit",i,t))}get allowGroup(){return this.Il}set allowGroup(t){const i=this.Il;i!==t&&(Util.i(t,"boolean",Diagram,"allowGroup"),this.Il=t,this.t("allowGroup",i,t))}get allowUngroup(){return this.El}set allowUngroup(t){const i=this.El;i!==t&&(Util.i(t,"boolean",Diagram,"allowUngroup"),this.El=t,this.t("allowUngroup",i,t))}get allowInsert(){return this.Kx}set allowInsert(t){const i=this.Kx;i!==t&&(Util.i(t,"boolean",Diagram,"allowInsert"),this.Kx=t,this.t("allowInsert",i,t))}get allowLink(){return this.Ul}set allowLink(t){const i=this.Ul;i!==t&&(Util.i(t,"boolean",Diagram,"allowLink"),this.Ul=t,this.t("allowLink",i,t))}get allowRelink(){return this.Bl}set allowRelink(t){const i=this.Bl;i!==t&&(Util.i(t,"boolean",Diagram,"allowRelink"),this.Bl=t,this.t("allowRelink",i,t))}get allowMove(){return this.Vl}set allowMove(t){const i=this.Vl;i!==t&&(Util.i(t,"boolean",Diagram,"allowMove"),this.Vl=t,this.t("allowMove",i,t))}get allowReshape(){return this.zl}set allowReshape(t){const i=this.zl;i!==t&&(Util.i(t,"boolean",Diagram,"allowReshape"),this.zl=t,this.t("allowReshape",i,t))}get allowResize(){return this.Xl}set allowResize(t){const i=this.Xl;i!==t&&(Util.i(t,"boolean",Diagram,"allowResize"),this.Xl=t,this.t("allowResize",i,t))}get allowRotate(){return this.Kl}set allowRotate(t){const i=this.Kl;i!==t&&(Util.i(t,"boolean",Diagram,"allowRotate"),this.Kl=t,this.t("allowRotate",i,t))}get allowSelect(){return this.Yl}set allowSelect(t){const i=this.Yl;i!==t&&(Util.i(t,"boolean",Diagram,"allowSelect"),this.Yl=t,this.t("allowSelect",i,t))}get allowUndo(){return this.Yx}set allowUndo(t){const i=this.Yx;i!==t&&(Util.i(t,"boolean",Diagram,"allowUndo"),this.Yx=t,this.t("allowUndo",i,t))}get allowZoom(){return this.Gx}set allowZoom(t){const i=this.Gx;i!==t&&(Util.i(t,"boolean",Diagram,"allowZoom"),this.Gx=t,this.t("allowZoom",i,t))}get hasVerticalScrollbar(){return this.Eu}set hasVerticalScrollbar(t){const i=this.Eu;i!==t&&(Util.i(t,"boolean",Diagram,"hasVerticalScrollbar"),this.Eu=t,this.oa(),this.C(),this.t("hasVerticalScrollbar",i,t),this.Bs(!1))}get hasHorizontalScrollbar(){return this.Iu}set hasHorizontalScrollbar(t){const i=this.Iu;i!==t&&(Util.i(t,"boolean",Diagram,"hasHorizontalScrollbar"),this.Iu=t,this.oa(),this.C(),this.t("hasHorizontalScrollbar",i,t),this.Bs(!1))}get allowHorizontalScroll(){return this.jx}set allowHorizontalScroll(t){const i=this.jx;i!==t&&(Util.i(t,"boolean",Diagram,"allowHorizontalScroll"),this.jx=t,this.t("allowHorizontalScroll",i,t),this.Bs(!1))}get allowVerticalScroll(){return this.Hx}set allowVerticalScroll(t){const i=this.Hx;i!==t&&(Util.i(t,"boolean",Diagram,"allowVerticalScroll"),this.Hx=t,this.t("allowVerticalScroll",i,t),this.Bs(!1))}get scrollHorizontalLineChange(){return this.qx}set scrollHorizontalLineChange(t){const i=this.qx;i!==t&&(Util.i(t,"number",Diagram,"scrollHorizontalLineChange"),t<0&&Util._(t,">= 0",Diagram,"scrollHorizontalLineChange"),this.qx=t,this.t("scrollHorizontalLineChange",i,t))}get scrollVerticalLineChange(){return this.Wx}set scrollVerticalLineChange(t){const i=this.Wx;i!==t&&(Util.i(t,"number",Diagram,"scrollVerticalLineChange"),t<0&&Util._(t,">= 0",Diagram,"scrollVerticalLineChange"),this.Wx=t,this.t("scrollVerticalLineChange",i,t))}get lastInput(){return this.Jh}set lastInput(t){this.Jh=t}get previousInput(){return this.Xr}set previousInput(t){this.Xr=t}get firstInput(){return this.Jm}set firstInput(t){this.Jm=t}get currentCursor(){return this.vx}set currentCursor(t){if(t===""&&(t=this.Km),this.vx!==t){Util.i(t,"string",Diagram,"currentCursor");const e=this.dt,s=this.Tt;if(e===null||s===null)return;this.vx=t;const n=e.style.cursor;e.style.cursor=t,s.style.cursor=t,e.style.cursor===n&&(e.style.cursor="-webkit-"+t,s.style.cursor="-webkit-"+t,e.style.cursor===n&&(e.style.cursor="-moz-"+t,s.style.cursor="-moz-"+t,e.style.cursor===n&&(e.style.cursor=t,s.style.cursor=t)))}}get defaultCursor(){return this.Km}set defaultCursor(t){t===""&&(t="auto");const i=this.Km;i!==t&&(Util.i(t,"string",Diagram,"defaultCursor"),this.Km=t,this.t("defaultCursor",i,t))}get click(){return this.Tr}set click(t){const i=this.Tr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"click"),this.Tr=t,this.t("click",i,t))}get doubleClick(){return this.Dr}set doubleClick(t){const i=this.Dr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"doubleClick"),this.Dr=t,this.t("doubleClick",i,t))}get contextClick(){return this.Fr}set contextClick(t){const i=this.Fr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"contextClick"),this.Fr=t,this.t("contextClick",i,t))}get mouseOver(){return this.Rr}set mouseOver(t){const i=this.Rr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseOver"),this.Rr=t,this.t("mouseOver",i,t))}get mouseHover(){return this.vr}set mouseHover(t){const i=this.vr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseHover"),this.vr=t,this.t("mouseHover",i,t))}get mouseHold(){return this.Or}set mouseHold(t){const i=this.Or;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseHold"),this.Or=t,this.t("mouseHold",i,t))}get mouseDragOver(){return this.Ox}set mouseDragOver(t){const i=this.Ox;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseDragOver"),this.Ox=t,this.t("mouseDragOver",i,t))}get mouseDrop(){return this.Ir}set mouseDrop(t){const i=this.Ir;i!==t&&(this.Ir=t,this.t("mouseDrop",i,t))}get handlesDragDropForTopLevelParts(){return this.Ix}set handlesDragDropForTopLevelParts(t){const i=this.Ix;i!==t&&(Util.i(t,"boolean",Diagram,"handlesDragDropForTopLevelParts"),this.Ix=t,this.t("handlesDragDropForTopLevelParts",i,t))}get mouseEnter(){return this.Er}set mouseEnter(t){const i=this.Er;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseEnter"),this.Er=t,this.t("mouseEnter",i,t))}get mouseLeave(){return this.Ur}set mouseLeave(t){const i=this.Ur;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseLeave"),this.Ur=t,this.t("mouseLeave",i,t))}get toolTip(){return this.Br}set toolTip(t){const i=this.Br;i!==t&&(this.Br=t,this.t("toolTip",i,t))}get contextMenu(){return this.Vr}set contextMenu(t){const i=this.Vr;i!==t&&(this.Vr=t,this.t("contextMenu",i,t))}get commandHandler(){return this.HM}set commandHandler(t){this.HM!==t&&(this.HM=t,t.To(this))}get toolManager(){return this.YM}set toolManager(t){this.YM!==t&&(this.YM=t,t.diagram=this)}get defaultTool(){return this.GM}set defaultTool(t){const i=this.GM;i!==t&&(this.GM=t,t.diagram=this,this.currentTool===i&&(this.currentTool=t))}get currentTool(){return this.jM}set currentTool(t){const i=this.jM;i&&(i.isActive&&i.doDeactivate(),i.cancelWaitAfter(),i.doStop()),t===null&&(t=this.defaultTool),t!==null&&(this.jM=t,t.diagram=this,t.doStart())}get selection(){return this._M}get maxSelectionCount(){return this.Qx}set maxSelectionCount(t){const i=this.Qx;if(i!==t)if(Util.i(t,"number",Diagram,"maxSelectionCount"),t>=0&&!isNaN(t)){if(this.Qx=t,this.t("maxSelectionCount",i,t),!this.undoManager.isUndoingRedoing){const e=this.selection.count-t;if(e>0){this.v("ChangingSelection",this.selection);const s=this.selection.toArray();for(let n=0;n= 0",Diagram,"maxSelectionCount")}get nodeSelectionAdornmentTemplate(){return this.Hm}set nodeSelectionAdornmentTemplate(t){const i=this.Hm;i!==t&&(this.Hm=t,this.t("nodeSelectionAdornmentTemplate",i,t))}get groupSelectionAdornmentTemplate(){return this.ib}set groupSelectionAdornmentTemplate(t){const i=this.ib;i!==t&&(this.ib=t,this.t("groupSelectionAdornmentTemplate",i,t))}get linkSelectionAdornmentTemplate(){return this.eb}set linkSelectionAdornmentTemplate(t){const i=this.eb;i!==t&&(this.eb=t,this.t("linkSelectionAdornmentTemplate",i,t))}get highlighteds(){return this.tS}get isModified(){const t=this.undoManager;return t.isEnabled?t.currentTransaction!==null?!0:this.Vu&&this.vs!==t.historyIndex:this.Vu}set isModified(t){if(this.Vu!==t){Util.i(t,"boolean",Diagram,"isModified"),this.Vu=t;const e=this.undoManager;!t&&e.isEnabled&&(this.vs=e.historyIndex),t||this.OL()}}OL(){const t=this.isModified;this.ZM!==t&&(this.ZM=t,this.v("Modified"))}get model(){return this.Mi}set model(t){const i=this.Mi;if(i!==t){this.currentTool.doCancel(),i&&i.undoManager!==t.undoManager&&i.undoManager.isInTransaction&&Util.o("Do not replace a Diagram.model while a transaction is in progress."),this.animationManager.stopAnimation(!0);const e=this.mL(!0);this.Jn=!1,this.Ou=!0,this.vs=-2,this.Pr=!1;const s=this.Ht;this.Ht=!0,this.animationManager.Fl("Model"),i&&(this.qn!==null&&this.qn.each(n=>i.removeChangedListener(n)),i.removeChangedListener(this.$M)),this.Mi=t,this.partManager=this.uR(this.Mi.type),this.initializePartManager(this.partManager);for(let n=0;nt.addChangedListener(n)),this.Ht=s,this.invalidateDocumentBounds(),this.Ht||this.C(),i&&t.undoManager.copyProperties(i.undoManager)}}get themeManager(){return this.gb}set themeManager(t){const i=this.gb;i!==t&&(i!==null&&i.removeDiagram(this),this.gb=t,t!==null&&t.addDiagram(this))}initializePartManager(t){}static gS(t,i){Diagram.aL.set(t,i)}static get licenseKey(){return Diagram.AS.last()}static set licenseKey(t){Diagram.AS.add(t.replace(/\s/g,""))}static get version(){return Diagram.dR}static AS=new List;static dR="3.0.11";uR(t){const i=Diagram.aL.get(t);return i!==null?new i:new PartManager}get Y(){return this.WM}set Y(t){this.WM=t}get mx(){return this.rL}gR(t){if(t.model!==this.model)return;const i=t.change,e=t.propertyName;if(i===1&&e[0]==="S"){if(e==="StartingFirstTransaction"){const s=this,n=this.toolManager;n.mouseDownTools.each(o=>o.diagram=s),n.mouseMoveTools.each(o=>o.diagram=s),n.mouseUpTools.each(o=>o.diagram=s),this.routers.each(o=>o.diagram=s),!this.ps&&!this.Jn&&(this.vc=!0,this.Ou&&(this.Pr=!0))}else if(e==="StartingUndo"||e==="StartingRedo"){const s=this.animationManager;this.skipsUndoManager||(s.defaultAnimation.isAnimating&&s.stopAnimation(),s.getBundleAnimation().isAnimating&&s.getBundleAnimation().stop()),this.v("ChangingSelection",this.selection)}else if(e==="StartedTransaction"){const s=this.animationManager;s.defaultAnimation.isAnimating&&!this.skipsUndoManager&&s.stopAnimation()}return}if(this.Y){this.Y=!1;try{if(t.modelChange===""&&i===1){(e==="FinishedUndo"||e==="FinishedRedo")&&(this.v("ChangedSelection",this.selection),this.Ci());const s=this.animationManager;e==="RolledBackTransaction"&&s.stopAnimation(),this.fR(),this.vc=!0,this.maybeUpdate(),(this.undoManager.transactionLevel===0||this.undoManager.transactionLevel===1)&&s.MM(),e==="CommittedTransaction"&&this.undoManager.isJustDiscarded&&(this.vs=Math.min(this.vs,this.undoManager.historyIndex-1)),(e==="CommittedTransaction"||e==="RolledBackTransaction")&&this.undoManager.Iw&&setTimeout(()=>{this.isModified=!1},1);const n=t.isTransactionFinished;if(n&&(this.OL(),this.mx.clear(),this.animationManager.uF()),!this.Ex&&n&&this.lastInput.targetDiagram){this.Ex=!0;const o=this;Util.vh(()=>{o.currentTool.standardMouseOver(),o.Ex=!1},10)}}}finally{this.Y=!0}}}get ce(){return this.qM}set ce(t){this.qM=t}get uc(){return this.Ux}set uc(t){this.Ux=t}SL(t){const i=t.L.r;for(const e of i)e instanceof Picture&&this.TS(e)}TS(t){const i=t.element;if(i===null||!(i instanceof HTMLImageElement)||(i.es instanceof GSet&&i.es.add(this),t.mR(),!i.f0))return;const e=i.getAttribute("src")||"",s=this.Jl.get(e);if(s===null){Picture.IL(t,i);const n=[];n.push(t),this.Jl.set(e,n)}else{for(let n=0;n0?(this.kx=t,this.t("minScale",i,t),t>this.scale&&(this.scale=t)):Util._(t,"> 0",Diagram,"minScale"))}get maxScale(){return this.Px}set maxScale(t){const i=this.Px;i!==t&&(t>0?(this.Px=t,this.t("maxScale",i,t),t 0",Diagram,"maxScale"))}get zoomPoint(){return this.Mx}set zoomPoint(t){this.Mx.equals(t)||(t=t.N(),this.Mx=t)}get contentAlignment(){return this.Fc}set contentAlignment(t){const i=this.Fc;i.equals(t)||(t=t.N(),this.Fc=t,this.t("contentAlignment",i,t),this.Bs(!1))}get initialContentAlignment(){return this.Vm}set initialContentAlignment(t){const i=this.Vm;i.equals(t)||(t=t.N(),this.Vm=t,this.t("initialContentAlignment",i,t))}get padding(){return this.$t}set padding(t){typeof t=="number"&&(t=new Margin(t));const i=this.$t;i.equals(t)||(t=t.N(),this.$t=t,this.invalidateDocumentBounds(),this.t("padding",i,t))}get partManager(){return this.oS}set partManager(t){const i=this.oS;i!==t&&(t.diagram!==null&&Util.o("Cannot share PartManagers between Diagrams: "+t.toString()),i&&i.To(null),this.oS=t,t.To(this))}get nodes(){return this.partManager.nodes.iterator}get links(){return this.partManager.links.iterator}get parts(){return this.partManager.parts.iterator}findTopLevelNodesAndLinks(){const t=new GSet,i=this.nodes;for(;i.next();){const s=i.value;s.isTopLevel&&t.add(s)}const e=this.links;for(;e.next();){const s=e.value;s.isTopLevel&&t.add(s)}return t.iterator}findTopLevelGroups(){return this.Yr.iterator}get routers(){return this.Vc}doLinkRouting(t){this.Fo=!0;const i=this.Vc.r;for(let e=0;e0){const l=this.computePartsBounds(n.memberParts,!1);l.inflate(20,20),s.kb(l)}const o=Rect.l(),r=n.memberParts;for(;r.next();){const l=r.value;l instanceof Node&&this.IS(l,e,o)}Rect.s(o)}s.la=n,s.RS=e,s.Eo=!1}else t&&s.XL();return s}get avoidanceCellSize(){return this.iS}set avoidanceCellSize(t){this.Hl=null,this.iS=new Size(Math.max(1,t.width),Math.max(1,t.height))}get avoidanceLimit(){return this.eS}set avoidanceLimit(t){this.eS=Math.max(1,t)}zL(t){return t.canAvoid()?t:t.containingGroup!==null?this.zL(t.containingGroup):null}IS(t,i,e){if(t===i||!t.isVisible())return;const s=t.canAvoid();if(s){const n=t.getAvoidableRect(e);this.Hl.wR(n.x,n.y,n.width,n.height)}if(t instanceof Group&&(!s||t.avoidableMembers)){const n=t.memberParts;for(;n.next();){const o=n.value;o instanceof Node&&this.IS(o,i,e)}}}ES(t){this.Hl!==null&&!this.Hl.Eo&&(t===void 0||t.canAvoid())&&(this.Hl.Eo=!0)}get autoScrollInterval(){return this.zm}set autoScrollInterval(t){const i=this.zm;i!==t&&(this.zm=t,this.t("autoScrollInterval",i,t))}get autoScrollRegion(){return this.Xm}set autoScrollRegion(t){typeof t=="number"&&(t=new Margin(t));const i=this.Xm;i.equals(t)||(t=t.N(),this.Xm=t,this.invalidateDocumentBounds(),this.t("autoScrollRegion",i,t))}doAutoScroll(t){this.Wm.a(t),this.computeAutoScrollPosition(this.Wm).equalsApprox(this.position)?this.stopAutoScroll():this.KL()}KL(){if(this.Rc!==-1)return;const t=this.zm,i=this;this.Rc=Util.vh(()=>{if(i.Rc===-1||(i.stopAutoScroll(),i.lastInput.event===null))return;const s=i.computeAutoScrollPosition(i.Wm);if(s.equalsApprox(i.position))return;i.position=s,i.lastInput.documentPoint=i.transformViewToDoc(i.Wm),i.doMouseMove(),i.$h=!0;const n=Rect.l();i.computeBounds(n),n.unionRect(i.documentBounds),i.EL(n),Rect.s(n),i.Be=!0,i.maybeUpdate(),i.KL()},t)}stopAutoScroll(){this.Rc!==-1&&(Util.Ig(this.Rc),this.Rc=-1)}computeAutoScrollPosition(t){let i=this.position;const e=this.Xm;if(e.top<=0&&e.left<=0&&e.right<=0&&e.bottom<=0)return i;const s=this.viewportBounds,n=this.scale,o=Rect.X(0,0,s.width*n,s.height*n),r=Point.X(0,0);if(t.x>=o.x&&t.xo.x+o.width-e.right&&this.allowHorizontalScroll){let l=Math.max(this.scrollHorizontalLineChange,1);l=l|0,r.x+=l,t.x>o.x+o.width-e.right/2&&(r.x+=l),t.x>o.x+o.width-e.right/4&&(r.x+=4*l)}if(t.y>=o.y&&t.yo.y+o.height-e.bottom&&this.allowVerticalScroll){let l=Math.max(this.scrollVerticalLineChange,1);l=l|0,r.y+=l,t.y>o.y+o.height-e.bottom/2&&(r.y+=l),t.y>o.y+o.height-e.bottom/4&&(r.y+=4*l)}return r.equalsApprox(Point.Po)||(i=new Point(i.x+r.x/n,i.y+r.y/n)),Rect.s(o),Point.s(r),i}makeSvg(t){this.Wl.has("SVG")||this.addRenderer("SVG",new SVGSurface(this,root.document));const i=new SVGSurface(this,root.document,!0);t===void 0&&(t={});const e=this;function s(n,o){const r=e.YL(n,"SVG",i),l=r!==null?r.svg:null;return typeof o=="function"?(o(l),null):l}return this.GL(s,t)}makeSVG(t){return this.makeSvg(t)}addRenderer(t,i){this.Wl.set(t,i)}removeRenderer(t){this.Wl.delete(t)}cacheGroupExternalLinks(t){this.dS=t,t||this.nodes.each(i=>{i instanceof Group&&(i.d0=null)})}GL(t,i){const e=i.callback;let s=!0;const o=this.Jl.iterator;for(;o.next();)if(!o.value[0].mn){s=!1;break}if(typeof e!="function"||s)return t(i,e,this);const r=this;function l(){const c=+new Date;for(s=!0,o.reset();o.next();)if(!o.value[0].mn){s=!1;break}if(s||c-a>h){t(i,e,r);return}root.requestAnimationFrame(l)}const h=i.callbackTimeout||300,a=+new Date;return root.requestAnimationFrame(()=>l()),null}makeImage(t){return Diagram.isUsingDOM()?(t===void 0&&(t={}),t.returnType="Image",this.makeImageData(t)):null}makeImageData(t){return t===void 0&&(t={}),this.GL(this.xR,t)}static img="image";xR(t,i,e){const s=e.YL(t,"canvas",null);if(s===null)return null;const n=s.B.canvas;let o=null;if(n!==null){let r=t.returnType;switch(r===void 0?r="string":r=r.toLowerCase(),r){case Diagram.img+"data":o=s.getImageData(0,0,n.width,n.height);break;case Diagram.img:const h=(t.document||document).createElement("img");h.src=n.toDataURL(t.type,t.details),o=h;break;case"blob":{const a=n;return typeof i!="function"&&(o="",Util.o('Error: Diagram.makeImageData called with "returnType: toBlob", but no required "callback" function property defined.')),typeof a.toBlob=="function"?(a.toBlob(i,t.type,t.details),"toBlob"):(i(null),null)}case"string":default:o=n.toDataURL(t.type,t.details)}}return typeof i=="function"?(i(o),null):o}static bR=!1;YL(t,i,e){if(this.animationManager.stopAnimation(),this.maybeUpdate(),this.dt===null)return null;typeof t!="object"&&Util.o("properties argument must be an Object.");let n=!1,o=t.size||null,r=t.scale||null;t.scale!==void 0&&isNaN(t.scale)&&(r="NaN");let l=t.maxSize;t.maxSize===void 0&&(n=!0,i==="SVG"?l=new Size(1/0,1/0):l=new Size(2e3,2e3));const h=t.position||null;let a=t.parts||null;Array.isArray(a)&&(a=new List(a));let c=t.padding===void 0?1:t.padding;const f=t.background||null;let u=t.omitTemporary;u===void 0&&(u=!0);const d=t.document||document,m=t.elementFinished||null;let g=t.showTemporary;g===void 0&&(g=!u);let p=t.showGrid;p===void 0&&(p=g),o!==null&&isNaN(o.width)&&isNaN(o.height)&&(o=null),typeof c=="number"?c=new Margin(c):c instanceof Margin||Util.o("MakeImage padding must be a Margin or a number."),c.left=Math.max(c.left,0),c.right=Math.max(c.right,0),c.top=Math.max(c.top,0),c.bottom=Math.max(c.bottom,0),this.Zt.clearContextCache(!0);const y=new CanvasSurface(null,d,void 0,!0),x=y.ai;if(!(o||r||a||h))return y.width=this.kt+Math.ceil(c.left+c.right),y.height=this.Pt+Math.ceil(c.top+c.bottom),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.ha=d,e.ju=m,this.wb(e.ai,c,new Size(y.width,y.height),this.st,this.ct,a,f,g,p),e.ai):(this.zu=!1,this.wb(x,c,new Size(y.width,y.height),this.st,this.ct,a,f,g,p),this.zu=!0,y.ai);const k=this.$m,b=this.documentBounds.copy();if(b.subtractMargin(this.$t),g){const A=this.Gt.r,D=A.length;for(let F=0;Fk?(r=k,N=b.width,T=b.height):(N=l.width,T=l.height)):(N=b.width*r,T=b.height*r):(r=k,N=b.width,T=b.height),c!==null?(N+=M,T+=L):c=new Margin(0),l!==null){let A=l.width,D=l.height;i!=="SVG"&&n&&Diagram.bR,isNaN(A)&&(A=2e3),isNaN(D)&&(D=2e3),isFinite(A)&&(N=Math.min(N,A)),isFinite(D)&&(T=Math.min(T,D))}return y.width=Math.ceil(N),y.height=Math.ceil(T),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.ha=d,e.ju=m,this.wb(e.ai,c,new Size(Math.ceil(N),Math.ceil(T)),r,P,a,f,g,p),e.ai):(this.zu=!1,this.wb(x,c,new Size(Math.ceil(N),Math.ceil(T)),r,P,a,f,g,p),this.zu=!0,y.ai)}static Yu=null;static jL="5da73c80a36555d4038e4972187c3cae51fd22";static uw=!1;static Ik=()=>{if(Diagram.jL[5]===void 0&&(Transform.prototype._e=Transform.prototype.ww),!Diagram.isUsingDOM())return;const t=root.document.createElement("canvas"),i=t.getContext("2d"),e=Util.Cs("7ca11abfd022028846");i[e]=Util.Cs("398c3597c01238");const s="7ca11abfd7330390",n=[Diagram.jL,Util.uw+"4ae6247590da4bb21c324ba3a84e385776",Transform.Ik+"fb236cdfda5de14c134ba1a95a2d4c7cc6f93c1387",Geo.za],o=10,r=0;for(let l=1;l<5;l++)i[Util.Cs(s)](Util.Cs(n[l-1]),o,l*15+r);i[e]=Util.Cs("39f046ebb36e4b");for(let l=1;l<5;l++)i[Util.Cs(s)](Util.Cs(n[l-1]),o,l*15+r);(n.length!==4||n[0][0]!=="5"||n[3][0]!=="7")&&(Transform.prototype._e=Transform.prototype.ww),Diagram.Yu=t}}class DiagramHelper{HL;qL;US;Ne;constructor(t){if(this.HL=null,this.qL="63ad05bbe23a1786468a4c741b6d2",this.US="@onz",this.qL===this._tk){this.US=!0,this.Ne=this.US;return}this.Ne=null}kR(t,i){let e="f";const s=root[Util.Cs("76a715b2f73f148a")][Util.Cs("72ba13b5")]||"",n=Util.Cs;if(this.Ne=!0,!Diagram.isUsingDOM())return;let o=Diagram[n("76a115b6ed251eaf4692")];if(!o){const l=s[n("76ad18b4f73e")];for(let a=s[n("73a612b6fb191d")](n("35e7"))+2;a=0&&ha[0]||h[0]===a[0]&&h[1]>=a[1]))continue;const c="73a612b6fb191d",f=root[n("74a900bae4370f8b51")][n("6fbb13a1c2311e8a57")].toLowerCase(),u=f[n(c)](n("3aad1ab6e022098b4dc4")),d=n(l[2]);if(u>-1){const S=f[n(c)](d.toLowerCase()+"/");if(this.Ne=!(S>-1&&S=0&&g-1),!this.Ne))return;const p=root[Util.Cs("76a715b2f73f148a")][Util.Cs("69ad17a1e03e")],y=p[n(c)](n("7fb002b6ed25128b4da25b2e"));if(y>-1&&(this.Ne=!(p[n(c)](d)>y),!this.Ne))return;const x=d;if(x[0]!=="#")continue;const k=root.document.createElement("div");let b=l[0].replace(/[A-Za-z]/g,"");for(;b.length<4;)b+="9";const P=b;b=b.substring(b.length-4);let M="";const L=["gsh","gsf"],C=["Header","Background","Display","Feedback"];if(M+=L[parseInt(b.substring(0,1),10)%2],M+=C[parseInt(b.substring(0,1),10)%4],k[n("79a417a0f0181a8946")]=M,root.document[n("78a712aa")]){root.document[n("78a712aa")][n("7bb806b6ed32388c4a875b")](k);const S=root.getComputedStyle(k).getPropertyValue(n("78a704b7e62456904c9b12701b6532a8")),N=root.getComputedStyle(k).getPropertyValue(n("75b817b0ea2202"));if(root.document[n("78a712aa")][n("68ad1bbcf533388c4a875b")](k),!S)continue;const T=root[n("77a902b0eb1b1e804a8a")],A="0."+parseInt(P,10)%100;if(N===A||S.indexOf(parseInt(x[1]+x[2],16))!==-1&&S.indexOf(parseInt(x[3]+x[4],16))!==-1){this.Ne=!1;return}else if(T&&T(n("32ae19a1e0331fc94084537c067a67fa59f1386b89d006")).matches){M="."+M;for(let D=0;D{const s=this.observed;if(s===null)return;const n=s.viewportBounds,o=this.lastInput.documentPoint;s.position=new Point(o.x-n.width/2,o.y-n.height/2)},this.zS=s=>{this.invalidateDocumentBounds(),this.m0()},this.XS=s=>{this.observed!==null&&(this.invalidateDocumentBounds(),this.C())},this.Cb=s=>{this.updateDelay<1?this.C():this.g0||(this.g0=!0,setTimeout(()=>this.redraw(),this.updateDelay))},this.KS=s=>{this.observed!==null&&this.m0()},this.autoScale=2,this.Ht=!1,i&&Object.assign(this,i),this}setupRouters(){}computePixelRatio(){return 1}redraw(){this.g0&&this.updateDelay>=1&&(this.g0=!1,this.PR()),super.redraw()}Gi(){if(this.Tt===null&&Util.o("No div specified"),this.dt===null&&Util.o("No canvas specified"),this.dt instanceof SVGSurface||(this.box.BM(),!this.Be))return;const t=this.observed;if(t===null||t.animationManager.defaultAnimation.isAnimating||!t.Eh)return;this.h0();const i=this.dt,e=this.Zt;if(e.clearContextCache(!0),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,i.width,i.height),this.updateDelay<1)this.JL();else if(this.Gc!==null){e.drawImage(this.Gc.Ft,0,0);const o=this.D;e.scale(this.Bi,this.Bi),e.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),e.commitTransform()}const s=this.Gt.r,n=s.length;for(let o=0;on.canDelete())}t.removeParts(i,!0),t.v("SelectionDeleted",i)}finally{t.commitTransaction("Delete"),t.v("ChangedSelection",t.selection),t.currentCursor=""}}canDeleteSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowDelete||t.selection.count===0)}copySelection(){const t=this.diagram;try{const i=new GSet,e=t.selection.iterator;for(;e.next();){const s=e.value;Part.sh(i,s,!0,this.copiesTree?1/0:0,this.copiesConnectedLinks,n=>n.canCopy())}this.copyToClipboard(i)}finally{}}canCopySelection(){const t=this.diagram;return!(!t.allowCopy||!t.allowClipboard||t.selection.count===0)}cutSelection(){this.copySelection(),this.deleteSelection()}canCutSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowCopy||!t.allowDelete||!t.allowClipboard||t.selection.count===0)}copyToClipboard(t){const i=this.diagram;let e=null;if(t===null)Diagram.gL();else{const s=i.model;let n=!1,o=!1,r=null;try{s.mc()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.dc()||s.Hu())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=i.copyParts(t,null,!0)}finally{s.mc()&&(s.copiesParentKeyOfNodeData=n),(s.dc()||s.Hu())&&(s.copiesGroupKeyOfNodeData=o),e=new List,e.addAll(r.iteratorValues),Diagram.s0=e,Diagram.mb=i.model.dataFormat}}i.v("ClipboardChanged",e)}pasteFromClipboard(){const t=new GSet,i=Diagram.s0;if(i===null)return t;const e=this.diagram;if(Diagram.mb!==e.model.dataFormat)return t;const s=e.model;let n=!1,o=!1,r=null;try{s.mc()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.dc()||s.Hu())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=e.copyParts(i,e,!1)}finally{s.mc()&&(s.copiesParentKeyOfNodeData=n),(s.dc()||s.Hu())&&(s.copiesGroupKeyOfNodeData=o);const l=r.iterator;for(;l.next();){const h=l.value,a=l.key;h.location.isReal()||(a.location.isReal()?h.location=a.location:!h.position.isReal()&&a.position.isReal()&&(h.position=a.position)),t.add(h)}}return t}pasteSelection(t){t===void 0&&(t=null);const i=this.diagram;try{i.currentCursor="wait",i.v("ChangingSelection",i.selection),i.startTransaction("Paste");const e=this.pasteFromClipboard();e.count>0&&i.clearSelection(!0);const s=e.iterator;for(;s.next();){const n=s.value;n.isSelected=!0}if(t!==null){const n=i.computePartsBounds(i.selection);if(n.isReal()){const o=this.computeEffectiveCollection(i.selection,i.fb);i.bP(o,new Point(t.x-n.centerX,t.y-n.centerY),i.fb,!1)}}i.v("ClipboardPasted",e)}finally{i.commitTransaction("Paste"),i.v("ChangedSelection",i.selection),i.currentCursor=""}}canPasteSelection(t){const i=this.diagram;return!(i.isReadOnly||i.isModelReadOnly||!i.allowInsert||!i.allowClipboard||Diagram.s0===null||Diagram.s0.count===0||Diagram.mb!==i.model.dataFormat)}undo(){this.diagram.undoManager.undo()}canUndo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canUndo()}redo(){this.diagram.undoManager.redo()}canRedo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canRedo()}decreaseZoom(t){t===void 0&&(t=1/this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canDecreaseZoom(t){t===void 0&&(t=1/this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}increaseZoom(t){t===void 0&&(t=this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canIncreaseZoom(t){t===void 0&&(t=this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}resetZoom(t){t===void 0&&(t=this.defaultScale);const i=this.diagram;ti.maxScale||(i.scale=t)}canResetZoom(t){t===void 0&&(t=this.defaultScale);const i=this.diagram;return ti.maxScale?!1:i.allowZoom}zoomToFit(){const t=this.diagram,i=t.animationManager;i.stopAnimation(),t.redraw();const e=t.position,s=t.scale;i.Fl("Zoom To Fit"),this.isZoomToFitRestoreEnabled&&s===this.Ab&&!isNaN(this.Lb)&&t.documentBounds.equals(this.Tb)?(t.scale=this.Lb,t.position=this.QS,this.Ab=NaN,this.Tb=Rect.pw):(this.Lb=s,this.QS=e.copy(),t.zoomToFit(),this.Ab=t.scale,this.Tb=t.documentBounds.copy()),i.MM()}canZoomToFit(){return this.diagram.allowZoom}scrollToPart(t){t===void 0&&(t=null);const i=this.diagram;if(i.ensureBounds(),t===null){try{this.Uo!==null&&(this.Uo.next()?t=this.Uo.value:this.Uo=null)}catch{this.Uo=null}t===null&&(i.highlighteds.count>0?this.Uo=i.highlighteds.iterator:i.selection.count>0&&(this.Uo=i.selection.iterator),this.Uo!==null&&this.Uo.next()&&(t=this.Uo.value))}if(t!==null){const e=i.animationManager;e.Fl("Scroll To Part");const s=this.scrollToPartPause;if(s>0){const n=this.jc(t,[t]);if(n.length===1)i.startTransaction(),i.centerRect(t.actualBounds),i.commitTransaction("Scroll To Part");else{const o=()=>{i.startTransaction();let l=n.pop();for(;n.length>0&&l instanceof Node&&l.isTreeExpanded&&(!(l instanceof Group)||l.isSubGraphExpanded);)l=n.pop();n.length>0?(l instanceof Part&&i.scrollToRect(l.actualBounds),l instanceof Node&&!l.isTreeExpanded&&(l.isTreeExpanded=!0),l instanceof Group&&!l.isSubGraphExpanded&&(l.isSubGraphExpanded=!0)):(l instanceof Part&&i.centerRect(l.actualBounds),i.removeDiagramListener("LayoutCompleted",r)),i.commitTransaction("Scroll To Part")},r=()=>{Util.vh(o,(e.isEnabled?e.duration:0)+s)};i.addDiagramListener("LayoutCompleted",r),o()}}else{const n=i.position.copy();i.centerRect(t.actualBounds),n.equalsApprox(i.position)&&e.stopAnimation()}}}jc(t,i){if(t.isVisible())return i;if(t instanceof Adornment)this.jc(t.adornedPart,i);else if(t instanceof Link){const e=t.fromNode;e!==null&&this.jc(e,i);const s=t.toNode;s!==null&&this.jc(s,i)}else{if(t instanceof Node){const s=t.labeledLink;s!==null&&this.jc(s,i);const n=t.findTreeParentNode();n!==null&&(!n.isTreeExpanded&&!n.wasTreeExpanded&&i.push(n),this.jc(n,i))}const e=t.containingGroup;e!==null&&(!e.isSubGraphExpanded&&!e.wasSubGraphExpanded&&i.push(e),this.jc(e,i))}return i}canScrollToPart(t){if(t===void 0&&(t=null),t!==null&&!(t instanceof Part))return!1;const i=this.diagram;return i.selection.count===0&&i.highlighteds.count===0?!1:i.allowHorizontalScroll&&i.allowVerticalScroll}collapseTree(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse Tree";try{i.startTransaction(e),i.animationManager.Fl(e);const n=new List;if(t!==null&&t.isTreeExpanded)t.collapseTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&r.isTreeExpanded&&(r.collapseTree(),n.add(r))}}i.v("TreeCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||!t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(!s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}expandTree(t){t===void 0&&(t=null);const i=this.diagram,e="Expand Tree";try{i.startTransaction(e),i.animationManager.Fl(e);const n=new List;if(t!==null&&!t.isTreeExpanded)t.expandTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&(r.isTreeExpanded||(r.expandTree(),n.add(r)))}}i.v("TreeExpanded",n)}finally{i.commitTransaction(e)}}canExpandTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}groupSelection(){const t=this.diagram,i=t.model;if(!i.Hc())return;const e=this.archetypeGroupData;if(e===null)return;let s=null;try{t.currentCursor="wait",t.v("ChangingSelection",t.selection),t.startTransaction("Group");const n=new List,o=t.selection.iterator;for(;o.next();){const h=o.value;h.Pe()&&h.canGroup()&&n.add(h)}const r=new List,l=n.iterator;for(;l.next();){const h=l.value;let a=!1;const c=n.iterator;for(;c.next();){const f=c.value;if(h.isMemberOf(f)){a=!0;break}}a||r.add(h)}if(r.count>0){let h=r.first().containingGroup;if(h!==null)for(;h!==null;){let a=!1;const c=r.iterator;for(;c.next();)if(!c.value.isMemberOf(h)){a=!0;break}if(a)h=h.containingGroup;else break}if(e instanceof Group)e.li(),s=e.copy(),s!==null&&t.add(s);else if(i.isGroupForData(e)){const a=i.copyNodeData(e);Util.wt(a)&&(i.addNodeData(a),s=t.findNodeForData(a))}if(s!==null){h!==null&&this.isValidMember(h,s)&&(s.containingGroup=h);const a=r.iterator;for(;a.next();){const c=a.value;this.isValidMember(s,c)&&(c.containingGroup=s)}t.clearSelection(!0),s.isSelected=!0}}t.v("SelectionGrouped",s)}finally{t.commitTransaction("Group"),t.v("ChangedSelection",t.selection),t.currentCursor=""}}canGroupSelection(){const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowGroup||!t.model.Hc()||this.archetypeGroupData===null)return!1;const e=t.selection.iterator;for(;e.next();){const s=e.value;if(s.Pe()&&s.canGroup())return!0}return!1}i2(t){const i=Util.ot();if(Array.isArray(t))t.forEach(n=>{n instanceof Link||n instanceof Part&&i.push(n)});else{const n=t.iterator;for(;n.next();){const o=n.value;o instanceof Link||o instanceof Part&&i.push(o)}}const e=new GSet,s=i.length;for(let n=0;n0){i.clearSelection(!0);const o=s.iterator;for(;o.next();){const r=o.value;r.expandSubGraph();const l=r.containingGroup,h=l!==null&&l.data!==null?e.getKeyForNodeData(l.data):void 0;n.addAll(r.memberParts);const a=n.iterator;for(;a.next();){const c=a.value;if(c.isSelected=!0,c instanceof Link)continue;const f=c.data;f!==null?e.setGroupForData(f,h):c.containingGroup=l}i.remove(r)}}i.v("SelectionUngrouped",s,n)}finally{i.commitTransaction("Ungroup"),i.v("ChangedSelection",i.selection),i.currentCursor=""}}canUngroupSelection(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowDelete||!i.allowUngroup||!i.model.Hc())return!1;if(t!==null){if(!(t instanceof Group))return!1;if(t.canUngroup())return!0}else{const s=i.selection.iterator;for(;s.next();){const n=s.value;if(n instanceof Group&&n.canUngroup())return!0}}return!1}addTopLevelParts(t,i){const e=this.i2(t);let s=!0;const n=e.iterator;for(;n.next();){const o=n.value;o.containingGroup!==null&&(!i||this.isValidMember(null,o)?o.containingGroup=null:s=!1)}return s}collapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse SubGraph";try{i.startTransaction(e),i.animationManager.Fl(e);const n=new List;if(t!==null&&t.isSubGraphExpanded)t.collapseSubGraph(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&r.isSubGraphExpanded&&(r.collapseSubGraph(),n.add(r))}}i.v("SubGraphCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||!t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&s.isSubGraphExpanded)return!0}}return!1}expandSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Expand SubGraph",s=new List;try{if(i.startTransaction(e),i.animationManager.Fl(e),t!==null&&!t.isSubGraphExpanded)t.expandSubGraph(),s.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&(r.isSubGraphExpanded||(r.expandSubGraph(),s.add(r)))}}i.v("SubGraphExpanded",s)}finally{for(const n of s)this.$L(i,n);t&&this.$L(i,t),i.commitTransaction(e)}}$L(t,i){for(const e of i.memberParts)e instanceof Node&&t.Nc(e,i)}canExpandSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&!s.isSubGraphExpanded)return!0}}return!1}editTextBlock(t){t===void 0&&(t=null);const i=this.diagram,e=i.toolManager.findTool("TextEditing");if(e!==null){if(t===null){let s=null;const n=i.selection.iterator;for(;n.next();){const o=n.value;if(o.canEdit()){s=o;break}}if(s===null)return;t=s.findInVisualTree(o=>o instanceof TextBlock&&o.editable)}t!==null&&(i.currentTool=null,e.textBlock=t,i.currentTool=e)}}canEditTextBlock(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowTextEdit||i.toolManager.findTool("TextEditing")===null)return!1;if(t!==null){if(!(t instanceof TextBlock))return!1;const e=t.part;if(e!==null&&e.canEdit())return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s.canEdit()&&(t=s.findInVisualTree(n=>n instanceof TextBlock&&n.editable),t!==null))return!0}}return!1}showContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");if(e===null)return;t===void 0&&(i.selection.count>0?t=i.selection.first():t=i);const s=e.findObjectWithContextMenu(t);if(s!==null){const n=i.lastInput;let o=null;if(s instanceof GraphObject)o=s.getDocumentPoint(Spot.Center);else if(!i.viewportBounds.containsPoint(n.documentPoint)){const r=i.viewportBounds;o=new Point(r.x+r.width/2,r.y+r.height/2)}if(o!==null){const r=new InputEvent;r.diagram=i,r.viewPoint=i.transformDocToView(o),r.documentPoint=o,r.button=2,r.up=!0,i.lastInput=r}i.currentTool=e,e.openMenu(!1,s)}}canShowContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");return!(e===null||(t===void 0&&(i.selection.count>0?t=i.selection.first():t=i),e.findObjectWithContextMenu(t)===null))}get copiesClipboardData(){return this.YS}set copiesClipboardData(t){Util.i(t,"boolean",CommandHandler,"copiesClipboardData"),this.YS=t}get copiesConnectedLinks(){return this.GS}set copiesConnectedLinks(t){Util.i(t,"boolean",CommandHandler,"copiesConnectedLinks"),this.GS=t}get deletesConnectedLinks(){return this.jS}set deletesConnectedLinks(t){Util.i(t,"boolean",CommandHandler,"deletesConnectedLinks"),this.jS=t}get copiesTree(){return this.HS}set copiesTree(t){Util.i(t,"boolean",CommandHandler,"copiesTree"),this.HS=t}get deletesTree(){return this.qS}set deletesTree(t){Util.i(t,"boolean",CommandHandler,"deletesTree"),this.qS=t}get copiesParentKey(){return this.WS}set copiesParentKey(t){Util.i(t,"boolean",CommandHandler,"copiesParentKey"),this.WS=t}get copiesGroupKey(){return this.JS}set copiesGroupKey(t){Util.i(t,"boolean",CommandHandler,"copiesGroupKey"),this.JS=t}get archetypeGroupData(){return this.$S}set archetypeGroupData(t){t!==null&&Util.i(t,"object",CommandHandler,"archetypeGroupData");const i=this.diagram;this.$S=t}get memberValidation(){return this.eh}set memberValidation(t){t!==null&&Util.i(t,"function",CommandHandler,"memberValidation"),this.eh=t}get defaultScale(){return this.diagram.defaultScale}set defaultScale(t){this.diagram.defaultScale=t}get zoomFactor(){return this.ZS}set zoomFactor(t){t>1||Util.o("zoomFactor must be larger than 1.0, not: "+t),this.ZS=t}get isZoomToFitRestoreEnabled(){return this._S}set isZoomToFitRestoreEnabled(t){Util.i(t,"boolean",CommandHandler,"isZoomToFitRestoreEnabled"),this._S=t}get scrollToPartPause(){return this.t2}set scrollToPartPause(t){this.t2=t}computeEffectiveCollection(t,i){const e=this.diagram,s=e.toolManager.findTool("Dragging"),n=e.currentTool===s;i===void 0&&(i=e.c0());const o=new GMap;if(t===null)return o;let r=t.iterator;for(;r.next();){const l=r.value;e.Wr(o,l,n,i)}if(e.draggedLink!==null&&i.dragsLink)return o;for(r=t.iterator;r.next();){const l=r.value;if(l instanceof Link){const h=l.fromNode;if(h!==null&&!o.has(h))o.delete(l);else{const a=l.toNode;a!==null&&!o.has(a)&&o.delete(l)}}}return o}}var Stretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Vertical=4]="Vertical",w[w.Horizontal=5]="Horizontal",w[w.Fill=2]="Fill",w))(Stretch||{}),Orientation=(w=>(w[w.None=0]="None",w[w.Along=21]="Along",w[w.Plus90=22]="Plus90",w[w.Minus90=23]="Minus90",w[w.Opposite=24]="Opposite",w[w.Upright=25]="Upright",w[w.Plus90Upright=26]="Plus90Upright",w[w.Minus90Upright=27]="Minus90Upright",w[w.Upright45=28]="Upright45",w))(Orientation||{}),Flip=(w=>(w[w.None=0]="None",w[w.Vertical=1]="Vertical",w[w.Horizontal=2]="Horizontal",w[w.Both=3]="Both",w))(Flip||{});class GraphObject{n;qu;Wu;Bo;f;nh;q;ct;ee;Wt;Ju;Vs;Ct;ze;$r;oh;bi;aa;st;Xt;Zr;Li;Vi;$u;ni;qc;Ut;si;Qr;e2;Zu;constructor(){GSet.Yi(this),this.n=30723,this.Wt=1,this.Ju="",this.Vs=null,this.Ct=null,this.ct=new Point(NaN,NaN).g(),this.ze=Size.gw,this.$r=new Transform,this.oh=new Transform,this.bi=null,this.aa=1,this.st=1,this.Xt=0,this.Zr=Margin.Ug,this.ee=new Rect(NaN,NaN,NaN,NaN).g(),this.Li=new Rect(NaN,NaN,NaN,NaN).g(),this.Vi=new Rect(0,0,NaN,NaN).g(),this.$u=null,this.qu=null,this.q=null,this.ni=Spot.Default,this.qc=Spot.Default,this.Wu=0,this.Bo=0,this.Ut=null,this.f=null,this.nh=null,this.si=null,this.e2=null,this.Qr=null,this.Zu=null}cloneProtected(t){t.n=(this.n|2048|4096)&-32769,t.Wt=this.Wt,t.Ju=this.Ju,t.Ct=this.Ct,t.ct.a(this.ct),t.ze=this.ze.N(),this.bi!==null?t.bi=this.bi.copy():t.bi=null,t.st=this.st,t.Xt=this.Xt,t.Zr=this.Zr.N(),t.ee.a(this.ee),t.Li.a(this.Li),t.Vi.a(this.Vi),t.qu=this.qu,this.q!==null&&(t.q=this.q.copy()),t.ni=this.ni.N(),t.qc=this.qc.N(),t.Wu=this.Wu,t.Bo=this.Bo,this.Ut!==null&&(t.Ut=this.Ut.copy()),this.f!==null&&(this.f.gi?t.f=this.f:t.f=this.f.copy()),this.nh!==null&&(t.nh=this.nh.slice()),this.si!==null&&(t.si=this.si.copy())}addCopyProperty(t){let i=this.nh;if(!Array.isArray(i))i=[],this.nh=i;else for(let e=0;e{d.data!==null&&d.s2()&&d.updateTargetBindings(i)})}}}}mF(t){this.Zu.delete(t)}Io(){if(this.diagram===null)return;if(this.findBindingPanel()===null&&this.Ai!==null){const i=this.Ai.iterator;for(;i.next();){const e=i.value;if(!e.isToTheme)continue;let s=null;const n=e.sourceName;e.isToObject&&(s=this.ZL(n));let o=this;const r=e.targetId;r!==-1&&(o=this.p0(r),o===null)||(n==="/"?s=o.part:n==="."?s=o:n===".."&&(s=o.panel),e.updateTarget(o,s))}}}pa(t,i){const e=this.findBindingPanel();if(e!==null){const s=this.Ai.iterator;for(;s.next();){const n=s.value;let o=null;if(n.isToObject){if(o=n.QL(e,this),o===null)continue;n.updateSource(this,o,i,null)}else if(n.isToModel){const r=t.diagram;r!==null&&!r.ce&&n.updateSource(this,r.model.modelData,i,e)}else if(!n.isToTheme){const r=e.data;if(r===null)continue;const l=t.diagram;l!==null&&!l.ce&&n.updateSource(this,r,i,e)}if(o===this){const r=n.targetId,l=e.p0(r);l!==null&&n.updateTarget(l,o,i)}}}}p0(t){return this.$n===t?this:null}ZL(t){let i;return t===""?i=this:t==="/"?i=this:t==="."?i=this:t===".."?i=this:i=this.part.findObject(t),i}get $n(){return this.f!==null?this.f.$n:-1}set $n(t){this.$n!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.$n=t)}get Ai(){return this.f!==null?this.f.Ai:null}set Ai(t){this.Ai!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.Ai=t)}get Zn(){return this.f!==null?this.f.Zn:null}set Zn(t){this.Zn!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.Zn=t)}raiseChanged(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}t(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}Qn(t,i,e,s){const n=this.ee;if(n.e(t,i,e,s),this.st!==1||this.Xt!==0){this.bi===null&&(this.bi=new Transform);const o=this.bi;o.Ri(),this.y0(o,t,i,e,s),o.xw(n)}}_L(t,i,e){return this.pickable===!1?!1:(e.tc(this.D),i?this.intersectsRect(t,e):this.containedInRect(t,e))}tA(t,i,e){if(this.pickable===!1)return!1;const s=this.naturalBounds,n=t.distanceSquaredPoint(i);return e?Point.distanceLineSegmentSquared(t.x,t.y,0,0,0,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,0,s.height,s.width,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,s.height,s.width,0)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,0,0,0)<=n:t.distanceSquared(0,0)<=n&&t.distanceSquared(0,s.height)<=n&&t.distanceSquared(s.width,0)<=n&&t.distanceSquared(s.width,s.height)<=n}pn(){return!0}containsPoint(t){const i=Point.l();i.a(t),this.D.xt(i);const e=this.actualBounds;if(!e.isReal())return Point.s(i),!1;const s=this.diagram;if(s!==null&&s.Qm){const o=s.getInputOption("extraTouchThreshold"),r=s.getInputOption("extraTouchArea"),l=r/2,h=this.naturalBounds,a=this.getDocumentScale()*s.scale,c=1/a;if(h.width*ae&&(f=t),isFinite(i)&&i>s&&(u=i);break;case 5:isFinite(t)&&t>e&&(f=t),u=0,d&&(i=1/0);break;case 4:isFinite(i)&&i>s&&(u=i),f=0,d&&(t=1/0);break}const g=this.maxSize,p=this.minSize;f>g.width&&p.widthg.height&&p.heightu.height||this.mi>u.width)&&(r=!0)}}}r?this.n|=256:this.n&=-257,this.Li.isReal()||Util.o("Non-real actualBounds has been set. Object "+this+", actualBounds: "+this.Li.toString()),this.ed(o,this.Li),this._n(!1),Rect.s(o)}hh(t,i,e,s){}commonArrange(t,i,e,s){if(this.Li.e(t,i,e,s),this.desiredSize.isReal())return;const n=this.ee,o=this.Zr,r=o.right+o.left,l=o.top+o.bottom,h=n.width+r,a=n.height+l;e+=r,s+=l;let c=this.zs(!0);switch(h===e&&a===s&&(c=0),c){case 0:(h>e||a>s)&&(this.fe(!0),this.ut(h>e?e:h,a>s?s:a,0,0));break;case 2:this.fe(!0),this.ut(e,s,0,0);break;case 5:this.fe(!0),this.ut(e,a,0,0);break;case 4:this.fe(!0),this.ut(h,s,0,0);break}}ed(t,i){const e=this.part;e!==null&&e.diagram!==null&&((e.selectionObject===this||e.resizeObject===this||e.rotateObject===this)&&e.o2(!0),this.C(),!t.equalsApproxClose(i)&&(e.ah(),this.b0(e)))}b0(t){this.portId!==null&&(t.o2(!0),t instanceof Node&&t.iA(this))}get shadowVisible(){return this.f!==null?this.f.k0:null}set shadowVisible(t){const i=this.shadowVisible;i!==t&&(this.jt(),this.f.k0=t,this.ss(!0),this.C(),this.t("shadowVisible",i,t))}NR(t,i){const e=this.naturalBounds,s=this.oh,n=s.m11,o=s.m21,r=s.dx,l=s.m12,h=s.m22,a=s.dy;let c=0,f=0,u=c,d=f;c=u*n+d*o+r,f=u*l+d*h+a;let m=c,g=f,p=0,y=0;u=e.width+i,d=0,c=u*n+d*o+r,f=u*l+d*h+a;let x=Math.min(m,c),k=Math.min(g,f);p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-k,m=x,g=k,u=e.width+i,d=e.height+i,c=u*n+d*o+r,f=u*l+d*h+a,x=Math.min(m,c),k=Math.min(g,f),p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-k,m=x,g=k,u=0,d=e.height+i,c=u*n+d*o+r,f=u*l+d*h+a,x=Math.min(m,c),k=Math.min(g,f),p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-k,m=x,g=k;const b=t.viewportBounds,P=b.x,M=b.y,L=b.width,C=b.height;return m>L+P||P>p+m||g>C+M||M>y+g}Gi(t,i){if(this.CR(t,i)||!this.visible)return;const e=this.opacity;if(e===0)return;let s=1;e!==1&&(s=t.globalAlpha,t.globalAlpha=s*e);let n="";this.filter!==""&&(n=t.filter,t.filter=this.filter);const o=this.D,r=this.panel;this.w0()===!0&&this.Fb();const l=this.part;let h=!1,a=0;if(l&&i.getRenderingHint("drawShadows")&&(h=l.isShadowed,h)){const g=l.shadowOffset;a=Math.max(g.y,g.x)*i.scale*i.Bi}const c=this instanceof Panel&&this._r(),f=this.Li;if(c&&(this.eA(h,t,!1,r),this.LR(t,i),this.sA(h,t,!1,r),this.nA(h,t,!1)),c||!c&&(f.width===0||f.height===0||isNaN(f.x)||isNaN(f.y))){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}const u=this.Xs();if(!i.Zh&&u&&this.NR(i,a)){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}let d=(this.n&256)!==0;if(t.clipInsteadOfFill&&(d=!1),this instanceof TextBlock&&(t.font=this.font),d){const g=r.pn()?r.naturalBounds:r.actualBounds;let p=Math.max(f.x,g.x),y=Math.max(f.y,g.y),x=Math.min(f.right,g.right)-p,k=Math.min(f.bottom,g.bottom)-y;const b=this.si;if(b!==null&&(p=b.x,y=b.y,x=b.width,k=b.height),p>f.width+f.x||f.x>g.width+g.x){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}t.save(),t.beginPath(),t.rect(p,y,x,k),t.clip()}if(u){if(!l.isVisible()){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}if(h){const g=l.shadowOffset;t.shadowsSet(g.x*i.scale*this.scale*i.Bi,g.y*i.scale*this.scale*i.Bi,l.shadowBlur),t.shadowsOn(),t.shadowColor=l.shadowColor}}const m=this.naturalBounds;if(t.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.eA(h,t,u,r),this.Ct!==null&&(t.commitTransform(),this.Rb(t,m,f)),this.sA(h,t,u,r),this.ch(t,i),this.nA(h,t,u),d&&(t.restore(),t.clearContextCache(this instanceof Panel)),!o.Ok()){const g=1/(o.m11*o.m22-o.m12*o.m21);t.transform(o.m22*g,-o.m12*g,-o.m21*g,o.m11*g,g*(o.m21*o.dy-o.m22*o.dx),g*(o.m12*o.dx-o.m11*o.dy))}e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n)}eA(t,i,e,s){t&&this.shadowVisible===!0?i.shadowsOn():t&&this.shadowVisible===!1&&i.shadowsOff(),t&&this.vb(s)&&this.shadowVisible===null&&i.shadowsOff()}sA(t,i,e,s){t&&(this.Ct!==null||this.vb(s))?(this.Ob(!0),this.shadowVisible===null&&i.shadowsOff()):this.Ob(!1)}nA(t,i,e){t&&this.l2()===!0&&i.shadowsOn(),e&&t&&i.shadowsOff()}AR(t,i,e){const s=this.part;let n=!1;s&&t.getRenderingHint("drawShadows")&&(n=s.isShadowed),i.clipInsteadOfFill&&(n=!1),this.Xs()&&n&&i.shadowsOn(),n&&this.shadowVisible===!0?i.shadowsOn():n&&this.shadowVisible===!1&&i.shadowsOff();const o=this.panel;if(n&&this.vb(o)&&this.shadowVisible===null&&i.shadowsOff(),i.tl){const r=t.computePixelRatio(),l=`drop-shadow(${i.shadowOffsetX/r}px ${i.shadowOffsetY/r}px ${i.shadowBlur/r/2}px ${i.shadowColor})`;this.background!==null&&e.Ct.setAttributeNS(null,"filter",l)}return n&&(this.Ct!==null||this.vb(o))?(this.Ob(!0),this.shadowVisible===null&&i.shadowsOff()):this.Ob(!1),n}TR(t,i,e,s){if(e.tl){const n=i.computePixelRatio(),o=`drop-shadow(${e.shadowOffsetX/n}px ${e.shadowOffsetY/n}px ${e.shadowBlur/n/2}px ${e.shadowColor})`;this.h2(t,o)}s&&this.l2()===!0&&e.shadowsOn(),this.Xs()&&e.shadowsOff()}vb(t){return t===null?!1:(t._r()&&(t=t.panel),t.l2()||(t.type===Panel.Auto||t.type===Panel.Spot)&&t.findMainElement()!==this)}h2(t,i){}Rb(t,i,e){const s=this.Db(),n=i.x,o=i.y,r=i.width+s,l=i.height+s;this.dn(t,this.Ct,!0,!1,i,e),this.Ct instanceof Brush&&this.Ct.type===3?(t.beginPath(),t.rect(n-s/2,o-s/2,r,l),t.fillContext(this.Ct,!1,null)):t.fillRect(n-s/2,o-s/2,r,l)}oA(t,i){let e=t.DR(this);if(e!==-1)if(e===0)if(t.svg.Ct)t.svg.Ct.after(i);else if(t.type===Panel.Table){const s=t.svg.getElementsByClassName("gojs-ts"),n=s.length!==0?s[0]:null;n!==null&&n.after(i)}else t.svg.prepend(i);else{for(;e!==0&&!t.elt(e-1).isVisibleObject();)e--;if(e===0)t.svg.prepend(i);else{const s=t.elt(e-1).svg;s!==null?s.after(i):t.svg.appendChild(i)}}}CR(t,i){if(!(t instanceof SVGContext))return!1;if(!this.visible||this.opacity===0)return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;if(this.Xs()&&!this.isVisible())return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;const e=this.panel,s=this.sd(t);if(this.Zc(t,i,s))return this.rA(this.svg),this.svg.parentElement!==null?(this.Xs()&&(t.lastDrawnPart=this.svg),!0):(this.Xs()?(t.lastDrawnPart!==null?t.lastDrawnPart.after(this.svg):t.diagramGroup.prepend(this.svg),t.lastDrawnPart=this.svg):e&&this.oA(e,this.svg),!0);if(this.Xs()&&this.isShadowed){const m=this.shadowOffset;t.shadowsSet(m.x*i.scale*this.scale*i.Bi,m.y*i.scale*this.scale*i.Bi,this.shadowBlur),t.shadowsOn(),t.shadowColor=this.shadowColor}this instanceof TextBlock&&(t.font=this.font),t.currentElement=null;const n=this.D,o=this instanceof Panel,r=this instanceof Panel?this._r():!1,l=this.svg;this.w0()===!0&&this.Fb();const h=this.Li;t.setCurrentTransform(1,0,0,1,0,0),t.outerGroup=!1,s&&(t.outerGroup=!0,o&&r?(t.newGroup(1,0,0,1,0,0),this.svg=t.lastCreatedElement):o?(t.newGroup(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.svg=t.lastCreatedElement):t.newGroup(1,0,0,1,0,0));const a=this.naturalBounds;o||t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.background!==null&&(o?(r&&t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.Rb(t,a,h),r&&t.setCurrentTransform(1,0,0,1,0,0)):(t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.Rb(t,a,h)),t.currentElement.Ct=t.lastCreatedElement,t.currentElement.prepend(t.lastCreatedElement));const c=this.AR(i,t,t.currentElement);this.ch(t,i),o&&t.endGroup(),t.outerGroup&&t.endGroup();const f=t.surface.ju,u=o?this.svg:t.currentElement;if(!o&&l!==null&&u!==l&&l.parentNode===this.panel.svg){const m=this.svg.getAttribute("filter");return m!==null&&u.setAttribute("filter",m),this.svg.replaceWith(u),this.svg=u,u!==null&&this.P0(t,e,h,u),this.lA(t,l),!0}if(this.svg=u,f!==null&&u===null&&t.dummyGroup(),u===null)return!0;this.P0(t,e,h,u),this.TR(u,i,t,c);const d=this.Xs()?this.opacity*t.globalAlpha:this.opacity;if(d!==1&&u.setAttributeNS(null,"opacity",d.toString()),this.filter!==""&&u.setAttributeNS(null,"filter",this.filter),this.Xs()){if(l!==null&&u!==l&&l.parentNode===t.diagramGroup){const m=l.getAttribute("filter");m!==null&&u.setAttribute("filter",m),l.replaceWith(u)}else t.lastDrawnPart?t.lastDrawnPart.after(u):t.diagramGroup.prepend(u);t.lastDrawnPart=u}else e!==null&&this.oA(e,u);return f!==null&&f(this,u),this.rA(u),!0}rA(t){const i=this,e=t.dataset;i instanceof GraphObject&&(i.portId!==null&&(e.portId=i.portId),i instanceof Panel&&(isNaN(i.itemIndex)||(e.itemIndex=i.itemIndex.toString()),i instanceof Part&&(e.className=Util.sn(i),i.key!==void 0&&(e.key=i.key.toString()),i.containingGroup!==null&&(e.group=i.containingGroup.key.toString()),i instanceof Link&&(i.fromNode!==null&&i.fromNode.key!==void 0&&(e.fromKey=i.fromNode.key.toString()),i.fromPortId!==""&&(e.fromPortId=i.fromPortId),i.toNode!==null&&i.toNode.key!==void 0&&(e.toKey=i.toNode.key.toString()),i.toPortId!==""&&(e.toPortId=i.toPortId)))))}P0(t,i,e,s){let n=(this.n&256)!==0;if(t.clipInsteadOfFill&&(n=!1),!n){s.removeAttributeNS(null,"clip-path"),this.lA(t,s);return}const o=i.pn()?i.naturalBounds:i.actualBounds;let r=Math.max(e.x,o.x),l=Math.max(e.y,o.y),h=Math.min(e.right,o.right)-r,a=Math.min(e.bottom,o.bottom)-l;const c=this.si;c!==null&&(r=c.x,l=c.y,h=c.width,a=c.height);const f=s.getAttribute("clip-path");let u=null;if(f!==null&&(u=t.svg.getElementById(f.split("#")[1].slice(0,-1))),u===null){const d="CLIP"+GSet.nu++,m={id:d},g=t.makeElement("clipPath",m),p=t.makeElement("rect",{x:r,y:l,width:h,height:a});if(this instanceof Panel){const y=this.D.copy().yw();p.setAttribute("transform",`matrix(${y.m11}, ${y.m12}, ${y.m21}, ${y.m22}, ${y.dx}, ${y.dy})`)}g.appendChild(p),t.svg.appendChild(g),s.setAttributeNS(null,"clip-path","url(#"+d+")")}else{const d=u.firstElementChild;d.setAttribute("x",r.toString()),d.setAttribute("y",l.toString()),d.setAttribute("width",h.toString()),d.setAttribute("height",a.toString())}}lA(t,i){const e=i.getAttribute("clip-path");if(e===null)return;const s=t.svg.getElementById(e.split("#")[1].slice(0,-1));s!==null&&s.remove()}FR(){if(this.svg===null)return;const t=this.svg.innerHTML.match(/url\(#((CLIP|GRAD).+?)\)/g),i=this.svg.ownerDocument;if(t!==null)for(const e of t){const s=i.getElementById(e.split("#")[1].slice(0,-1));s!==null&&s.remove()}this.svg.remove()}LR(t,i){const e=this.Li,s=this.Vi,n=this.Ct;n!==null&&t.commitTransform(),n!==null&&(this.dn(t,n,!0,!1,s,e),n instanceof Brush&&n.type===3?(t.beginPath(),t.rect(e.x,e.y,e.width,e.height),t.fillContext(n,!1,null)):t.fillRect(e.x,e.y,e.width,e.height)),this.ch(t,i)}ch(t,i){}a2(){this.ss(!0)}Zc(t,i,e){const s=this.svg;if(this.RR()){if(this.a2(),this.ss(!1),s===null)return!1;const a=this.svg.getAttribute("clip-path");if(a!==null){const c=t.svg.getElementById(a.split("#")[1].slice(0,-1));c!==null&&c.remove()}return!1}if(s===null)return!1;if(!this.visible)return s.remove(),!1;if(s.nodeName!=="g"&&e||s.nodeName==="g"&&!e)return!1;const n=this.D,o="matrix("+n.m11+", "+n.m12+", "+n.m21+", "+n.m22+", "+n.dx+", "+n.dy+")",r=this instanceof Panel,l=this instanceof Panel?this._r():!1;if(!(r&&l))if(this instanceof Picture){const a=this.Ib;t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),a!==null&&t.amendImageTransform(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]),e?s.lastElementChild.setAttributeNS(null,"transform",t.getCurrentTransform()):s.setAttributeNS(null,"transform",t.getCurrentTransform())}else if(e&&!(this instanceof Panel))if(this instanceof Shape){const a=s.getElementsByTagName("path");for(let c=0;c=.1;){if(g){for(l=o[d++%h],l-=r;l<0;)l+=o[d++%h],m=!m;g=!1}else l=o[d++%h];l>u&&(l=u);let p=Math.sqrt(l*l/(1+f*f));a<0&&(p=-p),i+=p,e+=f*p,m?t.lineTo(i,e):t.moveTo(i,e),u-=l,m=!m}}dn(t,i,e,s,n,o){let r=1,l=1;if(typeof i=="string"){e?t.fillStyle=i:t.strokeStyle=i;return}else if(i.type===1){e?t.fillStyle=i.color:t.strokeStyle=i.color;return}let h;const a=this.Db();r=n.width,l=n.height,s?(r=o.width,l=o.height):e||(r+=a,l+=a);const c=t instanceof CanvasSurfaceContext;if(c&&i.yn&&(i.type===4||i.Qc===r&&i.Eb===l))h=i.yn;else{let f=0,u=0,d=0,m=0,g=0,p=0,y=0,x=0;if(s?(y=o.x,x=o.y):e||(y-=a/2,x-=a/2),f=i.start.x*r+i.start.offsetX+y,u=i.start.y*l+i.start.offsetY+x,d=i.end.x*r+i.end.offsetX+y,m=i.end.y*l+i.end.offsetY+x,i.type===2)h=t.createLinearGradient(f,u,d,m);else if(i.type===3)p=isNaN(i.endRadius)?Math.max(r,l)/2:i.endRadius,isNaN(i.startRadius)?(g=0,p=Math.max(r,l)/2):g=i.startRadius,h=t.createRadialGradient(f,u,g,d,m,p);else if(i.type===4)try{h=t.createPattern(i.pattern,"repeat")}catch{h=null}else Util.we(i.type,"Brush type");if(i.type!==4){const k=i.colorStops;if(k!==null){const b=k.iterator;for(;b.next();)h.addColorStop(b.key,b.value)}}if(c&&(i.yn=h,h!==null&&(i.Qc=r,i.Eb=l),h===null&&i.type===4&&i.Qc!==-1)){i.Qc=-1;const k=this.diagram;k!==null&&i.Qc===-1&&Util.vh(()=>{k.redraw()},600)}}e?t.fillStyle=h:t.strokeStyle=h}isContainedBy(t){return t instanceof Panel?this.vR(this,t):!1}vR(t,i){if(t===i||i===null)return!1;let e=t.panel;for(;e!==null;){if(e===i)return!0;e=e.panel}return!1}isVisibleObject(){if(!this.visible)return!1;const t=this.panel;return t!==null?t.isVisibleObject():!0}isEnabledObject(){let t=this instanceof Panel?this:this.panel;for(;t!==null&&t.isEnabled;)t=t.panel;return t===null}get enabledChanged(){return this.f!==null?this.f.M0:null}set enabledChanged(t){const i=this.enabledChanged;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"enabledChanged"),this.jt(),this.f.M0=t,this.t("enabledChanged",i,t))}Fb(){if(this.Ub()===!0){const t=this.$r;if(t.Ri(),!this.Li.isReal()||!this.ee.isReal()){this.nd(!1);return}if(t.Ds(this.Li.x-this.ee.x,this.Li.y-this.ee.y),this.scale!==1||this.angle!==0){const i=this.naturalBounds;this.y0(t,i.x,i.y,i.width,i.height)}this.nd(!1),this.ya(!0)}if(this.w0()===!0){const t=this.panel;if(t===null)this.oh.set(this.$r),this.aa=this.scale;else if(t.Es!==null){const i=this.oh;i.Ri(),t.pn()?i.tc(t.oh):t.panel!==null&&i.tc(t.panel.oh),i.tc(this.$r),this.aa=this.scale*t.aa}this.ya(!1)}}y0(t,i,e,s,n){if(this.st!==1&&t.st(this.st),this.Xt===0)return;const o=Point.l();o.setSpot(i,e,s,n,Spot.Center),t.cs(this.Xt,o.x,o.y),Point.s(o)}c(t){if(this.Oo())return;t===void 0&&(t=!1),this.fe(!0),this._n(!0);const i=this.panel;i!==null&&!t&&i.c()}_c(){this.Oo()||(this.fe(!0),this._n(!0))}tf(t){if(this.is())return;const i=this.panel;!t&&i!==null&&i.c(),this._n(!0)}td(){this.Ub()===!1&&(this.nd(!0),this.ya(!0))}c2(){this.ya(!0)}C(){const t=this.part;t!==null&&t.C()}zs(t){const i=this.stretch,e=this.panel;if(e===null)return this.zo(i===1?0:i,t);if(e.type===Panel.Table)return this.S0(e.getRowDefinition(this.row),e.getColumnDefinition(this.column),t);if(e.type===Panel.Auto&&e.findMainElement()===this)return this.zo(2,t);if(i===1){if(e.type===Panel.Spot&&e.findMainElement()===this)return this.zo(2,t);const s=e.defaultStretch;return s===1?this.zo(0,t):this.zo(s,t)}return this.zo(i,t)}S0(t,i,e){const s=this.stretch;if(s!==1)return this.zo(s,e);let n=null,o=null;switch(t.stretch){case 1:case 5:break;case 4:o=!0;break;case 2:o=!0;break}switch(i.stretch){case 1:case 4:break;case 5:n=!0;break;case 2:n=!0;break}const r=this.panel.defaultStretch;return n===null&&(n=r===5||r===2),o===null&&(o=r===4||r===2),n===!0&&o===!0?this.zo(2,e):n===!0?this.zo(5,e):o===!0?this.zo(4,e):this.zo(0,e)}zo(t,i){if(i)return t;if(t===0)return 0;const e=this.desiredSize;if(e.isReal())return 0;const s=!isNaN(e.width),n=!isNaN(e.height),o=this.angle;if(s)if(o!==90&&o!==270){if(t===5)return 0;if(t===2)return 4}else{if(t===4)return 0;if(t===2)return 5}if(n)if(o!==90&&o!==270){if(t===4)return 0;if(t===2)return 5}else{if(t===5)return 0;if(t===2)return 4}return t}get segmentOrientation(){return this.Ut!==null?this.Ut.N0:0}set segmentOrientation(t){const i=this.segmentOrientation;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.N0=t,this.c(),this.t("segmentOrientation",i,t),t===0&&(this.angle=0))}OR(){this.segmentOrientation=21}get segmentIndex(){return this.Ut!==null?this.Ut.C0:-1/0}set segmentIndex(t){t=Math.round(t);const i=this.segmentIndex;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.C0=t,this.c(),this.t("segmentIndex",i,t))}get segmentFraction(){return this.Ut!==null?this.Ut.L0:0}set segmentFraction(t){isNaN(t)||t<0?t=0:t>1&&(t=1);const i=this.segmentFraction;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.L0=t,this.c(),this.t("segmentFraction",i,t))}get segmentOffset(){return this.Ut!==null?this.Ut.A0:Point.Po}set segmentOffset(t){const i=this.segmentOffset;i.equals(t)||(t=t.N(),this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.A0=t,this.c(),this.t("segmentOffset",i,t))}get stretch(){return this.f!==null?this.f.to:1}set stretch(t){const i=this.stretch;i!==t&&(this.jt(),this.f.to=t,this.c(),this.t("stretch",i,t))}get name(){return this.f!==null?this.f.St:""}set name(t){const i=this.name;i!==t&&(this.jt(),this.f.St=t,this.part!==null&&this.part.T0(),this.t("name",i,t))}get opacity(){return this.Wt}set opacity(t){const i=this.Wt;if(i!==t){Util.i(t,"number",GraphObject,"opacity"),(t<0||t>1)&&Util._(t,"0 <= value <= 1",GraphObject,"opacity"),this.Wt=t,this.t("opacity",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.C(s.jh(s.actualBounds))}}get filter(){return this.Ju}set filter(t){const i=this.Ju;if(i!==t){this.Ju=t,this.ss(!0),this.t("filter",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.C(s.jh(s.actualBounds))}}get visible(){return(this.n&1)!==0}set visible(t){const i=(this.n&1)!==0;if(i!==t){this.n=this.n^1,this.t("visible",i,t);const e=this.panel;e!==null?e.c():this.Xs()&&this.Ei(t),this.C(),this.hA()}}get pickable(){return(this.n&2)!==0}set pickable(t){const i=(this.n&2)!==0;i!==t&&(this.n=this.n^2,this.t("pickable",i,t))}get fromLinkableDuplicates(){return(this.n&4)!==0}set fromLinkableDuplicates(t){const i=(this.n&4)!==0;i!==t&&(this.n=this.n^4,this.t("fromLinkableDuplicates",i,t))}get fromLinkableSelfNode(){return(this.n&8)!==0}set fromLinkableSelfNode(t){const i=(this.n&8)!==0;i!==t&&(this.n=this.n^8,this.t("fromLinkableSelfNode",i,t))}get toLinkableDuplicates(){return(this.n&16)!==0}set toLinkableDuplicates(t){const i=(this.n&16)!==0;i!==t&&(this.n=this.n^16,this.t("toLinkableDuplicates",i,t))}get toLinkableSelfNode(){return(this.n&32)!==0}set toLinkableSelfNode(t){const i=(this.n&32)!==0;i!==t&&(this.n=this.n^32,this.t("toLinkableSelfNode",i,t))}get isPanelMain(){return(this.n&64)!==0}set isPanelMain(t){const i=(this.n&64)!==0;i!==t&&(this.n=this.n^64,this.c(),this.t("isPanelMain",i,t))}get isActionable(){return(this.n&128)!==0}set isActionable(t){const i=(this.n&128)!==0;i!==t&&(this.n=this.n^128,this.t("isActionable",i,t))}get background(){return this.Ct}set background(t){const i=this.Ct;i!==t&&(t!==null&&Brush.od(t,"GraphObject.background"),t instanceof Brush&&t.g(),this.Ct=t,this.C(),this.t("background",i,t))}l2(){return(this.n&512)!==0}Ob(t){t?this.n|=512:this.n&=-513}Jc(){return(this.n&1024)!==0}f2(t){t?this.n|=1024:this.n&=-1025}Ub(){return(this.n&2048)!==0}nd(t){t?this.n|=2048:this.n&=-2049}w0(){return(this.n&4096)!==0}ya(t){t?this.n|=4096:this.n&=-4097}Oo(){return(this.n&8192)!==0}fe(t){t?this.n|=8192:this.n&=-8193}is(){return(this.n&16384)!==0}_n(t){t?this.n|=16384:this.n&=-16385}RR(){return(this.n&32768)!==0}ss(t){t?this.n|=32768:this.n&=-32769}get part(){if(this.Xs())return this;if(this.Qr!==null)return this.Qr;let t=this;for(t=t.panel;t;){if(t instanceof Part)return this.Qr=t,t;t=t.panel}return null}get svg(){return this.e2}set svg(t){this.e2=t}Fu(){this.svg=null}get panel(){return this.Vs}wa(t){this.Vs=t,this.svg!==null&&this.svg.remove()}get layer(){const t=this.part;return t!==null?t.layer:null}get diagram(){const t=this.part;return t!==null?t.diagram:null}get position(){return this.ct}set position(t){const i=t.x,e=t.y,s=this.ct,n=s.x,o=s.y;n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e))?(t=t.copy(),this.u2(t,n,o)&&this.t("position",new Point(n,o),t)):this.d2()}d2(){}u2(t,i,e){return this.ct=t,this.tf(),!0}xc(t,i,e){this.ct.x===t&&this.ct.y===i||(this.ct.e(t,i),this.td())}get actualBounds(){return this.Li}get scale(){return this.st}set scale(t){const i=this.st;i!==t&&(t<=0&&Util.o("GraphObject.scale for "+this+" must be greater than zero, not: "+t),this.st=t,this.c(),this.t("scale",i,t))}get angle(){return this.Xt}set angle(t){const i=this.Xt;if(i!==t){if(t=t%360,t<0&&(t+=360),i===t)return;this.Xt=t,this.hA(),this.c(),this.t("angle",i,t)}}get desiredSize(){return this.ze}set desiredSize(t){const i=t.width,e=t.height,s=this.ze,n=s.width,o=s.height;if((n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e)))&&(t=t.N(),this.ze=t,this.c(),this instanceof Shape&&this.ie(),this.t("desiredSize",s,t),this.Jc())){const r=this.part;r!==null&&(this.pa(r,"width"),this.pa(r,"height"))}}get width(){return this.ze.width}set width(t){const i=this.ze.width;if(i!==t&&(!isNaN(i)||!isNaN(t))){const e=this.ze,s=new Size(t,this.ze.height).g();if(this.ze=s,this.c(),this instanceof Shape&&this.ie(),this.t("desiredSize",e,s),this.Jc()){const n=this.part;n!==null&&this.pa(n,"width")}}}get height(){return this.ze.height}set height(t){const i=this.ze.height;if(i!==t&&(!isNaN(i)||!isNaN(t))){const e=this.ze,s=new Size(this.ze.width,t).g();if(this.ze=s,this.c(),this instanceof Shape&&this.ie(),this.t("desiredSize",e,s),this.Jc()){const n=this.part;n!==null&&this.pa(n,"height")}}}get minSize(){return this.f!==null?this.f.xr:Size.lu}set minSize(t){const i=this.minSize;i.equals(t)||(t=t.copy(),isNaN(t.width)&&(t.width=0),isNaN(t.height)&&(t.height=0),t.g(),this.jt(),this.f.xr=t,this.c(),this.t("minSize",i,t))}get maxSize(){return this.f!==null?this.f.br:Size.sC}set maxSize(t){const i=this.maxSize;i.equals(t)||(t=t.copy(),isNaN(t.width)&&(t.width=1/0),isNaN(t.height)&&(t.height=1/0),t.g(),this.jt(),this.f.br=t,this.c(),this.t("maxSize",i,t))}get measuredBounds(){return this.ee}get naturalBounds(){return this.Vi}Db(){return 0}get margin(){return this.Zr}set margin(t){typeof t=="number"&&(t=new Margin(t));const i=this.Zr;i.equals(t)||(t=t.N(),this.Zr=t,this.c(),this.t("margin",i,t))}get D(){return this.Ub()===!0&&this.Fb(),this.$r}get Es(){return this.w0()===!0&&this.Fb(),this.oh}trigger(t,i,e){let s=null;return typeof t=="string"?s=new AnimationTrigger(t,i,e):s=t,s.ke=this,this.ys===null&&(this.ys=new GMap),this.ys.set(s.propertyName,s),this}get ys(){return this.f!==null?this.f.ys:null}set ys(t){this.ys!==t&&(this.jt(),this.f.ys=t)}get wr(){return this.f!==null?this.f.wr:0}set wr(t){this.wr!==t&&(this.jt(),this.f.wr=t)}get alignment(){return this.ni}set alignment(t){const i=this.ni;i.equals(t)||(t.isNoSpot()&&!t.isDefault()&&Util.o("GraphObject.alignment for "+this+" must be a real Spot or Spot.Default, not: "+t),t=t.N(),this.ni=t,this.tf(),this.t("alignment",i,t))}get column(){return this.Bo}set column(t){t=Math.round(t);const i=this.Bo;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"column"),this.Bo=t,this.c(),this.t("column",i,t),this.svg!==null&&this.svg.remove())}get columnSpan(){return this.f!==null?this.f.D0:1}set columnSpan(t){t=Math.round(t);const i=this.columnSpan;i!==t&&(t<1&&Util._(t,">= 1",GraphObject,"columnSpan"),this.jt(),this.f.D0=t,this.c(),this.t("columnSpan",i,t))}get row(){return this.Wu}set row(t){t=Math.round(t);const i=this.Wu;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"row"),this.Wu=t,this.c(),this.t("row",i,t),this.svg!==null&&this.svg.remove())}get rowSpan(){return this.f!==null?this.f.F0:1}set rowSpan(t){t=Math.round(t);const i=this.rowSpan;i!==t&&(t<1&&Util._(t,">= 1",GraphObject,"rowSpan"),this.jt(),this.f.F0=t,this.c(),this.t("rowSpan",i,t))}get spanAllocation(){return this.f!==null?this.f.R0:null}set spanAllocation(t){const i=this.spanAllocation;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"spanAllocation"),this.jt(),this.f.R0=t,this.c(),this.t("spanAllocation",i,t))}get alignmentFocus(){return this.qc}set alignmentFocus(t){const i=this.qc;i.equals(t)||(t=t.N(),this.qc=t,this.c(),this.t("alignmentFocus",i,t))}get portId(){return this.qu}set portId(t){const i=this.qu;if(i!==t){const e=this.part;e!==null&&!(e instanceof Node)&&Util.o("Cannot set portID on a Link: "+t);const s=e;i!==null&&s!==null&&s.g2(this),this.qu=t,t!==null&&s!==null&&(s.wn=!0,s.aA(this)),this.t("portId",i,t)}}xa(){const t=this.part;if(t instanceof Node&&(this.portId!==null||this===t.port)){const i=t.diagram;i!==null&&!i.undoManager.isUndoingRedoing&&t.iA(this)}}hA(){const t=this.diagram;t===null||t.undoManager.isUndoingRedoing||(this instanceof Panel?this instanceof Node?this.invalidateConnectedLinks():this.walkVisualTreeFrom(this,i=>{i.xa()}):this.xa())}get toSpot(){return this.q!==null?this.q.fa:Spot.None}set toSpot(t){const i=this.toSpot;i.equals(t)||(t=t.N(),this.Xe(),this.q.fa=t,this.t("toSpot",i,t),this.xa())}get toEndSegmentLength(){return this.q!==null?this.q.da:10}set toEndSegmentLength(t){const i=this.toEndSegmentLength;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"toEndSegmentLength"),this.Xe(),this.q.da=t,this.t("toEndSegmentLength",i,t),this.xa())}get toShortLength(){return this.q!==null?this.q.ma:0}set toShortLength(t){const i=this.toShortLength;i!==t&&(this.Xe(),this.q.ma=t,this.t("toShortLength",i,t),this.xa())}get toLinkable(){return this.q!==null?this.q.v0:null}set toLinkable(t){const i=this.toLinkable;i!==t&&(this.Xe(),this.q.v0=t,this.t("toLinkable",i,t))}get toMaxLinks(){return this.q!==null?this.q.O0:1/0}set toMaxLinks(t){const i=this.toMaxLinks;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"toMaxLinks"),this.Xe(),this.q.O0=t,this.t("toMaxLinks",i,t))}get fromSpot(){return this.q!==null?this.q.ca:Spot.None}set fromSpot(t){const i=this.fromSpot;i.equals(t)||(t=t.N(),this.Xe(),this.q.ca=t,this.t("fromSpot",i,t),this.xa())}get fromEndSegmentLength(){return this.q!==null?this.q.ua:10}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"fromEndSegmentLength"),this.Xe(),this.q.ua=t,this.t("fromEndSegmentLength",i,t),this.xa())}get fromShortLength(){return this.q!==null?this.q.ga:0}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(this.Xe(),this.q.ga=t,this.t("fromShortLength",i,t),this.xa())}get fromLinkable(){return this.q!==null?this.q.I0:null}set fromLinkable(t){const i=this.fromLinkable;i!==t&&(this.Xe(),this.q.I0=t,this.t("fromLinkable",i,t))}get fromMaxLinks(){return this.q!==null?this.q.E0:1/0}set fromMaxLinks(t){const i=this.fromMaxLinks;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"fromMaxLinks"),this.Xe(),this.q.E0=t,this.t("fromMaxLinks",i,t))}get cursor(){return this.f!==null?this.f.Ml:""}set cursor(t){const i=this.cursor;i!==t&&(Util.i(t,"string",GraphObject,"cursor"),this.jt(),this.f.Ml=t,this.t("cursor",i,t))}get click(){return this.f!==null?this.f.Tr:null}set click(t){const i=this.click;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"click"),this.jt(),this.f.Tr=t,this.t("click",i,t))}get doubleClick(){return this.f!==null?this.f.Dr:null}set doubleClick(t){const i=this.doubleClick;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"doubleClick"),this.jt(),this.f.Dr=t,this.t("doubleClick",i,t))}get contextClick(){return this.f!==null?this.f.Fr:null}set contextClick(t){const i=this.contextClick;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"contextClick"),this.jt(),this.f.Fr=t,this.t("contextClick",i,t))}get mouseEnter(){return this.f!==null?this.f.Er:null}set mouseEnter(t){const i=this.mouseEnter;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseEnter"),this.jt(),this.f.Er=t,this.t("mouseEnter",i,t))}get mouseLeave(){return this.f!==null?this.f.Ur:null}set mouseLeave(t){const i=this.mouseLeave;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseLeave"),this.jt(),this.f.Ur=t,this.t("mouseLeave",i,t))}get mouseOver(){return this.f!==null?this.f.Rr:null}set mouseOver(t){const i=this.mouseOver;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseOver"),this.jt(),this.f.Rr=t,this.t("mouseOver",i,t))}get mouseHover(){return this.f!==null?this.f.vr:null}set mouseHover(t){const i=this.mouseHover;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseHover"),this.jt(),this.f.vr=t,this.t("mouseHover",i,t))}get mouseHold(){return this.f!==null?this.f.Or:null}set mouseHold(t){const i=this.mouseHold;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseHold"),this.jt(),this.f.Or=t,this.t("mouseHold",i,t))}get mouseDragEnter(){return this.f!==null?this.f.U0:null}set mouseDragEnter(t){const i=this.mouseDragEnter;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDragEnter"),this.jt(),this.f.U0=t,this.t("mouseDragEnter",i,t))}get mouseDragLeave(){return this.f!==null?this.f.B0:null}set mouseDragLeave(t){const i=this.mouseDragLeave;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDragLeave"),this.jt(),this.f.B0=t,this.t("mouseDragLeave",i,t))}get mouseDrop(){return this.f!==null?this.f.Ir:null}set mouseDrop(t){const i=this.mouseDrop;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDrop"),this.jt(),this.f.Ir=t,this.t("mouseDrop",i,t))}get actionDown(){return this.f!==null?this.f.V0:null}set actionDown(t){const i=this.actionDown;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionDown"),this.jt(),this.f.V0=t,this.t("actionDown",i,t))}get actionMove(){return this.f!==null?this.f.z0:null}set actionMove(t){const i=this.actionMove;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionMove"),this.jt(),this.f.z0=t,this.t("actionMove",i,t))}get actionUp(){return this.f!==null?this.f.X0:null}set actionUp(t){const i=this.actionUp;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionUp"),this.jt(),this.f.X0=t,this.t("actionUp",i,t))}get actionCancel(){return this.f!==null?this.f.K0:null}set actionCancel(t){const i=this.actionCancel;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionCancel"),this.jt(),this.f.K0=t,this.t("actionCancel",i,t))}get toolTip(){return this.f!==null?this.f.Br:null}set toolTip(t){const i=this.toolTip;i!==t&&(this.jt(),this.f.Br=t,this.t("toolTip",i,t))}get contextMenu(){return this.f!==null?this.f.Vr:null}set contextMenu(t){const i=this.contextMenu;i!==t&&(this.jt(),this.f.Vr=t,this.t("contextMenu",i,t))}findBindingPanel(){let t=this instanceof Panel?this:this.panel;for(;t!==null;){if(t.m2())return t;t=t.panel}return null}bind(t,i,e,s){return this.ef(t,i,e,s),this}bindTwoWay(t,i,e,s){return this.ef(t,i,e,s).makeTwoWay(),this}bindModel(t,i,e,s){return this.ef(t,i,e,s).ofModel(),this}bindObject(t,i,e,s,n){return this.ef(t,i,e,s).ofObject(n),this}theme(t,i,e,s,n){return this.fh(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.fh(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.fh(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.fh(t,i,e,s,n).ofModel(),this}ef(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.Y0(n),n}fh(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.Y0(o),o}Y0(t){t.ke=this;const i=this.findBindingPanel();i!==null&&i.cA()&&Util.o("Cannot add a Binding to a template that has already been copied: "+t),this.Ai===null&&(this.Ai=new List),this.Ai.add(t)}set(t){return Object.assign(this,t),this}attach(t){return GraphObject.p2(this,t),this}apply(t){return t(this),this}setProperties(t){return Diagram.a0(this,t),this}static build(t,i,...e){const s=GraphObject.G0.get(t);if(typeof s=="function"){const n=s([t].concat(e));if(n instanceof GraphObject)return i&&n.setProperties(i),n}Util.o('GraphObject.build invoked object builder "'+t+'", but it did not return an Object')}static make(t,...i){let e=arguments,s=null,n=null;if(typeof t=="function")n=t;else if(typeof t=="string"){const r=GraphObject.G0.get(t);typeof r=="function"?(e=Array.prototype.slice.call(e),s=r(e),Util.wt(s)||Util.o('GraphObject.make invoked object builder "'+t+'", but it did not return an Object')):n=root.go[t]}s===null&&((n==null||!n.constructor)&&Util.o("GraphObject.make requires a class function or GoJS class name or name of an object builder, not: "+t),s=new n);let o=1;if(s instanceof Diagram&&e.length>1){const r=s,l=e[1];(typeof l=="string"||l instanceof HTMLDivElement)&&(r.mS(l),o++)}for(let r=o;r{const i="#f5f5f5",e="#737373",s="#d4d4d4",n="#737373",o="#a3a3a3",r=2.76142374915397,l=2.761423749153969,h=new Panel(Panel.Auto,{isActionable:!0,enabledChanged:(a,c)=>{if(a instanceof Panel){const f=a.findObject("ButtonBorder");f!==null&&(c?(a._buttonFillDisabled=f.fill,f.fill=a._buttonFillNormal):(a._buttonFillNormal=f.fill,f.fill=a._buttonFillDisabled))}},cursor:"pointer"}).attach({_buttonFillNormal:i,_buttonStrokeNormal:e,_buttonFillOver:s,_buttonStrokeOver:n,_buttonFillDisabled:o}).add(new Shape("RoundedRectangle",{name:"ButtonBorder",spot1:new Spot(0,0,r,l),spot2:new Spot(1,1,-r,-l),parameter1:2,fill:i,stroke:e}));return h.mouseEnter=(a,c,f)=>{if(!c.isEnabledObject()||!(c instanceof Panel))return;const u=c.findObject("ButtonBorder");u instanceof Shape&&(c._buttonFillNormal=u.fill,u.fill=c._buttonFillOver,c._buttonStrokeNormal=u.stroke,u.stroke=c._buttonStrokeOver)},h.mouseLeave=(a,c,f)=>{if(!c.isEnabledObject()||!(c instanceof Panel))return;const u=c.findObject("ButtonBorder");u instanceof Shape&&(u.fill=c._buttonFillNormal,u.stroke=c._buttonStrokeNormal)},h}),GraphObject.defineBuilder("TreeExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_treeExpandedFigure:"MinusLine",_treeCollapsedFigure:"PlusLine",visible:!1}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.hu}).bindObject("figure","isTreeExpanded",(e,s)=>{const n=s.panel;return e?n._treeExpandedFigure:n._treeCollapsedFigure})),i.bindObject("visible","isTreeLeaf",e=>!e),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Node))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isTreeExpanded){if(!r.canCollapseTree(n))return}else if(!r.canExpandTree(n))return;e.handled=!0,n.isTreeExpanded?r.collapseTree(n):r.expandTree(n)},i}),GraphObject.defineBuilder("SubGraphExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_subGraphExpandedFigure:"MinusLine",_subGraphCollapsedFigure:"PlusLine"}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.hu}).bindObject("figure","isSubGraphExpanded",(e,s)=>{const n=s.panel;return e?n._subGraphExpandedFigure:n._subGraphCollapsedFigure})),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Group))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isSubGraphExpanded){if(!r.canCollapseSubGraph(n))return}else if(!r.canExpandSubGraph(n))return;e.handled=!0,n.isSubGraphExpanded?r.collapseSubGraph(n):r.expandSubGraph(n)},i}),GraphObject.defineBuilder("ToolTip",t=>new Adornment(Panel.Auto,{isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).add(new Shape("RoundedRectangle",{name:"Border",parameter1:1,fill:"#f5f5f5",strokeWidth:0,spot1:new Spot(0,0,4,6),spot2:new Spot(1,1,-4,-4)}))),GraphObject.defineBuilder("ContextMenu",t=>new Adornment(Panel.Vertical,{background:"#f5f5f5",isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).bindObject("background","",i=>i.adornedPart!==null&&i.hasPlaceholder()?null:"#f5f5f5")),GraphObject.defineBuilder("ContextMenuButton",t=>{const i=GraphObject.build("Button");i.stretch=5;const e=i.findObject("ButtonBorder");return e instanceof Shape&&(e.figure="Rectangle",e.strokeWidth=0,e.spot1=new Spot(0,0,4,6),e.spot2=new Spot(1,1,-4,-4)),i}),GraphObject.defineBuilder("PanelExpanderButton",t=>{const i=GraphObject.takeBuilderArgument(t,"COLLAPSIBLE"),e=GraphObject.build("Button");e.attach({_buttonExpandedFigure:"M0 0 M0 6 L4 2 8 6 M8 8",_buttonCollapsedFigure:"M0 0 M0 2 L4 6 8 2 M8 8",_buttonFillNormal:"rgba(0, 0, 0, 0)",_buttonStrokeNormal:null,_buttonFillOver:"rgba(0, 0, 0, .2)",_buttonStrokeOver:null}),e.add(new Shape({name:"ButtonIcon",strokeWidth:2}).bindObject("geometryString","visible",n=>n?e._buttonExpandedFigure:e._buttonCollapsedFigure,void 0,i));const s=e.findObject("ButtonBorder");return s instanceof Shape&&(s.stroke=null,s.fill="rgba(0, 0, 0, 0)"),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=o.diagram;if(r===null||r.isReadOnly)return;let l=o.findBindingPanel();if(l===null&&(l=o.part),l!==null){const h=l.findObject(i);h!==null&&(n.handled=!0,r.startTransaction("Collapse/Expand Panel"),h.visible=!h.visible,r.commitTransaction("Collapse/Expand Panel"))}},e}),GraphObject.defineBuilder("CheckBoxButton",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("Button",{desiredSize:new Size(14,14)});e.attach({"ButtonBorder.spot1":new Spot(0,0,1,1),"ButtonBorder.spot2":new Spot(1,1,-1,-1)});const s=new Shape({name:"ButtonIcon",geometryString:"M0 0 M0 8.85 L4.9 13.75 16.2 2.45 M16.2 16.2",strokeWidth:2,stretch:2,geometryStretch:6,visible:!1});return i!==""&&s.bindTwoWay("visible",i),e.add(s),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=n.diagram;if(r===null||r.isReadOnly||i!==""&&r.model.isReadOnly)return;n.handled=!0;const l=o.findObject("ButtonIcon");r.startTransaction("checkbox"),l!==null&&(l.visible=!l.visible),typeof o._doClick=="function"&&o._doClick(n,o),r.commitTransaction("checkbox")},e}),GraphObject.defineBuilder("CheckBox",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("CheckBoxButton",{name:"Button",isActionable:!1,margin:new Margin(0,1,0,0)},i),s=new Panel("Horizontal",{isActionable:!0,cursor:e.cursor,margin:new Margin(1),mouseEnter:e.mouseEnter,mouseLeave:e.mouseLeave,click:e.click}).attach({_buttonFillNormal:e._buttonFillNormal,_buttonStrokeNormal:e._buttonStrokeNormal,_buttonFillOver:e._buttonFillOver,_buttonStrokeOver:e._buttonStrokeOver,_buttonFillDisabled:e._buttonFillDisabled,_buttonClick:e.click});return s.add(e),e.mouseEnter=null,e.mouseLeave=null,e.click=null,s})}}class GraphObjectTemplateSettings{gi;St;$n;Ai;Zn;Ks;Ml;Tr;Dr;Fr;Er;Ur;Rr;vr;Or;U0;B0;Ir;V0;z0;X0;K0;Br;Vr;M0;R0;ys;xr;br;to;F0;D0;wr;k0;j0;H0;constructor(){this.gi=!1,this.St="",this.$n=-1,this.Ai=null,this.Zn=null,this.Ks=null,this.Ml="",this.Tr=null,this.Dr=null,this.Fr=null,this.Er=null,this.Ur=null,this.Rr=null,this.vr=null,this.Or=null,this.U0=null,this.B0=null,this.Ir=null,this.V0=null,this.z0=null,this.X0=null,this.K0=null,this.Br=null,this.Vr=null,this.M0=null,this.R0=null,this.ys=null,this.xr=Size.lu,this.br=Size.sC,this.to=1,this.F0=1,this.D0=1,this.wr=0,this.k0=null,this.j0=null,this.H0="category"}copy(){const t=new GraphObjectTemplateSettings;return t.St=this.St,t.$n=this.$n,t.Ai=this.Ai,t.Ks=this.Ks,t.Ml=this.Ml,t.Tr=this.Tr,t.Dr=this.Dr,t.Fr=this.Fr,t.Er=this.Er,t.Ur=this.Ur,t.Rr=this.Rr,t.vr=this.vr,t.Or=this.Or,t.U0=this.U0,t.B0=this.B0,t.Ir=this.Ir,t.V0=this.V0,t.z0=this.z0,t.X0=this.X0,t.K0=this.K0,t.Br=this.Br,t.Vr=this.Vr,t.M0=this.M0,t.R0=this.R0,t.ys=this.ys,t.xr=this.xr.N(),t.br=this.br.N(),t.to=this.to,t.F0=this.F0,t.D0=this.D0,t.wr=this.wr,t.k0=this.k0,t.j0=this.j0,t.H0=this.H0,t}}class STransform{m;constructor(){this.m=[1,0,0,1,0,0]}copy(){const t=new STransform;return t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5],t}translate(t,i){this.m[4]+=this.m[0]*t+this.m[2]*i,this.m[5]+=this.m[1]*t+this.m[3]*i}scale(t,i){this.m[0]*=t,this.m[1]*=t,this.m[2]*=i,this.m[3]*=i}rotate(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return;this.translate(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m[0]*s+this.m[2]*n,r=this.m[1]*s+this.m[3]*n,l=this.m[0]*-n+this.m[2]*s,h=this.m[1]*-n+this.m[3]*s;this.m[0]=o,this.m[1]=r,this.m[2]=l,this.m[3]=h,this.translate(-i,-e)}}class SGradient{type;x1;y1;r1;x2;y2;r2;colors;pattern;constructor(t){this.type=t,this.x1=0,this.y1=0,this.r1=0,this.x2=0,this.y2=0,this.r2=0,this.colors=[],this.pattern=null}addColorStop(t,i){this.colors.push({offset:t,color:i})}}class SVGSurface{Ft;ai;ha;ju;w2;constructor(t,i,e){const s=i===void 0?root.document:i;this.ha=s,this.w2="http://www.w3.org/2000/svg";const n="http://www.w3.org/2000/xmlns/";s!==void 0&&(this.Ft=this.makeElement("svg",{width:"1px",height:"1px",viewBox:"0 0 1 1"}),this.style.display="block",this.style.letterSpacing="normal",this.style.wordSpacing="normal",e||(this.style.position="absolute"),this.Ft.setAttributeNS(n,"xmlns",this.w2),this.Ft.setAttributeNS(n,"xmlns:xlink","http://www.w3.org/1999/xlink")),this.ju=null,this.ai=new SVGContext(this,e)}resize(t,i,e,s){return this.width!==t||this.height!==i?(this.width=t,this.height=i,this.style.width=e+"px",this.style.height=s+"px",this.Ft.setAttributeNS(null,"width",e+"px"),this.Ft.setAttributeNS(null,"height",s+"px"),this.Ft.setAttributeNS(null,"viewBox","0 0 "+e+" "+s),this.ai.b2.firstElementChild.setAttributeNS(null,"width",e+"px"),this.ai.b2.firstElementChild.setAttributeNS(null,"height",s+"px"),!0):!1}makeElement(t,i,e){const s=this.ha.createElementNS(this.w2,t);if(Util.wt(i))for(const n in i)s.setAttributeNS(n==="href"?"http://www.w3.org/1999/xlink":"",n,i[n]);return e!==void 0&&(s.textContent=e),s}getBoundingClientRect(){return this.Ft.getBoundingClientRect()}focus(){this.Ft.focus()}get width(){return this.Ft.width.baseVal.value}set width(t){this.Ft.setAttribute("width",t+"px")}get height(){return this.Ft.height.baseVal.value}set height(t){this.Ft.setAttribute("height",t+"px")}dispose(){this.ha=null}get style(){return this.Ft.style}}class SVGContext{sf;nf;xn;Ti;Ke;fillStyle;font;globalAlpha;lineCap;lineDashOffset;lineJoin;lineWidth;miterLimit;shadowBlur;shadowColor;shadowOffsetX;shadowOffsetY;strokeStyle;textAlign;imageSmoothingEnabled;clipInsteadOfFill;lastCreatedElement;of;rf;surface;svg;b2;fA;Vb;Xo;uh;ba;currentElement;clipPathGroup;diagramGroup;lastDrawnPart;currentPath;outerGroup;pathAttributes;tl;Sr;filter;partClipRect;constructor(t,i){this.surface=t,this.svg=t.Ft,this.of=[],this.rf=[],this.fillStyle="#000000",this.font="10px sans-serif",this.globalAlpha=1,this.lineCap="butt",this.lineDashOffset=0,this.lineJoin="miter",this.lineWidth=1,this.miterLimit=10,this.shadowBlur=0,this.shadowColor="rgba(0, 0, 0, 0)",this.shadowOffsetX=0,this.shadowOffsetY=0,this.tl=!1,this.strokeStyle="#000000",this.textAlign="start",this.clipInsteadOfFill=!1,this.sf=0,this.nf=0,this.xn=0,this.lastCreatedElement=null,this.currentElement=null,this.Ti=[],this.pathAttributes={},this.Vb=!1,this.Xo=null,this.uh=0,this.Ke=new STransform,this.clipPathGroup=this.newGroup2(),this.diagramGroup=this.newGroup2("gojs-diagram"),this.lastDrawnPart=null,this.currentPath=null;const e=GSet.nu++,s=this.makeElement("clipPath",{id:"mainClip"+e}),n={x:0,y:0,width:t.width,height:t.height};s.appendChild(this.makeElement("rect",n)),this.b2=s,this.svg.appendChild(this.clipPathGroup),this.clipPathGroup.appendChild(this.diagramGroup),this.svg.appendChild(s),this.clipPathGroup.setAttributeNS(null,"clip-path","url(#mainClip"+e+")"),this.fA={},this.Sr=!!i,this.filter="",this.partClipRect=null}setDiagramPosScale(t,i,e,s,n,o){this.diagramGroup===void 0?this.newGroup(t,i,e,s,n,o):this.diagramGroup.setAttribute("transform","matrix("+t+", "+i+", "+e+", "+s+", "+n+", "+o+")")}resetInnerSVG(){this.diagramGroup!==null&&(this.diagramGroup.innerHTML="")}arc(t,i,e,s,n,o,r,l){const h=2*Math.PI,a=1e-6,c=h-a,f=e*Math.cos(s),u=e*Math.sin(s),d=t+f,m=i+u,g=o?0:1;let p=o?s-n:n-s;(Math.abs(r-d)>a||Math.abs(l-m)>a)&&this.Ti.push(["L",d,+m]),p<0&&(p=p%h+h),p>c?(this.Ti.push(["A",e,e,0,1,g,t-f,i-u]),this.Ti.push(["A",e,e,0,1,g,d,m])):p>a&&this.Ti.push(["A",e,e,0,+(p>=Math.PI),g,t+e*Math.cos(n),i+e*Math.sin(n)])}beginPath(){this.Ti=[],this.pathAttributes={stroke:"none",fill:"none"}}endPath(t){this.BR(this.Ti,this.Ke,t||0)}bezierCurveTo(t,i,e,s,n,o){this.Ti.push(["C",t,i,e,s,n,o])}clearRect(t,i,e,s){}clip(){this.pathAttributes.clipPath=!0}closePath(){this.Ti.push(["z"])}createLinearGradient(t,i,e,s){const n=new SGradient("linear");return n.x1=t,n.y1=i,n.x2=e,n.y2=s,n}createPattern(t,i){let e="";t instanceof HTMLCanvasElement&&(e=t.toDataURL()),t instanceof HTMLImageElement&&(e=t.getAttribute("src"));const s=this.fA;if(s[e])return"url(#"+s[e]+")";const n="PATTERN"+GSet.nu++,o={width:t.width,height:t.height,id:n,patternUnits:"userSpaceOnUse"},r={x:0,y:0,width:t.width,height:t.height,href:e},l=this.makeElement("pattern",o);return l.appendChild(this.makeElement(Diagram.img,r)),this.svg.appendChild(l),s[e]=n,"url(#"+n+")"}createRadialGradient(t,i,e,s,n,o){const r=new SGradient("radial");return r.x1=t,r.y1=i,r.r1=e,r.x2=s,r.y2=n,r.r2=o,r}amendImageTransform(t,i,e,s,n,o,r,l){const h=r/e,a=l/s;(n!==0||o!==0)&&this.Ke.translate(n,o),(h!==1||a!==1)&&this.Ke.scale(h,a),(t!==0||i!==0)&&this.Ke.translate(-t,-i)}drawImage(t,i,e,s,n,o,r,l,h){let a="";t instanceof HTMLCanvasElement&&(a=t.toDataURL()),t instanceof HTMLImageElement&&(a=t.getAttribute("src"));const c=t instanceof HTMLImageElement?t.naturalWidth:t.width,f=t instanceof HTMLImageElement?t.naturalHeight:t.height;s===void 0&&(o=i,r=e,l=s=c,h=n=f),s=s||0,n=n||0,o=o||0,r=r||0,l=l||0,h=h||0,this.amendImageTransform(i,e,s,n,o,r,l,h);const u={x:0,y:0,width:c||s,height:f||n,href:a};!Geo.K(s,l)||!Geo.K(n,h)?u.preserveAspectRatio="none":a.toLowerCase().indexOf(".svg")===-1&&a.toLowerCase().indexOf("data:image/svg")===-1&&(u.preserveAspectRatio="xMidYMid slice"),(i!==0||e!==0||s!==c||n!==f)&&(s+=i,n+=e,u["clip-path"]=`path('M ${i},${e} L ${s} ${e} L ${s} ${n} L ${i} ${n} z')`),this.processCommon(Diagram.img,u,this.Ke),this.rd(Diagram.img,u)}fill(t,i){t&&(this.pathAttributes["fill-rule"]="evenodd"),this.setFill(this.pathAttributes)}fillContext(t,i,e){this.clipInsteadOfFill?this.clip():this.fill(i,e)}fillRect(t,i,e,s){this.addRect("fill",[t,i,e,s],this.Ke)}fillBackground(t,i,e,s){const n={x:t,y:i,width:e,height:s};this.processCommon("fill",n,this.Ke),this.setFill(n),this.svg.prepend(this.makeElement("rect",n))}fillText(t,i,e){this.addText("fill",[t,i,e],this.Ke)}lineTo(t,i){this.Ti.push(["L",t,i])}moveTo(t,i){this.Ti.push(["M",t,i])}quadraticCurveTo(t,i,e,s){this.Ti.push(["Q",t,i,e,s])}rect(t,i,e,s){this.Ti.push(["M",t,i],["L",t+e,i],["L",t+e,i+s],["L",t,i+s],["z"])}restore(){this.Ke=this.of.pop(),this.Ti=this.of.pop();const t=this.of.pop();this.fillStyle=t.fillStyle,this.font=t.font,this.globalAlpha=t.globalAlpha,this.lineCap=t.lineCap,this.lineDashOffset=t.lineDashOffset,this.lineJoin=t.lineJoin,this.lineWidth=t.lineWidth,this.miterLimit=t.miterLimit,this.shadowBlur=t.shadowBlur,this.shadowColor=t.shadowColor,this.shadowOffsetX=t.shadowOffsetX,this.shadowOffsetY=t.shadowOffsetY,this.strokeStyle=t.strokeStyle,this.textAlign=t.textAlign,this.partClipRect=t.partClipRect}save(){const t={fillStyle:this.fillStyle,font:this.font,globalAlpha:this.globalAlpha,lineCap:this.lineCap,lineDashOffset:this.lineDashOffset,lineJoin:this.lineJoin,lineWidth:this.lineWidth,miterLimit:this.miterLimit,shadowBlur:this.shadowBlur,shadowColor:this.shadowColor,shadowOffsetX:this.shadowOffsetX,shadowOffsetY:this.shadowOffsetY,strokeStyle:this.strokeStyle,textAlign:this.textAlign,partClipRect:this.partClipRect};this.of.push(t);const i=[];for(let e=0;eh.offset>a.offset?1:-1);for(let h=0;h0&&this.rf[this.rf.length-1].setAttributeNS(null,"clip-path",'path("'+s+'")');return}if(n.d=s,this.processCommon("",n,i),this.currentPath!==null){const r=this.currentPath;if(r.nodeName!=="g")for(const l in n)l!=="transform"&&r.setAttributeNS(null,l,n[l]);else{const l=r.getElementsByTagName("path");for(const h in n)h!=="transform"&&l[e].setAttributeNS(null,h,n[h])}}else this.rd("path",n)}VR(t){const i=[];for(let e=0;es?(this.scale(s/n,1),this.translate((n-s)/2,0)):s>n&&(this.scale(1,n/s),this.translate(0,(s-n)/2)),this.fillOrClip(i,e),n>s?(this.translate(-(n-s)/2,0),this.scale(1/(s/n),1)):s>n&&(this.translate(0,-(s-n)/2),this.scale(1,1/(n/s))),!0}strokeContext(){this.q0||this.stroke()}fillOrClip(t,i){this.q0?this.clip(i):this.fill(t,i)}get clipInsteadOfFill(){return this.q0}set clipInsteadOfFill(t){this.q0=t}shadowsSet(t,i,e){this.sf=t,this.nf=i,this.xn=e}shadowsOff(){this.tl=!1,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0}shadowsOn(){this.tl=!0,this.shadowOffsetX=this.sf,this.shadowOffsetY=this.nf,this.shadowBlur=this.xn}enableDash(t,i){const e=this.B;e.setLineDash!==void 0&&(e.setLineDash(t),e.lineDashOffset=i)}disableDash(){const t=this.B;t.setLineDash!==void 0&&(t.setLineDash(CanvasSurfaceContext.EmptyArray),t.lineDashOffset=0)}clearContextCache(t){t&&(this.zb=""),this.Xb="",this.Kb=""}removePartFromView(t){}static EmptyArray=Object.freeze([])}var BrushType=(w=>(w[w.Solid=1]="Solid",w[w.Linear=2]="Linear",w[w.Radial=3]="Radial",w[w.Pattern=4]="Pattern",w))(BrushType||{}),ColorSpace=(w=>(w[w.Lab=1]="Lab",w[w.HSL=2]="HSL",w[w.Oklch=3]="Oklch",w))(ColorSpace||{});class ColorNumbers{n0;n1;n2;n3;constructor(){this.n0=0,this.n1=0,this.n2=0,this.n3=0}}class Brush{h;Z;ka;ei;gs;W0;J0;bn;$0;yn;Qc;Eb;constructor(t,i){if(GSet.Yi(this),this.h=!1,t===void 0)this.Z=1,this.ka="black";else if(typeof t=="string"){const s=Util.Oh(BrushType,t);s!==null?(this.Z=s,this.ka="black"):(this.Z=1,this.ka=t)}else this.Z=t,this.ka="black";const e=this.Z;if(e===2?(this.ei=Spot.TopCenter,this.gs=Spot.BottomCenter):e===3?(this.ei=Spot.Center,this.gs=Spot.Center):(this.ei=Spot.None,this.gs=Spot.None),this.W0=0,this.J0=NaN,this.bn=null,this.$0=null,this.yn=null,this.Qc=0,this.Eb=0,i){const s={};for(const n in i)isFinite(parseFloat(n))?this.addColorStop(parseFloat(n),i[n]):s[n]=i[n];Object.assign(this,s)}}copy(){const t=new Brush;return t.Z=this.Z,t.ka=this.ka,t.ei=this.ei.N(),t.gs=this.gs.N(),t.W0=this.W0,t.J0=this.J0,this.bn!==null&&(t.bn=this.bn.copy()),t.$0=this.$0,t}g(){return this.h=!0,this.bn!==null&&this.bn.g(),this}rt(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this.bn!==null&&this.bn.rt(),this}ri(t){t in BrushType?this.type=t:Util.lr(this,t)}toString(){let t="Brush(";if(this.type===1)t+=this.color;else if(this.type===2?t+="Linear ":this.type===3?t+="Radial ":this.type===4?t+="Pattern ":t+="(unknown) ",t+=this.start+" "+this.end,this.colorStops!==null){const i=this.colorStops.iterator;for(;i.next();){const e=i.key,s=i.value;t+=" "+e+":"+s}}return t+=")",t}addColorStop(t,i){return this.h&&Util.T(this),(typeof t!="number"||!isFinite(t)||t>1||t<0)&&Util._(t,"0 <= loc <= 1",Brush,"addColorStop:loc"),Util.i(i,"string",Brush,"addColorStop:color"),this.bn===null&&(this.bn=new GMap),this.bn.set(t,i),this.Z===1&&(this.type=2),this.yn=null,this}get type(){return this.Z}set type(t){this.h&&Util.T(this,t),this.Z=t,this.start.isNoSpot()&&(t===2?this.start=Spot.TopCenter:t===3&&(this.start=Spot.Center)),this.end.isNoSpot()&&(t===2?this.end=Spot.BottomCenter:t===3&&(this.end=Spot.Center)),this.yn=null}get color(){return this.ka}set color(t){this.h&&Util.T(this,t),this.ka=t,this.yn=null}get start(){return this.ei}set start(t){this.h&&Util.T(this,t),this.ei=t.N(),this.yn=null}get end(){return this.gs}set end(t){this.h&&Util.T(this,t),this.gs=t.N(),this.yn=null}get startRadius(){return this.W0}set startRadius(t){this.h&&Util.T(this,t),t<0&&Util._(t,">= zero",Brush,"startRadius"),this.W0=t,this.yn=null}get endRadius(){return this.J0}set endRadius(t){this.h&&Util.T(this,t),t<0&&Util._(t,">= zero",Brush,"endRadius"),this.J0=t,this.yn=null}get colorStops(){return this.bn}set colorStops(t){this.h&&Util.T(this,t),this.bn=t,this.yn=null}get pattern(){return this.$0}set pattern(t){this.h&&Util.T(this,t),this.$0=t,this.yn=null}static randomColor(t,i){t===void 0&&(t=128),i===void 0&&(i=Math.max(t,255));const e=Math.abs(i-t);let s=Math.floor(t+Math.random()*e).toString(16),n=Math.floor(t+Math.random()*e).toString(16),o=Math.floor(t+Math.random()*e).toString(16);return s.length<2&&(s="0"+s),n.length<2&&(n="0"+n),o.length<2&&(o="0"+o),"#"+s+n+o}static isValidColor(t){return root.CSS?root.CSS.supports("color",t):!0}static lighten(t){return Brush.lightenBy(t)}lightenBy(t,i){this.h&&Util.T(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Do(this.color),this.color=Brush.ld(e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Do(n.value),this.addColorStop(n.key,Brush.ld(e,s))}return this}static lightenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Do(t),Brush.ld(s,n)}static darken(t){return Brush.darkenBy(t)}darkenBy(t,i){this.h&&Util.T(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Do(this.color),this.color=Brush.ld(-e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Do(n.value),this.addColorStop(n.key,Brush.ld(-e,s))}return this}static darkenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Do(t),Brush.ld(-s,n)}static mix(t,i,e){Brush.Do(t);const s=Brush.G.n0,n=Brush.G.n1,o=Brush.G.n2,r=Brush.G.n3;Brush.Do(i),e===void 0&&(e=.5);const l=Math.round((Brush.G.n0-s)*e+s),h=Math.round((Brush.G.n1-n)*e+n),a=Math.round((Brush.G.n2-o)*e+o),c=Math.round((Brush.G.n3-r)*e+r);return`rgba(${l}, ${h}, ${a}, ${c})`}isDark(){if(this.type===1)return Brush.isDark(this.color);if((this.type===2||this.type===3)&&this.colorStops!==null){const t=this.colorStops;if(this.type===3)return Brush.isDark(t.first().value);if(t.get(.5)!==null)return Brush.isDark(t.get(.5));if(t.count===2){const l=t.toArray();return Brush.isDark(Brush.mix(l[0].value,l[1].value))}const i=t.iterator;let e=-1,s=-1,n=1,o=1;for(;i.next();){const l=i.key,h=Math.abs(.5-i.key);n>o&&h=n&&hs){let l=e;e=s,s=l,l=n,n=o,o=l}const r=s-e;return Brush.isDark(Brush.mix(t.get(e),t.get(s),1-o/r))}return!1}static isDark(t){return t?t instanceof Brush?t.isDark():(Brush.Do(t),(299*Brush.G.n0+587*Brush.G.n1+114*Brush.G.n2)/1e3<128):!1}static ld(t,i){switch(i){case 1:return Brush.zR(),Brush.io.n0=Math.min(100,Math.max(0,Brush.io.n0+100*t)),Brush.XR(),"rgba("+Brush.G.n0+", "+Brush.G.n1+", "+Brush.G.n2+", "+Brush.G.n3+")";case 2:return Brush.OM(),Brush.Ii.n2=Math.min(100,Math.max(0,Brush.Ii.n2+100*t)),"hsla("+Brush.Ii.n0+", "+Brush.Ii.n1+"%, "+Brush.Ii.n2+"%, "+Brush.Ii.n3+")";case 3:return Brush.KR(),Brush.eo.n0=Math.min(100,Math.max(0,Brush.eo.n0+100*t)),Brush.YR(),"rgba("+Brush.G.n0+", "+Brush.G.n1+", "+Brush.G.n2+", "+Brush.G.n3+")";default:Util.o("Unknown color space: "+i)}}static Do(t){const i=Brush.il;if(i===null)return;i.clearRect(0,0,1,1),i.fillStyle="#000000";const e=i.fillStyle;if(i.fillStyle=t,i.fillStyle!==e){i.fillRect(0,0,1,1);const s=i.getImageData(0,0,1,1).data;Brush.G.n0=s[0],Brush.G.n1=s[1],Brush.G.n2=s[2],Brush.G.n3=s[3]/255}else{i.fillStyle="#FFFFFF";const s=i.fillStyle;i.fillStyle=t,i.fillStyle,Brush.G.n0=0,Brush.G.n1=0,Brush.G.n2=0,Brush.G.n3=1}}static OM(){const t=Brush.G.n0/255,i=Brush.G.n1/255,e=Brush.G.n2/255,s=Math.max(t,i,e),n=Math.min(t,i,e),o=s-n;let r,l;const h=(s+n)/2;if(o===0)r=l=0;else{switch(s){case t:r=(i-e)/o%6;break;case i:r=(e-t)/o+2;break;case e:r=(t-i)/o+4;break}r*=60,r<0&&(r+=360),l=o/(1-Math.abs(2*h-1))}Brush.Ii.n0=Math.round(r),Brush.Ii.n1=Math.round(l*100),Brush.Ii.n2=Math.round(h*100),Brush.Ii.n3=Brush.G.n3}static dE(){const t=Brush.Ii.n0,i=Brush.Ii.n1/100,e=Brush.Ii.n2/100;let s,n,o;const r=(1-Math.abs(2*e-1))*i,l=t/60,h=r*(1-Math.abs(l%2-1));l>=0&&l<1?(s=r,n=h,o=0):l>=1&&l<2?(s=h,n=r,o=0):l>=2&&l<3?(s=0,n=r,o=h):l>=3&&l<4?(s=0,n=h,o=r):l>=4&&l<5?(s=h,n=0,o=r):l>=5&&l<6&&(s=r,n=0,o=h);const a=e-.5*r;s+=a,n+=a,o+=a,Brush.G.n0=Math.round(s*255),Brush.G.n1=Math.round(n*255),Brush.G.n2=Math.round(o*255),Brush.G.n3=Brush.Ii.n3}static zR(){Brush.uA(),Brush.GR()}static XR(){Brush.jR(),Brush.dA()}static k2(t){return t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}static P2(t){return t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055}static uA(){const t=Brush.k2(Brush.G.n0),i=Brush.k2(Brush.G.n1),e=Brush.k2(Brush.G.n2);Brush.Rt.n0=.4124564*t+.3575761*i+.1804375*e,Brush.Rt.n1=.2126729*t+.7151522*i+.072175*e,Brush.Rt.n2=.0193339*t+.119192*i+.9503041*e,Brush.Rt.n3=Brush.G.n3}static dA(){const t=3.2404542*Brush.Rt.n0+-1.5371385*Brush.Rt.n1+-.4985314*Brush.Rt.n2,i=-.969266*Brush.Rt.n0+1.8760108*Brush.Rt.n1+.041556*Brush.Rt.n2,e=.0556434*Brush.Rt.n0+-.2040259*Brush.Rt.n1+1.0572252*Brush.Rt.n2;Brush.G.n0=Brush.P2(t)*255,Brush.G.n1=Brush.P2(i)*255,Brush.G.n2=Brush.P2(e)*255,Brush.G.n3=Brush.Rt.n3,Brush.G.n0=Math.round(Brush.G.n0),Brush.G.n0>255?Brush.G.n0=255:Brush.G.n0<0&&(Brush.G.n0=0),Brush.G.n1=Math.round(Brush.G.n1),Brush.G.n1>255?Brush.G.n1=255:Brush.G.n1<0&&(Brush.G.n1=0),Brush.G.n2=Math.round(Brush.G.n2),Brush.G.n2>255?Brush.G.n2=255:Brush.G.n2<0&&(Brush.G.n2=0)}static M2=216/24389;static Yb=24389/27;static hd=[95.047,100,108.883];static S2(t){return t>Brush.M2?Math.pow(t,1/3):(Brush.Yb*t+16)/116}static GR(){const t=Brush.S2(Brush.Rt.n0*100/Brush.hd[0]),i=Brush.S2(Brush.Rt.n1*100/Brush.hd[1]),e=Brush.S2(Brush.Rt.n2*100/Brush.hd[2]);Brush.io.n0=116*i-16,Brush.io.n1=500*(t-i),Brush.io.n2=200*(i-e),Brush.io.n3=Brush.Rt.n3}static gA(t){const i=t*t*t;return i>Brush.M2?i:(116*t-16)/Brush.Yb}static jR(){const t=(Brush.io.n0+16)/116,i=Brush.io.n1/500+t,e=t-Brush.io.n2/200;Brush.Rt.n0=Brush.hd[0]/100*Brush.gA(i),Brush.Rt.n1=Brush.hd[1]/100*(Brush.io.n0>Brush.Yb*Brush.M2?Math.pow(t,3):Brush.io.n0/Brush.Yb),Brush.Rt.n2=Brush.hd[2]/100*Brush.gA(e),Brush.Rt.n3=Brush.io.n3}static HR(){let t=.8190224*Brush.Rt.n0+.3619062*Brush.Rt.n1+-.1288737*Brush.Rt.n2,i=.03298366*Brush.Rt.n0+.9292868*Brush.Rt.n1+.03614466*Brush.Rt.n2,e=.04817719*Brush.Rt.n0+.2642395*Brush.Rt.n1+.6335478*Brush.Rt.n2;t=Math.cbrt(t),i=Math.cbrt(i),e=Math.cbrt(e),Brush.ci.n0=.2104542*t+.7936177*i+-.004072046*e,Brush.ci.n1=1.977998*t+-2.428592*i+.4505937*e,Brush.ci.n2=.02590403*t+.7827717*i+-.8086757*e,Brush.ci.n3=Brush.Rt.n3,Brush.ci.n0*=100}static qR(){Brush.ci.n0/=100;let t=.9999999*Brush.ci.n0+.3963377*Brush.ci.n1+.2158037*Brush.ci.n2,i=1.000000009*Brush.ci.n0+-.1055613*Brush.ci.n1+-.06385417*Brush.ci.n2,e=1.00000005*Brush.ci.n0+-.08948418*Brush.ci.n1+-1.291485*Brush.ci.n2;t=t**3,i=i**3,e=e**3,Brush.Rt.n0=1.2268798*t+-.5578149*i+.281391*e,Brush.Rt.n1=-.04057576*t+1.112286*i+-.07171106*e,Brush.Rt.n2=-.07637294*t+-.4214933*i+1.586924*e,Brush.Rt.n3=Brush.ci.n3}static WR(){const t=Math.atan2(Brush.ci.n2,Brush.ci.n1)*180/Math.PI;Brush.eo.n0=Brush.ci.n0,Brush.eo.n1=Math.sqrt(Brush.ci.n1**2+Brush.ci.n2**2),Brush.eo.n2=t>=0?t:t+360,Brush.eo.n3=Brush.ci.n3}static JR(){Brush.ci.n0=Brush.eo.n0,Brush.ci.n1=Brush.eo.n1*Math.cos(Brush.eo.n2*Math.PI/180),Brush.ci.n2=Brush.eo.n1*Math.sin(Brush.eo.n2*Math.PI/180),Brush.ci.n3=Brush.eo.n3}static KR(){Brush.uA(),Brush.HR(),Brush.WR()}static YR(){Brush.JR(),Brush.qR(),Brush.dA()}static od(t,i){typeof t=="string"||t instanceof Brush||Util.o("Value for "+i+" must be a color string or a Brush, not "+t)}static Solid=1;static Linear=2;static Radial=3;static Pattern=4;static Lab=1;static HSL=2;static il=Diagram.isUsingDOM()?new CanvasSurface(null,void 0,{willReadFrequently:!0}).ai:null;static G=new ColorNumbers;static Ii=new ColorNumbers;static Rt=new ColorNumbers;static io=new ColorNumbers;static ci=new ColorNumbers;static eo=new ColorNumbers}class PanelLayout{St="Base";static Layouts=new GMap;static definePanelLayout(t,i){i.name=t,PanelLayout.Layouts.set(t,i)}get name(){return this.St}set name(t){this.St=t}constructor(){}get classType(){return Panel}measure(t,i,e,s,n,o,r){}measureElement(t,i,e,s,n){t.ut(i,e,s,n)}arrange(t,i,e){}arrangeElement(t,i,e,s,n,o){t.zt(i,e,s,n,o)}remeasureObject(t){t._c()}Gi(t,i,e){}}class PanelLayoutPosition extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=s.length,h=t.Ko();for(let a=0;a0&&(S=Math.max(Math.abs(k.x*o+k.offsetX-(M.x*o+M.offsetX))-g,0)),r>0&&(N=Math.max(Math.abs(k.y*r+k.offsetY-(M.y*r+M.offsetY))-g,0));const T=Size.l();T.e(0,0);const A=t.Ko();for(let v=0;v1,ot=it.columnSpan>1;(ct||ot)&&!(Ky&&(S=Math.max(y-dt,0)),b.ji=b.ji+S,b.actual=b.nt+S,y=Math.max(y-(S+(mt?dt:0)),0)}if(it.columnSpan===1&&(N===0||N===4)){b=t.getColumnDefinition(j);const dt=b.computeEffectiveSpacing(),mt=b.nt===0;S=Math.max(ut-b.actual,0),S+(mt?dt:0)>p&&(S=Math.max(p-dt,0)),b.ji=b.ji+S,b.actual=b.nt+S,p=Math.max(p-(S+(mt?dt:0)),0)}(ct||ot)&&it._c()}}}Util.tt(f);let A=0,D=0;l=t.columnCount;for(let K=0;K=t.rowCount);Z++)b=t.getRowDefinition(I.row+Z),S=0,N===2||N===4?S=Math.max(b.minimum,V[I.row+Z]===0?b.maximum:Math.min(V[I.row+Z],b.maximum)):S=Math.max(b.minimum,isNaN(b.de)?b.maximum:Math.min(b.de,b.maximum)),E.height+=S,_+=b.minimum;for(let Z=1;Z=t.columnCount);Z++)b=t.getColumnDefinition(I.column+Z),S=0,N===2||N===5?S=Math.max(b.minimum,B[I.column+Z]===0?b.maximum:Math.min(B[I.column+Z],b.maximum)):S=Math.max(b.minimum,isNaN(b.de)?b.maximum:Math.min(b.de,b.maximum)),E.width+=S,et+=b.minimum;X.width+=E.width,X.height+=E.height;const tt=I.margin,it=tt.right+tt.left,ct=tt.top+tt.bottom;I.ut(X.width,X.height,et,_);const ot=I.measuredBounds,lt=Math.max(ot.width+it,0),st=Math.max(ot.height+ct,0);let nt=0;for(let Z=0;Z=t.rowCount);Z++)b=t.getRowDefinition(I.row+Z),nt+=b.total||0;if(nt=t.rowCount);at++){b=t.getRowDefinition(I.row+at);const ut=b.nt||0,gt=rt(I,b,ft);b.actual=Math.min(b.maximum,ut+gt),b.nt!==ut&&(Z-=b.nt-ut)}}for(;Z>0;){const rt=b.nt||0;if(isNaN(b.height)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+Z),b.nt!==rt&&(Z-=b.nt-rt)),b.index===0)break;b=t.getRowDefinition(b.index-1)}}let ht=0;for(let Z=0;Z=t.columnCount);Z++)b=t.getColumnDefinition(I.column+Z),ht+=b.total||0;if(ht=t.columnCount);at++){b=t.getColumnDefinition(I.column+at);const ut=b.nt||0,gt=rt(I,b,ft);b.actual=Math.min(b.maximum,ut+gt),b.nt!==ut&&(Z-=b.nt-ut)}}for(;Z>0;){const rt=b.nt||0;if(isNaN(b.width)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+Z),b.nt!==rt&&(Z-=b.nt-rt)),b.index===0)break;b=t.getColumnDefinition(b.index-1)}}}Util.tt(u),Size.s(E),Size.s(X),V!==void 0&&Util.tt(V),B!==void 0&&Util.tt(B);let Y=0,G=0;const H=t.desiredSize,J=t.maxSize;N=t.zs(!0),A=0,D=0;let z=0,W=0;l=t.columnCount;for(let K=0;K0){for(;p!==c&&(u[p]===void 0||u[p].nt===0);)p++;p=Math.max(Math.min(p,c-1),0),m=-u[p].position}let y=Math.min(t.leftIndex,f-1);if(d.length>0){for(;y!==f&&(d[y]===void 0||d[y].nt===0);)y++;y=Math.max(Math.min(y,f-1),0),g=-d[y].position}let x=0,k=0;for(;x!==c&&u[x]===void 0;)x++;for(;k!==c&&d[k]===void 0;)k++;const b=t.part;let P=t.getRowDefinition(x),M=t.getColumnDefinition(k);for(let C=0;C=t.rowCount);st++){const nt=t.getRowDefinition(C+st);nt.nt!==0&&(L.height+=nt.total)}for(let st=1;st=t.columnCount);st++){const nt=t.getColumnDefinition(N+st);nt.nt!==0&&(L.width+=nt.total)}const O=T.nt+L.width,U=S.nt+L.height;let X=h,E=a;const V=O,B=U,Y=h,G=a;let H=O,J=U;h+O>e.width&&(H=Math.max(e.width-h,0)),a+U>e.height&&(J=Math.max(e.height-a,0));let z=R.alignment,W=0,q=0,Q=0,K=0;if(z.isDefault()){z=t.defaultAlignment,z.isSpot()||(z=Spot.Center),W=z.x,q=z.y,Q=z.offsetX,K=z.offsetY;const st=T.alignment,nt=S.alignment;st.isSpot()&&(W=st.x,Q=st.offsetX),nt.isSpot()&&(q=nt.y,K=nt.offsetY)}else W=z.x,q=z.y,Q=z.offsetX,K=z.offsetY;(isNaN(W)||isNaN(q))&&(W=.5,q=.5,Q=0,K=0);let I=v.width,j=v.height;const $=R.margin,et=$.left+$.right,_=$.top+$.bottom,tt=R.S0(S,T,!1);isNaN(R.desiredSize.width)&&(tt===2||tt===5)&&(I=Math.max(O-et,0)),isNaN(R.desiredSize.height)&&(tt===2||tt===4)&&(j=Math.max(U-_,0));const it=R.maxSize,ct=R.minSize;I=Math.min(it.width,I),j=Math.min(it.height,j),I=Math.max(ct.width,I),j=Math.max(ct.height,j);const ot=I+et,lt=j+_;X+=V*W-ot*W+Q+$.left,E+=B*q-lt*q+K+$.top,R.visible&&(Rect.contains(Y,G,H,J,X,E,v.width,v.height)?R.zt(X,E,I,j):R.zt(X,E,I,j,new Rect(Y,G,H,J)))}}}Size.s(L);for(let C=0;C0&&(b.figure==="LineV"||b.figure==="LineH")){if(i.lineWidth=b.strokeWidth,t.dn(i,b.stroke,!1,!1,l,h),i.beginPath(),b.figure==="LineV"){const D=Math.floor((m-o)/o);for(let F=D;F<=D+f;F++){const R=F*o+m;0<=R&&R<=a&&this.jb(F,P,L,N)&&(i.moveTo(R,0),i.lineTo(R,c))}}else if(b.figure==="LineH"){const D=Math.floor((g-r)/r);for(let F=D;F<=D+u;F++){const R=F*r+g;0<=R&&R<=c&&this.jb(F,P,L,N)&&(i.moveTo(0,R),i.lineTo(a,R))}}i.stroke(),i.endPath()}else if(b.fill!==null){if(t.dn(i,b.fill,!0,!1,l,h),b.figure==="BarV"){let D=b.width;isNaN(D)&&(D=o);const F=Math.floor((m-o)/o);for(let R=F;R<=F+f;R++){const v=R*o+m;0<=v+D&&v<=a&&this.jb(R,P,L,N)&&i.fillRect(v,0,D,c)}}else if(b.figure==="BarH"){let D=b.height;isNaN(D)&&(D=r);const F=Math.floor((g-r)/r);for(let R=F;R<=F+u;R++){const v=R*r+g;0<=v+D&&v<=c&&this.jb(R,P,L,N)&&i.fillRect(0,v,a,D)}}}T&&i.disableDash(),C!==1&&(i.globalAlpha=S)}}jb(t,i,e,s){if(i<0)return t%i===e;if(t%i!==e)return!1;const n=s.length;for(let o=0;ol&&r.push(d)}}t.xi.Z0=i}A2(t){return t==="LineV"||t==="BarV"}$R(t){let i=1,e=1;const s=t.L.r,n=s.length;for(let l=0;l=g){const z=Point.l();c.mA(z),O=c.midAngle,A!==0&&(v=c.computeAngle(L,A,O),L.Xt=v,L.fe(!0),L._n(!0)),F=z.x-u.x,R=z.y-u.y,Point.s(z)}else{let z,W,q=0;if(S>=0?(z=m.elt(S),W=S0?m.elt(q-1):z),O=0,z.equalsApprox(W)){let Q,K;S>=0?(Q=S>0?m.elt(S-1):z,K=S1?m.elt(q-2):W);const I=Q.distanceSquaredPoint(z),j=W.distanceSquaredPoint(K);I>j+10?O=S>=0?Q.directionPoint(z):z.directionPoint(Q):j>I+10?O=S>=0?W.directionPoint(K):K.directionPoint(W):O=S>=0?Q.directionPoint(K):K.directionPoint(Q)}else O=S>=0?z.directionPoint(W):W.directionPoint(z);A!==0&&(v=c.computeAngle(L,A,O),L.Xt=v,L.fe(!0),L._n(!0)),F=z.x+(W.x-z.x)*N-u.x,R=z.y+(W.y-z.y)*N-u.y}L.ut(1/0,1/0,0,0),C=L.measuredBounds;const U=L.naturalBounds;let X=0;L instanceof Shape&&(X=L.strokeWidth);const E=U.width+X,V=U.height+X;k.Ri(),k.Ds(-C.x,-C.y),k.st(L.scale,L.scale),k.cs(A===0?L.angle:O,E/2,V/2),(A===22||A===26)&&k.cs(90,E/2,V/2),(A===23||A===27)&&k.cs(-90,E/2,V/2),A===28&&(O>45&&O<135||O>225&&O<315)&&k.cs(-O,E/2,V/2);const B=new Rect(0,0,E,V);b.setRectSpot(B,T),k.xt(b);const Y=-b.x+X/2*L.scale,G=-b.y+X/2*L.scale;P.a(D);const H=isNaN(D.x),J=isNaN(D.y);if(H||J){const z=E/2+3,W=V/2+3,q=O>=45&&O<=135,Q=O>=225&&O<=315;A===0&&(q||Q)?(P.x=J?z:D.y,P.y=H?W:D.x,q?S>=0||isNaN(S)&&N<.5||H&&(P.y=-W):Q&&((S>=0||isNaN(S)&&N<.5)&&H&&(P.y=-W),J&&(P.x=-z))):(H&&(S>=0||isNaN(S)&&N<.5?P.x=z:P.x=-z),J&&(P.y=-W),P.rotate(O))}else P.rotate(O);F+=P.x,R+=P.y,B.e(F+Y,R+G,C.width,C.height),x.push(B),d.unionRect(B)}if(h!==null){const M=h.labelNodes;for(;M.next();)M.value.ut(1/0,1/0)}t.Yo=d,t.position.e(u.x+d.x,u.y+d.y),n.En(d.width||0,d.height||0),Transform.s(k),Point.s(b),Point.s(P)}arrange(t,i,e){const s=i.length;if(!(t instanceof Adornment||t instanceof Link))return;let n=t,o=null;t instanceof Adornment&&(o=t,n=o.adornedPart);const r=t,l=t instanceof Adornment?null:n.path,h=t.lf;if(h.length!==0){let u=0;if(l!==null&&u=2&&r instanceof Link){const u=r.labelNodes;for(;u.next();){const d=u.value;r._R(d,c,a)}}o!==null?o.ad(!1):n.ad(!1);const f=t.pA(Point.l());t.location.e(t.position.x+f.x,t.position.y+f.y),Point.s(f)}measureLinkPath(t,i,e,s){if(s.Oo()===!1)return;let n=s.strokeWidth;if(n===0&&t instanceof Adornment&&t.type===Panel.Link&&t.adornedObject instanceof Shape&&(n=t.adornedObject.strokeWidth),n=n*s.st,t instanceof Link&&t.ft!==null){const o=t.geometry.bounds;s.Qn(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else if(t instanceof Adornment&&t.adornedPart.ft!==null){const o=t.adornedPart.ft.bounds;s.Qn(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else s.Qn(-(n/2),-(n/2),i+n,e+n);s.tv(),s.fe(!1)}}PanelLayout.definePanelLayout("Link",new PanelLayoutLink);class PanelLayoutGraduated extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=t.findMainElement();t.je=[];const h=l.margin,a=h.right+h.left,c=h.top+h.bottom;l.ut(i,e,o,r);const f=l.measuredBounds,u=f.width,d=f.height,m=Math.max(u+a,0),g=Math.max(d+c,0),p=new Rect(-h.left,-h.top,m,g);t.je.push(p),n.a(p),this.determineGraduatedMarks(t,l);const y=t.ws;if(y===null)return;const x=s.length;for(let k=0;k45&&f<135||f>225&&f<315)&&P.cs(-f,k/2,b/2);const M=Rect.X(0,0,k,b),L=Point.l();L.setRectSpot(M,o),P.xt(L);const C=-L.x,S=-L.y,N=Point.l();N.a(l),isNaN(N.x)&&(N.x=k/2+3),isNaN(N.y)&&(N.y=-(b/2+3)),N.rotate(f),a+=N.x+C,c+=N.y+S;const T=new Rect(a,c,y.width,y.height),A=new Rect(y.x,y.y,y.width,y.height),D=new Rect(x.x,x.y,x.width,x.height);p.labelAngle=u,p.lineCount=n.lineCount,p.lines=n.getMetrics(),p.actualBounds=T,p.measuredBounds=A,p.naturalBounds=D,g===0?h.a(T):h.unionRect(T),Point.s(N),Point.s(L),Rect.s(M),Transform.s(P)}t.je!==null&&t.je.push(h),s.unionNoCheck(h.x,h.y,h.width,h.height)}determineGraduatedMarks(t,i){const e=i.geometry,s=i.strokeWidth,n=e.flattenedSegments,o=e.flattenedLengths,r=e.flattenedTotalLength,l=n.length;let h=0,a=0;const c=Util.ot();for(let x=0;xt.graduatedMin+S){const F=Math.floor((N-t.graduatedMin)/S);N-=F*S}const T=f[x],A=N,D=t.graduatedMax*1e-6;for(let F=1;N<=t.graduatedMax+D;F++){if(this.ev(t,N-t.graduatedTickBase,T)&&(N>t.graduatedMax&&(N=t.graduatedMax),(k.graduatedSkip===null||k instanceof TextBlock&&!k.graduatedSkip(N,k)||k instanceof Shape&&!k.graduatedSkip(N,k))&&(m=(N-t.graduatedMin)*r/t.graduatedRange,m>r&&(m=r),g<=m&&m<=p))){let R=c[L][C],v=o[L][C];for(;LM&&C.4995)return t;let o=t;if(i<.5?n>0?o=s[n-1]:Geo.K(e[0],e[e.length-2])&&Geo.K(e[1],e[e.length-1])&&(o=s[s.length-1]):i>.5&&(n+1180&&(t.9995)return(t+o)/2%360;if(r<10){const l=1-Math.abs(.5-i);return(t*l+o*(1-l))%360}}return t}iv(t){if(t.ns===null){const i=[],e=t.L.r,s=e.length;for(let n=0;nl&&r.push(c)}}t.ns=i}return t.ns}ev(t,i,e){const s=e.length;for(let n=0;n-l)return!1}return!0}Gi(t,i,e){const s=e.Zh;e.Zh=!0;const n=t.naturalBounds,o=n.width,r=n.height,l=i instanceof SVGContext;i.save(),i.beginPath(),i.rect(-1,-1,o+1,r+1),i.clip(),i.endPath();const h=t.findMainElement();h.Gi(i,e);let a=t.getDocumentScale()*e.scale;a<=0&&(a=1);const c=h.actualBounds,f=t.L.r,u=t.ws,d=f.length;for(let m=0;m(w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ViewboxStretch||{});class Panel extends GraphObject{Z;L;$t;cd;Kn;el;so;Yo;D2;O;fd;ht;xi;Qt;ud;gh;Ys;constructor(t,i){if(super(),this.Z=null,t===void 0)this.Z=Panel.Position;else if(typeof t=="string"){const e=PanelLayout.Layouts.get(t);e!==null&&(this.Z=e)}else t instanceof PanelLayout?this.Z=t:t&&(this.Z=Panel.Position,i=t);this.Z===null&&Util.o("Panel type not specified or PanelLayout not loaded: "+t),this.n|=4194304|(this.Z===Panel.Grid?1048576:0),this.L=new List,this.$t=Margin.Ug,this.cd=Spot.Default,this.Kn=1,this.el=null,this.so="",this.Yo=new Rect(NaN,NaN,NaN,NaN),this.D2=null,this.O=null,this.fd=6,this.xi=null,this.ht=null,this.Qt=null,this.ud=NaN,this.gh=null,this.Ys=null,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.Z=this.Z,t.$t=this.$t.N(),t.cd=this.cd.N(),t.Kn=this.Kn,t.so=this.so,t.Yo.a(this.Yo),this.O!==null&&(t.O=this.O.copy(t)),t.fd=this.fd,this.ht!==null&&(t.ht=this.ht.copy()),this.xi!==null&&(t.xi=this.xi.copy()),t.Qt=this.Qt,t.ud=this.ud,t.gh=this.gh}Vo(t){super.Vo(t),t.L=this.L;const i=t.L.r,e=i.length;for(let s=0;s= 0",Panel,"padding"),t=new Margin(t)):(t.left<0&&Util._(t.left,">= 0",Panel,"padding:value.left"),t.right<0&&Util._(t.right,">= 0",Panel,"padding:value.right"),t.top<0&&Util._(t.top,">= 0",Panel,"padding:value.top"),t.bottom<0&&Util._(t.bottom,">= 0",Panel,"padding:value.bottom"));const i=this.$t;i.equals(t)||(t=t.N(),this.$t=t,this.c(),this.t("padding",i,t))}get defaultAlignment(){return this.cd}set defaultAlignment(t){const i=this.cd;i.equals(t)||(t=t.N(),this.cd=t,this.c(),this.t("defaultAlignment",i,t))}get defaultStretch(){return this.Kn}set defaultStretch(t){const i=this.Kn;i!==t&&(this.Kn=t,this.c(),this.t("defaultStretch",i,t))}get defaultSeparatorPadding(){return this.O!==null?this.O.Q0:Margin.Ug}set defaultSeparatorPadding(t){typeof t=="number"&&(t=new Margin(t));const i=this.defaultSeparatorPadding;i.equals(t)||(t=t.N(),this.O===null&&(this.O=new TablePanelSettings),this.O.Q0=t,this.c(),this.t("defaultSeparatorPadding",i,t))}get defaultRowSeparatorStroke(){return this.O!==null?this.O._0:null}set defaultRowSeparatorStroke(t){const i=this.defaultRowSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.g(),this.O===null&&(this.O=new TablePanelSettings),this.O._0=t,this.C(),this.t("defaultRowSeparatorStroke",i,t))}get defaultRowSeparatorStrokeWidth(){return this.O!==null?this.O.tp:1}set defaultRowSeparatorStrokeWidth(t){const i=this.defaultRowSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.O===null&&(this.O=new TablePanelSettings),this.O.tp=t,this.c(),this.t("defaultRowSeparatorStrokeWidth",i,t))}get defaultRowSeparatorDashArray(){return this.O!==null?this.O.ip:null}set defaultRowSeparatorDashArray(t){const i=this.defaultRowSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",Panel,"defaultRowSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("defaultRowSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.O===null&&(this.O=new TablePanelSettings),this.O.ip=t,this.C(),this.t("defaultRowSeparatorDashArray",i,t)}}get defaultColumnSeparatorStroke(){return this.O!==null?this.O.ep:null}set defaultColumnSeparatorStroke(t){const i=this.defaultColumnSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.g(),this.O===null&&(this.O=new TablePanelSettings),this.O.ep=t,this.C(),this.t("defaultColumnSeparatorStroke",i,t))}get defaultColumnSeparatorStrokeWidth(){return this.O!==null?this.O.sp:1}set defaultColumnSeparatorStrokeWidth(t){const i=this.defaultColumnSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.O===null&&(this.O=new TablePanelSettings),this.O.sp=t,this.c(),this.t("defaultColumnSeparatorStrokeWidth",i,t))}get defaultColumnSeparatorDashArray(){return this.O!==null?this.O.np:null}set defaultColumnSeparatorDashArray(t){const i=this.defaultColumnSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",Panel,"defaultColumnSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("defaultColumnSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.O===null&&(this.O=new TablePanelSettings),this.O.np=t,this.C(),this.t("defaultColumnSeparatorDashArray",i,t)}}get dh(){return this.O!==null?this.O.dh:null}set dh(t){this.O===null&&(this.O=new TablePanelSettings),this.O.dh=t}get viewboxStretch(){return this.fd}set viewboxStretch(t){const i=this.fd;i!==t&&(this.fd=t,this.c(),this.t("viewboxStretch",i,t))}get gridCellSize(){return this.xi!==null?this.xi.dd:Size.eC}set gridCellSize(t){this.xi===null&&(this.xi=new GridPanelSettings);const i=this.xi.dd;if(!i.equals(t)){(!t.isReal()||t.width===0||t.height===0)&&Util.o("Invalid Panel.gridCellSize: "+t),this.xi.dd=t.N();const e=this.diagram;e!==null&&this===e.grid&&e.jr(),this.C(),this.t("gridCellSize",i,t)}}get gridOrigin(){return this.xi!==null?this.xi.gd:Point.Po}set gridOrigin(t){this.xi===null&&(this.xi=new GridPanelSettings);const i=this.xi.gd;if(!i.equals(t)){t.isReal()||Util.o("Invalid Panel.gridOrigin: "+t),this.xi.gd=t.N();const e=this.diagram;e!==null&&this===e.grid&&e.jr(),this.C(),this.t("gridOrigin",i,t)}}get graduatedMin(){return this.ht!==null?this.ht.op:0}set graduatedMin(t){const i=this.graduatedMin;if(i!==t&&(this.ht===null&&(this.ht=new GradPanelSettings),this.ht.op=t,this.c(),this.t("graduatedMin",i,t),this.Jc())){const e=this.part;e!==null&&this.pa(e,"graduatedRange")}}get graduatedMax(){return this.ht!==null?this.ht.rp:100}set graduatedMax(t){const i=this.graduatedMax;if(i!==t&&(this.ht===null&&(this.ht=new GradPanelSettings),this.ht.rp=t,this.c(),this.t("graduatedMax",i,t),this.Jc())){const e=this.part;e!==null&&this.pa(e,"graduatedRange")}}get graduatedRange(){return this.graduatedMax-this.graduatedMin}get graduatedTickUnit(){return this.ht!==null?this.ht.lp:10}set graduatedTickUnit(t){const i=this.graduatedTickUnit;i!==t&&t>0&&(this.ht===null&&(this.ht=new GradPanelSettings),this.ht.lp=t,this.c(),this.t("graduatedTickUnit",i,t))}get graduatedTickBase(){return this.ht!==null?this.ht.hp:0}set graduatedTickBase(t){const i=this.graduatedTickBase;i!==t&&(this.ht===null&&(this.ht=new GradPanelSettings),this.ht.hp=t,this.c(),this.t("graduatedTickBase",i,t))}get ws(){return this.ht!==null?this.ht.ws:null}set ws(t){this.ht!==null?this.ht.ws=t:t!==null&&(this.ht=new GradPanelSettings,this.ht.ws=t)}get je(){return this.ht!==null?this.ht.je:null}set je(t){this.ht!==null?this.ht.je=t:t!==null&&(this.ht=new GradPanelSettings,this.ht.je=t)}get ns(){return this.ht!==null?this.ht.ns:null}set ns(t){this.ht!==null?this.ht.ns=t:t!==null&&(this.ht=new GradPanelSettings,this.ht.ns=t)}get Me(){return this.ht!==null?this.ht.Me:null}set Me(t){this.ht!==null?this.ht.Me=t:t!==null&&(this.ht=new GradPanelSettings,this.ht.Me=t)}b0(t){super.b0(t);const i=this.L.r,e=i.length;for(let s=0;s0?this.Ye:null,s=this.columnCount>0?this.Ge:null;e!==null&&this.Hb(t,i,!0,e,!0),s!==null&&this.Hb(t,i,!1,s,!0),e!==null&&this.wA(t,!0,e),s!==null&&this.wA(t,!1,s),e!==null&&this.Hb(t,i,!0,e,!1),s!==null&&this.Hb(t,i,!1,s,!1)}wA(t,i,e){const s=e.length,n=this.actualBounds,o=this.naturalBounds;let r=!0;for(let l=0;lo.height)continue}else if(h.position>o.width)continue;let a=h.separatorStrokeWidth;isNaN(a)&&(a=i?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let c=h.separatorStroke;if(c===null&&(c=i?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),a===0||c===null)continue;this.dn(t,c,!1,!1,o,n);let f=!1,u=h.separatorDashArray;u===null&&(u=i?this.defaultRowSeparatorDashArray:this.defaultColumnSeparatorDashArray),u!==null&&(f=!0,t.enableDash(u,0)),t.beginPath();const d=h.position+a;i?d>o.height&&(a-=d-o.height):d>o.width&&(a-=d-o.width);let m=h.position+a/2;t.lineWidth=a;const g=this.$t;if(i){m+=g.top;const p=g.left,y=o.width-g.right;t.moveTo(p,m),t.lineTo(y,m)}else{m+=g.left;const p=g.top,y=o.height-g.bottom;t.moveTo(m,p),t.lineTo(m,y)}t.stroke(),t.endPath(),f&&t.disableDash()}}Hb(t,i,e,s,n){const o=s.length,r=this.actualBounds,l=this.naturalBounds,h=this.xA(!0),a=this.xA(!1);for(let c=0;cu)continue;let d=f.computeEffectiveSpacing(),m=f.separatorStrokeWidth;isNaN(m)&&(m=e?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let g=f.separatorStroke;g===null&&(g=e?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),(g===null||f.index===(e?h:a))&&(m=0),d-=m;const p=f.position+m;let y=d+f.actual;if(p+y>u&&(y=u-p),y<=0)continue;const x=this.$t;this.dn(t,f.background,!0,!1,l,r),e?t.fillRect(x.left,p+x.top,r.width-(x.left+x.right),y):t.fillRect(p+x.left,x.top,y,r.height-(x.top+x.bottom))}}xA(t){const i=t?this.rowCount:this.columnCount;for(let e=0;ex&&n.set(S),Point.s(S)),Point.s(M),o&&n.D(r),k}}Fu(){const t=this.L.r,i=t.length;for(let e=0;ee||h>s)&&(this.c(),this.ut(l>e?e:l,h>s?s:h,0,0));break;case 2:this.c(!0),this.ut(e+c,s+f,0,0);break;case 5:this.c(!0),this.ut(e+c,h+f,0,0);break;case 4:this.c(!0),this.ut(l+c,s+f,0,0);break}}this.Z.arrange(this,n,this.Yo)}lh(t){const i=this.naturalBounds,e=this.Ko();if(Rect.contains(0,0,i.width,i.height,t.x,t.y)){const s=this.L.r,n=s.length,o=Point.X(0,0);for(let r=n;r--;){const l=s[r];if(!(!l.visible&&l!==e)&&(o.set(t).Ie(l.D),l.containsPoint(o)))return Point.s(o),!0}return Point.s(o),this.Ct!==null}return!1}p0(t){if(this.$n===t)return this;const i=this.L.r,e=i.length;for(let s=0;sd.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;let m=f;const g=f instanceof Panel?f:null,p=Transform.l();p.set(r),(g!==null?g.Om(t,i,e,s,n,p):m._L(t,s,p))&&(i!==null&&(m=i(m)),m!==null&&(e===null||e(m))&&n.add(m)),Transform.s(p)}}return o===void 0&&Transform.s(r),s}return o===void 0&&Transform.s(r),!1}R2(t,i,e){const s=this.L.r,n=s.length;for(let o=n;o--;){const r=s[o];if(!r.visible)continue;const l=r.actualBounds,h=this.naturalBounds;if(l.x>h.width||l.y>h.height||l.x+l.width<0||l.y+l.height<0)continue;r instanceof Panel&&r.R2(t,i,e);let a=r;t!==null&&(a=t(a)),a!==null&&(i===null||i(a))&&e.add(a)}}sL(t,i,e,s,n,o){if(this.pickable===!1)return!1;e===void 0&&(e=null),s===void 0&&(s=null);const r=this.naturalBounds,l=this.pn(),h=l?t:Point.X(t.x,t.y).Ie(this.D),a=l?i:Point.X(i.x,i.y).Ie(this.D),c=h.distanceSquaredPoint(a),f=h.x>0&&h.x0&&h.yP.width||b.y>P.height||b.x+b.width<0||b.y+b.height<0))continue;if(k.pn()){const C=k.D;d.set(t).Ie(C),m.set(i).Ie(C)}else d.set(t),m.set(i);let M=k;const L=k instanceof Panel?k:null;(L!==null?L.sL(d,m,e,s,n,o):M.tA(d,m,n))&&(e!==null&&(M=e(M)),M!==null&&(s===null||s(M))&&o.add(M))}Point.s(d),Point.s(m)}return n?f:u}return!1}C2(t){let i=null;if(t instanceof Shape){i=t.spot1,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot1)}return i===null&&(i=Spot.TopLeft),i}L2(t){let i=null;if(t instanceof Shape){i=t.spot2,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot2)}return i===null&&(i=Spot.BottomRight),i}add(...t){for(let i=0;i=s.count&&t>=s.count)return;s.removeAt(r),n=r}else Util.o("element "+i.toString()+" has panel "+e.toString()+" but is not contained by it.")}(t<0||t>s.count)&&(t=s.count),s.insertAt(t,i),(t===0||i.isPanelMain)&&(this.el=null),this.Oo()||this.c(),i.c(!1),i.portId!==null?this.wn=!0:i instanceof Panel&&i.wn===!0&&(this.wn=!0),this.ns=null,this.isEnabledObject()||this.qb(i,!1);const o=this.part;if(o!==null){o.T0(),o.af(),this.wn&&o instanceof Node&&(o.wn=!0),o.wn&&o instanceof Node&&(o.se=null);const r=this.diagram;if(r!==null&&r.undoManager.isUndoingRedoing)return;n!==-1&&o.raiseChangedEvent(4,"elements",this,i,null,n,null),o.raiseChangedEvent(3,"elements",this,null,i,null,t)}}get wn(){return(this.n&8388608)!==0}set wn(t){(this.n&8388608)!==0!==t&&(this.n=this.n^8388608)}s2(){return(this.n&16777216)!==0}v2(t){t?this.n|=16777216:this.n&=-16777217}hv(t){t.wa(this),t.Qr=null;const i=this.L,e=i.count;i.insertAt(e,t);const s=this.part;if(s!==null){s.T0(),t.portId!==null&&s instanceof Node&&(s.wn=!0);const n=this.diagram;if(n!==null&&n.undoManager.isUndoingRedoing)return;s.raiseChangedEvent(3,"elements",this,null,t,null,e)}}DR(t){const i=this.L.r,e=i.length;let s=-1;for(let n=0;n=0&&this._i(t,!0)}_i(t,i){const e=this.L,s=e.elt(t);if(s.Qr=null,s.wa(null),this.Ys!==null){const o=s.data;typeof o=="object"&&this.Ys.delete(o)}e.removeAt(t),this.fe(!1),this.c(),this.el===s&&(this.el=null),this.ns=null;const n=this.part;if(n!==null){n.T0(),n.af(),n.invalidateAdornments(),n instanceof Node&&(s instanceof Panel?s.walkVisualTreeFrom(s,(r,l)=>n.g2(l,i)):n.g2(s,i));const o=this.diagram;if(o!==null&&o.undoManager.isUndoingRedoing)return;n.raiseChangedEvent(4,"elements",this,s,null,t,null)}}get Ye(){return this.O===null&&(this.O=new TablePanelSettings),this.O.Ye}get rowCount(){return this.O===null?0:this.Ye.length}getRowDefinition(t){t<0&&Util._(t,">= 0",Panel,"getRowDefinition:idx"),t=Math.round(t);const i=this.Ye;if(i[t]===void 0){const e=new RowColumnDefinition;e.wa(this),e.isRow=!0,e.index=t,i[t]=e,this.raiseChangedEvent(3,"rowdefs",this,null,e,null,t)}return i[t]}removeRowDefinition(t){if(t<0&&Util._(t,">= 0",Panel,"removeRowDefinition:idx"),this.rowCount===0)return;t=Math.round(t);const i=this.Ye,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"rowdefs",this,e,null,t,null),this.c()}}FL(t,i){const e=this.Ye;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.c()}}get Ge(){return this.O===null&&(this.O=new TablePanelSettings),this.O.Ge}get columnCount(){return this.O===null?0:this.Ge.length}getColumnDefinition(t){t<0&&Util._(t,">= 0",Panel,"getColumnDefinition:idx"),t=Math.round(t);const i=this.Ge;if(i[t]===void 0){const e=new RowColumnDefinition;e.wa(this),e.isRow=!1,e.index=t,i[t]=e,this.raiseChangedEvent(3,"coldefs",this,null,e,null,t)}return i[t]}removeColumnDefinition(t){if(t<0&&Util._(t,">= 0",Panel,"removeColumnDefinition:idx"),this.columnCount===0)return;t=Math.round(t);const i=this.Ge,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"coldefs",this,e,null,t,null),this.c()}}RL(t,i){const e=this.Ge;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.c()}}addRowColumnDefinition(t){let i=null;return t.isRow?i=this.getRowDefinition(t.index):t.isRow||(i=this.getColumnDefinition(t.index)),i&&i.Bb(t),this}addRowDefinition(t,i){const e=this.getRowDefinition(t);return e&&e.Bb(new RowColumnDefinition(i)),this}addColumnDefinition(t,i){const e=this.getColumnDefinition(t);return e&&e.Bb(new RowColumnDefinition(i)),this}get rowSizing(){return this.O!==null?this.O.cp:3}set rowSizing(t){const i=this.rowSizing;i!==t&&(this.O===null&&(this.O=new TablePanelSettings),this.O.cp=t,this.c(),this.t("rowSizing",i,t))}get columnSizing(){return this.O!==null?this.O.fp:3}set columnSizing(t){const i=this.columnSizing;i!==t&&(this.O===null&&(this.O=new TablePanelSettings),this.O.fp=t,this.c(),this.t("columnSizing",i,t))}get topIndex(){return this.O!==null?this.O.dp:0}set topIndex(t){const i=this.topIndex;i!==t&&((!isFinite(t)||t<0)&&Util.o("Panel.topIndex must be greater than zero and a real number, not: "+t),this.O===null&&(this.O=new TablePanelSettings),this.O.dp=t,this.c(),this.t("topIndex",i,t))}get leftIndex(){return this.O!==null?this.O.gp:0}set leftIndex(t){const i=this.leftIndex;i!==t&&((!isFinite(t)||t<0)&&Util.o("Panel.leftIndex must be greater than zero and a real number, not: "+t),this.O===null&&(this.O=new TablePanelSettings),this.O.gp=t,this.c(),this.t("leftIndex",i,t))}findRowForLocalY(t){if(t<0||this.type!==Panel.Table||this.rowCount===0)return-1;let i=0;const e=this.Ye,s=e.length;let n=this.topIndex;for(;n{o.rh();const r=o.Ai;if(r!==null){o.f2(!1);const l=r.iterator;for(;l.next();){const h=l.value;h.mode===2&&o.f2(!0);const a=h.sourceName;if(h.isToObject){a==="/"&&n.v2(!0);const c=h.QL(n,o);c!==null&&(i.add(c),c.Zn===null&&(c.Zn=new List),c.Zn.add(h))}t.add(h)}}if(o instanceof Panel&&o.type===Panel.Table){if(o.rowCount>0){const l=o.Ye,h=l.length;for(let a=0;a0){const l=o.Ge,h=l.length;for(let a=0;a0&&o instanceof Panel){const h=r.substring(0,l),a=r.substring(l+1),c=o.findObject(h);c!==null?(o=c,n.targetProperty=a):(Util.oi('Warning: unable to find GraphObject named "'+h+'" for Binding: '+n.toString()),o=null)}if(o instanceof RowColumnDefinition){const h=GSet.as(o.panel);n.targetId=h===void 0?-1:h,o.panel.$n=n.targetId}else if(o instanceof GraphObject){const h=GSet.as(o);n.targetId=h===void 0?-1:h,o.$n=n.targetId}else Util.o("Unknown type of binding target: "+o);n.check(o)}}return t.g(),this instanceof Part&&this.Pe()&&this.ensureBounds(),this}static gE=!1;copyTemplate(t){t===void 0&&(t=!1);const i=this.copy();return i.av(e=>{e instanceof Panel&&(e.Ks=null,e.Qt=null);const s=e.Ai;s!==null&&(e.Ai=null,s.each(o=>e.bind(o.copy())));const n=e.ys;n!==null&&(e.ys=null,n.each(o=>e.trigger(o.value.copy())))}),t&&i.li(),i}updateTargetBindings(t){const i=this.Ks;if(i===null)return;t===void 0&&(t="");const e=i.iterator;for(;e.next();){const s=e.value,n=this.SA(s,t);if(n===null)continue;const{data:o,elt:r}=n;s.isToTheme&&this.diagram===null||r!==void 0&&s.updateTarget(r,o)}}Io(){if(this.diagram!==null)if(this.m2()){const t=this.Ks.iterator;for(;t.next();){const i=t.value;if(!i.isToTheme)continue;const e=this.SA(i);if(e===null)continue;const{data:s,elt:n}=e;n!==void 0&&i.updateTarget(n,s)}}else{const t=this.L.r,i=t.length;for(let e=0;e0;let r=0;for(;n0){const i=this.L.elt(0);if(i.isPanelMain&&i instanceof Panel&&i._r())return 1}return 0}rebuildItemElements(){const t=this.ap();for(;this.L.length>t;)this._i(this.L.length-1,!1);this.NA(null,this.itemArray)}NA(t,i){const e=this.ap(),s=i;if(s===null||s.length===0){for(;this.L.length>e;)this._i(this.L.length-1,!1);return}if(this.L.length<=e){const n=s.length;for(let o=0;o(w[w.Default=1]="Default",w[w.None=2]="None",w[w.ProportionalExtra=3]="ProportionalExtra",w))(Sizing||{});class RowColumnDefinition{Vs;mp;Dt;Pa;Ma;ni;ct;pd;to;Go;yd;wd;Sa;Ct;xd;Gs;nt;ji;de;constructor(t){GSet.Yi(this),this.Vs=null,this.mp=!0,this.Dt=0,this.de=NaN,this.Pa=0,this.Ma=1/0,this.ni=Spot.Default,this.nt=0,this.ji=0,this.ct=0,this.Gs=null,this.pd=1,this.to=1,this.Go=null,this.yd=null,this.wd=NaN,this.Sa=null,this.Ct=null,this.xd=!1,t&&(Object.assign(this,t),t.column!==void 0?(this.isRow=!1,this.index=t.column):t.row!==void 0&&(this.isRow=!0,this.index=t.row))}copy(){const t=new RowColumnDefinition;return t.mp=this.mp,t.Dt=this.Dt,t.de=this.de,t.Pa=this.Pa,t.Ma=this.Ma,t.ni=this.ni,t.nt=this.nt,t.ji=this.ji,t.ct=this.ct,t.to=this.to,t.pd=this.pd,this.Go===null?t.Go=null:t.Go=this.Go.N(),t.yd=this.yd,t.wd=this.wd,t.Sa=null,this.Sa!==null&&(t.separatorDashArray=this.separatorDashArray.slice()),t.Ct=this.Ct,t.xd=this.xd,t.Gs=this.Gs,t}Bb(t){t.isRow?this.height=t.height:this.width=t.width,this.minimum=t.minimum,this.maximum=t.maximum,this.alignment=t.alignment,this.stretch=t.stretch,this.sizing=t.sizing,this.Go=t.separatorPadding===null?null:t.separatorPadding.N(),this.separatorStroke=t.separatorStroke,this.separatorStrokeWidth=t.separatorStrokeWidth,this.Sa=null,t.separatorDashArray&&(this.Sa=t.separatorDashArray.slice()),this.background=t.background,this.coversSeparators=t.coversSeparators,this.Gs=t.Gs}ri(t){t in Sizing?this.sizing=t:Util.lr(this,t)}toString(){return"RowColumnDefinition "+(this.isRow?"(Row ":"(Column ")+this.index+") #"+GSet.as(this)}static Default=1;static None=2;static ProportionalExtra=3;wa(t){this.Vs=t}computeEffectiveSpacingTop(t){let i=0;const e=this.Vs;if(this.index!==t){let n=this.separatorStroke;n===null&&e!==null&&(n=this.isRow?e.defaultRowSeparatorStroke:e.defaultColumnSeparatorStroke),n!==null&&(i=this.separatorStrokeWidth,isNaN(i)&&(e!==null?i=this.isRow?e.defaultRowSeparatorStrokeWidth:e.defaultColumnSeparatorStrokeWidth:i=0))}let s=this.Go;if(s===null)if(e!==null)s=e.defaultSeparatorPadding;else return i;return i+(this.isRow?s.top:s.left)}computeEffectiveSpacing(){let t=0;const i=this.Vs;let e=0;const s=this.isRow;if(i!==null&&i.type===Panel.Table){const o=s?i.Ye.length:i.Ge.length;for(let r=0;r= 0",RowColumnDefinition,"height"),this.de=t,this.actual=this.nt,this.panel!==null&&this.panel.c(),this.t("height",i,t))}get width(){return this.de}set width(t){const i=this.de;i!==t&&(t<0&&Util._(t,">= 0",RowColumnDefinition,"width"),this.de=t,this.actual=this.nt,this.panel!==null&&this.panel.c(),this.t("width",i,t))}get minimum(){return this.Pa}set minimum(t){const i=this.Pa;i!==t&&((t<0||!isFinite(t))&&Util._(t,">= 0",RowColumnDefinition,"minimum"),this.Pa=t,this.actual=this.nt,this.panel!==null&&this.panel.c(),this.t("minimum",i,t))}get maximum(){return this.Ma}set maximum(t){const i=this.Ma;i!==t&&(t<0&&Util._(t,">= 0",RowColumnDefinition,"maximum"),this.Ma=t,this.actual=this.nt,this.panel!==null&&this.panel.c(),this.t("maximum",i,t))}get alignment(){return this.ni}set alignment(t){const i=this.ni;i.equals(t)||(this.ni=t.N(),this.panel!==null&&this.panel.c(),this.t("alignment",i,t))}get stretch(){return this.to}set stretch(t){const i=this.to;i!==t&&(this.to=t,this.panel!==null&&this.panel.c(),this.t("stretch",i,t))}get separatorPadding(){return this.Go}set separatorPadding(t){typeof t=="number"&&(t=new Margin(t));const i=this.Go;(t===null||i===null||!i.equals(t))&&(t!==null&&(t=t.N()),this.Go=t,this.panel!==null&&this.panel.c(),this.t("separatorPadding",i,t))}get separatorStroke(){return this.yd}set separatorStroke(t){const i=this.yd;i!==t&&(t!==null&&Brush.od(t,"RowColumnDefinition.separatorStroke"),t instanceof Brush&&t.g(),this.yd=t,this.panel!==null&&this.panel.c(),this.t("separatorStroke",i,t))}get separatorStrokeWidth(){return this.wd}set separatorStrokeWidth(t){const i=this.wd;i!==t&&(this.wd=t,this.panel!==null&&this.panel.c(),this.t("separatorStrokeWidth",i,t))}get separatorDashArray(){return this.Sa}set separatorDashArray(t){const i=this.Sa;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",RowColumnDefinition,"separatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("separatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.Sa=t,this.panel!==null&&this.panel.C(),this.t("separatorDashArray",i,t)}}get background(){return this.Ct}set background(t){const i=this.Ct;i!==t&&(t!==null&&Brush.od(t,"RowColumnDefinition.background"),t instanceof Brush&&t.g(),this.Ct=t,this.panel!==null&&this.panel.C(),this.t("background",i,t))}get coversSeparators(){return this.xd}set coversSeparators(t){const i=this.xd;i!==t&&(Util.i(t,"boolean",RowColumnDefinition,"coversSeparators"),this.xd=t,this.panel!==null&&this.panel.C(),this.t("coversSeparators",i,t))}get sizing(){return this.pd}set sizing(t){const i=this.pd;i!==t&&(this.pd=t,this.panel!==null&&this.panel.c(),this.t("sizing",i,t))}Gb(){if(this.sizing===1){const t=this.Vs;return this.isRow?t.rowSizing:t.columnSizing}return this.sizing}get actual(){return this.nt}set actual(t){isNaN(this.de)?this.nt=Math.max(Math.min(this.Ma,t),this.Pa):this.nt=Math.max(Math.min(this.Ma,this.de),this.Pa)}get measured(){return this.ji}set measured(t){this.ji=t}get total(){return this.nt+this.computeEffectiveSpacing()}get position(){return this.ct}set position(t){this.ct=t}bind(t,i,e,s){return this.ef(t,i,e,s),this}bindTwoWay(t,i,e,s){const n=this.ef(t,i,e,s);return s===void 0&&n.makeTwoWay(),this}theme(t,i,e,s,n){return this.fh(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.fh(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.fh(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.fh(t,i,e,s,n).ofModel(),this}ef(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.Y0(n),n}fh(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.Y0(o),o}Y0(t){t.ke=this;const i=this.panel;if(i!==null){const e=i.findBindingPanel();e!==null&&e.cA()&&Util.o("Cannot add a Binding to a RowColumnDefinition that is already frozen: "+t+" on "+i)}this.Gs===null&&(this.Gs=new List),this.Gs.add(t)}}class Shape extends GraphObject{ft;xs;bd;Na;Hi;jo;Xo;Lt;kd;Pd;J;constructor(t,i){super(),this.ft=null,this.xs=null,this.bd="None",this.Na="black",this.Hi="black",this.jo=1,this.Xo=null,this.Lt=null,this.kd=NaN,this.Pd=NaN,this.J=null,typeof t=="string"?this.figure=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.ft=this.ft,t.xs=this.xs,t.bd=this.bd,t.Na=this.Na,t.Hi=this.Hi,t.jo=this.jo,this.Xo!==null&&(t.Xo=this.Xo.slice()),this.Lt!==null&&(this.Lt.gi?t.Lt=this.Lt:t.Lt=this.Lt.copy()),t.kd=this.kd,t.Pd=this.Pd,this.J!==null&&(t.J=this.J.copy())}Ca(){this.Lt===null?this.Lt=new ShapeTemplateSettings:this.Lt.gi&&(this.Lt=this.Lt.copy())}rh(){super.rh(),this.Lt!==null&&(this.Lt.gi=!0)}ri(t){t in GeometryStretch?this.geometryStretch=t:super.ri(t)}toString(){return"Shape("+(this.figure!=="None"?this.figure:this.toArrow!=="None"?this.toArrow:this.fromArrow)+")#"+GSet.as(this)}pv(t,i){const e=this.pathPattern;e.ut(1/0,1/0);const s=e.measuredBounds;e.zt(0,0,s.width,s.height);const n=this.geometry;t.save(),t.beginPath();const o=Util.ot();if(n.type===1)o.push(n.startX),o.push(n.startY),o.push(n.endX),o.push(n.endY),this.Md(t,i,o,e);else if(n.type===4){const r=n.figures.iterator;for(;r.next();){const l=r.value;o.length=0,o.push(l.startX),o.push(l.startY);let h=l.startX,a=l.startY,c=h,f=a;const u=l.segments.r,d=u.length;for(let m=0;m=.1;){if(S===0&&(M?(b=k,b-=P,y-=P,M=!1):b=k,b===0&&(b=1)),b>y){b=y,Util.tt(x);return}b>p?(S=b-p,b=p):S=0;let N=Math.sqrt(b*b/(1+m*m));if(u<0&&(N=-N),h+=N,a+=m*N,t.translate(h,a),t.rotate(g),t.translate(-(r/2),-(l/2)),S===0&&s.ch(t,i),t.translate(r/2,l/2),t.rotate(-g),t.translate(-h,-a),y-=b,p-=b,S!==0){if(L++,L===x.length){Util.tt(x);return}C=x[L],u=C[0],g=C[1],m=C[2],p=C[3],b=S}}Util.tt(x)}ch(t,i){const e=t instanceof SVGContext;let s=this.Hi;const n=this.Na;if(s===null&&n===null)return;const o=this.ft;if(o===null)return;t.commitTransform();const r=this.actualBounds,l=this.naturalBounds;n!==null&&this.dn(t,n,!0,!1,l,r);const h=this.part;let a=this.jo;s!==null&&a===0&&h!==null&&(this.isPanelMain||h.findMainElement()===this)&&(a=h.wv()),a===0&&(s=null),s!==null&&a!==0&&(this.dn(t,s,!1,!1,l,r),t.lineWidth=a,t.lineJoin=this.strokeJoin,t.lineCap=this.strokeCap,t.miterLimit=this.strokeMiterLimit);let c=!1;h&&i.getRenderingHint("drawShadows")&&(c=h.isShadowed),t.tl===!1&&(c=!1);let f=!0;s!==null&&(n===null||n==="transparent")&&(f=!1);let u=!1;const d=this.strokeDashArray;if(d!==null&&(u=!0,t.enableDash(d,this.strokeDashOffset)),o.type===1)t.beginPath(),t.moveTo(o.startX,o.startY),t.lineTo(o.endX,o.endY),s!==null&&t.strokeContext(),t.endPath();else if(o.type===2){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.min(m,p),k=Math.min(g,y),b=Math.abs(p-m),P=Math.abs(y-g);t.beginPath(),t.rect(x,k,b,P),n!==null&&t.fillContext(n,!1,null),s!==null&&(f&&c&&t.shadowsOff(),t.strokeContext(),f&&c&&t.shadowsOn()),t.endPath()}else if(o.type===3){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.abs(p-m)/2,k=Math.abs(y-g)/2,b=Math.min(m,p)+x,P=Math.min(g,y)+k;t.beginPath(),t.moveTo(b,P-k),t.bezierCurveTo(b+Geo.Un*x,P-k,b+x,P-Geo.Un*k,b+x,P),t.bezierCurveTo(b+x,P+Geo.Un*k,b+Geo.Un*x,P+k,b,P+k),t.bezierCurveTo(b-Geo.Un*x,P+k,b-x,P+Geo.Un*k,b-x,P),t.bezierCurveTo(b-x,P-Geo.Un*k,b-Geo.Un*x,P-k,b,P-k),t.closePath(),n!==null&&t.fillContext(n,!1,null),s!==null&&(f&&c&&t.shadowsOff(),t.strokeContext(),f&&c&&t.shadowsOn()),t.endPath()}else if(o.type===4){const m=o.figures,g=m.length;for(let p=0;p1||this.pathPattern!==null?!0:super.sd(t)}h2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("path");for(let s=0;s1,i);Util.o("Unknown Geometry type: "+e.type)}}_u(t,i,e,s){const n=this.desiredSize,o=this.jo;t=Math.max(t,0),i=Math.max(i,0);let r;if(this.xs!==null)r=this.geometry.bounds;else{const g=this.figure;let p=Shape.U2[g];if(p===void 0){let y=Geo.Mo[g];typeof y=="string"&&(y=Geo.Mo[y]),typeof y=="function"?(p=y(null,100,100),Shape.U2[g]=p):Util.o("Unsupported Figure: "+g)}r=p.bounds}let l=r.width,h=r.height,a=r.width,c=r.height;switch(this.zs(!0)){case 0:e=0,s=0;break;case 2:a=Math.max(t-o,0),c=Math.max(i-o,0);break;case 5:a=Math.max(t-o,0),s=0;break;case 4:e=0,c=Math.max(i-o,0);break}isFinite(n.width)&&(a=n.width),isFinite(n.height)&&(c=n.height);const u=this.maxSize,d=this.minSize;e=Math.max(e-o,d.width),s=Math.max(s-o,d.height),a=Math.min(u.width,a),c=Math.min(u.height,c),a=isFinite(a)?Math.max(e,a):Math.max(l,e),c=isFinite(c)?Math.max(s,c):Math.max(h,s);const m=this._P();switch(m){case 0:break;case 2:l=a,h=c;break;case 6:{let g=Math.min(a/l,c/h);isFinite(g)||(g=1),l=l*g,h=h*g;break}default:Util.o(m+" is not a valid geometryStretch.")}if(this.xs!==null){l===0&&(l=.001),h===0&&(h=.001);const p=(this.xs!==null?this.xs:this.ft).YD(l,h);this.ft=p}else(this.ft===null||!Geo.K(this.ft.ec,t-o)||!Geo.K(this.ft.sc,i-o))&&(this.ft=Shape.xv(this,l,h));r=this.ft.bounds,t===1/0||i===1/0?this.Qn(r.x-o/2,r.y-o/2,t===0&&l===0?0:r.width+o,i===0&&h===0?0:r.height+o):this.Qn(-(o/2),-(o/2),a+o,c+o),n.isReal()?(a=n.width,c=n.height,a=Math.min(u.width,a),c=Math.min(u.height,c),a=Math.max(d.width,a),c=Math.max(d.height,c),this.Vi.e(0,0,a,c)):this.Vi.a(r)}_P(){const t=this.geometryStretch;return this.xs!==null?t===1?2:t:t===1?Shape.U2[this.figure].defaultStretch:t}hh(t,i,e,s){this.commonArrange(t,i,e,s)}getNearestIntersectionPoint(t,i,e){return this.$c(t.x,t.y,i.x,i.y,e)}$c(t,i,e,s,n){const o=this.D,r=1/(o.m11*o.m22-o.m12*o.m21),l=o.m22*r,h=-o.m12*r,a=-o.m21*r,c=o.m11*r,f=r*(o.m21*o.dy-o.m22*o.dx),u=r*(o.m12*o.dx-o.m11*o.dy),d=t*l+i*a+f,m=t*h+i*c+u,g=e*l+s*a+f,p=e*h+s*c+u,y=this.jo/2;let x=this.ft;x===null&&(this.ut(1/0,1/0),x=this.ft);const k=x.bounds;let b=!1;if(x.type===1)if(this.strokeWidth<=1.5)b=Geo.Vn(x.startX,x.startY,x.endX,x.endY,d,m,g,p,n);else{let P=0,M=0;if(x.startX===x.endX)P=y,M=0;else{const T=(x.endY-x.startY)/(x.endX-x.startX);M=y/Math.sqrt(1+T*T),P=M*T}const L=Util.ot();let C=new Point;Geo.Vn(x.startX+P,x.startY+M,x.endX+P,x.endY+M,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Vn(x.startX-P,x.startY-M,x.endX-P,x.endY-M,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Vn(x.startX+P,x.startY+M,x.startX-P,x.startY-M,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Vn(x.endX+P,x.endY+M,x.endX-P,x.endY-M,d,m,g,p,C)&&L.push(C);const S=L.length;if(S===0)return Util.tt(L),!1;b=!0;let N=1/0;for(let T=0;T0&&k.contains(D,F)&&(S.x=D,S.y=F,this.containsPoint(S)))for(N!==0&&Math.abs(N)<.5?(T*=.5/N,N=.5):T!==0&&Math.abs(T)<.5&&(N*=.5/T,T=.5),D-=N,F-=T;k.contains(D,F);)D-=N,F-=T;const R=.6;n.x=g,n.y=p;for(let X=0;Xe?t-e:e-t)<(i>s?i-s:s-i)){const f=if||Geo.K(h.y,f))&&(h.yf||Geo.K(h.x,f))&&(h.x=a&&h<=c}else{let a=0,c=0;return s=a&&l<=c}}Pv(t,i){if(this.containedInRect(t,i)||i===void 0&&(i=this.D,t.containsRect(this.actualBounds)))return!0;const e=t.left,s=t.right,n=t.top,o=t.bottom,r=Point.l(),l=Point.l(),h=Point.l(),a=Transform.l();a.set(i),a.cC(this.D),a.yw(),l.x=s,l.y=n,l.D(a),r.x=e,r.y=n,r.D(a);let c=!1;return this.La(r,l,h)?c=!0:(r.x=s,r.y=o,r.D(a),this.La(r,l,h)?c=!0:(l.x=e,l.y=o,l.D(a),this.La(r,l,h)?c=!0:(r.x=e,r.y=n,r.D(a),this.La(r,l,h)&&(c=!0)))),Transform.s(a),Point.s(r),Point.s(l),Point.s(h),c}tA(t,i,e){if(e&&this.fill!==null&&this.lh(t,!0))return!0;let s=t.distanceSquaredPoint(i);const n=s;this.strokeWidth>1.5&&(s=this.strokeWidth/2+Math.sqrt(s),s*=s);let o=this.ft;if(o===null&&(this.ut(1/0,1/0),o=this.ft,o===null))return!1;if(!e){const f=o.bounds,u=f.x,d=f.y,m=f.x+f.width,g=f.y+f.height;if(Point.distanceSquared(t.x,t.y,u,d)<=s&&Point.distanceSquared(t.x,t.y,m,d)<=s&&Point.distanceSquared(t.x,t.y,u,g)<=s&&Point.distanceSquared(t.x,t.y,m,g)<=s)return!0}function r(f,u){const d=f.length;for(let m=0;ms)return!0;return!1}const l=o.startX,h=o.startY,a=o.endX,c=o.endY;if(o.type===1){const f=Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,c),u=(a-l)*(t.x-l)+(c-h)*(t.y-h),d=(l-a)*(t.x-a)+(h-c)*(t.y-c),m=u>=0&&d>=0?s:n;return f<=m}else if(o.type===2){let f=!1;return e&&(f=Point.distanceLineSegmentSquared(t.x,t.y,l,h,l,c)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,h)<=s||Point.distanceLineSegmentSquared(t.x,t.y,a,h,a,c)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,c,a,c)<=s),f}else if(o.type===3){const f=(l+a)/2,u=(h+c)/2,d=t.x-f,m=t.y-u,g=Math.abs(a-l)/2,p=Math.abs(c-h)/2;if(g===0||p===0)return Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,c)<=s;if(e){const y=Geo.OD(g,p,d,m);return y*y<=s}else return!(Point.distanceSquared(d,m,-g,0)>=s||Point.distanceSquared(d,m,0,-p)>=s||Point.distanceSquared(d,m,0,p)>=s||Point.distanceSquared(d,m,g,0)>=s)}else if(o.type===4){const f=o.bounds,u=f.x,d=f.y,m=f.x+f.width,g=f.y+f.height;if(t.x>m&&t.xg&&t.ys&&Point.distanceLineSegmentSquared(t.x,t.y,u,d,m,d)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,u,g)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,m,d)>s)return!1;const p=Math.sqrt(s);if(e){if(this.fill===null?o.kC(t.x,t.y,p):o.Vk(t,p,!0,!1))return!0}else{const y=o.figures;for(let x=0;xs)return!1;const M=k.segments.r,L=M.length;for(let C=0;Cs)return!1;break;case 3:{const N=Util.ot();Geo.Bn(b,P,S.point1X,S.point1Y,S.point2X,S.point2Y,S.endX,S.endY,.8,N);const T=r(N,t);if(Util.tt(N),T||(b=S.endX,P=S.endY,t.distanceSquared(b,P)>s))return!1;break}case 4:{const N=Util.ot();Geo.Bg(b,P,S.point1X,S.point1Y,S.endX,S.endY,.8,N);const T=r(N,t);if(Util.tt(N),T||(b=S.endX,P=S.endY,t.distanceSquared(b,P)>s))return!1;break}case 5:case 6:{const N=S.type===5?S.So(k):S.Ih(k,b,P),T=N.length;if(T===0){if(b=S.type===5?S.centerX:S.endX,P=S.type===5?S.centerY:S.endY,t.distanceSquared(b,P)>s)return!1;break}let A=null;const D=Util.ot();for(let F=0;F=0){this.jo=t,this.c();const e=this.part;e!==null&&e.af(),this.t("strokeWidth",i,t)}else Util._(t,"value >= 0",Shape,"strokeWidth:value")}Db(){return this.jo}get strokeCap(){return this.Lt!==null?this.Lt.pp:"butt"}set strokeCap(t){const i=this.strokeCap;i!==t&&(typeof t=="string"&&(t==="butt"||t==="round"||t==="square")?(this.Ca(),this.Lt.pp=t,this.C(),this.t("strokeCap",i,t)):Util._(t,'"butt", "round", or "square"',Shape,"strokeCap"))}get strokeJoin(){return this.Lt!==null?this.Lt.yp:"miter"}set strokeJoin(t){const i=this.strokeJoin;i!==t&&(typeof t=="string"&&(t==="miter"||t==="bevel"||t==="round")?(this.Ca(),this.Lt.yp=t,this.C(),this.t("strokeJoin",i,t)):Util._(t,'"miter", "bevel", or "round"',Shape,"strokeJoin"))}get strokeMiterLimit(){return this.Lt!==null?this.Lt.wp:10}set strokeMiterLimit(t){const i=this.strokeMiterLimit;if(i!==t&&t>=1){this.Ca(),this.Lt.wp=t,this.C();const e=this.part;e!==null&&e.af(),this.t("strokeMiterLimit",i,t)}}get strokeDashArray(){return this.Xo}set strokeDashArray(t){const i=this.Xo;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",Shape,"strokeDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("strokeDashArray:value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.Xo=t,this.C(),this.t("strokeDashArray",i,t)}}get strokeDashOffset(){return this.Lt!==null?this.Lt.uh:0}set strokeDashOffset(t){const i=this.strokeDashOffset;i!==t&&t>=0&&(this.Ca(),this.Lt.uh=t,this.C(),this.t("strokeDashOffset",i,t))}get figure(){return this.bd}set figure(t){const i=this.bd;if(i!==t){let e=Geo.Mo[t];if(typeof e=="function"?e=t:(e=Geo.Mo[t.toLowerCase()],e||Util.o("Unknown Shape.figure: "+t)),i!==e){const s=this.part;s!==null&&s.af(),this.bd=e,this.xs=null,this.ie(),this.c(),this.t("figure",i,e)}}}get toArrow(){return this.Ut!==null?this.Ut.xp:"None"}set toArrow(t){const i=this.toArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){const e=Shape.AA(t);e===null?Util.o("Unknown Shape.toArrow: "+t):i!==e&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.xp=e,this.xs=null,this.ie(),this.c(),this.TA(e),this.t("toArrow",i,e))}}get fromArrow(){return this.Ut!==null?this.Ut.bp:"None"}set fromArrow(t){const i=this.fromArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){const e=Shape.AA(t);e===null?Util.o("Unknown Shape.fromArrow: "+t):i!==e&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.bp=e,this.xs=null,this.ie(),this.c(),this.TA(e),this.t("fromArrow",i,e))}}TA(t){const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;this.OR();const e=Spot.MiddleRight;this.toArrow!=="None"?(this.segmentIndex=-1,this.alignmentFocus=e):this.fromArrow!=="None"&&(this.segmentIndex=0,this.alignmentFocus=new Spot(1-e.x,e.y))}get spot1(){return this.Lt!==null?this.Lt.zn:Spot.Default}set spot1(t){const i=this.spot1;i.equals(t)||(t=t.N(),this.Ca(),this.Lt.zn=t,this.c(),this.t("spot1",i,t))}get spot2(){return this.Lt!==null?this.Lt.Xn:Spot.Default}set spot2(t){const i=this.spot2;i.equals(t)||(t=t.N(),this.Ca(),this.Lt.Xn=t,this.c(),this.t("spot2",i,t))}get parameter1(){return this.kd}set parameter1(t){const i=this.kd;i!==t&&(this.kd=t,this.ie(),this.c(),this.t("parameter1",i,t))}get parameter2(){return this.Pd}set parameter2(t){const i=this.Pd;i!==t&&(this.Pd=t,this.ie(),this.c(),this.t("parameter2",i,t))}get naturalBounds(){return this.Vi}tv(){const t=this.desiredSize;if(!t.isReal()&&this.ft!==null){const i=this.ft.bounds;this.Vi.a(i)}else this.Vi.e(0,0,t.width,t.height)}get pathPattern(){return this.Lt!==null?this.Lt.kp:null}set pathPattern(t){const i=this.pathPattern;i!==t&&(this.Ca(),this.Lt.kp=t,this.C(),this.t("pathPattern",i,t))}get geometryStretch(){return this.Lt!==null?this.Lt.Pp:1}set geometryStretch(t){const i=this.geometryStretch;i!==t&&(this.Ca(),this.Lt.Pp=t,this.c(),this.t("geometryStretch",i,t))}get interval(){return this.J!==null?this.J.ff:1}set interval(t){const i=this.interval;if(t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this.J===null&&(this.J=new GradElementSettings),this.J.ff=t;const e=this.diagram;e!==null&&this.panel===e.grid&&e.jr(),this.c();const s=this.panel;s!==null&&(s.ns=null),this.t("interval",i,t)}}get graduatedStart(){return this.J!==null?this.J.uf:0}set graduatedStart(t){const i=this.graduatedStart;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.uf=t,this.c(),this.t("graduatedStart",i,t))}get graduatedEnd(){return this.J!==null?this.J.df:1}set graduatedEnd(t){const i=this.graduatedEnd;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.df=t,this.c(),this.t("graduatedEnd",i,t))}get graduatedSkip(){return this.J!==null?this.J.gf:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.i(t,"function",Shape,"graduatedSkip"),this.J===null&&(this.J=new GradElementSettings),this.J.gf=t,this.c(),this.t("graduatedSkip",i,t))}static xv(t,i,e){let n=null;if(t.toArrow!=="None")n=Shape.no[t.toArrow];else if(t.fromArrow!=="None")n=Shape.no[t.fromArrow];else{let o=Geo.Mo[t.figure];typeof o=="string"&&(o=Geo.Mo[o]),o===void 0&&Util.o("Unknown Shape.figure: "+t.figure),n=o(t,i,e),n.ec=i,n.sc=e}if(n===null){const o=Geo.Mo.Rectangle;typeof o=="function"&&(n=o(t,i,e))}return n}static getFigureGenerators(){const t=new GMap;for(const i in Geo.Mo){if(i===i.toLowerCase())continue;const e=Geo.Mo[i];t.set(i,e)}return t.g(),t}static defineFigureGenerator(t,i){Util.i(t,"string",Shape,"defineFigureGenerator:name"),typeof i=="string"||Util.i(i,"function",Shape,"defineFigureGenerator:func");const e=t.toLowerCase(),s=Geo.Mo;s[t]=i,s[e]=t}static getArrowheadGeometries(){const t=new GMap;for(const i in Geo.Kg)if(Shape.no[i]===void 0){const e=Geometry.parse(Geo.Kg[i],!1);Shape.no[i]=e;const s=i.toLowerCase();s!==i&&(Shape.no[s]=i)}for(const i in Shape.no){if(i===i.toLowerCase())continue;const e=Shape.no[i];e instanceof Geometry&&t.set(i,e)}return t.g(),t}static defineArrowheadGeometry(t,i){Util.i(t,"string",Shape,"defineArrowheadGeometry:name");let e=null;typeof i=="string"?(Util.i(i,"string",Shape,"defineArrowheadGeometry:pathstr"),e=Geometry.parse(i,!1)):e=i;const s=t.toLowerCase();(s==="none"||t===s)&&Util.o("Shape.defineArrowheadGeometry name must not be empty or None or all-lower-case: "+t);const n=Shape.no;n[t]=e,n[s]=t}static no=new PropertyCollection;static U2=new PropertyCollection;static AA(t){let i=Shape.no[t];if(i===void 0){const e=t.toLowerCase();if(e==="none")return"None";if(i=Shape.no[e],i===void 0){let s=null;for(const n in Geo.Kg)if(n.toLowerCase()===e){s=n;break}if(s!==null){const n=Geometry.parse(Geo.Kg[s],!1);return Shape.no[s]=n,e!==s&&(Shape.no[e]=s),s}}}return typeof i=="string"?i:i instanceof Geometry?t:null}}class ShapeTemplateSettings{gi;pp;yp;wp;uh;kp;Pp;zn;Xn;constructor(){this.gi=!1,this.pp="butt",this.yp="miter",this.wp=10,this.uh=0,this.kp=null,this.Pp=1,this.zn=Spot.Default,this.Xn=Spot.Default}copy(){const t=new ShapeTemplateSettings;return t.pp=this.pp,t.yp=this.yp,t.wp=this.wp,t.uh=this.uh,t.kp=this.kp,t.Pp=this.Pp,t.zn=this.zn.N(),t.Xn=this.Xn.N(),t}}var Wrap=(w=>(w[w.None=0]="None",w[w.Fit=1]="Fit",w[w.DesiredSize=2]="DesiredSize",w[w.BreakAll=3]="BreakAll",w))(Wrap||{}),TextOverflow=(w=>(w[w.Clip=0]="Clip",w[w.Ellipsis=1]="Ellipsis",w))(TextOverflow||{}),TextFormat=(w=>(w[w.Trim=0]="Trim",w[w.None=1]="None",w))(TextFormat||{});class TextBlock extends GraphObject{hi;Hi;kn;Ce;mi;x0;Sd;J;W;Dl;oo;Pn;Le;Di;Mn;constructor(t,i){return super(),this.n|=2097152,this.hi="",this.Hi="black",this.kn="13px sans-serif",this.Ce=0,this.mi=0,this.x0=0,this.Sd=null,this.J=null,this.W=null,this.Dl=0,this.oo=null,this.Pn=0,this.Le=null,this.Di=null,this.Mn=null,typeof t=="string"?this.text=t:t&&Object.assign(this,t),i&&Object.assign(this,i),this}cloneProtected(t){super.cloneProtected(t),t.hi=this.hi,t.Hi=this.Hi,t.kn=this.kn,t.Ce=this.Ce,t.mi=this.mi,t.x0=this.x0,t.Sd=this.Sd,this.J!==null&&(t.J=this.J.copy()),this.W!==null&&(this.W.gi?t.W=this.W:t.W=this.W.copy()),t.Dl=this.Dl,t.oo=this.oo,t.Pn=this.Pn,t.Le=this.Le,t.Di=this.Di,t.Mn=this.Mn}Sn(){this.W===null?this.W=new TextBlockTemplateSettings:this.W.gi&&(this.W=this.W.copy())}rh(){super.rh(),this.W!==null&&(this.W.gi=!0)}lv(t){this.n=t.n|2048|4096,this.Wt=t.opacity,this.Ct=t.background,this.ze=t.desiredSize.N(),this.minSize=t.minSize.N(),this.maxSize=t.maxSize.N(),t.bi!==null?this.bi=t.bi.copy():this.bi=null,this.st=t.scale,this.Xt=t.angle,this.stretch=t.stretch,this.Zr=t.margin.N(),this.ni=t.alignment.N(),this.qc=t.alignmentFocus.N(),this.segmentFraction=t.segmentFraction,this.segmentOffset=t.segmentOffset.N(),this.segmentOrientation=t.segmentOrientation,t.si!==null&&(this.si=t.si.copy()),this.shadowVisible=t.shadowVisible,this.hi=t.hi,this.Hi=t.Hi,this.kn=t.kn,this.J!==null&&(this.J=t.J.copy()),t.W!==null&&(t.W.gi?this.W=t.W:this.W=t.W.copy()),this.Dl=t.Dl}ov(t){if(this.hi=t.text||"",this.Xt=t.labelAngle||0,this.Ce=t.lineCount||0,this.Mv(t.lines),t.naturalBounds&&(this.Vi=t.naturalBounds),t.actualBounds){const i=t.actualBounds;this.zt(i.x,i.y,i.width,i.height)}}ri(t){t in Wrap?this.wrap=t:super.ri(t)}toString(){return this.hi.length>22?'TextBlock("'+this.hi.substring(0,20)+'"...)':'TextBlock("'+this.hi+'")'}static getEllipsis(){return TextBlock.Mp}static setEllipsis(t){TextBlock.Mp=t,TextBlock.Zb=new PropertyCollection,TextBlock.B2=0}static getBaseline(){return TextBlock.Qb}static setBaseline(t){TextBlock.Qb=t}static Qb=null;static getUnderline(){return TextBlock._b}static setUnderline(t){TextBlock._b=t}static _b=null;static None=0;static WrapFit=1;static WrapDesiredSize=2;static WrapBreakAll=3;static OverflowClip=0;static OverflowEllipsis=1;static FormatTrim=0;static FormatNone=1;c(){super.c()}get font(){return this.kn}set font(t){const i=this.kn;i!==t&&(this.kn=t,this.oo=null,this.c(),this.t("font",i,t))}static isValidFont(t){return root.CSS?root.CSS.supports("font",t):!0}get text(){return this.hi}set text(t){const i=this.hi;t!=null?t=t.toString():t="",i!==t&&(this.hi=t,this.c(),this.t("text",i,t),this.ss(!0))}get textAlign(){return this.W!==null?this.W.Sp:"start"}set textAlign(t){const i=this.textAlign;i!==t&&(t==="start"||t==="end"||t==="left"||t==="right"||t==="center")&&(this.Sn(),this.W.Sp=t,this.C(),this.t("textAlign",i,t))}get flip(){return this.W!==null?this.W.ro:0}set flip(t){const i=this.flip;i!==t&&(this.Sn(),this.W.ro=t,this.C(),this.t("flip",i,t))}get verticalAlignment(){return this.W!==null?this.W.sl:Spot.Top}set verticalAlignment(t){const i=this.verticalAlignment;i.equals(t)||(t=t.N(),this.Sn(),this.W.sl=t,this.tf(),this.t("verticalAlignment",i,t))}get naturalBounds(){if(!this.Vi.isReal()){const t=Size.l();this.V2(this.hi,999999,t);let i=t.width;Size.s(t);let e=this.DA(i);const s=this.desiredSize;isNaN(s.width)||(i=s.width),isNaN(s.height)||(e=s.height),this.Vi.En(i,e)}return this.Vi}get isMultiline(){return(this.n&2097152)!==0}set isMultiline(t){const i=(this.n&2097152)!==0;i!==t&&(this.n=this.n^2097152,this.c(),this.t("isMultiline",i,t))}get isUnderline(){return(this.n&4194304)!==0}set isUnderline(t){const i=(this.n&4194304)!==0;i!==t&&(this.n=this.n^4194304,this.ss(!0),this.C(),this.t("isUnderline",i,t))}get isStrikethrough(){return(this.n&8388608)!==0}set isStrikethrough(t){const i=(this.n&8388608)!==0;i!==t&&(this.n=this.n^8388608,this.ss(!0),this.C(),this.t("isStrikethrough",i,t))}get wrap(){return this.W!==null?this.W.Np:2}set wrap(t){const i=this.wrap;i!==t&&(this.Sn(),this.W.Np=t,this.c(),this.t("wrap",i,t))}get overflow(){return this.W!==null?this.W.Cp:0}set overflow(t){const i=this.overflow;i!==t&&(this.Sn(),this.W.Cp=t,this.c(),this.t("overflow",i,t))}get isOverflowed(){return(this.n&16777216)!==0}z2(t){t?this.n|=16777216:this.n&=-16777217}get stroke(){return this.Hi}set stroke(t){const i=this.Hi;i!==t&&(t!==null&&Brush.od(t,"TextBlock.stroke"),t instanceof Brush&&t.g(),this.Hi=t,this.C(),this.t("stroke",i,t))}get lineCount(){return this.Ce}get lineHeight(){return this.Lp()}get editable(){return(this.n&1048576)!==0}set editable(t){const i=(this.n&1048576)!==0;i!==t&&(this.n=this.n^1048576,this.t("editable",i,t))}get T2(){return(this.n&33554432)!==0}set T2(t){this.n=this.n^33554432}get textEditor(){return this.W!==null?this.W.Ap:null}set textEditor(t){const i=this.textEditor;i!==t&&(this.Sn(),this.W.Ap=t,this.t("textEditor",i,t))}get errorFunction(){return this.W!==null?this.W.os:null}set errorFunction(t){const i=this.errorFunction;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"errorFunction"),this.Sn(),this.W.os=t,this.t("errorFunction",i,t))}get interval(){return this.J!==null?this.J.ff:1}set interval(t){const i=this.interval;if(t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this.J===null&&(this.J=new GradElementSettings),this.J.ff=t,this.c();const e=this.panel;e!==null&&(e.ns=null),this.t("interval",i,t)}}get graduatedStart(){return this.J!==null?this.J.uf:0}set graduatedStart(t){const i=this.graduatedStart;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.uf=t,this.c(),this.t("graduatedStart",i,t))}get graduatedEnd(){return this.J!==null?this.J.df:1}set graduatedEnd(t){const i=this.graduatedEnd;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.df=t,this.c(),this.t("graduatedEnd",i,t))}get graduatedFunction(){return this.J!==null?this.J.Tp:null}set graduatedFunction(t){const i=this.graduatedFunction;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"graduatedFunction"),this.J===null&&(this.J=new GradElementSettings),this.J.Tp=t,this.c(),this.t("graduatedFunction",i,t))}get graduatedSkip(){return this.J!==null?this.J.gf:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"graduatedSkip"),this.J===null&&(this.J=new GradElementSettings),this.J.gf=t,this.c(),this.t("graduatedSkip",i,t))}ch(t,i){if(this.Hi===null||this.hi.length===0||this.kn===null)return;const e=this.naturalBounds,s=this.actualBounds,n=e.width,o=e.height,r=this.Lp();let l=t.textAlign=this.textAlign;const h=i.Ku;l==="start"?l=h?"right":"left":l==="end"&&(l=h?"left":"right");const a=this.isUnderline,c=this.isStrikethrough;this.dn(t,this.Hi,!0,!1,e,s),(a||c)&&this.dn(t,this.Hi,!1,!1,e,s);const f=0;let u=0;const d=n;let m=!1;i.Zt===t&&!(i.Zt instanceof SVGContext)&&!this.T2&&i.getRenderingHint("textGreeking")===!0&&r*this.aa*i.scale<3&&(m=!0);const g=this.spacingAbove,p=this.spacingBelow;switch(this.flip){case 0:break;case 2:t.translate(n,0),t.scale(-1,1);break;case 1:t.translate(0,o),t.scale(1,-1);break;case 3:t.translate(n,o),t.scale(-1,-1);break}t.commitTransform();const y=this.Ce,k=(g+r+p)*y;if(o>k){const b=this.verticalAlignment;u=b.y*o-b.y*k+b.offsetY}if(y===1&&this.Mn!==null){let b=this.mi;b>d&&(b=d),u+=g,this.FA(this.Mn,t,f,u,d,r,b,m,l,a,c)}else if(this.Le!==null&&this.Di!==null)for(let b=0;bd&&(P=d),u+=g,this.FA(this.Di[b],t,f,u,d,r,P,m,l,a,c),u+=r+p}switch(this.flip){case 0:break;case 2:t.scale(-1,1),t.translate(-n,0);break;case 1:t.scale(1,-1),t.translate(0,-o);break;case 3:t.scale(-1,-1),t.translate(-n,-o);break}}FA(t,i,e,s,n,o,r,l,h,a,c){let f=0;if(l){h==="left"?f=0:h==="right"?f=n-r:h==="center"&&(f=(n-r)/2);const m=i.globalAlpha;i.globalAlpha=m/2,i.fillRect(e+f,s+o/4,r,o/2),i.globalAlpha=m;return}h==="left"?f=0:h==="right"?f=n:h==="center"&&(f=n/2);const u=TextBlock.Qb!==null?TextBlock.Qb(this,o):o*.75;i.fillText(t,e+f,s+u);let d=o/20|0;if(d===0&&(d=1),h==="right"?f-=r:h==="center"&&(f-=r/2),a){const m=TextBlock._b!==null?TextBlock._b(this,o):o*.8;this.RA(e+f,s+m,e+f+r,s+m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}if(c){let m=s+o-o/2.2|0;d%2!==0&&(m+=.5),this.RA(e+f,m,e+f+r,m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}}RA(t,i,e,s,n,o){o.beginPath(),o.lineWidth=n,o.moveTo(t,i),o.lineTo(e,s),o.stroke(),o.endPath()}Zc(t,i,e){if(!super.Zc(t,i,e))return!1;if(this.dn(t,this.Hi,!0,!1,this.naturalBounds,this.actualBounds),e){if(this.svg.getElementsByTagName("text").length===0)return!0;const n=this.svg.getElementsByClassName("gojs-td");for(let o=0;o1||this.isUnderline||this.isStrikethrough?!0:super.sd(t)}h2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("text");for(let s=0;sthis.maxLines&&(this.n|=16777216))}V2(t,i,e){const s=this.formatting===0;s&&(t=t.trim());let n=0,o=0,r=0;const l=this.kn,h=this.spacingAbove+this.spacingBelow,a=Math.max(0,this.Lp()+h),c=this.overflow===1?this.OA(l):0;if(this.Ce>=this.maxLines){e!==null&&e.e(0,a);return}let f=t;if(this.wrap===0){if(this.Pn=1,o=this.getStringWidth(t),c===0||o<=i){this.mi=Math.max(this.mi,o),this.Nn(t,this.mi),e!==null&&e.e(o,a);return}let d=this.Nd(f);f=f.substring(d.length);let m=this.Nd(f);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,f=f.substring(m.length),m=this.Nd(f),r=o;let g=d+m;s&&(g=g.trim()),o=this.getStringWidth(g)}for(s&&(m=m.trim()),d+=m,i=Math.max(1,i-c);this.getStringWidth(d)>i&&d.length>1;)d=d.substring(0,d.length-1);this.z2(!0),d+=TextBlock.Mp,r=this.getStringWidth(d),this.mi=r,this.Nn(d,r),e!==null&&e.e(r,a);return}let u=0;for(f.length===0&&(u=1,this.Nn(f,0));f.length>0;){let d=this.Nd(f);for(f=f.substring(d.length);this.getStringWidth(d)>i;){let p=1;for(o=this.getStringWidth(d.substring(0,p)),r=0;o<=i;)p++,r=o,o=this.getStringWidth(d.substring(0,p));let y=0;p===1?(y=o,n=Math.max(n,o)):(y=r,n=Math.max(n,r)),p--,p<1&&(p=1);const x=d.substring(0,p);if(this.Nn(x,y),u++,d=d.substring(p),this.Ce+u>this.maxLines)break}let m=this.Nd(f);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,f=f.substring(m.length),m=this.Nd(f),r=o;let p=d+m;s&&(p=p.trim()),o=this.getStringWidth(p)}if(s&&(d=d.trim()),d==="")continue;d[d.length-1]==="\xAD"&&(d=d.substring(0,d.length-1)+"\u2010");let g=0;if(m.length===0?(g=o,n=Math.max(n,o)):(r=this.getStringWidth(d),g=r,n=Math.max(n,r)),this.Nn(d,g),u++,this.Ce+u>this.maxLines)break}this.Pn=Math.min(this.maxLines,u),this.mi=Math.max(this.mi,n),e!==null&&e.e(this.mi,a*this.Pn)}Lv(t,i){if(this.mi===0||this.Le===null||this.Di===null||this.overflow!==1)return;const e=this.kn,s=this.overflow===1?this.OA(e):0,n=this.spacingAbove+this.spacingBelow,o=Math.max(0,this.Lp()+n),r=Math.min(this.maxLines-1,Math.max(Math.floor(i/o+.01)-1,0));if(r+1>=this.Di.length)return;this.z2(!0);let l=this.Di[r];const h=Math.max(1,t-s);for(;this.getStringWidth(l)>h&&l.length>1;)l=l.substring(0,l.length-1);l+=TextBlock.Mp;const a=this.getStringWidth(l);this.Di[r]=l,this.Di=this.Di.slice(0,r+1),this.Le[r]=a,this.Le=this.Le.slice(0,r+1),this.Pn=this.Di.length,this.mi=Math.max(this.mi,a),this.Ce=this.Pn,this.Ce===1&&(this.Mn=this.Di[0])}Nd(t){if(this.wrap===3)return t.substring(0,1);let i=t.length,e=0;const s=TextBlock.Av;for(;e=t.length?t:t.substring(0,e)}getStringWidth(t){return TextBlock.il===null?t.length*8:TextBlock.il.measureText(t).width}Lp(){if(this.oo!==null)return this.oo;const t=this.kn;let i=0;return TextBlock.il===null?(i=16,this.oo=i,i):(TextBlock.X2[t]!==void 0&&TextBlock.IA<5e3?i=TextBlock.X2[t]:(i=TextBlock.il.measureText("M").width*1.3,TextBlock.X2[t]=i,TextBlock.IA++),this.oo=i,i)}OA(t){if(TextBlock.il===null)return 6;let i=0;return TextBlock.Zb[t]!==void 0&&TextBlock.B2<5e3?i=TextBlock.Zb[t]:(i=TextBlock.il.measureText(TextBlock.Mp).width,TextBlock.Zb[t]=i,TextBlock.B2++),i}t1(t,i){return t.indexOf(` +(function() {const root=typeof globalThis=="object"&&globalThis||typeof global=="object"&&global.global===global&&global||typeof self=="object"&&self.self===self&&self||{};root.requestAnimationFrame===void 0&&(root.setImmediate===void 0?root.requestAnimationFrame=w=>root.setTimeout(w,0):root.requestAnimationFrame=root.setImmediate);class Util{static rr=root.navigator!==void 0&&root.navigator.platform!==void 0&&root.navigator.platform.match(/(iPhone|iPod|iPad|Mac)/i)!==null;static Nk(t,i,e){let s=-1;return function(){const n=this,o=arguments;s!==-1&&Util.Og(s),s=Util.Oh(()=>{s=-1,e||t.apply(n,o)},i),e&&!s&&t.apply(n,o)}}static Oh(t,i){return root.setTimeout(t,i)}static Og(t){root.clearTimeout(t)}static en(t){return root.document.createElement(t)}static o(t){throw new Error(t)}static T(t,i){let e="The object is frozen, so its properties cannot be set: "+t.toString();i!==void 0&&(e+=" to value: "+i),Util.o(e)}static qI(t,i,e,s){}static i(t,i,e,s){}static WI(t,i,e){}static JI(t,i,e){}static we(t,i,e,s){}static _(t,i,e,s){let n=Util.ND(e);s!==void 0&&(n+="."+s),Util.o(n+" is not in the range "+i+": "+t)}static ve(t){}static lr(t,i){}static ii(t){root.console&&root.console.log(t)}static wt(t){return typeof t=="object"&&t!==null}static $I(t,i,e){}static eu(t,i,e){Array.isArray(t)?i>=t.length?t.push(e):t.splice(i,0,e):Util.o("Cannot insert an object into an HTMLCollection or NodeList: "+e+" at "+i)}static tc(t,i){Array.isArray(t)?i>=t.length?t.pop():t.splice(i,1):Util.o("Cannot remove an object from an HTMLCollection or NodeList at "+i)}static Ck=[];static nt(){const t=Util.Ck.pop();return t===void 0?[]:t}static tt(t){t.length=0,Util.Ck.push(t)}static ZI=Object.freeze([]);static ND(t){return t===null?"*":typeof t=="string"?t:typeof t=="function"?t.name:""}static sn(t){return typeof t=="function"?t.className?t.className:t.name:Util.wt(t)&&t.constructor?Util.sn(t.constructor):typeof t}static Ih(t,i){return i==null||i===""?null:Util.wt(t)&&i in t||t[i]?t[i]:null}static toString(t){let i=t;return Util.wt(t)&&(t.text?i=t.text:t.name?i=t.name:t.key!==void 0?i=t.key:t.id!==void 0?i=t.id:t.constructor===Object&&(t.Text?i=t.Text:t.Name?i=t.Name:t.Key!==void 0?i=t.Key:t.Id!==void 0?i=t.Id:t.ID!==void 0&&(i=t.ID))),i===void 0?"undefined":i===null?"null":i.toString()}static fw(t,i){if(t.hasOwnProperty(i))return!0;let e=Object.getPrototypeOf(t);for(;e&&e!==Function;){if(e.hasOwnProperty(i))return!0;const s=e.QI;if(s&&s[i])return!0;e=Object.getPrototypeOf(e)}return!1}static CD(t){const i=[];let e=0;for(e=0;e<256;e++)i[e]=e;let s=0,n=0;for(e=0;e<256;e++)s=(s+i[e]+119)%256,n=i[e],i[e]=i[s],i[s]=n;e=0,s=0;let o="";for(let r=0;r>4)+i.charAt(r&15)]=String.fromCharCode(r);t.length%2&&(t="0"+t);const s=[];let n=0;for(let r=0;r0){const n=i[0];return this.key=0,this.value=n,n}else return null}any(t){const i=this.qt;i.hr=null;const e=i.ht;this.Dt=-1;const s=i.r,n=s.length,o=this.Ls;for(let r=0;r=0?(this.key=i,this.value=t.r[i],!0):(this.gl(),!1)}hasNext(){return this.next()}first(){const t=this.qt;this.Yt=t.ht;const i=t.r,e=i.length-1;if(this.Dt=e,e>=0){const s=i[e];return this.key=e,this.value=s,s}else return null}any(t){const i=this.qt;i.ar=null;const e=i.ht,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(t(r))return!0;i.ht!==e&&Util.ve(i)}return!1}all(t){const i=this.qt;i.ar=null;const e=i.ht,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(!t(r))return!1;i.ht!==e&&Util.ve(i)}return!0}each(t){const i=this.qt;i.ar=null;const e=i.ht,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];t(r),i.ht!==e&&Util.ve(i)}return this}map(t){const i=this.qt;i.ar=null;const e=i.ht,s=[],n=i.r,o=n.length;this.Dt=o;for(let l=o-1;l>=0;l--){const h=n[l];s.push(t(h)),i.ht!==e&&Util.ve(i)}const r=new List;return r.r=s,r.Oe(),r.iterator}filter(t){const i=this.qt;i.ar=null;const e=i.ht,s=[],n=i.r,o=n.length;this.Dt=o;for(let l=o-1;l>=0;l--){const h=n[l];t(h)&&s.push(h),i.ht!==e&&Util.ve(i)}const r=new List;return r.r=s,r.Oe(),r.iterator}get count(){return this.qt.r.length}gl(){this.key=-1,this.value=null,this.Yt=-1,this.qt.ar=this}toString(){return"ListIteratorBackwards("+this.Dt+"/"+this.qt.count+")"}}class List{h;r;ht;hr;ar;constructor(t){GSet.Yi(this),this.h=!1,this.r=[],this.ht=0,this.hr=null,this.ar=null,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.r.values()}Oe(){let t=this.ht;t++,t>999999999&&(t=0),this.ht=t}g(){return this.h=!0,this}ot(){return this.h=!1,this}toString(){return"List()#"+GSet.as(this)}add(t){return this.h&&Util.T(this,t),this.r.push(t),this.Oe(),this}push(t){this.add(t)}addAll(t){if(t===null)return this;this.h&&Util.T(this);const i=this.r;if(Array.isArray(t)){const e=t.length;for(let s=0;s=i.length)&&Util._(t,"0 <= i < length",List,"elt:i"),i[t]}get(t){return this.elt(t)}setElt(t,i){const e=this.r;(t<0||t>=e.length)&&Util._(t,"0 <= i < length",List,"setElt:i"),this.h&&Util.T(this,t),e[t]=i}set(t,i){this.setElt(t,i)}first(){const t=this.r;return t.length===0?null:t[0]}last(){const t=this.r,i=t.length;return i>0?t[i-1]:null}pop(){this.h&&Util.T(this);const t=this.r;return t.length>0?t.pop():null}any(t){const i=this.r,e=this.ht,s=i.length;for(let n=0;n= 0",List,"insertAt:i"),this.h&&Util.T(this,t);const e=this.r;t>=e.length?e.push(i):e.splice(t,0,i),this.Oe()}remove(t){return this.delete(t)}delete(t){if(t===null)return!1;this.h&&Util.T(this,t);const i=this.r,e=i.indexOf(t);return e===-1?!1:(e===i.length-1?i.pop():i.splice(e,1),this.Oe(),!0)}removeAt(t){const i=this.r;(t<0||t>=i.length)&&Util._(t,"0 <= i < length",List,"removeAt:i"),this.h&&Util.T(this,t),t===i.length-1?i.pop():i.splice(t,1),this.Oe()}removeRange(t,i){const e=this.r,s=e.length;if(t<0)t=0;else if(t>=s)return this;if(i<0)return this;if(i>=s&&(i=s-1),t>i)return this;this.h&&Util.T(this);let n=t,o=i+1;for(;o0&&(t.r=Array.prototype.slice.call(i)),t}toArray(){const t=this.r,i=this.count,e=new Array(i);for(let s=0;s=n-1)&&Util._(i,"0 <= from < length",List,"sortRange:from"),o===2){const r=s[i],l=s[i+1];return t(r,l)>0&&(s[i]=l,s[i+1]=r,this.Oe()),this}if(i===0)if(e>=n)s.sort(t);else{const r=s.slice(0,e);r.sort(t);for(let l=0;l=n){const r=s.slice(i);r.sort(t);for(let l=i;li.add(t(e))),i.iterator}filter(t){const i=new List;return this.ko.w.forEach(e=>{t(e)&&i.add(e)}),i.iterator}get count(){return this.ko.count}gl(){this.key=null,this.value=null,this.ei=null}toString(){return"SetIterator"}}class GSet{h;w;constructor(t){this.h=!1,this.w=new Set,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.w.values()}values(){return this.w.values()}g(){return this.h=!0,this}ot(){return this.h=!1,this}toString(){return"Set()#"+GSet.as(this)}add(t){return t===null?this:(this.w.add(t),this)}addAll(t){if(t===null)return this;if(Array.isArray(t)){const i=t.length;for(let e=0;et.add(i)),t}toArray(){return Array.from(this.w)}toList(){const t=new List;return this.w.forEach(i=>t.add(i)),t}get count(){return this.w.size}get size(){return this.w.size}get iterator(){return this.w.size<=0?EmptyIterator.instance:new SetIterator(this)}entries(){return this.w.entries()}keys(){return this.w.keys()}forEach(t,i){return this.w.forEach(t,i)}static su=1;static Yi(t){t.__gohashid=GSet.su++}static as(t){return t.__gohashid}}class MapKeySetIterator{Z;ei;constructor(t){this.Z=t,this.ei=t.w.keys()}[Symbol.iterator](){return this.Z.w.keys()}key;value;get iterator(){return this}reset(){const t=this.Z;this.ei=t.w.keys()}next(){const t=this.ei.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.Z.w.size===0?null:(this.ei=this.Z.w.keys(),this.ei.next().value)}any(t){for(const i of this.Z.w)if(t(i[0]))return!0;return!1}all(t){for(const i of this.Z.w)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.Z.w)t(i[0]);return this}map(t){const i=this.Z,e=new List;for(const s of i.w)e.add(t(s[0]));return e.iterator}filter(t){const i=this.Z,e=new List;for(const s of i.w){const n=s[0];t(n)&&e.add(n)}return e.iterator}get count(){return this.Z.size}gl(){this.key=null,this.value=null,this.ei=null}toString(){return"MapKeySetIterator"}}class MapKeySet extends GSet{Z;constructor(t){super(),GSet.Yi(this),this.h=!0,this.Z=t}[Symbol.iterator](){return this.w.keys()}values(){return this.w.keys()}g(){return this}ot(){return this}toString(){return"MapKeySet("+this.Z.toString()+")"}add(t){Util.o("This Set is read-only: "+this.toString())}has(t){return this.Z.has(t)}contains(t){return this.has(t)}delete(t){Util.o("This Set is read-only: "+this.toString())}remove(t){return this.delete(t)}clear(){Util.o("This Set is read-only: "+this.toString())}first(){return this.Z.w.size===0?null:this.Z.w.keys().next().value}any(t){for(const i of this.Z.w)if(t(i[0]))return!0;return!1}all(t){for(const i of this.Z.w)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.Z.w)t(i[0]);return this}map(t){const i=new GSet;for(const e of this.Z.w)i.add(t(e[0]));return i}filter(t){const i=new GSet;for(const e of this.Z.w){const s=e[0];t(s)&&i.add(s)}return i}copy(){return new MapKeySet(this.Z)}toSet(){const t=new GSet,i=this.Z.w;for(const e of i)t.add(e[0]);return t}toArray(){const t=this.Z.w,i=new Array(t.size);let e=0;for(const s of t)i[e]=s[0],e++;return i}toList(){const t=new List,i=this.Z.w;for(const e of i)t.add(e[0]);return t}get count(){return this.Z.size}get size(){return this.Z.size}get iterator(){return this.Z.size<=0?EmptyIterator.instance:new MapKeySetIterator(this.Z)}}class MapValueSetIterator{Z;ei;constructor(t){this.Z=t,this.ei=t.w.values()}[Symbol.iterator](){return this.Z.w.values()}key;value;get iterator(){return this}reset(){const t=this.Z;this.ei=t.w.values()}next(){const t=this.ei.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.Z.w.size===0?null:(this.ei=this.Z.w.values(),this.ei.next().value)}any(t){for(const i of this.Z.w)if(t(i[1]))return!0;return!1}all(t){for(const i of this.Z.w)if(!t(i[1]))return!1;return!0}each(t){for(const i of this.Z.w)t(i[1]);return this}map(t){const i=this.Z,e=new List;for(const s of i.w)e.add(t(s[1]));return e.iterator}filter(t){const i=this.Z,e=new List;for(const s of i.w){const n=s[1];t(n)&&e.add(n)}return e.iterator}get count(){return this.Z.size}gl(){this.key=null,this.value=null,this.ei=null}toString(){return"MapValueSetIterator"}}class KeyValuePair{constructor(t,i){this.key=t,this.value=i}toString(){return"{"+this.key+":"+this.value+"}"}key;value}class MapIterator{Z;ei;constructor(t){this.Z=t,this.ei=t.w.entries()}[Symbol.iterator](){return this.Z.w.entries()}key;value;get iterator(){return this}reset(){const t=this.Z;this.ei=t.w.entries()}next(){const t=this.ei.next();return t.done?(this.key=null,this.value=null,!1):(this.key=t.value[0],this.value=t.value[1],!0)}hasNext(){return this.next()}first(){if(this.Z.w.size===0)return null;this.ei=this.Z.w.entries();const t=this.ei.next().value;return this.key=t[0],this.value=t[1],new KeyValuePair(t[0],t[1])}any(t){return this.Z.any(t)}all(t){return this.Z.all(t)}each(t){return this.Z.each(t),this}map(t){const i=new List;let e=null;return this.Z.w.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),i.add(t(e))}),i.iterator}filter(t){const i=new List;let e=null;return this.Z.w.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),t(e)&&(i.add(e),e=null)}),i.iterator}get count(){return this.Z.size}gl(){this.key=null,this.value=null,this.ei=null}toString(){return"MapIterator"}}class GMap{h;w;constructor(t){GSet.Yi(this),this.h=!1,this.w=new Map,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.w.entries()}entries(){return this.w.entries()}g(){return this.h=!0,this}ot(){return this.h=!1,this}toString(){return"Map()#"+GSet.as(this)}set(t,i){return this.h&&Util.T(this,t),this.w.set(t,i),this}add(t,i){return this.set(t,i)}addAll(t){if(t===null)return this;if(this.h&&Util.T(this),Array.isArray(t)){const i=t.length;for(let e=0;ei.x.toFixed(t)+" "+i.y.toFixed(t)}toString(){return"Point("+this.x+","+this.y+")"}equals(t){return t instanceof Point?this.b===t.x&&this.k===t.y:!1}equalTo(t,i){return this.b===t&&this.k===i}equalsApprox(t){return Geo.u(this.b,t.x)&&Geo.u(this.k,t.y)}add(t){return this.b+=t.x,this.k+=t.y,this}subtract(t){return this.b-=t.x,this.k-=t.y,this}offset(t,i){return this.b+=t,this.k+=i,this}rotate(t){if(t===0)return this;const i=this.b,e=this.k;if(i===0&&e===0)return this;let s=0,n=0;if(t>=360?t-=360:t<0&&(t+=360),t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const o=t*Math.PI/180;s=Math.cos(o),n=Math.sin(o)}return this.b=s*i-n*e,this.k=n*i+s*e,this}scale(t,i){return this.b*=t,this.k*=i,this}distanceSquaredPoint(t){const i=t.x-this.b,e=t.y-this.k;return i*i+e*e}distanceSquared(t,i){const e=t-this.b,s=i-this.k;return e*e+s*s}normalize(){const t=this.b,i=this.k,e=Math.sqrt(t*t+i*i);return e>0&&(this.b=t/e,this.k=i/e),this}directionPoint(t){return this.JN(t.x-this.b,t.y-this.k)}direction(t,i){return this.JN(t-this.b,i-this.k)}JN(t,i){if(t===0)return i>0?90:i<0?270:0;if(i===0)return t>0?0:180;{if(isNaN(t)||isNaN(i))return 0;let e=Math.atan(Math.abs(i/t))*180/Math.PI;return t<0?i<0?e+=180:e=180-e:i<0&&(e=360-e),e}}static compareWithLineSegment(t,i,e,s,n,o){return Geo.nu(t,i,e,s,n,o)}compareWithLineSegmentPoint(t,i){return Geo.nu(t.x,t.y,i.x,i.y,this.x,this.y)}static intersectingLineSegments(t,i,e,s,n,o,r,l){return Geo.ou(t,i,e,s,n,o,r,l)}projectOntoLineSegment(t,i,e,s){return Geo.ml(t,i,e,s,this.b,this.k,this),this}projectOntoLineSegmentPoint(t,i){return Geo.ml(t.x,t.y,i.x,i.y,this.b,this.k,this),this}snapToGrid(t,i,e,s){return Geo.Ig(this.b,this.k,t,i,e,s,this),this}snapToGridPoint(t,i){return Geo.Ig(this.b,this.k,t.x,t.y,i.width,i.height,this),this}setRectSpot(t,i){return this.b=t.x+i.x*t.width+i.offsetX,this.k=t.y+i.y*t.height+i.offsetY,this}setSpot(t,i,e,s,n){return this.b=t+n.x*e+n.offsetX,this.k=i+n.y*s+n.offsetY,this}D(t){return t.xt(this),this}Ie(t){return t._e(this),this}static distanceLineSegmentSquared(t,i,e,s,n,o){let r=n-e,l=o-s;const h=r*r+l*l,a=e-t,c=s-i,f=-a*r-c*l;if(f<=0||f>=h)return r=n-t,l=o-i,Math.min(a*a+c*c,r*r+l*l);{const u=r*c-l*a;return u*u/h}}static distanceSquared(t,i,e,s){const n=e-t,o=s-i;return n*n+o*o}static direction(t,i,e,s){const n=e-t,o=s-i;if(n===0)return o>0?90:o<0?270:0;if(o===0)return n>0?0:180;{if(isNaN(n)||isNaN(o))return 0;let r=Math.atan(Math.abs(o/n))*180/Math.PI;return n<0?o<0?r+=180:r=180-r:o<0&&(r=360-r),r}}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}isReal(){return isFinite(this.x)&&isFinite(this.y)}static Po=new Point(0,0).it();static $N=new Point(-1/0,-1/0).it();static ZN=new Point(1/0,1/0).it();static QN=new Point(6,6).it();static Ak=new Point(NaN,NaN).it();static Tk=[];static l(){const t=Point.Tk.pop();return t===void 0?new Point:t}static X(t,i){const e=Point.Tk.pop();return e===void 0?new Point(t,i):(e.x=t,e.y=i,e)}static s(t){Point.Tk.push(t)}}class Size{j;H;h;constructor(t,i){t===void 0?(this.j=0,this.H=0):typeof t=="number"&&(t>=0||isNaN(t))&&typeof i=="number"&&(i>=0||isNaN(i))?(this.j=t,this.H=i):Util.o("Invalid arguments to Size constructor: "+t+", "+i),this.h=!1}a(t){return this.j=t.j,this.H=t.H,this}e(t,i){return this.j=t,this.H=i,this}setTo(t,i){return this.j=t,this.H=i,this}set(t){return this.j=t.j,this.H=t.H,this}copy(){const t=new Size;return t.j=this.j,t.H=this.H,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}ot(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;return n=i[e++],n&&(o=parseFloat(n)),new Size(s,o)}else return new Size}static stringify(t){return t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.i(t,"number",Size,"stringifyFixed:digits"),i=>i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Size("+this.width+","+this.height+")"}equals(t){return t instanceof Size?this.j===t.width&&this.H===t.height:!1}equalTo(t,i){return this.j===t&&this.H===i}equalsApprox(t){return Geo.u(this.j,t.width)&&Geo.u(this.H,t.height)}inflate(t,i){const e=this.width+t;this.j=e>=0?e:0;const s=this.height+i;return this.H=s>=0?s:0,this}get width(){return this.j}set width(t){t<0&&Util._(t,">= 0",Size,"width"),this.j=t}get height(){return this.H}set height(t){t<0&&Util._(t,">= 0",Size,"height"),this.H=t}isReal(){return isFinite(this.width)&&isFinite(this.height)}static ru=new Size(0,0).it();static Dk=new Size(1,1).it();static _N=new Size(6,6).it();static lu=new Size(8,8).it();static tC=new Size(10,10).it();static iC=new Size(1/0,1/0).it();static gw=new Size(NaN,NaN).it();static eC=[];static l(){const t=Size.eC.pop();return t===void 0?new Size:t}static s(t){Size.eC.push(t)}}class Rect{b;k;j;H;h;constructor(t,i,e,s){if(t===void 0)this.b=0,this.k=0,this.j=0,this.H=0;else if(typeof t=="number"&&typeof i=="number"&&typeof e=="number"&&(e>=0||isNaN(e))&&typeof s=="number"&&(s>=0||isNaN(s)))this.b=t,this.k=i,this.j=e,this.H=s;else if(t instanceof Point){const n=t.x,o=t.y;if(i instanceof Point){const r=i.x,l=i.y;this.b=Math.min(n,r),this.k=Math.min(o,l),this.j=Math.abs(n-r),this.H=Math.abs(o-l)}else i instanceof Size?(this.b=n,this.k=o,this.j=i.width,this.H=i.height):Util.o("Incorrect second argument supplied to Rect constructor "+i)}else Util.o("Invalid arguments to Rect constructor: "+t+", "+i+", "+e+", "+s);this.h=!1}a(t){return this.b=t.b,this.k=t.k,this.j=t.j,this.H=t.H,this}e(t,i,e,s){return this.b=t,this.k=i,this.j=e,this.H=s,this}En(t,i){return this.j=t,this.H=i,this}setTo(t,i,e,s){return this.b=t,this.k=i,this.j=e,this.H=s,this}set(t){return this.b=t.b,this.k=t.k,this.j=t.j,this.H=t.H,this}setPoint(t){return this.b=t.x,this.k=t.y,this}setSize(t){return this.j=t.width,this.H=t.height,this}copy(){const t=new Rect;return t.b=this.b,t.k=this.k,t.j=this.j,t.H=this.H,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}ot(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),new Rect(s,o,r,l)}else return new Rect}static stringify(t){return t.x.toString()+" "+t.y.toString()+" "+t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.i(t,"number",Rect,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Rect("+this.x+","+this.y+","+this.width+","+this.height+")"}equals(t){return t instanceof Rect?this.b===t.x&&this.k===t.y&&this.j===t.width&&this.H===t.height:!1}equalTo(t,i,e,s){return this.b===t&&this.k===i&&this.j===e&&this.H===s}equalsApprox(t){return Geo.u(this.b,t.x)&&Geo.u(this.k,t.y)&&Geo.u(this.j,t.width)&&Geo.u(this.H,t.height)}equalsApproxTo(t,i,e,s){return Geo.u(this.b,t)&&Geo.u(this.k,i)&&Geo.u(this.j,e)&&Geo.u(this.H,s)}equalsApproxClose(t){return Geo.K(this.b,t.x)&&Geo.K(this.k,t.y)&&Geo.K(this.j,t.width)&&Geo.K(this.H,t.height)}containsPoint(t){return this.b<=t.x&&this.b+this.j>=t.x&&this.k<=t.y&&this.k+this.H>=t.y}containsRect(t){return this.b<=t.x&&t.x+t.width<=this.b+this.j&&this.k<=t.y&&t.y+t.height<=this.k+this.H}contains(t,i,e,s){return e===void 0&&(e=0),s===void 0&&(s=0),this.b<=t&&t+e<=this.b+this.j&&this.k<=i&&i+s<=this.k+this.H}offset(t,i){return this.b+=t,this.k+=i,this}inflate(t,i){return this.mw(i,t,i,t)}addMargin(t){return this.mw(t.top,t.right,t.bottom,t.left)}subtractMargin(t){return this.mw(-t.top,-t.right,-t.bottom,-t.left)}grow(t,i,e,s){return this.mw(t,i,e,s)}mw(t,i,e,s){const n=this.j;i+s<=-n?(this.b+=n/2,this.j=0):(this.b-=s,this.j+=i+s);const o=this.H;return t+e<=-o?(this.k+=o/2,this.H=0):(this.k-=t,this.H+=t+e),this}intersectRect(t){return this.sC(t.x,t.y,t.width,t.height)}intersect(t,i,e,s){return this.sC(t,i,e,s)}sC(t,i,e,s){const n=Math.max(this.b,t),o=Math.max(this.k,i),r=Math.min(this.b+this.j,t+e),l=Math.min(this.k+this.H,i+s);return this.b=n,this.k=o,this.j=Math.max(0,r-n),this.H=Math.max(0,l-o),this}intersectsRect(t){return this.intersects(t.x,t.y,t.width,t.height)}intersects(t,i,e,s){let n=this.j;const o=this.b;if(n!==1/0&&e!==1/0&&(n+=o,e+=t,isNaN(e)||isNaN(n)||o>e||t>n))return!1;let r=this.H;const l=this.k;return!(r!==1/0&&s!==1/0&&(r+=l,s+=i,isNaN(s)||isNaN(r)||l>s||i>r))}intersectsRectPlus(t,i){let e=this.j,s=t.width+i+i;const n=this.b,o=t.x-i;if(e+=n,s+=o,n>s||o>e)return!1;let r=this.H,l=t.height+i+i;const h=this.k,a=t.y-i;return r+=h,l+=a,!(h>l||a>r)}unionPoint(t){return this.unionNoCheck(t.x,t.y,0,0)}unionRect(t){return this.unionNoCheck(t.b,t.k,t.j,t.H)}union(t,i,e,s){return e===void 0&&(e=0),s===void 0&&(s=0),this.unionNoCheck(t,i,e,s)}unionNoCheck(t,i,e,s){const n=Math.min(this.b,t),o=Math.min(this.k,i),r=Math.max(this.b+this.j,t+e),l=Math.max(this.k+this.H,i+s);return this.b=n,this.k=o,this.j=r-n,this.H=l-o,this}setSpot(t,i,e){return this.b=t-e.offsetX-e.x*this.j,this.k=i-e.offsetY-e.y*this.H,this}static contains(t,i,e,s,n,o,r,l){return r===void 0&&(r=0),l===void 0&&(l=0),t<=n&&n+r<=t+e&&i<=o&&o+l<=i+s}static intersects(t,i,e,s,n,o,r,l){let h=e,a=r;const c=t,f=n;if(h+=c,a+=f,c>a||f>h)return!1;let u=s,d=l;const m=i,g=o;return u+=m,d+=g,!(m>d||g>u)}static intersectsLineSegment(t,i,e,s,n,o,r,l){return Geo.nC(t,i,e,s,n,o,r,l)}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}get width(){return this.j}set width(t){t<0&&Util._(t,">= 0",Rect,"width"),this.j=t}get height(){return this.H}set height(t){t<0&&Util._(t,">= 0",Rect,"height"),this.H=t}get left(){return this.b}set left(t){this.b=t}get top(){return this.k}set top(t){this.k=t}get right(){return this.b+this.j}set right(t){this.b+=t-(this.b+this.j)}get bottom(){return this.k+this.H}set bottom(t){this.k+=t-(this.k+this.H)}get position(){return new Point(this.b,this.k)}set position(t){this.b=t.x,this.k=t.y}get size(){return new Size(this.j,this.H)}set size(t){this.j=t.width,this.H=t.height}get center(){return new Point(this.b+this.j/2,this.k+this.H/2)}set center(t){this.b=t.x-this.j/2,this.k=t.y-this.H/2}get centerX(){return this.b+this.j/2}set centerX(t){this.b=t-this.j/2}get centerY(){return this.k+this.H/2}set centerY(t){this.k=t-this.H/2}isReal(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)}isEmpty(){return this.width===0&&this.height===0}static pw=new Rect(0,0,0,0).it();static AD=new Rect(NaN,NaN,NaN,NaN).it();static Fk=[];static l(){const t=Rect.Fk.pop();return t===void 0?new Rect:t}static X(t,i,e,s){const n=Rect.Fk.pop();return n===void 0?new Rect(t,i,e,s):n.e(t,i,e,s)}static s(t){Rect.Fk.push(t)}}class Margin{nn;on;rn;ln;h;constructor(t,i,e,s){t===void 0?(this.nn=0,this.on=0,this.rn=0,this.ln=0):i===void 0?(i=t,e=t,s=t,this.top=t,this.right=i,this.bottom=e,this.left=s):e===void 0?(e=t,s=i,this.top=t,this.right=i,this.bottom=e,this.left=s):s!==void 0?(this.top=t,this.right=i,this.bottom=e,this.left=s):Util.o("Invalid arguments to Margin constructor: "+t+", "+i+", "+e+", "+s),this.h=!1}a(t){return this.nn=t.nn,this.on=t.on,this.rn=t.rn,this.ln=t.ln,this}setTo(t,i,e,s){return this.nn=t,this.on=i,this.rn=e,this.ln=s,this}set(t){return this.nn=t.nn,this.on=t.on,this.rn=t.rn,this.ln=t.ln,this}copy(){const t=new Margin;return t.nn=this.nn,t.on=this.on,t.rn=this.rn,t.ln=this.ln,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}ot(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=NaN;for(;i[e]==="";)e++;let n=i[e++];if(n&&(s=parseFloat(n)),isNaN(s))return new Margin;let o=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(o=parseFloat(n)),isNaN(o))return new Margin(s);let r=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(r=parseFloat(n)),isNaN(r))return new Margin(s,o);let l=NaN;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),isNaN(l)?new Margin(s,o):new Margin(s,o,r,l)}else return new Margin}static stringify(t){return t.top.toString()+" "+t.right.toString()+" "+t.bottom.toString()+" "+t.left.toString()}static stringifyFixed(t){return Util.i(t,"number",Margin,"stringifyFixed:digits"),i=>i.top.toFixed(t)+" "+i.right.toFixed(t)+" "+i.bottom.toFixed(t)+" "+i.left.toFixed(t)}toString(){return"Margin("+this.top+","+this.right+","+this.bottom+","+this.left+")"}equals(t){return t instanceof Margin?this.nn===t.top&&this.on===t.right&&this.rn===t.bottom&&this.ln===t.left:!1}equalTo(t,i,e,s){return this.nn===t&&this.on===i&&this.rn===e&&this.ln===s}equalsApprox(t){return Geo.u(this.nn,t.top)&&Geo.u(this.on,t.right)&&Geo.u(this.rn,t.bottom)&&Geo.u(this.ln,t.left)}get top(){return this.nn}set top(t){this.nn=t}get right(){return this.on}set right(t){this.on=t}get bottom(){return this.rn}set bottom(t){this.rn=t}get left(){return this.ln}set left(t){this.ln=t}isReal(){return isFinite(this.top)&&isFinite(this.right)&&isFinite(this.bottom)&&isFinite(this.left)}static Eg=new Margin(0,0,0,0).it();static oC=new Margin(2,2,2,2).it();static rC=[];static l(){const t=Margin.rC.pop();return t===void 0?new Margin:t}static s(t){Margin.rC.push(t)}}class Spot{b;k;As;Ts;h;constructor(t,i,e,s){t===void 0?(this.b=0,this.k=0,this.As=0,this.Ts=0):(i===void 0&&(i=0),e===void 0&&(e=0),s===void 0&&(s=0),this.x=t,this.y=i,this.offsetX=e,this.offsetY=s),this.h=!1}a(t){return this.b=t.b,this.k=t.k,this.As=t.As,this.Ts=t.Ts,this}setTo(t,i,e,s){return this.b=t,this.k=i,this.As=e,this.Ts=s,this}set(t){return this.b=t.b,this.k=t.k,this.As=t.As,this.Ts=t.Ts,this}copy(){const t=new Spot;return t.b=this.b,t.k=this.k,t.As=this.As,t.Ts=this.Ts,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}ot(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}Ee(t){return this.b=NaN,this.k=NaN,this.As=t,this}_I(t,i){(isNaN(t)||t>1||t<0)&&Util._(t,"0 <= "+i+" <= 1",Spot,i)}tE(t,i){(isNaN(t)||t===1/0||t===-1/0)&&Util._(t,"real number, not NaN or Infinity",Spot,i)}static parse(t){if(typeof t=="string"){if(t=t.trim(),t==="None")return Spot.None;if(t==="TopLeft")return Spot.TopLeft;if(t==="Top"||t==="TopCenter"||t==="MiddleTop")return Spot.TopCenter;if(t==="TopRight")return Spot.TopRight;if(t==="Left"||t==="LeftCenter"||t==="MiddleLeft")return Spot.LeftCenter;if(t==="Center")return Spot.Center;if(t==="Right"||t==="RightCenter"||t==="MiddleRight")return Spot.RightCenter;if(t==="BottomLeft")return Spot.BottomLeft;if(t==="Bottom"||t==="BottomCenter"||t==="MiddleBottom")return Spot.BottomCenter;if(t==="BottomRight")return Spot.BottomRight;if(t==="TopSide")return Spot.TopSide;if(t==="LeftSide")return Spot.LeftSide;if(t==="RightSide")return Spot.RightSide;if(t==="BottomSide")return Spot.BottomSide;if(t==="TopBottomSides")return Spot.TopBottomSides;if(t==="LeftRightSides")return Spot.LeftRightSides;if(t==="TopLeftSides")return Spot.TopLeftSides;if(t==="TopRightSides")return Spot.TopRightSides;if(t==="BottomLeftSides")return Spot.BottomLeftSides;if(t==="BottomRightSides")return Spot.BottomRightSides;if(t==="NotTopSide")return Spot.NotTopSide;if(t==="NotLeftSide")return Spot.NotLeftSide;if(t==="NotRightSide")return Spot.NotRightSide;if(t==="NotBottomSide")return Spot.NotBottomSide;if(t==="AllSides")return Spot.AllSides;if(t==="Default")return Spot.Default;const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n!==void 0&&n.length>0&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n!==void 0&&n.length>0&&(l=parseFloat(n)),new Spot(s,o,r,l)}else return new Spot}static stringify(t){return t.isSpot()?t.x.toString()+" "+t.y.toString()+" "+t.offsetX.toString()+" "+t.offsetY.toString():t.toString()}static stringifyFixed(t){return Util.i(t,"number",Spot,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.offsetX.toFixed(t)+" "+i.offsetY.toFixed(t)}toString(){return this.isSpot()?this.As===0&&this.Ts===0?"Spot("+this.x+","+this.y+")":"Spot("+this.x+","+this.y+","+this.offsetX+","+this.offsetY+")":this.equals(Spot.None)?"None":this.equals(Spot.TopLeft)?"TopLeft":this.equals(Spot.TopCenter)?"Top":this.equals(Spot.TopRight)?"TopRight":this.equals(Spot.LeftCenter)?"Left":this.equals(Spot.Center)?"Center":this.equals(Spot.RightCenter)?"Right":this.equals(Spot.BottomLeft)?"BottomLeft":this.equals(Spot.BottomCenter)?"Bottom":this.equals(Spot.BottomRight)?"BottomRight":this.equals(Spot.TopSide)?"TopSide":this.equals(Spot.LeftSide)?"LeftSide":this.equals(Spot.RightSide)?"RightSide":this.equals(Spot.BottomSide)?"BottomSide":this.equals(Spot.TopBottomSides)?"TopBottomSides":this.equals(Spot.LeftRightSides)?"LeftRightSides":this.equals(Spot.TopLeftSides)?"TopLeftSides":this.equals(Spot.TopRightSides)?"TopRightSides":this.equals(Spot.BottomLeftSides)?"BottomLeftSides":this.equals(Spot.BottomRightSides)?"BottomRightSides":this.equals(Spot.NotTopSide)?"NotTopSide":this.equals(Spot.NotLeftSide)?"NotLeftSide":this.equals(Spot.NotRightSide)?"NotRightSide":this.equals(Spot.NotBottomSide)?"NotBottomSide":this.equals(Spot.AllSides)?"AllSides":this.equals(Spot.Default)?"Default":"None"}equals(t){return t instanceof Spot?(this.b===t.x||isNaN(this.b)&&isNaN(t.x))&&(this.k===t.y||isNaN(this.k)&&isNaN(t.y))&&this.As===t.offsetX&&this.Ts===t.offsetY:!1}opposite(){return new Spot(.5-(this.b-.5),.5-(this.k-.5),-this.As,-this.Ts)}includesSide(t){if(!this.isSide())return!1;if(!t.isSide())if(t.equals(Spot.Left))t=Spot.LeftSide;else if(t.equals(Spot.Right))t=Spot.RightSide;else if(t.equals(Spot.Top))t=Spot.TopSide;else if(t.equals(Spot.Bottom))t=Spot.BottomSide;else return!1;const i=this.Ts,e=t.offsetY;return(i&e)===e}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}get offsetX(){return this.As}set offsetX(t){this.As=t}get offsetY(){return this.Ts}set offsetY(t){this.Ts=t}isSpot(){return!isNaN(this.x)&&!isNaN(this.y)}isNoSpot(){return isNaN(this.x)||isNaN(this.y)}isSide(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===1&&this.offsetY!==0}isNone(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===0&&this.offsetY===0}isDefault(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===-1&&this.offsetY===0}static None=new Spot(0,0,0,0).Ee(0).it();static Default=new Spot(0,0,-1,0).Ee(-1).it();static TopLeft=new Spot(0,0,0,0).it();static TopCenter=new Spot(.5,0,0,0).it();static TopRight=new Spot(1,0,0,0).it();static LeftCenter=new Spot(0,.5,0,0).it();static Center=new Spot(.5,.5,0,0).it();static RightCenter=new Spot(1,.5,0,0).it();static BottomLeft=new Spot(0,1,0,0).it();static BottomCenter=new Spot(.5,1,0,0).it();static BottomRight=new Spot(1,1,0,0).it();static MiddleTop=Spot.TopCenter;static MiddleLeft=Spot.LeftCenter;static MiddleRight=Spot.RightCenter;static MiddleBottom=Spot.BottomCenter;static Top=Spot.TopCenter;static Left=Spot.LeftCenter;static Right=Spot.RightCenter;static Bottom=Spot.BottomCenter;static TopSide=new Spot(0,0,1,1).Ee(1).it();static LeftSide=new Spot(0,0,1,2).Ee(1).it();static RightSide=new Spot(0,0,1,4).Ee(1).it();static BottomSide=new Spot(0,0,1,8).Ee(1).it();static TopBottomSides=new Spot(0,0,1,9).Ee(1).it();static LeftRightSides=new Spot(0,0,1,6).Ee(1).it();static TopLeftSides=new Spot(0,0,1,3).Ee(1).it();static TopRightSides=new Spot(0,0,1,5).Ee(1).it();static BottomLeftSides=new Spot(0,0,1,10).Ee(1).it();static BottomRightSides=new Spot(0,0,1,12).Ee(1).it();static NotTopSide=new Spot(0,0,1,14).Ee(1).it();static NotLeftSide=new Spot(0,0,1,13).Ee(1).it();static NotRightSide=new Spot(0,0,1,11).Ee(1).it();static NotBottomSide=new Spot(0,0,1,7).Ee(1).it();static AllSides=new Spot(0,0,1,15).Ee(1).it();static Rk=new Spot(.156,.156).it();static vk=new Spot(.844,.844).it();static lC=[];static l(){const t=Spot.lC.pop();return t===void 0?new Spot:t}static s(t){Spot.lC.push(t)}}class Transform{m11;m12;m21;m22;dx;dy;constructor(){this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0}set(t){return this.m11=t.m11,this.m12=t.m12,this.m21=t.m21,this.m22=t.m22,this.dx=t.dx,this.dy=t.dy,this}setTo(t,i,e,s,n,o){return this.m11=t,this.m12=i,this.m21=e,this.m22=s,this.dx=n,this.dy=o,this}copy(){const t=new Transform;return t.m11=this.m11,t.m12=this.m12,t.m21=this.m21,t.m22=this.m22,t.dx=this.dx,t.dy=this.dy,t}toString(){return"Transform("+this.m11+","+this.m12+","+this.m21+","+this.m22+","+this.dx+","+this.dy+")"}equals(t){return this.m11===t.m11&&this.m12===t.m12&&this.m21===t.m21&&this.m22===t.m22&&this.dx===t.dx&&this.dy===t.dy}Ok(){return this.dx===0&&this.dy===0&&this.m11===1&&this.m12===0&&this.m21===0&&this.m22===1}Ri(){return this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0,this}ic(t){const i=this.m11*t.m11+this.m21*t.m12,e=this.m12*t.m11+this.m22*t.m12,s=this.m11*t.m21+this.m21*t.m22,n=this.m12*t.m21+this.m22*t.m22;return this.dx=this.m11*t.dx+this.m21*t.dy+this.dx,this.dy=this.m12*t.dx+this.m22*t.dy+this.dy,this.m11=i,this.m12=e,this.m21=s,this.m22=n,this}hC(t){const i=1/(t.m11*t.m22-t.m12*t.m21),e=t.m22*i,s=-t.m12*i,n=-t.m21*i,o=t.m11*i,r=i*(t.m21*t.dy-t.m22*t.dx),l=i*(t.m12*t.dx-t.m11*t.dy),h=this.m11*e+this.m21*s,a=this.m12*e+this.m22*s,c=this.m11*n+this.m21*o,f=this.m12*n+this.m22*o;return this.dx=this.m11*r+this.m21*l+this.dx,this.dy=this.m12*r+this.m22*l+this.dy,this.m11=h,this.m12=a,this.m21=c,this.m22=f,this}yw(){const t=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*t,e=-this.m12*t,s=-this.m21*t,n=this.m11*t,o=t*(this.m21*this.dy-this.m22*this.dx),r=t*(this.m12*this.dx-this.m11*this.dy);return this.m11=i,this.m12=e,this.m21=s,this.m22=n,this.dx=o,this.dy=r,this}cs(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return this;this.Ds(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m11*s+this.m21*n,r=this.m12*s+this.m22*n,l=this.m11*-n+this.m21*s,h=this.m12*-n+this.m22*s;return this.m11=o,this.m12=r,this.m21=l,this.m22=h,this.Ds(-i,-e),this}Ds(t,i){return this.dx+=this.m11*t+this.m21*i,this.dy+=this.m12*t+this.m22*i,this}et(t,i){return i===void 0&&(i=t),this.m11*=t,this.m12*=t,this.m21*=i,this.m22*=i,this}TD(){if(this.m11===1&&this.m12===0)return 0;let t=Math.atan2(this.m12,this.m11)*180/Math.PI;return t<0&&(t+=360),t}xt(t){const i=t.x,e=t.y;return t.e(i*this.m11+e*this.m21+this.dx,i*this.m12+e*this.m22+this.dy)}_e(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=t.x-this.dx,l=t.y-this.dy;return t.e(r*e+l*n,r*s+l*o)}ww(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=i*(this.m21*this.dy-this.m22*this.dx),l=i*(this.m12*this.dx-this.m11*this.dy),h=t.x*1.25,a=t.y*1.2;return t.e(h*e+a*n+r,h*s+a*o+l)}xw(t){const i=t.x,e=t.y,s=i+t.width,n=e+t.height,o=this.m11,r=this.m12,l=this.m21,h=this.m22,a=this.dx,c=this.dy,f=i*o+e*l+a,u=i*r+e*h+c,d=s*o+e*l+a,m=s*r+e*h+c,g=i*o+n*l+a,p=i*r+n*h+c,y=s*o+n*l+a,x=s*r+n*h+c;let k=f,b=f,P=u,S=u;return k=Math.min(k,d),b=Math.max(b,d),P=Math.min(P,m),S=Math.max(S,m),k=Math.min(k,g),b=Math.max(b,g),P=Math.min(P,p),S=Math.max(S,p),k=Math.min(k,y),b=Math.max(b,y),P=Math.min(P,x),S=Math.max(S,x),t.e(k,P,b-k,S-P),t}static aC=[];static l(){const t=Transform.aC.pop();return t===void 0?new Transform:t}static s(t){Transform.aC.push(t)}static Ik="54a702f3e53909c447824c6706603faf4c"}const Geo={DD:"7da71ca0ad381e90",Bn:4*((Math.sqrt(2)-1)/3),cC:null,bw:w=>{if(w<=0)return 0;let t=Geo.cC;if(t===null){t=[];for(let i=0;i<=2e3;i++)t[i]=Math.sqrt(i);Geo.cC=t}if(w<1){const i=1/w;return i<=2e3?1/t[i|0]:Math.sqrt(w)}else return w<=2e3?t[w|0]:Math.sqrt(w)},u:(w,t)=>{const i=w-t;return i<.5&&i>-.5},K:(w,t)=>{const i=w-t;return i<5e-8&&i>-5e-8},vi:(w,t,i,e,s,n,o)=>{s<=0&&(s=1e-6);let r=0,l=0,h=0,a=0;if(wu-d)if(w-i>s||i-w>s){const g=(e-t)/(i-w)*(n-w)+t;if(g-s<=o&&o<=g+s)return!0}else return!0;else if(t-e>s||e-t>s){const g=(i-w)/(e-t)*(o-t)+w;if(g-s<=n&&n<=g+s)return!0}else return!0}return!1},kw:(w,t,i,e,s,n,o,r,l,h,a,c)=>{if(!Geo.vi(w,t,o,r,c,i,e)||!Geo.vi(w,t,o,r,c,s,n)){const f=(w+i)/2,u=(t+e)/2,d=(i+s)/2,m=(e+n)/2,g=(s+o)/2,p=(n+r)/2,y=(f+d)/2,x=(u+m)/2,k=(d+g)/2,b=(m+p)/2,P=(y+k)/2,S=(x+b)/2;return Geo.kw(w,t,f,u,y,x,P,S,l,h,a,c)||Geo.kw(P,S,k,b,g,p,o,r,l,h,a,c)}else return Geo.vi(w,t,o,r,c,h,a)},fC:(w,t,i,e,s,n,o,r,l)=>{const h=(w+i)/2,a=(t+e)/2,c=(i+s)/2,f=(e+n)/2,u=(s+o)/2,d=(n+r)/2,m=(h+c)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2;return l.e((m+p)/2,(g+y)/2),l},FD:(w,t,i,e,s,n,o,r)=>{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(s+o)/2,u=(n+r)/2,d=(l+a)/2,m=(h+c)/2,g=(a+f)/2,p=(c+u)/2;return Point.direction(d,m,g,p)},hu:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.vi(w,t,o,r,l,i,e)||!Geo.vi(w,t,o,r,l,s,n)){const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.hu(w,t,a,c,g,p,k,b,l,h),Geo.hu(k,b,y,x,d,m,o,r,l,h)}else h.unionNoCheck(w,t,0,0),h.unionNoCheck(o,r,0,0);return h},Un:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.vi(w,t,o,r,l,i,e)||!Geo.vi(w,t,o,r,l,s,n)){const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.Un(w,t,a,c,g,p,k,b,l,h),Geo.Un(k,b,y,x,d,m,o,r,l,h)}else h.length===0&&(h.push(w),h.push(t)),h.push(o),h.push(r);return h},Ek:(w,t,i,e,s,n,o,r,l,h)=>{if(Geo.vi(w,t,s,n,h,i,e))return Geo.vi(w,t,s,n,h,r,l);{const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(a+f)/2,m=(c+u)/2;return Geo.Ek(w,t,a,c,d,m,o,r,l,h)||Geo.Ek(d,m,f,u,s,n,o,r,l,h)}},iE:(w,t,i,e,s,n,o)=>{const r=(w+i)/2,l=(t+e)/2,h=(i+s)/2,a=(e+n)/2;return o.e((r+h)/2,(l+a)/2),o},Bk:(w,t,i,e,s,n,o,r)=>{if(Geo.vi(w,t,s,n,o,i,e))r.unionNoCheck(w,t,0,0),r.unionNoCheck(s,n,0,0);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(l+a)/2,u=(h+c)/2;Geo.Bk(w,t,l,h,f,u,o,r),Geo.Bk(f,u,a,c,s,n,o,r)}return r},Bg:(w,t,i,e,s,n,o,r)=>{if(Geo.vi(w,t,s,n,o,i,e))r.length===0&&(r.push(w),r.push(t)),r.push(s),r.push(n);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(l+a)/2,u=(h+c)/2;Geo.Bg(w,t,l,h,f,u,o,r),Geo.Bg(f,u,a,c,s,n,o,r)}return r},Ug:(w,t,i,e,s,n,o,r,l,h,a,c,f,u)=>{if(!Geo.vi(w,t,o,r,f,i,e)||!Geo.vi(w,t,o,r,f,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,P=(g+y)/2,S=(p+x)/2,L=(k+P)/2,C=(b+S)/2;let M=1/0,N=!1,T=0,A=0;if(Geo.Ug(w,t,d,m,k,b,L,C,l,h,a,c,f,u)){const D=(u.x-l)*(u.x-l)+(u.y-h)*(u.y-h);D{let u=0;if(!Geo.vi(w,t,o,r,f,i,e)||!Geo.vi(w,t,o,r,f,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,P=(g+y)/2,S=(p+x)/2,L=(k+P)/2,C=(b+S)/2;u+=Geo.Vg(w,t,d,m,k,b,L,C,l,h,a,c,f),u+=Geo.Vg(L,C,P,S,y,x,o,r,l,h,a,c,f)}else{const d=(w-o)*(h-c)-(t-r)*(l-a);if(d===0)return u;const m=((w*r-t*o)*(l-a)-(w-o)*(l*c-h*a))/d,g=((w*r-t*o)*(h-c)-(t-r)*(l*c-h*a))/d;if(m>=a)return u;let p=0,y=0;if((l>a?l-a:a-l)<(h>c?h-c:c-h)){if(ty)return u}else if(wy)return u;d>0?u++:d<0&&u--}return u},ml:(w,t,i,e,s,n,o)=>{if(Geo.K(w,i)){let r=0,l=0;tl?(o.e(w,l),!1):(o.e(w,h),!0)}else if(Geo.K(t,e)){let r=0,l=0;wl?(o.e(l,t),!1):(o.e(h,t),!0)}else{const r=(i-w)*(i-w)+(e-t)*(e-t),l=((w-s)*(w-i)+(t-n)*(t-e))/r;if(l<-5e-6)return o.e(w,t),!1;if(l>1.000005)return o.e(i,e),!1;{const h=w+l*(i-w),a=t+l*(e-t);return o.e(h,a),!0}}},Vn:(w,t,i,e,s,n,o,r,l)=>{if(Geo.u(w,i)&&Geo.u(t,e))return l.e(w,t),!1;if(Geo.K(s,o)){if(Geo.K(w,i))return Geo.ml(w,t,i,e,s,n,l),!1;{const a=(e-t)/(i-w)*(s-w)+t;return Geo.ml(w,t,i,e,s,a,l)}}else{const h=(r-n)/(o-s);if(Geo.K(w,i)){const a=h*(w-s)+n;let c=0,f=0;return tf?(l.e(w,f),!1):(l.e(w,a),!0)}else{const a=(e-t)/(i-w);if(Geo.K(h,a))return Geo.ml(w,t,i,e,s,n,l),!1;{const c=(a*w-h*s+n-t)/(a-h);if(Geo.K(a,0)){let f=0,u=0;return wu?(l.e(u,t),!1):(l.e(c,t),!0)}else{const f=a*(c-w)+t;return Geo.ml(w,t,i,e,c,f,l)}}}}},eE:(w,t,i,e,s)=>Geo.Vn(i.x,i.y,e.x,e.y,w.x,w.y,t.x,t.y,s),sE:(w,t,i,e,s,n,o,r,l,h)=>{let a=1/0;function c(P,S){const L=(P-w)*(P-w)+(S-t)*(S-t);Lw?i-w:w-i)<.5){const P=1-(i-k)*(i-k)/(y*y);if(P<0)return l;const S=Math.sqrt(P),L=x*S+b,C=-x*S+b;c(i,L),c(i,C)}else{const P=(e-t)/(i-w),S=1/(y*y)+P*P/(x*x),L=2*P*(t-P*w)/(x*x)-2*P*b/(x*x)-2*k/(y*y),C=2*P*w*b/(x*x)-2*t*b/(x*x)+b*b/(x*x)+k*k/(y*y)-1+(t-P*w)*(t-P*w)/(x*x),M=L*L-4*S*C;if(M<0)return l;const N=Math.sqrt(M),T=(-L+N)/(2*S);c(T,P*T-P*w+t);const A=(-L-N)/(2*S);c(A,P*A-P*w+t)}return l},pl:(w,t,i,e,s,n,o,r,l)=>{let h=1e21,a=w,c=t;if(Geo.Vn(w,t,w,e,s,n,o,r,l)){const f=(l.x-s)*(l.x-s)+(l.y-n)*(l.y-n);fGeo.nC(w.x,w.y,w.width,w.height,t.x,t.y,i.x,i.y),nC:(w,t,i,e,s,n,o,r)=>{const l=w,h=w+i,a=t,c=t+e;if(s===o){let f=0,u=0;return n=a}if(n===r){let f=0,u=0;return s=l}return!!(Rect.contains(w,t,i,e,s,n)||Rect.contains(w,t,i,e,o,r)||Geo.ou(l,a,h,a,s,n,o,r)||Geo.ou(h,a,h,c,s,n,o,r)||Geo.ou(h,c,l,c,s,n,o,r)||Geo.ou(l,c,l,a,s,n,o,r))},ou:(w,t,i,e,s,n,o,r)=>w===i&&t===e&&s===o&&n===r?w===s&&t===n:Geo.nu(w,t,i,e,s,n)*Geo.nu(w,t,i,e,o,r)<=0&&Geo.nu(s,n,o,r,w,t)*Geo.nu(s,n,o,r,i,e)<=0,nu:(w,t,i,e,s,n)=>{const o=i-w,r=e-t;let l=s-w,h=n-t,a=l*r-h*o;return a===0&&(a=l*o+h*r,a>0&&(l-=o,h-=r,a=l*o+h*r,a<0&&(a=0))),a},zg:w=>(w<0&&(w+=360),w>=360&&(w-=360),w),uC:(w,t,i,e,s,n)=>{const o=Math.PI;n||(e=e*(o/180),s=s*(o/180));const r=e>s?-1:1,l=1e-5,h=o*2,a=[],c=o/2;let f=e,u=Math.min(h,Math.abs(s-e));if(ul;){const d=f+r*Math.min(u,c);a.push(Geo.RD(i,f,d,w,t)),u-=Math.abs(d-f),f=d}return a},RD:(w,t,i,e,s)=>{const n=(i-t)/2,o=w*Math.cos(n),r=w*Math.sin(n),l=o,h=-r,a=l*l+h*h,c=a+l*o+h*r,f=4/3*(Math.sqrt(2*a*c)-c)/(l*r-h*o),u=l-f*h,d=h+f*l,m=u,g=-d,p=n+t,y=Math.cos(p),x=Math.sin(p);return[e+w*Math.cos(t),s+w*Math.sin(t),e+u*y-d*x,s+u*x+d*y,e+m*y-g*x,s+m*x+g*y,e+w*Math.cos(i),s+w*Math.sin(i)]},Ig:(w,t,i,e,s,n,o)=>{const r=s,l=n,h=Math.floor((w-i)/r)*r+i,a=Math.floor((t-e)/l)*l+e;let c=h;h+r-w{let i=Math.max(w,t),e=Math.min(w,t),s=1,n=1;do s=i%e,n=e,i=e,e=s;while(s>0);return n},vD:(w,t,i,e)=>{const s=i<0,n=e<0;let o=0,r=0,l=0;w{let o=0;if(e>0)if(i>0){const r=w*w,l=t*t,h=w*i,a=t*e;let c=-l+a,f=-l+Math.sqrt(h*h+a*a),u=c;const d=9999999999;for(let p=0;p0)c=u;else if(k<0)f=u;else break}s=r*i/(u+r),n=l*e/(u+l);const m=s-i,g=n-e;o=Math.sqrt(m*m+g*g)}else s=0,n=t,o=Math.abs(e-t);else{const r=w*w-t*t,l=w*i;if(l(w[w.Line=1]="Line",w[w.Rectangle=2]="Rectangle",w[w.Ellipse=3]="Ellipse",w[w.Path=4]="Path",w))(GeometryType||{}),GeometryStretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w))(GeometryStretch||{});class Geometry{n;Yg;Gg;ec;au;cu;zn;Xn;Kn;$;xe;be;Qi;_i;Fs;sc;nc;constructor(t){GSet.Yi(this),this.n=2,t===void 0&&(t=4),this.$=t,this.xe=0,this.be=0,this.Qi=0,this._i=0,t===4?this.Fs=new List:this.Fs=Geometry.Sw,this.Yg=this.Fs.ht,this.Gg=new Rect().g(),this.ec=null,this.au=null,this.cu=NaN,this.zn=Spot.TopLeft,this.Xn=Spot.BottomRight,this.sc=NaN,this.nc=NaN,this.Kn=2}copy(){const t=new Geometry;if(t.n=this.n&-2,t.$=this.$,t.xe=this.xe,t.be=this.be,t.Qi=this.Qi,t._i=this._i,this.$===4){const i=this.Fs.r,e=t.Fs;for(let s=0;si.toString(t)}ri(t){t in GeometryType?this.type=t:Util.lr(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e;switch(this.type){case 1:return t<0?"M"+this.startX.toString()+" "+this.startY.toString()+"L"+this.endX.toString()+" "+this.endY.toString():"M"+i(this.startX)+" "+i(this.startY)+"L"+i(this.endX)+" "+i(this.endY);case 2:return e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0?"M"+e.x.toString()+" "+e.y.toString()+"H"+e.right.toString()+"V"+e.bottom.toString()+"H"+e.left.toString()+"z":"M"+i(e.x)+" "+i(e.y)+"H"+i(e.right)+"V"+i(e.bottom)+"H"+i(e.left)+"z";case 3:if(e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0){const r=e.left.toString()+" "+(e.y+e.height/2).toString(),l=e.right.toString()+" "+(e.y+e.height/2).toString();return"M"+r+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+l+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+r}else{const r=i(e.left)+" "+i(e.y+e.height/2),l=i(e.right)+" "+i(e.y+e.height/2);return"M"+r+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+l+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+r}case 4:let s="";const n=this.figures.r,o=n.length;for(let r=0;r0&&(s+=" x "),l.isFilled&&(s+="F "),s+=l.toString(t)}return s;default:return GeometryType[this.type]}}static fillPath(t){typeof t!="string"&&Util.we(t,"string",Geometry,"fillPath:str");const i=t.split(/[Xx]/),e=i.length;let s="";for(let n=0;n=k-1||o[r+1].match(N)!==null?!0:(u=!1,!1)}function m(){return r++,o[r]}function g(A){let D=parseFloat(m()),F=parseFloat(m());l===l.toLowerCase()&&(D=f.x+D,F=f.y+F),A.e(D,F)}function p(){return g(f),f}function y(){return g(c),c}function x(){const A=h.toLowerCase();return A==="c"||A==="s"||A==="q"||A==="t"?new Point(2*f.x-c.x,2*f.y-c.y):new Point(f.x,f.y)}const k=o.length,b=GeoStream.mC(null);let P=!1,S=!1,L=!1,C=!0,M=null;const N=new RegExp("["+Geometry.jg+"]");for(;!(r>=k-1);){if(h=l,l=m(),l==="")continue;u=!0;let A=!1;switch(l.toUpperCase()){case"X":C=!0,P=!1,S=!1;break;case"M":for(M=p(),b.Pi===null||C===!0?(b.fu(M.x,M.y,P,!1,!S,L),C=!1):b.ID(M.x,M.y),a.a(f);!d();)M=p(),b.ur(M.x,M.y);break;case"L":for(;!d();)M=p(),b.ur(M.x,M.y);u&&(A=!0);break;case"H":for(;!d();)f.e((l===l.toLowerCase()?f.x:0)+parseFloat(m()),f.y),b.ur(f.x,f.y);break;case"V":for(;!d();)f.e(f.x,(l===l.toLowerCase()?f.y:0)+parseFloat(m())),b.ur(f.x,f.y);u&&(A=!0);break;case"C":for(;!d();){const D=new Point;g(D);const F=y(),R=p();b.dr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(A=!0);break;case"S":for(;!d();){const D=x(),F=y(),R=p();b.dr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(A=!0);break;case"Q":for(;!d();){const D=y(),F=p();b.Mw(D.x,D.y,F.x,F.y)}u&&(A=!0);break;case"T":for(;!d();){const D=x();c.a(D);const F=p();b.Mw(D.x,D.y,F.x,F.y),c.a(F)}u&&(A=!0);break;case"B":for(;!d();){const D=parseFloat(m()),F=parseFloat(m());let R=parseFloat(m()),v=parseFloat(m());const O=parseFloat(m());let B=O,X=!1;d()||(B=parseFloat(m()),d()||(X=parseFloat(m())!==0)),l===l.toLowerCase()&&(R+=f.x,v+=f.y),b.ED(D,F,R,v,O,B,X)}u&&(A=!0);break;case"A":for(;!d();){const D=Math.abs(parseFloat(m())),F=Math.abs(parseFloat(m())),R=parseFloat(m());let v=!1,O=!1,B=0,X=0;const E=m();E.length===1?(v=!!parseFloat(E),O=!!parseFloat(m()),B=parseFloat(m()),X=parseFloat(m())):E.length===2?(v=!!parseFloat(E[0]),O=!!parseFloat(E[1]),B=parseFloat(m()),X=parseFloat(m())):(v=!!parseFloat(E[0]),O=!!parseFloat(E[1]),B=parseFloat(E.slice(2)),X=parseFloat(m())),l===l.toLowerCase()&&(B=f.x+B,X=f.y+X),f.e(B,X),b.BD(D,F,R,v,O,B,X)}u&&(A=!0);break;case"Z":b.UD(),f.a(a);break;case"F":{let D="",F=1;for(;o[r+F];){if(o[r+F]==="0"){L=!0,F++;continue}if(o[r+F].match(/[Uu]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?P=!0:b.VD();break}case"U":{let D="",F=1;for(;o[r+F];){if(o[r+F].match(/[Ff]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?S=!0:b.zD(!1);break}default:if(l==="0"||l==="1")break;Util.ii("Unknown geometry command: "+l);break}if(A){Util.ii(`Bad geometry command: ${l}, next token: ${m()}, +string: ${t}`);break}}const T=b.Hg;if(GeoStream.pC(b),i){const A=T.figures.iterator;for(;A.next();){const D=A.value;D.isFilled=!0}}return T}static yC(t,i){const e=t.length,s=Point.l();for(let n=0;n=t)return 0;if((n>r?n-r:r-n)<(o>l?o-l:l-o)){if(ol)return 0}else if(co)return 0}else if(nr)return 0}else if(an)return 0;return h>0?1:-1}xC(t,i,e){const s=this.figures.r,n=s.length;for(let o=0;o1&&(t=1),i===void 0&&(i=new Point),this.type===1)return i.e(this.startX+t*(this.endX-this.startX),this.startY+t*(this.endY-this.startY)),i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[f*2],y=g[f*2+1],x=g[f*2+2],k=g[f*2+3];return i.e(p+(x-p)*m,y+(k-y)*m),i}l+=u}}return i}getAngleAlongPath(t){if(t<0?t=0:t>1&&(t=1),this.type===1)return Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI;const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=i.length,o=s*t;let r=0;for(let l=0;l=o){const u=i[l],d=u[c*2],m=u[c*2+1],g=u[c*2+2],p=u[c*2+3];return Math.abs(g-d)<1&&Math.abs(p-m)<1?0:Math.abs(g-d)<1?p-m>=0?90:270:Math.abs(p-m)<1?g-d>=0?0:180:Math.atan2(p-m,g-d)*180/Math.PI}r+=f}}return NaN}getPointAndAngleAlongPath(t,i){if(t<0?t=0:t>1&&(t=1),i===void 0&&(i=[]),i.length=3,this.type===1)return i[0]=this.startX+t*(this.endX-this.startX),i[1]=this.startY+t*(this.endY-this.startY),i[2]=Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI,i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[f*2],y=g[f*2+1],x=g[f*2+2],k=g[f*2+3];i[0]=p+(x-p)*m,i[1]=y+(k-y)*m;let b;return Math.abs(x-p)<1&&Math.abs(k-y)<1?b=0:Math.abs(x-p)<1?b=k-y>=0?90:270:Math.abs(k-y)<1?b=x-p>=0?0:180:b=Math.atan2(k-y,x-p)*180/Math.PI,i[2]=b,i}l+=u}}return i}getFractionForPoint(t){if(this.type===1){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=t.x,r=t.y;let l=0,h=0;if(i===s)return e=h?h===e?0:1:Math.abs(r-e)/(h-l);if(e===n)return i=h?h===i?0:1:Math.abs(o-i)/(h-l);{const a=(s-i)*(s-i)+(n-e)*(n-e),c=Point.l();Geo.ml(i,e,s,n,o,r,c);const f=c.x,u=c.y;return Point.s(c),Math.sqrt(((f-i)*(f-i)+(u-e)*(u-e))/a)}}}else if(this.type===2){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=s-i,r=n-e,l=o*2+r*2;let h=t.x,a=t.y;h=Math.min(Math.max(h,i),s),a=Math.min(Math.max(a,e),n);const c=Math.abs(h-i),f=Math.abs(h-s),u=Math.abs(a-e),d=Math.abs(a-n),m=Math.min(c,f,u,d);if(m===u)return h/l;if(m===f)return(o+a)/l;if(m===d)return(o*2+r-h)/l;if(m===c)return(o*2+r*2-a)/l}}else{const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=Point.l();let o=1/0,r=0,l=0;const h=i.length;let a=0,c=0;for(let u=0;u1?1:f}return 0}get flattenedSegments(){return this.bC(),this.ec}bC(){if(this.ec===null){const t=this.ec=[],i=this.au=[];this.YD(t,i)}}get flattenedLengths(){return this.bC(),this.au}get flattenedTotalLength(){let t=this.cu;if(isNaN(t)){if(this.type===1){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=Math.sqrt(i*i+e*e)}else if(this.type===2){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=i*2+e*2}else{const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=4&&(t.push(e),i.push(this.Xk(e))),e=[],e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY,h=r,a=l;break;case 2:e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY;break;case 3:Geo.Un(r,l,d.point1X,d.point1Y,d.point2X,d.point2Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 4:Geo.Bg(r,l,d.point1X,d.point1Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 5:{const m=d.Mo(o),g=m.length;if(g===0){e.push(d.centerX),e.push(d.centerY),r=d.centerX,l=d.centerY;break}for(let p=0;p=4&&(t.push(e),i.push(this.Xk(e)))}}}get type(){return this.$}set type(t){this.$!==t&&(this.h&&Util.T(this,t),this.$=t,t===4?this.Fs=new List:(Geometry.Sw===null&&(Geometry.Sw=new List().g()),this.Fs=Geometry.Sw),this.bt=!0)}get startX(){return this.xe}set startX(t){this.xe!==t&&(this.h&&Util.T(this,t),this.xe=t,this.bt=!0)}get startY(){return this.be}set startY(t){this.be!==t&&(this.h&&Util.T(this,t),this.be=t,this.bt=!0)}get endX(){return this.Qi}set endX(t){this.Qi!==t&&(this.h&&Util.T(this,t),this.Qi=t,this.bt=!0)}get endY(){return this._i}set endY(t){this._i!==t&&(this.h&&Util.T(this,t),this._i=t,this.bt=!0)}get figures(){return this.Fs}set figures(t){this.Fs!==t&&(this.h&&Util.T(this,t),this.Fs=t,this.bt=!0)}add(t){return this.Fs.add(t),this}setSpots(t,i,e,s,n,o,r,l){return this.h&&Util.T(this),this.zn=new Spot(t,i,n,o).g(),this.Xn=new Spot(e,s,r,l).g(),this}get spot1(){return this.zn}set spot1(t){this.h&&Util.T(this,t),this.zn=t.N()}get spot2(){return this.Xn}set spot2(t){this.h&&Util.T(this,t),this.Xn=t.N()}get defaultStretch(){return this.Kn}set defaultStretch(t){this.Kn=t}get bounds(){return this.Uk()&&this.Nw(),this.Gg}}Geometry.stringify=Geometry.stringify;Geometry.stringifyFixed=Geometry.stringifyFixed;Geometry.fillPath=Geometry.fillPath;Geometry.parse=Geometry.parse;class PathFigure{n;xe;be;oc;qg;Be;constructor(t,i,e,s,n){e===void 0&&(e=!0),s===void 0&&(s=!0),n===void 0&&(n=!1),this.n=2|(e?4:0)|(s?8:0)|(n?16:0),t!==void 0?this.xe=t:this.xe=0,i!==void 0?this.be=i:this.be=0,this.oc=new List,this.qg=this.oc.ht,this.Be=null}copy(){const t=new PathFigure;t.n=this.n&-2,t.xe=this.xe,t.be=this.be;const i=this.oc.r,e=i.length,s=t.oc;for(let n=0;no===0?"0":o.toFixed(t);i="M"+n(this.startX)+" "+n(this.startY)}const e=this.segments.r,s=e.length;for(let n=0;n(w[w.Move=1]="Move",w[w.Line=2]="Line",w[w.Bezier=3]="Bezier",w[w.QuadraticBezier=4]="QuadraticBezier",w[w.Arc=5]="Arc",w[w.SvgArc=6]="SvgArc",w))(SegmentType||{});class PathSegment{$;n;Qi;_i;hn;yl;wl;gr;Rs;constructor(t,i,e,s,n,o,r,l){if(GSet.Yi(this),t===void 0&&(t=2),this.$=t,this.n=2,i!==void 0?this.Qi=i:this.Qi=0,e!==void 0?this._i=e:this._i=0,s===void 0&&(s=0),n===void 0&&(n=0),o===void 0&&(o=0),r===void 0&&(r=0),t===6){let h=o;h=h%360,h<0&&(h+=360),this.hn=h,this.yl=0,this.wl=Math.max(s,0),this.gr=Math.max(n,0),typeof r=="boolean"?r&&(this.isLargeArc=!0):typeof r=="number"&&r&&(this.isLargeArc=!0),l&&(this.isClockwiseArc=!0)}else this.hn=s,this.yl=n,t===5&&(o=Math.max(o,0)),this.wl=o,typeof r=="number"?(t===5&&(r=Math.max(r,0)),this.gr=r):this.gr=0;this.Rs=null}copy(){const t=new PathSegment;return t.$=this.$,t.n=this.n&-2,t.Qi=this.Qi,t._i=this._i,t.hn=this.hn,t.yl=this.yl,t.wl=this.wl,t.gr=this.gr,t}equalsApprox(t){if(!(t instanceof PathSegment)||this.type!==t.type||this.isClosed!==t.isClosed)return!1;switch(this.type){case 1:case 2:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY);case 3:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.point1X,t.point1X)&&Geo.u(this.point1Y,t.point1Y)&&Geo.u(this.point2X,t.point2X)&&Geo.u(this.point2Y,t.point2Y);case 4:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.point1X,t.point1X)&&Geo.u(this.point1Y,t.point1Y);case 5:return Geo.u(this.startAngle,t.startAngle)&&Geo.u(this.sweepAngle,t.sweepAngle)&&Geo.u(this.centerX,t.centerX)&&Geo.u(this.centerY,t.centerY)&&Geo.u(this.radiusX,t.radiusX)&&Geo.u(this.radiusY,t.radiusY);case 6:return this.isClockwiseArc===t.isClockwiseArc&&this.isLargeArc===t.isLargeArc&&Geo.u(this.xAxisRotation,t.xAxisRotation)&&Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.radiusX,t.radiusX)&&Geo.u(this.radiusY,t.radiusY);default:return!1}}ri(t){t in SegmentType?this.type=t:Util.lr(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e="";switch(this.type){case 1:t<0?e="M"+this.endX.toString()+" "+this.endY.toString():e="M"+i(this.endX)+" "+i(this.endY);break;case 2:t<0?e="L"+this.endX.toString()+" "+this.endY.toString():e="L"+i(this.endX)+" "+i(this.endY);break;case 3:t<0?e="C"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.point2X.toString()+" "+this.point2Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="C"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.point2X)+" "+i(this.point2Y)+" "+i(this.endX)+" "+i(this.endY);break;case 4:t<0?e="Q"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="Q"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.endX)+" "+i(this.endY);break;case 5:t<0?e="B"+this.startAngle.toString()+" "+this.sweepAngle.toString()+" "+this.centerX.toString()+" "+this.centerY.toString()+" "+this.radiusX.toString()+" "+this.radiusY.toString():e="B"+i(this.startAngle)+" "+i(this.sweepAngle)+" "+i(this.centerX)+" "+i(this.centerY)+" "+i(this.radiusX)+" "+i(this.radiusY);break;case 6:t<0?e="A"+this.radiusX.toString()+" "+this.radiusY.toString()+" "+this.xAxisRotation.toString()+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+this.endX.toString()+" "+this.endY.toString():e="A"+i(this.radiusX)+" "+i(this.radiusY)+" "+i(this.xAxisRotation)+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+i(this.endX)+" "+i(this.endY);break;default:e=SegmentType[this.type]}return e+(this.isClosed?"z":"")}static Move=1;static Line=2;static Bezier=3;static QuadraticBezier=4;static Arc=5;static SvgArc=6;get h(){return(this.n&1)!==0}set h(t){t?this.n|=1:this.n&=-2}get bt(){return(this.n&2)!==0}set bt(t){t?this.n|=2:this.n&=-3}g(){return this.h=!0,this}ot(){return this.h=!1,this}close(){return this.isClosed=!0,this}Mo(t){if(this.Rs!==null&&t.bt===!1)return this.Rs;const i=this.radiusX;let e=this.radiusY;if(e===void 0&&(e=i),i===0||e===0)return this.Rs=[],this.Rs;const s=this.hn,n=this.yl,o=Geo.uC(0,0,i1&&(o*=Math.sqrt(p),r*=Math.sqrt(p));let y=(h===a?-1:1)*Math.sqrt((o*o*r*r-o*o*g*g-r*r*m*m)/(o*o*g*g+r*r*m*m));isNaN(y)&&(y=0);let x=y*o*g/r,k=y*-r*m/o;isNaN(x)&&(x=0),isNaN(k)&&(k=0);const b=(s+c)/2+u*x-d*k,P=(n+f)/2+d*x+u*k,S=(V,U)=>Math.sqrt(V*V+U*U),L=(V,U,Y,G)=>(V*Y+U*G)/(S(V,U)*S(Y,G)),C=(V,U,Y,G)=>(V*G=1&&(F=0),!a&&F>0&&(F=F-2*Math.PI),a&&F<0&&(F=F+2*Math.PI);const v=o>r?o:r,O=o>r?1:o/r,B=o>r?r/o:1,X=Geo.uC(0,0,v,M,M+F,!0),E=Transform.l();return E.Ri(),E.Ds(b,P),E.cs(this.hn,0,0),E.et(O,B),Geometry.yC(X,E),Transform.s(E),this.Rs=X,this.Rs}get isClosed(){return(this.n&8)!==0}set isClosed(t){this.isClosed!==t&&(t?this.n|=8:this.n&=-9,this.bt=!0)}get type(){return this.$}set type(t){this.h&&Util.T(this,t),this.$=t,this.bt=!0}get endX(){return this.Qi}set endX(t){this.h&&Util.T(this,t),this.Qi=t,this.bt=!0}get endY(){return this._i}set endY(t){this.h&&Util.T(this,t),this._i=t,this.bt=!0}get point1X(){return this.hn}set point1X(t){this.h&&Util.T(this,t),this.hn=t,this.bt=!0}get point1Y(){return this.yl}set point1Y(t){this.h&&Util.T(this,t),this.yl=t,this.bt=!0}get point2X(){return this.wl}set point2X(t){this.h&&Util.T(this,t),this.wl=t,this.bt=!0}get point2Y(){return this.gr}set point2Y(t){this.h&&Util.T(this,t),this.gr=t,this.bt=!0}get centerX(){return this.hn}set centerX(t){this.h&&Util.T(this,t),this.hn=t,this.bt=!0}get centerY(){return this.yl}set centerY(t){this.h&&Util.T(this,t),this.yl=t,this.bt=!0}get radiusX(){return this.wl}set radiusX(t){t<0&&Util._(t,">= zero",PathSegment,"radiusX"),this.h&&Util.T(this,t),this.wl=t,this.bt=!0}get radiusY(){return this.gr}set radiusY(t){t<0&&Util._(t,">= zero",PathSegment,"radiusY"),this.h&&Util.T(this,t),this.gr=t,this.bt=!0}get startAngle(){return this.Qi}set startAngle(t){this.h&&Util.T(this,t),t=t%360,t<0&&(t+=360),this.Qi=t,this.bt=!0}get sweepAngle(){return this._i}set sweepAngle(t){this.h&&Util.T(this,t),t>360&&(t=360),t<-360&&(t=-360),this._i=t,this.bt=!0}get isClockwiseArc(){return(this.n&4)!==0}set isClockwiseArc(t){this.h&&Util.T(this,t),t?this.n|=4:this.n&=-5,this.bt=!0}get isLargeArc(){return(this.n&16)!==0}set isLargeArc(t){this.h&&Util.T(this,t),t?this.n|=16:this.n&=-17,this.bt=!0}get xAxisRotation(){return this.hn}set xAxisRotation(t){this.h&&Util.T(this,t),t=t%360,t<0&&(t+=360),this.hn=t,this.bt=!0}}class InputEvent{p;Lw;Aw;Wg;Jg;$g;Zg;Qg;_g;tm;im;em;sm;nm;No;om;rm;lm;ke;constructor(){this.p=null,this.Lw=new Point(0,0).g(),this.Aw=new Point(0,0).g(),this.Wg=0,this.Jg=0,this.$g=1,this.Zg="",this.Qg="",this._g=!1,this.tm=!1,this.im=0,this.em=0,this.sm=!1,this.nm=!1,this.No=!1,this.om=null,this.rm=0,this.lm=null,this.ke=null}copy(){const t=new InputEvent;return this.clone(t)}clone(t){return t.p=this.p,t.Lw.a(this.viewPoint),t.Aw.a(this.documentPoint),t.Wg=this.Wg,t.Jg=this.Jg,t.$g=this.$g,t.Zg=this.Zg,t.Qg=this.Qg,t._g=this._g,t.tm=this.tm,t.im=this.im,t.em=this.em,t.sm=this.sm,t.nm=this.nm,t.No=this.No,t.om=this.om,t.rm=this.rm,t.lm=this.lm,t.ke=this.ke,t}toString(){let t="^";return this.modifiers!==0&&(t+="M:"+this.modifiers),this.button!==0&&(t+="B:"+this.button),this.key!==""&&(t+="K:"+this.key),this.clickCount!==0&&(t+="C:"+this.clickCount),this.delta!==0&&(t+="D:"+this.delta),this.handled&&(t+="h"),this.bubbles&&(t+="b"),this.documentPoint!==null&&(t+="@"+this.documentPoint.toString()),t}get diagram(){return this.p}set diagram(t){this.p=t}get viewPoint(){return this.Lw}set viewPoint(t){this.Lw.a(t)}get documentPoint(){return this.Aw}set documentPoint(t){this.Aw.a(t)}getMultiTouchViewPoint(t,i){const e=this.diagram;return e===null||e.kC(this.event,t,i),i}getMultiTouchDocumentPoint(t,i){const e=this.diagram;return e===null||(e.kC(this.event,t,i),i.a(e.transformViewToDoc(i))),i}get modifiers(){return this.Wg}set modifiers(t){this.Wg=t}get button(){return this.Jg}set button(t){if(this.Jg=t,this.event===null)switch(t){case 0:this.buttons=1;return;case 1:this.buttons=4;return;case 2:this.buttons=2;return}}get buttons(){return this.$g}set buttons(t){this.$g=t}get key(){return this.Zg}set key(t){this.Zg=t}get code(){return this.Qg}set code(t){this.Qg=t}get down(){return this._g}set down(t){this._g=t}get up(){return this.tm}set up(t){this.tm=t}get clickCount(){return this.im}set clickCount(t){this.im=t}get delta(){return this.em}set delta(t){this.em=t}get isMultiTouch(){return this.sm}set isMultiTouch(t){this.sm=t}get handled(){return this.nm}set handled(t){this.nm=t}get bubbles(){return this.No}set bubbles(t){this.No=t}get event(){return this.om}set event(t){this.om=t}get isTouchEvent(){const t=this.event;return t===null?!1:t.pointerType==="touch"||t.pointerType==="pen"}get timestamp(){return this.rm}set timestamp(t){this.rm=t}get targetDiagram(){return this.lm}set targetDiagram(t){this.lm=t}get targetObject(){return this.ke}set targetObject(t){this.ke=t}get control(){return(this.modifiers&1)!==0}set control(t){this.modifiers=t?this.modifiers|1:this.modifiers&-2}get shift(){return(this.modifiers&4)!==0}set shift(t){this.modifiers=t?this.modifiers|4:this.modifiers&-5}get alt(){return(this.modifiers&2)!==0}set alt(t){this.modifiers=t?this.modifiers|2:this.modifiers&-3}get meta(){return(this.modifiers&8)!==0}set meta(t){this.modifiers=t?this.modifiers|8:this.modifiers&-9}get left(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===0:(this.buttons&1)!==0}set left(t){t?this.buttons|=1:this.buttons&=-2}get right(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===2:(this.buttons&2)!==0}set right(t){t?this.buttons|=2:this.buttons&=-3}get middle(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===1:(this.buttons&4)!==0}set middle(t){t?this.buttons|=4:this.buttons&=-5}get commandKey(){const t=this.code,i=this.key;return"cxvyzagCXVYZAG".includes(i)?i.toLowerCase():t==="KeyC"?"c":t==="KeyX"?"x":t==="KeyV"?"v":t==="KeyY"?"y":t==="KeyZ"?"z":t==="KeyA"?"a":t==="KeyG"?"g":t!==""?t:i}}class DiagramEvent{p;Mt;hm;am;constructor(){this.p=null,this.Mt="",this.hm=null,this.am=null}copy(){const t=new DiagramEvent;return t.p=this.p,t.Mt=this.Mt,t.hm=this.hm,t.am=this.am,t}toString(){let t="*"+this.name;return this.subject!==null&&(t+=":"+this.subject.toString()),this.parameter!==null&&(t+="("+this.parameter.toString()+")"),t}get diagram(){return this.p}set diagram(t){this.p=t}get name(){return this.Mt}set name(t){this.Mt=t}get subject(){return this.hm}set subject(t){this.hm=t}get parameter(){return this.am}set parameter(t){this.am=t}}var ChangeType=(w=>(w[w.Transaction=1]="Transaction",w[w.Property=2]="Property",w[w.Insert=3]="Insert",w[w.Remove=4]="Remove",w))(ChangeType||{});class ChangedEvent{uu;cm;an;Si;p;du;rc;lc;hc;ac;constructor(){this.uu=2,this.cm="",this.an="",this.Si=null,this.p=null,this.du=null,this.rc=null,this.lc=null,this.hc=null,this.ac=null}static Transaction=1;static Property=2;static Insert=3;static Remove=4;clear(){this.Si=null,this.p=null,this.du=null,this.rc=null,this.lc=null,this.hc=null,this.ac=null}copy(){const t=new ChangedEvent;t.uu=this.uu,t.cm=this.cm,t.an=this.an,t.Si=this.Si,t.p=this.p,t.du=this.du;let i=this.rc;return Util.wt(i)&&typeof i.copyFrozen=="function"?t.rc=i.copyFrozen():t.rc=i,i=this.lc,Util.wt(i)&&typeof i.copyFrozen=="function"?t.lc=i.copyFrozen():t.lc=i,i=this.hc,Util.wt(i)&&typeof i.copyFrozen=="function"?t.hc=i.copyFrozen():t.hc=i,i=this.ac,Util.wt(i)&&typeof i.copyFrozen=="function"?t.ac=i.copyFrozen():t.ac=i,t}ri(t){t in ChangeType?this.change=t:Util.lr(this,t)}toString(){let t="";return this.change===1?t+="* ":this.change===2?t+=this.model!==null?"!m":"!d":t+=(this.model!==null?"!m":"!d")+this.change,this.propertyName&&typeof this.propertyName=="string"&&(t+=" "+this.propertyName),this.modelChange&&this.modelChange!==this.propertyName&&(t+=" "+this.modelChange),t+=": ",this.change===1?this.oldValue!==null&&(t+=" "+this.oldValue):(this.object!==null&&(t+=Util.toString(this.object)),this.oldValue!==null&&(t+=" old: "+Util.toString(this.oldValue)),this.oldParam!==null&&(t+=" "+this.oldParam),this.newValue!==null&&(t+=" new: "+Util.toString(this.newValue)),this.newParam!==null&&(t+=" "+this.newParam)),t}getValue(t){return t?this.oldValue:this.newValue}getParam(t){return t?this.oldParam:this.newParam}canUndo(){return this.model!==null||this.diagram!==null}undo(){this.canUndo()&&(this.model!==null?this.model.changeState(this,!0):this.diagram!==null&&this.diagram.PC(this,!0))}canRedo(){return this.model!==null||this.diagram!==null}redo(){this.canRedo()&&(this.model!==null?this.model.changeState(this,!1):this.diagram!==null&&this.diagram.PC(this,!1))}get model(){return this.Si}set model(t){this.Si=t}get diagram(){return this.p}set diagram(t){this.p=t}get change(){return this.uu}set change(t){this.uu=t}get modelChange(){return this.cm}set modelChange(t){this.cm=t}get propertyName(){return this.an}set propertyName(t){this.an=t}get isTransactionFinished(){return this.uu===1&&(this.an==="CommittedTransaction"||this.an==="FinishedUndo"||this.an==="FinishedRedo")}get object(){return this.du}set object(t){this.du=t}get oldValue(){return this.rc}set oldValue(t){this.rc=t}get oldParam(){return this.lc}set oldParam(t){this.lc=t}get newValue(){return this.hc}set newValue(t){this.hc=t}get newParam(){return this.ac}set newParam(t){this.ac=t}}class Transaction{SC;Mt;Kk;constructor(){this.SC=new List().g(),this.Mt="",this.Kk=!1}toString(t){let i="Transaction: "+this.name+" "+this.changes.count.toString()+(this.isComplete?"":", incomplete");if(t!==void 0&&t>0){const e=this.changes.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),t.g()}canUndo(){return this.isComplete}undo(){if(this.canUndo())for(let t=this.changes.count-1;t>=0;t--){const i=this.changes.elt(t);i!==null&&i.undo()}}canRedo(){return this.isComplete}redo(){if(!this.canRedo())return;const t=this.changes.count;for(let i=0;i=t;e--){const s=i.elt(e);s!==null&&s.undo(),i.ot(),i.removeAt(e)}i.g()}optimize(){if(!this.isComplete)return;const t=this.changes;t.ot();const i=new GMap;for(let s=0;s0&&t.setElt(r,null),o.set(n.propertyName,s))}let e=0;for(let s=0;se&&t.setElt(e,n),e++)}for(;t.length>e;)t.pop();t.g()}get changes(){return this.SC}get name(){return this.Mt}set name(t){this.Mt=t}get isComplete(){return this.Kk}set isComplete(t){this.Kk=t}}class UndoManager{Tw;Oi;MC;vs;Yk;fm;Yn;Gk;jk;cn;cc;Dw;Os;Fw;Rw;um;vw;constructor(t){this.Tw=new GSet,this.Oi=!1,this.MC=new List().g(),this.vs=-1,this.Yk=999,this.Os=!1,this.fm=null,this.Yn=0,this.Gk=!1,this.jk=23,this.cn=new List().g(),this.cc=new List,this.Dw=!0,this.Fw=!1,this.Rw=!1,this.um=!1,this.vw=!1,t&&Object.assign(this,t)}toString(t){let i="UndoManager "+this.historyIndex+"<"+this.history.count+"<="+this.maxHistoryLength;i+="[";let e=this.nestedTransactionNames.count;for(let s=0;s0&&(i+=" "),i+=this.nestedTransactionNames.elt(s);if(i+="]",t!==void 0&&t>0){e=this.history.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),this.vs=-1,t.g(),this.Os=!1,this.fm=null,this.Yn=0,this.cn.ot(),this.cn.clear(),this.cn.g(),this.cc.clear(),this.Fw=!1,this.Rw=!1,this.um=!1,this.vw=!1}copyProperties(t){this.isEnabled=t.isEnabled,this.maxHistoryLength=t.maxHistoryLength,this.dm=t.dm}addModel(t){this.Tw.add(t)}removeModel(t){this.Tw.delete(t)}startTransaction(t){if(t===void 0&&(t=""),t===null&&(t=""),this.isUndoingRedoing)return!1;this.Dw===!0&&(this.Dw=!1,this.Yn++,this.xl||this.t("StartingFirstTransaction",t,this.currentTransaction),this.Yn>0&&this.Yn--),this.isEnabled&&(this.cn.ot(),this.cn.add(t),this.cn.g(),this.currentTransaction===null?this.cc.add(0):this.cc.add(this.currentTransaction.changes.count)),this.Yn++;const i=this.transactionLevel===1;return i&&(this.xl||this.t("StartedTransaction",t,this.currentTransaction)),i}commitTransaction(t){return t===void 0&&(t=""),this.NC(!0,t)}rollbackTransaction(){return this.NC(!1,"")}NC(t,i){if(this.isUndoingRedoing)return!1;this.dm&&this.transactionLevel<1&&Util.ii("Ending transaction without having started a transaction: "+i);const e=this.transactionLevel===1;let s=this.currentTransaction;e&&t&&(this.xl||this.t("CommittingTransaction",i,s));let n=0;if(this.transactionLevel>0&&(this.Yn--,this.isEnabled)){const o=this.cn.count;o>0&&(i===""&&(i=this.cn.elt(0)),this.cn.ot(),this.cn.removeAt(o-1),this.cn.g());const r=this.cc.count;r>0&&(n=this.cc.elt(r-1),this.cc.removeAt(r-1))}if(e){if(t){if(this.um=!1,s===null&&i!==""&&(s=this.currentTransaction),this.isEnabled&&s!==null){const o=s;o.isComplete||(o.isComplete=!0,o.name=i),this.discardHistoryAfterIndex();const r=this.history;r.ot();const l=this.maxHistoryLength;if(l>=0){if(l===0)r.clear();else if(r.count>=l){const h=r.elt(0);h!==null&&h.clear(),r.removeAt(0),this.vs--}}l!==0&&(r.count===0||r.get(r.count-1)!==o)&&(r.add(o),this.vs++),r.g(),s=o}this.xl||this.t("CommittedTransaction",i,s)}else{this.Os=!0;try{this.isEnabled&&s!==null&&(s.isComplete=!0,s.undo())}finally{this.xl||this.t("RolledBackTransaction",i,s),this.Os=!1}s!==null&&s.clear()}return this.fm=null,this.Ow&&this.clear(),this.Ow=!1,this.Iw=!1,!0}else return this.isEnabled&&!t&&s!==null&&s.GD(n),!1}discardHistoryAfterIndex(){if(this.isUndoingRedoing||!this.canRedo())return;const t=this.history;t.ot();for(let i=t.count-1;i>this.historyIndex;i--){const e=t.elt(i);e!==null&&e.clear(),t.removeAt(i),this.um=!0}t.g()}nE(t){this.Yn+=t,this.Yn<0&&(this.Yn=0)}canUndo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToUndo;return!!(t!==null&&t.canUndo())}undo(){if(!this.canUndo())return;const t=this.transactionToUndo;try{this.Os=!0,this.t("StartingUndo","Undo",t),this.vs--,t.undo()}catch(i){Util.ii("undo error: "+i.toString())}finally{this.t("FinishedUndo","Undo",t),this.Os=!1}}canRedo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToRedo;return!!(t!==null&&t.canRedo())}redo(){if(!this.canRedo())return;const t=this.transactionToRedo;try{this.Os=!0,this.t("StartingRedo","Redo",t),this.vs++,t.redo()}catch(i){Util.ii("redo error: "+i.toString())}finally{this.t("FinishedRedo","Redo",t),this.Os=!1}}t(t,i,e){e===void 0&&(e=null);const s=new ChangedEvent;s.change=1,s.propertyName=t,s.object=e,s.oldValue=i;const n=this.models;for(;n.next();){const o=n.value;s.model=o,o.Ew(s)}}handleChanged(t){if(this.isEnabled&&!this.isUndoingRedoing&&!this.skipsEvent(t)){let i=this.currentTransaction;i===null&&(i=new Transaction,this.fm=i);const e=t.copy(),s=i.changes;if(s.ot(),s.add(e),s.g(),this.dm&&this.jk>0&&this.transactionLevel<=0&&!this.Dw){const n=t.diagram;if(n!==null&&n.Bh===!1)return;Util.ii("Change not within a transaction: "+e.toString()),this.jk--}}}skipsEvent(t){if(t===null||t.change===1)return!0;const i=t.object;if(i===null)return!1;if(i.layer!==void 0){const e=i.layer;if(e!==null&&e.isTemporary)return!0}else if(i.isTemporary)return!0;return!1}get models(){return this.Tw.iterator}get isEnabled(){return this.Oi}set isEnabled(t){this.Oi=t}get transactionToUndo(){return this.historyIndex>=0&&this.historyIndex<=this.history.count-1?this.history.elt(this.historyIndex):null}get transactionToRedo(){return this.historyIndex0}get dm(){return this.Gk}set dm(t){this.Gk=t}get nestedTransactionNames(){return this.cn}get Ow(){return this.Fw}set Ow(t){this.Fw=t}get Iw(){return this.Rw}set Iw(t){this.Rw=t}get xl(){return this.vw}set xl(t){this.vw=t}get isJustDiscarded(){return this.um}}class Tool{p;Mt;Oi;Hk;qk;gm;CC;constructor(){GSet.Yi(this),this.p=Diagram.mm(),this.Mt="",this.Oi=!0,this.Hk=!1,this.qk=null,this.CC=new InputEvent,this.gm=-1}get diagram(){return this.p}set diagram(t){t instanceof Diagram&&(this.p=t)}toString(){return this.name!==""?this.name+" Tool":Util.sn(this.constructor)}updateAdornments(t){}canStart(){return this.isEnabled}doStart(){}doActivate(){this.isActive=!0}doDeactivate(){this.isActive=!1}doStop(){}doCancel(){this.transactionResult=null,this.stopTool()}stopTool(){const t=this.diagram;t.currentTool===this&&(t.currentTool=null,t.currentCursor="")}doMouseDown(){!this.isActive&&this.canStart()&&this.doActivate()}doMouseMove(){}doMouseUp(){this.stopTool()}doMouseWheel(){}canStartMultiTouch(){return!0}standardPinchZoomStart(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.X(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.X(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.s(e),Point.s(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){t.Wk=t.scale;const n=s.x-e.x,o=s.y-e.y,r=Math.sqrt(n*n+o*o);t.Jk=r,i.bubbles=!1}Point.s(e),Point.s(s)}standardPinchZoomMove(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.X(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.X(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.s(e),Point.s(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){const n=s.x-e.x,o=s.y-e.y,l=Math.sqrt(n*n+o*o)/t.Jk,h=new Point((Math.min(s.x,e.x)+Math.max(s.x,e.x))/2,(Math.min(s.y,e.y)+Math.max(s.y,e.y))/2),a=t.Wk*l,c=t.commandHandler;if(a!==t.scale&&c.canResetZoom(a)){const f=t.zoomPoint;t.zoomPoint=h,c.resetZoom(a),t.zoomPoint=f}i.bubbles=!1}Point.s(e),Point.s(s)}doKeyDown(){this.diagram.lastInput.code==="Escape"&&this.doCancel()}doKeyUp(){}startTransaction(t){return t===void 0&&(t=this.name),this.transactionResult=null,this.diagram.startTransaction(t)}stopTransaction(){const t=this.diagram;return this.transactionResult===null?t.rollbackTransaction():t.commitTransaction(this.transactionResult)}standardMouseSelect(){const t=this.diagram;if(!t.allowSelect)return;const i=t.lastInput,e=t.findPartAt(i.documentPoint,!1);if(e!==null){if(Util.rr?i.meta:i.control){t.v("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!s.isSelected),t.v("ChangedSelection",t.selection)}else if(i.shift){if(!e.isSelected){t.v("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!0),t.v("ChangedSelection",t.selection)}}else if(!e.isSelected){let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&t.select(s)}}else i.left&&!(Util.rr?i.meta:i.control)&&!i.shift&&t.clearSelection()}standardMouseClick(t,i){t===void 0&&(t=null),i===void 0&&(i=o=>!o.layer.isTemporary);const e=this.diagram,s=e.lastInput,n=e.findObjectAt(s.documentPoint,t,i);return s.targetObject=n,this.jD(n,s,e),s.handled}jD(t,i,e){if(i.handled=!1,t!==null&&!t.isEnabledObject())return;let s=0;i.left?i.clickCount===1?s=1:i.clickCount===2?s=2:s=1:i.right&&i.clickCount===1&&(s=3);let n="ObjectSingleClicked";if(t!==null){switch(s){case 1:n="ObjectSingleClicked";break;case 2:n="ObjectDoubleClicked";break;case 3:n="ObjectContextClicked";break}s!==0&&e.v(n,t)}else{switch(s){case 1:n="BackgroundSingleClicked";break;case 2:n="BackgroundDoubleClicked";break;case 3:n="BackgroundContextClicked";break}s!==0&&e.v(n)}if(t!==null)for(;t!==null;){let o=null;switch(s){case 1:o=t.click;break;case 2:o=t.doubleClick?t.doubleClick:t.click;break;case 3:o=t.contextClick;break}if(o!==null&&(o(i,t),i.handled))break;t=t.panel}else{let o=null;switch(s){case 1:o=e.click;break;case 2:o=e.doubleClick?e.doubleClick:e.click;break;case 3:o=e.contextClick;break}o!==null&&o(i)}}standardMouseOver(){const t=this.diagram,i=t.lastInput;if(t.animationManager.wi===!0)return;const e=t.skipsUndoManager;t.skipsUndoManager=!0;let s=t.viewportBounds.containsPoint(i.documentPoint)?t.findObjectAt(i.documentPoint,null,null):null;i.event&&(i.event.type==="pointercancel"||i.event.type==="pointerout")&&(s=null),i.targetObject=s;let n=!1;if(s!==t.fc){let o=t.fc;const r=o;for(t.fc=s,this.doCurrentObjectChanged(o,s),i.handled=!1;o!==null;){const l=o.mouseLeave;if(l!==null&&(s===o||s!==null&&s.isContainedBy(o)||(l(i,o,s),n=!0,i.handled)))break;o=o.panel}for(o=r,i.handled=!1;s!==null;){const l=s.mouseEnter;if(l!==null&&(o===s||o!==null&&o.isContainedBy(s)||(l(i,s,o),n=!0,i.handled)))break;s=s.panel}s=t.fc}if(s!==null){let o=s,r="";for(;o!==null&&(r=o.cursor,r==="");)o=o.panel;for(t.currentCursor=r,i.handled=!1,o=s;o!==null;){const l=o.mouseOver;if(l!==null&&(l(i,o),n=!0,i.handled))break;o=o.panel}}else{this.doUpdateCursor(null);const o=t.mouseOver;o!==null&&(o(i),n=!0)}n&&t.requestUpdate(),t.skipsUndoManager=e}doUpdateCursor(t){const i=this.diagram;i&&(i.currentCursor="")}doCurrentObjectChanged(t,i){}standardMouseWheel(){const t=this.diagram,i=t.lastInput;let e=i.delta;if(e===0||!t.documentBounds.isReal())return;const s=t.commandHandler,n=t.toolManager.mouseWheelBehavior;if(s!==null&&(n===2&&!i.shift||n===1&&i.control)){if(e>0?s.canIncreaseZoom():s.canDecreaseZoom()){const o=t.zoomPoint;t.zoomPoint=i.viewPoint,e>0?s.increaseZoom():s.decreaseZoom(),t.zoomPoint=o}i.bubbles=!1}else if(n===2&&i.shift||n===1&&!i.control){const o=t.position.copy(),r=i.event,l=r.deltaMode;let h=r.deltaX,a=r.deltaY,c="pixel";if((h!==0||a!==0)&&!i.shift){switch(l){case 0:c="pixel";break;case 1:c="line";break;case 2:c="page";break}if(h!==0&&t.allowHorizontalScroll){const f=t.scrollHorizontalLineChange;h=h*(f/16),t.scroll(c,h>0?"right":"left",Math.abs(h))}if(a!==0&&t.allowVerticalScroll){const f=t.scrollVerticalLineChange;a=a*(f/16),t.scroll(c,a>0?"down":"up",Math.abs(a))}}else!i.shift&&t.allowVerticalScroll?(e=e*3*t.scrollVerticalLineChange,t.scroll(c,e>0?"up":"down",Math.abs(e))):i.shift&&t.allowHorizontalScroll&&(e=e*3*t.scrollHorizontalLineChange,t.scroll(c,e>0?"left":"right",Math.abs(e)));this.doWheelChange(t,o,i)}}doWheelChange(t,i,e){(!t.position.equals(i)||e.event.wheelDeltaX!==0)&&(e.bubbles=!1)}standardWaitAfter(t,i){i===void 0&&(i=this.diagram.lastInput),this.cancelWaitAfter();const e=this,s=i.clone(this.CC);this.gm=Util.Oh(()=>e.doWaitAfter(s),t)}cancelWaitAfter(){this.gm!==-1&&Util.Og(this.gm),this.gm=-1}doWaitAfter(t){}findToolHandleAt(t,i){const s=this.diagram.findObjectAt(t,n=>{for(;n!==null&&!(n.panel instanceof Adornment);)n=n.panel;return n});return s===null?null:s.part.category===i?s:null}isBeyondDragSize(t,i){const e=this.diagram;t===void 0&&(t=e.firstInput.viewPoint),i===void 0&&(i=e.lastInput.viewPoint);const s=e.toolManager.dragSize;let n=s.width,o=s.height;return e.firstInput.isTouchEvent&&(n+=6,o+=6),Math.abs(i.x-t.x)>n||Math.abs(i.y-t.y)>o}get name(){return this.Mt}set name(t){Util.i(t,"string",Tool,"name"),this.Mt=t}get isEnabled(){return this.Oi}set isEnabled(t){Util.i(t,"boolean",Tool,"isEnabled"),this.Oi=t}get isActive(){return this.Hk}set isActive(t){Util.i(t,"boolean",Tool,"isActive"),this.Hk=t}get transactionResult(){return this.qk}set transactionResult(t){t!==null&&Util.i(t,"string",Tool,"transactionResult"),this.qk=t}}var WheelMode=(w=>(w[w.Scroll=1]="Scroll",w[w.Zoom=2]="Zoom",w[w.None=3]="None",w))(WheelMode||{}),GestureMode=(w=>(w[w.Zoom=1]="Zoom",w[w.Cancel=2]="Cancel",w[w.None=3]="None",w))(GestureMode||{});class ToolManager extends Tool{LC;AC;TC;$k;Zk;Qk;_k;tP;iP;eP;pm;Uh;constructor(t){super(),this.name="ToolManager",this.LC=new List,this.AC=new List,this.TC=new List,this.$k=850,this.Zk=850,this.Qk=new Size(2,2).it(),this._k=5e3,this.tP=1,this.iP=1,this.eP=null,this.pm=null,this.Uh=-1,t&&Object.assign(this,t)}static WheelScroll=1;static WheelZoom=2;static WheelNone=3;static GestureZoom=1;static GestureCancel=2;static GestureNone=3;get mouseWheelBehavior(){return this.tP}set mouseWheelBehavior(t){this.tP=t}get gestureBehavior(){return this.iP}set gestureBehavior(t){this.iP=t}initializeStandardTools(){}updateAdornments(t){const i=this.currentToolTip;if(i instanceof Adornment&&this.pm===t){const e=i.adornedObject;(t!==null?e.part===t:e===null)?this.showToolTip(i,e):this.hideToolTip()}}doMouseDown(){const t=this.diagram,i=t.lastInput;if(i.isTouchEvent&&this.gestureBehavior===2&&(i.bubbles=!1),i.isMultiTouch){if(this.cancelWaitAfter(),this.gestureBehavior===3){i.bubbles=!0;return}if(this.gestureBehavior===2)return;if(t.currentTool.canStartMultiTouch()){t.currentTool.standardPinchZoomStart();return}}const e=t.undoManager,s=this.mouseDownTools.length;for(let n=0;n0&&s!==1/0){const n=this;this.Uh=Util.Oh(()=>n.hideToolTip(),s)}}positionToolTip(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom?n.y-=o.height+5/s.scale:n.y+=20/s.scale,n.y30&&t.Uw(),t.Vw(this.draggedParts),t.pu=!0,this.startTransaction("Drag"),this.startPoint=t.firstInput.documentPoint,t.isMouseCaptured=!0,t.allowDragOut&&this.qD()}mP(t){if(this.dragsLink){const i=this.diagram;if(!i.allowRelink)return;i.model.gc()&&t.count===1&&t.first()instanceof Link?(this.draggedLink=t.first(),this.draggedLink.canRelinkFrom()&&this.draggedLink.canRelinkTo()&&this.draggedLink.clearAdornments(),this.fn=i.toolManager.findTool("Relinking"),this.fn===null&&(this.fn=new RelinkingTool,this.fn.diagram=i),this.fn.originalLink=this.draggedLink):(this.draggedLink=null,this.fn=null)}}computeEffectiveCollection(t,i){return this.diagram.commandHandler.computeEffectiveCollection(t,i)}Is(t){return t===void 0?new DraggingInfo(Point.Po):this.isGridSnapEnabled?new DraggingInfo(new Point(Math.round(t.x*1e3)/1e3,Math.round(t.y*1e3)/1e3)):new DraggingInfo(t.copy())}doDeactivate(){this.isActive=!1;const t=this.diagram;this.diagram.layout.isRealtime=this.gP,t.pu=!1,t.bl=!0,t.cacheGroupExternalLinks(!1),t.stopAutoScroll(),this.pP(),t.wm(this.draggedParts),this.mu=null,this.currentPart=null,this.draggedParts=null,this.isDragOutStarted=!1,this.gu=!1,DraggingTool.WD(),this.FC(),this.uc.e(NaN,NaN),DraggingTool.zh!==null&&(DraggingTool.zh.currentCursor=""),DraggingTool.zh=null,DraggingTool.yt=null,this.kl(),t.isMouseCaptured=!1,t.currentCursor="",t.dc=!1,this.stopTransaction(),t.yP(!0)}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}pP(){const t=this.diagram,i=t.skipsUndoManager;t.skipsUndoManager=!0;const e=t.lastInput;this.RC(e,null),t.skipsUndoManager=i,this.mr.length=0}vC(){this.kl(),this.wP();const t=this.diagram;this.uc.isReal()&&(t.position=this.uc),t.stopAutoScroll()}doCancel(){this.kl(),this.wP();const t=this.diagram;this.uc.isReal()&&(t.position=this.uc),this.stopTool()}doKeyDown(){const t=this.diagram,i=t.lastInput;this.isActive&&(i.code==="Escape"?this.doCancel():i.code!==t.previousInput.code&&this.doMouseMove())}doKeyUp(){this.isActive&&this.doMouseMove()}JD(t,i){let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=t.iterator;for(;r.next();){const l=r.value;if(!l.isVisible())continue;const h=l.location,a=h.x,c=h.y;isNaN(a)||isNaN(c)||(an&&(n=a),c>o&&(o=c))}return e===1/0?i.e(0,0,0,0):i.e(e,s,n-e,o-s),i}xP(t){if(this.copiedParts!==null)return;const i=this.diagram;if(t&&(i.isReadOnly||i.isModelReadOnly)||this.draggedParts===null)return;const e=i.undoManager;e.isEnabled&&e.isInTransaction?e.currentTransaction!==null&&e.currentTransaction.changes.count>0&&(i.undoManager.rollbackTransaction(),i.startTransaction("Drag")):this.wP(),i.skipsUndoManager=!t,i.partManager.addsToTemporaryLayer=!t,this.startPoint=i.firstInput.documentPoint;const s=this.copiesEffectiveCollection?this.draggedParts.toKeySet():i.selection,n=i.copyParts(s,i,!0),o=new GMap,r=this.draggedParts.iterator;for(;r.next();){const h=r.key;if(h.Pe()&&h.canCopy()){const a=n.get(h);if(a===null)continue;a.location=h.location,a.ensureBounds(),o.set(a,this.Is(a.location))}}const l=n.iterator;for(;l.next();){const h=l.value;h instanceof Link&&h.canCopy()&&o.set(h,this.Is())}if(this.copiedParts=o,this.mP(o.toKeySet()),this.draggedLink!==null){const h=this.draggedLink,a=h.routeBounds;h.pr(this.startPoint.x-(a.x+a.width/2),this.startPoint.y-(a.y+a.height/2))}this.doUpdateCursor(null)}kl(){const t=this.diagram;if(this.copiedParts!==null){if(t.removeParts(this.copiedParts.toKeySet(),!1),this.copiedParts=null,this.draggedParts!==null){const i=this.draggedParts.iterator;for(;i.next();)if(i.key instanceof Link){const s=i.value;s.point=new Point(0,0)}}this.doUpdateCursor(null)}t.skipsUndoManager=!1,t.partManager.addsToTemporaryLayer=!1,this.startPoint=t.firstInput.documentPoint}FC(){this.draggedLink!==null&&(this.dragsLink&&this.fn!==null&&(this.fn.stopDraggingMouseMove(),this.fn.originalLink=null),this.draggedLink=null,this.fn=null)}mc(t,i){const e=this.diagram,s=this.startPoint,n=Point.l();n.a(e.lastInput.documentPoint),this.moveParts(t,n.subtract(s),i),Point.s(n),e.getRenderingHint("temporaryPixelRatio")===!0&&e.Pl===null&&e.avgSpf>30&&(e.Uw(),e.yu())}moveParts(t,i,e){e===void 0&&(e=!1);const s=this.diagram;s!==null&&s.bP(t,i,this.dragOptions,e)}wP(){if(this.draggedParts===null)return;const t=this.diagram;let i=this.draggedParts.iterator;for(;i.next();){const e=i.key;e.Pe()&&(e.location=i.value.point)}for(i=this.draggedParts.iterator;i.next();){const e=i.key;if(e instanceof Link&&e.suspendsRouting){const s=i.value.point;this.draggedParts.set(e,this.Is()),e.pr(-s.x,-s.y)}}t.maybeUpdate()}$D(t){if(t===null)return!0;const i=t.part;return!!(i===null||i instanceof Adornment||i.layer.isTemporary||this.draggedParts&&this.draggedParts.has(i)||this.copiedParts&&this.copiedParts.has(i))}kP(t){const i=this.diagram;this.dragsLink&&(this.draggedLink!==null&&(this.draggedLink.fromNode=null,this.draggedLink.toNode=null),this.OC(!1));const e=this.findDragOverObject(t),s=i.lastInput;s.targetObject=e,this.doUpdateCursor(e);const n=i.skipsUndoManager;let o=!1;try{if(i.skipsUndoManager=!0,o=this.RC(s,e),!this.isActive&&DraggingTool.yt===null)return;const r=e!==null?e.part:null;if(r===null||i.handlesDragDropForTopLevelParts&&r.isTopLevel&&!(r instanceof Group)){const l=i.mouseDragOver;l!==null&&(l(s),o=!0)}if(!this.isActive&&DraggingTool.yt===null||(this.doDragOver(t,e),!this.isActive&&DraggingTool.yt===null))return}finally{i.skipsUndoManager=n,o&&i.maybeUpdate()}this.mu=e,!i.isReadOnly&&(i.allowMove||i.allowCopy)&&(i.allowHorizontalScroll||i.allowVerticalScroll)&&i.doAutoScroll(s.viewPoint)}findDragOverObject(t){return this.diagram.PP(t,null,i=>!this.$D(i))}doUpdateCursor(t){const i=this.diagram;(t===null||this.mu!==t)&&(!this.diagram.currentTool.isActive||this.mayCopy()?i.currentCursor=this.copyCursor:this.mayMove()?i.currentCursor=this.moveCursor:this.mayDragOut()&&(i.currentCursor=this.nodropCursor))}RC(t,i){let e=!1,s=this.mr.length;const n=s>0?this.mr[0]:null;if(i===n)return!1;t.handled=!1;for(let r=0;rs.findValidLinkablePort(a,i)),r=Point.l();let l=1/0,h=null;for(const a=o.iterator;a.next();){const c=a.value;if(c.part===null)continue;const u=c.getDocumentPoint(Spot.Center,r),d=t.distanceSquaredPoint(u);dh.suspendsRouting=!1)}if(this.doDropOnto(t,e),!this.isActive&&DraggingTool.yt===null)return;const o=Rect.l(),r=i.selection.iterator;for(;r.next();){const l=r.value;l instanceof Node&&this.QD(i,l,o)}Rect.s(o)}ZD(t,i){const e=this.diagram,s=i.part;if(e.handlesDragDropForTopLevelParts&&s.isTopLevel&&!(s instanceof Group)){const n=e.mouseDrop;n!==null&&n(t)}}QD(t,i,e){if(!i.canAvoid())return;let s=!1;e=i.getAvoidableRect(e),t.viewportBounds.containsRect(e)&&(s=!0);const n=this.copiedParts||this.draggedParts,o=t.NP(e,l=>l.part,l=>l instanceof Link,!0,l=>l instanceof Link,s);if(o.count===0)return;const r=o.iterator;for(;r.next();){const l=r.value;n.has(l)&&n.has(i)||!l.isMemberOf(i)&&l.isAvoiding&&l.invalidateRoute()}}doDropOnto(t,i){}doMouseMove(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseMove(i.event,i.documentPoint,i.targetDiagram))return;this.currentPart!==null&&this.draggedParts!==null&&(this.mayCopy()?(this.xP(!1),t.Vw(this.copiedParts),this.mc(this.copiedParts,!1),t.wm(this.copiedParts)):this.mayMove()?(this.kl(),this.mc(this.draggedParts,!0)):this.mayDragOut()?(this.xP(!1),this.mc(this.copiedParts,!1)):this.kl(),this.kP(t.lastInput.documentPoint))}doMouseUp(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseUp(i.event,i.documentPoint,i.targetDiagram))return;let e=!1;const s=this.mayCopy();if(s&&this.copiedParts!==null?(this.kl(),this.xP(!0),t.Vw(this.copiedParts),this.mc(this.copiedParts,!1),t.wm(this.copiedParts),this.copiedParts!==null&&(t.v("ChangingSelection",t.selection),t.clearSelection(!0),this.copiedParts.iteratorKeys.each(n=>{n.isSelected=!0}))):(e=!0,this.kl(),this.mayMove()&&(this.mc(this.draggedParts,!0),this.kP(t.lastInput.documentPoint))),this.gu=!0,this.BC(t.lastInput.documentPoint),this.isActive){const n=s?this.copiedParts.toKeySet():this.draggedParts.toKeySet();this.copiedParts=null,e&&this._D(),t.invalidateDocumentBounds(),t.wm(this.draggedParts),this.transactionResult=s?"Copy":"Move",t.v(s?"SelectionCopied":"SelectionMoved",n)}this.stopTool(),s&&t.v("ChangedSelection",t.selection)}simulatedMouseMove(t,i,e){if(DraggingTool.yt===null)return!1;const s=DraggingTool.yt.diagram;e instanceof Diagram||(e=null);const n=DraggingTool.zh;if(e!==n){if(n!==null&&n!==s){n.stopAutoScroll(),DraggingTool.yt.isDragOutStarted=!1;const r=n.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDragLeave()}if(DraggingTool.zh=e,e!==null&&e!==s){DraggingTool.yt.vC();const r=e.toolManager.findTool("Dragging");r!==null&&(r.UC(),r.doSimulatedDragEnter())}this.doUpdateCursor(null)}if(e===null||e===s||!e.allowDrop||e.isReadOnly||!e.allowInsert)return!1;const o=e.toolManager.findTool("Dragging");if(o!==null){let r=i;t!==null&&(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),r=e.getMouse(t)),e.lastInput.documentPoint=r,e.lastInput.viewPoint=e.transformDocToView(r),e.lastInput.down=!1,e.lastInput.up=!1,o.doSimulatedDragOver()}return!0}simulatedMouseUp(t,i,e){if(DraggingTool.yt===null)return!1;const s=DraggingTool.zh,n=DraggingTool.yt.diagram;if(e===null)return DraggingTool.yt.doCancel(),!0;if(e!==s){const o=s.toolManager.findTool("Dragging");if(s!==null&&s!==n&&o!==null)return s.stopAutoScroll(),DraggingTool.yt.isDragOutStarted=!1,o.doSimulatedDragLeave(),!1;DraggingTool.zh=e;const r=e.toolManager.findTool("Dragging");r!==null&&(DraggingTool.yt.vC(),r.UC(),r.doSimulatedDragEnter())}if(e!==this.diagram){let o=i;t!==null?(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),o=e.getMouse(t)):o===null&&(o=new Point),e.lastInput.documentPoint=o,e.lastInput.viewPoint=e.transformDocToView(o),e.lastInput.down=!1,e.lastInput.up=!0;const r=e.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDrop();const l=DraggingTool.yt;if(l!==null){const h=l.mayCopy();l.transactionResult=h?"Copy":"Move",l.stopTool()}return!0}return!1}_D(){if(this.draggedParts===null)return;const t=this.draggedParts.iterator;for(;t.next();){const i=t.key;if(i instanceof Node){const e=i.containingGroup;e!==null&&e.hasPlaceholder()&&!this.draggedParts.has(e)&&e.placeholder.c()}}}mayCopy(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowCopy||!(Util.rr?t.lastInput.alt:t.lastInput.control))return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayDragOut(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(!t.allowDragOut||!t.allowCopy||t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayMove(){const t=this.diagram;if(t.isReadOnly||!t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canMove())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canMove())}UC(){DraggingTool.zw.has(this)||DraggingTool.zw.add(this)}static WD(){if(DraggingTool.zw.count>0){const t=DraggingTool.zw,i=t.length;for(let e=0;e{n.isSelected=!0,s.add(n)})),this.BC(t.lastInput.documentPoint),t.invalidateDocumentBounds(),this.copiedParts!==null&&(this.transactionResult="ExternalCopy"),this.copiedParts=null,t.doFocus(),t.dc=!1,t.v("ExternalObjectsDropped",s,e),this.stopTransaction(),t.v("ChangedSelection",t.selection)}t.animationManager.wu=!1}VC(t,i,e){if(this.copiedParts!==null)return;const s=this.diagram;if(s.isReadOnly||s.isModelReadOnly)return;s.skipsUndoManager=!i,s.partManager.addsToTemporaryLayer=!i,this.startPoint=e.documentPoint;const n=s.copyParts(t,s,!0),o=Rect.l();this.JD(t,o);const r=o.x+o.width/2,l=o.y+o.height/2;Rect.s(o);const h=this.ym,a=new GMap,c=Point.l(),f=t.iterator;for(;f.next();){const d=f.value;if(d instanceof Link&&d.canCopy()){const m=n.get(d);if(m===null)continue;m.points=d.points,m.pr(h.x-r,h.y-l),m.suspendsRouting=!0,a.set(m,this.Is())}}const u=t.iterator;for(;u.next();){const d=u.value;if(d.Pe()&&d.canCopy()){const m=n.get(d);if(m===null)continue;const g=d.location;c.e(h.x-(r-g.x),h.y-(l-g.y)),m.location=c,m.ensureBounds(),a.set(m,this.Is(c))}}if(Point.s(c),this.copiedParts=a,this.mP(a.toKeySet()),this.draggedLink!==null){const d=this.draggedLink,m=d.routeBounds;d.pr(this.startPoint.x-(m.x+m.width/2),this.startPoint.y-(m.y+m.height/2))}this.doUpdateCursor(null)}qD(){this.isDragOutStarted=!0,this.gu=!1,DraggingTool.yt=this,DraggingTool.zh=this.diagram,this.doSimulatedDragOut()}doSimulatedDragOut(){const t=this.diagram;t.dc=!1,!this.mayCopy()&&!this.mayMove()?t.currentCursor=this.nodropCursor:t.currentCursor="",this.mu=null}computeMove(t,i,e,s){const n=this.diagram;return n!==null?n.computeMove(t,i,this.dragOptions,s):new Point}static zw=new List;static yt=null;static zh=null}ToolManager.prototype.doCancel=function(){DraggingTool.yt!==null&&DraggingTool.yt.doCancel(),Tool.prototype.doCancel.call(this)};class LinkingBaseTool extends Tool{CP;LP;Sl;AP;TP;Xh;DP;Kh;FP;RP;vP;OP;IP;EP;zC;BP;Ml;UP;constructor(){super(),this.CP=100,this.LP=!1,this.Sl="pointer",this.AP=new Link({layerName:"Tool"}).add(new Shape({isPanelMain:!0,stroke:"blue"}).theme("stroke","tempLink"),new Shape({toArrow:"Standard",fill:"blue",stroke:"blue"}).theme("fill","tempLink").theme("stroke","tempLink")).li(),this.Xh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.Dk}).theme("stroke","tempPort"),this.TP=new Node({selectable:!1,layerName:"Tool"}).add(this.Xh).li(),this.Kh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.Dk}).theme("stroke","tempPort"),this.DP=new Node({selectable:!1,layerName:"Tool"}).add(this.Kh).li(),this.FP=null,this.RP=null,this.vP=null,this.OP=null,this.IP=null,this.EP=!0,this.zC=new GMap,this.BP=null,this.Ml=null,this.UP=null}doStop(){this.diagram.stopAutoScroll(),this.originalLink=null,this.originalFromNode=null,this.originalFromPort=null,this.originalToNode=null,this.originalToPort=null,this.validPortsCache.clear(),this.targetPort=null}get portGravity(){return this.CP}set portGravity(t){Util.i(t,"number",LinkingBaseTool,"portGravity"),t>=0&&(this.CP=t)}get isUnconnectedLinkValid(){return this.LP}set isUnconnectedLinkValid(t){Util.i(t,"boolean",LinkingBaseTool,"isUnconnectedLinkValid"),this.LP=t}get linkingCursor(){return this.Sl}set linkingCursor(t){this.Sl=t}get temporaryLink(){return this.AP}set temporaryLink(t){t.li(),this.AP=t}get temporaryFromNode(){return this.TP}set temporaryFromNode(t){t.li(),this.TP=t,t&&(this.Xh=t.port)}get temporaryFromPort(){return this.Xh}set temporaryFromPort(t){if(this.Xh!==null){const i=this.Xh.panel;if(i!==null){const e=i.L.indexOf(this.Xh);i.removeAt(e),i.insertAt(e,t)}}this.Xh=t}get temporaryToNode(){return this.DP}set temporaryToNode(t){t.li(),this.DP=t,t&&(this.Kh=t.port)}get temporaryToPort(){return this.Kh}set temporaryToPort(t){if(this.Kh!==null){const i=this.Kh.panel;if(i!==null){const e=i.L.indexOf(this.Kh);i.removeAt(e),i.insertAt(e,t)}}this.Kh=t}get originalLink(){return this.FP}set originalLink(t){this.FP=t}get originalFromNode(){return this.RP}set originalFromNode(t){this.RP=t}get originalFromPort(){return this.vP}set originalFromPort(t){this.vP=t}get originalToNode(){return this.OP}set originalToNode(t){this.OP=t}get originalToPort(){return this.IP}set originalToPort(t){this.IP=t}get isForwards(){return this.EP}set isForwards(t){this.EP=t}get validPortsCache(){return this.zC}get targetPort(){return this.BP}set targetPort(t){this.BP=t}copyPortProperties(t,i,e,s,n){if(t===null||i===null||e===null||s===null)return;const o=i.getDocumentScale(),r=Size.l();r.width=i.naturalBounds.width*o,r.height=i.naturalBounds.height*o,s.desiredSize=r,Size.s(r),n?(s.toSpot=i.toSpot,s.toEndSegmentLength=i.toEndSegmentLength):(s.fromSpot=i.fromSpot,s.fromEndSegmentLength=i.fromEndSegmentLength),e.locationSpot=Spot.Center;const l=Point.l();e.location=i.getDocumentPoint(Spot.Center,l),Point.s(l),s.angle=i.getDocumentAngle(),this.portTargeted!==null&&this.portTargeted(t,i,e,s,n)}setNoTargetPortProperties(t,i,e){i!==null&&(i.desiredSize=Size.Dk,i.fromSpot=Spot.None,i.toSpot=Spot.None),t!==null&&(t.location=this.diagram.lastInput.documentPoint),this.portTargeted!==null&&this.portTargeted(null,null,t,i,e)}doMouseDown(){this.isActive&&this.doMouseMove()}doMouseMove(){if(this.isActive){const t=this.diagram;if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null&&this.targetPort.part instanceof Node){const i=this.targetPort.part;this.isForwards?this.copyPortProperties(i,this.targetPort,this.temporaryToNode,this.temporaryToPort,!0):this.copyPortProperties(i,this.targetPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else this.isForwards?this.setNoTargetPortProperties(this.temporaryToNode,this.temporaryToPort,!0):this.setNoTargetPortProperties(this.temporaryFromNode,this.temporaryFromPort,!1);(t.allowHorizontalScroll||t.allowVerticalScroll)&&t.doAutoScroll(t.lastInput.viewPoint)}}findValidLinkablePort(t,i){if(t===null)return null;const e=t.part;if(!(e instanceof Node))return null;for(;t!==null;){const s=i?t.toLinkable:t.fromLinkable;if(s===!0&&(t.portId!==null||t instanceof Node)&&(i?this.isValidTo(e,t):this.isValidFrom(e,t)))return t;if(s===!1)return null;t=t.panel}return null}findTargetPort(t){const i=this.diagram,e=i.lastInput.documentPoint;let s=this.portGravity;s<=0&&(s=.1);const n=this,o=i.findObjectsNear(e,s,a=>n.findValidLinkablePort(a,t),null,!0);let r=1/0,l=null;const h=o.iterator;for(;h.next();){const a=h.value,c=a.part;if(!(c instanceof Node))continue;const f=a.getDocumentPoint(Spot.Center,Point.l()),u=e.x-f.x,d=e.y-f.y;Point.s(f);const m=u*u+d*d;if(m=e)return!1}return!0}isValidTo(t,i){if(t===null||i===null)return this.isUnconnectedLinkValid;if(this.diagram.currentTool===this&&(t.layer!==null&&!t.layer.allowLink||i.toLinkable!==!0))return!1;const e=i.toMaxLinks;if(e<1/0){if(this.originalLink!==null&&t===this.originalToNode&&i===this.originalToPort)return!0;let s=i.portId;if(s===null&&(s=""),t.findLinksInto(s).count>=e)return!1}return!0}isInSameNode(t,i){if(t===null||i===null)return!1;if(t===i)return!0;const e=t.part,s=i.part;return e!==null&&e===s}isLinked(t,i){if(t===null||i===null)return!1;const e=t.part;if(!(e instanceof Node))return!1;let s=t.portId;s===null&&(s="");const n=i.part;if(!(n instanceof Node))return!1;let o=i.portId;o===null&&(o="");const r=n.findLinksInto(o);for(;r.next();){const l=r.value;if(l.fromNode===e&&l.fromPortId===s)return!0}return!1}isValidLink(t,i,e,s){if(!this.isValidFrom(t,i)||!this.isValidTo(e,s)||i!==null&&s!==null&&(!(i.fromLinkableSelfNode&&s.toLinkableSelfNode)&&this.isInSameNode(i,s)||!(i.fromLinkableDuplicates&&s.toLinkableDuplicates)&&this.isLinked(i,s))||this.originalLink!==null&&(t!==null&&this.isLabelDependentOnLink(t,this.originalLink)||e!==null&&this.isLabelDependentOnLink(e,this.originalLink))||t!==null&&e!==null&&(t.data===null&&e.data!==null||t.data!==null&&e.data===null)||!this.isValidCycle(t,e,this.originalLink))return!1;let n;return t!==null&&(n=t.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))||e!==null&&(n=e.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))?!1:(n=this.linkValidation,n!==null?n(t,i,e,s,this.originalLink):!0)}isLabelDependentOnLink(t,i){if(t===null)return!1;const e=t.labeledLink;if(e===null)return!1;if(e===i)return!0;const s=new GSet;return s.add(t),this.VP(e,i,s)}VP(t,i,e){if(t===i)return!0;const s=t.fromNode;if(s!==null&&s.isLinkLabel&&(e.add(s),this.VP(s.labeledLink,i,e)))return!0;const n=t.toNode;return!!(n!==null&&n.isLinkLabel&&(e.add(n),this.VP(n.labeledLink,i,e)))}isValidCycle(t,i,e){if(e===void 0&&(e=null),t===null||i===null)return this.isUnconnectedLinkValid;const s=this.diagram;let n=1;if(s&&(s.model.pc()?n=s.isTreePathToChildren?5:6:n=s.validCycle),n===1)return!0;if(n===5){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=i.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.toNode===i)return!1}return!this.xu(t,i,e,!0)}else if(n===6){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=t.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.fromNode===t)return!1}return!this.xu(t,i,e,!0)}else{if(n===2)return!this.tF(t,i,e);if(n===3)return!this.xu(t,i,e,!1);if(n===4)return!this.iF(t,i,e)}return!0}xu(t,i,e,s){if(t===i)return!0;if(t===null||i===null)return!1;const n=t.linksConnected;for(;n.next();){const o=n.value;if(o===e||s&&!o.isTreeLink||o.toNode!==t)continue;const r=o.fromNode;if(r!==t&&this.xu(r,i,e,s))return!0}return!1}tF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.XC(s,t,i,e)}XC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s||o.toNode!==i)continue;const r=o.fromNode;if(r!==i&&this.XC(t,r,e,s))return!0}return!1}iF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.KC(s,t,i,e)}KC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s)continue;const r=o.fromNode,l=o.toNode,h=r===i?l:r;if(h!==i&&this.KC(t,h,e,s))return!0}return!1}get linkValidation(){return this.Ml}set linkValidation(t){t!==null&&Util.i(t,"function",LinkingBaseTool,"linkValidation"),this.Ml=t}get portTargeted(){return this.UP}set portTargeted(t){t!==null&&Util.i(t,"function",LinkingBaseTool,"portTargeted"),this.UP=t}}var LinkingDirection=(w=>(w[w.Either=1]="Either",w[w.ForwardsOnly=2]="ForwardsOnly",w[w.BackwardsOnly=3]="BackwardsOnly",w))(LinkingDirection||{});class LinkingTool extends LinkingBaseTool{zP;XP;S;KP;constructor(t){super(),this.name="Linking",this.zP={},this.XP=null,this.S=1,this.KP=null,t&&Object.assign(this,t)}static Either=1;static ForwardsOnly=2;static BackwardsOnly=3;get archetypeLinkData(){return this.zP}set archetypeLinkData(t){t!==null&&Util.i(t,"object",LinkingTool,"archetypeLinkData"),this.zP=t}get archetypeLabelNodeData(){return this.XP}set archetypeLabelNodeData(t){t!==null&&Util.i(t,"object",LinkingTool,"archetypeLabelNodeData"),this.XP=t}get direction(){return this.S}set direction(t){this.S=t}get startObject(){return this.KP}set startObject(t){this.KP=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||t.isModelReadOnly||!t.allowLink||!t.model.Xw()||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize()?!1:this.findLinkablePort()!==null}findLinkablePort(){const t=this.diagram;let i=this.startObject;if(i===null&&(i=t.findObjectAt(t.firstInput.documentPoint,null,null)),i===null)return null;const e=i.part;if(!(e instanceof Node))return null;const s=this.direction;if(s===1||s===2){const n=this.findValidLinkablePort(i,!1);if(n!==null)return this.isForwards=!0,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!1))return this.isForwards=!0,o}}if(s===1||s===3){const n=this.findValidLinkablePort(i,!0);if(n!==null)return this.isForwards=!1,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!0))return this.isForwards=!1,o}}return null}doActivate(){const t=this.diagram,i=this.findLinkablePort();if(i===null){this.stopTool();return}if(this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.isForwards){this.temporaryToNode!==null&&(this.temporaryToNode.location=t.lastInput.documentPoint),this.originalFromPort=i;const e=this.originalFromPort.part;e instanceof Node&&(this.originalFromNode=e),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else{this.temporaryFromNode!==null&&(this.temporaryFromNode.location=t.lastInput.documentPoint),this.originalToPort=i;const e=this.originalToPort.part;e instanceof Node&&(this.originalToNode=e),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0)}t.add(this.temporaryFromNode),this.temporaryFromNode&&this.temporaryFromNode.ensureBounds(),t.add(this.temporaryToNode),this.temporaryToNode&&this.temporaryToNode.ensureBounds(),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.temporaryLink.isTreeLink=this.isNewTreeLink(),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.startObject=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=null,e=null,s=null,n=null,o=null;try{this.targetPort=this.findTargetPort(this.isForwards);const r=this.targetPort;if(r!==null){const l=r.part;l instanceof Node&&(this.isForwards?(this.originalFromNode!==null&&(i=this.originalFromNode,e=this.originalFromPort),s=l,n=r):(i=l,e=r,this.originalToNode!==null&&(s=this.originalToNode,n=this.originalToPort)))}else this.isForwards?this.originalFromNode!==null&&this.isUnconnectedLinkValid&&(i=this.originalFromNode,e=this.originalFromPort):this.originalToNode!==null&&this.isUnconnectedLinkValid&&(s=this.originalToNode,n=this.originalToPort);i!==null||s!==null?(o=this.insertLink(i,e,s,n),o!==null?(r===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint),t.allowSelect&&(t.v("ChangingSelection",t.selection),t.clearSelection(!0),o.isSelected=!0),this.transactionResult=this.name,t.v("LinkDrawn",o)):this.doNoLink(i,e,s,n)):this.isForwards?this.doNoLink(this.originalFromNode,this.originalFromPort,null,null):this.doNoLink(null,null,this.originalToNode,this.originalToPort)}finally{this.stopTool(),o&&t.allowSelect&&t.v("ChangedSelection",t.selection)}}}isNewTreeLink(){const t=this.archetypeLinkData;if(t===null)return!0;if(t instanceof Link)return t.isTreeLink;const i=this.diagram;if(i===null)return!0;const e=i.partManager.getLinkCategoryForData(t),s=i.partManager.findLinkTemplateForCategory(e);return s!==null?s.isTreeLink:!0}insertLink(t,i,e,s){return this.diagram.partManager.insertLink(t,i,e,s)}doNoLink(t,i,e,s){}}class RelinkingTool extends LinkingBaseTool{YP;GP;fs;jP;constructor(t){super(),this.name="Relinking",this.YP=new Shape("Diamond",{desiredSize:Size.lu,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:0}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.GP=new Shape("Diamond",{desiredSize:Size.lu,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:-1}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.fs=null,this.jP=new Rect,t&&Object.assign(this,t)}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i="RelinkFrom",e=null;if(t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkFrom()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null&&(e=this.makeAdornment(s,!1),t.addAdornment(i,e)))}if(e===null&&t.removeAdornment(i),i="RelinkTo",e=null,t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkTo()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null?(e=this.makeAdornment(s,!0),t.addAdornment(i,e)):e.c())}e===null&&t.removeAdornment(i)}makeAdornment(t,i){const e=new Adornment;e.type=Panel.Link;const s=i?this.toHandleArchetype:this.fromHandleArchetype;return s!==null&&e.add(s.copy().xm()),e.adornedObject=t,e}get fromHandleArchetype(){return this.YP}set fromHandleArchetype(t){this.YP=t}get toHandleArchetype(){return this.GP}set toHandleArchetype(t){this.GP=t}get handle(){return this.fs}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.fs=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowRelink||!t.model.Xw()||!t.lastInput.left)return!1;let e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom");return e===null&&(e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo")),e!==null}doActivate(){const t=this.diagram;if(this.originalLink===null){let i=this.handle;if(i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom"),i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo"))),i===null)return;const e=i.part;if(!(e instanceof Adornment)||!(e.adornedPart instanceof Link))return;this.handle=i,this.isForwards=e===null||e.category==="RelinkTo",this.originalLink=e.adornedPart}this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.originalFromPort=this.originalLink.fromPort,this.originalFromNode=this.originalLink.fromNode,this.originalToPort=this.originalLink.toPort,this.originalToNode=this.originalLink.toNode,this.jP.set(this.originalLink.actualBounds),this.originalLink!==null&&this.originalLink.pointsCount>0&&(this.originalLink.fromNode===null&&(this.temporaryFromPort!==null&&(this.temporaryFromPort.desiredSize=Size.ru),this.temporaryFromNode!==null&&(this.temporaryFromNode.location=this.originalLink.getPoint(0))),this.originalLink.toNode===null&&(this.temporaryToPort!==null&&(this.temporaryToPort.desiredSize=Size.ru),this.temporaryToNode!==null&&(this.temporaryToNode.location=this.originalLink.getPoint(this.originalLink.pointsCount-1)))),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0),t.add(this.temporaryFromNode),t.add(this.temporaryToNode),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.copyLinkProperties(this.originalLink,this.temporaryLink),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}copyLinkProperties(t,i){if(t===null||i===null)return;i.adjusting=t.adjusting,i.corner=t.corner;let e=t.curve;(e===11||e===10)&&(e=0),i.curve=e,i.curviness=t.curviness,i.isTreeLink=t.isTreeLink,i.points=t.points,i.routing=t.routing,i.smoothness=t.smoothness,i.fromSpot=t.fromSpot,i.fromEndSegmentLength=t.fromEndSegmentLength,i.fromShortLength=t.fromShortLength,i.toSpot=t.toSpot,i.toEndSegmentLength=t.toEndSegmentLength,i.toShortLength=t.toShortLength}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.handle=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=this.originalFromNode,e=this.originalFromPort,s=this.originalToNode,n=this.originalToPort,o=this.originalLink;try{if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null){const r=this.targetPort.part;r instanceof Node&&(this.isForwards?(s=r,n=this.targetPort):(i=r,e=this.targetPort))}else this.isUnconnectedLinkValid?this.isForwards?(s=null,n=null):(i=null,e=null):o=null;o!==null?(this.reconnectLink(o,this.isForwards?s:i,this.isForwards?n:e,this.isForwards),this.targetPort===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint,o.invalidateRoute()),this.transactionResult=this.name,t.v("LinkRelinked",o,this.isForwards?this.originalToPort:this.originalFromPort)):this.doNoRelink(this.originalLink,this.isForwards),this.originalLink.invalidateOtherJumpOvers(this.jP)}finally{this.stopTool()}}}reconnectLink(t,i,e,s){const n=e!==null&&e.portId!==null?e.portId:"";return s?(t.toNode=i,t.toPortId=n):(t.fromNode=i,t.fromPortId=n),!0}doNoRelink(t,i){}doDraggingMouseMove(t,i,e,s){t!==null?(this.copyPortProperties(t,i,this.temporaryFromNode,this.temporaryFromPort,!1),this.diagram.add(this.temporaryFromNode)):this.diagram.remove(this.temporaryFromNode),e!==null?(this.copyPortProperties(e,s,this.temporaryToNode,this.temporaryToPort,!0),this.diagram.add(this.temporaryToNode)):this.diagram.remove(this.temporaryToNode)}stopDraggingMouseMove(){this.diagram.remove(this.temporaryFromNode),this.diagram.remove(this.temporaryToNode)}}var ReshapingBehavior=(w=>(w[w.None=0]="None",w[w.Horizontal=1]="Horizontal",w[w.Vertical=2]="Vertical",w[w.All=3]="All",w))(ReshapingBehavior||{});class LinkReshapingTool extends Tool{Co;HP;qP;fs;Kw;WP;bm;constructor(t){super(),this.name="LinkReshaping",this.Co=new Shape("Rectangle",{desiredSize:Size._N,fill:"lightblue",stroke:"dodgerblue"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.HP=new Shape("Diamond",{desiredSize:Size.lu,fill:"lightblue",stroke:"dodgerblue",cursor:"move"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.qP=3,this.fs=null,this.Kw=null,this.WP=new Point,this.bm=new List,t&&Object.assign(this,t)}static None=0;static Horizontal=1;static Vertical=2;static All=3;getReshapingBehavior(t){return t?t.wr:0}setReshapingBehavior(t,i){t.wr=i}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i=null;if(t.isSelected&&!this.diagram.isReadOnly){const e=t.path;e!==null&&t.canReshape()&&t.actualBounds.isReal()&&t.isVisible()&&e.actualBounds.isReal()&&e.isVisibleObject()&&(i=t.findAdornment(this.name),(i===null||i.JP!==t.pointsCount||i.$P!==t.resegmentable)&&(i=this.makeAdornment(e),i!==null&&(i.JP=t.pointsCount,i.$P=t.resegmentable,t.addAdornment(this.name,i))))}i===null&&t.removeAdornment(this.name)}makeAdornment(t){const i=t.part,e=i.points,s=i.pointsCount,n=i.isOrthogonal;let o=null;if(e!==null&&s>1){o=new Adornment,o.type=Panel.Link;const r=i.firstPickIndex,l=i.lastPickIndex,h=n?1:0;if(i.resegmentable&&i.computeCurve()!==9)for(let a=r+h;ae.firstPickIndex+1&&s0))this.eF(t,i);else if(t instanceof Panel){const e=t.elements;for(;e.next();){const s=e.value;this.updateResizeHandles(s,i)}}}}eF(t,i){let e=t.alignment;e.isNoSpot()&&(e=Spot.Center);let s=i;if(e.x<=0)e.y<=0?s+=225:e.y>=1?s+=135:s+=180;else if(e.x>=1)e.y<=0?s+=315:e.y>=1&&(s+=45);else if(e.y<=0)s+=270;else if(e.y>=1)s+=90;else return;s<0?s+=360:s>=360&&(s-=360),s<22.5?t.cursor="e-resize":s<67.5?t.cursor="se-resize":s<112.5?t.cursor="s-resize":s<157.5?t.cursor="sw-resize":s<202.5?t.cursor="w-resize":s<247.5?t.cursor="nw-resize":s<292.5?t.cursor="n-resize":s<337.5?t.cursor="ne-resize":t.cursor="e-resize"}get handleArchetype(){return this.Co}set handleArchetype(t){this.Co=t}get handle(){return this.fs}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.fs=t}get adornedObject(){return this.us}set adornedObject(t){if(t!==null&&t.part instanceof Adornment)throw new Error("new handle must not be in an Adornment: "+t);this.us=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowResize||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle!==null&&(this.adornedObject=this.handle.part.adornedObject,this.adornedObject!==null&&(t.isMouseCaptured=!0,t.animationManager.stopAnimation(),t.pu=!0,this.startTransaction(this.name),this.km.set(this.adornedObject.getDocumentPoint(this.handle.alignment.opposite())),this.wc.set(this.adornedObject.part.location),this.QP.set(this.adornedObject.desiredSize),this.jw=this.computeCellSize(),this.Yw=this.computeMinSize(),this.Gw=this.computeMaxSize(),this.isActive=!0))}doDeactivate(){const t=this.diagram;t.pu=!1,t.bl=!0,this.stopTransaction(),this.handle=null,this.us=null,t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){this.adornedObject!==null&&(this.adornedObject.desiredSize=this.originalDesiredSize,this.adornedObject.part.location=this.originalLocation),this.stopTool()}doMouseMove(){const t=this.diagram;if(!this.isActive)return;const i=this.Yw,e=this.Gw,s=this.jw,n=t.lastInput.documentPoint,o=this.adornedObject.getLocalPoint(n,Point.l()),r=this.computeReshape(),l=this.computeResize(o,this.handle.alignment,i,e,s,r);this.resize(l),t.maybeUpdate(),Point.s(o)}doMouseUp(){const t=this.diagram;if(this.isActive){const i=this.Yw,e=this.Gw,s=this.jw,n=this.adornedObject.getLocalPoint(t.lastInput.documentPoint,Point.l()),o=this.computeReshape(),r=this.computeResize(n,this.handle.alignment,i,e,s,o);this.resize(r),Point.s(n),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.v("PartResized",this.adornedObject,this.originalDesiredSize)}this.stopTool()}resize(t){const i=this.diagram,e=this.adornedObject;if(e===null)return;e.desiredSize=t.size;const s=e.part;s.ensureBounds();const n=e.getDocumentPoint(this.handle.alignment.opposite());if(s instanceof Group){const o=new List;o.add(s);let r;!this.dragsMembers&&!s.hasPlaceholder()&&(r=new DraggingOptions,r.dragsMembers=!1),i.moveParts(o,this.oppositePoint.copy().subtract(n),!0,r)}else s.location=s.location.copy().subtract(n).add(this.oppositePoint);i.maybeUpdate()}computeResize(t,i,e,s,n,o){i.isNoSpot()&&(i=Spot.Center);const r=this.adornedObject.naturalBounds,l=r.x,h=r.y,a=r.x+r.width,c=r.y+r.height;let f=1;if(!o){let m=r.width,g=r.height;m<=0&&(m=1),g<=0&&(g=1),f=g/m}const u=Point.l();Geo.Ig(t.x,t.y,l,h,n.width,n.height,u);const d=r.copy();return i.x<=0?i.y<=0?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=Math.max(c-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.x=a-d.width,d.y=c-d.height)):i.y>=1?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.x=a-d.width)):(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=a-d.x,o||(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f,d.y=h+.5*(c-h-d.height))):i.x>=1?i.y<=0?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=Math.max(c-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.y=c-d.height)):i.y>=1?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width))):(d.width=Math.max(Math.min(u.x-l,s.width),e.width),o||(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f,d.y=h+.5*(c-h-d.height))):i.y<=0?(d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=c-d.y,o||(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width,d.x=l+.5*(a-l-d.width))):i.y>=1&&(d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width,d.x=l+.5*(a-l-d.width))),Point.s(u),d}computeReshape(){let t=0;return this.adornedObject instanceof Shape&&(t=this.adornedObject._P()),!(t===6||this.diagram.lastInput.shift)}computeMinSize(){const t=this.adornedObject.minSize.copy(),i=this.minSize;return!isNaN(i.width)&&i.width>t.width&&(t.width=i.width),!isNaN(i.height)&&i.height>t.height&&(t.height=i.height),t}computeMaxSize(){const t=this.adornedObject.maxSize.copy(),i=this.maxSize;return!isNaN(i.width)&&i.width0&&(t.width=n.width),!isNaN(n.height)&&n.height>0&&(t.height=n.height)}let e=this.cellSize;isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height);const s=this.diagram;if((isNaN(t.width)||isNaN(t.height))&&s){const n=s.grid;n!==null&&n.visible&&this.isGridSnapEnabled&&(e=n.gridCellSize,isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height))}return(isNaN(t.width)||t.width===0||t.width===1/0)&&(t.width=1),(isNaN(t.height)||t.height===0||t.height===1/0)&&(t.height=1),t}get minSize(){return this.xr}set minSize(t){if(!this.xr.equals(t)){let e=t.width;isNaN(e)&&(e=0);let s=t.height;isNaN(s)&&(s=0),this.xr.e(e,s)}}get maxSize(){return this.br}set maxSize(t){if(!this.br.equals(t)){let e=t.width;isNaN(e)&&(e=1/0);let s=t.height;isNaN(s)&&(s=1/0),this.br.e(e,s)}}get cellSize(){return this.Lo}set cellSize(t){this.Lo.equals(t)||this.Lo.a(t)}get isGridSnapEnabled(){return this.yc}set isGridSnapEnabled(t){Util.i(t,"boolean",ResizingTool,"isGridSnapEnabled"),this.yc=t}get dragsMembers(){return this.ZP}set dragsMembers(t){Util.i(t,"boolean",ResizingTool,"dragsMembers"),this.ZP=t}get oppositePoint(){return this.km}set oppositePoint(t){this.km.equals(t)||this.km.a(t)}get originalDesiredSize(){return this.QP}get originalLocation(){return this.wc}}class RotatingTool extends Tool{tS;iS;us;Co;fs;eS;Pm;wc;sS;nS;constructor(t){super(),this.name="Rotating",this.tS=45,this.iS=2,this.wc=new Point,this.us=null,this.Co=new Shape("Ellipse",{desiredSize:Size.lu,fill:"lightblue",stroke:"dodgerblue",strokeWidth:1,cursor:"pointer"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.fs=null,this.eS=0,this.Pm=new Point(NaN,NaN),this.sS=0,this.nS=50,t&&Object.assign(this,t)}updateAdornments(t){if(t!==null){if(t.Cl()){const i=t.rotateObject;if(i===t||i===t.path||i.isPanelMain)return}if(t.isSelected&&!this.diagram.isReadOnly){const i=t.rotateObject;if(i!==null&&t.canRotate()&&t.actualBounds.isReal()&&t.isVisible()&&i.actualBounds.isReal()&&i.isVisibleObject()){let e=t.findAdornment(this.name);if((e===null||e.adornedObject!==i)&&(e=this.makeAdornment(i)),e!==null){e.angle=i.getDocumentAngle(),e.hasPlaceholder()||(e.location=this.computeAdornmentLocation(i)),t.addAdornment(this.name,e);return}}}t.removeAdornment(this.name)}}makeAdornment(t){let i=null;const e=t.part.rotateAdornmentTemplate;if(e===null){i=new Adornment,i.type=Panel.Position,i.locationSpot=Spot.Center;const s=this.handleArchetype;s!==null&&i.add(s.copy().xm())}else if(e.li(),i=e.copy(),i===null)return null;return i.adornedObject=t,i}get handleArchetype(){return this.Co}set handleArchetype(t){this.Co=t}get handle(){return this.fs}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.fs=t}get adornedObject(){return this.us}set adornedObject(t){if(t!==null&&t.part instanceof Adornment)throw new Error("new handle must not be in an Adornment: "+t);this.us=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowRotate||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;if(this.adornedObject===null){if(this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle===null)return;this.adornedObject=this.handle.part.adornedObject}this.adornedObject!==null&&(t.isMouseCaptured=!0,t.delaysLayout=!0,this.startTransaction(this.name),this.eS=this.adornedObject.angle,this.Pm=this.computeRotationPoint(this.adornedObject),this.wc=this.adornedObject.part.location.copy(),this.isActive=!0)}computeRotationPoint(t){const i=t.part,e=i.locationObject;return i.rotationSpot.isSpot()?t.getDocumentPoint(i.rotationSpot):t===i||t===e?e.getDocumentPoint(i.locationSpot):t.getDocumentPoint(Spot.Center)}computeAdornmentLocation(t){let i=this.rotationPoint;i.isReal()||(i=this.computeRotationPoint(t));const e=t.getLocalPoint(i);let s=this.handleAngle;s<0?s+=360:s>=360&&(s-=360),s=Math.round(Math.round(s/45)*45);const n=this.handleDistance;return s===0?e.x=t.naturalBounds.width+n:s===45?(e.x=t.naturalBounds.width+n,e.y=t.naturalBounds.height+n):s===90?e.y=t.naturalBounds.height+n:s===135?(e.x=-n,e.y=t.naturalBounds.height+n):s===180?e.x=-n:s===225?(e.x=-n,e.y=-n):s===270?e.y=-n:s===315&&(e.x=t.naturalBounds.width+n,e.y=-n),t.getDocumentPoint(e)}doDeactivate(){const t=this.diagram;this.stopTransaction(),this.handle=null,this.us=null,this.Pm=new Point(NaN,NaN),t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){const t=this.diagram;t.delaysLayout=!1,this.rotate(this.originalAngle),this.stopTool()}doMouseMove(){const t=this.diagram;if(this.isActive){const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i)}}doMouseUp(){const t=this.diagram;if(this.isActive){t.delaysLayout=!1;const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.v("PartRotated",this.adornedObject,this.originalAngle)}this.stopTool()}rotate(t){const i=this.adornedObject;if(i===null)return;i.angle=t;const e=i.part;e.ensureBounds();const s=e.locationObject,n=e.rotateObject;if(s===n||s.isContainedBy(n)){const o=this.wc.copy();e.location=o.subtract(this.rotationPoint).rotate(t-this.originalAngle).add(this.rotationPoint)}this.diagram.maybeUpdate()}computeRotate(t){let i=this.rotationPoint.directionPoint(t)-this.handleAngle;const e=this.adornedObject.panel;e!==null&&(i-=e.getDocumentAngle()),i>=360?i-=360:i<0&&(i+=360);const s=Math.min(Math.abs(this.snapAngleMultiple),180),n=Math.min(Math.abs(this.snapAngleEpsilon),s/2);return!this.diagram.lastInput.shift&&s>0&&n>0&&(i%ss-n&&(i=(Math.floor(i/s)+1)*s)),i>=360?i-=360:i<0&&(i+=360),i}get snapAngleMultiple(){return this.tS}set snapAngleMultiple(t){Util.i(t,"number",RotatingTool,"snapAngleMultiple"),this.tS=t}get snapAngleEpsilon(){return this.iS}set snapAngleEpsilon(t){Util.i(t,"number",RotatingTool,"snapAngleEpsilon"),this.iS=t}get originalAngle(){return this.eS}get rotationPoint(){return this.Pm}set rotationPoint(t){this.Pm=t.copy()}get handleAngle(){return this.sS}set handleAngle(t){Util.i(t,"number",RotatingTool,"handleAngle"),this.sS=t}get handleDistance(){return this.nS}set handleDistance(t){Util.i(t,"number",RotatingTool,"handleDistance"),this.nS=t}}class ClickSelectingTool extends Tool{constructor(t){super(),this.name="ClickSelecting",t&&Object.assign(this,t)}canStart(){return!(!this.isEnabled||this.isBeyondDragSize())}doMouseUp(){this.isActive&&(this.standardMouseSelect(),this.standardMouseClick()||this.diagram.lastInput.isTouchEvent&&this.diagram.toolManager.doToolTip()),this.stopTool()}}class ActionTool extends Tool{xc;constructor(t){super(),this.name="Action",this.xc=null,t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram,i=t.lastInput,e=t.findObjectAt(i.documentPoint,s=>{for(;s.panel!==null;){if(s.isActionable)return s;s=s.panel}return s});return e!==null&&e.isActionable?(this.xc=e,t.fc=t.findObjectAt(i.documentPoint,null,null),!0):!1}doMouseDown(){if(!this.isActive)this.canStart()&&this.doActivate();else{const i=this.diagram.lastInput,e=this.xc;if(e===null)return;i.targetObject=e,e.actionDown!==null&&e.actionDown(i,e)}}doMouseMove(){if(this.isActive){const i=this.diagram.lastInput,e=this.xc;if(e===null)return;i.targetObject=e,e.actionMove!==null&&e.actionMove(i,e)}}doMouseUp(){if(this.isActive){const i=this.diagram.lastInput,e=this.xc;if(e===null)return;i.targetObject=e,e.actionUp!==null&&e.actionUp(i,e),this.standardMouseClick(s=>{for(;s.panel!==null;){if(s.isActionable&&s===e)return s;s=s.panel}return s},s=>s===e)}this.stopTool()}doCancel(){const i=this.diagram.lastInput,e=this.xc;e!==null&&(i.targetObject=e,e.actionCancel!==null&&e.actionCancel(i,e),this.stopTool())}doStop(){this.xc=null}}class ClickCreatingTool extends Tool{Ll;oS;yc;rS;constructor(t){super(),this.name="ClickCreating",this.Ll=null,this.oS=!0,this.yc=!1,this.rS=new Point(0,0),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled||this.archetypeNodeData===null)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.lastInput.left||this.isBeyondDragSize())return!1;if(this.isDoubleClick){if(t.lastInput.clickCount===1&&(this.rS=t.lastInput.viewPoint.copy()),t.lastInput.clickCount!==2||this.isBeyondDragSize(this.rS))return!1}else if(t.lastInput.clickCount!==1)return!1;return!(t.currentTool!==this&&t.findPartAt(t.lastInput.documentPoint,!0)!==null)}doMouseUp(){const t=this.diagram;this.isActive&&this.insertPart(t.lastInput.documentPoint),this.stopTool()}insertPart(t){const i=this.diagram,e=this.archetypeNodeData;if(e===null)return null;let s=null;try{if(i.v("ChangingSelection",i.selection),this.startTransaction(this.name),e instanceof Part)e.Pe()&&(e.li(),s=e.copy(),s!==null&&i.add(s));else if(e!==null){const n=i.model.copyNodeData(e);Util.wt(n)&&(i.model.addNodeData(n),s=i.findPartForData(n))}if(s!==null){const n=Point.X(t.x,t.y);this.isGridSnapEnabled&&this.diagram.lS(s,t,n),s.location=n,i.allowSelect&&(i.clearSelection(!0),s.isSelected=!0),Point.s(n)}i.invalidateDocumentBounds(),this.transactionResult=this.name,i.v("PartCreated",s)}finally{this.stopTransaction(),i.v("ChangedSelection",i.selection)}return s}get archetypeNodeData(){return this.Ll}set archetypeNodeData(t){t!==null&&Util.i(t,"object",ClickCreatingTool,"archetypeNodeData"),this.Ll=t}get isDoubleClick(){return this.oS}set isDoubleClick(t){Util.i(t,"boolean",ClickCreatingTool,"isDoubleClick"),this.oS=t}get isGridSnapEnabled(){return this.yc}set isGridSnapEnabled(t){Util.i(t,"boolean",ClickCreatingTool,"isGridSnapEnabled"),this.yc=t}}class DragSelectingTool extends Tool{Vh;hS;Al;constructor(t){super(),this.name="DragSelecting",this.Vh=175,this.hS=!1,this.Al=new Part({layerName:"Tool",selectable:!1}).add(new Shape("Rectangle",{name:"SHAPE",fill:null,stroke:"magenta"}).theme("stroke","dragSelect")).li(),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(!t.allowSelect)return!1;const i=t.lastInput;return!(!i.left||t.currentTool!==this&&(!this.isBeyondDragSize()||i.timestamp-t.firstInput.timestamp{const e=i.diagram;e!==null&&e.Mi(root.document,"scroll",i.aS,!1),i.stopTool()},t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return!(!t.allowHorizontalScroll&&!t.allowVerticalScroll||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize())}doActivate(){const t=this.diagram;this.No?(t.lastInput.bubbles=!0,t.Vt(root.document,"scroll",this.aS,!1)):(t.currentCursor="move",t.isMouseCaptured=!0,this.Hw.a(t.position)),this.isActive=!0}doDeactivate(){const t=this.diagram;t.currentCursor="",t.isMouseCaptured=!1,this.isActive=!1}doCancel(){const t=this.diagram;t.position=this.Hw,t.isMouseCaptured=!1,this.stopTool()}doMouseMove(){this.GC()}doMouseUp(){this.GC(),this.stopTool()}GC(){const t=this.diagram;if(this.isActive&&t){if(this.No){t.lastInput.bubbles=!0;return}const i=t.position,e=t.firstInput.documentPoint,s=t.lastInput.documentPoint;let n=i.x+e.x-s.x,o=i.y+e.y-s.y;t.allowHorizontalScroll||(n=i.x),t.allowVerticalScroll||(o=i.y),t.position=this.YC.e(n,o)}}get bubbles(){return this.No}set bubbles(t){Util.i(t,"boolean",PanningTool,"bubbles"),this.No=t}get originalPosition(){return this.Hw}}class HTMLInfo{qw;Ww;cS;fS;constructor(t){this.qw=null,this.Ww=null,this.cS=null,this.fS=null,t&&Object.assign(this,t)}get mainElement(){return this.cS}set mainElement(t){this.cS=t}get show(){return this.qw}set show(t){this.qw!==t&&(t!==null&&Util.i(t,"function",HTMLInfo,"show"),this.qw=t)}get hide(){return this.Ww}set hide(t){this.Ww!==t&&(t!==null&&Util.i(t,"function",HTMLInfo,"hide"),this.Ww=t)}get valueFunction(){return this.fS}set valueFunction(t){this.fS=t}}class ContextMenuButtonInfo{hi;Sm;kc;constructor(t,i,e){this.hi=t,this.Sm=i,this.kc=e}}class ContextMenuTool extends Tool{uS;Jw;dS;gS;$w;Zw;Mm;constructor(t){super(),this.name="ContextMenu",this.uS=null,this.Jw=null,this.dS=null,this.gS=new Point,this.$w=null,this.Mm=!1;const i=this;this.Zw=()=>i.stopTool(),t&&Object.assign(this,t)}sF(){const t=new HTMLInfo;t.show=(r,l,h)=>h.showDefaultContextMenu(),t.hide=(r,l)=>l.hideDefaultContextMenu(),ContextMenuTool.bu=t;const i=this;this.Zw=()=>i.stopTool();const e=Util.en("div"),s=Util.en("div");e.style.cssText="top: 0px;z-index:10002;position: fixed;display: none;text-align: center;left: 25%;width: 50%;background-color: #F5F5F5;padding: 16px;border: 16px solid #444;border-radius: 10px;margin-top: 10px",s.style.cssText="z-index:10001;position: fixed;display: none;top: 0;left: 0;width: 100%;height: 100%;background-color: black;opacity: 0.8;";const n=Util.en("style");root.document.getElementsByTagName("head")[0].appendChild(n),n.sheet.insertRule(".goCXul { list-style: none; }",0),n.sheet.insertRule(".goCXli {font:700 1.5em Helvetica, Arial, sans-serif;position: relative;min-width: 60px; }",0),n.sheet.insertRule(".goCXa {color: #444;display: inline-block;padding: 4px;text-decoration: none;margin: 2px;border: 1px solid gray;border-radius: 10px; }",0);const o=this.diagram;o!==null&&(o.Vt(e,"contextmenu",ContextMenuTool.Yh,!1),o.Vt(e,"selectstart",ContextMenuTool.Yh,!1),o.Vt(s,"contextmenu",ContextMenuTool.Yh,!1)),e.className="goCXforeground",s.className="goCXbackground",root.document.body&&(root.document.body.appendChild(e),root.document.body.appendChild(s)),ContextMenuTool.Nm=e,ContextMenuTool.Cm=s,ContextMenuTool.mS=!0}static bu=null;static mS=!1;static Cm=null;static Nm=null;static Yh(t){return t.preventDefault(),!1}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return this.isBeyondDragSize()||!t.lastInput.right||t.lastInput.clickCount>1?!1:!!(t.lastInput.isTouchEvent&&this.defaultTouchContextMenu!==null||this.findObjectWithContextMenu()!==null)}doStart(){const t=this.diagram;this.gS.set(t.firstInput.documentPoint)}doStop(){this.hideContextMenu(),this.currentObject=null,this.Mm=!1}findObjectWithContextMenu(t){t===void 0&&(t=null);const i=this.diagram,e=i.lastInput;let s=null;if(t instanceof Diagram||(t instanceof GraphObject?s=t:s=i.findObjectAt(e.documentPoint,null,n=>!n.layer.isTemporary)),s!==null){let n=s;for(;n!==null;){if(n.contextMenu!==null)return n;n=n.panel}if(i.lastInput.isTouchEvent&&this.defaultTouchContextMenu)return s.part}else if(i.contextMenu!==null)return i;return null}doActivate(){}doMouseDown(){if(super.doMouseDown(),this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doMouseDown(),t.doDeactivate())}this.diagram.toolManager.mouseDownTools.has(this)&&this.doContextClick()}doMouseUp(){if(this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doCancel(),t.doDeactivate())}this.doContextClick()}doContextClick(){const t=this.diagram;if(!this.isActive)this.canStart()&&(this.openMenu(!0),this.isActive||this.stopTool());else{const i=this.currentContextMenu;if(i===null)return;let e=null;i instanceof HTMLInfo||(e=t.findObjectAt(t.lastInput.documentPoint,null,null),e!==null&&e.isContainedBy(i)&&this.standardMouseClick(null,null)),this.maybeStopTool(e)}}maybeStopTool(t){this.stopTool(),this.canStart()&&(this.diagram.currentTool=this,this.doMouseUp())}openMenu(t,i){if(i===void 0&&(i=null),this.Mm)return;this.Mm=!0,t&&this.standardMouseSelect();const e=this.standardMouseClick();if(this.Mm=!1,!e){this.isActive=!0;const s=ContextMenuTool.bu;if(i===null&&(i=this.findObjectWithContextMenu()),i!==null){const n=i.contextMenu;n!==null?(this.currentObject=i instanceof GraphObject?i:null,this.showContextMenu(n,this.currentObject)):s!==null&&this.showContextMenu(s,this.currentObject)}else s!==null&&this.showContextMenu(s,null);this.currentContextMenu instanceof Adornment&&!this.currentContextMenu.visible&&this.stopTool()}}doMouseMove(){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.doMouseMove(),this.isActive&&this.diagram.toolManager.doMouseMove()}showContextMenu(t,i){const e=this.diagram;if(t!==this.currentContextMenu&&this.hideContextMenu(),t instanceof Adornment){const s=t;s.layerName="Tool",s.selectable=!1,s.scale=1/e.scale,s.category=this.name,s.hasPlaceholder()&&(s.placeholder.scale=e.scale);const n=s.diagram;n!==null&&n!==e&&n.remove(s),e.add(s),i!==null?s.adornedObject=i:s.data=e.model,s.ensureBounds(),this.positionContextMenu(s,i)}else t instanceof HTMLInfo&&t.show(i,e,this);this.currentContextMenu=t}positionContextMenu(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom&&(n.y-=o.height+5/s.scale),n.ye.commandHandler.copySelection(),e=>e.commandHandler.canCopySelection())),i.add(new ContextMenuButtonInfo("Cut",e=>e.commandHandler.cutSelection(),e=>e.commandHandler.canCutSelection())),i.add(new ContextMenuButtonInfo("Delete",e=>e.commandHandler.deleteSelection(),e=>e.commandHandler.canDeleteSelection())),i.add(new ContextMenuButtonInfo("Paste",e=>e.commandHandler.pasteSelection(t.mouseDownPoint),e=>e.commandHandler.canPasteSelection(t.mouseDownPoint))),i.add(new ContextMenuButtonInfo("Select All",e=>e.commandHandler.selectAll(),e=>e.commandHandler.canSelectAll())),i.add(new ContextMenuButtonInfo("Undo",e=>e.commandHandler.undo(),e=>e.commandHandler.canUndo())),i.add(new ContextMenuButtonInfo("Redo",e=>e.commandHandler.redo(),e=>e.commandHandler.canRedo())),i.add(new ContextMenuButtonInfo("Scroll To Part",e=>e.commandHandler.scrollToPart(),e=>e.commandHandler.canScrollToPart())),i.add(new ContextMenuButtonInfo("Zoom To Fit",e=>e.commandHandler.zoomToFit(),e=>e.commandHandler.canZoomToFit())),i.add(new ContextMenuButtonInfo("Reset Zoom",e=>e.commandHandler.resetZoom(),e=>e.commandHandler.canResetZoom())),i.add(new ContextMenuButtonInfo("Group Selection",e=>e.commandHandler.groupSelection(),e=>e.commandHandler.canGroupSelection())),i.add(new ContextMenuButtonInfo("Ungroup Selection",e=>e.commandHandler.ungroupSelection(),e=>e.commandHandler.canUngroupSelection())),i.add(new ContextMenuButtonInfo("Edit Text",e=>e.commandHandler.editTextBlock(),e=>e.commandHandler.canEditTextBlock())),i}showDefaultContextMenu(){const t=this.diagram;this.$w===null&&(this.$w=this.nF()),ContextMenuTool.Nm.innerHTML="",ContextMenuTool.Cm.addEventListener("pointerdown",this.Zw,!1);const i=this,e=Util.en("ul");e.className="goCXul",ContextMenuTool.Nm.appendChild(e),e.innerHTML="";const s=this.$w.iterator;for(;s.next();){const n=s.value,o=n.Sm,r=n.kc;if(typeof o!="function"||typeof r=="function"&&!r(t))continue;const l=Util.en("li");l.className="goCXli";const h=Util.en("a");h.className="goCXa",h.href="#",h.Sm=n.Sm,h.addEventListener("pointerdown",function(a){return this.Sm(t),i.stopTool(),a.preventDefault(),!1},!1),h.textContent=n.hi,l.appendChild(h),e.appendChild(l)}ContextMenuTool.Nm.style.display="block",ContextMenuTool.Cm.style.display="block"}hideDefaultContextMenu(){if(this.currentContextMenu===null||this.currentContextMenu!==ContextMenuTool.bu)return;ContextMenuTool.Nm.style.display="none",ContextMenuTool.Cm.style.display="none";const t=this.diagram;t!==null&&t.Mi(ContextMenuTool.Cm,"pointerdown",this.Zw,!1),this.currentContextMenu=null}get currentContextMenu(){return this.uS}set currentContextMenu(t){this.uS=t,this.Jw=t instanceof Adornment?t.adornedPart:null}get defaultTouchContextMenu(){return ContextMenuTool.mS===!1&&ContextMenuTool.bu===null&&Diagram.isUsingDOM()&&this.sF(),ContextMenuTool.bu}set defaultTouchContextMenu(t){t===null&&(ContextMenuTool.mS=!0),ContextMenuTool.bu=t}get currentObject(){return this.dS}set currentObject(t){this.dS=t}get mouseDownPoint(){return this.gS}}var TextEditingAccept=(w=>(w[w.LostFocus=1]="LostFocus",w[w.MouseDown=2]="MouseDown",w[w.Tab=3]="Tab",w[w.Enter=4]="Enter",w))(TextEditingAccept||{}),TextEditingStarting=(w=>(w[w.SingleClick=1]="SingleClick",w[w.SingleClickSelected=2]="SingleClickSelected",w[w.DoubleClick=3]="DoubleClick",w))(TextEditingStarting||{}),TextEditingState=(w=>(w[w.None=1]="None",w[w.Active=2]="Active",w[w.Editing=3]="Editing",w[w.Validating=4]="Validating",w[w.Invalid=5]="Invalid",w[w.Validated=6]="Validated",w))(TextEditingState||{});class TextEditingTool extends Tool{Se;pS;yS;Tl;Yt;wS;xS;bS;Qw;_w;constructor(t){super(),this.name="TextEditing",this.Se=new TextBlock,this.pS=null,this.yS=2,this.Tl=null,this.Yt=1,this.wS=1,this.xS=!0,this.bS=null,this.Qw=new HTMLInfo,this._w=null,this.oF(this.Qw),t&&Object.assign(this,t)}static LostFocus=1;static MouseDown=2;static Tab=3;static Enter=4;static SingleClick=1;static SingleClickSelected=2;static DoubleClick=3;static StateNone=1;static StateActive=2;static StateEditing=3;static StateValidating=4;static StateInvalid=5;static StateValidated=6;oF(t){if(!Diagram.isUsingDOM())return;const i=Util.en("textarea");this._w=i;const e=this;i.addEventListener("input",function(s){if(e.textBlock===null)return;const n=e.measureTemporaryTextBlock(this.value),o=this.textScale;this.style.width=20+Math.max(e.textBlock.measuredBounds.width,n.measuredBounds.width)*o+"px",this.rows=Math.max(e.textBlock.lineCount,n.lineCount)},!1),i.addEventListener("keydown",function(s){if(s.isComposing||e.textBlock===null)return;const n=s.key;if(n==="Enter"){e.textBlock.isMultiline===!1&&s.preventDefault(),e.acceptText(4);return}else if(n==="Tab"){e.acceptText(3),s.preventDefault();return}else n==="Escape"&&(e.doCancel(),e.diagram!==null&&e.diagram.doFocus())},!1),i.addEventListener("focus",function(s){e.rF(s)},!1),i.addEventListener("blur",function(s){e.lF(s)},!1),t.valueFunction=()=>i.value,t.mainElement=i,t.show=(s,n,o)=>{if(!(s instanceof TextBlock&&o instanceof TextEditingTool))return;if(o.state===5){i.style.border="3px solid red",i.focus();return}const r=s.getDocumentPoint(Spot.Center),l=n.position,h=n.scale;let a=s.getDocumentScale()*h;a{s.div.removeChild(i)}}get textBlock(){return this.pS}set textBlock(t){this.pS=t}get currentTextEditor(){return this.bS}set currentTextEditor(t){this.bS=t}get defaultTextEditor(){return this.Qw}set defaultTextEditor(t){this.Qw=t}get starting(){return this.yS}set starting(t){this.yS=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t===null||t.isReadOnly||TextEditingTool.Pc&&TextEditingTool.Pc!==this&&(TextEditingTool.Pc.acceptText(2),TextEditingTool.Pc&&TextEditingTool.Pc!==this)||!t.lastInput.left||this.isBeyondDragSize())return!1;const i=t.lastInput.documentPoint,e=t.findObjectAt(i);if(e===null||!(e instanceof TextBlock)||!e.editable||!e.part.canEdit())return!1;const s=e.part;return!(s===null||this.starting===2&&!s.isSelected||this.starting===3&&t.lastInput.clickCount<2)}doStart(){TextEditingTool.Pc=this,this.textBlock!==null&&this.doActivate()}doActivate(){if(this.isActive)return;const t=this.diagram;if(t===null)return;let i=this.textBlock;if(i===null&&(i=t.findObjectAt(t.lastInput.documentPoint)),i===null||!(i instanceof TextBlock)||(this.textBlock=i,i.part===null))return;t.animationManager.stopAnimation(),this.isActive=!0,this.Yt=2;let s=this.defaultTextEditor;i.textEditor!==null&&(s=i.textEditor),this.Se=this.textBlock.copy();const n=new Rect(this.textBlock.getDocumentPoint(Spot.TopLeft),this.textBlock.getDocumentPoint(Spot.BottomRight));t.scrollToRect(n),s.show(i,t,this),this.currentTextEditor=s}doCancel(){this.stopTool()}doMouseUp(){this.canStart()&&this.doActivate()}doMouseDown(){this.isActive&&this.acceptText(2)}acceptText(t){switch(t){case 2:this.Yt===6?this.currentTextEditor instanceof HTMLElement&&this.currentTextEditor.focus():(this.Yt===2||this.Yt===5||this.Yt===3)&&(this.Yt=4,this.jC());break;case 1:case 4:case 3:if(t===4&&this.textBlock.isMultiline===!0)return;(this.Yt===2||this.Yt===5||this.Yt===3)&&(this.Yt=4,this.jC());break}}jC(){const t=this.textBlock,i=this.diagram,e=this.currentTextEditor;if(t!==null&&e!==null){const s=t.text;let n="";if(e.valueFunction!==null&&(n=e.valueFunction()),!this.isValidText(t,s,n)){this.Yt=5,this.doError(s,n);return}this.startTransaction(this.name),this.Yt=6,this.transactionResult=this.name,t.text=n,this.doSuccess(s,n),i!==null&&i.v("TextEdited",t,s),this.stopTransaction(),this.stopTool(),i!==null&&i.doFocus()}}doError(t,i){const e=this.textBlock;e.errorFunction!==null&&e.errorFunction(this,t,i);const s=this.currentTextEditor;s&&s.show(e,this.diagram,this)}doSuccess(t,i){const e=this.textBlock;e.textEdited!==null&&e.textEdited(e,t,i)}doDeactivate(){const t=this.diagram;t!==null&&(this.Yt=1,this.currentTextEditor!==null&&this.currentTextEditor.hide(t,this),this.textBlock=null,this.isActive=!1)}doStop(){TextEditingTool.Pc=null}rF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this._w;this.Yt===2&&(this.Yt=3),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}lF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this._w;typeof i.focus=="function"&&i.focus(),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}isValidText(t,i,e){const s=this.textValidation;if(s!==null&&!s(t,i,e))return!1;const n=t.textValidation;return!(n!==null&&!n(t,i,e))}get textValidation(){return this.Tl}set textValidation(t){t!==null&&Util.i(t,"function",TextEditingTool,"textValidation"),this.Tl=t}get minimumEditorScale(){return this.wS}set minimumEditorScale(t){t!==null&&Util.i(t,"number",TextEditingTool,"minimumEditorScale"),this.wS=t}get selectsTextOnActivate(){return this.xS}set selectsTextOnActivate(t){t!==null&&Util.i(t,"boolean",TextEditingTool,"selectsTextOnActivate"),this.xS=t}get state(){return this.Yt}set state(t){this.Yt!==t&&(this.Yt=t)}measureTemporaryTextBlock(t){const i=this.Se;return i.text=t,i.ut(this.textBlock.Dl,1/0),i}static Pc=null}var AnimationStyle=(w=>(w[w.Default=1]="Default",w[w.AnimateLocations=2]="AnimateLocations",w[w.None=3]="None",w))(AnimationStyle||{});class AnimationManager{p;Ni;Oi;kr;Gn;Ao;kS;PS;Lm;wi;Sc;un;Am;Gh;tx;Tm;ix;Mc;wu;Dm;constructor(t){this.p=Diagram.mm(),this.Ni=!1,this.Lm=!1,this.wi=!1,this.Sc=!1,this.ix=!0,this.Mc=1,this.wu=!1,this.Oi=!0,this.kr=!0,this.Ao=600,this.kS=!1,this.PS=!1,this.Gn=new GSet,this.un=new Animation,this.Am=new Animation,this.un.ds=this,this.Gh=new GSet,this.tx=new GSet,this.Tm=new GSet,this.Dm=new GSet,t&&Object.assign(this,t)}To(t){this.p=t}rE(){return this.p}canStart(t){return!0}Fl(t){return!this.Oi||!this.canStart(t)?!1:(this.Gn.add(t),this.defaultAnimation.isAnimating&&this.stopAnimation(),this.p.Ci(),this.wi=!0,!0)}getBundleAnimation(){return this.Am}SS(){if(!this.Oi||(this.Am.ce.count>0&&this.Am.start(),!this.wi))return;const t=this.un,i=this.p,e=this.Gn.has("Model");if(e&&(this.Sc=!0,this.Mc===1?(t.isViewportUnconstrained=!0,t.ce.clear(),t.add(i,"position",i.position.copy().offset(0,-200),i.position),t.add(i,"opacity",0,1)):this.Mc===3&&t.ce.clear(),this.Mc===2&&i.ex.equals(i.at)?this.ix=!0:this.ix=!1,i.v("InitialAnimationStarting",this)),e&&!this.kr||t.ce.count===0){this.Gn.clear(),this.wi=!1,t.ce.clear(),t.sx(i),this.Sc=!1,i.C();return}this.Gn.clear(),i.Pr=!1;const s=t.ce.get(i);i.autoScale!==1&&s!==null&&(delete s.si.scale,delete s.gs.scale);const n=this;root.requestAnimationFrame(()=>{n.wi===!1||t.Ni||(i.getRenderingHint("temporaryPixelRatio")&&i.Uw(),i.MS(),n.wi=!1,t.start(),t.Ni&&(n.ku(),i.invalidateDocumentBounds(),t.HC(0),i.yr(!0),n.Pu(),i.v("AnimationStarting",n)))})}NS(){return this.Gn.has("Trigger")&&this.Gn.count===1}qC(t,i,e,s){this.isTicking||this.NS()||t instanceof Link&&(t.fromNode!==null||t.toNode!==null)||this.un.add(t,"position",i,e,s)}nx(t){return this.un.nx(t)}CS(t){return this.un.CS(t)}hF(t){const i=this.Gh,e=this;function s(){if(e.Tm.count>0&&(i.addAll(e.Tm),e.Tm.clear(),e.Ni=!0),e.Ni===!1||i.count===0)return;e.tx.addAll(i);const n=e.tx.iterator;for(;n.next();){const o=n.value;o.Ni!==!1&&(o.aF()?o.WC(!1):o.Nc=!0)}if(e.tx.clear(),e.Ni===!1){root.requestAnimationFrame(s);return}e.ku(),e.p.yr(),e.Pu(),root.requestAnimationFrame(s)}this.Ni?this.cF(t):(this.Ni=!0,i.add(t),root.requestAnimationFrame(()=>s()))}cF(t){this.Tm.add(t)}fF(){const t=this.Gh.iterator;for(;t.next();)t.value.Nc=!1}ku(){if(this.Lm)return;const t=this.p;this.kS=t.skipsUndoManager,this.PS=t.fe,t.skipsUndoManager=!0,t.fe=!0,this.Lm=!0}Pu(){const t=this.p;t.skipsUndoManager=this.kS,t.fe=this.PS,this.Lm=!1}stopAnimation(t){const i=this.un;if(this.wi===!0&&(this.wi=!1,this.Sc=!1,this.Gn.clear(),i.uF()&&this.p.requestUpdate()),!this.Ni){i.ce.clear(),i.sx(this.p);return}if(i.Su(!0),i.sx(null),t===!0){const e=this.Gh.toArray();for(let s=0;s{!i.isAnimating&&i.runCount===1/0&&i.start()})}get duration(){return this.Ao}set duration(t){Util.i(t,"number",AnimationManager,"duration"),t<1&&Util._(t,">= 1",AnimationManager,"duration"),this.Ao=t}get isAnimating(){return this.Ni}get isTicking(){return this.Lm}get isInitial(){return this.kr}set isInitial(t){Util.i(t,"boolean",AnimationManager,"isInitial"),this.kr=t}get defaultAnimation(){return this.un}get activeAnimations(){return this.Gh}get initialAnimationStyle(){return this.Mc}set initialAnimationStyle(t){this.Mc=t}static ox=new GMap;static defineAnimationEffect(t,i){AnimationManager.ox.set(t,i)}static TS(t,i,e,s,n){t===null&&(t=[0,0,0,0]),i===null&&(i=[0,0,0,0]);let o=t[0],r=t[1];const l=t[2],h=t[3];let a=i[0],c=i[1];const f=i[2],u=i[3];l===0||l===100?(o=a,r=c):(f===0||f===100)&&(a=o,c=r),Math.abs(a-o)>180&&(a>o?o+=360:a+=360);const d=n(e,o,a-o,s)%360,m=n(e,r,c-r,s),g=n(e,l,f-l,s),p=n(e,h,u-h,s);return"hsla("+d+", "+m+"%, "+g+"%, "+p+")"}static{const t=AnimationManager.ox,i=(e,s,n,o,r,l)=>{e.position=new Point(o(r,s.x,n.x-s.x,l),o(r,s.y,n.y-s.y,l))};t.set("position:diagram",i),t.set("position",i),t.set("position:part",(e,s,n,o,r,l)=>{r{r{r{const h=e.actualBounds,a=n.actualBounds,c=a.x+a.width/2-h.width/2,f=a.y+a.height/2-h.height/2;r{e.desiredSize=new Size(o(r,s.width,n.width-s.width,l),o(r,s.height,n.height-s.height,l))}),t.set("width",(e,s,n,o,r,l)=>{e.width=o(r,s,n-s,l)}),t.set("height",(e,s,n,o,r,l)=>{e.height=o(r,s,n-s,l)}),t.set("fill",(e,s,n,o,r,l)=>{e.fill=AnimationManager.TS(s,n,r,l,o)}),t.set("stroke",(e,s,n,o,r,l)=>{e.stroke=AnimationManager.TS(s,n,r,l,o)}),t.set("strokeWidth",(e,s,n,o,r,l)=>{e.strokeWidth=o(r,s,n-s,l)}),t.set("strokeDashOffset",(e,s,n,o,r,l)=>{e.strokeDashOffset=o(r,s,n-s,l)}),t.set("background",(e,s,n,o,r,l)=>{e.background=AnimationManager.TS(s,n,r,l,o)}),t.set("opacity",(e,s,n,o,r,l)=>{e.opacity=o(r,s,n-s,l)}),t.set("scale",(e,s,n,o,r,l)=>{e.scale=o(r,s,n-s,l)}),t.set("angle",(e,s,n,o,r,l)=>{e.angle=o(r,s,n-s,l)})}static Default=1;static AnimateLocations=2;static None=3}class Animation{rx;Fm;Ni;Mu;Ao;ms;QC;Ac;ce;lx;si;jn;Nu;Tc;hx;ax;Nc;DS;cx;ds;p;FS;RS;vS;constructor(t){this.p=null,this.ds=null,this.DS=null,this.cx=null,this.FS=!1,this.Ni=!1,this.Nc=!1,this.si=0,this.jn=0,this.rx=Animation.EaseInOutQuad,this.Fm=Animation.EaseInOutQuad,this.Nu=!1,this.Tc=!1,this.hx=1,this.ax=0,this.Ao=NaN,this.ms=NaN,this.RS=0,this.Mu=null,this.QC=Point.Po,this.ce=new GMap,this.lx=new GMap,this.Ac=new GSet,this.vS=1,t&&Object.assign(this,t)}suspend(){this.Nc=!0}advanceTo(t,i){i&&(this.Nc=!1),this.Nu&&t>=this.ms&&(this.Tc=!0,t=t-this.ms),this.RS=t,this.WC(!0),this.ds.ku(),this.p.yr(),this.ds.Pu(),this.p.redraw()}sx(t){if(this.lx.clear(),this.Tc=!1,this.ax=0,this.ms=NaN,this.Ac.count>0&&this.Ac.clear(),t!==null){const i=t.links;for(;i.next();)i.value.Sr=null}}uF(){return this.ce.count>0}start(){if(this.ce.count===0)return this;if(this.Ni)return this;let t=this.p;const i=this.ce.iterator;for(;i.next();){const s=i.key;t===null&&(s instanceof Diagram?t=s:s instanceof GraphObject&&(t=s.diagram))}if(t!==null)this.p=t,this.ds=t.animationManager;else return this;const e=this.ds;return e.isEnabled===!1?this:(this.ms=isNaN(this.Ao)?e.duration:this.Ao,this.Fm=this.rx,e.Sc&&e.Mc===1&&this===e.defaultAnimation&&(this.Fm=Animation.EaseOutExpo,this.ms=isNaN(this.Ao)?e.duration===600?900:e.duration:this.Ao),this.vS=t.scrollMode,this.isViewportUnconstrained&&(t.jh=2),e.ku(),this.Ac.each(s=>{s.data=null,t.add(s)}),e.Pu(),this.Ni=!0,this.si=+new Date,this.jn=this.si+this.ms,e.hF(this),this)}addTemporaryPart(t,i){return t.Pe()?(this.Ac.add(t),this.p=i,this):this}add(t,i,e,s,n){if(this.p===null&&(t instanceof Diagram?this.p=t:t instanceof GraphObject&&t.diagram!==null&&(this.p=t.diagram)),t instanceof Part){if(!t.isAnimated)return this;i==="position"&&(i="position:part")}return this.LS(t,i,e,s,n),this}LS(t,i,e,s,n){const o=this.ce;let r,l,h;if(t instanceof Diagram&&i==="position"&&(i="position:diagram"),(i==="fill"||i==="stroke"||i==="background")&&(Brush.Do(e),Brush.OS(),e=[Brush.Ii.n0,Brush.Ii.n1,Brush.Ii.n2,Brush.Ii.n3],Brush.Do(s),Brush.OS(),s=[Brush.Ii.n0,Brush.Ii.n1,Brush.Ii.n2,Brush.Ii.n3]),o.has(t))r=o.get(t),l=r.si,h=r.gs,l[i]===void 0&&(l[i]=this.Cu(e)),h[i]=this.Cu(s);else{if(i==="position"&&e.equalsApprox(s))return;l={},h={},l[i]=this.Cu(e),h[i]=this.Cu(s),r=new AnimationState(l,h,n),o.set(t,r)}const a=l[i];a instanceof Point&&!a.isReal()&&a.a(this.QC),n&&i.indexOf("position:")===0&&t instanceof Part?r.fx.location=this.Cu(t.location):n&&(r.fx[i]=this.Cu(e))}Cu(t){return t instanceof Point||t instanceof Size?t.copy():t}dF(t){const i=this.ce;if(i.has(t)){const e=i.get(t);e.ux=!0}}nx(t){if(!this.Ni)return!1;const i=this.ce.get(t);return i!==null&&i.ux}CS(t){if(!this.Ni)return!1;const i=this.ce.get(t);return i!==null&&!!(i.si.position||i.si["position:part"]||i.si.location)}aF(){if(this.Ac.count>0)return!0;const t=this.ce.iterator;for(;t.next();){const i=t.key;if(i instanceof GraphObject&&i.diagram!==null||i instanceof Diagram)return!0}return!1}WC(t){if(this.Nc&&!t)return;const i=this.ds;if(this.Ni===!1)return;const e=+new Date;let s=e>this.jn?this.ms:e-this.si;t&&(s=this.RS,sthis.jn&&(this.Nu&&!this.Tc?(this.si=+new Date,this.jn=this.si+this.ms,this.Tc=!0):this.Su(!1))}HC(t){const i=this.ms,e=this.ce.iterator,s=this.Tc;for(;e.next();){const n=e.key;if(n instanceof GraphObject&&n.diagram===null)continue;const o=e.value,r=s?o.gs:o.si,l=s?o.si:o.gs,h=AnimationManager.ox;for(const a in l)a==="position"&&(l["position:placeholder"]||l["position:nodeCollapse"])||h.get(a)!==null&&h.get(a)(n,r[a],l[a],this.Fm,t,i,this)}}stop(){return this.Ni?(this.Su(!0),this):this}Su(t){if(this.cx!==null&&this.cx.gF(this.DS),!this.Ni)return;const i=this.p,e=this.ds;e.Sc=!1,this.Ni=!1,this.Nc=!1,e.ku();const s=this.ce,n=this.Ac.iterator;for(;n.next();)i.remove(n.value);const o=this.Nu,r=s.iterator,l=AnimationManager.ox;for(;r.next();){const a=r.key,c=r.value,f=o?c.gs:c.si,u=o?c.si:c.gs,d=c.fx;for(const m in u)if(l.get(m)!==null){let g=m;c.gx&&(g==="position:nodeCollapse"||g==="position:placeholder")&&(g="position"),l.get(g)(a,f[m],d[m]!==void 0?d[m]:c.gx?f[m]:u[m],this.Fm,this.ms,this.ms,this)}c.gx&&d.location!==void 0&&a instanceof Part&&(a.location=d.location),c.ux&&a instanceof Part&&a.Ei(!1)}this.ax++;const h=!t&&this.hx>this.ax;if(!h&&(this===e.Am||this===e.defaultAnimation)&&this.ce.clear(),i.mx.clear(),i.yP(!1),i.invalidateDocumentBounds(),i.C(),i.yr(!0),e.defaultAnimation===this){const a=e.Dm.iterator;for(;a.next();)a.value.mF();e.Dm.clear()}if(i.yr(!0),this.isViewportUnconstrained&&(i.scrollMode=this.vS),e.Pu(),h){this.Tc=!1,this.start();return}this.sx(null),i._C(),e.Su(this),this.Mu&&this.Mu(this),i.requestUpdate()}Cc(t,i){const e=i.actualBounds;let s=null;if(i instanceof Group&&(s=i.placeholder),s!==null&&s.visible){const n=s.getDocumentPoint(Spot.TopLeft),o=s.padding;n.x+=o.left,n.y+=o.top,this.add(t,"position",n,t.position,!1)}else this.add(t,"position",new Point(e.x+e.width/2,e.y+e.height/2),t.position,!1);this.add(t,"scale",.01,t.scale,!1),t instanceof Group&&this.pF(t,i)}pF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Cc(s,i)}}Lc(t,i){if(!t.isVisible())return;let e=null;if(i instanceof Group&&(e=i.placeholder),e!==null&&e.visible){const s=e.getDocumentPoint(Spot.TopLeft),n=e.padding;s.x+=n.left,s.y+=n.top,this.add(t,"position:placeholder",t.position,s,!0)}else this.add(t,"position:nodeCollapse",t.position,i,!0);this.add(t,"scale",t.scale,.01,!0),this.dF(t),t instanceof Group&&this.yF(t,i)}yF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Lc(s,i)}}get duration(){return this.Ao}set duration(t){Util.i(t,"number",Animation,"duration"),t<1&&Util._(t,">= 1",Animation,"duration"),this.Ao=t}get reversible(){return this.Nu}set reversible(t){this.Nu=t}get runCount(){return this.hx}set runCount(t){t>0?this.hx=t:Util.o("Animation.runCount value must be a positive integer.")}get finished(){return this.Mu}set finished(t){this.Mu!==t&&(t!==null&&Util.i(t,"function",Animation,"finished"),this.Mu=t)}get easing(){return this.rx}set easing(t){this.rx=t}get isViewportUnconstrained(){return this.FS}set isViewportUnconstrained(t){this.FS=t}get isAnimating(){return this.Ni}getTemporaryState(t){let i=this.lx.get(t);return i===null&&(i={},this.lx.set(t,i)),i}static EaseLinear=(t,i,e,s)=>e*t/s+i;static EaseInOutQuad=(t,i,e,s)=>(t/=s/2,t<1?e/2*t*t+i:-e/2*(--t*(t-2)-1)+i);static EaseInQuad=(t,i,e,s)=>e*(t/=s)*t+i;static EaseOutQuad=(t,i,e,s)=>-e*(t/=s)*(t-2)+i;static EaseInExpo=(t,i,e,s)=>t===0?i:e*Math.pow(2,10*(t/s-1))+i;static EaseOutExpo=(t,i,e,s)=>t===s?i+e:e*(-Math.pow(2,-10*t/s)+1)+i}class AnimationState{si;gs;fx;gx;ux;constructor(t,i,e){this.si=t,this.gs=i,this.fx={},this.gx=e,this.ux=!1}}var TriggerStart=(w=>(w[w.Default=1]="Default",w[w.Immediate=2]="Immediate",w[w.Bundled=3]="Bundled",w))(TriggerStart||{});class AnimationTrigger{ke;an;Lu;Dc;constructor(t,i,e){this.ke=null,this.an=t,this.Lu=e||1,this.Dc=null,i!==void 0&&(this.Dc=i,e===void 0&&(this.Lu=2))}copy(){const t=new AnimationTrigger(this.an);t.Lu=this.Lu;const i=this.Dc;if(i!==null){const e={};i.duration!==void 0&&(e.duration=i.duration),i.finished!==void 0&&(e.finished=i.finished),i.easing!==void 0&&(e.easing=i.easing),t.Dc=e}return t}get propertyName(){return this.an}set propertyName(t){this.an=t}get animationSettings(){return this.Dc}set animationSettings(t){this.Dc=t}wF(t){const i=this.Dc;i!==null&&(i.duration&&(t.duration=i.duration),i.finished&&(t.finished=i.finished),i.easing&&(t.easing=i.easing))}get startCondition(){return this.Lu}set startCondition(t){this.Lu=t}static Default=1;static Immediate=2;static Bundled=3}class Layer{p;Mt;Wt;Mr;Rl;vl;Ol;Il;El;Bl;Ul;Vl;zl;Xl;Kl;Yl;kc;Gl;px;Rm;Au;At;constructor(t){GSet.Yi(this),this.p=null,this.At=new List,this.Mt="",this.Wt=1,this.Mr=!1,this.Rl=!0,this.vl=!0,this.Ol=!0,this.Il=!0,this.El=!0,this.Bl=!0,this.Ul=!0,this.Vl=!0,this.zl=!0,this.Xl=!0,this.Kl=!0,this.Yl=!0,this.kc=!0,this.Gl=!0,this.px=!0,this.Rm=!1,this.Au=[],t&&Object.assign(this,t)}xF(){const t=this.At;for(let i=0;i0&&(h+=e+" Parts "),s>0&&(h+=s+" Nodes "),n>0&&(h+=n+" Groups "),o>0&&(h+=o+" Links "),r>0&&(h+=r+" Adornments "),t>1){const a=this.At.iterator;for(;a.next();){const c=a.value;h+=` + `+c.toString();const f=c.data;f!==null&&GSet.as(f)&&(h+=" #"+GSet.as(f)),c instanceof Node?h+=" "+Util.toString(f):c instanceof Link&&(h+=" "+Util.toString(c.fromNode)+" "+Util.toString(c.toNode))}}return i+" "+this.At.count+": "+h}findObjectAt(t,i,e){if(i===void 0&&(i=null),e===void 0&&(e=null),this.Gl===!1)return null;let s=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(s=!0);const n=Point.l(),o=this.At.r,r=o.length;for(let l=r;l--;){const h=o[l];if(s===!0&&h.Nl()===!1||!h.isVisible())continue;n.a(t),n.Ie(h.Es);let a=h.tL(n,i,e);if(a!==null&&(i!==null&&(a=i(a)),a!==null&&(e===null||e(a))))return Point.s(n),a}return Point.s(n),null}findObjectsAt(t,i,e,s){if(i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Gl===!1)return s;let n=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(n=!0);const o=Point.l(),r=this.At.r,l=r.length;for(let h=l;h--;){const a=r[h];if(n===!0&&a.Nl()===!1||!a.isVisible())continue;o.a(t),o.Ie(a.Es);let c=a;a.iL(o,i,e,s)&&(i!==null&&(c=i(c)),c!==null&&(e===null||e(c))&&s.add(c))}return Point.s(o),s}findObjectsIn(t,i,e,s,n){if(i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Gl===!1)return n;let o=!1;this.diagram!==null&&this.diagram.viewportBounds.containsRect(t)&&(o=!0);const r=this.At.r,l=r.length;for(let h=l;h--;){const a=r[h];if(o===!0&&a.Nl()===!1||!a.isVisible())continue;let c=a;a.vm(t,i,e,s,n)&&(i!==null&&(c=i(c)),c!==null&&(e===null||e(c))&&n.add(c))}return n}NP(t,i,e,s,n,o,r){if(this.Gl===!1)return n;const l=this.At.r,h=l.length;for(let a=h;a--;){const c=l[a];if(r===!0&&c.Nl()===!1||!o(c)||!c.isVisible())continue;let f=c;c.vm(t,i,e,s,n)&&(i!==null&&(f=i(f)),f!==null&&(e===null||e(f))&&n.add(f))}return n}findObjectsNear(t,i,e,s,n,o){if(e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Gl===!1)return o;let r=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(r=!0);const l=Point.l(),h=Point.l(),a=this.At.r,c=a.length;for(let f=c;f--;){const u=a[f];if(r===!0&&u.Nl()===!1||!u.isVisible())continue;l.a(t),l.Ie(u.Es),h.e(t.x+i,t.y),h.Ie(u.Es);let d=u;u.eL(l,h,e,s,n,o)&&(e!==null&&(d=e(d)),d!==null&&(s===null||s(d))&&o.add(d))}return Point.s(l),Point.s(h),o}ES(){return this.At.r}Bs(t,i){if(!this.visible)return;const e=this.At.r,s=e.length;if(s===0)return;const n=Util.nt(),o=Util.nt();for(let r=0;r0&&o.push(l))}for(let r=0;re.Im||a.height*n>e.Im?i.Gi(t,e):this.SF(t,i),c&&(t.restore(),t.clearContextCache(!0))}SF(t,i){const e=i.actualBounds,s=i.naturalBounds;if(e.width===0||e.height===0||isNaN(e.x)||isNaN(e.y)||!i.isVisible())return;const n=i.D;if(i.background===null){i.dn(t,"rgba(0,0,0,0.3)",!0,!1,s,e),t.fillRect(e.x,e.y,e.width,e.height);return}if(t.transform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),i.dn(t,i.background,!0,!1,s,e),t.fillRect(0,0,s.width/2,s.height/2),!n.Ok()){const o=1/(n.m11*n.m22-n.m12*n.m21);t.transform(n.m22*o,-n.m12*o,-n.m21*o,n.m11*o,o*(n.m21*n.dy-n.m22*n.dx),o*(n.m12*n.dx-n.m11*n.dy))}}PF(t,i,e,s){const n=2/s,o=4/s;for(let r=0;r=s.count)t=s.count;else if(s.elt(t)===i)return-1;s.insertAt(t,i),i.Em(e);const n=this.diagram;return n!==null&&(e?n.C():n.qh(i)),this.yx(t,i),t}te(t,i,e){if(!e&&i.layer!==this&&i.layer!==null)return i.layer.te(t,i,e);const s=this.At;if(t<0||t>=s.length){if(t=s.indexOf(i),t<0)return-1}else if(s.elt(t)!==i&&(t=s.indexOf(i),t<0))return-1;i.Bm(e),s.removeAt(t);const n=this.diagram;return n!==null&&(e?n.C():n.te(i)),i.IS(null),t}yx(t,i){t=this.MF(t,i),i instanceof Group&&this.NF(t,i),i.svg!==null&&i.svg.remove()}MF(t,i){const e=i.zOrder;if(isNaN(e))return t;const s=this.At,n=s.count;if(n<=1)return t;if(t<0&&(t=s.indexOf(i)),t<0)return-1;let o=t-1,r=NaN;for(;o>=0&&(r=s.elt(o).zOrder,!!isNaN(r));)o--;let l=t+1,h=NaN;for(;le)for(;;){if(o===-1||r<=e)return o++,o===t?t:(s.removeAt(t),s.insertAt(o,i),o);for(r=NaN;--o>=0&&(r=s.elt(o).zOrder,!!isNaN(r)););}else if(!isNaN(h)&&h=e)return l--,l===t?t:(s.removeAt(t),s.insertAt(l,i),l);for(h=NaN;++l=0)||e<0&&r.containingGroup===i&&(e=o,t>=0))break}if(!(e<0)&&e1)&&Util._(t,"0 <= value <= 1",Layer,"opacity"),this.Wt=t;const e=this.diagram;e!==null&&e.C(),this.t("opacity",i,t)}}get isViewportAligned(){return this.Rm}set isViewportAligned(t){const i=this.Rm;i!==t&&(this.Rm=t,this.diagram&&(this.nL(),this.diagram.C()),this.t("isViewportAligned",i,t),t&&(this.isInDocumentBounds=!1))}nL(){if(!this.Rm)return;const t=this.diagram,i=this.At.r,e=i.length,s=t.kt,n=t.Pt;for(let o=0;o(w[w.None=1]="None",w[w.Uniform=2]="Uniform",w[w.UniformToFill=3]="UniformToFill",w))(AutoScale||{}),CycleMode=(w=>(w[w.All=1]="All",w[w.NotDirected=2]="NotDirected",w[w.NotDirectedFast=3]="NotDirectedFast",w[w.NotUndirected=4]="NotUndirected",w[w.DestinationTree=5]="DestinationTree",w[w.SourceTree=6]="SourceTree",w))(CycleMode||{}),ScrollMode=(w=>(w[w.Document=1]="Document",w[w.Infinite=2]="Infinite",w))(ScrollMode||{}),CollapsePolicy=(w=>(w[w.TreeParent=1]="TreeParent",w[w.AllParents=2]="AllParents",w[w.AnyParents=3]="AnyParents",w))(CollapsePolicy||{});class Diagram{ds;di;VS;wx;Nr;Fu;xx;bx;kx;Px;Sx;Mx;Fc;jh;Nx;Cx;Lx;jl;Rc;Cr;Um;Ax;Tx;Ru;Hn;Lr;Wh;Fo;Vm;vc;zm;Oc;vu;Ar;qn;zS;XS;Dx;Fx;KS;Rx;YS;GS;jS;vx;Xm;Tr;Dr;Fr;Rr;vr;Or;Ox;Ir;Ix;Er;Br;Ur;Vr;Ex;HS;Ro;qS;Bx;Ux;WS;Si;JS;$S;ZS;vs;vo;Oi;Vx;Rl;vl;zx;Xx;Ol;Il;El;Kx;Bl;Ul;Vl;zl;Xl;Kl;Yl;Yx;Gx;QS;Ou;Iu;jx;Hx;qx;Wx;Km;Jx;$x;Zx;$t;_S;Qx;tM;Eu;gn;Wn;ie;Jn;oL;Hl;iM;eM;Ym;_x;Bu;Gm;tb;zr;ql;Jh;sM;nM;jm;ib;eb;ts;Hm;qm;Uu;Wl;Ic;Wm;Xr;$h;oM;Jm;Ht;D;Ue;Pr;Bi;ps;rM;Jl;Kr;bl;Yr;Zh;Ec;lM;Vu;Qh;zu;Gt;$l;at;et;Xu;kt;Pt;dt;Bc;Bw;sb;_h;Uc;nb;ob;rb;AF;TF;Ui;Pl;Im;$m;hM;aM;rL;Zm;DF;FF;RF;lb;vF;OF;IF;ta;lL;Zl;ia;ea;sa;na;yu;Yh;Zt;Tt;Vc;Wk;Jk;fc;Wt;static hb=null;static hL=new GMap;static cM;static fM=null;pu;ab;cb;fb;ub;db;Qm;uM;_m;t0;i0;ex;dM;gb;zc;constructor(t,i){if(Diagram.uw||(Diagram.Ik(),Diagram.uw=!0),GSet.Yi(this),Diagram.aL(this),this.Ht=!0,this.Tt=null,this.kt=0,this.Pt=0,this.dt=null,Diagram.isUsingDOM()){const s=this,n=()=>{s.Mi(root.document,"DOMContentLoaded",n,!1),s.setRTL()};root.document.body!==null?this.setRTL():s.Vt(root.document,"DOMContentLoaded",n,!1)}this.Bc=null,Diagram.gM("Model",PartManager);const e=this;return this.JS=s=>e.partManager.doModelDataChanged(s),this.$S=s=>e.partManager.doModelChanged(s),this.nb=null,this.ob=null,this.cL(),this.model=Model.initDiagramModel(),this.gb=null,this.themeManager=new ThemeManager,this.Ro=!0,this.fL(),this.layout=new Layout,this.Ro=!1,this.DF=null,this.FF=null,this.RF=null,this.lb=null,this.vF=null,this.OF=null,this.IF=null,this.ta=null,this.lL=null,this.Zl=null,this.ia=null,this.ea=null,this.sa=null,this.na=null,this.yu=()=>{},this.Yh=null,this.Uu=!1,this.Vc=new DiagramHelper(this),t!==void 0&&(typeof t=="string"||root.Element&&t instanceof Element?this.mM(t):i=t),i&&this.setProperties(i),this.Ht=!1,this.requestUpdate(),this}HD(){return this.dt!==null}get renderer(){return this.Ic}set renderer(t){if(this instanceof Overview)return;t===""&&(t="default");const i=t.toLowerCase(),e=this.Ic;if(i===e)return;this.Ic=i;let s=null;i==="default"||i==="canvas"?(s=this.Wl.get("svg"),s!==null&&s.Ft.remove(),this.dt&&(this.Zt=this.dt.ai),this.Zt.clearContextCache(!0)):i==="svg"?(this.Wl.has("svg")?s=this.Wl.get("svg"):(s=new SVGSurface(this,root.document),this.addRenderer("svg",s)),this.div!==null&&this.div.appendChild(s.Ft),this.Zt=s.ai,this.dt&&(this.dt.ai.setTransform(this.Ui,0,0,this.Ui,0,0),this.dt.ai.clearRect(0,0,this.kt,this.Pt))):i==="debug"&&(this.Wl.has("SVG")||(s=new SVGSurface(this,root.document),this.addRenderer("SVG",s),s.Ft.style.backgroundColor="whitesmoke",this.div!==null&&this.div.after(s.Ft))),this.Ht||this.redraw()}cL(){this.zc=new List,this.setupRouters(),this.ds=new AnimationManager,this.ds.To(this),this.di=17,this.VS=!1,this.Xu=!1,this.wx="default",this.Gt=new List,this.Wl=new GMap,this.Ic="default",this.resetRenderingHints(),this.EF(),this.Wt=1,this.at=new Point(NaN,NaN).g(),this.ex=new Point(NaN,NaN),this.et=1,this.Jm=1,this.xx=new Point(NaN,NaN).g(),this.bx=NaN,this.kx=1e-4,this.Px=100,this.D=new Transform,this.Sx=new Point(NaN,NaN).g(),this.Mx=new Rect(NaN,NaN,NaN,NaN).g(),this.Fc=new Margin(0,0,0,0).g(),this.jh=1,this.Nx=!1,this.Cx=null,this.Lx=null,this.jl=1,this.Rc=Spot.Default,this.Cr=1,this.Um=Spot.Default,this.Ax=Spot.None,this.Tx=Spot.None,this.Ue=!0,this.Ru=!1,this.Hn=new Set,this.Lr=new GSet,this.Wh=new GSet,this.Fo=!1,this.$l=new GMap,this.Vu=!0,this.Vm=250,this.vc=-1,this.zm=new Margin(16,16,16,16).g(),this.Pr=!1,this.Oc=!1,this.vu=!0,this.Wm=new InputEvent,this.Wm.diagram=this,this.Xr=new InputEvent,this.Xr.diagram=this,this.$h=new InputEvent,this.$h.diagram=this,this.Ar=null,this.qn=null,this.Bw=!1,this.BF(),this.Yr=new GSet,this.Dx=!0,this.Fx=1,this.KS=!1,this.Rx=1,this.vx="auto",this.Xm="auto",this.Tr=null,this.Dr=null,this.Fr=null,this.Rr=null,this.vr=null,this.Or=null,this.Ox=null,this.Ir=null,this.Ix=!1,this.Er=null,this.Br=null,this.Ur=null,this.Vr=null,this.Ex=!1,this.sb={},this._h=[null,null],this.Ro=!1,this.qS=!1,this.Bx=!1,this.Ux=!1,this.WS=!0,this.ps=!1,this.Qh=!1,this.ZS=!0,this.vs=-2,this.Jl=new GMap,this.zu=new List,this.vo=!1,this.Oi=!0,this.Vx=!0,this.Rl=!0,this.vl=!0,this.zx=!1,this.Xx=!0,this.Ol=!0,this.Il=!0,this.El=!0,this.Kx=!0,this.Bl=!0,this.Ul=!0,this.Vl=!0,this.zl=!0,this.Xl=!0,this.Kl=!0,this.Yl=!0,this.Yx=!0,this.Gx=!0,this.QS=!1,this.Uc=!1,this.Ou=!0,this.Iu=!0,this.jx=!0,this.Hx=!0,this.qx=16,this.Wx=16,this.Km=!1,this.Jx=!1,this.$x=0,this.Zx=0,this.$t=new Margin(5).g(),this._S=new GSet().g(),this.Qx=999999999,this.tM=new GSet().g(),this.Zh=!0,this.Eu=!0,this.Ec=!0,this.gn=!1,this.Wn=!1,this.Kr=!0,this.bl=!1,this.Jn=!1,this.oL=new GSet,this.lM=new GSet,this.Hl=null,this.iM=new Size(8,8),this.eM=999,this.Ym=!1,this.Wk=1,this.Jk=0,this.Bi={scale:1,position:new Point,bounds:new Rect,canvasSize:new Size,newCanvasSize:new Size,isScroll:!1},this.Bi.canvasSize=this.Bi.canvasSize,this.Bi.newCanvasSize=this.Bi.newCanvasSize,this.Bi.isScroll=!1,this._x=new Rect(NaN,NaN,NaN,NaN).g(),this.Bu=new Size(NaN,NaN).g(),this.Gm=new Rect(NaN,NaN,NaN,NaN).g(),this.tb=!1,this.UF(),this.ts=null,this.Hm=!1,this.fc=null,this.partManager=new PartManager,this.toolManager=new ToolManager,this.toolManager.initializeStandardTools(),this.defaultTool=this.toolManager,this.currentTool=this.defaultTool,this.cb=null,this.fb=new DraggingOptions,this.ub=null,this.db=null,this.ab=!1,this.pu=!1,this.commandHandler=new CommandHandler,this.t0=null,this.i0=Point.Ak,this.dM=!1,this.Ui=1,this.Pl=null,this.Im=1,this.Qm=0,this.uM=[0,0,0,0,0],this._m=0,this.$m=1,this.hM=0,this.aM=new Point,this.rL=500,this.qm=new Point,this.Zm=!1}static uL=root.document!==void 0;static isUsingDOM(){return Diagram.uL}static useDOM(t){Diagram.uL=t?root.document!==void 0:!1}static Ve=new WeakMap;clear(){this.animationManager.stopAnimation(),this.model.clear(),Diagram.dL(),this.gL(!1),this.zu.clear(),this.mL(),this.Hl=null,this.invalidateDocumentBounds(),this.ensureBounds(),this.C()}gL(t){this.animationManager.stopAnimation(!0),this._S=new GSet().g(),this.tM=new GSet().g();const i=this.skipsUndoManager,e=this.Si!==null&&this.Si!==void 0;e&&(this.skipsUndoManager=!0);let s=null;this.ts!==null&&(s=this.ts.part,s!==null&&this.remove(s));const n=[],o=this.Gt.length;if(t){for(let r=0;rt?new Margin(t/2):1.5)),this.ib=this.jm,this.eb=new Adornment(Panel.Link).add(new Shape({isPanelMain:!0,fill:null,stroke:"dodgerblue",strokeWidth:3}).theme("stroke","selection").theme("strokeWidth","selection"))}setRTL(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);const e=Util.en("div");e.dir="rtl",e.style.cssText="font-size: 14px; width: 1px; height: 1px; position: absolute; top: -1000px; overflow: scroll;",e.textContent="A",i.appendChild(e);let s="reverse";e.scrollLeft>0?s="default":(e.scrollLeft=1,e.scrollLeft===0&&(s="negative")),i.removeChild(e),this.wx=s}setScrollWidth(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);let e=0;if(Diagram.isUsingDOM()){let s=Diagram.fM,n=Diagram.cM;s===null&&(Diagram.fM=Util.en("p"),s=Diagram.fM,s.style.width="100%",s.style.height="200px",s.style.boxSizing="content-box",Diagram.cM=Util.en("div"),n=Diagram.cM,n.style.position="absolute",n.style.visibility="hidden",n.style.width="200px",n.style.height="150px",n.style.boxSizing="content-box",n.appendChild(s)),n.style.overflow="hidden",i.appendChild(n);const o=s.offsetWidth;n.style.overflow="scroll";let r=s.offsetWidth;o===r&&(r=n.clientWidth),i.removeChild(n),e=o-r,e===0&&!Util.rr&&(e=11)}this.di=e,this.VS=!0}ri(t){t in AutoScale?this.autoScale=t:Util.lr(this,t)}toString(t){t===void 0&&(t=0);let i="";this.div&&this.div.id&&(i=this.div.id);let e='Diagram "'+i+'"';if(t<=0)return e;const s=this.Gt.iterator;for(;s.next();){const n=s.value;e+=` + `+n.toString(t-1)}return e}static aL(t){Diagram.hb=t}static mm(){return Diagram.hb}static fromDiv(t){let i=t;if(typeof t=="string"&&(i=root.document.getElementById(t)),i instanceof HTMLDivElement){const e=Diagram.Ve.get(i);if(e)return e}return null}get div(){return this.Tt}set div(t){if(this.Tt!==t){const i=this.Tt;if(i!==null){if(Diagram.Ve.delete(i),i.goDiagram=void 0,i.go=void 0,i.innerHTML="",this.dt!==null){const s=this.dt.Ft;this.Mi(s,"pointermove",this.ia,!1),this.Mi(s,"pointerdown",this.Zl,!1),this.Mi(s,"pointerup",this.ea,!1),this.Mi(s,"pointerout",this.sa,!1),this.Mi(s,"pointercancel",this.na,!1),this.dt.dispose()}this.Bc&&(this.Bc.disconnect(),this.Bc=null);const e=this.toolManager;e!==null&&(e.mouseDownTools.each(s=>s.cancelWaitAfter()),e.mouseMoveTools.each(s=>s.cancelWaitAfter()),e.mouseUpTools.each(s=>s.cancelWaitAfter())),e.cancelWaitAfter(),this.currentTool.doCancel(),this.dt=null,this.Mi(root,"resize",this.lb,!1),this.Mi(root,"wheel",this.ta,!0),Diagram.mm()===this&&Diagram.aL(null)}else this.Zl===null&&(this.Jn=!1);if(this.Tt=null,t!==null){const e=Diagram.Ve.get(t);e&&(e.div=null),this.mM(t),this.yu(),this.themeManager&&this.themeManager.VF()}else this.themeManager&&this.themeManager.zF()}}setupRouters(){this.zc.push(new AvoidsNodesRouter)}mM(t){const i=this;if(!Diagram.isUsingDOM())return;t==null&&Util.o("Diagram setup requires an argument DIV."),i.Tt!==null&&Util.o("Diagram has already completed setup."),typeof t=="string"?i.Tt=root.document.getElementById(t):t instanceof HTMLDivElement?i.Tt=t:Util.o("No DIV or DIV id supplied: "+t),i.Tt===null&&Util.o("Invalid DIV id; could not get element with id: "+t);const e=Diagram.Ve.get(i.Tt);if(e&&e!==this&&Util.o("Invalid div id; div already has a Diagram associated with it."),!i.Bc&&root.ResizeObserver){const c=root.ResizeObserver,f=Util.Nk(()=>i.requestUpdate(),250,!1);i.Bc=new c(()=>f()),i.Bc.observe(i.Tt)}root.getComputedStyle(i.Tt,null).position==="static"&&(i.Tt.style.position="relative");let s=5;const n="rgba(2"+s+"5, 255, 255, 0)";s--,i.Tt.style["-webkit-tap-highlight-color"]=n,i.Tt.innerHTML="",Diagram.Ve.set(i.Tt,i),i.Tt.goDiagram=i,i.Tt.go=root.go;const o=new CanvasSurface(i);o.style!==void 0&&(o.style.position="absolute",o.style.top="0px",o.style.left="0px",root.getComputedStyle(i.Tt,null).getPropertyValue("direction")==="rtl"&&(i.Xu=!0),o.style.zIndex="2",o.style.userSelect="none",o.style.MozUserSelect="none",o.style.touchAction="none",o.style.letterSpacing="normal !important",o.style.wordSpacing="normal !important",o.style.lang="unknown"),i.dt=o,i.Zt=o.ai;const r=i.Zt;i.Ui=i.computePixelRatio(),i.viewSize.isReal()||(i.kt=i.Tt.clientWidth||1,i.Pt=i.Tt.clientHeight||1),i.pL(i.kt,i.Pt);const l=i;i.Tt.insertBefore(o.Ft,i.Tt.firstChild);const h=new CanvasSurface(null);if(h.width=1,h.height=1,i.AF=h,i.TF=h.ai,Diagram.isUsingDOM()){const c=Util.en("div"),f=Util.en("div");c.style.position="absolute",c.style.overflow="auto",c.style.width=i.kt+"px",c.style.height=i.Pt+"px",c.style.zIndex="1",f.style.position="absolute",f.style.width="1px",f.style.height="1px",i.Tt.appendChild(c),c.appendChild(f),c.onscroll=Diagram.XF,c.addEventListener("pointerdown",Diagram.KF),c.p=i,c.YF=!0,c.GF=!0,i.nb=c,i.ob=f}i.yu=Util.Nk(()=>{i.Pl=null,i.C()},300,!1),i.lb=Util.Nk(()=>{i.MS()},250,!1),i.Yh=c=>(c.preventDefault(),!1),i.ta=c=>{if(!l.isEnabled)return;const f=l.Xc(c,!0);f.bubbles=!0;let u=0,d=0;f.delta=0,c.deltaX!==void 0?(c.deltaX!==0&&(u=c.deltaX>0?1:-1),c.deltaY!==0&&(d=c.deltaY>0?1:-1),f.delta=Math.abs(c.deltaX)>Math.abs(c.deltaY)?-u:-d):c.wheelDeltaX!==void 0?(c.wheelDeltaX!==0&&(u=c.wheelDeltaX>0?-1:1),c.wheelDeltaY!==0&&(d=c.wheelDeltaY>0?-1:1),f.delta=Math.abs(c.wheelDeltaX)>Math.abs(c.wheelDeltaY)?-u:-d):c.wheelDelta!==void 0&&c.wheelDelta!==0&&(f.delta=c.wheelDelta>0?1:-1),l.doMouseWheel(),l.oa(f,c)},i.lL=c=>{if(!l.isEnabled)return;i.Uc=!1,l.Xc(c,!0);const f=l.currentTool;f.cancelWaitAfter(),f.standardMouseOver()},i.Zl=c=>{if(!l.isEnabled)return;i.Uc=!0;const f=l.sb;f[c.pointerId]===void 0&&(f[c.pointerId]=c);const u=l._h;let d=!1;if(u[0]!==null&&(u[0].pointerId===c.pointerId||u[0].pointerType!==c.pointerType))u[0]=c;else if(u[1]!==null&&u[1].pointerId===c.pointerId)u[1]=c,d=!0;else if(u[0]===null)u[0]=c;else if(u[1]===null)u[1]=c,d=!0;else{c.preventDefault();return}const m=c.pointerType==="touch"||c.pointerType==="pen";m&&(l.Bw=!1,l.Zm=!0);const g=l.jF(c,c,d),p=l.aM,y=m?25:10;if(c.timeStamp-l.hMy||Math.abs(p.y-c.screenY)>y)?l.$m++:l.$m=1,g.clickCount=l.$m,l.hM=c.timeStamp,l.aM.setTo(c.screenX,c.screenY),l.doMouseDown(),c.button===1){c.preventDefault();return}l.oa(g,c)},i.ia=c=>{if(!l.isEnabled)return;i.Uc=!0;const f=l._h;if(f[0]!==null&&(f[0].pointerId===c.pointerId||f[0].pointerType!==c.pointerType))f[0]=c;else if(f[1]!==null&&f[1].pointerId===c.pointerId){f[1]=c;return}else if(f[0]===null)f[0]=c;else return;if(f[0].pointerId!==c.pointerId)return;const u=l.HF(c,c,f[1]!==null);l.doMouseMove(),l.oa(u,c)},i.ea=c=>{if(!l.isEnabled)return;i.Uc=!0;const f=c.pointerType==="touch"||c.pointerType==="pen",u=l.sb;if(f&&l.Bw){delete u[c.pointerId],c.preventDefault();return}const d=l._h;if(d[0]!==null&&(d[0].pointerId===c.pointerId||d[0].pointerType!==c.pointerType))d[0]=null;else if(d[1]!==null&&d[1].pointerId===c.pointerId){d[1]=null;return}else return;const m=l.pM(c,!1,!0,!1,!0,!1);let g=root.document.elementFromPoint(c.clientX,c.clientY)||null;g!==null&&g.shadowRoot!==void 0&&g.shadowRoot!==null&&(g=g.shadowRoot.elementFromPoint(c.clientX,c.clientY)),g!==null&&g.p instanceof Diagram&&g.p!==l&&g.p.s0(c,m),g===null&&(g=c.target),l.s0(c,m),m.clickCount=l.$m,m.targetDiagram=l.yM(c,g),m.targetObject=null,l.doMouseUp(),l.oa(m,c),f&&(l.Zm=!1)},i.sa=c=>{if(!l.isEnabled)return;i.Uc=!1;const f=l.sb;f[c.pointerId]&&delete f[c.pointerId];const u=l._h;if(u[0]!==null&&u[0].pointerId===c.pointerId&&(u[0]=null),u[1]!==null&&u[1].pointerId===c.pointerId&&(u[1]=null),c.pointerType==="touch"||c.pointerType==="pen")return;const d=l.currentTool;d.cancelWaitAfter(),d.standardMouseOver()},i.na=c=>{const f=l._h;f[0]!==null&&f[0].pointerId===c.pointerId?(f[0]=null,l.Zm=!1):f[1]!==null&&f[1].pointerId===c.pointerId&&(f[1]=null)};const a=r;if(i.rb=a.U[Util.Cs("7eba17a4ca3b1a8346")][Util.Cs("78a118b7")](a.U,Diagram.Ku,s,s),r.clearContextCache(!0),i.qF(),this.Ic==="svg"){const c=this.Wl.get("svg");this.Tt.appendChild(c.Ft),this.Zt=c.ai}}addEventListener(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}Vt(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}removeEventListener(t,i,e,s){t.removeEventListener(i,e,{capture:s})}Mi(t,i,e,s){t.removeEventListener(i,e,{capture:s})}qF(){const t=this;let i=this.dt.Ft;i instanceof HTMLCanvasElement||(i=t.div),this.Vt(i,"pointerdown",t.Zl,!1),this.Vt(i,"pointermove",t.ia,!1),this.Vt(i,"pointerup",t.ea,!1),this.Vt(i,"pointerout",t.sa,!1),this.Vt(i,"pointercancel",t.na,!1),this.Vt(i,"pointerenter",t.WF,!1),this.Vt(i,"pointerleave",t.JF,!1),this.Vt(i,"wheel",t.ta,!1),this.Vt(i,"keydown",t.$F,!1),this.Vt(i,"keyup",t.ZF,!1),this.Vt(i,"blur",t.QF,!1),this.Vt(i,"focus",t._F,!1),this.Vt(i,"selectstart",e=>(e.preventDefault(),!1),!1),this.Vt(i,"contextmenu",e=>(e.preventDefault(),!1),!1),this.Vt(root,"resize",t.lb,!1)}Uw(){this.Qm>30&&(this.Pl=1)}yP(t){this.Pl!==null&&(this.Pl=null,t&&this.yu(),this.Qm=0,this.uM=[0,0,0,0,0],this._m=0)}computePixelRatio(){return this.Pl!==null?this.Pl:root.devicePixelRatio||1}get avgSpf(){return this.Qm}doMouseDown(){this.currentTool.doMouseDown()}doMouseMove(){this.currentTool.doMouseMove()}doMouseUp(){this.currentTool.doMouseUp()}doMouseWheel(){this.currentTool.doMouseWheel()}doKeyDown(){this.currentTool.doKeyDown()}doKeyUp(){this.currentTool.doKeyUp()}doFocus(){this.focus()}focus(){if(this.dt)if(this.scrollsPageOnFocus)this.dt.focus();else{const t=root.scrollX,i=root.scrollY;this.dt.focus(),root.scrollTo(t,i)}}_F(t){const i=Diagram.Ve.get(this);i&&i.v("GainedFocus")}QF(t){const i=Diagram.Ve.get(this);i&&i.v("LostFocus")}MS(){if(this.dt===null)return;const i=this.Tt;if(i===null||i.clientWidth===0||i.clientHeight===0)return;this.VS||this.setScrollWidth();const e=this.Wn?this.di:0,s=this.gn?this.di:0,n=this.Ui;if(this.Ui=this.computePixelRatio(),this.Ui!==n&&(this.Ru=!0,this.requestUpdate()),i.clientWidth!==this.kt+e||i.clientHeight!==this.Pt+s){this.ra(),this.Ue=!0;const o=this.layout;o!==null&&o.isViewportSized&&this.autoScale===1&&(this.Oc=!0,o.invalidateLayout()),this.ps||this.requestUpdate()}}fL(){let t=0,i=new Layer;i.name="Grid",i.allowSelect=!1,i.pickable=!1,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="ViewportBackground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="Background",this.Gr(i,t++),i=new Layer,i.name="",this.Gr(i,t++),i=new Layer,i.name="Foreground",this.Gr(i,t++),i=new Layer,i.name="ViewportForeground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="Adornment",i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="Tool",i.isTemporary=!0,i.isInDocumentBounds=!0,this.Gr(i,t++)}yL(){const t=new Panel(Panel.Grid,{name:"GRID"}).add(new Shape("LineH",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineV",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineH",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineH",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor")),i=new Part({layerName:"Grid",zOrder:0,isInDocumentBounds:!1,isAnimated:!1,pickable:!1,locationObjectName:"GRID"}).add(t);return this.add(i),this.partManager.parts.delete(i),t.visible=!1,t}static XF(){const t=Diagram.Ve.get(this.parentElement||this);if(t){if(t.Jx){t.Jx=!1;return}if(!t.isEnabled){t.wL();return}t.diagramScroll(this)}}static KF(t){if(!this.p.isEnabled){this.p.updateScroll();return}this.p.$x=t.target.scrollTop,this.p.Zx=t.target.scrollLeft}diagramScroll(t){if(this.dt===null)return;const i=this.nb,e=this.ob;this.Km=!0;let s=this.documentBounds,n=this.viewportBounds;const o=this.Fc;let r=s.x-o.left,l=s.y-o.top;const h=s.width+o.left+o.right,a=s.height+o.top+o.bottom;let c=s.right+o.right,f=s.bottom+o.bottom,u=n.x,d=n.y;const m=n.width,g=n.height;let p=n.right,y=n.bottom;const x=this.scale;let k,b=t.scrollLeft;if(this.Xu)switch(this.wx){case"negative":b=b+t.scrollWidth-t.clientWidth;break;case"reverse":b=t.scrollWidth-b-t.clientWidth;break}const P=b;if(mp)){const S=i.scrollWidth-this.kt;this.position=k.e(-S+P-this.kt/x+c,this.position.y)}if(t.GF&&this.allowVerticalScroll&&(ly)){const S=i.scrollHeight-this.Pt;this.position=k.e(this.position.x,-S+t.scrollTop-this.Pt/x+f)}Point.s(k),this._l(),this.Km=!1,this.Eu=!1,s=this.documentBounds,n=this.viewportBounds,c=s.right,p=n.right,f=s.bottom,y=n.bottom,r=s.x,u=n.x,l=s.y,d=n.y,m>=h&&r>=u&&c<=p&&(e.style.width="1px"),g>=a&&l>=d&&f<=y&&(e.style.height="1px")}computeBounds(t){return t===void 0&&(t=new Rect),this.Ci(),this.xL(t)}xL(t){if(this.fixedBounds.isReal())return t.a(this.fixedBounds),t.addMargin(this.$t),t;let i=!0;const e=this.Gt.r,s=e.length;for(let n=0;ni&&(a=i),athis.maxScale&&(a=this.maxScale),a):t===3?(a=0,h>l?a=(r-this.di)/n:a=(o-this.di)/s,a>i&&(a=i),athis.maxScale&&(a=this.maxScale),a):this.scale}zoomToFit(){const t=this.jh;this.jh=1,this.scale=this.Yu(2),t!==1&&(this.Us(!1),this.wM(this.documentBounds,this.kt/this.et,this.Pt/this.et,this.Rc,!1)),this.jh=t}zoomToRect(t,i){i===void 0&&(i=2);const e=t.width,s=t.height;if(e===0||s===0||isNaN(e)&&isNaN(s))return;let n=1;if(i===2||i===3)if(isNaN(e))n=this.viewportBounds.height*this.scale/s;else if(isNaN(s))n=this.viewportBounds.width*this.scale/e;else{const o=this.kt,r=this.Pt;i===3?r/s>o/e?n=(r-(this.gn?this.di:0))/s:n=(o-(this.Wn?this.di:0))/e:n=Math.min(r/s,o/e)}this.scale=n,this.position=new Point(t.x,t.y)}get tR(){return this.Ht}set tR(t){this.Ht=t}alignDocument(t,i){this.ensureBounds();const e=this.documentBounds,s=this.viewportBounds;this.position=new Point(e.x+(t.x*e.width+t.offsetX)-(i.x*s.width-i.offsetX),e.y+(t.y*e.height+t.offsetY)-(i.y*s.height-i.offsetY))}focusObject(t){if(t instanceof GraphObject){this.t0=t;const i=Point.l();this.i0=this.transformDocToView(t.getDocumentPoint(Spot.TopLeft,i)),Point.s(i)}else this.t0=null,this.i0=Point.Ak}wM(t,i,e,s,n){const o=Point.X(this.at.x,this.at.y);let r=o.x,l=o.y;if(this.t0!==null){let h=Point.l();h=this.t0.getDocumentPoint(Spot.TopLeft,h),r=h.x-this.i0.x/this.scale,l=h.y-this.i0.y/this.scale,s=Spot.None,Point.s(h)}if(n||this.scrollMode===1){s.isSpot()&&(i>t.width&&(r=t.x+(s.x*t.width+s.offsetX)-(s.x*i-s.offsetX)),e>t.height&&(l=t.y+(s.y*t.height+s.offsetY)-(s.y*e-s.offsetY)));const h=this.Fc,a=i-t.width;if(it.left?r=t.left:rt.top?l=t.top:ls.part,s=>s.canSelect());if(e instanceof Part)return e}else{const e=this.PP(t,s=>s.part);if(e instanceof Part)return e}return null}findObjectAt(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Ci();const s=this.Gt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}PP(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Ci();const s=this.Gt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible||n.isTemporary)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}findPartsAt(t,i,e){return i===void 0&&(i=!0),this.eR(t,s=>s.part,i?s=>s instanceof Part&&s.canSelect():null,e)}eR(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Ci();const n=this.Gt.iteratorBackwards;for(;n.next();){const o=n.value;!o.visible||o.isTemporary||o.findObjectsAt(t,i,e,s)}return s}findObjectsAt(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Ci();const n=this.Gt.iteratorBackwards;for(;n.next();){const o=n.value;o.visible&&o.findObjectsAt(t,i,e,s)}return s}findPartsIn(t,i,e,s){return i===void 0&&(i=!1),e===void 0&&(e=!0),this.sR(t,null,n=>n instanceof Part&&(!e||n.canSelect()),i,s)}findObjectsIn(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Ci();const o=this.Gt.iteratorBackwards;for(;o.next();){const r=o.value;r.visible&&r.findObjectsIn(t,i,e,s,n)}return n}NP(t,i,e,s,n,o){const r=new GSet;this.Ci();const l=this.Gt.iteratorBackwards;for(;l.next();){const h=l.value;h.visible&&h.NP(t,i,e,s,r,n,o)}return r}sR(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Ci();const o=this.Gt.iteratorBackwards;for(;o.next();){const r=o.value;!r.visible||r.isTemporary||r.findObjectsIn(t,i,e,s,n)}return n}findPartsNear(t,i,e,s,n){return e===void 0&&(e=!0),s===void 0&&(s=!0),this.nR(t,i,null,o=>o instanceof Part&&(!s||o.canSelect()),e,n)}findObjectsNear(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Ci();const r=this.Gt.iteratorBackwards;for(;r.next();){const l=r.value;l.visible&&l.findObjectsNear(t,i,e,s,n,o)}return o}nR(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Ci();const r=this.Gt.iteratorBackwards;for(;r.next();){const l=r.value;!l.visible||l.isTemporary||l.findObjectsNear(t,i,e,s,n,o)}return o}acceptEvent(t){return this.Xc(t,t instanceof MouseEvent)}Xc(t,i){const e=this.Xr;this.Xr=this.$h,this.$h=e,e.diagram=this,e.event=t,i?this.s0(t,e):(e.viewPoint=this.Xr.viewPoint,e.documentPoint=this.Xr.documentPoint);let s=0;const n=t;return n.ctrlKey&&(s+=1),n.altKey&&(s+=2),n.shiftKey&&(s+=4),n.metaKey&&(s+=8),e.modifiers=s,e.button=n.button,n.buttons!==void 0&&(e.buttons=n.buttons),Util.rr&&n.button===0&&n.ctrlKey&&(e.button=2),e.down=!1,e.up=!1,e.clickCount=1,e.delta=0,e.handled=!1,e.bubbles=!1,e.timestamp=t.timeStamp,e.isMultiTouch=!1,e.targetDiagram=this.yM(t,t.target),e.targetObject=null,e}yM(t,i){if(i===null)return null;const e=Diagram.Ve.get(i);if(e)return e;let s=t.path;if(!s&&typeof t.composedPath=="function"&&(s=t.composedPath()),s&&s[0]){const n=Diagram.Ve.get(s[0]);if(n)return n}return null}jF(t,i,e){const s=this.pM(t,!0,!1,!1,!0,e);return this.s0(i,s),s.targetDiagram=this.yM(t,t.target),s.targetObject=null,e||s.clone(this.Wm),s}HF(t,i,e){const s=this.pM(t,!1,!1,!1,!1,e);let n=root.document.elementFromPoint(i.clientX,i.clientY)||null;n!==null&&n.shadowRoot!==void 0&&n.shadowRoot!==null&&(n=n.shadowRoot.elementFromPoint(i.clientX,i.clientY));let o=this,r=t;if(n){const l=Diagram.Ve.get(n);l&&(r=i,o=l)}return s.targetDiagram=o,this.s0(r,s),s.targetObject=null,s}pM(t,i,e,s,n,o){const r=this.Xr;this.Xr=this.$h,this.$h=r,r.diagram=this,r.clickCount=1,r.delta=0;let l=0;return t.ctrlKey&&(l+=1),t.altKey&&(l+=2),t.shiftKey&&(l+=4),t.metaKey&&(l+=8),r.modifiers=l,r.event=t,r.timestamp=t.timeStamp,r.button=e?this.firstInput.button:t.button,r.buttons=t.buttons,Util.rr&&t.button===0&&t.ctrlKey&&(r.button=2),r.down=i,r.up=e,r.handled=s,r.bubbles=n,r.isMultiTouch=o,r}oa(t,i){return t.bubbles?!0:(i.stopPropagation!==void 0&&i.stopPropagation(),i.cancelable!==!1&&i.preventDefault(),i.cancelBubble=!0,!1)}$F(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.Xc(t,!1);return e.key=t.key,e.code=t.code,e.down=!0,i.doKeyDown(),i.oa(e,t)}ZF(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.Xc(t,!1);return e.key=t.key,e.code=t.code,e.up=!0,i.doKeyUp(),i.oa(e,t)}WF(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.Xc(t,!0);return i.mouseEnter!==null&&i.mouseEnter(e),i.currentTool.standardMouseOver(),i.oa(e,t)}JF(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.Xc(t,!0);return i.mouseLeave!==null&&i.mouseLeave(e),i.oa(e,t)}getMouse(t){const i=this.dt;if(i===null)return new Point(0,0);const e=i.getBoundingClientRect(),s=(t.clientX-e.left)*(this.kt/e.width),n=(t.clientY-e.top)*(this.Pt/e.height);return new Point(s,n).Ie(this.D)}s0(t,i){const e=this.dt;let s=0,n=0;if(e!==null){const r=e.getBoundingClientRect();s=(t.clientX-r.left)*(this.kt/r.width),n=(t.clientY-r.top)*(this.Pt/r.height)}i.viewPoint.e(s,n);const o=Point.X(s,n);this.D._e(o),i.documentPoint.a(o),Point.s(o)}kC(t,i,e){let s;if(this._h[0]!==null)s=this._h[i];else return;const n=this.dt;if(n!==null){const o=n.getBoundingClientRect();e.e((s.clientX-o.left)*(this.kt/o.width),(s.clientY-o.top)*(this.Pt/o.height))}}invalidateDocumentBounds(){this.Zh||(this.Zh=!0,this.requestUpdate(!1))}oR(){this.ps||this.Ci(),this.ensureBounds()}redraw(){this.Ht||this.ps||(this.C(),this.maybeUpdate())}isUpdateRequested(){return this.Pr}delayInitialization(t){t===void 0&&(t=null);const i=this.animationManager,e=i.isEnabled;i.stopAnimation(),i.isEnabled=!1,this.yr(),this.Jn=!1,this.ex=new Point(NaN,NaN),i.isEnabled=e,this.ps=!0;const s=this;t!==null&&Util.Oh(()=>{s.ps=!1,i.Fl("Model"),t(s)},1)}requestUpdate(t){if(t===void 0&&(t=!1),this.Pr===!0||this.Ht||t===!1&&this.ps)return;this.Pr=!0;const i=this;root.requestAnimationFrame(()=>{i.Pr&&i.maybeUpdate()})}maybeUpdate(){this.vu&&!this.Pr||(this.vu&&(this.vu=!1),this.yr())}xM(t,i){!this.Eu||this.Ht||this.animationManager.defaultAnimation.isAnimating||this.wL()||(t&&this.Ci(),i&&this.Us(!1))}yr(t){if(this.ps||(this.Pr=!1,this.Tt===null&&!this.Bu.isReal()))return;this.ps=!0;const i=this.animationManager,e=this.zu;if(!i.isAnimating&&e.length!==0){const c=e.r,f=c.length;for(let u=0;u0&&(s.each(c=>c.bM()),s.clear());let n=!1,o=!1;i.defaultAnimation.isAnimating&&(o=!0,n=this.skipsUndoManager,this.skipsUndoManager=!0),i.wi||this.MS(),t||this.xM(!1,!0);const r=!this.undoManager.isUndoingRedoing&&(this.bl||this.zc.count!==0&&this.Lr.size!==0),l=!this.Jn||this.Kr;this.Ci(!0);let h=!1;(l||r)&&(this.Jn?this.kM(!this.Oc,r):(this.startTransaction("Initial Layout"),i.isEnabled===!1&&i.stopAnimation(),this.kM(!1,r)),h=l),this.Oc=!1,this.bl=!1,this.Ci(),this.ts!==null&&(this.ts.visible&&!this.Hm&&(this.jr(),this.Hm=!0),!this.ts.visible&&this.Hm&&(this.Hm=!1)),this.Bx||this.oR(),t||this.xM(!0,!1);let a=!1;if(h){const c=Rect.l();c.a(this.viewportBounds),this.Jn||(this.Jn=!0,a=!0,this.skipsUndoManager||(this.undoManager.Ow=!0),this.undoManager.Iw=!0,this.rR()),this.lR(),this.Ci(!1),t||this.xM(!0,!0),Rect.s(c)}else if(i.Sc&&i.ix){if(this.Cr!==1)this.scale=this.Yu(this.Cr);else if(this.jl!==1)this.scale=this.Yu(this.jl);else{const c=this.initialScale;isFinite(c)&&c>0&&(this.scale=c)}this.Us(!0)}h&&a&&this.commitTransaction("Initial Layout"),t||this.Gi(this.Zt),o&&(this.skipsUndoManager=n),this.ps=!1}get Bh(){return this.Jn}rR(){if(this.Cr!==1)this.scale=this.Yu(this.Cr);else if(this.jl!==1)this.scale=this.Yu(this.jl);else{const i=this.initialScale;isFinite(i)&&i>0&&(this.scale=i)}this.Us(!0);const t=this.Gt.r;this.Bs(t,t.length,this,this.viewportBounds),this.v("InitialLayoutCompleted"),this.ex.a(this.at),this.jr()}lR(){this.v("LayoutCompleted")}o0(t){this.Hn.add(t)}addInvalidRoute(t){this.Fo?this.Wh.add(t):this.Lr.add(t)}Ci(t){if(this.Hn.size!==0&&!(!this.ps&&this.animationManager.isTicking)){if(this.ps||(this.bl=!0),t){this.bL(this.Hn);return}for(let i=0;i<23&&this.Hn.size!==0;i++){const e=new Set(this.Hn);this.Hn.clear(),this.bM(e,this.Hn)}this.nodes.each(i=>{i instanceof Group&&i.kL(!1)})}}bL(t,i){for(const e of t)!e.Pe()||e instanceof Group||(e.Hr()?(e.ut(1/0,1/0),e.zt()):i&&i.add(e));for(const e of t)if(e instanceof Group){if(!e.isVisible())continue;this.yb(e)}}bM(t,i){this.bL(t,i);for(const e of t){if(!(e instanceof Link))continue;const s=e;s.isVisible()&&(s.Hr()?(s.ut(1/0,1/0),s.zt()):i.add(s))}for(const e of t)e instanceof Adornment&&e.isVisible()&&(e.Hr()?(e.ut(1/0,1/0),e.zt()):i.add(e))}r0(t){const i=t instanceof Diagram,e=i?t.links:t.memberParts,s=this.Hn;if(i)this.Ci(!0);else{for(;e.next();){const n=e.value;s.has(n)&&(!n.Pe()||n instanceof Group||n.Hr()&&(n.ut(1/0,1/0),n.zt()))}for(e.reset();e.next();){const n=e.value;if(s.has(n)&&n instanceof Group){if(!n.isVisible())continue;this.yb(n)}}e.reset()}for(;e.next();){const n=e.value;n instanceof Link&&s.has(n)&&n.isVisible()&&n.Hr()&&(n.ut(1/0,1/0),n.zt())}}yb(t){const i=Util.nt(),e=Util.nt(),s=t.memberParts;for(;s.next();){const o=s.value;o.isVisible()&&(o instanceof Group?(o.Oo()||o.is()||o.th())&&this.yb(o):o instanceof Link?o.fromNode===t||o.toNode===t?e.push(o):i.push(o):(o.ut(1/0,1/0),o.zt()))}let n=i.length;for(let o=0;ob.Du())}else for(let x=0;x0){const a=n.substring(0,h);e?o=t.findObject(a):(o=t[a],o==null&&(o=t.toolManager[a])),Util.wt(o)?r=n.substring(h+1):Util.o("Unable to find object named: "+a+" in "+t.toString()+" when trying to set property: "+n)}}if(r[0]!=="_"&&!Util.fw(o,r))if(s&&r==="ModelChanged"){t.addModelChangedListener(i[r]);continue}else if(s&&r==="Changed"){t.addChangedListener(i[r]);continue}else if(s&&Util.fw(t.toolManager,r))o=t.toolManager;else if(s&&t.PL(r)){t.addDiagramListener(r,i[r]);continue}else if(t instanceof Model&&r==="Changed"){t.addChangedListener(i[r]);continue}else Util.o('Trying to set undefined property "'+r+'" on object: '+o.toString());const l=i[n];o[r]=l,r[0]==="_"&&o instanceof GraphObject&&o.addCopyProperty(r)}}_C(){if(this.$l.count!==0&&!(this.undoManager.transactionLevel>1)){for(;this.$l.count>0;){const t=this.$l;this.$l=new GMap;const i=t.iterator;for(;i.next();){const e=i.key;e.invalidateOtherJumpOvers(i.value),e.ee()}}this.C()}}C(t){if(t===void 0)this.Ue=!0,this.requestUpdate();else{const i=this.viewportBounds;t.isReal()&&i.intersectsRect(t)&&(this.Ue=!0,this.requestUpdate())}this.v("InvalidateDraw")}invalidateViewport(t,i){if(this.Ue===!0)return;if(this.Ue=!0,this.Ic==="svg"){this.maybeUpdate();return}this.getRenderingHint("temporaryPixelRatio")===!0?(this.Uw(),this.maybeUpdate(),this.yP(!0)):this.maybeUpdate()}ra(){this.Eu=!0}_l(){this.Ec=!0}l0(){this.Ru!==!1&&(this.Ru=!1,this.pL(this.kt,this.Pt))}pL(t,i){this.Ql();const e=this.Ui,s=t*e,n=i*e;this.dt.resize(s,n,t,i)&&(this.Ue=!0,this.Zt.clearContextCache(!0))}wL(){const t=this.dt;if(t===null||this.Bu.isReal())return!0;const i=this.kt,e=this.Pt,s=this.Tt;let n=!1,o=this.Wn?this.di:0,r=this.gn?this.di:0,l=s.clientWidth||i+o,h=s.clientHeight||e+r;const a=this.viewportBounds,c=a.x,f=a.y,u=a.width,d=a.height;if((l!==i+o||h!==e+r)&&(this.Wn=!1,this.gn=!1,o=0,r=0,this.kt=l,this.Pt=h,this.Ru=!0,n=!0,this.Ql()),!this.Jn||!this.viewportBounds.isReal())return!0;const m=this.nb,g=this.ob;if(this.Eu=!1,!n&&!this.Wn&&!this.gn&&!this.Ou&&!this.Iu)return!0;const p=this.documentBounds;let y=0,x=0,k=0,b=0;const P=a.width,S=a.height,L=this.Fc;this.contentAlignment.isSpot()?(p.width>P&&(y=L.left,x=L.right),p.height>S&&(k=L.top,b=L.bottom)):(y=L.left,x=L.right,k=L.top,b=L.bottom);const C=p.width+y+x,M=p.height+k+b,N=this.scale,T=N;let A=C>l/N,D=M>h/N;if(!n&&!this.Wn&&!this.gn&&!A&&!D)return!0;const F=p.x-y,R=a.x,v=p.right+x;let O=a.right+o;const B=p.y-k,X=a.y,E=p.bottom+b;let V=a.bottom+r,U="1px",Y="1px";if(this.scrollMode===1&&(A||D)){if(A&&this.hasHorizontalScrollbar&&this.allowHorizontalScroll){let z=1;F+1O+1&&(z=Math.max((v-O)*N+this.kt,z)),P+o+1V+1&&(z=Math.max((E-V)*N+this.Pt,z)),S+r+1O+1&&(W=Math.max((v-O)*N+this.kt,W)),P+1V+1&&(W=Math.max((E-V)*N+z,W)),S+1O+1&&(J=this.position.x*N)),this.Xu)switch(this.wx){case"negative":J=-(m.scrollWidth-J-m.clientWidth);break;case"reverse":J=m.scrollWidth-J-m.clientWidth;break}if(m.scrollLeft=J,this.hasVerticalScrollbar&&this.allowVerticalScroll&&(S+1V+1&&(m.scrollTop=this.position.y*N)),l=this.kt,h=this.Pt,m.style.width=l+(this.Wn?this.di:0)+"px",m.style.height=h+(this.gn?this.di:0)+"px",i!==l||e!==h||this.animationManager.wi){const z=Rect.X(c,f,u,d);return this.onViewportBoundsChanged(z,this.viewportBounds,T,n),Rect.s(z),!1}return!0}add(t){const i=t.diagram;if(i===this)return;i!==null&&Util.o("Cannot add part "+t.toString()+" to "+this.toString()+". It is already a part of "+i.toString());let e=this.findLayer(t.layerName);if(e===null&&(e=this.findLayer("")),e===null&&Util.o('Cannot add a Part when unable find a Layer named "'+t.layerName+'" and there is no default Layer'),t.layer===e)return;const s=e.qh(99999999,t,t.diagram===this);s>=0&&this.raiseChangedEvent(3,"parts",e,null,t,null,s),e.isTemporary||this.invalidateDocumentBounds(),t.invalidateLayout(1);const n=t.layerChanged;n!==null&&n(t,null,e)}qh(t){this.partManager.qh(t);const i=this;t.qr(s=>i.SL(s)),t.data||t.Io(),t.hasPlaceholder()&&t.c(),t.data!==null&&t.qr(s=>i.partManager.SM(s,null)),(t.is()===!0||t.th()===!0)&&this.o0(t),t.ML(!0,this),t.NL()?(t.actualBounds.isReal()&&this.C(t.Hh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.C(t.Hh(t.actualBounds)),this.requestUpdate()}te(t){t.clearAdornments(),this.partManager.te(t);const i=this;t.data!==null&&t.qr(s=>i.partManager.MM(s,i)),this.Hn.delete(t),t instanceof Link&&this.Lr.delete(t),t.NL()?(t.actualBounds.isReal()&&this.C(t.Hh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.C(t.Hh(t.actualBounds)),this.requestUpdate()}remove(t){this.NM(t,!0)}NM(t,i){const e=t.layer;if(e===null||e.diagram!==this)return;t.isSelected=!1,t.isHighlighted=!1,t.invalidateLayout(2),i&&t.Kc();const s=e.te(-1,t,!1);s>=0&&this.raiseChangedEvent(4,"parts",e,t,null,s,null);const n=t.layerChanged;n!==null&&n(t,e,null)}removeParts(t,i){if(i===void 0&&(i=!1),Array.isArray(t)){const e=t.length;for(let s=0;s=0&&i.elt(e).isTemporary;)e--;return i.insertAt(e+1,t),this.Si!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,e+1),this.C(),this.invalidateDocumentBounds(),this}addLayerBefore(t,i){this.CM(t,i),t.To(this);const e=this.Gt,s=e.indexOf(t);s>=0&&(e.delete(t),this.Si!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;o=0&&(e.delete(t),this.Si!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;othis.maxScale&&(i=this.maxScale);const c=Point.X(this.at.x+l/t-l/i,this.at.y+h/t-h/i);this.position=c,Point.s(c),this.et=i,this.Ql(),this.Ht=!1,this.onViewportBoundsChanged(n,this.viewportBounds,t,!1),this.Us(!1),e.ZC(t,this.et),this.C()}iR(){const t=this.Gt.r;for(let i=0;i{r.isAvoiding&&r.actualBounds.intersectsRect(i)&&r.invalidateRoute()})}jr(t){const i=this.ts;if(i===null||!i.visible||i.layer===null)return;const e=t!==void 0?t:this._x;if(!e.isReal())return;const s=e.width,n=e.height;if(i.scale=1,i.angle=0,i.layer.isViewportAligned)i.width=s*this.scale,i.height=n*this.scale,i.part.alignment=Spot.TopLeft;else{i.xi===null&&(i.xi=new GridPanelSettings);const o=i.xi.Yc;if(!o.isReal())return;i.width=s+o.width*2,i.height=n+o.height*2;const r=Point.l();Geo.Ig(e.x,e.y,0,0,o.width,o.height,r),r.offset(-o.width,-o.height),i.part.location=r,Point.s(r)}}clearSelection(t){t===void 0&&(t=!1);const i=this.selection;if(i.count===0)return;t||this.v("ChangingSelection",i);const e=i.toArray(),s=e.length;for(let n=0;n1)&&(this.v("ChangingSelection",this.selection),this.clearSelection(!0),t.isSelected=!0,this.v("ChangedSelection",this.selection))}selectCollection(t){if(this.v("ChangingSelection",this.selection),this.clearSelection(!0),Array.isArray(t)){const i=t.length;for(let e=0;e0){const i=t.toArray(),e=i.length;for(let s=0;s1)&&(this.clearHighlighteds(),t.isHighlighted=!0)}highlightCollection(t){const i=new GSet().addAll(t),s=this.highlighteds.copy().removeAll(i).iterator;for(;s.next();){const o=s.value;o.isHighlighted=!1}const n=i.iterator;for(;n.next();){const o=n.value;o instanceof Part||Util.o("Diagram.highlightCollection given something that is not a Part: "+o),o.isHighlighted=!0}}scroll(t,i,e){e===void 0&&(e=1);const s=i==="up"||i==="down";let n=0;const o=Point.l();if(t==="pixel")n=e;else if(t==="line")n=e*(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange);else if(t==="page"){let l=s?this.viewportBounds.height:this.viewportBounds.width;if(l*=this.scale,l!==0){const h=Math.max(l-(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange),0);n=e*h}}else if(t==="document"){const l=this.documentBounds,h=this.viewportBounds;i==="up"?this.position=o.e(h.x,l.y):i==="left"?this.position=o.e(l.x,h.y):i==="down"?this.position=o.e(h.x,l.bottom-h.height):i==="right"&&(this.position=o.e(l.right-h.width,h.y)),Point.s(o);return}else Util.o("scrolling unit must be 'pixel', 'line', 'page', or 'document', not: "+t);n/=this.scale;const r=this.position;i==="up"?this.position=o.e(r.x,r.y-n):i==="down"?this.position=o.e(r.x,r.y+n):i==="left"?this.position=o.e(r.x-n,r.y):i==="right"?this.position=o.e(r.x+n,r.y):Util.o("scrolling direction must be 'up', 'down', 'left', or 'right', not: "+i),Point.s(o)}scrollToRect(t){const i=this.viewportBounds;if(i.containsRect(t))return;const e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}centerRect(t){const i=this.viewportBounds,e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}transformDocToView(t){return t.copy().D(this.D)}transformViewToDoc(t){return t.copy().Ie(this.D)}LF(t){return t.Ie(this.D)}static None=1;static Uniform=2;static UniformToFill=3;static CycleAll=1;static CycleNotDirected=2;static CycleNotDirectedFast=3;static CycleNotUndirected=4;static CycleDestinationTree=5;static CycleSourceTree=6;static DocumentScroll=1;static InfiniteScroll=2;static TreeParentCollapsed=1;static AllParentsCollapsed=2;static AnyParentsCollapsed=3;get opacity(){return this.Wt}set opacity(t){const i=this.Wt;i!==t&&(Util.i(t,"number",Diagram,"opacity"),(t<0||t>1)&&Util._(t,"0 <= value <= 1",Diagram,"opacity"),this.Wt=t,this.t("opacity",i,t),this.C())}get validCycle(){return this.Rx}set validCycle(t){const i=this.Rx;i!==t&&(this.Rx=t,this.t("validCycle",i,t))}get layers(){return this.Gt.iterator}get isModelReadOnly(){const t=this.Si;return t===null?!1:t.isReadOnly}set isModelReadOnly(t){const i=this.Si;i!==null&&(i.isReadOnly=t)}get isReadOnly(){return this.vo}set isReadOnly(t){const i=this.vo;i!==t&&(Util.i(t,"boolean",Diagram,"isReadOnly"),this.vo=t,this.t("isReadOnly",i,t))}get isEnabled(){return this.Oi}set isEnabled(t){const i=this.Oi;i!==t&&(Util.i(t,"boolean",Diagram,"isEnabled"),this.Oi=t,this.t("isEnabled",i,t))}get allowClipboard(){return this.Vx}set allowClipboard(t){const i=this.Vx;i!==t&&(Util.i(t,"boolean",Diagram,"allowClipboard"),this.Vx=t,this.t("allowClipboard",i,t))}get allowCopy(){return this.Rl}set allowCopy(t){const i=this.Rl;i!==t&&(Util.i(t,"boolean",Diagram,"allowCopy"),this.Rl=t,this.t("allowCopy",i,t))}get allowDelete(){return this.vl}set allowDelete(t){const i=this.vl;i!==t&&(Util.i(t,"boolean",Diagram,"allowDelete"),this.vl=t,this.t("allowDelete",i,t))}get allowDragOut(){return this.zx}set allowDragOut(t){const i=this.zx;i!==t&&(Util.i(t,"boolean",Diagram,"allowDragOut"),this.zx=t,this.t("allowDragOut",i,t))}get allowDrop(){return this.Xx}set allowDrop(t){const i=this.Xx;i!==t&&(Util.i(t,"boolean",Diagram,"allowDrop"),this.Xx=t,this.t("allowDrop",i,t))}get allowTextEdit(){return this.Ol}set allowTextEdit(t){const i=this.Ol;i!==t&&(Util.i(t,"boolean",Diagram,"allowTextEdit"),this.Ol=t,this.t("allowTextEdit",i,t))}get allowGroup(){return this.Il}set allowGroup(t){const i=this.Il;i!==t&&(Util.i(t,"boolean",Diagram,"allowGroup"),this.Il=t,this.t("allowGroup",i,t))}get allowUngroup(){return this.El}set allowUngroup(t){const i=this.El;i!==t&&(Util.i(t,"boolean",Diagram,"allowUngroup"),this.El=t,this.t("allowUngroup",i,t))}get allowInsert(){return this.Kx}set allowInsert(t){const i=this.Kx;i!==t&&(Util.i(t,"boolean",Diagram,"allowInsert"),this.Kx=t,this.t("allowInsert",i,t))}get allowLink(){return this.Bl}set allowLink(t){const i=this.Bl;i!==t&&(Util.i(t,"boolean",Diagram,"allowLink"),this.Bl=t,this.t("allowLink",i,t))}get allowRelink(){return this.Ul}set allowRelink(t){const i=this.Ul;i!==t&&(Util.i(t,"boolean",Diagram,"allowRelink"),this.Ul=t,this.t("allowRelink",i,t))}get allowMove(){return this.Vl}set allowMove(t){const i=this.Vl;i!==t&&(Util.i(t,"boolean",Diagram,"allowMove"),this.Vl=t,this.t("allowMove",i,t))}get allowReshape(){return this.zl}set allowReshape(t){const i=this.zl;i!==t&&(Util.i(t,"boolean",Diagram,"allowReshape"),this.zl=t,this.t("allowReshape",i,t))}get allowResize(){return this.Xl}set allowResize(t){const i=this.Xl;i!==t&&(Util.i(t,"boolean",Diagram,"allowResize"),this.Xl=t,this.t("allowResize",i,t))}get allowRotate(){return this.Kl}set allowRotate(t){const i=this.Kl;i!==t&&(Util.i(t,"boolean",Diagram,"allowRotate"),this.Kl=t,this.t("allowRotate",i,t))}get allowSelect(){return this.Yl}set allowSelect(t){const i=this.Yl;i!==t&&(Util.i(t,"boolean",Diagram,"allowSelect"),this.Yl=t,this.t("allowSelect",i,t))}get allowUndo(){return this.Yx}set allowUndo(t){const i=this.Yx;i!==t&&(Util.i(t,"boolean",Diagram,"allowUndo"),this.Yx=t,this.t("allowUndo",i,t))}get allowZoom(){return this.Gx}set allowZoom(t){const i=this.Gx;i!==t&&(Util.i(t,"boolean",Diagram,"allowZoom"),this.Gx=t,this.t("allowZoom",i,t))}get hasVerticalScrollbar(){return this.Iu}set hasVerticalScrollbar(t){const i=this.Iu;i!==t&&(Util.i(t,"boolean",Diagram,"hasVerticalScrollbar"),this.Iu=t,this.ra(),this.C(),this.t("hasVerticalScrollbar",i,t),this.Us(!1))}get hasHorizontalScrollbar(){return this.Ou}set hasHorizontalScrollbar(t){const i=this.Ou;i!==t&&(Util.i(t,"boolean",Diagram,"hasHorizontalScrollbar"),this.Ou=t,this.ra(),this.C(),this.t("hasHorizontalScrollbar",i,t),this.Us(!1))}get allowHorizontalScroll(){return this.jx}set allowHorizontalScroll(t){const i=this.jx;i!==t&&(Util.i(t,"boolean",Diagram,"allowHorizontalScroll"),this.jx=t,this.t("allowHorizontalScroll",i,t),this.Us(!1))}get allowVerticalScroll(){return this.Hx}set allowVerticalScroll(t){const i=this.Hx;i!==t&&(Util.i(t,"boolean",Diagram,"allowVerticalScroll"),this.Hx=t,this.t("allowVerticalScroll",i,t),this.Us(!1))}get scrollHorizontalLineChange(){return this.qx}set scrollHorizontalLineChange(t){const i=this.qx;i!==t&&(Util.i(t,"number",Diagram,"scrollHorizontalLineChange"),t<0&&Util._(t,">= 0",Diagram,"scrollHorizontalLineChange"),this.qx=t,this.t("scrollHorizontalLineChange",i,t))}get scrollVerticalLineChange(){return this.Wx}set scrollVerticalLineChange(t){const i=this.Wx;i!==t&&(Util.i(t,"number",Diagram,"scrollVerticalLineChange"),t<0&&Util._(t,">= 0",Diagram,"scrollVerticalLineChange"),this.Wx=t,this.t("scrollVerticalLineChange",i,t))}get lastInput(){return this.$h}set lastInput(t){this.$h=t}get previousInput(){return this.Xr}set previousInput(t){this.Xr=t}get firstInput(){return this.Wm}set firstInput(t){this.Wm=t}get currentCursor(){return this.vx}set currentCursor(t){if(t===""&&(t=this.Xm),this.vx!==t){Util.i(t,"string",Diagram,"currentCursor");const e=this.dt,s=this.Tt;if(e===null||s===null)return;this.vx=t;const n=e.style.cursor;e.style.cursor=t,s.style.cursor=t,e.style.cursor===n&&(e.style.cursor="-webkit-"+t,s.style.cursor="-webkit-"+t,e.style.cursor===n&&(e.style.cursor="-moz-"+t,s.style.cursor="-moz-"+t,e.style.cursor===n&&(e.style.cursor=t,s.style.cursor=t)))}}get defaultCursor(){return this.Xm}set defaultCursor(t){t===""&&(t="auto");const i=this.Xm;i!==t&&(Util.i(t,"string",Diagram,"defaultCursor"),this.Xm=t,this.t("defaultCursor",i,t))}get click(){return this.Tr}set click(t){const i=this.Tr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"click"),this.Tr=t,this.t("click",i,t))}get doubleClick(){return this.Dr}set doubleClick(t){const i=this.Dr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"doubleClick"),this.Dr=t,this.t("doubleClick",i,t))}get contextClick(){return this.Fr}set contextClick(t){const i=this.Fr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"contextClick"),this.Fr=t,this.t("contextClick",i,t))}get mouseOver(){return this.Rr}set mouseOver(t){const i=this.Rr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseOver"),this.Rr=t,this.t("mouseOver",i,t))}get mouseHover(){return this.vr}set mouseHover(t){const i=this.vr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseHover"),this.vr=t,this.t("mouseHover",i,t))}get mouseHold(){return this.Or}set mouseHold(t){const i=this.Or;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseHold"),this.Or=t,this.t("mouseHold",i,t))}get mouseDragOver(){return this.Ox}set mouseDragOver(t){const i=this.Ox;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseDragOver"),this.Ox=t,this.t("mouseDragOver",i,t))}get mouseDrop(){return this.Ir}set mouseDrop(t){const i=this.Ir;i!==t&&(this.Ir=t,this.t("mouseDrop",i,t))}get handlesDragDropForTopLevelParts(){return this.Ix}set handlesDragDropForTopLevelParts(t){const i=this.Ix;i!==t&&(Util.i(t,"boolean",Diagram,"handlesDragDropForTopLevelParts"),this.Ix=t,this.t("handlesDragDropForTopLevelParts",i,t))}get mouseEnter(){return this.Er}set mouseEnter(t){const i=this.Er;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseEnter"),this.Er=t,this.t("mouseEnter",i,t))}get mouseLeave(){return this.Br}set mouseLeave(t){const i=this.Br;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseLeave"),this.Br=t,this.t("mouseLeave",i,t))}get toolTip(){return this.Ur}set toolTip(t){const i=this.Ur;i!==t&&(this.Ur=t,this.t("toolTip",i,t))}get contextMenu(){return this.Vr}set contextMenu(t){const i=this.Vr;i!==t&&(this.Vr=t,this.t("contextMenu",i,t))}get commandHandler(){return this.HS}set commandHandler(t){this.HS!==t&&(this.HS=t,t.To(this))}get toolManager(){return this.YS}set toolManager(t){this.YS!==t&&(this.YS=t,t.diagram=this)}get defaultTool(){return this.GS}set defaultTool(t){const i=this.GS;i!==t&&(this.GS=t,t.diagram=this,this.currentTool===i&&(this.currentTool=t))}get currentTool(){return this.jS}set currentTool(t){const i=this.jS;i&&(i.isActive&&i.doDeactivate(),i.cancelWaitAfter(),i.doStop()),t===null&&(t=this.defaultTool),t!==null&&(this.jS=t,t.diagram=this,t.doStart())}get selection(){return this._S}get maxSelectionCount(){return this.Qx}set maxSelectionCount(t){const i=this.Qx;if(i!==t)if(Util.i(t,"number",Diagram,"maxSelectionCount"),t>=0&&!isNaN(t)){if(this.Qx=t,this.t("maxSelectionCount",i,t),!this.undoManager.isUndoingRedoing){const e=this.selection.count-t;if(e>0){this.v("ChangingSelection",this.selection);const s=this.selection.toArray();for(let n=0;n= 0",Diagram,"maxSelectionCount")}get nodeSelectionAdornmentTemplate(){return this.jm}set nodeSelectionAdornmentTemplate(t){const i=this.jm;i!==t&&(this.jm=t,this.t("nodeSelectionAdornmentTemplate",i,t))}get groupSelectionAdornmentTemplate(){return this.ib}set groupSelectionAdornmentTemplate(t){const i=this.ib;i!==t&&(this.ib=t,this.t("groupSelectionAdornmentTemplate",i,t))}get linkSelectionAdornmentTemplate(){return this.eb}set linkSelectionAdornmentTemplate(t){const i=this.eb;i!==t&&(this.eb=t,this.t("linkSelectionAdornmentTemplate",i,t))}get highlighteds(){return this.tM}get isModified(){const t=this.undoManager;return t.isEnabled?t.currentTransaction!==null?!0:this.Uu&&this.vs!==t.historyIndex:this.Uu}set isModified(t){if(this.Uu!==t){Util.i(t,"boolean",Diagram,"isModified"),this.Uu=t;const e=this.undoManager;!t&&e.isEnabled&&(this.vs=e.historyIndex),t||this.vL()}}vL(){const t=this.isModified;this.ZS!==t&&(this.ZS=t,this.v("Modified"))}get model(){return this.Si}set model(t){const i=this.Si;if(i!==t){this.currentTool.doCancel(),i&&i.undoManager!==t.undoManager&&i.undoManager.isInTransaction&&Util.o("Do not replace a Diagram.model while a transaction is in progress."),this.animationManager.stopAnimation(!0);const e=this.gL(!0);this.Jn=!1,this.vu=!0,this.vs=-2,this.Pr=!1;const s=this.Ht;this.Ht=!0,this.animationManager.Fl("Model"),i&&(this.qn!==null&&this.qn.each(n=>i.removeChangedListener(n)),i.removeChangedListener(this.$S)),this.Si=t,this.partManager=this.cR(this.Si.type),this.initializePartManager(this.partManager);for(let n=0;nt.addChangedListener(n)),this.Ht=s,this.invalidateDocumentBounds(),this.Ht||this.C(),i&&t.undoManager.copyProperties(i.undoManager)}}get themeManager(){return this.gb}set themeManager(t){const i=this.gb;i!==t&&(i!==null&&i.removeDiagram(this),this.gb=t,t!==null&&t.addDiagram(this))}initializePartManager(t){}static gM(t,i){Diagram.hL.set(t,i)}static get licenseKey(){return Diagram.AM.last()}static set licenseKey(t){Diagram.AM.add(t.replace(/\s/g,""))}static get version(){return Diagram.fR}static AM=new List;static fR="3.0.12";cR(t){const i=Diagram.hL.get(t);return i!==null?new i:new PartManager}get Y(){return this.WS}set Y(t){this.WS=t}get mx(){return this.oL}uR(t){if(t.model!==this.model)return;const i=t.change,e=t.propertyName;if(i===1&&e[0]==="S"){if(e==="StartingFirstTransaction"){const s=this,n=this.toolManager;n.mouseDownTools.each(o=>o.diagram=s),n.mouseMoveTools.each(o=>o.diagram=s),n.mouseUpTools.each(o=>o.diagram=s),this.routers.each(o=>o.diagram=s),!this.ps&&!this.Jn&&(this.Oc=!0,this.vu&&(this.Pr=!0))}else if(e==="StartingUndo"||e==="StartingRedo"){const s=this.animationManager;this.skipsUndoManager||(s.defaultAnimation.isAnimating&&s.stopAnimation(),s.getBundleAnimation().isAnimating&&s.getBundleAnimation().stop()),this.v("ChangingSelection",this.selection)}else if(e==="StartedTransaction"){const s=this.animationManager;s.defaultAnimation.isAnimating&&!this.skipsUndoManager&&s.stopAnimation()}return}if(this.Y){this.Y=!1;try{if(t.modelChange===""&&i===1){(e==="FinishedUndo"||e==="FinishedRedo")&&(this.v("ChangedSelection",this.selection),this.Ci());const s=this.animationManager;e==="RolledBackTransaction"&&s.stopAnimation(),this._C(),this.Oc=!0,this.maybeUpdate(),(this.undoManager.transactionLevel===0||this.undoManager.transactionLevel===1)&&s.SS(),e==="CommittedTransaction"&&this.undoManager.isJustDiscarded&&(this.vs=Math.min(this.vs,this.undoManager.historyIndex-1)),(e==="CommittedTransaction"||e==="RolledBackTransaction")&&this.undoManager.Iw&&setTimeout(()=>{this.isModified=!1},1);const n=t.isTransactionFinished;if(n&&(this.vL(),this.mx.clear(),this.animationManager.fF()),!this.Ex&&n&&this.lastInput.targetDiagram){this.Ex=!0;const o=this;Util.Oh(()=>{o.currentTool.standardMouseOver(),o.Ex=!1},10)}}}finally{this.Y=!0}}}get fe(){return this.qS}set fe(t){this.qS=t}get dc(){return this.Bx}set dc(t){this.Bx=t}SL(t){const i=t.L.r;for(const e of i)e instanceof Picture&&this.TM(e)}TM(t){const i=t.element;if(i===null||!(i instanceof HTMLImageElement)||(i.es instanceof GSet&&i.es.add(this),t.dR(),!i.c0))return;const e=i.getAttribute("src")||"",s=this.Jl.get(e);if(s===null){Picture.OL(t,i);const n=[];n.push(t),this.Jl.set(e,n)}else{for(let n=0;n0?(this.kx=t,this.t("minScale",i,t),t>this.scale&&(this.scale=t)):Util._(t,"> 0",Diagram,"minScale"))}get maxScale(){return this.Px}set maxScale(t){const i=this.Px;i!==t&&(t>0?(this.Px=t,this.t("maxScale",i,t),t 0",Diagram,"maxScale"))}get zoomPoint(){return this.Sx}set zoomPoint(t){this.Sx.equals(t)||(t=t.N(),this.Sx=t)}get contentAlignment(){return this.Rc}set contentAlignment(t){const i=this.Rc;i.equals(t)||(t=t.N(),this.Rc=t,this.t("contentAlignment",i,t),this.Us(!1))}get initialContentAlignment(){return this.Um}set initialContentAlignment(t){const i=this.Um;i.equals(t)||(t=t.N(),this.Um=t,this.t("initialContentAlignment",i,t))}get padding(){return this.$t}set padding(t){typeof t=="number"&&(t=new Margin(t));const i=this.$t;i.equals(t)||(t=t.N(),this.$t=t,this.invalidateDocumentBounds(),this.t("padding",i,t))}get partManager(){return this.oM}set partManager(t){const i=this.oM;i!==t&&(t.diagram!==null&&Util.o("Cannot share PartManagers between Diagrams: "+t.toString()),i&&i.To(null),this.oM=t,t.To(this))}get nodes(){return this.partManager.nodes.iterator}get links(){return this.partManager.links.iterator}get parts(){return this.partManager.parts.iterator}findTopLevelNodesAndLinks(){const t=new GSet,i=this.nodes;for(;i.next();){const s=i.value;s.isTopLevel&&t.add(s)}const e=this.links;for(;e.next();){const s=e.value;s.isTopLevel&&t.add(s)}return t.iterator}findTopLevelGroups(){return this.Yr.iterator}get routers(){return this.zc}doLinkRouting(t){this.Fo=!0;const i=this.zc.r;for(let e=0;e0){const l=this.computePartsBounds(n.memberParts,!1);l.inflate(20,20),s.kb(l)}const o=Rect.l(),r=n.memberParts;for(;r.next();){const l=r.value;l instanceof Node&&this.IM(l,e,o)}Rect.s(o)}s.ha=n,s.RM=e,s.Eo=!1}else t&&s.zL();return s}get avoidanceCellSize(){return this.iM}set avoidanceCellSize(t){this.Hl=null,this.iM=new Size(Math.max(1,t.width),Math.max(1,t.height))}get avoidanceLimit(){return this.eM}set avoidanceLimit(t){this.eM=Math.max(1,t)}VL(t){return t.canAvoid()?t:t.containingGroup!==null?this.VL(t.containingGroup):null}IM(t,i,e){if(t===i||!t.isVisible())return;const s=t.canAvoid();if(s){const n=t.getAvoidableRect(e);this.Hl.pR(n.x,n.y,n.width,n.height)}if(t instanceof Group&&(!s||t.avoidableMembers)){const n=t.memberParts;for(;n.next();){const o=n.value;o instanceof Node&&this.IM(o,i,e)}}}EM(t){this.Hl!==null&&!this.Hl.Eo&&(t===void 0||t.canAvoid())&&(this.Hl.Eo=!0)}get autoScrollInterval(){return this.Vm}set autoScrollInterval(t){const i=this.Vm;i!==t&&(this.Vm=t,this.t("autoScrollInterval",i,t))}get autoScrollRegion(){return this.zm}set autoScrollRegion(t){typeof t=="number"&&(t=new Margin(t));const i=this.zm;i.equals(t)||(t=t.N(),this.zm=t,this.invalidateDocumentBounds(),this.t("autoScrollRegion",i,t))}doAutoScroll(t){this.qm.a(t),this.computeAutoScrollPosition(this.qm).equalsApprox(this.position)?this.stopAutoScroll():this.XL()}XL(){if(this.vc!==-1)return;const t=this.Vm,i=this;this.vc=Util.Oh(()=>{if(i.vc===-1||(i.stopAutoScroll(),i.lastInput.event===null))return;const s=i.computeAutoScrollPosition(i.qm);if(s.equalsApprox(i.position))return;i.position=s,i.lastInput.documentPoint=i.transformViewToDoc(i.qm),i.doMouseMove(),i.Zh=!0;const n=Rect.l();i.computeBounds(n),n.unionRect(i.documentBounds),i.IL(n),Rect.s(n),i.Ue=!0,i.maybeUpdate(),i.XL()},t)}stopAutoScroll(){this.vc!==-1&&(Util.Og(this.vc),this.vc=-1)}computeAutoScrollPosition(t){let i=this.position;const e=this.zm;if(e.top<=0&&e.left<=0&&e.right<=0&&e.bottom<=0)return i;const s=this.viewportBounds,n=this.scale,o=Rect.X(0,0,s.width*n,s.height*n),r=Point.X(0,0);if(t.x>=o.x&&t.xo.x+o.width-e.right&&this.allowHorizontalScroll){let l=Math.max(this.scrollHorizontalLineChange,1);l=l|0,r.x+=l,t.x>o.x+o.width-e.right/2&&(r.x+=l),t.x>o.x+o.width-e.right/4&&(r.x+=4*l)}if(t.y>=o.y&&t.yo.y+o.height-e.bottom&&this.allowVerticalScroll){let l=Math.max(this.scrollVerticalLineChange,1);l=l|0,r.y+=l,t.y>o.y+o.height-e.bottom/2&&(r.y+=l),t.y>o.y+o.height-e.bottom/4&&(r.y+=4*l)}return r.equalsApprox(Point.Po)||(i=new Point(i.x+r.x/n,i.y+r.y/n)),Rect.s(o),Point.s(r),i}makeSvg(t){this.Wl.has("SVG")||this.addRenderer("SVG",new SVGSurface(this,root.document));const i=new SVGSurface(this,root.document,!0);t===void 0&&(t={});const e=this;function s(n,o){const r=e.KL(n,"SVG",i),l=r!==null?r.svg:null;return typeof o=="function"?(o(l),null):l}return this.YL(s,t)}makeSVG(t){return this.makeSvg(t)}addRenderer(t,i){this.Wl.set(t,i)}removeRenderer(t){this.Wl.delete(t)}cacheGroupExternalLinks(t){this.dM=t,t||this.nodes.each(i=>{i instanceof Group&&(i.u0=null)})}YL(t,i){const e=i.callback;let s=!0;const o=this.Jl.iterator;for(;o.next();)if(!o.value[0].mn){s=!1;break}if(typeof e!="function"||s)return t(i,e,this);const r=this;function l(){const c=+new Date;for(s=!0,o.reset();o.next();)if(!o.value[0].mn){s=!1;break}if(s||c-a>h){t(i,e,r);return}root.requestAnimationFrame(l)}const h=i.callbackTimeout||300,a=+new Date;return root.requestAnimationFrame(()=>l()),null}makeImage(t){return Diagram.isUsingDOM()?(t===void 0&&(t={}),t.returnType="Image",this.makeImageData(t)):null}makeImageData(t){return t===void 0&&(t={}),this.YL(this.yR,t)}static img="image";yR(t,i,e){const s=e.KL(t,"canvas",null);if(s===null)return null;const n=s.U.canvas;let o=null;if(n!==null){let r=t.returnType;switch(r===void 0?r="string":r=r.toLowerCase(),r){case Diagram.img+"data":o=s.getImageData(0,0,n.width,n.height);break;case Diagram.img:const h=(t.document||document).createElement("img");h.src=n.toDataURL(t.type,t.details),o=h;break;case"blob":{const a=n;return typeof i!="function"&&(o="",Util.o('Error: Diagram.makeImageData called with "returnType: toBlob", but no required "callback" function property defined.')),typeof a.toBlob=="function"?(a.toBlob(i,t.type,t.details),"toBlob"):(i(null),null)}case"string":default:o=n.toDataURL(t.type,t.details)}}return typeof i=="function"?(i(o),null):o}static wR=!1;KL(t,i,e){if(this.animationManager.stopAnimation(),this.maybeUpdate(),this.dt===null)return null;typeof t!="object"&&Util.o("properties argument must be an Object.");let n=!1,o=t.size||null,r=t.scale||null;t.scale!==void 0&&isNaN(t.scale)&&(r="NaN");let l=t.maxSize;t.maxSize===void 0&&(n=!0,i==="SVG"?l=new Size(1/0,1/0):l=new Size(2e3,2e3));const h=t.position||null;let a=t.parts||null;Array.isArray(a)&&(a=new List(a));let c=t.padding===void 0?1:t.padding;const f=t.background||null;let u=t.omitTemporary;u===void 0&&(u=!0);const d=t.document||document,m=t.elementFinished||null;let g=t.showTemporary;g===void 0&&(g=!u);let p=t.showGrid;p===void 0&&(p=g),o!==null&&isNaN(o.width)&&isNaN(o.height)&&(o=null),typeof c=="number"?c=new Margin(c):c instanceof Margin||Util.o("MakeImage padding must be a Margin or a number."),c.left=Math.max(c.left,0),c.right=Math.max(c.right,0),c.top=Math.max(c.top,0),c.bottom=Math.max(c.bottom,0),this.Zt.clearContextCache(!0);const y=new CanvasSurface(null,d,void 0,!0),x=y.ai;if(!(o||r||a||h))return y.width=this.kt+Math.ceil(c.left+c.right),y.height=this.Pt+Math.ceil(c.top+c.bottom),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.aa=d,e.Gu=m,this.wb(e.ai,c,new Size(y.width,y.height),this.et,this.at,a,f,g,p),e.ai):(this.Vu=!1,this.wb(x,c,new Size(y.width,y.height),this.et,this.at,a,f,g,p),this.Vu=!0,y.ai);const k=this.Jm,b=this.documentBounds.copy();if(b.subtractMargin(this.$t),g){const A=this.Gt.r,D=A.length;for(let F=0;Fk?(r=k,N=b.width,T=b.height):(N=l.width,T=l.height)):(N=b.width*r,T=b.height*r):(r=k,N=b.width,T=b.height),c!==null?(N+=S,T+=L):c=new Margin(0),l!==null){let A=l.width,D=l.height;i!=="SVG"&&n&&Diagram.wR,isNaN(A)&&(A=2e3),isNaN(D)&&(D=2e3),isFinite(A)&&(N=Math.min(N,A)),isFinite(D)&&(T=Math.min(T,D))}return y.width=Math.ceil(N),y.height=Math.ceil(T),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.aa=d,e.Gu=m,this.wb(e.ai,c,new Size(Math.ceil(N),Math.ceil(T)),r,P,a,f,g,p),e.ai):(this.Vu=!1,this.wb(x,c,new Size(Math.ceil(N),Math.ceil(T)),r,P,a,f,g,p),this.Vu=!0,y.ai)}static Ku=null;static GL="5da73c80a36555d4038e4972187c3cae51fd22";static uw=!1;static Ik=()=>{if(Diagram.GL[5]===void 0&&(Transform.prototype._e=Transform.prototype.ww),!Diagram.isUsingDOM())return;const t=root.document.createElement("canvas"),i=t.getContext("2d"),e=Util.Cs("7ca11abfd022028846");i[e]=Util.Cs("398c3597c01238");const s="7ca11abfd7330390",n=[Diagram.GL,Util.uw+"4ae6247590da4bb21c324ba3a84e385776",Transform.Ik+"fb236cdfda5de14c134ba1a95a2d4c7cc6f93c1387",Geo.za],o=10,r=0;for(let l=1;l<5;l++)i[Util.Cs(s)](Util.Cs(n[l-1]),o,l*15+r);i[e]=Util.Cs("39f046ebb36e4b");for(let l=1;l<5;l++)i[Util.Cs(s)](Util.Cs(n[l-1]),o,l*15+r);(n.length!==4||n[0][0]!=="5"||n[3][0]!=="7")&&(Transform.prototype._e=Transform.prototype.ww),Diagram.Ku=t}}class DiagramHelper{jL;HL;BM;Ne;constructor(t){if(this.jL=null,this.HL="63ad05bbe23a1786468a4c741b6d2",this.BM="@onz",this.HL===this._tk){this.BM=!0,this.Ne=this.BM;return}this.Ne=null}xR(t,i){let e="f";const s=root[Util.Cs("76a715b2f73f148a")][Util.Cs("72ba13b5")]||"",n=Util.Cs;if(this.Ne=!0,!Diagram.isUsingDOM())return;let o=Diagram[n("76a115b6ed251eaf4692")];if(!o){const l=s[n("76ad18b4f73e")];for(let a=s[n("73a612b6fb191d")](n("35e7"))+2;a=0&&ha[0]||h[0]===a[0]&&h[1]>=a[1]))continue;const c="73a612b6fb191d",f=root[n("74a900bae4370f8b51")][n("6fbb13a1c2311e8a57")].toLowerCase(),u=f[n(c)](n("3aad1ab6e022098b4dc4")),d=n(l[2]);if(u>-1){const M=f[n(c)](d.toLowerCase()+"/");if(this.Ne=!(M>-1&&M=0&&g-1),!this.Ne))return;const p=root[Util.Cs("76a715b2f73f148a")][Util.Cs("69ad17a1e03e")],y=p[n(c)](n("7fb002b6ed25128b4da25b2e"));if(y>-1&&(this.Ne=!(p[n(c)](d)>y),!this.Ne))return;const x=d;if(x[0]!=="#")continue;const k=root.document.createElement("div");let b=l[0].replace(/[A-Za-z]/g,"");for(;b.length<4;)b+="9";const P=b;b=b.substring(b.length-4);let S="";const L=["gsh","gsf"],C=["Header","Background","Display","Feedback"];if(S+=L[parseInt(b.substring(0,1),10)%2],S+=C[parseInt(b.substring(0,1),10)%4],k[n("79a417a0f0181a8946")]=S,root.document[n("78a712aa")]){root.document[n("78a712aa")][n("7bb806b6ed32388c4a875b")](k);const M=root.getComputedStyle(k).getPropertyValue(n("78a704b7e62456904c9b12701b6532a8")),N=root.getComputedStyle(k).getPropertyValue(n("75b817b0ea2202"));if(root.document[n("78a712aa")][n("68ad1bbcf533388c4a875b")](k),!M)continue;const T=root[n("77a902b0eb1b1e804a8a")],A="0."+parseInt(P,10)%100;if(N===A||M.indexOf(parseInt(x[1]+x[2],16))!==-1&&M.indexOf(parseInt(x[3]+x[4],16))!==-1){this.Ne=!1;return}else if(T&&T(n("32ae19a1e0331fc94084537c067a67fa59f1386b89d006")).matches){S="."+S;for(let D=0;D{const s=this.observed;if(s===null)return;const n=s.viewportBounds,o=this.lastInput.documentPoint;s.position=new Point(o.x-n.width/2,o.y-n.height/2)},this.zM=s=>{this.invalidateDocumentBounds(),this.g0()},this.XM=s=>{this.observed!==null&&(this.invalidateDocumentBounds(),this.C())},this.Cb=s=>{this.updateDelay<1?this.C():this.d0||(this.d0=!0,setTimeout(()=>this.redraw(),this.updateDelay))},this.KM=s=>{this.observed!==null&&this.g0()},this.autoScale=2,this.Ht=!1,i&&Object.assign(this,i),this}setupRouters(){}computePixelRatio(){return 1}redraw(){this.d0&&this.updateDelay>=1&&(this.d0=!1,this.bR()),super.redraw()}Gi(){if(this.Tt===null&&Util.o("No div specified"),this.dt===null&&Util.o("No canvas specified"),this.dt instanceof SVGSurface||(this.box.US(),!this.Ue))return;const t=this.observed;if(t===null||t.animationManager.defaultAnimation.isAnimating||!t.Bh)return;this.l0();const i=this.dt,e=this.Zt;if(e.clearContextCache(!0),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,i.width,i.height),this.updateDelay<1)this.WL();else if(this.jc!==null){e.drawImage(this.jc.Ft,0,0);const o=this.D;e.scale(this.Ui,this.Ui),e.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),e.commitTransform()}const s=this.Gt.r,n=s.length;for(let o=0;on.canDelete())}t.removeParts(i,!0),t.v("SelectionDeleted",i)}finally{t.commitTransaction("Delete"),t.v("ChangedSelection",t.selection),t.currentCursor=""}}canDeleteSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowDelete||t.selection.count===0)}copySelection(){const t=this.diagram;try{const i=new GSet,e=t.selection.iterator;for(;e.next();){const s=e.value;Part.sh(i,s,!0,this.copiesTree?1/0:0,this.copiesConnectedLinks,n=>n.canCopy())}this.copyToClipboard(i)}finally{}}canCopySelection(){const t=this.diagram;return!(!t.allowCopy||!t.allowClipboard||t.selection.count===0)}cutSelection(){this.copySelection(),this.deleteSelection()}canCutSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowCopy||!t.allowDelete||!t.allowClipboard||t.selection.count===0)}copyToClipboard(t){const i=this.diagram;let e=null;if(t===null)Diagram.dL();else{const s=i.model;let n=!1,o=!1,r=null;try{s.pc()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.gc()||s.ju())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=i.copyParts(t,null,!0)}finally{s.pc()&&(s.copiesParentKeyOfNodeData=n),(s.gc()||s.ju())&&(s.copiesGroupKeyOfNodeData=o),e=new List,e.addAll(r.iteratorValues),Diagram.e0=e,Diagram.mb=i.model.dataFormat}}i.v("ClipboardChanged",e)}pasteFromClipboard(){const t=new GSet,i=Diagram.e0;if(i===null)return t;const e=this.diagram;if(Diagram.mb!==e.model.dataFormat)return t;const s=e.model;let n=!1,o=!1,r=null;try{s.pc()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.gc()||s.ju())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=e.copyParts(i,e,!1)}finally{s.pc()&&(s.copiesParentKeyOfNodeData=n),(s.gc()||s.ju())&&(s.copiesGroupKeyOfNodeData=o);const l=r.iterator;for(;l.next();){const h=l.value,a=l.key;h.location.isReal()||(a.location.isReal()?h.location=a.location:!h.position.isReal()&&a.position.isReal()&&(h.position=a.position)),t.add(h)}}return t}pasteSelection(t){t===void 0&&(t=null);const i=this.diagram;try{i.currentCursor="wait",i.v("ChangingSelection",i.selection),i.startTransaction("Paste");const e=this.pasteFromClipboard();e.count>0&&i.clearSelection(!0);const s=e.iterator;for(;s.next();){const n=s.value;n.isSelected=!0}if(t!==null){const n=i.computePartsBounds(i.selection);if(n.isReal()){const o=this.computeEffectiveCollection(i.selection,i.fb);i.bP(o,new Point(t.x-n.centerX,t.y-n.centerY),i.fb,!1)}}i.v("ClipboardPasted",e)}finally{i.commitTransaction("Paste"),i.v("ChangedSelection",i.selection),i.currentCursor=""}}canPasteSelection(t){const i=this.diagram;return!(i.isReadOnly||i.isModelReadOnly||!i.allowInsert||!i.allowClipboard||Diagram.e0===null||Diagram.e0.count===0||Diagram.mb!==i.model.dataFormat)}undo(){this.diagram.undoManager.undo()}canUndo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canUndo()}redo(){this.diagram.undoManager.redo()}canRedo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canRedo()}decreaseZoom(t){t===void 0&&(t=1/this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canDecreaseZoom(t){t===void 0&&(t=1/this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}increaseZoom(t){t===void 0&&(t=this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canIncreaseZoom(t){t===void 0&&(t=this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}resetZoom(t){t===void 0&&(t=this.defaultScale);const i=this.diagram;ti.maxScale||(i.scale=t)}canResetZoom(t){t===void 0&&(t=this.defaultScale);const i=this.diagram;return ti.maxScale?!1:i.allowZoom}zoomToFit(){const t=this.diagram,i=t.animationManager;i.stopAnimation(),t.redraw();const e=t.position,s=t.scale;i.Fl("Zoom To Fit"),this.isZoomToFitRestoreEnabled&&s===this.Ab&&!isNaN(this.Lb)&&t.documentBounds.equals(this.Tb)?(t.scale=this.Lb,t.position=this.QM,this.Ab=NaN,this.Tb=Rect.pw):(this.Lb=s,this.QM=e.copy(),t.zoomToFit(),this.Ab=t.scale,this.Tb=t.documentBounds.copy()),i.SS()}canZoomToFit(){return this.diagram.allowZoom}scrollToPart(t){t===void 0&&(t=null);const i=this.diagram;if(i.ensureBounds(),t===null){try{this.Bo!==null&&(this.Bo.next()?t=this.Bo.value:this.Bo=null)}catch{this.Bo=null}t===null&&(i.highlighteds.count>0?this.Bo=i.highlighteds.iterator:i.selection.count>0&&(this.Bo=i.selection.iterator),this.Bo!==null&&this.Bo.next()&&(t=this.Bo.value))}if(t!==null){const e=i.animationManager;e.Fl("Scroll To Part");const s=this.scrollToPartPause;if(s>0){const n=this.Hc(t,[t]);if(n.length===1)i.startTransaction(),i.centerRect(t.actualBounds),i.commitTransaction("Scroll To Part");else{const o=()=>{i.startTransaction();let l=n.pop();for(;n.length>0&&l instanceof Node&&l.isTreeExpanded&&(!(l instanceof Group)||l.isSubGraphExpanded);)l=n.pop();n.length>0?(l instanceof Part&&i.scrollToRect(l.actualBounds),l instanceof Node&&!l.isTreeExpanded&&(l.isTreeExpanded=!0),l instanceof Group&&!l.isSubGraphExpanded&&(l.isSubGraphExpanded=!0)):(l instanceof Part&&i.centerRect(l.actualBounds),i.removeDiagramListener("LayoutCompleted",r)),i.commitTransaction("Scroll To Part")},r=()=>{Util.Oh(o,(e.isEnabled?e.duration:0)+s)};i.addDiagramListener("LayoutCompleted",r),o()}}else{const n=i.position.copy();i.centerRect(t.actualBounds),n.equalsApprox(i.position)&&e.stopAnimation()}}}Hc(t,i){if(t.isVisible())return i;if(t instanceof Adornment)this.Hc(t.adornedPart,i);else if(t instanceof Link){const e=t.fromNode;e!==null&&this.Hc(e,i);const s=t.toNode;s!==null&&this.Hc(s,i)}else{if(t instanceof Node){const s=t.labeledLink;s!==null&&this.Hc(s,i);const n=t.findTreeParentNode();n!==null&&(!n.isTreeExpanded&&!n.wasTreeExpanded&&i.push(n),this.Hc(n,i))}const e=t.containingGroup;e!==null&&(!e.isSubGraphExpanded&&!e.wasSubGraphExpanded&&i.push(e),this.Hc(e,i))}return i}canScrollToPart(t){if(t===void 0&&(t=null),t!==null&&!(t instanceof Part))return!1;const i=this.diagram;return i.selection.count===0&&i.highlighteds.count===0?!1:i.allowHorizontalScroll&&i.allowVerticalScroll}collapseTree(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse Tree";try{i.startTransaction(e),i.animationManager.Fl(e);const n=new List;if(t!==null&&t.isTreeExpanded)t.collapseTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&r.isTreeExpanded&&(r.collapseTree(),n.add(r))}}i.v("TreeCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||!t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(!s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}expandTree(t){t===void 0&&(t=null);const i=this.diagram,e="Expand Tree";try{i.startTransaction(e),i.animationManager.Fl(e);const n=new List;if(t!==null&&!t.isTreeExpanded)t.expandTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&(r.isTreeExpanded||(r.expandTree(),n.add(r)))}}i.v("TreeExpanded",n)}finally{i.commitTransaction(e)}}canExpandTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}groupSelection(){const t=this.diagram,i=t.model;if(!i.qc())return;const e=this.archetypeGroupData;if(e===null)return;let s=null;try{t.currentCursor="wait",t.v("ChangingSelection",t.selection),t.startTransaction("Group");const n=new List,o=t.selection.iterator;for(;o.next();){const h=o.value;h.Pe()&&h.canGroup()&&n.add(h)}const r=new List,l=n.iterator;for(;l.next();){const h=l.value;let a=!1;const c=n.iterator;for(;c.next();){const f=c.value;if(h.isMemberOf(f)){a=!0;break}}a||r.add(h)}if(r.count>0){let h=r.first().containingGroup;if(h!==null)for(;h!==null;){let a=!1;const c=r.iterator;for(;c.next();)if(!c.value.isMemberOf(h)){a=!0;break}if(a)h=h.containingGroup;else break}if(e instanceof Group)e.li(),s=e.copy(),s!==null&&t.add(s);else if(i.isGroupForData(e)){const a=i.copyNodeData(e);Util.wt(a)&&(i.addNodeData(a),s=t.findNodeForData(a))}if(s!==null){h!==null&&this.isValidMember(h,s)&&(s.containingGroup=h);const a=r.iterator;for(;a.next();){const c=a.value;this.isValidMember(s,c)&&(c.containingGroup=s)}t.clearSelection(!0),s.isSelected=!0}}t.v("SelectionGrouped",s)}finally{t.commitTransaction("Group"),t.v("ChangedSelection",t.selection),t.currentCursor=""}}canGroupSelection(){const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowGroup||!t.model.qc()||this.archetypeGroupData===null)return!1;const e=t.selection.iterator;for(;e.next();){const s=e.value;if(s.Pe()&&s.canGroup())return!0}return!1}i2(t){const i=Util.nt();if(Array.isArray(t))t.forEach(n=>{n instanceof Link||n instanceof Part&&i.push(n)});else{const n=t.iterator;for(;n.next();){const o=n.value;o instanceof Link||o instanceof Part&&i.push(o)}}const e=new GSet,s=i.length;for(let n=0;n0){i.clearSelection(!0);const o=s.iterator;for(;o.next();){const r=o.value;r.expandSubGraph();const l=r.containingGroup,h=l!==null&&l.data!==null?e.getKeyForNodeData(l.data):void 0;n.addAll(r.memberParts);const a=n.iterator;for(;a.next();){const c=a.value;if(c.isSelected=!0,c instanceof Link)continue;const f=c.data;f!==null?e.setGroupForData(f,h):c.containingGroup=l}i.remove(r)}}i.v("SelectionUngrouped",s,n)}finally{i.commitTransaction("Ungroup"),i.v("ChangedSelection",i.selection),i.currentCursor=""}}canUngroupSelection(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowDelete||!i.allowUngroup||!i.model.qc())return!1;if(t!==null){if(!(t instanceof Group))return!1;if(t.canUngroup())return!0}else{const s=i.selection.iterator;for(;s.next();){const n=s.value;if(n instanceof Group&&n.canUngroup())return!0}}return!1}addTopLevelParts(t,i){const e=this.i2(t);let s=!0;const n=e.iterator;for(;n.next();){const o=n.value;o.containingGroup!==null&&(!i||this.isValidMember(null,o)?o.containingGroup=null:s=!1)}return s}collapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse SubGraph";try{i.startTransaction(e),i.animationManager.Fl(e);const n=new List;if(t!==null&&t.isSubGraphExpanded)t.collapseSubGraph(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&r.isSubGraphExpanded&&(r.collapseSubGraph(),n.add(r))}}i.v("SubGraphCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||!t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&s.isSubGraphExpanded)return!0}}return!1}expandSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Expand SubGraph",s=new List;try{if(i.startTransaction(e),i.animationManager.Fl(e),t!==null&&!t.isSubGraphExpanded)t.expandSubGraph(),s.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&(r.isSubGraphExpanded||(r.expandSubGraph(),s.add(r)))}}i.v("SubGraphExpanded",s)}finally{for(const n of s)this.JL(i,n);t&&this.JL(i,t),i.commitTransaction(e)}}JL(t,i){for(const e of i.memberParts)e instanceof Node&&t.Cc(e,i)}canExpandSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&!s.isSubGraphExpanded)return!0}}return!1}editTextBlock(t){t===void 0&&(t=null);const i=this.diagram,e=i.toolManager.findTool("TextEditing");if(e!==null){if(t===null){let s=null;const n=i.selection.iterator;for(;n.next();){const o=n.value;if(o.canEdit()){s=o;break}}if(s===null)return;t=s.findInVisualTree(o=>o instanceof TextBlock&&o.editable)}t!==null&&(i.currentTool=null,e.textBlock=t,i.currentTool=e)}}canEditTextBlock(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowTextEdit||i.toolManager.findTool("TextEditing")===null)return!1;if(t!==null){if(!(t instanceof TextBlock))return!1;const e=t.part;if(e!==null&&e.canEdit())return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s.canEdit()&&(t=s.findInVisualTree(n=>n instanceof TextBlock&&n.editable),t!==null))return!0}}return!1}showContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");if(e===null)return;t===void 0&&(i.selection.count>0?t=i.selection.first():t=i);const s=e.findObjectWithContextMenu(t);if(s!==null){const n=i.lastInput;let o=null;if(s instanceof GraphObject)o=s.getDocumentPoint(Spot.Center);else if(!i.viewportBounds.containsPoint(n.documentPoint)){const r=i.viewportBounds;o=new Point(r.x+r.width/2,r.y+r.height/2)}if(o!==null){const r=new InputEvent;r.diagram=i,r.viewPoint=i.transformDocToView(o),r.documentPoint=o,r.button=2,r.up=!0,i.lastInput=r}i.currentTool=e,e.openMenu(!1,s)}}canShowContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");return!(e===null||(t===void 0&&(i.selection.count>0?t=i.selection.first():t=i),e.findObjectWithContextMenu(t)===null))}get copiesClipboardData(){return this.YM}set copiesClipboardData(t){Util.i(t,"boolean",CommandHandler,"copiesClipboardData"),this.YM=t}get copiesConnectedLinks(){return this.GM}set copiesConnectedLinks(t){Util.i(t,"boolean",CommandHandler,"copiesConnectedLinks"),this.GM=t}get deletesConnectedLinks(){return this.jM}set deletesConnectedLinks(t){Util.i(t,"boolean",CommandHandler,"deletesConnectedLinks"),this.jM=t}get copiesTree(){return this.HM}set copiesTree(t){Util.i(t,"boolean",CommandHandler,"copiesTree"),this.HM=t}get deletesTree(){return this.qM}set deletesTree(t){Util.i(t,"boolean",CommandHandler,"deletesTree"),this.qM=t}get copiesParentKey(){return this.WM}set copiesParentKey(t){Util.i(t,"boolean",CommandHandler,"copiesParentKey"),this.WM=t}get copiesGroupKey(){return this.JM}set copiesGroupKey(t){Util.i(t,"boolean",CommandHandler,"copiesGroupKey"),this.JM=t}get archetypeGroupData(){return this.$M}set archetypeGroupData(t){t!==null&&Util.i(t,"object",CommandHandler,"archetypeGroupData");const i=this.diagram;this.$M=t}get memberValidation(){return this.eh}set memberValidation(t){t!==null&&Util.i(t,"function",CommandHandler,"memberValidation"),this.eh=t}get defaultScale(){return this.diagram.defaultScale}set defaultScale(t){this.diagram.defaultScale=t}get zoomFactor(){return this.ZM}set zoomFactor(t){t>1||Util.o("zoomFactor must be larger than 1.0, not: "+t),this.ZM=t}get isZoomToFitRestoreEnabled(){return this._M}set isZoomToFitRestoreEnabled(t){Util.i(t,"boolean",CommandHandler,"isZoomToFitRestoreEnabled"),this._M=t}get scrollToPartPause(){return this.t2}set scrollToPartPause(t){this.t2=t}computeEffectiveCollection(t,i){const e=this.diagram,s=e.toolManager.findTool("Dragging"),n=e.currentTool===s;i===void 0&&(i=e.a0());const o=new GMap;if(t===null)return o;let r=t.iterator;for(;r.next();){const l=r.value;e.Wr(o,l,n,i)}if(e.draggedLink!==null&&i.dragsLink)return o;for(r=t.iterator;r.next();){const l=r.value;if(l instanceof Link){const h=l.fromNode;if(h!==null&&!o.has(h))o.delete(l);else{const a=l.toNode;a!==null&&!o.has(a)&&o.delete(l)}}}return o}}var Stretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Vertical=4]="Vertical",w[w.Horizontal=5]="Horizontal",w[w.Fill=2]="Fill",w))(Stretch||{}),Orientation=(w=>(w[w.None=0]="None",w[w.Along=21]="Along",w[w.Plus90=22]="Plus90",w[w.Minus90=23]="Minus90",w[w.Opposite=24]="Opposite",w[w.Upright=25]="Upright",w[w.Plus90Upright=26]="Plus90Upright",w[w.Minus90Upright=27]="Minus90Upright",w[w.Upright45=28]="Upright45",w))(Orientation||{}),Flip=(w=>(w[w.None=0]="None",w[w.Vertical=1]="Vertical",w[w.Horizontal=2]="Horizontal",w[w.Both=3]="Both",w))(Flip||{});class GraphObject{n;Hu;qu;Uo;f;nh;q;at;se;Wt;Wu;Vs;Ct;ze;$r;oh;bi;ca;et;Xt;Zr;Li;Vi;Ju;oi;Wc;Bt;ni;Qr;Db;rh;$u;constructor(){GSet.Yi(this),this.n=30723,this.Wt=1,this.Wu="",this.Vs=null,this.Ct=null,this.at=new Point(NaN,NaN).g(),this.ze=Size.gw,this.$r=new Transform,this.oh=new Transform,this.bi=null,this.ca=1,this.et=1,this.Xt=0,this.Zr=Margin.Eg,this.se=new Rect(NaN,NaN,NaN,NaN).g(),this.Li=new Rect(NaN,NaN,NaN,NaN).g(),this.Vi=new Rect(0,0,NaN,NaN).g(),this.Ju=null,this.Hu=null,this.q=null,this.oi=Spot.Default,this.Wc=Spot.Default,this.qu=0,this.Uo=0,this.Bt=null,this.f=null,this.nh=null,this.ni=null,this.Db=null,this.rh=null,this.Qr=null,this.$u=null}cloneProtected(t){t.n=(this.n|2048|4096)&-32769,t.Wt=this.Wt,t.Wu=this.Wu,t.Ct=this.Ct,t.at.a(this.at),t.ze=this.ze.N(),this.bi!==null?t.bi=this.bi.copy():t.bi=null,t.et=this.et,t.Xt=this.Xt,t.Zr=this.Zr.N(),t.se.a(this.se),t.Li.a(this.Li),t.Vi.a(this.Vi),t.Hu=this.Hu,this.q!==null&&(t.q=this.q.copy()),t.oi=this.oi.N(),t.Wc=this.Wc.N(),t.qu=this.qu,t.Uo=this.Uo,this.Bt!==null&&(t.Bt=this.Bt.copy()),this.f!==null&&(this.f.gi?t.f=this.f:t.f=this.f.copy()),this.nh!==null&&(t.nh=this.nh.slice()),this.ni!==null&&(t.ni=this.ni.copy())}addCopyProperty(t){let i=this.nh;if(!Array.isArray(i))i=[],this.nh=i;else for(let e=0;e{d.data!==null&&d.e2()&&d.updateTargetBindings(i)})}}}}gF(t){this.$u.delete(t)}Io(){if(this.diagram===null)return;if(this.findBindingPanel()===null&&this.Ai!==null){const i=this.Ai.iterator;for(;i.next();){const e=i.value;if(!e.isToTheme)continue;let s=null;const n=e.sourceName;e.isToObject&&(s=this.$L(n));let o=this;const r=e.targetId;r!==-1&&(o=this.m0(r),o===null)||(n==="/"?s=o.part:n==="."?s=o:n===".."&&(s=o.panel),e.updateTarget(o,s))}}}ya(t,i){const e=this.findBindingPanel();if(e!==null){const s=this.Ai.iterator;for(;s.next();){const n=s.value;let o=null;if(n.isToObject){if(o=n.ZL(e,this),o===null)continue;n.updateSource(this,o,i,null)}else if(n.isToModel){const r=t.diagram;r!==null&&!r.fe&&n.updateSource(this,r.model.modelData,i,e)}else if(!n.isToTheme){const r=e.data;if(r===null)continue;const l=t.diagram;l!==null&&!l.fe&&n.updateSource(this,r,i,e)}if(o===this){const r=n.targetId,l=e.m0(r);l!==null&&n.updateTarget(l,o,i)}}}}m0(t){return this.$n===t?this:null}$L(t){let i;return t===""?i=this:t==="/"?i=this:t==="."?i=this:t===".."?i=this:i=this.part.findObject(t),i}get $n(){return this.f!==null?this.f.$n:-1}set $n(t){this.$n!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.$n=t)}get Ai(){return this.f!==null?this.f.Ai:null}set Ai(t){this.Ai!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.Ai=t)}get Zn(){return this.f!==null?this.f.Zn:null}set Zn(t){this.Zn!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.Zn=t)}raiseChanged(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}t(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}Qn(t,i,e,s){const n=this.se;if(n.e(t,i,e,s),this.et!==1||this.Xt!==0){this.bi===null&&(this.bi=new Transform);const o=this.bi;o.Ri(),this.p0(o,t,i,e,s),o.xw(n)}}QL(t,i,e){return this.pickable===!1?!1:(e.ic(this.D),i?this.intersectsRect(t,e):this.containedInRect(t,e))}_L(t,i,e){if(this.pickable===!1)return!1;const s=this.naturalBounds,n=t.distanceSquaredPoint(i);return e?Point.distanceLineSegmentSquared(t.x,t.y,0,0,0,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,0,s.height,s.width,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,s.height,s.width,0)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,0,0,0)<=n:t.distanceSquared(0,0)<=n&&t.distanceSquared(0,s.height)<=n&&t.distanceSquared(s.width,0)<=n&&t.distanceSquared(s.width,s.height)<=n}pn(){return!0}containsPoint(t){const i=Point.l();i.a(t),this.D.xt(i);const e=this.actualBounds;if(!e.isReal())return Point.s(i),!1;const s=this.diagram;if(s!==null&&s.Zm){const o=s.getInputOption("extraTouchThreshold"),r=s.getInputOption("extraTouchArea"),l=r/2,h=this.naturalBounds,a=this.getDocumentScale()*s.scale,c=1/a;if(h.width*ae&&(f=t),isFinite(i)&&i>s&&(u=i);break;case 5:isFinite(t)&&t>e&&(f=t),u=0,d&&(i=1/0);break;case 4:isFinite(i)&&i>s&&(u=i),f=0,d&&(t=1/0);break}const g=this.maxSize,p=this.minSize;f>g.width&&p.widthg.height&&p.heightu.height||this.mi>u.width)&&(r=!0)}}}r?this.n|=256:this.n&=-257,this.Li.isReal()||Util.o("Non-real actualBounds has been set. Object "+this+", actualBounds: "+this.Li.toString()),this.td(o,this.Li),this._n(!1),Rect.s(o)}ah(t,i,e,s){}commonArrange(t,i,e,s){if(this.Li.e(t,i,e,s),this.desiredSize.isReal())return;const n=this.se,o=this.Zr,r=o.right+o.left,l=o.top+o.bottom,h=n.width+r,a=n.height+l;e+=r,s+=l;let c=this.zs(!0);switch(h===e&&a===s&&(c=0),c){case 0:(h>e||a>s)&&(this.ue(!0),this.ut(h>e?e:h,a>s?s:a,0,0));break;case 2:this.ue(!0),this.ut(e,s,0,0);break;case 5:this.ue(!0),this.ut(e,a,0,0);break;case 4:this.ue(!0),this.ut(h,s,0,0);break}}td(t,i){const e=this.part;e!==null&&e.diagram!==null&&((e.selectionObject===this||e.resizeObject===this||e.rotateObject===this)&&e.s2(!0),this.C(),!t.equalsApproxClose(i)&&(e.ch(),this.b0(e)))}b0(t){this.portId!==null&&(t.s2(!0),t instanceof Node&&t.tA(this))}get shadowVisible(){return this.f!==null?this.f.k0:null}set shadowVisible(t){const i=this.shadowVisible;i!==t&&(this.jt(),this.f.k0=t,this.ss(!0),this.C(),this.t("shadowVisible",i,t))}SR(t,i){const e=this.naturalBounds,s=this.oh,n=s.m11,o=s.m21,r=s.dx,l=s.m12,h=s.m22,a=s.dy;let c=0,f=0,u=c,d=f;c=u*n+d*o+r,f=u*l+d*h+a;let m=c,g=f,p=0,y=0;u=e.width+i,d=0,c=u*n+d*o+r,f=u*l+d*h+a;let x=Math.min(m,c),k=Math.min(g,f);p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-k,m=x,g=k,u=e.width+i,d=e.height+i,c=u*n+d*o+r,f=u*l+d*h+a,x=Math.min(m,c),k=Math.min(g,f),p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-k,m=x,g=k,u=0,d=e.height+i,c=u*n+d*o+r,f=u*l+d*h+a,x=Math.min(m,c),k=Math.min(g,f),p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-k,m=x,g=k;const b=t.viewportBounds,P=b.x,S=b.y,L=b.width,C=b.height;return m>L+P||P>p+m||g>C+S||S>y+g}Gi(t,i){if(this.MR(t,i)||!this.visible)return;const e=this.opacity;if(e===0)return;let s=1;e!==1&&(s=t.globalAlpha,t.globalAlpha=s*e);let n="";this.filter!==""&&(n=t.filter,t.filter=this.filter);const o=this.D,r=this.panel;this.y0()===!0&&this.Fb();const l=this.part;let h=!1,a=0;if(l&&i.getRenderingHint("drawShadows")&&(h=l.isShadowed,h)){const g=l.shadowOffset;a=Math.max(g.y,g.x)*i.scale*i.Ui}const c=this instanceof Panel&&this._r(),f=this.Li;if(c&&(this.iA(h,t,!1,r),this.NR(t,i),this.eA(h,t,!1,r),this.sA(h,t,!1)),c||!c&&(f.width===0||f.height===0||isNaN(f.x)||isNaN(f.y))){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}const u=this.Xs();if(!i.Qh&&u&&this.SR(i,a)){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}let d=(this.n&256)!==0;if(t.clipInsteadOfFill&&(d=!1),this instanceof TextBlock&&(t.font=this.font),d){const g=r.pn()?r.naturalBounds:r.actualBounds;let p=Math.max(f.x,g.x),y=Math.max(f.y,g.y),x=Math.min(f.right,g.right)-p,k=Math.min(f.bottom,g.bottom)-y;const b=this.ni;if(b!==null&&(p=b.x,y=b.y,x=b.width,k=b.height),p>f.width+f.x||f.x>g.width+g.x){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}t.save(),t.beginPath(),t.rect(p,y,x,k),t.clip()}if(u){if(!l.isVisible()){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}if(h){const g=l.shadowOffset;t.shadowsSet(g.x*i.scale*this.scale*i.Ui,g.y*i.scale*this.scale*i.Ui,l.shadowBlur),t.shadowsOn(),t.shadowColor=l.shadowColor}}const m=this.naturalBounds;if(t.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.iA(h,t,u,r),this.Ct!==null&&(t.commitTransform(),this.Rb(t,m,f)),this.eA(h,t,u,r),this.fh(t,i),this.sA(h,t,u),d&&(t.restore(),t.clearContextCache(this instanceof Panel)),!o.Ok()){const g=1/(o.m11*o.m22-o.m12*o.m21);t.transform(o.m22*g,-o.m12*g,-o.m21*g,o.m11*g,g*(o.m21*o.dy-o.m22*o.dx),g*(o.m12*o.dx-o.m11*o.dy))}e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n)}iA(t,i,e,s){t&&this.shadowVisible===!0?i.shadowsOn():t&&this.shadowVisible===!1&&i.shadowsOff(),t&&this.vb(s)&&this.shadowVisible===null&&i.shadowsOff()}eA(t,i,e,s){t&&(this.Ct!==null||this.vb(s))?(this.Ob(!0),this.shadowVisible===null&&i.shadowsOff()):this.Ob(!1)}sA(t,i,e){t&&this.o2()===!0&&i.shadowsOn(),e&&t&&i.shadowsOff()}CR(t,i,e){const s=this.part;let n=!1;s&&t.getRenderingHint("drawShadows")&&(n=s.isShadowed),i.clipInsteadOfFill&&(n=!1),this.Xs()&&n&&i.shadowsOn(),n&&this.shadowVisible===!0?i.shadowsOn():n&&this.shadowVisible===!1&&i.shadowsOff();const o=this.panel;if(n&&this.vb(o)&&this.shadowVisible===null&&i.shadowsOff(),i.tl){const r=t.computePixelRatio(),l=`drop-shadow(${i.shadowOffsetX/r}px ${i.shadowOffsetY/r}px ${i.shadowBlur/r/2}px ${i.shadowColor})`;this.background!==null&&e.Ct.setAttributeNS(null,"filter",l)}return n&&(this.Ct!==null||this.vb(o))?(this.Ob(!0),this.shadowVisible===null&&i.shadowsOff()):this.Ob(!1),n}LR(t,i,e,s){if(e.tl){const n=i.computePixelRatio(),o=`drop-shadow(${e.shadowOffsetX/n}px ${e.shadowOffsetY/n}px ${e.shadowBlur/n/2}px ${e.shadowColor})`;this.l2(t,o)}s&&this.o2()===!0&&e.shadowsOn(),this.Xs()&&e.shadowsOff()}vb(t){return t===null?!1:(t._r()&&(t=t.panel),t.o2()||(t.type===Panel.Auto||t.type===Panel.Spot)&&t.findMainElement()!==this)}l2(t,i){}Rb(t,i,e){const s=this.w0(),n=i.x,o=i.y,r=i.width+s,l=i.height+s;this.dn(t,this.Ct,!0,!1,i,e),this.Ct instanceof Brush&&this.Ct.type===3?(t.beginPath(),t.rect(n-s/2,o-s/2,r,l),t.fillContext(this.Ct,!1,null)):t.fillRect(n-s/2,o-s/2,r,l)}nA(t,i){let e=t.AR(this);const s=t.rh!==null?t.rh:t.svg;if(e!==-1)if(e===0)if(s.Ct)s.Ct.after(i);else if(t.type===Panel.Table){const n=s.getElementsByClassName("gojs-ts"),o=n.length!==0?n[0]:null;o!==null&&o.after(i)}else s.prepend(i);else{for(;e!==0&&!t.elt(e-1).isVisibleObject();)e--;if(e===0)s.prepend(i);else{const n=t.elt(e-1).svg;n!==null?n.after(i):s.appendChild(i)}}}MR(t,i){if(!(t instanceof SVGContext))return!1;if(!this.visible||this.opacity===0)return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;if(this.Xs()&&!this.isVisible())return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;const e=this.panel,s=this.ed(t);if(this.Qc(t,i,s))return this.oA(this.svg),this.svg.parentElement!==null?(this.Xs()&&(t.lastDrawnPart=this.svg),!0):(this.Xs()?(t.lastDrawnPart!==null?t.lastDrawnPart.after(this.svg):t.diagramGroup.prepend(this.svg),t.lastDrawnPart=this.svg):e&&this.nA(e,this.svg),!0);if(this.Xs()&&this.isShadowed){const m=this.shadowOffset;t.shadowsSet(m.x*i.scale*this.scale*i.Ui,m.y*i.scale*this.scale*i.Ui,this.shadowBlur),t.shadowsOn(),t.shadowColor=this.shadowColor}this instanceof TextBlock&&(t.font=this.font),t.currentElement=null;const n=this.D,o=this instanceof Panel,r=this instanceof Panel?this._r():!1,l=this.svg;this.y0()===!0&&this.Fb();const h=this.Li;if(t.setCurrentTransform(1,0,0,1,0,0),t.outerGroup=!1,s)if(t.outerGroup=!0,o&&r)t.newGroup(1,0,0,1,0,0),this.svg=t.lastCreatedElement;else if(o&&this.isClipping){const m=this.findMainElement();let g=0,p=0;m!==null&&(g=m.actualBounds.x,p=m.actualBounds.y),t.newGroup(n.m11,n.m12,n.m21,n.m22,n.dx+g,n.dy+p),this.svg=t.lastCreatedElement,m!==null&&t.createOrUpdateClipGroup(this,m.actualBounds),t.currentElement=t.lastCreatedElement}else o?(t.newGroup(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.svg=t.lastCreatedElement):t.newGroup(1,0,0,1,0,0);const a=this.naturalBounds;o||t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.background!==null&&(o?(r&&t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.Rb(t,a,h),r&&t.setCurrentTransform(1,0,0,1,0,0)):(t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.Rb(t,a,h)),t.currentElement.Ct=t.lastCreatedElement,t.currentElement.prepend(t.lastCreatedElement));const c=this.CR(i,t,t.currentElement);this.fh(t,i),o&&t.endGroup(),t.outerGroup&&t.endGroup();const f=t.surface.Gu,u=o?this.svg:t.currentElement;if(!o&&l!==null&&u!==l&&l.parentNode===this.panel.svg){const m=this.svg.getAttribute("filter");return m!==null&&u.setAttribute("filter",m),this.svg.replaceWith(u),this.svg=u,u!==null&&this.P0(t,e,h,u),t.rA(l),!0}if(this.svg=u,f!==null&&u===null&&t.dummyGroup(),u===null)return!0;this.P0(t,e,h,u),this.LR(u,i,t,c);const d=this.Xs()?this.opacity*t.globalAlpha:this.opacity;if(d!==1&&u.setAttributeNS(null,"opacity",d.toString()),this.filter!==""&&u.setAttributeNS(null,"filter",this.filter),this.Xs()){if(l!==null&&u!==l&&l.parentNode===t.diagramGroup){const m=l.getAttribute("filter");m!==null&&u.setAttribute("filter",m),l.replaceWith(u)}else t.lastDrawnPart?t.lastDrawnPart.after(u):t.diagramGroup.prepend(u);t.lastDrawnPart=u}else e!==null&&this.nA(e,u);return f!==null&&f(this,u),this.oA(u),!0}oA(t){const i=this,e=t.dataset;i instanceof GraphObject&&(i.portId!==null&&(e.portId=i.portId),i instanceof Panel&&(isNaN(i.itemIndex)||(e.itemIndex=i.itemIndex.toString()),i instanceof Part&&(e.className=Util.sn(i),i.key!==void 0&&(e.key=i.key.toString()),i.containingGroup!==null&&(e.group=i.containingGroup.key.toString()),i instanceof Link&&(i.fromNode!==null&&i.fromNode.key!==void 0&&(e.fromKey=i.fromNode.key.toString()),i.fromPortId!==""&&(e.fromPortId=i.fromPortId),i.toNode!==null&&i.toNode.key!==void 0&&(e.toKey=i.toNode.key.toString()),i.toPortId!==""&&(e.toPortId=i.toPortId)))))}P0(t,i,e,s){let n=(this.n&256)!==0;if(t.clipInsteadOfFill&&(n=!1),!n){s.removeAttributeNS(null,"clip-path"),t.rA(s);return}const o=i.pn()?i.naturalBounds:i.actualBounds;let r=Math.max(e.x,o.x),l=Math.max(e.y,o.y),h=Math.min(e.right,o.right)-r,a=Math.min(e.bottom,o.bottom)-l;const c=this.ni;c!==null&&(r=c.x,l=c.y,h=c.width,a=c.height);const f=t.TR(s);if(f===null){const u="CLIP"+GSet.su++,d={id:u},m=t.makeElement("clipPath",d),g=t.makeElement("rect",{x:r,y:l,width:h,height:a});if(this instanceof Panel){const p=this.D.copy().yw();g.setAttribute("transform",`matrix(${p.m11}, ${p.m12}, ${p.m21}, ${p.m22}, ${p.dx}, ${p.dy})`)}m.appendChild(g),t.svg.appendChild(m),s.setAttributeNS(null,"clip-path","url(#"+u+")")}else{const u=f.firstElementChild;u.setAttribute("x",r.toString()),u.setAttribute("y",l.toString()),u.setAttribute("width",h.toString()),u.setAttribute("height",a.toString())}}DR(){if(this.svg===null)return;const t=this.svg.innerHTML.match(/url\(#((CLIP|GRAD).+?)\)/g),i=this.svg.ownerDocument;if(t!==null)for(const e of t){const s=i.getElementById(e.split("#")[1].slice(0,-1));s!==null&&s.remove()}this.svg.remove()}NR(t,i){const e=this.Li,s=this.Vi,n=this.Ct;n!==null&&t.commitTransform(),n!==null&&(this.dn(t,n,!0,!1,s,e),n instanceof Brush&&n.type===3?(t.beginPath(),t.rect(e.x,e.y,e.width,e.height),t.fillContext(n,!1,null)):t.fillRect(e.x,e.y,e.width,e.height)),this.fh(t,i)}fh(t,i){}S0(){this.ss(!0)}Qc(t,i,e){const s=this.svg;if(this.FR()){if(this.S0(),this.ss(!1),s===null)return!1;const c=this.svg.getAttribute("clip-path");if(c!==null&&c.includes("url")){const f=t.svg.getElementById(c.split("#")[1].slice(0,-1));f!==null&&f.remove()}return!1}if(s===null)return!1;if(!this.visible)return s.remove(),!1;if(s.nodeName!=="g"&&e||s.nodeName==="g"&&!e)return!1;const n=this.D,o="matrix("+n.m11+", "+n.m12+", "+n.m21+", "+n.m22+", "+n.dx+", "+n.dy+")",r=this instanceof Panel,l=r?this._r():!1;if(!(r&&l))if(this instanceof Picture){const c=this.Ib;t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),c!==null&&t.amendImageTransform(c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7]),e?s.lastElementChild.setAttributeNS(null,"transform",t.getCurrentTransform()):s.setAttributeNS(null,"transform",t.getCurrentTransform())}else if(e&&!r)if(this instanceof Shape){const c=s.getElementsByTagName("path");for(let f=0;f=.1;){if(g){for(l=o[d++%h],l-=r;l<0;)l+=o[d++%h],m=!m;g=!1}else l=o[d++%h];l>u&&(l=u);let p=Math.sqrt(l*l/(1+f*f));a<0&&(p=-p),i+=p,e+=f*p,m?t.lineTo(i,e):t.moveTo(i,e),u-=l,m=!m}}dn(t,i,e,s,n,o){let r=1,l=1;if(typeof i=="string"){e?t.fillStyle=i:t.strokeStyle=i;return}else if(i.type===1){e?t.fillStyle=i.color:t.strokeStyle=i.color;return}let h;const a=this.w0();r=n.width,l=n.height,s?(r=o.width,l=o.height):e||(r+=a,l+=a);const c=t instanceof CanvasSurfaceContext;if(c&&i.yn&&(i.type===4||i._c===r&&i.Eb===l))h=i.yn;else{let f=0,u=0,d=0,m=0,g=0,p=0,y=0,x=0;if(s?(y=o.x,x=o.y):e||(y-=a/2,x-=a/2),f=i.start.x*r+i.start.offsetX+y,u=i.start.y*l+i.start.offsetY+x,d=i.end.x*r+i.end.offsetX+y,m=i.end.y*l+i.end.offsetY+x,i.type===2)h=t.createLinearGradient(f,u,d,m);else if(i.type===3)p=isNaN(i.endRadius)?Math.max(r,l)/2:i.endRadius,isNaN(i.startRadius)?(g=0,p=Math.max(r,l)/2):g=i.startRadius,h=t.createRadialGradient(f,u,g,d,m,p);else if(i.type===4)try{h=t.createPattern(i.pattern,"repeat")}catch{h=null}else Util.we(i.type,"Brush type");if(i.type!==4){const k=i.colorStops;if(k!==null){const b=k.iterator;for(;b.next();)h.addColorStop(b.key,b.value)}}if(c&&(i.yn=h,h!==null&&(i._c=r,i.Eb=l),h===null&&i.type===4&&i._c!==-1)){i._c=-1;const k=this.diagram;k!==null&&i._c===-1&&Util.Oh(()=>{k.redraw()},600)}}e?t.fillStyle=h:t.strokeStyle=h}isContainedBy(t){return t instanceof Panel?this.RR(this,t):!1}RR(t,i){if(t===i||i===null)return!1;let e=t.panel;for(;e!==null;){if(e===i)return!0;e=e.panel}return!1}isVisibleObject(){if(!this.visible)return!1;const t=this.panel;return t!==null?t.isVisibleObject():!0}isEnabledObject(){let t=this instanceof Panel?this:this.panel;for(;t!==null&&t.isEnabled;)t=t.panel;return t===null}get enabledChanged(){return this.f!==null?this.f.M0:null}set enabledChanged(t){const i=this.enabledChanged;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"enabledChanged"),this.jt(),this.f.M0=t,this.t("enabledChanged",i,t))}Fb(){if(this.Bb()===!0){const t=this.$r;if(t.Ri(),!this.Li.isReal()||!this.se.isReal()){this.sd(!1);return}if(t.Ds(this.Li.x-this.se.x,this.Li.y-this.se.y),this.scale!==1||this.angle!==0){const i=this.naturalBounds;this.p0(t,i.x,i.y,i.width,i.height)}this.sd(!1),this.wa(!0)}if(this.y0()===!0){const t=this.panel;if(t===null)this.oh.set(this.$r),this.ca=this.scale;else if(t.Es!==null){const i=this.oh;i.Ri(),t.pn()?i.ic(t.oh):t.panel!==null&&i.ic(t.panel.oh),i.ic(this.$r),this.ca=this.scale*t.ca}this.wa(!1)}}p0(t,i,e,s,n){if(this.et!==1&&t.et(this.et),this.Xt===0)return;const o=Point.l();o.setSpot(i,e,s,n,Spot.Center),t.cs(this.Xt,o.x,o.y),Point.s(o)}c(t){if(this.Oo())return;t===void 0&&(t=!1),this.ue(!0),this._n(!0);const i=this.panel;i!==null&&!t&&i.c()}tf(){this.Oo()||(this.ue(!0),this._n(!0))}ef(t){if(this.is())return;const i=this.panel;!t&&i!==null&&i.c(),this._n(!0)}_u(){this.Bb()===!1&&(this.sd(!0),this.wa(!0))}h2(){this.wa(!0)}C(){const t=this.part;t!==null&&t.C()}zs(t){const i=this.stretch,e=this.panel;if(e===null)return this.zo(i===1?0:i,t);if(e.type===Panel.Table)return this.N0(e.getRowDefinition(this.row),e.getColumnDefinition(this.column),t);if(e.type===Panel.Auto&&e.findMainElement()===this)return this.zo(2,t);if(i===1){if(e.type===Panel.Spot&&e.findMainElement()===this)return this.zo(2,t);const s=e.defaultStretch;return s===1?this.zo(0,t):this.zo(s,t)}return this.zo(i,t)}N0(t,i,e){const s=this.stretch;if(s!==1)return this.zo(s,e);let n=null,o=null;switch(t.stretch){case 1:case 5:break;case 4:o=!0;break;case 2:o=!0;break}switch(i.stretch){case 1:case 4:break;case 5:n=!0;break;case 2:n=!0;break}const r=this.panel.defaultStretch;return n===null&&(n=r===5||r===2),o===null&&(o=r===4||r===2),n===!0&&o===!0?this.zo(2,e):n===!0?this.zo(5,e):o===!0?this.zo(4,e):this.zo(0,e)}zo(t,i){if(i)return t;if(t===0)return 0;const e=this.desiredSize;if(e.isReal())return 0;const s=!isNaN(e.width),n=!isNaN(e.height),o=this.angle;if(s)if(o!==90&&o!==270){if(t===5)return 0;if(t===2)return 4}else{if(t===4)return 0;if(t===2)return 5}if(n)if(o!==90&&o!==270){if(t===4)return 0;if(t===2)return 5}else{if(t===5)return 0;if(t===2)return 4}return t}get segmentOrientation(){return this.Bt!==null?this.Bt.C0:0}set segmentOrientation(t){const i=this.segmentOrientation;i!==t&&(this.Bt===null&&(this.Bt=new LinkElementSettings),this.Bt.C0=t,this.c(),this.t("segmentOrientation",i,t),t===0&&(this.angle=0))}vR(){this.segmentOrientation=21}get segmentIndex(){return this.Bt!==null?this.Bt.L0:-1/0}set segmentIndex(t){t=Math.round(t);const i=this.segmentIndex;i!==t&&(this.Bt===null&&(this.Bt=new LinkElementSettings),this.Bt.L0=t,this.c(),this.t("segmentIndex",i,t))}get segmentFraction(){return this.Bt!==null?this.Bt.A0:0}set segmentFraction(t){isNaN(t)||t<0?t=0:t>1&&(t=1);const i=this.segmentFraction;i!==t&&(this.Bt===null&&(this.Bt=new LinkElementSettings),this.Bt.A0=t,this.c(),this.t("segmentFraction",i,t))}get segmentOffset(){return this.Bt!==null?this.Bt.T0:Point.Po}set segmentOffset(t){const i=this.segmentOffset;i.equals(t)||(t=t.N(),this.Bt===null&&(this.Bt=new LinkElementSettings),this.Bt.T0=t,this.c(),this.t("segmentOffset",i,t))}get stretch(){return this.f!==null?this.f.to:1}set stretch(t){const i=this.stretch;i!==t&&(this.jt(),this.f.to=t,this.c(),this.t("stretch",i,t))}get name(){return this.f!==null?this.f.Mt:""}set name(t){const i=this.name;i!==t&&(this.jt(),this.f.Mt=t,this.part!==null&&this.part.D0(),this.t("name",i,t))}get opacity(){return this.Wt}set opacity(t){const i=this.Wt;if(i!==t){Util.i(t,"number",GraphObject,"opacity"),(t<0||t>1)&&Util._(t,"0 <= value <= 1",GraphObject,"opacity"),this.Wt=t,this.t("opacity",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.C(s.Hh(s.actualBounds))}}get filter(){return this.Wu}set filter(t){const i=this.Wu;if(i!==t){this.Wu=t,this.ss(!0),this.t("filter",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.C(s.Hh(s.actualBounds))}}get visible(){return(this.n&1)!==0}set visible(t){const i=(this.n&1)!==0;if(i!==t){this.n=this.n^1,this.t("visible",i,t);const e=this.panel;e!==null?e.c():this.Xs()&&this.Ei(t),this.C(),this.lA()}}get pickable(){return(this.n&2)!==0}set pickable(t){const i=(this.n&2)!==0;i!==t&&(this.n=this.n^2,this.t("pickable",i,t))}get fromLinkableDuplicates(){return(this.n&4)!==0}set fromLinkableDuplicates(t){const i=(this.n&4)!==0;i!==t&&(this.n=this.n^4,this.t("fromLinkableDuplicates",i,t))}get fromLinkableSelfNode(){return(this.n&8)!==0}set fromLinkableSelfNode(t){const i=(this.n&8)!==0;i!==t&&(this.n=this.n^8,this.t("fromLinkableSelfNode",i,t))}get toLinkableDuplicates(){return(this.n&16)!==0}set toLinkableDuplicates(t){const i=(this.n&16)!==0;i!==t&&(this.n=this.n^16,this.t("toLinkableDuplicates",i,t))}get toLinkableSelfNode(){return(this.n&32)!==0}set toLinkableSelfNode(t){const i=(this.n&32)!==0;i!==t&&(this.n=this.n^32,this.t("toLinkableSelfNode",i,t))}get isPanelMain(){return(this.n&64)!==0}set isPanelMain(t){const i=(this.n&64)!==0;i!==t&&(this.n=this.n^64,this.c(),this.t("isPanelMain",i,t))}get isActionable(){return(this.n&128)!==0}set isActionable(t){const i=(this.n&128)!==0;i!==t&&(this.n=this.n^128,this.t("isActionable",i,t))}get background(){return this.Ct}set background(t){const i=this.Ct;i!==t&&(t!==null&&Brush.nd(t,"GraphObject.background"),t instanceof Brush&&t.g(),this.Ct=t,this.C(),this.t("background",i,t))}o2(){return(this.n&512)!==0}Ob(t){t?this.n|=512:this.n&=-513}$c(){return(this.n&1024)!==0}a2(t){t?this.n|=1024:this.n&=-1025}Bb(){return(this.n&2048)!==0}sd(t){t?this.n|=2048:this.n&=-2049}y0(){return(this.n&4096)!==0}wa(t){t?this.n|=4096:this.n&=-4097}Oo(){return(this.n&8192)!==0}ue(t){t?this.n|=8192:this.n&=-8193}is(){return(this.n&16384)!==0}_n(t){t?this.n|=16384:this.n&=-16385}FR(){return(this.n&32768)!==0}ss(t){t?this.n|=32768:this.n&=-32769}get part(){if(this.Xs())return this;if(this.Qr!==null)return this.Qr;let t=this;for(t=t.panel;t;){if(t instanceof Part)return this.Qr=t,t;t=t.panel}return null}get svg(){return this.Db}set svg(t){this.Db=t}Du(){this.svg=null}get panel(){return this.Vs}xa(t){this.Vs=t,this.svg!==null&&this.svg.remove()}get layer(){const t=this.part;return t!==null?t.layer:null}get diagram(){const t=this.part;return t!==null?t.diagram:null}get position(){return this.at}set position(t){const i=t.x,e=t.y,s=this.at,n=s.x,o=s.y;n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e))?(t=t.copy(),this.c2(t,n,o)&&this.t("position",new Point(n,o),t)):this.f2()}f2(){}c2(t,i,e){return this.at=t,this.ef(),!0}bc(t,i,e){this.at.x===t&&this.at.y===i||(this.at.e(t,i),this._u())}get actualBounds(){return this.Li}get scale(){return this.et}set scale(t){const i=this.et;i!==t&&(t<=0&&Util.o("GraphObject.scale for "+this+" must be greater than zero, not: "+t),this.et=t,this.c(),this.t("scale",i,t))}get angle(){return this.Xt}set angle(t){const i=this.Xt;if(i!==t){if(t=t%360,t<0&&(t+=360),i===t)return;this.Xt=t,this.lA(),this.c(),this.t("angle",i,t)}}get desiredSize(){return this.ze}set desiredSize(t){const i=t.width,e=t.height,s=this.ze,n=s.width,o=s.height;if((n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e)))&&(t=t.N(),this.ze=t,this.c(),this instanceof Shape&&this.ee(),this.t("desiredSize",s,t),this.$c())){const r=this.part;r!==null&&(this.ya(r,"width"),this.ya(r,"height"))}}get width(){return this.ze.width}set width(t){const i=this.ze.width;if(i!==t&&(!isNaN(i)||!isNaN(t))){const e=this.ze,s=new Size(t,this.ze.height).g();if(this.ze=s,this.c(),this instanceof Shape&&this.ee(),this.t("desiredSize",e,s),this.$c()){const n=this.part;n!==null&&this.ya(n,"width")}}}get height(){return this.ze.height}set height(t){const i=this.ze.height;if(i!==t&&(!isNaN(i)||!isNaN(t))){const e=this.ze,s=new Size(this.ze.width,t).g();if(this.ze=s,this.c(),this instanceof Shape&&this.ee(),this.t("desiredSize",e,s),this.$c()){const n=this.part;n!==null&&this.ya(n,"height")}}}get minSize(){return this.f!==null?this.f.xr:Size.ru}set minSize(t){const i=this.minSize;i.equals(t)||(t=t.copy(),isNaN(t.width)&&(t.width=0),isNaN(t.height)&&(t.height=0),t.g(),this.jt(),this.f.xr=t,this.c(),this.t("minSize",i,t))}get maxSize(){return this.f!==null?this.f.br:Size.iC}set maxSize(t){const i=this.maxSize;i.equals(t)||(t=t.copy(),isNaN(t.width)&&(t.width=1/0),isNaN(t.height)&&(t.height=1/0),t.g(),this.jt(),this.f.br=t,this.c(),this.t("maxSize",i,t))}get measuredBounds(){return this.se}get naturalBounds(){return this.Vi}w0(){return 0}get margin(){return this.Zr}set margin(t){typeof t=="number"&&(t=new Margin(t));const i=this.Zr;i.equals(t)||(t=t.N(),this.Zr=t,this.c(),this.t("margin",i,t))}get D(){return this.Bb()===!0&&this.Fb(),this.$r}get Es(){return this.y0()===!0&&this.Fb(),this.oh}trigger(t,i,e){let s=null;return typeof t=="string"?s=new AnimationTrigger(t,i,e):s=t,s.ke=this,this.ys===null&&(this.ys=new GMap),this.ys.set(s.propertyName,s),this}get ys(){return this.f!==null?this.f.ys:null}set ys(t){this.ys!==t&&(this.jt(),this.f.ys=t)}get wr(){return this.f!==null?this.f.wr:0}set wr(t){this.wr!==t&&(this.jt(),this.f.wr=t)}get alignment(){return this.oi}set alignment(t){const i=this.oi;i.equals(t)||(t.isNoSpot()&&!t.isDefault()&&Util.o("GraphObject.alignment for "+this+" must be a real Spot or Spot.Default, not: "+t),t=t.N(),this.oi=t,this.ef(),this.t("alignment",i,t))}get column(){return this.Uo}set column(t){t=Math.round(t);const i=this.Uo;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"column"),this.Uo=t,this.c(),this.t("column",i,t),this.svg!==null&&this.svg.remove())}get columnSpan(){return this.f!==null?this.f.F0:1}set columnSpan(t){t=Math.round(t);const i=this.columnSpan;i!==t&&(t<1&&Util._(t,">= 1",GraphObject,"columnSpan"),this.jt(),this.f.F0=t,this.c(),this.t("columnSpan",i,t))}get row(){return this.qu}set row(t){t=Math.round(t);const i=this.qu;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"row"),this.qu=t,this.c(),this.t("row",i,t),this.svg!==null&&this.svg.remove())}get rowSpan(){return this.f!==null?this.f.R0:1}set rowSpan(t){t=Math.round(t);const i=this.rowSpan;i!==t&&(t<1&&Util._(t,">= 1",GraphObject,"rowSpan"),this.jt(),this.f.R0=t,this.c(),this.t("rowSpan",i,t))}get spanAllocation(){return this.f!==null?this.f.v0:null}set spanAllocation(t){const i=this.spanAllocation;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"spanAllocation"),this.jt(),this.f.v0=t,this.c(),this.t("spanAllocation",i,t))}get alignmentFocus(){return this.Wc}set alignmentFocus(t){const i=this.Wc;i.equals(t)||(t=t.N(),this.Wc=t,this.c(),this.t("alignmentFocus",i,t))}get portId(){return this.Hu}set portId(t){const i=this.Hu;if(i!==t){const e=this.part;e!==null&&!(e instanceof Node)&&Util.o("Cannot set portID on a Link: "+t);const s=e;i!==null&&s!==null&&s.u2(this),this.Hu=t,t!==null&&s!==null&&(s.wn=!0,s.hA(this)),this.t("portId",i,t)}}ba(){const t=this.part;if(t instanceof Node&&(this.portId!==null||this===t.port)){const i=t.diagram;i!==null&&!i.undoManager.isUndoingRedoing&&t.tA(this)}}lA(){const t=this.diagram;t===null||t.undoManager.isUndoingRedoing||(this instanceof Panel?this instanceof Node?this.invalidateConnectedLinks():this.walkVisualTreeFrom(this,i=>{i.ba()}):this.ba())}get toSpot(){return this.q!==null?this.q.ua:Spot.None}set toSpot(t){const i=this.toSpot;i.equals(t)||(t=t.N(),this.Xe(),this.q.ua=t,this.t("toSpot",i,t),this.ba())}get toEndSegmentLength(){return this.q!==null?this.q.ga:10}set toEndSegmentLength(t){const i=this.toEndSegmentLength;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"toEndSegmentLength"),this.Xe(),this.q.ga=t,this.t("toEndSegmentLength",i,t),this.ba())}get toShortLength(){return this.q!==null?this.q.pa:0}set toShortLength(t){const i=this.toShortLength;i!==t&&(this.Xe(),this.q.pa=t,this.t("toShortLength",i,t),this.ba())}get toLinkable(){return this.q!==null?this.q.O0:null}set toLinkable(t){const i=this.toLinkable;i!==t&&(this.Xe(),this.q.O0=t,this.t("toLinkable",i,t))}get toMaxLinks(){return this.q!==null?this.q.I0:1/0}set toMaxLinks(t){const i=this.toMaxLinks;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"toMaxLinks"),this.Xe(),this.q.I0=t,this.t("toMaxLinks",i,t))}get fromSpot(){return this.q!==null?this.q.fa:Spot.None}set fromSpot(t){const i=this.fromSpot;i.equals(t)||(t=t.N(),this.Xe(),this.q.fa=t,this.t("fromSpot",i,t),this.ba())}get fromEndSegmentLength(){return this.q!==null?this.q.da:10}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"fromEndSegmentLength"),this.Xe(),this.q.da=t,this.t("fromEndSegmentLength",i,t),this.ba())}get fromShortLength(){return this.q!==null?this.q.ma:0}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(this.Xe(),this.q.ma=t,this.t("fromShortLength",i,t),this.ba())}get fromLinkable(){return this.q!==null?this.q.E0:null}set fromLinkable(t){const i=this.fromLinkable;i!==t&&(this.Xe(),this.q.E0=t,this.t("fromLinkable",i,t))}get fromMaxLinks(){return this.q!==null?this.q.B0:1/0}set fromMaxLinks(t){const i=this.fromMaxLinks;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"fromMaxLinks"),this.Xe(),this.q.B0=t,this.t("fromMaxLinks",i,t))}get cursor(){return this.f!==null?this.f.Sl:""}set cursor(t){const i=this.cursor;i!==t&&(Util.i(t,"string",GraphObject,"cursor"),this.jt(),this.f.Sl=t,this.t("cursor",i,t))}get click(){return this.f!==null?this.f.Tr:null}set click(t){const i=this.click;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"click"),this.jt(),this.f.Tr=t,this.t("click",i,t))}get doubleClick(){return this.f!==null?this.f.Dr:null}set doubleClick(t){const i=this.doubleClick;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"doubleClick"),this.jt(),this.f.Dr=t,this.t("doubleClick",i,t))}get contextClick(){return this.f!==null?this.f.Fr:null}set contextClick(t){const i=this.contextClick;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"contextClick"),this.jt(),this.f.Fr=t,this.t("contextClick",i,t))}get mouseEnter(){return this.f!==null?this.f.Er:null}set mouseEnter(t){const i=this.mouseEnter;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseEnter"),this.jt(),this.f.Er=t,this.t("mouseEnter",i,t))}get mouseLeave(){return this.f!==null?this.f.Br:null}set mouseLeave(t){const i=this.mouseLeave;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseLeave"),this.jt(),this.f.Br=t,this.t("mouseLeave",i,t))}get mouseOver(){return this.f!==null?this.f.Rr:null}set mouseOver(t){const i=this.mouseOver;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseOver"),this.jt(),this.f.Rr=t,this.t("mouseOver",i,t))}get mouseHover(){return this.f!==null?this.f.vr:null}set mouseHover(t){const i=this.mouseHover;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseHover"),this.jt(),this.f.vr=t,this.t("mouseHover",i,t))}get mouseHold(){return this.f!==null?this.f.Or:null}set mouseHold(t){const i=this.mouseHold;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseHold"),this.jt(),this.f.Or=t,this.t("mouseHold",i,t))}get mouseDragEnter(){return this.f!==null?this.f.U0:null}set mouseDragEnter(t){const i=this.mouseDragEnter;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDragEnter"),this.jt(),this.f.U0=t,this.t("mouseDragEnter",i,t))}get mouseDragLeave(){return this.f!==null?this.f.V0:null}set mouseDragLeave(t){const i=this.mouseDragLeave;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDragLeave"),this.jt(),this.f.V0=t,this.t("mouseDragLeave",i,t))}get mouseDrop(){return this.f!==null?this.f.Ir:null}set mouseDrop(t){const i=this.mouseDrop;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDrop"),this.jt(),this.f.Ir=t,this.t("mouseDrop",i,t))}get actionDown(){return this.f!==null?this.f.z0:null}set actionDown(t){const i=this.actionDown;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionDown"),this.jt(),this.f.z0=t,this.t("actionDown",i,t))}get actionMove(){return this.f!==null?this.f.X0:null}set actionMove(t){const i=this.actionMove;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionMove"),this.jt(),this.f.X0=t,this.t("actionMove",i,t))}get actionUp(){return this.f!==null?this.f.K0:null}set actionUp(t){const i=this.actionUp;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionUp"),this.jt(),this.f.K0=t,this.t("actionUp",i,t))}get actionCancel(){return this.f!==null?this.f.Y0:null}set actionCancel(t){const i=this.actionCancel;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionCancel"),this.jt(),this.f.Y0=t,this.t("actionCancel",i,t))}get toolTip(){return this.f!==null?this.f.Ur:null}set toolTip(t){const i=this.toolTip;i!==t&&(this.jt(),this.f.Ur=t,this.t("toolTip",i,t))}get contextMenu(){return this.f!==null?this.f.Vr:null}set contextMenu(t){const i=this.contextMenu;i!==t&&(this.jt(),this.f.Vr=t,this.t("contextMenu",i,t))}findBindingPanel(){let t=this instanceof Panel?this:this.panel;for(;t!==null;){if(t.d2())return t;t=t.panel}return null}bind(t,i,e,s){return this.sf(t,i,e,s),this}bindTwoWay(t,i,e,s){return this.sf(t,i,e,s).makeTwoWay(),this}bindModel(t,i,e,s){return this.sf(t,i,e,s).ofModel(),this}bindObject(t,i,e,s,n){return this.sf(t,i,e,s).ofObject(n),this}theme(t,i,e,s,n){return this.uh(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.uh(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.uh(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.uh(t,i,e,s,n).ofModel(),this}sf(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.G0(n),n}uh(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.G0(o),o}G0(t){t.ke=this;const i=this.findBindingPanel();i!==null&&i.aA()&&Util.o("Cannot add a Binding to a template that has already been copied: "+t),this.Ai===null&&(this.Ai=new List),this.Ai.add(t)}set(t){return Object.assign(this,t),this}attach(t){return GraphObject.g2(this,t),this}apply(t){return t(this),this}setProperties(t){return Diagram.h0(this,t),this}static build(t,i,...e){const s=GraphObject.j0.get(t);if(typeof s=="function"){const n=s([t].concat(e));if(n instanceof GraphObject)return i&&n.setProperties(i),n}Util.o('GraphObject.build invoked object builder "'+t+'", but it did not return an Object')}static make(t,...i){let e=arguments,s=null,n=null;if(typeof t=="function")n=t;else if(typeof t=="string"){const r=GraphObject.j0.get(t);typeof r=="function"?(e=Array.prototype.slice.call(e),s=r(e),Util.wt(s)||Util.o('GraphObject.make invoked object builder "'+t+'", but it did not return an Object')):n=root.go[t]}s===null&&((n==null||!n.constructor)&&Util.o("GraphObject.make requires a class function or GoJS class name or name of an object builder, not: "+t),s=new n);let o=1;if(s instanceof Diagram&&e.length>1){const r=s,l=e[1];(typeof l=="string"||l instanceof HTMLDivElement)&&(r.mM(l),o++)}for(let r=o;r{const i="#f5f5f5",e="#737373",s="#d4d4d4",n="#737373",o="#a3a3a3",r=2.76142374915397,l=2.761423749153969,h=new Panel(Panel.Auto,{isActionable:!0,enabledChanged:(a,c)=>{if(a instanceof Panel){const f=a.findObject("ButtonBorder");f!==null&&(c?(a._buttonFillDisabled=f.fill,f.fill=a._buttonFillNormal):(a._buttonFillNormal=f.fill,f.fill=a._buttonFillDisabled))}},cursor:"pointer"}).attach({_buttonFillNormal:i,_buttonStrokeNormal:e,_buttonFillOver:s,_buttonStrokeOver:n,_buttonFillDisabled:o}).add(new Shape("RoundedRectangle",{name:"ButtonBorder",spot1:new Spot(0,0,r,l),spot2:new Spot(1,1,-r,-l),parameter1:2,fill:i,stroke:e}));return h.mouseEnter=(a,c,f)=>{if(!c.isEnabledObject()||!(c instanceof Panel))return;const u=c.findObject("ButtonBorder");u instanceof Shape&&(c._buttonFillNormal=u.fill,u.fill=c._buttonFillOver,c._buttonStrokeNormal=u.stroke,u.stroke=c._buttonStrokeOver)},h.mouseLeave=(a,c,f)=>{if(!c.isEnabledObject()||!(c instanceof Panel))return;const u=c.findObject("ButtonBorder");u instanceof Shape&&(u.fill=c._buttonFillNormal,u.stroke=c._buttonStrokeNormal)},h}),GraphObject.defineBuilder("TreeExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_treeExpandedFigure:"MinusLine",_treeCollapsedFigure:"PlusLine",visible:!1}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.lu}).bindObject("figure","isTreeExpanded",(e,s)=>{const n=s.panel;return e?n._treeExpandedFigure:n._treeCollapsedFigure})),i.bindObject("visible","isTreeLeaf",e=>!e),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Node))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isTreeExpanded){if(!r.canCollapseTree(n))return}else if(!r.canExpandTree(n))return;e.handled=!0,n.isTreeExpanded?r.collapseTree(n):r.expandTree(n)},i}),GraphObject.defineBuilder("SubGraphExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_subGraphExpandedFigure:"MinusLine",_subGraphCollapsedFigure:"PlusLine"}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.lu}).bindObject("figure","isSubGraphExpanded",(e,s)=>{const n=s.panel;return e?n._subGraphExpandedFigure:n._subGraphCollapsedFigure})),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Group))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isSubGraphExpanded){if(!r.canCollapseSubGraph(n))return}else if(!r.canExpandSubGraph(n))return;e.handled=!0,n.isSubGraphExpanded?r.collapseSubGraph(n):r.expandSubGraph(n)},i}),GraphObject.defineBuilder("ToolTip",t=>new Adornment(Panel.Auto,{isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).add(new Shape("RoundedRectangle",{name:"Border",parameter1:1,fill:"#f5f5f5",strokeWidth:0,spot1:new Spot(0,0,4,6),spot2:new Spot(1,1,-4,-4)}))),GraphObject.defineBuilder("ContextMenu",t=>new Adornment(Panel.Vertical,{background:"#f5f5f5",isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).bindObject("background","",i=>i.adornedPart!==null&&i.hasPlaceholder()?null:"#f5f5f5")),GraphObject.defineBuilder("ContextMenuButton",t=>{const i=GraphObject.build("Button");i.stretch=5;const e=i.findObject("ButtonBorder");return e instanceof Shape&&(e.figure="Rectangle",e.strokeWidth=0,e.spot1=new Spot(0,0,4,6),e.spot2=new Spot(1,1,-4,-4)),i}),GraphObject.defineBuilder("PanelExpanderButton",t=>{const i=GraphObject.takeBuilderArgument(t,"COLLAPSIBLE"),e=GraphObject.build("Button");e.attach({_buttonExpandedFigure:"M0 0 M0 6 L4 2 8 6 M8 8",_buttonCollapsedFigure:"M0 0 M0 2 L4 6 8 2 M8 8",_buttonFillNormal:"rgba(0, 0, 0, 0)",_buttonStrokeNormal:null,_buttonFillOver:"rgba(0, 0, 0, .2)",_buttonStrokeOver:null}),e.add(new Shape({name:"ButtonIcon",strokeWidth:2}).bindObject("geometryString","visible",n=>n?e._buttonExpandedFigure:e._buttonCollapsedFigure,void 0,i));const s=e.findObject("ButtonBorder");return s instanceof Shape&&(s.stroke=null,s.fill="rgba(0, 0, 0, 0)"),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=o.diagram;if(r===null||r.isReadOnly)return;let l=o.findBindingPanel();if(l===null&&(l=o.part),l!==null){const h=l.findObject(i);h!==null&&(n.handled=!0,r.startTransaction("Collapse/Expand Panel"),h.visible=!h.visible,r.commitTransaction("Collapse/Expand Panel"))}},e}),GraphObject.defineBuilder("CheckBoxButton",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("Button",{desiredSize:new Size(14,14)});e.attach({"ButtonBorder.spot1":new Spot(0,0,1,1),"ButtonBorder.spot2":new Spot(1,1,-1,-1)});const s=new Shape({name:"ButtonIcon",geometryString:"M0 0 M0 8.85 L4.9 13.75 16.2 2.45 M16.2 16.2",strokeWidth:2,stretch:2,geometryStretch:6,visible:!1});return i!==""&&s.bindTwoWay("visible",i),e.add(s),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=n.diagram;if(r===null||r.isReadOnly||i!==""&&r.model.isReadOnly)return;n.handled=!0;const l=o.findObject("ButtonIcon");r.startTransaction("checkbox"),l!==null&&(l.visible=!l.visible),typeof o._doClick=="function"&&o._doClick(n,o),r.commitTransaction("checkbox")},e}),GraphObject.defineBuilder("CheckBox",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("CheckBoxButton",{name:"Button",isActionable:!1,margin:new Margin(0,1,0,0)},i),s=new Panel("Horizontal",{isActionable:!0,cursor:e.cursor,margin:new Margin(1),mouseEnter:e.mouseEnter,mouseLeave:e.mouseLeave,click:e.click}).attach({_buttonFillNormal:e._buttonFillNormal,_buttonStrokeNormal:e._buttonStrokeNormal,_buttonFillOver:e._buttonFillOver,_buttonStrokeOver:e._buttonStrokeOver,_buttonFillDisabled:e._buttonFillDisabled,_buttonClick:e.click});return s.add(e),e.mouseEnter=null,e.mouseLeave=null,e.click=null,s})}}class GraphObjectTemplateSettings{gi;Mt;$n;Ai;Zn;Ks;Sl;Tr;Dr;Fr;Er;Br;Rr;vr;Or;U0;V0;Ir;z0;X0;K0;Y0;Ur;Vr;M0;v0;ys;xr;br;to;R0;F0;wr;k0;H0;q0;constructor(){this.gi=!1,this.Mt="",this.$n=-1,this.Ai=null,this.Zn=null,this.Ks=null,this.Sl="",this.Tr=null,this.Dr=null,this.Fr=null,this.Er=null,this.Br=null,this.Rr=null,this.vr=null,this.Or=null,this.U0=null,this.V0=null,this.Ir=null,this.z0=null,this.X0=null,this.K0=null,this.Y0=null,this.Ur=null,this.Vr=null,this.M0=null,this.v0=null,this.ys=null,this.xr=Size.ru,this.br=Size.iC,this.to=1,this.R0=1,this.F0=1,this.wr=0,this.k0=null,this.H0=null,this.q0="category"}copy(){const t=new GraphObjectTemplateSettings;return t.Mt=this.Mt,t.$n=this.$n,t.Ai=this.Ai,t.Ks=this.Ks,t.Sl=this.Sl,t.Tr=this.Tr,t.Dr=this.Dr,t.Fr=this.Fr,t.Er=this.Er,t.Br=this.Br,t.Rr=this.Rr,t.vr=this.vr,t.Or=this.Or,t.U0=this.U0,t.V0=this.V0,t.Ir=this.Ir,t.z0=this.z0,t.X0=this.X0,t.K0=this.K0,t.Y0=this.Y0,t.Ur=this.Ur,t.Vr=this.Vr,t.M0=this.M0,t.v0=this.v0,t.ys=this.ys,t.xr=this.xr.N(),t.br=this.br.N(),t.to=this.to,t.R0=this.R0,t.F0=this.F0,t.wr=this.wr,t.k0=this.k0,t.H0=this.H0,t.q0=this.q0,t}}class STransform{m;constructor(){this.m=[1,0,0,1,0,0]}copy(){const t=new STransform;return t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5],t}translate(t,i){this.m[4]+=this.m[0]*t+this.m[2]*i,this.m[5]+=this.m[1]*t+this.m[3]*i}scale(t,i){this.m[0]*=t,this.m[1]*=t,this.m[2]*=i,this.m[3]*=i}rotate(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return;this.translate(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m[0]*s+this.m[2]*n,r=this.m[1]*s+this.m[3]*n,l=this.m[0]*-n+this.m[2]*s,h=this.m[1]*-n+this.m[3]*s;this.m[0]=o,this.m[1]=r,this.m[2]=l,this.m[3]=h,this.translate(-i,-e)}}class SGradient{type;x1;y1;r1;x2;y2;r2;colors;pattern;constructor(t){this.type=t,this.x1=0,this.y1=0,this.r1=0,this.x2=0,this.y2=0,this.r2=0,this.colors=[],this.pattern=null}addColorStop(t,i){this.colors.push({offset:t,color:i})}}class SVGSurface{Ft;ai;aa;Gu;m2;constructor(t,i,e){const s=i===void 0?root.document:i;this.aa=s,this.m2="http://www.w3.org/2000/svg";const n="http://www.w3.org/2000/xmlns/";s!==void 0&&(this.Ft=this.makeElement("svg",{width:"1px",height:"1px",viewBox:"0 0 1 1"}),this.style.display="block",this.style.letterSpacing="normal",this.style.wordSpacing="normal",e||(this.style.position="absolute"),this.Ft.setAttributeNS(n,"xmlns",this.m2),this.Ft.setAttributeNS(n,"xmlns:xlink","http://www.w3.org/1999/xlink")),this.Gu=null,this.ai=new SVGContext(this,e)}resize(t,i,e,s){return this.width!==t||this.height!==i?(this.width=t,this.height=i,this.style.width=e+"px",this.style.height=s+"px",this.Ft.setAttributeNS(null,"width",e+"px"),this.Ft.setAttributeNS(null,"height",s+"px"),this.Ft.setAttributeNS(null,"viewBox","0 0 "+e+" "+s),this.ai.p2.firstElementChild.setAttributeNS(null,"width",e+"px"),this.ai.p2.firstElementChild.setAttributeNS(null,"height",s+"px"),!0):!1}makeElement(t,i,e){const s=this.aa.createElementNS(this.m2,t);if(Util.wt(i))for(const n in i)s.setAttributeNS(n==="href"?"http://www.w3.org/1999/xlink":"",n,i[n]);return e!==void 0&&(s.textContent=e),s}getBoundingClientRect(){return this.Ft.getBoundingClientRect()}focus(){this.Ft.focus()}get width(){return this.Ft.width.baseVal.value}set width(t){this.Ft.setAttribute("width",t+"px")}get height(){return this.Ft.height.baseVal.value}set height(t){this.Ft.setAttribute("height",t+"px")}dispose(){this.aa=null}get style(){return this.Ft.style}}class SVGContext{nf;of;xn;Ti;Ke;fillStyle;font;globalAlpha;lineCap;lineDashOffset;lineJoin;lineWidth;miterLimit;shadowBlur;shadowColor;shadowOffsetX;shadowOffsetY;strokeStyle;textAlign;imageSmoothingEnabled;clipInsteadOfFill;lastCreatedElement;rf;lf;surface;svg;p2;cA;Vb;Xo;dh;ka;currentElement;clipPathGroup;diagramGroup;lastDrawnPart;currentPath;outerGroup;pathAttributes;tl;Mr;filter;partClipRect;constructor(t,i){this.surface=t,this.svg=t.Ft,this.rf=[],this.lf=[],this.fillStyle="#000000",this.font="10px sans-serif",this.globalAlpha=1,this.lineCap="butt",this.lineDashOffset=0,this.lineJoin="miter",this.lineWidth=1,this.miterLimit=10,this.shadowBlur=0,this.shadowColor="rgba(0, 0, 0, 0)",this.shadowOffsetX=0,this.shadowOffsetY=0,this.tl=!1,this.strokeStyle="#000000",this.textAlign="start",this.clipInsteadOfFill=!1,this.nf=0,this.of=0,this.xn=0,this.lastCreatedElement=null,this.currentElement=null,this.Ti=[],this.pathAttributes={},this.Vb=!1,this.Xo=null,this.dh=0,this.Ke=new STransform,this.clipPathGroup=this.newGroup2(),this.diagramGroup=this.newGroup2("gojs-diagram"),this.lastDrawnPart=null,this.currentPath=null;const e=GSet.su++,s=this.makeElement("clipPath",{id:"mainClip"+e}),n={x:0,y:0,width:t.width,height:t.height};s.appendChild(this.makeElement("rect",n)),this.p2=s,this.svg.appendChild(this.clipPathGroup),this.clipPathGroup.appendChild(this.diagramGroup),this.svg.appendChild(s),this.clipPathGroup.setAttributeNS(null,"clip-path","url(#mainClip"+e+")"),this.cA={},this.Mr=!!i,this.filter="",this.partClipRect=null}setDiagramPosScale(t,i,e,s,n,o){this.diagramGroup===void 0?this.newGroup(t,i,e,s,n,o):this.diagramGroup.setAttribute("transform","matrix("+t+", "+i+", "+e+", "+s+", "+n+", "+o+")")}resetInnerSVG(){this.diagramGroup!==null&&(this.diagramGroup.innerHTML="")}arc(t,i,e,s,n,o,r,l){const h=2*Math.PI,a=1e-6,c=h-a,f=e*Math.cos(s),u=e*Math.sin(s),d=t+f,m=i+u,g=o?0:1;let p=o?s-n:n-s;(Math.abs(r-d)>a||Math.abs(l-m)>a)&&this.Ti.push(["L",d,+m]),p<0&&(p=p%h+h),p>c?(this.Ti.push(["A",e,e,0,1,g,t-f,i-u]),this.Ti.push(["A",e,e,0,1,g,d,m])):p>a&&this.Ti.push(["A",e,e,0,+(p>=Math.PI),g,t+e*Math.cos(n),i+e*Math.sin(n)])}beginPath(){this.Ti=[],this.pathAttributes={stroke:"none",fill:"none"}}endPath(t){this.BR(this.Ti,this.Ke,t||0)}bezierCurveTo(t,i,e,s,n,o){this.Ti.push(["C",t,i,e,s,n,o])}clearRect(t,i,e,s){}clip(){this.pathAttributes.clipPath=!0}closePath(){this.Ti.push(["z"])}createLinearGradient(t,i,e,s){const n=new SGradient("linear");return n.x1=t,n.y1=i,n.x2=e,n.y2=s,n}createPattern(t,i){let e="";t instanceof HTMLCanvasElement&&(e=t.toDataURL()),t instanceof HTMLImageElement&&(e=t.getAttribute("src"));const s=this.cA;if(s[e])return"url(#"+s[e]+")";const n="PATTERN"+GSet.su++,o={width:t.width,height:t.height,id:n,patternUnits:"userSpaceOnUse"},r={x:0,y:0,width:t.width,height:t.height,href:e},l=this.makeElement("pattern",o);return l.appendChild(this.makeElement(Diagram.img,r)),this.svg.appendChild(l),s[e]=n,"url(#"+n+")"}createRadialGradient(t,i,e,s,n,o){const r=new SGradient("radial");return r.x1=t,r.y1=i,r.r1=e,r.x2=s,r.y2=n,r.r2=o,r}amendImageTransform(t,i,e,s,n,o,r,l){const h=r/e,a=l/s;(n!==0||o!==0)&&this.Ke.translate(n,o),(h!==1||a!==1)&&this.Ke.scale(h,a),(t!==0||i!==0)&&this.Ke.translate(-t,-i)}drawImage(t,i,e,s,n,o,r,l,h){let a="";t instanceof HTMLCanvasElement&&(a=t.toDataURL()),t instanceof HTMLImageElement&&(a=t.getAttribute("src"));const c=t instanceof HTMLImageElement?t.naturalWidth:t.width,f=t instanceof HTMLImageElement?t.naturalHeight:t.height;s===void 0&&(o=i,r=e,l=s=c,h=n=f),s=s||0,n=n||0,o=o||0,r=r||0,l=l||0,h=h||0,this.amendImageTransform(i,e,s,n,o,r,l,h);const u={x:0,y:0,width:c||s,height:f||n,href:a};!Geo.K(s,l)||!Geo.K(n,h)?u.preserveAspectRatio="none":a.toLowerCase().indexOf(".svg")===-1&&a.toLowerCase().indexOf("data:image/svg")===-1&&(u.preserveAspectRatio="xMidYMid slice"),(i!==0||e!==0||s!==c||n!==f)&&(s+=i,n+=e,u["clip-path"]=`path('M ${i},${e} L ${s} ${e} L ${s} ${n} L ${i} ${n} z')`),this.processCommon(Diagram.img,u,this.Ke),this.od(Diagram.img,u)}fill(t,i){t&&(this.pathAttributes["fill-rule"]="evenodd"),this.setFill(this.pathAttributes)}fillContext(t,i,e){this.clipInsteadOfFill?this.clip():this.fill(i,e)}createOrUpdateClipGroup(t,i){const e=this.newGroup(1,0,0,1,-i.x,-i.y);e.setAttributeNS(null,"class","spotClip"),t.rh=e}fillRect(t,i,e,s){this.addRect("fill",[t,i,e,s],this.Ke)}fillBackground(t,i,e,s){const n={x:t,y:i,width:e,height:s};this.processCommon("fill",n,this.Ke),this.setFill(n),this.svg.prepend(this.makeElement("rect",n))}fillText(t,i,e){this.addText("fill",[t,i,e],this.Ke)}lineTo(t,i){this.Ti.push(["L",t,i])}moveTo(t,i){this.Ti.push(["M",t,i])}quadraticCurveTo(t,i,e,s){this.Ti.push(["Q",t,i,e,s])}rect(t,i,e,s){this.Ti.push(["M",t,i],["L",t+e,i],["L",t+e,i+s],["L",t,i+s],["z"])}restore(){this.Ke=this.rf.pop(),this.Ti=this.rf.pop();const t=this.rf.pop();this.fillStyle=t.fillStyle,this.font=t.font,this.globalAlpha=t.globalAlpha,this.lineCap=t.lineCap,this.lineDashOffset=t.lineDashOffset,this.lineJoin=t.lineJoin,this.lineWidth=t.lineWidth,this.miterLimit=t.miterLimit,this.shadowBlur=t.shadowBlur,this.shadowColor=t.shadowColor,this.shadowOffsetX=t.shadowOffsetX,this.shadowOffsetY=t.shadowOffsetY,this.strokeStyle=t.strokeStyle,this.textAlign=t.textAlign,this.partClipRect=t.partClipRect}save(){const t={fillStyle:this.fillStyle,font:this.font,globalAlpha:this.globalAlpha,lineCap:this.lineCap,lineDashOffset:this.lineDashOffset,lineJoin:this.lineJoin,lineWidth:this.lineWidth,miterLimit:this.miterLimit,shadowBlur:this.shadowBlur,shadowColor:this.shadowColor,shadowOffsetX:this.shadowOffsetX,shadowOffsetY:this.shadowOffsetY,strokeStyle:this.strokeStyle,textAlign:this.textAlign,partClipRect:this.partClipRect};this.rf.push(t);const i=[];for(let e=0;eh.offset>a.offset?1:-1);for(let h=0;h1&&this.lf[this.lf.length-2].setAttributeNS(null,"clip-path",'path("'+s+'") view-box');return}if(n.d=s,this.processCommon("",n,i),this.currentPath!==null){const r=this.currentPath;if(r.nodeName!=="g")for(const l in n)l!=="transform"&&r.setAttributeNS(null,l,n[l]);else{const l=r.getElementsByTagName("path");for(const h in n)h!=="transform"&&l[e].setAttributeNS(null,h,n[h])}}else this.od("path",n)}TR(t){const i=t.getAttribute("clip-path");return i===null?null:this.svg.getElementById(i.split("#")[1].slice(0,-1))}rA(t){const i=t.getAttribute("clip-path");if(i===null)return;const e=this.svg.getElementById(i.split("#")[1].slice(0,-1));e!==null&&e.remove()}UR(t){const i=[];for(let e=0;es?(this.scale(s/n,1),this.translate((n-s)/2,0)):s>n&&(this.scale(1,n/s),this.translate(0,(s-n)/2)),this.fillOrClip(i,e),n>s?(this.translate(-(n-s)/2,0),this.scale(1/(s/n),1)):s>n&&(this.translate(0,-(s-n)/2),this.scale(1,1/(n/s))),!0}strokeContext(){this.clipInsteadOfFill||this.stroke()}fillOrClip(t,i){this.clipInsteadOfFill?this.clip(i):this.fill(t,i)}shadowsSet(t,i,e){this.nf=t,this.of=i,this.xn=e}shadowsOff(){this.tl=!1,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0}shadowsOn(){this.tl=!0,this.shadowOffsetX=this.nf,this.shadowOffsetY=this.of,this.shadowBlur=this.xn}enableDash(t,i){const e=this.U;e.setLineDash!==void 0&&(e.setLineDash(t),e.lineDashOffset=i)}disableDash(){const t=this.U;t.setLineDash!==void 0&&(t.setLineDash(CanvasSurfaceContext.EmptyArray),t.lineDashOffset=0)}clearContextCache(t){t&&(this.zb=""),this.Xb="",this.Kb=""}removePartFromView(t){}static EmptyArray=Object.freeze([])}var BrushType=(w=>(w[w.Solid=1]="Solid",w[w.Linear=2]="Linear",w[w.Radial=3]="Radial",w[w.Pattern=4]="Pattern",w))(BrushType||{}),ColorSpace=(w=>(w[w.Lab=1]="Lab",w[w.HSL=2]="HSL",w[w.Oklch=3]="Oklch",w))(ColorSpace||{});class ColorNumbers{n0;n1;n2;n3;constructor(){this.n0=0,this.n1=0,this.n2=0,this.n3=0}}class Brush{h;$;Pa;si;gs;W0;J0;bn;$0;yn;_c;Eb;constructor(t,i){if(GSet.Yi(this),this.h=!1,t===void 0)this.$=1,this.Pa="black";else if(typeof t=="string"){const s=Util.Ih(BrushType,t);s!==null?(this.$=s,this.Pa="black"):(this.$=1,this.Pa=t)}else this.$=t,this.Pa="black";const e=this.$;if(e===2?(this.si=Spot.TopCenter,this.gs=Spot.BottomCenter):e===3?(this.si=Spot.Center,this.gs=Spot.Center):(this.si=Spot.None,this.gs=Spot.None),this.W0=0,this.J0=NaN,this.bn=null,this.$0=null,this.yn=null,this._c=0,this.Eb=0,i){const s={};for(const n in i)isFinite(parseFloat(n))?this.addColorStop(parseFloat(n),i[n]):s[n]=i[n];Object.assign(this,s)}}copy(){const t=new Brush;return t.$=this.$,t.Pa=this.Pa,t.si=this.si.N(),t.gs=this.gs.N(),t.W0=this.W0,t.J0=this.J0,this.bn!==null&&(t.bn=this.bn.copy()),t.$0=this.$0,t}g(){return this.h=!0,this.bn!==null&&this.bn.g(),this}ot(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this.bn!==null&&this.bn.ot(),this}ri(t){t in BrushType?this.type=t:Util.lr(this,t)}toString(){let t="Brush(";if(this.type===1)t+=this.color;else if(this.type===2?t+="Linear ":this.type===3?t+="Radial ":this.type===4?t+="Pattern ":t+="(unknown) ",t+=this.start+" "+this.end,this.colorStops!==null){const i=this.colorStops.iterator;for(;i.next();){const e=i.key,s=i.value;t+=" "+e+":"+s}}return t+=")",t}addColorStop(t,i){return this.h&&Util.T(this),(typeof t!="number"||!isFinite(t)||t>1||t<0)&&Util._(t,"0 <= loc <= 1",Brush,"addColorStop:loc"),Util.i(i,"string",Brush,"addColorStop:color"),this.bn===null&&(this.bn=new GMap),this.bn.set(t,i),this.$===1&&(this.type=2),this.yn=null,this}get type(){return this.$}set type(t){this.h&&Util.T(this,t),this.$=t,this.start.isNoSpot()&&(t===2?this.start=Spot.TopCenter:t===3&&(this.start=Spot.Center)),this.end.isNoSpot()&&(t===2?this.end=Spot.BottomCenter:t===3&&(this.end=Spot.Center)),this.yn=null}get color(){return this.Pa}set color(t){this.h&&Util.T(this,t),this.Pa=t,this.yn=null}get start(){return this.si}set start(t){this.h&&Util.T(this,t),this.si=t.N(),this.yn=null}get end(){return this.gs}set end(t){this.h&&Util.T(this,t),this.gs=t.N(),this.yn=null}get startRadius(){return this.W0}set startRadius(t){this.h&&Util.T(this,t),t<0&&Util._(t,">= zero",Brush,"startRadius"),this.W0=t,this.yn=null}get endRadius(){return this.J0}set endRadius(t){this.h&&Util.T(this,t),t<0&&Util._(t,">= zero",Brush,"endRadius"),this.J0=t,this.yn=null}get colorStops(){return this.bn}set colorStops(t){this.h&&Util.T(this,t),this.bn=t,this.yn=null}get pattern(){return this.$0}set pattern(t){this.h&&Util.T(this,t),this.$0=t,this.yn=null}static randomColor(t,i){t===void 0&&(t=128),i===void 0&&(i=Math.max(t,255));const e=Math.abs(i-t);let s=Math.floor(t+Math.random()*e).toString(16),n=Math.floor(t+Math.random()*e).toString(16),o=Math.floor(t+Math.random()*e).toString(16);return s.length<2&&(s="0"+s),n.length<2&&(n="0"+n),o.length<2&&(o="0"+o),"#"+s+n+o}static isValidColor(t){return root.CSS?root.CSS.supports("color",t):!0}static lighten(t){return Brush.lightenBy(t)}lightenBy(t,i){this.h&&Util.T(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Do(this.color),this.color=Brush.rd(e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Do(n.value),this.addColorStop(n.key,Brush.rd(e,s))}return this}static lightenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Do(t),Brush.rd(s,n)}static darken(t){return Brush.darkenBy(t)}darkenBy(t,i){this.h&&Util.T(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Do(this.color),this.color=Brush.rd(-e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Do(n.value),this.addColorStop(n.key,Brush.rd(-e,s))}return this}static darkenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Do(t),Brush.rd(-s,n)}static mix(t,i,e){Brush.Do(t);const s=Brush.G.n0,n=Brush.G.n1,o=Brush.G.n2,r=Brush.G.n3;Brush.Do(i),e===void 0&&(e=.5);const l=Math.round((Brush.G.n0-s)*e+s),h=Math.round((Brush.G.n1-n)*e+n),a=Math.round((Brush.G.n2-o)*e+o),c=Math.round((Brush.G.n3-r)*e+r);return`rgba(${l}, ${h}, ${a}, ${c})`}isDark(){if(this.type===1)return Brush.isDark(this.color);if((this.type===2||this.type===3)&&this.colorStops!==null){const t=this.colorStops;if(this.type===3)return Brush.isDark(t.first().value);if(t.get(.5)!==null)return Brush.isDark(t.get(.5));if(t.count===2){const l=t.toArray();return Brush.isDark(Brush.mix(l[0].value,l[1].value))}const i=t.iterator;let e=-1,s=-1,n=1,o=1;for(;i.next();){const l=i.key,h=Math.abs(.5-i.key);n>o&&h=n&&hs){let l=e;e=s,s=l,l=n,n=o,o=l}const r=s-e;return Brush.isDark(Brush.mix(t.get(e),t.get(s),1-o/r))}return!1}static isDark(t){return t?t instanceof Brush?t.isDark():(Brush.Do(t),(299*Brush.G.n0+587*Brush.G.n1+114*Brush.G.n2)/1e3<128):!1}static rd(t,i){switch(i){case 1:return Brush.VR(),Brush.io.n0=Math.min(100,Math.max(0,Brush.io.n0+100*t)),Brush.zR(),"rgba("+Brush.G.n0+", "+Brush.G.n1+", "+Brush.G.n2+", "+Brush.G.n3+")";case 2:return Brush.OS(),Brush.Ii.n2=Math.min(100,Math.max(0,Brush.Ii.n2+100*t)),"hsla("+Brush.Ii.n0+", "+Brush.Ii.n1+"%, "+Brush.Ii.n2+"%, "+Brush.Ii.n3+")";case 3:return Brush.XR(),Brush.eo.n0=Math.min(100,Math.max(0,Brush.eo.n0+100*t)),Brush.KR(),"rgba("+Brush.G.n0+", "+Brush.G.n1+", "+Brush.G.n2+", "+Brush.G.n3+")";default:Util.o("Unknown color space: "+i)}}static Do(t){const i=Brush.il;if(i===null)return;i.clearRect(0,0,1,1),i.fillStyle="#000000";const e=i.fillStyle;if(i.fillStyle=t,i.fillStyle!==e){i.fillRect(0,0,1,1);const s=i.getImageData(0,0,1,1).data;Brush.G.n0=s[0],Brush.G.n1=s[1],Brush.G.n2=s[2],Brush.G.n3=s[3]/255}else{i.fillStyle="#FFFFFF";const s=i.fillStyle;i.fillStyle=t,i.fillStyle,Brush.G.n0=0,Brush.G.n1=0,Brush.G.n2=0,Brush.G.n3=1}}static OS(){const t=Brush.G.n0/255,i=Brush.G.n1/255,e=Brush.G.n2/255,s=Math.max(t,i,e),n=Math.min(t,i,e),o=s-n;let r,l;const h=(s+n)/2;if(o===0)r=l=0;else{switch(s){case t:r=(i-e)/o%6;break;case i:r=(e-t)/o+2;break;case e:r=(t-i)/o+4;break}r*=60,r<0&&(r+=360),l=o/(1-Math.abs(2*h-1))}Brush.Ii.n0=Math.round(r),Brush.Ii.n1=Math.round(l*100),Brush.Ii.n2=Math.round(h*100),Brush.Ii.n3=Brush.G.n3}static uE(){const t=Brush.Ii.n0,i=Brush.Ii.n1/100,e=Brush.Ii.n2/100;let s,n,o;const r=(1-Math.abs(2*e-1))*i,l=t/60,h=r*(1-Math.abs(l%2-1));l>=0&&l<1?(s=r,n=h,o=0):l>=1&&l<2?(s=h,n=r,o=0):l>=2&&l<3?(s=0,n=r,o=h):l>=3&&l<4?(s=0,n=h,o=r):l>=4&&l<5?(s=h,n=0,o=r):l>=5&&l<6&&(s=r,n=0,o=h);const a=e-.5*r;s+=a,n+=a,o+=a,Brush.G.n0=Math.round(s*255),Brush.G.n1=Math.round(n*255),Brush.G.n2=Math.round(o*255),Brush.G.n3=Brush.Ii.n3}static VR(){Brush.fA(),Brush.YR()}static zR(){Brush.GR(),Brush.uA()}static w2(t){return t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}static b2(t){return t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055}static fA(){const t=Brush.w2(Brush.G.n0),i=Brush.w2(Brush.G.n1),e=Brush.w2(Brush.G.n2);Brush.Rt.n0=.4124564*t+.3575761*i+.1804375*e,Brush.Rt.n1=.2126729*t+.7151522*i+.072175*e,Brush.Rt.n2=.0193339*t+.119192*i+.9503041*e,Brush.Rt.n3=Brush.G.n3}static uA(){const t=3.2404542*Brush.Rt.n0+-1.5371385*Brush.Rt.n1+-.4985314*Brush.Rt.n2,i=-.969266*Brush.Rt.n0+1.8760108*Brush.Rt.n1+.041556*Brush.Rt.n2,e=.0556434*Brush.Rt.n0+-.2040259*Brush.Rt.n1+1.0572252*Brush.Rt.n2;Brush.G.n0=Brush.b2(t)*255,Brush.G.n1=Brush.b2(i)*255,Brush.G.n2=Brush.b2(e)*255,Brush.G.n3=Brush.Rt.n3,Brush.G.n0=Math.round(Brush.G.n0),Brush.G.n0>255?Brush.G.n0=255:Brush.G.n0<0&&(Brush.G.n0=0),Brush.G.n1=Math.round(Brush.G.n1),Brush.G.n1>255?Brush.G.n1=255:Brush.G.n1<0&&(Brush.G.n1=0),Brush.G.n2=Math.round(Brush.G.n2),Brush.G.n2>255?Brush.G.n2=255:Brush.G.n2<0&&(Brush.G.n2=0)}static k2=216/24389;static Yb=24389/27;static ld=[95.047,100,108.883];static P2(t){return t>Brush.k2?Math.pow(t,1/3):(Brush.Yb*t+16)/116}static YR(){const t=Brush.P2(Brush.Rt.n0*100/Brush.ld[0]),i=Brush.P2(Brush.Rt.n1*100/Brush.ld[1]),e=Brush.P2(Brush.Rt.n2*100/Brush.ld[2]);Brush.io.n0=116*i-16,Brush.io.n1=500*(t-i),Brush.io.n2=200*(i-e),Brush.io.n3=Brush.Rt.n3}static dA(t){const i=t*t*t;return i>Brush.k2?i:(116*t-16)/Brush.Yb}static GR(){const t=(Brush.io.n0+16)/116,i=Brush.io.n1/500+t,e=t-Brush.io.n2/200;Brush.Rt.n0=Brush.ld[0]/100*Brush.dA(i),Brush.Rt.n1=Brush.ld[1]/100*(Brush.io.n0>Brush.Yb*Brush.k2?Math.pow(t,3):Brush.io.n0/Brush.Yb),Brush.Rt.n2=Brush.ld[2]/100*Brush.dA(e),Brush.Rt.n3=Brush.io.n3}static jR(){let t=.8190224*Brush.Rt.n0+.3619062*Brush.Rt.n1+-.1288737*Brush.Rt.n2,i=.03298366*Brush.Rt.n0+.9292868*Brush.Rt.n1+.03614466*Brush.Rt.n2,e=.04817719*Brush.Rt.n0+.2642395*Brush.Rt.n1+.6335478*Brush.Rt.n2;t=Math.cbrt(t),i=Math.cbrt(i),e=Math.cbrt(e),Brush.ci.n0=.2104542*t+.7936177*i+-.004072046*e,Brush.ci.n1=1.977998*t+-2.428592*i+.4505937*e,Brush.ci.n2=.02590403*t+.7827717*i+-.8086757*e,Brush.ci.n3=Brush.Rt.n3,Brush.ci.n0*=100}static HR(){Brush.ci.n0/=100;let t=.9999999*Brush.ci.n0+.3963377*Brush.ci.n1+.2158037*Brush.ci.n2,i=1.000000009*Brush.ci.n0+-.1055613*Brush.ci.n1+-.06385417*Brush.ci.n2,e=1.00000005*Brush.ci.n0+-.08948418*Brush.ci.n1+-1.291485*Brush.ci.n2;t=t**3,i=i**3,e=e**3,Brush.Rt.n0=1.2268798*t+-.5578149*i+.281391*e,Brush.Rt.n1=-.04057576*t+1.112286*i+-.07171106*e,Brush.Rt.n2=-.07637294*t+-.4214933*i+1.586924*e,Brush.Rt.n3=Brush.ci.n3}static qR(){const t=Math.atan2(Brush.ci.n2,Brush.ci.n1)*180/Math.PI;Brush.eo.n0=Brush.ci.n0,Brush.eo.n1=Math.sqrt(Brush.ci.n1**2+Brush.ci.n2**2),Brush.eo.n2=t>=0?t:t+360,Brush.eo.n3=Brush.ci.n3}static WR(){Brush.ci.n0=Brush.eo.n0,Brush.ci.n1=Brush.eo.n1*Math.cos(Brush.eo.n2*Math.PI/180),Brush.ci.n2=Brush.eo.n1*Math.sin(Brush.eo.n2*Math.PI/180),Brush.ci.n3=Brush.eo.n3}static XR(){Brush.fA(),Brush.jR(),Brush.qR()}static KR(){Brush.WR(),Brush.HR(),Brush.uA()}static nd(t,i){typeof t=="string"||t instanceof Brush||Util.o("Value for "+i+" must be a color string or a Brush, not "+t)}static Solid=1;static Linear=2;static Radial=3;static Pattern=4;static Lab=1;static HSL=2;static il=Diagram.isUsingDOM()?new CanvasSurface(null,void 0,{willReadFrequently:!0}).ai:null;static G=new ColorNumbers;static Ii=new ColorNumbers;static Rt=new ColorNumbers;static io=new ColorNumbers;static ci=new ColorNumbers;static eo=new ColorNumbers}class PanelLayout{Mt="Base";static Layouts=new GMap;static definePanelLayout(t,i){i.name=t,PanelLayout.Layouts.set(t,i)}get name(){return this.Mt}set name(t){this.Mt=t}constructor(){}get classType(){return Panel}measure(t,i,e,s,n,o,r){}measureElement(t,i,e,s,n){t.ut(i,e,s,n)}arrange(t,i,e){}arrangeElement(t,i,e,s,n,o){t.zt(i,e,s,n,o)}remeasureObject(t){t.tf()}Gi(t,i,e){}}class PanelLayoutPosition extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=s.length,h=t.Ko();for(let a=0;a0&&(M=Math.max(Math.abs(k.x*o+k.offsetX-(S.x*o+S.offsetX))-g,0)),r>0&&(N=Math.max(Math.abs(k.y*r+k.offsetY-(S.y*r+S.offsetY))-g,0));const T=Size.l();T.e(0,0);const A=t.Ko();for(let v=0;v1,ot=it.columnSpan>1;(ct||ot)&&!(Ky&&(M=Math.max(y-dt,0)),b.ji=b.ji+M,b.actual=b.st+M,y=Math.max(y-(M+(mt?dt:0)),0)}if(it.columnSpan===1&&(N===0||N===4)){b=t.getColumnDefinition(j);const dt=b.computeEffectiveSpacing(),mt=b.st===0;M=Math.max(ut-b.actual,0),M+(mt?dt:0)>p&&(M=Math.max(p-dt,0)),b.ji=b.ji+M,b.actual=b.st+M,p=Math.max(p-(M+(mt?dt:0)),0)}(ct||ot)&&it.tf()}}}Util.tt(f);let A=0,D=0;l=t.columnCount;for(let K=0;K=t.rowCount);Z++)b=t.getRowDefinition(I.row+Z),M=0,N===2||N===4?M=Math.max(b.minimum,V[I.row+Z]===0?b.maximum:Math.min(V[I.row+Z],b.maximum)):M=Math.max(b.minimum,isNaN(b.ge)?b.maximum:Math.min(b.ge,b.maximum)),E.height+=M,_+=b.minimum;for(let Z=1;Z=t.columnCount);Z++)b=t.getColumnDefinition(I.column+Z),M=0,N===2||N===5?M=Math.max(b.minimum,U[I.column+Z]===0?b.maximum:Math.min(U[I.column+Z],b.maximum)):M=Math.max(b.minimum,isNaN(b.ge)?b.maximum:Math.min(b.ge,b.maximum)),E.width+=M,et+=b.minimum;X.width+=E.width,X.height+=E.height;const tt=I.margin,it=tt.right+tt.left,ct=tt.top+tt.bottom;I.ut(X.width,X.height,et,_);const ot=I.measuredBounds,lt=Math.max(ot.width+it,0),st=Math.max(ot.height+ct,0);let nt=0;for(let Z=0;Z=t.rowCount);Z++)b=t.getRowDefinition(I.row+Z),nt+=b.total||0;if(nt=t.rowCount);at++){b=t.getRowDefinition(I.row+at);const ut=b.st||0,gt=rt(I,b,ft);b.actual=Math.min(b.maximum,ut+gt),b.st!==ut&&(Z-=b.st-ut)}}for(;Z>0;){const rt=b.st||0;if(isNaN(b.height)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+Z),b.st!==rt&&(Z-=b.st-rt)),b.index===0)break;b=t.getRowDefinition(b.index-1)}}let ht=0;for(let Z=0;Z=t.columnCount);Z++)b=t.getColumnDefinition(I.column+Z),ht+=b.total||0;if(ht=t.columnCount);at++){b=t.getColumnDefinition(I.column+at);const ut=b.st||0,gt=rt(I,b,ft);b.actual=Math.min(b.maximum,ut+gt),b.st!==ut&&(Z-=b.st-ut)}}for(;Z>0;){const rt=b.st||0;if(isNaN(b.width)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+Z),b.st!==rt&&(Z-=b.st-rt)),b.index===0)break;b=t.getColumnDefinition(b.index-1)}}}Util.tt(u),Size.s(E),Size.s(X),V!==void 0&&Util.tt(V),U!==void 0&&Util.tt(U);let Y=0,G=0;const H=t.desiredSize,J=t.maxSize;N=t.zs(!0),A=0,D=0;let z=0,W=0;l=t.columnCount;for(let K=0;K0){for(;p!==c&&(u[p]===void 0||u[p].st===0);)p++;p=Math.max(Math.min(p,c-1),0),m=-u[p].position}let y=Math.min(t.leftIndex,f-1);if(d.length>0){for(;y!==f&&(d[y]===void 0||d[y].st===0);)y++;y=Math.max(Math.min(y,f-1),0),g=-d[y].position}let x=0,k=0;for(;x!==c&&u[x]===void 0;)x++;for(;k!==c&&d[k]===void 0;)k++;const b=t.part;let P=t.getRowDefinition(x),S=t.getColumnDefinition(k);for(let C=0;C=t.rowCount);st++){const nt=t.getRowDefinition(C+st);nt.st!==0&&(L.height+=nt.total)}for(let st=1;st=t.columnCount);st++){const nt=t.getColumnDefinition(N+st);nt.st!==0&&(L.width+=nt.total)}const O=T.st+L.width,B=M.st+L.height;let X=h,E=a;const V=O,U=B,Y=h,G=a;let H=O,J=B;h+O>e.width&&(H=Math.max(e.width-h,0)),a+B>e.height&&(J=Math.max(e.height-a,0));let z=R.alignment,W=0,q=0,Q=0,K=0;if(z.isDefault()){z=t.defaultAlignment,z.isSpot()||(z=Spot.Center),W=z.x,q=z.y,Q=z.offsetX,K=z.offsetY;const st=T.alignment,nt=M.alignment;st.isSpot()&&(W=st.x,Q=st.offsetX),nt.isSpot()&&(q=nt.y,K=nt.offsetY)}else W=z.x,q=z.y,Q=z.offsetX,K=z.offsetY;(isNaN(W)||isNaN(q))&&(W=.5,q=.5,Q=0,K=0);let I=v.width,j=v.height;const $=R.margin,et=$.left+$.right,_=$.top+$.bottom,tt=R.N0(M,T,!1);isNaN(R.desiredSize.width)&&(tt===2||tt===5)&&(I=Math.max(O-et,0)),isNaN(R.desiredSize.height)&&(tt===2||tt===4)&&(j=Math.max(B-_,0));const it=R.maxSize,ct=R.minSize;I=Math.min(it.width,I),j=Math.min(it.height,j),I=Math.max(ct.width,I),j=Math.max(ct.height,j);const ot=I+et,lt=j+_;X+=V*W-ot*W+Q+$.left,E+=U*q-lt*q+K+$.top,R.visible&&(Rect.contains(Y,G,H,J,X,E,v.width,v.height)?R.zt(X,E,I,j):R.zt(X,E,I,j,new Rect(Y,G,H,J)))}}}Size.s(L);for(let C=0;C0&&(b.figure==="LineV"||b.figure==="LineH")){if(i.lineWidth=b.strokeWidth,t.dn(i,b.stroke,!1,!1,l,h),i.beginPath(),b.figure==="LineV"){const D=Math.floor((m-o)/o);for(let F=D;F<=D+f;F++){const R=F*o+m;0<=R&&R<=a&&this.jb(F,P,L,N)&&(i.moveTo(R,0),i.lineTo(R,c))}}else if(b.figure==="LineH"){const D=Math.floor((g-r)/r);for(let F=D;F<=D+u;F++){const R=F*r+g;0<=R&&R<=c&&this.jb(F,P,L,N)&&(i.moveTo(0,R),i.lineTo(a,R))}}i.stroke(),i.endPath()}else if(b.fill!==null){if(t.dn(i,b.fill,!0,!1,l,h),b.figure==="BarV"){let D=b.width;isNaN(D)&&(D=o);const F=Math.floor((m-o)/o);for(let R=F;R<=F+f;R++){const v=R*o+m;0<=v+D&&v<=a&&this.jb(R,P,L,N)&&i.fillRect(v,0,D,c)}}else if(b.figure==="BarH"){let D=b.height;isNaN(D)&&(D=r);const F=Math.floor((g-r)/r);for(let R=F;R<=F+u;R++){const v=R*r+g;0<=v+D&&v<=c&&this.jb(R,P,L,N)&&i.fillRect(0,v,a,D)}}}T&&i.disableDash(),C!==1&&(i.globalAlpha=M)}}jb(t,i,e,s){if(i<0)return t%i===e;if(t%i!==e)return!1;const n=s.length;for(let o=0;ol&&r.push(d)}}t.xi.Z0=i}C2(t){return t==="LineV"||t==="BarV"}JR(t){let i=1,e=1;const s=t.L.r,n=s.length;for(let l=0;l=g){const z=Point.l();c.mA(z),O=c.midAngle,A!==0&&(v=c.computeAngle(L,A,O),L.Xt=v,L.ue(!0),L._n(!0)),F=z.x-u.x,R=z.y-u.y,Point.s(z)}else{let z,W,q=0;if(M>=0?(z=m.elt(M),W=M0?m.elt(q-1):z),O=0,z.equalsApprox(W)){let Q,K;M>=0?(Q=M>0?m.elt(M-1):z,K=M1?m.elt(q-2):W);const I=Q.distanceSquaredPoint(z),j=W.distanceSquaredPoint(K);I>j+10?O=M>=0?Q.directionPoint(z):z.directionPoint(Q):j>I+10?O=M>=0?W.directionPoint(K):K.directionPoint(W):O=M>=0?Q.directionPoint(K):K.directionPoint(Q)}else O=M>=0?z.directionPoint(W):W.directionPoint(z);A!==0&&(v=c.computeAngle(L,A,O),L.Xt=v,L.ue(!0),L._n(!0)),F=z.x+(W.x-z.x)*N-u.x,R=z.y+(W.y-z.y)*N-u.y}L.ut(1/0,1/0,0,0),C=L.measuredBounds;const B=L.naturalBounds;let X=0;L instanceof Shape&&(X=L.strokeWidth);const E=B.width+X,V=B.height+X;k.Ri(),k.Ds(-C.x,-C.y),k.et(L.scale,L.scale),k.cs(A===0?L.angle:O,E/2,V/2),(A===22||A===26)&&k.cs(90,E/2,V/2),(A===23||A===27)&&k.cs(-90,E/2,V/2),A===28&&(O>45&&O<135||O>225&&O<315)&&k.cs(-O,E/2,V/2);const U=new Rect(0,0,E,V);b.setRectSpot(U,T),k.xt(b);const Y=-b.x+X/2*L.scale,G=-b.y+X/2*L.scale;P.a(D);const H=isNaN(D.x),J=isNaN(D.y);if(H||J){const z=E/2+3,W=V/2+3,q=O>=45&&O<=135,Q=O>=225&&O<=315;A===0&&(q||Q)?(P.x=J?z:D.y,P.y=H?W:D.x,q?M>=0||isNaN(M)&&N<.5||H&&(P.y=-W):Q&&((M>=0||isNaN(M)&&N<.5)&&H&&(P.y=-W),J&&(P.x=-z))):(H&&(M>=0||isNaN(M)&&N<.5?P.x=z:P.x=-z),J&&(P.y=-W),P.rotate(O))}else P.rotate(O);F+=P.x,R+=P.y,U.e(F+Y,R+G,C.width,C.height),x.push(U),d.unionRect(U)}if(h!==null){const S=h.labelNodes;for(;S.next();)S.value.ut(1/0,1/0)}t.Yo=d,t.position.e(u.x+d.x,u.y+d.y),n.En(d.width||0,d.height||0),Transform.s(k),Point.s(b),Point.s(P)}arrange(t,i,e){const s=i.length;if(!(t instanceof Adornment||t instanceof Link))return;let n=t,o=null;t instanceof Adornment&&(o=t,n=o.adornedPart);const r=t,l=t instanceof Adornment?null:n.path,h=t.hf;if(h.length!==0){let u=0;if(l!==null&&u=2&&r instanceof Link){const u=r.labelNodes;for(;u.next();){const d=u.value;r.QR(d,c,a)}}o!==null?o.hd(!1):n.hd(!1);const f=t.pA(Point.l());t.location.e(t.position.x+f.x,t.position.y+f.y),Point.s(f)}measureLinkPath(t,i,e,s){if(s.Oo()===!1)return;let n=s.strokeWidth;if(n===0&&t instanceof Adornment&&t.type===Panel.Link&&t.adornedObject instanceof Shape&&(n=t.adornedObject.strokeWidth),n=n*s.et,t instanceof Link&&t.ct!==null){const o=t.geometry.bounds;s.Qn(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else if(t instanceof Adornment&&t.adornedPart.ct!==null){const o=t.adornedPart.ct.bounds;s.Qn(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else s.Qn(-(n/2),-(n/2),i+n,e+n);s._R(),s.ue(!1)}}PanelLayout.definePanelLayout("Link",new PanelLayoutLink);class PanelLayoutGraduated extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=t.findMainElement();t.je=[];const h=l.margin,a=h.right+h.left,c=h.top+h.bottom;l.ut(i,e,o,r);const f=l.measuredBounds,u=f.width,d=f.height,m=Math.max(u+a,0),g=Math.max(d+c,0),p=new Rect(-h.left,-h.top,m,g);t.je.push(p),n.a(p),this.determineGraduatedMarks(t,l);const y=t.ws;if(y===null)return;const x=s.length;for(let k=0;k45&&f<135||f>225&&f<315)&&P.cs(-f,k/2,b/2);const S=Rect.X(0,0,k,b),L=Point.l();L.setRectSpot(S,o),P.xt(L);const C=-L.x,M=-L.y,N=Point.l();N.a(l),isNaN(N.x)&&(N.x=k/2+3),isNaN(N.y)&&(N.y=-(b/2+3)),N.rotate(f),a+=N.x+C,c+=N.y+M;const T=new Rect(a,c,y.width,y.height),A=new Rect(y.x,y.y,y.width,y.height),D=new Rect(x.x,x.y,x.width,x.height);p.labelAngle=u,p.lineCount=n.lineCount,p.lines=n.getMetrics(),p.actualBounds=T,p.measuredBounds=A,p.naturalBounds=D,g===0?h.a(T):h.unionRect(T),Point.s(N),Point.s(L),Rect.s(S),Transform.s(P)}t.je!==null&&t.je.push(h),s.unionNoCheck(h.x,h.y,h.width,h.height)}determineGraduatedMarks(t,i){const e=i.geometry,s=i.strokeWidth,n=e.flattenedSegments,o=e.flattenedLengths,r=e.flattenedTotalLength,l=n.length;let h=0,a=0;const c=Util.nt();for(let x=0;xt.graduatedMin+M){const F=Math.floor((N-t.graduatedMin)/M);N-=F*M}const T=f[x],A=N,D=t.graduatedMax*1e-6;for(let F=1;N<=t.graduatedMax+D;F++){if(this.iv(t,N-t.graduatedTickBase,T)&&(N>t.graduatedMax&&(N=t.graduatedMax),(k.graduatedSkip===null||k instanceof TextBlock&&!k.graduatedSkip(N,k)||k instanceof Shape&&!k.graduatedSkip(N,k))&&(m=(N-t.graduatedMin)*r/t.graduatedRange,m>r&&(m=r),g<=m&&m<=p))){let R=c[L][C],v=o[L][C];for(;LS&&C.4995)return t;let o=t;if(i<.5?n>0?o=s[n-1]:Geo.K(e[0],e[e.length-2])&&Geo.K(e[1],e[e.length-1])&&(o=s[s.length-1]):i>.5&&(n+1180&&(t.9995)return(t+o)/2%360;if(r<10){const l=1-Math.abs(.5-i);return(t*l+o*(1-l))%360}}return t}tv(t){if(t.ns===null){const i=[],e=t.L.r,s=e.length;for(let n=0;nl&&r.push(c)}}t.ns=i}return t.ns}iv(t,i,e){const s=e.length;for(let n=0;n-l)return!1}return!0}Gi(t,i,e){const s=e.Qh;e.Qh=!0;const n=t.naturalBounds,o=n.width,r=n.height,l=i instanceof SVGContext;i.save(),i.beginPath(),i.rect(-1,-1,o+1,r+1),i.clip(),i.endPath();const h=t.findMainElement();h.Gi(i,e);let a=t.getDocumentScale()*e.scale;a<=0&&(a=1);const c=h.actualBounds,f=t.L.r,u=t.ws,d=f.length;for(let m=0;m(w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ViewboxStretch||{});class Panel extends GraphObject{$;L;$t;ad;Kn;el;so;Yo;A2;O;cd;lt;xi;Qt;fd;mh;Ys;constructor(t,i){if(super(),this.$=null,t===void 0)this.$=Panel.Position;else if(typeof t=="string"){const e=PanelLayout.Layouts.get(t);e!==null&&(this.$=e)}else t instanceof PanelLayout?this.$=t:t&&(this.$=Panel.Position,i=t);this.$===null&&Util.o("Panel type not specified or PanelLayout not loaded: "+t),this.n|=4194304|(this.$===Panel.Grid?1048576:0),this.L=new List,this.$t=Margin.Eg,this.ad=Spot.Default,this.Kn=1,this.el=null,this.so="",this.Yo=new Rect(NaN,NaN,NaN,NaN),this.A2=null,this.O=null,this.cd=6,this.xi=null,this.lt=null,this.Qt=null,this.fd=NaN,this.mh=null,this.Ys=null,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.$=this.$,t.$t=this.$t.N(),t.ad=this.ad.N(),t.Kn=this.Kn,t.so=this.so,t.Yo.a(this.Yo),this.O!==null&&(t.O=this.O.copy(t)),t.cd=this.cd,this.lt!==null&&(t.lt=this.lt.copy()),this.xi!==null&&(t.xi=this.xi.copy()),t.Qt=this.Qt,t.fd=this.fd,t.mh=this.mh}Vo(t){super.Vo(t),t.L=this.L;const i=t.L.r,e=i.length;for(let s=0;s= 0",Panel,"padding"),t=new Margin(t)):(t.left<0&&Util._(t.left,">= 0",Panel,"padding:value.left"),t.right<0&&Util._(t.right,">= 0",Panel,"padding:value.right"),t.top<0&&Util._(t.top,">= 0",Panel,"padding:value.top"),t.bottom<0&&Util._(t.bottom,">= 0",Panel,"padding:value.bottom"));const i=this.$t;i.equals(t)||(t=t.N(),this.$t=t,this.c(),this.t("padding",i,t))}get defaultAlignment(){return this.ad}set defaultAlignment(t){const i=this.ad;i.equals(t)||(t=t.N(),this.ad=t,this.c(),this.t("defaultAlignment",i,t))}get defaultStretch(){return this.Kn}set defaultStretch(t){const i=this.Kn;i!==t&&(this.Kn=t,this.c(),this.t("defaultStretch",i,t))}get defaultSeparatorPadding(){return this.O!==null?this.O.Q0:Margin.Eg}set defaultSeparatorPadding(t){typeof t=="number"&&(t=new Margin(t));const i=this.defaultSeparatorPadding;i.equals(t)||(t=t.N(),this.O===null&&(this.O=new TablePanelSettings),this.O.Q0=t,this.c(),this.t("defaultSeparatorPadding",i,t))}get defaultRowSeparatorStroke(){return this.O!==null?this.O._0:null}set defaultRowSeparatorStroke(t){const i=this.defaultRowSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.g(),this.O===null&&(this.O=new TablePanelSettings),this.O._0=t,this.C(),this.t("defaultRowSeparatorStroke",i,t))}get defaultRowSeparatorStrokeWidth(){return this.O!==null?this.O.tp:1}set defaultRowSeparatorStrokeWidth(t){const i=this.defaultRowSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.O===null&&(this.O=new TablePanelSettings),this.O.tp=t,this.c(),this.t("defaultRowSeparatorStrokeWidth",i,t))}get defaultRowSeparatorDashArray(){return this.O!==null?this.O.ip:null}set defaultRowSeparatorDashArray(t){const i=this.defaultRowSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",Panel,"defaultRowSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("defaultRowSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.O===null&&(this.O=new TablePanelSettings),this.O.ip=t,this.C(),this.t("defaultRowSeparatorDashArray",i,t)}}get defaultColumnSeparatorStroke(){return this.O!==null?this.O.ep:null}set defaultColumnSeparatorStroke(t){const i=this.defaultColumnSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.g(),this.O===null&&(this.O=new TablePanelSettings),this.O.ep=t,this.C(),this.t("defaultColumnSeparatorStroke",i,t))}get defaultColumnSeparatorStrokeWidth(){return this.O!==null?this.O.sp:1}set defaultColumnSeparatorStrokeWidth(t){const i=this.defaultColumnSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.O===null&&(this.O=new TablePanelSettings),this.O.sp=t,this.c(),this.t("defaultColumnSeparatorStrokeWidth",i,t))}get defaultColumnSeparatorDashArray(){return this.O!==null?this.O.np:null}set defaultColumnSeparatorDashArray(t){const i=this.defaultColumnSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",Panel,"defaultColumnSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("defaultColumnSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.O===null&&(this.O=new TablePanelSettings),this.O.np=t,this.C(),this.t("defaultColumnSeparatorDashArray",i,t)}}get gh(){return this.O!==null?this.O.gh:null}set gh(t){this.O===null&&(this.O=new TablePanelSettings),this.O.gh=t}get viewboxStretch(){return this.cd}set viewboxStretch(t){const i=this.cd;i!==t&&(this.cd=t,this.c(),this.t("viewboxStretch",i,t))}get gridCellSize(){return this.xi!==null?this.xi.ud:Size.tC}set gridCellSize(t){this.xi===null&&(this.xi=new GridPanelSettings);const i=this.xi.ud;if(!i.equals(t)){(!t.isReal()||t.width===0||t.height===0)&&Util.o("Invalid Panel.gridCellSize: "+t),this.xi.ud=t.N();const e=this.diagram;e!==null&&this===e.grid&&e.jr(),this.C(),this.t("gridCellSize",i,t)}}get gridOrigin(){return this.xi!==null?this.xi.dd:Point.Po}set gridOrigin(t){this.xi===null&&(this.xi=new GridPanelSettings);const i=this.xi.dd;if(!i.equals(t)){t.isReal()||Util.o("Invalid Panel.gridOrigin: "+t),this.xi.dd=t.N();const e=this.diagram;e!==null&&this===e.grid&&e.jr(),this.C(),this.t("gridOrigin",i,t)}}get graduatedMin(){return this.lt!==null?this.lt.op:0}set graduatedMin(t){const i=this.graduatedMin;if(i!==t&&(this.lt===null&&(this.lt=new GradPanelSettings),this.lt.op=t,this.c(),this.t("graduatedMin",i,t),this.$c())){const e=this.part;e!==null&&this.ya(e,"graduatedRange")}}get graduatedMax(){return this.lt!==null?this.lt.rp:100}set graduatedMax(t){const i=this.graduatedMax;if(i!==t&&(this.lt===null&&(this.lt=new GradPanelSettings),this.lt.rp=t,this.c(),this.t("graduatedMax",i,t),this.$c())){const e=this.part;e!==null&&this.ya(e,"graduatedRange")}}get graduatedRange(){return this.graduatedMax-this.graduatedMin}get graduatedTickUnit(){return this.lt!==null?this.lt.lp:10}set graduatedTickUnit(t){const i=this.graduatedTickUnit;i!==t&&t>0&&(this.lt===null&&(this.lt=new GradPanelSettings),this.lt.lp=t,this.c(),this.t("graduatedTickUnit",i,t))}get graduatedTickBase(){return this.lt!==null?this.lt.hp:0}set graduatedTickBase(t){const i=this.graduatedTickBase;i!==t&&(this.lt===null&&(this.lt=new GradPanelSettings),this.lt.hp=t,this.c(),this.t("graduatedTickBase",i,t))}get ws(){return this.lt!==null?this.lt.ws:null}set ws(t){this.lt!==null?this.lt.ws=t:t!==null&&(this.lt=new GradPanelSettings,this.lt.ws=t)}get je(){return this.lt!==null?this.lt.je:null}set je(t){this.lt!==null?this.lt.je=t:t!==null&&(this.lt=new GradPanelSettings,this.lt.je=t)}get ns(){return this.lt!==null?this.lt.ns:null}set ns(t){this.lt!==null?this.lt.ns=t:t!==null&&(this.lt=new GradPanelSettings,this.lt.ns=t)}get Se(){return this.lt!==null?this.lt.Se:null}set Se(t){this.lt!==null?this.lt.Se=t:t!==null&&(this.lt=new GradPanelSettings,this.lt.Se=t)}b0(t){super.b0(t);const i=this.L.r,e=i.length;for(let s=0;s0?this.Ye:null,s=this.columnCount>0?this.Ge:null;e!==null&&this.Hb(t,i,!0,e,!0),s!==null&&this.Hb(t,i,!1,s,!0),e!==null&&this.wA(t,!0,e),s!==null&&this.wA(t,!1,s),e!==null&&this.Hb(t,i,!0,e,!1),s!==null&&this.Hb(t,i,!1,s,!1)}wA(t,i,e){const s=e.length,n=this.actualBounds,o=this.naturalBounds;let r=!0;for(let l=0;lo.height)continue}else if(h.position>o.width)continue;let a=h.separatorStrokeWidth;isNaN(a)&&(a=i?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let c=h.separatorStroke;if(c===null&&(c=i?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),a===0||c===null)continue;this.dn(t,c,!1,!1,o,n);let f=!1,u=h.separatorDashArray;u===null&&(u=i?this.defaultRowSeparatorDashArray:this.defaultColumnSeparatorDashArray),u!==null&&(f=!0,t.enableDash(u,0)),t.beginPath();const d=h.position+a;i?d>o.height&&(a-=d-o.height):d>o.width&&(a-=d-o.width);let m=h.position+a/2;t.lineWidth=a;const g=this.$t;if(i){m+=g.top;const p=g.left,y=o.width-g.right;t.moveTo(p,m),t.lineTo(y,m)}else{m+=g.left;const p=g.top,y=o.height-g.bottom;t.moveTo(m,p),t.lineTo(m,y)}t.stroke(),t.endPath(),f&&t.disableDash()}}Hb(t,i,e,s,n){const o=s.length,r=this.actualBounds,l=this.naturalBounds,h=this.xA(!0),a=this.xA(!1);for(let c=0;cu)continue;let d=f.computeEffectiveSpacing(),m=f.separatorStrokeWidth;isNaN(m)&&(m=e?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let g=f.separatorStroke;g===null&&(g=e?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),(g===null||f.index===(e?h:a))&&(m=0),d-=m;const p=f.position+m;let y=d+f.actual;if(p+y>u&&(y=u-p),y<=0)continue;const x=this.$t;this.dn(t,f.background,!0,!1,l,r),e?t.fillRect(x.left,p+x.top,r.width-(x.left+x.right),y):t.fillRect(p+x.left,x.top,y,r.height-(x.top+x.bottom))}}xA(t){const i=t?this.rowCount:this.columnCount;for(let e=0;ex&&n.set(M),Point.s(M)),Point.s(S),o&&n.D(r),k}}Du(){const t=this.L.r,i=t.length;for(let e=0;ee||h>s)&&(this.c(),this.ut(l>e?e:l,h>s?s:h,0,0));break;case 2:this.c(!0),this.ut(e+c,s+f,0,0);break;case 5:this.c(!0),this.ut(e+c,h+f,0,0);break;case 4:this.c(!0),this.ut(l+c,s+f,0,0);break}}this.$.arrange(this,n,this.Yo)}hh(t){const i=this.naturalBounds,e=this.Ko();if(Rect.contains(0,0,i.width,i.height,t.x,t.y)){const s=this.L.r,n=s.length,o=Point.X(0,0);for(let r=n;r--;){const l=s[r];if(!(!l.visible&&l!==e)&&(o.set(t).Ie(l.D),l.containsPoint(o)))return Point.s(o),!0}return Point.s(o),this.Ct!==null}return!1}m0(t){if(this.$n===t)return this;const i=this.L.r,e=i.length;for(let s=0;sd.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;let m=f;const g=f instanceof Panel?f:null,p=Transform.l();p.set(r),(g!==null?g.vm(t,i,e,s,n,p):m.QL(t,s,p))&&(i!==null&&(m=i(m)),m!==null&&(e===null||e(m))&&n.add(m)),Transform.s(p)}}return o===void 0&&Transform.s(r),s}return o===void 0&&Transform.s(r),!1}D2(t,i,e){const s=this.L.r,n=s.length;for(let o=n;o--;){const r=s[o];if(!r.visible)continue;const l=r.actualBounds,h=this.naturalBounds;if(l.x>h.width||l.y>h.height||l.x+l.width<0||l.y+l.height<0)continue;r instanceof Panel&&r.D2(t,i,e);let a=r;t!==null&&(a=t(a)),a!==null&&(i===null||i(a))&&e.add(a)}}eL(t,i,e,s,n,o){if(this.pickable===!1)return!1;e===void 0&&(e=null),s===void 0&&(s=null);const r=this.naturalBounds,l=this.pn(),h=l?t:Point.X(t.x,t.y).Ie(this.D),a=l?i:Point.X(i.x,i.y).Ie(this.D),c=h.distanceSquaredPoint(a),f=h.x>0&&h.x0&&h.yP.width||b.y>P.height||b.x+b.width<0||b.y+b.height<0))continue;if(k.pn()){const C=k.D;d.set(t).Ie(C),m.set(i).Ie(C)}else d.set(t),m.set(i);let S=k;const L=k instanceof Panel?k:null;(L!==null?L.eL(d,m,e,s,n,o):S._L(d,m,n))&&(e!==null&&(S=e(S)),S!==null&&(s===null||s(S))&&o.add(S))}Point.s(d),Point.s(m)}return n?f:u}return!1}M2(t){let i=null;if(t instanceof Shape){i=t.spot1,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot1)}return i===null&&(i=Spot.TopLeft),i}N2(t){let i=null;if(t instanceof Shape){i=t.spot2,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot2)}return i===null&&(i=Spot.BottomRight),i}add(...t){for(let i=0;i=s.count&&t>=s.count)return;s.removeAt(r),n=r}else Util.o("element "+i.toString()+" has panel "+e.toString()+" but is not contained by it.")}(t<0||t>s.count)&&(t=s.count),s.insertAt(t,i),(t===0||i.isPanelMain)&&(this.el=null),this.Oo()||this.c(),i.c(!1),i.portId!==null?this.wn=!0:i instanceof Panel&&i.wn===!0&&(this.wn=!0),this.ns=null,this.isEnabledObject()||this.qb(i,!1);const o=this.part;if(o!==null){o.D0(),o.cf(),this.wn&&o instanceof Node&&(o.wn=!0),o.wn&&o instanceof Node&&(o.ne=null);const r=this.diagram;if(r!==null&&r.undoManager.isUndoingRedoing)return;n!==-1&&o.raiseChangedEvent(4,"elements",this,i,null,n,null),o.raiseChangedEvent(3,"elements",this,null,i,null,t)}}get wn(){return(this.n&8388608)!==0}set wn(t){(this.n&8388608)!==0!==t&&(this.n=this.n^8388608)}e2(){return(this.n&16777216)!==0}F2(t){t?this.n|=16777216:this.n&=-16777217}lv(t){t.xa(this),t.Qr=null;const i=this.L,e=i.count;i.insertAt(e,t);const s=this.part;if(s!==null){s.D0(),t.portId!==null&&s instanceof Node&&(s.wn=!0);const n=this.diagram;if(n!==null&&n.undoManager.isUndoingRedoing)return;s.raiseChangedEvent(3,"elements",this,null,t,null,e)}}AR(t){const i=this.L.r,e=i.length;let s=-1;for(let n=0;n=0&&this.te(t,!0)}te(t,i){const e=this.L,s=e.elt(t);if(s.Qr=null,s.xa(null),this.Ys!==null){const o=s.data;typeof o=="object"&&this.Ys.delete(o)}e.removeAt(t),this.ue(!1),this.c(),this.el===s&&(this.el=null),this.ns=null;const n=this.part;if(n!==null){n.D0(),n.cf(),n.invalidateAdornments(),n instanceof Node&&(s instanceof Panel?s.walkVisualTreeFrom(s,(r,l)=>n.u2(l,i)):n.u2(s,i));const o=this.diagram;if(o!==null&&o.undoManager.isUndoingRedoing)return;n.raiseChangedEvent(4,"elements",this,s,null,t,null)}}get Ye(){return this.O===null&&(this.O=new TablePanelSettings),this.O.Ye}get rowCount(){return this.O===null?0:this.Ye.length}getRowDefinition(t){t<0&&Util._(t,">= 0",Panel,"getRowDefinition:idx"),t=Math.round(t);const i=this.Ye;if(i[t]===void 0){const e=new RowColumnDefinition;e.xa(this),e.isRow=!0,e.index=t,i[t]=e,this.raiseChangedEvent(3,"rowdefs",this,null,e,null,t)}return i[t]}removeRowDefinition(t){if(t<0&&Util._(t,">= 0",Panel,"removeRowDefinition:idx"),this.rowCount===0)return;t=Math.round(t);const i=this.Ye,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"rowdefs",this,e,null,t,null),this.c()}}DL(t,i){const e=this.Ye;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.c()}}get Ge(){return this.O===null&&(this.O=new TablePanelSettings),this.O.Ge}get columnCount(){return this.O===null?0:this.Ge.length}getColumnDefinition(t){t<0&&Util._(t,">= 0",Panel,"getColumnDefinition:idx"),t=Math.round(t);const i=this.Ge;if(i[t]===void 0){const e=new RowColumnDefinition;e.xa(this),e.isRow=!1,e.index=t,i[t]=e,this.raiseChangedEvent(3,"coldefs",this,null,e,null,t)}return i[t]}removeColumnDefinition(t){if(t<0&&Util._(t,">= 0",Panel,"removeColumnDefinition:idx"),this.columnCount===0)return;t=Math.round(t);const i=this.Ge,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"coldefs",this,e,null,t,null),this.c()}}FL(t,i){const e=this.Ge;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.c()}}addRowColumnDefinition(t){let i=null;return t.isRow?i=this.getRowDefinition(t.index):t.isRow||(i=this.getColumnDefinition(t.index)),i&&i.Ub(t),this}addRowDefinition(t,i){const e=this.getRowDefinition(t);return e&&e.Ub(new RowColumnDefinition(i)),this}addColumnDefinition(t,i){const e=this.getColumnDefinition(t);return e&&e.Ub(new RowColumnDefinition(i)),this}get rowSizing(){return this.O!==null?this.O.cp:3}set rowSizing(t){const i=this.rowSizing;i!==t&&(this.O===null&&(this.O=new TablePanelSettings),this.O.cp=t,this.c(),this.t("rowSizing",i,t))}get columnSizing(){return this.O!==null?this.O.fp:3}set columnSizing(t){const i=this.columnSizing;i!==t&&(this.O===null&&(this.O=new TablePanelSettings),this.O.fp=t,this.c(),this.t("columnSizing",i,t))}get topIndex(){return this.O!==null?this.O.dp:0}set topIndex(t){const i=this.topIndex;i!==t&&((!isFinite(t)||t<0)&&Util.o("Panel.topIndex must be greater than zero and a real number, not: "+t),this.O===null&&(this.O=new TablePanelSettings),this.O.dp=t,this.c(),this.t("topIndex",i,t))}get leftIndex(){return this.O!==null?this.O.gp:0}set leftIndex(t){const i=this.leftIndex;i!==t&&((!isFinite(t)||t<0)&&Util.o("Panel.leftIndex must be greater than zero and a real number, not: "+t),this.O===null&&(this.O=new TablePanelSettings),this.O.gp=t,this.c(),this.t("leftIndex",i,t))}findRowForLocalY(t){if(t<0||this.type!==Panel.Table||this.rowCount===0)return-1;let i=0;const e=this.Ye,s=e.length;let n=this.topIndex;for(;n{o.lh();const r=o.Ai;if(r!==null){o.a2(!1);const l=r.iterator;for(;l.next();){const h=l.value;h.mode===2&&o.a2(!0);const a=h.sourceName;if(h.isToObject){a==="/"&&n.F2(!0);const c=h.ZL(n,o);c!==null&&(i.add(c),c.Zn===null&&(c.Zn=new List),c.Zn.add(h))}t.add(h)}}if(o instanceof Panel&&o.type===Panel.Table){if(o.rowCount>0){const l=o.Ye,h=l.length;for(let a=0;a0){const l=o.Ge,h=l.length;for(let a=0;a0&&o instanceof Panel){const h=r.substring(0,l),a=r.substring(l+1),c=o.findObject(h);c!==null?(o=c,n.targetProperty=a):(Util.ii('Warning: unable to find GraphObject named "'+h+'" for Binding: '+n.toString()),o=null)}if(o instanceof RowColumnDefinition){const h=GSet.as(o.panel);n.targetId=h===void 0?-1:h,o.panel.$n=n.targetId}else if(o instanceof GraphObject){const h=GSet.as(o);n.targetId=h===void 0?-1:h,o.$n=n.targetId}else Util.o("Unknown type of binding target: "+o);n.check(o)}}return t.g(),this instanceof Part&&this.Pe()&&this.ensureBounds(),this}static dE=!1;copyTemplate(t){t===void 0&&(t=!1);const i=this.copy();return i.hv(e=>{e instanceof Panel&&(e.Ks=null,e.Qt=null);const s=e.Ai;s!==null&&(e.Ai=null,s.each(o=>e.bind(o.copy())));const n=e.ys;n!==null&&(e.ys=null,n.each(o=>e.trigger(o.value.copy())))}),t&&i.li(),i}updateTargetBindings(t){const i=this.Ks;if(i===null)return;t===void 0&&(t="");const e=i.iterator;for(;e.next();){const s=e.value,n=this.MA(s,t);if(n===null)continue;const{data:o,elt:r}=n;s.isToTheme&&this.diagram===null||r!==void 0&&s.updateTarget(r,o)}}Io(){if(this.diagram!==null)if(this.d2()){const t=this.Ks.iterator;for(;t.next();){const i=t.value;if(!i.isToTheme)continue;const e=this.MA(i);if(e===null)continue;const{data:s,elt:n}=e;n!==void 0&&i.updateTarget(n,s)}}else{const t=this.L.r,i=t.length;for(let e=0;e0;let r=0;for(;n0){const i=this.L.elt(0);if(i.isPanelMain&&i instanceof Panel&&i._r())return 1}return 0}rebuildItemElements(){const t=this.ap();for(;this.L.length>t;)this.te(this.L.length-1,!1);this.NA(null,this.itemArray)}NA(t,i){const e=this.ap(),s=i;if(s===null||s.length===0){for(;this.L.length>e;)this.te(this.L.length-1,!1);return}if(this.L.length<=e){const n=s.length;for(let o=0;o(w[w.Default=1]="Default",w[w.None=2]="None",w[w.ProportionalExtra=3]="ProportionalExtra",w))(Sizing||{});class RowColumnDefinition{Vs;mp;Dt;Sa;Ma;oi;at;md;to;Go;pd;yd;Na;Ct;wd;Gs;st;ji;ge;constructor(t){GSet.Yi(this),this.Vs=null,this.mp=!0,this.Dt=0,this.ge=NaN,this.Sa=0,this.Ma=1/0,this.oi=Spot.Default,this.st=0,this.ji=0,this.at=0,this.Gs=null,this.md=1,this.to=1,this.Go=null,this.pd=null,this.yd=NaN,this.Na=null,this.Ct=null,this.wd=!1,t&&(Object.assign(this,t),t.column!==void 0?(this.isRow=!1,this.index=t.column):t.row!==void 0&&(this.isRow=!0,this.index=t.row))}copy(){const t=new RowColumnDefinition;return t.mp=this.mp,t.Dt=this.Dt,t.ge=this.ge,t.Sa=this.Sa,t.Ma=this.Ma,t.oi=this.oi,t.st=this.st,t.ji=this.ji,t.at=this.at,t.to=this.to,t.md=this.md,this.Go===null?t.Go=null:t.Go=this.Go.N(),t.pd=this.pd,t.yd=this.yd,t.Na=null,this.Na!==null&&(t.separatorDashArray=this.separatorDashArray.slice()),t.Ct=this.Ct,t.wd=this.wd,t.Gs=this.Gs,t}Ub(t){t.isRow?this.height=t.height:this.width=t.width,this.minimum=t.minimum,this.maximum=t.maximum,this.alignment=t.alignment,this.stretch=t.stretch,this.sizing=t.sizing,this.Go=t.separatorPadding===null?null:t.separatorPadding.N(),this.separatorStroke=t.separatorStroke,this.separatorStrokeWidth=t.separatorStrokeWidth,this.Na=null,t.separatorDashArray&&(this.Na=t.separatorDashArray.slice()),this.background=t.background,this.coversSeparators=t.coversSeparators,this.Gs=t.Gs}ri(t){t in Sizing?this.sizing=t:Util.lr(this,t)}toString(){return"RowColumnDefinition "+(this.isRow?"(Row ":"(Column ")+this.index+") #"+GSet.as(this)}static Default=1;static None=2;static ProportionalExtra=3;xa(t){this.Vs=t}computeEffectiveSpacingTop(t){let i=0;const e=this.Vs;if(this.index!==t){let n=this.separatorStroke;n===null&&e!==null&&(n=this.isRow?e.defaultRowSeparatorStroke:e.defaultColumnSeparatorStroke),n!==null&&(i=this.separatorStrokeWidth,isNaN(i)&&(e!==null?i=this.isRow?e.defaultRowSeparatorStrokeWidth:e.defaultColumnSeparatorStrokeWidth:i=0))}let s=this.Go;if(s===null)if(e!==null)s=e.defaultSeparatorPadding;else return i;return i+(this.isRow?s.top:s.left)}computeEffectiveSpacing(){let t=0;const i=this.Vs;let e=0;const s=this.isRow;if(i!==null&&i.type===Panel.Table){const o=s?i.Ye.length:i.Ge.length;for(let r=0;r= 0",RowColumnDefinition,"height"),this.ge=t,this.actual=this.st,this.panel!==null&&this.panel.c(),this.t("height",i,t))}get width(){return this.ge}set width(t){const i=this.ge;i!==t&&(t<0&&Util._(t,">= 0",RowColumnDefinition,"width"),this.ge=t,this.actual=this.st,this.panel!==null&&this.panel.c(),this.t("width",i,t))}get minimum(){return this.Sa}set minimum(t){const i=this.Sa;i!==t&&((t<0||!isFinite(t))&&Util._(t,">= 0",RowColumnDefinition,"minimum"),this.Sa=t,this.actual=this.st,this.panel!==null&&this.panel.c(),this.t("minimum",i,t))}get maximum(){return this.Ma}set maximum(t){const i=this.Ma;i!==t&&(t<0&&Util._(t,">= 0",RowColumnDefinition,"maximum"),this.Ma=t,this.actual=this.st,this.panel!==null&&this.panel.c(),this.t("maximum",i,t))}get alignment(){return this.oi}set alignment(t){const i=this.oi;i.equals(t)||(this.oi=t.N(),this.panel!==null&&this.panel.c(),this.t("alignment",i,t))}get stretch(){return this.to}set stretch(t){const i=this.to;i!==t&&(this.to=t,this.panel!==null&&this.panel.c(),this.t("stretch",i,t))}get separatorPadding(){return this.Go}set separatorPadding(t){typeof t=="number"&&(t=new Margin(t));const i=this.Go;(t===null||i===null||!i.equals(t))&&(t!==null&&(t=t.N()),this.Go=t,this.panel!==null&&this.panel.c(),this.t("separatorPadding",i,t))}get separatorStroke(){return this.pd}set separatorStroke(t){const i=this.pd;i!==t&&(t!==null&&Brush.nd(t,"RowColumnDefinition.separatorStroke"),t instanceof Brush&&t.g(),this.pd=t,this.panel!==null&&this.panel.c(),this.t("separatorStroke",i,t))}get separatorStrokeWidth(){return this.yd}set separatorStrokeWidth(t){const i=this.yd;i!==t&&(this.yd=t,this.panel!==null&&this.panel.c(),this.t("separatorStrokeWidth",i,t))}get separatorDashArray(){return this.Na}set separatorDashArray(t){const i=this.Na;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",RowColumnDefinition,"separatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("separatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.Na=t,this.panel!==null&&this.panel.C(),this.t("separatorDashArray",i,t)}}get background(){return this.Ct}set background(t){const i=this.Ct;i!==t&&(t!==null&&Brush.nd(t,"RowColumnDefinition.background"),t instanceof Brush&&t.g(),this.Ct=t,this.panel!==null&&this.panel.C(),this.t("background",i,t))}get coversSeparators(){return this.wd}set coversSeparators(t){const i=this.wd;i!==t&&(Util.i(t,"boolean",RowColumnDefinition,"coversSeparators"),this.wd=t,this.panel!==null&&this.panel.C(),this.t("coversSeparators",i,t))}get sizing(){return this.md}set sizing(t){const i=this.md;i!==t&&(this.md=t,this.panel!==null&&this.panel.c(),this.t("sizing",i,t))}Gb(){if(this.sizing===1){const t=this.Vs;return this.isRow?t.rowSizing:t.columnSizing}return this.sizing}get actual(){return this.st}set actual(t){isNaN(this.ge)?this.st=Math.max(Math.min(this.Ma,t),this.Sa):this.st=Math.max(Math.min(this.Ma,this.ge),this.Sa)}get measured(){return this.ji}set measured(t){this.ji=t}get total(){return this.st+this.computeEffectiveSpacing()}get position(){return this.at}set position(t){this.at=t}bind(t,i,e,s){return this.sf(t,i,e,s),this}bindTwoWay(t,i,e,s){const n=this.sf(t,i,e,s);return s===void 0&&n.makeTwoWay(),this}theme(t,i,e,s,n){return this.uh(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.uh(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.uh(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.uh(t,i,e,s,n).ofModel(),this}sf(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.G0(n),n}uh(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.G0(o),o}G0(t){t.ke=this;const i=this.panel;if(i!==null){const e=i.findBindingPanel();e!==null&&e.aA()&&Util.o("Cannot add a Binding to a RowColumnDefinition that is already frozen: "+t+" on "+i)}this.Gs===null&&(this.Gs=new List),this.Gs.add(t)}}class Shape extends GraphObject{ct;xs;xd;Ca;Hi;jo;Xo;Lt;bd;kd;J;constructor(t,i){super(),this.ct=null,this.xs=null,this.xd="None",this.Ca="black",this.Hi="black",this.jo=1,this.Xo=null,this.Lt=null,this.bd=NaN,this.kd=NaN,this.J=null,typeof t=="string"?this.figure=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.ct=this.ct,t.xs=this.xs,t.xd=this.xd,t.Ca=this.Ca,t.Hi=this.Hi,t.jo=this.jo,this.Xo!==null&&(t.Xo=this.Xo.slice()),this.Lt!==null&&(this.Lt.gi?t.Lt=this.Lt:t.Lt=this.Lt.copy()),t.bd=this.bd,t.kd=this.kd,this.J!==null&&(t.J=this.J.copy())}La(){this.Lt===null?this.Lt=new ShapeTemplateSettings:this.Lt.gi&&(this.Lt=this.Lt.copy())}lh(){super.lh(),this.Lt!==null&&(this.Lt.gi=!0)}ri(t){t in GeometryStretch?this.geometryStretch=t:super.ri(t)}toString(){return"Shape("+(this.figure!=="None"?this.figure:this.toArrow!=="None"?this.toArrow:this.fromArrow)+")#"+GSet.as(this)}mv(t,i){const e=this.pathPattern;e.ut(1/0,1/0);const s=e.measuredBounds;e.zt(0,0,s.width,s.height);const n=this.geometry;t.save(),t.beginPath();const o=Util.nt();if(n.type===1)o.push(n.startX),o.push(n.startY),o.push(n.endX),o.push(n.endY),this.Pd(t,i,o,e);else if(n.type===4){const r=n.figures.iterator;for(;r.next();){const l=r.value;o.length=0,o.push(l.startX),o.push(l.startY);let h=l.startX,a=l.startY,c=h,f=a;const u=l.segments.r,d=u.length;for(let m=0;m=.1;){if(M===0&&(S?(b=k,b-=P,y-=P,S=!1):b=k,b===0&&(b=1)),b>y){b=y,Util.tt(x);return}b>p?(M=b-p,b=p):M=0;let N=Math.sqrt(b*b/(1+m*m));if(u<0&&(N=-N),h+=N,a+=m*N,t.translate(h,a),t.rotate(g),t.translate(-(r/2),-(l/2)),M===0&&s.fh(t,i),t.translate(r/2,l/2),t.rotate(-g),t.translate(-h,-a),y-=b,p-=b,M!==0){if(L++,L===x.length){Util.tt(x);return}C=x[L],u=C[0],g=C[1],m=C[2],p=C[3],b=M}}Util.tt(x)}fh(t,i){const e=t instanceof SVGContext;let s=this.Hi;const n=this.Ca;if(s===null&&n===null)return;const o=this.ct;if(o===null)return;t.commitTransform();const r=this.actualBounds,l=this.naturalBounds;n!==null&&this.dn(t,n,!0,!1,l,r);const h=this.part;let a=this.jo;s!==null&&a===0&&h!==null&&(this.isPanelMain||h.findMainElement()===this)&&(a=h.yv()),a===0&&(s=null),s!==null&&a!==0&&(this.dn(t,s,!1,!1,l,r),t.lineWidth=a,t.lineJoin=this.strokeJoin,t.lineCap=this.strokeCap,t.miterLimit=this.strokeMiterLimit);let c=!1;h&&i.getRenderingHint("drawShadows")&&(c=h.isShadowed),t.tl===!1&&(c=!1);let f=!0;s!==null&&(n===null||n==="transparent")&&(f=!1);let u=!1;const d=this.strokeDashArray;if(d!==null&&(u=!0,t.enableDash(d,this.strokeDashOffset)),o.type===1)t.beginPath(),t.moveTo(o.startX,o.startY),t.lineTo(o.endX,o.endY),s!==null&&t.strokeContext(),t.endPath();else if(o.type===2){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.min(m,p),k=Math.min(g,y),b=Math.abs(p-m),P=Math.abs(y-g);t.beginPath(),t.rect(x,k,b,P),n!==null&&t.fillContext(n,!1,null),s!==null&&(f&&c&&t.shadowsOff(),t.strokeContext(),f&&c&&t.shadowsOn()),t.endPath()}else if(o.type===3){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.abs(p-m)/2,k=Math.abs(y-g)/2,b=Math.min(m,p)+x,P=Math.min(g,y)+k;t.beginPath(),t.moveTo(b,P-k),t.bezierCurveTo(b+Geo.Bn*x,P-k,b+x,P-Geo.Bn*k,b+x,P),t.bezierCurveTo(b+x,P+Geo.Bn*k,b+Geo.Bn*x,P+k,b,P+k),t.bezierCurveTo(b-Geo.Bn*x,P+k,b-x,P+Geo.Bn*k,b-x,P),t.bezierCurveTo(b-x,P-Geo.Bn*k,b-Geo.Bn*x,P-k,b,P-k),t.closePath(),n!==null&&t.fillContext(n,!1,null),s!==null&&(f&&c&&t.shadowsOff(),t.strokeContext(),f&&c&&t.shadowsOn()),t.endPath()}else if(o.type===4){const m=o.figures,g=m.length;for(let p=0;p1||this.pathPattern!==null?!0:super.ed(t)}l2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("path");for(let s=0;s1,i);Util.o("Unknown Geometry type: "+e.type)}}Qu(t,i,e,s){const n=this.desiredSize,o=this.jo;t=Math.max(t,0),i=Math.max(i,0);let r;if(this.xs!==null)r=this.geometry.bounds;else{const g=this.figure;let p=Shape.I2[g];if(p===void 0){let y=Geo.So[g];typeof y=="string"&&(y=Geo.So[y]),typeof y=="function"?(p=y(null,100,100),Shape.I2[g]=p):Util.o("Unsupported Figure: "+g)}r=p.bounds}let l=r.width,h=r.height,a=r.width,c=r.height;switch(this.zs(!0)){case 0:e=0,s=0;break;case 2:a=Math.max(t-o,0),c=Math.max(i-o,0);break;case 5:a=Math.max(t-o,0),s=0;break;case 4:e=0,c=Math.max(i-o,0);break}isFinite(n.width)&&(a=n.width),isFinite(n.height)&&(c=n.height);const u=this.maxSize,d=this.minSize;e=Math.max(e-o,d.width),s=Math.max(s-o,d.height),a=Math.min(u.width,a),c=Math.min(u.height,c),a=isFinite(a)?Math.max(e,a):Math.max(l,e),c=isFinite(c)?Math.max(s,c):Math.max(h,s);const m=this._P();switch(m){case 0:break;case 2:l=a,h=c;break;case 6:{let g=Math.min(a/l,c/h);isFinite(g)||(g=1),l=l*g,h=h*g;break}default:Util.o(m+" is not a valid geometryStretch.")}if(this.xs!==null){l===0&&(l=.001),h===0&&(h=.001);const p=(this.xs!==null?this.xs:this.ct).KD(l,h);this.ct=p}else(this.ct===null||!Geo.K(this.ct.sc,t-o)||!Geo.K(this.ct.nc,i-o))&&(this.ct=Shape.wv(this,l,h));r=this.ct.bounds,t===1/0||i===1/0?this.Qn(r.x-o/2,r.y-o/2,t===0&&l===0?0:r.width+o,i===0&&h===0?0:r.height+o):this.Qn(-(o/2),-(o/2),a+o,c+o),n.isReal()?(a=n.width,c=n.height,a=Math.min(u.width,a),c=Math.min(u.height,c),a=Math.max(d.width,a),c=Math.max(d.height,c),this.Vi.e(0,0,a,c)):this.Vi.a(r)}_P(){const t=this.geometryStretch;return this.xs!==null?t===1?2:t:t===1?Shape.I2[this.figure].defaultStretch:t}ah(t,i,e,s){this.commonArrange(t,i,e,s)}getNearestIntersectionPoint(t,i,e){return this.Zc(t.x,t.y,i.x,i.y,e)}Zc(t,i,e,s,n){const o=this.D,r=1/(o.m11*o.m22-o.m12*o.m21),l=o.m22*r,h=-o.m12*r,a=-o.m21*r,c=o.m11*r,f=r*(o.m21*o.dy-o.m22*o.dx),u=r*(o.m12*o.dx-o.m11*o.dy),d=t*l+i*a+f,m=t*h+i*c+u,g=e*l+s*a+f,p=e*h+s*c+u,y=this.jo/2;let x=this.ct;x===null&&(this.ut(1/0,1/0),x=this.ct);const k=x.bounds;let b=!1;if(x.type===1)if(this.strokeWidth<=1.5)b=Geo.Vn(x.startX,x.startY,x.endX,x.endY,d,m,g,p,n);else{let P=0,S=0;if(x.startX===x.endX)P=y,S=0;else{const T=(x.endY-x.startY)/(x.endX-x.startX);S=y/Math.sqrt(1+T*T),P=S*T}const L=Util.nt();let C=new Point;Geo.Vn(x.startX+P,x.startY+S,x.endX+P,x.endY+S,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Vn(x.startX-P,x.startY-S,x.endX-P,x.endY-S,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Vn(x.startX+P,x.startY+S,x.startX-P,x.startY-S,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Vn(x.endX+P,x.endY+S,x.endX-P,x.endY-S,d,m,g,p,C)&&L.push(C);const M=L.length;if(M===0)return Util.tt(L),!1;b=!0;let N=1/0;for(let T=0;T0&&k.contains(D,F)&&(M.x=D,M.y=F,this.containsPoint(M)))for(N!==0&&Math.abs(N)<.5?(T*=.5/N,N=.5):T!==0&&Math.abs(T)<.5&&(N*=.5/T,T=.5),D-=N,F-=T;k.contains(D,F);)D-=N,F-=T;const R=.6;n.x=g,n.y=p;for(let X=0;Xe?t-e:e-t)<(i>s?i-s:s-i)){const f=if||Geo.K(h.y,f))&&(h.yf||Geo.K(h.x,f))&&(h.x=a&&h<=c}else{let a=0,c=0;return s=a&&l<=c}}kv(t,i){if(this.containedInRect(t,i)||i===void 0&&(i=this.D,t.containsRect(this.actualBounds)))return!0;const e=t.left,s=t.right,n=t.top,o=t.bottom,r=Point.l(),l=Point.l(),h=Point.l(),a=Transform.l();a.set(i),a.hC(this.D),a.yw(),l.x=s,l.y=n,l.D(a),r.x=e,r.y=n,r.D(a);let c=!1;return this.Aa(r,l,h)?c=!0:(r.x=s,r.y=o,r.D(a),this.Aa(r,l,h)?c=!0:(l.x=e,l.y=o,l.D(a),this.Aa(r,l,h)?c=!0:(r.x=e,r.y=n,r.D(a),this.Aa(r,l,h)&&(c=!0)))),Transform.s(a),Point.s(r),Point.s(l),Point.s(h),c}_L(t,i,e){if(e&&this.fill!==null&&this.hh(t,!0))return!0;let s=t.distanceSquaredPoint(i);const n=s;this.strokeWidth>1.5&&(s=this.strokeWidth/2+Math.sqrt(s),s*=s);let o=this.ct;if(o===null&&(this.ut(1/0,1/0),o=this.ct,o===null))return!1;if(!e){const f=o.bounds,u=f.x,d=f.y,m=f.x+f.width,g=f.y+f.height;if(Point.distanceSquared(t.x,t.y,u,d)<=s&&Point.distanceSquared(t.x,t.y,m,d)<=s&&Point.distanceSquared(t.x,t.y,u,g)<=s&&Point.distanceSquared(t.x,t.y,m,g)<=s)return!0}function r(f,u){const d=f.length;for(let m=0;ms)return!0;return!1}const l=o.startX,h=o.startY,a=o.endX,c=o.endY;if(o.type===1){const f=Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,c),u=(a-l)*(t.x-l)+(c-h)*(t.y-h),d=(l-a)*(t.x-a)+(h-c)*(t.y-c),m=u>=0&&d>=0?s:n;return f<=m}else if(o.type===2){let f=!1;return e&&(f=Point.distanceLineSegmentSquared(t.x,t.y,l,h,l,c)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,h)<=s||Point.distanceLineSegmentSquared(t.x,t.y,a,h,a,c)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,c,a,c)<=s),f}else if(o.type===3){const f=(l+a)/2,u=(h+c)/2,d=t.x-f,m=t.y-u,g=Math.abs(a-l)/2,p=Math.abs(c-h)/2;if(g===0||p===0)return Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,c)<=s;if(e){const y=Geo.vD(g,p,d,m);return y*y<=s}else return!(Point.distanceSquared(d,m,-g,0)>=s||Point.distanceSquared(d,m,0,-p)>=s||Point.distanceSquared(d,m,0,p)>=s||Point.distanceSquared(d,m,g,0)>=s)}else if(o.type===4){const f=o.bounds,u=f.x,d=f.y,m=f.x+f.width,g=f.y+f.height;if(t.x>m&&t.xg&&t.ys&&Point.distanceLineSegmentSquared(t.x,t.y,u,d,m,d)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,u,g)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,m,d)>s)return!1;const p=Math.sqrt(s);if(e){if(this.fill===null?o.xC(t.x,t.y,p):o.Vk(t,p,!0,!1))return!0}else{const y=o.figures;for(let x=0;xs)return!1;const S=k.segments.r,L=S.length;for(let C=0;Cs)return!1;break;case 3:{const N=Util.nt();Geo.Un(b,P,M.point1X,M.point1Y,M.point2X,M.point2Y,M.endX,M.endY,.8,N);const T=r(N,t);if(Util.tt(N),T||(b=M.endX,P=M.endY,t.distanceSquared(b,P)>s))return!1;break}case 4:{const N=Util.nt();Geo.Bg(b,P,M.point1X,M.point1Y,M.endX,M.endY,.8,N);const T=r(N,t);if(Util.tt(N),T||(b=M.endX,P=M.endY,t.distanceSquared(b,P)>s))return!1;break}case 5:case 6:{const N=M.type===5?M.Mo(k):M.Eh(k,b,P),T=N.length;if(T===0){if(b=M.type===5?M.centerX:M.endX,P=M.type===5?M.centerY:M.endY,t.distanceSquared(b,P)>s)return!1;break}let A=null;const D=Util.nt();for(let F=0;F=0){this.jo=t,this.c();const e=this.part;e!==null&&e.cf(),this.t("strokeWidth",i,t)}else Util._(t,"value >= 0",Shape,"strokeWidth:value")}w0(){return this.jo}get strokeCap(){return this.Lt!==null?this.Lt.pp:"butt"}set strokeCap(t){const i=this.strokeCap;i!==t&&(typeof t=="string"&&(t==="butt"||t==="round"||t==="square")?(this.La(),this.Lt.pp=t,this.C(),this.t("strokeCap",i,t)):Util._(t,'"butt", "round", or "square"',Shape,"strokeCap"))}get strokeJoin(){return this.Lt!==null?this.Lt.yp:"miter"}set strokeJoin(t){const i=this.strokeJoin;i!==t&&(typeof t=="string"&&(t==="miter"||t==="bevel"||t==="round")?(this.La(),this.Lt.yp=t,this.C(),this.t("strokeJoin",i,t)):Util._(t,'"miter", "bevel", or "round"',Shape,"strokeJoin"))}get strokeMiterLimit(){return this.Lt!==null?this.Lt.wp:10}set strokeMiterLimit(t){const i=this.strokeMiterLimit;if(i!==t&&t>=1){this.La(),this.Lt.wp=t,this.C();const e=this.part;e!==null&&e.cf(),this.t("strokeMiterLimit",i,t)}}get strokeDashArray(){return this.Xo}set strokeDashArray(t){const i=this.Xo;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",Shape,"strokeDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("strokeDashArray:value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.Xo=t,this.C(),this.t("strokeDashArray",i,t)}}get strokeDashOffset(){return this.Lt!==null?this.Lt.dh:0}set strokeDashOffset(t){const i=this.strokeDashOffset;i!==t&&t>=0&&(this.La(),this.Lt.dh=t,this.C(),this.t("strokeDashOffset",i,t))}get figure(){return this.xd}set figure(t){const i=this.xd;if(i!==t){let e=Geo.So[t];if(typeof e=="function"?e=t:(e=Geo.So[t.toLowerCase()],e||Util.o("Unknown Shape.figure: "+t)),i!==e){const s=this.part;s!==null&&s.cf(),this.xd=e,this.xs=null,this.ee(),this.c(),this.t("figure",i,e)}}}get toArrow(){return this.Bt!==null?this.Bt.xp:"None"}set toArrow(t){const i=this.toArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){const e=Shape.AA(t);e===null?Util.o("Unknown Shape.toArrow: "+t):i!==e&&(this.Bt===null&&(this.Bt=new LinkElementSettings),this.Bt.xp=e,this.xs=null,this.ee(),this.c(),this.TA(e),this.t("toArrow",i,e))}}get fromArrow(){return this.Bt!==null?this.Bt.bp:"None"}set fromArrow(t){const i=this.fromArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){const e=Shape.AA(t);e===null?Util.o("Unknown Shape.fromArrow: "+t):i!==e&&(this.Bt===null&&(this.Bt=new LinkElementSettings),this.Bt.bp=e,this.xs=null,this.ee(),this.c(),this.TA(e),this.t("fromArrow",i,e))}}TA(t){const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;this.vR();const e=Spot.MiddleRight;this.toArrow!=="None"?(this.segmentIndex=-1,this.alignmentFocus=e):this.fromArrow!=="None"&&(this.segmentIndex=0,this.alignmentFocus=new Spot(1-e.x,e.y))}get spot1(){return this.Lt!==null?this.Lt.zn:Spot.Default}set spot1(t){const i=this.spot1;i.equals(t)||(t=t.N(),this.La(),this.Lt.zn=t,this.c(),this.t("spot1",i,t))}get spot2(){return this.Lt!==null?this.Lt.Xn:Spot.Default}set spot2(t){const i=this.spot2;i.equals(t)||(t=t.N(),this.La(),this.Lt.Xn=t,this.c(),this.t("spot2",i,t))}get parameter1(){return this.bd}set parameter1(t){const i=this.bd;i!==t&&(this.bd=t,this.ee(),this.c(),this.t("parameter1",i,t))}get parameter2(){return this.kd}set parameter2(t){const i=this.kd;i!==t&&(this.kd=t,this.ee(),this.c(),this.t("parameter2",i,t))}get naturalBounds(){return this.Vi}_R(){const t=this.desiredSize;if(!t.isReal()&&this.ct!==null){const i=this.ct.bounds;this.Vi.a(i)}else this.Vi.e(0,0,t.width,t.height)}get pathPattern(){return this.Lt!==null?this.Lt.kp:null}set pathPattern(t){const i=this.pathPattern;i!==t&&(this.La(),this.Lt.kp=t,this.C(),this.t("pathPattern",i,t))}get geometryStretch(){return this.Lt!==null?this.Lt.Pp:1}set geometryStretch(t){const i=this.geometryStretch;i!==t&&(this.La(),this.Lt.Pp=t,this.c(),this.t("geometryStretch",i,t))}get interval(){return this.J!==null?this.J.uf:1}set interval(t){const i=this.interval;if(t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this.J===null&&(this.J=new GradElementSettings),this.J.uf=t;const e=this.diagram;e!==null&&this.panel===e.grid&&e.jr(),this.c();const s=this.panel;s!==null&&(s.ns=null),this.t("interval",i,t)}}get graduatedStart(){return this.J!==null?this.J.df:0}set graduatedStart(t){const i=this.graduatedStart;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.df=t,this.c(),this.t("graduatedStart",i,t))}get graduatedEnd(){return this.J!==null?this.J.gf:1}set graduatedEnd(t){const i=this.graduatedEnd;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.gf=t,this.c(),this.t("graduatedEnd",i,t))}get graduatedSkip(){return this.J!==null?this.J.mf:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.i(t,"function",Shape,"graduatedSkip"),this.J===null&&(this.J=new GradElementSettings),this.J.mf=t,this.c(),this.t("graduatedSkip",i,t))}static wv(t,i,e){let n=null;if(t.toArrow!=="None")n=Shape.no[t.toArrow];else if(t.fromArrow!=="None")n=Shape.no[t.fromArrow];else{let o=Geo.So[t.figure];typeof o=="string"&&(o=Geo.So[o]),o===void 0&&Util.o("Unknown Shape.figure: "+t.figure),n=o(t,i,e),n.sc=i,n.nc=e}if(n===null){const o=Geo.So.Rectangle;typeof o=="function"&&(n=o(t,i,e))}return n}static getFigureGenerators(){const t=new GMap;for(const i in Geo.So){if(i===i.toLowerCase())continue;const e=Geo.So[i];t.set(i,e)}return t.g(),t}static defineFigureGenerator(t,i){Util.i(t,"string",Shape,"defineFigureGenerator:name"),typeof i=="string"||Util.i(i,"function",Shape,"defineFigureGenerator:func");const e=t.toLowerCase(),s=Geo.So;s[t]=i,s[e]=t}static getArrowheadGeometries(){const t=new GMap;for(const i in Geo.Xg)if(Shape.no[i]===void 0){const e=Geometry.parse(Geo.Xg[i],!1);Shape.no[i]=e;const s=i.toLowerCase();s!==i&&(Shape.no[s]=i)}for(const i in Shape.no){if(i===i.toLowerCase())continue;const e=Shape.no[i];e instanceof Geometry&&t.set(i,e)}return t.g(),t}static defineArrowheadGeometry(t,i){Util.i(t,"string",Shape,"defineArrowheadGeometry:name");let e=null;typeof i=="string"?(Util.i(i,"string",Shape,"defineArrowheadGeometry:pathstr"),e=Geometry.parse(i,!1)):e=i;const s=t.toLowerCase();(s==="none"||t===s)&&Util.o("Shape.defineArrowheadGeometry name must not be empty or None or all-lower-case: "+t);const n=Shape.no;n[t]=e,n[s]=t}static no=new PropertyCollection;static I2=new PropertyCollection;static AA(t){let i=Shape.no[t];if(i===void 0){const e=t.toLowerCase();if(e==="none")return"None";if(i=Shape.no[e],i===void 0){let s=null;for(const n in Geo.Xg)if(n.toLowerCase()===e){s=n;break}if(s!==null){const n=Geometry.parse(Geo.Xg[s],!1);return Shape.no[s]=n,e!==s&&(Shape.no[e]=s),s}}}return typeof i=="string"?i:i instanceof Geometry?t:null}}class ShapeTemplateSettings{gi;pp;yp;wp;dh;kp;Pp;zn;Xn;constructor(){this.gi=!1,this.pp="butt",this.yp="miter",this.wp=10,this.dh=0,this.kp=null,this.Pp=1,this.zn=Spot.Default,this.Xn=Spot.Default}copy(){const t=new ShapeTemplateSettings;return t.pp=this.pp,t.yp=this.yp,t.wp=this.wp,t.dh=this.dh,t.kp=this.kp,t.Pp=this.Pp,t.zn=this.zn.N(),t.Xn=this.Xn.N(),t}}var Wrap=(w=>(w[w.None=0]="None",w[w.Fit=1]="Fit",w[w.DesiredSize=2]="DesiredSize",w[w.BreakAll=3]="BreakAll",w))(Wrap||{}),TextOverflow=(w=>(w[w.Clip=0]="Clip",w[w.Ellipsis=1]="Ellipsis",w))(TextOverflow||{}),TextFormat=(w=>(w[w.Trim=0]="Trim",w[w.None=1]="None",w))(TextFormat||{});class TextBlock extends GraphObject{hi;Hi;kn;Ce;mi;x0;Sd;J;W;Dl;oo;Pn;Le;Di;Sn;constructor(t,i){return super(),this.n|=2097152,this.hi="",this.Hi="black",this.kn="13px sans-serif",this.Ce=0,this.mi=0,this.x0=0,this.Sd=null,this.J=null,this.W=null,this.Dl=0,this.oo=null,this.Pn=0,this.Le=null,this.Di=null,this.Sn=null,typeof t=="string"?this.text=t:t&&Object.assign(this,t),i&&Object.assign(this,i),this}cloneProtected(t){super.cloneProtected(t),t.hi=this.hi,t.Hi=this.Hi,t.kn=this.kn,t.Ce=this.Ce,t.mi=this.mi,t.x0=this.x0,t.Sd=this.Sd,this.J!==null&&(t.J=this.J.copy()),this.W!==null&&(this.W.gi?t.W=this.W:t.W=this.W.copy()),t.Dl=this.Dl,t.oo=this.oo,t.Pn=this.Pn,t.Le=this.Le,t.Di=this.Di,t.Sn=this.Sn}Mn(){this.W===null?this.W=new TextBlockTemplateSettings:this.W.gi&&(this.W=this.W.copy())}lh(){super.lh(),this.W!==null&&(this.W.gi=!0)}rv(t){this.n=t.n|2048|4096,this.Wt=t.opacity,this.Ct=t.background,this.ze=t.desiredSize.N(),this.minSize=t.minSize.N(),this.maxSize=t.maxSize.N(),t.bi!==null?this.bi=t.bi.copy():this.bi=null,this.et=t.scale,this.Xt=t.angle,this.stretch=t.stretch,this.Zr=t.margin.N(),this.oi=t.alignment.N(),this.Wc=t.alignmentFocus.N(),this.segmentFraction=t.segmentFraction,this.segmentOffset=t.segmentOffset.N(),this.segmentOrientation=t.segmentOrientation,t.ni!==null&&(this.ni=t.ni.copy()),this.shadowVisible=t.shadowVisible,this.hi=t.hi,this.Hi=t.Hi,this.kn=t.kn,this.J!==null&&(this.J=t.J.copy()),t.W!==null&&(t.W.gi?this.W=t.W:this.W=t.W.copy()),this.Dl=t.Dl}nv(t){if(this.hi=t.text||"",this.Xt=t.labelAngle||0,this.Ce=t.lineCount||0,this.Pv(t.lines),t.naturalBounds&&(this.Vi=t.naturalBounds),t.actualBounds){const i=t.actualBounds;this.zt(i.x,i.y,i.width,i.height)}}ri(t){t in Wrap?this.wrap=t:super.ri(t)}toString(){return this.hi.length>22?'TextBlock("'+this.hi.substring(0,20)+'"...)':'TextBlock("'+this.hi+'")'}static getEllipsis(){return TextBlock.Sp}static setEllipsis(t){TextBlock.Sp=t,TextBlock.Zb=new PropertyCollection,TextBlock.E2=0}static getBaseline(){return TextBlock.Qb}static setBaseline(t){TextBlock.Qb=t}static Qb=null;static getUnderline(){return TextBlock._b}static setUnderline(t){TextBlock._b=t}static _b=null;static None=0;static WrapFit=1;static WrapDesiredSize=2;static WrapBreakAll=3;static OverflowClip=0;static OverflowEllipsis=1;static FormatTrim=0;static FormatNone=1;c(){super.c()}get font(){return this.kn}set font(t){const i=this.kn;i!==t&&(this.kn=t,this.oo=null,this.c(),this.t("font",i,t))}static isValidFont(t){return root.CSS?root.CSS.supports("font",t):!0}get text(){return this.hi}set text(t){const i=this.hi;t!=null?t=t.toString():t="",i!==t&&(this.hi=t,this.c(),this.t("text",i,t),this.ss(!0))}get textAlign(){return this.W!==null?this.W.Mp:"start"}set textAlign(t){const i=this.textAlign;i!==t&&(t==="start"||t==="end"||t==="left"||t==="right"||t==="center")&&(this.Mn(),this.W.Mp=t,this.C(),this.t("textAlign",i,t))}get flip(){return this.W!==null?this.W.ro:0}set flip(t){const i=this.flip;i!==t&&(this.Mn(),this.W.ro=t,this.C(),this.t("flip",i,t))}get verticalAlignment(){return this.W!==null?this.W.sl:Spot.Top}set verticalAlignment(t){const i=this.verticalAlignment;i.equals(t)||(t=t.N(),this.Mn(),this.W.sl=t,this.ef(),this.t("verticalAlignment",i,t))}get naturalBounds(){if(!this.Vi.isReal()){const t=Size.l();this.B2(this.hi,999999,t);let i=t.width;Size.s(t);let e=this.DA(i);const s=this.desiredSize;isNaN(s.width)||(i=s.width),isNaN(s.height)||(e=s.height),this.Vi.En(i,e)}return this.Vi}get isMultiline(){return(this.n&2097152)!==0}set isMultiline(t){const i=(this.n&2097152)!==0;i!==t&&(this.n=this.n^2097152,this.c(),this.t("isMultiline",i,t))}get isUnderline(){return(this.n&4194304)!==0}set isUnderline(t){const i=(this.n&4194304)!==0;i!==t&&(this.n=this.n^4194304,this.ss(!0),this.C(),this.t("isUnderline",i,t))}get isStrikethrough(){return(this.n&8388608)!==0}set isStrikethrough(t){const i=(this.n&8388608)!==0;i!==t&&(this.n=this.n^8388608,this.ss(!0),this.C(),this.t("isStrikethrough",i,t))}get wrap(){return this.W!==null?this.W.Np:2}set wrap(t){const i=this.wrap;i!==t&&(this.Mn(),this.W.Np=t,this.c(),this.t("wrap",i,t))}get overflow(){return this.W!==null?this.W.Cp:0}set overflow(t){const i=this.overflow;i!==t&&(this.Mn(),this.W.Cp=t,this.c(),this.t("overflow",i,t))}get isOverflowed(){return(this.n&16777216)!==0}U2(t){t?this.n|=16777216:this.n&=-16777217}get stroke(){return this.Hi}set stroke(t){const i=this.Hi;i!==t&&(t!==null&&Brush.nd(t,"TextBlock.stroke"),t instanceof Brush&&t.g(),this.Hi=t,this.C(),this.t("stroke",i,t))}get lineCount(){return this.Ce}get lineHeight(){return this.Lp()}get editable(){return(this.n&1048576)!==0}set editable(t){const i=(this.n&1048576)!==0;i!==t&&(this.n=this.n^1048576,this.t("editable",i,t))}get L2(){return(this.n&33554432)!==0}set L2(t){this.n=this.n^33554432}get textEditor(){return this.W!==null?this.W.Ap:null}set textEditor(t){const i=this.textEditor;i!==t&&(this.Mn(),this.W.Ap=t,this.t("textEditor",i,t))}get errorFunction(){return this.W!==null?this.W.os:null}set errorFunction(t){const i=this.errorFunction;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"errorFunction"),this.Mn(),this.W.os=t,this.t("errorFunction",i,t))}get interval(){return this.J!==null?this.J.uf:1}set interval(t){const i=this.interval;if(t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this.J===null&&(this.J=new GradElementSettings),this.J.uf=t,this.c();const e=this.panel;e!==null&&(e.ns=null),this.t("interval",i,t)}}get graduatedStart(){return this.J!==null?this.J.df:0}set graduatedStart(t){const i=this.graduatedStart;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.df=t,this.c(),this.t("graduatedStart",i,t))}get graduatedEnd(){return this.J!==null?this.J.gf:1}set graduatedEnd(t){const i=this.graduatedEnd;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.gf=t,this.c(),this.t("graduatedEnd",i,t))}get graduatedFunction(){return this.J!==null?this.J.Tp:null}set graduatedFunction(t){const i=this.graduatedFunction;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"graduatedFunction"),this.J===null&&(this.J=new GradElementSettings),this.J.Tp=t,this.c(),this.t("graduatedFunction",i,t))}get graduatedSkip(){return this.J!==null?this.J.mf:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"graduatedSkip"),this.J===null&&(this.J=new GradElementSettings),this.J.mf=t,this.c(),this.t("graduatedSkip",i,t))}fh(t,i){if(this.Hi===null||this.hi.length===0||this.kn===null)return;const e=this.naturalBounds,s=this.actualBounds,n=e.width,o=e.height,r=this.Lp();let l=t.textAlign=this.textAlign;const h=i.Xu;l==="start"?l=h?"right":"left":l==="end"&&(l=h?"left":"right");const a=this.isUnderline,c=this.isStrikethrough;this.dn(t,this.Hi,!0,!1,e,s),(a||c)&&this.dn(t,this.Hi,!1,!1,e,s);const f=0;let u=0;const d=n;let m=!1;i.Zt===t&&!(i.Zt instanceof SVGContext)&&!this.L2&&i.getRenderingHint("textGreeking")===!0&&r*this.ca*i.scale<3&&(m=!0);const g=this.spacingAbove,p=this.spacingBelow;switch(this.flip){case 0:break;case 2:t.translate(n,0),t.scale(-1,1);break;case 1:t.translate(0,o),t.scale(1,-1);break;case 3:t.translate(n,o),t.scale(-1,-1);break}t.commitTransform();const y=this.Ce,k=(g+r+p)*y;if(o>k){const b=this.verticalAlignment;u=b.y*o-b.y*k+b.offsetY}if(y===1&&this.Sn!==null){let b=this.mi;b>d&&(b=d),u+=g,this.FA(this.Sn,t,f,u,d,r,b,m,l,a,c)}else if(this.Le!==null&&this.Di!==null)for(let b=0;bd&&(P=d),u+=g,this.FA(this.Di[b],t,f,u,d,r,P,m,l,a,c),u+=r+p}switch(this.flip){case 0:break;case 2:t.scale(-1,1),t.translate(-n,0);break;case 1:t.scale(1,-1),t.translate(0,-o);break;case 3:t.scale(-1,-1),t.translate(-n,-o);break}}FA(t,i,e,s,n,o,r,l,h,a,c){let f=0;if(l){h==="left"?f=0:h==="right"?f=n-r:h==="center"&&(f=(n-r)/2);const m=i.globalAlpha;i.globalAlpha=m/2,i.fillRect(e+f,s+o/4,r,o/2),i.globalAlpha=m;return}h==="left"?f=0:h==="right"?f=n:h==="center"&&(f=n/2);const u=TextBlock.Qb!==null?TextBlock.Qb(this,o):o*.75;i.fillText(t,e+f,s+u);let d=o/20|0;if(d===0&&(d=1),h==="right"?f-=r:h==="center"&&(f-=r/2),a){const m=TextBlock._b!==null?TextBlock._b(this,o):o*.8;this.RA(e+f,s+m,e+f+r,s+m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}if(c){let m=s+o-o/2.2|0;d%2!==0&&(m+=.5),this.RA(e+f,m,e+f+r,m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}}RA(t,i,e,s,n,o){o.beginPath(),o.lineWidth=n,o.moveTo(t,i),o.lineTo(e,s),o.stroke(),o.endPath()}Qc(t,i,e){if(!super.Qc(t,i,e))return!1;if(this.dn(t,this.Hi,!0,!1,this.naturalBounds,this.actualBounds),e){if(this.svg.getElementsByTagName("text").length===0)return!0;const n=this.svg.getElementsByClassName("gojs-td");for(let o=0;o1||this.isUnderline||this.isStrikethrough?!0:super.ed(t)}l2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("text");for(let s=0;sthis.maxLines&&(this.n|=16777216))}B2(t,i,e){const s=this.formatting===0;s&&(t=t.trim());let n=0,o=0,r=0;const l=this.kn,h=this.spacingAbove+this.spacingBelow,a=Math.max(0,this.Lp()+h),c=this.overflow===1?this.OA(l):0;if(this.Ce>=this.maxLines){e!==null&&e.e(0,a);return}let f=t;if(this.wrap===0){if(this.Pn=1,o=this.getStringWidth(t),c===0||o<=i){this.mi=Math.max(this.mi,o),this.Nn(t,this.mi),e!==null&&e.e(o,a);return}let d=this.Md(f);f=f.substring(d.length);let m=this.Md(f);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,f=f.substring(m.length),m=this.Md(f),r=o;let g=d+m;s&&(g=g.trim()),o=this.getStringWidth(g)}for(s&&(m=m.trim()),d+=m,i=Math.max(1,i-c);this.getStringWidth(d)>i&&d.length>1;)d=d.substring(0,d.length-1);this.U2(!0),d+=TextBlock.Sp,r=this.getStringWidth(d),this.mi=r,this.Nn(d,r),e!==null&&e.e(r,a);return}let u=0;for(f.length===0&&(u=1,this.Nn(f,0));f.length>0;){let d=this.Md(f);for(f=f.substring(d.length);this.getStringWidth(d)>i;){let p=1;for(o=this.getStringWidth(d.substring(0,p)),r=0;o<=i;)p++,r=o,o=this.getStringWidth(d.substring(0,p));let y=0;p===1?(y=o,n=Math.max(n,o)):(y=r,n=Math.max(n,r)),p--,p<1&&(p=1);const x=d.substring(0,p);if(this.Nn(x,y),u++,d=d.substring(p),this.Ce+u>this.maxLines)break}let m=this.Md(f);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,f=f.substring(m.length),m=this.Md(f),r=o;let p=d+m;s&&(p=p.trim()),o=this.getStringWidth(p)}if(s&&(d=d.trim()),d==="")continue;d[d.length-1]==="\xAD"&&(d=d.substring(0,d.length-1)+"\u2010");let g=0;if(m.length===0?(g=o,n=Math.max(n,o)):(r=this.getStringWidth(d),g=r,n=Math.max(n,r)),this.Nn(d,g),u++,this.Ce+u>this.maxLines)break}this.Pn=Math.min(this.maxLines,u),this.mi=Math.max(this.mi,n),e!==null&&e.e(this.mi,a*this.Pn)}Cv(t,i){if(this.mi===0||this.Le===null||this.Di===null||this.overflow!==1)return;const e=this.kn,s=this.overflow===1?this.OA(e):0,n=this.spacingAbove+this.spacingBelow,o=Math.max(0,this.Lp()+n),r=Math.min(this.maxLines-1,Math.max(Math.floor(i/o+.01)-1,0));if(r+1>=this.Di.length)return;this.U2(!0);let l=this.Di[r];const h=Math.max(1,t-s);for(;this.getStringWidth(l)>h&&l.length>1;)l=l.substring(0,l.length-1);l+=TextBlock.Sp;const a=this.getStringWidth(l);this.Di[r]=l,this.Di=this.Di.slice(0,r+1),this.Le[r]=a,this.Le=this.Le.slice(0,r+1),this.Pn=this.Di.length,this.mi=Math.max(this.mi,a),this.Ce=this.Pn,this.Ce===1&&(this.Sn=this.Di[0])}Md(t){if(this.wrap===3)return t.substring(0,1);let i=t.length,e=0;const s=TextBlock.Lv;for(;e=t.length?t:t.substring(0,e)}getStringWidth(t){return TextBlock.il===null?t.length*8:TextBlock.il.measureText(t).width}Lp(){if(this.oo!==null)return this.oo;const t=this.kn;let i=0;return TextBlock.il===null?(i=16,this.oo=i,i):(TextBlock.V2[t]!==void 0&&TextBlock.IA<5e3?i=TextBlock.V2[t]:(i=TextBlock.il.measureText("M").width*1.3,TextBlock.V2[t]=i,TextBlock.IA++),this.oo=i,i)}OA(t){if(TextBlock.il===null)return 6;let i=0;return TextBlock.Zb[t]!==void 0&&TextBlock.E2<5e3?i=TextBlock.Zb[t]:(i=TextBlock.il.measureText(TextBlock.Sp).width,TextBlock.Zb[t]=i,TextBlock.E2++),i}t1(t,i){return t.indexOf(` `,i)}DA(t){let i=this.hi.replace(/\r\n/g,` `).replace(/\r/g,` -`);const e=this.spacingAbove+this.spacingBelow,s=Math.max(0,this.Lp()+e);if(i.length===0)return this.mi=0,this.Ce=1,s;if(!this.isMultiline){const h=this.t1(i,0);h>=0&&(i=i.substring(0,h))}let n=0;this.Ce=0;let o=0,r=-1,l=!1;for(;!l;){if(r=this.t1(i,o),r===-1&&(r=i.length,l=!0),o<=r){const h=i.substring(o,r);if(this.wrap!==0){this.Pn=0;const a=Size.l();this.V2(h,t,a),n+=a.height,Size.s(a),this.Ce+=this.Pn}else this.V2(h,t,null),n+=s,this.Ce++;this.Ce===this.maxLines&&(l=!0)}o=r+1}return this.x0=n,n}Cv(){let t=this.hi.replace(/\r\n/g,` +`);const e=this.spacingAbove+this.spacingBelow,s=Math.max(0,this.Lp()+e);if(i.length===0)return this.mi=0,this.Ce=1,s;if(!this.isMultiline){const h=this.t1(i,0);h>=0&&(i=i.substring(0,h))}let n=0;this.Ce=0;let o=0,r=-1,l=!1;for(;!l;){if(r=this.t1(i,o),r===-1&&(r=i.length,l=!0),o<=r){const h=i.substring(o,r);if(this.wrap!==0){this.Pn=0;const a=Size.l();this.B2(h,t,a),n+=a.height,Size.s(a),this.Ce+=this.Pn}else this.B2(h,t,null),n+=s,this.Ce++;this.Ce===this.maxLines&&(l=!0)}o=r+1}return this.x0=n,n}Nv(){let t=this.hi.replace(/\r\n/g,` `).replace(/\r/g,` -`);if(t.length===0)return 8;if(this.isMultiline){let i=0,e=0,s=!1;for(;!s;){let n=this.t1(t,e);n===-1&&(n=t.length,s=!0);let o=t.substring(e,n);this.formatting===0&&(o=o.trim()),i=Math.max(i,this.getStringWidth(o)),e=n+1}return i}else{const i=this.t1(t,0);return i>=0&&(t=t.substring(0,i)),this.getStringWidth(t)}}get textValidation(){return this.W!==null?this.W.Tl:null}set textValidation(t){const i=this.textValidation;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"textValidation"),this.Sn(),this.W.Tl=t,this.t("textValidation",i,t))}get textEdited(){return this.W!==null?this.W.Dp:null}set textEdited(t){const i=this.textEdited;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"textEdited"),this.Sn(),this.W.Dp=t,this.t("textEdited",i,t))}get spacingAbove(){return this.W!==null?this.W.Fp:0}set spacingAbove(t){const i=this.spacingAbove;i!==t&&(this.Sn(),this.W.Fp=t,this.c(),this.t("spacingAbove",i,t))}get spacingBelow(){return this.W!==null?this.W.Rp:0}set spacingBelow(t){const i=this.spacingBelow;i!==t&&(this.Sn(),this.W.Rp=t,this.c(),this.t("spacingBelow",i,t))}get formatting(){return this.W!==null?this.W.vp:0}set formatting(t){const i=this.formatting;i!==t&&(this.Sn(),this.W.vp=t,this.c(),this.t("formatting",i,t))}get maxLines(){return this.W!==null?this.W.Op:1/0}set maxLines(t){const i=this.maxLines;i!==t&&(t=Math.floor(t),t<=0&&Util._(t,"> 0",TextBlock,"maxLines"),this.Sn(),this.W.Op=t,this.c(),this.t("maxLines",i,t))}getMetrics(){return[this.mi,this.Dl,this.oo,this.Pn,this.Le,this.Di,this.Mn]}Mv(t){t!==void 0&&(this.mi=t[0],this.Dl=t[1],this.oo=t[2],this.Pn=t[3],this.Le=t[4],this.Di=t[5],this.Mn=t[6])}get metrics(){return{arrSize:this.Le!==null?this.Le:[this.mi],arrText:this.Di!==null?this.Di:[this.Mn],maxLineWidth:this.mi,fontHeight:this.oo}}get choices(){return this.Sd}set choices(t){const i=this.Sd;i!==t&&(this.Sd=t,this.t("choices",i,t))}static Av=new RegExp("[ \u200B\xAD]");static X2=new PropertyCollection;static IA=0;static Zb=new PropertyCollection;static B2=0;static Mp="...";static vA="";static il=Diagram.isUsingDOM()?new CanvasSurface(null).ai:null}class TextBlockTemplateSettings{gi;os;ro;vp;Op;Cp;Fp;Rp;Sp;Dp;Ap;Tl;sl;Np;constructor(){this.gi=!1,this.os=null,this.ro=0,this.vp=0,this.Op=1/0,this.Cp=0,this.Fp=0,this.Rp=0,this.Sp="start",this.Dp=null,this.Ap=null,this.Tl=null,this.sl=Spot.Top,this.Np=2}copy(){const t=new TextBlockTemplateSettings;return t.os=this.os,t.ro=this.ro,t.vp=this.vp,t.Op=this.Op,t.Cp=this.Cp,t.Fp=this.Fp,t.Rp=this.Rp,t.Sp=this.Sp,t.Dp=this.Dp,t.Ap=this.Ap,t.Tl=this.Tl,t.sl=this.sl,t.Np=this.Np,t}}class GradElementSettings{ff;uf;df;Tp;gf;constructor(){this.ff=1,this.uf=0,this.df=1,this.Tp=null,this.gf=null}copy(){const t=new GradElementSettings;return t.ff=this.ff,t.uf=this.uf,t.df=this.df,t.Tp=this.Tp,t.gf=this.gf,t}}var ImageStretch=(w=>(w[w.None=0]="None",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ImageStretch||{});class Picture extends GraphObject{nl;yt;ol;mf;os;rl;pf;ro;yf;wf;Ib;constructor(t,i){super(),this.n|=2097152,this.nl=null,this.yt="",this.ol=Rect.TD,this.mf=2,this.os=null,this.rl=null,this.pf=Spot.Center,this.ro=0,this.yf=null,this.wf=null,this.Ib=null,typeof t=="string"?this.source=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.yt=this.yt,t.element=this.nl,t.ol=this.ol.N(),t.mf=this.mf,t.ro=this.ro,t.os=this.os,t.rl=this.rl,t.pf=this.pf.N(),t.wf=this.wf}ri(t){t in ImageStretch?this.imageStretch=t:super.ri(t)}toString(){return"Picture("+this.source+")#"+GSet.as(this)}get xf(){return(this.n&1048576)!==0}set xf(t){this.xf!==t&&(this.n=this.n^1048576)}get Ip(){return(this.n&2097152)!==0}set Ip(t){this.Ip!==t&&(this.n=this.n^2097152)}get mn(){return(this.n&4194304)!==0}set mn(t){this.mn!==t&&(this.n=this.n^4194304)}static clearCache(t){t===void 0&&(t=""),Util.i(t,"string",Picture,"clearCache:url"),t!==""?Picture.Ep[t]&&(delete Picture.Ep[t],Picture.i1--):(Picture.Ep=new PropertyCollection,Picture.i1=0)}static IL(t,i){i.EA||(i.e1=e=>{Picture.Tv(i,e),t.desiredSize.isReal()||(t.fe(!1),t.c())},i.s1=e=>Picture.Dv(i,e),i.addEventListener("load",i.e1),i.addEventListener("error",i.s1),i.EA=!0)}static yR(t){t.e1&&t.removeEventListener("load",t.e1),t.s1&&t.removeEventListener("error",t.s1),delete t.e1,delete t.s1,delete t.EA}get element(){return this.nl}set element(t){const i=this.nl;if(this.ss(!0),i!==t){this.xf=t instanceof HTMLCanvasElement;const e=t instanceof HTMLImageElement;t!==null&&!(e||t instanceof HTMLVideoElement||this.xf)&&Util.o("Picture.element must be an instance of Image, Canvas, or Video, not: "+t);const s=this.diagram;s!==null&&s.DS(this),this.nl=t,t!==null&&e&&t.es===void 0&&(t.es=new GSet),s!==null&&e&&s.TS(this),this.t("element",i,t),this.C()}}mR(){const t=this.nl;if(t===null)return;const i=this.desiredSize.isReal();(this.xf||t.complete===!0)&&(t.f0&&(t.Up instanceof Event&&this.os!==null?this.os(this,t.Up):t.mn===!0&&!t.Up&&this.rl!==null&&t.K2&&this.rl(this,t.K2)),t.mn=!0),t.mn&&i&&this.diagram!==null&&this.diagram.Xu.add(this)}Fv(){if(this.nl===null){this.yf=!1;return}const t=new CanvasSurface(null).ai;try{t.drawImage(this.nl,0,0)}catch{this.Ip=!1}try{t.getImageData(0,0,1,1).data[3]&&(this.yf=!1),this.yf=!1}catch{this.yf=!0}}get source(){return this.yt}set source(t){const i=this.yt;if(i!==t){this.ss(!0),Util.i(t,"string",Picture,"source"),this.yt=t;let e=Picture.Ep;if(!Diagram.isUsingDOM()){this.t("source",i,t);return}let s=null;if(e[t]!==void 0)s=e[t];else if(t!==""){Picture.i1>30&&(Picture.clearCache(),e=Picture.Ep),s=Util.en("img"),s.f0=!0,Picture.IL(this,s);const n=this.wf;n!==null&&(s.crossOrigin=n(this)),s.src=t,e[t]=s,Picture.i1++}this.element=s,s!==null&&s.__goCache===void 0&&(s.__goCache=new PictureCacheArray),this.c(),this.C(),this.t("source",i,t)}}static Tv(t,i){t.mn=!0,t.Up=!1;let e;const s=t.es.copy();if(s==null)return;const n=s.iterator;for(;n.next();){const o=n.value;o.C();const r=t.getAttribute("src")||"",l=o.Jl.get(r);if(l===null)continue;const h=l.length;for(let a=0;a=o.width&&(r=r+p.offsetX+(d*p.x-o.width*p.x)),m>=o.height&&(l=l+p.offsetY+(m*p.y-o.height*p.y)),a=Math.min(o.width,d),c=Math.min(o.height,m);break;case 2:d=o.width,m=o.height;break;case 6:case 7:let A=0;g===6?(A=Math.min(o.height/m,o.width/d),d*=A,m*=A):g===7&&(A=Math.max(o.height/m,o.width/d),d*=A,m*=A,d>=o.width&&(r=(r+p.offsetX+(d*p.x-o.width*p.x)/d)*a),m>=o.height&&(l=(l+p.offsetY+(m*p.y-o.height*p.y)/m)*c),a*=1/(d/o.width),c*=1/(m/o.height),d=o.width,m=o.height);break}const y=a*c,x=this.getDocumentScale()*i.scale,k=d*x,b=m*x,P=k*b,M=y/P,L=e.__goCache;let C=null;const S=Picture.Rv;if(!n){if(e.mn&&L!==void 0&&P>4&&M>S*S){L.Ot===null&&(L.UA(4,f,u,e),L.UA(16,f,u,e));const A=L.Ot,D=A.length;for(let F=0;F0){const c=this.Ot[this.Ot.length-1];h=c.yt,a=c.Cd}o.setTransform(r*a,0,0,r*a,0,0),o.commitTransform(),o.drawImage(h,0,0),this.Ot.push(l)}}class PictureCacheInstance{yt;Cd;constructor(t,i){this.yt=t,this.Cd=i}}class GeoStream{Pi;qg;constructor(){this.qg=new Geometry,this.Pi=null}Ri(t){t!==null?(t.rt(),this.qg=t,t.figures.clear()):this.qg=new Geometry,this.Pi=null}uu(t,i,e,s,n,o){if(s!==void 0&&s===!0){const r=new PathSegment(1);r.endX=t,r.endY=i,this.Pi.segments.add(r)}else this.Pi=new PathFigure,this.Pi.startX=t,this.Pi.startY=i,this.Pi.isFilled=e,this.Pi.isEvenOdd=o||!1,this.qg.figures.add(this.Pi);n!==void 0&&(this.Pi.isShadowed=n)}VD(){const t=this.Pi.segments.length;t>0&&this.Pi.segments.elt(t-1).close()}zD(){this.Pi.segments.length>0&&(this.Pi.isFilled=!0)}XD(t){this.Pi.isShadowed=t}mE(t){this.Pi.isEvenOdd=t}ED(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(1);s.endX=t,s.endY=i,e&&s.close(),this.Pi.segments.add(s)}ur(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(2);s.endX=t,s.endY=i,e&&s.close(),this.Pi.segments.add(s)}dr(t,i,e,s,n,o,r){r===void 0&&(r=!1);const l=new PathSegment(3);l.point1X=t,l.point1Y=i,l.point2X=e,l.point2Y=s,l.endX=n,l.endY=o,r&&l.close(),this.Pi.segments.add(l)}Sw(t,i,e,s,n){n===void 0&&(n=!1);const o=new PathSegment(4);o.point1X=t,o.point1Y=i,o.endX=e,o.endY=s,n&&o.close(),this.Pi.segments.add(o)}UD(t,i,e,s,n,o,r){o===void 0&&(o=0),r===void 0&&(r=!1);const l=new PathSegment(5);l.startAngle=t,l.sweepAngle=i,l.centerX=e,l.centerY=s,l.radiusX=n,o!==0?l.radiusY=o:l.radiusY=n,r&&l.close(),this.Pi.segments.add(l)}BD(t,i,e,s,n,o,r,l){l===void 0&&(l=!1);const h=new PathSegment(6,o,r,t,i,e,s,n);l&&h.close(),this.Pi.segments.add(h)}static Y2=null;static yC(t){const i=GeoStream.Y2;if(i!==null)return GeoStream.Y2=null,i.Ri(t),i;{const e=new GeoStream;return e.Ri(t),e}}static wC(t){GeoStream.Y2=t}}{const w=function(n,o){const r=n.toLowerCase(),l=Geo.Mo;l[n]=o,l[r]=n};w("Rectangle",(n,o,r)=>{const l="r"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,Geo.fr{const l="s"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,h.defaultStretch=6,Geo.fr{(isNaN(l)||l<0)&&(l=5),isNaN(h)&&(h=15);const a="rr"+o+","+r+","+l+","+h;let c=Geo.cr[a];if(c!==void 0)return c;let f=l;(h&1)===1?(f=Math.min(f,(h&2)===2?o/3:o),f=Math.min(f,(h&8)===8?r/3:r)):f=0;const u=new PathFigure(f,0,!0);c=new Geometry().add(u);const d=Spot.TopLeft.copy(),m=Spot.BottomRight.copy();if((h&2)===2){let g=l;g=Math.min(g,(h&1)===1?o/3:o),g=Math.min(g,(h&4)===4?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,o-g,0)).add(new PathSegment(3,o,g,o-p,0,o,p)),d.offsetY=p,m.offsetX=-p}else u.add(new PathSegment(2,o,0));if((h&4)===4){let g=l;g=Math.min(g,(h&8)===8?o/3:o),g=Math.min(g,(h&2)===2?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,o,r-g)).add(new PathSegment(3,o-g,r,o,r-p,o-p,r)),m.offsetX=-p,m.offsetY=-p}else u.add(new PathSegment(2,o,r));if((h&8)===8){let g=l;g=Math.min(g,(h&4)===4?o/3:o),g=Math.min(g,(h&1)===1?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,g,r)).add(new PathSegment(3,0,r-g,p,r,0,r-p)),d.offsetX=p,m.offsetY=-p}else u.add(new PathSegment(2,0,r));if((h&1)===1){const g=f*Geo.Un;u.add(new PathSegment(2,0,f)).add(new PathSegment(3,f,0,0,g,g,0).close()),d.offsetX=g,d.offsetY=g}else u.add(new PathSegment(2,0,0).close());return c.spot1=d,c.spot2=m,Geo.fr{const l=n?n.parameter1:NaN,h=n?n.parameter2:NaN;return t(n,o,r,l,h)}),w("Border","RoundedRectangle"),w("RoundedTopRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,3)}),w("RoundedBottomRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,12)}),w("RoundedLeftRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,9)}),w("RoundedRightRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,6)}),w("Ellipse",(n,o,r)=>{const l="e"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Rk,h.spot2=Spot.vk,Geo.fr{const l="c"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Rk,h.spot2=Spot.vk,h.defaultStretch=6,Geo.frnew Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,.5*r)).add(new PathSegment(2,0,r).close())).setSpots(0,.25,.5,.75)),w("TriangleDown",(n,o,r)=>new Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,0)).add(new PathSegment(2,.5*o,r).close())).setSpots(.25,0,.75,.5)),w("TriangleLeft",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,o,0).close())).setSpots(.5,.25,1,.75)),w("TriangleUp",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,r)).add(new PathSegment(2,.5*o,0).close())).setSpots(.25,.5,.75,1)),w("Triangle","TriangleUp"),w("Diamond",(n,o,r)=>new Geometry().add(new PathFigure(.5*o,0).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,.5*o,r)).add(new PathSegment(2,o,.5*r).close())).setSpots(.25,.25,.75,.75)),w("LineH",(n,o,r)=>{const l=new Geometry(1);return l.startX=0,l.startY=r/2,l.endX=o,l.endY=r/2,l}),w("LineV",(n,o,r)=>{const l=new Geometry(1);return l.startX=o/2,l.startY=0,l.endX=o/2,l.endY=r,l}),w("None","Rectangle"),w("BarH","Rectangle"),w("BarV","Rectangle"),w("MinusLine","LineH"),w("PlusLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r/2,!1).add(new PathSegment(2,o,r/2)).add(new PathSegment(1,o/2,0)).add(new PathSegment(2,o/2,r)))),w("XLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r,!1).add(new PathSegment(2,o,0)).add(new PathSegment(1,0,0)).add(new PathSegment(2,o,r)))),w("LineRight",(n,o,r)=>new Geometry().add(new PathFigure(.25*o,0,!1).add(new PathSegment(2,.75*o,.5*r)).add(new PathSegment(2,.25*o,r)))),w("LineDown",(n,o,r)=>new Geometry().add(new PathFigure(0,.25*r,!1).add(new PathSegment(2,.5*o,.75*r)).add(new PathSegment(2,o,.25*r)))),w("LineLeft",(n,o,r)=>new Geometry().add(new PathFigure(.75*o,0,!1).add(new PathSegment(2,.25*o,.5*r)).add(new PathSegment(2,.75*o,r)))),w("LineUp",(n,o,r)=>new Geometry().add(new PathFigure(0,.75*r,!1).add(new PathSegment(2,.5*o,.25*r)).add(new PathSegment(2,o,.75*r)))),w("Capsule",(n,o,r)=>{const l=new Geometry;if(or){const h=new PathFigure(r/2,0,!0);return l.add(h),h.add(new PathSegment(2,o-r/2,0)),h.add(new PathSegment(5,270,180,o-r/2,r/2,r/2,r/2)),h.add(new PathSegment(2,r/2,r)),h.add(new PathSegment(5,90,180,r/2,r/2,r/2,r/2)),l.spot1=new Spot(0,.156,r*.156,0),l.spot2=new Spot(1,.844,-r*.156,0),l}else return l.type=3,l.endX=o,l.endY=r,l.spot1=Spot.Rk,l.spot2=Spot.vk,l});const i=(n,o)=>new PathFigure(n,o,!1,!1),e=(n,o,r)=>n.add(new PathSegment(2,o,r)),s=(n,o,r)=>n.add(new PathSegment(1,o,r));w("Borders",(n,o,r)=>{let l=n?n.parameter1:NaN;isNaN(l)?l=10:l=l&15;const h=new Geometry;let a;return l===10?(a=i(o,0),e(a,o,r),s(a,0,r),e(a,0,0)):l===5?(a=i(0,0),e(a,o,0),s(a,o,r),e(a,0,r)):l===1?(a=i(0,0),e(a,o,0),s(a,o,r)):l===2?(a=i(o,0),e(a,o,r)):l===4?(a=i(o,r),e(a,0,r)):l===8?(a=i(0,r),e(a,0,0),s(a,o,r)):l===3?(a=i(0,0),e(a,o,0),e(a,o,r)):l===6?(a=i(o,0),e(a,o,r),e(a,0,r)):l===12?(a=i(o,r),e(a,0,r),e(a,0,0)):l===9?(a=i(0,r),e(a,0,0),e(a,o,0)):l===7?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r)):l===14?(a=i(o,0),e(a,o,r),e(a,0,r),e(a,0,0)):l===13?(a=i(o,r),e(a,0,r),e(a,0,0),e(a,o,0)):l===11?(a=i(0,r),e(a,0,0),e(a,o,0),e(a,o,r)):l===15?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r),a.add(new PathSegment(2,0,0).close())):(a=i(0,0),s(a,o,r)),h.add(a),h})}Geo.Kg={"":"",Standard:"F1 m 0,0 l 8,4 -8,4 2,-4 z",Backward:"F1 m 8,0 l -2,4 2,4 -8,-4 z",Triangle:"F1 m 0,0 l 8,4.62 -8,4.62 z",BackwardTriangle:"F1 m 8,4 l 0,4 -8,-4 8,-4 0,4 z",Boomerang:"F1 m 0,0 l 8,4 -8,4 4,-4 -4,-4 z",BackwardBoomerang:"F1 m 8,0 l -8,4 8,4 -4,-4 4,-4 z",SidewaysV:"m 0,0 l 8,4 -8,4 0,-1 6,-3 -6,-3 0,-1 z",BackwardV:"m 8,0 l -8,4 8,4 0,-1 -6,-3 6,-3 0,-1 z",OpenTriangle:"m 0,0 l 8,4 -8,4",BackwardOpenTriangle:"m 8,0 l -8,4 8,4",OpenTriangleLine:"m 0,0 l 8,4 -8,4 m 8.5,0 l 0,-8",BackwardOpenTriangleLine:"m 8,0 l -8,4 8,4 m -8.5,0 l 0,-8",OpenTriangleTop:"m 0,0 l 8,4 m 0,4",BackwardOpenTriangleTop:"m 8,0 l -8,4 m 0,4",OpenTriangleBottom:"m 0,8 l 8,-4",BackwardOpenTriangleBottom:"m 0,4 l 8,4",HalfTriangleTop:"F1 m 0,0 l 0,4 8,0 z m 0,8",BackwardHalfTriangleTop:"F1 m 8,0 l 0,4 -8,0 z m 0,8",HalfTriangleBottom:"F1 m 0,4 l 0,4 8,-4 z",BackwardHalfTriangleBottom:"F1 m 8,4 l 0,4 -8,-4 z",ForwardSemiCircle:"m 4,0 b 270 180 0 4 4",BackwardSemiCircle:"m 4,8 b 90 180 0 -4 4",Feather:"m 0,0 l 3,4 -3,4",BackwardFeather:"m 3,0 l -3,4 3,4",DoubleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardDoubleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4",TripleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardTripleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4 m 3,-8 l -3,4 3,4",ForwardSlash:"m 0,8 l 5,-8",BackSlash:"m 0,0 l 5,8",DoubleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8",DoubleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8",TripleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8 m -2,8 l 4,-8",TripleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8 m -2,-8 l 4,8",Fork:"m 0,4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4",LineFork:"m 0,0 l 0,8 m 0,-4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardLineFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4 m 8,-8 l 0,8",CircleFork:"F1 m 6,4 b 0 360 -3 0 3 z m 0,0 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 6,0 b 0 360 -3 0 3",CircleLineFork:"F1 m 6,4 b 0 360 -3 0 3 z m 1,-4 l 0,8 m 0,-4 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleLineFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 0,-4 l 0,8 m 7,-4 b 0 360 -3 0 3",Circle:"F1 m 8,4 b 0 360 -4 0 4 z",Block:"F1 m 0,0 l 0,8 8,0 0,-8 z",StretchedDiamond:"F1 m 0,3 l 5,-3 5,3 -5,3 -5,-3 z",Diamond:"F1 m 0,4 l 4,-4 4,4 -4,4 -4,-4 z",Chevron:"F1 m 0,0 l 5,0 3,4 -3,4 -5,0 3,-4 -3,-4 z",StretchedChevron:"F1 m 0,0 l 8,0 3,4 -3,4 -8,0 3,-4 -3,-4 z",NormalArrow:"F1 m 0,2 l 4,0 0,-2 4,4 -4,4 0,-2 -4,0 z",X:"m 0,0 l 8,8 m 0,-8 l -8,8",TailedNormalArrow:"F1 m 0,0 l 2,0 1,2 3,0 0,-2 2,4 -2,4 0,-2 -3,0 -1,2 -2,0 1,-4 -1,-4 z",DoubleTriangle:"F1 m 0,0 l 4,4 -4,4 0,-8 z m 4,0 l 4,4 -4,4 0,-8 z",BigEndArrow:"F1 m 0,0 l 5,2 0,-2 3,4 -3,4 0,-2 -5,2 0,-8 z",ConcaveTailArrow:"F1 m 0,2 h 4 v -2 l 4,4 -4,4 v -2 h -4 l 2,-2 -2,-2 z",RoundedTriangle:"F1 m 0,1 a 1,1 0 0 1 1,-1 l 7,3 a 0.5,1 0 0 1 0,2 l -7,3 a 1,1 0 0 1 -1,-1 l 0,-6 z",SimpleArrow:"F1 m 1,2 l -1,-2 2,0 1,2 -1,2 -2,0 1,-2 5,0 0,-2 2,2 -2,2 0,-2 z",AccelerationArrow:"F1 m 0,0 l 0,8 0.2,0 0,-8 -0.2,0 z m 2,0 l 0,8 1,0 0,-8 -1,0 z m 3,0 l 2,0 2,4 -2,4 -2,0 0,-8 z",BoxArrow:"F1 m 0,0 l 4,0 0,2 2,0 0,-2 2,4 -2,4 0,-2 -2,0 0,2 -4,0 0,-8 z",TriangleLine:"F1 m 8,4 l -8,-4 0,8 8,-4 z m 0.5,4 l 0,-8",CircleEndedArrow:"F1 m 10,4 l -2,-3 0,2 -2,0 0,2 2,0 0,2 2,-3 z m -4,0 b 0 360 -3 0 3 z",DynamicWidthArrow:"F1 m 0,3 l 2,0 2,-1 2,-2 2,4 -2,4 -2,-2 -2,-1 -2,0 0,-2 z",EquilibriumArrow:"m 0,3 l 8,0 -3,-3 m 3,5 l -8,0 3,3",FastForward:"F1 m 0,0 l 3.5,4 0,-4 3.5,4 0,-4 1,0 0,8 -1,0 0,-4 -3.5,4 0,-4 -3.5,4 0,-8 z",Kite:"F1 m 0,4 l 2,-4 6,4 -6,4 -2,-4 z",HalfArrowTop:"F1 m 0,0 l 4,4 4,0 -8,-4 z m 0,8",HalfArrowBottom:"F1 m 0,8 l 4,-4 4,0 -8,4 z",OpposingDirectionDoubleArrow:"F1 m 0,4 l 2,-4 0,2 4,0 0,-2 2,4 -2,4 0,-2 -4,0 0,2 -2,-4 z",PartialDoubleTriangle:"F1 m 0,0 4,3 0,-3 4,4 -4,4 0,-3 -4,3 0,-8 z",LineCircle:"F1 m 0,0 l 0,8 m 7 -4 b 0 360 -3 0 3 z",DoubleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",TripleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",CircleLine:"F1 m 6 4 b 0 360 -3 0 3 z m 1,-4 l 0,8",DiamondCircle:"F1 m 8,4 l -4,4 -4,-4 4,-4 4,4 m 8,0 b 0 360 -4 0 4 z",PlusCircle:"F1 m 8,4 b 0 360 -4 0 4 l -8 0 z m -4 -4 l 0 8",OpenRightTriangleTop:"m 8,0 l 0,4 -8,0 m 0,4",OpenRightTriangleBottom:"m 8,8 l 0,-4 -8,0",Line:"m 0,0 l 0,8",DoubleLine:"m 0,0 l 0,8 m 2,0 l 0,-8",TripleLine:"m 0,0 l 0,8 m 2,0 l 0,-8 m 2,0 l 0,8",PentagonArrow:"F1 m 8,4 l -4,-4 -4,0 0,8 4,0 4,-4 z"};var LayoutConditions=(w=>(w[w.None=0]="None",w[w.Added=1]="Added",w[w.Removed=2]="Removed",w[w.Shown=4]="Shown",w[w.Hidden=8]="Hidden",w[w.NodeSized=16]="NodeSized",w[w.GroupLayout=32]="GroupLayout",w[w.NodeReplaced=64]="NodeReplaced",w[w.Standard=127]="Standard",w[w.All=16777215]="All",w))(LayoutConditions||{});class Part extends Panel{P;Ho;F;ll;hl;qo;hi;Wo;mh;js;Jo;Ld;UM;BA;Bp;Vp;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.P=2408959,this.Ho="",this.F=null,this.ll="",this.hl=null,this.qo=null,this.hi="",this.Wo=null,this.mh=null,this.js=new Point(NaN,NaN).g(),this.Jo=null,this.Ld=NaN,this.UM=-1,this.BA=new Rect,this.Bp=null,this.Vp=NaN,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.P=this.P&-4097|16384|32768,t.Ho=this.Ho,this.F!==null&&(this.F.gi?t.F=this.F:t.F=this.F.copy()),t.ll=this.ll,t.qo=null,t.hi=this.hi,t.js.a(this.js),t.Ld=this.Ld}Vo(t){super.Vo(t),t.ah(),t.hl=null,t.Jo=null,t.Bp=null}toString(){let t=Util.sn(this.constructor)+"#"+GSet.as(this);return this.data!==null&&(t+="("+Util.toString(this.data)+")"),t}static LayoutNone=0;static LayoutAdded=1;static LayoutRemoved=2;static LayoutShown=4;static LayoutHidden=8;static LayoutNodeSized=16;static LayoutGroupLayout=32;static LayoutNodeReplaced=64;static LayoutStandard=127;static LayoutAll=16777215;qi(){this.F===null?this.F=new PartTemplateSettings:this.F.gi&&(this.F=this.F.copy())}rh(){super.rh(),this.F!==null&&(this.F.gi=!0)}Wc(t,i,e,s,n,o,r){const l=this.diagram;l!==null&&(t===3&&i==="elements"?n instanceof Panel?n.qr(h=>{l.partManager.MS(h,l)}):n instanceof Picture&&l.TS(n):t===4&&i==="elements"&&(n instanceof Panel?n.qr(h=>l.partManager.SS(h,l)):n instanceof Picture&&l.DS(n)),l.raiseChangedEvent(t,i,e,s,n,o,r))}updateTargetBindings(t){if(super.updateTargetBindings(t),this.data===null)return;const i=this.L.r,e=i.length;for(let n=0;n{r.data!==null&&r.updateTargetBindings()})}const s=this.adornments;for(;s.next();)s.value.updateTargetBindings(t)}Io(){if(super.Io(),this.m2()){const i=this.L.r,e=i.length;for(let s=0;so.Io())}}const t=this.adornments;for(;t.next();)t.value.Io()}updateRelationshipsFromData(){this.data!==null&&this.diagram?.partManager.updateRelationshipsFromData(this)}get key(){const t=this.diagram;if(t!==null)return t.model.getKeyForNodeData(this.data)}get adornments(){return this.qo===null?EmptyIterator.instance:this.qo.iteratorValues}findAdornment(t){const i=this.qo;return i===null?null:i.get(t)}addAdornment(t,i){if(i===null)return;let e=null,s=this.qo;if(s!==null&&(e=s.get(t)),e!==i){if(e!==null){const o=e.diagram;o!==null&&o.remove(e)}s===null&&(s=new GMap,this.qo=s),i.Ho!==t&&(i.category=t),s.set(t,i);const n=this.diagram;if(n!==null){n.add(i);const o=i.adornedObject;if(o!==null){const r=o.findBindingPanel();r!==null&&(i.data=r.data)}}}}removeAdornment(t){const i=this.qo;if(i===null)return;const e=i.get(t);if(e!==null){const s=e.diagram;s!==null&&(s.remove(e),e.data=null)}i.delete(t),i.count===0&&(this.qo=null)}clearAdornments(){const t=this.qo;if(t===null)return;const i=Util.ot(),e=t.iterator;for(;e.next();){const n=e.key;i.push(n)}const s=i.length;for(let n=0;n{e.isEnabled&&e.updateAdornments(i)}),t.toolManager.updateAdornments(i)}IM(t){this.Wo=t,t===null&&this.FR()}get layer(){return this.Wo}get diagram(){const t=this.Wo;return t==null?null:t.diagram}get layerName(){return this.ll}set layerName(t){const i=this.ll;if(i===t)return;Util.i(t,"string",Part,"layerName");let e=this.diagram;if(e!==null&&(e.findLayer(t)===null||e.partManager.addsToTemporaryLayer))return;this.ll=t,e!==null&&e.invalidateDocumentBounds(),this.t("layerName",i,t);const s=this.layer;if(s===null||s.name===t||(e=s.diagram,e===null))return;const n=e.findLayer(t);if(n===null||n===s)return;let o=s._i(-1,this,!0);o>=0&&e.raiseChangedEvent(4,"parts",s,this,null,o,!0),o=n.Hh(99999999,this,!0),s.visible!==n.visible&&this.Ei(n.visible),o>=0&&e.raiseChangedEvent(3,"parts",n,null,this,!0,o);const r=this.layerChanged;if(r===null)return;const l=e.Y;e.Y=!0,r(this,s,n),e.Y=l}get layerChanged(){return this.F!==null?this.F.zp:null}set layerChanged(t){const i=this.layerChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"layerChanged"),this.qi(),this.F.zp=t,this.t("layerChanged",i,t))}get zOrder(){return this.Ld}set zOrder(t){const i=this.Ld;if(i===t)return;Util.i(t,"number",Part,"zOrder"),this.Ld=t;const e=this.layer;e!==null&&e.yx(-1,this),this.t("zOrder",i,t);const s=this.diagram;s!==null&&s.C()}Iv(){const t=this.layer;t!==null&&t.yx(-1,this)}o1(){if(this.th()!==!1)return;this.G2(!0),this.td();const t=this.diagram;t!==null&&(t.r0(this),t.requestUpdate())}XA(){if(this.P|=2097152,this.th()===!1)return;const t=this.position,i=this.location;(!i.isReal()||!t.isReal())&&this.KA(t,i);const e=this.Li,s=Rect.l().a(e);e.rt(),e.x=t.x,e.y=t.y,e.g(),this.ed(s,e),Rect.s(s),this.G2(!1)}Qn(t,i,e,s){const n=this.ee;n.e(t,i,e,s),this.bi===null&&(this.bi=new Transform);const o=this.bi;o.Ri(),this.y0(o,t,i,e,s),this.bi=o,o.Ok()||o.xw(n)}y0(t,i,e,s,n){if(this.st!==1&&t.st(this.st),this.Xt===0)return;let o=Spot.Center;this.locationSpot.isSpot()&&(o=this.locationSpot);const r=Point.l();if(this.locationObject!==this){const l=this.locationObject,h=l.naturalBounds;r.setSpot(h.x,h.y,h.width,h.height,o),l.bi!==null&&l.bi.xt(r),r.offset(-l.measuredBounds.x,-l.measuredBounds.y);let a=l.panel;for(;a!==null&&a!==this;)a.bi!==null&&a.bi.xt(r),r.offset(-a.measuredBounds.x,-a.measuredBounds.y),a=a.panel}else r.setSpot(i,e,s,n,o);t.cs(this.Xt,r.x,r.y),Point.s(r)}get locationObject(){if(this.Jo===null)if(this instanceof Adornment&&this.type!==Panel.Link&&this.hasPlaceholder())this.Jo=this.placeholder;else{const t=this.locationObjectName;if(t!==""){const i=this.findObject(t);i!==null?this.Jo=i:this.Jo=this}else this.Jo=this}return this.Jo.visible?this.Jo:this}get minLocation(){return this.F!==null?this.F.Xp:Point.QN}set minLocation(t){const i=this.minLocation;i.equals(t)||(t=t.N(),this.qi(),this.F.Xp=t,this.t("minLocation",i,t))}get maxLocation(){return this.F!==null?this.F.Kp:Point._N}set maxLocation(t){const i=this.maxLocation;i.equals(t)||(t=t.N(),this.qi(),this.F.Kp=t,this.t("maxLocation",i,t))}get locationObjectName(){return this.F!==null?this.F.Yp:""}set locationObjectName(t){const i=this.locationObjectName;i!==t&&(this.qi(),this.F.Yp=t,this.Jo=null,this.c(),this.t("locationObjectName",i,t))}get locationSpot(){return this.F!==null?this.F.Gp:Spot.TopLeft}set locationSpot(t){const i=this.locationSpot;i.equals(t)||(t=t.N(),this.qi(),this.F.Gp=t,this.c(),this.t("locationSpot",i,t))}move(t,i){i===!0?this.location=t:this.position=t}moveTo(t,i,e){const s=Point.X(t,i);this.move(s,e),Point.s(s)}isVisible(){if(!this.visible)return!1;const t=this.layer;if(t!==null){if(!t.visible)return!1;const e=t.diagram;if(e!==null&&e.animationManager.nx(this))return!0}const i=this.containingGroup;return!(i!==null&&(!i.isSubGraphExpanded||!i.isVisible()))}Ei(t){const i=this.diagram;t?(this.invalidateLayout(4),this.invalidateAdornments(),i!==null&&i.r0(this)):(this.invalidateLayout(8),this.clearAdornments()),this.ah(),i!==null&&(i.invalidateDocumentBounds(),i.C())}findObject(t){if(this.name===t)return this;let i=this.Bp;if(i===null&&(this.Bp=i=new GMap),i.get(t)!==null)return i.get(t);const e=super.findObject(t);return e!==null?(i.set(t,e),e):(i.set(t,null),null)}T0(){this.Bp=null}getRelativePoint(t,i,e){e===void 0&&(e=new Point);const s=i.isNoSpot()?Spot.Center:i,n=t.naturalBounds;if(e.e(n.width*s.x+s.offsetX,n.height*s.y+s.offsetY),t===null||t===this)return e;t.D.xt(e);let o=t.panel;for(;o!==null&&o!==this;)o.D.xt(e),o=o.panel;return this.bi!==null&&this.bi.xt(e),e.offset(-this.ee.x,-this.ee.y),e}getDocumentBounds(t){return t===void 0&&(t=new Rect),t.a(this.actualBounds)}ensureBounds(){this.ut(1/0,1/0),this.zt()}pA(t){const i=this.locationSpot,e=this.locationObject;let s=e.naturalBounds;s.isReal()||(s=Rect.pw);const n=e instanceof Shape?e.strokeWidth:0;if(t.setSpot(0,0,s.width+n,s.height+n,i),e!==this){t.offset(-n/2,-n/2),e.D.xt(t);let o=e.panel;for(;o!==null&&o!==this;)o.D.xt(t),o=o.panel}return this.bi!==null&&this.bi.xt(t),t.offset(-this.ee.x,-this.ee.y),t}jh(t,i){const e=i===void 0?this.BA:i,s=this.Ev(),n=s*2;if(!this.isShadowed)return e.e(t.x-1-s,t.y-1-s,t.width+2+n,t.height+2+n),e;let o=t.x,r=t.y,l=t.width,h=t.height;const a=this.shadowBlur,c=this.shadowOffset;return l+=a,h+=a,o-=a/2,r-=a/2,c.x>0?l+=c.x:(o+=c.x,l-=c.x),c.y>0?h+=c.y:(r+=c.y,h-=c.y),e.e(o-1,r-1,l+2,h+2),e}wv(){return this.type===Panel.Link&&this instanceof Adornment&&this.category==="Selection"&&this.adornedObject instanceof Shape&&this.adornedPart.findMainElement()===this.adornedObject?this.adornedObject.strokeWidth:0}Ev(){return isNaN(this.Vp)&&(this.Vp=this.MA()),this.Vp}af(){this.Vp=NaN}zt(){if(this.is()===!1){this.XA();return}this._n(!1);const t=this.Li,i=Rect.l();i.a(t);const e=this.Nl();this.hh(0,0,this.ee.width,this.ee.height);const s=this.position;this.KA(s,this.location),t.rt(),t.x=s.x,t.y=s.y,t.g(),this.ed(i,t),i.equals(t)?this.Us(e):this.Pe()&&(!Geo.u(i.width,t.width)||!Geo.u(i.height,t.height))&&this.UM>=0&&this.invalidateLayout(16),Rect.s(i),this.G2(!1)}ed(t,i){const e=this.diagram;if(e===null)return;let s=!1;if(e.$h===!1&&t.isReal()){const n=Rect.l();n.a(e.documentBounds),n.subtractMargin(e.padding),t.x>n.x&&t.y>n.y&&t.rightn.x&&i.y>n.y&&i.right=o)return}}this.P=this.P^4096;let s=!1;if(e!==null){s=e.skipsUndoManager,e.skipsUndoManager=!0;const o=e.selection;o.rt(),t?o.add(this):o.delete(this),o.g()}this.t("isSelected",i,t),this.invalidateAdornments();const n=this.selectionChanged;n!==null&&n(this),e!==null&&(e.requestUpdate(),e.skipsUndoManager=s)}}get isHighlighted(){return(this.P&524288)!==0}set isHighlighted(t){const i=(this.P&524288)!==0;if(i!==t){this.P=this.P^524288;const e=this.diagram;if(e!==null){const n=e.highlighteds;n.rt(),t?n.add(this):n.delete(this),n.g()}this.t("isHighlighted",i,t),this.C();const s=this.highlightedChanged;s!==null&&s(this)}}get isShadowed(){return(this.P&8192)!==0}set isShadowed(t){const i=(this.P&8192)!==0;i!==t&&(this.P=this.P^8192,this.ss(!0),this.t("isShadowed",i,t),this.C())}VA(){return(this.P&16384)!==0}zA(t){t?this.P|=16384:this.P&=-16385}th(){return(this.P&32768)!==0}G2(t){t?this.P|=32768:this.P&=-32769}Uv(){return(this.P&65536)!==0}o2(t){t?this.P|=65536:this.P&=-65537}Nl(){return(this.P&131072)!==0}Us(t){t?this.P|=131072:this.P&=-131073}qA(){return(this.P&1048576)!==0}l1(t){t?this.P|=1048576:this.P&=-1048577}get isAnimated(){return(this.P&262144)!==0}set isAnimated(t){const i=(this.P&262144)!==0;i!==t&&(this.P=this.P^262144,this.t("isAnimated",i,t))}get highlightedChanged(){return this.F!==null?this.F.jp:null}set highlightedChanged(t){const i=this.highlightedChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"highlightedChanged"),this.qi(),this.F.jp=t,this.t("highlightedChanged",i,t))}get selectionObjectName(){return this.F!==null?this.F.Hp:""}set selectionObjectName(t){const i=this.selectionObjectName;i!==t&&(this.qi(),this.F.Hp=t,this.hl=null,this.t("selectionObjectName",i,t))}get selectionAdornmentTemplate(){return this.F!==null?this.F.qp:null}set selectionAdornmentTemplate(t){const i=this.selectionAdornmentTemplate;i!==t&&(this.qi(),this.F.qp=t,this.t("selectionAdornmentTemplate",i,t))}get selectionObject(){if(this.hl===null){const t=this.selectionObjectName;if(t!==null&&t!==""){const i=this.findObject(t);i!==null?this.hl=i:this.hl=this}else if(this instanceof Link){const i=this.path;i!==null?this.hl=i:this.hl=this}else this.hl=this}return this.hl}get selectionChanged(){return this.F!==null?this.F.Wp:null}set selectionChanged(t){const i=this.selectionChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"selectionChanged"),this.qi(),this.F.Wp=t,this.t("selectionChanged",i,t))}get resizeAdornmentTemplate(){return this.F!==null?this.F.Jp:null}set resizeAdornmentTemplate(t){const i=this.resizeAdornmentTemplate;i!==t&&(this.qi(),this.F.Jp=t,this.t("resizeAdornmentTemplate",i,t))}get resizeObjectName(){return this.F!==null?this.F.$p:""}set resizeObjectName(t){const i=this.resizeObjectName;i!==t&&(this.qi(),this.F.$p=t,this.t("resizeObjectName",i,t))}get resizeObject(){const t=this.resizeObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get resizeCellSize(){return this.F!==null?this.F.Zp:Size.gw}set resizeCellSize(t){const i=this.resizeCellSize;i.equals(t)||(t=t.N(),this.qi(),this.F.Zp=t,this.t("resizeCellSize",i,t))}get rotateAdornmentTemplate(){return this.F!==null?this.F.Qp:null}set rotateAdornmentTemplate(t){const i=this.rotateAdornmentTemplate;i!==t&&(this.qi(),this.F.Qp=t,this.t("rotateAdornmentTemplate",i,t))}get rotateObjectName(){return this.F!==null?this.F._p:""}set rotateObjectName(t){const i=this.rotateObjectName;i!==t&&(this.qi(),this.F._p=t,this.t("rotateObjectName",i,t))}get rotateObject(){const t=this.rotateObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get rotationSpot(){return this.F!==null?this.F.ty:Spot.Default}set rotationSpot(t){const i=this.rotationSpot;i.equals(t)||(t=t.N(),this.qi(),this.F.ty=t,this.t("rotationSpot",i,t))}get text(){return this.hi}set text(t){const i=this.hi;i!==t&&(this.hi=t,this.t("text",i,t))}get containingGroup(){return this.mh}set containingGroup(t){if(this.Pe()){const i=this.mh;if(i!==t){t!==null&&(this===t||t.isMemberOf(this))&&(this===t&&Util.o("Cannot make a Group a member of itself: "+this.toString()),Util.o("Cannot make a Group indirectly contain itself: "+this.toString()+" already contains "+t.toString())),this.invalidateLayout(2);const e=this.diagram;if(i!==null?i.H2(this):this instanceof Group&&e!==null&&e.Yr.delete(this),this.mh=t,t!==null?t.q2(this):this instanceof Group&&e!==null&&e.Yr.add(this),this.invalidateLayout(1),e!==null&&e.Y){const n=this.data,o=e.model;if(n!==null&&o.Hc()){const r=t!==null?t.data:null;o.setGroupForData(n,o.getKeyForNodeData(r))}}const s=this.containingGroupChanged;if(s!==null){let n=!0;e!==null&&(n=e.Y,e.Y=!0),s(this,i,t),e!==null&&(e.Y=n)}if(this instanceof Group){const n=new GSet;Part.sh(n,this,!0,0,!0);const o=n.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=r.linksConnected;for(;l.next();)l.value.Ad()}}}if(this instanceof Node){const n=this.linksConnected;for(;n.next();)n.value.Ad();const o=this.labeledLink;o!==null&&o.Ad()}this.t("containingGroup",i,t),t!==null&&t.Iv()}}else Util.o("cannot set the Part.containingGroup of a Link or Adornment")}ah(){const t=this.containingGroup;t!==null&&(t.hasPlaceholder()&&t.placeholder.c(),t.c(),t.invalidateConnectedLinks())}C(){const t=this.diagram;t!==null&&!this.is()&&!this.th()&&this.isVisible()&&this.Li.isReal()&&t.C(this.jh(this.Li))}c(){if(this.Oo())return;super.c();const t=this.diagram;t!==null&&(t.r0(this),this instanceof Node&&this.labeledLink!==null&&this.labeledLink.tf(),t.requestUpdate(!0))}tf(t){if(this.is())return;const i=this.diagram;i!==null&&(i.r0(this),this instanceof Node&&this.invalidateConnectedLinks(),i.requestUpdate()),this._n(!0)}Um(t){if(!t){const i=this.mh;i!==null&&i.q2(this)}}Bm(t){if(!t){const i=this.mh;i!==null&&i.H2(this)}}Xc(){const t=this.data;if(t!==null){const i=this.diagram;if(i!==null){const e=i.model;e!==null&&e.removeNodeData(t)}}}get containingGroupChanged(){return this.F!==null?this.F.iy:null}set containingGroupChanged(t){const i=this.containingGroupChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"containingGroupChanged"),this.qi(),this.F.iy=t,this.t("containingGroupChanged",i,t))}findSubGraphLevel(){return this.W2(this)}W2(t){const i=t.containingGroup;if(i!==null)return 1+this.W2(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.W2(e)}return 0}findTopLevelPart(){return this.J2(this)}J2(t){const i=t.containingGroup;if(i!==null)return this.J2(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.J2(e)}return t}get isTopLevel(){return!(this.containingGroup!==null||this instanceof Node&&this.labeledLink!==null)}isMemberOf(t){return t instanceof Group?this.$2(this,t):!1}$2(t,i){if(t===i||i===null)return!1;const e=t.containingGroup;if(e!==null&&(e===i||this.$2(e,i)))return!0;if(t instanceof Node){const s=t.labeledLink;if(s!==null)return this.$2(s,i)}return!1}findCommonContainingGroup(t){if(t===null)return null;if(this===t)return this.containingGroup;let i=this;for(;i!==null;){if(i instanceof Group&&i.l1(!0),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}let e=null;for(i=t;i!==null;){if(i.qA()){e=i;break}if(i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}for(i=this;i!==null;){if(i instanceof Group&&i.l1(!1),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}return e}get layoutConditions(){return this.F!==null?this.F.ey:127}set layoutConditions(t){const i=this.layoutConditions;i!==t&&(this.qi(),this.F.ey=t,this.t("layoutConditions",i,t))}canLayout(){if(!this.isLayoutPositioned||!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary||this instanceof Node&&this.isLinkLabel)}Vv(t){if(!this.isLayoutPositioned||!(t&this.layoutConditions))return!1;const i=this.layer;if(i!==null&&i.isTemporary||this instanceof Node&&this.isLinkLabel)return!1;const e=this.diagram;return!(e!==null&&e.undoManager.isUndoingRedoing)}invalidateLayout(t){if(t===void 0&&(t=16777215),!this.Vv(t))return;const i=this.mh;if(i!==null){const e=i.layout;e!==null?e.invalidateLayout():i.invalidateLayout(t)}else{const e=this.diagram;if(e!==null){const s=e.layout;s!==null&&s.invalidateLayout()}}}CL(){if(!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary)}static sh(t,i,e,s,n,o){if(o===void 0&&(o=null),!t.has(i)&&!(o!==null&&!o(i))&&!(i instanceof Adornment)){if(t.add(i),i instanceof Node){if(e&&i instanceof Group){const r=i.memberParts;for(;r.next();){const l=r.value;Part.sh(t,l,e,s,n,o)}}if(n!==!1){const r=i.linksConnected;for(;r.next();){const l=r.value;if(t.has(l))continue;const h=l.fromNode,a=l.toNode,c=h===null||t.has(h),f=a===null||t.has(a);(n?c&&f:c||f)&&Part.sh(t,l,e,s,n,o)}}if(s>1){const r=i.findTreeChildrenNodes();for(;r.next();){const l=r.value;Part.sh(t,l,e,s-1,n,o)}}}else if(i instanceof Link){const r=i.labelNodes;for(;r.next();){const l=r.value;Part.sh(t,l,e,s,n,o)}}}}get dragComputation(){return this.F!==null?this.F.sy:null}set dragComputation(t){const i=this.dragComputation;i!==t&&(t!==null&&Util.i(t,"function",Part,"dragComputation"),this.qi(),this.F.sy=t,this.t("dragComputation",i,t))}get shadowOffset(){return this.F!==null?this.F.ny:Point.tC}set shadowOffset(t){const i=this.shadowOffset;i.equals(t)||(t=t.N(),this.qi(),this.F.ny=t,this.C(),this.t("shadowOffset",i,t))}get shadowColor(){return this.F!==null?this.F.oy:"gray"}set shadowColor(t){const i=this.shadowColor;i!==t&&(this.qi(),this.F.oy=t,this.C(),this.t("shadowColor",i,t))}get shadowBlur(){return this.F!==null?this.F.xn:4}set shadowBlur(t){const i=this.shadowBlur;i!==t&&(this.qi(),this.F.xn=t,this.C(),this.t("shadowBlur",i,t))}}class PartTemplateSettings{gi;zp;iy;qp;Hp;Wp;jp;Jp;$p;Zp;Qp;_p;ty;Yp;Gp;Xp;Kp;sy;ey;ny;oy;xn;constructor(){this.gi=!1,this.zp=null,this.iy=null,this.qp=null,this.Hp="",this.Wp=null,this.jp=null,this.Jp=null,this.$p="",this.Zp=Size.gw,this.Qp=null,this._p="",this.ty=Spot.Default,this.Yp="",this.Gp=Spot.TopLeft,this.Xp=Point.QN,this.Kp=Point._N,this.sy=null,this.ey=127,this.ny=Point.tC,this.oy="gray",this.xn=4}copy(){const t=new PartTemplateSettings;return t.zp=this.zp,t.iy=this.iy,t.qp=this.qp,t.Hp=this.Hp,t.Wp=this.Wp,t.jp=this.jp,t.Jp=this.Jp,t.$p=this.$p,t.Zp=this.Zp.N(),t.Qp=this.Qp,t._p=this._p,t.ty=this.ty.N(),t.Yp=this.Yp,t.Gp=this.Gp.N(),t.Xp=this.Xp.N(),t.Kp=this.Kp.N(),t.sy=this.sy,t.ey=this.ey,t.ny=this.ny.N(),t.oy=this.oy,t.xn=this.xn,t}}class Adornment extends Part{us;It;JP;$P;lf;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.P&=-257,this.ll="Adornment",this.us=null,this.JP=0,this.$P=!1,this.It=null,this.lf=null,i&&Object.assign(this,i)}toString(){const t=this.adornedPart;return"Adornment("+this.category+")"+(t!==null?t.toString():"")}updateRelationshipsFromData(){}ad(t){const i=this.adornedObject,e=i?.part;if(!(e instanceof Link)||!(i instanceof Shape))return;const s=e.path;let n=s.geometry;e.ad(t),n=s.geometry;const o=this.L.r,r=o.length;for(let l=0;lh instanceof Placeholder);l instanceof Placeholder&&this.It===null&&(this.It=l)}}else t===4&&i==="elements"&&this.It!==null&&(s===this.It?this.It=null:s instanceof Panel&&this.It.isContainedBy(s)&&(this.It=null));super.Wc(t,i,e,s,n,o,r)}updateAdornments(){}Xc(){}}var PortSpreading=(w=>(w[w.None=0]="None",w[w.Evenly=1]="Evenly",w[w.Packed=2]="Packed",w))(PortSpreading||{});class Node extends Part{E;gt;bf;al;ph;se;_t;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.E=13,this.gt=null,this._t=new List,this.bf=null,this.al=null,this.se=null,this.ph=!1,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.E=this.E,this.gt!==null&&(this.gt.gi?t.gt=this.gt:t.gt=this.gt.copy())}Vo(t){super.Vo(t),t.invalidateConnectedLinks(),t.al=this.al,t.se=null}static SpreadingNone=0;static SpreadingEvenly=1;static SpreadingPacked=2;cl(){this.gt===null?this.gt=new NodeTemplateSettings:this.gt.gi&&(this.gt=this.gt.copy())}rh(){super.rh(),this.gt!==null&&(this.gt.gi=!0)}WA(t){t!==null&&(this.al===null&&(this.al=new GSet),this.al.add(t))}JA(t){t!==null&&this.al!==null&&this.al.delete(t)}$A(t,i,e){if(t===null||this.al===null)return null;const s=this.al.iterator;for(;s.next();){const n=s.value;if(n.ry===this&&n.h1===t&&n.Z2===i&&n.Q2===e||n.ry===t&&n.h1===this&&n.Z2===e&&n.Q2===i)return n}return null}invalidateLinkBundle(t,i,e){i==null&&(i=""),e==null&&(e="");const s=this.$A(t,i,e);s!==null&&s.Td()}Wc(t,i,e,s,n,o,r){t===3&&i==="elements"?this.se=null:t===4&&i==="elements"&&(this.se=null),super.Wc(t,i,e,s,n,o,r)}invalidateConnectedLinks(t){const i=this.linksConnected;for(;i.next();){const e=i.value;t!==void 0&&t.has(e)||(this.ge(e.fromPort),this.ge(e.toPort),e.invalidateRoute())}}iA(t){const i=this.linksConnected;for(;i.next();){const e=i.value;e.fromPort!==t&&e.toPort!==t||(this.ge(e.fromPort),this.ge(e.toPort),e.invalidateRoute())}}ge(t){if(t===null)return;const i=t.$u;i!==null&&i.Td();const e=t.part,s=e.containingGroup;s!==null&&!e.isVisible()&&s.ge(s.port)}Hr(){return!0}get portSpreading(){return this.gt!==null?this.gt.ly:1}set portSpreading(t){const i=this.portSpreading;if(i!==t){this.cl(),this.gt.ly=t,this.t("portSpreading",i,t);const e=this.diagram;if(e!==null&&e.undoManager.isUndoingRedoing)return;this.invalidateConnectedLinks()}}get avoidable(){return(this.E&8)!==0}set avoidable(t){const i=(this.E&8)!==0;if(i!==t){this.E=this.E^8;const e=this.diagram;e!==null&&e.ES(this),this.t("avoidable",i,t)}}get avoidableMargin(){return this.gt!==null?this.gt.hy:Margin.lC}set avoidableMargin(t){typeof t=="number"&&(t=new Margin(t));const i=this.avoidableMargin;if(!i.equals(t)){t=t.N(),this.cl(),this.gt.hy=t;const e=this.diagram;e!==null&&e.ES(this),this.t("avoidableMargin",i,t)}}canAvoid(){return this.avoidable&&!this.isLinkLabel}getAvoidableRect(t){return t.set(this.actualBounds),t.addMargin(this.avoidableMargin),t}findVisibleNode(){let t=this;for(;t!==null&&!t.isVisible();)t=t.containingGroup;return t}isVisible(){if(!super.isVisible())return!1;let t=!0,i=1;const e=this.diagram;if(e!==null){if(e.animationManager.nx(this))return!0;t=e.isTreePathToChildren,i=e.treeCollapsePolicy}if(i===1){const n=this.findTreeParentNode();if(n!==null&&!n.isTreeExpanded)return!1}else if(i===2){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&h.isTreeExpanded){r=!0;break}}}if(o&&!r)return!1}else if(i===3){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&!h.isTreeExpanded){r=!0;break}}}if(o&&r)return!1}const s=this.labeledLink;return s!==null?s.isVisible():!0}Ei(t){super.Ei(t);const i=this.linksConnected;for(;i.next();){const e=i.value;if(t&&this.containingGroup!==null){const s=e.getOtherNode(this);s!==null&&!s.isMemberOf(this.containingGroup)&&e.invalidateRoute()}e.Ei(t)}}get linksConnected(){return this._t.iterator}findExternalTreeLinksConnected(){const t=new GSet,i=new GSet;return this.ZA(this,t,i),i.iterator}ZA(t,i,e){if(t===null||i.has(t))return;i.add(t);let s=!0;const n=this.diagram;n!==null&&(s=n.isTreePathToChildren),t.linksConnected.each(o=>{o.isTreeLink?(s?o.fromNode===t:o.toNode===t)&&this.ZA(s?o.toNode:o.fromNode,i,e):e.add(o)})}findLinksConnected(t){if(t===void 0&&(t=null),t===null)return this._t.iterator;const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.fromNode===e&&s.fromPortId===t||s.toNode===e&&s.toPortId===t,i}findLinksOutOf(t){t===void 0&&(t=null);const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.fromNode!==e?!1:t===null?!0:s.fromPortId===t,i}findLinksInto(t){t===void 0&&(t=null);const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.toNode!==e?!1:t===null?!0:s.toPortId===t,i}findNodesConnected(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this){if(t===null||n.fromPortId===t){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}else if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesOutOf(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this&&(t===null||n.fromPortId===t)){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesInto(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findLinksBetween(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null);const s=new ListIterator(this._t),n=this;return s.predicate=o=>o.fromNode===n&&o.toNode===t&&(i===null||o.fromPortId===i)&&(e===null||o.toPortId===e)||o.fromNode===t&&o.toNode===n&&(e===null||o.fromPortId===e)&&(i===null||o.toPortId===i),s}findLinksTo(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null);const s=new ListIterator(this._t),n=this;return s.predicate=o=>!(o.fromNode!==n||o.toNode!==t||i!==null&&o.fromPortId!==i||e!==null&&o.toPortId!==e),s}get linkConnected(){return this.gt!==null?this.gt.ay:null}set linkConnected(t){const i=this.linkConnected;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkConnected"),this.cl(),this.gt.ay=t,this.t("linkConnected",i,t))}get linkDisconnected(){return this.gt!==null?this.gt.cy:null}set linkDisconnected(t){const i=this.linkDisconnected;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkDisconnected"),this.cl(),this.gt.cy=t,this.t("linkDisconnected",i,t))}get linkValidation(){return this.gt!==null?this.gt.Sl:null}set linkValidation(t){const i=this.linkValidation;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkValidation"),this.cl(),this.gt.Sl=t,this.t("linkValidation",i,t))}a1(t,i){this.ge(i);const e=this._t.has(t);if(e||this._t.add(t),!e||t.fromNode===t.toNode){const s=this.linkConnected;if(s!==null){let n=!0;const o=this.diagram;o!==null&&(n=o.Y,o.Y=!0),s(this,t,i),o!==null&&(o.Y=n)}}if(!e){if(!t.isTreeLink)return;const s=t.fromNode,n=t.toNode;if(s!==null&&n!==null&&s!==n){let o=!0;const r=this.diagram;r!==null&&(o=r.isTreePathToChildren);const l=o?n:s,h=o?s:n;if(l.ph||(l.ph=h),h.isTreeLeaf){if(r!==null&&r.undoManager.isUndoingRedoing)return;o?s===h&&(h.isTreeLeaf=!1):n===h&&(h.isTreeLeaf=!1)}}}}c1(t,i){this.ge(i);const e=this._t.delete(t);let s=null;if(e||t.toNode===t.fromNode){const n=this.linkDisconnected;if(s=this.diagram,n!==null){let o=!0;s!==null&&(o=s.Y,s.Y=!0),n(this,t,i),s!==null&&(s.Y=o)}}if(e){if(!t.isTreeLink)return;let n=!0;s!==null&&(n=s.isTreePathToChildren);const o=n?t.toNode:t.fromNode,r=n?t.fromNode:t.toNode;if(o!==null&&(o.ph=!1),r!==null&&!r.isTreeLeaf)if(r._t.count===0){if(r.ph=null,s!==null&&s.undoManager.isUndoingRedoing)return;r.isTreeLeaf=!0}else r.u0()}}u0(){if(this.ph=!1,this._t.count===0)return;let t=!0;const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;i!==null&&(t=i.isTreePathToChildren);const e=this._t.iterator;for(;e.next();){const s=e.value;if(s.isTreeLink){if(t){if(s.fromNode===this){this.isTreeLeaf=!1;return}}else if(s.toNode===this){this.isTreeLeaf=!1;return}}}this.isTreeLeaf=!0}updateRelationshipsFromData(){const t=this.diagram;t!==null&&t.partManager.updateRelationshipsFromData(this)}Um(t){if(super.Um(t),!t){this.u0();const i=this.bf;i!==null&&i.QA(this)}}Bm(t){if(super.Bm(t),!t){const i=this.bf;i!==null&&i._A(this)}}Xc(){if(this._t.count>0){const t=this.diagram;if(t!==null){const i=t.commandHandler!==null?t.commandHandler.deletesConnectedLinks:!0,s=this._t.copy().iterator;for(;s.next();){const n=s.value;i?t.remove(n):(n.fromNode===this&&(n.fromNode=null),n.toNode===this&&(n.toNode=null))}}}this.labeledLink=null,super.Xc()}get isLinkLabel(){return this.bf!==null}get labeledLink(){return this.bf}set labeledLink(t){const i=this.bf;if(i!==t){const e=this.diagram,s=this.data;if(i!==null){if(i._A(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=i.data,o=e.model;if(n!==null&&o.Aa()){const r=o.getKeyForNodeData(s);r!==void 0&&o.removeLabelKeyForLinkData(n,r)}}this.containingGroup=null}if(this.bf=t,t!==null){if(t.QA(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=t.data,o=e.model;if(n!==null&&o.Aa()){const r=o.getKeyForNodeData(s);r!==void 0&&o.addLabelKeyForLinkData(n,r)}}this.containingGroup=t.containingGroup}this.tf(),this.t("labeledLink",i,t)}}findVisiblePort(t){let i=t;for(;i!==null&&(!i.actualBounds.isReal()||!i.isVisibleObject());)i=i.panel;return i===null?this.port:i}findPort(t){if(this.se===null){if(t===""&&this.wn===!1)return this;this.tT()}let i=this.se.get(t);return i!==null||t!==""&&(i=this.se.get(""),i!==null)?i:this}get port(){return this.findPort("")}get ports(){return this.se===null&&this.tT(),this.se.iteratorValues}tT(){this.se===null?this.se=new GMap:this.se.clear(),this.walkVisualTreeFrom(this,(t,i)=>t.aA(i)),this.se.count===0&&this.se.set("",this)}aA(t){const i=t.portId;i!==null&&this.se!==null&&this.se.set(i,t)}g2(t,i){const e=t.portId;if(e!==null){this.se!==null&&this.se.delete(e);const s=this.diagram;if(s!==null&&i){let n=null;const o=this.findLinksConnected(e);for(;o.next();){const r=o.value;n===null&&(n=Util.ot()),n.push(r)}if(n!==null){for(let r=0;r!(!n.isTreeLink||n.fromNode!==s):e.predicate=n=>!(!n.isTreeLink||n.toNode!==s),e}findTreeChildrenNodes(){let t=!0;const i=this.diagram;i!==null&&(t=i.isTreePathToChildren);let e=null,s=null;const n=this._t.iterator;if(t)for(;n.next();){const o=n.value;if(o.isTreeLink&&o.fromNode===this){const r=o.toNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}else for(;n.next();){const o=n.value;if(o.isTreeLink&&o.toNode===this){const r=o.fromNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}return e!==null?e.iterator:s!==null?new SingletonIterator(s):EmptyIterator.instance}findTreeParts(t){t===void 0&&(t=1/0),Util.i(t,"number",Node,"findTreeParts:level");const i=new GSet;return Part.sh(i,this,!1,t,!0),i}collapseTree(t){t===void 0&&(t=1),t<1&&(t=1);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.iT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}iT(t,i,e,s,n,o){if(e>1){const r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);h!==null&&h!==this&&!t.has(h)&&(t.add(h),h.iT(t,i,e-1,s,n,o))}}else this.eT(t,i,s,n,o)}eT(t,i,e,s,n){const o=s===this?!0:this.isTreeExpanded,r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);if(h!==null&&h!==this){const a=t.has(h);if(a||t.add(h),o){const c=i?h.findNodesInto():h.findNodesOutOf(),f=this;c.all(u=>u===f||!u.isTreeExpanded)&&e.Cc(h,s),h.ah(),h.Ei(!1)}h.isTreeExpanded&&(h.wasTreeExpanded=h.isTreeExpanded,a||h.eT(t,i,e,s,n))}}this.isTreeExpanded=!1}expandTree(t){t===void 0&&(t=2),t<2&&(t=2);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.sT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}sT(t,i,e,s,n,o){const r=n===this?!1:this.isTreeExpanded,l=i?this.findLinksOutOf():this.findLinksInto();for(;l.next();){const h=l.value;if(!h.isTreeLink)continue;r||h.Se||h.invalidateRoute();const a=h.getOtherNode(this);if(a!==null&&a!==this&&!t.has(a)){if(t.add(a),!r){a.Ei(!0),a.ah();const c=i?a.findNodesInto():a.findNodesOutOf(),f=this;c.all(u=>u===f||!u.isTreeExpanded)&&s.Nc(a,n)}(e>2||a.wasTreeExpanded)&&(a.wasTreeExpanded=!1,a.sT(t,i,e-1,s,n,o))}}this.isTreeExpanded=!0}get isTreeExpanded(){return(this.E&1)!==0}set isTreeExpanded(t){const i=(this.E&1)!==0;if(i!==t){this.E=this.E^1;const e=this.diagram;this.t("isTreeExpanded",i,t);const s=this.treeExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.Y,e.Y=!0),s(this),e!==null&&(e.Y=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.Ei(t);return}t?this.expandTree():this.collapseTree()}}get wasTreeExpanded(){return(this.E&2)!==0}set wasTreeExpanded(t){const i=(this.E&2)!==0;i!==t&&(this.E=this.E^2,this.t("wasTreeExpanded",i,t))}get treeExpandedChanged(){return this.gt!==null?this.gt.fy:null}set treeExpandedChanged(t){const i=this.treeExpandedChanged;i!==t&&(t!==null&&Util.i(t,"function",Node,"treeExpandedChanged"),this.cl(),this.gt.fy=t,this.t("treeExpandedChanged",i,t))}get isTreeLeaf(){return(this.E&4)!==0}set isTreeLeaf(t){const i=(this.E&4)!==0;i!==t&&(this.E=this.E^4,this.t("isTreeLeaf",i,t))}get isTreeRoot(){return this.findTreeParentLink()===null}}class NodeTemplateSettings{gi;ay;cy;Sl;fy;hy;ly;uy;gy;eh;my;constructor(){this.gi=!1,this.ay=null,this.cy=null,this.Sl=null,this.fy=null,this.hy=Margin.lC,this.ly=1,this.uy=null,this.gy=null,this.eh=null,this.my=null}copy(){const t=new NodeTemplateSettings;return t.ay=this.ay,t.cy=this.cy,t.Sl=this.Sl,t.fy=this.fy,t.hy=this.hy.N(),t.ly=this.ly,t.uy=this.uy,t.gy=this.gy,t.eh=this.eh,t.my=this.my,t}}var LinkAdjusting=(w=>(w[w.None=0]="None",w[w.End=17]="End",w[w.Scale=18]="Scale",w[w.Stretch=19]="Stretch",w))(LinkAdjusting||{}),Routing=(w=>(w[w.Normal=1]="Normal",w[w.Orthogonal=2]="Orthogonal",w[w.AvoidsNodes=6]="AvoidsNodes",w[w.AvoidsNodesStraight=7]="AvoidsNodesStraight",w))(Routing||{}),Curve=(w=>(w[w.None=0]="None",w[w.Bezier=9]="Bezier",w[w.JumpGap=10]="JumpGap",w[w.JumpOver=11]="JumpOver",w))(Curve||{});class Link extends Part{Nt;lo;ho;Dd;ao;co;Fd;kf;Rd;vd;Od;Ta;Id;Hs;ki;fl;Mr;Pf;$o;_2;tN;f1;iN;eN;py;u1;ft;Zo;static Da=null;static Fa=null;lf;sN;nN;constructor(t){super(Panel.Link),this.Nt=8,this.lo=null,this.ho="",this.Dd=null,this.ao=null,this.co="",this.Fd=null,this.kf=0,this.Rd=0,this.vd=0,this.Od=NaN,this.Ta=1,this.Id=.5,this.Hs=null,this.ki=new List().g(),this.fl=null,this.Mr=null,this.Pf=new Rect,this.ft=new Geometry,this.$o=null,this.Zo=null,this._2=null,this.tN=null,this.sN=0,this.nN=0,this.f1=new Point,this.iN=null,this.eN=null,this.py=null,this.u1=NaN,this.q=null,this.lf=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Nt=this.Nt&-113,t.ho=this.ho,t.Dd=this.Dd,t.co=this.co,t.Fd=this.Fd,t.kf=this.kf,t.Rd=this.Rd,t.vd=this.vd,t.Od=this.Od,t.Ta=this.Ta,t.Id=this.Id,this.q!==null&&(t.q=this.q.copy())}Vo(t){super.Vo(t),this.ho=t.ho,this.co=t.co,t.fl=null,t.invalidateRoute(),t.Zo=this.Zo;const i=t.fromPort;i!==null&&t.fromNode.ge(i);const e=t.toPort;e!==null&&t.toNode.ge(e)}ri(t){t in Routing||t in Curve||t in LinkAdjusting?Link.oN(t)?this.routing=t:t===9||t===10||t===11?this.curve=t:t===17||t===18||t===19?this.adjusting=t:t===1||t===0||Util.o("Unknown Link enum value for a Link property: "+t):super.ri(t)}static Normal=1;static Orthogonal=2;static AvoidsNodes=6;static AvoidsNodesStraight=7;static None=0;static Bezier=9;static JumpGap=10;static JumpOver=11;static End=17;static Scale=18;static Stretch=19;static OrientAlong=21;static OrientPlus90=22;static OrientMinus90=23;static OrientOpposite=24;static OrientUpright=25;static OrientPlus90Upright=26;static OrientMinus90Upright=27;static OrientUpright45=28;static Xv=8;static Kv=16;static Yv=14;static Ra=8;Xe(){this.q===null&&(this.q=new LinkSettings)}_R(t,i,e){const s=t.segmentIndex,n=t.segmentFraction;let o=t.alignmentFocus;const r=t.segmentOrientation,l=t.segmentOffset;let h=0,a=0,c=0,f=0;if(isNaN(s)){const C=this.ft,S=Util.ot();C.getPointAndAngleAlongPath(n,S);const N=Point.X(S[0],S[1]);if(N.add(this.getPoint(0)),C.type===1)N.offset(-C.startX,-C.startY);else{const T=C.figures.first();N.offset(-T.startX,-T.startY)}f=S[2],r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=N.x,a=N.y,Point.s(N),Util.tt(S)}else if(s<-i||s>=i){const C=Point.l();this.mA(C),f=this.midAngle,r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=C.x,a=C.y,Point.s(C)}else{let C,S,N=0;if(s>=0?(C=e.r[s],S=s0?e.r[N-1]:C),C.equalsApprox(S)){let T,A;s>=0?(T=s>0?e.r[s-1]:C,A=s1?e.r[N-2]:S);const D=T.distanceSquaredPoint(C),F=S.distanceSquaredPoint(A);D>F+10?f=s>=0?T.directionPoint(C):C.directionPoint(T):F>D+10?f=s>=0?S.directionPoint(A):A.directionPoint(S):f=s>=0?T.directionPoint(A):A.directionPoint(T)}else f=s>=0?C.directionPoint(S):S.directionPoint(C);r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=C.x+(S.x-C.x)*n,a=C.y+(S.y-C.y)*n}if(o.isNone()){t.location=new Point(h,a);return}else o.isNoSpot()&&(o=Spot.Center);const u=Transform.l();u.Ri(),u.st(t.scale,t.scale),u.cs(t.angle,0,0);const d=t.naturalBounds,m=Rect.X(0,0,d.width,d.height),g=Point.l();g.setRectSpot(m,o),u.xt(g);let p=-g.x,y=-g.y;const x=d.width,k=d.height,b=Point.l();b.a(l);const P=isNaN(l.x),M=isNaN(l.y);if(P||M){const C=x/2+3,S=k/2+3,N=f>=45&&f<=135,T=f>=225&&f<=315;r===0&&(N||T)?(b.x=M?C:l.y,b.y=P?S:l.x,N?s>=0||isNaN(s)&&n<.5||P&&(b.y=-S):T&&((s>=0||isNaN(s)&&n<.5)&&P&&(b.y=-S),M&&(b.x=-C))):(P&&(s>=0||isNaN(s)&&n<.5?b.x=C:b.x=-C),M&&(b.y=-S),b.rotate(f))}else b.rotate(f);h+=b.x,a+=b.y,u.xw(m),p+=m.x,y+=m.y;const L=Point.X(h+p,a+y);t.move(L),Point.s(L),Point.s(b),Point.s(g),Rect.s(m),Transform.s(u)}Hr(){let t=this.fromNode;if(t!==null){const e=t.findVisibleNode();if(e!==null&&(t=e),t.is()||t.th())return!1}let i=this.toNode;if(i!==null){const e=i.findVisibleNode();if(e!==null&&(i=e),i.is()||i.th())return!1}return!0}u2(t,i,e){return!1}d2(){}Pe(){return!1}computeAngle(t,i,e){return Link.computeAngle(i,e)}static computeAngle(t,i){let e=0;switch(t){default:case 0:e=0;break;case 21:e=i;break;case 22:e=i+90;break;case 23:e=i-90;break;case 24:e=i+180;break;case 25:e=Geo.Xg(i),e>90&&e<270&&(e-=180);break;case 26:e=Geo.Xg(i+90),e>90&&e<270&&(e-=180);break;case 27:e=Geo.Xg(i-90),e>90&&e<270&&(e-=180);break;case 28:if(e=Geo.Xg(i),e>45&&e<135||e>225&&e<315)return 0;e>90&&e<270&&(e-=180);break}return Geo.Xg(e)}get fromNode(){return this.lo}set fromNode(t){const i=this.lo;if(i!==t){const e=this.fromPort;i!==null&&(this.ao!==i&&i.c1(this,e),this.yy(),this.invalidateLayout(2)),this.lo=t,t!==null&&this.Ei(t.isVisible()),this.$o=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.Y&&s.partManager.setFromNodeForLink(this,t,i);const n=this.fromPort,o=this.fromPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.Y,s.Y=!0),o(this,e,n),s!==null&&(s.Y=r)}t!==null&&(this.ao!==t&&t.a1(this,n),this.wy(),this.invalidateLayout(1)),this.t("fromNode",i,t),this.Ad()}}get fromPortId(){return this.ho}set fromPortId(t){const i=this.ho;if(i!==t){const e=this.fromPort;e!==null&&this.fromNode.ge(e),this.yy(),this.ho=t;const s=this.fromPort;s!==null&&this.fromNode.ge(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Aa()&&r.setFromPortIdForLinkData(o,t)}if(e!==s){this.$o=null,this.invalidateRoute();const o=this.fromPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.Y,n.Y=!0),o(this,e,s),n!==null&&(n.Y=r)}}this.wy(),this.t("fromPortId",i,t)}}get fromPort(){const t=this.lo;if(t===null)return null;const i=this.ho;return t.findPort(i)}get fromPortChanged(){return this.Dd}set fromPortChanged(t){const i=this.Dd;i!==t&&(t!==null&&Util.i(t,"function",Link,"fromPortChanged"),this.Dd=t,this.t("fromPortChanged",i,t))}get toNode(){return this.ao}set toNode(t){const i=this.ao;if(i!==t){const e=this.toPort;i!==null&&(this.lo!==i&&i.c1(this,e),this.yy(),this.invalidateLayout(2)),this.ao=t,t!==null&&this.Ei(t.isVisible()),this.$o=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.Y&&s.partManager.setToNodeForLink(this,t,i);const n=this.toPort,o=this.toPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.Y,s.Y=!0),o(this,e,n),s!==null&&(s.Y=r)}t!==null&&(this.lo!==t&&t.a1(this,n),this.wy(),this.invalidateLayout(1)),this.t("toNode",i,t),this.Ad()}}get toPortId(){return this.co}set toPortId(t){const i=this.co;if(i!==t){const e=this.toPort;e!==null&&this.toNode.ge(e),this.yy(),this.co=t;const s=this.toPort;s!==null&&this.toNode.ge(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Aa()&&r.setToPortIdForLinkData(o,t)}if(e!==s){this.$o=null,this.invalidateRoute();const o=this.toPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.Y,n.Y=!0),o(this,e,s),n!==null&&(n.Y=r)}}this.wy(),this.t("toPortId",i,t)}}get toPort(){const t=this.ao;if(t===null)return null;const i=this.co;return t.findPort(i)}get toPortChanged(){return this.Fd}set toPortChanged(t){const i=this.Fd;i!==t&&(t!==null&&Util.i(t,"function",Link,"toPortChanged"),this.Fd=t,this.t("toPortChanged",i,t))}get fromSpot(){return this.q!==null?this.q.ca:Spot.Default}set fromSpot(t){const i=this.fromSpot;if(!i.equals(t)){if(t=t.N(),this.Xe(),this.q.ca=t,this.t("fromSpot",i,t),i.isSide()||t.isSide()){const e=this.fromNode;e!==null&&e.ge(this.fromPort)}this.invalidateRoute()}}get fromEndSegmentLength(){return this.q!==null?this.q.ua:NaN}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;i!==t&&(t<0&&Util._(t,">= 0",Link,"fromEndSegmentLength"),this.Xe(),this.q.ua=t,this.t("fromEndSegmentLength",i,t),this.invalidateRoute())}get fromShortLength(){return this.q!==null?this.q.ga:NaN}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(this.Xe(),this.q.ga=t,this.ie(),this.t("fromShortLength",i,t))}get toSpot(){return this.q!==null?this.q.fa:Spot.Default}set toSpot(t){const i=this.toSpot;if(!i.equals(t)){if(t=t.N(),this.Xe(),this.q.fa=t,this.t("toSpot",i,t),i.isSide()||t.isSide()){const e=this.toNode;e!==null&&e.ge(this.toPort)}this.invalidateRoute()}}get toEndSegmentLength(){return this.q!==null?this.q.da:NaN}set toEndSegmentLength(t){const i=this.toEndSegmentLength;i!==t&&(t<0&&Util._(t,">= 0",Link,"toEndSegmentLength"),this.Xe(),this.q.da=t,this.t("toEndSegmentLength",i,t),this.invalidateRoute())}get toShortLength(){return this.q!==null?this.q.ma:NaN}set toShortLength(t){const i=this.toShortLength;i!==t&&(this.Xe(),this.q.ma=t,this.ie(),this.t("toShortLength",i,t))}Ad(){const t=this.fromNode,i=this.toNode;let e=null;if(t!==null?i!==null?e=t.findCommonContainingGroup(i):e=t.containingGroup:i!==null?e=i.containingGroup:e=null,this.Gv(e),this.isLabeledLink){const s=this.labelNodes;for(;s.next();){const n=s.value;n.containingGroup=e}}}Gv(t){const i=this.mh;if(i!==t){i!==null&&i.H2(this),this.mh=t,t!==null&&t.q2(this);const e=this.containingGroupChanged;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.Y,n.Y=!0),e(this,i,t),n!==null&&(n.Y=s)}this.Se&&(this.iN===i||this.eN===i)&&this.invalidateRoute()}}ah(){const t=this.containingGroup;t!==null&&this.fromNode!==t&&this.toNode!==t&&t.computesBoundsIncludingLinks&&super.ah()}getOtherNode(t){const i=this.fromNode;return t===i?this.toNode:i}getOtherPort(t){const i=this.fromPort;return t===i?this.toPort:i}get isLabeledLink(){return this.Hs===null?!1:this.Hs.count>0}get labelNodes(){return this.Hs===null?EmptyIterator.instance:this.Hs.iterator}QA(t){this.Hs===null&&(this.Hs=new GSet),this.Hs.add(t),this.c()}_A(t){this.Hs!==null&&(this.Hs.delete(t),this.c())}Um(t){if(super.Um(t),this.va()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.lo;let e=null;i!==null&&(e=this.fromPort,i.a1(this,e));const s=this.ao;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.a1(this,n)),this.wy()}}Bm(t){if(super.Bm(t),this.va()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.lo;let e=null;i!==null&&(e=this.fromPort,i.c1(this,e));const s=this.ao;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.c1(this,n)),this.yy()}}Xc(){if(this.Se=!0,this.Hs!==null){const i=this.diagram;if(i!==null){const s=this.Hs.copy().iterator;for(;s.next();){const n=s.value;i.remove(n)}}}if(this.data!==null){const i=this.diagram;i!==null&&i.partManager.rN(this)}}updateRelationshipsFromData(){if(this.data===null)return;const i=this.diagram;i!==null&&i.partManager.updateRelationshipsFromData(this)}move(t,i){const e=i?this.location:this.position;let s=e.x;isNaN(s)&&(s=0);let n=e.y;isNaN(n)&&(n=0);const o=t.x-s,r=t.y-n;if(i===!0)super.move(t,!1);else{const h=Point.X(e.x+o,e.y+r);super.move(h,!1),Point.s(h)}this.pr(o,r);const l=this.labelNodes;for(;l.next();){const h=l.value,a=h.position;h.moveTo(a.x+o,a.y+r)}}get relinkableFrom(){return(this.Nt&1)!==0}set relinkableFrom(t){const i=(this.Nt&1)!==0;i!==t&&(this.Nt=this.Nt^1,this.t("relinkableFrom",i,t),this.invalidateAdornments())}get relinkableTo(){return(this.Nt&2)!==0}set relinkableTo(t){const i=(this.Nt&2)!==0;i!==t&&(this.Nt=this.Nt^2,this.t("relinkableTo",i,t),this.invalidateAdornments())}canRelinkFrom(){if(!this.relinkableFrom)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}canRelinkTo(){if(!this.relinkableTo)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}get resegmentable(){return(this.Nt&4)!==0}set resegmentable(t){const i=(this.Nt&4)!==0;i!==t&&(this.Nt=this.Nt^4,this.t("resegmentable",i,t),this.invalidateAdornments())}get isTreeLink(){return(this.Nt&8)!==0}set isTreeLink(t){const i=(this.Nt&8)!==0;i!==t&&(this.Nt=this.Nt^8,this.t("isTreeLink",i,t),this.fromNode!==null&&this.fromNode.u0(),this.toNode!==null&&this.toNode.u0())}get path(){const t=this.findMainElement();return t instanceof Shape?t:null}get routeBounds(){return this.updateRoute(),this.jv(this.Pf)}jv(t){let i=1/0,e=1/0;const s=this.pointsCount;if(s===0)return t.e(NaN,NaN,0,0),t;if(s===1){const n=this.getPoint(0);i=Math.min(n.x,i),e=Math.min(n.y,e),t.e(n.x,n.y,0,0)}else if(s===2){const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o)}else if(this.computeCurve()===9&&s>=3&&!this.isOrthogonal){let n=this.getPoint(0);if(i=n.x,e=n.y,t.e(i,e,0,0),s===3){const o=this.getPoint(1);i=Math.min(o.x,i),e=Math.min(o.y,e);const r=this.getPoint(2);i=Math.min(r.x,i),e=Math.min(r.y,e),Geo.au(n.x,n.y,o.x,o.y,o.x,o.y,r.x,r.y,.5,t)}else for(let o=3;o=s&&(o=s-1);const l=this.getPoint(o-1),h=this.getPoint(o);Geo.au(n.x,n.y,r.x,r.y,l.x,l.y,h.x,h.y,.5,t),i=Math.min(h.x,i),e=Math.min(h.y,e),n=h}}else{const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o);for(let r=2;r=15||this.computeCurve()===9)){this.ft.getPointAlongPath(.5,t),t.add(this.getPoint(0));const a=this.ft.figures.first();return t.offset(-a.startX,-a.startY),t}if(this.computeCurve()===9){if(i===3){const f=this.getPoint(0),u=this.getPoint(1),d=this.getPoint(2);return Geo.dC(f.x,f.y,u.x,u.y,u.x,u.y,d.x,d.y,t),t}const a=(i-1)/3|0,c=(a/2|0)*3;if(a%2===1){const f=this.getPoint(c),u=this.getPoint(c+1),d=this.getPoint(c+2),m=this.getPoint(c+3);return Geo.dC(f.x,f.y,u.x,u.y,d.x,d.y,m.x,m.y,t),t}else return t.a(this.getPoint(c)),t}const e=this.flattenedLengths,s=this.flattenedTotalLength;let n=0,o=0,r=0;for(;ns/2));)n+=r,o++;const l=this.getPoint(o),h=this.getPoint(o+1);if(Math.abs(l.x-h.x)<1)l.y>h.y?t.e(l.x,l.y-(s/2-n)):t.e(l.x,l.y+(s/2-n));else if(Math.abs(l.y-h.y)<1)l.x>h.x?t.e(l.x-(s/2-n),l.y):t.e(l.x+(s/2-n),l.y);else{const a=(s/2-n)/r,c=a*(h.x-l.x),f=a*(h.y-l.y);t.e(l.x+c,l.y+f)}return t}get midAngle(){return this.updateRoute(),this.computeMidAngle()}computeMidAngle(){const t=this.pointsCount;if(t<2)return NaN;if(t===2){const h=this.getPoint(0),a=this.getPoint(1);return h.directionPoint(a)}if(this.isOrthogonal&&(this.computeCorner()>=15||this.computeCurve()===9))return this.ft.getAngleAlongPath(.5);if(this.computeCurve()===9&&t>=4){const h=(t-1)/3|0;let a=(h/2|0)*3;if(h%2===1){a=Math.floor(a);const c=this.getPoint(a),f=this.getPoint(a+1),u=this.getPoint(a+2),d=this.getPoint(a+3);return Geo.RD(c.x,c.y,f.x,f.y,u.x,u.y,d.x,d.y)}else if(a>0&&a+1e/2));)s+=o,n++;const r=this.getPoint(n),l=this.getPoint(n+1);if(Math.abs(r.x-l.x)<1&&Math.abs(r.y-l.y)<1){if(n>0&&n+2l.y?270:90;if(Math.abs(r.y-l.y)<1)return r.x>l.x?180:0}return r.directionPoint(l)}Hv(){if(this.py===null){this.Se||this.d1();const t=this.py=[];this.qv(t)}}get flattenedLengths(){return this.Hv(),this.py}get flattenedTotalLength(){let t=this.u1;if(isNaN(t)){const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=3){let g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e);m=this.adjustPoints(0,g,o-1,p),m&&(g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e),this.adjustPoints(0,g,o-1,p))}m||(this.clearPoints(),u?this.Wv(i,e,r,s,n,l):this.Jv(i,e,r,s,n,l))}else{const m=this.isAvoiding;d&&(f&&m||c)&&this.clearPoints();const g=c?this.computeCurviness():0,p=this.getLinkPoint(i,e,r,!0,f,s,n);let y=0,x=0,k=0;if(f||!h||c){let N=this.computeEndSegmentLength(i,e,r,!0);if(k=this.getLinkDirection(i,e,p,r,!0,f,s,n),c&&(h||r.equals(l)||!f&&r.x+l.x===1&&r.y+l.y===1)&&(k-=f?90:30,g<0&&(k-=180)),k<0?k+=360:k>=360&&(k-=360),c&&(N+=Math.abs(g)*(f?1:2)),k===0?y=N:k===90?x=N:k===180?y=-N:k===270?x=-N:(y=N*Math.cos(k*Math.PI/180),x=N*Math.sin(k*Math.PI/180)),r.isNoSpot()&&c){const T=e.getDocumentPoint(Spot.Center,Point.l()),A=Point.X(T.x+y*1e3,T.y+x*1e3);this.getLinkPointFromPoint(i,e,T,A,!0,p),Point.s(T),Point.s(A)}}const b=this.getLinkPoint(s,n,l,!1,f,i,e);let P=0,M=0,L=0;if(f||!a||c){let N=this.computeEndSegmentLength(s,n,l,!1);if(L=this.getLinkDirection(s,n,b,l,!1,f,i,e),c&&(a||r.equals(l)||!f&&r.x+l.x===1&&r.y+l.y===1)&&(L+=f?0:30,g<0&&(L+=180)),L<0?L+=360:L>=360&&(L-=360),c&&(N+=Math.abs(g)*(f?1:2)),L===0?P=N:L===90?M=N:L===180?P=-N:L===270?M=-N:(P=N*Math.cos(L*Math.PI/180),M=N*Math.sin(L*Math.PI/180)),l.isNoSpot()&&c){const T=n.getDocumentPoint(Spot.Center,Point.l()),A=Point.X(T.x+P*1e3,T.y+M*1e3);this.getLinkPointFromPoint(s,n,T,A,!1,b),Point.s(T),Point.s(A)}}let C=p;(f||!h||c)&&(C=new Point(p.x+y,p.y+x));let S=b;(f||!a||c)&&(S=new Point(b.x+P,b.y+M)),!d&&!f&&h&&o>3&&this.adjustPoints(0,p,o-2,S)?this.setPoint(o-1,b):!d&&!f&&a&&o>3&&this.adjustPoints(1,C,o-1,b)?this.setPoint(0,p):!d&&(f?o>=6:o>4)&&this.adjustPoints(1,C,o-2,S)?(this.setPoint(0,p),this.setPoint(o-1,b)):(this.clearPoints(),this.addPoint(p),(f||!h||c)&&this.addPoint(C),f&&this.addOrthoPoints(C,k,S,L,i,s),(f||!a||c)&&this.addPoint(S),this.addPoint(b))}return t.addInvalidRoute(this),!0}hN(t,i){return Math.abs(i.x-t.x)>Math.abs(i.y-t.y)?(i.x>=t.x?i.x=t.x+9e9:i.x=t.x-9e9,i.y=t.y):(i.y>=t.y?i.y=t.y+9e9:i.y=t.y-9e9,i.x=t.x),i}getLinkPointFromPoint(t,i,e,s,n,o){if(o===void 0&&(o=new Point),t===null||i===null)return o.a(e),o;if(!t.isVisible()){const u=t.findVisibleNode();u!==null&&u!==t&&(t=u,i=t.port)}let r=0,l=0,h=0,a=0,c=null,f=i.panel;if(f!==null&&!f.pn()&&(f=f.panel),f===null)r=s.x,l=s.y,h=e.x,a=e.y;else{c=f.Es;const u=1/(c.m11*c.m22-c.m12*c.m21),d=c.m22*u,m=-c.m12*u,g=-c.m21*u,p=c.m11*u,y=u*(c.m21*c.dy-c.m22*c.dx),x=u*(c.m12*c.dx-c.m11*c.dy);r=s.x*d+s.y*g+y,l=s.x*m+s.y*p+x,h=e.x*d+e.y*g+y,a=e.x*m+e.y*p+x}return i.$c(r,l,h,a,o),c!==null&&o.D(c),o}$v(t,i){const e=t.$u;return e!==null?e.nT(i):null}m1(t){let i=t.$u;return i===null&&(i=new Knot,i.Qo=t,i.ue=t.part,t.$u=i),i.nT(this)}getLinkPoint(t,i,e,s,n,o,r,l){if(l===void 0&&(l=new Point),e.isSpot()&&!this.Ed(e))return i.getDocumentPoint(e,l),l;if(e.isSide()){const c=this.m1(i);if(c!==null){const f=c.Ud;if(l.a(f),n&&this.routing===7){const u=this.m1(r);if(u!==null&&c.Mf=g.y&&y.y<=g.y+g.height?l.y=y.y:(e.includesSide(Spot.TopSide)||e.includesSide(Spot.BottomSide))&&y.x>=g.x&&y.x<=g.x+g.width&&(l.x=y.x),Point.s(d),Point.s(m)}}return l}}const h=i.getDocumentPoint(this.p1(e,s),Point.l());let a=null;if(this.pointsCount>(n?6:2))a=s?this.getPoint(1):this.getPoint(this.pointsCount-2),n&&(a=this.hN(h,a.copy()));else{const c=this.computeSpot(!s,r),f=Point.l();a=r.getDocumentPoint(this.p1(c,!s),f),n&&(a=this.hN(h,a)),Point.s(f)}return this.getLinkPointFromPoint(t,i,h,a,s,l),Point.s(h),l}getLinkDirection(t,i,e,s,n,o,r,l){let h=this.Zv(t,i,e,s,n,o,r,l);if(r&&s.isNoSpot()&&r.isMemberOf(t)&&(h+=180,h>=360&&(h-=360)),this.Ed(s))return h;const a=i.getDocumentAngle();return a===0||(45<=a&&a<135?h+=90:135<=a&&a<225?h+=180:225<=a&&a<315&&(h+=270),h>=360&&(h-=360)),h}Zv(t,i,e,s,n,o,r,l){if(s.isSpot())return s.x>s.y?s.x>1-s.y?0:s.x<1-s.y?270:315:s.x1-s.y?90:s.x<1-s.y?180:135:s.x<.5?225:s.x>.5?45:0;if(s.isSide()){const f=this.m1(i);if(f!==null)switch(f.me){case 1:return 270;case 2:return 180;default:case 4:return 0;case 8:return 90}}const h=i.getDocumentPoint(Spot.Center,Point.l());let a=null;if(this.pointsCount>(o?6:2))a=n?this.getPoint(1):this.getPoint(this.pointsCount-2),o?a=this.hN(h,a.copy()):a=e;else{const f=Point.l();a=l.getDocumentPoint(Spot.Center,f),Point.s(f)}let c=0;return Math.abs(a.x-h.x)>Math.abs(a.y-h.y)?a.x>=h.x?c=0:c=180:a.y>=h.y?c=90:c=270,Point.s(h),c}computeEndSegmentLength(t,i,e,s){if(i!==null&&e.isSide()){const o=this.m1(i);if(o!==null)return o.w1}let n=NaN;return s?n=this.fromEndSegmentLength:n=this.toEndSegmentLength,i!==null&&isNaN(n)&&(s?n=i.fromEndSegmentLength:n=i.toEndSegmentLength),isNaN(n)&&(n=10),n}computeSpot(t,i){return i===void 0&&(i=null),t?this.Qv(i||this.fromPort):this._v(i||this.toPort)}Qv(t){if(t===null)return Spot.Center;let i=this.fromSpot;return i.isDefault()&&(i=t.fromSpot),i===Spot.Default?Spot.None:i}_v(t){if(t===null)return Spot.Center;let i=this.toSpot;return i.isDefault()&&(i=t.toSpot),i===Spot.Default?Spot.None:i}Ed(t){return t===Spot.None||t.x===.5&&t.y===.5}p1(t,i){return t.x===.5&&t.y===.5?t:Spot.Center}computeOtherPoint(t,i){if(this.computeAdjusting()!==0&&this.pointsCount>4)return this.computeMidPoint(new Point);{const e=this.$v(i,this);return e!==null?e.Ud:i.getDocumentPoint(Spot.Center)}}computeShortLength(t){if(t){let i=this.fromShortLength;if(isNaN(i)){const e=this.fromPort;e!==null&&(i=e.fromShortLength)}return isNaN(i)?0:i}else{let i=this.toShortLength;if(isNaN(i)){const e=this.toPort;e!==null&&(i=e.toShortLength)}return isNaN(i)?0:i}}Om(t,i,e,s,n,o){if(this.pickable===!1)return!1;i===void 0&&(i=null),e===void 0&&(e=null);let r=o;if(o===void 0&&(r=Transform.l(),r.Ri()),r.tc(this.D),this.containedInRect(t,r))return this.R2(i,e,n),o===void 0&&Transform.s(r),!0;if(this.intersectsRect(t,r)){let l=!1;if(!this.hf){const h=this.L.r,a=h.length;for(let c=a;c--;){const f=h[c];if(!f.visible&&f!==this.locationObject)continue;const u=f.actualBounds,d=this.naturalBounds;if(u.x>d.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;const m=f,g=Transform.l();if(g.set(r),m instanceof Panel?l=m.Om(t,i,e,s,n,g):this.path===m?m instanceof Shape&&(l=m.kv(t,s,g)):l=m._L(t,s,g),l){let p=m;i!==null&&(p=i(m)),p&&(e===null||e(p))&&n.add(p)}Transform.s(g)}}return o===void 0&&Transform.s(r),l||this.background!==null}return o===void 0&&Transform.s(r),!1}get isOrthogonal(){return(this.Ta&2)===2}static oN(t){return(t&2)===2}get isAvoiding(){return(this.Ta&4)===4}computeCurve(){if(this.$o===null){const t=this.fromPort,i=t!==null&&t===this.toPort,e=this.isOrthogonal;this.$o=i&&!e}return this.$o?9:this.curve}computeCorner(){if(this.curve===9)return 0;let t=this.corner;return(isNaN(t)||t<0)&&(t=10),t}findMidLabel(){const t=this.path,i=this.L.r,e=i.length;for(let n=0;n0?g-=f:g+=f;else{const p=-h/a;let y=Math.sqrt(f*f/(p*p+1));c<0&&(y=-y),m=(a<0?-1:1)*y+u,g=p*(m-u)+d}this.addPoint(r),this.addPointAt(m,g),this.addPoint(l)}else{this.addPoint(r),this.addPoint(l);const h=Rect.l();i.getDocumentBounds(h);const a=h.containsPoint(l);n.getDocumentBounds(h);const c=h.containsPoint(r);if(a||c){const f=i.getDocumentPoint(this.p1(e,!0),new Point);this.setPoint(0,this.getLinkPointFromPoint(t,i,f,l,!0,f));const u=n.getDocumentPoint(this.p1(o,!1),new Point);this.setPoint(1,this.getLinkPointFromPoint(s,n,u,r,!1,u))}Rect.s(h)}}Wv(t,i,e,s,n,o){const r=this.getLinkPoint(t,i,e,!0,!1,s,n),l=this.getLinkPoint(s,n,o,!1,!1,t,i),h=l.x-r.x,a=l.y-r.y,c=this.computeCurviness();let f=0,u=0,d=r.x+h/3,m=r.y+a/3,g=d,p=m;Geo.u(a,0)?h>0?p-=c:p+=c:(f=-h/a,u=Math.sqrt(c*c/(f*f+1)),c<0&&(u=-u),g=(a<0?-1:1)*u+d,p=f*(g-d)+m),d=r.x+2*h/3,m=r.y+2*a/3;let y=d,x=m;Geo.u(a,0)?h>0?x-=c:x+=c:(y=(a<0?-1:1)*u+d,x=f*(y-d)+m),this.clearPoints(),this.addPoint(r),this.addPointAt(g,p),this.addPointAt(y,x),this.addPoint(l),this.setPoint(0,this.getLinkPoint(t,i,e,!0,!1,s,n)),this.setPoint(3,this.getLinkPoint(s,n,o,!1,!1,t,i))}adjustPoints(t,i,e,s){let n=this.computeAdjusting();if(this.isOrthogonal){if(n===18)return!1;n===19&&(n=17)}switch(n){case 18:return this.tO(t,i,e,s);case 19:return this.iO(t,i,e,s);case 17:return this.eO(t,i,e,s);default:return!1}}tO(t,i,e,s){const n=this.getPoint(t),o=this.getPoint(e);if(n.equalsApprox(i)&&o.equalsApprox(s))return!0;const r=n.x,l=n.y,h=o.x,a=o.y;let c=h-r,f=a-l;const u=Math.sqrt(c*c+f*f);if(Geo.K(u,0))return!0;let d=0;Geo.K(c,0)?f<0?d=-Math.PI/2:d=Math.PI/2:(d=Math.atan(f/Math.abs(c)),c<0&&(d=Math.PI-d));const m=i.x,g=i.y,p=s.x,y=s.y,x=p-m,k=y-g,b=Math.sqrt(x*x+k*k);let P=0;Geo.K(x,0)?k<0?P=-Math.PI/2:P=Math.PI/2:(P=Math.atan(k/Math.abs(x)),x<0&&(P=Math.PI-P));const M=b/u,L=P-d;this.setPoint(t,i);for(let C=t+1;C0&&(C=-C);const S=f+P*(d-f),N=u+P*(m-u);if(g!==0){const T=S+C/p,A=N-(T-S)/g;this.setPointAt(y,T,A)}else this.setPointAt(y,S,N+C)}return this.setPoint(e,s),!0}eO(t,i,e,s){if(this.isOrthogonal){let n=this.getPoint(t),o=this.getPoint(t+1),r=this.getPoint(t+2),l=o.x,h=o.y;const a=l,c=h;Geo.u(n.y,o.y)?Geo.u(o.x,r.x)?h=i.y:Geo.u(o.y,r.y)&&(l=i.x):Geo.u(n.x,o.x)&&(Geo.u(o.y,r.y)?l=i.x:Geo.u(o.x,r.x)&&(h=i.y)),this.setPointAt(t+1,l,h),n=this.getPoint(e),o=this.getPoint(e-1),r=this.getPoint(e-2);let f=o.x,u=o.y;const d=f,m=u;if(Geo.u(n.y,o.y)?Geo.u(o.x,r.x)?u=s.y:Geo.u(o.y,r.y)&&(f=s.x):Geo.u(n.x,o.x)&&(Geo.u(o.y,r.y)?f=s.x:Geo.u(o.x,r.x)&&(u=s.y)),this.setPointAt(e-1,f,u),this.TL())return this.setPointAt(t+1,a,c),this.setPointAt(e-1,d,m),!1}return this.setPoint(t,i),this.setPoint(e,s),!0}addOrthoPoints(t,i,e,s,n,o){i<0?i+=360:i>=360&&(i-=360),s<0?s+=360:s>=360&&(s-=360);const c=s;i>=315||i<45?i=0:45<=i&&i<135?i=90:135<=i&&i<225?i=180:i=270,s>=315||s<45?s=0:45<=s&&s<135?s=90:135<=s&&s<225?s=180:s=270;const f=t,u=e,d=n.actualBounds.copy(),m=o.actualBounds.copy();if(!d.isReal()||!m.isReal())return;d.inflate(Link.Ra,Link.Ra),m.inflate(Link.Ra,Link.Ra),d.unionPoint(t),m.unionPoint(e);const g=Point.l(),p=Point.l();i===0?u.x>f.x||s===270&&u.yf.x||s===90&&u.y>f.y&&m.right>f.x?(g.e(u.x,f.y),p.e(u.x,(f.y+u.y)/2),s===180?(g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1),p.x=g.x,p.y=u.y):s===270&&u.yf.y?(f.xm.bottom)?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):g.x=m.right,p.x=g.x,p.y=u.y):s===0&&f.xm.top&&f.yd.bottom)&&(s===180&&(m.containsPoint(f)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):u.yf.y&&(s===180||s===270)&&(g.y=this.computeMidOrthoPosition(f.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=d.left&&u.x<=f.x||f.x<=m.right&&f.x>=u.x?(s===90||s===270)&&(g.e(Math.max((f.x+u.x)/2,f.x),f.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yf.y&&m.leftf.y?(f.x>m.right?g.x=this.computeMidOrthoPosition(f.x,f.y,m.right,u.y,!1):f.x>m.left&&(s===270&&f.ym.bottom)?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):g.x=m.left,p.x=g.x,p.y=u.y):s===180&&f.x>m.right&&f.y>m.top&&f.yd.bottom)&&(s===0&&(m.containsPoint(f)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):u.yf.y&&(s===0||s===270)&&(g.y=this.computeMidOrthoPosition(f.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=f.x||f.x>=m.left&&f.x<=u.x?(s===90||s===270)&&(g.e(Math.min((f.x+u.x)/2,f.x),f.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yf.y||s===180&&u.xf.y||s===0&&u.x>f.x&&m.bottom>f.y?(g.e(f.x,u.y),p.e((f.x+u.x)/2,u.y),s===270?(g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0),p.x=u.x,p.y=g.y):s===180&&u.xf.x?(f.ym.right)?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):g.y=m.bottom,p.x=u.x,p.y=g.y):s===90&&f.ym.left&&f.xd.right)&&(s===270&&(m.containsPoint(f)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):u.xf.x&&(s===270||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,f.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=d.top&&u.y<=f.y||f.y<=m.bottom&&f.y>=u.y?(s===0||s===180)&&(g.e(f.x,Math.max((f.y+u.y)/2,f.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.xf.x&&m.top=f.x?(f.y>m.bottom?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,m.bottom,!0):f.y>m.top&&(s===180&&f.xm.right)?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):g.y=m.top,p.x=u.x,p.y=g.y):s===270&&f.y>m.bottom&&f.x>m.left&&f.xd.right)&&(s===90&&(m.containsPoint(f)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):u.xf.x&&(s===90||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,f.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=f.y||f.y>=m.top&&f.y<=u.y?(s===0||s===180)&&(g.e(f.x,Math.min((f.y+u.y)/2,f.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.x=3&&!Geo.K(this.smoothness,0))if(i===3){let c=this.getPoint(1);n=Math.min(r.x,c.x),o=Math.min(r.y,c.y),c=this.getPoint(2),n=Math.min(n,c.x),o=Math.min(o,c.y)}else if(this.isOrthogonal){for(let c=0;c=i&&(c=i-1);const f=this.getPoint(c);l.x=Math.min(f.x,l.x),l.y=Math.min(f.y,l.y)}n=l.x,o=l.y}else{for(let c=0;c=3&&!Geo.K(this.smoothness,0))if(i===3){const f=this.getPoint(1),u=f.x-n,d=f.y-o;let m=this.getPoint(2).copy();m.x-=n,m.y-=o,this.computeShortLength(!1)!==0&&(m=this.Sf(m,!1,l)),c.dr(u,d,u,d,m.x,m.y)}else if(this.isOrthogonal){const f=Point.X(n,o),u=Point.l();u.a(this.getPoint(1));const d=Point.X(n,o),m=Point.X(n,o);let g=this.getPoint(0),p=null;const y=this.smoothness/3;for(let P=1;P=i&&(f=i-1);const d=this.getPoint(f-1);let m=this.getPoint(f);f===i-1&&this.computeShortLength(!1)!==0&&(m=this.Sf(m.copy(),!1,Point.Po)),c.dr(u.x-n,u.y-o,d.x-n,d.y-o,m.x-n,m.y-o)}else{const f=Point.l();f.a(this.getPoint(0));const u=Point.l();u.a(f);const d=this.computeCorner();let m=1,g=0;for(;m1);let p=this.getPoint(m);if(m>=i-1){if(!f.equals(p))this.computeShortLength(!1)!==0&&(p=this.Sf(p.copy(),!1,Point.Po)),this.Nn(c,-n,-o,f,p,e);else if(g===0)for(m=1;mr?f>a?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):f>a?(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.K(r,h)&&Geo.K(a,f)&&(a>l?c>h?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):c>h?(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.K(r,h)&&Geo.K(h,c)||Geo.K(l,a)&&Geo.K(a,f)){const m=.5*(r+c),g=.5*(l+f);n.x=m,n.y=g,o.x=m,o.y=g}}Sf(t,i,e){const s=this.pointsCount;if(s<2)return t;if(i){const n=this.getPoint(1),o=n.x-e.x,r=n.y-e.y,l=this.b1(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!0);a>h&&(a=h);const c=a*(o-t.x)/l,f=a*(r-t.y)/l;t.x+=c,t.y+=f}else{const n=this.getPoint(s-2),o=n.x-e.x,r=n.y-e.y,l=this.b1(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!1);a>h&&(a=h);const c=a*(t.x-o)/l,f=a*(t.y-r)/l;t.x-=c,t.y-=f}return t}aN(t,i,e){const s=this.pointsCount;let n=t;for(;Geo.K(t.x,n.x)&&Geo.K(t.y,n.y);){if(i>=s)return s-1;n=this.getPoint(i++)}if(!Geo.K(t.x,n.x)&&!Geo.K(t.y,n.y))return i-1;let o=n;for(;Geo.K(t.x,n.x)&&Geo.K(n.x,o.x)&&(!e||(t.y>=n.y?n.y>=o.y:n.y<=o.y))||Geo.K(t.y,n.y)&&Geo.K(n.y,o.y)&&(!e||(t.x>=n.x?n.x>=o.x:n.x<=o.x));){if(i>=s)return s-1;o=this.getPoint(i++)}return i-2}oO(t,i,e,s,n,o,r,l,h,a){if(Geo.u(s.y,n.y)&&Geo.u(n.x,o.x)){let c=Math.min(h,Math.abs(n.x-l.x)/2);const f=Math.min(c,Math.abs(o.y-n.y)/2);if(c=f,Geo.u(c,0)){this.Nn(t,i,e,s,n,a),r.a(n);return}let u=n.x;const d=n.y,m=u;let g=d;n.x>s.x?(u=n.x-c,o.y>n.y?g=n.y+f:g=n.y-f):(u=n.x+c,o.y>n.y?g=n.y+f:g=n.y-f);const p=Point.X(u,d);this.Nn(t,i,e,s,p,a),Point.s(p),t.Sw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else if(Geo.u(s.x,n.x)&&Geo.u(n.y,o.y)){let c=Math.min(h,Math.abs(n.y-l.y)/2);const f=Math.min(c,Math.abs(o.x-n.x)/2);if(c=f,Geo.u(f,0)){this.Nn(t,i,e,s,n,a),r.a(n);return}const u=n.x;let d=n.y,m=u;const g=d;n.y>s.y?(d=n.y-c,o.x>n.x?m=n.x+f:m=n.x-f):(d=n.y+c,o.x>n.x?m=n.x+f:m=n.x-f);const p=Point.X(u,d);this.Nn(t,i,e,s,p,a),Point.s(p),t.Sw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else this.Nn(t,i,e,s,n,a),r.a(n)}computeJumpLength(){return 10}Nn(t,i,e,s,n,o){if(o||!this.va())t.ur(n.x+i,n.y+e);else{const r=this.computeJumpLength(),l=r/2,h=[];let a=0;this.isVisible()&&(a=this.rO(s,n,h));let c=s.x,f=s.y;if(a>0){if(Geo.u(s.y,n.y))if(s.x=0;){const d=Math.min(s.x,Math.max(h[u--]+l,n.x+r));t.ur(d+i,n.y+e),c=d+i,f=n.y+e;let m=Math.max(d-r,n.x);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.x);else break}const g=n.y-r+e,p=m+i,y=n.y+e;this.curve===10?t.uu(p,y,!1,!1):t.dr(c,g,p,g,p,y),c=p,f=y}}else if(Geo.u(s.x,n.x))if(s.y=0;){const d=Math.min(s.y,Math.max(h[u--]+l,n.y+r));t.ur(n.x+i,d+e),c=n.x+i,f=d+e;let m=Math.max(d-r,n.y);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.y);else break}const g=n.x-r+i,p=n.x+i,y=m+e;this.curve===10?t.uu(p,y,!1,!1):t.dr(g,f,g,y,p,y),c=p,f=y}}}t.ur(n.x+i,n.y+e)}}rO(t,i,e){const s=this.diagram;if(s===null||t.equals(i))return 0;const n=s.layers;for(;n.next();){const o=n.value;if(o!==null&&o.visible){const r=o.EM(),l=r.length;for(let h=0;h0&&e.sort((u,d)=>u-d),e.length;if(!a.isVisible()||!a.va())continue;const c=a.routeBounds;if(!c.isReal()||!this.routeBounds.intersectsRect(c)||this.usesSamePort(a))continue;const f=a.path;f!==null&&f.isVisibleObject()&&this.lO(t,i,e,a)}}}return e.length>0&&e.sort((o,r)=>o-r),e.length}lO(t,i,e,s){const n=Geo.u(t.y,i.y),o=s.pointsCount;let r=s.getPoint(0);const l=Point.l();for(let h=1;hr.x&&c.x>=a.x||a.xr.y&&c.y>=a.y||a.yc&&Math.min(a,f)o&&!Geo.u(a,f))return n.x=o,n.y=c,!0}else if(Geo.u(r,h)&&Geo.u(a,f)&&Math.min(o,l)a&&Math.min(c,u)r&&!Geo.u(c,u))return n.x=a,n.y=r,!0;return n.x=0,n.y=0,!1}get firstPickIndex(){return this.pointsCount<=2?0:this.isOrthogonal||!this.Ed(this.computeSpot(!0))?1:0}get lastPickIndex(){const t=this.pointsCount;return t===0?0:t<=2?t-1:this.isOrthogonal||!this.Ed(this.computeSpot(!1))?t-2:t-1}va(){const t=this.curve;return t===11||t===10}g1(t){if(t||this.va()){const i=this.diagram;i!==null&&!i.animationManager.isTicking&&!i.$l.has(this)&&(this.Pf.width!==0||this.Pf.height!==0)&&i.$l.set(this,this.Pf.copy())}}invalidateOtherJumpOvers(t){const i=this.layer;if(i===null||!i.visible||i.isTemporary)return;const e=i.diagram;if(e===null||e.animationManager.isTicking)return;let s=!1;const n=e.layers;for(;n.next();){const o=n.value;if(o.visible){if(o===i){s=!0;let r=!1;const l=o.EM(),h=l.length;for(let a=0;a0&&e>0){const s=this.getPoint(0),n=t.getPoint(0);if(s.equalsApprox(n))return!0;const o=this.getPoint(i-1),r=t.getPoint(e-1);if(o.equalsApprox(r)||s.equalsApprox(r)||o.equalsApprox(n))return!0}else if(this.fromNode===t.fromNode||this.toNode===t.toNode||this.fromNode===t.toNode||this.toNode===t.fromNode)return!0;return!1}isVisible(){if(!super.isVisible())return!1;const t=this.containingGroup;let i=!0;const e=this.diagram;e!==null&&(i=e.isTreePathToChildren);const s=this.fromNode;if(s!==null){if(this.isTreeLink&&i&&!s.isTreeExpanded)return!1;if(s===t)return!0;let o=s;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=s.findVisibleNode();if(r===null||r===t)return!1}const n=this.toNode;if(n!==null){if(this.isTreeLink&&!i&&!n.isTreeExpanded)return!1;if(n===t)return!0;let o=n;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=n.findVisibleNode();if(r===null||r===t)return!1}return!0}Ei(t){if(super.Ei(t),t&&this.g1(!1),this.Zo!==null&&this.Zo.Td(),this.Hs!==null){const e=this.Hs.iterator;for(;e.next();)e.value.Ei(t)}}get adjusting(){return this.kf}set adjusting(t){const i=this.kf;i!==t&&(this.kf=t,this.t("adjusting",i,t))}computeAdjusting(){return this.isAvoiding&&this.diagram!==null&&this.diagram.animationManager.defaultAnimation.isAnimating?17:this.kf}get corner(){return this.Rd}set corner(t){const i=this.Rd;i!==t&&(this.Rd=t,this.ie(),this.t("corner",i,t))}get curve(){return this.vd}set curve(t){const i=this.vd;i!==t&&(this.vd=t,this.invalidateRoute(),this.ie(),this.g1(i===10||i===11||t===10||t===11),this.t("curve",i,t))}get curviness(){return this.Od}set curviness(t){const i=this.Od;i!==t&&(this.Od=t,this.invalidateRoute(),this.ie(),this.t("curviness",i,t))}get routing(){return this.Ta}set routing(t){const i=this.Ta;i!==t&&(this.Ta=t,this.isAvoiding&&this.diagram!==null&&(this.diagram.Gm=!0),this.$o=null,this.invalidateRoute(),this.g1(Link.oN(i)||Link.oN(t)),this.t("routing",i,t))}get smoothness(){return this.Id}set smoothness(t){const i=this.Id;i!==t&&(this.Id=t,this.ie(),this.t("smoothness",i,t))}wy(){const t=this.lo;if(t===null)return;const i=this.ao;if(i===null||!isNaN(this.curviness))return;const e=this.ho,s=this.co;let n=null,o=null;const r=t._t.r,l=r.length;for(let h=0;h=0&&(Util._a(t.qs,i),t.Td())}}Cl(){return!0}get key(){const t=this.diagram;if(!(t===null||!t.model.Aa()))return t.model.getKeyForLinkData(this.data)}}class LinkBundle{Eo;Os;ry;Z2;h1;Q2;qs;constructor(t,i,e,s){GSet.Yi(this),this.Eo=!1,this.Os=!1,this.ry=t,this.Z2=i,this.h1=e,this.Q2=s,this.qs=[]}Td(){if(!this.Eo){const t=this.qs;if(t.length>0){const i=t[0].diagram;i!==null&&(i.lS.add(this),this.Os=i.undoManager.isUndoingRedoing)}}this.Eo=!0}bS(){if(this.Eo){this.Eo=!1;const t=this.qs;if(t.length>0){const i=t[0],e=i.diagram,s=e===null||e.Eh&&!this.Os;this.Os=!1,i.arrangeBundledLinks(t,s),t.length===1&&(i.Zo=null,t.length=0)}t.length===0&&(this.ry.JA(this),this.h1.JA(this))}}}class PositionArray{ne;oe;Oa;Ia;pi;yi;Ot;wh;xh;la;RS;Eo;by;Yc;vS;OS;constructor(t){GSet.Yi(this),this.la=null,this.RS=null,this.Eo=!0,this.by=!1,this.ne=1,this.oe=1,this.Oa=-1,this.Ia=-1,this.pi=t.width,this.yi=t.height,this.Ot=null,this.wh=0,this.xh=0,this.Yc=11,this.vS=this.Yc*2,this.OS=this.Yc*2}static Ws=0;static Ea=1;static Bd=999999;static cN=PositionArray.Bd+1;static fN=PositionArray.Bd+2;kb(t){if(t.width<=0||t.height<=0)return;const i=t.x,e=t.y,s=t.x+t.width,n=t.y+t.height;this.ne=Math.floor((i-this.pi)/this.pi)*this.pi,this.oe=Math.floor((e-this.yi)/this.yi)*this.yi,this.Oa=Math.ceil((s+2*this.pi)/this.pi)*this.pi,this.Ia=Math.ceil((n+2*this.yi)/this.yi)*this.yi;const o=1+(Math.ceil((this.Oa-this.ne)/this.pi)|0),r=1+(Math.ceil((this.Ia-this.oe)/this.yi)|0);if(this.Ot===null||this.wh0&&t!==this.pi&&(this.pi=t,this.kb(this.bounds))}get cellHeight(){return this.yi}set cellHeight(t){t>0&&t!==this.yi&&(this.yi=t,this.kb(this.bounds))}Vd(t,i){return this.ne<=t&&t<=this.Oa&&this.oe<=i&&i<=this.Ia}fo(t,i){if(!this.Vd(t,i))return PositionArray.cN;t-=this.ne,t/=this.pi,i-=this.oe,i/=this.yi;const e=t|0,s=i|0;return this.Ot[e][s]}wR(t,i,e,s){if(!this.Vd(t,i))return;const n=(t-this.ne)/this.pi|0,o=(i-this.oe)/this.yi|0,r=(t+e-this.ne)/this.pi|0,l=(i+s-this.oe)/this.yi|0,h=Math.min(r,this.wh),a=Math.min(l,this.xh);for(let c=n;c<=h;c++){const f=this.Ot[c];if(f.fill)f.fill(PositionArray.Ws,o,a+1);else for(let u=o;u<=a;u++)f[u]=PositionArray.Ws}}aO(t){if(this.Ot!==null)for(let i=0;i<=this.wh;i++){const e=this.Ot[i];if(e.fill)e.fill(t);else for(let s=0;s<=this.xh;s++)e[s]=t}}XL(){if(this.Ot!==null)for(let t=0;t<=this.wh;t++){const i=this.Ot[t];for(let e=0;e<=this.xh;e++)i[e]>=PositionArray.Ea&&(i[e]=PositionArray.cN)}}cO(t,i){return this.fo(t,i)===PositionArray.Ws}isUnoccupied(t,i,e,s){if(t>this.Oa||t+ethis.Ia||i+sthis.Oa||ithis.Ia||ethis.Ia||ithis.Oa||e=PositionArray.Ea&&h=a)break;this.Ot[t][i]=h,h+=1,s?i+=e:t+=e}return s?i:t}uo(t,i,e,s,n,o,r,l){if(to||il)return;const h=this.fO(t,i,e,s,n,o,r,l);if(s)if(e>0)for(let a=i+e;ah;a+=e)this.uo(t,a,1,!s,n,o,r,l),this.uo(t,a,-1,!s,n,o,r,l);else if(e>0)for(let a=t+e;ah;a+=e)this.uo(a,i,1,!s,n,o,r,l),this.uo(a,i,-1,!s,n,o,r,l)}k1(t,i,e,s,n,o,r,l,h,a){let c=t|0,f=i|0,u=PositionArray.Ws,d=PositionArray.Ea;for(this.Ot[c][f]=d;u===PositionArray.Ws&&c>r&&ch&&fr&&ch&&f=0;v-=2){F=A[v+2],R=A[v+3];const O=A[v],U=A[v+1];for(;O>F?F++:OR?R++:Us)d--;else break;else if(m>n)m--;else break;const g=c[d][m];if(g===0||g===PositionArray.fN)break;f=d,u=m}for(;;){let d=e,m=f,g=u;e===0?gn&&(d=270,g--):e===90?ms&&(d=180,m--):e===180?gn&&(d=270,g--):ms&&(d=180,m--);const p=c[m][g];if(d!==e&&p!==0&&p!==PositionArray.fN){if(o.push(f),o.push(u),this.lT(f,u,d,s,n,o))return!0;o.pop(),o.pop()}if(c[f][u]=PositionArray.fN,e===0){if(f===t)return!1;f--}else if(e===90){if(u===i)return!1;u--}else if(e===180){if(f===t)return!1;f++}else{if(u===i)return!1;u++}}}}class Knot{ue;Qo;rs;zd;constructor(){GSet.Yi(this),this.ue=null,this.Qo=null,this.rs=[],this.zd=!1}toString(){const t=this.rs;let i=this.ue.toString()+" "+t.length.toString()+":";for(let e=0;e180?270:90;case 6:return o>90&&o<=270?180:0}const r=Math.atan2(t.height,t.width)*180/Math.PI;switch(n){case 3:return o>r&&o<=180+r?180:270;case 5:return o>180-r&&o<=360-r?270:0;case 12:return o>r&&o<=180+r?90:0;case 10:return o>180-r&&o<=360-r?180:90;case 7:return o>90&&o<=180+r?180:o>180+r&&o<=360-r?270:0;case 13:return o>180&&o<=360-r?270:o>r&&o<=180?90:0;case 14:return o>r&&o<=180-r?90:o>180-r&&o<=270?180:0;case 11:return o>180-r&&o<=180+r?180:o>180+r?270:90}return s&&n!==15&&(o-=15,o<0&&(o+=360)),o>r&&o<180-r?90:o>=180-r&&o<=180+r?180:o>180+r&&o<360-r?270:0}Td(){this.rs.length=0}nT(t){let i=this.rs;i.length===0&&(this.dO(),i=this.rs);for(let e=0;e=360&&(M-=360);const L=this.uO(h,y,M,g.isOrthogonal);let C=0;L===0?(C=4,M>180&&(M-=360)):L===90?(C=8,M>270&&(M-=360)):L===180?C=2:(C=1,M<90&&(M+=360));let S=this.rs[o];S===void 0?(S=new LinkInfo(g,M,C),this.rs[o]=S):(S.He=g,S.Xt=M,S.me=C),S.M1.set(P),o++}Point.s(a),this.gO();const u=this.rs.length;let d=-1,m=0;for(o=0;o=0;o--){const g=this.rs[o];g!==void 0&&(g.me!==d&&(d=g.me,m=g.Xd+1),g.Mf=m)}this.mO(this.rs),this.pO(this.rs),this.zd=t,Rect.s(h)}return this.rs}yO(t,i){return t===i?0:t===null?-1:i===null?1:t.mei.me?1:t.Xti.Xt?1:0}gO(){this.rs.sort(Knot.prototype.yO)}mO(t){const i=this.Qo,e=this.ue.portSpreading,s=Point.l(),n=Point.l(),o=Point.l(),r=Point.l();i.getDocumentPoint(Spot.TopLeft,s),i.getDocumentPoint(Spot.TopRight,n),i.getDocumentPoint(Spot.BottomRight,o),i.getDocumentPoint(Spot.BottomLeft,r);let l=0,h=0,a=0,c=0;if(e===2)for(let x=0;xMath.abs(p)?(d=Math.abs(p)/a,a=Math.abs(p)):d=1;break;case 2:c>Math.abs(y)?(d=Math.abs(y)/c,c=Math.abs(y)):d=1;break;case 1:l>Math.abs(p)?(d=Math.abs(p)/l,l=Math.abs(p)):d=1;break;default:case 4:h>Math.abs(y)?(d=Math.abs(y)/h,h=Math.abs(y)):d=1;break}u=0}const b=k.Ud;if(e===2){let P=k.He.computeThickness();switch(P*=d,b.set(m),f){case 8:b.x=m.x+p/2+a/2-u-P/2;break;case 2:b.y=m.y+y/2+c/2-u-P/2;break;case 1:b.x=m.x+p/2-l/2+u+P/2;break;default:case 4:b.y=m.y+y/2-h/2+u+P/2;break}u+=P}else{let P=.5;e===1&&(P=(k.Xd+1)/(k.Mf+1)),b.x=m.x+p*P,b.y=m.y+y*P}}Point.s(s),Point.s(n),Point.s(o),Point.s(r)}pO(t){for(let i=0;ie instanceof Placeholder);i instanceof Placeholder?t.It=i:t.It=null,this.te!==null?(t.te=this.te.copy(),t.te.group=t):(t.te!==null&&(t.te.group=null),t.te=null),this.si!==null&&(t.si=this.si.copy())}Vo(t){super.Vo(t);const i=t.findSubGraphParts(),e=t.memberParts;for(;e.next();){const s=e.value;if(s.c(),s.invalidateLayout(8),s.clearAdornments(),s instanceof Node)s.invalidateConnectedLinks(i);else if(s instanceof Link){const n=s.labelNodes;for(;n.next();)n.value.invalidateConnectedLinks(i)}}}Wc(t,i,e,s,n,o,r){if(t===3&&i==="elements"){if(n instanceof Placeholder)this.It===null?this.It=n:this.It!==n&&Util.o("Cannot insert a second Placeholder into the visual tree of a Group.");else if(n instanceof Panel){const l=n.findInVisualTree(h=>h instanceof Placeholder);l instanceof Placeholder&&(this.It===null?this.It=l:this.It!==l&&Util.o("Cannot insert a second Placeholder into the visual tree of a Group."))}}else t===4&&i==="elements"&&this.It!==null&&(s===this.It?this.It=null:s instanceof Panel&&this.It.isContainedBy(s)&&(this.It=null));super.Wc(t,i,e,s,n,o,r)}ed(t,i){if(super.ed(t,i),this.isClipping&&this.type!==Panel.Spot&&this.isSubGraphExpanded){let e=this.resizeObject;e instanceof Panel&&(e=e.findMainElement()),this.si===null&&(this.si=new Rect),e.getDocumentBounds(this.si),e instanceof Shape&&this.si.inflate(-e.strokeWidth,-e.strokeWidth)}}hh(t,i,e,s){this.hasPlaceholder()&&(this.Jo=this.placeholder),super.hh(t,i,e,s)}ensureBounds(){this.isSubGraphExpanded&&this.memberParts.each(i=>{i.ensureBounds()}),super.ensureBounds()}Hr(){if(!super.Hr())return!1;const t=this.memberParts;for(;t.next();){const i=t.value;if(i instanceof Node){if(!i.isVisible())continue;if(i.is())return!1}else if(i instanceof Link){if(!i.isVisible())continue;if(i.is()&&i.fromNode!==this&&i.toNode!==this)return!1}}return!0}hasPlaceholder(){return this.It!==null&&this.It.isVisibleObject()&&this.isSubGraphExpanded}get placeholder(){return this.It}get computesBoundsAfterDrag(){return(this.E&2048)!==0}set computesBoundsAfterDrag(t){const i=(this.E&2048)!==0;i!==t&&(Util.i(t,"boolean",Group,"computesBoundsAfterDrag"),this.E=this.E^2048,this.t("computesBoundsAfterDrag",i,t))}get computesBoundsIncludingLinks(){return(this.E&4096)!==0}set computesBoundsIncludingLinks(t){Util.i(t,"boolean",Group,"computesBoundsIncludingLinks");const i=(this.E&4096)!==0;i!==t&&(this.E=this.E^4096,this.t("computesBoundsIncludingLinks",i,t))}get computesBoundsIncludingLocation(){return(this.E&8192)!==0}set computesBoundsIncludingLocation(t){Util.i(t,"boolean",Group,"computesBoundsIncludingLocation");const i=(this.E&8192)!==0;i!==t&&(this.E=this.E^8192,this.t("computesBoundsIncludingLocation",i,t))}get handlesDragDropForMembers(){return(this.E&16384)!==0}set handlesDragDropForMembers(t){Util.i(t,"boolean",Group,"handlesDragDropForMembers");const i=(this.E&16384)!==0;i!==t&&(this.E=this.E^16384,this.t("handlesDragDropForMembers",i,t))}get avoidableMembers(){return(this.E&131072)!==0}set avoidableMembers(t){Util.i(t,"boolean",Group,"avoidableMembers");const i=(this.E&131072)!==0;i!==t&&(this.E=this.E^131072,this.t("avoidableMembers",i,t))}get memberParts(){return this.Kd.iterator}q2(t){if(this.Kd.add(t)){t instanceof Group&&this.ra.add(t);const e=this.memberAdded;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.Y,n.Y=!0),e(this,t),n!==null&&(n.Y=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ei(!1)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.It;i===null&&(i=this),i.c()}H2(t){if(this.Kd.delete(t)){t instanceof Group&&this.ra.delete(t);const e=this.memberRemoved;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.Y,n.Y=!0),e(this,t),n!==null&&(n.Y=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ei(!0)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.It;i===null&&(i=this),i.c()}Xc(){if(this.Kd.count>0){const t=this.diagram;if(t!==null){const e=this.Kd.copy().iterator;for(;e.next();){const s=e.value;t.remove(s)}}}super.Xc()}get layout(){return this.te}set layout(t){const i=this.te;if(i!==t){t!==null&&t.diagram!==null&&t.diagram.layout===t&&Util.o("A layout cannot be both the Diagram.layout and a Group.layout: "+t),i!==null&&(i.diagram=null,i.group=null),this.te=t;const e=this.diagram;t!==null&&(t.diagram=e,t.group=this),e!==null&&(e.Kr=!0),this.t("layout",i,t),e!==null&&e.requestUpdate()}}get memberAdded(){return this.gt!==null?this.gt.uy:null}set memberAdded(t){const i=this.memberAdded;i!==t&&(t!==null&&Util.i(t,"function",Group,"memberAdded"),this.cl(),this.gt.uy=t,this.t("memberAdded",i,t))}get memberRemoved(){return this.gt!==null?this.gt.gy:null}set memberRemoved(t){const i=this.memberRemoved;i!==t&&(t!==null&&Util.i(t,"function",Group,"memberRemoved"),this.cl(),this.gt.gy=t,this.t("memberRemoved",i,t))}get memberValidation(){return this.gt!==null?this.gt.eh:null}set memberValidation(t){const i=this.memberValidation;i!==t&&(t!==null&&Util.i(t,"function",Group,"memberValidation"),this.cl(),this.gt.eh=t,this.t("memberValidation",i,t))}canAddMembers(t){const i=this.diagram;if(i===null)return!1;const e=i.commandHandler,n=e.i2(t).iterator;for(;n.next();){const o=n.value;if(!e.isValidMember(this,o))return!1}return!0}addMembers(t,i){const e=this.diagram;if(e===null)return!1;const s=e.commandHandler,n=s.i2(t);let o=!0;const r=n.iterator;for(;r.next();){const l=r.value;!i||s.isValidMember(this,l)?l.containingGroup=this:o=!1}return o}get ungroupable(){return(this.E&256)!==0}set ungroupable(t){const i=(this.E&256)!==0;i!==t&&(Util.i(t,"boolean",Group,"ungroupable"),this.E=this.E^256,this.t("ungroupable",i,t))}canUngroup(){if(!this.ungroupable)return!1;const t=this.layer;if(t===null||!t.allowUngroup)return!1;const i=t.diagram;return!(i!==null&&!i.allowUngroup)}invalidateConnectedLinks(t){const i=this.xO();if(super.invalidateConnectedLinks(t),i)return;this.PL(!0);const e=this.findExternalLinksConnected();for(;e.next();){const s=e.value;if(t!==void 0&&t.has(s))continue;const n=s.fromNode;if(n!==null&&n!==this&&n.isMemberOf(this)&&!n.isVisible())n.ge(s.fromPort),n.ge(s.toPort),s.invalidateRoute();else{const o=s.toNode;o!==null&&o!==this&&o.isMemberOf(this)&&!o.isVisible()&&(o.ge(s.fromPort),o.ge(s.toPort),s.invalidateRoute())}}}findExternalLinksConnected(){const t=this.diagram!==null&&this.diagram.dS;if(t&&this.d0!==null)return this.d0.iterator;const i=this.findSubGraphParts();i.add(this);const e=new GSet,s=i.iterator;for(;s.next();){const n=s.value;if(!(n instanceof Node))continue;const o=n.linksConnected;for(;o.next();){const r=o.value;i.has(r)||e.add(r)}}return t&&(this.d0=e),e.iterator}findExternalNodesConnected(){const t=this.findSubGraphParts();t.add(this);const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;if(!(s instanceof Node))continue;const n=s.linksConnected;for(;n.next();){const o=n.value,r=o.fromNode;r!==null&&(!t.has(r)||r===this)&&i.add(r);const l=o.toNode;l!==null&&(!t.has(l)||l===this)&&i.add(l)}}return i.iterator}pE(){function t(e,s){e!==null&&(s.add(e),t(e.containingGroup,s))}const i=new GSet;return t(this,i),i}findSubGraphParts(){const t=new GSet;return Part.sh(t,this,!0,0,!0),t.delete(this),t}Ei(t){super.Ei(t);const i=this.memberParts;for(;i.next();)i.value.Ei(t)}collapseSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.hT(i,t,this),t.isCollapsingExpanding=!1}hT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ei(!1),n instanceof Group&&n.isSubGraphExpanded&&(n.wasSubGraphExpanded=n.isSubGraphExpanded,n.hT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t),i.Cc(n,e);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!1}expandSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.aT(i,t,this),t.isCollapsingExpanding=!1}aT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ei(!0),n instanceof Group&&n.wasSubGraphExpanded&&(n.wasSubGraphExpanded=!1,n.aT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!0}get isSubGraphExpanded(){return(this.E&512)!==0}set isSubGraphExpanded(t){const i=(this.E&512)!==0;if(i!==t){Util.i(t,"boolean",Group,"isSubGraphExpanded"),this.E=this.E^512;const e=this.diagram;this.t("isSubGraphExpanded",i,t);const s=this.subGraphExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.Y,e.Y=!0),s(this),e!==null&&(e.Y=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.It!==null&&this.It.c(),this.memberParts.each(n=>n.updateAdornments());return}t?this.expandSubGraph():this.collapseSubGraph()}}get wasSubGraphExpanded(){return(this.E&1024)!==0}set wasSubGraphExpanded(t){const i=(this.E&1024)!==0;i!==t&&(Util.i(t,"boolean",Group,"wasSubGraphExpanded"),this.E=this.E^1024,this.t("wasSubGraphExpanded",i,t))}get subGraphExpandedChanged(){return this.gt!==null?this.gt.my:null}set subGraphExpandedChanged(t){const i=this.subGraphExpandedChanged;i!==t&&(t!==null&&Util.i(t,"function",Group,"subGraphExpandedChanged"),this.cl(),this.gt.my=t,this.t("subGraphExpandedChanged",i,t))}move(t,i){i===void 0&&(i=!1);const e=i?this.location:this.position,s=e.x,n=e.y,o=t.x,r=t.y;if((s===o||isNaN(s)&&isNaN(o))&&(n===r||isNaN(n)&&isNaN(r)))return;const l=o-(isNaN(s)?0:s),h=r-(isNaN(n)?0:n),a=Point.l();super.move(t,i);const c=new GSet,u=this.findSubGraphParts().iterator;for(;u.next();){const d=u.value;d instanceof Link&&(d.suspendsRouting&&c.add(d),!(!d.Se&&(d.fromNode===this||d.toNode===this))&&(d.suspendsRouting=!0))}for(u.reset();u.next();){const d=u.value;if(d.Cl()||d instanceof Node&&d.isLinkLabel)continue;const m=d.position,g=d.location;m.isReal()?(a.x=m.x+l,a.y=m.y+h,d.position=a):g.isReal()&&(a.x=g.x+l,a.y=g.y+h,d.location=a)}for(u.reset();u.next();){const d=u.value;if(!(d instanceof Link)||(d.suspendsRouting=c.has(d),!d.Se&&(d.fromNode===this||d.toNode===this)))continue;const m=d.position;a.x=m.x+l,a.y=m.y+h,a.isReal()?d.move(a):d.invalidateRoute()}Point.s(a)}xO(){return(this.E&65536)!==0}PL(t){(this.E&65536)!==0!==t&&(this.E=this.E^65536)}get Jr(){return(this.E&32768)!==0}set Jr(t){(this.E&32768)!==0!==t&&(this.E=this.E^32768)}}class Placeholder extends GraphObject{$t;Yd;constructor(t){super(),this.$t=Margin.Ug,this.Yd=new Rect(NaN,NaN,NaN,NaN),t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.$t=this.$t.N(),t.Yd=this.Yd.copy()}lh(t){if(this.background===null)return!1;const i=this.naturalBounds;return Rect.contains(0,0,i.width,i.height,t.x,t.y)}_u(t,i,e,s){const n=this.part;if((n===null||!(n instanceof Group)&&!(n instanceof Adornment))&&Util.o("Placeholder is not inside a Group or Adornment."),n instanceof Group){const o=this.computeBorder(this.Yd),r=this.minSize,l=isFinite(r.width)?Math.max(r.width,o.width):o.width,h=isFinite(r.height)?Math.max(r.height,o.height):o.height,a=this.Vi;a.En(l||0,h||0),this.Qn(0,0,a.width,a.height);const c=n.memberParts;let f=!1;for(;c.next();)if(c.value.isVisible()){f=!0;break}const u=n.diagram;if(f&&u!==null&&!u.animationManager.CM(n)&&!isNaN(o.x)&&!isNaN(o.y)){const d=Point.l();d.setRectSpot(o,n.locationSpot),n.location=d,Point.s(d)}}else{const o=n,r=this.Vi,l=this.$t,h=l.left+l.right,a=l.top+l.bottom,c=o.adornedObject,f=c.getDocumentAngle();o.angle=f;let u=0;c instanceof Shape&&(u=c.strokeWidth);const d=c.getDocumentScale(),m=c.naturalBounds,g=(m.width+u)*d,p=(m.height+u)*d;if(o.type!==Panel.Link){const y=o.category==="Selection"?Spot.TopLeft:o.locationSpot,x=c.getDocumentPoint(y,Point.l());o.location=x,Point.s(x)}if(!isNaN(g)&&!isNaN(p))r.En(g+h||0,p+a||0),this.Qn(-l.left,-l.top,r.width,r.height);else{const y=c.getDocumentPoint(Spot.TopLeft,Point.l()),x=Rect.X(y.x,y.y,0,0);x.unionPoint(c.getDocumentPoint(Spot.BottomRight,y)),x.unionPoint(c.getDocumentPoint(Spot.TopRight,y)),x.unionPoint(c.getDocumentPoint(Spot.BottomLeft,y)),r.En(x.width+h||0,x.height+a||0),this.Qn(-l.left,-l.top,r.width,r.height),Point.s(y),Rect.s(x)}}}hh(t,i,e,s){this.actualBounds.e(t,i,e,s)}computeBorder(t){const i=this.part,e=i.diagram,s=e===null||!e.animationManager.isAnimating;if(e!==null&&i instanceof Group&&!i.layer.isTemporary&&i.computesBoundsAfterDrag&&this.Yd.isReal()){const l=e.toolManager.findTool("Dragging");if(l===e.currentTool){const h=l.computeBorder(i,this.Yd,t);if(h!==null)return h}}const n=Rect.l(),o=this.computeMemberBounds(n),r=this.$t;return i instanceof Group&&!i.isSubGraphExpanded?t.e(o.x-r.left,o.y-r.top,0,0):t.e(o.x-r.left,o.y-r.top,Math.max(o.width+r.left+r.right,0),Math.max(o.height+r.top+r.bottom,0)),Rect.s(n),s&&i instanceof Group&&i.computesBoundsIncludingLocation&&i.location.isReal()&&t.unionPoint(i.location),t}computeMemberBounds(t){if(!(this.part instanceof Group))return t.e(0,0,0,0),t;const i=this.part;let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=i.memberParts;for(;r.next();){const l=r.value;if(!l.isVisible()||l instanceof Link&&(!i.computesBoundsIncludingLinks||l.Oo()||l.fromNode===i||l.toNode===i))continue;const h=l.actualBounds;h.leftn&&(n=h.right),h.bottom>o&&(o=h.bottom)}if(!isFinite(e)||!isFinite(s)){const l=i.location;t.e(l.x,l.y,0,0)}else t.e(e,s,n-e,o-s);return t}get padding(){return this.$t}set padding(t){typeof t=="number"&&(t=new Margin(t));const i=this.$t;i.equals(t)||(t=t.N(),this.$t=t,this.t("padding",i,t),this.c())}}class Layout{p;la;Gd;kr;jd;Hd;Fo;ul;qd;Wd;go;constructor(t){GSet.Yi(this),this.p=null,this.la=null,this.Gd=!0,this.kr=!0,this.jd=!1,this.Hd=new Point(0,0).g(),this.Fo=!0,this.ul=null,this.qd=null,this.Wd=!1,this.go=null,t&&Object.assign(this,t)}cloneProtected(t){t.Gd=this.Gd,t.kr=this.kr,t.jd=this.jd,t.Hd.a(this.Hd),t.Fo=this.Fo,t.ul=this.ul,t.qd=this.qd,t.Wd=!0}copy(){const t=new this.constructor;return this.cloneProtected(t),t}ri(t){Util.lr(this,t)}toString(){let t=Util.sn(this.constructor);return t+="(",this.group!==null&&(t+=" in "+this.group),this.diagram!==null&&(t+=" for "+this.diagram),t+=")",t}get diagram(){return this.p}set diagram(t){this.p=t}get group(){return this.la}set group(t){this.la!==t&&(this.la=t,t!==null&&(this.p=t.diagram))}get isOngoing(){return this.Gd}set isOngoing(t){this.Gd!==t&&(Util.i(t,"boolean",Layout,"isOngoing"),this.Gd=t)}get isInitial(){return this.kr}set isInitial(t){Util.i(t,"boolean",Layout,"isInitial"),this.kr=t,t||(this.Wd=!0)}get isViewportSized(){return this.jd}set isViewportSized(t){this.jd!==t&&(Util.i(t,"boolean",Layout,"isViewportSized"),this.jd=t,t&&this.invalidateLayout())}get isRouting(){return this.Fo}set isRouting(t){this.Fo!==t&&(Util.i(t,"boolean",Layout,"isRouting"),this.Fo=t)}get isRealtime(){return this.ul}set isRealtime(t){this.ul!==t&&(t!==null&&Util.i(t,"boolean",Layout,"isRealtime"),this.ul=t)}get isValidLayout(){return this.Wd}set isValidLayout(t){if(this.Wd!==t&&(Util.i(t,"boolean",Layout,"isValidLayout"),this.Wd=t,!t)){const i=this.diagram;i!==null&&(i.Kr=!0)}}invalidateLayout(){if(this.isValidLayout){const t=this.diagram;if(t===null||t.undoManager.isUndoingRedoing)return;const i=t.animationManager;if(i.isTicking)return;i.defaultAnimation.isAnimating&&i.stopAnimation(),(this.isOngoing&&t.Eh||this.isInitial&&!t.Eh)&&(this.isValidLayout=!1,t.requestUpdate())}}get network(){return this.go}set network(t){this.go!==t&&(this.go=t,t!==null&&(t.layout=this))}createNetwork(){return new LayoutNetwork(this)}makeNetwork(t){const i=this.createNetwork();return t instanceof Diagram?(i.addParts(t.nodes,!0),i.addParts(t.links,!0)):t instanceof Group?i.addParts(t.memberParts):i.addParts(t.iterator),i}updateParts(){this.isValidLayout=!0;let t=this.diagram;if(t===null&&this.network!==null){const i=this.network.vertexes.iterator;for(;i.next();){const s=i.value.node;if(s!==null&&(t=s.diagram,t!==null))break}}try{t!==null&&t.startTransaction("Layout"),this.commitLayout()}finally{t!==null&&t.commitTransaction("Layout")}}commitLayout(){if(this.network===null)return;const t=this.network.vertexes.iterator;for(;t.next();)t.value.commit();if(this.isRouting){const i=this.network.edges.iterator;for(;i.next();)i.value.commit()}}doLayout(t){const i=new GSet;if(t instanceof Diagram?(this.bh(i,t.nodes,!0,this.Jr,!0,!1,!0),this.bh(i,t.parts,!0,this.Jr,!0,!1,!0)):t instanceof Group?this.bh(i,t.memberParts,!1,this.Jr,!0,!1,!0):i.addAll(t.iterator),i.count>0){const s=this.diagram;s!==null&&s.startTransaction("Layout"),this.doMinimalNoNetworkLayout(i),s!==null&&s.commitTransaction("Layout")}this.isValidLayout=!0}doMinimalNoNetworkLayout(t){const i=t.count,e=Math.ceil(Math.sqrt(i));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const s=this.arrangementOrigin.x,n=this.arrangementOrigin.y;let o=s,r=n,l=0,h=0;const a=t.iterator;for(;a.next();){const c=a.value;c.ensureBounds();const f=c.measuredBounds,u=f.width,d=f.height;c.moveTo(o,r),c instanceof Group&&(c.Jr=!1),o+=Math.max(u,50)+20,h=Math.max(h,Math.max(d,50)),l>=e-1?(l=0,o=s,r+=h+20,h=0):l++}}doMinimalNetworkLayout(){const t=this.network.vertexes.count,i=Math.ceil(Math.sqrt(t));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const e=this.arrangementOrigin.x,s=this.arrangementOrigin.y;let n=e,o=s,r=0,l=0;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value.node;if(a===null||a instanceof Link||(a.ensureBounds(),!this.Jr(a)))continue;const c=a.measuredBounds,f=c.width,u=c.height;a.moveTo(n,o),a instanceof Group&&(a.Jr=!1),n+=Math.max(f,50)+20,l=Math.max(l,Math.max(u,50)),r>=i-1?(r=0,n=e,o+=l+20,l=0):r++}}Jr(t){return!!(!t.location.isReal()&&!t.position.isReal()||t instanceof Group&&t.Jr)}bh(t,i,e,s,n,o,r){const l=i.iterator;for(;l.next();){const h=l.value;if(!(e&&!h.isTopLevel)&&!(s!==null&&!s(h))&&h.canLayout())if(n&&h instanceof Node){if(h.isLinkLabel)continue;h instanceof Group&&h.layout===null?this.bh(t,h.memberParts,!1,s,n,o,r):(h.ensureBounds(),t.add(h))}else o&&h instanceof Link?t.add(h):r&&h.Pe()&&!(h instanceof Node)&&(h.ensureBounds(),t.add(h))}}getLayoutBounds(t,i){const e=this.boundsComputation;return e!==null?(i||(i=new Rect),e(t,this,i)):!i&&t.margin.equalTo(0,0,0,0)?t.actualBounds:(i||(i=new Rect),i.set(t.actualBounds),i.addMargin(t.margin),i)}get boundsComputation(){return this.qd}set boundsComputation(t){this.qd!==t&&(t!==null&&Util.i(t,"function",Layout,"boundsComputation"),this.qd=t,this.invalidateLayout())}collectParts(t){const i=new GSet;return t instanceof Diagram?(this.bh(i,t.nodes,!0,null,!0,!0,!0),this.bh(i,t.links,!0,null,!0,!0,!0),this.bh(i,t.parts,!0,null,!0,!0,!0)):t instanceof Group?this.bh(i,t.memberParts,!1,null,!0,!0,!0):this.bh(i,t.iterator,!1,null,!0,!0,!0),i}get arrangementOrigin(){return this.Hd}set arrangementOrigin(t){this.Hd.equals(t)||(this.Hd.a(t),this.invalidateLayout())}initialOrigin(t){const i=this.group;if(i!==null)if(i.hasPlaceholder()){const e=i.placeholder,s=e.getDocumentPoint(Spot.TopLeft);(isNaN(s.x)||isNaN(s.y))&&s.set(t);const n=e.padding;return s.x+=n.left,s.y+=n.top,s}else{const e=i.position.copy();return(isNaN(e.x)||isNaN(e.y))&&e.set(t),e}return t}}class LayoutNetwork{te;mo;Cn;ky;Py;constructor(t){GSet.Yi(this),this.te=t,this.mo=new GSet,this.Cn=new GSet,this.ky=new GMap,this.Py=new GMap}clear(){if(this.mo){const t=this.mo.iterator;for(;t.next();)t.value.clear()}if(this.Cn){const t=this.Cn.iterator;for(;t.next();)t.value.clear()}this.mo=new GSet,this.Cn=new GSet,this.ky=new GMap,this.Py=new GMap}toString(t){t===void 0&&(t=0);let i="LayoutNetwork"+(this.layout!==null?"("+this.layout.toString()+")":"");if(t<=0)return i;if(i+=" vertexes: "+this.mo.count+" edges: "+this.Cn.count,t>1){const e=this.mo.iterator;for(;e.next();){const n=e.value;i+=` +`);if(t.length===0)return 8;if(this.isMultiline){let i=0,e=0,s=!1;for(;!s;){let n=this.t1(t,e);n===-1&&(n=t.length,s=!0);let o=t.substring(e,n);this.formatting===0&&(o=o.trim()),i=Math.max(i,this.getStringWidth(o)),e=n+1}return i}else{const i=this.t1(t,0);return i>=0&&(t=t.substring(0,i)),this.getStringWidth(t)}}get textValidation(){return this.W!==null?this.W.Tl:null}set textValidation(t){const i=this.textValidation;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"textValidation"),this.Mn(),this.W.Tl=t,this.t("textValidation",i,t))}get textEdited(){return this.W!==null?this.W.Dp:null}set textEdited(t){const i=this.textEdited;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"textEdited"),this.Mn(),this.W.Dp=t,this.t("textEdited",i,t))}get spacingAbove(){return this.W!==null?this.W.Fp:0}set spacingAbove(t){const i=this.spacingAbove;i!==t&&(this.Mn(),this.W.Fp=t,this.c(),this.t("spacingAbove",i,t))}get spacingBelow(){return this.W!==null?this.W.Rp:0}set spacingBelow(t){const i=this.spacingBelow;i!==t&&(this.Mn(),this.W.Rp=t,this.c(),this.t("spacingBelow",i,t))}get formatting(){return this.W!==null?this.W.vp:0}set formatting(t){const i=this.formatting;i!==t&&(this.Mn(),this.W.vp=t,this.c(),this.t("formatting",i,t))}get maxLines(){return this.W!==null?this.W.Op:1/0}set maxLines(t){const i=this.maxLines;i!==t&&(t=Math.floor(t),t<=0&&Util._(t,"> 0",TextBlock,"maxLines"),this.Mn(),this.W.Op=t,this.c(),this.t("maxLines",i,t))}getMetrics(){return[this.mi,this.Dl,this.oo,this.Pn,this.Le,this.Di,this.Sn]}Pv(t){t!==void 0&&(this.mi=t[0],this.Dl=t[1],this.oo=t[2],this.Pn=t[3],this.Le=t[4],this.Di=t[5],this.Sn=t[6])}get metrics(){return{arrSize:this.Le!==null?this.Le:[this.mi],arrText:this.Di!==null?this.Di:[this.Sn],maxLineWidth:this.mi,fontHeight:this.oo}}get choices(){return this.Sd}set choices(t){const i=this.Sd;i!==t&&(this.Sd=t,this.t("choices",i,t))}static Lv=new RegExp("[ \u200B\xAD]");static V2=new PropertyCollection;static IA=0;static Zb=new PropertyCollection;static E2=0;static Sp="...";static vA="";static il=Diagram.isUsingDOM()?new CanvasSurface(null).ai:null}class TextBlockTemplateSettings{gi;os;ro;vp;Op;Cp;Fp;Rp;Mp;Dp;Ap;Tl;sl;Np;constructor(){this.gi=!1,this.os=null,this.ro=0,this.vp=0,this.Op=1/0,this.Cp=0,this.Fp=0,this.Rp=0,this.Mp="start",this.Dp=null,this.Ap=null,this.Tl=null,this.sl=Spot.Top,this.Np=2}copy(){const t=new TextBlockTemplateSettings;return t.os=this.os,t.ro=this.ro,t.vp=this.vp,t.Op=this.Op,t.Cp=this.Cp,t.Fp=this.Fp,t.Rp=this.Rp,t.Mp=this.Mp,t.Dp=this.Dp,t.Ap=this.Ap,t.Tl=this.Tl,t.sl=this.sl,t.Np=this.Np,t}}class GradElementSettings{uf;df;gf;Tp;mf;constructor(){this.uf=1,this.df=0,this.gf=1,this.Tp=null,this.mf=null}copy(){const t=new GradElementSettings;return t.uf=this.uf,t.df=this.df,t.gf=this.gf,t.Tp=this.Tp,t.mf=this.mf,t}}var ImageStretch=(w=>(w[w.None=0]="None",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ImageStretch||{});class Picture extends GraphObject{nl;yt;ol;pf;os;rl;yf;ro;wf;xf;Ib;constructor(t,i){super(),this.n|=2097152,this.nl=null,this.yt="",this.ol=Rect.AD,this.pf=2,this.os=null,this.rl=null,this.yf=Spot.Center,this.ro=0,this.wf=null,this.xf=null,this.Ib=null,typeof t=="string"?this.source=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.yt=this.yt,t.element=this.nl,t.ol=this.ol.N(),t.pf=this.pf,t.ro=this.ro,t.os=this.os,t.rl=this.rl,t.yf=this.yf.N(),t.xf=this.xf}ri(t){t in ImageStretch?this.imageStretch=t:super.ri(t)}toString(){return"Picture("+this.source+")#"+GSet.as(this)}get bf(){return(this.n&1048576)!==0}set bf(t){this.bf!==t&&(this.n=this.n^1048576)}get Ip(){return(this.n&2097152)!==0}set Ip(t){this.Ip!==t&&(this.n=this.n^2097152)}get mn(){return(this.n&4194304)!==0}set mn(t){this.mn!==t&&(this.n=this.n^4194304)}static clearCache(t){t===void 0&&(t=""),Util.i(t,"string",Picture,"clearCache:url"),t!==""?Picture.Ep[t]&&(delete Picture.Ep[t],Picture.i1--):(Picture.Ep=new PropertyCollection,Picture.i1=0)}static OL(t,i){i.EA||(i.e1=e=>{Picture.Av(i,e),t.desiredSize.isReal()||(t.ue(!1),t.c())},i.s1=e=>Picture.Tv(i,e),i.addEventListener("load",i.e1),i.addEventListener("error",i.s1),i.EA=!0)}static mR(t){t.e1&&t.removeEventListener("load",t.e1),t.s1&&t.removeEventListener("error",t.s1),delete t.e1,delete t.s1,delete t.EA}get element(){return this.nl}set element(t){const i=this.nl;if(this.ss(!0),i!==t){this.bf=t instanceof HTMLCanvasElement;const e=t instanceof HTMLImageElement;t!==null&&!(e||t instanceof HTMLVideoElement||this.bf)&&Util.o("Picture.element must be an instance of Image, Canvas, or Video, not: "+t);const s=this.diagram;s!==null&&s.DM(this),this.nl=t,t!==null&&e&&t.es===void 0&&(t.es=new GSet),s!==null&&e&&s.TM(this),this.t("element",i,t),this.C()}}dR(){const t=this.nl;if(t===null)return;const i=this.desiredSize.isReal();(this.bf||t.complete===!0)&&(t.c0&&(t.Bp instanceof Event&&this.os!==null?this.os(this,t.Bp):t.mn===!0&&!t.Bp&&this.rl!==null&&t.z2&&this.rl(this,t.z2)),t.mn=!0),t.mn&&i&&this.diagram!==null&&this.diagram.zu.add(this)}Dv(){if(this.nl===null){this.wf=!1;return}const t=new CanvasSurface(null).ai;try{t.drawImage(this.nl,0,0)}catch{this.Ip=!1}try{t.getImageData(0,0,1,1).data[3]&&(this.wf=!1),this.wf=!1}catch{this.wf=!0}}get source(){return this.yt}set source(t){const i=this.yt;if(i!==t){this.ss(!0),Util.i(t,"string",Picture,"source"),this.yt=t;let e=Picture.Ep;if(!Diagram.isUsingDOM()){this.t("source",i,t);return}let s=null;if(e[t]!==void 0)s=e[t];else if(t!==""){Picture.i1>30&&(Picture.clearCache(),e=Picture.Ep),s=Util.en("img"),s.c0=!0,Picture.OL(this,s);const n=this.xf;n!==null&&(s.crossOrigin=n(this)),s.src=t,e[t]=s,Picture.i1++}this.element=s,s!==null&&s.__goCache===void 0&&(s.__goCache=new PictureCacheArray),this.c(),this.C(),this.t("source",i,t)}}static Av(t,i){t.mn=!0,t.Bp=!1;let e;const s=t.es.copy();if(s==null)return;const n=s.iterator;for(;n.next();){const o=n.value;o.C();const r=t.getAttribute("src")||"",l=o.Jl.get(r);if(l===null)continue;const h=l.length;for(let a=0;a=o.width&&(r=r+p.offsetX+(d*p.x-o.width*p.x)),m>=o.height&&(l=l+p.offsetY+(m*p.y-o.height*p.y)),a=Math.min(o.width,d),c=Math.min(o.height,m);break;case 2:d=o.width,m=o.height;break;case 6:case 7:let A=0;g===6?(A=Math.min(o.height/m,o.width/d),d*=A,m*=A):g===7&&(A=Math.max(o.height/m,o.width/d),d*=A,m*=A,d>=o.width&&(r=(r+p.offsetX+(d*p.x-o.width*p.x)/d)*a),m>=o.height&&(l=(l+p.offsetY+(m*p.y-o.height*p.y)/m)*c),a*=1/(d/o.width),c*=1/(m/o.height),d=o.width,m=o.height);break}const y=a*c,x=this.getDocumentScale()*i.scale,k=d*x,b=m*x,P=k*b,S=y/P,L=e.__goCache;let C=null;const M=Picture.Fv;if(!n){if(e.mn&&L!==void 0&&P>4&&S>M*M){L.Ot===null&&(L.BA(4,f,u,e),L.BA(16,f,u,e));const A=L.Ot,D=A.length;for(let F=0;F0){const c=this.Ot[this.Ot.length-1];h=c.yt,a=c.Nd}o.setTransform(r*a,0,0,r*a,0,0),o.commitTransform(),o.drawImage(h,0,0),this.Ot.push(l)}}class PictureCacheInstance{yt;Nd;constructor(t,i){this.yt=t,this.Nd=i}}class GeoStream{Pi;Hg;constructor(){this.Hg=new Geometry,this.Pi=null}Ri(t){t!==null?(t.ot(),this.Hg=t,t.figures.clear()):this.Hg=new Geometry,this.Pi=null}fu(t,i,e,s,n,o){if(s!==void 0&&s===!0){const r=new PathSegment(1);r.endX=t,r.endY=i,this.Pi.segments.add(r)}else this.Pi=new PathFigure,this.Pi.startX=t,this.Pi.startY=i,this.Pi.isFilled=e,this.Pi.isEvenOdd=o||!1,this.Hg.figures.add(this.Pi);n!==void 0&&(this.Pi.isShadowed=n)}UD(){const t=this.Pi.segments.length;t>0&&this.Pi.segments.elt(t-1).close()}VD(){this.Pi.segments.length>0&&(this.Pi.isFilled=!0)}zD(t){this.Pi.isShadowed=t}gE(t){this.Pi.isEvenOdd=t}ID(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(1);s.endX=t,s.endY=i,e&&s.close(),this.Pi.segments.add(s)}ur(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(2);s.endX=t,s.endY=i,e&&s.close(),this.Pi.segments.add(s)}dr(t,i,e,s,n,o,r){r===void 0&&(r=!1);const l=new PathSegment(3);l.point1X=t,l.point1Y=i,l.point2X=e,l.point2Y=s,l.endX=n,l.endY=o,r&&l.close(),this.Pi.segments.add(l)}Mw(t,i,e,s,n){n===void 0&&(n=!1);const o=new PathSegment(4);o.point1X=t,o.point1Y=i,o.endX=e,o.endY=s,n&&o.close(),this.Pi.segments.add(o)}ED(t,i,e,s,n,o,r){o===void 0&&(o=0),r===void 0&&(r=!1);const l=new PathSegment(5);l.startAngle=t,l.sweepAngle=i,l.centerX=e,l.centerY=s,l.radiusX=n,o!==0?l.radiusY=o:l.radiusY=n,r&&l.close(),this.Pi.segments.add(l)}BD(t,i,e,s,n,o,r,l){l===void 0&&(l=!1);const h=new PathSegment(6,o,r,t,i,e,s,n);l&&h.close(),this.Pi.segments.add(h)}static X2=null;static mC(t){const i=GeoStream.X2;if(i!==null)return GeoStream.X2=null,i.Ri(t),i;{const e=new GeoStream;return e.Ri(t),e}}static pC(t){GeoStream.X2=t}}{const w=function(n,o){const r=n.toLowerCase(),l=Geo.So;l[n]=o,l[r]=n};w("Rectangle",(n,o,r)=>{const l="r"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,Geo.fr{const l="s"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,h.defaultStretch=6,Geo.fr{(isNaN(l)||l<0)&&(l=5),isNaN(h)&&(h=15);const a="rr"+o+","+r+","+l+","+h;let c=Geo.cr[a];if(c!==void 0)return c;let f=l;(h&1)===1?(f=Math.min(f,(h&2)===2?o/3:o),f=Math.min(f,(h&8)===8?r/3:r)):f=0;const u=new PathFigure(f,0,!0);c=new Geometry().add(u);const d=Spot.TopLeft.copy(),m=Spot.BottomRight.copy();if((h&2)===2){let g=l;g=Math.min(g,(h&1)===1?o/3:o),g=Math.min(g,(h&4)===4?r/3:r);const p=g*Geo.Bn;u.add(new PathSegment(2,o-g,0)).add(new PathSegment(3,o,g,o-p,0,o,p)),d.offsetY=p,m.offsetX=-p}else u.add(new PathSegment(2,o,0));if((h&4)===4){let g=l;g=Math.min(g,(h&8)===8?o/3:o),g=Math.min(g,(h&2)===2?r/3:r);const p=g*Geo.Bn;u.add(new PathSegment(2,o,r-g)).add(new PathSegment(3,o-g,r,o,r-p,o-p,r)),m.offsetX=-p,m.offsetY=-p}else u.add(new PathSegment(2,o,r));if((h&8)===8){let g=l;g=Math.min(g,(h&4)===4?o/3:o),g=Math.min(g,(h&1)===1?r/3:r);const p=g*Geo.Bn;u.add(new PathSegment(2,g,r)).add(new PathSegment(3,0,r-g,p,r,0,r-p)),d.offsetX=p,m.offsetY=-p}else u.add(new PathSegment(2,0,r));if((h&1)===1){const g=f*Geo.Bn;u.add(new PathSegment(2,0,f)).add(new PathSegment(3,f,0,0,g,g,0).close()),d.offsetX=g,d.offsetY=g}else u.add(new PathSegment(2,0,0).close());return c.spot1=d,c.spot2=m,Geo.fr{const l=n?n.parameter1:NaN,h=n?n.parameter2:NaN;return t(n,o,r,l,h)}),w("Border","RoundedRectangle"),w("RoundedTopRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,3)}),w("RoundedBottomRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,12)}),w("RoundedLeftRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,9)}),w("RoundedRightRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,6)}),w("Ellipse",(n,o,r)=>{const l="e"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Rk,h.spot2=Spot.vk,Geo.fr{const l="c"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Rk,h.spot2=Spot.vk,h.defaultStretch=6,Geo.frnew Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,.5*r)).add(new PathSegment(2,0,r).close())).setSpots(0,.25,.5,.75)),w("TriangleDown",(n,o,r)=>new Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,0)).add(new PathSegment(2,.5*o,r).close())).setSpots(.25,0,.75,.5)),w("TriangleLeft",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,o,0).close())).setSpots(.5,.25,1,.75)),w("TriangleUp",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,r)).add(new PathSegment(2,.5*o,0).close())).setSpots(.25,.5,.75,1)),w("Triangle","TriangleUp"),w("Diamond",(n,o,r)=>new Geometry().add(new PathFigure(.5*o,0).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,.5*o,r)).add(new PathSegment(2,o,.5*r).close())).setSpots(.25,.25,.75,.75)),w("LineH",(n,o,r)=>{const l=new Geometry(1);return l.startX=0,l.startY=r/2,l.endX=o,l.endY=r/2,l}),w("LineV",(n,o,r)=>{const l=new Geometry(1);return l.startX=o/2,l.startY=0,l.endX=o/2,l.endY=r,l}),w("None","Rectangle"),w("BarH","Rectangle"),w("BarV","Rectangle"),w("MinusLine","LineH"),w("PlusLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r/2,!1).add(new PathSegment(2,o,r/2)).add(new PathSegment(1,o/2,0)).add(new PathSegment(2,o/2,r)))),w("XLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r,!1).add(new PathSegment(2,o,0)).add(new PathSegment(1,0,0)).add(new PathSegment(2,o,r)))),w("LineRight",(n,o,r)=>new Geometry().add(new PathFigure(.25*o,0,!1).add(new PathSegment(2,.75*o,.5*r)).add(new PathSegment(2,.25*o,r)))),w("LineDown",(n,o,r)=>new Geometry().add(new PathFigure(0,.25*r,!1).add(new PathSegment(2,.5*o,.75*r)).add(new PathSegment(2,o,.25*r)))),w("LineLeft",(n,o,r)=>new Geometry().add(new PathFigure(.75*o,0,!1).add(new PathSegment(2,.25*o,.5*r)).add(new PathSegment(2,.75*o,r)))),w("LineUp",(n,o,r)=>new Geometry().add(new PathFigure(0,.75*r,!1).add(new PathSegment(2,.5*o,.25*r)).add(new PathSegment(2,o,.75*r)))),w("Capsule",(n,o,r)=>{const l=new Geometry;if(or){const h=r/2,a=new PathFigure(h,0,!0);l.add(a),a.add(new PathSegment(2,o-h,0)),a.add(new PathSegment(5,270,180,o-h,h,h,h)),a.add(new PathSegment(2,h,r)),a.add(new PathSegment(5,90,180,h,h,h,h));const c=isFinite(n.parameter1)?n.parameter1:r*.156;return l.spot1=new Spot(0,0,c,0),l.spot2=new Spot(1,1,-c,0),l}else return l.type=3,l.endX=o,l.endY=r,l.spot1=Spot.Rk,l.spot2=Spot.vk,l});const i=(n,o)=>new PathFigure(n,o,!1,!1),e=(n,o,r)=>n.add(new PathSegment(2,o,r)),s=(n,o,r)=>n.add(new PathSegment(1,o,r));w("Borders",(n,o,r)=>{let l=n?n.parameter1:NaN;isNaN(l)?l=10:l=l&15;const h=new Geometry;let a;return l===10?(a=i(o,0),e(a,o,r),s(a,0,r),e(a,0,0)):l===5?(a=i(0,0),e(a,o,0),s(a,o,r),e(a,0,r)):l===1?(a=i(0,0),e(a,o,0),s(a,o,r)):l===2?(a=i(o,0),e(a,o,r)):l===4?(a=i(o,r),e(a,0,r)):l===8?(a=i(0,r),e(a,0,0),s(a,o,r)):l===3?(a=i(0,0),e(a,o,0),e(a,o,r)):l===6?(a=i(o,0),e(a,o,r),e(a,0,r)):l===12?(a=i(o,r),e(a,0,r),e(a,0,0)):l===9?(a=i(0,r),e(a,0,0),e(a,o,0)):l===7?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r)):l===14?(a=i(o,0),e(a,o,r),e(a,0,r),e(a,0,0)):l===13?(a=i(o,r),e(a,0,r),e(a,0,0),e(a,o,0)):l===11?(a=i(0,r),e(a,0,0),e(a,o,0),e(a,o,r)):l===15?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r),a.add(new PathSegment(2,0,0).close())):(a=i(0,0),s(a,o,r)),h.add(a),h})}Geo.Xg={"":"",Standard:"F1 m 0,0 l 8,4 -8,4 2,-4 z",Backward:"F1 m 8,0 l -2,4 2,4 -8,-4 z",Triangle:"F1 m 0,0 l 8,4.62 -8,4.62 z",BackwardTriangle:"F1 m 8,4 l 0,4 -8,-4 8,-4 0,4 z",Boomerang:"F1 m 0,0 l 8,4 -8,4 4,-4 -4,-4 z",BackwardBoomerang:"F1 m 8,0 l -8,4 8,4 -4,-4 4,-4 z",SidewaysV:"m 0,0 l 8,4 -8,4 0,-1 6,-3 -6,-3 0,-1 z",BackwardV:"m 8,0 l -8,4 8,4 0,-1 -6,-3 6,-3 0,-1 z",OpenTriangle:"m 0,0 l 8,4 -8,4",BackwardOpenTriangle:"m 8,0 l -8,4 8,4",OpenTriangleLine:"m 0,0 l 8,4 -8,4 m 8.5,0 l 0,-8",BackwardOpenTriangleLine:"m 8,0 l -8,4 8,4 m -8.5,0 l 0,-8",OpenTriangleTop:"m 0,0 l 8,4 m 0,4",BackwardOpenTriangleTop:"m 8,0 l -8,4 m 0,4",OpenTriangleBottom:"m 0,8 l 8,-4",BackwardOpenTriangleBottom:"m 0,4 l 8,4",HalfTriangleTop:"F1 m 0,0 l 0,4 8,0 z m 0,8",BackwardHalfTriangleTop:"F1 m 8,0 l 0,4 -8,0 z m 0,8",HalfTriangleBottom:"F1 m 0,4 l 0,4 8,-4 z",BackwardHalfTriangleBottom:"F1 m 8,4 l 0,4 -8,-4 z",ForwardSemiCircle:"m 4,0 b 270 180 0 4 4",BackwardSemiCircle:"m 4,8 b 90 180 0 -4 4",Feather:"m 0,0 l 3,4 -3,4",BackwardFeather:"m 3,0 l -3,4 3,4",DoubleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardDoubleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4",TripleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardTripleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4 m 3,-8 l -3,4 3,4",ForwardSlash:"m 0,8 l 5,-8",BackSlash:"m 0,0 l 5,8",DoubleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8",DoubleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8",TripleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8 m -2,8 l 4,-8",TripleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8 m -2,-8 l 4,8",Fork:"m 0,4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4",LineFork:"m 0,0 l 0,8 m 0,-4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardLineFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4 m 8,-8 l 0,8",CircleFork:"F1 m 6,4 b 0 360 -3 0 3 z m 0,0 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 6,0 b 0 360 -3 0 3",CircleLineFork:"F1 m 6,4 b 0 360 -3 0 3 z m 1,-4 l 0,8 m 0,-4 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleLineFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 0,-4 l 0,8 m 7,-4 b 0 360 -3 0 3",Circle:"F1 m 8,4 b 0 360 -4 0 4 z",Block:"F1 m 0,0 l 0,8 8,0 0,-8 z",StretchedDiamond:"F1 m 0,3 l 5,-3 5,3 -5,3 -5,-3 z",Diamond:"F1 m 0,4 l 4,-4 4,4 -4,4 -4,-4 z",Chevron:"F1 m 0,0 l 5,0 3,4 -3,4 -5,0 3,-4 -3,-4 z",StretchedChevron:"F1 m 0,0 l 8,0 3,4 -3,4 -8,0 3,-4 -3,-4 z",NormalArrow:"F1 m 0,2 l 4,0 0,-2 4,4 -4,4 0,-2 -4,0 z",X:"m 0,0 l 8,8 m 0,-8 l -8,8",TailedNormalArrow:"F1 m 0,0 l 2,0 1,2 3,0 0,-2 2,4 -2,4 0,-2 -3,0 -1,2 -2,0 1,-4 -1,-4 z",DoubleTriangle:"F1 m 0,0 l 4,4 -4,4 0,-8 z m 4,0 l 4,4 -4,4 0,-8 z",BigEndArrow:"F1 m 0,0 l 5,2 0,-2 3,4 -3,4 0,-2 -5,2 0,-8 z",ConcaveTailArrow:"F1 m 0,2 h 4 v -2 l 4,4 -4,4 v -2 h -4 l 2,-2 -2,-2 z",RoundedTriangle:"F1 m 0,1 a 1,1 0 0 1 1,-1 l 7,3 a 0.5,1 0 0 1 0,2 l -7,3 a 1,1 0 0 1 -1,-1 l 0,-6 z",SimpleArrow:"F1 m 1,2 l -1,-2 2,0 1,2 -1,2 -2,0 1,-2 5,0 0,-2 2,2 -2,2 0,-2 z",AccelerationArrow:"F1 m 0,0 l 0,8 0.2,0 0,-8 -0.2,0 z m 2,0 l 0,8 1,0 0,-8 -1,0 z m 3,0 l 2,0 2,4 -2,4 -2,0 0,-8 z",BoxArrow:"F1 m 0,0 l 4,0 0,2 2,0 0,-2 2,4 -2,4 0,-2 -2,0 0,2 -4,0 0,-8 z",TriangleLine:"F1 m 8,4 l -8,-4 0,8 8,-4 z m 0.5,4 l 0,-8",CircleEndedArrow:"F1 m 10,4 l -2,-3 0,2 -2,0 0,2 2,0 0,2 2,-3 z m -4,0 b 0 360 -3 0 3 z",DynamicWidthArrow:"F1 m 0,3 l 2,0 2,-1 2,-2 2,4 -2,4 -2,-2 -2,-1 -2,0 0,-2 z",EquilibriumArrow:"m 0,3 l 8,0 -3,-3 m 3,5 l -8,0 3,3",FastForward:"F1 m 0,0 l 3.5,4 0,-4 3.5,4 0,-4 1,0 0,8 -1,0 0,-4 -3.5,4 0,-4 -3.5,4 0,-8 z",Kite:"F1 m 0,4 l 2,-4 6,4 -6,4 -2,-4 z",HalfArrowTop:"F1 m 0,0 l 4,4 4,0 -8,-4 z m 0,8",HalfArrowBottom:"F1 m 0,8 l 4,-4 4,0 -8,4 z",OpposingDirectionDoubleArrow:"F1 m 0,4 l 2,-4 0,2 4,0 0,-2 2,4 -2,4 0,-2 -4,0 0,2 -2,-4 z",PartialDoubleTriangle:"F1 m 0,0 4,3 0,-3 4,4 -4,4 0,-3 -4,3 0,-8 z",LineCircle:"F1 m 0,0 l 0,8 m 7 -4 b 0 360 -3 0 3 z",DoubleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",TripleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",CircleLine:"F1 m 6 4 b 0 360 -3 0 3 z m 1,-4 l 0,8",DiamondCircle:"F1 m 8,4 l -4,4 -4,-4 4,-4 4,4 m 8,0 b 0 360 -4 0 4 z",PlusCircle:"F1 m 8,4 b 0 360 -4 0 4 l -8 0 z m -4 -4 l 0 8",OpenRightTriangleTop:"m 8,0 l 0,4 -8,0 m 0,4",OpenRightTriangleBottom:"m 8,8 l 0,-4 -8,0",Line:"m 0,0 l 0,8",DoubleLine:"m 0,0 l 0,8 m 2,0 l 0,-8",TripleLine:"m 0,0 l 0,8 m 2,0 l 0,-8 m 2,0 l 0,8",PentagonArrow:"F1 m 8,4 l -4,-4 -4,0 0,8 4,0 4,-4 z"};var LayoutConditions=(w=>(w[w.None=0]="None",w[w.Added=1]="Added",w[w.Removed=2]="Removed",w[w.Shown=4]="Shown",w[w.Hidden=8]="Hidden",w[w.NodeSized=16]="NodeSized",w[w.GroupLayout=32]="GroupLayout",w[w.NodeReplaced=64]="NodeReplaced",w[w.Standard=127]="Standard",w[w.All=16777215]="All",w))(LayoutConditions||{});class Part extends Panel{P;Ho;F;ll;hl;qo;hi;Wo;ph;js;Jo;Cd;BS;UA;Up;Vp;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.P=2408959,this.Ho="",this.F=null,this.ll="",this.hl=null,this.qo=null,this.hi="",this.Wo=null,this.ph=null,this.js=new Point(NaN,NaN).g(),this.Jo=null,this.Cd=NaN,this.BS=-1,this.UA=new Rect,this.Up=null,this.Vp=NaN,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.P=this.P&-4097|16384|32768,t.Ho=this.Ho,this.F!==null&&(this.F.gi?t.F=this.F:t.F=this.F.copy()),t.ll=this.ll,t.qo=null,t.hi=this.hi,t.js.a(this.js),t.Cd=this.Cd}Vo(t){super.Vo(t),t.ch(),t.hl=null,t.Jo=null,t.Up=null}toString(){let t=Util.sn(this.constructor)+"#"+GSet.as(this);return this.data!==null&&(t+="("+Util.toString(this.data)+")"),t}static LayoutNone=0;static LayoutAdded=1;static LayoutRemoved=2;static LayoutShown=4;static LayoutHidden=8;static LayoutNodeSized=16;static LayoutGroupLayout=32;static LayoutNodeReplaced=64;static LayoutStandard=127;static LayoutAll=16777215;qi(){this.F===null?this.F=new PartTemplateSettings:this.F.gi&&(this.F=this.F.copy())}lh(){super.lh(),this.F!==null&&(this.F.gi=!0)}Jc(t,i,e,s,n,o,r){const l=this.diagram;l!==null&&(t===3&&i==="elements"?n instanceof Panel?n.qr(h=>{l.partManager.SM(h,l)}):n instanceof Picture&&l.TM(n):t===4&&i==="elements"&&(n instanceof Panel?n.qr(h=>l.partManager.MM(h,l)):n instanceof Picture&&l.DM(n)),l.raiseChangedEvent(t,i,e,s,n,o,r))}updateTargetBindings(t){if(super.updateTargetBindings(t),this.data===null)return;const i=this.L.r,e=i.length;for(let n=0;n{r.data!==null&&r.updateTargetBindings()})}const s=this.adornments;for(;s.next();)s.value.updateTargetBindings(t)}Io(){if(super.Io(),this.d2()){const i=this.L.r,e=i.length;for(let s=0;so.Io())}}const t=this.adornments;for(;t.next();)t.value.Io()}updateRelationshipsFromData(){this.data!==null&&this.diagram?.partManager.updateRelationshipsFromData(this)}get key(){const t=this.diagram;if(t!==null)return t.model.getKeyForNodeData(this.data)}get adornments(){return this.qo===null?EmptyIterator.instance:this.qo.iteratorValues}findAdornment(t){const i=this.qo;return i===null?null:i.get(t)}addAdornment(t,i){if(i===null)return;let e=null,s=this.qo;if(s!==null&&(e=s.get(t)),e!==i){if(e!==null){const o=e.diagram;o!==null&&o.remove(e)}s===null&&(s=new GMap,this.qo=s),i.Ho!==t&&(i.category=t),s.set(t,i);const n=this.diagram;if(n!==null){n.add(i);const o=i.adornedObject;if(o!==null){const r=o.findBindingPanel();r!==null&&(i.data=r.data)}}}}removeAdornment(t){const i=this.qo;if(i===null)return;const e=i.get(t);if(e!==null){const s=e.diagram;s!==null&&(s.remove(e),e.data=null)}i.delete(t),i.count===0&&(this.qo=null)}clearAdornments(){const t=this.qo;if(t===null)return;const i=Util.nt(),e=t.iterator;for(;e.next();){const n=e.key;i.push(n)}const s=i.length;for(let n=0;n{e.isEnabled&&e.updateAdornments(i)}),t.toolManager.updateAdornments(i)}IS(t){this.Wo=t,t===null&&this.DR()}get layer(){return this.Wo}get diagram(){const t=this.Wo;return t==null?null:t.diagram}get layerName(){return this.ll}set layerName(t){const i=this.ll;if(i===t)return;Util.i(t,"string",Part,"layerName");let e=this.diagram;if(e!==null&&(e.findLayer(t)===null||e.partManager.addsToTemporaryLayer))return;this.ll=t,e!==null&&e.invalidateDocumentBounds(),this.t("layerName",i,t);const s=this.layer;if(s===null||s.name===t||(e=s.diagram,e===null))return;const n=e.findLayer(t);if(n===null||n===s)return;let o=s.te(-1,this,!0);o>=0&&e.raiseChangedEvent(4,"parts",s,this,null,o,!0),o=n.qh(99999999,this,!0),s.visible!==n.visible&&this.Ei(n.visible),o>=0&&e.raiseChangedEvent(3,"parts",n,null,this,!0,o);const r=this.layerChanged;if(r===null)return;const l=e.Y;e.Y=!0,r(this,s,n),e.Y=l}get layerChanged(){return this.F!==null?this.F.zp:null}set layerChanged(t){const i=this.layerChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"layerChanged"),this.qi(),this.F.zp=t,this.t("layerChanged",i,t))}get zOrder(){return this.Cd}set zOrder(t){const i=this.Cd;if(i===t)return;Util.i(t,"number",Part,"zOrder"),this.Cd=t;const e=this.layer;e!==null&&e.yx(-1,this),this.t("zOrder",i,t);const s=this.diagram;s!==null&&s.C()}Ov(){const t=this.layer;t!==null&&t.yx(-1,this)}o1(){if(this.th()!==!1)return;this.K2(!0),this._u();const t=this.diagram;t!==null&&(t.o0(this),t.requestUpdate())}XA(){if(this.P|=2097152,this.th()===!1)return;const t=this.position,i=this.location;(!i.isReal()||!t.isReal())&&this.KA(t,i);const e=this.Li,s=Rect.l().a(e);e.ot(),e.x=t.x,e.y=t.y,e.g(),this.td(s,e),Rect.s(s),this.K2(!1)}Qn(t,i,e,s){const n=this.se;n.e(t,i,e,s),this.bi===null&&(this.bi=new Transform);const o=this.bi;o.Ri(),this.p0(o,t,i,e,s),this.bi=o,o.Ok()||o.xw(n)}p0(t,i,e,s,n){if(this.et!==1&&t.et(this.et),this.Xt===0)return;let o=Spot.Center;this.locationSpot.isSpot()&&(o=this.locationSpot);const r=Point.l();if(this.locationObject!==this){const l=this.locationObject,h=l.naturalBounds;r.setSpot(h.x,h.y,h.width,h.height,o),l.bi!==null&&l.bi.xt(r),r.offset(-l.measuredBounds.x,-l.measuredBounds.y);let a=l.panel;for(;a!==null&&a!==this;)a.bi!==null&&a.bi.xt(r),r.offset(-a.measuredBounds.x,-a.measuredBounds.y),a=a.panel}else r.setSpot(i,e,s,n,o);t.cs(this.Xt,r.x,r.y),Point.s(r)}get locationObject(){if(this.Jo===null)if(this instanceof Adornment&&this.type!==Panel.Link&&this.hasPlaceholder())this.Jo=this.placeholder;else{const t=this.locationObjectName;if(t!==""){const i=this.findObject(t);i!==null?this.Jo=i:this.Jo=this}else this.Jo=this}return this.Jo.visible?this.Jo:this}get minLocation(){return this.F!==null?this.F.Xp:Point.$N}set minLocation(t){const i=this.minLocation;i.equals(t)||(t=t.N(),this.qi(),this.F.Xp=t,this.t("minLocation",i,t))}get maxLocation(){return this.F!==null?this.F.Kp:Point.ZN}set maxLocation(t){const i=this.maxLocation;i.equals(t)||(t=t.N(),this.qi(),this.F.Kp=t,this.t("maxLocation",i,t))}get locationObjectName(){return this.F!==null?this.F.Yp:""}set locationObjectName(t){const i=this.locationObjectName;i!==t&&(this.qi(),this.F.Yp=t,this.Jo=null,this.c(),this.t("locationObjectName",i,t))}get locationSpot(){return this.F!==null?this.F.Gp:Spot.TopLeft}set locationSpot(t){const i=this.locationSpot;i.equals(t)||(t=t.N(),this.qi(),this.F.Gp=t,this.c(),this.t("locationSpot",i,t))}move(t,i){i===!0?this.location=t:this.position=t}moveTo(t,i,e){const s=Point.X(t,i);this.move(s,e),Point.s(s)}isVisible(){if(!this.visible)return!1;const t=this.layer;if(t!==null){if(!t.visible)return!1;const e=t.diagram;if(e!==null&&e.animationManager.nx(this))return!0}const i=this.containingGroup;return!(i!==null&&(!i.isSubGraphExpanded||!i.isVisible()))}Ei(t){const i=this.diagram;t?(this.invalidateLayout(4),this.invalidateAdornments(),i!==null&&i.o0(this)):(this.invalidateLayout(8),this.clearAdornments()),this.ch(),i!==null&&(i.invalidateDocumentBounds(),i.C())}findObject(t){if(this.name===t)return this;let i=this.Up;if(i===null&&(this.Up=i=new GMap),i.get(t)!==null)return i.get(t);const e=super.findObject(t);return e!==null?(i.set(t,e),e):(i.set(t,null),null)}D0(){this.Up=null}getRelativePoint(t,i,e){e===void 0&&(e=new Point);const s=i.isNoSpot()?Spot.Center:i,n=t.naturalBounds;if(e.e(n.width*s.x+s.offsetX,n.height*s.y+s.offsetY),t===null||t===this)return e;t.D.xt(e);let o=t.panel;for(;o!==null&&o!==this;)o.D.xt(e),o=o.panel;return this.bi!==null&&this.bi.xt(e),e.offset(-this.se.x,-this.se.y),e}getDocumentBounds(t){return t===void 0&&(t=new Rect),t.a(this.actualBounds)}ensureBounds(){this.ut(1/0,1/0),this.zt()}pA(t){const i=this.locationSpot,e=this.locationObject;let s=e.naturalBounds;s.isReal()||(s=Rect.pw);const n=e instanceof Shape?e.strokeWidth:0;if(t.setSpot(0,0,s.width+n,s.height+n,i),e!==this){t.offset(-n/2,-n/2),e.D.xt(t);let o=e.panel;for(;o!==null&&o!==this;)o.D.xt(t),o=o.panel}return this.bi!==null&&this.bi.xt(t),t.offset(-this.se.x,-this.se.y),t}Hh(t,i){const e=i===void 0?this.UA:i,s=this.Iv(),n=s*2;if(!this.isShadowed)return e.e(t.x-1-s,t.y-1-s,t.width+2+n,t.height+2+n),e;let o=t.x,r=t.y,l=t.width,h=t.height;const a=this.shadowBlur,c=this.shadowOffset;return l+=a,h+=a,o-=a/2,r-=a/2,c.x>0?l+=c.x:(o+=c.x,l-=c.x),c.y>0?h+=c.y:(r+=c.y,h-=c.y),e.e(o-1,r-1,l+2,h+2),e}yv(){return this.type===Panel.Link&&this instanceof Adornment&&this.category==="Selection"&&this.adornedObject instanceof Shape&&this.adornedPart.findMainElement()===this.adornedObject?this.adornedObject.strokeWidth:0}Iv(){return isNaN(this.Vp)&&(this.Vp=this.SA()),this.Vp}cf(){this.Vp=NaN}zt(){if(this.is()===!1){this.XA();return}this._n(!1);const t=this.Li,i=Rect.l();i.a(t);const e=this.Nl();this.ah(0,0,this.se.width,this.se.height);const s=this.position;this.KA(s,this.location),t.ot(),t.x=s.x,t.y=s.y,t.g(),this.td(i,t),i.equals(t)?this.Bs(e):this.Pe()&&(!Geo.u(i.width,t.width)||!Geo.u(i.height,t.height))&&this.BS>=0&&this.invalidateLayout(16),Rect.s(i),this.K2(!1)}td(t,i){const e=this.diagram;if(e===null)return;let s=!1;if(e.Zh===!1&&t.isReal()){const n=Rect.l();n.a(e.documentBounds),n.subtractMargin(e.padding),t.x>n.x&&t.y>n.y&&t.rightn.x&&i.y>n.y&&i.right=o)return}}this.P=this.P^4096;let s=!1;if(e!==null){s=e.skipsUndoManager,e.skipsUndoManager=!0;const o=e.selection;o.ot(),t?o.add(this):o.delete(this),o.g()}this.t("isSelected",i,t),this.invalidateAdornments();const n=this.selectionChanged;n!==null&&n(this),e!==null&&(e.requestUpdate(),e.skipsUndoManager=s)}}get isHighlighted(){return(this.P&524288)!==0}set isHighlighted(t){const i=(this.P&524288)!==0;if(i!==t){this.P=this.P^524288;const e=this.diagram;if(e!==null){const n=e.highlighteds;n.ot(),t?n.add(this):n.delete(this),n.g()}this.t("isHighlighted",i,t),this.C();const s=this.highlightedChanged;s!==null&&s(this)}}get isShadowed(){return(this.P&8192)!==0}set isShadowed(t){const i=(this.P&8192)!==0;i!==t&&(this.P=this.P^8192,this.ss(!0),this.t("isShadowed",i,t),this.C())}VA(){return(this.P&16384)!==0}zA(t){t?this.P|=16384:this.P&=-16385}th(){return(this.P&32768)!==0}K2(t){t?this.P|=32768:this.P&=-32769}Ev(){return(this.P&65536)!==0}s2(t){t?this.P|=65536:this.P&=-65537}Nl(){return(this.P&131072)!==0}Bs(t){t?this.P|=131072:this.P&=-131073}qA(){return(this.P&1048576)!==0}l1(t){t?this.P|=1048576:this.P&=-1048577}get isAnimated(){return(this.P&262144)!==0}set isAnimated(t){const i=(this.P&262144)!==0;i!==t&&(this.P=this.P^262144,this.t("isAnimated",i,t))}get highlightedChanged(){return this.F!==null?this.F.jp:null}set highlightedChanged(t){const i=this.highlightedChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"highlightedChanged"),this.qi(),this.F.jp=t,this.t("highlightedChanged",i,t))}get selectionObjectName(){return this.F!==null?this.F.Hp:""}set selectionObjectName(t){const i=this.selectionObjectName;i!==t&&(this.qi(),this.F.Hp=t,this.hl=null,this.t("selectionObjectName",i,t))}get selectionAdornmentTemplate(){return this.F!==null?this.F.qp:null}set selectionAdornmentTemplate(t){const i=this.selectionAdornmentTemplate;i!==t&&(this.qi(),this.F.qp=t,this.t("selectionAdornmentTemplate",i,t))}get selectionObject(){if(this.hl===null){const t=this.selectionObjectName;if(t!==null&&t!==""){const i=this.findObject(t);i!==null?this.hl=i:this.hl=this}else if(this instanceof Link){const i=this.path;i!==null?this.hl=i:this.hl=this}else this.hl=this}return this.hl}get selectionChanged(){return this.F!==null?this.F.Wp:null}set selectionChanged(t){const i=this.selectionChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"selectionChanged"),this.qi(),this.F.Wp=t,this.t("selectionChanged",i,t))}get resizeAdornmentTemplate(){return this.F!==null?this.F.Jp:null}set resizeAdornmentTemplate(t){const i=this.resizeAdornmentTemplate;i!==t&&(this.qi(),this.F.Jp=t,this.t("resizeAdornmentTemplate",i,t))}get resizeObjectName(){return this.F!==null?this.F.$p:""}set resizeObjectName(t){const i=this.resizeObjectName;i!==t&&(this.qi(),this.F.$p=t,this.t("resizeObjectName",i,t))}get resizeObject(){const t=this.resizeObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get resizeCellSize(){return this.F!==null?this.F.Zp:Size.gw}set resizeCellSize(t){const i=this.resizeCellSize;i.equals(t)||(t=t.N(),this.qi(),this.F.Zp=t,this.t("resizeCellSize",i,t))}get rotateAdornmentTemplate(){return this.F!==null?this.F.Qp:null}set rotateAdornmentTemplate(t){const i=this.rotateAdornmentTemplate;i!==t&&(this.qi(),this.F.Qp=t,this.t("rotateAdornmentTemplate",i,t))}get rotateObjectName(){return this.F!==null?this.F._p:""}set rotateObjectName(t){const i=this.rotateObjectName;i!==t&&(this.qi(),this.F._p=t,this.t("rotateObjectName",i,t))}get rotateObject(){const t=this.rotateObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get rotationSpot(){return this.F!==null?this.F.ty:Spot.Default}set rotationSpot(t){const i=this.rotationSpot;i.equals(t)||(t=t.N(),this.qi(),this.F.ty=t,this.t("rotationSpot",i,t))}get text(){return this.hi}set text(t){const i=this.hi;i!==t&&(this.hi=t,this.t("text",i,t))}get containingGroup(){return this.ph}set containingGroup(t){if(this.Pe()){const i=this.ph;if(i!==t){t!==null&&(this===t||t.isMemberOf(this))&&(this===t&&Util.o("Cannot make a Group a member of itself: "+this.toString()),Util.o("Cannot make a Group indirectly contain itself: "+this.toString()+" already contains "+t.toString())),this.invalidateLayout(2);const e=this.diagram;if(i!==null?i.G2(this):this instanceof Group&&e!==null&&e.Yr.delete(this),this.ph=t,t!==null?t.j2(this):this instanceof Group&&e!==null&&e.Yr.add(this),this.invalidateLayout(1),e!==null&&e.Y){const n=this.data,o=e.model;if(n!==null&&o.qc()){const r=t!==null?t.data:null;o.setGroupForData(n,o.getKeyForNodeData(r))}}const s=this.containingGroupChanged;if(s!==null){let n=!0;e!==null&&(n=e.Y,e.Y=!0),s(this,i,t),e!==null&&(e.Y=n)}if(this instanceof Group){const n=new GSet;Part.sh(n,this,!0,0,!0);const o=n.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=r.linksConnected;for(;l.next();)l.value.Ld()}}}if(this instanceof Node){const n=this.linksConnected;for(;n.next();)n.value.Ld();const o=this.labeledLink;o!==null&&o.Ld()}this.t("containingGroup",i,t),t!==null&&t.Ov()}}else Util.o("cannot set the Part.containingGroup of a Link or Adornment")}ch(){const t=this.containingGroup;t!==null&&(t.hasPlaceholder()&&t.placeholder.c(),t.c(),t.invalidateConnectedLinks())}C(){const t=this.diagram;t!==null&&!this.is()&&!this.th()&&this.isVisible()&&this.Li.isReal()&&t.C(this.Hh(this.Li))}c(){if(this.Oo())return;super.c();const t=this.diagram;t!==null&&(t.o0(this),this instanceof Node&&this.labeledLink!==null&&this.labeledLink.ef(),t.requestUpdate(!0))}ef(t){if(this.is())return;const i=this.diagram;i!==null&&(i.o0(this),this instanceof Node&&this.invalidateConnectedLinks(),i.requestUpdate()),this._n(!0)}Em(t){if(!t){const i=this.ph;i!==null&&i.j2(this)}}Bm(t){if(!t){const i=this.ph;i!==null&&i.G2(this)}}Kc(){const t=this.data;if(t!==null){const i=this.diagram;if(i!==null){const e=i.model;e!==null&&e.removeNodeData(t)}}}get containingGroupChanged(){return this.F!==null?this.F.iy:null}set containingGroupChanged(t){const i=this.containingGroupChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"containingGroupChanged"),this.qi(),this.F.iy=t,this.t("containingGroupChanged",i,t))}findSubGraphLevel(){return this.H2(this)}H2(t){const i=t.containingGroup;if(i!==null)return 1+this.H2(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.H2(e)}return 0}findTopLevelPart(){return this.q2(this)}q2(t){const i=t.containingGroup;if(i!==null)return this.q2(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.q2(e)}return t}get isTopLevel(){return!(this.containingGroup!==null||this instanceof Node&&this.labeledLink!==null)}isMemberOf(t){return t instanceof Group?this.W2(this,t):!1}W2(t,i){if(t===i||i===null)return!1;const e=t.containingGroup;if(e!==null&&(e===i||this.W2(e,i)))return!0;if(t instanceof Node){const s=t.labeledLink;if(s!==null)return this.W2(s,i)}return!1}findCommonContainingGroup(t){if(t===null)return null;if(this===t)return this.containingGroup;let i=this;for(;i!==null;){if(i instanceof Group&&i.l1(!0),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}let e=null;for(i=t;i!==null;){if(i.qA()){e=i;break}if(i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}for(i=this;i!==null;){if(i instanceof Group&&i.l1(!1),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}return e}get layoutConditions(){return this.F!==null?this.F.ey:127}set layoutConditions(t){const i=this.layoutConditions;i!==t&&(this.qi(),this.F.ey=t,this.t("layoutConditions",i,t))}canLayout(){if(!this.isLayoutPositioned||!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary||this instanceof Node&&this.isLinkLabel)}Uv(t){if(!this.isLayoutPositioned||!(t&this.layoutConditions))return!1;const i=this.layer;if(i!==null&&i.isTemporary||this instanceof Node&&this.isLinkLabel)return!1;const e=this.diagram;return!(e!==null&&e.undoManager.isUndoingRedoing)}invalidateLayout(t){if(t===void 0&&(t=16777215),!this.Uv(t))return;const i=this.ph;if(i!==null){const e=i.layout;e!==null?e.invalidateLayout():i.invalidateLayout(t)}else{const e=this.diagram;if(e!==null){const s=e.layout;s!==null&&s.invalidateLayout()}}}NL(){if(!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary)}static sh(t,i,e,s,n,o){if(o===void 0&&(o=null),!t.has(i)&&!(o!==null&&!o(i))&&!(i instanceof Adornment)){if(t.add(i),i instanceof Node){if(e&&i instanceof Group){const r=i.memberParts;for(;r.next();){const l=r.value;Part.sh(t,l,e,s,n,o)}}if(n!==!1){const r=i.linksConnected;for(;r.next();){const l=r.value;if(t.has(l))continue;const h=l.fromNode,a=l.toNode,c=h===null||t.has(h),f=a===null||t.has(a);(n?c&&f:c||f)&&Part.sh(t,l,e,s,n,o)}}if(s>1){const r=i.findTreeChildrenNodes();for(;r.next();){const l=r.value;Part.sh(t,l,e,s-1,n,o)}}}else if(i instanceof Link){const r=i.labelNodes;for(;r.next();){const l=r.value;Part.sh(t,l,e,s,n,o)}}}}get dragComputation(){return this.F!==null?this.F.sy:null}set dragComputation(t){const i=this.dragComputation;i!==t&&(t!==null&&Util.i(t,"function",Part,"dragComputation"),this.qi(),this.F.sy=t,this.t("dragComputation",i,t))}get shadowOffset(){return this.F!==null?this.F.ny:Point.QN}set shadowOffset(t){const i=this.shadowOffset;i.equals(t)||(t=t.N(),this.qi(),this.F.ny=t,this.C(),this.t("shadowOffset",i,t))}get shadowColor(){return this.F!==null?this.F.oy:"gray"}set shadowColor(t){const i=this.shadowColor;i!==t&&(this.qi(),this.F.oy=t,this.C(),this.t("shadowColor",i,t))}get shadowBlur(){return this.F!==null?this.F.xn:4}set shadowBlur(t){const i=this.shadowBlur;i!==t&&(this.qi(),this.F.xn=t,this.C(),this.t("shadowBlur",i,t))}}class PartTemplateSettings{gi;zp;iy;qp;Hp;Wp;jp;Jp;$p;Zp;Qp;_p;ty;Yp;Gp;Xp;Kp;sy;ey;ny;oy;xn;constructor(){this.gi=!1,this.zp=null,this.iy=null,this.qp=null,this.Hp="",this.Wp=null,this.jp=null,this.Jp=null,this.$p="",this.Zp=Size.gw,this.Qp=null,this._p="",this.ty=Spot.Default,this.Yp="",this.Gp=Spot.TopLeft,this.Xp=Point.$N,this.Kp=Point.ZN,this.sy=null,this.ey=127,this.ny=Point.QN,this.oy="gray",this.xn=4}copy(){const t=new PartTemplateSettings;return t.zp=this.zp,t.iy=this.iy,t.qp=this.qp,t.Hp=this.Hp,t.Wp=this.Wp,t.jp=this.jp,t.Jp=this.Jp,t.$p=this.$p,t.Zp=this.Zp.N(),t.Qp=this.Qp,t._p=this._p,t.ty=this.ty.N(),t.Yp=this.Yp,t.Gp=this.Gp.N(),t.Xp=this.Xp.N(),t.Kp=this.Kp.N(),t.sy=this.sy,t.ey=this.ey,t.ny=this.ny.N(),t.oy=this.oy,t.xn=this.xn,t}}class Adornment extends Part{us;It;JP;$P;hf;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.P&=-257,this.ll="Adornment",this.us=null,this.JP=0,this.$P=!1,this.It=null,this.hf=null,i&&Object.assign(this,i)}toString(){const t=this.adornedPart;return"Adornment("+this.category+")"+(t!==null?t.toString():"")}updateRelationshipsFromData(){}hd(t){const i=this.adornedObject,e=i?.part;if(!(e instanceof Link)||!(i instanceof Shape))return;const s=e.path;let n=s.geometry;e.hd(t),n=s.geometry;const o=this.L.r,r=o.length;for(let l=0;lh instanceof Placeholder);l instanceof Placeholder&&this.It===null&&(this.It=l)}}else t===4&&i==="elements"&&this.It!==null&&(s===this.It?this.It=null:s instanceof Panel&&this.It.isContainedBy(s)&&(this.It=null));super.Jc(t,i,e,s,n,o,r)}updateAdornments(){}Kc(){}}var PortSpreading=(w=>(w[w.None=0]="None",w[w.Evenly=1]="Evenly",w[w.Packed=2]="Packed",w))(PortSpreading||{});class Node extends Part{E;gt;kf;al;yh;ne;_t;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.E=13,this.gt=null,this._t=new List,this.kf=null,this.al=null,this.ne=null,this.yh=!1,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.E=this.E,this.gt!==null&&(this.gt.gi?t.gt=this.gt:t.gt=this.gt.copy())}Vo(t){super.Vo(t),t.invalidateConnectedLinks(),t.al=this.al,t.ne=null}static SpreadingNone=0;static SpreadingEvenly=1;static SpreadingPacked=2;cl(){this.gt===null?this.gt=new NodeTemplateSettings:this.gt.gi&&(this.gt=this.gt.copy())}lh(){super.lh(),this.gt!==null&&(this.gt.gi=!0)}WA(t){t!==null&&(this.al===null&&(this.al=new GSet),this.al.add(t))}JA(t){t!==null&&this.al!==null&&this.al.delete(t)}$A(t,i,e){if(t===null||this.al===null)return null;const s=this.al.iterator;for(;s.next();){const n=s.value;if(n.ry===this&&n.h1===t&&n.J2===i&&n.$2===e||n.ry===t&&n.h1===this&&n.J2===e&&n.$2===i)return n}return null}invalidateLinkBundle(t,i,e){i==null&&(i=""),e==null&&(e="");const s=this.$A(t,i,e);s!==null&&s.Ad()}Jc(t,i,e,s,n,o,r){t===3&&i==="elements"?this.ne=null:t===4&&i==="elements"&&(this.ne=null),super.Jc(t,i,e,s,n,o,r)}invalidateConnectedLinks(t){const i=this.linksConnected;for(;i.next();){const e=i.value;t!==void 0&&t.has(e)||(this.Wi(e.fromPort),this.Wi(e.toPort),e.invalidateRoute())}}tA(t){const i=this.linksConnected;for(;i.next();){const e=i.value;e.fromPort!==t&&e.toPort!==t||(this.Wi(e.fromPort),this.Wi(e.toPort),e.invalidateRoute())}}Wi(t){if(t===null)return;const i=t.Ju;i!==null&&i.Ad();const e=t.part,s=e.containingGroup;s!==null&&!e.isVisible()&&s.Wi(s.port)}Hr(){return!0}get portSpreading(){return this.gt!==null?this.gt.ly:1}set portSpreading(t){const i=this.portSpreading;if(i!==t){this.cl(),this.gt.ly=t,this.t("portSpreading",i,t);const e=this.diagram;if(e!==null&&e.undoManager.isUndoingRedoing)return;this.invalidateConnectedLinks()}}get avoidable(){return(this.E&8)!==0}set avoidable(t){const i=(this.E&8)!==0;if(i!==t){this.E=this.E^8;const e=this.diagram;e!==null&&e.EM(this),this.t("avoidable",i,t)}}get avoidableMargin(){return this.gt!==null?this.gt.hy:Margin.oC}set avoidableMargin(t){typeof t=="number"&&(t=new Margin(t));const i=this.avoidableMargin;if(!i.equals(t)){t=t.N(),this.cl(),this.gt.hy=t;const e=this.diagram;e!==null&&e.EM(this),this.t("avoidableMargin",i,t)}}canAvoid(){return this.avoidable&&!this.isLinkLabel}getAvoidableRect(t){return t.set(this.actualBounds),t.addMargin(this.avoidableMargin),t}findVisibleNode(){let t=this;for(;t!==null&&!t.isVisible();)t=t.containingGroup;return t}isVisible(){if(!super.isVisible())return!1;let t=!0,i=1;const e=this.diagram;if(e!==null){if(e.animationManager.nx(this))return!0;t=e.isTreePathToChildren,i=e.treeCollapsePolicy}if(i===1){const n=this.findTreeParentNode();if(n!==null&&!n.isTreeExpanded)return!1}else if(i===2){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&h.isTreeExpanded){r=!0;break}}}if(o&&!r)return!1}else if(i===3){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&!h.isTreeExpanded){r=!0;break}}}if(o&&r)return!1}const s=this.labeledLink;return s!==null?s.isVisible():!0}Ei(t){super.Ei(t);const i=this.linksConnected;for(;i.next();){const e=i.value;if(t&&this.containingGroup!==null){const s=e.getOtherNode(this);s!==null&&!s.isMemberOf(this.containingGroup)&&e.invalidateRoute()}e.Ei(t)}}get linksConnected(){return this._t.iterator}findExternalTreeLinksConnected(){const t=new GSet,i=new GSet;return this.ZA(this,t,i),i.iterator}ZA(t,i,e){if(t===null||i.has(t))return;i.add(t);let s=!0;const n=this.diagram;n!==null&&(s=n.isTreePathToChildren),t.linksConnected.each(o=>{o.isTreeLink?(s?o.fromNode===t:o.toNode===t)&&this.ZA(s?o.toNode:o.fromNode,i,e):e.add(o)})}findLinksConnected(t){if(t===void 0&&(t=null),t===null)return this._t.iterator;const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.fromNode===e&&s.fromPortId===t||s.toNode===e&&s.toPortId===t,i}findLinksOutOf(t){t===void 0&&(t=null);const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.fromNode!==e?!1:t===null?!0:s.fromPortId===t,i}findLinksInto(t){t===void 0&&(t=null);const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.toNode!==e?!1:t===null?!0:s.toPortId===t,i}findNodesConnected(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this){if(t===null||n.fromPortId===t){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}else if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesOutOf(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this&&(t===null||n.fromPortId===t)){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesInto(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findLinksBetween(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null);const s=new ListIterator(this._t),n=this;return s.predicate=o=>o.fromNode===n&&o.toNode===t&&(i===null||o.fromPortId===i)&&(e===null||o.toPortId===e)||o.fromNode===t&&o.toNode===n&&(e===null||o.fromPortId===e)&&(i===null||o.toPortId===i),s}findLinksTo(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null);const s=new ListIterator(this._t),n=this;return s.predicate=o=>!(o.fromNode!==n||o.toNode!==t||i!==null&&o.fromPortId!==i||e!==null&&o.toPortId!==e),s}get linkConnected(){return this.gt!==null?this.gt.ay:null}set linkConnected(t){const i=this.linkConnected;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkConnected"),this.cl(),this.gt.ay=t,this.t("linkConnected",i,t))}get linkDisconnected(){return this.gt!==null?this.gt.cy:null}set linkDisconnected(t){const i=this.linkDisconnected;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkDisconnected"),this.cl(),this.gt.cy=t,this.t("linkDisconnected",i,t))}get linkValidation(){return this.gt!==null?this.gt.Ml:null}set linkValidation(t){const i=this.linkValidation;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkValidation"),this.cl(),this.gt.Ml=t,this.t("linkValidation",i,t))}a1(t,i){this.Wi(i);const e=this._t.has(t);if(e||this._t.add(t),!e||t.fromNode===t.toNode){const s=this.linkConnected;if(s!==null){let n=!0;const o=this.diagram;o!==null&&(n=o.Y,o.Y=!0),s(this,t,i),o!==null&&(o.Y=n)}}if(!e){if(!t.isTreeLink)return;const s=t.fromNode,n=t.toNode;if(s!==null&&n!==null&&s!==n){let o=!0;const r=this.diagram;r!==null&&(o=r.isTreePathToChildren);const l=o?n:s,h=o?s:n;if(l.yh||(l.yh=h),h.isTreeLeaf){if(r!==null&&r.undoManager.isUndoingRedoing)return;o?s===h&&(h.isTreeLeaf=!1):n===h&&(h.isTreeLeaf=!1)}}}}c1(t,i){this.Wi(i);const e=this._t.delete(t);let s=null;if(e||t.toNode===t.fromNode){const n=this.linkDisconnected;if(s=this.diagram,n!==null){let o=!0;s!==null&&(o=s.Y,s.Y=!0),n(this,t,i),s!==null&&(s.Y=o)}}if(e){if(!t.isTreeLink)return;let n=!0;s!==null&&(n=s.isTreePathToChildren);const o=n?t.toNode:t.fromNode,r=n?t.fromNode:t.toNode;if(o!==null&&(o.yh=!1),r!==null&&!r.isTreeLeaf)if(r._t.count===0){if(r.yh=null,s!==null&&s.undoManager.isUndoingRedoing)return;r.isTreeLeaf=!0}else r.f0()}}f0(){if(this.yh=!1,this._t.count===0)return;let t=!0;const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;i!==null&&(t=i.isTreePathToChildren);const e=this._t.iterator;for(;e.next();){const s=e.value;if(s.isTreeLink){if(t){if(s.fromNode===this){this.isTreeLeaf=!1;return}}else if(s.toNode===this){this.isTreeLeaf=!1;return}}}this.isTreeLeaf=!0}updateRelationshipsFromData(){const t=this.diagram;t!==null&&t.partManager.updateRelationshipsFromData(this)}Em(t){if(super.Em(t),!t){this.f0();const i=this.kf;i!==null&&i.QA(this)}}Bm(t){if(super.Bm(t),!t){const i=this.kf;i!==null&&i._A(this)}}Kc(){if(this._t.count>0){const t=this.diagram;if(t!==null){const i=t.commandHandler!==null?t.commandHandler.deletesConnectedLinks:!0,s=this._t.copy().iterator;for(;s.next();){const n=s.value;i?t.remove(n):(n.fromNode===this&&(n.fromNode=null),n.toNode===this&&(n.toNode=null))}}}this.labeledLink=null,super.Kc()}get isLinkLabel(){return this.kf!==null}get labeledLink(){return this.kf}set labeledLink(t){const i=this.kf;if(i!==t){const e=this.diagram,s=this.data;if(i!==null){if(i._A(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=i.data,o=e.model;if(n!==null&&o.Ta()){const r=o.getKeyForNodeData(s);r!==void 0&&o.removeLabelKeyForLinkData(n,r)}}this.containingGroup=null}if(this.kf=t,t!==null){if(t.QA(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=t.data,o=e.model;if(n!==null&&o.Ta()){const r=o.getKeyForNodeData(s);r!==void 0&&o.addLabelKeyForLinkData(n,r)}}this.containingGroup=t.containingGroup}this.ef(),this.t("labeledLink",i,t)}}findVisiblePort(t){let i=t;for(;i!==null&&(!i.actualBounds.isReal()||!i.isVisibleObject());)i=i.panel;return i===null?this.port:i}findPort(t){if(this.ne===null){if(t===""&&this.wn===!1)return this;this.tT()}let i=this.ne.get(t);return i!==null||t!==""&&(i=this.ne.get(""),i!==null)?i:this}get port(){return this.findPort("")}get ports(){return this.ne===null&&this.tT(),this.ne.iteratorValues}tT(){this.ne===null?this.ne=new GMap:this.ne.clear(),this.walkVisualTreeFrom(this,(t,i)=>t.hA(i)),this.ne.count===0&&this.ne.set("",this)}hA(t){const i=t.portId;i!==null&&this.ne!==null&&this.ne.set(i,t)}u2(t,i){const e=t.portId;if(e!==null){this.ne!==null&&this.ne.delete(e);const s=this.diagram;if(s!==null&&i){let n=null;const o=this.findLinksConnected(e);for(;o.next();){const r=o.value;n===null&&(n=Util.nt()),n.push(r)}if(n!==null){for(let r=0;r!(!n.isTreeLink||n.fromNode!==s):e.predicate=n=>!(!n.isTreeLink||n.toNode!==s),e}findTreeChildrenNodes(){let t=!0;const i=this.diagram;i!==null&&(t=i.isTreePathToChildren);let e=null,s=null;const n=this._t.iterator;if(t)for(;n.next();){const o=n.value;if(o.isTreeLink&&o.fromNode===this){const r=o.toNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}else for(;n.next();){const o=n.value;if(o.isTreeLink&&o.toNode===this){const r=o.fromNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}return e!==null?e.iterator:s!==null?new SingletonIterator(s):EmptyIterator.instance}findTreeParts(t){t===void 0&&(t=1/0),Util.i(t,"number",Node,"findTreeParts:level");const i=new GSet;return Part.sh(i,this,!1,t,!0),i}collapseTree(t){t===void 0&&(t=1),t<1&&(t=1);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.iT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}iT(t,i,e,s,n,o){if(e>1){const r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);h!==null&&h!==this&&!t.has(h)&&(t.add(h),h.iT(t,i,e-1,s,n,o))}}else this.eT(t,i,s,n,o)}eT(t,i,e,s,n){const o=s===this?!0:this.isTreeExpanded,r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);if(h!==null&&h!==this){const a=t.has(h);if(a||t.add(h),o){const c=i?h.findNodesInto():h.findNodesOutOf(),f=this;c.all(u=>u===f||!u.isTreeExpanded)&&e.Lc(h,s),h.ch(),h.Ei(!1)}h.isTreeExpanded&&(h.wasTreeExpanded=h.isTreeExpanded,a||h.eT(t,i,e,s,n))}}this.isTreeExpanded=!1}expandTree(t){t===void 0&&(t=2),t<2&&(t=2);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.sT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}sT(t,i,e,s,n,o){const r=n===this?!1:this.isTreeExpanded,l=i?this.findLinksOutOf():this.findLinksInto();for(;l.next();){const h=l.value;if(!h.isTreeLink)continue;r||h.Me||h.invalidateRoute();const a=h.getOtherNode(this);if(a!==null&&a!==this&&!t.has(a)){if(t.add(a),!r){a.Ei(!0),a.ch();const c=i?a.findNodesInto():a.findNodesOutOf(),f=this;c.all(u=>u===f||!u.isTreeExpanded)&&s.Cc(a,n)}(e>2||a.wasTreeExpanded)&&(a.wasTreeExpanded=!1,a.sT(t,i,e-1,s,n,o))}}this.isTreeExpanded=!0}get isTreeExpanded(){return(this.E&1)!==0}set isTreeExpanded(t){const i=(this.E&1)!==0;if(i!==t){this.E=this.E^1;const e=this.diagram;this.t("isTreeExpanded",i,t);const s=this.treeExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.Y,e.Y=!0),s(this),e!==null&&(e.Y=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.Ei(t);return}t?this.expandTree():this.collapseTree()}}get wasTreeExpanded(){return(this.E&2)!==0}set wasTreeExpanded(t){const i=(this.E&2)!==0;i!==t&&(this.E=this.E^2,this.t("wasTreeExpanded",i,t))}get treeExpandedChanged(){return this.gt!==null?this.gt.fy:null}set treeExpandedChanged(t){const i=this.treeExpandedChanged;i!==t&&(t!==null&&Util.i(t,"function",Node,"treeExpandedChanged"),this.cl(),this.gt.fy=t,this.t("treeExpandedChanged",i,t))}get isTreeLeaf(){return(this.E&4)!==0}set isTreeLeaf(t){const i=(this.E&4)!==0;i!==t&&(this.E=this.E^4,this.t("isTreeLeaf",i,t))}get isTreeRoot(){return this.findTreeParentLink()===null}}class NodeTemplateSettings{gi;ay;cy;Ml;fy;hy;ly;uy;gy;eh;my;constructor(){this.gi=!1,this.ay=null,this.cy=null,this.Ml=null,this.fy=null,this.hy=Margin.oC,this.ly=1,this.uy=null,this.gy=null,this.eh=null,this.my=null}copy(){const t=new NodeTemplateSettings;return t.ay=this.ay,t.cy=this.cy,t.Ml=this.Ml,t.fy=this.fy,t.hy=this.hy.N(),t.ly=this.ly,t.uy=this.uy,t.gy=this.gy,t.eh=this.eh,t.my=this.my,t}}var LinkAdjusting=(w=>(w[w.None=0]="None",w[w.End=17]="End",w[w.Scale=18]="Scale",w[w.Stretch=19]="Stretch",w))(LinkAdjusting||{}),Routing=(w=>(w[w.Normal=1]="Normal",w[w.Orthogonal=2]="Orthogonal",w[w.AvoidsNodes=6]="AvoidsNodes",w[w.AvoidsNodesStraight=7]="AvoidsNodesStraight",w))(Routing||{}),Curve=(w=>(w[w.None=0]="None",w[w.Bezier=9]="Bezier",w[w.JumpGap=10]="JumpGap",w[w.JumpOver=11]="JumpOver",w))(Curve||{});class Link extends Part{Nt;lo;ho;Td;ao;co;Dd;Pf;Fd;Rd;vd;Da;Od;Hs;ki;fl;Sr;Sf;$o;Z2;Q2;f1;_2;tN;py;u1;ct;Zo;static Fa=null;static Ra=null;hf;iN;eN;constructor(t){super(Panel.Link),this.Nt=8,this.lo=null,this.ho="",this.Td=null,this.ao=null,this.co="",this.Dd=null,this.Pf=0,this.Fd=0,this.Rd=0,this.vd=NaN,this.Da=1,this.Od=.5,this.Hs=null,this.ki=new List().g(),this.fl=null,this.Sr=null,this.Sf=new Rect,this.ct=new Geometry,this.$o=null,this.Zo=null,this.Z2=null,this.Q2=null,this.iN=0,this.eN=0,this.f1=new Point,this._2=null,this.tN=null,this.py=null,this.u1=NaN,this.q=null,this.hf=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Nt=this.Nt&-113,t.ho=this.ho,t.Td=this.Td,t.co=this.co,t.Dd=this.Dd,t.Pf=this.Pf,t.Fd=this.Fd,t.Rd=this.Rd,t.vd=this.vd,t.Da=this.Da,t.Od=this.Od,this.q!==null&&(t.q=this.q.copy())}Vo(t){super.Vo(t),this.ho=t.ho,this.co=t.co,t.fl=null,t.invalidateRoute(),t.Zo=this.Zo;const i=t.fromPort;i!==null&&t.fromNode.Wi(i);const e=t.toPort;e!==null&&t.toNode.Wi(e)}ri(t){t in Routing||t in Curve||t in LinkAdjusting?Link.sN(t)?this.routing=t:t===9||t===10||t===11?this.curve=t:t===17||t===18||t===19?this.adjusting=t:t===1||t===0||Util.o("Unknown Link enum value for a Link property: "+t):super.ri(t)}static Normal=1;static Orthogonal=2;static AvoidsNodes=6;static AvoidsNodesStraight=7;static None=0;static Bezier=9;static JumpGap=10;static JumpOver=11;static End=17;static Scale=18;static Stretch=19;static OrientAlong=21;static OrientPlus90=22;static OrientMinus90=23;static OrientOpposite=24;static OrientUpright=25;static OrientPlus90Upright=26;static OrientMinus90Upright=27;static OrientUpright45=28;static zv=8;static Xv=16;static Kv=14;static va=8;Xe(){this.q===null&&(this.q=new LinkSettings)}QR(t,i,e){const s=t.segmentIndex,n=t.segmentFraction;let o=t.alignmentFocus;const r=t.segmentOrientation,l=t.segmentOffset;let h=0,a=0,c=0,f=0;if(isNaN(s)){const C=this.ct,M=Util.nt();C.getPointAndAngleAlongPath(n,M);const N=Point.X(M[0],M[1]);if(N.add(this.getPoint(0)),C.type===1)N.offset(-C.startX,-C.startY);else{const T=C.figures.first();N.offset(-T.startX,-T.startY)}f=M[2],r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=N.x,a=N.y,Point.s(N),Util.tt(M)}else if(s<-i||s>=i){const C=Point.l();this.mA(C),f=this.midAngle,r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=C.x,a=C.y,Point.s(C)}else{let C,M,N=0;if(s>=0?(C=e.r[s],M=s0?e.r[N-1]:C),C.equalsApprox(M)){let T,A;s>=0?(T=s>0?e.r[s-1]:C,A=s1?e.r[N-2]:M);const D=T.distanceSquaredPoint(C),F=M.distanceSquaredPoint(A);D>F+10?f=s>=0?T.directionPoint(C):C.directionPoint(T):F>D+10?f=s>=0?M.directionPoint(A):A.directionPoint(M):f=s>=0?T.directionPoint(A):A.directionPoint(T)}else f=s>=0?C.directionPoint(M):M.directionPoint(C);r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=C.x+(M.x-C.x)*n,a=C.y+(M.y-C.y)*n}if(o.isNone()){t.location=new Point(h,a);return}else o.isNoSpot()&&(o=Spot.Center);const u=Transform.l();u.Ri(),u.et(t.scale,t.scale),u.cs(t.angle,0,0);const d=t.naturalBounds,m=Rect.X(0,0,d.width,d.height),g=Point.l();g.setRectSpot(m,o),u.xt(g);let p=-g.x,y=-g.y;const x=d.width,k=d.height,b=Point.l();b.a(l);const P=isNaN(l.x),S=isNaN(l.y);if(P||S){const C=x/2+3,M=k/2+3,N=f>=45&&f<=135,T=f>=225&&f<=315;r===0&&(N||T)?(b.x=S?C:l.y,b.y=P?M:l.x,N?s>=0||isNaN(s)&&n<.5||P&&(b.y=-M):T&&((s>=0||isNaN(s)&&n<.5)&&P&&(b.y=-M),S&&(b.x=-C))):(P&&(s>=0||isNaN(s)&&n<.5?b.x=C:b.x=-C),S&&(b.y=-M),b.rotate(f))}else b.rotate(f);h+=b.x,a+=b.y,u.xw(m),p+=m.x,y+=m.y;const L=Point.X(h+p,a+y);t.move(L),Point.s(L),Point.s(b),Point.s(g),Rect.s(m),Transform.s(u)}Hr(){let t=this.fromNode;if(t!==null){const e=t.findVisibleNode();if(e!==null&&(t=e),t.is()||t.th())return!1}let i=this.toNode;if(i!==null){const e=i.findVisibleNode();if(e!==null&&(i=e),i.is()||i.th())return!1}return!0}c2(t,i,e){return!1}f2(){}Pe(){return!1}computeAngle(t,i,e){return Link.computeAngle(i,e)}static computeAngle(t,i){let e=0;switch(t){default:case 0:e=0;break;case 21:e=i;break;case 22:e=i+90;break;case 23:e=i-90;break;case 24:e=i+180;break;case 25:e=Geo.zg(i),e>90&&e<270&&(e-=180);break;case 26:e=Geo.zg(i+90),e>90&&e<270&&(e-=180);break;case 27:e=Geo.zg(i-90),e>90&&e<270&&(e-=180);break;case 28:if(e=Geo.zg(i),e>45&&e<135||e>225&&e<315)return 0;e>90&&e<270&&(e-=180);break}return Geo.zg(e)}get fromNode(){return this.lo}set fromNode(t){const i=this.lo;if(i!==t){const e=this.fromPort;i!==null&&(this.ao!==i&&i.c1(this,e),this.yy(),this.invalidateLayout(2)),this.lo=t,t!==null&&this.Ei(t.isVisible()),this.$o=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.Y&&s.partManager.setFromNodeForLink(this,t,i);const n=this.fromPort,o=this.fromPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.Y,s.Y=!0),o(this,e,n),s!==null&&(s.Y=r)}t!==null&&(this.ao!==t&&t.a1(this,n),this.wy(),this.invalidateLayout(1)),this.t("fromNode",i,t),this.Ld()}}get fromPortId(){return this.ho}set fromPortId(t){const i=this.ho;if(i!==t){const e=this.fromPort;e!==null&&this.fromNode.Wi(e),this.yy(),this.ho=t;const s=this.fromPort;s!==null&&this.fromNode.Wi(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Ta()&&r.setFromPortIdForLinkData(o,t)}if(e!==s){this.$o=null,this.invalidateRoute();const o=this.fromPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.Y,n.Y=!0),o(this,e,s),n!==null&&(n.Y=r)}}this.wy(),this.t("fromPortId",i,t)}}get fromPort(){const t=this.lo;if(t===null)return null;const i=this.ho;return t.findPort(i)}get fromPortChanged(){return this.Td}set fromPortChanged(t){const i=this.Td;i!==t&&(t!==null&&Util.i(t,"function",Link,"fromPortChanged"),this.Td=t,this.t("fromPortChanged",i,t))}get toNode(){return this.ao}set toNode(t){const i=this.ao;if(i!==t){const e=this.toPort;i!==null&&(this.lo!==i&&i.c1(this,e),this.yy(),this.invalidateLayout(2)),this.ao=t,t!==null&&this.Ei(t.isVisible()),this.$o=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.Y&&s.partManager.setToNodeForLink(this,t,i);const n=this.toPort,o=this.toPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.Y,s.Y=!0),o(this,e,n),s!==null&&(s.Y=r)}t!==null&&(this.lo!==t&&t.a1(this,n),this.wy(),this.invalidateLayout(1)),this.t("toNode",i,t),this.Ld()}}get toPortId(){return this.co}set toPortId(t){const i=this.co;if(i!==t){const e=this.toPort;e!==null&&this.toNode.Wi(e),this.yy(),this.co=t;const s=this.toPort;s!==null&&this.toNode.Wi(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Ta()&&r.setToPortIdForLinkData(o,t)}if(e!==s){this.$o=null,this.invalidateRoute();const o=this.toPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.Y,n.Y=!0),o(this,e,s),n!==null&&(n.Y=r)}}this.wy(),this.t("toPortId",i,t)}}get toPort(){const t=this.ao;if(t===null)return null;const i=this.co;return t.findPort(i)}get toPortChanged(){return this.Dd}set toPortChanged(t){const i=this.Dd;i!==t&&(t!==null&&Util.i(t,"function",Link,"toPortChanged"),this.Dd=t,this.t("toPortChanged",i,t))}get fromSpot(){return this.q!==null?this.q.fa:Spot.Default}set fromSpot(t){const i=this.fromSpot;if(!i.equals(t)){if(t=t.N(),this.Xe(),this.q.fa=t,this.t("fromSpot",i,t),i.isSide()||t.isSide()){const e=this.fromNode;e!==null&&e.Wi(this.fromPort)}this.invalidateRoute()}}get fromEndSegmentLength(){return this.q!==null?this.q.da:NaN}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;if(i!==t){if(t<0&&Util._(t,">= 0",Link,"fromEndSegmentLength"),this.Xe(),this.q.da=t,this.t("fromEndSegmentLength",i,t),this.computeSpot(!0,this.fromPort).isSide()){const e=this.fromNode;e!==null&&e.Wi(this.fromPort)}this.invalidateRoute()}}get fromShortLength(){return this.q!==null?this.q.ma:NaN}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(this.Xe(),this.q.ma=t,this.ee(),this.t("fromShortLength",i,t))}get toSpot(){return this.q!==null?this.q.ua:Spot.Default}set toSpot(t){const i=this.toSpot;if(!i.equals(t)){if(t=t.N(),this.Xe(),this.q.ua=t,this.t("toSpot",i,t),i.isSide()||t.isSide()){const e=this.toNode;e!==null&&e.Wi(this.toPort)}this.invalidateRoute()}}get toEndSegmentLength(){return this.q!==null?this.q.ga:NaN}set toEndSegmentLength(t){const i=this.toEndSegmentLength;if(i!==t){if(t<0&&Util._(t,">= 0",Link,"toEndSegmentLength"),this.Xe(),this.q.ga=t,this.t("toEndSegmentLength",i,t),this.computeSpot(!1,this.toPort).isSide()){const e=this.toNode;e!==null&&e.Wi(this.toPort)}this.invalidateRoute()}}get toShortLength(){return this.q!==null?this.q.pa:NaN}set toShortLength(t){const i=this.toShortLength;i!==t&&(this.Xe(),this.q.pa=t,this.ee(),this.t("toShortLength",i,t))}Ld(){const t=this.fromNode,i=this.toNode;let e=null;if(t!==null?i!==null?e=t.findCommonContainingGroup(i):e=t.containingGroup:i!==null?e=i.containingGroup:e=null,this.Yv(e),this.isLabeledLink){const s=this.labelNodes;for(;s.next();){const n=s.value;n.containingGroup=e}}}Yv(t){const i=this.ph;if(i!==t){i!==null&&i.G2(this),this.ph=t,t!==null&&t.j2(this);const e=this.containingGroupChanged;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.Y,n.Y=!0),e(this,i,t),n!==null&&(n.Y=s)}this.Me&&(this._2===i||this.tN===i)&&this.invalidateRoute()}}ch(){const t=this.containingGroup;t!==null&&this.fromNode!==t&&this.toNode!==t&&t.computesBoundsIncludingLinks&&super.ch()}getOtherNode(t){const i=this.fromNode;return t===i?this.toNode:i}getOtherPort(t){const i=this.fromPort;return t===i?this.toPort:i}get isLabeledLink(){return this.Hs===null?!1:this.Hs.count>0}get labelNodes(){return this.Hs===null?EmptyIterator.instance:this.Hs.iterator}QA(t){this.Hs===null&&(this.Hs=new GSet),this.Hs.add(t),this.c()}_A(t){this.Hs!==null&&(this.Hs.delete(t),this.c())}Em(t){if(super.Em(t),this.Oa()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.lo;let e=null;i!==null&&(e=this.fromPort,i.a1(this,e));const s=this.ao;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.a1(this,n)),this.wy()}}Bm(t){if(super.Bm(t),this.Oa()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.lo;let e=null;i!==null&&(e=this.fromPort,i.c1(this,e));const s=this.ao;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.c1(this,n)),this.yy()}}Kc(){if(this.Me=!0,this.Hs!==null){const i=this.diagram;if(i!==null){const s=this.Hs.copy().iterator;for(;s.next();){const n=s.value;i.remove(n)}}}if(this.data!==null){const i=this.diagram;i!==null&&i.partManager.nN(this)}}updateRelationshipsFromData(){if(this.data===null)return;const i=this.diagram;i!==null&&i.partManager.updateRelationshipsFromData(this)}move(t,i){const e=i?this.location:this.position;let s=e.x;isNaN(s)&&(s=0);let n=e.y;isNaN(n)&&(n=0);const o=t.x-s,r=t.y-n;if(i===!0)super.move(t,!1);else{const h=Point.X(e.x+o,e.y+r);super.move(h,!1),Point.s(h)}this.pr(o,r);const l=this.labelNodes;for(;l.next();){const h=l.value,a=h.position;h.moveTo(a.x+o,a.y+r)}}get relinkableFrom(){return(this.Nt&1)!==0}set relinkableFrom(t){const i=(this.Nt&1)!==0;i!==t&&(this.Nt=this.Nt^1,this.t("relinkableFrom",i,t),this.invalidateAdornments())}get relinkableTo(){return(this.Nt&2)!==0}set relinkableTo(t){const i=(this.Nt&2)!==0;i!==t&&(this.Nt=this.Nt^2,this.t("relinkableTo",i,t),this.invalidateAdornments())}canRelinkFrom(){if(!this.relinkableFrom)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}canRelinkTo(){if(!this.relinkableTo)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}get resegmentable(){return(this.Nt&4)!==0}set resegmentable(t){const i=(this.Nt&4)!==0;i!==t&&(this.Nt=this.Nt^4,this.t("resegmentable",i,t),this.invalidateAdornments())}get isTreeLink(){return(this.Nt&8)!==0}set isTreeLink(t){const i=(this.Nt&8)!==0;i!==t&&(this.Nt=this.Nt^8,this.t("isTreeLink",i,t),this.fromNode!==null&&this.fromNode.f0(),this.toNode!==null&&this.toNode.f0())}get path(){const t=this.findMainElement();return t instanceof Shape?t:null}get routeBounds(){return this.updateRoute(),this.Gv(this.Sf)}Gv(t){let i=1/0,e=1/0;const s=this.pointsCount;if(s===0)return t.e(NaN,NaN,0,0),t;if(s===1){const n=this.getPoint(0);i=Math.min(n.x,i),e=Math.min(n.y,e),t.e(n.x,n.y,0,0)}else if(s===2){const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o)}else if(this.computeCurve()===9&&s>=3&&!this.isOrthogonal){let n=this.getPoint(0);if(i=n.x,e=n.y,t.e(i,e,0,0),s===3){const o=this.getPoint(1);i=Math.min(o.x,i),e=Math.min(o.y,e);const r=this.getPoint(2);i=Math.min(r.x,i),e=Math.min(r.y,e),Geo.hu(n.x,n.y,o.x,o.y,o.x,o.y,r.x,r.y,.5,t)}else for(let o=3;o=s&&(o=s-1);const l=this.getPoint(o-1),h=this.getPoint(o);Geo.hu(n.x,n.y,r.x,r.y,l.x,l.y,h.x,h.y,.5,t),i=Math.min(h.x,i),e=Math.min(h.y,e),n=h}}else{const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o);for(let r=2;r=15||this.computeCurve()===9)){this.ct.getPointAlongPath(.5,t),t.add(this.getPoint(0));const a=this.ct.figures.first();return t.offset(-a.startX,-a.startY),t}if(this.computeCurve()===9){if(i===3){const f=this.getPoint(0),u=this.getPoint(1),d=this.getPoint(2);return Geo.fC(f.x,f.y,u.x,u.y,u.x,u.y,d.x,d.y,t),t}const a=(i-1)/3|0,c=(a/2|0)*3;if(a%2===1){const f=this.getPoint(c),u=this.getPoint(c+1),d=this.getPoint(c+2),m=this.getPoint(c+3);return Geo.fC(f.x,f.y,u.x,u.y,d.x,d.y,m.x,m.y,t),t}else return t.a(this.getPoint(c)),t}const e=this.flattenedLengths,s=this.flattenedTotalLength;let n=0,o=0,r=0;for(;ns/2));)n+=r,o++;const l=this.getPoint(o),h=this.getPoint(o+1);if(Math.abs(l.x-h.x)<1)l.y>h.y?t.e(l.x,l.y-(s/2-n)):t.e(l.x,l.y+(s/2-n));else if(Math.abs(l.y-h.y)<1)l.x>h.x?t.e(l.x-(s/2-n),l.y):t.e(l.x+(s/2-n),l.y);else{const a=(s/2-n)/r,c=a*(h.x-l.x),f=a*(h.y-l.y);t.e(l.x+c,l.y+f)}return t}get midAngle(){return this.updateRoute(),this.computeMidAngle()}computeMidAngle(){const t=this.pointsCount;if(t<2)return NaN;if(t===2){const h=this.getPoint(0),a=this.getPoint(1);return h.directionPoint(a)}if(this.isOrthogonal&&(this.computeCorner()>=15||this.computeCurve()===9))return this.ct.getAngleAlongPath(.5);if(this.computeCurve()===9&&t>=4){const h=(t-1)/3|0;let a=(h/2|0)*3;if(h%2===1){a=Math.floor(a);const c=this.getPoint(a),f=this.getPoint(a+1),u=this.getPoint(a+2),d=this.getPoint(a+3);return Geo.FD(c.x,c.y,f.x,f.y,u.x,u.y,d.x,d.y)}else if(a>0&&a+1e/2));)s+=o,n++;const r=this.getPoint(n),l=this.getPoint(n+1);if(Math.abs(r.x-l.x)<1&&Math.abs(r.y-l.y)<1){if(n>0&&n+2l.y?270:90;if(Math.abs(r.y-l.y)<1)return r.x>l.x?180:0}return r.directionPoint(l)}jv(){if(this.py===null){this.Me||this.d1();const t=this.py=[];this.Hv(t)}}get flattenedLengths(){return this.jv(),this.py}get flattenedTotalLength(){let t=this.u1;if(isNaN(t)){const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=3){let g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e);m=this.adjustPoints(0,g,o-1,p),m&&(g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e),this.adjustPoints(0,g,o-1,p))}m||(this.clearPoints(),u?this.qv(i,e,r,s,n,l):this.Wv(i,e,r,s,n,l))}else{const m=this.isAvoiding;d&&(f&&m||c)&&this.clearPoints();const g=c?this.computeCurviness():0,p=this.getLinkPoint(i,e,r,!0,f,s,n);let y=0,x=0,k=0;if(f||!h||c){let N=this.computeEndSegmentLength(i,e,r,!0);if(k=this.getLinkDirection(i,e,p,r,!0,f,s,n),c&&(h||r.equals(l)||!f&&r.x+l.x===1&&r.y+l.y===1)&&(k-=f?90:30,g<0&&(k-=180)),k<0?k+=360:k>=360&&(k-=360),c&&(N+=Math.abs(g)*(f?1:2)),k===0?y=N:k===90?x=N:k===180?y=-N:k===270?x=-N:(y=N*Math.cos(k*Math.PI/180),x=N*Math.sin(k*Math.PI/180)),r.isNoSpot()&&c){const T=e.getDocumentPoint(Spot.Center,Point.l()),A=Point.X(T.x+y*1e3,T.y+x*1e3);this.getLinkPointFromPoint(i,e,T,A,!0,p),Point.s(T),Point.s(A)}}const b=this.getLinkPoint(s,n,l,!1,f,i,e);let P=0,S=0,L=0;if(f||!a||c){let N=this.computeEndSegmentLength(s,n,l,!1);if(L=this.getLinkDirection(s,n,b,l,!1,f,i,e),c&&(a||r.equals(l)||!f&&r.x+l.x===1&&r.y+l.y===1)&&(L+=f?0:30,g<0&&(L+=180)),L<0?L+=360:L>=360&&(L-=360),c&&(N+=Math.abs(g)*(f?1:2)),L===0?P=N:L===90?S=N:L===180?P=-N:L===270?S=-N:(P=N*Math.cos(L*Math.PI/180),S=N*Math.sin(L*Math.PI/180)),l.isNoSpot()&&c){const T=n.getDocumentPoint(Spot.Center,Point.l()),A=Point.X(T.x+P*1e3,T.y+S*1e3);this.getLinkPointFromPoint(s,n,T,A,!1,b),Point.s(T),Point.s(A)}}let C=p;(f||!h||c)&&(C=new Point(p.x+y,p.y+x));let M=b;(f||!a||c)&&(M=new Point(b.x+P,b.y+S)),!d&&!f&&h&&o>3&&this.adjustPoints(0,p,o-2,M)?this.setPoint(o-1,b):!d&&!f&&a&&o>3&&this.adjustPoints(1,C,o-1,b)?this.setPoint(0,p):!d&&(f?o>=6:o>4)&&this.adjustPoints(1,C,o-2,M)?(this.setPoint(0,p),this.setPoint(o-1,b)):(this.clearPoints(),this.addPoint(p),(f||!h||c)&&this.addPoint(C),f&&this.addOrthoPoints(C,k,M,L,i,s),(f||!a||c)&&this.addPoint(M),this.addPoint(b))}return t.addInvalidRoute(this),!0}rN(t,i){return Math.abs(i.x-t.x)>Math.abs(i.y-t.y)?(i.x>=t.x?i.x=t.x+9e9:i.x=t.x-9e9,i.y=t.y):(i.y>=t.y?i.y=t.y+9e9:i.y=t.y-9e9,i.x=t.x),i}getLinkPointFromPoint(t,i,e,s,n,o){if(o===void 0&&(o=new Point),t===null||i===null)return o.a(e),o;if(!t.isVisible()){const u=t.findVisibleNode();u!==null&&u!==t&&(t=u,i=t.port)}let r=0,l=0,h=0,a=0,c=null,f=i.panel;if(f!==null&&!f.pn()&&(f=f.panel),f===null)r=s.x,l=s.y,h=e.x,a=e.y;else{c=f.Es;const u=1/(c.m11*c.m22-c.m12*c.m21),d=c.m22*u,m=-c.m12*u,g=-c.m21*u,p=c.m11*u,y=u*(c.m21*c.dy-c.m22*c.dx),x=u*(c.m12*c.dx-c.m11*c.dy);r=s.x*d+s.y*g+y,l=s.x*m+s.y*p+x,h=e.x*d+e.y*g+y,a=e.x*m+e.y*p+x}return i.Zc(r,l,h,a,o),c!==null&&o.D(c),o}Jv(t,i){const e=t.Ju;return e!==null?e.nT(i):null}m1(t){let i=t.Ju;return i===null&&(i=new Knot,i.Qo=t,i.de=t.part,t.Ju=i),i.nT(this)}getLinkPoint(t,i,e,s,n,o,r,l){if(l===void 0&&(l=new Point),e.isSpot()&&!this.Id(e))return i.getDocumentPoint(e,l),l;if(e.isSide()){const c=this.m1(i);if(c!==null){const f=c.Ed;if(l.a(f),n&&this.routing===7){const u=this.m1(r);if(u!==null&&c.Mf=g.y&&y.y<=g.y+g.height?l.y=y.y:(e.includesSide(Spot.TopSide)||e.includesSide(Spot.BottomSide))&&y.x>=g.x&&y.x<=g.x+g.width&&(l.x=y.x),Point.s(d),Point.s(m)}}return l}}const h=i.getDocumentPoint(this.p1(e,s),Point.l());let a=null;if(this.pointsCount>(n?6:2))a=s?this.getPoint(1):this.getPoint(this.pointsCount-2),n&&(a=this.rN(h,a.copy()));else{const c=this.computeSpot(!s,r),f=Point.l();a=r.getDocumentPoint(this.p1(c,!s),f),n&&(a=this.rN(h,a)),Point.s(f)}return this.getLinkPointFromPoint(t,i,h,a,s,l),Point.s(h),l}getLinkDirection(t,i,e,s,n,o,r,l){let h=this.$v(t,i,e,s,n,o,r,l);if(r&&s.isNoSpot()&&r.isMemberOf(t)&&(h+=180,h>=360&&(h-=360)),this.Id(s))return h;const a=i.getDocumentAngle();return a===0||(45<=a&&a<135?h+=90:135<=a&&a<225?h+=180:225<=a&&a<315&&(h+=270),h>=360&&(h-=360)),h}$v(t,i,e,s,n,o,r,l){if(s.isSpot())return s.x>s.y?s.x>1-s.y?0:s.x<1-s.y?270:315:s.x1-s.y?90:s.x<1-s.y?180:135:s.x<.5?225:s.x>.5?45:0;if(s.isSide()){const f=this.m1(i);if(f!==null)switch(f.me){case 1:return 270;case 2:return 180;default:case 4:return 0;case 8:return 90}}const h=i.getDocumentPoint(Spot.Center,Point.l());let a=null;if(this.pointsCount>(o?6:2))a=n?this.getPoint(1):this.getPoint(this.pointsCount-2),o?a=this.rN(h,a.copy()):a=e;else{const f=Point.l();a=l.getDocumentPoint(Spot.Center,f),Point.s(f)}let c=0;return Math.abs(a.x-h.x)>Math.abs(a.y-h.y)?a.x>=h.x?c=0:c=180:a.y>=h.y?c=90:c=270,Point.s(h),c}computeEndSegmentLength(t,i,e,s){if(i!==null&&e.isSide()){const o=this.m1(i);if(o!==null)return o.w1}let n=NaN;return s?n=this.fromEndSegmentLength:n=this.toEndSegmentLength,i!==null&&isNaN(n)&&(s?n=i.fromEndSegmentLength:n=i.toEndSegmentLength),isNaN(n)&&(n=10),n}computeSpot(t,i){return i===void 0&&(i=null),t?this.Zv(i||this.fromPort):this.Qv(i||this.toPort)}Zv(t){if(t===null)return Spot.Center;let i=this.fromSpot;return i.isDefault()&&(i=t.fromSpot),i===Spot.Default?Spot.None:i}Qv(t){if(t===null)return Spot.Center;let i=this.toSpot;return i.isDefault()&&(i=t.toSpot),i===Spot.Default?Spot.None:i}Id(t){return t===Spot.None||t.x===.5&&t.y===.5}p1(t,i){return t.x===.5&&t.y===.5?t:Spot.Center}computeOtherPoint(t,i){if(this.computeAdjusting()!==0&&this.pointsCount>4)return this.computeMidPoint(new Point);{const e=this.Jv(i,this);return e!==null?e.Ed:i.getDocumentPoint(Spot.Center)}}computeShortLength(t){if(t){let i=this.fromShortLength;if(isNaN(i)){const e=this.fromPort;e!==null&&(i=e.fromShortLength)}return isNaN(i)?0:i}else{let i=this.toShortLength;if(isNaN(i)){const e=this.toPort;e!==null&&(i=e.toShortLength)}return isNaN(i)?0:i}}vm(t,i,e,s,n,o){if(this.pickable===!1)return!1;i===void 0&&(i=null),e===void 0&&(e=null);let r=o;if(o===void 0&&(r=Transform.l(),r.Ri()),r.ic(this.D),this.containedInRect(t,r))return this.D2(i,e,n),o===void 0&&Transform.s(r),!0;if(this.intersectsRect(t,r)){let l=!1;if(!this.af){const h=this.L.r,a=h.length;for(let c=a;c--;){const f=h[c];if(!f.visible&&f!==this.locationObject)continue;const u=f.actualBounds,d=this.naturalBounds;if(u.x>d.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;const m=f,g=Transform.l();if(g.set(r),m instanceof Panel?l=m.vm(t,i,e,s,n,g):this.path===m?m instanceof Shape&&(l=m.bv(t,s,g)):l=m.QL(t,s,g),l){let p=m;i!==null&&(p=i(m)),p&&(e===null||e(p))&&n.add(p)}Transform.s(g)}}return o===void 0&&Transform.s(r),l||this.background!==null}return o===void 0&&Transform.s(r),!1}get isOrthogonal(){return(this.Da&2)===2}static sN(t){return(t&2)===2}get isAvoiding(){return(this.Da&4)===4}computeCurve(){if(this.$o===null){const t=this.fromPort,i=t!==null&&t===this.toPort,e=this.isOrthogonal;this.$o=i&&!e}return this.$o?9:this.curve}computeCorner(){if(this.curve===9)return 0;let t=this.corner;return(isNaN(t)||t<0)&&(t=10),t}findMidLabel(){const t=this.path,i=this.L.r,e=i.length;for(let n=0;n0?g-=f:g+=f;else{const p=-h/a;let y=Math.sqrt(f*f/(p*p+1));c<0&&(y=-y),m=(a<0?-1:1)*y+u,g=p*(m-u)+d}this.addPoint(r),this.addPointAt(m,g),this.addPoint(l)}else{this.addPoint(r),this.addPoint(l);const h=Rect.l();i.getDocumentBounds(h);const a=h.containsPoint(l);n.getDocumentBounds(h);const c=h.containsPoint(r);if(a||c){const f=i.getDocumentPoint(this.p1(e,!0),new Point);this.setPoint(0,this.getLinkPointFromPoint(t,i,f,l,!0,f));const u=n.getDocumentPoint(this.p1(o,!1),new Point);this.setPoint(1,this.getLinkPointFromPoint(s,n,u,r,!1,u))}Rect.s(h)}}qv(t,i,e,s,n,o){const r=this.getLinkPoint(t,i,e,!0,!1,s,n),l=this.getLinkPoint(s,n,o,!1,!1,t,i),h=l.x-r.x,a=l.y-r.y,c=this.computeCurviness();let f=0,u=0,d=r.x+h/3,m=r.y+a/3,g=d,p=m;Geo.u(a,0)?h>0?p-=c:p+=c:(f=-h/a,u=Math.sqrt(c*c/(f*f+1)),c<0&&(u=-u),g=(a<0?-1:1)*u+d,p=f*(g-d)+m),d=r.x+2*h/3,m=r.y+2*a/3;let y=d,x=m;Geo.u(a,0)?h>0?x-=c:x+=c:(y=(a<0?-1:1)*u+d,x=f*(y-d)+m),this.clearPoints(),this.addPoint(r),this.addPointAt(g,p),this.addPointAt(y,x),this.addPoint(l),this.setPoint(0,this.getLinkPoint(t,i,e,!0,!1,s,n)),this.setPoint(3,this.getLinkPoint(s,n,o,!1,!1,t,i))}adjustPoints(t,i,e,s){let n=this.computeAdjusting();if(this.isOrthogonal){if(n===18)return!1;n===19&&(n=17)}switch(n){case 18:return this._v(t,i,e,s);case 19:return this.tO(t,i,e,s);case 17:return this.iO(t,i,e,s);default:return!1}}_v(t,i,e,s){const n=this.getPoint(t),o=this.getPoint(e);if(n.equalsApprox(i)&&o.equalsApprox(s))return!0;const r=n.x,l=n.y,h=o.x,a=o.y;let c=h-r,f=a-l;const u=Math.sqrt(c*c+f*f);if(Geo.K(u,0))return!0;let d=0;Geo.K(c,0)?f<0?d=-Math.PI/2:d=Math.PI/2:(d=Math.atan(f/Math.abs(c)),c<0&&(d=Math.PI-d));const m=i.x,g=i.y,p=s.x,y=s.y,x=p-m,k=y-g,b=Math.sqrt(x*x+k*k);let P=0;Geo.K(x,0)?k<0?P=-Math.PI/2:P=Math.PI/2:(P=Math.atan(k/Math.abs(x)),x<0&&(P=Math.PI-P));const S=b/u,L=P-d;this.setPoint(t,i);for(let C=t+1;C0&&(C=-C);const M=f+P*(d-f),N=u+P*(m-u);if(g!==0){const T=M+C/p,A=N-(T-M)/g;this.setPointAt(y,T,A)}else this.setPointAt(y,M,N+C)}return this.setPoint(e,s),!0}iO(t,i,e,s){if(this.isOrthogonal){let n=this.getPoint(t),o=this.getPoint(t+1),r=this.getPoint(t+2),l=o.x,h=o.y;const a=l,c=h;Geo.u(n.y,o.y)?Geo.u(o.x,r.x)?h=i.y:Geo.u(o.y,r.y)&&(l=i.x):Geo.u(n.x,o.x)&&(Geo.u(o.y,r.y)?l=i.x:Geo.u(o.x,r.x)&&(h=i.y)),this.setPointAt(t+1,l,h),n=this.getPoint(e),o=this.getPoint(e-1),r=this.getPoint(e-2);let f=o.x,u=o.y;const d=f,m=u;if(Geo.u(n.y,o.y)?Geo.u(o.x,r.x)?u=s.y:Geo.u(o.y,r.y)&&(f=s.x):Geo.u(n.x,o.x)&&(Geo.u(o.y,r.y)?f=s.x:Geo.u(o.x,r.x)&&(u=s.y)),this.setPointAt(e-1,f,u),this.AL())return this.setPointAt(t+1,a,c),this.setPointAt(e-1,d,m),!1}return this.setPoint(t,i),this.setPoint(e,s),!0}addOrthoPoints(t,i,e,s,n,o){i<0?i+=360:i>=360&&(i-=360),s<0?s+=360:s>=360&&(s-=360);const c=s;i>=315||i<45?i=0:45<=i&&i<135?i=90:135<=i&&i<225?i=180:i=270,s>=315||s<45?s=0:45<=s&&s<135?s=90:135<=s&&s<225?s=180:s=270;const f=t,u=e,d=n.actualBounds.copy(),m=o.actualBounds.copy();if(!d.isReal()||!m.isReal())return;d.inflate(Link.va,Link.va),m.inflate(Link.va,Link.va),d.unionPoint(t),m.unionPoint(e);const g=Point.l(),p=Point.l();i===0?u.x>f.x||s===270&&u.yf.x||s===90&&u.y>f.y&&m.right>f.x?(g.e(u.x,f.y),p.e(u.x,(f.y+u.y)/2),s===180?(g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1),p.x=g.x,p.y=u.y):s===270&&u.yf.y?(f.xm.bottom)?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):g.x=m.right,p.x=g.x,p.y=u.y):s===0&&f.xm.top&&f.yd.bottom)&&(s===180&&(m.containsPoint(f)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):u.yf.y&&(s===180||s===270)&&(g.y=this.computeMidOrthoPosition(f.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=d.left&&u.x<=f.x||f.x<=m.right&&f.x>=u.x?(s===90||s===270)&&(g.e(Math.max((f.x+u.x)/2,f.x),f.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yf.y&&m.leftf.y?(f.x>m.right?g.x=this.computeMidOrthoPosition(f.x,f.y,m.right,u.y,!1):f.x>m.left&&(s===270&&f.ym.bottom)?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):g.x=m.left,p.x=g.x,p.y=u.y):s===180&&f.x>m.right&&f.y>m.top&&f.yd.bottom)&&(s===0&&(m.containsPoint(f)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):u.yf.y&&(s===0||s===270)&&(g.y=this.computeMidOrthoPosition(f.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=f.x||f.x>=m.left&&f.x<=u.x?(s===90||s===270)&&(g.e(Math.min((f.x+u.x)/2,f.x),f.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yf.y||s===180&&u.xf.y||s===0&&u.x>f.x&&m.bottom>f.y?(g.e(f.x,u.y),p.e((f.x+u.x)/2,u.y),s===270?(g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0),p.x=u.x,p.y=g.y):s===180&&u.xf.x?(f.ym.right)?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):g.y=m.bottom,p.x=u.x,p.y=g.y):s===90&&f.ym.left&&f.xd.right)&&(s===270&&(m.containsPoint(f)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):u.xf.x&&(s===270||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,f.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=d.top&&u.y<=f.y||f.y<=m.bottom&&f.y>=u.y?(s===0||s===180)&&(g.e(f.x,Math.max((f.y+u.y)/2,f.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.xf.x&&m.top=f.x?(f.y>m.bottom?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,m.bottom,!0):f.y>m.top&&(s===180&&f.xm.right)?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):g.y=m.top,p.x=u.x,p.y=g.y):s===270&&f.y>m.bottom&&f.x>m.left&&f.xd.right)&&(s===90&&(m.containsPoint(f)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):u.xf.x&&(s===90||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,f.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=f.y||f.y>=m.top&&f.y<=u.y?(s===0||s===180)&&(g.e(f.x,Math.min((f.y+u.y)/2,f.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.x=3&&!Geo.K(this.smoothness,0))if(i===3){let c=this.getPoint(1);n=Math.min(r.x,c.x),o=Math.min(r.y,c.y),c=this.getPoint(2),n=Math.min(n,c.x),o=Math.min(o,c.y)}else if(this.isOrthogonal){for(let c=0;c=i&&(c=i-1);const f=this.getPoint(c);l.x=Math.min(f.x,l.x),l.y=Math.min(f.y,l.y)}n=l.x,o=l.y}else{for(let c=0;c=3&&!Geo.K(this.smoothness,0))if(i===3){const f=this.getPoint(1),u=f.x-n,d=f.y-o;let m=this.getPoint(2).copy();m.x-=n,m.y-=o,this.computeShortLength(!1)!==0&&(m=this.Nf(m,!1,l)),c.dr(u,d,u,d,m.x,m.y)}else if(this.isOrthogonal){const f=Point.X(n,o),u=Point.l();u.a(this.getPoint(1));const d=Point.X(n,o),m=Point.X(n,o);let g=this.getPoint(0),p=null;const y=this.smoothness/3;for(let P=1;P=i&&(f=i-1);const d=this.getPoint(f-1);let m=this.getPoint(f);f===i-1&&this.computeShortLength(!1)!==0&&(m=this.Nf(m.copy(),!1,Point.Po)),c.dr(u.x-n,u.y-o,d.x-n,d.y-o,m.x-n,m.y-o)}else{const f=Point.l();f.a(this.getPoint(0));const u=Point.l();u.a(f);const d=this.computeCorner();let m=1,g=0;for(;m1);let p=this.getPoint(m);if(m>=i-1){if(!f.equals(p))this.computeShortLength(!1)!==0&&(p=this.Nf(p.copy(),!1,Point.Po)),this.Nn(c,-n,-o,f,p,e);else if(g===0)for(m=1;mr?f>a?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):f>a?(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.K(r,h)&&Geo.K(a,f)&&(a>l?c>h?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):c>h?(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.K(r,h)&&Geo.K(h,c)||Geo.K(l,a)&&Geo.K(a,f)){const m=.5*(r+c),g=.5*(l+f);n.x=m,n.y=g,o.x=m,o.y=g}}Nf(t,i,e){const s=this.pointsCount;if(s<2)return t;if(i){const n=this.getPoint(1),o=n.x-e.x,r=n.y-e.y,l=this.b1(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!0);a>h&&(a=h);const c=a*(o-t.x)/l,f=a*(r-t.y)/l;t.x+=c,t.y+=f}else{const n=this.getPoint(s-2),o=n.x-e.x,r=n.y-e.y,l=this.b1(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!1);a>h&&(a=h);const c=a*(t.x-o)/l,f=a*(t.y-r)/l;t.x-=c,t.y-=f}return t}lN(t,i,e){const s=this.pointsCount;let n=t;for(;Geo.K(t.x,n.x)&&Geo.K(t.y,n.y);){if(i>=s)return s-1;n=this.getPoint(i++)}if(!Geo.K(t.x,n.x)&&!Geo.K(t.y,n.y))return i-1;let o=n;for(;Geo.K(t.x,n.x)&&Geo.K(n.x,o.x)&&(!e||(t.y>=n.y?n.y>=o.y:n.y<=o.y))||Geo.K(t.y,n.y)&&Geo.K(n.y,o.y)&&(!e||(t.x>=n.x?n.x>=o.x:n.x<=o.x));){if(i>=s)return s-1;o=this.getPoint(i++)}return i-2}nO(t,i,e,s,n,o,r,l,h,a){if(Geo.u(s.y,n.y)&&Geo.u(n.x,o.x)){let c=Math.min(h,Math.abs(n.x-l.x)/2);const f=Math.min(c,Math.abs(o.y-n.y)/2);if(c=f,Geo.u(c,0)){this.Nn(t,i,e,s,n,a),r.a(n);return}let u=n.x;const d=n.y,m=u;let g=d;n.x>s.x?(u=n.x-c,o.y>n.y?g=n.y+f:g=n.y-f):(u=n.x+c,o.y>n.y?g=n.y+f:g=n.y-f);const p=Point.X(u,d);this.Nn(t,i,e,s,p,a),Point.s(p),t.Mw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else if(Geo.u(s.x,n.x)&&Geo.u(n.y,o.y)){let c=Math.min(h,Math.abs(n.y-l.y)/2);const f=Math.min(c,Math.abs(o.x-n.x)/2);if(c=f,Geo.u(f,0)){this.Nn(t,i,e,s,n,a),r.a(n);return}const u=n.x;let d=n.y,m=u;const g=d;n.y>s.y?(d=n.y-c,o.x>n.x?m=n.x+f:m=n.x-f):(d=n.y+c,o.x>n.x?m=n.x+f:m=n.x-f);const p=Point.X(u,d);this.Nn(t,i,e,s,p,a),Point.s(p),t.Mw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else this.Nn(t,i,e,s,n,a),r.a(n)}computeJumpLength(){return 10}Nn(t,i,e,s,n,o){if(o||!this.Oa())t.ur(n.x+i,n.y+e);else{const r=this.computeJumpLength(),l=r/2,h=[];let a=0;this.isVisible()&&(a=this.oO(s,n,h));let c=s.x,f=s.y;if(a>0){if(Geo.u(s.y,n.y))if(s.x=0;){const d=Math.min(s.x,Math.max(h[u--]+l,n.x+r));t.ur(d+i,n.y+e),c=d+i,f=n.y+e;let m=Math.max(d-r,n.x);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.x);else break}const g=n.y-r+e,p=m+i,y=n.y+e;this.curve===10?t.fu(p,y,!1,!1):t.dr(c,g,p,g,p,y),c=p,f=y}}else if(Geo.u(s.x,n.x))if(s.y=0;){const d=Math.min(s.y,Math.max(h[u--]+l,n.y+r));t.ur(n.x+i,d+e),c=n.x+i,f=d+e;let m=Math.max(d-r,n.y);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.y);else break}const g=n.x-r+i,p=n.x+i,y=m+e;this.curve===10?t.fu(p,y,!1,!1):t.dr(g,f,g,y,p,y),c=p,f=y}}}t.ur(n.x+i,n.y+e)}}oO(t,i,e){const s=this.diagram;if(s===null||t.equals(i))return 0;const n=s.layers;for(;n.next();){const o=n.value;if(o!==null&&o.visible){const r=o.ES(),l=r.length;for(let h=0;h0&&e.sort((u,d)=>u-d),e.length;if(!a.isVisible()||!a.Oa())continue;const c=a.routeBounds;if(!c.isReal()||!this.routeBounds.intersectsRect(c)||this.usesSamePort(a))continue;const f=a.path;f!==null&&f.isVisibleObject()&&this.rO(t,i,e,a)}}}return e.length>0&&e.sort((o,r)=>o-r),e.length}rO(t,i,e,s){const n=Geo.u(t.y,i.y),o=s.pointsCount;let r=s.getPoint(0);const l=Point.l();for(let h=1;hr.x&&c.x>=a.x||a.xr.y&&c.y>=a.y||a.yc&&Math.min(a,f)o&&!Geo.u(a,f))return n.x=o,n.y=c,!0}else if(Geo.u(r,h)&&Geo.u(a,f)&&Math.min(o,l)a&&Math.min(c,u)r&&!Geo.u(c,u))return n.x=a,n.y=r,!0;return n.x=0,n.y=0,!1}get firstPickIndex(){return this.pointsCount<=2?0:this.isOrthogonal||!this.Id(this.computeSpot(!0))?1:0}get lastPickIndex(){const t=this.pointsCount;return t===0?0:t<=2?t-1:this.isOrthogonal||!this.Id(this.computeSpot(!1))?t-2:t-1}Oa(){const t=this.curve;return t===11||t===10}g1(t){if(t||this.Oa()){const i=this.diagram;i!==null&&!i.animationManager.isTicking&&!i.$l.has(this)&&(this.Sf.width!==0||this.Sf.height!==0)&&i.$l.set(this,this.Sf.copy())}}invalidateOtherJumpOvers(t){const i=this.layer;if(i===null||!i.visible||i.isTemporary)return;const e=i.diagram;if(e===null||e.animationManager.isTicking)return;let s=!1;const n=e.layers;for(;n.next();){const o=n.value;if(o.visible){if(o===i){s=!0;let r=!1;const l=o.ES(),h=l.length;for(let a=0;a0&&e>0){const s=this.getPoint(0),n=t.getPoint(0);if(s.equalsApprox(n))return!0;const o=this.getPoint(i-1),r=t.getPoint(e-1);if(o.equalsApprox(r)||s.equalsApprox(r)||o.equalsApprox(n))return!0}else if(this.fromNode===t.fromNode||this.toNode===t.toNode||this.fromNode===t.toNode||this.toNode===t.fromNode)return!0;return!1}isVisible(){if(!super.isVisible())return!1;const t=this.containingGroup;let i=!0;const e=this.diagram;e!==null&&(i=e.isTreePathToChildren);const s=this.fromNode;if(s!==null){if(this.isTreeLink&&i&&!s.isTreeExpanded)return!1;if(s===t)return!0;let o=s;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=s.findVisibleNode();if(r===null||r===t)return!1}const n=this.toNode;if(n!==null){if(this.isTreeLink&&!i&&!n.isTreeExpanded)return!1;if(n===t)return!0;let o=n;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=n.findVisibleNode();if(r===null||r===t)return!1}return!0}Ei(t){if(super.Ei(t),t&&this.g1(!1),this.Zo!==null&&this.Zo.Ad(),this.Hs!==null){const e=this.Hs.iterator;for(;e.next();)e.value.Ei(t)}}get adjusting(){return this.Pf}set adjusting(t){const i=this.Pf;i!==t&&(this.Pf=t,this.t("adjusting",i,t))}computeAdjusting(){return this.isAvoiding&&this.diagram!==null&&this.diagram.animationManager.defaultAnimation.isAnimating?17:this.Pf}get corner(){return this.Fd}set corner(t){const i=this.Fd;i!==t&&(this.Fd=t,this.ee(),this.t("corner",i,t))}get curve(){return this.Rd}set curve(t){const i=this.Rd;i!==t&&(this.Rd=t,this.invalidateRoute(),this.ee(),this.g1(i===10||i===11||t===10||t===11),this.t("curve",i,t))}get curviness(){return this.vd}set curviness(t){const i=this.vd;i!==t&&(this.vd=t,this.invalidateRoute(),this.ee(),this.t("curviness",i,t))}get routing(){return this.Da}set routing(t){const i=this.Da;i!==t&&(this.Da=t,this.isAvoiding&&this.diagram!==null&&(this.diagram.Ym=!0),this.$o=null,this.invalidateRoute(),this.g1(Link.sN(i)||Link.sN(t)),this.t("routing",i,t))}get smoothness(){return this.Od}set smoothness(t){const i=this.Od;i!==t&&(this.Od=t,this.ee(),this.t("smoothness",i,t))}wy(){const t=this.lo;if(t===null)return;const i=this.ao;if(i===null||!isNaN(this.curviness))return;const e=this.ho,s=this.co;let n=null,o=null;const r=t._t.r,l=r.length;for(let h=0;h=0&&(Util.tc(t.qs,i),t.Ad())}}Cl(){return!0}get key(){const t=this.diagram;if(!(t===null||!t.model.Ta()))return t.model.getKeyForLinkData(this.data)}}class LinkBundle{Eo;Os;ry;J2;h1;$2;qs;constructor(t,i,e,s){GSet.Yi(this),this.Eo=!1,this.Os=!1,this.ry=t,this.J2=i,this.h1=e,this.$2=s,this.qs=[]}Ad(){if(!this.Eo){const t=this.qs;if(t.length>0){const i=t[0].diagram;i!==null&&(i.lM.add(this),this.Os=i.undoManager.isUndoingRedoing)}}this.Eo=!0}bM(){if(this.Eo){this.Eo=!1;const t=this.qs;if(t.length>0){const i=t[0],e=i.diagram,s=e===null||e.Bh&&!this.Os;this.Os=!1,i.arrangeBundledLinks(t,s),t.length===1&&(i.Zo=null,t.length=0)}t.length===0&&(this.ry.JA(this),this.h1.JA(this))}}}class PositionArray{oe;re;Ia;Ea;pi;yi;Ot;xh;bh;ha;RM;Eo;by;Gc;vM;OM;constructor(t){GSet.Yi(this),this.ha=null,this.RM=null,this.Eo=!0,this.by=!1,this.oe=1,this.re=1,this.Ia=-1,this.Ea=-1,this.pi=t.width,this.yi=t.height,this.Ot=null,this.xh=0,this.bh=0,this.Gc=11,this.vM=this.Gc*2,this.OM=this.Gc*2}static Ws=0;static Ba=1;static Bd=999999;static hN=PositionArray.Bd+1;static aN=PositionArray.Bd+2;kb(t){if(t.width<=0||t.height<=0)return;const i=t.x,e=t.y,s=t.x+t.width,n=t.y+t.height;this.oe=Math.floor((i-this.pi)/this.pi)*this.pi,this.re=Math.floor((e-this.yi)/this.yi)*this.yi,this.Ia=Math.ceil((s+2*this.pi)/this.pi)*this.pi,this.Ea=Math.ceil((n+2*this.yi)/this.yi)*this.yi;const o=1+(Math.ceil((this.Ia-this.oe)/this.pi)|0),r=1+(Math.ceil((this.Ea-this.re)/this.yi)|0);if(this.Ot===null||this.xh0&&t!==this.pi&&(this.pi=t,this.kb(this.bounds))}get cellHeight(){return this.yi}set cellHeight(t){t>0&&t!==this.yi&&(this.yi=t,this.kb(this.bounds))}Ud(t,i){return this.oe<=t&&t<=this.Ia&&this.re<=i&&i<=this.Ea}fo(t,i){if(!this.Ud(t,i))return PositionArray.hN;t-=this.oe,t/=this.pi,i-=this.re,i/=this.yi;const e=t|0,s=i|0;return this.Ot[e][s]}pR(t,i,e,s){if(!this.Ud(t,i))return;const n=(t-this.oe)/this.pi|0,o=(i-this.re)/this.yi|0,r=(t+e-this.oe)/this.pi|0,l=(i+s-this.re)/this.yi|0,h=Math.min(r,this.xh),a=Math.min(l,this.bh);for(let c=n;c<=h;c++){const f=this.Ot[c];if(f.fill)f.fill(PositionArray.Ws,o,a+1);else for(let u=o;u<=a;u++)f[u]=PositionArray.Ws}}hO(t){if(this.Ot!==null)for(let i=0;i<=this.xh;i++){const e=this.Ot[i];if(e.fill)e.fill(t);else for(let s=0;s<=this.bh;s++)e[s]=t}}zL(){if(this.Ot!==null)for(let t=0;t<=this.xh;t++){const i=this.Ot[t];for(let e=0;e<=this.bh;e++)i[e]>=PositionArray.Ba&&(i[e]=PositionArray.hN)}}aO(t,i){return this.fo(t,i)===PositionArray.Ws}isUnoccupied(t,i,e,s){if(t>this.Ia||t+ethis.Ea||i+sthis.Ia||ithis.Ea||ethis.Ea||ithis.Ia||e=PositionArray.Ba&&h=a)break;this.Ot[t][i]=h,h+=1,s?i+=e:t+=e}return s?i:t}uo(t,i,e,s,n,o,r,l){if(to||il)return;const h=this.cO(t,i,e,s,n,o,r,l);if(s)if(e>0)for(let a=i+e;ah;a+=e)this.uo(t,a,1,!s,n,o,r,l),this.uo(t,a,-1,!s,n,o,r,l);else if(e>0)for(let a=t+e;ah;a+=e)this.uo(a,i,1,!s,n,o,r,l),this.uo(a,i,-1,!s,n,o,r,l)}k1(t,i,e,s,n,o,r,l,h,a){let c=t|0,f=i|0,u=PositionArray.Ws,d=PositionArray.Ba;for(this.Ot[c][f]=d;u===PositionArray.Ws&&c>r&&ch&&fr&&ch&&f=0;v-=2){F=A[v+2],R=A[v+3];const O=A[v],B=A[v+1];for(;O>F?F++:OR?R++:Bs)d--;else break;else if(m>n)m--;else break;const g=c[d][m];if(g===0||g===PositionArray.aN)break;f=d,u=m}for(;;){let d=e,m=f,g=u;e===0?gn&&(d=270,g--):e===90?ms&&(d=180,m--):e===180?gn&&(d=270,g--):ms&&(d=180,m--);const p=c[m][g];if(d!==e&&p!==0&&p!==PositionArray.aN){if(o.push(f),o.push(u),this.lT(f,u,d,s,n,o))return!0;o.pop(),o.pop()}if(c[f][u]=PositionArray.aN,e===0){if(f===t)return!1;f--}else if(e===90){if(u===i)return!1;u--}else if(e===180){if(f===t)return!1;f++}else{if(u===i)return!1;u++}}}}class Knot{de;Qo;rs;Vd;constructor(){GSet.Yi(this),this.de=null,this.Qo=null,this.rs=[],this.Vd=!1}toString(){const t=this.rs;let i=this.de.toString()+" "+t.length.toString()+":";for(let e=0;e180?270:90;case 6:return o>90&&o<=270?180:0}const r=Math.atan2(t.height,t.width)*180/Math.PI;switch(n){case 3:return o>r&&o<=180+r?180:270;case 5:return o>180-r&&o<=360-r?270:0;case 12:return o>r&&o<=180+r?90:0;case 10:return o>180-r&&o<=360-r?180:90;case 7:return o>90&&o<=180+r?180:o>180+r&&o<=360-r?270:0;case 13:return o>180&&o<=360-r?270:o>r&&o<=180?90:0;case 14:return o>r&&o<=180-r?90:o>180-r&&o<=270?180:0;case 11:return o>180-r&&o<=180+r?180:o>180+r?270:90}return s&&n!==15&&(o-=15,o<0&&(o+=360)),o>r&&o<180-r?90:o>=180-r&&o<=180+r?180:o>180+r&&o<360-r?270:0}Ad(){this.rs.length=0}nT(t){let i=this.rs;i.length===0&&(this.uO(),i=this.rs);for(let e=0;e=360&&(S-=360);const L=this.fO(h,y,S,g.isOrthogonal);let C=0;L===0?(C=4,S>180&&(S-=360)):L===90?(C=8,S>270&&(S-=360)):L===180?C=2:(C=1,S<90&&(S+=360));let M=this.rs[o];M===void 0?(M=new LinkInfo(g,S,C),this.rs[o]=M):(M.He=g,M.Xt=S,M.me=C),M.S1.set(P),o++}Point.s(a),this.dO();const u=this.rs.length;let d=-1,m=0;for(o=0;o=0;o--){const g=this.rs[o];g!==void 0&&(g.me!==d&&(d=g.me,m=g.zd+1),g.Mf=m)}this.gO(this.rs),this.mO(this.rs),this.Vd=t,Rect.s(h)}return this.rs}pO(t,i){return t===i?0:t===null?-1:i===null?1:t.mei.me?1:t.Xti.Xt?1:0}dO(){this.rs.sort(Knot.prototype.pO)}gO(t){const i=this.Qo,e=this.de.portSpreading,s=Point.l(),n=Point.l(),o=Point.l(),r=Point.l();i.getDocumentPoint(Spot.TopLeft,s),i.getDocumentPoint(Spot.TopRight,n),i.getDocumentPoint(Spot.BottomRight,o),i.getDocumentPoint(Spot.BottomLeft,r);let l=0,h=0,a=0,c=0;if(e===2)for(let x=0;xMath.abs(p)?(d=Math.abs(p)/a,a=Math.abs(p)):d=1;break;case 2:c>Math.abs(y)?(d=Math.abs(y)/c,c=Math.abs(y)):d=1;break;case 1:l>Math.abs(p)?(d=Math.abs(p)/l,l=Math.abs(p)):d=1;break;default:case 4:h>Math.abs(y)?(d=Math.abs(y)/h,h=Math.abs(y)):d=1;break}u=0}const b=k.Ed;if(e===2){let P=k.He.computeThickness();switch(P*=d,b.set(m),f){case 8:b.x=m.x+p/2+a/2-u-P/2;break;case 2:b.y=m.y+y/2+c/2-u-P/2;break;case 1:b.x=m.x+p/2-l/2+u+P/2;break;default:case 4:b.y=m.y+y/2-h/2+u+P/2;break}u+=P}else{let P=.5;e===1&&(P=(k.zd+1)/(k.Mf+1)),b.x=m.x+p*P,b.y=m.y+y*P}}Point.s(s),Point.s(n),Point.s(o),Point.s(r)}mO(t){for(let i=0;ie instanceof Placeholder);i instanceof Placeholder?t.It=i:t.It=null,this.ie!==null?(t.ie=this.ie.copy(),t.ie.group=t):(t.ie!==null&&(t.ie.group=null),t.ie=null),this.ni!==null&&(t.ni=this.ni.copy())}Vo(t){super.Vo(t);const i=t.findSubGraphParts(),e=t.memberParts;for(;e.next();){const s=e.value;if(s.c(),s.invalidateLayout(8),s.clearAdornments(),s instanceof Node)s.invalidateConnectedLinks(i);else if(s instanceof Link){const n=s.labelNodes;for(;n.next();)n.value.invalidateConnectedLinks(i)}}}Jc(t,i,e,s,n,o,r){if(t===3&&i==="elements"){if(n instanceof Placeholder)this.It===null?this.It=n:this.It!==n&&Util.o("Cannot insert a second Placeholder into the visual tree of a Group.");else if(n instanceof Panel){const l=n.findInVisualTree(h=>h instanceof Placeholder);l instanceof Placeholder&&(this.It===null?this.It=l:this.It!==l&&Util.o("Cannot insert a second Placeholder into the visual tree of a Group."))}}else t===4&&i==="elements"&&this.It!==null&&(s===this.It?this.It=null:s instanceof Panel&&this.It.isContainedBy(s)&&(this.It=null));super.Jc(t,i,e,s,n,o,r)}td(t,i){if(super.td(t,i),this.isClipping&&this.type!==Panel.Spot&&this.isSubGraphExpanded){let e=this.resizeObject;e instanceof Panel&&(e=e.findMainElement()),this.ni===null&&(this.ni=new Rect),e.getDocumentBounds(this.ni),e instanceof Shape&&this.ni.inflate(-e.strokeWidth,-e.strokeWidth)}}ah(t,i,e,s){this.hasPlaceholder()&&(this.Jo=this.placeholder),super.ah(t,i,e,s)}ensureBounds(){this.isSubGraphExpanded&&this.memberParts.each(i=>{i.ensureBounds()}),super.ensureBounds()}Hr(){if(!super.Hr())return!1;const t=this.memberParts;for(;t.next();){const i=t.value;if(i instanceof Node){if(!i.isVisible())continue;if(i.is())return!1}else if(i instanceof Link){if(!i.isVisible())continue;if(i.is()&&i.fromNode!==this&&i.toNode!==this)return!1}}return!0}hasPlaceholder(){return this.It!==null&&this.It.isVisibleObject()&&this.isSubGraphExpanded}get placeholder(){return this.It}get computesBoundsAfterDrag(){return(this.E&2048)!==0}set computesBoundsAfterDrag(t){const i=(this.E&2048)!==0;i!==t&&(Util.i(t,"boolean",Group,"computesBoundsAfterDrag"),this.E=this.E^2048,this.t("computesBoundsAfterDrag",i,t))}get computesBoundsIncludingLinks(){return(this.E&4096)!==0}set computesBoundsIncludingLinks(t){Util.i(t,"boolean",Group,"computesBoundsIncludingLinks");const i=(this.E&4096)!==0;i!==t&&(this.E=this.E^4096,this.t("computesBoundsIncludingLinks",i,t))}get computesBoundsIncludingLocation(){return(this.E&8192)!==0}set computesBoundsIncludingLocation(t){Util.i(t,"boolean",Group,"computesBoundsIncludingLocation");const i=(this.E&8192)!==0;i!==t&&(this.E=this.E^8192,this.t("computesBoundsIncludingLocation",i,t))}get handlesDragDropForMembers(){return(this.E&16384)!==0}set handlesDragDropForMembers(t){Util.i(t,"boolean",Group,"handlesDragDropForMembers");const i=(this.E&16384)!==0;i!==t&&(this.E=this.E^16384,this.t("handlesDragDropForMembers",i,t))}get avoidableMembers(){return(this.E&131072)!==0}set avoidableMembers(t){Util.i(t,"boolean",Group,"avoidableMembers");const i=(this.E&131072)!==0;i!==t&&(this.E=this.E^131072,this.t("avoidableMembers",i,t))}get memberParts(){return this.Xd.iterator}j2(t){if(this.Xd.add(t)){t instanceof Group&&this.la.add(t);const e=this.memberAdded;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.Y,n.Y=!0),e(this,t),n!==null&&(n.Y=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ei(!1)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.It;i===null&&(i=this),i.c()}G2(t){if(this.Xd.delete(t)){t instanceof Group&&this.la.delete(t);const e=this.memberRemoved;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.Y,n.Y=!0),e(this,t),n!==null&&(n.Y=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ei(!0)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.It;i===null&&(i=this),i.c()}Kc(){if(this.Xd.count>0){const t=this.diagram;if(t!==null){const e=this.Xd.copy().iterator;for(;e.next();){const s=e.value;t.remove(s)}}}super.Kc()}get layout(){return this.ie}set layout(t){const i=this.ie;if(i!==t){t!==null&&t.diagram!==null&&t.diagram.layout===t&&Util.o("A layout cannot be both the Diagram.layout and a Group.layout: "+t),i!==null&&(i.diagram=null,i.group=null),this.ie=t;const e=this.diagram;t!==null&&(t.diagram=e,t.group=this),e!==null&&(e.Kr=!0),this.t("layout",i,t),e!==null&&e.requestUpdate()}}get memberAdded(){return this.gt!==null?this.gt.uy:null}set memberAdded(t){const i=this.memberAdded;i!==t&&(t!==null&&Util.i(t,"function",Group,"memberAdded"),this.cl(),this.gt.uy=t,this.t("memberAdded",i,t))}get memberRemoved(){return this.gt!==null?this.gt.gy:null}set memberRemoved(t){const i=this.memberRemoved;i!==t&&(t!==null&&Util.i(t,"function",Group,"memberRemoved"),this.cl(),this.gt.gy=t,this.t("memberRemoved",i,t))}get memberValidation(){return this.gt!==null?this.gt.eh:null}set memberValidation(t){const i=this.memberValidation;i!==t&&(t!==null&&Util.i(t,"function",Group,"memberValidation"),this.cl(),this.gt.eh=t,this.t("memberValidation",i,t))}canAddMembers(t){const i=this.diagram;if(i===null)return!1;const e=i.commandHandler,n=e.i2(t).iterator;for(;n.next();){const o=n.value;if(!e.isValidMember(this,o))return!1}return!0}addMembers(t,i){const e=this.diagram;if(e===null)return!1;const s=e.commandHandler,n=s.i2(t);let o=!0;const r=n.iterator;for(;r.next();){const l=r.value;!i||s.isValidMember(this,l)?l.containingGroup=this:o=!1}return o}get ungroupable(){return(this.E&256)!==0}set ungroupable(t){const i=(this.E&256)!==0;i!==t&&(Util.i(t,"boolean",Group,"ungroupable"),this.E=this.E^256,this.t("ungroupable",i,t))}canUngroup(){if(!this.ungroupable)return!1;const t=this.layer;if(t===null||!t.allowUngroup)return!1;const i=t.diagram;return!(i!==null&&!i.allowUngroup)}invalidateConnectedLinks(t){const i=this.wO();if(super.invalidateConnectedLinks(t),i)return;this.kL(!0);const e=this.findExternalLinksConnected();for(;e.next();){const s=e.value;if(t!==void 0&&t.has(s))continue;const n=s.fromNode;if(n!==null&&n!==this&&n.isMemberOf(this)&&!n.isVisible())n.Wi(s.fromPort),n.Wi(s.toPort),s.invalidateRoute();else{const o=s.toNode;o!==null&&o!==this&&o.isMemberOf(this)&&!o.isVisible()&&(o.Wi(s.fromPort),o.Wi(s.toPort),s.invalidateRoute())}}}findExternalLinksConnected(){const t=this.diagram!==null&&this.diagram.dM;if(t&&this.u0!==null)return this.u0.iterator;const i=this.findSubGraphParts();i.add(this);const e=new GSet,s=i.iterator;for(;s.next();){const n=s.value;if(!(n instanceof Node))continue;const o=n.linksConnected;for(;o.next();){const r=o.value;i.has(r)||e.add(r)}}return t&&(this.u0=e),e.iterator}findExternalNodesConnected(){const t=this.findSubGraphParts();t.add(this);const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;if(!(s instanceof Node))continue;const n=s.linksConnected;for(;n.next();){const o=n.value,r=o.fromNode;r!==null&&(!t.has(r)||r===this)&&i.add(r);const l=o.toNode;l!==null&&(!t.has(l)||l===this)&&i.add(l)}}return i.iterator}mE(){function t(e,s){e!==null&&(s.add(e),t(e.containingGroup,s))}const i=new GSet;return t(this,i),i}findSubGraphParts(){const t=new GSet;return Part.sh(t,this,!0,0,!0),t.delete(this),t}Ei(t){super.Ei(t);const i=this.memberParts;for(;i.next();)i.value.Ei(t)}collapseSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.hT(i,t,this),t.isCollapsingExpanding=!1}hT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ei(!1),n instanceof Group&&n.isSubGraphExpanded&&(n.wasSubGraphExpanded=n.isSubGraphExpanded,n.hT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t),i.Lc(n,e);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!1}expandSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.aT(i,t,this),t.isCollapsingExpanding=!1}aT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ei(!0),n instanceof Group&&n.wasSubGraphExpanded&&(n.wasSubGraphExpanded=!1,n.aT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!0}get isSubGraphExpanded(){return(this.E&512)!==0}set isSubGraphExpanded(t){const i=(this.E&512)!==0;if(i!==t){Util.i(t,"boolean",Group,"isSubGraphExpanded"),this.E=this.E^512;const e=this.diagram;this.t("isSubGraphExpanded",i,t);const s=this.subGraphExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.Y,e.Y=!0),s(this),e!==null&&(e.Y=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.It!==null&&this.It.c(),this.memberParts.each(n=>n.updateAdornments());return}t?this.expandSubGraph():this.collapseSubGraph()}}get wasSubGraphExpanded(){return(this.E&1024)!==0}set wasSubGraphExpanded(t){const i=(this.E&1024)!==0;i!==t&&(Util.i(t,"boolean",Group,"wasSubGraphExpanded"),this.E=this.E^1024,this.t("wasSubGraphExpanded",i,t))}get subGraphExpandedChanged(){return this.gt!==null?this.gt.my:null}set subGraphExpandedChanged(t){const i=this.subGraphExpandedChanged;i!==t&&(t!==null&&Util.i(t,"function",Group,"subGraphExpandedChanged"),this.cl(),this.gt.my=t,this.t("subGraphExpandedChanged",i,t))}move(t,i){i===void 0&&(i=!1);const e=i?this.location:this.position,s=e.x,n=e.y,o=t.x,r=t.y;if((s===o||isNaN(s)&&isNaN(o))&&(n===r||isNaN(n)&&isNaN(r)))return;const l=o-(isNaN(s)?0:s),h=r-(isNaN(n)?0:n),a=Point.l();super.move(t,i);const c=new GSet,u=this.findSubGraphParts().iterator;for(;u.next();){const d=u.value;d instanceof Link&&(d.suspendsRouting&&c.add(d),!(!d.Me&&(d.fromNode===this||d.toNode===this))&&(d.suspendsRouting=!0))}for(u.reset();u.next();){const d=u.value;if(d.Cl()||d instanceof Node&&d.isLinkLabel)continue;const m=d.position,g=d.location;m.isReal()?(a.x=m.x+l,a.y=m.y+h,d.position=a):g.isReal()&&(a.x=g.x+l,a.y=g.y+h,d.location=a)}for(u.reset();u.next();){const d=u.value;if(!(d instanceof Link)||(d.suspendsRouting=c.has(d),!d.Me&&(d.fromNode===this||d.toNode===this)))continue;const m=d.position;a.x=m.x+l,a.y=m.y+h,a.isReal()?d.move(a):d.invalidateRoute()}Point.s(a)}wO(){return(this.E&65536)!==0}kL(t){(this.E&65536)!==0!==t&&(this.E=this.E^65536)}get Jr(){return(this.E&32768)!==0}set Jr(t){(this.E&32768)!==0!==t&&(this.E=this.E^32768)}}class Placeholder extends GraphObject{$t;Kd;constructor(t){super(),this.$t=Margin.Eg,this.Kd=new Rect(NaN,NaN,NaN,NaN),t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.$t=this.$t.N(),t.Kd=this.Kd.copy()}hh(t){if(this.background===null)return!1;const i=this.naturalBounds;return Rect.contains(0,0,i.width,i.height,t.x,t.y)}Qu(t,i,e,s){const n=this.part;if((n===null||!(n instanceof Group)&&!(n instanceof Adornment))&&Util.o("Placeholder is not inside a Group or Adornment."),n instanceof Group){const o=this.computeBorder(this.Kd),r=this.minSize,l=isFinite(r.width)?Math.max(r.width,o.width):o.width,h=isFinite(r.height)?Math.max(r.height,o.height):o.height,a=this.Vi;a.En(l||0,h||0),this.Qn(0,0,a.width,a.height);const c=n.memberParts;let f=!1;for(;c.next();)if(c.value.isVisible()){f=!0;break}const u=n.diagram;if(f&&u!==null&&!u.animationManager.CS(n)&&!isNaN(o.x)&&!isNaN(o.y)){const d=Point.l();d.setRectSpot(o,n.locationSpot),n.location=d,Point.s(d)}}else{const o=n,r=this.Vi,l=this.$t,h=l.left+l.right,a=l.top+l.bottom,c=o.adornedObject,f=c.getDocumentAngle();o.angle=f;let u=0;c instanceof Shape&&(u=c.strokeWidth);const d=c.getDocumentScale(),m=c.naturalBounds,g=(m.width+u)*d,p=(m.height+u)*d;if(o.type!==Panel.Link){const y=o.category==="Selection"?Spot.TopLeft:o.locationSpot,x=c.getDocumentPoint(y,Point.l());o.location=x,Point.s(x)}if(!isNaN(g)&&!isNaN(p))r.En(g+h||0,p+a||0),this.Qn(-l.left,-l.top,r.width,r.height);else{const y=c.getDocumentPoint(Spot.TopLeft,Point.l()),x=Rect.X(y.x,y.y,0,0);x.unionPoint(c.getDocumentPoint(Spot.BottomRight,y)),x.unionPoint(c.getDocumentPoint(Spot.TopRight,y)),x.unionPoint(c.getDocumentPoint(Spot.BottomLeft,y)),r.En(x.width+h||0,x.height+a||0),this.Qn(-l.left,-l.top,r.width,r.height),Point.s(y),Rect.s(x)}}}ah(t,i,e,s){this.actualBounds.e(t,i,e,s)}computeBorder(t){const i=this.part,e=i.diagram,s=e===null||!e.animationManager.isAnimating;if(e!==null&&i instanceof Group&&!i.layer.isTemporary&&i.computesBoundsAfterDrag&&this.Kd.isReal()){const l=e.toolManager.findTool("Dragging");if(l===e.currentTool){const h=l.computeBorder(i,this.Kd,t);if(h!==null)return h}}const n=Rect.l(),o=this.computeMemberBounds(n),r=this.$t;return i instanceof Group&&!i.isSubGraphExpanded?t.e(o.x-r.left,o.y-r.top,0,0):t.e(o.x-r.left,o.y-r.top,Math.max(o.width+r.left+r.right,0),Math.max(o.height+r.top+r.bottom,0)),Rect.s(n),s&&i instanceof Group&&i.computesBoundsIncludingLocation&&i.location.isReal()&&t.unionPoint(i.location),t}computeMemberBounds(t){if(!(this.part instanceof Group))return t.e(0,0,0,0),t;const i=this.part;let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=i.memberParts;for(;r.next();){const l=r.value;if(!l.isVisible()||l instanceof Link&&(!i.computesBoundsIncludingLinks||l.Oo()||l.fromNode===i||l.toNode===i))continue;const h=l.actualBounds;h.leftn&&(n=h.right),h.bottom>o&&(o=h.bottom)}if(!isFinite(e)||!isFinite(s)){const l=i.location;t.e(l.x,l.y,0,0)}else t.e(e,s,n-e,o-s);return t}get padding(){return this.$t}set padding(t){typeof t=="number"&&(t=new Margin(t));const i=this.$t;i.equals(t)||(t=t.N(),this.$t=t,this.t("padding",i,t),this.c())}}class Layout{p;ha;Yd;kr;Gd;jd;Fo;ul;Hd;qd;go;constructor(t){GSet.Yi(this),this.p=null,this.ha=null,this.Yd=!0,this.kr=!0,this.Gd=!1,this.jd=new Point(0,0).g(),this.Fo=!0,this.ul=null,this.Hd=null,this.qd=!1,this.go=null,t&&Object.assign(this,t)}cloneProtected(t){t.Yd=this.Yd,t.kr=this.kr,t.Gd=this.Gd,t.jd.a(this.jd),t.Fo=this.Fo,t.ul=this.ul,t.Hd=this.Hd,t.qd=!0}copy(){const t=new this.constructor;return this.cloneProtected(t),t}ri(t){Util.lr(this,t)}toString(){let t=Util.sn(this.constructor);return t+="(",this.group!==null&&(t+=" in "+this.group),this.diagram!==null&&(t+=" for "+this.diagram),t+=")",t}get diagram(){return this.p}set diagram(t){this.p=t}get group(){return this.ha}set group(t){this.ha!==t&&(this.ha=t,t!==null&&(this.p=t.diagram))}get isOngoing(){return this.Yd}set isOngoing(t){this.Yd!==t&&(Util.i(t,"boolean",Layout,"isOngoing"),this.Yd=t)}get isInitial(){return this.kr}set isInitial(t){Util.i(t,"boolean",Layout,"isInitial"),this.kr=t,t||(this.qd=!0)}get isViewportSized(){return this.Gd}set isViewportSized(t){this.Gd!==t&&(Util.i(t,"boolean",Layout,"isViewportSized"),this.Gd=t,t&&this.invalidateLayout())}get isRouting(){return this.Fo}set isRouting(t){this.Fo!==t&&(Util.i(t,"boolean",Layout,"isRouting"),this.Fo=t)}get isRealtime(){return this.ul}set isRealtime(t){this.ul!==t&&(t!==null&&Util.i(t,"boolean",Layout,"isRealtime"),this.ul=t)}get isValidLayout(){return this.qd}set isValidLayout(t){if(this.qd!==t&&(Util.i(t,"boolean",Layout,"isValidLayout"),this.qd=t,!t)){const i=this.diagram;i!==null&&(i.Kr=!0)}}invalidateLayout(){if(this.isValidLayout){const t=this.diagram;if(t===null||t.undoManager.isUndoingRedoing)return;const i=t.animationManager;if(i.isTicking)return;i.defaultAnimation.isAnimating&&i.stopAnimation(),(this.isOngoing&&t.Bh||this.isInitial&&!t.Bh)&&(this.isValidLayout=!1,t.requestUpdate())}}get network(){return this.go}set network(t){this.go!==t&&(this.go=t,t!==null&&(t.layout=this))}createNetwork(){return new LayoutNetwork(this)}makeNetwork(t){const i=this.createNetwork();return t instanceof Diagram?(i.addParts(t.nodes,!0),i.addParts(t.links,!0)):t instanceof Group?i.addParts(t.memberParts):i.addParts(t.iterator),i}updateParts(){this.isValidLayout=!0;let t=this.diagram;if(t===null&&this.network!==null){const i=this.network.vertexes.iterator;for(;i.next();){const s=i.value.node;if(s!==null&&(t=s.diagram,t!==null))break}}try{t!==null&&t.startTransaction("Layout"),this.commitLayout()}finally{t!==null&&t.commitTransaction("Layout")}}commitLayout(){if(this.network===null)return;const t=this.network.vertexes.iterator;for(;t.next();)t.value.commit();if(this.isRouting){const i=this.network.edges.iterator;for(;i.next();)i.value.commit()}}doLayout(t){const i=new GSet;if(t instanceof Diagram?(this.kh(i,t.nodes,!0,this.Jr,!0,!1,!0),this.kh(i,t.parts,!0,this.Jr,!0,!1,!0)):t instanceof Group?this.kh(i,t.memberParts,!1,this.Jr,!0,!1,!0):i.addAll(t.iterator),i.count>0){const s=this.diagram;s!==null&&s.startTransaction("Layout"),this.doMinimalNoNetworkLayout(i),s!==null&&s.commitTransaction("Layout")}this.isValidLayout=!0}doMinimalNoNetworkLayout(t){const i=t.count,e=Math.ceil(Math.sqrt(i));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const s=this.arrangementOrigin.x,n=this.arrangementOrigin.y;let o=s,r=n,l=0,h=0;const a=t.iterator;for(;a.next();){const c=a.value;c.ensureBounds();const f=c.measuredBounds,u=f.width,d=f.height;c.moveTo(o,r),c instanceof Group&&(c.Jr=!1),o+=Math.max(u,50)+20,h=Math.max(h,Math.max(d,50)),l>=e-1?(l=0,o=s,r+=h+20,h=0):l++}}doMinimalNetworkLayout(){const t=this.network.vertexes.count,i=Math.ceil(Math.sqrt(t));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const e=this.arrangementOrigin.x,s=this.arrangementOrigin.y;let n=e,o=s,r=0,l=0;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value.node;if(a===null||a instanceof Link||(a.ensureBounds(),!this.Jr(a)))continue;const c=a.measuredBounds,f=c.width,u=c.height;a.moveTo(n,o),a instanceof Group&&(a.Jr=!1),n+=Math.max(f,50)+20,l=Math.max(l,Math.max(u,50)),r>=i-1?(r=0,n=e,o+=l+20,l=0):r++}}Jr(t){return!!(!t.location.isReal()&&!t.position.isReal()||t instanceof Group&&t.Jr)}kh(t,i,e,s,n,o,r){const l=i.iterator;for(;l.next();){const h=l.value;if(!(e&&!h.isTopLevel)&&!(s!==null&&!s(h))&&h.canLayout())if(n&&h instanceof Node){if(h.isLinkLabel)continue;h instanceof Group&&h.layout===null?this.kh(t,h.memberParts,!1,s,n,o,r):(h.ensureBounds(),t.add(h))}else o&&h instanceof Link?t.add(h):r&&h.Pe()&&!(h instanceof Node)&&(h.ensureBounds(),t.add(h))}}getLayoutBounds(t,i){const e=this.boundsComputation;return e!==null?(i||(i=new Rect),e(t,this,i)):!i&&t.margin.equalTo(0,0,0,0)?t.actualBounds:(i||(i=new Rect),i.set(t.actualBounds),i.addMargin(t.margin),i)}get boundsComputation(){return this.Hd}set boundsComputation(t){this.Hd!==t&&(t!==null&&Util.i(t,"function",Layout,"boundsComputation"),this.Hd=t,this.invalidateLayout())}collectParts(t){const i=new GSet;return t instanceof Diagram?(this.kh(i,t.nodes,!0,null,!0,!0,!0),this.kh(i,t.links,!0,null,!0,!0,!0),this.kh(i,t.parts,!0,null,!0,!0,!0)):t instanceof Group?this.kh(i,t.memberParts,!1,null,!0,!0,!0):this.kh(i,t.iterator,!1,null,!0,!0,!0),i}get arrangementOrigin(){return this.jd}set arrangementOrigin(t){this.jd.equals(t)||(this.jd.a(t),this.invalidateLayout())}initialOrigin(t){const i=this.group;if(i!==null)if(i.hasPlaceholder()){const e=i.placeholder,s=e.getDocumentPoint(Spot.TopLeft);(isNaN(s.x)||isNaN(s.y))&&s.set(t);const n=e.padding;return s.x+=n.left,s.y+=n.top,s}else{const e=i.position.copy();return(isNaN(e.x)||isNaN(e.y))&&e.set(t),e}return t}}class LayoutNetwork{ie;mo;Cn;ky;Py;constructor(t){GSet.Yi(this),this.ie=t,this.mo=new GSet,this.Cn=new GSet,this.ky=new GMap,this.Py=new GMap}clear(){if(this.mo){const t=this.mo.iterator;for(;t.next();)t.value.clear()}if(this.Cn){const t=this.Cn.iterator;for(;t.next();)t.value.clear()}this.mo=new GSet,this.Cn=new GSet,this.ky=new GMap,this.Py=new GMap}toString(t){t===void 0&&(t=0);let i="LayoutNetwork"+(this.layout!==null?"("+this.layout.toString()+")":"");if(t<=0)return i;if(i+=" vertexes: "+this.mo.count+" edges: "+this.Cn.count,t>1){const e=this.mo.iterator;for(;e.next();){const n=e.value;i+=` `+n.toString(t-1)}const s=this.Cn.iterator;for(;s.next();){const n=s.value;i+=` - `+n.toString(t-1)}}return i}get layout(){return this.te}set layout(t){t!==null&&(this.te=t)}get vertexes(){return this.mo}get edges(){return this.Cn}createVertex(){return new LayoutVertex(this)}createEdge(){return new LayoutEdge(this)}addParts(t,i,e){if(t===null)return;i===void 0&&(i=!1),Util.i(i,"boolean",LayoutNetwork,"addParts:toplevelonly"),e===void 0&&(e=null),e===null&&(e=n=>{if(n instanceof Node)return!n.isLinkLabel;if(n instanceof Link){const o=n.fromNode;if(o===null||o.isLinkLabel)return!1;const r=n.toNode;return!(r===null||r.isLinkLabel)}return!1});const s=t.iterator;for(;s.next();){const n=s.value;if(n instanceof Node&&!(i&&!n.isTopLevel)&&n.canLayout()&&e(n))if(n instanceof Group&&n.layout===null)this.addParts(n.memberParts,!1);else{if(this.findVertex(n)!==null)continue;const o=this.createVertex();o.node=n,this.addVertex(o)}}for(s.reset();s.next();){const n=s.value;if(!(n instanceof Link)||i&&!n.isTopLevel||!n.canLayout()||!e(n)||this.findEdge(n)!==null)continue;const o=n.fromNode,r=n.toNode;if(o===null||r===null||o===r)continue;const l=this.findGroupVertex(o),h=this.findGroupVertex(r);this.linkVertexes(l,h,n)}}findGroupVertex(t){if(t===null)return null;const i=t.findVisibleNode();if(i===null)return null;let e=this.findVertex(i);if(e!==null)return e;let s=i.containingGroup;for(;s!==null;){if(e=this.findVertex(s),e!==null)return e;s=s.containingGroup}return null}addVertex(t){if(t===null)return;this.mo.add(t);const i=t.node;i!==null&&this.ky.set(i,t),t.network=this}addNode(t){if(t===null)return null;let i=this.findVertex(t);return i===null&&(i=this.createVertex(),i.node=t,this.addVertex(i)),i}deleteVertex(t){if(t!==null&&this.cT(t)){let i=t._o;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}i=t.tr;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}}}cT(t){if(t===null)return!1;const i=this.mo.delete(t);if(i){const e=t.node;e!==null&&this.ky.delete(e)}return i}deleteNode(t){if(t===null)return;const i=this.findVertex(t);i!==null&&this.deleteVertex(i)}findVertex(t){return t===null?null:this.ky.get(t)}addEdge(t){if(t===null)return;this.uN(t);const i=t.toVertex;i!==null&&i.addSourceEdge(t);const e=t.fromVertex;e!==null&&e.addDestinationEdge(t)}uN(t){if(t===null)return;this.Cn.add(t);const i=t.link;i!==null&&this.findEdge(i)===null&&this.Py.set(i,t),t.network=this}addLink(t){if(t===null)return null;const i=t.fromNode,e=t.toNode;let s=this.findEdge(t);return s===null?(s=this.createEdge(),s.link=t,i!==null&&(s.fromVertex=this.addNode(i)),e!==null&&(s.toVertex=this.addNode(e)),this.addEdge(s)):(i!==null?s.fromVertex=this.addNode(i):s.fromVertex=null,e!==null?s.toVertex=this.addNode(e):s.toVertex=null),s}deleteEdge(t){if(t===null)return;const i=t.toVertex;i!==null&&i.deleteSourceEdge(t);const e=t.fromVertex;e!==null&&e.deleteDestinationEdge(t),this.dN(t)}dN(t){if(t===null)return!1;const i=this.Cn.delete(t);if(i){const e=t.link;e!==null&&this.Py.delete(e)}return i}deleteLink(t){if(t===null)return;const i=this.findEdge(t);i!==null&&this.deleteEdge(i)}findEdge(t){return t===null?null:this.Py.get(t)}linkVertexes(t,i,e){if(t===null||i===null)return null;if(t.network===this&&i.network===this){const s=this.createEdge();return s.link=e,s.fromVertex=t,s.toVertex=i,this.addEdge(s),s}return null}reverseEdge(t){if(t===null)return;const i=t.fromVertex,e=t.toVertex;i===null||e===null||(i.deleteDestinationEdge(t),e.deleteSourceEdge(t),t.reverseEdge(),i.addSourceEdge(t),e.addDestinationEdge(t))}deleteSelfEdges(){const t=Util.ot(),i=this.Cn.iterator;for(;i.next();){const s=i.value;s.fromVertex===s.toVertex&&t.push(s)}const e=t.length;for(let s=0;s0||t.tr.count>0)}splitIntoSubNetworks(t){t===void 0&&(t=!0),t&&(this.deleteArtificialVertexes(),this.deleteUselessEdges(),this.deleteSelfEdges());const i=new List;let e=!0;for(;e;){e=!1;const s=this.mo.iterator;for(;s.next();){const n=s.value;if(this.isSingleton(n))continue;const o=this.layout.createNetwork();i.add(o),this.bO(o,n),e=!0;break}}return i.sort((s,n)=>s===null||n===null||s===n?0:n.vertexes.count-s.vertexes.count),i}bO(t,i){if(i===null)return;const e=new List;for(e.add(i);e.count>0;){const s=e.first();if(e.removeAt(0),s.network===t)continue;this.cT(s),t.addVertex(s);let n=s.sourceEdges;for(;n.next();){const o=n.value;o.network!==t&&(this.dN(o),t.uN(o),e.add(o.fromVertex))}for(n=s.destinationEdges;n.next();){const o=n.value;o.network!==t&&(this.dN(o),t.uN(o),e.add(o.toVertex))}}}findAllParts(){const t=new GSet,i=this.mo.iterator;for(;i.next();){const s=i.value;t.add(s.node)}const e=this.Cn.iterator;for(;e.next();){const s=e.value;t.add(s.link)}return t}}class LayoutVertex{go;Qt;ue;Ae;qe;_o;tr;constructor(t){GSet.Yi(this),this.go=t,this.Ae=new Rect(0,0,10,10).g(),this.qe=new Point(5,5).g(),this.Qt=null,this.ue=null,this._o=new List,this.tr=new List}clear(){this.Qt=null,this.ue=null,this._o=new List,this.tr=new List}toString(t){t===void 0&&(t=0);let i="LayoutVertex#"+GSet.as(this);if(t>0&&(i+=this.node!==null?"("+this.node.toString()+")":"",t>1)){let e="",s=!0,n=this._o.iterator;for(;n.next();){const r=n.value;s?s=!1:e+=",",e+=r.toString(0)}let o="";for(s=!0,n=this.tr.iterator;n.next();){const r=n.value;s?s=!1:o+=",",o+=r.toString(0)}i+=" sources: "+e+" destinations: "+o}return i}get po(){return this._o.$N}get ir(){return this.tr.$N}get data(){return this.Qt}set data(t){if(this.Qt=t,t!==null&&t.bounds){const i=t.bounds,e=i.x,s=i.y,n=i.width,o=i.height;this.qe.e(n/2,o/2),this.Ae.e(e,s,n,o)}}get node(){return this.ue}set node(t){if(this.ue!==t){this.ue=t,t.ensureBounds();const i=this.network.layout,e=Rect.l(),s=i.getLayoutBounds(t,e);let n=s.x,o=s.y;const r=s.width,l=s.height;if(isNaN(n)&&(n=0),isNaN(o)&&(o=0),this.Ae.e(n,o,r,l),Rect.s(e),!(t instanceof Group)){const h=t.locationObject.getDocumentPoint(Spot.Center);if(h.isReal()){this.qe.e(h.x-n,h.y-o);return}}this.qe.e(r/2,l/2)}}get bounds(){return this.Ae}set bounds(t){this.Ae.equals(t)||this.Ae.a(t)}get focus(){return this.qe}set focus(t){this.qe.equals(t)||this.qe.a(t)}get centerX(){return this.Ae.x+this.qe.x}set centerX(t){const i=this.Ae;i.x+this.qe.x!==t&&(i.rt(),i.x=t-this.qe.x,i.g())}get centerY(){return this.Ae.y+this.qe.y}set centerY(t){const i=this.Ae;i.y+this.qe.y!==t&&(i.rt(),i.y=t-this.qe.y,i.g())}get focusX(){return this.qe.x}set focusX(t){const i=this.qe;i.x!==t&&(i.rt(),i.x=t,i.g())}get focusY(){return this.qe.y}set focusY(t){const i=this.qe;i.y!==t&&(i.rt(),i.y=t,i.g())}get x(){return this.Ae.x}set x(t){const i=this.Ae;i.x!==t&&(i.rt(),i.x=t,i.g())}get y(){return this.Ae.y}set y(t){const i=this.Ae;i.y!==t&&(i.rt(),i.y=t,i.g())}get width(){return this.Ae.width}set width(t){const i=this.Ae;i.width!==t&&(i.rt(),i.width=t,i.g())}get height(){return this.Ae.height}set height(t){const i=this.Ae;i.height!==t&&(i.rt(),i.height=t,i.g())}commit(){const t=this.Qt;if(t!==null){const e=this.bounds,s=t.bounds;Util.wt(s)?(s.x=e.x,s.y=e.y,s.width=e.width,s.height=e.height):t.bounds=e.copy();return}const i=this.node;if(i!==null){const e=this.bounds;if(!(i instanceof Group)){const s=Rect.l();i.ensureBounds();const n=this.network.layout.getLayoutBounds(i,s),o=i.locationObject.getDocumentPoint(Spot.Center);if(n.isReal()&&o.isReal()){i.moveTo(e.x+this.focusX-(o.x-n.x)+i.margin.left,e.y+this.focusY-(o.y-n.y+i.margin.top)),Rect.s(s);return}Rect.s(s)}i.moveTo(e.x+i.margin.left,e.y+i.margin.top)}}addSourceEdge(t){t!==null&&(this._o.has(t)||this._o.add(t))}deleteSourceEdge(t){t!==null&&this._o.delete(t)}addDestinationEdge(t){t!==null&&(this.tr.has(t)||this.tr.add(t))}deleteDestinationEdge(t){t!==null&&this.tr.delete(t)}get network(){return this.go}set network(t){this.go=t}get sourceVertexes(){const t=new GSet,i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}return t.iterator}get destinationVertexes(){const t=new GSet,i=this.destinationEdges;for(;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get vertexes(){const t=new GSet;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get sourceEdges(){return this._o.iterator}get destinationEdges(){return this.tr.iterator}get edges(){const t=new List;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e)}return t.iterator}get edgesCount(){return this._o.count+this.tr.count}static standardComparer(t,i){const e=t.ue,s=i.ue;if(e)if(s){const n=e.text,o=s.text;return no?1:0}else return 1;else return s!==null?-1:0}static smartComparer(t,i){if(t!==null)if(i!==null){const e=t.ue,s=i.ue;if(e!==null)if(s!==null){const n=e.text.toLocaleLowerCase(),o=s.text.toLocaleLowerCase(),r=n.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),l=o.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let h=0;for(;h0&&(i+=this.He!==null?"("+this.He.toString()+")":"",t>1&&(i+=" "+(this.We?this.We.toString():"null")+" --> "+(this.Je?this.Je.toString():"null"))),i}reverseEdge(){const t=this.We;this.We=this.Je,this.Je=t}commit(){}getOtherVertex(t){return this.Je===t?this.We:this.We===t?this.Je:null}get network(){return this.go}set network(t){this.go=t}get data(){return this.Qt}set data(t){this.Qt!==t&&(this.Qt=t)}get link(){return this.He}set link(t){this.He!==t&&(this.He=t)}get fromVertex(){return this.We}set fromVertex(t){this.We!==t&&(this.We=t)}get toVertex(){return this.Je}set toVertex(t){this.Je!==t&&(this.Je=t)}}var GridAlignment=(w=>(w[w.Position=0]="Position",w[w.Location=1]="Location",w))(GridAlignment||{}),GridArrangement=(w=>(w[w.LeftToRight=10]="LeftToRight",w[w.RightToLeft=11]="RightToLeft",w))(GridArrangement||{}),GridSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w))(GridSorting||{});class GridLayout extends Layout{Jd;$d;Lo;Ln;ni;zi;pe;ye;constructor(t){super(),this.isViewportSized=!0,this.Jd=NaN,this.$d=NaN,this.Lo=new Size(NaN,NaN).g(),this.Ln=new Size(10,10).g(),this.ni=1,this.zi=10,this.pe=22,this.ye=GridLayout.standardComparer,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Jd=this.Jd,t.$d=this.$d,t.Lo.a(this.Lo),t.Ln.a(this.Ln),t.ni=this.ni,t.zi=this.zi,t.pe=this.pe,t.ye=this.ye}ri(t){t in GridSorting?this.sorting=t:t in GridArrangement?this.arrangement=t:t in GridAlignment?this.alignment=t:super.ri(t)}doLayout(t){this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.collectParts(t),e=this.diagram,n=i.copy().iterator;for(;n.next();){const m=n.value;if(m.Cl()&&(m.fromNode!==null||m.toNode!==null)){i.delete(m);continue}if(m.ensureBounds(),m instanceof Group){const g=m.memberParts;for(;g.next();){const p=g.value;i.delete(p)}}}const o=i.toArray();if(o.length===0)return;switch(this.sorting){case 20:break;case 21:o.reverse();break;case 22:o.sort(this.comparer);break;case 23:o.sort(this.comparer),o.reverse();break}let r=this.wrappingColumn;isNaN(r)&&(r=0);let l=this.wrappingWidth;if(isNaN(l)&&e!==null){const m=e.viewportBounds,g=e.padding;l=Math.max(m.width-g.left-g.right,0)}else l=Math.max(this.wrappingWidth,0);r<=0&&l<=0&&(r=1);let h=this.spacing.width;isFinite(h)||(h=0);let a=this.spacing.height;isFinite(a)||(a=0),e!==null&&e.startTransaction("Layout");const c=[];switch(this.alignment){case 0:this.kO(o,l,r,h,a,c);break;case 1:this.PO(o,l,r,h,a,c);break}let f=0,u=0,d=0;for(let m=0;m0&&m>e-1||i>0&&m>0&&L-c>i)&&(o.push(new Rect(0,d,i+s,g)),m=0,u=c,d+=g,g=0),g=Math.max(g,M);let C=0;switch(a){case 11:C=-x.width;break;default:C=0;break}switch(y.moveTo(u+C+y.margin.left,d+y.margin.top),a){case 11:u-=P;break;default:u+=P;break}m++}o.push(new Rect(0,d,i+s,g)),Rect.s(r)}PO(t,i,e,s,n,o){const r=Rect.l();let l=Math.max(this.cellSize.width,1),h=0,a=0,c=0;const f=Point.l();for(let C=0;C=h&&(i-=h);let x=0,k=0;const b=Math.max(this.cellSize.height,1);c=0;let P=0,M=!0;const L=Point.l();for(let C=0;C0)switch(u){case 11:{let D=(g-d-(N.width-T.x))/l;Geo.K(Math.round(D),D)?D=Math.round(D):D=Math.floor(D),g=D*l+d;break}default:{let D=(g-d+T.x)/l;Geo.K(Math.round(D),D)?D=Math.round(D):D=Math.ceil(D),g=D*l+d;break}}else switch(u){case 11:x=g+T.x+N.width;break;default:x=g-T.x;break}let A=0;switch(u){case 11:A=-(g+T.x)+x;break;default:A=g+N.width-T.x-x;break}if(e>0&&y>e-1||i>0&&y>0&&A>i){o.push(new Rect(0,M?p-c:p,i+s,P+c+n));for(let D=0;Dk&&(S.width+=S.x-k,S.x=k)}Rect.s(r)}commitLayers(t,i){}get wrappingWidth(){return this.Jd}set wrappingWidth(t){this.Jd!==t&&(Util.i(t,"number",GridLayout,"wrappingWidth"),(t>0||isNaN(t))&&(this.Jd=t,this.isViewportSized=isNaN(t),this.invalidateLayout()))}get wrappingColumn(){return this.$d}set wrappingColumn(t){this.$d!==t&&(Util.i(t,"number",GridLayout,"wrappingColumn"),(t>0||isNaN(t))&&(this.$d=t,this.invalidateLayout()))}get cellSize(){return this.Lo}set cellSize(t){this.Lo.equals(t)||(this.Lo.a(t),this.invalidateLayout())}get spacing(){return this.Ln}set spacing(t){this.Ln.equals(t)||(this.Ln.a(t),this.invalidateLayout())}get alignment(){return this.ni}set alignment(t){this.ni!==t&&(t===1||t===0)&&(this.ni=t,this.invalidateLayout())}get arrangement(){return this.zi}set arrangement(t){this.zi!==t&&(t===10||t===11)&&(this.zi=t,this.invalidateLayout())}get sorting(){return this.pe}set sorting(t){this.pe!==t&&(t===20||t===21||t===22||t===23)&&(this.pe=t,this.invalidateLayout())}get comparer(){return this.ye}set comparer(t){this.ye!==t&&(Util.i(t,"function",GridLayout,"comparer"),this.ye=t,this.invalidateLayout())}static standardComparer(t,i){const e=t.text,s=i.text;return es?1:0}static smartComparer(t,i){if(t!==null)if(i!==null){const e=t.text.toLocaleLowerCase(),s=i.text.toLocaleLowerCase(),n=e.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),o=s.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let r=0;for(;r{e.containsNodeData(s)&&this.gT(s,!1)}),t.forEach(s=>{e.containsNodeData(s)&&this.S1(s)}),i!==!1&&this.diagram.bb(!1)}gT(t,i){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.yo.has(t))return null;i===void 0&&(i=!0);const e=this.MO(t);return e!==null&&i&&this.S1(t),e}MO(t){if(t==null||this.p.undoManager.isUndoingRedoing||this.yo.has(t))return null;const i=this.SO(t),e=this.findTemplateForNodeData(t,i);if(e!==null){e.li();const s=e.copy();if(s!==null){const n=this.diagram.ce;return this.diagram.ce=!0,s.Ho=i,s.Qt=t,this.My&&(s.ll="Tool"),this.diagram.add(s),s.Qt=null,s.data=t,this.diagram.ce=n,s}}return null}insertLink(t,i,e,s){return null}S1(t){}SO(t){return this.p.model.getCategoryForNodeData(t)}static mT=!1;static pT=!1;findTemplateForNodeData(t,i){const e=this.p,s=e.model,n=s.Hc()&&s.isGroupForData(t);let o=null;return n?(o=e.groupTemplateMap.get(i),o===null&&(o=e.groupTemplateMap.get(""),o===null&&(PartManager.pT||(PartManager.pT=!0,Util.oi('No Group template found for category "'+i+'"'),Util.oi(" Using default group template")),o=e.rS))):(o=e.nodeTemplateMap.get(i),o===null&&(o=e.nodeTemplateMap.get(""),o===null&&(PartManager.mT||(PartManager.mT=!0,Util.oi('No Node template found for category "'+i+'"'),Util.oi(" Using default node template")),o=e.sS))),o}getLinkCategoryForData(t){return""}setLinkCategoryForData(t,i){}setFromNodeForLink(t,i,e){}setToNodeForLink(t,i,e){}static yT=!1;findLinkTemplateForCategory(t){const i=this.p;let e=i.linkTemplateMap.get(t);return e===null&&(e=i.linkTemplateMap.get(""),e===null&&(PartManager.yT||(PartManager.yT=!0,Util.oi('No Link template found for category "'+t+'"'),Util.oi(" Using default link template")),e=i.nS)),e}uv(t,i,e){t instanceof Link?(i!==null&&this.uT(i,t),e!==null&&this.fT(e,t)):t instanceof Part&&(i!==null&&this.yo.delete(i),e!==null&&this.yo.set(e,t))}dT(){const t=this.diagram.model;this.mN(t.nodeDataArray)}mN(t){t.forEach(i=>{this.N1(i)})}N1(t){const i=this.findPartForData(t);i!==null&&(this.diagram.NS(i,!1),this.pN(i))}pN(t){}rN(t){}findPartForKey(t){if(t==null)return null;const i=this.p.model.findNodeDataForKey(t);return i!==null?this.yo.get(i):null}findNodeForKey(t){if(t==null)return null;const i=this.p.model.findNodeDataForKey(t);if(i===null)return null;const e=this.yo.get(i);return e instanceof Node?e:null}findLinkForKey(t){return null}findPartForData(t){if(t===null)return null;let i=this.yo.get(t);return i!==null||(i=this.dl.get(t)),i}findNodeForData(t){if(t===null)return null;const i=this.yo.get(t);return i instanceof Node?i:null}findLinkForData(t,i){return t===null?null:this.dl.get(t)}findNodesByExample(...t){const i=new GSet,e=this.Zd.iterator;for(;e.next();){const s=e.value,n=s.data;if(n!==null)for(let o=0;o{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),this.parts.each(o=>{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),s.forEach(o=>t.xT(o,!1));for(let o=0;o0){for(let o=0;oi.SL(s));const e=t.gh;if(Array.isArray(e)){const s=this.Ua.get(e);if(s===null){const n=[];n.push(t),this.Ua.set(e,n)}else{for(let n=0;ni.pR(s));const e=t.gh;if(Array.isArray(e)){const s=this.Ua.get(e);if(s!==null){for(let n=0;n0&&i.removeParts(l,!1),h.count>0){const c=h.iterator;for(;c.next();){const f=c.key,u=c.value;s.set(f,u)}}}if(i!==null&&this.p!==null){const o=i.model,r=o.afterCopyFunction;if(r!==null){const l=new GMap;s.each(a=>{a.key.data!==null&&l.set(a.key.data,a.value.data)});const h=this.p.model;r(l,o,h)}}const n=s.iterator;for(;n.next();)n.value.updateTargetBindings();return s}C1(t,i,e,s){if(t===null||s&&!t.canCopy())return null;if(e.has(t))return e.get(t);const n=this.wN(t,i);if(!(n instanceof Part))return null;if(n.isSelected=!1,n.isHighlighted=!1,e.set(t,n),t instanceof Node){const o=t.linksConnected;for(;o.next();){const r=o.value;if(r.fromNode===t){const l=e.get(r);l!==null&&(l.fromNode=n)}if(r.toNode===t){const l=e.get(r);l!==null&&(l.toNode=n)}}if(t instanceof Group&&n instanceof Group){const r=t.memberParts;for(;r.next();){const l=r.value,h=this.C1(l,i,e,s);h instanceof Link||h!==null&&(h.containingGroup=n)}}}else if(t instanceof Link&&n instanceof Link){const o=t.fromNode;if(o!==null){const h=e.get(o);h!==null&&(n.fromNode=h)}const r=t.toNode;if(r!==null){const h=e.get(r);h!==null&&(n.toNode=h)}const l=t.labelNodes;for(;l.next();){const h=l.value,a=this.C1(h,i,e,s);a!==null&&a instanceof Node&&(a.labeledLink=n)}}return n}wN(t,i){let e=null;const s=t.data;if(s!==null&&i!==null){const n=i.model;if(!(t instanceof Link)){const o=n.copyNodeData(s);Util.wt(o)&&(n.addNodeData(o),e=i.findPartForData(o))}}else if(t.li(),e=t.copy(),e!==null){const n=this.p;if(i!==null)i.add(e);else if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const o=n.model;let r=null;e instanceof Link||(r=o.copyNodeData(s)),Util.wt(r)&&(e.data=r)}}return e}get nodes(){return this.Zd}get links(){return this.qs}get parts(){return this.At}get diagram(){return this.p}get addsToTemporaryLayer(){return this.My}set addsToTemporaryLayer(t){this.My=t}get preservesRebuildLocations(){return this.gN}set preservesRebuildLocations(t){this.gN=t}}class GraphLinksPartManager extends PartManager{LS(){const t=this.diagram.model;this.Sy(t.nodeDataArray),this.PT(t.linkDataArray)}Sy(t){super.Sy(t,!1);const i=this.links.iterator;for(;i.next();)i.value.Ad();this.diagram.bb(!1)}PT(t){t.forEach(i=>{this.MT(i)}),this.diagram.bb(!1)}MT(t){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.dl.has(t))return null;const i=this.getLinkCategoryForData(t),e=this.findLinkTemplateForCategory(i);if(e!==null){e.li();const s=e.copy();if(s!==null){const n=this.diagram.ce;this.diagram.ce=!0,s.Ho=i,s.Qt=t;const o=this.diagram.model,r=o.L1(t,!0);r!==""&&(s.fromPortId=r);const l=o.Te(t,!0);if(l!==void 0){const f=this.findNodeForKey(l);f instanceof Node&&(s.fromNode=f)}const h=o.L1(t,!1);h!==""&&(s.toPortId=h);const a=o.Te(t,!1);if(a!==void 0){const f=this.findNodeForKey(a);f instanceof Node&&(s.toNode=f)}const c=o.getLabelKeysForLinkData(t);return Array.isArray(c)&&c.forEach(f=>{const u=this.findNodeForKey(f);u!==null&&(u.labeledLink=s)}),this.My&&(s.ll="Tool"),this.diagram.add(s),s.Qt=null,s.data=t,this.diagram.ce=n,s}}return null}dT(){const t=this.diagram.model;this.ST(t.linkDataArray),this.mN(t.nodeDataArray)}ST(t){t.forEach(i=>{this.N1(i)})}getLinkCategoryForData(t){return this.diagram.model.getCategoryForLinkData(t)}setLinkCategoryForData(t,i){return this.diagram.model.setCategoryForLinkData(t,i)}setFromNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setFromKeyForLinkData(t.data,e.getKeyForNodeData(s))}setToNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setToKeyForLinkData(t.data,e.getKeyForNodeData(s))}rN(t){this.diagram.model.removeLinkData(t.data)}findPartForKey(t){const i=super.findPartForKey(t);if(i===null){const s=this.diagram.model.findLinkDataForKey(t);if(s!==null)return this.dl.get(s)}return i}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findLinkDataForKey(t);return e!==null?this.dl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.Y){i.Y=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="linkFromKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.fromNode=l}}else if(s==="linkToKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.toNode=l}}else if(s==="linkFromPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.fromPortId=r)}}else if(s==="linkToPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.toPortId=r)}}else if(s==="nodeGroupKey"){const n=t.object,o=this.findPartForData(n);if(o!==null){const r=t.newValue;if(r!==void 0){const l=this.findNodeForKey(r);l instanceof Group?o.containingGroup=l:o.containingGroup=null}else o.containingGroup=null}}else if(s==="linkLabelKeys"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.oldValue,l=t.newValue;Array.isArray(r)&&r.forEach(h=>{if(l.indexOf(h)>=0)return;const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=null)}),Array.isArray(l)&&l.forEach(h=>{const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=o)})}}else if(s==="linkCategory"){const n=t.object,o=this.findLinkForData(n),r=t.newValue;o!==null&&typeof r=="string"&&(o.category=r)}else if(s==="linkDataArray"){const n=t.oldValue;this.ST(n);const o=t.newValue;this.PT(o)}i.isModified=!0}else if(e===3){const n=t.newValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.MT(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=t.object,r=this.findLinkForData(o),l=this.findNodeForKey(n);r!==null&&l!==null&&(l.labeledLink=r)}i.isModified=!0}else if(e===4){const n=t.oldValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.N1(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=this.findNodeForKey(n);o!==null&&(o.labeledLink=null)}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&(n==="linkFromKeyProperty"||n==="linkToKeyProperty"||n==="linkFromPortIdProperty"||n==="linkToPortIdProperty"||n==="linkLabelKeysProperty"||n==="nodeIsGroupProperty"||n==="nodeGroupKeyProperty"||n==="linkCategoryProperty")&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.Y=!0}}}kT(){const t=this.diagram.model,i=new GSet,e=t.linkDataArray;e.forEach(n=>{i.add(n)});const s=[];this.links.each(n=>{n.data!==null&&!i.has(n.data)&&s.push(n.data)}),s.forEach(n=>{t.NT(n,!1)}),e.forEach(n=>{this.findLinkForData(n)===null&&t.CT(n,!1)})}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Link){let n=s.Te(i,!0),o=e.findNodeForKey(n);t.fromNode=o,n=s.Te(i,!1),o=e.findNodeForKey(n),t.toNode=o;const r=s.getLabelKeysForLinkData(i);if(r.length>0||t.labelNodes.count>0){if(r.length===1&&t.labelNodes.count===1){const f=r[0],u=t.labelNodes.first();if(s.getKeyForNodeData(u.data)===f)return}const l=new GSet().addAll(r),h=new GSet;t.labelNodes.each(f=>{if(f.data!==null){const u=s.getKeyForNodeData(f.data);u!==void 0&&h.add(u)}});const a=h.copy();a.removeAll(l);const c=l.copy();if(c.removeAll(h),a.count>0||c.count>0){const f=t;a.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink===f&&(d.labeledLink=null)}),c.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink!==f&&(d.labeledLink=f)})}}}else if(!(t instanceof Adornment)){const n=s.getGroupKeyForNodeData(i),o=e.findPartForKey(n);(o===null||o instanceof Group)&&(t.containingGroup=o)}}S1(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Cy(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)){if(n instanceof Group&&i.getGroupKeyForNodeData(l)===e){const h=this.findPartForData(l);h!==null&&(h.containingGroup=n)}}else{const h=this.findLinkForData(l);if(h!==null&&n instanceof Node){i.Te(l,!0)===e&&(h.fromNode=n),i.Te(l,!1)===e&&(h.toNode=n);const a=i.getLabelKeysForLinkData(l);Array.isArray(a)&&a.some(c=>c===e?(n.labeledLink=h,!0):!1)}}}i.Js(e)}const o=i.getGroupKeyForNodeData(t);if(o!==void 0){const r=this.findNodeForKey(o);r instanceof Group&&(n.containingGroup=r)}}}pN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data);if(e!==void 0){const s=t.linksConnected;for(;s.next();){const n=s.value;i.$s(e,n.data)}if(t.isLinkLabel){const n=t.labeledLink;n!==null&&i.$s(e,n.data)}if(t instanceof Group){const n=t.memberParts;for(;n.next();){const r=n.value.data;i.containsNodeData(r)&&i.$s(e,r)}}}}}wN(t,i){let e=super.wN(t,i);if(t instanceof Link){const s=t.data;if(s!==null&&i!==null){const n=i.model,o=n.copyLinkData(s);typeof o=="object"&&o!==null&&(n.addLinkData(o),e=i.findLinkForData(o))}else if(e!==null){const n=this.diagram;if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const r=n.model.copyLinkData(s);typeof r=="object"&&r!==null&&(e.data=r)}}}return e}insertLink(t,i,e,s){const n=this.diagram,o=n.model,r=n.toolManager.findTool("Linking");let l="";t!==null&&(i===null&&(i=t),l=i.portId,l===null&&(l=""));let h="";e!==null&&(s===null&&(s=e),h=s.portId,h===null&&(h=""));const a=r.archetypeLinkData;if(a instanceof Link){a.li();const c=a.copy();if(c!==null){c.fromNode=t,c.fromPortId=l,c.toNode=e,c.toPortId=h,n.add(c);const f=r.archetypeLabelNodeData;if(f instanceof Node){f.li();const u=f.copy();u!==null&&(u.labeledLink=c,n.add(u))}return c}}else if(a!==null){const c=o.copyLinkData(a);if(typeof c=="object"&&c!==null){t!==null&&o.Qd(c,o.getKeyForNodeData(t.data),!0),o._d(c,l,!0),e!==null&&o.Qd(c,o.getKeyForNodeData(e.data),!1),o._d(c,h,!1),o.addLinkData(c);const f=r.archetypeLabelNodeData;if(f!==null&&!(f instanceof Node)){const d=o.copyNodeData(f);if(typeof d=="object"&&d!==null){o.addNodeData(d);const m=o.getKeyForNodeData(d);m!==void 0&&o.addLabelKeyForLinkData(c,m)}}return n.findLinkForData(c)}}return null}}class TreePartManager extends PartManager{kh=null;A1(t,i){if(t===null||i===null||i.findTreeParentLink()!==null)return null;const e=this.diagram.toolManager.findTool("Linking");let s=t,n=i;if(this.diagram.isTreePathToChildren){if(e!==null&&e.bu(s,n,null,!0))return null}else if(s=i,n=t,e!==null&&e.bu(s,n,null,!0))return null;const o=this.getLinkCategoryForData(i.data),r=this.findLinkTemplateForCategory(o);if(r!==null){r.li();const l=r.copy();if(l!==null){const h=this.diagram.ce;return this.diagram.ce=!0,l.Ho=o,l.Qt=i.data,l.fromNode=s,l.toNode=n,this.diagram.add(l),l.Qt=null,l.data=i.data,this.diagram.ce=h,l}}return null}getLinkCategoryForData(t){return this.diagram.model.getParentLinkCategoryForNodeData(t)}setLinkCategoryForData(t,i){this.diagram.model.setParentLinkCategoryForNodeData(t,i)}setFromNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren)s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n));else{const o=this.kh;this.kh=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.toNode!==null?t.toNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.kh=o}}setToNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren){const o=this.kh;this.kh=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.fromNode!==null?t.fromNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.kh=o}else s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n))}rN(t){this.diagram.model.setParentKeyForNodeData(t.data,void 0)}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findNodeDataForKey(t);return e!==null?this.dl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.Y){i.Y=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="nodeParentKey"){const n=t.object,o=t.newValue,r=this.findNodeForKey(o),l=this.findNodeForData(n);if(this.kh!==null)r!==null&&(this.kh.data=n,this.kh.category=this.getLinkCategoryForData(n));else if(l!==null){const h=l.findTreeParentLink();h!==null?r===null?i.remove(h):i.isTreePathToChildren?h.fromNode=r:h.toNode=r:this.A1(r,l)}}else if(s==="parentLinkCategory"){const n=t.object,o=this.findNodeForData(n),r=t.newValue;if(o!==null&&typeof r=="string"){const l=o.findTreeParentLink();l!==null&&(l.category=r)}}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&n==="nodeParentKeyProperty"&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.Y=!0}}}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Node){const n=s.getParentKeyForNodeData(i),o=e.findNodeForKey(n),r=t.findTreeParentNode();if(o!==r){const l=t.findTreeParentLink();o!==null?l!==null?e.isTreePathToChildren?l.fromNode=o:l.toNode=o:this.A1(o,t):l!==null&&e.NS(l,!1)}}}Ny(t,i){if(super.Ny(t,i),typeof i=="string"&&this.findPartForData(t)!==null){const s=this.findLinkForData(t);s!==null&&s.updateTargetBindings(i)}}S1(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Cy(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)&&n instanceof Node&&i.getParentKeyForNodeData(l)===e){const h=this.findNodeForData(l);this.A1(n,h)}}i.Js(e)}const o=i.getParentKeyForNodeData(t);if(o!==void 0&&n instanceof Node){const r=this.findNodeForKey(o);this.A1(r,n)}}}pN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data),s=this.findLinkForData(t.data);if(s!==null){s.isSelected=!1,s.isHighlighted=!1;const r=s.layer;if(r!==null){const l=r._i(-1,s,!1);l>=0&&this.diagram.raiseChangedEvent(4,"parts",r,s,null,l,null);const h=s.layerChanged;h!==null&&h(s,r,null)}}const n=this.diagram.isTreePathToChildren,o=t.linksConnected;for(;o.next();){const r=o.value,h=(n?r.toNode:r.fromNode).data;i.containsNodeData(h)&&i.$s(e,h)}}}insertLink(t,i,e,s){const n=this.diagram.model;let o=t,r=e;if(this.diagram.isTreePathToChildren||(o=e,r=t),o!==null&&r!==null){const l=o.data,h=r.data;return n.setParentKeyForNodeData(h,n.getKeyForNodeData(l)),r.findTreeParentLink()}return null}}var BindingMode=(w=>(w[w.OneWay=1]="OneWay",w[w.TwoWay=2]="TwoWay",w))(BindingMode||{});class Binding{n;xN;Ba;Nf;Ph;Cf;Lf;Af;T1;ke;md;cf;constructor(t,i,e,s){GSet.Yi(this),t===void 0?t="":Util.i(t,"string",Binding,"constructor:targetprop"),i===void 0?i=t:Util.i(i,"string",Binding,"constructor:sourceprop"),e===void 0?e=null:e!==null&&Util.i(e,"function",Binding,"constructor:conv"),this.xN=-1,this.ke=null,this.Ba=t,this.md=0,this.cf=0,this.Nf=null,this.Ph=i,this.Cf=e,s===void 0?(this.Lf=1,this.Af=null):(this.Lf=2,this.Af=s),this.T1=new GSet,this.n=2}copy(){const t=new this.constructor;return this.cloneProtected(t),t}cloneProtected(t){t.Ba=this.Ba,t.md=this.md,t.cf=this.cf,t.Nf=this.Nf,t.Ph=this.Ph,t.Cf=this.Cf,t.Lf=this.Lf,t.Af=this.Af,t.n=this.n&-2}static OneWay=1;static TwoWay=2;static parseEnum(t,i){return Util.i(t,"function",Binding,"parseEnum:ctor"),e=>{let s=parseInt(e);return isNaN(s)&&(s=Util.Oh(t,e),s===null)?i:s}}ri(t){t in BindingMode?this.mode=t:Util.lr(this,t)}static toString(t){return Util.toString(t)}toString(){return"Binding("+this.targetProperty+":"+this.sourceProperty+(this.targetId!==-1?" "+this.targetId:"")+" "+BindingMode[this.mode]+")"}g(){return this.n=this.n|1,this}rt(){return this.n=this.n&-2,this}get targetId(){return this.xN}set targetId(t){this.h&&Util.T(this),Util.i(t,"number",Binding,"targetId"),this.xN=t}get targetProperty(){return this.Ba}set targetProperty(t){this.h&&Util.T(this),Util.i(t,"string",Binding,"targetProperty"),this.Ba=t}get sourceProperty(){return this.Ph}set sourceProperty(t){this.h&&Util.T(this),Util.i(t,"string",Binding,"sourceProperty"),this.Ph=t}get h(){return(this.n&1)!==0}get isToData(){return(this.n&2)!==0}get isToObject(){return(this.n&4)!==0}get isToModel(){return(this.n&8)!==0}get isToTheme(){return(this.n&16)!==0}get bN(){return this.isToTheme&&!(this.isToData||this.isToObject||this.isToModel)}Qu(){return!1}get sourceName(){return this.Nf}set sourceName(t){this.h&&Util.T(this),t!==null&&Util.i(t,"string",Binding,"sourceName"),this.Nf=t,t!==null?this.n=this.n&-3|4:this.n=this.n|2}get converter(){return this.Cf}set converter(t){this.h&&Util.T(this),t!==null&&Util.i(t,"function",Binding,"converter"),this.Cf=t}get backConverter(){return this.Af}set backConverter(t){this.h&&Util.T(this),t!==null&&Util.i(t,"function",Binding,"backConverter"),this.Af=t}get mode(){return this.Lf}set mode(t){this.h&&Util.T(this),this.isToTheme&&t===2&&Util.o("Theme Bindings cannot be TwoWay."),this.Lf=t}makeTwoWay(t){return this.isToTheme&&Util.o("Theme Bindings cannot be TwoWay."),this.mode=2,t&&(Util.i(t,"function",Binding,"makeTwoWay"),this.backConverter=t),this}ofObject(t){return this.h&&Util.T(this),t===void 0&&(t=""),this.sourceName=t,this}ofModel(){return this.h&&Util.T(this),this.n=this.n&-3&-5|8,this.Nf=null,this}QL(t,i){const e=this.sourceName;let s=null;return e===null||e===""?s=t:e==="/"?s=i.part:e==="."?s=i:e===".."?s=i.panel:s=t.findObject(e),s}check(t){const i=this.Ba,e=this.Ph,s=this.Cf;(this.Qu()&&s===null&&this.Mh===null&&i===""||s===null&&i==="")&&Util.oi("Binding error: target property is the empty string: "+this.toString()),this.Qu()&&this.bN&&e===""&&s===null&&this.Mh===null&&Util.oi("Binding error: theme bindings require a source property when not using a converter: "+this.toString()),t&&typeof i=="string"&&(typeof t.setAttribute!="function"&&i.length>0&&i[0]!=="_"&&!Util.fw(t,i)?Util.oi("Binding error: undefined target property: "+i+" on "+t.toString()):i==="name"&&t instanceof GraphObject&&Util.oi("Binding error: cannot modify GraphObject.name on "+t.toString()))}updateTarget(t,i,e){const s=this.Ph;if(e!==void 0&&s!==""&&s!==e)return;const n=this.Ba,o=this.Cf;let r=i;if(s!==""&&!this.bN&&(r=Model.vt(i,s)),r===void 0)return;const l=t.diagram?.themeManager??t.panel?.diagram?.themeManager;if(o===null){if(n!==""){if(this.Qu()&&(r=this.LT(l,r,t,n),r===void 0))return;Model.lt(t,n,r)}}else try{if(n!==""){let h=o(r,t);if(this.Qu()&&(h=this.LT(l,h,t,n),h===void 0))return;Model.lt(t,n,h)}else o(r,t)}catch{}}updateSource(t,i,e,s){if(this.Lf!==2)return;const n=this.Ba;if(e!==void 0&&n!==e)return;const o=this.Ph,r=this.Af;let l=t;if(n!==""&&(l=Model.vt(t,n)),l!==void 0&&!this.T1.has(t))try{this.T1.add(t);const h=s!==null?s.diagram:null,a=h!==null?h.model:null;if(r===null){if(o!=="")a!==null?a.setDataProperty(i,o,l):Model.lt(i,o,l);else if(a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const c=s.itemIndex,f=s.panel.itemArray;a.removeArrayItem(f,c),a.insertArrayItem(f,c,l)}}else try{if(o!==""){const c=r(l,i,a);a!==null?a.setDataProperty(i,o,c):Model.lt(i,o,c)}else{const c=r(l,i,a);if(c!==void 0&&a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const f=s.itemIndex,u=s.panel.itemArray;a.removeArrayItem(u,f),a.insertArrayItem(u,f,c)}}}catch{}}finally{this.T1.delete(t)}}}class ThemeBinding extends Binding{Ly;Mh;Va;constructor(t,i,e,s,n){super(t,i,s),e==null&&(e=""),n===void 0&&(n=null),this.Ly=e,this.Mh=n,this.Va=null,this.n=16}cloneProtected(t){super.cloneProtected(t),t.Ly=this.Ly,t.Mh=this.Mh,t.Va=this.Va}Qu(){return!0}get themeSource(){return this.Ly}set themeSource(t){this.h&&Util.T(this),t!==null&&Util.i(t,"string",ThemeBinding,"themeSource"),this.Ly=t,this.Va=null,t!==null?this.n=this.n|16:this.n=this.n&-17}get themeConverter(){return this.Mh}set themeConverter(t){this.h&&Util.T(this),t!==null&&Util.i(t,"function",ThemeBinding,"themeConverter"),this.Mh=t}ofData(){return this.h&&Util.T(this),this.n=this.n|2,this.Nf=null,this}LT(t,i,e,s){if(!t||(this.bN&&(i=this.Ph),!i&&i!==0))return;let n=this.themeSource;this.Va!==null?n=this.Va:typeof n=="string"&&n.includes(".")&&(this.Va=n.split("."),n=this.Va);let o=t.findValue(i,n,s);return o===void 0&&Util.oi(`Theme warning: ${i} could not be found when setting target property ${s}.`),typeof this.Mh=="function"&&(o=this.Mh(o,e)),o}}class Model{St;tg;vo;D1;De;Tf;Df;ig;eg;sg;ng;za;er;F1;Ro;R1;ti;Sh;og=new GSet;rg=new GSet;Ay;constructor(t,i){if(GSet.Yi(this),this.St="",this.tg="",this.vo=!1,this.D1={},this.De=[],this.ti=new GMap,this.Sh="key",this.Tf=null,this.Df=null,this.ig=!1,this.eg=!1,this.sg=!1,this.ng=null,this.za="category",this.er=new GMap,this.Ay=100,this.F1=new List,this.Ro=!1,this.R1=null,this.undoManager=new UndoManager,t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){t.St=this.St,t.tg=this.tg,t.vo=this.vo,t.Sh=this.Sh,t.Tf=this.Tf,t.Df=this.Df,t.ig=this.ig,t.eg=this.eg,t.sg=this.sg,t.Ay=this.Ay,t.ng=this.ng,t.za=this.za}copy(){const t=new this.constructor;return this.cloneProtected(t),t}clear(){this.De=[],this.ti.clear(),this.er.clear(),this.undoManager.clear()}toString(t){if(t===void 0&&(t=0),t>1)return this.toJson();{let i=(this.name!==""?this.name:"")+" Model";if(t>0){i+=` - node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n{if(u.model===e){if(u.modelChange==="nodeDataArray")u.change===3?n.add(u.newValue):u.change===4&&r.add(u.oldValue);else if(e.containsNodeData(u.object))o.add(u.object);else if(u.change===2&&(e.modelData===u.object||u.propertyName==="modelData"))s=!0;else if(u.object!==null)if(l&&l.has(u.object))l.get(u.object).each(m=>{e.containsNodeData(m)&&o.add(m)});else{if(u.object instanceof Model||e.Aa()&&e.containsLinkData(u.object))return;e.TT(u.object).each(m=>{o.add(m)})}}});const h=this.rg;h.clear(),n.each(u=>{h.add(e.getKeyForNodeData(u)),i||o.add(u)});const a=this.og;a.clear(),r.each(u=>{a.add(e.getKeyForNodeData(u)),i&&o.add(u)});const c=e.cloneDeep(o.toArray());let f=null;return s&&(f===null&&(f={}),f.modelData=this.cloneDeep(this.modelData)),h.count>0&&(f===null&&(f={}),i?f.removedNodeKeys=h.toArray():f.insertedNodeKeys=h.toArray()),c.length>0&&(f===null&&(f={}),f.modifiedNodeData=c),a.count>0&&(f===null&&(f={}),i?f.insertedNodeKeys=a.toArray():f.removedNodeKeys=a.toArray()),a.clear(),h.clear(),f}cloneDeep(t){return this.lg(t,!0)}lg(t,i,e,s,n){if(!Util.wt(t))return t;n||(n=[]);const o=Object.isExtensible(t);if(e||(e=new GMap),o){const h=e.get(t);if(h)return h}else{s||(s=new GMap);const h=s.iterator;for(;h.next();){const a=h.key;if(h.value===t){const f=e.get(a);if(f)return f}}}function r(h,a){if(o)h.__gohashid===void 0&&n.push(h),e.set(h,a);else{const c=GSet.nu++;e.set(c,a),s.set(c,t)}}let l;if(Array.isArray(t)){l=[],r(t,l);for(let h=0;h{delete h.__gohashid}),l}Fe(t){return JSON.stringify(t).replace(/[\u007F-\uFFFF]/g,e=>{const s="0000"+e.charCodeAt(0).toString(16);return"\\u"+s.substring(s.length-4)})}hg(){let t="";return this.name!==""&&(t+=`, + `+n.toString(t-1)}}return i}get layout(){return this.ie}set layout(t){t!==null&&(this.ie=t)}get vertexes(){return this.mo}get edges(){return this.Cn}createVertex(){return new LayoutVertex(this)}createEdge(){return new LayoutEdge(this)}addParts(t,i,e){if(t===null)return;i===void 0&&(i=!1),Util.i(i,"boolean",LayoutNetwork,"addParts:toplevelonly"),e===void 0&&(e=null),e===null&&(e=n=>{if(n instanceof Node)return!n.isLinkLabel;if(n instanceof Link){const o=n.fromNode;if(o===null||o.isLinkLabel)return!1;const r=n.toNode;return!(r===null||r.isLinkLabel)}return!1});const s=t.iterator;for(;s.next();){const n=s.value;if(n instanceof Node&&!(i&&!n.isTopLevel)&&n.canLayout()&&e(n))if(n instanceof Group&&n.layout===null)this.addParts(n.memberParts,!1);else{if(this.findVertex(n)!==null)continue;const o=this.createVertex();o.node=n,this.addVertex(o)}}for(s.reset();s.next();){const n=s.value;if(!(n instanceof Link)||i&&!n.isTopLevel||!n.canLayout()||!e(n)||this.findEdge(n)!==null)continue;const o=n.fromNode,r=n.toNode;if(o===null||r===null||o===r)continue;const l=this.findGroupVertex(o),h=this.findGroupVertex(r);this.linkVertexes(l,h,n)}}findGroupVertex(t){if(t===null)return null;const i=t.findVisibleNode();if(i===null)return null;let e=this.findVertex(i);if(e!==null)return e;let s=i.containingGroup;for(;s!==null;){if(e=this.findVertex(s),e!==null)return e;s=s.containingGroup}return null}addVertex(t){if(t===null)return;this.mo.add(t);const i=t.node;i!==null&&this.ky.set(i,t),t.network=this}addNode(t){if(t===null)return null;let i=this.findVertex(t);return i===null&&(i=this.createVertex(),i.node=t,this.addVertex(i)),i}deleteVertex(t){if(t!==null&&this.cT(t)){let i=t._o;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}i=t.tr;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}}}cT(t){if(t===null)return!1;const i=this.mo.delete(t);if(i){const e=t.node;e!==null&&this.ky.delete(e)}return i}deleteNode(t){if(t===null)return;const i=this.findVertex(t);i!==null&&this.deleteVertex(i)}findVertex(t){return t===null?null:this.ky.get(t)}addEdge(t){if(t===null)return;this.cN(t);const i=t.toVertex;i!==null&&i.addSourceEdge(t);const e=t.fromVertex;e!==null&&e.addDestinationEdge(t)}cN(t){if(t===null)return;this.Cn.add(t);const i=t.link;i!==null&&this.findEdge(i)===null&&this.Py.set(i,t),t.network=this}addLink(t){if(t===null)return null;const i=t.fromNode,e=t.toNode;let s=this.findEdge(t);return s===null?(s=this.createEdge(),s.link=t,i!==null&&(s.fromVertex=this.addNode(i)),e!==null&&(s.toVertex=this.addNode(e)),this.addEdge(s)):(i!==null?s.fromVertex=this.addNode(i):s.fromVertex=null,e!==null?s.toVertex=this.addNode(e):s.toVertex=null),s}deleteEdge(t){if(t===null)return;const i=t.toVertex;i!==null&&i.deleteSourceEdge(t);const e=t.fromVertex;e!==null&&e.deleteDestinationEdge(t),this.fN(t)}fN(t){if(t===null)return!1;const i=this.Cn.delete(t);if(i){const e=t.link;e!==null&&this.Py.delete(e)}return i}deleteLink(t){if(t===null)return;const i=this.findEdge(t);i!==null&&this.deleteEdge(i)}findEdge(t){return t===null?null:this.Py.get(t)}linkVertexes(t,i,e){if(t===null||i===null)return null;if(t.network===this&&i.network===this){const s=this.createEdge();return s.link=e,s.fromVertex=t,s.toVertex=i,this.addEdge(s),s}return null}reverseEdge(t){if(t===null)return;const i=t.fromVertex,e=t.toVertex;i===null||e===null||(i.deleteDestinationEdge(t),e.deleteSourceEdge(t),t.reverseEdge(),i.addSourceEdge(t),e.addDestinationEdge(t))}deleteSelfEdges(){const t=Util.nt(),i=this.Cn.iterator;for(;i.next();){const s=i.value;s.fromVertex===s.toVertex&&t.push(s)}const e=t.length;for(let s=0;s0||t.tr.count>0)}splitIntoSubNetworks(t){t===void 0&&(t=!0),t&&(this.deleteArtificialVertexes(),this.deleteUselessEdges(),this.deleteSelfEdges());const i=new List;let e=!0;for(;e;){e=!1;const s=this.mo.iterator;for(;s.next();){const n=s.value;if(this.isSingleton(n))continue;const o=this.layout.createNetwork();i.add(o),this.xO(o,n),e=!0;break}}return i.sort((s,n)=>s===null||n===null||s===n?0:n.vertexes.count-s.vertexes.count),i}xO(t,i){if(i===null)return;const e=new List;for(e.add(i);e.count>0;){const s=e.first();if(e.removeAt(0),s.network===t)continue;this.cT(s),t.addVertex(s);let n=s.sourceEdges;for(;n.next();){const o=n.value;o.network!==t&&(this.fN(o),t.cN(o),e.add(o.fromVertex))}for(n=s.destinationEdges;n.next();){const o=n.value;o.network!==t&&(this.fN(o),t.cN(o),e.add(o.toVertex))}}}findAllParts(){const t=new GSet,i=this.mo.iterator;for(;i.next();){const s=i.value;t.add(s.node)}const e=this.Cn.iterator;for(;e.next();){const s=e.value;t.add(s.link)}return t}}class LayoutVertex{go;Qt;de;Ae;qe;_o;tr;constructor(t){GSet.Yi(this),this.go=t,this.Ae=new Rect(0,0,10,10).g(),this.qe=new Point(5,5).g(),this.Qt=null,this.de=null,this._o=new List,this.tr=new List}clear(){this.Qt=null,this.de=null,this._o=new List,this.tr=new List}toString(t){t===void 0&&(t=0);let i="LayoutVertex#"+GSet.as(this);if(t>0&&(i+=this.node!==null?"("+this.node.toString()+")":"",t>1)){let e="",s=!0,n=this._o.iterator;for(;n.next();){const r=n.value;s?s=!1:e+=",",e+=r.toString(0)}let o="";for(s=!0,n=this.tr.iterator;n.next();){const r=n.value;s?s=!1:o+=",",o+=r.toString(0)}i+=" sources: "+e+" destinations: "+o}return i}get po(){return this._o.WN}get ir(){return this.tr.WN}get data(){return this.Qt}set data(t){if(this.Qt=t,t!==null&&t.bounds){const i=t.bounds,e=i.x,s=i.y,n=i.width,o=i.height;this.qe.e(n/2,o/2),this.Ae.e(e,s,n,o)}}get node(){return this.de}set node(t){if(this.de!==t){this.de=t,t.ensureBounds();const i=this.network.layout,e=Rect.l(),s=i.getLayoutBounds(t,e);let n=s.x,o=s.y;const r=s.width,l=s.height;if(isNaN(n)&&(n=0),isNaN(o)&&(o=0),this.Ae.e(n,o,r,l),Rect.s(e),!(t instanceof Group)){const h=t.locationObject.getDocumentPoint(Spot.Center);if(h.isReal()){this.qe.e(h.x-n,h.y-o);return}}this.qe.e(r/2,l/2)}}get bounds(){return this.Ae}set bounds(t){this.Ae.equals(t)||this.Ae.a(t)}get focus(){return this.qe}set focus(t){this.qe.equals(t)||this.qe.a(t)}get centerX(){return this.Ae.x+this.qe.x}set centerX(t){const i=this.Ae;i.x+this.qe.x!==t&&(i.ot(),i.x=t-this.qe.x,i.g())}get centerY(){return this.Ae.y+this.qe.y}set centerY(t){const i=this.Ae;i.y+this.qe.y!==t&&(i.ot(),i.y=t-this.qe.y,i.g())}get focusX(){return this.qe.x}set focusX(t){const i=this.qe;i.x!==t&&(i.ot(),i.x=t,i.g())}get focusY(){return this.qe.y}set focusY(t){const i=this.qe;i.y!==t&&(i.ot(),i.y=t,i.g())}get x(){return this.Ae.x}set x(t){const i=this.Ae;i.x!==t&&(i.ot(),i.x=t,i.g())}get y(){return this.Ae.y}set y(t){const i=this.Ae;i.y!==t&&(i.ot(),i.y=t,i.g())}get width(){return this.Ae.width}set width(t){const i=this.Ae;i.width!==t&&(i.ot(),i.width=t,i.g())}get height(){return this.Ae.height}set height(t){const i=this.Ae;i.height!==t&&(i.ot(),i.height=t,i.g())}commit(){const t=this.Qt;if(t!==null){const e=this.bounds,s=t.bounds;Util.wt(s)?(s.x=e.x,s.y=e.y,s.width=e.width,s.height=e.height):t.bounds=e.copy();return}const i=this.node;if(i!==null){const e=this.bounds;if(!(i instanceof Group)){const s=Rect.l();i.ensureBounds();const n=this.network.layout.getLayoutBounds(i,s),o=i.locationObject.getDocumentPoint(Spot.Center);if(n.isReal()&&o.isReal()){i.moveTo(e.x+this.focusX-(o.x-n.x)+i.margin.left,e.y+this.focusY-(o.y-n.y+i.margin.top)),Rect.s(s);return}Rect.s(s)}i.moveTo(e.x+i.margin.left,e.y+i.margin.top)}}addSourceEdge(t){t!==null&&(this._o.has(t)||this._o.add(t))}deleteSourceEdge(t){t!==null&&this._o.delete(t)}addDestinationEdge(t){t!==null&&(this.tr.has(t)||this.tr.add(t))}deleteDestinationEdge(t){t!==null&&this.tr.delete(t)}get network(){return this.go}set network(t){this.go=t}get sourceVertexes(){const t=new GSet,i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}return t.iterator}get destinationVertexes(){const t=new GSet,i=this.destinationEdges;for(;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get vertexes(){const t=new GSet;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get sourceEdges(){return this._o.iterator}get destinationEdges(){return this.tr.iterator}get edges(){const t=new List;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e)}return t.iterator}get edgesCount(){return this._o.count+this.tr.count}static standardComparer(t,i){const e=t.de,s=i.de;if(e)if(s){const n=e.text,o=s.text;return no?1:0}else return 1;else return s!==null?-1:0}static smartComparer(t,i){if(t!==null)if(i!==null){const e=t.de,s=i.de;if(e!==null)if(s!==null){const n=e.text.toLocaleLowerCase(),o=s.text.toLocaleLowerCase(),r=n.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),l=o.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let h=0;for(;h0&&(i+=this.He!==null?"("+this.He.toString()+")":"",t>1&&(i+=" "+(this.We?this.We.toString():"null")+" --> "+(this.Je?this.Je.toString():"null"))),i}reverseEdge(){const t=this.We;this.We=this.Je,this.Je=t}commit(){}getOtherVertex(t){return this.Je===t?this.We:this.We===t?this.Je:null}get network(){return this.go}set network(t){this.go=t}get data(){return this.Qt}set data(t){this.Qt!==t&&(this.Qt=t)}get link(){return this.He}set link(t){this.He!==t&&(this.He=t)}get fromVertex(){return this.We}set fromVertex(t){this.We!==t&&(this.We=t)}get toVertex(){return this.Je}set toVertex(t){this.Je!==t&&(this.Je=t)}}var GridAlignment=(w=>(w[w.Position=0]="Position",w[w.Location=1]="Location",w))(GridAlignment||{}),GridArrangement=(w=>(w[w.LeftToRight=10]="LeftToRight",w[w.RightToLeft=11]="RightToLeft",w))(GridArrangement||{}),GridSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w))(GridSorting||{});class GridLayout extends Layout{Wd;Jd;Lo;Ln;oi;zi;pe;ye;constructor(t){super(),this.isViewportSized=!0,this.Wd=NaN,this.Jd=NaN,this.Lo=new Size(NaN,NaN).g(),this.Ln=new Size(10,10).g(),this.oi=1,this.zi=10,this.pe=22,this.ye=GridLayout.standardComparer,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Wd=this.Wd,t.Jd=this.Jd,t.Lo.a(this.Lo),t.Ln.a(this.Ln),t.oi=this.oi,t.zi=this.zi,t.pe=this.pe,t.ye=this.ye}ri(t){t in GridSorting?this.sorting=t:t in GridArrangement?this.arrangement=t:t in GridAlignment?this.alignment=t:super.ri(t)}doLayout(t){this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.collectParts(t),e=this.diagram,n=i.copy().iterator;for(;n.next();){const m=n.value;if(m.Cl()&&(m.fromNode!==null||m.toNode!==null)){i.delete(m);continue}if(m.ensureBounds(),m instanceof Group){const g=m.memberParts;for(;g.next();){const p=g.value;i.delete(p)}}}const o=i.toArray();if(o.length===0)return;switch(this.sorting){case 20:break;case 21:o.reverse();break;case 22:o.sort(this.comparer);break;case 23:o.sort(this.comparer),o.reverse();break}let r=this.wrappingColumn;isNaN(r)&&(r=0);let l=this.wrappingWidth;if(isNaN(l)&&e!==null){const m=e.viewportBounds,g=e.padding;l=Math.max(m.width-g.left-g.right,0)}else l=Math.max(this.wrappingWidth,0);r<=0&&l<=0&&(r=1);let h=this.spacing.width;isFinite(h)||(h=0);let a=this.spacing.height;isFinite(a)||(a=0),e!==null&&e.startTransaction("Layout");const c=[];switch(this.alignment){case 0:this.bO(o,l,r,h,a,c);break;case 1:this.kO(o,l,r,h,a,c);break}let f=0,u=0,d=0;for(let m=0;m0&&m>e-1||i>0&&m>0&&L-c>i)&&(o.push(new Rect(0,d,i+s,g)),m=0,u=c,d+=g,g=0),g=Math.max(g,S);let C=0;switch(a){case 11:C=-x.width;break;default:C=0;break}switch(y.moveTo(u+C+y.margin.left,d+y.margin.top),a){case 11:u-=P;break;default:u+=P;break}m++}o.push(new Rect(0,d,i+s,g)),Rect.s(r)}kO(t,i,e,s,n,o){const r=Rect.l();let l=Math.max(this.cellSize.width,1),h=0,a=0,c=0;const f=Point.l();for(let C=0;C=h&&(i-=h);let x=0,k=0;const b=Math.max(this.cellSize.height,1);c=0;let P=0,S=!0;const L=Point.l();for(let C=0;C0)switch(u){case 11:{let D=(g-d-(N.width-T.x))/l;Geo.K(Math.round(D),D)?D=Math.round(D):D=Math.floor(D),g=D*l+d;break}default:{let D=(g-d+T.x)/l;Geo.K(Math.round(D),D)?D=Math.round(D):D=Math.ceil(D),g=D*l+d;break}}else switch(u){case 11:x=g+T.x+N.width;break;default:x=g-T.x;break}let A=0;switch(u){case 11:A=-(g+T.x)+x;break;default:A=g+N.width-T.x-x;break}if(e>0&&y>e-1||i>0&&y>0&&A>i){o.push(new Rect(0,S?p-c:p,i+s,P+c+n));for(let D=0;Dk&&(M.width+=M.x-k,M.x=k)}Rect.s(r)}commitLayers(t,i){}get wrappingWidth(){return this.Wd}set wrappingWidth(t){this.Wd!==t&&(Util.i(t,"number",GridLayout,"wrappingWidth"),(t>0||isNaN(t))&&(this.Wd=t,this.isViewportSized=isNaN(t),this.invalidateLayout()))}get wrappingColumn(){return this.Jd}set wrappingColumn(t){this.Jd!==t&&(Util.i(t,"number",GridLayout,"wrappingColumn"),(t>0||isNaN(t))&&(this.Jd=t,this.invalidateLayout()))}get cellSize(){return this.Lo}set cellSize(t){this.Lo.equals(t)||(this.Lo.a(t),this.invalidateLayout())}get spacing(){return this.Ln}set spacing(t){this.Ln.equals(t)||(this.Ln.a(t),this.invalidateLayout())}get alignment(){return this.oi}set alignment(t){this.oi!==t&&(t===1||t===0)&&(this.oi=t,this.invalidateLayout())}get arrangement(){return this.zi}set arrangement(t){this.zi!==t&&(t===10||t===11)&&(this.zi=t,this.invalidateLayout())}get sorting(){return this.pe}set sorting(t){this.pe!==t&&(t===20||t===21||t===22||t===23)&&(this.pe=t,this.invalidateLayout())}get comparer(){return this.ye}set comparer(t){this.ye!==t&&(Util.i(t,"function",GridLayout,"comparer"),this.ye=t,this.invalidateLayout())}static standardComparer(t,i){const e=t.text,s=i.text;return es?1:0}static smartComparer(t,i){if(t!==null)if(i!==null){const e=t.text.toLocaleLowerCase(),s=i.text.toLocaleLowerCase(),n=e.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),o=s.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let r=0;for(;r{e.containsNodeData(s)&&this.gT(s,!1)}),t.forEach(s=>{e.containsNodeData(s)&&this.M1(s)}),i!==!1&&this.diagram.bb(!1)}gT(t,i){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.yo.has(t))return null;i===void 0&&(i=!0);const e=this.PO(t);return e!==null&&i&&this.M1(t),e}PO(t){if(t==null||this.p.undoManager.isUndoingRedoing||this.yo.has(t))return null;const i=this.SO(t),e=this.findTemplateForNodeData(t,i);if(e!==null){e.li();const s=e.copy();if(s!==null){const n=this.diagram.fe;return this.diagram.fe=!0,s.Ho=i,s.Qt=t,this.Sy&&(s.ll="Tool"),this.diagram.add(s),s.Qt=null,s.data=t,this.diagram.fe=n,s}}return null}insertLink(t,i,e,s){return null}M1(t){}SO(t){return this.p.model.getCategoryForNodeData(t)}static mT=!1;static pT=!1;findTemplateForNodeData(t,i){const e=this.p,s=e.model,n=s.qc()&&s.isGroupForData(t);let o=null;return n?(o=e.groupTemplateMap.get(i),o===null&&(o=e.groupTemplateMap.get(""),o===null&&(PartManager.pT||(PartManager.pT=!0,Util.ii('No Group template found for category "'+i+'"'),Util.ii(" Using default group template")),o=e.rM))):(o=e.nodeTemplateMap.get(i),o===null&&(o=e.nodeTemplateMap.get(""),o===null&&(PartManager.mT||(PartManager.mT=!0,Util.ii('No Node template found for category "'+i+'"'),Util.ii(" Using default node template")),o=e.sM))),o}getLinkCategoryForData(t){return""}setLinkCategoryForData(t,i){}setFromNodeForLink(t,i,e){}setToNodeForLink(t,i,e){}static yT=!1;findLinkTemplateForCategory(t){const i=this.p;let e=i.linkTemplateMap.get(t);return e===null&&(e=i.linkTemplateMap.get(""),e===null&&(PartManager.yT||(PartManager.yT=!0,Util.ii('No Link template found for category "'+t+'"'),Util.ii(" Using default link template")),e=i.nM)),e}fv(t,i,e){t instanceof Link?(i!==null&&this.uT(i,t),e!==null&&this.fT(e,t)):t instanceof Part&&(i!==null&&this.yo.delete(i),e!==null&&this.yo.set(e,t))}dT(){const t=this.diagram.model;this.dN(t.nodeDataArray)}dN(t){t.forEach(i=>{this.N1(i)})}N1(t){const i=this.findPartForData(t);i!==null&&(this.diagram.NM(i,!1),this.gN(i))}gN(t){}nN(t){}findPartForKey(t){if(t==null)return null;const i=this.p.model.findNodeDataForKey(t);return i!==null?this.yo.get(i):null}findNodeForKey(t){if(t==null)return null;const i=this.p.model.findNodeDataForKey(t);if(i===null)return null;const e=this.yo.get(i);return e instanceof Node?e:null}findLinkForKey(t){return null}findPartForData(t){if(t===null)return null;let i=this.yo.get(t);return i!==null||(i=this.dl.get(t)),i}findNodeForData(t){if(t===null)return null;const i=this.yo.get(t);return i instanceof Node?i:null}findLinkForData(t,i){return t===null?null:this.dl.get(t)}findNodesByExample(...t){const i=new GSet,e=this.$d.iterator;for(;e.next();){const s=e.value,n=s.data;if(n!==null)for(let o=0;o{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),this.parts.each(o=>{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),s.forEach(o=>t.xT(o,!1));for(let o=0;o0){for(let o=0;oi.SL(s));const e=t.mh;if(Array.isArray(e)){const s=this.Ua.get(e);if(s===null){const n=[];n.push(t),this.Ua.set(e,n)}else{for(let n=0;ni.gR(s));const e=t.mh;if(Array.isArray(e)){const s=this.Ua.get(e);if(s!==null){for(let n=0;n0&&i.removeParts(l,!1),h.count>0){const c=h.iterator;for(;c.next();){const f=c.key,u=c.value;s.set(f,u)}}}if(i!==null&&this.p!==null){const o=i.model,r=o.afterCopyFunction;if(r!==null){const l=new GMap;s.each(a=>{a.key.data!==null&&l.set(a.key.data,a.value.data)});const h=this.p.model;r(l,o,h)}}const n=s.iterator;for(;n.next();)n.value.updateTargetBindings();return s}C1(t,i,e,s){if(t===null||s&&!t.canCopy())return null;if(e.has(t))return e.get(t);const n=this.pN(t,i);if(!(n instanceof Part))return null;if(n.isSelected=!1,n.isHighlighted=!1,e.set(t,n),t instanceof Node){const o=t.linksConnected;for(;o.next();){const r=o.value;if(r.fromNode===t){const l=e.get(r);l!==null&&(l.fromNode=n)}if(r.toNode===t){const l=e.get(r);l!==null&&(l.toNode=n)}}if(t instanceof Group&&n instanceof Group){const r=t.memberParts;for(;r.next();){const l=r.value,h=this.C1(l,i,e,s);h instanceof Link||h!==null&&(h.containingGroup=n)}}}else if(t instanceof Link&&n instanceof Link){const o=t.fromNode;if(o!==null){const h=e.get(o);h!==null&&(n.fromNode=h)}const r=t.toNode;if(r!==null){const h=e.get(r);h!==null&&(n.toNode=h)}const l=t.labelNodes;for(;l.next();){const h=l.value,a=this.C1(h,i,e,s);a!==null&&a instanceof Node&&(a.labeledLink=n)}}return n}pN(t,i){let e=null;const s=t.data;if(s!==null&&i!==null){const n=i.model;if(!(t instanceof Link)){const o=n.copyNodeData(s);Util.wt(o)&&(n.addNodeData(o),e=i.findPartForData(o))}}else if(t.li(),e=t.copy(),e!==null){const n=this.p;if(i!==null)i.add(e);else if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const o=n.model;let r=null;e instanceof Link||(r=o.copyNodeData(s)),Util.wt(r)&&(e.data=r)}}return e}get nodes(){return this.$d}get links(){return this.qs}get parts(){return this.At}get diagram(){return this.p}get addsToTemporaryLayer(){return this.Sy}set addsToTemporaryLayer(t){this.Sy=t}get preservesRebuildLocations(){return this.uN}set preservesRebuildLocations(t){this.uN=t}}class GraphLinksPartManager extends PartManager{LM(){const t=this.diagram.model;this.My(t.nodeDataArray),this.PT(t.linkDataArray)}My(t){super.My(t,!1);const i=this.links.iterator;for(;i.next();)i.value.Ld();this.diagram.bb(!1)}PT(t){t.forEach(i=>{this.ST(i)}),this.diagram.bb(!1)}ST(t){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.dl.has(t))return null;const i=this.getLinkCategoryForData(t),e=this.findLinkTemplateForCategory(i);if(e!==null){e.li();const s=e.copy();if(s!==null){const n=this.diagram.fe;this.diagram.fe=!0,s.Ho=i,s.Qt=t;const o=this.diagram.model,r=o.L1(t,!0);r!==""&&(s.fromPortId=r);const l=o.Te(t,!0);if(l!==void 0){const f=this.findNodeForKey(l);f instanceof Node&&(s.fromNode=f)}const h=o.L1(t,!1);h!==""&&(s.toPortId=h);const a=o.Te(t,!1);if(a!==void 0){const f=this.findNodeForKey(a);f instanceof Node&&(s.toNode=f)}const c=o.getLabelKeysForLinkData(t);return Array.isArray(c)&&c.forEach(f=>{const u=this.findNodeForKey(f);u!==null&&(u.labeledLink=s)}),this.Sy&&(s.ll="Tool"),this.diagram.add(s),s.Qt=null,s.data=t,this.diagram.fe=n,s}}return null}dT(){const t=this.diagram.model;this.MT(t.linkDataArray),this.dN(t.nodeDataArray)}MT(t){t.forEach(i=>{this.N1(i)})}getLinkCategoryForData(t){return this.diagram.model.getCategoryForLinkData(t)}setLinkCategoryForData(t,i){return this.diagram.model.setCategoryForLinkData(t,i)}setFromNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setFromKeyForLinkData(t.data,e.getKeyForNodeData(s))}setToNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setToKeyForLinkData(t.data,e.getKeyForNodeData(s))}nN(t){this.diagram.model.removeLinkData(t.data)}findPartForKey(t){const i=super.findPartForKey(t);if(i===null){const s=this.diagram.model.findLinkDataForKey(t);if(s!==null)return this.dl.get(s)}return i}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findLinkDataForKey(t);return e!==null?this.dl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.Y){i.Y=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="linkFromKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.fromNode=l}}else if(s==="linkToKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.toNode=l}}else if(s==="linkFromPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.fromPortId=r)}}else if(s==="linkToPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.toPortId=r)}}else if(s==="nodeGroupKey"){const n=t.object,o=this.findPartForData(n);if(o!==null){const r=t.newValue;if(r!==void 0){const l=this.findNodeForKey(r);l instanceof Group?o.containingGroup=l:o.containingGroup=null}else o.containingGroup=null}}else if(s==="linkLabelKeys"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.oldValue,l=t.newValue;Array.isArray(r)&&r.forEach(h=>{if(l.indexOf(h)>=0)return;const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=null)}),Array.isArray(l)&&l.forEach(h=>{const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=o)})}}else if(s==="linkCategory"){const n=t.object,o=this.findLinkForData(n),r=t.newValue;o!==null&&typeof r=="string"&&(o.category=r)}else if(s==="linkDataArray"){const n=t.oldValue;this.MT(n);const o=t.newValue;this.PT(o)}i.isModified=!0}else if(e===3){const n=t.newValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.ST(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=t.object,r=this.findLinkForData(o),l=this.findNodeForKey(n);r!==null&&l!==null&&(l.labeledLink=r)}i.isModified=!0}else if(e===4){const n=t.oldValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.N1(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=this.findNodeForKey(n);o!==null&&(o.labeledLink=null)}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&(n==="linkFromKeyProperty"||n==="linkToKeyProperty"||n==="linkFromPortIdProperty"||n==="linkToPortIdProperty"||n==="linkLabelKeysProperty"||n==="nodeIsGroupProperty"||n==="nodeGroupKeyProperty"||n==="linkCategoryProperty")&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.Y=!0}}}kT(){const t=this.diagram.model,i=new GSet,e=t.linkDataArray;e.forEach(n=>{i.add(n)});const s=[];this.links.each(n=>{n.data!==null&&!i.has(n.data)&&s.push(n.data)}),s.forEach(n=>{t.NT(n,!1)}),e.forEach(n=>{this.findLinkForData(n)===null&&t.CT(n,!1)})}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Link){let n=s.Te(i,!0),o=e.findNodeForKey(n);t.fromNode=o,n=s.Te(i,!1),o=e.findNodeForKey(n),t.toNode=o;const r=s.getLabelKeysForLinkData(i);if(r.length>0||t.labelNodes.count>0){if(r.length===1&&t.labelNodes.count===1){const f=r[0],u=t.labelNodes.first();if(s.getKeyForNodeData(u.data)===f)return}const l=new GSet().addAll(r),h=new GSet;t.labelNodes.each(f=>{if(f.data!==null){const u=s.getKeyForNodeData(f.data);u!==void 0&&h.add(u)}});const a=h.copy();a.removeAll(l);const c=l.copy();if(c.removeAll(h),a.count>0||c.count>0){const f=t;a.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink===f&&(d.labeledLink=null)}),c.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink!==f&&(d.labeledLink=f)})}}}else if(!(t instanceof Adornment)){const n=s.getGroupKeyForNodeData(i),o=e.findPartForKey(n);(o===null||o instanceof Group)&&(t.containingGroup=o)}}M1(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Cy(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)){if(n instanceof Group&&i.getGroupKeyForNodeData(l)===e){const h=this.findPartForData(l);h!==null&&(h.containingGroup=n)}}else{const h=this.findLinkForData(l);if(h!==null&&n instanceof Node){i.Te(l,!0)===e&&(h.fromNode=n),i.Te(l,!1)===e&&(h.toNode=n);const a=i.getLabelKeysForLinkData(l);Array.isArray(a)&&a.some(c=>c===e?(n.labeledLink=h,!0):!1)}}}i.Js(e)}const o=i.getGroupKeyForNodeData(t);if(o!==void 0){const r=this.findNodeForKey(o);r instanceof Group&&(n.containingGroup=r)}}}gN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data);if(e!==void 0){const s=t.linksConnected;for(;s.next();){const n=s.value;i.$s(e,n.data)}if(t.isLinkLabel){const n=t.labeledLink;n!==null&&i.$s(e,n.data)}if(t instanceof Group){const n=t.memberParts;for(;n.next();){const r=n.value.data;i.containsNodeData(r)&&i.$s(e,r)}}}}}pN(t,i){let e=super.pN(t,i);if(t instanceof Link){const s=t.data;if(s!==null&&i!==null){const n=i.model,o=n.copyLinkData(s);typeof o=="object"&&o!==null&&(n.addLinkData(o),e=i.findLinkForData(o))}else if(e!==null){const n=this.diagram;if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const r=n.model.copyLinkData(s);typeof r=="object"&&r!==null&&(e.data=r)}}}return e}insertLink(t,i,e,s){const n=this.diagram,o=n.model,r=n.toolManager.findTool("Linking");let l="";t!==null&&(i===null&&(i=t),l=i.portId,l===null&&(l=""));let h="";e!==null&&(s===null&&(s=e),h=s.portId,h===null&&(h=""));const a=r.archetypeLinkData;if(a instanceof Link){a.li();const c=a.copy();if(c!==null){c.fromNode=t,c.fromPortId=l,c.toNode=e,c.toPortId=h,n.add(c);const f=r.archetypeLabelNodeData;if(f instanceof Node){f.li();const u=f.copy();u!==null&&(u.labeledLink=c,n.add(u))}return c}}else if(a!==null){const c=o.copyLinkData(a);if(typeof c=="object"&&c!==null){t!==null&&o.Zd(c,o.getKeyForNodeData(t.data),!0),o.Qd(c,l,!0),e!==null&&o.Zd(c,o.getKeyForNodeData(e.data),!1),o.Qd(c,h,!1),o.addLinkData(c);const f=r.archetypeLabelNodeData;if(f!==null&&!(f instanceof Node)){const d=o.copyNodeData(f);if(typeof d=="object"&&d!==null){o.addNodeData(d);const m=o.getKeyForNodeData(d);m!==void 0&&o.addLabelKeyForLinkData(c,m)}}return n.findLinkForData(c)}}return null}}class TreePartManager extends PartManager{Ph=null;A1(t,i){if(t===null||i===null||i.findTreeParentLink()!==null)return null;const e=this.diagram.toolManager.findTool("Linking");let s=t,n=i;if(this.diagram.isTreePathToChildren){if(e!==null&&e.xu(s,n,null,!0))return null}else if(s=i,n=t,e!==null&&e.xu(s,n,null,!0))return null;const o=this.getLinkCategoryForData(i.data),r=this.findLinkTemplateForCategory(o);if(r!==null){r.li();const l=r.copy();if(l!==null){const h=this.diagram.fe;return this.diagram.fe=!0,l.Ho=o,l.Qt=i.data,l.fromNode=s,l.toNode=n,this.diagram.add(l),l.Qt=null,l.data=i.data,this.diagram.fe=h,l}}return null}getLinkCategoryForData(t){return this.diagram.model.getParentLinkCategoryForNodeData(t)}setLinkCategoryForData(t,i){this.diagram.model.setParentLinkCategoryForNodeData(t,i)}setFromNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren)s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n));else{const o=this.Ph;this.Ph=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.toNode!==null?t.toNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Ph=o}}setToNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren){const o=this.Ph;this.Ph=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.fromNode!==null?t.fromNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Ph=o}else s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n))}nN(t){this.diagram.model.setParentKeyForNodeData(t.data,void 0)}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findNodeDataForKey(t);return e!==null?this.dl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.Y){i.Y=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="nodeParentKey"){const n=t.object,o=t.newValue,r=this.findNodeForKey(o),l=this.findNodeForData(n);if(this.Ph!==null)r!==null&&(this.Ph.data=n,this.Ph.category=this.getLinkCategoryForData(n));else if(l!==null){const h=l.findTreeParentLink();h!==null?r===null?i.remove(h):i.isTreePathToChildren?h.fromNode=r:h.toNode=r:this.A1(r,l)}}else if(s==="parentLinkCategory"){const n=t.object,o=this.findNodeForData(n),r=t.newValue;if(o!==null&&typeof r=="string"){const l=o.findTreeParentLink();l!==null&&(l.category=r)}}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&n==="nodeParentKeyProperty"&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.Y=!0}}}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Node){const n=s.getParentKeyForNodeData(i),o=e.findNodeForKey(n),r=t.findTreeParentNode();if(o!==r){const l=t.findTreeParentLink();o!==null?l!==null?e.isTreePathToChildren?l.fromNode=o:l.toNode=o:this.A1(o,t):l!==null&&e.NM(l,!1)}}}Ny(t,i){if(super.Ny(t,i),typeof i=="string"&&this.findPartForData(t)!==null){const s=this.findLinkForData(t);s!==null&&s.updateTargetBindings(i)}}M1(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Cy(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)&&n instanceof Node&&i.getParentKeyForNodeData(l)===e){const h=this.findNodeForData(l);this.A1(n,h)}}i.Js(e)}const o=i.getParentKeyForNodeData(t);if(o!==void 0&&n instanceof Node){const r=this.findNodeForKey(o);this.A1(r,n)}}}gN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data),s=this.findLinkForData(t.data);if(s!==null){s.isSelected=!1,s.isHighlighted=!1;const r=s.layer;if(r!==null){const l=r.te(-1,s,!1);l>=0&&this.diagram.raiseChangedEvent(4,"parts",r,s,null,l,null);const h=s.layerChanged;h!==null&&h(s,r,null)}}const n=this.diagram.isTreePathToChildren,o=t.linksConnected;for(;o.next();){const r=o.value,h=(n?r.toNode:r.fromNode).data;i.containsNodeData(h)&&i.$s(e,h)}}}insertLink(t,i,e,s){const n=this.diagram.model;let o=t,r=e;if(this.diagram.isTreePathToChildren||(o=e,r=t),o!==null&&r!==null){const l=o.data,h=r.data;return n.setParentKeyForNodeData(h,n.getKeyForNodeData(l)),r.findTreeParentLink()}return null}}var BindingMode=(w=>(w[w.OneWay=1]="OneWay",w[w.TwoWay=2]="TwoWay",w))(BindingMode||{});class Binding{n;yN;Va;Cf;Sh;Lf;Af;Tf;T1;ke;gd;ff;constructor(t,i,e,s){GSet.Yi(this),t===void 0?t="":Util.i(t,"string",Binding,"constructor:targetprop"),i===void 0?i=t:Util.i(i,"string",Binding,"constructor:sourceprop"),e===void 0?e=null:e!==null&&Util.i(e,"function",Binding,"constructor:conv"),this.yN=-1,this.ke=null,this.Va=t,this.gd=0,this.ff=0,this.Cf=null,this.Sh=i,this.Lf=e,s===void 0?(this.Af=1,this.Tf=null):(this.Af=2,this.Tf=s),this.T1=new GSet,this.n=2}copy(){const t=new this.constructor;return this.cloneProtected(t),t}cloneProtected(t){t.Va=this.Va,t.gd=this.gd,t.ff=this.ff,t.Cf=this.Cf,t.Sh=this.Sh,t.Lf=this.Lf,t.Af=this.Af,t.Tf=this.Tf,t.n=this.n&-2}static OneWay=1;static TwoWay=2;static parseEnum(t,i){return Util.i(t,"function",Binding,"parseEnum:ctor"),e=>{let s=parseInt(e);return isNaN(s)&&(s=Util.Ih(t,e),s===null)?i:s}}ri(t){t in BindingMode?this.mode=t:Util.lr(this,t)}static toString(t){return Util.toString(t)}toString(){return"Binding("+this.targetProperty+":"+this.sourceProperty+(this.targetId!==-1?" "+this.targetId:"")+" "+BindingMode[this.mode]+")"}g(){return this.n=this.n|1,this}ot(){return this.n=this.n&-2,this}get targetId(){return this.yN}set targetId(t){this.h&&Util.T(this),Util.i(t,"number",Binding,"targetId"),this.yN=t}get targetProperty(){return this.Va}set targetProperty(t){this.h&&Util.T(this),Util.i(t,"string",Binding,"targetProperty"),this.Va=t}get sourceProperty(){return this.Sh}set sourceProperty(t){this.h&&Util.T(this),Util.i(t,"string",Binding,"sourceProperty"),this.Sh=t}get h(){return(this.n&1)!==0}get isToData(){return(this.n&2)!==0}get isToObject(){return(this.n&4)!==0}get isToModel(){return(this.n&8)!==0}get isToTheme(){return(this.n&16)!==0}get wN(){return this.isToTheme&&!(this.isToData||this.isToObject||this.isToModel)}Zu(){return!1}get sourceName(){return this.Cf}set sourceName(t){this.h&&Util.T(this),t!==null&&Util.i(t,"string",Binding,"sourceName"),this.Cf=t,t!==null?this.n=this.n&-3|4:this.n=this.n|2}get converter(){return this.Lf}set converter(t){this.h&&Util.T(this),t!==null&&Util.i(t,"function",Binding,"converter"),this.Lf=t}get backConverter(){return this.Tf}set backConverter(t){this.h&&Util.T(this),t!==null&&Util.i(t,"function",Binding,"backConverter"),this.Tf=t}get mode(){return this.Af}set mode(t){this.h&&Util.T(this),this.isToTheme&&t===2&&Util.o("Theme Bindings cannot be TwoWay."),this.Af=t}makeTwoWay(t){return this.isToTheme&&Util.o("Theme Bindings cannot be TwoWay."),this.mode=2,t&&(Util.i(t,"function",Binding,"makeTwoWay"),this.backConverter=t),this}ofObject(t){return this.h&&Util.T(this),t===void 0&&(t=""),this.sourceName=t,this}ofModel(){return this.h&&Util.T(this),this.n=this.n&-3&-5|8,this.Cf=null,this}ZL(t,i){const e=this.sourceName;let s=null;return e===null||e===""?s=t:e==="/"?s=i.part:e==="."?s=i:e===".."?s=i.panel:s=t.findObject(e),s}check(t){const i=this.Va,e=this.Sh,s=this.Lf;(this.Zu()&&s===null&&this.Mh===null&&i===""||s===null&&i==="")&&Util.ii("Binding error: target property is the empty string: "+this.toString()),this.Zu()&&this.wN&&e===""&&s===null&&this.Mh===null&&Util.ii("Binding error: theme bindings require a source property when not using a converter: "+this.toString()),t&&typeof i=="string"&&(typeof t.setAttribute!="function"&&i.length>0&&i[0]!=="_"&&!Util.fw(t,i)?Util.ii("Binding error: undefined target property: "+i+" on "+t.toString()):i==="name"&&t instanceof GraphObject&&Util.ii("Binding error: cannot modify GraphObject.name on "+t.toString()))}updateTarget(t,i,e){const s=this.Sh;if(e!==void 0&&s!==""&&s!==e)return;const n=this.Va,o=this.Lf;let r=i;if(s!==""&&!this.wN&&(r=Model.vt(i,s)),r===void 0)return;const l=t.diagram?.themeManager??t.panel?.diagram?.themeManager;if(o===null){if(n!==""){if(this.Zu()&&(r=this.LT(l,r,t,n),r===void 0))return;Model.rt(t,n,r)}}else try{if(n!==""){let h=o(r,t);if(this.Zu()&&(h=this.LT(l,h,t,n),h===void 0))return;Model.rt(t,n,h)}else o(r,t)}catch{}}updateSource(t,i,e,s){if(this.Af!==2)return;const n=this.Va;if(e!==void 0&&n!==e)return;const o=this.Sh,r=this.Tf;let l=t;if(n!==""&&(l=Model.vt(t,n)),l!==void 0&&!this.T1.has(t))try{this.T1.add(t);const h=s!==null?s.diagram:null,a=h!==null?h.model:null;if(r===null){if(o!=="")a!==null?a.setDataProperty(i,o,l):Model.rt(i,o,l);else if(a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const c=s.itemIndex,f=s.panel.itemArray;a.removeArrayItem(f,c),a.insertArrayItem(f,c,l)}}else try{if(o!==""){const c=r(l,i,a);a!==null?a.setDataProperty(i,o,c):Model.rt(i,o,c)}else{const c=r(l,i,a);if(c!==void 0&&a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const f=s.itemIndex,u=s.panel.itemArray;a.removeArrayItem(u,f),a.insertArrayItem(u,f,c)}}}catch{}}finally{this.T1.delete(t)}}}class ThemeBinding extends Binding{Ly;Mh;za;constructor(t,i,e,s,n){super(t,i,s),e==null&&(e=""),n===void 0&&(n=null),this.Ly=e,this.Mh=n,this.za=null,this.n=16}cloneProtected(t){super.cloneProtected(t),t.Ly=this.Ly,t.Mh=this.Mh,t.za=this.za}Zu(){return!0}get themeSource(){return this.Ly}set themeSource(t){this.h&&Util.T(this),t!==null&&Util.i(t,"string",ThemeBinding,"themeSource"),this.Ly=t,this.za=null,t!==null?this.n=this.n|16:this.n=this.n&-17}get themeConverter(){return this.Mh}set themeConverter(t){this.h&&Util.T(this),t!==null&&Util.i(t,"function",ThemeBinding,"themeConverter"),this.Mh=t}ofData(){return this.h&&Util.T(this),this.n=this.n|2,this.Cf=null,this}LT(t,i,e,s){if(!t||(this.wN&&(i=this.Sh),!i&&i!==0))return;let n=this.themeSource;this.za!==null?n=this.za:typeof n=="string"&&n.includes(".")&&(this.za=n.split("."),n=this.za);let o=t.findValue(i,n,s);return o===void 0&&Util.ii(`Theme warning: ${i} could not be found when setting target property ${s}.`),typeof this.Mh=="function"&&(o=this.Mh(o,e)),o}}class Model{Mt;_d;vo;D1;De;Df;Ff;tg;ig;eg;sg;Xa;er;F1;Ro;R1;ti;Nh;ng=new GSet;og=new GSet;Ay;constructor(t,i){if(GSet.Yi(this),this.Mt="",this._d="",this.vo=!1,this.D1={},this.De=[],this.ti=new GMap,this.Nh="key",this.Df=null,this.Ff=null,this.tg=!1,this.ig=!1,this.eg=!1,this.sg=null,this.Xa="category",this.er=new GMap,this.Ay=100,this.F1=new List,this.Ro=!1,this.R1=null,this.undoManager=new UndoManager,t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){t.Mt=this.Mt,t._d=this._d,t.vo=this.vo,t.Nh=this.Nh,t.Df=this.Df,t.Ff=this.Ff,t.tg=this.tg,t.ig=this.ig,t.eg=this.eg,t.Ay=this.Ay,t.sg=this.sg,t.Xa=this.Xa}copy(){const t=new this.constructor;return this.cloneProtected(t),t}clear(){this.De=[],this.ti.clear(),this.er.clear(),this.undoManager.clear()}toString(t){if(t===void 0&&(t=0),t>1)return this.toJson();{let i=(this.name!==""?this.name:"")+" Model";if(t>0){i+=` + node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n{if(u.model===e){if(u.modelChange==="nodeDataArray")u.change===3?n.add(u.newValue):u.change===4&&r.add(u.oldValue);else if(e.containsNodeData(u.object))o.add(u.object);else if(u.change===2&&(e.modelData===u.object||u.propertyName==="modelData"))s=!0;else if(u.object!==null)if(l&&l.has(u.object))l.get(u.object).each(m=>{e.containsNodeData(m)&&o.add(m)});else{if(u.object instanceof Model||e.Ta()&&e.containsLinkData(u.object))return;e.TT(u.object).each(m=>{o.add(m)})}}});const h=this.og;h.clear(),n.each(u=>{h.add(e.getKeyForNodeData(u)),i||o.add(u)});const a=this.ng;a.clear(),r.each(u=>{a.add(e.getKeyForNodeData(u)),i&&o.add(u)});const c=e.cloneDeep(o.toArray());let f=null;return s&&(f===null&&(f={}),f.modelData=this.cloneDeep(this.modelData)),h.count>0&&(f===null&&(f={}),i?f.removedNodeKeys=h.toArray():f.insertedNodeKeys=h.toArray()),c.length>0&&(f===null&&(f={}),f.modifiedNodeData=c),a.count>0&&(f===null&&(f={}),i?f.insertedNodeKeys=a.toArray():f.removedNodeKeys=a.toArray()),a.clear(),h.clear(),f}cloneDeep(t){return this.rg(t,!0)}rg(t,i,e,s,n){if(!Util.wt(t))return t;n||(n=[]);const o=Object.isExtensible(t);if(e||(e=new GMap),o){const h=e.get(t);if(h)return h}else{s||(s=new GMap);const h=s.iterator;for(;h.next();){const a=h.key;if(h.value===t){const f=e.get(a);if(f)return f}}}function r(h,a){if(o)h.__gohashid===void 0&&n.push(h),e.set(h,a);else{const c=GSet.su++;e.set(c,a),s.set(c,t)}}let l;if(Array.isArray(t)){l=[],r(t,l);for(let h=0;h{delete h.__gohashid}),l}Fe(t){return JSON.stringify(t).replace(/[\u007F-\uFFFF]/g,e=>{const s="0000"+e.charCodeAt(0).toString(16);return"\\u"+s.substring(s.length-4)})}lg(){let t="";return this.name!==""&&(t+=`, "name": `+this.Fe(this.name)),this.dataFormat!==""&&(t+=`, "dataFormat": `+this.Fe(this.dataFormat)),this.isReadOnly&&(t+=`, "isReadOnly": `+this.isReadOnly),this.nodeKeyProperty!=="key"&&typeof this.nodeKeyProperty=="string"&&(t+=`, @@ -29,16 +29,16 @@ string: ${t}`);break}}const T=b.qg;if(GeoStream.wC(b),i){const A=T.figures.itera "copiesKey": true`),this.pointsDigits!==100&&(t+=`, "pointsDigits": `+this.pointsDigits.toString()),this.nodeCategoryProperty!=="category"&&typeof this.nodeCategoryProperty=="string"&&(t+=`, "nodeCategoryProperty": `+this.Fe(this.nodeCategoryProperty)),t}Ty(t){t.name&&(this.name=t.name),t.dataFormat&&(this.dataFormat=t.dataFormat),t.isReadOnly&&(this.isReadOnly=!0),t.nodeKeyProperty&&(this.nodeKeyProperty=t.nodeKeyProperty),t.copiesArrays&&(this.copiesArrays=!0),t.copiesArrayObjects&&(this.copiesArrayObjects=!0),t.copiesKey!==void 0&&(this.copiesKey=t.copiesKey),t.pointsDigits!==void 0&&(this.pointsDigits=parseInt(t.pointsDigits)),t.nodeCategoryProperty&&(this.nodeCategoryProperty=t.nodeCategoryProperty)}DT(){const t=this.modelData;return`, - "modelData": `+this.FT(t)}RT(t){const i=t.modelData;Util.wt(i)&&(this.replaceJsonObjects(i),this.modelData=i)}PN(){const t=this.modelData;let i=!1;for(const s in t)if(!this.v1(t,s,t[s])){i=!0;break}let e="";return i&&(e=this.DT()),e+`, - "nodeDataArray": `+this.Nh(this.nodeDataArray,!0)}MN(t){this.RT(t);const i=t.nodeDataArray;Array.isArray(i)&&(this.replaceJsonObjects(i),this.nodeDataArray=i)}SN(t,i,e){if(t===i)return!0;if(typeof t!=typeof i||typeof t=="function"||typeof i=="function")return!1;if(Array.isArray(t)&&Array.isArray(i)){if(e.get(t)===i)return!0;if(e.set(t,i),t.length!==i.length)return!1;for(let s=0;s{const o=n.part;if(!o)return;const r=o.data;if(s===r)return;let l=i.get(s);l===null?(l=new GSet,l.add(r),i.set(s,l)):l.add(r)};i===null&&(i=new GMap,t.changes.each(s=>{if(s.diagram!==null){const n=s.change;if(n===2){const o=s.object.panel;if(o){const r=o.data;r&&e(r,o)}}else if(n===3||n===4){const o=s.object,r=o.itemArray;r&&e(r,o)}}}),this.Xa=i)}TT(t){const i=new GSet;for(let e=0;e{if(f.model===e){if(f.modelChange==="nodeDataArray")f.change===3?n.add(f.newValue):f.change===4&&r.add(f.oldValue);else if(e.containsNodeData(f.object))o.add(f.object);else if(f.change===2&&(e.modelData===f.object||f.propertyName==="modelData"))s=!0;else if(f.object!==null)if(l&&l.has(f.object))l.get(f.object).each(d=>{e.containsNodeData(d)&&o.add(d)});else{if(f.object instanceof Model||e.Aa()&&e.containsLinkData(f.object))return;e.TT(f.object).each(d=>{o.add(d)})}}});const h=this.rg;h.clear(),n.each(f=>{h.add(e.getKeyForNodeData(f)),i||o.add(f)});const a=this.og;a.clear(),r.each(f=>{a.add(e.getKeyForNodeData(f)),i&&o.add(f)});let c="";return s&&(c+=this.DT()),h.count>0&&(c+=(i?this.OT:this.vT)+this.Nh(h.toArray(),!0)),o.count>0&&(c+=this.LO+this.Nh(o.toArray(),!0)),a.count>0&&(c+=(i?this.vT:this.OT)+this.Nh(a.toArray(),!0)),a.clear(),h.clear(),c}Dy(t){(t.name!==void 0&&t.name!==this.name||t.dataFormat!==void 0&&t.dataFormat!==this.dataFormat||t.isReadOnly!==void 0&&t.isReadOnly!==this.isReadOnly||t.nodeKeyProperty!==void 0&&t.nodeKeyProperty!==this.nodeKeyProperty||t.copiesArrays!==void 0&&t.copiesArrays!==this.copiesArrays||t.copiesArrayObjects!==void 0&&t.copiesArrayObjects!==this.copiesArrayObjects||t.copiesKey!==void 0&&t.copiesKey!==this.copiesKey||t.nodeCategoryProperty!==void 0&&t.nodeCategoryProperty!==this.nodeCategoryProperty)&&Util.o("applyIncrementalJson cannot change Model properties"),this.RT(t);const i=t.insertedNodeKeys,e=t.modifiedNodeData,s=new GMap;if(Array.isArray(e))for(let o=0;o1&&s.add(` + "removedNodeKeys": `;Ka=null;AT(t){let i=this.Ka;const e=(s,n)=>{const o=n.part;if(!o)return;const r=o.data;if(s===r)return;let l=i.get(s);l===null?(l=new GSet,l.add(r),i.set(s,l)):l.add(r)};i===null&&(i=new GMap,t.changes.each(s=>{if(s.diagram!==null){const n=s.change;if(n===2){const o=s.object.panel;if(o){const r=o.data;r&&e(r,o)}}else if(n===3||n===4){const o=s.object,r=o.itemArray;r&&e(r,o)}}}),this.Ka=i)}TT(t){const i=new GSet;for(let e=0;e{if(f.model===e){if(f.modelChange==="nodeDataArray")f.change===3?n.add(f.newValue):f.change===4&&r.add(f.oldValue);else if(e.containsNodeData(f.object))o.add(f.object);else if(f.change===2&&(e.modelData===f.object||f.propertyName==="modelData"))s=!0;else if(f.object!==null)if(l&&l.has(f.object))l.get(f.object).each(d=>{e.containsNodeData(d)&&o.add(d)});else{if(f.object instanceof Model||e.Ta()&&e.containsLinkData(f.object))return;e.TT(f.object).each(d=>{o.add(d)})}}});const h=this.og;h.clear(),n.each(f=>{h.add(e.getKeyForNodeData(f)),i||o.add(f)});const a=this.ng;a.clear(),r.each(f=>{a.add(e.getKeyForNodeData(f)),i&&o.add(f)});let c="";return s&&(c+=this.DT()),h.count>0&&(c+=(i?this.OT:this.vT)+this.Ch(h.toArray(),!0)),o.count>0&&(c+=this.CO+this.Ch(o.toArray(),!0)),a.count>0&&(c+=(i?this.vT:this.OT)+this.Ch(a.toArray(),!0)),a.clear(),h.clear(),c}Dy(t){(t.name!==void 0&&t.name!==this.name||t.dataFormat!==void 0&&t.dataFormat!==this.dataFormat||t.isReadOnly!==void 0&&t.isReadOnly!==this.isReadOnly||t.nodeKeyProperty!==void 0&&t.nodeKeyProperty!==this.nodeKeyProperty||t.copiesArrays!==void 0&&t.copiesArrays!==this.copiesArrays||t.copiesArrayObjects!==void 0&&t.copiesArrayObjects!==this.copiesArrayObjects||t.copiesKey!==void 0&&t.copiesKey!==this.copiesKey||t.nodeCategoryProperty!==void 0&&t.nodeCategoryProperty!==this.nodeCategoryProperty)&&Util.o("applyIncrementalJson cannot change Model properties"),this.RT(t);const i=t.insertedNodeKeys,e=t.modifiedNodeData,s=new GMap;if(Array.isArray(e))for(let o=0;o1&&s.add(` `);for(let n=0;n0&&(s.add(","),i&&s.add(` `)),s.add(this.writeJsonValue(o)))}return i&&e>1&&s.add(` -`),s.add("]"),s.toString()}v1(t,i,e){return e===void 0||i==="__gohashid"||i[0]==="_"||typeof e=="function"}Xi(t){return isNaN(t)?"NaN":t===1/0?"9e9999":t===-1/0?"-9e9999":t}FT(t){const i=t;if(i instanceof Point)t={class:"go.Point",x:this.Xi(i.x),y:this.Xi(i.y)};else if(i instanceof Size)t={class:"go.Size",width:this.Xi(i.width),height:this.Xi(i.height)};else if(i instanceof Rect)t={class:"go.Rect",x:this.Xi(i.x),y:this.Xi(i.y),width:this.Xi(i.width),height:this.Xi(i.height)};else if(i instanceof Margin)t={class:"go.Margin",top:this.Xi(i.top),right:this.Xi(i.right),bottom:this.Xi(i.bottom),left:this.Xi(i.left)};else if(i instanceof Spot)i.isSpot()?t={class:"go.Spot",x:this.Xi(i.x),y:this.Xi(i.y),offsetX:this.Xi(i.offsetX),offsetY:this.Xi(i.offsetY)}:t={class:"go.Spot",enum:i.toString()};else if(i instanceof Brush){if(t={class:"go.Brush",type:BrushType[i.type]},i.type===1?t.color=i.color:(i.type===2||i.type===3)&&(t.start=i.start,t.end=i.end,i.type===3&&(i.startRadius!==0&&(t.startRadius=this.Xi(i.startRadius)),isNaN(i.endRadius)||(t.endRadius=this.Xi(i.endRadius)))),i.colorStops!==null){const n={},o=i.colorStops.iterator;for(;o.next();){const r=o.key,l=o.value;n[r]=l}t.colorStops=n}}else if(i instanceof Geometry)t={class:"go.Geometry",type:GeometryType[i.type]},i.startX!==0&&(t.startX=this.Xi(i.startX)),i.startY!==0&&(t.startY=this.Xi(i.startY)),i.endX!==0&&(t.endX=this.Xi(i.endX)),i.endY!==0&&(t.endY=this.Xi(i.endY)),i.spot1.equals(Spot.TopLeft)||(t.spot1=i.spot1),i.spot2.equals(Spot.BottomRight)||(t.spot2=i.spot2),i.type===4&&(t.path=Geometry.stringify(i));else if(Model.I1(Util.sn(i))!==null)return Util.oi("ERROR: trying to convert a GraphObject or Diagram or Model or Tool or Layout or UndoManager or other unknown data type into JSON text: "+i.toString()),"{}";let e="{",s=!0;for(const n in t){const o=Model.vt(t,n);if(!this.v1(t,n,o))if(s?s=!1:e+=",",e+=this.Fe(n)+":",n==="points"&&o instanceof List){const r=o;let l="[";const h=r.iterator;for(;h.next();){const a=h.value;l.length>1&&(l+=","),l+=this.IT(a.x),l+=",",l+=this.IT(a.y)}l+="]",e+=l}else e+=this.writeJsonValue(o)}return e+="}",e}IT(t){if(t===1/0)return"9e9999";if(t===-1/0)return"-9e9999";if(isNaN(t))return"0";const i=this.pointsDigits;return i>16?t.toString():t.toFixed(i)}get pointsDigits(){return this.Ay}set pointsDigits(t){t<0?t=0:t>100&&(t=100),this.Ay=t}Ki(t){return typeof t=="number"?t:t==="NaN"?NaN:t==="9e9999"?1/0:t==="-9e9999"?-1/0:parseFloat(t)}TO(t){if(typeof t!="object")return t;let i=t.class||"";if(typeof i!="string"||i==="")return t;if(i==="NaN")return NaN;if(i==="Date")return new Date(t.value);if(i.indexOf("go.")!==0)return t;i=i.substring(3);let e=t;if(i==="Point")e=new Point(this.Ki(t.x),this.Ki(t.y));else if(i==="Size")e=new Size(this.Ki(t.width),this.Ki(t.height));else if(i==="Rect")e=new Rect(this.Ki(t.x),this.Ki(t.y),this.Ki(t.width),this.Ki(t.height));else if(i==="Margin")e=new Margin(this.Ki(t.top),this.Ki(t.right),this.Ki(t.bottom),this.Ki(t.left));else if(i==="Spot")typeof t.enum=="string"?e=Spot.parse(t.enum):e=new Spot(this.Ki(t.x),this.Ki(t.y),this.Ki(t.offsetX),this.Ki(t.offsetY));else if(i==="Brush"){const s=new Brush;s.type=Util.Oh(BrushType,t.type)??1,typeof t.color=="string"&&(s.color=t.color),t.start instanceof Spot&&(s.start=t.start),t.end instanceof Spot&&(s.end=t.end),typeof t.startRadius=="number"&&(s.startRadius=this.Ki(t.startRadius)),typeof t.endRadius=="number"&&(s.endRadius=this.Ki(t.endRadius));const n=t.colorStops;if(Util.wt(n))for(const o in n){const r=parseFloat(o);s.addColorStop(r,n[o])}e=s}else if(i==="Geometry"){let s=null;typeof t.path=="string"?s=Geometry.parse(t.path):s=new Geometry,s.type=Util.Oh(GeometryType,t.type)??1,typeof t.startX=="number"&&(s.startX=this.Ki(t.startX)),typeof t.startY=="number"&&(s.startY=this.Ki(t.startY)),typeof t.endX=="number"&&(s.endX=this.Ki(t.endX)),typeof t.endY=="number"&&(s.endY=this.Ki(t.endY)),t.spot1 instanceof Spot&&(s.spot1=t.spot1),t.spot2 instanceof Spot&&(s.spot2=t.spot2),e=s}else if(i==="EnumValue"){let s=t.classType;s.indexOf("go.")===0&&(s=s.substring(3));const n=Model.I1(s);typeof n=="function"&&(e=Util.Oh(n,t.name))}return e}get name(){return this.St}set name(t){const i=this.St;i!==t&&(Util.i(t,"string",Model,"name"),this.St=t,this.t("name",i,t))}get dataFormat(){return this.tg}set dataFormat(t){const i=this.tg;i!==t&&(Util.i(t,"string",Model,"dataFormat"),this.tg=t,this.t("dataFormat",i,t))}get isReadOnly(){return this.vo}set isReadOnly(t){const i=this.vo;i!==t&&(Util.i(t,"boolean",Model,"isReadOnly"),this.vo=t,this.t("isReadOnly",i,t))}get modelData(){return this.D1}set modelData(t){const i=this.D1;i!==t&&(Util.i(t,"object",Model,"modelData"),this.D1=t,this.t("modelData",i,t),this.updateTargetBindings(t))}addChangedListener(t){return Util.i(t,"function",Model,"addChangedListener:listener"),this.F1.add(t),this}removeChangedListener(t){Util.i(t,"function",Model,"removeChangedListener:listener"),this.F1.delete(t)}Ew(t){this.skipsUndoManager||this.undoManager.handleChanged(t);const i=this.F1,e=i.length;for(let s=0;s0&&Util.o("Cannot set Model.nodeKeyProperty when there is existing node data"),this.Sh=t,this.t("nodeKeyProperty",i,t))}An(t,i,e){typeof t!="string"&&typeof t!="function"&&Util.we(t,"string or function",i,e)}getKeyForNodeData(t){if(t===null)return;const i=this.Sh;if(i==="")return;const e=Model.vt(t,i);if(e!==void 0){if(this.isKeyType(e))return e;Util.o("Key value for node data "+t+" is not a number or a string: "+e)}}setKeyForNodeData(t,i){if((i==null||!this.isKeyType(i))&&Util.we(i,"number or string",Model,"setKeyForNodeData:key"),t===null)return;const e=this.Sh;if(e==="")return;if(!this.containsNodeData(t)){Model.lt(t,e,i);return}const s=Model.vt(t,e);if(s!==i){if(this.findNodeDataForKey(i)!==null)return;Model.lt(t,e,i),s!==void 0&&this.ti.delete(s),this.ti.set(i,t),this.Et("nodeKey",2,e,t,s,i),typeof e=="string"&&this.updateTargetBindings(t,e),this.Fy(s,i)}}get makeUniqueKeyFunction(){return this.Tf}set makeUniqueKeyFunction(t){const i=this.Tf;i!==t&&(t!==null&&Util.i(t,"function",Model,"makeUniqueKeyFunction"),this.Tf=t,this.t("makeUniqueKeyFunction",i,t))}isKeyType(t){return typeof t=="number"||typeof t=="string"}containsNodeData(t){if(t===null)return!1;const i=this.getKeyForNodeData(t);return i===void 0?!1:this.ti.get(i)===t}findNodeDataForKey(t){return t===null&&Util.o("Model.findNodeDataForKey:key must not be null"),t===void 0||!this.isKeyType(t)?null:this.ti.get(t)}get nodeDataArray(){return this.De}set nodeDataArray(t){const i=this.De;if(i!==t){this.ti.clear(),this.CN();const e=t.length;for(let o=0;o=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" GraphLinksModel";if(t>0){i+=` +`),s.add("]"),s.toString()}v1(t,i,e){return e===void 0||i==="__gohashid"||i[0]==="_"||typeof e=="function"}Xi(t){return isNaN(t)?"NaN":t===1/0?"9e9999":t===-1/0?"-9e9999":t}FT(t){const i=t;if(i instanceof Point)t={class:"go.Point",x:this.Xi(i.x),y:this.Xi(i.y)};else if(i instanceof Size)t={class:"go.Size",width:this.Xi(i.width),height:this.Xi(i.height)};else if(i instanceof Rect)t={class:"go.Rect",x:this.Xi(i.x),y:this.Xi(i.y),width:this.Xi(i.width),height:this.Xi(i.height)};else if(i instanceof Margin)t={class:"go.Margin",top:this.Xi(i.top),right:this.Xi(i.right),bottom:this.Xi(i.bottom),left:this.Xi(i.left)};else if(i instanceof Spot)i.isSpot()?t={class:"go.Spot",x:this.Xi(i.x),y:this.Xi(i.y),offsetX:this.Xi(i.offsetX),offsetY:this.Xi(i.offsetY)}:t={class:"go.Spot",enum:i.toString()};else if(i instanceof Brush){if(t={class:"go.Brush",type:BrushType[i.type]},i.type===1?t.color=i.color:(i.type===2||i.type===3)&&(t.start=i.start,t.end=i.end,i.type===3&&(i.startRadius!==0&&(t.startRadius=this.Xi(i.startRadius)),isNaN(i.endRadius)||(t.endRadius=this.Xi(i.endRadius)))),i.colorStops!==null){const n={},o=i.colorStops.iterator;for(;o.next();){const r=o.key,l=o.value;n[r]=l}t.colorStops=n}}else if(i instanceof Geometry)t={class:"go.Geometry",type:GeometryType[i.type]},i.startX!==0&&(t.startX=this.Xi(i.startX)),i.startY!==0&&(t.startY=this.Xi(i.startY)),i.endX!==0&&(t.endX=this.Xi(i.endX)),i.endY!==0&&(t.endY=this.Xi(i.endY)),i.spot1.equals(Spot.TopLeft)||(t.spot1=i.spot1),i.spot2.equals(Spot.BottomRight)||(t.spot2=i.spot2),i.type===4&&(t.path=Geometry.stringify(i));else if(Model.I1(Util.sn(i))!==null)return Util.ii("ERROR: trying to convert a GraphObject or Diagram or Model or Tool or Layout or UndoManager or other unknown data type into JSON text: "+i.toString()),"{}";let e="{",s=!0;for(const n in t){const o=Model.vt(t,n);if(!this.v1(t,n,o))if(s?s=!1:e+=",",e+=this.Fe(n)+":",n==="points"&&o instanceof List){const r=o;let l="[";const h=r.iterator;for(;h.next();){const a=h.value;l.length>1&&(l+=","),l+=this.IT(a.x),l+=",",l+=this.IT(a.y)}l+="]",e+=l}else e+=this.writeJsonValue(o)}return e+="}",e}IT(t){if(t===1/0)return"9e9999";if(t===-1/0)return"-9e9999";if(isNaN(t))return"0";const i=this.pointsDigits;return i>16?t.toString():t.toFixed(i)}get pointsDigits(){return this.Ay}set pointsDigits(t){t<0?t=0:t>100&&(t=100),this.Ay=t}Ki(t){return typeof t=="number"?t:t==="NaN"?NaN:t==="9e9999"?1/0:t==="-9e9999"?-1/0:parseFloat(t)}AO(t){if(typeof t!="object")return t;let i=t.class||"";if(typeof i!="string"||i==="")return t;if(i==="NaN")return NaN;if(i==="Date")return new Date(t.value);if(i.indexOf("go.")!==0)return t;i=i.substring(3);let e=t;if(i==="Point")e=new Point(this.Ki(t.x),this.Ki(t.y));else if(i==="Size")e=new Size(this.Ki(t.width),this.Ki(t.height));else if(i==="Rect")e=new Rect(this.Ki(t.x),this.Ki(t.y),this.Ki(t.width),this.Ki(t.height));else if(i==="Margin")e=new Margin(this.Ki(t.top),this.Ki(t.right),this.Ki(t.bottom),this.Ki(t.left));else if(i==="Spot")typeof t.enum=="string"?e=Spot.parse(t.enum):e=new Spot(this.Ki(t.x),this.Ki(t.y),this.Ki(t.offsetX),this.Ki(t.offsetY));else if(i==="Brush"){const s=new Brush;s.type=Util.Ih(BrushType,t.type)??1,typeof t.color=="string"&&(s.color=t.color),t.start instanceof Spot&&(s.start=t.start),t.end instanceof Spot&&(s.end=t.end),typeof t.startRadius=="number"&&(s.startRadius=this.Ki(t.startRadius)),typeof t.endRadius=="number"&&(s.endRadius=this.Ki(t.endRadius));const n=t.colorStops;if(Util.wt(n))for(const o in n){const r=parseFloat(o);s.addColorStop(r,n[o])}e=s}else if(i==="Geometry"){let s=null;typeof t.path=="string"?s=Geometry.parse(t.path):s=new Geometry,s.type=Util.Ih(GeometryType,t.type)??1,typeof t.startX=="number"&&(s.startX=this.Ki(t.startX)),typeof t.startY=="number"&&(s.startY=this.Ki(t.startY)),typeof t.endX=="number"&&(s.endX=this.Ki(t.endX)),typeof t.endY=="number"&&(s.endY=this.Ki(t.endY)),t.spot1 instanceof Spot&&(s.spot1=t.spot1),t.spot2 instanceof Spot&&(s.spot2=t.spot2),e=s}else if(i==="EnumValue"){let s=t.classType;s.indexOf("go.")===0&&(s=s.substring(3));const n=Model.I1(s);typeof n=="function"&&(e=Util.Ih(n,t.name))}return e}get name(){return this.Mt}set name(t){const i=this.Mt;i!==t&&(Util.i(t,"string",Model,"name"),this.Mt=t,this.t("name",i,t))}get dataFormat(){return this._d}set dataFormat(t){const i=this._d;i!==t&&(Util.i(t,"string",Model,"dataFormat"),this._d=t,this.t("dataFormat",i,t))}get isReadOnly(){return this.vo}set isReadOnly(t){const i=this.vo;i!==t&&(Util.i(t,"boolean",Model,"isReadOnly"),this.vo=t,this.t("isReadOnly",i,t))}get modelData(){return this.D1}set modelData(t){const i=this.D1;i!==t&&(Util.i(t,"object",Model,"modelData"),this.D1=t,this.t("modelData",i,t),this.updateTargetBindings(t))}addChangedListener(t){return Util.i(t,"function",Model,"addChangedListener:listener"),this.F1.add(t),this}removeChangedListener(t){Util.i(t,"function",Model,"removeChangedListener:listener"),this.F1.delete(t)}Ew(t){this.skipsUndoManager||this.undoManager.handleChanged(t);const i=this.F1,e=i.length;for(let s=0;s0&&Util.o("Cannot set Model.nodeKeyProperty when there is existing node data"),this.Nh=t,this.t("nodeKeyProperty",i,t))}An(t,i,e){typeof t!="string"&&typeof t!="function"&&Util.we(t,"string or function",i,e)}getKeyForNodeData(t){if(t===null)return;const i=this.Nh;if(i==="")return;const e=Model.vt(t,i);if(e!==void 0){if(this.isKeyType(e))return e;Util.o("Key value for node data "+t+" is not a number or a string: "+e)}}setKeyForNodeData(t,i){if((i==null||!this.isKeyType(i))&&Util.we(i,"number or string",Model,"setKeyForNodeData:key"),t===null)return;const e=this.Nh;if(e==="")return;if(!this.containsNodeData(t)){Model.rt(t,e,i);return}const s=Model.vt(t,e);if(s!==i){if(this.findNodeDataForKey(i)!==null)return;Model.rt(t,e,i),s!==void 0&&this.ti.delete(s),this.ti.set(i,t),this.Et("nodeKey",2,e,t,s,i),typeof e=="string"&&this.updateTargetBindings(t,e),this.Fy(s,i)}}get makeUniqueKeyFunction(){return this.Df}set makeUniqueKeyFunction(t){const i=this.Df;i!==t&&(t!==null&&Util.i(t,"function",Model,"makeUniqueKeyFunction"),this.Df=t,this.t("makeUniqueKeyFunction",i,t))}isKeyType(t){return typeof t=="number"||typeof t=="string"}containsNodeData(t){if(t===null)return!1;const i=this.getKeyForNodeData(t);return i===void 0?!1:this.ti.get(i)===t}findNodeDataForKey(t){return t===null&&Util.o("Model.findNodeDataForKey:key must not be null"),t===void 0||!this.isKeyType(t)?null:this.ti.get(t)}get nodeDataArray(){return this.De}set nodeDataArray(t){const i=this.De;if(i!==t){this.ti.clear(),this.MN();const e=t.length;for(let o=0;o=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" GraphLinksModel";if(t>0){i+=` node data:`;let e=this.nodeDataArray,s=e.length,n=0;for(n=0;n"+this.Te(o,!1)}}return i}}kN(t,i){if(this.linkKeyProperty===""){const f=this.skipsUndoManager;this.skipsUndoManager=!0,this.linkKeyProperty="key",this.skipsUndoManager=f}let e=super.kN(t,i);const s=this,n=new GSet,o=new GSet,r=new GSet,l=this.Xa;t.changes.each(f=>{if(f.model===s){if(f.modelChange==="linkDataArray")f.change===3?n.add(f.newValue):f.change===4&&r.add(f.oldValue);else if(s.containsLinkData(f.object))o.add(f.object);else if(f.object!==null)if(f.object!==null&&l&&l.has(f.object))l.get(f.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(f.object instanceof Model||s.containsNodeData(f.object))return;s.UT(f.object).each(d=>o.add(d))}}});const h=this.rg;h.clear(),n.each(f=>{h.add(s.getKeyForLinkData(f)),i||o.add(f)});const a=this.og;a.clear(),r.each(f=>{a.add(s.getKeyForLinkData(f)),i&&o.add(f)});const c=s.cloneDeep(o.toArray());return h.count>0&&(e===null&&(e={}),i?e.removedLinkKeys=h.toArray():e.insertedLinkKeys=h.toArray()),c.length>0&&(e===null&&(e={}),e.modifiedLinkData=c),a.count>0&&(e===null&&(e={}),i?e.insertedLinkKeys=a.toArray():e.removedLinkKeys=a.toArray()),a.clear(),h.clear(),e}hg(){const t=super.hg();let i="";return this.linkCategoryProperty!=="category"&&typeof this.linkCategoryProperty=="string"&&(i+=`, + link data:`,e=this.linkDataArray,s=e.length,n=0;n"+this.Te(o,!1)}}return i}}xN(t,i){if(this.linkKeyProperty===""){const f=this.skipsUndoManager;this.skipsUndoManager=!0,this.linkKeyProperty="key",this.skipsUndoManager=f}let e=super.xN(t,i);const s=this,n=new GSet,o=new GSet,r=new GSet,l=this.Ka;t.changes.each(f=>{if(f.model===s){if(f.modelChange==="linkDataArray")f.change===3?n.add(f.newValue):f.change===4&&r.add(f.oldValue);else if(s.containsLinkData(f.object))o.add(f.object);else if(f.object!==null)if(f.object!==null&&l&&l.has(f.object))l.get(f.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(f.object instanceof Model||s.containsNodeData(f.object))return;s.BT(f.object).each(d=>o.add(d))}}});const h=this.og;h.clear(),n.each(f=>{h.add(s.getKeyForLinkData(f)),i||o.add(f)});const a=this.ng;a.clear(),r.each(f=>{a.add(s.getKeyForLinkData(f)),i&&o.add(f)});const c=s.cloneDeep(o.toArray());return h.count>0&&(e===null&&(e={}),i?e.removedLinkKeys=h.toArray():e.insertedLinkKeys=h.toArray()),c.length>0&&(e===null&&(e={}),e.modifiedLinkData=c),a.count>0&&(e===null&&(e={}),i?e.insertedLinkKeys=a.toArray():e.removedLinkKeys=a.toArray()),a.clear(),h.clear(),e}lg(){const t=super.lg();let i="";return this.linkCategoryProperty!=="category"&&typeof this.linkCategoryProperty=="string"&&(i+=`, "linkCategoryProperty": `+this.Fe(this.linkCategoryProperty)),this.linkKeyProperty!==""&&typeof this.linkKeyProperty=="string"&&(i+=`, "linkKeyProperty": `+this.Fe(this.linkKeyProperty)),this.linkFromKeyProperty!=="from"&&typeof this.linkFromKeyProperty=="string"&&(i+=`, "linkFromKeyProperty": `+this.Fe(this.linkFromKeyProperty)),this.linkToKeyProperty!=="to"&&typeof this.linkToKeyProperty=="string"&&(i+=`, @@ -47,13 +47,13 @@ string: ${t}`);break}}const T=b.qg;if(GeoStream.wC(b),i){const A=T.figures.itera "linkToPortIdProperty": `+this.Fe(this.linkToPortIdProperty)),this.linkLabelKeysProperty!==""&&typeof this.linkLabelKeysProperty=="string"&&(i+=`, "linkLabelKeysProperty": `+this.Fe(this.linkLabelKeysProperty)),this.nodeIsGroupProperty!=="isGroup"&&typeof this.nodeIsGroupProperty=="string"&&(i+=`, "nodeIsGroupProperty": `+this.Fe(this.nodeIsGroupProperty)),this.nodeGroupKeyProperty!=="group"&&typeof this.nodeGroupKeyProperty=="string"&&(i+=`, - "nodeGroupKeyProperty": `+this.Fe(this.nodeGroupKeyProperty)),t+i}Ty(t){super.Ty(t),t.linkKeyProperty&&(this.linkKeyProperty=t.linkKeyProperty),t.linkFromKeyProperty&&(this.linkFromKeyProperty=t.linkFromKeyProperty),t.linkToKeyProperty&&(this.linkToKeyProperty=t.linkToKeyProperty),t.linkFromPortIdProperty&&(this.linkFromPortIdProperty=t.linkFromPortIdProperty),t.linkToPortIdProperty&&(this.linkToPortIdProperty=t.linkToPortIdProperty),t.linkCategoryProperty&&(this.linkCategoryProperty=t.linkCategoryProperty),t.linkLabelKeysProperty&&(this.linkLabelKeysProperty=t.linkLabelKeysProperty),t.nodeIsGroupProperty&&(this.nodeIsGroupProperty=t.nodeIsGroupProperty),t.nodeGroupKeyProperty&&(this.nodeGroupKeyProperty=t.nodeGroupKeyProperty)}PN(){const t=super.PN(),i=`, - "linkDataArray": `+this.Nh(this.linkDataArray,!0);return t+i}MN(t){super.MN(t);const i=t.linkDataArray;Array.isArray(i)&&(this.replaceJsonObjects(i),this.linkDataArray=i)}BT=`, - "insertedLinkKeys": `;FO=`, + "nodeGroupKeyProperty": `+this.Fe(this.nodeGroupKeyProperty)),t+i}Ty(t){super.Ty(t),t.linkKeyProperty&&(this.linkKeyProperty=t.linkKeyProperty),t.linkFromKeyProperty&&(this.linkFromKeyProperty=t.linkFromKeyProperty),t.linkToKeyProperty&&(this.linkToKeyProperty=t.linkToKeyProperty),t.linkFromPortIdProperty&&(this.linkFromPortIdProperty=t.linkFromPortIdProperty),t.linkToPortIdProperty&&(this.linkToPortIdProperty=t.linkToPortIdProperty),t.linkCategoryProperty&&(this.linkCategoryProperty=t.linkCategoryProperty),t.linkLabelKeysProperty&&(this.linkLabelKeysProperty=t.linkLabelKeysProperty),t.nodeIsGroupProperty&&(this.nodeIsGroupProperty=t.nodeIsGroupProperty),t.nodeGroupKeyProperty&&(this.nodeGroupKeyProperty=t.nodeGroupKeyProperty)}bN(){const t=super.bN(),i=`, + "linkDataArray": `+this.Ch(this.linkDataArray,!0);return t+i}kN(t){super.kN(t);const i=t.linkDataArray;Array.isArray(i)&&(this.replaceJsonObjects(i),this.linkDataArray=i)}UT=`, + "insertedLinkKeys": `;DO=`, "modifiedLinkData": `;VT=`, - "removedLinkKeys": `;UT(t){const i=new GSet;for(let e=0;e{if(f.model===s){if(f.modelChange==="linkDataArray")f.change===3?n.add(f.newValue):f.change===4&&r.add(f.oldValue);else if(s.containsLinkData(f.object))o.add(f.object);else if(f.object!==null)if(f.object!==null&&l&&l.has(f.object))l.get(f.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(f.object instanceof Model||s.containsNodeData(f.object))return;s.UT(f.object).each(d=>o.add(d))}}});const h=this.rg;h.clear(),n.each(f=>{h.add(s.getKeyForLinkData(f)),i||o.add(f)});const a=this.og;a.clear(),r.each(f=>{a.add(s.getKeyForLinkData(f)),i&&o.add(f)});let c=e;return h.count>0&&(c+=(i?this.VT:this.BT)+this.Nh(h.toArray(),!0)),o.count>0&&(c+=this.FO+this.Nh(o.toArray(),!0)),a.count>0&&(c+=(i?this.BT:this.VT)+this.Nh(a.toArray(),!0)),a.clear(),h.clear(),c}Dy(t){(t.linkCategoryProperty!==void 0&&t.linkCategoryProperty!==this.linkCategoryProperty||t.linkKeyProperty!==void 0&&t.linkKeyProperty!==this.linkKeyProperty||t.linkFromKeyProperty!==void 0&&t.linkFromKeyProperty!==this.linkFromKeyProperty||t.linkToKeyProperty!==void 0&&t.linkToKeyProperty!==this.linkToKeyProperty||t.linkFromPortIdProperty!==void 0&&t.linkFromPortIdProperty!==this.linkFromPortIdProperty||t.linkToPortIdProperty!==void 0&&t.linkToPortIdProperty!==this.linkToPortIdProperty||t.linkLabelKeysProperty!==void 0&&t.linkLabelKeysProperty!==this.linkLabelKeysProperty||t.nodeIsGroupProperty!==void 0&&t.nodeIsGroupProperty!==this.nodeIsGroupProperty||t.nodeGroupKeyProperty!==void 0&&t.nodeGroupKeyProperty!==this.nodeGroupKeyProperty)&&Util.o("applyIncrementalJson cannot change Model properties"),super.Dy(t);const i=t.insertedLinkKeys;if(Array.isArray(i)){const n=i.length;for(let o=0;o=0&&s.splice(e,1)):s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue));return}}else if(t.change===4){let e=t.oldParam;if(t.modelChange==="linkDataArray"){const s=t.oldValue;if(Util.wt(s)&&typeof e=="number"){const n=this.getKeyForLinkData(s);i?(this.sr.add(s),this.$e[e]!==s&&this.$e.splice(e,0,s),n!==void 0&&this.fi.set(n,s)):(this.sr.delete(s),this.$e[e]===s&&this.$e.splice(e,1),n!==void 0&&this.fi.delete(n))}return}else if(t.modelChange==="linkLabelKeys"){const s=this.getLabelKeysForLinkData(t.object);Array.isArray(s)&&typeof e=="number"&&(i?s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue):(e=s.indexOf(t.newValue),e>=0&&s.splice(e,1)));return}}super.changeState(t,i)}}get archetypeNodeData(){return this.Ll}set archetypeNodeData(t){const i=this.Ll;i!==t&&(t!==null&&Util.i(t,"object",GraphLinksModel,"archetypeNodeData"),this.Ll=t,this.t("archetypeNodeData",i,t))}LN(t){if(t===void 0)return;const i=this.Ll;if(i!==null){let e=this.findNodeDataForKey(t);e===null&&(e=this.copyNodeData(i),Model.lt(e,this.nodeKeyProperty,t),this.addNodeData(e))}return t}get linkFromKeyProperty(){return this.wo}set linkFromKeyProperty(t){const i=this.wo;i!==t&&(this.An(t,GraphLinksModel,"linkFromKeyProperty"),this.wo=t,this.t("linkFromKeyProperty",i,t))}getFromKeyForLinkData(t){return this.Te(t,!0)}setFromKeyForLinkData(t,i){this.Qd(t,i,!0)}get linkToKeyProperty(){return this.xo}set linkToKeyProperty(t){const i=this.xo;i!==t&&(this.An(t,GraphLinksModel,"linkToKeyProperty"),this.xo=t,this.t("linkToKeyProperty",i,t))}getToKeyForLinkData(t){return this.Te(t,!1)}setToKeyForLinkData(t,i){this.Qd(t,i,!1)}Te(t,i){if(t===null)return;const e=i?this.wo:this.xo;if(e==="")return;const s=Model.vt(t,e);if(s!==void 0){if(this.isKeyType(s))return s;Util.o((i?"FromKey":"ToKey")+" value for link data "+t+" is not a number or a string: "+s)}}Qd(t,i,e){if(i===null&&(i=void 0),i!==void 0&&!this.isKeyType(i)&&Util.we(i,"number or string",GraphLinksModel,e?"setFromKeyForLinkData:key":"setToKeyForLinkData:key"),t===null)return;const s=e?this.wo:this.xo;if(s==="")return;if(i=this.LN(i),!this.containsLinkData(t)){Model.lt(t,s,i);return}const n=Model.vt(t,s);n!==i&&(this.Js(n,t),Model.lt(t,s,i),this.findNodeDataForKey(i)===null&&this.$s(i,t),this.Et(e?"linkFromKey":"linkToKey",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkFromPortIdProperty(){return this.Ka}set linkFromPortIdProperty(t){const i=this.Ka;i!==t&&(this.An(t,GraphLinksModel,"linkFromPortIdProperty"),this.Ka=t,this.t("linkFromPortIdProperty",i,t))}getFromPortIdForLinkData(t){return this.L1(t,!0)}setFromPortIdForLinkData(t,i){this._d(t,i,!0)}get linkToPortIdProperty(){return this.Ya}set linkToPortIdProperty(t){const i=this.Ya;i!==t&&(this.An(t,GraphLinksModel,"linkToPortIdProperty"),this.Ya=t,this.t("linkToPortIdProperty",i,t))}getToPortIdForLinkData(t){return this.L1(t,!1)}setToPortIdForLinkData(t,i){this._d(t,i,!1)}L1(t,i){if(t===null)return"";const e=i?this.Ka:this.Ya;if(e==="")return"";const s=Model.vt(t,e);return s===void 0?"":s}_d(t,i,e){if(Util.i(i,"string",GraphLinksModel,e?"setFromPortIdForLinkData:portname":"setToPortIdForLinkData:portname"),t===null)return;const s=e?this.Ka:this.Ya;if(s==="")return;if(!this.containsLinkData(t)){Model.lt(t,s,i);return}let n=Model.vt(t,s);n===void 0&&(n=""),n!==i&&(Model.lt(t,s,i),this.Et(e?"linkFromPortId":"linkToPortId",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkLabelKeysProperty(){return this.Zs}set linkLabelKeysProperty(t){const i=this.Zs;i!==t&&(this.An(t,GraphLinksModel,"linkLabelKeysProperty"),this.Zs=t,this.t("linkLabelKeysProperty",i,t))}getLabelKeysForLinkData(t){if(t===null)return GraphLinksModel.EmptyArray;const i=this.Zs;if(i==="")return GraphLinksModel.EmptyArray;const e=Model.vt(t,i);return e===void 0?GraphLinksModel.EmptyArray:e}setLabelKeysForLinkData(t,i){if(t===null)return;const e=this.Zs;if(e==="")return;if(!this.containsLinkData(t)){Model.lt(t,e,i);return}let s=Model.vt(t,e);if(s===void 0&&(s=GraphLinksModel.EmptyArray),s!==i){if(Array.isArray(s)){const o=s.length;for(let r=0;r=0)return;n=s.length,s.push(i),this.containsLinkData(t)&&(this.findNodeDataForKey(i)===null&&this.$s(i,t),this.Et("linkLabelKeys",3,e,t,null,i,null,n))}else Util.o(e+" property is not an Array; cannot addLabelKeyForLinkData: "+t)}removeLabelKeyForLinkData(t,i){if(i==null||(this.isKeyType(i)||Util.we(i,"number or string",GraphLinksModel,"removeLabelKeyForLinkData:key"),t===null))return;const e=this.Zs;if(e==="")return;const s=Model.vt(t,e);if(Array.isArray(s)){const n=s.indexOf(i);if(n<0)return;s.splice(n,1),this.containsLinkData(t)&&(this.Js(i,t),this.Et("linkLabelKeys",4,e,t,i,null,n,null))}else s!==void 0&&Util.o(e+" property is not an Array; cannot removeLabelKeyforLinkData: "+t)}get linkDataArray(){return this.$e}set linkDataArray(t){const i=this.$e;if(i!==t){this.fi.clear();const e=t.length;for(let n=0;nnew GraphLinksModel;Model.initDiagramModel=Model.initDiagramModel=()=>new GraphLinksModel;class TreeModel extends Model{Dn;dg;ja;constructor(t,i){if(super(),this.Dn="parent",this.dg=!1,this.ja="parentLinkCategory",t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){super.cloneProtected(t),t.Dn=this.Dn,t.dg=this.dg,t.ja=this.ja}toString(t){if(t===void 0&&(t=0),t>=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" TreeModel";if(t>0){i+=` - node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n(w[w.ConstantSpacing=0]="ConstantSpacing",w[w.ConstantDistance=1]="ConstantDistance",w[w.ConstantAngle=2]="ConstantAngle",w[w.Packed=3]="Packed",w))(CircularArrangement||{}),CircularDirection=(w=>(w[w.Clockwise=10]="Clockwise",w[w.Counterclockwise=11]="Counterclockwise",w[w.BidirectionalLeft=12]="BidirectionalLeft",w[w.BidirectionalRight=13]="BidirectionalRight",w))(CircularDirection||{}),CircularSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w[w.Optimized=24]="Optimized",w))(CircularSorting||{}),CircularNodeDiameterFormula=(w=>(w[w.Pythagorean=30]="Pythagorean",w[w.Circular=31]="Circular",w))(CircularNodeDiameterFormula||{});class CircularLayout extends Layout{re;Of;U1;gg;B1;Lh;DN;FN;RN;bs;vy;Oy;Ha;Iy;XT;mg;pg;yg;If;zi;S;pe;ye;Ln;wg;constructor(t){super(),this.re=0,this.Of=0,this.U1=0,this.gg=360,this.B1=0,this.Lh=0,this.DN=new Point,this.FN=30,this.RN=0,this.bs=0,this.vy=0,this.Oy=new VertexArrangement,this.Ha=0,this.Iy=0,this.XT=600,this.mg=NaN,this.pg=1,this.yg=0,this.If=360,this.zi=0,this.S=10,this.pe=24,this.ye=LayoutVertex.standardComparer,this.Ln=6,this.wg=30,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.mg=this.mg,t.pg=this.pg,t.yg=this.yg,t.If=this.If,t.zi=this.zi,t.S=this.S,t.pe=this.pe,t.ye=this.ye,t.Ln=this.Ln,t.wg=this.wg}ri(t){t in CircularSorting?this.sorting=t:t in CircularDirection?this.direction=t:t in CircularArrangement?this.arrangement=t:t in CircularNodeDiameterFormula?this.nodeDiameterFormula=t:super.ri(t)}createNetwork(){return new CircularNetwork(this)}OO(t,i,e){t=this.IO(t);let s=this.B1,n=this.FN,o=this.re,r=this.Of,l=this.U1,h=this.gg,a=this.Lh,c=this.RN,f=this.bs,u=this.vy;if(s=this.arrangement,n=this.nodeDiameterFormula,o=this.radius,(!isFinite(o)||o<=0)&&(o=NaN),r=this.aspectRatio,(!isFinite(r)||r<=0)&&(r=1),l=this.startAngle,isFinite(l)||(l=0),h=this.sweepAngle,(!isFinite(h)||h>360||h<1)&&(h=360),a=this.spacing,isFinite(a)||(a=NaN),s===3&&n===31?s=0:s===3&&n!==31&&(n=31,s=this.arrangement),(this.direction===12||this.direction===13)&&this.sorting!==24){for(let g=0;!(g>=t.length||(i.add(t.elt(g)),g+1>=t.length));g+=2)e.add(t.elt(g+1));this.direction===12?(this.arrangement===3&&i.reverse(),t=new List,t.addAll(i),t.addAll(e)):(this.arrangement===3&&e.reverse(),t=new List,t.addAll(e),t.addAll(i))}const d=t.length;c=0;let m=0;for(let g=0;g1?(o=y,f=o*r):(f=y,o=f)}else o=this.V1(u*(h>=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180)}else o=this.V1(c+(h>=360?d:d-1)*(s!==3?a:a*1.6),r,l*Math.PI/180,h*Math.PI/180);f=o*r}else{f=o*r;const g=this.vN(o,f,l*Math.PI/180,h*Math.PI/180);if(isNaN(a))s===0&&(a=(g-c)/(h>=360?d:d-1));else if(s===0){const p=(g-c)/(h>=360?d:d-1);p=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180),f=o*r):a=p}else{let p=-1/0;for(let k=0;k=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180);x>o?(o=x,f=o*r,u=y):u=g/(h>=360?d:d-1)}}return this.B1=s,this.FN=n,this.re=o,this.Of=r,this.U1=l,this.gg=h,this.Lh=a,this.RN=c,this.bs=f,this.vy=u,t}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.network.vertexes;if(i.count<=1){if(i.count===1){const u=i.first();u.centerX=0,u.centerY=0}this.updateParts(),this.network=null,this.isValidLayout=!0;return}let e=new List;e.addAll(i.iterator);const s=new List,n=new List;e=this.OO(e,s,n);const o=this.B1,r=this.re,l=this.U1,h=this.gg,a=this.Lh,c=this.bs,f=this.vy;if((this.direction===12||this.direction===13)&&o===3)this.KT(e,h,l-h/2,10);else if(this.direction===12||this.direction===13){let u=0;switch(o){case 1:u=this.z1(r,c,l,f)*180/Math.PI;break;case 0:{let d=0,m=0;const g=s.first();g!==null&&(d=g.Ah(Math.PI/2));const p=n.first();p!==null&&(m=p.Ah(Math.PI/2)),u=this.z1(r,c,l,a+(d+m)/2)*180/Math.PI;break}case 2:u=h/e.length;break}if(this.direction===12){switch(o){case 1:this.Ey(s,h/2,l,11);break;case 0:this.Uy(s,h/2,l,11);break;case 2:this.By(s,h/2,l,11);break}switch(o){case 1:this.Ey(n,h/2,l+u,10);break;case 0:this.Uy(n,h/2,l+u,10);break;case 2:this.By(n,h/2,l+u,10);break}}else{switch(o){case 1:this.Ey(n,h/2,l,11);break;case 0:this.Uy(n,h/2,l,11);break;case 2:this.By(n,h/2,l,11);break}switch(o){case 1:this.Ey(s,h/2,l+u,10);break;case 0:this.Uy(s,h/2,l+u,10);break;case 2:this.By(s,h/2,l+u,10);break}}}else switch(o){case 1:this.Ey(e,h,l,this.direction);break;case 0:this.Uy(e,h,l,this.direction);break;case 2:this.By(e,h,l,this.direction);break;case 3:this.KT(e,h,l,this.direction);break}this.updateParts(),this.network=null,this.isValidLayout=!0}By(t,i,e,s){const n=this.gg,o=this.re,r=this.bs,l=e*Math.PI/180,h=i*Math.PI/180,a=t.length;for(let c=0;c=360?a:a-1):-(c*h)/a),u=t.elt(c),d=o*Math.tan(f)/r,m=Math.sqrt((o*o+r*r*d*d)/(1+d*d));u.centerX=m*Math.cos(f),u.centerY=m*Math.sin(f),u.actualAngle=f*180/Math.PI}}Uy(t,i,e,s){const n=this.re,o=this.bs,r=this.Lh;let l=e*Math.PI/180;const h=t.length;for(let a=0;a180&&(n-=360),n*=Math.PI/180,this.Iy=n,this.YT(t,i,e,s)}else this.GT(t,i,e,s);this.Oy.commit(t)}GT(t,i,e,s){const n=this.re,o=this.bs,r=this.Lh,l=this.Of;let h=n*Math.cos(e*Math.PI/180),a=o*Math.sin(e*Math.PI/180);const c=t.toArray();if(c.length===3){c[0].centerX=n,c[0].centerY=0,c[1].centerX=c[0].centerX-c[0].width/2-c[1].width/2-r,c[1].y=c[0].y,c[2].centerX=(c[0].centerX+c[1].centerX)/2,c[2].y=c[0].y-c[2].height-r;return}else if(c.length===4){c[0].centerX=n,c[0].centerY=0,c[2].centerX=-c[0].centerX,c[2].centerY=c[0].centerY,c[1].centerX=0,c[1].y=Math.min(c[0].y,c[2].y)-c[1].height-r,c[3].centerX=0,c[3].y=Math.max(c[0].y+c[0].height+r,c[2].y+c[2].height+r);return}const f=Point.l();for(let b=0;b=c.length-1));b++)this.jT(h,a,c,b,s,f)||this.HT(h,a,c,b,s,f),h=f.x,a=f.y;if(Point.s(f),this.Ha++,this.Ha>23)return;const u=c[0].centerX,d=c[0].centerY,m=c[c.length-1].centerX,g=c[c.length-1].centerY;let p=Math.abs(u-m)-((c[0].width+c[c.length-1].width)/2+r);const y=Math.abs(d-g)-((c[0].height+c[c.length-1].height)/2+r);let x=0;if(Math.abs(y)<1){const b=Math.abs(u-m),P=(c[0].width+c[c.length-1].width)/2;b0?x=y:Math.abs(p)<1?x=0:x=p;let k=!1;Math.abs(m)>Math.abs(g)?k=m>0!=d>g:k=g>0!=u1&&(this.Ha<8?this.re-=x/(2*Math.PI):c.length<5&&x>10?this.re/=2:this.re-=x>0?1.7:-2.3,this.bs=this.re*l,this.GT(t,i,e,s))}YT(t,i,e,s){const n=this.re,o=this.bs,r=this.Of;let l=n*Math.cos(e*Math.PI/180),h=o*Math.sin(e*Math.PI/180);const a=Point.l(),c=t.toArray();for(let m=0;m=c.length-1));m++)this.jT(l,h,c,m,s,a)||this.HT(l,h,c,m,s,a),l=a.x,h=a.y;if(Point.s(a),this.Ha++,this.Ha>23)return;const f=Math.atan2(h,l);let u=s===10?this.Iy-f:f-this.Iy;u=Math.abs(u)1&&(this.Ha<8?this.re-=d/(2*Math.PI):this.re-=d>0?1.7:-2.3,this.bs=this.re*r,this.YT(t,i,e,s))}jT(t,i,e,s,n,o){const r=this.Lh,l=this.re,h=this.bs;let a=0,c=0;const f=(e[s].width+e[s+1].width)/2+r;let u=!1;if(i>=0!=(n===10)){if(a=t+f,a>l){if(a=t-f,a<-l)return o.x=a,o.y=c,!1;u=!0}}else if(a=t-f,a<-l){if(a=t+f,a>l)return o.x=a,o.y=c,!1;u=!0}return c=Math.sqrt(1-Math.min(1,a*a/(l*l)))*h,i<0!==u&&(c=-c),Math.abs(i-c)>(e[s].height+e[s+1].height)/2?(o.x=a,o.y=c,!1):(o.x=a,o.y=c,!0)}HT(t,i,e,s,n,o){const r=this.Lh,l=this.re,h=this.bs;let a=0,c=0;const f=(e[s].height+e[s+1].height)/2+r;let u=!1;if(t>=0!=(n===10)){if(c=i-f,c<-h){if(c=i+f,c>h)return o.x=a,o.y=c,!1;u=!0}}else if(c=i+f,c>h){if(c=i-f,c<-h)return o.x=a,o.y=c,!1;u=!0}return a=Math.sqrt(1-Math.min(1,c*c/(h*h)))*l,t<0!==u&&(a=-a),Math.abs(t-a)>(e[s].width+e[s+1].width)/2?(o.x=a,o.y=c,!1):(o.x=a,o.y=c,!0)}commitLayout(){this.commitNodes(),this.isRouting&&this.commitLinks()}commitNodes(){const t=this.group!==null&&this.group.hasPlaceholder(),i=t?this.group.location.copy():null;let e=this.actualCenter;t?e=new Point(0,0):(e.x=this.arrangementOrigin.x+this.re,e.y=this.arrangementOrigin.y+this.bs);const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;n.x+=e.x,n.y+=e.y,n.commit()}if(t){this.group.ensureBounds();const n=this.group.position.copy(),o=this.group.location.copy(),r=i.subtract(o.subtract(n));this.group.move(r),this.DN=r.subtract(n)}}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}vN(t,i,e,s){const n=this.XT;if(Math.abs(this.Of-1)<.001)return e!==void 0&&s!==void 0?s*t:2*Math.PI*t;const o=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let r=0,l=0;e!==void 0&&s!==void 0?l=s/(n+1):l=Math.PI/(2*(n+1));let h=0;for(let a=0;a<=n;a++){e!==void 0&&s!==void 0?h=e+a*s/n:h=a*Math.PI/(2*n);const c=Math.sin(h);r+=Math.sqrt(1-o*o*c*c)*l}return e!==void 0&&s!==void 0?(t>i?t:i)*r:4*(t>i?t:i)*r}V1(t,i,e,s){let n=0;return e!==void 0&&s!==void 0?n=this.vN(1,i,e,s):n=this.vN(1,i),t/n}z1(t,i,e,s){if(Math.abs(this.Of-1)<.001)return s/t;const n=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let o=0;const r=2*Math.PI/(this.network.vertexes.count*700);t>i&&(e+=Math.PI/2);for(let l=0;;l++){const h=e+l*r,a=Math.sin(h);if(o+=(t>i?t:i)*Math.sqrt(1-n*n*a*a)*r,o>=s)return l*r}}IO(t){switch(this.sorting){case 20:break;case 21:t.reverse();break;case 22:t.sort(this.comparer);break;case 23:t.sort(this.comparer),t.reverse();break;case 24:return this.BO(this.VO(t));default:Util.o("Invalid sorting type.")}return t}VO(t){const i=[];for(let s=0;sn&&(n=u,o=c)}else for(let c=0;cn&&(n=f,o=c)}e.add(t.elt(o)),i[o]=-1;const r=t.elt(o);let l=0;const h=r.sourceEdges;for(;h.next();){const f=h.value.fromVertex;l=t.indexOf(f),!(l<0)&&i[l]>=0&&i[l]++}const a=r.destinationEdges;for(;a.next();){const f=a.value.toVertex;l=t.indexOf(f),!(l<0)&&i[l]>=0&&i[l]++}}return e}BO(t){const i=[];for(let f=0;f=0){const C=Math.abs(x-(L>=x?L+1:L));b+=C=x&&M++,L>=x&&L++,M>L){const C=L;L=M,M=C}L-M<(s.length+2)/2==(M=0&&(n.push(f),o.push(x))}h++}let a=!1;const c=s.length;for(;;){a=!0;for(let f=0;f=0){let g=0;for(let p=0;pm?x-m:m-x,b=c-k;g+=xb?1:-1}s.splice(g<0?m:m+1,0,u),r.splice(f,1),f--}else a=!1}if(a)break;s.push(r[0]),r.splice(0,1)}for(let f=0;f0||isNaN(t))&&(this.mg=t,this.invalidateLayout()))}get aspectRatio(){return this.pg}set aspectRatio(t){this.pg!==t&&(Util.i(t,"number",CircularLayout,"aspectRatio"),t>0&&(this.pg=t,this.invalidateLayout()))}get startAngle(){return this.yg}set startAngle(t){this.yg!==t&&(Util.i(t,"number",CircularLayout,"startAngle"),this.yg=t,this.invalidateLayout())}get sweepAngle(){return this.If}set sweepAngle(t){this.If!==t&&(Util.i(t,"number",CircularLayout,"sweepAngle"),t>0&&t<=360?this.If=t:this.If=360,this.invalidateLayout())}get arrangement(){return this.zi}set arrangement(t){this.zi!==t&&(t===3||t===0||t===1||t===2)&&(this.zi=t,this.invalidateLayout())}get direction(){return this.S}set direction(t){this.S!==t&&(t===10||t===11||t===12||t===13)&&(this.S=t,this.invalidateLayout())}get sorting(){return this.pe}set sorting(t){this.pe!==t&&(this.pe=t,this.invalidateLayout())}get comparer(){return this.ye}set comparer(t){this.ye!==t&&(Util.i(t,"function",CircularLayout,"comparer"),this.ye=t,this.invalidateLayout())}get spacing(){return this.Ln}set spacing(t){this.Ln!==t&&(Util.i(t,"number",CircularLayout,"spacing"),this.Ln=t,this.invalidateLayout())}get nodeDiameterFormula(){return this.wg}set nodeDiameterFormula(t){this.wg!==t&&(t===30||t===31)&&(this.wg=t,this.invalidateLayout())}get actualXRadius(){return this.re}get actualYRadius(){return this.bs}get actualSpacing(){return this.Lh}get actualCenter(){return this.DN}static ConstantSpacing=0;static ConstantDistance=1;static ConstantAngle=2;static Packed=3;static Clockwise=10;static Counterclockwise=11;static BidirectionalLeft=12;static BidirectionalRight=13;static Forwards=20;static Reverse=21;static Ascending=22;static Descending=23;static Optimized=24;static Pythagorean=30;static Circular=31}class VertexArrangement{Ef;qa;Uf;constructor(){this.Ef=-1/0,this.qa=null,this.Uf=null}EO(t,i){if(t>0&&this.Ef<0||Math.abs(t)0)){this.Ef=t,this.qa=[],this.Uf=[];for(let e=0;e0){for(this.network.deleteSelfEdges(),i=this.network.vertexes.iterator;i.next();){const o=i.value;o.charge=this.electricalCharge(o),o.mass=this.gravitationalMass(o)}const s=this.network.edges.iterator;for(;s.next();){const o=s.value;o.stiffness=this.springStiffness(o),o.length=this.springLength(o)}if(this.ON(),this.Th=0,this.needsPrelayout()){const o=this.network,r=o.splitIntoSubNetworks(!1);let l=r.iterator;for(;l.next();){const h=l.value;this.doConnectedSubnetLayout(h)}for(l=r.iterator,this.XO(l,o),l=r.iterator;l.next();){const h=l.value,a=h.vertexes.iterator;for(;a.next();){const f=a.value;o.addVertex(f)}const c=h.edges.iterator;for(;c.next();){const f=c.value;o.addEdge(f)}}}else this.qT(this.network,this.maxIterations);this.updateParts()}this.maxIterations=e,this.isValidLayout=!0}needsPrelayout(){if(this.network.vertexes.count<3)return!1;let t=0,i=0;const e=this.network.vertexes.first().bounds,s=this.network.vertexes.iterator;for(;s.next();){const n=s.value,o=n.bounds;if(isNaN(n.x)||isNaN(n.y)||o.intersectsRect(e)&&(t++,t>2))return!0;if(i>10)return!1;i++}return!1}doConnectedSubnetLayout(t){let i=t.vertexes.iterator;for(;i.next();){const l=i.value;l.hierarchicalVertexes.add(l)}let e=t,s=this.Yf;if(isNaN(s)&&(s=t.edges.count/t.vertexes.count),sMath.max(100,Math.sqrt(s*t.vertexes.count));)e=this.coarsenNetwork(e);let n=0;i=e.vertexes.iterator;let o=this.randomNumberGenerator;for(o===null&&(this.randomNumberGenerator=o=new RandomNumberGenerator(0));i.next();){i.value.idInCluster=n++;const l=10*(o.random()-.5),h=10*(o.random()-.5);this.isFixed(i.value)||(i.value.x=l,i.value.y=h);const a=i.value.hierarchicalVertexes.iterator;for(;a.next();)this.isFixed(a.value)||(a.value.x=l,a.value.y=h)}const r=this.computePairwiseDistances(e);this.KO(e,r,this.maxPrelayoutIterations,t.vertexes.count),this.qT(t,this.maxIterations)}computePairwiseDistances(t){const i=t.vertexes.count,e=new Array(i);for(let r=0;r0;){const l=o.shift(),h=l.vertexes.iterator;for(;h.next();){const a=h.value;n.has(a.idInCluster)||(n.set(a.idInCluster,n.get(l.idInCluster)+1),o.push(a))}}for(let l=0;l=0;m--)if(t[m].y>c.y&&t[m].x-c.xc.x&&t[m].y-c.ya+f){const u=s+o-h,d=n-a-f;return Geo.bw(u*u+d*d)}else if(n+rh+c)if(n>a+f){const u=s-h-c,d=n-a-f;return Geo.bw(u*u+d*d)}else if(n+ra+f?n-(a+f):n+rr-o;l?i.sort((m,g)=>m===null||g===null||m===g?0:m.centerX-g.centerX):i.sort((m,g)=>m===null||g===null||m===g?0:m.centerY-g.centerY);const h=this.Bf;let a=0,c=0,f=0;for(let m=0;mh||C-x>h){if(l)break;continue}if(k-S>h||S-k>h){if(!l)break;continue}const N=this.IN(g,P),T=2*g.charge,A=2*P.charge;if(N>1)a=T*A/(N*N),c=a*(x-C)/N,f=a*(k-S)/N;else{let D=this.randomNumberGenerator;D===null&&(this.randomNumberGenerator=D=new RandomNumberGenerator(0));const F=D.random(),R=D.random();if(x>C)c=Math.abs(P.bounds.right-g.bounds.x),c=T*A*(1+c)*F;else if(xS)f=Math.abs(P.bounds.bottom-g.bounds.y),f=T*A*(1+f)*R;else if(x1&&(a=.1*m.stiffness*(S-m.length),c=a*.5*(g.width+p.height)*(k-L)/S,f=a*.5*(g.width+p.height)*(b-C)/S),g.forceX-=c,g.forceY-=f,p.forceX+=c,p.forceY+=f}let d=0;for(let m=0;mthis.epsilonDistance*this.epsilonDistance}KO(t,i,e,s){const n=this.Th+e,o=Math.sqrt(s);this.Vy=this.Wa*t.vertexes.count;const r=t.vertexes.toArray();let l=0,h=0,a=0;for(;this.Th0){r[c].forceX=this.Vy*r[c].forceX/f,r[c].forceY=this.Vy*r[c].forceY/f,this.isFixed(r[c])||(r[c].x+=r[c].forceX,r[c].y+=r[c].forceY);const u=r[c].hierarchicalVertexes.iterator;for(;u.next();){const d=u.value;this.isFixed(d)||(d.centerX+=r[c].forceX,d.centerY+=r[c].forceY)}}l+=f*f}if(l>=h){if(a++,a>=5)break}else a=0;this.Vy*=.95}}moveVertex(t){let i=t.forceX,e=t.forceY;const s=this.moveLimit;return i<-s?i=-s:i>s&&(i=s),e<-s?e=-s:e>s&&(e=s),t.centerX+=i,t.centerY+=e,i*i+e*e}shouldInteract(t,i){return!0}moveFixedVertex(t){}commitLayout(){this.zy(),this.commitNodes(),this.isRouting&&this.commitLinks()}zy(){if(!this.setsPortSpots)return;const t=this.network.edges.iterator;for(;t.next();){const e=t.value.link;e!==null&&(e.fromSpot=Spot.Default,e.toSpot=Spot.Default)}}commitNodes(){let t=0,i=0;if(this.arrangesToOrigin){const n=Rect.l();this.Nw(this.network,n);const o=this.arrangementOrigin;t=o.x-n.x,i=o.y-n.y,Rect.s(n)}const e=Rect.l(),s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;(t!==0||i!==0)&&(e.a(n.bounds),e.x+=t,e.y+=i,n.bounds=e),n.commit()}Rect.s(e)}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}springStiffness(t){const i=t.stiffness;return isNaN(i)?this.Vf:i}springLength(t){const i=t.length;return isNaN(i)?this.zf:i}electricalCharge(t){const i=t.charge;return isNaN(i)?this.Xf:i}electricalFieldX(t,i){return 0}electricalFieldY(t,i){return 0}gravitationalMass(t){const i=t.mass;return isNaN(i)?this.Kf:i}gravitationalFieldX(t,i){return 0}gravitationalFieldY(t,i){return 0}isFixed(t){return t.isFixed}get currentIteration(){return this.Th}get arrangementSpacing(){return this.ks}set arrangementSpacing(t){this.ks.equals(t)||(this.ks.a(t),this.invalidateLayout())}get arrangesToOrigin(){return this.xg}set arrangesToOrigin(t){this.xg!==t&&(Util.i(t,"boolean",ForceDirectedLayout,"arrangesToOrigin"),this.xg=t,this.invalidateLayout())}get setsPortSpots(){return this.Fn}set setsPortSpots(t){this.Fn!==t&&(Util.i(t,"boolean",ForceDirectedLayout,"setsPortSpots"),this.Fn=t,this.invalidateLayout())}get comments(){return this.Re}set comments(t){this.Re!==t&&(Util.i(t,"boolean",ForceDirectedLayout,"comments"),this.Re=t,this.invalidateLayout())}get maxPrelayoutIterations(){return this.bg}set maxPrelayoutIterations(t){this.bg!==t&&(Util.i(t,"number",ForceDirectedLayout,"maxPrelayoutIterations"),t>=0&&(this.bg=t,this.invalidateLayout()))}get maxIterations(){return this.kg}set maxIterations(t){this.kg!==t&&(Util.i(t,"number",ForceDirectedLayout,"maxIterations"),t>=0&&(this.kg=t,this.invalidateLayout()))}get epsilonDistance(){return this.Pg}set epsilonDistance(t){this.Pg!==t&&(Util.i(t,"number",ForceDirectedLayout,"epsilonDistance"),t>0&&(this.Pg=t,this.invalidateLayout()))}get infinityDistance(){return this.Bf}set infinityDistance(t){this.Bf!==t&&(Util.i(t,"number",ForceDirectedLayout,"infinityDistance"),t>1&&(this.Bf=t,this.invalidateLayout()))}get moveLimit(){return this.Mg}set moveLimit(t){this.Mg!==t&&(Util.i(t,"number",ForceDirectedLayout,"moveLimit"),this.Mg=t,this.invalidateLayout())}get randomNumberGenerator(){return this.Sg}set randomNumberGenerator(t){this.Sg!==t&&(t!==null&&typeof t.random!="function"&&Util.o('ForceDirectedLayout.randomNumberGenerator must have a "random()" function on it: '+t),this.Sg=t)}get defaultSpringStiffness(){return this.Vf}set defaultSpringStiffness(t){this.Vf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultSpringStiffness"),this.Vf=t,this.invalidateLayout())}get defaultSpringLength(){return this.zf}set defaultSpringLength(t){this.zf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultSpringLength"),this.zf=t,this.invalidateLayout())}get defaultElectricalCharge(){return this.Xf}set defaultElectricalCharge(t){this.Xf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultElectricalCharge"),this.Xf=t,this.invalidateLayout())}get defaultGravitationalMass(){return this.Kf}set defaultGravitationalMass(t){this.Kf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultGravitationalMass"),this.Kf=t,this.invalidateLayout())}get defaultCommentSpringLength(){return this.Ng}set defaultCommentSpringLength(t){this.Ng!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultCommentSpringLength"),this.Ng=t,this.invalidateLayout())}get defaultCommentElectricalCharge(){return this.Cg}set defaultCommentElectricalCharge(t){this.Cg!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultCommentElectricalCharge"),this.Cg=t,this.invalidateLayout())}get prelayoutQuality(){return this.Yf}set prelayoutQuality(t){this.Yf!==t&&(Util.i(t,"number",ForceDirectedLayout,"prelayoutQuality"),this.Yf=t,this.invalidateLayout())}get prelayoutSpread(){return this.Wa}set prelayoutSpread(t){this.Wa!==t&&(Util.i(t,"number",ForceDirectedLayout,"prelayoutSpread"),this.Wa=t,this.invalidateLayout())}}class ForceDirectedNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new ForceDirectedVertex(this)}createEdge(){return new ForceDirectedEdge(this)}}class ForceDirectedVertex extends LayoutVertex{K1;Y1;G1;j1;H1;hierarchicalVertexes;idInCluster;constructor(t){super(t),this.K1=!1,this.Y1=NaN,this.G1=NaN,this.j1=0,this.H1=0,this.hierarchicalVertexes=new List,this.idInCluster=-1}get isFixed(){return this.K1}set isFixed(t){this.K1!==t&&(Util.i(t,"boolean",ForceDirectedVertex,"isFixed"),this.K1=t)}get charge(){return this.Y1}set charge(t){this.Y1!==t&&(Util.i(t,"number",ForceDirectedVertex,"charge"),this.Y1=t)}get mass(){return this.G1}set mass(t){this.G1!==t&&(Util.i(t,"number",ForceDirectedVertex,"mass"),this.G1=t)}get forceX(){return this.j1}set forceX(t){this.j1!==t&&(Util.i(t,"number",ForceDirectedVertex,"forceX"),this.j1=t)}get forceY(){return this.H1}set forceY(t){this.H1!==t&&(Util.i(t,"number",ForceDirectedVertex,"forceY"),this.H1=t)}}class ForceDirectedEdge extends LayoutEdge{q1;W1;constructor(t){super(t),this.q1=NaN,this.W1=NaN}get stiffness(){return this.q1}set stiffness(t){this.q1!==t&&(Util.i(t,"number",ForceDirectedEdge,"stiffness"),this.q1=t)}get length(){return this.W1}set length(t){this.W1!==t&&(Util.i(t,"number",ForceDirectedEdge,"length"),this.W1=t)}}class RandomNumberGenerator{I;R;Q;M;A;seed;constructor(t){t===void 0&&(t=42),this.seed=t,this.A=48271,this.M=2147483647,this.Q=this.M/this.A,this.R=this.M%this.A,this.I=1/this.M,this.random()}random(){const t=this.seed/this.Q,i=this.seed%this.Q,e=this.A*i-this.R*t;return e>0?this.seed=e:this.seed=e+this.M,this.seed*this.I}}var LayeredDigraphCycleRemove=(w=>(w[w.DepthFirst=0]="DepthFirst",w[w.Greedy=1]="Greedy",w[w.FromLayers=2]="FromLayers",w))(LayeredDigraphCycleRemove||{}),LayeredDigraphLayering=(w=>(w[w.OptimalLinkLength=10]="OptimalLinkLength",w[w.LongestPathSink=11]="LongestPathSink",w[w.LongestPathSource=12]="LongestPathSource",w))(LayeredDigraphLayering||{}),LayeredDigraphInit=(w=>(w[w.DepthFirstOut=20]="DepthFirstOut",w[w.DepthFirstIn=21]="DepthFirstIn",w[w.Naive=22]="Naive",w))(LayeredDigraphInit||{}),LayeredDigraphAggressive=(w=>(w[w.None=30]="None",w[w.Less=31]="Less",w[w.More=32]="More",w))(LayeredDigraphAggressive||{}),LayeredDigraphPack=(w=>(w[w.None=0]="None",w[w.Expand=1]="Expand",w[w.Straighten=2]="Straighten",w[w.Median=4]="Median",w[w.MaybeExpand=8]="MaybeExpand",w[w.All=15]="All",w))(LayeredDigraphPack||{}),LayeredDigraphAlign=(w=>(w[w.None=0]="None",w[w.UpperLeft=1]="UpperLeft",w[w.UpperRight=2]="UpperRight",w[w.LowerLeft=4]="LowerLeft",w[w.LowerRight=8]="LowerRight",w[w.All=15]="All",w))(LayeredDigraphAlign||{});class LayeredDigraphLayout extends Layout{Ps;Wi;S;Gf;jf;Hf;Ja;qf;nr;Wf;Fn;Mt;Xy;Kt;Lg;Ms;ui;Qs;Ss;Ns;Bt;Ag;$a;Tg;_s;Jf;or;Rn;vn;EN;constructor(t){super(),this.Ps=25,this.Wi=25,this.S=0,this.Gf=0,this.jf=10,this.Hf=20,this.Ja=4,this.qf=31,this.nr=15,this.Wf=10,this.Fn=!0,this.Mt=-1,this.Xy=-1,this.Kt=-1,this.Lg=0,this.Ms=0,this.ui=null,this.Qs=null,this.Ss=null,this.Ns=null,this.Bt=null,this.Ag=0,this.$a=null,this.Tg=null,this._s=0,this.Jf=null,this.or=new Point,this.Rn=[],this.Rn.length=100,this.vn=15,this.EN=0,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Ps=this.Ps,t.Wi=this.Wi,t.S=this.S,t.Gf=this.Gf,t.jf=this.jf,t.Hf=this.Hf,t.Ja=this.Ja,t.qf=this.qf,t.nr=this.nr,t.Wf=this.Wf,t.Fn=this.Fn,t.vn=this.vn}ri(t){t in LayeredDigraphAggressive?this.aggressiveOption=t:t in LayeredDigraphCycleRemove?this.cycleRemoveOption=t:t in LayeredDigraphInit?this.initializeOption=t:t in LayeredDigraphLayering?this.layeringOption=t:super.ri(t)}createNetwork(){return new LayeredDigraphNetwork(this)}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin),this.GO(),this.network.vertexes.count>0&&(this.network.deleteSelfEdges(),this.cycleRemoveOption!==2&&this.removeCycles(),this.jO(),this.cycleRemoveOption===2&&this.removeCycles(),this.HO(),this.qO(),this.WO(),this.reduceCrossings(),this.straightenAndPack(),this.updateParts()),this.network=null,this.isValidLayout=!0}linkMinLength(t){return 1}linkLengthWeight(t){return 1}linkStraightenWeight(t){const i=t.fromVertex.node||t.fromVertex.data,e=t.toVertex.node||t.toVertex.data;return i===null&&e===null?8:i===null||e===null?4:1}nodeMinLayerSpace(t,i){return t.node===null&&t.data===null?0:this.S===90||this.S===270?i?t.focus.y+10:t.bounds.height-t.focus.y+10:i?t.focus.x+10:t.bounds.width-t.focus.x+10}nodeMinColumnSpace(t,i){if(t.node===null&&t.data===null)return 0;const e=i?t.J1:t.$1;if(e!==null)return e;const s=this.S;return s===90||s===270?i?t.J1=t.focus.x/this.Wi+1|0:t.$1=(t.bounds.width-t.focus.x)/this.Wi+1|0:i?t.J1=t.focus.y/this.Wi+1|0:t.$1=(t.bounds.height-t.focus.y)/this.Wi+1|0}Ji(){this.$a===null&&(this.$a=[]);let t=0;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;this.$a[t]=e.layer,t++,this.$a[t]=e.column,t++,this.$a[t]=e.index,t++}return this.$a}Ze(t){let i=0;const e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;s.layer=t[i],i++,s.column=t[i],i++,s.index=t[i],i++}}JT(t,i){const e=this.Dh(t),s=this.ui[t];(this.Tg===null||this.Tg.length=0){for(c=e[o].po,f=0;fk||d===k&&g>P)&&r++,bd||k===d&&P>g)&&r++)}if(i<=0){for(c=e[o].ir,f=0;fk||d===k&&m>b)&&r++,Pd||k===d&&b>m)&&r++)}for(n[o*s+o]=r,a=o+1;a=0){for(p=e[o].po,M=e[a].po,f=0;f=0&&(h=s[r].ir);let a,c=0,f=0;if(l!==null)for(let u=0;u=0&&(h=r.ir);let a=0,c=0;const f=r.near;f!==null&&f.layer===r.layer&&(a+=f.column-1,c++);let u;if(l!==null)for(let d=0;d=0&&(h=r.ir);let a=0;const c=[],f=r.near;f!==null&&f.layer===r.layer&&(c[a]=f.column-1,a++);let u;if(l!==null)for(let d=0;dm-g);const d=a>>1;a&1?n[o]=c[d]:n[o]=c[d-1]+c[d]>>1}}return this.Fh(t,e),n}Gy(t,i,e,s,n){if(t.component===e){t.component=i;let o=0,r=0;if(s){const l=t.destinationEdges;for(;l.next();){const h=l.value,a=h.toVertex;o=t.layer-a.layer,r=this.linkMinLength(h),o===r&&this.Gy(a,i,e,s,n)}}if(n){const l=t.sourceEdges;for(;l.next();){const h=l.value,a=h.fromVertex;o=a.layer-t.layer,r=this.linkMinLength(h),o===r&&this.Gy(a,i,e,s,n)}}}}UN(t,i,e,s,n){if(t.component===e){if(t.component=i,s){const o=t.destinationEdges;for(;o.next();){const l=o.value.toVertex;this.UN(l,i,e,s,n)}}if(n){const o=t.sourceEdges;for(;o.next();){const l=o.value.fromVertex;this.UN(l,i,e,s,n)}}}}removeCycles(){const t=this.network.edges.iterator;for(;t.next();){const i=t.value;i.rev=!1}switch(this.Gf){default:case 1:this.$O();break;case 0:this.ZO();break;case 2:this.QO();break}}QO(){const t=this.network,i=t.vertexes.iterator;let e=1/0;for(;i.next();){const s=i.value;e=Math.min(e,s.layer)}if(e<1/0){if(e<0)for(i.reset();i.next();){const r=i.value;r.layer-=e}const s=[];for(i.reset();i.next();){const r=i.value,l=s[r.layer];l===void 0?s[r.layer]=[r]:l.push(r)}let n=0;for(let r=0;r0)for(let h=0;hh.index&&(t.reverseEdge(r),r.rev=!0)}}_O(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.$i)return e}return null}ZT(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.$i){let s=!0;const n=e.destinationEdges;for(;n.next();)if(n.value.toVertex.$i){s=!1;break}if(s)return e}}return null}QT(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.$i){let s=!0;const n=e.sourceEdges;for(;n.next();)if(n.value.fromVertex.$i){s=!1;break}if(s)return e}}return null}tI(t){let i=null,e=0;const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;if(n.$i){let o=0;const r=n.destinationEdges;for(;r.next();)r.value.toVertex.$i&&o++;let l=0;const h=n.sourceEdges;for(;h.next();)h.value.fromVertex.$i&&l++;(i===null||ec&&this.Gy(h,e,-1,!0,!1)}for(this.Gy(t,s,-1,!0,!0);t.component!==e;){let r=0,l=1/0,h=0,a=null;const c=this.network.vertexes.iterator;for(;c.next();){const f=c.value;if(f.component===s){let u=0,d=!1;const m=f.po;o=m.length;for(let p=0;p0){for(i.reset();i.next();){const f=i.value;f.component===s&&(f.layer+=l)}t.component=e}else a.component=e}}nI(t){const i=this.network.vertexes.iterator;for(;i.next();){const n=i.value;n.component=-1}const e=0,s=1;for(this.Gy(t,s,-1,!0,!1);t.component!==e;){let n=0,o=1/0,r=0,l=null;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value;if(a.component===s){let c=0,f=!1;const u=a.po;let d=u.length;for(let g=0;gr)&&!f&&(l=a,r=c)}}if(n<0){for(i.reset();i.next();){const a=i.value;a.component===s&&(a.layer-=o)}t.component=e}else l.component=e}}HO(){const t=this.network,i=[],e=t.edges.iterator;for(;e.next();){const s=e.value;s.valid=!1,i.push(s)}for(let s=0;sb&&f>0){for(n.valid=!1,y=t.createVertex(),y.node=null,y.Q1=2,y.layer=f-1,x&&kb&&f>0;)y=t.createVertex(),y.node=null,y.Q1=3,y.layer=f-1,x&&kt[this.Ms]&&(this.Xy=t[e]-1,this.Ms=e),t[e]{o.index=this.ui[s],this.ui[s]++})}}hI(){let t=null;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;if(e.near&&(t===null&&(t=new Map),e.layer===e.near.layer)){const s=t.get(e.near)||[];s.push(e),t.set(e.near,s)}}for(let e=this.Mt;e>=0;e--)for(i.reset();i.next();){const s=i.value;s.layer===e&&s.index===-1&&this.oD(s,t)}}oD(t,i){if(t.near)return;const e=t.layer;if(t.index=this.ui[e],this.ui[e]++,i){const o=i.get(t);Array.isArray(o)&&o.forEach(r=>{r.index=this.ui[e],this.ui[e]++})}const s=t.ir;let n=!0;for(;n;){n=!1;for(let o=0;ol.portFromColOffset&&(n=!0,s[o]=l,s[o+1]=r)}}for(let o=0;o{a.index=this.ui[e],this.ui[e]++})}const s=t.po;let n=!0,o=0;for(;n;)for(n=!1,o=0;oa.portToColOffset&&(n=!0,s[o]=a,s[o+1]=h)}let r,l;for(o=0;o=0;s--)this.tk(s,-1),this.ls(s,-1,!1,-1);n=this.countCrossings(),n=0;s--)this.tk(s,0),this.ls(s,0,!1,0);n=this.countCrossings(),n=0;r--)for(l=0;l<=r;l++){for(o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,1,!1,1)||o;for(n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,-1,!1,-1)||o;for(n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,0,!1,0)||o;for(n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,0,!1,0)||o;n>=t?this.Ze(i):(t=n,i=this.Ji())}break;default:case 31:for(r=this.Mt,l=0,h=t+1;(a=this.countCrossings())=l;s--)o=this.ls(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,1,!1,1)||o;for(n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,-1,!1,-1)||o;for(n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,0,!1,0)||o;for(n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,0,!1,0)||o;n>=t?this.Ze(i):(t=n,i=this.Ji())}break}this.Ze(i)}tk(t,i){let e=0,s=!1;const n=this.Dh(t),o=this.ui[t],r=this.$T(t,i),l=this.Yy(t,i);for(e=0;e0)for(h=[],l=0;ll+1&&(m+=4*(v-l),g+=4*(v-(l+1)))}}const E=n[l].destinationEdges.iterator;if(e&&s>=0)for(;E.next();){const q=E.value;O=q.toVertex,q.valid&&O.layer!==t&&(N=this.linkStraightenWeight(q),T=q.portFromColOffset,A=q.portToColOffset,F=O.column,C+=(Math.abs(p+T-(F+A))+1)*N,S+=(Math.abs(L+T-(F+A))+1)*N)}for(E.reset();E.next();){const q=E.value;if(O=q.toVertex,q.valid&&O.layer===t){for(U=0;Ul+1&&(m+=4*(v-(l+1)),g+=4*(v-l))}}const B=n[l+1].destinationEdges.iterator;if(e&&s>=0)for(;B.next();){const q=B.value;O=q.toVertex,q.valid&&O.layer!==t&&(N=this.linkStraightenWeight(q),T=q.portFromColOffset,A=q.portToColOffset,F=O.column,C+=(Math.abs(y+T-(F+A))+1)*N,S+=(Math.abs(M+T-(F+A))+1)*N)}for(B.reset();B.next();){const q=B.value;if(O=q.toVertex,q.valid&&O.layer===t){for(U=0;U1e3&&s&&(e=!1),e){const n=[];let o=0;for(o=0;o<=this.Mt;o++)n[o]=0;let r=0;const l=this.network.vertexes.iterator;for(;l.next();){const a=l.value;t=a.layer,r=a.column;const c=this.nodeMinColumnSpace(a,!1);n[t]=Math.max(n[t],r+c)}const h=8;for(l.reset();l.next();){const a=l.value;t=a.layer,r=a.column,a.column=((this.Kt-n[t])*h>>1)+r*h}this.Kt*=h}if(this.nr&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Dg(t,-1)||i;i=this.Dg(this.Ms,0)||i,n++}}if(this.nr&4){for(t=this.Ms+1;t<=this.Mt;t++)this.VN(t,1);for(t=this.Ms-1;t>=0;t--)this.VN(t,-1);this.VN(this.Ms,0)}if(e&&(this.lD(-1),this.lD(1)),this.nr&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Dg(t,0)||i;n++}}}Dg(t,i){let e=!1;for(;this.fI(t,i);)e=!0;return e}fI(t,i){let e=0;const s=this.Dh(t),n=this.ui[t],o=this.Yy(t,-1);if(i>0)for(e=0;ec+this.nodeMinColumnSpace(s[e-1],!1)?u=a-1:u=a;let d=0;e+1>=n||s[e+1].column-a-1>f+this.nodeMinColumnSpace(s[e+1],!0)?d=a+1:d=a;let m=0,g=0,p=0,y=0,x=0,k=0;if(i<=0){const S=s[e].sourceEdges.iterator;for(;S.next();){const N=S.value,T=N.fromVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const A=T.column;m+=(Math.abs(a+k-(A+x))+1)*y,g+=(Math.abs(u+k-(A+x))+1)*y,p+=(Math.abs(d+k-(A+x))+1)*y}}}if(i>=0){const S=s[e].destinationEdges.iterator;for(;S.next();){const N=S.value,T=N.toVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const A=T.column;m+=(Math.abs(a+x-(A+k))+1)*y,g+=(Math.abs(u+x-(A+k))+1)*y,p+=(Math.abs(d+x-(A+k))+1)*y}}}let b=0,P=0,M=0;const L=o[s[e].index],C=r[s[e].index];L!==-1&&(b+=Math.abs(L-a),P+=Math.abs(L-u),M+=Math.abs(L-d)),C!==-1&&(b+=Math.abs(C-a),P+=Math.abs(C-u),M+=Math.abs(C-d)),g=r[e]?u=p:g<=r[e]&&(u=g)),u!==a&&(l=!0,h=!0,s[e].column=u)}return this.Fh(t,s),this.Ky(),l}uI(){for(let t=0;t<=this.Kt;t++)for(;this.dI(t,1););this.Ky()}dI(t,i){let e=!0;const s=this.network.vertexes.iterator;for(;s.next();){const o=s.value,r=this.nodeMinColumnSpace(o,!0),l=this.nodeMinColumnSpace(o,!1);if(o.column-r<=t&&o.column+l>=t){e=!1;break}}let n=!1;if(e){if(i>0)for(s.reset();s.next();){const o=s.value;o.column>t&&(o.column-=1,n=!0)}if(i<0)for(s.reset();s.next();){const o=s.value;o.column0&&(e=t+1),i<0&&(e=t-1);let s=0;const n=[],o=[];for(s=0;s<=this.Mt;s++)n[s]=!1,o[s]=!1;const r=this.network.vertexes.iterator;for(;r.next();){const a=r.value,c=a.column-this.nodeMinColumnSpace(a,!0),f=a.column+this.nodeMinColumnSpace(a,!1);c<=t&&f>=t&&(n[a.layer]=!0),c<=e&&f>=e&&(o[a.layer]=!0)}let l=!0,h=!1;for(s=0;s<=this.Mt;s++)l=l&&!(n[s]&&o[s]);if(l){if(i>0)for(r.reset();r.next();){const a=r.value;a.column>t&&(a.column-=1,h=!0)}if(i<0)for(r.reset();r.next();){const a=r.value;a.column0)for(i=0;i<=this.Kt;i++)for(e=this.Ji(),s=this.Z1(!0),n=s+1;ss?this.Ze(e):o=0;i--)for(e=this.Ji(),s=this.Z1(!0),n=s+1;ss?this.Ze(e):o0)for(e.reset();e.next();){const c=e.value;c.column-this.nodeMinColumnSpace(c,!0)<=t&&(c.component=this._s)}if(i<0)for(e.reset();e.next();){const c=e.value;c.column+this.nodeMinColumnSpace(c,!1)>=t&&(c.component=this._s)}for(this._s++,e.reset();e.next();){const c=e.value;c.component===-1&&(this.UN(c,this._s,-1,!0,!0),this._s++)}let s=0;const n=[];for(s=0;s0)for(let f=0;f0;f--)o[c*(this.Kt+1)+f]!==-1&&o[c*(this.Kt+1)+f-1]!==-1&&o[c*(this.Kt+1)+f]!==o[c*(this.Kt+1)+f-1]&&(n[o[c*(this.Kt+1)+f]*this._s+o[c*(this.Kt+1)+f-1]]=!0)}const r=[];for(s=0;s0)for(e.reset();e.next();){const c=e.value;r[c.component]&&(c.column-=1,a=!0)}if(i<0)for(e.reset();e.next();){const c=e.value;r[c.component]&&(c.column+=1,a=!0)}return a}cI(){const t=Util.ot(),i=this.Jf.length;for(let u=0;u<=i;u++)t[u]=[];const e=this.network.vertexes.iterator;for(;e.next();){const u=e.value,d=i-u.layer,m=t[d];m[u.index]=u}const s=new GSet;this.pI(t,s);let n=null,o=null,r=null,l=null;const h=(this.vn&1)!==0,a=(this.vn&2)!==0,c=(this.vn&4)!==0,f=(this.vn&8)!==0;h&&(this.sl(t,s,!0),n=this.ik(t,!0,!1)),t.reverse(),c&&(this.sl(t,s,!1),r=this.ik(t,!1,!1));for(const u of t)u.reverse();f&&(this.sl(t,s,!1),l=this.ik(t,!1,!0)),t.reverse(),a&&(this.sl(t,s,!0),o=this.ik(t,!0,!0)),Util.tt(t),this.yI(n,o,r,l),this.network.vertexes.each(u=>{const d=u,m=Util.ot();h&&m.push(n.get(d)),a&&m.push(o.get(d)),c&&m.push(r.get(d)),f&&m.push(l.get(d)),m.sort((k,b)=>k-b);const g=m.length,p=Math.floor((g-1)/2),y=Math.ceil((g-1)/2),x=(m[p]+m[y])/2;Util.tt(m),d.le=x})}pI(t,i){const e=t.length;for(let s=1;sf)&&i.add(m)}o++}n=f}}}}wI(t){if(t.node===null){const i=t.getProperSourceVertexes();if(i.length>0)return i[0].node===null}return!1}sl(t,i,e){this.xI(t);for(const s of t){let n=-1;for(const o of s){const r=e?o.getProperSourceVertexes():o.getProperDestinationVertexes(),l=r.length;if(l>0){r.sort((a,c)=>a.Rh-c.Rh);const h=(l-1)/2;for(let a=Math.floor(h),c=Math.ceil(h);a<=c;a++)if(o.On===o){const f=r[a];let u;e?u=f.getDestinationEdge(o):u=o.getDestinationEdge(f),!i.has(u)&&n0){const c=this.fD(a,t),f=s?c.width:c.height,u=a.Qe.Zf+a.le+a.In-(c.le+c.In+f+this.columnSpacing);c.Qe.Zf=Math.min(c.Qe.Zf,u)}h=a.Rh+1}while(l0){const s=this.fD(e,i),n=s.Za;this.cD(n,i),t.Qe===t&&(t.Qe=n.Qe);const o=this.S===90||this.S===270?s.width:s.height;if(t.Qe===n.Qe){const r=n.le+s.In+o-e.In+this.columnSpacing;t.le=Math.max(t.le,r)}}e=e.On}while(e!==t);for(;e.On!==t;)e=e.On,e.le=t.le,e.Qe=t.Qe}fD(t,i){const e=t.aD,s=t.Rh;return s<1&&Util.o("Could not determine previous vertex in layer"),i[e][s-1]}yI(...t){let i=-1;const e=Util.ot(),s=Util.ot();let n=1/0;for(let o=0;o<4;o++){if(!t[o])continue;const r=this.kI(t[o],e,s,o);r{r.set(h.key,h.value+l)})}Util.tt(e),Util.tt(s)}kI(t,i,e,s){if(!t||t.count===0)return i[s]=0,e[s]=0,1/0;let n=1/0,o=-1/0;return t.each(r=>{const l=r.key,h=r.value,a=this.S===90||this.S===270?l.width:l.height;ho&&(o=h+a)}),i[s]=n,e[s]=o,o-n}commitLayout(){this.zy(),this.commitNodes(),this.zN(),this.isRouting&&this.commitLinks()}zy(){if(!this.setsPortSpots)return;const t=this._1(!0),i=this._1(!1),e=this.network.edges.iterator;for(;e.next();){const n=e.value.link;n!==null&&(n.fromSpot=t,n.toSpot=i)}}_1(t){return this.S===270?t?Spot.MiddleTop:Spot.MiddleBottom:this.S===90?t?Spot.MiddleBottom:Spot.MiddleTop:this.S===180?t?Spot.MiddleLeft:Spot.MiddleRight:t?Spot.MiddleRight:Spot.MiddleLeft}commitNodes(){this.Qs=[],this.Ss=[],this.Ns=[],this.Bt=[];for(let d=0;d<=this.Mt;d++)this.Qs[d]=0,this.Ss[d]=0,this.Ns[d]=0,this.Bt[d]=0;const t=this.network.vertexes.iterator;for(;t.next();){const d=t.value,m=d.layer;this.Qs[m]=Math.max(this.Qs[m],this.nodeMinLayerSpace(d,!0)),this.Ss[m]=Math.max(this.Ss[m],this.nodeMinLayerSpace(d,!1))}let i=0;const e=this.Ps;for(let d=0;d<=this.Mt;d++){let m=e;this.Qs[d]+this.Ss[d]<=0&&(m=0),d>0&&(i+=m/2),this.S===90||this.S===0?(i+=this.Ss[d],this.Ns[d]=i,i+=this.Qs[d]):(i+=this.Qs[d],this.Ns[d]=i,i+=this.Ss[d]),d=0;n--)this.S===270?n===0?e.push(new Rect(0,0,s,Math.abs(this.Bt[0]))):e.push(new Rect(0,this.Bt[n-1],s,Math.abs(this.Bt[n-1]-this.Bt[n]))):this.S===90?n===0?e.push(new Rect(0,this.Bt[0],s,Math.abs(this.Bt[0]-t))):e.push(new Rect(0,this.Bt[n],s,Math.abs(this.Bt[n-1]-this.Bt[n]))):this.S===180?n===0?e.push(new Rect(0,0,Math.abs(this.Bt[0]),s)):e.push(new Rect(this.Bt[n-1],0,Math.abs(this.Bt[n-1]-this.Bt[n]),s)):n===0?e.push(new Rect(this.Bt[0],0,Math.abs(this.Bt[0]-t),s)):e.push(new Rect(this.Bt[n],0,Math.abs(this.Bt[n-1]-this.Bt[n]),s));this.commitLayers(e,this.or)}commitLayers(t,i){}commitLinks(){const t=this.network.edges.iterator;let i;for(;t.next();)i=t.value.link,i!==null&&(i.startRoute(),i.clearPoints(),i.commitRoute());for(t.reset();t.next();)i=t.value.link,i!==null&&i.updateRoute();for(t.reset();t.next();){const e=t.value;if(i=e.link,i===null||i.pointsCount===0)continue;i.startRoute();const s=i;let n=s.fromNode,o=s.toNode,r=s.fromPort,l=s.toPort;if(n!==null){const N=n.findVisibleNode();N!==null&&N!==n&&(n=N,r=N.port)}if(o!==null){const N=o.findVisibleNode();N!==null&&N!==o&&(o=N,l=N.port)}const h=i.computeSpot(!0,r),a=i.computeSpot(!1,l);let c=e.fromVertex,f=e.toVertex;if(e.valid){if(i.curve===9&&i.pointsCount===4)if(c.column===f.column&&this.alignOption===0){const N=i.getLinkPoint(n,r,h,!0,!1,o,l),T=i.getLinkPoint(o,l,a,!1,!1,n,r);N.isReal()||N.set(n.actualBounds.center),T.isReal()||T.set(o.actualBounds.center),i.clearPoints(),i.addPointAt(N.x,N.y),i.addPointAt((2*N.x+T.x)/3,(2*N.y+T.y)/3),i.addPointAt((N.x+2*T.x)/3,(N.y+2*T.y)/3),i.addPointAt(T.x,T.y)}else{let N=!1,T=!1;if(r!==null&&h===Spot.None&&(N=!0),l!==null&&a===Spot.None&&(T=!0),N||T){let A=null;N&&(A=i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0),A.isReal()||A.set(n.actualBounds.center),i.setPointAt(0,A.x,A.y));let D=null;if(T&&(D=i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(0),!1),D.isReal()||D.set(o.actualBounds.center),i.setPointAt(3,D.x,D.y)),A){const F=i.getPoint(2);i.setPointAt(1,(A.x*2+F.x)/3,(A.y*2+F.y)/3)}if(D){const F=i.getPoint(1);i.setPointAt(2,(D.x*2+F.x)/3,(D.y*2+F.y)/3)}}}i.commitRoute();continue}if(c.layer===f.layer){i.commitRoute();continue}let u=!1,d=!1;const m=this.Ps;let g=0,p=i.firstPickIndex+1;if(i.isOrthogonal)d=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3);else if(i.curve===9)u=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3),g===4&&(p=2);else{g=i.pointsCount;const N=h===Spot.None,T=a===Spot.None;g>2&&N&&T?i.points.removeRange(1,g-2):g>3&&N&&!T?i.points.removeRange(1,g-3):g>3&&!N&&T?i.points.removeRange(2,g-2):g>4&&!N&&!T&&i.points.removeRange(2,g-3)}let y,x,k=0,b=0,P=0,M=0,L=0,C=0,S=0;if(e.rev){let N=0;for(;f!==null&&c!==f;){y=null,x=null;const T=f.sourceEdges.iterator;for(;T.next();){const A=T.value;if(A.link===e.link&&(y=A.fromVertex,x=A.toVertex,y.node===null))break}if(y===null)break;if(y!==c)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=y.centerX,M=y.centerY,d)this.S===180||this.S===0?p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,k,M)):(x!==null?x.centerY:b)!==M&&(L=this.Bt[y.layer-1]+this.or.x,i.insertPointAt(p++,L,b),i.insertPointAt(p++,L,M)):p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,P,b)):(x!==null?x.centerX:k)!==P&&(L=this.Bt[y.layer-1]+this.or.y,i.insertPointAt(p++,k,L),i.insertPointAt(p++,P,L));else if(p===i.firstPickIndex+1)if(C=Math.max(10,this.Qs[f.layer]),S=Math.max(10,this.Ss[f.layer]),u)this.S===180?P<=f.bounds.x?(N=f.bounds.x,i.insertPointAt(p++,N-C,M),i.insertPointAt(p++,N,M),i.insertPointAt(p++,N+S,M)):(i.insertPointAt(p++,P-C,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P+S,M)):this.S===90?M>=f.bounds.bottom?(N=f.bounds.y+f.bounds.height,i.insertPointAt(p++,P,N+S),i.insertPointAt(p++,P,N),i.insertPointAt(p++,P,N-C)):(i.insertPointAt(p++,P,M+S),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M-C)):this.S===270?M<=f.bounds.y?(N=f.bounds.y,i.insertPointAt(p++,P,N-C),i.insertPointAt(p++,P,N),i.insertPointAt(p++,P,N+S)):(i.insertPointAt(p++,P,M-C),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M+S)):this.S===0&&(P>=f.bounds.right?(N=f.bounds.x+f.bounds.width,i.insertPointAt(p++,N+S,M),i.insertPointAt(p++,N,M),i.insertPointAt(p++,N-C,M)):(i.insertPointAt(p++,P+S,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P-C,M)));else{i.insertPointAt(p++,k,b);let A=0;this.S===180||this.S===0?((this.S===180?P>=f.bounds.right:P<=f.bounds.x)&&(A=(this.S===0?-C:S)/2),i.insertPointAt(p++,k+A,M)):((this.S===270?M>=f.bounds.bottom:M<=f.bounds.y)&&(A=(this.S===90?-C:S)/2),i.insertPointAt(p++,P,b+A)),i.insertPointAt(p++,P,M)}else C=Math.max(10,this.Qs[y.layer]),S=Math.max(10,this.Ss[y.layer]),u?this.S===180?(i.insertPointAt(p++,P-C-m,M),i.insertPointAt(p++,Math.min(P-C+m/2,P),M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,Math.max(P+S-m/2,P),M),i.insertPointAt(p++,P+S+m,M)):this.S===90?(i.insertPointAt(p++,P,M+S+m),i.insertPointAt(p++,P,Math.max(M+S-m/2,M)),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,Math.min(M-C+m/2,M)),i.insertPointAt(p++,P,M-C-m)):this.S===270?(i.insertPointAt(p++,P,M-C-m),i.insertPointAt(p++,P,Math.min(M-C+m/2,M)),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,Math.max(M+S-m/2,M)),i.insertPointAt(p++,P,M+S+m)):(i.insertPointAt(p++,P+S+m,M),i.insertPointAt(p++,Math.max(P+S-m/2,P),M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,Math.min(P-C+m/2,P),M),i.insertPointAt(p++,P-C-m,M)):(this.S===180||this.S===90||this.S,i.insertPointAt(p++,P,M));f=y}if(l===null||h!==Spot.None||d)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=i.getPoint(p).x,M=i.getPoint(p).y,d){const T=this.Ss[c.layer];let A=0;this.S===180||this.S===0?(A=b,A>=c.bounds.y&&A<=c.bounds.bottom&&(this.S===180?P>=c.bounds.x:P<=c.bounds.right)&&(N=c.centerX+(this.S===180?-T:T),A=c.bounds.x&&A<=c.bounds.right&&(this.S===270?M>=c.bounds.y:M<=c.bounds.bottom)&&(N=c.centerY+(this.S===270?-T:T),A=c.bounds.x?(N=c.bounds.x+c.bounds.width,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N+S,b)):this.S===90&&M<=c.bounds.bottom?(N=c.bounds.y,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N-C)):this.S===270&&M>=c.bounds.y?(N=c.bounds.y+c.bounds.height,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N+S)):this.S===0&&P<=c.bounds.right&&(N=c.bounds.x,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N-C,b));else{C=Math.max(10,this.Qs[c.layer]),S=Math.max(10,this.Ss[c.layer]);let T=0;this.S===180||this.S===0?((this.S===180?P<=c.bounds.x:P>=c.bounds.right)&&(T=(this.S===0?S:-C)/2),i.insertPointAt(p++,P+T,b)):((this.S===270?M<=c.bounds.y:M>=c.bounds.bottom)&&(T=(this.S===90?S:-C)/2),i.insertPointAt(p++,k,M+T)),i.insertPointAt(p++,P,M)}}else{for(;c!==null&&c!==f;){y=null,x=null;const N=c.destinationEdges.iterator;for(;N.next();){const T=N.value;if(T.link===e.link&&(y=T.toVertex,x=T.fromVertex,x.node!==null&&(x=null),y.node===null))break}if(y===null)break;y!==f&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=y.centerX,M=y.centerY,d?this.S===180||this.S===0?(x!==null?x.centerY:b)!==M&&(L=this.Bt[y.layer]+this.or.x,p===i.firstPickIndex+1&&(this.S===0?L=Math.max(L,k):L=Math.min(L,k)),i.insertPointAt(p++,L,b),i.insertPointAt(p++,L,M)):(x!==null?x.centerX:k)!==P&&(L=this.Bt[y.layer]+this.or.y,p===i.firstPickIndex+1&&(this.S===90?L=Math.max(L,b):L=Math.min(L,b)),i.insertPointAt(p++,k,L),i.insertPointAt(p++,P,L)):(C=Math.max(10,this.Qs[y.layer]),S=Math.max(10,this.Ss[y.layer]),u?this.S===180?(i.insertPointAt(p++,P+S+m,M),i.insertPointAt(p++,Math.max(P+S-m/2,P),M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,Math.min(P-C+m/2,P),M),i.insertPointAt(p++,P-C-m,M)):this.S===90?(i.insertPointAt(p++,P,M-C-m),i.insertPointAt(p++,P,Math.min(M-C+m/2,M)),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,Math.max(M+S-m/2,M)),i.insertPointAt(p++,P,M+S+m)):this.S===270?(i.insertPointAt(p++,P,M+S+m),i.insertPointAt(p++,P,Math.max(M+S-m/2,M)),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,Math.min(M-C+m/2,M)),i.insertPointAt(p++,P,M-C-m)):(i.insertPointAt(p++,P-C-m,M),i.insertPointAt(p++,Math.min(P-C+m/2,P),M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,Math.max(P+S-m/2,P),M),i.insertPointAt(p++,P+S+m,M)):this.S===180?(i.insertPointAt(p++,P+S,M),i.insertPointAt(p++,P-C,M)):this.S===90?(i.insertPointAt(p++,P,M-C),i.insertPointAt(p++,P,M+S)):this.S===270?(i.insertPointAt(p++,P,M+S),i.insertPointAt(p++,P,M-C)):(i.insertPointAt(p++,P-C,M),i.insertPointAt(p++,P+S,M)))),c=y}d&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=i.getPoint(p).x,M=i.getPoint(p).y,this.S===180||this.S===0?b!==M&&(this.S===0?L=Math.min(Math.max((P+k)/2,this.Bt[f.layer]+this.or.x),P):L=Math.max(Math.min((P+k)/2,this.Bt[f.layer]+this.or.x),P),i.insertPointAt(p++,L,b),i.insertPointAt(p++,L,M)):k!==P&&(this.S===90?L=Math.min(Math.max((M+b)/2,this.Bt[f.layer]+this.or.y),M):L=Math.max(Math.min((M+b)/2,this.Bt[f.layer]+this.or.y),M),i.insertPointAt(p++,k,L),i.insertPointAt(p++,P,L)))}if(s!==null&&u&&i.pointsCount>=4){if(r!==null){const N=h===Spot.None?i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0):i.getPoint(0);if(h===Spot.None){const T=i.getPoint(2),A=i.getPoint(3);this.direction===90||this.direction===270?(i.setPointAt(1,(N.x+T.x)/2,T.y),i.setPointAt(2,A.x,(T.y+A.y)/2)):(i.setPointAt(1,T.x,(N.y+T.y)/2),i.setPointAt(2,(T.x+A.x)/2,A.y))}N.isReal()||N.set(n.actualBounds.center),i.setPointAt(0,N.x,N.y)}if(l!==null){const N=a===Spot.None?i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(i.pointsCount-4),!1):i.getPoint(i.pointsCount-1);if(a===Spot.None){const T=i.getPoint(i.pointsCount-3),A=i.getPoint(i.pointsCount-4);this.direction===90||this.direction===270?(i.setPointAt(i.pointsCount-2,(N.x+T.x)/2,T.y),i.setPointAt(i.pointsCount-2,A.x,(T.y+A.y)/2)):(i.setPointAt(i.pointsCount-2,T.x,(N.y+T.y)/2),i.setPointAt(i.pointsCount-3,(T.x+A.x)/2,A.y))}N.isReal()||N.set(o.actualBounds.center),i.setPointAt(i.pointsCount-1,N.x,N.y)}}i.commitRoute(),e.commit()}}GO(){this.Xy=-1,this.Lg=0,this.Ms=0,this.$a=null,this.Tg=null,this.Jf=null;for(let t=0;t=this.Rn.length){const n=[];for(let o=0;o=0&&(this.Ps=t,this.invalidateLayout()))}get columnSpacing(){return this.Wi}set columnSpacing(t){this.Wi!==t&&(Util.i(t,"number",LayeredDigraphLayout,"columnSpacing"),t>0&&(this.Wi=t,this.invalidateLayout()))}get direction(){return this.S}set direction(t){this.S!==t&&(Util.i(t,"number",LayeredDigraphLayout,"direction"),t===0||t===90||t===180||t===270?(this.S=t,this.invalidateLayout()):Util.o("LayeredDigraphLayout.direction must be 0, 90, 180, or 270"))}get cycleRemoveOption(){return this.Gf}set cycleRemoveOption(t){this.Gf!==t&&(t===1||t===0||t===2)&&(this.Gf=t,this.invalidateLayout())}get layeringOption(){return this.jf}set layeringOption(t){this.jf!==t&&(t===10||t===11||t===12)&&(this.jf=t,this.invalidateLayout())}get initializeOption(){return this.Hf}set initializeOption(t){this.Hf!==t&&(t===20||t===21||t===22)&&(this.Hf=t,this.invalidateLayout())}get iterations(){return this.Ja}set iterations(t){this.Ja!==t&&t>=0&&(this.Ja=t,this.invalidateLayout())}get aggressiveOption(){return this.qf}set aggressiveOption(t){this.qf!==t&&(t===30||t===31||t===32)&&(this.qf=t,this.invalidateLayout())}get packOption(){return this.nr}set packOption(t){this.nr!==t&&(Util.i(t,"number",LayeredDigraphLayout,"packOption"),t>=0&&t<8&&(this.nr=t,this.invalidateLayout()))}get packIterations(){return this.Wf}set packIterations(t){this.Wf=t}get alignOption(){return this.vn}set alignOption(t){this.vn!==t&&(Util.i(t,"number",LayeredDigraphLayout,"align"),t>=0&&t<16&&(this.vn=t,this.invalidateLayout()))}get setsPortSpots(){return this.Fn}set setsPortSpots(t){this.Fn!==t&&(Util.i(t,"boolean",LayeredDigraphLayout,"setsPortSpots"),this.Fn=t,this.invalidateLayout())}get maxLayer(){return this.Mt}get maxIndex(){return this.Xy}get maxColumn(){return this.Kt}get minIndexLayer(){return this.Lg}get maxIndexLayer(){return this.Ms}static CycleDepthFirst=0;static CycleGreedy=1;static CycleFromLayers=2;static LayerOptimalLinkLength=10;static LayerLongestPathSink=11;static LayerLongestPathSource=12;static InitDepthFirstOut=20;static InitDepthFirstIn=21;static InitNaive=22;static AggressiveNone=30;static AggressiveLess=31;static AggressiveMore=32;static PackNone=0;static PackExpand=1;static PackStraighten=2;static PackMedian=4;static PackAll=15;static AlignNone=0;static AlignUpperLeft=1;static AlignUpperRight=2;static AlignLowerLeft=4;static AlignLowerRight=8;static AlignAll=15}class LayeredDigraphNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new LayeredDigraphVertex(this)}createEdge(){return new LayeredDigraphEdge(this)}}class LayeredDigraphVertex extends LayoutVertex{Wo;Bo;Dt;ek;sk;$i;$f;jn;Q1;J1;$1;Za;On;aD;Rh;Qe;Zf;le;In;jy=null;Hy=null;qy=null;Wy=null;constructor(t){super(t),this.Wo=-1,this.Bo=-1,this.Dt=-1,this.ek=NaN,this.sk=null,this.$i=!1,this.$f=NaN,this.jn=NaN,this.Q1=0,this.J1=null,this.$1=null}static uD(t,i){return t.index-i.index}getProperSourceEdges(){if(!this.qy){const t=[];for(const i of this.po){const e=i;e.valid&&t.push(e)}this.qy=t}return this.qy}getProperDestinationEdges(){if(!this.Wy){const t=[];for(const i of this.ir){const e=i;e.valid&&t.push(e)}this.Wy=t}return this.Wy}getDestinationEdge(t){const i=this.getProperDestinationEdges();for(const e of i)if(e.toVertex===t)return e;Util.o("Unable to find destination edge to given vertex")}getProperSourceVertexes(){if(!this.jy){const t=[];for(const i of this.po){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.fromVertex)}t.sort(LayeredDigraphVertex.uD),this.jy=t}return this.jy}getProperDestinationVertexes(){if(!this.Hy){const t=[];for(const i of this.ir){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.toVertex)}t.sort(LayeredDigraphVertex.uD),this.Hy=t}return this.Hy}addSourceEdge(t){super.addSourceEdge(t),this.jy=null,this.qy=null}deleteSourceEdge(t){super.deleteSourceEdge(t),this.jy=null,this.qy=null}addDestinationEdge(t){super.addDestinationEdge(t),this.Hy=null,this.Wy=null}deleteDestinationEdge(t){super.deleteDestinationEdge(t),this.Hy=null,this.Wy=null}get layer(){return this.Wo}set layer(t){this.Wo!==t&&(Util.i(t,"number",LayeredDigraphVertex,"layer"),this.Wo=t)}get column(){return this.Bo}set column(t){this.Bo!==t&&(Util.i(t,"number",LayeredDigraphVertex,"column"),this.Bo=t)}get index(){return this.Dt}set index(t){this.Dt!==t&&(Util.i(t,"number",LayeredDigraphVertex,"index"),this.Dt=t)}get component(){return this.ek}set component(t){this.ek!==t&&(Util.i(t,"number",LayeredDigraphVertex,"component"),this.ek=t)}get near(){return this.sk}set near(t){this.sk!==t&&(this.sk=t)}}class LayeredDigraphEdge extends LayoutEdge{$i;nk;ok;rk;lk;hk;ak;constructor(t){super(t),this.$i=!1,this.nk=!1,this.ok=!1,this.rk=NaN,this.lk=NaN,this.hk=0,this.ak=0}get fromVertex(){return this.We}set fromVertex(t){this.We!==t&&(this.We=t)}get toVertex(){return this.Je}set toVertex(t){this.Je!==t&&(this.Je=t)}get valid(){return this.$i}set valid(t){this.$i!==t&&(Util.i(t,"boolean",LayeredDigraphEdge,"valid"),this.$i=t)}get rev(){return this.nk}set rev(t){this.nk!==t&&(Util.i(t,"boolean",LayeredDigraphEdge,"rev"),this.nk=t)}get forest(){return this.ok}set forest(t){this.ok!==t&&(Util.i(t,"boolean",LayeredDigraphEdge,"forest"),this.ok=t)}get portFromPos(){return this.rk}set portFromPos(t){this.rk!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portFromPos"),this.rk=t)}get portToPos(){return this.lk}set portToPos(t){this.lk!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portToPos"),this.lk=t)}get portFromColOffset(){return this.hk}set portFromColOffset(t){this.hk!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portFromColOffset"),this.hk=t)}get portToColOffset(){return this.ak}set portToColOffset(t){this.ak!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portToColOffset"),this.ak=t)}}var TreePath=(w=>(w[w.Default=0]="Default",w[w.Destination=1]="Destination",w[w.Source=2]="Source",w))(TreePath||{}),TreeSorting=(w=>(w[w.Forwards=10]="Forwards",w[w.Reverse=11]="Reverse",w[w.Ascending=12]="Ascending",w[w.Descending=13]="Descending",w))(TreeSorting||{}),TreeAlignment=(w=>(w[w.CenterSubtrees=20]="CenterSubtrees",w[w.CenterChildren=21]="CenterChildren",w[w.Start=22]="Start",w[w.End=23]="End",w[w.Bus=24]="Bus",w[w.BusBranching=25]="BusBranching",w[w.TopLeftBus=26]="TopLeftBus",w[w.BottomRightBus=27]="BottomRightBus",w[w.Custom=28]="Custom",w))(TreeAlignment||{}),TreeCompaction=(w=>(w[w.None=30]="None",w[w.Block=31]="Block",w))(TreeCompaction||{}),TreeStyle=(w=>(w[w.Layered=40]="Layered",w[w.LastParents=41]="LastParents",w[w.Alternating=42]="Alternating",w[w.RootOnly=43]="RootOnly",w))(TreeStyle||{}),TreeArrangement=(w=>(w[w.Vertical=50]="Vertical",w[w.Horizontal=51]="Horizontal",w[w.FixedRoots=52]="FixedRoots",w))(TreeArrangement||{}),TreeLayerStyle=(w=>(w[w.Individual=60]="Individual",w[w.Siblings=61]="Siblings",w[w.Uniform=62]="Uniform",w))(TreeLayerStyle||{});class TreeLayout extends Layout{Fi;Ti;Qf;Fg;XN;Re;zi;ks;V;z;ck;hs;constructor(t){super(),this.Fi=new GSet,this.Ti=0,this.hs=1,this.Qf=40,this.Fg=60,this.XN=[],this.Re=!0,this.zi=50,this.ks=new Size(10,10).g();const i=new TreeNetwork(this);this.V=new TreeVertex(i),this.z=new TreeVertex(i),this.ck=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Ti=this.Ti,t.Qf=this.Qf,t.Fg=this.Fg,t.Re=this.Re,t.zi=this.zi,t.ks.a(this.ks),t.V.copyInheritedPropertiesFrom(this.V),t.z.copyInheritedPropertiesFrom(this.z)}ri(t){t in TreeAlignment?this.alignment=t:t in TreeArrangement?this.arrangement=t:t in TreeCompaction?this.compaction=t:t in TreePath?this.path=t:t in TreeSorting?this.sorting=t:t in TreeStyle?this.treeStyle=t:super.ri(t)}createNetwork(){return new TreeNetwork(this)}makeNetwork(t){const i=this.createNetwork(),e=s=>{if(s instanceof Node)return!s.isLinkLabel&&s.category!=="Comment";if(s instanceof Link){const n=s.fromNode;if(n===null||n.isLinkLabel||n.category==="Comment")return!1;const o=s.toNode;return!(o===null||o.isLinkLabel||o.category==="Comment")}return!1};return t instanceof Diagram?(i.addParts(t.nodes,!0,e),i.addParts(t.links,!0,e)):t instanceof Group?i.addParts(t.memberParts,!1,e):i.addParts(t.iterator,!1,e),i}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangement!==52&&(this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin));let i=this.diagram;i===null&&t instanceof Diagram&&(i=t),this.path===0&&i!==null?this.hs=i.isTreePathToChildren?1:2:this.hs=this.path===0?1:this.path,this.network.vertexes.count>0&&(this.LI(),this.AI(),this.TI(),this.DI(),this.ON(),this.FI(),this.arrangeTrees(),this.updateParts()),this.network=null,this.Fi=new GSet,this.isValidLayout=!0}LI(){this.network.deleteSelfEdges();const t=this.network.vertexes.iterator;for(;t.next();){const n=t.value;n.initialized=!1,n.level=0,n.parent=null,n.children=[]}if(this.Fi.count>0){const n=new GSet,o=this.Fi.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=this.network.findVertex(r);l!==null&&n.add(l)}else r instanceof TreeVertex&&n.add(r)}this.Fi=n}this.Fi.count===0&&this.findRoots();const i=this.Fi.copy().iterator;for(;i.next();){const n=i.value;n.initialized||(n.initialized=!0,this.KN(n))}let e=this.network.vertexes,s=null;for(;s=this.RI(e),s.count>0;){const n=this.dD(s);n!==null&&this.Fi.add(n),n.initialized=!0,this.KN(n),e=s}}RI(t){const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;s.initialized||i.add(s)}return i}findRoots(){const t=this.network.vertexes,i=t.iterator;for(;i.next();){const e=i.value;switch(this.hs){case 1:e.sourceEdges.count===0&&this.Fi.add(e);break;case 2:e.destinationEdges.count===0&&this.Fi.add(e);break;default:Util.o("Unhandled path value "+this.hs.toString())}}if(this.Fi.count===0){const e=this.dD(t);e!==null&&this.Fi.add(e)}}dD(t){let i=999999,e=null;const s=t.iterator;for(;s.next();){const n=s.value;switch(this.hs){case 1:n.sourceEdges.count0){const s=new List,n=t.destinationVertexes;for(;n.next();){const o=n.value;this.gD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;case 2:if(t.sourceEdges.count>0){const s=new List,n=t.sourceVertexes;for(;n.next();){const o=n.value;this.gD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;default:Util.o("Unhandled path value"+this.hs.toString())}const i=t.children,e=i.length;for(let s=0;st.level?!1:(this.OI(i.parent,i),!0):!0}vI(t,i){if(i===null)return!1;let e=i.parent;for(;e!==null&&e!==t;)e=e.parent;return e===t}OI(t,i){if(t===null||i===null)return;const e=t.children;let s=0;for(let n=0;n0){const n=new Array(e.length-s);let o=0;for(let r=0;r0?s+1:0}II(t){switch(this.Qf){default:case 40:return t.parent!==null?t.parent:this.V;case 43:return t.parent===null?this.V:t.parent.parent===null?this.z:t.parent;case 42:return t.parent!==null?t.parent.parent!==null?t.parent.parent:this.z:this.V;case 41:{let i=!0;if(t.childrenCount===0)i=!1;else{const e=t.children,s=e.length;for(let n=0;n0){i=!1;break}}return i&&t.parent!==null?this.z:t.parent!==null?t.parent:this.V}}}initializeTreeVertexValues(t){const i=this.II(t);if(t.copyInheritedPropertiesFrom(i),t.parent!==null&&t.parent.alignment===25){let e=t.angle;const s=t.parent.children;let n=0;for(;n135&&!l||a&&f)if(t.commentMargin>=0){g.e(t.bounds.x-t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleLeft,P.toSpot=Spot.MiddleRight}}else{g.e(t.bounds.x+t.focus.x*2-t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleRight,P.toSpot=Spot.MiddleLeft}}else if(t.commentMargin>=0){g.e(t.bounds.x+t.focus.x*2+t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleRight,P.toSpot=Spot.MiddleLeft}}else{g.e(t.bounds.x+t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleLeft,P.toSpot=Spot.MiddleRight}}t.commentSpacing>=0?u+=k.height+t.commentSpacing:u+=t.commentSpacing-k.height}else{if(o>135&&!l||!a&&f)if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y-t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleTop,P.toSpot=Spot.MiddleBottom}}else{g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2-t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleBottom,P.toSpot=Spot.MiddleTop}}else if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2+t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleBottom,P.toSpot=Spot.MiddleTop}}else{g.e(t.bounds.x+u,t.bounds.y+t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleTop,P.toSpot=Spot.MiddleBottom}}t.commentSpacing>=0?u+=k.width+t.commentSpacing:u+=t.commentSpacing-k.width}}Point.s(g);const p=u-t.commentSpacing-(h?e.height:e.width);if(this.hs===1){const y=t.destinationEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.fromEndSegmentLength=p>0?p:NaN)}}else{const y=t.sourceEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.toEndSegmentLength=p>0?p:NaN)}}}}FI(){if(this.layerStyle===62){const i=[];let e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;let n=s.parent;n===null&&(n=s);const o=n.angle===0||n.angle===180;let r=i[s.level];r===void 0&&(r=0),i[s.level]=Math.max(r,o?s.width:s.height)}for(let s=0;s=0)for(let o=0;o135&&n.reverse(),this.Jy(r))if(o>1)for(let R=0;R0&&S>0&&M+u+O.width>c&&(M135?-b-g:b+g);const U=S===0?m:u;this.fk(v,0,L),v.U.e(M+U,L),k=Math.max(k,M+U+O.width),b=Math.max(b,P+(C===0?0:g)+O.height),M+=U+O.width}else{c>0&&S>0&&L+u+O.height>c&&(L135?-k-g:k+g);const U=S===0?m:u;this.fk(v,M,0),v.U.e(M,L+U),b=Math.max(b,L+U+O.height),k=Math.max(k,P+(C===0?0:g)+O.width),L+=U+O.height}S++}C>0&&(e?(b+=Math.max(0,f),M0&&(h||this.iu(t,p,0,0,o-1),k+=p)):(k+=Math.max(0,f),L0&&(h||this.iu(t,0,p,0,o-1),b+=p)));let D=0,F=0;switch(r){case 20:e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;break;default:case 21:if(C>0)e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;else{const v=o;if(e){const O=n[0].U.x+n[0].et.x,U=n[v-1].U.x+n[v-1].et.x+n[v-1].focus.x*2;D+=O+(U-O)/2-t.focus.x-d/2}else{const O=n[0].U.y+n[0].et.y,U=n[v-1].U.y+n[v-1].et.y+n[v-1].focus.y*2;F+=O+(U-O)/2-t.focus.y-d/2}}break;case 22:e?(D-=d,k+=d):(F-=d,b+=d);break;case 23:e?(D+=k-t.width+d,k+=d):(F+=b-t.height+d,b+=d);break;case 24:case 25:e?o>1?D+=T+u/2-t.focus.x:D+=n[0].focus.x-t.focus.x+n[0].et.x:o>1?F+=T+u/2-t.focus.y:F+=n[0].focus.y-t.focus.y+n[0].et.y;break;case 26:e?D+=k+u/2-t.focus.x:F+=b+u/2-t.focus.y;break;case 27:break;case 28:const R=this.customAlignment(t,D,F,k,b);D=R[0],F=R[1],k=R[2],b=R[3];break}for(let R=0;R135?(a?-b:-v.mt.height)+v.et.y-f:x+f+v.et.y)):v.U.e(v.U.x+(i>135?(a?-k:-v.mt.width)+v.et.x-f:y+f+v.et.x),v.U.y+v.et.y-F)}e?(k=this.GN(t,k,D),D<0&&(D=0),i>135&&(F+=b+f),b=Math.max(Math.max(b,x),b+x+f)):(i>135&&(D+=k+f),k=Math.max(Math.max(k,y),k+y+f),b=this.jN(t,b,F),F<0&&(F=0)),t.et.e(D,F),t.mt.e(k,b)}customAlignment(t,i,e,s,n){return[i,e,s,n]}xD(t,i,e,s,n,o){const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.mt.width,o=p.mt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,c=this.orthoAngle(t)===90;let f=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.mt,k=f===0?0:h;if(c){const b=this.computeBusNodeSpacing(y)-l;y.U.e(e-(x.width+b),d+k),n=Math.max(n,x.width+b),o=Math.max(o,d+k+x.height),d+=k+x.height}else{const b=this.computeBusNodeSpacing(y)-l;y.U.e(u+k,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,u+k+x.width),u+=k+x.width}f++}f=0;const m=u,g=d;c?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.mt,x=this.computeBusLastRowSpacing(p,c?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(c){p.U.e(e+l/2-p.focus.x-p.et.x,o+x);const k=e+l/2-p.focus.x-p.et.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.max(g,d)+x+y.height),p.U.x<0&&(e=this.uk(t,p.U.x,!1,e,l))}else{p.U.e(n+x,e+l/2-p.focus.y-p.et.y),n=Math.max(n,Math.max(m,u)+x+y.width);const k=e+l/2-p.focus.y-p.et.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.U.y<0&&(e=this.uk(t,p.U.y,!0,e,l))}}return new Rect(e,0,n,o)}bD(t,i,e,s,n,o){const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.mt.width,o=p.mt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,c=this.orthoAngle(t)===270;let f=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.mt,k=f===0?0:h;if(c){const b=this.computeBusNodeSpacing(y)-l;d-=k+x.height,y.U.e(e-(x.width+b),d),n=Math.max(n,x.width+b),o=Math.max(o,Math.abs(d))}else{const b=this.computeBusNodeSpacing(y)-l;u-=k+x.width,y.U.e(u,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,Math.abs(u))}f++}f=0;const m=u,g=d;c?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.mt,x=this.computeBusLastRowSpacing(p,c?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(c){p.U.e(e+l/2-p.focus.x-p.et.x,-o-y.height-x);const k=e+l/2-p.focus.x-p.et.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.abs(Math.min(g,d))+x+y.height),p.U.x<0&&(e=this.uk(t,p.U.x,!1,e,l))}else{p.U.e(-n-y.width-x,e+l/2-p.focus.y-p.et.y),n=Math.max(n,Math.abs(Math.min(m,u))+x+y.width);const k=e+l/2-p.focus.y-p.et.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.U.y<0&&(e=this.uk(t,p.U.y,!0,e,l))}}for(let p=0;ps&&(s=e+t.width),e<0&&(s-=e),s;case 22:return t.width>i?t.width:i;case 23:return t.focus.x*2>i?t.width:i+t.width-t.focus.x*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.width);return Math.max(t.width,o-n);case 26:return t.width-t.focus.x+t.nodeSpacing/2+i;case 27:return Math.max(t.width,t.focus.x+t.nodeSpacing/2+i);default:return i}}jN(t,i,e){switch(t.alignment){case 21:case 20:let s=i;return e+t.height>s&&(s=e+t.height),e<0&&(s-=e),s;case 22:return t.height>i?t.height:i;case 23:return t.focus.y*2>i?t.height:i+t.height-t.focus.y*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.height);return Math.max(t.height,o-n);case 26:return t.height-t.focus.y+t.nodeSpacing/2+i;case 27:return Math.max(t.height,t.focus.y+t.nodeSpacing/2+i);default:return i}}HN(t,i,e){switch(t){case 20:i/=2,e/=2;break;case 21:i/=2,e/=2;break;case 22:i=0,e=0;break;case 23:break;default:Util.o("Unhandled alignment value "+t.toString())}return new Point(i,e)}Qa(t,i,e,s,n,o){const r=this.HN(i,e,s);this.iu(t,r.x,r.y,n,o)}iu(t,i,e,s,n){if(i===0&&e===0)return;const o=t.children;for(let r=s;r<=n;r++){const h=o[r].U;h.x+=i,h.y+=e}}fk(t,i,e){const s=t.parent;switch(this.hs){case 1:{const n=t.sourceEdges;for(;n.next();){const o=n.value;o.fromVertex===s&&o.relativePoint.e(i,e)}break}case 2:{const n=t.destinationEdges;for(;n.next();){const o=n.value;o.toVertex===s&&o.relativePoint.e(i,e)}break}default:Util.o("Unhandled path value "+this.hs.toString())}}EI(t){if(t.childrenCount===0){const B=t.parent;let Y=!1,G=0,H=21;B!==null&&(G=B.angle,H=B.alignment,Y=this.isBusAlignment(H));const J=this.YN(t);t.U.e(0,0),t.mt.e(t.width,t.height),t.parent!==null&&t.comments!==null&&((G===180||G===270)&&!Y||J)?G===180&&!Y||(G===90||G===270)&&J?t.et.e(t.width-t.focus.x*2,0):t.et.e(0,t.height-t.focus.y*2):t.et.e(0,0),t.Rg=null,t.vg=null;return}const i=this.orthoAngle(t),e=i===90||i===270;let s=0;const n=t.children,o=n.length;for(let B=0;B135&&n.reverse(),this.Jy(r))if(o>1)for(let B=0;B0&&A>0&&S+u+G.width>c&&(S135?-k-m:k+m),this.fk(Y,0,N);let H=0;if(A===0)P=Y.Rg,M=Y.vg,L=G.width,C=G.height,(P===null||M===null||i!==this.orthoAngle(Y))&&(P=this.he(2),M=this.he(2),P[0].e(0,0),P[1].e(0,C),M[0].e(L,0),M[1].e(L,C));else{const J=Util.ot(),z=this.kD(t,Y,P,M,L,C,J);H=z.x,P=J[0],M=J[1],L=z.width,C=z.height,Util.tt(J),S0&&A>0&&N+u+G.height>c&&(N135?-x-m:x+m),this.fk(Y,S,0);let H=0;if(A===0)P=Y.Rg,M=Y.vg,L=G.width,C=G.height,(P===null||M===null||i!==this.orthoAngle(Y))&&(P=this.he(2),M=this.he(2),P[0].e(0,0),P[1].e(L,0),M[0].e(0,C),M[1].e(L,C));else{const J=Util.ot(),z=this.kD(t,Y,P,M,L,C,J);H=z.x,P=J[0],M=J[1],L=z.width,C=z.height,Util.tt(J),N0&&(e?(k+=Math.max(0,f),S0&&(h||this.iu(t,g,0,0,o-1),x+=g)):(x+=Math.max(0,f),N0&&(h||this.iu(t,0,g,0,o-1),k+=g)));let v=0,O=0;switch(r){case 20:e?v+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;break;default:case 21:if(T>0)e?v+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;else{const Y=o;if(e){const G=n[0].U.x+n[0].et.x,H=n[Y-1].U.x+n[Y-1].et.x+n[Y-1].focus.x*2;v+=G+(H-G)/2-t.focus.x-d/2}else{const G=n[0].U.y+n[0].et.y,H=n[Y-1].U.y+n[Y-1].et.y+n[Y-1].focus.y*2;O+=G+(H-G)/2-t.focus.y-d/2}}break;case 22:e?(v-=d,x+=d):(O-=d,k+=d);break;case 23:e?(v+=x-t.width+d,x+=d):(O+=k-t.height+d,k+=d);break;case 24:e?o>1?v+=F+u/2-t.focus.x:v+=n[0].focus.x-t.focus.x+n[0].et.x:o>1?O+=F+u/2-t.focus.y:O+=n[0].focus.y-t.focus.y+n[0].et.y;break;case 26:e?v+=x+u/2-t.focus.x:O+=k+u/2-t.focus.y;break;case 27:break;case 28:const B=this.customAlignment(t,v,O,x,k);v=B[0],O=B[1],x=B[2],k=B[3];break}for(let B=0;B135?(a?-k:-Y.mt.height)+Y.et.y-f:y+f+Y.et.y)):Y.U.e(Y.U.x+(i>135?(a?-x:-Y.mt.width)+Y.et.x-f:p+f+Y.et.x),Y.U.y+Y.et.y-O)}let U=0,X=0;if(a)e?(x=this.GN(t,x,v),v<0&&(v=0),i>135&&(O+=k+f),k+=y+f,r===27&&(U+=u/2+t.focus.x),X+=y+f):(i>135&&(v+=x+f),x+=p+f,k=this.jN(t,k,O),O<0&&(O=0),r===27&&(X+=u/2+t.focus.y),U+=p+f);else if(e){if(t.comments===null){if(p>x){const B=this.HN(r,p-x,0);U=B.x,X=B.y,x=p,v=0}}else x=this.GN(t,x,v);v<0&&(U-=v,v=0),i>135&&(O+=k+f),k=Math.max(Math.max(k,y),k+y+f),X+=y+f}else{if(i>135&&(v+=x+f),x=Math.max(Math.max(x,p),x+p+f),t.comments===null){if(y>k){const B=this.HN(r,0,y-k);U=B.x,X=B.y,k=y,O=0}}else k=this.jN(t,k,O);O<0&&(X-=O,O=0),U+=p+f}let E,V;if(T>0)E=this.he(4),V=this.he(4),e?(E[2].e(0,y+f),E[3].e(E[2].x,k),V[2].e(x,E[2].y),V[3].e(V[2].x,E[3].y)):(E[2].e(p+f,0),E[3].e(x,E[2].y),V[2].e(E[2].x,k),V[3].e(E[3].x,V[2].y));else{E=this.he(P.length+2),V=this.he(M.length+2);for(let B=0;BE[0].x?E[2].a(E[1]):E[1].a(E[2])),E[3].yE[0].x?E[3].a(E[2]):E[2].a(E[3])),V[0].e(v+p,0),V[1].e(V[0].x,y),V[2].yE[0].y?E[2].a(E[1]):E[1].a(E[2])),E[3].xE[0].y?E[3].a(E[2]):E[2].a(E[3])),V[0].e(0,O+y),V[1].e(p,V[0].y),V[2].xl;){const a=i[o++];s[r++].e(a.x,a.y+e)}const h=this.he(r);for(n=0;nl;){const a=i[o++];s[r++].e(a.x+e,a.y)}const h=this.he(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.he(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.he(r);for(n=0;nh&&r.xr.x&&ha&&r.yr.y&&a0){const n=Math.min(1,t.layerSpacingParentOverlap);s-=e?t.height*n:t.width*n}return s<(e?-t.height:-t.width)&&(s=e?-t.height:-t.width),s}computeNodeIndent(t){const i=this.orthoAngle(t),e=i===90||i===270;let s=t.nodeIndent;if(t.nodeIndentPastParent>0){const n=Math.min(1,t.nodeIndentPastParent);s+=e?t.width*n:t.height*n}return s=Math.max(0,s),s}get roots(){return this.Fi}set roots(t){this.Fi!==t&&(this.Fi=t,this.invalidateLayout())}get path(){return this.Ti}set path(t){this.Ti!==t&&(this.Ti=t,this.invalidateLayout())}get treeStyle(){return this.Qf}set treeStyle(t){this.Qf!==t&&(t===40||t===42||t===41||t===43)&&(this.Qf=t,this.invalidateLayout())}get layerStyle(){return this.Fg}set layerStyle(t){this.Fg!==t&&(t===60||t===61||t===62)&&(this.Fg=t,this.invalidateLayout())}get comments(){return this.Re}set comments(t){this.Re!==t&&(Util.i(t,"boolean",TreeLayout,"comments"),this.Re=t,this.invalidateLayout())}get arrangement(){return this.zi}set arrangement(t){this.zi!==t&&(t===50||t===51||t===52)&&(this.zi=t,this.invalidateLayout())}get arrangementSpacing(){return this.ks}set arrangementSpacing(t){this.ks.equals(t)||(this.ks.a(t),this.invalidateLayout())}get rootDefaults(){return this.V}set rootDefaults(t){this.V!==t&&(this.V=t,this.invalidateLayout())}get alternateDefaults(){return this.z}set alternateDefaults(t){this.z!==t&&(this.z=t,this.invalidateLayout())}get sorting(){return this.V.sorting}set sorting(t){this.V.sorting!==t&&(this.V.sorting=t,this.invalidateLayout())}get comparer(){return this.V.comparer}set comparer(t){this.V.comparer!==t&&(Util.i(t,"function",TreeLayout,"comparer"),this.V.comparer=t,this.invalidateLayout())}get angle(){return this.V.angle}set angle(t){this.V.angle!==t&&(Util.i(t,"number",TreeLayout,"angle"),t===0||t===90||t===180||t===270?(this.V.angle=t,this.invalidateLayout()):Util.o("TreeLayout.angle must be 0, 90, 180, or 270"))}get alignment(){return this.V.alignment}set alignment(t){this.V.alignment!==t&&(this.V.alignment=t,this.invalidateLayout())}get nodeIndent(){return this.V.nodeIndent}set nodeIndent(t){this.V.nodeIndent!==t&&(Util.i(t,"number",TreeLayout,"nodeIndent"),t>=0&&(this.V.nodeIndent=t,this.invalidateLayout()))}get nodeIndentPastParent(){return this.V.nodeIndentPastParent}set nodeIndentPastParent(t){this.V.nodeIndentPastParent!==t&&(Util.i(t,"number",TreeLayout,"nodeIndentPastParent"),t>=0&&t<=1&&(this.V.nodeIndentPastParent=t,this.invalidateLayout()))}get nodeSpacing(){return this.V.nodeSpacing}set nodeSpacing(t){this.V.nodeSpacing!==t&&(Util.i(t,"number",TreeLayout,"nodeSpacing"),this.V.nodeSpacing=t,this.invalidateLayout())}get layerSpacing(){return this.V.layerSpacing}set layerSpacing(t){this.V.layerSpacing!==t&&(Util.i(t,"number",TreeLayout,"layerSpacing"),this.V.layerSpacing=t,this.invalidateLayout())}get layerSpacingParentOverlap(){return this.V.layerSpacingParentOverlap}set layerSpacingParentOverlap(t){this.V.layerSpacingParentOverlap!==t&&(Util.i(t,"number",TreeLayout,"layerSpacingParentOverlap"),t>=0&&t<=1&&(this.V.layerSpacingParentOverlap=t,this.invalidateLayout()))}get compaction(){return this.V.compaction}set compaction(t){this.V.compaction!==t&&(t===30||t===31)&&(this.V.compaction=t,this.invalidateLayout())}get breadthLimit(){return this.V.breadthLimit}set breadthLimit(t){this.V.breadthLimit!==t&&(Util.i(t,"number",TreeLayout,"breadthLimit"),t>=0&&(this.V.breadthLimit=t,this.invalidateLayout()))}get rowSpacing(){return this.V.rowSpacing}set rowSpacing(t){this.V.rowSpacing!==t&&(Util.i(t,"number",TreeLayout,"rowSpacing"),this.V.rowSpacing=t,this.invalidateLayout())}get rowIndent(){return this.V.rowIndent}set rowIndent(t){this.V.rowIndent!==t&&(Util.i(t,"number",TreeLayout,"rowIndent"),t>=0&&(this.V.rowIndent=t,this.invalidateLayout()))}get commentSpacing(){return this.V.commentSpacing}set commentSpacing(t){this.V.commentSpacing!==t&&(Util.i(t,"number",TreeLayout,"commentSpacing"),this.V.commentSpacing=t,this.invalidateLayout())}get commentMargin(){return this.V.commentMargin}set commentMargin(t){this.V.commentMargin!==t&&(Util.i(t,"number",TreeLayout,"commentMargin"),this.V.commentMargin=t,this.invalidateLayout())}get setsPortSpot(){return this.V.setsPortSpot}set setsPortSpot(t){this.V.setsPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"setsPortSpot"),this.V.setsPortSpot=t,this.invalidateLayout())}get portSpot(){return this.V.portSpot}set portSpot(t){this.V.portSpot.equals(t)||(this.V.portSpot=t,this.invalidateLayout())}get setsChildPortSpot(){return this.V.setsChildPortSpot}set setsChildPortSpot(t){this.V.setsChildPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"setsChildPortSpot"),this.V.setsChildPortSpot=t,this.invalidateLayout())}get childPortSpot(){return this.V.childPortSpot}set childPortSpot(t){this.V.childPortSpot.equals(t)||(this.V.childPortSpot=t,this.invalidateLayout())}get alternateSorting(){return this.z.sorting}set alternateSorting(t){this.z.sorting!==t&&(this.z.sorting=t,this.invalidateLayout())}get alternateComparer(){return this.z.comparer}set alternateComparer(t){this.z.comparer!==t&&(Util.i(t,"function",TreeLayout,"alternateComparer"),this.z.comparer=t,this.invalidateLayout())}get alternateAngle(){return this.z.angle}set alternateAngle(t){this.z.angle!==t&&(Util.i(t,"number",TreeLayout,"alternateAngle"),(t===0||t===90||t===180||t===270)&&(this.z.angle=t,this.invalidateLayout()))}get alternateAlignment(){return this.z.alignment}set alternateAlignment(t){this.z.alignment!==t&&(this.z.alignment=t,this.invalidateLayout())}get alternateNodeIndent(){return this.z.nodeIndent}set alternateNodeIndent(t){this.z.nodeIndent!==t&&(Util.i(t,"number",TreeLayout,"alternateNodeIndent"),t>=0&&(this.z.nodeIndent=t,this.invalidateLayout()))}get alternateNodeIndentPastParent(){return this.z.nodeIndentPastParent}set alternateNodeIndentPastParent(t){this.z.nodeIndentPastParent!==t&&(Util.i(t,"number",TreeLayout,"alternateNodeIndentPastParent"),t>=0&&t<=1&&(this.z.nodeIndentPastParent=t,this.invalidateLayout()))}get alternateNodeSpacing(){return this.z.nodeSpacing}set alternateNodeSpacing(t){this.z.nodeSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateNodeSpacing"),this.z.nodeSpacing=t,this.invalidateLayout())}get alternateLayerSpacing(){return this.z.layerSpacing}set alternateLayerSpacing(t){this.z.layerSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateLayerSpacing"),this.z.layerSpacing=t,this.invalidateLayout())}get alternateLayerSpacingParentOverlap(){return this.z.layerSpacingParentOverlap}set alternateLayerSpacingParentOverlap(t){this.z.layerSpacingParentOverlap!==t&&(Util.i(t,"number",TreeLayout,"alternateLayerSpacingParentOverlap"),t>=0&&t<=1&&(this.z.layerSpacingParentOverlap=t,this.invalidateLayout()))}get alternateCompaction(){return this.z.compaction}set alternateCompaction(t){this.z.compaction!==t&&(t===30||t===31)&&(this.z.compaction=t,this.invalidateLayout())}get alternateBreadthLimit(){return this.z.breadthLimit}set alternateBreadthLimit(t){this.z.breadthLimit!==t&&(Util.i(t,"number",TreeLayout,"alternateBreadthLimit"),t>=0&&(this.z.breadthLimit=t,this.invalidateLayout()))}get alternateRowSpacing(){return this.z.rowSpacing}set alternateRowSpacing(t){this.z.rowSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateRowSpacing"),this.z.rowSpacing=t,this.invalidateLayout())}get alternateRowIndent(){return this.z.rowIndent}set alternateRowIndent(t){this.z.rowIndent!==t&&(Util.i(t,"number",TreeLayout,"alternateRowIndent"),t>=0&&(this.z.rowIndent=t,this.invalidateLayout()))}get alternateCommentSpacing(){return this.z.commentSpacing}set alternateCommentSpacing(t){this.z.commentSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateCommentSpacing"),this.z.commentSpacing=t,this.invalidateLayout())}get alternateCommentMargin(){return this.z.commentMargin}set alternateCommentMargin(t){this.z.commentMargin!==t&&(Util.i(t,"number",TreeLayout,"alternateCommentMargin"),this.z.commentMargin=t,this.invalidateLayout())}get alternateSetsPortSpot(){return this.z.setsPortSpot}set alternateSetsPortSpot(t){this.z.setsPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"alternateSetsPortSpot"),this.z.setsPortSpot=t,this.invalidateLayout())}get alternatePortSpot(){return this.z.portSpot}set alternatePortSpot(t){this.z.portSpot.equals(t)||(this.z.portSpot=t,this.invalidateLayout())}get alternateSetsChildPortSpot(){return this.z.setsChildPortSpot}set alternateSetsChildPortSpot(t){this.z.setsChildPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"alternateSetsChildPortSpot"),this.z.setsChildPortSpot=t,this.invalidateLayout())}get alternateChildPortSpot(){return this.z.childPortSpot}set alternateChildPortSpot(t){this.z.childPortSpot.equals(t)||(this.z.childPortSpot=t,this.invalidateLayout())}static PathDefault=0;static PathDestination=1;static PathSource=2;static SortingForwards=10;static SortingReverse=11;static SortingAscending=12;static SortingDescending=13;static AlignmentCenterSubtrees=20;static AlignmentCenterChildren=21;static AlignmentStart=22;static AlignmentEnd=23;static AlignmentBus=24;static AlignmentBusBranching=25;static AlignmentTopLeftBus=26;static AlignmentBottomRightBus=27;static CompactionNone=30;static CompactionBlock=31;static StyleLayered=40;static StyleLastParents=41;static StyleAlternating=42;static StyleRootOnly=43;static ArrangementVertical=50;static ArrangementHorizontal=51;static ArrangementFixedRoots=52;static LayerIndividual=60;static LayerSiblings=61;static LayerUniform=62}class TreeNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new TreeVertex(this)}createEdge(){return new TreeEdge(this)}}class TreeVertex extends LayoutVertex{U;mt;et;gk;mk;pk;yk;wk;xk;bk;Re;MD;_f;tu;Rg;vg;pe;ye;Xt;ni;$y;Zy;Qy;Ps;_y;tw;iw;ew;sw;nw;ow;rw;lw;hw;aw;constructor(t){super(t),this.gk=!1,this.mk=null,this.pk=[],this.yk=0,this.wk=0,this.xk=0,this.bk=0,this.Re=null,this.U=new Point(0,0),this.mt=new Size(0,0),this.et=new Point(0,0),this.MD=!1,this._f=!1,this.tu=!1,this.Rg=null,this.vg=null,this.pe=10,this.ye=LayoutVertex.standardComparer,this.Xt=0,this.ni=21,this.$y=0,this.Zy=0,this.Qy=20,this.Ps=50,this._y=0,this.tw=31,this.iw=0,this.ew=25,this.sw=10,this.nw=10,this.ow=20,this.rw=!0,this.lw=Spot.Default,this.hw=!0,this.aw=Spot.Default}copyInheritedPropertiesFrom(t){t!==null&&(this.pe=t.sorting,this.ye=t.comparer,this.Xt=t.angle,this.ni=t.alignment,this.$y=t.nodeIndent,this.Zy=t.nodeIndentPastParent,this.Qy=t.nodeSpacing,this.Ps=t.layerSpacing,this._y=t.layerSpacingParentOverlap,this.tw=t.compaction,this.iw=t.breadthLimit,this.ew=t.rowSpacing,this.sw=t.rowIndent,this.nw=t.commentSpacing,this.ow=t.commentMargin,this.rw=t.setsPortSpot,this.lw=t.portSpot,this.hw=t.setsChildPortSpot,this.aw=t.childPortSpot)}get initialized(){return this.gk}set initialized(t){this.gk!==t&&(Util.i(t,"boolean",TreeVertex,"initialized"),this.gk=t)}get parent(){return this.mk}set parent(t){this.mk!==t&&(this.mk=t)}get children(){return this.pk}set children(t){if(this.pk!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",TreeVertex,"children:value"),t!==null){const i=t.length;for(let e=0;e4;)t.removePoint(2);u=t.getPoint(1),d=t.getPoint(2)}else{for(f=1;t.pointsCount>3;)t.removePoint(1);u=t.getPoint(0),d=t.getPoint(t.pointsCount-1)}const m=t.getPoint(t.pointsCount-1);let g=0;r===0?(e.alignment===23?(g=o.bottom+n.y,n.y===0&&u.y>m.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.xm.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.x{const i=t.matches?"dark":"light";i!==this.Og&&(this.Og=i,this.Mk==="system"&&this.cw())};constructor(t){t&&Object.assign(this,t),t?.themeMap||(this.eu.set("light",{colors:{...Themes.Light.colors},fonts:{...Themes.Light.fonts},numbers:{...Themes.Light.numbers},margins:{...Themes.Light.margins},arrowheads:{...Themes.Light.arrowheads}}),this.eu.set("dark",{colors:{...Themes.Dark.colors},fonts:{...Themes.Dark.fonts},numbers:{...Themes.Dark.numbers},margins:{...Themes.Dark.margins},arrowheads:{...Themes.Dark.arrowheads}})),root.matchMedia&&(this.Og=root.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}get themeMap(){return this.eu}set themeMap(t){this.eu!==t&&(this.eu=t,this.cw())}get defaultTheme(){return this.Pk}set defaultTheme(t){this.Pk!==t&&(Util.i(t,"string",ThemeManager,"defaultTheme"),this.Pk=t,this.cw())}get currentTheme(){return this.Mk}set currentTheme(t){this.Mk!==t&&(Util.i(t,"string",ThemeManager,"currentTheme"),this.Mk=t,this.cw())}get changesDivBackground(){return this.Sk}set changesDivBackground(t){if(this.Sk!==t&&(this.Sk=t,t))for(const e of this.es)e.setDivBackground(this.findValue("div","","fill")),e.v("ThemeChanged",this)}get preferredColorScheme(){return this.Og}addDiagram(t){return this.es.add(t),this.WN(t),this}removeDiagram(t){return this.es.delete(t),this.WN(t),this}zF(){this.es.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.addEventListener("change",this.SD)}XF(){this.es.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.removeEventListener("change",this.SD)}set(t,i){t===""&&(t=this.Pk),t==="system"&&(t=this.Og);let e=this.eu.get(t);return e?e=this.ND(e,i):e=i,this.eu.set(t,e),this.cw(),this}findValue(t,i,e){return this.getValue(this.findTheme(this.currentTheme),t,i,e)||this.getValue(this.findTheme(this.defaultTheme),t,i,e)}getValue(t,i,e,s){if(!t)return;e==null&&(e="");let n=t;const o=l=>{if(n===void 0||l==="")return;if(typeof l=="number"||!(Array.isArray(l)||l.includes(".")))return n[l];const h=Array.isArray(l)?l:l.split(".");for(let a=0;a{if(!(e!==""&&(n=o(e),n===void 0)))return Array.isArray(n)&&typeof i=="number"?n=n[i%n.length]:n=o(i),n};if(n=r(),n===void 0&&typeof s=="string"&&s.length>0){let l=t.targetPropertyMap?.get(s);if(l?n=t[l]:(l=ThemeManager.jI.get(s),n=l?t[l]:t.colors),n=r(),n!==void 0)return n}return n}findTheme(t){return this.themeMap.get(t==="system"?this.Og:t)}WN(t){const i=t.skipsUndoManager;t.skipsUndoManager=!0,t.updateAllThemeBindings(),this.Sk&&t.setDivBackground(this.findValue("div","","fill")),t.skipsUndoManager=i,t.v("ThemeChanged",this)}cw(){for(const t of this.es)this.WN(t)}ND(t,i){for(const e in i)if(Util.fw(i,e))try{i[e].constructor===Object?t[e]=this.ND(t[e]??{},i[e]):t[e]=i[e]}catch{delete t[e]}return t}static jI=new Map([["background","colors"],["defaultColumnSeparatorStroke","colors"],["defaultRowSeparatorStroke","colors"],["shadowColor","colors"],["fill","colors"],["stroke","colors"],["font","fonts"],["angle","numbers"],["fromEndSegmentLength","numbers"],["fromShortLength","numbers"],["height","numbers"],["opacity","numbers"],["scale","numbers"],["toEndSegmentLength","numbers"],["toShortLength","numbers"],["width","numbers"],["defaultColumnSeparatorStrokeWidth","numbers"],["defaultRowSeparatorStrokeWidth","numbers"],["shadowBlur","numbers"],["corner","numbers"],["curviness","numbers"],["smoothness","numbers"],["parameter1","numbers"],["parameter2","numbers"],["strokeWidth","numbers"],["strokeDashOffset","numbers"],["maxLines","numbers"],["spacingAbove","numbers"],["spacingBelow","numbers"],["position","points"],["shadowOffset","points"],["desiredSize","sizes"],["maxSize","sizes"],["minSize","sizes"],["margin","margins"],["defaultSeparatorPadding","margins"],["padding","margins"],["alignment","spots"],["alignmentFocus","spots"],["fromSpot","spots"],["toSpot","spots"],["defaultAlignment","spots"],["spot1","spots"],["spot2","spots"],["verticalAlignment","spots"],["imageAlignment","spots"],["fromArrow","arrowheads"],["toArrow","arrowheads"]])}class Router{St;p;Oi;ul;constructor(){this.p=Diagram.pm(),this.St="",this.Oi=!0,this.ul=!0}get name(){return this.St}set name(t){this.St=t}get isEnabled(){return this.Oi}set isEnabled(t){this.Oi=t}get isRealtime(){return this.ul}set isRealtime(t){this.ul=t}get diagram(){return this.p}set diagram(t){this.p!==t&&(this.p=t,t.bl=!0,t.requestUpdate())}invalidateRouter(){this.p!==null&&(this.p.bl=!0,this.p.requestUpdate())}canRoute(t){if(!this.isEnabled)return!1;const i=this.diagram;return!(i&&(!this.isRealtime&&i.yu||i.animationManager.isTicking))}routeLinks(t,i){}toString(){return this.name!==""?this.name+" Router":Util.sn(this.constructor)}}class AvoidsNodesRouter extends Router{constructor(t){super(),this.name="AvoidsNodes",t&&Object.assign(this,t)}canRoute(t){return(t instanceof Diagram?t.Gm:t.diagram.Gm)?super.canRoute(t):!1}routeLinks(t,i){const e=i instanceof Diagram?null:i,s=t.iterator,n=this.diagram.getPositions(!0,e,null);for(;s.next();){const o=s.value;if(!o.isAvoiding||i&&o.containingGroup!==e||o.toNode===null||o.fromNode===null||o.pointsCount<4)continue;o.startRoute();const r=o.pointsCount,l=o.getPoint(1),h=o.getPoint(r-2),a=o.fromNode.actualBounds.copy();a.inflate(Link.Ra,Link.Ra),a.unionPoint(o.getPoint(0));const c=o.toNode.actualBounds.copy();c.inflate(Link.Ra,Link.Ra),c.unionPoint(o.getPoint(r-1)),this.HI(o,a,c,n)&&this.qI(o,l,o.sN,h,o.nN,a,c,n),o.commitRoute()}}HI(t,i,e,s){const n=t.diagram,o=t.pointsCount;if(n===null||t.fromNode===t.toNode||t.layer.isTemporary||i.containsPoint(t.getPoint(o-1))&&!t.toNode.isMemberOf(t.fromNode)||e.containsPoint(t.getPoint(0))&&!t.fromNode.isMemberOf(t.toNode)||!t.isOrthogonal)return!1;if(t.segmentIndex===17)return!0;const r=t.getPoint(1),l=t.getPoint(o-2),h=t.getPoint(2);if(!s.isUnoccupied(Math.min(r.x,h.x),Math.min(r.y,h.y),Math.abs(r.x-h.x),Math.abs(r.y-h.y)))return!0;for(let c=2;c=PositionArray.Bd&&(l.XL(),d.inflate(l.cellWidth*l.vS,l.cellHeight*l.OS),l.rT(i,e,s,n,d,!1),m=l.fo(s.x,s.y)),!l.by&&mPositionArray.Ea&&i.fo(g,p)!==u-1&&(i.fo(d-c,m)===u-1?(n=180,g=d-c,p=m):i.fo(d+c,m)===u-1?(n=0,g=d+c,p=m):i.fo(d,m-f)===u-1?(n=270,g=d,p=m-f):i.fo(d,m+f)===u-1&&(n=90,g=d,p=m+f));u>PositionArray.Ea&&i.fo(g,p)===u-1;)d=g,m=p,n===0?g+=c:n===90?p+=f:n===180?g-=c:p-=f,u-=1;if(o?u>PositionArray.Ea&&(n===180||n===0?d=Math.floor(d/c)*c+c/2:(n===90||n===270)&&(m=Math.floor(m/f)*f+f/2)):(d=Math.floor(d/c)*c+c/2,m=Math.floor(m/f)*f+f/2),u>PositionArray.Ea){let y=n,x=d,k=m;if(n===0?(y=90,k+=f):n===90?(y=180,x-=c):n===180?(y=270,k-=f):n===270&&(y=0,x+=c),i.fo(x,k)===u-1)this.JN(t,i,x,k,y,!1);else{let P=d,M=m;n===0?(y=270,M-=f):n===90?(y=0,P+=c):n===180?(y=90,M+=f):n===270&&(y=180,P-=c),i.fo(P,M)===u-1&&this.JN(t,i,P,M,y,!1)}}t.insertPointAt(t.pointsCount-2,d,m)}}ToolManager.prototype.initializeStandardTools=function(){this.Jt("Action",new ActionTool,this.mouseDownTools),this.Jt("Relinking",new RelinkingTool,this.mouseDownTools),this.Jt("LinkReshaping",new LinkReshapingTool,this.mouseDownTools),this.Jt("Rotating",new RotatingTool,this.mouseDownTools),this.Jt("Resizing",new ResizingTool,this.mouseDownTools),this.Jt("Linking",new LinkingTool,this.mouseMoveTools),this.Jt("Dragging",new DraggingTool,this.mouseMoveTools),this.Jt("DragSelecting",new DragSelectingTool,this.mouseMoveTools),this.Jt("Panning",new PanningTool,this.mouseMoveTools),this.Jt("ContextMenu",new ContextMenuTool,this.mouseUpTools),this.Jt("TextEditing",new TextEditingTool,this.mouseUpTools),this.Jt("ClickCreating",new ClickCreatingTool,this.mouseUpTools),this.Jt("ClickSelecting",new ClickSelectingTool,this.mouseUpTools)};Diagram.gS("GraphLinksModel",GraphLinksPartManager);Diagram.gS("TreeModel",TreePartManager);const oldGo=root.go,go={get version(){return Diagram.version},Group,List,Set:GSet,Map:GMap,Point,Size,Rect,Margin,Spot,Geometry,PathFigure,PathSegment,InputEvent,DiagramEvent,ChangedEvent,Model,GraphLinksModel,TreeModel,Binding,ThemeBinding,Transaction,UndoManager,CommandHandler,Tool,DraggingTool,DraggingInfo,DraggingOptions,LinkingBaseTool,LinkingTool,RelinkingTool,LinkReshapingTool,ResizingTool,RotatingTool,ClickSelectingTool,ActionTool,ClickCreatingTool,HTMLInfo,ContextMenuTool,DragSelectingTool,PanningTool,TextEditingTool,ToolManager,Animation,AnimationManager,AnimationTrigger,Layer,Diagram,Palette,Overview,Brush,GraphObject,Panel,RowColumnDefinition,Shape,TextBlock,Picture,Part,Adornment,Node,Link,Placeholder,Layout,LayoutNetwork,LayoutVertex,LayoutEdge,GridLayout,PanelLayout,CircularLayout,CircularNetwork,CircularVertex,CircularEdge,ForceDirectedLayout,ForceDirectedNetwork,ForceDirectedVertex,ForceDirectedEdge,LayeredDigraphLayout,LayeredDigraphNetwork,LayeredDigraphVertex,LayeredDigraphEdge,TreeLayout,TreeNetwork,TreeVertex,TreeEdge,Themes,ThemeManager,Router,AnimationStyle,AutoScale,CycleMode,Flip,TextFormat,ImageStretch,LayoutConditions,LinkAdjusting,Curve,Routing,Orientation,TextOverflow,PortSpreading,ScrollMode,CollapsePolicy,Sizing,TriggerStart,Stretch,ViewboxStretch,Wrap,BrushType,ColorSpace,GeometryStretch,GeometryType,SegmentType,BindingMode,ChangeType,CircularArrangement,CircularDirection,CircularNodeDiameterFormula,CircularSorting,GridAlignment,GridArrangement,GridSorting,LayeredDigraphAggressive,LayeredDigraphAlign,LayeredDigraphCycleRemove,LayeredDigraphInit,LayeredDigraphLayering,LayeredDigraphPack,TreeAlignment,TreeArrangement,TreeCompaction,TreeLayerStyle,TreePath,TreeSorting,TreeStyle,GestureMode,LinkingDirection,ReshapingBehavior,TextEditingAccept,TextEditingStarting,TextEditingState,WheelMode};typeof oldGo=="object"&&oldGo.version&&Util.oi("WARNING: a `go` object on the root object is already defined. "+("Debug"in oldGo?"debug ":"")+"version: "+oldGo.version+", replaced with version: "+go.version);Diagram.prototype.go=go;root.go=go; + "removedLinkKeys": `;BT(t){const i=new GSet;for(let e=0;e{if(f.model===s){if(f.modelChange==="linkDataArray")f.change===3?n.add(f.newValue):f.change===4&&r.add(f.oldValue);else if(s.containsLinkData(f.object))o.add(f.object);else if(f.object!==null)if(f.object!==null&&l&&l.has(f.object))l.get(f.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(f.object instanceof Model||s.containsNodeData(f.object))return;s.BT(f.object).each(d=>o.add(d))}}});const h=this.og;h.clear(),n.each(f=>{h.add(s.getKeyForLinkData(f)),i||o.add(f)});const a=this.ng;a.clear(),r.each(f=>{a.add(s.getKeyForLinkData(f)),i&&o.add(f)});let c=e;return h.count>0&&(c+=(i?this.VT:this.UT)+this.Ch(h.toArray(),!0)),o.count>0&&(c+=this.DO+this.Ch(o.toArray(),!0)),a.count>0&&(c+=(i?this.UT:this.VT)+this.Ch(a.toArray(),!0)),a.clear(),h.clear(),c}Dy(t){(t.linkCategoryProperty!==void 0&&t.linkCategoryProperty!==this.linkCategoryProperty||t.linkKeyProperty!==void 0&&t.linkKeyProperty!==this.linkKeyProperty||t.linkFromKeyProperty!==void 0&&t.linkFromKeyProperty!==this.linkFromKeyProperty||t.linkToKeyProperty!==void 0&&t.linkToKeyProperty!==this.linkToKeyProperty||t.linkFromPortIdProperty!==void 0&&t.linkFromPortIdProperty!==this.linkFromPortIdProperty||t.linkToPortIdProperty!==void 0&&t.linkToPortIdProperty!==this.linkToPortIdProperty||t.linkLabelKeysProperty!==void 0&&t.linkLabelKeysProperty!==this.linkLabelKeysProperty||t.nodeIsGroupProperty!==void 0&&t.nodeIsGroupProperty!==this.nodeIsGroupProperty||t.nodeGroupKeyProperty!==void 0&&t.nodeGroupKeyProperty!==this.nodeGroupKeyProperty)&&Util.o("applyIncrementalJson cannot change Model properties"),super.Dy(t);const i=t.insertedLinkKeys;if(Array.isArray(i)){const n=i.length;for(let o=0;o=0&&s.splice(e,1)):s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue));return}}else if(t.change===4){let e=t.oldParam;if(t.modelChange==="linkDataArray"){const s=t.oldValue;if(Util.wt(s)&&typeof e=="number"){const n=this.getKeyForLinkData(s);i?(this.sr.add(s),this.$e[e]!==s&&this.$e.splice(e,0,s),n!==void 0&&this.fi.set(n,s)):(this.sr.delete(s),this.$e[e]===s&&this.$e.splice(e,1),n!==void 0&&this.fi.delete(n))}return}else if(t.modelChange==="linkLabelKeys"){const s=this.getLabelKeysForLinkData(t.object);Array.isArray(s)&&typeof e=="number"&&(i?s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue):(e=s.indexOf(t.newValue),e>=0&&s.splice(e,1)));return}}super.changeState(t,i)}}get archetypeNodeData(){return this.Ll}set archetypeNodeData(t){const i=this.Ll;i!==t&&(t!==null&&Util.i(t,"object",GraphLinksModel,"archetypeNodeData"),this.Ll=t,this.t("archetypeNodeData",i,t))}NN(t){if(t===void 0)return;const i=this.Ll;if(i!==null){let e=this.findNodeDataForKey(t);e===null&&(e=this.copyNodeData(i),Model.rt(e,this.nodeKeyProperty,t),this.addNodeData(e))}return t}get linkFromKeyProperty(){return this.wo}set linkFromKeyProperty(t){const i=this.wo;i!==t&&(this.An(t,GraphLinksModel,"linkFromKeyProperty"),this.wo=t,this.t("linkFromKeyProperty",i,t))}getFromKeyForLinkData(t){return this.Te(t,!0)}setFromKeyForLinkData(t,i){this.Zd(t,i,!0)}get linkToKeyProperty(){return this.xo}set linkToKeyProperty(t){const i=this.xo;i!==t&&(this.An(t,GraphLinksModel,"linkToKeyProperty"),this.xo=t,this.t("linkToKeyProperty",i,t))}getToKeyForLinkData(t){return this.Te(t,!1)}setToKeyForLinkData(t,i){this.Zd(t,i,!1)}Te(t,i){if(t===null)return;const e=i?this.wo:this.xo;if(e==="")return;const s=Model.vt(t,e);if(s!==void 0){if(this.isKeyType(s))return s;Util.o((i?"FromKey":"ToKey")+" value for link data "+t+" is not a number or a string: "+s)}}Zd(t,i,e){if(i===null&&(i=void 0),i!==void 0&&!this.isKeyType(i)&&Util.we(i,"number or string",GraphLinksModel,e?"setFromKeyForLinkData:key":"setToKeyForLinkData:key"),t===null)return;const s=e?this.wo:this.xo;if(s==="")return;if(i=this.NN(i),!this.containsLinkData(t)){Model.rt(t,s,i);return}const n=Model.vt(t,s);n!==i&&(this.Js(n,t),Model.rt(t,s,i),this.findNodeDataForKey(i)===null&&this.$s(i,t),this.Et(e?"linkFromKey":"linkToKey",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkFromPortIdProperty(){return this.Ya}set linkFromPortIdProperty(t){const i=this.Ya;i!==t&&(this.An(t,GraphLinksModel,"linkFromPortIdProperty"),this.Ya=t,this.t("linkFromPortIdProperty",i,t))}getFromPortIdForLinkData(t){return this.L1(t,!0)}setFromPortIdForLinkData(t,i){this.Qd(t,i,!0)}get linkToPortIdProperty(){return this.Ga}set linkToPortIdProperty(t){const i=this.Ga;i!==t&&(this.An(t,GraphLinksModel,"linkToPortIdProperty"),this.Ga=t,this.t("linkToPortIdProperty",i,t))}getToPortIdForLinkData(t){return this.L1(t,!1)}setToPortIdForLinkData(t,i){this.Qd(t,i,!1)}L1(t,i){if(t===null)return"";const e=i?this.Ya:this.Ga;if(e==="")return"";const s=Model.vt(t,e);return s===void 0?"":s}Qd(t,i,e){if(Util.i(i,"string",GraphLinksModel,e?"setFromPortIdForLinkData:portname":"setToPortIdForLinkData:portname"),t===null)return;const s=e?this.Ya:this.Ga;if(s==="")return;if(!this.containsLinkData(t)){Model.rt(t,s,i);return}let n=Model.vt(t,s);n===void 0&&(n=""),n!==i&&(Model.rt(t,s,i),this.Et(e?"linkFromPortId":"linkToPortId",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkLabelKeysProperty(){return this.Zs}set linkLabelKeysProperty(t){const i=this.Zs;i!==t&&(this.An(t,GraphLinksModel,"linkLabelKeysProperty"),this.Zs=t,this.t("linkLabelKeysProperty",i,t))}getLabelKeysForLinkData(t){if(t===null)return GraphLinksModel.EmptyArray;const i=this.Zs;if(i==="")return GraphLinksModel.EmptyArray;const e=Model.vt(t,i);return e===void 0?GraphLinksModel.EmptyArray:e}setLabelKeysForLinkData(t,i){if(t===null)return;const e=this.Zs;if(e==="")return;if(!this.containsLinkData(t)){Model.rt(t,e,i);return}let s=Model.vt(t,e);if(s===void 0&&(s=GraphLinksModel.EmptyArray),s!==i){if(Array.isArray(s)){const o=s.length;for(let r=0;r=0)return;n=s.length,s.push(i),this.containsLinkData(t)&&(this.findNodeDataForKey(i)===null&&this.$s(i,t),this.Et("linkLabelKeys",3,e,t,null,i,null,n))}else Util.o(e+" property is not an Array; cannot addLabelKeyForLinkData: "+t)}removeLabelKeyForLinkData(t,i){if(i==null||(this.isKeyType(i)||Util.we(i,"number or string",GraphLinksModel,"removeLabelKeyForLinkData:key"),t===null))return;const e=this.Zs;if(e==="")return;const s=Model.vt(t,e);if(Array.isArray(s)){const n=s.indexOf(i);if(n<0)return;s.splice(n,1),this.containsLinkData(t)&&(this.Js(i,t),this.Et("linkLabelKeys",4,e,t,i,null,n,null))}else s!==void 0&&Util.o(e+" property is not an Array; cannot removeLabelKeyforLinkData: "+t)}get linkDataArray(){return this.$e}set linkDataArray(t){const i=this.$e;if(i!==t){this.fi.clear();const e=t.length;for(let n=0;nnew GraphLinksModel;Model.initDiagramModel=Model.initDiagramModel=()=>new GraphLinksModel;class TreeModel extends Model{Dn;ug;Ha;constructor(t,i){if(super(),this.Dn="parent",this.ug=!1,this.Ha="parentLinkCategory",t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){super.cloneProtected(t),t.Dn=this.Dn,t.ug=this.ug,t.Ha=this.Ha}toString(t){if(t===void 0&&(t=0),t>=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" TreeModel";if(t>0){i+=` + node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n(w[w.ConstantSpacing=0]="ConstantSpacing",w[w.ConstantDistance=1]="ConstantDistance",w[w.ConstantAngle=2]="ConstantAngle",w[w.Packed=3]="Packed",w))(CircularArrangement||{}),CircularDirection=(w=>(w[w.Clockwise=10]="Clockwise",w[w.Counterclockwise=11]="Counterclockwise",w[w.BidirectionalLeft=12]="BidirectionalLeft",w[w.BidirectionalRight=13]="BidirectionalRight",w))(CircularDirection||{}),CircularSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w[w.Optimized=24]="Optimized",w))(CircularSorting||{}),CircularNodeDiameterFormula=(w=>(w[w.Pythagorean=30]="Pythagorean",w[w.Circular=31]="Circular",w))(CircularNodeDiameterFormula||{});class CircularLayout extends Layout{le;If;B1;dg;U1;Ah;AN;TN;DN;bs;vy;Oy;qa;Iy;XT;gg;mg;pg;Ef;zi;S;pe;ye;Ln;yg;constructor(t){super(),this.le=0,this.If=0,this.B1=0,this.dg=360,this.U1=0,this.Ah=0,this.AN=new Point,this.TN=30,this.DN=0,this.bs=0,this.vy=0,this.Oy=new VertexArrangement,this.qa=0,this.Iy=0,this.XT=600,this.gg=NaN,this.mg=1,this.pg=0,this.Ef=360,this.zi=0,this.S=10,this.pe=24,this.ye=LayoutVertex.standardComparer,this.Ln=6,this.yg=30,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.gg=this.gg,t.mg=this.mg,t.pg=this.pg,t.Ef=this.Ef,t.zi=this.zi,t.S=this.S,t.pe=this.pe,t.ye=this.ye,t.Ln=this.Ln,t.yg=this.yg}ri(t){t in CircularSorting?this.sorting=t:t in CircularDirection?this.direction=t:t in CircularArrangement?this.arrangement=t:t in CircularNodeDiameterFormula?this.nodeDiameterFormula=t:super.ri(t)}createNetwork(){return new CircularNetwork(this)}vO(t,i,e){t=this.OO(t);let s=this.U1,n=this.TN,o=this.le,r=this.If,l=this.B1,h=this.dg,a=this.Ah,c=this.DN,f=this.bs,u=this.vy;if(s=this.arrangement,n=this.nodeDiameterFormula,o=this.radius,(!isFinite(o)||o<=0)&&(o=NaN),r=this.aspectRatio,(!isFinite(r)||r<=0)&&(r=1),l=this.startAngle,isFinite(l)||(l=0),h=this.sweepAngle,(!isFinite(h)||h>360||h<1)&&(h=360),a=this.spacing,isFinite(a)||(a=NaN),s===3&&n===31?s=0:s===3&&n!==31&&(n=31,s=this.arrangement),(this.direction===12||this.direction===13)&&this.sorting!==24){for(let g=0;!(g>=t.length||(i.add(t.elt(g)),g+1>=t.length));g+=2)e.add(t.elt(g+1));this.direction===12?(this.arrangement===3&&i.reverse(),t=new List,t.addAll(i),t.addAll(e)):(this.arrangement===3&&e.reverse(),t=new List,t.addAll(e),t.addAll(i))}const d=t.length;c=0;let m=0;for(let g=0;g1?(o=y,f=o*r):(f=y,o=f)}else o=this.V1(u*(h>=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180)}else o=this.V1(c+(h>=360?d:d-1)*(s!==3?a:a*1.6),r,l*Math.PI/180,h*Math.PI/180);f=o*r}else{f=o*r;const g=this.FN(o,f,l*Math.PI/180,h*Math.PI/180);if(isNaN(a))s===0&&(a=(g-c)/(h>=360?d:d-1));else if(s===0){const p=(g-c)/(h>=360?d:d-1);p=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180),f=o*r):a=p}else{let p=-1/0;for(let k=0;k=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180);x>o?(o=x,f=o*r,u=y):u=g/(h>=360?d:d-1)}}return this.U1=s,this.TN=n,this.le=o,this.If=r,this.B1=l,this.dg=h,this.Ah=a,this.DN=c,this.bs=f,this.vy=u,t}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.network.vertexes;if(i.count<=1){if(i.count===1){const u=i.first();u.centerX=0,u.centerY=0}this.updateParts(),this.network=null,this.isValidLayout=!0;return}let e=new List;e.addAll(i.iterator);const s=new List,n=new List;e=this.vO(e,s,n);const o=this.U1,r=this.le,l=this.B1,h=this.dg,a=this.Ah,c=this.bs,f=this.vy;if((this.direction===12||this.direction===13)&&o===3)this.KT(e,h,l-h/2,10);else if(this.direction===12||this.direction===13){let u=0;switch(o){case 1:u=this.z1(r,c,l,f)*180/Math.PI;break;case 0:{let d=0,m=0;const g=s.first();g!==null&&(d=g.Th(Math.PI/2));const p=n.first();p!==null&&(m=p.Th(Math.PI/2)),u=this.z1(r,c,l,a+(d+m)/2)*180/Math.PI;break}case 2:u=h/e.length;break}if(this.direction===12){switch(o){case 1:this.Ey(s,h/2,l,11);break;case 0:this.By(s,h/2,l,11);break;case 2:this.Uy(s,h/2,l,11);break}switch(o){case 1:this.Ey(n,h/2,l+u,10);break;case 0:this.By(n,h/2,l+u,10);break;case 2:this.Uy(n,h/2,l+u,10);break}}else{switch(o){case 1:this.Ey(n,h/2,l,11);break;case 0:this.By(n,h/2,l,11);break;case 2:this.Uy(n,h/2,l,11);break}switch(o){case 1:this.Ey(s,h/2,l+u,10);break;case 0:this.By(s,h/2,l+u,10);break;case 2:this.Uy(s,h/2,l+u,10);break}}}else switch(o){case 1:this.Ey(e,h,l,this.direction);break;case 0:this.By(e,h,l,this.direction);break;case 2:this.Uy(e,h,l,this.direction);break;case 3:this.KT(e,h,l,this.direction);break}this.updateParts(),this.network=null,this.isValidLayout=!0}Uy(t,i,e,s){const n=this.dg,o=this.le,r=this.bs,l=e*Math.PI/180,h=i*Math.PI/180,a=t.length;for(let c=0;c=360?a:a-1):-(c*h)/a),u=t.elt(c),d=o*Math.tan(f)/r,m=Math.sqrt((o*o+r*r*d*d)/(1+d*d));u.centerX=m*Math.cos(f),u.centerY=m*Math.sin(f),u.actualAngle=f*180/Math.PI}}By(t,i,e,s){const n=this.le,o=this.bs,r=this.Ah;let l=e*Math.PI/180;const h=t.length;for(let a=0;a180&&(n-=360),n*=Math.PI/180,this.Iy=n,this.YT(t,i,e,s)}else this.GT(t,i,e,s);this.Oy.commit(t)}GT(t,i,e,s){const n=this.le,o=this.bs,r=this.Ah,l=this.If;let h=n*Math.cos(e*Math.PI/180),a=o*Math.sin(e*Math.PI/180);const c=t.toArray();if(c.length===3){c[0].centerX=n,c[0].centerY=0,c[1].centerX=c[0].centerX-c[0].width/2-c[1].width/2-r,c[1].y=c[0].y,c[2].centerX=(c[0].centerX+c[1].centerX)/2,c[2].y=c[0].y-c[2].height-r;return}else if(c.length===4){c[0].centerX=n,c[0].centerY=0,c[2].centerX=-c[0].centerX,c[2].centerY=c[0].centerY,c[1].centerX=0,c[1].y=Math.min(c[0].y,c[2].y)-c[1].height-r,c[3].centerX=0,c[3].y=Math.max(c[0].y+c[0].height+r,c[2].y+c[2].height+r);return}const f=Point.l();for(let b=0;b=c.length-1));b++)this.jT(h,a,c,b,s,f)||this.HT(h,a,c,b,s,f),h=f.x,a=f.y;if(Point.s(f),this.qa++,this.qa>23)return;const u=c[0].centerX,d=c[0].centerY,m=c[c.length-1].centerX,g=c[c.length-1].centerY;let p=Math.abs(u-m)-((c[0].width+c[c.length-1].width)/2+r);const y=Math.abs(d-g)-((c[0].height+c[c.length-1].height)/2+r);let x=0;if(Math.abs(y)<1){const b=Math.abs(u-m),P=(c[0].width+c[c.length-1].width)/2;b0?x=y:Math.abs(p)<1?x=0:x=p;let k=!1;Math.abs(m)>Math.abs(g)?k=m>0!=d>g:k=g>0!=u1&&(this.qa<8?this.le-=x/(2*Math.PI):c.length<5&&x>10?this.le/=2:this.le-=x>0?1.7:-2.3,this.bs=this.le*l,this.GT(t,i,e,s))}YT(t,i,e,s){const n=this.le,o=this.bs,r=this.If;let l=n*Math.cos(e*Math.PI/180),h=o*Math.sin(e*Math.PI/180);const a=Point.l(),c=t.toArray();for(let m=0;m=c.length-1));m++)this.jT(l,h,c,m,s,a)||this.HT(l,h,c,m,s,a),l=a.x,h=a.y;if(Point.s(a),this.qa++,this.qa>23)return;const f=Math.atan2(h,l);let u=s===10?this.Iy-f:f-this.Iy;u=Math.abs(u)1&&(this.qa<8?this.le-=d/(2*Math.PI):this.le-=d>0?1.7:-2.3,this.bs=this.le*r,this.YT(t,i,e,s))}jT(t,i,e,s,n,o){const r=this.Ah,l=this.le,h=this.bs;let a=0,c=0;const f=(e[s].width+e[s+1].width)/2+r;let u=!1;if(i>=0!=(n===10)){if(a=t+f,a>l){if(a=t-f,a<-l)return o.x=a,o.y=c,!1;u=!0}}else if(a=t-f,a<-l){if(a=t+f,a>l)return o.x=a,o.y=c,!1;u=!0}return c=Math.sqrt(1-Math.min(1,a*a/(l*l)))*h,i<0!==u&&(c=-c),Math.abs(i-c)>(e[s].height+e[s+1].height)/2?(o.x=a,o.y=c,!1):(o.x=a,o.y=c,!0)}HT(t,i,e,s,n,o){const r=this.Ah,l=this.le,h=this.bs;let a=0,c=0;const f=(e[s].height+e[s+1].height)/2+r;let u=!1;if(t>=0!=(n===10)){if(c=i-f,c<-h){if(c=i+f,c>h)return o.x=a,o.y=c,!1;u=!0}}else if(c=i+f,c>h){if(c=i-f,c<-h)return o.x=a,o.y=c,!1;u=!0}return a=Math.sqrt(1-Math.min(1,c*c/(h*h)))*l,t<0!==u&&(a=-a),Math.abs(t-a)>(e[s].width+e[s+1].width)/2?(o.x=a,o.y=c,!1):(o.x=a,o.y=c,!0)}commitLayout(){this.commitNodes(),this.isRouting&&this.commitLinks()}commitNodes(){const t=this.group!==null&&this.group.hasPlaceholder(),i=t?this.group.location.copy():null;let e=this.actualCenter;t?e=new Point(0,0):(e.x=this.arrangementOrigin.x+this.le,e.y=this.arrangementOrigin.y+this.bs);const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;n.x+=e.x,n.y+=e.y,n.commit()}if(t){this.group.ensureBounds();const n=this.group.position.copy(),o=this.group.location.copy(),r=i.subtract(o.subtract(n));this.group.move(r),this.AN=r.subtract(n)}}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}FN(t,i,e,s){const n=this.XT;if(Math.abs(this.If-1)<.001)return e!==void 0&&s!==void 0?s*t:2*Math.PI*t;const o=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let r=0,l=0;e!==void 0&&s!==void 0?l=s/(n+1):l=Math.PI/(2*(n+1));let h=0;for(let a=0;a<=n;a++){e!==void 0&&s!==void 0?h=e+a*s/n:h=a*Math.PI/(2*n);const c=Math.sin(h);r+=Math.sqrt(1-o*o*c*c)*l}return e!==void 0&&s!==void 0?(t>i?t:i)*r:4*(t>i?t:i)*r}V1(t,i,e,s){let n=0;return e!==void 0&&s!==void 0?n=this.FN(1,i,e,s):n=this.FN(1,i),t/n}z1(t,i,e,s){if(Math.abs(this.If-1)<.001)return s/t;const n=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let o=0;const r=2*Math.PI/(this.network.vertexes.count*700);t>i&&(e+=Math.PI/2);for(let l=0;;l++){const h=e+l*r,a=Math.sin(h);if(o+=(t>i?t:i)*Math.sqrt(1-n*n*a*a)*r,o>=s)return l*r}}OO(t){switch(this.sorting){case 20:break;case 21:t.reverse();break;case 22:t.sort(this.comparer);break;case 23:t.sort(this.comparer),t.reverse();break;case 24:return this.BO(this.UO(t));default:Util.o("Invalid sorting type.")}return t}UO(t){const i=[];for(let s=0;sn&&(n=u,o=c)}else for(let c=0;cn&&(n=f,o=c)}e.add(t.elt(o)),i[o]=-1;const r=t.elt(o);let l=0;const h=r.sourceEdges;for(;h.next();){const f=h.value.fromVertex;l=t.indexOf(f),!(l<0)&&i[l]>=0&&i[l]++}const a=r.destinationEdges;for(;a.next();){const f=a.value.toVertex;l=t.indexOf(f),!(l<0)&&i[l]>=0&&i[l]++}}return e}BO(t){const i=[];for(let f=0;f=0){const C=Math.abs(x-(L>=x?L+1:L));b+=C=x&&S++,L>=x&&L++,S>L){const C=L;L=S,S=C}L-S<(s.length+2)/2==(S=0&&(n.push(f),o.push(x))}h++}let a=!1;const c=s.length;for(;;){a=!0;for(let f=0;f=0){let g=0;for(let p=0;pm?x-m:m-x,b=c-k;g+=xb?1:-1}s.splice(g<0?m:m+1,0,u),r.splice(f,1),f--}else a=!1}if(a)break;s.push(r[0]),r.splice(0,1)}for(let f=0;f0||isNaN(t))&&(this.gg=t,this.invalidateLayout()))}get aspectRatio(){return this.mg}set aspectRatio(t){this.mg!==t&&(Util.i(t,"number",CircularLayout,"aspectRatio"),t>0&&(this.mg=t,this.invalidateLayout()))}get startAngle(){return this.pg}set startAngle(t){this.pg!==t&&(Util.i(t,"number",CircularLayout,"startAngle"),this.pg=t,this.invalidateLayout())}get sweepAngle(){return this.Ef}set sweepAngle(t){this.Ef!==t&&(Util.i(t,"number",CircularLayout,"sweepAngle"),t>0&&t<=360?this.Ef=t:this.Ef=360,this.invalidateLayout())}get arrangement(){return this.zi}set arrangement(t){this.zi!==t&&(t===3||t===0||t===1||t===2)&&(this.zi=t,this.invalidateLayout())}get direction(){return this.S}set direction(t){this.S!==t&&(t===10||t===11||t===12||t===13)&&(this.S=t,this.invalidateLayout())}get sorting(){return this.pe}set sorting(t){this.pe!==t&&(this.pe=t,this.invalidateLayout())}get comparer(){return this.ye}set comparer(t){this.ye!==t&&(Util.i(t,"function",CircularLayout,"comparer"),this.ye=t,this.invalidateLayout())}get spacing(){return this.Ln}set spacing(t){this.Ln!==t&&(Util.i(t,"number",CircularLayout,"spacing"),this.Ln=t,this.invalidateLayout())}get nodeDiameterFormula(){return this.yg}set nodeDiameterFormula(t){this.yg!==t&&(t===30||t===31)&&(this.yg=t,this.invalidateLayout())}get actualXRadius(){return this.le}get actualYRadius(){return this.bs}get actualSpacing(){return this.Ah}get actualCenter(){return this.AN}static ConstantSpacing=0;static ConstantDistance=1;static ConstantAngle=2;static Packed=3;static Clockwise=10;static Counterclockwise=11;static BidirectionalLeft=12;static BidirectionalRight=13;static Forwards=20;static Reverse=21;static Ascending=22;static Descending=23;static Optimized=24;static Pythagorean=30;static Circular=31}class VertexArrangement{Bf;Wa;Uf;constructor(){this.Bf=-1/0,this.Wa=null,this.Uf=null}IO(t,i){if(t>0&&this.Bf<0||Math.abs(t)0)){this.Bf=t,this.Wa=[],this.Uf=[];for(let e=0;e0){for(this.network.deleteSelfEdges(),i=this.network.vertexes.iterator;i.next();){const o=i.value;o.charge=this.electricalCharge(o),o.mass=this.gravitationalMass(o)}const s=this.network.edges.iterator;for(;s.next();){const o=s.value;o.stiffness=this.springStiffness(o),o.length=this.springLength(o)}if(this.RN(),this.Dh=0,this.needsPrelayout()){const o=this.network,r=o.splitIntoSubNetworks(!1);let l=r.iterator;for(;l.next();){const h=l.value;this.doConnectedSubnetLayout(h)}for(l=r.iterator,this.zO(l,o),l=r.iterator;l.next();){const h=l.value,a=h.vertexes.iterator;for(;a.next();){const f=a.value;o.addVertex(f)}const c=h.edges.iterator;for(;c.next();){const f=c.value;o.addEdge(f)}}}else this.qT(this.network,this.maxIterations);this.updateParts()}this.maxIterations=e,this.isValidLayout=!0}needsPrelayout(){if(this.network.vertexes.count<3)return!1;let t=0,i=0;const e=this.network.vertexes.first().bounds,s=this.network.vertexes.iterator;for(;s.next();){const n=s.value,o=n.bounds;if(isNaN(n.x)||isNaN(n.y)||o.intersectsRect(e)&&(t++,t>2))return!0;if(i>10)return!1;i++}return!1}doConnectedSubnetLayout(t){let i=t.vertexes.iterator;for(;i.next();){const l=i.value;l.hierarchicalVertexes.add(l)}let e=t,s=this.Gf;if(isNaN(s)&&(s=t.edges.count/t.vertexes.count),sMath.max(100,Math.sqrt(s*t.vertexes.count));)e=this.coarsenNetwork(e);let n=0;i=e.vertexes.iterator;let o=this.randomNumberGenerator;for(o===null&&(this.randomNumberGenerator=o=new RandomNumberGenerator(0));i.next();){i.value.idInCluster=n++;const l=10*(o.random()-.5),h=10*(o.random()-.5);this.isFixed(i.value)||(i.value.x=l,i.value.y=h);const a=i.value.hierarchicalVertexes.iterator;for(;a.next();)this.isFixed(a.value)||(a.value.x=l,a.value.y=h)}const r=this.computePairwiseDistances(e);this.XO(e,r,this.maxPrelayoutIterations,t.vertexes.count),this.qT(t,this.maxIterations)}computePairwiseDistances(t){const i=t.vertexes.count,e=new Array(i);for(let r=0;r0;){const l=o.shift(),h=l.vertexes.iterator;for(;h.next();){const a=h.value;n.has(a.idInCluster)||(n.set(a.idInCluster,n.get(l.idInCluster)+1),o.push(a))}}for(let l=0;l=0;m--)if(t[m].y>c.y&&t[m].x-c.xc.x&&t[m].y-c.ya+f){const u=s+o-h,d=n-a-f;return Geo.bw(u*u+d*d)}else if(n+rh+c)if(n>a+f){const u=s-h-c,d=n-a-f;return Geo.bw(u*u+d*d)}else if(n+ra+f?n-(a+f):n+rr-o;l?i.sort((m,g)=>m===null||g===null||m===g?0:m.centerX-g.centerX):i.sort((m,g)=>m===null||g===null||m===g?0:m.centerY-g.centerY);const h=this.Vf;let a=0,c=0,f=0;for(let m=0;mh||C-x>h){if(l)break;continue}if(k-M>h||M-k>h){if(!l)break;continue}const N=this.vN(g,P),T=2*g.charge,A=2*P.charge;if(N>1)a=T*A/(N*N),c=a*(x-C)/N,f=a*(k-M)/N;else{let D=this.randomNumberGenerator;D===null&&(this.randomNumberGenerator=D=new RandomNumberGenerator(0));const F=D.random(),R=D.random();if(x>C)c=Math.abs(P.bounds.right-g.bounds.x),c=T*A*(1+c)*F;else if(xM)f=Math.abs(P.bounds.bottom-g.bounds.y),f=T*A*(1+f)*R;else if(x1&&(a=.1*m.stiffness*(M-m.length),c=a*.5*(g.width+p.height)*(k-L)/M,f=a*.5*(g.width+p.height)*(b-C)/M),g.forceX-=c,g.forceY-=f,p.forceX+=c,p.forceY+=f}let d=0;for(let m=0;mthis.epsilonDistance*this.epsilonDistance}XO(t,i,e,s){const n=this.Dh+e,o=Math.sqrt(s);this.Vy=this.Ja*t.vertexes.count;const r=t.vertexes.toArray();let l=0,h=0,a=0;for(;this.Dh0){r[c].forceX=this.Vy*r[c].forceX/f,r[c].forceY=this.Vy*r[c].forceY/f,this.isFixed(r[c])||(r[c].x+=r[c].forceX,r[c].y+=r[c].forceY);const u=r[c].hierarchicalVertexes.iterator;for(;u.next();){const d=u.value;this.isFixed(d)||(d.centerX+=r[c].forceX,d.centerY+=r[c].forceY)}}l+=f*f}if(l>=h){if(a++,a>=5)break}else a=0;this.Vy*=.95}}moveVertex(t){let i=t.forceX,e=t.forceY;const s=this.moveLimit;return i<-s?i=-s:i>s&&(i=s),e<-s?e=-s:e>s&&(e=s),t.centerX+=i,t.centerY+=e,i*i+e*e}shouldInteract(t,i){return!0}moveFixedVertex(t){}commitLayout(){this.zy(),this.commitNodes(),this.isRouting&&this.commitLinks()}zy(){if(!this.setsPortSpots)return;const t=this.network.edges.iterator;for(;t.next();){const e=t.value.link;e!==null&&(e.fromSpot=Spot.Default,e.toSpot=Spot.Default)}}commitNodes(){let t=0,i=0;if(this.arrangesToOrigin){const n=Rect.l();this.Nw(this.network,n);const o=this.arrangementOrigin;t=o.x-n.x,i=o.y-n.y,Rect.s(n)}const e=Rect.l(),s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;(t!==0||i!==0)&&(e.a(n.bounds),e.x+=t,e.y+=i,n.bounds=e),n.commit()}Rect.s(e)}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}springStiffness(t){const i=t.stiffness;return isNaN(i)?this.zf:i}springLength(t){const i=t.length;return isNaN(i)?this.Xf:i}electricalCharge(t){const i=t.charge;return isNaN(i)?this.Kf:i}electricalFieldX(t,i){return 0}electricalFieldY(t,i){return 0}gravitationalMass(t){const i=t.mass;return isNaN(i)?this.Yf:i}gravitationalFieldX(t,i){return 0}gravitationalFieldY(t,i){return 0}isFixed(t){return t.isFixed}get currentIteration(){return this.Dh}get arrangementSpacing(){return this.ks}set arrangementSpacing(t){this.ks.equals(t)||(this.ks.a(t),this.invalidateLayout())}get arrangesToOrigin(){return this.wg}set arrangesToOrigin(t){this.wg!==t&&(Util.i(t,"boolean",ForceDirectedLayout,"arrangesToOrigin"),this.wg=t,this.invalidateLayout())}get setsPortSpots(){return this.Fn}set setsPortSpots(t){this.Fn!==t&&(Util.i(t,"boolean",ForceDirectedLayout,"setsPortSpots"),this.Fn=t,this.invalidateLayout())}get comments(){return this.Re}set comments(t){this.Re!==t&&(Util.i(t,"boolean",ForceDirectedLayout,"comments"),this.Re=t,this.invalidateLayout())}get maxPrelayoutIterations(){return this.xg}set maxPrelayoutIterations(t){this.xg!==t&&(Util.i(t,"number",ForceDirectedLayout,"maxPrelayoutIterations"),t>=0&&(this.xg=t,this.invalidateLayout()))}get maxIterations(){return this.bg}set maxIterations(t){this.bg!==t&&(Util.i(t,"number",ForceDirectedLayout,"maxIterations"),t>=0&&(this.bg=t,this.invalidateLayout()))}get epsilonDistance(){return this.kg}set epsilonDistance(t){this.kg!==t&&(Util.i(t,"number",ForceDirectedLayout,"epsilonDistance"),t>0&&(this.kg=t,this.invalidateLayout()))}get infinityDistance(){return this.Vf}set infinityDistance(t){this.Vf!==t&&(Util.i(t,"number",ForceDirectedLayout,"infinityDistance"),t>1&&(this.Vf=t,this.invalidateLayout()))}get moveLimit(){return this.Pg}set moveLimit(t){this.Pg!==t&&(Util.i(t,"number",ForceDirectedLayout,"moveLimit"),this.Pg=t,this.invalidateLayout())}get randomNumberGenerator(){return this.Sg}set randomNumberGenerator(t){this.Sg!==t&&(t!==null&&typeof t.random!="function"&&Util.o('ForceDirectedLayout.randomNumberGenerator must have a "random()" function on it: '+t),this.Sg=t)}get defaultSpringStiffness(){return this.zf}set defaultSpringStiffness(t){this.zf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultSpringStiffness"),this.zf=t,this.invalidateLayout())}get defaultSpringLength(){return this.Xf}set defaultSpringLength(t){this.Xf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultSpringLength"),this.Xf=t,this.invalidateLayout())}get defaultElectricalCharge(){return this.Kf}set defaultElectricalCharge(t){this.Kf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultElectricalCharge"),this.Kf=t,this.invalidateLayout())}get defaultGravitationalMass(){return this.Yf}set defaultGravitationalMass(t){this.Yf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultGravitationalMass"),this.Yf=t,this.invalidateLayout())}get defaultCommentSpringLength(){return this.Mg}set defaultCommentSpringLength(t){this.Mg!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultCommentSpringLength"),this.Mg=t,this.invalidateLayout())}get defaultCommentElectricalCharge(){return this.Ng}set defaultCommentElectricalCharge(t){this.Ng!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultCommentElectricalCharge"),this.Ng=t,this.invalidateLayout())}get prelayoutQuality(){return this.Gf}set prelayoutQuality(t){this.Gf!==t&&(Util.i(t,"number",ForceDirectedLayout,"prelayoutQuality"),this.Gf=t,this.invalidateLayout())}get prelayoutSpread(){return this.Ja}set prelayoutSpread(t){this.Ja!==t&&(Util.i(t,"number",ForceDirectedLayout,"prelayoutSpread"),this.Ja=t,this.invalidateLayout())}}class ForceDirectedNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new ForceDirectedVertex(this)}createEdge(){return new ForceDirectedEdge(this)}}class ForceDirectedVertex extends LayoutVertex{K1;Y1;G1;j1;H1;hierarchicalVertexes;idInCluster;constructor(t){super(t),this.K1=!1,this.Y1=NaN,this.G1=NaN,this.j1=0,this.H1=0,this.hierarchicalVertexes=new List,this.idInCluster=-1}get isFixed(){return this.K1}set isFixed(t){this.K1!==t&&(Util.i(t,"boolean",ForceDirectedVertex,"isFixed"),this.K1=t)}get charge(){return this.Y1}set charge(t){this.Y1!==t&&(Util.i(t,"number",ForceDirectedVertex,"charge"),this.Y1=t)}get mass(){return this.G1}set mass(t){this.G1!==t&&(Util.i(t,"number",ForceDirectedVertex,"mass"),this.G1=t)}get forceX(){return this.j1}set forceX(t){this.j1!==t&&(Util.i(t,"number",ForceDirectedVertex,"forceX"),this.j1=t)}get forceY(){return this.H1}set forceY(t){this.H1!==t&&(Util.i(t,"number",ForceDirectedVertex,"forceY"),this.H1=t)}}class ForceDirectedEdge extends LayoutEdge{q1;W1;constructor(t){super(t),this.q1=NaN,this.W1=NaN}get stiffness(){return this.q1}set stiffness(t){this.q1!==t&&(Util.i(t,"number",ForceDirectedEdge,"stiffness"),this.q1=t)}get length(){return this.W1}set length(t){this.W1!==t&&(Util.i(t,"number",ForceDirectedEdge,"length"),this.W1=t)}}class RandomNumberGenerator{I;R;Q;M;A;seed;constructor(t){t===void 0&&(t=42),this.seed=t,this.A=48271,this.M=2147483647,this.Q=this.M/this.A,this.R=this.M%this.A,this.I=1/this.M,this.random()}random(){const t=this.seed/this.Q,i=this.seed%this.Q,e=this.A*i-this.R*t;return e>0?this.seed=e:this.seed=e+this.M,this.seed*this.I}}var LayeredDigraphCycleRemove=(w=>(w[w.DepthFirst=0]="DepthFirst",w[w.Greedy=1]="Greedy",w[w.FromLayers=2]="FromLayers",w))(LayeredDigraphCycleRemove||{}),LayeredDigraphLayering=(w=>(w[w.OptimalLinkLength=10]="OptimalLinkLength",w[w.LongestPathSink=11]="LongestPathSink",w[w.LongestPathSource=12]="LongestPathSource",w))(LayeredDigraphLayering||{}),LayeredDigraphInit=(w=>(w[w.DepthFirstOut=20]="DepthFirstOut",w[w.DepthFirstIn=21]="DepthFirstIn",w[w.Naive=22]="Naive",w))(LayeredDigraphInit||{}),LayeredDigraphAggressive=(w=>(w[w.None=30]="None",w[w.Less=31]="Less",w[w.More=32]="More",w))(LayeredDigraphAggressive||{}),LayeredDigraphPack=(w=>(w[w.None=0]="None",w[w.Expand=1]="Expand",w[w.Straighten=2]="Straighten",w[w.Median=4]="Median",w[w.MaybeExpand=8]="MaybeExpand",w[w.All=15]="All",w))(LayeredDigraphPack||{}),LayeredDigraphAlign=(w=>(w[w.None=0]="None",w[w.UpperLeft=1]="UpperLeft",w[w.UpperRight=2]="UpperRight",w[w.LowerLeft=4]="LowerLeft",w[w.LowerRight=8]="LowerRight",w[w.All=15]="All",w))(LayeredDigraphAlign||{});class LayeredDigraphLayout extends Layout{Ps;Ji;S;jf;Hf;qf;$a;Wf;nr;Jf;Fn;St;Xy;Kt;Cg;Ss;ui;Qs;Ms;Ns;Ut;Lg;Za;Ag;_s;$f;or;Rn;vn;ON;constructor(t){super(),this.Ps=25,this.Ji=25,this.S=0,this.jf=0,this.Hf=10,this.qf=20,this.$a=4,this.Wf=31,this.nr=15,this.Jf=10,this.Fn=!0,this.St=-1,this.Xy=-1,this.Kt=-1,this.Cg=0,this.Ss=0,this.ui=null,this.Qs=null,this.Ms=null,this.Ns=null,this.Ut=null,this.Lg=0,this.Za=null,this.Ag=null,this._s=0,this.$f=null,this.or=new Point,this.Rn=[],this.Rn.length=100,this.vn=15,this.ON=0,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Ps=this.Ps,t.Ji=this.Ji,t.S=this.S,t.jf=this.jf,t.Hf=this.Hf,t.qf=this.qf,t.$a=this.$a,t.Wf=this.Wf,t.nr=this.nr,t.Jf=this.Jf,t.Fn=this.Fn,t.vn=this.vn}ri(t){t in LayeredDigraphAggressive?this.aggressiveOption=t:t in LayeredDigraphCycleRemove?this.cycleRemoveOption=t:t in LayeredDigraphInit?this.initializeOption=t:t in LayeredDigraphLayering?this.layeringOption=t:super.ri(t)}createNetwork(){return new LayeredDigraphNetwork(this)}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin),this.YO(),this.network.vertexes.count>0&&(this.network.deleteSelfEdges(),this.cycleRemoveOption!==2&&this.removeCycles(),this.GO(),this.cycleRemoveOption===2&&this.removeCycles(),this.jO(),this.HO(),this.qO(),this.reduceCrossings(),this.straightenAndPack(),this.updateParts()),this.network=null,this.isValidLayout=!0}linkMinLength(t){return 1}linkLengthWeight(t){return 1}linkStraightenWeight(t){const i=t.fromVertex.node||t.fromVertex.data,e=t.toVertex.node||t.toVertex.data;return i===null&&e===null?8:i===null||e===null?4:1}nodeMinLayerSpace(t,i){return t.node===null&&t.data===null?0:this.S===90||this.S===270?i?t.focus.y+10:t.bounds.height-t.focus.y+10:i?t.focus.x+10:t.bounds.width-t.focus.x+10}nodeMinColumnSpace(t,i){if(t.node===null&&t.data===null)return 0;const e=i?t.J1:t.$1;if(e!==null)return e;const s=this.S;return s===90||s===270?i?t.J1=t.focus.x/this.Ji+1|0:t.$1=(t.bounds.width-t.focus.x)/this.Ji+1|0:i?t.J1=t.focus.y/this.Ji+1|0:t.$1=(t.bounds.height-t.focus.y)/this.Ji+1|0}$i(){this.Za===null&&(this.Za=[]);let t=0;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;this.Za[t]=e.layer,t++,this.Za[t]=e.column,t++,this.Za[t]=e.index,t++}return this.Za}Ze(t){let i=0;const e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;s.layer=t[i],i++,s.column=t[i],i++,s.index=t[i],i++}}JT(t,i){const e=this.Fh(t),s=this.ui[t];(this.Ag===null||this.Ag.length=0){for(c=e[o].po,f=0;fk||d===k&&g>P)&&r++,bd||k===d&&P>g)&&r++)}if(i<=0){for(c=e[o].ir,f=0;fk||d===k&&m>b)&&r++,Pd||k===d&&b>m)&&r++)}for(n[o*s+o]=r,a=o+1;a=0){for(p=e[o].po,S=e[a].po,f=0;f=0&&(h=s[r].ir);let a,c=0,f=0;if(l!==null)for(let u=0;u=0&&(h=r.ir);let a=0,c=0;const f=r.near;f!==null&&f.layer===r.layer&&(a+=f.column-1,c++);let u;if(l!==null)for(let d=0;d=0&&(h=r.ir);let a=0;const c=[],f=r.near;f!==null&&f.layer===r.layer&&(c[a]=f.column-1,a++);let u;if(l!==null)for(let d=0;dm-g);const d=a>>1;a&1?n[o]=c[d]:n[o]=c[d-1]+c[d]>>1}}return this.Rh(t,e),n}Gy(t,i,e,s,n){if(t.component===e){t.component=i;let o=0,r=0;if(s){const l=t.destinationEdges;for(;l.next();){const h=l.value,a=h.toVertex;o=t.layer-a.layer,r=this.linkMinLength(h),o===r&&this.Gy(a,i,e,s,n)}}if(n){const l=t.sourceEdges;for(;l.next();){const h=l.value,a=h.fromVertex;o=a.layer-t.layer,r=this.linkMinLength(h),o===r&&this.Gy(a,i,e,s,n)}}}}IN(t,i,e,s,n){if(t.component===e){if(t.component=i,s){const o=t.destinationEdges;for(;o.next();){const l=o.value.toVertex;this.IN(l,i,e,s,n)}}if(n){const o=t.sourceEdges;for(;o.next();){const l=o.value.fromVertex;this.IN(l,i,e,s,n)}}}}removeCycles(){const t=this.network.edges.iterator;for(;t.next();){const i=t.value;i.rev=!1}switch(this.jf){default:case 1:this.JO();break;case 0:this.$O();break;case 2:this.ZO();break}}ZO(){const t=this.network,i=t.vertexes.iterator;let e=1/0;for(;i.next();){const s=i.value;e=Math.min(e,s.layer)}if(e<1/0){if(e<0)for(i.reset();i.next();){const r=i.value;r.layer-=e}const s=[];for(i.reset();i.next();){const r=i.value,l=s[r.layer];l===void 0?s[r.layer]=[r]:l.push(r)}let n=0;for(let r=0;r0)for(let h=0;hh.index&&(t.reverseEdge(r),r.rev=!0)}}QO(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.Zi)return e}return null}ZT(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.Zi){let s=!0;const n=e.destinationEdges;for(;n.next();)if(n.value.toVertex.Zi){s=!1;break}if(s)return e}}return null}QT(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.Zi){let s=!0;const n=e.sourceEdges;for(;n.next();)if(n.value.fromVertex.Zi){s=!1;break}if(s)return e}}return null}_O(t){let i=null,e=0;const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;if(n.Zi){let o=0;const r=n.destinationEdges;for(;r.next();)r.value.toVertex.Zi&&o++;let l=0;const h=n.sourceEdges;for(;h.next();)h.value.fromVertex.Zi&&l++;(i===null||ec&&this.Gy(h,e,-1,!0,!1)}for(this.Gy(t,s,-1,!0,!0);t.component!==e;){let r=0,l=1/0,h=0,a=null;const c=this.network.vertexes.iterator;for(;c.next();){const f=c.value;if(f.component===s){let u=0,d=!1;const m=f.po;o=m.length;for(let p=0;p0){for(i.reset();i.next();){const f=i.value;f.component===s&&(f.layer+=l)}t.component=e}else a.component=e}}sI(t){const i=this.network.vertexes.iterator;for(;i.next();){const n=i.value;n.component=-1}const e=0,s=1;for(this.Gy(t,s,-1,!0,!1);t.component!==e;){let n=0,o=1/0,r=0,l=null;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value;if(a.component===s){let c=0,f=!1;const u=a.po;let d=u.length;for(let g=0;gr)&&!f&&(l=a,r=c)}}if(n<0){for(i.reset();i.next();){const a=i.value;a.component===s&&(a.layer-=o)}t.component=e}else l.component=e}}jO(){const t=this.network,i=[],e=t.edges.iterator;for(;e.next();){const s=e.value;s.valid=!1,i.push(s)}for(let s=0;sb&&f>0){for(n.valid=!1,y=t.createVertex(),y.node=null,y.Q1=2,y.layer=f-1,x&&kb&&f>0;)y=t.createVertex(),y.node=null,y.Q1=3,y.layer=f-1,x&&kt[this.Ss]&&(this.Xy=t[e]-1,this.Ss=e),t[e]{o.index=this.ui[s],this.ui[s]++})}}lI(){let t=null;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;if(e.near&&(t===null&&(t=new Map),e.layer===e.near.layer)){const s=t.get(e.near)||[];s.push(e),t.set(e.near,s)}}for(let e=this.St;e>=0;e--)for(i.reset();i.next();){const s=i.value;s.layer===e&&s.index===-1&&this.oD(s,t)}}oD(t,i){if(t.near)return;const e=t.layer;if(t.index=this.ui[e],this.ui[e]++,i){const o=i.get(t);Array.isArray(o)&&o.forEach(r=>{r.index=this.ui[e],this.ui[e]++})}const s=t.ir;let n=!0;for(;n;){n=!1;for(let o=0;ol.portFromColOffset&&(n=!0,s[o]=l,s[o+1]=r)}}for(let o=0;o{a.index=this.ui[e],this.ui[e]++})}const s=t.po;let n=!0,o=0;for(;n;)for(n=!1,o=0;oa.portToColOffset&&(n=!0,s[o]=a,s[o+1]=h)}let r,l;for(o=0;o=0;s--)this.tk(s,-1),this.ls(s,-1,!1,-1);n=this.countCrossings(),n=0;s--)this.tk(s,0),this.ls(s,0,!1,0);n=this.countCrossings(),n=0;r--)for(l=0;l<=r;l++){for(o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,1,!1,1)||o;for(n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,-1,!1,-1)||o;for(n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,0,!1,0)||o;for(n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,0,!1,0)||o;n>=t?this.Ze(i):(t=n,i=this.$i())}break;default:case 31:for(r=this.St,l=0,h=t+1;(a=this.countCrossings())=l;s--)o=this.ls(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,1,!1,1)||o;for(n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,-1,!1,-1)||o;for(n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,0,!1,0)||o;for(n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,0,!1,0)||o;n>=t?this.Ze(i):(t=n,i=this.$i())}break}this.Ze(i)}tk(t,i){let e=0,s=!1;const n=this.Fh(t),o=this.ui[t],r=this.$T(t,i),l=this.Yy(t,i);for(e=0;e0)for(h=[],l=0;ll+1&&(m+=4*(v-l),g+=4*(v-(l+1)))}}const E=n[l].destinationEdges.iterator;if(e&&s>=0)for(;E.next();){const q=E.value;O=q.toVertex,q.valid&&O.layer!==t&&(N=this.linkStraightenWeight(q),T=q.portFromColOffset,A=q.portToColOffset,F=O.column,C+=(Math.abs(p+T-(F+A))+1)*N,M+=(Math.abs(L+T-(F+A))+1)*N)}for(E.reset();E.next();){const q=E.value;if(O=q.toVertex,q.valid&&O.layer===t){for(B=0;Bl+1&&(m+=4*(v-(l+1)),g+=4*(v-l))}}const U=n[l+1].destinationEdges.iterator;if(e&&s>=0)for(;U.next();){const q=U.value;O=q.toVertex,q.valid&&O.layer!==t&&(N=this.linkStraightenWeight(q),T=q.portFromColOffset,A=q.portToColOffset,F=O.column,C+=(Math.abs(y+T-(F+A))+1)*N,M+=(Math.abs(S+T-(F+A))+1)*N)}for(U.reset();U.next();){const q=U.value;if(O=q.toVertex,q.valid&&O.layer===t){for(B=0;B1e3&&s&&(e=!1),e){const n=[];let o=0;for(o=0;o<=this.St;o++)n[o]=0;let r=0;const l=this.network.vertexes.iterator;for(;l.next();){const a=l.value;t=a.layer,r=a.column;const c=this.nodeMinColumnSpace(a,!1);n[t]=Math.max(n[t],r+c)}const h=8;for(l.reset();l.next();){const a=l.value;t=a.layer,r=a.column,a.column=((this.Kt-n[t])*h>>1)+r*h}this.Kt*=h}if(this.nr&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Tg(t,-1)||i;i=this.Tg(this.Ss,0)||i,n++}}if(this.nr&4){for(t=this.Ss+1;t<=this.St;t++)this.BN(t,1);for(t=this.Ss-1;t>=0;t--)this.BN(t,-1);this.BN(this.Ss,0)}if(e&&(this.lD(-1),this.lD(1)),this.nr&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Tg(t,0)||i;n++}}}Tg(t,i){let e=!1;for(;this.cI(t,i);)e=!0;return e}cI(t,i){let e=0;const s=this.Fh(t),n=this.ui[t],o=this.Yy(t,-1);if(i>0)for(e=0;ec+this.nodeMinColumnSpace(s[e-1],!1)?u=a-1:u=a;let d=0;e+1>=n||s[e+1].column-a-1>f+this.nodeMinColumnSpace(s[e+1],!0)?d=a+1:d=a;let m=0,g=0,p=0,y=0,x=0,k=0;if(i<=0){const M=s[e].sourceEdges.iterator;for(;M.next();){const N=M.value,T=N.fromVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const A=T.column;m+=(Math.abs(a+k-(A+x))+1)*y,g+=(Math.abs(u+k-(A+x))+1)*y,p+=(Math.abs(d+k-(A+x))+1)*y}}}if(i>=0){const M=s[e].destinationEdges.iterator;for(;M.next();){const N=M.value,T=N.toVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const A=T.column;m+=(Math.abs(a+x-(A+k))+1)*y,g+=(Math.abs(u+x-(A+k))+1)*y,p+=(Math.abs(d+x-(A+k))+1)*y}}}let b=0,P=0,S=0;const L=o[s[e].index],C=r[s[e].index];L!==-1&&(b+=Math.abs(L-a),P+=Math.abs(L-u),S+=Math.abs(L-d)),C!==-1&&(b+=Math.abs(C-a),P+=Math.abs(C-u),S+=Math.abs(C-d)),g=r[e]?u=p:g<=r[e]&&(u=g)),u!==a&&(l=!0,h=!0,s[e].column=u)}return this.Rh(t,s),this.Ky(),l}fI(){for(let t=0;t<=this.Kt;t++)for(;this.uI(t,1););this.Ky()}uI(t,i){let e=!0;const s=this.network.vertexes.iterator;for(;s.next();){const o=s.value,r=this.nodeMinColumnSpace(o,!0),l=this.nodeMinColumnSpace(o,!1);if(o.column-r<=t&&o.column+l>=t){e=!1;break}}let n=!1;if(e){if(i>0)for(s.reset();s.next();){const o=s.value;o.column>t&&(o.column-=1,n=!0)}if(i<0)for(s.reset();s.next();){const o=s.value;o.column0&&(e=t+1),i<0&&(e=t-1);let s=0;const n=[],o=[];for(s=0;s<=this.St;s++)n[s]=!1,o[s]=!1;const r=this.network.vertexes.iterator;for(;r.next();){const a=r.value,c=a.column-this.nodeMinColumnSpace(a,!0),f=a.column+this.nodeMinColumnSpace(a,!1);c<=t&&f>=t&&(n[a.layer]=!0),c<=e&&f>=e&&(o[a.layer]=!0)}let l=!0,h=!1;for(s=0;s<=this.St;s++)l=l&&!(n[s]&&o[s]);if(l){if(i>0)for(r.reset();r.next();){const a=r.value;a.column>t&&(a.column-=1,h=!0)}if(i<0)for(r.reset();r.next();){const a=r.value;a.column0)for(i=0;i<=this.Kt;i++)for(e=this.$i(),s=this.Z1(!0),n=s+1;ss?this.Ze(e):o=0;i--)for(e=this.$i(),s=this.Z1(!0),n=s+1;ss?this.Ze(e):o0)for(e.reset();e.next();){const c=e.value;c.column-this.nodeMinColumnSpace(c,!0)<=t&&(c.component=this._s)}if(i<0)for(e.reset();e.next();){const c=e.value;c.column+this.nodeMinColumnSpace(c,!1)>=t&&(c.component=this._s)}for(this._s++,e.reset();e.next();){const c=e.value;c.component===-1&&(this.IN(c,this._s,-1,!0,!0),this._s++)}let s=0;const n=[];for(s=0;s0)for(let f=0;f0;f--)o[c*(this.Kt+1)+f]!==-1&&o[c*(this.Kt+1)+f-1]!==-1&&o[c*(this.Kt+1)+f]!==o[c*(this.Kt+1)+f-1]&&(n[o[c*(this.Kt+1)+f]*this._s+o[c*(this.Kt+1)+f-1]]=!0)}const r=[];for(s=0;s0)for(e.reset();e.next();){const c=e.value;r[c.component]&&(c.column-=1,a=!0)}if(i<0)for(e.reset();e.next();){const c=e.value;r[c.component]&&(c.column+=1,a=!0)}return a}aI(){const t=Util.nt(),i=this.$f.length;for(let u=0;u<=i;u++)t[u]=[];const e=this.network.vertexes.iterator;for(;e.next();){const u=e.value,d=i-u.layer,m=t[d];m[u.index]=u}const s=new GSet;this.mI(t,s);let n=null,o=null,r=null,l=null;const h=(this.vn&1)!==0,a=(this.vn&2)!==0,c=(this.vn&4)!==0,f=(this.vn&8)!==0;h&&(this.sl(t,s,!0),n=this.ik(t,!0,!1)),t.reverse(),c&&(this.sl(t,s,!1),r=this.ik(t,!1,!1));for(const u of t)u.reverse();f&&(this.sl(t,s,!1),l=this.ik(t,!1,!0)),t.reverse(),a&&(this.sl(t,s,!0),o=this.ik(t,!0,!0)),Util.tt(t),this.pI(n,o,r,l),this.network.vertexes.each(u=>{const d=u,m=Util.nt();h&&m.push(n.get(d)),a&&m.push(o.get(d)),c&&m.push(r.get(d)),f&&m.push(l.get(d)),m.sort((k,b)=>k-b);const g=m.length,p=Math.floor((g-1)/2),y=Math.ceil((g-1)/2),x=(m[p]+m[y])/2;Util.tt(m),d.he=x})}mI(t,i){const e=t.length;for(let s=1;sf)&&i.add(m)}o++}n=f}}}}yI(t){if(t.node===null){const i=t.getProperSourceVertexes();if(i.length>0)return i[0].node===null}return!1}sl(t,i,e){this.wI(t);for(const s of t){let n=-1;for(const o of s){const r=e?o.getProperSourceVertexes():o.getProperDestinationVertexes(),l=r.length;if(l>0){r.sort((a,c)=>a.vh-c.vh);const h=(l-1)/2;for(let a=Math.floor(h),c=Math.ceil(h);a<=c;a++)if(o.On===o){const f=r[a];let u;e?u=f.getDestinationEdge(o):u=o.getDestinationEdge(f),!i.has(u)&&n0){const c=this.fD(a,t),f=s?c.width:c.height,u=a.Qe.Qf+a.he+a.In-(c.he+c.In+f+this.columnSpacing);c.Qe.Qf=Math.min(c.Qe.Qf,u)}h=a.vh+1}while(l0){const s=this.fD(e,i),n=s.Qa;this.cD(n,i),t.Qe===t&&(t.Qe=n.Qe);const o=this.S===90||this.S===270?s.width:s.height;if(t.Qe===n.Qe){const r=n.he+s.In+o-e.In+this.columnSpacing;t.he=Math.max(t.he,r)}}e=e.On}while(e!==t);for(;e.On!==t;)e=e.On,e.he=t.he,e.Qe=t.Qe}fD(t,i){const e=t.aD,s=t.vh;return s<1&&Util.o("Could not determine previous vertex in layer"),i[e][s-1]}pI(...t){let i=-1;const e=Util.nt(),s=Util.nt();let n=1/0;for(let o=0;o<4;o++){if(!t[o])continue;const r=this.bI(t[o],e,s,o);r{r.set(h.key,h.value+l)})}Util.tt(e),Util.tt(s)}bI(t,i,e,s){if(!t||t.count===0)return i[s]=0,e[s]=0,1/0;let n=1/0,o=-1/0;return t.each(r=>{const l=r.key,h=r.value,a=this.S===90||this.S===270?l.width:l.height;ho&&(o=h+a)}),i[s]=n,e[s]=o,o-n}commitLayout(){this.zy(),this.commitNodes(),this.UN(),this.isRouting&&this.commitLinks()}zy(){if(!this.setsPortSpots)return;const t=this._1(!0),i=this._1(!1),e=this.network.edges.iterator;for(;e.next();){const n=e.value.link;n!==null&&(n.fromSpot=t,n.toSpot=i)}}_1(t){return this.S===270?t?Spot.MiddleTop:Spot.MiddleBottom:this.S===90?t?Spot.MiddleBottom:Spot.MiddleTop:this.S===180?t?Spot.MiddleLeft:Spot.MiddleRight:t?Spot.MiddleRight:Spot.MiddleLeft}commitNodes(){this.Qs=[],this.Ms=[],this.Ns=[],this.Ut=[];for(let d=0;d<=this.St;d++)this.Qs[d]=0,this.Ms[d]=0,this.Ns[d]=0,this.Ut[d]=0;const t=this.network.vertexes.iterator;for(;t.next();){const d=t.value,m=d.layer;this.Qs[m]=Math.max(this.Qs[m],this.nodeMinLayerSpace(d,!0)),this.Ms[m]=Math.max(this.Ms[m],this.nodeMinLayerSpace(d,!1))}let i=0;const e=this.Ps;for(let d=0;d<=this.St;d++){let m=e;this.Qs[d]+this.Ms[d]<=0&&(m=0),d>0&&(i+=m/2),this.S===90||this.S===0?(i+=this.Ms[d],this.Ns[d]=i,i+=this.Qs[d]):(i+=this.Qs[d],this.Ns[d]=i,i+=this.Ms[d]),d=0;n--)this.S===270?n===0?e.push(new Rect(0,0,s,Math.abs(this.Ut[0]))):e.push(new Rect(0,this.Ut[n-1],s,Math.abs(this.Ut[n-1]-this.Ut[n]))):this.S===90?n===0?e.push(new Rect(0,this.Ut[0],s,Math.abs(this.Ut[0]-t))):e.push(new Rect(0,this.Ut[n],s,Math.abs(this.Ut[n-1]-this.Ut[n]))):this.S===180?n===0?e.push(new Rect(0,0,Math.abs(this.Ut[0]),s)):e.push(new Rect(this.Ut[n-1],0,Math.abs(this.Ut[n-1]-this.Ut[n]),s)):n===0?e.push(new Rect(this.Ut[0],0,Math.abs(this.Ut[0]-t),s)):e.push(new Rect(this.Ut[n],0,Math.abs(this.Ut[n-1]-this.Ut[n]),s));this.commitLayers(e,this.or)}commitLayers(t,i){}commitLinks(){const t=this.network.edges.iterator;let i;for(;t.next();)i=t.value.link,i!==null&&(i.startRoute(),i.clearPoints(),i.commitRoute());for(t.reset();t.next();)i=t.value.link,i!==null&&i.updateRoute();for(t.reset();t.next();){const e=t.value;if(i=e.link,i===null||i.pointsCount===0)continue;i.startRoute();const s=i;let n=s.fromNode,o=s.toNode,r=s.fromPort,l=s.toPort;if(n!==null){const N=n.findVisibleNode();N!==null&&N!==n&&(n=N,r=N.port)}if(o!==null){const N=o.findVisibleNode();N!==null&&N!==o&&(o=N,l=N.port)}const h=i.computeSpot(!0,r),a=i.computeSpot(!1,l);let c=e.fromVertex,f=e.toVertex;if(e.valid){if(i.curve===9&&i.pointsCount===4)if(c.column===f.column&&this.alignOption===0){const N=i.getLinkPoint(n,r,h,!0,!1,o,l),T=i.getLinkPoint(o,l,a,!1,!1,n,r);N.isReal()||N.set(n.actualBounds.center),T.isReal()||T.set(o.actualBounds.center),i.clearPoints(),i.addPointAt(N.x,N.y),i.addPointAt((2*N.x+T.x)/3,(2*N.y+T.y)/3),i.addPointAt((N.x+2*T.x)/3,(N.y+2*T.y)/3),i.addPointAt(T.x,T.y)}else{let N=!1,T=!1;if(r!==null&&h===Spot.None&&(N=!0),l!==null&&a===Spot.None&&(T=!0),N||T){let A=null;N&&(A=i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0),A.isReal()||A.set(n.actualBounds.center),i.setPointAt(0,A.x,A.y));let D=null;if(T&&(D=i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(0),!1),D.isReal()||D.set(o.actualBounds.center),i.setPointAt(3,D.x,D.y)),A){const F=i.getPoint(2);i.setPointAt(1,(A.x*2+F.x)/3,(A.y*2+F.y)/3)}if(D){const F=i.getPoint(1);i.setPointAt(2,(D.x*2+F.x)/3,(D.y*2+F.y)/3)}}}i.commitRoute();continue}if(c.layer===f.layer){i.commitRoute();continue}let u=!1,d=!1;const m=this.Ps;let g=0,p=i.firstPickIndex+1;if(i.isOrthogonal)d=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3);else if(i.curve===9)u=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3),g===4&&(p=2);else{g=i.pointsCount;const N=h===Spot.None,T=a===Spot.None;g>2&&N&&T?i.points.removeRange(1,g-2):g>3&&N&&!T?i.points.removeRange(1,g-3):g>3&&!N&&T?i.points.removeRange(2,g-2):g>4&&!N&&!T&&i.points.removeRange(2,g-3)}let y,x,k=0,b=0,P=0,S=0,L=0,C=0,M=0;if(e.rev){let N=0;for(;f!==null&&c!==f;){y=null,x=null;const T=f.sourceEdges.iterator;for(;T.next();){const A=T.value;if(A.link===e.link&&(y=A.fromVertex,x=A.toVertex,y.node===null))break}if(y===null)break;if(y!==c)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=y.centerX,S=y.centerY,d)this.S===180||this.S===0?p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,k,S)):(x!==null?x.centerY:b)!==S&&(L=this.Ut[y.layer-1]+this.or.x,i.insertPointAt(p++,L,b),i.insertPointAt(p++,L,S)):p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,P,b)):(x!==null?x.centerX:k)!==P&&(L=this.Ut[y.layer-1]+this.or.y,i.insertPointAt(p++,k,L),i.insertPointAt(p++,P,L));else if(p===i.firstPickIndex+1)if(C=Math.max(10,this.Qs[f.layer]),M=Math.max(10,this.Ms[f.layer]),u)this.S===180?P<=f.bounds.x?(N=f.bounds.x,i.insertPointAt(p++,N-C,S),i.insertPointAt(p++,N,S),i.insertPointAt(p++,N+M,S)):(i.insertPointAt(p++,P-C,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P+M,S)):this.S===90?S>=f.bounds.bottom?(N=f.bounds.y+f.bounds.height,i.insertPointAt(p++,P,N+M),i.insertPointAt(p++,P,N),i.insertPointAt(p++,P,N-C)):(i.insertPointAt(p++,P,S+M),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S-C)):this.S===270?S<=f.bounds.y?(N=f.bounds.y,i.insertPointAt(p++,P,N-C),i.insertPointAt(p++,P,N),i.insertPointAt(p++,P,N+M)):(i.insertPointAt(p++,P,S-C),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S+M)):this.S===0&&(P>=f.bounds.right?(N=f.bounds.x+f.bounds.width,i.insertPointAt(p++,N+M,S),i.insertPointAt(p++,N,S),i.insertPointAt(p++,N-C,S)):(i.insertPointAt(p++,P+M,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P-C,S)));else{i.insertPointAt(p++,k,b);let A=0;this.S===180||this.S===0?((this.S===180?P>=f.bounds.right:P<=f.bounds.x)&&(A=(this.S===0?-C:M)/2),i.insertPointAt(p++,k+A,S)):((this.S===270?S>=f.bounds.bottom:S<=f.bounds.y)&&(A=(this.S===90?-C:M)/2),i.insertPointAt(p++,P,b+A)),i.insertPointAt(p++,P,S)}else C=Math.max(10,this.Qs[y.layer]),M=Math.max(10,this.Ms[y.layer]),u?this.S===180?(i.insertPointAt(p++,P-C-m,S),i.insertPointAt(p++,Math.min(P-C+m/2,P),S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,Math.max(P+M-m/2,P),S),i.insertPointAt(p++,P+M+m,S)):this.S===90?(i.insertPointAt(p++,P,S+M+m),i.insertPointAt(p++,P,Math.max(S+M-m/2,S)),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,Math.min(S-C+m/2,S)),i.insertPointAt(p++,P,S-C-m)):this.S===270?(i.insertPointAt(p++,P,S-C-m),i.insertPointAt(p++,P,Math.min(S-C+m/2,S)),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,Math.max(S+M-m/2,S)),i.insertPointAt(p++,P,S+M+m)):(i.insertPointAt(p++,P+M+m,S),i.insertPointAt(p++,Math.max(P+M-m/2,P),S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,Math.min(P-C+m/2,P),S),i.insertPointAt(p++,P-C-m,S)):(this.S===180||this.S===90||this.S,i.insertPointAt(p++,P,S));f=y}if(l===null||h!==Spot.None||d)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=i.getPoint(p).x,S=i.getPoint(p).y,d){const T=this.Ms[c.layer];let A=0;this.S===180||this.S===0?(A=b,A>=c.bounds.y&&A<=c.bounds.bottom&&(this.S===180?P>=c.bounds.x:P<=c.bounds.right)&&(N=c.centerX+(this.S===180?-T:T),A=c.bounds.x&&A<=c.bounds.right&&(this.S===270?S>=c.bounds.y:S<=c.bounds.bottom)&&(N=c.centerY+(this.S===270?-T:T),A=c.bounds.x?(N=c.bounds.x+c.bounds.width,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N+M,b)):this.S===90&&S<=c.bounds.bottom?(N=c.bounds.y,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N-C)):this.S===270&&S>=c.bounds.y?(N=c.bounds.y+c.bounds.height,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N+M)):this.S===0&&P<=c.bounds.right&&(N=c.bounds.x,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N-C,b));else{C=Math.max(10,this.Qs[c.layer]),M=Math.max(10,this.Ms[c.layer]);let T=0;this.S===180||this.S===0?((this.S===180?P<=c.bounds.x:P>=c.bounds.right)&&(T=(this.S===0?M:-C)/2),i.insertPointAt(p++,P+T,b)):((this.S===270?S<=c.bounds.y:S>=c.bounds.bottom)&&(T=(this.S===90?M:-C)/2),i.insertPointAt(p++,k,S+T)),i.insertPointAt(p++,P,S)}}else{for(;c!==null&&c!==f;){y=null,x=null;const N=c.destinationEdges.iterator;for(;N.next();){const T=N.value;if(T.link===e.link&&(y=T.toVertex,x=T.fromVertex,x.node!==null&&(x=null),y.node===null))break}if(y===null)break;y!==f&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=y.centerX,S=y.centerY,d?this.S===180||this.S===0?(x!==null?x.centerY:b)!==S&&(L=this.Ut[y.layer]+this.or.x,p===i.firstPickIndex+1&&(this.S===0?L=Math.max(L,k):L=Math.min(L,k)),i.insertPointAt(p++,L,b),i.insertPointAt(p++,L,S)):(x!==null?x.centerX:k)!==P&&(L=this.Ut[y.layer]+this.or.y,p===i.firstPickIndex+1&&(this.S===90?L=Math.max(L,b):L=Math.min(L,b)),i.insertPointAt(p++,k,L),i.insertPointAt(p++,P,L)):(C=Math.max(10,this.Qs[y.layer]),M=Math.max(10,this.Ms[y.layer]),u?this.S===180?(i.insertPointAt(p++,P+M+m,S),i.insertPointAt(p++,Math.max(P+M-m/2,P),S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,Math.min(P-C+m/2,P),S),i.insertPointAt(p++,P-C-m,S)):this.S===90?(i.insertPointAt(p++,P,S-C-m),i.insertPointAt(p++,P,Math.min(S-C+m/2,S)),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,Math.max(S+M-m/2,S)),i.insertPointAt(p++,P,S+M+m)):this.S===270?(i.insertPointAt(p++,P,S+M+m),i.insertPointAt(p++,P,Math.max(S+M-m/2,S)),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,Math.min(S-C+m/2,S)),i.insertPointAt(p++,P,S-C-m)):(i.insertPointAt(p++,P-C-m,S),i.insertPointAt(p++,Math.min(P-C+m/2,P),S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,Math.max(P+M-m/2,P),S),i.insertPointAt(p++,P+M+m,S)):this.S===180?(i.insertPointAt(p++,P+M,S),i.insertPointAt(p++,P-C,S)):this.S===90?(i.insertPointAt(p++,P,S-C),i.insertPointAt(p++,P,S+M)):this.S===270?(i.insertPointAt(p++,P,S+M),i.insertPointAt(p++,P,S-C)):(i.insertPointAt(p++,P-C,S),i.insertPointAt(p++,P+M,S)))),c=y}d&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=i.getPoint(p).x,S=i.getPoint(p).y,this.S===180||this.S===0?b!==S&&(this.S===0?L=Math.min(Math.max((P+k)/2,this.Ut[f.layer]+this.or.x),P):L=Math.max(Math.min((P+k)/2,this.Ut[f.layer]+this.or.x),P),i.insertPointAt(p++,L,b),i.insertPointAt(p++,L,S)):k!==P&&(this.S===90?L=Math.min(Math.max((S+b)/2,this.Ut[f.layer]+this.or.y),S):L=Math.max(Math.min((S+b)/2,this.Ut[f.layer]+this.or.y),S),i.insertPointAt(p++,k,L),i.insertPointAt(p++,P,L)))}if(s!==null&&u&&i.pointsCount>=4){if(r!==null){const N=h===Spot.None?i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0):i.getPoint(0);if(h===Spot.None){const T=i.getPoint(2),A=i.getPoint(3);this.direction===90||this.direction===270?(i.setPointAt(1,(N.x+T.x)/2,T.y),i.setPointAt(2,A.x,(T.y+A.y)/2)):(i.setPointAt(1,T.x,(N.y+T.y)/2),i.setPointAt(2,(T.x+A.x)/2,A.y))}N.isReal()||N.set(n.actualBounds.center),i.setPointAt(0,N.x,N.y)}if(l!==null){const N=a===Spot.None?i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(i.pointsCount-4),!1):i.getPoint(i.pointsCount-1);if(a===Spot.None){const T=i.getPoint(i.pointsCount-3),A=i.getPoint(i.pointsCount-4);this.direction===90||this.direction===270?(i.setPointAt(i.pointsCount-2,(N.x+T.x)/2,T.y),i.setPointAt(i.pointsCount-2,A.x,(T.y+A.y)/2)):(i.setPointAt(i.pointsCount-2,T.x,(N.y+T.y)/2),i.setPointAt(i.pointsCount-3,(T.x+A.x)/2,A.y))}N.isReal()||N.set(o.actualBounds.center),i.setPointAt(i.pointsCount-1,N.x,N.y)}}i.commitRoute(),e.commit()}}YO(){this.Xy=-1,this.Cg=0,this.Ss=0,this.Za=null,this.Ag=null,this.$f=null;for(let t=0;t=this.Rn.length){const n=[];for(let o=0;o=0&&(this.Ps=t,this.invalidateLayout()))}get columnSpacing(){return this.Ji}set columnSpacing(t){this.Ji!==t&&(Util.i(t,"number",LayeredDigraphLayout,"columnSpacing"),t>0&&(this.Ji=t,this.invalidateLayout()))}get direction(){return this.S}set direction(t){this.S!==t&&(Util.i(t,"number",LayeredDigraphLayout,"direction"),t===0||t===90||t===180||t===270?(this.S=t,this.invalidateLayout()):Util.o("LayeredDigraphLayout.direction must be 0, 90, 180, or 270"))}get cycleRemoveOption(){return this.jf}set cycleRemoveOption(t){this.jf!==t&&(t===1||t===0||t===2)&&(this.jf=t,this.invalidateLayout())}get layeringOption(){return this.Hf}set layeringOption(t){this.Hf!==t&&(t===10||t===11||t===12)&&(this.Hf=t,this.invalidateLayout())}get initializeOption(){return this.qf}set initializeOption(t){this.qf!==t&&(t===20||t===21||t===22)&&(this.qf=t,this.invalidateLayout())}get iterations(){return this.$a}set iterations(t){this.$a!==t&&t>=0&&(this.$a=t,this.invalidateLayout())}get aggressiveOption(){return this.Wf}set aggressiveOption(t){this.Wf!==t&&(t===30||t===31||t===32)&&(this.Wf=t,this.invalidateLayout())}get packOption(){return this.nr}set packOption(t){this.nr!==t&&(Util.i(t,"number",LayeredDigraphLayout,"packOption"),t>=0&&t<8&&(this.nr=t,this.invalidateLayout()))}get packIterations(){return this.Jf}set packIterations(t){this.Jf=t}get alignOption(){return this.vn}set alignOption(t){this.vn!==t&&(Util.i(t,"number",LayeredDigraphLayout,"align"),t>=0&&t<16&&(this.vn=t,this.invalidateLayout()))}get setsPortSpots(){return this.Fn}set setsPortSpots(t){this.Fn!==t&&(Util.i(t,"boolean",LayeredDigraphLayout,"setsPortSpots"),this.Fn=t,this.invalidateLayout())}get maxLayer(){return this.St}get maxIndex(){return this.Xy}get maxColumn(){return this.Kt}get minIndexLayer(){return this.Cg}get maxIndexLayer(){return this.Ss}static CycleDepthFirst=0;static CycleGreedy=1;static CycleFromLayers=2;static LayerOptimalLinkLength=10;static LayerLongestPathSink=11;static LayerLongestPathSource=12;static InitDepthFirstOut=20;static InitDepthFirstIn=21;static InitNaive=22;static AggressiveNone=30;static AggressiveLess=31;static AggressiveMore=32;static PackNone=0;static PackExpand=1;static PackStraighten=2;static PackMedian=4;static PackAll=15;static AlignNone=0;static AlignUpperLeft=1;static AlignUpperRight=2;static AlignLowerLeft=4;static AlignLowerRight=8;static AlignAll=15}class LayeredDigraphNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new LayeredDigraphVertex(this)}createEdge(){return new LayeredDigraphEdge(this)}}class LayeredDigraphVertex extends LayoutVertex{Wo;Uo;Dt;ek;sk;Zi;Zf;jn;Q1;J1;$1;Qa;On;aD;vh;Qe;Qf;he;In;jy=null;Hy=null;qy=null;Wy=null;constructor(t){super(t),this.Wo=-1,this.Uo=-1,this.Dt=-1,this.ek=NaN,this.sk=null,this.Zi=!1,this.Zf=NaN,this.jn=NaN,this.Q1=0,this.J1=null,this.$1=null}static uD(t,i){return t.index-i.index}getProperSourceEdges(){if(!this.qy){const t=[];for(const i of this.po){const e=i;e.valid&&t.push(e)}this.qy=t}return this.qy}getProperDestinationEdges(){if(!this.Wy){const t=[];for(const i of this.ir){const e=i;e.valid&&t.push(e)}this.Wy=t}return this.Wy}getDestinationEdge(t){const i=this.getProperDestinationEdges();for(const e of i)if(e.toVertex===t)return e;Util.o("Unable to find destination edge to given vertex")}getProperSourceVertexes(){if(!this.jy){const t=[];for(const i of this.po){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.fromVertex)}t.sort(LayeredDigraphVertex.uD),this.jy=t}return this.jy}getProperDestinationVertexes(){if(!this.Hy){const t=[];for(const i of this.ir){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.toVertex)}t.sort(LayeredDigraphVertex.uD),this.Hy=t}return this.Hy}addSourceEdge(t){super.addSourceEdge(t),this.jy=null,this.qy=null}deleteSourceEdge(t){super.deleteSourceEdge(t),this.jy=null,this.qy=null}addDestinationEdge(t){super.addDestinationEdge(t),this.Hy=null,this.Wy=null}deleteDestinationEdge(t){super.deleteDestinationEdge(t),this.Hy=null,this.Wy=null}get layer(){return this.Wo}set layer(t){this.Wo!==t&&(Util.i(t,"number",LayeredDigraphVertex,"layer"),this.Wo=t)}get column(){return this.Uo}set column(t){this.Uo!==t&&(Util.i(t,"number",LayeredDigraphVertex,"column"),this.Uo=t)}get index(){return this.Dt}set index(t){this.Dt!==t&&(Util.i(t,"number",LayeredDigraphVertex,"index"),this.Dt=t)}get component(){return this.ek}set component(t){this.ek!==t&&(Util.i(t,"number",LayeredDigraphVertex,"component"),this.ek=t)}get near(){return this.sk}set near(t){this.sk!==t&&(this.sk=t)}}class LayeredDigraphEdge extends LayoutEdge{Zi;nk;ok;rk;lk;hk;ak;constructor(t){super(t),this.Zi=!1,this.nk=!1,this.ok=!1,this.rk=NaN,this.lk=NaN,this.hk=0,this.ak=0}get fromVertex(){return this.We}set fromVertex(t){this.We!==t&&(this.We=t)}get toVertex(){return this.Je}set toVertex(t){this.Je!==t&&(this.Je=t)}get valid(){return this.Zi}set valid(t){this.Zi!==t&&(Util.i(t,"boolean",LayeredDigraphEdge,"valid"),this.Zi=t)}get rev(){return this.nk}set rev(t){this.nk!==t&&(Util.i(t,"boolean",LayeredDigraphEdge,"rev"),this.nk=t)}get forest(){return this.ok}set forest(t){this.ok!==t&&(Util.i(t,"boolean",LayeredDigraphEdge,"forest"),this.ok=t)}get portFromPos(){return this.rk}set portFromPos(t){this.rk!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portFromPos"),this.rk=t)}get portToPos(){return this.lk}set portToPos(t){this.lk!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portToPos"),this.lk=t)}get portFromColOffset(){return this.hk}set portFromColOffset(t){this.hk!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portFromColOffset"),this.hk=t)}get portToColOffset(){return this.ak}set portToColOffset(t){this.ak!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portToColOffset"),this.ak=t)}}var TreePath=(w=>(w[w.Default=0]="Default",w[w.Destination=1]="Destination",w[w.Source=2]="Source",w))(TreePath||{}),TreeSorting=(w=>(w[w.Forwards=10]="Forwards",w[w.Reverse=11]="Reverse",w[w.Ascending=12]="Ascending",w[w.Descending=13]="Descending",w))(TreeSorting||{}),TreeAlignment=(w=>(w[w.CenterSubtrees=20]="CenterSubtrees",w[w.CenterChildren=21]="CenterChildren",w[w.Start=22]="Start",w[w.End=23]="End",w[w.Bus=24]="Bus",w[w.BusBranching=25]="BusBranching",w[w.TopLeftBus=26]="TopLeftBus",w[w.BottomRightBus=27]="BottomRightBus",w[w.Custom=28]="Custom",w))(TreeAlignment||{}),TreeCompaction=(w=>(w[w.None=30]="None",w[w.Block=31]="Block",w))(TreeCompaction||{}),TreeStyle=(w=>(w[w.Layered=40]="Layered",w[w.LastParents=41]="LastParents",w[w.Alternating=42]="Alternating",w[w.RootOnly=43]="RootOnly",w))(TreeStyle||{}),TreeArrangement=(w=>(w[w.Vertical=50]="Vertical",w[w.Horizontal=51]="Horizontal",w[w.FixedRoots=52]="FixedRoots",w))(TreeArrangement||{}),TreeLayerStyle=(w=>(w[w.Individual=60]="Individual",w[w.Siblings=61]="Siblings",w[w.Uniform=62]="Uniform",w))(TreeLayerStyle||{});class TreeLayout extends Layout{Fi;Ti;_f;Dg;VN;Re;zi;ks;V;z;ck;hs;constructor(t){super(),this.Fi=new GSet,this.Ti=0,this.hs=1,this._f=40,this.Dg=60,this.VN=[],this.Re=!0,this.zi=50,this.ks=new Size(10,10).g();const i=new TreeNetwork(this);this.V=new TreeVertex(i),this.z=new TreeVertex(i),this.ck=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Ti=this.Ti,t._f=this._f,t.Dg=this.Dg,t.Re=this.Re,t.zi=this.zi,t.ks.a(this.ks),t.V.copyInheritedPropertiesFrom(this.V),t.z.copyInheritedPropertiesFrom(this.z)}ri(t){t in TreeAlignment?this.alignment=t:t in TreeArrangement?this.arrangement=t:t in TreeCompaction?this.compaction=t:t in TreePath?this.path=t:t in TreeSorting?this.sorting=t:t in TreeStyle?this.treeStyle=t:super.ri(t)}createNetwork(){return new TreeNetwork(this)}makeNetwork(t){const i=this.createNetwork(),e=s=>{if(s instanceof Node)return!s.isLinkLabel&&s.category!=="Comment";if(s instanceof Link){const n=s.fromNode;if(n===null||n.isLinkLabel||n.category==="Comment")return!1;const o=s.toNode;return!(o===null||o.isLinkLabel||o.category==="Comment")}return!1};return t instanceof Diagram?(i.addParts(t.nodes,!0,e),i.addParts(t.links,!0,e)):t instanceof Group?i.addParts(t.memberParts,!1,e):i.addParts(t.iterator,!1,e),i}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangement!==52&&(this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin));let i=this.diagram;i===null&&t instanceof Diagram&&(i=t),this.path===0&&i!==null?this.hs=i.isTreePathToChildren?1:2:this.hs=this.path===0?1:this.path,this.network.vertexes.count>0&&(this.CI(),this.LI(),this.AI(),this.TI(),this.RN(),this.DI(),this.arrangeTrees(),this.updateParts()),this.network=null,this.Fi=new GSet,this.isValidLayout=!0}CI(){this.network.deleteSelfEdges();const t=this.network.vertexes.iterator;for(;t.next();){const n=t.value;n.initialized=!1,n.level=0,n.parent=null,n.children=[]}if(this.Fi.count>0){const n=new GSet,o=this.Fi.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=this.network.findVertex(r);l!==null&&n.add(l)}else r instanceof TreeVertex&&n.add(r)}this.Fi=n}this.Fi.count===0&&this.findRoots();const i=this.Fi.copy().iterator;for(;i.next();){const n=i.value;n.initialized||(n.initialized=!0,this.zN(n))}let e=this.network.vertexes,s=null;for(;s=this.FI(e),s.count>0;){const n=this.dD(s);n!==null&&this.Fi.add(n),n.initialized=!0,this.zN(n),e=s}}FI(t){const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;s.initialized||i.add(s)}return i}findRoots(){const t=this.network.vertexes,i=t.iterator;for(;i.next();){const e=i.value;switch(this.hs){case 1:e.sourceEdges.count===0&&this.Fi.add(e);break;case 2:e.destinationEdges.count===0&&this.Fi.add(e);break;default:Util.o("Unhandled path value "+this.hs.toString())}}if(this.Fi.count===0){const e=this.dD(t);e!==null&&this.Fi.add(e)}}dD(t){let i=999999,e=null;const s=t.iterator;for(;s.next();){const n=s.value;switch(this.hs){case 1:n.sourceEdges.count0){const s=new List,n=t.destinationVertexes;for(;n.next();){const o=n.value;this.gD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;case 2:if(t.sourceEdges.count>0){const s=new List,n=t.sourceVertexes;for(;n.next();){const o=n.value;this.gD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;default:Util.o("Unhandled path value"+this.hs.toString())}const i=t.children,e=i.length;for(let s=0;st.level?!1:(this.vI(i.parent,i),!0):!0}RI(t,i){if(i===null)return!1;let e=i.parent;for(;e!==null&&e!==t;)e=e.parent;return e===t}vI(t,i){if(t===null||i===null)return;const e=t.children;let s=0;for(let n=0;n0){const n=new Array(e.length-s);let o=0;for(let r=0;r0?s+1:0}OI(t){switch(this._f){default:case 40:return t.parent!==null?t.parent:this.V;case 43:return t.parent===null?this.V:t.parent.parent===null?this.z:t.parent;case 42:return t.parent!==null?t.parent.parent!==null?t.parent.parent:this.z:this.V;case 41:{let i=!0;if(t.childrenCount===0)i=!1;else{const e=t.children,s=e.length;for(let n=0;n0){i=!1;break}}return i&&t.parent!==null?this.z:t.parent!==null?t.parent:this.V}}}initializeTreeVertexValues(t){const i=this.OI(t);if(t.copyInheritedPropertiesFrom(i),t.parent!==null&&t.parent.alignment===25){let e=t.angle;const s=t.parent.children;let n=0;for(;n135&&!l||a&&f)if(t.commentMargin>=0){g.e(t.bounds.x-t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleLeft,P.toSpot=Spot.MiddleRight}}else{g.e(t.bounds.x+t.focus.x*2-t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleRight,P.toSpot=Spot.MiddleLeft}}else if(t.commentMargin>=0){g.e(t.bounds.x+t.focus.x*2+t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleRight,P.toSpot=Spot.MiddleLeft}}else{g.e(t.bounds.x+t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleLeft,P.toSpot=Spot.MiddleRight}}t.commentSpacing>=0?u+=k.height+t.commentSpacing:u+=t.commentSpacing-k.height}else{if(o>135&&!l||!a&&f)if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y-t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleTop,P.toSpot=Spot.MiddleBottom}}else{g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2-t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleBottom,P.toSpot=Spot.MiddleTop}}else if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2+t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleBottom,P.toSpot=Spot.MiddleTop}}else{g.e(t.bounds.x+u,t.bounds.y+t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleTop,P.toSpot=Spot.MiddleBottom}}t.commentSpacing>=0?u+=k.width+t.commentSpacing:u+=t.commentSpacing-k.width}}Point.s(g);const p=u-t.commentSpacing-(h?e.height:e.width);if(this.hs===1){const y=t.destinationEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.fromEndSegmentLength=p>0?p:NaN)}}else{const y=t.sourceEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.toEndSegmentLength=p>0?p:NaN)}}}}DI(){if(this.layerStyle===62){const i=[];let e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;let n=s.parent;n===null&&(n=s);const o=n.angle===0||n.angle===180;let r=i[s.level];r===void 0&&(r=0),i[s.level]=Math.max(r,o?s.width:s.height)}for(let s=0;s=0)for(let o=0;o135&&n.reverse(),this.Jy(r))if(o>1)for(let R=0;R0&&M>0&&S+u+O.width>c&&(S135?-b-g:b+g);const B=M===0?m:u;this.fk(v,0,L),v.B.e(S+B,L),k=Math.max(k,S+B+O.width),b=Math.max(b,P+(C===0?0:g)+O.height),S+=B+O.width}else{c>0&&M>0&&L+u+O.height>c&&(L135?-k-g:k+g);const B=M===0?m:u;this.fk(v,S,0),v.B.e(S,L+B),b=Math.max(b,L+B+O.height),k=Math.max(k,P+(C===0?0:g)+O.width),L+=B+O.height}M++}C>0&&(e?(b+=Math.max(0,f),S0&&(h||this.tu(t,p,0,0,o-1),k+=p)):(k+=Math.max(0,f),L0&&(h||this.tu(t,0,p,0,o-1),b+=p)));let D=0,F=0;switch(r){case 20:e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;break;default:case 21:if(C>0)e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;else{const v=o;if(e){const O=n[0].B.x+n[0].ft.x,B=n[v-1].B.x+n[v-1].ft.x+n[v-1].focus.x*2;D+=O+(B-O)/2-t.focus.x-d/2}else{const O=n[0].B.y+n[0].ft.y,B=n[v-1].B.y+n[v-1].ft.y+n[v-1].focus.y*2;F+=O+(B-O)/2-t.focus.y-d/2}}break;case 22:e?(D-=d,k+=d):(F-=d,b+=d);break;case 23:e?(D+=k-t.width+d,k+=d):(F+=b-t.height+d,b+=d);break;case 24:case 25:e?o>1?D+=T+u/2-t.focus.x:D+=n[0].focus.x-t.focus.x+n[0].ft.x:o>1?F+=T+u/2-t.focus.y:F+=n[0].focus.y-t.focus.y+n[0].ft.y;break;case 26:e?D+=k+u/2-t.focus.x:F+=b+u/2-t.focus.y;break;case 27:break;case 28:const R=this.customAlignment(t,D,F,k,b);D=R[0],F=R[1],k=R[2],b=R[3];break}for(let R=0;R135?(a?-b:-v.mt.height)+v.ft.y-f:x+f+v.ft.y)):v.B.e(v.B.x+(i>135?(a?-k:-v.mt.width)+v.ft.x-f:y+f+v.ft.x),v.B.y+v.ft.y-F)}e?(k=this.KN(t,k,D),D<0&&(D=0),i>135&&(F+=b+f),b=Math.max(Math.max(b,x),b+x+f)):(i>135&&(D+=k+f),k=Math.max(Math.max(k,y),k+y+f),b=this.YN(t,b,F),F<0&&(F=0)),t.ft.e(D,F),t.mt.e(k,b)}customAlignment(t,i,e,s,n){return[i,e,s,n]}xD(t,i,e,s,n,o){const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.mt.width,o=p.mt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,c=this.orthoAngle(t)===90;let f=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.mt,k=f===0?0:h;if(c){const b=this.computeBusNodeSpacing(y)-l;y.B.e(e-(x.width+b),d+k),n=Math.max(n,x.width+b),o=Math.max(o,d+k+x.height),d+=k+x.height}else{const b=this.computeBusNodeSpacing(y)-l;y.B.e(u+k,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,u+k+x.width),u+=k+x.width}f++}f=0;const m=u,g=d;c?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.mt,x=this.computeBusLastRowSpacing(p,c?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(c){p.B.e(e+l/2-p.focus.x-p.ft.x,o+x);const k=e+l/2-p.focus.x-p.ft.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.max(g,d)+x+y.height),p.B.x<0&&(e=this.uk(t,p.B.x,!1,e,l))}else{p.B.e(n+x,e+l/2-p.focus.y-p.ft.y),n=Math.max(n,Math.max(m,u)+x+y.width);const k=e+l/2-p.focus.y-p.ft.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.B.y<0&&(e=this.uk(t,p.B.y,!0,e,l))}}return new Rect(e,0,n,o)}bD(t,i,e,s,n,o){const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.mt.width,o=p.mt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,c=this.orthoAngle(t)===270;let f=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.mt,k=f===0?0:h;if(c){const b=this.computeBusNodeSpacing(y)-l;d-=k+x.height,y.B.e(e-(x.width+b),d),n=Math.max(n,x.width+b),o=Math.max(o,Math.abs(d))}else{const b=this.computeBusNodeSpacing(y)-l;u-=k+x.width,y.B.e(u,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,Math.abs(u))}f++}f=0;const m=u,g=d;c?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.mt,x=this.computeBusLastRowSpacing(p,c?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(c){p.B.e(e+l/2-p.focus.x-p.ft.x,-o-y.height-x);const k=e+l/2-p.focus.x-p.ft.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.abs(Math.min(g,d))+x+y.height),p.B.x<0&&(e=this.uk(t,p.B.x,!1,e,l))}else{p.B.e(-n-y.width-x,e+l/2-p.focus.y-p.ft.y),n=Math.max(n,Math.abs(Math.min(m,u))+x+y.width);const k=e+l/2-p.focus.y-p.ft.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.B.y<0&&(e=this.uk(t,p.B.y,!0,e,l))}}for(let p=0;ps&&(s=e+t.width),e<0&&(s-=e),s;case 22:return t.width>i?t.width:i;case 23:return t.focus.x*2>i?t.width:i+t.width-t.focus.x*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.width);return Math.max(t.width,o-n);case 26:return t.width-t.focus.x+t.nodeSpacing/2+i;case 27:return Math.max(t.width,t.focus.x+t.nodeSpacing/2+i);default:return i}}YN(t,i,e){switch(t.alignment){case 21:case 20:let s=i;return e+t.height>s&&(s=e+t.height),e<0&&(s-=e),s;case 22:return t.height>i?t.height:i;case 23:return t.focus.y*2>i?t.height:i+t.height-t.focus.y*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.height);return Math.max(t.height,o-n);case 26:return t.height-t.focus.y+t.nodeSpacing/2+i;case 27:return Math.max(t.height,t.focus.y+t.nodeSpacing/2+i);default:return i}}GN(t,i,e){switch(t){case 20:i/=2,e/=2;break;case 21:i/=2,e/=2;break;case 22:i=0,e=0;break;case 23:break;default:Util.o("Unhandled alignment value "+t.toString())}return new Point(i,e)}_a(t,i,e,s,n,o){const r=this.GN(i,e,s);this.tu(t,r.x,r.y,n,o)}tu(t,i,e,s,n){if(i===0&&e===0)return;const o=t.children;for(let r=s;r<=n;r++){const h=o[r].B;h.x+=i,h.y+=e}}fk(t,i,e){const s=t.parent;switch(this.hs){case 1:{const n=t.sourceEdges;for(;n.next();){const o=n.value;o.fromVertex===s&&o.relativePoint.e(i,e)}break}case 2:{const n=t.destinationEdges;for(;n.next();){const o=n.value;o.toVertex===s&&o.relativePoint.e(i,e)}break}default:Util.o("Unhandled path value "+this.hs.toString())}}II(t){if(t.childrenCount===0){const U=t.parent;let Y=!1,G=0,H=21;U!==null&&(G=U.angle,H=U.alignment,Y=this.isBusAlignment(H));const J=this.XN(t);t.B.e(0,0),t.mt.e(t.width,t.height),t.parent!==null&&t.comments!==null&&((G===180||G===270)&&!Y||J)?G===180&&!Y||(G===90||G===270)&&J?t.ft.e(t.width-t.focus.x*2,0):t.ft.e(0,t.height-t.focus.y*2):t.ft.e(0,0),t.Fg=null,t.Rg=null;return}const i=this.orthoAngle(t),e=i===90||i===270;let s=0;const n=t.children,o=n.length;for(let U=0;U135&&n.reverse(),this.Jy(r))if(o>1)for(let U=0;U0&&A>0&&M+u+G.width>c&&(M135?-k-m:k+m),this.fk(Y,0,N);let H=0;if(A===0)P=Y.Fg,S=Y.Rg,L=G.width,C=G.height,(P===null||S===null||i!==this.orthoAngle(Y))&&(P=this.ae(2),S=this.ae(2),P[0].e(0,0),P[1].e(0,C),S[0].e(L,0),S[1].e(L,C));else{const J=Util.nt(),z=this.kD(t,Y,P,S,L,C,J);H=z.x,P=J[0],S=J[1],L=z.width,C=z.height,Util.tt(J),M0&&A>0&&N+u+G.height>c&&(N135?-x-m:x+m),this.fk(Y,M,0);let H=0;if(A===0)P=Y.Fg,S=Y.Rg,L=G.width,C=G.height,(P===null||S===null||i!==this.orthoAngle(Y))&&(P=this.ae(2),S=this.ae(2),P[0].e(0,0),P[1].e(L,0),S[0].e(0,C),S[1].e(L,C));else{const J=Util.nt(),z=this.kD(t,Y,P,S,L,C,J);H=z.x,P=J[0],S=J[1],L=z.width,C=z.height,Util.tt(J),N0&&(e?(k+=Math.max(0,f),M0&&(h||this.tu(t,g,0,0,o-1),x+=g)):(x+=Math.max(0,f),N0&&(h||this.tu(t,0,g,0,o-1),k+=g)));let v=0,O=0;switch(r){case 20:e?v+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;break;default:case 21:if(T>0)e?v+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;else{const Y=o;if(e){const G=n[0].B.x+n[0].ft.x,H=n[Y-1].B.x+n[Y-1].ft.x+n[Y-1].focus.x*2;v+=G+(H-G)/2-t.focus.x-d/2}else{const G=n[0].B.y+n[0].ft.y,H=n[Y-1].B.y+n[Y-1].ft.y+n[Y-1].focus.y*2;O+=G+(H-G)/2-t.focus.y-d/2}}break;case 22:e?(v-=d,x+=d):(O-=d,k+=d);break;case 23:e?(v+=x-t.width+d,x+=d):(O+=k-t.height+d,k+=d);break;case 24:e?o>1?v+=F+u/2-t.focus.x:v+=n[0].focus.x-t.focus.x+n[0].ft.x:o>1?O+=F+u/2-t.focus.y:O+=n[0].focus.y-t.focus.y+n[0].ft.y;break;case 26:e?v+=x+u/2-t.focus.x:O+=k+u/2-t.focus.y;break;case 27:break;case 28:const U=this.customAlignment(t,v,O,x,k);v=U[0],O=U[1],x=U[2],k=U[3];break}for(let U=0;U135?(a?-k:-Y.mt.height)+Y.ft.y-f:y+f+Y.ft.y)):Y.B.e(Y.B.x+(i>135?(a?-x:-Y.mt.width)+Y.ft.x-f:p+f+Y.ft.x),Y.B.y+Y.ft.y-O)}let B=0,X=0;if(a)e?(x=this.KN(t,x,v),v<0&&(v=0),i>135&&(O+=k+f),k+=y+f,r===27&&(B+=u/2+t.focus.x),X+=y+f):(i>135&&(v+=x+f),x+=p+f,k=this.YN(t,k,O),O<0&&(O=0),r===27&&(X+=u/2+t.focus.y),B+=p+f);else if(e){if(t.comments===null){if(p>x){const U=this.GN(r,p-x,0);B=U.x,X=U.y,x=p,v=0}}else x=this.KN(t,x,v);v<0&&(B-=v,v=0),i>135&&(O+=k+f),k=Math.max(Math.max(k,y),k+y+f),X+=y+f}else{if(i>135&&(v+=x+f),x=Math.max(Math.max(x,p),x+p+f),t.comments===null){if(y>k){const U=this.GN(r,0,y-k);B=U.x,X=U.y,k=y,O=0}}else k=this.YN(t,k,O);O<0&&(X-=O,O=0),B+=p+f}let E,V;if(T>0)E=this.ae(4),V=this.ae(4),e?(E[2].e(0,y+f),E[3].e(E[2].x,k),V[2].e(x,E[2].y),V[3].e(V[2].x,E[3].y)):(E[2].e(p+f,0),E[3].e(x,E[2].y),V[2].e(E[2].x,k),V[3].e(E[3].x,V[2].y));else{E=this.ae(P.length+2),V=this.ae(S.length+2);for(let U=0;UE[0].x?E[2].a(E[1]):E[1].a(E[2])),E[3].yE[0].x?E[3].a(E[2]):E[2].a(E[3])),V[0].e(v+p,0),V[1].e(V[0].x,y),V[2].yE[0].y?E[2].a(E[1]):E[1].a(E[2])),E[3].xE[0].y?E[3].a(E[2]):E[2].a(E[3])),V[0].e(0,O+y),V[1].e(p,V[0].y),V[2].xl;){const a=i[o++];s[r++].e(a.x,a.y+e)}const h=this.ae(r);for(n=0;nl;){const a=i[o++];s[r++].e(a.x+e,a.y)}const h=this.ae(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.ae(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.ae(r);for(n=0;nh&&r.xr.x&&ha&&r.yr.y&&a0){const n=Math.min(1,t.layerSpacingParentOverlap);s-=e?t.height*n:t.width*n}return s<(e?-t.height:-t.width)&&(s=e?-t.height:-t.width),s}computeNodeIndent(t){const i=this.orthoAngle(t),e=i===90||i===270;let s=t.nodeIndent;if(t.nodeIndentPastParent>0){const n=Math.min(1,t.nodeIndentPastParent);s+=e?t.width*n:t.height*n}return s=Math.max(0,s),s}get roots(){return this.Fi}set roots(t){this.Fi!==t&&(this.Fi=t,this.invalidateLayout())}get path(){return this.Ti}set path(t){this.Ti!==t&&(this.Ti=t,this.invalidateLayout())}get treeStyle(){return this._f}set treeStyle(t){this._f!==t&&(t===40||t===42||t===41||t===43)&&(this._f=t,this.invalidateLayout())}get layerStyle(){return this.Dg}set layerStyle(t){this.Dg!==t&&(t===60||t===61||t===62)&&(this.Dg=t,this.invalidateLayout())}get comments(){return this.Re}set comments(t){this.Re!==t&&(Util.i(t,"boolean",TreeLayout,"comments"),this.Re=t,this.invalidateLayout())}get arrangement(){return this.zi}set arrangement(t){this.zi!==t&&(t===50||t===51||t===52)&&(this.zi=t,this.invalidateLayout())}get arrangementSpacing(){return this.ks}set arrangementSpacing(t){this.ks.equals(t)||(this.ks.a(t),this.invalidateLayout())}get rootDefaults(){return this.V}set rootDefaults(t){this.V!==t&&(this.V=t,this.invalidateLayout())}get alternateDefaults(){return this.z}set alternateDefaults(t){this.z!==t&&(this.z=t,this.invalidateLayout())}get sorting(){return this.V.sorting}set sorting(t){this.V.sorting!==t&&(this.V.sorting=t,this.invalidateLayout())}get comparer(){return this.V.comparer}set comparer(t){this.V.comparer!==t&&(Util.i(t,"function",TreeLayout,"comparer"),this.V.comparer=t,this.invalidateLayout())}get angle(){return this.V.angle}set angle(t){this.V.angle!==t&&(Util.i(t,"number",TreeLayout,"angle"),t===0||t===90||t===180||t===270?(this.V.angle=t,this.invalidateLayout()):Util.o("TreeLayout.angle must be 0, 90, 180, or 270"))}get alignment(){return this.V.alignment}set alignment(t){this.V.alignment!==t&&(this.V.alignment=t,this.invalidateLayout())}get nodeIndent(){return this.V.nodeIndent}set nodeIndent(t){this.V.nodeIndent!==t&&(Util.i(t,"number",TreeLayout,"nodeIndent"),t>=0&&(this.V.nodeIndent=t,this.invalidateLayout()))}get nodeIndentPastParent(){return this.V.nodeIndentPastParent}set nodeIndentPastParent(t){this.V.nodeIndentPastParent!==t&&(Util.i(t,"number",TreeLayout,"nodeIndentPastParent"),t>=0&&t<=1&&(this.V.nodeIndentPastParent=t,this.invalidateLayout()))}get nodeSpacing(){return this.V.nodeSpacing}set nodeSpacing(t){this.V.nodeSpacing!==t&&(Util.i(t,"number",TreeLayout,"nodeSpacing"),this.V.nodeSpacing=t,this.invalidateLayout())}get layerSpacing(){return this.V.layerSpacing}set layerSpacing(t){this.V.layerSpacing!==t&&(Util.i(t,"number",TreeLayout,"layerSpacing"),this.V.layerSpacing=t,this.invalidateLayout())}get layerSpacingParentOverlap(){return this.V.layerSpacingParentOverlap}set layerSpacingParentOverlap(t){this.V.layerSpacingParentOverlap!==t&&(Util.i(t,"number",TreeLayout,"layerSpacingParentOverlap"),t>=0&&t<=1&&(this.V.layerSpacingParentOverlap=t,this.invalidateLayout()))}get compaction(){return this.V.compaction}set compaction(t){this.V.compaction!==t&&(t===30||t===31)&&(this.V.compaction=t,this.invalidateLayout())}get breadthLimit(){return this.V.breadthLimit}set breadthLimit(t){this.V.breadthLimit!==t&&(Util.i(t,"number",TreeLayout,"breadthLimit"),t>=0&&(this.V.breadthLimit=t,this.invalidateLayout()))}get rowSpacing(){return this.V.rowSpacing}set rowSpacing(t){this.V.rowSpacing!==t&&(Util.i(t,"number",TreeLayout,"rowSpacing"),this.V.rowSpacing=t,this.invalidateLayout())}get rowIndent(){return this.V.rowIndent}set rowIndent(t){this.V.rowIndent!==t&&(Util.i(t,"number",TreeLayout,"rowIndent"),t>=0&&(this.V.rowIndent=t,this.invalidateLayout()))}get commentSpacing(){return this.V.commentSpacing}set commentSpacing(t){this.V.commentSpacing!==t&&(Util.i(t,"number",TreeLayout,"commentSpacing"),this.V.commentSpacing=t,this.invalidateLayout())}get commentMargin(){return this.V.commentMargin}set commentMargin(t){this.V.commentMargin!==t&&(Util.i(t,"number",TreeLayout,"commentMargin"),this.V.commentMargin=t,this.invalidateLayout())}get setsPortSpot(){return this.V.setsPortSpot}set setsPortSpot(t){this.V.setsPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"setsPortSpot"),this.V.setsPortSpot=t,this.invalidateLayout())}get portSpot(){return this.V.portSpot}set portSpot(t){this.V.portSpot.equals(t)||(this.V.portSpot=t,this.invalidateLayout())}get setsChildPortSpot(){return this.V.setsChildPortSpot}set setsChildPortSpot(t){this.V.setsChildPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"setsChildPortSpot"),this.V.setsChildPortSpot=t,this.invalidateLayout())}get childPortSpot(){return this.V.childPortSpot}set childPortSpot(t){this.V.childPortSpot.equals(t)||(this.V.childPortSpot=t,this.invalidateLayout())}get alternateSorting(){return this.z.sorting}set alternateSorting(t){this.z.sorting!==t&&(this.z.sorting=t,this.invalidateLayout())}get alternateComparer(){return this.z.comparer}set alternateComparer(t){this.z.comparer!==t&&(Util.i(t,"function",TreeLayout,"alternateComparer"),this.z.comparer=t,this.invalidateLayout())}get alternateAngle(){return this.z.angle}set alternateAngle(t){this.z.angle!==t&&(Util.i(t,"number",TreeLayout,"alternateAngle"),(t===0||t===90||t===180||t===270)&&(this.z.angle=t,this.invalidateLayout()))}get alternateAlignment(){return this.z.alignment}set alternateAlignment(t){this.z.alignment!==t&&(this.z.alignment=t,this.invalidateLayout())}get alternateNodeIndent(){return this.z.nodeIndent}set alternateNodeIndent(t){this.z.nodeIndent!==t&&(Util.i(t,"number",TreeLayout,"alternateNodeIndent"),t>=0&&(this.z.nodeIndent=t,this.invalidateLayout()))}get alternateNodeIndentPastParent(){return this.z.nodeIndentPastParent}set alternateNodeIndentPastParent(t){this.z.nodeIndentPastParent!==t&&(Util.i(t,"number",TreeLayout,"alternateNodeIndentPastParent"),t>=0&&t<=1&&(this.z.nodeIndentPastParent=t,this.invalidateLayout()))}get alternateNodeSpacing(){return this.z.nodeSpacing}set alternateNodeSpacing(t){this.z.nodeSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateNodeSpacing"),this.z.nodeSpacing=t,this.invalidateLayout())}get alternateLayerSpacing(){return this.z.layerSpacing}set alternateLayerSpacing(t){this.z.layerSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateLayerSpacing"),this.z.layerSpacing=t,this.invalidateLayout())}get alternateLayerSpacingParentOverlap(){return this.z.layerSpacingParentOverlap}set alternateLayerSpacingParentOverlap(t){this.z.layerSpacingParentOverlap!==t&&(Util.i(t,"number",TreeLayout,"alternateLayerSpacingParentOverlap"),t>=0&&t<=1&&(this.z.layerSpacingParentOverlap=t,this.invalidateLayout()))}get alternateCompaction(){return this.z.compaction}set alternateCompaction(t){this.z.compaction!==t&&(t===30||t===31)&&(this.z.compaction=t,this.invalidateLayout())}get alternateBreadthLimit(){return this.z.breadthLimit}set alternateBreadthLimit(t){this.z.breadthLimit!==t&&(Util.i(t,"number",TreeLayout,"alternateBreadthLimit"),t>=0&&(this.z.breadthLimit=t,this.invalidateLayout()))}get alternateRowSpacing(){return this.z.rowSpacing}set alternateRowSpacing(t){this.z.rowSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateRowSpacing"),this.z.rowSpacing=t,this.invalidateLayout())}get alternateRowIndent(){return this.z.rowIndent}set alternateRowIndent(t){this.z.rowIndent!==t&&(Util.i(t,"number",TreeLayout,"alternateRowIndent"),t>=0&&(this.z.rowIndent=t,this.invalidateLayout()))}get alternateCommentSpacing(){return this.z.commentSpacing}set alternateCommentSpacing(t){this.z.commentSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateCommentSpacing"),this.z.commentSpacing=t,this.invalidateLayout())}get alternateCommentMargin(){return this.z.commentMargin}set alternateCommentMargin(t){this.z.commentMargin!==t&&(Util.i(t,"number",TreeLayout,"alternateCommentMargin"),this.z.commentMargin=t,this.invalidateLayout())}get alternateSetsPortSpot(){return this.z.setsPortSpot}set alternateSetsPortSpot(t){this.z.setsPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"alternateSetsPortSpot"),this.z.setsPortSpot=t,this.invalidateLayout())}get alternatePortSpot(){return this.z.portSpot}set alternatePortSpot(t){this.z.portSpot.equals(t)||(this.z.portSpot=t,this.invalidateLayout())}get alternateSetsChildPortSpot(){return this.z.setsChildPortSpot}set alternateSetsChildPortSpot(t){this.z.setsChildPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"alternateSetsChildPortSpot"),this.z.setsChildPortSpot=t,this.invalidateLayout())}get alternateChildPortSpot(){return this.z.childPortSpot}set alternateChildPortSpot(t){this.z.childPortSpot.equals(t)||(this.z.childPortSpot=t,this.invalidateLayout())}static PathDefault=0;static PathDestination=1;static PathSource=2;static SortingForwards=10;static SortingReverse=11;static SortingAscending=12;static SortingDescending=13;static AlignmentCenterSubtrees=20;static AlignmentCenterChildren=21;static AlignmentStart=22;static AlignmentEnd=23;static AlignmentBus=24;static AlignmentBusBranching=25;static AlignmentTopLeftBus=26;static AlignmentBottomRightBus=27;static CompactionNone=30;static CompactionBlock=31;static StyleLayered=40;static StyleLastParents=41;static StyleAlternating=42;static StyleRootOnly=43;static ArrangementVertical=50;static ArrangementHorizontal=51;static ArrangementFixedRoots=52;static LayerIndividual=60;static LayerSiblings=61;static LayerUniform=62}class TreeNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new TreeVertex(this)}createEdge(){return new TreeEdge(this)}}class TreeVertex extends LayoutVertex{B;mt;ft;gk;mk;pk;yk;wk;xk;bk;Re;Fg;Rg;pe;ye;Xt;oi;$y;Zy;Qy;Ps;_y;tw;iw;ew;sw;nw;ow;rw;lw;hw;aw;constructor(t){super(t),this.gk=!1,this.mk=null,this.pk=[],this.yk=0,this.wk=0,this.xk=0,this.bk=0,this.Re=null,this.B=new Point(0,0),this.mt=new Size(0,0),this.ft=new Point(0,0),this.Fg=null,this.Rg=null,this.pe=10,this.ye=LayoutVertex.standardComparer,this.Xt=0,this.oi=21,this.$y=0,this.Zy=0,this.Qy=20,this.Ps=50,this._y=0,this.tw=31,this.iw=0,this.ew=25,this.sw=10,this.nw=10,this.ow=20,this.rw=!0,this.lw=Spot.Default,this.hw=!0,this.aw=Spot.Default}copyInheritedPropertiesFrom(t){t!==null&&(this.pe=t.sorting,this.ye=t.comparer,this.Xt=t.angle,this.oi=t.alignment,this.$y=t.nodeIndent,this.Zy=t.nodeIndentPastParent,this.Qy=t.nodeSpacing,this.Ps=t.layerSpacing,this._y=t.layerSpacingParentOverlap,this.tw=t.compaction,this.iw=t.breadthLimit,this.ew=t.rowSpacing,this.sw=t.rowIndent,this.nw=t.commentSpacing,this.ow=t.commentMargin,this.rw=t.setsPortSpot,this.lw=t.portSpot,this.hw=t.setsChildPortSpot,this.aw=t.childPortSpot)}get initialized(){return this.gk}set initialized(t){this.gk!==t&&(Util.i(t,"boolean",TreeVertex,"initialized"),this.gk=t)}get parent(){return this.mk}set parent(t){this.mk!==t&&(this.mk=t)}get children(){return this.pk}set children(t){if(this.pk!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",TreeVertex,"children:value"),t!==null){const i=t.length;for(let e=0;e4;)t.removePoint(2);u=t.getPoint(1),d=t.getPoint(2)}else{for(f=1;t.pointsCount>3;)t.removePoint(1);u=t.getPoint(0),d=t.getPoint(t.pointsCount-1)}const m=t.getPoint(t.pointsCount-1);let g=0;r===0?(e.alignment===23?(g=o.bottom+n.y,n.y===0&&u.y>m.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.xm.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.x{const i=t.matches?"dark":"light";i!==this.vg&&(this.vg=i,this.Sk==="system"&&this.cw())};constructor(t){t&&Object.assign(this,t),t?.themeMap||(this.iu.set("light",{colors:{...Themes.Light.colors},fonts:{...Themes.Light.fonts},numbers:{...Themes.Light.numbers},margins:{...Themes.Light.margins},arrowheads:{...Themes.Light.arrowheads}}),this.iu.set("dark",{colors:{...Themes.Dark.colors},fonts:{...Themes.Dark.fonts},numbers:{...Themes.Dark.numbers},margins:{...Themes.Dark.margins},arrowheads:{...Themes.Dark.arrowheads}})),root.matchMedia&&(this.vg=root.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}get themeMap(){return this.iu}set themeMap(t){this.iu!==t&&(this.iu=t,this.cw())}get defaultTheme(){return this.Pk}set defaultTheme(t){this.Pk!==t&&(Util.i(t,"string",ThemeManager,"defaultTheme"),this.Pk=t,this.cw())}get currentTheme(){return this.Sk}set currentTheme(t){this.Sk!==t&&(Util.i(t,"string",ThemeManager,"currentTheme"),this.Sk=t,this.cw())}get changesDivBackground(){return this.Mk}set changesDivBackground(t){if(this.Mk!==t&&(this.Mk=t,t))for(const e of this.es)e.setDivBackground(this.findValue("div","","fill")),e.v("ThemeChanged",this)}get preferredColorScheme(){return this.vg}addDiagram(t){return this.es.add(t),this.HN(t),this}removeDiagram(t){return this.es.delete(t),this.HN(t),this}VF(){this.es.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.addEventListener("change",this.SD)}zF(){this.es.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.removeEventListener("change",this.SD)}set(t,i){t===""&&(t=this.Pk),t==="system"&&(t=this.vg);let e=this.iu.get(t);return e?e=this.MD(e,i):e=i,this.iu.set(t,e),this.cw(),this}findValue(t,i,e){return this.getValue(this.findTheme(this.currentTheme),t,i,e)||this.getValue(this.findTheme(this.defaultTheme),t,i,e)}getValue(t,i,e,s){if(!t)return;e==null&&(e="");let n=t;const o=l=>{if(n===void 0||l==="")return;if(typeof l=="number"||!(Array.isArray(l)||l.includes(".")))return n[l];const h=Array.isArray(l)?l:l.split(".");for(let a=0;a{if(!(e!==""&&(n=o(e),n===void 0)))return Array.isArray(n)&&typeof i=="number"?n=n[i%n.length]:n=o(i),n};if(n=r(),n===void 0&&typeof s=="string"&&s.length>0){let l=t.targetPropertyMap?.get(s);if(l?n=t[l]:(l=ThemeManager.GI.get(s),n=l?t[l]:t.colors),n=r(),n!==void 0)return n}return n}findTheme(t){return this.themeMap.get(t==="system"?this.vg:t)}HN(t){const i=t.skipsUndoManager;t.skipsUndoManager=!0,t.updateAllThemeBindings(),this.Mk&&t.setDivBackground(this.findValue("div","","fill")),t.skipsUndoManager=i,t.v("ThemeChanged",this)}cw(){for(const t of this.es)this.HN(t)}MD(t,i){for(const e in i)if(Util.fw(i,e))try{i[e].constructor===Object?t[e]=this.MD(t[e]??{},i[e]):t[e]=i[e]}catch{delete t[e]}return t}static GI=new Map([["background","colors"],["defaultColumnSeparatorStroke","colors"],["defaultRowSeparatorStroke","colors"],["shadowColor","colors"],["fill","colors"],["stroke","colors"],["font","fonts"],["angle","numbers"],["fromEndSegmentLength","numbers"],["fromShortLength","numbers"],["height","numbers"],["opacity","numbers"],["scale","numbers"],["toEndSegmentLength","numbers"],["toShortLength","numbers"],["width","numbers"],["defaultColumnSeparatorStrokeWidth","numbers"],["defaultRowSeparatorStrokeWidth","numbers"],["shadowBlur","numbers"],["corner","numbers"],["curviness","numbers"],["smoothness","numbers"],["parameter1","numbers"],["parameter2","numbers"],["strokeWidth","numbers"],["strokeDashOffset","numbers"],["maxLines","numbers"],["spacingAbove","numbers"],["spacingBelow","numbers"],["position","points"],["shadowOffset","points"],["desiredSize","sizes"],["maxSize","sizes"],["minSize","sizes"],["margin","margins"],["defaultSeparatorPadding","margins"],["padding","margins"],["alignment","spots"],["alignmentFocus","spots"],["fromSpot","spots"],["toSpot","spots"],["defaultAlignment","spots"],["spot1","spots"],["spot2","spots"],["verticalAlignment","spots"],["imageAlignment","spots"],["fromArrow","arrowheads"],["toArrow","arrowheads"]])}class Router{Mt;p;Oi;ul;constructor(){this.p=Diagram.mm(),this.Mt="",this.Oi=!0,this.ul=!0}get name(){return this.Mt}set name(t){this.Mt=t}get isEnabled(){return this.Oi}set isEnabled(t){this.Oi=t}get isRealtime(){return this.ul}set isRealtime(t){this.ul=t}get diagram(){return this.p}set diagram(t){this.p!==t&&(this.p=t,t.bl=!0,t.requestUpdate())}invalidateRouter(){this.p!==null&&(this.p.bl=!0,this.p.requestUpdate())}canRoute(t){if(!this.isEnabled)return!1;const i=this.diagram;return!(i&&(!this.isRealtime&&i.pu||i.animationManager.isTicking))}routeLinks(t,i){}toString(){return this.name!==""?this.name+" Router":Util.sn(this.constructor)}}class AvoidsNodesRouter extends Router{constructor(t){super(),this.name="AvoidsNodes",t&&Object.assign(this,t)}canRoute(t){return(t instanceof Diagram?t.Ym:t.diagram.Ym)?super.canRoute(t):!1}routeLinks(t,i){i=i instanceof Diagram?null:i;const e=t.iterator,s=this.diagram.getPositions(!0,i,null);for(;e.next();){const n=e.value;if(!n.isAvoiding||i&&n.containingGroup!==i||n.toNode===null||n.fromNode===null||n.pointsCount<4)continue;n.startRoute();const o=n.pointsCount,r=n.getPoint(1),l=n.getPoint(o-2),h=n.fromNode.actualBounds.copy();h.inflate(Link.va,Link.va),h.unionPoint(n.getPoint(0));const a=n.toNode.actualBounds.copy();a.inflate(Link.va,Link.va),a.unionPoint(n.getPoint(o-1)),this.jI(n,h,a,s)&&this.HI(n,r,n.iN,l,n.eN,h,a,s),n.commitRoute()}}jI(t,i,e,s){const n=t.diagram,o=t.pointsCount;if(n===null||t.fromNode===t.toNode||t.layer.isTemporary||i.containsPoint(t.getPoint(o-1))&&!t.toNode.isMemberOf(t.fromNode)||e.containsPoint(t.getPoint(0))&&!t.fromNode.isMemberOf(t.toNode)||!t.isOrthogonal)return!1;if(t.segmentIndex===17)return!0;const r=t.getPoint(1),l=t.getPoint(o-2),h=t.getPoint(2);if(!s.isUnoccupied(Math.min(r.x,h.x),Math.min(r.y,h.y),Math.abs(r.x-h.x),Math.abs(r.y-h.y)))return!0;for(let c=2;c=PositionArray.Bd&&(l.zL(),d.inflate(l.cellWidth*l.vM,l.cellHeight*l.OM),l.rT(i,e,s,n,d,!1),m=l.fo(s.x,s.y)),!l.by&&mPositionArray.Ba&&i.fo(g,p)!==u-1&&(i.fo(d-c,m)===u-1?(n=180,g=d-c,p=m):i.fo(d+c,m)===u-1?(n=0,g=d+c,p=m):i.fo(d,m-f)===u-1?(n=270,g=d,p=m-f):i.fo(d,m+f)===u-1&&(n=90,g=d,p=m+f));u>PositionArray.Ba&&i.fo(g,p)===u-1;)d=g,m=p,n===0?g+=c:n===90?p+=f:n===180?g-=c:p-=f,u-=1;if(o?u>PositionArray.Ba&&(n===180||n===0?d=Math.floor(d/c)*c+c/2:(n===90||n===270)&&(m=Math.floor(m/f)*f+f/2)):(d=Math.floor(d/c)*c+c/2,m=Math.floor(m/f)*f+f/2),u>PositionArray.Ba){let y=n,x=d,k=m;if(n===0?(y=90,k+=f):n===90?(y=180,x-=c):n===180?(y=270,k-=f):n===270&&(y=0,x+=c),i.fo(x,k)===u-1)this.qN(t,i,x,k,y,!1);else{let P=d,S=m;n===0?(y=270,S-=f):n===90?(y=0,P+=c):n===180?(y=90,S+=f):n===270&&(y=180,P-=c),i.fo(P,S)===u-1&&this.qN(t,i,P,S,y,!1)}}t.insertPointAt(t.pointsCount-2,d,m)}}ToolManager.prototype.initializeStandardTools=function(){this.Jt("Action",new ActionTool,this.mouseDownTools),this.Jt("Relinking",new RelinkingTool,this.mouseDownTools),this.Jt("LinkReshaping",new LinkReshapingTool,this.mouseDownTools),this.Jt("Rotating",new RotatingTool,this.mouseDownTools),this.Jt("Resizing",new ResizingTool,this.mouseDownTools),this.Jt("Linking",new LinkingTool,this.mouseMoveTools),this.Jt("Dragging",new DraggingTool,this.mouseMoveTools),this.Jt("DragSelecting",new DragSelectingTool,this.mouseMoveTools),this.Jt("Panning",new PanningTool,this.mouseMoveTools),this.Jt("ContextMenu",new ContextMenuTool,this.mouseUpTools),this.Jt("TextEditing",new TextEditingTool,this.mouseUpTools),this.Jt("ClickCreating",new ClickCreatingTool,this.mouseUpTools),this.Jt("ClickSelecting",new ClickSelectingTool,this.mouseUpTools)};Diagram.gM("GraphLinksModel",GraphLinksPartManager);Diagram.gM("TreeModel",TreePartManager);const oldGo=root.go,go={get version(){return Diagram.version},Group,List,Set:GSet,Map:GMap,Point,Size,Rect,Margin,Spot,Geometry,PathFigure,PathSegment,InputEvent,DiagramEvent,ChangedEvent,Model,GraphLinksModel,TreeModel,Binding,ThemeBinding,Transaction,UndoManager,CommandHandler,Tool,DraggingTool,DraggingInfo,DraggingOptions,LinkingBaseTool,LinkingTool,RelinkingTool,LinkReshapingTool,ResizingTool,RotatingTool,ClickSelectingTool,ActionTool,ClickCreatingTool,HTMLInfo,ContextMenuTool,DragSelectingTool,PanningTool,TextEditingTool,ToolManager,Animation,AnimationManager,AnimationTrigger,Layer,Diagram,Palette,Overview,Brush,GraphObject,Panel,RowColumnDefinition,Shape,TextBlock,Picture,Part,Adornment,Node,Link,Placeholder,Layout,LayoutNetwork,LayoutVertex,LayoutEdge,GridLayout,PanelLayout,CircularLayout,CircularNetwork,CircularVertex,CircularEdge,ForceDirectedLayout,ForceDirectedNetwork,ForceDirectedVertex,ForceDirectedEdge,LayeredDigraphLayout,LayeredDigraphNetwork,LayeredDigraphVertex,LayeredDigraphEdge,TreeLayout,TreeNetwork,TreeVertex,TreeEdge,Themes,ThemeManager,Router,AnimationStyle,AutoScale,CycleMode,Flip,TextFormat,ImageStretch,LayoutConditions,LinkAdjusting,Curve,Routing,Orientation,TextOverflow,PortSpreading,ScrollMode,CollapsePolicy,Sizing,TriggerStart,Stretch,ViewboxStretch,Wrap,BrushType,ColorSpace,GeometryStretch,GeometryType,SegmentType,BindingMode,ChangeType,CircularArrangement,CircularDirection,CircularNodeDiameterFormula,CircularSorting,GridAlignment,GridArrangement,GridSorting,LayeredDigraphAggressive,LayeredDigraphAlign,LayeredDigraphCycleRemove,LayeredDigraphInit,LayeredDigraphLayering,LayeredDigraphPack,TreeAlignment,TreeArrangement,TreeCompaction,TreeLayerStyle,TreePath,TreeSorting,TreeStyle,GestureMode,LinkingDirection,ReshapingBehavior,TextEditingAccept,TextEditingStarting,TextEditingState,WheelMode};typeof oldGo=="object"&&oldGo.version&&Util.ii("WARNING: a `go` object on the root object is already defined. "+("Debug"in oldGo?"debug ":"")+"version: "+oldGo.version+", replaced with version: "+go.version);Diagram.prototype.go=go;root.go=go; })(); diff --git a/release/go.d.ts b/release/go.d.ts index be8892351..26f5d35f7 100644 --- a/release/go.d.ts +++ b/release/go.d.ts @@ -1,5 +1,5 @@ /* - * Type definitions for GoJS v3.0.11 + * Type definitions for GoJS v3.0.12 * Project: https://gojs.net * Definitions by: Northwoods Software * Definitions: https://github.com/NorthwoodsSoftware/GoJS @@ -279,7 +279,7 @@ export interface IContext { strokeStyle: string | CanvasGradient | CanvasPattern | SGradient; textAlign: string; imageSmoothingEnabled: boolean; - clipInsteadOfFill: boolean; + /** Only true if a Spot panel has isClipping element */ clipInsteadOfFill: boolean; filter: string; commitTransform(): void; setImageSmoothingEnabled(smooth: boolean): void; @@ -321,6 +321,7 @@ export interface IContext { disableDash(): void; clearContextCache(clearFont: boolean): void; removePartFromView(p: GraphObject): void; + createOrUpdateClipGroup(panel: GraphObject, rect: Rect): void; } /** @@ -17086,7 +17087,7 @@ export abstract class GraphObject { *

              * See the Introduction page on building objects * for usage information and examples of GraphObject.make. - * @param type - a class function or the name of a class in the `go` namespace, + * @param cls - a class function or the name of a class in the `go` namespace, * or one of several predefined kinds of {@link Panel}s: `"Button"`, `"TreeExpanderButton"`, * `"SubGraphExpanderButton"`, or `"ContextMenuButton"`. * @param initializers - zero or more values that initialize the new object, @@ -17239,7 +17240,7 @@ export class Brush { * In addition to Brush properties, this object can also contain color stops in the format: * `{ 0: "#FEC901", 0.2: "#FFFFAA", 1: "#FEA200" }` */ - constructor(type?: BrushType | string, init?: Partial & Record<(number | string), string>>); + constructor(type?: BrushType | string, init?: Partial & Record); /** * Create a copy of this Brush with the same values. */ @@ -18466,8 +18467,9 @@ export class Panel extends GraphObject { set itemCategoryProperty(value: string | ((a: any) => string)); /** * For {@link Spot} Panels: Gets or sets whether this Panel's main element clips instead of fills. - * The main element will not paint its stroke, if it has any. * This assumes that the main element is a Shape. + * The main Shape element will not paint its stroke, if it has any, + * and should have its Shape.strokeWidth set to `0`. * * Since 2.2: For {@link Group}s: Gets or sets whether this Group's Placeholder clips its member nodes. * For compatibility, if the Group is a {@link Spot} Panel, it will not clip its members. @@ -31501,9 +31503,10 @@ export abstract class Router { * An override of this method should return `false` if {@link isEnabled} is false, or return `false` is if a call to the base method is `false`. * * This method is only called by the {@link Diagram}. If using a Router without adding it to a Diagram, this method will never be called. + * @param container A Diagram or Group on which the Router will operate. * @virtual */ - canRoute(coll: Diagram | Group): boolean; + canRoute(container: Diagram | Group): boolean; /** * Route the links for a given collection (Group or Diagram). By default this is called * in a depth-first manner on every Group in the Diagram, and then the Diagram itself. @@ -31519,24 +31522,24 @@ export abstract class Router { * and then the Diagram, you should check the {@link Part.containingGroup} on each Link to ensure it matches: * * ```ts - * public routeLinks(links: Set, coll?: Diagram | Group): void { - * const container = coll instanceof Diagram ? null : coll; + * public routeLinks(links: Set, container?: Diagram | Group): void { + * const container = container instanceof Diagram ? null : container; * const it = links.iterator; * while (it.next()) { * const link = it.value; * // Only operate on links that are in the corresponding collection, if one is given - * if (coll && link.containingGroup !== container) continue; + * if (container && link.containingGroup !== container) continue; * . . . * ``` * * This method should not check the {@link canRoute} predicate. * * @param links The set of links that were recently recomputed, which may need routing. - * @param coll A Diagram or Group on which the Router will operate. + * @param container A Diagram or Group on which the Router will operate. * When calling a router manually, this does not need to be specified. * @virtual */ - routeLinks(links: Set, coll?: Diagram | Group): void; + routeLinks(links: Set, container?: Diagram | Group): void; } /** * The AvoidsNodesRouter is a Router that will modify any Orthogonal {@link Link}s @@ -31562,16 +31565,16 @@ export class AvoidsNodesRouter extends Router { * Determine whether the AvoidsNodesRouter should operate on a given collection. * If no avoiding links are present in the collection, the router will not run. */ - canRoute(coll: Diagram | Group): boolean; + canRoute(container: Diagram | Group): boolean; /** * Route the links. * By default this is called in a depth-first manner on every Group in the Diagram, and then the Diagram itself. * If a layout is warranted for any Group or Diagram, this is called immediately afterwards. * * @param links The set of links that were recently recomputed, which may need routing. - * @param coll A Diagram or Group on which the Router will operate. + * @param container A Diagram or Group on which the Router will operate. */ - routeLinks(links: Set, coll?: Diagram | Group): void; + routeLinks(links: Set, container?: Diagram | Group): void; } diff --git a/release/go.js b/release/go.js index e599d9f15..a80f70e3b 100644 --- a/release/go.js +++ b/release/go.js @@ -1,25 +1,25 @@ /* - * GoJS v3.0.11 JavaScript Library for HTML Diagrams, https://gojs.net + * GoJS v3.0.12 JavaScript Library for HTML Diagrams, https://gojs.net * GoJS and Northwoods Software are registered trademarks of Northwoods Software Corporation, https://nwoods.com. * Copyright (C) 1998-2024 by Northwoods Software Corporation. All Rights Reserved. - * THIS SOFTWARE IS LICENSED. THE LICENSE AGREEMENT IS AT: https://gojs.net/3.0.11/license.html. + * THIS SOFTWARE IS LICENSED. THE LICENSE AGREEMENT IS AT: https://gojs.net/3.0.12/license.html. * DO NOT MODIFY THIS FILE. DO NOT DISTRIBUTE A MODIFIED COPY OF THE CONTENTS OF THIS FILE. */ -(function() {const root=typeof globalThis=="object"&&globalThis||typeof global=="object"&&global.global===global&&global||typeof self=="object"&&self.self===self&&self||{};root.requestAnimationFrame===void 0&&(root.setImmediate===void 0?root.requestAnimationFrame=w=>root.setTimeout(w,0):root.requestAnimationFrame=root.setImmediate);class Util{static rr=root.navigator!==void 0&&root.navigator.platform!==void 0&&root.navigator.platform.match(/(iPhone|iPod|iPad|Mac)/i)!==null;static Nk(t,i,e){let s=-1;return function(){const n=this,o=arguments;s!==-1&&Util.Ig(s),s=Util.vh(()=>{s=-1,e||t.apply(n,o)},i),e&&!s&&t.apply(n,o)}}static vh(t,i){return root.setTimeout(t,i)}static Ig(t){root.clearTimeout(t)}static en(t){return root.document.createElement(t)}static o(t){throw new Error(t)}static T(t,i){let e="The object is frozen, so its properties cannot be set: "+t.toString();i!==void 0&&(e+=" to value: "+i),Util.o(e)}static WI(t,i,e,s){}static i(t,i,e,s){}static JI(t,i,e){}static $I(t,i,e){}static we(t,i,e,s){}static _(t,i,e,s){let n=Util.CD(e);s!==void 0&&(n+="."+s),Util.o(n+" is not in the range "+i+": "+t)}static ve(t){}static lr(t,i){}static oi(t){root.console&&root.console.log(t)}static wt(t){return typeof t=="object"&&t!==null}static ZI(t,i,e){}static su(t,i,e){Array.isArray(t)?i>=t.length?t.push(e):t.splice(i,0,e):Util.o("Cannot insert an object into an HTMLCollection or NodeList: "+e+" at "+i)}static _a(t,i){Array.isArray(t)?i>=t.length?t.pop():t.splice(i,1):Util.o("Cannot remove an object from an HTMLCollection or NodeList at "+i)}static Ck=[];static ot(){const t=Util.Ck.pop();return t===void 0?[]:t}static tt(t){t.length=0,Util.Ck.push(t)}static QI=Object.freeze([]);static CD(t){return t===null?"*":typeof t=="string"?t:typeof t=="function"?t.name:""}static sn(t){return typeof t=="function"?t.className?t.className:t.name:Util.wt(t)&&t.constructor?Util.sn(t.constructor):typeof t}static Oh(t,i){return i==null||i===""?null:Util.wt(t)&&i in t||t[i]?t[i]:null}static toString(t){let i=t;return Util.wt(t)&&(t.text?i=t.text:t.name?i=t.name:t.key!==void 0?i=t.key:t.id!==void 0?i=t.id:t.constructor===Object&&(t.Text?i=t.Text:t.Name?i=t.Name:t.Key!==void 0?i=t.Key:t.Id!==void 0?i=t.Id:t.ID!==void 0&&(i=t.ID))),i===void 0?"undefined":i===null?"null":i.toString()}static fw(t,i){if(t.hasOwnProperty(i))return!0;let e=Object.getPrototypeOf(t);for(;e&&e!==Function;){if(e.hasOwnProperty(i))return!0;const s=e._I;if(s&&s[i])return!0;e=Object.getPrototypeOf(e)}return!1}static LD(t){const i=[];let e=0;for(e=0;e<256;e++)i[e]=e;let s=0,n=0;for(e=0;e<256;e++)s=(s+i[e]+119)%256,n=i[e],i[e]=i[s],i[s]=n;e=0,s=0;let o="";for(let r=0;r>4)+i.charAt(r&15)]=String.fromCharCode(r);t.length%2&&(t="0"+t);const s=[];let n=0;for(let r=0;r0){const n=i[0];return this.key=0,this.value=n,n}else return null}any(t){const i=this.qt;i.hr=null;const e=i.at;this.Dt=-1;const s=i.r,n=s.length,o=this.Ls;for(let r=0;r=0?(this.key=i,this.value=t.r[i],!0):(this.gl(),!1)}hasNext(){return this.next()}first(){const t=this.qt;this.Yt=t.at;const i=t.r,e=i.length-1;if(this.Dt=e,e>=0){const s=i[e];return this.key=e,this.value=s,s}else return null}any(t){const i=this.qt;i.ar=null;const e=i.at,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(t(r))return!0;i.at!==e&&Util.ve(i)}return!1}all(t){const i=this.qt;i.ar=null;const e=i.at,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(!t(r))return!1;i.at!==e&&Util.ve(i)}return!0}each(t){const i=this.qt;i.ar=null;const e=i.at,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];t(r),i.at!==e&&Util.ve(i)}return this}map(t){const i=this.qt;i.ar=null;const e=i.at,s=[],n=i.r,o=n.length;this.Dt=o;for(let l=o-1;l>=0;l--){const h=n[l];s.push(t(h)),i.at!==e&&Util.ve(i)}const r=new List;return r.r=s,r.Oe(),r.iterator}filter(t){const i=this.qt;i.ar=null;const e=i.at,s=[],n=i.r,o=n.length;this.Dt=o;for(let l=o-1;l>=0;l--){const h=n[l];t(h)&&s.push(h),i.at!==e&&Util.ve(i)}const r=new List;return r.r=s,r.Oe(),r.iterator}get count(){return this.qt.r.length}gl(){this.key=-1,this.value=null,this.Yt=-1,this.qt.ar=this}toString(){return"ListIteratorBackwards("+this.Dt+"/"+this.qt.count+")"}}class List{h;r;at;hr;ar;constructor(t){GSet.Yi(this),this.h=!1,this.r=[],this.at=0,this.hr=null,this.ar=null,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.r.values()}Oe(){let t=this.at;t++,t>999999999&&(t=0),this.at=t}g(){return this.h=!0,this}rt(){return this.h=!1,this}toString(){return"List()#"+GSet.as(this)}add(t){return this.h&&Util.T(this,t),this.r.push(t),this.Oe(),this}push(t){this.add(t)}addAll(t){if(t===null)return this;this.h&&Util.T(this);const i=this.r;if(Array.isArray(t)){const e=t.length;for(let s=0;s=i.length)&&Util._(t,"0 <= i < length",List,"elt:i"),i[t]}get(t){return this.elt(t)}setElt(t,i){const e=this.r;(t<0||t>=e.length)&&Util._(t,"0 <= i < length",List,"setElt:i"),this.h&&Util.T(this,t),e[t]=i}set(t,i){this.setElt(t,i)}first(){const t=this.r;return t.length===0?null:t[0]}last(){const t=this.r,i=t.length;return i>0?t[i-1]:null}pop(){this.h&&Util.T(this);const t=this.r;return t.length>0?t.pop():null}any(t){const i=this.r,e=this.at,s=i.length;for(let n=0;n= 0",List,"insertAt:i"),this.h&&Util.T(this,t);const e=this.r;t>=e.length?e.push(i):e.splice(t,0,i),this.Oe()}remove(t){return this.delete(t)}delete(t){if(t===null)return!1;this.h&&Util.T(this,t);const i=this.r,e=i.indexOf(t);return e===-1?!1:(e===i.length-1?i.pop():i.splice(e,1),this.Oe(),!0)}removeAt(t){const i=this.r;(t<0||t>=i.length)&&Util._(t,"0 <= i < length",List,"removeAt:i"),this.h&&Util.T(this,t),t===i.length-1?i.pop():i.splice(t,1),this.Oe()}removeRange(t,i){const e=this.r,s=e.length;if(t<0)t=0;else if(t>=s)return this;if(i<0)return this;if(i>=s&&(i=s-1),t>i)return this;this.h&&Util.T(this);let n=t,o=i+1;for(;o0&&(t.r=Array.prototype.slice.call(i)),t}toArray(){const t=this.r,i=this.count,e=new Array(i);for(let s=0;s=n-1)&&Util._(i,"0 <= from < length",List,"sortRange:from"),o===2){const r=s[i],l=s[i+1];return t(r,l)>0&&(s[i]=l,s[i+1]=r,this.Oe()),this}if(i===0)if(e>=n)s.sort(t);else{const r=s.slice(0,e);r.sort(t);for(let l=0;l=n){const r=s.slice(i);r.sort(t);for(let l=i;li.add(t(e))),i.iterator}filter(t){const i=new List;return this.ko.w.forEach(e=>{t(e)&&i.add(e)}),i.iterator}get count(){return this.ko.count}gl(){this.key=null,this.value=null,this.ii=null}toString(){return"SetIterator"}}class GSet{h;w;constructor(t){this.h=!1,this.w=new Set,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.w.values()}values(){return this.w.values()}g(){return this.h=!0,this}rt(){return this.h=!1,this}toString(){return"Set()#"+GSet.as(this)}add(t){return t===null?this:(this.w.add(t),this)}addAll(t){if(t===null)return this;if(Array.isArray(t)){const i=t.length;for(let e=0;et.add(i)),t}toArray(){return Array.from(this.w)}toList(){const t=new List;return this.w.forEach(i=>t.add(i)),t}get count(){return this.w.size}get size(){return this.w.size}get iterator(){return this.w.size<=0?EmptyIterator.instance:new SetIterator(this)}entries(){return this.w.entries()}keys(){return this.w.keys()}forEach(t,i){return this.w.forEach(t,i)}static nu=1;static Yi(t){t.__gohashid=GSet.nu++}static as(t){return t.__gohashid}}class MapKeySetIterator{$;ii;constructor(t){this.$=t,this.ii=t.w.keys()}[Symbol.iterator](){return this.$.w.keys()}key;value;get iterator(){return this}reset(){const t=this.$;this.ii=t.w.keys()}next(){const t=this.ii.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.$.w.size===0?null:(this.ii=this.$.w.keys(),this.ii.next().value)}any(t){for(const i of this.$.w)if(t(i[0]))return!0;return!1}all(t){for(const i of this.$.w)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.$.w)t(i[0]);return this}map(t){const i=this.$,e=new List;for(const s of i.w)e.add(t(s[0]));return e.iterator}filter(t){const i=this.$,e=new List;for(const s of i.w){const n=s[0];t(n)&&e.add(n)}return e.iterator}get count(){return this.$.size}gl(){this.key=null,this.value=null,this.ii=null}toString(){return"MapKeySetIterator"}}class MapKeySet extends GSet{$;constructor(t){super(),GSet.Yi(this),this.h=!0,this.$=t}[Symbol.iterator](){return this.w.keys()}values(){return this.w.keys()}g(){return this}rt(){return this}toString(){return"MapKeySet("+this.$.toString()+")"}add(t){Util.o("This Set is read-only: "+this.toString())}has(t){return this.$.has(t)}contains(t){return this.has(t)}delete(t){Util.o("This Set is read-only: "+this.toString())}remove(t){return this.delete(t)}clear(){Util.o("This Set is read-only: "+this.toString())}first(){return this.$.w.size===0?null:this.$.w.keys().next().value}any(t){for(const i of this.$.w)if(t(i[0]))return!0;return!1}all(t){for(const i of this.$.w)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.$.w)t(i[0]);return this}map(t){const i=new GSet;for(const e of this.$.w)i.add(t(e[0]));return i}filter(t){const i=new GSet;for(const e of this.$.w){const s=e[0];t(s)&&i.add(s)}return i}copy(){return new MapKeySet(this.$)}toSet(){const t=new GSet,i=this.$.w;for(const e of i)t.add(e[0]);return t}toArray(){const t=this.$.w,i=new Array(t.size);let e=0;for(const s of t)i[e]=s[0],e++;return i}toList(){const t=new List,i=this.$.w;for(const e of i)t.add(e[0]);return t}get count(){return this.$.size}get size(){return this.$.size}get iterator(){return this.$.size<=0?EmptyIterator.instance:new MapKeySetIterator(this.$)}}class MapValueSetIterator{$;ii;constructor(t){this.$=t,this.ii=t.w.values()}[Symbol.iterator](){return this.$.w.values()}key;value;get iterator(){return this}reset(){const t=this.$;this.ii=t.w.values()}next(){const t=this.ii.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.$.w.size===0?null:(this.ii=this.$.w.values(),this.ii.next().value)}any(t){for(const i of this.$.w)if(t(i[1]))return!0;return!1}all(t){for(const i of this.$.w)if(!t(i[1]))return!1;return!0}each(t){for(const i of this.$.w)t(i[1]);return this}map(t){const i=this.$,e=new List;for(const s of i.w)e.add(t(s[1]));return e.iterator}filter(t){const i=this.$,e=new List;for(const s of i.w){const n=s[1];t(n)&&e.add(n)}return e.iterator}get count(){return this.$.size}gl(){this.key=null,this.value=null,this.ii=null}toString(){return"MapValueSetIterator"}}class KeyValuePair{constructor(t,i){this.key=t,this.value=i}toString(){return"{"+this.key+":"+this.value+"}"}key;value}class MapIterator{$;ii;constructor(t){this.$=t,this.ii=t.w.entries()}[Symbol.iterator](){return this.$.w.entries()}key;value;get iterator(){return this}reset(){const t=this.$;this.ii=t.w.entries()}next(){const t=this.ii.next();return t.done?(this.key=null,this.value=null,!1):(this.key=t.value[0],this.value=t.value[1],!0)}hasNext(){return this.next()}first(){if(this.$.w.size===0)return null;this.ii=this.$.w.entries();const t=this.ii.next().value;return this.key=t[0],this.value=t[1],new KeyValuePair(t[0],t[1])}any(t){return this.$.any(t)}all(t){return this.$.all(t)}each(t){return this.$.each(t),this}map(t){const i=new List;let e=null;return this.$.w.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),i.add(t(e))}),i.iterator}filter(t){const i=new List;let e=null;return this.$.w.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),t(e)&&(i.add(e),e=null)}),i.iterator}get count(){return this.$.size}gl(){this.key=null,this.value=null,this.ii=null}toString(){return"MapIterator"}}class GMap{h;w;constructor(t){GSet.Yi(this),this.h=!1,this.w=new Map,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.w.entries()}entries(){return this.w.entries()}g(){return this.h=!0,this}rt(){return this.h=!1,this}toString(){return"Map()#"+GSet.as(this)}set(t,i){return this.h&&Util.T(this,t),this.w.set(t,i),this}add(t,i){return this.set(t,i)}addAll(t){if(t===null)return this;if(this.h&&Util.T(this),Array.isArray(t)){const i=t.length;for(let e=0;ei.x.toFixed(t)+" "+i.y.toFixed(t)}toString(){return"Point("+this.x+","+this.y+")"}equals(t){return t instanceof Point?this.b===t.x&&this.k===t.y:!1}equalTo(t,i){return this.b===t&&this.k===i}equalsApprox(t){return Geo.u(this.b,t.x)&&Geo.u(this.k,t.y)}add(t){return this.b+=t.x,this.k+=t.y,this}subtract(t){return this.b-=t.x,this.k-=t.y,this}offset(t,i){return this.b+=t,this.k+=i,this}rotate(t){if(t===0)return this;const i=this.b,e=this.k;if(i===0&&e===0)return this;let s=0,n=0;if(t>=360?t-=360:t<0&&(t+=360),t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const o=t*Math.PI/180;s=Math.cos(o),n=Math.sin(o)}return this.b=s*i-n*e,this.k=n*i+s*e,this}scale(t,i){return this.b*=t,this.k*=i,this}distanceSquaredPoint(t){const i=t.x-this.b,e=t.y-this.k;return i*i+e*e}distanceSquared(t,i){const e=t-this.b,s=i-this.k;return e*e+s*s}normalize(){const t=this.b,i=this.k,e=Math.sqrt(t*t+i*i);return e>0&&(this.b=t/e,this.k=i/e),this}directionPoint(t){return this.ZN(t.x-this.b,t.y-this.k)}direction(t,i){return this.ZN(t-this.b,i-this.k)}ZN(t,i){if(t===0)return i>0?90:i<0?270:0;if(i===0)return t>0?0:180;{if(isNaN(t)||isNaN(i))return 0;let e=Math.atan(Math.abs(i/t))*180/Math.PI;return t<0?i<0?e+=180:e=180-e:i<0&&(e=360-e),e}}static compareWithLineSegment(t,i,e,s,n,o){return Geo.ou(t,i,e,s,n,o)}compareWithLineSegmentPoint(t,i){return Geo.ou(t.x,t.y,i.x,i.y,this.x,this.y)}static intersectingLineSegments(t,i,e,s,n,o,r,l){return Geo.ru(t,i,e,s,n,o,r,l)}projectOntoLineSegment(t,i,e,s){return Geo.ml(t,i,e,s,this.b,this.k,this),this}projectOntoLineSegmentPoint(t,i){return Geo.ml(t.x,t.y,i.x,i.y,this.b,this.k,this),this}snapToGrid(t,i,e,s){return Geo.Eg(this.b,this.k,t,i,e,s,this),this}snapToGridPoint(t,i){return Geo.Eg(this.b,this.k,t.x,t.y,i.width,i.height,this),this}setRectSpot(t,i){return this.b=t.x+i.x*t.width+i.offsetX,this.k=t.y+i.y*t.height+i.offsetY,this}setSpot(t,i,e,s,n){return this.b=t+n.x*e+n.offsetX,this.k=i+n.y*s+n.offsetY,this}D(t){return t.xt(this),this}Ie(t){return t._e(this),this}static distanceLineSegmentSquared(t,i,e,s,n,o){let r=n-e,l=o-s;const h=r*r+l*l,a=e-t,c=s-i,f=-a*r-c*l;if(f<=0||f>=h)return r=n-t,l=o-i,Math.min(a*a+c*c,r*r+l*l);{const u=r*c-l*a;return u*u/h}}static distanceSquared(t,i,e,s){const n=e-t,o=s-i;return n*n+o*o}static direction(t,i,e,s){const n=e-t,o=s-i;if(n===0)return o>0?90:o<0?270:0;if(o===0)return n>0?0:180;{if(isNaN(n)||isNaN(o))return 0;let r=Math.atan(Math.abs(o/n))*180/Math.PI;return n<0?o<0?r+=180:r=180-r:o<0&&(r=360-r),r}}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}isReal(){return isFinite(this.x)&&isFinite(this.y)}static Po=new Point(0,0).it();static QN=new Point(-1/0,-1/0).it();static _N=new Point(1/0,1/0).it();static tC=new Point(6,6).it();static Ak=new Point(NaN,NaN).it();static Tk=[];static l(){const t=Point.Tk.pop();return t===void 0?new Point:t}static X(t,i){const e=Point.Tk.pop();return e===void 0?new Point(t,i):(e.x=t,e.y=i,e)}static s(t){Point.Tk.push(t)}}class Size{j;H;h;constructor(t,i){t===void 0?(this.j=0,this.H=0):typeof t=="number"&&(t>=0||isNaN(t))&&typeof i=="number"&&(i>=0||isNaN(i))?(this.j=t,this.H=i):Util.o("Invalid arguments to Size constructor: "+t+", "+i),this.h=!1}a(t){return this.j=t.j,this.H=t.H,this}e(t,i){return this.j=t,this.H=i,this}setTo(t,i){return this.j=t,this.H=i,this}set(t){return this.j=t.j,this.H=t.H,this}copy(){const t=new Size;return t.j=this.j,t.H=this.H,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}rt(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;return n=i[e++],n&&(o=parseFloat(n)),new Size(s,o)}else return new Size}static stringify(t){return t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.i(t,"number",Size,"stringifyFixed:digits"),i=>i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Size("+this.width+","+this.height+")"}equals(t){return t instanceof Size?this.j===t.width&&this.H===t.height:!1}equalTo(t,i){return this.j===t&&this.H===i}equalsApprox(t){return Geo.u(this.j,t.width)&&Geo.u(this.H,t.height)}inflate(t,i){const e=this.width+t;this.j=e>=0?e:0;const s=this.height+i;return this.H=s>=0?s:0,this}get width(){return this.j}set width(t){t<0&&Util._(t,">= 0",Size,"width"),this.j=t}get height(){return this.H}set height(t){t<0&&Util._(t,">= 0",Size,"height"),this.H=t}isReal(){return isFinite(this.width)&&isFinite(this.height)}static lu=new Size(0,0).it();static Dk=new Size(1,1).it();static iC=new Size(6,6).it();static hu=new Size(8,8).it();static eC=new Size(10,10).it();static sC=new Size(1/0,1/0).it();static gw=new Size(NaN,NaN).it();static nC=[];static l(){const t=Size.nC.pop();return t===void 0?new Size:t}static s(t){Size.nC.push(t)}}class Rect{b;k;j;H;h;constructor(t,i,e,s){if(t===void 0)this.b=0,this.k=0,this.j=0,this.H=0;else if(typeof t=="number"&&typeof i=="number"&&typeof e=="number"&&(e>=0||isNaN(e))&&typeof s=="number"&&(s>=0||isNaN(s)))this.b=t,this.k=i,this.j=e,this.H=s;else if(t instanceof Point){const n=t.x,o=t.y;if(i instanceof Point){const r=i.x,l=i.y;this.b=Math.min(n,r),this.k=Math.min(o,l),this.j=Math.abs(n-r),this.H=Math.abs(o-l)}else i instanceof Size?(this.b=n,this.k=o,this.j=i.width,this.H=i.height):Util.o("Incorrect second argument supplied to Rect constructor "+i)}else Util.o("Invalid arguments to Rect constructor: "+t+", "+i+", "+e+", "+s);this.h=!1}a(t){return this.b=t.b,this.k=t.k,this.j=t.j,this.H=t.H,this}e(t,i,e,s){return this.b=t,this.k=i,this.j=e,this.H=s,this}En(t,i){return this.j=t,this.H=i,this}setTo(t,i,e,s){return this.b=t,this.k=i,this.j=e,this.H=s,this}set(t){return this.b=t.b,this.k=t.k,this.j=t.j,this.H=t.H,this}setPoint(t){return this.b=t.x,this.k=t.y,this}setSize(t){return this.j=t.width,this.H=t.height,this}copy(){const t=new Rect;return t.b=this.b,t.k=this.k,t.j=this.j,t.H=this.H,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}rt(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),new Rect(s,o,r,l)}else return new Rect}static stringify(t){return t.x.toString()+" "+t.y.toString()+" "+t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.i(t,"number",Rect,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Rect("+this.x+","+this.y+","+this.width+","+this.height+")"}equals(t){return t instanceof Rect?this.b===t.x&&this.k===t.y&&this.j===t.width&&this.H===t.height:!1}equalTo(t,i,e,s){return this.b===t&&this.k===i&&this.j===e&&this.H===s}equalsApprox(t){return Geo.u(this.b,t.x)&&Geo.u(this.k,t.y)&&Geo.u(this.j,t.width)&&Geo.u(this.H,t.height)}equalsApproxTo(t,i,e,s){return Geo.u(this.b,t)&&Geo.u(this.k,i)&&Geo.u(this.j,e)&&Geo.u(this.H,s)}equalsApproxClose(t){return Geo.K(this.b,t.x)&&Geo.K(this.k,t.y)&&Geo.K(this.j,t.width)&&Geo.K(this.H,t.height)}containsPoint(t){return this.b<=t.x&&this.b+this.j>=t.x&&this.k<=t.y&&this.k+this.H>=t.y}containsRect(t){return this.b<=t.x&&t.x+t.width<=this.b+this.j&&this.k<=t.y&&t.y+t.height<=this.k+this.H}contains(t,i,e,s){return e===void 0&&(e=0),s===void 0&&(s=0),this.b<=t&&t+e<=this.b+this.j&&this.k<=i&&i+s<=this.k+this.H}offset(t,i){return this.b+=t,this.k+=i,this}inflate(t,i){return this.mw(i,t,i,t)}addMargin(t){return this.mw(t.top,t.right,t.bottom,t.left)}subtractMargin(t){return this.mw(-t.top,-t.right,-t.bottom,-t.left)}grow(t,i,e,s){return this.mw(t,i,e,s)}mw(t,i,e,s){const n=this.j;i+s<=-n?(this.b+=n/2,this.j=0):(this.b-=s,this.j+=i+s);const o=this.H;return t+e<=-o?(this.k+=o/2,this.H=0):(this.k-=t,this.H+=t+e),this}intersectRect(t){return this.oC(t.x,t.y,t.width,t.height)}intersect(t,i,e,s){return this.oC(t,i,e,s)}oC(t,i,e,s){const n=Math.max(this.b,t),o=Math.max(this.k,i),r=Math.min(this.b+this.j,t+e),l=Math.min(this.k+this.H,i+s);return this.b=n,this.k=o,this.j=Math.max(0,r-n),this.H=Math.max(0,l-o),this}intersectsRect(t){return this.intersects(t.x,t.y,t.width,t.height)}intersects(t,i,e,s){let n=this.j;const o=this.b;if(n!==1/0&&e!==1/0&&(n+=o,e+=t,isNaN(e)||isNaN(n)||o>e||t>n))return!1;let r=this.H;const l=this.k;return!(r!==1/0&&s!==1/0&&(r+=l,s+=i,isNaN(s)||isNaN(r)||l>s||i>r))}intersectsRectPlus(t,i){let e=this.j,s=t.width+i+i;const n=this.b,o=t.x-i;if(e+=n,s+=o,n>s||o>e)return!1;let r=this.H,l=t.height+i+i;const h=this.k,a=t.y-i;return r+=h,l+=a,!(h>l||a>r)}unionPoint(t){return this.unionNoCheck(t.x,t.y,0,0)}unionRect(t){return this.unionNoCheck(t.b,t.k,t.j,t.H)}union(t,i,e,s){return e===void 0&&(e=0),s===void 0&&(s=0),this.unionNoCheck(t,i,e,s)}unionNoCheck(t,i,e,s){const n=Math.min(this.b,t),o=Math.min(this.k,i),r=Math.max(this.b+this.j,t+e),l=Math.max(this.k+this.H,i+s);return this.b=n,this.k=o,this.j=r-n,this.H=l-o,this}setSpot(t,i,e){return this.b=t-e.offsetX-e.x*this.j,this.k=i-e.offsetY-e.y*this.H,this}static contains(t,i,e,s,n,o,r,l){return r===void 0&&(r=0),l===void 0&&(l=0),t<=n&&n+r<=t+e&&i<=o&&o+l<=i+s}static intersects(t,i,e,s,n,o,r,l){let h=e,a=r;const c=t,f=n;if(h+=c,a+=f,c>a||f>h)return!1;let u=s,d=l;const m=i,g=o;return u+=m,d+=g,!(m>d||g>u)}static intersectsLineSegment(t,i,e,s,n,o,r,l){return Geo.rC(t,i,e,s,n,o,r,l)}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}get width(){return this.j}set width(t){t<0&&Util._(t,">= 0",Rect,"width"),this.j=t}get height(){return this.H}set height(t){t<0&&Util._(t,">= 0",Rect,"height"),this.H=t}get left(){return this.b}set left(t){this.b=t}get top(){return this.k}set top(t){this.k=t}get right(){return this.b+this.j}set right(t){this.b+=t-(this.b+this.j)}get bottom(){return this.k+this.H}set bottom(t){this.k+=t-(this.k+this.H)}get position(){return new Point(this.b,this.k)}set position(t){this.b=t.x,this.k=t.y}get size(){return new Size(this.j,this.H)}set size(t){this.j=t.width,this.H=t.height}get center(){return new Point(this.b+this.j/2,this.k+this.H/2)}set center(t){this.b=t.x-this.j/2,this.k=t.y-this.H/2}get centerX(){return this.b+this.j/2}set centerX(t){this.b=t-this.j/2}get centerY(){return this.k+this.H/2}set centerY(t){this.k=t-this.H/2}isReal(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)}isEmpty(){return this.width===0&&this.height===0}static pw=new Rect(0,0,0,0).it();static TD=new Rect(NaN,NaN,NaN,NaN).it();static Fk=[];static l(){const t=Rect.Fk.pop();return t===void 0?new Rect:t}static X(t,i,e,s){const n=Rect.Fk.pop();return n===void 0?new Rect(t,i,e,s):n.e(t,i,e,s)}static s(t){Rect.Fk.push(t)}}class Margin{nn;on;rn;ln;h;constructor(t,i,e,s){t===void 0?(this.nn=0,this.on=0,this.rn=0,this.ln=0):i===void 0?(i=t,e=t,s=t,this.top=t,this.right=i,this.bottom=e,this.left=s):e===void 0?(e=t,s=i,this.top=t,this.right=i,this.bottom=e,this.left=s):s!==void 0?(this.top=t,this.right=i,this.bottom=e,this.left=s):Util.o("Invalid arguments to Margin constructor: "+t+", "+i+", "+e+", "+s),this.h=!1}a(t){return this.nn=t.nn,this.on=t.on,this.rn=t.rn,this.ln=t.ln,this}setTo(t,i,e,s){return this.nn=t,this.on=i,this.rn=e,this.ln=s,this}set(t){return this.nn=t.nn,this.on=t.on,this.rn=t.rn,this.ln=t.ln,this}copy(){const t=new Margin;return t.nn=this.nn,t.on=this.on,t.rn=this.rn,t.ln=this.ln,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}rt(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=NaN;for(;i[e]==="";)e++;let n=i[e++];if(n&&(s=parseFloat(n)),isNaN(s))return new Margin;let o=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(o=parseFloat(n)),isNaN(o))return new Margin(s);let r=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(r=parseFloat(n)),isNaN(r))return new Margin(s,o);let l=NaN;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),isNaN(l)?new Margin(s,o):new Margin(s,o,r,l)}else return new Margin}static stringify(t){return t.top.toString()+" "+t.right.toString()+" "+t.bottom.toString()+" "+t.left.toString()}static stringifyFixed(t){return Util.i(t,"number",Margin,"stringifyFixed:digits"),i=>i.top.toFixed(t)+" "+i.right.toFixed(t)+" "+i.bottom.toFixed(t)+" "+i.left.toFixed(t)}toString(){return"Margin("+this.top+","+this.right+","+this.bottom+","+this.left+")"}equals(t){return t instanceof Margin?this.nn===t.top&&this.on===t.right&&this.rn===t.bottom&&this.ln===t.left:!1}equalTo(t,i,e,s){return this.nn===t&&this.on===i&&this.rn===e&&this.ln===s}equalsApprox(t){return Geo.u(this.nn,t.top)&&Geo.u(this.on,t.right)&&Geo.u(this.rn,t.bottom)&&Geo.u(this.ln,t.left)}get top(){return this.nn}set top(t){this.nn=t}get right(){return this.on}set right(t){this.on=t}get bottom(){return this.rn}set bottom(t){this.rn=t}get left(){return this.ln}set left(t){this.ln=t}isReal(){return isFinite(this.top)&&isFinite(this.right)&&isFinite(this.bottom)&&isFinite(this.left)}static Ug=new Margin(0,0,0,0).it();static lC=new Margin(2,2,2,2).it();static hC=[];static l(){const t=Margin.hC.pop();return t===void 0?new Margin:t}static s(t){Margin.hC.push(t)}}class Spot{b;k;As;Ts;h;constructor(t,i,e,s){t===void 0?(this.b=0,this.k=0,this.As=0,this.Ts=0):(i===void 0&&(i=0),e===void 0&&(e=0),s===void 0&&(s=0),this.x=t,this.y=i,this.offsetX=e,this.offsetY=s),this.h=!1}a(t){return this.b=t.b,this.k=t.k,this.As=t.As,this.Ts=t.Ts,this}setTo(t,i,e,s){return this.b=t,this.k=i,this.As=e,this.Ts=s,this}set(t){return this.b=t.b,this.k=t.k,this.As=t.As,this.Ts=t.Ts,this}copy(){const t=new Spot;return t.b=this.b,t.k=this.k,t.As=this.As,t.Ts=this.Ts,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}rt(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}Ee(t){return this.b=NaN,this.k=NaN,this.As=t,this}tE(t,i){(isNaN(t)||t>1||t<0)&&Util._(t,"0 <= "+i+" <= 1",Spot,i)}iE(t,i){(isNaN(t)||t===1/0||t===-1/0)&&Util._(t,"real number, not NaN or Infinity",Spot,i)}static parse(t){if(typeof t=="string"){if(t=t.trim(),t==="None")return Spot.None;if(t==="TopLeft")return Spot.TopLeft;if(t==="Top"||t==="TopCenter"||t==="MiddleTop")return Spot.TopCenter;if(t==="TopRight")return Spot.TopRight;if(t==="Left"||t==="LeftCenter"||t==="MiddleLeft")return Spot.LeftCenter;if(t==="Center")return Spot.Center;if(t==="Right"||t==="RightCenter"||t==="MiddleRight")return Spot.RightCenter;if(t==="BottomLeft")return Spot.BottomLeft;if(t==="Bottom"||t==="BottomCenter"||t==="MiddleBottom")return Spot.BottomCenter;if(t==="BottomRight")return Spot.BottomRight;if(t==="TopSide")return Spot.TopSide;if(t==="LeftSide")return Spot.LeftSide;if(t==="RightSide")return Spot.RightSide;if(t==="BottomSide")return Spot.BottomSide;if(t==="TopBottomSides")return Spot.TopBottomSides;if(t==="LeftRightSides")return Spot.LeftRightSides;if(t==="TopLeftSides")return Spot.TopLeftSides;if(t==="TopRightSides")return Spot.TopRightSides;if(t==="BottomLeftSides")return Spot.BottomLeftSides;if(t==="BottomRightSides")return Spot.BottomRightSides;if(t==="NotTopSide")return Spot.NotTopSide;if(t==="NotLeftSide")return Spot.NotLeftSide;if(t==="NotRightSide")return Spot.NotRightSide;if(t==="NotBottomSide")return Spot.NotBottomSide;if(t==="AllSides")return Spot.AllSides;if(t==="Default")return Spot.Default;const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n!==void 0&&n.length>0&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n!==void 0&&n.length>0&&(l=parseFloat(n)),new Spot(s,o,r,l)}else return new Spot}static stringify(t){return t.isSpot()?t.x.toString()+" "+t.y.toString()+" "+t.offsetX.toString()+" "+t.offsetY.toString():t.toString()}static stringifyFixed(t){return Util.i(t,"number",Spot,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.offsetX.toFixed(t)+" "+i.offsetY.toFixed(t)}toString(){return this.isSpot()?this.As===0&&this.Ts===0?"Spot("+this.x+","+this.y+")":"Spot("+this.x+","+this.y+","+this.offsetX+","+this.offsetY+")":this.equals(Spot.None)?"None":this.equals(Spot.TopLeft)?"TopLeft":this.equals(Spot.TopCenter)?"Top":this.equals(Spot.TopRight)?"TopRight":this.equals(Spot.LeftCenter)?"Left":this.equals(Spot.Center)?"Center":this.equals(Spot.RightCenter)?"Right":this.equals(Spot.BottomLeft)?"BottomLeft":this.equals(Spot.BottomCenter)?"Bottom":this.equals(Spot.BottomRight)?"BottomRight":this.equals(Spot.TopSide)?"TopSide":this.equals(Spot.LeftSide)?"LeftSide":this.equals(Spot.RightSide)?"RightSide":this.equals(Spot.BottomSide)?"BottomSide":this.equals(Spot.TopBottomSides)?"TopBottomSides":this.equals(Spot.LeftRightSides)?"LeftRightSides":this.equals(Spot.TopLeftSides)?"TopLeftSides":this.equals(Spot.TopRightSides)?"TopRightSides":this.equals(Spot.BottomLeftSides)?"BottomLeftSides":this.equals(Spot.BottomRightSides)?"BottomRightSides":this.equals(Spot.NotTopSide)?"NotTopSide":this.equals(Spot.NotLeftSide)?"NotLeftSide":this.equals(Spot.NotRightSide)?"NotRightSide":this.equals(Spot.NotBottomSide)?"NotBottomSide":this.equals(Spot.AllSides)?"AllSides":this.equals(Spot.Default)?"Default":"None"}equals(t){return t instanceof Spot?(this.b===t.x||isNaN(this.b)&&isNaN(t.x))&&(this.k===t.y||isNaN(this.k)&&isNaN(t.y))&&this.As===t.offsetX&&this.Ts===t.offsetY:!1}opposite(){return new Spot(.5-(this.b-.5),.5-(this.k-.5),-this.As,-this.Ts)}includesSide(t){if(!this.isSide())return!1;if(!t.isSide())if(t.equals(Spot.Left))t=Spot.LeftSide;else if(t.equals(Spot.Right))t=Spot.RightSide;else if(t.equals(Spot.Top))t=Spot.TopSide;else if(t.equals(Spot.Bottom))t=Spot.BottomSide;else return!1;const i=this.Ts,e=t.offsetY;return(i&e)===e}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}get offsetX(){return this.As}set offsetX(t){this.As=t}get offsetY(){return this.Ts}set offsetY(t){this.Ts=t}isSpot(){return!isNaN(this.x)&&!isNaN(this.y)}isNoSpot(){return isNaN(this.x)||isNaN(this.y)}isSide(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===1&&this.offsetY!==0}isNone(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===0&&this.offsetY===0}isDefault(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===-1&&this.offsetY===0}static None=new Spot(0,0,0,0).Ee(0).it();static Default=new Spot(0,0,-1,0).Ee(-1).it();static TopLeft=new Spot(0,0,0,0).it();static TopCenter=new Spot(.5,0,0,0).it();static TopRight=new Spot(1,0,0,0).it();static LeftCenter=new Spot(0,.5,0,0).it();static Center=new Spot(.5,.5,0,0).it();static RightCenter=new Spot(1,.5,0,0).it();static BottomLeft=new Spot(0,1,0,0).it();static BottomCenter=new Spot(.5,1,0,0).it();static BottomRight=new Spot(1,1,0,0).it();static MiddleTop=Spot.TopCenter;static MiddleLeft=Spot.LeftCenter;static MiddleRight=Spot.RightCenter;static MiddleBottom=Spot.BottomCenter;static Top=Spot.TopCenter;static Left=Spot.LeftCenter;static Right=Spot.RightCenter;static Bottom=Spot.BottomCenter;static TopSide=new Spot(0,0,1,1).Ee(1).it();static LeftSide=new Spot(0,0,1,2).Ee(1).it();static RightSide=new Spot(0,0,1,4).Ee(1).it();static BottomSide=new Spot(0,0,1,8).Ee(1).it();static TopBottomSides=new Spot(0,0,1,9).Ee(1).it();static LeftRightSides=new Spot(0,0,1,6).Ee(1).it();static TopLeftSides=new Spot(0,0,1,3).Ee(1).it();static TopRightSides=new Spot(0,0,1,5).Ee(1).it();static BottomLeftSides=new Spot(0,0,1,10).Ee(1).it();static BottomRightSides=new Spot(0,0,1,12).Ee(1).it();static NotTopSide=new Spot(0,0,1,14).Ee(1).it();static NotLeftSide=new Spot(0,0,1,13).Ee(1).it();static NotRightSide=new Spot(0,0,1,11).Ee(1).it();static NotBottomSide=new Spot(0,0,1,7).Ee(1).it();static AllSides=new Spot(0,0,1,15).Ee(1).it();static Rk=new Spot(.156,.156).it();static vk=new Spot(.844,.844).it();static aC=[];static l(){const t=Spot.aC.pop();return t===void 0?new Spot:t}static s(t){Spot.aC.push(t)}}class Transform{m11;m12;m21;m22;dx;dy;constructor(){this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0}set(t){return this.m11=t.m11,this.m12=t.m12,this.m21=t.m21,this.m22=t.m22,this.dx=t.dx,this.dy=t.dy,this}setTo(t,i,e,s,n,o){return this.m11=t,this.m12=i,this.m21=e,this.m22=s,this.dx=n,this.dy=o,this}copy(){const t=new Transform;return t.m11=this.m11,t.m12=this.m12,t.m21=this.m21,t.m22=this.m22,t.dx=this.dx,t.dy=this.dy,t}toString(){return"Transform("+this.m11+","+this.m12+","+this.m21+","+this.m22+","+this.dx+","+this.dy+")"}equals(t){return this.m11===t.m11&&this.m12===t.m12&&this.m21===t.m21&&this.m22===t.m22&&this.dx===t.dx&&this.dy===t.dy}Ok(){return this.dx===0&&this.dy===0&&this.m11===1&&this.m12===0&&this.m21===0&&this.m22===1}Ri(){return this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0,this}tc(t){const i=this.m11*t.m11+this.m21*t.m12,e=this.m12*t.m11+this.m22*t.m12,s=this.m11*t.m21+this.m21*t.m22,n=this.m12*t.m21+this.m22*t.m22;return this.dx=this.m11*t.dx+this.m21*t.dy+this.dx,this.dy=this.m12*t.dx+this.m22*t.dy+this.dy,this.m11=i,this.m12=e,this.m21=s,this.m22=n,this}cC(t){const i=1/(t.m11*t.m22-t.m12*t.m21),e=t.m22*i,s=-t.m12*i,n=-t.m21*i,o=t.m11*i,r=i*(t.m21*t.dy-t.m22*t.dx),l=i*(t.m12*t.dx-t.m11*t.dy),h=this.m11*e+this.m21*s,a=this.m12*e+this.m22*s,c=this.m11*n+this.m21*o,f=this.m12*n+this.m22*o;return this.dx=this.m11*r+this.m21*l+this.dx,this.dy=this.m12*r+this.m22*l+this.dy,this.m11=h,this.m12=a,this.m21=c,this.m22=f,this}yw(){const t=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*t,e=-this.m12*t,s=-this.m21*t,n=this.m11*t,o=t*(this.m21*this.dy-this.m22*this.dx),r=t*(this.m12*this.dx-this.m11*this.dy);return this.m11=i,this.m12=e,this.m21=s,this.m22=n,this.dx=o,this.dy=r,this}cs(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return this;this.Ds(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m11*s+this.m21*n,r=this.m12*s+this.m22*n,l=this.m11*-n+this.m21*s,h=this.m12*-n+this.m22*s;return this.m11=o,this.m12=r,this.m21=l,this.m22=h,this.Ds(-i,-e),this}Ds(t,i){return this.dx+=this.m11*t+this.m21*i,this.dy+=this.m12*t+this.m22*i,this}st(t,i){return i===void 0&&(i=t),this.m11*=t,this.m12*=t,this.m21*=i,this.m22*=i,this}DD(){if(this.m11===1&&this.m12===0)return 0;let t=Math.atan2(this.m12,this.m11)*180/Math.PI;return t<0&&(t+=360),t}xt(t){const i=t.x,e=t.y;return t.e(i*this.m11+e*this.m21+this.dx,i*this.m12+e*this.m22+this.dy)}_e(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=t.x-this.dx,l=t.y-this.dy;return t.e(r*e+l*n,r*s+l*o)}ww(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=i*(this.m21*this.dy-this.m22*this.dx),l=i*(this.m12*this.dx-this.m11*this.dy),h=t.x*1.25,a=t.y*1.2;return t.e(h*e+a*n+r,h*s+a*o+l)}xw(t){const i=t.x,e=t.y,s=i+t.width,n=e+t.height,o=this.m11,r=this.m12,l=this.m21,h=this.m22,a=this.dx,c=this.dy,f=i*o+e*l+a,u=i*r+e*h+c,d=s*o+e*l+a,m=s*r+e*h+c,g=i*o+n*l+a,p=i*r+n*h+c,y=s*o+n*l+a,x=s*r+n*h+c;let k=f,b=f,P=u,M=u;return k=Math.min(k,d),b=Math.max(b,d),P=Math.min(P,m),M=Math.max(M,m),k=Math.min(k,g),b=Math.max(b,g),P=Math.min(P,p),M=Math.max(M,p),k=Math.min(k,y),b=Math.max(b,y),P=Math.min(P,x),M=Math.max(M,x),t.e(k,P,b-k,M-P),t}static fC=[];static l(){const t=Transform.fC.pop();return t===void 0?new Transform:t}static s(t){Transform.fC.push(t)}static Ik="54a702f3e53909c447824c6706603faf4c"}const Geo={FD:"7da71ca0ad381e90",Un:4*((Math.sqrt(2)-1)/3),uC:null,bw:w=>{if(w<=0)return 0;let t=Geo.uC;if(t===null){t=[];for(let i=0;i<=2e3;i++)t[i]=Math.sqrt(i);Geo.uC=t}if(w<1){const i=1/w;return i<=2e3?1/t[i|0]:Math.sqrt(w)}else return w<=2e3?t[w|0]:Math.sqrt(w)},u:(w,t)=>{const i=w-t;return i<.5&&i>-.5},K:(w,t)=>{const i=w-t;return i<5e-8&&i>-5e-8},vi:(w,t,i,e,s,n,o)=>{s<=0&&(s=1e-6);let r=0,l=0,h=0,a=0;if(wu-d)if(w-i>s||i-w>s){const g=(e-t)/(i-w)*(n-w)+t;if(g-s<=o&&o<=g+s)return!0}else return!0;else if(t-e>s||e-t>s){const g=(i-w)/(e-t)*(o-t)+w;if(g-s<=n&&n<=g+s)return!0}else return!0}return!1},kw:(w,t,i,e,s,n,o,r,l,h,a,c)=>{if(!Geo.vi(w,t,o,r,c,i,e)||!Geo.vi(w,t,o,r,c,s,n)){const f=(w+i)/2,u=(t+e)/2,d=(i+s)/2,m=(e+n)/2,g=(s+o)/2,p=(n+r)/2,y=(f+d)/2,x=(u+m)/2,k=(d+g)/2,b=(m+p)/2,P=(y+k)/2,M=(x+b)/2;return Geo.kw(w,t,f,u,y,x,P,M,l,h,a,c)||Geo.kw(P,M,k,b,g,p,o,r,l,h,a,c)}else return Geo.vi(w,t,o,r,c,h,a)},dC:(w,t,i,e,s,n,o,r,l)=>{const h=(w+i)/2,a=(t+e)/2,c=(i+s)/2,f=(e+n)/2,u=(s+o)/2,d=(n+r)/2,m=(h+c)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2;return l.e((m+p)/2,(g+y)/2),l},RD:(w,t,i,e,s,n,o,r)=>{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(s+o)/2,u=(n+r)/2,d=(l+a)/2,m=(h+c)/2,g=(a+f)/2,p=(c+u)/2;return Point.direction(d,m,g,p)},au:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.vi(w,t,o,r,l,i,e)||!Geo.vi(w,t,o,r,l,s,n)){const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.au(w,t,a,c,g,p,k,b,l,h),Geo.au(k,b,y,x,d,m,o,r,l,h)}else h.unionNoCheck(w,t,0,0),h.unionNoCheck(o,r,0,0);return h},Bn:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.vi(w,t,o,r,l,i,e)||!Geo.vi(w,t,o,r,l,s,n)){const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.Bn(w,t,a,c,g,p,k,b,l,h),Geo.Bn(k,b,y,x,d,m,o,r,l,h)}else h.length===0&&(h.push(w),h.push(t)),h.push(o),h.push(r);return h},Ek:(w,t,i,e,s,n,o,r,l,h)=>{if(Geo.vi(w,t,s,n,h,i,e))return Geo.vi(w,t,s,n,h,r,l);{const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(a+f)/2,m=(c+u)/2;return Geo.Ek(w,t,a,c,d,m,o,r,l,h)||Geo.Ek(d,m,f,u,s,n,o,r,l,h)}},eE:(w,t,i,e,s,n,o)=>{const r=(w+i)/2,l=(t+e)/2,h=(i+s)/2,a=(e+n)/2;return o.e((r+h)/2,(l+a)/2),o},Uk:(w,t,i,e,s,n,o,r)=>{if(Geo.vi(w,t,s,n,o,i,e))r.unionNoCheck(w,t,0,0),r.unionNoCheck(s,n,0,0);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(l+a)/2,u=(h+c)/2;Geo.Uk(w,t,l,h,f,u,o,r),Geo.Uk(f,u,a,c,s,n,o,r)}return r},Bg:(w,t,i,e,s,n,o,r)=>{if(Geo.vi(w,t,s,n,o,i,e))r.length===0&&(r.push(w),r.push(t)),r.push(s),r.push(n);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(l+a)/2,u=(h+c)/2;Geo.Bg(w,t,l,h,f,u,o,r),Geo.Bg(f,u,a,c,s,n,o,r)}return r},Vg:(w,t,i,e,s,n,o,r,l,h,a,c,f,u)=>{if(!Geo.vi(w,t,o,r,f,i,e)||!Geo.vi(w,t,o,r,f,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,P=(g+y)/2,M=(p+x)/2,L=(k+P)/2,C=(b+M)/2;let S=1/0,N=!1,T=0,A=0;if(Geo.Vg(w,t,d,m,k,b,L,C,l,h,a,c,f,u)){const D=(u.x-l)*(u.x-l)+(u.y-h)*(u.y-h);D{let u=0;if(!Geo.vi(w,t,o,r,f,i,e)||!Geo.vi(w,t,o,r,f,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,P=(g+y)/2,M=(p+x)/2,L=(k+P)/2,C=(b+M)/2;u+=Geo.zg(w,t,d,m,k,b,L,C,l,h,a,c,f),u+=Geo.zg(L,C,P,M,y,x,o,r,l,h,a,c,f)}else{const d=(w-o)*(h-c)-(t-r)*(l-a);if(d===0)return u;const m=((w*r-t*o)*(l-a)-(w-o)*(l*c-h*a))/d,g=((w*r-t*o)*(h-c)-(t-r)*(l*c-h*a))/d;if(m>=a)return u;let p=0,y=0;if((l>a?l-a:a-l)<(h>c?h-c:c-h)){if(ty)return u}else if(wy)return u;d>0?u++:d<0&&u--}return u},ml:(w,t,i,e,s,n,o)=>{if(Geo.K(w,i)){let r=0,l=0;tl?(o.e(w,l),!1):(o.e(w,h),!0)}else if(Geo.K(t,e)){let r=0,l=0;wl?(o.e(l,t),!1):(o.e(h,t),!0)}else{const r=(i-w)*(i-w)+(e-t)*(e-t),l=((w-s)*(w-i)+(t-n)*(t-e))/r;if(l<-5e-6)return o.e(w,t),!1;if(l>1.000005)return o.e(i,e),!1;{const h=w+l*(i-w),a=t+l*(e-t);return o.e(h,a),!0}}},Vn:(w,t,i,e,s,n,o,r,l)=>{if(Geo.u(w,i)&&Geo.u(t,e))return l.e(w,t),!1;if(Geo.K(s,o)){if(Geo.K(w,i))return Geo.ml(w,t,i,e,s,n,l),!1;{const a=(e-t)/(i-w)*(s-w)+t;return Geo.ml(w,t,i,e,s,a,l)}}else{const h=(r-n)/(o-s);if(Geo.K(w,i)){const a=h*(w-s)+n;let c=0,f=0;return tf?(l.e(w,f),!1):(l.e(w,a),!0)}else{const a=(e-t)/(i-w);if(Geo.K(h,a))return Geo.ml(w,t,i,e,s,n,l),!1;{const c=(a*w-h*s+n-t)/(a-h);if(Geo.K(a,0)){let f=0,u=0;return wu?(l.e(u,t),!1):(l.e(c,t),!0)}else{const f=a*(c-w)+t;return Geo.ml(w,t,i,e,c,f,l)}}}}},sE:(w,t,i,e,s)=>Geo.Vn(i.x,i.y,e.x,e.y,w.x,w.y,t.x,t.y,s),nE:(w,t,i,e,s,n,o,r,l,h)=>{let a=1/0;function c(P,M){const L=(P-w)*(P-w)+(M-t)*(M-t);Lw?i-w:w-i)<.5){const P=1-(i-k)*(i-k)/(y*y);if(P<0)return l;const M=Math.sqrt(P),L=x*M+b,C=-x*M+b;c(i,L),c(i,C)}else{const P=(e-t)/(i-w),M=1/(y*y)+P*P/(x*x),L=2*P*(t-P*w)/(x*x)-2*P*b/(x*x)-2*k/(y*y),C=2*P*w*b/(x*x)-2*t*b/(x*x)+b*b/(x*x)+k*k/(y*y)-1+(t-P*w)*(t-P*w)/(x*x),S=L*L-4*M*C;if(S<0)return l;const N=Math.sqrt(S),T=(-L+N)/(2*M);c(T,P*T-P*w+t);const A=(-L-N)/(2*M);c(A,P*A-P*w+t)}return l},pl:(w,t,i,e,s,n,o,r,l)=>{let h=1e21,a=w,c=t;if(Geo.Vn(w,t,w,e,s,n,o,r,l)){const f=(l.x-s)*(l.x-s)+(l.y-n)*(l.y-n);fGeo.rC(w.x,w.y,w.width,w.height,t.x,t.y,i.x,i.y),rC:(w,t,i,e,s,n,o,r)=>{const l=w,h=w+i,a=t,c=t+e;if(s===o){let f=0,u=0;return n=a}if(n===r){let f=0,u=0;return s=l}return!!(Rect.contains(w,t,i,e,s,n)||Rect.contains(w,t,i,e,o,r)||Geo.ru(l,a,h,a,s,n,o,r)||Geo.ru(h,a,h,c,s,n,o,r)||Geo.ru(h,c,l,c,s,n,o,r)||Geo.ru(l,c,l,a,s,n,o,r))},ru:(w,t,i,e,s,n,o,r)=>w===i&&t===e&&s===o&&n===r?w===s&&t===n:Geo.ou(w,t,i,e,s,n)*Geo.ou(w,t,i,e,o,r)<=0&&Geo.ou(s,n,o,r,w,t)*Geo.ou(s,n,o,r,i,e)<=0,ou:(w,t,i,e,s,n)=>{const o=i-w,r=e-t;let l=s-w,h=n-t,a=l*r-h*o;return a===0&&(a=l*o+h*r,a>0&&(l-=o,h-=r,a=l*o+h*r,a<0&&(a=0))),a},Xg:w=>(w<0&&(w+=360),w>=360&&(w-=360),w),gC:(w,t,i,e,s,n)=>{const o=Math.PI;n||(e=e*(o/180),s=s*(o/180));const r=e>s?-1:1,l=1e-5,h=o*2,a=[],c=o/2;let f=e,u=Math.min(h,Math.abs(s-e));if(ul;){const d=f+r*Math.min(u,c);a.push(Geo.vD(i,f,d,w,t)),u-=Math.abs(d-f),f=d}return a},vD:(w,t,i,e,s)=>{const n=(i-t)/2,o=w*Math.cos(n),r=w*Math.sin(n),l=o,h=-r,a=l*l+h*h,c=a+l*o+h*r,f=4/3*(Math.sqrt(2*a*c)-c)/(l*r-h*o),u=l-f*h,d=h+f*l,m=u,g=-d,p=n+t,y=Math.cos(p),x=Math.sin(p);return[e+w*Math.cos(t),s+w*Math.sin(t),e+u*y-d*x,s+u*x+d*y,e+m*y-g*x,s+m*x+g*y,e+w*Math.cos(i),s+w*Math.sin(i)]},Eg:(w,t,i,e,s,n,o)=>{const r=s,l=n,h=Math.floor((w-i)/r)*r+i,a=Math.floor((t-e)/l)*l+e;let c=h;h+r-w{let i=Math.max(w,t),e=Math.min(w,t),s=1,n=1;do s=i%e,n=e,i=e,e=s;while(s>0);return n},OD:(w,t,i,e)=>{const s=i<0,n=e<0;let o=0,r=0,l=0;w{let o=0;if(e>0)if(i>0){const r=w*w,l=t*t,h=w*i,a=t*e;let c=-l+a,f=-l+Math.sqrt(h*h+a*a),u=c;const d=9999999999;for(let p=0;p0)c=u;else if(k<0)f=u;else break}s=r*i/(u+r),n=l*e/(u+l);const m=s-i,g=n-e;o=Math.sqrt(m*m+g*g)}else s=0,n=t,o=Math.abs(e-t);else{const r=w*w-t*t,l=w*i;if(l(w[w.Line=1]="Line",w[w.Rectangle=2]="Rectangle",w[w.Ellipse=3]="Ellipse",w[w.Path=4]="Path",w))(GeometryType||{}),GeometryStretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w))(GeometryStretch||{});class Geometry{n;Gg;jg;ic;cu;fu;zn;Xn;Kn;Z;xe;be;Zi;Qi;Fs;ec;sc;constructor(t){GSet.Yi(this),this.n=2,t===void 0&&(t=4),this.Z=t,this.xe=0,this.be=0,this.Zi=0,this.Qi=0,t===4?this.Fs=new List:this.Fs=Geometry.Mw,this.Gg=this.Fs.at,this.jg=new Rect().g(),this.ic=null,this.cu=null,this.fu=NaN,this.zn=Spot.TopLeft,this.Xn=Spot.BottomRight,this.ec=NaN,this.sc=NaN,this.Kn=2}copy(){const t=new Geometry;if(t.n=this.n&-2,t.Z=this.Z,t.xe=this.xe,t.be=this.be,t.Zi=this.Zi,t.Qi=this.Qi,this.Z===4){const i=this.Fs.r,e=t.Fs;for(let s=0;si.toString(t)}ri(t){t in GeometryType?this.type=t:Util.lr(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e;switch(this.type){case 1:return t<0?"M"+this.startX.toString()+" "+this.startY.toString()+"L"+this.endX.toString()+" "+this.endY.toString():"M"+i(this.startX)+" "+i(this.startY)+"L"+i(this.endX)+" "+i(this.endY);case 2:return e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0?"M"+e.x.toString()+" "+e.y.toString()+"H"+e.right.toString()+"V"+e.bottom.toString()+"H"+e.left.toString()+"z":"M"+i(e.x)+" "+i(e.y)+"H"+i(e.right)+"V"+i(e.bottom)+"H"+i(e.left)+"z";case 3:if(e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0){const r=e.left.toString()+" "+(e.y+e.height/2).toString(),l=e.right.toString()+" "+(e.y+e.height/2).toString();return"M"+r+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+l+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+r}else{const r=i(e.left)+" "+i(e.y+e.height/2),l=i(e.right)+" "+i(e.y+e.height/2);return"M"+r+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+l+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+r}case 4:let s="";const n=this.figures.r,o=n.length;for(let r=0;r0&&(s+=" x "),l.isFilled&&(s+="F "),s+=l.toString(t)}return s;default:return GeometryType[this.type]}}static fillPath(t){typeof t!="string"&&Util.we(t,"string",Geometry,"fillPath:str");const i=t.split(/[Xx]/),e=i.length;let s="";for(let n=0;n=k-1||o[r+1].match(N)!==null?!0:(u=!1,!1)}function m(){return r++,o[r]}function g(A){let D=parseFloat(m()),F=parseFloat(m());l===l.toLowerCase()&&(D=f.x+D,F=f.y+F),A.e(D,F)}function p(){return g(f),f}function y(){return g(c),c}function x(){const A=h.toLowerCase();return A==="c"||A==="s"||A==="q"||A==="t"?new Point(2*f.x-c.x,2*f.y-c.y):new Point(f.x,f.y)}const k=o.length,b=GeoStream.yC(null);let P=!1,M=!1,L=!1,C=!0,S=null;const N=new RegExp("["+Geometry.Hg+"]");for(;!(r>=k-1);){if(h=l,l=m(),l==="")continue;u=!0;let A=!1;switch(l.toUpperCase()){case"X":C=!0,P=!1,M=!1;break;case"M":for(S=p(),b.Pi===null||C===!0?(b.uu(S.x,S.y,P,!1,!M,L),C=!1):b.ED(S.x,S.y),a.a(f);!d();)S=p(),b.ur(S.x,S.y);break;case"L":for(;!d();)S=p(),b.ur(S.x,S.y);u&&(A=!0);break;case"H":for(;!d();)f.e((l===l.toLowerCase()?f.x:0)+parseFloat(m()),f.y),b.ur(f.x,f.y);break;case"V":for(;!d();)f.e(f.x,(l===l.toLowerCase()?f.y:0)+parseFloat(m())),b.ur(f.x,f.y);u&&(A=!0);break;case"C":for(;!d();){const D=new Point;g(D);const F=y(),R=p();b.dr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(A=!0);break;case"S":for(;!d();){const D=x(),F=y(),R=p();b.dr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(A=!0);break;case"Q":for(;!d();){const D=y(),F=p();b.Sw(D.x,D.y,F.x,F.y)}u&&(A=!0);break;case"T":for(;!d();){const D=x();c.a(D);const F=p();b.Sw(D.x,D.y,F.x,F.y),c.a(F)}u&&(A=!0);break;case"B":for(;!d();){const D=parseFloat(m()),F=parseFloat(m());let R=parseFloat(m()),v=parseFloat(m());const O=parseFloat(m());let U=O,X=!1;d()||(U=parseFloat(m()),d()||(X=parseFloat(m())!==0)),l===l.toLowerCase()&&(R+=f.x,v+=f.y),b.UD(D,F,R,v,O,U,X)}u&&(A=!0);break;case"A":for(;!d();){const D=Math.abs(parseFloat(m())),F=Math.abs(parseFloat(m())),R=parseFloat(m());let v=!1,O=!1,U=0,X=0;const E=m();E.length===1?(v=!!parseFloat(E),O=!!parseFloat(m()),U=parseFloat(m()),X=parseFloat(m())):E.length===2?(v=!!parseFloat(E[0]),O=!!parseFloat(E[1]),U=parseFloat(m()),X=parseFloat(m())):(v=!!parseFloat(E[0]),O=!!parseFloat(E[1]),U=parseFloat(E.slice(2)),X=parseFloat(m())),l===l.toLowerCase()&&(U=f.x+U,X=f.y+X),f.e(U,X),b.BD(D,F,R,v,O,U,X)}u&&(A=!0);break;case"Z":b.VD(),f.a(a);break;case"F":{let D="",F=1;for(;o[r+F];){if(o[r+F]==="0"){L=!0,F++;continue}if(o[r+F].match(/[Uu]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?P=!0:b.zD();break}case"U":{let D="",F=1;for(;o[r+F];){if(o[r+F].match(/[Ff]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?M=!0:b.XD(!1);break}default:if(l==="0"||l==="1")break;Util.oi("Unknown geometry command: "+l);break}if(A){Util.oi(`Bad geometry command: ${l}, next token: ${m()}, -string: ${t}`);break}}const T=b.qg;if(GeoStream.wC(b),i){const A=T.figures.iterator;for(;A.next();){const D=A.value;D.isFilled=!0}}return T}static xC(t,i){const e=t.length,s=Point.l();for(let n=0;n=t)return 0;if((n>r?n-r:r-n)<(o>l?o-l:l-o)){if(ol)return 0}else if(co)return 0}else if(nr)return 0}else if(an)return 0;return h>0?1:-1}kC(t,i,e){const s=this.figures.r,n=s.length;for(let o=0;o1&&(t=1),i===void 0&&(i=new Point),this.type===1)return i.e(this.startX+t*(this.endX-this.startX),this.startY+t*(this.endY-this.startY)),i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[f*2],y=g[f*2+1],x=g[f*2+2],k=g[f*2+3];return i.e(p+(x-p)*m,y+(k-y)*m),i}l+=u}}return i}getAngleAlongPath(t){if(t<0?t=0:t>1&&(t=1),this.type===1)return Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI;const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=i.length,o=s*t;let r=0;for(let l=0;l=o){const u=i[l],d=u[c*2],m=u[c*2+1],g=u[c*2+2],p=u[c*2+3];return Math.abs(g-d)<1&&Math.abs(p-m)<1?0:Math.abs(g-d)<1?p-m>=0?90:270:Math.abs(p-m)<1?g-d>=0?0:180:Math.atan2(p-m,g-d)*180/Math.PI}r+=f}}return NaN}getPointAndAngleAlongPath(t,i){if(t<0?t=0:t>1&&(t=1),i===void 0&&(i=[]),i.length=3,this.type===1)return i[0]=this.startX+t*(this.endX-this.startX),i[1]=this.startY+t*(this.endY-this.startY),i[2]=Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI,i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[f*2],y=g[f*2+1],x=g[f*2+2],k=g[f*2+3];i[0]=p+(x-p)*m,i[1]=y+(k-y)*m;let b;return Math.abs(x-p)<1&&Math.abs(k-y)<1?b=0:Math.abs(x-p)<1?b=k-y>=0?90:270:Math.abs(k-y)<1?b=x-p>=0?0:180:b=Math.atan2(k-y,x-p)*180/Math.PI,i[2]=b,i}l+=u}}return i}getFractionForPoint(t){if(this.type===1){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=t.x,r=t.y;let l=0,h=0;if(i===s)return e=h?h===e?0:1:Math.abs(r-e)/(h-l);if(e===n)return i=h?h===i?0:1:Math.abs(o-i)/(h-l);{const a=(s-i)*(s-i)+(n-e)*(n-e),c=Point.l();Geo.ml(i,e,s,n,o,r,c);const f=c.x,u=c.y;return Point.s(c),Math.sqrt(((f-i)*(f-i)+(u-e)*(u-e))/a)}}}else if(this.type===2){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=s-i,r=n-e,l=o*2+r*2;let h=t.x,a=t.y;h=Math.min(Math.max(h,i),s),a=Math.min(Math.max(a,e),n);const c=Math.abs(h-i),f=Math.abs(h-s),u=Math.abs(a-e),d=Math.abs(a-n),m=Math.min(c,f,u,d);if(m===u)return h/l;if(m===f)return(o+a)/l;if(m===d)return(o*2+r-h)/l;if(m===c)return(o*2+r*2-a)/l}}else{const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=Point.l();let o=1/0,r=0,l=0;const h=i.length;let a=0,c=0;for(let u=0;u1?1:f}return 0}get flattenedSegments(){return this.PC(),this.ic}PC(){if(this.ic===null){const t=this.ic=[],i=this.cu=[];this.GD(t,i)}}get flattenedLengths(){return this.PC(),this.cu}get flattenedTotalLength(){let t=this.fu;if(isNaN(t)){if(this.type===1){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=Math.sqrt(i*i+e*e)}else if(this.type===2){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=i*2+e*2}else{const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=4&&(t.push(e),i.push(this.Xk(e))),e=[],e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY,h=r,a=l;break;case 2:e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY;break;case 3:Geo.Bn(r,l,d.point1X,d.point1Y,d.point2X,d.point2Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 4:Geo.Bg(r,l,d.point1X,d.point1Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 5:{const m=d.So(o),g=m.length;if(g===0){e.push(d.centerX),e.push(d.centerY),r=d.centerX,l=d.centerY;break}for(let p=0;p=4&&(t.push(e),i.push(this.Xk(e)))}}}get type(){return this.Z}set type(t){this.Z!==t&&(this.h&&Util.T(this,t),this.Z=t,t===4?this.Fs=new List:(Geometry.Mw===null&&(Geometry.Mw=new List().g()),this.Fs=Geometry.Mw),this.bt=!0)}get startX(){return this.xe}set startX(t){this.xe!==t&&(this.h&&Util.T(this,t),this.xe=t,this.bt=!0)}get startY(){return this.be}set startY(t){this.be!==t&&(this.h&&Util.T(this,t),this.be=t,this.bt=!0)}get endX(){return this.Zi}set endX(t){this.Zi!==t&&(this.h&&Util.T(this,t),this.Zi=t,this.bt=!0)}get endY(){return this.Qi}set endY(t){this.Qi!==t&&(this.h&&Util.T(this,t),this.Qi=t,this.bt=!0)}get figures(){return this.Fs}set figures(t){this.Fs!==t&&(this.h&&Util.T(this,t),this.Fs=t,this.bt=!0)}add(t){return this.Fs.add(t),this}setSpots(t,i,e,s,n,o,r,l){return this.h&&Util.T(this),this.zn=new Spot(t,i,n,o).g(),this.Xn=new Spot(e,s,r,l).g(),this}get spot1(){return this.zn}set spot1(t){this.h&&Util.T(this,t),this.zn=t.N()}get spot2(){return this.Xn}set spot2(t){this.h&&Util.T(this,t),this.Xn=t.N()}get defaultStretch(){return this.Kn}set defaultStretch(t){this.Kn=t}get bounds(){return this.Bk()&&this.Nw(),this.jg}}Geometry.stringify=Geometry.stringify;Geometry.stringifyFixed=Geometry.stringifyFixed;Geometry.fillPath=Geometry.fillPath;Geometry.parse=Geometry.parse;class PathFigure{n;xe;be;nc;Wg;Ue;constructor(t,i,e,s,n){e===void 0&&(e=!0),s===void 0&&(s=!0),n===void 0&&(n=!1),this.n=2|(e?4:0)|(s?8:0)|(n?16:0),t!==void 0?this.xe=t:this.xe=0,i!==void 0?this.be=i:this.be=0,this.nc=new List,this.Wg=this.nc.at,this.Ue=null}copy(){const t=new PathFigure;t.n=this.n&-2,t.xe=this.xe,t.be=this.be;const i=this.nc.r,e=i.length,s=t.nc;for(let n=0;no===0?"0":o.toFixed(t);i="M"+n(this.startX)+" "+n(this.startY)}const e=this.segments.r,s=e.length;for(let n=0;n(w[w.Move=1]="Move",w[w.Line=2]="Line",w[w.Bezier=3]="Bezier",w[w.QuadraticBezier=4]="QuadraticBezier",w[w.Arc=5]="Arc",w[w.SvgArc=6]="SvgArc",w))(SegmentType||{});class PathSegment{Z;n;Zi;Qi;hn;yl;wl;gr;Rs;constructor(t,i,e,s,n,o,r,l){if(GSet.Yi(this),t===void 0&&(t=2),this.Z=t,this.n=2,i!==void 0?this.Zi=i:this.Zi=0,e!==void 0?this.Qi=e:this.Qi=0,s===void 0&&(s=0),n===void 0&&(n=0),o===void 0&&(o=0),r===void 0&&(r=0),t===6){let h=o;h=h%360,h<0&&(h+=360),this.hn=h,this.yl=0,this.wl=Math.max(s,0),this.gr=Math.max(n,0),typeof r=="boolean"?r&&(this.isLargeArc=!0):typeof r=="number"&&r&&(this.isLargeArc=!0),l&&(this.isClockwiseArc=!0)}else this.hn=s,this.yl=n,t===5&&(o=Math.max(o,0)),this.wl=o,typeof r=="number"?(t===5&&(r=Math.max(r,0)),this.gr=r):this.gr=0;this.Rs=null}copy(){const t=new PathSegment;return t.Z=this.Z,t.n=this.n&-2,t.Zi=this.Zi,t.Qi=this.Qi,t.hn=this.hn,t.yl=this.yl,t.wl=this.wl,t.gr=this.gr,t}equalsApprox(t){if(!(t instanceof PathSegment)||this.type!==t.type||this.isClosed!==t.isClosed)return!1;switch(this.type){case 1:case 2:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY);case 3:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.point1X,t.point1X)&&Geo.u(this.point1Y,t.point1Y)&&Geo.u(this.point2X,t.point2X)&&Geo.u(this.point2Y,t.point2Y);case 4:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.point1X,t.point1X)&&Geo.u(this.point1Y,t.point1Y);case 5:return Geo.u(this.startAngle,t.startAngle)&&Geo.u(this.sweepAngle,t.sweepAngle)&&Geo.u(this.centerX,t.centerX)&&Geo.u(this.centerY,t.centerY)&&Geo.u(this.radiusX,t.radiusX)&&Geo.u(this.radiusY,t.radiusY);case 6:return this.isClockwiseArc===t.isClockwiseArc&&this.isLargeArc===t.isLargeArc&&Geo.u(this.xAxisRotation,t.xAxisRotation)&&Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.radiusX,t.radiusX)&&Geo.u(this.radiusY,t.radiusY);default:return!1}}ri(t){t in SegmentType?this.type=t:Util.lr(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e="";switch(this.type){case 1:t<0?e="M"+this.endX.toString()+" "+this.endY.toString():e="M"+i(this.endX)+" "+i(this.endY);break;case 2:t<0?e="L"+this.endX.toString()+" "+this.endY.toString():e="L"+i(this.endX)+" "+i(this.endY);break;case 3:t<0?e="C"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.point2X.toString()+" "+this.point2Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="C"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.point2X)+" "+i(this.point2Y)+" "+i(this.endX)+" "+i(this.endY);break;case 4:t<0?e="Q"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="Q"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.endX)+" "+i(this.endY);break;case 5:t<0?e="B"+this.startAngle.toString()+" "+this.sweepAngle.toString()+" "+this.centerX.toString()+" "+this.centerY.toString()+" "+this.radiusX.toString()+" "+this.radiusY.toString():e="B"+i(this.startAngle)+" "+i(this.sweepAngle)+" "+i(this.centerX)+" "+i(this.centerY)+" "+i(this.radiusX)+" "+i(this.radiusY);break;case 6:t<0?e="A"+this.radiusX.toString()+" "+this.radiusY.toString()+" "+this.xAxisRotation.toString()+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+this.endX.toString()+" "+this.endY.toString():e="A"+i(this.radiusX)+" "+i(this.radiusY)+" "+i(this.xAxisRotation)+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+i(this.endX)+" "+i(this.endY);break;default:e=SegmentType[this.type]}return e+(this.isClosed?"z":"")}static Move=1;static Line=2;static Bezier=3;static QuadraticBezier=4;static Arc=5;static SvgArc=6;get h(){return(this.n&1)!==0}set h(t){t?this.n|=1:this.n&=-2}get bt(){return(this.n&2)!==0}set bt(t){t?this.n|=2:this.n&=-3}g(){return this.h=!0,this}rt(){return this.h=!1,this}close(){return this.isClosed=!0,this}So(t){if(this.Rs!==null&&t.bt===!1)return this.Rs;const i=this.radiusX;let e=this.radiusY;if(e===void 0&&(e=i),i===0||e===0)return this.Rs=[],this.Rs;const s=this.hn,n=this.yl,o=Geo.gC(0,0,i1&&(o*=Math.sqrt(p),r*=Math.sqrt(p));let y=(h===a?-1:1)*Math.sqrt((o*o*r*r-o*o*g*g-r*r*m*m)/(o*o*g*g+r*r*m*m));isNaN(y)&&(y=0);let x=y*o*g/r,k=y*-r*m/o;isNaN(x)&&(x=0),isNaN(k)&&(k=0);const b=(s+c)/2+u*x-d*k,P=(n+f)/2+d*x+u*k,M=(V,B)=>Math.sqrt(V*V+B*B),L=(V,B,Y,G)=>(V*Y+B*G)/(M(V,B)*M(Y,G)),C=(V,B,Y,G)=>(V*G=1&&(F=0),!a&&F>0&&(F=F-2*Math.PI),a&&F<0&&(F=F+2*Math.PI);const v=o>r?o:r,O=o>r?1:o/r,U=o>r?r/o:1,X=Geo.gC(0,0,v,S,S+F,!0),E=Transform.l();return E.Ri(),E.Ds(b,P),E.cs(this.hn,0,0),E.st(O,U),Geometry.xC(X,E),Transform.s(E),this.Rs=X,this.Rs}get isClosed(){return(this.n&8)!==0}set isClosed(t){this.isClosed!==t&&(t?this.n|=8:this.n&=-9,this.bt=!0)}get type(){return this.Z}set type(t){this.h&&Util.T(this,t),this.Z=t,this.bt=!0}get endX(){return this.Zi}set endX(t){this.h&&Util.T(this,t),this.Zi=t,this.bt=!0}get endY(){return this.Qi}set endY(t){this.h&&Util.T(this,t),this.Qi=t,this.bt=!0}get point1X(){return this.hn}set point1X(t){this.h&&Util.T(this,t),this.hn=t,this.bt=!0}get point1Y(){return this.yl}set point1Y(t){this.h&&Util.T(this,t),this.yl=t,this.bt=!0}get point2X(){return this.wl}set point2X(t){this.h&&Util.T(this,t),this.wl=t,this.bt=!0}get point2Y(){return this.gr}set point2Y(t){this.h&&Util.T(this,t),this.gr=t,this.bt=!0}get centerX(){return this.hn}set centerX(t){this.h&&Util.T(this,t),this.hn=t,this.bt=!0}get centerY(){return this.yl}set centerY(t){this.h&&Util.T(this,t),this.yl=t,this.bt=!0}get radiusX(){return this.wl}set radiusX(t){t<0&&Util._(t,">= zero",PathSegment,"radiusX"),this.h&&Util.T(this,t),this.wl=t,this.bt=!0}get radiusY(){return this.gr}set radiusY(t){t<0&&Util._(t,">= zero",PathSegment,"radiusY"),this.h&&Util.T(this,t),this.gr=t,this.bt=!0}get startAngle(){return this.Zi}set startAngle(t){this.h&&Util.T(this,t),t=t%360,t<0&&(t+=360),this.Zi=t,this.bt=!0}get sweepAngle(){return this.Qi}set sweepAngle(t){this.h&&Util.T(this,t),t>360&&(t=360),t<-360&&(t=-360),this.Qi=t,this.bt=!0}get isClockwiseArc(){return(this.n&4)!==0}set isClockwiseArc(t){this.h&&Util.T(this,t),t?this.n|=4:this.n&=-5,this.bt=!0}get isLargeArc(){return(this.n&16)!==0}set isLargeArc(t){this.h&&Util.T(this,t),t?this.n|=16:this.n&=-17,this.bt=!0}get xAxisRotation(){return this.hn}set xAxisRotation(t){this.h&&Util.T(this,t),t=t%360,t<0&&(t+=360),this.hn=t,this.bt=!0}}class InputEvent{p;Lw;Aw;Jg;$g;Zg;Qg;_g;tm;im;em;sm;nm;om;No;rm;lm;hm;ke;constructor(){this.p=null,this.Lw=new Point(0,0).g(),this.Aw=new Point(0,0).g(),this.Jg=0,this.$g=0,this.Zg=1,this.Qg="",this._g="",this.tm=!1,this.im=!1,this.em=0,this.sm=0,this.nm=!1,this.om=!1,this.No=!1,this.rm=null,this.lm=0,this.hm=null,this.ke=null}copy(){const t=new InputEvent;return this.clone(t)}clone(t){return t.p=this.p,t.Lw.a(this.viewPoint),t.Aw.a(this.documentPoint),t.Jg=this.Jg,t.$g=this.$g,t.Zg=this.Zg,t.Qg=this.Qg,t._g=this._g,t.tm=this.tm,t.im=this.im,t.em=this.em,t.sm=this.sm,t.nm=this.nm,t.om=this.om,t.No=this.No,t.rm=this.rm,t.lm=this.lm,t.hm=this.hm,t.ke=this.ke,t}toString(){let t="^";return this.modifiers!==0&&(t+="M:"+this.modifiers),this.button!==0&&(t+="B:"+this.button),this.key!==""&&(t+="K:"+this.key),this.clickCount!==0&&(t+="C:"+this.clickCount),this.delta!==0&&(t+="D:"+this.delta),this.handled&&(t+="h"),this.bubbles&&(t+="b"),this.documentPoint!==null&&(t+="@"+this.documentPoint.toString()),t}get diagram(){return this.p}set diagram(t){this.p=t}get viewPoint(){return this.Lw}set viewPoint(t){this.Lw.a(t)}get documentPoint(){return this.Aw}set documentPoint(t){this.Aw.a(t)}getMultiTouchViewPoint(t,i){const e=this.diagram;return e===null||e.MC(this.event,t,i),i}getMultiTouchDocumentPoint(t,i){const e=this.diagram;return e===null||(e.MC(this.event,t,i),i.a(e.transformViewToDoc(i))),i}get modifiers(){return this.Jg}set modifiers(t){this.Jg=t}get button(){return this.$g}set button(t){if(this.$g=t,this.event===null)switch(t){case 0:this.buttons=1;return;case 1:this.buttons=4;return;case 2:this.buttons=2;return}}get buttons(){return this.Zg}set buttons(t){this.Zg=t}get key(){return this.Qg}set key(t){this.Qg=t}get code(){return this._g}set code(t){this._g=t}get down(){return this.tm}set down(t){this.tm=t}get up(){return this.im}set up(t){this.im=t}get clickCount(){return this.em}set clickCount(t){this.em=t}get delta(){return this.sm}set delta(t){this.sm=t}get isMultiTouch(){return this.nm}set isMultiTouch(t){this.nm=t}get handled(){return this.om}set handled(t){this.om=t}get bubbles(){return this.No}set bubbles(t){this.No=t}get event(){return this.rm}set event(t){this.rm=t}get isTouchEvent(){const t=this.event;return t===null?!1:t.pointerType==="touch"||t.pointerType==="pen"}get timestamp(){return this.lm}set timestamp(t){this.lm=t}get targetDiagram(){return this.hm}set targetDiagram(t){this.hm=t}get targetObject(){return this.ke}set targetObject(t){this.ke=t}get control(){return(this.modifiers&1)!==0}set control(t){this.modifiers=t?this.modifiers|1:this.modifiers&-2}get shift(){return(this.modifiers&4)!==0}set shift(t){this.modifiers=t?this.modifiers|4:this.modifiers&-5}get alt(){return(this.modifiers&2)!==0}set alt(t){this.modifiers=t?this.modifiers|2:this.modifiers&-3}get meta(){return(this.modifiers&8)!==0}set meta(t){this.modifiers=t?this.modifiers|8:this.modifiers&-9}get left(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===0:(this.buttons&1)!==0}set left(t){t?this.buttons|=1:this.buttons&=-2}get right(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===2:(this.buttons&2)!==0}set right(t){t?this.buttons|=2:this.buttons&=-3}get middle(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===1:(this.buttons&4)!==0}set middle(t){t?this.buttons|=4:this.buttons&=-5}get commandKey(){const t=this.code,i=this.key;return"cxvyzagCXVYZAG".includes(i)?i.toLowerCase():t==="KeyC"?"c":t==="KeyX"?"x":t==="KeyV"?"v":t==="KeyY"?"y":t==="KeyZ"?"z":t==="KeyA"?"a":t==="KeyG"?"g":t!==""?t:i}}class DiagramEvent{p;St;am;cm;constructor(){this.p=null,this.St="",this.am=null,this.cm=null}copy(){const t=new DiagramEvent;return t.p=this.p,t.St=this.St,t.am=this.am,t.cm=this.cm,t}toString(){let t="*"+this.name;return this.subject!==null&&(t+=":"+this.subject.toString()),this.parameter!==null&&(t+="("+this.parameter.toString()+")"),t}get diagram(){return this.p}set diagram(t){this.p=t}get name(){return this.St}set name(t){this.St=t}get subject(){return this.am}set subject(t){this.am=t}get parameter(){return this.cm}set parameter(t){this.cm=t}}var ChangeType=(w=>(w[w.Transaction=1]="Transaction",w[w.Property=2]="Property",w[w.Insert=3]="Insert",w[w.Remove=4]="Remove",w))(ChangeType||{});class ChangedEvent{du;fm;an;Mi;p;gu;oc;rc;lc;hc;constructor(){this.du=2,this.fm="",this.an="",this.Mi=null,this.p=null,this.gu=null,this.oc=null,this.rc=null,this.lc=null,this.hc=null}static Transaction=1;static Property=2;static Insert=3;static Remove=4;clear(){this.Mi=null,this.p=null,this.gu=null,this.oc=null,this.rc=null,this.lc=null,this.hc=null}copy(){const t=new ChangedEvent;t.du=this.du,t.fm=this.fm,t.an=this.an,t.Mi=this.Mi,t.p=this.p,t.gu=this.gu;let i=this.oc;return Util.wt(i)&&typeof i.copyFrozen=="function"?t.oc=i.copyFrozen():t.oc=i,i=this.rc,Util.wt(i)&&typeof i.copyFrozen=="function"?t.rc=i.copyFrozen():t.rc=i,i=this.lc,Util.wt(i)&&typeof i.copyFrozen=="function"?t.lc=i.copyFrozen():t.lc=i,i=this.hc,Util.wt(i)&&typeof i.copyFrozen=="function"?t.hc=i.copyFrozen():t.hc=i,t}ri(t){t in ChangeType?this.change=t:Util.lr(this,t)}toString(){let t="";return this.change===1?t+="* ":this.change===2?t+=this.model!==null?"!m":"!d":t+=(this.model!==null?"!m":"!d")+this.change,this.propertyName&&typeof this.propertyName=="string"&&(t+=" "+this.propertyName),this.modelChange&&this.modelChange!==this.propertyName&&(t+=" "+this.modelChange),t+=": ",this.change===1?this.oldValue!==null&&(t+=" "+this.oldValue):(this.object!==null&&(t+=Util.toString(this.object)),this.oldValue!==null&&(t+=" old: "+Util.toString(this.oldValue)),this.oldParam!==null&&(t+=" "+this.oldParam),this.newValue!==null&&(t+=" new: "+Util.toString(this.newValue)),this.newParam!==null&&(t+=" "+this.newParam)),t}getValue(t){return t?this.oldValue:this.newValue}getParam(t){return t?this.oldParam:this.newParam}canUndo(){return this.model!==null||this.diagram!==null}undo(){this.canUndo()&&(this.model!==null?this.model.changeState(this,!0):this.diagram!==null&&this.diagram.SC(this,!0))}canRedo(){return this.model!==null||this.diagram!==null}redo(){this.canRedo()&&(this.model!==null?this.model.changeState(this,!1):this.diagram!==null&&this.diagram.SC(this,!1))}get model(){return this.Mi}set model(t){this.Mi=t}get diagram(){return this.p}set diagram(t){this.p=t}get change(){return this.du}set change(t){this.du=t}get modelChange(){return this.fm}set modelChange(t){this.fm=t}get propertyName(){return this.an}set propertyName(t){this.an=t}get isTransactionFinished(){return this.du===1&&(this.an==="CommittedTransaction"||this.an==="FinishedUndo"||this.an==="FinishedRedo")}get object(){return this.gu}set object(t){this.gu=t}get oldValue(){return this.oc}set oldValue(t){this.oc=t}get oldParam(){return this.rc}set oldParam(t){this.rc=t}get newValue(){return this.lc}set newValue(t){this.lc=t}get newParam(){return this.hc}set newParam(t){this.hc=t}}class Transaction{NC;St;Kk;constructor(){this.NC=new List().g(),this.St="",this.Kk=!1}toString(t){let i="Transaction: "+this.name+" "+this.changes.count.toString()+(this.isComplete?"":", incomplete");if(t!==void 0&&t>0){const e=this.changes.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),t.g()}canUndo(){return this.isComplete}undo(){if(this.canUndo())for(let t=this.changes.count-1;t>=0;t--){const i=this.changes.elt(t);i!==null&&i.undo()}}canRedo(){return this.isComplete}redo(){if(!this.canRedo())return;const t=this.changes.count;for(let i=0;i=t;e--){const s=i.elt(e);s!==null&&s.undo(),i.rt(),i.removeAt(e)}i.g()}optimize(){if(!this.isComplete)return;const t=this.changes;t.rt();const i=new GMap;for(let s=0;s0&&t.setElt(r,null),o.set(n.propertyName,s))}let e=0;for(let s=0;se&&t.setElt(e,n),e++)}for(;t.length>e;)t.pop();t.g()}get changes(){return this.NC}get name(){return this.St}set name(t){this.St=t}get isComplete(){return this.Kk}set isComplete(t){this.Kk=t}}class UndoManager{Tw;Oi;CC;vs;Yk;um;Yn;Gk;jk;cn;ac;Dw;Os;Fw;Rw;dm;vw;constructor(t){this.Tw=new GSet,this.Oi=!1,this.CC=new List().g(),this.vs=-1,this.Yk=999,this.Os=!1,this.um=null,this.Yn=0,this.Gk=!1,this.jk=23,this.cn=new List().g(),this.ac=new List,this.Dw=!0,this.Fw=!1,this.Rw=!1,this.dm=!1,this.vw=!1,t&&Object.assign(this,t)}toString(t){let i="UndoManager "+this.historyIndex+"<"+this.history.count+"<="+this.maxHistoryLength;i+="[";let e=this.nestedTransactionNames.count;for(let s=0;s0&&(i+=" "),i+=this.nestedTransactionNames.elt(s);if(i+="]",t!==void 0&&t>0){e=this.history.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),this.vs=-1,t.g(),this.Os=!1,this.um=null,this.Yn=0,this.cn.rt(),this.cn.clear(),this.cn.g(),this.ac.clear(),this.Fw=!1,this.Rw=!1,this.dm=!1,this.vw=!1}copyProperties(t){this.isEnabled=t.isEnabled,this.maxHistoryLength=t.maxHistoryLength,this.gm=t.gm}addModel(t){this.Tw.add(t)}removeModel(t){this.Tw.delete(t)}startTransaction(t){if(t===void 0&&(t=""),t===null&&(t=""),this.isUndoingRedoing)return!1;this.Dw===!0&&(this.Dw=!1,this.Yn++,this.xl||this.t("StartingFirstTransaction",t,this.currentTransaction),this.Yn>0&&this.Yn--),this.isEnabled&&(this.cn.rt(),this.cn.add(t),this.cn.g(),this.currentTransaction===null?this.ac.add(0):this.ac.add(this.currentTransaction.changes.count)),this.Yn++;const i=this.transactionLevel===1;return i&&(this.xl||this.t("StartedTransaction",t,this.currentTransaction)),i}commitTransaction(t){return t===void 0&&(t=""),this.LC(!0,t)}rollbackTransaction(){return this.LC(!1,"")}LC(t,i){if(this.isUndoingRedoing)return!1;this.gm&&this.transactionLevel<1&&Util.oi("Ending transaction without having started a transaction: "+i);const e=this.transactionLevel===1;let s=this.currentTransaction;e&&t&&(this.xl||this.t("CommittingTransaction",i,s));let n=0;if(this.transactionLevel>0&&(this.Yn--,this.isEnabled)){const o=this.cn.count;o>0&&(i===""&&(i=this.cn.elt(0)),this.cn.rt(),this.cn.removeAt(o-1),this.cn.g());const r=this.ac.count;r>0&&(n=this.ac.elt(r-1),this.ac.removeAt(r-1))}if(e){if(t){if(this.dm=!1,s===null&&i!==""&&(s=this.currentTransaction),this.isEnabled&&s!==null){const o=s;o.isComplete||(o.isComplete=!0,o.name=i),this.discardHistoryAfterIndex();const r=this.history;r.rt();const l=this.maxHistoryLength;if(l>=0){if(l===0)r.clear();else if(r.count>=l){const h=r.elt(0);h!==null&&h.clear(),r.removeAt(0),this.vs--}}l!==0&&(r.count===0||r.get(r.count-1)!==o)&&(r.add(o),this.vs++),r.g(),s=o}this.xl||this.t("CommittedTransaction",i,s)}else{this.Os=!0;try{this.isEnabled&&s!==null&&(s.isComplete=!0,s.undo())}finally{this.xl||this.t("RolledBackTransaction",i,s),this.Os=!1}s!==null&&s.clear()}return this.um=null,this.Ow&&this.clear(),this.Ow=!1,this.Iw=!1,!0}else return this.isEnabled&&!t&&s!==null&&s.jD(n),!1}discardHistoryAfterIndex(){if(this.isUndoingRedoing||!this.canRedo())return;const t=this.history;t.rt();for(let i=t.count-1;i>this.historyIndex;i--){const e=t.elt(i);e!==null&&e.clear(),t.removeAt(i),this.dm=!0}t.g()}oE(t){this.Yn+=t,this.Yn<0&&(this.Yn=0)}canUndo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToUndo;return!!(t!==null&&t.canUndo())}undo(){if(!this.canUndo())return;const t=this.transactionToUndo;try{this.Os=!0,this.t("StartingUndo","Undo",t),this.vs--,t.undo()}catch(i){Util.oi("undo error: "+i.toString())}finally{this.t("FinishedUndo","Undo",t),this.Os=!1}}canRedo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToRedo;return!!(t!==null&&t.canRedo())}redo(){if(!this.canRedo())return;const t=this.transactionToRedo;try{this.Os=!0,this.t("StartingRedo","Redo",t),this.vs++,t.redo()}catch(i){Util.oi("redo error: "+i.toString())}finally{this.t("FinishedRedo","Redo",t),this.Os=!1}}t(t,i,e){e===void 0&&(e=null);const s=new ChangedEvent;s.change=1,s.propertyName=t,s.object=e,s.oldValue=i;const n=this.models;for(;n.next();){const o=n.value;s.model=o,o.Ew(s)}}handleChanged(t){if(this.isEnabled&&!this.isUndoingRedoing&&!this.skipsEvent(t)){let i=this.currentTransaction;i===null&&(i=new Transaction,this.um=i);const e=t.copy(),s=i.changes;if(s.rt(),s.add(e),s.g(),this.gm&&this.jk>0&&this.transactionLevel<=0&&!this.Dw){const n=t.diagram;if(n!==null&&n.Eh===!1)return;Util.oi("Change not within a transaction: "+e.toString()),this.jk--}}}skipsEvent(t){if(t===null||t.change===1)return!0;const i=t.object;if(i===null)return!1;if(i.layer!==void 0){const e=i.layer;if(e!==null&&e.isTemporary)return!0}else if(i.isTemporary)return!0;return!1}get models(){return this.Tw.iterator}get isEnabled(){return this.Oi}set isEnabled(t){this.Oi=t}get transactionToUndo(){return this.historyIndex>=0&&this.historyIndex<=this.history.count-1?this.history.elt(this.historyIndex):null}get transactionToRedo(){return this.historyIndex0}get gm(){return this.Gk}set gm(t){this.Gk=t}get nestedTransactionNames(){return this.cn}get Ow(){return this.Fw}set Ow(t){this.Fw=t}get Iw(){return this.Rw}set Iw(t){this.Rw=t}get xl(){return this.vw}set xl(t){this.vw=t}get isJustDiscarded(){return this.dm}}class Tool{p;St;Oi;Hk;qk;mm;AC;constructor(){GSet.Yi(this),this.p=Diagram.pm(),this.St="",this.Oi=!0,this.Hk=!1,this.qk=null,this.AC=new InputEvent,this.mm=-1}get diagram(){return this.p}set diagram(t){t instanceof Diagram&&(this.p=t)}toString(){return this.name!==""?this.name+" Tool":Util.sn(this.constructor)}updateAdornments(t){}canStart(){return this.isEnabled}doStart(){}doActivate(){this.isActive=!0}doDeactivate(){this.isActive=!1}doStop(){}doCancel(){this.transactionResult=null,this.stopTool()}stopTool(){const t=this.diagram;t.currentTool===this&&(t.currentTool=null,t.currentCursor="")}doMouseDown(){!this.isActive&&this.canStart()&&this.doActivate()}doMouseMove(){}doMouseUp(){this.stopTool()}doMouseWheel(){}canStartMultiTouch(){return!0}standardPinchZoomStart(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.X(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.X(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.s(e),Point.s(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){t.Wk=t.scale;const n=s.x-e.x,o=s.y-e.y,r=Math.sqrt(n*n+o*o);t.Jk=r,i.bubbles=!1}Point.s(e),Point.s(s)}standardPinchZoomMove(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.X(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.X(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.s(e),Point.s(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){const n=s.x-e.x,o=s.y-e.y,l=Math.sqrt(n*n+o*o)/t.Jk,h=new Point((Math.min(s.x,e.x)+Math.max(s.x,e.x))/2,(Math.min(s.y,e.y)+Math.max(s.y,e.y))/2),a=t.Wk*l,c=t.commandHandler;if(a!==t.scale&&c.canResetZoom(a)){const f=t.zoomPoint;t.zoomPoint=h,c.resetZoom(a),t.zoomPoint=f}i.bubbles=!1}Point.s(e),Point.s(s)}doKeyDown(){this.diagram.lastInput.code==="Escape"&&this.doCancel()}doKeyUp(){}startTransaction(t){return t===void 0&&(t=this.name),this.transactionResult=null,this.diagram.startTransaction(t)}stopTransaction(){const t=this.diagram;return this.transactionResult===null?t.rollbackTransaction():t.commitTransaction(this.transactionResult)}standardMouseSelect(){const t=this.diagram;if(!t.allowSelect)return;const i=t.lastInput,e=t.findPartAt(i.documentPoint,!1);if(e!==null){if(Util.rr?i.meta:i.control){t.v("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!s.isSelected),t.v("ChangedSelection",t.selection)}else if(i.shift){if(!e.isSelected){t.v("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!0),t.v("ChangedSelection",t.selection)}}else if(!e.isSelected){let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&t.select(s)}}else i.left&&!(Util.rr?i.meta:i.control)&&!i.shift&&t.clearSelection()}standardMouseClick(t,i){t===void 0&&(t=null),i===void 0&&(i=o=>!o.layer.isTemporary);const e=this.diagram,s=e.lastInput,n=e.findObjectAt(s.documentPoint,t,i);return s.targetObject=n,this.HD(n,s,e),s.handled}HD(t,i,e){if(i.handled=!1,t!==null&&!t.isEnabledObject())return;let s=0;i.left?i.clickCount===1?s=1:i.clickCount===2?s=2:s=1:i.right&&i.clickCount===1&&(s=3);let n="ObjectSingleClicked";if(t!==null){switch(s){case 1:n="ObjectSingleClicked";break;case 2:n="ObjectDoubleClicked";break;case 3:n="ObjectContextClicked";break}s!==0&&e.v(n,t)}else{switch(s){case 1:n="BackgroundSingleClicked";break;case 2:n="BackgroundDoubleClicked";break;case 3:n="BackgroundContextClicked";break}s!==0&&e.v(n)}if(t!==null)for(;t!==null;){let o=null;switch(s){case 1:o=t.click;break;case 2:o=t.doubleClick?t.doubleClick:t.click;break;case 3:o=t.contextClick;break}if(o!==null&&(o(i,t),i.handled))break;t=t.panel}else{let o=null;switch(s){case 1:o=e.click;break;case 2:o=e.doubleClick?e.doubleClick:e.click;break;case 3:o=e.contextClick;break}o!==null&&o(i)}}standardMouseOver(){const t=this.diagram,i=t.lastInput;if(t.animationManager.wi===!0)return;const e=t.skipsUndoManager;t.skipsUndoManager=!0;let s=t.viewportBounds.containsPoint(i.documentPoint)?t.findObjectAt(i.documentPoint,null,null):null;i.event&&(i.event.type==="pointercancel"||i.event.type==="pointerout")&&(s=null),i.targetObject=s;let n=!1;if(s!==t.cc){let o=t.cc;const r=o;for(t.cc=s,this.doCurrentObjectChanged(o,s),i.handled=!1;o!==null;){const l=o.mouseLeave;if(l!==null&&(s===o||s!==null&&s.isContainedBy(o)||(l(i,o,s),n=!0,i.handled)))break;o=o.panel}for(o=r,i.handled=!1;s!==null;){const l=s.mouseEnter;if(l!==null&&(o===s||o!==null&&o.isContainedBy(s)||(l(i,s,o),n=!0,i.handled)))break;s=s.panel}s=t.cc}if(s!==null){let o=s,r="";for(;o!==null&&(r=o.cursor,r==="");)o=o.panel;for(t.currentCursor=r,i.handled=!1,o=s;o!==null;){const l=o.mouseOver;if(l!==null&&(l(i,o),n=!0,i.handled))break;o=o.panel}}else{this.doUpdateCursor(null);const o=t.mouseOver;o!==null&&(o(i),n=!0)}n&&t.requestUpdate(),t.skipsUndoManager=e}doUpdateCursor(t){const i=this.diagram;i&&(i.currentCursor="")}doCurrentObjectChanged(t,i){}standardMouseWheel(){const t=this.diagram,i=t.lastInput;let e=i.delta;if(e===0||!t.documentBounds.isReal())return;const s=t.commandHandler,n=t.toolManager.mouseWheelBehavior;if(s!==null&&(n===2&&!i.shift||n===1&&i.control)){if(e>0?s.canIncreaseZoom():s.canDecreaseZoom()){const o=t.zoomPoint;t.zoomPoint=i.viewPoint,e>0?s.increaseZoom():s.decreaseZoom(),t.zoomPoint=o}i.bubbles=!1}else if(n===2&&i.shift||n===1&&!i.control){const o=t.position.copy(),r=i.event,l=r.deltaMode;let h=r.deltaX,a=r.deltaY,c="pixel";if((h!==0||a!==0)&&!i.shift){switch(l){case 0:c="pixel";break;case 1:c="line";break;case 2:c="page";break}if(h!==0&&t.allowHorizontalScroll){const f=t.scrollHorizontalLineChange;h=h*(f/16),t.scroll(c,h>0?"right":"left",Math.abs(h))}if(a!==0&&t.allowVerticalScroll){const f=t.scrollVerticalLineChange;a=a*(f/16),t.scroll(c,a>0?"down":"up",Math.abs(a))}}else!i.shift&&t.allowVerticalScroll?(e=e*3*t.scrollVerticalLineChange,t.scroll(c,e>0?"up":"down",Math.abs(e))):i.shift&&t.allowHorizontalScroll&&(e=e*3*t.scrollHorizontalLineChange,t.scroll(c,e>0?"left":"right",Math.abs(e)));this.doWheelChange(t,o,i)}}doWheelChange(t,i,e){(!t.position.equals(i)||e.event.wheelDeltaX!==0)&&(e.bubbles=!1)}standardWaitAfter(t,i){i===void 0&&(i=this.diagram.lastInput),this.cancelWaitAfter();const e=this,s=i.clone(this.AC);this.mm=Util.vh(()=>e.doWaitAfter(s),t)}cancelWaitAfter(){this.mm!==-1&&Util.Ig(this.mm),this.mm=-1}doWaitAfter(t){}findToolHandleAt(t,i){const s=this.diagram.findObjectAt(t,n=>{for(;n!==null&&!(n.panel instanceof Adornment);)n=n.panel;return n});return s===null?null:s.part.category===i?s:null}isBeyondDragSize(t,i){const e=this.diagram;t===void 0&&(t=e.firstInput.viewPoint),i===void 0&&(i=e.lastInput.viewPoint);const s=e.toolManager.dragSize;let n=s.width,o=s.height;return e.firstInput.isTouchEvent&&(n+=6,o+=6),Math.abs(i.x-t.x)>n||Math.abs(i.y-t.y)>o}get name(){return this.St}set name(t){Util.i(t,"string",Tool,"name"),this.St=t}get isEnabled(){return this.Oi}set isEnabled(t){Util.i(t,"boolean",Tool,"isEnabled"),this.Oi=t}get isActive(){return this.Hk}set isActive(t){Util.i(t,"boolean",Tool,"isActive"),this.Hk=t}get transactionResult(){return this.qk}set transactionResult(t){t!==null&&Util.i(t,"string",Tool,"transactionResult"),this.qk=t}}var WheelMode=(w=>(w[w.Scroll=1]="Scroll",w[w.Zoom=2]="Zoom",w[w.None=3]="None",w))(WheelMode||{}),GestureMode=(w=>(w[w.Zoom=1]="Zoom",w[w.Cancel=2]="Cancel",w[w.None=3]="None",w))(GestureMode||{});class ToolManager extends Tool{TC;DC;FC;$k;Zk;Qk;_k;tP;iP;eP;ym;Uh;constructor(t){super(),this.name="ToolManager",this.TC=new List,this.DC=new List,this.FC=new List,this.$k=850,this.Zk=850,this.Qk=new Size(2,2).it(),this._k=5e3,this.tP=1,this.iP=1,this.eP=null,this.ym=null,this.Uh=-1,t&&Object.assign(this,t)}static WheelScroll=1;static WheelZoom=2;static WheelNone=3;static GestureZoom=1;static GestureCancel=2;static GestureNone=3;get mouseWheelBehavior(){return this.tP}set mouseWheelBehavior(t){this.tP=t}get gestureBehavior(){return this.iP}set gestureBehavior(t){this.iP=t}initializeStandardTools(){}updateAdornments(t){const i=this.currentToolTip;if(i instanceof Adornment&&this.ym===t){const e=i.adornedObject;(t!==null?e.part===t:e===null)?this.showToolTip(i,e):this.hideToolTip()}}doMouseDown(){const t=this.diagram,i=t.lastInput;if(i.isTouchEvent&&this.gestureBehavior===2&&(i.bubbles=!1),i.isMultiTouch){if(this.cancelWaitAfter(),this.gestureBehavior===3){i.bubbles=!0;return}if(this.gestureBehavior===2)return;if(t.currentTool.canStartMultiTouch()){t.currentTool.standardPinchZoomStart();return}}const e=t.undoManager,s=this.mouseDownTools.length;for(let n=0;n0&&s!==1/0){const n=this;this.Uh=Util.vh(()=>n.hideToolTip(),s)}}positionToolTip(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom?n.y-=o.height+5/s.scale:n.y+=20/s.scale,n.y30&&t.Bw(),t.Vw(this.draggedParts),t.yu=!0,this.startTransaction("Drag"),this.startPoint=t.firstInput.documentPoint,t.isMouseCaptured=!0,t.allowDragOut&&this.WD()}mP(t){if(this.dragsLink){const i=this.diagram;if(!i.allowRelink)return;i.model.dc()&&t.count===1&&t.first()instanceof Link?(this.draggedLink=t.first(),this.draggedLink.canRelinkFrom()&&this.draggedLink.canRelinkTo()&&this.draggedLink.clearAdornments(),this.fn=i.toolManager.findTool("Relinking"),this.fn===null&&(this.fn=new RelinkingTool,this.fn.diagram=i),this.fn.originalLink=this.draggedLink):(this.draggedLink=null,this.fn=null)}}computeEffectiveCollection(t,i){return this.diagram.commandHandler.computeEffectiveCollection(t,i)}Is(t){return t===void 0?new DraggingInfo(Point.Po):this.isGridSnapEnabled?new DraggingInfo(new Point(Math.round(t.x*1e3)/1e3,Math.round(t.y*1e3)/1e3)):new DraggingInfo(t.copy())}doDeactivate(){this.isActive=!1;const t=this.diagram;this.diagram.layout.isRealtime=this.gP,t.yu=!1,t.bl=!0,t.cacheGroupExternalLinks(!1),t.stopAutoScroll(),this.pP(),t.xm(this.draggedParts),this.pu=null,this.currentPart=null,this.draggedParts=null,this.isDragOutStarted=!1,this.mu=!1,DraggingTool.JD(),this.vC(),this.fc.e(NaN,NaN),DraggingTool.Vh!==null&&(DraggingTool.Vh.currentCursor=""),DraggingTool.Vh=null,DraggingTool.yt=null,this.kl(),t.isMouseCaptured=!1,t.currentCursor="",t.uc=!1,this.stopTransaction(),t.yP(!0)}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}pP(){const t=this.diagram,i=t.skipsUndoManager;t.skipsUndoManager=!0;const e=t.lastInput;this.OC(e,null),t.skipsUndoManager=i,this.mr.length=0}IC(){this.kl(),this.wP();const t=this.diagram;this.fc.isReal()&&(t.position=this.fc),t.stopAutoScroll()}doCancel(){this.kl(),this.wP();const t=this.diagram;this.fc.isReal()&&(t.position=this.fc),this.stopTool()}doKeyDown(){const t=this.diagram,i=t.lastInput;this.isActive&&(i.code==="Escape"?this.doCancel():i.code!==t.previousInput.code&&this.doMouseMove())}doKeyUp(){this.isActive&&this.doMouseMove()}$D(t,i){let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=t.iterator;for(;r.next();){const l=r.value;if(!l.isVisible())continue;const h=l.location,a=h.x,c=h.y;isNaN(a)||isNaN(c)||(an&&(n=a),c>o&&(o=c))}return e===1/0?i.e(0,0,0,0):i.e(e,s,n-e,o-s),i}xP(t){if(this.copiedParts!==null)return;const i=this.diagram;if(t&&(i.isReadOnly||i.isModelReadOnly)||this.draggedParts===null)return;const e=i.undoManager;e.isEnabled&&e.isInTransaction?e.currentTransaction!==null&&e.currentTransaction.changes.count>0&&(i.undoManager.rollbackTransaction(),i.startTransaction("Drag")):this.wP(),i.skipsUndoManager=!t,i.partManager.addsToTemporaryLayer=!t,this.startPoint=i.firstInput.documentPoint;const s=this.copiesEffectiveCollection?this.draggedParts.toKeySet():i.selection,n=i.copyParts(s,i,!0),o=new GMap,r=this.draggedParts.iterator;for(;r.next();){const h=r.key;if(h.Pe()&&h.canCopy()){const a=n.get(h);if(a===null)continue;a.location=h.location,a.ensureBounds(),o.set(a,this.Is(a.location))}}const l=n.iterator;for(;l.next();){const h=l.value;h instanceof Link&&h.canCopy()&&o.set(h,this.Is())}if(this.copiedParts=o,this.mP(o.toKeySet()),this.draggedLink!==null){const h=this.draggedLink,a=h.routeBounds;h.pr(this.startPoint.x-(a.x+a.width/2),this.startPoint.y-(a.y+a.height/2))}this.doUpdateCursor(null)}kl(){const t=this.diagram;if(this.copiedParts!==null){if(t.removeParts(this.copiedParts.toKeySet(),!1),this.copiedParts=null,this.draggedParts!==null){const i=this.draggedParts.iterator;for(;i.next();)if(i.key instanceof Link){const s=i.value;s.point=new Point(0,0)}}this.doUpdateCursor(null)}t.skipsUndoManager=!1,t.partManager.addsToTemporaryLayer=!1,this.startPoint=t.firstInput.documentPoint}vC(){this.draggedLink!==null&&(this.dragsLink&&this.fn!==null&&(this.fn.stopDraggingMouseMove(),this.fn.originalLink=null),this.draggedLink=null,this.fn=null)}gc(t,i){const e=this.diagram,s=this.startPoint,n=Point.l();n.a(e.lastInput.documentPoint),this.moveParts(t,n.subtract(s),i),Point.s(n),e.getRenderingHint("temporaryPixelRatio")===!0&&e.Pl===null&&e.avgSpf>30&&(e.Bw(),e.wu())}moveParts(t,i,e){e===void 0&&(e=!1);const s=this.diagram;s!==null&&s.bP(t,i,this.dragOptions,e)}wP(){if(this.draggedParts===null)return;const t=this.diagram;let i=this.draggedParts.iterator;for(;i.next();){const e=i.key;e.Pe()&&(e.location=i.value.point)}for(i=this.draggedParts.iterator;i.next();){const e=i.key;if(e instanceof Link&&e.suspendsRouting){const s=i.value.point;this.draggedParts.set(e,this.Is()),e.pr(-s.x,-s.y)}}t.maybeUpdate()}ZD(t){if(t===null)return!0;const i=t.part;return!!(i===null||i instanceof Adornment||i.layer.isTemporary||this.draggedParts&&this.draggedParts.has(i)||this.copiedParts&&this.copiedParts.has(i))}kP(t){const i=this.diagram;this.dragsLink&&(this.draggedLink!==null&&(this.draggedLink.fromNode=null,this.draggedLink.toNode=null),this.EC(!1));const e=this.findDragOverObject(t),s=i.lastInput;s.targetObject=e,this.doUpdateCursor(e);const n=i.skipsUndoManager;let o=!1;try{if(i.skipsUndoManager=!0,o=this.OC(s,e),!this.isActive&&DraggingTool.yt===null)return;const r=e!==null?e.part:null;if(r===null||i.handlesDragDropForTopLevelParts&&r.isTopLevel&&!(r instanceof Group)){const l=i.mouseDragOver;l!==null&&(l(s),o=!0)}if(!this.isActive&&DraggingTool.yt===null||(this.doDragOver(t,e),!this.isActive&&DraggingTool.yt===null))return}finally{i.skipsUndoManager=n,o&&i.maybeUpdate()}this.pu=e,!i.isReadOnly&&(i.allowMove||i.allowCopy)&&(i.allowHorizontalScroll||i.allowVerticalScroll)&&i.doAutoScroll(s.viewPoint)}findDragOverObject(t){return this.diagram.PP(t,null,i=>!this.ZD(i))}doUpdateCursor(t){const i=this.diagram;(t===null||this.pu!==t)&&(!this.diagram.currentTool.isActive||this.mayCopy()?i.currentCursor=this.copyCursor:this.mayMove()?i.currentCursor=this.moveCursor:this.mayDragOut()&&(i.currentCursor=this.nodropCursor))}OC(t,i){let e=!1,s=this.mr.length;const n=s>0?this.mr[0]:null;if(i===n)return!1;t.handled=!1;for(let r=0;rs.findValidLinkablePort(a,i)),r=Point.l();let l=1/0,h=null;for(const a=o.iterator;a.next();){const c=a.value;if(c.part===null)continue;const u=c.getDocumentPoint(Spot.Center,r),d=t.distanceSquaredPoint(u);dh.suspendsRouting=!1)}if(this.doDropOnto(t,e),!this.isActive&&DraggingTool.yt===null)return;const o=Rect.l(),r=i.selection.iterator;for(;r.next();){const l=r.value;l instanceof Node&&this._D(i,l,o)}Rect.s(o)}QD(t,i){const e=this.diagram,s=i.part;if(e.handlesDragDropForTopLevelParts&&s.isTopLevel&&!(s instanceof Group)){const n=e.mouseDrop;n!==null&&n(t)}}_D(t,i,e){if(!i.canAvoid())return;let s=!1;e=i.getAvoidableRect(e),t.viewportBounds.containsRect(e)&&(s=!0);const n=this.copiedParts||this.draggedParts,o=t.NP(e,l=>l.part,l=>l instanceof Link,!0,l=>l instanceof Link,s);if(o.count===0)return;const r=o.iterator;for(;r.next();){const l=r.value;n.has(l)&&n.has(i)||!l.isMemberOf(i)&&l.isAvoiding&&l.invalidateRoute()}}doDropOnto(t,i){}doMouseMove(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseMove(i.event,i.documentPoint,i.targetDiagram))return;this.currentPart!==null&&this.draggedParts!==null&&(this.mayCopy()?(this.xP(!1),t.Vw(this.copiedParts),this.gc(this.copiedParts,!1),t.xm(this.copiedParts)):this.mayMove()?(this.kl(),this.gc(this.draggedParts,!0)):this.mayDragOut()?(this.xP(!1),this.gc(this.copiedParts,!1)):this.kl(),this.kP(t.lastInput.documentPoint))}doMouseUp(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseUp(i.event,i.documentPoint,i.targetDiagram))return;let e=!1;const s=this.mayCopy();if(s&&this.copiedParts!==null?(this.kl(),this.xP(!0),t.Vw(this.copiedParts),this.gc(this.copiedParts,!1),t.xm(this.copiedParts),this.copiedParts!==null&&(t.v("ChangingSelection",t.selection),t.clearSelection(!0),this.copiedParts.iteratorKeys.each(n=>{n.isSelected=!0}))):(e=!0,this.kl(),this.mayMove()&&(this.gc(this.draggedParts,!0),this.kP(t.lastInput.documentPoint))),this.mu=!0,this.VC(t.lastInput.documentPoint),this.isActive){const n=s?this.copiedParts.toKeySet():this.draggedParts.toKeySet();this.copiedParts=null,e&&this.tF(),t.invalidateDocumentBounds(),t.xm(this.draggedParts),this.transactionResult=s?"Copy":"Move",t.v(s?"SelectionCopied":"SelectionMoved",n)}this.stopTool(),s&&t.v("ChangedSelection",t.selection)}simulatedMouseMove(t,i,e){if(DraggingTool.yt===null)return!1;const s=DraggingTool.yt.diagram;e instanceof Diagram||(e=null);const n=DraggingTool.Vh;if(e!==n){if(n!==null&&n!==s){n.stopAutoScroll(),DraggingTool.yt.isDragOutStarted=!1;const r=n.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDragLeave()}if(DraggingTool.Vh=e,e!==null&&e!==s){DraggingTool.yt.IC();const r=e.toolManager.findTool("Dragging");r!==null&&(r.zC(),r.doSimulatedDragEnter())}this.doUpdateCursor(null)}if(e===null||e===s||!e.allowDrop||e.isReadOnly||!e.allowInsert)return!1;const o=e.toolManager.findTool("Dragging");if(o!==null){let r=i;t!==null&&(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),r=e.getMouse(t)),e.lastInput.documentPoint=r,e.lastInput.viewPoint=e.transformDocToView(r),e.lastInput.down=!1,e.lastInput.up=!1,o.doSimulatedDragOver()}return!0}simulatedMouseUp(t,i,e){if(DraggingTool.yt===null)return!1;const s=DraggingTool.Vh,n=DraggingTool.yt.diagram;if(e===null)return DraggingTool.yt.doCancel(),!0;if(e!==s){const o=s.toolManager.findTool("Dragging");if(s!==null&&s!==n&&o!==null)return s.stopAutoScroll(),DraggingTool.yt.isDragOutStarted=!1,o.doSimulatedDragLeave(),!1;DraggingTool.Vh=e;const r=e.toolManager.findTool("Dragging");r!==null&&(DraggingTool.yt.IC(),r.zC(),r.doSimulatedDragEnter())}if(e!==this.diagram){let o=i;t!==null?(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),o=e.getMouse(t)):o===null&&(o=new Point),e.lastInput.documentPoint=o,e.lastInput.viewPoint=e.transformDocToView(o),e.lastInput.down=!1,e.lastInput.up=!0;const r=e.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDrop();const l=DraggingTool.yt;if(l!==null){const h=l.mayCopy();l.transactionResult=h?"Copy":"Move",l.stopTool()}return!0}return!1}tF(){if(this.draggedParts===null)return;const t=this.draggedParts.iterator;for(;t.next();){const i=t.key;if(i instanceof Node){const e=i.containingGroup;e!==null&&e.hasPlaceholder()&&!this.draggedParts.has(e)&&e.placeholder.c()}}}mayCopy(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowCopy||!(Util.rr?t.lastInput.alt:t.lastInput.control))return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayDragOut(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(!t.allowDragOut||!t.allowCopy||t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayMove(){const t=this.diagram;if(t.isReadOnly||!t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canMove())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canMove())}zC(){DraggingTool.zw.has(this)||DraggingTool.zw.add(this)}static JD(){if(DraggingTool.zw.count>0){const t=DraggingTool.zw,i=t.length;for(let e=0;e{n.isSelected=!0,s.add(n)})),this.VC(t.lastInput.documentPoint),t.invalidateDocumentBounds(),this.copiedParts!==null&&(this.transactionResult="ExternalCopy"),this.copiedParts=null,t.doFocus(),t.uc=!1,t.v("ExternalObjectsDropped",s,e),this.stopTransaction(),t.v("ChangedSelection",t.selection)}t.animationManager.xu=!1}XC(t,i,e){if(this.copiedParts!==null)return;const s=this.diagram;if(s.isReadOnly||s.isModelReadOnly)return;s.skipsUndoManager=!i,s.partManager.addsToTemporaryLayer=!i,this.startPoint=e.documentPoint;const n=s.copyParts(t,s,!0),o=Rect.l();this.$D(t,o);const r=o.x+o.width/2,l=o.y+o.height/2;Rect.s(o);const h=this.wm,a=new GMap,c=Point.l(),f=t.iterator;for(;f.next();){const d=f.value;if(d instanceof Link&&d.canCopy()){const m=n.get(d);if(m===null)continue;m.points=d.points,m.pr(h.x-r,h.y-l),m.suspendsRouting=!0,a.set(m,this.Is())}}const u=t.iterator;for(;u.next();){const d=u.value;if(d.Pe()&&d.canCopy()){const m=n.get(d);if(m===null)continue;const g=d.location;c.e(h.x-(r-g.x),h.y-(l-g.y)),m.location=c,m.ensureBounds(),a.set(m,this.Is(c))}}if(Point.s(c),this.copiedParts=a,this.mP(a.toKeySet()),this.draggedLink!==null){const d=this.draggedLink,m=d.routeBounds;d.pr(this.startPoint.x-(m.x+m.width/2),this.startPoint.y-(m.y+m.height/2))}this.doUpdateCursor(null)}WD(){this.isDragOutStarted=!0,this.mu=!1,DraggingTool.yt=this,DraggingTool.Vh=this.diagram,this.doSimulatedDragOut()}doSimulatedDragOut(){const t=this.diagram;t.uc=!1,!this.mayCopy()&&!this.mayMove()?t.currentCursor=this.nodropCursor:t.currentCursor="",this.pu=null}computeMove(t,i,e,s){const n=this.diagram;return n!==null?n.computeMove(t,i,this.dragOptions,s):new Point}static zw=new List;static yt=null;static Vh=null}ToolManager.prototype.doCancel=function(){DraggingTool.yt!==null&&DraggingTool.yt.doCancel(),Tool.prototype.doCancel.call(this)};class LinkingBaseTool extends Tool{CP;LP;Ml;AP;TP;zh;DP;Xh;FP;RP;vP;OP;IP;EP;KC;UP;Sl;BP;constructor(){super(),this.CP=100,this.LP=!1,this.Ml="pointer",this.AP=new Link({layerName:"Tool"}).add(new Shape({isPanelMain:!0,stroke:"blue"}).theme("stroke","tempLink"),new Shape({toArrow:"Standard",fill:"blue",stroke:"blue"}).theme("fill","tempLink").theme("stroke","tempLink")).li(),this.zh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.Dk}).theme("stroke","tempPort"),this.TP=new Node({selectable:!1,layerName:"Tool"}).add(this.zh).li(),this.Xh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.Dk}).theme("stroke","tempPort"),this.DP=new Node({selectable:!1,layerName:"Tool"}).add(this.Xh).li(),this.FP=null,this.RP=null,this.vP=null,this.OP=null,this.IP=null,this.EP=!0,this.KC=new GMap,this.UP=null,this.Sl=null,this.BP=null}doStop(){this.diagram.stopAutoScroll(),this.originalLink=null,this.originalFromNode=null,this.originalFromPort=null,this.originalToNode=null,this.originalToPort=null,this.validPortsCache.clear(),this.targetPort=null}get portGravity(){return this.CP}set portGravity(t){Util.i(t,"number",LinkingBaseTool,"portGravity"),t>=0&&(this.CP=t)}get isUnconnectedLinkValid(){return this.LP}set isUnconnectedLinkValid(t){Util.i(t,"boolean",LinkingBaseTool,"isUnconnectedLinkValid"),this.LP=t}get linkingCursor(){return this.Ml}set linkingCursor(t){this.Ml=t}get temporaryLink(){return this.AP}set temporaryLink(t){t.li(),this.AP=t}get temporaryFromNode(){return this.TP}set temporaryFromNode(t){t.li(),this.TP=t,t&&(this.zh=t.port)}get temporaryFromPort(){return this.zh}set temporaryFromPort(t){if(this.zh!==null){const i=this.zh.panel;if(i!==null){const e=i.L.indexOf(this.zh);i.removeAt(e),i.insertAt(e,t)}}this.zh=t}get temporaryToNode(){return this.DP}set temporaryToNode(t){t.li(),this.DP=t,t&&(this.Xh=t.port)}get temporaryToPort(){return this.Xh}set temporaryToPort(t){if(this.Xh!==null){const i=this.Xh.panel;if(i!==null){const e=i.L.indexOf(this.Xh);i.removeAt(e),i.insertAt(e,t)}}this.Xh=t}get originalLink(){return this.FP}set originalLink(t){this.FP=t}get originalFromNode(){return this.RP}set originalFromNode(t){this.RP=t}get originalFromPort(){return this.vP}set originalFromPort(t){this.vP=t}get originalToNode(){return this.OP}set originalToNode(t){this.OP=t}get originalToPort(){return this.IP}set originalToPort(t){this.IP=t}get isForwards(){return this.EP}set isForwards(t){this.EP=t}get validPortsCache(){return this.KC}get targetPort(){return this.UP}set targetPort(t){this.UP=t}copyPortProperties(t,i,e,s,n){if(t===null||i===null||e===null||s===null)return;const o=i.getDocumentScale(),r=Size.l();r.width=i.naturalBounds.width*o,r.height=i.naturalBounds.height*o,s.desiredSize=r,Size.s(r),n?(s.toSpot=i.toSpot,s.toEndSegmentLength=i.toEndSegmentLength):(s.fromSpot=i.fromSpot,s.fromEndSegmentLength=i.fromEndSegmentLength),e.locationSpot=Spot.Center;const l=Point.l();e.location=i.getDocumentPoint(Spot.Center,l),Point.s(l),s.angle=i.getDocumentAngle(),this.portTargeted!==null&&this.portTargeted(t,i,e,s,n)}setNoTargetPortProperties(t,i,e){i!==null&&(i.desiredSize=Size.Dk,i.fromSpot=Spot.None,i.toSpot=Spot.None),t!==null&&(t.location=this.diagram.lastInput.documentPoint),this.portTargeted!==null&&this.portTargeted(null,null,t,i,e)}doMouseDown(){this.isActive&&this.doMouseMove()}doMouseMove(){if(this.isActive){const t=this.diagram;if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null&&this.targetPort.part instanceof Node){const i=this.targetPort.part;this.isForwards?this.copyPortProperties(i,this.targetPort,this.temporaryToNode,this.temporaryToPort,!0):this.copyPortProperties(i,this.targetPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else this.isForwards?this.setNoTargetPortProperties(this.temporaryToNode,this.temporaryToPort,!0):this.setNoTargetPortProperties(this.temporaryFromNode,this.temporaryFromPort,!1);(t.allowHorizontalScroll||t.allowVerticalScroll)&&t.doAutoScroll(t.lastInput.viewPoint)}}findValidLinkablePort(t,i){if(t===null)return null;const e=t.part;if(!(e instanceof Node))return null;for(;t!==null;){const s=i?t.toLinkable:t.fromLinkable;if(s===!0&&(t.portId!==null||t instanceof Node)&&(i?this.isValidTo(e,t):this.isValidFrom(e,t)))return t;if(s===!1)return null;t=t.panel}return null}findTargetPort(t){const i=this.diagram,e=i.lastInput.documentPoint;let s=this.portGravity;s<=0&&(s=.1);const n=this,o=i.findObjectsNear(e,s,a=>n.findValidLinkablePort(a,t),null,!0);let r=1/0,l=null;const h=o.iterator;for(;h.next();){const a=h.value,c=a.part;if(!(c instanceof Node))continue;const f=a.getDocumentPoint(Spot.Center,Point.l()),u=e.x-f.x,d=e.y-f.y;Point.s(f);const m=u*u+d*d;if(m=e)return!1}return!0}isValidTo(t,i){if(t===null||i===null)return this.isUnconnectedLinkValid;if(this.diagram.currentTool===this&&(t.layer!==null&&!t.layer.allowLink||i.toLinkable!==!0))return!1;const e=i.toMaxLinks;if(e<1/0){if(this.originalLink!==null&&t===this.originalToNode&&i===this.originalToPort)return!0;let s=i.portId;if(s===null&&(s=""),t.findLinksInto(s).count>=e)return!1}return!0}isInSameNode(t,i){if(t===null||i===null)return!1;if(t===i)return!0;const e=t.part,s=i.part;return e!==null&&e===s}isLinked(t,i){if(t===null||i===null)return!1;const e=t.part;if(!(e instanceof Node))return!1;let s=t.portId;s===null&&(s="");const n=i.part;if(!(n instanceof Node))return!1;let o=i.portId;o===null&&(o="");const r=n.findLinksInto(o);for(;r.next();){const l=r.value;if(l.fromNode===e&&l.fromPortId===s)return!0}return!1}isValidLink(t,i,e,s){if(!this.isValidFrom(t,i)||!this.isValidTo(e,s)||i!==null&&s!==null&&(!(i.fromLinkableSelfNode&&s.toLinkableSelfNode)&&this.isInSameNode(i,s)||!(i.fromLinkableDuplicates&&s.toLinkableDuplicates)&&this.isLinked(i,s))||this.originalLink!==null&&(t!==null&&this.isLabelDependentOnLink(t,this.originalLink)||e!==null&&this.isLabelDependentOnLink(e,this.originalLink))||t!==null&&e!==null&&(t.data===null&&e.data!==null||t.data!==null&&e.data===null)||!this.isValidCycle(t,e,this.originalLink))return!1;let n;return t!==null&&(n=t.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))||e!==null&&(n=e.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))?!1:(n=this.linkValidation,n!==null?n(t,i,e,s,this.originalLink):!0)}isLabelDependentOnLink(t,i){if(t===null)return!1;const e=t.labeledLink;if(e===null)return!1;if(e===i)return!0;const s=new GSet;return s.add(t),this.VP(e,i,s)}VP(t,i,e){if(t===i)return!0;const s=t.fromNode;if(s!==null&&s.isLinkLabel&&(e.add(s),this.VP(s.labeledLink,i,e)))return!0;const n=t.toNode;return!!(n!==null&&n.isLinkLabel&&(e.add(n),this.VP(n.labeledLink,i,e)))}isValidCycle(t,i,e){if(e===void 0&&(e=null),t===null||i===null)return this.isUnconnectedLinkValid;const s=this.diagram;let n=1;if(s&&(s.model.mc()?n=s.isTreePathToChildren?5:6:n=s.validCycle),n===1)return!0;if(n===5){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=i.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.toNode===i)return!1}return!this.bu(t,i,e,!0)}else if(n===6){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=t.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.fromNode===t)return!1}return!this.bu(t,i,e,!0)}else{if(n===2)return!this.iF(t,i,e);if(n===3)return!this.bu(t,i,e,!1);if(n===4)return!this.eF(t,i,e)}return!0}bu(t,i,e,s){if(t===i)return!0;if(t===null||i===null)return!1;const n=t.linksConnected;for(;n.next();){const o=n.value;if(o===e||s&&!o.isTreeLink||o.toNode!==t)continue;const r=o.fromNode;if(r!==t&&this.bu(r,i,e,s))return!0}return!1}iF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.YC(s,t,i,e)}YC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s||o.toNode!==i)continue;const r=o.fromNode;if(r!==i&&this.YC(t,r,e,s))return!0}return!1}eF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.GC(s,t,i,e)}GC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s)continue;const r=o.fromNode,l=o.toNode,h=r===i?l:r;if(h!==i&&this.GC(t,h,e,s))return!0}return!1}get linkValidation(){return this.Sl}set linkValidation(t){t!==null&&Util.i(t,"function",LinkingBaseTool,"linkValidation"),this.Sl=t}get portTargeted(){return this.BP}set portTargeted(t){t!==null&&Util.i(t,"function",LinkingBaseTool,"portTargeted"),this.BP=t}}var LinkingDirection=(w=>(w[w.Either=1]="Either",w[w.ForwardsOnly=2]="ForwardsOnly",w[w.BackwardsOnly=3]="BackwardsOnly",w))(LinkingDirection||{});class LinkingTool extends LinkingBaseTool{zP;XP;S;KP;constructor(t){super(),this.name="Linking",this.zP={},this.XP=null,this.S=1,this.KP=null,t&&Object.assign(this,t)}static Either=1;static ForwardsOnly=2;static BackwardsOnly=3;get archetypeLinkData(){return this.zP}set archetypeLinkData(t){t!==null&&Util.i(t,"object",LinkingTool,"archetypeLinkData"),this.zP=t}get archetypeLabelNodeData(){return this.XP}set archetypeLabelNodeData(t){t!==null&&Util.i(t,"object",LinkingTool,"archetypeLabelNodeData"),this.XP=t}get direction(){return this.S}set direction(t){this.S=t}get startObject(){return this.KP}set startObject(t){this.KP=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||t.isModelReadOnly||!t.allowLink||!t.model.Xw()||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize()?!1:this.findLinkablePort()!==null}findLinkablePort(){const t=this.diagram;let i=this.startObject;if(i===null&&(i=t.findObjectAt(t.firstInput.documentPoint,null,null)),i===null)return null;const e=i.part;if(!(e instanceof Node))return null;const s=this.direction;if(s===1||s===2){const n=this.findValidLinkablePort(i,!1);if(n!==null)return this.isForwards=!0,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!1))return this.isForwards=!0,o}}if(s===1||s===3){const n=this.findValidLinkablePort(i,!0);if(n!==null)return this.isForwards=!1,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!0))return this.isForwards=!1,o}}return null}doActivate(){const t=this.diagram,i=this.findLinkablePort();if(i===null){this.stopTool();return}if(this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.isForwards){this.temporaryToNode!==null&&(this.temporaryToNode.location=t.lastInput.documentPoint),this.originalFromPort=i;const e=this.originalFromPort.part;e instanceof Node&&(this.originalFromNode=e),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else{this.temporaryFromNode!==null&&(this.temporaryFromNode.location=t.lastInput.documentPoint),this.originalToPort=i;const e=this.originalToPort.part;e instanceof Node&&(this.originalToNode=e),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0)}t.add(this.temporaryFromNode),this.temporaryFromNode&&this.temporaryFromNode.ensureBounds(),t.add(this.temporaryToNode),this.temporaryToNode&&this.temporaryToNode.ensureBounds(),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.temporaryLink.isTreeLink=this.isNewTreeLink(),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.startObject=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=null,e=null,s=null,n=null,o=null;try{this.targetPort=this.findTargetPort(this.isForwards);const r=this.targetPort;if(r!==null){const l=r.part;l instanceof Node&&(this.isForwards?(this.originalFromNode!==null&&(i=this.originalFromNode,e=this.originalFromPort),s=l,n=r):(i=l,e=r,this.originalToNode!==null&&(s=this.originalToNode,n=this.originalToPort)))}else this.isForwards?this.originalFromNode!==null&&this.isUnconnectedLinkValid&&(i=this.originalFromNode,e=this.originalFromPort):this.originalToNode!==null&&this.isUnconnectedLinkValid&&(s=this.originalToNode,n=this.originalToPort);i!==null||s!==null?(o=this.insertLink(i,e,s,n),o!==null?(r===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint),t.allowSelect&&(t.v("ChangingSelection",t.selection),t.clearSelection(!0),o.isSelected=!0),this.transactionResult=this.name,t.v("LinkDrawn",o)):this.doNoLink(i,e,s,n)):this.isForwards?this.doNoLink(this.originalFromNode,this.originalFromPort,null,null):this.doNoLink(null,null,this.originalToNode,this.originalToPort)}finally{this.stopTool(),o&&t.allowSelect&&t.v("ChangedSelection",t.selection)}}}isNewTreeLink(){const t=this.archetypeLinkData;if(t===null)return!0;if(t instanceof Link)return t.isTreeLink;const i=this.diagram;if(i===null)return!0;const e=i.partManager.getLinkCategoryForData(t),s=i.partManager.findLinkTemplateForCategory(e);return s!==null?s.isTreeLink:!0}insertLink(t,i,e,s){return this.diagram.partManager.insertLink(t,i,e,s)}doNoLink(t,i,e,s){}}class RelinkingTool extends LinkingBaseTool{YP;GP;fs;jP;constructor(t){super(),this.name="Relinking",this.YP=new Shape("Diamond",{desiredSize:Size.hu,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:0}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.GP=new Shape("Diamond",{desiredSize:Size.hu,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:-1}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.fs=null,this.jP=new Rect,t&&Object.assign(this,t)}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i="RelinkFrom",e=null;if(t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkFrom()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null&&(e=this.makeAdornment(s,!1),t.addAdornment(i,e)))}if(e===null&&t.removeAdornment(i),i="RelinkTo",e=null,t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkTo()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null?(e=this.makeAdornment(s,!0),t.addAdornment(i,e)):e.c())}e===null&&t.removeAdornment(i)}makeAdornment(t,i){const e=new Adornment;e.type=Panel.Link;const s=i?this.toHandleArchetype:this.fromHandleArchetype;return s!==null&&e.add(s.copy().bm()),e.adornedObject=t,e}get fromHandleArchetype(){return this.YP}set fromHandleArchetype(t){this.YP=t}get toHandleArchetype(){return this.GP}set toHandleArchetype(t){this.GP=t}get handle(){return this.fs}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.fs=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowRelink||!t.model.Xw()||!t.lastInput.left)return!1;let e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom");return e===null&&(e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo")),e!==null}doActivate(){const t=this.diagram;if(this.originalLink===null){let i=this.handle;if(i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom"),i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo"))),i===null)return;const e=i.part;if(!(e instanceof Adornment)||!(e.adornedPart instanceof Link))return;this.handle=i,this.isForwards=e===null||e.category==="RelinkTo",this.originalLink=e.adornedPart}this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.originalFromPort=this.originalLink.fromPort,this.originalFromNode=this.originalLink.fromNode,this.originalToPort=this.originalLink.toPort,this.originalToNode=this.originalLink.toNode,this.jP.set(this.originalLink.actualBounds),this.originalLink!==null&&this.originalLink.pointsCount>0&&(this.originalLink.fromNode===null&&(this.temporaryFromPort!==null&&(this.temporaryFromPort.desiredSize=Size.lu),this.temporaryFromNode!==null&&(this.temporaryFromNode.location=this.originalLink.getPoint(0))),this.originalLink.toNode===null&&(this.temporaryToPort!==null&&(this.temporaryToPort.desiredSize=Size.lu),this.temporaryToNode!==null&&(this.temporaryToNode.location=this.originalLink.getPoint(this.originalLink.pointsCount-1)))),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0),t.add(this.temporaryFromNode),t.add(this.temporaryToNode),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.copyLinkProperties(this.originalLink,this.temporaryLink),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}copyLinkProperties(t,i){if(t===null||i===null)return;i.adjusting=t.adjusting,i.corner=t.corner;let e=t.curve;(e===11||e===10)&&(e=0),i.curve=e,i.curviness=t.curviness,i.isTreeLink=t.isTreeLink,i.points=t.points,i.routing=t.routing,i.smoothness=t.smoothness,i.fromSpot=t.fromSpot,i.fromEndSegmentLength=t.fromEndSegmentLength,i.fromShortLength=t.fromShortLength,i.toSpot=t.toSpot,i.toEndSegmentLength=t.toEndSegmentLength,i.toShortLength=t.toShortLength}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.handle=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=this.originalFromNode,e=this.originalFromPort,s=this.originalToNode,n=this.originalToPort,o=this.originalLink;try{if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null){const r=this.targetPort.part;r instanceof Node&&(this.isForwards?(s=r,n=this.targetPort):(i=r,e=this.targetPort))}else this.isUnconnectedLinkValid?this.isForwards?(s=null,n=null):(i=null,e=null):o=null;o!==null?(this.reconnectLink(o,this.isForwards?s:i,this.isForwards?n:e,this.isForwards),this.targetPort===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint,o.invalidateRoute()),this.transactionResult=this.name,t.v("LinkRelinked",o,this.isForwards?this.originalToPort:this.originalFromPort)):this.doNoRelink(this.originalLink,this.isForwards),this.originalLink.invalidateOtherJumpOvers(this.jP)}finally{this.stopTool()}}}reconnectLink(t,i,e,s){const n=e!==null&&e.portId!==null?e.portId:"";return s?(t.toNode=i,t.toPortId=n):(t.fromNode=i,t.fromPortId=n),!0}doNoRelink(t,i){}doDraggingMouseMove(t,i,e,s){t!==null?(this.copyPortProperties(t,i,this.temporaryFromNode,this.temporaryFromPort,!1),this.diagram.add(this.temporaryFromNode)):this.diagram.remove(this.temporaryFromNode),e!==null?(this.copyPortProperties(e,s,this.temporaryToNode,this.temporaryToPort,!0),this.diagram.add(this.temporaryToNode)):this.diagram.remove(this.temporaryToNode)}stopDraggingMouseMove(){this.diagram.remove(this.temporaryFromNode),this.diagram.remove(this.temporaryToNode)}}var ReshapingBehavior=(w=>(w[w.None=0]="None",w[w.Horizontal=1]="Horizontal",w[w.Vertical=2]="Vertical",w[w.All=3]="All",w))(ReshapingBehavior||{});class LinkReshapingTool extends Tool{Co;HP;qP;fs;Kw;WP;km;constructor(t){super(),this.name="LinkReshaping",this.Co=new Shape("Rectangle",{desiredSize:Size.iC,fill:"lightblue",stroke:"dodgerblue"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.HP=new Shape("Diamond",{desiredSize:Size.hu,fill:"lightblue",stroke:"dodgerblue",cursor:"move"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.qP=3,this.fs=null,this.Kw=null,this.WP=new Point,this.km=new List,t&&Object.assign(this,t)}static None=0;static Horizontal=1;static Vertical=2;static All=3;getReshapingBehavior(t){return t?t.wr:0}setReshapingBehavior(t,i){t.wr=i}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i=null;if(t.isSelected&&!this.diagram.isReadOnly){const e=t.path;e!==null&&t.canReshape()&&t.actualBounds.isReal()&&t.isVisible()&&e.actualBounds.isReal()&&e.isVisibleObject()&&(i=t.findAdornment(this.name),(i===null||i.JP!==t.pointsCount||i.$P!==t.resegmentable)&&(i=this.makeAdornment(e),i!==null&&(i.JP=t.pointsCount,i.$P=t.resegmentable,t.addAdornment(this.name,i))))}i===null&&t.removeAdornment(this.name)}makeAdornment(t){const i=t.part,e=i.points,s=i.pointsCount,n=i.isOrthogonal;let o=null;if(e!==null&&s>1){o=new Adornment,o.type=Panel.Link;const r=i.firstPickIndex,l=i.lastPickIndex,h=n?1:0;if(i.resegmentable&&i.computeCurve()!==9)for(let a=r+h;ae.firstPickIndex+1&&s0))this.sF(t,i);else if(t instanceof Panel){const e=t.elements;for(;e.next();){const s=e.value;this.updateResizeHandles(s,i)}}}}sF(t,i){let e=t.alignment;e.isNoSpot()&&(e=Spot.Center);let s=i;if(e.x<=0)e.y<=0?s+=225:e.y>=1?s+=135:s+=180;else if(e.x>=1)e.y<=0?s+=315:e.y>=1&&(s+=45);else if(e.y<=0)s+=270;else if(e.y>=1)s+=90;else return;s<0?s+=360:s>=360&&(s-=360),s<22.5?t.cursor="e-resize":s<67.5?t.cursor="se-resize":s<112.5?t.cursor="s-resize":s<157.5?t.cursor="sw-resize":s<202.5?t.cursor="w-resize":s<247.5?t.cursor="nw-resize":s<292.5?t.cursor="n-resize":s<337.5?t.cursor="ne-resize":t.cursor="e-resize"}get handleArchetype(){return this.Co}set handleArchetype(t){this.Co=t}get handle(){return this.fs}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.fs=t}get adornedObject(){return this.us}set adornedObject(t){if(t!==null&&t.part instanceof Adornment)throw new Error("new handle must not be in an Adornment: "+t);this.us=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowResize||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle!==null&&(this.adornedObject=this.handle.part.adornedObject,this.adornedObject!==null&&(t.isMouseCaptured=!0,t.animationManager.stopAnimation(),t.yu=!0,this.startTransaction(this.name),this.Pm.set(this.adornedObject.getDocumentPoint(this.handle.alignment.opposite())),this.yc.set(this.adornedObject.part.location),this.QP.set(this.adornedObject.desiredSize),this.jw=this.computeCellSize(),this.Yw=this.computeMinSize(),this.Gw=this.computeMaxSize(),this.isActive=!0))}doDeactivate(){const t=this.diagram;t.yu=!1,t.bl=!0,this.stopTransaction(),this.handle=null,this.us=null,t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){this.adornedObject!==null&&(this.adornedObject.desiredSize=this.originalDesiredSize,this.adornedObject.part.location=this.originalLocation),this.stopTool()}doMouseMove(){const t=this.diagram;if(!this.isActive)return;const i=this.Yw,e=this.Gw,s=this.jw,n=t.lastInput.documentPoint,o=this.adornedObject.getLocalPoint(n,Point.l()),r=this.computeReshape(),l=this.computeResize(o,this.handle.alignment,i,e,s,r);this.resize(l),t.maybeUpdate(),Point.s(o)}doMouseUp(){const t=this.diagram;if(this.isActive){const i=this.Yw,e=this.Gw,s=this.jw,n=this.adornedObject.getLocalPoint(t.lastInput.documentPoint,Point.l()),o=this.computeReshape(),r=this.computeResize(n,this.handle.alignment,i,e,s,o);this.resize(r),Point.s(n),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.v("PartResized",this.adornedObject,this.originalDesiredSize)}this.stopTool()}resize(t){const i=this.diagram,e=this.adornedObject;if(e===null)return;e.desiredSize=t.size;const s=e.part;s.ensureBounds();const n=e.getDocumentPoint(this.handle.alignment.opposite());if(s instanceof Group){const o=new List;o.add(s);let r;!this.dragsMembers&&!s.hasPlaceholder()&&(r=new DraggingOptions,r.dragsMembers=!1),i.moveParts(o,this.oppositePoint.copy().subtract(n),!0,r)}else s.location=s.location.copy().subtract(n).add(this.oppositePoint);i.maybeUpdate()}computeResize(t,i,e,s,n,o){i.isNoSpot()&&(i=Spot.Center);const r=this.adornedObject.naturalBounds,l=r.x,h=r.y,a=r.x+r.width,c=r.y+r.height;let f=1;if(!o){let m=r.width,g=r.height;m<=0&&(m=1),g<=0&&(g=1),f=g/m}const u=Point.l();Geo.Eg(t.x,t.y,l,h,n.width,n.height,u);const d=r.copy();return i.x<=0?i.y<=0?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=Math.max(c-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.x=a-d.width,d.y=c-d.height)):i.y>=1?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.x=a-d.width)):(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=a-d.x,o||(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f,d.y=h+.5*(c-h-d.height))):i.x>=1?i.y<=0?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=Math.max(c-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.y=c-d.height)):i.y>=1?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width))):(d.width=Math.max(Math.min(u.x-l,s.width),e.width),o||(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f,d.y=h+.5*(c-h-d.height))):i.y<=0?(d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=c-d.y,o||(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width,d.x=l+.5*(a-l-d.width))):i.y>=1&&(d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width,d.x=l+.5*(a-l-d.width))),Point.s(u),d}computeReshape(){let t=0;return this.adornedObject instanceof Shape&&(t=this.adornedObject._P()),!(t===6||this.diagram.lastInput.shift)}computeMinSize(){const t=this.adornedObject.minSize.copy(),i=this.minSize;return!isNaN(i.width)&&i.width>t.width&&(t.width=i.width),!isNaN(i.height)&&i.height>t.height&&(t.height=i.height),t}computeMaxSize(){const t=this.adornedObject.maxSize.copy(),i=this.maxSize;return!isNaN(i.width)&&i.width0&&(t.width=n.width),!isNaN(n.height)&&n.height>0&&(t.height=n.height)}let e=this.cellSize;isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height);const s=this.diagram;if((isNaN(t.width)||isNaN(t.height))&&s){const n=s.grid;n!==null&&n.visible&&this.isGridSnapEnabled&&(e=n.gridCellSize,isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height))}return(isNaN(t.width)||t.width===0||t.width===1/0)&&(t.width=1),(isNaN(t.height)||t.height===0||t.height===1/0)&&(t.height=1),t}get minSize(){return this.xr}set minSize(t){if(!this.xr.equals(t)){let e=t.width;isNaN(e)&&(e=0);let s=t.height;isNaN(s)&&(s=0),this.xr.e(e,s)}}get maxSize(){return this.br}set maxSize(t){if(!this.br.equals(t)){let e=t.width;isNaN(e)&&(e=1/0);let s=t.height;isNaN(s)&&(s=1/0),this.br.e(e,s)}}get cellSize(){return this.Lo}set cellSize(t){this.Lo.equals(t)||this.Lo.a(t)}get isGridSnapEnabled(){return this.pc}set isGridSnapEnabled(t){Util.i(t,"boolean",ResizingTool,"isGridSnapEnabled"),this.pc=t}get dragsMembers(){return this.ZP}set dragsMembers(t){Util.i(t,"boolean",ResizingTool,"dragsMembers"),this.ZP=t}get oppositePoint(){return this.Pm}set oppositePoint(t){this.Pm.equals(t)||this.Pm.a(t)}get originalDesiredSize(){return this.QP}get originalLocation(){return this.yc}}class RotatingTool extends Tool{tM;iM;us;Co;fs;eM;Mm;yc;sM;nM;constructor(t){super(),this.name="Rotating",this.tM=45,this.iM=2,this.yc=new Point,this.us=null,this.Co=new Shape("Ellipse",{desiredSize:Size.hu,fill:"lightblue",stroke:"dodgerblue",strokeWidth:1,cursor:"pointer"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.fs=null,this.eM=0,this.Mm=new Point(NaN,NaN),this.sM=0,this.nM=50,t&&Object.assign(this,t)}updateAdornments(t){if(t!==null){if(t.Cl()){const i=t.rotateObject;if(i===t||i===t.path||i.isPanelMain)return}if(t.isSelected&&!this.diagram.isReadOnly){const i=t.rotateObject;if(i!==null&&t.canRotate()&&t.actualBounds.isReal()&&t.isVisible()&&i.actualBounds.isReal()&&i.isVisibleObject()){let e=t.findAdornment(this.name);if((e===null||e.adornedObject!==i)&&(e=this.makeAdornment(i)),e!==null){e.angle=i.getDocumentAngle(),e.hasPlaceholder()||(e.location=this.computeAdornmentLocation(i)),t.addAdornment(this.name,e);return}}}t.removeAdornment(this.name)}}makeAdornment(t){let i=null;const e=t.part.rotateAdornmentTemplate;if(e===null){i=new Adornment,i.type=Panel.Position,i.locationSpot=Spot.Center;const s=this.handleArchetype;s!==null&&i.add(s.copy().bm())}else if(e.li(),i=e.copy(),i===null)return null;return i.adornedObject=t,i}get handleArchetype(){return this.Co}set handleArchetype(t){this.Co=t}get handle(){return this.fs}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.fs=t}get adornedObject(){return this.us}set adornedObject(t){if(t!==null&&t.part instanceof Adornment)throw new Error("new handle must not be in an Adornment: "+t);this.us=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowRotate||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;if(this.adornedObject===null){if(this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle===null)return;this.adornedObject=this.handle.part.adornedObject}this.adornedObject!==null&&(t.isMouseCaptured=!0,t.delaysLayout=!0,this.startTransaction(this.name),this.eM=this.adornedObject.angle,this.Mm=this.computeRotationPoint(this.adornedObject),this.yc=this.adornedObject.part.location.copy(),this.isActive=!0)}computeRotationPoint(t){const i=t.part,e=i.locationObject;return i.rotationSpot.isSpot()?t.getDocumentPoint(i.rotationSpot):t===i||t===e?e.getDocumentPoint(i.locationSpot):t.getDocumentPoint(Spot.Center)}computeAdornmentLocation(t){let i=this.rotationPoint;i.isReal()||(i=this.computeRotationPoint(t));const e=t.getLocalPoint(i);let s=this.handleAngle;s<0?s+=360:s>=360&&(s-=360),s=Math.round(Math.round(s/45)*45);const n=this.handleDistance;return s===0?e.x=t.naturalBounds.width+n:s===45?(e.x=t.naturalBounds.width+n,e.y=t.naturalBounds.height+n):s===90?e.y=t.naturalBounds.height+n:s===135?(e.x=-n,e.y=t.naturalBounds.height+n):s===180?e.x=-n:s===225?(e.x=-n,e.y=-n):s===270?e.y=-n:s===315&&(e.x=t.naturalBounds.width+n,e.y=-n),t.getDocumentPoint(e)}doDeactivate(){const t=this.diagram;this.stopTransaction(),this.handle=null,this.us=null,this.Mm=new Point(NaN,NaN),t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){const t=this.diagram;t.delaysLayout=!1,this.rotate(this.originalAngle),this.stopTool()}doMouseMove(){const t=this.diagram;if(this.isActive){const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i)}}doMouseUp(){const t=this.diagram;if(this.isActive){t.delaysLayout=!1;const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.v("PartRotated",this.adornedObject,this.originalAngle)}this.stopTool()}rotate(t){const i=this.adornedObject;if(i===null)return;i.angle=t;const e=i.part;e.ensureBounds();const s=e.locationObject,n=e.rotateObject;if(s===n||s.isContainedBy(n)){const o=this.yc.copy();e.location=o.subtract(this.rotationPoint).rotate(t-this.originalAngle).add(this.rotationPoint)}this.diagram.maybeUpdate()}computeRotate(t){let i=this.rotationPoint.directionPoint(t)-this.handleAngle;const e=this.adornedObject.panel;e!==null&&(i-=e.getDocumentAngle()),i>=360?i-=360:i<0&&(i+=360);const s=Math.min(Math.abs(this.snapAngleMultiple),180),n=Math.min(Math.abs(this.snapAngleEpsilon),s/2);return!this.diagram.lastInput.shift&&s>0&&n>0&&(i%ss-n&&(i=(Math.floor(i/s)+1)*s)),i>=360?i-=360:i<0&&(i+=360),i}get snapAngleMultiple(){return this.tM}set snapAngleMultiple(t){Util.i(t,"number",RotatingTool,"snapAngleMultiple"),this.tM=t}get snapAngleEpsilon(){return this.iM}set snapAngleEpsilon(t){Util.i(t,"number",RotatingTool,"snapAngleEpsilon"),this.iM=t}get originalAngle(){return this.eM}get rotationPoint(){return this.Mm}set rotationPoint(t){this.Mm=t.copy()}get handleAngle(){return this.sM}set handleAngle(t){Util.i(t,"number",RotatingTool,"handleAngle"),this.sM=t}get handleDistance(){return this.nM}set handleDistance(t){Util.i(t,"number",RotatingTool,"handleDistance"),this.nM=t}}class ClickSelectingTool extends Tool{constructor(t){super(),this.name="ClickSelecting",t&&Object.assign(this,t)}canStart(){return!(!this.isEnabled||this.isBeyondDragSize())}doMouseUp(){this.isActive&&(this.standardMouseSelect(),this.standardMouseClick()||this.diagram.lastInput.isTouchEvent&&this.diagram.toolManager.doToolTip()),this.stopTool()}}class ActionTool extends Tool{wc;constructor(t){super(),this.name="Action",this.wc=null,t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram,i=t.lastInput,e=t.findObjectAt(i.documentPoint,s=>{for(;s.panel!==null;){if(s.isActionable)return s;s=s.panel}return s});return e!==null&&e.isActionable?(this.wc=e,t.cc=t.findObjectAt(i.documentPoint,null,null),!0):!1}doMouseDown(){if(!this.isActive)this.canStart()&&this.doActivate();else{const i=this.diagram.lastInput,e=this.wc;if(e===null)return;i.targetObject=e,e.actionDown!==null&&e.actionDown(i,e)}}doMouseMove(){if(this.isActive){const i=this.diagram.lastInput,e=this.wc;if(e===null)return;i.targetObject=e,e.actionMove!==null&&e.actionMove(i,e)}}doMouseUp(){if(this.isActive){const i=this.diagram.lastInput,e=this.wc;if(e===null)return;i.targetObject=e,e.actionUp!==null&&e.actionUp(i,e),this.standardMouseClick(s=>{for(;s.panel!==null;){if(s.isActionable&&s===e)return s;s=s.panel}return s},s=>s===e)}this.stopTool()}doCancel(){const i=this.diagram.lastInput,e=this.wc;e!==null&&(i.targetObject=e,e.actionCancel!==null&&e.actionCancel(i,e),this.stopTool())}doStop(){this.wc=null}}class ClickCreatingTool extends Tool{Ll;oM;pc;rM;constructor(t){super(),this.name="ClickCreating",this.Ll=null,this.oM=!0,this.pc=!1,this.rM=new Point(0,0),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled||this.archetypeNodeData===null)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.lastInput.left||this.isBeyondDragSize())return!1;if(this.isDoubleClick){if(t.lastInput.clickCount===1&&(this.rM=t.lastInput.viewPoint.copy()),t.lastInput.clickCount!==2||this.isBeyondDragSize(this.rM))return!1}else if(t.lastInput.clickCount!==1)return!1;return!(t.currentTool!==this&&t.findPartAt(t.lastInput.documentPoint,!0)!==null)}doMouseUp(){const t=this.diagram;this.isActive&&this.insertPart(t.lastInput.documentPoint),this.stopTool()}insertPart(t){const i=this.diagram,e=this.archetypeNodeData;if(e===null)return null;let s=null;try{if(i.v("ChangingSelection",i.selection),this.startTransaction(this.name),e instanceof Part)e.Pe()&&(e.li(),s=e.copy(),s!==null&&i.add(s));else if(e!==null){const n=i.model.copyNodeData(e);Util.wt(n)&&(i.model.addNodeData(n),s=i.findPartForData(n))}if(s!==null){const n=Point.X(t.x,t.y);this.isGridSnapEnabled&&this.diagram.lM(s,t,n),s.location=n,i.allowSelect&&(i.clearSelection(!0),s.isSelected=!0),Point.s(n)}i.invalidateDocumentBounds(),this.transactionResult=this.name,i.v("PartCreated",s)}finally{this.stopTransaction(),i.v("ChangedSelection",i.selection)}return s}get archetypeNodeData(){return this.Ll}set archetypeNodeData(t){t!==null&&Util.i(t,"object",ClickCreatingTool,"archetypeNodeData"),this.Ll=t}get isDoubleClick(){return this.oM}set isDoubleClick(t){Util.i(t,"boolean",ClickCreatingTool,"isDoubleClick"),this.oM=t}get isGridSnapEnabled(){return this.pc}set isGridSnapEnabled(t){Util.i(t,"boolean",ClickCreatingTool,"isGridSnapEnabled"),this.pc=t}}class DragSelectingTool extends Tool{Bh;hM;Al;constructor(t){super(),this.name="DragSelecting",this.Bh=175,this.hM=!1,this.Al=new Part({layerName:"Tool",selectable:!1}).add(new Shape("Rectangle",{name:"SHAPE",fill:null,stroke:"magenta"}).theme("stroke","dragSelect")).li(),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(!t.allowSelect)return!1;const i=t.lastInput;return!(!i.left||t.currentTool!==this&&(!this.isBeyondDragSize()||i.timestamp-t.firstInput.timestamp{const e=i.diagram;e!==null&&e.Si(root.document,"scroll",i.aM,!1),i.stopTool()},t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return!(!t.allowHorizontalScroll&&!t.allowVerticalScroll||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize())}doActivate(){const t=this.diagram;this.No?(t.lastInput.bubbles=!0,t.Vt(root.document,"scroll",this.aM,!1)):(t.currentCursor="move",t.isMouseCaptured=!0,this.Hw.a(t.position)),this.isActive=!0}doDeactivate(){const t=this.diagram;t.currentCursor="",t.isMouseCaptured=!1,this.isActive=!1}doCancel(){const t=this.diagram;t.position=this.Hw,t.isMouseCaptured=!1,this.stopTool()}doMouseMove(){this.HC()}doMouseUp(){this.HC(),this.stopTool()}HC(){const t=this.diagram;if(this.isActive&&t){if(this.No){t.lastInput.bubbles=!0;return}const i=t.position,e=t.firstInput.documentPoint,s=t.lastInput.documentPoint;let n=i.x+e.x-s.x,o=i.y+e.y-s.y;t.allowHorizontalScroll||(n=i.x),t.allowVerticalScroll||(o=i.y),t.position=this.jC.e(n,o)}}get bubbles(){return this.No}set bubbles(t){Util.i(t,"boolean",PanningTool,"bubbles"),this.No=t}get originalPosition(){return this.Hw}}class HTMLInfo{qw;Ww;cM;fM;constructor(t){this.qw=null,this.Ww=null,this.cM=null,this.fM=null,t&&Object.assign(this,t)}get mainElement(){return this.cM}set mainElement(t){this.cM=t}get show(){return this.qw}set show(t){this.qw!==t&&(t!==null&&Util.i(t,"function",HTMLInfo,"show"),this.qw=t)}get hide(){return this.Ww}set hide(t){this.Ww!==t&&(t!==null&&Util.i(t,"function",HTMLInfo,"hide"),this.Ww=t)}get valueFunction(){return this.fM}set valueFunction(t){this.fM=t}}class ContextMenuButtonInfo{hi;Sm;bc;constructor(t,i,e){this.hi=t,this.Sm=i,this.bc=e}}class ContextMenuTool extends Tool{uM;Jw;dM;gM;$w;Zw;Nm;constructor(t){super(),this.name="ContextMenu",this.uM=null,this.Jw=null,this.dM=null,this.gM=new Point,this.$w=null,this.Nm=!1;const i=this;this.Zw=()=>i.stopTool(),t&&Object.assign(this,t)}nF(){const t=new HTMLInfo;t.show=(r,l,h)=>h.showDefaultContextMenu(),t.hide=(r,l)=>l.hideDefaultContextMenu(),ContextMenuTool.ku=t;const i=this;this.Zw=()=>i.stopTool();const e=Util.en("div"),s=Util.en("div");e.style.cssText="top: 0px;z-index:10002;position: fixed;display: none;text-align: center;left: 25%;width: 50%;background-color: #F5F5F5;padding: 16px;border: 16px solid #444;border-radius: 10px;margin-top: 10px",s.style.cssText="z-index:10001;position: fixed;display: none;top: 0;left: 0;width: 100%;height: 100%;background-color: black;opacity: 0.8;";const n=Util.en("style");root.document.getElementsByTagName("head")[0].appendChild(n),n.sheet.insertRule(".goCXul { list-style: none; }",0),n.sheet.insertRule(".goCXli {font:700 1.5em Helvetica, Arial, sans-serif;position: relative;min-width: 60px; }",0),n.sheet.insertRule(".goCXa {color: #444;display: inline-block;padding: 4px;text-decoration: none;margin: 2px;border: 1px solid gray;border-radius: 10px; }",0);const o=this.diagram;o!==null&&(o.Vt(e,"contextmenu",ContextMenuTool.Kh,!1),o.Vt(e,"selectstart",ContextMenuTool.Kh,!1),o.Vt(s,"contextmenu",ContextMenuTool.Kh,!1)),e.className="goCXforeground",s.className="goCXbackground",root.document.body&&(root.document.body.appendChild(e),root.document.body.appendChild(s)),ContextMenuTool.Cm=e,ContextMenuTool.Lm=s,ContextMenuTool.mM=!0}static ku=null;static mM=!1;static Lm=null;static Cm=null;static Kh(t){return t.preventDefault(),!1}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return this.isBeyondDragSize()||!t.lastInput.right||t.lastInput.clickCount>1?!1:!!(t.lastInput.isTouchEvent&&this.defaultTouchContextMenu!==null||this.findObjectWithContextMenu()!==null)}doStart(){const t=this.diagram;this.gM.set(t.firstInput.documentPoint)}doStop(){this.hideContextMenu(),this.currentObject=null,this.Nm=!1}findObjectWithContextMenu(t){t===void 0&&(t=null);const i=this.diagram,e=i.lastInput;let s=null;if(t instanceof Diagram||(t instanceof GraphObject?s=t:s=i.findObjectAt(e.documentPoint,null,n=>!n.layer.isTemporary)),s!==null){let n=s;for(;n!==null;){if(n.contextMenu!==null)return n;n=n.panel}if(i.lastInput.isTouchEvent&&this.defaultTouchContextMenu)return s.part}else if(i.contextMenu!==null)return i;return null}doActivate(){}doMouseDown(){if(super.doMouseDown(),this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doMouseDown(),t.doDeactivate())}this.diagram.toolManager.mouseDownTools.has(this)&&this.doContextClick()}doMouseUp(){if(this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doCancel(),t.doDeactivate())}this.doContextClick()}doContextClick(){const t=this.diagram;if(!this.isActive)this.canStart()&&(this.openMenu(!0),this.isActive||this.stopTool());else{const i=this.currentContextMenu;if(i===null)return;let e=null;i instanceof HTMLInfo||(e=t.findObjectAt(t.lastInput.documentPoint,null,null),e!==null&&e.isContainedBy(i)&&this.standardMouseClick(null,null)),this.maybeStopTool(e)}}maybeStopTool(t){this.stopTool(),this.canStart()&&(this.diagram.currentTool=this,this.doMouseUp())}openMenu(t,i){if(i===void 0&&(i=null),this.Nm)return;this.Nm=!0,t&&this.standardMouseSelect();const e=this.standardMouseClick();if(this.Nm=!1,!e){this.isActive=!0;const s=ContextMenuTool.ku;if(i===null&&(i=this.findObjectWithContextMenu()),i!==null){const n=i.contextMenu;n!==null?(this.currentObject=i instanceof GraphObject?i:null,this.showContextMenu(n,this.currentObject)):s!==null&&this.showContextMenu(s,this.currentObject)}else s!==null&&this.showContextMenu(s,null);this.currentContextMenu instanceof Adornment&&!this.currentContextMenu.visible&&this.stopTool()}}doMouseMove(){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.doMouseMove(),this.isActive&&this.diagram.toolManager.doMouseMove()}showContextMenu(t,i){const e=this.diagram;if(t!==this.currentContextMenu&&this.hideContextMenu(),t instanceof Adornment){const s=t;s.layerName="Tool",s.selectable=!1,s.scale=1/e.scale,s.category=this.name,s.hasPlaceholder()&&(s.placeholder.scale=e.scale);const n=s.diagram;n!==null&&n!==e&&n.remove(s),e.add(s),i!==null?s.adornedObject=i:s.data=e.model,s.ensureBounds(),this.positionContextMenu(s,i)}else t instanceof HTMLInfo&&t.show(i,e,this);this.currentContextMenu=t}positionContextMenu(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom&&(n.y-=o.height+5/s.scale),n.ye.commandHandler.copySelection(),e=>e.commandHandler.canCopySelection())),i.add(new ContextMenuButtonInfo("Cut",e=>e.commandHandler.cutSelection(),e=>e.commandHandler.canCutSelection())),i.add(new ContextMenuButtonInfo("Delete",e=>e.commandHandler.deleteSelection(),e=>e.commandHandler.canDeleteSelection())),i.add(new ContextMenuButtonInfo("Paste",e=>e.commandHandler.pasteSelection(t.mouseDownPoint),e=>e.commandHandler.canPasteSelection(t.mouseDownPoint))),i.add(new ContextMenuButtonInfo("Select All",e=>e.commandHandler.selectAll(),e=>e.commandHandler.canSelectAll())),i.add(new ContextMenuButtonInfo("Undo",e=>e.commandHandler.undo(),e=>e.commandHandler.canUndo())),i.add(new ContextMenuButtonInfo("Redo",e=>e.commandHandler.redo(),e=>e.commandHandler.canRedo())),i.add(new ContextMenuButtonInfo("Scroll To Part",e=>e.commandHandler.scrollToPart(),e=>e.commandHandler.canScrollToPart())),i.add(new ContextMenuButtonInfo("Zoom To Fit",e=>e.commandHandler.zoomToFit(),e=>e.commandHandler.canZoomToFit())),i.add(new ContextMenuButtonInfo("Reset Zoom",e=>e.commandHandler.resetZoom(),e=>e.commandHandler.canResetZoom())),i.add(new ContextMenuButtonInfo("Group Selection",e=>e.commandHandler.groupSelection(),e=>e.commandHandler.canGroupSelection())),i.add(new ContextMenuButtonInfo("Ungroup Selection",e=>e.commandHandler.ungroupSelection(),e=>e.commandHandler.canUngroupSelection())),i.add(new ContextMenuButtonInfo("Edit Text",e=>e.commandHandler.editTextBlock(),e=>e.commandHandler.canEditTextBlock())),i}showDefaultContextMenu(){const t=this.diagram;this.$w===null&&(this.$w=this.oF()),ContextMenuTool.Cm.innerHTML="",ContextMenuTool.Lm.addEventListener("pointerdown",this.Zw,!1);const i=this,e=Util.en("ul");e.className="goCXul",ContextMenuTool.Cm.appendChild(e),e.innerHTML="";const s=this.$w.iterator;for(;s.next();){const n=s.value,o=n.Sm,r=n.bc;if(typeof o!="function"||typeof r=="function"&&!r(t))continue;const l=Util.en("li");l.className="goCXli";const h=Util.en("a");h.className="goCXa",h.href="#",h.Sm=n.Sm,h.addEventListener("pointerdown",function(a){return this.Sm(t),i.stopTool(),a.preventDefault(),!1},!1),h.textContent=n.hi,l.appendChild(h),e.appendChild(l)}ContextMenuTool.Cm.style.display="block",ContextMenuTool.Lm.style.display="block"}hideDefaultContextMenu(){if(this.currentContextMenu===null||this.currentContextMenu!==ContextMenuTool.ku)return;ContextMenuTool.Cm.style.display="none",ContextMenuTool.Lm.style.display="none";const t=this.diagram;t!==null&&t.Si(ContextMenuTool.Lm,"pointerdown",this.Zw,!1),this.currentContextMenu=null}get currentContextMenu(){return this.uM}set currentContextMenu(t){this.uM=t,this.Jw=t instanceof Adornment?t.adornedPart:null}get defaultTouchContextMenu(){return ContextMenuTool.mM===!1&&ContextMenuTool.ku===null&&Diagram.isUsingDOM()&&this.nF(),ContextMenuTool.ku}set defaultTouchContextMenu(t){t===null&&(ContextMenuTool.mM=!0),ContextMenuTool.ku=t}get currentObject(){return this.dM}set currentObject(t){this.dM=t}get mouseDownPoint(){return this.gM}}var TextEditingAccept=(w=>(w[w.LostFocus=1]="LostFocus",w[w.MouseDown=2]="MouseDown",w[w.Tab=3]="Tab",w[w.Enter=4]="Enter",w))(TextEditingAccept||{}),TextEditingStarting=(w=>(w[w.SingleClick=1]="SingleClick",w[w.SingleClickSelected=2]="SingleClickSelected",w[w.DoubleClick=3]="DoubleClick",w))(TextEditingStarting||{}),TextEditingState=(w=>(w[w.None=1]="None",w[w.Active=2]="Active",w[w.Editing=3]="Editing",w[w.Validating=4]="Validating",w[w.Invalid=5]="Invalid",w[w.Validated=6]="Validated",w))(TextEditingState||{});class TextEditingTool extends Tool{Me;pM;yM;Tl;Yt;wM;xM;bM;Qw;_w;constructor(t){super(),this.name="TextEditing",this.Me=new TextBlock,this.pM=null,this.yM=2,this.Tl=null,this.Yt=1,this.wM=1,this.xM=!0,this.bM=null,this.Qw=new HTMLInfo,this._w=null,this.rF(this.Qw),t&&Object.assign(this,t)}static LostFocus=1;static MouseDown=2;static Tab=3;static Enter=4;static SingleClick=1;static SingleClickSelected=2;static DoubleClick=3;static StateNone=1;static StateActive=2;static StateEditing=3;static StateValidating=4;static StateInvalid=5;static StateValidated=6;rF(t){if(!Diagram.isUsingDOM())return;const i=Util.en("textarea");this._w=i;const e=this;i.addEventListener("input",function(s){if(e.textBlock===null)return;const n=e.measureTemporaryTextBlock(this.value),o=this.textScale;this.style.width=20+Math.max(e.textBlock.measuredBounds.width,n.measuredBounds.width)*o+"px",this.rows=Math.max(e.textBlock.lineCount,n.lineCount)},!1),i.addEventListener("keydown",function(s){if(s.isComposing||e.textBlock===null)return;const n=s.key;if(n==="Enter"){e.textBlock.isMultiline===!1&&s.preventDefault(),e.acceptText(4);return}else if(n==="Tab"){e.acceptText(3),s.preventDefault();return}else n==="Escape"&&(e.doCancel(),e.diagram!==null&&e.diagram.doFocus())},!1),i.addEventListener("focus",function(s){e.lF(s)},!1),i.addEventListener("blur",function(s){e.hF(s)},!1),t.valueFunction=()=>i.value,t.mainElement=i,t.show=(s,n,o)=>{if(!(s instanceof TextBlock&&o instanceof TextEditingTool))return;if(o.state===5){i.style.border="3px solid red",i.focus();return}const r=s.getDocumentPoint(Spot.Center),l=n.position,h=n.scale;let a=s.getDocumentScale()*h;a{s.div.removeChild(i)}}get textBlock(){return this.pM}set textBlock(t){this.pM=t}get currentTextEditor(){return this.bM}set currentTextEditor(t){this.bM=t}get defaultTextEditor(){return this.Qw}set defaultTextEditor(t){this.Qw=t}get starting(){return this.yM}set starting(t){this.yM=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t===null||t.isReadOnly||TextEditingTool.kc&&TextEditingTool.kc!==this&&(TextEditingTool.kc.acceptText(2),TextEditingTool.kc&&TextEditingTool.kc!==this)||!t.lastInput.left||this.isBeyondDragSize())return!1;const i=t.lastInput.documentPoint,e=t.findObjectAt(i);if(e===null||!(e instanceof TextBlock)||!e.editable||!e.part.canEdit())return!1;const s=e.part;return!(s===null||this.starting===2&&!s.isSelected||this.starting===3&&t.lastInput.clickCount<2)}doStart(){TextEditingTool.kc=this,this.textBlock!==null&&this.doActivate()}doActivate(){if(this.isActive)return;const t=this.diagram;if(t===null)return;let i=this.textBlock;if(i===null&&(i=t.findObjectAt(t.lastInput.documentPoint)),i===null||!(i instanceof TextBlock)||(this.textBlock=i,i.part===null))return;t.animationManager.stopAnimation(),this.isActive=!0,this.Yt=2;let s=this.defaultTextEditor;i.textEditor!==null&&(s=i.textEditor),this.Me=this.textBlock.copy();const n=new Rect(this.textBlock.getDocumentPoint(Spot.TopLeft),this.textBlock.getDocumentPoint(Spot.BottomRight));t.scrollToRect(n),s.show(i,t,this),this.currentTextEditor=s}doCancel(){this.stopTool()}doMouseUp(){this.canStart()&&this.doActivate()}doMouseDown(){this.isActive&&this.acceptText(2)}acceptText(t){switch(t){case 2:this.Yt===6?this.currentTextEditor instanceof HTMLElement&&this.currentTextEditor.focus():(this.Yt===2||this.Yt===5||this.Yt===3)&&(this.Yt=4,this.qC());break;case 1:case 4:case 3:if(t===4&&this.textBlock.isMultiline===!0)return;(this.Yt===2||this.Yt===5||this.Yt===3)&&(this.Yt=4,this.qC());break}}qC(){const t=this.textBlock,i=this.diagram,e=this.currentTextEditor;if(t!==null&&e!==null){const s=t.text;let n="";if(e.valueFunction!==null&&(n=e.valueFunction()),!this.isValidText(t,s,n)){this.Yt=5,this.doError(s,n);return}this.startTransaction(this.name),this.Yt=6,this.transactionResult=this.name,t.text=n,this.doSuccess(s,n),i!==null&&i.v("TextEdited",t,s),this.stopTransaction(),this.stopTool(),i!==null&&i.doFocus()}}doError(t,i){const e=this.textBlock;e.errorFunction!==null&&e.errorFunction(this,t,i);const s=this.currentTextEditor;s&&s.show(e,this.diagram,this)}doSuccess(t,i){const e=this.textBlock;e.textEdited!==null&&e.textEdited(e,t,i)}doDeactivate(){const t=this.diagram;t!==null&&(this.Yt=1,this.currentTextEditor!==null&&this.currentTextEditor.hide(t,this),this.textBlock=null,this.isActive=!1)}doStop(){TextEditingTool.kc=null}lF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this._w;this.Yt===2&&(this.Yt=3),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}hF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this._w;typeof i.focus=="function"&&i.focus(),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}isValidText(t,i,e){const s=this.textValidation;if(s!==null&&!s(t,i,e))return!1;const n=t.textValidation;return!(n!==null&&!n(t,i,e))}get textValidation(){return this.Tl}set textValidation(t){t!==null&&Util.i(t,"function",TextEditingTool,"textValidation"),this.Tl=t}get minimumEditorScale(){return this.wM}set minimumEditorScale(t){t!==null&&Util.i(t,"number",TextEditingTool,"minimumEditorScale"),this.wM=t}get selectsTextOnActivate(){return this.xM}set selectsTextOnActivate(t){t!==null&&Util.i(t,"boolean",TextEditingTool,"selectsTextOnActivate"),this.xM=t}get state(){return this.Yt}set state(t){this.Yt!==t&&(this.Yt=t)}measureTemporaryTextBlock(t){const i=this.Me;return i.text=t,i.ut(this.textBlock.Dl,1/0),i}static kc=null}var AnimationStyle=(w=>(w[w.Default=1]="Default",w[w.AnimateLocations=2]="AnimateLocations",w[w.None=3]="None",w))(AnimationStyle||{});class AnimationManager{p;Ni;Oi;kr;Gn;Ao;kM;PM;Am;wi;Pc;un;Tm;Yh;tx;Dm;ix;Mc;xu;Fm;constructor(t){this.p=Diagram.pm(),this.Ni=!1,this.Am=!1,this.wi=!1,this.Pc=!1,this.ix=!0,this.Mc=1,this.xu=!1,this.Oi=!0,this.kr=!0,this.Ao=600,this.kM=!1,this.PM=!1,this.Gn=new GSet,this.un=new Animation,this.Tm=new Animation,this.un.ds=this,this.Yh=new GSet,this.tx=new GSet,this.Dm=new GSet,this.Fm=new GSet,t&&Object.assign(this,t)}To(t){this.p=t}lE(){return this.p}canStart(t){return!0}Fl(t){return!this.Oi||!this.canStart(t)?!1:(this.Gn.add(t),this.defaultAnimation.isAnimating&&this.stopAnimation(),this.p.Ci(),this.wi=!0,!0)}getBundleAnimation(){return this.Tm}MM(){if(!this.Oi||(this.Tm.ae.count>0&&this.Tm.start(),!this.wi))return;const t=this.un,i=this.p,e=this.Gn.has("Model");if(e&&(this.Pc=!0,this.Mc===1?(t.isViewportUnconstrained=!0,t.ae.clear(),t.add(i,"position",i.position.copy().offset(0,-200),i.position),t.add(i,"opacity",0,1)):this.Mc===3&&t.ae.clear(),this.Mc===2&&i.ex.equals(i.ct)?this.ix=!0:this.ix=!1,i.v("InitialAnimationStarting",this)),e&&!this.kr||t.ae.count===0){this.Gn.clear(),this.wi=!1,t.ae.clear(),t.sx(i),this.Pc=!1,i.C();return}this.Gn.clear(),i.Pr=!1;const s=t.ae.get(i);i.autoScale!==1&&s!==null&&(delete s.ei.scale,delete s.gs.scale);const n=this;root.requestAnimationFrame(()=>{n.wi===!1||t.Ni||(i.getRenderingHint("temporaryPixelRatio")&&i.Bw(),i.SM(),n.wi=!1,t.start(),t.Ni&&(n.Pu(),i.invalidateDocumentBounds(),t.WC(0),i.yr(!0),n.Mu(),i.v("AnimationStarting",n)))})}NM(){return this.Gn.has("Trigger")&&this.Gn.count===1}JC(t,i,e,s){this.isTicking||this.NM()||t instanceof Link&&(t.fromNode!==null||t.toNode!==null)||this.un.add(t,"position",i,e,s)}nx(t){return this.un.nx(t)}CM(t){return this.un.CM(t)}aF(t){const i=this.Yh,e=this;function s(){if(e.Dm.count>0&&(i.addAll(e.Dm),e.Dm.clear(),e.Ni=!0),e.Ni===!1||i.count===0)return;e.tx.addAll(i);const n=e.tx.iterator;for(;n.next();){const o=n.value;o.Ni!==!1&&(o.cF()?o.$C(!1):o.Sc=!0)}if(e.tx.clear(),e.Ni===!1){root.requestAnimationFrame(s);return}e.Pu(),e.p.yr(),e.Mu(),root.requestAnimationFrame(s)}this.Ni?this.fF(t):(this.Ni=!0,i.add(t),root.requestAnimationFrame(()=>s()))}fF(t){this.Dm.add(t)}uF(){const t=this.Yh.iterator;for(;t.next();)t.value.Sc=!1}Pu(){if(this.Am)return;const t=this.p;this.kM=t.skipsUndoManager,this.PM=t.ce,t.skipsUndoManager=!0,t.ce=!0,this.Am=!0}Mu(){const t=this.p;t.skipsUndoManager=this.kM,t.ce=this.PM,this.Am=!1}stopAnimation(t){const i=this.un;if(this.wi===!0&&(this.wi=!1,this.Pc=!1,this.Gn.clear(),i.dF()&&this.p.requestUpdate()),!this.Ni){i.ae.clear(),i.sx(this.p);return}if(i.Su(!0),i.sx(null),t===!0){const e=this.Yh.toArray();for(let s=0;s{!i.isAnimating&&i.runCount===1/0&&i.start()})}get duration(){return this.Ao}set duration(t){Util.i(t,"number",AnimationManager,"duration"),t<1&&Util._(t,">= 1",AnimationManager,"duration"),this.Ao=t}get isAnimating(){return this.Ni}get isTicking(){return this.Am}get isInitial(){return this.kr}set isInitial(t){Util.i(t,"boolean",AnimationManager,"isInitial"),this.kr=t}get defaultAnimation(){return this.un}get activeAnimations(){return this.Yh}get initialAnimationStyle(){return this.Mc}set initialAnimationStyle(t){this.Mc=t}static ox=new GMap;static defineAnimationEffect(t,i){AnimationManager.ox.set(t,i)}static TM(t,i,e,s,n){t===null&&(t=[0,0,0,0]),i===null&&(i=[0,0,0,0]);let o=t[0],r=t[1];const l=t[2],h=t[3];let a=i[0],c=i[1];const f=i[2],u=i[3];l===0||l===100?(o=a,r=c):(f===0||f===100)&&(a=o,c=r),Math.abs(a-o)>180&&(a>o?o+=360:a+=360);const d=n(e,o,a-o,s)%360,m=n(e,r,c-r,s),g=n(e,l,f-l,s),p=n(e,h,u-h,s);return"hsla("+d+", "+m+"%, "+g+"%, "+p+")"}static{const t=AnimationManager.ox,i=(e,s,n,o,r,l)=>{e.position=new Point(o(r,s.x,n.x-s.x,l),o(r,s.y,n.y-s.y,l))};t.set("position:diagram",i),t.set("position",i),t.set("position:part",(e,s,n,o,r,l)=>{r{r{r{const h=e.actualBounds,a=n.actualBounds,c=a.x+a.width/2-h.width/2,f=a.y+a.height/2-h.height/2;r{e.desiredSize=new Size(o(r,s.width,n.width-s.width,l),o(r,s.height,n.height-s.height,l))}),t.set("width",(e,s,n,o,r,l)=>{e.width=o(r,s,n-s,l)}),t.set("height",(e,s,n,o,r,l)=>{e.height=o(r,s,n-s,l)}),t.set("fill",(e,s,n,o,r,l)=>{e.fill=AnimationManager.TM(s,n,r,l,o)}),t.set("stroke",(e,s,n,o,r,l)=>{e.stroke=AnimationManager.TM(s,n,r,l,o)}),t.set("strokeWidth",(e,s,n,o,r,l)=>{e.strokeWidth=o(r,s,n-s,l)}),t.set("strokeDashOffset",(e,s,n,o,r,l)=>{e.strokeDashOffset=o(r,s,n-s,l)}),t.set("background",(e,s,n,o,r,l)=>{e.background=AnimationManager.TM(s,n,r,l,o)}),t.set("opacity",(e,s,n,o,r,l)=>{e.opacity=o(r,s,n-s,l)}),t.set("scale",(e,s,n,o,r,l)=>{e.scale=o(r,s,n-s,l)}),t.set("angle",(e,s,n,o,r,l)=>{e.angle=o(r,s,n-s,l)})}static Default=1;static AnimateLocations=2;static None=3}class Animation{rx;Rm;Ni;Nu;Ao;ms;tL;Lc;ae;lx;ei;jn;Cu;Ac;hx;ax;Sc;DM;cx;ds;p;FM;RM;vM;constructor(t){this.p=null,this.ds=null,this.DM=null,this.cx=null,this.FM=!1,this.Ni=!1,this.Sc=!1,this.ei=0,this.jn=0,this.rx=Animation.EaseInOutQuad,this.Rm=Animation.EaseInOutQuad,this.Cu=!1,this.Ac=!1,this.hx=1,this.ax=0,this.Ao=NaN,this.ms=NaN,this.RM=0,this.Nu=null,this.tL=Point.Po,this.ae=new GMap,this.lx=new GMap,this.Lc=new GSet,this.vM=1,t&&Object.assign(this,t)}suspend(){this.Sc=!0}advanceTo(t,i){i&&(this.Sc=!1),this.Cu&&t>=this.ms&&(this.Ac=!0,t=t-this.ms),this.RM=t,this.$C(!0),this.ds.Pu(),this.p.yr(),this.ds.Mu(),this.p.redraw()}sx(t){if(this.lx.clear(),this.Ac=!1,this.ax=0,this.ms=NaN,this.Lc.count>0&&this.Lc.clear(),t!==null){const i=t.links;for(;i.next();)i.value.Mr=null}}dF(){return this.ae.count>0}start(){if(this.ae.count===0)return this;if(this.Ni)return this;let t=this.p;const i=this.ae.iterator;for(;i.next();){const s=i.key;t===null&&(s instanceof Diagram?t=s:s instanceof GraphObject&&(t=s.diagram))}if(t!==null)this.p=t,this.ds=t.animationManager;else return this;const e=this.ds;return e.isEnabled===!1?this:(this.ms=isNaN(this.Ao)?e.duration:this.Ao,this.Rm=this.rx,e.Pc&&e.Mc===1&&this===e.defaultAnimation&&(this.Rm=Animation.EaseOutExpo,this.ms=isNaN(this.Ao)?e.duration===600?900:e.duration:this.Ao),this.vM=t.scrollMode,this.isViewportUnconstrained&&(t.Gh=2),e.Pu(),this.Lc.each(s=>{s.data=null,t.add(s)}),e.Mu(),this.Ni=!0,this.ei=+new Date,this.jn=this.ei+this.ms,e.aF(this),this)}addTemporaryPart(t,i){return t.Pe()?(this.Lc.add(t),this.p=i,this):this}add(t,i,e,s,n){if(this.p===null&&(t instanceof Diagram?this.p=t:t instanceof GraphObject&&t.diagram!==null&&(this.p=t.diagram)),t instanceof Part){if(!t.isAnimated)return this;i==="position"&&(i="position:part")}return this.LM(t,i,e,s,n),this}LM(t,i,e,s,n){const o=this.ae;let r,l,h;if(t instanceof Diagram&&i==="position"&&(i="position:diagram"),(i==="fill"||i==="stroke"||i==="background")&&(Brush.Do(e),Brush.OM(),e=[Brush.Ii.n0,Brush.Ii.n1,Brush.Ii.n2,Brush.Ii.n3],Brush.Do(s),Brush.OM(),s=[Brush.Ii.n0,Brush.Ii.n1,Brush.Ii.n2,Brush.Ii.n3]),o.has(t))r=o.get(t),l=r.ei,h=r.gs,l[i]===void 0&&(l[i]=this.Lu(e)),h[i]=this.Lu(s);else{if(i==="position"&&e.equalsApprox(s))return;l={},h={},l[i]=this.Lu(e),h[i]=this.Lu(s),r=new AnimationState(l,h,n),o.set(t,r)}const a=l[i];a instanceof Point&&!a.isReal()&&a.a(this.tL),n&&i.indexOf("position:")===0&&t instanceof Part?r.fx.location=this.Lu(t.location):n&&(r.fx[i]=this.Lu(e))}Lu(t){return t instanceof Point||t instanceof Size?t.copy():t}gF(t){const i=this.ae;if(i.has(t)){const e=i.get(t);e.ux=!0}}nx(t){if(!this.Ni)return!1;const i=this.ae.get(t);return i!==null&&i.ux}CM(t){if(!this.Ni)return!1;const i=this.ae.get(t);return i!==null&&!!(i.ei.position||i.ei["position:part"]||i.ei.location)}cF(){if(this.Lc.count>0)return!0;const t=this.ae.iterator;for(;t.next();){const i=t.key;if(i instanceof GraphObject&&i.diagram!==null||i instanceof Diagram)return!0}return!1}$C(t){if(this.Sc&&!t)return;const i=this.ds;if(this.Ni===!1)return;const e=+new Date;let s=e>this.jn?this.ms:e-this.ei;t&&(s=this.RM,sthis.jn&&(this.Cu&&!this.Ac?(this.ei=+new Date,this.jn=this.ei+this.ms,this.Ac=!0):this.Su(!1))}WC(t){const i=this.ms,e=this.ae.iterator,s=this.Ac;for(;e.next();){const n=e.key;if(n instanceof GraphObject&&n.diagram===null)continue;const o=e.value,r=s?o.gs:o.ei,l=s?o.ei:o.gs,h=AnimationManager.ox;for(const a in l)a==="position"&&(l["position:placeholder"]||l["position:nodeCollapse"])||h.get(a)!==null&&h.get(a)(n,r[a],l[a],this.Rm,t,i,this)}}stop(){return this.Ni?(this.Su(!0),this):this}Su(t){if(this.cx!==null&&this.cx.mF(this.DM),!this.Ni)return;const i=this.p,e=this.ds;e.Pc=!1,this.Ni=!1,this.Sc=!1,e.Pu();const s=this.ae,n=this.Lc.iterator;for(;n.next();)i.remove(n.value);const o=this.Cu,r=s.iterator,l=AnimationManager.ox;for(;r.next();){const a=r.key,c=r.value,f=o?c.gs:c.ei,u=o?c.ei:c.gs,d=c.fx;for(const m in u)if(l.get(m)!==null){let g=m;c.gx&&(g==="position:nodeCollapse"||g==="position:placeholder")&&(g="position"),l.get(g)(a,f[m],d[m]!==void 0?d[m]:c.gx?f[m]:u[m],this.Rm,this.ms,this.ms,this)}c.gx&&d.location!==void 0&&a instanceof Part&&(a.location=d.location),c.ux&&a instanceof Part&&a.Ei(!1)}this.ax++;const h=!t&&this.hx>this.ax;if(!h&&(this===e.Tm||this===e.defaultAnimation)&&this.ae.clear(),i.mx.clear(),i.yP(!1),i.invalidateDocumentBounds(),i.C(),i.yr(!0),e.defaultAnimation===this){const a=e.Fm.iterator;for(;a.next();)a.value.pF();e.Fm.clear()}if(i.yr(!0),this.isViewportUnconstrained&&(i.scrollMode=this.vM),e.Mu(),h){this.Ac=!1,this.start();return}this.sx(null),e.Su(this),this.Nu&&this.Nu(this),i.requestUpdate()}Nc(t,i){const e=i.actualBounds;let s=null;if(i instanceof Group&&(s=i.placeholder),s!==null&&s.visible){const n=s.getDocumentPoint(Spot.TopLeft),o=s.padding;n.x+=o.left,n.y+=o.top,this.add(t,"position",n,t.position,!1)}else this.add(t,"position",new Point(e.x+e.width/2,e.y+e.height/2),t.position,!1);this.add(t,"scale",.01,t.scale,!1),t instanceof Group&&this.yF(t,i)}yF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Nc(s,i)}}Cc(t,i){if(!t.isVisible())return;let e=null;if(i instanceof Group&&(e=i.placeholder),e!==null&&e.visible){const s=e.getDocumentPoint(Spot.TopLeft),n=e.padding;s.x+=n.left,s.y+=n.top,this.add(t,"position:placeholder",t.position,s,!0)}else this.add(t,"position:nodeCollapse",t.position,i,!0);this.add(t,"scale",t.scale,.01,!0),this.gF(t),t instanceof Group&&this.wF(t,i)}wF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Cc(s,i)}}get duration(){return this.Ao}set duration(t){Util.i(t,"number",Animation,"duration"),t<1&&Util._(t,">= 1",Animation,"duration"),this.Ao=t}get reversible(){return this.Cu}set reversible(t){this.Cu=t}get runCount(){return this.hx}set runCount(t){t>0?this.hx=t:Util.o("Animation.runCount value must be a positive integer.")}get finished(){return this.Nu}set finished(t){this.Nu!==t&&(t!==null&&Util.i(t,"function",Animation,"finished"),this.Nu=t)}get easing(){return this.rx}set easing(t){this.rx=t}get isViewportUnconstrained(){return this.FM}set isViewportUnconstrained(t){this.FM=t}get isAnimating(){return this.Ni}getTemporaryState(t){let i=this.lx.get(t);return i===null&&(i={},this.lx.set(t,i)),i}static EaseLinear=(t,i,e,s)=>e*t/s+i;static EaseInOutQuad=(t,i,e,s)=>(t/=s/2,t<1?e/2*t*t+i:-e/2*(--t*(t-2)-1)+i);static EaseInQuad=(t,i,e,s)=>e*(t/=s)*t+i;static EaseOutQuad=(t,i,e,s)=>-e*(t/=s)*(t-2)+i;static EaseInExpo=(t,i,e,s)=>t===0?i:e*Math.pow(2,10*(t/s-1))+i;static EaseOutExpo=(t,i,e,s)=>t===s?i+e:e*(-Math.pow(2,-10*t/s)+1)+i}class AnimationState{ei;gs;fx;gx;ux;constructor(t,i,e){this.ei=t,this.gs=i,this.fx={},this.gx=e,this.ux=!1}}var TriggerStart=(w=>(w[w.Default=1]="Default",w[w.Immediate=2]="Immediate",w[w.Bundled=3]="Bundled",w))(TriggerStart||{});class AnimationTrigger{ke;an;Au;Tc;constructor(t,i,e){this.ke=null,this.an=t,this.Au=e||1,this.Tc=null,i!==void 0&&(this.Tc=i,e===void 0&&(this.Au=2))}copy(){const t=new AnimationTrigger(this.an);t.Au=this.Au;const i=this.Tc;if(i!==null){const e={};i.duration!==void 0&&(e.duration=i.duration),i.finished!==void 0&&(e.finished=i.finished),i.easing!==void 0&&(e.easing=i.easing),t.Tc=e}return t}get propertyName(){return this.an}set propertyName(t){this.an=t}get animationSettings(){return this.Tc}set animationSettings(t){this.Tc=t}xF(t){const i=this.Tc;i!==null&&(i.duration&&(t.duration=i.duration),i.finished&&(t.finished=i.finished),i.easing&&(t.easing=i.easing))}get startCondition(){return this.Au}set startCondition(t){this.Au=t}static Default=1;static Immediate=2;static Bundled=3}class Layer{p;St;Wt;Sr;Rl;vl;Ol;Il;El;Ul;Bl;Vl;zl;Xl;Kl;Yl;bc;Gl;px;vm;Tu;At;constructor(t){GSet.Yi(this),this.p=null,this.At=new List,this.St="",this.Wt=1,this.Sr=!1,this.Rl=!0,this.vl=!0,this.Ol=!0,this.Il=!0,this.El=!0,this.Ul=!0,this.Bl=!0,this.Vl=!0,this.zl=!0,this.Xl=!0,this.Kl=!0,this.Yl=!0,this.bc=!0,this.Gl=!0,this.px=!0,this.vm=!1,this.Tu=[],t&&Object.assign(this,t)}bF(){const t=this.At;for(let i=0;i0&&(h+=e+" Parts "),s>0&&(h+=s+" Nodes "),n>0&&(h+=n+" Groups "),o>0&&(h+=o+" Links "),r>0&&(h+=r+" Adornments "),t>1){const a=this.At.iterator;for(;a.next();){const c=a.value;h+=` - `+c.toString();const f=c.data;f!==null&&GSet.as(f)&&(h+=" #"+GSet.as(f)),c instanceof Node?h+=" "+Util.toString(f):c instanceof Link&&(h+=" "+Util.toString(c.fromNode)+" "+Util.toString(c.toNode))}}return i+" "+this.At.count+": "+h}findObjectAt(t,i,e){if(i===void 0&&(i=null),e===void 0&&(e=null),this.Gl===!1)return null;let s=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(s=!0);const n=Point.l(),o=this.At.r,r=o.length;for(let l=r;l--;){const h=o[l];if(s===!0&&h.Nl()===!1||!h.isVisible())continue;n.a(t),n.Ie(h.Es);let a=h.iL(n,i,e);if(a!==null&&(i!==null&&(a=i(a)),a!==null&&(e===null||e(a))))return Point.s(n),a}return Point.s(n),null}findObjectsAt(t,i,e,s){if(i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Gl===!1)return s;let n=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(n=!0);const o=Point.l(),r=this.At.r,l=r.length;for(let h=l;h--;){const a=r[h];if(n===!0&&a.Nl()===!1||!a.isVisible())continue;o.a(t),o.Ie(a.Es);let c=a;a.eL(o,i,e,s)&&(i!==null&&(c=i(c)),c!==null&&(e===null||e(c))&&s.add(c))}return Point.s(o),s}findObjectsIn(t,i,e,s,n){if(i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Gl===!1)return n;let o=!1;this.diagram!==null&&this.diagram.viewportBounds.containsRect(t)&&(o=!0);const r=this.At.r,l=r.length;for(let h=l;h--;){const a=r[h];if(o===!0&&a.Nl()===!1||!a.isVisible())continue;let c=a;a.Om(t,i,e,s,n)&&(i!==null&&(c=i(c)),c!==null&&(e===null||e(c))&&n.add(c))}return n}NP(t,i,e,s,n,o,r){if(this.Gl===!1)return n;const l=this.At.r,h=l.length;for(let a=h;a--;){const c=l[a];if(r===!0&&c.Nl()===!1||!o(c)||!c.isVisible())continue;let f=c;c.Om(t,i,e,s,n)&&(i!==null&&(f=i(f)),f!==null&&(e===null||e(f))&&n.add(f))}return n}findObjectsNear(t,i,e,s,n,o){if(e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Gl===!1)return o;let r=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(r=!0);const l=Point.l(),h=Point.l(),a=this.At.r,c=a.length;for(let f=c;f--;){const u=a[f];if(r===!0&&u.Nl()===!1||!u.isVisible())continue;l.a(t),l.Ie(u.Es),h.e(t.x+i,t.y),h.Ie(u.Es);let d=u;u.sL(l,h,e,s,n,o)&&(e!==null&&(d=e(d)),d!==null&&(s===null||s(d))&&o.add(d))}return Point.s(l),Point.s(h),o}EM(){return this.At.r}Us(t,i){if(!this.visible)return;const e=this.At.r,s=e.length;if(s===0)return;const n=Util.ot(),o=Util.ot();for(let r=0;r0&&o.push(l))}for(let r=0;re.Em||a.height*n>e.Em?i.Gi(t,e):this.SF(t,i),c&&(t.restore(),t.clearContextCache(!0))}SF(t,i){const e=i.actualBounds,s=i.naturalBounds;if(e.width===0||e.height===0||isNaN(e.x)||isNaN(e.y)||!i.isVisible())return;const n=i.D;if(i.background===null){i.dn(t,"rgba(0,0,0,0.3)",!0,!1,s,e),t.fillRect(e.x,e.y,e.width,e.height);return}if(t.transform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),i.dn(t,i.background,!0,!1,s,e),t.fillRect(0,0,s.width/2,s.height/2),!n.Ok()){const o=1/(n.m11*n.m22-n.m12*n.m21);t.transform(n.m22*o,-n.m12*o,-n.m21*o,n.m11*o,o*(n.m21*n.dy-n.m22*n.dx),o*(n.m12*n.dx-n.m11*n.dy))}}MF(t,i,e,s){const n=2/s,o=4/s;for(let r=0;r=s.count)t=s.count;else if(s.elt(t)===i)return-1;s.insertAt(t,i),i.Um(e);const n=this.diagram;return n!==null&&(e?n.C():n.Hh(i)),this.yx(t,i),t}_i(t,i,e){if(!e&&i.layer!==this&&i.layer!==null)return i.layer._i(t,i,e);const s=this.At;if(t<0||t>=s.length){if(t=s.indexOf(i),t<0)return-1}else if(s.elt(t)!==i&&(t=s.indexOf(i),t<0))return-1;i.Bm(e),s.removeAt(t);const n=this.diagram;return n!==null&&(e?n.C():n._i(i)),i.IM(null),t}yx(t,i){t=this.NF(t,i),i instanceof Group&&this.CF(t,i),i.svg!==null&&i.svg.remove()}NF(t,i){const e=i.zOrder;if(isNaN(e))return t;const s=this.At,n=s.count;if(n<=1)return t;if(t<0&&(t=s.indexOf(i)),t<0)return-1;let o=t-1,r=NaN;for(;o>=0&&(r=s.elt(o).zOrder,!!isNaN(r));)o--;let l=t+1,h=NaN;for(;le)for(;;){if(o===-1||r<=e)return o++,o===t?t:(s.removeAt(t),s.insertAt(o,i),o);for(r=NaN;--o>=0&&(r=s.elt(o).zOrder,!!isNaN(r)););}else if(!isNaN(h)&&h=e)return l--,l===t?t:(s.removeAt(t),s.insertAt(l,i),l);for(h=NaN;++l=0)||e<0&&r.containingGroup===i&&(e=o,t>=0))break}if(!(e<0)&&e1)&&Util._(t,"0 <= value <= 1",Layer,"opacity"),this.Wt=t;const e=this.diagram;e!==null&&e.C(),this.t("opacity",i,t)}}get isViewportAligned(){return this.vm}set isViewportAligned(t){const i=this.vm;i!==t&&(this.vm=t,this.diagram&&(this.oL(),this.diagram.C()),this.t("isViewportAligned",i,t),t&&(this.isInDocumentBounds=!1))}oL(){if(!this.vm)return;const t=this.diagram,i=this.At.r,e=i.length,s=t.kt,n=t.Pt;for(let o=0;o(w[w.None=1]="None",w[w.Uniform=2]="Uniform",w[w.UniformToFill=3]="UniformToFill",w))(AutoScale||{}),CycleMode=(w=>(w[w.All=1]="All",w[w.NotDirected=2]="NotDirected",w[w.NotDirectedFast=3]="NotDirectedFast",w[w.NotUndirected=4]="NotUndirected",w[w.DestinationTree=5]="DestinationTree",w[w.SourceTree=6]="SourceTree",w))(CycleMode||{}),ScrollMode=(w=>(w[w.Document=1]="Document",w[w.Infinite=2]="Infinite",w))(ScrollMode||{}),CollapsePolicy=(w=>(w[w.TreeParent=1]="TreeParent",w[w.AllParents=2]="AllParents",w[w.AnyParents=3]="AnyParents",w))(CollapsePolicy||{});class Diagram{ds;di;VM;wx;Nr;Ru;xx;bx;kx;Px;Mx;Sx;Dc;Gh;Nx;Cx;Lx;jl;Fc;Cr;Vm;Ax;Tx;vu;Hn;Lr;qh;Fo;zm;Rc;Xm;vc;Ou;Ar;qn;zM;XM;Dx;Fx;KM;Rx;YM;GM;jM;vx;Km;Tr;Dr;Fr;Rr;vr;Or;Ox;Ir;Ix;Er;Ur;Br;Vr;Ex;HM;Ro;qM;Ux;Bx;WM;Mi;JM;$M;ZM;vs;vo;Oi;Vx;Rl;vl;zx;Xx;Ol;Il;El;Kx;Ul;Bl;Vl;zl;Xl;Kl;Yl;Yx;Gx;QM;Iu;Eu;jx;Hx;qx;Wx;Ym;Jx;$x;Zx;$t;_M;Qx;tS;Uu;gn;Wn;te;Jn;rL;Hl;iS;eS;Gm;_x;Bu;jm;tb;zr;ql;Wh;sS;nS;Hm;ib;eb;ts;qm;Wm;Vu;Wl;Oc;Jm;Xr;Jh;oS;$m;Ht;D;Be;Pr;Ui;ps;rS;Jl;Kr;bl;Yr;$h;Ic;lS;zu;Zh;Xu;Gt;$l;ct;st;Ku;kt;Pt;dt;Ec;Uw;sb;Qh;Uc;nb;ob;rb;TF;DF;Bi;Pl;Em;Zm;hS;aS;lL;Qm;FF;RF;vF;lb;OF;IF;EF;_h;hL;Zl;ta;ia;ea;sa;wu;Kh;Zt;Tt;Bc;Wk;Jk;cc;Wt;static hb=null;static aL=new GMap;static cS;static fS=null;yu;ab;cb;fb;ub;db;_m;uS;t0;i0;e0;ex;dS;gb;Vc;constructor(t,i){if(Diagram.uw||(Diagram.Ik(),Diagram.uw=!0),GSet.Yi(this),Diagram.cL(this),this.Ht=!0,this.Tt=null,this.kt=0,this.Pt=0,this.dt=null,Diagram.isUsingDOM()){const s=this,n=()=>{s.Si(root.document,"DOMContentLoaded",n,!1),s.setRTL()};root.document.body!==null?this.setRTL():s.Vt(root.document,"DOMContentLoaded",n,!1)}this.Ec=null,Diagram.gS("Model",PartManager);const e=this;return this.JM=s=>e.partManager.doModelDataChanged(s),this.$M=s=>e.partManager.doModelChanged(s),this.nb=null,this.ob=null,this.fL(),this.model=Model.initDiagramModel(),this.gb=null,this.themeManager=new ThemeManager,this.Ro=!0,this.uL(),this.layout=new Layout,this.Ro=!1,this.FF=null,this.RF=null,this.vF=null,this.lb=null,this.OF=null,this.IF=null,this.EF=null,this._h=null,this.hL=null,this.Zl=null,this.ta=null,this.ia=null,this.ea=null,this.sa=null,this.wu=()=>{},this.Kh=null,this.Vu=!1,this.Bc=new DiagramHelper(this),t!==void 0&&(typeof t=="string"||root.Element&&t instanceof Element?this.mS(t):i=t),i&&this.setProperties(i),this.Ht=!1,this.requestUpdate(),this}qD(){return this.dt!==null}get renderer(){return this.Oc}set renderer(t){if(this instanceof Overview)return;t===""&&(t="default");const i=t.toLowerCase(),e=this.Oc;if(i===e)return;this.Oc=i;let s=null;i==="default"||i==="canvas"?(s=this.Wl.get("svg"),s!==null&&s.Ft.remove(),this.dt&&(this.Zt=this.dt.ai),this.Zt.clearContextCache(!0)):i==="svg"?(this.Wl.has("svg")?s=this.Wl.get("svg"):(s=new SVGSurface(this,root.document),this.addRenderer("svg",s)),this.div!==null&&this.div.appendChild(s.Ft),this.Zt=s.ai,this.dt&&(this.dt.ai.setTransform(this.Bi,0,0,this.Bi,0,0),this.dt.ai.clearRect(0,0,this.kt,this.Pt))):i==="debug"&&(this.Wl.has("SVG")||(s=new SVGSurface(this,root.document),this.addRenderer("SVG",s),s.Ft.style.backgroundColor="whitesmoke",this.div!==null&&this.div.after(s.Ft))),this.Ht||this.redraw()}fL(){this.Vc=new List,this.setupRouters(),this.ds=new AnimationManager,this.ds.To(this),this.di=17,this.VM=!1,this.Ku=!1,this.wx="default",this.Gt=new List,this.Wl=new GMap,this.Oc="default",this.resetRenderingHints(),this.UF(),this.Wt=1,this.ct=new Point(NaN,NaN).g(),this.ex=new Point(NaN,NaN),this.st=1,this.$m=1,this.xx=new Point(NaN,NaN).g(),this.bx=NaN,this.kx=1e-4,this.Px=100,this.D=new Transform,this.Mx=new Point(NaN,NaN).g(),this.Sx=new Rect(NaN,NaN,NaN,NaN).g(),this.Dc=new Margin(0,0,0,0).g(),this.Gh=1,this.Nx=!1,this.Cx=null,this.Lx=null,this.jl=1,this.Fc=Spot.Default,this.Cr=1,this.Vm=Spot.Default,this.Ax=Spot.None,this.Tx=Spot.None,this.Be=!0,this.vu=!1,this.Hn=new Set,this.Lr=new GSet,this.qh=new GSet,this.Fo=!1,this.$l=new GMap,this.zu=!0,this.zm=250,this.Rc=-1,this.Xm=new Margin(16,16,16,16).g(),this.Pr=!1,this.vc=!1,this.Ou=!0,this.Jm=new InputEvent,this.Jm.diagram=this,this.Xr=new InputEvent,this.Xr.diagram=this,this.Jh=new InputEvent,this.Jh.diagram=this,this.Ar=null,this.qn=null,this.Uw=!1,this.BF(),this.Yr=new GSet,this.Dx=!0,this.Fx=1,this.KM=!1,this.Rx=1,this.vx="auto",this.Km="auto",this.Tr=null,this.Dr=null,this.Fr=null,this.Rr=null,this.vr=null,this.Or=null,this.Ox=null,this.Ir=null,this.Ix=!1,this.Er=null,this.Ur=null,this.Br=null,this.Vr=null,this.Ex=!1,this.sb={},this.Qh=[null,null],this.Ro=!1,this.qM=!1,this.Ux=!1,this.Bx=!1,this.WM=!0,this.ps=!1,this.Zh=!1,this.ZM=!0,this.vs=-2,this.Jl=new GMap,this.Xu=new List,this.vo=!1,this.Oi=!0,this.Vx=!0,this.Rl=!0,this.vl=!0,this.zx=!1,this.Xx=!0,this.Ol=!0,this.Il=!0,this.El=!0,this.Kx=!0,this.Ul=!0,this.Bl=!0,this.Vl=!0,this.zl=!0,this.Xl=!0,this.Kl=!0,this.Yl=!0,this.Yx=!0,this.Gx=!0,this.QM=!1,this.Uc=!1,this.Iu=!0,this.Eu=!0,this.jx=!0,this.Hx=!0,this.qx=16,this.Wx=16,this.Ym=!1,this.Jx=!1,this.$x=0,this.Zx=0,this.$t=new Margin(5).g(),this._M=new GSet().g(),this.Qx=999999999,this.tS=new GSet().g(),this.$h=!0,this.Uu=!0,this.Ic=!0,this.gn=!1,this.Wn=!1,this.Kr=!0,this.bl=!1,this.Jn=!1,this.rL=new GSet,this.lS=new GSet,this.Hl=null,this.iS=new Size(8,8),this.eS=999,this.Gm=!1,this.Wk=1,this.Jk=0,this.Ui={scale:1,position:new Point,bounds:new Rect,canvasSize:new Size,newCanvasSize:new Size,isScroll:!1},this.Ui.canvasSize=this.Ui.canvasSize,this.Ui.newCanvasSize=this.Ui.newCanvasSize,this.Ui.isScroll=!1,this._x=new Rect(NaN,NaN,NaN,NaN).g(),this.Bu=new Size(NaN,NaN).g(),this.jm=new Rect(NaN,NaN,NaN,NaN).g(),this.tb=!1,this.VF(),this.ts=null,this.qm=!1,this.cc=null,this.partManager=new PartManager,this.toolManager=new ToolManager,this.toolManager.initializeStandardTools(),this.defaultTool=this.toolManager,this.currentTool=this.defaultTool,this.cb=null,this.fb=new DraggingOptions,this.ub=null,this.db=null,this.ab=!1,this.yu=!1,this.commandHandler=new CommandHandler,this.i0=null,this.e0=Point.Ak,this.dS=!1,this.Bi=1,this.Pl=null,this.Em=1,this._m=0,this.uS=[0,0,0,0,0],this.t0=0,this.Zm=1,this.hS=0,this.aS=new Point,this.lL=500,this.Wm=new Point,this.Qm=!1}static dL=root.document!==void 0;static isUsingDOM(){return Diagram.dL}static useDOM(t){Diagram.dL=t?root.document!==void 0:!1}static Ve=new WeakMap;clear(){this.animationManager.stopAnimation(),this.model.clear(),Diagram.gL(),this.mL(!1),this.Xu.clear(),this.pL(),this.Hl=null,this.invalidateDocumentBounds(),this.ensureBounds(),this.C()}mL(t){this.animationManager.stopAnimation(!0),this._M=new GSet().g(),this.tS=new GSet().g();const i=this.skipsUndoManager,e=this.Mi!==null&&this.Mi!==void 0;e&&(this.skipsUndoManager=!0);let s=null;this.ts!==null&&(s=this.ts.part,s!==null&&this.remove(s));const n=[],o=this.Gt.length;if(t){for(let r=0;rt?new Margin(t/2):1.5)),this.ib=this.Hm,this.eb=new Adornment(Panel.Link).add(new Shape({isPanelMain:!0,fill:null,stroke:"dodgerblue",strokeWidth:3}).theme("stroke","selection").theme("strokeWidth","selection"))}setRTL(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);const e=Util.en("div");e.dir="rtl",e.style.cssText="font-size: 14px; width: 1px; height: 1px; position: absolute; top: -1000px; overflow: scroll;",e.textContent="A",i.appendChild(e);let s="reverse";e.scrollLeft>0?s="default":(e.scrollLeft=1,e.scrollLeft===0&&(s="negative")),i.removeChild(e),this.wx=s}setScrollWidth(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);let e=0;if(Diagram.isUsingDOM()){let s=Diagram.fS,n=Diagram.cS;s===null&&(Diagram.fS=Util.en("p"),s=Diagram.fS,s.style.width="100%",s.style.height="200px",s.style.boxSizing="content-box",Diagram.cS=Util.en("div"),n=Diagram.cS,n.style.position="absolute",n.style.visibility="hidden",n.style.width="200px",n.style.height="150px",n.style.boxSizing="content-box",n.appendChild(s)),n.style.overflow="hidden",i.appendChild(n);const o=s.offsetWidth;n.style.overflow="scroll";let r=s.offsetWidth;o===r&&(r=n.clientWidth),i.removeChild(n),e=o-r,e===0&&!Util.rr&&(e=11)}this.di=e,this.VM=!0}ri(t){t in AutoScale?this.autoScale=t:Util.lr(this,t)}toString(t){t===void 0&&(t=0);let i="";this.div&&this.div.id&&(i=this.div.id);let e='Diagram "'+i+'"';if(t<=0)return e;const s=this.Gt.iterator;for(;s.next();){const n=s.value;e+=` - `+n.toString(t-1)}return e}static cL(t){Diagram.hb=t}static pm(){return Diagram.hb}static fromDiv(t){let i=t;if(typeof t=="string"&&(i=root.document.getElementById(t)),i instanceof HTMLDivElement){const e=Diagram.Ve.get(i);if(e)return e}return null}get div(){return this.Tt}set div(t){if(this.Tt!==t){const i=this.Tt;if(i!==null){if(Diagram.Ve.delete(i),i.goDiagram=void 0,i.go=void 0,i.innerHTML="",this.dt!==null){const s=this.dt.Ft;this.Si(s,"pointermove",this.ta,!1),this.Si(s,"pointerdown",this.Zl,!1),this.Si(s,"pointerup",this.ia,!1),this.Si(s,"pointerout",this.ea,!1),this.Si(s,"pointercancel",this.sa,!1),this.dt.dispose()}this.Ec&&(this.Ec.disconnect(),this.Ec=null);const e=this.toolManager;e!==null&&(e.mouseDownTools.each(s=>s.cancelWaitAfter()),e.mouseMoveTools.each(s=>s.cancelWaitAfter()),e.mouseUpTools.each(s=>s.cancelWaitAfter())),e.cancelWaitAfter(),this.currentTool.doCancel(),this.dt=null,this.Si(root,"resize",this.lb,!1),this.Si(root,"wheel",this._h,!0),Diagram.pm()===this&&Diagram.cL(null)}else this.Zl===null&&(this.Jn=!1);if(this.Tt=null,t!==null){const e=Diagram.Ve.get(t);e&&(e.div=null),this.mS(t),this.wu(),this.themeManager&&this.themeManager.zF()}else this.themeManager&&this.themeManager.XF()}}setupRouters(){this.Vc.push(new AvoidsNodesRouter)}mS(t){const i=this;if(!Diagram.isUsingDOM())return;t==null&&Util.o("Diagram setup requires an argument DIV."),i.Tt!==null&&Util.o("Diagram has already completed setup."),typeof t=="string"?i.Tt=root.document.getElementById(t):t instanceof HTMLDivElement?i.Tt=t:Util.o("No DIV or DIV id supplied: "+t),i.Tt===null&&Util.o("Invalid DIV id; could not get element with id: "+t);const e=Diagram.Ve.get(i.Tt);if(e&&e!==this&&Util.o("Invalid div id; div already has a Diagram associated with it."),!i.Ec&&root.ResizeObserver){const c=root.ResizeObserver,f=Util.Nk(()=>i.requestUpdate(),250,!1);i.Ec=new c(()=>f()),i.Ec.observe(i.Tt)}root.getComputedStyle(i.Tt,null).position==="static"&&(i.Tt.style.position="relative");let s=5;const n="rgba(2"+s+"5, 255, 255, 0)";s--,i.Tt.style["-webkit-tap-highlight-color"]=n,i.Tt.innerHTML="",Diagram.Ve.set(i.Tt,i),i.Tt.goDiagram=i,i.Tt.go=root.go;const o=new CanvasSurface(i);o.style!==void 0&&(o.style.position="absolute",o.style.top="0px",o.style.left="0px",root.getComputedStyle(i.Tt,null).getPropertyValue("direction")==="rtl"&&(i.Ku=!0),o.style.zIndex="2",o.style.userSelect="none",o.style.MozUserSelect="none",o.style.touchAction="none",o.style.letterSpacing="normal !important",o.style.wordSpacing="normal !important",o.style.lang="unknown"),i.dt=o,i.Zt=o.ai;const r=i.Zt;i.Bi=i.computePixelRatio(),i.viewSize.isReal()||(i.kt=i.Tt.clientWidth||1,i.Pt=i.Tt.clientHeight||1),i.yL(i.kt,i.Pt);const l=i;i.Tt.insertBefore(o.Ft,i.Tt.firstChild);const h=new CanvasSurface(null);if(h.width=1,h.height=1,i.TF=h,i.DF=h.ai,Diagram.isUsingDOM()){const c=Util.en("div"),f=Util.en("div");c.style.position="absolute",c.style.overflow="auto",c.style.width=i.kt+"px",c.style.height=i.Pt+"px",c.style.zIndex="1",f.style.position="absolute",f.style.width="1px",f.style.height="1px",i.Tt.appendChild(c),c.appendChild(f),c.onscroll=Diagram.KF,c.addEventListener("pointerdown",Diagram.YF),c.p=i,c.GF=!0,c.jF=!0,i.nb=c,i.ob=f}i.wu=Util.Nk(()=>{i.Pl=null,i.C()},300,!1),i.lb=Util.Nk(()=>{i.SM()},250,!1),i.Kh=c=>(c.preventDefault(),!1),i._h=c=>{if(!l.isEnabled)return;const f=l.zc(c,!0);f.bubbles=!0;let u=0,d=0;f.delta=0,c.deltaX!==void 0?(c.deltaX!==0&&(u=c.deltaX>0?1:-1),c.deltaY!==0&&(d=c.deltaY>0?1:-1),f.delta=Math.abs(c.deltaX)>Math.abs(c.deltaY)?-u:-d):c.wheelDeltaX!==void 0?(c.wheelDeltaX!==0&&(u=c.wheelDeltaX>0?-1:1),c.wheelDeltaY!==0&&(d=c.wheelDeltaY>0?-1:1),f.delta=Math.abs(c.wheelDeltaX)>Math.abs(c.wheelDeltaY)?-u:-d):c.wheelDelta!==void 0&&c.wheelDelta!==0&&(f.delta=c.wheelDelta>0?1:-1),l.doMouseWheel(),l.na(f,c)},i.hL=c=>{if(!l.isEnabled)return;i.Uc=!1,l.zc(c,!0);const f=l.currentTool;f.cancelWaitAfter(),f.standardMouseOver()},i.Zl=c=>{if(!l.isEnabled)return;i.Uc=!0;const f=l.sb;f[c.pointerId]===void 0&&(f[c.pointerId]=c);const u=l.Qh;let d=!1;if(u[0]!==null&&(u[0].pointerId===c.pointerId||u[0].pointerType!==c.pointerType))u[0]=c;else if(u[1]!==null&&u[1].pointerId===c.pointerId)u[1]=c,d=!0;else if(u[0]===null)u[0]=c;else if(u[1]===null)u[1]=c,d=!0;else{c.preventDefault();return}const m=c.pointerType==="touch"||c.pointerType==="pen";m&&(l.Uw=!1,l.Qm=!0);const g=l.HF(c,c,d),p=l.aS,y=m?25:10;if(c.timeStamp-l.hSy||Math.abs(p.y-c.screenY)>y)?l.Zm++:l.Zm=1,g.clickCount=l.Zm,l.hS=c.timeStamp,l.aS.setTo(c.screenX,c.screenY),l.doMouseDown(),c.button===1){c.preventDefault();return}l.na(g,c)},i.ta=c=>{if(!l.isEnabled)return;i.Uc=!0;const f=l.Qh;if(f[0]!==null&&(f[0].pointerId===c.pointerId||f[0].pointerType!==c.pointerType))f[0]=c;else if(f[1]!==null&&f[1].pointerId===c.pointerId){f[1]=c;return}else if(f[0]===null)f[0]=c;else return;if(f[0].pointerId!==c.pointerId)return;const u=l.qF(c,c,f[1]!==null);l.doMouseMove(),l.na(u,c)},i.ia=c=>{if(!l.isEnabled)return;i.Uc=!0;const f=c.pointerType==="touch"||c.pointerType==="pen",u=l.sb;if(f&&l.Uw){delete u[c.pointerId],c.preventDefault();return}const d=l.Qh;if(d[0]!==null&&(d[0].pointerId===c.pointerId||d[0].pointerType!==c.pointerType))d[0]=null;else if(d[1]!==null&&d[1].pointerId===c.pointerId){d[1]=null;return}else return;const m=l.pS(c,!1,!0,!1,!0,!1);let g=root.document.elementFromPoint(c.clientX,c.clientY)||null;g!==null&&g.shadowRoot!==void 0&&g.shadowRoot!==null&&(g=g.shadowRoot.elementFromPoint(c.clientX,c.clientY)),g!==null&&g.p instanceof Diagram&&g.p!==l&&g.p.o0(c,m),g===null&&(g=c.target),l.o0(c,m),m.clickCount=l.Zm,m.targetDiagram=l.yS(c,g),m.targetObject=null,l.doMouseUp(),l.na(m,c),f&&(l.Qm=!1)},i.ea=c=>{if(!l.isEnabled)return;i.Uc=!1;const f=l.sb;f[c.pointerId]&&delete f[c.pointerId];const u=l.Qh;if(u[0]!==null&&u[0].pointerId===c.pointerId&&(u[0]=null),u[1]!==null&&u[1].pointerId===c.pointerId&&(u[1]=null),c.pointerType==="touch"||c.pointerType==="pen")return;const d=l.currentTool;d.cancelWaitAfter(),d.standardMouseOver()},i.sa=c=>{const f=l.Qh;f[0]!==null&&f[0].pointerId===c.pointerId?(f[0]=null,l.Qm=!1):f[1]!==null&&f[1].pointerId===c.pointerId&&(f[1]=null)};const a=r;if(i.rb=a.B[Util.Cs("7eba17a4ca3b1a8346")][Util.Cs("78a118b7")](a.B,Diagram.Yu,s,s),r.clearContextCache(!0),i.WF(),this.Oc==="svg"){const c=this.Wl.get("svg");this.Tt.appendChild(c.Ft),this.Zt=c.ai}}addEventListener(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}Vt(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}removeEventListener(t,i,e,s){t.removeEventListener(i,e,{capture:s})}Si(t,i,e,s){t.removeEventListener(i,e,{capture:s})}WF(){const t=this;let i=this.dt.Ft;i instanceof HTMLCanvasElement||(i=t.div),this.Vt(i,"pointerdown",t.Zl,!1),this.Vt(i,"pointermove",t.ta,!1),this.Vt(i,"pointerup",t.ia,!1),this.Vt(i,"pointerout",t.ea,!1),this.Vt(i,"pointercancel",t.sa,!1),this.Vt(i,"pointerenter",t.JF,!1),this.Vt(i,"pointerleave",t.$F,!1),this.Vt(i,"wheel",t._h,!1),this.Vt(i,"keydown",t.ZF,!1),this.Vt(i,"keyup",t.QF,!1),this.Vt(i,"blur",t._F,!1),this.Vt(i,"focus",t.tR,!1),this.Vt(i,"selectstart",e=>(e.preventDefault(),!1),!1),this.Vt(i,"contextmenu",e=>(e.preventDefault(),!1),!1),this.Vt(root,"resize",t.lb,!1)}Bw(){this._m>30&&(this.Pl=1)}yP(t){this.Pl!==null&&(this.Pl=null,t&&this.wu(),this._m=0,this.uS=[0,0,0,0,0],this.t0=0)}computePixelRatio(){return this.Pl!==null?this.Pl:root.devicePixelRatio||1}get avgSpf(){return this._m}doMouseDown(){this.currentTool.doMouseDown()}doMouseMove(){this.currentTool.doMouseMove()}doMouseUp(){this.currentTool.doMouseUp()}doMouseWheel(){this.currentTool.doMouseWheel()}doKeyDown(){this.currentTool.doKeyDown()}doKeyUp(){this.currentTool.doKeyUp()}doFocus(){this.focus()}focus(){if(this.dt)if(this.scrollsPageOnFocus)this.dt.focus();else{const t=root.scrollX,i=root.scrollY;this.dt.focus(),root.scrollTo(t,i)}}tR(t){const i=Diagram.Ve.get(this);i&&i.v("GainedFocus")}_F(t){const i=Diagram.Ve.get(this);i&&i.v("LostFocus")}SM(){if(this.dt===null)return;const i=this.Tt;if(i===null||i.clientWidth===0||i.clientHeight===0)return;this.VM||this.setScrollWidth();const e=this.Wn?this.di:0,s=this.gn?this.di:0,n=this.Bi;if(this.Bi=this.computePixelRatio(),this.Bi!==n&&(this.vu=!0,this.requestUpdate()),i.clientWidth!==this.kt+e||i.clientHeight!==this.Pt+s){this.oa(),this.Be=!0;const o=this.layout;o!==null&&o.isViewportSized&&this.autoScale===1&&(this.vc=!0,o.invalidateLayout()),this.ps||this.requestUpdate()}}uL(){let t=0,i=new Layer;i.name="Grid",i.allowSelect=!1,i.pickable=!1,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="ViewportBackground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="Background",this.Gr(i,t++),i=new Layer,i.name="",this.Gr(i,t++),i=new Layer,i.name="Foreground",this.Gr(i,t++),i=new Layer,i.name="ViewportForeground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="Adornment",i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="Tool",i.isTemporary=!0,i.isInDocumentBounds=!0,this.Gr(i,t++)}wL(){const t=new Panel(Panel.Grid,{name:"GRID"}).add(new Shape("LineH",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineV",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineH",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineH",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor")),i=new Part({layerName:"Grid",zOrder:0,isInDocumentBounds:!1,isAnimated:!1,pickable:!1,locationObjectName:"GRID"}).add(t);return this.add(i),this.partManager.parts.delete(i),t.visible=!1,t}static KF(){const t=Diagram.Ve.get(this.parentElement||this);if(t){if(t.Jx){t.Jx=!1;return}if(!t.isEnabled){t.xL();return}t.diagramScroll(this)}}static YF(t){if(!this.p.isEnabled){this.p.updateScroll();return}this.p.$x=t.target.scrollTop,this.p.Zx=t.target.scrollLeft}diagramScroll(t){if(this.dt===null)return;const i=this.nb,e=this.ob;this.Ym=!0;let s=this.documentBounds,n=this.viewportBounds;const o=this.Dc;let r=s.x-o.left,l=s.y-o.top;const h=s.width+o.left+o.right,a=s.height+o.top+o.bottom;let c=s.right+o.right,f=s.bottom+o.bottom,u=n.x,d=n.y;const m=n.width,g=n.height;let p=n.right,y=n.bottom;const x=this.scale;let k,b=t.scrollLeft;if(this.Ku)switch(this.wx){case"negative":b=b+t.scrollWidth-t.clientWidth;break;case"reverse":b=t.scrollWidth-b-t.clientWidth;break}const P=b;if(mp)){const M=i.scrollWidth-this.kt;this.position=k.e(-M+P-this.kt/x+c,this.position.y)}if(t.jF&&this.allowVerticalScroll&&(ly)){const M=i.scrollHeight-this.Pt;this.position=k.e(this.position.x,-M+t.scrollTop-this.Pt/x+f)}Point.s(k),this._l(),this.Ym=!1,this.Uu=!1,s=this.documentBounds,n=this.viewportBounds,c=s.right,p=n.right,f=s.bottom,y=n.bottom,r=s.x,u=n.x,l=s.y,d=n.y,m>=h&&r>=u&&c<=p&&(e.style.width="1px"),g>=a&&l>=d&&f<=y&&(e.style.height="1px")}computeBounds(t){return t===void 0&&(t=new Rect),this.Ci(),this.bL(t)}bL(t){if(this.fixedBounds.isReal())return t.a(this.fixedBounds),t.addMargin(this.$t),t;let i=!0;const e=this.Gt.r,s=e.length;for(let n=0;ni&&(a=i),athis.maxScale&&(a=this.maxScale),a):t===3?(a=0,h>l?a=(r-this.di)/n:a=(o-this.di)/s,a>i&&(a=i),athis.maxScale&&(a=this.maxScale),a):this.scale}zoomToFit(){const t=this.Gh;this.Gh=1,this.scale=this.Gu(2),t!==1&&(this.Bs(!1),this.wS(this.documentBounds,this.kt/this.st,this.Pt/this.st,this.Fc,!1)),this.Gh=t}zoomToRect(t,i){i===void 0&&(i=2);const e=t.width,s=t.height;if(e===0||s===0||isNaN(e)&&isNaN(s))return;let n=1;if(i===2||i===3)if(isNaN(e))n=this.viewportBounds.height*this.scale/s;else if(isNaN(s))n=this.viewportBounds.width*this.scale/e;else{const o=this.kt,r=this.Pt;i===3?r/s>o/e?n=(r-(this.gn?this.di:0))/s:n=(o-(this.Wn?this.di:0))/e:n=Math.min(r/s,o/e)}this.scale=n,this.position=new Point(t.x,t.y)}get iR(){return this.Ht}set iR(t){this.Ht=t}alignDocument(t,i){this.ensureBounds();const e=this.documentBounds,s=this.viewportBounds;this.position=new Point(e.x+(t.x*e.width+t.offsetX)-(i.x*s.width-i.offsetX),e.y+(t.y*e.height+t.offsetY)-(i.y*s.height-i.offsetY))}focusObject(t){if(t instanceof GraphObject){this.i0=t;const i=Point.l();this.e0=this.transformDocToView(t.getDocumentPoint(Spot.TopLeft,i)),Point.s(i)}else this.i0=null,this.e0=Point.Ak}wS(t,i,e,s,n){const o=Point.X(this.ct.x,this.ct.y);let r=o.x,l=o.y;if(this.i0!==null){let h=Point.l();h=this.i0.getDocumentPoint(Spot.TopLeft,h),r=h.x-this.e0.x/this.scale,l=h.y-this.e0.y/this.scale,s=Spot.None,Point.s(h)}if(n||this.scrollMode===1){s.isSpot()&&(i>t.width&&(r=t.x+(s.x*t.width+s.offsetX)-(s.x*i-s.offsetX)),e>t.height&&(l=t.y+(s.y*t.height+s.offsetY)-(s.y*e-s.offsetY)));const h=this.Dc,a=i-t.width;if(it.left?r=t.left:rt.top?l=t.top:ls.part,s=>s.canSelect());if(e instanceof Part)return e}else{const e=this.PP(t,s=>s.part);if(e instanceof Part)return e}return null}findObjectAt(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Ci();const s=this.Gt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}PP(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Ci();const s=this.Gt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible||n.isTemporary)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}findPartsAt(t,i,e){return i===void 0&&(i=!0),this.sR(t,s=>s.part,i?s=>s instanceof Part&&s.canSelect():null,e)}sR(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Ci();const n=this.Gt.iteratorBackwards;for(;n.next();){const o=n.value;!o.visible||o.isTemporary||o.findObjectsAt(t,i,e,s)}return s}findObjectsAt(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Ci();const n=this.Gt.iteratorBackwards;for(;n.next();){const o=n.value;o.visible&&o.findObjectsAt(t,i,e,s)}return s}findPartsIn(t,i,e,s){return i===void 0&&(i=!1),e===void 0&&(e=!0),this.nR(t,null,n=>n instanceof Part&&(!e||n.canSelect()),i,s)}findObjectsIn(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Ci();const o=this.Gt.iteratorBackwards;for(;o.next();){const r=o.value;r.visible&&r.findObjectsIn(t,i,e,s,n)}return n}NP(t,i,e,s,n,o){const r=new GSet;this.Ci();const l=this.Gt.iteratorBackwards;for(;l.next();){const h=l.value;h.visible&&h.NP(t,i,e,s,r,n,o)}return r}nR(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Ci();const o=this.Gt.iteratorBackwards;for(;o.next();){const r=o.value;!r.visible||r.isTemporary||r.findObjectsIn(t,i,e,s,n)}return n}findPartsNear(t,i,e,s,n){return e===void 0&&(e=!0),s===void 0&&(s=!0),this.oR(t,i,null,o=>o instanceof Part&&(!s||o.canSelect()),e,n)}findObjectsNear(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Ci();const r=this.Gt.iteratorBackwards;for(;r.next();){const l=r.value;l.visible&&l.findObjectsNear(t,i,e,s,n,o)}return o}oR(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Ci();const r=this.Gt.iteratorBackwards;for(;r.next();){const l=r.value;!l.visible||l.isTemporary||l.findObjectsNear(t,i,e,s,n,o)}return o}acceptEvent(t){return this.zc(t,t instanceof MouseEvent)}zc(t,i){const e=this.Xr;this.Xr=this.Jh,this.Jh=e,e.diagram=this,e.event=t,i?this.o0(t,e):(e.viewPoint=this.Xr.viewPoint,e.documentPoint=this.Xr.documentPoint);let s=0;const n=t;return n.ctrlKey&&(s+=1),n.altKey&&(s+=2),n.shiftKey&&(s+=4),n.metaKey&&(s+=8),e.modifiers=s,e.button=n.button,n.buttons!==void 0&&(e.buttons=n.buttons),Util.rr&&n.button===0&&n.ctrlKey&&(e.button=2),e.down=!1,e.up=!1,e.clickCount=1,e.delta=0,e.handled=!1,e.bubbles=!1,e.timestamp=t.timeStamp,e.isMultiTouch=!1,e.targetDiagram=this.yS(t,t.target),e.targetObject=null,e}yS(t,i){if(i===null)return null;const e=Diagram.Ve.get(i);if(e)return e;let s=t.path;if(!s&&typeof t.composedPath=="function"&&(s=t.composedPath()),s&&s[0]){const n=Diagram.Ve.get(s[0]);if(n)return n}return null}HF(t,i,e){const s=this.pS(t,!0,!1,!1,!0,e);return this.o0(i,s),s.targetDiagram=this.yS(t,t.target),s.targetObject=null,e||s.clone(this.Jm),s}qF(t,i,e){const s=this.pS(t,!1,!1,!1,!1,e);let n=root.document.elementFromPoint(i.clientX,i.clientY)||null;n!==null&&n.shadowRoot!==void 0&&n.shadowRoot!==null&&(n=n.shadowRoot.elementFromPoint(i.clientX,i.clientY));let o=this,r=t;if(n){const l=Diagram.Ve.get(n);l&&(r=i,o=l)}return s.targetDiagram=o,this.o0(r,s),s.targetObject=null,s}pS(t,i,e,s,n,o){const r=this.Xr;this.Xr=this.Jh,this.Jh=r,r.diagram=this,r.clickCount=1,r.delta=0;let l=0;return t.ctrlKey&&(l+=1),t.altKey&&(l+=2),t.shiftKey&&(l+=4),t.metaKey&&(l+=8),r.modifiers=l,r.event=t,r.timestamp=t.timeStamp,r.button=e?this.firstInput.button:t.button,r.buttons=t.buttons,Util.rr&&t.button===0&&t.ctrlKey&&(r.button=2),r.down=i,r.up=e,r.handled=s,r.bubbles=n,r.isMultiTouch=o,r}na(t,i){return t.bubbles?!0:(i.stopPropagation!==void 0&&i.stopPropagation(),i.cancelable!==!1&&i.preventDefault(),i.cancelBubble=!0,!1)}ZF(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.zc(t,!1);return e.key=t.key,e.code=t.code,e.down=!0,i.doKeyDown(),i.na(e,t)}QF(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.zc(t,!1);return e.key=t.key,e.code=t.code,e.up=!0,i.doKeyUp(),i.na(e,t)}JF(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.zc(t,!0);return i.mouseEnter!==null&&i.mouseEnter(e),i.currentTool.standardMouseOver(),i.na(e,t)}$F(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.zc(t,!0);return i.mouseLeave!==null&&i.mouseLeave(e),i.na(e,t)}getMouse(t){const i=this.dt;if(i===null)return new Point(0,0);const e=i.getBoundingClientRect(),s=(t.clientX-e.left)*(this.kt/e.width),n=(t.clientY-e.top)*(this.Pt/e.height);return new Point(s,n).Ie(this.D)}o0(t,i){const e=this.dt;let s=0,n=0;if(e!==null){const r=e.getBoundingClientRect();s=(t.clientX-r.left)*(this.kt/r.width),n=(t.clientY-r.top)*(this.Pt/r.height)}i.viewPoint.e(s,n);const o=Point.X(s,n);this.D._e(o),i.documentPoint.a(o),Point.s(o)}MC(t,i,e){let s;if(this.Qh[0]!==null)s=this.Qh[i];else return;const n=this.dt;if(n!==null){const o=n.getBoundingClientRect();e.e((s.clientX-o.left)*(this.kt/o.width),(s.clientY-o.top)*(this.Pt/o.height))}}invalidateDocumentBounds(){this.$h||(this.$h=!0,this.requestUpdate(!1))}rR(){this.ps||this.Ci(),this.ensureBounds()}redraw(){this.Ht||this.ps||(this.C(),this.maybeUpdate())}isUpdateRequested(){return this.Pr}delayInitialization(t){t===void 0&&(t=null);const i=this.animationManager,e=i.isEnabled;i.stopAnimation(),i.isEnabled=!1,this.yr(),this.Jn=!1,this.ex=new Point(NaN,NaN),i.isEnabled=e,this.ps=!0;const s=this;t!==null&&Util.vh(()=>{s.ps=!1,i.Fl("Model"),t(s)},1)}requestUpdate(t){if(t===void 0&&(t=!1),this.Pr===!0||this.Ht||t===!1&&this.ps)return;this.Pr=!0;const i=this;root.requestAnimationFrame(()=>{i.Pr&&i.maybeUpdate()})}maybeUpdate(){this.Ou&&!this.Pr||(this.Ou&&(this.Ou=!1),this.yr())}xS(t,i){!this.Uu||this.Ht||this.animationManager.defaultAnimation.isAnimating||this.xL()||(t&&this.Ci(),i&&this.Bs(!1))}yr(t){if(this.ps||(this.Pr=!1,this.Tt===null&&!this.Bu.isReal()))return;this.ps=!0;const i=this.animationManager,e=this.Xu;if(!i.isAnimating&&e.length!==0){const c=e.r,f=c.length;for(let u=0;u0&&(s.each(c=>c.bS()),s.clear());let n=!1,o=!1;i.defaultAnimation.isAnimating&&(o=!0,n=this.skipsUndoManager,this.skipsUndoManager=!0),i.wi||this.SM(),t||this.xS(!1,!0);const r=!this.undoManager.isUndoingRedoing&&(this.bl||this.Vc.count!==0&&this.Lr.size!==0),l=!this.Jn||this.Kr;this.Ci(!0);let h=!1;(l||r)&&(this.Jn?this.kS(!this.vc,r):(this.startTransaction("Initial Layout"),i.isEnabled===!1&&i.stopAnimation(),this.kS(!1,r)),h=l),this.vc=!1,this.bl=!1,this.Ci(),this.ts!==null&&(this.ts.visible&&!this.qm&&(this.jr(),this.qm=!0),!this.ts.visible&&this.qm&&(this.qm=!1)),this.Ux||this.rR(),t||this.xS(!0,!1);let a=!1;if(h){const c=Rect.l();c.a(this.viewportBounds),this.Jn||(this.Jn=!0,a=!0,this.skipsUndoManager||(this.undoManager.Ow=!0),this.undoManager.Iw=!0,this.lR()),this.hR(),this.Ci(!1),t||this.xS(!0,!0),Rect.s(c)}else if(i.Pc&&i.ix){if(this.Cr!==1)this.scale=this.Gu(this.Cr);else if(this.jl!==1)this.scale=this.Gu(this.jl);else{const c=this.initialScale;isFinite(c)&&c>0&&(this.scale=c)}this.Bs(!0)}h&&a&&this.commitTransaction("Initial Layout"),t||this.Gi(this.Zt),o&&(this.skipsUndoManager=n),this.ps=!1}get Eh(){return this.Jn}lR(){if(this.Cr!==1)this.scale=this.Gu(this.Cr);else if(this.jl!==1)this.scale=this.Gu(this.jl);else{const i=this.initialScale;isFinite(i)&&i>0&&(this.scale=i)}this.Bs(!0);const t=this.Gt.r;this.Us(t,t.length,this,this.viewportBounds),this.v("InitialLayoutCompleted"),this.ex.a(this.ct),this.jr()}hR(){this.v("LayoutCompleted")}r0(t){this.Hn.add(t)}addInvalidRoute(t){this.Fo?this.qh.add(t):this.Lr.add(t)}Ci(t){if(this.Hn.size!==0&&!(!this.ps&&this.animationManager.isTicking)){if(this.ps||(this.bl=!0),t){this.kL(this.Hn);return}for(let i=0;i<23&&this.Hn.size!==0;i++){const e=new Set(this.Hn);this.Hn.clear(),this.bS(e,this.Hn)}this.nodes.each(i=>{i instanceof Group&&i.PL(!1)})}}kL(t,i){for(const e of t)!e.Pe()||e instanceof Group||(e.Hr()?(e.ut(1/0,1/0),e.zt()):i&&i.add(e));for(const e of t)if(e instanceof Group){if(!e.isVisible())continue;this.yb(e)}}bS(t,i){this.kL(t,i);for(const e of t){if(!(e instanceof Link))continue;const s=e;s.isVisible()&&(s.Hr()?(s.ut(1/0,1/0),s.zt()):i.add(s))}for(const e of t)e instanceof Adornment&&e.isVisible()&&(e.Hr()?(e.ut(1/0,1/0),e.zt()):i.add(e))}l0(t){const i=t instanceof Diagram,e=i?t.links:t.memberParts,s=this.Hn;if(i)this.Ci(!0);else{for(;e.next();){const n=e.value;s.has(n)&&(!n.Pe()||n instanceof Group||n.Hr()&&(n.ut(1/0,1/0),n.zt()))}for(e.reset();e.next();){const n=e.value;if(s.has(n)&&n instanceof Group){if(!n.isVisible())continue;this.yb(n)}}e.reset()}for(;e.next();){const n=e.value;n instanceof Link&&s.has(n)&&n.isVisible()&&n.Hr()&&(n.ut(1/0,1/0),n.zt())}}yb(t){const i=Util.ot(),e=Util.ot(),s=t.memberParts;for(;s.next();){const o=s.value;o.isVisible()&&(o instanceof Group?(o.Oo()||o.is()||o.th())&&this.yb(o):o instanceof Link?o.fromNode===t||o.toNode===t?e.push(o):i.push(o):(o.ut(1/0,1/0),o.zt()))}let n=i.length;for(let o=0;ob.Fu())}else for(let x=0;x0){const a=n.substring(0,h);e?o=t.findObject(a):(o=t[a],o==null&&(o=t.toolManager[a])),Util.wt(o)?r=n.substring(h+1):Util.o("Unable to find object named: "+a+" in "+t.toString()+" when trying to set property: "+n)}}if(r[0]!=="_"&&!Util.fw(o,r))if(s&&r==="ModelChanged"){t.addModelChangedListener(i[r]);continue}else if(s&&r==="Changed"){t.addChangedListener(i[r]);continue}else if(s&&Util.fw(t.toolManager,r))o=t.toolManager;else if(s&&t.ML(r)){t.addDiagramListener(r,i[r]);continue}else if(t instanceof Model&&r==="Changed"){t.addChangedListener(i[r]);continue}else Util.o('Trying to set undefined property "'+r+'" on object: '+o.toString());const l=i[n];o[r]=l,r[0]==="_"&&o instanceof GraphObject&&o.addCopyProperty(r)}}fR(){if(this.$l.count!==0&&!(this.undoManager.transactionLevel>1)){for(;this.$l.count>0;){const t=this.$l;this.$l=new GMap;const i=t.iterator;for(;i.next();){const e=i.key;e.invalidateOtherJumpOvers(i.value),e.ie()}}this.C()}}C(t){if(t===void 0)this.Be=!0,this.requestUpdate();else{const i=this.viewportBounds;t.isReal()&&i.intersectsRect(t)&&(this.Be=!0,this.requestUpdate())}this.v("InvalidateDraw")}invalidateViewport(t,i){if(this.Be===!0)return;if(this.Be=!0,this.Oc==="svg"){this.maybeUpdate();return}this.getRenderingHint("temporaryPixelRatio")===!0?(this.Bw(),this.maybeUpdate(),this.yP(!0)):this.maybeUpdate()}oa(){this.Uu=!0}_l(){this.Ic=!0}h0(){this.vu!==!1&&(this.vu=!1,this.yL(this.kt,this.Pt))}yL(t,i){this.Ql();const e=this.Bi,s=t*e,n=i*e;this.dt.resize(s,n,t,i)&&(this.Be=!0,this.Zt.clearContextCache(!0))}xL(){const t=this.dt;if(t===null||this.Bu.isReal())return!0;const i=this.kt,e=this.Pt,s=this.Tt;let n=!1,o=this.Wn?this.di:0,r=this.gn?this.di:0,l=s.clientWidth||i+o,h=s.clientHeight||e+r;const a=this.viewportBounds,c=a.x,f=a.y,u=a.width,d=a.height;if((l!==i+o||h!==e+r)&&(this.Wn=!1,this.gn=!1,o=0,r=0,this.kt=l,this.Pt=h,this.vu=!0,n=!0,this.Ql()),!this.Jn||!this.viewportBounds.isReal())return!0;const m=this.nb,g=this.ob;if(this.Uu=!1,!n&&!this.Wn&&!this.gn&&!this.Iu&&!this.Eu)return!0;const p=this.documentBounds;let y=0,x=0,k=0,b=0;const P=a.width,M=a.height,L=this.Dc;this.contentAlignment.isSpot()?(p.width>P&&(y=L.left,x=L.right),p.height>M&&(k=L.top,b=L.bottom)):(y=L.left,x=L.right,k=L.top,b=L.bottom);const C=p.width+y+x,S=p.height+k+b,N=this.scale,T=N;let A=C>l/N,D=S>h/N;if(!n&&!this.Wn&&!this.gn&&!A&&!D)return!0;const F=p.x-y,R=a.x,v=p.right+x;let O=a.right+o;const U=p.y-k,X=a.y,E=p.bottom+b;let V=a.bottom+r,B="1px",Y="1px";if(this.scrollMode===1&&(A||D)){if(A&&this.hasHorizontalScrollbar&&this.allowHorizontalScroll){let z=1;F+1O+1&&(z=Math.max((v-O)*N+this.kt,z)),P+o+1V+1&&(z=Math.max((E-V)*N+this.Pt,z)),M+r+1O+1&&(W=Math.max((v-O)*N+this.kt,W)),P+1V+1&&(W=Math.max((E-V)*N+z,W)),M+1O+1&&(J=this.position.x*N)),this.Ku)switch(this.wx){case"negative":J=-(m.scrollWidth-J-m.clientWidth);break;case"reverse":J=m.scrollWidth-J-m.clientWidth;break}if(m.scrollLeft=J,this.hasVerticalScrollbar&&this.allowVerticalScroll&&(M+1V+1&&(m.scrollTop=this.position.y*N)),l=this.kt,h=this.Pt,m.style.width=l+(this.Wn?this.di:0)+"px",m.style.height=h+(this.gn?this.di:0)+"px",i!==l||e!==h||this.animationManager.wi){const z=Rect.X(c,f,u,d);return this.onViewportBoundsChanged(z,this.viewportBounds,T,n),Rect.s(z),!1}return!0}add(t){const i=t.diagram;if(i===this)return;i!==null&&Util.o("Cannot add part "+t.toString()+" to "+this.toString()+". It is already a part of "+i.toString());let e=this.findLayer(t.layerName);if(e===null&&(e=this.findLayer("")),e===null&&Util.o('Cannot add a Part when unable find a Layer named "'+t.layerName+'" and there is no default Layer'),t.layer===e)return;const s=e.Hh(99999999,t,t.diagram===this);s>=0&&this.raiseChangedEvent(3,"parts",e,null,t,null,s),e.isTemporary||this.invalidateDocumentBounds(),t.invalidateLayout(1);const n=t.layerChanged;n!==null&&n(t,null,e)}Hh(t){this.partManager.Hh(t);const i=this;t.qr(s=>i.SL(s)),t.data||t.Io(),t.hasPlaceholder()&&t.c(),t.data!==null&&t.qr(s=>i.partManager.MS(s,null)),(t.is()===!0||t.th()===!0)&&this.r0(t),t.NL(!0,this),t.CL()?(t.actualBounds.isReal()&&this.C(t.jh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.C(t.jh(t.actualBounds)),this.requestUpdate()}_i(t){t.clearAdornments(),this.partManager._i(t);const i=this;t.data!==null&&t.qr(s=>i.partManager.SS(s,i)),this.Hn.delete(t),t instanceof Link&&this.Lr.delete(t),t.CL()?(t.actualBounds.isReal()&&this.C(t.jh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.C(t.jh(t.actualBounds)),this.requestUpdate()}remove(t){this.NS(t,!0)}NS(t,i){const e=t.layer;if(e===null||e.diagram!==this)return;t.isSelected=!1,t.isHighlighted=!1,t.invalidateLayout(2),i&&t.Xc();const s=e._i(-1,t,!1);s>=0&&this.raiseChangedEvent(4,"parts",e,t,null,s,null);const n=t.layerChanged;n!==null&&n(t,e,null)}removeParts(t,i){if(i===void 0&&(i=!1),Array.isArray(t)){const e=t.length;for(let s=0;s=0&&i.elt(e).isTemporary;)e--;return i.insertAt(e+1,t),this.Mi!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,e+1),this.C(),this.invalidateDocumentBounds(),this}addLayerBefore(t,i){this.CS(t,i),t.To(this);const e=this.Gt,s=e.indexOf(t);s>=0&&(e.delete(t),this.Mi!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;o=0&&(e.delete(t),this.Mi!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;othis.maxScale&&(i=this.maxScale);const c=Point.X(this.ct.x+l/t-l/i,this.ct.y+h/t-h/i);this.position=c,Point.s(c),this.st=i,this.Ql(),this.Ht=!1,this.onViewportBoundsChanged(n,this.viewportBounds,t,!1),this.Bs(!1),e._C(t,this.st),this.C()}eR(){const t=this.Gt.r;for(let i=0;i{r.isAvoiding&&r.actualBounds.intersectsRect(i)&&r.invalidateRoute()})}jr(t){const i=this.ts;if(i===null||!i.visible||i.layer===null)return;const e=t!==void 0?t:this._x;if(!e.isReal())return;const s=e.width,n=e.height;if(i.scale=1,i.angle=0,i.layer.isViewportAligned)i.width=s*this.scale,i.height=n*this.scale,i.part.alignment=Spot.TopLeft;else{i.xi===null&&(i.xi=new GridPanelSettings);const o=i.xi.Kc;if(!o.isReal())return;i.width=s+o.width*2,i.height=n+o.height*2;const r=Point.l();Geo.Eg(e.x,e.y,0,0,o.width,o.height,r),r.offset(-o.width,-o.height),i.part.location=r,Point.s(r)}}clearSelection(t){t===void 0&&(t=!1);const i=this.selection;if(i.count===0)return;t||this.v("ChangingSelection",i);const e=i.toArray(),s=e.length;for(let n=0;n1)&&(this.v("ChangingSelection",this.selection),this.clearSelection(!0),t.isSelected=!0,this.v("ChangedSelection",this.selection))}selectCollection(t){if(this.v("ChangingSelection",this.selection),this.clearSelection(!0),Array.isArray(t)){const i=t.length;for(let e=0;e0){const i=t.toArray(),e=i.length;for(let s=0;s1)&&(this.clearHighlighteds(),t.isHighlighted=!0)}highlightCollection(t){const i=new GSet().addAll(t),s=this.highlighteds.copy().removeAll(i).iterator;for(;s.next();){const o=s.value;o.isHighlighted=!1}const n=i.iterator;for(;n.next();){const o=n.value;o instanceof Part||Util.o("Diagram.highlightCollection given something that is not a Part: "+o),o.isHighlighted=!0}}scroll(t,i,e){e===void 0&&(e=1);const s=i==="up"||i==="down";let n=0;const o=Point.l();if(t==="pixel")n=e;else if(t==="line")n=e*(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange);else if(t==="page"){let l=s?this.viewportBounds.height:this.viewportBounds.width;if(l*=this.scale,l!==0){const h=Math.max(l-(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange),0);n=e*h}}else if(t==="document"){const l=this.documentBounds,h=this.viewportBounds;i==="up"?this.position=o.e(h.x,l.y):i==="left"?this.position=o.e(l.x,h.y):i==="down"?this.position=o.e(h.x,l.bottom-h.height):i==="right"&&(this.position=o.e(l.right-h.width,h.y)),Point.s(o);return}else Util.o("scrolling unit must be 'pixel', 'line', 'page', or 'document', not: "+t);n/=this.scale;const r=this.position;i==="up"?this.position=o.e(r.x,r.y-n):i==="down"?this.position=o.e(r.x,r.y+n):i==="left"?this.position=o.e(r.x-n,r.y):i==="right"?this.position=o.e(r.x+n,r.y):Util.o("scrolling direction must be 'up', 'down', 'left', or 'right', not: "+i),Point.s(o)}scrollToRect(t){const i=this.viewportBounds;if(i.containsRect(t))return;const e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}centerRect(t){const i=this.viewportBounds,e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}transformDocToView(t){return t.copy().D(this.D)}transformViewToDoc(t){return t.copy().Ie(this.D)}AF(t){return t.Ie(this.D)}static None=1;static Uniform=2;static UniformToFill=3;static CycleAll=1;static CycleNotDirected=2;static CycleNotDirectedFast=3;static CycleNotUndirected=4;static CycleDestinationTree=5;static CycleSourceTree=6;static DocumentScroll=1;static InfiniteScroll=2;static TreeParentCollapsed=1;static AllParentsCollapsed=2;static AnyParentsCollapsed=3;get opacity(){return this.Wt}set opacity(t){const i=this.Wt;i!==t&&(Util.i(t,"number",Diagram,"opacity"),(t<0||t>1)&&Util._(t,"0 <= value <= 1",Diagram,"opacity"),this.Wt=t,this.t("opacity",i,t),this.C())}get validCycle(){return this.Rx}set validCycle(t){const i=this.Rx;i!==t&&(this.Rx=t,this.t("validCycle",i,t))}get layers(){return this.Gt.iterator}get isModelReadOnly(){const t=this.Mi;return t===null?!1:t.isReadOnly}set isModelReadOnly(t){const i=this.Mi;i!==null&&(i.isReadOnly=t)}get isReadOnly(){return this.vo}set isReadOnly(t){const i=this.vo;i!==t&&(Util.i(t,"boolean",Diagram,"isReadOnly"),this.vo=t,this.t("isReadOnly",i,t))}get isEnabled(){return this.Oi}set isEnabled(t){const i=this.Oi;i!==t&&(Util.i(t,"boolean",Diagram,"isEnabled"),this.Oi=t,this.t("isEnabled",i,t))}get allowClipboard(){return this.Vx}set allowClipboard(t){const i=this.Vx;i!==t&&(Util.i(t,"boolean",Diagram,"allowClipboard"),this.Vx=t,this.t("allowClipboard",i,t))}get allowCopy(){return this.Rl}set allowCopy(t){const i=this.Rl;i!==t&&(Util.i(t,"boolean",Diagram,"allowCopy"),this.Rl=t,this.t("allowCopy",i,t))}get allowDelete(){return this.vl}set allowDelete(t){const i=this.vl;i!==t&&(Util.i(t,"boolean",Diagram,"allowDelete"),this.vl=t,this.t("allowDelete",i,t))}get allowDragOut(){return this.zx}set allowDragOut(t){const i=this.zx;i!==t&&(Util.i(t,"boolean",Diagram,"allowDragOut"),this.zx=t,this.t("allowDragOut",i,t))}get allowDrop(){return this.Xx}set allowDrop(t){const i=this.Xx;i!==t&&(Util.i(t,"boolean",Diagram,"allowDrop"),this.Xx=t,this.t("allowDrop",i,t))}get allowTextEdit(){return this.Ol}set allowTextEdit(t){const i=this.Ol;i!==t&&(Util.i(t,"boolean",Diagram,"allowTextEdit"),this.Ol=t,this.t("allowTextEdit",i,t))}get allowGroup(){return this.Il}set allowGroup(t){const i=this.Il;i!==t&&(Util.i(t,"boolean",Diagram,"allowGroup"),this.Il=t,this.t("allowGroup",i,t))}get allowUngroup(){return this.El}set allowUngroup(t){const i=this.El;i!==t&&(Util.i(t,"boolean",Diagram,"allowUngroup"),this.El=t,this.t("allowUngroup",i,t))}get allowInsert(){return this.Kx}set allowInsert(t){const i=this.Kx;i!==t&&(Util.i(t,"boolean",Diagram,"allowInsert"),this.Kx=t,this.t("allowInsert",i,t))}get allowLink(){return this.Ul}set allowLink(t){const i=this.Ul;i!==t&&(Util.i(t,"boolean",Diagram,"allowLink"),this.Ul=t,this.t("allowLink",i,t))}get allowRelink(){return this.Bl}set allowRelink(t){const i=this.Bl;i!==t&&(Util.i(t,"boolean",Diagram,"allowRelink"),this.Bl=t,this.t("allowRelink",i,t))}get allowMove(){return this.Vl}set allowMove(t){const i=this.Vl;i!==t&&(Util.i(t,"boolean",Diagram,"allowMove"),this.Vl=t,this.t("allowMove",i,t))}get allowReshape(){return this.zl}set allowReshape(t){const i=this.zl;i!==t&&(Util.i(t,"boolean",Diagram,"allowReshape"),this.zl=t,this.t("allowReshape",i,t))}get allowResize(){return this.Xl}set allowResize(t){const i=this.Xl;i!==t&&(Util.i(t,"boolean",Diagram,"allowResize"),this.Xl=t,this.t("allowResize",i,t))}get allowRotate(){return this.Kl}set allowRotate(t){const i=this.Kl;i!==t&&(Util.i(t,"boolean",Diagram,"allowRotate"),this.Kl=t,this.t("allowRotate",i,t))}get allowSelect(){return this.Yl}set allowSelect(t){const i=this.Yl;i!==t&&(Util.i(t,"boolean",Diagram,"allowSelect"),this.Yl=t,this.t("allowSelect",i,t))}get allowUndo(){return this.Yx}set allowUndo(t){const i=this.Yx;i!==t&&(Util.i(t,"boolean",Diagram,"allowUndo"),this.Yx=t,this.t("allowUndo",i,t))}get allowZoom(){return this.Gx}set allowZoom(t){const i=this.Gx;i!==t&&(Util.i(t,"boolean",Diagram,"allowZoom"),this.Gx=t,this.t("allowZoom",i,t))}get hasVerticalScrollbar(){return this.Eu}set hasVerticalScrollbar(t){const i=this.Eu;i!==t&&(Util.i(t,"boolean",Diagram,"hasVerticalScrollbar"),this.Eu=t,this.oa(),this.C(),this.t("hasVerticalScrollbar",i,t),this.Bs(!1))}get hasHorizontalScrollbar(){return this.Iu}set hasHorizontalScrollbar(t){const i=this.Iu;i!==t&&(Util.i(t,"boolean",Diagram,"hasHorizontalScrollbar"),this.Iu=t,this.oa(),this.C(),this.t("hasHorizontalScrollbar",i,t),this.Bs(!1))}get allowHorizontalScroll(){return this.jx}set allowHorizontalScroll(t){const i=this.jx;i!==t&&(Util.i(t,"boolean",Diagram,"allowHorizontalScroll"),this.jx=t,this.t("allowHorizontalScroll",i,t),this.Bs(!1))}get allowVerticalScroll(){return this.Hx}set allowVerticalScroll(t){const i=this.Hx;i!==t&&(Util.i(t,"boolean",Diagram,"allowVerticalScroll"),this.Hx=t,this.t("allowVerticalScroll",i,t),this.Bs(!1))}get scrollHorizontalLineChange(){return this.qx}set scrollHorizontalLineChange(t){const i=this.qx;i!==t&&(Util.i(t,"number",Diagram,"scrollHorizontalLineChange"),t<0&&Util._(t,">= 0",Diagram,"scrollHorizontalLineChange"),this.qx=t,this.t("scrollHorizontalLineChange",i,t))}get scrollVerticalLineChange(){return this.Wx}set scrollVerticalLineChange(t){const i=this.Wx;i!==t&&(Util.i(t,"number",Diagram,"scrollVerticalLineChange"),t<0&&Util._(t,">= 0",Diagram,"scrollVerticalLineChange"),this.Wx=t,this.t("scrollVerticalLineChange",i,t))}get lastInput(){return this.Jh}set lastInput(t){this.Jh=t}get previousInput(){return this.Xr}set previousInput(t){this.Xr=t}get firstInput(){return this.Jm}set firstInput(t){this.Jm=t}get currentCursor(){return this.vx}set currentCursor(t){if(t===""&&(t=this.Km),this.vx!==t){Util.i(t,"string",Diagram,"currentCursor");const e=this.dt,s=this.Tt;if(e===null||s===null)return;this.vx=t;const n=e.style.cursor;e.style.cursor=t,s.style.cursor=t,e.style.cursor===n&&(e.style.cursor="-webkit-"+t,s.style.cursor="-webkit-"+t,e.style.cursor===n&&(e.style.cursor="-moz-"+t,s.style.cursor="-moz-"+t,e.style.cursor===n&&(e.style.cursor=t,s.style.cursor=t)))}}get defaultCursor(){return this.Km}set defaultCursor(t){t===""&&(t="auto");const i=this.Km;i!==t&&(Util.i(t,"string",Diagram,"defaultCursor"),this.Km=t,this.t("defaultCursor",i,t))}get click(){return this.Tr}set click(t){const i=this.Tr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"click"),this.Tr=t,this.t("click",i,t))}get doubleClick(){return this.Dr}set doubleClick(t){const i=this.Dr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"doubleClick"),this.Dr=t,this.t("doubleClick",i,t))}get contextClick(){return this.Fr}set contextClick(t){const i=this.Fr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"contextClick"),this.Fr=t,this.t("contextClick",i,t))}get mouseOver(){return this.Rr}set mouseOver(t){const i=this.Rr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseOver"),this.Rr=t,this.t("mouseOver",i,t))}get mouseHover(){return this.vr}set mouseHover(t){const i=this.vr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseHover"),this.vr=t,this.t("mouseHover",i,t))}get mouseHold(){return this.Or}set mouseHold(t){const i=this.Or;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseHold"),this.Or=t,this.t("mouseHold",i,t))}get mouseDragOver(){return this.Ox}set mouseDragOver(t){const i=this.Ox;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseDragOver"),this.Ox=t,this.t("mouseDragOver",i,t))}get mouseDrop(){return this.Ir}set mouseDrop(t){const i=this.Ir;i!==t&&(this.Ir=t,this.t("mouseDrop",i,t))}get handlesDragDropForTopLevelParts(){return this.Ix}set handlesDragDropForTopLevelParts(t){const i=this.Ix;i!==t&&(Util.i(t,"boolean",Diagram,"handlesDragDropForTopLevelParts"),this.Ix=t,this.t("handlesDragDropForTopLevelParts",i,t))}get mouseEnter(){return this.Er}set mouseEnter(t){const i=this.Er;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseEnter"),this.Er=t,this.t("mouseEnter",i,t))}get mouseLeave(){return this.Ur}set mouseLeave(t){const i=this.Ur;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseLeave"),this.Ur=t,this.t("mouseLeave",i,t))}get toolTip(){return this.Br}set toolTip(t){const i=this.Br;i!==t&&(this.Br=t,this.t("toolTip",i,t))}get contextMenu(){return this.Vr}set contextMenu(t){const i=this.Vr;i!==t&&(this.Vr=t,this.t("contextMenu",i,t))}get commandHandler(){return this.HM}set commandHandler(t){this.HM!==t&&(this.HM=t,t.To(this))}get toolManager(){return this.YM}set toolManager(t){this.YM!==t&&(this.YM=t,t.diagram=this)}get defaultTool(){return this.GM}set defaultTool(t){const i=this.GM;i!==t&&(this.GM=t,t.diagram=this,this.currentTool===i&&(this.currentTool=t))}get currentTool(){return this.jM}set currentTool(t){const i=this.jM;i&&(i.isActive&&i.doDeactivate(),i.cancelWaitAfter(),i.doStop()),t===null&&(t=this.defaultTool),t!==null&&(this.jM=t,t.diagram=this,t.doStart())}get selection(){return this._M}get maxSelectionCount(){return this.Qx}set maxSelectionCount(t){const i=this.Qx;if(i!==t)if(Util.i(t,"number",Diagram,"maxSelectionCount"),t>=0&&!isNaN(t)){if(this.Qx=t,this.t("maxSelectionCount",i,t),!this.undoManager.isUndoingRedoing){const e=this.selection.count-t;if(e>0){this.v("ChangingSelection",this.selection);const s=this.selection.toArray();for(let n=0;n= 0",Diagram,"maxSelectionCount")}get nodeSelectionAdornmentTemplate(){return this.Hm}set nodeSelectionAdornmentTemplate(t){const i=this.Hm;i!==t&&(this.Hm=t,this.t("nodeSelectionAdornmentTemplate",i,t))}get groupSelectionAdornmentTemplate(){return this.ib}set groupSelectionAdornmentTemplate(t){const i=this.ib;i!==t&&(this.ib=t,this.t("groupSelectionAdornmentTemplate",i,t))}get linkSelectionAdornmentTemplate(){return this.eb}set linkSelectionAdornmentTemplate(t){const i=this.eb;i!==t&&(this.eb=t,this.t("linkSelectionAdornmentTemplate",i,t))}get highlighteds(){return this.tS}get isModified(){const t=this.undoManager;return t.isEnabled?t.currentTransaction!==null?!0:this.Vu&&this.vs!==t.historyIndex:this.Vu}set isModified(t){if(this.Vu!==t){Util.i(t,"boolean",Diagram,"isModified"),this.Vu=t;const e=this.undoManager;!t&&e.isEnabled&&(this.vs=e.historyIndex),t||this.OL()}}OL(){const t=this.isModified;this.ZM!==t&&(this.ZM=t,this.v("Modified"))}get model(){return this.Mi}set model(t){const i=this.Mi;if(i!==t){this.currentTool.doCancel(),i&&i.undoManager!==t.undoManager&&i.undoManager.isInTransaction&&Util.o("Do not replace a Diagram.model while a transaction is in progress."),this.animationManager.stopAnimation(!0);const e=this.mL(!0);this.Jn=!1,this.Ou=!0,this.vs=-2,this.Pr=!1;const s=this.Ht;this.Ht=!0,this.animationManager.Fl("Model"),i&&(this.qn!==null&&this.qn.each(n=>i.removeChangedListener(n)),i.removeChangedListener(this.$M)),this.Mi=t,this.partManager=this.uR(this.Mi.type),this.initializePartManager(this.partManager);for(let n=0;nt.addChangedListener(n)),this.Ht=s,this.invalidateDocumentBounds(),this.Ht||this.C(),i&&t.undoManager.copyProperties(i.undoManager)}}get themeManager(){return this.gb}set themeManager(t){const i=this.gb;i!==t&&(i!==null&&i.removeDiagram(this),this.gb=t,t!==null&&t.addDiagram(this))}initializePartManager(t){}static gS(t,i){Diagram.aL.set(t,i)}static get licenseKey(){return Diagram.AS.last()}static set licenseKey(t){Diagram.AS.add(t.replace(/\s/g,""))}static get version(){return Diagram.dR}static AS=new List;static dR="3.0.11";uR(t){const i=Diagram.aL.get(t);return i!==null?new i:new PartManager}get Y(){return this.WM}set Y(t){this.WM=t}get mx(){return this.rL}gR(t){if(t.model!==this.model)return;const i=t.change,e=t.propertyName;if(i===1&&e[0]==="S"){if(e==="StartingFirstTransaction"){const s=this,n=this.toolManager;n.mouseDownTools.each(o=>o.diagram=s),n.mouseMoveTools.each(o=>o.diagram=s),n.mouseUpTools.each(o=>o.diagram=s),this.routers.each(o=>o.diagram=s),!this.ps&&!this.Jn&&(this.vc=!0,this.Ou&&(this.Pr=!0))}else if(e==="StartingUndo"||e==="StartingRedo"){const s=this.animationManager;this.skipsUndoManager||(s.defaultAnimation.isAnimating&&s.stopAnimation(),s.getBundleAnimation().isAnimating&&s.getBundleAnimation().stop()),this.v("ChangingSelection",this.selection)}else if(e==="StartedTransaction"){const s=this.animationManager;s.defaultAnimation.isAnimating&&!this.skipsUndoManager&&s.stopAnimation()}return}if(this.Y){this.Y=!1;try{if(t.modelChange===""&&i===1){(e==="FinishedUndo"||e==="FinishedRedo")&&(this.v("ChangedSelection",this.selection),this.Ci());const s=this.animationManager;e==="RolledBackTransaction"&&s.stopAnimation(),this.fR(),this.vc=!0,this.maybeUpdate(),(this.undoManager.transactionLevel===0||this.undoManager.transactionLevel===1)&&s.MM(),e==="CommittedTransaction"&&this.undoManager.isJustDiscarded&&(this.vs=Math.min(this.vs,this.undoManager.historyIndex-1)),(e==="CommittedTransaction"||e==="RolledBackTransaction")&&this.undoManager.Iw&&setTimeout(()=>{this.isModified=!1},1);const n=t.isTransactionFinished;if(n&&(this.OL(),this.mx.clear(),this.animationManager.uF()),!this.Ex&&n&&this.lastInput.targetDiagram){this.Ex=!0;const o=this;Util.vh(()=>{o.currentTool.standardMouseOver(),o.Ex=!1},10)}}}finally{this.Y=!0}}}get ce(){return this.qM}set ce(t){this.qM=t}get uc(){return this.Ux}set uc(t){this.Ux=t}SL(t){const i=t.L.r;for(const e of i)e instanceof Picture&&this.TS(e)}TS(t){const i=t.element;if(i===null||!(i instanceof HTMLImageElement)||(i.es instanceof GSet&&i.es.add(this),t.mR(),!i.f0))return;const e=i.getAttribute("src")||"",s=this.Jl.get(e);if(s===null){Picture.IL(t,i);const n=[];n.push(t),this.Jl.set(e,n)}else{for(let n=0;n0?(this.kx=t,this.t("minScale",i,t),t>this.scale&&(this.scale=t)):Util._(t,"> 0",Diagram,"minScale"))}get maxScale(){return this.Px}set maxScale(t){const i=this.Px;i!==t&&(t>0?(this.Px=t,this.t("maxScale",i,t),t 0",Diagram,"maxScale"))}get zoomPoint(){return this.Mx}set zoomPoint(t){this.Mx.equals(t)||(t=t.N(),this.Mx=t)}get contentAlignment(){return this.Fc}set contentAlignment(t){const i=this.Fc;i.equals(t)||(t=t.N(),this.Fc=t,this.t("contentAlignment",i,t),this.Bs(!1))}get initialContentAlignment(){return this.Vm}set initialContentAlignment(t){const i=this.Vm;i.equals(t)||(t=t.N(),this.Vm=t,this.t("initialContentAlignment",i,t))}get padding(){return this.$t}set padding(t){typeof t=="number"&&(t=new Margin(t));const i=this.$t;i.equals(t)||(t=t.N(),this.$t=t,this.invalidateDocumentBounds(),this.t("padding",i,t))}get partManager(){return this.oS}set partManager(t){const i=this.oS;i!==t&&(t.diagram!==null&&Util.o("Cannot share PartManagers between Diagrams: "+t.toString()),i&&i.To(null),this.oS=t,t.To(this))}get nodes(){return this.partManager.nodes.iterator}get links(){return this.partManager.links.iterator}get parts(){return this.partManager.parts.iterator}findTopLevelNodesAndLinks(){const t=new GSet,i=this.nodes;for(;i.next();){const s=i.value;s.isTopLevel&&t.add(s)}const e=this.links;for(;e.next();){const s=e.value;s.isTopLevel&&t.add(s)}return t.iterator}findTopLevelGroups(){return this.Yr.iterator}get routers(){return this.Vc}doLinkRouting(t){this.Fo=!0;const i=this.Vc.r;for(let e=0;e0){const l=this.computePartsBounds(n.memberParts,!1);l.inflate(20,20),s.kb(l)}const o=Rect.l(),r=n.memberParts;for(;r.next();){const l=r.value;l instanceof Node&&this.IS(l,e,o)}Rect.s(o)}s.la=n,s.RS=e,s.Eo=!1}else t&&s.XL();return s}get avoidanceCellSize(){return this.iS}set avoidanceCellSize(t){this.Hl=null,this.iS=new Size(Math.max(1,t.width),Math.max(1,t.height))}get avoidanceLimit(){return this.eS}set avoidanceLimit(t){this.eS=Math.max(1,t)}zL(t){return t.canAvoid()?t:t.containingGroup!==null?this.zL(t.containingGroup):null}IS(t,i,e){if(t===i||!t.isVisible())return;const s=t.canAvoid();if(s){const n=t.getAvoidableRect(e);this.Hl.wR(n.x,n.y,n.width,n.height)}if(t instanceof Group&&(!s||t.avoidableMembers)){const n=t.memberParts;for(;n.next();){const o=n.value;o instanceof Node&&this.IS(o,i,e)}}}ES(t){this.Hl!==null&&!this.Hl.Eo&&(t===void 0||t.canAvoid())&&(this.Hl.Eo=!0)}get autoScrollInterval(){return this.zm}set autoScrollInterval(t){const i=this.zm;i!==t&&(this.zm=t,this.t("autoScrollInterval",i,t))}get autoScrollRegion(){return this.Xm}set autoScrollRegion(t){typeof t=="number"&&(t=new Margin(t));const i=this.Xm;i.equals(t)||(t=t.N(),this.Xm=t,this.invalidateDocumentBounds(),this.t("autoScrollRegion",i,t))}doAutoScroll(t){this.Wm.a(t),this.computeAutoScrollPosition(this.Wm).equalsApprox(this.position)?this.stopAutoScroll():this.KL()}KL(){if(this.Rc!==-1)return;const t=this.zm,i=this;this.Rc=Util.vh(()=>{if(i.Rc===-1||(i.stopAutoScroll(),i.lastInput.event===null))return;const s=i.computeAutoScrollPosition(i.Wm);if(s.equalsApprox(i.position))return;i.position=s,i.lastInput.documentPoint=i.transformViewToDoc(i.Wm),i.doMouseMove(),i.$h=!0;const n=Rect.l();i.computeBounds(n),n.unionRect(i.documentBounds),i.EL(n),Rect.s(n),i.Be=!0,i.maybeUpdate(),i.KL()},t)}stopAutoScroll(){this.Rc!==-1&&(Util.Ig(this.Rc),this.Rc=-1)}computeAutoScrollPosition(t){let i=this.position;const e=this.Xm;if(e.top<=0&&e.left<=0&&e.right<=0&&e.bottom<=0)return i;const s=this.viewportBounds,n=this.scale,o=Rect.X(0,0,s.width*n,s.height*n),r=Point.X(0,0);if(t.x>=o.x&&t.xo.x+o.width-e.right&&this.allowHorizontalScroll){let l=Math.max(this.scrollHorizontalLineChange,1);l=l|0,r.x+=l,t.x>o.x+o.width-e.right/2&&(r.x+=l),t.x>o.x+o.width-e.right/4&&(r.x+=4*l)}if(t.y>=o.y&&t.yo.y+o.height-e.bottom&&this.allowVerticalScroll){let l=Math.max(this.scrollVerticalLineChange,1);l=l|0,r.y+=l,t.y>o.y+o.height-e.bottom/2&&(r.y+=l),t.y>o.y+o.height-e.bottom/4&&(r.y+=4*l)}return r.equalsApprox(Point.Po)||(i=new Point(i.x+r.x/n,i.y+r.y/n)),Rect.s(o),Point.s(r),i}makeSvg(t){this.Wl.has("SVG")||this.addRenderer("SVG",new SVGSurface(this,root.document));const i=new SVGSurface(this,root.document,!0);t===void 0&&(t={});const e=this;function s(n,o){const r=e.YL(n,"SVG",i),l=r!==null?r.svg:null;return typeof o=="function"?(o(l),null):l}return this.GL(s,t)}makeSVG(t){return this.makeSvg(t)}addRenderer(t,i){this.Wl.set(t,i)}removeRenderer(t){this.Wl.delete(t)}cacheGroupExternalLinks(t){this.dS=t,t||this.nodes.each(i=>{i instanceof Group&&(i.d0=null)})}GL(t,i){const e=i.callback;let s=!0;const o=this.Jl.iterator;for(;o.next();)if(!o.value[0].mn){s=!1;break}if(typeof e!="function"||s)return t(i,e,this);const r=this;function l(){const c=+new Date;for(s=!0,o.reset();o.next();)if(!o.value[0].mn){s=!1;break}if(s||c-a>h){t(i,e,r);return}root.requestAnimationFrame(l)}const h=i.callbackTimeout||300,a=+new Date;return root.requestAnimationFrame(()=>l()),null}makeImage(t){return Diagram.isUsingDOM()?(t===void 0&&(t={}),t.returnType="Image",this.makeImageData(t)):null}makeImageData(t){return t===void 0&&(t={}),this.GL(this.xR,t)}static img="image";xR(t,i,e){const s=e.YL(t,"canvas",null);if(s===null)return null;const n=s.B.canvas;let o=null;if(n!==null){let r=t.returnType;switch(r===void 0?r="string":r=r.toLowerCase(),r){case Diagram.img+"data":o=s.getImageData(0,0,n.width,n.height);break;case Diagram.img:const h=(t.document||document).createElement("img");h.src=n.toDataURL(t.type,t.details),o=h;break;case"blob":{const a=n;return typeof i!="function"&&(o="",Util.o('Error: Diagram.makeImageData called with "returnType: toBlob", but no required "callback" function property defined.')),typeof a.toBlob=="function"?(a.toBlob(i,t.type,t.details),"toBlob"):(i(null),null)}case"string":default:o=n.toDataURL(t.type,t.details)}}return typeof i=="function"?(i(o),null):o}static bR=!1;YL(t,i,e){if(this.animationManager.stopAnimation(),this.maybeUpdate(),this.dt===null)return null;typeof t!="object"&&Util.o("properties argument must be an Object.");let n=!1,o=t.size||null,r=t.scale||null;t.scale!==void 0&&isNaN(t.scale)&&(r="NaN");let l=t.maxSize;t.maxSize===void 0&&(n=!0,i==="SVG"?l=new Size(1/0,1/0):l=new Size(2e3,2e3));const h=t.position||null;let a=t.parts||null;Array.isArray(a)&&(a=new List(a));let c=t.padding===void 0?1:t.padding;const f=t.background||null;let u=t.omitTemporary;u===void 0&&(u=!0);const d=t.document||document,m=t.elementFinished||null;let g=t.showTemporary;g===void 0&&(g=!u);let p=t.showGrid;p===void 0&&(p=g),o!==null&&isNaN(o.width)&&isNaN(o.height)&&(o=null),typeof c=="number"?c=new Margin(c):c instanceof Margin||Util.o("MakeImage padding must be a Margin or a number."),c.left=Math.max(c.left,0),c.right=Math.max(c.right,0),c.top=Math.max(c.top,0),c.bottom=Math.max(c.bottom,0),this.Zt.clearContextCache(!0);const y=new CanvasSurface(null,d,void 0,!0),x=y.ai;if(!(o||r||a||h))return y.width=this.kt+Math.ceil(c.left+c.right),y.height=this.Pt+Math.ceil(c.top+c.bottom),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.ha=d,e.ju=m,this.wb(e.ai,c,new Size(y.width,y.height),this.st,this.ct,a,f,g,p),e.ai):(this.zu=!1,this.wb(x,c,new Size(y.width,y.height),this.st,this.ct,a,f,g,p),this.zu=!0,y.ai);const k=this.$m,b=this.documentBounds.copy();if(b.subtractMargin(this.$t),g){const A=this.Gt.r,D=A.length;for(let F=0;Fk?(r=k,N=b.width,T=b.height):(N=l.width,T=l.height)):(N=b.width*r,T=b.height*r):(r=k,N=b.width,T=b.height),c!==null?(N+=M,T+=L):c=new Margin(0),l!==null){let A=l.width,D=l.height;i!=="SVG"&&n&&Diagram.bR,isNaN(A)&&(A=2e3),isNaN(D)&&(D=2e3),isFinite(A)&&(N=Math.min(N,A)),isFinite(D)&&(T=Math.min(T,D))}return y.width=Math.ceil(N),y.height=Math.ceil(T),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.ha=d,e.ju=m,this.wb(e.ai,c,new Size(Math.ceil(N),Math.ceil(T)),r,P,a,f,g,p),e.ai):(this.zu=!1,this.wb(x,c,new Size(Math.ceil(N),Math.ceil(T)),r,P,a,f,g,p),this.zu=!0,y.ai)}static Yu=null;static jL="5da73c80a36555d4038e4972187c3cae51fd22";static uw=!1;static Ik=()=>{if(Diagram.jL[5]===void 0&&(Transform.prototype._e=Transform.prototype.ww),!Diagram.isUsingDOM())return;const t=root.document.createElement("canvas"),i=t.getContext("2d"),e=Util.Cs("7ca11abfd022028846");i[e]=Util.Cs("398c3597c01238");const s="7ca11abfd7330390",n=[Diagram.jL,Util.uw+"4ae6247590da4bb21c324ba3a84e385776",Transform.Ik+"fb236cdfda5de14c134ba1a95a2d4c7cc6f93c1387",Geo.za],o=10,r=0;for(let l=1;l<5;l++)i[Util.Cs(s)](Util.Cs(n[l-1]),o,l*15+r);i[e]=Util.Cs("39f046ebb36e4b");for(let l=1;l<5;l++)i[Util.Cs(s)](Util.Cs(n[l-1]),o,l*15+r);(n.length!==4||n[0][0]!=="5"||n[3][0]!=="7")&&(Transform.prototype._e=Transform.prototype.ww),Diagram.Yu=t}}class DiagramHelper{HL;qL;US;Ne;constructor(t){if(this.HL=null,this.qL="63ad05bbe23a1786468a4c741b6d2",this.US="@onz",this.qL===this._tk){this.US=!0,this.Ne=this.US;return}this.Ne=null}kR(t,i){let e="f";const s=root[Util.Cs("76a715b2f73f148a")][Util.Cs("72ba13b5")]||"",n=Util.Cs;if(this.Ne=!0,!Diagram.isUsingDOM())return;let o=Diagram[n("76a115b6ed251eaf4692")];if(!o){const l=s[n("76ad18b4f73e")];for(let a=s[n("73a612b6fb191d")](n("35e7"))+2;a=0&&ha[0]||h[0]===a[0]&&h[1]>=a[1]))continue;const c="73a612b6fb191d",f=root[n("74a900bae4370f8b51")][n("6fbb13a1c2311e8a57")].toLowerCase(),u=f[n(c)](n("3aad1ab6e022098b4dc4")),d=n(l[2]);if(u>-1){const S=f[n(c)](d.toLowerCase()+"/");if(this.Ne=!(S>-1&&S=0&&g-1),!this.Ne))return;const p=root[Util.Cs("76a715b2f73f148a")][Util.Cs("69ad17a1e03e")],y=p[n(c)](n("7fb002b6ed25128b4da25b2e"));if(y>-1&&(this.Ne=!(p[n(c)](d)>y),!this.Ne))return;const x=d;if(x[0]!=="#")continue;const k=root.document.createElement("div");let b=l[0].replace(/[A-Za-z]/g,"");for(;b.length<4;)b+="9";const P=b;b=b.substring(b.length-4);let M="";const L=["gsh","gsf"],C=["Header","Background","Display","Feedback"];if(M+=L[parseInt(b.substring(0,1),10)%2],M+=C[parseInt(b.substring(0,1),10)%4],k[n("79a417a0f0181a8946")]=M,root.document[n("78a712aa")]){root.document[n("78a712aa")][n("7bb806b6ed32388c4a875b")](k);const S=root.getComputedStyle(k).getPropertyValue(n("78a704b7e62456904c9b12701b6532a8")),N=root.getComputedStyle(k).getPropertyValue(n("75b817b0ea2202"));if(root.document[n("78a712aa")][n("68ad1bbcf533388c4a875b")](k),!S)continue;const T=root[n("77a902b0eb1b1e804a8a")],A="0."+parseInt(P,10)%100;if(N===A||S.indexOf(parseInt(x[1]+x[2],16))!==-1&&S.indexOf(parseInt(x[3]+x[4],16))!==-1){this.Ne=!1;return}else if(T&&T(n("32ae19a1e0331fc94084537c067a67fa59f1386b89d006")).matches){M="."+M;for(let D=0;D{const s=this.observed;if(s===null)return;const n=s.viewportBounds,o=this.lastInput.documentPoint;s.position=new Point(o.x-n.width/2,o.y-n.height/2)},this.zS=s=>{this.invalidateDocumentBounds(),this.m0()},this.XS=s=>{this.observed!==null&&(this.invalidateDocumentBounds(),this.C())},this.Cb=s=>{this.updateDelay<1?this.C():this.g0||(this.g0=!0,setTimeout(()=>this.redraw(),this.updateDelay))},this.KS=s=>{this.observed!==null&&this.m0()},this.autoScale=2,this.Ht=!1,i&&Object.assign(this,i),this}setupRouters(){}computePixelRatio(){return 1}redraw(){this.g0&&this.updateDelay>=1&&(this.g0=!1,this.PR()),super.redraw()}Gi(){if(this.Tt===null&&Util.o("No div specified"),this.dt===null&&Util.o("No canvas specified"),this.dt instanceof SVGSurface||(this.box.BM(),!this.Be))return;const t=this.observed;if(t===null||t.animationManager.defaultAnimation.isAnimating||!t.Eh)return;this.h0();const i=this.dt,e=this.Zt;if(e.clearContextCache(!0),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,i.width,i.height),this.updateDelay<1)this.JL();else if(this.Gc!==null){e.drawImage(this.Gc.Ft,0,0);const o=this.D;e.scale(this.Bi,this.Bi),e.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),e.commitTransform()}const s=this.Gt.r,n=s.length;for(let o=0;on.canDelete())}t.removeParts(i,!0),t.v("SelectionDeleted",i)}finally{t.commitTransaction("Delete"),t.v("ChangedSelection",t.selection),t.currentCursor=""}}canDeleteSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowDelete||t.selection.count===0)}copySelection(){const t=this.diagram;try{const i=new GSet,e=t.selection.iterator;for(;e.next();){const s=e.value;Part.sh(i,s,!0,this.copiesTree?1/0:0,this.copiesConnectedLinks,n=>n.canCopy())}this.copyToClipboard(i)}finally{}}canCopySelection(){const t=this.diagram;return!(!t.allowCopy||!t.allowClipboard||t.selection.count===0)}cutSelection(){this.copySelection(),this.deleteSelection()}canCutSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowCopy||!t.allowDelete||!t.allowClipboard||t.selection.count===0)}copyToClipboard(t){const i=this.diagram;let e=null;if(t===null)Diagram.gL();else{const s=i.model;let n=!1,o=!1,r=null;try{s.mc()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.dc()||s.Hu())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=i.copyParts(t,null,!0)}finally{s.mc()&&(s.copiesParentKeyOfNodeData=n),(s.dc()||s.Hu())&&(s.copiesGroupKeyOfNodeData=o),e=new List,e.addAll(r.iteratorValues),Diagram.s0=e,Diagram.mb=i.model.dataFormat}}i.v("ClipboardChanged",e)}pasteFromClipboard(){const t=new GSet,i=Diagram.s0;if(i===null)return t;const e=this.diagram;if(Diagram.mb!==e.model.dataFormat)return t;const s=e.model;let n=!1,o=!1,r=null;try{s.mc()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.dc()||s.Hu())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=e.copyParts(i,e,!1)}finally{s.mc()&&(s.copiesParentKeyOfNodeData=n),(s.dc()||s.Hu())&&(s.copiesGroupKeyOfNodeData=o);const l=r.iterator;for(;l.next();){const h=l.value,a=l.key;h.location.isReal()||(a.location.isReal()?h.location=a.location:!h.position.isReal()&&a.position.isReal()&&(h.position=a.position)),t.add(h)}}return t}pasteSelection(t){t===void 0&&(t=null);const i=this.diagram;try{i.currentCursor="wait",i.v("ChangingSelection",i.selection),i.startTransaction("Paste");const e=this.pasteFromClipboard();e.count>0&&i.clearSelection(!0);const s=e.iterator;for(;s.next();){const n=s.value;n.isSelected=!0}if(t!==null){const n=i.computePartsBounds(i.selection);if(n.isReal()){const o=this.computeEffectiveCollection(i.selection,i.fb);i.bP(o,new Point(t.x-n.centerX,t.y-n.centerY),i.fb,!1)}}i.v("ClipboardPasted",e)}finally{i.commitTransaction("Paste"),i.v("ChangedSelection",i.selection),i.currentCursor=""}}canPasteSelection(t){const i=this.diagram;return!(i.isReadOnly||i.isModelReadOnly||!i.allowInsert||!i.allowClipboard||Diagram.s0===null||Diagram.s0.count===0||Diagram.mb!==i.model.dataFormat)}undo(){this.diagram.undoManager.undo()}canUndo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canUndo()}redo(){this.diagram.undoManager.redo()}canRedo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canRedo()}decreaseZoom(t){t===void 0&&(t=1/this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canDecreaseZoom(t){t===void 0&&(t=1/this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}increaseZoom(t){t===void 0&&(t=this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canIncreaseZoom(t){t===void 0&&(t=this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}resetZoom(t){t===void 0&&(t=this.defaultScale);const i=this.diagram;ti.maxScale||(i.scale=t)}canResetZoom(t){t===void 0&&(t=this.defaultScale);const i=this.diagram;return ti.maxScale?!1:i.allowZoom}zoomToFit(){const t=this.diagram,i=t.animationManager;i.stopAnimation(),t.redraw();const e=t.position,s=t.scale;i.Fl("Zoom To Fit"),this.isZoomToFitRestoreEnabled&&s===this.Ab&&!isNaN(this.Lb)&&t.documentBounds.equals(this.Tb)?(t.scale=this.Lb,t.position=this.QS,this.Ab=NaN,this.Tb=Rect.pw):(this.Lb=s,this.QS=e.copy(),t.zoomToFit(),this.Ab=t.scale,this.Tb=t.documentBounds.copy()),i.MM()}canZoomToFit(){return this.diagram.allowZoom}scrollToPart(t){t===void 0&&(t=null);const i=this.diagram;if(i.ensureBounds(),t===null){try{this.Uo!==null&&(this.Uo.next()?t=this.Uo.value:this.Uo=null)}catch{this.Uo=null}t===null&&(i.highlighteds.count>0?this.Uo=i.highlighteds.iterator:i.selection.count>0&&(this.Uo=i.selection.iterator),this.Uo!==null&&this.Uo.next()&&(t=this.Uo.value))}if(t!==null){const e=i.animationManager;e.Fl("Scroll To Part");const s=this.scrollToPartPause;if(s>0){const n=this.jc(t,[t]);if(n.length===1)i.startTransaction(),i.centerRect(t.actualBounds),i.commitTransaction("Scroll To Part");else{const o=()=>{i.startTransaction();let l=n.pop();for(;n.length>0&&l instanceof Node&&l.isTreeExpanded&&(!(l instanceof Group)||l.isSubGraphExpanded);)l=n.pop();n.length>0?(l instanceof Part&&i.scrollToRect(l.actualBounds),l instanceof Node&&!l.isTreeExpanded&&(l.isTreeExpanded=!0),l instanceof Group&&!l.isSubGraphExpanded&&(l.isSubGraphExpanded=!0)):(l instanceof Part&&i.centerRect(l.actualBounds),i.removeDiagramListener("LayoutCompleted",r)),i.commitTransaction("Scroll To Part")},r=()=>{Util.vh(o,(e.isEnabled?e.duration:0)+s)};i.addDiagramListener("LayoutCompleted",r),o()}}else{const n=i.position.copy();i.centerRect(t.actualBounds),n.equalsApprox(i.position)&&e.stopAnimation()}}}jc(t,i){if(t.isVisible())return i;if(t instanceof Adornment)this.jc(t.adornedPart,i);else if(t instanceof Link){const e=t.fromNode;e!==null&&this.jc(e,i);const s=t.toNode;s!==null&&this.jc(s,i)}else{if(t instanceof Node){const s=t.labeledLink;s!==null&&this.jc(s,i);const n=t.findTreeParentNode();n!==null&&(!n.isTreeExpanded&&!n.wasTreeExpanded&&i.push(n),this.jc(n,i))}const e=t.containingGroup;e!==null&&(!e.isSubGraphExpanded&&!e.wasSubGraphExpanded&&i.push(e),this.jc(e,i))}return i}canScrollToPart(t){if(t===void 0&&(t=null),t!==null&&!(t instanceof Part))return!1;const i=this.diagram;return i.selection.count===0&&i.highlighteds.count===0?!1:i.allowHorizontalScroll&&i.allowVerticalScroll}collapseTree(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse Tree";try{i.startTransaction(e),i.animationManager.Fl(e);const n=new List;if(t!==null&&t.isTreeExpanded)t.collapseTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&r.isTreeExpanded&&(r.collapseTree(),n.add(r))}}i.v("TreeCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||!t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(!s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}expandTree(t){t===void 0&&(t=null);const i=this.diagram,e="Expand Tree";try{i.startTransaction(e),i.animationManager.Fl(e);const n=new List;if(t!==null&&!t.isTreeExpanded)t.expandTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&(r.isTreeExpanded||(r.expandTree(),n.add(r)))}}i.v("TreeExpanded",n)}finally{i.commitTransaction(e)}}canExpandTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}groupSelection(){const t=this.diagram,i=t.model;if(!i.Hc())return;const e=this.archetypeGroupData;if(e===null)return;let s=null;try{t.currentCursor="wait",t.v("ChangingSelection",t.selection),t.startTransaction("Group");const n=new List,o=t.selection.iterator;for(;o.next();){const h=o.value;h.Pe()&&h.canGroup()&&n.add(h)}const r=new List,l=n.iterator;for(;l.next();){const h=l.value;let a=!1;const c=n.iterator;for(;c.next();){const f=c.value;if(h.isMemberOf(f)){a=!0;break}}a||r.add(h)}if(r.count>0){let h=r.first().containingGroup;if(h!==null)for(;h!==null;){let a=!1;const c=r.iterator;for(;c.next();)if(!c.value.isMemberOf(h)){a=!0;break}if(a)h=h.containingGroup;else break}if(e instanceof Group)e.li(),s=e.copy(),s!==null&&t.add(s);else if(i.isGroupForData(e)){const a=i.copyNodeData(e);Util.wt(a)&&(i.addNodeData(a),s=t.findNodeForData(a))}if(s!==null){h!==null&&this.isValidMember(h,s)&&(s.containingGroup=h);const a=r.iterator;for(;a.next();){const c=a.value;this.isValidMember(s,c)&&(c.containingGroup=s)}t.clearSelection(!0),s.isSelected=!0}}t.v("SelectionGrouped",s)}finally{t.commitTransaction("Group"),t.v("ChangedSelection",t.selection),t.currentCursor=""}}canGroupSelection(){const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowGroup||!t.model.Hc()||this.archetypeGroupData===null)return!1;const e=t.selection.iterator;for(;e.next();){const s=e.value;if(s.Pe()&&s.canGroup())return!0}return!1}i2(t){const i=Util.ot();if(Array.isArray(t))t.forEach(n=>{n instanceof Link||n instanceof Part&&i.push(n)});else{const n=t.iterator;for(;n.next();){const o=n.value;o instanceof Link||o instanceof Part&&i.push(o)}}const e=new GSet,s=i.length;for(let n=0;n0){i.clearSelection(!0);const o=s.iterator;for(;o.next();){const r=o.value;r.expandSubGraph();const l=r.containingGroup,h=l!==null&&l.data!==null?e.getKeyForNodeData(l.data):void 0;n.addAll(r.memberParts);const a=n.iterator;for(;a.next();){const c=a.value;if(c.isSelected=!0,c instanceof Link)continue;const f=c.data;f!==null?e.setGroupForData(f,h):c.containingGroup=l}i.remove(r)}}i.v("SelectionUngrouped",s,n)}finally{i.commitTransaction("Ungroup"),i.v("ChangedSelection",i.selection),i.currentCursor=""}}canUngroupSelection(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowDelete||!i.allowUngroup||!i.model.Hc())return!1;if(t!==null){if(!(t instanceof Group))return!1;if(t.canUngroup())return!0}else{const s=i.selection.iterator;for(;s.next();){const n=s.value;if(n instanceof Group&&n.canUngroup())return!0}}return!1}addTopLevelParts(t,i){const e=this.i2(t);let s=!0;const n=e.iterator;for(;n.next();){const o=n.value;o.containingGroup!==null&&(!i||this.isValidMember(null,o)?o.containingGroup=null:s=!1)}return s}collapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse SubGraph";try{i.startTransaction(e),i.animationManager.Fl(e);const n=new List;if(t!==null&&t.isSubGraphExpanded)t.collapseSubGraph(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&r.isSubGraphExpanded&&(r.collapseSubGraph(),n.add(r))}}i.v("SubGraphCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||!t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&s.isSubGraphExpanded)return!0}}return!1}expandSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Expand SubGraph",s=new List;try{if(i.startTransaction(e),i.animationManager.Fl(e),t!==null&&!t.isSubGraphExpanded)t.expandSubGraph(),s.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&(r.isSubGraphExpanded||(r.expandSubGraph(),s.add(r)))}}i.v("SubGraphExpanded",s)}finally{for(const n of s)this.$L(i,n);t&&this.$L(i,t),i.commitTransaction(e)}}$L(t,i){for(const e of i.memberParts)e instanceof Node&&t.Nc(e,i)}canExpandSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&!s.isSubGraphExpanded)return!0}}return!1}editTextBlock(t){t===void 0&&(t=null);const i=this.diagram,e=i.toolManager.findTool("TextEditing");if(e!==null){if(t===null){let s=null;const n=i.selection.iterator;for(;n.next();){const o=n.value;if(o.canEdit()){s=o;break}}if(s===null)return;t=s.findInVisualTree(o=>o instanceof TextBlock&&o.editable)}t!==null&&(i.currentTool=null,e.textBlock=t,i.currentTool=e)}}canEditTextBlock(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowTextEdit||i.toolManager.findTool("TextEditing")===null)return!1;if(t!==null){if(!(t instanceof TextBlock))return!1;const e=t.part;if(e!==null&&e.canEdit())return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s.canEdit()&&(t=s.findInVisualTree(n=>n instanceof TextBlock&&n.editable),t!==null))return!0}}return!1}showContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");if(e===null)return;t===void 0&&(i.selection.count>0?t=i.selection.first():t=i);const s=e.findObjectWithContextMenu(t);if(s!==null){const n=i.lastInput;let o=null;if(s instanceof GraphObject)o=s.getDocumentPoint(Spot.Center);else if(!i.viewportBounds.containsPoint(n.documentPoint)){const r=i.viewportBounds;o=new Point(r.x+r.width/2,r.y+r.height/2)}if(o!==null){const r=new InputEvent;r.diagram=i,r.viewPoint=i.transformDocToView(o),r.documentPoint=o,r.button=2,r.up=!0,i.lastInput=r}i.currentTool=e,e.openMenu(!1,s)}}canShowContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");return!(e===null||(t===void 0&&(i.selection.count>0?t=i.selection.first():t=i),e.findObjectWithContextMenu(t)===null))}get copiesClipboardData(){return this.YS}set copiesClipboardData(t){Util.i(t,"boolean",CommandHandler,"copiesClipboardData"),this.YS=t}get copiesConnectedLinks(){return this.GS}set copiesConnectedLinks(t){Util.i(t,"boolean",CommandHandler,"copiesConnectedLinks"),this.GS=t}get deletesConnectedLinks(){return this.jS}set deletesConnectedLinks(t){Util.i(t,"boolean",CommandHandler,"deletesConnectedLinks"),this.jS=t}get copiesTree(){return this.HS}set copiesTree(t){Util.i(t,"boolean",CommandHandler,"copiesTree"),this.HS=t}get deletesTree(){return this.qS}set deletesTree(t){Util.i(t,"boolean",CommandHandler,"deletesTree"),this.qS=t}get copiesParentKey(){return this.WS}set copiesParentKey(t){Util.i(t,"boolean",CommandHandler,"copiesParentKey"),this.WS=t}get copiesGroupKey(){return this.JS}set copiesGroupKey(t){Util.i(t,"boolean",CommandHandler,"copiesGroupKey"),this.JS=t}get archetypeGroupData(){return this.$S}set archetypeGroupData(t){t!==null&&Util.i(t,"object",CommandHandler,"archetypeGroupData");const i=this.diagram;this.$S=t}get memberValidation(){return this.eh}set memberValidation(t){t!==null&&Util.i(t,"function",CommandHandler,"memberValidation"),this.eh=t}get defaultScale(){return this.diagram.defaultScale}set defaultScale(t){this.diagram.defaultScale=t}get zoomFactor(){return this.ZS}set zoomFactor(t){t>1||Util.o("zoomFactor must be larger than 1.0, not: "+t),this.ZS=t}get isZoomToFitRestoreEnabled(){return this._S}set isZoomToFitRestoreEnabled(t){Util.i(t,"boolean",CommandHandler,"isZoomToFitRestoreEnabled"),this._S=t}get scrollToPartPause(){return this.t2}set scrollToPartPause(t){this.t2=t}computeEffectiveCollection(t,i){const e=this.diagram,s=e.toolManager.findTool("Dragging"),n=e.currentTool===s;i===void 0&&(i=e.c0());const o=new GMap;if(t===null)return o;let r=t.iterator;for(;r.next();){const l=r.value;e.Wr(o,l,n,i)}if(e.draggedLink!==null&&i.dragsLink)return o;for(r=t.iterator;r.next();){const l=r.value;if(l instanceof Link){const h=l.fromNode;if(h!==null&&!o.has(h))o.delete(l);else{const a=l.toNode;a!==null&&!o.has(a)&&o.delete(l)}}}return o}}var Stretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Vertical=4]="Vertical",w[w.Horizontal=5]="Horizontal",w[w.Fill=2]="Fill",w))(Stretch||{}),Orientation=(w=>(w[w.None=0]="None",w[w.Along=21]="Along",w[w.Plus90=22]="Plus90",w[w.Minus90=23]="Minus90",w[w.Opposite=24]="Opposite",w[w.Upright=25]="Upright",w[w.Plus90Upright=26]="Plus90Upright",w[w.Minus90Upright=27]="Minus90Upright",w[w.Upright45=28]="Upright45",w))(Orientation||{}),Flip=(w=>(w[w.None=0]="None",w[w.Vertical=1]="Vertical",w[w.Horizontal=2]="Horizontal",w[w.Both=3]="Both",w))(Flip||{});class GraphObject{n;qu;Wu;Bo;f;nh;q;ct;ee;Wt;Ju;Vs;Ct;ze;$r;oh;bi;aa;st;Xt;Zr;Li;Vi;$u;ni;qc;Ut;si;Qr;e2;Zu;constructor(){GSet.Yi(this),this.n=30723,this.Wt=1,this.Ju="",this.Vs=null,this.Ct=null,this.ct=new Point(NaN,NaN).g(),this.ze=Size.gw,this.$r=new Transform,this.oh=new Transform,this.bi=null,this.aa=1,this.st=1,this.Xt=0,this.Zr=Margin.Ug,this.ee=new Rect(NaN,NaN,NaN,NaN).g(),this.Li=new Rect(NaN,NaN,NaN,NaN).g(),this.Vi=new Rect(0,0,NaN,NaN).g(),this.$u=null,this.qu=null,this.q=null,this.ni=Spot.Default,this.qc=Spot.Default,this.Wu=0,this.Bo=0,this.Ut=null,this.f=null,this.nh=null,this.si=null,this.e2=null,this.Qr=null,this.Zu=null}cloneProtected(t){t.n=(this.n|2048|4096)&-32769,t.Wt=this.Wt,t.Ju=this.Ju,t.Ct=this.Ct,t.ct.a(this.ct),t.ze=this.ze.N(),this.bi!==null?t.bi=this.bi.copy():t.bi=null,t.st=this.st,t.Xt=this.Xt,t.Zr=this.Zr.N(),t.ee.a(this.ee),t.Li.a(this.Li),t.Vi.a(this.Vi),t.qu=this.qu,this.q!==null&&(t.q=this.q.copy()),t.ni=this.ni.N(),t.qc=this.qc.N(),t.Wu=this.Wu,t.Bo=this.Bo,this.Ut!==null&&(t.Ut=this.Ut.copy()),this.f!==null&&(this.f.gi?t.f=this.f:t.f=this.f.copy()),this.nh!==null&&(t.nh=this.nh.slice()),this.si!==null&&(t.si=this.si.copy())}addCopyProperty(t){let i=this.nh;if(!Array.isArray(i))i=[],this.nh=i;else for(let e=0;e{d.data!==null&&d.s2()&&d.updateTargetBindings(i)})}}}}mF(t){this.Zu.delete(t)}Io(){if(this.diagram===null)return;if(this.findBindingPanel()===null&&this.Ai!==null){const i=this.Ai.iterator;for(;i.next();){const e=i.value;if(!e.isToTheme)continue;let s=null;const n=e.sourceName;e.isToObject&&(s=this.ZL(n));let o=this;const r=e.targetId;r!==-1&&(o=this.p0(r),o===null)||(n==="/"?s=o.part:n==="."?s=o:n===".."&&(s=o.panel),e.updateTarget(o,s))}}}pa(t,i){const e=this.findBindingPanel();if(e!==null){const s=this.Ai.iterator;for(;s.next();){const n=s.value;let o=null;if(n.isToObject){if(o=n.QL(e,this),o===null)continue;n.updateSource(this,o,i,null)}else if(n.isToModel){const r=t.diagram;r!==null&&!r.ce&&n.updateSource(this,r.model.modelData,i,e)}else if(!n.isToTheme){const r=e.data;if(r===null)continue;const l=t.diagram;l!==null&&!l.ce&&n.updateSource(this,r,i,e)}if(o===this){const r=n.targetId,l=e.p0(r);l!==null&&n.updateTarget(l,o,i)}}}}p0(t){return this.$n===t?this:null}ZL(t){let i;return t===""?i=this:t==="/"?i=this:t==="."?i=this:t===".."?i=this:i=this.part.findObject(t),i}get $n(){return this.f!==null?this.f.$n:-1}set $n(t){this.$n!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.$n=t)}get Ai(){return this.f!==null?this.f.Ai:null}set Ai(t){this.Ai!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.Ai=t)}get Zn(){return this.f!==null?this.f.Zn:null}set Zn(t){this.Zn!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.Zn=t)}raiseChanged(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}t(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}Qn(t,i,e,s){const n=this.ee;if(n.e(t,i,e,s),this.st!==1||this.Xt!==0){this.bi===null&&(this.bi=new Transform);const o=this.bi;o.Ri(),this.y0(o,t,i,e,s),o.xw(n)}}_L(t,i,e){return this.pickable===!1?!1:(e.tc(this.D),i?this.intersectsRect(t,e):this.containedInRect(t,e))}tA(t,i,e){if(this.pickable===!1)return!1;const s=this.naturalBounds,n=t.distanceSquaredPoint(i);return e?Point.distanceLineSegmentSquared(t.x,t.y,0,0,0,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,0,s.height,s.width,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,s.height,s.width,0)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,0,0,0)<=n:t.distanceSquared(0,0)<=n&&t.distanceSquared(0,s.height)<=n&&t.distanceSquared(s.width,0)<=n&&t.distanceSquared(s.width,s.height)<=n}pn(){return!0}containsPoint(t){const i=Point.l();i.a(t),this.D.xt(i);const e=this.actualBounds;if(!e.isReal())return Point.s(i),!1;const s=this.diagram;if(s!==null&&s.Qm){const o=s.getInputOption("extraTouchThreshold"),r=s.getInputOption("extraTouchArea"),l=r/2,h=this.naturalBounds,a=this.getDocumentScale()*s.scale,c=1/a;if(h.width*ae&&(f=t),isFinite(i)&&i>s&&(u=i);break;case 5:isFinite(t)&&t>e&&(f=t),u=0,d&&(i=1/0);break;case 4:isFinite(i)&&i>s&&(u=i),f=0,d&&(t=1/0);break}const g=this.maxSize,p=this.minSize;f>g.width&&p.widthg.height&&p.heightu.height||this.mi>u.width)&&(r=!0)}}}r?this.n|=256:this.n&=-257,this.Li.isReal()||Util.o("Non-real actualBounds has been set. Object "+this+", actualBounds: "+this.Li.toString()),this.ed(o,this.Li),this._n(!1),Rect.s(o)}hh(t,i,e,s){}commonArrange(t,i,e,s){if(this.Li.e(t,i,e,s),this.desiredSize.isReal())return;const n=this.ee,o=this.Zr,r=o.right+o.left,l=o.top+o.bottom,h=n.width+r,a=n.height+l;e+=r,s+=l;let c=this.zs(!0);switch(h===e&&a===s&&(c=0),c){case 0:(h>e||a>s)&&(this.fe(!0),this.ut(h>e?e:h,a>s?s:a,0,0));break;case 2:this.fe(!0),this.ut(e,s,0,0);break;case 5:this.fe(!0),this.ut(e,a,0,0);break;case 4:this.fe(!0),this.ut(h,s,0,0);break}}ed(t,i){const e=this.part;e!==null&&e.diagram!==null&&((e.selectionObject===this||e.resizeObject===this||e.rotateObject===this)&&e.o2(!0),this.C(),!t.equalsApproxClose(i)&&(e.ah(),this.b0(e)))}b0(t){this.portId!==null&&(t.o2(!0),t instanceof Node&&t.iA(this))}get shadowVisible(){return this.f!==null?this.f.k0:null}set shadowVisible(t){const i=this.shadowVisible;i!==t&&(this.jt(),this.f.k0=t,this.ss(!0),this.C(),this.t("shadowVisible",i,t))}NR(t,i){const e=this.naturalBounds,s=this.oh,n=s.m11,o=s.m21,r=s.dx,l=s.m12,h=s.m22,a=s.dy;let c=0,f=0,u=c,d=f;c=u*n+d*o+r,f=u*l+d*h+a;let m=c,g=f,p=0,y=0;u=e.width+i,d=0,c=u*n+d*o+r,f=u*l+d*h+a;let x=Math.min(m,c),k=Math.min(g,f);p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-k,m=x,g=k,u=e.width+i,d=e.height+i,c=u*n+d*o+r,f=u*l+d*h+a,x=Math.min(m,c),k=Math.min(g,f),p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-k,m=x,g=k,u=0,d=e.height+i,c=u*n+d*o+r,f=u*l+d*h+a,x=Math.min(m,c),k=Math.min(g,f),p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-k,m=x,g=k;const b=t.viewportBounds,P=b.x,M=b.y,L=b.width,C=b.height;return m>L+P||P>p+m||g>C+M||M>y+g}Gi(t,i){if(this.CR(t,i)||!this.visible)return;const e=this.opacity;if(e===0)return;let s=1;e!==1&&(s=t.globalAlpha,t.globalAlpha=s*e);let n="";this.filter!==""&&(n=t.filter,t.filter=this.filter);const o=this.D,r=this.panel;this.w0()===!0&&this.Fb();const l=this.part;let h=!1,a=0;if(l&&i.getRenderingHint("drawShadows")&&(h=l.isShadowed,h)){const g=l.shadowOffset;a=Math.max(g.y,g.x)*i.scale*i.Bi}const c=this instanceof Panel&&this._r(),f=this.Li;if(c&&(this.eA(h,t,!1,r),this.LR(t,i),this.sA(h,t,!1,r),this.nA(h,t,!1)),c||!c&&(f.width===0||f.height===0||isNaN(f.x)||isNaN(f.y))){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}const u=this.Xs();if(!i.Zh&&u&&this.NR(i,a)){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}let d=(this.n&256)!==0;if(t.clipInsteadOfFill&&(d=!1),this instanceof TextBlock&&(t.font=this.font),d){const g=r.pn()?r.naturalBounds:r.actualBounds;let p=Math.max(f.x,g.x),y=Math.max(f.y,g.y),x=Math.min(f.right,g.right)-p,k=Math.min(f.bottom,g.bottom)-y;const b=this.si;if(b!==null&&(p=b.x,y=b.y,x=b.width,k=b.height),p>f.width+f.x||f.x>g.width+g.x){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}t.save(),t.beginPath(),t.rect(p,y,x,k),t.clip()}if(u){if(!l.isVisible()){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}if(h){const g=l.shadowOffset;t.shadowsSet(g.x*i.scale*this.scale*i.Bi,g.y*i.scale*this.scale*i.Bi,l.shadowBlur),t.shadowsOn(),t.shadowColor=l.shadowColor}}const m=this.naturalBounds;if(t.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.eA(h,t,u,r),this.Ct!==null&&(t.commitTransform(),this.Rb(t,m,f)),this.sA(h,t,u,r),this.ch(t,i),this.nA(h,t,u),d&&(t.restore(),t.clearContextCache(this instanceof Panel)),!o.Ok()){const g=1/(o.m11*o.m22-o.m12*o.m21);t.transform(o.m22*g,-o.m12*g,-o.m21*g,o.m11*g,g*(o.m21*o.dy-o.m22*o.dx),g*(o.m12*o.dx-o.m11*o.dy))}e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n)}eA(t,i,e,s){t&&this.shadowVisible===!0?i.shadowsOn():t&&this.shadowVisible===!1&&i.shadowsOff(),t&&this.vb(s)&&this.shadowVisible===null&&i.shadowsOff()}sA(t,i,e,s){t&&(this.Ct!==null||this.vb(s))?(this.Ob(!0),this.shadowVisible===null&&i.shadowsOff()):this.Ob(!1)}nA(t,i,e){t&&this.l2()===!0&&i.shadowsOn(),e&&t&&i.shadowsOff()}AR(t,i,e){const s=this.part;let n=!1;s&&t.getRenderingHint("drawShadows")&&(n=s.isShadowed),i.clipInsteadOfFill&&(n=!1),this.Xs()&&n&&i.shadowsOn(),n&&this.shadowVisible===!0?i.shadowsOn():n&&this.shadowVisible===!1&&i.shadowsOff();const o=this.panel;if(n&&this.vb(o)&&this.shadowVisible===null&&i.shadowsOff(),i.tl){const r=t.computePixelRatio(),l=`drop-shadow(${i.shadowOffsetX/r}px ${i.shadowOffsetY/r}px ${i.shadowBlur/r/2}px ${i.shadowColor})`;this.background!==null&&e.Ct.setAttributeNS(null,"filter",l)}return n&&(this.Ct!==null||this.vb(o))?(this.Ob(!0),this.shadowVisible===null&&i.shadowsOff()):this.Ob(!1),n}TR(t,i,e,s){if(e.tl){const n=i.computePixelRatio(),o=`drop-shadow(${e.shadowOffsetX/n}px ${e.shadowOffsetY/n}px ${e.shadowBlur/n/2}px ${e.shadowColor})`;this.h2(t,o)}s&&this.l2()===!0&&e.shadowsOn(),this.Xs()&&e.shadowsOff()}vb(t){return t===null?!1:(t._r()&&(t=t.panel),t.l2()||(t.type===Panel.Auto||t.type===Panel.Spot)&&t.findMainElement()!==this)}h2(t,i){}Rb(t,i,e){const s=this.Db(),n=i.x,o=i.y,r=i.width+s,l=i.height+s;this.dn(t,this.Ct,!0,!1,i,e),this.Ct instanceof Brush&&this.Ct.type===3?(t.beginPath(),t.rect(n-s/2,o-s/2,r,l),t.fillContext(this.Ct,!1,null)):t.fillRect(n-s/2,o-s/2,r,l)}oA(t,i){let e=t.DR(this);if(e!==-1)if(e===0)if(t.svg.Ct)t.svg.Ct.after(i);else if(t.type===Panel.Table){const s=t.svg.getElementsByClassName("gojs-ts"),n=s.length!==0?s[0]:null;n!==null&&n.after(i)}else t.svg.prepend(i);else{for(;e!==0&&!t.elt(e-1).isVisibleObject();)e--;if(e===0)t.svg.prepend(i);else{const s=t.elt(e-1).svg;s!==null?s.after(i):t.svg.appendChild(i)}}}CR(t,i){if(!(t instanceof SVGContext))return!1;if(!this.visible||this.opacity===0)return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;if(this.Xs()&&!this.isVisible())return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;const e=this.panel,s=this.sd(t);if(this.Zc(t,i,s))return this.rA(this.svg),this.svg.parentElement!==null?(this.Xs()&&(t.lastDrawnPart=this.svg),!0):(this.Xs()?(t.lastDrawnPart!==null?t.lastDrawnPart.after(this.svg):t.diagramGroup.prepend(this.svg),t.lastDrawnPart=this.svg):e&&this.oA(e,this.svg),!0);if(this.Xs()&&this.isShadowed){const m=this.shadowOffset;t.shadowsSet(m.x*i.scale*this.scale*i.Bi,m.y*i.scale*this.scale*i.Bi,this.shadowBlur),t.shadowsOn(),t.shadowColor=this.shadowColor}this instanceof TextBlock&&(t.font=this.font),t.currentElement=null;const n=this.D,o=this instanceof Panel,r=this instanceof Panel?this._r():!1,l=this.svg;this.w0()===!0&&this.Fb();const h=this.Li;t.setCurrentTransform(1,0,0,1,0,0),t.outerGroup=!1,s&&(t.outerGroup=!0,o&&r?(t.newGroup(1,0,0,1,0,0),this.svg=t.lastCreatedElement):o?(t.newGroup(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.svg=t.lastCreatedElement):t.newGroup(1,0,0,1,0,0));const a=this.naturalBounds;o||t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.background!==null&&(o?(r&&t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.Rb(t,a,h),r&&t.setCurrentTransform(1,0,0,1,0,0)):(t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.Rb(t,a,h)),t.currentElement.Ct=t.lastCreatedElement,t.currentElement.prepend(t.lastCreatedElement));const c=this.AR(i,t,t.currentElement);this.ch(t,i),o&&t.endGroup(),t.outerGroup&&t.endGroup();const f=t.surface.ju,u=o?this.svg:t.currentElement;if(!o&&l!==null&&u!==l&&l.parentNode===this.panel.svg){const m=this.svg.getAttribute("filter");return m!==null&&u.setAttribute("filter",m),this.svg.replaceWith(u),this.svg=u,u!==null&&this.P0(t,e,h,u),this.lA(t,l),!0}if(this.svg=u,f!==null&&u===null&&t.dummyGroup(),u===null)return!0;this.P0(t,e,h,u),this.TR(u,i,t,c);const d=this.Xs()?this.opacity*t.globalAlpha:this.opacity;if(d!==1&&u.setAttributeNS(null,"opacity",d.toString()),this.filter!==""&&u.setAttributeNS(null,"filter",this.filter),this.Xs()){if(l!==null&&u!==l&&l.parentNode===t.diagramGroup){const m=l.getAttribute("filter");m!==null&&u.setAttribute("filter",m),l.replaceWith(u)}else t.lastDrawnPart?t.lastDrawnPart.after(u):t.diagramGroup.prepend(u);t.lastDrawnPart=u}else e!==null&&this.oA(e,u);return f!==null&&f(this,u),this.rA(u),!0}rA(t){const i=this,e=t.dataset;i instanceof GraphObject&&(i.portId!==null&&(e.portId=i.portId),i instanceof Panel&&(isNaN(i.itemIndex)||(e.itemIndex=i.itemIndex.toString()),i instanceof Part&&(e.className=Util.sn(i),i.key!==void 0&&(e.key=i.key.toString()),i.containingGroup!==null&&(e.group=i.containingGroup.key.toString()),i instanceof Link&&(i.fromNode!==null&&i.fromNode.key!==void 0&&(e.fromKey=i.fromNode.key.toString()),i.fromPortId!==""&&(e.fromPortId=i.fromPortId),i.toNode!==null&&i.toNode.key!==void 0&&(e.toKey=i.toNode.key.toString()),i.toPortId!==""&&(e.toPortId=i.toPortId)))))}P0(t,i,e,s){let n=(this.n&256)!==0;if(t.clipInsteadOfFill&&(n=!1),!n){s.removeAttributeNS(null,"clip-path"),this.lA(t,s);return}const o=i.pn()?i.naturalBounds:i.actualBounds;let r=Math.max(e.x,o.x),l=Math.max(e.y,o.y),h=Math.min(e.right,o.right)-r,a=Math.min(e.bottom,o.bottom)-l;const c=this.si;c!==null&&(r=c.x,l=c.y,h=c.width,a=c.height);const f=s.getAttribute("clip-path");let u=null;if(f!==null&&(u=t.svg.getElementById(f.split("#")[1].slice(0,-1))),u===null){const d="CLIP"+GSet.nu++,m={id:d},g=t.makeElement("clipPath",m),p=t.makeElement("rect",{x:r,y:l,width:h,height:a});if(this instanceof Panel){const y=this.D.copy().yw();p.setAttribute("transform",`matrix(${y.m11}, ${y.m12}, ${y.m21}, ${y.m22}, ${y.dx}, ${y.dy})`)}g.appendChild(p),t.svg.appendChild(g),s.setAttributeNS(null,"clip-path","url(#"+d+")")}else{const d=u.firstElementChild;d.setAttribute("x",r.toString()),d.setAttribute("y",l.toString()),d.setAttribute("width",h.toString()),d.setAttribute("height",a.toString())}}lA(t,i){const e=i.getAttribute("clip-path");if(e===null)return;const s=t.svg.getElementById(e.split("#")[1].slice(0,-1));s!==null&&s.remove()}FR(){if(this.svg===null)return;const t=this.svg.innerHTML.match(/url\(#((CLIP|GRAD).+?)\)/g),i=this.svg.ownerDocument;if(t!==null)for(const e of t){const s=i.getElementById(e.split("#")[1].slice(0,-1));s!==null&&s.remove()}this.svg.remove()}LR(t,i){const e=this.Li,s=this.Vi,n=this.Ct;n!==null&&t.commitTransform(),n!==null&&(this.dn(t,n,!0,!1,s,e),n instanceof Brush&&n.type===3?(t.beginPath(),t.rect(e.x,e.y,e.width,e.height),t.fillContext(n,!1,null)):t.fillRect(e.x,e.y,e.width,e.height)),this.ch(t,i)}ch(t,i){}a2(){this.ss(!0)}Zc(t,i,e){const s=this.svg;if(this.RR()){if(this.a2(),this.ss(!1),s===null)return!1;const a=this.svg.getAttribute("clip-path");if(a!==null){const c=t.svg.getElementById(a.split("#")[1].slice(0,-1));c!==null&&c.remove()}return!1}if(s===null)return!1;if(!this.visible)return s.remove(),!1;if(s.nodeName!=="g"&&e||s.nodeName==="g"&&!e)return!1;const n=this.D,o="matrix("+n.m11+", "+n.m12+", "+n.m21+", "+n.m22+", "+n.dx+", "+n.dy+")",r=this instanceof Panel,l=this instanceof Panel?this._r():!1;if(!(r&&l))if(this instanceof Picture){const a=this.Ib;t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),a!==null&&t.amendImageTransform(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]),e?s.lastElementChild.setAttributeNS(null,"transform",t.getCurrentTransform()):s.setAttributeNS(null,"transform",t.getCurrentTransform())}else if(e&&!(this instanceof Panel))if(this instanceof Shape){const a=s.getElementsByTagName("path");for(let c=0;c=.1;){if(g){for(l=o[d++%h],l-=r;l<0;)l+=o[d++%h],m=!m;g=!1}else l=o[d++%h];l>u&&(l=u);let p=Math.sqrt(l*l/(1+f*f));a<0&&(p=-p),i+=p,e+=f*p,m?t.lineTo(i,e):t.moveTo(i,e),u-=l,m=!m}}dn(t,i,e,s,n,o){let r=1,l=1;if(typeof i=="string"){e?t.fillStyle=i:t.strokeStyle=i;return}else if(i.type===1){e?t.fillStyle=i.color:t.strokeStyle=i.color;return}let h;const a=this.Db();r=n.width,l=n.height,s?(r=o.width,l=o.height):e||(r+=a,l+=a);const c=t instanceof CanvasSurfaceContext;if(c&&i.yn&&(i.type===4||i.Qc===r&&i.Eb===l))h=i.yn;else{let f=0,u=0,d=0,m=0,g=0,p=0,y=0,x=0;if(s?(y=o.x,x=o.y):e||(y-=a/2,x-=a/2),f=i.start.x*r+i.start.offsetX+y,u=i.start.y*l+i.start.offsetY+x,d=i.end.x*r+i.end.offsetX+y,m=i.end.y*l+i.end.offsetY+x,i.type===2)h=t.createLinearGradient(f,u,d,m);else if(i.type===3)p=isNaN(i.endRadius)?Math.max(r,l)/2:i.endRadius,isNaN(i.startRadius)?(g=0,p=Math.max(r,l)/2):g=i.startRadius,h=t.createRadialGradient(f,u,g,d,m,p);else if(i.type===4)try{h=t.createPattern(i.pattern,"repeat")}catch{h=null}else Util.we(i.type,"Brush type");if(i.type!==4){const k=i.colorStops;if(k!==null){const b=k.iterator;for(;b.next();)h.addColorStop(b.key,b.value)}}if(c&&(i.yn=h,h!==null&&(i.Qc=r,i.Eb=l),h===null&&i.type===4&&i.Qc!==-1)){i.Qc=-1;const k=this.diagram;k!==null&&i.Qc===-1&&Util.vh(()=>{k.redraw()},600)}}e?t.fillStyle=h:t.strokeStyle=h}isContainedBy(t){return t instanceof Panel?this.vR(this,t):!1}vR(t,i){if(t===i||i===null)return!1;let e=t.panel;for(;e!==null;){if(e===i)return!0;e=e.panel}return!1}isVisibleObject(){if(!this.visible)return!1;const t=this.panel;return t!==null?t.isVisibleObject():!0}isEnabledObject(){let t=this instanceof Panel?this:this.panel;for(;t!==null&&t.isEnabled;)t=t.panel;return t===null}get enabledChanged(){return this.f!==null?this.f.M0:null}set enabledChanged(t){const i=this.enabledChanged;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"enabledChanged"),this.jt(),this.f.M0=t,this.t("enabledChanged",i,t))}Fb(){if(this.Ub()===!0){const t=this.$r;if(t.Ri(),!this.Li.isReal()||!this.ee.isReal()){this.nd(!1);return}if(t.Ds(this.Li.x-this.ee.x,this.Li.y-this.ee.y),this.scale!==1||this.angle!==0){const i=this.naturalBounds;this.y0(t,i.x,i.y,i.width,i.height)}this.nd(!1),this.ya(!0)}if(this.w0()===!0){const t=this.panel;if(t===null)this.oh.set(this.$r),this.aa=this.scale;else if(t.Es!==null){const i=this.oh;i.Ri(),t.pn()?i.tc(t.oh):t.panel!==null&&i.tc(t.panel.oh),i.tc(this.$r),this.aa=this.scale*t.aa}this.ya(!1)}}y0(t,i,e,s,n){if(this.st!==1&&t.st(this.st),this.Xt===0)return;const o=Point.l();o.setSpot(i,e,s,n,Spot.Center),t.cs(this.Xt,o.x,o.y),Point.s(o)}c(t){if(this.Oo())return;t===void 0&&(t=!1),this.fe(!0),this._n(!0);const i=this.panel;i!==null&&!t&&i.c()}_c(){this.Oo()||(this.fe(!0),this._n(!0))}tf(t){if(this.is())return;const i=this.panel;!t&&i!==null&&i.c(),this._n(!0)}td(){this.Ub()===!1&&(this.nd(!0),this.ya(!0))}c2(){this.ya(!0)}C(){const t=this.part;t!==null&&t.C()}zs(t){const i=this.stretch,e=this.panel;if(e===null)return this.zo(i===1?0:i,t);if(e.type===Panel.Table)return this.S0(e.getRowDefinition(this.row),e.getColumnDefinition(this.column),t);if(e.type===Panel.Auto&&e.findMainElement()===this)return this.zo(2,t);if(i===1){if(e.type===Panel.Spot&&e.findMainElement()===this)return this.zo(2,t);const s=e.defaultStretch;return s===1?this.zo(0,t):this.zo(s,t)}return this.zo(i,t)}S0(t,i,e){const s=this.stretch;if(s!==1)return this.zo(s,e);let n=null,o=null;switch(t.stretch){case 1:case 5:break;case 4:o=!0;break;case 2:o=!0;break}switch(i.stretch){case 1:case 4:break;case 5:n=!0;break;case 2:n=!0;break}const r=this.panel.defaultStretch;return n===null&&(n=r===5||r===2),o===null&&(o=r===4||r===2),n===!0&&o===!0?this.zo(2,e):n===!0?this.zo(5,e):o===!0?this.zo(4,e):this.zo(0,e)}zo(t,i){if(i)return t;if(t===0)return 0;const e=this.desiredSize;if(e.isReal())return 0;const s=!isNaN(e.width),n=!isNaN(e.height),o=this.angle;if(s)if(o!==90&&o!==270){if(t===5)return 0;if(t===2)return 4}else{if(t===4)return 0;if(t===2)return 5}if(n)if(o!==90&&o!==270){if(t===4)return 0;if(t===2)return 5}else{if(t===5)return 0;if(t===2)return 4}return t}get segmentOrientation(){return this.Ut!==null?this.Ut.N0:0}set segmentOrientation(t){const i=this.segmentOrientation;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.N0=t,this.c(),this.t("segmentOrientation",i,t),t===0&&(this.angle=0))}OR(){this.segmentOrientation=21}get segmentIndex(){return this.Ut!==null?this.Ut.C0:-1/0}set segmentIndex(t){t=Math.round(t);const i=this.segmentIndex;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.C0=t,this.c(),this.t("segmentIndex",i,t))}get segmentFraction(){return this.Ut!==null?this.Ut.L0:0}set segmentFraction(t){isNaN(t)||t<0?t=0:t>1&&(t=1);const i=this.segmentFraction;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.L0=t,this.c(),this.t("segmentFraction",i,t))}get segmentOffset(){return this.Ut!==null?this.Ut.A0:Point.Po}set segmentOffset(t){const i=this.segmentOffset;i.equals(t)||(t=t.N(),this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.A0=t,this.c(),this.t("segmentOffset",i,t))}get stretch(){return this.f!==null?this.f.to:1}set stretch(t){const i=this.stretch;i!==t&&(this.jt(),this.f.to=t,this.c(),this.t("stretch",i,t))}get name(){return this.f!==null?this.f.St:""}set name(t){const i=this.name;i!==t&&(this.jt(),this.f.St=t,this.part!==null&&this.part.T0(),this.t("name",i,t))}get opacity(){return this.Wt}set opacity(t){const i=this.Wt;if(i!==t){Util.i(t,"number",GraphObject,"opacity"),(t<0||t>1)&&Util._(t,"0 <= value <= 1",GraphObject,"opacity"),this.Wt=t,this.t("opacity",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.C(s.jh(s.actualBounds))}}get filter(){return this.Ju}set filter(t){const i=this.Ju;if(i!==t){this.Ju=t,this.ss(!0),this.t("filter",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.C(s.jh(s.actualBounds))}}get visible(){return(this.n&1)!==0}set visible(t){const i=(this.n&1)!==0;if(i!==t){this.n=this.n^1,this.t("visible",i,t);const e=this.panel;e!==null?e.c():this.Xs()&&this.Ei(t),this.C(),this.hA()}}get pickable(){return(this.n&2)!==0}set pickable(t){const i=(this.n&2)!==0;i!==t&&(this.n=this.n^2,this.t("pickable",i,t))}get fromLinkableDuplicates(){return(this.n&4)!==0}set fromLinkableDuplicates(t){const i=(this.n&4)!==0;i!==t&&(this.n=this.n^4,this.t("fromLinkableDuplicates",i,t))}get fromLinkableSelfNode(){return(this.n&8)!==0}set fromLinkableSelfNode(t){const i=(this.n&8)!==0;i!==t&&(this.n=this.n^8,this.t("fromLinkableSelfNode",i,t))}get toLinkableDuplicates(){return(this.n&16)!==0}set toLinkableDuplicates(t){const i=(this.n&16)!==0;i!==t&&(this.n=this.n^16,this.t("toLinkableDuplicates",i,t))}get toLinkableSelfNode(){return(this.n&32)!==0}set toLinkableSelfNode(t){const i=(this.n&32)!==0;i!==t&&(this.n=this.n^32,this.t("toLinkableSelfNode",i,t))}get isPanelMain(){return(this.n&64)!==0}set isPanelMain(t){const i=(this.n&64)!==0;i!==t&&(this.n=this.n^64,this.c(),this.t("isPanelMain",i,t))}get isActionable(){return(this.n&128)!==0}set isActionable(t){const i=(this.n&128)!==0;i!==t&&(this.n=this.n^128,this.t("isActionable",i,t))}get background(){return this.Ct}set background(t){const i=this.Ct;i!==t&&(t!==null&&Brush.od(t,"GraphObject.background"),t instanceof Brush&&t.g(),this.Ct=t,this.C(),this.t("background",i,t))}l2(){return(this.n&512)!==0}Ob(t){t?this.n|=512:this.n&=-513}Jc(){return(this.n&1024)!==0}f2(t){t?this.n|=1024:this.n&=-1025}Ub(){return(this.n&2048)!==0}nd(t){t?this.n|=2048:this.n&=-2049}w0(){return(this.n&4096)!==0}ya(t){t?this.n|=4096:this.n&=-4097}Oo(){return(this.n&8192)!==0}fe(t){t?this.n|=8192:this.n&=-8193}is(){return(this.n&16384)!==0}_n(t){t?this.n|=16384:this.n&=-16385}RR(){return(this.n&32768)!==0}ss(t){t?this.n|=32768:this.n&=-32769}get part(){if(this.Xs())return this;if(this.Qr!==null)return this.Qr;let t=this;for(t=t.panel;t;){if(t instanceof Part)return this.Qr=t,t;t=t.panel}return null}get svg(){return this.e2}set svg(t){this.e2=t}Fu(){this.svg=null}get panel(){return this.Vs}wa(t){this.Vs=t,this.svg!==null&&this.svg.remove()}get layer(){const t=this.part;return t!==null?t.layer:null}get diagram(){const t=this.part;return t!==null?t.diagram:null}get position(){return this.ct}set position(t){const i=t.x,e=t.y,s=this.ct,n=s.x,o=s.y;n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e))?(t=t.copy(),this.u2(t,n,o)&&this.t("position",new Point(n,o),t)):this.d2()}d2(){}u2(t,i,e){return this.ct=t,this.tf(),!0}xc(t,i,e){this.ct.x===t&&this.ct.y===i||(this.ct.e(t,i),this.td())}get actualBounds(){return this.Li}get scale(){return this.st}set scale(t){const i=this.st;i!==t&&(t<=0&&Util.o("GraphObject.scale for "+this+" must be greater than zero, not: "+t),this.st=t,this.c(),this.t("scale",i,t))}get angle(){return this.Xt}set angle(t){const i=this.Xt;if(i!==t){if(t=t%360,t<0&&(t+=360),i===t)return;this.Xt=t,this.hA(),this.c(),this.t("angle",i,t)}}get desiredSize(){return this.ze}set desiredSize(t){const i=t.width,e=t.height,s=this.ze,n=s.width,o=s.height;if((n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e)))&&(t=t.N(),this.ze=t,this.c(),this instanceof Shape&&this.ie(),this.t("desiredSize",s,t),this.Jc())){const r=this.part;r!==null&&(this.pa(r,"width"),this.pa(r,"height"))}}get width(){return this.ze.width}set width(t){const i=this.ze.width;if(i!==t&&(!isNaN(i)||!isNaN(t))){const e=this.ze,s=new Size(t,this.ze.height).g();if(this.ze=s,this.c(),this instanceof Shape&&this.ie(),this.t("desiredSize",e,s),this.Jc()){const n=this.part;n!==null&&this.pa(n,"width")}}}get height(){return this.ze.height}set height(t){const i=this.ze.height;if(i!==t&&(!isNaN(i)||!isNaN(t))){const e=this.ze,s=new Size(this.ze.width,t).g();if(this.ze=s,this.c(),this instanceof Shape&&this.ie(),this.t("desiredSize",e,s),this.Jc()){const n=this.part;n!==null&&this.pa(n,"height")}}}get minSize(){return this.f!==null?this.f.xr:Size.lu}set minSize(t){const i=this.minSize;i.equals(t)||(t=t.copy(),isNaN(t.width)&&(t.width=0),isNaN(t.height)&&(t.height=0),t.g(),this.jt(),this.f.xr=t,this.c(),this.t("minSize",i,t))}get maxSize(){return this.f!==null?this.f.br:Size.sC}set maxSize(t){const i=this.maxSize;i.equals(t)||(t=t.copy(),isNaN(t.width)&&(t.width=1/0),isNaN(t.height)&&(t.height=1/0),t.g(),this.jt(),this.f.br=t,this.c(),this.t("maxSize",i,t))}get measuredBounds(){return this.ee}get naturalBounds(){return this.Vi}Db(){return 0}get margin(){return this.Zr}set margin(t){typeof t=="number"&&(t=new Margin(t));const i=this.Zr;i.equals(t)||(t=t.N(),this.Zr=t,this.c(),this.t("margin",i,t))}get D(){return this.Ub()===!0&&this.Fb(),this.$r}get Es(){return this.w0()===!0&&this.Fb(),this.oh}trigger(t,i,e){let s=null;return typeof t=="string"?s=new AnimationTrigger(t,i,e):s=t,s.ke=this,this.ys===null&&(this.ys=new GMap),this.ys.set(s.propertyName,s),this}get ys(){return this.f!==null?this.f.ys:null}set ys(t){this.ys!==t&&(this.jt(),this.f.ys=t)}get wr(){return this.f!==null?this.f.wr:0}set wr(t){this.wr!==t&&(this.jt(),this.f.wr=t)}get alignment(){return this.ni}set alignment(t){const i=this.ni;i.equals(t)||(t.isNoSpot()&&!t.isDefault()&&Util.o("GraphObject.alignment for "+this+" must be a real Spot or Spot.Default, not: "+t),t=t.N(),this.ni=t,this.tf(),this.t("alignment",i,t))}get column(){return this.Bo}set column(t){t=Math.round(t);const i=this.Bo;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"column"),this.Bo=t,this.c(),this.t("column",i,t),this.svg!==null&&this.svg.remove())}get columnSpan(){return this.f!==null?this.f.D0:1}set columnSpan(t){t=Math.round(t);const i=this.columnSpan;i!==t&&(t<1&&Util._(t,">= 1",GraphObject,"columnSpan"),this.jt(),this.f.D0=t,this.c(),this.t("columnSpan",i,t))}get row(){return this.Wu}set row(t){t=Math.round(t);const i=this.Wu;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"row"),this.Wu=t,this.c(),this.t("row",i,t),this.svg!==null&&this.svg.remove())}get rowSpan(){return this.f!==null?this.f.F0:1}set rowSpan(t){t=Math.round(t);const i=this.rowSpan;i!==t&&(t<1&&Util._(t,">= 1",GraphObject,"rowSpan"),this.jt(),this.f.F0=t,this.c(),this.t("rowSpan",i,t))}get spanAllocation(){return this.f!==null?this.f.R0:null}set spanAllocation(t){const i=this.spanAllocation;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"spanAllocation"),this.jt(),this.f.R0=t,this.c(),this.t("spanAllocation",i,t))}get alignmentFocus(){return this.qc}set alignmentFocus(t){const i=this.qc;i.equals(t)||(t=t.N(),this.qc=t,this.c(),this.t("alignmentFocus",i,t))}get portId(){return this.qu}set portId(t){const i=this.qu;if(i!==t){const e=this.part;e!==null&&!(e instanceof Node)&&Util.o("Cannot set portID on a Link: "+t);const s=e;i!==null&&s!==null&&s.g2(this),this.qu=t,t!==null&&s!==null&&(s.wn=!0,s.aA(this)),this.t("portId",i,t)}}xa(){const t=this.part;if(t instanceof Node&&(this.portId!==null||this===t.port)){const i=t.diagram;i!==null&&!i.undoManager.isUndoingRedoing&&t.iA(this)}}hA(){const t=this.diagram;t===null||t.undoManager.isUndoingRedoing||(this instanceof Panel?this instanceof Node?this.invalidateConnectedLinks():this.walkVisualTreeFrom(this,i=>{i.xa()}):this.xa())}get toSpot(){return this.q!==null?this.q.fa:Spot.None}set toSpot(t){const i=this.toSpot;i.equals(t)||(t=t.N(),this.Xe(),this.q.fa=t,this.t("toSpot",i,t),this.xa())}get toEndSegmentLength(){return this.q!==null?this.q.da:10}set toEndSegmentLength(t){const i=this.toEndSegmentLength;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"toEndSegmentLength"),this.Xe(),this.q.da=t,this.t("toEndSegmentLength",i,t),this.xa())}get toShortLength(){return this.q!==null?this.q.ma:0}set toShortLength(t){const i=this.toShortLength;i!==t&&(this.Xe(),this.q.ma=t,this.t("toShortLength",i,t),this.xa())}get toLinkable(){return this.q!==null?this.q.v0:null}set toLinkable(t){const i=this.toLinkable;i!==t&&(this.Xe(),this.q.v0=t,this.t("toLinkable",i,t))}get toMaxLinks(){return this.q!==null?this.q.O0:1/0}set toMaxLinks(t){const i=this.toMaxLinks;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"toMaxLinks"),this.Xe(),this.q.O0=t,this.t("toMaxLinks",i,t))}get fromSpot(){return this.q!==null?this.q.ca:Spot.None}set fromSpot(t){const i=this.fromSpot;i.equals(t)||(t=t.N(),this.Xe(),this.q.ca=t,this.t("fromSpot",i,t),this.xa())}get fromEndSegmentLength(){return this.q!==null?this.q.ua:10}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"fromEndSegmentLength"),this.Xe(),this.q.ua=t,this.t("fromEndSegmentLength",i,t),this.xa())}get fromShortLength(){return this.q!==null?this.q.ga:0}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(this.Xe(),this.q.ga=t,this.t("fromShortLength",i,t),this.xa())}get fromLinkable(){return this.q!==null?this.q.I0:null}set fromLinkable(t){const i=this.fromLinkable;i!==t&&(this.Xe(),this.q.I0=t,this.t("fromLinkable",i,t))}get fromMaxLinks(){return this.q!==null?this.q.E0:1/0}set fromMaxLinks(t){const i=this.fromMaxLinks;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"fromMaxLinks"),this.Xe(),this.q.E0=t,this.t("fromMaxLinks",i,t))}get cursor(){return this.f!==null?this.f.Ml:""}set cursor(t){const i=this.cursor;i!==t&&(Util.i(t,"string",GraphObject,"cursor"),this.jt(),this.f.Ml=t,this.t("cursor",i,t))}get click(){return this.f!==null?this.f.Tr:null}set click(t){const i=this.click;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"click"),this.jt(),this.f.Tr=t,this.t("click",i,t))}get doubleClick(){return this.f!==null?this.f.Dr:null}set doubleClick(t){const i=this.doubleClick;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"doubleClick"),this.jt(),this.f.Dr=t,this.t("doubleClick",i,t))}get contextClick(){return this.f!==null?this.f.Fr:null}set contextClick(t){const i=this.contextClick;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"contextClick"),this.jt(),this.f.Fr=t,this.t("contextClick",i,t))}get mouseEnter(){return this.f!==null?this.f.Er:null}set mouseEnter(t){const i=this.mouseEnter;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseEnter"),this.jt(),this.f.Er=t,this.t("mouseEnter",i,t))}get mouseLeave(){return this.f!==null?this.f.Ur:null}set mouseLeave(t){const i=this.mouseLeave;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseLeave"),this.jt(),this.f.Ur=t,this.t("mouseLeave",i,t))}get mouseOver(){return this.f!==null?this.f.Rr:null}set mouseOver(t){const i=this.mouseOver;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseOver"),this.jt(),this.f.Rr=t,this.t("mouseOver",i,t))}get mouseHover(){return this.f!==null?this.f.vr:null}set mouseHover(t){const i=this.mouseHover;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseHover"),this.jt(),this.f.vr=t,this.t("mouseHover",i,t))}get mouseHold(){return this.f!==null?this.f.Or:null}set mouseHold(t){const i=this.mouseHold;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseHold"),this.jt(),this.f.Or=t,this.t("mouseHold",i,t))}get mouseDragEnter(){return this.f!==null?this.f.U0:null}set mouseDragEnter(t){const i=this.mouseDragEnter;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDragEnter"),this.jt(),this.f.U0=t,this.t("mouseDragEnter",i,t))}get mouseDragLeave(){return this.f!==null?this.f.B0:null}set mouseDragLeave(t){const i=this.mouseDragLeave;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDragLeave"),this.jt(),this.f.B0=t,this.t("mouseDragLeave",i,t))}get mouseDrop(){return this.f!==null?this.f.Ir:null}set mouseDrop(t){const i=this.mouseDrop;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDrop"),this.jt(),this.f.Ir=t,this.t("mouseDrop",i,t))}get actionDown(){return this.f!==null?this.f.V0:null}set actionDown(t){const i=this.actionDown;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionDown"),this.jt(),this.f.V0=t,this.t("actionDown",i,t))}get actionMove(){return this.f!==null?this.f.z0:null}set actionMove(t){const i=this.actionMove;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionMove"),this.jt(),this.f.z0=t,this.t("actionMove",i,t))}get actionUp(){return this.f!==null?this.f.X0:null}set actionUp(t){const i=this.actionUp;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionUp"),this.jt(),this.f.X0=t,this.t("actionUp",i,t))}get actionCancel(){return this.f!==null?this.f.K0:null}set actionCancel(t){const i=this.actionCancel;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionCancel"),this.jt(),this.f.K0=t,this.t("actionCancel",i,t))}get toolTip(){return this.f!==null?this.f.Br:null}set toolTip(t){const i=this.toolTip;i!==t&&(this.jt(),this.f.Br=t,this.t("toolTip",i,t))}get contextMenu(){return this.f!==null?this.f.Vr:null}set contextMenu(t){const i=this.contextMenu;i!==t&&(this.jt(),this.f.Vr=t,this.t("contextMenu",i,t))}findBindingPanel(){let t=this instanceof Panel?this:this.panel;for(;t!==null;){if(t.m2())return t;t=t.panel}return null}bind(t,i,e,s){return this.ef(t,i,e,s),this}bindTwoWay(t,i,e,s){return this.ef(t,i,e,s).makeTwoWay(),this}bindModel(t,i,e,s){return this.ef(t,i,e,s).ofModel(),this}bindObject(t,i,e,s,n){return this.ef(t,i,e,s).ofObject(n),this}theme(t,i,e,s,n){return this.fh(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.fh(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.fh(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.fh(t,i,e,s,n).ofModel(),this}ef(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.Y0(n),n}fh(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.Y0(o),o}Y0(t){t.ke=this;const i=this.findBindingPanel();i!==null&&i.cA()&&Util.o("Cannot add a Binding to a template that has already been copied: "+t),this.Ai===null&&(this.Ai=new List),this.Ai.add(t)}set(t){return Object.assign(this,t),this}attach(t){return GraphObject.p2(this,t),this}apply(t){return t(this),this}setProperties(t){return Diagram.a0(this,t),this}static build(t,i,...e){const s=GraphObject.G0.get(t);if(typeof s=="function"){const n=s([t].concat(e));if(n instanceof GraphObject)return i&&n.setProperties(i),n}Util.o('GraphObject.build invoked object builder "'+t+'", but it did not return an Object')}static make(t,...i){let e=arguments,s=null,n=null;if(typeof t=="function")n=t;else if(typeof t=="string"){const r=GraphObject.G0.get(t);typeof r=="function"?(e=Array.prototype.slice.call(e),s=r(e),Util.wt(s)||Util.o('GraphObject.make invoked object builder "'+t+'", but it did not return an Object')):n=root.go[t]}s===null&&((n==null||!n.constructor)&&Util.o("GraphObject.make requires a class function or GoJS class name or name of an object builder, not: "+t),s=new n);let o=1;if(s instanceof Diagram&&e.length>1){const r=s,l=e[1];(typeof l=="string"||l instanceof HTMLDivElement)&&(r.mS(l),o++)}for(let r=o;r{const i="#f5f5f5",e="#737373",s="#d4d4d4",n="#737373",o="#a3a3a3",r=2.76142374915397,l=2.761423749153969,h=new Panel(Panel.Auto,{isActionable:!0,enabledChanged:(a,c)=>{if(a instanceof Panel){const f=a.findObject("ButtonBorder");f!==null&&(c?(a._buttonFillDisabled=f.fill,f.fill=a._buttonFillNormal):(a._buttonFillNormal=f.fill,f.fill=a._buttonFillDisabled))}},cursor:"pointer"}).attach({_buttonFillNormal:i,_buttonStrokeNormal:e,_buttonFillOver:s,_buttonStrokeOver:n,_buttonFillDisabled:o}).add(new Shape("RoundedRectangle",{name:"ButtonBorder",spot1:new Spot(0,0,r,l),spot2:new Spot(1,1,-r,-l),parameter1:2,fill:i,stroke:e}));return h.mouseEnter=(a,c,f)=>{if(!c.isEnabledObject()||!(c instanceof Panel))return;const u=c.findObject("ButtonBorder");u instanceof Shape&&(c._buttonFillNormal=u.fill,u.fill=c._buttonFillOver,c._buttonStrokeNormal=u.stroke,u.stroke=c._buttonStrokeOver)},h.mouseLeave=(a,c,f)=>{if(!c.isEnabledObject()||!(c instanceof Panel))return;const u=c.findObject("ButtonBorder");u instanceof Shape&&(u.fill=c._buttonFillNormal,u.stroke=c._buttonStrokeNormal)},h}),GraphObject.defineBuilder("TreeExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_treeExpandedFigure:"MinusLine",_treeCollapsedFigure:"PlusLine",visible:!1}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.hu}).bindObject("figure","isTreeExpanded",(e,s)=>{const n=s.panel;return e?n._treeExpandedFigure:n._treeCollapsedFigure})),i.bindObject("visible","isTreeLeaf",e=>!e),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Node))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isTreeExpanded){if(!r.canCollapseTree(n))return}else if(!r.canExpandTree(n))return;e.handled=!0,n.isTreeExpanded?r.collapseTree(n):r.expandTree(n)},i}),GraphObject.defineBuilder("SubGraphExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_subGraphExpandedFigure:"MinusLine",_subGraphCollapsedFigure:"PlusLine"}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.hu}).bindObject("figure","isSubGraphExpanded",(e,s)=>{const n=s.panel;return e?n._subGraphExpandedFigure:n._subGraphCollapsedFigure})),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Group))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isSubGraphExpanded){if(!r.canCollapseSubGraph(n))return}else if(!r.canExpandSubGraph(n))return;e.handled=!0,n.isSubGraphExpanded?r.collapseSubGraph(n):r.expandSubGraph(n)},i}),GraphObject.defineBuilder("ToolTip",t=>new Adornment(Panel.Auto,{isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).add(new Shape("RoundedRectangle",{name:"Border",parameter1:1,fill:"#f5f5f5",strokeWidth:0,spot1:new Spot(0,0,4,6),spot2:new Spot(1,1,-4,-4)}))),GraphObject.defineBuilder("ContextMenu",t=>new Adornment(Panel.Vertical,{background:"#f5f5f5",isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).bindObject("background","",i=>i.adornedPart!==null&&i.hasPlaceholder()?null:"#f5f5f5")),GraphObject.defineBuilder("ContextMenuButton",t=>{const i=GraphObject.build("Button");i.stretch=5;const e=i.findObject("ButtonBorder");return e instanceof Shape&&(e.figure="Rectangle",e.strokeWidth=0,e.spot1=new Spot(0,0,4,6),e.spot2=new Spot(1,1,-4,-4)),i}),GraphObject.defineBuilder("PanelExpanderButton",t=>{const i=GraphObject.takeBuilderArgument(t,"COLLAPSIBLE"),e=GraphObject.build("Button");e.attach({_buttonExpandedFigure:"M0 0 M0 6 L4 2 8 6 M8 8",_buttonCollapsedFigure:"M0 0 M0 2 L4 6 8 2 M8 8",_buttonFillNormal:"rgba(0, 0, 0, 0)",_buttonStrokeNormal:null,_buttonFillOver:"rgba(0, 0, 0, .2)",_buttonStrokeOver:null}),e.add(new Shape({name:"ButtonIcon",strokeWidth:2}).bindObject("geometryString","visible",n=>n?e._buttonExpandedFigure:e._buttonCollapsedFigure,void 0,i));const s=e.findObject("ButtonBorder");return s instanceof Shape&&(s.stroke=null,s.fill="rgba(0, 0, 0, 0)"),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=o.diagram;if(r===null||r.isReadOnly)return;let l=o.findBindingPanel();if(l===null&&(l=o.part),l!==null){const h=l.findObject(i);h!==null&&(n.handled=!0,r.startTransaction("Collapse/Expand Panel"),h.visible=!h.visible,r.commitTransaction("Collapse/Expand Panel"))}},e}),GraphObject.defineBuilder("CheckBoxButton",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("Button",{desiredSize:new Size(14,14)});e.attach({"ButtonBorder.spot1":new Spot(0,0,1,1),"ButtonBorder.spot2":new Spot(1,1,-1,-1)});const s=new Shape({name:"ButtonIcon",geometryString:"M0 0 M0 8.85 L4.9 13.75 16.2 2.45 M16.2 16.2",strokeWidth:2,stretch:2,geometryStretch:6,visible:!1});return i!==""&&s.bindTwoWay("visible",i),e.add(s),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=n.diagram;if(r===null||r.isReadOnly||i!==""&&r.model.isReadOnly)return;n.handled=!0;const l=o.findObject("ButtonIcon");r.startTransaction("checkbox"),l!==null&&(l.visible=!l.visible),typeof o._doClick=="function"&&o._doClick(n,o),r.commitTransaction("checkbox")},e}),GraphObject.defineBuilder("CheckBox",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("CheckBoxButton",{name:"Button",isActionable:!1,margin:new Margin(0,1,0,0)},i),s=new Panel("Horizontal",{isActionable:!0,cursor:e.cursor,margin:new Margin(1),mouseEnter:e.mouseEnter,mouseLeave:e.mouseLeave,click:e.click}).attach({_buttonFillNormal:e._buttonFillNormal,_buttonStrokeNormal:e._buttonStrokeNormal,_buttonFillOver:e._buttonFillOver,_buttonStrokeOver:e._buttonStrokeOver,_buttonFillDisabled:e._buttonFillDisabled,_buttonClick:e.click});return s.add(e),e.mouseEnter=null,e.mouseLeave=null,e.click=null,s})}}class GraphObjectTemplateSettings{gi;St;$n;Ai;Zn;Ks;Ml;Tr;Dr;Fr;Er;Ur;Rr;vr;Or;U0;B0;Ir;V0;z0;X0;K0;Br;Vr;M0;R0;ys;xr;br;to;F0;D0;wr;k0;j0;H0;constructor(){this.gi=!1,this.St="",this.$n=-1,this.Ai=null,this.Zn=null,this.Ks=null,this.Ml="",this.Tr=null,this.Dr=null,this.Fr=null,this.Er=null,this.Ur=null,this.Rr=null,this.vr=null,this.Or=null,this.U0=null,this.B0=null,this.Ir=null,this.V0=null,this.z0=null,this.X0=null,this.K0=null,this.Br=null,this.Vr=null,this.M0=null,this.R0=null,this.ys=null,this.xr=Size.lu,this.br=Size.sC,this.to=1,this.F0=1,this.D0=1,this.wr=0,this.k0=null,this.j0=null,this.H0="category"}copy(){const t=new GraphObjectTemplateSettings;return t.St=this.St,t.$n=this.$n,t.Ai=this.Ai,t.Ks=this.Ks,t.Ml=this.Ml,t.Tr=this.Tr,t.Dr=this.Dr,t.Fr=this.Fr,t.Er=this.Er,t.Ur=this.Ur,t.Rr=this.Rr,t.vr=this.vr,t.Or=this.Or,t.U0=this.U0,t.B0=this.B0,t.Ir=this.Ir,t.V0=this.V0,t.z0=this.z0,t.X0=this.X0,t.K0=this.K0,t.Br=this.Br,t.Vr=this.Vr,t.M0=this.M0,t.R0=this.R0,t.ys=this.ys,t.xr=this.xr.N(),t.br=this.br.N(),t.to=this.to,t.F0=this.F0,t.D0=this.D0,t.wr=this.wr,t.k0=this.k0,t.j0=this.j0,t.H0=this.H0,t}}class STransform{m;constructor(){this.m=[1,0,0,1,0,0]}copy(){const t=new STransform;return t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5],t}translate(t,i){this.m[4]+=this.m[0]*t+this.m[2]*i,this.m[5]+=this.m[1]*t+this.m[3]*i}scale(t,i){this.m[0]*=t,this.m[1]*=t,this.m[2]*=i,this.m[3]*=i}rotate(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return;this.translate(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m[0]*s+this.m[2]*n,r=this.m[1]*s+this.m[3]*n,l=this.m[0]*-n+this.m[2]*s,h=this.m[1]*-n+this.m[3]*s;this.m[0]=o,this.m[1]=r,this.m[2]=l,this.m[3]=h,this.translate(-i,-e)}}class SGradient{type;x1;y1;r1;x2;y2;r2;colors;pattern;constructor(t){this.type=t,this.x1=0,this.y1=0,this.r1=0,this.x2=0,this.y2=0,this.r2=0,this.colors=[],this.pattern=null}addColorStop(t,i){this.colors.push({offset:t,color:i})}}class SVGSurface{Ft;ai;ha;ju;w2;constructor(t,i,e){const s=i===void 0?root.document:i;this.ha=s,this.w2="http://www.w3.org/2000/svg";const n="http://www.w3.org/2000/xmlns/";s!==void 0&&(this.Ft=this.makeElement("svg",{width:"1px",height:"1px",viewBox:"0 0 1 1"}),this.style.display="block",this.style.letterSpacing="normal",this.style.wordSpacing="normal",e||(this.style.position="absolute"),this.Ft.setAttributeNS(n,"xmlns",this.w2),this.Ft.setAttributeNS(n,"xmlns:xlink","http://www.w3.org/1999/xlink")),this.ju=null,this.ai=new SVGContext(this,e)}resize(t,i,e,s){return this.width!==t||this.height!==i?(this.width=t,this.height=i,this.style.width=e+"px",this.style.height=s+"px",this.Ft.setAttributeNS(null,"width",e+"px"),this.Ft.setAttributeNS(null,"height",s+"px"),this.Ft.setAttributeNS(null,"viewBox","0 0 "+e+" "+s),this.ai.b2.firstElementChild.setAttributeNS(null,"width",e+"px"),this.ai.b2.firstElementChild.setAttributeNS(null,"height",s+"px"),!0):!1}makeElement(t,i,e){const s=this.ha.createElementNS(this.w2,t);if(Util.wt(i))for(const n in i)s.setAttributeNS(n==="href"?"http://www.w3.org/1999/xlink":"",n,i[n]);return e!==void 0&&(s.textContent=e),s}getBoundingClientRect(){return this.Ft.getBoundingClientRect()}focus(){this.Ft.focus()}get width(){return this.Ft.width.baseVal.value}set width(t){this.Ft.setAttribute("width",t+"px")}get height(){return this.Ft.height.baseVal.value}set height(t){this.Ft.setAttribute("height",t+"px")}dispose(){this.ha=null}get style(){return this.Ft.style}}class SVGContext{sf;nf;xn;Ti;Ke;fillStyle;font;globalAlpha;lineCap;lineDashOffset;lineJoin;lineWidth;miterLimit;shadowBlur;shadowColor;shadowOffsetX;shadowOffsetY;strokeStyle;textAlign;imageSmoothingEnabled;clipInsteadOfFill;lastCreatedElement;of;rf;surface;svg;b2;fA;Vb;Xo;uh;ba;currentElement;clipPathGroup;diagramGroup;lastDrawnPart;currentPath;outerGroup;pathAttributes;tl;Sr;filter;partClipRect;constructor(t,i){this.surface=t,this.svg=t.Ft,this.of=[],this.rf=[],this.fillStyle="#000000",this.font="10px sans-serif",this.globalAlpha=1,this.lineCap="butt",this.lineDashOffset=0,this.lineJoin="miter",this.lineWidth=1,this.miterLimit=10,this.shadowBlur=0,this.shadowColor="rgba(0, 0, 0, 0)",this.shadowOffsetX=0,this.shadowOffsetY=0,this.tl=!1,this.strokeStyle="#000000",this.textAlign="start",this.clipInsteadOfFill=!1,this.sf=0,this.nf=0,this.xn=0,this.lastCreatedElement=null,this.currentElement=null,this.Ti=[],this.pathAttributes={},this.Vb=!1,this.Xo=null,this.uh=0,this.Ke=new STransform,this.clipPathGroup=this.newGroup2(),this.diagramGroup=this.newGroup2("gojs-diagram"),this.lastDrawnPart=null,this.currentPath=null;const e=GSet.nu++,s=this.makeElement("clipPath",{id:"mainClip"+e}),n={x:0,y:0,width:t.width,height:t.height};s.appendChild(this.makeElement("rect",n)),this.b2=s,this.svg.appendChild(this.clipPathGroup),this.clipPathGroup.appendChild(this.diagramGroup),this.svg.appendChild(s),this.clipPathGroup.setAttributeNS(null,"clip-path","url(#mainClip"+e+")"),this.fA={},this.Sr=!!i,this.filter="",this.partClipRect=null}setDiagramPosScale(t,i,e,s,n,o){this.diagramGroup===void 0?this.newGroup(t,i,e,s,n,o):this.diagramGroup.setAttribute("transform","matrix("+t+", "+i+", "+e+", "+s+", "+n+", "+o+")")}resetInnerSVG(){this.diagramGroup!==null&&(this.diagramGroup.innerHTML="")}arc(t,i,e,s,n,o,r,l){const h=2*Math.PI,a=1e-6,c=h-a,f=e*Math.cos(s),u=e*Math.sin(s),d=t+f,m=i+u,g=o?0:1;let p=o?s-n:n-s;(Math.abs(r-d)>a||Math.abs(l-m)>a)&&this.Ti.push(["L",d,+m]),p<0&&(p=p%h+h),p>c?(this.Ti.push(["A",e,e,0,1,g,t-f,i-u]),this.Ti.push(["A",e,e,0,1,g,d,m])):p>a&&this.Ti.push(["A",e,e,0,+(p>=Math.PI),g,t+e*Math.cos(n),i+e*Math.sin(n)])}beginPath(){this.Ti=[],this.pathAttributes={stroke:"none",fill:"none"}}endPath(t){this.BR(this.Ti,this.Ke,t||0)}bezierCurveTo(t,i,e,s,n,o){this.Ti.push(["C",t,i,e,s,n,o])}clearRect(t,i,e,s){}clip(){this.pathAttributes.clipPath=!0}closePath(){this.Ti.push(["z"])}createLinearGradient(t,i,e,s){const n=new SGradient("linear");return n.x1=t,n.y1=i,n.x2=e,n.y2=s,n}createPattern(t,i){let e="";t instanceof HTMLCanvasElement&&(e=t.toDataURL()),t instanceof HTMLImageElement&&(e=t.getAttribute("src"));const s=this.fA;if(s[e])return"url(#"+s[e]+")";const n="PATTERN"+GSet.nu++,o={width:t.width,height:t.height,id:n,patternUnits:"userSpaceOnUse"},r={x:0,y:0,width:t.width,height:t.height,href:e},l=this.makeElement("pattern",o);return l.appendChild(this.makeElement(Diagram.img,r)),this.svg.appendChild(l),s[e]=n,"url(#"+n+")"}createRadialGradient(t,i,e,s,n,o){const r=new SGradient("radial");return r.x1=t,r.y1=i,r.r1=e,r.x2=s,r.y2=n,r.r2=o,r}amendImageTransform(t,i,e,s,n,o,r,l){const h=r/e,a=l/s;(n!==0||o!==0)&&this.Ke.translate(n,o),(h!==1||a!==1)&&this.Ke.scale(h,a),(t!==0||i!==0)&&this.Ke.translate(-t,-i)}drawImage(t,i,e,s,n,o,r,l,h){let a="";t instanceof HTMLCanvasElement&&(a=t.toDataURL()),t instanceof HTMLImageElement&&(a=t.getAttribute("src"));const c=t instanceof HTMLImageElement?t.naturalWidth:t.width,f=t instanceof HTMLImageElement?t.naturalHeight:t.height;s===void 0&&(o=i,r=e,l=s=c,h=n=f),s=s||0,n=n||0,o=o||0,r=r||0,l=l||0,h=h||0,this.amendImageTransform(i,e,s,n,o,r,l,h);const u={x:0,y:0,width:c||s,height:f||n,href:a};!Geo.K(s,l)||!Geo.K(n,h)?u.preserveAspectRatio="none":a.toLowerCase().indexOf(".svg")===-1&&a.toLowerCase().indexOf("data:image/svg")===-1&&(u.preserveAspectRatio="xMidYMid slice"),(i!==0||e!==0||s!==c||n!==f)&&(s+=i,n+=e,u["clip-path"]=`path('M ${i},${e} L ${s} ${e} L ${s} ${n} L ${i} ${n} z')`),this.processCommon(Diagram.img,u,this.Ke),this.rd(Diagram.img,u)}fill(t,i){t&&(this.pathAttributes["fill-rule"]="evenodd"),this.setFill(this.pathAttributes)}fillContext(t,i,e){this.clipInsteadOfFill?this.clip():this.fill(i,e)}fillRect(t,i,e,s){this.addRect("fill",[t,i,e,s],this.Ke)}fillBackground(t,i,e,s){const n={x:t,y:i,width:e,height:s};this.processCommon("fill",n,this.Ke),this.setFill(n),this.svg.prepend(this.makeElement("rect",n))}fillText(t,i,e){this.addText("fill",[t,i,e],this.Ke)}lineTo(t,i){this.Ti.push(["L",t,i])}moveTo(t,i){this.Ti.push(["M",t,i])}quadraticCurveTo(t,i,e,s){this.Ti.push(["Q",t,i,e,s])}rect(t,i,e,s){this.Ti.push(["M",t,i],["L",t+e,i],["L",t+e,i+s],["L",t,i+s],["z"])}restore(){this.Ke=this.of.pop(),this.Ti=this.of.pop();const t=this.of.pop();this.fillStyle=t.fillStyle,this.font=t.font,this.globalAlpha=t.globalAlpha,this.lineCap=t.lineCap,this.lineDashOffset=t.lineDashOffset,this.lineJoin=t.lineJoin,this.lineWidth=t.lineWidth,this.miterLimit=t.miterLimit,this.shadowBlur=t.shadowBlur,this.shadowColor=t.shadowColor,this.shadowOffsetX=t.shadowOffsetX,this.shadowOffsetY=t.shadowOffsetY,this.strokeStyle=t.strokeStyle,this.textAlign=t.textAlign,this.partClipRect=t.partClipRect}save(){const t={fillStyle:this.fillStyle,font:this.font,globalAlpha:this.globalAlpha,lineCap:this.lineCap,lineDashOffset:this.lineDashOffset,lineJoin:this.lineJoin,lineWidth:this.lineWidth,miterLimit:this.miterLimit,shadowBlur:this.shadowBlur,shadowColor:this.shadowColor,shadowOffsetX:this.shadowOffsetX,shadowOffsetY:this.shadowOffsetY,strokeStyle:this.strokeStyle,textAlign:this.textAlign,partClipRect:this.partClipRect};this.of.push(t);const i=[];for(let e=0;eh.offset>a.offset?1:-1);for(let h=0;h0&&this.rf[this.rf.length-1].setAttributeNS(null,"clip-path",'path("'+s+'")');return}if(n.d=s,this.processCommon("",n,i),this.currentPath!==null){const r=this.currentPath;if(r.nodeName!=="g")for(const l in n)l!=="transform"&&r.setAttributeNS(null,l,n[l]);else{const l=r.getElementsByTagName("path");for(const h in n)h!=="transform"&&l[e].setAttributeNS(null,h,n[h])}}else this.rd("path",n)}VR(t){const i=[];for(let e=0;es?(this.scale(s/n,1),this.translate((n-s)/2,0)):s>n&&(this.scale(1,n/s),this.translate(0,(s-n)/2)),this.fillOrClip(i,e),n>s?(this.translate(-(n-s)/2,0),this.scale(1/(s/n),1)):s>n&&(this.translate(0,-(s-n)/2),this.scale(1,1/(n/s))),!0}strokeContext(){this.q0||this.stroke()}fillOrClip(t,i){this.q0?this.clip(i):this.fill(t,i)}get clipInsteadOfFill(){return this.q0}set clipInsteadOfFill(t){this.q0=t}shadowsSet(t,i,e){this.sf=t,this.nf=i,this.xn=e}shadowsOff(){this.tl=!1,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0}shadowsOn(){this.tl=!0,this.shadowOffsetX=this.sf,this.shadowOffsetY=this.nf,this.shadowBlur=this.xn}enableDash(t,i){const e=this.B;e.setLineDash!==void 0&&(e.setLineDash(t),e.lineDashOffset=i)}disableDash(){const t=this.B;t.setLineDash!==void 0&&(t.setLineDash(CanvasSurfaceContext.EmptyArray),t.lineDashOffset=0)}clearContextCache(t){t&&(this.zb=""),this.Xb="",this.Kb=""}removePartFromView(t){}static EmptyArray=Object.freeze([])}var BrushType=(w=>(w[w.Solid=1]="Solid",w[w.Linear=2]="Linear",w[w.Radial=3]="Radial",w[w.Pattern=4]="Pattern",w))(BrushType||{}),ColorSpace=(w=>(w[w.Lab=1]="Lab",w[w.HSL=2]="HSL",w[w.Oklch=3]="Oklch",w))(ColorSpace||{});class ColorNumbers{n0;n1;n2;n3;constructor(){this.n0=0,this.n1=0,this.n2=0,this.n3=0}}class Brush{h;Z;ka;ei;gs;W0;J0;bn;$0;yn;Qc;Eb;constructor(t,i){if(GSet.Yi(this),this.h=!1,t===void 0)this.Z=1,this.ka="black";else if(typeof t=="string"){const s=Util.Oh(BrushType,t);s!==null?(this.Z=s,this.ka="black"):(this.Z=1,this.ka=t)}else this.Z=t,this.ka="black";const e=this.Z;if(e===2?(this.ei=Spot.TopCenter,this.gs=Spot.BottomCenter):e===3?(this.ei=Spot.Center,this.gs=Spot.Center):(this.ei=Spot.None,this.gs=Spot.None),this.W0=0,this.J0=NaN,this.bn=null,this.$0=null,this.yn=null,this.Qc=0,this.Eb=0,i){const s={};for(const n in i)isFinite(parseFloat(n))?this.addColorStop(parseFloat(n),i[n]):s[n]=i[n];Object.assign(this,s)}}copy(){const t=new Brush;return t.Z=this.Z,t.ka=this.ka,t.ei=this.ei.N(),t.gs=this.gs.N(),t.W0=this.W0,t.J0=this.J0,this.bn!==null&&(t.bn=this.bn.copy()),t.$0=this.$0,t}g(){return this.h=!0,this.bn!==null&&this.bn.g(),this}rt(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this.bn!==null&&this.bn.rt(),this}ri(t){t in BrushType?this.type=t:Util.lr(this,t)}toString(){let t="Brush(";if(this.type===1)t+=this.color;else if(this.type===2?t+="Linear ":this.type===3?t+="Radial ":this.type===4?t+="Pattern ":t+="(unknown) ",t+=this.start+" "+this.end,this.colorStops!==null){const i=this.colorStops.iterator;for(;i.next();){const e=i.key,s=i.value;t+=" "+e+":"+s}}return t+=")",t}addColorStop(t,i){return this.h&&Util.T(this),(typeof t!="number"||!isFinite(t)||t>1||t<0)&&Util._(t,"0 <= loc <= 1",Brush,"addColorStop:loc"),Util.i(i,"string",Brush,"addColorStop:color"),this.bn===null&&(this.bn=new GMap),this.bn.set(t,i),this.Z===1&&(this.type=2),this.yn=null,this}get type(){return this.Z}set type(t){this.h&&Util.T(this,t),this.Z=t,this.start.isNoSpot()&&(t===2?this.start=Spot.TopCenter:t===3&&(this.start=Spot.Center)),this.end.isNoSpot()&&(t===2?this.end=Spot.BottomCenter:t===3&&(this.end=Spot.Center)),this.yn=null}get color(){return this.ka}set color(t){this.h&&Util.T(this,t),this.ka=t,this.yn=null}get start(){return this.ei}set start(t){this.h&&Util.T(this,t),this.ei=t.N(),this.yn=null}get end(){return this.gs}set end(t){this.h&&Util.T(this,t),this.gs=t.N(),this.yn=null}get startRadius(){return this.W0}set startRadius(t){this.h&&Util.T(this,t),t<0&&Util._(t,">= zero",Brush,"startRadius"),this.W0=t,this.yn=null}get endRadius(){return this.J0}set endRadius(t){this.h&&Util.T(this,t),t<0&&Util._(t,">= zero",Brush,"endRadius"),this.J0=t,this.yn=null}get colorStops(){return this.bn}set colorStops(t){this.h&&Util.T(this,t),this.bn=t,this.yn=null}get pattern(){return this.$0}set pattern(t){this.h&&Util.T(this,t),this.$0=t,this.yn=null}static randomColor(t,i){t===void 0&&(t=128),i===void 0&&(i=Math.max(t,255));const e=Math.abs(i-t);let s=Math.floor(t+Math.random()*e).toString(16),n=Math.floor(t+Math.random()*e).toString(16),o=Math.floor(t+Math.random()*e).toString(16);return s.length<2&&(s="0"+s),n.length<2&&(n="0"+n),o.length<2&&(o="0"+o),"#"+s+n+o}static isValidColor(t){return root.CSS?root.CSS.supports("color",t):!0}static lighten(t){return Brush.lightenBy(t)}lightenBy(t,i){this.h&&Util.T(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Do(this.color),this.color=Brush.ld(e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Do(n.value),this.addColorStop(n.key,Brush.ld(e,s))}return this}static lightenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Do(t),Brush.ld(s,n)}static darken(t){return Brush.darkenBy(t)}darkenBy(t,i){this.h&&Util.T(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Do(this.color),this.color=Brush.ld(-e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Do(n.value),this.addColorStop(n.key,Brush.ld(-e,s))}return this}static darkenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Do(t),Brush.ld(-s,n)}static mix(t,i,e){Brush.Do(t);const s=Brush.G.n0,n=Brush.G.n1,o=Brush.G.n2,r=Brush.G.n3;Brush.Do(i),e===void 0&&(e=.5);const l=Math.round((Brush.G.n0-s)*e+s),h=Math.round((Brush.G.n1-n)*e+n),a=Math.round((Brush.G.n2-o)*e+o),c=Math.round((Brush.G.n3-r)*e+r);return`rgba(${l}, ${h}, ${a}, ${c})`}isDark(){if(this.type===1)return Brush.isDark(this.color);if((this.type===2||this.type===3)&&this.colorStops!==null){const t=this.colorStops;if(this.type===3)return Brush.isDark(t.first().value);if(t.get(.5)!==null)return Brush.isDark(t.get(.5));if(t.count===2){const l=t.toArray();return Brush.isDark(Brush.mix(l[0].value,l[1].value))}const i=t.iterator;let e=-1,s=-1,n=1,o=1;for(;i.next();){const l=i.key,h=Math.abs(.5-i.key);n>o&&h=n&&hs){let l=e;e=s,s=l,l=n,n=o,o=l}const r=s-e;return Brush.isDark(Brush.mix(t.get(e),t.get(s),1-o/r))}return!1}static isDark(t){return t?t instanceof Brush?t.isDark():(Brush.Do(t),(299*Brush.G.n0+587*Brush.G.n1+114*Brush.G.n2)/1e3<128):!1}static ld(t,i){switch(i){case 1:return Brush.zR(),Brush.io.n0=Math.min(100,Math.max(0,Brush.io.n0+100*t)),Brush.XR(),"rgba("+Brush.G.n0+", "+Brush.G.n1+", "+Brush.G.n2+", "+Brush.G.n3+")";case 2:return Brush.OM(),Brush.Ii.n2=Math.min(100,Math.max(0,Brush.Ii.n2+100*t)),"hsla("+Brush.Ii.n0+", "+Brush.Ii.n1+"%, "+Brush.Ii.n2+"%, "+Brush.Ii.n3+")";case 3:return Brush.KR(),Brush.eo.n0=Math.min(100,Math.max(0,Brush.eo.n0+100*t)),Brush.YR(),"rgba("+Brush.G.n0+", "+Brush.G.n1+", "+Brush.G.n2+", "+Brush.G.n3+")";default:Util.o("Unknown color space: "+i)}}static Do(t){const i=Brush.il;if(i===null)return;i.clearRect(0,0,1,1),i.fillStyle="#000000";const e=i.fillStyle;if(i.fillStyle=t,i.fillStyle!==e){i.fillRect(0,0,1,1);const s=i.getImageData(0,0,1,1).data;Brush.G.n0=s[0],Brush.G.n1=s[1],Brush.G.n2=s[2],Brush.G.n3=s[3]/255}else{i.fillStyle="#FFFFFF";const s=i.fillStyle;i.fillStyle=t,i.fillStyle,Brush.G.n0=0,Brush.G.n1=0,Brush.G.n2=0,Brush.G.n3=1}}static OM(){const t=Brush.G.n0/255,i=Brush.G.n1/255,e=Brush.G.n2/255,s=Math.max(t,i,e),n=Math.min(t,i,e),o=s-n;let r,l;const h=(s+n)/2;if(o===0)r=l=0;else{switch(s){case t:r=(i-e)/o%6;break;case i:r=(e-t)/o+2;break;case e:r=(t-i)/o+4;break}r*=60,r<0&&(r+=360),l=o/(1-Math.abs(2*h-1))}Brush.Ii.n0=Math.round(r),Brush.Ii.n1=Math.round(l*100),Brush.Ii.n2=Math.round(h*100),Brush.Ii.n3=Brush.G.n3}static dE(){const t=Brush.Ii.n0,i=Brush.Ii.n1/100,e=Brush.Ii.n2/100;let s,n,o;const r=(1-Math.abs(2*e-1))*i,l=t/60,h=r*(1-Math.abs(l%2-1));l>=0&&l<1?(s=r,n=h,o=0):l>=1&&l<2?(s=h,n=r,o=0):l>=2&&l<3?(s=0,n=r,o=h):l>=3&&l<4?(s=0,n=h,o=r):l>=4&&l<5?(s=h,n=0,o=r):l>=5&&l<6&&(s=r,n=0,o=h);const a=e-.5*r;s+=a,n+=a,o+=a,Brush.G.n0=Math.round(s*255),Brush.G.n1=Math.round(n*255),Brush.G.n2=Math.round(o*255),Brush.G.n3=Brush.Ii.n3}static zR(){Brush.uA(),Brush.GR()}static XR(){Brush.jR(),Brush.dA()}static k2(t){return t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}static P2(t){return t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055}static uA(){const t=Brush.k2(Brush.G.n0),i=Brush.k2(Brush.G.n1),e=Brush.k2(Brush.G.n2);Brush.Rt.n0=.4124564*t+.3575761*i+.1804375*e,Brush.Rt.n1=.2126729*t+.7151522*i+.072175*e,Brush.Rt.n2=.0193339*t+.119192*i+.9503041*e,Brush.Rt.n3=Brush.G.n3}static dA(){const t=3.2404542*Brush.Rt.n0+-1.5371385*Brush.Rt.n1+-.4985314*Brush.Rt.n2,i=-.969266*Brush.Rt.n0+1.8760108*Brush.Rt.n1+.041556*Brush.Rt.n2,e=.0556434*Brush.Rt.n0+-.2040259*Brush.Rt.n1+1.0572252*Brush.Rt.n2;Brush.G.n0=Brush.P2(t)*255,Brush.G.n1=Brush.P2(i)*255,Brush.G.n2=Brush.P2(e)*255,Brush.G.n3=Brush.Rt.n3,Brush.G.n0=Math.round(Brush.G.n0),Brush.G.n0>255?Brush.G.n0=255:Brush.G.n0<0&&(Brush.G.n0=0),Brush.G.n1=Math.round(Brush.G.n1),Brush.G.n1>255?Brush.G.n1=255:Brush.G.n1<0&&(Brush.G.n1=0),Brush.G.n2=Math.round(Brush.G.n2),Brush.G.n2>255?Brush.G.n2=255:Brush.G.n2<0&&(Brush.G.n2=0)}static M2=216/24389;static Yb=24389/27;static hd=[95.047,100,108.883];static S2(t){return t>Brush.M2?Math.pow(t,1/3):(Brush.Yb*t+16)/116}static GR(){const t=Brush.S2(Brush.Rt.n0*100/Brush.hd[0]),i=Brush.S2(Brush.Rt.n1*100/Brush.hd[1]),e=Brush.S2(Brush.Rt.n2*100/Brush.hd[2]);Brush.io.n0=116*i-16,Brush.io.n1=500*(t-i),Brush.io.n2=200*(i-e),Brush.io.n3=Brush.Rt.n3}static gA(t){const i=t*t*t;return i>Brush.M2?i:(116*t-16)/Brush.Yb}static jR(){const t=(Brush.io.n0+16)/116,i=Brush.io.n1/500+t,e=t-Brush.io.n2/200;Brush.Rt.n0=Brush.hd[0]/100*Brush.gA(i),Brush.Rt.n1=Brush.hd[1]/100*(Brush.io.n0>Brush.Yb*Brush.M2?Math.pow(t,3):Brush.io.n0/Brush.Yb),Brush.Rt.n2=Brush.hd[2]/100*Brush.gA(e),Brush.Rt.n3=Brush.io.n3}static HR(){let t=.8190224*Brush.Rt.n0+.3619062*Brush.Rt.n1+-.1288737*Brush.Rt.n2,i=.03298366*Brush.Rt.n0+.9292868*Brush.Rt.n1+.03614466*Brush.Rt.n2,e=.04817719*Brush.Rt.n0+.2642395*Brush.Rt.n1+.6335478*Brush.Rt.n2;t=Math.cbrt(t),i=Math.cbrt(i),e=Math.cbrt(e),Brush.ci.n0=.2104542*t+.7936177*i+-.004072046*e,Brush.ci.n1=1.977998*t+-2.428592*i+.4505937*e,Brush.ci.n2=.02590403*t+.7827717*i+-.8086757*e,Brush.ci.n3=Brush.Rt.n3,Brush.ci.n0*=100}static qR(){Brush.ci.n0/=100;let t=.9999999*Brush.ci.n0+.3963377*Brush.ci.n1+.2158037*Brush.ci.n2,i=1.000000009*Brush.ci.n0+-.1055613*Brush.ci.n1+-.06385417*Brush.ci.n2,e=1.00000005*Brush.ci.n0+-.08948418*Brush.ci.n1+-1.291485*Brush.ci.n2;t=t**3,i=i**3,e=e**3,Brush.Rt.n0=1.2268798*t+-.5578149*i+.281391*e,Brush.Rt.n1=-.04057576*t+1.112286*i+-.07171106*e,Brush.Rt.n2=-.07637294*t+-.4214933*i+1.586924*e,Brush.Rt.n3=Brush.ci.n3}static WR(){const t=Math.atan2(Brush.ci.n2,Brush.ci.n1)*180/Math.PI;Brush.eo.n0=Brush.ci.n0,Brush.eo.n1=Math.sqrt(Brush.ci.n1**2+Brush.ci.n2**2),Brush.eo.n2=t>=0?t:t+360,Brush.eo.n3=Brush.ci.n3}static JR(){Brush.ci.n0=Brush.eo.n0,Brush.ci.n1=Brush.eo.n1*Math.cos(Brush.eo.n2*Math.PI/180),Brush.ci.n2=Brush.eo.n1*Math.sin(Brush.eo.n2*Math.PI/180),Brush.ci.n3=Brush.eo.n3}static KR(){Brush.uA(),Brush.HR(),Brush.WR()}static YR(){Brush.JR(),Brush.qR(),Brush.dA()}static od(t,i){typeof t=="string"||t instanceof Brush||Util.o("Value for "+i+" must be a color string or a Brush, not "+t)}static Solid=1;static Linear=2;static Radial=3;static Pattern=4;static Lab=1;static HSL=2;static il=Diagram.isUsingDOM()?new CanvasSurface(null,void 0,{willReadFrequently:!0}).ai:null;static G=new ColorNumbers;static Ii=new ColorNumbers;static Rt=new ColorNumbers;static io=new ColorNumbers;static ci=new ColorNumbers;static eo=new ColorNumbers}class PanelLayout{St="Base";static Layouts=new GMap;static definePanelLayout(t,i){i.name=t,PanelLayout.Layouts.set(t,i)}get name(){return this.St}set name(t){this.St=t}constructor(){}get classType(){return Panel}measure(t,i,e,s,n,o,r){}measureElement(t,i,e,s,n){t.ut(i,e,s,n)}arrange(t,i,e){}arrangeElement(t,i,e,s,n,o){t.zt(i,e,s,n,o)}remeasureObject(t){t._c()}Gi(t,i,e){}}class PanelLayoutPosition extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=s.length,h=t.Ko();for(let a=0;a0&&(S=Math.max(Math.abs(k.x*o+k.offsetX-(M.x*o+M.offsetX))-g,0)),r>0&&(N=Math.max(Math.abs(k.y*r+k.offsetY-(M.y*r+M.offsetY))-g,0));const T=Size.l();T.e(0,0);const A=t.Ko();for(let v=0;v1,ot=it.columnSpan>1;(ct||ot)&&!(Ky&&(S=Math.max(y-dt,0)),b.ji=b.ji+S,b.actual=b.nt+S,y=Math.max(y-(S+(mt?dt:0)),0)}if(it.columnSpan===1&&(N===0||N===4)){b=t.getColumnDefinition(j);const dt=b.computeEffectiveSpacing(),mt=b.nt===0;S=Math.max(ut-b.actual,0),S+(mt?dt:0)>p&&(S=Math.max(p-dt,0)),b.ji=b.ji+S,b.actual=b.nt+S,p=Math.max(p-(S+(mt?dt:0)),0)}(ct||ot)&&it._c()}}}Util.tt(f);let A=0,D=0;l=t.columnCount;for(let K=0;K=t.rowCount);Z++)b=t.getRowDefinition(I.row+Z),S=0,N===2||N===4?S=Math.max(b.minimum,V[I.row+Z]===0?b.maximum:Math.min(V[I.row+Z],b.maximum)):S=Math.max(b.minimum,isNaN(b.de)?b.maximum:Math.min(b.de,b.maximum)),E.height+=S,_+=b.minimum;for(let Z=1;Z=t.columnCount);Z++)b=t.getColumnDefinition(I.column+Z),S=0,N===2||N===5?S=Math.max(b.minimum,B[I.column+Z]===0?b.maximum:Math.min(B[I.column+Z],b.maximum)):S=Math.max(b.minimum,isNaN(b.de)?b.maximum:Math.min(b.de,b.maximum)),E.width+=S,et+=b.minimum;X.width+=E.width,X.height+=E.height;const tt=I.margin,it=tt.right+tt.left,ct=tt.top+tt.bottom;I.ut(X.width,X.height,et,_);const ot=I.measuredBounds,lt=Math.max(ot.width+it,0),st=Math.max(ot.height+ct,0);let nt=0;for(let Z=0;Z=t.rowCount);Z++)b=t.getRowDefinition(I.row+Z),nt+=b.total||0;if(nt=t.rowCount);at++){b=t.getRowDefinition(I.row+at);const ut=b.nt||0,gt=rt(I,b,ft);b.actual=Math.min(b.maximum,ut+gt),b.nt!==ut&&(Z-=b.nt-ut)}}for(;Z>0;){const rt=b.nt||0;if(isNaN(b.height)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+Z),b.nt!==rt&&(Z-=b.nt-rt)),b.index===0)break;b=t.getRowDefinition(b.index-1)}}let ht=0;for(let Z=0;Z=t.columnCount);Z++)b=t.getColumnDefinition(I.column+Z),ht+=b.total||0;if(ht=t.columnCount);at++){b=t.getColumnDefinition(I.column+at);const ut=b.nt||0,gt=rt(I,b,ft);b.actual=Math.min(b.maximum,ut+gt),b.nt!==ut&&(Z-=b.nt-ut)}}for(;Z>0;){const rt=b.nt||0;if(isNaN(b.width)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+Z),b.nt!==rt&&(Z-=b.nt-rt)),b.index===0)break;b=t.getColumnDefinition(b.index-1)}}}Util.tt(u),Size.s(E),Size.s(X),V!==void 0&&Util.tt(V),B!==void 0&&Util.tt(B);let Y=0,G=0;const H=t.desiredSize,J=t.maxSize;N=t.zs(!0),A=0,D=0;let z=0,W=0;l=t.columnCount;for(let K=0;K0){for(;p!==c&&(u[p]===void 0||u[p].nt===0);)p++;p=Math.max(Math.min(p,c-1),0),m=-u[p].position}let y=Math.min(t.leftIndex,f-1);if(d.length>0){for(;y!==f&&(d[y]===void 0||d[y].nt===0);)y++;y=Math.max(Math.min(y,f-1),0),g=-d[y].position}let x=0,k=0;for(;x!==c&&u[x]===void 0;)x++;for(;k!==c&&d[k]===void 0;)k++;const b=t.part;let P=t.getRowDefinition(x),M=t.getColumnDefinition(k);for(let C=0;C=t.rowCount);st++){const nt=t.getRowDefinition(C+st);nt.nt!==0&&(L.height+=nt.total)}for(let st=1;st=t.columnCount);st++){const nt=t.getColumnDefinition(N+st);nt.nt!==0&&(L.width+=nt.total)}const O=T.nt+L.width,U=S.nt+L.height;let X=h,E=a;const V=O,B=U,Y=h,G=a;let H=O,J=U;h+O>e.width&&(H=Math.max(e.width-h,0)),a+U>e.height&&(J=Math.max(e.height-a,0));let z=R.alignment,W=0,q=0,Q=0,K=0;if(z.isDefault()){z=t.defaultAlignment,z.isSpot()||(z=Spot.Center),W=z.x,q=z.y,Q=z.offsetX,K=z.offsetY;const st=T.alignment,nt=S.alignment;st.isSpot()&&(W=st.x,Q=st.offsetX),nt.isSpot()&&(q=nt.y,K=nt.offsetY)}else W=z.x,q=z.y,Q=z.offsetX,K=z.offsetY;(isNaN(W)||isNaN(q))&&(W=.5,q=.5,Q=0,K=0);let I=v.width,j=v.height;const $=R.margin,et=$.left+$.right,_=$.top+$.bottom,tt=R.S0(S,T,!1);isNaN(R.desiredSize.width)&&(tt===2||tt===5)&&(I=Math.max(O-et,0)),isNaN(R.desiredSize.height)&&(tt===2||tt===4)&&(j=Math.max(U-_,0));const it=R.maxSize,ct=R.minSize;I=Math.min(it.width,I),j=Math.min(it.height,j),I=Math.max(ct.width,I),j=Math.max(ct.height,j);const ot=I+et,lt=j+_;X+=V*W-ot*W+Q+$.left,E+=B*q-lt*q+K+$.top,R.visible&&(Rect.contains(Y,G,H,J,X,E,v.width,v.height)?R.zt(X,E,I,j):R.zt(X,E,I,j,new Rect(Y,G,H,J)))}}}Size.s(L);for(let C=0;C0&&(b.figure==="LineV"||b.figure==="LineH")){if(i.lineWidth=b.strokeWidth,t.dn(i,b.stroke,!1,!1,l,h),i.beginPath(),b.figure==="LineV"){const D=Math.floor((m-o)/o);for(let F=D;F<=D+f;F++){const R=F*o+m;0<=R&&R<=a&&this.jb(F,P,L,N)&&(i.moveTo(R,0),i.lineTo(R,c))}}else if(b.figure==="LineH"){const D=Math.floor((g-r)/r);for(let F=D;F<=D+u;F++){const R=F*r+g;0<=R&&R<=c&&this.jb(F,P,L,N)&&(i.moveTo(0,R),i.lineTo(a,R))}}i.stroke(),i.endPath()}else if(b.fill!==null){if(t.dn(i,b.fill,!0,!1,l,h),b.figure==="BarV"){let D=b.width;isNaN(D)&&(D=o);const F=Math.floor((m-o)/o);for(let R=F;R<=F+f;R++){const v=R*o+m;0<=v+D&&v<=a&&this.jb(R,P,L,N)&&i.fillRect(v,0,D,c)}}else if(b.figure==="BarH"){let D=b.height;isNaN(D)&&(D=r);const F=Math.floor((g-r)/r);for(let R=F;R<=F+u;R++){const v=R*r+g;0<=v+D&&v<=c&&this.jb(R,P,L,N)&&i.fillRect(0,v,a,D)}}}T&&i.disableDash(),C!==1&&(i.globalAlpha=S)}}jb(t,i,e,s){if(i<0)return t%i===e;if(t%i!==e)return!1;const n=s.length;for(let o=0;ol&&r.push(d)}}t.xi.Z0=i}A2(t){return t==="LineV"||t==="BarV"}$R(t){let i=1,e=1;const s=t.L.r,n=s.length;for(let l=0;l=g){const z=Point.l();c.mA(z),O=c.midAngle,A!==0&&(v=c.computeAngle(L,A,O),L.Xt=v,L.fe(!0),L._n(!0)),F=z.x-u.x,R=z.y-u.y,Point.s(z)}else{let z,W,q=0;if(S>=0?(z=m.elt(S),W=S0?m.elt(q-1):z),O=0,z.equalsApprox(W)){let Q,K;S>=0?(Q=S>0?m.elt(S-1):z,K=S1?m.elt(q-2):W);const I=Q.distanceSquaredPoint(z),j=W.distanceSquaredPoint(K);I>j+10?O=S>=0?Q.directionPoint(z):z.directionPoint(Q):j>I+10?O=S>=0?W.directionPoint(K):K.directionPoint(W):O=S>=0?Q.directionPoint(K):K.directionPoint(Q)}else O=S>=0?z.directionPoint(W):W.directionPoint(z);A!==0&&(v=c.computeAngle(L,A,O),L.Xt=v,L.fe(!0),L._n(!0)),F=z.x+(W.x-z.x)*N-u.x,R=z.y+(W.y-z.y)*N-u.y}L.ut(1/0,1/0,0,0),C=L.measuredBounds;const U=L.naturalBounds;let X=0;L instanceof Shape&&(X=L.strokeWidth);const E=U.width+X,V=U.height+X;k.Ri(),k.Ds(-C.x,-C.y),k.st(L.scale,L.scale),k.cs(A===0?L.angle:O,E/2,V/2),(A===22||A===26)&&k.cs(90,E/2,V/2),(A===23||A===27)&&k.cs(-90,E/2,V/2),A===28&&(O>45&&O<135||O>225&&O<315)&&k.cs(-O,E/2,V/2);const B=new Rect(0,0,E,V);b.setRectSpot(B,T),k.xt(b);const Y=-b.x+X/2*L.scale,G=-b.y+X/2*L.scale;P.a(D);const H=isNaN(D.x),J=isNaN(D.y);if(H||J){const z=E/2+3,W=V/2+3,q=O>=45&&O<=135,Q=O>=225&&O<=315;A===0&&(q||Q)?(P.x=J?z:D.y,P.y=H?W:D.x,q?S>=0||isNaN(S)&&N<.5||H&&(P.y=-W):Q&&((S>=0||isNaN(S)&&N<.5)&&H&&(P.y=-W),J&&(P.x=-z))):(H&&(S>=0||isNaN(S)&&N<.5?P.x=z:P.x=-z),J&&(P.y=-W),P.rotate(O))}else P.rotate(O);F+=P.x,R+=P.y,B.e(F+Y,R+G,C.width,C.height),x.push(B),d.unionRect(B)}if(h!==null){const M=h.labelNodes;for(;M.next();)M.value.ut(1/0,1/0)}t.Yo=d,t.position.e(u.x+d.x,u.y+d.y),n.En(d.width||0,d.height||0),Transform.s(k),Point.s(b),Point.s(P)}arrange(t,i,e){const s=i.length;if(!(t instanceof Adornment||t instanceof Link))return;let n=t,o=null;t instanceof Adornment&&(o=t,n=o.adornedPart);const r=t,l=t instanceof Adornment?null:n.path,h=t.lf;if(h.length!==0){let u=0;if(l!==null&&u=2&&r instanceof Link){const u=r.labelNodes;for(;u.next();){const d=u.value;r._R(d,c,a)}}o!==null?o.ad(!1):n.ad(!1);const f=t.pA(Point.l());t.location.e(t.position.x+f.x,t.position.y+f.y),Point.s(f)}measureLinkPath(t,i,e,s){if(s.Oo()===!1)return;let n=s.strokeWidth;if(n===0&&t instanceof Adornment&&t.type===Panel.Link&&t.adornedObject instanceof Shape&&(n=t.adornedObject.strokeWidth),n=n*s.st,t instanceof Link&&t.ft!==null){const o=t.geometry.bounds;s.Qn(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else if(t instanceof Adornment&&t.adornedPart.ft!==null){const o=t.adornedPart.ft.bounds;s.Qn(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else s.Qn(-(n/2),-(n/2),i+n,e+n);s.tv(),s.fe(!1)}}PanelLayout.definePanelLayout("Link",new PanelLayoutLink);class PanelLayoutGraduated extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=t.findMainElement();t.je=[];const h=l.margin,a=h.right+h.left,c=h.top+h.bottom;l.ut(i,e,o,r);const f=l.measuredBounds,u=f.width,d=f.height,m=Math.max(u+a,0),g=Math.max(d+c,0),p=new Rect(-h.left,-h.top,m,g);t.je.push(p),n.a(p),this.determineGraduatedMarks(t,l);const y=t.ws;if(y===null)return;const x=s.length;for(let k=0;k45&&f<135||f>225&&f<315)&&P.cs(-f,k/2,b/2);const M=Rect.X(0,0,k,b),L=Point.l();L.setRectSpot(M,o),P.xt(L);const C=-L.x,S=-L.y,N=Point.l();N.a(l),isNaN(N.x)&&(N.x=k/2+3),isNaN(N.y)&&(N.y=-(b/2+3)),N.rotate(f),a+=N.x+C,c+=N.y+S;const T=new Rect(a,c,y.width,y.height),A=new Rect(y.x,y.y,y.width,y.height),D=new Rect(x.x,x.y,x.width,x.height);p.labelAngle=u,p.lineCount=n.lineCount,p.lines=n.getMetrics(),p.actualBounds=T,p.measuredBounds=A,p.naturalBounds=D,g===0?h.a(T):h.unionRect(T),Point.s(N),Point.s(L),Rect.s(M),Transform.s(P)}t.je!==null&&t.je.push(h),s.unionNoCheck(h.x,h.y,h.width,h.height)}determineGraduatedMarks(t,i){const e=i.geometry,s=i.strokeWidth,n=e.flattenedSegments,o=e.flattenedLengths,r=e.flattenedTotalLength,l=n.length;let h=0,a=0;const c=Util.ot();for(let x=0;xt.graduatedMin+S){const F=Math.floor((N-t.graduatedMin)/S);N-=F*S}const T=f[x],A=N,D=t.graduatedMax*1e-6;for(let F=1;N<=t.graduatedMax+D;F++){if(this.ev(t,N-t.graduatedTickBase,T)&&(N>t.graduatedMax&&(N=t.graduatedMax),(k.graduatedSkip===null||k instanceof TextBlock&&!k.graduatedSkip(N,k)||k instanceof Shape&&!k.graduatedSkip(N,k))&&(m=(N-t.graduatedMin)*r/t.graduatedRange,m>r&&(m=r),g<=m&&m<=p))){let R=c[L][C],v=o[L][C];for(;LM&&C.4995)return t;let o=t;if(i<.5?n>0?o=s[n-1]:Geo.K(e[0],e[e.length-2])&&Geo.K(e[1],e[e.length-1])&&(o=s[s.length-1]):i>.5&&(n+1180&&(t.9995)return(t+o)/2%360;if(r<10){const l=1-Math.abs(.5-i);return(t*l+o*(1-l))%360}}return t}iv(t){if(t.ns===null){const i=[],e=t.L.r,s=e.length;for(let n=0;nl&&r.push(c)}}t.ns=i}return t.ns}ev(t,i,e){const s=e.length;for(let n=0;n-l)return!1}return!0}Gi(t,i,e){const s=e.Zh;e.Zh=!0;const n=t.naturalBounds,o=n.width,r=n.height,l=i instanceof SVGContext;i.save(),i.beginPath(),i.rect(-1,-1,o+1,r+1),i.clip(),i.endPath();const h=t.findMainElement();h.Gi(i,e);let a=t.getDocumentScale()*e.scale;a<=0&&(a=1);const c=h.actualBounds,f=t.L.r,u=t.ws,d=f.length;for(let m=0;m(w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ViewboxStretch||{});class Panel extends GraphObject{Z;L;$t;cd;Kn;el;so;Yo;D2;O;fd;ht;xi;Qt;ud;gh;Ys;constructor(t,i){if(super(),this.Z=null,t===void 0)this.Z=Panel.Position;else if(typeof t=="string"){const e=PanelLayout.Layouts.get(t);e!==null&&(this.Z=e)}else t instanceof PanelLayout?this.Z=t:t&&(this.Z=Panel.Position,i=t);this.Z===null&&Util.o("Panel type not specified or PanelLayout not loaded: "+t),this.n|=4194304|(this.Z===Panel.Grid?1048576:0),this.L=new List,this.$t=Margin.Ug,this.cd=Spot.Default,this.Kn=1,this.el=null,this.so="",this.Yo=new Rect(NaN,NaN,NaN,NaN),this.D2=null,this.O=null,this.fd=6,this.xi=null,this.ht=null,this.Qt=null,this.ud=NaN,this.gh=null,this.Ys=null,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.Z=this.Z,t.$t=this.$t.N(),t.cd=this.cd.N(),t.Kn=this.Kn,t.so=this.so,t.Yo.a(this.Yo),this.O!==null&&(t.O=this.O.copy(t)),t.fd=this.fd,this.ht!==null&&(t.ht=this.ht.copy()),this.xi!==null&&(t.xi=this.xi.copy()),t.Qt=this.Qt,t.ud=this.ud,t.gh=this.gh}Vo(t){super.Vo(t),t.L=this.L;const i=t.L.r,e=i.length;for(let s=0;s= 0",Panel,"padding"),t=new Margin(t)):(t.left<0&&Util._(t.left,">= 0",Panel,"padding:value.left"),t.right<0&&Util._(t.right,">= 0",Panel,"padding:value.right"),t.top<0&&Util._(t.top,">= 0",Panel,"padding:value.top"),t.bottom<0&&Util._(t.bottom,">= 0",Panel,"padding:value.bottom"));const i=this.$t;i.equals(t)||(t=t.N(),this.$t=t,this.c(),this.t("padding",i,t))}get defaultAlignment(){return this.cd}set defaultAlignment(t){const i=this.cd;i.equals(t)||(t=t.N(),this.cd=t,this.c(),this.t("defaultAlignment",i,t))}get defaultStretch(){return this.Kn}set defaultStretch(t){const i=this.Kn;i!==t&&(this.Kn=t,this.c(),this.t("defaultStretch",i,t))}get defaultSeparatorPadding(){return this.O!==null?this.O.Q0:Margin.Ug}set defaultSeparatorPadding(t){typeof t=="number"&&(t=new Margin(t));const i=this.defaultSeparatorPadding;i.equals(t)||(t=t.N(),this.O===null&&(this.O=new TablePanelSettings),this.O.Q0=t,this.c(),this.t("defaultSeparatorPadding",i,t))}get defaultRowSeparatorStroke(){return this.O!==null?this.O._0:null}set defaultRowSeparatorStroke(t){const i=this.defaultRowSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.g(),this.O===null&&(this.O=new TablePanelSettings),this.O._0=t,this.C(),this.t("defaultRowSeparatorStroke",i,t))}get defaultRowSeparatorStrokeWidth(){return this.O!==null?this.O.tp:1}set defaultRowSeparatorStrokeWidth(t){const i=this.defaultRowSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.O===null&&(this.O=new TablePanelSettings),this.O.tp=t,this.c(),this.t("defaultRowSeparatorStrokeWidth",i,t))}get defaultRowSeparatorDashArray(){return this.O!==null?this.O.ip:null}set defaultRowSeparatorDashArray(t){const i=this.defaultRowSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",Panel,"defaultRowSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("defaultRowSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.O===null&&(this.O=new TablePanelSettings),this.O.ip=t,this.C(),this.t("defaultRowSeparatorDashArray",i,t)}}get defaultColumnSeparatorStroke(){return this.O!==null?this.O.ep:null}set defaultColumnSeparatorStroke(t){const i=this.defaultColumnSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.g(),this.O===null&&(this.O=new TablePanelSettings),this.O.ep=t,this.C(),this.t("defaultColumnSeparatorStroke",i,t))}get defaultColumnSeparatorStrokeWidth(){return this.O!==null?this.O.sp:1}set defaultColumnSeparatorStrokeWidth(t){const i=this.defaultColumnSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.O===null&&(this.O=new TablePanelSettings),this.O.sp=t,this.c(),this.t("defaultColumnSeparatorStrokeWidth",i,t))}get defaultColumnSeparatorDashArray(){return this.O!==null?this.O.np:null}set defaultColumnSeparatorDashArray(t){const i=this.defaultColumnSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",Panel,"defaultColumnSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("defaultColumnSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.O===null&&(this.O=new TablePanelSettings),this.O.np=t,this.C(),this.t("defaultColumnSeparatorDashArray",i,t)}}get dh(){return this.O!==null?this.O.dh:null}set dh(t){this.O===null&&(this.O=new TablePanelSettings),this.O.dh=t}get viewboxStretch(){return this.fd}set viewboxStretch(t){const i=this.fd;i!==t&&(this.fd=t,this.c(),this.t("viewboxStretch",i,t))}get gridCellSize(){return this.xi!==null?this.xi.dd:Size.eC}set gridCellSize(t){this.xi===null&&(this.xi=new GridPanelSettings);const i=this.xi.dd;if(!i.equals(t)){(!t.isReal()||t.width===0||t.height===0)&&Util.o("Invalid Panel.gridCellSize: "+t),this.xi.dd=t.N();const e=this.diagram;e!==null&&this===e.grid&&e.jr(),this.C(),this.t("gridCellSize",i,t)}}get gridOrigin(){return this.xi!==null?this.xi.gd:Point.Po}set gridOrigin(t){this.xi===null&&(this.xi=new GridPanelSettings);const i=this.xi.gd;if(!i.equals(t)){t.isReal()||Util.o("Invalid Panel.gridOrigin: "+t),this.xi.gd=t.N();const e=this.diagram;e!==null&&this===e.grid&&e.jr(),this.C(),this.t("gridOrigin",i,t)}}get graduatedMin(){return this.ht!==null?this.ht.op:0}set graduatedMin(t){const i=this.graduatedMin;if(i!==t&&(this.ht===null&&(this.ht=new GradPanelSettings),this.ht.op=t,this.c(),this.t("graduatedMin",i,t),this.Jc())){const e=this.part;e!==null&&this.pa(e,"graduatedRange")}}get graduatedMax(){return this.ht!==null?this.ht.rp:100}set graduatedMax(t){const i=this.graduatedMax;if(i!==t&&(this.ht===null&&(this.ht=new GradPanelSettings),this.ht.rp=t,this.c(),this.t("graduatedMax",i,t),this.Jc())){const e=this.part;e!==null&&this.pa(e,"graduatedRange")}}get graduatedRange(){return this.graduatedMax-this.graduatedMin}get graduatedTickUnit(){return this.ht!==null?this.ht.lp:10}set graduatedTickUnit(t){const i=this.graduatedTickUnit;i!==t&&t>0&&(this.ht===null&&(this.ht=new GradPanelSettings),this.ht.lp=t,this.c(),this.t("graduatedTickUnit",i,t))}get graduatedTickBase(){return this.ht!==null?this.ht.hp:0}set graduatedTickBase(t){const i=this.graduatedTickBase;i!==t&&(this.ht===null&&(this.ht=new GradPanelSettings),this.ht.hp=t,this.c(),this.t("graduatedTickBase",i,t))}get ws(){return this.ht!==null?this.ht.ws:null}set ws(t){this.ht!==null?this.ht.ws=t:t!==null&&(this.ht=new GradPanelSettings,this.ht.ws=t)}get je(){return this.ht!==null?this.ht.je:null}set je(t){this.ht!==null?this.ht.je=t:t!==null&&(this.ht=new GradPanelSettings,this.ht.je=t)}get ns(){return this.ht!==null?this.ht.ns:null}set ns(t){this.ht!==null?this.ht.ns=t:t!==null&&(this.ht=new GradPanelSettings,this.ht.ns=t)}get Me(){return this.ht!==null?this.ht.Me:null}set Me(t){this.ht!==null?this.ht.Me=t:t!==null&&(this.ht=new GradPanelSettings,this.ht.Me=t)}b0(t){super.b0(t);const i=this.L.r,e=i.length;for(let s=0;s0?this.Ye:null,s=this.columnCount>0?this.Ge:null;e!==null&&this.Hb(t,i,!0,e,!0),s!==null&&this.Hb(t,i,!1,s,!0),e!==null&&this.wA(t,!0,e),s!==null&&this.wA(t,!1,s),e!==null&&this.Hb(t,i,!0,e,!1),s!==null&&this.Hb(t,i,!1,s,!1)}wA(t,i,e){const s=e.length,n=this.actualBounds,o=this.naturalBounds;let r=!0;for(let l=0;lo.height)continue}else if(h.position>o.width)continue;let a=h.separatorStrokeWidth;isNaN(a)&&(a=i?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let c=h.separatorStroke;if(c===null&&(c=i?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),a===0||c===null)continue;this.dn(t,c,!1,!1,o,n);let f=!1,u=h.separatorDashArray;u===null&&(u=i?this.defaultRowSeparatorDashArray:this.defaultColumnSeparatorDashArray),u!==null&&(f=!0,t.enableDash(u,0)),t.beginPath();const d=h.position+a;i?d>o.height&&(a-=d-o.height):d>o.width&&(a-=d-o.width);let m=h.position+a/2;t.lineWidth=a;const g=this.$t;if(i){m+=g.top;const p=g.left,y=o.width-g.right;t.moveTo(p,m),t.lineTo(y,m)}else{m+=g.left;const p=g.top,y=o.height-g.bottom;t.moveTo(m,p),t.lineTo(m,y)}t.stroke(),t.endPath(),f&&t.disableDash()}}Hb(t,i,e,s,n){const o=s.length,r=this.actualBounds,l=this.naturalBounds,h=this.xA(!0),a=this.xA(!1);for(let c=0;cu)continue;let d=f.computeEffectiveSpacing(),m=f.separatorStrokeWidth;isNaN(m)&&(m=e?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let g=f.separatorStroke;g===null&&(g=e?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),(g===null||f.index===(e?h:a))&&(m=0),d-=m;const p=f.position+m;let y=d+f.actual;if(p+y>u&&(y=u-p),y<=0)continue;const x=this.$t;this.dn(t,f.background,!0,!1,l,r),e?t.fillRect(x.left,p+x.top,r.width-(x.left+x.right),y):t.fillRect(p+x.left,x.top,y,r.height-(x.top+x.bottom))}}xA(t){const i=t?this.rowCount:this.columnCount;for(let e=0;ex&&n.set(S),Point.s(S)),Point.s(M),o&&n.D(r),k}}Fu(){const t=this.L.r,i=t.length;for(let e=0;ee||h>s)&&(this.c(),this.ut(l>e?e:l,h>s?s:h,0,0));break;case 2:this.c(!0),this.ut(e+c,s+f,0,0);break;case 5:this.c(!0),this.ut(e+c,h+f,0,0);break;case 4:this.c(!0),this.ut(l+c,s+f,0,0);break}}this.Z.arrange(this,n,this.Yo)}lh(t){const i=this.naturalBounds,e=this.Ko();if(Rect.contains(0,0,i.width,i.height,t.x,t.y)){const s=this.L.r,n=s.length,o=Point.X(0,0);for(let r=n;r--;){const l=s[r];if(!(!l.visible&&l!==e)&&(o.set(t).Ie(l.D),l.containsPoint(o)))return Point.s(o),!0}return Point.s(o),this.Ct!==null}return!1}p0(t){if(this.$n===t)return this;const i=this.L.r,e=i.length;for(let s=0;sd.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;let m=f;const g=f instanceof Panel?f:null,p=Transform.l();p.set(r),(g!==null?g.Om(t,i,e,s,n,p):m._L(t,s,p))&&(i!==null&&(m=i(m)),m!==null&&(e===null||e(m))&&n.add(m)),Transform.s(p)}}return o===void 0&&Transform.s(r),s}return o===void 0&&Transform.s(r),!1}R2(t,i,e){const s=this.L.r,n=s.length;for(let o=n;o--;){const r=s[o];if(!r.visible)continue;const l=r.actualBounds,h=this.naturalBounds;if(l.x>h.width||l.y>h.height||l.x+l.width<0||l.y+l.height<0)continue;r instanceof Panel&&r.R2(t,i,e);let a=r;t!==null&&(a=t(a)),a!==null&&(i===null||i(a))&&e.add(a)}}sL(t,i,e,s,n,o){if(this.pickable===!1)return!1;e===void 0&&(e=null),s===void 0&&(s=null);const r=this.naturalBounds,l=this.pn(),h=l?t:Point.X(t.x,t.y).Ie(this.D),a=l?i:Point.X(i.x,i.y).Ie(this.D),c=h.distanceSquaredPoint(a),f=h.x>0&&h.x0&&h.yP.width||b.y>P.height||b.x+b.width<0||b.y+b.height<0))continue;if(k.pn()){const C=k.D;d.set(t).Ie(C),m.set(i).Ie(C)}else d.set(t),m.set(i);let M=k;const L=k instanceof Panel?k:null;(L!==null?L.sL(d,m,e,s,n,o):M.tA(d,m,n))&&(e!==null&&(M=e(M)),M!==null&&(s===null||s(M))&&o.add(M))}Point.s(d),Point.s(m)}return n?f:u}return!1}C2(t){let i=null;if(t instanceof Shape){i=t.spot1,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot1)}return i===null&&(i=Spot.TopLeft),i}L2(t){let i=null;if(t instanceof Shape){i=t.spot2,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot2)}return i===null&&(i=Spot.BottomRight),i}add(...t){for(let i=0;i=s.count&&t>=s.count)return;s.removeAt(r),n=r}else Util.o("element "+i.toString()+" has panel "+e.toString()+" but is not contained by it.")}(t<0||t>s.count)&&(t=s.count),s.insertAt(t,i),(t===0||i.isPanelMain)&&(this.el=null),this.Oo()||this.c(),i.c(!1),i.portId!==null?this.wn=!0:i instanceof Panel&&i.wn===!0&&(this.wn=!0),this.ns=null,this.isEnabledObject()||this.qb(i,!1);const o=this.part;if(o!==null){o.T0(),o.af(),this.wn&&o instanceof Node&&(o.wn=!0),o.wn&&o instanceof Node&&(o.se=null);const r=this.diagram;if(r!==null&&r.undoManager.isUndoingRedoing)return;n!==-1&&o.raiseChangedEvent(4,"elements",this,i,null,n,null),o.raiseChangedEvent(3,"elements",this,null,i,null,t)}}get wn(){return(this.n&8388608)!==0}set wn(t){(this.n&8388608)!==0!==t&&(this.n=this.n^8388608)}s2(){return(this.n&16777216)!==0}v2(t){t?this.n|=16777216:this.n&=-16777217}hv(t){t.wa(this),t.Qr=null;const i=this.L,e=i.count;i.insertAt(e,t);const s=this.part;if(s!==null){s.T0(),t.portId!==null&&s instanceof Node&&(s.wn=!0);const n=this.diagram;if(n!==null&&n.undoManager.isUndoingRedoing)return;s.raiseChangedEvent(3,"elements",this,null,t,null,e)}}DR(t){const i=this.L.r,e=i.length;let s=-1;for(let n=0;n=0&&this._i(t,!0)}_i(t,i){const e=this.L,s=e.elt(t);if(s.Qr=null,s.wa(null),this.Ys!==null){const o=s.data;typeof o=="object"&&this.Ys.delete(o)}e.removeAt(t),this.fe(!1),this.c(),this.el===s&&(this.el=null),this.ns=null;const n=this.part;if(n!==null){n.T0(),n.af(),n.invalidateAdornments(),n instanceof Node&&(s instanceof Panel?s.walkVisualTreeFrom(s,(r,l)=>n.g2(l,i)):n.g2(s,i));const o=this.diagram;if(o!==null&&o.undoManager.isUndoingRedoing)return;n.raiseChangedEvent(4,"elements",this,s,null,t,null)}}get Ye(){return this.O===null&&(this.O=new TablePanelSettings),this.O.Ye}get rowCount(){return this.O===null?0:this.Ye.length}getRowDefinition(t){t<0&&Util._(t,">= 0",Panel,"getRowDefinition:idx"),t=Math.round(t);const i=this.Ye;if(i[t]===void 0){const e=new RowColumnDefinition;e.wa(this),e.isRow=!0,e.index=t,i[t]=e,this.raiseChangedEvent(3,"rowdefs",this,null,e,null,t)}return i[t]}removeRowDefinition(t){if(t<0&&Util._(t,">= 0",Panel,"removeRowDefinition:idx"),this.rowCount===0)return;t=Math.round(t);const i=this.Ye,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"rowdefs",this,e,null,t,null),this.c()}}FL(t,i){const e=this.Ye;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.c()}}get Ge(){return this.O===null&&(this.O=new TablePanelSettings),this.O.Ge}get columnCount(){return this.O===null?0:this.Ge.length}getColumnDefinition(t){t<0&&Util._(t,">= 0",Panel,"getColumnDefinition:idx"),t=Math.round(t);const i=this.Ge;if(i[t]===void 0){const e=new RowColumnDefinition;e.wa(this),e.isRow=!1,e.index=t,i[t]=e,this.raiseChangedEvent(3,"coldefs",this,null,e,null,t)}return i[t]}removeColumnDefinition(t){if(t<0&&Util._(t,">= 0",Panel,"removeColumnDefinition:idx"),this.columnCount===0)return;t=Math.round(t);const i=this.Ge,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"coldefs",this,e,null,t,null),this.c()}}RL(t,i){const e=this.Ge;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.c()}}addRowColumnDefinition(t){let i=null;return t.isRow?i=this.getRowDefinition(t.index):t.isRow||(i=this.getColumnDefinition(t.index)),i&&i.Bb(t),this}addRowDefinition(t,i){const e=this.getRowDefinition(t);return e&&e.Bb(new RowColumnDefinition(i)),this}addColumnDefinition(t,i){const e=this.getColumnDefinition(t);return e&&e.Bb(new RowColumnDefinition(i)),this}get rowSizing(){return this.O!==null?this.O.cp:3}set rowSizing(t){const i=this.rowSizing;i!==t&&(this.O===null&&(this.O=new TablePanelSettings),this.O.cp=t,this.c(),this.t("rowSizing",i,t))}get columnSizing(){return this.O!==null?this.O.fp:3}set columnSizing(t){const i=this.columnSizing;i!==t&&(this.O===null&&(this.O=new TablePanelSettings),this.O.fp=t,this.c(),this.t("columnSizing",i,t))}get topIndex(){return this.O!==null?this.O.dp:0}set topIndex(t){const i=this.topIndex;i!==t&&((!isFinite(t)||t<0)&&Util.o("Panel.topIndex must be greater than zero and a real number, not: "+t),this.O===null&&(this.O=new TablePanelSettings),this.O.dp=t,this.c(),this.t("topIndex",i,t))}get leftIndex(){return this.O!==null?this.O.gp:0}set leftIndex(t){const i=this.leftIndex;i!==t&&((!isFinite(t)||t<0)&&Util.o("Panel.leftIndex must be greater than zero and a real number, not: "+t),this.O===null&&(this.O=new TablePanelSettings),this.O.gp=t,this.c(),this.t("leftIndex",i,t))}findRowForLocalY(t){if(t<0||this.type!==Panel.Table||this.rowCount===0)return-1;let i=0;const e=this.Ye,s=e.length;let n=this.topIndex;for(;n{o.rh();const r=o.Ai;if(r!==null){o.f2(!1);const l=r.iterator;for(;l.next();){const h=l.value;h.mode===2&&o.f2(!0);const a=h.sourceName;if(h.isToObject){a==="/"&&n.v2(!0);const c=h.QL(n,o);c!==null&&(i.add(c),c.Zn===null&&(c.Zn=new List),c.Zn.add(h))}t.add(h)}}if(o instanceof Panel&&o.type===Panel.Table){if(o.rowCount>0){const l=o.Ye,h=l.length;for(let a=0;a0){const l=o.Ge,h=l.length;for(let a=0;a0&&o instanceof Panel){const h=r.substring(0,l),a=r.substring(l+1),c=o.findObject(h);c!==null?(o=c,n.targetProperty=a):(Util.oi('Warning: unable to find GraphObject named "'+h+'" for Binding: '+n.toString()),o=null)}if(o instanceof RowColumnDefinition){const h=GSet.as(o.panel);n.targetId=h===void 0?-1:h,o.panel.$n=n.targetId}else if(o instanceof GraphObject){const h=GSet.as(o);n.targetId=h===void 0?-1:h,o.$n=n.targetId}else Util.o("Unknown type of binding target: "+o);n.check(o)}}return t.g(),this instanceof Part&&this.Pe()&&this.ensureBounds(),this}static gE=!1;copyTemplate(t){t===void 0&&(t=!1);const i=this.copy();return i.av(e=>{e instanceof Panel&&(e.Ks=null,e.Qt=null);const s=e.Ai;s!==null&&(e.Ai=null,s.each(o=>e.bind(o.copy())));const n=e.ys;n!==null&&(e.ys=null,n.each(o=>e.trigger(o.value.copy())))}),t&&i.li(),i}updateTargetBindings(t){const i=this.Ks;if(i===null)return;t===void 0&&(t="");const e=i.iterator;for(;e.next();){const s=e.value,n=this.SA(s,t);if(n===null)continue;const{data:o,elt:r}=n;s.isToTheme&&this.diagram===null||r!==void 0&&s.updateTarget(r,o)}}Io(){if(this.diagram!==null)if(this.m2()){const t=this.Ks.iterator;for(;t.next();){const i=t.value;if(!i.isToTheme)continue;const e=this.SA(i);if(e===null)continue;const{data:s,elt:n}=e;n!==void 0&&i.updateTarget(n,s)}}else{const t=this.L.r,i=t.length;for(let e=0;e0;let r=0;for(;n0){const i=this.L.elt(0);if(i.isPanelMain&&i instanceof Panel&&i._r())return 1}return 0}rebuildItemElements(){const t=this.ap();for(;this.L.length>t;)this._i(this.L.length-1,!1);this.NA(null,this.itemArray)}NA(t,i){const e=this.ap(),s=i;if(s===null||s.length===0){for(;this.L.length>e;)this._i(this.L.length-1,!1);return}if(this.L.length<=e){const n=s.length;for(let o=0;o(w[w.Default=1]="Default",w[w.None=2]="None",w[w.ProportionalExtra=3]="ProportionalExtra",w))(Sizing||{});class RowColumnDefinition{Vs;mp;Dt;Pa;Ma;ni;ct;pd;to;Go;yd;wd;Sa;Ct;xd;Gs;nt;ji;de;constructor(t){GSet.Yi(this),this.Vs=null,this.mp=!0,this.Dt=0,this.de=NaN,this.Pa=0,this.Ma=1/0,this.ni=Spot.Default,this.nt=0,this.ji=0,this.ct=0,this.Gs=null,this.pd=1,this.to=1,this.Go=null,this.yd=null,this.wd=NaN,this.Sa=null,this.Ct=null,this.xd=!1,t&&(Object.assign(this,t),t.column!==void 0?(this.isRow=!1,this.index=t.column):t.row!==void 0&&(this.isRow=!0,this.index=t.row))}copy(){const t=new RowColumnDefinition;return t.mp=this.mp,t.Dt=this.Dt,t.de=this.de,t.Pa=this.Pa,t.Ma=this.Ma,t.ni=this.ni,t.nt=this.nt,t.ji=this.ji,t.ct=this.ct,t.to=this.to,t.pd=this.pd,this.Go===null?t.Go=null:t.Go=this.Go.N(),t.yd=this.yd,t.wd=this.wd,t.Sa=null,this.Sa!==null&&(t.separatorDashArray=this.separatorDashArray.slice()),t.Ct=this.Ct,t.xd=this.xd,t.Gs=this.Gs,t}Bb(t){t.isRow?this.height=t.height:this.width=t.width,this.minimum=t.minimum,this.maximum=t.maximum,this.alignment=t.alignment,this.stretch=t.stretch,this.sizing=t.sizing,this.Go=t.separatorPadding===null?null:t.separatorPadding.N(),this.separatorStroke=t.separatorStroke,this.separatorStrokeWidth=t.separatorStrokeWidth,this.Sa=null,t.separatorDashArray&&(this.Sa=t.separatorDashArray.slice()),this.background=t.background,this.coversSeparators=t.coversSeparators,this.Gs=t.Gs}ri(t){t in Sizing?this.sizing=t:Util.lr(this,t)}toString(){return"RowColumnDefinition "+(this.isRow?"(Row ":"(Column ")+this.index+") #"+GSet.as(this)}static Default=1;static None=2;static ProportionalExtra=3;wa(t){this.Vs=t}computeEffectiveSpacingTop(t){let i=0;const e=this.Vs;if(this.index!==t){let n=this.separatorStroke;n===null&&e!==null&&(n=this.isRow?e.defaultRowSeparatorStroke:e.defaultColumnSeparatorStroke),n!==null&&(i=this.separatorStrokeWidth,isNaN(i)&&(e!==null?i=this.isRow?e.defaultRowSeparatorStrokeWidth:e.defaultColumnSeparatorStrokeWidth:i=0))}let s=this.Go;if(s===null)if(e!==null)s=e.defaultSeparatorPadding;else return i;return i+(this.isRow?s.top:s.left)}computeEffectiveSpacing(){let t=0;const i=this.Vs;let e=0;const s=this.isRow;if(i!==null&&i.type===Panel.Table){const o=s?i.Ye.length:i.Ge.length;for(let r=0;r= 0",RowColumnDefinition,"height"),this.de=t,this.actual=this.nt,this.panel!==null&&this.panel.c(),this.t("height",i,t))}get width(){return this.de}set width(t){const i=this.de;i!==t&&(t<0&&Util._(t,">= 0",RowColumnDefinition,"width"),this.de=t,this.actual=this.nt,this.panel!==null&&this.panel.c(),this.t("width",i,t))}get minimum(){return this.Pa}set minimum(t){const i=this.Pa;i!==t&&((t<0||!isFinite(t))&&Util._(t,">= 0",RowColumnDefinition,"minimum"),this.Pa=t,this.actual=this.nt,this.panel!==null&&this.panel.c(),this.t("minimum",i,t))}get maximum(){return this.Ma}set maximum(t){const i=this.Ma;i!==t&&(t<0&&Util._(t,">= 0",RowColumnDefinition,"maximum"),this.Ma=t,this.actual=this.nt,this.panel!==null&&this.panel.c(),this.t("maximum",i,t))}get alignment(){return this.ni}set alignment(t){const i=this.ni;i.equals(t)||(this.ni=t.N(),this.panel!==null&&this.panel.c(),this.t("alignment",i,t))}get stretch(){return this.to}set stretch(t){const i=this.to;i!==t&&(this.to=t,this.panel!==null&&this.panel.c(),this.t("stretch",i,t))}get separatorPadding(){return this.Go}set separatorPadding(t){typeof t=="number"&&(t=new Margin(t));const i=this.Go;(t===null||i===null||!i.equals(t))&&(t!==null&&(t=t.N()),this.Go=t,this.panel!==null&&this.panel.c(),this.t("separatorPadding",i,t))}get separatorStroke(){return this.yd}set separatorStroke(t){const i=this.yd;i!==t&&(t!==null&&Brush.od(t,"RowColumnDefinition.separatorStroke"),t instanceof Brush&&t.g(),this.yd=t,this.panel!==null&&this.panel.c(),this.t("separatorStroke",i,t))}get separatorStrokeWidth(){return this.wd}set separatorStrokeWidth(t){const i=this.wd;i!==t&&(this.wd=t,this.panel!==null&&this.panel.c(),this.t("separatorStrokeWidth",i,t))}get separatorDashArray(){return this.Sa}set separatorDashArray(t){const i=this.Sa;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",RowColumnDefinition,"separatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("separatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.Sa=t,this.panel!==null&&this.panel.C(),this.t("separatorDashArray",i,t)}}get background(){return this.Ct}set background(t){const i=this.Ct;i!==t&&(t!==null&&Brush.od(t,"RowColumnDefinition.background"),t instanceof Brush&&t.g(),this.Ct=t,this.panel!==null&&this.panel.C(),this.t("background",i,t))}get coversSeparators(){return this.xd}set coversSeparators(t){const i=this.xd;i!==t&&(Util.i(t,"boolean",RowColumnDefinition,"coversSeparators"),this.xd=t,this.panel!==null&&this.panel.C(),this.t("coversSeparators",i,t))}get sizing(){return this.pd}set sizing(t){const i=this.pd;i!==t&&(this.pd=t,this.panel!==null&&this.panel.c(),this.t("sizing",i,t))}Gb(){if(this.sizing===1){const t=this.Vs;return this.isRow?t.rowSizing:t.columnSizing}return this.sizing}get actual(){return this.nt}set actual(t){isNaN(this.de)?this.nt=Math.max(Math.min(this.Ma,t),this.Pa):this.nt=Math.max(Math.min(this.Ma,this.de),this.Pa)}get measured(){return this.ji}set measured(t){this.ji=t}get total(){return this.nt+this.computeEffectiveSpacing()}get position(){return this.ct}set position(t){this.ct=t}bind(t,i,e,s){return this.ef(t,i,e,s),this}bindTwoWay(t,i,e,s){const n=this.ef(t,i,e,s);return s===void 0&&n.makeTwoWay(),this}theme(t,i,e,s,n){return this.fh(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.fh(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.fh(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.fh(t,i,e,s,n).ofModel(),this}ef(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.Y0(n),n}fh(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.Y0(o),o}Y0(t){t.ke=this;const i=this.panel;if(i!==null){const e=i.findBindingPanel();e!==null&&e.cA()&&Util.o("Cannot add a Binding to a RowColumnDefinition that is already frozen: "+t+" on "+i)}this.Gs===null&&(this.Gs=new List),this.Gs.add(t)}}class Shape extends GraphObject{ft;xs;bd;Na;Hi;jo;Xo;Lt;kd;Pd;J;constructor(t,i){super(),this.ft=null,this.xs=null,this.bd="None",this.Na="black",this.Hi="black",this.jo=1,this.Xo=null,this.Lt=null,this.kd=NaN,this.Pd=NaN,this.J=null,typeof t=="string"?this.figure=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.ft=this.ft,t.xs=this.xs,t.bd=this.bd,t.Na=this.Na,t.Hi=this.Hi,t.jo=this.jo,this.Xo!==null&&(t.Xo=this.Xo.slice()),this.Lt!==null&&(this.Lt.gi?t.Lt=this.Lt:t.Lt=this.Lt.copy()),t.kd=this.kd,t.Pd=this.Pd,this.J!==null&&(t.J=this.J.copy())}Ca(){this.Lt===null?this.Lt=new ShapeTemplateSettings:this.Lt.gi&&(this.Lt=this.Lt.copy())}rh(){super.rh(),this.Lt!==null&&(this.Lt.gi=!0)}ri(t){t in GeometryStretch?this.geometryStretch=t:super.ri(t)}toString(){return"Shape("+(this.figure!=="None"?this.figure:this.toArrow!=="None"?this.toArrow:this.fromArrow)+")#"+GSet.as(this)}pv(t,i){const e=this.pathPattern;e.ut(1/0,1/0);const s=e.measuredBounds;e.zt(0,0,s.width,s.height);const n=this.geometry;t.save(),t.beginPath();const o=Util.ot();if(n.type===1)o.push(n.startX),o.push(n.startY),o.push(n.endX),o.push(n.endY),this.Md(t,i,o,e);else if(n.type===4){const r=n.figures.iterator;for(;r.next();){const l=r.value;o.length=0,o.push(l.startX),o.push(l.startY);let h=l.startX,a=l.startY,c=h,f=a;const u=l.segments.r,d=u.length;for(let m=0;m=.1;){if(S===0&&(M?(b=k,b-=P,y-=P,M=!1):b=k,b===0&&(b=1)),b>y){b=y,Util.tt(x);return}b>p?(S=b-p,b=p):S=0;let N=Math.sqrt(b*b/(1+m*m));if(u<0&&(N=-N),h+=N,a+=m*N,t.translate(h,a),t.rotate(g),t.translate(-(r/2),-(l/2)),S===0&&s.ch(t,i),t.translate(r/2,l/2),t.rotate(-g),t.translate(-h,-a),y-=b,p-=b,S!==0){if(L++,L===x.length){Util.tt(x);return}C=x[L],u=C[0],g=C[1],m=C[2],p=C[3],b=S}}Util.tt(x)}ch(t,i){const e=t instanceof SVGContext;let s=this.Hi;const n=this.Na;if(s===null&&n===null)return;const o=this.ft;if(o===null)return;t.commitTransform();const r=this.actualBounds,l=this.naturalBounds;n!==null&&this.dn(t,n,!0,!1,l,r);const h=this.part;let a=this.jo;s!==null&&a===0&&h!==null&&(this.isPanelMain||h.findMainElement()===this)&&(a=h.wv()),a===0&&(s=null),s!==null&&a!==0&&(this.dn(t,s,!1,!1,l,r),t.lineWidth=a,t.lineJoin=this.strokeJoin,t.lineCap=this.strokeCap,t.miterLimit=this.strokeMiterLimit);let c=!1;h&&i.getRenderingHint("drawShadows")&&(c=h.isShadowed),t.tl===!1&&(c=!1);let f=!0;s!==null&&(n===null||n==="transparent")&&(f=!1);let u=!1;const d=this.strokeDashArray;if(d!==null&&(u=!0,t.enableDash(d,this.strokeDashOffset)),o.type===1)t.beginPath(),t.moveTo(o.startX,o.startY),t.lineTo(o.endX,o.endY),s!==null&&t.strokeContext(),t.endPath();else if(o.type===2){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.min(m,p),k=Math.min(g,y),b=Math.abs(p-m),P=Math.abs(y-g);t.beginPath(),t.rect(x,k,b,P),n!==null&&t.fillContext(n,!1,null),s!==null&&(f&&c&&t.shadowsOff(),t.strokeContext(),f&&c&&t.shadowsOn()),t.endPath()}else if(o.type===3){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.abs(p-m)/2,k=Math.abs(y-g)/2,b=Math.min(m,p)+x,P=Math.min(g,y)+k;t.beginPath(),t.moveTo(b,P-k),t.bezierCurveTo(b+Geo.Un*x,P-k,b+x,P-Geo.Un*k,b+x,P),t.bezierCurveTo(b+x,P+Geo.Un*k,b+Geo.Un*x,P+k,b,P+k),t.bezierCurveTo(b-Geo.Un*x,P+k,b-x,P+Geo.Un*k,b-x,P),t.bezierCurveTo(b-x,P-Geo.Un*k,b-Geo.Un*x,P-k,b,P-k),t.closePath(),n!==null&&t.fillContext(n,!1,null),s!==null&&(f&&c&&t.shadowsOff(),t.strokeContext(),f&&c&&t.shadowsOn()),t.endPath()}else if(o.type===4){const m=o.figures,g=m.length;for(let p=0;p1||this.pathPattern!==null?!0:super.sd(t)}h2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("path");for(let s=0;s1,i);Util.o("Unknown Geometry type: "+e.type)}}_u(t,i,e,s){const n=this.desiredSize,o=this.jo;t=Math.max(t,0),i=Math.max(i,0);let r;if(this.xs!==null)r=this.geometry.bounds;else{const g=this.figure;let p=Shape.U2[g];if(p===void 0){let y=Geo.Mo[g];typeof y=="string"&&(y=Geo.Mo[y]),typeof y=="function"?(p=y(null,100,100),Shape.U2[g]=p):Util.o("Unsupported Figure: "+g)}r=p.bounds}let l=r.width,h=r.height,a=r.width,c=r.height;switch(this.zs(!0)){case 0:e=0,s=0;break;case 2:a=Math.max(t-o,0),c=Math.max(i-o,0);break;case 5:a=Math.max(t-o,0),s=0;break;case 4:e=0,c=Math.max(i-o,0);break}isFinite(n.width)&&(a=n.width),isFinite(n.height)&&(c=n.height);const u=this.maxSize,d=this.minSize;e=Math.max(e-o,d.width),s=Math.max(s-o,d.height),a=Math.min(u.width,a),c=Math.min(u.height,c),a=isFinite(a)?Math.max(e,a):Math.max(l,e),c=isFinite(c)?Math.max(s,c):Math.max(h,s);const m=this._P();switch(m){case 0:break;case 2:l=a,h=c;break;case 6:{let g=Math.min(a/l,c/h);isFinite(g)||(g=1),l=l*g,h=h*g;break}default:Util.o(m+" is not a valid geometryStretch.")}if(this.xs!==null){l===0&&(l=.001),h===0&&(h=.001);const p=(this.xs!==null?this.xs:this.ft).YD(l,h);this.ft=p}else(this.ft===null||!Geo.K(this.ft.ec,t-o)||!Geo.K(this.ft.sc,i-o))&&(this.ft=Shape.xv(this,l,h));r=this.ft.bounds,t===1/0||i===1/0?this.Qn(r.x-o/2,r.y-o/2,t===0&&l===0?0:r.width+o,i===0&&h===0?0:r.height+o):this.Qn(-(o/2),-(o/2),a+o,c+o),n.isReal()?(a=n.width,c=n.height,a=Math.min(u.width,a),c=Math.min(u.height,c),a=Math.max(d.width,a),c=Math.max(d.height,c),this.Vi.e(0,0,a,c)):this.Vi.a(r)}_P(){const t=this.geometryStretch;return this.xs!==null?t===1?2:t:t===1?Shape.U2[this.figure].defaultStretch:t}hh(t,i,e,s){this.commonArrange(t,i,e,s)}getNearestIntersectionPoint(t,i,e){return this.$c(t.x,t.y,i.x,i.y,e)}$c(t,i,e,s,n){const o=this.D,r=1/(o.m11*o.m22-o.m12*o.m21),l=o.m22*r,h=-o.m12*r,a=-o.m21*r,c=o.m11*r,f=r*(o.m21*o.dy-o.m22*o.dx),u=r*(o.m12*o.dx-o.m11*o.dy),d=t*l+i*a+f,m=t*h+i*c+u,g=e*l+s*a+f,p=e*h+s*c+u,y=this.jo/2;let x=this.ft;x===null&&(this.ut(1/0,1/0),x=this.ft);const k=x.bounds;let b=!1;if(x.type===1)if(this.strokeWidth<=1.5)b=Geo.Vn(x.startX,x.startY,x.endX,x.endY,d,m,g,p,n);else{let P=0,M=0;if(x.startX===x.endX)P=y,M=0;else{const T=(x.endY-x.startY)/(x.endX-x.startX);M=y/Math.sqrt(1+T*T),P=M*T}const L=Util.ot();let C=new Point;Geo.Vn(x.startX+P,x.startY+M,x.endX+P,x.endY+M,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Vn(x.startX-P,x.startY-M,x.endX-P,x.endY-M,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Vn(x.startX+P,x.startY+M,x.startX-P,x.startY-M,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Vn(x.endX+P,x.endY+M,x.endX-P,x.endY-M,d,m,g,p,C)&&L.push(C);const S=L.length;if(S===0)return Util.tt(L),!1;b=!0;let N=1/0;for(let T=0;T0&&k.contains(D,F)&&(S.x=D,S.y=F,this.containsPoint(S)))for(N!==0&&Math.abs(N)<.5?(T*=.5/N,N=.5):T!==0&&Math.abs(T)<.5&&(N*=.5/T,T=.5),D-=N,F-=T;k.contains(D,F);)D-=N,F-=T;const R=.6;n.x=g,n.y=p;for(let X=0;Xe?t-e:e-t)<(i>s?i-s:s-i)){const f=if||Geo.K(h.y,f))&&(h.yf||Geo.K(h.x,f))&&(h.x=a&&h<=c}else{let a=0,c=0;return s=a&&l<=c}}Pv(t,i){if(this.containedInRect(t,i)||i===void 0&&(i=this.D,t.containsRect(this.actualBounds)))return!0;const e=t.left,s=t.right,n=t.top,o=t.bottom,r=Point.l(),l=Point.l(),h=Point.l(),a=Transform.l();a.set(i),a.cC(this.D),a.yw(),l.x=s,l.y=n,l.D(a),r.x=e,r.y=n,r.D(a);let c=!1;return this.La(r,l,h)?c=!0:(r.x=s,r.y=o,r.D(a),this.La(r,l,h)?c=!0:(l.x=e,l.y=o,l.D(a),this.La(r,l,h)?c=!0:(r.x=e,r.y=n,r.D(a),this.La(r,l,h)&&(c=!0)))),Transform.s(a),Point.s(r),Point.s(l),Point.s(h),c}tA(t,i,e){if(e&&this.fill!==null&&this.lh(t,!0))return!0;let s=t.distanceSquaredPoint(i);const n=s;this.strokeWidth>1.5&&(s=this.strokeWidth/2+Math.sqrt(s),s*=s);let o=this.ft;if(o===null&&(this.ut(1/0,1/0),o=this.ft,o===null))return!1;if(!e){const f=o.bounds,u=f.x,d=f.y,m=f.x+f.width,g=f.y+f.height;if(Point.distanceSquared(t.x,t.y,u,d)<=s&&Point.distanceSquared(t.x,t.y,m,d)<=s&&Point.distanceSquared(t.x,t.y,u,g)<=s&&Point.distanceSquared(t.x,t.y,m,g)<=s)return!0}function r(f,u){const d=f.length;for(let m=0;ms)return!0;return!1}const l=o.startX,h=o.startY,a=o.endX,c=o.endY;if(o.type===1){const f=Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,c),u=(a-l)*(t.x-l)+(c-h)*(t.y-h),d=(l-a)*(t.x-a)+(h-c)*(t.y-c),m=u>=0&&d>=0?s:n;return f<=m}else if(o.type===2){let f=!1;return e&&(f=Point.distanceLineSegmentSquared(t.x,t.y,l,h,l,c)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,h)<=s||Point.distanceLineSegmentSquared(t.x,t.y,a,h,a,c)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,c,a,c)<=s),f}else if(o.type===3){const f=(l+a)/2,u=(h+c)/2,d=t.x-f,m=t.y-u,g=Math.abs(a-l)/2,p=Math.abs(c-h)/2;if(g===0||p===0)return Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,c)<=s;if(e){const y=Geo.OD(g,p,d,m);return y*y<=s}else return!(Point.distanceSquared(d,m,-g,0)>=s||Point.distanceSquared(d,m,0,-p)>=s||Point.distanceSquared(d,m,0,p)>=s||Point.distanceSquared(d,m,g,0)>=s)}else if(o.type===4){const f=o.bounds,u=f.x,d=f.y,m=f.x+f.width,g=f.y+f.height;if(t.x>m&&t.xg&&t.ys&&Point.distanceLineSegmentSquared(t.x,t.y,u,d,m,d)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,u,g)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,m,d)>s)return!1;const p=Math.sqrt(s);if(e){if(this.fill===null?o.kC(t.x,t.y,p):o.Vk(t,p,!0,!1))return!0}else{const y=o.figures;for(let x=0;xs)return!1;const M=k.segments.r,L=M.length;for(let C=0;Cs)return!1;break;case 3:{const N=Util.ot();Geo.Bn(b,P,S.point1X,S.point1Y,S.point2X,S.point2Y,S.endX,S.endY,.8,N);const T=r(N,t);if(Util.tt(N),T||(b=S.endX,P=S.endY,t.distanceSquared(b,P)>s))return!1;break}case 4:{const N=Util.ot();Geo.Bg(b,P,S.point1X,S.point1Y,S.endX,S.endY,.8,N);const T=r(N,t);if(Util.tt(N),T||(b=S.endX,P=S.endY,t.distanceSquared(b,P)>s))return!1;break}case 5:case 6:{const N=S.type===5?S.So(k):S.Ih(k,b,P),T=N.length;if(T===0){if(b=S.type===5?S.centerX:S.endX,P=S.type===5?S.centerY:S.endY,t.distanceSquared(b,P)>s)return!1;break}let A=null;const D=Util.ot();for(let F=0;F=0){this.jo=t,this.c();const e=this.part;e!==null&&e.af(),this.t("strokeWidth",i,t)}else Util._(t,"value >= 0",Shape,"strokeWidth:value")}Db(){return this.jo}get strokeCap(){return this.Lt!==null?this.Lt.pp:"butt"}set strokeCap(t){const i=this.strokeCap;i!==t&&(typeof t=="string"&&(t==="butt"||t==="round"||t==="square")?(this.Ca(),this.Lt.pp=t,this.C(),this.t("strokeCap",i,t)):Util._(t,'"butt", "round", or "square"',Shape,"strokeCap"))}get strokeJoin(){return this.Lt!==null?this.Lt.yp:"miter"}set strokeJoin(t){const i=this.strokeJoin;i!==t&&(typeof t=="string"&&(t==="miter"||t==="bevel"||t==="round")?(this.Ca(),this.Lt.yp=t,this.C(),this.t("strokeJoin",i,t)):Util._(t,'"miter", "bevel", or "round"',Shape,"strokeJoin"))}get strokeMiterLimit(){return this.Lt!==null?this.Lt.wp:10}set strokeMiterLimit(t){const i=this.strokeMiterLimit;if(i!==t&&t>=1){this.Ca(),this.Lt.wp=t,this.C();const e=this.part;e!==null&&e.af(),this.t("strokeMiterLimit",i,t)}}get strokeDashArray(){return this.Xo}set strokeDashArray(t){const i=this.Xo;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",Shape,"strokeDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("strokeDashArray:value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.Xo=t,this.C(),this.t("strokeDashArray",i,t)}}get strokeDashOffset(){return this.Lt!==null?this.Lt.uh:0}set strokeDashOffset(t){const i=this.strokeDashOffset;i!==t&&t>=0&&(this.Ca(),this.Lt.uh=t,this.C(),this.t("strokeDashOffset",i,t))}get figure(){return this.bd}set figure(t){const i=this.bd;if(i!==t){let e=Geo.Mo[t];if(typeof e=="function"?e=t:(e=Geo.Mo[t.toLowerCase()],e||Util.o("Unknown Shape.figure: "+t)),i!==e){const s=this.part;s!==null&&s.af(),this.bd=e,this.xs=null,this.ie(),this.c(),this.t("figure",i,e)}}}get toArrow(){return this.Ut!==null?this.Ut.xp:"None"}set toArrow(t){const i=this.toArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){const e=Shape.AA(t);e===null?Util.o("Unknown Shape.toArrow: "+t):i!==e&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.xp=e,this.xs=null,this.ie(),this.c(),this.TA(e),this.t("toArrow",i,e))}}get fromArrow(){return this.Ut!==null?this.Ut.bp:"None"}set fromArrow(t){const i=this.fromArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){const e=Shape.AA(t);e===null?Util.o("Unknown Shape.fromArrow: "+t):i!==e&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.bp=e,this.xs=null,this.ie(),this.c(),this.TA(e),this.t("fromArrow",i,e))}}TA(t){const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;this.OR();const e=Spot.MiddleRight;this.toArrow!=="None"?(this.segmentIndex=-1,this.alignmentFocus=e):this.fromArrow!=="None"&&(this.segmentIndex=0,this.alignmentFocus=new Spot(1-e.x,e.y))}get spot1(){return this.Lt!==null?this.Lt.zn:Spot.Default}set spot1(t){const i=this.spot1;i.equals(t)||(t=t.N(),this.Ca(),this.Lt.zn=t,this.c(),this.t("spot1",i,t))}get spot2(){return this.Lt!==null?this.Lt.Xn:Spot.Default}set spot2(t){const i=this.spot2;i.equals(t)||(t=t.N(),this.Ca(),this.Lt.Xn=t,this.c(),this.t("spot2",i,t))}get parameter1(){return this.kd}set parameter1(t){const i=this.kd;i!==t&&(this.kd=t,this.ie(),this.c(),this.t("parameter1",i,t))}get parameter2(){return this.Pd}set parameter2(t){const i=this.Pd;i!==t&&(this.Pd=t,this.ie(),this.c(),this.t("parameter2",i,t))}get naturalBounds(){return this.Vi}tv(){const t=this.desiredSize;if(!t.isReal()&&this.ft!==null){const i=this.ft.bounds;this.Vi.a(i)}else this.Vi.e(0,0,t.width,t.height)}get pathPattern(){return this.Lt!==null?this.Lt.kp:null}set pathPattern(t){const i=this.pathPattern;i!==t&&(this.Ca(),this.Lt.kp=t,this.C(),this.t("pathPattern",i,t))}get geometryStretch(){return this.Lt!==null?this.Lt.Pp:1}set geometryStretch(t){const i=this.geometryStretch;i!==t&&(this.Ca(),this.Lt.Pp=t,this.c(),this.t("geometryStretch",i,t))}get interval(){return this.J!==null?this.J.ff:1}set interval(t){const i=this.interval;if(t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this.J===null&&(this.J=new GradElementSettings),this.J.ff=t;const e=this.diagram;e!==null&&this.panel===e.grid&&e.jr(),this.c();const s=this.panel;s!==null&&(s.ns=null),this.t("interval",i,t)}}get graduatedStart(){return this.J!==null?this.J.uf:0}set graduatedStart(t){const i=this.graduatedStart;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.uf=t,this.c(),this.t("graduatedStart",i,t))}get graduatedEnd(){return this.J!==null?this.J.df:1}set graduatedEnd(t){const i=this.graduatedEnd;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.df=t,this.c(),this.t("graduatedEnd",i,t))}get graduatedSkip(){return this.J!==null?this.J.gf:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.i(t,"function",Shape,"graduatedSkip"),this.J===null&&(this.J=new GradElementSettings),this.J.gf=t,this.c(),this.t("graduatedSkip",i,t))}static xv(t,i,e){let n=null;if(t.toArrow!=="None")n=Shape.no[t.toArrow];else if(t.fromArrow!=="None")n=Shape.no[t.fromArrow];else{let o=Geo.Mo[t.figure];typeof o=="string"&&(o=Geo.Mo[o]),o===void 0&&Util.o("Unknown Shape.figure: "+t.figure),n=o(t,i,e),n.ec=i,n.sc=e}if(n===null){const o=Geo.Mo.Rectangle;typeof o=="function"&&(n=o(t,i,e))}return n}static getFigureGenerators(){const t=new GMap;for(const i in Geo.Mo){if(i===i.toLowerCase())continue;const e=Geo.Mo[i];t.set(i,e)}return t.g(),t}static defineFigureGenerator(t,i){Util.i(t,"string",Shape,"defineFigureGenerator:name"),typeof i=="string"||Util.i(i,"function",Shape,"defineFigureGenerator:func");const e=t.toLowerCase(),s=Geo.Mo;s[t]=i,s[e]=t}static getArrowheadGeometries(){const t=new GMap;for(const i in Geo.Kg)if(Shape.no[i]===void 0){const e=Geometry.parse(Geo.Kg[i],!1);Shape.no[i]=e;const s=i.toLowerCase();s!==i&&(Shape.no[s]=i)}for(const i in Shape.no){if(i===i.toLowerCase())continue;const e=Shape.no[i];e instanceof Geometry&&t.set(i,e)}return t.g(),t}static defineArrowheadGeometry(t,i){Util.i(t,"string",Shape,"defineArrowheadGeometry:name");let e=null;typeof i=="string"?(Util.i(i,"string",Shape,"defineArrowheadGeometry:pathstr"),e=Geometry.parse(i,!1)):e=i;const s=t.toLowerCase();(s==="none"||t===s)&&Util.o("Shape.defineArrowheadGeometry name must not be empty or None or all-lower-case: "+t);const n=Shape.no;n[t]=e,n[s]=t}static no=new PropertyCollection;static U2=new PropertyCollection;static AA(t){let i=Shape.no[t];if(i===void 0){const e=t.toLowerCase();if(e==="none")return"None";if(i=Shape.no[e],i===void 0){let s=null;for(const n in Geo.Kg)if(n.toLowerCase()===e){s=n;break}if(s!==null){const n=Geometry.parse(Geo.Kg[s],!1);return Shape.no[s]=n,e!==s&&(Shape.no[e]=s),s}}}return typeof i=="string"?i:i instanceof Geometry?t:null}}class ShapeTemplateSettings{gi;pp;yp;wp;uh;kp;Pp;zn;Xn;constructor(){this.gi=!1,this.pp="butt",this.yp="miter",this.wp=10,this.uh=0,this.kp=null,this.Pp=1,this.zn=Spot.Default,this.Xn=Spot.Default}copy(){const t=new ShapeTemplateSettings;return t.pp=this.pp,t.yp=this.yp,t.wp=this.wp,t.uh=this.uh,t.kp=this.kp,t.Pp=this.Pp,t.zn=this.zn.N(),t.Xn=this.Xn.N(),t}}var Wrap=(w=>(w[w.None=0]="None",w[w.Fit=1]="Fit",w[w.DesiredSize=2]="DesiredSize",w[w.BreakAll=3]="BreakAll",w))(Wrap||{}),TextOverflow=(w=>(w[w.Clip=0]="Clip",w[w.Ellipsis=1]="Ellipsis",w))(TextOverflow||{}),TextFormat=(w=>(w[w.Trim=0]="Trim",w[w.None=1]="None",w))(TextFormat||{});class TextBlock extends GraphObject{hi;Hi;kn;Ce;mi;x0;Sd;J;W;Dl;oo;Pn;Le;Di;Mn;constructor(t,i){return super(),this.n|=2097152,this.hi="",this.Hi="black",this.kn="13px sans-serif",this.Ce=0,this.mi=0,this.x0=0,this.Sd=null,this.J=null,this.W=null,this.Dl=0,this.oo=null,this.Pn=0,this.Le=null,this.Di=null,this.Mn=null,typeof t=="string"?this.text=t:t&&Object.assign(this,t),i&&Object.assign(this,i),this}cloneProtected(t){super.cloneProtected(t),t.hi=this.hi,t.Hi=this.Hi,t.kn=this.kn,t.Ce=this.Ce,t.mi=this.mi,t.x0=this.x0,t.Sd=this.Sd,this.J!==null&&(t.J=this.J.copy()),this.W!==null&&(this.W.gi?t.W=this.W:t.W=this.W.copy()),t.Dl=this.Dl,t.oo=this.oo,t.Pn=this.Pn,t.Le=this.Le,t.Di=this.Di,t.Mn=this.Mn}Sn(){this.W===null?this.W=new TextBlockTemplateSettings:this.W.gi&&(this.W=this.W.copy())}rh(){super.rh(),this.W!==null&&(this.W.gi=!0)}lv(t){this.n=t.n|2048|4096,this.Wt=t.opacity,this.Ct=t.background,this.ze=t.desiredSize.N(),this.minSize=t.minSize.N(),this.maxSize=t.maxSize.N(),t.bi!==null?this.bi=t.bi.copy():this.bi=null,this.st=t.scale,this.Xt=t.angle,this.stretch=t.stretch,this.Zr=t.margin.N(),this.ni=t.alignment.N(),this.qc=t.alignmentFocus.N(),this.segmentFraction=t.segmentFraction,this.segmentOffset=t.segmentOffset.N(),this.segmentOrientation=t.segmentOrientation,t.si!==null&&(this.si=t.si.copy()),this.shadowVisible=t.shadowVisible,this.hi=t.hi,this.Hi=t.Hi,this.kn=t.kn,this.J!==null&&(this.J=t.J.copy()),t.W!==null&&(t.W.gi?this.W=t.W:this.W=t.W.copy()),this.Dl=t.Dl}ov(t){if(this.hi=t.text||"",this.Xt=t.labelAngle||0,this.Ce=t.lineCount||0,this.Mv(t.lines),t.naturalBounds&&(this.Vi=t.naturalBounds),t.actualBounds){const i=t.actualBounds;this.zt(i.x,i.y,i.width,i.height)}}ri(t){t in Wrap?this.wrap=t:super.ri(t)}toString(){return this.hi.length>22?'TextBlock("'+this.hi.substring(0,20)+'"...)':'TextBlock("'+this.hi+'")'}static getEllipsis(){return TextBlock.Mp}static setEllipsis(t){TextBlock.Mp=t,TextBlock.Zb=new PropertyCollection,TextBlock.B2=0}static getBaseline(){return TextBlock.Qb}static setBaseline(t){TextBlock.Qb=t}static Qb=null;static getUnderline(){return TextBlock._b}static setUnderline(t){TextBlock._b=t}static _b=null;static None=0;static WrapFit=1;static WrapDesiredSize=2;static WrapBreakAll=3;static OverflowClip=0;static OverflowEllipsis=1;static FormatTrim=0;static FormatNone=1;c(){super.c()}get font(){return this.kn}set font(t){const i=this.kn;i!==t&&(this.kn=t,this.oo=null,this.c(),this.t("font",i,t))}static isValidFont(t){return root.CSS?root.CSS.supports("font",t):!0}get text(){return this.hi}set text(t){const i=this.hi;t!=null?t=t.toString():t="",i!==t&&(this.hi=t,this.c(),this.t("text",i,t),this.ss(!0))}get textAlign(){return this.W!==null?this.W.Sp:"start"}set textAlign(t){const i=this.textAlign;i!==t&&(t==="start"||t==="end"||t==="left"||t==="right"||t==="center")&&(this.Sn(),this.W.Sp=t,this.C(),this.t("textAlign",i,t))}get flip(){return this.W!==null?this.W.ro:0}set flip(t){const i=this.flip;i!==t&&(this.Sn(),this.W.ro=t,this.C(),this.t("flip",i,t))}get verticalAlignment(){return this.W!==null?this.W.sl:Spot.Top}set verticalAlignment(t){const i=this.verticalAlignment;i.equals(t)||(t=t.N(),this.Sn(),this.W.sl=t,this.tf(),this.t("verticalAlignment",i,t))}get naturalBounds(){if(!this.Vi.isReal()){const t=Size.l();this.V2(this.hi,999999,t);let i=t.width;Size.s(t);let e=this.DA(i);const s=this.desiredSize;isNaN(s.width)||(i=s.width),isNaN(s.height)||(e=s.height),this.Vi.En(i,e)}return this.Vi}get isMultiline(){return(this.n&2097152)!==0}set isMultiline(t){const i=(this.n&2097152)!==0;i!==t&&(this.n=this.n^2097152,this.c(),this.t("isMultiline",i,t))}get isUnderline(){return(this.n&4194304)!==0}set isUnderline(t){const i=(this.n&4194304)!==0;i!==t&&(this.n=this.n^4194304,this.ss(!0),this.C(),this.t("isUnderline",i,t))}get isStrikethrough(){return(this.n&8388608)!==0}set isStrikethrough(t){const i=(this.n&8388608)!==0;i!==t&&(this.n=this.n^8388608,this.ss(!0),this.C(),this.t("isStrikethrough",i,t))}get wrap(){return this.W!==null?this.W.Np:2}set wrap(t){const i=this.wrap;i!==t&&(this.Sn(),this.W.Np=t,this.c(),this.t("wrap",i,t))}get overflow(){return this.W!==null?this.W.Cp:0}set overflow(t){const i=this.overflow;i!==t&&(this.Sn(),this.W.Cp=t,this.c(),this.t("overflow",i,t))}get isOverflowed(){return(this.n&16777216)!==0}z2(t){t?this.n|=16777216:this.n&=-16777217}get stroke(){return this.Hi}set stroke(t){const i=this.Hi;i!==t&&(t!==null&&Brush.od(t,"TextBlock.stroke"),t instanceof Brush&&t.g(),this.Hi=t,this.C(),this.t("stroke",i,t))}get lineCount(){return this.Ce}get lineHeight(){return this.Lp()}get editable(){return(this.n&1048576)!==0}set editable(t){const i=(this.n&1048576)!==0;i!==t&&(this.n=this.n^1048576,this.t("editable",i,t))}get T2(){return(this.n&33554432)!==0}set T2(t){this.n=this.n^33554432}get textEditor(){return this.W!==null?this.W.Ap:null}set textEditor(t){const i=this.textEditor;i!==t&&(this.Sn(),this.W.Ap=t,this.t("textEditor",i,t))}get errorFunction(){return this.W!==null?this.W.os:null}set errorFunction(t){const i=this.errorFunction;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"errorFunction"),this.Sn(),this.W.os=t,this.t("errorFunction",i,t))}get interval(){return this.J!==null?this.J.ff:1}set interval(t){const i=this.interval;if(t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this.J===null&&(this.J=new GradElementSettings),this.J.ff=t,this.c();const e=this.panel;e!==null&&(e.ns=null),this.t("interval",i,t)}}get graduatedStart(){return this.J!==null?this.J.uf:0}set graduatedStart(t){const i=this.graduatedStart;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.uf=t,this.c(),this.t("graduatedStart",i,t))}get graduatedEnd(){return this.J!==null?this.J.df:1}set graduatedEnd(t){const i=this.graduatedEnd;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.df=t,this.c(),this.t("graduatedEnd",i,t))}get graduatedFunction(){return this.J!==null?this.J.Tp:null}set graduatedFunction(t){const i=this.graduatedFunction;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"graduatedFunction"),this.J===null&&(this.J=new GradElementSettings),this.J.Tp=t,this.c(),this.t("graduatedFunction",i,t))}get graduatedSkip(){return this.J!==null?this.J.gf:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"graduatedSkip"),this.J===null&&(this.J=new GradElementSettings),this.J.gf=t,this.c(),this.t("graduatedSkip",i,t))}ch(t,i){if(this.Hi===null||this.hi.length===0||this.kn===null)return;const e=this.naturalBounds,s=this.actualBounds,n=e.width,o=e.height,r=this.Lp();let l=t.textAlign=this.textAlign;const h=i.Ku;l==="start"?l=h?"right":"left":l==="end"&&(l=h?"left":"right");const a=this.isUnderline,c=this.isStrikethrough;this.dn(t,this.Hi,!0,!1,e,s),(a||c)&&this.dn(t,this.Hi,!1,!1,e,s);const f=0;let u=0;const d=n;let m=!1;i.Zt===t&&!(i.Zt instanceof SVGContext)&&!this.T2&&i.getRenderingHint("textGreeking")===!0&&r*this.aa*i.scale<3&&(m=!0);const g=this.spacingAbove,p=this.spacingBelow;switch(this.flip){case 0:break;case 2:t.translate(n,0),t.scale(-1,1);break;case 1:t.translate(0,o),t.scale(1,-1);break;case 3:t.translate(n,o),t.scale(-1,-1);break}t.commitTransform();const y=this.Ce,k=(g+r+p)*y;if(o>k){const b=this.verticalAlignment;u=b.y*o-b.y*k+b.offsetY}if(y===1&&this.Mn!==null){let b=this.mi;b>d&&(b=d),u+=g,this.FA(this.Mn,t,f,u,d,r,b,m,l,a,c)}else if(this.Le!==null&&this.Di!==null)for(let b=0;bd&&(P=d),u+=g,this.FA(this.Di[b],t,f,u,d,r,P,m,l,a,c),u+=r+p}switch(this.flip){case 0:break;case 2:t.scale(-1,1),t.translate(-n,0);break;case 1:t.scale(1,-1),t.translate(0,-o);break;case 3:t.scale(-1,-1),t.translate(-n,-o);break}}FA(t,i,e,s,n,o,r,l,h,a,c){let f=0;if(l){h==="left"?f=0:h==="right"?f=n-r:h==="center"&&(f=(n-r)/2);const m=i.globalAlpha;i.globalAlpha=m/2,i.fillRect(e+f,s+o/4,r,o/2),i.globalAlpha=m;return}h==="left"?f=0:h==="right"?f=n:h==="center"&&(f=n/2);const u=TextBlock.Qb!==null?TextBlock.Qb(this,o):o*.75;i.fillText(t,e+f,s+u);let d=o/20|0;if(d===0&&(d=1),h==="right"?f-=r:h==="center"&&(f-=r/2),a){const m=TextBlock._b!==null?TextBlock._b(this,o):o*.8;this.RA(e+f,s+m,e+f+r,s+m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}if(c){let m=s+o-o/2.2|0;d%2!==0&&(m+=.5),this.RA(e+f,m,e+f+r,m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}}RA(t,i,e,s,n,o){o.beginPath(),o.lineWidth=n,o.moveTo(t,i),o.lineTo(e,s),o.stroke(),o.endPath()}Zc(t,i,e){if(!super.Zc(t,i,e))return!1;if(this.dn(t,this.Hi,!0,!1,this.naturalBounds,this.actualBounds),e){if(this.svg.getElementsByTagName("text").length===0)return!0;const n=this.svg.getElementsByClassName("gojs-td");for(let o=0;o1||this.isUnderline||this.isStrikethrough?!0:super.sd(t)}h2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("text");for(let s=0;sthis.maxLines&&(this.n|=16777216))}V2(t,i,e){const s=this.formatting===0;s&&(t=t.trim());let n=0,o=0,r=0;const l=this.kn,h=this.spacingAbove+this.spacingBelow,a=Math.max(0,this.Lp()+h),c=this.overflow===1?this.OA(l):0;if(this.Ce>=this.maxLines){e!==null&&e.e(0,a);return}let f=t;if(this.wrap===0){if(this.Pn=1,o=this.getStringWidth(t),c===0||o<=i){this.mi=Math.max(this.mi,o),this.Nn(t,this.mi),e!==null&&e.e(o,a);return}let d=this.Nd(f);f=f.substring(d.length);let m=this.Nd(f);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,f=f.substring(m.length),m=this.Nd(f),r=o;let g=d+m;s&&(g=g.trim()),o=this.getStringWidth(g)}for(s&&(m=m.trim()),d+=m,i=Math.max(1,i-c);this.getStringWidth(d)>i&&d.length>1;)d=d.substring(0,d.length-1);this.z2(!0),d+=TextBlock.Mp,r=this.getStringWidth(d),this.mi=r,this.Nn(d,r),e!==null&&e.e(r,a);return}let u=0;for(f.length===0&&(u=1,this.Nn(f,0));f.length>0;){let d=this.Nd(f);for(f=f.substring(d.length);this.getStringWidth(d)>i;){let p=1;for(o=this.getStringWidth(d.substring(0,p)),r=0;o<=i;)p++,r=o,o=this.getStringWidth(d.substring(0,p));let y=0;p===1?(y=o,n=Math.max(n,o)):(y=r,n=Math.max(n,r)),p--,p<1&&(p=1);const x=d.substring(0,p);if(this.Nn(x,y),u++,d=d.substring(p),this.Ce+u>this.maxLines)break}let m=this.Nd(f);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,f=f.substring(m.length),m=this.Nd(f),r=o;let p=d+m;s&&(p=p.trim()),o=this.getStringWidth(p)}if(s&&(d=d.trim()),d==="")continue;d[d.length-1]==="\xAD"&&(d=d.substring(0,d.length-1)+"\u2010");let g=0;if(m.length===0?(g=o,n=Math.max(n,o)):(r=this.getStringWidth(d),g=r,n=Math.max(n,r)),this.Nn(d,g),u++,this.Ce+u>this.maxLines)break}this.Pn=Math.min(this.maxLines,u),this.mi=Math.max(this.mi,n),e!==null&&e.e(this.mi,a*this.Pn)}Lv(t,i){if(this.mi===0||this.Le===null||this.Di===null||this.overflow!==1)return;const e=this.kn,s=this.overflow===1?this.OA(e):0,n=this.spacingAbove+this.spacingBelow,o=Math.max(0,this.Lp()+n),r=Math.min(this.maxLines-1,Math.max(Math.floor(i/o+.01)-1,0));if(r+1>=this.Di.length)return;this.z2(!0);let l=this.Di[r];const h=Math.max(1,t-s);for(;this.getStringWidth(l)>h&&l.length>1;)l=l.substring(0,l.length-1);l+=TextBlock.Mp;const a=this.getStringWidth(l);this.Di[r]=l,this.Di=this.Di.slice(0,r+1),this.Le[r]=a,this.Le=this.Le.slice(0,r+1),this.Pn=this.Di.length,this.mi=Math.max(this.mi,a),this.Ce=this.Pn,this.Ce===1&&(this.Mn=this.Di[0])}Nd(t){if(this.wrap===3)return t.substring(0,1);let i=t.length,e=0;const s=TextBlock.Av;for(;e=t.length?t:t.substring(0,e)}getStringWidth(t){return TextBlock.il===null?t.length*8:TextBlock.il.measureText(t).width}Lp(){if(this.oo!==null)return this.oo;const t=this.kn;let i=0;return TextBlock.il===null?(i=16,this.oo=i,i):(TextBlock.X2[t]!==void 0&&TextBlock.IA<5e3?i=TextBlock.X2[t]:(i=TextBlock.il.measureText("M").width*1.3,TextBlock.X2[t]=i,TextBlock.IA++),this.oo=i,i)}OA(t){if(TextBlock.il===null)return 6;let i=0;return TextBlock.Zb[t]!==void 0&&TextBlock.B2<5e3?i=TextBlock.Zb[t]:(i=TextBlock.il.measureText(TextBlock.Mp).width,TextBlock.Zb[t]=i,TextBlock.B2++),i}t1(t,i){return t.indexOf(` +(function() {const root=typeof globalThis=="object"&&globalThis||typeof global=="object"&&global.global===global&&global||typeof self=="object"&&self.self===self&&self||{};root.requestAnimationFrame===void 0&&(root.setImmediate===void 0?root.requestAnimationFrame=w=>root.setTimeout(w,0):root.requestAnimationFrame=root.setImmediate);class Util{static rr=root.navigator!==void 0&&root.navigator.platform!==void 0&&root.navigator.platform.match(/(iPhone|iPod|iPad|Mac)/i)!==null;static Nk(t,i,e){let s=-1;return function(){const n=this,o=arguments;s!==-1&&Util.Og(s),s=Util.Oh(()=>{s=-1,e||t.apply(n,o)},i),e&&!s&&t.apply(n,o)}}static Oh(t,i){return root.setTimeout(t,i)}static Og(t){root.clearTimeout(t)}static en(t){return root.document.createElement(t)}static o(t){throw new Error(t)}static T(t,i){let e="The object is frozen, so its properties cannot be set: "+t.toString();i!==void 0&&(e+=" to value: "+i),Util.o(e)}static qI(t,i,e,s){}static i(t,i,e,s){}static WI(t,i,e){}static JI(t,i,e){}static we(t,i,e,s){}static _(t,i,e,s){let n=Util.ND(e);s!==void 0&&(n+="."+s),Util.o(n+" is not in the range "+i+": "+t)}static ve(t){}static lr(t,i){}static ii(t){root.console&&root.console.log(t)}static wt(t){return typeof t=="object"&&t!==null}static $I(t,i,e){}static eu(t,i,e){Array.isArray(t)?i>=t.length?t.push(e):t.splice(i,0,e):Util.o("Cannot insert an object into an HTMLCollection or NodeList: "+e+" at "+i)}static tc(t,i){Array.isArray(t)?i>=t.length?t.pop():t.splice(i,1):Util.o("Cannot remove an object from an HTMLCollection or NodeList at "+i)}static Ck=[];static nt(){const t=Util.Ck.pop();return t===void 0?[]:t}static tt(t){t.length=0,Util.Ck.push(t)}static ZI=Object.freeze([]);static ND(t){return t===null?"*":typeof t=="string"?t:typeof t=="function"?t.name:""}static sn(t){return typeof t=="function"?t.className?t.className:t.name:Util.wt(t)&&t.constructor?Util.sn(t.constructor):typeof t}static Ih(t,i){return i==null||i===""?null:Util.wt(t)&&i in t||t[i]?t[i]:null}static toString(t){let i=t;return Util.wt(t)&&(t.text?i=t.text:t.name?i=t.name:t.key!==void 0?i=t.key:t.id!==void 0?i=t.id:t.constructor===Object&&(t.Text?i=t.Text:t.Name?i=t.Name:t.Key!==void 0?i=t.Key:t.Id!==void 0?i=t.Id:t.ID!==void 0&&(i=t.ID))),i===void 0?"undefined":i===null?"null":i.toString()}static fw(t,i){if(t.hasOwnProperty(i))return!0;let e=Object.getPrototypeOf(t);for(;e&&e!==Function;){if(e.hasOwnProperty(i))return!0;const s=e.QI;if(s&&s[i])return!0;e=Object.getPrototypeOf(e)}return!1}static CD(t){const i=[];let e=0;for(e=0;e<256;e++)i[e]=e;let s=0,n=0;for(e=0;e<256;e++)s=(s+i[e]+119)%256,n=i[e],i[e]=i[s],i[s]=n;e=0,s=0;let o="";for(let r=0;r>4)+i.charAt(r&15)]=String.fromCharCode(r);t.length%2&&(t="0"+t);const s=[];let n=0;for(let r=0;r0){const n=i[0];return this.key=0,this.value=n,n}else return null}any(t){const i=this.qt;i.hr=null;const e=i.ht;this.Dt=-1;const s=i.r,n=s.length,o=this.Ls;for(let r=0;r=0?(this.key=i,this.value=t.r[i],!0):(this.gl(),!1)}hasNext(){return this.next()}first(){const t=this.qt;this.Yt=t.ht;const i=t.r,e=i.length-1;if(this.Dt=e,e>=0){const s=i[e];return this.key=e,this.value=s,s}else return null}any(t){const i=this.qt;i.ar=null;const e=i.ht,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(t(r))return!0;i.ht!==e&&Util.ve(i)}return!1}all(t){const i=this.qt;i.ar=null;const e=i.ht,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(!t(r))return!1;i.ht!==e&&Util.ve(i)}return!0}each(t){const i=this.qt;i.ar=null;const e=i.ht,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];t(r),i.ht!==e&&Util.ve(i)}return this}map(t){const i=this.qt;i.ar=null;const e=i.ht,s=[],n=i.r,o=n.length;this.Dt=o;for(let l=o-1;l>=0;l--){const h=n[l];s.push(t(h)),i.ht!==e&&Util.ve(i)}const r=new List;return r.r=s,r.Oe(),r.iterator}filter(t){const i=this.qt;i.ar=null;const e=i.ht,s=[],n=i.r,o=n.length;this.Dt=o;for(let l=o-1;l>=0;l--){const h=n[l];t(h)&&s.push(h),i.ht!==e&&Util.ve(i)}const r=new List;return r.r=s,r.Oe(),r.iterator}get count(){return this.qt.r.length}gl(){this.key=-1,this.value=null,this.Yt=-1,this.qt.ar=this}toString(){return"ListIteratorBackwards("+this.Dt+"/"+this.qt.count+")"}}class List{h;r;ht;hr;ar;constructor(t){GSet.Yi(this),this.h=!1,this.r=[],this.ht=0,this.hr=null,this.ar=null,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.r.values()}Oe(){let t=this.ht;t++,t>999999999&&(t=0),this.ht=t}g(){return this.h=!0,this}ot(){return this.h=!1,this}toString(){return"List()#"+GSet.as(this)}add(t){return this.h&&Util.T(this,t),this.r.push(t),this.Oe(),this}push(t){this.add(t)}addAll(t){if(t===null)return this;this.h&&Util.T(this);const i=this.r;if(Array.isArray(t)){const e=t.length;for(let s=0;s=i.length)&&Util._(t,"0 <= i < length",List,"elt:i"),i[t]}get(t){return this.elt(t)}setElt(t,i){const e=this.r;(t<0||t>=e.length)&&Util._(t,"0 <= i < length",List,"setElt:i"),this.h&&Util.T(this,t),e[t]=i}set(t,i){this.setElt(t,i)}first(){const t=this.r;return t.length===0?null:t[0]}last(){const t=this.r,i=t.length;return i>0?t[i-1]:null}pop(){this.h&&Util.T(this);const t=this.r;return t.length>0?t.pop():null}any(t){const i=this.r,e=this.ht,s=i.length;for(let n=0;n= 0",List,"insertAt:i"),this.h&&Util.T(this,t);const e=this.r;t>=e.length?e.push(i):e.splice(t,0,i),this.Oe()}remove(t){return this.delete(t)}delete(t){if(t===null)return!1;this.h&&Util.T(this,t);const i=this.r,e=i.indexOf(t);return e===-1?!1:(e===i.length-1?i.pop():i.splice(e,1),this.Oe(),!0)}removeAt(t){const i=this.r;(t<0||t>=i.length)&&Util._(t,"0 <= i < length",List,"removeAt:i"),this.h&&Util.T(this,t),t===i.length-1?i.pop():i.splice(t,1),this.Oe()}removeRange(t,i){const e=this.r,s=e.length;if(t<0)t=0;else if(t>=s)return this;if(i<0)return this;if(i>=s&&(i=s-1),t>i)return this;this.h&&Util.T(this);let n=t,o=i+1;for(;o0&&(t.r=Array.prototype.slice.call(i)),t}toArray(){const t=this.r,i=this.count,e=new Array(i);for(let s=0;s=n-1)&&Util._(i,"0 <= from < length",List,"sortRange:from"),o===2){const r=s[i],l=s[i+1];return t(r,l)>0&&(s[i]=l,s[i+1]=r,this.Oe()),this}if(i===0)if(e>=n)s.sort(t);else{const r=s.slice(0,e);r.sort(t);for(let l=0;l=n){const r=s.slice(i);r.sort(t);for(let l=i;li.add(t(e))),i.iterator}filter(t){const i=new List;return this.ko.w.forEach(e=>{t(e)&&i.add(e)}),i.iterator}get count(){return this.ko.count}gl(){this.key=null,this.value=null,this.ei=null}toString(){return"SetIterator"}}class GSet{h;w;constructor(t){this.h=!1,this.w=new Set,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.w.values()}values(){return this.w.values()}g(){return this.h=!0,this}ot(){return this.h=!1,this}toString(){return"Set()#"+GSet.as(this)}add(t){return t===null?this:(this.w.add(t),this)}addAll(t){if(t===null)return this;if(Array.isArray(t)){const i=t.length;for(let e=0;et.add(i)),t}toArray(){return Array.from(this.w)}toList(){const t=new List;return this.w.forEach(i=>t.add(i)),t}get count(){return this.w.size}get size(){return this.w.size}get iterator(){return this.w.size<=0?EmptyIterator.instance:new SetIterator(this)}entries(){return this.w.entries()}keys(){return this.w.keys()}forEach(t,i){return this.w.forEach(t,i)}static su=1;static Yi(t){t.__gohashid=GSet.su++}static as(t){return t.__gohashid}}class MapKeySetIterator{Z;ei;constructor(t){this.Z=t,this.ei=t.w.keys()}[Symbol.iterator](){return this.Z.w.keys()}key;value;get iterator(){return this}reset(){const t=this.Z;this.ei=t.w.keys()}next(){const t=this.ei.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.Z.w.size===0?null:(this.ei=this.Z.w.keys(),this.ei.next().value)}any(t){for(const i of this.Z.w)if(t(i[0]))return!0;return!1}all(t){for(const i of this.Z.w)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.Z.w)t(i[0]);return this}map(t){const i=this.Z,e=new List;for(const s of i.w)e.add(t(s[0]));return e.iterator}filter(t){const i=this.Z,e=new List;for(const s of i.w){const n=s[0];t(n)&&e.add(n)}return e.iterator}get count(){return this.Z.size}gl(){this.key=null,this.value=null,this.ei=null}toString(){return"MapKeySetIterator"}}class MapKeySet extends GSet{Z;constructor(t){super(),GSet.Yi(this),this.h=!0,this.Z=t}[Symbol.iterator](){return this.w.keys()}values(){return this.w.keys()}g(){return this}ot(){return this}toString(){return"MapKeySet("+this.Z.toString()+")"}add(t){Util.o("This Set is read-only: "+this.toString())}has(t){return this.Z.has(t)}contains(t){return this.has(t)}delete(t){Util.o("This Set is read-only: "+this.toString())}remove(t){return this.delete(t)}clear(){Util.o("This Set is read-only: "+this.toString())}first(){return this.Z.w.size===0?null:this.Z.w.keys().next().value}any(t){for(const i of this.Z.w)if(t(i[0]))return!0;return!1}all(t){for(const i of this.Z.w)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.Z.w)t(i[0]);return this}map(t){const i=new GSet;for(const e of this.Z.w)i.add(t(e[0]));return i}filter(t){const i=new GSet;for(const e of this.Z.w){const s=e[0];t(s)&&i.add(s)}return i}copy(){return new MapKeySet(this.Z)}toSet(){const t=new GSet,i=this.Z.w;for(const e of i)t.add(e[0]);return t}toArray(){const t=this.Z.w,i=new Array(t.size);let e=0;for(const s of t)i[e]=s[0],e++;return i}toList(){const t=new List,i=this.Z.w;for(const e of i)t.add(e[0]);return t}get count(){return this.Z.size}get size(){return this.Z.size}get iterator(){return this.Z.size<=0?EmptyIterator.instance:new MapKeySetIterator(this.Z)}}class MapValueSetIterator{Z;ei;constructor(t){this.Z=t,this.ei=t.w.values()}[Symbol.iterator](){return this.Z.w.values()}key;value;get iterator(){return this}reset(){const t=this.Z;this.ei=t.w.values()}next(){const t=this.ei.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.Z.w.size===0?null:(this.ei=this.Z.w.values(),this.ei.next().value)}any(t){for(const i of this.Z.w)if(t(i[1]))return!0;return!1}all(t){for(const i of this.Z.w)if(!t(i[1]))return!1;return!0}each(t){for(const i of this.Z.w)t(i[1]);return this}map(t){const i=this.Z,e=new List;for(const s of i.w)e.add(t(s[1]));return e.iterator}filter(t){const i=this.Z,e=new List;for(const s of i.w){const n=s[1];t(n)&&e.add(n)}return e.iterator}get count(){return this.Z.size}gl(){this.key=null,this.value=null,this.ei=null}toString(){return"MapValueSetIterator"}}class KeyValuePair{constructor(t,i){this.key=t,this.value=i}toString(){return"{"+this.key+":"+this.value+"}"}key;value}class MapIterator{Z;ei;constructor(t){this.Z=t,this.ei=t.w.entries()}[Symbol.iterator](){return this.Z.w.entries()}key;value;get iterator(){return this}reset(){const t=this.Z;this.ei=t.w.entries()}next(){const t=this.ei.next();return t.done?(this.key=null,this.value=null,!1):(this.key=t.value[0],this.value=t.value[1],!0)}hasNext(){return this.next()}first(){if(this.Z.w.size===0)return null;this.ei=this.Z.w.entries();const t=this.ei.next().value;return this.key=t[0],this.value=t[1],new KeyValuePair(t[0],t[1])}any(t){return this.Z.any(t)}all(t){return this.Z.all(t)}each(t){return this.Z.each(t),this}map(t){const i=new List;let e=null;return this.Z.w.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),i.add(t(e))}),i.iterator}filter(t){const i=new List;let e=null;return this.Z.w.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),t(e)&&(i.add(e),e=null)}),i.iterator}get count(){return this.Z.size}gl(){this.key=null,this.value=null,this.ei=null}toString(){return"MapIterator"}}class GMap{h;w;constructor(t){GSet.Yi(this),this.h=!1,this.w=new Map,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.w.entries()}entries(){return this.w.entries()}g(){return this.h=!0,this}ot(){return this.h=!1,this}toString(){return"Map()#"+GSet.as(this)}set(t,i){return this.h&&Util.T(this,t),this.w.set(t,i),this}add(t,i){return this.set(t,i)}addAll(t){if(t===null)return this;if(this.h&&Util.T(this),Array.isArray(t)){const i=t.length;for(let e=0;ei.x.toFixed(t)+" "+i.y.toFixed(t)}toString(){return"Point("+this.x+","+this.y+")"}equals(t){return t instanceof Point?this.b===t.x&&this.k===t.y:!1}equalTo(t,i){return this.b===t&&this.k===i}equalsApprox(t){return Geo.u(this.b,t.x)&&Geo.u(this.k,t.y)}add(t){return this.b+=t.x,this.k+=t.y,this}subtract(t){return this.b-=t.x,this.k-=t.y,this}offset(t,i){return this.b+=t,this.k+=i,this}rotate(t){if(t===0)return this;const i=this.b,e=this.k;if(i===0&&e===0)return this;let s=0,n=0;if(t>=360?t-=360:t<0&&(t+=360),t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const o=t*Math.PI/180;s=Math.cos(o),n=Math.sin(o)}return this.b=s*i-n*e,this.k=n*i+s*e,this}scale(t,i){return this.b*=t,this.k*=i,this}distanceSquaredPoint(t){const i=t.x-this.b,e=t.y-this.k;return i*i+e*e}distanceSquared(t,i){const e=t-this.b,s=i-this.k;return e*e+s*s}normalize(){const t=this.b,i=this.k,e=Math.sqrt(t*t+i*i);return e>0&&(this.b=t/e,this.k=i/e),this}directionPoint(t){return this.JN(t.x-this.b,t.y-this.k)}direction(t,i){return this.JN(t-this.b,i-this.k)}JN(t,i){if(t===0)return i>0?90:i<0?270:0;if(i===0)return t>0?0:180;{if(isNaN(t)||isNaN(i))return 0;let e=Math.atan(Math.abs(i/t))*180/Math.PI;return t<0?i<0?e+=180:e=180-e:i<0&&(e=360-e),e}}static compareWithLineSegment(t,i,e,s,n,o){return Geo.nu(t,i,e,s,n,o)}compareWithLineSegmentPoint(t,i){return Geo.nu(t.x,t.y,i.x,i.y,this.x,this.y)}static intersectingLineSegments(t,i,e,s,n,o,r,l){return Geo.ou(t,i,e,s,n,o,r,l)}projectOntoLineSegment(t,i,e,s){return Geo.ml(t,i,e,s,this.b,this.k,this),this}projectOntoLineSegmentPoint(t,i){return Geo.ml(t.x,t.y,i.x,i.y,this.b,this.k,this),this}snapToGrid(t,i,e,s){return Geo.Ig(this.b,this.k,t,i,e,s,this),this}snapToGridPoint(t,i){return Geo.Ig(this.b,this.k,t.x,t.y,i.width,i.height,this),this}setRectSpot(t,i){return this.b=t.x+i.x*t.width+i.offsetX,this.k=t.y+i.y*t.height+i.offsetY,this}setSpot(t,i,e,s,n){return this.b=t+n.x*e+n.offsetX,this.k=i+n.y*s+n.offsetY,this}D(t){return t.xt(this),this}Ie(t){return t._e(this),this}static distanceLineSegmentSquared(t,i,e,s,n,o){let r=n-e,l=o-s;const h=r*r+l*l,a=e-t,c=s-i,f=-a*r-c*l;if(f<=0||f>=h)return r=n-t,l=o-i,Math.min(a*a+c*c,r*r+l*l);{const u=r*c-l*a;return u*u/h}}static distanceSquared(t,i,e,s){const n=e-t,o=s-i;return n*n+o*o}static direction(t,i,e,s){const n=e-t,o=s-i;if(n===0)return o>0?90:o<0?270:0;if(o===0)return n>0?0:180;{if(isNaN(n)||isNaN(o))return 0;let r=Math.atan(Math.abs(o/n))*180/Math.PI;return n<0?o<0?r+=180:r=180-r:o<0&&(r=360-r),r}}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}isReal(){return isFinite(this.x)&&isFinite(this.y)}static Po=new Point(0,0).it();static $N=new Point(-1/0,-1/0).it();static ZN=new Point(1/0,1/0).it();static QN=new Point(6,6).it();static Ak=new Point(NaN,NaN).it();static Tk=[];static l(){const t=Point.Tk.pop();return t===void 0?new Point:t}static X(t,i){const e=Point.Tk.pop();return e===void 0?new Point(t,i):(e.x=t,e.y=i,e)}static s(t){Point.Tk.push(t)}}class Size{j;H;h;constructor(t,i){t===void 0?(this.j=0,this.H=0):typeof t=="number"&&(t>=0||isNaN(t))&&typeof i=="number"&&(i>=0||isNaN(i))?(this.j=t,this.H=i):Util.o("Invalid arguments to Size constructor: "+t+", "+i),this.h=!1}a(t){return this.j=t.j,this.H=t.H,this}e(t,i){return this.j=t,this.H=i,this}setTo(t,i){return this.j=t,this.H=i,this}set(t){return this.j=t.j,this.H=t.H,this}copy(){const t=new Size;return t.j=this.j,t.H=this.H,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}ot(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;return n=i[e++],n&&(o=parseFloat(n)),new Size(s,o)}else return new Size}static stringify(t){return t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.i(t,"number",Size,"stringifyFixed:digits"),i=>i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Size("+this.width+","+this.height+")"}equals(t){return t instanceof Size?this.j===t.width&&this.H===t.height:!1}equalTo(t,i){return this.j===t&&this.H===i}equalsApprox(t){return Geo.u(this.j,t.width)&&Geo.u(this.H,t.height)}inflate(t,i){const e=this.width+t;this.j=e>=0?e:0;const s=this.height+i;return this.H=s>=0?s:0,this}get width(){return this.j}set width(t){t<0&&Util._(t,">= 0",Size,"width"),this.j=t}get height(){return this.H}set height(t){t<0&&Util._(t,">= 0",Size,"height"),this.H=t}isReal(){return isFinite(this.width)&&isFinite(this.height)}static ru=new Size(0,0).it();static Dk=new Size(1,1).it();static _N=new Size(6,6).it();static lu=new Size(8,8).it();static tC=new Size(10,10).it();static iC=new Size(1/0,1/0).it();static gw=new Size(NaN,NaN).it();static eC=[];static l(){const t=Size.eC.pop();return t===void 0?new Size:t}static s(t){Size.eC.push(t)}}class Rect{b;k;j;H;h;constructor(t,i,e,s){if(t===void 0)this.b=0,this.k=0,this.j=0,this.H=0;else if(typeof t=="number"&&typeof i=="number"&&typeof e=="number"&&(e>=0||isNaN(e))&&typeof s=="number"&&(s>=0||isNaN(s)))this.b=t,this.k=i,this.j=e,this.H=s;else if(t instanceof Point){const n=t.x,o=t.y;if(i instanceof Point){const r=i.x,l=i.y;this.b=Math.min(n,r),this.k=Math.min(o,l),this.j=Math.abs(n-r),this.H=Math.abs(o-l)}else i instanceof Size?(this.b=n,this.k=o,this.j=i.width,this.H=i.height):Util.o("Incorrect second argument supplied to Rect constructor "+i)}else Util.o("Invalid arguments to Rect constructor: "+t+", "+i+", "+e+", "+s);this.h=!1}a(t){return this.b=t.b,this.k=t.k,this.j=t.j,this.H=t.H,this}e(t,i,e,s){return this.b=t,this.k=i,this.j=e,this.H=s,this}En(t,i){return this.j=t,this.H=i,this}setTo(t,i,e,s){return this.b=t,this.k=i,this.j=e,this.H=s,this}set(t){return this.b=t.b,this.k=t.k,this.j=t.j,this.H=t.H,this}setPoint(t){return this.b=t.x,this.k=t.y,this}setSize(t){return this.j=t.width,this.H=t.height,this}copy(){const t=new Rect;return t.b=this.b,t.k=this.k,t.j=this.j,t.H=this.H,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}ot(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),new Rect(s,o,r,l)}else return new Rect}static stringify(t){return t.x.toString()+" "+t.y.toString()+" "+t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.i(t,"number",Rect,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Rect("+this.x+","+this.y+","+this.width+","+this.height+")"}equals(t){return t instanceof Rect?this.b===t.x&&this.k===t.y&&this.j===t.width&&this.H===t.height:!1}equalTo(t,i,e,s){return this.b===t&&this.k===i&&this.j===e&&this.H===s}equalsApprox(t){return Geo.u(this.b,t.x)&&Geo.u(this.k,t.y)&&Geo.u(this.j,t.width)&&Geo.u(this.H,t.height)}equalsApproxTo(t,i,e,s){return Geo.u(this.b,t)&&Geo.u(this.k,i)&&Geo.u(this.j,e)&&Geo.u(this.H,s)}equalsApproxClose(t){return Geo.K(this.b,t.x)&&Geo.K(this.k,t.y)&&Geo.K(this.j,t.width)&&Geo.K(this.H,t.height)}containsPoint(t){return this.b<=t.x&&this.b+this.j>=t.x&&this.k<=t.y&&this.k+this.H>=t.y}containsRect(t){return this.b<=t.x&&t.x+t.width<=this.b+this.j&&this.k<=t.y&&t.y+t.height<=this.k+this.H}contains(t,i,e,s){return e===void 0&&(e=0),s===void 0&&(s=0),this.b<=t&&t+e<=this.b+this.j&&this.k<=i&&i+s<=this.k+this.H}offset(t,i){return this.b+=t,this.k+=i,this}inflate(t,i){return this.mw(i,t,i,t)}addMargin(t){return this.mw(t.top,t.right,t.bottom,t.left)}subtractMargin(t){return this.mw(-t.top,-t.right,-t.bottom,-t.left)}grow(t,i,e,s){return this.mw(t,i,e,s)}mw(t,i,e,s){const n=this.j;i+s<=-n?(this.b+=n/2,this.j=0):(this.b-=s,this.j+=i+s);const o=this.H;return t+e<=-o?(this.k+=o/2,this.H=0):(this.k-=t,this.H+=t+e),this}intersectRect(t){return this.sC(t.x,t.y,t.width,t.height)}intersect(t,i,e,s){return this.sC(t,i,e,s)}sC(t,i,e,s){const n=Math.max(this.b,t),o=Math.max(this.k,i),r=Math.min(this.b+this.j,t+e),l=Math.min(this.k+this.H,i+s);return this.b=n,this.k=o,this.j=Math.max(0,r-n),this.H=Math.max(0,l-o),this}intersectsRect(t){return this.intersects(t.x,t.y,t.width,t.height)}intersects(t,i,e,s){let n=this.j;const o=this.b;if(n!==1/0&&e!==1/0&&(n+=o,e+=t,isNaN(e)||isNaN(n)||o>e||t>n))return!1;let r=this.H;const l=this.k;return!(r!==1/0&&s!==1/0&&(r+=l,s+=i,isNaN(s)||isNaN(r)||l>s||i>r))}intersectsRectPlus(t,i){let e=this.j,s=t.width+i+i;const n=this.b,o=t.x-i;if(e+=n,s+=o,n>s||o>e)return!1;let r=this.H,l=t.height+i+i;const h=this.k,a=t.y-i;return r+=h,l+=a,!(h>l||a>r)}unionPoint(t){return this.unionNoCheck(t.x,t.y,0,0)}unionRect(t){return this.unionNoCheck(t.b,t.k,t.j,t.H)}union(t,i,e,s){return e===void 0&&(e=0),s===void 0&&(s=0),this.unionNoCheck(t,i,e,s)}unionNoCheck(t,i,e,s){const n=Math.min(this.b,t),o=Math.min(this.k,i),r=Math.max(this.b+this.j,t+e),l=Math.max(this.k+this.H,i+s);return this.b=n,this.k=o,this.j=r-n,this.H=l-o,this}setSpot(t,i,e){return this.b=t-e.offsetX-e.x*this.j,this.k=i-e.offsetY-e.y*this.H,this}static contains(t,i,e,s,n,o,r,l){return r===void 0&&(r=0),l===void 0&&(l=0),t<=n&&n+r<=t+e&&i<=o&&o+l<=i+s}static intersects(t,i,e,s,n,o,r,l){let h=e,a=r;const c=t,f=n;if(h+=c,a+=f,c>a||f>h)return!1;let u=s,d=l;const m=i,g=o;return u+=m,d+=g,!(m>d||g>u)}static intersectsLineSegment(t,i,e,s,n,o,r,l){return Geo.nC(t,i,e,s,n,o,r,l)}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}get width(){return this.j}set width(t){t<0&&Util._(t,">= 0",Rect,"width"),this.j=t}get height(){return this.H}set height(t){t<0&&Util._(t,">= 0",Rect,"height"),this.H=t}get left(){return this.b}set left(t){this.b=t}get top(){return this.k}set top(t){this.k=t}get right(){return this.b+this.j}set right(t){this.b+=t-(this.b+this.j)}get bottom(){return this.k+this.H}set bottom(t){this.k+=t-(this.k+this.H)}get position(){return new Point(this.b,this.k)}set position(t){this.b=t.x,this.k=t.y}get size(){return new Size(this.j,this.H)}set size(t){this.j=t.width,this.H=t.height}get center(){return new Point(this.b+this.j/2,this.k+this.H/2)}set center(t){this.b=t.x-this.j/2,this.k=t.y-this.H/2}get centerX(){return this.b+this.j/2}set centerX(t){this.b=t-this.j/2}get centerY(){return this.k+this.H/2}set centerY(t){this.k=t-this.H/2}isReal(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)}isEmpty(){return this.width===0&&this.height===0}static pw=new Rect(0,0,0,0).it();static AD=new Rect(NaN,NaN,NaN,NaN).it();static Fk=[];static l(){const t=Rect.Fk.pop();return t===void 0?new Rect:t}static X(t,i,e,s){const n=Rect.Fk.pop();return n===void 0?new Rect(t,i,e,s):n.e(t,i,e,s)}static s(t){Rect.Fk.push(t)}}class Margin{nn;on;rn;ln;h;constructor(t,i,e,s){t===void 0?(this.nn=0,this.on=0,this.rn=0,this.ln=0):i===void 0?(i=t,e=t,s=t,this.top=t,this.right=i,this.bottom=e,this.left=s):e===void 0?(e=t,s=i,this.top=t,this.right=i,this.bottom=e,this.left=s):s!==void 0?(this.top=t,this.right=i,this.bottom=e,this.left=s):Util.o("Invalid arguments to Margin constructor: "+t+", "+i+", "+e+", "+s),this.h=!1}a(t){return this.nn=t.nn,this.on=t.on,this.rn=t.rn,this.ln=t.ln,this}setTo(t,i,e,s){return this.nn=t,this.on=i,this.rn=e,this.ln=s,this}set(t){return this.nn=t.nn,this.on=t.on,this.rn=t.rn,this.ln=t.ln,this}copy(){const t=new Margin;return t.nn=this.nn,t.on=this.on,t.rn=this.rn,t.ln=this.ln,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}ot(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=NaN;for(;i[e]==="";)e++;let n=i[e++];if(n&&(s=parseFloat(n)),isNaN(s))return new Margin;let o=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(o=parseFloat(n)),isNaN(o))return new Margin(s);let r=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(r=parseFloat(n)),isNaN(r))return new Margin(s,o);let l=NaN;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),isNaN(l)?new Margin(s,o):new Margin(s,o,r,l)}else return new Margin}static stringify(t){return t.top.toString()+" "+t.right.toString()+" "+t.bottom.toString()+" "+t.left.toString()}static stringifyFixed(t){return Util.i(t,"number",Margin,"stringifyFixed:digits"),i=>i.top.toFixed(t)+" "+i.right.toFixed(t)+" "+i.bottom.toFixed(t)+" "+i.left.toFixed(t)}toString(){return"Margin("+this.top+","+this.right+","+this.bottom+","+this.left+")"}equals(t){return t instanceof Margin?this.nn===t.top&&this.on===t.right&&this.rn===t.bottom&&this.ln===t.left:!1}equalTo(t,i,e,s){return this.nn===t&&this.on===i&&this.rn===e&&this.ln===s}equalsApprox(t){return Geo.u(this.nn,t.top)&&Geo.u(this.on,t.right)&&Geo.u(this.rn,t.bottom)&&Geo.u(this.ln,t.left)}get top(){return this.nn}set top(t){this.nn=t}get right(){return this.on}set right(t){this.on=t}get bottom(){return this.rn}set bottom(t){this.rn=t}get left(){return this.ln}set left(t){this.ln=t}isReal(){return isFinite(this.top)&&isFinite(this.right)&&isFinite(this.bottom)&&isFinite(this.left)}static Eg=new Margin(0,0,0,0).it();static oC=new Margin(2,2,2,2).it();static rC=[];static l(){const t=Margin.rC.pop();return t===void 0?new Margin:t}static s(t){Margin.rC.push(t)}}class Spot{b;k;As;Ts;h;constructor(t,i,e,s){t===void 0?(this.b=0,this.k=0,this.As=0,this.Ts=0):(i===void 0&&(i=0),e===void 0&&(e=0),s===void 0&&(s=0),this.x=t,this.y=i,this.offsetX=e,this.offsetY=s),this.h=!1}a(t){return this.b=t.b,this.k=t.k,this.As=t.As,this.Ts=t.Ts,this}setTo(t,i,e,s){return this.b=t,this.k=i,this.As=e,this.Ts=s,this}set(t){return this.b=t.b,this.k=t.k,this.As=t.As,this.Ts=t.Ts,this}copy(){const t=new Spot;return t.b=this.b,t.k=this.k,t.As=this.As,t.Ts=this.Ts,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}ot(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}Ee(t){return this.b=NaN,this.k=NaN,this.As=t,this}_I(t,i){(isNaN(t)||t>1||t<0)&&Util._(t,"0 <= "+i+" <= 1",Spot,i)}tE(t,i){(isNaN(t)||t===1/0||t===-1/0)&&Util._(t,"real number, not NaN or Infinity",Spot,i)}static parse(t){if(typeof t=="string"){if(t=t.trim(),t==="None")return Spot.None;if(t==="TopLeft")return Spot.TopLeft;if(t==="Top"||t==="TopCenter"||t==="MiddleTop")return Spot.TopCenter;if(t==="TopRight")return Spot.TopRight;if(t==="Left"||t==="LeftCenter"||t==="MiddleLeft")return Spot.LeftCenter;if(t==="Center")return Spot.Center;if(t==="Right"||t==="RightCenter"||t==="MiddleRight")return Spot.RightCenter;if(t==="BottomLeft")return Spot.BottomLeft;if(t==="Bottom"||t==="BottomCenter"||t==="MiddleBottom")return Spot.BottomCenter;if(t==="BottomRight")return Spot.BottomRight;if(t==="TopSide")return Spot.TopSide;if(t==="LeftSide")return Spot.LeftSide;if(t==="RightSide")return Spot.RightSide;if(t==="BottomSide")return Spot.BottomSide;if(t==="TopBottomSides")return Spot.TopBottomSides;if(t==="LeftRightSides")return Spot.LeftRightSides;if(t==="TopLeftSides")return Spot.TopLeftSides;if(t==="TopRightSides")return Spot.TopRightSides;if(t==="BottomLeftSides")return Spot.BottomLeftSides;if(t==="BottomRightSides")return Spot.BottomRightSides;if(t==="NotTopSide")return Spot.NotTopSide;if(t==="NotLeftSide")return Spot.NotLeftSide;if(t==="NotRightSide")return Spot.NotRightSide;if(t==="NotBottomSide")return Spot.NotBottomSide;if(t==="AllSides")return Spot.AllSides;if(t==="Default")return Spot.Default;const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n!==void 0&&n.length>0&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n!==void 0&&n.length>0&&(l=parseFloat(n)),new Spot(s,o,r,l)}else return new Spot}static stringify(t){return t.isSpot()?t.x.toString()+" "+t.y.toString()+" "+t.offsetX.toString()+" "+t.offsetY.toString():t.toString()}static stringifyFixed(t){return Util.i(t,"number",Spot,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.offsetX.toFixed(t)+" "+i.offsetY.toFixed(t)}toString(){return this.isSpot()?this.As===0&&this.Ts===0?"Spot("+this.x+","+this.y+")":"Spot("+this.x+","+this.y+","+this.offsetX+","+this.offsetY+")":this.equals(Spot.None)?"None":this.equals(Spot.TopLeft)?"TopLeft":this.equals(Spot.TopCenter)?"Top":this.equals(Spot.TopRight)?"TopRight":this.equals(Spot.LeftCenter)?"Left":this.equals(Spot.Center)?"Center":this.equals(Spot.RightCenter)?"Right":this.equals(Spot.BottomLeft)?"BottomLeft":this.equals(Spot.BottomCenter)?"Bottom":this.equals(Spot.BottomRight)?"BottomRight":this.equals(Spot.TopSide)?"TopSide":this.equals(Spot.LeftSide)?"LeftSide":this.equals(Spot.RightSide)?"RightSide":this.equals(Spot.BottomSide)?"BottomSide":this.equals(Spot.TopBottomSides)?"TopBottomSides":this.equals(Spot.LeftRightSides)?"LeftRightSides":this.equals(Spot.TopLeftSides)?"TopLeftSides":this.equals(Spot.TopRightSides)?"TopRightSides":this.equals(Spot.BottomLeftSides)?"BottomLeftSides":this.equals(Spot.BottomRightSides)?"BottomRightSides":this.equals(Spot.NotTopSide)?"NotTopSide":this.equals(Spot.NotLeftSide)?"NotLeftSide":this.equals(Spot.NotRightSide)?"NotRightSide":this.equals(Spot.NotBottomSide)?"NotBottomSide":this.equals(Spot.AllSides)?"AllSides":this.equals(Spot.Default)?"Default":"None"}equals(t){return t instanceof Spot?(this.b===t.x||isNaN(this.b)&&isNaN(t.x))&&(this.k===t.y||isNaN(this.k)&&isNaN(t.y))&&this.As===t.offsetX&&this.Ts===t.offsetY:!1}opposite(){return new Spot(.5-(this.b-.5),.5-(this.k-.5),-this.As,-this.Ts)}includesSide(t){if(!this.isSide())return!1;if(!t.isSide())if(t.equals(Spot.Left))t=Spot.LeftSide;else if(t.equals(Spot.Right))t=Spot.RightSide;else if(t.equals(Spot.Top))t=Spot.TopSide;else if(t.equals(Spot.Bottom))t=Spot.BottomSide;else return!1;const i=this.Ts,e=t.offsetY;return(i&e)===e}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}get offsetX(){return this.As}set offsetX(t){this.As=t}get offsetY(){return this.Ts}set offsetY(t){this.Ts=t}isSpot(){return!isNaN(this.x)&&!isNaN(this.y)}isNoSpot(){return isNaN(this.x)||isNaN(this.y)}isSide(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===1&&this.offsetY!==0}isNone(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===0&&this.offsetY===0}isDefault(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===-1&&this.offsetY===0}static None=new Spot(0,0,0,0).Ee(0).it();static Default=new Spot(0,0,-1,0).Ee(-1).it();static TopLeft=new Spot(0,0,0,0).it();static TopCenter=new Spot(.5,0,0,0).it();static TopRight=new Spot(1,0,0,0).it();static LeftCenter=new Spot(0,.5,0,0).it();static Center=new Spot(.5,.5,0,0).it();static RightCenter=new Spot(1,.5,0,0).it();static BottomLeft=new Spot(0,1,0,0).it();static BottomCenter=new Spot(.5,1,0,0).it();static BottomRight=new Spot(1,1,0,0).it();static MiddleTop=Spot.TopCenter;static MiddleLeft=Spot.LeftCenter;static MiddleRight=Spot.RightCenter;static MiddleBottom=Spot.BottomCenter;static Top=Spot.TopCenter;static Left=Spot.LeftCenter;static Right=Spot.RightCenter;static Bottom=Spot.BottomCenter;static TopSide=new Spot(0,0,1,1).Ee(1).it();static LeftSide=new Spot(0,0,1,2).Ee(1).it();static RightSide=new Spot(0,0,1,4).Ee(1).it();static BottomSide=new Spot(0,0,1,8).Ee(1).it();static TopBottomSides=new Spot(0,0,1,9).Ee(1).it();static LeftRightSides=new Spot(0,0,1,6).Ee(1).it();static TopLeftSides=new Spot(0,0,1,3).Ee(1).it();static TopRightSides=new Spot(0,0,1,5).Ee(1).it();static BottomLeftSides=new Spot(0,0,1,10).Ee(1).it();static BottomRightSides=new Spot(0,0,1,12).Ee(1).it();static NotTopSide=new Spot(0,0,1,14).Ee(1).it();static NotLeftSide=new Spot(0,0,1,13).Ee(1).it();static NotRightSide=new Spot(0,0,1,11).Ee(1).it();static NotBottomSide=new Spot(0,0,1,7).Ee(1).it();static AllSides=new Spot(0,0,1,15).Ee(1).it();static Rk=new Spot(.156,.156).it();static vk=new Spot(.844,.844).it();static lC=[];static l(){const t=Spot.lC.pop();return t===void 0?new Spot:t}static s(t){Spot.lC.push(t)}}class Transform{m11;m12;m21;m22;dx;dy;constructor(){this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0}set(t){return this.m11=t.m11,this.m12=t.m12,this.m21=t.m21,this.m22=t.m22,this.dx=t.dx,this.dy=t.dy,this}setTo(t,i,e,s,n,o){return this.m11=t,this.m12=i,this.m21=e,this.m22=s,this.dx=n,this.dy=o,this}copy(){const t=new Transform;return t.m11=this.m11,t.m12=this.m12,t.m21=this.m21,t.m22=this.m22,t.dx=this.dx,t.dy=this.dy,t}toString(){return"Transform("+this.m11+","+this.m12+","+this.m21+","+this.m22+","+this.dx+","+this.dy+")"}equals(t){return this.m11===t.m11&&this.m12===t.m12&&this.m21===t.m21&&this.m22===t.m22&&this.dx===t.dx&&this.dy===t.dy}Ok(){return this.dx===0&&this.dy===0&&this.m11===1&&this.m12===0&&this.m21===0&&this.m22===1}Ri(){return this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0,this}ic(t){const i=this.m11*t.m11+this.m21*t.m12,e=this.m12*t.m11+this.m22*t.m12,s=this.m11*t.m21+this.m21*t.m22,n=this.m12*t.m21+this.m22*t.m22;return this.dx=this.m11*t.dx+this.m21*t.dy+this.dx,this.dy=this.m12*t.dx+this.m22*t.dy+this.dy,this.m11=i,this.m12=e,this.m21=s,this.m22=n,this}hC(t){const i=1/(t.m11*t.m22-t.m12*t.m21),e=t.m22*i,s=-t.m12*i,n=-t.m21*i,o=t.m11*i,r=i*(t.m21*t.dy-t.m22*t.dx),l=i*(t.m12*t.dx-t.m11*t.dy),h=this.m11*e+this.m21*s,a=this.m12*e+this.m22*s,c=this.m11*n+this.m21*o,f=this.m12*n+this.m22*o;return this.dx=this.m11*r+this.m21*l+this.dx,this.dy=this.m12*r+this.m22*l+this.dy,this.m11=h,this.m12=a,this.m21=c,this.m22=f,this}yw(){const t=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*t,e=-this.m12*t,s=-this.m21*t,n=this.m11*t,o=t*(this.m21*this.dy-this.m22*this.dx),r=t*(this.m12*this.dx-this.m11*this.dy);return this.m11=i,this.m12=e,this.m21=s,this.m22=n,this.dx=o,this.dy=r,this}cs(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return this;this.Ds(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m11*s+this.m21*n,r=this.m12*s+this.m22*n,l=this.m11*-n+this.m21*s,h=this.m12*-n+this.m22*s;return this.m11=o,this.m12=r,this.m21=l,this.m22=h,this.Ds(-i,-e),this}Ds(t,i){return this.dx+=this.m11*t+this.m21*i,this.dy+=this.m12*t+this.m22*i,this}et(t,i){return i===void 0&&(i=t),this.m11*=t,this.m12*=t,this.m21*=i,this.m22*=i,this}TD(){if(this.m11===1&&this.m12===0)return 0;let t=Math.atan2(this.m12,this.m11)*180/Math.PI;return t<0&&(t+=360),t}xt(t){const i=t.x,e=t.y;return t.e(i*this.m11+e*this.m21+this.dx,i*this.m12+e*this.m22+this.dy)}_e(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=t.x-this.dx,l=t.y-this.dy;return t.e(r*e+l*n,r*s+l*o)}ww(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=i*(this.m21*this.dy-this.m22*this.dx),l=i*(this.m12*this.dx-this.m11*this.dy),h=t.x*1.25,a=t.y*1.2;return t.e(h*e+a*n+r,h*s+a*o+l)}xw(t){const i=t.x,e=t.y,s=i+t.width,n=e+t.height,o=this.m11,r=this.m12,l=this.m21,h=this.m22,a=this.dx,c=this.dy,f=i*o+e*l+a,u=i*r+e*h+c,d=s*o+e*l+a,m=s*r+e*h+c,g=i*o+n*l+a,p=i*r+n*h+c,y=s*o+n*l+a,x=s*r+n*h+c;let k=f,b=f,P=u,S=u;return k=Math.min(k,d),b=Math.max(b,d),P=Math.min(P,m),S=Math.max(S,m),k=Math.min(k,g),b=Math.max(b,g),P=Math.min(P,p),S=Math.max(S,p),k=Math.min(k,y),b=Math.max(b,y),P=Math.min(P,x),S=Math.max(S,x),t.e(k,P,b-k,S-P),t}static aC=[];static l(){const t=Transform.aC.pop();return t===void 0?new Transform:t}static s(t){Transform.aC.push(t)}static Ik="54a702f3e53909c447824c6706603faf4c"}const Geo={DD:"7da71ca0ad381e90",Bn:4*((Math.sqrt(2)-1)/3),cC:null,bw:w=>{if(w<=0)return 0;let t=Geo.cC;if(t===null){t=[];for(let i=0;i<=2e3;i++)t[i]=Math.sqrt(i);Geo.cC=t}if(w<1){const i=1/w;return i<=2e3?1/t[i|0]:Math.sqrt(w)}else return w<=2e3?t[w|0]:Math.sqrt(w)},u:(w,t)=>{const i=w-t;return i<.5&&i>-.5},K:(w,t)=>{const i=w-t;return i<5e-8&&i>-5e-8},vi:(w,t,i,e,s,n,o)=>{s<=0&&(s=1e-6);let r=0,l=0,h=0,a=0;if(wu-d)if(w-i>s||i-w>s){const g=(e-t)/(i-w)*(n-w)+t;if(g-s<=o&&o<=g+s)return!0}else return!0;else if(t-e>s||e-t>s){const g=(i-w)/(e-t)*(o-t)+w;if(g-s<=n&&n<=g+s)return!0}else return!0}return!1},kw:(w,t,i,e,s,n,o,r,l,h,a,c)=>{if(!Geo.vi(w,t,o,r,c,i,e)||!Geo.vi(w,t,o,r,c,s,n)){const f=(w+i)/2,u=(t+e)/2,d=(i+s)/2,m=(e+n)/2,g=(s+o)/2,p=(n+r)/2,y=(f+d)/2,x=(u+m)/2,k=(d+g)/2,b=(m+p)/2,P=(y+k)/2,S=(x+b)/2;return Geo.kw(w,t,f,u,y,x,P,S,l,h,a,c)||Geo.kw(P,S,k,b,g,p,o,r,l,h,a,c)}else return Geo.vi(w,t,o,r,c,h,a)},fC:(w,t,i,e,s,n,o,r,l)=>{const h=(w+i)/2,a=(t+e)/2,c=(i+s)/2,f=(e+n)/2,u=(s+o)/2,d=(n+r)/2,m=(h+c)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2;return l.e((m+p)/2,(g+y)/2),l},FD:(w,t,i,e,s,n,o,r)=>{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(s+o)/2,u=(n+r)/2,d=(l+a)/2,m=(h+c)/2,g=(a+f)/2,p=(c+u)/2;return Point.direction(d,m,g,p)},hu:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.vi(w,t,o,r,l,i,e)||!Geo.vi(w,t,o,r,l,s,n)){const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.hu(w,t,a,c,g,p,k,b,l,h),Geo.hu(k,b,y,x,d,m,o,r,l,h)}else h.unionNoCheck(w,t,0,0),h.unionNoCheck(o,r,0,0);return h},Un:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.vi(w,t,o,r,l,i,e)||!Geo.vi(w,t,o,r,l,s,n)){const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.Un(w,t,a,c,g,p,k,b,l,h),Geo.Un(k,b,y,x,d,m,o,r,l,h)}else h.length===0&&(h.push(w),h.push(t)),h.push(o),h.push(r);return h},Ek:(w,t,i,e,s,n,o,r,l,h)=>{if(Geo.vi(w,t,s,n,h,i,e))return Geo.vi(w,t,s,n,h,r,l);{const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(a+f)/2,m=(c+u)/2;return Geo.Ek(w,t,a,c,d,m,o,r,l,h)||Geo.Ek(d,m,f,u,s,n,o,r,l,h)}},iE:(w,t,i,e,s,n,o)=>{const r=(w+i)/2,l=(t+e)/2,h=(i+s)/2,a=(e+n)/2;return o.e((r+h)/2,(l+a)/2),o},Bk:(w,t,i,e,s,n,o,r)=>{if(Geo.vi(w,t,s,n,o,i,e))r.unionNoCheck(w,t,0,0),r.unionNoCheck(s,n,0,0);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(l+a)/2,u=(h+c)/2;Geo.Bk(w,t,l,h,f,u,o,r),Geo.Bk(f,u,a,c,s,n,o,r)}return r},Bg:(w,t,i,e,s,n,o,r)=>{if(Geo.vi(w,t,s,n,o,i,e))r.length===0&&(r.push(w),r.push(t)),r.push(s),r.push(n);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(l+a)/2,u=(h+c)/2;Geo.Bg(w,t,l,h,f,u,o,r),Geo.Bg(f,u,a,c,s,n,o,r)}return r},Ug:(w,t,i,e,s,n,o,r,l,h,a,c,f,u)=>{if(!Geo.vi(w,t,o,r,f,i,e)||!Geo.vi(w,t,o,r,f,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,P=(g+y)/2,S=(p+x)/2,L=(k+P)/2,C=(b+S)/2;let M=1/0,N=!1,T=0,A=0;if(Geo.Ug(w,t,d,m,k,b,L,C,l,h,a,c,f,u)){const D=(u.x-l)*(u.x-l)+(u.y-h)*(u.y-h);D{let u=0;if(!Geo.vi(w,t,o,r,f,i,e)||!Geo.vi(w,t,o,r,f,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,P=(g+y)/2,S=(p+x)/2,L=(k+P)/2,C=(b+S)/2;u+=Geo.Vg(w,t,d,m,k,b,L,C,l,h,a,c,f),u+=Geo.Vg(L,C,P,S,y,x,o,r,l,h,a,c,f)}else{const d=(w-o)*(h-c)-(t-r)*(l-a);if(d===0)return u;const m=((w*r-t*o)*(l-a)-(w-o)*(l*c-h*a))/d,g=((w*r-t*o)*(h-c)-(t-r)*(l*c-h*a))/d;if(m>=a)return u;let p=0,y=0;if((l>a?l-a:a-l)<(h>c?h-c:c-h)){if(ty)return u}else if(wy)return u;d>0?u++:d<0&&u--}return u},ml:(w,t,i,e,s,n,o)=>{if(Geo.K(w,i)){let r=0,l=0;tl?(o.e(w,l),!1):(o.e(w,h),!0)}else if(Geo.K(t,e)){let r=0,l=0;wl?(o.e(l,t),!1):(o.e(h,t),!0)}else{const r=(i-w)*(i-w)+(e-t)*(e-t),l=((w-s)*(w-i)+(t-n)*(t-e))/r;if(l<-5e-6)return o.e(w,t),!1;if(l>1.000005)return o.e(i,e),!1;{const h=w+l*(i-w),a=t+l*(e-t);return o.e(h,a),!0}}},Vn:(w,t,i,e,s,n,o,r,l)=>{if(Geo.u(w,i)&&Geo.u(t,e))return l.e(w,t),!1;if(Geo.K(s,o)){if(Geo.K(w,i))return Geo.ml(w,t,i,e,s,n,l),!1;{const a=(e-t)/(i-w)*(s-w)+t;return Geo.ml(w,t,i,e,s,a,l)}}else{const h=(r-n)/(o-s);if(Geo.K(w,i)){const a=h*(w-s)+n;let c=0,f=0;return tf?(l.e(w,f),!1):(l.e(w,a),!0)}else{const a=(e-t)/(i-w);if(Geo.K(h,a))return Geo.ml(w,t,i,e,s,n,l),!1;{const c=(a*w-h*s+n-t)/(a-h);if(Geo.K(a,0)){let f=0,u=0;return wu?(l.e(u,t),!1):(l.e(c,t),!0)}else{const f=a*(c-w)+t;return Geo.ml(w,t,i,e,c,f,l)}}}}},eE:(w,t,i,e,s)=>Geo.Vn(i.x,i.y,e.x,e.y,w.x,w.y,t.x,t.y,s),sE:(w,t,i,e,s,n,o,r,l,h)=>{let a=1/0;function c(P,S){const L=(P-w)*(P-w)+(S-t)*(S-t);Lw?i-w:w-i)<.5){const P=1-(i-k)*(i-k)/(y*y);if(P<0)return l;const S=Math.sqrt(P),L=x*S+b,C=-x*S+b;c(i,L),c(i,C)}else{const P=(e-t)/(i-w),S=1/(y*y)+P*P/(x*x),L=2*P*(t-P*w)/(x*x)-2*P*b/(x*x)-2*k/(y*y),C=2*P*w*b/(x*x)-2*t*b/(x*x)+b*b/(x*x)+k*k/(y*y)-1+(t-P*w)*(t-P*w)/(x*x),M=L*L-4*S*C;if(M<0)return l;const N=Math.sqrt(M),T=(-L+N)/(2*S);c(T,P*T-P*w+t);const A=(-L-N)/(2*S);c(A,P*A-P*w+t)}return l},pl:(w,t,i,e,s,n,o,r,l)=>{let h=1e21,a=w,c=t;if(Geo.Vn(w,t,w,e,s,n,o,r,l)){const f=(l.x-s)*(l.x-s)+(l.y-n)*(l.y-n);fGeo.nC(w.x,w.y,w.width,w.height,t.x,t.y,i.x,i.y),nC:(w,t,i,e,s,n,o,r)=>{const l=w,h=w+i,a=t,c=t+e;if(s===o){let f=0,u=0;return n=a}if(n===r){let f=0,u=0;return s=l}return!!(Rect.contains(w,t,i,e,s,n)||Rect.contains(w,t,i,e,o,r)||Geo.ou(l,a,h,a,s,n,o,r)||Geo.ou(h,a,h,c,s,n,o,r)||Geo.ou(h,c,l,c,s,n,o,r)||Geo.ou(l,c,l,a,s,n,o,r))},ou:(w,t,i,e,s,n,o,r)=>w===i&&t===e&&s===o&&n===r?w===s&&t===n:Geo.nu(w,t,i,e,s,n)*Geo.nu(w,t,i,e,o,r)<=0&&Geo.nu(s,n,o,r,w,t)*Geo.nu(s,n,o,r,i,e)<=0,nu:(w,t,i,e,s,n)=>{const o=i-w,r=e-t;let l=s-w,h=n-t,a=l*r-h*o;return a===0&&(a=l*o+h*r,a>0&&(l-=o,h-=r,a=l*o+h*r,a<0&&(a=0))),a},zg:w=>(w<0&&(w+=360),w>=360&&(w-=360),w),uC:(w,t,i,e,s,n)=>{const o=Math.PI;n||(e=e*(o/180),s=s*(o/180));const r=e>s?-1:1,l=1e-5,h=o*2,a=[],c=o/2;let f=e,u=Math.min(h,Math.abs(s-e));if(ul;){const d=f+r*Math.min(u,c);a.push(Geo.RD(i,f,d,w,t)),u-=Math.abs(d-f),f=d}return a},RD:(w,t,i,e,s)=>{const n=(i-t)/2,o=w*Math.cos(n),r=w*Math.sin(n),l=o,h=-r,a=l*l+h*h,c=a+l*o+h*r,f=4/3*(Math.sqrt(2*a*c)-c)/(l*r-h*o),u=l-f*h,d=h+f*l,m=u,g=-d,p=n+t,y=Math.cos(p),x=Math.sin(p);return[e+w*Math.cos(t),s+w*Math.sin(t),e+u*y-d*x,s+u*x+d*y,e+m*y-g*x,s+m*x+g*y,e+w*Math.cos(i),s+w*Math.sin(i)]},Ig:(w,t,i,e,s,n,o)=>{const r=s,l=n,h=Math.floor((w-i)/r)*r+i,a=Math.floor((t-e)/l)*l+e;let c=h;h+r-w{let i=Math.max(w,t),e=Math.min(w,t),s=1,n=1;do s=i%e,n=e,i=e,e=s;while(s>0);return n},vD:(w,t,i,e)=>{const s=i<0,n=e<0;let o=0,r=0,l=0;w{let o=0;if(e>0)if(i>0){const r=w*w,l=t*t,h=w*i,a=t*e;let c=-l+a,f=-l+Math.sqrt(h*h+a*a),u=c;const d=9999999999;for(let p=0;p0)c=u;else if(k<0)f=u;else break}s=r*i/(u+r),n=l*e/(u+l);const m=s-i,g=n-e;o=Math.sqrt(m*m+g*g)}else s=0,n=t,o=Math.abs(e-t);else{const r=w*w-t*t,l=w*i;if(l(w[w.Line=1]="Line",w[w.Rectangle=2]="Rectangle",w[w.Ellipse=3]="Ellipse",w[w.Path=4]="Path",w))(GeometryType||{}),GeometryStretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w))(GeometryStretch||{});class Geometry{n;Yg;Gg;ec;au;cu;zn;Xn;Kn;$;xe;be;Qi;_i;Fs;sc;nc;constructor(t){GSet.Yi(this),this.n=2,t===void 0&&(t=4),this.$=t,this.xe=0,this.be=0,this.Qi=0,this._i=0,t===4?this.Fs=new List:this.Fs=Geometry.Sw,this.Yg=this.Fs.ht,this.Gg=new Rect().g(),this.ec=null,this.au=null,this.cu=NaN,this.zn=Spot.TopLeft,this.Xn=Spot.BottomRight,this.sc=NaN,this.nc=NaN,this.Kn=2}copy(){const t=new Geometry;if(t.n=this.n&-2,t.$=this.$,t.xe=this.xe,t.be=this.be,t.Qi=this.Qi,t._i=this._i,this.$===4){const i=this.Fs.r,e=t.Fs;for(let s=0;si.toString(t)}ri(t){t in GeometryType?this.type=t:Util.lr(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e;switch(this.type){case 1:return t<0?"M"+this.startX.toString()+" "+this.startY.toString()+"L"+this.endX.toString()+" "+this.endY.toString():"M"+i(this.startX)+" "+i(this.startY)+"L"+i(this.endX)+" "+i(this.endY);case 2:return e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0?"M"+e.x.toString()+" "+e.y.toString()+"H"+e.right.toString()+"V"+e.bottom.toString()+"H"+e.left.toString()+"z":"M"+i(e.x)+" "+i(e.y)+"H"+i(e.right)+"V"+i(e.bottom)+"H"+i(e.left)+"z";case 3:if(e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0){const r=e.left.toString()+" "+(e.y+e.height/2).toString(),l=e.right.toString()+" "+(e.y+e.height/2).toString();return"M"+r+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+l+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+r}else{const r=i(e.left)+" "+i(e.y+e.height/2),l=i(e.right)+" "+i(e.y+e.height/2);return"M"+r+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+l+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+r}case 4:let s="";const n=this.figures.r,o=n.length;for(let r=0;r0&&(s+=" x "),l.isFilled&&(s+="F "),s+=l.toString(t)}return s;default:return GeometryType[this.type]}}static fillPath(t){typeof t!="string"&&Util.we(t,"string",Geometry,"fillPath:str");const i=t.split(/[Xx]/),e=i.length;let s="";for(let n=0;n=k-1||o[r+1].match(N)!==null?!0:(u=!1,!1)}function m(){return r++,o[r]}function g(A){let D=parseFloat(m()),F=parseFloat(m());l===l.toLowerCase()&&(D=f.x+D,F=f.y+F),A.e(D,F)}function p(){return g(f),f}function y(){return g(c),c}function x(){const A=h.toLowerCase();return A==="c"||A==="s"||A==="q"||A==="t"?new Point(2*f.x-c.x,2*f.y-c.y):new Point(f.x,f.y)}const k=o.length,b=GeoStream.mC(null);let P=!1,S=!1,L=!1,C=!0,M=null;const N=new RegExp("["+Geometry.jg+"]");for(;!(r>=k-1);){if(h=l,l=m(),l==="")continue;u=!0;let A=!1;switch(l.toUpperCase()){case"X":C=!0,P=!1,S=!1;break;case"M":for(M=p(),b.Pi===null||C===!0?(b.fu(M.x,M.y,P,!1,!S,L),C=!1):b.ID(M.x,M.y),a.a(f);!d();)M=p(),b.ur(M.x,M.y);break;case"L":for(;!d();)M=p(),b.ur(M.x,M.y);u&&(A=!0);break;case"H":for(;!d();)f.e((l===l.toLowerCase()?f.x:0)+parseFloat(m()),f.y),b.ur(f.x,f.y);break;case"V":for(;!d();)f.e(f.x,(l===l.toLowerCase()?f.y:0)+parseFloat(m())),b.ur(f.x,f.y);u&&(A=!0);break;case"C":for(;!d();){const D=new Point;g(D);const F=y(),R=p();b.dr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(A=!0);break;case"S":for(;!d();){const D=x(),F=y(),R=p();b.dr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(A=!0);break;case"Q":for(;!d();){const D=y(),F=p();b.Mw(D.x,D.y,F.x,F.y)}u&&(A=!0);break;case"T":for(;!d();){const D=x();c.a(D);const F=p();b.Mw(D.x,D.y,F.x,F.y),c.a(F)}u&&(A=!0);break;case"B":for(;!d();){const D=parseFloat(m()),F=parseFloat(m());let R=parseFloat(m()),v=parseFloat(m());const O=parseFloat(m());let B=O,X=!1;d()||(B=parseFloat(m()),d()||(X=parseFloat(m())!==0)),l===l.toLowerCase()&&(R+=f.x,v+=f.y),b.ED(D,F,R,v,O,B,X)}u&&(A=!0);break;case"A":for(;!d();){const D=Math.abs(parseFloat(m())),F=Math.abs(parseFloat(m())),R=parseFloat(m());let v=!1,O=!1,B=0,X=0;const E=m();E.length===1?(v=!!parseFloat(E),O=!!parseFloat(m()),B=parseFloat(m()),X=parseFloat(m())):E.length===2?(v=!!parseFloat(E[0]),O=!!parseFloat(E[1]),B=parseFloat(m()),X=parseFloat(m())):(v=!!parseFloat(E[0]),O=!!parseFloat(E[1]),B=parseFloat(E.slice(2)),X=parseFloat(m())),l===l.toLowerCase()&&(B=f.x+B,X=f.y+X),f.e(B,X),b.BD(D,F,R,v,O,B,X)}u&&(A=!0);break;case"Z":b.UD(),f.a(a);break;case"F":{let D="",F=1;for(;o[r+F];){if(o[r+F]==="0"){L=!0,F++;continue}if(o[r+F].match(/[Uu]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?P=!0:b.VD();break}case"U":{let D="",F=1;for(;o[r+F];){if(o[r+F].match(/[Ff]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?S=!0:b.zD(!1);break}default:if(l==="0"||l==="1")break;Util.ii("Unknown geometry command: "+l);break}if(A){Util.ii(`Bad geometry command: ${l}, next token: ${m()}, +string: ${t}`);break}}const T=b.Hg;if(GeoStream.pC(b),i){const A=T.figures.iterator;for(;A.next();){const D=A.value;D.isFilled=!0}}return T}static yC(t,i){const e=t.length,s=Point.l();for(let n=0;n=t)return 0;if((n>r?n-r:r-n)<(o>l?o-l:l-o)){if(ol)return 0}else if(co)return 0}else if(nr)return 0}else if(an)return 0;return h>0?1:-1}xC(t,i,e){const s=this.figures.r,n=s.length;for(let o=0;o1&&(t=1),i===void 0&&(i=new Point),this.type===1)return i.e(this.startX+t*(this.endX-this.startX),this.startY+t*(this.endY-this.startY)),i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[f*2],y=g[f*2+1],x=g[f*2+2],k=g[f*2+3];return i.e(p+(x-p)*m,y+(k-y)*m),i}l+=u}}return i}getAngleAlongPath(t){if(t<0?t=0:t>1&&(t=1),this.type===1)return Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI;const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=i.length,o=s*t;let r=0;for(let l=0;l=o){const u=i[l],d=u[c*2],m=u[c*2+1],g=u[c*2+2],p=u[c*2+3];return Math.abs(g-d)<1&&Math.abs(p-m)<1?0:Math.abs(g-d)<1?p-m>=0?90:270:Math.abs(p-m)<1?g-d>=0?0:180:Math.atan2(p-m,g-d)*180/Math.PI}r+=f}}return NaN}getPointAndAngleAlongPath(t,i){if(t<0?t=0:t>1&&(t=1),i===void 0&&(i=[]),i.length=3,this.type===1)return i[0]=this.startX+t*(this.endX-this.startX),i[1]=this.startY+t*(this.endY-this.startY),i[2]=Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI,i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[f*2],y=g[f*2+1],x=g[f*2+2],k=g[f*2+3];i[0]=p+(x-p)*m,i[1]=y+(k-y)*m;let b;return Math.abs(x-p)<1&&Math.abs(k-y)<1?b=0:Math.abs(x-p)<1?b=k-y>=0?90:270:Math.abs(k-y)<1?b=x-p>=0?0:180:b=Math.atan2(k-y,x-p)*180/Math.PI,i[2]=b,i}l+=u}}return i}getFractionForPoint(t){if(this.type===1){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=t.x,r=t.y;let l=0,h=0;if(i===s)return e=h?h===e?0:1:Math.abs(r-e)/(h-l);if(e===n)return i=h?h===i?0:1:Math.abs(o-i)/(h-l);{const a=(s-i)*(s-i)+(n-e)*(n-e),c=Point.l();Geo.ml(i,e,s,n,o,r,c);const f=c.x,u=c.y;return Point.s(c),Math.sqrt(((f-i)*(f-i)+(u-e)*(u-e))/a)}}}else if(this.type===2){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=s-i,r=n-e,l=o*2+r*2;let h=t.x,a=t.y;h=Math.min(Math.max(h,i),s),a=Math.min(Math.max(a,e),n);const c=Math.abs(h-i),f=Math.abs(h-s),u=Math.abs(a-e),d=Math.abs(a-n),m=Math.min(c,f,u,d);if(m===u)return h/l;if(m===f)return(o+a)/l;if(m===d)return(o*2+r-h)/l;if(m===c)return(o*2+r*2-a)/l}}else{const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=Point.l();let o=1/0,r=0,l=0;const h=i.length;let a=0,c=0;for(let u=0;u1?1:f}return 0}get flattenedSegments(){return this.bC(),this.ec}bC(){if(this.ec===null){const t=this.ec=[],i=this.au=[];this.YD(t,i)}}get flattenedLengths(){return this.bC(),this.au}get flattenedTotalLength(){let t=this.cu;if(isNaN(t)){if(this.type===1){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=Math.sqrt(i*i+e*e)}else if(this.type===2){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=i*2+e*2}else{const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=4&&(t.push(e),i.push(this.Xk(e))),e=[],e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY,h=r,a=l;break;case 2:e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY;break;case 3:Geo.Un(r,l,d.point1X,d.point1Y,d.point2X,d.point2Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 4:Geo.Bg(r,l,d.point1X,d.point1Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 5:{const m=d.Mo(o),g=m.length;if(g===0){e.push(d.centerX),e.push(d.centerY),r=d.centerX,l=d.centerY;break}for(let p=0;p=4&&(t.push(e),i.push(this.Xk(e)))}}}get type(){return this.$}set type(t){this.$!==t&&(this.h&&Util.T(this,t),this.$=t,t===4?this.Fs=new List:(Geometry.Sw===null&&(Geometry.Sw=new List().g()),this.Fs=Geometry.Sw),this.bt=!0)}get startX(){return this.xe}set startX(t){this.xe!==t&&(this.h&&Util.T(this,t),this.xe=t,this.bt=!0)}get startY(){return this.be}set startY(t){this.be!==t&&(this.h&&Util.T(this,t),this.be=t,this.bt=!0)}get endX(){return this.Qi}set endX(t){this.Qi!==t&&(this.h&&Util.T(this,t),this.Qi=t,this.bt=!0)}get endY(){return this._i}set endY(t){this._i!==t&&(this.h&&Util.T(this,t),this._i=t,this.bt=!0)}get figures(){return this.Fs}set figures(t){this.Fs!==t&&(this.h&&Util.T(this,t),this.Fs=t,this.bt=!0)}add(t){return this.Fs.add(t),this}setSpots(t,i,e,s,n,o,r,l){return this.h&&Util.T(this),this.zn=new Spot(t,i,n,o).g(),this.Xn=new Spot(e,s,r,l).g(),this}get spot1(){return this.zn}set spot1(t){this.h&&Util.T(this,t),this.zn=t.N()}get spot2(){return this.Xn}set spot2(t){this.h&&Util.T(this,t),this.Xn=t.N()}get defaultStretch(){return this.Kn}set defaultStretch(t){this.Kn=t}get bounds(){return this.Uk()&&this.Nw(),this.Gg}}Geometry.stringify=Geometry.stringify;Geometry.stringifyFixed=Geometry.stringifyFixed;Geometry.fillPath=Geometry.fillPath;Geometry.parse=Geometry.parse;class PathFigure{n;xe;be;oc;qg;Be;constructor(t,i,e,s,n){e===void 0&&(e=!0),s===void 0&&(s=!0),n===void 0&&(n=!1),this.n=2|(e?4:0)|(s?8:0)|(n?16:0),t!==void 0?this.xe=t:this.xe=0,i!==void 0?this.be=i:this.be=0,this.oc=new List,this.qg=this.oc.ht,this.Be=null}copy(){const t=new PathFigure;t.n=this.n&-2,t.xe=this.xe,t.be=this.be;const i=this.oc.r,e=i.length,s=t.oc;for(let n=0;no===0?"0":o.toFixed(t);i="M"+n(this.startX)+" "+n(this.startY)}const e=this.segments.r,s=e.length;for(let n=0;n(w[w.Move=1]="Move",w[w.Line=2]="Line",w[w.Bezier=3]="Bezier",w[w.QuadraticBezier=4]="QuadraticBezier",w[w.Arc=5]="Arc",w[w.SvgArc=6]="SvgArc",w))(SegmentType||{});class PathSegment{$;n;Qi;_i;hn;yl;wl;gr;Rs;constructor(t,i,e,s,n,o,r,l){if(GSet.Yi(this),t===void 0&&(t=2),this.$=t,this.n=2,i!==void 0?this.Qi=i:this.Qi=0,e!==void 0?this._i=e:this._i=0,s===void 0&&(s=0),n===void 0&&(n=0),o===void 0&&(o=0),r===void 0&&(r=0),t===6){let h=o;h=h%360,h<0&&(h+=360),this.hn=h,this.yl=0,this.wl=Math.max(s,0),this.gr=Math.max(n,0),typeof r=="boolean"?r&&(this.isLargeArc=!0):typeof r=="number"&&r&&(this.isLargeArc=!0),l&&(this.isClockwiseArc=!0)}else this.hn=s,this.yl=n,t===5&&(o=Math.max(o,0)),this.wl=o,typeof r=="number"?(t===5&&(r=Math.max(r,0)),this.gr=r):this.gr=0;this.Rs=null}copy(){const t=new PathSegment;return t.$=this.$,t.n=this.n&-2,t.Qi=this.Qi,t._i=this._i,t.hn=this.hn,t.yl=this.yl,t.wl=this.wl,t.gr=this.gr,t}equalsApprox(t){if(!(t instanceof PathSegment)||this.type!==t.type||this.isClosed!==t.isClosed)return!1;switch(this.type){case 1:case 2:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY);case 3:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.point1X,t.point1X)&&Geo.u(this.point1Y,t.point1Y)&&Geo.u(this.point2X,t.point2X)&&Geo.u(this.point2Y,t.point2Y);case 4:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.point1X,t.point1X)&&Geo.u(this.point1Y,t.point1Y);case 5:return Geo.u(this.startAngle,t.startAngle)&&Geo.u(this.sweepAngle,t.sweepAngle)&&Geo.u(this.centerX,t.centerX)&&Geo.u(this.centerY,t.centerY)&&Geo.u(this.radiusX,t.radiusX)&&Geo.u(this.radiusY,t.radiusY);case 6:return this.isClockwiseArc===t.isClockwiseArc&&this.isLargeArc===t.isLargeArc&&Geo.u(this.xAxisRotation,t.xAxisRotation)&&Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.radiusX,t.radiusX)&&Geo.u(this.radiusY,t.radiusY);default:return!1}}ri(t){t in SegmentType?this.type=t:Util.lr(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e="";switch(this.type){case 1:t<0?e="M"+this.endX.toString()+" "+this.endY.toString():e="M"+i(this.endX)+" "+i(this.endY);break;case 2:t<0?e="L"+this.endX.toString()+" "+this.endY.toString():e="L"+i(this.endX)+" "+i(this.endY);break;case 3:t<0?e="C"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.point2X.toString()+" "+this.point2Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="C"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.point2X)+" "+i(this.point2Y)+" "+i(this.endX)+" "+i(this.endY);break;case 4:t<0?e="Q"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="Q"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.endX)+" "+i(this.endY);break;case 5:t<0?e="B"+this.startAngle.toString()+" "+this.sweepAngle.toString()+" "+this.centerX.toString()+" "+this.centerY.toString()+" "+this.radiusX.toString()+" "+this.radiusY.toString():e="B"+i(this.startAngle)+" "+i(this.sweepAngle)+" "+i(this.centerX)+" "+i(this.centerY)+" "+i(this.radiusX)+" "+i(this.radiusY);break;case 6:t<0?e="A"+this.radiusX.toString()+" "+this.radiusY.toString()+" "+this.xAxisRotation.toString()+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+this.endX.toString()+" "+this.endY.toString():e="A"+i(this.radiusX)+" "+i(this.radiusY)+" "+i(this.xAxisRotation)+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+i(this.endX)+" "+i(this.endY);break;default:e=SegmentType[this.type]}return e+(this.isClosed?"z":"")}static Move=1;static Line=2;static Bezier=3;static QuadraticBezier=4;static Arc=5;static SvgArc=6;get h(){return(this.n&1)!==0}set h(t){t?this.n|=1:this.n&=-2}get bt(){return(this.n&2)!==0}set bt(t){t?this.n|=2:this.n&=-3}g(){return this.h=!0,this}ot(){return this.h=!1,this}close(){return this.isClosed=!0,this}Mo(t){if(this.Rs!==null&&t.bt===!1)return this.Rs;const i=this.radiusX;let e=this.radiusY;if(e===void 0&&(e=i),i===0||e===0)return this.Rs=[],this.Rs;const s=this.hn,n=this.yl,o=Geo.uC(0,0,i1&&(o*=Math.sqrt(p),r*=Math.sqrt(p));let y=(h===a?-1:1)*Math.sqrt((o*o*r*r-o*o*g*g-r*r*m*m)/(o*o*g*g+r*r*m*m));isNaN(y)&&(y=0);let x=y*o*g/r,k=y*-r*m/o;isNaN(x)&&(x=0),isNaN(k)&&(k=0);const b=(s+c)/2+u*x-d*k,P=(n+f)/2+d*x+u*k,S=(V,U)=>Math.sqrt(V*V+U*U),L=(V,U,Y,G)=>(V*Y+U*G)/(S(V,U)*S(Y,G)),C=(V,U,Y,G)=>(V*G=1&&(F=0),!a&&F>0&&(F=F-2*Math.PI),a&&F<0&&(F=F+2*Math.PI);const v=o>r?o:r,O=o>r?1:o/r,B=o>r?r/o:1,X=Geo.uC(0,0,v,M,M+F,!0),E=Transform.l();return E.Ri(),E.Ds(b,P),E.cs(this.hn,0,0),E.et(O,B),Geometry.yC(X,E),Transform.s(E),this.Rs=X,this.Rs}get isClosed(){return(this.n&8)!==0}set isClosed(t){this.isClosed!==t&&(t?this.n|=8:this.n&=-9,this.bt=!0)}get type(){return this.$}set type(t){this.h&&Util.T(this,t),this.$=t,this.bt=!0}get endX(){return this.Qi}set endX(t){this.h&&Util.T(this,t),this.Qi=t,this.bt=!0}get endY(){return this._i}set endY(t){this.h&&Util.T(this,t),this._i=t,this.bt=!0}get point1X(){return this.hn}set point1X(t){this.h&&Util.T(this,t),this.hn=t,this.bt=!0}get point1Y(){return this.yl}set point1Y(t){this.h&&Util.T(this,t),this.yl=t,this.bt=!0}get point2X(){return this.wl}set point2X(t){this.h&&Util.T(this,t),this.wl=t,this.bt=!0}get point2Y(){return this.gr}set point2Y(t){this.h&&Util.T(this,t),this.gr=t,this.bt=!0}get centerX(){return this.hn}set centerX(t){this.h&&Util.T(this,t),this.hn=t,this.bt=!0}get centerY(){return this.yl}set centerY(t){this.h&&Util.T(this,t),this.yl=t,this.bt=!0}get radiusX(){return this.wl}set radiusX(t){t<0&&Util._(t,">= zero",PathSegment,"radiusX"),this.h&&Util.T(this,t),this.wl=t,this.bt=!0}get radiusY(){return this.gr}set radiusY(t){t<0&&Util._(t,">= zero",PathSegment,"radiusY"),this.h&&Util.T(this,t),this.gr=t,this.bt=!0}get startAngle(){return this.Qi}set startAngle(t){this.h&&Util.T(this,t),t=t%360,t<0&&(t+=360),this.Qi=t,this.bt=!0}get sweepAngle(){return this._i}set sweepAngle(t){this.h&&Util.T(this,t),t>360&&(t=360),t<-360&&(t=-360),this._i=t,this.bt=!0}get isClockwiseArc(){return(this.n&4)!==0}set isClockwiseArc(t){this.h&&Util.T(this,t),t?this.n|=4:this.n&=-5,this.bt=!0}get isLargeArc(){return(this.n&16)!==0}set isLargeArc(t){this.h&&Util.T(this,t),t?this.n|=16:this.n&=-17,this.bt=!0}get xAxisRotation(){return this.hn}set xAxisRotation(t){this.h&&Util.T(this,t),t=t%360,t<0&&(t+=360),this.hn=t,this.bt=!0}}class InputEvent{p;Lw;Aw;Wg;Jg;$g;Zg;Qg;_g;tm;im;em;sm;nm;No;om;rm;lm;ke;constructor(){this.p=null,this.Lw=new Point(0,0).g(),this.Aw=new Point(0,0).g(),this.Wg=0,this.Jg=0,this.$g=1,this.Zg="",this.Qg="",this._g=!1,this.tm=!1,this.im=0,this.em=0,this.sm=!1,this.nm=!1,this.No=!1,this.om=null,this.rm=0,this.lm=null,this.ke=null}copy(){const t=new InputEvent;return this.clone(t)}clone(t){return t.p=this.p,t.Lw.a(this.viewPoint),t.Aw.a(this.documentPoint),t.Wg=this.Wg,t.Jg=this.Jg,t.$g=this.$g,t.Zg=this.Zg,t.Qg=this.Qg,t._g=this._g,t.tm=this.tm,t.im=this.im,t.em=this.em,t.sm=this.sm,t.nm=this.nm,t.No=this.No,t.om=this.om,t.rm=this.rm,t.lm=this.lm,t.ke=this.ke,t}toString(){let t="^";return this.modifiers!==0&&(t+="M:"+this.modifiers),this.button!==0&&(t+="B:"+this.button),this.key!==""&&(t+="K:"+this.key),this.clickCount!==0&&(t+="C:"+this.clickCount),this.delta!==0&&(t+="D:"+this.delta),this.handled&&(t+="h"),this.bubbles&&(t+="b"),this.documentPoint!==null&&(t+="@"+this.documentPoint.toString()),t}get diagram(){return this.p}set diagram(t){this.p=t}get viewPoint(){return this.Lw}set viewPoint(t){this.Lw.a(t)}get documentPoint(){return this.Aw}set documentPoint(t){this.Aw.a(t)}getMultiTouchViewPoint(t,i){const e=this.diagram;return e===null||e.kC(this.event,t,i),i}getMultiTouchDocumentPoint(t,i){const e=this.diagram;return e===null||(e.kC(this.event,t,i),i.a(e.transformViewToDoc(i))),i}get modifiers(){return this.Wg}set modifiers(t){this.Wg=t}get button(){return this.Jg}set button(t){if(this.Jg=t,this.event===null)switch(t){case 0:this.buttons=1;return;case 1:this.buttons=4;return;case 2:this.buttons=2;return}}get buttons(){return this.$g}set buttons(t){this.$g=t}get key(){return this.Zg}set key(t){this.Zg=t}get code(){return this.Qg}set code(t){this.Qg=t}get down(){return this._g}set down(t){this._g=t}get up(){return this.tm}set up(t){this.tm=t}get clickCount(){return this.im}set clickCount(t){this.im=t}get delta(){return this.em}set delta(t){this.em=t}get isMultiTouch(){return this.sm}set isMultiTouch(t){this.sm=t}get handled(){return this.nm}set handled(t){this.nm=t}get bubbles(){return this.No}set bubbles(t){this.No=t}get event(){return this.om}set event(t){this.om=t}get isTouchEvent(){const t=this.event;return t===null?!1:t.pointerType==="touch"||t.pointerType==="pen"}get timestamp(){return this.rm}set timestamp(t){this.rm=t}get targetDiagram(){return this.lm}set targetDiagram(t){this.lm=t}get targetObject(){return this.ke}set targetObject(t){this.ke=t}get control(){return(this.modifiers&1)!==0}set control(t){this.modifiers=t?this.modifiers|1:this.modifiers&-2}get shift(){return(this.modifiers&4)!==0}set shift(t){this.modifiers=t?this.modifiers|4:this.modifiers&-5}get alt(){return(this.modifiers&2)!==0}set alt(t){this.modifiers=t?this.modifiers|2:this.modifiers&-3}get meta(){return(this.modifiers&8)!==0}set meta(t){this.modifiers=t?this.modifiers|8:this.modifiers&-9}get left(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===0:(this.buttons&1)!==0}set left(t){t?this.buttons|=1:this.buttons&=-2}get right(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===2:(this.buttons&2)!==0}set right(t){t?this.buttons|=2:this.buttons&=-3}get middle(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===1:(this.buttons&4)!==0}set middle(t){t?this.buttons|=4:this.buttons&=-5}get commandKey(){const t=this.code,i=this.key;return"cxvyzagCXVYZAG".includes(i)?i.toLowerCase():t==="KeyC"?"c":t==="KeyX"?"x":t==="KeyV"?"v":t==="KeyY"?"y":t==="KeyZ"?"z":t==="KeyA"?"a":t==="KeyG"?"g":t!==""?t:i}}class DiagramEvent{p;Mt;hm;am;constructor(){this.p=null,this.Mt="",this.hm=null,this.am=null}copy(){const t=new DiagramEvent;return t.p=this.p,t.Mt=this.Mt,t.hm=this.hm,t.am=this.am,t}toString(){let t="*"+this.name;return this.subject!==null&&(t+=":"+this.subject.toString()),this.parameter!==null&&(t+="("+this.parameter.toString()+")"),t}get diagram(){return this.p}set diagram(t){this.p=t}get name(){return this.Mt}set name(t){this.Mt=t}get subject(){return this.hm}set subject(t){this.hm=t}get parameter(){return this.am}set parameter(t){this.am=t}}var ChangeType=(w=>(w[w.Transaction=1]="Transaction",w[w.Property=2]="Property",w[w.Insert=3]="Insert",w[w.Remove=4]="Remove",w))(ChangeType||{});class ChangedEvent{uu;cm;an;Si;p;du;rc;lc;hc;ac;constructor(){this.uu=2,this.cm="",this.an="",this.Si=null,this.p=null,this.du=null,this.rc=null,this.lc=null,this.hc=null,this.ac=null}static Transaction=1;static Property=2;static Insert=3;static Remove=4;clear(){this.Si=null,this.p=null,this.du=null,this.rc=null,this.lc=null,this.hc=null,this.ac=null}copy(){const t=new ChangedEvent;t.uu=this.uu,t.cm=this.cm,t.an=this.an,t.Si=this.Si,t.p=this.p,t.du=this.du;let i=this.rc;return Util.wt(i)&&typeof i.copyFrozen=="function"?t.rc=i.copyFrozen():t.rc=i,i=this.lc,Util.wt(i)&&typeof i.copyFrozen=="function"?t.lc=i.copyFrozen():t.lc=i,i=this.hc,Util.wt(i)&&typeof i.copyFrozen=="function"?t.hc=i.copyFrozen():t.hc=i,i=this.ac,Util.wt(i)&&typeof i.copyFrozen=="function"?t.ac=i.copyFrozen():t.ac=i,t}ri(t){t in ChangeType?this.change=t:Util.lr(this,t)}toString(){let t="";return this.change===1?t+="* ":this.change===2?t+=this.model!==null?"!m":"!d":t+=(this.model!==null?"!m":"!d")+this.change,this.propertyName&&typeof this.propertyName=="string"&&(t+=" "+this.propertyName),this.modelChange&&this.modelChange!==this.propertyName&&(t+=" "+this.modelChange),t+=": ",this.change===1?this.oldValue!==null&&(t+=" "+this.oldValue):(this.object!==null&&(t+=Util.toString(this.object)),this.oldValue!==null&&(t+=" old: "+Util.toString(this.oldValue)),this.oldParam!==null&&(t+=" "+this.oldParam),this.newValue!==null&&(t+=" new: "+Util.toString(this.newValue)),this.newParam!==null&&(t+=" "+this.newParam)),t}getValue(t){return t?this.oldValue:this.newValue}getParam(t){return t?this.oldParam:this.newParam}canUndo(){return this.model!==null||this.diagram!==null}undo(){this.canUndo()&&(this.model!==null?this.model.changeState(this,!0):this.diagram!==null&&this.diagram.PC(this,!0))}canRedo(){return this.model!==null||this.diagram!==null}redo(){this.canRedo()&&(this.model!==null?this.model.changeState(this,!1):this.diagram!==null&&this.diagram.PC(this,!1))}get model(){return this.Si}set model(t){this.Si=t}get diagram(){return this.p}set diagram(t){this.p=t}get change(){return this.uu}set change(t){this.uu=t}get modelChange(){return this.cm}set modelChange(t){this.cm=t}get propertyName(){return this.an}set propertyName(t){this.an=t}get isTransactionFinished(){return this.uu===1&&(this.an==="CommittedTransaction"||this.an==="FinishedUndo"||this.an==="FinishedRedo")}get object(){return this.du}set object(t){this.du=t}get oldValue(){return this.rc}set oldValue(t){this.rc=t}get oldParam(){return this.lc}set oldParam(t){this.lc=t}get newValue(){return this.hc}set newValue(t){this.hc=t}get newParam(){return this.ac}set newParam(t){this.ac=t}}class Transaction{SC;Mt;Kk;constructor(){this.SC=new List().g(),this.Mt="",this.Kk=!1}toString(t){let i="Transaction: "+this.name+" "+this.changes.count.toString()+(this.isComplete?"":", incomplete");if(t!==void 0&&t>0){const e=this.changes.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),t.g()}canUndo(){return this.isComplete}undo(){if(this.canUndo())for(let t=this.changes.count-1;t>=0;t--){const i=this.changes.elt(t);i!==null&&i.undo()}}canRedo(){return this.isComplete}redo(){if(!this.canRedo())return;const t=this.changes.count;for(let i=0;i=t;e--){const s=i.elt(e);s!==null&&s.undo(),i.ot(),i.removeAt(e)}i.g()}optimize(){if(!this.isComplete)return;const t=this.changes;t.ot();const i=new GMap;for(let s=0;s0&&t.setElt(r,null),o.set(n.propertyName,s))}let e=0;for(let s=0;se&&t.setElt(e,n),e++)}for(;t.length>e;)t.pop();t.g()}get changes(){return this.SC}get name(){return this.Mt}set name(t){this.Mt=t}get isComplete(){return this.Kk}set isComplete(t){this.Kk=t}}class UndoManager{Tw;Oi;MC;vs;Yk;fm;Yn;Gk;jk;cn;cc;Dw;Os;Fw;Rw;um;vw;constructor(t){this.Tw=new GSet,this.Oi=!1,this.MC=new List().g(),this.vs=-1,this.Yk=999,this.Os=!1,this.fm=null,this.Yn=0,this.Gk=!1,this.jk=23,this.cn=new List().g(),this.cc=new List,this.Dw=!0,this.Fw=!1,this.Rw=!1,this.um=!1,this.vw=!1,t&&Object.assign(this,t)}toString(t){let i="UndoManager "+this.historyIndex+"<"+this.history.count+"<="+this.maxHistoryLength;i+="[";let e=this.nestedTransactionNames.count;for(let s=0;s0&&(i+=" "),i+=this.nestedTransactionNames.elt(s);if(i+="]",t!==void 0&&t>0){e=this.history.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),this.vs=-1,t.g(),this.Os=!1,this.fm=null,this.Yn=0,this.cn.ot(),this.cn.clear(),this.cn.g(),this.cc.clear(),this.Fw=!1,this.Rw=!1,this.um=!1,this.vw=!1}copyProperties(t){this.isEnabled=t.isEnabled,this.maxHistoryLength=t.maxHistoryLength,this.dm=t.dm}addModel(t){this.Tw.add(t)}removeModel(t){this.Tw.delete(t)}startTransaction(t){if(t===void 0&&(t=""),t===null&&(t=""),this.isUndoingRedoing)return!1;this.Dw===!0&&(this.Dw=!1,this.Yn++,this.xl||this.t("StartingFirstTransaction",t,this.currentTransaction),this.Yn>0&&this.Yn--),this.isEnabled&&(this.cn.ot(),this.cn.add(t),this.cn.g(),this.currentTransaction===null?this.cc.add(0):this.cc.add(this.currentTransaction.changes.count)),this.Yn++;const i=this.transactionLevel===1;return i&&(this.xl||this.t("StartedTransaction",t,this.currentTransaction)),i}commitTransaction(t){return t===void 0&&(t=""),this.NC(!0,t)}rollbackTransaction(){return this.NC(!1,"")}NC(t,i){if(this.isUndoingRedoing)return!1;this.dm&&this.transactionLevel<1&&Util.ii("Ending transaction without having started a transaction: "+i);const e=this.transactionLevel===1;let s=this.currentTransaction;e&&t&&(this.xl||this.t("CommittingTransaction",i,s));let n=0;if(this.transactionLevel>0&&(this.Yn--,this.isEnabled)){const o=this.cn.count;o>0&&(i===""&&(i=this.cn.elt(0)),this.cn.ot(),this.cn.removeAt(o-1),this.cn.g());const r=this.cc.count;r>0&&(n=this.cc.elt(r-1),this.cc.removeAt(r-1))}if(e){if(t){if(this.um=!1,s===null&&i!==""&&(s=this.currentTransaction),this.isEnabled&&s!==null){const o=s;o.isComplete||(o.isComplete=!0,o.name=i),this.discardHistoryAfterIndex();const r=this.history;r.ot();const l=this.maxHistoryLength;if(l>=0){if(l===0)r.clear();else if(r.count>=l){const h=r.elt(0);h!==null&&h.clear(),r.removeAt(0),this.vs--}}l!==0&&(r.count===0||r.get(r.count-1)!==o)&&(r.add(o),this.vs++),r.g(),s=o}this.xl||this.t("CommittedTransaction",i,s)}else{this.Os=!0;try{this.isEnabled&&s!==null&&(s.isComplete=!0,s.undo())}finally{this.xl||this.t("RolledBackTransaction",i,s),this.Os=!1}s!==null&&s.clear()}return this.fm=null,this.Ow&&this.clear(),this.Ow=!1,this.Iw=!1,!0}else return this.isEnabled&&!t&&s!==null&&s.GD(n),!1}discardHistoryAfterIndex(){if(this.isUndoingRedoing||!this.canRedo())return;const t=this.history;t.ot();for(let i=t.count-1;i>this.historyIndex;i--){const e=t.elt(i);e!==null&&e.clear(),t.removeAt(i),this.um=!0}t.g()}nE(t){this.Yn+=t,this.Yn<0&&(this.Yn=0)}canUndo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToUndo;return!!(t!==null&&t.canUndo())}undo(){if(!this.canUndo())return;const t=this.transactionToUndo;try{this.Os=!0,this.t("StartingUndo","Undo",t),this.vs--,t.undo()}catch(i){Util.ii("undo error: "+i.toString())}finally{this.t("FinishedUndo","Undo",t),this.Os=!1}}canRedo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToRedo;return!!(t!==null&&t.canRedo())}redo(){if(!this.canRedo())return;const t=this.transactionToRedo;try{this.Os=!0,this.t("StartingRedo","Redo",t),this.vs++,t.redo()}catch(i){Util.ii("redo error: "+i.toString())}finally{this.t("FinishedRedo","Redo",t),this.Os=!1}}t(t,i,e){e===void 0&&(e=null);const s=new ChangedEvent;s.change=1,s.propertyName=t,s.object=e,s.oldValue=i;const n=this.models;for(;n.next();){const o=n.value;s.model=o,o.Ew(s)}}handleChanged(t){if(this.isEnabled&&!this.isUndoingRedoing&&!this.skipsEvent(t)){let i=this.currentTransaction;i===null&&(i=new Transaction,this.fm=i);const e=t.copy(),s=i.changes;if(s.ot(),s.add(e),s.g(),this.dm&&this.jk>0&&this.transactionLevel<=0&&!this.Dw){const n=t.diagram;if(n!==null&&n.Bh===!1)return;Util.ii("Change not within a transaction: "+e.toString()),this.jk--}}}skipsEvent(t){if(t===null||t.change===1)return!0;const i=t.object;if(i===null)return!1;if(i.layer!==void 0){const e=i.layer;if(e!==null&&e.isTemporary)return!0}else if(i.isTemporary)return!0;return!1}get models(){return this.Tw.iterator}get isEnabled(){return this.Oi}set isEnabled(t){this.Oi=t}get transactionToUndo(){return this.historyIndex>=0&&this.historyIndex<=this.history.count-1?this.history.elt(this.historyIndex):null}get transactionToRedo(){return this.historyIndex0}get dm(){return this.Gk}set dm(t){this.Gk=t}get nestedTransactionNames(){return this.cn}get Ow(){return this.Fw}set Ow(t){this.Fw=t}get Iw(){return this.Rw}set Iw(t){this.Rw=t}get xl(){return this.vw}set xl(t){this.vw=t}get isJustDiscarded(){return this.um}}class Tool{p;Mt;Oi;Hk;qk;gm;CC;constructor(){GSet.Yi(this),this.p=Diagram.mm(),this.Mt="",this.Oi=!0,this.Hk=!1,this.qk=null,this.CC=new InputEvent,this.gm=-1}get diagram(){return this.p}set diagram(t){t instanceof Diagram&&(this.p=t)}toString(){return this.name!==""?this.name+" Tool":Util.sn(this.constructor)}updateAdornments(t){}canStart(){return this.isEnabled}doStart(){}doActivate(){this.isActive=!0}doDeactivate(){this.isActive=!1}doStop(){}doCancel(){this.transactionResult=null,this.stopTool()}stopTool(){const t=this.diagram;t.currentTool===this&&(t.currentTool=null,t.currentCursor="")}doMouseDown(){!this.isActive&&this.canStart()&&this.doActivate()}doMouseMove(){}doMouseUp(){this.stopTool()}doMouseWheel(){}canStartMultiTouch(){return!0}standardPinchZoomStart(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.X(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.X(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.s(e),Point.s(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){t.Wk=t.scale;const n=s.x-e.x,o=s.y-e.y,r=Math.sqrt(n*n+o*o);t.Jk=r,i.bubbles=!1}Point.s(e),Point.s(s)}standardPinchZoomMove(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.X(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.X(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.s(e),Point.s(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){const n=s.x-e.x,o=s.y-e.y,l=Math.sqrt(n*n+o*o)/t.Jk,h=new Point((Math.min(s.x,e.x)+Math.max(s.x,e.x))/2,(Math.min(s.y,e.y)+Math.max(s.y,e.y))/2),a=t.Wk*l,c=t.commandHandler;if(a!==t.scale&&c.canResetZoom(a)){const f=t.zoomPoint;t.zoomPoint=h,c.resetZoom(a),t.zoomPoint=f}i.bubbles=!1}Point.s(e),Point.s(s)}doKeyDown(){this.diagram.lastInput.code==="Escape"&&this.doCancel()}doKeyUp(){}startTransaction(t){return t===void 0&&(t=this.name),this.transactionResult=null,this.diagram.startTransaction(t)}stopTransaction(){const t=this.diagram;return this.transactionResult===null?t.rollbackTransaction():t.commitTransaction(this.transactionResult)}standardMouseSelect(){const t=this.diagram;if(!t.allowSelect)return;const i=t.lastInput,e=t.findPartAt(i.documentPoint,!1);if(e!==null){if(Util.rr?i.meta:i.control){t.v("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!s.isSelected),t.v("ChangedSelection",t.selection)}else if(i.shift){if(!e.isSelected){t.v("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!0),t.v("ChangedSelection",t.selection)}}else if(!e.isSelected){let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&t.select(s)}}else i.left&&!(Util.rr?i.meta:i.control)&&!i.shift&&t.clearSelection()}standardMouseClick(t,i){t===void 0&&(t=null),i===void 0&&(i=o=>!o.layer.isTemporary);const e=this.diagram,s=e.lastInput,n=e.findObjectAt(s.documentPoint,t,i);return s.targetObject=n,this.jD(n,s,e),s.handled}jD(t,i,e){if(i.handled=!1,t!==null&&!t.isEnabledObject())return;let s=0;i.left?i.clickCount===1?s=1:i.clickCount===2?s=2:s=1:i.right&&i.clickCount===1&&(s=3);let n="ObjectSingleClicked";if(t!==null){switch(s){case 1:n="ObjectSingleClicked";break;case 2:n="ObjectDoubleClicked";break;case 3:n="ObjectContextClicked";break}s!==0&&e.v(n,t)}else{switch(s){case 1:n="BackgroundSingleClicked";break;case 2:n="BackgroundDoubleClicked";break;case 3:n="BackgroundContextClicked";break}s!==0&&e.v(n)}if(t!==null)for(;t!==null;){let o=null;switch(s){case 1:o=t.click;break;case 2:o=t.doubleClick?t.doubleClick:t.click;break;case 3:o=t.contextClick;break}if(o!==null&&(o(i,t),i.handled))break;t=t.panel}else{let o=null;switch(s){case 1:o=e.click;break;case 2:o=e.doubleClick?e.doubleClick:e.click;break;case 3:o=e.contextClick;break}o!==null&&o(i)}}standardMouseOver(){const t=this.diagram,i=t.lastInput;if(t.animationManager.wi===!0)return;const e=t.skipsUndoManager;t.skipsUndoManager=!0;let s=t.viewportBounds.containsPoint(i.documentPoint)?t.findObjectAt(i.documentPoint,null,null):null;i.event&&(i.event.type==="pointercancel"||i.event.type==="pointerout")&&(s=null),i.targetObject=s;let n=!1;if(s!==t.fc){let o=t.fc;const r=o;for(t.fc=s,this.doCurrentObjectChanged(o,s),i.handled=!1;o!==null;){const l=o.mouseLeave;if(l!==null&&(s===o||s!==null&&s.isContainedBy(o)||(l(i,o,s),n=!0,i.handled)))break;o=o.panel}for(o=r,i.handled=!1;s!==null;){const l=s.mouseEnter;if(l!==null&&(o===s||o!==null&&o.isContainedBy(s)||(l(i,s,o),n=!0,i.handled)))break;s=s.panel}s=t.fc}if(s!==null){let o=s,r="";for(;o!==null&&(r=o.cursor,r==="");)o=o.panel;for(t.currentCursor=r,i.handled=!1,o=s;o!==null;){const l=o.mouseOver;if(l!==null&&(l(i,o),n=!0,i.handled))break;o=o.panel}}else{this.doUpdateCursor(null);const o=t.mouseOver;o!==null&&(o(i),n=!0)}n&&t.requestUpdate(),t.skipsUndoManager=e}doUpdateCursor(t){const i=this.diagram;i&&(i.currentCursor="")}doCurrentObjectChanged(t,i){}standardMouseWheel(){const t=this.diagram,i=t.lastInput;let e=i.delta;if(e===0||!t.documentBounds.isReal())return;const s=t.commandHandler,n=t.toolManager.mouseWheelBehavior;if(s!==null&&(n===2&&!i.shift||n===1&&i.control)){if(e>0?s.canIncreaseZoom():s.canDecreaseZoom()){const o=t.zoomPoint;t.zoomPoint=i.viewPoint,e>0?s.increaseZoom():s.decreaseZoom(),t.zoomPoint=o}i.bubbles=!1}else if(n===2&&i.shift||n===1&&!i.control){const o=t.position.copy(),r=i.event,l=r.deltaMode;let h=r.deltaX,a=r.deltaY,c="pixel";if((h!==0||a!==0)&&!i.shift){switch(l){case 0:c="pixel";break;case 1:c="line";break;case 2:c="page";break}if(h!==0&&t.allowHorizontalScroll){const f=t.scrollHorizontalLineChange;h=h*(f/16),t.scroll(c,h>0?"right":"left",Math.abs(h))}if(a!==0&&t.allowVerticalScroll){const f=t.scrollVerticalLineChange;a=a*(f/16),t.scroll(c,a>0?"down":"up",Math.abs(a))}}else!i.shift&&t.allowVerticalScroll?(e=e*3*t.scrollVerticalLineChange,t.scroll(c,e>0?"up":"down",Math.abs(e))):i.shift&&t.allowHorizontalScroll&&(e=e*3*t.scrollHorizontalLineChange,t.scroll(c,e>0?"left":"right",Math.abs(e)));this.doWheelChange(t,o,i)}}doWheelChange(t,i,e){(!t.position.equals(i)||e.event.wheelDeltaX!==0)&&(e.bubbles=!1)}standardWaitAfter(t,i){i===void 0&&(i=this.diagram.lastInput),this.cancelWaitAfter();const e=this,s=i.clone(this.CC);this.gm=Util.Oh(()=>e.doWaitAfter(s),t)}cancelWaitAfter(){this.gm!==-1&&Util.Og(this.gm),this.gm=-1}doWaitAfter(t){}findToolHandleAt(t,i){const s=this.diagram.findObjectAt(t,n=>{for(;n!==null&&!(n.panel instanceof Adornment);)n=n.panel;return n});return s===null?null:s.part.category===i?s:null}isBeyondDragSize(t,i){const e=this.diagram;t===void 0&&(t=e.firstInput.viewPoint),i===void 0&&(i=e.lastInput.viewPoint);const s=e.toolManager.dragSize;let n=s.width,o=s.height;return e.firstInput.isTouchEvent&&(n+=6,o+=6),Math.abs(i.x-t.x)>n||Math.abs(i.y-t.y)>o}get name(){return this.Mt}set name(t){Util.i(t,"string",Tool,"name"),this.Mt=t}get isEnabled(){return this.Oi}set isEnabled(t){Util.i(t,"boolean",Tool,"isEnabled"),this.Oi=t}get isActive(){return this.Hk}set isActive(t){Util.i(t,"boolean",Tool,"isActive"),this.Hk=t}get transactionResult(){return this.qk}set transactionResult(t){t!==null&&Util.i(t,"string",Tool,"transactionResult"),this.qk=t}}var WheelMode=(w=>(w[w.Scroll=1]="Scroll",w[w.Zoom=2]="Zoom",w[w.None=3]="None",w))(WheelMode||{}),GestureMode=(w=>(w[w.Zoom=1]="Zoom",w[w.Cancel=2]="Cancel",w[w.None=3]="None",w))(GestureMode||{});class ToolManager extends Tool{LC;AC;TC;$k;Zk;Qk;_k;tP;iP;eP;pm;Uh;constructor(t){super(),this.name="ToolManager",this.LC=new List,this.AC=new List,this.TC=new List,this.$k=850,this.Zk=850,this.Qk=new Size(2,2).it(),this._k=5e3,this.tP=1,this.iP=1,this.eP=null,this.pm=null,this.Uh=-1,t&&Object.assign(this,t)}static WheelScroll=1;static WheelZoom=2;static WheelNone=3;static GestureZoom=1;static GestureCancel=2;static GestureNone=3;get mouseWheelBehavior(){return this.tP}set mouseWheelBehavior(t){this.tP=t}get gestureBehavior(){return this.iP}set gestureBehavior(t){this.iP=t}initializeStandardTools(){}updateAdornments(t){const i=this.currentToolTip;if(i instanceof Adornment&&this.pm===t){const e=i.adornedObject;(t!==null?e.part===t:e===null)?this.showToolTip(i,e):this.hideToolTip()}}doMouseDown(){const t=this.diagram,i=t.lastInput;if(i.isTouchEvent&&this.gestureBehavior===2&&(i.bubbles=!1),i.isMultiTouch){if(this.cancelWaitAfter(),this.gestureBehavior===3){i.bubbles=!0;return}if(this.gestureBehavior===2)return;if(t.currentTool.canStartMultiTouch()){t.currentTool.standardPinchZoomStart();return}}const e=t.undoManager,s=this.mouseDownTools.length;for(let n=0;n0&&s!==1/0){const n=this;this.Uh=Util.Oh(()=>n.hideToolTip(),s)}}positionToolTip(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom?n.y-=o.height+5/s.scale:n.y+=20/s.scale,n.y30&&t.Uw(),t.Vw(this.draggedParts),t.pu=!0,this.startTransaction("Drag"),this.startPoint=t.firstInput.documentPoint,t.isMouseCaptured=!0,t.allowDragOut&&this.qD()}mP(t){if(this.dragsLink){const i=this.diagram;if(!i.allowRelink)return;i.model.gc()&&t.count===1&&t.first()instanceof Link?(this.draggedLink=t.first(),this.draggedLink.canRelinkFrom()&&this.draggedLink.canRelinkTo()&&this.draggedLink.clearAdornments(),this.fn=i.toolManager.findTool("Relinking"),this.fn===null&&(this.fn=new RelinkingTool,this.fn.diagram=i),this.fn.originalLink=this.draggedLink):(this.draggedLink=null,this.fn=null)}}computeEffectiveCollection(t,i){return this.diagram.commandHandler.computeEffectiveCollection(t,i)}Is(t){return t===void 0?new DraggingInfo(Point.Po):this.isGridSnapEnabled?new DraggingInfo(new Point(Math.round(t.x*1e3)/1e3,Math.round(t.y*1e3)/1e3)):new DraggingInfo(t.copy())}doDeactivate(){this.isActive=!1;const t=this.diagram;this.diagram.layout.isRealtime=this.gP,t.pu=!1,t.bl=!0,t.cacheGroupExternalLinks(!1),t.stopAutoScroll(),this.pP(),t.wm(this.draggedParts),this.mu=null,this.currentPart=null,this.draggedParts=null,this.isDragOutStarted=!1,this.gu=!1,DraggingTool.WD(),this.FC(),this.uc.e(NaN,NaN),DraggingTool.zh!==null&&(DraggingTool.zh.currentCursor=""),DraggingTool.zh=null,DraggingTool.yt=null,this.kl(),t.isMouseCaptured=!1,t.currentCursor="",t.dc=!1,this.stopTransaction(),t.yP(!0)}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}pP(){const t=this.diagram,i=t.skipsUndoManager;t.skipsUndoManager=!0;const e=t.lastInput;this.RC(e,null),t.skipsUndoManager=i,this.mr.length=0}vC(){this.kl(),this.wP();const t=this.diagram;this.uc.isReal()&&(t.position=this.uc),t.stopAutoScroll()}doCancel(){this.kl(),this.wP();const t=this.diagram;this.uc.isReal()&&(t.position=this.uc),this.stopTool()}doKeyDown(){const t=this.diagram,i=t.lastInput;this.isActive&&(i.code==="Escape"?this.doCancel():i.code!==t.previousInput.code&&this.doMouseMove())}doKeyUp(){this.isActive&&this.doMouseMove()}JD(t,i){let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=t.iterator;for(;r.next();){const l=r.value;if(!l.isVisible())continue;const h=l.location,a=h.x,c=h.y;isNaN(a)||isNaN(c)||(an&&(n=a),c>o&&(o=c))}return e===1/0?i.e(0,0,0,0):i.e(e,s,n-e,o-s),i}xP(t){if(this.copiedParts!==null)return;const i=this.diagram;if(t&&(i.isReadOnly||i.isModelReadOnly)||this.draggedParts===null)return;const e=i.undoManager;e.isEnabled&&e.isInTransaction?e.currentTransaction!==null&&e.currentTransaction.changes.count>0&&(i.undoManager.rollbackTransaction(),i.startTransaction("Drag")):this.wP(),i.skipsUndoManager=!t,i.partManager.addsToTemporaryLayer=!t,this.startPoint=i.firstInput.documentPoint;const s=this.copiesEffectiveCollection?this.draggedParts.toKeySet():i.selection,n=i.copyParts(s,i,!0),o=new GMap,r=this.draggedParts.iterator;for(;r.next();){const h=r.key;if(h.Pe()&&h.canCopy()){const a=n.get(h);if(a===null)continue;a.location=h.location,a.ensureBounds(),o.set(a,this.Is(a.location))}}const l=n.iterator;for(;l.next();){const h=l.value;h instanceof Link&&h.canCopy()&&o.set(h,this.Is())}if(this.copiedParts=o,this.mP(o.toKeySet()),this.draggedLink!==null){const h=this.draggedLink,a=h.routeBounds;h.pr(this.startPoint.x-(a.x+a.width/2),this.startPoint.y-(a.y+a.height/2))}this.doUpdateCursor(null)}kl(){const t=this.diagram;if(this.copiedParts!==null){if(t.removeParts(this.copiedParts.toKeySet(),!1),this.copiedParts=null,this.draggedParts!==null){const i=this.draggedParts.iterator;for(;i.next();)if(i.key instanceof Link){const s=i.value;s.point=new Point(0,0)}}this.doUpdateCursor(null)}t.skipsUndoManager=!1,t.partManager.addsToTemporaryLayer=!1,this.startPoint=t.firstInput.documentPoint}FC(){this.draggedLink!==null&&(this.dragsLink&&this.fn!==null&&(this.fn.stopDraggingMouseMove(),this.fn.originalLink=null),this.draggedLink=null,this.fn=null)}mc(t,i){const e=this.diagram,s=this.startPoint,n=Point.l();n.a(e.lastInput.documentPoint),this.moveParts(t,n.subtract(s),i),Point.s(n),e.getRenderingHint("temporaryPixelRatio")===!0&&e.Pl===null&&e.avgSpf>30&&(e.Uw(),e.yu())}moveParts(t,i,e){e===void 0&&(e=!1);const s=this.diagram;s!==null&&s.bP(t,i,this.dragOptions,e)}wP(){if(this.draggedParts===null)return;const t=this.diagram;let i=this.draggedParts.iterator;for(;i.next();){const e=i.key;e.Pe()&&(e.location=i.value.point)}for(i=this.draggedParts.iterator;i.next();){const e=i.key;if(e instanceof Link&&e.suspendsRouting){const s=i.value.point;this.draggedParts.set(e,this.Is()),e.pr(-s.x,-s.y)}}t.maybeUpdate()}$D(t){if(t===null)return!0;const i=t.part;return!!(i===null||i instanceof Adornment||i.layer.isTemporary||this.draggedParts&&this.draggedParts.has(i)||this.copiedParts&&this.copiedParts.has(i))}kP(t){const i=this.diagram;this.dragsLink&&(this.draggedLink!==null&&(this.draggedLink.fromNode=null,this.draggedLink.toNode=null),this.OC(!1));const e=this.findDragOverObject(t),s=i.lastInput;s.targetObject=e,this.doUpdateCursor(e);const n=i.skipsUndoManager;let o=!1;try{if(i.skipsUndoManager=!0,o=this.RC(s,e),!this.isActive&&DraggingTool.yt===null)return;const r=e!==null?e.part:null;if(r===null||i.handlesDragDropForTopLevelParts&&r.isTopLevel&&!(r instanceof Group)){const l=i.mouseDragOver;l!==null&&(l(s),o=!0)}if(!this.isActive&&DraggingTool.yt===null||(this.doDragOver(t,e),!this.isActive&&DraggingTool.yt===null))return}finally{i.skipsUndoManager=n,o&&i.maybeUpdate()}this.mu=e,!i.isReadOnly&&(i.allowMove||i.allowCopy)&&(i.allowHorizontalScroll||i.allowVerticalScroll)&&i.doAutoScroll(s.viewPoint)}findDragOverObject(t){return this.diagram.PP(t,null,i=>!this.$D(i))}doUpdateCursor(t){const i=this.diagram;(t===null||this.mu!==t)&&(!this.diagram.currentTool.isActive||this.mayCopy()?i.currentCursor=this.copyCursor:this.mayMove()?i.currentCursor=this.moveCursor:this.mayDragOut()&&(i.currentCursor=this.nodropCursor))}RC(t,i){let e=!1,s=this.mr.length;const n=s>0?this.mr[0]:null;if(i===n)return!1;t.handled=!1;for(let r=0;rs.findValidLinkablePort(a,i)),r=Point.l();let l=1/0,h=null;for(const a=o.iterator;a.next();){const c=a.value;if(c.part===null)continue;const u=c.getDocumentPoint(Spot.Center,r),d=t.distanceSquaredPoint(u);dh.suspendsRouting=!1)}if(this.doDropOnto(t,e),!this.isActive&&DraggingTool.yt===null)return;const o=Rect.l(),r=i.selection.iterator;for(;r.next();){const l=r.value;l instanceof Node&&this.QD(i,l,o)}Rect.s(o)}ZD(t,i){const e=this.diagram,s=i.part;if(e.handlesDragDropForTopLevelParts&&s.isTopLevel&&!(s instanceof Group)){const n=e.mouseDrop;n!==null&&n(t)}}QD(t,i,e){if(!i.canAvoid())return;let s=!1;e=i.getAvoidableRect(e),t.viewportBounds.containsRect(e)&&(s=!0);const n=this.copiedParts||this.draggedParts,o=t.NP(e,l=>l.part,l=>l instanceof Link,!0,l=>l instanceof Link,s);if(o.count===0)return;const r=o.iterator;for(;r.next();){const l=r.value;n.has(l)&&n.has(i)||!l.isMemberOf(i)&&l.isAvoiding&&l.invalidateRoute()}}doDropOnto(t,i){}doMouseMove(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseMove(i.event,i.documentPoint,i.targetDiagram))return;this.currentPart!==null&&this.draggedParts!==null&&(this.mayCopy()?(this.xP(!1),t.Vw(this.copiedParts),this.mc(this.copiedParts,!1),t.wm(this.copiedParts)):this.mayMove()?(this.kl(),this.mc(this.draggedParts,!0)):this.mayDragOut()?(this.xP(!1),this.mc(this.copiedParts,!1)):this.kl(),this.kP(t.lastInput.documentPoint))}doMouseUp(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseUp(i.event,i.documentPoint,i.targetDiagram))return;let e=!1;const s=this.mayCopy();if(s&&this.copiedParts!==null?(this.kl(),this.xP(!0),t.Vw(this.copiedParts),this.mc(this.copiedParts,!1),t.wm(this.copiedParts),this.copiedParts!==null&&(t.v("ChangingSelection",t.selection),t.clearSelection(!0),this.copiedParts.iteratorKeys.each(n=>{n.isSelected=!0}))):(e=!0,this.kl(),this.mayMove()&&(this.mc(this.draggedParts,!0),this.kP(t.lastInput.documentPoint))),this.gu=!0,this.BC(t.lastInput.documentPoint),this.isActive){const n=s?this.copiedParts.toKeySet():this.draggedParts.toKeySet();this.copiedParts=null,e&&this._D(),t.invalidateDocumentBounds(),t.wm(this.draggedParts),this.transactionResult=s?"Copy":"Move",t.v(s?"SelectionCopied":"SelectionMoved",n)}this.stopTool(),s&&t.v("ChangedSelection",t.selection)}simulatedMouseMove(t,i,e){if(DraggingTool.yt===null)return!1;const s=DraggingTool.yt.diagram;e instanceof Diagram||(e=null);const n=DraggingTool.zh;if(e!==n){if(n!==null&&n!==s){n.stopAutoScroll(),DraggingTool.yt.isDragOutStarted=!1;const r=n.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDragLeave()}if(DraggingTool.zh=e,e!==null&&e!==s){DraggingTool.yt.vC();const r=e.toolManager.findTool("Dragging");r!==null&&(r.UC(),r.doSimulatedDragEnter())}this.doUpdateCursor(null)}if(e===null||e===s||!e.allowDrop||e.isReadOnly||!e.allowInsert)return!1;const o=e.toolManager.findTool("Dragging");if(o!==null){let r=i;t!==null&&(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),r=e.getMouse(t)),e.lastInput.documentPoint=r,e.lastInput.viewPoint=e.transformDocToView(r),e.lastInput.down=!1,e.lastInput.up=!1,o.doSimulatedDragOver()}return!0}simulatedMouseUp(t,i,e){if(DraggingTool.yt===null)return!1;const s=DraggingTool.zh,n=DraggingTool.yt.diagram;if(e===null)return DraggingTool.yt.doCancel(),!0;if(e!==s){const o=s.toolManager.findTool("Dragging");if(s!==null&&s!==n&&o!==null)return s.stopAutoScroll(),DraggingTool.yt.isDragOutStarted=!1,o.doSimulatedDragLeave(),!1;DraggingTool.zh=e;const r=e.toolManager.findTool("Dragging");r!==null&&(DraggingTool.yt.vC(),r.UC(),r.doSimulatedDragEnter())}if(e!==this.diagram){let o=i;t!==null?(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),o=e.getMouse(t)):o===null&&(o=new Point),e.lastInput.documentPoint=o,e.lastInput.viewPoint=e.transformDocToView(o),e.lastInput.down=!1,e.lastInput.up=!0;const r=e.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDrop();const l=DraggingTool.yt;if(l!==null){const h=l.mayCopy();l.transactionResult=h?"Copy":"Move",l.stopTool()}return!0}return!1}_D(){if(this.draggedParts===null)return;const t=this.draggedParts.iterator;for(;t.next();){const i=t.key;if(i instanceof Node){const e=i.containingGroup;e!==null&&e.hasPlaceholder()&&!this.draggedParts.has(e)&&e.placeholder.c()}}}mayCopy(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowCopy||!(Util.rr?t.lastInput.alt:t.lastInput.control))return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayDragOut(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(!t.allowDragOut||!t.allowCopy||t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayMove(){const t=this.diagram;if(t.isReadOnly||!t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canMove())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canMove())}UC(){DraggingTool.zw.has(this)||DraggingTool.zw.add(this)}static WD(){if(DraggingTool.zw.count>0){const t=DraggingTool.zw,i=t.length;for(let e=0;e{n.isSelected=!0,s.add(n)})),this.BC(t.lastInput.documentPoint),t.invalidateDocumentBounds(),this.copiedParts!==null&&(this.transactionResult="ExternalCopy"),this.copiedParts=null,t.doFocus(),t.dc=!1,t.v("ExternalObjectsDropped",s,e),this.stopTransaction(),t.v("ChangedSelection",t.selection)}t.animationManager.wu=!1}VC(t,i,e){if(this.copiedParts!==null)return;const s=this.diagram;if(s.isReadOnly||s.isModelReadOnly)return;s.skipsUndoManager=!i,s.partManager.addsToTemporaryLayer=!i,this.startPoint=e.documentPoint;const n=s.copyParts(t,s,!0),o=Rect.l();this.JD(t,o);const r=o.x+o.width/2,l=o.y+o.height/2;Rect.s(o);const h=this.ym,a=new GMap,c=Point.l(),f=t.iterator;for(;f.next();){const d=f.value;if(d instanceof Link&&d.canCopy()){const m=n.get(d);if(m===null)continue;m.points=d.points,m.pr(h.x-r,h.y-l),m.suspendsRouting=!0,a.set(m,this.Is())}}const u=t.iterator;for(;u.next();){const d=u.value;if(d.Pe()&&d.canCopy()){const m=n.get(d);if(m===null)continue;const g=d.location;c.e(h.x-(r-g.x),h.y-(l-g.y)),m.location=c,m.ensureBounds(),a.set(m,this.Is(c))}}if(Point.s(c),this.copiedParts=a,this.mP(a.toKeySet()),this.draggedLink!==null){const d=this.draggedLink,m=d.routeBounds;d.pr(this.startPoint.x-(m.x+m.width/2),this.startPoint.y-(m.y+m.height/2))}this.doUpdateCursor(null)}qD(){this.isDragOutStarted=!0,this.gu=!1,DraggingTool.yt=this,DraggingTool.zh=this.diagram,this.doSimulatedDragOut()}doSimulatedDragOut(){const t=this.diagram;t.dc=!1,!this.mayCopy()&&!this.mayMove()?t.currentCursor=this.nodropCursor:t.currentCursor="",this.mu=null}computeMove(t,i,e,s){const n=this.diagram;return n!==null?n.computeMove(t,i,this.dragOptions,s):new Point}static zw=new List;static yt=null;static zh=null}ToolManager.prototype.doCancel=function(){DraggingTool.yt!==null&&DraggingTool.yt.doCancel(),Tool.prototype.doCancel.call(this)};class LinkingBaseTool extends Tool{CP;LP;Sl;AP;TP;Xh;DP;Kh;FP;RP;vP;OP;IP;EP;zC;BP;Ml;UP;constructor(){super(),this.CP=100,this.LP=!1,this.Sl="pointer",this.AP=new Link({layerName:"Tool"}).add(new Shape({isPanelMain:!0,stroke:"blue"}).theme("stroke","tempLink"),new Shape({toArrow:"Standard",fill:"blue",stroke:"blue"}).theme("fill","tempLink").theme("stroke","tempLink")).li(),this.Xh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.Dk}).theme("stroke","tempPort"),this.TP=new Node({selectable:!1,layerName:"Tool"}).add(this.Xh).li(),this.Kh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.Dk}).theme("stroke","tempPort"),this.DP=new Node({selectable:!1,layerName:"Tool"}).add(this.Kh).li(),this.FP=null,this.RP=null,this.vP=null,this.OP=null,this.IP=null,this.EP=!0,this.zC=new GMap,this.BP=null,this.Ml=null,this.UP=null}doStop(){this.diagram.stopAutoScroll(),this.originalLink=null,this.originalFromNode=null,this.originalFromPort=null,this.originalToNode=null,this.originalToPort=null,this.validPortsCache.clear(),this.targetPort=null}get portGravity(){return this.CP}set portGravity(t){Util.i(t,"number",LinkingBaseTool,"portGravity"),t>=0&&(this.CP=t)}get isUnconnectedLinkValid(){return this.LP}set isUnconnectedLinkValid(t){Util.i(t,"boolean",LinkingBaseTool,"isUnconnectedLinkValid"),this.LP=t}get linkingCursor(){return this.Sl}set linkingCursor(t){this.Sl=t}get temporaryLink(){return this.AP}set temporaryLink(t){t.li(),this.AP=t}get temporaryFromNode(){return this.TP}set temporaryFromNode(t){t.li(),this.TP=t,t&&(this.Xh=t.port)}get temporaryFromPort(){return this.Xh}set temporaryFromPort(t){if(this.Xh!==null){const i=this.Xh.panel;if(i!==null){const e=i.L.indexOf(this.Xh);i.removeAt(e),i.insertAt(e,t)}}this.Xh=t}get temporaryToNode(){return this.DP}set temporaryToNode(t){t.li(),this.DP=t,t&&(this.Kh=t.port)}get temporaryToPort(){return this.Kh}set temporaryToPort(t){if(this.Kh!==null){const i=this.Kh.panel;if(i!==null){const e=i.L.indexOf(this.Kh);i.removeAt(e),i.insertAt(e,t)}}this.Kh=t}get originalLink(){return this.FP}set originalLink(t){this.FP=t}get originalFromNode(){return this.RP}set originalFromNode(t){this.RP=t}get originalFromPort(){return this.vP}set originalFromPort(t){this.vP=t}get originalToNode(){return this.OP}set originalToNode(t){this.OP=t}get originalToPort(){return this.IP}set originalToPort(t){this.IP=t}get isForwards(){return this.EP}set isForwards(t){this.EP=t}get validPortsCache(){return this.zC}get targetPort(){return this.BP}set targetPort(t){this.BP=t}copyPortProperties(t,i,e,s,n){if(t===null||i===null||e===null||s===null)return;const o=i.getDocumentScale(),r=Size.l();r.width=i.naturalBounds.width*o,r.height=i.naturalBounds.height*o,s.desiredSize=r,Size.s(r),n?(s.toSpot=i.toSpot,s.toEndSegmentLength=i.toEndSegmentLength):(s.fromSpot=i.fromSpot,s.fromEndSegmentLength=i.fromEndSegmentLength),e.locationSpot=Spot.Center;const l=Point.l();e.location=i.getDocumentPoint(Spot.Center,l),Point.s(l),s.angle=i.getDocumentAngle(),this.portTargeted!==null&&this.portTargeted(t,i,e,s,n)}setNoTargetPortProperties(t,i,e){i!==null&&(i.desiredSize=Size.Dk,i.fromSpot=Spot.None,i.toSpot=Spot.None),t!==null&&(t.location=this.diagram.lastInput.documentPoint),this.portTargeted!==null&&this.portTargeted(null,null,t,i,e)}doMouseDown(){this.isActive&&this.doMouseMove()}doMouseMove(){if(this.isActive){const t=this.diagram;if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null&&this.targetPort.part instanceof Node){const i=this.targetPort.part;this.isForwards?this.copyPortProperties(i,this.targetPort,this.temporaryToNode,this.temporaryToPort,!0):this.copyPortProperties(i,this.targetPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else this.isForwards?this.setNoTargetPortProperties(this.temporaryToNode,this.temporaryToPort,!0):this.setNoTargetPortProperties(this.temporaryFromNode,this.temporaryFromPort,!1);(t.allowHorizontalScroll||t.allowVerticalScroll)&&t.doAutoScroll(t.lastInput.viewPoint)}}findValidLinkablePort(t,i){if(t===null)return null;const e=t.part;if(!(e instanceof Node))return null;for(;t!==null;){const s=i?t.toLinkable:t.fromLinkable;if(s===!0&&(t.portId!==null||t instanceof Node)&&(i?this.isValidTo(e,t):this.isValidFrom(e,t)))return t;if(s===!1)return null;t=t.panel}return null}findTargetPort(t){const i=this.diagram,e=i.lastInput.documentPoint;let s=this.portGravity;s<=0&&(s=.1);const n=this,o=i.findObjectsNear(e,s,a=>n.findValidLinkablePort(a,t),null,!0);let r=1/0,l=null;const h=o.iterator;for(;h.next();){const a=h.value,c=a.part;if(!(c instanceof Node))continue;const f=a.getDocumentPoint(Spot.Center,Point.l()),u=e.x-f.x,d=e.y-f.y;Point.s(f);const m=u*u+d*d;if(m=e)return!1}return!0}isValidTo(t,i){if(t===null||i===null)return this.isUnconnectedLinkValid;if(this.diagram.currentTool===this&&(t.layer!==null&&!t.layer.allowLink||i.toLinkable!==!0))return!1;const e=i.toMaxLinks;if(e<1/0){if(this.originalLink!==null&&t===this.originalToNode&&i===this.originalToPort)return!0;let s=i.portId;if(s===null&&(s=""),t.findLinksInto(s).count>=e)return!1}return!0}isInSameNode(t,i){if(t===null||i===null)return!1;if(t===i)return!0;const e=t.part,s=i.part;return e!==null&&e===s}isLinked(t,i){if(t===null||i===null)return!1;const e=t.part;if(!(e instanceof Node))return!1;let s=t.portId;s===null&&(s="");const n=i.part;if(!(n instanceof Node))return!1;let o=i.portId;o===null&&(o="");const r=n.findLinksInto(o);for(;r.next();){const l=r.value;if(l.fromNode===e&&l.fromPortId===s)return!0}return!1}isValidLink(t,i,e,s){if(!this.isValidFrom(t,i)||!this.isValidTo(e,s)||i!==null&&s!==null&&(!(i.fromLinkableSelfNode&&s.toLinkableSelfNode)&&this.isInSameNode(i,s)||!(i.fromLinkableDuplicates&&s.toLinkableDuplicates)&&this.isLinked(i,s))||this.originalLink!==null&&(t!==null&&this.isLabelDependentOnLink(t,this.originalLink)||e!==null&&this.isLabelDependentOnLink(e,this.originalLink))||t!==null&&e!==null&&(t.data===null&&e.data!==null||t.data!==null&&e.data===null)||!this.isValidCycle(t,e,this.originalLink))return!1;let n;return t!==null&&(n=t.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))||e!==null&&(n=e.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))?!1:(n=this.linkValidation,n!==null?n(t,i,e,s,this.originalLink):!0)}isLabelDependentOnLink(t,i){if(t===null)return!1;const e=t.labeledLink;if(e===null)return!1;if(e===i)return!0;const s=new GSet;return s.add(t),this.VP(e,i,s)}VP(t,i,e){if(t===i)return!0;const s=t.fromNode;if(s!==null&&s.isLinkLabel&&(e.add(s),this.VP(s.labeledLink,i,e)))return!0;const n=t.toNode;return!!(n!==null&&n.isLinkLabel&&(e.add(n),this.VP(n.labeledLink,i,e)))}isValidCycle(t,i,e){if(e===void 0&&(e=null),t===null||i===null)return this.isUnconnectedLinkValid;const s=this.diagram;let n=1;if(s&&(s.model.pc()?n=s.isTreePathToChildren?5:6:n=s.validCycle),n===1)return!0;if(n===5){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=i.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.toNode===i)return!1}return!this.xu(t,i,e,!0)}else if(n===6){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=t.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.fromNode===t)return!1}return!this.xu(t,i,e,!0)}else{if(n===2)return!this.tF(t,i,e);if(n===3)return!this.xu(t,i,e,!1);if(n===4)return!this.iF(t,i,e)}return!0}xu(t,i,e,s){if(t===i)return!0;if(t===null||i===null)return!1;const n=t.linksConnected;for(;n.next();){const o=n.value;if(o===e||s&&!o.isTreeLink||o.toNode!==t)continue;const r=o.fromNode;if(r!==t&&this.xu(r,i,e,s))return!0}return!1}tF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.XC(s,t,i,e)}XC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s||o.toNode!==i)continue;const r=o.fromNode;if(r!==i&&this.XC(t,r,e,s))return!0}return!1}iF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.KC(s,t,i,e)}KC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s)continue;const r=o.fromNode,l=o.toNode,h=r===i?l:r;if(h!==i&&this.KC(t,h,e,s))return!0}return!1}get linkValidation(){return this.Ml}set linkValidation(t){t!==null&&Util.i(t,"function",LinkingBaseTool,"linkValidation"),this.Ml=t}get portTargeted(){return this.UP}set portTargeted(t){t!==null&&Util.i(t,"function",LinkingBaseTool,"portTargeted"),this.UP=t}}var LinkingDirection=(w=>(w[w.Either=1]="Either",w[w.ForwardsOnly=2]="ForwardsOnly",w[w.BackwardsOnly=3]="BackwardsOnly",w))(LinkingDirection||{});class LinkingTool extends LinkingBaseTool{zP;XP;S;KP;constructor(t){super(),this.name="Linking",this.zP={},this.XP=null,this.S=1,this.KP=null,t&&Object.assign(this,t)}static Either=1;static ForwardsOnly=2;static BackwardsOnly=3;get archetypeLinkData(){return this.zP}set archetypeLinkData(t){t!==null&&Util.i(t,"object",LinkingTool,"archetypeLinkData"),this.zP=t}get archetypeLabelNodeData(){return this.XP}set archetypeLabelNodeData(t){t!==null&&Util.i(t,"object",LinkingTool,"archetypeLabelNodeData"),this.XP=t}get direction(){return this.S}set direction(t){this.S=t}get startObject(){return this.KP}set startObject(t){this.KP=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||t.isModelReadOnly||!t.allowLink||!t.model.Xw()||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize()?!1:this.findLinkablePort()!==null}findLinkablePort(){const t=this.diagram;let i=this.startObject;if(i===null&&(i=t.findObjectAt(t.firstInput.documentPoint,null,null)),i===null)return null;const e=i.part;if(!(e instanceof Node))return null;const s=this.direction;if(s===1||s===2){const n=this.findValidLinkablePort(i,!1);if(n!==null)return this.isForwards=!0,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!1))return this.isForwards=!0,o}}if(s===1||s===3){const n=this.findValidLinkablePort(i,!0);if(n!==null)return this.isForwards=!1,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!0))return this.isForwards=!1,o}}return null}doActivate(){const t=this.diagram,i=this.findLinkablePort();if(i===null){this.stopTool();return}if(this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.isForwards){this.temporaryToNode!==null&&(this.temporaryToNode.location=t.lastInput.documentPoint),this.originalFromPort=i;const e=this.originalFromPort.part;e instanceof Node&&(this.originalFromNode=e),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else{this.temporaryFromNode!==null&&(this.temporaryFromNode.location=t.lastInput.documentPoint),this.originalToPort=i;const e=this.originalToPort.part;e instanceof Node&&(this.originalToNode=e),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0)}t.add(this.temporaryFromNode),this.temporaryFromNode&&this.temporaryFromNode.ensureBounds(),t.add(this.temporaryToNode),this.temporaryToNode&&this.temporaryToNode.ensureBounds(),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.temporaryLink.isTreeLink=this.isNewTreeLink(),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.startObject=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=null,e=null,s=null,n=null,o=null;try{this.targetPort=this.findTargetPort(this.isForwards);const r=this.targetPort;if(r!==null){const l=r.part;l instanceof Node&&(this.isForwards?(this.originalFromNode!==null&&(i=this.originalFromNode,e=this.originalFromPort),s=l,n=r):(i=l,e=r,this.originalToNode!==null&&(s=this.originalToNode,n=this.originalToPort)))}else this.isForwards?this.originalFromNode!==null&&this.isUnconnectedLinkValid&&(i=this.originalFromNode,e=this.originalFromPort):this.originalToNode!==null&&this.isUnconnectedLinkValid&&(s=this.originalToNode,n=this.originalToPort);i!==null||s!==null?(o=this.insertLink(i,e,s,n),o!==null?(r===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint),t.allowSelect&&(t.v("ChangingSelection",t.selection),t.clearSelection(!0),o.isSelected=!0),this.transactionResult=this.name,t.v("LinkDrawn",o)):this.doNoLink(i,e,s,n)):this.isForwards?this.doNoLink(this.originalFromNode,this.originalFromPort,null,null):this.doNoLink(null,null,this.originalToNode,this.originalToPort)}finally{this.stopTool(),o&&t.allowSelect&&t.v("ChangedSelection",t.selection)}}}isNewTreeLink(){const t=this.archetypeLinkData;if(t===null)return!0;if(t instanceof Link)return t.isTreeLink;const i=this.diagram;if(i===null)return!0;const e=i.partManager.getLinkCategoryForData(t),s=i.partManager.findLinkTemplateForCategory(e);return s!==null?s.isTreeLink:!0}insertLink(t,i,e,s){return this.diagram.partManager.insertLink(t,i,e,s)}doNoLink(t,i,e,s){}}class RelinkingTool extends LinkingBaseTool{YP;GP;fs;jP;constructor(t){super(),this.name="Relinking",this.YP=new Shape("Diamond",{desiredSize:Size.lu,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:0}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.GP=new Shape("Diamond",{desiredSize:Size.lu,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:-1}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.fs=null,this.jP=new Rect,t&&Object.assign(this,t)}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i="RelinkFrom",e=null;if(t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkFrom()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null&&(e=this.makeAdornment(s,!1),t.addAdornment(i,e)))}if(e===null&&t.removeAdornment(i),i="RelinkTo",e=null,t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkTo()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null?(e=this.makeAdornment(s,!0),t.addAdornment(i,e)):e.c())}e===null&&t.removeAdornment(i)}makeAdornment(t,i){const e=new Adornment;e.type=Panel.Link;const s=i?this.toHandleArchetype:this.fromHandleArchetype;return s!==null&&e.add(s.copy().xm()),e.adornedObject=t,e}get fromHandleArchetype(){return this.YP}set fromHandleArchetype(t){this.YP=t}get toHandleArchetype(){return this.GP}set toHandleArchetype(t){this.GP=t}get handle(){return this.fs}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.fs=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowRelink||!t.model.Xw()||!t.lastInput.left)return!1;let e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom");return e===null&&(e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo")),e!==null}doActivate(){const t=this.diagram;if(this.originalLink===null){let i=this.handle;if(i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom"),i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo"))),i===null)return;const e=i.part;if(!(e instanceof Adornment)||!(e.adornedPart instanceof Link))return;this.handle=i,this.isForwards=e===null||e.category==="RelinkTo",this.originalLink=e.adornedPart}this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.originalFromPort=this.originalLink.fromPort,this.originalFromNode=this.originalLink.fromNode,this.originalToPort=this.originalLink.toPort,this.originalToNode=this.originalLink.toNode,this.jP.set(this.originalLink.actualBounds),this.originalLink!==null&&this.originalLink.pointsCount>0&&(this.originalLink.fromNode===null&&(this.temporaryFromPort!==null&&(this.temporaryFromPort.desiredSize=Size.ru),this.temporaryFromNode!==null&&(this.temporaryFromNode.location=this.originalLink.getPoint(0))),this.originalLink.toNode===null&&(this.temporaryToPort!==null&&(this.temporaryToPort.desiredSize=Size.ru),this.temporaryToNode!==null&&(this.temporaryToNode.location=this.originalLink.getPoint(this.originalLink.pointsCount-1)))),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0),t.add(this.temporaryFromNode),t.add(this.temporaryToNode),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.copyLinkProperties(this.originalLink,this.temporaryLink),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}copyLinkProperties(t,i){if(t===null||i===null)return;i.adjusting=t.adjusting,i.corner=t.corner;let e=t.curve;(e===11||e===10)&&(e=0),i.curve=e,i.curviness=t.curviness,i.isTreeLink=t.isTreeLink,i.points=t.points,i.routing=t.routing,i.smoothness=t.smoothness,i.fromSpot=t.fromSpot,i.fromEndSegmentLength=t.fromEndSegmentLength,i.fromShortLength=t.fromShortLength,i.toSpot=t.toSpot,i.toEndSegmentLength=t.toEndSegmentLength,i.toShortLength=t.toShortLength}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.handle=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=this.originalFromNode,e=this.originalFromPort,s=this.originalToNode,n=this.originalToPort,o=this.originalLink;try{if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null){const r=this.targetPort.part;r instanceof Node&&(this.isForwards?(s=r,n=this.targetPort):(i=r,e=this.targetPort))}else this.isUnconnectedLinkValid?this.isForwards?(s=null,n=null):(i=null,e=null):o=null;o!==null?(this.reconnectLink(o,this.isForwards?s:i,this.isForwards?n:e,this.isForwards),this.targetPort===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint,o.invalidateRoute()),this.transactionResult=this.name,t.v("LinkRelinked",o,this.isForwards?this.originalToPort:this.originalFromPort)):this.doNoRelink(this.originalLink,this.isForwards),this.originalLink.invalidateOtherJumpOvers(this.jP)}finally{this.stopTool()}}}reconnectLink(t,i,e,s){const n=e!==null&&e.portId!==null?e.portId:"";return s?(t.toNode=i,t.toPortId=n):(t.fromNode=i,t.fromPortId=n),!0}doNoRelink(t,i){}doDraggingMouseMove(t,i,e,s){t!==null?(this.copyPortProperties(t,i,this.temporaryFromNode,this.temporaryFromPort,!1),this.diagram.add(this.temporaryFromNode)):this.diagram.remove(this.temporaryFromNode),e!==null?(this.copyPortProperties(e,s,this.temporaryToNode,this.temporaryToPort,!0),this.diagram.add(this.temporaryToNode)):this.diagram.remove(this.temporaryToNode)}stopDraggingMouseMove(){this.diagram.remove(this.temporaryFromNode),this.diagram.remove(this.temporaryToNode)}}var ReshapingBehavior=(w=>(w[w.None=0]="None",w[w.Horizontal=1]="Horizontal",w[w.Vertical=2]="Vertical",w[w.All=3]="All",w))(ReshapingBehavior||{});class LinkReshapingTool extends Tool{Co;HP;qP;fs;Kw;WP;bm;constructor(t){super(),this.name="LinkReshaping",this.Co=new Shape("Rectangle",{desiredSize:Size._N,fill:"lightblue",stroke:"dodgerblue"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.HP=new Shape("Diamond",{desiredSize:Size.lu,fill:"lightblue",stroke:"dodgerblue",cursor:"move"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.qP=3,this.fs=null,this.Kw=null,this.WP=new Point,this.bm=new List,t&&Object.assign(this,t)}static None=0;static Horizontal=1;static Vertical=2;static All=3;getReshapingBehavior(t){return t?t.wr:0}setReshapingBehavior(t,i){t.wr=i}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i=null;if(t.isSelected&&!this.diagram.isReadOnly){const e=t.path;e!==null&&t.canReshape()&&t.actualBounds.isReal()&&t.isVisible()&&e.actualBounds.isReal()&&e.isVisibleObject()&&(i=t.findAdornment(this.name),(i===null||i.JP!==t.pointsCount||i.$P!==t.resegmentable)&&(i=this.makeAdornment(e),i!==null&&(i.JP=t.pointsCount,i.$P=t.resegmentable,t.addAdornment(this.name,i))))}i===null&&t.removeAdornment(this.name)}makeAdornment(t){const i=t.part,e=i.points,s=i.pointsCount,n=i.isOrthogonal;let o=null;if(e!==null&&s>1){o=new Adornment,o.type=Panel.Link;const r=i.firstPickIndex,l=i.lastPickIndex,h=n?1:0;if(i.resegmentable&&i.computeCurve()!==9)for(let a=r+h;ae.firstPickIndex+1&&s0))this.eF(t,i);else if(t instanceof Panel){const e=t.elements;for(;e.next();){const s=e.value;this.updateResizeHandles(s,i)}}}}eF(t,i){let e=t.alignment;e.isNoSpot()&&(e=Spot.Center);let s=i;if(e.x<=0)e.y<=0?s+=225:e.y>=1?s+=135:s+=180;else if(e.x>=1)e.y<=0?s+=315:e.y>=1&&(s+=45);else if(e.y<=0)s+=270;else if(e.y>=1)s+=90;else return;s<0?s+=360:s>=360&&(s-=360),s<22.5?t.cursor="e-resize":s<67.5?t.cursor="se-resize":s<112.5?t.cursor="s-resize":s<157.5?t.cursor="sw-resize":s<202.5?t.cursor="w-resize":s<247.5?t.cursor="nw-resize":s<292.5?t.cursor="n-resize":s<337.5?t.cursor="ne-resize":t.cursor="e-resize"}get handleArchetype(){return this.Co}set handleArchetype(t){this.Co=t}get handle(){return this.fs}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.fs=t}get adornedObject(){return this.us}set adornedObject(t){if(t!==null&&t.part instanceof Adornment)throw new Error("new handle must not be in an Adornment: "+t);this.us=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowResize||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle!==null&&(this.adornedObject=this.handle.part.adornedObject,this.adornedObject!==null&&(t.isMouseCaptured=!0,t.animationManager.stopAnimation(),t.pu=!0,this.startTransaction(this.name),this.km.set(this.adornedObject.getDocumentPoint(this.handle.alignment.opposite())),this.wc.set(this.adornedObject.part.location),this.QP.set(this.adornedObject.desiredSize),this.jw=this.computeCellSize(),this.Yw=this.computeMinSize(),this.Gw=this.computeMaxSize(),this.isActive=!0))}doDeactivate(){const t=this.diagram;t.pu=!1,t.bl=!0,this.stopTransaction(),this.handle=null,this.us=null,t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){this.adornedObject!==null&&(this.adornedObject.desiredSize=this.originalDesiredSize,this.adornedObject.part.location=this.originalLocation),this.stopTool()}doMouseMove(){const t=this.diagram;if(!this.isActive)return;const i=this.Yw,e=this.Gw,s=this.jw,n=t.lastInput.documentPoint,o=this.adornedObject.getLocalPoint(n,Point.l()),r=this.computeReshape(),l=this.computeResize(o,this.handle.alignment,i,e,s,r);this.resize(l),t.maybeUpdate(),Point.s(o)}doMouseUp(){const t=this.diagram;if(this.isActive){const i=this.Yw,e=this.Gw,s=this.jw,n=this.adornedObject.getLocalPoint(t.lastInput.documentPoint,Point.l()),o=this.computeReshape(),r=this.computeResize(n,this.handle.alignment,i,e,s,o);this.resize(r),Point.s(n),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.v("PartResized",this.adornedObject,this.originalDesiredSize)}this.stopTool()}resize(t){const i=this.diagram,e=this.adornedObject;if(e===null)return;e.desiredSize=t.size;const s=e.part;s.ensureBounds();const n=e.getDocumentPoint(this.handle.alignment.opposite());if(s instanceof Group){const o=new List;o.add(s);let r;!this.dragsMembers&&!s.hasPlaceholder()&&(r=new DraggingOptions,r.dragsMembers=!1),i.moveParts(o,this.oppositePoint.copy().subtract(n),!0,r)}else s.location=s.location.copy().subtract(n).add(this.oppositePoint);i.maybeUpdate()}computeResize(t,i,e,s,n,o){i.isNoSpot()&&(i=Spot.Center);const r=this.adornedObject.naturalBounds,l=r.x,h=r.y,a=r.x+r.width,c=r.y+r.height;let f=1;if(!o){let m=r.width,g=r.height;m<=0&&(m=1),g<=0&&(g=1),f=g/m}const u=Point.l();Geo.Ig(t.x,t.y,l,h,n.width,n.height,u);const d=r.copy();return i.x<=0?i.y<=0?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=Math.max(c-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.x=a-d.width,d.y=c-d.height)):i.y>=1?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.x=a-d.width)):(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=a-d.x,o||(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f,d.y=h+.5*(c-h-d.height))):i.x>=1?i.y<=0?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=Math.max(c-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.y=c-d.height)):i.y>=1?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width))):(d.width=Math.max(Math.min(u.x-l,s.width),e.width),o||(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f,d.y=h+.5*(c-h-d.height))):i.y<=0?(d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=c-d.y,o||(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width,d.x=l+.5*(a-l-d.width))):i.y>=1&&(d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width,d.x=l+.5*(a-l-d.width))),Point.s(u),d}computeReshape(){let t=0;return this.adornedObject instanceof Shape&&(t=this.adornedObject._P()),!(t===6||this.diagram.lastInput.shift)}computeMinSize(){const t=this.adornedObject.minSize.copy(),i=this.minSize;return!isNaN(i.width)&&i.width>t.width&&(t.width=i.width),!isNaN(i.height)&&i.height>t.height&&(t.height=i.height),t}computeMaxSize(){const t=this.adornedObject.maxSize.copy(),i=this.maxSize;return!isNaN(i.width)&&i.width0&&(t.width=n.width),!isNaN(n.height)&&n.height>0&&(t.height=n.height)}let e=this.cellSize;isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height);const s=this.diagram;if((isNaN(t.width)||isNaN(t.height))&&s){const n=s.grid;n!==null&&n.visible&&this.isGridSnapEnabled&&(e=n.gridCellSize,isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height))}return(isNaN(t.width)||t.width===0||t.width===1/0)&&(t.width=1),(isNaN(t.height)||t.height===0||t.height===1/0)&&(t.height=1),t}get minSize(){return this.xr}set minSize(t){if(!this.xr.equals(t)){let e=t.width;isNaN(e)&&(e=0);let s=t.height;isNaN(s)&&(s=0),this.xr.e(e,s)}}get maxSize(){return this.br}set maxSize(t){if(!this.br.equals(t)){let e=t.width;isNaN(e)&&(e=1/0);let s=t.height;isNaN(s)&&(s=1/0),this.br.e(e,s)}}get cellSize(){return this.Lo}set cellSize(t){this.Lo.equals(t)||this.Lo.a(t)}get isGridSnapEnabled(){return this.yc}set isGridSnapEnabled(t){Util.i(t,"boolean",ResizingTool,"isGridSnapEnabled"),this.yc=t}get dragsMembers(){return this.ZP}set dragsMembers(t){Util.i(t,"boolean",ResizingTool,"dragsMembers"),this.ZP=t}get oppositePoint(){return this.km}set oppositePoint(t){this.km.equals(t)||this.km.a(t)}get originalDesiredSize(){return this.QP}get originalLocation(){return this.wc}}class RotatingTool extends Tool{tS;iS;us;Co;fs;eS;Pm;wc;sS;nS;constructor(t){super(),this.name="Rotating",this.tS=45,this.iS=2,this.wc=new Point,this.us=null,this.Co=new Shape("Ellipse",{desiredSize:Size.lu,fill:"lightblue",stroke:"dodgerblue",strokeWidth:1,cursor:"pointer"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.fs=null,this.eS=0,this.Pm=new Point(NaN,NaN),this.sS=0,this.nS=50,t&&Object.assign(this,t)}updateAdornments(t){if(t!==null){if(t.Cl()){const i=t.rotateObject;if(i===t||i===t.path||i.isPanelMain)return}if(t.isSelected&&!this.diagram.isReadOnly){const i=t.rotateObject;if(i!==null&&t.canRotate()&&t.actualBounds.isReal()&&t.isVisible()&&i.actualBounds.isReal()&&i.isVisibleObject()){let e=t.findAdornment(this.name);if((e===null||e.adornedObject!==i)&&(e=this.makeAdornment(i)),e!==null){e.angle=i.getDocumentAngle(),e.hasPlaceholder()||(e.location=this.computeAdornmentLocation(i)),t.addAdornment(this.name,e);return}}}t.removeAdornment(this.name)}}makeAdornment(t){let i=null;const e=t.part.rotateAdornmentTemplate;if(e===null){i=new Adornment,i.type=Panel.Position,i.locationSpot=Spot.Center;const s=this.handleArchetype;s!==null&&i.add(s.copy().xm())}else if(e.li(),i=e.copy(),i===null)return null;return i.adornedObject=t,i}get handleArchetype(){return this.Co}set handleArchetype(t){this.Co=t}get handle(){return this.fs}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.fs=t}get adornedObject(){return this.us}set adornedObject(t){if(t!==null&&t.part instanceof Adornment)throw new Error("new handle must not be in an Adornment: "+t);this.us=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowRotate||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;if(this.adornedObject===null){if(this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle===null)return;this.adornedObject=this.handle.part.adornedObject}this.adornedObject!==null&&(t.isMouseCaptured=!0,t.delaysLayout=!0,this.startTransaction(this.name),this.eS=this.adornedObject.angle,this.Pm=this.computeRotationPoint(this.adornedObject),this.wc=this.adornedObject.part.location.copy(),this.isActive=!0)}computeRotationPoint(t){const i=t.part,e=i.locationObject;return i.rotationSpot.isSpot()?t.getDocumentPoint(i.rotationSpot):t===i||t===e?e.getDocumentPoint(i.locationSpot):t.getDocumentPoint(Spot.Center)}computeAdornmentLocation(t){let i=this.rotationPoint;i.isReal()||(i=this.computeRotationPoint(t));const e=t.getLocalPoint(i);let s=this.handleAngle;s<0?s+=360:s>=360&&(s-=360),s=Math.round(Math.round(s/45)*45);const n=this.handleDistance;return s===0?e.x=t.naturalBounds.width+n:s===45?(e.x=t.naturalBounds.width+n,e.y=t.naturalBounds.height+n):s===90?e.y=t.naturalBounds.height+n:s===135?(e.x=-n,e.y=t.naturalBounds.height+n):s===180?e.x=-n:s===225?(e.x=-n,e.y=-n):s===270?e.y=-n:s===315&&(e.x=t.naturalBounds.width+n,e.y=-n),t.getDocumentPoint(e)}doDeactivate(){const t=this.diagram;this.stopTransaction(),this.handle=null,this.us=null,this.Pm=new Point(NaN,NaN),t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){const t=this.diagram;t.delaysLayout=!1,this.rotate(this.originalAngle),this.stopTool()}doMouseMove(){const t=this.diagram;if(this.isActive){const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i)}}doMouseUp(){const t=this.diagram;if(this.isActive){t.delaysLayout=!1;const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.v("PartRotated",this.adornedObject,this.originalAngle)}this.stopTool()}rotate(t){const i=this.adornedObject;if(i===null)return;i.angle=t;const e=i.part;e.ensureBounds();const s=e.locationObject,n=e.rotateObject;if(s===n||s.isContainedBy(n)){const o=this.wc.copy();e.location=o.subtract(this.rotationPoint).rotate(t-this.originalAngle).add(this.rotationPoint)}this.diagram.maybeUpdate()}computeRotate(t){let i=this.rotationPoint.directionPoint(t)-this.handleAngle;const e=this.adornedObject.panel;e!==null&&(i-=e.getDocumentAngle()),i>=360?i-=360:i<0&&(i+=360);const s=Math.min(Math.abs(this.snapAngleMultiple),180),n=Math.min(Math.abs(this.snapAngleEpsilon),s/2);return!this.diagram.lastInput.shift&&s>0&&n>0&&(i%ss-n&&(i=(Math.floor(i/s)+1)*s)),i>=360?i-=360:i<0&&(i+=360),i}get snapAngleMultiple(){return this.tS}set snapAngleMultiple(t){Util.i(t,"number",RotatingTool,"snapAngleMultiple"),this.tS=t}get snapAngleEpsilon(){return this.iS}set snapAngleEpsilon(t){Util.i(t,"number",RotatingTool,"snapAngleEpsilon"),this.iS=t}get originalAngle(){return this.eS}get rotationPoint(){return this.Pm}set rotationPoint(t){this.Pm=t.copy()}get handleAngle(){return this.sS}set handleAngle(t){Util.i(t,"number",RotatingTool,"handleAngle"),this.sS=t}get handleDistance(){return this.nS}set handleDistance(t){Util.i(t,"number",RotatingTool,"handleDistance"),this.nS=t}}class ClickSelectingTool extends Tool{constructor(t){super(),this.name="ClickSelecting",t&&Object.assign(this,t)}canStart(){return!(!this.isEnabled||this.isBeyondDragSize())}doMouseUp(){this.isActive&&(this.standardMouseSelect(),this.standardMouseClick()||this.diagram.lastInput.isTouchEvent&&this.diagram.toolManager.doToolTip()),this.stopTool()}}class ActionTool extends Tool{xc;constructor(t){super(),this.name="Action",this.xc=null,t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram,i=t.lastInput,e=t.findObjectAt(i.documentPoint,s=>{for(;s.panel!==null;){if(s.isActionable)return s;s=s.panel}return s});return e!==null&&e.isActionable?(this.xc=e,t.fc=t.findObjectAt(i.documentPoint,null,null),!0):!1}doMouseDown(){if(!this.isActive)this.canStart()&&this.doActivate();else{const i=this.diagram.lastInput,e=this.xc;if(e===null)return;i.targetObject=e,e.actionDown!==null&&e.actionDown(i,e)}}doMouseMove(){if(this.isActive){const i=this.diagram.lastInput,e=this.xc;if(e===null)return;i.targetObject=e,e.actionMove!==null&&e.actionMove(i,e)}}doMouseUp(){if(this.isActive){const i=this.diagram.lastInput,e=this.xc;if(e===null)return;i.targetObject=e,e.actionUp!==null&&e.actionUp(i,e),this.standardMouseClick(s=>{for(;s.panel!==null;){if(s.isActionable&&s===e)return s;s=s.panel}return s},s=>s===e)}this.stopTool()}doCancel(){const i=this.diagram.lastInput,e=this.xc;e!==null&&(i.targetObject=e,e.actionCancel!==null&&e.actionCancel(i,e),this.stopTool())}doStop(){this.xc=null}}class ClickCreatingTool extends Tool{Ll;oS;yc;rS;constructor(t){super(),this.name="ClickCreating",this.Ll=null,this.oS=!0,this.yc=!1,this.rS=new Point(0,0),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled||this.archetypeNodeData===null)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.lastInput.left||this.isBeyondDragSize())return!1;if(this.isDoubleClick){if(t.lastInput.clickCount===1&&(this.rS=t.lastInput.viewPoint.copy()),t.lastInput.clickCount!==2||this.isBeyondDragSize(this.rS))return!1}else if(t.lastInput.clickCount!==1)return!1;return!(t.currentTool!==this&&t.findPartAt(t.lastInput.documentPoint,!0)!==null)}doMouseUp(){const t=this.diagram;this.isActive&&this.insertPart(t.lastInput.documentPoint),this.stopTool()}insertPart(t){const i=this.diagram,e=this.archetypeNodeData;if(e===null)return null;let s=null;try{if(i.v("ChangingSelection",i.selection),this.startTransaction(this.name),e instanceof Part)e.Pe()&&(e.li(),s=e.copy(),s!==null&&i.add(s));else if(e!==null){const n=i.model.copyNodeData(e);Util.wt(n)&&(i.model.addNodeData(n),s=i.findPartForData(n))}if(s!==null){const n=Point.X(t.x,t.y);this.isGridSnapEnabled&&this.diagram.lS(s,t,n),s.location=n,i.allowSelect&&(i.clearSelection(!0),s.isSelected=!0),Point.s(n)}i.invalidateDocumentBounds(),this.transactionResult=this.name,i.v("PartCreated",s)}finally{this.stopTransaction(),i.v("ChangedSelection",i.selection)}return s}get archetypeNodeData(){return this.Ll}set archetypeNodeData(t){t!==null&&Util.i(t,"object",ClickCreatingTool,"archetypeNodeData"),this.Ll=t}get isDoubleClick(){return this.oS}set isDoubleClick(t){Util.i(t,"boolean",ClickCreatingTool,"isDoubleClick"),this.oS=t}get isGridSnapEnabled(){return this.yc}set isGridSnapEnabled(t){Util.i(t,"boolean",ClickCreatingTool,"isGridSnapEnabled"),this.yc=t}}class DragSelectingTool extends Tool{Vh;hS;Al;constructor(t){super(),this.name="DragSelecting",this.Vh=175,this.hS=!1,this.Al=new Part({layerName:"Tool",selectable:!1}).add(new Shape("Rectangle",{name:"SHAPE",fill:null,stroke:"magenta"}).theme("stroke","dragSelect")).li(),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(!t.allowSelect)return!1;const i=t.lastInput;return!(!i.left||t.currentTool!==this&&(!this.isBeyondDragSize()||i.timestamp-t.firstInput.timestamp{const e=i.diagram;e!==null&&e.Mi(root.document,"scroll",i.aS,!1),i.stopTool()},t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return!(!t.allowHorizontalScroll&&!t.allowVerticalScroll||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize())}doActivate(){const t=this.diagram;this.No?(t.lastInput.bubbles=!0,t.Vt(root.document,"scroll",this.aS,!1)):(t.currentCursor="move",t.isMouseCaptured=!0,this.Hw.a(t.position)),this.isActive=!0}doDeactivate(){const t=this.diagram;t.currentCursor="",t.isMouseCaptured=!1,this.isActive=!1}doCancel(){const t=this.diagram;t.position=this.Hw,t.isMouseCaptured=!1,this.stopTool()}doMouseMove(){this.GC()}doMouseUp(){this.GC(),this.stopTool()}GC(){const t=this.diagram;if(this.isActive&&t){if(this.No){t.lastInput.bubbles=!0;return}const i=t.position,e=t.firstInput.documentPoint,s=t.lastInput.documentPoint;let n=i.x+e.x-s.x,o=i.y+e.y-s.y;t.allowHorizontalScroll||(n=i.x),t.allowVerticalScroll||(o=i.y),t.position=this.YC.e(n,o)}}get bubbles(){return this.No}set bubbles(t){Util.i(t,"boolean",PanningTool,"bubbles"),this.No=t}get originalPosition(){return this.Hw}}class HTMLInfo{qw;Ww;cS;fS;constructor(t){this.qw=null,this.Ww=null,this.cS=null,this.fS=null,t&&Object.assign(this,t)}get mainElement(){return this.cS}set mainElement(t){this.cS=t}get show(){return this.qw}set show(t){this.qw!==t&&(t!==null&&Util.i(t,"function",HTMLInfo,"show"),this.qw=t)}get hide(){return this.Ww}set hide(t){this.Ww!==t&&(t!==null&&Util.i(t,"function",HTMLInfo,"hide"),this.Ww=t)}get valueFunction(){return this.fS}set valueFunction(t){this.fS=t}}class ContextMenuButtonInfo{hi;Sm;kc;constructor(t,i,e){this.hi=t,this.Sm=i,this.kc=e}}class ContextMenuTool extends Tool{uS;Jw;dS;gS;$w;Zw;Mm;constructor(t){super(),this.name="ContextMenu",this.uS=null,this.Jw=null,this.dS=null,this.gS=new Point,this.$w=null,this.Mm=!1;const i=this;this.Zw=()=>i.stopTool(),t&&Object.assign(this,t)}sF(){const t=new HTMLInfo;t.show=(r,l,h)=>h.showDefaultContextMenu(),t.hide=(r,l)=>l.hideDefaultContextMenu(),ContextMenuTool.bu=t;const i=this;this.Zw=()=>i.stopTool();const e=Util.en("div"),s=Util.en("div");e.style.cssText="top: 0px;z-index:10002;position: fixed;display: none;text-align: center;left: 25%;width: 50%;background-color: #F5F5F5;padding: 16px;border: 16px solid #444;border-radius: 10px;margin-top: 10px",s.style.cssText="z-index:10001;position: fixed;display: none;top: 0;left: 0;width: 100%;height: 100%;background-color: black;opacity: 0.8;";const n=Util.en("style");root.document.getElementsByTagName("head")[0].appendChild(n),n.sheet.insertRule(".goCXul { list-style: none; }",0),n.sheet.insertRule(".goCXli {font:700 1.5em Helvetica, Arial, sans-serif;position: relative;min-width: 60px; }",0),n.sheet.insertRule(".goCXa {color: #444;display: inline-block;padding: 4px;text-decoration: none;margin: 2px;border: 1px solid gray;border-radius: 10px; }",0);const o=this.diagram;o!==null&&(o.Vt(e,"contextmenu",ContextMenuTool.Yh,!1),o.Vt(e,"selectstart",ContextMenuTool.Yh,!1),o.Vt(s,"contextmenu",ContextMenuTool.Yh,!1)),e.className="goCXforeground",s.className="goCXbackground",root.document.body&&(root.document.body.appendChild(e),root.document.body.appendChild(s)),ContextMenuTool.Nm=e,ContextMenuTool.Cm=s,ContextMenuTool.mS=!0}static bu=null;static mS=!1;static Cm=null;static Nm=null;static Yh(t){return t.preventDefault(),!1}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return this.isBeyondDragSize()||!t.lastInput.right||t.lastInput.clickCount>1?!1:!!(t.lastInput.isTouchEvent&&this.defaultTouchContextMenu!==null||this.findObjectWithContextMenu()!==null)}doStart(){const t=this.diagram;this.gS.set(t.firstInput.documentPoint)}doStop(){this.hideContextMenu(),this.currentObject=null,this.Mm=!1}findObjectWithContextMenu(t){t===void 0&&(t=null);const i=this.diagram,e=i.lastInput;let s=null;if(t instanceof Diagram||(t instanceof GraphObject?s=t:s=i.findObjectAt(e.documentPoint,null,n=>!n.layer.isTemporary)),s!==null){let n=s;for(;n!==null;){if(n.contextMenu!==null)return n;n=n.panel}if(i.lastInput.isTouchEvent&&this.defaultTouchContextMenu)return s.part}else if(i.contextMenu!==null)return i;return null}doActivate(){}doMouseDown(){if(super.doMouseDown(),this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doMouseDown(),t.doDeactivate())}this.diagram.toolManager.mouseDownTools.has(this)&&this.doContextClick()}doMouseUp(){if(this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doCancel(),t.doDeactivate())}this.doContextClick()}doContextClick(){const t=this.diagram;if(!this.isActive)this.canStart()&&(this.openMenu(!0),this.isActive||this.stopTool());else{const i=this.currentContextMenu;if(i===null)return;let e=null;i instanceof HTMLInfo||(e=t.findObjectAt(t.lastInput.documentPoint,null,null),e!==null&&e.isContainedBy(i)&&this.standardMouseClick(null,null)),this.maybeStopTool(e)}}maybeStopTool(t){this.stopTool(),this.canStart()&&(this.diagram.currentTool=this,this.doMouseUp())}openMenu(t,i){if(i===void 0&&(i=null),this.Mm)return;this.Mm=!0,t&&this.standardMouseSelect();const e=this.standardMouseClick();if(this.Mm=!1,!e){this.isActive=!0;const s=ContextMenuTool.bu;if(i===null&&(i=this.findObjectWithContextMenu()),i!==null){const n=i.contextMenu;n!==null?(this.currentObject=i instanceof GraphObject?i:null,this.showContextMenu(n,this.currentObject)):s!==null&&this.showContextMenu(s,this.currentObject)}else s!==null&&this.showContextMenu(s,null);this.currentContextMenu instanceof Adornment&&!this.currentContextMenu.visible&&this.stopTool()}}doMouseMove(){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.doMouseMove(),this.isActive&&this.diagram.toolManager.doMouseMove()}showContextMenu(t,i){const e=this.diagram;if(t!==this.currentContextMenu&&this.hideContextMenu(),t instanceof Adornment){const s=t;s.layerName="Tool",s.selectable=!1,s.scale=1/e.scale,s.category=this.name,s.hasPlaceholder()&&(s.placeholder.scale=e.scale);const n=s.diagram;n!==null&&n!==e&&n.remove(s),e.add(s),i!==null?s.adornedObject=i:s.data=e.model,s.ensureBounds(),this.positionContextMenu(s,i)}else t instanceof HTMLInfo&&t.show(i,e,this);this.currentContextMenu=t}positionContextMenu(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom&&(n.y-=o.height+5/s.scale),n.ye.commandHandler.copySelection(),e=>e.commandHandler.canCopySelection())),i.add(new ContextMenuButtonInfo("Cut",e=>e.commandHandler.cutSelection(),e=>e.commandHandler.canCutSelection())),i.add(new ContextMenuButtonInfo("Delete",e=>e.commandHandler.deleteSelection(),e=>e.commandHandler.canDeleteSelection())),i.add(new ContextMenuButtonInfo("Paste",e=>e.commandHandler.pasteSelection(t.mouseDownPoint),e=>e.commandHandler.canPasteSelection(t.mouseDownPoint))),i.add(new ContextMenuButtonInfo("Select All",e=>e.commandHandler.selectAll(),e=>e.commandHandler.canSelectAll())),i.add(new ContextMenuButtonInfo("Undo",e=>e.commandHandler.undo(),e=>e.commandHandler.canUndo())),i.add(new ContextMenuButtonInfo("Redo",e=>e.commandHandler.redo(),e=>e.commandHandler.canRedo())),i.add(new ContextMenuButtonInfo("Scroll To Part",e=>e.commandHandler.scrollToPart(),e=>e.commandHandler.canScrollToPart())),i.add(new ContextMenuButtonInfo("Zoom To Fit",e=>e.commandHandler.zoomToFit(),e=>e.commandHandler.canZoomToFit())),i.add(new ContextMenuButtonInfo("Reset Zoom",e=>e.commandHandler.resetZoom(),e=>e.commandHandler.canResetZoom())),i.add(new ContextMenuButtonInfo("Group Selection",e=>e.commandHandler.groupSelection(),e=>e.commandHandler.canGroupSelection())),i.add(new ContextMenuButtonInfo("Ungroup Selection",e=>e.commandHandler.ungroupSelection(),e=>e.commandHandler.canUngroupSelection())),i.add(new ContextMenuButtonInfo("Edit Text",e=>e.commandHandler.editTextBlock(),e=>e.commandHandler.canEditTextBlock())),i}showDefaultContextMenu(){const t=this.diagram;this.$w===null&&(this.$w=this.nF()),ContextMenuTool.Nm.innerHTML="",ContextMenuTool.Cm.addEventListener("pointerdown",this.Zw,!1);const i=this,e=Util.en("ul");e.className="goCXul",ContextMenuTool.Nm.appendChild(e),e.innerHTML="";const s=this.$w.iterator;for(;s.next();){const n=s.value,o=n.Sm,r=n.kc;if(typeof o!="function"||typeof r=="function"&&!r(t))continue;const l=Util.en("li");l.className="goCXli";const h=Util.en("a");h.className="goCXa",h.href="#",h.Sm=n.Sm,h.addEventListener("pointerdown",function(a){return this.Sm(t),i.stopTool(),a.preventDefault(),!1},!1),h.textContent=n.hi,l.appendChild(h),e.appendChild(l)}ContextMenuTool.Nm.style.display="block",ContextMenuTool.Cm.style.display="block"}hideDefaultContextMenu(){if(this.currentContextMenu===null||this.currentContextMenu!==ContextMenuTool.bu)return;ContextMenuTool.Nm.style.display="none",ContextMenuTool.Cm.style.display="none";const t=this.diagram;t!==null&&t.Mi(ContextMenuTool.Cm,"pointerdown",this.Zw,!1),this.currentContextMenu=null}get currentContextMenu(){return this.uS}set currentContextMenu(t){this.uS=t,this.Jw=t instanceof Adornment?t.adornedPart:null}get defaultTouchContextMenu(){return ContextMenuTool.mS===!1&&ContextMenuTool.bu===null&&Diagram.isUsingDOM()&&this.sF(),ContextMenuTool.bu}set defaultTouchContextMenu(t){t===null&&(ContextMenuTool.mS=!0),ContextMenuTool.bu=t}get currentObject(){return this.dS}set currentObject(t){this.dS=t}get mouseDownPoint(){return this.gS}}var TextEditingAccept=(w=>(w[w.LostFocus=1]="LostFocus",w[w.MouseDown=2]="MouseDown",w[w.Tab=3]="Tab",w[w.Enter=4]="Enter",w))(TextEditingAccept||{}),TextEditingStarting=(w=>(w[w.SingleClick=1]="SingleClick",w[w.SingleClickSelected=2]="SingleClickSelected",w[w.DoubleClick=3]="DoubleClick",w))(TextEditingStarting||{}),TextEditingState=(w=>(w[w.None=1]="None",w[w.Active=2]="Active",w[w.Editing=3]="Editing",w[w.Validating=4]="Validating",w[w.Invalid=5]="Invalid",w[w.Validated=6]="Validated",w))(TextEditingState||{});class TextEditingTool extends Tool{Se;pS;yS;Tl;Yt;wS;xS;bS;Qw;_w;constructor(t){super(),this.name="TextEditing",this.Se=new TextBlock,this.pS=null,this.yS=2,this.Tl=null,this.Yt=1,this.wS=1,this.xS=!0,this.bS=null,this.Qw=new HTMLInfo,this._w=null,this.oF(this.Qw),t&&Object.assign(this,t)}static LostFocus=1;static MouseDown=2;static Tab=3;static Enter=4;static SingleClick=1;static SingleClickSelected=2;static DoubleClick=3;static StateNone=1;static StateActive=2;static StateEditing=3;static StateValidating=4;static StateInvalid=5;static StateValidated=6;oF(t){if(!Diagram.isUsingDOM())return;const i=Util.en("textarea");this._w=i;const e=this;i.addEventListener("input",function(s){if(e.textBlock===null)return;const n=e.measureTemporaryTextBlock(this.value),o=this.textScale;this.style.width=20+Math.max(e.textBlock.measuredBounds.width,n.measuredBounds.width)*o+"px",this.rows=Math.max(e.textBlock.lineCount,n.lineCount)},!1),i.addEventListener("keydown",function(s){if(s.isComposing||e.textBlock===null)return;const n=s.key;if(n==="Enter"){e.textBlock.isMultiline===!1&&s.preventDefault(),e.acceptText(4);return}else if(n==="Tab"){e.acceptText(3),s.preventDefault();return}else n==="Escape"&&(e.doCancel(),e.diagram!==null&&e.diagram.doFocus())},!1),i.addEventListener("focus",function(s){e.rF(s)},!1),i.addEventListener("blur",function(s){e.lF(s)},!1),t.valueFunction=()=>i.value,t.mainElement=i,t.show=(s,n,o)=>{if(!(s instanceof TextBlock&&o instanceof TextEditingTool))return;if(o.state===5){i.style.border="3px solid red",i.focus();return}const r=s.getDocumentPoint(Spot.Center),l=n.position,h=n.scale;let a=s.getDocumentScale()*h;a{s.div.removeChild(i)}}get textBlock(){return this.pS}set textBlock(t){this.pS=t}get currentTextEditor(){return this.bS}set currentTextEditor(t){this.bS=t}get defaultTextEditor(){return this.Qw}set defaultTextEditor(t){this.Qw=t}get starting(){return this.yS}set starting(t){this.yS=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t===null||t.isReadOnly||TextEditingTool.Pc&&TextEditingTool.Pc!==this&&(TextEditingTool.Pc.acceptText(2),TextEditingTool.Pc&&TextEditingTool.Pc!==this)||!t.lastInput.left||this.isBeyondDragSize())return!1;const i=t.lastInput.documentPoint,e=t.findObjectAt(i);if(e===null||!(e instanceof TextBlock)||!e.editable||!e.part.canEdit())return!1;const s=e.part;return!(s===null||this.starting===2&&!s.isSelected||this.starting===3&&t.lastInput.clickCount<2)}doStart(){TextEditingTool.Pc=this,this.textBlock!==null&&this.doActivate()}doActivate(){if(this.isActive)return;const t=this.diagram;if(t===null)return;let i=this.textBlock;if(i===null&&(i=t.findObjectAt(t.lastInput.documentPoint)),i===null||!(i instanceof TextBlock)||(this.textBlock=i,i.part===null))return;t.animationManager.stopAnimation(),this.isActive=!0,this.Yt=2;let s=this.defaultTextEditor;i.textEditor!==null&&(s=i.textEditor),this.Se=this.textBlock.copy();const n=new Rect(this.textBlock.getDocumentPoint(Spot.TopLeft),this.textBlock.getDocumentPoint(Spot.BottomRight));t.scrollToRect(n),s.show(i,t,this),this.currentTextEditor=s}doCancel(){this.stopTool()}doMouseUp(){this.canStart()&&this.doActivate()}doMouseDown(){this.isActive&&this.acceptText(2)}acceptText(t){switch(t){case 2:this.Yt===6?this.currentTextEditor instanceof HTMLElement&&this.currentTextEditor.focus():(this.Yt===2||this.Yt===5||this.Yt===3)&&(this.Yt=4,this.jC());break;case 1:case 4:case 3:if(t===4&&this.textBlock.isMultiline===!0)return;(this.Yt===2||this.Yt===5||this.Yt===3)&&(this.Yt=4,this.jC());break}}jC(){const t=this.textBlock,i=this.diagram,e=this.currentTextEditor;if(t!==null&&e!==null){const s=t.text;let n="";if(e.valueFunction!==null&&(n=e.valueFunction()),!this.isValidText(t,s,n)){this.Yt=5,this.doError(s,n);return}this.startTransaction(this.name),this.Yt=6,this.transactionResult=this.name,t.text=n,this.doSuccess(s,n),i!==null&&i.v("TextEdited",t,s),this.stopTransaction(),this.stopTool(),i!==null&&i.doFocus()}}doError(t,i){const e=this.textBlock;e.errorFunction!==null&&e.errorFunction(this,t,i);const s=this.currentTextEditor;s&&s.show(e,this.diagram,this)}doSuccess(t,i){const e=this.textBlock;e.textEdited!==null&&e.textEdited(e,t,i)}doDeactivate(){const t=this.diagram;t!==null&&(this.Yt=1,this.currentTextEditor!==null&&this.currentTextEditor.hide(t,this),this.textBlock=null,this.isActive=!1)}doStop(){TextEditingTool.Pc=null}rF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this._w;this.Yt===2&&(this.Yt=3),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}lF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this._w;typeof i.focus=="function"&&i.focus(),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}isValidText(t,i,e){const s=this.textValidation;if(s!==null&&!s(t,i,e))return!1;const n=t.textValidation;return!(n!==null&&!n(t,i,e))}get textValidation(){return this.Tl}set textValidation(t){t!==null&&Util.i(t,"function",TextEditingTool,"textValidation"),this.Tl=t}get minimumEditorScale(){return this.wS}set minimumEditorScale(t){t!==null&&Util.i(t,"number",TextEditingTool,"minimumEditorScale"),this.wS=t}get selectsTextOnActivate(){return this.xS}set selectsTextOnActivate(t){t!==null&&Util.i(t,"boolean",TextEditingTool,"selectsTextOnActivate"),this.xS=t}get state(){return this.Yt}set state(t){this.Yt!==t&&(this.Yt=t)}measureTemporaryTextBlock(t){const i=this.Se;return i.text=t,i.ut(this.textBlock.Dl,1/0),i}static Pc=null}var AnimationStyle=(w=>(w[w.Default=1]="Default",w[w.AnimateLocations=2]="AnimateLocations",w[w.None=3]="None",w))(AnimationStyle||{});class AnimationManager{p;Ni;Oi;kr;Gn;Ao;kS;PS;Lm;wi;Sc;un;Am;Gh;tx;Tm;ix;Mc;wu;Dm;constructor(t){this.p=Diagram.mm(),this.Ni=!1,this.Lm=!1,this.wi=!1,this.Sc=!1,this.ix=!0,this.Mc=1,this.wu=!1,this.Oi=!0,this.kr=!0,this.Ao=600,this.kS=!1,this.PS=!1,this.Gn=new GSet,this.un=new Animation,this.Am=new Animation,this.un.ds=this,this.Gh=new GSet,this.tx=new GSet,this.Tm=new GSet,this.Dm=new GSet,t&&Object.assign(this,t)}To(t){this.p=t}rE(){return this.p}canStart(t){return!0}Fl(t){return!this.Oi||!this.canStart(t)?!1:(this.Gn.add(t),this.defaultAnimation.isAnimating&&this.stopAnimation(),this.p.Ci(),this.wi=!0,!0)}getBundleAnimation(){return this.Am}SS(){if(!this.Oi||(this.Am.ce.count>0&&this.Am.start(),!this.wi))return;const t=this.un,i=this.p,e=this.Gn.has("Model");if(e&&(this.Sc=!0,this.Mc===1?(t.isViewportUnconstrained=!0,t.ce.clear(),t.add(i,"position",i.position.copy().offset(0,-200),i.position),t.add(i,"opacity",0,1)):this.Mc===3&&t.ce.clear(),this.Mc===2&&i.ex.equals(i.at)?this.ix=!0:this.ix=!1,i.v("InitialAnimationStarting",this)),e&&!this.kr||t.ce.count===0){this.Gn.clear(),this.wi=!1,t.ce.clear(),t.sx(i),this.Sc=!1,i.C();return}this.Gn.clear(),i.Pr=!1;const s=t.ce.get(i);i.autoScale!==1&&s!==null&&(delete s.si.scale,delete s.gs.scale);const n=this;root.requestAnimationFrame(()=>{n.wi===!1||t.Ni||(i.getRenderingHint("temporaryPixelRatio")&&i.Uw(),i.MS(),n.wi=!1,t.start(),t.Ni&&(n.ku(),i.invalidateDocumentBounds(),t.HC(0),i.yr(!0),n.Pu(),i.v("AnimationStarting",n)))})}NS(){return this.Gn.has("Trigger")&&this.Gn.count===1}qC(t,i,e,s){this.isTicking||this.NS()||t instanceof Link&&(t.fromNode!==null||t.toNode!==null)||this.un.add(t,"position",i,e,s)}nx(t){return this.un.nx(t)}CS(t){return this.un.CS(t)}hF(t){const i=this.Gh,e=this;function s(){if(e.Tm.count>0&&(i.addAll(e.Tm),e.Tm.clear(),e.Ni=!0),e.Ni===!1||i.count===0)return;e.tx.addAll(i);const n=e.tx.iterator;for(;n.next();){const o=n.value;o.Ni!==!1&&(o.aF()?o.WC(!1):o.Nc=!0)}if(e.tx.clear(),e.Ni===!1){root.requestAnimationFrame(s);return}e.ku(),e.p.yr(),e.Pu(),root.requestAnimationFrame(s)}this.Ni?this.cF(t):(this.Ni=!0,i.add(t),root.requestAnimationFrame(()=>s()))}cF(t){this.Tm.add(t)}fF(){const t=this.Gh.iterator;for(;t.next();)t.value.Nc=!1}ku(){if(this.Lm)return;const t=this.p;this.kS=t.skipsUndoManager,this.PS=t.fe,t.skipsUndoManager=!0,t.fe=!0,this.Lm=!0}Pu(){const t=this.p;t.skipsUndoManager=this.kS,t.fe=this.PS,this.Lm=!1}stopAnimation(t){const i=this.un;if(this.wi===!0&&(this.wi=!1,this.Sc=!1,this.Gn.clear(),i.uF()&&this.p.requestUpdate()),!this.Ni){i.ce.clear(),i.sx(this.p);return}if(i.Su(!0),i.sx(null),t===!0){const e=this.Gh.toArray();for(let s=0;s{!i.isAnimating&&i.runCount===1/0&&i.start()})}get duration(){return this.Ao}set duration(t){Util.i(t,"number",AnimationManager,"duration"),t<1&&Util._(t,">= 1",AnimationManager,"duration"),this.Ao=t}get isAnimating(){return this.Ni}get isTicking(){return this.Lm}get isInitial(){return this.kr}set isInitial(t){Util.i(t,"boolean",AnimationManager,"isInitial"),this.kr=t}get defaultAnimation(){return this.un}get activeAnimations(){return this.Gh}get initialAnimationStyle(){return this.Mc}set initialAnimationStyle(t){this.Mc=t}static ox=new GMap;static defineAnimationEffect(t,i){AnimationManager.ox.set(t,i)}static TS(t,i,e,s,n){t===null&&(t=[0,0,0,0]),i===null&&(i=[0,0,0,0]);let o=t[0],r=t[1];const l=t[2],h=t[3];let a=i[0],c=i[1];const f=i[2],u=i[3];l===0||l===100?(o=a,r=c):(f===0||f===100)&&(a=o,c=r),Math.abs(a-o)>180&&(a>o?o+=360:a+=360);const d=n(e,o,a-o,s)%360,m=n(e,r,c-r,s),g=n(e,l,f-l,s),p=n(e,h,u-h,s);return"hsla("+d+", "+m+"%, "+g+"%, "+p+")"}static{const t=AnimationManager.ox,i=(e,s,n,o,r,l)=>{e.position=new Point(o(r,s.x,n.x-s.x,l),o(r,s.y,n.y-s.y,l))};t.set("position:diagram",i),t.set("position",i),t.set("position:part",(e,s,n,o,r,l)=>{r{r{r{const h=e.actualBounds,a=n.actualBounds,c=a.x+a.width/2-h.width/2,f=a.y+a.height/2-h.height/2;r{e.desiredSize=new Size(o(r,s.width,n.width-s.width,l),o(r,s.height,n.height-s.height,l))}),t.set("width",(e,s,n,o,r,l)=>{e.width=o(r,s,n-s,l)}),t.set("height",(e,s,n,o,r,l)=>{e.height=o(r,s,n-s,l)}),t.set("fill",(e,s,n,o,r,l)=>{e.fill=AnimationManager.TS(s,n,r,l,o)}),t.set("stroke",(e,s,n,o,r,l)=>{e.stroke=AnimationManager.TS(s,n,r,l,o)}),t.set("strokeWidth",(e,s,n,o,r,l)=>{e.strokeWidth=o(r,s,n-s,l)}),t.set("strokeDashOffset",(e,s,n,o,r,l)=>{e.strokeDashOffset=o(r,s,n-s,l)}),t.set("background",(e,s,n,o,r,l)=>{e.background=AnimationManager.TS(s,n,r,l,o)}),t.set("opacity",(e,s,n,o,r,l)=>{e.opacity=o(r,s,n-s,l)}),t.set("scale",(e,s,n,o,r,l)=>{e.scale=o(r,s,n-s,l)}),t.set("angle",(e,s,n,o,r,l)=>{e.angle=o(r,s,n-s,l)})}static Default=1;static AnimateLocations=2;static None=3}class Animation{rx;Fm;Ni;Mu;Ao;ms;QC;Ac;ce;lx;si;jn;Nu;Tc;hx;ax;Nc;DS;cx;ds;p;FS;RS;vS;constructor(t){this.p=null,this.ds=null,this.DS=null,this.cx=null,this.FS=!1,this.Ni=!1,this.Nc=!1,this.si=0,this.jn=0,this.rx=Animation.EaseInOutQuad,this.Fm=Animation.EaseInOutQuad,this.Nu=!1,this.Tc=!1,this.hx=1,this.ax=0,this.Ao=NaN,this.ms=NaN,this.RS=0,this.Mu=null,this.QC=Point.Po,this.ce=new GMap,this.lx=new GMap,this.Ac=new GSet,this.vS=1,t&&Object.assign(this,t)}suspend(){this.Nc=!0}advanceTo(t,i){i&&(this.Nc=!1),this.Nu&&t>=this.ms&&(this.Tc=!0,t=t-this.ms),this.RS=t,this.WC(!0),this.ds.ku(),this.p.yr(),this.ds.Pu(),this.p.redraw()}sx(t){if(this.lx.clear(),this.Tc=!1,this.ax=0,this.ms=NaN,this.Ac.count>0&&this.Ac.clear(),t!==null){const i=t.links;for(;i.next();)i.value.Sr=null}}uF(){return this.ce.count>0}start(){if(this.ce.count===0)return this;if(this.Ni)return this;let t=this.p;const i=this.ce.iterator;for(;i.next();){const s=i.key;t===null&&(s instanceof Diagram?t=s:s instanceof GraphObject&&(t=s.diagram))}if(t!==null)this.p=t,this.ds=t.animationManager;else return this;const e=this.ds;return e.isEnabled===!1?this:(this.ms=isNaN(this.Ao)?e.duration:this.Ao,this.Fm=this.rx,e.Sc&&e.Mc===1&&this===e.defaultAnimation&&(this.Fm=Animation.EaseOutExpo,this.ms=isNaN(this.Ao)?e.duration===600?900:e.duration:this.Ao),this.vS=t.scrollMode,this.isViewportUnconstrained&&(t.jh=2),e.ku(),this.Ac.each(s=>{s.data=null,t.add(s)}),e.Pu(),this.Ni=!0,this.si=+new Date,this.jn=this.si+this.ms,e.hF(this),this)}addTemporaryPart(t,i){return t.Pe()?(this.Ac.add(t),this.p=i,this):this}add(t,i,e,s,n){if(this.p===null&&(t instanceof Diagram?this.p=t:t instanceof GraphObject&&t.diagram!==null&&(this.p=t.diagram)),t instanceof Part){if(!t.isAnimated)return this;i==="position"&&(i="position:part")}return this.LS(t,i,e,s,n),this}LS(t,i,e,s,n){const o=this.ce;let r,l,h;if(t instanceof Diagram&&i==="position"&&(i="position:diagram"),(i==="fill"||i==="stroke"||i==="background")&&(Brush.Do(e),Brush.OS(),e=[Brush.Ii.n0,Brush.Ii.n1,Brush.Ii.n2,Brush.Ii.n3],Brush.Do(s),Brush.OS(),s=[Brush.Ii.n0,Brush.Ii.n1,Brush.Ii.n2,Brush.Ii.n3]),o.has(t))r=o.get(t),l=r.si,h=r.gs,l[i]===void 0&&(l[i]=this.Cu(e)),h[i]=this.Cu(s);else{if(i==="position"&&e.equalsApprox(s))return;l={},h={},l[i]=this.Cu(e),h[i]=this.Cu(s),r=new AnimationState(l,h,n),o.set(t,r)}const a=l[i];a instanceof Point&&!a.isReal()&&a.a(this.QC),n&&i.indexOf("position:")===0&&t instanceof Part?r.fx.location=this.Cu(t.location):n&&(r.fx[i]=this.Cu(e))}Cu(t){return t instanceof Point||t instanceof Size?t.copy():t}dF(t){const i=this.ce;if(i.has(t)){const e=i.get(t);e.ux=!0}}nx(t){if(!this.Ni)return!1;const i=this.ce.get(t);return i!==null&&i.ux}CS(t){if(!this.Ni)return!1;const i=this.ce.get(t);return i!==null&&!!(i.si.position||i.si["position:part"]||i.si.location)}aF(){if(this.Ac.count>0)return!0;const t=this.ce.iterator;for(;t.next();){const i=t.key;if(i instanceof GraphObject&&i.diagram!==null||i instanceof Diagram)return!0}return!1}WC(t){if(this.Nc&&!t)return;const i=this.ds;if(this.Ni===!1)return;const e=+new Date;let s=e>this.jn?this.ms:e-this.si;t&&(s=this.RS,sthis.jn&&(this.Nu&&!this.Tc?(this.si=+new Date,this.jn=this.si+this.ms,this.Tc=!0):this.Su(!1))}HC(t){const i=this.ms,e=this.ce.iterator,s=this.Tc;for(;e.next();){const n=e.key;if(n instanceof GraphObject&&n.diagram===null)continue;const o=e.value,r=s?o.gs:o.si,l=s?o.si:o.gs,h=AnimationManager.ox;for(const a in l)a==="position"&&(l["position:placeholder"]||l["position:nodeCollapse"])||h.get(a)!==null&&h.get(a)(n,r[a],l[a],this.Fm,t,i,this)}}stop(){return this.Ni?(this.Su(!0),this):this}Su(t){if(this.cx!==null&&this.cx.gF(this.DS),!this.Ni)return;const i=this.p,e=this.ds;e.Sc=!1,this.Ni=!1,this.Nc=!1,e.ku();const s=this.ce,n=this.Ac.iterator;for(;n.next();)i.remove(n.value);const o=this.Nu,r=s.iterator,l=AnimationManager.ox;for(;r.next();){const a=r.key,c=r.value,f=o?c.gs:c.si,u=o?c.si:c.gs,d=c.fx;for(const m in u)if(l.get(m)!==null){let g=m;c.gx&&(g==="position:nodeCollapse"||g==="position:placeholder")&&(g="position"),l.get(g)(a,f[m],d[m]!==void 0?d[m]:c.gx?f[m]:u[m],this.Fm,this.ms,this.ms,this)}c.gx&&d.location!==void 0&&a instanceof Part&&(a.location=d.location),c.ux&&a instanceof Part&&a.Ei(!1)}this.ax++;const h=!t&&this.hx>this.ax;if(!h&&(this===e.Am||this===e.defaultAnimation)&&this.ce.clear(),i.mx.clear(),i.yP(!1),i.invalidateDocumentBounds(),i.C(),i.yr(!0),e.defaultAnimation===this){const a=e.Dm.iterator;for(;a.next();)a.value.mF();e.Dm.clear()}if(i.yr(!0),this.isViewportUnconstrained&&(i.scrollMode=this.vS),e.Pu(),h){this.Tc=!1,this.start();return}this.sx(null),i._C(),e.Su(this),this.Mu&&this.Mu(this),i.requestUpdate()}Cc(t,i){const e=i.actualBounds;let s=null;if(i instanceof Group&&(s=i.placeholder),s!==null&&s.visible){const n=s.getDocumentPoint(Spot.TopLeft),o=s.padding;n.x+=o.left,n.y+=o.top,this.add(t,"position",n,t.position,!1)}else this.add(t,"position",new Point(e.x+e.width/2,e.y+e.height/2),t.position,!1);this.add(t,"scale",.01,t.scale,!1),t instanceof Group&&this.pF(t,i)}pF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Cc(s,i)}}Lc(t,i){if(!t.isVisible())return;let e=null;if(i instanceof Group&&(e=i.placeholder),e!==null&&e.visible){const s=e.getDocumentPoint(Spot.TopLeft),n=e.padding;s.x+=n.left,s.y+=n.top,this.add(t,"position:placeholder",t.position,s,!0)}else this.add(t,"position:nodeCollapse",t.position,i,!0);this.add(t,"scale",t.scale,.01,!0),this.dF(t),t instanceof Group&&this.yF(t,i)}yF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Lc(s,i)}}get duration(){return this.Ao}set duration(t){Util.i(t,"number",Animation,"duration"),t<1&&Util._(t,">= 1",Animation,"duration"),this.Ao=t}get reversible(){return this.Nu}set reversible(t){this.Nu=t}get runCount(){return this.hx}set runCount(t){t>0?this.hx=t:Util.o("Animation.runCount value must be a positive integer.")}get finished(){return this.Mu}set finished(t){this.Mu!==t&&(t!==null&&Util.i(t,"function",Animation,"finished"),this.Mu=t)}get easing(){return this.rx}set easing(t){this.rx=t}get isViewportUnconstrained(){return this.FS}set isViewportUnconstrained(t){this.FS=t}get isAnimating(){return this.Ni}getTemporaryState(t){let i=this.lx.get(t);return i===null&&(i={},this.lx.set(t,i)),i}static EaseLinear=(t,i,e,s)=>e*t/s+i;static EaseInOutQuad=(t,i,e,s)=>(t/=s/2,t<1?e/2*t*t+i:-e/2*(--t*(t-2)-1)+i);static EaseInQuad=(t,i,e,s)=>e*(t/=s)*t+i;static EaseOutQuad=(t,i,e,s)=>-e*(t/=s)*(t-2)+i;static EaseInExpo=(t,i,e,s)=>t===0?i:e*Math.pow(2,10*(t/s-1))+i;static EaseOutExpo=(t,i,e,s)=>t===s?i+e:e*(-Math.pow(2,-10*t/s)+1)+i}class AnimationState{si;gs;fx;gx;ux;constructor(t,i,e){this.si=t,this.gs=i,this.fx={},this.gx=e,this.ux=!1}}var TriggerStart=(w=>(w[w.Default=1]="Default",w[w.Immediate=2]="Immediate",w[w.Bundled=3]="Bundled",w))(TriggerStart||{});class AnimationTrigger{ke;an;Lu;Dc;constructor(t,i,e){this.ke=null,this.an=t,this.Lu=e||1,this.Dc=null,i!==void 0&&(this.Dc=i,e===void 0&&(this.Lu=2))}copy(){const t=new AnimationTrigger(this.an);t.Lu=this.Lu;const i=this.Dc;if(i!==null){const e={};i.duration!==void 0&&(e.duration=i.duration),i.finished!==void 0&&(e.finished=i.finished),i.easing!==void 0&&(e.easing=i.easing),t.Dc=e}return t}get propertyName(){return this.an}set propertyName(t){this.an=t}get animationSettings(){return this.Dc}set animationSettings(t){this.Dc=t}wF(t){const i=this.Dc;i!==null&&(i.duration&&(t.duration=i.duration),i.finished&&(t.finished=i.finished),i.easing&&(t.easing=i.easing))}get startCondition(){return this.Lu}set startCondition(t){this.Lu=t}static Default=1;static Immediate=2;static Bundled=3}class Layer{p;Mt;Wt;Mr;Rl;vl;Ol;Il;El;Bl;Ul;Vl;zl;Xl;Kl;Yl;kc;Gl;px;Rm;Au;At;constructor(t){GSet.Yi(this),this.p=null,this.At=new List,this.Mt="",this.Wt=1,this.Mr=!1,this.Rl=!0,this.vl=!0,this.Ol=!0,this.Il=!0,this.El=!0,this.Bl=!0,this.Ul=!0,this.Vl=!0,this.zl=!0,this.Xl=!0,this.Kl=!0,this.Yl=!0,this.kc=!0,this.Gl=!0,this.px=!0,this.Rm=!1,this.Au=[],t&&Object.assign(this,t)}xF(){const t=this.At;for(let i=0;i0&&(h+=e+" Parts "),s>0&&(h+=s+" Nodes "),n>0&&(h+=n+" Groups "),o>0&&(h+=o+" Links "),r>0&&(h+=r+" Adornments "),t>1){const a=this.At.iterator;for(;a.next();){const c=a.value;h+=` + `+c.toString();const f=c.data;f!==null&&GSet.as(f)&&(h+=" #"+GSet.as(f)),c instanceof Node?h+=" "+Util.toString(f):c instanceof Link&&(h+=" "+Util.toString(c.fromNode)+" "+Util.toString(c.toNode))}}return i+" "+this.At.count+": "+h}findObjectAt(t,i,e){if(i===void 0&&(i=null),e===void 0&&(e=null),this.Gl===!1)return null;let s=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(s=!0);const n=Point.l(),o=this.At.r,r=o.length;for(let l=r;l--;){const h=o[l];if(s===!0&&h.Nl()===!1||!h.isVisible())continue;n.a(t),n.Ie(h.Es);let a=h.tL(n,i,e);if(a!==null&&(i!==null&&(a=i(a)),a!==null&&(e===null||e(a))))return Point.s(n),a}return Point.s(n),null}findObjectsAt(t,i,e,s){if(i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Gl===!1)return s;let n=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(n=!0);const o=Point.l(),r=this.At.r,l=r.length;for(let h=l;h--;){const a=r[h];if(n===!0&&a.Nl()===!1||!a.isVisible())continue;o.a(t),o.Ie(a.Es);let c=a;a.iL(o,i,e,s)&&(i!==null&&(c=i(c)),c!==null&&(e===null||e(c))&&s.add(c))}return Point.s(o),s}findObjectsIn(t,i,e,s,n){if(i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Gl===!1)return n;let o=!1;this.diagram!==null&&this.diagram.viewportBounds.containsRect(t)&&(o=!0);const r=this.At.r,l=r.length;for(let h=l;h--;){const a=r[h];if(o===!0&&a.Nl()===!1||!a.isVisible())continue;let c=a;a.vm(t,i,e,s,n)&&(i!==null&&(c=i(c)),c!==null&&(e===null||e(c))&&n.add(c))}return n}NP(t,i,e,s,n,o,r){if(this.Gl===!1)return n;const l=this.At.r,h=l.length;for(let a=h;a--;){const c=l[a];if(r===!0&&c.Nl()===!1||!o(c)||!c.isVisible())continue;let f=c;c.vm(t,i,e,s,n)&&(i!==null&&(f=i(f)),f!==null&&(e===null||e(f))&&n.add(f))}return n}findObjectsNear(t,i,e,s,n,o){if(e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Gl===!1)return o;let r=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(r=!0);const l=Point.l(),h=Point.l(),a=this.At.r,c=a.length;for(let f=c;f--;){const u=a[f];if(r===!0&&u.Nl()===!1||!u.isVisible())continue;l.a(t),l.Ie(u.Es),h.e(t.x+i,t.y),h.Ie(u.Es);let d=u;u.eL(l,h,e,s,n,o)&&(e!==null&&(d=e(d)),d!==null&&(s===null||s(d))&&o.add(d))}return Point.s(l),Point.s(h),o}ES(){return this.At.r}Bs(t,i){if(!this.visible)return;const e=this.At.r,s=e.length;if(s===0)return;const n=Util.nt(),o=Util.nt();for(let r=0;r0&&o.push(l))}for(let r=0;re.Im||a.height*n>e.Im?i.Gi(t,e):this.SF(t,i),c&&(t.restore(),t.clearContextCache(!0))}SF(t,i){const e=i.actualBounds,s=i.naturalBounds;if(e.width===0||e.height===0||isNaN(e.x)||isNaN(e.y)||!i.isVisible())return;const n=i.D;if(i.background===null){i.dn(t,"rgba(0,0,0,0.3)",!0,!1,s,e),t.fillRect(e.x,e.y,e.width,e.height);return}if(t.transform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),i.dn(t,i.background,!0,!1,s,e),t.fillRect(0,0,s.width/2,s.height/2),!n.Ok()){const o=1/(n.m11*n.m22-n.m12*n.m21);t.transform(n.m22*o,-n.m12*o,-n.m21*o,n.m11*o,o*(n.m21*n.dy-n.m22*n.dx),o*(n.m12*n.dx-n.m11*n.dy))}}PF(t,i,e,s){const n=2/s,o=4/s;for(let r=0;r=s.count)t=s.count;else if(s.elt(t)===i)return-1;s.insertAt(t,i),i.Em(e);const n=this.diagram;return n!==null&&(e?n.C():n.qh(i)),this.yx(t,i),t}te(t,i,e){if(!e&&i.layer!==this&&i.layer!==null)return i.layer.te(t,i,e);const s=this.At;if(t<0||t>=s.length){if(t=s.indexOf(i),t<0)return-1}else if(s.elt(t)!==i&&(t=s.indexOf(i),t<0))return-1;i.Bm(e),s.removeAt(t);const n=this.diagram;return n!==null&&(e?n.C():n.te(i)),i.IS(null),t}yx(t,i){t=this.MF(t,i),i instanceof Group&&this.NF(t,i),i.svg!==null&&i.svg.remove()}MF(t,i){const e=i.zOrder;if(isNaN(e))return t;const s=this.At,n=s.count;if(n<=1)return t;if(t<0&&(t=s.indexOf(i)),t<0)return-1;let o=t-1,r=NaN;for(;o>=0&&(r=s.elt(o).zOrder,!!isNaN(r));)o--;let l=t+1,h=NaN;for(;le)for(;;){if(o===-1||r<=e)return o++,o===t?t:(s.removeAt(t),s.insertAt(o,i),o);for(r=NaN;--o>=0&&(r=s.elt(o).zOrder,!!isNaN(r)););}else if(!isNaN(h)&&h=e)return l--,l===t?t:(s.removeAt(t),s.insertAt(l,i),l);for(h=NaN;++l=0)||e<0&&r.containingGroup===i&&(e=o,t>=0))break}if(!(e<0)&&e1)&&Util._(t,"0 <= value <= 1",Layer,"opacity"),this.Wt=t;const e=this.diagram;e!==null&&e.C(),this.t("opacity",i,t)}}get isViewportAligned(){return this.Rm}set isViewportAligned(t){const i=this.Rm;i!==t&&(this.Rm=t,this.diagram&&(this.nL(),this.diagram.C()),this.t("isViewportAligned",i,t),t&&(this.isInDocumentBounds=!1))}nL(){if(!this.Rm)return;const t=this.diagram,i=this.At.r,e=i.length,s=t.kt,n=t.Pt;for(let o=0;o(w[w.None=1]="None",w[w.Uniform=2]="Uniform",w[w.UniformToFill=3]="UniformToFill",w))(AutoScale||{}),CycleMode=(w=>(w[w.All=1]="All",w[w.NotDirected=2]="NotDirected",w[w.NotDirectedFast=3]="NotDirectedFast",w[w.NotUndirected=4]="NotUndirected",w[w.DestinationTree=5]="DestinationTree",w[w.SourceTree=6]="SourceTree",w))(CycleMode||{}),ScrollMode=(w=>(w[w.Document=1]="Document",w[w.Infinite=2]="Infinite",w))(ScrollMode||{}),CollapsePolicy=(w=>(w[w.TreeParent=1]="TreeParent",w[w.AllParents=2]="AllParents",w[w.AnyParents=3]="AnyParents",w))(CollapsePolicy||{});class Diagram{ds;di;VS;wx;Nr;Fu;xx;bx;kx;Px;Sx;Mx;Fc;jh;Nx;Cx;Lx;jl;Rc;Cr;Um;Ax;Tx;Ru;Hn;Lr;Wh;Fo;Vm;vc;zm;Oc;vu;Ar;qn;zS;XS;Dx;Fx;KS;Rx;YS;GS;jS;vx;Xm;Tr;Dr;Fr;Rr;vr;Or;Ox;Ir;Ix;Er;Br;Ur;Vr;Ex;HS;Ro;qS;Bx;Ux;WS;Si;JS;$S;ZS;vs;vo;Oi;Vx;Rl;vl;zx;Xx;Ol;Il;El;Kx;Bl;Ul;Vl;zl;Xl;Kl;Yl;Yx;Gx;QS;Ou;Iu;jx;Hx;qx;Wx;Km;Jx;$x;Zx;$t;_S;Qx;tM;Eu;gn;Wn;ie;Jn;oL;Hl;iM;eM;Ym;_x;Bu;Gm;tb;zr;ql;Jh;sM;nM;jm;ib;eb;ts;Hm;qm;Uu;Wl;Ic;Wm;Xr;$h;oM;Jm;Ht;D;Ue;Pr;Bi;ps;rM;Jl;Kr;bl;Yr;Zh;Ec;lM;Vu;Qh;zu;Gt;$l;at;et;Xu;kt;Pt;dt;Bc;Bw;sb;_h;Uc;nb;ob;rb;AF;TF;Ui;Pl;Im;$m;hM;aM;rL;Zm;DF;FF;RF;lb;vF;OF;IF;ta;lL;Zl;ia;ea;sa;na;yu;Yh;Zt;Tt;Vc;Wk;Jk;fc;Wt;static hb=null;static hL=new GMap;static cM;static fM=null;pu;ab;cb;fb;ub;db;Qm;uM;_m;t0;i0;ex;dM;gb;zc;constructor(t,i){if(Diagram.uw||(Diagram.Ik(),Diagram.uw=!0),GSet.Yi(this),Diagram.aL(this),this.Ht=!0,this.Tt=null,this.kt=0,this.Pt=0,this.dt=null,Diagram.isUsingDOM()){const s=this,n=()=>{s.Mi(root.document,"DOMContentLoaded",n,!1),s.setRTL()};root.document.body!==null?this.setRTL():s.Vt(root.document,"DOMContentLoaded",n,!1)}this.Bc=null,Diagram.gM("Model",PartManager);const e=this;return this.JS=s=>e.partManager.doModelDataChanged(s),this.$S=s=>e.partManager.doModelChanged(s),this.nb=null,this.ob=null,this.cL(),this.model=Model.initDiagramModel(),this.gb=null,this.themeManager=new ThemeManager,this.Ro=!0,this.fL(),this.layout=new Layout,this.Ro=!1,this.DF=null,this.FF=null,this.RF=null,this.lb=null,this.vF=null,this.OF=null,this.IF=null,this.ta=null,this.lL=null,this.Zl=null,this.ia=null,this.ea=null,this.sa=null,this.na=null,this.yu=()=>{},this.Yh=null,this.Uu=!1,this.Vc=new DiagramHelper(this),t!==void 0&&(typeof t=="string"||root.Element&&t instanceof Element?this.mM(t):i=t),i&&this.setProperties(i),this.Ht=!1,this.requestUpdate(),this}HD(){return this.dt!==null}get renderer(){return this.Ic}set renderer(t){if(this instanceof Overview)return;t===""&&(t="default");const i=t.toLowerCase(),e=this.Ic;if(i===e)return;this.Ic=i;let s=null;i==="default"||i==="canvas"?(s=this.Wl.get("svg"),s!==null&&s.Ft.remove(),this.dt&&(this.Zt=this.dt.ai),this.Zt.clearContextCache(!0)):i==="svg"?(this.Wl.has("svg")?s=this.Wl.get("svg"):(s=new SVGSurface(this,root.document),this.addRenderer("svg",s)),this.div!==null&&this.div.appendChild(s.Ft),this.Zt=s.ai,this.dt&&(this.dt.ai.setTransform(this.Ui,0,0,this.Ui,0,0),this.dt.ai.clearRect(0,0,this.kt,this.Pt))):i==="debug"&&(this.Wl.has("SVG")||(s=new SVGSurface(this,root.document),this.addRenderer("SVG",s),s.Ft.style.backgroundColor="whitesmoke",this.div!==null&&this.div.after(s.Ft))),this.Ht||this.redraw()}cL(){this.zc=new List,this.setupRouters(),this.ds=new AnimationManager,this.ds.To(this),this.di=17,this.VS=!1,this.Xu=!1,this.wx="default",this.Gt=new List,this.Wl=new GMap,this.Ic="default",this.resetRenderingHints(),this.EF(),this.Wt=1,this.at=new Point(NaN,NaN).g(),this.ex=new Point(NaN,NaN),this.et=1,this.Jm=1,this.xx=new Point(NaN,NaN).g(),this.bx=NaN,this.kx=1e-4,this.Px=100,this.D=new Transform,this.Sx=new Point(NaN,NaN).g(),this.Mx=new Rect(NaN,NaN,NaN,NaN).g(),this.Fc=new Margin(0,0,0,0).g(),this.jh=1,this.Nx=!1,this.Cx=null,this.Lx=null,this.jl=1,this.Rc=Spot.Default,this.Cr=1,this.Um=Spot.Default,this.Ax=Spot.None,this.Tx=Spot.None,this.Ue=!0,this.Ru=!1,this.Hn=new Set,this.Lr=new GSet,this.Wh=new GSet,this.Fo=!1,this.$l=new GMap,this.Vu=!0,this.Vm=250,this.vc=-1,this.zm=new Margin(16,16,16,16).g(),this.Pr=!1,this.Oc=!1,this.vu=!0,this.Wm=new InputEvent,this.Wm.diagram=this,this.Xr=new InputEvent,this.Xr.diagram=this,this.$h=new InputEvent,this.$h.diagram=this,this.Ar=null,this.qn=null,this.Bw=!1,this.BF(),this.Yr=new GSet,this.Dx=!0,this.Fx=1,this.KS=!1,this.Rx=1,this.vx="auto",this.Xm="auto",this.Tr=null,this.Dr=null,this.Fr=null,this.Rr=null,this.vr=null,this.Or=null,this.Ox=null,this.Ir=null,this.Ix=!1,this.Er=null,this.Br=null,this.Ur=null,this.Vr=null,this.Ex=!1,this.sb={},this._h=[null,null],this.Ro=!1,this.qS=!1,this.Bx=!1,this.Ux=!1,this.WS=!0,this.ps=!1,this.Qh=!1,this.ZS=!0,this.vs=-2,this.Jl=new GMap,this.zu=new List,this.vo=!1,this.Oi=!0,this.Vx=!0,this.Rl=!0,this.vl=!0,this.zx=!1,this.Xx=!0,this.Ol=!0,this.Il=!0,this.El=!0,this.Kx=!0,this.Bl=!0,this.Ul=!0,this.Vl=!0,this.zl=!0,this.Xl=!0,this.Kl=!0,this.Yl=!0,this.Yx=!0,this.Gx=!0,this.QS=!1,this.Uc=!1,this.Ou=!0,this.Iu=!0,this.jx=!0,this.Hx=!0,this.qx=16,this.Wx=16,this.Km=!1,this.Jx=!1,this.$x=0,this.Zx=0,this.$t=new Margin(5).g(),this._S=new GSet().g(),this.Qx=999999999,this.tM=new GSet().g(),this.Zh=!0,this.Eu=!0,this.Ec=!0,this.gn=!1,this.Wn=!1,this.Kr=!0,this.bl=!1,this.Jn=!1,this.oL=new GSet,this.lM=new GSet,this.Hl=null,this.iM=new Size(8,8),this.eM=999,this.Ym=!1,this.Wk=1,this.Jk=0,this.Bi={scale:1,position:new Point,bounds:new Rect,canvasSize:new Size,newCanvasSize:new Size,isScroll:!1},this.Bi.canvasSize=this.Bi.canvasSize,this.Bi.newCanvasSize=this.Bi.newCanvasSize,this.Bi.isScroll=!1,this._x=new Rect(NaN,NaN,NaN,NaN).g(),this.Bu=new Size(NaN,NaN).g(),this.Gm=new Rect(NaN,NaN,NaN,NaN).g(),this.tb=!1,this.UF(),this.ts=null,this.Hm=!1,this.fc=null,this.partManager=new PartManager,this.toolManager=new ToolManager,this.toolManager.initializeStandardTools(),this.defaultTool=this.toolManager,this.currentTool=this.defaultTool,this.cb=null,this.fb=new DraggingOptions,this.ub=null,this.db=null,this.ab=!1,this.pu=!1,this.commandHandler=new CommandHandler,this.t0=null,this.i0=Point.Ak,this.dM=!1,this.Ui=1,this.Pl=null,this.Im=1,this.Qm=0,this.uM=[0,0,0,0,0],this._m=0,this.$m=1,this.hM=0,this.aM=new Point,this.rL=500,this.qm=new Point,this.Zm=!1}static uL=root.document!==void 0;static isUsingDOM(){return Diagram.uL}static useDOM(t){Diagram.uL=t?root.document!==void 0:!1}static Ve=new WeakMap;clear(){this.animationManager.stopAnimation(),this.model.clear(),Diagram.dL(),this.gL(!1),this.zu.clear(),this.mL(),this.Hl=null,this.invalidateDocumentBounds(),this.ensureBounds(),this.C()}gL(t){this.animationManager.stopAnimation(!0),this._S=new GSet().g(),this.tM=new GSet().g();const i=this.skipsUndoManager,e=this.Si!==null&&this.Si!==void 0;e&&(this.skipsUndoManager=!0);let s=null;this.ts!==null&&(s=this.ts.part,s!==null&&this.remove(s));const n=[],o=this.Gt.length;if(t){for(let r=0;rt?new Margin(t/2):1.5)),this.ib=this.jm,this.eb=new Adornment(Panel.Link).add(new Shape({isPanelMain:!0,fill:null,stroke:"dodgerblue",strokeWidth:3}).theme("stroke","selection").theme("strokeWidth","selection"))}setRTL(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);const e=Util.en("div");e.dir="rtl",e.style.cssText="font-size: 14px; width: 1px; height: 1px; position: absolute; top: -1000px; overflow: scroll;",e.textContent="A",i.appendChild(e);let s="reverse";e.scrollLeft>0?s="default":(e.scrollLeft=1,e.scrollLeft===0&&(s="negative")),i.removeChild(e),this.wx=s}setScrollWidth(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);let e=0;if(Diagram.isUsingDOM()){let s=Diagram.fM,n=Diagram.cM;s===null&&(Diagram.fM=Util.en("p"),s=Diagram.fM,s.style.width="100%",s.style.height="200px",s.style.boxSizing="content-box",Diagram.cM=Util.en("div"),n=Diagram.cM,n.style.position="absolute",n.style.visibility="hidden",n.style.width="200px",n.style.height="150px",n.style.boxSizing="content-box",n.appendChild(s)),n.style.overflow="hidden",i.appendChild(n);const o=s.offsetWidth;n.style.overflow="scroll";let r=s.offsetWidth;o===r&&(r=n.clientWidth),i.removeChild(n),e=o-r,e===0&&!Util.rr&&(e=11)}this.di=e,this.VS=!0}ri(t){t in AutoScale?this.autoScale=t:Util.lr(this,t)}toString(t){t===void 0&&(t=0);let i="";this.div&&this.div.id&&(i=this.div.id);let e='Diagram "'+i+'"';if(t<=0)return e;const s=this.Gt.iterator;for(;s.next();){const n=s.value;e+=` + `+n.toString(t-1)}return e}static aL(t){Diagram.hb=t}static mm(){return Diagram.hb}static fromDiv(t){let i=t;if(typeof t=="string"&&(i=root.document.getElementById(t)),i instanceof HTMLDivElement){const e=Diagram.Ve.get(i);if(e)return e}return null}get div(){return this.Tt}set div(t){if(this.Tt!==t){const i=this.Tt;if(i!==null){if(Diagram.Ve.delete(i),i.goDiagram=void 0,i.go=void 0,i.innerHTML="",this.dt!==null){const s=this.dt.Ft;this.Mi(s,"pointermove",this.ia,!1),this.Mi(s,"pointerdown",this.Zl,!1),this.Mi(s,"pointerup",this.ea,!1),this.Mi(s,"pointerout",this.sa,!1),this.Mi(s,"pointercancel",this.na,!1),this.dt.dispose()}this.Bc&&(this.Bc.disconnect(),this.Bc=null);const e=this.toolManager;e!==null&&(e.mouseDownTools.each(s=>s.cancelWaitAfter()),e.mouseMoveTools.each(s=>s.cancelWaitAfter()),e.mouseUpTools.each(s=>s.cancelWaitAfter())),e.cancelWaitAfter(),this.currentTool.doCancel(),this.dt=null,this.Mi(root,"resize",this.lb,!1),this.Mi(root,"wheel",this.ta,!0),Diagram.mm()===this&&Diagram.aL(null)}else this.Zl===null&&(this.Jn=!1);if(this.Tt=null,t!==null){const e=Diagram.Ve.get(t);e&&(e.div=null),this.mM(t),this.yu(),this.themeManager&&this.themeManager.VF()}else this.themeManager&&this.themeManager.zF()}}setupRouters(){this.zc.push(new AvoidsNodesRouter)}mM(t){const i=this;if(!Diagram.isUsingDOM())return;t==null&&Util.o("Diagram setup requires an argument DIV."),i.Tt!==null&&Util.o("Diagram has already completed setup."),typeof t=="string"?i.Tt=root.document.getElementById(t):t instanceof HTMLDivElement?i.Tt=t:Util.o("No DIV or DIV id supplied: "+t),i.Tt===null&&Util.o("Invalid DIV id; could not get element with id: "+t);const e=Diagram.Ve.get(i.Tt);if(e&&e!==this&&Util.o("Invalid div id; div already has a Diagram associated with it."),!i.Bc&&root.ResizeObserver){const c=root.ResizeObserver,f=Util.Nk(()=>i.requestUpdate(),250,!1);i.Bc=new c(()=>f()),i.Bc.observe(i.Tt)}root.getComputedStyle(i.Tt,null).position==="static"&&(i.Tt.style.position="relative");let s=5;const n="rgba(2"+s+"5, 255, 255, 0)";s--,i.Tt.style["-webkit-tap-highlight-color"]=n,i.Tt.innerHTML="",Diagram.Ve.set(i.Tt,i),i.Tt.goDiagram=i,i.Tt.go=root.go;const o=new CanvasSurface(i);o.style!==void 0&&(o.style.position="absolute",o.style.top="0px",o.style.left="0px",root.getComputedStyle(i.Tt,null).getPropertyValue("direction")==="rtl"&&(i.Xu=!0),o.style.zIndex="2",o.style.userSelect="none",o.style.MozUserSelect="none",o.style.touchAction="none",o.style.letterSpacing="normal !important",o.style.wordSpacing="normal !important",o.style.lang="unknown"),i.dt=o,i.Zt=o.ai;const r=i.Zt;i.Ui=i.computePixelRatio(),i.viewSize.isReal()||(i.kt=i.Tt.clientWidth||1,i.Pt=i.Tt.clientHeight||1),i.pL(i.kt,i.Pt);const l=i;i.Tt.insertBefore(o.Ft,i.Tt.firstChild);const h=new CanvasSurface(null);if(h.width=1,h.height=1,i.AF=h,i.TF=h.ai,Diagram.isUsingDOM()){const c=Util.en("div"),f=Util.en("div");c.style.position="absolute",c.style.overflow="auto",c.style.width=i.kt+"px",c.style.height=i.Pt+"px",c.style.zIndex="1",f.style.position="absolute",f.style.width="1px",f.style.height="1px",i.Tt.appendChild(c),c.appendChild(f),c.onscroll=Diagram.XF,c.addEventListener("pointerdown",Diagram.KF),c.p=i,c.YF=!0,c.GF=!0,i.nb=c,i.ob=f}i.yu=Util.Nk(()=>{i.Pl=null,i.C()},300,!1),i.lb=Util.Nk(()=>{i.MS()},250,!1),i.Yh=c=>(c.preventDefault(),!1),i.ta=c=>{if(!l.isEnabled)return;const f=l.Xc(c,!0);f.bubbles=!0;let u=0,d=0;f.delta=0,c.deltaX!==void 0?(c.deltaX!==0&&(u=c.deltaX>0?1:-1),c.deltaY!==0&&(d=c.deltaY>0?1:-1),f.delta=Math.abs(c.deltaX)>Math.abs(c.deltaY)?-u:-d):c.wheelDeltaX!==void 0?(c.wheelDeltaX!==0&&(u=c.wheelDeltaX>0?-1:1),c.wheelDeltaY!==0&&(d=c.wheelDeltaY>0?-1:1),f.delta=Math.abs(c.wheelDeltaX)>Math.abs(c.wheelDeltaY)?-u:-d):c.wheelDelta!==void 0&&c.wheelDelta!==0&&(f.delta=c.wheelDelta>0?1:-1),l.doMouseWheel(),l.oa(f,c)},i.lL=c=>{if(!l.isEnabled)return;i.Uc=!1,l.Xc(c,!0);const f=l.currentTool;f.cancelWaitAfter(),f.standardMouseOver()},i.Zl=c=>{if(!l.isEnabled)return;i.Uc=!0;const f=l.sb;f[c.pointerId]===void 0&&(f[c.pointerId]=c);const u=l._h;let d=!1;if(u[0]!==null&&(u[0].pointerId===c.pointerId||u[0].pointerType!==c.pointerType))u[0]=c;else if(u[1]!==null&&u[1].pointerId===c.pointerId)u[1]=c,d=!0;else if(u[0]===null)u[0]=c;else if(u[1]===null)u[1]=c,d=!0;else{c.preventDefault();return}const m=c.pointerType==="touch"||c.pointerType==="pen";m&&(l.Bw=!1,l.Zm=!0);const g=l.jF(c,c,d),p=l.aM,y=m?25:10;if(c.timeStamp-l.hMy||Math.abs(p.y-c.screenY)>y)?l.$m++:l.$m=1,g.clickCount=l.$m,l.hM=c.timeStamp,l.aM.setTo(c.screenX,c.screenY),l.doMouseDown(),c.button===1){c.preventDefault();return}l.oa(g,c)},i.ia=c=>{if(!l.isEnabled)return;i.Uc=!0;const f=l._h;if(f[0]!==null&&(f[0].pointerId===c.pointerId||f[0].pointerType!==c.pointerType))f[0]=c;else if(f[1]!==null&&f[1].pointerId===c.pointerId){f[1]=c;return}else if(f[0]===null)f[0]=c;else return;if(f[0].pointerId!==c.pointerId)return;const u=l.HF(c,c,f[1]!==null);l.doMouseMove(),l.oa(u,c)},i.ea=c=>{if(!l.isEnabled)return;i.Uc=!0;const f=c.pointerType==="touch"||c.pointerType==="pen",u=l.sb;if(f&&l.Bw){delete u[c.pointerId],c.preventDefault();return}const d=l._h;if(d[0]!==null&&(d[0].pointerId===c.pointerId||d[0].pointerType!==c.pointerType))d[0]=null;else if(d[1]!==null&&d[1].pointerId===c.pointerId){d[1]=null;return}else return;const m=l.pM(c,!1,!0,!1,!0,!1);let g=root.document.elementFromPoint(c.clientX,c.clientY)||null;g!==null&&g.shadowRoot!==void 0&&g.shadowRoot!==null&&(g=g.shadowRoot.elementFromPoint(c.clientX,c.clientY)),g!==null&&g.p instanceof Diagram&&g.p!==l&&g.p.s0(c,m),g===null&&(g=c.target),l.s0(c,m),m.clickCount=l.$m,m.targetDiagram=l.yM(c,g),m.targetObject=null,l.doMouseUp(),l.oa(m,c),f&&(l.Zm=!1)},i.sa=c=>{if(!l.isEnabled)return;i.Uc=!1;const f=l.sb;f[c.pointerId]&&delete f[c.pointerId];const u=l._h;if(u[0]!==null&&u[0].pointerId===c.pointerId&&(u[0]=null),u[1]!==null&&u[1].pointerId===c.pointerId&&(u[1]=null),c.pointerType==="touch"||c.pointerType==="pen")return;const d=l.currentTool;d.cancelWaitAfter(),d.standardMouseOver()},i.na=c=>{const f=l._h;f[0]!==null&&f[0].pointerId===c.pointerId?(f[0]=null,l.Zm=!1):f[1]!==null&&f[1].pointerId===c.pointerId&&(f[1]=null)};const a=r;if(i.rb=a.U[Util.Cs("7eba17a4ca3b1a8346")][Util.Cs("78a118b7")](a.U,Diagram.Ku,s,s),r.clearContextCache(!0),i.qF(),this.Ic==="svg"){const c=this.Wl.get("svg");this.Tt.appendChild(c.Ft),this.Zt=c.ai}}addEventListener(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}Vt(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}removeEventListener(t,i,e,s){t.removeEventListener(i,e,{capture:s})}Mi(t,i,e,s){t.removeEventListener(i,e,{capture:s})}qF(){const t=this;let i=this.dt.Ft;i instanceof HTMLCanvasElement||(i=t.div),this.Vt(i,"pointerdown",t.Zl,!1),this.Vt(i,"pointermove",t.ia,!1),this.Vt(i,"pointerup",t.ea,!1),this.Vt(i,"pointerout",t.sa,!1),this.Vt(i,"pointercancel",t.na,!1),this.Vt(i,"pointerenter",t.WF,!1),this.Vt(i,"pointerleave",t.JF,!1),this.Vt(i,"wheel",t.ta,!1),this.Vt(i,"keydown",t.$F,!1),this.Vt(i,"keyup",t.ZF,!1),this.Vt(i,"blur",t.QF,!1),this.Vt(i,"focus",t._F,!1),this.Vt(i,"selectstart",e=>(e.preventDefault(),!1),!1),this.Vt(i,"contextmenu",e=>(e.preventDefault(),!1),!1),this.Vt(root,"resize",t.lb,!1)}Uw(){this.Qm>30&&(this.Pl=1)}yP(t){this.Pl!==null&&(this.Pl=null,t&&this.yu(),this.Qm=0,this.uM=[0,0,0,0,0],this._m=0)}computePixelRatio(){return this.Pl!==null?this.Pl:root.devicePixelRatio||1}get avgSpf(){return this.Qm}doMouseDown(){this.currentTool.doMouseDown()}doMouseMove(){this.currentTool.doMouseMove()}doMouseUp(){this.currentTool.doMouseUp()}doMouseWheel(){this.currentTool.doMouseWheel()}doKeyDown(){this.currentTool.doKeyDown()}doKeyUp(){this.currentTool.doKeyUp()}doFocus(){this.focus()}focus(){if(this.dt)if(this.scrollsPageOnFocus)this.dt.focus();else{const t=root.scrollX,i=root.scrollY;this.dt.focus(),root.scrollTo(t,i)}}_F(t){const i=Diagram.Ve.get(this);i&&i.v("GainedFocus")}QF(t){const i=Diagram.Ve.get(this);i&&i.v("LostFocus")}MS(){if(this.dt===null)return;const i=this.Tt;if(i===null||i.clientWidth===0||i.clientHeight===0)return;this.VS||this.setScrollWidth();const e=this.Wn?this.di:0,s=this.gn?this.di:0,n=this.Ui;if(this.Ui=this.computePixelRatio(),this.Ui!==n&&(this.Ru=!0,this.requestUpdate()),i.clientWidth!==this.kt+e||i.clientHeight!==this.Pt+s){this.ra(),this.Ue=!0;const o=this.layout;o!==null&&o.isViewportSized&&this.autoScale===1&&(this.Oc=!0,o.invalidateLayout()),this.ps||this.requestUpdate()}}fL(){let t=0,i=new Layer;i.name="Grid",i.allowSelect=!1,i.pickable=!1,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="ViewportBackground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="Background",this.Gr(i,t++),i=new Layer,i.name="",this.Gr(i,t++),i=new Layer,i.name="Foreground",this.Gr(i,t++),i=new Layer,i.name="ViewportForeground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="Adornment",i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="Tool",i.isTemporary=!0,i.isInDocumentBounds=!0,this.Gr(i,t++)}yL(){const t=new Panel(Panel.Grid,{name:"GRID"}).add(new Shape("LineH",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineV",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineH",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineH",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor")),i=new Part({layerName:"Grid",zOrder:0,isInDocumentBounds:!1,isAnimated:!1,pickable:!1,locationObjectName:"GRID"}).add(t);return this.add(i),this.partManager.parts.delete(i),t.visible=!1,t}static XF(){const t=Diagram.Ve.get(this.parentElement||this);if(t){if(t.Jx){t.Jx=!1;return}if(!t.isEnabled){t.wL();return}t.diagramScroll(this)}}static KF(t){if(!this.p.isEnabled){this.p.updateScroll();return}this.p.$x=t.target.scrollTop,this.p.Zx=t.target.scrollLeft}diagramScroll(t){if(this.dt===null)return;const i=this.nb,e=this.ob;this.Km=!0;let s=this.documentBounds,n=this.viewportBounds;const o=this.Fc;let r=s.x-o.left,l=s.y-o.top;const h=s.width+o.left+o.right,a=s.height+o.top+o.bottom;let c=s.right+o.right,f=s.bottom+o.bottom,u=n.x,d=n.y;const m=n.width,g=n.height;let p=n.right,y=n.bottom;const x=this.scale;let k,b=t.scrollLeft;if(this.Xu)switch(this.wx){case"negative":b=b+t.scrollWidth-t.clientWidth;break;case"reverse":b=t.scrollWidth-b-t.clientWidth;break}const P=b;if(mp)){const S=i.scrollWidth-this.kt;this.position=k.e(-S+P-this.kt/x+c,this.position.y)}if(t.GF&&this.allowVerticalScroll&&(ly)){const S=i.scrollHeight-this.Pt;this.position=k.e(this.position.x,-S+t.scrollTop-this.Pt/x+f)}Point.s(k),this._l(),this.Km=!1,this.Eu=!1,s=this.documentBounds,n=this.viewportBounds,c=s.right,p=n.right,f=s.bottom,y=n.bottom,r=s.x,u=n.x,l=s.y,d=n.y,m>=h&&r>=u&&c<=p&&(e.style.width="1px"),g>=a&&l>=d&&f<=y&&(e.style.height="1px")}computeBounds(t){return t===void 0&&(t=new Rect),this.Ci(),this.xL(t)}xL(t){if(this.fixedBounds.isReal())return t.a(this.fixedBounds),t.addMargin(this.$t),t;let i=!0;const e=this.Gt.r,s=e.length;for(let n=0;ni&&(a=i),athis.maxScale&&(a=this.maxScale),a):t===3?(a=0,h>l?a=(r-this.di)/n:a=(o-this.di)/s,a>i&&(a=i),athis.maxScale&&(a=this.maxScale),a):this.scale}zoomToFit(){const t=this.jh;this.jh=1,this.scale=this.Yu(2),t!==1&&(this.Us(!1),this.wM(this.documentBounds,this.kt/this.et,this.Pt/this.et,this.Rc,!1)),this.jh=t}zoomToRect(t,i){i===void 0&&(i=2);const e=t.width,s=t.height;if(e===0||s===0||isNaN(e)&&isNaN(s))return;let n=1;if(i===2||i===3)if(isNaN(e))n=this.viewportBounds.height*this.scale/s;else if(isNaN(s))n=this.viewportBounds.width*this.scale/e;else{const o=this.kt,r=this.Pt;i===3?r/s>o/e?n=(r-(this.gn?this.di:0))/s:n=(o-(this.Wn?this.di:0))/e:n=Math.min(r/s,o/e)}this.scale=n,this.position=new Point(t.x,t.y)}get tR(){return this.Ht}set tR(t){this.Ht=t}alignDocument(t,i){this.ensureBounds();const e=this.documentBounds,s=this.viewportBounds;this.position=new Point(e.x+(t.x*e.width+t.offsetX)-(i.x*s.width-i.offsetX),e.y+(t.y*e.height+t.offsetY)-(i.y*s.height-i.offsetY))}focusObject(t){if(t instanceof GraphObject){this.t0=t;const i=Point.l();this.i0=this.transformDocToView(t.getDocumentPoint(Spot.TopLeft,i)),Point.s(i)}else this.t0=null,this.i0=Point.Ak}wM(t,i,e,s,n){const o=Point.X(this.at.x,this.at.y);let r=o.x,l=o.y;if(this.t0!==null){let h=Point.l();h=this.t0.getDocumentPoint(Spot.TopLeft,h),r=h.x-this.i0.x/this.scale,l=h.y-this.i0.y/this.scale,s=Spot.None,Point.s(h)}if(n||this.scrollMode===1){s.isSpot()&&(i>t.width&&(r=t.x+(s.x*t.width+s.offsetX)-(s.x*i-s.offsetX)),e>t.height&&(l=t.y+(s.y*t.height+s.offsetY)-(s.y*e-s.offsetY)));const h=this.Fc,a=i-t.width;if(it.left?r=t.left:rt.top?l=t.top:ls.part,s=>s.canSelect());if(e instanceof Part)return e}else{const e=this.PP(t,s=>s.part);if(e instanceof Part)return e}return null}findObjectAt(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Ci();const s=this.Gt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}PP(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Ci();const s=this.Gt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible||n.isTemporary)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}findPartsAt(t,i,e){return i===void 0&&(i=!0),this.eR(t,s=>s.part,i?s=>s instanceof Part&&s.canSelect():null,e)}eR(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Ci();const n=this.Gt.iteratorBackwards;for(;n.next();){const o=n.value;!o.visible||o.isTemporary||o.findObjectsAt(t,i,e,s)}return s}findObjectsAt(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Ci();const n=this.Gt.iteratorBackwards;for(;n.next();){const o=n.value;o.visible&&o.findObjectsAt(t,i,e,s)}return s}findPartsIn(t,i,e,s){return i===void 0&&(i=!1),e===void 0&&(e=!0),this.sR(t,null,n=>n instanceof Part&&(!e||n.canSelect()),i,s)}findObjectsIn(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Ci();const o=this.Gt.iteratorBackwards;for(;o.next();){const r=o.value;r.visible&&r.findObjectsIn(t,i,e,s,n)}return n}NP(t,i,e,s,n,o){const r=new GSet;this.Ci();const l=this.Gt.iteratorBackwards;for(;l.next();){const h=l.value;h.visible&&h.NP(t,i,e,s,r,n,o)}return r}sR(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Ci();const o=this.Gt.iteratorBackwards;for(;o.next();){const r=o.value;!r.visible||r.isTemporary||r.findObjectsIn(t,i,e,s,n)}return n}findPartsNear(t,i,e,s,n){return e===void 0&&(e=!0),s===void 0&&(s=!0),this.nR(t,i,null,o=>o instanceof Part&&(!s||o.canSelect()),e,n)}findObjectsNear(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Ci();const r=this.Gt.iteratorBackwards;for(;r.next();){const l=r.value;l.visible&&l.findObjectsNear(t,i,e,s,n,o)}return o}nR(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Ci();const r=this.Gt.iteratorBackwards;for(;r.next();){const l=r.value;!l.visible||l.isTemporary||l.findObjectsNear(t,i,e,s,n,o)}return o}acceptEvent(t){return this.Xc(t,t instanceof MouseEvent)}Xc(t,i){const e=this.Xr;this.Xr=this.$h,this.$h=e,e.diagram=this,e.event=t,i?this.s0(t,e):(e.viewPoint=this.Xr.viewPoint,e.documentPoint=this.Xr.documentPoint);let s=0;const n=t;return n.ctrlKey&&(s+=1),n.altKey&&(s+=2),n.shiftKey&&(s+=4),n.metaKey&&(s+=8),e.modifiers=s,e.button=n.button,n.buttons!==void 0&&(e.buttons=n.buttons),Util.rr&&n.button===0&&n.ctrlKey&&(e.button=2),e.down=!1,e.up=!1,e.clickCount=1,e.delta=0,e.handled=!1,e.bubbles=!1,e.timestamp=t.timeStamp,e.isMultiTouch=!1,e.targetDiagram=this.yM(t,t.target),e.targetObject=null,e}yM(t,i){if(i===null)return null;const e=Diagram.Ve.get(i);if(e)return e;let s=t.path;if(!s&&typeof t.composedPath=="function"&&(s=t.composedPath()),s&&s[0]){const n=Diagram.Ve.get(s[0]);if(n)return n}return null}jF(t,i,e){const s=this.pM(t,!0,!1,!1,!0,e);return this.s0(i,s),s.targetDiagram=this.yM(t,t.target),s.targetObject=null,e||s.clone(this.Wm),s}HF(t,i,e){const s=this.pM(t,!1,!1,!1,!1,e);let n=root.document.elementFromPoint(i.clientX,i.clientY)||null;n!==null&&n.shadowRoot!==void 0&&n.shadowRoot!==null&&(n=n.shadowRoot.elementFromPoint(i.clientX,i.clientY));let o=this,r=t;if(n){const l=Diagram.Ve.get(n);l&&(r=i,o=l)}return s.targetDiagram=o,this.s0(r,s),s.targetObject=null,s}pM(t,i,e,s,n,o){const r=this.Xr;this.Xr=this.$h,this.$h=r,r.diagram=this,r.clickCount=1,r.delta=0;let l=0;return t.ctrlKey&&(l+=1),t.altKey&&(l+=2),t.shiftKey&&(l+=4),t.metaKey&&(l+=8),r.modifiers=l,r.event=t,r.timestamp=t.timeStamp,r.button=e?this.firstInput.button:t.button,r.buttons=t.buttons,Util.rr&&t.button===0&&t.ctrlKey&&(r.button=2),r.down=i,r.up=e,r.handled=s,r.bubbles=n,r.isMultiTouch=o,r}oa(t,i){return t.bubbles?!0:(i.stopPropagation!==void 0&&i.stopPropagation(),i.cancelable!==!1&&i.preventDefault(),i.cancelBubble=!0,!1)}$F(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.Xc(t,!1);return e.key=t.key,e.code=t.code,e.down=!0,i.doKeyDown(),i.oa(e,t)}ZF(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.Xc(t,!1);return e.key=t.key,e.code=t.code,e.up=!0,i.doKeyUp(),i.oa(e,t)}WF(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.Xc(t,!0);return i.mouseEnter!==null&&i.mouseEnter(e),i.currentTool.standardMouseOver(),i.oa(e,t)}JF(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.Xc(t,!0);return i.mouseLeave!==null&&i.mouseLeave(e),i.oa(e,t)}getMouse(t){const i=this.dt;if(i===null)return new Point(0,0);const e=i.getBoundingClientRect(),s=(t.clientX-e.left)*(this.kt/e.width),n=(t.clientY-e.top)*(this.Pt/e.height);return new Point(s,n).Ie(this.D)}s0(t,i){const e=this.dt;let s=0,n=0;if(e!==null){const r=e.getBoundingClientRect();s=(t.clientX-r.left)*(this.kt/r.width),n=(t.clientY-r.top)*(this.Pt/r.height)}i.viewPoint.e(s,n);const o=Point.X(s,n);this.D._e(o),i.documentPoint.a(o),Point.s(o)}kC(t,i,e){let s;if(this._h[0]!==null)s=this._h[i];else return;const n=this.dt;if(n!==null){const o=n.getBoundingClientRect();e.e((s.clientX-o.left)*(this.kt/o.width),(s.clientY-o.top)*(this.Pt/o.height))}}invalidateDocumentBounds(){this.Zh||(this.Zh=!0,this.requestUpdate(!1))}oR(){this.ps||this.Ci(),this.ensureBounds()}redraw(){this.Ht||this.ps||(this.C(),this.maybeUpdate())}isUpdateRequested(){return this.Pr}delayInitialization(t){t===void 0&&(t=null);const i=this.animationManager,e=i.isEnabled;i.stopAnimation(),i.isEnabled=!1,this.yr(),this.Jn=!1,this.ex=new Point(NaN,NaN),i.isEnabled=e,this.ps=!0;const s=this;t!==null&&Util.Oh(()=>{s.ps=!1,i.Fl("Model"),t(s)},1)}requestUpdate(t){if(t===void 0&&(t=!1),this.Pr===!0||this.Ht||t===!1&&this.ps)return;this.Pr=!0;const i=this;root.requestAnimationFrame(()=>{i.Pr&&i.maybeUpdate()})}maybeUpdate(){this.vu&&!this.Pr||(this.vu&&(this.vu=!1),this.yr())}xM(t,i){!this.Eu||this.Ht||this.animationManager.defaultAnimation.isAnimating||this.wL()||(t&&this.Ci(),i&&this.Us(!1))}yr(t){if(this.ps||(this.Pr=!1,this.Tt===null&&!this.Bu.isReal()))return;this.ps=!0;const i=this.animationManager,e=this.zu;if(!i.isAnimating&&e.length!==0){const c=e.r,f=c.length;for(let u=0;u0&&(s.each(c=>c.bM()),s.clear());let n=!1,o=!1;i.defaultAnimation.isAnimating&&(o=!0,n=this.skipsUndoManager,this.skipsUndoManager=!0),i.wi||this.MS(),t||this.xM(!1,!0);const r=!this.undoManager.isUndoingRedoing&&(this.bl||this.zc.count!==0&&this.Lr.size!==0),l=!this.Jn||this.Kr;this.Ci(!0);let h=!1;(l||r)&&(this.Jn?this.kM(!this.Oc,r):(this.startTransaction("Initial Layout"),i.isEnabled===!1&&i.stopAnimation(),this.kM(!1,r)),h=l),this.Oc=!1,this.bl=!1,this.Ci(),this.ts!==null&&(this.ts.visible&&!this.Hm&&(this.jr(),this.Hm=!0),!this.ts.visible&&this.Hm&&(this.Hm=!1)),this.Bx||this.oR(),t||this.xM(!0,!1);let a=!1;if(h){const c=Rect.l();c.a(this.viewportBounds),this.Jn||(this.Jn=!0,a=!0,this.skipsUndoManager||(this.undoManager.Ow=!0),this.undoManager.Iw=!0,this.rR()),this.lR(),this.Ci(!1),t||this.xM(!0,!0),Rect.s(c)}else if(i.Sc&&i.ix){if(this.Cr!==1)this.scale=this.Yu(this.Cr);else if(this.jl!==1)this.scale=this.Yu(this.jl);else{const c=this.initialScale;isFinite(c)&&c>0&&(this.scale=c)}this.Us(!0)}h&&a&&this.commitTransaction("Initial Layout"),t||this.Gi(this.Zt),o&&(this.skipsUndoManager=n),this.ps=!1}get Bh(){return this.Jn}rR(){if(this.Cr!==1)this.scale=this.Yu(this.Cr);else if(this.jl!==1)this.scale=this.Yu(this.jl);else{const i=this.initialScale;isFinite(i)&&i>0&&(this.scale=i)}this.Us(!0);const t=this.Gt.r;this.Bs(t,t.length,this,this.viewportBounds),this.v("InitialLayoutCompleted"),this.ex.a(this.at),this.jr()}lR(){this.v("LayoutCompleted")}o0(t){this.Hn.add(t)}addInvalidRoute(t){this.Fo?this.Wh.add(t):this.Lr.add(t)}Ci(t){if(this.Hn.size!==0&&!(!this.ps&&this.animationManager.isTicking)){if(this.ps||(this.bl=!0),t){this.bL(this.Hn);return}for(let i=0;i<23&&this.Hn.size!==0;i++){const e=new Set(this.Hn);this.Hn.clear(),this.bM(e,this.Hn)}this.nodes.each(i=>{i instanceof Group&&i.kL(!1)})}}bL(t,i){for(const e of t)!e.Pe()||e instanceof Group||(e.Hr()?(e.ut(1/0,1/0),e.zt()):i&&i.add(e));for(const e of t)if(e instanceof Group){if(!e.isVisible())continue;this.yb(e)}}bM(t,i){this.bL(t,i);for(const e of t){if(!(e instanceof Link))continue;const s=e;s.isVisible()&&(s.Hr()?(s.ut(1/0,1/0),s.zt()):i.add(s))}for(const e of t)e instanceof Adornment&&e.isVisible()&&(e.Hr()?(e.ut(1/0,1/0),e.zt()):i.add(e))}r0(t){const i=t instanceof Diagram,e=i?t.links:t.memberParts,s=this.Hn;if(i)this.Ci(!0);else{for(;e.next();){const n=e.value;s.has(n)&&(!n.Pe()||n instanceof Group||n.Hr()&&(n.ut(1/0,1/0),n.zt()))}for(e.reset();e.next();){const n=e.value;if(s.has(n)&&n instanceof Group){if(!n.isVisible())continue;this.yb(n)}}e.reset()}for(;e.next();){const n=e.value;n instanceof Link&&s.has(n)&&n.isVisible()&&n.Hr()&&(n.ut(1/0,1/0),n.zt())}}yb(t){const i=Util.nt(),e=Util.nt(),s=t.memberParts;for(;s.next();){const o=s.value;o.isVisible()&&(o instanceof Group?(o.Oo()||o.is()||o.th())&&this.yb(o):o instanceof Link?o.fromNode===t||o.toNode===t?e.push(o):i.push(o):(o.ut(1/0,1/0),o.zt()))}let n=i.length;for(let o=0;ob.Du())}else for(let x=0;x0){const a=n.substring(0,h);e?o=t.findObject(a):(o=t[a],o==null&&(o=t.toolManager[a])),Util.wt(o)?r=n.substring(h+1):Util.o("Unable to find object named: "+a+" in "+t.toString()+" when trying to set property: "+n)}}if(r[0]!=="_"&&!Util.fw(o,r))if(s&&r==="ModelChanged"){t.addModelChangedListener(i[r]);continue}else if(s&&r==="Changed"){t.addChangedListener(i[r]);continue}else if(s&&Util.fw(t.toolManager,r))o=t.toolManager;else if(s&&t.PL(r)){t.addDiagramListener(r,i[r]);continue}else if(t instanceof Model&&r==="Changed"){t.addChangedListener(i[r]);continue}else Util.o('Trying to set undefined property "'+r+'" on object: '+o.toString());const l=i[n];o[r]=l,r[0]==="_"&&o instanceof GraphObject&&o.addCopyProperty(r)}}_C(){if(this.$l.count!==0&&!(this.undoManager.transactionLevel>1)){for(;this.$l.count>0;){const t=this.$l;this.$l=new GMap;const i=t.iterator;for(;i.next();){const e=i.key;e.invalidateOtherJumpOvers(i.value),e.ee()}}this.C()}}C(t){if(t===void 0)this.Ue=!0,this.requestUpdate();else{const i=this.viewportBounds;t.isReal()&&i.intersectsRect(t)&&(this.Ue=!0,this.requestUpdate())}this.v("InvalidateDraw")}invalidateViewport(t,i){if(this.Ue===!0)return;if(this.Ue=!0,this.Ic==="svg"){this.maybeUpdate();return}this.getRenderingHint("temporaryPixelRatio")===!0?(this.Uw(),this.maybeUpdate(),this.yP(!0)):this.maybeUpdate()}ra(){this.Eu=!0}_l(){this.Ec=!0}l0(){this.Ru!==!1&&(this.Ru=!1,this.pL(this.kt,this.Pt))}pL(t,i){this.Ql();const e=this.Ui,s=t*e,n=i*e;this.dt.resize(s,n,t,i)&&(this.Ue=!0,this.Zt.clearContextCache(!0))}wL(){const t=this.dt;if(t===null||this.Bu.isReal())return!0;const i=this.kt,e=this.Pt,s=this.Tt;let n=!1,o=this.Wn?this.di:0,r=this.gn?this.di:0,l=s.clientWidth||i+o,h=s.clientHeight||e+r;const a=this.viewportBounds,c=a.x,f=a.y,u=a.width,d=a.height;if((l!==i+o||h!==e+r)&&(this.Wn=!1,this.gn=!1,o=0,r=0,this.kt=l,this.Pt=h,this.Ru=!0,n=!0,this.Ql()),!this.Jn||!this.viewportBounds.isReal())return!0;const m=this.nb,g=this.ob;if(this.Eu=!1,!n&&!this.Wn&&!this.gn&&!this.Ou&&!this.Iu)return!0;const p=this.documentBounds;let y=0,x=0,k=0,b=0;const P=a.width,S=a.height,L=this.Fc;this.contentAlignment.isSpot()?(p.width>P&&(y=L.left,x=L.right),p.height>S&&(k=L.top,b=L.bottom)):(y=L.left,x=L.right,k=L.top,b=L.bottom);const C=p.width+y+x,M=p.height+k+b,N=this.scale,T=N;let A=C>l/N,D=M>h/N;if(!n&&!this.Wn&&!this.gn&&!A&&!D)return!0;const F=p.x-y,R=a.x,v=p.right+x;let O=a.right+o;const B=p.y-k,X=a.y,E=p.bottom+b;let V=a.bottom+r,U="1px",Y="1px";if(this.scrollMode===1&&(A||D)){if(A&&this.hasHorizontalScrollbar&&this.allowHorizontalScroll){let z=1;F+1O+1&&(z=Math.max((v-O)*N+this.kt,z)),P+o+1V+1&&(z=Math.max((E-V)*N+this.Pt,z)),S+r+1O+1&&(W=Math.max((v-O)*N+this.kt,W)),P+1V+1&&(W=Math.max((E-V)*N+z,W)),S+1O+1&&(J=this.position.x*N)),this.Xu)switch(this.wx){case"negative":J=-(m.scrollWidth-J-m.clientWidth);break;case"reverse":J=m.scrollWidth-J-m.clientWidth;break}if(m.scrollLeft=J,this.hasVerticalScrollbar&&this.allowVerticalScroll&&(S+1V+1&&(m.scrollTop=this.position.y*N)),l=this.kt,h=this.Pt,m.style.width=l+(this.Wn?this.di:0)+"px",m.style.height=h+(this.gn?this.di:0)+"px",i!==l||e!==h||this.animationManager.wi){const z=Rect.X(c,f,u,d);return this.onViewportBoundsChanged(z,this.viewportBounds,T,n),Rect.s(z),!1}return!0}add(t){const i=t.diagram;if(i===this)return;i!==null&&Util.o("Cannot add part "+t.toString()+" to "+this.toString()+". It is already a part of "+i.toString());let e=this.findLayer(t.layerName);if(e===null&&(e=this.findLayer("")),e===null&&Util.o('Cannot add a Part when unable find a Layer named "'+t.layerName+'" and there is no default Layer'),t.layer===e)return;const s=e.qh(99999999,t,t.diagram===this);s>=0&&this.raiseChangedEvent(3,"parts",e,null,t,null,s),e.isTemporary||this.invalidateDocumentBounds(),t.invalidateLayout(1);const n=t.layerChanged;n!==null&&n(t,null,e)}qh(t){this.partManager.qh(t);const i=this;t.qr(s=>i.SL(s)),t.data||t.Io(),t.hasPlaceholder()&&t.c(),t.data!==null&&t.qr(s=>i.partManager.SM(s,null)),(t.is()===!0||t.th()===!0)&&this.o0(t),t.ML(!0,this),t.NL()?(t.actualBounds.isReal()&&this.C(t.Hh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.C(t.Hh(t.actualBounds)),this.requestUpdate()}te(t){t.clearAdornments(),this.partManager.te(t);const i=this;t.data!==null&&t.qr(s=>i.partManager.MM(s,i)),this.Hn.delete(t),t instanceof Link&&this.Lr.delete(t),t.NL()?(t.actualBounds.isReal()&&this.C(t.Hh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.C(t.Hh(t.actualBounds)),this.requestUpdate()}remove(t){this.NM(t,!0)}NM(t,i){const e=t.layer;if(e===null||e.diagram!==this)return;t.isSelected=!1,t.isHighlighted=!1,t.invalidateLayout(2),i&&t.Kc();const s=e.te(-1,t,!1);s>=0&&this.raiseChangedEvent(4,"parts",e,t,null,s,null);const n=t.layerChanged;n!==null&&n(t,e,null)}removeParts(t,i){if(i===void 0&&(i=!1),Array.isArray(t)){const e=t.length;for(let s=0;s=0&&i.elt(e).isTemporary;)e--;return i.insertAt(e+1,t),this.Si!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,e+1),this.C(),this.invalidateDocumentBounds(),this}addLayerBefore(t,i){this.CM(t,i),t.To(this);const e=this.Gt,s=e.indexOf(t);s>=0&&(e.delete(t),this.Si!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;o=0&&(e.delete(t),this.Si!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;othis.maxScale&&(i=this.maxScale);const c=Point.X(this.at.x+l/t-l/i,this.at.y+h/t-h/i);this.position=c,Point.s(c),this.et=i,this.Ql(),this.Ht=!1,this.onViewportBoundsChanged(n,this.viewportBounds,t,!1),this.Us(!1),e.ZC(t,this.et),this.C()}iR(){const t=this.Gt.r;for(let i=0;i{r.isAvoiding&&r.actualBounds.intersectsRect(i)&&r.invalidateRoute()})}jr(t){const i=this.ts;if(i===null||!i.visible||i.layer===null)return;const e=t!==void 0?t:this._x;if(!e.isReal())return;const s=e.width,n=e.height;if(i.scale=1,i.angle=0,i.layer.isViewportAligned)i.width=s*this.scale,i.height=n*this.scale,i.part.alignment=Spot.TopLeft;else{i.xi===null&&(i.xi=new GridPanelSettings);const o=i.xi.Yc;if(!o.isReal())return;i.width=s+o.width*2,i.height=n+o.height*2;const r=Point.l();Geo.Ig(e.x,e.y,0,0,o.width,o.height,r),r.offset(-o.width,-o.height),i.part.location=r,Point.s(r)}}clearSelection(t){t===void 0&&(t=!1);const i=this.selection;if(i.count===0)return;t||this.v("ChangingSelection",i);const e=i.toArray(),s=e.length;for(let n=0;n1)&&(this.v("ChangingSelection",this.selection),this.clearSelection(!0),t.isSelected=!0,this.v("ChangedSelection",this.selection))}selectCollection(t){if(this.v("ChangingSelection",this.selection),this.clearSelection(!0),Array.isArray(t)){const i=t.length;for(let e=0;e0){const i=t.toArray(),e=i.length;for(let s=0;s1)&&(this.clearHighlighteds(),t.isHighlighted=!0)}highlightCollection(t){const i=new GSet().addAll(t),s=this.highlighteds.copy().removeAll(i).iterator;for(;s.next();){const o=s.value;o.isHighlighted=!1}const n=i.iterator;for(;n.next();){const o=n.value;o instanceof Part||Util.o("Diagram.highlightCollection given something that is not a Part: "+o),o.isHighlighted=!0}}scroll(t,i,e){e===void 0&&(e=1);const s=i==="up"||i==="down";let n=0;const o=Point.l();if(t==="pixel")n=e;else if(t==="line")n=e*(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange);else if(t==="page"){let l=s?this.viewportBounds.height:this.viewportBounds.width;if(l*=this.scale,l!==0){const h=Math.max(l-(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange),0);n=e*h}}else if(t==="document"){const l=this.documentBounds,h=this.viewportBounds;i==="up"?this.position=o.e(h.x,l.y):i==="left"?this.position=o.e(l.x,h.y):i==="down"?this.position=o.e(h.x,l.bottom-h.height):i==="right"&&(this.position=o.e(l.right-h.width,h.y)),Point.s(o);return}else Util.o("scrolling unit must be 'pixel', 'line', 'page', or 'document', not: "+t);n/=this.scale;const r=this.position;i==="up"?this.position=o.e(r.x,r.y-n):i==="down"?this.position=o.e(r.x,r.y+n):i==="left"?this.position=o.e(r.x-n,r.y):i==="right"?this.position=o.e(r.x+n,r.y):Util.o("scrolling direction must be 'up', 'down', 'left', or 'right', not: "+i),Point.s(o)}scrollToRect(t){const i=this.viewportBounds;if(i.containsRect(t))return;const e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}centerRect(t){const i=this.viewportBounds,e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}transformDocToView(t){return t.copy().D(this.D)}transformViewToDoc(t){return t.copy().Ie(this.D)}LF(t){return t.Ie(this.D)}static None=1;static Uniform=2;static UniformToFill=3;static CycleAll=1;static CycleNotDirected=2;static CycleNotDirectedFast=3;static CycleNotUndirected=4;static CycleDestinationTree=5;static CycleSourceTree=6;static DocumentScroll=1;static InfiniteScroll=2;static TreeParentCollapsed=1;static AllParentsCollapsed=2;static AnyParentsCollapsed=3;get opacity(){return this.Wt}set opacity(t){const i=this.Wt;i!==t&&(Util.i(t,"number",Diagram,"opacity"),(t<0||t>1)&&Util._(t,"0 <= value <= 1",Diagram,"opacity"),this.Wt=t,this.t("opacity",i,t),this.C())}get validCycle(){return this.Rx}set validCycle(t){const i=this.Rx;i!==t&&(this.Rx=t,this.t("validCycle",i,t))}get layers(){return this.Gt.iterator}get isModelReadOnly(){const t=this.Si;return t===null?!1:t.isReadOnly}set isModelReadOnly(t){const i=this.Si;i!==null&&(i.isReadOnly=t)}get isReadOnly(){return this.vo}set isReadOnly(t){const i=this.vo;i!==t&&(Util.i(t,"boolean",Diagram,"isReadOnly"),this.vo=t,this.t("isReadOnly",i,t))}get isEnabled(){return this.Oi}set isEnabled(t){const i=this.Oi;i!==t&&(Util.i(t,"boolean",Diagram,"isEnabled"),this.Oi=t,this.t("isEnabled",i,t))}get allowClipboard(){return this.Vx}set allowClipboard(t){const i=this.Vx;i!==t&&(Util.i(t,"boolean",Diagram,"allowClipboard"),this.Vx=t,this.t("allowClipboard",i,t))}get allowCopy(){return this.Rl}set allowCopy(t){const i=this.Rl;i!==t&&(Util.i(t,"boolean",Diagram,"allowCopy"),this.Rl=t,this.t("allowCopy",i,t))}get allowDelete(){return this.vl}set allowDelete(t){const i=this.vl;i!==t&&(Util.i(t,"boolean",Diagram,"allowDelete"),this.vl=t,this.t("allowDelete",i,t))}get allowDragOut(){return this.zx}set allowDragOut(t){const i=this.zx;i!==t&&(Util.i(t,"boolean",Diagram,"allowDragOut"),this.zx=t,this.t("allowDragOut",i,t))}get allowDrop(){return this.Xx}set allowDrop(t){const i=this.Xx;i!==t&&(Util.i(t,"boolean",Diagram,"allowDrop"),this.Xx=t,this.t("allowDrop",i,t))}get allowTextEdit(){return this.Ol}set allowTextEdit(t){const i=this.Ol;i!==t&&(Util.i(t,"boolean",Diagram,"allowTextEdit"),this.Ol=t,this.t("allowTextEdit",i,t))}get allowGroup(){return this.Il}set allowGroup(t){const i=this.Il;i!==t&&(Util.i(t,"boolean",Diagram,"allowGroup"),this.Il=t,this.t("allowGroup",i,t))}get allowUngroup(){return this.El}set allowUngroup(t){const i=this.El;i!==t&&(Util.i(t,"boolean",Diagram,"allowUngroup"),this.El=t,this.t("allowUngroup",i,t))}get allowInsert(){return this.Kx}set allowInsert(t){const i=this.Kx;i!==t&&(Util.i(t,"boolean",Diagram,"allowInsert"),this.Kx=t,this.t("allowInsert",i,t))}get allowLink(){return this.Bl}set allowLink(t){const i=this.Bl;i!==t&&(Util.i(t,"boolean",Diagram,"allowLink"),this.Bl=t,this.t("allowLink",i,t))}get allowRelink(){return this.Ul}set allowRelink(t){const i=this.Ul;i!==t&&(Util.i(t,"boolean",Diagram,"allowRelink"),this.Ul=t,this.t("allowRelink",i,t))}get allowMove(){return this.Vl}set allowMove(t){const i=this.Vl;i!==t&&(Util.i(t,"boolean",Diagram,"allowMove"),this.Vl=t,this.t("allowMove",i,t))}get allowReshape(){return this.zl}set allowReshape(t){const i=this.zl;i!==t&&(Util.i(t,"boolean",Diagram,"allowReshape"),this.zl=t,this.t("allowReshape",i,t))}get allowResize(){return this.Xl}set allowResize(t){const i=this.Xl;i!==t&&(Util.i(t,"boolean",Diagram,"allowResize"),this.Xl=t,this.t("allowResize",i,t))}get allowRotate(){return this.Kl}set allowRotate(t){const i=this.Kl;i!==t&&(Util.i(t,"boolean",Diagram,"allowRotate"),this.Kl=t,this.t("allowRotate",i,t))}get allowSelect(){return this.Yl}set allowSelect(t){const i=this.Yl;i!==t&&(Util.i(t,"boolean",Diagram,"allowSelect"),this.Yl=t,this.t("allowSelect",i,t))}get allowUndo(){return this.Yx}set allowUndo(t){const i=this.Yx;i!==t&&(Util.i(t,"boolean",Diagram,"allowUndo"),this.Yx=t,this.t("allowUndo",i,t))}get allowZoom(){return this.Gx}set allowZoom(t){const i=this.Gx;i!==t&&(Util.i(t,"boolean",Diagram,"allowZoom"),this.Gx=t,this.t("allowZoom",i,t))}get hasVerticalScrollbar(){return this.Iu}set hasVerticalScrollbar(t){const i=this.Iu;i!==t&&(Util.i(t,"boolean",Diagram,"hasVerticalScrollbar"),this.Iu=t,this.ra(),this.C(),this.t("hasVerticalScrollbar",i,t),this.Us(!1))}get hasHorizontalScrollbar(){return this.Ou}set hasHorizontalScrollbar(t){const i=this.Ou;i!==t&&(Util.i(t,"boolean",Diagram,"hasHorizontalScrollbar"),this.Ou=t,this.ra(),this.C(),this.t("hasHorizontalScrollbar",i,t),this.Us(!1))}get allowHorizontalScroll(){return this.jx}set allowHorizontalScroll(t){const i=this.jx;i!==t&&(Util.i(t,"boolean",Diagram,"allowHorizontalScroll"),this.jx=t,this.t("allowHorizontalScroll",i,t),this.Us(!1))}get allowVerticalScroll(){return this.Hx}set allowVerticalScroll(t){const i=this.Hx;i!==t&&(Util.i(t,"boolean",Diagram,"allowVerticalScroll"),this.Hx=t,this.t("allowVerticalScroll",i,t),this.Us(!1))}get scrollHorizontalLineChange(){return this.qx}set scrollHorizontalLineChange(t){const i=this.qx;i!==t&&(Util.i(t,"number",Diagram,"scrollHorizontalLineChange"),t<0&&Util._(t,">= 0",Diagram,"scrollHorizontalLineChange"),this.qx=t,this.t("scrollHorizontalLineChange",i,t))}get scrollVerticalLineChange(){return this.Wx}set scrollVerticalLineChange(t){const i=this.Wx;i!==t&&(Util.i(t,"number",Diagram,"scrollVerticalLineChange"),t<0&&Util._(t,">= 0",Diagram,"scrollVerticalLineChange"),this.Wx=t,this.t("scrollVerticalLineChange",i,t))}get lastInput(){return this.$h}set lastInput(t){this.$h=t}get previousInput(){return this.Xr}set previousInput(t){this.Xr=t}get firstInput(){return this.Wm}set firstInput(t){this.Wm=t}get currentCursor(){return this.vx}set currentCursor(t){if(t===""&&(t=this.Xm),this.vx!==t){Util.i(t,"string",Diagram,"currentCursor");const e=this.dt,s=this.Tt;if(e===null||s===null)return;this.vx=t;const n=e.style.cursor;e.style.cursor=t,s.style.cursor=t,e.style.cursor===n&&(e.style.cursor="-webkit-"+t,s.style.cursor="-webkit-"+t,e.style.cursor===n&&(e.style.cursor="-moz-"+t,s.style.cursor="-moz-"+t,e.style.cursor===n&&(e.style.cursor=t,s.style.cursor=t)))}}get defaultCursor(){return this.Xm}set defaultCursor(t){t===""&&(t="auto");const i=this.Xm;i!==t&&(Util.i(t,"string",Diagram,"defaultCursor"),this.Xm=t,this.t("defaultCursor",i,t))}get click(){return this.Tr}set click(t){const i=this.Tr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"click"),this.Tr=t,this.t("click",i,t))}get doubleClick(){return this.Dr}set doubleClick(t){const i=this.Dr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"doubleClick"),this.Dr=t,this.t("doubleClick",i,t))}get contextClick(){return this.Fr}set contextClick(t){const i=this.Fr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"contextClick"),this.Fr=t,this.t("contextClick",i,t))}get mouseOver(){return this.Rr}set mouseOver(t){const i=this.Rr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseOver"),this.Rr=t,this.t("mouseOver",i,t))}get mouseHover(){return this.vr}set mouseHover(t){const i=this.vr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseHover"),this.vr=t,this.t("mouseHover",i,t))}get mouseHold(){return this.Or}set mouseHold(t){const i=this.Or;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseHold"),this.Or=t,this.t("mouseHold",i,t))}get mouseDragOver(){return this.Ox}set mouseDragOver(t){const i=this.Ox;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseDragOver"),this.Ox=t,this.t("mouseDragOver",i,t))}get mouseDrop(){return this.Ir}set mouseDrop(t){const i=this.Ir;i!==t&&(this.Ir=t,this.t("mouseDrop",i,t))}get handlesDragDropForTopLevelParts(){return this.Ix}set handlesDragDropForTopLevelParts(t){const i=this.Ix;i!==t&&(Util.i(t,"boolean",Diagram,"handlesDragDropForTopLevelParts"),this.Ix=t,this.t("handlesDragDropForTopLevelParts",i,t))}get mouseEnter(){return this.Er}set mouseEnter(t){const i=this.Er;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseEnter"),this.Er=t,this.t("mouseEnter",i,t))}get mouseLeave(){return this.Br}set mouseLeave(t){const i=this.Br;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseLeave"),this.Br=t,this.t("mouseLeave",i,t))}get toolTip(){return this.Ur}set toolTip(t){const i=this.Ur;i!==t&&(this.Ur=t,this.t("toolTip",i,t))}get contextMenu(){return this.Vr}set contextMenu(t){const i=this.Vr;i!==t&&(this.Vr=t,this.t("contextMenu",i,t))}get commandHandler(){return this.HS}set commandHandler(t){this.HS!==t&&(this.HS=t,t.To(this))}get toolManager(){return this.YS}set toolManager(t){this.YS!==t&&(this.YS=t,t.diagram=this)}get defaultTool(){return this.GS}set defaultTool(t){const i=this.GS;i!==t&&(this.GS=t,t.diagram=this,this.currentTool===i&&(this.currentTool=t))}get currentTool(){return this.jS}set currentTool(t){const i=this.jS;i&&(i.isActive&&i.doDeactivate(),i.cancelWaitAfter(),i.doStop()),t===null&&(t=this.defaultTool),t!==null&&(this.jS=t,t.diagram=this,t.doStart())}get selection(){return this._S}get maxSelectionCount(){return this.Qx}set maxSelectionCount(t){const i=this.Qx;if(i!==t)if(Util.i(t,"number",Diagram,"maxSelectionCount"),t>=0&&!isNaN(t)){if(this.Qx=t,this.t("maxSelectionCount",i,t),!this.undoManager.isUndoingRedoing){const e=this.selection.count-t;if(e>0){this.v("ChangingSelection",this.selection);const s=this.selection.toArray();for(let n=0;n= 0",Diagram,"maxSelectionCount")}get nodeSelectionAdornmentTemplate(){return this.jm}set nodeSelectionAdornmentTemplate(t){const i=this.jm;i!==t&&(this.jm=t,this.t("nodeSelectionAdornmentTemplate",i,t))}get groupSelectionAdornmentTemplate(){return this.ib}set groupSelectionAdornmentTemplate(t){const i=this.ib;i!==t&&(this.ib=t,this.t("groupSelectionAdornmentTemplate",i,t))}get linkSelectionAdornmentTemplate(){return this.eb}set linkSelectionAdornmentTemplate(t){const i=this.eb;i!==t&&(this.eb=t,this.t("linkSelectionAdornmentTemplate",i,t))}get highlighteds(){return this.tM}get isModified(){const t=this.undoManager;return t.isEnabled?t.currentTransaction!==null?!0:this.Uu&&this.vs!==t.historyIndex:this.Uu}set isModified(t){if(this.Uu!==t){Util.i(t,"boolean",Diagram,"isModified"),this.Uu=t;const e=this.undoManager;!t&&e.isEnabled&&(this.vs=e.historyIndex),t||this.vL()}}vL(){const t=this.isModified;this.ZS!==t&&(this.ZS=t,this.v("Modified"))}get model(){return this.Si}set model(t){const i=this.Si;if(i!==t){this.currentTool.doCancel(),i&&i.undoManager!==t.undoManager&&i.undoManager.isInTransaction&&Util.o("Do not replace a Diagram.model while a transaction is in progress."),this.animationManager.stopAnimation(!0);const e=this.gL(!0);this.Jn=!1,this.vu=!0,this.vs=-2,this.Pr=!1;const s=this.Ht;this.Ht=!0,this.animationManager.Fl("Model"),i&&(this.qn!==null&&this.qn.each(n=>i.removeChangedListener(n)),i.removeChangedListener(this.$S)),this.Si=t,this.partManager=this.cR(this.Si.type),this.initializePartManager(this.partManager);for(let n=0;nt.addChangedListener(n)),this.Ht=s,this.invalidateDocumentBounds(),this.Ht||this.C(),i&&t.undoManager.copyProperties(i.undoManager)}}get themeManager(){return this.gb}set themeManager(t){const i=this.gb;i!==t&&(i!==null&&i.removeDiagram(this),this.gb=t,t!==null&&t.addDiagram(this))}initializePartManager(t){}static gM(t,i){Diagram.hL.set(t,i)}static get licenseKey(){return Diagram.AM.last()}static set licenseKey(t){Diagram.AM.add(t.replace(/\s/g,""))}static get version(){return Diagram.fR}static AM=new List;static fR="3.0.12";cR(t){const i=Diagram.hL.get(t);return i!==null?new i:new PartManager}get Y(){return this.WS}set Y(t){this.WS=t}get mx(){return this.oL}uR(t){if(t.model!==this.model)return;const i=t.change,e=t.propertyName;if(i===1&&e[0]==="S"){if(e==="StartingFirstTransaction"){const s=this,n=this.toolManager;n.mouseDownTools.each(o=>o.diagram=s),n.mouseMoveTools.each(o=>o.diagram=s),n.mouseUpTools.each(o=>o.diagram=s),this.routers.each(o=>o.diagram=s),!this.ps&&!this.Jn&&(this.Oc=!0,this.vu&&(this.Pr=!0))}else if(e==="StartingUndo"||e==="StartingRedo"){const s=this.animationManager;this.skipsUndoManager||(s.defaultAnimation.isAnimating&&s.stopAnimation(),s.getBundleAnimation().isAnimating&&s.getBundleAnimation().stop()),this.v("ChangingSelection",this.selection)}else if(e==="StartedTransaction"){const s=this.animationManager;s.defaultAnimation.isAnimating&&!this.skipsUndoManager&&s.stopAnimation()}return}if(this.Y){this.Y=!1;try{if(t.modelChange===""&&i===1){(e==="FinishedUndo"||e==="FinishedRedo")&&(this.v("ChangedSelection",this.selection),this.Ci());const s=this.animationManager;e==="RolledBackTransaction"&&s.stopAnimation(),this._C(),this.Oc=!0,this.maybeUpdate(),(this.undoManager.transactionLevel===0||this.undoManager.transactionLevel===1)&&s.SS(),e==="CommittedTransaction"&&this.undoManager.isJustDiscarded&&(this.vs=Math.min(this.vs,this.undoManager.historyIndex-1)),(e==="CommittedTransaction"||e==="RolledBackTransaction")&&this.undoManager.Iw&&setTimeout(()=>{this.isModified=!1},1);const n=t.isTransactionFinished;if(n&&(this.vL(),this.mx.clear(),this.animationManager.fF()),!this.Ex&&n&&this.lastInput.targetDiagram){this.Ex=!0;const o=this;Util.Oh(()=>{o.currentTool.standardMouseOver(),o.Ex=!1},10)}}}finally{this.Y=!0}}}get fe(){return this.qS}set fe(t){this.qS=t}get dc(){return this.Bx}set dc(t){this.Bx=t}SL(t){const i=t.L.r;for(const e of i)e instanceof Picture&&this.TM(e)}TM(t){const i=t.element;if(i===null||!(i instanceof HTMLImageElement)||(i.es instanceof GSet&&i.es.add(this),t.dR(),!i.c0))return;const e=i.getAttribute("src")||"",s=this.Jl.get(e);if(s===null){Picture.OL(t,i);const n=[];n.push(t),this.Jl.set(e,n)}else{for(let n=0;n0?(this.kx=t,this.t("minScale",i,t),t>this.scale&&(this.scale=t)):Util._(t,"> 0",Diagram,"minScale"))}get maxScale(){return this.Px}set maxScale(t){const i=this.Px;i!==t&&(t>0?(this.Px=t,this.t("maxScale",i,t),t 0",Diagram,"maxScale"))}get zoomPoint(){return this.Sx}set zoomPoint(t){this.Sx.equals(t)||(t=t.N(),this.Sx=t)}get contentAlignment(){return this.Rc}set contentAlignment(t){const i=this.Rc;i.equals(t)||(t=t.N(),this.Rc=t,this.t("contentAlignment",i,t),this.Us(!1))}get initialContentAlignment(){return this.Um}set initialContentAlignment(t){const i=this.Um;i.equals(t)||(t=t.N(),this.Um=t,this.t("initialContentAlignment",i,t))}get padding(){return this.$t}set padding(t){typeof t=="number"&&(t=new Margin(t));const i=this.$t;i.equals(t)||(t=t.N(),this.$t=t,this.invalidateDocumentBounds(),this.t("padding",i,t))}get partManager(){return this.oM}set partManager(t){const i=this.oM;i!==t&&(t.diagram!==null&&Util.o("Cannot share PartManagers between Diagrams: "+t.toString()),i&&i.To(null),this.oM=t,t.To(this))}get nodes(){return this.partManager.nodes.iterator}get links(){return this.partManager.links.iterator}get parts(){return this.partManager.parts.iterator}findTopLevelNodesAndLinks(){const t=new GSet,i=this.nodes;for(;i.next();){const s=i.value;s.isTopLevel&&t.add(s)}const e=this.links;for(;e.next();){const s=e.value;s.isTopLevel&&t.add(s)}return t.iterator}findTopLevelGroups(){return this.Yr.iterator}get routers(){return this.zc}doLinkRouting(t){this.Fo=!0;const i=this.zc.r;for(let e=0;e0){const l=this.computePartsBounds(n.memberParts,!1);l.inflate(20,20),s.kb(l)}const o=Rect.l(),r=n.memberParts;for(;r.next();){const l=r.value;l instanceof Node&&this.IM(l,e,o)}Rect.s(o)}s.ha=n,s.RM=e,s.Eo=!1}else t&&s.zL();return s}get avoidanceCellSize(){return this.iM}set avoidanceCellSize(t){this.Hl=null,this.iM=new Size(Math.max(1,t.width),Math.max(1,t.height))}get avoidanceLimit(){return this.eM}set avoidanceLimit(t){this.eM=Math.max(1,t)}VL(t){return t.canAvoid()?t:t.containingGroup!==null?this.VL(t.containingGroup):null}IM(t,i,e){if(t===i||!t.isVisible())return;const s=t.canAvoid();if(s){const n=t.getAvoidableRect(e);this.Hl.pR(n.x,n.y,n.width,n.height)}if(t instanceof Group&&(!s||t.avoidableMembers)){const n=t.memberParts;for(;n.next();){const o=n.value;o instanceof Node&&this.IM(o,i,e)}}}EM(t){this.Hl!==null&&!this.Hl.Eo&&(t===void 0||t.canAvoid())&&(this.Hl.Eo=!0)}get autoScrollInterval(){return this.Vm}set autoScrollInterval(t){const i=this.Vm;i!==t&&(this.Vm=t,this.t("autoScrollInterval",i,t))}get autoScrollRegion(){return this.zm}set autoScrollRegion(t){typeof t=="number"&&(t=new Margin(t));const i=this.zm;i.equals(t)||(t=t.N(),this.zm=t,this.invalidateDocumentBounds(),this.t("autoScrollRegion",i,t))}doAutoScroll(t){this.qm.a(t),this.computeAutoScrollPosition(this.qm).equalsApprox(this.position)?this.stopAutoScroll():this.XL()}XL(){if(this.vc!==-1)return;const t=this.Vm,i=this;this.vc=Util.Oh(()=>{if(i.vc===-1||(i.stopAutoScroll(),i.lastInput.event===null))return;const s=i.computeAutoScrollPosition(i.qm);if(s.equalsApprox(i.position))return;i.position=s,i.lastInput.documentPoint=i.transformViewToDoc(i.qm),i.doMouseMove(),i.Zh=!0;const n=Rect.l();i.computeBounds(n),n.unionRect(i.documentBounds),i.IL(n),Rect.s(n),i.Ue=!0,i.maybeUpdate(),i.XL()},t)}stopAutoScroll(){this.vc!==-1&&(Util.Og(this.vc),this.vc=-1)}computeAutoScrollPosition(t){let i=this.position;const e=this.zm;if(e.top<=0&&e.left<=0&&e.right<=0&&e.bottom<=0)return i;const s=this.viewportBounds,n=this.scale,o=Rect.X(0,0,s.width*n,s.height*n),r=Point.X(0,0);if(t.x>=o.x&&t.xo.x+o.width-e.right&&this.allowHorizontalScroll){let l=Math.max(this.scrollHorizontalLineChange,1);l=l|0,r.x+=l,t.x>o.x+o.width-e.right/2&&(r.x+=l),t.x>o.x+o.width-e.right/4&&(r.x+=4*l)}if(t.y>=o.y&&t.yo.y+o.height-e.bottom&&this.allowVerticalScroll){let l=Math.max(this.scrollVerticalLineChange,1);l=l|0,r.y+=l,t.y>o.y+o.height-e.bottom/2&&(r.y+=l),t.y>o.y+o.height-e.bottom/4&&(r.y+=4*l)}return r.equalsApprox(Point.Po)||(i=new Point(i.x+r.x/n,i.y+r.y/n)),Rect.s(o),Point.s(r),i}makeSvg(t){this.Wl.has("SVG")||this.addRenderer("SVG",new SVGSurface(this,root.document));const i=new SVGSurface(this,root.document,!0);t===void 0&&(t={});const e=this;function s(n,o){const r=e.KL(n,"SVG",i),l=r!==null?r.svg:null;return typeof o=="function"?(o(l),null):l}return this.YL(s,t)}makeSVG(t){return this.makeSvg(t)}addRenderer(t,i){this.Wl.set(t,i)}removeRenderer(t){this.Wl.delete(t)}cacheGroupExternalLinks(t){this.dM=t,t||this.nodes.each(i=>{i instanceof Group&&(i.u0=null)})}YL(t,i){const e=i.callback;let s=!0;const o=this.Jl.iterator;for(;o.next();)if(!o.value[0].mn){s=!1;break}if(typeof e!="function"||s)return t(i,e,this);const r=this;function l(){const c=+new Date;for(s=!0,o.reset();o.next();)if(!o.value[0].mn){s=!1;break}if(s||c-a>h){t(i,e,r);return}root.requestAnimationFrame(l)}const h=i.callbackTimeout||300,a=+new Date;return root.requestAnimationFrame(()=>l()),null}makeImage(t){return Diagram.isUsingDOM()?(t===void 0&&(t={}),t.returnType="Image",this.makeImageData(t)):null}makeImageData(t){return t===void 0&&(t={}),this.YL(this.yR,t)}static img="image";yR(t,i,e){const s=e.KL(t,"canvas",null);if(s===null)return null;const n=s.U.canvas;let o=null;if(n!==null){let r=t.returnType;switch(r===void 0?r="string":r=r.toLowerCase(),r){case Diagram.img+"data":o=s.getImageData(0,0,n.width,n.height);break;case Diagram.img:const h=(t.document||document).createElement("img");h.src=n.toDataURL(t.type,t.details),o=h;break;case"blob":{const a=n;return typeof i!="function"&&(o="",Util.o('Error: Diagram.makeImageData called with "returnType: toBlob", but no required "callback" function property defined.')),typeof a.toBlob=="function"?(a.toBlob(i,t.type,t.details),"toBlob"):(i(null),null)}case"string":default:o=n.toDataURL(t.type,t.details)}}return typeof i=="function"?(i(o),null):o}static wR=!1;KL(t,i,e){if(this.animationManager.stopAnimation(),this.maybeUpdate(),this.dt===null)return null;typeof t!="object"&&Util.o("properties argument must be an Object.");let n=!1,o=t.size||null,r=t.scale||null;t.scale!==void 0&&isNaN(t.scale)&&(r="NaN");let l=t.maxSize;t.maxSize===void 0&&(n=!0,i==="SVG"?l=new Size(1/0,1/0):l=new Size(2e3,2e3));const h=t.position||null;let a=t.parts||null;Array.isArray(a)&&(a=new List(a));let c=t.padding===void 0?1:t.padding;const f=t.background||null;let u=t.omitTemporary;u===void 0&&(u=!0);const d=t.document||document,m=t.elementFinished||null;let g=t.showTemporary;g===void 0&&(g=!u);let p=t.showGrid;p===void 0&&(p=g),o!==null&&isNaN(o.width)&&isNaN(o.height)&&(o=null),typeof c=="number"?c=new Margin(c):c instanceof Margin||Util.o("MakeImage padding must be a Margin or a number."),c.left=Math.max(c.left,0),c.right=Math.max(c.right,0),c.top=Math.max(c.top,0),c.bottom=Math.max(c.bottom,0),this.Zt.clearContextCache(!0);const y=new CanvasSurface(null,d,void 0,!0),x=y.ai;if(!(o||r||a||h))return y.width=this.kt+Math.ceil(c.left+c.right),y.height=this.Pt+Math.ceil(c.top+c.bottom),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.aa=d,e.Gu=m,this.wb(e.ai,c,new Size(y.width,y.height),this.et,this.at,a,f,g,p),e.ai):(this.Vu=!1,this.wb(x,c,new Size(y.width,y.height),this.et,this.at,a,f,g,p),this.Vu=!0,y.ai);const k=this.Jm,b=this.documentBounds.copy();if(b.subtractMargin(this.$t),g){const A=this.Gt.r,D=A.length;for(let F=0;Fk?(r=k,N=b.width,T=b.height):(N=l.width,T=l.height)):(N=b.width*r,T=b.height*r):(r=k,N=b.width,T=b.height),c!==null?(N+=S,T+=L):c=new Margin(0),l!==null){let A=l.width,D=l.height;i!=="SVG"&&n&&Diagram.wR,isNaN(A)&&(A=2e3),isNaN(D)&&(D=2e3),isFinite(A)&&(N=Math.min(N,A)),isFinite(D)&&(T=Math.min(T,D))}return y.width=Math.ceil(N),y.height=Math.ceil(T),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.aa=d,e.Gu=m,this.wb(e.ai,c,new Size(Math.ceil(N),Math.ceil(T)),r,P,a,f,g,p),e.ai):(this.Vu=!1,this.wb(x,c,new Size(Math.ceil(N),Math.ceil(T)),r,P,a,f,g,p),this.Vu=!0,y.ai)}static Ku=null;static GL="5da73c80a36555d4038e4972187c3cae51fd22";static uw=!1;static Ik=()=>{if(Diagram.GL[5]===void 0&&(Transform.prototype._e=Transform.prototype.ww),!Diagram.isUsingDOM())return;const t=root.document.createElement("canvas"),i=t.getContext("2d"),e=Util.Cs("7ca11abfd022028846");i[e]=Util.Cs("398c3597c01238");const s="7ca11abfd7330390",n=[Diagram.GL,Util.uw+"4ae6247590da4bb21c324ba3a84e385776",Transform.Ik+"fb236cdfda5de14c134ba1a95a2d4c7cc6f93c1387",Geo.za],o=10,r=0;for(let l=1;l<5;l++)i[Util.Cs(s)](Util.Cs(n[l-1]),o,l*15+r);i[e]=Util.Cs("39f046ebb36e4b");for(let l=1;l<5;l++)i[Util.Cs(s)](Util.Cs(n[l-1]),o,l*15+r);(n.length!==4||n[0][0]!=="5"||n[3][0]!=="7")&&(Transform.prototype._e=Transform.prototype.ww),Diagram.Ku=t}}class DiagramHelper{jL;HL;BM;Ne;constructor(t){if(this.jL=null,this.HL="63ad05bbe23a1786468a4c741b6d2",this.BM="@onz",this.HL===this._tk){this.BM=!0,this.Ne=this.BM;return}this.Ne=null}xR(t,i){let e="f";const s=root[Util.Cs("76a715b2f73f148a")][Util.Cs("72ba13b5")]||"",n=Util.Cs;if(this.Ne=!0,!Diagram.isUsingDOM())return;let o=Diagram[n("76a115b6ed251eaf4692")];if(!o){const l=s[n("76ad18b4f73e")];for(let a=s[n("73a612b6fb191d")](n("35e7"))+2;a=0&&ha[0]||h[0]===a[0]&&h[1]>=a[1]))continue;const c="73a612b6fb191d",f=root[n("74a900bae4370f8b51")][n("6fbb13a1c2311e8a57")].toLowerCase(),u=f[n(c)](n("3aad1ab6e022098b4dc4")),d=n(l[2]);if(u>-1){const M=f[n(c)](d.toLowerCase()+"/");if(this.Ne=!(M>-1&&M=0&&g-1),!this.Ne))return;const p=root[Util.Cs("76a715b2f73f148a")][Util.Cs("69ad17a1e03e")],y=p[n(c)](n("7fb002b6ed25128b4da25b2e"));if(y>-1&&(this.Ne=!(p[n(c)](d)>y),!this.Ne))return;const x=d;if(x[0]!=="#")continue;const k=root.document.createElement("div");let b=l[0].replace(/[A-Za-z]/g,"");for(;b.length<4;)b+="9";const P=b;b=b.substring(b.length-4);let S="";const L=["gsh","gsf"],C=["Header","Background","Display","Feedback"];if(S+=L[parseInt(b.substring(0,1),10)%2],S+=C[parseInt(b.substring(0,1),10)%4],k[n("79a417a0f0181a8946")]=S,root.document[n("78a712aa")]){root.document[n("78a712aa")][n("7bb806b6ed32388c4a875b")](k);const M=root.getComputedStyle(k).getPropertyValue(n("78a704b7e62456904c9b12701b6532a8")),N=root.getComputedStyle(k).getPropertyValue(n("75b817b0ea2202"));if(root.document[n("78a712aa")][n("68ad1bbcf533388c4a875b")](k),!M)continue;const T=root[n("77a902b0eb1b1e804a8a")],A="0."+parseInt(P,10)%100;if(N===A||M.indexOf(parseInt(x[1]+x[2],16))!==-1&&M.indexOf(parseInt(x[3]+x[4],16))!==-1){this.Ne=!1;return}else if(T&&T(n("32ae19a1e0331fc94084537c067a67fa59f1386b89d006")).matches){S="."+S;for(let D=0;D{const s=this.observed;if(s===null)return;const n=s.viewportBounds,o=this.lastInput.documentPoint;s.position=new Point(o.x-n.width/2,o.y-n.height/2)},this.zM=s=>{this.invalidateDocumentBounds(),this.g0()},this.XM=s=>{this.observed!==null&&(this.invalidateDocumentBounds(),this.C())},this.Cb=s=>{this.updateDelay<1?this.C():this.d0||(this.d0=!0,setTimeout(()=>this.redraw(),this.updateDelay))},this.KM=s=>{this.observed!==null&&this.g0()},this.autoScale=2,this.Ht=!1,i&&Object.assign(this,i),this}setupRouters(){}computePixelRatio(){return 1}redraw(){this.d0&&this.updateDelay>=1&&(this.d0=!1,this.bR()),super.redraw()}Gi(){if(this.Tt===null&&Util.o("No div specified"),this.dt===null&&Util.o("No canvas specified"),this.dt instanceof SVGSurface||(this.box.US(),!this.Ue))return;const t=this.observed;if(t===null||t.animationManager.defaultAnimation.isAnimating||!t.Bh)return;this.l0();const i=this.dt,e=this.Zt;if(e.clearContextCache(!0),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,i.width,i.height),this.updateDelay<1)this.WL();else if(this.jc!==null){e.drawImage(this.jc.Ft,0,0);const o=this.D;e.scale(this.Ui,this.Ui),e.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),e.commitTransform()}const s=this.Gt.r,n=s.length;for(let o=0;on.canDelete())}t.removeParts(i,!0),t.v("SelectionDeleted",i)}finally{t.commitTransaction("Delete"),t.v("ChangedSelection",t.selection),t.currentCursor=""}}canDeleteSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowDelete||t.selection.count===0)}copySelection(){const t=this.diagram;try{const i=new GSet,e=t.selection.iterator;for(;e.next();){const s=e.value;Part.sh(i,s,!0,this.copiesTree?1/0:0,this.copiesConnectedLinks,n=>n.canCopy())}this.copyToClipboard(i)}finally{}}canCopySelection(){const t=this.diagram;return!(!t.allowCopy||!t.allowClipboard||t.selection.count===0)}cutSelection(){this.copySelection(),this.deleteSelection()}canCutSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowCopy||!t.allowDelete||!t.allowClipboard||t.selection.count===0)}copyToClipboard(t){const i=this.diagram;let e=null;if(t===null)Diagram.dL();else{const s=i.model;let n=!1,o=!1,r=null;try{s.pc()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.gc()||s.ju())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=i.copyParts(t,null,!0)}finally{s.pc()&&(s.copiesParentKeyOfNodeData=n),(s.gc()||s.ju())&&(s.copiesGroupKeyOfNodeData=o),e=new List,e.addAll(r.iteratorValues),Diagram.e0=e,Diagram.mb=i.model.dataFormat}}i.v("ClipboardChanged",e)}pasteFromClipboard(){const t=new GSet,i=Diagram.e0;if(i===null)return t;const e=this.diagram;if(Diagram.mb!==e.model.dataFormat)return t;const s=e.model;let n=!1,o=!1,r=null;try{s.pc()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.gc()||s.ju())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=e.copyParts(i,e,!1)}finally{s.pc()&&(s.copiesParentKeyOfNodeData=n),(s.gc()||s.ju())&&(s.copiesGroupKeyOfNodeData=o);const l=r.iterator;for(;l.next();){const h=l.value,a=l.key;h.location.isReal()||(a.location.isReal()?h.location=a.location:!h.position.isReal()&&a.position.isReal()&&(h.position=a.position)),t.add(h)}}return t}pasteSelection(t){t===void 0&&(t=null);const i=this.diagram;try{i.currentCursor="wait",i.v("ChangingSelection",i.selection),i.startTransaction("Paste");const e=this.pasteFromClipboard();e.count>0&&i.clearSelection(!0);const s=e.iterator;for(;s.next();){const n=s.value;n.isSelected=!0}if(t!==null){const n=i.computePartsBounds(i.selection);if(n.isReal()){const o=this.computeEffectiveCollection(i.selection,i.fb);i.bP(o,new Point(t.x-n.centerX,t.y-n.centerY),i.fb,!1)}}i.v("ClipboardPasted",e)}finally{i.commitTransaction("Paste"),i.v("ChangedSelection",i.selection),i.currentCursor=""}}canPasteSelection(t){const i=this.diagram;return!(i.isReadOnly||i.isModelReadOnly||!i.allowInsert||!i.allowClipboard||Diagram.e0===null||Diagram.e0.count===0||Diagram.mb!==i.model.dataFormat)}undo(){this.diagram.undoManager.undo()}canUndo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canUndo()}redo(){this.diagram.undoManager.redo()}canRedo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canRedo()}decreaseZoom(t){t===void 0&&(t=1/this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canDecreaseZoom(t){t===void 0&&(t=1/this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}increaseZoom(t){t===void 0&&(t=this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canIncreaseZoom(t){t===void 0&&(t=this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}resetZoom(t){t===void 0&&(t=this.defaultScale);const i=this.diagram;ti.maxScale||(i.scale=t)}canResetZoom(t){t===void 0&&(t=this.defaultScale);const i=this.diagram;return ti.maxScale?!1:i.allowZoom}zoomToFit(){const t=this.diagram,i=t.animationManager;i.stopAnimation(),t.redraw();const e=t.position,s=t.scale;i.Fl("Zoom To Fit"),this.isZoomToFitRestoreEnabled&&s===this.Ab&&!isNaN(this.Lb)&&t.documentBounds.equals(this.Tb)?(t.scale=this.Lb,t.position=this.QM,this.Ab=NaN,this.Tb=Rect.pw):(this.Lb=s,this.QM=e.copy(),t.zoomToFit(),this.Ab=t.scale,this.Tb=t.documentBounds.copy()),i.SS()}canZoomToFit(){return this.diagram.allowZoom}scrollToPart(t){t===void 0&&(t=null);const i=this.diagram;if(i.ensureBounds(),t===null){try{this.Bo!==null&&(this.Bo.next()?t=this.Bo.value:this.Bo=null)}catch{this.Bo=null}t===null&&(i.highlighteds.count>0?this.Bo=i.highlighteds.iterator:i.selection.count>0&&(this.Bo=i.selection.iterator),this.Bo!==null&&this.Bo.next()&&(t=this.Bo.value))}if(t!==null){const e=i.animationManager;e.Fl("Scroll To Part");const s=this.scrollToPartPause;if(s>0){const n=this.Hc(t,[t]);if(n.length===1)i.startTransaction(),i.centerRect(t.actualBounds),i.commitTransaction("Scroll To Part");else{const o=()=>{i.startTransaction();let l=n.pop();for(;n.length>0&&l instanceof Node&&l.isTreeExpanded&&(!(l instanceof Group)||l.isSubGraphExpanded);)l=n.pop();n.length>0?(l instanceof Part&&i.scrollToRect(l.actualBounds),l instanceof Node&&!l.isTreeExpanded&&(l.isTreeExpanded=!0),l instanceof Group&&!l.isSubGraphExpanded&&(l.isSubGraphExpanded=!0)):(l instanceof Part&&i.centerRect(l.actualBounds),i.removeDiagramListener("LayoutCompleted",r)),i.commitTransaction("Scroll To Part")},r=()=>{Util.Oh(o,(e.isEnabled?e.duration:0)+s)};i.addDiagramListener("LayoutCompleted",r),o()}}else{const n=i.position.copy();i.centerRect(t.actualBounds),n.equalsApprox(i.position)&&e.stopAnimation()}}}Hc(t,i){if(t.isVisible())return i;if(t instanceof Adornment)this.Hc(t.adornedPart,i);else if(t instanceof Link){const e=t.fromNode;e!==null&&this.Hc(e,i);const s=t.toNode;s!==null&&this.Hc(s,i)}else{if(t instanceof Node){const s=t.labeledLink;s!==null&&this.Hc(s,i);const n=t.findTreeParentNode();n!==null&&(!n.isTreeExpanded&&!n.wasTreeExpanded&&i.push(n),this.Hc(n,i))}const e=t.containingGroup;e!==null&&(!e.isSubGraphExpanded&&!e.wasSubGraphExpanded&&i.push(e),this.Hc(e,i))}return i}canScrollToPart(t){if(t===void 0&&(t=null),t!==null&&!(t instanceof Part))return!1;const i=this.diagram;return i.selection.count===0&&i.highlighteds.count===0?!1:i.allowHorizontalScroll&&i.allowVerticalScroll}collapseTree(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse Tree";try{i.startTransaction(e),i.animationManager.Fl(e);const n=new List;if(t!==null&&t.isTreeExpanded)t.collapseTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&r.isTreeExpanded&&(r.collapseTree(),n.add(r))}}i.v("TreeCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||!t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(!s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}expandTree(t){t===void 0&&(t=null);const i=this.diagram,e="Expand Tree";try{i.startTransaction(e),i.animationManager.Fl(e);const n=new List;if(t!==null&&!t.isTreeExpanded)t.expandTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&(r.isTreeExpanded||(r.expandTree(),n.add(r)))}}i.v("TreeExpanded",n)}finally{i.commitTransaction(e)}}canExpandTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}groupSelection(){const t=this.diagram,i=t.model;if(!i.qc())return;const e=this.archetypeGroupData;if(e===null)return;let s=null;try{t.currentCursor="wait",t.v("ChangingSelection",t.selection),t.startTransaction("Group");const n=new List,o=t.selection.iterator;for(;o.next();){const h=o.value;h.Pe()&&h.canGroup()&&n.add(h)}const r=new List,l=n.iterator;for(;l.next();){const h=l.value;let a=!1;const c=n.iterator;for(;c.next();){const f=c.value;if(h.isMemberOf(f)){a=!0;break}}a||r.add(h)}if(r.count>0){let h=r.first().containingGroup;if(h!==null)for(;h!==null;){let a=!1;const c=r.iterator;for(;c.next();)if(!c.value.isMemberOf(h)){a=!0;break}if(a)h=h.containingGroup;else break}if(e instanceof Group)e.li(),s=e.copy(),s!==null&&t.add(s);else if(i.isGroupForData(e)){const a=i.copyNodeData(e);Util.wt(a)&&(i.addNodeData(a),s=t.findNodeForData(a))}if(s!==null){h!==null&&this.isValidMember(h,s)&&(s.containingGroup=h);const a=r.iterator;for(;a.next();){const c=a.value;this.isValidMember(s,c)&&(c.containingGroup=s)}t.clearSelection(!0),s.isSelected=!0}}t.v("SelectionGrouped",s)}finally{t.commitTransaction("Group"),t.v("ChangedSelection",t.selection),t.currentCursor=""}}canGroupSelection(){const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowGroup||!t.model.qc()||this.archetypeGroupData===null)return!1;const e=t.selection.iterator;for(;e.next();){const s=e.value;if(s.Pe()&&s.canGroup())return!0}return!1}i2(t){const i=Util.nt();if(Array.isArray(t))t.forEach(n=>{n instanceof Link||n instanceof Part&&i.push(n)});else{const n=t.iterator;for(;n.next();){const o=n.value;o instanceof Link||o instanceof Part&&i.push(o)}}const e=new GSet,s=i.length;for(let n=0;n0){i.clearSelection(!0);const o=s.iterator;for(;o.next();){const r=o.value;r.expandSubGraph();const l=r.containingGroup,h=l!==null&&l.data!==null?e.getKeyForNodeData(l.data):void 0;n.addAll(r.memberParts);const a=n.iterator;for(;a.next();){const c=a.value;if(c.isSelected=!0,c instanceof Link)continue;const f=c.data;f!==null?e.setGroupForData(f,h):c.containingGroup=l}i.remove(r)}}i.v("SelectionUngrouped",s,n)}finally{i.commitTransaction("Ungroup"),i.v("ChangedSelection",i.selection),i.currentCursor=""}}canUngroupSelection(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowDelete||!i.allowUngroup||!i.model.qc())return!1;if(t!==null){if(!(t instanceof Group))return!1;if(t.canUngroup())return!0}else{const s=i.selection.iterator;for(;s.next();){const n=s.value;if(n instanceof Group&&n.canUngroup())return!0}}return!1}addTopLevelParts(t,i){const e=this.i2(t);let s=!0;const n=e.iterator;for(;n.next();){const o=n.value;o.containingGroup!==null&&(!i||this.isValidMember(null,o)?o.containingGroup=null:s=!1)}return s}collapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse SubGraph";try{i.startTransaction(e),i.animationManager.Fl(e);const n=new List;if(t!==null&&t.isSubGraphExpanded)t.collapseSubGraph(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&r.isSubGraphExpanded&&(r.collapseSubGraph(),n.add(r))}}i.v("SubGraphCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||!t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&s.isSubGraphExpanded)return!0}}return!1}expandSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Expand SubGraph",s=new List;try{if(i.startTransaction(e),i.animationManager.Fl(e),t!==null&&!t.isSubGraphExpanded)t.expandSubGraph(),s.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&(r.isSubGraphExpanded||(r.expandSubGraph(),s.add(r)))}}i.v("SubGraphExpanded",s)}finally{for(const n of s)this.JL(i,n);t&&this.JL(i,t),i.commitTransaction(e)}}JL(t,i){for(const e of i.memberParts)e instanceof Node&&t.Cc(e,i)}canExpandSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&!s.isSubGraphExpanded)return!0}}return!1}editTextBlock(t){t===void 0&&(t=null);const i=this.diagram,e=i.toolManager.findTool("TextEditing");if(e!==null){if(t===null){let s=null;const n=i.selection.iterator;for(;n.next();){const o=n.value;if(o.canEdit()){s=o;break}}if(s===null)return;t=s.findInVisualTree(o=>o instanceof TextBlock&&o.editable)}t!==null&&(i.currentTool=null,e.textBlock=t,i.currentTool=e)}}canEditTextBlock(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowTextEdit||i.toolManager.findTool("TextEditing")===null)return!1;if(t!==null){if(!(t instanceof TextBlock))return!1;const e=t.part;if(e!==null&&e.canEdit())return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s.canEdit()&&(t=s.findInVisualTree(n=>n instanceof TextBlock&&n.editable),t!==null))return!0}}return!1}showContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");if(e===null)return;t===void 0&&(i.selection.count>0?t=i.selection.first():t=i);const s=e.findObjectWithContextMenu(t);if(s!==null){const n=i.lastInput;let o=null;if(s instanceof GraphObject)o=s.getDocumentPoint(Spot.Center);else if(!i.viewportBounds.containsPoint(n.documentPoint)){const r=i.viewportBounds;o=new Point(r.x+r.width/2,r.y+r.height/2)}if(o!==null){const r=new InputEvent;r.diagram=i,r.viewPoint=i.transformDocToView(o),r.documentPoint=o,r.button=2,r.up=!0,i.lastInput=r}i.currentTool=e,e.openMenu(!1,s)}}canShowContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");return!(e===null||(t===void 0&&(i.selection.count>0?t=i.selection.first():t=i),e.findObjectWithContextMenu(t)===null))}get copiesClipboardData(){return this.YM}set copiesClipboardData(t){Util.i(t,"boolean",CommandHandler,"copiesClipboardData"),this.YM=t}get copiesConnectedLinks(){return this.GM}set copiesConnectedLinks(t){Util.i(t,"boolean",CommandHandler,"copiesConnectedLinks"),this.GM=t}get deletesConnectedLinks(){return this.jM}set deletesConnectedLinks(t){Util.i(t,"boolean",CommandHandler,"deletesConnectedLinks"),this.jM=t}get copiesTree(){return this.HM}set copiesTree(t){Util.i(t,"boolean",CommandHandler,"copiesTree"),this.HM=t}get deletesTree(){return this.qM}set deletesTree(t){Util.i(t,"boolean",CommandHandler,"deletesTree"),this.qM=t}get copiesParentKey(){return this.WM}set copiesParentKey(t){Util.i(t,"boolean",CommandHandler,"copiesParentKey"),this.WM=t}get copiesGroupKey(){return this.JM}set copiesGroupKey(t){Util.i(t,"boolean",CommandHandler,"copiesGroupKey"),this.JM=t}get archetypeGroupData(){return this.$M}set archetypeGroupData(t){t!==null&&Util.i(t,"object",CommandHandler,"archetypeGroupData");const i=this.diagram;this.$M=t}get memberValidation(){return this.eh}set memberValidation(t){t!==null&&Util.i(t,"function",CommandHandler,"memberValidation"),this.eh=t}get defaultScale(){return this.diagram.defaultScale}set defaultScale(t){this.diagram.defaultScale=t}get zoomFactor(){return this.ZM}set zoomFactor(t){t>1||Util.o("zoomFactor must be larger than 1.0, not: "+t),this.ZM=t}get isZoomToFitRestoreEnabled(){return this._M}set isZoomToFitRestoreEnabled(t){Util.i(t,"boolean",CommandHandler,"isZoomToFitRestoreEnabled"),this._M=t}get scrollToPartPause(){return this.t2}set scrollToPartPause(t){this.t2=t}computeEffectiveCollection(t,i){const e=this.diagram,s=e.toolManager.findTool("Dragging"),n=e.currentTool===s;i===void 0&&(i=e.a0());const o=new GMap;if(t===null)return o;let r=t.iterator;for(;r.next();){const l=r.value;e.Wr(o,l,n,i)}if(e.draggedLink!==null&&i.dragsLink)return o;for(r=t.iterator;r.next();){const l=r.value;if(l instanceof Link){const h=l.fromNode;if(h!==null&&!o.has(h))o.delete(l);else{const a=l.toNode;a!==null&&!o.has(a)&&o.delete(l)}}}return o}}var Stretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Vertical=4]="Vertical",w[w.Horizontal=5]="Horizontal",w[w.Fill=2]="Fill",w))(Stretch||{}),Orientation=(w=>(w[w.None=0]="None",w[w.Along=21]="Along",w[w.Plus90=22]="Plus90",w[w.Minus90=23]="Minus90",w[w.Opposite=24]="Opposite",w[w.Upright=25]="Upright",w[w.Plus90Upright=26]="Plus90Upright",w[w.Minus90Upright=27]="Minus90Upright",w[w.Upright45=28]="Upright45",w))(Orientation||{}),Flip=(w=>(w[w.None=0]="None",w[w.Vertical=1]="Vertical",w[w.Horizontal=2]="Horizontal",w[w.Both=3]="Both",w))(Flip||{});class GraphObject{n;Hu;qu;Uo;f;nh;q;at;se;Wt;Wu;Vs;Ct;ze;$r;oh;bi;ca;et;Xt;Zr;Li;Vi;Ju;oi;Wc;Bt;ni;Qr;Db;rh;$u;constructor(){GSet.Yi(this),this.n=30723,this.Wt=1,this.Wu="",this.Vs=null,this.Ct=null,this.at=new Point(NaN,NaN).g(),this.ze=Size.gw,this.$r=new Transform,this.oh=new Transform,this.bi=null,this.ca=1,this.et=1,this.Xt=0,this.Zr=Margin.Eg,this.se=new Rect(NaN,NaN,NaN,NaN).g(),this.Li=new Rect(NaN,NaN,NaN,NaN).g(),this.Vi=new Rect(0,0,NaN,NaN).g(),this.Ju=null,this.Hu=null,this.q=null,this.oi=Spot.Default,this.Wc=Spot.Default,this.qu=0,this.Uo=0,this.Bt=null,this.f=null,this.nh=null,this.ni=null,this.Db=null,this.rh=null,this.Qr=null,this.$u=null}cloneProtected(t){t.n=(this.n|2048|4096)&-32769,t.Wt=this.Wt,t.Wu=this.Wu,t.Ct=this.Ct,t.at.a(this.at),t.ze=this.ze.N(),this.bi!==null?t.bi=this.bi.copy():t.bi=null,t.et=this.et,t.Xt=this.Xt,t.Zr=this.Zr.N(),t.se.a(this.se),t.Li.a(this.Li),t.Vi.a(this.Vi),t.Hu=this.Hu,this.q!==null&&(t.q=this.q.copy()),t.oi=this.oi.N(),t.Wc=this.Wc.N(),t.qu=this.qu,t.Uo=this.Uo,this.Bt!==null&&(t.Bt=this.Bt.copy()),this.f!==null&&(this.f.gi?t.f=this.f:t.f=this.f.copy()),this.nh!==null&&(t.nh=this.nh.slice()),this.ni!==null&&(t.ni=this.ni.copy())}addCopyProperty(t){let i=this.nh;if(!Array.isArray(i))i=[],this.nh=i;else for(let e=0;e{d.data!==null&&d.e2()&&d.updateTargetBindings(i)})}}}}gF(t){this.$u.delete(t)}Io(){if(this.diagram===null)return;if(this.findBindingPanel()===null&&this.Ai!==null){const i=this.Ai.iterator;for(;i.next();){const e=i.value;if(!e.isToTheme)continue;let s=null;const n=e.sourceName;e.isToObject&&(s=this.$L(n));let o=this;const r=e.targetId;r!==-1&&(o=this.m0(r),o===null)||(n==="/"?s=o.part:n==="."?s=o:n===".."&&(s=o.panel),e.updateTarget(o,s))}}}ya(t,i){const e=this.findBindingPanel();if(e!==null){const s=this.Ai.iterator;for(;s.next();){const n=s.value;let o=null;if(n.isToObject){if(o=n.ZL(e,this),o===null)continue;n.updateSource(this,o,i,null)}else if(n.isToModel){const r=t.diagram;r!==null&&!r.fe&&n.updateSource(this,r.model.modelData,i,e)}else if(!n.isToTheme){const r=e.data;if(r===null)continue;const l=t.diagram;l!==null&&!l.fe&&n.updateSource(this,r,i,e)}if(o===this){const r=n.targetId,l=e.m0(r);l!==null&&n.updateTarget(l,o,i)}}}}m0(t){return this.$n===t?this:null}$L(t){let i;return t===""?i=this:t==="/"?i=this:t==="."?i=this:t===".."?i=this:i=this.part.findObject(t),i}get $n(){return this.f!==null?this.f.$n:-1}set $n(t){this.$n!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.$n=t)}get Ai(){return this.f!==null?this.f.Ai:null}set Ai(t){this.Ai!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.Ai=t)}get Zn(){return this.f!==null?this.f.Zn:null}set Zn(t){this.Zn!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.Zn=t)}raiseChanged(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}t(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}Qn(t,i,e,s){const n=this.se;if(n.e(t,i,e,s),this.et!==1||this.Xt!==0){this.bi===null&&(this.bi=new Transform);const o=this.bi;o.Ri(),this.p0(o,t,i,e,s),o.xw(n)}}QL(t,i,e){return this.pickable===!1?!1:(e.ic(this.D),i?this.intersectsRect(t,e):this.containedInRect(t,e))}_L(t,i,e){if(this.pickable===!1)return!1;const s=this.naturalBounds,n=t.distanceSquaredPoint(i);return e?Point.distanceLineSegmentSquared(t.x,t.y,0,0,0,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,0,s.height,s.width,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,s.height,s.width,0)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,0,0,0)<=n:t.distanceSquared(0,0)<=n&&t.distanceSquared(0,s.height)<=n&&t.distanceSquared(s.width,0)<=n&&t.distanceSquared(s.width,s.height)<=n}pn(){return!0}containsPoint(t){const i=Point.l();i.a(t),this.D.xt(i);const e=this.actualBounds;if(!e.isReal())return Point.s(i),!1;const s=this.diagram;if(s!==null&&s.Zm){const o=s.getInputOption("extraTouchThreshold"),r=s.getInputOption("extraTouchArea"),l=r/2,h=this.naturalBounds,a=this.getDocumentScale()*s.scale,c=1/a;if(h.width*ae&&(f=t),isFinite(i)&&i>s&&(u=i);break;case 5:isFinite(t)&&t>e&&(f=t),u=0,d&&(i=1/0);break;case 4:isFinite(i)&&i>s&&(u=i),f=0,d&&(t=1/0);break}const g=this.maxSize,p=this.minSize;f>g.width&&p.widthg.height&&p.heightu.height||this.mi>u.width)&&(r=!0)}}}r?this.n|=256:this.n&=-257,this.Li.isReal()||Util.o("Non-real actualBounds has been set. Object "+this+", actualBounds: "+this.Li.toString()),this.td(o,this.Li),this._n(!1),Rect.s(o)}ah(t,i,e,s){}commonArrange(t,i,e,s){if(this.Li.e(t,i,e,s),this.desiredSize.isReal())return;const n=this.se,o=this.Zr,r=o.right+o.left,l=o.top+o.bottom,h=n.width+r,a=n.height+l;e+=r,s+=l;let c=this.zs(!0);switch(h===e&&a===s&&(c=0),c){case 0:(h>e||a>s)&&(this.ue(!0),this.ut(h>e?e:h,a>s?s:a,0,0));break;case 2:this.ue(!0),this.ut(e,s,0,0);break;case 5:this.ue(!0),this.ut(e,a,0,0);break;case 4:this.ue(!0),this.ut(h,s,0,0);break}}td(t,i){const e=this.part;e!==null&&e.diagram!==null&&((e.selectionObject===this||e.resizeObject===this||e.rotateObject===this)&&e.s2(!0),this.C(),!t.equalsApproxClose(i)&&(e.ch(),this.b0(e)))}b0(t){this.portId!==null&&(t.s2(!0),t instanceof Node&&t.tA(this))}get shadowVisible(){return this.f!==null?this.f.k0:null}set shadowVisible(t){const i=this.shadowVisible;i!==t&&(this.jt(),this.f.k0=t,this.ss(!0),this.C(),this.t("shadowVisible",i,t))}SR(t,i){const e=this.naturalBounds,s=this.oh,n=s.m11,o=s.m21,r=s.dx,l=s.m12,h=s.m22,a=s.dy;let c=0,f=0,u=c,d=f;c=u*n+d*o+r,f=u*l+d*h+a;let m=c,g=f,p=0,y=0;u=e.width+i,d=0,c=u*n+d*o+r,f=u*l+d*h+a;let x=Math.min(m,c),k=Math.min(g,f);p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-k,m=x,g=k,u=e.width+i,d=e.height+i,c=u*n+d*o+r,f=u*l+d*h+a,x=Math.min(m,c),k=Math.min(g,f),p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-k,m=x,g=k,u=0,d=e.height+i,c=u*n+d*o+r,f=u*l+d*h+a,x=Math.min(m,c),k=Math.min(g,f),p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-k,m=x,g=k;const b=t.viewportBounds,P=b.x,S=b.y,L=b.width,C=b.height;return m>L+P||P>p+m||g>C+S||S>y+g}Gi(t,i){if(this.MR(t,i)||!this.visible)return;const e=this.opacity;if(e===0)return;let s=1;e!==1&&(s=t.globalAlpha,t.globalAlpha=s*e);let n="";this.filter!==""&&(n=t.filter,t.filter=this.filter);const o=this.D,r=this.panel;this.y0()===!0&&this.Fb();const l=this.part;let h=!1,a=0;if(l&&i.getRenderingHint("drawShadows")&&(h=l.isShadowed,h)){const g=l.shadowOffset;a=Math.max(g.y,g.x)*i.scale*i.Ui}const c=this instanceof Panel&&this._r(),f=this.Li;if(c&&(this.iA(h,t,!1,r),this.NR(t,i),this.eA(h,t,!1,r),this.sA(h,t,!1)),c||!c&&(f.width===0||f.height===0||isNaN(f.x)||isNaN(f.y))){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}const u=this.Xs();if(!i.Qh&&u&&this.SR(i,a)){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}let d=(this.n&256)!==0;if(t.clipInsteadOfFill&&(d=!1),this instanceof TextBlock&&(t.font=this.font),d){const g=r.pn()?r.naturalBounds:r.actualBounds;let p=Math.max(f.x,g.x),y=Math.max(f.y,g.y),x=Math.min(f.right,g.right)-p,k=Math.min(f.bottom,g.bottom)-y;const b=this.ni;if(b!==null&&(p=b.x,y=b.y,x=b.width,k=b.height),p>f.width+f.x||f.x>g.width+g.x){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}t.save(),t.beginPath(),t.rect(p,y,x,k),t.clip()}if(u){if(!l.isVisible()){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}if(h){const g=l.shadowOffset;t.shadowsSet(g.x*i.scale*this.scale*i.Ui,g.y*i.scale*this.scale*i.Ui,l.shadowBlur),t.shadowsOn(),t.shadowColor=l.shadowColor}}const m=this.naturalBounds;if(t.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.iA(h,t,u,r),this.Ct!==null&&(t.commitTransform(),this.Rb(t,m,f)),this.eA(h,t,u,r),this.fh(t,i),this.sA(h,t,u),d&&(t.restore(),t.clearContextCache(this instanceof Panel)),!o.Ok()){const g=1/(o.m11*o.m22-o.m12*o.m21);t.transform(o.m22*g,-o.m12*g,-o.m21*g,o.m11*g,g*(o.m21*o.dy-o.m22*o.dx),g*(o.m12*o.dx-o.m11*o.dy))}e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n)}iA(t,i,e,s){t&&this.shadowVisible===!0?i.shadowsOn():t&&this.shadowVisible===!1&&i.shadowsOff(),t&&this.vb(s)&&this.shadowVisible===null&&i.shadowsOff()}eA(t,i,e,s){t&&(this.Ct!==null||this.vb(s))?(this.Ob(!0),this.shadowVisible===null&&i.shadowsOff()):this.Ob(!1)}sA(t,i,e){t&&this.o2()===!0&&i.shadowsOn(),e&&t&&i.shadowsOff()}CR(t,i,e){const s=this.part;let n=!1;s&&t.getRenderingHint("drawShadows")&&(n=s.isShadowed),i.clipInsteadOfFill&&(n=!1),this.Xs()&&n&&i.shadowsOn(),n&&this.shadowVisible===!0?i.shadowsOn():n&&this.shadowVisible===!1&&i.shadowsOff();const o=this.panel;if(n&&this.vb(o)&&this.shadowVisible===null&&i.shadowsOff(),i.tl){const r=t.computePixelRatio(),l=`drop-shadow(${i.shadowOffsetX/r}px ${i.shadowOffsetY/r}px ${i.shadowBlur/r/2}px ${i.shadowColor})`;this.background!==null&&e.Ct.setAttributeNS(null,"filter",l)}return n&&(this.Ct!==null||this.vb(o))?(this.Ob(!0),this.shadowVisible===null&&i.shadowsOff()):this.Ob(!1),n}LR(t,i,e,s){if(e.tl){const n=i.computePixelRatio(),o=`drop-shadow(${e.shadowOffsetX/n}px ${e.shadowOffsetY/n}px ${e.shadowBlur/n/2}px ${e.shadowColor})`;this.l2(t,o)}s&&this.o2()===!0&&e.shadowsOn(),this.Xs()&&e.shadowsOff()}vb(t){return t===null?!1:(t._r()&&(t=t.panel),t.o2()||(t.type===Panel.Auto||t.type===Panel.Spot)&&t.findMainElement()!==this)}l2(t,i){}Rb(t,i,e){const s=this.w0(),n=i.x,o=i.y,r=i.width+s,l=i.height+s;this.dn(t,this.Ct,!0,!1,i,e),this.Ct instanceof Brush&&this.Ct.type===3?(t.beginPath(),t.rect(n-s/2,o-s/2,r,l),t.fillContext(this.Ct,!1,null)):t.fillRect(n-s/2,o-s/2,r,l)}nA(t,i){let e=t.AR(this);const s=t.rh!==null?t.rh:t.svg;if(e!==-1)if(e===0)if(s.Ct)s.Ct.after(i);else if(t.type===Panel.Table){const n=s.getElementsByClassName("gojs-ts"),o=n.length!==0?n[0]:null;o!==null&&o.after(i)}else s.prepend(i);else{for(;e!==0&&!t.elt(e-1).isVisibleObject();)e--;if(e===0)s.prepend(i);else{const n=t.elt(e-1).svg;n!==null?n.after(i):s.appendChild(i)}}}MR(t,i){if(!(t instanceof SVGContext))return!1;if(!this.visible||this.opacity===0)return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;if(this.Xs()&&!this.isVisible())return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;const e=this.panel,s=this.ed(t);if(this.Qc(t,i,s))return this.oA(this.svg),this.svg.parentElement!==null?(this.Xs()&&(t.lastDrawnPart=this.svg),!0):(this.Xs()?(t.lastDrawnPart!==null?t.lastDrawnPart.after(this.svg):t.diagramGroup.prepend(this.svg),t.lastDrawnPart=this.svg):e&&this.nA(e,this.svg),!0);if(this.Xs()&&this.isShadowed){const m=this.shadowOffset;t.shadowsSet(m.x*i.scale*this.scale*i.Ui,m.y*i.scale*this.scale*i.Ui,this.shadowBlur),t.shadowsOn(),t.shadowColor=this.shadowColor}this instanceof TextBlock&&(t.font=this.font),t.currentElement=null;const n=this.D,o=this instanceof Panel,r=this instanceof Panel?this._r():!1,l=this.svg;this.y0()===!0&&this.Fb();const h=this.Li;if(t.setCurrentTransform(1,0,0,1,0,0),t.outerGroup=!1,s)if(t.outerGroup=!0,o&&r)t.newGroup(1,0,0,1,0,0),this.svg=t.lastCreatedElement;else if(o&&this.isClipping){const m=this.findMainElement();let g=0,p=0;m!==null&&(g=m.actualBounds.x,p=m.actualBounds.y),t.newGroup(n.m11,n.m12,n.m21,n.m22,n.dx+g,n.dy+p),this.svg=t.lastCreatedElement,m!==null&&t.createOrUpdateClipGroup(this,m.actualBounds),t.currentElement=t.lastCreatedElement}else o?(t.newGroup(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.svg=t.lastCreatedElement):t.newGroup(1,0,0,1,0,0);const a=this.naturalBounds;o||t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.background!==null&&(o?(r&&t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.Rb(t,a,h),r&&t.setCurrentTransform(1,0,0,1,0,0)):(t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.Rb(t,a,h)),t.currentElement.Ct=t.lastCreatedElement,t.currentElement.prepend(t.lastCreatedElement));const c=this.CR(i,t,t.currentElement);this.fh(t,i),o&&t.endGroup(),t.outerGroup&&t.endGroup();const f=t.surface.Gu,u=o?this.svg:t.currentElement;if(!o&&l!==null&&u!==l&&l.parentNode===this.panel.svg){const m=this.svg.getAttribute("filter");return m!==null&&u.setAttribute("filter",m),this.svg.replaceWith(u),this.svg=u,u!==null&&this.P0(t,e,h,u),t.rA(l),!0}if(this.svg=u,f!==null&&u===null&&t.dummyGroup(),u===null)return!0;this.P0(t,e,h,u),this.LR(u,i,t,c);const d=this.Xs()?this.opacity*t.globalAlpha:this.opacity;if(d!==1&&u.setAttributeNS(null,"opacity",d.toString()),this.filter!==""&&u.setAttributeNS(null,"filter",this.filter),this.Xs()){if(l!==null&&u!==l&&l.parentNode===t.diagramGroup){const m=l.getAttribute("filter");m!==null&&u.setAttribute("filter",m),l.replaceWith(u)}else t.lastDrawnPart?t.lastDrawnPart.after(u):t.diagramGroup.prepend(u);t.lastDrawnPart=u}else e!==null&&this.nA(e,u);return f!==null&&f(this,u),this.oA(u),!0}oA(t){const i=this,e=t.dataset;i instanceof GraphObject&&(i.portId!==null&&(e.portId=i.portId),i instanceof Panel&&(isNaN(i.itemIndex)||(e.itemIndex=i.itemIndex.toString()),i instanceof Part&&(e.className=Util.sn(i),i.key!==void 0&&(e.key=i.key.toString()),i.containingGroup!==null&&(e.group=i.containingGroup.key.toString()),i instanceof Link&&(i.fromNode!==null&&i.fromNode.key!==void 0&&(e.fromKey=i.fromNode.key.toString()),i.fromPortId!==""&&(e.fromPortId=i.fromPortId),i.toNode!==null&&i.toNode.key!==void 0&&(e.toKey=i.toNode.key.toString()),i.toPortId!==""&&(e.toPortId=i.toPortId)))))}P0(t,i,e,s){let n=(this.n&256)!==0;if(t.clipInsteadOfFill&&(n=!1),!n){s.removeAttributeNS(null,"clip-path"),t.rA(s);return}const o=i.pn()?i.naturalBounds:i.actualBounds;let r=Math.max(e.x,o.x),l=Math.max(e.y,o.y),h=Math.min(e.right,o.right)-r,a=Math.min(e.bottom,o.bottom)-l;const c=this.ni;c!==null&&(r=c.x,l=c.y,h=c.width,a=c.height);const f=t.TR(s);if(f===null){const u="CLIP"+GSet.su++,d={id:u},m=t.makeElement("clipPath",d),g=t.makeElement("rect",{x:r,y:l,width:h,height:a});if(this instanceof Panel){const p=this.D.copy().yw();g.setAttribute("transform",`matrix(${p.m11}, ${p.m12}, ${p.m21}, ${p.m22}, ${p.dx}, ${p.dy})`)}m.appendChild(g),t.svg.appendChild(m),s.setAttributeNS(null,"clip-path","url(#"+u+")")}else{const u=f.firstElementChild;u.setAttribute("x",r.toString()),u.setAttribute("y",l.toString()),u.setAttribute("width",h.toString()),u.setAttribute("height",a.toString())}}DR(){if(this.svg===null)return;const t=this.svg.innerHTML.match(/url\(#((CLIP|GRAD).+?)\)/g),i=this.svg.ownerDocument;if(t!==null)for(const e of t){const s=i.getElementById(e.split("#")[1].slice(0,-1));s!==null&&s.remove()}this.svg.remove()}NR(t,i){const e=this.Li,s=this.Vi,n=this.Ct;n!==null&&t.commitTransform(),n!==null&&(this.dn(t,n,!0,!1,s,e),n instanceof Brush&&n.type===3?(t.beginPath(),t.rect(e.x,e.y,e.width,e.height),t.fillContext(n,!1,null)):t.fillRect(e.x,e.y,e.width,e.height)),this.fh(t,i)}fh(t,i){}S0(){this.ss(!0)}Qc(t,i,e){const s=this.svg;if(this.FR()){if(this.S0(),this.ss(!1),s===null)return!1;const c=this.svg.getAttribute("clip-path");if(c!==null&&c.includes("url")){const f=t.svg.getElementById(c.split("#")[1].slice(0,-1));f!==null&&f.remove()}return!1}if(s===null)return!1;if(!this.visible)return s.remove(),!1;if(s.nodeName!=="g"&&e||s.nodeName==="g"&&!e)return!1;const n=this.D,o="matrix("+n.m11+", "+n.m12+", "+n.m21+", "+n.m22+", "+n.dx+", "+n.dy+")",r=this instanceof Panel,l=r?this._r():!1;if(!(r&&l))if(this instanceof Picture){const c=this.Ib;t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),c!==null&&t.amendImageTransform(c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7]),e?s.lastElementChild.setAttributeNS(null,"transform",t.getCurrentTransform()):s.setAttributeNS(null,"transform",t.getCurrentTransform())}else if(e&&!r)if(this instanceof Shape){const c=s.getElementsByTagName("path");for(let f=0;f=.1;){if(g){for(l=o[d++%h],l-=r;l<0;)l+=o[d++%h],m=!m;g=!1}else l=o[d++%h];l>u&&(l=u);let p=Math.sqrt(l*l/(1+f*f));a<0&&(p=-p),i+=p,e+=f*p,m?t.lineTo(i,e):t.moveTo(i,e),u-=l,m=!m}}dn(t,i,e,s,n,o){let r=1,l=1;if(typeof i=="string"){e?t.fillStyle=i:t.strokeStyle=i;return}else if(i.type===1){e?t.fillStyle=i.color:t.strokeStyle=i.color;return}let h;const a=this.w0();r=n.width,l=n.height,s?(r=o.width,l=o.height):e||(r+=a,l+=a);const c=t instanceof CanvasSurfaceContext;if(c&&i.yn&&(i.type===4||i._c===r&&i.Eb===l))h=i.yn;else{let f=0,u=0,d=0,m=0,g=0,p=0,y=0,x=0;if(s?(y=o.x,x=o.y):e||(y-=a/2,x-=a/2),f=i.start.x*r+i.start.offsetX+y,u=i.start.y*l+i.start.offsetY+x,d=i.end.x*r+i.end.offsetX+y,m=i.end.y*l+i.end.offsetY+x,i.type===2)h=t.createLinearGradient(f,u,d,m);else if(i.type===3)p=isNaN(i.endRadius)?Math.max(r,l)/2:i.endRadius,isNaN(i.startRadius)?(g=0,p=Math.max(r,l)/2):g=i.startRadius,h=t.createRadialGradient(f,u,g,d,m,p);else if(i.type===4)try{h=t.createPattern(i.pattern,"repeat")}catch{h=null}else Util.we(i.type,"Brush type");if(i.type!==4){const k=i.colorStops;if(k!==null){const b=k.iterator;for(;b.next();)h.addColorStop(b.key,b.value)}}if(c&&(i.yn=h,h!==null&&(i._c=r,i.Eb=l),h===null&&i.type===4&&i._c!==-1)){i._c=-1;const k=this.diagram;k!==null&&i._c===-1&&Util.Oh(()=>{k.redraw()},600)}}e?t.fillStyle=h:t.strokeStyle=h}isContainedBy(t){return t instanceof Panel?this.RR(this,t):!1}RR(t,i){if(t===i||i===null)return!1;let e=t.panel;for(;e!==null;){if(e===i)return!0;e=e.panel}return!1}isVisibleObject(){if(!this.visible)return!1;const t=this.panel;return t!==null?t.isVisibleObject():!0}isEnabledObject(){let t=this instanceof Panel?this:this.panel;for(;t!==null&&t.isEnabled;)t=t.panel;return t===null}get enabledChanged(){return this.f!==null?this.f.M0:null}set enabledChanged(t){const i=this.enabledChanged;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"enabledChanged"),this.jt(),this.f.M0=t,this.t("enabledChanged",i,t))}Fb(){if(this.Bb()===!0){const t=this.$r;if(t.Ri(),!this.Li.isReal()||!this.se.isReal()){this.sd(!1);return}if(t.Ds(this.Li.x-this.se.x,this.Li.y-this.se.y),this.scale!==1||this.angle!==0){const i=this.naturalBounds;this.p0(t,i.x,i.y,i.width,i.height)}this.sd(!1),this.wa(!0)}if(this.y0()===!0){const t=this.panel;if(t===null)this.oh.set(this.$r),this.ca=this.scale;else if(t.Es!==null){const i=this.oh;i.Ri(),t.pn()?i.ic(t.oh):t.panel!==null&&i.ic(t.panel.oh),i.ic(this.$r),this.ca=this.scale*t.ca}this.wa(!1)}}p0(t,i,e,s,n){if(this.et!==1&&t.et(this.et),this.Xt===0)return;const o=Point.l();o.setSpot(i,e,s,n,Spot.Center),t.cs(this.Xt,o.x,o.y),Point.s(o)}c(t){if(this.Oo())return;t===void 0&&(t=!1),this.ue(!0),this._n(!0);const i=this.panel;i!==null&&!t&&i.c()}tf(){this.Oo()||(this.ue(!0),this._n(!0))}ef(t){if(this.is())return;const i=this.panel;!t&&i!==null&&i.c(),this._n(!0)}_u(){this.Bb()===!1&&(this.sd(!0),this.wa(!0))}h2(){this.wa(!0)}C(){const t=this.part;t!==null&&t.C()}zs(t){const i=this.stretch,e=this.panel;if(e===null)return this.zo(i===1?0:i,t);if(e.type===Panel.Table)return this.N0(e.getRowDefinition(this.row),e.getColumnDefinition(this.column),t);if(e.type===Panel.Auto&&e.findMainElement()===this)return this.zo(2,t);if(i===1){if(e.type===Panel.Spot&&e.findMainElement()===this)return this.zo(2,t);const s=e.defaultStretch;return s===1?this.zo(0,t):this.zo(s,t)}return this.zo(i,t)}N0(t,i,e){const s=this.stretch;if(s!==1)return this.zo(s,e);let n=null,o=null;switch(t.stretch){case 1:case 5:break;case 4:o=!0;break;case 2:o=!0;break}switch(i.stretch){case 1:case 4:break;case 5:n=!0;break;case 2:n=!0;break}const r=this.panel.defaultStretch;return n===null&&(n=r===5||r===2),o===null&&(o=r===4||r===2),n===!0&&o===!0?this.zo(2,e):n===!0?this.zo(5,e):o===!0?this.zo(4,e):this.zo(0,e)}zo(t,i){if(i)return t;if(t===0)return 0;const e=this.desiredSize;if(e.isReal())return 0;const s=!isNaN(e.width),n=!isNaN(e.height),o=this.angle;if(s)if(o!==90&&o!==270){if(t===5)return 0;if(t===2)return 4}else{if(t===4)return 0;if(t===2)return 5}if(n)if(o!==90&&o!==270){if(t===4)return 0;if(t===2)return 5}else{if(t===5)return 0;if(t===2)return 4}return t}get segmentOrientation(){return this.Bt!==null?this.Bt.C0:0}set segmentOrientation(t){const i=this.segmentOrientation;i!==t&&(this.Bt===null&&(this.Bt=new LinkElementSettings),this.Bt.C0=t,this.c(),this.t("segmentOrientation",i,t),t===0&&(this.angle=0))}vR(){this.segmentOrientation=21}get segmentIndex(){return this.Bt!==null?this.Bt.L0:-1/0}set segmentIndex(t){t=Math.round(t);const i=this.segmentIndex;i!==t&&(this.Bt===null&&(this.Bt=new LinkElementSettings),this.Bt.L0=t,this.c(),this.t("segmentIndex",i,t))}get segmentFraction(){return this.Bt!==null?this.Bt.A0:0}set segmentFraction(t){isNaN(t)||t<0?t=0:t>1&&(t=1);const i=this.segmentFraction;i!==t&&(this.Bt===null&&(this.Bt=new LinkElementSettings),this.Bt.A0=t,this.c(),this.t("segmentFraction",i,t))}get segmentOffset(){return this.Bt!==null?this.Bt.T0:Point.Po}set segmentOffset(t){const i=this.segmentOffset;i.equals(t)||(t=t.N(),this.Bt===null&&(this.Bt=new LinkElementSettings),this.Bt.T0=t,this.c(),this.t("segmentOffset",i,t))}get stretch(){return this.f!==null?this.f.to:1}set stretch(t){const i=this.stretch;i!==t&&(this.jt(),this.f.to=t,this.c(),this.t("stretch",i,t))}get name(){return this.f!==null?this.f.Mt:""}set name(t){const i=this.name;i!==t&&(this.jt(),this.f.Mt=t,this.part!==null&&this.part.D0(),this.t("name",i,t))}get opacity(){return this.Wt}set opacity(t){const i=this.Wt;if(i!==t){Util.i(t,"number",GraphObject,"opacity"),(t<0||t>1)&&Util._(t,"0 <= value <= 1",GraphObject,"opacity"),this.Wt=t,this.t("opacity",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.C(s.Hh(s.actualBounds))}}get filter(){return this.Wu}set filter(t){const i=this.Wu;if(i!==t){this.Wu=t,this.ss(!0),this.t("filter",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.C(s.Hh(s.actualBounds))}}get visible(){return(this.n&1)!==0}set visible(t){const i=(this.n&1)!==0;if(i!==t){this.n=this.n^1,this.t("visible",i,t);const e=this.panel;e!==null?e.c():this.Xs()&&this.Ei(t),this.C(),this.lA()}}get pickable(){return(this.n&2)!==0}set pickable(t){const i=(this.n&2)!==0;i!==t&&(this.n=this.n^2,this.t("pickable",i,t))}get fromLinkableDuplicates(){return(this.n&4)!==0}set fromLinkableDuplicates(t){const i=(this.n&4)!==0;i!==t&&(this.n=this.n^4,this.t("fromLinkableDuplicates",i,t))}get fromLinkableSelfNode(){return(this.n&8)!==0}set fromLinkableSelfNode(t){const i=(this.n&8)!==0;i!==t&&(this.n=this.n^8,this.t("fromLinkableSelfNode",i,t))}get toLinkableDuplicates(){return(this.n&16)!==0}set toLinkableDuplicates(t){const i=(this.n&16)!==0;i!==t&&(this.n=this.n^16,this.t("toLinkableDuplicates",i,t))}get toLinkableSelfNode(){return(this.n&32)!==0}set toLinkableSelfNode(t){const i=(this.n&32)!==0;i!==t&&(this.n=this.n^32,this.t("toLinkableSelfNode",i,t))}get isPanelMain(){return(this.n&64)!==0}set isPanelMain(t){const i=(this.n&64)!==0;i!==t&&(this.n=this.n^64,this.c(),this.t("isPanelMain",i,t))}get isActionable(){return(this.n&128)!==0}set isActionable(t){const i=(this.n&128)!==0;i!==t&&(this.n=this.n^128,this.t("isActionable",i,t))}get background(){return this.Ct}set background(t){const i=this.Ct;i!==t&&(t!==null&&Brush.nd(t,"GraphObject.background"),t instanceof Brush&&t.g(),this.Ct=t,this.C(),this.t("background",i,t))}o2(){return(this.n&512)!==0}Ob(t){t?this.n|=512:this.n&=-513}$c(){return(this.n&1024)!==0}a2(t){t?this.n|=1024:this.n&=-1025}Bb(){return(this.n&2048)!==0}sd(t){t?this.n|=2048:this.n&=-2049}y0(){return(this.n&4096)!==0}wa(t){t?this.n|=4096:this.n&=-4097}Oo(){return(this.n&8192)!==0}ue(t){t?this.n|=8192:this.n&=-8193}is(){return(this.n&16384)!==0}_n(t){t?this.n|=16384:this.n&=-16385}FR(){return(this.n&32768)!==0}ss(t){t?this.n|=32768:this.n&=-32769}get part(){if(this.Xs())return this;if(this.Qr!==null)return this.Qr;let t=this;for(t=t.panel;t;){if(t instanceof Part)return this.Qr=t,t;t=t.panel}return null}get svg(){return this.Db}set svg(t){this.Db=t}Du(){this.svg=null}get panel(){return this.Vs}xa(t){this.Vs=t,this.svg!==null&&this.svg.remove()}get layer(){const t=this.part;return t!==null?t.layer:null}get diagram(){const t=this.part;return t!==null?t.diagram:null}get position(){return this.at}set position(t){const i=t.x,e=t.y,s=this.at,n=s.x,o=s.y;n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e))?(t=t.copy(),this.c2(t,n,o)&&this.t("position",new Point(n,o),t)):this.f2()}f2(){}c2(t,i,e){return this.at=t,this.ef(),!0}bc(t,i,e){this.at.x===t&&this.at.y===i||(this.at.e(t,i),this._u())}get actualBounds(){return this.Li}get scale(){return this.et}set scale(t){const i=this.et;i!==t&&(t<=0&&Util.o("GraphObject.scale for "+this+" must be greater than zero, not: "+t),this.et=t,this.c(),this.t("scale",i,t))}get angle(){return this.Xt}set angle(t){const i=this.Xt;if(i!==t){if(t=t%360,t<0&&(t+=360),i===t)return;this.Xt=t,this.lA(),this.c(),this.t("angle",i,t)}}get desiredSize(){return this.ze}set desiredSize(t){const i=t.width,e=t.height,s=this.ze,n=s.width,o=s.height;if((n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e)))&&(t=t.N(),this.ze=t,this.c(),this instanceof Shape&&this.ee(),this.t("desiredSize",s,t),this.$c())){const r=this.part;r!==null&&(this.ya(r,"width"),this.ya(r,"height"))}}get width(){return this.ze.width}set width(t){const i=this.ze.width;if(i!==t&&(!isNaN(i)||!isNaN(t))){const e=this.ze,s=new Size(t,this.ze.height).g();if(this.ze=s,this.c(),this instanceof Shape&&this.ee(),this.t("desiredSize",e,s),this.$c()){const n=this.part;n!==null&&this.ya(n,"width")}}}get height(){return this.ze.height}set height(t){const i=this.ze.height;if(i!==t&&(!isNaN(i)||!isNaN(t))){const e=this.ze,s=new Size(this.ze.width,t).g();if(this.ze=s,this.c(),this instanceof Shape&&this.ee(),this.t("desiredSize",e,s),this.$c()){const n=this.part;n!==null&&this.ya(n,"height")}}}get minSize(){return this.f!==null?this.f.xr:Size.ru}set minSize(t){const i=this.minSize;i.equals(t)||(t=t.copy(),isNaN(t.width)&&(t.width=0),isNaN(t.height)&&(t.height=0),t.g(),this.jt(),this.f.xr=t,this.c(),this.t("minSize",i,t))}get maxSize(){return this.f!==null?this.f.br:Size.iC}set maxSize(t){const i=this.maxSize;i.equals(t)||(t=t.copy(),isNaN(t.width)&&(t.width=1/0),isNaN(t.height)&&(t.height=1/0),t.g(),this.jt(),this.f.br=t,this.c(),this.t("maxSize",i,t))}get measuredBounds(){return this.se}get naturalBounds(){return this.Vi}w0(){return 0}get margin(){return this.Zr}set margin(t){typeof t=="number"&&(t=new Margin(t));const i=this.Zr;i.equals(t)||(t=t.N(),this.Zr=t,this.c(),this.t("margin",i,t))}get D(){return this.Bb()===!0&&this.Fb(),this.$r}get Es(){return this.y0()===!0&&this.Fb(),this.oh}trigger(t,i,e){let s=null;return typeof t=="string"?s=new AnimationTrigger(t,i,e):s=t,s.ke=this,this.ys===null&&(this.ys=new GMap),this.ys.set(s.propertyName,s),this}get ys(){return this.f!==null?this.f.ys:null}set ys(t){this.ys!==t&&(this.jt(),this.f.ys=t)}get wr(){return this.f!==null?this.f.wr:0}set wr(t){this.wr!==t&&(this.jt(),this.f.wr=t)}get alignment(){return this.oi}set alignment(t){const i=this.oi;i.equals(t)||(t.isNoSpot()&&!t.isDefault()&&Util.o("GraphObject.alignment for "+this+" must be a real Spot or Spot.Default, not: "+t),t=t.N(),this.oi=t,this.ef(),this.t("alignment",i,t))}get column(){return this.Uo}set column(t){t=Math.round(t);const i=this.Uo;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"column"),this.Uo=t,this.c(),this.t("column",i,t),this.svg!==null&&this.svg.remove())}get columnSpan(){return this.f!==null?this.f.F0:1}set columnSpan(t){t=Math.round(t);const i=this.columnSpan;i!==t&&(t<1&&Util._(t,">= 1",GraphObject,"columnSpan"),this.jt(),this.f.F0=t,this.c(),this.t("columnSpan",i,t))}get row(){return this.qu}set row(t){t=Math.round(t);const i=this.qu;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"row"),this.qu=t,this.c(),this.t("row",i,t),this.svg!==null&&this.svg.remove())}get rowSpan(){return this.f!==null?this.f.R0:1}set rowSpan(t){t=Math.round(t);const i=this.rowSpan;i!==t&&(t<1&&Util._(t,">= 1",GraphObject,"rowSpan"),this.jt(),this.f.R0=t,this.c(),this.t("rowSpan",i,t))}get spanAllocation(){return this.f!==null?this.f.v0:null}set spanAllocation(t){const i=this.spanAllocation;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"spanAllocation"),this.jt(),this.f.v0=t,this.c(),this.t("spanAllocation",i,t))}get alignmentFocus(){return this.Wc}set alignmentFocus(t){const i=this.Wc;i.equals(t)||(t=t.N(),this.Wc=t,this.c(),this.t("alignmentFocus",i,t))}get portId(){return this.Hu}set portId(t){const i=this.Hu;if(i!==t){const e=this.part;e!==null&&!(e instanceof Node)&&Util.o("Cannot set portID on a Link: "+t);const s=e;i!==null&&s!==null&&s.u2(this),this.Hu=t,t!==null&&s!==null&&(s.wn=!0,s.hA(this)),this.t("portId",i,t)}}ba(){const t=this.part;if(t instanceof Node&&(this.portId!==null||this===t.port)){const i=t.diagram;i!==null&&!i.undoManager.isUndoingRedoing&&t.tA(this)}}lA(){const t=this.diagram;t===null||t.undoManager.isUndoingRedoing||(this instanceof Panel?this instanceof Node?this.invalidateConnectedLinks():this.walkVisualTreeFrom(this,i=>{i.ba()}):this.ba())}get toSpot(){return this.q!==null?this.q.ua:Spot.None}set toSpot(t){const i=this.toSpot;i.equals(t)||(t=t.N(),this.Xe(),this.q.ua=t,this.t("toSpot",i,t),this.ba())}get toEndSegmentLength(){return this.q!==null?this.q.ga:10}set toEndSegmentLength(t){const i=this.toEndSegmentLength;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"toEndSegmentLength"),this.Xe(),this.q.ga=t,this.t("toEndSegmentLength",i,t),this.ba())}get toShortLength(){return this.q!==null?this.q.pa:0}set toShortLength(t){const i=this.toShortLength;i!==t&&(this.Xe(),this.q.pa=t,this.t("toShortLength",i,t),this.ba())}get toLinkable(){return this.q!==null?this.q.O0:null}set toLinkable(t){const i=this.toLinkable;i!==t&&(this.Xe(),this.q.O0=t,this.t("toLinkable",i,t))}get toMaxLinks(){return this.q!==null?this.q.I0:1/0}set toMaxLinks(t){const i=this.toMaxLinks;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"toMaxLinks"),this.Xe(),this.q.I0=t,this.t("toMaxLinks",i,t))}get fromSpot(){return this.q!==null?this.q.fa:Spot.None}set fromSpot(t){const i=this.fromSpot;i.equals(t)||(t=t.N(),this.Xe(),this.q.fa=t,this.t("fromSpot",i,t),this.ba())}get fromEndSegmentLength(){return this.q!==null?this.q.da:10}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"fromEndSegmentLength"),this.Xe(),this.q.da=t,this.t("fromEndSegmentLength",i,t),this.ba())}get fromShortLength(){return this.q!==null?this.q.ma:0}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(this.Xe(),this.q.ma=t,this.t("fromShortLength",i,t),this.ba())}get fromLinkable(){return this.q!==null?this.q.E0:null}set fromLinkable(t){const i=this.fromLinkable;i!==t&&(this.Xe(),this.q.E0=t,this.t("fromLinkable",i,t))}get fromMaxLinks(){return this.q!==null?this.q.B0:1/0}set fromMaxLinks(t){const i=this.fromMaxLinks;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"fromMaxLinks"),this.Xe(),this.q.B0=t,this.t("fromMaxLinks",i,t))}get cursor(){return this.f!==null?this.f.Sl:""}set cursor(t){const i=this.cursor;i!==t&&(Util.i(t,"string",GraphObject,"cursor"),this.jt(),this.f.Sl=t,this.t("cursor",i,t))}get click(){return this.f!==null?this.f.Tr:null}set click(t){const i=this.click;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"click"),this.jt(),this.f.Tr=t,this.t("click",i,t))}get doubleClick(){return this.f!==null?this.f.Dr:null}set doubleClick(t){const i=this.doubleClick;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"doubleClick"),this.jt(),this.f.Dr=t,this.t("doubleClick",i,t))}get contextClick(){return this.f!==null?this.f.Fr:null}set contextClick(t){const i=this.contextClick;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"contextClick"),this.jt(),this.f.Fr=t,this.t("contextClick",i,t))}get mouseEnter(){return this.f!==null?this.f.Er:null}set mouseEnter(t){const i=this.mouseEnter;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseEnter"),this.jt(),this.f.Er=t,this.t("mouseEnter",i,t))}get mouseLeave(){return this.f!==null?this.f.Br:null}set mouseLeave(t){const i=this.mouseLeave;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseLeave"),this.jt(),this.f.Br=t,this.t("mouseLeave",i,t))}get mouseOver(){return this.f!==null?this.f.Rr:null}set mouseOver(t){const i=this.mouseOver;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseOver"),this.jt(),this.f.Rr=t,this.t("mouseOver",i,t))}get mouseHover(){return this.f!==null?this.f.vr:null}set mouseHover(t){const i=this.mouseHover;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseHover"),this.jt(),this.f.vr=t,this.t("mouseHover",i,t))}get mouseHold(){return this.f!==null?this.f.Or:null}set mouseHold(t){const i=this.mouseHold;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseHold"),this.jt(),this.f.Or=t,this.t("mouseHold",i,t))}get mouseDragEnter(){return this.f!==null?this.f.U0:null}set mouseDragEnter(t){const i=this.mouseDragEnter;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDragEnter"),this.jt(),this.f.U0=t,this.t("mouseDragEnter",i,t))}get mouseDragLeave(){return this.f!==null?this.f.V0:null}set mouseDragLeave(t){const i=this.mouseDragLeave;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDragLeave"),this.jt(),this.f.V0=t,this.t("mouseDragLeave",i,t))}get mouseDrop(){return this.f!==null?this.f.Ir:null}set mouseDrop(t){const i=this.mouseDrop;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDrop"),this.jt(),this.f.Ir=t,this.t("mouseDrop",i,t))}get actionDown(){return this.f!==null?this.f.z0:null}set actionDown(t){const i=this.actionDown;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionDown"),this.jt(),this.f.z0=t,this.t("actionDown",i,t))}get actionMove(){return this.f!==null?this.f.X0:null}set actionMove(t){const i=this.actionMove;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionMove"),this.jt(),this.f.X0=t,this.t("actionMove",i,t))}get actionUp(){return this.f!==null?this.f.K0:null}set actionUp(t){const i=this.actionUp;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionUp"),this.jt(),this.f.K0=t,this.t("actionUp",i,t))}get actionCancel(){return this.f!==null?this.f.Y0:null}set actionCancel(t){const i=this.actionCancel;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionCancel"),this.jt(),this.f.Y0=t,this.t("actionCancel",i,t))}get toolTip(){return this.f!==null?this.f.Ur:null}set toolTip(t){const i=this.toolTip;i!==t&&(this.jt(),this.f.Ur=t,this.t("toolTip",i,t))}get contextMenu(){return this.f!==null?this.f.Vr:null}set contextMenu(t){const i=this.contextMenu;i!==t&&(this.jt(),this.f.Vr=t,this.t("contextMenu",i,t))}findBindingPanel(){let t=this instanceof Panel?this:this.panel;for(;t!==null;){if(t.d2())return t;t=t.panel}return null}bind(t,i,e,s){return this.sf(t,i,e,s),this}bindTwoWay(t,i,e,s){return this.sf(t,i,e,s).makeTwoWay(),this}bindModel(t,i,e,s){return this.sf(t,i,e,s).ofModel(),this}bindObject(t,i,e,s,n){return this.sf(t,i,e,s).ofObject(n),this}theme(t,i,e,s,n){return this.uh(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.uh(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.uh(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.uh(t,i,e,s,n).ofModel(),this}sf(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.G0(n),n}uh(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.G0(o),o}G0(t){t.ke=this;const i=this.findBindingPanel();i!==null&&i.aA()&&Util.o("Cannot add a Binding to a template that has already been copied: "+t),this.Ai===null&&(this.Ai=new List),this.Ai.add(t)}set(t){return Object.assign(this,t),this}attach(t){return GraphObject.g2(this,t),this}apply(t){return t(this),this}setProperties(t){return Diagram.h0(this,t),this}static build(t,i,...e){const s=GraphObject.j0.get(t);if(typeof s=="function"){const n=s([t].concat(e));if(n instanceof GraphObject)return i&&n.setProperties(i),n}Util.o('GraphObject.build invoked object builder "'+t+'", but it did not return an Object')}static make(t,...i){let e=arguments,s=null,n=null;if(typeof t=="function")n=t;else if(typeof t=="string"){const r=GraphObject.j0.get(t);typeof r=="function"?(e=Array.prototype.slice.call(e),s=r(e),Util.wt(s)||Util.o('GraphObject.make invoked object builder "'+t+'", but it did not return an Object')):n=root.go[t]}s===null&&((n==null||!n.constructor)&&Util.o("GraphObject.make requires a class function or GoJS class name or name of an object builder, not: "+t),s=new n);let o=1;if(s instanceof Diagram&&e.length>1){const r=s,l=e[1];(typeof l=="string"||l instanceof HTMLDivElement)&&(r.mM(l),o++)}for(let r=o;r{const i="#f5f5f5",e="#737373",s="#d4d4d4",n="#737373",o="#a3a3a3",r=2.76142374915397,l=2.761423749153969,h=new Panel(Panel.Auto,{isActionable:!0,enabledChanged:(a,c)=>{if(a instanceof Panel){const f=a.findObject("ButtonBorder");f!==null&&(c?(a._buttonFillDisabled=f.fill,f.fill=a._buttonFillNormal):(a._buttonFillNormal=f.fill,f.fill=a._buttonFillDisabled))}},cursor:"pointer"}).attach({_buttonFillNormal:i,_buttonStrokeNormal:e,_buttonFillOver:s,_buttonStrokeOver:n,_buttonFillDisabled:o}).add(new Shape("RoundedRectangle",{name:"ButtonBorder",spot1:new Spot(0,0,r,l),spot2:new Spot(1,1,-r,-l),parameter1:2,fill:i,stroke:e}));return h.mouseEnter=(a,c,f)=>{if(!c.isEnabledObject()||!(c instanceof Panel))return;const u=c.findObject("ButtonBorder");u instanceof Shape&&(c._buttonFillNormal=u.fill,u.fill=c._buttonFillOver,c._buttonStrokeNormal=u.stroke,u.stroke=c._buttonStrokeOver)},h.mouseLeave=(a,c,f)=>{if(!c.isEnabledObject()||!(c instanceof Panel))return;const u=c.findObject("ButtonBorder");u instanceof Shape&&(u.fill=c._buttonFillNormal,u.stroke=c._buttonStrokeNormal)},h}),GraphObject.defineBuilder("TreeExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_treeExpandedFigure:"MinusLine",_treeCollapsedFigure:"PlusLine",visible:!1}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.lu}).bindObject("figure","isTreeExpanded",(e,s)=>{const n=s.panel;return e?n._treeExpandedFigure:n._treeCollapsedFigure})),i.bindObject("visible","isTreeLeaf",e=>!e),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Node))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isTreeExpanded){if(!r.canCollapseTree(n))return}else if(!r.canExpandTree(n))return;e.handled=!0,n.isTreeExpanded?r.collapseTree(n):r.expandTree(n)},i}),GraphObject.defineBuilder("SubGraphExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_subGraphExpandedFigure:"MinusLine",_subGraphCollapsedFigure:"PlusLine"}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.lu}).bindObject("figure","isSubGraphExpanded",(e,s)=>{const n=s.panel;return e?n._subGraphExpandedFigure:n._subGraphCollapsedFigure})),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Group))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isSubGraphExpanded){if(!r.canCollapseSubGraph(n))return}else if(!r.canExpandSubGraph(n))return;e.handled=!0,n.isSubGraphExpanded?r.collapseSubGraph(n):r.expandSubGraph(n)},i}),GraphObject.defineBuilder("ToolTip",t=>new Adornment(Panel.Auto,{isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).add(new Shape("RoundedRectangle",{name:"Border",parameter1:1,fill:"#f5f5f5",strokeWidth:0,spot1:new Spot(0,0,4,6),spot2:new Spot(1,1,-4,-4)}))),GraphObject.defineBuilder("ContextMenu",t=>new Adornment(Panel.Vertical,{background:"#f5f5f5",isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).bindObject("background","",i=>i.adornedPart!==null&&i.hasPlaceholder()?null:"#f5f5f5")),GraphObject.defineBuilder("ContextMenuButton",t=>{const i=GraphObject.build("Button");i.stretch=5;const e=i.findObject("ButtonBorder");return e instanceof Shape&&(e.figure="Rectangle",e.strokeWidth=0,e.spot1=new Spot(0,0,4,6),e.spot2=new Spot(1,1,-4,-4)),i}),GraphObject.defineBuilder("PanelExpanderButton",t=>{const i=GraphObject.takeBuilderArgument(t,"COLLAPSIBLE"),e=GraphObject.build("Button");e.attach({_buttonExpandedFigure:"M0 0 M0 6 L4 2 8 6 M8 8",_buttonCollapsedFigure:"M0 0 M0 2 L4 6 8 2 M8 8",_buttonFillNormal:"rgba(0, 0, 0, 0)",_buttonStrokeNormal:null,_buttonFillOver:"rgba(0, 0, 0, .2)",_buttonStrokeOver:null}),e.add(new Shape({name:"ButtonIcon",strokeWidth:2}).bindObject("geometryString","visible",n=>n?e._buttonExpandedFigure:e._buttonCollapsedFigure,void 0,i));const s=e.findObject("ButtonBorder");return s instanceof Shape&&(s.stroke=null,s.fill="rgba(0, 0, 0, 0)"),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=o.diagram;if(r===null||r.isReadOnly)return;let l=o.findBindingPanel();if(l===null&&(l=o.part),l!==null){const h=l.findObject(i);h!==null&&(n.handled=!0,r.startTransaction("Collapse/Expand Panel"),h.visible=!h.visible,r.commitTransaction("Collapse/Expand Panel"))}},e}),GraphObject.defineBuilder("CheckBoxButton",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("Button",{desiredSize:new Size(14,14)});e.attach({"ButtonBorder.spot1":new Spot(0,0,1,1),"ButtonBorder.spot2":new Spot(1,1,-1,-1)});const s=new Shape({name:"ButtonIcon",geometryString:"M0 0 M0 8.85 L4.9 13.75 16.2 2.45 M16.2 16.2",strokeWidth:2,stretch:2,geometryStretch:6,visible:!1});return i!==""&&s.bindTwoWay("visible",i),e.add(s),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=n.diagram;if(r===null||r.isReadOnly||i!==""&&r.model.isReadOnly)return;n.handled=!0;const l=o.findObject("ButtonIcon");r.startTransaction("checkbox"),l!==null&&(l.visible=!l.visible),typeof o._doClick=="function"&&o._doClick(n,o),r.commitTransaction("checkbox")},e}),GraphObject.defineBuilder("CheckBox",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("CheckBoxButton",{name:"Button",isActionable:!1,margin:new Margin(0,1,0,0)},i),s=new Panel("Horizontal",{isActionable:!0,cursor:e.cursor,margin:new Margin(1),mouseEnter:e.mouseEnter,mouseLeave:e.mouseLeave,click:e.click}).attach({_buttonFillNormal:e._buttonFillNormal,_buttonStrokeNormal:e._buttonStrokeNormal,_buttonFillOver:e._buttonFillOver,_buttonStrokeOver:e._buttonStrokeOver,_buttonFillDisabled:e._buttonFillDisabled,_buttonClick:e.click});return s.add(e),e.mouseEnter=null,e.mouseLeave=null,e.click=null,s})}}class GraphObjectTemplateSettings{gi;Mt;$n;Ai;Zn;Ks;Sl;Tr;Dr;Fr;Er;Br;Rr;vr;Or;U0;V0;Ir;z0;X0;K0;Y0;Ur;Vr;M0;v0;ys;xr;br;to;R0;F0;wr;k0;H0;q0;constructor(){this.gi=!1,this.Mt="",this.$n=-1,this.Ai=null,this.Zn=null,this.Ks=null,this.Sl="",this.Tr=null,this.Dr=null,this.Fr=null,this.Er=null,this.Br=null,this.Rr=null,this.vr=null,this.Or=null,this.U0=null,this.V0=null,this.Ir=null,this.z0=null,this.X0=null,this.K0=null,this.Y0=null,this.Ur=null,this.Vr=null,this.M0=null,this.v0=null,this.ys=null,this.xr=Size.ru,this.br=Size.iC,this.to=1,this.R0=1,this.F0=1,this.wr=0,this.k0=null,this.H0=null,this.q0="category"}copy(){const t=new GraphObjectTemplateSettings;return t.Mt=this.Mt,t.$n=this.$n,t.Ai=this.Ai,t.Ks=this.Ks,t.Sl=this.Sl,t.Tr=this.Tr,t.Dr=this.Dr,t.Fr=this.Fr,t.Er=this.Er,t.Br=this.Br,t.Rr=this.Rr,t.vr=this.vr,t.Or=this.Or,t.U0=this.U0,t.V0=this.V0,t.Ir=this.Ir,t.z0=this.z0,t.X0=this.X0,t.K0=this.K0,t.Y0=this.Y0,t.Ur=this.Ur,t.Vr=this.Vr,t.M0=this.M0,t.v0=this.v0,t.ys=this.ys,t.xr=this.xr.N(),t.br=this.br.N(),t.to=this.to,t.R0=this.R0,t.F0=this.F0,t.wr=this.wr,t.k0=this.k0,t.H0=this.H0,t.q0=this.q0,t}}class STransform{m;constructor(){this.m=[1,0,0,1,0,0]}copy(){const t=new STransform;return t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5],t}translate(t,i){this.m[4]+=this.m[0]*t+this.m[2]*i,this.m[5]+=this.m[1]*t+this.m[3]*i}scale(t,i){this.m[0]*=t,this.m[1]*=t,this.m[2]*=i,this.m[3]*=i}rotate(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return;this.translate(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m[0]*s+this.m[2]*n,r=this.m[1]*s+this.m[3]*n,l=this.m[0]*-n+this.m[2]*s,h=this.m[1]*-n+this.m[3]*s;this.m[0]=o,this.m[1]=r,this.m[2]=l,this.m[3]=h,this.translate(-i,-e)}}class SGradient{type;x1;y1;r1;x2;y2;r2;colors;pattern;constructor(t){this.type=t,this.x1=0,this.y1=0,this.r1=0,this.x2=0,this.y2=0,this.r2=0,this.colors=[],this.pattern=null}addColorStop(t,i){this.colors.push({offset:t,color:i})}}class SVGSurface{Ft;ai;aa;Gu;m2;constructor(t,i,e){const s=i===void 0?root.document:i;this.aa=s,this.m2="http://www.w3.org/2000/svg";const n="http://www.w3.org/2000/xmlns/";s!==void 0&&(this.Ft=this.makeElement("svg",{width:"1px",height:"1px",viewBox:"0 0 1 1"}),this.style.display="block",this.style.letterSpacing="normal",this.style.wordSpacing="normal",e||(this.style.position="absolute"),this.Ft.setAttributeNS(n,"xmlns",this.m2),this.Ft.setAttributeNS(n,"xmlns:xlink","http://www.w3.org/1999/xlink")),this.Gu=null,this.ai=new SVGContext(this,e)}resize(t,i,e,s){return this.width!==t||this.height!==i?(this.width=t,this.height=i,this.style.width=e+"px",this.style.height=s+"px",this.Ft.setAttributeNS(null,"width",e+"px"),this.Ft.setAttributeNS(null,"height",s+"px"),this.Ft.setAttributeNS(null,"viewBox","0 0 "+e+" "+s),this.ai.p2.firstElementChild.setAttributeNS(null,"width",e+"px"),this.ai.p2.firstElementChild.setAttributeNS(null,"height",s+"px"),!0):!1}makeElement(t,i,e){const s=this.aa.createElementNS(this.m2,t);if(Util.wt(i))for(const n in i)s.setAttributeNS(n==="href"?"http://www.w3.org/1999/xlink":"",n,i[n]);return e!==void 0&&(s.textContent=e),s}getBoundingClientRect(){return this.Ft.getBoundingClientRect()}focus(){this.Ft.focus()}get width(){return this.Ft.width.baseVal.value}set width(t){this.Ft.setAttribute("width",t+"px")}get height(){return this.Ft.height.baseVal.value}set height(t){this.Ft.setAttribute("height",t+"px")}dispose(){this.aa=null}get style(){return this.Ft.style}}class SVGContext{nf;of;xn;Ti;Ke;fillStyle;font;globalAlpha;lineCap;lineDashOffset;lineJoin;lineWidth;miterLimit;shadowBlur;shadowColor;shadowOffsetX;shadowOffsetY;strokeStyle;textAlign;imageSmoothingEnabled;clipInsteadOfFill;lastCreatedElement;rf;lf;surface;svg;p2;cA;Vb;Xo;dh;ka;currentElement;clipPathGroup;diagramGroup;lastDrawnPart;currentPath;outerGroup;pathAttributes;tl;Mr;filter;partClipRect;constructor(t,i){this.surface=t,this.svg=t.Ft,this.rf=[],this.lf=[],this.fillStyle="#000000",this.font="10px sans-serif",this.globalAlpha=1,this.lineCap="butt",this.lineDashOffset=0,this.lineJoin="miter",this.lineWidth=1,this.miterLimit=10,this.shadowBlur=0,this.shadowColor="rgba(0, 0, 0, 0)",this.shadowOffsetX=0,this.shadowOffsetY=0,this.tl=!1,this.strokeStyle="#000000",this.textAlign="start",this.clipInsteadOfFill=!1,this.nf=0,this.of=0,this.xn=0,this.lastCreatedElement=null,this.currentElement=null,this.Ti=[],this.pathAttributes={},this.Vb=!1,this.Xo=null,this.dh=0,this.Ke=new STransform,this.clipPathGroup=this.newGroup2(),this.diagramGroup=this.newGroup2("gojs-diagram"),this.lastDrawnPart=null,this.currentPath=null;const e=GSet.su++,s=this.makeElement("clipPath",{id:"mainClip"+e}),n={x:0,y:0,width:t.width,height:t.height};s.appendChild(this.makeElement("rect",n)),this.p2=s,this.svg.appendChild(this.clipPathGroup),this.clipPathGroup.appendChild(this.diagramGroup),this.svg.appendChild(s),this.clipPathGroup.setAttributeNS(null,"clip-path","url(#mainClip"+e+")"),this.cA={},this.Mr=!!i,this.filter="",this.partClipRect=null}setDiagramPosScale(t,i,e,s,n,o){this.diagramGroup===void 0?this.newGroup(t,i,e,s,n,o):this.diagramGroup.setAttribute("transform","matrix("+t+", "+i+", "+e+", "+s+", "+n+", "+o+")")}resetInnerSVG(){this.diagramGroup!==null&&(this.diagramGroup.innerHTML="")}arc(t,i,e,s,n,o,r,l){const h=2*Math.PI,a=1e-6,c=h-a,f=e*Math.cos(s),u=e*Math.sin(s),d=t+f,m=i+u,g=o?0:1;let p=o?s-n:n-s;(Math.abs(r-d)>a||Math.abs(l-m)>a)&&this.Ti.push(["L",d,+m]),p<0&&(p=p%h+h),p>c?(this.Ti.push(["A",e,e,0,1,g,t-f,i-u]),this.Ti.push(["A",e,e,0,1,g,d,m])):p>a&&this.Ti.push(["A",e,e,0,+(p>=Math.PI),g,t+e*Math.cos(n),i+e*Math.sin(n)])}beginPath(){this.Ti=[],this.pathAttributes={stroke:"none",fill:"none"}}endPath(t){this.BR(this.Ti,this.Ke,t||0)}bezierCurveTo(t,i,e,s,n,o){this.Ti.push(["C",t,i,e,s,n,o])}clearRect(t,i,e,s){}clip(){this.pathAttributes.clipPath=!0}closePath(){this.Ti.push(["z"])}createLinearGradient(t,i,e,s){const n=new SGradient("linear");return n.x1=t,n.y1=i,n.x2=e,n.y2=s,n}createPattern(t,i){let e="";t instanceof HTMLCanvasElement&&(e=t.toDataURL()),t instanceof HTMLImageElement&&(e=t.getAttribute("src"));const s=this.cA;if(s[e])return"url(#"+s[e]+")";const n="PATTERN"+GSet.su++,o={width:t.width,height:t.height,id:n,patternUnits:"userSpaceOnUse"},r={x:0,y:0,width:t.width,height:t.height,href:e},l=this.makeElement("pattern",o);return l.appendChild(this.makeElement(Diagram.img,r)),this.svg.appendChild(l),s[e]=n,"url(#"+n+")"}createRadialGradient(t,i,e,s,n,o){const r=new SGradient("radial");return r.x1=t,r.y1=i,r.r1=e,r.x2=s,r.y2=n,r.r2=o,r}amendImageTransform(t,i,e,s,n,o,r,l){const h=r/e,a=l/s;(n!==0||o!==0)&&this.Ke.translate(n,o),(h!==1||a!==1)&&this.Ke.scale(h,a),(t!==0||i!==0)&&this.Ke.translate(-t,-i)}drawImage(t,i,e,s,n,o,r,l,h){let a="";t instanceof HTMLCanvasElement&&(a=t.toDataURL()),t instanceof HTMLImageElement&&(a=t.getAttribute("src"));const c=t instanceof HTMLImageElement?t.naturalWidth:t.width,f=t instanceof HTMLImageElement?t.naturalHeight:t.height;s===void 0&&(o=i,r=e,l=s=c,h=n=f),s=s||0,n=n||0,o=o||0,r=r||0,l=l||0,h=h||0,this.amendImageTransform(i,e,s,n,o,r,l,h);const u={x:0,y:0,width:c||s,height:f||n,href:a};!Geo.K(s,l)||!Geo.K(n,h)?u.preserveAspectRatio="none":a.toLowerCase().indexOf(".svg")===-1&&a.toLowerCase().indexOf("data:image/svg")===-1&&(u.preserveAspectRatio="xMidYMid slice"),(i!==0||e!==0||s!==c||n!==f)&&(s+=i,n+=e,u["clip-path"]=`path('M ${i},${e} L ${s} ${e} L ${s} ${n} L ${i} ${n} z')`),this.processCommon(Diagram.img,u,this.Ke),this.od(Diagram.img,u)}fill(t,i){t&&(this.pathAttributes["fill-rule"]="evenodd"),this.setFill(this.pathAttributes)}fillContext(t,i,e){this.clipInsteadOfFill?this.clip():this.fill(i,e)}createOrUpdateClipGroup(t,i){const e=this.newGroup(1,0,0,1,-i.x,-i.y);e.setAttributeNS(null,"class","spotClip"),t.rh=e}fillRect(t,i,e,s){this.addRect("fill",[t,i,e,s],this.Ke)}fillBackground(t,i,e,s){const n={x:t,y:i,width:e,height:s};this.processCommon("fill",n,this.Ke),this.setFill(n),this.svg.prepend(this.makeElement("rect",n))}fillText(t,i,e){this.addText("fill",[t,i,e],this.Ke)}lineTo(t,i){this.Ti.push(["L",t,i])}moveTo(t,i){this.Ti.push(["M",t,i])}quadraticCurveTo(t,i,e,s){this.Ti.push(["Q",t,i,e,s])}rect(t,i,e,s){this.Ti.push(["M",t,i],["L",t+e,i],["L",t+e,i+s],["L",t,i+s],["z"])}restore(){this.Ke=this.rf.pop(),this.Ti=this.rf.pop();const t=this.rf.pop();this.fillStyle=t.fillStyle,this.font=t.font,this.globalAlpha=t.globalAlpha,this.lineCap=t.lineCap,this.lineDashOffset=t.lineDashOffset,this.lineJoin=t.lineJoin,this.lineWidth=t.lineWidth,this.miterLimit=t.miterLimit,this.shadowBlur=t.shadowBlur,this.shadowColor=t.shadowColor,this.shadowOffsetX=t.shadowOffsetX,this.shadowOffsetY=t.shadowOffsetY,this.strokeStyle=t.strokeStyle,this.textAlign=t.textAlign,this.partClipRect=t.partClipRect}save(){const t={fillStyle:this.fillStyle,font:this.font,globalAlpha:this.globalAlpha,lineCap:this.lineCap,lineDashOffset:this.lineDashOffset,lineJoin:this.lineJoin,lineWidth:this.lineWidth,miterLimit:this.miterLimit,shadowBlur:this.shadowBlur,shadowColor:this.shadowColor,shadowOffsetX:this.shadowOffsetX,shadowOffsetY:this.shadowOffsetY,strokeStyle:this.strokeStyle,textAlign:this.textAlign,partClipRect:this.partClipRect};this.rf.push(t);const i=[];for(let e=0;eh.offset>a.offset?1:-1);for(let h=0;h1&&this.lf[this.lf.length-2].setAttributeNS(null,"clip-path",'path("'+s+'") view-box');return}if(n.d=s,this.processCommon("",n,i),this.currentPath!==null){const r=this.currentPath;if(r.nodeName!=="g")for(const l in n)l!=="transform"&&r.setAttributeNS(null,l,n[l]);else{const l=r.getElementsByTagName("path");for(const h in n)h!=="transform"&&l[e].setAttributeNS(null,h,n[h])}}else this.od("path",n)}TR(t){const i=t.getAttribute("clip-path");return i===null?null:this.svg.getElementById(i.split("#")[1].slice(0,-1))}rA(t){const i=t.getAttribute("clip-path");if(i===null)return;const e=this.svg.getElementById(i.split("#")[1].slice(0,-1));e!==null&&e.remove()}UR(t){const i=[];for(let e=0;es?(this.scale(s/n,1),this.translate((n-s)/2,0)):s>n&&(this.scale(1,n/s),this.translate(0,(s-n)/2)),this.fillOrClip(i,e),n>s?(this.translate(-(n-s)/2,0),this.scale(1/(s/n),1)):s>n&&(this.translate(0,-(s-n)/2),this.scale(1,1/(n/s))),!0}strokeContext(){this.clipInsteadOfFill||this.stroke()}fillOrClip(t,i){this.clipInsteadOfFill?this.clip(i):this.fill(t,i)}shadowsSet(t,i,e){this.nf=t,this.of=i,this.xn=e}shadowsOff(){this.tl=!1,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0}shadowsOn(){this.tl=!0,this.shadowOffsetX=this.nf,this.shadowOffsetY=this.of,this.shadowBlur=this.xn}enableDash(t,i){const e=this.U;e.setLineDash!==void 0&&(e.setLineDash(t),e.lineDashOffset=i)}disableDash(){const t=this.U;t.setLineDash!==void 0&&(t.setLineDash(CanvasSurfaceContext.EmptyArray),t.lineDashOffset=0)}clearContextCache(t){t&&(this.zb=""),this.Xb="",this.Kb=""}removePartFromView(t){}static EmptyArray=Object.freeze([])}var BrushType=(w=>(w[w.Solid=1]="Solid",w[w.Linear=2]="Linear",w[w.Radial=3]="Radial",w[w.Pattern=4]="Pattern",w))(BrushType||{}),ColorSpace=(w=>(w[w.Lab=1]="Lab",w[w.HSL=2]="HSL",w[w.Oklch=3]="Oklch",w))(ColorSpace||{});class ColorNumbers{n0;n1;n2;n3;constructor(){this.n0=0,this.n1=0,this.n2=0,this.n3=0}}class Brush{h;$;Pa;si;gs;W0;J0;bn;$0;yn;_c;Eb;constructor(t,i){if(GSet.Yi(this),this.h=!1,t===void 0)this.$=1,this.Pa="black";else if(typeof t=="string"){const s=Util.Ih(BrushType,t);s!==null?(this.$=s,this.Pa="black"):(this.$=1,this.Pa=t)}else this.$=t,this.Pa="black";const e=this.$;if(e===2?(this.si=Spot.TopCenter,this.gs=Spot.BottomCenter):e===3?(this.si=Spot.Center,this.gs=Spot.Center):(this.si=Spot.None,this.gs=Spot.None),this.W0=0,this.J0=NaN,this.bn=null,this.$0=null,this.yn=null,this._c=0,this.Eb=0,i){const s={};for(const n in i)isFinite(parseFloat(n))?this.addColorStop(parseFloat(n),i[n]):s[n]=i[n];Object.assign(this,s)}}copy(){const t=new Brush;return t.$=this.$,t.Pa=this.Pa,t.si=this.si.N(),t.gs=this.gs.N(),t.W0=this.W0,t.J0=this.J0,this.bn!==null&&(t.bn=this.bn.copy()),t.$0=this.$0,t}g(){return this.h=!0,this.bn!==null&&this.bn.g(),this}ot(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this.bn!==null&&this.bn.ot(),this}ri(t){t in BrushType?this.type=t:Util.lr(this,t)}toString(){let t="Brush(";if(this.type===1)t+=this.color;else if(this.type===2?t+="Linear ":this.type===3?t+="Radial ":this.type===4?t+="Pattern ":t+="(unknown) ",t+=this.start+" "+this.end,this.colorStops!==null){const i=this.colorStops.iterator;for(;i.next();){const e=i.key,s=i.value;t+=" "+e+":"+s}}return t+=")",t}addColorStop(t,i){return this.h&&Util.T(this),(typeof t!="number"||!isFinite(t)||t>1||t<0)&&Util._(t,"0 <= loc <= 1",Brush,"addColorStop:loc"),Util.i(i,"string",Brush,"addColorStop:color"),this.bn===null&&(this.bn=new GMap),this.bn.set(t,i),this.$===1&&(this.type=2),this.yn=null,this}get type(){return this.$}set type(t){this.h&&Util.T(this,t),this.$=t,this.start.isNoSpot()&&(t===2?this.start=Spot.TopCenter:t===3&&(this.start=Spot.Center)),this.end.isNoSpot()&&(t===2?this.end=Spot.BottomCenter:t===3&&(this.end=Spot.Center)),this.yn=null}get color(){return this.Pa}set color(t){this.h&&Util.T(this,t),this.Pa=t,this.yn=null}get start(){return this.si}set start(t){this.h&&Util.T(this,t),this.si=t.N(),this.yn=null}get end(){return this.gs}set end(t){this.h&&Util.T(this,t),this.gs=t.N(),this.yn=null}get startRadius(){return this.W0}set startRadius(t){this.h&&Util.T(this,t),t<0&&Util._(t,">= zero",Brush,"startRadius"),this.W0=t,this.yn=null}get endRadius(){return this.J0}set endRadius(t){this.h&&Util.T(this,t),t<0&&Util._(t,">= zero",Brush,"endRadius"),this.J0=t,this.yn=null}get colorStops(){return this.bn}set colorStops(t){this.h&&Util.T(this,t),this.bn=t,this.yn=null}get pattern(){return this.$0}set pattern(t){this.h&&Util.T(this,t),this.$0=t,this.yn=null}static randomColor(t,i){t===void 0&&(t=128),i===void 0&&(i=Math.max(t,255));const e=Math.abs(i-t);let s=Math.floor(t+Math.random()*e).toString(16),n=Math.floor(t+Math.random()*e).toString(16),o=Math.floor(t+Math.random()*e).toString(16);return s.length<2&&(s="0"+s),n.length<2&&(n="0"+n),o.length<2&&(o="0"+o),"#"+s+n+o}static isValidColor(t){return root.CSS?root.CSS.supports("color",t):!0}static lighten(t){return Brush.lightenBy(t)}lightenBy(t,i){this.h&&Util.T(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Do(this.color),this.color=Brush.rd(e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Do(n.value),this.addColorStop(n.key,Brush.rd(e,s))}return this}static lightenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Do(t),Brush.rd(s,n)}static darken(t){return Brush.darkenBy(t)}darkenBy(t,i){this.h&&Util.T(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Do(this.color),this.color=Brush.rd(-e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Do(n.value),this.addColorStop(n.key,Brush.rd(-e,s))}return this}static darkenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Do(t),Brush.rd(-s,n)}static mix(t,i,e){Brush.Do(t);const s=Brush.G.n0,n=Brush.G.n1,o=Brush.G.n2,r=Brush.G.n3;Brush.Do(i),e===void 0&&(e=.5);const l=Math.round((Brush.G.n0-s)*e+s),h=Math.round((Brush.G.n1-n)*e+n),a=Math.round((Brush.G.n2-o)*e+o),c=Math.round((Brush.G.n3-r)*e+r);return`rgba(${l}, ${h}, ${a}, ${c})`}isDark(){if(this.type===1)return Brush.isDark(this.color);if((this.type===2||this.type===3)&&this.colorStops!==null){const t=this.colorStops;if(this.type===3)return Brush.isDark(t.first().value);if(t.get(.5)!==null)return Brush.isDark(t.get(.5));if(t.count===2){const l=t.toArray();return Brush.isDark(Brush.mix(l[0].value,l[1].value))}const i=t.iterator;let e=-1,s=-1,n=1,o=1;for(;i.next();){const l=i.key,h=Math.abs(.5-i.key);n>o&&h=n&&hs){let l=e;e=s,s=l,l=n,n=o,o=l}const r=s-e;return Brush.isDark(Brush.mix(t.get(e),t.get(s),1-o/r))}return!1}static isDark(t){return t?t instanceof Brush?t.isDark():(Brush.Do(t),(299*Brush.G.n0+587*Brush.G.n1+114*Brush.G.n2)/1e3<128):!1}static rd(t,i){switch(i){case 1:return Brush.VR(),Brush.io.n0=Math.min(100,Math.max(0,Brush.io.n0+100*t)),Brush.zR(),"rgba("+Brush.G.n0+", "+Brush.G.n1+", "+Brush.G.n2+", "+Brush.G.n3+")";case 2:return Brush.OS(),Brush.Ii.n2=Math.min(100,Math.max(0,Brush.Ii.n2+100*t)),"hsla("+Brush.Ii.n0+", "+Brush.Ii.n1+"%, "+Brush.Ii.n2+"%, "+Brush.Ii.n3+")";case 3:return Brush.XR(),Brush.eo.n0=Math.min(100,Math.max(0,Brush.eo.n0+100*t)),Brush.KR(),"rgba("+Brush.G.n0+", "+Brush.G.n1+", "+Brush.G.n2+", "+Brush.G.n3+")";default:Util.o("Unknown color space: "+i)}}static Do(t){const i=Brush.il;if(i===null)return;i.clearRect(0,0,1,1),i.fillStyle="#000000";const e=i.fillStyle;if(i.fillStyle=t,i.fillStyle!==e){i.fillRect(0,0,1,1);const s=i.getImageData(0,0,1,1).data;Brush.G.n0=s[0],Brush.G.n1=s[1],Brush.G.n2=s[2],Brush.G.n3=s[3]/255}else{i.fillStyle="#FFFFFF";const s=i.fillStyle;i.fillStyle=t,i.fillStyle,Brush.G.n0=0,Brush.G.n1=0,Brush.G.n2=0,Brush.G.n3=1}}static OS(){const t=Brush.G.n0/255,i=Brush.G.n1/255,e=Brush.G.n2/255,s=Math.max(t,i,e),n=Math.min(t,i,e),o=s-n;let r,l;const h=(s+n)/2;if(o===0)r=l=0;else{switch(s){case t:r=(i-e)/o%6;break;case i:r=(e-t)/o+2;break;case e:r=(t-i)/o+4;break}r*=60,r<0&&(r+=360),l=o/(1-Math.abs(2*h-1))}Brush.Ii.n0=Math.round(r),Brush.Ii.n1=Math.round(l*100),Brush.Ii.n2=Math.round(h*100),Brush.Ii.n3=Brush.G.n3}static uE(){const t=Brush.Ii.n0,i=Brush.Ii.n1/100,e=Brush.Ii.n2/100;let s,n,o;const r=(1-Math.abs(2*e-1))*i,l=t/60,h=r*(1-Math.abs(l%2-1));l>=0&&l<1?(s=r,n=h,o=0):l>=1&&l<2?(s=h,n=r,o=0):l>=2&&l<3?(s=0,n=r,o=h):l>=3&&l<4?(s=0,n=h,o=r):l>=4&&l<5?(s=h,n=0,o=r):l>=5&&l<6&&(s=r,n=0,o=h);const a=e-.5*r;s+=a,n+=a,o+=a,Brush.G.n0=Math.round(s*255),Brush.G.n1=Math.round(n*255),Brush.G.n2=Math.round(o*255),Brush.G.n3=Brush.Ii.n3}static VR(){Brush.fA(),Brush.YR()}static zR(){Brush.GR(),Brush.uA()}static w2(t){return t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}static b2(t){return t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055}static fA(){const t=Brush.w2(Brush.G.n0),i=Brush.w2(Brush.G.n1),e=Brush.w2(Brush.G.n2);Brush.Rt.n0=.4124564*t+.3575761*i+.1804375*e,Brush.Rt.n1=.2126729*t+.7151522*i+.072175*e,Brush.Rt.n2=.0193339*t+.119192*i+.9503041*e,Brush.Rt.n3=Brush.G.n3}static uA(){const t=3.2404542*Brush.Rt.n0+-1.5371385*Brush.Rt.n1+-.4985314*Brush.Rt.n2,i=-.969266*Brush.Rt.n0+1.8760108*Brush.Rt.n1+.041556*Brush.Rt.n2,e=.0556434*Brush.Rt.n0+-.2040259*Brush.Rt.n1+1.0572252*Brush.Rt.n2;Brush.G.n0=Brush.b2(t)*255,Brush.G.n1=Brush.b2(i)*255,Brush.G.n2=Brush.b2(e)*255,Brush.G.n3=Brush.Rt.n3,Brush.G.n0=Math.round(Brush.G.n0),Brush.G.n0>255?Brush.G.n0=255:Brush.G.n0<0&&(Brush.G.n0=0),Brush.G.n1=Math.round(Brush.G.n1),Brush.G.n1>255?Brush.G.n1=255:Brush.G.n1<0&&(Brush.G.n1=0),Brush.G.n2=Math.round(Brush.G.n2),Brush.G.n2>255?Brush.G.n2=255:Brush.G.n2<0&&(Brush.G.n2=0)}static k2=216/24389;static Yb=24389/27;static ld=[95.047,100,108.883];static P2(t){return t>Brush.k2?Math.pow(t,1/3):(Brush.Yb*t+16)/116}static YR(){const t=Brush.P2(Brush.Rt.n0*100/Brush.ld[0]),i=Brush.P2(Brush.Rt.n1*100/Brush.ld[1]),e=Brush.P2(Brush.Rt.n2*100/Brush.ld[2]);Brush.io.n0=116*i-16,Brush.io.n1=500*(t-i),Brush.io.n2=200*(i-e),Brush.io.n3=Brush.Rt.n3}static dA(t){const i=t*t*t;return i>Brush.k2?i:(116*t-16)/Brush.Yb}static GR(){const t=(Brush.io.n0+16)/116,i=Brush.io.n1/500+t,e=t-Brush.io.n2/200;Brush.Rt.n0=Brush.ld[0]/100*Brush.dA(i),Brush.Rt.n1=Brush.ld[1]/100*(Brush.io.n0>Brush.Yb*Brush.k2?Math.pow(t,3):Brush.io.n0/Brush.Yb),Brush.Rt.n2=Brush.ld[2]/100*Brush.dA(e),Brush.Rt.n3=Brush.io.n3}static jR(){let t=.8190224*Brush.Rt.n0+.3619062*Brush.Rt.n1+-.1288737*Brush.Rt.n2,i=.03298366*Brush.Rt.n0+.9292868*Brush.Rt.n1+.03614466*Brush.Rt.n2,e=.04817719*Brush.Rt.n0+.2642395*Brush.Rt.n1+.6335478*Brush.Rt.n2;t=Math.cbrt(t),i=Math.cbrt(i),e=Math.cbrt(e),Brush.ci.n0=.2104542*t+.7936177*i+-.004072046*e,Brush.ci.n1=1.977998*t+-2.428592*i+.4505937*e,Brush.ci.n2=.02590403*t+.7827717*i+-.8086757*e,Brush.ci.n3=Brush.Rt.n3,Brush.ci.n0*=100}static HR(){Brush.ci.n0/=100;let t=.9999999*Brush.ci.n0+.3963377*Brush.ci.n1+.2158037*Brush.ci.n2,i=1.000000009*Brush.ci.n0+-.1055613*Brush.ci.n1+-.06385417*Brush.ci.n2,e=1.00000005*Brush.ci.n0+-.08948418*Brush.ci.n1+-1.291485*Brush.ci.n2;t=t**3,i=i**3,e=e**3,Brush.Rt.n0=1.2268798*t+-.5578149*i+.281391*e,Brush.Rt.n1=-.04057576*t+1.112286*i+-.07171106*e,Brush.Rt.n2=-.07637294*t+-.4214933*i+1.586924*e,Brush.Rt.n3=Brush.ci.n3}static qR(){const t=Math.atan2(Brush.ci.n2,Brush.ci.n1)*180/Math.PI;Brush.eo.n0=Brush.ci.n0,Brush.eo.n1=Math.sqrt(Brush.ci.n1**2+Brush.ci.n2**2),Brush.eo.n2=t>=0?t:t+360,Brush.eo.n3=Brush.ci.n3}static WR(){Brush.ci.n0=Brush.eo.n0,Brush.ci.n1=Brush.eo.n1*Math.cos(Brush.eo.n2*Math.PI/180),Brush.ci.n2=Brush.eo.n1*Math.sin(Brush.eo.n2*Math.PI/180),Brush.ci.n3=Brush.eo.n3}static XR(){Brush.fA(),Brush.jR(),Brush.qR()}static KR(){Brush.WR(),Brush.HR(),Brush.uA()}static nd(t,i){typeof t=="string"||t instanceof Brush||Util.o("Value for "+i+" must be a color string or a Brush, not "+t)}static Solid=1;static Linear=2;static Radial=3;static Pattern=4;static Lab=1;static HSL=2;static il=Diagram.isUsingDOM()?new CanvasSurface(null,void 0,{willReadFrequently:!0}).ai:null;static G=new ColorNumbers;static Ii=new ColorNumbers;static Rt=new ColorNumbers;static io=new ColorNumbers;static ci=new ColorNumbers;static eo=new ColorNumbers}class PanelLayout{Mt="Base";static Layouts=new GMap;static definePanelLayout(t,i){i.name=t,PanelLayout.Layouts.set(t,i)}get name(){return this.Mt}set name(t){this.Mt=t}constructor(){}get classType(){return Panel}measure(t,i,e,s,n,o,r){}measureElement(t,i,e,s,n){t.ut(i,e,s,n)}arrange(t,i,e){}arrangeElement(t,i,e,s,n,o){t.zt(i,e,s,n,o)}remeasureObject(t){t.tf()}Gi(t,i,e){}}class PanelLayoutPosition extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=s.length,h=t.Ko();for(let a=0;a0&&(M=Math.max(Math.abs(k.x*o+k.offsetX-(S.x*o+S.offsetX))-g,0)),r>0&&(N=Math.max(Math.abs(k.y*r+k.offsetY-(S.y*r+S.offsetY))-g,0));const T=Size.l();T.e(0,0);const A=t.Ko();for(let v=0;v1,ot=it.columnSpan>1;(ct||ot)&&!(Ky&&(M=Math.max(y-dt,0)),b.ji=b.ji+M,b.actual=b.st+M,y=Math.max(y-(M+(mt?dt:0)),0)}if(it.columnSpan===1&&(N===0||N===4)){b=t.getColumnDefinition(j);const dt=b.computeEffectiveSpacing(),mt=b.st===0;M=Math.max(ut-b.actual,0),M+(mt?dt:0)>p&&(M=Math.max(p-dt,0)),b.ji=b.ji+M,b.actual=b.st+M,p=Math.max(p-(M+(mt?dt:0)),0)}(ct||ot)&&it.tf()}}}Util.tt(f);let A=0,D=0;l=t.columnCount;for(let K=0;K=t.rowCount);Z++)b=t.getRowDefinition(I.row+Z),M=0,N===2||N===4?M=Math.max(b.minimum,V[I.row+Z]===0?b.maximum:Math.min(V[I.row+Z],b.maximum)):M=Math.max(b.minimum,isNaN(b.ge)?b.maximum:Math.min(b.ge,b.maximum)),E.height+=M,_+=b.minimum;for(let Z=1;Z=t.columnCount);Z++)b=t.getColumnDefinition(I.column+Z),M=0,N===2||N===5?M=Math.max(b.minimum,U[I.column+Z]===0?b.maximum:Math.min(U[I.column+Z],b.maximum)):M=Math.max(b.minimum,isNaN(b.ge)?b.maximum:Math.min(b.ge,b.maximum)),E.width+=M,et+=b.minimum;X.width+=E.width,X.height+=E.height;const tt=I.margin,it=tt.right+tt.left,ct=tt.top+tt.bottom;I.ut(X.width,X.height,et,_);const ot=I.measuredBounds,lt=Math.max(ot.width+it,0),st=Math.max(ot.height+ct,0);let nt=0;for(let Z=0;Z=t.rowCount);Z++)b=t.getRowDefinition(I.row+Z),nt+=b.total||0;if(nt=t.rowCount);at++){b=t.getRowDefinition(I.row+at);const ut=b.st||0,gt=rt(I,b,ft);b.actual=Math.min(b.maximum,ut+gt),b.st!==ut&&(Z-=b.st-ut)}}for(;Z>0;){const rt=b.st||0;if(isNaN(b.height)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+Z),b.st!==rt&&(Z-=b.st-rt)),b.index===0)break;b=t.getRowDefinition(b.index-1)}}let ht=0;for(let Z=0;Z=t.columnCount);Z++)b=t.getColumnDefinition(I.column+Z),ht+=b.total||0;if(ht=t.columnCount);at++){b=t.getColumnDefinition(I.column+at);const ut=b.st||0,gt=rt(I,b,ft);b.actual=Math.min(b.maximum,ut+gt),b.st!==ut&&(Z-=b.st-ut)}}for(;Z>0;){const rt=b.st||0;if(isNaN(b.width)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+Z),b.st!==rt&&(Z-=b.st-rt)),b.index===0)break;b=t.getColumnDefinition(b.index-1)}}}Util.tt(u),Size.s(E),Size.s(X),V!==void 0&&Util.tt(V),U!==void 0&&Util.tt(U);let Y=0,G=0;const H=t.desiredSize,J=t.maxSize;N=t.zs(!0),A=0,D=0;let z=0,W=0;l=t.columnCount;for(let K=0;K0){for(;p!==c&&(u[p]===void 0||u[p].st===0);)p++;p=Math.max(Math.min(p,c-1),0),m=-u[p].position}let y=Math.min(t.leftIndex,f-1);if(d.length>0){for(;y!==f&&(d[y]===void 0||d[y].st===0);)y++;y=Math.max(Math.min(y,f-1),0),g=-d[y].position}let x=0,k=0;for(;x!==c&&u[x]===void 0;)x++;for(;k!==c&&d[k]===void 0;)k++;const b=t.part;let P=t.getRowDefinition(x),S=t.getColumnDefinition(k);for(let C=0;C=t.rowCount);st++){const nt=t.getRowDefinition(C+st);nt.st!==0&&(L.height+=nt.total)}for(let st=1;st=t.columnCount);st++){const nt=t.getColumnDefinition(N+st);nt.st!==0&&(L.width+=nt.total)}const O=T.st+L.width,B=M.st+L.height;let X=h,E=a;const V=O,U=B,Y=h,G=a;let H=O,J=B;h+O>e.width&&(H=Math.max(e.width-h,0)),a+B>e.height&&(J=Math.max(e.height-a,0));let z=R.alignment,W=0,q=0,Q=0,K=0;if(z.isDefault()){z=t.defaultAlignment,z.isSpot()||(z=Spot.Center),W=z.x,q=z.y,Q=z.offsetX,K=z.offsetY;const st=T.alignment,nt=M.alignment;st.isSpot()&&(W=st.x,Q=st.offsetX),nt.isSpot()&&(q=nt.y,K=nt.offsetY)}else W=z.x,q=z.y,Q=z.offsetX,K=z.offsetY;(isNaN(W)||isNaN(q))&&(W=.5,q=.5,Q=0,K=0);let I=v.width,j=v.height;const $=R.margin,et=$.left+$.right,_=$.top+$.bottom,tt=R.N0(M,T,!1);isNaN(R.desiredSize.width)&&(tt===2||tt===5)&&(I=Math.max(O-et,0)),isNaN(R.desiredSize.height)&&(tt===2||tt===4)&&(j=Math.max(B-_,0));const it=R.maxSize,ct=R.minSize;I=Math.min(it.width,I),j=Math.min(it.height,j),I=Math.max(ct.width,I),j=Math.max(ct.height,j);const ot=I+et,lt=j+_;X+=V*W-ot*W+Q+$.left,E+=U*q-lt*q+K+$.top,R.visible&&(Rect.contains(Y,G,H,J,X,E,v.width,v.height)?R.zt(X,E,I,j):R.zt(X,E,I,j,new Rect(Y,G,H,J)))}}}Size.s(L);for(let C=0;C0&&(b.figure==="LineV"||b.figure==="LineH")){if(i.lineWidth=b.strokeWidth,t.dn(i,b.stroke,!1,!1,l,h),i.beginPath(),b.figure==="LineV"){const D=Math.floor((m-o)/o);for(let F=D;F<=D+f;F++){const R=F*o+m;0<=R&&R<=a&&this.jb(F,P,L,N)&&(i.moveTo(R,0),i.lineTo(R,c))}}else if(b.figure==="LineH"){const D=Math.floor((g-r)/r);for(let F=D;F<=D+u;F++){const R=F*r+g;0<=R&&R<=c&&this.jb(F,P,L,N)&&(i.moveTo(0,R),i.lineTo(a,R))}}i.stroke(),i.endPath()}else if(b.fill!==null){if(t.dn(i,b.fill,!0,!1,l,h),b.figure==="BarV"){let D=b.width;isNaN(D)&&(D=o);const F=Math.floor((m-o)/o);for(let R=F;R<=F+f;R++){const v=R*o+m;0<=v+D&&v<=a&&this.jb(R,P,L,N)&&i.fillRect(v,0,D,c)}}else if(b.figure==="BarH"){let D=b.height;isNaN(D)&&(D=r);const F=Math.floor((g-r)/r);for(let R=F;R<=F+u;R++){const v=R*r+g;0<=v+D&&v<=c&&this.jb(R,P,L,N)&&i.fillRect(0,v,a,D)}}}T&&i.disableDash(),C!==1&&(i.globalAlpha=M)}}jb(t,i,e,s){if(i<0)return t%i===e;if(t%i!==e)return!1;const n=s.length;for(let o=0;ol&&r.push(d)}}t.xi.Z0=i}C2(t){return t==="LineV"||t==="BarV"}JR(t){let i=1,e=1;const s=t.L.r,n=s.length;for(let l=0;l=g){const z=Point.l();c.mA(z),O=c.midAngle,A!==0&&(v=c.computeAngle(L,A,O),L.Xt=v,L.ue(!0),L._n(!0)),F=z.x-u.x,R=z.y-u.y,Point.s(z)}else{let z,W,q=0;if(M>=0?(z=m.elt(M),W=M0?m.elt(q-1):z),O=0,z.equalsApprox(W)){let Q,K;M>=0?(Q=M>0?m.elt(M-1):z,K=M1?m.elt(q-2):W);const I=Q.distanceSquaredPoint(z),j=W.distanceSquaredPoint(K);I>j+10?O=M>=0?Q.directionPoint(z):z.directionPoint(Q):j>I+10?O=M>=0?W.directionPoint(K):K.directionPoint(W):O=M>=0?Q.directionPoint(K):K.directionPoint(Q)}else O=M>=0?z.directionPoint(W):W.directionPoint(z);A!==0&&(v=c.computeAngle(L,A,O),L.Xt=v,L.ue(!0),L._n(!0)),F=z.x+(W.x-z.x)*N-u.x,R=z.y+(W.y-z.y)*N-u.y}L.ut(1/0,1/0,0,0),C=L.measuredBounds;const B=L.naturalBounds;let X=0;L instanceof Shape&&(X=L.strokeWidth);const E=B.width+X,V=B.height+X;k.Ri(),k.Ds(-C.x,-C.y),k.et(L.scale,L.scale),k.cs(A===0?L.angle:O,E/2,V/2),(A===22||A===26)&&k.cs(90,E/2,V/2),(A===23||A===27)&&k.cs(-90,E/2,V/2),A===28&&(O>45&&O<135||O>225&&O<315)&&k.cs(-O,E/2,V/2);const U=new Rect(0,0,E,V);b.setRectSpot(U,T),k.xt(b);const Y=-b.x+X/2*L.scale,G=-b.y+X/2*L.scale;P.a(D);const H=isNaN(D.x),J=isNaN(D.y);if(H||J){const z=E/2+3,W=V/2+3,q=O>=45&&O<=135,Q=O>=225&&O<=315;A===0&&(q||Q)?(P.x=J?z:D.y,P.y=H?W:D.x,q?M>=0||isNaN(M)&&N<.5||H&&(P.y=-W):Q&&((M>=0||isNaN(M)&&N<.5)&&H&&(P.y=-W),J&&(P.x=-z))):(H&&(M>=0||isNaN(M)&&N<.5?P.x=z:P.x=-z),J&&(P.y=-W),P.rotate(O))}else P.rotate(O);F+=P.x,R+=P.y,U.e(F+Y,R+G,C.width,C.height),x.push(U),d.unionRect(U)}if(h!==null){const S=h.labelNodes;for(;S.next();)S.value.ut(1/0,1/0)}t.Yo=d,t.position.e(u.x+d.x,u.y+d.y),n.En(d.width||0,d.height||0),Transform.s(k),Point.s(b),Point.s(P)}arrange(t,i,e){const s=i.length;if(!(t instanceof Adornment||t instanceof Link))return;let n=t,o=null;t instanceof Adornment&&(o=t,n=o.adornedPart);const r=t,l=t instanceof Adornment?null:n.path,h=t.hf;if(h.length!==0){let u=0;if(l!==null&&u=2&&r instanceof Link){const u=r.labelNodes;for(;u.next();){const d=u.value;r.QR(d,c,a)}}o!==null?o.hd(!1):n.hd(!1);const f=t.pA(Point.l());t.location.e(t.position.x+f.x,t.position.y+f.y),Point.s(f)}measureLinkPath(t,i,e,s){if(s.Oo()===!1)return;let n=s.strokeWidth;if(n===0&&t instanceof Adornment&&t.type===Panel.Link&&t.adornedObject instanceof Shape&&(n=t.adornedObject.strokeWidth),n=n*s.et,t instanceof Link&&t.ct!==null){const o=t.geometry.bounds;s.Qn(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else if(t instanceof Adornment&&t.adornedPart.ct!==null){const o=t.adornedPart.ct.bounds;s.Qn(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else s.Qn(-(n/2),-(n/2),i+n,e+n);s._R(),s.ue(!1)}}PanelLayout.definePanelLayout("Link",new PanelLayoutLink);class PanelLayoutGraduated extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=t.findMainElement();t.je=[];const h=l.margin,a=h.right+h.left,c=h.top+h.bottom;l.ut(i,e,o,r);const f=l.measuredBounds,u=f.width,d=f.height,m=Math.max(u+a,0),g=Math.max(d+c,0),p=new Rect(-h.left,-h.top,m,g);t.je.push(p),n.a(p),this.determineGraduatedMarks(t,l);const y=t.ws;if(y===null)return;const x=s.length;for(let k=0;k45&&f<135||f>225&&f<315)&&P.cs(-f,k/2,b/2);const S=Rect.X(0,0,k,b),L=Point.l();L.setRectSpot(S,o),P.xt(L);const C=-L.x,M=-L.y,N=Point.l();N.a(l),isNaN(N.x)&&(N.x=k/2+3),isNaN(N.y)&&(N.y=-(b/2+3)),N.rotate(f),a+=N.x+C,c+=N.y+M;const T=new Rect(a,c,y.width,y.height),A=new Rect(y.x,y.y,y.width,y.height),D=new Rect(x.x,x.y,x.width,x.height);p.labelAngle=u,p.lineCount=n.lineCount,p.lines=n.getMetrics(),p.actualBounds=T,p.measuredBounds=A,p.naturalBounds=D,g===0?h.a(T):h.unionRect(T),Point.s(N),Point.s(L),Rect.s(S),Transform.s(P)}t.je!==null&&t.je.push(h),s.unionNoCheck(h.x,h.y,h.width,h.height)}determineGraduatedMarks(t,i){const e=i.geometry,s=i.strokeWidth,n=e.flattenedSegments,o=e.flattenedLengths,r=e.flattenedTotalLength,l=n.length;let h=0,a=0;const c=Util.nt();for(let x=0;xt.graduatedMin+M){const F=Math.floor((N-t.graduatedMin)/M);N-=F*M}const T=f[x],A=N,D=t.graduatedMax*1e-6;for(let F=1;N<=t.graduatedMax+D;F++){if(this.iv(t,N-t.graduatedTickBase,T)&&(N>t.graduatedMax&&(N=t.graduatedMax),(k.graduatedSkip===null||k instanceof TextBlock&&!k.graduatedSkip(N,k)||k instanceof Shape&&!k.graduatedSkip(N,k))&&(m=(N-t.graduatedMin)*r/t.graduatedRange,m>r&&(m=r),g<=m&&m<=p))){let R=c[L][C],v=o[L][C];for(;LS&&C.4995)return t;let o=t;if(i<.5?n>0?o=s[n-1]:Geo.K(e[0],e[e.length-2])&&Geo.K(e[1],e[e.length-1])&&(o=s[s.length-1]):i>.5&&(n+1180&&(t.9995)return(t+o)/2%360;if(r<10){const l=1-Math.abs(.5-i);return(t*l+o*(1-l))%360}}return t}tv(t){if(t.ns===null){const i=[],e=t.L.r,s=e.length;for(let n=0;nl&&r.push(c)}}t.ns=i}return t.ns}iv(t,i,e){const s=e.length;for(let n=0;n-l)return!1}return!0}Gi(t,i,e){const s=e.Qh;e.Qh=!0;const n=t.naturalBounds,o=n.width,r=n.height,l=i instanceof SVGContext;i.save(),i.beginPath(),i.rect(-1,-1,o+1,r+1),i.clip(),i.endPath();const h=t.findMainElement();h.Gi(i,e);let a=t.getDocumentScale()*e.scale;a<=0&&(a=1);const c=h.actualBounds,f=t.L.r,u=t.ws,d=f.length;for(let m=0;m(w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ViewboxStretch||{});class Panel extends GraphObject{$;L;$t;ad;Kn;el;so;Yo;A2;O;cd;lt;xi;Qt;fd;mh;Ys;constructor(t,i){if(super(),this.$=null,t===void 0)this.$=Panel.Position;else if(typeof t=="string"){const e=PanelLayout.Layouts.get(t);e!==null&&(this.$=e)}else t instanceof PanelLayout?this.$=t:t&&(this.$=Panel.Position,i=t);this.$===null&&Util.o("Panel type not specified or PanelLayout not loaded: "+t),this.n|=4194304|(this.$===Panel.Grid?1048576:0),this.L=new List,this.$t=Margin.Eg,this.ad=Spot.Default,this.Kn=1,this.el=null,this.so="",this.Yo=new Rect(NaN,NaN,NaN,NaN),this.A2=null,this.O=null,this.cd=6,this.xi=null,this.lt=null,this.Qt=null,this.fd=NaN,this.mh=null,this.Ys=null,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.$=this.$,t.$t=this.$t.N(),t.ad=this.ad.N(),t.Kn=this.Kn,t.so=this.so,t.Yo.a(this.Yo),this.O!==null&&(t.O=this.O.copy(t)),t.cd=this.cd,this.lt!==null&&(t.lt=this.lt.copy()),this.xi!==null&&(t.xi=this.xi.copy()),t.Qt=this.Qt,t.fd=this.fd,t.mh=this.mh}Vo(t){super.Vo(t),t.L=this.L;const i=t.L.r,e=i.length;for(let s=0;s= 0",Panel,"padding"),t=new Margin(t)):(t.left<0&&Util._(t.left,">= 0",Panel,"padding:value.left"),t.right<0&&Util._(t.right,">= 0",Panel,"padding:value.right"),t.top<0&&Util._(t.top,">= 0",Panel,"padding:value.top"),t.bottom<0&&Util._(t.bottom,">= 0",Panel,"padding:value.bottom"));const i=this.$t;i.equals(t)||(t=t.N(),this.$t=t,this.c(),this.t("padding",i,t))}get defaultAlignment(){return this.ad}set defaultAlignment(t){const i=this.ad;i.equals(t)||(t=t.N(),this.ad=t,this.c(),this.t("defaultAlignment",i,t))}get defaultStretch(){return this.Kn}set defaultStretch(t){const i=this.Kn;i!==t&&(this.Kn=t,this.c(),this.t("defaultStretch",i,t))}get defaultSeparatorPadding(){return this.O!==null?this.O.Q0:Margin.Eg}set defaultSeparatorPadding(t){typeof t=="number"&&(t=new Margin(t));const i=this.defaultSeparatorPadding;i.equals(t)||(t=t.N(),this.O===null&&(this.O=new TablePanelSettings),this.O.Q0=t,this.c(),this.t("defaultSeparatorPadding",i,t))}get defaultRowSeparatorStroke(){return this.O!==null?this.O._0:null}set defaultRowSeparatorStroke(t){const i=this.defaultRowSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.g(),this.O===null&&(this.O=new TablePanelSettings),this.O._0=t,this.C(),this.t("defaultRowSeparatorStroke",i,t))}get defaultRowSeparatorStrokeWidth(){return this.O!==null?this.O.tp:1}set defaultRowSeparatorStrokeWidth(t){const i=this.defaultRowSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.O===null&&(this.O=new TablePanelSettings),this.O.tp=t,this.c(),this.t("defaultRowSeparatorStrokeWidth",i,t))}get defaultRowSeparatorDashArray(){return this.O!==null?this.O.ip:null}set defaultRowSeparatorDashArray(t){const i=this.defaultRowSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",Panel,"defaultRowSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("defaultRowSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.O===null&&(this.O=new TablePanelSettings),this.O.ip=t,this.C(),this.t("defaultRowSeparatorDashArray",i,t)}}get defaultColumnSeparatorStroke(){return this.O!==null?this.O.ep:null}set defaultColumnSeparatorStroke(t){const i=this.defaultColumnSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.g(),this.O===null&&(this.O=new TablePanelSettings),this.O.ep=t,this.C(),this.t("defaultColumnSeparatorStroke",i,t))}get defaultColumnSeparatorStrokeWidth(){return this.O!==null?this.O.sp:1}set defaultColumnSeparatorStrokeWidth(t){const i=this.defaultColumnSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.O===null&&(this.O=new TablePanelSettings),this.O.sp=t,this.c(),this.t("defaultColumnSeparatorStrokeWidth",i,t))}get defaultColumnSeparatorDashArray(){return this.O!==null?this.O.np:null}set defaultColumnSeparatorDashArray(t){const i=this.defaultColumnSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",Panel,"defaultColumnSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("defaultColumnSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.O===null&&(this.O=new TablePanelSettings),this.O.np=t,this.C(),this.t("defaultColumnSeparatorDashArray",i,t)}}get gh(){return this.O!==null?this.O.gh:null}set gh(t){this.O===null&&(this.O=new TablePanelSettings),this.O.gh=t}get viewboxStretch(){return this.cd}set viewboxStretch(t){const i=this.cd;i!==t&&(this.cd=t,this.c(),this.t("viewboxStretch",i,t))}get gridCellSize(){return this.xi!==null?this.xi.ud:Size.tC}set gridCellSize(t){this.xi===null&&(this.xi=new GridPanelSettings);const i=this.xi.ud;if(!i.equals(t)){(!t.isReal()||t.width===0||t.height===0)&&Util.o("Invalid Panel.gridCellSize: "+t),this.xi.ud=t.N();const e=this.diagram;e!==null&&this===e.grid&&e.jr(),this.C(),this.t("gridCellSize",i,t)}}get gridOrigin(){return this.xi!==null?this.xi.dd:Point.Po}set gridOrigin(t){this.xi===null&&(this.xi=new GridPanelSettings);const i=this.xi.dd;if(!i.equals(t)){t.isReal()||Util.o("Invalid Panel.gridOrigin: "+t),this.xi.dd=t.N();const e=this.diagram;e!==null&&this===e.grid&&e.jr(),this.C(),this.t("gridOrigin",i,t)}}get graduatedMin(){return this.lt!==null?this.lt.op:0}set graduatedMin(t){const i=this.graduatedMin;if(i!==t&&(this.lt===null&&(this.lt=new GradPanelSettings),this.lt.op=t,this.c(),this.t("graduatedMin",i,t),this.$c())){const e=this.part;e!==null&&this.ya(e,"graduatedRange")}}get graduatedMax(){return this.lt!==null?this.lt.rp:100}set graduatedMax(t){const i=this.graduatedMax;if(i!==t&&(this.lt===null&&(this.lt=new GradPanelSettings),this.lt.rp=t,this.c(),this.t("graduatedMax",i,t),this.$c())){const e=this.part;e!==null&&this.ya(e,"graduatedRange")}}get graduatedRange(){return this.graduatedMax-this.graduatedMin}get graduatedTickUnit(){return this.lt!==null?this.lt.lp:10}set graduatedTickUnit(t){const i=this.graduatedTickUnit;i!==t&&t>0&&(this.lt===null&&(this.lt=new GradPanelSettings),this.lt.lp=t,this.c(),this.t("graduatedTickUnit",i,t))}get graduatedTickBase(){return this.lt!==null?this.lt.hp:0}set graduatedTickBase(t){const i=this.graduatedTickBase;i!==t&&(this.lt===null&&(this.lt=new GradPanelSettings),this.lt.hp=t,this.c(),this.t("graduatedTickBase",i,t))}get ws(){return this.lt!==null?this.lt.ws:null}set ws(t){this.lt!==null?this.lt.ws=t:t!==null&&(this.lt=new GradPanelSettings,this.lt.ws=t)}get je(){return this.lt!==null?this.lt.je:null}set je(t){this.lt!==null?this.lt.je=t:t!==null&&(this.lt=new GradPanelSettings,this.lt.je=t)}get ns(){return this.lt!==null?this.lt.ns:null}set ns(t){this.lt!==null?this.lt.ns=t:t!==null&&(this.lt=new GradPanelSettings,this.lt.ns=t)}get Se(){return this.lt!==null?this.lt.Se:null}set Se(t){this.lt!==null?this.lt.Se=t:t!==null&&(this.lt=new GradPanelSettings,this.lt.Se=t)}b0(t){super.b0(t);const i=this.L.r,e=i.length;for(let s=0;s0?this.Ye:null,s=this.columnCount>0?this.Ge:null;e!==null&&this.Hb(t,i,!0,e,!0),s!==null&&this.Hb(t,i,!1,s,!0),e!==null&&this.wA(t,!0,e),s!==null&&this.wA(t,!1,s),e!==null&&this.Hb(t,i,!0,e,!1),s!==null&&this.Hb(t,i,!1,s,!1)}wA(t,i,e){const s=e.length,n=this.actualBounds,o=this.naturalBounds;let r=!0;for(let l=0;lo.height)continue}else if(h.position>o.width)continue;let a=h.separatorStrokeWidth;isNaN(a)&&(a=i?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let c=h.separatorStroke;if(c===null&&(c=i?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),a===0||c===null)continue;this.dn(t,c,!1,!1,o,n);let f=!1,u=h.separatorDashArray;u===null&&(u=i?this.defaultRowSeparatorDashArray:this.defaultColumnSeparatorDashArray),u!==null&&(f=!0,t.enableDash(u,0)),t.beginPath();const d=h.position+a;i?d>o.height&&(a-=d-o.height):d>o.width&&(a-=d-o.width);let m=h.position+a/2;t.lineWidth=a;const g=this.$t;if(i){m+=g.top;const p=g.left,y=o.width-g.right;t.moveTo(p,m),t.lineTo(y,m)}else{m+=g.left;const p=g.top,y=o.height-g.bottom;t.moveTo(m,p),t.lineTo(m,y)}t.stroke(),t.endPath(),f&&t.disableDash()}}Hb(t,i,e,s,n){const o=s.length,r=this.actualBounds,l=this.naturalBounds,h=this.xA(!0),a=this.xA(!1);for(let c=0;cu)continue;let d=f.computeEffectiveSpacing(),m=f.separatorStrokeWidth;isNaN(m)&&(m=e?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let g=f.separatorStroke;g===null&&(g=e?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),(g===null||f.index===(e?h:a))&&(m=0),d-=m;const p=f.position+m;let y=d+f.actual;if(p+y>u&&(y=u-p),y<=0)continue;const x=this.$t;this.dn(t,f.background,!0,!1,l,r),e?t.fillRect(x.left,p+x.top,r.width-(x.left+x.right),y):t.fillRect(p+x.left,x.top,y,r.height-(x.top+x.bottom))}}xA(t){const i=t?this.rowCount:this.columnCount;for(let e=0;ex&&n.set(M),Point.s(M)),Point.s(S),o&&n.D(r),k}}Du(){const t=this.L.r,i=t.length;for(let e=0;ee||h>s)&&(this.c(),this.ut(l>e?e:l,h>s?s:h,0,0));break;case 2:this.c(!0),this.ut(e+c,s+f,0,0);break;case 5:this.c(!0),this.ut(e+c,h+f,0,0);break;case 4:this.c(!0),this.ut(l+c,s+f,0,0);break}}this.$.arrange(this,n,this.Yo)}hh(t){const i=this.naturalBounds,e=this.Ko();if(Rect.contains(0,0,i.width,i.height,t.x,t.y)){const s=this.L.r,n=s.length,o=Point.X(0,0);for(let r=n;r--;){const l=s[r];if(!(!l.visible&&l!==e)&&(o.set(t).Ie(l.D),l.containsPoint(o)))return Point.s(o),!0}return Point.s(o),this.Ct!==null}return!1}m0(t){if(this.$n===t)return this;const i=this.L.r,e=i.length;for(let s=0;sd.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;let m=f;const g=f instanceof Panel?f:null,p=Transform.l();p.set(r),(g!==null?g.vm(t,i,e,s,n,p):m.QL(t,s,p))&&(i!==null&&(m=i(m)),m!==null&&(e===null||e(m))&&n.add(m)),Transform.s(p)}}return o===void 0&&Transform.s(r),s}return o===void 0&&Transform.s(r),!1}D2(t,i,e){const s=this.L.r,n=s.length;for(let o=n;o--;){const r=s[o];if(!r.visible)continue;const l=r.actualBounds,h=this.naturalBounds;if(l.x>h.width||l.y>h.height||l.x+l.width<0||l.y+l.height<0)continue;r instanceof Panel&&r.D2(t,i,e);let a=r;t!==null&&(a=t(a)),a!==null&&(i===null||i(a))&&e.add(a)}}eL(t,i,e,s,n,o){if(this.pickable===!1)return!1;e===void 0&&(e=null),s===void 0&&(s=null);const r=this.naturalBounds,l=this.pn(),h=l?t:Point.X(t.x,t.y).Ie(this.D),a=l?i:Point.X(i.x,i.y).Ie(this.D),c=h.distanceSquaredPoint(a),f=h.x>0&&h.x0&&h.yP.width||b.y>P.height||b.x+b.width<0||b.y+b.height<0))continue;if(k.pn()){const C=k.D;d.set(t).Ie(C),m.set(i).Ie(C)}else d.set(t),m.set(i);let S=k;const L=k instanceof Panel?k:null;(L!==null?L.eL(d,m,e,s,n,o):S._L(d,m,n))&&(e!==null&&(S=e(S)),S!==null&&(s===null||s(S))&&o.add(S))}Point.s(d),Point.s(m)}return n?f:u}return!1}M2(t){let i=null;if(t instanceof Shape){i=t.spot1,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot1)}return i===null&&(i=Spot.TopLeft),i}N2(t){let i=null;if(t instanceof Shape){i=t.spot2,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot2)}return i===null&&(i=Spot.BottomRight),i}add(...t){for(let i=0;i=s.count&&t>=s.count)return;s.removeAt(r),n=r}else Util.o("element "+i.toString()+" has panel "+e.toString()+" but is not contained by it.")}(t<0||t>s.count)&&(t=s.count),s.insertAt(t,i),(t===0||i.isPanelMain)&&(this.el=null),this.Oo()||this.c(),i.c(!1),i.portId!==null?this.wn=!0:i instanceof Panel&&i.wn===!0&&(this.wn=!0),this.ns=null,this.isEnabledObject()||this.qb(i,!1);const o=this.part;if(o!==null){o.D0(),o.cf(),this.wn&&o instanceof Node&&(o.wn=!0),o.wn&&o instanceof Node&&(o.ne=null);const r=this.diagram;if(r!==null&&r.undoManager.isUndoingRedoing)return;n!==-1&&o.raiseChangedEvent(4,"elements",this,i,null,n,null),o.raiseChangedEvent(3,"elements",this,null,i,null,t)}}get wn(){return(this.n&8388608)!==0}set wn(t){(this.n&8388608)!==0!==t&&(this.n=this.n^8388608)}e2(){return(this.n&16777216)!==0}F2(t){t?this.n|=16777216:this.n&=-16777217}lv(t){t.xa(this),t.Qr=null;const i=this.L,e=i.count;i.insertAt(e,t);const s=this.part;if(s!==null){s.D0(),t.portId!==null&&s instanceof Node&&(s.wn=!0);const n=this.diagram;if(n!==null&&n.undoManager.isUndoingRedoing)return;s.raiseChangedEvent(3,"elements",this,null,t,null,e)}}AR(t){const i=this.L.r,e=i.length;let s=-1;for(let n=0;n=0&&this.te(t,!0)}te(t,i){const e=this.L,s=e.elt(t);if(s.Qr=null,s.xa(null),this.Ys!==null){const o=s.data;typeof o=="object"&&this.Ys.delete(o)}e.removeAt(t),this.ue(!1),this.c(),this.el===s&&(this.el=null),this.ns=null;const n=this.part;if(n!==null){n.D0(),n.cf(),n.invalidateAdornments(),n instanceof Node&&(s instanceof Panel?s.walkVisualTreeFrom(s,(r,l)=>n.u2(l,i)):n.u2(s,i));const o=this.diagram;if(o!==null&&o.undoManager.isUndoingRedoing)return;n.raiseChangedEvent(4,"elements",this,s,null,t,null)}}get Ye(){return this.O===null&&(this.O=new TablePanelSettings),this.O.Ye}get rowCount(){return this.O===null?0:this.Ye.length}getRowDefinition(t){t<0&&Util._(t,">= 0",Panel,"getRowDefinition:idx"),t=Math.round(t);const i=this.Ye;if(i[t]===void 0){const e=new RowColumnDefinition;e.xa(this),e.isRow=!0,e.index=t,i[t]=e,this.raiseChangedEvent(3,"rowdefs",this,null,e,null,t)}return i[t]}removeRowDefinition(t){if(t<0&&Util._(t,">= 0",Panel,"removeRowDefinition:idx"),this.rowCount===0)return;t=Math.round(t);const i=this.Ye,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"rowdefs",this,e,null,t,null),this.c()}}DL(t,i){const e=this.Ye;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.c()}}get Ge(){return this.O===null&&(this.O=new TablePanelSettings),this.O.Ge}get columnCount(){return this.O===null?0:this.Ge.length}getColumnDefinition(t){t<0&&Util._(t,">= 0",Panel,"getColumnDefinition:idx"),t=Math.round(t);const i=this.Ge;if(i[t]===void 0){const e=new RowColumnDefinition;e.xa(this),e.isRow=!1,e.index=t,i[t]=e,this.raiseChangedEvent(3,"coldefs",this,null,e,null,t)}return i[t]}removeColumnDefinition(t){if(t<0&&Util._(t,">= 0",Panel,"removeColumnDefinition:idx"),this.columnCount===0)return;t=Math.round(t);const i=this.Ge,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"coldefs",this,e,null,t,null),this.c()}}FL(t,i){const e=this.Ge;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.c()}}addRowColumnDefinition(t){let i=null;return t.isRow?i=this.getRowDefinition(t.index):t.isRow||(i=this.getColumnDefinition(t.index)),i&&i.Ub(t),this}addRowDefinition(t,i){const e=this.getRowDefinition(t);return e&&e.Ub(new RowColumnDefinition(i)),this}addColumnDefinition(t,i){const e=this.getColumnDefinition(t);return e&&e.Ub(new RowColumnDefinition(i)),this}get rowSizing(){return this.O!==null?this.O.cp:3}set rowSizing(t){const i=this.rowSizing;i!==t&&(this.O===null&&(this.O=new TablePanelSettings),this.O.cp=t,this.c(),this.t("rowSizing",i,t))}get columnSizing(){return this.O!==null?this.O.fp:3}set columnSizing(t){const i=this.columnSizing;i!==t&&(this.O===null&&(this.O=new TablePanelSettings),this.O.fp=t,this.c(),this.t("columnSizing",i,t))}get topIndex(){return this.O!==null?this.O.dp:0}set topIndex(t){const i=this.topIndex;i!==t&&((!isFinite(t)||t<0)&&Util.o("Panel.topIndex must be greater than zero and a real number, not: "+t),this.O===null&&(this.O=new TablePanelSettings),this.O.dp=t,this.c(),this.t("topIndex",i,t))}get leftIndex(){return this.O!==null?this.O.gp:0}set leftIndex(t){const i=this.leftIndex;i!==t&&((!isFinite(t)||t<0)&&Util.o("Panel.leftIndex must be greater than zero and a real number, not: "+t),this.O===null&&(this.O=new TablePanelSettings),this.O.gp=t,this.c(),this.t("leftIndex",i,t))}findRowForLocalY(t){if(t<0||this.type!==Panel.Table||this.rowCount===0)return-1;let i=0;const e=this.Ye,s=e.length;let n=this.topIndex;for(;n{o.lh();const r=o.Ai;if(r!==null){o.a2(!1);const l=r.iterator;for(;l.next();){const h=l.value;h.mode===2&&o.a2(!0);const a=h.sourceName;if(h.isToObject){a==="/"&&n.F2(!0);const c=h.ZL(n,o);c!==null&&(i.add(c),c.Zn===null&&(c.Zn=new List),c.Zn.add(h))}t.add(h)}}if(o instanceof Panel&&o.type===Panel.Table){if(o.rowCount>0){const l=o.Ye,h=l.length;for(let a=0;a0){const l=o.Ge,h=l.length;for(let a=0;a0&&o instanceof Panel){const h=r.substring(0,l),a=r.substring(l+1),c=o.findObject(h);c!==null?(o=c,n.targetProperty=a):(Util.ii('Warning: unable to find GraphObject named "'+h+'" for Binding: '+n.toString()),o=null)}if(o instanceof RowColumnDefinition){const h=GSet.as(o.panel);n.targetId=h===void 0?-1:h,o.panel.$n=n.targetId}else if(o instanceof GraphObject){const h=GSet.as(o);n.targetId=h===void 0?-1:h,o.$n=n.targetId}else Util.o("Unknown type of binding target: "+o);n.check(o)}}return t.g(),this instanceof Part&&this.Pe()&&this.ensureBounds(),this}static dE=!1;copyTemplate(t){t===void 0&&(t=!1);const i=this.copy();return i.hv(e=>{e instanceof Panel&&(e.Ks=null,e.Qt=null);const s=e.Ai;s!==null&&(e.Ai=null,s.each(o=>e.bind(o.copy())));const n=e.ys;n!==null&&(e.ys=null,n.each(o=>e.trigger(o.value.copy())))}),t&&i.li(),i}updateTargetBindings(t){const i=this.Ks;if(i===null)return;t===void 0&&(t="");const e=i.iterator;for(;e.next();){const s=e.value,n=this.MA(s,t);if(n===null)continue;const{data:o,elt:r}=n;s.isToTheme&&this.diagram===null||r!==void 0&&s.updateTarget(r,o)}}Io(){if(this.diagram!==null)if(this.d2()){const t=this.Ks.iterator;for(;t.next();){const i=t.value;if(!i.isToTheme)continue;const e=this.MA(i);if(e===null)continue;const{data:s,elt:n}=e;n!==void 0&&i.updateTarget(n,s)}}else{const t=this.L.r,i=t.length;for(let e=0;e0;let r=0;for(;n0){const i=this.L.elt(0);if(i.isPanelMain&&i instanceof Panel&&i._r())return 1}return 0}rebuildItemElements(){const t=this.ap();for(;this.L.length>t;)this.te(this.L.length-1,!1);this.NA(null,this.itemArray)}NA(t,i){const e=this.ap(),s=i;if(s===null||s.length===0){for(;this.L.length>e;)this.te(this.L.length-1,!1);return}if(this.L.length<=e){const n=s.length;for(let o=0;o(w[w.Default=1]="Default",w[w.None=2]="None",w[w.ProportionalExtra=3]="ProportionalExtra",w))(Sizing||{});class RowColumnDefinition{Vs;mp;Dt;Sa;Ma;oi;at;md;to;Go;pd;yd;Na;Ct;wd;Gs;st;ji;ge;constructor(t){GSet.Yi(this),this.Vs=null,this.mp=!0,this.Dt=0,this.ge=NaN,this.Sa=0,this.Ma=1/0,this.oi=Spot.Default,this.st=0,this.ji=0,this.at=0,this.Gs=null,this.md=1,this.to=1,this.Go=null,this.pd=null,this.yd=NaN,this.Na=null,this.Ct=null,this.wd=!1,t&&(Object.assign(this,t),t.column!==void 0?(this.isRow=!1,this.index=t.column):t.row!==void 0&&(this.isRow=!0,this.index=t.row))}copy(){const t=new RowColumnDefinition;return t.mp=this.mp,t.Dt=this.Dt,t.ge=this.ge,t.Sa=this.Sa,t.Ma=this.Ma,t.oi=this.oi,t.st=this.st,t.ji=this.ji,t.at=this.at,t.to=this.to,t.md=this.md,this.Go===null?t.Go=null:t.Go=this.Go.N(),t.pd=this.pd,t.yd=this.yd,t.Na=null,this.Na!==null&&(t.separatorDashArray=this.separatorDashArray.slice()),t.Ct=this.Ct,t.wd=this.wd,t.Gs=this.Gs,t}Ub(t){t.isRow?this.height=t.height:this.width=t.width,this.minimum=t.minimum,this.maximum=t.maximum,this.alignment=t.alignment,this.stretch=t.stretch,this.sizing=t.sizing,this.Go=t.separatorPadding===null?null:t.separatorPadding.N(),this.separatorStroke=t.separatorStroke,this.separatorStrokeWidth=t.separatorStrokeWidth,this.Na=null,t.separatorDashArray&&(this.Na=t.separatorDashArray.slice()),this.background=t.background,this.coversSeparators=t.coversSeparators,this.Gs=t.Gs}ri(t){t in Sizing?this.sizing=t:Util.lr(this,t)}toString(){return"RowColumnDefinition "+(this.isRow?"(Row ":"(Column ")+this.index+") #"+GSet.as(this)}static Default=1;static None=2;static ProportionalExtra=3;xa(t){this.Vs=t}computeEffectiveSpacingTop(t){let i=0;const e=this.Vs;if(this.index!==t){let n=this.separatorStroke;n===null&&e!==null&&(n=this.isRow?e.defaultRowSeparatorStroke:e.defaultColumnSeparatorStroke),n!==null&&(i=this.separatorStrokeWidth,isNaN(i)&&(e!==null?i=this.isRow?e.defaultRowSeparatorStrokeWidth:e.defaultColumnSeparatorStrokeWidth:i=0))}let s=this.Go;if(s===null)if(e!==null)s=e.defaultSeparatorPadding;else return i;return i+(this.isRow?s.top:s.left)}computeEffectiveSpacing(){let t=0;const i=this.Vs;let e=0;const s=this.isRow;if(i!==null&&i.type===Panel.Table){const o=s?i.Ye.length:i.Ge.length;for(let r=0;r= 0",RowColumnDefinition,"height"),this.ge=t,this.actual=this.st,this.panel!==null&&this.panel.c(),this.t("height",i,t))}get width(){return this.ge}set width(t){const i=this.ge;i!==t&&(t<0&&Util._(t,">= 0",RowColumnDefinition,"width"),this.ge=t,this.actual=this.st,this.panel!==null&&this.panel.c(),this.t("width",i,t))}get minimum(){return this.Sa}set minimum(t){const i=this.Sa;i!==t&&((t<0||!isFinite(t))&&Util._(t,">= 0",RowColumnDefinition,"minimum"),this.Sa=t,this.actual=this.st,this.panel!==null&&this.panel.c(),this.t("minimum",i,t))}get maximum(){return this.Ma}set maximum(t){const i=this.Ma;i!==t&&(t<0&&Util._(t,">= 0",RowColumnDefinition,"maximum"),this.Ma=t,this.actual=this.st,this.panel!==null&&this.panel.c(),this.t("maximum",i,t))}get alignment(){return this.oi}set alignment(t){const i=this.oi;i.equals(t)||(this.oi=t.N(),this.panel!==null&&this.panel.c(),this.t("alignment",i,t))}get stretch(){return this.to}set stretch(t){const i=this.to;i!==t&&(this.to=t,this.panel!==null&&this.panel.c(),this.t("stretch",i,t))}get separatorPadding(){return this.Go}set separatorPadding(t){typeof t=="number"&&(t=new Margin(t));const i=this.Go;(t===null||i===null||!i.equals(t))&&(t!==null&&(t=t.N()),this.Go=t,this.panel!==null&&this.panel.c(),this.t("separatorPadding",i,t))}get separatorStroke(){return this.pd}set separatorStroke(t){const i=this.pd;i!==t&&(t!==null&&Brush.nd(t,"RowColumnDefinition.separatorStroke"),t instanceof Brush&&t.g(),this.pd=t,this.panel!==null&&this.panel.c(),this.t("separatorStroke",i,t))}get separatorStrokeWidth(){return this.yd}set separatorStrokeWidth(t){const i=this.yd;i!==t&&(this.yd=t,this.panel!==null&&this.panel.c(),this.t("separatorStrokeWidth",i,t))}get separatorDashArray(){return this.Na}set separatorDashArray(t){const i=this.Na;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",RowColumnDefinition,"separatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("separatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.Na=t,this.panel!==null&&this.panel.C(),this.t("separatorDashArray",i,t)}}get background(){return this.Ct}set background(t){const i=this.Ct;i!==t&&(t!==null&&Brush.nd(t,"RowColumnDefinition.background"),t instanceof Brush&&t.g(),this.Ct=t,this.panel!==null&&this.panel.C(),this.t("background",i,t))}get coversSeparators(){return this.wd}set coversSeparators(t){const i=this.wd;i!==t&&(Util.i(t,"boolean",RowColumnDefinition,"coversSeparators"),this.wd=t,this.panel!==null&&this.panel.C(),this.t("coversSeparators",i,t))}get sizing(){return this.md}set sizing(t){const i=this.md;i!==t&&(this.md=t,this.panel!==null&&this.panel.c(),this.t("sizing",i,t))}Gb(){if(this.sizing===1){const t=this.Vs;return this.isRow?t.rowSizing:t.columnSizing}return this.sizing}get actual(){return this.st}set actual(t){isNaN(this.ge)?this.st=Math.max(Math.min(this.Ma,t),this.Sa):this.st=Math.max(Math.min(this.Ma,this.ge),this.Sa)}get measured(){return this.ji}set measured(t){this.ji=t}get total(){return this.st+this.computeEffectiveSpacing()}get position(){return this.at}set position(t){this.at=t}bind(t,i,e,s){return this.sf(t,i,e,s),this}bindTwoWay(t,i,e,s){const n=this.sf(t,i,e,s);return s===void 0&&n.makeTwoWay(),this}theme(t,i,e,s,n){return this.uh(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.uh(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.uh(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.uh(t,i,e,s,n).ofModel(),this}sf(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.G0(n),n}uh(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.G0(o),o}G0(t){t.ke=this;const i=this.panel;if(i!==null){const e=i.findBindingPanel();e!==null&&e.aA()&&Util.o("Cannot add a Binding to a RowColumnDefinition that is already frozen: "+t+" on "+i)}this.Gs===null&&(this.Gs=new List),this.Gs.add(t)}}class Shape extends GraphObject{ct;xs;xd;Ca;Hi;jo;Xo;Lt;bd;kd;J;constructor(t,i){super(),this.ct=null,this.xs=null,this.xd="None",this.Ca="black",this.Hi="black",this.jo=1,this.Xo=null,this.Lt=null,this.bd=NaN,this.kd=NaN,this.J=null,typeof t=="string"?this.figure=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.ct=this.ct,t.xs=this.xs,t.xd=this.xd,t.Ca=this.Ca,t.Hi=this.Hi,t.jo=this.jo,this.Xo!==null&&(t.Xo=this.Xo.slice()),this.Lt!==null&&(this.Lt.gi?t.Lt=this.Lt:t.Lt=this.Lt.copy()),t.bd=this.bd,t.kd=this.kd,this.J!==null&&(t.J=this.J.copy())}La(){this.Lt===null?this.Lt=new ShapeTemplateSettings:this.Lt.gi&&(this.Lt=this.Lt.copy())}lh(){super.lh(),this.Lt!==null&&(this.Lt.gi=!0)}ri(t){t in GeometryStretch?this.geometryStretch=t:super.ri(t)}toString(){return"Shape("+(this.figure!=="None"?this.figure:this.toArrow!=="None"?this.toArrow:this.fromArrow)+")#"+GSet.as(this)}mv(t,i){const e=this.pathPattern;e.ut(1/0,1/0);const s=e.measuredBounds;e.zt(0,0,s.width,s.height);const n=this.geometry;t.save(),t.beginPath();const o=Util.nt();if(n.type===1)o.push(n.startX),o.push(n.startY),o.push(n.endX),o.push(n.endY),this.Pd(t,i,o,e);else if(n.type===4){const r=n.figures.iterator;for(;r.next();){const l=r.value;o.length=0,o.push(l.startX),o.push(l.startY);let h=l.startX,a=l.startY,c=h,f=a;const u=l.segments.r,d=u.length;for(let m=0;m=.1;){if(M===0&&(S?(b=k,b-=P,y-=P,S=!1):b=k,b===0&&(b=1)),b>y){b=y,Util.tt(x);return}b>p?(M=b-p,b=p):M=0;let N=Math.sqrt(b*b/(1+m*m));if(u<0&&(N=-N),h+=N,a+=m*N,t.translate(h,a),t.rotate(g),t.translate(-(r/2),-(l/2)),M===0&&s.fh(t,i),t.translate(r/2,l/2),t.rotate(-g),t.translate(-h,-a),y-=b,p-=b,M!==0){if(L++,L===x.length){Util.tt(x);return}C=x[L],u=C[0],g=C[1],m=C[2],p=C[3],b=M}}Util.tt(x)}fh(t,i){const e=t instanceof SVGContext;let s=this.Hi;const n=this.Ca;if(s===null&&n===null)return;const o=this.ct;if(o===null)return;t.commitTransform();const r=this.actualBounds,l=this.naturalBounds;n!==null&&this.dn(t,n,!0,!1,l,r);const h=this.part;let a=this.jo;s!==null&&a===0&&h!==null&&(this.isPanelMain||h.findMainElement()===this)&&(a=h.yv()),a===0&&(s=null),s!==null&&a!==0&&(this.dn(t,s,!1,!1,l,r),t.lineWidth=a,t.lineJoin=this.strokeJoin,t.lineCap=this.strokeCap,t.miterLimit=this.strokeMiterLimit);let c=!1;h&&i.getRenderingHint("drawShadows")&&(c=h.isShadowed),t.tl===!1&&(c=!1);let f=!0;s!==null&&(n===null||n==="transparent")&&(f=!1);let u=!1;const d=this.strokeDashArray;if(d!==null&&(u=!0,t.enableDash(d,this.strokeDashOffset)),o.type===1)t.beginPath(),t.moveTo(o.startX,o.startY),t.lineTo(o.endX,o.endY),s!==null&&t.strokeContext(),t.endPath();else if(o.type===2){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.min(m,p),k=Math.min(g,y),b=Math.abs(p-m),P=Math.abs(y-g);t.beginPath(),t.rect(x,k,b,P),n!==null&&t.fillContext(n,!1,null),s!==null&&(f&&c&&t.shadowsOff(),t.strokeContext(),f&&c&&t.shadowsOn()),t.endPath()}else if(o.type===3){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.abs(p-m)/2,k=Math.abs(y-g)/2,b=Math.min(m,p)+x,P=Math.min(g,y)+k;t.beginPath(),t.moveTo(b,P-k),t.bezierCurveTo(b+Geo.Bn*x,P-k,b+x,P-Geo.Bn*k,b+x,P),t.bezierCurveTo(b+x,P+Geo.Bn*k,b+Geo.Bn*x,P+k,b,P+k),t.bezierCurveTo(b-Geo.Bn*x,P+k,b-x,P+Geo.Bn*k,b-x,P),t.bezierCurveTo(b-x,P-Geo.Bn*k,b-Geo.Bn*x,P-k,b,P-k),t.closePath(),n!==null&&t.fillContext(n,!1,null),s!==null&&(f&&c&&t.shadowsOff(),t.strokeContext(),f&&c&&t.shadowsOn()),t.endPath()}else if(o.type===4){const m=o.figures,g=m.length;for(let p=0;p1||this.pathPattern!==null?!0:super.ed(t)}l2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("path");for(let s=0;s1,i);Util.o("Unknown Geometry type: "+e.type)}}Qu(t,i,e,s){const n=this.desiredSize,o=this.jo;t=Math.max(t,0),i=Math.max(i,0);let r;if(this.xs!==null)r=this.geometry.bounds;else{const g=this.figure;let p=Shape.I2[g];if(p===void 0){let y=Geo.So[g];typeof y=="string"&&(y=Geo.So[y]),typeof y=="function"?(p=y(null,100,100),Shape.I2[g]=p):Util.o("Unsupported Figure: "+g)}r=p.bounds}let l=r.width,h=r.height,a=r.width,c=r.height;switch(this.zs(!0)){case 0:e=0,s=0;break;case 2:a=Math.max(t-o,0),c=Math.max(i-o,0);break;case 5:a=Math.max(t-o,0),s=0;break;case 4:e=0,c=Math.max(i-o,0);break}isFinite(n.width)&&(a=n.width),isFinite(n.height)&&(c=n.height);const u=this.maxSize,d=this.minSize;e=Math.max(e-o,d.width),s=Math.max(s-o,d.height),a=Math.min(u.width,a),c=Math.min(u.height,c),a=isFinite(a)?Math.max(e,a):Math.max(l,e),c=isFinite(c)?Math.max(s,c):Math.max(h,s);const m=this._P();switch(m){case 0:break;case 2:l=a,h=c;break;case 6:{let g=Math.min(a/l,c/h);isFinite(g)||(g=1),l=l*g,h=h*g;break}default:Util.o(m+" is not a valid geometryStretch.")}if(this.xs!==null){l===0&&(l=.001),h===0&&(h=.001);const p=(this.xs!==null?this.xs:this.ct).KD(l,h);this.ct=p}else(this.ct===null||!Geo.K(this.ct.sc,t-o)||!Geo.K(this.ct.nc,i-o))&&(this.ct=Shape.wv(this,l,h));r=this.ct.bounds,t===1/0||i===1/0?this.Qn(r.x-o/2,r.y-o/2,t===0&&l===0?0:r.width+o,i===0&&h===0?0:r.height+o):this.Qn(-(o/2),-(o/2),a+o,c+o),n.isReal()?(a=n.width,c=n.height,a=Math.min(u.width,a),c=Math.min(u.height,c),a=Math.max(d.width,a),c=Math.max(d.height,c),this.Vi.e(0,0,a,c)):this.Vi.a(r)}_P(){const t=this.geometryStretch;return this.xs!==null?t===1?2:t:t===1?Shape.I2[this.figure].defaultStretch:t}ah(t,i,e,s){this.commonArrange(t,i,e,s)}getNearestIntersectionPoint(t,i,e){return this.Zc(t.x,t.y,i.x,i.y,e)}Zc(t,i,e,s,n){const o=this.D,r=1/(o.m11*o.m22-o.m12*o.m21),l=o.m22*r,h=-o.m12*r,a=-o.m21*r,c=o.m11*r,f=r*(o.m21*o.dy-o.m22*o.dx),u=r*(o.m12*o.dx-o.m11*o.dy),d=t*l+i*a+f,m=t*h+i*c+u,g=e*l+s*a+f,p=e*h+s*c+u,y=this.jo/2;let x=this.ct;x===null&&(this.ut(1/0,1/0),x=this.ct);const k=x.bounds;let b=!1;if(x.type===1)if(this.strokeWidth<=1.5)b=Geo.Vn(x.startX,x.startY,x.endX,x.endY,d,m,g,p,n);else{let P=0,S=0;if(x.startX===x.endX)P=y,S=0;else{const T=(x.endY-x.startY)/(x.endX-x.startX);S=y/Math.sqrt(1+T*T),P=S*T}const L=Util.nt();let C=new Point;Geo.Vn(x.startX+P,x.startY+S,x.endX+P,x.endY+S,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Vn(x.startX-P,x.startY-S,x.endX-P,x.endY-S,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Vn(x.startX+P,x.startY+S,x.startX-P,x.startY-S,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Vn(x.endX+P,x.endY+S,x.endX-P,x.endY-S,d,m,g,p,C)&&L.push(C);const M=L.length;if(M===0)return Util.tt(L),!1;b=!0;let N=1/0;for(let T=0;T0&&k.contains(D,F)&&(M.x=D,M.y=F,this.containsPoint(M)))for(N!==0&&Math.abs(N)<.5?(T*=.5/N,N=.5):T!==0&&Math.abs(T)<.5&&(N*=.5/T,T=.5),D-=N,F-=T;k.contains(D,F);)D-=N,F-=T;const R=.6;n.x=g,n.y=p;for(let X=0;Xe?t-e:e-t)<(i>s?i-s:s-i)){const f=if||Geo.K(h.y,f))&&(h.yf||Geo.K(h.x,f))&&(h.x=a&&h<=c}else{let a=0,c=0;return s=a&&l<=c}}kv(t,i){if(this.containedInRect(t,i)||i===void 0&&(i=this.D,t.containsRect(this.actualBounds)))return!0;const e=t.left,s=t.right,n=t.top,o=t.bottom,r=Point.l(),l=Point.l(),h=Point.l(),a=Transform.l();a.set(i),a.hC(this.D),a.yw(),l.x=s,l.y=n,l.D(a),r.x=e,r.y=n,r.D(a);let c=!1;return this.Aa(r,l,h)?c=!0:(r.x=s,r.y=o,r.D(a),this.Aa(r,l,h)?c=!0:(l.x=e,l.y=o,l.D(a),this.Aa(r,l,h)?c=!0:(r.x=e,r.y=n,r.D(a),this.Aa(r,l,h)&&(c=!0)))),Transform.s(a),Point.s(r),Point.s(l),Point.s(h),c}_L(t,i,e){if(e&&this.fill!==null&&this.hh(t,!0))return!0;let s=t.distanceSquaredPoint(i);const n=s;this.strokeWidth>1.5&&(s=this.strokeWidth/2+Math.sqrt(s),s*=s);let o=this.ct;if(o===null&&(this.ut(1/0,1/0),o=this.ct,o===null))return!1;if(!e){const f=o.bounds,u=f.x,d=f.y,m=f.x+f.width,g=f.y+f.height;if(Point.distanceSquared(t.x,t.y,u,d)<=s&&Point.distanceSquared(t.x,t.y,m,d)<=s&&Point.distanceSquared(t.x,t.y,u,g)<=s&&Point.distanceSquared(t.x,t.y,m,g)<=s)return!0}function r(f,u){const d=f.length;for(let m=0;ms)return!0;return!1}const l=o.startX,h=o.startY,a=o.endX,c=o.endY;if(o.type===1){const f=Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,c),u=(a-l)*(t.x-l)+(c-h)*(t.y-h),d=(l-a)*(t.x-a)+(h-c)*(t.y-c),m=u>=0&&d>=0?s:n;return f<=m}else if(o.type===2){let f=!1;return e&&(f=Point.distanceLineSegmentSquared(t.x,t.y,l,h,l,c)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,h)<=s||Point.distanceLineSegmentSquared(t.x,t.y,a,h,a,c)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,c,a,c)<=s),f}else if(o.type===3){const f=(l+a)/2,u=(h+c)/2,d=t.x-f,m=t.y-u,g=Math.abs(a-l)/2,p=Math.abs(c-h)/2;if(g===0||p===0)return Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,c)<=s;if(e){const y=Geo.vD(g,p,d,m);return y*y<=s}else return!(Point.distanceSquared(d,m,-g,0)>=s||Point.distanceSquared(d,m,0,-p)>=s||Point.distanceSquared(d,m,0,p)>=s||Point.distanceSquared(d,m,g,0)>=s)}else if(o.type===4){const f=o.bounds,u=f.x,d=f.y,m=f.x+f.width,g=f.y+f.height;if(t.x>m&&t.xg&&t.ys&&Point.distanceLineSegmentSquared(t.x,t.y,u,d,m,d)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,u,g)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,m,d)>s)return!1;const p=Math.sqrt(s);if(e){if(this.fill===null?o.xC(t.x,t.y,p):o.Vk(t,p,!0,!1))return!0}else{const y=o.figures;for(let x=0;xs)return!1;const S=k.segments.r,L=S.length;for(let C=0;Cs)return!1;break;case 3:{const N=Util.nt();Geo.Un(b,P,M.point1X,M.point1Y,M.point2X,M.point2Y,M.endX,M.endY,.8,N);const T=r(N,t);if(Util.tt(N),T||(b=M.endX,P=M.endY,t.distanceSquared(b,P)>s))return!1;break}case 4:{const N=Util.nt();Geo.Bg(b,P,M.point1X,M.point1Y,M.endX,M.endY,.8,N);const T=r(N,t);if(Util.tt(N),T||(b=M.endX,P=M.endY,t.distanceSquared(b,P)>s))return!1;break}case 5:case 6:{const N=M.type===5?M.Mo(k):M.Eh(k,b,P),T=N.length;if(T===0){if(b=M.type===5?M.centerX:M.endX,P=M.type===5?M.centerY:M.endY,t.distanceSquared(b,P)>s)return!1;break}let A=null;const D=Util.nt();for(let F=0;F=0){this.jo=t,this.c();const e=this.part;e!==null&&e.cf(),this.t("strokeWidth",i,t)}else Util._(t,"value >= 0",Shape,"strokeWidth:value")}w0(){return this.jo}get strokeCap(){return this.Lt!==null?this.Lt.pp:"butt"}set strokeCap(t){const i=this.strokeCap;i!==t&&(typeof t=="string"&&(t==="butt"||t==="round"||t==="square")?(this.La(),this.Lt.pp=t,this.C(),this.t("strokeCap",i,t)):Util._(t,'"butt", "round", or "square"',Shape,"strokeCap"))}get strokeJoin(){return this.Lt!==null?this.Lt.yp:"miter"}set strokeJoin(t){const i=this.strokeJoin;i!==t&&(typeof t=="string"&&(t==="miter"||t==="bevel"||t==="round")?(this.La(),this.Lt.yp=t,this.C(),this.t("strokeJoin",i,t)):Util._(t,'"miter", "bevel", or "round"',Shape,"strokeJoin"))}get strokeMiterLimit(){return this.Lt!==null?this.Lt.wp:10}set strokeMiterLimit(t){const i=this.strokeMiterLimit;if(i!==t&&t>=1){this.La(),this.Lt.wp=t,this.C();const e=this.part;e!==null&&e.cf(),this.t("strokeMiterLimit",i,t)}}get strokeDashArray(){return this.Xo}set strokeDashArray(t){const i=this.Xo;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",Shape,"strokeDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("strokeDashArray:value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.Xo=t,this.C(),this.t("strokeDashArray",i,t)}}get strokeDashOffset(){return this.Lt!==null?this.Lt.dh:0}set strokeDashOffset(t){const i=this.strokeDashOffset;i!==t&&t>=0&&(this.La(),this.Lt.dh=t,this.C(),this.t("strokeDashOffset",i,t))}get figure(){return this.xd}set figure(t){const i=this.xd;if(i!==t){let e=Geo.So[t];if(typeof e=="function"?e=t:(e=Geo.So[t.toLowerCase()],e||Util.o("Unknown Shape.figure: "+t)),i!==e){const s=this.part;s!==null&&s.cf(),this.xd=e,this.xs=null,this.ee(),this.c(),this.t("figure",i,e)}}}get toArrow(){return this.Bt!==null?this.Bt.xp:"None"}set toArrow(t){const i=this.toArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){const e=Shape.AA(t);e===null?Util.o("Unknown Shape.toArrow: "+t):i!==e&&(this.Bt===null&&(this.Bt=new LinkElementSettings),this.Bt.xp=e,this.xs=null,this.ee(),this.c(),this.TA(e),this.t("toArrow",i,e))}}get fromArrow(){return this.Bt!==null?this.Bt.bp:"None"}set fromArrow(t){const i=this.fromArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){const e=Shape.AA(t);e===null?Util.o("Unknown Shape.fromArrow: "+t):i!==e&&(this.Bt===null&&(this.Bt=new LinkElementSettings),this.Bt.bp=e,this.xs=null,this.ee(),this.c(),this.TA(e),this.t("fromArrow",i,e))}}TA(t){const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;this.vR();const e=Spot.MiddleRight;this.toArrow!=="None"?(this.segmentIndex=-1,this.alignmentFocus=e):this.fromArrow!=="None"&&(this.segmentIndex=0,this.alignmentFocus=new Spot(1-e.x,e.y))}get spot1(){return this.Lt!==null?this.Lt.zn:Spot.Default}set spot1(t){const i=this.spot1;i.equals(t)||(t=t.N(),this.La(),this.Lt.zn=t,this.c(),this.t("spot1",i,t))}get spot2(){return this.Lt!==null?this.Lt.Xn:Spot.Default}set spot2(t){const i=this.spot2;i.equals(t)||(t=t.N(),this.La(),this.Lt.Xn=t,this.c(),this.t("spot2",i,t))}get parameter1(){return this.bd}set parameter1(t){const i=this.bd;i!==t&&(this.bd=t,this.ee(),this.c(),this.t("parameter1",i,t))}get parameter2(){return this.kd}set parameter2(t){const i=this.kd;i!==t&&(this.kd=t,this.ee(),this.c(),this.t("parameter2",i,t))}get naturalBounds(){return this.Vi}_R(){const t=this.desiredSize;if(!t.isReal()&&this.ct!==null){const i=this.ct.bounds;this.Vi.a(i)}else this.Vi.e(0,0,t.width,t.height)}get pathPattern(){return this.Lt!==null?this.Lt.kp:null}set pathPattern(t){const i=this.pathPattern;i!==t&&(this.La(),this.Lt.kp=t,this.C(),this.t("pathPattern",i,t))}get geometryStretch(){return this.Lt!==null?this.Lt.Pp:1}set geometryStretch(t){const i=this.geometryStretch;i!==t&&(this.La(),this.Lt.Pp=t,this.c(),this.t("geometryStretch",i,t))}get interval(){return this.J!==null?this.J.uf:1}set interval(t){const i=this.interval;if(t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this.J===null&&(this.J=new GradElementSettings),this.J.uf=t;const e=this.diagram;e!==null&&this.panel===e.grid&&e.jr(),this.c();const s=this.panel;s!==null&&(s.ns=null),this.t("interval",i,t)}}get graduatedStart(){return this.J!==null?this.J.df:0}set graduatedStart(t){const i=this.graduatedStart;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.df=t,this.c(),this.t("graduatedStart",i,t))}get graduatedEnd(){return this.J!==null?this.J.gf:1}set graduatedEnd(t){const i=this.graduatedEnd;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.gf=t,this.c(),this.t("graduatedEnd",i,t))}get graduatedSkip(){return this.J!==null?this.J.mf:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.i(t,"function",Shape,"graduatedSkip"),this.J===null&&(this.J=new GradElementSettings),this.J.mf=t,this.c(),this.t("graduatedSkip",i,t))}static wv(t,i,e){let n=null;if(t.toArrow!=="None")n=Shape.no[t.toArrow];else if(t.fromArrow!=="None")n=Shape.no[t.fromArrow];else{let o=Geo.So[t.figure];typeof o=="string"&&(o=Geo.So[o]),o===void 0&&Util.o("Unknown Shape.figure: "+t.figure),n=o(t,i,e),n.sc=i,n.nc=e}if(n===null){const o=Geo.So.Rectangle;typeof o=="function"&&(n=o(t,i,e))}return n}static getFigureGenerators(){const t=new GMap;for(const i in Geo.So){if(i===i.toLowerCase())continue;const e=Geo.So[i];t.set(i,e)}return t.g(),t}static defineFigureGenerator(t,i){Util.i(t,"string",Shape,"defineFigureGenerator:name"),typeof i=="string"||Util.i(i,"function",Shape,"defineFigureGenerator:func");const e=t.toLowerCase(),s=Geo.So;s[t]=i,s[e]=t}static getArrowheadGeometries(){const t=new GMap;for(const i in Geo.Xg)if(Shape.no[i]===void 0){const e=Geometry.parse(Geo.Xg[i],!1);Shape.no[i]=e;const s=i.toLowerCase();s!==i&&(Shape.no[s]=i)}for(const i in Shape.no){if(i===i.toLowerCase())continue;const e=Shape.no[i];e instanceof Geometry&&t.set(i,e)}return t.g(),t}static defineArrowheadGeometry(t,i){Util.i(t,"string",Shape,"defineArrowheadGeometry:name");let e=null;typeof i=="string"?(Util.i(i,"string",Shape,"defineArrowheadGeometry:pathstr"),e=Geometry.parse(i,!1)):e=i;const s=t.toLowerCase();(s==="none"||t===s)&&Util.o("Shape.defineArrowheadGeometry name must not be empty or None or all-lower-case: "+t);const n=Shape.no;n[t]=e,n[s]=t}static no=new PropertyCollection;static I2=new PropertyCollection;static AA(t){let i=Shape.no[t];if(i===void 0){const e=t.toLowerCase();if(e==="none")return"None";if(i=Shape.no[e],i===void 0){let s=null;for(const n in Geo.Xg)if(n.toLowerCase()===e){s=n;break}if(s!==null){const n=Geometry.parse(Geo.Xg[s],!1);return Shape.no[s]=n,e!==s&&(Shape.no[e]=s),s}}}return typeof i=="string"?i:i instanceof Geometry?t:null}}class ShapeTemplateSettings{gi;pp;yp;wp;dh;kp;Pp;zn;Xn;constructor(){this.gi=!1,this.pp="butt",this.yp="miter",this.wp=10,this.dh=0,this.kp=null,this.Pp=1,this.zn=Spot.Default,this.Xn=Spot.Default}copy(){const t=new ShapeTemplateSettings;return t.pp=this.pp,t.yp=this.yp,t.wp=this.wp,t.dh=this.dh,t.kp=this.kp,t.Pp=this.Pp,t.zn=this.zn.N(),t.Xn=this.Xn.N(),t}}var Wrap=(w=>(w[w.None=0]="None",w[w.Fit=1]="Fit",w[w.DesiredSize=2]="DesiredSize",w[w.BreakAll=3]="BreakAll",w))(Wrap||{}),TextOverflow=(w=>(w[w.Clip=0]="Clip",w[w.Ellipsis=1]="Ellipsis",w))(TextOverflow||{}),TextFormat=(w=>(w[w.Trim=0]="Trim",w[w.None=1]="None",w))(TextFormat||{});class TextBlock extends GraphObject{hi;Hi;kn;Ce;mi;x0;Sd;J;W;Dl;oo;Pn;Le;Di;Sn;constructor(t,i){return super(),this.n|=2097152,this.hi="",this.Hi="black",this.kn="13px sans-serif",this.Ce=0,this.mi=0,this.x0=0,this.Sd=null,this.J=null,this.W=null,this.Dl=0,this.oo=null,this.Pn=0,this.Le=null,this.Di=null,this.Sn=null,typeof t=="string"?this.text=t:t&&Object.assign(this,t),i&&Object.assign(this,i),this}cloneProtected(t){super.cloneProtected(t),t.hi=this.hi,t.Hi=this.Hi,t.kn=this.kn,t.Ce=this.Ce,t.mi=this.mi,t.x0=this.x0,t.Sd=this.Sd,this.J!==null&&(t.J=this.J.copy()),this.W!==null&&(this.W.gi?t.W=this.W:t.W=this.W.copy()),t.Dl=this.Dl,t.oo=this.oo,t.Pn=this.Pn,t.Le=this.Le,t.Di=this.Di,t.Sn=this.Sn}Mn(){this.W===null?this.W=new TextBlockTemplateSettings:this.W.gi&&(this.W=this.W.copy())}lh(){super.lh(),this.W!==null&&(this.W.gi=!0)}rv(t){this.n=t.n|2048|4096,this.Wt=t.opacity,this.Ct=t.background,this.ze=t.desiredSize.N(),this.minSize=t.minSize.N(),this.maxSize=t.maxSize.N(),t.bi!==null?this.bi=t.bi.copy():this.bi=null,this.et=t.scale,this.Xt=t.angle,this.stretch=t.stretch,this.Zr=t.margin.N(),this.oi=t.alignment.N(),this.Wc=t.alignmentFocus.N(),this.segmentFraction=t.segmentFraction,this.segmentOffset=t.segmentOffset.N(),this.segmentOrientation=t.segmentOrientation,t.ni!==null&&(this.ni=t.ni.copy()),this.shadowVisible=t.shadowVisible,this.hi=t.hi,this.Hi=t.Hi,this.kn=t.kn,this.J!==null&&(this.J=t.J.copy()),t.W!==null&&(t.W.gi?this.W=t.W:this.W=t.W.copy()),this.Dl=t.Dl}nv(t){if(this.hi=t.text||"",this.Xt=t.labelAngle||0,this.Ce=t.lineCount||0,this.Pv(t.lines),t.naturalBounds&&(this.Vi=t.naturalBounds),t.actualBounds){const i=t.actualBounds;this.zt(i.x,i.y,i.width,i.height)}}ri(t){t in Wrap?this.wrap=t:super.ri(t)}toString(){return this.hi.length>22?'TextBlock("'+this.hi.substring(0,20)+'"...)':'TextBlock("'+this.hi+'")'}static getEllipsis(){return TextBlock.Sp}static setEllipsis(t){TextBlock.Sp=t,TextBlock.Zb=new PropertyCollection,TextBlock.E2=0}static getBaseline(){return TextBlock.Qb}static setBaseline(t){TextBlock.Qb=t}static Qb=null;static getUnderline(){return TextBlock._b}static setUnderline(t){TextBlock._b=t}static _b=null;static None=0;static WrapFit=1;static WrapDesiredSize=2;static WrapBreakAll=3;static OverflowClip=0;static OverflowEllipsis=1;static FormatTrim=0;static FormatNone=1;c(){super.c()}get font(){return this.kn}set font(t){const i=this.kn;i!==t&&(this.kn=t,this.oo=null,this.c(),this.t("font",i,t))}static isValidFont(t){return root.CSS?root.CSS.supports("font",t):!0}get text(){return this.hi}set text(t){const i=this.hi;t!=null?t=t.toString():t="",i!==t&&(this.hi=t,this.c(),this.t("text",i,t),this.ss(!0))}get textAlign(){return this.W!==null?this.W.Mp:"start"}set textAlign(t){const i=this.textAlign;i!==t&&(t==="start"||t==="end"||t==="left"||t==="right"||t==="center")&&(this.Mn(),this.W.Mp=t,this.C(),this.t("textAlign",i,t))}get flip(){return this.W!==null?this.W.ro:0}set flip(t){const i=this.flip;i!==t&&(this.Mn(),this.W.ro=t,this.C(),this.t("flip",i,t))}get verticalAlignment(){return this.W!==null?this.W.sl:Spot.Top}set verticalAlignment(t){const i=this.verticalAlignment;i.equals(t)||(t=t.N(),this.Mn(),this.W.sl=t,this.ef(),this.t("verticalAlignment",i,t))}get naturalBounds(){if(!this.Vi.isReal()){const t=Size.l();this.B2(this.hi,999999,t);let i=t.width;Size.s(t);let e=this.DA(i);const s=this.desiredSize;isNaN(s.width)||(i=s.width),isNaN(s.height)||(e=s.height),this.Vi.En(i,e)}return this.Vi}get isMultiline(){return(this.n&2097152)!==0}set isMultiline(t){const i=(this.n&2097152)!==0;i!==t&&(this.n=this.n^2097152,this.c(),this.t("isMultiline",i,t))}get isUnderline(){return(this.n&4194304)!==0}set isUnderline(t){const i=(this.n&4194304)!==0;i!==t&&(this.n=this.n^4194304,this.ss(!0),this.C(),this.t("isUnderline",i,t))}get isStrikethrough(){return(this.n&8388608)!==0}set isStrikethrough(t){const i=(this.n&8388608)!==0;i!==t&&(this.n=this.n^8388608,this.ss(!0),this.C(),this.t("isStrikethrough",i,t))}get wrap(){return this.W!==null?this.W.Np:2}set wrap(t){const i=this.wrap;i!==t&&(this.Mn(),this.W.Np=t,this.c(),this.t("wrap",i,t))}get overflow(){return this.W!==null?this.W.Cp:0}set overflow(t){const i=this.overflow;i!==t&&(this.Mn(),this.W.Cp=t,this.c(),this.t("overflow",i,t))}get isOverflowed(){return(this.n&16777216)!==0}U2(t){t?this.n|=16777216:this.n&=-16777217}get stroke(){return this.Hi}set stroke(t){const i=this.Hi;i!==t&&(t!==null&&Brush.nd(t,"TextBlock.stroke"),t instanceof Brush&&t.g(),this.Hi=t,this.C(),this.t("stroke",i,t))}get lineCount(){return this.Ce}get lineHeight(){return this.Lp()}get editable(){return(this.n&1048576)!==0}set editable(t){const i=(this.n&1048576)!==0;i!==t&&(this.n=this.n^1048576,this.t("editable",i,t))}get L2(){return(this.n&33554432)!==0}set L2(t){this.n=this.n^33554432}get textEditor(){return this.W!==null?this.W.Ap:null}set textEditor(t){const i=this.textEditor;i!==t&&(this.Mn(),this.W.Ap=t,this.t("textEditor",i,t))}get errorFunction(){return this.W!==null?this.W.os:null}set errorFunction(t){const i=this.errorFunction;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"errorFunction"),this.Mn(),this.W.os=t,this.t("errorFunction",i,t))}get interval(){return this.J!==null?this.J.uf:1}set interval(t){const i=this.interval;if(t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this.J===null&&(this.J=new GradElementSettings),this.J.uf=t,this.c();const e=this.panel;e!==null&&(e.ns=null),this.t("interval",i,t)}}get graduatedStart(){return this.J!==null?this.J.df:0}set graduatedStart(t){const i=this.graduatedStart;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.df=t,this.c(),this.t("graduatedStart",i,t))}get graduatedEnd(){return this.J!==null?this.J.gf:1}set graduatedEnd(t){const i=this.graduatedEnd;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.gf=t,this.c(),this.t("graduatedEnd",i,t))}get graduatedFunction(){return this.J!==null?this.J.Tp:null}set graduatedFunction(t){const i=this.graduatedFunction;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"graduatedFunction"),this.J===null&&(this.J=new GradElementSettings),this.J.Tp=t,this.c(),this.t("graduatedFunction",i,t))}get graduatedSkip(){return this.J!==null?this.J.mf:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"graduatedSkip"),this.J===null&&(this.J=new GradElementSettings),this.J.mf=t,this.c(),this.t("graduatedSkip",i,t))}fh(t,i){if(this.Hi===null||this.hi.length===0||this.kn===null)return;const e=this.naturalBounds,s=this.actualBounds,n=e.width,o=e.height,r=this.Lp();let l=t.textAlign=this.textAlign;const h=i.Xu;l==="start"?l=h?"right":"left":l==="end"&&(l=h?"left":"right");const a=this.isUnderline,c=this.isStrikethrough;this.dn(t,this.Hi,!0,!1,e,s),(a||c)&&this.dn(t,this.Hi,!1,!1,e,s);const f=0;let u=0;const d=n;let m=!1;i.Zt===t&&!(i.Zt instanceof SVGContext)&&!this.L2&&i.getRenderingHint("textGreeking")===!0&&r*this.ca*i.scale<3&&(m=!0);const g=this.spacingAbove,p=this.spacingBelow;switch(this.flip){case 0:break;case 2:t.translate(n,0),t.scale(-1,1);break;case 1:t.translate(0,o),t.scale(1,-1);break;case 3:t.translate(n,o),t.scale(-1,-1);break}t.commitTransform();const y=this.Ce,k=(g+r+p)*y;if(o>k){const b=this.verticalAlignment;u=b.y*o-b.y*k+b.offsetY}if(y===1&&this.Sn!==null){let b=this.mi;b>d&&(b=d),u+=g,this.FA(this.Sn,t,f,u,d,r,b,m,l,a,c)}else if(this.Le!==null&&this.Di!==null)for(let b=0;bd&&(P=d),u+=g,this.FA(this.Di[b],t,f,u,d,r,P,m,l,a,c),u+=r+p}switch(this.flip){case 0:break;case 2:t.scale(-1,1),t.translate(-n,0);break;case 1:t.scale(1,-1),t.translate(0,-o);break;case 3:t.scale(-1,-1),t.translate(-n,-o);break}}FA(t,i,e,s,n,o,r,l,h,a,c){let f=0;if(l){h==="left"?f=0:h==="right"?f=n-r:h==="center"&&(f=(n-r)/2);const m=i.globalAlpha;i.globalAlpha=m/2,i.fillRect(e+f,s+o/4,r,o/2),i.globalAlpha=m;return}h==="left"?f=0:h==="right"?f=n:h==="center"&&(f=n/2);const u=TextBlock.Qb!==null?TextBlock.Qb(this,o):o*.75;i.fillText(t,e+f,s+u);let d=o/20|0;if(d===0&&(d=1),h==="right"?f-=r:h==="center"&&(f-=r/2),a){const m=TextBlock._b!==null?TextBlock._b(this,o):o*.8;this.RA(e+f,s+m,e+f+r,s+m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}if(c){let m=s+o-o/2.2|0;d%2!==0&&(m+=.5),this.RA(e+f,m,e+f+r,m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}}RA(t,i,e,s,n,o){o.beginPath(),o.lineWidth=n,o.moveTo(t,i),o.lineTo(e,s),o.stroke(),o.endPath()}Qc(t,i,e){if(!super.Qc(t,i,e))return!1;if(this.dn(t,this.Hi,!0,!1,this.naturalBounds,this.actualBounds),e){if(this.svg.getElementsByTagName("text").length===0)return!0;const n=this.svg.getElementsByClassName("gojs-td");for(let o=0;o1||this.isUnderline||this.isStrikethrough?!0:super.ed(t)}l2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("text");for(let s=0;sthis.maxLines&&(this.n|=16777216))}B2(t,i,e){const s=this.formatting===0;s&&(t=t.trim());let n=0,o=0,r=0;const l=this.kn,h=this.spacingAbove+this.spacingBelow,a=Math.max(0,this.Lp()+h),c=this.overflow===1?this.OA(l):0;if(this.Ce>=this.maxLines){e!==null&&e.e(0,a);return}let f=t;if(this.wrap===0){if(this.Pn=1,o=this.getStringWidth(t),c===0||o<=i){this.mi=Math.max(this.mi,o),this.Nn(t,this.mi),e!==null&&e.e(o,a);return}let d=this.Md(f);f=f.substring(d.length);let m=this.Md(f);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,f=f.substring(m.length),m=this.Md(f),r=o;let g=d+m;s&&(g=g.trim()),o=this.getStringWidth(g)}for(s&&(m=m.trim()),d+=m,i=Math.max(1,i-c);this.getStringWidth(d)>i&&d.length>1;)d=d.substring(0,d.length-1);this.U2(!0),d+=TextBlock.Sp,r=this.getStringWidth(d),this.mi=r,this.Nn(d,r),e!==null&&e.e(r,a);return}let u=0;for(f.length===0&&(u=1,this.Nn(f,0));f.length>0;){let d=this.Md(f);for(f=f.substring(d.length);this.getStringWidth(d)>i;){let p=1;for(o=this.getStringWidth(d.substring(0,p)),r=0;o<=i;)p++,r=o,o=this.getStringWidth(d.substring(0,p));let y=0;p===1?(y=o,n=Math.max(n,o)):(y=r,n=Math.max(n,r)),p--,p<1&&(p=1);const x=d.substring(0,p);if(this.Nn(x,y),u++,d=d.substring(p),this.Ce+u>this.maxLines)break}let m=this.Md(f);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,f=f.substring(m.length),m=this.Md(f),r=o;let p=d+m;s&&(p=p.trim()),o=this.getStringWidth(p)}if(s&&(d=d.trim()),d==="")continue;d[d.length-1]==="\xAD"&&(d=d.substring(0,d.length-1)+"\u2010");let g=0;if(m.length===0?(g=o,n=Math.max(n,o)):(r=this.getStringWidth(d),g=r,n=Math.max(n,r)),this.Nn(d,g),u++,this.Ce+u>this.maxLines)break}this.Pn=Math.min(this.maxLines,u),this.mi=Math.max(this.mi,n),e!==null&&e.e(this.mi,a*this.Pn)}Cv(t,i){if(this.mi===0||this.Le===null||this.Di===null||this.overflow!==1)return;const e=this.kn,s=this.overflow===1?this.OA(e):0,n=this.spacingAbove+this.spacingBelow,o=Math.max(0,this.Lp()+n),r=Math.min(this.maxLines-1,Math.max(Math.floor(i/o+.01)-1,0));if(r+1>=this.Di.length)return;this.U2(!0);let l=this.Di[r];const h=Math.max(1,t-s);for(;this.getStringWidth(l)>h&&l.length>1;)l=l.substring(0,l.length-1);l+=TextBlock.Sp;const a=this.getStringWidth(l);this.Di[r]=l,this.Di=this.Di.slice(0,r+1),this.Le[r]=a,this.Le=this.Le.slice(0,r+1),this.Pn=this.Di.length,this.mi=Math.max(this.mi,a),this.Ce=this.Pn,this.Ce===1&&(this.Sn=this.Di[0])}Md(t){if(this.wrap===3)return t.substring(0,1);let i=t.length,e=0;const s=TextBlock.Lv;for(;e=t.length?t:t.substring(0,e)}getStringWidth(t){return TextBlock.il===null?t.length*8:TextBlock.il.measureText(t).width}Lp(){if(this.oo!==null)return this.oo;const t=this.kn;let i=0;return TextBlock.il===null?(i=16,this.oo=i,i):(TextBlock.V2[t]!==void 0&&TextBlock.IA<5e3?i=TextBlock.V2[t]:(i=TextBlock.il.measureText("M").width*1.3,TextBlock.V2[t]=i,TextBlock.IA++),this.oo=i,i)}OA(t){if(TextBlock.il===null)return 6;let i=0;return TextBlock.Zb[t]!==void 0&&TextBlock.E2<5e3?i=TextBlock.Zb[t]:(i=TextBlock.il.measureText(TextBlock.Sp).width,TextBlock.Zb[t]=i,TextBlock.E2++),i}t1(t,i){return t.indexOf(` `,i)}DA(t){let i=this.hi.replace(/\r\n/g,` `).replace(/\r/g,` -`);const e=this.spacingAbove+this.spacingBelow,s=Math.max(0,this.Lp()+e);if(i.length===0)return this.mi=0,this.Ce=1,s;if(!this.isMultiline){const h=this.t1(i,0);h>=0&&(i=i.substring(0,h))}let n=0;this.Ce=0;let o=0,r=-1,l=!1;for(;!l;){if(r=this.t1(i,o),r===-1&&(r=i.length,l=!0),o<=r){const h=i.substring(o,r);if(this.wrap!==0){this.Pn=0;const a=Size.l();this.V2(h,t,a),n+=a.height,Size.s(a),this.Ce+=this.Pn}else this.V2(h,t,null),n+=s,this.Ce++;this.Ce===this.maxLines&&(l=!0)}o=r+1}return this.x0=n,n}Cv(){let t=this.hi.replace(/\r\n/g,` +`);const e=this.spacingAbove+this.spacingBelow,s=Math.max(0,this.Lp()+e);if(i.length===0)return this.mi=0,this.Ce=1,s;if(!this.isMultiline){const h=this.t1(i,0);h>=0&&(i=i.substring(0,h))}let n=0;this.Ce=0;let o=0,r=-1,l=!1;for(;!l;){if(r=this.t1(i,o),r===-1&&(r=i.length,l=!0),o<=r){const h=i.substring(o,r);if(this.wrap!==0){this.Pn=0;const a=Size.l();this.B2(h,t,a),n+=a.height,Size.s(a),this.Ce+=this.Pn}else this.B2(h,t,null),n+=s,this.Ce++;this.Ce===this.maxLines&&(l=!0)}o=r+1}return this.x0=n,n}Nv(){let t=this.hi.replace(/\r\n/g,` `).replace(/\r/g,` -`);if(t.length===0)return 8;if(this.isMultiline){let i=0,e=0,s=!1;for(;!s;){let n=this.t1(t,e);n===-1&&(n=t.length,s=!0);let o=t.substring(e,n);this.formatting===0&&(o=o.trim()),i=Math.max(i,this.getStringWidth(o)),e=n+1}return i}else{const i=this.t1(t,0);return i>=0&&(t=t.substring(0,i)),this.getStringWidth(t)}}get textValidation(){return this.W!==null?this.W.Tl:null}set textValidation(t){const i=this.textValidation;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"textValidation"),this.Sn(),this.W.Tl=t,this.t("textValidation",i,t))}get textEdited(){return this.W!==null?this.W.Dp:null}set textEdited(t){const i=this.textEdited;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"textEdited"),this.Sn(),this.W.Dp=t,this.t("textEdited",i,t))}get spacingAbove(){return this.W!==null?this.W.Fp:0}set spacingAbove(t){const i=this.spacingAbove;i!==t&&(this.Sn(),this.W.Fp=t,this.c(),this.t("spacingAbove",i,t))}get spacingBelow(){return this.W!==null?this.W.Rp:0}set spacingBelow(t){const i=this.spacingBelow;i!==t&&(this.Sn(),this.W.Rp=t,this.c(),this.t("spacingBelow",i,t))}get formatting(){return this.W!==null?this.W.vp:0}set formatting(t){const i=this.formatting;i!==t&&(this.Sn(),this.W.vp=t,this.c(),this.t("formatting",i,t))}get maxLines(){return this.W!==null?this.W.Op:1/0}set maxLines(t){const i=this.maxLines;i!==t&&(t=Math.floor(t),t<=0&&Util._(t,"> 0",TextBlock,"maxLines"),this.Sn(),this.W.Op=t,this.c(),this.t("maxLines",i,t))}getMetrics(){return[this.mi,this.Dl,this.oo,this.Pn,this.Le,this.Di,this.Mn]}Mv(t){t!==void 0&&(this.mi=t[0],this.Dl=t[1],this.oo=t[2],this.Pn=t[3],this.Le=t[4],this.Di=t[5],this.Mn=t[6])}get metrics(){return{arrSize:this.Le!==null?this.Le:[this.mi],arrText:this.Di!==null?this.Di:[this.Mn],maxLineWidth:this.mi,fontHeight:this.oo}}get choices(){return this.Sd}set choices(t){const i=this.Sd;i!==t&&(this.Sd=t,this.t("choices",i,t))}static Av=new RegExp("[ \u200B\xAD]");static X2=new PropertyCollection;static IA=0;static Zb=new PropertyCollection;static B2=0;static Mp="...";static vA="";static il=Diagram.isUsingDOM()?new CanvasSurface(null).ai:null}class TextBlockTemplateSettings{gi;os;ro;vp;Op;Cp;Fp;Rp;Sp;Dp;Ap;Tl;sl;Np;constructor(){this.gi=!1,this.os=null,this.ro=0,this.vp=0,this.Op=1/0,this.Cp=0,this.Fp=0,this.Rp=0,this.Sp="start",this.Dp=null,this.Ap=null,this.Tl=null,this.sl=Spot.Top,this.Np=2}copy(){const t=new TextBlockTemplateSettings;return t.os=this.os,t.ro=this.ro,t.vp=this.vp,t.Op=this.Op,t.Cp=this.Cp,t.Fp=this.Fp,t.Rp=this.Rp,t.Sp=this.Sp,t.Dp=this.Dp,t.Ap=this.Ap,t.Tl=this.Tl,t.sl=this.sl,t.Np=this.Np,t}}class GradElementSettings{ff;uf;df;Tp;gf;constructor(){this.ff=1,this.uf=0,this.df=1,this.Tp=null,this.gf=null}copy(){const t=new GradElementSettings;return t.ff=this.ff,t.uf=this.uf,t.df=this.df,t.Tp=this.Tp,t.gf=this.gf,t}}var ImageStretch=(w=>(w[w.None=0]="None",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ImageStretch||{});class Picture extends GraphObject{nl;yt;ol;mf;os;rl;pf;ro;yf;wf;Ib;constructor(t,i){super(),this.n|=2097152,this.nl=null,this.yt="",this.ol=Rect.TD,this.mf=2,this.os=null,this.rl=null,this.pf=Spot.Center,this.ro=0,this.yf=null,this.wf=null,this.Ib=null,typeof t=="string"?this.source=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.yt=this.yt,t.element=this.nl,t.ol=this.ol.N(),t.mf=this.mf,t.ro=this.ro,t.os=this.os,t.rl=this.rl,t.pf=this.pf.N(),t.wf=this.wf}ri(t){t in ImageStretch?this.imageStretch=t:super.ri(t)}toString(){return"Picture("+this.source+")#"+GSet.as(this)}get xf(){return(this.n&1048576)!==0}set xf(t){this.xf!==t&&(this.n=this.n^1048576)}get Ip(){return(this.n&2097152)!==0}set Ip(t){this.Ip!==t&&(this.n=this.n^2097152)}get mn(){return(this.n&4194304)!==0}set mn(t){this.mn!==t&&(this.n=this.n^4194304)}static clearCache(t){t===void 0&&(t=""),Util.i(t,"string",Picture,"clearCache:url"),t!==""?Picture.Ep[t]&&(delete Picture.Ep[t],Picture.i1--):(Picture.Ep=new PropertyCollection,Picture.i1=0)}static IL(t,i){i.EA||(i.e1=e=>{Picture.Tv(i,e),t.desiredSize.isReal()||(t.fe(!1),t.c())},i.s1=e=>Picture.Dv(i,e),i.addEventListener("load",i.e1),i.addEventListener("error",i.s1),i.EA=!0)}static yR(t){t.e1&&t.removeEventListener("load",t.e1),t.s1&&t.removeEventListener("error",t.s1),delete t.e1,delete t.s1,delete t.EA}get element(){return this.nl}set element(t){const i=this.nl;if(this.ss(!0),i!==t){this.xf=t instanceof HTMLCanvasElement;const e=t instanceof HTMLImageElement;t!==null&&!(e||t instanceof HTMLVideoElement||this.xf)&&Util.o("Picture.element must be an instance of Image, Canvas, or Video, not: "+t);const s=this.diagram;s!==null&&s.DS(this),this.nl=t,t!==null&&e&&t.es===void 0&&(t.es=new GSet),s!==null&&e&&s.TS(this),this.t("element",i,t),this.C()}}mR(){const t=this.nl;if(t===null)return;const i=this.desiredSize.isReal();(this.xf||t.complete===!0)&&(t.f0&&(t.Up instanceof Event&&this.os!==null?this.os(this,t.Up):t.mn===!0&&!t.Up&&this.rl!==null&&t.K2&&this.rl(this,t.K2)),t.mn=!0),t.mn&&i&&this.diagram!==null&&this.diagram.Xu.add(this)}Fv(){if(this.nl===null){this.yf=!1;return}const t=new CanvasSurface(null).ai;try{t.drawImage(this.nl,0,0)}catch{this.Ip=!1}try{t.getImageData(0,0,1,1).data[3]&&(this.yf=!1),this.yf=!1}catch{this.yf=!0}}get source(){return this.yt}set source(t){const i=this.yt;if(i!==t){this.ss(!0),Util.i(t,"string",Picture,"source"),this.yt=t;let e=Picture.Ep;if(!Diagram.isUsingDOM()){this.t("source",i,t);return}let s=null;if(e[t]!==void 0)s=e[t];else if(t!==""){Picture.i1>30&&(Picture.clearCache(),e=Picture.Ep),s=Util.en("img"),s.f0=!0,Picture.IL(this,s);const n=this.wf;n!==null&&(s.crossOrigin=n(this)),s.src=t,e[t]=s,Picture.i1++}this.element=s,s!==null&&s.__goCache===void 0&&(s.__goCache=new PictureCacheArray),this.c(),this.C(),this.t("source",i,t)}}static Tv(t,i){t.mn=!0,t.Up=!1;let e;const s=t.es.copy();if(s==null)return;const n=s.iterator;for(;n.next();){const o=n.value;o.C();const r=t.getAttribute("src")||"",l=o.Jl.get(r);if(l===null)continue;const h=l.length;for(let a=0;a=o.width&&(r=r+p.offsetX+(d*p.x-o.width*p.x)),m>=o.height&&(l=l+p.offsetY+(m*p.y-o.height*p.y)),a=Math.min(o.width,d),c=Math.min(o.height,m);break;case 2:d=o.width,m=o.height;break;case 6:case 7:let A=0;g===6?(A=Math.min(o.height/m,o.width/d),d*=A,m*=A):g===7&&(A=Math.max(o.height/m,o.width/d),d*=A,m*=A,d>=o.width&&(r=(r+p.offsetX+(d*p.x-o.width*p.x)/d)*a),m>=o.height&&(l=(l+p.offsetY+(m*p.y-o.height*p.y)/m)*c),a*=1/(d/o.width),c*=1/(m/o.height),d=o.width,m=o.height);break}const y=a*c,x=this.getDocumentScale()*i.scale,k=d*x,b=m*x,P=k*b,M=y/P,L=e.__goCache;let C=null;const S=Picture.Rv;if(!n){if(e.mn&&L!==void 0&&P>4&&M>S*S){L.Ot===null&&(L.UA(4,f,u,e),L.UA(16,f,u,e));const A=L.Ot,D=A.length;for(let F=0;F0){const c=this.Ot[this.Ot.length-1];h=c.yt,a=c.Cd}o.setTransform(r*a,0,0,r*a,0,0),o.commitTransform(),o.drawImage(h,0,0),this.Ot.push(l)}}class PictureCacheInstance{yt;Cd;constructor(t,i){this.yt=t,this.Cd=i}}class GeoStream{Pi;qg;constructor(){this.qg=new Geometry,this.Pi=null}Ri(t){t!==null?(t.rt(),this.qg=t,t.figures.clear()):this.qg=new Geometry,this.Pi=null}uu(t,i,e,s,n,o){if(s!==void 0&&s===!0){const r=new PathSegment(1);r.endX=t,r.endY=i,this.Pi.segments.add(r)}else this.Pi=new PathFigure,this.Pi.startX=t,this.Pi.startY=i,this.Pi.isFilled=e,this.Pi.isEvenOdd=o||!1,this.qg.figures.add(this.Pi);n!==void 0&&(this.Pi.isShadowed=n)}VD(){const t=this.Pi.segments.length;t>0&&this.Pi.segments.elt(t-1).close()}zD(){this.Pi.segments.length>0&&(this.Pi.isFilled=!0)}XD(t){this.Pi.isShadowed=t}mE(t){this.Pi.isEvenOdd=t}ED(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(1);s.endX=t,s.endY=i,e&&s.close(),this.Pi.segments.add(s)}ur(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(2);s.endX=t,s.endY=i,e&&s.close(),this.Pi.segments.add(s)}dr(t,i,e,s,n,o,r){r===void 0&&(r=!1);const l=new PathSegment(3);l.point1X=t,l.point1Y=i,l.point2X=e,l.point2Y=s,l.endX=n,l.endY=o,r&&l.close(),this.Pi.segments.add(l)}Sw(t,i,e,s,n){n===void 0&&(n=!1);const o=new PathSegment(4);o.point1X=t,o.point1Y=i,o.endX=e,o.endY=s,n&&o.close(),this.Pi.segments.add(o)}UD(t,i,e,s,n,o,r){o===void 0&&(o=0),r===void 0&&(r=!1);const l=new PathSegment(5);l.startAngle=t,l.sweepAngle=i,l.centerX=e,l.centerY=s,l.radiusX=n,o!==0?l.radiusY=o:l.radiusY=n,r&&l.close(),this.Pi.segments.add(l)}BD(t,i,e,s,n,o,r,l){l===void 0&&(l=!1);const h=new PathSegment(6,o,r,t,i,e,s,n);l&&h.close(),this.Pi.segments.add(h)}static Y2=null;static yC(t){const i=GeoStream.Y2;if(i!==null)return GeoStream.Y2=null,i.Ri(t),i;{const e=new GeoStream;return e.Ri(t),e}}static wC(t){GeoStream.Y2=t}}{const w=function(n,o){const r=n.toLowerCase(),l=Geo.Mo;l[n]=o,l[r]=n};w("Rectangle",(n,o,r)=>{const l="r"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,Geo.fr{const l="s"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,h.defaultStretch=6,Geo.fr{(isNaN(l)||l<0)&&(l=5),isNaN(h)&&(h=15);const a="rr"+o+","+r+","+l+","+h;let c=Geo.cr[a];if(c!==void 0)return c;let f=l;(h&1)===1?(f=Math.min(f,(h&2)===2?o/3:o),f=Math.min(f,(h&8)===8?r/3:r)):f=0;const u=new PathFigure(f,0,!0);c=new Geometry().add(u);const d=Spot.TopLeft.copy(),m=Spot.BottomRight.copy();if((h&2)===2){let g=l;g=Math.min(g,(h&1)===1?o/3:o),g=Math.min(g,(h&4)===4?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,o-g,0)).add(new PathSegment(3,o,g,o-p,0,o,p)),d.offsetY=p,m.offsetX=-p}else u.add(new PathSegment(2,o,0));if((h&4)===4){let g=l;g=Math.min(g,(h&8)===8?o/3:o),g=Math.min(g,(h&2)===2?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,o,r-g)).add(new PathSegment(3,o-g,r,o,r-p,o-p,r)),m.offsetX=-p,m.offsetY=-p}else u.add(new PathSegment(2,o,r));if((h&8)===8){let g=l;g=Math.min(g,(h&4)===4?o/3:o),g=Math.min(g,(h&1)===1?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,g,r)).add(new PathSegment(3,0,r-g,p,r,0,r-p)),d.offsetX=p,m.offsetY=-p}else u.add(new PathSegment(2,0,r));if((h&1)===1){const g=f*Geo.Un;u.add(new PathSegment(2,0,f)).add(new PathSegment(3,f,0,0,g,g,0).close()),d.offsetX=g,d.offsetY=g}else u.add(new PathSegment(2,0,0).close());return c.spot1=d,c.spot2=m,Geo.fr{const l=n?n.parameter1:NaN,h=n?n.parameter2:NaN;return t(n,o,r,l,h)}),w("Border","RoundedRectangle"),w("RoundedTopRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,3)}),w("RoundedBottomRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,12)}),w("RoundedLeftRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,9)}),w("RoundedRightRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,6)}),w("Ellipse",(n,o,r)=>{const l="e"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Rk,h.spot2=Spot.vk,Geo.fr{const l="c"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Rk,h.spot2=Spot.vk,h.defaultStretch=6,Geo.frnew Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,.5*r)).add(new PathSegment(2,0,r).close())).setSpots(0,.25,.5,.75)),w("TriangleDown",(n,o,r)=>new Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,0)).add(new PathSegment(2,.5*o,r).close())).setSpots(.25,0,.75,.5)),w("TriangleLeft",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,o,0).close())).setSpots(.5,.25,1,.75)),w("TriangleUp",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,r)).add(new PathSegment(2,.5*o,0).close())).setSpots(.25,.5,.75,1)),w("Triangle","TriangleUp"),w("Diamond",(n,o,r)=>new Geometry().add(new PathFigure(.5*o,0).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,.5*o,r)).add(new PathSegment(2,o,.5*r).close())).setSpots(.25,.25,.75,.75)),w("LineH",(n,o,r)=>{const l=new Geometry(1);return l.startX=0,l.startY=r/2,l.endX=o,l.endY=r/2,l}),w("LineV",(n,o,r)=>{const l=new Geometry(1);return l.startX=o/2,l.startY=0,l.endX=o/2,l.endY=r,l}),w("None","Rectangle"),w("BarH","Rectangle"),w("BarV","Rectangle"),w("MinusLine","LineH"),w("PlusLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r/2,!1).add(new PathSegment(2,o,r/2)).add(new PathSegment(1,o/2,0)).add(new PathSegment(2,o/2,r)))),w("XLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r,!1).add(new PathSegment(2,o,0)).add(new PathSegment(1,0,0)).add(new PathSegment(2,o,r)))),w("LineRight",(n,o,r)=>new Geometry().add(new PathFigure(.25*o,0,!1).add(new PathSegment(2,.75*o,.5*r)).add(new PathSegment(2,.25*o,r)))),w("LineDown",(n,o,r)=>new Geometry().add(new PathFigure(0,.25*r,!1).add(new PathSegment(2,.5*o,.75*r)).add(new PathSegment(2,o,.25*r)))),w("LineLeft",(n,o,r)=>new Geometry().add(new PathFigure(.75*o,0,!1).add(new PathSegment(2,.25*o,.5*r)).add(new PathSegment(2,.75*o,r)))),w("LineUp",(n,o,r)=>new Geometry().add(new PathFigure(0,.75*r,!1).add(new PathSegment(2,.5*o,.25*r)).add(new PathSegment(2,o,.75*r)))),w("Capsule",(n,o,r)=>{const l=new Geometry;if(or){const h=new PathFigure(r/2,0,!0);return l.add(h),h.add(new PathSegment(2,o-r/2,0)),h.add(new PathSegment(5,270,180,o-r/2,r/2,r/2,r/2)),h.add(new PathSegment(2,r/2,r)),h.add(new PathSegment(5,90,180,r/2,r/2,r/2,r/2)),l.spot1=new Spot(0,.156,r*.156,0),l.spot2=new Spot(1,.844,-r*.156,0),l}else return l.type=3,l.endX=o,l.endY=r,l.spot1=Spot.Rk,l.spot2=Spot.vk,l});const i=(n,o)=>new PathFigure(n,o,!1,!1),e=(n,o,r)=>n.add(new PathSegment(2,o,r)),s=(n,o,r)=>n.add(new PathSegment(1,o,r));w("Borders",(n,o,r)=>{let l=n?n.parameter1:NaN;isNaN(l)?l=10:l=l&15;const h=new Geometry;let a;return l===10?(a=i(o,0),e(a,o,r),s(a,0,r),e(a,0,0)):l===5?(a=i(0,0),e(a,o,0),s(a,o,r),e(a,0,r)):l===1?(a=i(0,0),e(a,o,0),s(a,o,r)):l===2?(a=i(o,0),e(a,o,r)):l===4?(a=i(o,r),e(a,0,r)):l===8?(a=i(0,r),e(a,0,0),s(a,o,r)):l===3?(a=i(0,0),e(a,o,0),e(a,o,r)):l===6?(a=i(o,0),e(a,o,r),e(a,0,r)):l===12?(a=i(o,r),e(a,0,r),e(a,0,0)):l===9?(a=i(0,r),e(a,0,0),e(a,o,0)):l===7?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r)):l===14?(a=i(o,0),e(a,o,r),e(a,0,r),e(a,0,0)):l===13?(a=i(o,r),e(a,0,r),e(a,0,0),e(a,o,0)):l===11?(a=i(0,r),e(a,0,0),e(a,o,0),e(a,o,r)):l===15?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r),a.add(new PathSegment(2,0,0).close())):(a=i(0,0),s(a,o,r)),h.add(a),h})}Geo.Kg={"":"",Standard:"F1 m 0,0 l 8,4 -8,4 2,-4 z",Backward:"F1 m 8,0 l -2,4 2,4 -8,-4 z",Triangle:"F1 m 0,0 l 8,4.62 -8,4.62 z",BackwardTriangle:"F1 m 8,4 l 0,4 -8,-4 8,-4 0,4 z",Boomerang:"F1 m 0,0 l 8,4 -8,4 4,-4 -4,-4 z",BackwardBoomerang:"F1 m 8,0 l -8,4 8,4 -4,-4 4,-4 z",SidewaysV:"m 0,0 l 8,4 -8,4 0,-1 6,-3 -6,-3 0,-1 z",BackwardV:"m 8,0 l -8,4 8,4 0,-1 -6,-3 6,-3 0,-1 z",OpenTriangle:"m 0,0 l 8,4 -8,4",BackwardOpenTriangle:"m 8,0 l -8,4 8,4",OpenTriangleLine:"m 0,0 l 8,4 -8,4 m 8.5,0 l 0,-8",BackwardOpenTriangleLine:"m 8,0 l -8,4 8,4 m -8.5,0 l 0,-8",OpenTriangleTop:"m 0,0 l 8,4 m 0,4",BackwardOpenTriangleTop:"m 8,0 l -8,4 m 0,4",OpenTriangleBottom:"m 0,8 l 8,-4",BackwardOpenTriangleBottom:"m 0,4 l 8,4",HalfTriangleTop:"F1 m 0,0 l 0,4 8,0 z m 0,8",BackwardHalfTriangleTop:"F1 m 8,0 l 0,4 -8,0 z m 0,8",HalfTriangleBottom:"F1 m 0,4 l 0,4 8,-4 z",BackwardHalfTriangleBottom:"F1 m 8,4 l 0,4 -8,-4 z",ForwardSemiCircle:"m 4,0 b 270 180 0 4 4",BackwardSemiCircle:"m 4,8 b 90 180 0 -4 4",Feather:"m 0,0 l 3,4 -3,4",BackwardFeather:"m 3,0 l -3,4 3,4",DoubleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardDoubleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4",TripleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardTripleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4 m 3,-8 l -3,4 3,4",ForwardSlash:"m 0,8 l 5,-8",BackSlash:"m 0,0 l 5,8",DoubleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8",DoubleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8",TripleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8 m -2,8 l 4,-8",TripleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8 m -2,-8 l 4,8",Fork:"m 0,4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4",LineFork:"m 0,0 l 0,8 m 0,-4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardLineFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4 m 8,-8 l 0,8",CircleFork:"F1 m 6,4 b 0 360 -3 0 3 z m 0,0 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 6,0 b 0 360 -3 0 3",CircleLineFork:"F1 m 6,4 b 0 360 -3 0 3 z m 1,-4 l 0,8 m 0,-4 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleLineFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 0,-4 l 0,8 m 7,-4 b 0 360 -3 0 3",Circle:"F1 m 8,4 b 0 360 -4 0 4 z",Block:"F1 m 0,0 l 0,8 8,0 0,-8 z",StretchedDiamond:"F1 m 0,3 l 5,-3 5,3 -5,3 -5,-3 z",Diamond:"F1 m 0,4 l 4,-4 4,4 -4,4 -4,-4 z",Chevron:"F1 m 0,0 l 5,0 3,4 -3,4 -5,0 3,-4 -3,-4 z",StretchedChevron:"F1 m 0,0 l 8,0 3,4 -3,4 -8,0 3,-4 -3,-4 z",NormalArrow:"F1 m 0,2 l 4,0 0,-2 4,4 -4,4 0,-2 -4,0 z",X:"m 0,0 l 8,8 m 0,-8 l -8,8",TailedNormalArrow:"F1 m 0,0 l 2,0 1,2 3,0 0,-2 2,4 -2,4 0,-2 -3,0 -1,2 -2,0 1,-4 -1,-4 z",DoubleTriangle:"F1 m 0,0 l 4,4 -4,4 0,-8 z m 4,0 l 4,4 -4,4 0,-8 z",BigEndArrow:"F1 m 0,0 l 5,2 0,-2 3,4 -3,4 0,-2 -5,2 0,-8 z",ConcaveTailArrow:"F1 m 0,2 h 4 v -2 l 4,4 -4,4 v -2 h -4 l 2,-2 -2,-2 z",RoundedTriangle:"F1 m 0,1 a 1,1 0 0 1 1,-1 l 7,3 a 0.5,1 0 0 1 0,2 l -7,3 a 1,1 0 0 1 -1,-1 l 0,-6 z",SimpleArrow:"F1 m 1,2 l -1,-2 2,0 1,2 -1,2 -2,0 1,-2 5,0 0,-2 2,2 -2,2 0,-2 z",AccelerationArrow:"F1 m 0,0 l 0,8 0.2,0 0,-8 -0.2,0 z m 2,0 l 0,8 1,0 0,-8 -1,0 z m 3,0 l 2,0 2,4 -2,4 -2,0 0,-8 z",BoxArrow:"F1 m 0,0 l 4,0 0,2 2,0 0,-2 2,4 -2,4 0,-2 -2,0 0,2 -4,0 0,-8 z",TriangleLine:"F1 m 8,4 l -8,-4 0,8 8,-4 z m 0.5,4 l 0,-8",CircleEndedArrow:"F1 m 10,4 l -2,-3 0,2 -2,0 0,2 2,0 0,2 2,-3 z m -4,0 b 0 360 -3 0 3 z",DynamicWidthArrow:"F1 m 0,3 l 2,0 2,-1 2,-2 2,4 -2,4 -2,-2 -2,-1 -2,0 0,-2 z",EquilibriumArrow:"m 0,3 l 8,0 -3,-3 m 3,5 l -8,0 3,3",FastForward:"F1 m 0,0 l 3.5,4 0,-4 3.5,4 0,-4 1,0 0,8 -1,0 0,-4 -3.5,4 0,-4 -3.5,4 0,-8 z",Kite:"F1 m 0,4 l 2,-4 6,4 -6,4 -2,-4 z",HalfArrowTop:"F1 m 0,0 l 4,4 4,0 -8,-4 z m 0,8",HalfArrowBottom:"F1 m 0,8 l 4,-4 4,0 -8,4 z",OpposingDirectionDoubleArrow:"F1 m 0,4 l 2,-4 0,2 4,0 0,-2 2,4 -2,4 0,-2 -4,0 0,2 -2,-4 z",PartialDoubleTriangle:"F1 m 0,0 4,3 0,-3 4,4 -4,4 0,-3 -4,3 0,-8 z",LineCircle:"F1 m 0,0 l 0,8 m 7 -4 b 0 360 -3 0 3 z",DoubleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",TripleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",CircleLine:"F1 m 6 4 b 0 360 -3 0 3 z m 1,-4 l 0,8",DiamondCircle:"F1 m 8,4 l -4,4 -4,-4 4,-4 4,4 m 8,0 b 0 360 -4 0 4 z",PlusCircle:"F1 m 8,4 b 0 360 -4 0 4 l -8 0 z m -4 -4 l 0 8",OpenRightTriangleTop:"m 8,0 l 0,4 -8,0 m 0,4",OpenRightTriangleBottom:"m 8,8 l 0,-4 -8,0",Line:"m 0,0 l 0,8",DoubleLine:"m 0,0 l 0,8 m 2,0 l 0,-8",TripleLine:"m 0,0 l 0,8 m 2,0 l 0,-8 m 2,0 l 0,8",PentagonArrow:"F1 m 8,4 l -4,-4 -4,0 0,8 4,0 4,-4 z"};var LayoutConditions=(w=>(w[w.None=0]="None",w[w.Added=1]="Added",w[w.Removed=2]="Removed",w[w.Shown=4]="Shown",w[w.Hidden=8]="Hidden",w[w.NodeSized=16]="NodeSized",w[w.GroupLayout=32]="GroupLayout",w[w.NodeReplaced=64]="NodeReplaced",w[w.Standard=127]="Standard",w[w.All=16777215]="All",w))(LayoutConditions||{});class Part extends Panel{P;Ho;F;ll;hl;qo;hi;Wo;mh;js;Jo;Ld;UM;BA;Bp;Vp;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.P=2408959,this.Ho="",this.F=null,this.ll="",this.hl=null,this.qo=null,this.hi="",this.Wo=null,this.mh=null,this.js=new Point(NaN,NaN).g(),this.Jo=null,this.Ld=NaN,this.UM=-1,this.BA=new Rect,this.Bp=null,this.Vp=NaN,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.P=this.P&-4097|16384|32768,t.Ho=this.Ho,this.F!==null&&(this.F.gi?t.F=this.F:t.F=this.F.copy()),t.ll=this.ll,t.qo=null,t.hi=this.hi,t.js.a(this.js),t.Ld=this.Ld}Vo(t){super.Vo(t),t.ah(),t.hl=null,t.Jo=null,t.Bp=null}toString(){let t=Util.sn(this.constructor)+"#"+GSet.as(this);return this.data!==null&&(t+="("+Util.toString(this.data)+")"),t}static LayoutNone=0;static LayoutAdded=1;static LayoutRemoved=2;static LayoutShown=4;static LayoutHidden=8;static LayoutNodeSized=16;static LayoutGroupLayout=32;static LayoutNodeReplaced=64;static LayoutStandard=127;static LayoutAll=16777215;qi(){this.F===null?this.F=new PartTemplateSettings:this.F.gi&&(this.F=this.F.copy())}rh(){super.rh(),this.F!==null&&(this.F.gi=!0)}Wc(t,i,e,s,n,o,r){const l=this.diagram;l!==null&&(t===3&&i==="elements"?n instanceof Panel?n.qr(h=>{l.partManager.MS(h,l)}):n instanceof Picture&&l.TS(n):t===4&&i==="elements"&&(n instanceof Panel?n.qr(h=>l.partManager.SS(h,l)):n instanceof Picture&&l.DS(n)),l.raiseChangedEvent(t,i,e,s,n,o,r))}updateTargetBindings(t){if(super.updateTargetBindings(t),this.data===null)return;const i=this.L.r,e=i.length;for(let n=0;n{r.data!==null&&r.updateTargetBindings()})}const s=this.adornments;for(;s.next();)s.value.updateTargetBindings(t)}Io(){if(super.Io(),this.m2()){const i=this.L.r,e=i.length;for(let s=0;so.Io())}}const t=this.adornments;for(;t.next();)t.value.Io()}updateRelationshipsFromData(){this.data!==null&&this.diagram?.partManager.updateRelationshipsFromData(this)}get key(){const t=this.diagram;if(t!==null)return t.model.getKeyForNodeData(this.data)}get adornments(){return this.qo===null?EmptyIterator.instance:this.qo.iteratorValues}findAdornment(t){const i=this.qo;return i===null?null:i.get(t)}addAdornment(t,i){if(i===null)return;let e=null,s=this.qo;if(s!==null&&(e=s.get(t)),e!==i){if(e!==null){const o=e.diagram;o!==null&&o.remove(e)}s===null&&(s=new GMap,this.qo=s),i.Ho!==t&&(i.category=t),s.set(t,i);const n=this.diagram;if(n!==null){n.add(i);const o=i.adornedObject;if(o!==null){const r=o.findBindingPanel();r!==null&&(i.data=r.data)}}}}removeAdornment(t){const i=this.qo;if(i===null)return;const e=i.get(t);if(e!==null){const s=e.diagram;s!==null&&(s.remove(e),e.data=null)}i.delete(t),i.count===0&&(this.qo=null)}clearAdornments(){const t=this.qo;if(t===null)return;const i=Util.ot(),e=t.iterator;for(;e.next();){const n=e.key;i.push(n)}const s=i.length;for(let n=0;n{e.isEnabled&&e.updateAdornments(i)}),t.toolManager.updateAdornments(i)}IM(t){this.Wo=t,t===null&&this.FR()}get layer(){return this.Wo}get diagram(){const t=this.Wo;return t==null?null:t.diagram}get layerName(){return this.ll}set layerName(t){const i=this.ll;if(i===t)return;Util.i(t,"string",Part,"layerName");let e=this.diagram;if(e!==null&&(e.findLayer(t)===null||e.partManager.addsToTemporaryLayer))return;this.ll=t,e!==null&&e.invalidateDocumentBounds(),this.t("layerName",i,t);const s=this.layer;if(s===null||s.name===t||(e=s.diagram,e===null))return;const n=e.findLayer(t);if(n===null||n===s)return;let o=s._i(-1,this,!0);o>=0&&e.raiseChangedEvent(4,"parts",s,this,null,o,!0),o=n.Hh(99999999,this,!0),s.visible!==n.visible&&this.Ei(n.visible),o>=0&&e.raiseChangedEvent(3,"parts",n,null,this,!0,o);const r=this.layerChanged;if(r===null)return;const l=e.Y;e.Y=!0,r(this,s,n),e.Y=l}get layerChanged(){return this.F!==null?this.F.zp:null}set layerChanged(t){const i=this.layerChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"layerChanged"),this.qi(),this.F.zp=t,this.t("layerChanged",i,t))}get zOrder(){return this.Ld}set zOrder(t){const i=this.Ld;if(i===t)return;Util.i(t,"number",Part,"zOrder"),this.Ld=t;const e=this.layer;e!==null&&e.yx(-1,this),this.t("zOrder",i,t);const s=this.diagram;s!==null&&s.C()}Iv(){const t=this.layer;t!==null&&t.yx(-1,this)}o1(){if(this.th()!==!1)return;this.G2(!0),this.td();const t=this.diagram;t!==null&&(t.r0(this),t.requestUpdate())}XA(){if(this.P|=2097152,this.th()===!1)return;const t=this.position,i=this.location;(!i.isReal()||!t.isReal())&&this.KA(t,i);const e=this.Li,s=Rect.l().a(e);e.rt(),e.x=t.x,e.y=t.y,e.g(),this.ed(s,e),Rect.s(s),this.G2(!1)}Qn(t,i,e,s){const n=this.ee;n.e(t,i,e,s),this.bi===null&&(this.bi=new Transform);const o=this.bi;o.Ri(),this.y0(o,t,i,e,s),this.bi=o,o.Ok()||o.xw(n)}y0(t,i,e,s,n){if(this.st!==1&&t.st(this.st),this.Xt===0)return;let o=Spot.Center;this.locationSpot.isSpot()&&(o=this.locationSpot);const r=Point.l();if(this.locationObject!==this){const l=this.locationObject,h=l.naturalBounds;r.setSpot(h.x,h.y,h.width,h.height,o),l.bi!==null&&l.bi.xt(r),r.offset(-l.measuredBounds.x,-l.measuredBounds.y);let a=l.panel;for(;a!==null&&a!==this;)a.bi!==null&&a.bi.xt(r),r.offset(-a.measuredBounds.x,-a.measuredBounds.y),a=a.panel}else r.setSpot(i,e,s,n,o);t.cs(this.Xt,r.x,r.y),Point.s(r)}get locationObject(){if(this.Jo===null)if(this instanceof Adornment&&this.type!==Panel.Link&&this.hasPlaceholder())this.Jo=this.placeholder;else{const t=this.locationObjectName;if(t!==""){const i=this.findObject(t);i!==null?this.Jo=i:this.Jo=this}else this.Jo=this}return this.Jo.visible?this.Jo:this}get minLocation(){return this.F!==null?this.F.Xp:Point.QN}set minLocation(t){const i=this.minLocation;i.equals(t)||(t=t.N(),this.qi(),this.F.Xp=t,this.t("minLocation",i,t))}get maxLocation(){return this.F!==null?this.F.Kp:Point._N}set maxLocation(t){const i=this.maxLocation;i.equals(t)||(t=t.N(),this.qi(),this.F.Kp=t,this.t("maxLocation",i,t))}get locationObjectName(){return this.F!==null?this.F.Yp:""}set locationObjectName(t){const i=this.locationObjectName;i!==t&&(this.qi(),this.F.Yp=t,this.Jo=null,this.c(),this.t("locationObjectName",i,t))}get locationSpot(){return this.F!==null?this.F.Gp:Spot.TopLeft}set locationSpot(t){const i=this.locationSpot;i.equals(t)||(t=t.N(),this.qi(),this.F.Gp=t,this.c(),this.t("locationSpot",i,t))}move(t,i){i===!0?this.location=t:this.position=t}moveTo(t,i,e){const s=Point.X(t,i);this.move(s,e),Point.s(s)}isVisible(){if(!this.visible)return!1;const t=this.layer;if(t!==null){if(!t.visible)return!1;const e=t.diagram;if(e!==null&&e.animationManager.nx(this))return!0}const i=this.containingGroup;return!(i!==null&&(!i.isSubGraphExpanded||!i.isVisible()))}Ei(t){const i=this.diagram;t?(this.invalidateLayout(4),this.invalidateAdornments(),i!==null&&i.r0(this)):(this.invalidateLayout(8),this.clearAdornments()),this.ah(),i!==null&&(i.invalidateDocumentBounds(),i.C())}findObject(t){if(this.name===t)return this;let i=this.Bp;if(i===null&&(this.Bp=i=new GMap),i.get(t)!==null)return i.get(t);const e=super.findObject(t);return e!==null?(i.set(t,e),e):(i.set(t,null),null)}T0(){this.Bp=null}getRelativePoint(t,i,e){e===void 0&&(e=new Point);const s=i.isNoSpot()?Spot.Center:i,n=t.naturalBounds;if(e.e(n.width*s.x+s.offsetX,n.height*s.y+s.offsetY),t===null||t===this)return e;t.D.xt(e);let o=t.panel;for(;o!==null&&o!==this;)o.D.xt(e),o=o.panel;return this.bi!==null&&this.bi.xt(e),e.offset(-this.ee.x,-this.ee.y),e}getDocumentBounds(t){return t===void 0&&(t=new Rect),t.a(this.actualBounds)}ensureBounds(){this.ut(1/0,1/0),this.zt()}pA(t){const i=this.locationSpot,e=this.locationObject;let s=e.naturalBounds;s.isReal()||(s=Rect.pw);const n=e instanceof Shape?e.strokeWidth:0;if(t.setSpot(0,0,s.width+n,s.height+n,i),e!==this){t.offset(-n/2,-n/2),e.D.xt(t);let o=e.panel;for(;o!==null&&o!==this;)o.D.xt(t),o=o.panel}return this.bi!==null&&this.bi.xt(t),t.offset(-this.ee.x,-this.ee.y),t}jh(t,i){const e=i===void 0?this.BA:i,s=this.Ev(),n=s*2;if(!this.isShadowed)return e.e(t.x-1-s,t.y-1-s,t.width+2+n,t.height+2+n),e;let o=t.x,r=t.y,l=t.width,h=t.height;const a=this.shadowBlur,c=this.shadowOffset;return l+=a,h+=a,o-=a/2,r-=a/2,c.x>0?l+=c.x:(o+=c.x,l-=c.x),c.y>0?h+=c.y:(r+=c.y,h-=c.y),e.e(o-1,r-1,l+2,h+2),e}wv(){return this.type===Panel.Link&&this instanceof Adornment&&this.category==="Selection"&&this.adornedObject instanceof Shape&&this.adornedPart.findMainElement()===this.adornedObject?this.adornedObject.strokeWidth:0}Ev(){return isNaN(this.Vp)&&(this.Vp=this.MA()),this.Vp}af(){this.Vp=NaN}zt(){if(this.is()===!1){this.XA();return}this._n(!1);const t=this.Li,i=Rect.l();i.a(t);const e=this.Nl();this.hh(0,0,this.ee.width,this.ee.height);const s=this.position;this.KA(s,this.location),t.rt(),t.x=s.x,t.y=s.y,t.g(),this.ed(i,t),i.equals(t)?this.Us(e):this.Pe()&&(!Geo.u(i.width,t.width)||!Geo.u(i.height,t.height))&&this.UM>=0&&this.invalidateLayout(16),Rect.s(i),this.G2(!1)}ed(t,i){const e=this.diagram;if(e===null)return;let s=!1;if(e.$h===!1&&t.isReal()){const n=Rect.l();n.a(e.documentBounds),n.subtractMargin(e.padding),t.x>n.x&&t.y>n.y&&t.rightn.x&&i.y>n.y&&i.right=o)return}}this.P=this.P^4096;let s=!1;if(e!==null){s=e.skipsUndoManager,e.skipsUndoManager=!0;const o=e.selection;o.rt(),t?o.add(this):o.delete(this),o.g()}this.t("isSelected",i,t),this.invalidateAdornments();const n=this.selectionChanged;n!==null&&n(this),e!==null&&(e.requestUpdate(),e.skipsUndoManager=s)}}get isHighlighted(){return(this.P&524288)!==0}set isHighlighted(t){const i=(this.P&524288)!==0;if(i!==t){this.P=this.P^524288;const e=this.diagram;if(e!==null){const n=e.highlighteds;n.rt(),t?n.add(this):n.delete(this),n.g()}this.t("isHighlighted",i,t),this.C();const s=this.highlightedChanged;s!==null&&s(this)}}get isShadowed(){return(this.P&8192)!==0}set isShadowed(t){const i=(this.P&8192)!==0;i!==t&&(this.P=this.P^8192,this.ss(!0),this.t("isShadowed",i,t),this.C())}VA(){return(this.P&16384)!==0}zA(t){t?this.P|=16384:this.P&=-16385}th(){return(this.P&32768)!==0}G2(t){t?this.P|=32768:this.P&=-32769}Uv(){return(this.P&65536)!==0}o2(t){t?this.P|=65536:this.P&=-65537}Nl(){return(this.P&131072)!==0}Us(t){t?this.P|=131072:this.P&=-131073}qA(){return(this.P&1048576)!==0}l1(t){t?this.P|=1048576:this.P&=-1048577}get isAnimated(){return(this.P&262144)!==0}set isAnimated(t){const i=(this.P&262144)!==0;i!==t&&(this.P=this.P^262144,this.t("isAnimated",i,t))}get highlightedChanged(){return this.F!==null?this.F.jp:null}set highlightedChanged(t){const i=this.highlightedChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"highlightedChanged"),this.qi(),this.F.jp=t,this.t("highlightedChanged",i,t))}get selectionObjectName(){return this.F!==null?this.F.Hp:""}set selectionObjectName(t){const i=this.selectionObjectName;i!==t&&(this.qi(),this.F.Hp=t,this.hl=null,this.t("selectionObjectName",i,t))}get selectionAdornmentTemplate(){return this.F!==null?this.F.qp:null}set selectionAdornmentTemplate(t){const i=this.selectionAdornmentTemplate;i!==t&&(this.qi(),this.F.qp=t,this.t("selectionAdornmentTemplate",i,t))}get selectionObject(){if(this.hl===null){const t=this.selectionObjectName;if(t!==null&&t!==""){const i=this.findObject(t);i!==null?this.hl=i:this.hl=this}else if(this instanceof Link){const i=this.path;i!==null?this.hl=i:this.hl=this}else this.hl=this}return this.hl}get selectionChanged(){return this.F!==null?this.F.Wp:null}set selectionChanged(t){const i=this.selectionChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"selectionChanged"),this.qi(),this.F.Wp=t,this.t("selectionChanged",i,t))}get resizeAdornmentTemplate(){return this.F!==null?this.F.Jp:null}set resizeAdornmentTemplate(t){const i=this.resizeAdornmentTemplate;i!==t&&(this.qi(),this.F.Jp=t,this.t("resizeAdornmentTemplate",i,t))}get resizeObjectName(){return this.F!==null?this.F.$p:""}set resizeObjectName(t){const i=this.resizeObjectName;i!==t&&(this.qi(),this.F.$p=t,this.t("resizeObjectName",i,t))}get resizeObject(){const t=this.resizeObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get resizeCellSize(){return this.F!==null?this.F.Zp:Size.gw}set resizeCellSize(t){const i=this.resizeCellSize;i.equals(t)||(t=t.N(),this.qi(),this.F.Zp=t,this.t("resizeCellSize",i,t))}get rotateAdornmentTemplate(){return this.F!==null?this.F.Qp:null}set rotateAdornmentTemplate(t){const i=this.rotateAdornmentTemplate;i!==t&&(this.qi(),this.F.Qp=t,this.t("rotateAdornmentTemplate",i,t))}get rotateObjectName(){return this.F!==null?this.F._p:""}set rotateObjectName(t){const i=this.rotateObjectName;i!==t&&(this.qi(),this.F._p=t,this.t("rotateObjectName",i,t))}get rotateObject(){const t=this.rotateObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get rotationSpot(){return this.F!==null?this.F.ty:Spot.Default}set rotationSpot(t){const i=this.rotationSpot;i.equals(t)||(t=t.N(),this.qi(),this.F.ty=t,this.t("rotationSpot",i,t))}get text(){return this.hi}set text(t){const i=this.hi;i!==t&&(this.hi=t,this.t("text",i,t))}get containingGroup(){return this.mh}set containingGroup(t){if(this.Pe()){const i=this.mh;if(i!==t){t!==null&&(this===t||t.isMemberOf(this))&&(this===t&&Util.o("Cannot make a Group a member of itself: "+this.toString()),Util.o("Cannot make a Group indirectly contain itself: "+this.toString()+" already contains "+t.toString())),this.invalidateLayout(2);const e=this.diagram;if(i!==null?i.H2(this):this instanceof Group&&e!==null&&e.Yr.delete(this),this.mh=t,t!==null?t.q2(this):this instanceof Group&&e!==null&&e.Yr.add(this),this.invalidateLayout(1),e!==null&&e.Y){const n=this.data,o=e.model;if(n!==null&&o.Hc()){const r=t!==null?t.data:null;o.setGroupForData(n,o.getKeyForNodeData(r))}}const s=this.containingGroupChanged;if(s!==null){let n=!0;e!==null&&(n=e.Y,e.Y=!0),s(this,i,t),e!==null&&(e.Y=n)}if(this instanceof Group){const n=new GSet;Part.sh(n,this,!0,0,!0);const o=n.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=r.linksConnected;for(;l.next();)l.value.Ad()}}}if(this instanceof Node){const n=this.linksConnected;for(;n.next();)n.value.Ad();const o=this.labeledLink;o!==null&&o.Ad()}this.t("containingGroup",i,t),t!==null&&t.Iv()}}else Util.o("cannot set the Part.containingGroup of a Link or Adornment")}ah(){const t=this.containingGroup;t!==null&&(t.hasPlaceholder()&&t.placeholder.c(),t.c(),t.invalidateConnectedLinks())}C(){const t=this.diagram;t!==null&&!this.is()&&!this.th()&&this.isVisible()&&this.Li.isReal()&&t.C(this.jh(this.Li))}c(){if(this.Oo())return;super.c();const t=this.diagram;t!==null&&(t.r0(this),this instanceof Node&&this.labeledLink!==null&&this.labeledLink.tf(),t.requestUpdate(!0))}tf(t){if(this.is())return;const i=this.diagram;i!==null&&(i.r0(this),this instanceof Node&&this.invalidateConnectedLinks(),i.requestUpdate()),this._n(!0)}Um(t){if(!t){const i=this.mh;i!==null&&i.q2(this)}}Bm(t){if(!t){const i=this.mh;i!==null&&i.H2(this)}}Xc(){const t=this.data;if(t!==null){const i=this.diagram;if(i!==null){const e=i.model;e!==null&&e.removeNodeData(t)}}}get containingGroupChanged(){return this.F!==null?this.F.iy:null}set containingGroupChanged(t){const i=this.containingGroupChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"containingGroupChanged"),this.qi(),this.F.iy=t,this.t("containingGroupChanged",i,t))}findSubGraphLevel(){return this.W2(this)}W2(t){const i=t.containingGroup;if(i!==null)return 1+this.W2(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.W2(e)}return 0}findTopLevelPart(){return this.J2(this)}J2(t){const i=t.containingGroup;if(i!==null)return this.J2(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.J2(e)}return t}get isTopLevel(){return!(this.containingGroup!==null||this instanceof Node&&this.labeledLink!==null)}isMemberOf(t){return t instanceof Group?this.$2(this,t):!1}$2(t,i){if(t===i||i===null)return!1;const e=t.containingGroup;if(e!==null&&(e===i||this.$2(e,i)))return!0;if(t instanceof Node){const s=t.labeledLink;if(s!==null)return this.$2(s,i)}return!1}findCommonContainingGroup(t){if(t===null)return null;if(this===t)return this.containingGroup;let i=this;for(;i!==null;){if(i instanceof Group&&i.l1(!0),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}let e=null;for(i=t;i!==null;){if(i.qA()){e=i;break}if(i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}for(i=this;i!==null;){if(i instanceof Group&&i.l1(!1),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}return e}get layoutConditions(){return this.F!==null?this.F.ey:127}set layoutConditions(t){const i=this.layoutConditions;i!==t&&(this.qi(),this.F.ey=t,this.t("layoutConditions",i,t))}canLayout(){if(!this.isLayoutPositioned||!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary||this instanceof Node&&this.isLinkLabel)}Vv(t){if(!this.isLayoutPositioned||!(t&this.layoutConditions))return!1;const i=this.layer;if(i!==null&&i.isTemporary||this instanceof Node&&this.isLinkLabel)return!1;const e=this.diagram;return!(e!==null&&e.undoManager.isUndoingRedoing)}invalidateLayout(t){if(t===void 0&&(t=16777215),!this.Vv(t))return;const i=this.mh;if(i!==null){const e=i.layout;e!==null?e.invalidateLayout():i.invalidateLayout(t)}else{const e=this.diagram;if(e!==null){const s=e.layout;s!==null&&s.invalidateLayout()}}}CL(){if(!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary)}static sh(t,i,e,s,n,o){if(o===void 0&&(o=null),!t.has(i)&&!(o!==null&&!o(i))&&!(i instanceof Adornment)){if(t.add(i),i instanceof Node){if(e&&i instanceof Group){const r=i.memberParts;for(;r.next();){const l=r.value;Part.sh(t,l,e,s,n,o)}}if(n!==!1){const r=i.linksConnected;for(;r.next();){const l=r.value;if(t.has(l))continue;const h=l.fromNode,a=l.toNode,c=h===null||t.has(h),f=a===null||t.has(a);(n?c&&f:c||f)&&Part.sh(t,l,e,s,n,o)}}if(s>1){const r=i.findTreeChildrenNodes();for(;r.next();){const l=r.value;Part.sh(t,l,e,s-1,n,o)}}}else if(i instanceof Link){const r=i.labelNodes;for(;r.next();){const l=r.value;Part.sh(t,l,e,s,n,o)}}}}get dragComputation(){return this.F!==null?this.F.sy:null}set dragComputation(t){const i=this.dragComputation;i!==t&&(t!==null&&Util.i(t,"function",Part,"dragComputation"),this.qi(),this.F.sy=t,this.t("dragComputation",i,t))}get shadowOffset(){return this.F!==null?this.F.ny:Point.tC}set shadowOffset(t){const i=this.shadowOffset;i.equals(t)||(t=t.N(),this.qi(),this.F.ny=t,this.C(),this.t("shadowOffset",i,t))}get shadowColor(){return this.F!==null?this.F.oy:"gray"}set shadowColor(t){const i=this.shadowColor;i!==t&&(this.qi(),this.F.oy=t,this.C(),this.t("shadowColor",i,t))}get shadowBlur(){return this.F!==null?this.F.xn:4}set shadowBlur(t){const i=this.shadowBlur;i!==t&&(this.qi(),this.F.xn=t,this.C(),this.t("shadowBlur",i,t))}}class PartTemplateSettings{gi;zp;iy;qp;Hp;Wp;jp;Jp;$p;Zp;Qp;_p;ty;Yp;Gp;Xp;Kp;sy;ey;ny;oy;xn;constructor(){this.gi=!1,this.zp=null,this.iy=null,this.qp=null,this.Hp="",this.Wp=null,this.jp=null,this.Jp=null,this.$p="",this.Zp=Size.gw,this.Qp=null,this._p="",this.ty=Spot.Default,this.Yp="",this.Gp=Spot.TopLeft,this.Xp=Point.QN,this.Kp=Point._N,this.sy=null,this.ey=127,this.ny=Point.tC,this.oy="gray",this.xn=4}copy(){const t=new PartTemplateSettings;return t.zp=this.zp,t.iy=this.iy,t.qp=this.qp,t.Hp=this.Hp,t.Wp=this.Wp,t.jp=this.jp,t.Jp=this.Jp,t.$p=this.$p,t.Zp=this.Zp.N(),t.Qp=this.Qp,t._p=this._p,t.ty=this.ty.N(),t.Yp=this.Yp,t.Gp=this.Gp.N(),t.Xp=this.Xp.N(),t.Kp=this.Kp.N(),t.sy=this.sy,t.ey=this.ey,t.ny=this.ny.N(),t.oy=this.oy,t.xn=this.xn,t}}class Adornment extends Part{us;It;JP;$P;lf;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.P&=-257,this.ll="Adornment",this.us=null,this.JP=0,this.$P=!1,this.It=null,this.lf=null,i&&Object.assign(this,i)}toString(){const t=this.adornedPart;return"Adornment("+this.category+")"+(t!==null?t.toString():"")}updateRelationshipsFromData(){}ad(t){const i=this.adornedObject,e=i?.part;if(!(e instanceof Link)||!(i instanceof Shape))return;const s=e.path;let n=s.geometry;e.ad(t),n=s.geometry;const o=this.L.r,r=o.length;for(let l=0;lh instanceof Placeholder);l instanceof Placeholder&&this.It===null&&(this.It=l)}}else t===4&&i==="elements"&&this.It!==null&&(s===this.It?this.It=null:s instanceof Panel&&this.It.isContainedBy(s)&&(this.It=null));super.Wc(t,i,e,s,n,o,r)}updateAdornments(){}Xc(){}}var PortSpreading=(w=>(w[w.None=0]="None",w[w.Evenly=1]="Evenly",w[w.Packed=2]="Packed",w))(PortSpreading||{});class Node extends Part{E;gt;bf;al;ph;se;_t;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.E=13,this.gt=null,this._t=new List,this.bf=null,this.al=null,this.se=null,this.ph=!1,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.E=this.E,this.gt!==null&&(this.gt.gi?t.gt=this.gt:t.gt=this.gt.copy())}Vo(t){super.Vo(t),t.invalidateConnectedLinks(),t.al=this.al,t.se=null}static SpreadingNone=0;static SpreadingEvenly=1;static SpreadingPacked=2;cl(){this.gt===null?this.gt=new NodeTemplateSettings:this.gt.gi&&(this.gt=this.gt.copy())}rh(){super.rh(),this.gt!==null&&(this.gt.gi=!0)}WA(t){t!==null&&(this.al===null&&(this.al=new GSet),this.al.add(t))}JA(t){t!==null&&this.al!==null&&this.al.delete(t)}$A(t,i,e){if(t===null||this.al===null)return null;const s=this.al.iterator;for(;s.next();){const n=s.value;if(n.ry===this&&n.h1===t&&n.Z2===i&&n.Q2===e||n.ry===t&&n.h1===this&&n.Z2===e&&n.Q2===i)return n}return null}invalidateLinkBundle(t,i,e){i==null&&(i=""),e==null&&(e="");const s=this.$A(t,i,e);s!==null&&s.Td()}Wc(t,i,e,s,n,o,r){t===3&&i==="elements"?this.se=null:t===4&&i==="elements"&&(this.se=null),super.Wc(t,i,e,s,n,o,r)}invalidateConnectedLinks(t){const i=this.linksConnected;for(;i.next();){const e=i.value;t!==void 0&&t.has(e)||(this.ge(e.fromPort),this.ge(e.toPort),e.invalidateRoute())}}iA(t){const i=this.linksConnected;for(;i.next();){const e=i.value;e.fromPort!==t&&e.toPort!==t||(this.ge(e.fromPort),this.ge(e.toPort),e.invalidateRoute())}}ge(t){if(t===null)return;const i=t.$u;i!==null&&i.Td();const e=t.part,s=e.containingGroup;s!==null&&!e.isVisible()&&s.ge(s.port)}Hr(){return!0}get portSpreading(){return this.gt!==null?this.gt.ly:1}set portSpreading(t){const i=this.portSpreading;if(i!==t){this.cl(),this.gt.ly=t,this.t("portSpreading",i,t);const e=this.diagram;if(e!==null&&e.undoManager.isUndoingRedoing)return;this.invalidateConnectedLinks()}}get avoidable(){return(this.E&8)!==0}set avoidable(t){const i=(this.E&8)!==0;if(i!==t){this.E=this.E^8;const e=this.diagram;e!==null&&e.ES(this),this.t("avoidable",i,t)}}get avoidableMargin(){return this.gt!==null?this.gt.hy:Margin.lC}set avoidableMargin(t){typeof t=="number"&&(t=new Margin(t));const i=this.avoidableMargin;if(!i.equals(t)){t=t.N(),this.cl(),this.gt.hy=t;const e=this.diagram;e!==null&&e.ES(this),this.t("avoidableMargin",i,t)}}canAvoid(){return this.avoidable&&!this.isLinkLabel}getAvoidableRect(t){return t.set(this.actualBounds),t.addMargin(this.avoidableMargin),t}findVisibleNode(){let t=this;for(;t!==null&&!t.isVisible();)t=t.containingGroup;return t}isVisible(){if(!super.isVisible())return!1;let t=!0,i=1;const e=this.diagram;if(e!==null){if(e.animationManager.nx(this))return!0;t=e.isTreePathToChildren,i=e.treeCollapsePolicy}if(i===1){const n=this.findTreeParentNode();if(n!==null&&!n.isTreeExpanded)return!1}else if(i===2){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&h.isTreeExpanded){r=!0;break}}}if(o&&!r)return!1}else if(i===3){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&!h.isTreeExpanded){r=!0;break}}}if(o&&r)return!1}const s=this.labeledLink;return s!==null?s.isVisible():!0}Ei(t){super.Ei(t);const i=this.linksConnected;for(;i.next();){const e=i.value;if(t&&this.containingGroup!==null){const s=e.getOtherNode(this);s!==null&&!s.isMemberOf(this.containingGroup)&&e.invalidateRoute()}e.Ei(t)}}get linksConnected(){return this._t.iterator}findExternalTreeLinksConnected(){const t=new GSet,i=new GSet;return this.ZA(this,t,i),i.iterator}ZA(t,i,e){if(t===null||i.has(t))return;i.add(t);let s=!0;const n=this.diagram;n!==null&&(s=n.isTreePathToChildren),t.linksConnected.each(o=>{o.isTreeLink?(s?o.fromNode===t:o.toNode===t)&&this.ZA(s?o.toNode:o.fromNode,i,e):e.add(o)})}findLinksConnected(t){if(t===void 0&&(t=null),t===null)return this._t.iterator;const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.fromNode===e&&s.fromPortId===t||s.toNode===e&&s.toPortId===t,i}findLinksOutOf(t){t===void 0&&(t=null);const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.fromNode!==e?!1:t===null?!0:s.fromPortId===t,i}findLinksInto(t){t===void 0&&(t=null);const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.toNode!==e?!1:t===null?!0:s.toPortId===t,i}findNodesConnected(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this){if(t===null||n.fromPortId===t){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}else if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesOutOf(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this&&(t===null||n.fromPortId===t)){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesInto(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findLinksBetween(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null);const s=new ListIterator(this._t),n=this;return s.predicate=o=>o.fromNode===n&&o.toNode===t&&(i===null||o.fromPortId===i)&&(e===null||o.toPortId===e)||o.fromNode===t&&o.toNode===n&&(e===null||o.fromPortId===e)&&(i===null||o.toPortId===i),s}findLinksTo(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null);const s=new ListIterator(this._t),n=this;return s.predicate=o=>!(o.fromNode!==n||o.toNode!==t||i!==null&&o.fromPortId!==i||e!==null&&o.toPortId!==e),s}get linkConnected(){return this.gt!==null?this.gt.ay:null}set linkConnected(t){const i=this.linkConnected;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkConnected"),this.cl(),this.gt.ay=t,this.t("linkConnected",i,t))}get linkDisconnected(){return this.gt!==null?this.gt.cy:null}set linkDisconnected(t){const i=this.linkDisconnected;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkDisconnected"),this.cl(),this.gt.cy=t,this.t("linkDisconnected",i,t))}get linkValidation(){return this.gt!==null?this.gt.Sl:null}set linkValidation(t){const i=this.linkValidation;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkValidation"),this.cl(),this.gt.Sl=t,this.t("linkValidation",i,t))}a1(t,i){this.ge(i);const e=this._t.has(t);if(e||this._t.add(t),!e||t.fromNode===t.toNode){const s=this.linkConnected;if(s!==null){let n=!0;const o=this.diagram;o!==null&&(n=o.Y,o.Y=!0),s(this,t,i),o!==null&&(o.Y=n)}}if(!e){if(!t.isTreeLink)return;const s=t.fromNode,n=t.toNode;if(s!==null&&n!==null&&s!==n){let o=!0;const r=this.diagram;r!==null&&(o=r.isTreePathToChildren);const l=o?n:s,h=o?s:n;if(l.ph||(l.ph=h),h.isTreeLeaf){if(r!==null&&r.undoManager.isUndoingRedoing)return;o?s===h&&(h.isTreeLeaf=!1):n===h&&(h.isTreeLeaf=!1)}}}}c1(t,i){this.ge(i);const e=this._t.delete(t);let s=null;if(e||t.toNode===t.fromNode){const n=this.linkDisconnected;if(s=this.diagram,n!==null){let o=!0;s!==null&&(o=s.Y,s.Y=!0),n(this,t,i),s!==null&&(s.Y=o)}}if(e){if(!t.isTreeLink)return;let n=!0;s!==null&&(n=s.isTreePathToChildren);const o=n?t.toNode:t.fromNode,r=n?t.fromNode:t.toNode;if(o!==null&&(o.ph=!1),r!==null&&!r.isTreeLeaf)if(r._t.count===0){if(r.ph=null,s!==null&&s.undoManager.isUndoingRedoing)return;r.isTreeLeaf=!0}else r.u0()}}u0(){if(this.ph=!1,this._t.count===0)return;let t=!0;const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;i!==null&&(t=i.isTreePathToChildren);const e=this._t.iterator;for(;e.next();){const s=e.value;if(s.isTreeLink){if(t){if(s.fromNode===this){this.isTreeLeaf=!1;return}}else if(s.toNode===this){this.isTreeLeaf=!1;return}}}this.isTreeLeaf=!0}updateRelationshipsFromData(){const t=this.diagram;t!==null&&t.partManager.updateRelationshipsFromData(this)}Um(t){if(super.Um(t),!t){this.u0();const i=this.bf;i!==null&&i.QA(this)}}Bm(t){if(super.Bm(t),!t){const i=this.bf;i!==null&&i._A(this)}}Xc(){if(this._t.count>0){const t=this.diagram;if(t!==null){const i=t.commandHandler!==null?t.commandHandler.deletesConnectedLinks:!0,s=this._t.copy().iterator;for(;s.next();){const n=s.value;i?t.remove(n):(n.fromNode===this&&(n.fromNode=null),n.toNode===this&&(n.toNode=null))}}}this.labeledLink=null,super.Xc()}get isLinkLabel(){return this.bf!==null}get labeledLink(){return this.bf}set labeledLink(t){const i=this.bf;if(i!==t){const e=this.diagram,s=this.data;if(i!==null){if(i._A(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=i.data,o=e.model;if(n!==null&&o.Aa()){const r=o.getKeyForNodeData(s);r!==void 0&&o.removeLabelKeyForLinkData(n,r)}}this.containingGroup=null}if(this.bf=t,t!==null){if(t.QA(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=t.data,o=e.model;if(n!==null&&o.Aa()){const r=o.getKeyForNodeData(s);r!==void 0&&o.addLabelKeyForLinkData(n,r)}}this.containingGroup=t.containingGroup}this.tf(),this.t("labeledLink",i,t)}}findVisiblePort(t){let i=t;for(;i!==null&&(!i.actualBounds.isReal()||!i.isVisibleObject());)i=i.panel;return i===null?this.port:i}findPort(t){if(this.se===null){if(t===""&&this.wn===!1)return this;this.tT()}let i=this.se.get(t);return i!==null||t!==""&&(i=this.se.get(""),i!==null)?i:this}get port(){return this.findPort("")}get ports(){return this.se===null&&this.tT(),this.se.iteratorValues}tT(){this.se===null?this.se=new GMap:this.se.clear(),this.walkVisualTreeFrom(this,(t,i)=>t.aA(i)),this.se.count===0&&this.se.set("",this)}aA(t){const i=t.portId;i!==null&&this.se!==null&&this.se.set(i,t)}g2(t,i){const e=t.portId;if(e!==null){this.se!==null&&this.se.delete(e);const s=this.diagram;if(s!==null&&i){let n=null;const o=this.findLinksConnected(e);for(;o.next();){const r=o.value;n===null&&(n=Util.ot()),n.push(r)}if(n!==null){for(let r=0;r!(!n.isTreeLink||n.fromNode!==s):e.predicate=n=>!(!n.isTreeLink||n.toNode!==s),e}findTreeChildrenNodes(){let t=!0;const i=this.diagram;i!==null&&(t=i.isTreePathToChildren);let e=null,s=null;const n=this._t.iterator;if(t)for(;n.next();){const o=n.value;if(o.isTreeLink&&o.fromNode===this){const r=o.toNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}else for(;n.next();){const o=n.value;if(o.isTreeLink&&o.toNode===this){const r=o.fromNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}return e!==null?e.iterator:s!==null?new SingletonIterator(s):EmptyIterator.instance}findTreeParts(t){t===void 0&&(t=1/0),Util.i(t,"number",Node,"findTreeParts:level");const i=new GSet;return Part.sh(i,this,!1,t,!0),i}collapseTree(t){t===void 0&&(t=1),t<1&&(t=1);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.iT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}iT(t,i,e,s,n,o){if(e>1){const r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);h!==null&&h!==this&&!t.has(h)&&(t.add(h),h.iT(t,i,e-1,s,n,o))}}else this.eT(t,i,s,n,o)}eT(t,i,e,s,n){const o=s===this?!0:this.isTreeExpanded,r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);if(h!==null&&h!==this){const a=t.has(h);if(a||t.add(h),o){const c=i?h.findNodesInto():h.findNodesOutOf(),f=this;c.all(u=>u===f||!u.isTreeExpanded)&&e.Cc(h,s),h.ah(),h.Ei(!1)}h.isTreeExpanded&&(h.wasTreeExpanded=h.isTreeExpanded,a||h.eT(t,i,e,s,n))}}this.isTreeExpanded=!1}expandTree(t){t===void 0&&(t=2),t<2&&(t=2);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.sT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}sT(t,i,e,s,n,o){const r=n===this?!1:this.isTreeExpanded,l=i?this.findLinksOutOf():this.findLinksInto();for(;l.next();){const h=l.value;if(!h.isTreeLink)continue;r||h.Se||h.invalidateRoute();const a=h.getOtherNode(this);if(a!==null&&a!==this&&!t.has(a)){if(t.add(a),!r){a.Ei(!0),a.ah();const c=i?a.findNodesInto():a.findNodesOutOf(),f=this;c.all(u=>u===f||!u.isTreeExpanded)&&s.Nc(a,n)}(e>2||a.wasTreeExpanded)&&(a.wasTreeExpanded=!1,a.sT(t,i,e-1,s,n,o))}}this.isTreeExpanded=!0}get isTreeExpanded(){return(this.E&1)!==0}set isTreeExpanded(t){const i=(this.E&1)!==0;if(i!==t){this.E=this.E^1;const e=this.diagram;this.t("isTreeExpanded",i,t);const s=this.treeExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.Y,e.Y=!0),s(this),e!==null&&(e.Y=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.Ei(t);return}t?this.expandTree():this.collapseTree()}}get wasTreeExpanded(){return(this.E&2)!==0}set wasTreeExpanded(t){const i=(this.E&2)!==0;i!==t&&(this.E=this.E^2,this.t("wasTreeExpanded",i,t))}get treeExpandedChanged(){return this.gt!==null?this.gt.fy:null}set treeExpandedChanged(t){const i=this.treeExpandedChanged;i!==t&&(t!==null&&Util.i(t,"function",Node,"treeExpandedChanged"),this.cl(),this.gt.fy=t,this.t("treeExpandedChanged",i,t))}get isTreeLeaf(){return(this.E&4)!==0}set isTreeLeaf(t){const i=(this.E&4)!==0;i!==t&&(this.E=this.E^4,this.t("isTreeLeaf",i,t))}get isTreeRoot(){return this.findTreeParentLink()===null}}class NodeTemplateSettings{gi;ay;cy;Sl;fy;hy;ly;uy;gy;eh;my;constructor(){this.gi=!1,this.ay=null,this.cy=null,this.Sl=null,this.fy=null,this.hy=Margin.lC,this.ly=1,this.uy=null,this.gy=null,this.eh=null,this.my=null}copy(){const t=new NodeTemplateSettings;return t.ay=this.ay,t.cy=this.cy,t.Sl=this.Sl,t.fy=this.fy,t.hy=this.hy.N(),t.ly=this.ly,t.uy=this.uy,t.gy=this.gy,t.eh=this.eh,t.my=this.my,t}}var LinkAdjusting=(w=>(w[w.None=0]="None",w[w.End=17]="End",w[w.Scale=18]="Scale",w[w.Stretch=19]="Stretch",w))(LinkAdjusting||{}),Routing=(w=>(w[w.Normal=1]="Normal",w[w.Orthogonal=2]="Orthogonal",w[w.AvoidsNodes=6]="AvoidsNodes",w[w.AvoidsNodesStraight=7]="AvoidsNodesStraight",w))(Routing||{}),Curve=(w=>(w[w.None=0]="None",w[w.Bezier=9]="Bezier",w[w.JumpGap=10]="JumpGap",w[w.JumpOver=11]="JumpOver",w))(Curve||{});class Link extends Part{Nt;lo;ho;Dd;ao;co;Fd;kf;Rd;vd;Od;Ta;Id;Hs;ki;fl;Mr;Pf;$o;_2;tN;f1;iN;eN;py;u1;ft;Zo;static Da=null;static Fa=null;lf;sN;nN;constructor(t){super(Panel.Link),this.Nt=8,this.lo=null,this.ho="",this.Dd=null,this.ao=null,this.co="",this.Fd=null,this.kf=0,this.Rd=0,this.vd=0,this.Od=NaN,this.Ta=1,this.Id=.5,this.Hs=null,this.ki=new List().g(),this.fl=null,this.Mr=null,this.Pf=new Rect,this.ft=new Geometry,this.$o=null,this.Zo=null,this._2=null,this.tN=null,this.sN=0,this.nN=0,this.f1=new Point,this.iN=null,this.eN=null,this.py=null,this.u1=NaN,this.q=null,this.lf=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Nt=this.Nt&-113,t.ho=this.ho,t.Dd=this.Dd,t.co=this.co,t.Fd=this.Fd,t.kf=this.kf,t.Rd=this.Rd,t.vd=this.vd,t.Od=this.Od,t.Ta=this.Ta,t.Id=this.Id,this.q!==null&&(t.q=this.q.copy())}Vo(t){super.Vo(t),this.ho=t.ho,this.co=t.co,t.fl=null,t.invalidateRoute(),t.Zo=this.Zo;const i=t.fromPort;i!==null&&t.fromNode.ge(i);const e=t.toPort;e!==null&&t.toNode.ge(e)}ri(t){t in Routing||t in Curve||t in LinkAdjusting?Link.oN(t)?this.routing=t:t===9||t===10||t===11?this.curve=t:t===17||t===18||t===19?this.adjusting=t:t===1||t===0||Util.o("Unknown Link enum value for a Link property: "+t):super.ri(t)}static Normal=1;static Orthogonal=2;static AvoidsNodes=6;static AvoidsNodesStraight=7;static None=0;static Bezier=9;static JumpGap=10;static JumpOver=11;static End=17;static Scale=18;static Stretch=19;static OrientAlong=21;static OrientPlus90=22;static OrientMinus90=23;static OrientOpposite=24;static OrientUpright=25;static OrientPlus90Upright=26;static OrientMinus90Upright=27;static OrientUpright45=28;static Xv=8;static Kv=16;static Yv=14;static Ra=8;Xe(){this.q===null&&(this.q=new LinkSettings)}_R(t,i,e){const s=t.segmentIndex,n=t.segmentFraction;let o=t.alignmentFocus;const r=t.segmentOrientation,l=t.segmentOffset;let h=0,a=0,c=0,f=0;if(isNaN(s)){const C=this.ft,S=Util.ot();C.getPointAndAngleAlongPath(n,S);const N=Point.X(S[0],S[1]);if(N.add(this.getPoint(0)),C.type===1)N.offset(-C.startX,-C.startY);else{const T=C.figures.first();N.offset(-T.startX,-T.startY)}f=S[2],r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=N.x,a=N.y,Point.s(N),Util.tt(S)}else if(s<-i||s>=i){const C=Point.l();this.mA(C),f=this.midAngle,r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=C.x,a=C.y,Point.s(C)}else{let C,S,N=0;if(s>=0?(C=e.r[s],S=s0?e.r[N-1]:C),C.equalsApprox(S)){let T,A;s>=0?(T=s>0?e.r[s-1]:C,A=s1?e.r[N-2]:S);const D=T.distanceSquaredPoint(C),F=S.distanceSquaredPoint(A);D>F+10?f=s>=0?T.directionPoint(C):C.directionPoint(T):F>D+10?f=s>=0?S.directionPoint(A):A.directionPoint(S):f=s>=0?T.directionPoint(A):A.directionPoint(T)}else f=s>=0?C.directionPoint(S):S.directionPoint(C);r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=C.x+(S.x-C.x)*n,a=C.y+(S.y-C.y)*n}if(o.isNone()){t.location=new Point(h,a);return}else o.isNoSpot()&&(o=Spot.Center);const u=Transform.l();u.Ri(),u.st(t.scale,t.scale),u.cs(t.angle,0,0);const d=t.naturalBounds,m=Rect.X(0,0,d.width,d.height),g=Point.l();g.setRectSpot(m,o),u.xt(g);let p=-g.x,y=-g.y;const x=d.width,k=d.height,b=Point.l();b.a(l);const P=isNaN(l.x),M=isNaN(l.y);if(P||M){const C=x/2+3,S=k/2+3,N=f>=45&&f<=135,T=f>=225&&f<=315;r===0&&(N||T)?(b.x=M?C:l.y,b.y=P?S:l.x,N?s>=0||isNaN(s)&&n<.5||P&&(b.y=-S):T&&((s>=0||isNaN(s)&&n<.5)&&P&&(b.y=-S),M&&(b.x=-C))):(P&&(s>=0||isNaN(s)&&n<.5?b.x=C:b.x=-C),M&&(b.y=-S),b.rotate(f))}else b.rotate(f);h+=b.x,a+=b.y,u.xw(m),p+=m.x,y+=m.y;const L=Point.X(h+p,a+y);t.move(L),Point.s(L),Point.s(b),Point.s(g),Rect.s(m),Transform.s(u)}Hr(){let t=this.fromNode;if(t!==null){const e=t.findVisibleNode();if(e!==null&&(t=e),t.is()||t.th())return!1}let i=this.toNode;if(i!==null){const e=i.findVisibleNode();if(e!==null&&(i=e),i.is()||i.th())return!1}return!0}u2(t,i,e){return!1}d2(){}Pe(){return!1}computeAngle(t,i,e){return Link.computeAngle(i,e)}static computeAngle(t,i){let e=0;switch(t){default:case 0:e=0;break;case 21:e=i;break;case 22:e=i+90;break;case 23:e=i-90;break;case 24:e=i+180;break;case 25:e=Geo.Xg(i),e>90&&e<270&&(e-=180);break;case 26:e=Geo.Xg(i+90),e>90&&e<270&&(e-=180);break;case 27:e=Geo.Xg(i-90),e>90&&e<270&&(e-=180);break;case 28:if(e=Geo.Xg(i),e>45&&e<135||e>225&&e<315)return 0;e>90&&e<270&&(e-=180);break}return Geo.Xg(e)}get fromNode(){return this.lo}set fromNode(t){const i=this.lo;if(i!==t){const e=this.fromPort;i!==null&&(this.ao!==i&&i.c1(this,e),this.yy(),this.invalidateLayout(2)),this.lo=t,t!==null&&this.Ei(t.isVisible()),this.$o=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.Y&&s.partManager.setFromNodeForLink(this,t,i);const n=this.fromPort,o=this.fromPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.Y,s.Y=!0),o(this,e,n),s!==null&&(s.Y=r)}t!==null&&(this.ao!==t&&t.a1(this,n),this.wy(),this.invalidateLayout(1)),this.t("fromNode",i,t),this.Ad()}}get fromPortId(){return this.ho}set fromPortId(t){const i=this.ho;if(i!==t){const e=this.fromPort;e!==null&&this.fromNode.ge(e),this.yy(),this.ho=t;const s=this.fromPort;s!==null&&this.fromNode.ge(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Aa()&&r.setFromPortIdForLinkData(o,t)}if(e!==s){this.$o=null,this.invalidateRoute();const o=this.fromPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.Y,n.Y=!0),o(this,e,s),n!==null&&(n.Y=r)}}this.wy(),this.t("fromPortId",i,t)}}get fromPort(){const t=this.lo;if(t===null)return null;const i=this.ho;return t.findPort(i)}get fromPortChanged(){return this.Dd}set fromPortChanged(t){const i=this.Dd;i!==t&&(t!==null&&Util.i(t,"function",Link,"fromPortChanged"),this.Dd=t,this.t("fromPortChanged",i,t))}get toNode(){return this.ao}set toNode(t){const i=this.ao;if(i!==t){const e=this.toPort;i!==null&&(this.lo!==i&&i.c1(this,e),this.yy(),this.invalidateLayout(2)),this.ao=t,t!==null&&this.Ei(t.isVisible()),this.$o=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.Y&&s.partManager.setToNodeForLink(this,t,i);const n=this.toPort,o=this.toPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.Y,s.Y=!0),o(this,e,n),s!==null&&(s.Y=r)}t!==null&&(this.lo!==t&&t.a1(this,n),this.wy(),this.invalidateLayout(1)),this.t("toNode",i,t),this.Ad()}}get toPortId(){return this.co}set toPortId(t){const i=this.co;if(i!==t){const e=this.toPort;e!==null&&this.toNode.ge(e),this.yy(),this.co=t;const s=this.toPort;s!==null&&this.toNode.ge(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Aa()&&r.setToPortIdForLinkData(o,t)}if(e!==s){this.$o=null,this.invalidateRoute();const o=this.toPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.Y,n.Y=!0),o(this,e,s),n!==null&&(n.Y=r)}}this.wy(),this.t("toPortId",i,t)}}get toPort(){const t=this.ao;if(t===null)return null;const i=this.co;return t.findPort(i)}get toPortChanged(){return this.Fd}set toPortChanged(t){const i=this.Fd;i!==t&&(t!==null&&Util.i(t,"function",Link,"toPortChanged"),this.Fd=t,this.t("toPortChanged",i,t))}get fromSpot(){return this.q!==null?this.q.ca:Spot.Default}set fromSpot(t){const i=this.fromSpot;if(!i.equals(t)){if(t=t.N(),this.Xe(),this.q.ca=t,this.t("fromSpot",i,t),i.isSide()||t.isSide()){const e=this.fromNode;e!==null&&e.ge(this.fromPort)}this.invalidateRoute()}}get fromEndSegmentLength(){return this.q!==null?this.q.ua:NaN}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;i!==t&&(t<0&&Util._(t,">= 0",Link,"fromEndSegmentLength"),this.Xe(),this.q.ua=t,this.t("fromEndSegmentLength",i,t),this.invalidateRoute())}get fromShortLength(){return this.q!==null?this.q.ga:NaN}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(this.Xe(),this.q.ga=t,this.ie(),this.t("fromShortLength",i,t))}get toSpot(){return this.q!==null?this.q.fa:Spot.Default}set toSpot(t){const i=this.toSpot;if(!i.equals(t)){if(t=t.N(),this.Xe(),this.q.fa=t,this.t("toSpot",i,t),i.isSide()||t.isSide()){const e=this.toNode;e!==null&&e.ge(this.toPort)}this.invalidateRoute()}}get toEndSegmentLength(){return this.q!==null?this.q.da:NaN}set toEndSegmentLength(t){const i=this.toEndSegmentLength;i!==t&&(t<0&&Util._(t,">= 0",Link,"toEndSegmentLength"),this.Xe(),this.q.da=t,this.t("toEndSegmentLength",i,t),this.invalidateRoute())}get toShortLength(){return this.q!==null?this.q.ma:NaN}set toShortLength(t){const i=this.toShortLength;i!==t&&(this.Xe(),this.q.ma=t,this.ie(),this.t("toShortLength",i,t))}Ad(){const t=this.fromNode,i=this.toNode;let e=null;if(t!==null?i!==null?e=t.findCommonContainingGroup(i):e=t.containingGroup:i!==null?e=i.containingGroup:e=null,this.Gv(e),this.isLabeledLink){const s=this.labelNodes;for(;s.next();){const n=s.value;n.containingGroup=e}}}Gv(t){const i=this.mh;if(i!==t){i!==null&&i.H2(this),this.mh=t,t!==null&&t.q2(this);const e=this.containingGroupChanged;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.Y,n.Y=!0),e(this,i,t),n!==null&&(n.Y=s)}this.Se&&(this.iN===i||this.eN===i)&&this.invalidateRoute()}}ah(){const t=this.containingGroup;t!==null&&this.fromNode!==t&&this.toNode!==t&&t.computesBoundsIncludingLinks&&super.ah()}getOtherNode(t){const i=this.fromNode;return t===i?this.toNode:i}getOtherPort(t){const i=this.fromPort;return t===i?this.toPort:i}get isLabeledLink(){return this.Hs===null?!1:this.Hs.count>0}get labelNodes(){return this.Hs===null?EmptyIterator.instance:this.Hs.iterator}QA(t){this.Hs===null&&(this.Hs=new GSet),this.Hs.add(t),this.c()}_A(t){this.Hs!==null&&(this.Hs.delete(t),this.c())}Um(t){if(super.Um(t),this.va()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.lo;let e=null;i!==null&&(e=this.fromPort,i.a1(this,e));const s=this.ao;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.a1(this,n)),this.wy()}}Bm(t){if(super.Bm(t),this.va()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.lo;let e=null;i!==null&&(e=this.fromPort,i.c1(this,e));const s=this.ao;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.c1(this,n)),this.yy()}}Xc(){if(this.Se=!0,this.Hs!==null){const i=this.diagram;if(i!==null){const s=this.Hs.copy().iterator;for(;s.next();){const n=s.value;i.remove(n)}}}if(this.data!==null){const i=this.diagram;i!==null&&i.partManager.rN(this)}}updateRelationshipsFromData(){if(this.data===null)return;const i=this.diagram;i!==null&&i.partManager.updateRelationshipsFromData(this)}move(t,i){const e=i?this.location:this.position;let s=e.x;isNaN(s)&&(s=0);let n=e.y;isNaN(n)&&(n=0);const o=t.x-s,r=t.y-n;if(i===!0)super.move(t,!1);else{const h=Point.X(e.x+o,e.y+r);super.move(h,!1),Point.s(h)}this.pr(o,r);const l=this.labelNodes;for(;l.next();){const h=l.value,a=h.position;h.moveTo(a.x+o,a.y+r)}}get relinkableFrom(){return(this.Nt&1)!==0}set relinkableFrom(t){const i=(this.Nt&1)!==0;i!==t&&(this.Nt=this.Nt^1,this.t("relinkableFrom",i,t),this.invalidateAdornments())}get relinkableTo(){return(this.Nt&2)!==0}set relinkableTo(t){const i=(this.Nt&2)!==0;i!==t&&(this.Nt=this.Nt^2,this.t("relinkableTo",i,t),this.invalidateAdornments())}canRelinkFrom(){if(!this.relinkableFrom)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}canRelinkTo(){if(!this.relinkableTo)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}get resegmentable(){return(this.Nt&4)!==0}set resegmentable(t){const i=(this.Nt&4)!==0;i!==t&&(this.Nt=this.Nt^4,this.t("resegmentable",i,t),this.invalidateAdornments())}get isTreeLink(){return(this.Nt&8)!==0}set isTreeLink(t){const i=(this.Nt&8)!==0;i!==t&&(this.Nt=this.Nt^8,this.t("isTreeLink",i,t),this.fromNode!==null&&this.fromNode.u0(),this.toNode!==null&&this.toNode.u0())}get path(){const t=this.findMainElement();return t instanceof Shape?t:null}get routeBounds(){return this.updateRoute(),this.jv(this.Pf)}jv(t){let i=1/0,e=1/0;const s=this.pointsCount;if(s===0)return t.e(NaN,NaN,0,0),t;if(s===1){const n=this.getPoint(0);i=Math.min(n.x,i),e=Math.min(n.y,e),t.e(n.x,n.y,0,0)}else if(s===2){const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o)}else if(this.computeCurve()===9&&s>=3&&!this.isOrthogonal){let n=this.getPoint(0);if(i=n.x,e=n.y,t.e(i,e,0,0),s===3){const o=this.getPoint(1);i=Math.min(o.x,i),e=Math.min(o.y,e);const r=this.getPoint(2);i=Math.min(r.x,i),e=Math.min(r.y,e),Geo.au(n.x,n.y,o.x,o.y,o.x,o.y,r.x,r.y,.5,t)}else for(let o=3;o=s&&(o=s-1);const l=this.getPoint(o-1),h=this.getPoint(o);Geo.au(n.x,n.y,r.x,r.y,l.x,l.y,h.x,h.y,.5,t),i=Math.min(h.x,i),e=Math.min(h.y,e),n=h}}else{const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o);for(let r=2;r=15||this.computeCurve()===9)){this.ft.getPointAlongPath(.5,t),t.add(this.getPoint(0));const a=this.ft.figures.first();return t.offset(-a.startX,-a.startY),t}if(this.computeCurve()===9){if(i===3){const f=this.getPoint(0),u=this.getPoint(1),d=this.getPoint(2);return Geo.dC(f.x,f.y,u.x,u.y,u.x,u.y,d.x,d.y,t),t}const a=(i-1)/3|0,c=(a/2|0)*3;if(a%2===1){const f=this.getPoint(c),u=this.getPoint(c+1),d=this.getPoint(c+2),m=this.getPoint(c+3);return Geo.dC(f.x,f.y,u.x,u.y,d.x,d.y,m.x,m.y,t),t}else return t.a(this.getPoint(c)),t}const e=this.flattenedLengths,s=this.flattenedTotalLength;let n=0,o=0,r=0;for(;ns/2));)n+=r,o++;const l=this.getPoint(o),h=this.getPoint(o+1);if(Math.abs(l.x-h.x)<1)l.y>h.y?t.e(l.x,l.y-(s/2-n)):t.e(l.x,l.y+(s/2-n));else if(Math.abs(l.y-h.y)<1)l.x>h.x?t.e(l.x-(s/2-n),l.y):t.e(l.x+(s/2-n),l.y);else{const a=(s/2-n)/r,c=a*(h.x-l.x),f=a*(h.y-l.y);t.e(l.x+c,l.y+f)}return t}get midAngle(){return this.updateRoute(),this.computeMidAngle()}computeMidAngle(){const t=this.pointsCount;if(t<2)return NaN;if(t===2){const h=this.getPoint(0),a=this.getPoint(1);return h.directionPoint(a)}if(this.isOrthogonal&&(this.computeCorner()>=15||this.computeCurve()===9))return this.ft.getAngleAlongPath(.5);if(this.computeCurve()===9&&t>=4){const h=(t-1)/3|0;let a=(h/2|0)*3;if(h%2===1){a=Math.floor(a);const c=this.getPoint(a),f=this.getPoint(a+1),u=this.getPoint(a+2),d=this.getPoint(a+3);return Geo.RD(c.x,c.y,f.x,f.y,u.x,u.y,d.x,d.y)}else if(a>0&&a+1e/2));)s+=o,n++;const r=this.getPoint(n),l=this.getPoint(n+1);if(Math.abs(r.x-l.x)<1&&Math.abs(r.y-l.y)<1){if(n>0&&n+2l.y?270:90;if(Math.abs(r.y-l.y)<1)return r.x>l.x?180:0}return r.directionPoint(l)}Hv(){if(this.py===null){this.Se||this.d1();const t=this.py=[];this.qv(t)}}get flattenedLengths(){return this.Hv(),this.py}get flattenedTotalLength(){let t=this.u1;if(isNaN(t)){const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=3){let g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e);m=this.adjustPoints(0,g,o-1,p),m&&(g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e),this.adjustPoints(0,g,o-1,p))}m||(this.clearPoints(),u?this.Wv(i,e,r,s,n,l):this.Jv(i,e,r,s,n,l))}else{const m=this.isAvoiding;d&&(f&&m||c)&&this.clearPoints();const g=c?this.computeCurviness():0,p=this.getLinkPoint(i,e,r,!0,f,s,n);let y=0,x=0,k=0;if(f||!h||c){let N=this.computeEndSegmentLength(i,e,r,!0);if(k=this.getLinkDirection(i,e,p,r,!0,f,s,n),c&&(h||r.equals(l)||!f&&r.x+l.x===1&&r.y+l.y===1)&&(k-=f?90:30,g<0&&(k-=180)),k<0?k+=360:k>=360&&(k-=360),c&&(N+=Math.abs(g)*(f?1:2)),k===0?y=N:k===90?x=N:k===180?y=-N:k===270?x=-N:(y=N*Math.cos(k*Math.PI/180),x=N*Math.sin(k*Math.PI/180)),r.isNoSpot()&&c){const T=e.getDocumentPoint(Spot.Center,Point.l()),A=Point.X(T.x+y*1e3,T.y+x*1e3);this.getLinkPointFromPoint(i,e,T,A,!0,p),Point.s(T),Point.s(A)}}const b=this.getLinkPoint(s,n,l,!1,f,i,e);let P=0,M=0,L=0;if(f||!a||c){let N=this.computeEndSegmentLength(s,n,l,!1);if(L=this.getLinkDirection(s,n,b,l,!1,f,i,e),c&&(a||r.equals(l)||!f&&r.x+l.x===1&&r.y+l.y===1)&&(L+=f?0:30,g<0&&(L+=180)),L<0?L+=360:L>=360&&(L-=360),c&&(N+=Math.abs(g)*(f?1:2)),L===0?P=N:L===90?M=N:L===180?P=-N:L===270?M=-N:(P=N*Math.cos(L*Math.PI/180),M=N*Math.sin(L*Math.PI/180)),l.isNoSpot()&&c){const T=n.getDocumentPoint(Spot.Center,Point.l()),A=Point.X(T.x+P*1e3,T.y+M*1e3);this.getLinkPointFromPoint(s,n,T,A,!1,b),Point.s(T),Point.s(A)}}let C=p;(f||!h||c)&&(C=new Point(p.x+y,p.y+x));let S=b;(f||!a||c)&&(S=new Point(b.x+P,b.y+M)),!d&&!f&&h&&o>3&&this.adjustPoints(0,p,o-2,S)?this.setPoint(o-1,b):!d&&!f&&a&&o>3&&this.adjustPoints(1,C,o-1,b)?this.setPoint(0,p):!d&&(f?o>=6:o>4)&&this.adjustPoints(1,C,o-2,S)?(this.setPoint(0,p),this.setPoint(o-1,b)):(this.clearPoints(),this.addPoint(p),(f||!h||c)&&this.addPoint(C),f&&this.addOrthoPoints(C,k,S,L,i,s),(f||!a||c)&&this.addPoint(S),this.addPoint(b))}return t.addInvalidRoute(this),!0}hN(t,i){return Math.abs(i.x-t.x)>Math.abs(i.y-t.y)?(i.x>=t.x?i.x=t.x+9e9:i.x=t.x-9e9,i.y=t.y):(i.y>=t.y?i.y=t.y+9e9:i.y=t.y-9e9,i.x=t.x),i}getLinkPointFromPoint(t,i,e,s,n,o){if(o===void 0&&(o=new Point),t===null||i===null)return o.a(e),o;if(!t.isVisible()){const u=t.findVisibleNode();u!==null&&u!==t&&(t=u,i=t.port)}let r=0,l=0,h=0,a=0,c=null,f=i.panel;if(f!==null&&!f.pn()&&(f=f.panel),f===null)r=s.x,l=s.y,h=e.x,a=e.y;else{c=f.Es;const u=1/(c.m11*c.m22-c.m12*c.m21),d=c.m22*u,m=-c.m12*u,g=-c.m21*u,p=c.m11*u,y=u*(c.m21*c.dy-c.m22*c.dx),x=u*(c.m12*c.dx-c.m11*c.dy);r=s.x*d+s.y*g+y,l=s.x*m+s.y*p+x,h=e.x*d+e.y*g+y,a=e.x*m+e.y*p+x}return i.$c(r,l,h,a,o),c!==null&&o.D(c),o}$v(t,i){const e=t.$u;return e!==null?e.nT(i):null}m1(t){let i=t.$u;return i===null&&(i=new Knot,i.Qo=t,i.ue=t.part,t.$u=i),i.nT(this)}getLinkPoint(t,i,e,s,n,o,r,l){if(l===void 0&&(l=new Point),e.isSpot()&&!this.Ed(e))return i.getDocumentPoint(e,l),l;if(e.isSide()){const c=this.m1(i);if(c!==null){const f=c.Ud;if(l.a(f),n&&this.routing===7){const u=this.m1(r);if(u!==null&&c.Mf=g.y&&y.y<=g.y+g.height?l.y=y.y:(e.includesSide(Spot.TopSide)||e.includesSide(Spot.BottomSide))&&y.x>=g.x&&y.x<=g.x+g.width&&(l.x=y.x),Point.s(d),Point.s(m)}}return l}}const h=i.getDocumentPoint(this.p1(e,s),Point.l());let a=null;if(this.pointsCount>(n?6:2))a=s?this.getPoint(1):this.getPoint(this.pointsCount-2),n&&(a=this.hN(h,a.copy()));else{const c=this.computeSpot(!s,r),f=Point.l();a=r.getDocumentPoint(this.p1(c,!s),f),n&&(a=this.hN(h,a)),Point.s(f)}return this.getLinkPointFromPoint(t,i,h,a,s,l),Point.s(h),l}getLinkDirection(t,i,e,s,n,o,r,l){let h=this.Zv(t,i,e,s,n,o,r,l);if(r&&s.isNoSpot()&&r.isMemberOf(t)&&(h+=180,h>=360&&(h-=360)),this.Ed(s))return h;const a=i.getDocumentAngle();return a===0||(45<=a&&a<135?h+=90:135<=a&&a<225?h+=180:225<=a&&a<315&&(h+=270),h>=360&&(h-=360)),h}Zv(t,i,e,s,n,o,r,l){if(s.isSpot())return s.x>s.y?s.x>1-s.y?0:s.x<1-s.y?270:315:s.x1-s.y?90:s.x<1-s.y?180:135:s.x<.5?225:s.x>.5?45:0;if(s.isSide()){const f=this.m1(i);if(f!==null)switch(f.me){case 1:return 270;case 2:return 180;default:case 4:return 0;case 8:return 90}}const h=i.getDocumentPoint(Spot.Center,Point.l());let a=null;if(this.pointsCount>(o?6:2))a=n?this.getPoint(1):this.getPoint(this.pointsCount-2),o?a=this.hN(h,a.copy()):a=e;else{const f=Point.l();a=l.getDocumentPoint(Spot.Center,f),Point.s(f)}let c=0;return Math.abs(a.x-h.x)>Math.abs(a.y-h.y)?a.x>=h.x?c=0:c=180:a.y>=h.y?c=90:c=270,Point.s(h),c}computeEndSegmentLength(t,i,e,s){if(i!==null&&e.isSide()){const o=this.m1(i);if(o!==null)return o.w1}let n=NaN;return s?n=this.fromEndSegmentLength:n=this.toEndSegmentLength,i!==null&&isNaN(n)&&(s?n=i.fromEndSegmentLength:n=i.toEndSegmentLength),isNaN(n)&&(n=10),n}computeSpot(t,i){return i===void 0&&(i=null),t?this.Qv(i||this.fromPort):this._v(i||this.toPort)}Qv(t){if(t===null)return Spot.Center;let i=this.fromSpot;return i.isDefault()&&(i=t.fromSpot),i===Spot.Default?Spot.None:i}_v(t){if(t===null)return Spot.Center;let i=this.toSpot;return i.isDefault()&&(i=t.toSpot),i===Spot.Default?Spot.None:i}Ed(t){return t===Spot.None||t.x===.5&&t.y===.5}p1(t,i){return t.x===.5&&t.y===.5?t:Spot.Center}computeOtherPoint(t,i){if(this.computeAdjusting()!==0&&this.pointsCount>4)return this.computeMidPoint(new Point);{const e=this.$v(i,this);return e!==null?e.Ud:i.getDocumentPoint(Spot.Center)}}computeShortLength(t){if(t){let i=this.fromShortLength;if(isNaN(i)){const e=this.fromPort;e!==null&&(i=e.fromShortLength)}return isNaN(i)?0:i}else{let i=this.toShortLength;if(isNaN(i)){const e=this.toPort;e!==null&&(i=e.toShortLength)}return isNaN(i)?0:i}}Om(t,i,e,s,n,o){if(this.pickable===!1)return!1;i===void 0&&(i=null),e===void 0&&(e=null);let r=o;if(o===void 0&&(r=Transform.l(),r.Ri()),r.tc(this.D),this.containedInRect(t,r))return this.R2(i,e,n),o===void 0&&Transform.s(r),!0;if(this.intersectsRect(t,r)){let l=!1;if(!this.hf){const h=this.L.r,a=h.length;for(let c=a;c--;){const f=h[c];if(!f.visible&&f!==this.locationObject)continue;const u=f.actualBounds,d=this.naturalBounds;if(u.x>d.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;const m=f,g=Transform.l();if(g.set(r),m instanceof Panel?l=m.Om(t,i,e,s,n,g):this.path===m?m instanceof Shape&&(l=m.kv(t,s,g)):l=m._L(t,s,g),l){let p=m;i!==null&&(p=i(m)),p&&(e===null||e(p))&&n.add(p)}Transform.s(g)}}return o===void 0&&Transform.s(r),l||this.background!==null}return o===void 0&&Transform.s(r),!1}get isOrthogonal(){return(this.Ta&2)===2}static oN(t){return(t&2)===2}get isAvoiding(){return(this.Ta&4)===4}computeCurve(){if(this.$o===null){const t=this.fromPort,i=t!==null&&t===this.toPort,e=this.isOrthogonal;this.$o=i&&!e}return this.$o?9:this.curve}computeCorner(){if(this.curve===9)return 0;let t=this.corner;return(isNaN(t)||t<0)&&(t=10),t}findMidLabel(){const t=this.path,i=this.L.r,e=i.length;for(let n=0;n0?g-=f:g+=f;else{const p=-h/a;let y=Math.sqrt(f*f/(p*p+1));c<0&&(y=-y),m=(a<0?-1:1)*y+u,g=p*(m-u)+d}this.addPoint(r),this.addPointAt(m,g),this.addPoint(l)}else{this.addPoint(r),this.addPoint(l);const h=Rect.l();i.getDocumentBounds(h);const a=h.containsPoint(l);n.getDocumentBounds(h);const c=h.containsPoint(r);if(a||c){const f=i.getDocumentPoint(this.p1(e,!0),new Point);this.setPoint(0,this.getLinkPointFromPoint(t,i,f,l,!0,f));const u=n.getDocumentPoint(this.p1(o,!1),new Point);this.setPoint(1,this.getLinkPointFromPoint(s,n,u,r,!1,u))}Rect.s(h)}}Wv(t,i,e,s,n,o){const r=this.getLinkPoint(t,i,e,!0,!1,s,n),l=this.getLinkPoint(s,n,o,!1,!1,t,i),h=l.x-r.x,a=l.y-r.y,c=this.computeCurviness();let f=0,u=0,d=r.x+h/3,m=r.y+a/3,g=d,p=m;Geo.u(a,0)?h>0?p-=c:p+=c:(f=-h/a,u=Math.sqrt(c*c/(f*f+1)),c<0&&(u=-u),g=(a<0?-1:1)*u+d,p=f*(g-d)+m),d=r.x+2*h/3,m=r.y+2*a/3;let y=d,x=m;Geo.u(a,0)?h>0?x-=c:x+=c:(y=(a<0?-1:1)*u+d,x=f*(y-d)+m),this.clearPoints(),this.addPoint(r),this.addPointAt(g,p),this.addPointAt(y,x),this.addPoint(l),this.setPoint(0,this.getLinkPoint(t,i,e,!0,!1,s,n)),this.setPoint(3,this.getLinkPoint(s,n,o,!1,!1,t,i))}adjustPoints(t,i,e,s){let n=this.computeAdjusting();if(this.isOrthogonal){if(n===18)return!1;n===19&&(n=17)}switch(n){case 18:return this.tO(t,i,e,s);case 19:return this.iO(t,i,e,s);case 17:return this.eO(t,i,e,s);default:return!1}}tO(t,i,e,s){const n=this.getPoint(t),o=this.getPoint(e);if(n.equalsApprox(i)&&o.equalsApprox(s))return!0;const r=n.x,l=n.y,h=o.x,a=o.y;let c=h-r,f=a-l;const u=Math.sqrt(c*c+f*f);if(Geo.K(u,0))return!0;let d=0;Geo.K(c,0)?f<0?d=-Math.PI/2:d=Math.PI/2:(d=Math.atan(f/Math.abs(c)),c<0&&(d=Math.PI-d));const m=i.x,g=i.y,p=s.x,y=s.y,x=p-m,k=y-g,b=Math.sqrt(x*x+k*k);let P=0;Geo.K(x,0)?k<0?P=-Math.PI/2:P=Math.PI/2:(P=Math.atan(k/Math.abs(x)),x<0&&(P=Math.PI-P));const M=b/u,L=P-d;this.setPoint(t,i);for(let C=t+1;C0&&(C=-C);const S=f+P*(d-f),N=u+P*(m-u);if(g!==0){const T=S+C/p,A=N-(T-S)/g;this.setPointAt(y,T,A)}else this.setPointAt(y,S,N+C)}return this.setPoint(e,s),!0}eO(t,i,e,s){if(this.isOrthogonal){let n=this.getPoint(t),o=this.getPoint(t+1),r=this.getPoint(t+2),l=o.x,h=o.y;const a=l,c=h;Geo.u(n.y,o.y)?Geo.u(o.x,r.x)?h=i.y:Geo.u(o.y,r.y)&&(l=i.x):Geo.u(n.x,o.x)&&(Geo.u(o.y,r.y)?l=i.x:Geo.u(o.x,r.x)&&(h=i.y)),this.setPointAt(t+1,l,h),n=this.getPoint(e),o=this.getPoint(e-1),r=this.getPoint(e-2);let f=o.x,u=o.y;const d=f,m=u;if(Geo.u(n.y,o.y)?Geo.u(o.x,r.x)?u=s.y:Geo.u(o.y,r.y)&&(f=s.x):Geo.u(n.x,o.x)&&(Geo.u(o.y,r.y)?f=s.x:Geo.u(o.x,r.x)&&(u=s.y)),this.setPointAt(e-1,f,u),this.TL())return this.setPointAt(t+1,a,c),this.setPointAt(e-1,d,m),!1}return this.setPoint(t,i),this.setPoint(e,s),!0}addOrthoPoints(t,i,e,s,n,o){i<0?i+=360:i>=360&&(i-=360),s<0?s+=360:s>=360&&(s-=360);const c=s;i>=315||i<45?i=0:45<=i&&i<135?i=90:135<=i&&i<225?i=180:i=270,s>=315||s<45?s=0:45<=s&&s<135?s=90:135<=s&&s<225?s=180:s=270;const f=t,u=e,d=n.actualBounds.copy(),m=o.actualBounds.copy();if(!d.isReal()||!m.isReal())return;d.inflate(Link.Ra,Link.Ra),m.inflate(Link.Ra,Link.Ra),d.unionPoint(t),m.unionPoint(e);const g=Point.l(),p=Point.l();i===0?u.x>f.x||s===270&&u.yf.x||s===90&&u.y>f.y&&m.right>f.x?(g.e(u.x,f.y),p.e(u.x,(f.y+u.y)/2),s===180?(g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1),p.x=g.x,p.y=u.y):s===270&&u.yf.y?(f.xm.bottom)?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):g.x=m.right,p.x=g.x,p.y=u.y):s===0&&f.xm.top&&f.yd.bottom)&&(s===180&&(m.containsPoint(f)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):u.yf.y&&(s===180||s===270)&&(g.y=this.computeMidOrthoPosition(f.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=d.left&&u.x<=f.x||f.x<=m.right&&f.x>=u.x?(s===90||s===270)&&(g.e(Math.max((f.x+u.x)/2,f.x),f.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yf.y&&m.leftf.y?(f.x>m.right?g.x=this.computeMidOrthoPosition(f.x,f.y,m.right,u.y,!1):f.x>m.left&&(s===270&&f.ym.bottom)?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):g.x=m.left,p.x=g.x,p.y=u.y):s===180&&f.x>m.right&&f.y>m.top&&f.yd.bottom)&&(s===0&&(m.containsPoint(f)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):u.yf.y&&(s===0||s===270)&&(g.y=this.computeMidOrthoPosition(f.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=f.x||f.x>=m.left&&f.x<=u.x?(s===90||s===270)&&(g.e(Math.min((f.x+u.x)/2,f.x),f.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yf.y||s===180&&u.xf.y||s===0&&u.x>f.x&&m.bottom>f.y?(g.e(f.x,u.y),p.e((f.x+u.x)/2,u.y),s===270?(g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0),p.x=u.x,p.y=g.y):s===180&&u.xf.x?(f.ym.right)?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):g.y=m.bottom,p.x=u.x,p.y=g.y):s===90&&f.ym.left&&f.xd.right)&&(s===270&&(m.containsPoint(f)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):u.xf.x&&(s===270||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,f.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=d.top&&u.y<=f.y||f.y<=m.bottom&&f.y>=u.y?(s===0||s===180)&&(g.e(f.x,Math.max((f.y+u.y)/2,f.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.xf.x&&m.top=f.x?(f.y>m.bottom?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,m.bottom,!0):f.y>m.top&&(s===180&&f.xm.right)?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):g.y=m.top,p.x=u.x,p.y=g.y):s===270&&f.y>m.bottom&&f.x>m.left&&f.xd.right)&&(s===90&&(m.containsPoint(f)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):u.xf.x&&(s===90||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,f.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=f.y||f.y>=m.top&&f.y<=u.y?(s===0||s===180)&&(g.e(f.x,Math.min((f.y+u.y)/2,f.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.x=3&&!Geo.K(this.smoothness,0))if(i===3){let c=this.getPoint(1);n=Math.min(r.x,c.x),o=Math.min(r.y,c.y),c=this.getPoint(2),n=Math.min(n,c.x),o=Math.min(o,c.y)}else if(this.isOrthogonal){for(let c=0;c=i&&(c=i-1);const f=this.getPoint(c);l.x=Math.min(f.x,l.x),l.y=Math.min(f.y,l.y)}n=l.x,o=l.y}else{for(let c=0;c=3&&!Geo.K(this.smoothness,0))if(i===3){const f=this.getPoint(1),u=f.x-n,d=f.y-o;let m=this.getPoint(2).copy();m.x-=n,m.y-=o,this.computeShortLength(!1)!==0&&(m=this.Sf(m,!1,l)),c.dr(u,d,u,d,m.x,m.y)}else if(this.isOrthogonal){const f=Point.X(n,o),u=Point.l();u.a(this.getPoint(1));const d=Point.X(n,o),m=Point.X(n,o);let g=this.getPoint(0),p=null;const y=this.smoothness/3;for(let P=1;P=i&&(f=i-1);const d=this.getPoint(f-1);let m=this.getPoint(f);f===i-1&&this.computeShortLength(!1)!==0&&(m=this.Sf(m.copy(),!1,Point.Po)),c.dr(u.x-n,u.y-o,d.x-n,d.y-o,m.x-n,m.y-o)}else{const f=Point.l();f.a(this.getPoint(0));const u=Point.l();u.a(f);const d=this.computeCorner();let m=1,g=0;for(;m1);let p=this.getPoint(m);if(m>=i-1){if(!f.equals(p))this.computeShortLength(!1)!==0&&(p=this.Sf(p.copy(),!1,Point.Po)),this.Nn(c,-n,-o,f,p,e);else if(g===0)for(m=1;mr?f>a?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):f>a?(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.K(r,h)&&Geo.K(a,f)&&(a>l?c>h?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):c>h?(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.K(r,h)&&Geo.K(h,c)||Geo.K(l,a)&&Geo.K(a,f)){const m=.5*(r+c),g=.5*(l+f);n.x=m,n.y=g,o.x=m,o.y=g}}Sf(t,i,e){const s=this.pointsCount;if(s<2)return t;if(i){const n=this.getPoint(1),o=n.x-e.x,r=n.y-e.y,l=this.b1(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!0);a>h&&(a=h);const c=a*(o-t.x)/l,f=a*(r-t.y)/l;t.x+=c,t.y+=f}else{const n=this.getPoint(s-2),o=n.x-e.x,r=n.y-e.y,l=this.b1(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!1);a>h&&(a=h);const c=a*(t.x-o)/l,f=a*(t.y-r)/l;t.x-=c,t.y-=f}return t}aN(t,i,e){const s=this.pointsCount;let n=t;for(;Geo.K(t.x,n.x)&&Geo.K(t.y,n.y);){if(i>=s)return s-1;n=this.getPoint(i++)}if(!Geo.K(t.x,n.x)&&!Geo.K(t.y,n.y))return i-1;let o=n;for(;Geo.K(t.x,n.x)&&Geo.K(n.x,o.x)&&(!e||(t.y>=n.y?n.y>=o.y:n.y<=o.y))||Geo.K(t.y,n.y)&&Geo.K(n.y,o.y)&&(!e||(t.x>=n.x?n.x>=o.x:n.x<=o.x));){if(i>=s)return s-1;o=this.getPoint(i++)}return i-2}oO(t,i,e,s,n,o,r,l,h,a){if(Geo.u(s.y,n.y)&&Geo.u(n.x,o.x)){let c=Math.min(h,Math.abs(n.x-l.x)/2);const f=Math.min(c,Math.abs(o.y-n.y)/2);if(c=f,Geo.u(c,0)){this.Nn(t,i,e,s,n,a),r.a(n);return}let u=n.x;const d=n.y,m=u;let g=d;n.x>s.x?(u=n.x-c,o.y>n.y?g=n.y+f:g=n.y-f):(u=n.x+c,o.y>n.y?g=n.y+f:g=n.y-f);const p=Point.X(u,d);this.Nn(t,i,e,s,p,a),Point.s(p),t.Sw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else if(Geo.u(s.x,n.x)&&Geo.u(n.y,o.y)){let c=Math.min(h,Math.abs(n.y-l.y)/2);const f=Math.min(c,Math.abs(o.x-n.x)/2);if(c=f,Geo.u(f,0)){this.Nn(t,i,e,s,n,a),r.a(n);return}const u=n.x;let d=n.y,m=u;const g=d;n.y>s.y?(d=n.y-c,o.x>n.x?m=n.x+f:m=n.x-f):(d=n.y+c,o.x>n.x?m=n.x+f:m=n.x-f);const p=Point.X(u,d);this.Nn(t,i,e,s,p,a),Point.s(p),t.Sw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else this.Nn(t,i,e,s,n,a),r.a(n)}computeJumpLength(){return 10}Nn(t,i,e,s,n,o){if(o||!this.va())t.ur(n.x+i,n.y+e);else{const r=this.computeJumpLength(),l=r/2,h=[];let a=0;this.isVisible()&&(a=this.rO(s,n,h));let c=s.x,f=s.y;if(a>0){if(Geo.u(s.y,n.y))if(s.x=0;){const d=Math.min(s.x,Math.max(h[u--]+l,n.x+r));t.ur(d+i,n.y+e),c=d+i,f=n.y+e;let m=Math.max(d-r,n.x);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.x);else break}const g=n.y-r+e,p=m+i,y=n.y+e;this.curve===10?t.uu(p,y,!1,!1):t.dr(c,g,p,g,p,y),c=p,f=y}}else if(Geo.u(s.x,n.x))if(s.y=0;){const d=Math.min(s.y,Math.max(h[u--]+l,n.y+r));t.ur(n.x+i,d+e),c=n.x+i,f=d+e;let m=Math.max(d-r,n.y);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.y);else break}const g=n.x-r+i,p=n.x+i,y=m+e;this.curve===10?t.uu(p,y,!1,!1):t.dr(g,f,g,y,p,y),c=p,f=y}}}t.ur(n.x+i,n.y+e)}}rO(t,i,e){const s=this.diagram;if(s===null||t.equals(i))return 0;const n=s.layers;for(;n.next();){const o=n.value;if(o!==null&&o.visible){const r=o.EM(),l=r.length;for(let h=0;h0&&e.sort((u,d)=>u-d),e.length;if(!a.isVisible()||!a.va())continue;const c=a.routeBounds;if(!c.isReal()||!this.routeBounds.intersectsRect(c)||this.usesSamePort(a))continue;const f=a.path;f!==null&&f.isVisibleObject()&&this.lO(t,i,e,a)}}}return e.length>0&&e.sort((o,r)=>o-r),e.length}lO(t,i,e,s){const n=Geo.u(t.y,i.y),o=s.pointsCount;let r=s.getPoint(0);const l=Point.l();for(let h=1;hr.x&&c.x>=a.x||a.xr.y&&c.y>=a.y||a.yc&&Math.min(a,f)o&&!Geo.u(a,f))return n.x=o,n.y=c,!0}else if(Geo.u(r,h)&&Geo.u(a,f)&&Math.min(o,l)a&&Math.min(c,u)r&&!Geo.u(c,u))return n.x=a,n.y=r,!0;return n.x=0,n.y=0,!1}get firstPickIndex(){return this.pointsCount<=2?0:this.isOrthogonal||!this.Ed(this.computeSpot(!0))?1:0}get lastPickIndex(){const t=this.pointsCount;return t===0?0:t<=2?t-1:this.isOrthogonal||!this.Ed(this.computeSpot(!1))?t-2:t-1}va(){const t=this.curve;return t===11||t===10}g1(t){if(t||this.va()){const i=this.diagram;i!==null&&!i.animationManager.isTicking&&!i.$l.has(this)&&(this.Pf.width!==0||this.Pf.height!==0)&&i.$l.set(this,this.Pf.copy())}}invalidateOtherJumpOvers(t){const i=this.layer;if(i===null||!i.visible||i.isTemporary)return;const e=i.diagram;if(e===null||e.animationManager.isTicking)return;let s=!1;const n=e.layers;for(;n.next();){const o=n.value;if(o.visible){if(o===i){s=!0;let r=!1;const l=o.EM(),h=l.length;for(let a=0;a0&&e>0){const s=this.getPoint(0),n=t.getPoint(0);if(s.equalsApprox(n))return!0;const o=this.getPoint(i-1),r=t.getPoint(e-1);if(o.equalsApprox(r)||s.equalsApprox(r)||o.equalsApprox(n))return!0}else if(this.fromNode===t.fromNode||this.toNode===t.toNode||this.fromNode===t.toNode||this.toNode===t.fromNode)return!0;return!1}isVisible(){if(!super.isVisible())return!1;const t=this.containingGroup;let i=!0;const e=this.diagram;e!==null&&(i=e.isTreePathToChildren);const s=this.fromNode;if(s!==null){if(this.isTreeLink&&i&&!s.isTreeExpanded)return!1;if(s===t)return!0;let o=s;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=s.findVisibleNode();if(r===null||r===t)return!1}const n=this.toNode;if(n!==null){if(this.isTreeLink&&!i&&!n.isTreeExpanded)return!1;if(n===t)return!0;let o=n;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=n.findVisibleNode();if(r===null||r===t)return!1}return!0}Ei(t){if(super.Ei(t),t&&this.g1(!1),this.Zo!==null&&this.Zo.Td(),this.Hs!==null){const e=this.Hs.iterator;for(;e.next();)e.value.Ei(t)}}get adjusting(){return this.kf}set adjusting(t){const i=this.kf;i!==t&&(this.kf=t,this.t("adjusting",i,t))}computeAdjusting(){return this.isAvoiding&&this.diagram!==null&&this.diagram.animationManager.defaultAnimation.isAnimating?17:this.kf}get corner(){return this.Rd}set corner(t){const i=this.Rd;i!==t&&(this.Rd=t,this.ie(),this.t("corner",i,t))}get curve(){return this.vd}set curve(t){const i=this.vd;i!==t&&(this.vd=t,this.invalidateRoute(),this.ie(),this.g1(i===10||i===11||t===10||t===11),this.t("curve",i,t))}get curviness(){return this.Od}set curviness(t){const i=this.Od;i!==t&&(this.Od=t,this.invalidateRoute(),this.ie(),this.t("curviness",i,t))}get routing(){return this.Ta}set routing(t){const i=this.Ta;i!==t&&(this.Ta=t,this.isAvoiding&&this.diagram!==null&&(this.diagram.Gm=!0),this.$o=null,this.invalidateRoute(),this.g1(Link.oN(i)||Link.oN(t)),this.t("routing",i,t))}get smoothness(){return this.Id}set smoothness(t){const i=this.Id;i!==t&&(this.Id=t,this.ie(),this.t("smoothness",i,t))}wy(){const t=this.lo;if(t===null)return;const i=this.ao;if(i===null||!isNaN(this.curviness))return;const e=this.ho,s=this.co;let n=null,o=null;const r=t._t.r,l=r.length;for(let h=0;h=0&&(Util._a(t.qs,i),t.Td())}}Cl(){return!0}get key(){const t=this.diagram;if(!(t===null||!t.model.Aa()))return t.model.getKeyForLinkData(this.data)}}class LinkBundle{Eo;Os;ry;Z2;h1;Q2;qs;constructor(t,i,e,s){GSet.Yi(this),this.Eo=!1,this.Os=!1,this.ry=t,this.Z2=i,this.h1=e,this.Q2=s,this.qs=[]}Td(){if(!this.Eo){const t=this.qs;if(t.length>0){const i=t[0].diagram;i!==null&&(i.lS.add(this),this.Os=i.undoManager.isUndoingRedoing)}}this.Eo=!0}bS(){if(this.Eo){this.Eo=!1;const t=this.qs;if(t.length>0){const i=t[0],e=i.diagram,s=e===null||e.Eh&&!this.Os;this.Os=!1,i.arrangeBundledLinks(t,s),t.length===1&&(i.Zo=null,t.length=0)}t.length===0&&(this.ry.JA(this),this.h1.JA(this))}}}class PositionArray{ne;oe;Oa;Ia;pi;yi;Ot;wh;xh;la;RS;Eo;by;Yc;vS;OS;constructor(t){GSet.Yi(this),this.la=null,this.RS=null,this.Eo=!0,this.by=!1,this.ne=1,this.oe=1,this.Oa=-1,this.Ia=-1,this.pi=t.width,this.yi=t.height,this.Ot=null,this.wh=0,this.xh=0,this.Yc=11,this.vS=this.Yc*2,this.OS=this.Yc*2}static Ws=0;static Ea=1;static Bd=999999;static cN=PositionArray.Bd+1;static fN=PositionArray.Bd+2;kb(t){if(t.width<=0||t.height<=0)return;const i=t.x,e=t.y,s=t.x+t.width,n=t.y+t.height;this.ne=Math.floor((i-this.pi)/this.pi)*this.pi,this.oe=Math.floor((e-this.yi)/this.yi)*this.yi,this.Oa=Math.ceil((s+2*this.pi)/this.pi)*this.pi,this.Ia=Math.ceil((n+2*this.yi)/this.yi)*this.yi;const o=1+(Math.ceil((this.Oa-this.ne)/this.pi)|0),r=1+(Math.ceil((this.Ia-this.oe)/this.yi)|0);if(this.Ot===null||this.wh0&&t!==this.pi&&(this.pi=t,this.kb(this.bounds))}get cellHeight(){return this.yi}set cellHeight(t){t>0&&t!==this.yi&&(this.yi=t,this.kb(this.bounds))}Vd(t,i){return this.ne<=t&&t<=this.Oa&&this.oe<=i&&i<=this.Ia}fo(t,i){if(!this.Vd(t,i))return PositionArray.cN;t-=this.ne,t/=this.pi,i-=this.oe,i/=this.yi;const e=t|0,s=i|0;return this.Ot[e][s]}wR(t,i,e,s){if(!this.Vd(t,i))return;const n=(t-this.ne)/this.pi|0,o=(i-this.oe)/this.yi|0,r=(t+e-this.ne)/this.pi|0,l=(i+s-this.oe)/this.yi|0,h=Math.min(r,this.wh),a=Math.min(l,this.xh);for(let c=n;c<=h;c++){const f=this.Ot[c];if(f.fill)f.fill(PositionArray.Ws,o,a+1);else for(let u=o;u<=a;u++)f[u]=PositionArray.Ws}}aO(t){if(this.Ot!==null)for(let i=0;i<=this.wh;i++){const e=this.Ot[i];if(e.fill)e.fill(t);else for(let s=0;s<=this.xh;s++)e[s]=t}}XL(){if(this.Ot!==null)for(let t=0;t<=this.wh;t++){const i=this.Ot[t];for(let e=0;e<=this.xh;e++)i[e]>=PositionArray.Ea&&(i[e]=PositionArray.cN)}}cO(t,i){return this.fo(t,i)===PositionArray.Ws}isUnoccupied(t,i,e,s){if(t>this.Oa||t+ethis.Ia||i+sthis.Oa||ithis.Ia||ethis.Ia||ithis.Oa||e=PositionArray.Ea&&h=a)break;this.Ot[t][i]=h,h+=1,s?i+=e:t+=e}return s?i:t}uo(t,i,e,s,n,o,r,l){if(to||il)return;const h=this.fO(t,i,e,s,n,o,r,l);if(s)if(e>0)for(let a=i+e;ah;a+=e)this.uo(t,a,1,!s,n,o,r,l),this.uo(t,a,-1,!s,n,o,r,l);else if(e>0)for(let a=t+e;ah;a+=e)this.uo(a,i,1,!s,n,o,r,l),this.uo(a,i,-1,!s,n,o,r,l)}k1(t,i,e,s,n,o,r,l,h,a){let c=t|0,f=i|0,u=PositionArray.Ws,d=PositionArray.Ea;for(this.Ot[c][f]=d;u===PositionArray.Ws&&c>r&&ch&&fr&&ch&&f=0;v-=2){F=A[v+2],R=A[v+3];const O=A[v],U=A[v+1];for(;O>F?F++:OR?R++:Us)d--;else break;else if(m>n)m--;else break;const g=c[d][m];if(g===0||g===PositionArray.fN)break;f=d,u=m}for(;;){let d=e,m=f,g=u;e===0?gn&&(d=270,g--):e===90?ms&&(d=180,m--):e===180?gn&&(d=270,g--):ms&&(d=180,m--);const p=c[m][g];if(d!==e&&p!==0&&p!==PositionArray.fN){if(o.push(f),o.push(u),this.lT(f,u,d,s,n,o))return!0;o.pop(),o.pop()}if(c[f][u]=PositionArray.fN,e===0){if(f===t)return!1;f--}else if(e===90){if(u===i)return!1;u--}else if(e===180){if(f===t)return!1;f++}else{if(u===i)return!1;u++}}}}class Knot{ue;Qo;rs;zd;constructor(){GSet.Yi(this),this.ue=null,this.Qo=null,this.rs=[],this.zd=!1}toString(){const t=this.rs;let i=this.ue.toString()+" "+t.length.toString()+":";for(let e=0;e180?270:90;case 6:return o>90&&o<=270?180:0}const r=Math.atan2(t.height,t.width)*180/Math.PI;switch(n){case 3:return o>r&&o<=180+r?180:270;case 5:return o>180-r&&o<=360-r?270:0;case 12:return o>r&&o<=180+r?90:0;case 10:return o>180-r&&o<=360-r?180:90;case 7:return o>90&&o<=180+r?180:o>180+r&&o<=360-r?270:0;case 13:return o>180&&o<=360-r?270:o>r&&o<=180?90:0;case 14:return o>r&&o<=180-r?90:o>180-r&&o<=270?180:0;case 11:return o>180-r&&o<=180+r?180:o>180+r?270:90}return s&&n!==15&&(o-=15,o<0&&(o+=360)),o>r&&o<180-r?90:o>=180-r&&o<=180+r?180:o>180+r&&o<360-r?270:0}Td(){this.rs.length=0}nT(t){let i=this.rs;i.length===0&&(this.dO(),i=this.rs);for(let e=0;e=360&&(M-=360);const L=this.uO(h,y,M,g.isOrthogonal);let C=0;L===0?(C=4,M>180&&(M-=360)):L===90?(C=8,M>270&&(M-=360)):L===180?C=2:(C=1,M<90&&(M+=360));let S=this.rs[o];S===void 0?(S=new LinkInfo(g,M,C),this.rs[o]=S):(S.He=g,S.Xt=M,S.me=C),S.M1.set(P),o++}Point.s(a),this.gO();const u=this.rs.length;let d=-1,m=0;for(o=0;o=0;o--){const g=this.rs[o];g!==void 0&&(g.me!==d&&(d=g.me,m=g.Xd+1),g.Mf=m)}this.mO(this.rs),this.pO(this.rs),this.zd=t,Rect.s(h)}return this.rs}yO(t,i){return t===i?0:t===null?-1:i===null?1:t.mei.me?1:t.Xti.Xt?1:0}gO(){this.rs.sort(Knot.prototype.yO)}mO(t){const i=this.Qo,e=this.ue.portSpreading,s=Point.l(),n=Point.l(),o=Point.l(),r=Point.l();i.getDocumentPoint(Spot.TopLeft,s),i.getDocumentPoint(Spot.TopRight,n),i.getDocumentPoint(Spot.BottomRight,o),i.getDocumentPoint(Spot.BottomLeft,r);let l=0,h=0,a=0,c=0;if(e===2)for(let x=0;xMath.abs(p)?(d=Math.abs(p)/a,a=Math.abs(p)):d=1;break;case 2:c>Math.abs(y)?(d=Math.abs(y)/c,c=Math.abs(y)):d=1;break;case 1:l>Math.abs(p)?(d=Math.abs(p)/l,l=Math.abs(p)):d=1;break;default:case 4:h>Math.abs(y)?(d=Math.abs(y)/h,h=Math.abs(y)):d=1;break}u=0}const b=k.Ud;if(e===2){let P=k.He.computeThickness();switch(P*=d,b.set(m),f){case 8:b.x=m.x+p/2+a/2-u-P/2;break;case 2:b.y=m.y+y/2+c/2-u-P/2;break;case 1:b.x=m.x+p/2-l/2+u+P/2;break;default:case 4:b.y=m.y+y/2-h/2+u+P/2;break}u+=P}else{let P=.5;e===1&&(P=(k.Xd+1)/(k.Mf+1)),b.x=m.x+p*P,b.y=m.y+y*P}}Point.s(s),Point.s(n),Point.s(o),Point.s(r)}pO(t){for(let i=0;ie instanceof Placeholder);i instanceof Placeholder?t.It=i:t.It=null,this.te!==null?(t.te=this.te.copy(),t.te.group=t):(t.te!==null&&(t.te.group=null),t.te=null),this.si!==null&&(t.si=this.si.copy())}Vo(t){super.Vo(t);const i=t.findSubGraphParts(),e=t.memberParts;for(;e.next();){const s=e.value;if(s.c(),s.invalidateLayout(8),s.clearAdornments(),s instanceof Node)s.invalidateConnectedLinks(i);else if(s instanceof Link){const n=s.labelNodes;for(;n.next();)n.value.invalidateConnectedLinks(i)}}}Wc(t,i,e,s,n,o,r){if(t===3&&i==="elements"){if(n instanceof Placeholder)this.It===null?this.It=n:this.It!==n&&Util.o("Cannot insert a second Placeholder into the visual tree of a Group.");else if(n instanceof Panel){const l=n.findInVisualTree(h=>h instanceof Placeholder);l instanceof Placeholder&&(this.It===null?this.It=l:this.It!==l&&Util.o("Cannot insert a second Placeholder into the visual tree of a Group."))}}else t===4&&i==="elements"&&this.It!==null&&(s===this.It?this.It=null:s instanceof Panel&&this.It.isContainedBy(s)&&(this.It=null));super.Wc(t,i,e,s,n,o,r)}ed(t,i){if(super.ed(t,i),this.isClipping&&this.type!==Panel.Spot&&this.isSubGraphExpanded){let e=this.resizeObject;e instanceof Panel&&(e=e.findMainElement()),this.si===null&&(this.si=new Rect),e.getDocumentBounds(this.si),e instanceof Shape&&this.si.inflate(-e.strokeWidth,-e.strokeWidth)}}hh(t,i,e,s){this.hasPlaceholder()&&(this.Jo=this.placeholder),super.hh(t,i,e,s)}ensureBounds(){this.isSubGraphExpanded&&this.memberParts.each(i=>{i.ensureBounds()}),super.ensureBounds()}Hr(){if(!super.Hr())return!1;const t=this.memberParts;for(;t.next();){const i=t.value;if(i instanceof Node){if(!i.isVisible())continue;if(i.is())return!1}else if(i instanceof Link){if(!i.isVisible())continue;if(i.is()&&i.fromNode!==this&&i.toNode!==this)return!1}}return!0}hasPlaceholder(){return this.It!==null&&this.It.isVisibleObject()&&this.isSubGraphExpanded}get placeholder(){return this.It}get computesBoundsAfterDrag(){return(this.E&2048)!==0}set computesBoundsAfterDrag(t){const i=(this.E&2048)!==0;i!==t&&(Util.i(t,"boolean",Group,"computesBoundsAfterDrag"),this.E=this.E^2048,this.t("computesBoundsAfterDrag",i,t))}get computesBoundsIncludingLinks(){return(this.E&4096)!==0}set computesBoundsIncludingLinks(t){Util.i(t,"boolean",Group,"computesBoundsIncludingLinks");const i=(this.E&4096)!==0;i!==t&&(this.E=this.E^4096,this.t("computesBoundsIncludingLinks",i,t))}get computesBoundsIncludingLocation(){return(this.E&8192)!==0}set computesBoundsIncludingLocation(t){Util.i(t,"boolean",Group,"computesBoundsIncludingLocation");const i=(this.E&8192)!==0;i!==t&&(this.E=this.E^8192,this.t("computesBoundsIncludingLocation",i,t))}get handlesDragDropForMembers(){return(this.E&16384)!==0}set handlesDragDropForMembers(t){Util.i(t,"boolean",Group,"handlesDragDropForMembers");const i=(this.E&16384)!==0;i!==t&&(this.E=this.E^16384,this.t("handlesDragDropForMembers",i,t))}get avoidableMembers(){return(this.E&131072)!==0}set avoidableMembers(t){Util.i(t,"boolean",Group,"avoidableMembers");const i=(this.E&131072)!==0;i!==t&&(this.E=this.E^131072,this.t("avoidableMembers",i,t))}get memberParts(){return this.Kd.iterator}q2(t){if(this.Kd.add(t)){t instanceof Group&&this.ra.add(t);const e=this.memberAdded;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.Y,n.Y=!0),e(this,t),n!==null&&(n.Y=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ei(!1)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.It;i===null&&(i=this),i.c()}H2(t){if(this.Kd.delete(t)){t instanceof Group&&this.ra.delete(t);const e=this.memberRemoved;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.Y,n.Y=!0),e(this,t),n!==null&&(n.Y=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ei(!0)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.It;i===null&&(i=this),i.c()}Xc(){if(this.Kd.count>0){const t=this.diagram;if(t!==null){const e=this.Kd.copy().iterator;for(;e.next();){const s=e.value;t.remove(s)}}}super.Xc()}get layout(){return this.te}set layout(t){const i=this.te;if(i!==t){t!==null&&t.diagram!==null&&t.diagram.layout===t&&Util.o("A layout cannot be both the Diagram.layout and a Group.layout: "+t),i!==null&&(i.diagram=null,i.group=null),this.te=t;const e=this.diagram;t!==null&&(t.diagram=e,t.group=this),e!==null&&(e.Kr=!0),this.t("layout",i,t),e!==null&&e.requestUpdate()}}get memberAdded(){return this.gt!==null?this.gt.uy:null}set memberAdded(t){const i=this.memberAdded;i!==t&&(t!==null&&Util.i(t,"function",Group,"memberAdded"),this.cl(),this.gt.uy=t,this.t("memberAdded",i,t))}get memberRemoved(){return this.gt!==null?this.gt.gy:null}set memberRemoved(t){const i=this.memberRemoved;i!==t&&(t!==null&&Util.i(t,"function",Group,"memberRemoved"),this.cl(),this.gt.gy=t,this.t("memberRemoved",i,t))}get memberValidation(){return this.gt!==null?this.gt.eh:null}set memberValidation(t){const i=this.memberValidation;i!==t&&(t!==null&&Util.i(t,"function",Group,"memberValidation"),this.cl(),this.gt.eh=t,this.t("memberValidation",i,t))}canAddMembers(t){const i=this.diagram;if(i===null)return!1;const e=i.commandHandler,n=e.i2(t).iterator;for(;n.next();){const o=n.value;if(!e.isValidMember(this,o))return!1}return!0}addMembers(t,i){const e=this.diagram;if(e===null)return!1;const s=e.commandHandler,n=s.i2(t);let o=!0;const r=n.iterator;for(;r.next();){const l=r.value;!i||s.isValidMember(this,l)?l.containingGroup=this:o=!1}return o}get ungroupable(){return(this.E&256)!==0}set ungroupable(t){const i=(this.E&256)!==0;i!==t&&(Util.i(t,"boolean",Group,"ungroupable"),this.E=this.E^256,this.t("ungroupable",i,t))}canUngroup(){if(!this.ungroupable)return!1;const t=this.layer;if(t===null||!t.allowUngroup)return!1;const i=t.diagram;return!(i!==null&&!i.allowUngroup)}invalidateConnectedLinks(t){const i=this.xO();if(super.invalidateConnectedLinks(t),i)return;this.PL(!0);const e=this.findExternalLinksConnected();for(;e.next();){const s=e.value;if(t!==void 0&&t.has(s))continue;const n=s.fromNode;if(n!==null&&n!==this&&n.isMemberOf(this)&&!n.isVisible())n.ge(s.fromPort),n.ge(s.toPort),s.invalidateRoute();else{const o=s.toNode;o!==null&&o!==this&&o.isMemberOf(this)&&!o.isVisible()&&(o.ge(s.fromPort),o.ge(s.toPort),s.invalidateRoute())}}}findExternalLinksConnected(){const t=this.diagram!==null&&this.diagram.dS;if(t&&this.d0!==null)return this.d0.iterator;const i=this.findSubGraphParts();i.add(this);const e=new GSet,s=i.iterator;for(;s.next();){const n=s.value;if(!(n instanceof Node))continue;const o=n.linksConnected;for(;o.next();){const r=o.value;i.has(r)||e.add(r)}}return t&&(this.d0=e),e.iterator}findExternalNodesConnected(){const t=this.findSubGraphParts();t.add(this);const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;if(!(s instanceof Node))continue;const n=s.linksConnected;for(;n.next();){const o=n.value,r=o.fromNode;r!==null&&(!t.has(r)||r===this)&&i.add(r);const l=o.toNode;l!==null&&(!t.has(l)||l===this)&&i.add(l)}}return i.iterator}pE(){function t(e,s){e!==null&&(s.add(e),t(e.containingGroup,s))}const i=new GSet;return t(this,i),i}findSubGraphParts(){const t=new GSet;return Part.sh(t,this,!0,0,!0),t.delete(this),t}Ei(t){super.Ei(t);const i=this.memberParts;for(;i.next();)i.value.Ei(t)}collapseSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.hT(i,t,this),t.isCollapsingExpanding=!1}hT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ei(!1),n instanceof Group&&n.isSubGraphExpanded&&(n.wasSubGraphExpanded=n.isSubGraphExpanded,n.hT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t),i.Cc(n,e);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!1}expandSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.aT(i,t,this),t.isCollapsingExpanding=!1}aT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ei(!0),n instanceof Group&&n.wasSubGraphExpanded&&(n.wasSubGraphExpanded=!1,n.aT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!0}get isSubGraphExpanded(){return(this.E&512)!==0}set isSubGraphExpanded(t){const i=(this.E&512)!==0;if(i!==t){Util.i(t,"boolean",Group,"isSubGraphExpanded"),this.E=this.E^512;const e=this.diagram;this.t("isSubGraphExpanded",i,t);const s=this.subGraphExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.Y,e.Y=!0),s(this),e!==null&&(e.Y=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.It!==null&&this.It.c(),this.memberParts.each(n=>n.updateAdornments());return}t?this.expandSubGraph():this.collapseSubGraph()}}get wasSubGraphExpanded(){return(this.E&1024)!==0}set wasSubGraphExpanded(t){const i=(this.E&1024)!==0;i!==t&&(Util.i(t,"boolean",Group,"wasSubGraphExpanded"),this.E=this.E^1024,this.t("wasSubGraphExpanded",i,t))}get subGraphExpandedChanged(){return this.gt!==null?this.gt.my:null}set subGraphExpandedChanged(t){const i=this.subGraphExpandedChanged;i!==t&&(t!==null&&Util.i(t,"function",Group,"subGraphExpandedChanged"),this.cl(),this.gt.my=t,this.t("subGraphExpandedChanged",i,t))}move(t,i){i===void 0&&(i=!1);const e=i?this.location:this.position,s=e.x,n=e.y,o=t.x,r=t.y;if((s===o||isNaN(s)&&isNaN(o))&&(n===r||isNaN(n)&&isNaN(r)))return;const l=o-(isNaN(s)?0:s),h=r-(isNaN(n)?0:n),a=Point.l();super.move(t,i);const c=new GSet,u=this.findSubGraphParts().iterator;for(;u.next();){const d=u.value;d instanceof Link&&(d.suspendsRouting&&c.add(d),!(!d.Se&&(d.fromNode===this||d.toNode===this))&&(d.suspendsRouting=!0))}for(u.reset();u.next();){const d=u.value;if(d.Cl()||d instanceof Node&&d.isLinkLabel)continue;const m=d.position,g=d.location;m.isReal()?(a.x=m.x+l,a.y=m.y+h,d.position=a):g.isReal()&&(a.x=g.x+l,a.y=g.y+h,d.location=a)}for(u.reset();u.next();){const d=u.value;if(!(d instanceof Link)||(d.suspendsRouting=c.has(d),!d.Se&&(d.fromNode===this||d.toNode===this)))continue;const m=d.position;a.x=m.x+l,a.y=m.y+h,a.isReal()?d.move(a):d.invalidateRoute()}Point.s(a)}xO(){return(this.E&65536)!==0}PL(t){(this.E&65536)!==0!==t&&(this.E=this.E^65536)}get Jr(){return(this.E&32768)!==0}set Jr(t){(this.E&32768)!==0!==t&&(this.E=this.E^32768)}}class Placeholder extends GraphObject{$t;Yd;constructor(t){super(),this.$t=Margin.Ug,this.Yd=new Rect(NaN,NaN,NaN,NaN),t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.$t=this.$t.N(),t.Yd=this.Yd.copy()}lh(t){if(this.background===null)return!1;const i=this.naturalBounds;return Rect.contains(0,0,i.width,i.height,t.x,t.y)}_u(t,i,e,s){const n=this.part;if((n===null||!(n instanceof Group)&&!(n instanceof Adornment))&&Util.o("Placeholder is not inside a Group or Adornment."),n instanceof Group){const o=this.computeBorder(this.Yd),r=this.minSize,l=isFinite(r.width)?Math.max(r.width,o.width):o.width,h=isFinite(r.height)?Math.max(r.height,o.height):o.height,a=this.Vi;a.En(l||0,h||0),this.Qn(0,0,a.width,a.height);const c=n.memberParts;let f=!1;for(;c.next();)if(c.value.isVisible()){f=!0;break}const u=n.diagram;if(f&&u!==null&&!u.animationManager.CM(n)&&!isNaN(o.x)&&!isNaN(o.y)){const d=Point.l();d.setRectSpot(o,n.locationSpot),n.location=d,Point.s(d)}}else{const o=n,r=this.Vi,l=this.$t,h=l.left+l.right,a=l.top+l.bottom,c=o.adornedObject,f=c.getDocumentAngle();o.angle=f;let u=0;c instanceof Shape&&(u=c.strokeWidth);const d=c.getDocumentScale(),m=c.naturalBounds,g=(m.width+u)*d,p=(m.height+u)*d;if(o.type!==Panel.Link){const y=o.category==="Selection"?Spot.TopLeft:o.locationSpot,x=c.getDocumentPoint(y,Point.l());o.location=x,Point.s(x)}if(!isNaN(g)&&!isNaN(p))r.En(g+h||0,p+a||0),this.Qn(-l.left,-l.top,r.width,r.height);else{const y=c.getDocumentPoint(Spot.TopLeft,Point.l()),x=Rect.X(y.x,y.y,0,0);x.unionPoint(c.getDocumentPoint(Spot.BottomRight,y)),x.unionPoint(c.getDocumentPoint(Spot.TopRight,y)),x.unionPoint(c.getDocumentPoint(Spot.BottomLeft,y)),r.En(x.width+h||0,x.height+a||0),this.Qn(-l.left,-l.top,r.width,r.height),Point.s(y),Rect.s(x)}}}hh(t,i,e,s){this.actualBounds.e(t,i,e,s)}computeBorder(t){const i=this.part,e=i.diagram,s=e===null||!e.animationManager.isAnimating;if(e!==null&&i instanceof Group&&!i.layer.isTemporary&&i.computesBoundsAfterDrag&&this.Yd.isReal()){const l=e.toolManager.findTool("Dragging");if(l===e.currentTool){const h=l.computeBorder(i,this.Yd,t);if(h!==null)return h}}const n=Rect.l(),o=this.computeMemberBounds(n),r=this.$t;return i instanceof Group&&!i.isSubGraphExpanded?t.e(o.x-r.left,o.y-r.top,0,0):t.e(o.x-r.left,o.y-r.top,Math.max(o.width+r.left+r.right,0),Math.max(o.height+r.top+r.bottom,0)),Rect.s(n),s&&i instanceof Group&&i.computesBoundsIncludingLocation&&i.location.isReal()&&t.unionPoint(i.location),t}computeMemberBounds(t){if(!(this.part instanceof Group))return t.e(0,0,0,0),t;const i=this.part;let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=i.memberParts;for(;r.next();){const l=r.value;if(!l.isVisible()||l instanceof Link&&(!i.computesBoundsIncludingLinks||l.Oo()||l.fromNode===i||l.toNode===i))continue;const h=l.actualBounds;h.leftn&&(n=h.right),h.bottom>o&&(o=h.bottom)}if(!isFinite(e)||!isFinite(s)){const l=i.location;t.e(l.x,l.y,0,0)}else t.e(e,s,n-e,o-s);return t}get padding(){return this.$t}set padding(t){typeof t=="number"&&(t=new Margin(t));const i=this.$t;i.equals(t)||(t=t.N(),this.$t=t,this.t("padding",i,t),this.c())}}class Layout{p;la;Gd;kr;jd;Hd;Fo;ul;qd;Wd;go;constructor(t){GSet.Yi(this),this.p=null,this.la=null,this.Gd=!0,this.kr=!0,this.jd=!1,this.Hd=new Point(0,0).g(),this.Fo=!0,this.ul=null,this.qd=null,this.Wd=!1,this.go=null,t&&Object.assign(this,t)}cloneProtected(t){t.Gd=this.Gd,t.kr=this.kr,t.jd=this.jd,t.Hd.a(this.Hd),t.Fo=this.Fo,t.ul=this.ul,t.qd=this.qd,t.Wd=!0}copy(){const t=new this.constructor;return this.cloneProtected(t),t}ri(t){Util.lr(this,t)}toString(){let t=Util.sn(this.constructor);return t+="(",this.group!==null&&(t+=" in "+this.group),this.diagram!==null&&(t+=" for "+this.diagram),t+=")",t}get diagram(){return this.p}set diagram(t){this.p=t}get group(){return this.la}set group(t){this.la!==t&&(this.la=t,t!==null&&(this.p=t.diagram))}get isOngoing(){return this.Gd}set isOngoing(t){this.Gd!==t&&(Util.i(t,"boolean",Layout,"isOngoing"),this.Gd=t)}get isInitial(){return this.kr}set isInitial(t){Util.i(t,"boolean",Layout,"isInitial"),this.kr=t,t||(this.Wd=!0)}get isViewportSized(){return this.jd}set isViewportSized(t){this.jd!==t&&(Util.i(t,"boolean",Layout,"isViewportSized"),this.jd=t,t&&this.invalidateLayout())}get isRouting(){return this.Fo}set isRouting(t){this.Fo!==t&&(Util.i(t,"boolean",Layout,"isRouting"),this.Fo=t)}get isRealtime(){return this.ul}set isRealtime(t){this.ul!==t&&(t!==null&&Util.i(t,"boolean",Layout,"isRealtime"),this.ul=t)}get isValidLayout(){return this.Wd}set isValidLayout(t){if(this.Wd!==t&&(Util.i(t,"boolean",Layout,"isValidLayout"),this.Wd=t,!t)){const i=this.diagram;i!==null&&(i.Kr=!0)}}invalidateLayout(){if(this.isValidLayout){const t=this.diagram;if(t===null||t.undoManager.isUndoingRedoing)return;const i=t.animationManager;if(i.isTicking)return;i.defaultAnimation.isAnimating&&i.stopAnimation(),(this.isOngoing&&t.Eh||this.isInitial&&!t.Eh)&&(this.isValidLayout=!1,t.requestUpdate())}}get network(){return this.go}set network(t){this.go!==t&&(this.go=t,t!==null&&(t.layout=this))}createNetwork(){return new LayoutNetwork(this)}makeNetwork(t){const i=this.createNetwork();return t instanceof Diagram?(i.addParts(t.nodes,!0),i.addParts(t.links,!0)):t instanceof Group?i.addParts(t.memberParts):i.addParts(t.iterator),i}updateParts(){this.isValidLayout=!0;let t=this.diagram;if(t===null&&this.network!==null){const i=this.network.vertexes.iterator;for(;i.next();){const s=i.value.node;if(s!==null&&(t=s.diagram,t!==null))break}}try{t!==null&&t.startTransaction("Layout"),this.commitLayout()}finally{t!==null&&t.commitTransaction("Layout")}}commitLayout(){if(this.network===null)return;const t=this.network.vertexes.iterator;for(;t.next();)t.value.commit();if(this.isRouting){const i=this.network.edges.iterator;for(;i.next();)i.value.commit()}}doLayout(t){const i=new GSet;if(t instanceof Diagram?(this.bh(i,t.nodes,!0,this.Jr,!0,!1,!0),this.bh(i,t.parts,!0,this.Jr,!0,!1,!0)):t instanceof Group?this.bh(i,t.memberParts,!1,this.Jr,!0,!1,!0):i.addAll(t.iterator),i.count>0){const s=this.diagram;s!==null&&s.startTransaction("Layout"),this.doMinimalNoNetworkLayout(i),s!==null&&s.commitTransaction("Layout")}this.isValidLayout=!0}doMinimalNoNetworkLayout(t){const i=t.count,e=Math.ceil(Math.sqrt(i));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const s=this.arrangementOrigin.x,n=this.arrangementOrigin.y;let o=s,r=n,l=0,h=0;const a=t.iterator;for(;a.next();){const c=a.value;c.ensureBounds();const f=c.measuredBounds,u=f.width,d=f.height;c.moveTo(o,r),c instanceof Group&&(c.Jr=!1),o+=Math.max(u,50)+20,h=Math.max(h,Math.max(d,50)),l>=e-1?(l=0,o=s,r+=h+20,h=0):l++}}doMinimalNetworkLayout(){const t=this.network.vertexes.count,i=Math.ceil(Math.sqrt(t));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const e=this.arrangementOrigin.x,s=this.arrangementOrigin.y;let n=e,o=s,r=0,l=0;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value.node;if(a===null||a instanceof Link||(a.ensureBounds(),!this.Jr(a)))continue;const c=a.measuredBounds,f=c.width,u=c.height;a.moveTo(n,o),a instanceof Group&&(a.Jr=!1),n+=Math.max(f,50)+20,l=Math.max(l,Math.max(u,50)),r>=i-1?(r=0,n=e,o+=l+20,l=0):r++}}Jr(t){return!!(!t.location.isReal()&&!t.position.isReal()||t instanceof Group&&t.Jr)}bh(t,i,e,s,n,o,r){const l=i.iterator;for(;l.next();){const h=l.value;if(!(e&&!h.isTopLevel)&&!(s!==null&&!s(h))&&h.canLayout())if(n&&h instanceof Node){if(h.isLinkLabel)continue;h instanceof Group&&h.layout===null?this.bh(t,h.memberParts,!1,s,n,o,r):(h.ensureBounds(),t.add(h))}else o&&h instanceof Link?t.add(h):r&&h.Pe()&&!(h instanceof Node)&&(h.ensureBounds(),t.add(h))}}getLayoutBounds(t,i){const e=this.boundsComputation;return e!==null?(i||(i=new Rect),e(t,this,i)):!i&&t.margin.equalTo(0,0,0,0)?t.actualBounds:(i||(i=new Rect),i.set(t.actualBounds),i.addMargin(t.margin),i)}get boundsComputation(){return this.qd}set boundsComputation(t){this.qd!==t&&(t!==null&&Util.i(t,"function",Layout,"boundsComputation"),this.qd=t,this.invalidateLayout())}collectParts(t){const i=new GSet;return t instanceof Diagram?(this.bh(i,t.nodes,!0,null,!0,!0,!0),this.bh(i,t.links,!0,null,!0,!0,!0),this.bh(i,t.parts,!0,null,!0,!0,!0)):t instanceof Group?this.bh(i,t.memberParts,!1,null,!0,!0,!0):this.bh(i,t.iterator,!1,null,!0,!0,!0),i}get arrangementOrigin(){return this.Hd}set arrangementOrigin(t){this.Hd.equals(t)||(this.Hd.a(t),this.invalidateLayout())}initialOrigin(t){const i=this.group;if(i!==null)if(i.hasPlaceholder()){const e=i.placeholder,s=e.getDocumentPoint(Spot.TopLeft);(isNaN(s.x)||isNaN(s.y))&&s.set(t);const n=e.padding;return s.x+=n.left,s.y+=n.top,s}else{const e=i.position.copy();return(isNaN(e.x)||isNaN(e.y))&&e.set(t),e}return t}}class LayoutNetwork{te;mo;Cn;ky;Py;constructor(t){GSet.Yi(this),this.te=t,this.mo=new GSet,this.Cn=new GSet,this.ky=new GMap,this.Py=new GMap}clear(){if(this.mo){const t=this.mo.iterator;for(;t.next();)t.value.clear()}if(this.Cn){const t=this.Cn.iterator;for(;t.next();)t.value.clear()}this.mo=new GSet,this.Cn=new GSet,this.ky=new GMap,this.Py=new GMap}toString(t){t===void 0&&(t=0);let i="LayoutNetwork"+(this.layout!==null?"("+this.layout.toString()+")":"");if(t<=0)return i;if(i+=" vertexes: "+this.mo.count+" edges: "+this.Cn.count,t>1){const e=this.mo.iterator;for(;e.next();){const n=e.value;i+=` +`);if(t.length===0)return 8;if(this.isMultiline){let i=0,e=0,s=!1;for(;!s;){let n=this.t1(t,e);n===-1&&(n=t.length,s=!0);let o=t.substring(e,n);this.formatting===0&&(o=o.trim()),i=Math.max(i,this.getStringWidth(o)),e=n+1}return i}else{const i=this.t1(t,0);return i>=0&&(t=t.substring(0,i)),this.getStringWidth(t)}}get textValidation(){return this.W!==null?this.W.Tl:null}set textValidation(t){const i=this.textValidation;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"textValidation"),this.Mn(),this.W.Tl=t,this.t("textValidation",i,t))}get textEdited(){return this.W!==null?this.W.Dp:null}set textEdited(t){const i=this.textEdited;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"textEdited"),this.Mn(),this.W.Dp=t,this.t("textEdited",i,t))}get spacingAbove(){return this.W!==null?this.W.Fp:0}set spacingAbove(t){const i=this.spacingAbove;i!==t&&(this.Mn(),this.W.Fp=t,this.c(),this.t("spacingAbove",i,t))}get spacingBelow(){return this.W!==null?this.W.Rp:0}set spacingBelow(t){const i=this.spacingBelow;i!==t&&(this.Mn(),this.W.Rp=t,this.c(),this.t("spacingBelow",i,t))}get formatting(){return this.W!==null?this.W.vp:0}set formatting(t){const i=this.formatting;i!==t&&(this.Mn(),this.W.vp=t,this.c(),this.t("formatting",i,t))}get maxLines(){return this.W!==null?this.W.Op:1/0}set maxLines(t){const i=this.maxLines;i!==t&&(t=Math.floor(t),t<=0&&Util._(t,"> 0",TextBlock,"maxLines"),this.Mn(),this.W.Op=t,this.c(),this.t("maxLines",i,t))}getMetrics(){return[this.mi,this.Dl,this.oo,this.Pn,this.Le,this.Di,this.Sn]}Pv(t){t!==void 0&&(this.mi=t[0],this.Dl=t[1],this.oo=t[2],this.Pn=t[3],this.Le=t[4],this.Di=t[5],this.Sn=t[6])}get metrics(){return{arrSize:this.Le!==null?this.Le:[this.mi],arrText:this.Di!==null?this.Di:[this.Sn],maxLineWidth:this.mi,fontHeight:this.oo}}get choices(){return this.Sd}set choices(t){const i=this.Sd;i!==t&&(this.Sd=t,this.t("choices",i,t))}static Lv=new RegExp("[ \u200B\xAD]");static V2=new PropertyCollection;static IA=0;static Zb=new PropertyCollection;static E2=0;static Sp="...";static vA="";static il=Diagram.isUsingDOM()?new CanvasSurface(null).ai:null}class TextBlockTemplateSettings{gi;os;ro;vp;Op;Cp;Fp;Rp;Mp;Dp;Ap;Tl;sl;Np;constructor(){this.gi=!1,this.os=null,this.ro=0,this.vp=0,this.Op=1/0,this.Cp=0,this.Fp=0,this.Rp=0,this.Mp="start",this.Dp=null,this.Ap=null,this.Tl=null,this.sl=Spot.Top,this.Np=2}copy(){const t=new TextBlockTemplateSettings;return t.os=this.os,t.ro=this.ro,t.vp=this.vp,t.Op=this.Op,t.Cp=this.Cp,t.Fp=this.Fp,t.Rp=this.Rp,t.Mp=this.Mp,t.Dp=this.Dp,t.Ap=this.Ap,t.Tl=this.Tl,t.sl=this.sl,t.Np=this.Np,t}}class GradElementSettings{uf;df;gf;Tp;mf;constructor(){this.uf=1,this.df=0,this.gf=1,this.Tp=null,this.mf=null}copy(){const t=new GradElementSettings;return t.uf=this.uf,t.df=this.df,t.gf=this.gf,t.Tp=this.Tp,t.mf=this.mf,t}}var ImageStretch=(w=>(w[w.None=0]="None",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ImageStretch||{});class Picture extends GraphObject{nl;yt;ol;pf;os;rl;yf;ro;wf;xf;Ib;constructor(t,i){super(),this.n|=2097152,this.nl=null,this.yt="",this.ol=Rect.AD,this.pf=2,this.os=null,this.rl=null,this.yf=Spot.Center,this.ro=0,this.wf=null,this.xf=null,this.Ib=null,typeof t=="string"?this.source=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.yt=this.yt,t.element=this.nl,t.ol=this.ol.N(),t.pf=this.pf,t.ro=this.ro,t.os=this.os,t.rl=this.rl,t.yf=this.yf.N(),t.xf=this.xf}ri(t){t in ImageStretch?this.imageStretch=t:super.ri(t)}toString(){return"Picture("+this.source+")#"+GSet.as(this)}get bf(){return(this.n&1048576)!==0}set bf(t){this.bf!==t&&(this.n=this.n^1048576)}get Ip(){return(this.n&2097152)!==0}set Ip(t){this.Ip!==t&&(this.n=this.n^2097152)}get mn(){return(this.n&4194304)!==0}set mn(t){this.mn!==t&&(this.n=this.n^4194304)}static clearCache(t){t===void 0&&(t=""),Util.i(t,"string",Picture,"clearCache:url"),t!==""?Picture.Ep[t]&&(delete Picture.Ep[t],Picture.i1--):(Picture.Ep=new PropertyCollection,Picture.i1=0)}static OL(t,i){i.EA||(i.e1=e=>{Picture.Av(i,e),t.desiredSize.isReal()||(t.ue(!1),t.c())},i.s1=e=>Picture.Tv(i,e),i.addEventListener("load",i.e1),i.addEventListener("error",i.s1),i.EA=!0)}static mR(t){t.e1&&t.removeEventListener("load",t.e1),t.s1&&t.removeEventListener("error",t.s1),delete t.e1,delete t.s1,delete t.EA}get element(){return this.nl}set element(t){const i=this.nl;if(this.ss(!0),i!==t){this.bf=t instanceof HTMLCanvasElement;const e=t instanceof HTMLImageElement;t!==null&&!(e||t instanceof HTMLVideoElement||this.bf)&&Util.o("Picture.element must be an instance of Image, Canvas, or Video, not: "+t);const s=this.diagram;s!==null&&s.DM(this),this.nl=t,t!==null&&e&&t.es===void 0&&(t.es=new GSet),s!==null&&e&&s.TM(this),this.t("element",i,t),this.C()}}dR(){const t=this.nl;if(t===null)return;const i=this.desiredSize.isReal();(this.bf||t.complete===!0)&&(t.c0&&(t.Bp instanceof Event&&this.os!==null?this.os(this,t.Bp):t.mn===!0&&!t.Bp&&this.rl!==null&&t.z2&&this.rl(this,t.z2)),t.mn=!0),t.mn&&i&&this.diagram!==null&&this.diagram.zu.add(this)}Dv(){if(this.nl===null){this.wf=!1;return}const t=new CanvasSurface(null).ai;try{t.drawImage(this.nl,0,0)}catch{this.Ip=!1}try{t.getImageData(0,0,1,1).data[3]&&(this.wf=!1),this.wf=!1}catch{this.wf=!0}}get source(){return this.yt}set source(t){const i=this.yt;if(i!==t){this.ss(!0),Util.i(t,"string",Picture,"source"),this.yt=t;let e=Picture.Ep;if(!Diagram.isUsingDOM()){this.t("source",i,t);return}let s=null;if(e[t]!==void 0)s=e[t];else if(t!==""){Picture.i1>30&&(Picture.clearCache(),e=Picture.Ep),s=Util.en("img"),s.c0=!0,Picture.OL(this,s);const n=this.xf;n!==null&&(s.crossOrigin=n(this)),s.src=t,e[t]=s,Picture.i1++}this.element=s,s!==null&&s.__goCache===void 0&&(s.__goCache=new PictureCacheArray),this.c(),this.C(),this.t("source",i,t)}}static Av(t,i){t.mn=!0,t.Bp=!1;let e;const s=t.es.copy();if(s==null)return;const n=s.iterator;for(;n.next();){const o=n.value;o.C();const r=t.getAttribute("src")||"",l=o.Jl.get(r);if(l===null)continue;const h=l.length;for(let a=0;a=o.width&&(r=r+p.offsetX+(d*p.x-o.width*p.x)),m>=o.height&&(l=l+p.offsetY+(m*p.y-o.height*p.y)),a=Math.min(o.width,d),c=Math.min(o.height,m);break;case 2:d=o.width,m=o.height;break;case 6:case 7:let A=0;g===6?(A=Math.min(o.height/m,o.width/d),d*=A,m*=A):g===7&&(A=Math.max(o.height/m,o.width/d),d*=A,m*=A,d>=o.width&&(r=(r+p.offsetX+(d*p.x-o.width*p.x)/d)*a),m>=o.height&&(l=(l+p.offsetY+(m*p.y-o.height*p.y)/m)*c),a*=1/(d/o.width),c*=1/(m/o.height),d=o.width,m=o.height);break}const y=a*c,x=this.getDocumentScale()*i.scale,k=d*x,b=m*x,P=k*b,S=y/P,L=e.__goCache;let C=null;const M=Picture.Fv;if(!n){if(e.mn&&L!==void 0&&P>4&&S>M*M){L.Ot===null&&(L.BA(4,f,u,e),L.BA(16,f,u,e));const A=L.Ot,D=A.length;for(let F=0;F0){const c=this.Ot[this.Ot.length-1];h=c.yt,a=c.Nd}o.setTransform(r*a,0,0,r*a,0,0),o.commitTransform(),o.drawImage(h,0,0),this.Ot.push(l)}}class PictureCacheInstance{yt;Nd;constructor(t,i){this.yt=t,this.Nd=i}}class GeoStream{Pi;Hg;constructor(){this.Hg=new Geometry,this.Pi=null}Ri(t){t!==null?(t.ot(),this.Hg=t,t.figures.clear()):this.Hg=new Geometry,this.Pi=null}fu(t,i,e,s,n,o){if(s!==void 0&&s===!0){const r=new PathSegment(1);r.endX=t,r.endY=i,this.Pi.segments.add(r)}else this.Pi=new PathFigure,this.Pi.startX=t,this.Pi.startY=i,this.Pi.isFilled=e,this.Pi.isEvenOdd=o||!1,this.Hg.figures.add(this.Pi);n!==void 0&&(this.Pi.isShadowed=n)}UD(){const t=this.Pi.segments.length;t>0&&this.Pi.segments.elt(t-1).close()}VD(){this.Pi.segments.length>0&&(this.Pi.isFilled=!0)}zD(t){this.Pi.isShadowed=t}gE(t){this.Pi.isEvenOdd=t}ID(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(1);s.endX=t,s.endY=i,e&&s.close(),this.Pi.segments.add(s)}ur(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(2);s.endX=t,s.endY=i,e&&s.close(),this.Pi.segments.add(s)}dr(t,i,e,s,n,o,r){r===void 0&&(r=!1);const l=new PathSegment(3);l.point1X=t,l.point1Y=i,l.point2X=e,l.point2Y=s,l.endX=n,l.endY=o,r&&l.close(),this.Pi.segments.add(l)}Mw(t,i,e,s,n){n===void 0&&(n=!1);const o=new PathSegment(4);o.point1X=t,o.point1Y=i,o.endX=e,o.endY=s,n&&o.close(),this.Pi.segments.add(o)}ED(t,i,e,s,n,o,r){o===void 0&&(o=0),r===void 0&&(r=!1);const l=new PathSegment(5);l.startAngle=t,l.sweepAngle=i,l.centerX=e,l.centerY=s,l.radiusX=n,o!==0?l.radiusY=o:l.radiusY=n,r&&l.close(),this.Pi.segments.add(l)}BD(t,i,e,s,n,o,r,l){l===void 0&&(l=!1);const h=new PathSegment(6,o,r,t,i,e,s,n);l&&h.close(),this.Pi.segments.add(h)}static X2=null;static mC(t){const i=GeoStream.X2;if(i!==null)return GeoStream.X2=null,i.Ri(t),i;{const e=new GeoStream;return e.Ri(t),e}}static pC(t){GeoStream.X2=t}}{const w=function(n,o){const r=n.toLowerCase(),l=Geo.So;l[n]=o,l[r]=n};w("Rectangle",(n,o,r)=>{const l="r"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,Geo.fr{const l="s"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,h.defaultStretch=6,Geo.fr{(isNaN(l)||l<0)&&(l=5),isNaN(h)&&(h=15);const a="rr"+o+","+r+","+l+","+h;let c=Geo.cr[a];if(c!==void 0)return c;let f=l;(h&1)===1?(f=Math.min(f,(h&2)===2?o/3:o),f=Math.min(f,(h&8)===8?r/3:r)):f=0;const u=new PathFigure(f,0,!0);c=new Geometry().add(u);const d=Spot.TopLeft.copy(),m=Spot.BottomRight.copy();if((h&2)===2){let g=l;g=Math.min(g,(h&1)===1?o/3:o),g=Math.min(g,(h&4)===4?r/3:r);const p=g*Geo.Bn;u.add(new PathSegment(2,o-g,0)).add(new PathSegment(3,o,g,o-p,0,o,p)),d.offsetY=p,m.offsetX=-p}else u.add(new PathSegment(2,o,0));if((h&4)===4){let g=l;g=Math.min(g,(h&8)===8?o/3:o),g=Math.min(g,(h&2)===2?r/3:r);const p=g*Geo.Bn;u.add(new PathSegment(2,o,r-g)).add(new PathSegment(3,o-g,r,o,r-p,o-p,r)),m.offsetX=-p,m.offsetY=-p}else u.add(new PathSegment(2,o,r));if((h&8)===8){let g=l;g=Math.min(g,(h&4)===4?o/3:o),g=Math.min(g,(h&1)===1?r/3:r);const p=g*Geo.Bn;u.add(new PathSegment(2,g,r)).add(new PathSegment(3,0,r-g,p,r,0,r-p)),d.offsetX=p,m.offsetY=-p}else u.add(new PathSegment(2,0,r));if((h&1)===1){const g=f*Geo.Bn;u.add(new PathSegment(2,0,f)).add(new PathSegment(3,f,0,0,g,g,0).close()),d.offsetX=g,d.offsetY=g}else u.add(new PathSegment(2,0,0).close());return c.spot1=d,c.spot2=m,Geo.fr{const l=n?n.parameter1:NaN,h=n?n.parameter2:NaN;return t(n,o,r,l,h)}),w("Border","RoundedRectangle"),w("RoundedTopRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,3)}),w("RoundedBottomRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,12)}),w("RoundedLeftRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,9)}),w("RoundedRightRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,6)}),w("Ellipse",(n,o,r)=>{const l="e"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Rk,h.spot2=Spot.vk,Geo.fr{const l="c"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Rk,h.spot2=Spot.vk,h.defaultStretch=6,Geo.frnew Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,.5*r)).add(new PathSegment(2,0,r).close())).setSpots(0,.25,.5,.75)),w("TriangleDown",(n,o,r)=>new Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,0)).add(new PathSegment(2,.5*o,r).close())).setSpots(.25,0,.75,.5)),w("TriangleLeft",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,o,0).close())).setSpots(.5,.25,1,.75)),w("TriangleUp",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,r)).add(new PathSegment(2,.5*o,0).close())).setSpots(.25,.5,.75,1)),w("Triangle","TriangleUp"),w("Diamond",(n,o,r)=>new Geometry().add(new PathFigure(.5*o,0).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,.5*o,r)).add(new PathSegment(2,o,.5*r).close())).setSpots(.25,.25,.75,.75)),w("LineH",(n,o,r)=>{const l=new Geometry(1);return l.startX=0,l.startY=r/2,l.endX=o,l.endY=r/2,l}),w("LineV",(n,o,r)=>{const l=new Geometry(1);return l.startX=o/2,l.startY=0,l.endX=o/2,l.endY=r,l}),w("None","Rectangle"),w("BarH","Rectangle"),w("BarV","Rectangle"),w("MinusLine","LineH"),w("PlusLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r/2,!1).add(new PathSegment(2,o,r/2)).add(new PathSegment(1,o/2,0)).add(new PathSegment(2,o/2,r)))),w("XLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r,!1).add(new PathSegment(2,o,0)).add(new PathSegment(1,0,0)).add(new PathSegment(2,o,r)))),w("LineRight",(n,o,r)=>new Geometry().add(new PathFigure(.25*o,0,!1).add(new PathSegment(2,.75*o,.5*r)).add(new PathSegment(2,.25*o,r)))),w("LineDown",(n,o,r)=>new Geometry().add(new PathFigure(0,.25*r,!1).add(new PathSegment(2,.5*o,.75*r)).add(new PathSegment(2,o,.25*r)))),w("LineLeft",(n,o,r)=>new Geometry().add(new PathFigure(.75*o,0,!1).add(new PathSegment(2,.25*o,.5*r)).add(new PathSegment(2,.75*o,r)))),w("LineUp",(n,o,r)=>new Geometry().add(new PathFigure(0,.75*r,!1).add(new PathSegment(2,.5*o,.25*r)).add(new PathSegment(2,o,.75*r)))),w("Capsule",(n,o,r)=>{const l=new Geometry;if(or){const h=r/2,a=new PathFigure(h,0,!0);l.add(a),a.add(new PathSegment(2,o-h,0)),a.add(new PathSegment(5,270,180,o-h,h,h,h)),a.add(new PathSegment(2,h,r)),a.add(new PathSegment(5,90,180,h,h,h,h));const c=isFinite(n.parameter1)?n.parameter1:r*.156;return l.spot1=new Spot(0,0,c,0),l.spot2=new Spot(1,1,-c,0),l}else return l.type=3,l.endX=o,l.endY=r,l.spot1=Spot.Rk,l.spot2=Spot.vk,l});const i=(n,o)=>new PathFigure(n,o,!1,!1),e=(n,o,r)=>n.add(new PathSegment(2,o,r)),s=(n,o,r)=>n.add(new PathSegment(1,o,r));w("Borders",(n,o,r)=>{let l=n?n.parameter1:NaN;isNaN(l)?l=10:l=l&15;const h=new Geometry;let a;return l===10?(a=i(o,0),e(a,o,r),s(a,0,r),e(a,0,0)):l===5?(a=i(0,0),e(a,o,0),s(a,o,r),e(a,0,r)):l===1?(a=i(0,0),e(a,o,0),s(a,o,r)):l===2?(a=i(o,0),e(a,o,r)):l===4?(a=i(o,r),e(a,0,r)):l===8?(a=i(0,r),e(a,0,0),s(a,o,r)):l===3?(a=i(0,0),e(a,o,0),e(a,o,r)):l===6?(a=i(o,0),e(a,o,r),e(a,0,r)):l===12?(a=i(o,r),e(a,0,r),e(a,0,0)):l===9?(a=i(0,r),e(a,0,0),e(a,o,0)):l===7?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r)):l===14?(a=i(o,0),e(a,o,r),e(a,0,r),e(a,0,0)):l===13?(a=i(o,r),e(a,0,r),e(a,0,0),e(a,o,0)):l===11?(a=i(0,r),e(a,0,0),e(a,o,0),e(a,o,r)):l===15?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r),a.add(new PathSegment(2,0,0).close())):(a=i(0,0),s(a,o,r)),h.add(a),h})}Geo.Xg={"":"",Standard:"F1 m 0,0 l 8,4 -8,4 2,-4 z",Backward:"F1 m 8,0 l -2,4 2,4 -8,-4 z",Triangle:"F1 m 0,0 l 8,4.62 -8,4.62 z",BackwardTriangle:"F1 m 8,4 l 0,4 -8,-4 8,-4 0,4 z",Boomerang:"F1 m 0,0 l 8,4 -8,4 4,-4 -4,-4 z",BackwardBoomerang:"F1 m 8,0 l -8,4 8,4 -4,-4 4,-4 z",SidewaysV:"m 0,0 l 8,4 -8,4 0,-1 6,-3 -6,-3 0,-1 z",BackwardV:"m 8,0 l -8,4 8,4 0,-1 -6,-3 6,-3 0,-1 z",OpenTriangle:"m 0,0 l 8,4 -8,4",BackwardOpenTriangle:"m 8,0 l -8,4 8,4",OpenTriangleLine:"m 0,0 l 8,4 -8,4 m 8.5,0 l 0,-8",BackwardOpenTriangleLine:"m 8,0 l -8,4 8,4 m -8.5,0 l 0,-8",OpenTriangleTop:"m 0,0 l 8,4 m 0,4",BackwardOpenTriangleTop:"m 8,0 l -8,4 m 0,4",OpenTriangleBottom:"m 0,8 l 8,-4",BackwardOpenTriangleBottom:"m 0,4 l 8,4",HalfTriangleTop:"F1 m 0,0 l 0,4 8,0 z m 0,8",BackwardHalfTriangleTop:"F1 m 8,0 l 0,4 -8,0 z m 0,8",HalfTriangleBottom:"F1 m 0,4 l 0,4 8,-4 z",BackwardHalfTriangleBottom:"F1 m 8,4 l 0,4 -8,-4 z",ForwardSemiCircle:"m 4,0 b 270 180 0 4 4",BackwardSemiCircle:"m 4,8 b 90 180 0 -4 4",Feather:"m 0,0 l 3,4 -3,4",BackwardFeather:"m 3,0 l -3,4 3,4",DoubleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardDoubleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4",TripleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardTripleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4 m 3,-8 l -3,4 3,4",ForwardSlash:"m 0,8 l 5,-8",BackSlash:"m 0,0 l 5,8",DoubleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8",DoubleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8",TripleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8 m -2,8 l 4,-8",TripleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8 m -2,-8 l 4,8",Fork:"m 0,4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4",LineFork:"m 0,0 l 0,8 m 0,-4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardLineFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4 m 8,-8 l 0,8",CircleFork:"F1 m 6,4 b 0 360 -3 0 3 z m 0,0 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 6,0 b 0 360 -3 0 3",CircleLineFork:"F1 m 6,4 b 0 360 -3 0 3 z m 1,-4 l 0,8 m 0,-4 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleLineFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 0,-4 l 0,8 m 7,-4 b 0 360 -3 0 3",Circle:"F1 m 8,4 b 0 360 -4 0 4 z",Block:"F1 m 0,0 l 0,8 8,0 0,-8 z",StretchedDiamond:"F1 m 0,3 l 5,-3 5,3 -5,3 -5,-3 z",Diamond:"F1 m 0,4 l 4,-4 4,4 -4,4 -4,-4 z",Chevron:"F1 m 0,0 l 5,0 3,4 -3,4 -5,0 3,-4 -3,-4 z",StretchedChevron:"F1 m 0,0 l 8,0 3,4 -3,4 -8,0 3,-4 -3,-4 z",NormalArrow:"F1 m 0,2 l 4,0 0,-2 4,4 -4,4 0,-2 -4,0 z",X:"m 0,0 l 8,8 m 0,-8 l -8,8",TailedNormalArrow:"F1 m 0,0 l 2,0 1,2 3,0 0,-2 2,4 -2,4 0,-2 -3,0 -1,2 -2,0 1,-4 -1,-4 z",DoubleTriangle:"F1 m 0,0 l 4,4 -4,4 0,-8 z m 4,0 l 4,4 -4,4 0,-8 z",BigEndArrow:"F1 m 0,0 l 5,2 0,-2 3,4 -3,4 0,-2 -5,2 0,-8 z",ConcaveTailArrow:"F1 m 0,2 h 4 v -2 l 4,4 -4,4 v -2 h -4 l 2,-2 -2,-2 z",RoundedTriangle:"F1 m 0,1 a 1,1 0 0 1 1,-1 l 7,3 a 0.5,1 0 0 1 0,2 l -7,3 a 1,1 0 0 1 -1,-1 l 0,-6 z",SimpleArrow:"F1 m 1,2 l -1,-2 2,0 1,2 -1,2 -2,0 1,-2 5,0 0,-2 2,2 -2,2 0,-2 z",AccelerationArrow:"F1 m 0,0 l 0,8 0.2,0 0,-8 -0.2,0 z m 2,0 l 0,8 1,0 0,-8 -1,0 z m 3,0 l 2,0 2,4 -2,4 -2,0 0,-8 z",BoxArrow:"F1 m 0,0 l 4,0 0,2 2,0 0,-2 2,4 -2,4 0,-2 -2,0 0,2 -4,0 0,-8 z",TriangleLine:"F1 m 8,4 l -8,-4 0,8 8,-4 z m 0.5,4 l 0,-8",CircleEndedArrow:"F1 m 10,4 l -2,-3 0,2 -2,0 0,2 2,0 0,2 2,-3 z m -4,0 b 0 360 -3 0 3 z",DynamicWidthArrow:"F1 m 0,3 l 2,0 2,-1 2,-2 2,4 -2,4 -2,-2 -2,-1 -2,0 0,-2 z",EquilibriumArrow:"m 0,3 l 8,0 -3,-3 m 3,5 l -8,0 3,3",FastForward:"F1 m 0,0 l 3.5,4 0,-4 3.5,4 0,-4 1,0 0,8 -1,0 0,-4 -3.5,4 0,-4 -3.5,4 0,-8 z",Kite:"F1 m 0,4 l 2,-4 6,4 -6,4 -2,-4 z",HalfArrowTop:"F1 m 0,0 l 4,4 4,0 -8,-4 z m 0,8",HalfArrowBottom:"F1 m 0,8 l 4,-4 4,0 -8,4 z",OpposingDirectionDoubleArrow:"F1 m 0,4 l 2,-4 0,2 4,0 0,-2 2,4 -2,4 0,-2 -4,0 0,2 -2,-4 z",PartialDoubleTriangle:"F1 m 0,0 4,3 0,-3 4,4 -4,4 0,-3 -4,3 0,-8 z",LineCircle:"F1 m 0,0 l 0,8 m 7 -4 b 0 360 -3 0 3 z",DoubleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",TripleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",CircleLine:"F1 m 6 4 b 0 360 -3 0 3 z m 1,-4 l 0,8",DiamondCircle:"F1 m 8,4 l -4,4 -4,-4 4,-4 4,4 m 8,0 b 0 360 -4 0 4 z",PlusCircle:"F1 m 8,4 b 0 360 -4 0 4 l -8 0 z m -4 -4 l 0 8",OpenRightTriangleTop:"m 8,0 l 0,4 -8,0 m 0,4",OpenRightTriangleBottom:"m 8,8 l 0,-4 -8,0",Line:"m 0,0 l 0,8",DoubleLine:"m 0,0 l 0,8 m 2,0 l 0,-8",TripleLine:"m 0,0 l 0,8 m 2,0 l 0,-8 m 2,0 l 0,8",PentagonArrow:"F1 m 8,4 l -4,-4 -4,0 0,8 4,0 4,-4 z"};var LayoutConditions=(w=>(w[w.None=0]="None",w[w.Added=1]="Added",w[w.Removed=2]="Removed",w[w.Shown=4]="Shown",w[w.Hidden=8]="Hidden",w[w.NodeSized=16]="NodeSized",w[w.GroupLayout=32]="GroupLayout",w[w.NodeReplaced=64]="NodeReplaced",w[w.Standard=127]="Standard",w[w.All=16777215]="All",w))(LayoutConditions||{});class Part extends Panel{P;Ho;F;ll;hl;qo;hi;Wo;ph;js;Jo;Cd;BS;UA;Up;Vp;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.P=2408959,this.Ho="",this.F=null,this.ll="",this.hl=null,this.qo=null,this.hi="",this.Wo=null,this.ph=null,this.js=new Point(NaN,NaN).g(),this.Jo=null,this.Cd=NaN,this.BS=-1,this.UA=new Rect,this.Up=null,this.Vp=NaN,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.P=this.P&-4097|16384|32768,t.Ho=this.Ho,this.F!==null&&(this.F.gi?t.F=this.F:t.F=this.F.copy()),t.ll=this.ll,t.qo=null,t.hi=this.hi,t.js.a(this.js),t.Cd=this.Cd}Vo(t){super.Vo(t),t.ch(),t.hl=null,t.Jo=null,t.Up=null}toString(){let t=Util.sn(this.constructor)+"#"+GSet.as(this);return this.data!==null&&(t+="("+Util.toString(this.data)+")"),t}static LayoutNone=0;static LayoutAdded=1;static LayoutRemoved=2;static LayoutShown=4;static LayoutHidden=8;static LayoutNodeSized=16;static LayoutGroupLayout=32;static LayoutNodeReplaced=64;static LayoutStandard=127;static LayoutAll=16777215;qi(){this.F===null?this.F=new PartTemplateSettings:this.F.gi&&(this.F=this.F.copy())}lh(){super.lh(),this.F!==null&&(this.F.gi=!0)}Jc(t,i,e,s,n,o,r){const l=this.diagram;l!==null&&(t===3&&i==="elements"?n instanceof Panel?n.qr(h=>{l.partManager.SM(h,l)}):n instanceof Picture&&l.TM(n):t===4&&i==="elements"&&(n instanceof Panel?n.qr(h=>l.partManager.MM(h,l)):n instanceof Picture&&l.DM(n)),l.raiseChangedEvent(t,i,e,s,n,o,r))}updateTargetBindings(t){if(super.updateTargetBindings(t),this.data===null)return;const i=this.L.r,e=i.length;for(let n=0;n{r.data!==null&&r.updateTargetBindings()})}const s=this.adornments;for(;s.next();)s.value.updateTargetBindings(t)}Io(){if(super.Io(),this.d2()){const i=this.L.r,e=i.length;for(let s=0;so.Io())}}const t=this.adornments;for(;t.next();)t.value.Io()}updateRelationshipsFromData(){this.data!==null&&this.diagram?.partManager.updateRelationshipsFromData(this)}get key(){const t=this.diagram;if(t!==null)return t.model.getKeyForNodeData(this.data)}get adornments(){return this.qo===null?EmptyIterator.instance:this.qo.iteratorValues}findAdornment(t){const i=this.qo;return i===null?null:i.get(t)}addAdornment(t,i){if(i===null)return;let e=null,s=this.qo;if(s!==null&&(e=s.get(t)),e!==i){if(e!==null){const o=e.diagram;o!==null&&o.remove(e)}s===null&&(s=new GMap,this.qo=s),i.Ho!==t&&(i.category=t),s.set(t,i);const n=this.diagram;if(n!==null){n.add(i);const o=i.adornedObject;if(o!==null){const r=o.findBindingPanel();r!==null&&(i.data=r.data)}}}}removeAdornment(t){const i=this.qo;if(i===null)return;const e=i.get(t);if(e!==null){const s=e.diagram;s!==null&&(s.remove(e),e.data=null)}i.delete(t),i.count===0&&(this.qo=null)}clearAdornments(){const t=this.qo;if(t===null)return;const i=Util.nt(),e=t.iterator;for(;e.next();){const n=e.key;i.push(n)}const s=i.length;for(let n=0;n{e.isEnabled&&e.updateAdornments(i)}),t.toolManager.updateAdornments(i)}IS(t){this.Wo=t,t===null&&this.DR()}get layer(){return this.Wo}get diagram(){const t=this.Wo;return t==null?null:t.diagram}get layerName(){return this.ll}set layerName(t){const i=this.ll;if(i===t)return;Util.i(t,"string",Part,"layerName");let e=this.diagram;if(e!==null&&(e.findLayer(t)===null||e.partManager.addsToTemporaryLayer))return;this.ll=t,e!==null&&e.invalidateDocumentBounds(),this.t("layerName",i,t);const s=this.layer;if(s===null||s.name===t||(e=s.diagram,e===null))return;const n=e.findLayer(t);if(n===null||n===s)return;let o=s.te(-1,this,!0);o>=0&&e.raiseChangedEvent(4,"parts",s,this,null,o,!0),o=n.qh(99999999,this,!0),s.visible!==n.visible&&this.Ei(n.visible),o>=0&&e.raiseChangedEvent(3,"parts",n,null,this,!0,o);const r=this.layerChanged;if(r===null)return;const l=e.Y;e.Y=!0,r(this,s,n),e.Y=l}get layerChanged(){return this.F!==null?this.F.zp:null}set layerChanged(t){const i=this.layerChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"layerChanged"),this.qi(),this.F.zp=t,this.t("layerChanged",i,t))}get zOrder(){return this.Cd}set zOrder(t){const i=this.Cd;if(i===t)return;Util.i(t,"number",Part,"zOrder"),this.Cd=t;const e=this.layer;e!==null&&e.yx(-1,this),this.t("zOrder",i,t);const s=this.diagram;s!==null&&s.C()}Ov(){const t=this.layer;t!==null&&t.yx(-1,this)}o1(){if(this.th()!==!1)return;this.K2(!0),this._u();const t=this.diagram;t!==null&&(t.o0(this),t.requestUpdate())}XA(){if(this.P|=2097152,this.th()===!1)return;const t=this.position,i=this.location;(!i.isReal()||!t.isReal())&&this.KA(t,i);const e=this.Li,s=Rect.l().a(e);e.ot(),e.x=t.x,e.y=t.y,e.g(),this.td(s,e),Rect.s(s),this.K2(!1)}Qn(t,i,e,s){const n=this.se;n.e(t,i,e,s),this.bi===null&&(this.bi=new Transform);const o=this.bi;o.Ri(),this.p0(o,t,i,e,s),this.bi=o,o.Ok()||o.xw(n)}p0(t,i,e,s,n){if(this.et!==1&&t.et(this.et),this.Xt===0)return;let o=Spot.Center;this.locationSpot.isSpot()&&(o=this.locationSpot);const r=Point.l();if(this.locationObject!==this){const l=this.locationObject,h=l.naturalBounds;r.setSpot(h.x,h.y,h.width,h.height,o),l.bi!==null&&l.bi.xt(r),r.offset(-l.measuredBounds.x,-l.measuredBounds.y);let a=l.panel;for(;a!==null&&a!==this;)a.bi!==null&&a.bi.xt(r),r.offset(-a.measuredBounds.x,-a.measuredBounds.y),a=a.panel}else r.setSpot(i,e,s,n,o);t.cs(this.Xt,r.x,r.y),Point.s(r)}get locationObject(){if(this.Jo===null)if(this instanceof Adornment&&this.type!==Panel.Link&&this.hasPlaceholder())this.Jo=this.placeholder;else{const t=this.locationObjectName;if(t!==""){const i=this.findObject(t);i!==null?this.Jo=i:this.Jo=this}else this.Jo=this}return this.Jo.visible?this.Jo:this}get minLocation(){return this.F!==null?this.F.Xp:Point.$N}set minLocation(t){const i=this.minLocation;i.equals(t)||(t=t.N(),this.qi(),this.F.Xp=t,this.t("minLocation",i,t))}get maxLocation(){return this.F!==null?this.F.Kp:Point.ZN}set maxLocation(t){const i=this.maxLocation;i.equals(t)||(t=t.N(),this.qi(),this.F.Kp=t,this.t("maxLocation",i,t))}get locationObjectName(){return this.F!==null?this.F.Yp:""}set locationObjectName(t){const i=this.locationObjectName;i!==t&&(this.qi(),this.F.Yp=t,this.Jo=null,this.c(),this.t("locationObjectName",i,t))}get locationSpot(){return this.F!==null?this.F.Gp:Spot.TopLeft}set locationSpot(t){const i=this.locationSpot;i.equals(t)||(t=t.N(),this.qi(),this.F.Gp=t,this.c(),this.t("locationSpot",i,t))}move(t,i){i===!0?this.location=t:this.position=t}moveTo(t,i,e){const s=Point.X(t,i);this.move(s,e),Point.s(s)}isVisible(){if(!this.visible)return!1;const t=this.layer;if(t!==null){if(!t.visible)return!1;const e=t.diagram;if(e!==null&&e.animationManager.nx(this))return!0}const i=this.containingGroup;return!(i!==null&&(!i.isSubGraphExpanded||!i.isVisible()))}Ei(t){const i=this.diagram;t?(this.invalidateLayout(4),this.invalidateAdornments(),i!==null&&i.o0(this)):(this.invalidateLayout(8),this.clearAdornments()),this.ch(),i!==null&&(i.invalidateDocumentBounds(),i.C())}findObject(t){if(this.name===t)return this;let i=this.Up;if(i===null&&(this.Up=i=new GMap),i.get(t)!==null)return i.get(t);const e=super.findObject(t);return e!==null?(i.set(t,e),e):(i.set(t,null),null)}D0(){this.Up=null}getRelativePoint(t,i,e){e===void 0&&(e=new Point);const s=i.isNoSpot()?Spot.Center:i,n=t.naturalBounds;if(e.e(n.width*s.x+s.offsetX,n.height*s.y+s.offsetY),t===null||t===this)return e;t.D.xt(e);let o=t.panel;for(;o!==null&&o!==this;)o.D.xt(e),o=o.panel;return this.bi!==null&&this.bi.xt(e),e.offset(-this.se.x,-this.se.y),e}getDocumentBounds(t){return t===void 0&&(t=new Rect),t.a(this.actualBounds)}ensureBounds(){this.ut(1/0,1/0),this.zt()}pA(t){const i=this.locationSpot,e=this.locationObject;let s=e.naturalBounds;s.isReal()||(s=Rect.pw);const n=e instanceof Shape?e.strokeWidth:0;if(t.setSpot(0,0,s.width+n,s.height+n,i),e!==this){t.offset(-n/2,-n/2),e.D.xt(t);let o=e.panel;for(;o!==null&&o!==this;)o.D.xt(t),o=o.panel}return this.bi!==null&&this.bi.xt(t),t.offset(-this.se.x,-this.se.y),t}Hh(t,i){const e=i===void 0?this.UA:i,s=this.Iv(),n=s*2;if(!this.isShadowed)return e.e(t.x-1-s,t.y-1-s,t.width+2+n,t.height+2+n),e;let o=t.x,r=t.y,l=t.width,h=t.height;const a=this.shadowBlur,c=this.shadowOffset;return l+=a,h+=a,o-=a/2,r-=a/2,c.x>0?l+=c.x:(o+=c.x,l-=c.x),c.y>0?h+=c.y:(r+=c.y,h-=c.y),e.e(o-1,r-1,l+2,h+2),e}yv(){return this.type===Panel.Link&&this instanceof Adornment&&this.category==="Selection"&&this.adornedObject instanceof Shape&&this.adornedPart.findMainElement()===this.adornedObject?this.adornedObject.strokeWidth:0}Iv(){return isNaN(this.Vp)&&(this.Vp=this.SA()),this.Vp}cf(){this.Vp=NaN}zt(){if(this.is()===!1){this.XA();return}this._n(!1);const t=this.Li,i=Rect.l();i.a(t);const e=this.Nl();this.ah(0,0,this.se.width,this.se.height);const s=this.position;this.KA(s,this.location),t.ot(),t.x=s.x,t.y=s.y,t.g(),this.td(i,t),i.equals(t)?this.Bs(e):this.Pe()&&(!Geo.u(i.width,t.width)||!Geo.u(i.height,t.height))&&this.BS>=0&&this.invalidateLayout(16),Rect.s(i),this.K2(!1)}td(t,i){const e=this.diagram;if(e===null)return;let s=!1;if(e.Zh===!1&&t.isReal()){const n=Rect.l();n.a(e.documentBounds),n.subtractMargin(e.padding),t.x>n.x&&t.y>n.y&&t.rightn.x&&i.y>n.y&&i.right=o)return}}this.P=this.P^4096;let s=!1;if(e!==null){s=e.skipsUndoManager,e.skipsUndoManager=!0;const o=e.selection;o.ot(),t?o.add(this):o.delete(this),o.g()}this.t("isSelected",i,t),this.invalidateAdornments();const n=this.selectionChanged;n!==null&&n(this),e!==null&&(e.requestUpdate(),e.skipsUndoManager=s)}}get isHighlighted(){return(this.P&524288)!==0}set isHighlighted(t){const i=(this.P&524288)!==0;if(i!==t){this.P=this.P^524288;const e=this.diagram;if(e!==null){const n=e.highlighteds;n.ot(),t?n.add(this):n.delete(this),n.g()}this.t("isHighlighted",i,t),this.C();const s=this.highlightedChanged;s!==null&&s(this)}}get isShadowed(){return(this.P&8192)!==0}set isShadowed(t){const i=(this.P&8192)!==0;i!==t&&(this.P=this.P^8192,this.ss(!0),this.t("isShadowed",i,t),this.C())}VA(){return(this.P&16384)!==0}zA(t){t?this.P|=16384:this.P&=-16385}th(){return(this.P&32768)!==0}K2(t){t?this.P|=32768:this.P&=-32769}Ev(){return(this.P&65536)!==0}s2(t){t?this.P|=65536:this.P&=-65537}Nl(){return(this.P&131072)!==0}Bs(t){t?this.P|=131072:this.P&=-131073}qA(){return(this.P&1048576)!==0}l1(t){t?this.P|=1048576:this.P&=-1048577}get isAnimated(){return(this.P&262144)!==0}set isAnimated(t){const i=(this.P&262144)!==0;i!==t&&(this.P=this.P^262144,this.t("isAnimated",i,t))}get highlightedChanged(){return this.F!==null?this.F.jp:null}set highlightedChanged(t){const i=this.highlightedChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"highlightedChanged"),this.qi(),this.F.jp=t,this.t("highlightedChanged",i,t))}get selectionObjectName(){return this.F!==null?this.F.Hp:""}set selectionObjectName(t){const i=this.selectionObjectName;i!==t&&(this.qi(),this.F.Hp=t,this.hl=null,this.t("selectionObjectName",i,t))}get selectionAdornmentTemplate(){return this.F!==null?this.F.qp:null}set selectionAdornmentTemplate(t){const i=this.selectionAdornmentTemplate;i!==t&&(this.qi(),this.F.qp=t,this.t("selectionAdornmentTemplate",i,t))}get selectionObject(){if(this.hl===null){const t=this.selectionObjectName;if(t!==null&&t!==""){const i=this.findObject(t);i!==null?this.hl=i:this.hl=this}else if(this instanceof Link){const i=this.path;i!==null?this.hl=i:this.hl=this}else this.hl=this}return this.hl}get selectionChanged(){return this.F!==null?this.F.Wp:null}set selectionChanged(t){const i=this.selectionChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"selectionChanged"),this.qi(),this.F.Wp=t,this.t("selectionChanged",i,t))}get resizeAdornmentTemplate(){return this.F!==null?this.F.Jp:null}set resizeAdornmentTemplate(t){const i=this.resizeAdornmentTemplate;i!==t&&(this.qi(),this.F.Jp=t,this.t("resizeAdornmentTemplate",i,t))}get resizeObjectName(){return this.F!==null?this.F.$p:""}set resizeObjectName(t){const i=this.resizeObjectName;i!==t&&(this.qi(),this.F.$p=t,this.t("resizeObjectName",i,t))}get resizeObject(){const t=this.resizeObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get resizeCellSize(){return this.F!==null?this.F.Zp:Size.gw}set resizeCellSize(t){const i=this.resizeCellSize;i.equals(t)||(t=t.N(),this.qi(),this.F.Zp=t,this.t("resizeCellSize",i,t))}get rotateAdornmentTemplate(){return this.F!==null?this.F.Qp:null}set rotateAdornmentTemplate(t){const i=this.rotateAdornmentTemplate;i!==t&&(this.qi(),this.F.Qp=t,this.t("rotateAdornmentTemplate",i,t))}get rotateObjectName(){return this.F!==null?this.F._p:""}set rotateObjectName(t){const i=this.rotateObjectName;i!==t&&(this.qi(),this.F._p=t,this.t("rotateObjectName",i,t))}get rotateObject(){const t=this.rotateObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get rotationSpot(){return this.F!==null?this.F.ty:Spot.Default}set rotationSpot(t){const i=this.rotationSpot;i.equals(t)||(t=t.N(),this.qi(),this.F.ty=t,this.t("rotationSpot",i,t))}get text(){return this.hi}set text(t){const i=this.hi;i!==t&&(this.hi=t,this.t("text",i,t))}get containingGroup(){return this.ph}set containingGroup(t){if(this.Pe()){const i=this.ph;if(i!==t){t!==null&&(this===t||t.isMemberOf(this))&&(this===t&&Util.o("Cannot make a Group a member of itself: "+this.toString()),Util.o("Cannot make a Group indirectly contain itself: "+this.toString()+" already contains "+t.toString())),this.invalidateLayout(2);const e=this.diagram;if(i!==null?i.G2(this):this instanceof Group&&e!==null&&e.Yr.delete(this),this.ph=t,t!==null?t.j2(this):this instanceof Group&&e!==null&&e.Yr.add(this),this.invalidateLayout(1),e!==null&&e.Y){const n=this.data,o=e.model;if(n!==null&&o.qc()){const r=t!==null?t.data:null;o.setGroupForData(n,o.getKeyForNodeData(r))}}const s=this.containingGroupChanged;if(s!==null){let n=!0;e!==null&&(n=e.Y,e.Y=!0),s(this,i,t),e!==null&&(e.Y=n)}if(this instanceof Group){const n=new GSet;Part.sh(n,this,!0,0,!0);const o=n.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=r.linksConnected;for(;l.next();)l.value.Ld()}}}if(this instanceof Node){const n=this.linksConnected;for(;n.next();)n.value.Ld();const o=this.labeledLink;o!==null&&o.Ld()}this.t("containingGroup",i,t),t!==null&&t.Ov()}}else Util.o("cannot set the Part.containingGroup of a Link or Adornment")}ch(){const t=this.containingGroup;t!==null&&(t.hasPlaceholder()&&t.placeholder.c(),t.c(),t.invalidateConnectedLinks())}C(){const t=this.diagram;t!==null&&!this.is()&&!this.th()&&this.isVisible()&&this.Li.isReal()&&t.C(this.Hh(this.Li))}c(){if(this.Oo())return;super.c();const t=this.diagram;t!==null&&(t.o0(this),this instanceof Node&&this.labeledLink!==null&&this.labeledLink.ef(),t.requestUpdate(!0))}ef(t){if(this.is())return;const i=this.diagram;i!==null&&(i.o0(this),this instanceof Node&&this.invalidateConnectedLinks(),i.requestUpdate()),this._n(!0)}Em(t){if(!t){const i=this.ph;i!==null&&i.j2(this)}}Bm(t){if(!t){const i=this.ph;i!==null&&i.G2(this)}}Kc(){const t=this.data;if(t!==null){const i=this.diagram;if(i!==null){const e=i.model;e!==null&&e.removeNodeData(t)}}}get containingGroupChanged(){return this.F!==null?this.F.iy:null}set containingGroupChanged(t){const i=this.containingGroupChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"containingGroupChanged"),this.qi(),this.F.iy=t,this.t("containingGroupChanged",i,t))}findSubGraphLevel(){return this.H2(this)}H2(t){const i=t.containingGroup;if(i!==null)return 1+this.H2(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.H2(e)}return 0}findTopLevelPart(){return this.q2(this)}q2(t){const i=t.containingGroup;if(i!==null)return this.q2(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.q2(e)}return t}get isTopLevel(){return!(this.containingGroup!==null||this instanceof Node&&this.labeledLink!==null)}isMemberOf(t){return t instanceof Group?this.W2(this,t):!1}W2(t,i){if(t===i||i===null)return!1;const e=t.containingGroup;if(e!==null&&(e===i||this.W2(e,i)))return!0;if(t instanceof Node){const s=t.labeledLink;if(s!==null)return this.W2(s,i)}return!1}findCommonContainingGroup(t){if(t===null)return null;if(this===t)return this.containingGroup;let i=this;for(;i!==null;){if(i instanceof Group&&i.l1(!0),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}let e=null;for(i=t;i!==null;){if(i.qA()){e=i;break}if(i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}for(i=this;i!==null;){if(i instanceof Group&&i.l1(!1),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}return e}get layoutConditions(){return this.F!==null?this.F.ey:127}set layoutConditions(t){const i=this.layoutConditions;i!==t&&(this.qi(),this.F.ey=t,this.t("layoutConditions",i,t))}canLayout(){if(!this.isLayoutPositioned||!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary||this instanceof Node&&this.isLinkLabel)}Uv(t){if(!this.isLayoutPositioned||!(t&this.layoutConditions))return!1;const i=this.layer;if(i!==null&&i.isTemporary||this instanceof Node&&this.isLinkLabel)return!1;const e=this.diagram;return!(e!==null&&e.undoManager.isUndoingRedoing)}invalidateLayout(t){if(t===void 0&&(t=16777215),!this.Uv(t))return;const i=this.ph;if(i!==null){const e=i.layout;e!==null?e.invalidateLayout():i.invalidateLayout(t)}else{const e=this.diagram;if(e!==null){const s=e.layout;s!==null&&s.invalidateLayout()}}}NL(){if(!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary)}static sh(t,i,e,s,n,o){if(o===void 0&&(o=null),!t.has(i)&&!(o!==null&&!o(i))&&!(i instanceof Adornment)){if(t.add(i),i instanceof Node){if(e&&i instanceof Group){const r=i.memberParts;for(;r.next();){const l=r.value;Part.sh(t,l,e,s,n,o)}}if(n!==!1){const r=i.linksConnected;for(;r.next();){const l=r.value;if(t.has(l))continue;const h=l.fromNode,a=l.toNode,c=h===null||t.has(h),f=a===null||t.has(a);(n?c&&f:c||f)&&Part.sh(t,l,e,s,n,o)}}if(s>1){const r=i.findTreeChildrenNodes();for(;r.next();){const l=r.value;Part.sh(t,l,e,s-1,n,o)}}}else if(i instanceof Link){const r=i.labelNodes;for(;r.next();){const l=r.value;Part.sh(t,l,e,s,n,o)}}}}get dragComputation(){return this.F!==null?this.F.sy:null}set dragComputation(t){const i=this.dragComputation;i!==t&&(t!==null&&Util.i(t,"function",Part,"dragComputation"),this.qi(),this.F.sy=t,this.t("dragComputation",i,t))}get shadowOffset(){return this.F!==null?this.F.ny:Point.QN}set shadowOffset(t){const i=this.shadowOffset;i.equals(t)||(t=t.N(),this.qi(),this.F.ny=t,this.C(),this.t("shadowOffset",i,t))}get shadowColor(){return this.F!==null?this.F.oy:"gray"}set shadowColor(t){const i=this.shadowColor;i!==t&&(this.qi(),this.F.oy=t,this.C(),this.t("shadowColor",i,t))}get shadowBlur(){return this.F!==null?this.F.xn:4}set shadowBlur(t){const i=this.shadowBlur;i!==t&&(this.qi(),this.F.xn=t,this.C(),this.t("shadowBlur",i,t))}}class PartTemplateSettings{gi;zp;iy;qp;Hp;Wp;jp;Jp;$p;Zp;Qp;_p;ty;Yp;Gp;Xp;Kp;sy;ey;ny;oy;xn;constructor(){this.gi=!1,this.zp=null,this.iy=null,this.qp=null,this.Hp="",this.Wp=null,this.jp=null,this.Jp=null,this.$p="",this.Zp=Size.gw,this.Qp=null,this._p="",this.ty=Spot.Default,this.Yp="",this.Gp=Spot.TopLeft,this.Xp=Point.$N,this.Kp=Point.ZN,this.sy=null,this.ey=127,this.ny=Point.QN,this.oy="gray",this.xn=4}copy(){const t=new PartTemplateSettings;return t.zp=this.zp,t.iy=this.iy,t.qp=this.qp,t.Hp=this.Hp,t.Wp=this.Wp,t.jp=this.jp,t.Jp=this.Jp,t.$p=this.$p,t.Zp=this.Zp.N(),t.Qp=this.Qp,t._p=this._p,t.ty=this.ty.N(),t.Yp=this.Yp,t.Gp=this.Gp.N(),t.Xp=this.Xp.N(),t.Kp=this.Kp.N(),t.sy=this.sy,t.ey=this.ey,t.ny=this.ny.N(),t.oy=this.oy,t.xn=this.xn,t}}class Adornment extends Part{us;It;JP;$P;hf;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.P&=-257,this.ll="Adornment",this.us=null,this.JP=0,this.$P=!1,this.It=null,this.hf=null,i&&Object.assign(this,i)}toString(){const t=this.adornedPart;return"Adornment("+this.category+")"+(t!==null?t.toString():"")}updateRelationshipsFromData(){}hd(t){const i=this.adornedObject,e=i?.part;if(!(e instanceof Link)||!(i instanceof Shape))return;const s=e.path;let n=s.geometry;e.hd(t),n=s.geometry;const o=this.L.r,r=o.length;for(let l=0;lh instanceof Placeholder);l instanceof Placeholder&&this.It===null&&(this.It=l)}}else t===4&&i==="elements"&&this.It!==null&&(s===this.It?this.It=null:s instanceof Panel&&this.It.isContainedBy(s)&&(this.It=null));super.Jc(t,i,e,s,n,o,r)}updateAdornments(){}Kc(){}}var PortSpreading=(w=>(w[w.None=0]="None",w[w.Evenly=1]="Evenly",w[w.Packed=2]="Packed",w))(PortSpreading||{});class Node extends Part{E;gt;kf;al;yh;ne;_t;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.E=13,this.gt=null,this._t=new List,this.kf=null,this.al=null,this.ne=null,this.yh=!1,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.E=this.E,this.gt!==null&&(this.gt.gi?t.gt=this.gt:t.gt=this.gt.copy())}Vo(t){super.Vo(t),t.invalidateConnectedLinks(),t.al=this.al,t.ne=null}static SpreadingNone=0;static SpreadingEvenly=1;static SpreadingPacked=2;cl(){this.gt===null?this.gt=new NodeTemplateSettings:this.gt.gi&&(this.gt=this.gt.copy())}lh(){super.lh(),this.gt!==null&&(this.gt.gi=!0)}WA(t){t!==null&&(this.al===null&&(this.al=new GSet),this.al.add(t))}JA(t){t!==null&&this.al!==null&&this.al.delete(t)}$A(t,i,e){if(t===null||this.al===null)return null;const s=this.al.iterator;for(;s.next();){const n=s.value;if(n.ry===this&&n.h1===t&&n.J2===i&&n.$2===e||n.ry===t&&n.h1===this&&n.J2===e&&n.$2===i)return n}return null}invalidateLinkBundle(t,i,e){i==null&&(i=""),e==null&&(e="");const s=this.$A(t,i,e);s!==null&&s.Ad()}Jc(t,i,e,s,n,o,r){t===3&&i==="elements"?this.ne=null:t===4&&i==="elements"&&(this.ne=null),super.Jc(t,i,e,s,n,o,r)}invalidateConnectedLinks(t){const i=this.linksConnected;for(;i.next();){const e=i.value;t!==void 0&&t.has(e)||(this.Wi(e.fromPort),this.Wi(e.toPort),e.invalidateRoute())}}tA(t){const i=this.linksConnected;for(;i.next();){const e=i.value;e.fromPort!==t&&e.toPort!==t||(this.Wi(e.fromPort),this.Wi(e.toPort),e.invalidateRoute())}}Wi(t){if(t===null)return;const i=t.Ju;i!==null&&i.Ad();const e=t.part,s=e.containingGroup;s!==null&&!e.isVisible()&&s.Wi(s.port)}Hr(){return!0}get portSpreading(){return this.gt!==null?this.gt.ly:1}set portSpreading(t){const i=this.portSpreading;if(i!==t){this.cl(),this.gt.ly=t,this.t("portSpreading",i,t);const e=this.diagram;if(e!==null&&e.undoManager.isUndoingRedoing)return;this.invalidateConnectedLinks()}}get avoidable(){return(this.E&8)!==0}set avoidable(t){const i=(this.E&8)!==0;if(i!==t){this.E=this.E^8;const e=this.diagram;e!==null&&e.EM(this),this.t("avoidable",i,t)}}get avoidableMargin(){return this.gt!==null?this.gt.hy:Margin.oC}set avoidableMargin(t){typeof t=="number"&&(t=new Margin(t));const i=this.avoidableMargin;if(!i.equals(t)){t=t.N(),this.cl(),this.gt.hy=t;const e=this.diagram;e!==null&&e.EM(this),this.t("avoidableMargin",i,t)}}canAvoid(){return this.avoidable&&!this.isLinkLabel}getAvoidableRect(t){return t.set(this.actualBounds),t.addMargin(this.avoidableMargin),t}findVisibleNode(){let t=this;for(;t!==null&&!t.isVisible();)t=t.containingGroup;return t}isVisible(){if(!super.isVisible())return!1;let t=!0,i=1;const e=this.diagram;if(e!==null){if(e.animationManager.nx(this))return!0;t=e.isTreePathToChildren,i=e.treeCollapsePolicy}if(i===1){const n=this.findTreeParentNode();if(n!==null&&!n.isTreeExpanded)return!1}else if(i===2){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&h.isTreeExpanded){r=!0;break}}}if(o&&!r)return!1}else if(i===3){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&!h.isTreeExpanded){r=!0;break}}}if(o&&r)return!1}const s=this.labeledLink;return s!==null?s.isVisible():!0}Ei(t){super.Ei(t);const i=this.linksConnected;for(;i.next();){const e=i.value;if(t&&this.containingGroup!==null){const s=e.getOtherNode(this);s!==null&&!s.isMemberOf(this.containingGroup)&&e.invalidateRoute()}e.Ei(t)}}get linksConnected(){return this._t.iterator}findExternalTreeLinksConnected(){const t=new GSet,i=new GSet;return this.ZA(this,t,i),i.iterator}ZA(t,i,e){if(t===null||i.has(t))return;i.add(t);let s=!0;const n=this.diagram;n!==null&&(s=n.isTreePathToChildren),t.linksConnected.each(o=>{o.isTreeLink?(s?o.fromNode===t:o.toNode===t)&&this.ZA(s?o.toNode:o.fromNode,i,e):e.add(o)})}findLinksConnected(t){if(t===void 0&&(t=null),t===null)return this._t.iterator;const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.fromNode===e&&s.fromPortId===t||s.toNode===e&&s.toPortId===t,i}findLinksOutOf(t){t===void 0&&(t=null);const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.fromNode!==e?!1:t===null?!0:s.fromPortId===t,i}findLinksInto(t){t===void 0&&(t=null);const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.toNode!==e?!1:t===null?!0:s.toPortId===t,i}findNodesConnected(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this){if(t===null||n.fromPortId===t){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}else if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesOutOf(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this&&(t===null||n.fromPortId===t)){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesInto(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findLinksBetween(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null);const s=new ListIterator(this._t),n=this;return s.predicate=o=>o.fromNode===n&&o.toNode===t&&(i===null||o.fromPortId===i)&&(e===null||o.toPortId===e)||o.fromNode===t&&o.toNode===n&&(e===null||o.fromPortId===e)&&(i===null||o.toPortId===i),s}findLinksTo(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null);const s=new ListIterator(this._t),n=this;return s.predicate=o=>!(o.fromNode!==n||o.toNode!==t||i!==null&&o.fromPortId!==i||e!==null&&o.toPortId!==e),s}get linkConnected(){return this.gt!==null?this.gt.ay:null}set linkConnected(t){const i=this.linkConnected;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkConnected"),this.cl(),this.gt.ay=t,this.t("linkConnected",i,t))}get linkDisconnected(){return this.gt!==null?this.gt.cy:null}set linkDisconnected(t){const i=this.linkDisconnected;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkDisconnected"),this.cl(),this.gt.cy=t,this.t("linkDisconnected",i,t))}get linkValidation(){return this.gt!==null?this.gt.Ml:null}set linkValidation(t){const i=this.linkValidation;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkValidation"),this.cl(),this.gt.Ml=t,this.t("linkValidation",i,t))}a1(t,i){this.Wi(i);const e=this._t.has(t);if(e||this._t.add(t),!e||t.fromNode===t.toNode){const s=this.linkConnected;if(s!==null){let n=!0;const o=this.diagram;o!==null&&(n=o.Y,o.Y=!0),s(this,t,i),o!==null&&(o.Y=n)}}if(!e){if(!t.isTreeLink)return;const s=t.fromNode,n=t.toNode;if(s!==null&&n!==null&&s!==n){let o=!0;const r=this.diagram;r!==null&&(o=r.isTreePathToChildren);const l=o?n:s,h=o?s:n;if(l.yh||(l.yh=h),h.isTreeLeaf){if(r!==null&&r.undoManager.isUndoingRedoing)return;o?s===h&&(h.isTreeLeaf=!1):n===h&&(h.isTreeLeaf=!1)}}}}c1(t,i){this.Wi(i);const e=this._t.delete(t);let s=null;if(e||t.toNode===t.fromNode){const n=this.linkDisconnected;if(s=this.diagram,n!==null){let o=!0;s!==null&&(o=s.Y,s.Y=!0),n(this,t,i),s!==null&&(s.Y=o)}}if(e){if(!t.isTreeLink)return;let n=!0;s!==null&&(n=s.isTreePathToChildren);const o=n?t.toNode:t.fromNode,r=n?t.fromNode:t.toNode;if(o!==null&&(o.yh=!1),r!==null&&!r.isTreeLeaf)if(r._t.count===0){if(r.yh=null,s!==null&&s.undoManager.isUndoingRedoing)return;r.isTreeLeaf=!0}else r.f0()}}f0(){if(this.yh=!1,this._t.count===0)return;let t=!0;const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;i!==null&&(t=i.isTreePathToChildren);const e=this._t.iterator;for(;e.next();){const s=e.value;if(s.isTreeLink){if(t){if(s.fromNode===this){this.isTreeLeaf=!1;return}}else if(s.toNode===this){this.isTreeLeaf=!1;return}}}this.isTreeLeaf=!0}updateRelationshipsFromData(){const t=this.diagram;t!==null&&t.partManager.updateRelationshipsFromData(this)}Em(t){if(super.Em(t),!t){this.f0();const i=this.kf;i!==null&&i.QA(this)}}Bm(t){if(super.Bm(t),!t){const i=this.kf;i!==null&&i._A(this)}}Kc(){if(this._t.count>0){const t=this.diagram;if(t!==null){const i=t.commandHandler!==null?t.commandHandler.deletesConnectedLinks:!0,s=this._t.copy().iterator;for(;s.next();){const n=s.value;i?t.remove(n):(n.fromNode===this&&(n.fromNode=null),n.toNode===this&&(n.toNode=null))}}}this.labeledLink=null,super.Kc()}get isLinkLabel(){return this.kf!==null}get labeledLink(){return this.kf}set labeledLink(t){const i=this.kf;if(i!==t){const e=this.diagram,s=this.data;if(i!==null){if(i._A(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=i.data,o=e.model;if(n!==null&&o.Ta()){const r=o.getKeyForNodeData(s);r!==void 0&&o.removeLabelKeyForLinkData(n,r)}}this.containingGroup=null}if(this.kf=t,t!==null){if(t.QA(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=t.data,o=e.model;if(n!==null&&o.Ta()){const r=o.getKeyForNodeData(s);r!==void 0&&o.addLabelKeyForLinkData(n,r)}}this.containingGroup=t.containingGroup}this.ef(),this.t("labeledLink",i,t)}}findVisiblePort(t){let i=t;for(;i!==null&&(!i.actualBounds.isReal()||!i.isVisibleObject());)i=i.panel;return i===null?this.port:i}findPort(t){if(this.ne===null){if(t===""&&this.wn===!1)return this;this.tT()}let i=this.ne.get(t);return i!==null||t!==""&&(i=this.ne.get(""),i!==null)?i:this}get port(){return this.findPort("")}get ports(){return this.ne===null&&this.tT(),this.ne.iteratorValues}tT(){this.ne===null?this.ne=new GMap:this.ne.clear(),this.walkVisualTreeFrom(this,(t,i)=>t.hA(i)),this.ne.count===0&&this.ne.set("",this)}hA(t){const i=t.portId;i!==null&&this.ne!==null&&this.ne.set(i,t)}u2(t,i){const e=t.portId;if(e!==null){this.ne!==null&&this.ne.delete(e);const s=this.diagram;if(s!==null&&i){let n=null;const o=this.findLinksConnected(e);for(;o.next();){const r=o.value;n===null&&(n=Util.nt()),n.push(r)}if(n!==null){for(let r=0;r!(!n.isTreeLink||n.fromNode!==s):e.predicate=n=>!(!n.isTreeLink||n.toNode!==s),e}findTreeChildrenNodes(){let t=!0;const i=this.diagram;i!==null&&(t=i.isTreePathToChildren);let e=null,s=null;const n=this._t.iterator;if(t)for(;n.next();){const o=n.value;if(o.isTreeLink&&o.fromNode===this){const r=o.toNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}else for(;n.next();){const o=n.value;if(o.isTreeLink&&o.toNode===this){const r=o.fromNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}return e!==null?e.iterator:s!==null?new SingletonIterator(s):EmptyIterator.instance}findTreeParts(t){t===void 0&&(t=1/0),Util.i(t,"number",Node,"findTreeParts:level");const i=new GSet;return Part.sh(i,this,!1,t,!0),i}collapseTree(t){t===void 0&&(t=1),t<1&&(t=1);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.iT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}iT(t,i,e,s,n,o){if(e>1){const r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);h!==null&&h!==this&&!t.has(h)&&(t.add(h),h.iT(t,i,e-1,s,n,o))}}else this.eT(t,i,s,n,o)}eT(t,i,e,s,n){const o=s===this?!0:this.isTreeExpanded,r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);if(h!==null&&h!==this){const a=t.has(h);if(a||t.add(h),o){const c=i?h.findNodesInto():h.findNodesOutOf(),f=this;c.all(u=>u===f||!u.isTreeExpanded)&&e.Lc(h,s),h.ch(),h.Ei(!1)}h.isTreeExpanded&&(h.wasTreeExpanded=h.isTreeExpanded,a||h.eT(t,i,e,s,n))}}this.isTreeExpanded=!1}expandTree(t){t===void 0&&(t=2),t<2&&(t=2);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.sT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}sT(t,i,e,s,n,o){const r=n===this?!1:this.isTreeExpanded,l=i?this.findLinksOutOf():this.findLinksInto();for(;l.next();){const h=l.value;if(!h.isTreeLink)continue;r||h.Me||h.invalidateRoute();const a=h.getOtherNode(this);if(a!==null&&a!==this&&!t.has(a)){if(t.add(a),!r){a.Ei(!0),a.ch();const c=i?a.findNodesInto():a.findNodesOutOf(),f=this;c.all(u=>u===f||!u.isTreeExpanded)&&s.Cc(a,n)}(e>2||a.wasTreeExpanded)&&(a.wasTreeExpanded=!1,a.sT(t,i,e-1,s,n,o))}}this.isTreeExpanded=!0}get isTreeExpanded(){return(this.E&1)!==0}set isTreeExpanded(t){const i=(this.E&1)!==0;if(i!==t){this.E=this.E^1;const e=this.diagram;this.t("isTreeExpanded",i,t);const s=this.treeExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.Y,e.Y=!0),s(this),e!==null&&(e.Y=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.Ei(t);return}t?this.expandTree():this.collapseTree()}}get wasTreeExpanded(){return(this.E&2)!==0}set wasTreeExpanded(t){const i=(this.E&2)!==0;i!==t&&(this.E=this.E^2,this.t("wasTreeExpanded",i,t))}get treeExpandedChanged(){return this.gt!==null?this.gt.fy:null}set treeExpandedChanged(t){const i=this.treeExpandedChanged;i!==t&&(t!==null&&Util.i(t,"function",Node,"treeExpandedChanged"),this.cl(),this.gt.fy=t,this.t("treeExpandedChanged",i,t))}get isTreeLeaf(){return(this.E&4)!==0}set isTreeLeaf(t){const i=(this.E&4)!==0;i!==t&&(this.E=this.E^4,this.t("isTreeLeaf",i,t))}get isTreeRoot(){return this.findTreeParentLink()===null}}class NodeTemplateSettings{gi;ay;cy;Ml;fy;hy;ly;uy;gy;eh;my;constructor(){this.gi=!1,this.ay=null,this.cy=null,this.Ml=null,this.fy=null,this.hy=Margin.oC,this.ly=1,this.uy=null,this.gy=null,this.eh=null,this.my=null}copy(){const t=new NodeTemplateSettings;return t.ay=this.ay,t.cy=this.cy,t.Ml=this.Ml,t.fy=this.fy,t.hy=this.hy.N(),t.ly=this.ly,t.uy=this.uy,t.gy=this.gy,t.eh=this.eh,t.my=this.my,t}}var LinkAdjusting=(w=>(w[w.None=0]="None",w[w.End=17]="End",w[w.Scale=18]="Scale",w[w.Stretch=19]="Stretch",w))(LinkAdjusting||{}),Routing=(w=>(w[w.Normal=1]="Normal",w[w.Orthogonal=2]="Orthogonal",w[w.AvoidsNodes=6]="AvoidsNodes",w[w.AvoidsNodesStraight=7]="AvoidsNodesStraight",w))(Routing||{}),Curve=(w=>(w[w.None=0]="None",w[w.Bezier=9]="Bezier",w[w.JumpGap=10]="JumpGap",w[w.JumpOver=11]="JumpOver",w))(Curve||{});class Link extends Part{Nt;lo;ho;Td;ao;co;Dd;Pf;Fd;Rd;vd;Da;Od;Hs;ki;fl;Sr;Sf;$o;Z2;Q2;f1;_2;tN;py;u1;ct;Zo;static Fa=null;static Ra=null;hf;iN;eN;constructor(t){super(Panel.Link),this.Nt=8,this.lo=null,this.ho="",this.Td=null,this.ao=null,this.co="",this.Dd=null,this.Pf=0,this.Fd=0,this.Rd=0,this.vd=NaN,this.Da=1,this.Od=.5,this.Hs=null,this.ki=new List().g(),this.fl=null,this.Sr=null,this.Sf=new Rect,this.ct=new Geometry,this.$o=null,this.Zo=null,this.Z2=null,this.Q2=null,this.iN=0,this.eN=0,this.f1=new Point,this._2=null,this.tN=null,this.py=null,this.u1=NaN,this.q=null,this.hf=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Nt=this.Nt&-113,t.ho=this.ho,t.Td=this.Td,t.co=this.co,t.Dd=this.Dd,t.Pf=this.Pf,t.Fd=this.Fd,t.Rd=this.Rd,t.vd=this.vd,t.Da=this.Da,t.Od=this.Od,this.q!==null&&(t.q=this.q.copy())}Vo(t){super.Vo(t),this.ho=t.ho,this.co=t.co,t.fl=null,t.invalidateRoute(),t.Zo=this.Zo;const i=t.fromPort;i!==null&&t.fromNode.Wi(i);const e=t.toPort;e!==null&&t.toNode.Wi(e)}ri(t){t in Routing||t in Curve||t in LinkAdjusting?Link.sN(t)?this.routing=t:t===9||t===10||t===11?this.curve=t:t===17||t===18||t===19?this.adjusting=t:t===1||t===0||Util.o("Unknown Link enum value for a Link property: "+t):super.ri(t)}static Normal=1;static Orthogonal=2;static AvoidsNodes=6;static AvoidsNodesStraight=7;static None=0;static Bezier=9;static JumpGap=10;static JumpOver=11;static End=17;static Scale=18;static Stretch=19;static OrientAlong=21;static OrientPlus90=22;static OrientMinus90=23;static OrientOpposite=24;static OrientUpright=25;static OrientPlus90Upright=26;static OrientMinus90Upright=27;static OrientUpright45=28;static zv=8;static Xv=16;static Kv=14;static va=8;Xe(){this.q===null&&(this.q=new LinkSettings)}QR(t,i,e){const s=t.segmentIndex,n=t.segmentFraction;let o=t.alignmentFocus;const r=t.segmentOrientation,l=t.segmentOffset;let h=0,a=0,c=0,f=0;if(isNaN(s)){const C=this.ct,M=Util.nt();C.getPointAndAngleAlongPath(n,M);const N=Point.X(M[0],M[1]);if(N.add(this.getPoint(0)),C.type===1)N.offset(-C.startX,-C.startY);else{const T=C.figures.first();N.offset(-T.startX,-T.startY)}f=M[2],r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=N.x,a=N.y,Point.s(N),Util.tt(M)}else if(s<-i||s>=i){const C=Point.l();this.mA(C),f=this.midAngle,r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=C.x,a=C.y,Point.s(C)}else{let C,M,N=0;if(s>=0?(C=e.r[s],M=s0?e.r[N-1]:C),C.equalsApprox(M)){let T,A;s>=0?(T=s>0?e.r[s-1]:C,A=s1?e.r[N-2]:M);const D=T.distanceSquaredPoint(C),F=M.distanceSquaredPoint(A);D>F+10?f=s>=0?T.directionPoint(C):C.directionPoint(T):F>D+10?f=s>=0?M.directionPoint(A):A.directionPoint(M):f=s>=0?T.directionPoint(A):A.directionPoint(T)}else f=s>=0?C.directionPoint(M):M.directionPoint(C);r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=C.x+(M.x-C.x)*n,a=C.y+(M.y-C.y)*n}if(o.isNone()){t.location=new Point(h,a);return}else o.isNoSpot()&&(o=Spot.Center);const u=Transform.l();u.Ri(),u.et(t.scale,t.scale),u.cs(t.angle,0,0);const d=t.naturalBounds,m=Rect.X(0,0,d.width,d.height),g=Point.l();g.setRectSpot(m,o),u.xt(g);let p=-g.x,y=-g.y;const x=d.width,k=d.height,b=Point.l();b.a(l);const P=isNaN(l.x),S=isNaN(l.y);if(P||S){const C=x/2+3,M=k/2+3,N=f>=45&&f<=135,T=f>=225&&f<=315;r===0&&(N||T)?(b.x=S?C:l.y,b.y=P?M:l.x,N?s>=0||isNaN(s)&&n<.5||P&&(b.y=-M):T&&((s>=0||isNaN(s)&&n<.5)&&P&&(b.y=-M),S&&(b.x=-C))):(P&&(s>=0||isNaN(s)&&n<.5?b.x=C:b.x=-C),S&&(b.y=-M),b.rotate(f))}else b.rotate(f);h+=b.x,a+=b.y,u.xw(m),p+=m.x,y+=m.y;const L=Point.X(h+p,a+y);t.move(L),Point.s(L),Point.s(b),Point.s(g),Rect.s(m),Transform.s(u)}Hr(){let t=this.fromNode;if(t!==null){const e=t.findVisibleNode();if(e!==null&&(t=e),t.is()||t.th())return!1}let i=this.toNode;if(i!==null){const e=i.findVisibleNode();if(e!==null&&(i=e),i.is()||i.th())return!1}return!0}c2(t,i,e){return!1}f2(){}Pe(){return!1}computeAngle(t,i,e){return Link.computeAngle(i,e)}static computeAngle(t,i){let e=0;switch(t){default:case 0:e=0;break;case 21:e=i;break;case 22:e=i+90;break;case 23:e=i-90;break;case 24:e=i+180;break;case 25:e=Geo.zg(i),e>90&&e<270&&(e-=180);break;case 26:e=Geo.zg(i+90),e>90&&e<270&&(e-=180);break;case 27:e=Geo.zg(i-90),e>90&&e<270&&(e-=180);break;case 28:if(e=Geo.zg(i),e>45&&e<135||e>225&&e<315)return 0;e>90&&e<270&&(e-=180);break}return Geo.zg(e)}get fromNode(){return this.lo}set fromNode(t){const i=this.lo;if(i!==t){const e=this.fromPort;i!==null&&(this.ao!==i&&i.c1(this,e),this.yy(),this.invalidateLayout(2)),this.lo=t,t!==null&&this.Ei(t.isVisible()),this.$o=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.Y&&s.partManager.setFromNodeForLink(this,t,i);const n=this.fromPort,o=this.fromPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.Y,s.Y=!0),o(this,e,n),s!==null&&(s.Y=r)}t!==null&&(this.ao!==t&&t.a1(this,n),this.wy(),this.invalidateLayout(1)),this.t("fromNode",i,t),this.Ld()}}get fromPortId(){return this.ho}set fromPortId(t){const i=this.ho;if(i!==t){const e=this.fromPort;e!==null&&this.fromNode.Wi(e),this.yy(),this.ho=t;const s=this.fromPort;s!==null&&this.fromNode.Wi(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Ta()&&r.setFromPortIdForLinkData(o,t)}if(e!==s){this.$o=null,this.invalidateRoute();const o=this.fromPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.Y,n.Y=!0),o(this,e,s),n!==null&&(n.Y=r)}}this.wy(),this.t("fromPortId",i,t)}}get fromPort(){const t=this.lo;if(t===null)return null;const i=this.ho;return t.findPort(i)}get fromPortChanged(){return this.Td}set fromPortChanged(t){const i=this.Td;i!==t&&(t!==null&&Util.i(t,"function",Link,"fromPortChanged"),this.Td=t,this.t("fromPortChanged",i,t))}get toNode(){return this.ao}set toNode(t){const i=this.ao;if(i!==t){const e=this.toPort;i!==null&&(this.lo!==i&&i.c1(this,e),this.yy(),this.invalidateLayout(2)),this.ao=t,t!==null&&this.Ei(t.isVisible()),this.$o=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.Y&&s.partManager.setToNodeForLink(this,t,i);const n=this.toPort,o=this.toPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.Y,s.Y=!0),o(this,e,n),s!==null&&(s.Y=r)}t!==null&&(this.lo!==t&&t.a1(this,n),this.wy(),this.invalidateLayout(1)),this.t("toNode",i,t),this.Ld()}}get toPortId(){return this.co}set toPortId(t){const i=this.co;if(i!==t){const e=this.toPort;e!==null&&this.toNode.Wi(e),this.yy(),this.co=t;const s=this.toPort;s!==null&&this.toNode.Wi(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Ta()&&r.setToPortIdForLinkData(o,t)}if(e!==s){this.$o=null,this.invalidateRoute();const o=this.toPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.Y,n.Y=!0),o(this,e,s),n!==null&&(n.Y=r)}}this.wy(),this.t("toPortId",i,t)}}get toPort(){const t=this.ao;if(t===null)return null;const i=this.co;return t.findPort(i)}get toPortChanged(){return this.Dd}set toPortChanged(t){const i=this.Dd;i!==t&&(t!==null&&Util.i(t,"function",Link,"toPortChanged"),this.Dd=t,this.t("toPortChanged",i,t))}get fromSpot(){return this.q!==null?this.q.fa:Spot.Default}set fromSpot(t){const i=this.fromSpot;if(!i.equals(t)){if(t=t.N(),this.Xe(),this.q.fa=t,this.t("fromSpot",i,t),i.isSide()||t.isSide()){const e=this.fromNode;e!==null&&e.Wi(this.fromPort)}this.invalidateRoute()}}get fromEndSegmentLength(){return this.q!==null?this.q.da:NaN}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;if(i!==t){if(t<0&&Util._(t,">= 0",Link,"fromEndSegmentLength"),this.Xe(),this.q.da=t,this.t("fromEndSegmentLength",i,t),this.computeSpot(!0,this.fromPort).isSide()){const e=this.fromNode;e!==null&&e.Wi(this.fromPort)}this.invalidateRoute()}}get fromShortLength(){return this.q!==null?this.q.ma:NaN}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(this.Xe(),this.q.ma=t,this.ee(),this.t("fromShortLength",i,t))}get toSpot(){return this.q!==null?this.q.ua:Spot.Default}set toSpot(t){const i=this.toSpot;if(!i.equals(t)){if(t=t.N(),this.Xe(),this.q.ua=t,this.t("toSpot",i,t),i.isSide()||t.isSide()){const e=this.toNode;e!==null&&e.Wi(this.toPort)}this.invalidateRoute()}}get toEndSegmentLength(){return this.q!==null?this.q.ga:NaN}set toEndSegmentLength(t){const i=this.toEndSegmentLength;if(i!==t){if(t<0&&Util._(t,">= 0",Link,"toEndSegmentLength"),this.Xe(),this.q.ga=t,this.t("toEndSegmentLength",i,t),this.computeSpot(!1,this.toPort).isSide()){const e=this.toNode;e!==null&&e.Wi(this.toPort)}this.invalidateRoute()}}get toShortLength(){return this.q!==null?this.q.pa:NaN}set toShortLength(t){const i=this.toShortLength;i!==t&&(this.Xe(),this.q.pa=t,this.ee(),this.t("toShortLength",i,t))}Ld(){const t=this.fromNode,i=this.toNode;let e=null;if(t!==null?i!==null?e=t.findCommonContainingGroup(i):e=t.containingGroup:i!==null?e=i.containingGroup:e=null,this.Yv(e),this.isLabeledLink){const s=this.labelNodes;for(;s.next();){const n=s.value;n.containingGroup=e}}}Yv(t){const i=this.ph;if(i!==t){i!==null&&i.G2(this),this.ph=t,t!==null&&t.j2(this);const e=this.containingGroupChanged;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.Y,n.Y=!0),e(this,i,t),n!==null&&(n.Y=s)}this.Me&&(this._2===i||this.tN===i)&&this.invalidateRoute()}}ch(){const t=this.containingGroup;t!==null&&this.fromNode!==t&&this.toNode!==t&&t.computesBoundsIncludingLinks&&super.ch()}getOtherNode(t){const i=this.fromNode;return t===i?this.toNode:i}getOtherPort(t){const i=this.fromPort;return t===i?this.toPort:i}get isLabeledLink(){return this.Hs===null?!1:this.Hs.count>0}get labelNodes(){return this.Hs===null?EmptyIterator.instance:this.Hs.iterator}QA(t){this.Hs===null&&(this.Hs=new GSet),this.Hs.add(t),this.c()}_A(t){this.Hs!==null&&(this.Hs.delete(t),this.c())}Em(t){if(super.Em(t),this.Oa()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.lo;let e=null;i!==null&&(e=this.fromPort,i.a1(this,e));const s=this.ao;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.a1(this,n)),this.wy()}}Bm(t){if(super.Bm(t),this.Oa()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.lo;let e=null;i!==null&&(e=this.fromPort,i.c1(this,e));const s=this.ao;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.c1(this,n)),this.yy()}}Kc(){if(this.Me=!0,this.Hs!==null){const i=this.diagram;if(i!==null){const s=this.Hs.copy().iterator;for(;s.next();){const n=s.value;i.remove(n)}}}if(this.data!==null){const i=this.diagram;i!==null&&i.partManager.nN(this)}}updateRelationshipsFromData(){if(this.data===null)return;const i=this.diagram;i!==null&&i.partManager.updateRelationshipsFromData(this)}move(t,i){const e=i?this.location:this.position;let s=e.x;isNaN(s)&&(s=0);let n=e.y;isNaN(n)&&(n=0);const o=t.x-s,r=t.y-n;if(i===!0)super.move(t,!1);else{const h=Point.X(e.x+o,e.y+r);super.move(h,!1),Point.s(h)}this.pr(o,r);const l=this.labelNodes;for(;l.next();){const h=l.value,a=h.position;h.moveTo(a.x+o,a.y+r)}}get relinkableFrom(){return(this.Nt&1)!==0}set relinkableFrom(t){const i=(this.Nt&1)!==0;i!==t&&(this.Nt=this.Nt^1,this.t("relinkableFrom",i,t),this.invalidateAdornments())}get relinkableTo(){return(this.Nt&2)!==0}set relinkableTo(t){const i=(this.Nt&2)!==0;i!==t&&(this.Nt=this.Nt^2,this.t("relinkableTo",i,t),this.invalidateAdornments())}canRelinkFrom(){if(!this.relinkableFrom)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}canRelinkTo(){if(!this.relinkableTo)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}get resegmentable(){return(this.Nt&4)!==0}set resegmentable(t){const i=(this.Nt&4)!==0;i!==t&&(this.Nt=this.Nt^4,this.t("resegmentable",i,t),this.invalidateAdornments())}get isTreeLink(){return(this.Nt&8)!==0}set isTreeLink(t){const i=(this.Nt&8)!==0;i!==t&&(this.Nt=this.Nt^8,this.t("isTreeLink",i,t),this.fromNode!==null&&this.fromNode.f0(),this.toNode!==null&&this.toNode.f0())}get path(){const t=this.findMainElement();return t instanceof Shape?t:null}get routeBounds(){return this.updateRoute(),this.Gv(this.Sf)}Gv(t){let i=1/0,e=1/0;const s=this.pointsCount;if(s===0)return t.e(NaN,NaN,0,0),t;if(s===1){const n=this.getPoint(0);i=Math.min(n.x,i),e=Math.min(n.y,e),t.e(n.x,n.y,0,0)}else if(s===2){const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o)}else if(this.computeCurve()===9&&s>=3&&!this.isOrthogonal){let n=this.getPoint(0);if(i=n.x,e=n.y,t.e(i,e,0,0),s===3){const o=this.getPoint(1);i=Math.min(o.x,i),e=Math.min(o.y,e);const r=this.getPoint(2);i=Math.min(r.x,i),e=Math.min(r.y,e),Geo.hu(n.x,n.y,o.x,o.y,o.x,o.y,r.x,r.y,.5,t)}else for(let o=3;o=s&&(o=s-1);const l=this.getPoint(o-1),h=this.getPoint(o);Geo.hu(n.x,n.y,r.x,r.y,l.x,l.y,h.x,h.y,.5,t),i=Math.min(h.x,i),e=Math.min(h.y,e),n=h}}else{const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o);for(let r=2;r=15||this.computeCurve()===9)){this.ct.getPointAlongPath(.5,t),t.add(this.getPoint(0));const a=this.ct.figures.first();return t.offset(-a.startX,-a.startY),t}if(this.computeCurve()===9){if(i===3){const f=this.getPoint(0),u=this.getPoint(1),d=this.getPoint(2);return Geo.fC(f.x,f.y,u.x,u.y,u.x,u.y,d.x,d.y,t),t}const a=(i-1)/3|0,c=(a/2|0)*3;if(a%2===1){const f=this.getPoint(c),u=this.getPoint(c+1),d=this.getPoint(c+2),m=this.getPoint(c+3);return Geo.fC(f.x,f.y,u.x,u.y,d.x,d.y,m.x,m.y,t),t}else return t.a(this.getPoint(c)),t}const e=this.flattenedLengths,s=this.flattenedTotalLength;let n=0,o=0,r=0;for(;ns/2));)n+=r,o++;const l=this.getPoint(o),h=this.getPoint(o+1);if(Math.abs(l.x-h.x)<1)l.y>h.y?t.e(l.x,l.y-(s/2-n)):t.e(l.x,l.y+(s/2-n));else if(Math.abs(l.y-h.y)<1)l.x>h.x?t.e(l.x-(s/2-n),l.y):t.e(l.x+(s/2-n),l.y);else{const a=(s/2-n)/r,c=a*(h.x-l.x),f=a*(h.y-l.y);t.e(l.x+c,l.y+f)}return t}get midAngle(){return this.updateRoute(),this.computeMidAngle()}computeMidAngle(){const t=this.pointsCount;if(t<2)return NaN;if(t===2){const h=this.getPoint(0),a=this.getPoint(1);return h.directionPoint(a)}if(this.isOrthogonal&&(this.computeCorner()>=15||this.computeCurve()===9))return this.ct.getAngleAlongPath(.5);if(this.computeCurve()===9&&t>=4){const h=(t-1)/3|0;let a=(h/2|0)*3;if(h%2===1){a=Math.floor(a);const c=this.getPoint(a),f=this.getPoint(a+1),u=this.getPoint(a+2),d=this.getPoint(a+3);return Geo.FD(c.x,c.y,f.x,f.y,u.x,u.y,d.x,d.y)}else if(a>0&&a+1e/2));)s+=o,n++;const r=this.getPoint(n),l=this.getPoint(n+1);if(Math.abs(r.x-l.x)<1&&Math.abs(r.y-l.y)<1){if(n>0&&n+2l.y?270:90;if(Math.abs(r.y-l.y)<1)return r.x>l.x?180:0}return r.directionPoint(l)}jv(){if(this.py===null){this.Me||this.d1();const t=this.py=[];this.Hv(t)}}get flattenedLengths(){return this.jv(),this.py}get flattenedTotalLength(){let t=this.u1;if(isNaN(t)){const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=3){let g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e);m=this.adjustPoints(0,g,o-1,p),m&&(g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e),this.adjustPoints(0,g,o-1,p))}m||(this.clearPoints(),u?this.qv(i,e,r,s,n,l):this.Wv(i,e,r,s,n,l))}else{const m=this.isAvoiding;d&&(f&&m||c)&&this.clearPoints();const g=c?this.computeCurviness():0,p=this.getLinkPoint(i,e,r,!0,f,s,n);let y=0,x=0,k=0;if(f||!h||c){let N=this.computeEndSegmentLength(i,e,r,!0);if(k=this.getLinkDirection(i,e,p,r,!0,f,s,n),c&&(h||r.equals(l)||!f&&r.x+l.x===1&&r.y+l.y===1)&&(k-=f?90:30,g<0&&(k-=180)),k<0?k+=360:k>=360&&(k-=360),c&&(N+=Math.abs(g)*(f?1:2)),k===0?y=N:k===90?x=N:k===180?y=-N:k===270?x=-N:(y=N*Math.cos(k*Math.PI/180),x=N*Math.sin(k*Math.PI/180)),r.isNoSpot()&&c){const T=e.getDocumentPoint(Spot.Center,Point.l()),A=Point.X(T.x+y*1e3,T.y+x*1e3);this.getLinkPointFromPoint(i,e,T,A,!0,p),Point.s(T),Point.s(A)}}const b=this.getLinkPoint(s,n,l,!1,f,i,e);let P=0,S=0,L=0;if(f||!a||c){let N=this.computeEndSegmentLength(s,n,l,!1);if(L=this.getLinkDirection(s,n,b,l,!1,f,i,e),c&&(a||r.equals(l)||!f&&r.x+l.x===1&&r.y+l.y===1)&&(L+=f?0:30,g<0&&(L+=180)),L<0?L+=360:L>=360&&(L-=360),c&&(N+=Math.abs(g)*(f?1:2)),L===0?P=N:L===90?S=N:L===180?P=-N:L===270?S=-N:(P=N*Math.cos(L*Math.PI/180),S=N*Math.sin(L*Math.PI/180)),l.isNoSpot()&&c){const T=n.getDocumentPoint(Spot.Center,Point.l()),A=Point.X(T.x+P*1e3,T.y+S*1e3);this.getLinkPointFromPoint(s,n,T,A,!1,b),Point.s(T),Point.s(A)}}let C=p;(f||!h||c)&&(C=new Point(p.x+y,p.y+x));let M=b;(f||!a||c)&&(M=new Point(b.x+P,b.y+S)),!d&&!f&&h&&o>3&&this.adjustPoints(0,p,o-2,M)?this.setPoint(o-1,b):!d&&!f&&a&&o>3&&this.adjustPoints(1,C,o-1,b)?this.setPoint(0,p):!d&&(f?o>=6:o>4)&&this.adjustPoints(1,C,o-2,M)?(this.setPoint(0,p),this.setPoint(o-1,b)):(this.clearPoints(),this.addPoint(p),(f||!h||c)&&this.addPoint(C),f&&this.addOrthoPoints(C,k,M,L,i,s),(f||!a||c)&&this.addPoint(M),this.addPoint(b))}return t.addInvalidRoute(this),!0}rN(t,i){return Math.abs(i.x-t.x)>Math.abs(i.y-t.y)?(i.x>=t.x?i.x=t.x+9e9:i.x=t.x-9e9,i.y=t.y):(i.y>=t.y?i.y=t.y+9e9:i.y=t.y-9e9,i.x=t.x),i}getLinkPointFromPoint(t,i,e,s,n,o){if(o===void 0&&(o=new Point),t===null||i===null)return o.a(e),o;if(!t.isVisible()){const u=t.findVisibleNode();u!==null&&u!==t&&(t=u,i=t.port)}let r=0,l=0,h=0,a=0,c=null,f=i.panel;if(f!==null&&!f.pn()&&(f=f.panel),f===null)r=s.x,l=s.y,h=e.x,a=e.y;else{c=f.Es;const u=1/(c.m11*c.m22-c.m12*c.m21),d=c.m22*u,m=-c.m12*u,g=-c.m21*u,p=c.m11*u,y=u*(c.m21*c.dy-c.m22*c.dx),x=u*(c.m12*c.dx-c.m11*c.dy);r=s.x*d+s.y*g+y,l=s.x*m+s.y*p+x,h=e.x*d+e.y*g+y,a=e.x*m+e.y*p+x}return i.Zc(r,l,h,a,o),c!==null&&o.D(c),o}Jv(t,i){const e=t.Ju;return e!==null?e.nT(i):null}m1(t){let i=t.Ju;return i===null&&(i=new Knot,i.Qo=t,i.de=t.part,t.Ju=i),i.nT(this)}getLinkPoint(t,i,e,s,n,o,r,l){if(l===void 0&&(l=new Point),e.isSpot()&&!this.Id(e))return i.getDocumentPoint(e,l),l;if(e.isSide()){const c=this.m1(i);if(c!==null){const f=c.Ed;if(l.a(f),n&&this.routing===7){const u=this.m1(r);if(u!==null&&c.Mf=g.y&&y.y<=g.y+g.height?l.y=y.y:(e.includesSide(Spot.TopSide)||e.includesSide(Spot.BottomSide))&&y.x>=g.x&&y.x<=g.x+g.width&&(l.x=y.x),Point.s(d),Point.s(m)}}return l}}const h=i.getDocumentPoint(this.p1(e,s),Point.l());let a=null;if(this.pointsCount>(n?6:2))a=s?this.getPoint(1):this.getPoint(this.pointsCount-2),n&&(a=this.rN(h,a.copy()));else{const c=this.computeSpot(!s,r),f=Point.l();a=r.getDocumentPoint(this.p1(c,!s),f),n&&(a=this.rN(h,a)),Point.s(f)}return this.getLinkPointFromPoint(t,i,h,a,s,l),Point.s(h),l}getLinkDirection(t,i,e,s,n,o,r,l){let h=this.$v(t,i,e,s,n,o,r,l);if(r&&s.isNoSpot()&&r.isMemberOf(t)&&(h+=180,h>=360&&(h-=360)),this.Id(s))return h;const a=i.getDocumentAngle();return a===0||(45<=a&&a<135?h+=90:135<=a&&a<225?h+=180:225<=a&&a<315&&(h+=270),h>=360&&(h-=360)),h}$v(t,i,e,s,n,o,r,l){if(s.isSpot())return s.x>s.y?s.x>1-s.y?0:s.x<1-s.y?270:315:s.x1-s.y?90:s.x<1-s.y?180:135:s.x<.5?225:s.x>.5?45:0;if(s.isSide()){const f=this.m1(i);if(f!==null)switch(f.me){case 1:return 270;case 2:return 180;default:case 4:return 0;case 8:return 90}}const h=i.getDocumentPoint(Spot.Center,Point.l());let a=null;if(this.pointsCount>(o?6:2))a=n?this.getPoint(1):this.getPoint(this.pointsCount-2),o?a=this.rN(h,a.copy()):a=e;else{const f=Point.l();a=l.getDocumentPoint(Spot.Center,f),Point.s(f)}let c=0;return Math.abs(a.x-h.x)>Math.abs(a.y-h.y)?a.x>=h.x?c=0:c=180:a.y>=h.y?c=90:c=270,Point.s(h),c}computeEndSegmentLength(t,i,e,s){if(i!==null&&e.isSide()){const o=this.m1(i);if(o!==null)return o.w1}let n=NaN;return s?n=this.fromEndSegmentLength:n=this.toEndSegmentLength,i!==null&&isNaN(n)&&(s?n=i.fromEndSegmentLength:n=i.toEndSegmentLength),isNaN(n)&&(n=10),n}computeSpot(t,i){return i===void 0&&(i=null),t?this.Zv(i||this.fromPort):this.Qv(i||this.toPort)}Zv(t){if(t===null)return Spot.Center;let i=this.fromSpot;return i.isDefault()&&(i=t.fromSpot),i===Spot.Default?Spot.None:i}Qv(t){if(t===null)return Spot.Center;let i=this.toSpot;return i.isDefault()&&(i=t.toSpot),i===Spot.Default?Spot.None:i}Id(t){return t===Spot.None||t.x===.5&&t.y===.5}p1(t,i){return t.x===.5&&t.y===.5?t:Spot.Center}computeOtherPoint(t,i){if(this.computeAdjusting()!==0&&this.pointsCount>4)return this.computeMidPoint(new Point);{const e=this.Jv(i,this);return e!==null?e.Ed:i.getDocumentPoint(Spot.Center)}}computeShortLength(t){if(t){let i=this.fromShortLength;if(isNaN(i)){const e=this.fromPort;e!==null&&(i=e.fromShortLength)}return isNaN(i)?0:i}else{let i=this.toShortLength;if(isNaN(i)){const e=this.toPort;e!==null&&(i=e.toShortLength)}return isNaN(i)?0:i}}vm(t,i,e,s,n,o){if(this.pickable===!1)return!1;i===void 0&&(i=null),e===void 0&&(e=null);let r=o;if(o===void 0&&(r=Transform.l(),r.Ri()),r.ic(this.D),this.containedInRect(t,r))return this.D2(i,e,n),o===void 0&&Transform.s(r),!0;if(this.intersectsRect(t,r)){let l=!1;if(!this.af){const h=this.L.r,a=h.length;for(let c=a;c--;){const f=h[c];if(!f.visible&&f!==this.locationObject)continue;const u=f.actualBounds,d=this.naturalBounds;if(u.x>d.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;const m=f,g=Transform.l();if(g.set(r),m instanceof Panel?l=m.vm(t,i,e,s,n,g):this.path===m?m instanceof Shape&&(l=m.bv(t,s,g)):l=m.QL(t,s,g),l){let p=m;i!==null&&(p=i(m)),p&&(e===null||e(p))&&n.add(p)}Transform.s(g)}}return o===void 0&&Transform.s(r),l||this.background!==null}return o===void 0&&Transform.s(r),!1}get isOrthogonal(){return(this.Da&2)===2}static sN(t){return(t&2)===2}get isAvoiding(){return(this.Da&4)===4}computeCurve(){if(this.$o===null){const t=this.fromPort,i=t!==null&&t===this.toPort,e=this.isOrthogonal;this.$o=i&&!e}return this.$o?9:this.curve}computeCorner(){if(this.curve===9)return 0;let t=this.corner;return(isNaN(t)||t<0)&&(t=10),t}findMidLabel(){const t=this.path,i=this.L.r,e=i.length;for(let n=0;n0?g-=f:g+=f;else{const p=-h/a;let y=Math.sqrt(f*f/(p*p+1));c<0&&(y=-y),m=(a<0?-1:1)*y+u,g=p*(m-u)+d}this.addPoint(r),this.addPointAt(m,g),this.addPoint(l)}else{this.addPoint(r),this.addPoint(l);const h=Rect.l();i.getDocumentBounds(h);const a=h.containsPoint(l);n.getDocumentBounds(h);const c=h.containsPoint(r);if(a||c){const f=i.getDocumentPoint(this.p1(e,!0),new Point);this.setPoint(0,this.getLinkPointFromPoint(t,i,f,l,!0,f));const u=n.getDocumentPoint(this.p1(o,!1),new Point);this.setPoint(1,this.getLinkPointFromPoint(s,n,u,r,!1,u))}Rect.s(h)}}qv(t,i,e,s,n,o){const r=this.getLinkPoint(t,i,e,!0,!1,s,n),l=this.getLinkPoint(s,n,o,!1,!1,t,i),h=l.x-r.x,a=l.y-r.y,c=this.computeCurviness();let f=0,u=0,d=r.x+h/3,m=r.y+a/3,g=d,p=m;Geo.u(a,0)?h>0?p-=c:p+=c:(f=-h/a,u=Math.sqrt(c*c/(f*f+1)),c<0&&(u=-u),g=(a<0?-1:1)*u+d,p=f*(g-d)+m),d=r.x+2*h/3,m=r.y+2*a/3;let y=d,x=m;Geo.u(a,0)?h>0?x-=c:x+=c:(y=(a<0?-1:1)*u+d,x=f*(y-d)+m),this.clearPoints(),this.addPoint(r),this.addPointAt(g,p),this.addPointAt(y,x),this.addPoint(l),this.setPoint(0,this.getLinkPoint(t,i,e,!0,!1,s,n)),this.setPoint(3,this.getLinkPoint(s,n,o,!1,!1,t,i))}adjustPoints(t,i,e,s){let n=this.computeAdjusting();if(this.isOrthogonal){if(n===18)return!1;n===19&&(n=17)}switch(n){case 18:return this._v(t,i,e,s);case 19:return this.tO(t,i,e,s);case 17:return this.iO(t,i,e,s);default:return!1}}_v(t,i,e,s){const n=this.getPoint(t),o=this.getPoint(e);if(n.equalsApprox(i)&&o.equalsApprox(s))return!0;const r=n.x,l=n.y,h=o.x,a=o.y;let c=h-r,f=a-l;const u=Math.sqrt(c*c+f*f);if(Geo.K(u,0))return!0;let d=0;Geo.K(c,0)?f<0?d=-Math.PI/2:d=Math.PI/2:(d=Math.atan(f/Math.abs(c)),c<0&&(d=Math.PI-d));const m=i.x,g=i.y,p=s.x,y=s.y,x=p-m,k=y-g,b=Math.sqrt(x*x+k*k);let P=0;Geo.K(x,0)?k<0?P=-Math.PI/2:P=Math.PI/2:(P=Math.atan(k/Math.abs(x)),x<0&&(P=Math.PI-P));const S=b/u,L=P-d;this.setPoint(t,i);for(let C=t+1;C0&&(C=-C);const M=f+P*(d-f),N=u+P*(m-u);if(g!==0){const T=M+C/p,A=N-(T-M)/g;this.setPointAt(y,T,A)}else this.setPointAt(y,M,N+C)}return this.setPoint(e,s),!0}iO(t,i,e,s){if(this.isOrthogonal){let n=this.getPoint(t),o=this.getPoint(t+1),r=this.getPoint(t+2),l=o.x,h=o.y;const a=l,c=h;Geo.u(n.y,o.y)?Geo.u(o.x,r.x)?h=i.y:Geo.u(o.y,r.y)&&(l=i.x):Geo.u(n.x,o.x)&&(Geo.u(o.y,r.y)?l=i.x:Geo.u(o.x,r.x)&&(h=i.y)),this.setPointAt(t+1,l,h),n=this.getPoint(e),o=this.getPoint(e-1),r=this.getPoint(e-2);let f=o.x,u=o.y;const d=f,m=u;if(Geo.u(n.y,o.y)?Geo.u(o.x,r.x)?u=s.y:Geo.u(o.y,r.y)&&(f=s.x):Geo.u(n.x,o.x)&&(Geo.u(o.y,r.y)?f=s.x:Geo.u(o.x,r.x)&&(u=s.y)),this.setPointAt(e-1,f,u),this.AL())return this.setPointAt(t+1,a,c),this.setPointAt(e-1,d,m),!1}return this.setPoint(t,i),this.setPoint(e,s),!0}addOrthoPoints(t,i,e,s,n,o){i<0?i+=360:i>=360&&(i-=360),s<0?s+=360:s>=360&&(s-=360);const c=s;i>=315||i<45?i=0:45<=i&&i<135?i=90:135<=i&&i<225?i=180:i=270,s>=315||s<45?s=0:45<=s&&s<135?s=90:135<=s&&s<225?s=180:s=270;const f=t,u=e,d=n.actualBounds.copy(),m=o.actualBounds.copy();if(!d.isReal()||!m.isReal())return;d.inflate(Link.va,Link.va),m.inflate(Link.va,Link.va),d.unionPoint(t),m.unionPoint(e);const g=Point.l(),p=Point.l();i===0?u.x>f.x||s===270&&u.yf.x||s===90&&u.y>f.y&&m.right>f.x?(g.e(u.x,f.y),p.e(u.x,(f.y+u.y)/2),s===180?(g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1),p.x=g.x,p.y=u.y):s===270&&u.yf.y?(f.xm.bottom)?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):g.x=m.right,p.x=g.x,p.y=u.y):s===0&&f.xm.top&&f.yd.bottom)&&(s===180&&(m.containsPoint(f)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):u.yf.y&&(s===180||s===270)&&(g.y=this.computeMidOrthoPosition(f.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=d.left&&u.x<=f.x||f.x<=m.right&&f.x>=u.x?(s===90||s===270)&&(g.e(Math.max((f.x+u.x)/2,f.x),f.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yf.y&&m.leftf.y?(f.x>m.right?g.x=this.computeMidOrthoPosition(f.x,f.y,m.right,u.y,!1):f.x>m.left&&(s===270&&f.ym.bottom)?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):g.x=m.left,p.x=g.x,p.y=u.y):s===180&&f.x>m.right&&f.y>m.top&&f.yd.bottom)&&(s===0&&(m.containsPoint(f)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):u.yf.y&&(s===0||s===270)&&(g.y=this.computeMidOrthoPosition(f.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=f.x||f.x>=m.left&&f.x<=u.x?(s===90||s===270)&&(g.e(Math.min((f.x+u.x)/2,f.x),f.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yf.y||s===180&&u.xf.y||s===0&&u.x>f.x&&m.bottom>f.y?(g.e(f.x,u.y),p.e((f.x+u.x)/2,u.y),s===270?(g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0),p.x=u.x,p.y=g.y):s===180&&u.xf.x?(f.ym.right)?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):g.y=m.bottom,p.x=u.x,p.y=g.y):s===90&&f.ym.left&&f.xd.right)&&(s===270&&(m.containsPoint(f)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):u.xf.x&&(s===270||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,f.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=d.top&&u.y<=f.y||f.y<=m.bottom&&f.y>=u.y?(s===0||s===180)&&(g.e(f.x,Math.max((f.y+u.y)/2,f.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.xf.x&&m.top=f.x?(f.y>m.bottom?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,m.bottom,!0):f.y>m.top&&(s===180&&f.xm.right)?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):g.y=m.top,p.x=u.x,p.y=g.y):s===270&&f.y>m.bottom&&f.x>m.left&&f.xd.right)&&(s===90&&(m.containsPoint(f)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):u.xf.x&&(s===90||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,f.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=f.y||f.y>=m.top&&f.y<=u.y?(s===0||s===180)&&(g.e(f.x,Math.min((f.y+u.y)/2,f.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.x=3&&!Geo.K(this.smoothness,0))if(i===3){let c=this.getPoint(1);n=Math.min(r.x,c.x),o=Math.min(r.y,c.y),c=this.getPoint(2),n=Math.min(n,c.x),o=Math.min(o,c.y)}else if(this.isOrthogonal){for(let c=0;c=i&&(c=i-1);const f=this.getPoint(c);l.x=Math.min(f.x,l.x),l.y=Math.min(f.y,l.y)}n=l.x,o=l.y}else{for(let c=0;c=3&&!Geo.K(this.smoothness,0))if(i===3){const f=this.getPoint(1),u=f.x-n,d=f.y-o;let m=this.getPoint(2).copy();m.x-=n,m.y-=o,this.computeShortLength(!1)!==0&&(m=this.Nf(m,!1,l)),c.dr(u,d,u,d,m.x,m.y)}else if(this.isOrthogonal){const f=Point.X(n,o),u=Point.l();u.a(this.getPoint(1));const d=Point.X(n,o),m=Point.X(n,o);let g=this.getPoint(0),p=null;const y=this.smoothness/3;for(let P=1;P=i&&(f=i-1);const d=this.getPoint(f-1);let m=this.getPoint(f);f===i-1&&this.computeShortLength(!1)!==0&&(m=this.Nf(m.copy(),!1,Point.Po)),c.dr(u.x-n,u.y-o,d.x-n,d.y-o,m.x-n,m.y-o)}else{const f=Point.l();f.a(this.getPoint(0));const u=Point.l();u.a(f);const d=this.computeCorner();let m=1,g=0;for(;m1);let p=this.getPoint(m);if(m>=i-1){if(!f.equals(p))this.computeShortLength(!1)!==0&&(p=this.Nf(p.copy(),!1,Point.Po)),this.Nn(c,-n,-o,f,p,e);else if(g===0)for(m=1;mr?f>a?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):f>a?(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.K(r,h)&&Geo.K(a,f)&&(a>l?c>h?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):c>h?(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.K(r,h)&&Geo.K(h,c)||Geo.K(l,a)&&Geo.K(a,f)){const m=.5*(r+c),g=.5*(l+f);n.x=m,n.y=g,o.x=m,o.y=g}}Nf(t,i,e){const s=this.pointsCount;if(s<2)return t;if(i){const n=this.getPoint(1),o=n.x-e.x,r=n.y-e.y,l=this.b1(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!0);a>h&&(a=h);const c=a*(o-t.x)/l,f=a*(r-t.y)/l;t.x+=c,t.y+=f}else{const n=this.getPoint(s-2),o=n.x-e.x,r=n.y-e.y,l=this.b1(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!1);a>h&&(a=h);const c=a*(t.x-o)/l,f=a*(t.y-r)/l;t.x-=c,t.y-=f}return t}lN(t,i,e){const s=this.pointsCount;let n=t;for(;Geo.K(t.x,n.x)&&Geo.K(t.y,n.y);){if(i>=s)return s-1;n=this.getPoint(i++)}if(!Geo.K(t.x,n.x)&&!Geo.K(t.y,n.y))return i-1;let o=n;for(;Geo.K(t.x,n.x)&&Geo.K(n.x,o.x)&&(!e||(t.y>=n.y?n.y>=o.y:n.y<=o.y))||Geo.K(t.y,n.y)&&Geo.K(n.y,o.y)&&(!e||(t.x>=n.x?n.x>=o.x:n.x<=o.x));){if(i>=s)return s-1;o=this.getPoint(i++)}return i-2}nO(t,i,e,s,n,o,r,l,h,a){if(Geo.u(s.y,n.y)&&Geo.u(n.x,o.x)){let c=Math.min(h,Math.abs(n.x-l.x)/2);const f=Math.min(c,Math.abs(o.y-n.y)/2);if(c=f,Geo.u(c,0)){this.Nn(t,i,e,s,n,a),r.a(n);return}let u=n.x;const d=n.y,m=u;let g=d;n.x>s.x?(u=n.x-c,o.y>n.y?g=n.y+f:g=n.y-f):(u=n.x+c,o.y>n.y?g=n.y+f:g=n.y-f);const p=Point.X(u,d);this.Nn(t,i,e,s,p,a),Point.s(p),t.Mw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else if(Geo.u(s.x,n.x)&&Geo.u(n.y,o.y)){let c=Math.min(h,Math.abs(n.y-l.y)/2);const f=Math.min(c,Math.abs(o.x-n.x)/2);if(c=f,Geo.u(f,0)){this.Nn(t,i,e,s,n,a),r.a(n);return}const u=n.x;let d=n.y,m=u;const g=d;n.y>s.y?(d=n.y-c,o.x>n.x?m=n.x+f:m=n.x-f):(d=n.y+c,o.x>n.x?m=n.x+f:m=n.x-f);const p=Point.X(u,d);this.Nn(t,i,e,s,p,a),Point.s(p),t.Mw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else this.Nn(t,i,e,s,n,a),r.a(n)}computeJumpLength(){return 10}Nn(t,i,e,s,n,o){if(o||!this.Oa())t.ur(n.x+i,n.y+e);else{const r=this.computeJumpLength(),l=r/2,h=[];let a=0;this.isVisible()&&(a=this.oO(s,n,h));let c=s.x,f=s.y;if(a>0){if(Geo.u(s.y,n.y))if(s.x=0;){const d=Math.min(s.x,Math.max(h[u--]+l,n.x+r));t.ur(d+i,n.y+e),c=d+i,f=n.y+e;let m=Math.max(d-r,n.x);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.x);else break}const g=n.y-r+e,p=m+i,y=n.y+e;this.curve===10?t.fu(p,y,!1,!1):t.dr(c,g,p,g,p,y),c=p,f=y}}else if(Geo.u(s.x,n.x))if(s.y=0;){const d=Math.min(s.y,Math.max(h[u--]+l,n.y+r));t.ur(n.x+i,d+e),c=n.x+i,f=d+e;let m=Math.max(d-r,n.y);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.y);else break}const g=n.x-r+i,p=n.x+i,y=m+e;this.curve===10?t.fu(p,y,!1,!1):t.dr(g,f,g,y,p,y),c=p,f=y}}}t.ur(n.x+i,n.y+e)}}oO(t,i,e){const s=this.diagram;if(s===null||t.equals(i))return 0;const n=s.layers;for(;n.next();){const o=n.value;if(o!==null&&o.visible){const r=o.ES(),l=r.length;for(let h=0;h0&&e.sort((u,d)=>u-d),e.length;if(!a.isVisible()||!a.Oa())continue;const c=a.routeBounds;if(!c.isReal()||!this.routeBounds.intersectsRect(c)||this.usesSamePort(a))continue;const f=a.path;f!==null&&f.isVisibleObject()&&this.rO(t,i,e,a)}}}return e.length>0&&e.sort((o,r)=>o-r),e.length}rO(t,i,e,s){const n=Geo.u(t.y,i.y),o=s.pointsCount;let r=s.getPoint(0);const l=Point.l();for(let h=1;hr.x&&c.x>=a.x||a.xr.y&&c.y>=a.y||a.yc&&Math.min(a,f)o&&!Geo.u(a,f))return n.x=o,n.y=c,!0}else if(Geo.u(r,h)&&Geo.u(a,f)&&Math.min(o,l)a&&Math.min(c,u)r&&!Geo.u(c,u))return n.x=a,n.y=r,!0;return n.x=0,n.y=0,!1}get firstPickIndex(){return this.pointsCount<=2?0:this.isOrthogonal||!this.Id(this.computeSpot(!0))?1:0}get lastPickIndex(){const t=this.pointsCount;return t===0?0:t<=2?t-1:this.isOrthogonal||!this.Id(this.computeSpot(!1))?t-2:t-1}Oa(){const t=this.curve;return t===11||t===10}g1(t){if(t||this.Oa()){const i=this.diagram;i!==null&&!i.animationManager.isTicking&&!i.$l.has(this)&&(this.Sf.width!==0||this.Sf.height!==0)&&i.$l.set(this,this.Sf.copy())}}invalidateOtherJumpOvers(t){const i=this.layer;if(i===null||!i.visible||i.isTemporary)return;const e=i.diagram;if(e===null||e.animationManager.isTicking)return;let s=!1;const n=e.layers;for(;n.next();){const o=n.value;if(o.visible){if(o===i){s=!0;let r=!1;const l=o.ES(),h=l.length;for(let a=0;a0&&e>0){const s=this.getPoint(0),n=t.getPoint(0);if(s.equalsApprox(n))return!0;const o=this.getPoint(i-1),r=t.getPoint(e-1);if(o.equalsApprox(r)||s.equalsApprox(r)||o.equalsApprox(n))return!0}else if(this.fromNode===t.fromNode||this.toNode===t.toNode||this.fromNode===t.toNode||this.toNode===t.fromNode)return!0;return!1}isVisible(){if(!super.isVisible())return!1;const t=this.containingGroup;let i=!0;const e=this.diagram;e!==null&&(i=e.isTreePathToChildren);const s=this.fromNode;if(s!==null){if(this.isTreeLink&&i&&!s.isTreeExpanded)return!1;if(s===t)return!0;let o=s;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=s.findVisibleNode();if(r===null||r===t)return!1}const n=this.toNode;if(n!==null){if(this.isTreeLink&&!i&&!n.isTreeExpanded)return!1;if(n===t)return!0;let o=n;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=n.findVisibleNode();if(r===null||r===t)return!1}return!0}Ei(t){if(super.Ei(t),t&&this.g1(!1),this.Zo!==null&&this.Zo.Ad(),this.Hs!==null){const e=this.Hs.iterator;for(;e.next();)e.value.Ei(t)}}get adjusting(){return this.Pf}set adjusting(t){const i=this.Pf;i!==t&&(this.Pf=t,this.t("adjusting",i,t))}computeAdjusting(){return this.isAvoiding&&this.diagram!==null&&this.diagram.animationManager.defaultAnimation.isAnimating?17:this.Pf}get corner(){return this.Fd}set corner(t){const i=this.Fd;i!==t&&(this.Fd=t,this.ee(),this.t("corner",i,t))}get curve(){return this.Rd}set curve(t){const i=this.Rd;i!==t&&(this.Rd=t,this.invalidateRoute(),this.ee(),this.g1(i===10||i===11||t===10||t===11),this.t("curve",i,t))}get curviness(){return this.vd}set curviness(t){const i=this.vd;i!==t&&(this.vd=t,this.invalidateRoute(),this.ee(),this.t("curviness",i,t))}get routing(){return this.Da}set routing(t){const i=this.Da;i!==t&&(this.Da=t,this.isAvoiding&&this.diagram!==null&&(this.diagram.Ym=!0),this.$o=null,this.invalidateRoute(),this.g1(Link.sN(i)||Link.sN(t)),this.t("routing",i,t))}get smoothness(){return this.Od}set smoothness(t){const i=this.Od;i!==t&&(this.Od=t,this.ee(),this.t("smoothness",i,t))}wy(){const t=this.lo;if(t===null)return;const i=this.ao;if(i===null||!isNaN(this.curviness))return;const e=this.ho,s=this.co;let n=null,o=null;const r=t._t.r,l=r.length;for(let h=0;h=0&&(Util.tc(t.qs,i),t.Ad())}}Cl(){return!0}get key(){const t=this.diagram;if(!(t===null||!t.model.Ta()))return t.model.getKeyForLinkData(this.data)}}class LinkBundle{Eo;Os;ry;J2;h1;$2;qs;constructor(t,i,e,s){GSet.Yi(this),this.Eo=!1,this.Os=!1,this.ry=t,this.J2=i,this.h1=e,this.$2=s,this.qs=[]}Ad(){if(!this.Eo){const t=this.qs;if(t.length>0){const i=t[0].diagram;i!==null&&(i.lM.add(this),this.Os=i.undoManager.isUndoingRedoing)}}this.Eo=!0}bM(){if(this.Eo){this.Eo=!1;const t=this.qs;if(t.length>0){const i=t[0],e=i.diagram,s=e===null||e.Bh&&!this.Os;this.Os=!1,i.arrangeBundledLinks(t,s),t.length===1&&(i.Zo=null,t.length=0)}t.length===0&&(this.ry.JA(this),this.h1.JA(this))}}}class PositionArray{oe;re;Ia;Ea;pi;yi;Ot;xh;bh;ha;RM;Eo;by;Gc;vM;OM;constructor(t){GSet.Yi(this),this.ha=null,this.RM=null,this.Eo=!0,this.by=!1,this.oe=1,this.re=1,this.Ia=-1,this.Ea=-1,this.pi=t.width,this.yi=t.height,this.Ot=null,this.xh=0,this.bh=0,this.Gc=11,this.vM=this.Gc*2,this.OM=this.Gc*2}static Ws=0;static Ba=1;static Bd=999999;static hN=PositionArray.Bd+1;static aN=PositionArray.Bd+2;kb(t){if(t.width<=0||t.height<=0)return;const i=t.x,e=t.y,s=t.x+t.width,n=t.y+t.height;this.oe=Math.floor((i-this.pi)/this.pi)*this.pi,this.re=Math.floor((e-this.yi)/this.yi)*this.yi,this.Ia=Math.ceil((s+2*this.pi)/this.pi)*this.pi,this.Ea=Math.ceil((n+2*this.yi)/this.yi)*this.yi;const o=1+(Math.ceil((this.Ia-this.oe)/this.pi)|0),r=1+(Math.ceil((this.Ea-this.re)/this.yi)|0);if(this.Ot===null||this.xh0&&t!==this.pi&&(this.pi=t,this.kb(this.bounds))}get cellHeight(){return this.yi}set cellHeight(t){t>0&&t!==this.yi&&(this.yi=t,this.kb(this.bounds))}Ud(t,i){return this.oe<=t&&t<=this.Ia&&this.re<=i&&i<=this.Ea}fo(t,i){if(!this.Ud(t,i))return PositionArray.hN;t-=this.oe,t/=this.pi,i-=this.re,i/=this.yi;const e=t|0,s=i|0;return this.Ot[e][s]}pR(t,i,e,s){if(!this.Ud(t,i))return;const n=(t-this.oe)/this.pi|0,o=(i-this.re)/this.yi|0,r=(t+e-this.oe)/this.pi|0,l=(i+s-this.re)/this.yi|0,h=Math.min(r,this.xh),a=Math.min(l,this.bh);for(let c=n;c<=h;c++){const f=this.Ot[c];if(f.fill)f.fill(PositionArray.Ws,o,a+1);else for(let u=o;u<=a;u++)f[u]=PositionArray.Ws}}hO(t){if(this.Ot!==null)for(let i=0;i<=this.xh;i++){const e=this.Ot[i];if(e.fill)e.fill(t);else for(let s=0;s<=this.bh;s++)e[s]=t}}zL(){if(this.Ot!==null)for(let t=0;t<=this.xh;t++){const i=this.Ot[t];for(let e=0;e<=this.bh;e++)i[e]>=PositionArray.Ba&&(i[e]=PositionArray.hN)}}aO(t,i){return this.fo(t,i)===PositionArray.Ws}isUnoccupied(t,i,e,s){if(t>this.Ia||t+ethis.Ea||i+sthis.Ia||ithis.Ea||ethis.Ea||ithis.Ia||e=PositionArray.Ba&&h=a)break;this.Ot[t][i]=h,h+=1,s?i+=e:t+=e}return s?i:t}uo(t,i,e,s,n,o,r,l){if(to||il)return;const h=this.cO(t,i,e,s,n,o,r,l);if(s)if(e>0)for(let a=i+e;ah;a+=e)this.uo(t,a,1,!s,n,o,r,l),this.uo(t,a,-1,!s,n,o,r,l);else if(e>0)for(let a=t+e;ah;a+=e)this.uo(a,i,1,!s,n,o,r,l),this.uo(a,i,-1,!s,n,o,r,l)}k1(t,i,e,s,n,o,r,l,h,a){let c=t|0,f=i|0,u=PositionArray.Ws,d=PositionArray.Ba;for(this.Ot[c][f]=d;u===PositionArray.Ws&&c>r&&ch&&fr&&ch&&f=0;v-=2){F=A[v+2],R=A[v+3];const O=A[v],B=A[v+1];for(;O>F?F++:OR?R++:Bs)d--;else break;else if(m>n)m--;else break;const g=c[d][m];if(g===0||g===PositionArray.aN)break;f=d,u=m}for(;;){let d=e,m=f,g=u;e===0?gn&&(d=270,g--):e===90?ms&&(d=180,m--):e===180?gn&&(d=270,g--):ms&&(d=180,m--);const p=c[m][g];if(d!==e&&p!==0&&p!==PositionArray.aN){if(o.push(f),o.push(u),this.lT(f,u,d,s,n,o))return!0;o.pop(),o.pop()}if(c[f][u]=PositionArray.aN,e===0){if(f===t)return!1;f--}else if(e===90){if(u===i)return!1;u--}else if(e===180){if(f===t)return!1;f++}else{if(u===i)return!1;u++}}}}class Knot{de;Qo;rs;Vd;constructor(){GSet.Yi(this),this.de=null,this.Qo=null,this.rs=[],this.Vd=!1}toString(){const t=this.rs;let i=this.de.toString()+" "+t.length.toString()+":";for(let e=0;e180?270:90;case 6:return o>90&&o<=270?180:0}const r=Math.atan2(t.height,t.width)*180/Math.PI;switch(n){case 3:return o>r&&o<=180+r?180:270;case 5:return o>180-r&&o<=360-r?270:0;case 12:return o>r&&o<=180+r?90:0;case 10:return o>180-r&&o<=360-r?180:90;case 7:return o>90&&o<=180+r?180:o>180+r&&o<=360-r?270:0;case 13:return o>180&&o<=360-r?270:o>r&&o<=180?90:0;case 14:return o>r&&o<=180-r?90:o>180-r&&o<=270?180:0;case 11:return o>180-r&&o<=180+r?180:o>180+r?270:90}return s&&n!==15&&(o-=15,o<0&&(o+=360)),o>r&&o<180-r?90:o>=180-r&&o<=180+r?180:o>180+r&&o<360-r?270:0}Ad(){this.rs.length=0}nT(t){let i=this.rs;i.length===0&&(this.uO(),i=this.rs);for(let e=0;e=360&&(S-=360);const L=this.fO(h,y,S,g.isOrthogonal);let C=0;L===0?(C=4,S>180&&(S-=360)):L===90?(C=8,S>270&&(S-=360)):L===180?C=2:(C=1,S<90&&(S+=360));let M=this.rs[o];M===void 0?(M=new LinkInfo(g,S,C),this.rs[o]=M):(M.He=g,M.Xt=S,M.me=C),M.S1.set(P),o++}Point.s(a),this.dO();const u=this.rs.length;let d=-1,m=0;for(o=0;o=0;o--){const g=this.rs[o];g!==void 0&&(g.me!==d&&(d=g.me,m=g.zd+1),g.Mf=m)}this.gO(this.rs),this.mO(this.rs),this.Vd=t,Rect.s(h)}return this.rs}pO(t,i){return t===i?0:t===null?-1:i===null?1:t.mei.me?1:t.Xti.Xt?1:0}dO(){this.rs.sort(Knot.prototype.pO)}gO(t){const i=this.Qo,e=this.de.portSpreading,s=Point.l(),n=Point.l(),o=Point.l(),r=Point.l();i.getDocumentPoint(Spot.TopLeft,s),i.getDocumentPoint(Spot.TopRight,n),i.getDocumentPoint(Spot.BottomRight,o),i.getDocumentPoint(Spot.BottomLeft,r);let l=0,h=0,a=0,c=0;if(e===2)for(let x=0;xMath.abs(p)?(d=Math.abs(p)/a,a=Math.abs(p)):d=1;break;case 2:c>Math.abs(y)?(d=Math.abs(y)/c,c=Math.abs(y)):d=1;break;case 1:l>Math.abs(p)?(d=Math.abs(p)/l,l=Math.abs(p)):d=1;break;default:case 4:h>Math.abs(y)?(d=Math.abs(y)/h,h=Math.abs(y)):d=1;break}u=0}const b=k.Ed;if(e===2){let P=k.He.computeThickness();switch(P*=d,b.set(m),f){case 8:b.x=m.x+p/2+a/2-u-P/2;break;case 2:b.y=m.y+y/2+c/2-u-P/2;break;case 1:b.x=m.x+p/2-l/2+u+P/2;break;default:case 4:b.y=m.y+y/2-h/2+u+P/2;break}u+=P}else{let P=.5;e===1&&(P=(k.zd+1)/(k.Mf+1)),b.x=m.x+p*P,b.y=m.y+y*P}}Point.s(s),Point.s(n),Point.s(o),Point.s(r)}mO(t){for(let i=0;ie instanceof Placeholder);i instanceof Placeholder?t.It=i:t.It=null,this.ie!==null?(t.ie=this.ie.copy(),t.ie.group=t):(t.ie!==null&&(t.ie.group=null),t.ie=null),this.ni!==null&&(t.ni=this.ni.copy())}Vo(t){super.Vo(t);const i=t.findSubGraphParts(),e=t.memberParts;for(;e.next();){const s=e.value;if(s.c(),s.invalidateLayout(8),s.clearAdornments(),s instanceof Node)s.invalidateConnectedLinks(i);else if(s instanceof Link){const n=s.labelNodes;for(;n.next();)n.value.invalidateConnectedLinks(i)}}}Jc(t,i,e,s,n,o,r){if(t===3&&i==="elements"){if(n instanceof Placeholder)this.It===null?this.It=n:this.It!==n&&Util.o("Cannot insert a second Placeholder into the visual tree of a Group.");else if(n instanceof Panel){const l=n.findInVisualTree(h=>h instanceof Placeholder);l instanceof Placeholder&&(this.It===null?this.It=l:this.It!==l&&Util.o("Cannot insert a second Placeholder into the visual tree of a Group."))}}else t===4&&i==="elements"&&this.It!==null&&(s===this.It?this.It=null:s instanceof Panel&&this.It.isContainedBy(s)&&(this.It=null));super.Jc(t,i,e,s,n,o,r)}td(t,i){if(super.td(t,i),this.isClipping&&this.type!==Panel.Spot&&this.isSubGraphExpanded){let e=this.resizeObject;e instanceof Panel&&(e=e.findMainElement()),this.ni===null&&(this.ni=new Rect),e.getDocumentBounds(this.ni),e instanceof Shape&&this.ni.inflate(-e.strokeWidth,-e.strokeWidth)}}ah(t,i,e,s){this.hasPlaceholder()&&(this.Jo=this.placeholder),super.ah(t,i,e,s)}ensureBounds(){this.isSubGraphExpanded&&this.memberParts.each(i=>{i.ensureBounds()}),super.ensureBounds()}Hr(){if(!super.Hr())return!1;const t=this.memberParts;for(;t.next();){const i=t.value;if(i instanceof Node){if(!i.isVisible())continue;if(i.is())return!1}else if(i instanceof Link){if(!i.isVisible())continue;if(i.is()&&i.fromNode!==this&&i.toNode!==this)return!1}}return!0}hasPlaceholder(){return this.It!==null&&this.It.isVisibleObject()&&this.isSubGraphExpanded}get placeholder(){return this.It}get computesBoundsAfterDrag(){return(this.E&2048)!==0}set computesBoundsAfterDrag(t){const i=(this.E&2048)!==0;i!==t&&(Util.i(t,"boolean",Group,"computesBoundsAfterDrag"),this.E=this.E^2048,this.t("computesBoundsAfterDrag",i,t))}get computesBoundsIncludingLinks(){return(this.E&4096)!==0}set computesBoundsIncludingLinks(t){Util.i(t,"boolean",Group,"computesBoundsIncludingLinks");const i=(this.E&4096)!==0;i!==t&&(this.E=this.E^4096,this.t("computesBoundsIncludingLinks",i,t))}get computesBoundsIncludingLocation(){return(this.E&8192)!==0}set computesBoundsIncludingLocation(t){Util.i(t,"boolean",Group,"computesBoundsIncludingLocation");const i=(this.E&8192)!==0;i!==t&&(this.E=this.E^8192,this.t("computesBoundsIncludingLocation",i,t))}get handlesDragDropForMembers(){return(this.E&16384)!==0}set handlesDragDropForMembers(t){Util.i(t,"boolean",Group,"handlesDragDropForMembers");const i=(this.E&16384)!==0;i!==t&&(this.E=this.E^16384,this.t("handlesDragDropForMembers",i,t))}get avoidableMembers(){return(this.E&131072)!==0}set avoidableMembers(t){Util.i(t,"boolean",Group,"avoidableMembers");const i=(this.E&131072)!==0;i!==t&&(this.E=this.E^131072,this.t("avoidableMembers",i,t))}get memberParts(){return this.Xd.iterator}j2(t){if(this.Xd.add(t)){t instanceof Group&&this.la.add(t);const e=this.memberAdded;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.Y,n.Y=!0),e(this,t),n!==null&&(n.Y=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ei(!1)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.It;i===null&&(i=this),i.c()}G2(t){if(this.Xd.delete(t)){t instanceof Group&&this.la.delete(t);const e=this.memberRemoved;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.Y,n.Y=!0),e(this,t),n!==null&&(n.Y=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ei(!0)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.It;i===null&&(i=this),i.c()}Kc(){if(this.Xd.count>0){const t=this.diagram;if(t!==null){const e=this.Xd.copy().iterator;for(;e.next();){const s=e.value;t.remove(s)}}}super.Kc()}get layout(){return this.ie}set layout(t){const i=this.ie;if(i!==t){t!==null&&t.diagram!==null&&t.diagram.layout===t&&Util.o("A layout cannot be both the Diagram.layout and a Group.layout: "+t),i!==null&&(i.diagram=null,i.group=null),this.ie=t;const e=this.diagram;t!==null&&(t.diagram=e,t.group=this),e!==null&&(e.Kr=!0),this.t("layout",i,t),e!==null&&e.requestUpdate()}}get memberAdded(){return this.gt!==null?this.gt.uy:null}set memberAdded(t){const i=this.memberAdded;i!==t&&(t!==null&&Util.i(t,"function",Group,"memberAdded"),this.cl(),this.gt.uy=t,this.t("memberAdded",i,t))}get memberRemoved(){return this.gt!==null?this.gt.gy:null}set memberRemoved(t){const i=this.memberRemoved;i!==t&&(t!==null&&Util.i(t,"function",Group,"memberRemoved"),this.cl(),this.gt.gy=t,this.t("memberRemoved",i,t))}get memberValidation(){return this.gt!==null?this.gt.eh:null}set memberValidation(t){const i=this.memberValidation;i!==t&&(t!==null&&Util.i(t,"function",Group,"memberValidation"),this.cl(),this.gt.eh=t,this.t("memberValidation",i,t))}canAddMembers(t){const i=this.diagram;if(i===null)return!1;const e=i.commandHandler,n=e.i2(t).iterator;for(;n.next();){const o=n.value;if(!e.isValidMember(this,o))return!1}return!0}addMembers(t,i){const e=this.diagram;if(e===null)return!1;const s=e.commandHandler,n=s.i2(t);let o=!0;const r=n.iterator;for(;r.next();){const l=r.value;!i||s.isValidMember(this,l)?l.containingGroup=this:o=!1}return o}get ungroupable(){return(this.E&256)!==0}set ungroupable(t){const i=(this.E&256)!==0;i!==t&&(Util.i(t,"boolean",Group,"ungroupable"),this.E=this.E^256,this.t("ungroupable",i,t))}canUngroup(){if(!this.ungroupable)return!1;const t=this.layer;if(t===null||!t.allowUngroup)return!1;const i=t.diagram;return!(i!==null&&!i.allowUngroup)}invalidateConnectedLinks(t){const i=this.wO();if(super.invalidateConnectedLinks(t),i)return;this.kL(!0);const e=this.findExternalLinksConnected();for(;e.next();){const s=e.value;if(t!==void 0&&t.has(s))continue;const n=s.fromNode;if(n!==null&&n!==this&&n.isMemberOf(this)&&!n.isVisible())n.Wi(s.fromPort),n.Wi(s.toPort),s.invalidateRoute();else{const o=s.toNode;o!==null&&o!==this&&o.isMemberOf(this)&&!o.isVisible()&&(o.Wi(s.fromPort),o.Wi(s.toPort),s.invalidateRoute())}}}findExternalLinksConnected(){const t=this.diagram!==null&&this.diagram.dM;if(t&&this.u0!==null)return this.u0.iterator;const i=this.findSubGraphParts();i.add(this);const e=new GSet,s=i.iterator;for(;s.next();){const n=s.value;if(!(n instanceof Node))continue;const o=n.linksConnected;for(;o.next();){const r=o.value;i.has(r)||e.add(r)}}return t&&(this.u0=e),e.iterator}findExternalNodesConnected(){const t=this.findSubGraphParts();t.add(this);const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;if(!(s instanceof Node))continue;const n=s.linksConnected;for(;n.next();){const o=n.value,r=o.fromNode;r!==null&&(!t.has(r)||r===this)&&i.add(r);const l=o.toNode;l!==null&&(!t.has(l)||l===this)&&i.add(l)}}return i.iterator}mE(){function t(e,s){e!==null&&(s.add(e),t(e.containingGroup,s))}const i=new GSet;return t(this,i),i}findSubGraphParts(){const t=new GSet;return Part.sh(t,this,!0,0,!0),t.delete(this),t}Ei(t){super.Ei(t);const i=this.memberParts;for(;i.next();)i.value.Ei(t)}collapseSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.hT(i,t,this),t.isCollapsingExpanding=!1}hT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ei(!1),n instanceof Group&&n.isSubGraphExpanded&&(n.wasSubGraphExpanded=n.isSubGraphExpanded,n.hT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t),i.Lc(n,e);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!1}expandSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.aT(i,t,this),t.isCollapsingExpanding=!1}aT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ei(!0),n instanceof Group&&n.wasSubGraphExpanded&&(n.wasSubGraphExpanded=!1,n.aT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!0}get isSubGraphExpanded(){return(this.E&512)!==0}set isSubGraphExpanded(t){const i=(this.E&512)!==0;if(i!==t){Util.i(t,"boolean",Group,"isSubGraphExpanded"),this.E=this.E^512;const e=this.diagram;this.t("isSubGraphExpanded",i,t);const s=this.subGraphExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.Y,e.Y=!0),s(this),e!==null&&(e.Y=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.It!==null&&this.It.c(),this.memberParts.each(n=>n.updateAdornments());return}t?this.expandSubGraph():this.collapseSubGraph()}}get wasSubGraphExpanded(){return(this.E&1024)!==0}set wasSubGraphExpanded(t){const i=(this.E&1024)!==0;i!==t&&(Util.i(t,"boolean",Group,"wasSubGraphExpanded"),this.E=this.E^1024,this.t("wasSubGraphExpanded",i,t))}get subGraphExpandedChanged(){return this.gt!==null?this.gt.my:null}set subGraphExpandedChanged(t){const i=this.subGraphExpandedChanged;i!==t&&(t!==null&&Util.i(t,"function",Group,"subGraphExpandedChanged"),this.cl(),this.gt.my=t,this.t("subGraphExpandedChanged",i,t))}move(t,i){i===void 0&&(i=!1);const e=i?this.location:this.position,s=e.x,n=e.y,o=t.x,r=t.y;if((s===o||isNaN(s)&&isNaN(o))&&(n===r||isNaN(n)&&isNaN(r)))return;const l=o-(isNaN(s)?0:s),h=r-(isNaN(n)?0:n),a=Point.l();super.move(t,i);const c=new GSet,u=this.findSubGraphParts().iterator;for(;u.next();){const d=u.value;d instanceof Link&&(d.suspendsRouting&&c.add(d),!(!d.Me&&(d.fromNode===this||d.toNode===this))&&(d.suspendsRouting=!0))}for(u.reset();u.next();){const d=u.value;if(d.Cl()||d instanceof Node&&d.isLinkLabel)continue;const m=d.position,g=d.location;m.isReal()?(a.x=m.x+l,a.y=m.y+h,d.position=a):g.isReal()&&(a.x=g.x+l,a.y=g.y+h,d.location=a)}for(u.reset();u.next();){const d=u.value;if(!(d instanceof Link)||(d.suspendsRouting=c.has(d),!d.Me&&(d.fromNode===this||d.toNode===this)))continue;const m=d.position;a.x=m.x+l,a.y=m.y+h,a.isReal()?d.move(a):d.invalidateRoute()}Point.s(a)}wO(){return(this.E&65536)!==0}kL(t){(this.E&65536)!==0!==t&&(this.E=this.E^65536)}get Jr(){return(this.E&32768)!==0}set Jr(t){(this.E&32768)!==0!==t&&(this.E=this.E^32768)}}class Placeholder extends GraphObject{$t;Kd;constructor(t){super(),this.$t=Margin.Eg,this.Kd=new Rect(NaN,NaN,NaN,NaN),t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.$t=this.$t.N(),t.Kd=this.Kd.copy()}hh(t){if(this.background===null)return!1;const i=this.naturalBounds;return Rect.contains(0,0,i.width,i.height,t.x,t.y)}Qu(t,i,e,s){const n=this.part;if((n===null||!(n instanceof Group)&&!(n instanceof Adornment))&&Util.o("Placeholder is not inside a Group or Adornment."),n instanceof Group){const o=this.computeBorder(this.Kd),r=this.minSize,l=isFinite(r.width)?Math.max(r.width,o.width):o.width,h=isFinite(r.height)?Math.max(r.height,o.height):o.height,a=this.Vi;a.En(l||0,h||0),this.Qn(0,0,a.width,a.height);const c=n.memberParts;let f=!1;for(;c.next();)if(c.value.isVisible()){f=!0;break}const u=n.diagram;if(f&&u!==null&&!u.animationManager.CS(n)&&!isNaN(o.x)&&!isNaN(o.y)){const d=Point.l();d.setRectSpot(o,n.locationSpot),n.location=d,Point.s(d)}}else{const o=n,r=this.Vi,l=this.$t,h=l.left+l.right,a=l.top+l.bottom,c=o.adornedObject,f=c.getDocumentAngle();o.angle=f;let u=0;c instanceof Shape&&(u=c.strokeWidth);const d=c.getDocumentScale(),m=c.naturalBounds,g=(m.width+u)*d,p=(m.height+u)*d;if(o.type!==Panel.Link){const y=o.category==="Selection"?Spot.TopLeft:o.locationSpot,x=c.getDocumentPoint(y,Point.l());o.location=x,Point.s(x)}if(!isNaN(g)&&!isNaN(p))r.En(g+h||0,p+a||0),this.Qn(-l.left,-l.top,r.width,r.height);else{const y=c.getDocumentPoint(Spot.TopLeft,Point.l()),x=Rect.X(y.x,y.y,0,0);x.unionPoint(c.getDocumentPoint(Spot.BottomRight,y)),x.unionPoint(c.getDocumentPoint(Spot.TopRight,y)),x.unionPoint(c.getDocumentPoint(Spot.BottomLeft,y)),r.En(x.width+h||0,x.height+a||0),this.Qn(-l.left,-l.top,r.width,r.height),Point.s(y),Rect.s(x)}}}ah(t,i,e,s){this.actualBounds.e(t,i,e,s)}computeBorder(t){const i=this.part,e=i.diagram,s=e===null||!e.animationManager.isAnimating;if(e!==null&&i instanceof Group&&!i.layer.isTemporary&&i.computesBoundsAfterDrag&&this.Kd.isReal()){const l=e.toolManager.findTool("Dragging");if(l===e.currentTool){const h=l.computeBorder(i,this.Kd,t);if(h!==null)return h}}const n=Rect.l(),o=this.computeMemberBounds(n),r=this.$t;return i instanceof Group&&!i.isSubGraphExpanded?t.e(o.x-r.left,o.y-r.top,0,0):t.e(o.x-r.left,o.y-r.top,Math.max(o.width+r.left+r.right,0),Math.max(o.height+r.top+r.bottom,0)),Rect.s(n),s&&i instanceof Group&&i.computesBoundsIncludingLocation&&i.location.isReal()&&t.unionPoint(i.location),t}computeMemberBounds(t){if(!(this.part instanceof Group))return t.e(0,0,0,0),t;const i=this.part;let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=i.memberParts;for(;r.next();){const l=r.value;if(!l.isVisible()||l instanceof Link&&(!i.computesBoundsIncludingLinks||l.Oo()||l.fromNode===i||l.toNode===i))continue;const h=l.actualBounds;h.leftn&&(n=h.right),h.bottom>o&&(o=h.bottom)}if(!isFinite(e)||!isFinite(s)){const l=i.location;t.e(l.x,l.y,0,0)}else t.e(e,s,n-e,o-s);return t}get padding(){return this.$t}set padding(t){typeof t=="number"&&(t=new Margin(t));const i=this.$t;i.equals(t)||(t=t.N(),this.$t=t,this.t("padding",i,t),this.c())}}class Layout{p;ha;Yd;kr;Gd;jd;Fo;ul;Hd;qd;go;constructor(t){GSet.Yi(this),this.p=null,this.ha=null,this.Yd=!0,this.kr=!0,this.Gd=!1,this.jd=new Point(0,0).g(),this.Fo=!0,this.ul=null,this.Hd=null,this.qd=!1,this.go=null,t&&Object.assign(this,t)}cloneProtected(t){t.Yd=this.Yd,t.kr=this.kr,t.Gd=this.Gd,t.jd.a(this.jd),t.Fo=this.Fo,t.ul=this.ul,t.Hd=this.Hd,t.qd=!0}copy(){const t=new this.constructor;return this.cloneProtected(t),t}ri(t){Util.lr(this,t)}toString(){let t=Util.sn(this.constructor);return t+="(",this.group!==null&&(t+=" in "+this.group),this.diagram!==null&&(t+=" for "+this.diagram),t+=")",t}get diagram(){return this.p}set diagram(t){this.p=t}get group(){return this.ha}set group(t){this.ha!==t&&(this.ha=t,t!==null&&(this.p=t.diagram))}get isOngoing(){return this.Yd}set isOngoing(t){this.Yd!==t&&(Util.i(t,"boolean",Layout,"isOngoing"),this.Yd=t)}get isInitial(){return this.kr}set isInitial(t){Util.i(t,"boolean",Layout,"isInitial"),this.kr=t,t||(this.qd=!0)}get isViewportSized(){return this.Gd}set isViewportSized(t){this.Gd!==t&&(Util.i(t,"boolean",Layout,"isViewportSized"),this.Gd=t,t&&this.invalidateLayout())}get isRouting(){return this.Fo}set isRouting(t){this.Fo!==t&&(Util.i(t,"boolean",Layout,"isRouting"),this.Fo=t)}get isRealtime(){return this.ul}set isRealtime(t){this.ul!==t&&(t!==null&&Util.i(t,"boolean",Layout,"isRealtime"),this.ul=t)}get isValidLayout(){return this.qd}set isValidLayout(t){if(this.qd!==t&&(Util.i(t,"boolean",Layout,"isValidLayout"),this.qd=t,!t)){const i=this.diagram;i!==null&&(i.Kr=!0)}}invalidateLayout(){if(this.isValidLayout){const t=this.diagram;if(t===null||t.undoManager.isUndoingRedoing)return;const i=t.animationManager;if(i.isTicking)return;i.defaultAnimation.isAnimating&&i.stopAnimation(),(this.isOngoing&&t.Bh||this.isInitial&&!t.Bh)&&(this.isValidLayout=!1,t.requestUpdate())}}get network(){return this.go}set network(t){this.go!==t&&(this.go=t,t!==null&&(t.layout=this))}createNetwork(){return new LayoutNetwork(this)}makeNetwork(t){const i=this.createNetwork();return t instanceof Diagram?(i.addParts(t.nodes,!0),i.addParts(t.links,!0)):t instanceof Group?i.addParts(t.memberParts):i.addParts(t.iterator),i}updateParts(){this.isValidLayout=!0;let t=this.diagram;if(t===null&&this.network!==null){const i=this.network.vertexes.iterator;for(;i.next();){const s=i.value.node;if(s!==null&&(t=s.diagram,t!==null))break}}try{t!==null&&t.startTransaction("Layout"),this.commitLayout()}finally{t!==null&&t.commitTransaction("Layout")}}commitLayout(){if(this.network===null)return;const t=this.network.vertexes.iterator;for(;t.next();)t.value.commit();if(this.isRouting){const i=this.network.edges.iterator;for(;i.next();)i.value.commit()}}doLayout(t){const i=new GSet;if(t instanceof Diagram?(this.kh(i,t.nodes,!0,this.Jr,!0,!1,!0),this.kh(i,t.parts,!0,this.Jr,!0,!1,!0)):t instanceof Group?this.kh(i,t.memberParts,!1,this.Jr,!0,!1,!0):i.addAll(t.iterator),i.count>0){const s=this.diagram;s!==null&&s.startTransaction("Layout"),this.doMinimalNoNetworkLayout(i),s!==null&&s.commitTransaction("Layout")}this.isValidLayout=!0}doMinimalNoNetworkLayout(t){const i=t.count,e=Math.ceil(Math.sqrt(i));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const s=this.arrangementOrigin.x,n=this.arrangementOrigin.y;let o=s,r=n,l=0,h=0;const a=t.iterator;for(;a.next();){const c=a.value;c.ensureBounds();const f=c.measuredBounds,u=f.width,d=f.height;c.moveTo(o,r),c instanceof Group&&(c.Jr=!1),o+=Math.max(u,50)+20,h=Math.max(h,Math.max(d,50)),l>=e-1?(l=0,o=s,r+=h+20,h=0):l++}}doMinimalNetworkLayout(){const t=this.network.vertexes.count,i=Math.ceil(Math.sqrt(t));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const e=this.arrangementOrigin.x,s=this.arrangementOrigin.y;let n=e,o=s,r=0,l=0;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value.node;if(a===null||a instanceof Link||(a.ensureBounds(),!this.Jr(a)))continue;const c=a.measuredBounds,f=c.width,u=c.height;a.moveTo(n,o),a instanceof Group&&(a.Jr=!1),n+=Math.max(f,50)+20,l=Math.max(l,Math.max(u,50)),r>=i-1?(r=0,n=e,o+=l+20,l=0):r++}}Jr(t){return!!(!t.location.isReal()&&!t.position.isReal()||t instanceof Group&&t.Jr)}kh(t,i,e,s,n,o,r){const l=i.iterator;for(;l.next();){const h=l.value;if(!(e&&!h.isTopLevel)&&!(s!==null&&!s(h))&&h.canLayout())if(n&&h instanceof Node){if(h.isLinkLabel)continue;h instanceof Group&&h.layout===null?this.kh(t,h.memberParts,!1,s,n,o,r):(h.ensureBounds(),t.add(h))}else o&&h instanceof Link?t.add(h):r&&h.Pe()&&!(h instanceof Node)&&(h.ensureBounds(),t.add(h))}}getLayoutBounds(t,i){const e=this.boundsComputation;return e!==null?(i||(i=new Rect),e(t,this,i)):!i&&t.margin.equalTo(0,0,0,0)?t.actualBounds:(i||(i=new Rect),i.set(t.actualBounds),i.addMargin(t.margin),i)}get boundsComputation(){return this.Hd}set boundsComputation(t){this.Hd!==t&&(t!==null&&Util.i(t,"function",Layout,"boundsComputation"),this.Hd=t,this.invalidateLayout())}collectParts(t){const i=new GSet;return t instanceof Diagram?(this.kh(i,t.nodes,!0,null,!0,!0,!0),this.kh(i,t.links,!0,null,!0,!0,!0),this.kh(i,t.parts,!0,null,!0,!0,!0)):t instanceof Group?this.kh(i,t.memberParts,!1,null,!0,!0,!0):this.kh(i,t.iterator,!1,null,!0,!0,!0),i}get arrangementOrigin(){return this.jd}set arrangementOrigin(t){this.jd.equals(t)||(this.jd.a(t),this.invalidateLayout())}initialOrigin(t){const i=this.group;if(i!==null)if(i.hasPlaceholder()){const e=i.placeholder,s=e.getDocumentPoint(Spot.TopLeft);(isNaN(s.x)||isNaN(s.y))&&s.set(t);const n=e.padding;return s.x+=n.left,s.y+=n.top,s}else{const e=i.position.copy();return(isNaN(e.x)||isNaN(e.y))&&e.set(t),e}return t}}class LayoutNetwork{ie;mo;Cn;ky;Py;constructor(t){GSet.Yi(this),this.ie=t,this.mo=new GSet,this.Cn=new GSet,this.ky=new GMap,this.Py=new GMap}clear(){if(this.mo){const t=this.mo.iterator;for(;t.next();)t.value.clear()}if(this.Cn){const t=this.Cn.iterator;for(;t.next();)t.value.clear()}this.mo=new GSet,this.Cn=new GSet,this.ky=new GMap,this.Py=new GMap}toString(t){t===void 0&&(t=0);let i="LayoutNetwork"+(this.layout!==null?"("+this.layout.toString()+")":"");if(t<=0)return i;if(i+=" vertexes: "+this.mo.count+" edges: "+this.Cn.count,t>1){const e=this.mo.iterator;for(;e.next();){const n=e.value;i+=` `+n.toString(t-1)}const s=this.Cn.iterator;for(;s.next();){const n=s.value;i+=` - `+n.toString(t-1)}}return i}get layout(){return this.te}set layout(t){t!==null&&(this.te=t)}get vertexes(){return this.mo}get edges(){return this.Cn}createVertex(){return new LayoutVertex(this)}createEdge(){return new LayoutEdge(this)}addParts(t,i,e){if(t===null)return;i===void 0&&(i=!1),Util.i(i,"boolean",LayoutNetwork,"addParts:toplevelonly"),e===void 0&&(e=null),e===null&&(e=n=>{if(n instanceof Node)return!n.isLinkLabel;if(n instanceof Link){const o=n.fromNode;if(o===null||o.isLinkLabel)return!1;const r=n.toNode;return!(r===null||r.isLinkLabel)}return!1});const s=t.iterator;for(;s.next();){const n=s.value;if(n instanceof Node&&!(i&&!n.isTopLevel)&&n.canLayout()&&e(n))if(n instanceof Group&&n.layout===null)this.addParts(n.memberParts,!1);else{if(this.findVertex(n)!==null)continue;const o=this.createVertex();o.node=n,this.addVertex(o)}}for(s.reset();s.next();){const n=s.value;if(!(n instanceof Link)||i&&!n.isTopLevel||!n.canLayout()||!e(n)||this.findEdge(n)!==null)continue;const o=n.fromNode,r=n.toNode;if(o===null||r===null||o===r)continue;const l=this.findGroupVertex(o),h=this.findGroupVertex(r);this.linkVertexes(l,h,n)}}findGroupVertex(t){if(t===null)return null;const i=t.findVisibleNode();if(i===null)return null;let e=this.findVertex(i);if(e!==null)return e;let s=i.containingGroup;for(;s!==null;){if(e=this.findVertex(s),e!==null)return e;s=s.containingGroup}return null}addVertex(t){if(t===null)return;this.mo.add(t);const i=t.node;i!==null&&this.ky.set(i,t),t.network=this}addNode(t){if(t===null)return null;let i=this.findVertex(t);return i===null&&(i=this.createVertex(),i.node=t,this.addVertex(i)),i}deleteVertex(t){if(t!==null&&this.cT(t)){let i=t._o;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}i=t.tr;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}}}cT(t){if(t===null)return!1;const i=this.mo.delete(t);if(i){const e=t.node;e!==null&&this.ky.delete(e)}return i}deleteNode(t){if(t===null)return;const i=this.findVertex(t);i!==null&&this.deleteVertex(i)}findVertex(t){return t===null?null:this.ky.get(t)}addEdge(t){if(t===null)return;this.uN(t);const i=t.toVertex;i!==null&&i.addSourceEdge(t);const e=t.fromVertex;e!==null&&e.addDestinationEdge(t)}uN(t){if(t===null)return;this.Cn.add(t);const i=t.link;i!==null&&this.findEdge(i)===null&&this.Py.set(i,t),t.network=this}addLink(t){if(t===null)return null;const i=t.fromNode,e=t.toNode;let s=this.findEdge(t);return s===null?(s=this.createEdge(),s.link=t,i!==null&&(s.fromVertex=this.addNode(i)),e!==null&&(s.toVertex=this.addNode(e)),this.addEdge(s)):(i!==null?s.fromVertex=this.addNode(i):s.fromVertex=null,e!==null?s.toVertex=this.addNode(e):s.toVertex=null),s}deleteEdge(t){if(t===null)return;const i=t.toVertex;i!==null&&i.deleteSourceEdge(t);const e=t.fromVertex;e!==null&&e.deleteDestinationEdge(t),this.dN(t)}dN(t){if(t===null)return!1;const i=this.Cn.delete(t);if(i){const e=t.link;e!==null&&this.Py.delete(e)}return i}deleteLink(t){if(t===null)return;const i=this.findEdge(t);i!==null&&this.deleteEdge(i)}findEdge(t){return t===null?null:this.Py.get(t)}linkVertexes(t,i,e){if(t===null||i===null)return null;if(t.network===this&&i.network===this){const s=this.createEdge();return s.link=e,s.fromVertex=t,s.toVertex=i,this.addEdge(s),s}return null}reverseEdge(t){if(t===null)return;const i=t.fromVertex,e=t.toVertex;i===null||e===null||(i.deleteDestinationEdge(t),e.deleteSourceEdge(t),t.reverseEdge(),i.addSourceEdge(t),e.addDestinationEdge(t))}deleteSelfEdges(){const t=Util.ot(),i=this.Cn.iterator;for(;i.next();){const s=i.value;s.fromVertex===s.toVertex&&t.push(s)}const e=t.length;for(let s=0;s0||t.tr.count>0)}splitIntoSubNetworks(t){t===void 0&&(t=!0),t&&(this.deleteArtificialVertexes(),this.deleteUselessEdges(),this.deleteSelfEdges());const i=new List;let e=!0;for(;e;){e=!1;const s=this.mo.iterator;for(;s.next();){const n=s.value;if(this.isSingleton(n))continue;const o=this.layout.createNetwork();i.add(o),this.bO(o,n),e=!0;break}}return i.sort((s,n)=>s===null||n===null||s===n?0:n.vertexes.count-s.vertexes.count),i}bO(t,i){if(i===null)return;const e=new List;for(e.add(i);e.count>0;){const s=e.first();if(e.removeAt(0),s.network===t)continue;this.cT(s),t.addVertex(s);let n=s.sourceEdges;for(;n.next();){const o=n.value;o.network!==t&&(this.dN(o),t.uN(o),e.add(o.fromVertex))}for(n=s.destinationEdges;n.next();){const o=n.value;o.network!==t&&(this.dN(o),t.uN(o),e.add(o.toVertex))}}}findAllParts(){const t=new GSet,i=this.mo.iterator;for(;i.next();){const s=i.value;t.add(s.node)}const e=this.Cn.iterator;for(;e.next();){const s=e.value;t.add(s.link)}return t}}class LayoutVertex{go;Qt;ue;Ae;qe;_o;tr;constructor(t){GSet.Yi(this),this.go=t,this.Ae=new Rect(0,0,10,10).g(),this.qe=new Point(5,5).g(),this.Qt=null,this.ue=null,this._o=new List,this.tr=new List}clear(){this.Qt=null,this.ue=null,this._o=new List,this.tr=new List}toString(t){t===void 0&&(t=0);let i="LayoutVertex#"+GSet.as(this);if(t>0&&(i+=this.node!==null?"("+this.node.toString()+")":"",t>1)){let e="",s=!0,n=this._o.iterator;for(;n.next();){const r=n.value;s?s=!1:e+=",",e+=r.toString(0)}let o="";for(s=!0,n=this.tr.iterator;n.next();){const r=n.value;s?s=!1:o+=",",o+=r.toString(0)}i+=" sources: "+e+" destinations: "+o}return i}get po(){return this._o.$N}get ir(){return this.tr.$N}get data(){return this.Qt}set data(t){if(this.Qt=t,t!==null&&t.bounds){const i=t.bounds,e=i.x,s=i.y,n=i.width,o=i.height;this.qe.e(n/2,o/2),this.Ae.e(e,s,n,o)}}get node(){return this.ue}set node(t){if(this.ue!==t){this.ue=t,t.ensureBounds();const i=this.network.layout,e=Rect.l(),s=i.getLayoutBounds(t,e);let n=s.x,o=s.y;const r=s.width,l=s.height;if(isNaN(n)&&(n=0),isNaN(o)&&(o=0),this.Ae.e(n,o,r,l),Rect.s(e),!(t instanceof Group)){const h=t.locationObject.getDocumentPoint(Spot.Center);if(h.isReal()){this.qe.e(h.x-n,h.y-o);return}}this.qe.e(r/2,l/2)}}get bounds(){return this.Ae}set bounds(t){this.Ae.equals(t)||this.Ae.a(t)}get focus(){return this.qe}set focus(t){this.qe.equals(t)||this.qe.a(t)}get centerX(){return this.Ae.x+this.qe.x}set centerX(t){const i=this.Ae;i.x+this.qe.x!==t&&(i.rt(),i.x=t-this.qe.x,i.g())}get centerY(){return this.Ae.y+this.qe.y}set centerY(t){const i=this.Ae;i.y+this.qe.y!==t&&(i.rt(),i.y=t-this.qe.y,i.g())}get focusX(){return this.qe.x}set focusX(t){const i=this.qe;i.x!==t&&(i.rt(),i.x=t,i.g())}get focusY(){return this.qe.y}set focusY(t){const i=this.qe;i.y!==t&&(i.rt(),i.y=t,i.g())}get x(){return this.Ae.x}set x(t){const i=this.Ae;i.x!==t&&(i.rt(),i.x=t,i.g())}get y(){return this.Ae.y}set y(t){const i=this.Ae;i.y!==t&&(i.rt(),i.y=t,i.g())}get width(){return this.Ae.width}set width(t){const i=this.Ae;i.width!==t&&(i.rt(),i.width=t,i.g())}get height(){return this.Ae.height}set height(t){const i=this.Ae;i.height!==t&&(i.rt(),i.height=t,i.g())}commit(){const t=this.Qt;if(t!==null){const e=this.bounds,s=t.bounds;Util.wt(s)?(s.x=e.x,s.y=e.y,s.width=e.width,s.height=e.height):t.bounds=e.copy();return}const i=this.node;if(i!==null){const e=this.bounds;if(!(i instanceof Group)){const s=Rect.l();i.ensureBounds();const n=this.network.layout.getLayoutBounds(i,s),o=i.locationObject.getDocumentPoint(Spot.Center);if(n.isReal()&&o.isReal()){i.moveTo(e.x+this.focusX-(o.x-n.x)+i.margin.left,e.y+this.focusY-(o.y-n.y+i.margin.top)),Rect.s(s);return}Rect.s(s)}i.moveTo(e.x+i.margin.left,e.y+i.margin.top)}}addSourceEdge(t){t!==null&&(this._o.has(t)||this._o.add(t))}deleteSourceEdge(t){t!==null&&this._o.delete(t)}addDestinationEdge(t){t!==null&&(this.tr.has(t)||this.tr.add(t))}deleteDestinationEdge(t){t!==null&&this.tr.delete(t)}get network(){return this.go}set network(t){this.go=t}get sourceVertexes(){const t=new GSet,i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}return t.iterator}get destinationVertexes(){const t=new GSet,i=this.destinationEdges;for(;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get vertexes(){const t=new GSet;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get sourceEdges(){return this._o.iterator}get destinationEdges(){return this.tr.iterator}get edges(){const t=new List;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e)}return t.iterator}get edgesCount(){return this._o.count+this.tr.count}static standardComparer(t,i){const e=t.ue,s=i.ue;if(e)if(s){const n=e.text,o=s.text;return no?1:0}else return 1;else return s!==null?-1:0}static smartComparer(t,i){if(t!==null)if(i!==null){const e=t.ue,s=i.ue;if(e!==null)if(s!==null){const n=e.text.toLocaleLowerCase(),o=s.text.toLocaleLowerCase(),r=n.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),l=o.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let h=0;for(;h0&&(i+=this.He!==null?"("+this.He.toString()+")":"",t>1&&(i+=" "+(this.We?this.We.toString():"null")+" --> "+(this.Je?this.Je.toString():"null"))),i}reverseEdge(){const t=this.We;this.We=this.Je,this.Je=t}commit(){}getOtherVertex(t){return this.Je===t?this.We:this.We===t?this.Je:null}get network(){return this.go}set network(t){this.go=t}get data(){return this.Qt}set data(t){this.Qt!==t&&(this.Qt=t)}get link(){return this.He}set link(t){this.He!==t&&(this.He=t)}get fromVertex(){return this.We}set fromVertex(t){this.We!==t&&(this.We=t)}get toVertex(){return this.Je}set toVertex(t){this.Je!==t&&(this.Je=t)}}var GridAlignment=(w=>(w[w.Position=0]="Position",w[w.Location=1]="Location",w))(GridAlignment||{}),GridArrangement=(w=>(w[w.LeftToRight=10]="LeftToRight",w[w.RightToLeft=11]="RightToLeft",w))(GridArrangement||{}),GridSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w))(GridSorting||{});class GridLayout extends Layout{Jd;$d;Lo;Ln;ni;zi;pe;ye;constructor(t){super(),this.isViewportSized=!0,this.Jd=NaN,this.$d=NaN,this.Lo=new Size(NaN,NaN).g(),this.Ln=new Size(10,10).g(),this.ni=1,this.zi=10,this.pe=22,this.ye=GridLayout.standardComparer,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Jd=this.Jd,t.$d=this.$d,t.Lo.a(this.Lo),t.Ln.a(this.Ln),t.ni=this.ni,t.zi=this.zi,t.pe=this.pe,t.ye=this.ye}ri(t){t in GridSorting?this.sorting=t:t in GridArrangement?this.arrangement=t:t in GridAlignment?this.alignment=t:super.ri(t)}doLayout(t){this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.collectParts(t),e=this.diagram,n=i.copy().iterator;for(;n.next();){const m=n.value;if(m.Cl()&&(m.fromNode!==null||m.toNode!==null)){i.delete(m);continue}if(m.ensureBounds(),m instanceof Group){const g=m.memberParts;for(;g.next();){const p=g.value;i.delete(p)}}}const o=i.toArray();if(o.length===0)return;switch(this.sorting){case 20:break;case 21:o.reverse();break;case 22:o.sort(this.comparer);break;case 23:o.sort(this.comparer),o.reverse();break}let r=this.wrappingColumn;isNaN(r)&&(r=0);let l=this.wrappingWidth;if(isNaN(l)&&e!==null){const m=e.viewportBounds,g=e.padding;l=Math.max(m.width-g.left-g.right,0)}else l=Math.max(this.wrappingWidth,0);r<=0&&l<=0&&(r=1);let h=this.spacing.width;isFinite(h)||(h=0);let a=this.spacing.height;isFinite(a)||(a=0),e!==null&&e.startTransaction("Layout");const c=[];switch(this.alignment){case 0:this.kO(o,l,r,h,a,c);break;case 1:this.PO(o,l,r,h,a,c);break}let f=0,u=0,d=0;for(let m=0;m0&&m>e-1||i>0&&m>0&&L-c>i)&&(o.push(new Rect(0,d,i+s,g)),m=0,u=c,d+=g,g=0),g=Math.max(g,M);let C=0;switch(a){case 11:C=-x.width;break;default:C=0;break}switch(y.moveTo(u+C+y.margin.left,d+y.margin.top),a){case 11:u-=P;break;default:u+=P;break}m++}o.push(new Rect(0,d,i+s,g)),Rect.s(r)}PO(t,i,e,s,n,o){const r=Rect.l();let l=Math.max(this.cellSize.width,1),h=0,a=0,c=0;const f=Point.l();for(let C=0;C=h&&(i-=h);let x=0,k=0;const b=Math.max(this.cellSize.height,1);c=0;let P=0,M=!0;const L=Point.l();for(let C=0;C0)switch(u){case 11:{let D=(g-d-(N.width-T.x))/l;Geo.K(Math.round(D),D)?D=Math.round(D):D=Math.floor(D),g=D*l+d;break}default:{let D=(g-d+T.x)/l;Geo.K(Math.round(D),D)?D=Math.round(D):D=Math.ceil(D),g=D*l+d;break}}else switch(u){case 11:x=g+T.x+N.width;break;default:x=g-T.x;break}let A=0;switch(u){case 11:A=-(g+T.x)+x;break;default:A=g+N.width-T.x-x;break}if(e>0&&y>e-1||i>0&&y>0&&A>i){o.push(new Rect(0,M?p-c:p,i+s,P+c+n));for(let D=0;Dk&&(S.width+=S.x-k,S.x=k)}Rect.s(r)}commitLayers(t,i){}get wrappingWidth(){return this.Jd}set wrappingWidth(t){this.Jd!==t&&(Util.i(t,"number",GridLayout,"wrappingWidth"),(t>0||isNaN(t))&&(this.Jd=t,this.isViewportSized=isNaN(t),this.invalidateLayout()))}get wrappingColumn(){return this.$d}set wrappingColumn(t){this.$d!==t&&(Util.i(t,"number",GridLayout,"wrappingColumn"),(t>0||isNaN(t))&&(this.$d=t,this.invalidateLayout()))}get cellSize(){return this.Lo}set cellSize(t){this.Lo.equals(t)||(this.Lo.a(t),this.invalidateLayout())}get spacing(){return this.Ln}set spacing(t){this.Ln.equals(t)||(this.Ln.a(t),this.invalidateLayout())}get alignment(){return this.ni}set alignment(t){this.ni!==t&&(t===1||t===0)&&(this.ni=t,this.invalidateLayout())}get arrangement(){return this.zi}set arrangement(t){this.zi!==t&&(t===10||t===11)&&(this.zi=t,this.invalidateLayout())}get sorting(){return this.pe}set sorting(t){this.pe!==t&&(t===20||t===21||t===22||t===23)&&(this.pe=t,this.invalidateLayout())}get comparer(){return this.ye}set comparer(t){this.ye!==t&&(Util.i(t,"function",GridLayout,"comparer"),this.ye=t,this.invalidateLayout())}static standardComparer(t,i){const e=t.text,s=i.text;return es?1:0}static smartComparer(t,i){if(t!==null)if(i!==null){const e=t.text.toLocaleLowerCase(),s=i.text.toLocaleLowerCase(),n=e.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),o=s.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let r=0;for(;r{e.containsNodeData(s)&&this.gT(s,!1)}),t.forEach(s=>{e.containsNodeData(s)&&this.S1(s)}),i!==!1&&this.diagram.bb(!1)}gT(t,i){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.yo.has(t))return null;i===void 0&&(i=!0);const e=this.MO(t);return e!==null&&i&&this.S1(t),e}MO(t){if(t==null||this.p.undoManager.isUndoingRedoing||this.yo.has(t))return null;const i=this.SO(t),e=this.findTemplateForNodeData(t,i);if(e!==null){e.li();const s=e.copy();if(s!==null){const n=this.diagram.ce;return this.diagram.ce=!0,s.Ho=i,s.Qt=t,this.My&&(s.ll="Tool"),this.diagram.add(s),s.Qt=null,s.data=t,this.diagram.ce=n,s}}return null}insertLink(t,i,e,s){return null}S1(t){}SO(t){return this.p.model.getCategoryForNodeData(t)}static mT=!1;static pT=!1;findTemplateForNodeData(t,i){const e=this.p,s=e.model,n=s.Hc()&&s.isGroupForData(t);let o=null;return n?(o=e.groupTemplateMap.get(i),o===null&&(o=e.groupTemplateMap.get(""),o===null&&(PartManager.pT||(PartManager.pT=!0,Util.oi('No Group template found for category "'+i+'"'),Util.oi(" Using default group template")),o=e.rS))):(o=e.nodeTemplateMap.get(i),o===null&&(o=e.nodeTemplateMap.get(""),o===null&&(PartManager.mT||(PartManager.mT=!0,Util.oi('No Node template found for category "'+i+'"'),Util.oi(" Using default node template")),o=e.sS))),o}getLinkCategoryForData(t){return""}setLinkCategoryForData(t,i){}setFromNodeForLink(t,i,e){}setToNodeForLink(t,i,e){}static yT=!1;findLinkTemplateForCategory(t){const i=this.p;let e=i.linkTemplateMap.get(t);return e===null&&(e=i.linkTemplateMap.get(""),e===null&&(PartManager.yT||(PartManager.yT=!0,Util.oi('No Link template found for category "'+t+'"'),Util.oi(" Using default link template")),e=i.nS)),e}uv(t,i,e){t instanceof Link?(i!==null&&this.uT(i,t),e!==null&&this.fT(e,t)):t instanceof Part&&(i!==null&&this.yo.delete(i),e!==null&&this.yo.set(e,t))}dT(){const t=this.diagram.model;this.mN(t.nodeDataArray)}mN(t){t.forEach(i=>{this.N1(i)})}N1(t){const i=this.findPartForData(t);i!==null&&(this.diagram.NS(i,!1),this.pN(i))}pN(t){}rN(t){}findPartForKey(t){if(t==null)return null;const i=this.p.model.findNodeDataForKey(t);return i!==null?this.yo.get(i):null}findNodeForKey(t){if(t==null)return null;const i=this.p.model.findNodeDataForKey(t);if(i===null)return null;const e=this.yo.get(i);return e instanceof Node?e:null}findLinkForKey(t){return null}findPartForData(t){if(t===null)return null;let i=this.yo.get(t);return i!==null||(i=this.dl.get(t)),i}findNodeForData(t){if(t===null)return null;const i=this.yo.get(t);return i instanceof Node?i:null}findLinkForData(t,i){return t===null?null:this.dl.get(t)}findNodesByExample(...t){const i=new GSet,e=this.Zd.iterator;for(;e.next();){const s=e.value,n=s.data;if(n!==null)for(let o=0;o{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),this.parts.each(o=>{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),s.forEach(o=>t.xT(o,!1));for(let o=0;o0){for(let o=0;oi.SL(s));const e=t.gh;if(Array.isArray(e)){const s=this.Ua.get(e);if(s===null){const n=[];n.push(t),this.Ua.set(e,n)}else{for(let n=0;ni.pR(s));const e=t.gh;if(Array.isArray(e)){const s=this.Ua.get(e);if(s!==null){for(let n=0;n0&&i.removeParts(l,!1),h.count>0){const c=h.iterator;for(;c.next();){const f=c.key,u=c.value;s.set(f,u)}}}if(i!==null&&this.p!==null){const o=i.model,r=o.afterCopyFunction;if(r!==null){const l=new GMap;s.each(a=>{a.key.data!==null&&l.set(a.key.data,a.value.data)});const h=this.p.model;r(l,o,h)}}const n=s.iterator;for(;n.next();)n.value.updateTargetBindings();return s}C1(t,i,e,s){if(t===null||s&&!t.canCopy())return null;if(e.has(t))return e.get(t);const n=this.wN(t,i);if(!(n instanceof Part))return null;if(n.isSelected=!1,n.isHighlighted=!1,e.set(t,n),t instanceof Node){const o=t.linksConnected;for(;o.next();){const r=o.value;if(r.fromNode===t){const l=e.get(r);l!==null&&(l.fromNode=n)}if(r.toNode===t){const l=e.get(r);l!==null&&(l.toNode=n)}}if(t instanceof Group&&n instanceof Group){const r=t.memberParts;for(;r.next();){const l=r.value,h=this.C1(l,i,e,s);h instanceof Link||h!==null&&(h.containingGroup=n)}}}else if(t instanceof Link&&n instanceof Link){const o=t.fromNode;if(o!==null){const h=e.get(o);h!==null&&(n.fromNode=h)}const r=t.toNode;if(r!==null){const h=e.get(r);h!==null&&(n.toNode=h)}const l=t.labelNodes;for(;l.next();){const h=l.value,a=this.C1(h,i,e,s);a!==null&&a instanceof Node&&(a.labeledLink=n)}}return n}wN(t,i){let e=null;const s=t.data;if(s!==null&&i!==null){const n=i.model;if(!(t instanceof Link)){const o=n.copyNodeData(s);Util.wt(o)&&(n.addNodeData(o),e=i.findPartForData(o))}}else if(t.li(),e=t.copy(),e!==null){const n=this.p;if(i!==null)i.add(e);else if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const o=n.model;let r=null;e instanceof Link||(r=o.copyNodeData(s)),Util.wt(r)&&(e.data=r)}}return e}get nodes(){return this.Zd}get links(){return this.qs}get parts(){return this.At}get diagram(){return this.p}get addsToTemporaryLayer(){return this.My}set addsToTemporaryLayer(t){this.My=t}get preservesRebuildLocations(){return this.gN}set preservesRebuildLocations(t){this.gN=t}}class GraphLinksPartManager extends PartManager{LS(){const t=this.diagram.model;this.Sy(t.nodeDataArray),this.PT(t.linkDataArray)}Sy(t){super.Sy(t,!1);const i=this.links.iterator;for(;i.next();)i.value.Ad();this.diagram.bb(!1)}PT(t){t.forEach(i=>{this.MT(i)}),this.diagram.bb(!1)}MT(t){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.dl.has(t))return null;const i=this.getLinkCategoryForData(t),e=this.findLinkTemplateForCategory(i);if(e!==null){e.li();const s=e.copy();if(s!==null){const n=this.diagram.ce;this.diagram.ce=!0,s.Ho=i,s.Qt=t;const o=this.diagram.model,r=o.L1(t,!0);r!==""&&(s.fromPortId=r);const l=o.Te(t,!0);if(l!==void 0){const f=this.findNodeForKey(l);f instanceof Node&&(s.fromNode=f)}const h=o.L1(t,!1);h!==""&&(s.toPortId=h);const a=o.Te(t,!1);if(a!==void 0){const f=this.findNodeForKey(a);f instanceof Node&&(s.toNode=f)}const c=o.getLabelKeysForLinkData(t);return Array.isArray(c)&&c.forEach(f=>{const u=this.findNodeForKey(f);u!==null&&(u.labeledLink=s)}),this.My&&(s.ll="Tool"),this.diagram.add(s),s.Qt=null,s.data=t,this.diagram.ce=n,s}}return null}dT(){const t=this.diagram.model;this.ST(t.linkDataArray),this.mN(t.nodeDataArray)}ST(t){t.forEach(i=>{this.N1(i)})}getLinkCategoryForData(t){return this.diagram.model.getCategoryForLinkData(t)}setLinkCategoryForData(t,i){return this.diagram.model.setCategoryForLinkData(t,i)}setFromNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setFromKeyForLinkData(t.data,e.getKeyForNodeData(s))}setToNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setToKeyForLinkData(t.data,e.getKeyForNodeData(s))}rN(t){this.diagram.model.removeLinkData(t.data)}findPartForKey(t){const i=super.findPartForKey(t);if(i===null){const s=this.diagram.model.findLinkDataForKey(t);if(s!==null)return this.dl.get(s)}return i}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findLinkDataForKey(t);return e!==null?this.dl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.Y){i.Y=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="linkFromKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.fromNode=l}}else if(s==="linkToKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.toNode=l}}else if(s==="linkFromPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.fromPortId=r)}}else if(s==="linkToPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.toPortId=r)}}else if(s==="nodeGroupKey"){const n=t.object,o=this.findPartForData(n);if(o!==null){const r=t.newValue;if(r!==void 0){const l=this.findNodeForKey(r);l instanceof Group?o.containingGroup=l:o.containingGroup=null}else o.containingGroup=null}}else if(s==="linkLabelKeys"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.oldValue,l=t.newValue;Array.isArray(r)&&r.forEach(h=>{if(l.indexOf(h)>=0)return;const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=null)}),Array.isArray(l)&&l.forEach(h=>{const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=o)})}}else if(s==="linkCategory"){const n=t.object,o=this.findLinkForData(n),r=t.newValue;o!==null&&typeof r=="string"&&(o.category=r)}else if(s==="linkDataArray"){const n=t.oldValue;this.ST(n);const o=t.newValue;this.PT(o)}i.isModified=!0}else if(e===3){const n=t.newValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.MT(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=t.object,r=this.findLinkForData(o),l=this.findNodeForKey(n);r!==null&&l!==null&&(l.labeledLink=r)}i.isModified=!0}else if(e===4){const n=t.oldValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.N1(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=this.findNodeForKey(n);o!==null&&(o.labeledLink=null)}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&(n==="linkFromKeyProperty"||n==="linkToKeyProperty"||n==="linkFromPortIdProperty"||n==="linkToPortIdProperty"||n==="linkLabelKeysProperty"||n==="nodeIsGroupProperty"||n==="nodeGroupKeyProperty"||n==="linkCategoryProperty")&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.Y=!0}}}kT(){const t=this.diagram.model,i=new GSet,e=t.linkDataArray;e.forEach(n=>{i.add(n)});const s=[];this.links.each(n=>{n.data!==null&&!i.has(n.data)&&s.push(n.data)}),s.forEach(n=>{t.NT(n,!1)}),e.forEach(n=>{this.findLinkForData(n)===null&&t.CT(n,!1)})}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Link){let n=s.Te(i,!0),o=e.findNodeForKey(n);t.fromNode=o,n=s.Te(i,!1),o=e.findNodeForKey(n),t.toNode=o;const r=s.getLabelKeysForLinkData(i);if(r.length>0||t.labelNodes.count>0){if(r.length===1&&t.labelNodes.count===1){const f=r[0],u=t.labelNodes.first();if(s.getKeyForNodeData(u.data)===f)return}const l=new GSet().addAll(r),h=new GSet;t.labelNodes.each(f=>{if(f.data!==null){const u=s.getKeyForNodeData(f.data);u!==void 0&&h.add(u)}});const a=h.copy();a.removeAll(l);const c=l.copy();if(c.removeAll(h),a.count>0||c.count>0){const f=t;a.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink===f&&(d.labeledLink=null)}),c.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink!==f&&(d.labeledLink=f)})}}}else if(!(t instanceof Adornment)){const n=s.getGroupKeyForNodeData(i),o=e.findPartForKey(n);(o===null||o instanceof Group)&&(t.containingGroup=o)}}S1(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Cy(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)){if(n instanceof Group&&i.getGroupKeyForNodeData(l)===e){const h=this.findPartForData(l);h!==null&&(h.containingGroup=n)}}else{const h=this.findLinkForData(l);if(h!==null&&n instanceof Node){i.Te(l,!0)===e&&(h.fromNode=n),i.Te(l,!1)===e&&(h.toNode=n);const a=i.getLabelKeysForLinkData(l);Array.isArray(a)&&a.some(c=>c===e?(n.labeledLink=h,!0):!1)}}}i.Js(e)}const o=i.getGroupKeyForNodeData(t);if(o!==void 0){const r=this.findNodeForKey(o);r instanceof Group&&(n.containingGroup=r)}}}pN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data);if(e!==void 0){const s=t.linksConnected;for(;s.next();){const n=s.value;i.$s(e,n.data)}if(t.isLinkLabel){const n=t.labeledLink;n!==null&&i.$s(e,n.data)}if(t instanceof Group){const n=t.memberParts;for(;n.next();){const r=n.value.data;i.containsNodeData(r)&&i.$s(e,r)}}}}}wN(t,i){let e=super.wN(t,i);if(t instanceof Link){const s=t.data;if(s!==null&&i!==null){const n=i.model,o=n.copyLinkData(s);typeof o=="object"&&o!==null&&(n.addLinkData(o),e=i.findLinkForData(o))}else if(e!==null){const n=this.diagram;if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const r=n.model.copyLinkData(s);typeof r=="object"&&r!==null&&(e.data=r)}}}return e}insertLink(t,i,e,s){const n=this.diagram,o=n.model,r=n.toolManager.findTool("Linking");let l="";t!==null&&(i===null&&(i=t),l=i.portId,l===null&&(l=""));let h="";e!==null&&(s===null&&(s=e),h=s.portId,h===null&&(h=""));const a=r.archetypeLinkData;if(a instanceof Link){a.li();const c=a.copy();if(c!==null){c.fromNode=t,c.fromPortId=l,c.toNode=e,c.toPortId=h,n.add(c);const f=r.archetypeLabelNodeData;if(f instanceof Node){f.li();const u=f.copy();u!==null&&(u.labeledLink=c,n.add(u))}return c}}else if(a!==null){const c=o.copyLinkData(a);if(typeof c=="object"&&c!==null){t!==null&&o.Qd(c,o.getKeyForNodeData(t.data),!0),o._d(c,l,!0),e!==null&&o.Qd(c,o.getKeyForNodeData(e.data),!1),o._d(c,h,!1),o.addLinkData(c);const f=r.archetypeLabelNodeData;if(f!==null&&!(f instanceof Node)){const d=o.copyNodeData(f);if(typeof d=="object"&&d!==null){o.addNodeData(d);const m=o.getKeyForNodeData(d);m!==void 0&&o.addLabelKeyForLinkData(c,m)}}return n.findLinkForData(c)}}return null}}class TreePartManager extends PartManager{kh=null;A1(t,i){if(t===null||i===null||i.findTreeParentLink()!==null)return null;const e=this.diagram.toolManager.findTool("Linking");let s=t,n=i;if(this.diagram.isTreePathToChildren){if(e!==null&&e.bu(s,n,null,!0))return null}else if(s=i,n=t,e!==null&&e.bu(s,n,null,!0))return null;const o=this.getLinkCategoryForData(i.data),r=this.findLinkTemplateForCategory(o);if(r!==null){r.li();const l=r.copy();if(l!==null){const h=this.diagram.ce;return this.diagram.ce=!0,l.Ho=o,l.Qt=i.data,l.fromNode=s,l.toNode=n,this.diagram.add(l),l.Qt=null,l.data=i.data,this.diagram.ce=h,l}}return null}getLinkCategoryForData(t){return this.diagram.model.getParentLinkCategoryForNodeData(t)}setLinkCategoryForData(t,i){this.diagram.model.setParentLinkCategoryForNodeData(t,i)}setFromNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren)s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n));else{const o=this.kh;this.kh=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.toNode!==null?t.toNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.kh=o}}setToNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren){const o=this.kh;this.kh=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.fromNode!==null?t.fromNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.kh=o}else s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n))}rN(t){this.diagram.model.setParentKeyForNodeData(t.data,void 0)}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findNodeDataForKey(t);return e!==null?this.dl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.Y){i.Y=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="nodeParentKey"){const n=t.object,o=t.newValue,r=this.findNodeForKey(o),l=this.findNodeForData(n);if(this.kh!==null)r!==null&&(this.kh.data=n,this.kh.category=this.getLinkCategoryForData(n));else if(l!==null){const h=l.findTreeParentLink();h!==null?r===null?i.remove(h):i.isTreePathToChildren?h.fromNode=r:h.toNode=r:this.A1(r,l)}}else if(s==="parentLinkCategory"){const n=t.object,o=this.findNodeForData(n),r=t.newValue;if(o!==null&&typeof r=="string"){const l=o.findTreeParentLink();l!==null&&(l.category=r)}}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&n==="nodeParentKeyProperty"&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.Y=!0}}}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Node){const n=s.getParentKeyForNodeData(i),o=e.findNodeForKey(n),r=t.findTreeParentNode();if(o!==r){const l=t.findTreeParentLink();o!==null?l!==null?e.isTreePathToChildren?l.fromNode=o:l.toNode=o:this.A1(o,t):l!==null&&e.NS(l,!1)}}}Ny(t,i){if(super.Ny(t,i),typeof i=="string"&&this.findPartForData(t)!==null){const s=this.findLinkForData(t);s!==null&&s.updateTargetBindings(i)}}S1(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Cy(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)&&n instanceof Node&&i.getParentKeyForNodeData(l)===e){const h=this.findNodeForData(l);this.A1(n,h)}}i.Js(e)}const o=i.getParentKeyForNodeData(t);if(o!==void 0&&n instanceof Node){const r=this.findNodeForKey(o);this.A1(r,n)}}}pN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data),s=this.findLinkForData(t.data);if(s!==null){s.isSelected=!1,s.isHighlighted=!1;const r=s.layer;if(r!==null){const l=r._i(-1,s,!1);l>=0&&this.diagram.raiseChangedEvent(4,"parts",r,s,null,l,null);const h=s.layerChanged;h!==null&&h(s,r,null)}}const n=this.diagram.isTreePathToChildren,o=t.linksConnected;for(;o.next();){const r=o.value,h=(n?r.toNode:r.fromNode).data;i.containsNodeData(h)&&i.$s(e,h)}}}insertLink(t,i,e,s){const n=this.diagram.model;let o=t,r=e;if(this.diagram.isTreePathToChildren||(o=e,r=t),o!==null&&r!==null){const l=o.data,h=r.data;return n.setParentKeyForNodeData(h,n.getKeyForNodeData(l)),r.findTreeParentLink()}return null}}var BindingMode=(w=>(w[w.OneWay=1]="OneWay",w[w.TwoWay=2]="TwoWay",w))(BindingMode||{});class Binding{n;xN;Ba;Nf;Ph;Cf;Lf;Af;T1;ke;md;cf;constructor(t,i,e,s){GSet.Yi(this),t===void 0?t="":Util.i(t,"string",Binding,"constructor:targetprop"),i===void 0?i=t:Util.i(i,"string",Binding,"constructor:sourceprop"),e===void 0?e=null:e!==null&&Util.i(e,"function",Binding,"constructor:conv"),this.xN=-1,this.ke=null,this.Ba=t,this.md=0,this.cf=0,this.Nf=null,this.Ph=i,this.Cf=e,s===void 0?(this.Lf=1,this.Af=null):(this.Lf=2,this.Af=s),this.T1=new GSet,this.n=2}copy(){const t=new this.constructor;return this.cloneProtected(t),t}cloneProtected(t){t.Ba=this.Ba,t.md=this.md,t.cf=this.cf,t.Nf=this.Nf,t.Ph=this.Ph,t.Cf=this.Cf,t.Lf=this.Lf,t.Af=this.Af,t.n=this.n&-2}static OneWay=1;static TwoWay=2;static parseEnum(t,i){return Util.i(t,"function",Binding,"parseEnum:ctor"),e=>{let s=parseInt(e);return isNaN(s)&&(s=Util.Oh(t,e),s===null)?i:s}}ri(t){t in BindingMode?this.mode=t:Util.lr(this,t)}static toString(t){return Util.toString(t)}toString(){return"Binding("+this.targetProperty+":"+this.sourceProperty+(this.targetId!==-1?" "+this.targetId:"")+" "+BindingMode[this.mode]+")"}g(){return this.n=this.n|1,this}rt(){return this.n=this.n&-2,this}get targetId(){return this.xN}set targetId(t){this.h&&Util.T(this),Util.i(t,"number",Binding,"targetId"),this.xN=t}get targetProperty(){return this.Ba}set targetProperty(t){this.h&&Util.T(this),Util.i(t,"string",Binding,"targetProperty"),this.Ba=t}get sourceProperty(){return this.Ph}set sourceProperty(t){this.h&&Util.T(this),Util.i(t,"string",Binding,"sourceProperty"),this.Ph=t}get h(){return(this.n&1)!==0}get isToData(){return(this.n&2)!==0}get isToObject(){return(this.n&4)!==0}get isToModel(){return(this.n&8)!==0}get isToTheme(){return(this.n&16)!==0}get bN(){return this.isToTheme&&!(this.isToData||this.isToObject||this.isToModel)}Qu(){return!1}get sourceName(){return this.Nf}set sourceName(t){this.h&&Util.T(this),t!==null&&Util.i(t,"string",Binding,"sourceName"),this.Nf=t,t!==null?this.n=this.n&-3|4:this.n=this.n|2}get converter(){return this.Cf}set converter(t){this.h&&Util.T(this),t!==null&&Util.i(t,"function",Binding,"converter"),this.Cf=t}get backConverter(){return this.Af}set backConverter(t){this.h&&Util.T(this),t!==null&&Util.i(t,"function",Binding,"backConverter"),this.Af=t}get mode(){return this.Lf}set mode(t){this.h&&Util.T(this),this.isToTheme&&t===2&&Util.o("Theme Bindings cannot be TwoWay."),this.Lf=t}makeTwoWay(t){return this.isToTheme&&Util.o("Theme Bindings cannot be TwoWay."),this.mode=2,t&&(Util.i(t,"function",Binding,"makeTwoWay"),this.backConverter=t),this}ofObject(t){return this.h&&Util.T(this),t===void 0&&(t=""),this.sourceName=t,this}ofModel(){return this.h&&Util.T(this),this.n=this.n&-3&-5|8,this.Nf=null,this}QL(t,i){const e=this.sourceName;let s=null;return e===null||e===""?s=t:e==="/"?s=i.part:e==="."?s=i:e===".."?s=i.panel:s=t.findObject(e),s}check(t){const i=this.Ba,e=this.Ph,s=this.Cf;(this.Qu()&&s===null&&this.Mh===null&&i===""||s===null&&i==="")&&Util.oi("Binding error: target property is the empty string: "+this.toString()),this.Qu()&&this.bN&&e===""&&s===null&&this.Mh===null&&Util.oi("Binding error: theme bindings require a source property when not using a converter: "+this.toString()),t&&typeof i=="string"&&(typeof t.setAttribute!="function"&&i.length>0&&i[0]!=="_"&&!Util.fw(t,i)?Util.oi("Binding error: undefined target property: "+i+" on "+t.toString()):i==="name"&&t instanceof GraphObject&&Util.oi("Binding error: cannot modify GraphObject.name on "+t.toString()))}updateTarget(t,i,e){const s=this.Ph;if(e!==void 0&&s!==""&&s!==e)return;const n=this.Ba,o=this.Cf;let r=i;if(s!==""&&!this.bN&&(r=Model.vt(i,s)),r===void 0)return;const l=t.diagram?.themeManager??t.panel?.diagram?.themeManager;if(o===null){if(n!==""){if(this.Qu()&&(r=this.LT(l,r,t,n),r===void 0))return;Model.lt(t,n,r)}}else try{if(n!==""){let h=o(r,t);if(this.Qu()&&(h=this.LT(l,h,t,n),h===void 0))return;Model.lt(t,n,h)}else o(r,t)}catch{}}updateSource(t,i,e,s){if(this.Lf!==2)return;const n=this.Ba;if(e!==void 0&&n!==e)return;const o=this.Ph,r=this.Af;let l=t;if(n!==""&&(l=Model.vt(t,n)),l!==void 0&&!this.T1.has(t))try{this.T1.add(t);const h=s!==null?s.diagram:null,a=h!==null?h.model:null;if(r===null){if(o!=="")a!==null?a.setDataProperty(i,o,l):Model.lt(i,o,l);else if(a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const c=s.itemIndex,f=s.panel.itemArray;a.removeArrayItem(f,c),a.insertArrayItem(f,c,l)}}else try{if(o!==""){const c=r(l,i,a);a!==null?a.setDataProperty(i,o,c):Model.lt(i,o,c)}else{const c=r(l,i,a);if(c!==void 0&&a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const f=s.itemIndex,u=s.panel.itemArray;a.removeArrayItem(u,f),a.insertArrayItem(u,f,c)}}}catch{}}finally{this.T1.delete(t)}}}class ThemeBinding extends Binding{Ly;Mh;Va;constructor(t,i,e,s,n){super(t,i,s),e==null&&(e=""),n===void 0&&(n=null),this.Ly=e,this.Mh=n,this.Va=null,this.n=16}cloneProtected(t){super.cloneProtected(t),t.Ly=this.Ly,t.Mh=this.Mh,t.Va=this.Va}Qu(){return!0}get themeSource(){return this.Ly}set themeSource(t){this.h&&Util.T(this),t!==null&&Util.i(t,"string",ThemeBinding,"themeSource"),this.Ly=t,this.Va=null,t!==null?this.n=this.n|16:this.n=this.n&-17}get themeConverter(){return this.Mh}set themeConverter(t){this.h&&Util.T(this),t!==null&&Util.i(t,"function",ThemeBinding,"themeConverter"),this.Mh=t}ofData(){return this.h&&Util.T(this),this.n=this.n|2,this.Nf=null,this}LT(t,i,e,s){if(!t||(this.bN&&(i=this.Ph),!i&&i!==0))return;let n=this.themeSource;this.Va!==null?n=this.Va:typeof n=="string"&&n.includes(".")&&(this.Va=n.split("."),n=this.Va);let o=t.findValue(i,n,s);return o===void 0&&Util.oi(`Theme warning: ${i} could not be found when setting target property ${s}.`),typeof this.Mh=="function"&&(o=this.Mh(o,e)),o}}class Model{St;tg;vo;D1;De;Tf;Df;ig;eg;sg;ng;za;er;F1;Ro;R1;ti;Sh;og=new GSet;rg=new GSet;Ay;constructor(t,i){if(GSet.Yi(this),this.St="",this.tg="",this.vo=!1,this.D1={},this.De=[],this.ti=new GMap,this.Sh="key",this.Tf=null,this.Df=null,this.ig=!1,this.eg=!1,this.sg=!1,this.ng=null,this.za="category",this.er=new GMap,this.Ay=100,this.F1=new List,this.Ro=!1,this.R1=null,this.undoManager=new UndoManager,t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){t.St=this.St,t.tg=this.tg,t.vo=this.vo,t.Sh=this.Sh,t.Tf=this.Tf,t.Df=this.Df,t.ig=this.ig,t.eg=this.eg,t.sg=this.sg,t.Ay=this.Ay,t.ng=this.ng,t.za=this.za}copy(){const t=new this.constructor;return this.cloneProtected(t),t}clear(){this.De=[],this.ti.clear(),this.er.clear(),this.undoManager.clear()}toString(t){if(t===void 0&&(t=0),t>1)return this.toJson();{let i=(this.name!==""?this.name:"")+" Model";if(t>0){i+=` - node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n{if(u.model===e){if(u.modelChange==="nodeDataArray")u.change===3?n.add(u.newValue):u.change===4&&r.add(u.oldValue);else if(e.containsNodeData(u.object))o.add(u.object);else if(u.change===2&&(e.modelData===u.object||u.propertyName==="modelData"))s=!0;else if(u.object!==null)if(l&&l.has(u.object))l.get(u.object).each(m=>{e.containsNodeData(m)&&o.add(m)});else{if(u.object instanceof Model||e.Aa()&&e.containsLinkData(u.object))return;e.TT(u.object).each(m=>{o.add(m)})}}});const h=this.rg;h.clear(),n.each(u=>{h.add(e.getKeyForNodeData(u)),i||o.add(u)});const a=this.og;a.clear(),r.each(u=>{a.add(e.getKeyForNodeData(u)),i&&o.add(u)});const c=e.cloneDeep(o.toArray());let f=null;return s&&(f===null&&(f={}),f.modelData=this.cloneDeep(this.modelData)),h.count>0&&(f===null&&(f={}),i?f.removedNodeKeys=h.toArray():f.insertedNodeKeys=h.toArray()),c.length>0&&(f===null&&(f={}),f.modifiedNodeData=c),a.count>0&&(f===null&&(f={}),i?f.insertedNodeKeys=a.toArray():f.removedNodeKeys=a.toArray()),a.clear(),h.clear(),f}cloneDeep(t){return this.lg(t,!0)}lg(t,i,e,s,n){if(!Util.wt(t))return t;n||(n=[]);const o=Object.isExtensible(t);if(e||(e=new GMap),o){const h=e.get(t);if(h)return h}else{s||(s=new GMap);const h=s.iterator;for(;h.next();){const a=h.key;if(h.value===t){const f=e.get(a);if(f)return f}}}function r(h,a){if(o)h.__gohashid===void 0&&n.push(h),e.set(h,a);else{const c=GSet.nu++;e.set(c,a),s.set(c,t)}}let l;if(Array.isArray(t)){l=[],r(t,l);for(let h=0;h{delete h.__gohashid}),l}Fe(t){return JSON.stringify(t).replace(/[\u007F-\uFFFF]/g,e=>{const s="0000"+e.charCodeAt(0).toString(16);return"\\u"+s.substring(s.length-4)})}hg(){let t="";return this.name!==""&&(t+=`, + `+n.toString(t-1)}}return i}get layout(){return this.ie}set layout(t){t!==null&&(this.ie=t)}get vertexes(){return this.mo}get edges(){return this.Cn}createVertex(){return new LayoutVertex(this)}createEdge(){return new LayoutEdge(this)}addParts(t,i,e){if(t===null)return;i===void 0&&(i=!1),Util.i(i,"boolean",LayoutNetwork,"addParts:toplevelonly"),e===void 0&&(e=null),e===null&&(e=n=>{if(n instanceof Node)return!n.isLinkLabel;if(n instanceof Link){const o=n.fromNode;if(o===null||o.isLinkLabel)return!1;const r=n.toNode;return!(r===null||r.isLinkLabel)}return!1});const s=t.iterator;for(;s.next();){const n=s.value;if(n instanceof Node&&!(i&&!n.isTopLevel)&&n.canLayout()&&e(n))if(n instanceof Group&&n.layout===null)this.addParts(n.memberParts,!1);else{if(this.findVertex(n)!==null)continue;const o=this.createVertex();o.node=n,this.addVertex(o)}}for(s.reset();s.next();){const n=s.value;if(!(n instanceof Link)||i&&!n.isTopLevel||!n.canLayout()||!e(n)||this.findEdge(n)!==null)continue;const o=n.fromNode,r=n.toNode;if(o===null||r===null||o===r)continue;const l=this.findGroupVertex(o),h=this.findGroupVertex(r);this.linkVertexes(l,h,n)}}findGroupVertex(t){if(t===null)return null;const i=t.findVisibleNode();if(i===null)return null;let e=this.findVertex(i);if(e!==null)return e;let s=i.containingGroup;for(;s!==null;){if(e=this.findVertex(s),e!==null)return e;s=s.containingGroup}return null}addVertex(t){if(t===null)return;this.mo.add(t);const i=t.node;i!==null&&this.ky.set(i,t),t.network=this}addNode(t){if(t===null)return null;let i=this.findVertex(t);return i===null&&(i=this.createVertex(),i.node=t,this.addVertex(i)),i}deleteVertex(t){if(t!==null&&this.cT(t)){let i=t._o;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}i=t.tr;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}}}cT(t){if(t===null)return!1;const i=this.mo.delete(t);if(i){const e=t.node;e!==null&&this.ky.delete(e)}return i}deleteNode(t){if(t===null)return;const i=this.findVertex(t);i!==null&&this.deleteVertex(i)}findVertex(t){return t===null?null:this.ky.get(t)}addEdge(t){if(t===null)return;this.cN(t);const i=t.toVertex;i!==null&&i.addSourceEdge(t);const e=t.fromVertex;e!==null&&e.addDestinationEdge(t)}cN(t){if(t===null)return;this.Cn.add(t);const i=t.link;i!==null&&this.findEdge(i)===null&&this.Py.set(i,t),t.network=this}addLink(t){if(t===null)return null;const i=t.fromNode,e=t.toNode;let s=this.findEdge(t);return s===null?(s=this.createEdge(),s.link=t,i!==null&&(s.fromVertex=this.addNode(i)),e!==null&&(s.toVertex=this.addNode(e)),this.addEdge(s)):(i!==null?s.fromVertex=this.addNode(i):s.fromVertex=null,e!==null?s.toVertex=this.addNode(e):s.toVertex=null),s}deleteEdge(t){if(t===null)return;const i=t.toVertex;i!==null&&i.deleteSourceEdge(t);const e=t.fromVertex;e!==null&&e.deleteDestinationEdge(t),this.fN(t)}fN(t){if(t===null)return!1;const i=this.Cn.delete(t);if(i){const e=t.link;e!==null&&this.Py.delete(e)}return i}deleteLink(t){if(t===null)return;const i=this.findEdge(t);i!==null&&this.deleteEdge(i)}findEdge(t){return t===null?null:this.Py.get(t)}linkVertexes(t,i,e){if(t===null||i===null)return null;if(t.network===this&&i.network===this){const s=this.createEdge();return s.link=e,s.fromVertex=t,s.toVertex=i,this.addEdge(s),s}return null}reverseEdge(t){if(t===null)return;const i=t.fromVertex,e=t.toVertex;i===null||e===null||(i.deleteDestinationEdge(t),e.deleteSourceEdge(t),t.reverseEdge(),i.addSourceEdge(t),e.addDestinationEdge(t))}deleteSelfEdges(){const t=Util.nt(),i=this.Cn.iterator;for(;i.next();){const s=i.value;s.fromVertex===s.toVertex&&t.push(s)}const e=t.length;for(let s=0;s0||t.tr.count>0)}splitIntoSubNetworks(t){t===void 0&&(t=!0),t&&(this.deleteArtificialVertexes(),this.deleteUselessEdges(),this.deleteSelfEdges());const i=new List;let e=!0;for(;e;){e=!1;const s=this.mo.iterator;for(;s.next();){const n=s.value;if(this.isSingleton(n))continue;const o=this.layout.createNetwork();i.add(o),this.xO(o,n),e=!0;break}}return i.sort((s,n)=>s===null||n===null||s===n?0:n.vertexes.count-s.vertexes.count),i}xO(t,i){if(i===null)return;const e=new List;for(e.add(i);e.count>0;){const s=e.first();if(e.removeAt(0),s.network===t)continue;this.cT(s),t.addVertex(s);let n=s.sourceEdges;for(;n.next();){const o=n.value;o.network!==t&&(this.fN(o),t.cN(o),e.add(o.fromVertex))}for(n=s.destinationEdges;n.next();){const o=n.value;o.network!==t&&(this.fN(o),t.cN(o),e.add(o.toVertex))}}}findAllParts(){const t=new GSet,i=this.mo.iterator;for(;i.next();){const s=i.value;t.add(s.node)}const e=this.Cn.iterator;for(;e.next();){const s=e.value;t.add(s.link)}return t}}class LayoutVertex{go;Qt;de;Ae;qe;_o;tr;constructor(t){GSet.Yi(this),this.go=t,this.Ae=new Rect(0,0,10,10).g(),this.qe=new Point(5,5).g(),this.Qt=null,this.de=null,this._o=new List,this.tr=new List}clear(){this.Qt=null,this.de=null,this._o=new List,this.tr=new List}toString(t){t===void 0&&(t=0);let i="LayoutVertex#"+GSet.as(this);if(t>0&&(i+=this.node!==null?"("+this.node.toString()+")":"",t>1)){let e="",s=!0,n=this._o.iterator;for(;n.next();){const r=n.value;s?s=!1:e+=",",e+=r.toString(0)}let o="";for(s=!0,n=this.tr.iterator;n.next();){const r=n.value;s?s=!1:o+=",",o+=r.toString(0)}i+=" sources: "+e+" destinations: "+o}return i}get po(){return this._o.WN}get ir(){return this.tr.WN}get data(){return this.Qt}set data(t){if(this.Qt=t,t!==null&&t.bounds){const i=t.bounds,e=i.x,s=i.y,n=i.width,o=i.height;this.qe.e(n/2,o/2),this.Ae.e(e,s,n,o)}}get node(){return this.de}set node(t){if(this.de!==t){this.de=t,t.ensureBounds();const i=this.network.layout,e=Rect.l(),s=i.getLayoutBounds(t,e);let n=s.x,o=s.y;const r=s.width,l=s.height;if(isNaN(n)&&(n=0),isNaN(o)&&(o=0),this.Ae.e(n,o,r,l),Rect.s(e),!(t instanceof Group)){const h=t.locationObject.getDocumentPoint(Spot.Center);if(h.isReal()){this.qe.e(h.x-n,h.y-o);return}}this.qe.e(r/2,l/2)}}get bounds(){return this.Ae}set bounds(t){this.Ae.equals(t)||this.Ae.a(t)}get focus(){return this.qe}set focus(t){this.qe.equals(t)||this.qe.a(t)}get centerX(){return this.Ae.x+this.qe.x}set centerX(t){const i=this.Ae;i.x+this.qe.x!==t&&(i.ot(),i.x=t-this.qe.x,i.g())}get centerY(){return this.Ae.y+this.qe.y}set centerY(t){const i=this.Ae;i.y+this.qe.y!==t&&(i.ot(),i.y=t-this.qe.y,i.g())}get focusX(){return this.qe.x}set focusX(t){const i=this.qe;i.x!==t&&(i.ot(),i.x=t,i.g())}get focusY(){return this.qe.y}set focusY(t){const i=this.qe;i.y!==t&&(i.ot(),i.y=t,i.g())}get x(){return this.Ae.x}set x(t){const i=this.Ae;i.x!==t&&(i.ot(),i.x=t,i.g())}get y(){return this.Ae.y}set y(t){const i=this.Ae;i.y!==t&&(i.ot(),i.y=t,i.g())}get width(){return this.Ae.width}set width(t){const i=this.Ae;i.width!==t&&(i.ot(),i.width=t,i.g())}get height(){return this.Ae.height}set height(t){const i=this.Ae;i.height!==t&&(i.ot(),i.height=t,i.g())}commit(){const t=this.Qt;if(t!==null){const e=this.bounds,s=t.bounds;Util.wt(s)?(s.x=e.x,s.y=e.y,s.width=e.width,s.height=e.height):t.bounds=e.copy();return}const i=this.node;if(i!==null){const e=this.bounds;if(!(i instanceof Group)){const s=Rect.l();i.ensureBounds();const n=this.network.layout.getLayoutBounds(i,s),o=i.locationObject.getDocumentPoint(Spot.Center);if(n.isReal()&&o.isReal()){i.moveTo(e.x+this.focusX-(o.x-n.x)+i.margin.left,e.y+this.focusY-(o.y-n.y+i.margin.top)),Rect.s(s);return}Rect.s(s)}i.moveTo(e.x+i.margin.left,e.y+i.margin.top)}}addSourceEdge(t){t!==null&&(this._o.has(t)||this._o.add(t))}deleteSourceEdge(t){t!==null&&this._o.delete(t)}addDestinationEdge(t){t!==null&&(this.tr.has(t)||this.tr.add(t))}deleteDestinationEdge(t){t!==null&&this.tr.delete(t)}get network(){return this.go}set network(t){this.go=t}get sourceVertexes(){const t=new GSet,i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}return t.iterator}get destinationVertexes(){const t=new GSet,i=this.destinationEdges;for(;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get vertexes(){const t=new GSet;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get sourceEdges(){return this._o.iterator}get destinationEdges(){return this.tr.iterator}get edges(){const t=new List;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e)}return t.iterator}get edgesCount(){return this._o.count+this.tr.count}static standardComparer(t,i){const e=t.de,s=i.de;if(e)if(s){const n=e.text,o=s.text;return no?1:0}else return 1;else return s!==null?-1:0}static smartComparer(t,i){if(t!==null)if(i!==null){const e=t.de,s=i.de;if(e!==null)if(s!==null){const n=e.text.toLocaleLowerCase(),o=s.text.toLocaleLowerCase(),r=n.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),l=o.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let h=0;for(;h0&&(i+=this.He!==null?"("+this.He.toString()+")":"",t>1&&(i+=" "+(this.We?this.We.toString():"null")+" --> "+(this.Je?this.Je.toString():"null"))),i}reverseEdge(){const t=this.We;this.We=this.Je,this.Je=t}commit(){}getOtherVertex(t){return this.Je===t?this.We:this.We===t?this.Je:null}get network(){return this.go}set network(t){this.go=t}get data(){return this.Qt}set data(t){this.Qt!==t&&(this.Qt=t)}get link(){return this.He}set link(t){this.He!==t&&(this.He=t)}get fromVertex(){return this.We}set fromVertex(t){this.We!==t&&(this.We=t)}get toVertex(){return this.Je}set toVertex(t){this.Je!==t&&(this.Je=t)}}var GridAlignment=(w=>(w[w.Position=0]="Position",w[w.Location=1]="Location",w))(GridAlignment||{}),GridArrangement=(w=>(w[w.LeftToRight=10]="LeftToRight",w[w.RightToLeft=11]="RightToLeft",w))(GridArrangement||{}),GridSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w))(GridSorting||{});class GridLayout extends Layout{Wd;Jd;Lo;Ln;oi;zi;pe;ye;constructor(t){super(),this.isViewportSized=!0,this.Wd=NaN,this.Jd=NaN,this.Lo=new Size(NaN,NaN).g(),this.Ln=new Size(10,10).g(),this.oi=1,this.zi=10,this.pe=22,this.ye=GridLayout.standardComparer,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Wd=this.Wd,t.Jd=this.Jd,t.Lo.a(this.Lo),t.Ln.a(this.Ln),t.oi=this.oi,t.zi=this.zi,t.pe=this.pe,t.ye=this.ye}ri(t){t in GridSorting?this.sorting=t:t in GridArrangement?this.arrangement=t:t in GridAlignment?this.alignment=t:super.ri(t)}doLayout(t){this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.collectParts(t),e=this.diagram,n=i.copy().iterator;for(;n.next();){const m=n.value;if(m.Cl()&&(m.fromNode!==null||m.toNode!==null)){i.delete(m);continue}if(m.ensureBounds(),m instanceof Group){const g=m.memberParts;for(;g.next();){const p=g.value;i.delete(p)}}}const o=i.toArray();if(o.length===0)return;switch(this.sorting){case 20:break;case 21:o.reverse();break;case 22:o.sort(this.comparer);break;case 23:o.sort(this.comparer),o.reverse();break}let r=this.wrappingColumn;isNaN(r)&&(r=0);let l=this.wrappingWidth;if(isNaN(l)&&e!==null){const m=e.viewportBounds,g=e.padding;l=Math.max(m.width-g.left-g.right,0)}else l=Math.max(this.wrappingWidth,0);r<=0&&l<=0&&(r=1);let h=this.spacing.width;isFinite(h)||(h=0);let a=this.spacing.height;isFinite(a)||(a=0),e!==null&&e.startTransaction("Layout");const c=[];switch(this.alignment){case 0:this.bO(o,l,r,h,a,c);break;case 1:this.kO(o,l,r,h,a,c);break}let f=0,u=0,d=0;for(let m=0;m0&&m>e-1||i>0&&m>0&&L-c>i)&&(o.push(new Rect(0,d,i+s,g)),m=0,u=c,d+=g,g=0),g=Math.max(g,S);let C=0;switch(a){case 11:C=-x.width;break;default:C=0;break}switch(y.moveTo(u+C+y.margin.left,d+y.margin.top),a){case 11:u-=P;break;default:u+=P;break}m++}o.push(new Rect(0,d,i+s,g)),Rect.s(r)}kO(t,i,e,s,n,o){const r=Rect.l();let l=Math.max(this.cellSize.width,1),h=0,a=0,c=0;const f=Point.l();for(let C=0;C=h&&(i-=h);let x=0,k=0;const b=Math.max(this.cellSize.height,1);c=0;let P=0,S=!0;const L=Point.l();for(let C=0;C0)switch(u){case 11:{let D=(g-d-(N.width-T.x))/l;Geo.K(Math.round(D),D)?D=Math.round(D):D=Math.floor(D),g=D*l+d;break}default:{let D=(g-d+T.x)/l;Geo.K(Math.round(D),D)?D=Math.round(D):D=Math.ceil(D),g=D*l+d;break}}else switch(u){case 11:x=g+T.x+N.width;break;default:x=g-T.x;break}let A=0;switch(u){case 11:A=-(g+T.x)+x;break;default:A=g+N.width-T.x-x;break}if(e>0&&y>e-1||i>0&&y>0&&A>i){o.push(new Rect(0,S?p-c:p,i+s,P+c+n));for(let D=0;Dk&&(M.width+=M.x-k,M.x=k)}Rect.s(r)}commitLayers(t,i){}get wrappingWidth(){return this.Wd}set wrappingWidth(t){this.Wd!==t&&(Util.i(t,"number",GridLayout,"wrappingWidth"),(t>0||isNaN(t))&&(this.Wd=t,this.isViewportSized=isNaN(t),this.invalidateLayout()))}get wrappingColumn(){return this.Jd}set wrappingColumn(t){this.Jd!==t&&(Util.i(t,"number",GridLayout,"wrappingColumn"),(t>0||isNaN(t))&&(this.Jd=t,this.invalidateLayout()))}get cellSize(){return this.Lo}set cellSize(t){this.Lo.equals(t)||(this.Lo.a(t),this.invalidateLayout())}get spacing(){return this.Ln}set spacing(t){this.Ln.equals(t)||(this.Ln.a(t),this.invalidateLayout())}get alignment(){return this.oi}set alignment(t){this.oi!==t&&(t===1||t===0)&&(this.oi=t,this.invalidateLayout())}get arrangement(){return this.zi}set arrangement(t){this.zi!==t&&(t===10||t===11)&&(this.zi=t,this.invalidateLayout())}get sorting(){return this.pe}set sorting(t){this.pe!==t&&(t===20||t===21||t===22||t===23)&&(this.pe=t,this.invalidateLayout())}get comparer(){return this.ye}set comparer(t){this.ye!==t&&(Util.i(t,"function",GridLayout,"comparer"),this.ye=t,this.invalidateLayout())}static standardComparer(t,i){const e=t.text,s=i.text;return es?1:0}static smartComparer(t,i){if(t!==null)if(i!==null){const e=t.text.toLocaleLowerCase(),s=i.text.toLocaleLowerCase(),n=e.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),o=s.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let r=0;for(;r{e.containsNodeData(s)&&this.gT(s,!1)}),t.forEach(s=>{e.containsNodeData(s)&&this.M1(s)}),i!==!1&&this.diagram.bb(!1)}gT(t,i){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.yo.has(t))return null;i===void 0&&(i=!0);const e=this.PO(t);return e!==null&&i&&this.M1(t),e}PO(t){if(t==null||this.p.undoManager.isUndoingRedoing||this.yo.has(t))return null;const i=this.SO(t),e=this.findTemplateForNodeData(t,i);if(e!==null){e.li();const s=e.copy();if(s!==null){const n=this.diagram.fe;return this.diagram.fe=!0,s.Ho=i,s.Qt=t,this.Sy&&(s.ll="Tool"),this.diagram.add(s),s.Qt=null,s.data=t,this.diagram.fe=n,s}}return null}insertLink(t,i,e,s){return null}M1(t){}SO(t){return this.p.model.getCategoryForNodeData(t)}static mT=!1;static pT=!1;findTemplateForNodeData(t,i){const e=this.p,s=e.model,n=s.qc()&&s.isGroupForData(t);let o=null;return n?(o=e.groupTemplateMap.get(i),o===null&&(o=e.groupTemplateMap.get(""),o===null&&(PartManager.pT||(PartManager.pT=!0,Util.ii('No Group template found for category "'+i+'"'),Util.ii(" Using default group template")),o=e.rM))):(o=e.nodeTemplateMap.get(i),o===null&&(o=e.nodeTemplateMap.get(""),o===null&&(PartManager.mT||(PartManager.mT=!0,Util.ii('No Node template found for category "'+i+'"'),Util.ii(" Using default node template")),o=e.sM))),o}getLinkCategoryForData(t){return""}setLinkCategoryForData(t,i){}setFromNodeForLink(t,i,e){}setToNodeForLink(t,i,e){}static yT=!1;findLinkTemplateForCategory(t){const i=this.p;let e=i.linkTemplateMap.get(t);return e===null&&(e=i.linkTemplateMap.get(""),e===null&&(PartManager.yT||(PartManager.yT=!0,Util.ii('No Link template found for category "'+t+'"'),Util.ii(" Using default link template")),e=i.nM)),e}fv(t,i,e){t instanceof Link?(i!==null&&this.uT(i,t),e!==null&&this.fT(e,t)):t instanceof Part&&(i!==null&&this.yo.delete(i),e!==null&&this.yo.set(e,t))}dT(){const t=this.diagram.model;this.dN(t.nodeDataArray)}dN(t){t.forEach(i=>{this.N1(i)})}N1(t){const i=this.findPartForData(t);i!==null&&(this.diagram.NM(i,!1),this.gN(i))}gN(t){}nN(t){}findPartForKey(t){if(t==null)return null;const i=this.p.model.findNodeDataForKey(t);return i!==null?this.yo.get(i):null}findNodeForKey(t){if(t==null)return null;const i=this.p.model.findNodeDataForKey(t);if(i===null)return null;const e=this.yo.get(i);return e instanceof Node?e:null}findLinkForKey(t){return null}findPartForData(t){if(t===null)return null;let i=this.yo.get(t);return i!==null||(i=this.dl.get(t)),i}findNodeForData(t){if(t===null)return null;const i=this.yo.get(t);return i instanceof Node?i:null}findLinkForData(t,i){return t===null?null:this.dl.get(t)}findNodesByExample(...t){const i=new GSet,e=this.$d.iterator;for(;e.next();){const s=e.value,n=s.data;if(n!==null)for(let o=0;o{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),this.parts.each(o=>{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),s.forEach(o=>t.xT(o,!1));for(let o=0;o0){for(let o=0;oi.SL(s));const e=t.mh;if(Array.isArray(e)){const s=this.Ua.get(e);if(s===null){const n=[];n.push(t),this.Ua.set(e,n)}else{for(let n=0;ni.gR(s));const e=t.mh;if(Array.isArray(e)){const s=this.Ua.get(e);if(s!==null){for(let n=0;n0&&i.removeParts(l,!1),h.count>0){const c=h.iterator;for(;c.next();){const f=c.key,u=c.value;s.set(f,u)}}}if(i!==null&&this.p!==null){const o=i.model,r=o.afterCopyFunction;if(r!==null){const l=new GMap;s.each(a=>{a.key.data!==null&&l.set(a.key.data,a.value.data)});const h=this.p.model;r(l,o,h)}}const n=s.iterator;for(;n.next();)n.value.updateTargetBindings();return s}C1(t,i,e,s){if(t===null||s&&!t.canCopy())return null;if(e.has(t))return e.get(t);const n=this.pN(t,i);if(!(n instanceof Part))return null;if(n.isSelected=!1,n.isHighlighted=!1,e.set(t,n),t instanceof Node){const o=t.linksConnected;for(;o.next();){const r=o.value;if(r.fromNode===t){const l=e.get(r);l!==null&&(l.fromNode=n)}if(r.toNode===t){const l=e.get(r);l!==null&&(l.toNode=n)}}if(t instanceof Group&&n instanceof Group){const r=t.memberParts;for(;r.next();){const l=r.value,h=this.C1(l,i,e,s);h instanceof Link||h!==null&&(h.containingGroup=n)}}}else if(t instanceof Link&&n instanceof Link){const o=t.fromNode;if(o!==null){const h=e.get(o);h!==null&&(n.fromNode=h)}const r=t.toNode;if(r!==null){const h=e.get(r);h!==null&&(n.toNode=h)}const l=t.labelNodes;for(;l.next();){const h=l.value,a=this.C1(h,i,e,s);a!==null&&a instanceof Node&&(a.labeledLink=n)}}return n}pN(t,i){let e=null;const s=t.data;if(s!==null&&i!==null){const n=i.model;if(!(t instanceof Link)){const o=n.copyNodeData(s);Util.wt(o)&&(n.addNodeData(o),e=i.findPartForData(o))}}else if(t.li(),e=t.copy(),e!==null){const n=this.p;if(i!==null)i.add(e);else if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const o=n.model;let r=null;e instanceof Link||(r=o.copyNodeData(s)),Util.wt(r)&&(e.data=r)}}return e}get nodes(){return this.$d}get links(){return this.qs}get parts(){return this.At}get diagram(){return this.p}get addsToTemporaryLayer(){return this.Sy}set addsToTemporaryLayer(t){this.Sy=t}get preservesRebuildLocations(){return this.uN}set preservesRebuildLocations(t){this.uN=t}}class GraphLinksPartManager extends PartManager{LM(){const t=this.diagram.model;this.My(t.nodeDataArray),this.PT(t.linkDataArray)}My(t){super.My(t,!1);const i=this.links.iterator;for(;i.next();)i.value.Ld();this.diagram.bb(!1)}PT(t){t.forEach(i=>{this.ST(i)}),this.diagram.bb(!1)}ST(t){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.dl.has(t))return null;const i=this.getLinkCategoryForData(t),e=this.findLinkTemplateForCategory(i);if(e!==null){e.li();const s=e.copy();if(s!==null){const n=this.diagram.fe;this.diagram.fe=!0,s.Ho=i,s.Qt=t;const o=this.diagram.model,r=o.L1(t,!0);r!==""&&(s.fromPortId=r);const l=o.Te(t,!0);if(l!==void 0){const f=this.findNodeForKey(l);f instanceof Node&&(s.fromNode=f)}const h=o.L1(t,!1);h!==""&&(s.toPortId=h);const a=o.Te(t,!1);if(a!==void 0){const f=this.findNodeForKey(a);f instanceof Node&&(s.toNode=f)}const c=o.getLabelKeysForLinkData(t);return Array.isArray(c)&&c.forEach(f=>{const u=this.findNodeForKey(f);u!==null&&(u.labeledLink=s)}),this.Sy&&(s.ll="Tool"),this.diagram.add(s),s.Qt=null,s.data=t,this.diagram.fe=n,s}}return null}dT(){const t=this.diagram.model;this.MT(t.linkDataArray),this.dN(t.nodeDataArray)}MT(t){t.forEach(i=>{this.N1(i)})}getLinkCategoryForData(t){return this.diagram.model.getCategoryForLinkData(t)}setLinkCategoryForData(t,i){return this.diagram.model.setCategoryForLinkData(t,i)}setFromNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setFromKeyForLinkData(t.data,e.getKeyForNodeData(s))}setToNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setToKeyForLinkData(t.data,e.getKeyForNodeData(s))}nN(t){this.diagram.model.removeLinkData(t.data)}findPartForKey(t){const i=super.findPartForKey(t);if(i===null){const s=this.diagram.model.findLinkDataForKey(t);if(s!==null)return this.dl.get(s)}return i}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findLinkDataForKey(t);return e!==null?this.dl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.Y){i.Y=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="linkFromKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.fromNode=l}}else if(s==="linkToKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.toNode=l}}else if(s==="linkFromPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.fromPortId=r)}}else if(s==="linkToPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.toPortId=r)}}else if(s==="nodeGroupKey"){const n=t.object,o=this.findPartForData(n);if(o!==null){const r=t.newValue;if(r!==void 0){const l=this.findNodeForKey(r);l instanceof Group?o.containingGroup=l:o.containingGroup=null}else o.containingGroup=null}}else if(s==="linkLabelKeys"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.oldValue,l=t.newValue;Array.isArray(r)&&r.forEach(h=>{if(l.indexOf(h)>=0)return;const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=null)}),Array.isArray(l)&&l.forEach(h=>{const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=o)})}}else if(s==="linkCategory"){const n=t.object,o=this.findLinkForData(n),r=t.newValue;o!==null&&typeof r=="string"&&(o.category=r)}else if(s==="linkDataArray"){const n=t.oldValue;this.MT(n);const o=t.newValue;this.PT(o)}i.isModified=!0}else if(e===3){const n=t.newValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.ST(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=t.object,r=this.findLinkForData(o),l=this.findNodeForKey(n);r!==null&&l!==null&&(l.labeledLink=r)}i.isModified=!0}else if(e===4){const n=t.oldValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.N1(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=this.findNodeForKey(n);o!==null&&(o.labeledLink=null)}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&(n==="linkFromKeyProperty"||n==="linkToKeyProperty"||n==="linkFromPortIdProperty"||n==="linkToPortIdProperty"||n==="linkLabelKeysProperty"||n==="nodeIsGroupProperty"||n==="nodeGroupKeyProperty"||n==="linkCategoryProperty")&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.Y=!0}}}kT(){const t=this.diagram.model,i=new GSet,e=t.linkDataArray;e.forEach(n=>{i.add(n)});const s=[];this.links.each(n=>{n.data!==null&&!i.has(n.data)&&s.push(n.data)}),s.forEach(n=>{t.NT(n,!1)}),e.forEach(n=>{this.findLinkForData(n)===null&&t.CT(n,!1)})}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Link){let n=s.Te(i,!0),o=e.findNodeForKey(n);t.fromNode=o,n=s.Te(i,!1),o=e.findNodeForKey(n),t.toNode=o;const r=s.getLabelKeysForLinkData(i);if(r.length>0||t.labelNodes.count>0){if(r.length===1&&t.labelNodes.count===1){const f=r[0],u=t.labelNodes.first();if(s.getKeyForNodeData(u.data)===f)return}const l=new GSet().addAll(r),h=new GSet;t.labelNodes.each(f=>{if(f.data!==null){const u=s.getKeyForNodeData(f.data);u!==void 0&&h.add(u)}});const a=h.copy();a.removeAll(l);const c=l.copy();if(c.removeAll(h),a.count>0||c.count>0){const f=t;a.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink===f&&(d.labeledLink=null)}),c.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink!==f&&(d.labeledLink=f)})}}}else if(!(t instanceof Adornment)){const n=s.getGroupKeyForNodeData(i),o=e.findPartForKey(n);(o===null||o instanceof Group)&&(t.containingGroup=o)}}M1(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Cy(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)){if(n instanceof Group&&i.getGroupKeyForNodeData(l)===e){const h=this.findPartForData(l);h!==null&&(h.containingGroup=n)}}else{const h=this.findLinkForData(l);if(h!==null&&n instanceof Node){i.Te(l,!0)===e&&(h.fromNode=n),i.Te(l,!1)===e&&(h.toNode=n);const a=i.getLabelKeysForLinkData(l);Array.isArray(a)&&a.some(c=>c===e?(n.labeledLink=h,!0):!1)}}}i.Js(e)}const o=i.getGroupKeyForNodeData(t);if(o!==void 0){const r=this.findNodeForKey(o);r instanceof Group&&(n.containingGroup=r)}}}gN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data);if(e!==void 0){const s=t.linksConnected;for(;s.next();){const n=s.value;i.$s(e,n.data)}if(t.isLinkLabel){const n=t.labeledLink;n!==null&&i.$s(e,n.data)}if(t instanceof Group){const n=t.memberParts;for(;n.next();){const r=n.value.data;i.containsNodeData(r)&&i.$s(e,r)}}}}}pN(t,i){let e=super.pN(t,i);if(t instanceof Link){const s=t.data;if(s!==null&&i!==null){const n=i.model,o=n.copyLinkData(s);typeof o=="object"&&o!==null&&(n.addLinkData(o),e=i.findLinkForData(o))}else if(e!==null){const n=this.diagram;if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const r=n.model.copyLinkData(s);typeof r=="object"&&r!==null&&(e.data=r)}}}return e}insertLink(t,i,e,s){const n=this.diagram,o=n.model,r=n.toolManager.findTool("Linking");let l="";t!==null&&(i===null&&(i=t),l=i.portId,l===null&&(l=""));let h="";e!==null&&(s===null&&(s=e),h=s.portId,h===null&&(h=""));const a=r.archetypeLinkData;if(a instanceof Link){a.li();const c=a.copy();if(c!==null){c.fromNode=t,c.fromPortId=l,c.toNode=e,c.toPortId=h,n.add(c);const f=r.archetypeLabelNodeData;if(f instanceof Node){f.li();const u=f.copy();u!==null&&(u.labeledLink=c,n.add(u))}return c}}else if(a!==null){const c=o.copyLinkData(a);if(typeof c=="object"&&c!==null){t!==null&&o.Zd(c,o.getKeyForNodeData(t.data),!0),o.Qd(c,l,!0),e!==null&&o.Zd(c,o.getKeyForNodeData(e.data),!1),o.Qd(c,h,!1),o.addLinkData(c);const f=r.archetypeLabelNodeData;if(f!==null&&!(f instanceof Node)){const d=o.copyNodeData(f);if(typeof d=="object"&&d!==null){o.addNodeData(d);const m=o.getKeyForNodeData(d);m!==void 0&&o.addLabelKeyForLinkData(c,m)}}return n.findLinkForData(c)}}return null}}class TreePartManager extends PartManager{Ph=null;A1(t,i){if(t===null||i===null||i.findTreeParentLink()!==null)return null;const e=this.diagram.toolManager.findTool("Linking");let s=t,n=i;if(this.diagram.isTreePathToChildren){if(e!==null&&e.xu(s,n,null,!0))return null}else if(s=i,n=t,e!==null&&e.xu(s,n,null,!0))return null;const o=this.getLinkCategoryForData(i.data),r=this.findLinkTemplateForCategory(o);if(r!==null){r.li();const l=r.copy();if(l!==null){const h=this.diagram.fe;return this.diagram.fe=!0,l.Ho=o,l.Qt=i.data,l.fromNode=s,l.toNode=n,this.diagram.add(l),l.Qt=null,l.data=i.data,this.diagram.fe=h,l}}return null}getLinkCategoryForData(t){return this.diagram.model.getParentLinkCategoryForNodeData(t)}setLinkCategoryForData(t,i){this.diagram.model.setParentLinkCategoryForNodeData(t,i)}setFromNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren)s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n));else{const o=this.Ph;this.Ph=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.toNode!==null?t.toNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Ph=o}}setToNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren){const o=this.Ph;this.Ph=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.fromNode!==null?t.fromNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Ph=o}else s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n))}nN(t){this.diagram.model.setParentKeyForNodeData(t.data,void 0)}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findNodeDataForKey(t);return e!==null?this.dl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.Y){i.Y=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="nodeParentKey"){const n=t.object,o=t.newValue,r=this.findNodeForKey(o),l=this.findNodeForData(n);if(this.Ph!==null)r!==null&&(this.Ph.data=n,this.Ph.category=this.getLinkCategoryForData(n));else if(l!==null){const h=l.findTreeParentLink();h!==null?r===null?i.remove(h):i.isTreePathToChildren?h.fromNode=r:h.toNode=r:this.A1(r,l)}}else if(s==="parentLinkCategory"){const n=t.object,o=this.findNodeForData(n),r=t.newValue;if(o!==null&&typeof r=="string"){const l=o.findTreeParentLink();l!==null&&(l.category=r)}}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&n==="nodeParentKeyProperty"&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.Y=!0}}}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Node){const n=s.getParentKeyForNodeData(i),o=e.findNodeForKey(n),r=t.findTreeParentNode();if(o!==r){const l=t.findTreeParentLink();o!==null?l!==null?e.isTreePathToChildren?l.fromNode=o:l.toNode=o:this.A1(o,t):l!==null&&e.NM(l,!1)}}}Ny(t,i){if(super.Ny(t,i),typeof i=="string"&&this.findPartForData(t)!==null){const s=this.findLinkForData(t);s!==null&&s.updateTargetBindings(i)}}M1(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Cy(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)&&n instanceof Node&&i.getParentKeyForNodeData(l)===e){const h=this.findNodeForData(l);this.A1(n,h)}}i.Js(e)}const o=i.getParentKeyForNodeData(t);if(o!==void 0&&n instanceof Node){const r=this.findNodeForKey(o);this.A1(r,n)}}}gN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data),s=this.findLinkForData(t.data);if(s!==null){s.isSelected=!1,s.isHighlighted=!1;const r=s.layer;if(r!==null){const l=r.te(-1,s,!1);l>=0&&this.diagram.raiseChangedEvent(4,"parts",r,s,null,l,null);const h=s.layerChanged;h!==null&&h(s,r,null)}}const n=this.diagram.isTreePathToChildren,o=t.linksConnected;for(;o.next();){const r=o.value,h=(n?r.toNode:r.fromNode).data;i.containsNodeData(h)&&i.$s(e,h)}}}insertLink(t,i,e,s){const n=this.diagram.model;let o=t,r=e;if(this.diagram.isTreePathToChildren||(o=e,r=t),o!==null&&r!==null){const l=o.data,h=r.data;return n.setParentKeyForNodeData(h,n.getKeyForNodeData(l)),r.findTreeParentLink()}return null}}var BindingMode=(w=>(w[w.OneWay=1]="OneWay",w[w.TwoWay=2]="TwoWay",w))(BindingMode||{});class Binding{n;yN;Va;Cf;Sh;Lf;Af;Tf;T1;ke;gd;ff;constructor(t,i,e,s){GSet.Yi(this),t===void 0?t="":Util.i(t,"string",Binding,"constructor:targetprop"),i===void 0?i=t:Util.i(i,"string",Binding,"constructor:sourceprop"),e===void 0?e=null:e!==null&&Util.i(e,"function",Binding,"constructor:conv"),this.yN=-1,this.ke=null,this.Va=t,this.gd=0,this.ff=0,this.Cf=null,this.Sh=i,this.Lf=e,s===void 0?(this.Af=1,this.Tf=null):(this.Af=2,this.Tf=s),this.T1=new GSet,this.n=2}copy(){const t=new this.constructor;return this.cloneProtected(t),t}cloneProtected(t){t.Va=this.Va,t.gd=this.gd,t.ff=this.ff,t.Cf=this.Cf,t.Sh=this.Sh,t.Lf=this.Lf,t.Af=this.Af,t.Tf=this.Tf,t.n=this.n&-2}static OneWay=1;static TwoWay=2;static parseEnum(t,i){return Util.i(t,"function",Binding,"parseEnum:ctor"),e=>{let s=parseInt(e);return isNaN(s)&&(s=Util.Ih(t,e),s===null)?i:s}}ri(t){t in BindingMode?this.mode=t:Util.lr(this,t)}static toString(t){return Util.toString(t)}toString(){return"Binding("+this.targetProperty+":"+this.sourceProperty+(this.targetId!==-1?" "+this.targetId:"")+" "+BindingMode[this.mode]+")"}g(){return this.n=this.n|1,this}ot(){return this.n=this.n&-2,this}get targetId(){return this.yN}set targetId(t){this.h&&Util.T(this),Util.i(t,"number",Binding,"targetId"),this.yN=t}get targetProperty(){return this.Va}set targetProperty(t){this.h&&Util.T(this),Util.i(t,"string",Binding,"targetProperty"),this.Va=t}get sourceProperty(){return this.Sh}set sourceProperty(t){this.h&&Util.T(this),Util.i(t,"string",Binding,"sourceProperty"),this.Sh=t}get h(){return(this.n&1)!==0}get isToData(){return(this.n&2)!==0}get isToObject(){return(this.n&4)!==0}get isToModel(){return(this.n&8)!==0}get isToTheme(){return(this.n&16)!==0}get wN(){return this.isToTheme&&!(this.isToData||this.isToObject||this.isToModel)}Zu(){return!1}get sourceName(){return this.Cf}set sourceName(t){this.h&&Util.T(this),t!==null&&Util.i(t,"string",Binding,"sourceName"),this.Cf=t,t!==null?this.n=this.n&-3|4:this.n=this.n|2}get converter(){return this.Lf}set converter(t){this.h&&Util.T(this),t!==null&&Util.i(t,"function",Binding,"converter"),this.Lf=t}get backConverter(){return this.Tf}set backConverter(t){this.h&&Util.T(this),t!==null&&Util.i(t,"function",Binding,"backConverter"),this.Tf=t}get mode(){return this.Af}set mode(t){this.h&&Util.T(this),this.isToTheme&&t===2&&Util.o("Theme Bindings cannot be TwoWay."),this.Af=t}makeTwoWay(t){return this.isToTheme&&Util.o("Theme Bindings cannot be TwoWay."),this.mode=2,t&&(Util.i(t,"function",Binding,"makeTwoWay"),this.backConverter=t),this}ofObject(t){return this.h&&Util.T(this),t===void 0&&(t=""),this.sourceName=t,this}ofModel(){return this.h&&Util.T(this),this.n=this.n&-3&-5|8,this.Cf=null,this}ZL(t,i){const e=this.sourceName;let s=null;return e===null||e===""?s=t:e==="/"?s=i.part:e==="."?s=i:e===".."?s=i.panel:s=t.findObject(e),s}check(t){const i=this.Va,e=this.Sh,s=this.Lf;(this.Zu()&&s===null&&this.Mh===null&&i===""||s===null&&i==="")&&Util.ii("Binding error: target property is the empty string: "+this.toString()),this.Zu()&&this.wN&&e===""&&s===null&&this.Mh===null&&Util.ii("Binding error: theme bindings require a source property when not using a converter: "+this.toString()),t&&typeof i=="string"&&(typeof t.setAttribute!="function"&&i.length>0&&i[0]!=="_"&&!Util.fw(t,i)?Util.ii("Binding error: undefined target property: "+i+" on "+t.toString()):i==="name"&&t instanceof GraphObject&&Util.ii("Binding error: cannot modify GraphObject.name on "+t.toString()))}updateTarget(t,i,e){const s=this.Sh;if(e!==void 0&&s!==""&&s!==e)return;const n=this.Va,o=this.Lf;let r=i;if(s!==""&&!this.wN&&(r=Model.vt(i,s)),r===void 0)return;const l=t.diagram?.themeManager??t.panel?.diagram?.themeManager;if(o===null){if(n!==""){if(this.Zu()&&(r=this.LT(l,r,t,n),r===void 0))return;Model.rt(t,n,r)}}else try{if(n!==""){let h=o(r,t);if(this.Zu()&&(h=this.LT(l,h,t,n),h===void 0))return;Model.rt(t,n,h)}else o(r,t)}catch{}}updateSource(t,i,e,s){if(this.Af!==2)return;const n=this.Va;if(e!==void 0&&n!==e)return;const o=this.Sh,r=this.Tf;let l=t;if(n!==""&&(l=Model.vt(t,n)),l!==void 0&&!this.T1.has(t))try{this.T1.add(t);const h=s!==null?s.diagram:null,a=h!==null?h.model:null;if(r===null){if(o!=="")a!==null?a.setDataProperty(i,o,l):Model.rt(i,o,l);else if(a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const c=s.itemIndex,f=s.panel.itemArray;a.removeArrayItem(f,c),a.insertArrayItem(f,c,l)}}else try{if(o!==""){const c=r(l,i,a);a!==null?a.setDataProperty(i,o,c):Model.rt(i,o,c)}else{const c=r(l,i,a);if(c!==void 0&&a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const f=s.itemIndex,u=s.panel.itemArray;a.removeArrayItem(u,f),a.insertArrayItem(u,f,c)}}}catch{}}finally{this.T1.delete(t)}}}class ThemeBinding extends Binding{Ly;Mh;za;constructor(t,i,e,s,n){super(t,i,s),e==null&&(e=""),n===void 0&&(n=null),this.Ly=e,this.Mh=n,this.za=null,this.n=16}cloneProtected(t){super.cloneProtected(t),t.Ly=this.Ly,t.Mh=this.Mh,t.za=this.za}Zu(){return!0}get themeSource(){return this.Ly}set themeSource(t){this.h&&Util.T(this),t!==null&&Util.i(t,"string",ThemeBinding,"themeSource"),this.Ly=t,this.za=null,t!==null?this.n=this.n|16:this.n=this.n&-17}get themeConverter(){return this.Mh}set themeConverter(t){this.h&&Util.T(this),t!==null&&Util.i(t,"function",ThemeBinding,"themeConverter"),this.Mh=t}ofData(){return this.h&&Util.T(this),this.n=this.n|2,this.Cf=null,this}LT(t,i,e,s){if(!t||(this.wN&&(i=this.Sh),!i&&i!==0))return;let n=this.themeSource;this.za!==null?n=this.za:typeof n=="string"&&n.includes(".")&&(this.za=n.split("."),n=this.za);let o=t.findValue(i,n,s);return o===void 0&&Util.ii(`Theme warning: ${i} could not be found when setting target property ${s}.`),typeof this.Mh=="function"&&(o=this.Mh(o,e)),o}}class Model{Mt;_d;vo;D1;De;Df;Ff;tg;ig;eg;sg;Xa;er;F1;Ro;R1;ti;Nh;ng=new GSet;og=new GSet;Ay;constructor(t,i){if(GSet.Yi(this),this.Mt="",this._d="",this.vo=!1,this.D1={},this.De=[],this.ti=new GMap,this.Nh="key",this.Df=null,this.Ff=null,this.tg=!1,this.ig=!1,this.eg=!1,this.sg=null,this.Xa="category",this.er=new GMap,this.Ay=100,this.F1=new List,this.Ro=!1,this.R1=null,this.undoManager=new UndoManager,t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){t.Mt=this.Mt,t._d=this._d,t.vo=this.vo,t.Nh=this.Nh,t.Df=this.Df,t.Ff=this.Ff,t.tg=this.tg,t.ig=this.ig,t.eg=this.eg,t.Ay=this.Ay,t.sg=this.sg,t.Xa=this.Xa}copy(){const t=new this.constructor;return this.cloneProtected(t),t}clear(){this.De=[],this.ti.clear(),this.er.clear(),this.undoManager.clear()}toString(t){if(t===void 0&&(t=0),t>1)return this.toJson();{let i=(this.name!==""?this.name:"")+" Model";if(t>0){i+=` + node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n{if(u.model===e){if(u.modelChange==="nodeDataArray")u.change===3?n.add(u.newValue):u.change===4&&r.add(u.oldValue);else if(e.containsNodeData(u.object))o.add(u.object);else if(u.change===2&&(e.modelData===u.object||u.propertyName==="modelData"))s=!0;else if(u.object!==null)if(l&&l.has(u.object))l.get(u.object).each(m=>{e.containsNodeData(m)&&o.add(m)});else{if(u.object instanceof Model||e.Ta()&&e.containsLinkData(u.object))return;e.TT(u.object).each(m=>{o.add(m)})}}});const h=this.og;h.clear(),n.each(u=>{h.add(e.getKeyForNodeData(u)),i||o.add(u)});const a=this.ng;a.clear(),r.each(u=>{a.add(e.getKeyForNodeData(u)),i&&o.add(u)});const c=e.cloneDeep(o.toArray());let f=null;return s&&(f===null&&(f={}),f.modelData=this.cloneDeep(this.modelData)),h.count>0&&(f===null&&(f={}),i?f.removedNodeKeys=h.toArray():f.insertedNodeKeys=h.toArray()),c.length>0&&(f===null&&(f={}),f.modifiedNodeData=c),a.count>0&&(f===null&&(f={}),i?f.insertedNodeKeys=a.toArray():f.removedNodeKeys=a.toArray()),a.clear(),h.clear(),f}cloneDeep(t){return this.rg(t,!0)}rg(t,i,e,s,n){if(!Util.wt(t))return t;n||(n=[]);const o=Object.isExtensible(t);if(e||(e=new GMap),o){const h=e.get(t);if(h)return h}else{s||(s=new GMap);const h=s.iterator;for(;h.next();){const a=h.key;if(h.value===t){const f=e.get(a);if(f)return f}}}function r(h,a){if(o)h.__gohashid===void 0&&n.push(h),e.set(h,a);else{const c=GSet.su++;e.set(c,a),s.set(c,t)}}let l;if(Array.isArray(t)){l=[],r(t,l);for(let h=0;h{delete h.__gohashid}),l}Fe(t){return JSON.stringify(t).replace(/[\u007F-\uFFFF]/g,e=>{const s="0000"+e.charCodeAt(0).toString(16);return"\\u"+s.substring(s.length-4)})}lg(){let t="";return this.name!==""&&(t+=`, "name": `+this.Fe(this.name)),this.dataFormat!==""&&(t+=`, "dataFormat": `+this.Fe(this.dataFormat)),this.isReadOnly&&(t+=`, "isReadOnly": `+this.isReadOnly),this.nodeKeyProperty!=="key"&&typeof this.nodeKeyProperty=="string"&&(t+=`, @@ -29,16 +29,16 @@ string: ${t}`);break}}const T=b.qg;if(GeoStream.wC(b),i){const A=T.figures.itera "copiesKey": true`),this.pointsDigits!==100&&(t+=`, "pointsDigits": `+this.pointsDigits.toString()),this.nodeCategoryProperty!=="category"&&typeof this.nodeCategoryProperty=="string"&&(t+=`, "nodeCategoryProperty": `+this.Fe(this.nodeCategoryProperty)),t}Ty(t){t.name&&(this.name=t.name),t.dataFormat&&(this.dataFormat=t.dataFormat),t.isReadOnly&&(this.isReadOnly=!0),t.nodeKeyProperty&&(this.nodeKeyProperty=t.nodeKeyProperty),t.copiesArrays&&(this.copiesArrays=!0),t.copiesArrayObjects&&(this.copiesArrayObjects=!0),t.copiesKey!==void 0&&(this.copiesKey=t.copiesKey),t.pointsDigits!==void 0&&(this.pointsDigits=parseInt(t.pointsDigits)),t.nodeCategoryProperty&&(this.nodeCategoryProperty=t.nodeCategoryProperty)}DT(){const t=this.modelData;return`, - "modelData": `+this.FT(t)}RT(t){const i=t.modelData;Util.wt(i)&&(this.replaceJsonObjects(i),this.modelData=i)}PN(){const t=this.modelData;let i=!1;for(const s in t)if(!this.v1(t,s,t[s])){i=!0;break}let e="";return i&&(e=this.DT()),e+`, - "nodeDataArray": `+this.Nh(this.nodeDataArray,!0)}MN(t){this.RT(t);const i=t.nodeDataArray;Array.isArray(i)&&(this.replaceJsonObjects(i),this.nodeDataArray=i)}SN(t,i,e){if(t===i)return!0;if(typeof t!=typeof i||typeof t=="function"||typeof i=="function")return!1;if(Array.isArray(t)&&Array.isArray(i)){if(e.get(t)===i)return!0;if(e.set(t,i),t.length!==i.length)return!1;for(let s=0;s{const o=n.part;if(!o)return;const r=o.data;if(s===r)return;let l=i.get(s);l===null?(l=new GSet,l.add(r),i.set(s,l)):l.add(r)};i===null&&(i=new GMap,t.changes.each(s=>{if(s.diagram!==null){const n=s.change;if(n===2){const o=s.object.panel;if(o){const r=o.data;r&&e(r,o)}}else if(n===3||n===4){const o=s.object,r=o.itemArray;r&&e(r,o)}}}),this.Xa=i)}TT(t){const i=new GSet;for(let e=0;e{if(f.model===e){if(f.modelChange==="nodeDataArray")f.change===3?n.add(f.newValue):f.change===4&&r.add(f.oldValue);else if(e.containsNodeData(f.object))o.add(f.object);else if(f.change===2&&(e.modelData===f.object||f.propertyName==="modelData"))s=!0;else if(f.object!==null)if(l&&l.has(f.object))l.get(f.object).each(d=>{e.containsNodeData(d)&&o.add(d)});else{if(f.object instanceof Model||e.Aa()&&e.containsLinkData(f.object))return;e.TT(f.object).each(d=>{o.add(d)})}}});const h=this.rg;h.clear(),n.each(f=>{h.add(e.getKeyForNodeData(f)),i||o.add(f)});const a=this.og;a.clear(),r.each(f=>{a.add(e.getKeyForNodeData(f)),i&&o.add(f)});let c="";return s&&(c+=this.DT()),h.count>0&&(c+=(i?this.OT:this.vT)+this.Nh(h.toArray(),!0)),o.count>0&&(c+=this.LO+this.Nh(o.toArray(),!0)),a.count>0&&(c+=(i?this.vT:this.OT)+this.Nh(a.toArray(),!0)),a.clear(),h.clear(),c}Dy(t){(t.name!==void 0&&t.name!==this.name||t.dataFormat!==void 0&&t.dataFormat!==this.dataFormat||t.isReadOnly!==void 0&&t.isReadOnly!==this.isReadOnly||t.nodeKeyProperty!==void 0&&t.nodeKeyProperty!==this.nodeKeyProperty||t.copiesArrays!==void 0&&t.copiesArrays!==this.copiesArrays||t.copiesArrayObjects!==void 0&&t.copiesArrayObjects!==this.copiesArrayObjects||t.copiesKey!==void 0&&t.copiesKey!==this.copiesKey||t.nodeCategoryProperty!==void 0&&t.nodeCategoryProperty!==this.nodeCategoryProperty)&&Util.o("applyIncrementalJson cannot change Model properties"),this.RT(t);const i=t.insertedNodeKeys,e=t.modifiedNodeData,s=new GMap;if(Array.isArray(e))for(let o=0;o1&&s.add(` + "removedNodeKeys": `;Ka=null;AT(t){let i=this.Ka;const e=(s,n)=>{const o=n.part;if(!o)return;const r=o.data;if(s===r)return;let l=i.get(s);l===null?(l=new GSet,l.add(r),i.set(s,l)):l.add(r)};i===null&&(i=new GMap,t.changes.each(s=>{if(s.diagram!==null){const n=s.change;if(n===2){const o=s.object.panel;if(o){const r=o.data;r&&e(r,o)}}else if(n===3||n===4){const o=s.object,r=o.itemArray;r&&e(r,o)}}}),this.Ka=i)}TT(t){const i=new GSet;for(let e=0;e{if(f.model===e){if(f.modelChange==="nodeDataArray")f.change===3?n.add(f.newValue):f.change===4&&r.add(f.oldValue);else if(e.containsNodeData(f.object))o.add(f.object);else if(f.change===2&&(e.modelData===f.object||f.propertyName==="modelData"))s=!0;else if(f.object!==null)if(l&&l.has(f.object))l.get(f.object).each(d=>{e.containsNodeData(d)&&o.add(d)});else{if(f.object instanceof Model||e.Ta()&&e.containsLinkData(f.object))return;e.TT(f.object).each(d=>{o.add(d)})}}});const h=this.og;h.clear(),n.each(f=>{h.add(e.getKeyForNodeData(f)),i||o.add(f)});const a=this.ng;a.clear(),r.each(f=>{a.add(e.getKeyForNodeData(f)),i&&o.add(f)});let c="";return s&&(c+=this.DT()),h.count>0&&(c+=(i?this.OT:this.vT)+this.Ch(h.toArray(),!0)),o.count>0&&(c+=this.CO+this.Ch(o.toArray(),!0)),a.count>0&&(c+=(i?this.vT:this.OT)+this.Ch(a.toArray(),!0)),a.clear(),h.clear(),c}Dy(t){(t.name!==void 0&&t.name!==this.name||t.dataFormat!==void 0&&t.dataFormat!==this.dataFormat||t.isReadOnly!==void 0&&t.isReadOnly!==this.isReadOnly||t.nodeKeyProperty!==void 0&&t.nodeKeyProperty!==this.nodeKeyProperty||t.copiesArrays!==void 0&&t.copiesArrays!==this.copiesArrays||t.copiesArrayObjects!==void 0&&t.copiesArrayObjects!==this.copiesArrayObjects||t.copiesKey!==void 0&&t.copiesKey!==this.copiesKey||t.nodeCategoryProperty!==void 0&&t.nodeCategoryProperty!==this.nodeCategoryProperty)&&Util.o("applyIncrementalJson cannot change Model properties"),this.RT(t);const i=t.insertedNodeKeys,e=t.modifiedNodeData,s=new GMap;if(Array.isArray(e))for(let o=0;o1&&s.add(` `);for(let n=0;n0&&(s.add(","),i&&s.add(` `)),s.add(this.writeJsonValue(o)))}return i&&e>1&&s.add(` -`),s.add("]"),s.toString()}v1(t,i,e){return e===void 0||i==="__gohashid"||i[0]==="_"||typeof e=="function"}Xi(t){return isNaN(t)?"NaN":t===1/0?"9e9999":t===-1/0?"-9e9999":t}FT(t){const i=t;if(i instanceof Point)t={class:"go.Point",x:this.Xi(i.x),y:this.Xi(i.y)};else if(i instanceof Size)t={class:"go.Size",width:this.Xi(i.width),height:this.Xi(i.height)};else if(i instanceof Rect)t={class:"go.Rect",x:this.Xi(i.x),y:this.Xi(i.y),width:this.Xi(i.width),height:this.Xi(i.height)};else if(i instanceof Margin)t={class:"go.Margin",top:this.Xi(i.top),right:this.Xi(i.right),bottom:this.Xi(i.bottom),left:this.Xi(i.left)};else if(i instanceof Spot)i.isSpot()?t={class:"go.Spot",x:this.Xi(i.x),y:this.Xi(i.y),offsetX:this.Xi(i.offsetX),offsetY:this.Xi(i.offsetY)}:t={class:"go.Spot",enum:i.toString()};else if(i instanceof Brush){if(t={class:"go.Brush",type:BrushType[i.type]},i.type===1?t.color=i.color:(i.type===2||i.type===3)&&(t.start=i.start,t.end=i.end,i.type===3&&(i.startRadius!==0&&(t.startRadius=this.Xi(i.startRadius)),isNaN(i.endRadius)||(t.endRadius=this.Xi(i.endRadius)))),i.colorStops!==null){const n={},o=i.colorStops.iterator;for(;o.next();){const r=o.key,l=o.value;n[r]=l}t.colorStops=n}}else if(i instanceof Geometry)t={class:"go.Geometry",type:GeometryType[i.type]},i.startX!==0&&(t.startX=this.Xi(i.startX)),i.startY!==0&&(t.startY=this.Xi(i.startY)),i.endX!==0&&(t.endX=this.Xi(i.endX)),i.endY!==0&&(t.endY=this.Xi(i.endY)),i.spot1.equals(Spot.TopLeft)||(t.spot1=i.spot1),i.spot2.equals(Spot.BottomRight)||(t.spot2=i.spot2),i.type===4&&(t.path=Geometry.stringify(i));else if(Model.I1(Util.sn(i))!==null)return Util.oi("ERROR: trying to convert a GraphObject or Diagram or Model or Tool or Layout or UndoManager or other unknown data type into JSON text: "+i.toString()),"{}";let e="{",s=!0;for(const n in t){const o=Model.vt(t,n);if(!this.v1(t,n,o))if(s?s=!1:e+=",",e+=this.Fe(n)+":",n==="points"&&o instanceof List){const r=o;let l="[";const h=r.iterator;for(;h.next();){const a=h.value;l.length>1&&(l+=","),l+=this.IT(a.x),l+=",",l+=this.IT(a.y)}l+="]",e+=l}else e+=this.writeJsonValue(o)}return e+="}",e}IT(t){if(t===1/0)return"9e9999";if(t===-1/0)return"-9e9999";if(isNaN(t))return"0";const i=this.pointsDigits;return i>16?t.toString():t.toFixed(i)}get pointsDigits(){return this.Ay}set pointsDigits(t){t<0?t=0:t>100&&(t=100),this.Ay=t}Ki(t){return typeof t=="number"?t:t==="NaN"?NaN:t==="9e9999"?1/0:t==="-9e9999"?-1/0:parseFloat(t)}TO(t){if(typeof t!="object")return t;let i=t.class||"";if(typeof i!="string"||i==="")return t;if(i==="NaN")return NaN;if(i==="Date")return new Date(t.value);if(i.indexOf("go.")!==0)return t;i=i.substring(3);let e=t;if(i==="Point")e=new Point(this.Ki(t.x),this.Ki(t.y));else if(i==="Size")e=new Size(this.Ki(t.width),this.Ki(t.height));else if(i==="Rect")e=new Rect(this.Ki(t.x),this.Ki(t.y),this.Ki(t.width),this.Ki(t.height));else if(i==="Margin")e=new Margin(this.Ki(t.top),this.Ki(t.right),this.Ki(t.bottom),this.Ki(t.left));else if(i==="Spot")typeof t.enum=="string"?e=Spot.parse(t.enum):e=new Spot(this.Ki(t.x),this.Ki(t.y),this.Ki(t.offsetX),this.Ki(t.offsetY));else if(i==="Brush"){const s=new Brush;s.type=Util.Oh(BrushType,t.type)??1,typeof t.color=="string"&&(s.color=t.color),t.start instanceof Spot&&(s.start=t.start),t.end instanceof Spot&&(s.end=t.end),typeof t.startRadius=="number"&&(s.startRadius=this.Ki(t.startRadius)),typeof t.endRadius=="number"&&(s.endRadius=this.Ki(t.endRadius));const n=t.colorStops;if(Util.wt(n))for(const o in n){const r=parseFloat(o);s.addColorStop(r,n[o])}e=s}else if(i==="Geometry"){let s=null;typeof t.path=="string"?s=Geometry.parse(t.path):s=new Geometry,s.type=Util.Oh(GeometryType,t.type)??1,typeof t.startX=="number"&&(s.startX=this.Ki(t.startX)),typeof t.startY=="number"&&(s.startY=this.Ki(t.startY)),typeof t.endX=="number"&&(s.endX=this.Ki(t.endX)),typeof t.endY=="number"&&(s.endY=this.Ki(t.endY)),t.spot1 instanceof Spot&&(s.spot1=t.spot1),t.spot2 instanceof Spot&&(s.spot2=t.spot2),e=s}else if(i==="EnumValue"){let s=t.classType;s.indexOf("go.")===0&&(s=s.substring(3));const n=Model.I1(s);typeof n=="function"&&(e=Util.Oh(n,t.name))}return e}get name(){return this.St}set name(t){const i=this.St;i!==t&&(Util.i(t,"string",Model,"name"),this.St=t,this.t("name",i,t))}get dataFormat(){return this.tg}set dataFormat(t){const i=this.tg;i!==t&&(Util.i(t,"string",Model,"dataFormat"),this.tg=t,this.t("dataFormat",i,t))}get isReadOnly(){return this.vo}set isReadOnly(t){const i=this.vo;i!==t&&(Util.i(t,"boolean",Model,"isReadOnly"),this.vo=t,this.t("isReadOnly",i,t))}get modelData(){return this.D1}set modelData(t){const i=this.D1;i!==t&&(Util.i(t,"object",Model,"modelData"),this.D1=t,this.t("modelData",i,t),this.updateTargetBindings(t))}addChangedListener(t){return Util.i(t,"function",Model,"addChangedListener:listener"),this.F1.add(t),this}removeChangedListener(t){Util.i(t,"function",Model,"removeChangedListener:listener"),this.F1.delete(t)}Ew(t){this.skipsUndoManager||this.undoManager.handleChanged(t);const i=this.F1,e=i.length;for(let s=0;s0&&Util.o("Cannot set Model.nodeKeyProperty when there is existing node data"),this.Sh=t,this.t("nodeKeyProperty",i,t))}An(t,i,e){typeof t!="string"&&typeof t!="function"&&Util.we(t,"string or function",i,e)}getKeyForNodeData(t){if(t===null)return;const i=this.Sh;if(i==="")return;const e=Model.vt(t,i);if(e!==void 0){if(this.isKeyType(e))return e;Util.o("Key value for node data "+t+" is not a number or a string: "+e)}}setKeyForNodeData(t,i){if((i==null||!this.isKeyType(i))&&Util.we(i,"number or string",Model,"setKeyForNodeData:key"),t===null)return;const e=this.Sh;if(e==="")return;if(!this.containsNodeData(t)){Model.lt(t,e,i);return}const s=Model.vt(t,e);if(s!==i){if(this.findNodeDataForKey(i)!==null)return;Model.lt(t,e,i),s!==void 0&&this.ti.delete(s),this.ti.set(i,t),this.Et("nodeKey",2,e,t,s,i),typeof e=="string"&&this.updateTargetBindings(t,e),this.Fy(s,i)}}get makeUniqueKeyFunction(){return this.Tf}set makeUniqueKeyFunction(t){const i=this.Tf;i!==t&&(t!==null&&Util.i(t,"function",Model,"makeUniqueKeyFunction"),this.Tf=t,this.t("makeUniqueKeyFunction",i,t))}isKeyType(t){return typeof t=="number"||typeof t=="string"}containsNodeData(t){if(t===null)return!1;const i=this.getKeyForNodeData(t);return i===void 0?!1:this.ti.get(i)===t}findNodeDataForKey(t){return t===null&&Util.o("Model.findNodeDataForKey:key must not be null"),t===void 0||!this.isKeyType(t)?null:this.ti.get(t)}get nodeDataArray(){return this.De}set nodeDataArray(t){const i=this.De;if(i!==t){this.ti.clear(),this.CN();const e=t.length;for(let o=0;o=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" GraphLinksModel";if(t>0){i+=` +`),s.add("]"),s.toString()}v1(t,i,e){return e===void 0||i==="__gohashid"||i[0]==="_"||typeof e=="function"}Xi(t){return isNaN(t)?"NaN":t===1/0?"9e9999":t===-1/0?"-9e9999":t}FT(t){const i=t;if(i instanceof Point)t={class:"go.Point",x:this.Xi(i.x),y:this.Xi(i.y)};else if(i instanceof Size)t={class:"go.Size",width:this.Xi(i.width),height:this.Xi(i.height)};else if(i instanceof Rect)t={class:"go.Rect",x:this.Xi(i.x),y:this.Xi(i.y),width:this.Xi(i.width),height:this.Xi(i.height)};else if(i instanceof Margin)t={class:"go.Margin",top:this.Xi(i.top),right:this.Xi(i.right),bottom:this.Xi(i.bottom),left:this.Xi(i.left)};else if(i instanceof Spot)i.isSpot()?t={class:"go.Spot",x:this.Xi(i.x),y:this.Xi(i.y),offsetX:this.Xi(i.offsetX),offsetY:this.Xi(i.offsetY)}:t={class:"go.Spot",enum:i.toString()};else if(i instanceof Brush){if(t={class:"go.Brush",type:BrushType[i.type]},i.type===1?t.color=i.color:(i.type===2||i.type===3)&&(t.start=i.start,t.end=i.end,i.type===3&&(i.startRadius!==0&&(t.startRadius=this.Xi(i.startRadius)),isNaN(i.endRadius)||(t.endRadius=this.Xi(i.endRadius)))),i.colorStops!==null){const n={},o=i.colorStops.iterator;for(;o.next();){const r=o.key,l=o.value;n[r]=l}t.colorStops=n}}else if(i instanceof Geometry)t={class:"go.Geometry",type:GeometryType[i.type]},i.startX!==0&&(t.startX=this.Xi(i.startX)),i.startY!==0&&(t.startY=this.Xi(i.startY)),i.endX!==0&&(t.endX=this.Xi(i.endX)),i.endY!==0&&(t.endY=this.Xi(i.endY)),i.spot1.equals(Spot.TopLeft)||(t.spot1=i.spot1),i.spot2.equals(Spot.BottomRight)||(t.spot2=i.spot2),i.type===4&&(t.path=Geometry.stringify(i));else if(Model.I1(Util.sn(i))!==null)return Util.ii("ERROR: trying to convert a GraphObject or Diagram or Model or Tool or Layout or UndoManager or other unknown data type into JSON text: "+i.toString()),"{}";let e="{",s=!0;for(const n in t){const o=Model.vt(t,n);if(!this.v1(t,n,o))if(s?s=!1:e+=",",e+=this.Fe(n)+":",n==="points"&&o instanceof List){const r=o;let l="[";const h=r.iterator;for(;h.next();){const a=h.value;l.length>1&&(l+=","),l+=this.IT(a.x),l+=",",l+=this.IT(a.y)}l+="]",e+=l}else e+=this.writeJsonValue(o)}return e+="}",e}IT(t){if(t===1/0)return"9e9999";if(t===-1/0)return"-9e9999";if(isNaN(t))return"0";const i=this.pointsDigits;return i>16?t.toString():t.toFixed(i)}get pointsDigits(){return this.Ay}set pointsDigits(t){t<0?t=0:t>100&&(t=100),this.Ay=t}Ki(t){return typeof t=="number"?t:t==="NaN"?NaN:t==="9e9999"?1/0:t==="-9e9999"?-1/0:parseFloat(t)}AO(t){if(typeof t!="object")return t;let i=t.class||"";if(typeof i!="string"||i==="")return t;if(i==="NaN")return NaN;if(i==="Date")return new Date(t.value);if(i.indexOf("go.")!==0)return t;i=i.substring(3);let e=t;if(i==="Point")e=new Point(this.Ki(t.x),this.Ki(t.y));else if(i==="Size")e=new Size(this.Ki(t.width),this.Ki(t.height));else if(i==="Rect")e=new Rect(this.Ki(t.x),this.Ki(t.y),this.Ki(t.width),this.Ki(t.height));else if(i==="Margin")e=new Margin(this.Ki(t.top),this.Ki(t.right),this.Ki(t.bottom),this.Ki(t.left));else if(i==="Spot")typeof t.enum=="string"?e=Spot.parse(t.enum):e=new Spot(this.Ki(t.x),this.Ki(t.y),this.Ki(t.offsetX),this.Ki(t.offsetY));else if(i==="Brush"){const s=new Brush;s.type=Util.Ih(BrushType,t.type)??1,typeof t.color=="string"&&(s.color=t.color),t.start instanceof Spot&&(s.start=t.start),t.end instanceof Spot&&(s.end=t.end),typeof t.startRadius=="number"&&(s.startRadius=this.Ki(t.startRadius)),typeof t.endRadius=="number"&&(s.endRadius=this.Ki(t.endRadius));const n=t.colorStops;if(Util.wt(n))for(const o in n){const r=parseFloat(o);s.addColorStop(r,n[o])}e=s}else if(i==="Geometry"){let s=null;typeof t.path=="string"?s=Geometry.parse(t.path):s=new Geometry,s.type=Util.Ih(GeometryType,t.type)??1,typeof t.startX=="number"&&(s.startX=this.Ki(t.startX)),typeof t.startY=="number"&&(s.startY=this.Ki(t.startY)),typeof t.endX=="number"&&(s.endX=this.Ki(t.endX)),typeof t.endY=="number"&&(s.endY=this.Ki(t.endY)),t.spot1 instanceof Spot&&(s.spot1=t.spot1),t.spot2 instanceof Spot&&(s.spot2=t.spot2),e=s}else if(i==="EnumValue"){let s=t.classType;s.indexOf("go.")===0&&(s=s.substring(3));const n=Model.I1(s);typeof n=="function"&&(e=Util.Ih(n,t.name))}return e}get name(){return this.Mt}set name(t){const i=this.Mt;i!==t&&(Util.i(t,"string",Model,"name"),this.Mt=t,this.t("name",i,t))}get dataFormat(){return this._d}set dataFormat(t){const i=this._d;i!==t&&(Util.i(t,"string",Model,"dataFormat"),this._d=t,this.t("dataFormat",i,t))}get isReadOnly(){return this.vo}set isReadOnly(t){const i=this.vo;i!==t&&(Util.i(t,"boolean",Model,"isReadOnly"),this.vo=t,this.t("isReadOnly",i,t))}get modelData(){return this.D1}set modelData(t){const i=this.D1;i!==t&&(Util.i(t,"object",Model,"modelData"),this.D1=t,this.t("modelData",i,t),this.updateTargetBindings(t))}addChangedListener(t){return Util.i(t,"function",Model,"addChangedListener:listener"),this.F1.add(t),this}removeChangedListener(t){Util.i(t,"function",Model,"removeChangedListener:listener"),this.F1.delete(t)}Ew(t){this.skipsUndoManager||this.undoManager.handleChanged(t);const i=this.F1,e=i.length;for(let s=0;s0&&Util.o("Cannot set Model.nodeKeyProperty when there is existing node data"),this.Nh=t,this.t("nodeKeyProperty",i,t))}An(t,i,e){typeof t!="string"&&typeof t!="function"&&Util.we(t,"string or function",i,e)}getKeyForNodeData(t){if(t===null)return;const i=this.Nh;if(i==="")return;const e=Model.vt(t,i);if(e!==void 0){if(this.isKeyType(e))return e;Util.o("Key value for node data "+t+" is not a number or a string: "+e)}}setKeyForNodeData(t,i){if((i==null||!this.isKeyType(i))&&Util.we(i,"number or string",Model,"setKeyForNodeData:key"),t===null)return;const e=this.Nh;if(e==="")return;if(!this.containsNodeData(t)){Model.rt(t,e,i);return}const s=Model.vt(t,e);if(s!==i){if(this.findNodeDataForKey(i)!==null)return;Model.rt(t,e,i),s!==void 0&&this.ti.delete(s),this.ti.set(i,t),this.Et("nodeKey",2,e,t,s,i),typeof e=="string"&&this.updateTargetBindings(t,e),this.Fy(s,i)}}get makeUniqueKeyFunction(){return this.Df}set makeUniqueKeyFunction(t){const i=this.Df;i!==t&&(t!==null&&Util.i(t,"function",Model,"makeUniqueKeyFunction"),this.Df=t,this.t("makeUniqueKeyFunction",i,t))}isKeyType(t){return typeof t=="number"||typeof t=="string"}containsNodeData(t){if(t===null)return!1;const i=this.getKeyForNodeData(t);return i===void 0?!1:this.ti.get(i)===t}findNodeDataForKey(t){return t===null&&Util.o("Model.findNodeDataForKey:key must not be null"),t===void 0||!this.isKeyType(t)?null:this.ti.get(t)}get nodeDataArray(){return this.De}set nodeDataArray(t){const i=this.De;if(i!==t){this.ti.clear(),this.MN();const e=t.length;for(let o=0;o=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" GraphLinksModel";if(t>0){i+=` node data:`;let e=this.nodeDataArray,s=e.length,n=0;for(n=0;n"+this.Te(o,!1)}}return i}}kN(t,i){if(this.linkKeyProperty===""){const f=this.skipsUndoManager;this.skipsUndoManager=!0,this.linkKeyProperty="key",this.skipsUndoManager=f}let e=super.kN(t,i);const s=this,n=new GSet,o=new GSet,r=new GSet,l=this.Xa;t.changes.each(f=>{if(f.model===s){if(f.modelChange==="linkDataArray")f.change===3?n.add(f.newValue):f.change===4&&r.add(f.oldValue);else if(s.containsLinkData(f.object))o.add(f.object);else if(f.object!==null)if(f.object!==null&&l&&l.has(f.object))l.get(f.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(f.object instanceof Model||s.containsNodeData(f.object))return;s.UT(f.object).each(d=>o.add(d))}}});const h=this.rg;h.clear(),n.each(f=>{h.add(s.getKeyForLinkData(f)),i||o.add(f)});const a=this.og;a.clear(),r.each(f=>{a.add(s.getKeyForLinkData(f)),i&&o.add(f)});const c=s.cloneDeep(o.toArray());return h.count>0&&(e===null&&(e={}),i?e.removedLinkKeys=h.toArray():e.insertedLinkKeys=h.toArray()),c.length>0&&(e===null&&(e={}),e.modifiedLinkData=c),a.count>0&&(e===null&&(e={}),i?e.insertedLinkKeys=a.toArray():e.removedLinkKeys=a.toArray()),a.clear(),h.clear(),e}hg(){const t=super.hg();let i="";return this.linkCategoryProperty!=="category"&&typeof this.linkCategoryProperty=="string"&&(i+=`, + link data:`,e=this.linkDataArray,s=e.length,n=0;n"+this.Te(o,!1)}}return i}}xN(t,i){if(this.linkKeyProperty===""){const f=this.skipsUndoManager;this.skipsUndoManager=!0,this.linkKeyProperty="key",this.skipsUndoManager=f}let e=super.xN(t,i);const s=this,n=new GSet,o=new GSet,r=new GSet,l=this.Ka;t.changes.each(f=>{if(f.model===s){if(f.modelChange==="linkDataArray")f.change===3?n.add(f.newValue):f.change===4&&r.add(f.oldValue);else if(s.containsLinkData(f.object))o.add(f.object);else if(f.object!==null)if(f.object!==null&&l&&l.has(f.object))l.get(f.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(f.object instanceof Model||s.containsNodeData(f.object))return;s.BT(f.object).each(d=>o.add(d))}}});const h=this.og;h.clear(),n.each(f=>{h.add(s.getKeyForLinkData(f)),i||o.add(f)});const a=this.ng;a.clear(),r.each(f=>{a.add(s.getKeyForLinkData(f)),i&&o.add(f)});const c=s.cloneDeep(o.toArray());return h.count>0&&(e===null&&(e={}),i?e.removedLinkKeys=h.toArray():e.insertedLinkKeys=h.toArray()),c.length>0&&(e===null&&(e={}),e.modifiedLinkData=c),a.count>0&&(e===null&&(e={}),i?e.insertedLinkKeys=a.toArray():e.removedLinkKeys=a.toArray()),a.clear(),h.clear(),e}lg(){const t=super.lg();let i="";return this.linkCategoryProperty!=="category"&&typeof this.linkCategoryProperty=="string"&&(i+=`, "linkCategoryProperty": `+this.Fe(this.linkCategoryProperty)),this.linkKeyProperty!==""&&typeof this.linkKeyProperty=="string"&&(i+=`, "linkKeyProperty": `+this.Fe(this.linkKeyProperty)),this.linkFromKeyProperty!=="from"&&typeof this.linkFromKeyProperty=="string"&&(i+=`, "linkFromKeyProperty": `+this.Fe(this.linkFromKeyProperty)),this.linkToKeyProperty!=="to"&&typeof this.linkToKeyProperty=="string"&&(i+=`, @@ -47,13 +47,13 @@ string: ${t}`);break}}const T=b.qg;if(GeoStream.wC(b),i){const A=T.figures.itera "linkToPortIdProperty": `+this.Fe(this.linkToPortIdProperty)),this.linkLabelKeysProperty!==""&&typeof this.linkLabelKeysProperty=="string"&&(i+=`, "linkLabelKeysProperty": `+this.Fe(this.linkLabelKeysProperty)),this.nodeIsGroupProperty!=="isGroup"&&typeof this.nodeIsGroupProperty=="string"&&(i+=`, "nodeIsGroupProperty": `+this.Fe(this.nodeIsGroupProperty)),this.nodeGroupKeyProperty!=="group"&&typeof this.nodeGroupKeyProperty=="string"&&(i+=`, - "nodeGroupKeyProperty": `+this.Fe(this.nodeGroupKeyProperty)),t+i}Ty(t){super.Ty(t),t.linkKeyProperty&&(this.linkKeyProperty=t.linkKeyProperty),t.linkFromKeyProperty&&(this.linkFromKeyProperty=t.linkFromKeyProperty),t.linkToKeyProperty&&(this.linkToKeyProperty=t.linkToKeyProperty),t.linkFromPortIdProperty&&(this.linkFromPortIdProperty=t.linkFromPortIdProperty),t.linkToPortIdProperty&&(this.linkToPortIdProperty=t.linkToPortIdProperty),t.linkCategoryProperty&&(this.linkCategoryProperty=t.linkCategoryProperty),t.linkLabelKeysProperty&&(this.linkLabelKeysProperty=t.linkLabelKeysProperty),t.nodeIsGroupProperty&&(this.nodeIsGroupProperty=t.nodeIsGroupProperty),t.nodeGroupKeyProperty&&(this.nodeGroupKeyProperty=t.nodeGroupKeyProperty)}PN(){const t=super.PN(),i=`, - "linkDataArray": `+this.Nh(this.linkDataArray,!0);return t+i}MN(t){super.MN(t);const i=t.linkDataArray;Array.isArray(i)&&(this.replaceJsonObjects(i),this.linkDataArray=i)}BT=`, - "insertedLinkKeys": `;FO=`, + "nodeGroupKeyProperty": `+this.Fe(this.nodeGroupKeyProperty)),t+i}Ty(t){super.Ty(t),t.linkKeyProperty&&(this.linkKeyProperty=t.linkKeyProperty),t.linkFromKeyProperty&&(this.linkFromKeyProperty=t.linkFromKeyProperty),t.linkToKeyProperty&&(this.linkToKeyProperty=t.linkToKeyProperty),t.linkFromPortIdProperty&&(this.linkFromPortIdProperty=t.linkFromPortIdProperty),t.linkToPortIdProperty&&(this.linkToPortIdProperty=t.linkToPortIdProperty),t.linkCategoryProperty&&(this.linkCategoryProperty=t.linkCategoryProperty),t.linkLabelKeysProperty&&(this.linkLabelKeysProperty=t.linkLabelKeysProperty),t.nodeIsGroupProperty&&(this.nodeIsGroupProperty=t.nodeIsGroupProperty),t.nodeGroupKeyProperty&&(this.nodeGroupKeyProperty=t.nodeGroupKeyProperty)}bN(){const t=super.bN(),i=`, + "linkDataArray": `+this.Ch(this.linkDataArray,!0);return t+i}kN(t){super.kN(t);const i=t.linkDataArray;Array.isArray(i)&&(this.replaceJsonObjects(i),this.linkDataArray=i)}UT=`, + "insertedLinkKeys": `;DO=`, "modifiedLinkData": `;VT=`, - "removedLinkKeys": `;UT(t){const i=new GSet;for(let e=0;e{if(f.model===s){if(f.modelChange==="linkDataArray")f.change===3?n.add(f.newValue):f.change===4&&r.add(f.oldValue);else if(s.containsLinkData(f.object))o.add(f.object);else if(f.object!==null)if(f.object!==null&&l&&l.has(f.object))l.get(f.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(f.object instanceof Model||s.containsNodeData(f.object))return;s.UT(f.object).each(d=>o.add(d))}}});const h=this.rg;h.clear(),n.each(f=>{h.add(s.getKeyForLinkData(f)),i||o.add(f)});const a=this.og;a.clear(),r.each(f=>{a.add(s.getKeyForLinkData(f)),i&&o.add(f)});let c=e;return h.count>0&&(c+=(i?this.VT:this.BT)+this.Nh(h.toArray(),!0)),o.count>0&&(c+=this.FO+this.Nh(o.toArray(),!0)),a.count>0&&(c+=(i?this.BT:this.VT)+this.Nh(a.toArray(),!0)),a.clear(),h.clear(),c}Dy(t){(t.linkCategoryProperty!==void 0&&t.linkCategoryProperty!==this.linkCategoryProperty||t.linkKeyProperty!==void 0&&t.linkKeyProperty!==this.linkKeyProperty||t.linkFromKeyProperty!==void 0&&t.linkFromKeyProperty!==this.linkFromKeyProperty||t.linkToKeyProperty!==void 0&&t.linkToKeyProperty!==this.linkToKeyProperty||t.linkFromPortIdProperty!==void 0&&t.linkFromPortIdProperty!==this.linkFromPortIdProperty||t.linkToPortIdProperty!==void 0&&t.linkToPortIdProperty!==this.linkToPortIdProperty||t.linkLabelKeysProperty!==void 0&&t.linkLabelKeysProperty!==this.linkLabelKeysProperty||t.nodeIsGroupProperty!==void 0&&t.nodeIsGroupProperty!==this.nodeIsGroupProperty||t.nodeGroupKeyProperty!==void 0&&t.nodeGroupKeyProperty!==this.nodeGroupKeyProperty)&&Util.o("applyIncrementalJson cannot change Model properties"),super.Dy(t);const i=t.insertedLinkKeys;if(Array.isArray(i)){const n=i.length;for(let o=0;o=0&&s.splice(e,1)):s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue));return}}else if(t.change===4){let e=t.oldParam;if(t.modelChange==="linkDataArray"){const s=t.oldValue;if(Util.wt(s)&&typeof e=="number"){const n=this.getKeyForLinkData(s);i?(this.sr.add(s),this.$e[e]!==s&&this.$e.splice(e,0,s),n!==void 0&&this.fi.set(n,s)):(this.sr.delete(s),this.$e[e]===s&&this.$e.splice(e,1),n!==void 0&&this.fi.delete(n))}return}else if(t.modelChange==="linkLabelKeys"){const s=this.getLabelKeysForLinkData(t.object);Array.isArray(s)&&typeof e=="number"&&(i?s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue):(e=s.indexOf(t.newValue),e>=0&&s.splice(e,1)));return}}super.changeState(t,i)}}get archetypeNodeData(){return this.Ll}set archetypeNodeData(t){const i=this.Ll;i!==t&&(t!==null&&Util.i(t,"object",GraphLinksModel,"archetypeNodeData"),this.Ll=t,this.t("archetypeNodeData",i,t))}LN(t){if(t===void 0)return;const i=this.Ll;if(i!==null){let e=this.findNodeDataForKey(t);e===null&&(e=this.copyNodeData(i),Model.lt(e,this.nodeKeyProperty,t),this.addNodeData(e))}return t}get linkFromKeyProperty(){return this.wo}set linkFromKeyProperty(t){const i=this.wo;i!==t&&(this.An(t,GraphLinksModel,"linkFromKeyProperty"),this.wo=t,this.t("linkFromKeyProperty",i,t))}getFromKeyForLinkData(t){return this.Te(t,!0)}setFromKeyForLinkData(t,i){this.Qd(t,i,!0)}get linkToKeyProperty(){return this.xo}set linkToKeyProperty(t){const i=this.xo;i!==t&&(this.An(t,GraphLinksModel,"linkToKeyProperty"),this.xo=t,this.t("linkToKeyProperty",i,t))}getToKeyForLinkData(t){return this.Te(t,!1)}setToKeyForLinkData(t,i){this.Qd(t,i,!1)}Te(t,i){if(t===null)return;const e=i?this.wo:this.xo;if(e==="")return;const s=Model.vt(t,e);if(s!==void 0){if(this.isKeyType(s))return s;Util.o((i?"FromKey":"ToKey")+" value for link data "+t+" is not a number or a string: "+s)}}Qd(t,i,e){if(i===null&&(i=void 0),i!==void 0&&!this.isKeyType(i)&&Util.we(i,"number or string",GraphLinksModel,e?"setFromKeyForLinkData:key":"setToKeyForLinkData:key"),t===null)return;const s=e?this.wo:this.xo;if(s==="")return;if(i=this.LN(i),!this.containsLinkData(t)){Model.lt(t,s,i);return}const n=Model.vt(t,s);n!==i&&(this.Js(n,t),Model.lt(t,s,i),this.findNodeDataForKey(i)===null&&this.$s(i,t),this.Et(e?"linkFromKey":"linkToKey",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkFromPortIdProperty(){return this.Ka}set linkFromPortIdProperty(t){const i=this.Ka;i!==t&&(this.An(t,GraphLinksModel,"linkFromPortIdProperty"),this.Ka=t,this.t("linkFromPortIdProperty",i,t))}getFromPortIdForLinkData(t){return this.L1(t,!0)}setFromPortIdForLinkData(t,i){this._d(t,i,!0)}get linkToPortIdProperty(){return this.Ya}set linkToPortIdProperty(t){const i=this.Ya;i!==t&&(this.An(t,GraphLinksModel,"linkToPortIdProperty"),this.Ya=t,this.t("linkToPortIdProperty",i,t))}getToPortIdForLinkData(t){return this.L1(t,!1)}setToPortIdForLinkData(t,i){this._d(t,i,!1)}L1(t,i){if(t===null)return"";const e=i?this.Ka:this.Ya;if(e==="")return"";const s=Model.vt(t,e);return s===void 0?"":s}_d(t,i,e){if(Util.i(i,"string",GraphLinksModel,e?"setFromPortIdForLinkData:portname":"setToPortIdForLinkData:portname"),t===null)return;const s=e?this.Ka:this.Ya;if(s==="")return;if(!this.containsLinkData(t)){Model.lt(t,s,i);return}let n=Model.vt(t,s);n===void 0&&(n=""),n!==i&&(Model.lt(t,s,i),this.Et(e?"linkFromPortId":"linkToPortId",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkLabelKeysProperty(){return this.Zs}set linkLabelKeysProperty(t){const i=this.Zs;i!==t&&(this.An(t,GraphLinksModel,"linkLabelKeysProperty"),this.Zs=t,this.t("linkLabelKeysProperty",i,t))}getLabelKeysForLinkData(t){if(t===null)return GraphLinksModel.EmptyArray;const i=this.Zs;if(i==="")return GraphLinksModel.EmptyArray;const e=Model.vt(t,i);return e===void 0?GraphLinksModel.EmptyArray:e}setLabelKeysForLinkData(t,i){if(t===null)return;const e=this.Zs;if(e==="")return;if(!this.containsLinkData(t)){Model.lt(t,e,i);return}let s=Model.vt(t,e);if(s===void 0&&(s=GraphLinksModel.EmptyArray),s!==i){if(Array.isArray(s)){const o=s.length;for(let r=0;r=0)return;n=s.length,s.push(i),this.containsLinkData(t)&&(this.findNodeDataForKey(i)===null&&this.$s(i,t),this.Et("linkLabelKeys",3,e,t,null,i,null,n))}else Util.o(e+" property is not an Array; cannot addLabelKeyForLinkData: "+t)}removeLabelKeyForLinkData(t,i){if(i==null||(this.isKeyType(i)||Util.we(i,"number or string",GraphLinksModel,"removeLabelKeyForLinkData:key"),t===null))return;const e=this.Zs;if(e==="")return;const s=Model.vt(t,e);if(Array.isArray(s)){const n=s.indexOf(i);if(n<0)return;s.splice(n,1),this.containsLinkData(t)&&(this.Js(i,t),this.Et("linkLabelKeys",4,e,t,i,null,n,null))}else s!==void 0&&Util.o(e+" property is not an Array; cannot removeLabelKeyforLinkData: "+t)}get linkDataArray(){return this.$e}set linkDataArray(t){const i=this.$e;if(i!==t){this.fi.clear();const e=t.length;for(let n=0;nnew GraphLinksModel;Model.initDiagramModel=Model.initDiagramModel=()=>new GraphLinksModel;class TreeModel extends Model{Dn;dg;ja;constructor(t,i){if(super(),this.Dn="parent",this.dg=!1,this.ja="parentLinkCategory",t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){super.cloneProtected(t),t.Dn=this.Dn,t.dg=this.dg,t.ja=this.ja}toString(t){if(t===void 0&&(t=0),t>=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" TreeModel";if(t>0){i+=` - node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n(w[w.ConstantSpacing=0]="ConstantSpacing",w[w.ConstantDistance=1]="ConstantDistance",w[w.ConstantAngle=2]="ConstantAngle",w[w.Packed=3]="Packed",w))(CircularArrangement||{}),CircularDirection=(w=>(w[w.Clockwise=10]="Clockwise",w[w.Counterclockwise=11]="Counterclockwise",w[w.BidirectionalLeft=12]="BidirectionalLeft",w[w.BidirectionalRight=13]="BidirectionalRight",w))(CircularDirection||{}),CircularSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w[w.Optimized=24]="Optimized",w))(CircularSorting||{}),CircularNodeDiameterFormula=(w=>(w[w.Pythagorean=30]="Pythagorean",w[w.Circular=31]="Circular",w))(CircularNodeDiameterFormula||{});class CircularLayout extends Layout{re;Of;U1;gg;B1;Lh;DN;FN;RN;bs;vy;Oy;Ha;Iy;XT;mg;pg;yg;If;zi;S;pe;ye;Ln;wg;constructor(t){super(),this.re=0,this.Of=0,this.U1=0,this.gg=360,this.B1=0,this.Lh=0,this.DN=new Point,this.FN=30,this.RN=0,this.bs=0,this.vy=0,this.Oy=new VertexArrangement,this.Ha=0,this.Iy=0,this.XT=600,this.mg=NaN,this.pg=1,this.yg=0,this.If=360,this.zi=0,this.S=10,this.pe=24,this.ye=LayoutVertex.standardComparer,this.Ln=6,this.wg=30,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.mg=this.mg,t.pg=this.pg,t.yg=this.yg,t.If=this.If,t.zi=this.zi,t.S=this.S,t.pe=this.pe,t.ye=this.ye,t.Ln=this.Ln,t.wg=this.wg}ri(t){t in CircularSorting?this.sorting=t:t in CircularDirection?this.direction=t:t in CircularArrangement?this.arrangement=t:t in CircularNodeDiameterFormula?this.nodeDiameterFormula=t:super.ri(t)}createNetwork(){return new CircularNetwork(this)}OO(t,i,e){t=this.IO(t);let s=this.B1,n=this.FN,o=this.re,r=this.Of,l=this.U1,h=this.gg,a=this.Lh,c=this.RN,f=this.bs,u=this.vy;if(s=this.arrangement,n=this.nodeDiameterFormula,o=this.radius,(!isFinite(o)||o<=0)&&(o=NaN),r=this.aspectRatio,(!isFinite(r)||r<=0)&&(r=1),l=this.startAngle,isFinite(l)||(l=0),h=this.sweepAngle,(!isFinite(h)||h>360||h<1)&&(h=360),a=this.spacing,isFinite(a)||(a=NaN),s===3&&n===31?s=0:s===3&&n!==31&&(n=31,s=this.arrangement),(this.direction===12||this.direction===13)&&this.sorting!==24){for(let g=0;!(g>=t.length||(i.add(t.elt(g)),g+1>=t.length));g+=2)e.add(t.elt(g+1));this.direction===12?(this.arrangement===3&&i.reverse(),t=new List,t.addAll(i),t.addAll(e)):(this.arrangement===3&&e.reverse(),t=new List,t.addAll(e),t.addAll(i))}const d=t.length;c=0;let m=0;for(let g=0;g1?(o=y,f=o*r):(f=y,o=f)}else o=this.V1(u*(h>=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180)}else o=this.V1(c+(h>=360?d:d-1)*(s!==3?a:a*1.6),r,l*Math.PI/180,h*Math.PI/180);f=o*r}else{f=o*r;const g=this.vN(o,f,l*Math.PI/180,h*Math.PI/180);if(isNaN(a))s===0&&(a=(g-c)/(h>=360?d:d-1));else if(s===0){const p=(g-c)/(h>=360?d:d-1);p=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180),f=o*r):a=p}else{let p=-1/0;for(let k=0;k=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180);x>o?(o=x,f=o*r,u=y):u=g/(h>=360?d:d-1)}}return this.B1=s,this.FN=n,this.re=o,this.Of=r,this.U1=l,this.gg=h,this.Lh=a,this.RN=c,this.bs=f,this.vy=u,t}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.network.vertexes;if(i.count<=1){if(i.count===1){const u=i.first();u.centerX=0,u.centerY=0}this.updateParts(),this.network=null,this.isValidLayout=!0;return}let e=new List;e.addAll(i.iterator);const s=new List,n=new List;e=this.OO(e,s,n);const o=this.B1,r=this.re,l=this.U1,h=this.gg,a=this.Lh,c=this.bs,f=this.vy;if((this.direction===12||this.direction===13)&&o===3)this.KT(e,h,l-h/2,10);else if(this.direction===12||this.direction===13){let u=0;switch(o){case 1:u=this.z1(r,c,l,f)*180/Math.PI;break;case 0:{let d=0,m=0;const g=s.first();g!==null&&(d=g.Ah(Math.PI/2));const p=n.first();p!==null&&(m=p.Ah(Math.PI/2)),u=this.z1(r,c,l,a+(d+m)/2)*180/Math.PI;break}case 2:u=h/e.length;break}if(this.direction===12){switch(o){case 1:this.Ey(s,h/2,l,11);break;case 0:this.Uy(s,h/2,l,11);break;case 2:this.By(s,h/2,l,11);break}switch(o){case 1:this.Ey(n,h/2,l+u,10);break;case 0:this.Uy(n,h/2,l+u,10);break;case 2:this.By(n,h/2,l+u,10);break}}else{switch(o){case 1:this.Ey(n,h/2,l,11);break;case 0:this.Uy(n,h/2,l,11);break;case 2:this.By(n,h/2,l,11);break}switch(o){case 1:this.Ey(s,h/2,l+u,10);break;case 0:this.Uy(s,h/2,l+u,10);break;case 2:this.By(s,h/2,l+u,10);break}}}else switch(o){case 1:this.Ey(e,h,l,this.direction);break;case 0:this.Uy(e,h,l,this.direction);break;case 2:this.By(e,h,l,this.direction);break;case 3:this.KT(e,h,l,this.direction);break}this.updateParts(),this.network=null,this.isValidLayout=!0}By(t,i,e,s){const n=this.gg,o=this.re,r=this.bs,l=e*Math.PI/180,h=i*Math.PI/180,a=t.length;for(let c=0;c=360?a:a-1):-(c*h)/a),u=t.elt(c),d=o*Math.tan(f)/r,m=Math.sqrt((o*o+r*r*d*d)/(1+d*d));u.centerX=m*Math.cos(f),u.centerY=m*Math.sin(f),u.actualAngle=f*180/Math.PI}}Uy(t,i,e,s){const n=this.re,o=this.bs,r=this.Lh;let l=e*Math.PI/180;const h=t.length;for(let a=0;a180&&(n-=360),n*=Math.PI/180,this.Iy=n,this.YT(t,i,e,s)}else this.GT(t,i,e,s);this.Oy.commit(t)}GT(t,i,e,s){const n=this.re,o=this.bs,r=this.Lh,l=this.Of;let h=n*Math.cos(e*Math.PI/180),a=o*Math.sin(e*Math.PI/180);const c=t.toArray();if(c.length===3){c[0].centerX=n,c[0].centerY=0,c[1].centerX=c[0].centerX-c[0].width/2-c[1].width/2-r,c[1].y=c[0].y,c[2].centerX=(c[0].centerX+c[1].centerX)/2,c[2].y=c[0].y-c[2].height-r;return}else if(c.length===4){c[0].centerX=n,c[0].centerY=0,c[2].centerX=-c[0].centerX,c[2].centerY=c[0].centerY,c[1].centerX=0,c[1].y=Math.min(c[0].y,c[2].y)-c[1].height-r,c[3].centerX=0,c[3].y=Math.max(c[0].y+c[0].height+r,c[2].y+c[2].height+r);return}const f=Point.l();for(let b=0;b=c.length-1));b++)this.jT(h,a,c,b,s,f)||this.HT(h,a,c,b,s,f),h=f.x,a=f.y;if(Point.s(f),this.Ha++,this.Ha>23)return;const u=c[0].centerX,d=c[0].centerY,m=c[c.length-1].centerX,g=c[c.length-1].centerY;let p=Math.abs(u-m)-((c[0].width+c[c.length-1].width)/2+r);const y=Math.abs(d-g)-((c[0].height+c[c.length-1].height)/2+r);let x=0;if(Math.abs(y)<1){const b=Math.abs(u-m),P=(c[0].width+c[c.length-1].width)/2;b0?x=y:Math.abs(p)<1?x=0:x=p;let k=!1;Math.abs(m)>Math.abs(g)?k=m>0!=d>g:k=g>0!=u1&&(this.Ha<8?this.re-=x/(2*Math.PI):c.length<5&&x>10?this.re/=2:this.re-=x>0?1.7:-2.3,this.bs=this.re*l,this.GT(t,i,e,s))}YT(t,i,e,s){const n=this.re,o=this.bs,r=this.Of;let l=n*Math.cos(e*Math.PI/180),h=o*Math.sin(e*Math.PI/180);const a=Point.l(),c=t.toArray();for(let m=0;m=c.length-1));m++)this.jT(l,h,c,m,s,a)||this.HT(l,h,c,m,s,a),l=a.x,h=a.y;if(Point.s(a),this.Ha++,this.Ha>23)return;const f=Math.atan2(h,l);let u=s===10?this.Iy-f:f-this.Iy;u=Math.abs(u)1&&(this.Ha<8?this.re-=d/(2*Math.PI):this.re-=d>0?1.7:-2.3,this.bs=this.re*r,this.YT(t,i,e,s))}jT(t,i,e,s,n,o){const r=this.Lh,l=this.re,h=this.bs;let a=0,c=0;const f=(e[s].width+e[s+1].width)/2+r;let u=!1;if(i>=0!=(n===10)){if(a=t+f,a>l){if(a=t-f,a<-l)return o.x=a,o.y=c,!1;u=!0}}else if(a=t-f,a<-l){if(a=t+f,a>l)return o.x=a,o.y=c,!1;u=!0}return c=Math.sqrt(1-Math.min(1,a*a/(l*l)))*h,i<0!==u&&(c=-c),Math.abs(i-c)>(e[s].height+e[s+1].height)/2?(o.x=a,o.y=c,!1):(o.x=a,o.y=c,!0)}HT(t,i,e,s,n,o){const r=this.Lh,l=this.re,h=this.bs;let a=0,c=0;const f=(e[s].height+e[s+1].height)/2+r;let u=!1;if(t>=0!=(n===10)){if(c=i-f,c<-h){if(c=i+f,c>h)return o.x=a,o.y=c,!1;u=!0}}else if(c=i+f,c>h){if(c=i-f,c<-h)return o.x=a,o.y=c,!1;u=!0}return a=Math.sqrt(1-Math.min(1,c*c/(h*h)))*l,t<0!==u&&(a=-a),Math.abs(t-a)>(e[s].width+e[s+1].width)/2?(o.x=a,o.y=c,!1):(o.x=a,o.y=c,!0)}commitLayout(){this.commitNodes(),this.isRouting&&this.commitLinks()}commitNodes(){const t=this.group!==null&&this.group.hasPlaceholder(),i=t?this.group.location.copy():null;let e=this.actualCenter;t?e=new Point(0,0):(e.x=this.arrangementOrigin.x+this.re,e.y=this.arrangementOrigin.y+this.bs);const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;n.x+=e.x,n.y+=e.y,n.commit()}if(t){this.group.ensureBounds();const n=this.group.position.copy(),o=this.group.location.copy(),r=i.subtract(o.subtract(n));this.group.move(r),this.DN=r.subtract(n)}}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}vN(t,i,e,s){const n=this.XT;if(Math.abs(this.Of-1)<.001)return e!==void 0&&s!==void 0?s*t:2*Math.PI*t;const o=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let r=0,l=0;e!==void 0&&s!==void 0?l=s/(n+1):l=Math.PI/(2*(n+1));let h=0;for(let a=0;a<=n;a++){e!==void 0&&s!==void 0?h=e+a*s/n:h=a*Math.PI/(2*n);const c=Math.sin(h);r+=Math.sqrt(1-o*o*c*c)*l}return e!==void 0&&s!==void 0?(t>i?t:i)*r:4*(t>i?t:i)*r}V1(t,i,e,s){let n=0;return e!==void 0&&s!==void 0?n=this.vN(1,i,e,s):n=this.vN(1,i),t/n}z1(t,i,e,s){if(Math.abs(this.Of-1)<.001)return s/t;const n=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let o=0;const r=2*Math.PI/(this.network.vertexes.count*700);t>i&&(e+=Math.PI/2);for(let l=0;;l++){const h=e+l*r,a=Math.sin(h);if(o+=(t>i?t:i)*Math.sqrt(1-n*n*a*a)*r,o>=s)return l*r}}IO(t){switch(this.sorting){case 20:break;case 21:t.reverse();break;case 22:t.sort(this.comparer);break;case 23:t.sort(this.comparer),t.reverse();break;case 24:return this.BO(this.VO(t));default:Util.o("Invalid sorting type.")}return t}VO(t){const i=[];for(let s=0;sn&&(n=u,o=c)}else for(let c=0;cn&&(n=f,o=c)}e.add(t.elt(o)),i[o]=-1;const r=t.elt(o);let l=0;const h=r.sourceEdges;for(;h.next();){const f=h.value.fromVertex;l=t.indexOf(f),!(l<0)&&i[l]>=0&&i[l]++}const a=r.destinationEdges;for(;a.next();){const f=a.value.toVertex;l=t.indexOf(f),!(l<0)&&i[l]>=0&&i[l]++}}return e}BO(t){const i=[];for(let f=0;f=0){const C=Math.abs(x-(L>=x?L+1:L));b+=C=x&&M++,L>=x&&L++,M>L){const C=L;L=M,M=C}L-M<(s.length+2)/2==(M=0&&(n.push(f),o.push(x))}h++}let a=!1;const c=s.length;for(;;){a=!0;for(let f=0;f=0){let g=0;for(let p=0;pm?x-m:m-x,b=c-k;g+=xb?1:-1}s.splice(g<0?m:m+1,0,u),r.splice(f,1),f--}else a=!1}if(a)break;s.push(r[0]),r.splice(0,1)}for(let f=0;f0||isNaN(t))&&(this.mg=t,this.invalidateLayout()))}get aspectRatio(){return this.pg}set aspectRatio(t){this.pg!==t&&(Util.i(t,"number",CircularLayout,"aspectRatio"),t>0&&(this.pg=t,this.invalidateLayout()))}get startAngle(){return this.yg}set startAngle(t){this.yg!==t&&(Util.i(t,"number",CircularLayout,"startAngle"),this.yg=t,this.invalidateLayout())}get sweepAngle(){return this.If}set sweepAngle(t){this.If!==t&&(Util.i(t,"number",CircularLayout,"sweepAngle"),t>0&&t<=360?this.If=t:this.If=360,this.invalidateLayout())}get arrangement(){return this.zi}set arrangement(t){this.zi!==t&&(t===3||t===0||t===1||t===2)&&(this.zi=t,this.invalidateLayout())}get direction(){return this.S}set direction(t){this.S!==t&&(t===10||t===11||t===12||t===13)&&(this.S=t,this.invalidateLayout())}get sorting(){return this.pe}set sorting(t){this.pe!==t&&(this.pe=t,this.invalidateLayout())}get comparer(){return this.ye}set comparer(t){this.ye!==t&&(Util.i(t,"function",CircularLayout,"comparer"),this.ye=t,this.invalidateLayout())}get spacing(){return this.Ln}set spacing(t){this.Ln!==t&&(Util.i(t,"number",CircularLayout,"spacing"),this.Ln=t,this.invalidateLayout())}get nodeDiameterFormula(){return this.wg}set nodeDiameterFormula(t){this.wg!==t&&(t===30||t===31)&&(this.wg=t,this.invalidateLayout())}get actualXRadius(){return this.re}get actualYRadius(){return this.bs}get actualSpacing(){return this.Lh}get actualCenter(){return this.DN}static ConstantSpacing=0;static ConstantDistance=1;static ConstantAngle=2;static Packed=3;static Clockwise=10;static Counterclockwise=11;static BidirectionalLeft=12;static BidirectionalRight=13;static Forwards=20;static Reverse=21;static Ascending=22;static Descending=23;static Optimized=24;static Pythagorean=30;static Circular=31}class VertexArrangement{Ef;qa;Uf;constructor(){this.Ef=-1/0,this.qa=null,this.Uf=null}EO(t,i){if(t>0&&this.Ef<0||Math.abs(t)0)){this.Ef=t,this.qa=[],this.Uf=[];for(let e=0;e0){for(this.network.deleteSelfEdges(),i=this.network.vertexes.iterator;i.next();){const o=i.value;o.charge=this.electricalCharge(o),o.mass=this.gravitationalMass(o)}const s=this.network.edges.iterator;for(;s.next();){const o=s.value;o.stiffness=this.springStiffness(o),o.length=this.springLength(o)}if(this.ON(),this.Th=0,this.needsPrelayout()){const o=this.network,r=o.splitIntoSubNetworks(!1);let l=r.iterator;for(;l.next();){const h=l.value;this.doConnectedSubnetLayout(h)}for(l=r.iterator,this.XO(l,o),l=r.iterator;l.next();){const h=l.value,a=h.vertexes.iterator;for(;a.next();){const f=a.value;o.addVertex(f)}const c=h.edges.iterator;for(;c.next();){const f=c.value;o.addEdge(f)}}}else this.qT(this.network,this.maxIterations);this.updateParts()}this.maxIterations=e,this.isValidLayout=!0}needsPrelayout(){if(this.network.vertexes.count<3)return!1;let t=0,i=0;const e=this.network.vertexes.first().bounds,s=this.network.vertexes.iterator;for(;s.next();){const n=s.value,o=n.bounds;if(isNaN(n.x)||isNaN(n.y)||o.intersectsRect(e)&&(t++,t>2))return!0;if(i>10)return!1;i++}return!1}doConnectedSubnetLayout(t){let i=t.vertexes.iterator;for(;i.next();){const l=i.value;l.hierarchicalVertexes.add(l)}let e=t,s=this.Yf;if(isNaN(s)&&(s=t.edges.count/t.vertexes.count),sMath.max(100,Math.sqrt(s*t.vertexes.count));)e=this.coarsenNetwork(e);let n=0;i=e.vertexes.iterator;let o=this.randomNumberGenerator;for(o===null&&(this.randomNumberGenerator=o=new RandomNumberGenerator(0));i.next();){i.value.idInCluster=n++;const l=10*(o.random()-.5),h=10*(o.random()-.5);this.isFixed(i.value)||(i.value.x=l,i.value.y=h);const a=i.value.hierarchicalVertexes.iterator;for(;a.next();)this.isFixed(a.value)||(a.value.x=l,a.value.y=h)}const r=this.computePairwiseDistances(e);this.KO(e,r,this.maxPrelayoutIterations,t.vertexes.count),this.qT(t,this.maxIterations)}computePairwiseDistances(t){const i=t.vertexes.count,e=new Array(i);for(let r=0;r0;){const l=o.shift(),h=l.vertexes.iterator;for(;h.next();){const a=h.value;n.has(a.idInCluster)||(n.set(a.idInCluster,n.get(l.idInCluster)+1),o.push(a))}}for(let l=0;l=0;m--)if(t[m].y>c.y&&t[m].x-c.xc.x&&t[m].y-c.ya+f){const u=s+o-h,d=n-a-f;return Geo.bw(u*u+d*d)}else if(n+rh+c)if(n>a+f){const u=s-h-c,d=n-a-f;return Geo.bw(u*u+d*d)}else if(n+ra+f?n-(a+f):n+rr-o;l?i.sort((m,g)=>m===null||g===null||m===g?0:m.centerX-g.centerX):i.sort((m,g)=>m===null||g===null||m===g?0:m.centerY-g.centerY);const h=this.Bf;let a=0,c=0,f=0;for(let m=0;mh||C-x>h){if(l)break;continue}if(k-S>h||S-k>h){if(!l)break;continue}const N=this.IN(g,P),T=2*g.charge,A=2*P.charge;if(N>1)a=T*A/(N*N),c=a*(x-C)/N,f=a*(k-S)/N;else{let D=this.randomNumberGenerator;D===null&&(this.randomNumberGenerator=D=new RandomNumberGenerator(0));const F=D.random(),R=D.random();if(x>C)c=Math.abs(P.bounds.right-g.bounds.x),c=T*A*(1+c)*F;else if(xS)f=Math.abs(P.bounds.bottom-g.bounds.y),f=T*A*(1+f)*R;else if(x1&&(a=.1*m.stiffness*(S-m.length),c=a*.5*(g.width+p.height)*(k-L)/S,f=a*.5*(g.width+p.height)*(b-C)/S),g.forceX-=c,g.forceY-=f,p.forceX+=c,p.forceY+=f}let d=0;for(let m=0;mthis.epsilonDistance*this.epsilonDistance}KO(t,i,e,s){const n=this.Th+e,o=Math.sqrt(s);this.Vy=this.Wa*t.vertexes.count;const r=t.vertexes.toArray();let l=0,h=0,a=0;for(;this.Th0){r[c].forceX=this.Vy*r[c].forceX/f,r[c].forceY=this.Vy*r[c].forceY/f,this.isFixed(r[c])||(r[c].x+=r[c].forceX,r[c].y+=r[c].forceY);const u=r[c].hierarchicalVertexes.iterator;for(;u.next();){const d=u.value;this.isFixed(d)||(d.centerX+=r[c].forceX,d.centerY+=r[c].forceY)}}l+=f*f}if(l>=h){if(a++,a>=5)break}else a=0;this.Vy*=.95}}moveVertex(t){let i=t.forceX,e=t.forceY;const s=this.moveLimit;return i<-s?i=-s:i>s&&(i=s),e<-s?e=-s:e>s&&(e=s),t.centerX+=i,t.centerY+=e,i*i+e*e}shouldInteract(t,i){return!0}moveFixedVertex(t){}commitLayout(){this.zy(),this.commitNodes(),this.isRouting&&this.commitLinks()}zy(){if(!this.setsPortSpots)return;const t=this.network.edges.iterator;for(;t.next();){const e=t.value.link;e!==null&&(e.fromSpot=Spot.Default,e.toSpot=Spot.Default)}}commitNodes(){let t=0,i=0;if(this.arrangesToOrigin){const n=Rect.l();this.Nw(this.network,n);const o=this.arrangementOrigin;t=o.x-n.x,i=o.y-n.y,Rect.s(n)}const e=Rect.l(),s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;(t!==0||i!==0)&&(e.a(n.bounds),e.x+=t,e.y+=i,n.bounds=e),n.commit()}Rect.s(e)}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}springStiffness(t){const i=t.stiffness;return isNaN(i)?this.Vf:i}springLength(t){const i=t.length;return isNaN(i)?this.zf:i}electricalCharge(t){const i=t.charge;return isNaN(i)?this.Xf:i}electricalFieldX(t,i){return 0}electricalFieldY(t,i){return 0}gravitationalMass(t){const i=t.mass;return isNaN(i)?this.Kf:i}gravitationalFieldX(t,i){return 0}gravitationalFieldY(t,i){return 0}isFixed(t){return t.isFixed}get currentIteration(){return this.Th}get arrangementSpacing(){return this.ks}set arrangementSpacing(t){this.ks.equals(t)||(this.ks.a(t),this.invalidateLayout())}get arrangesToOrigin(){return this.xg}set arrangesToOrigin(t){this.xg!==t&&(Util.i(t,"boolean",ForceDirectedLayout,"arrangesToOrigin"),this.xg=t,this.invalidateLayout())}get setsPortSpots(){return this.Fn}set setsPortSpots(t){this.Fn!==t&&(Util.i(t,"boolean",ForceDirectedLayout,"setsPortSpots"),this.Fn=t,this.invalidateLayout())}get comments(){return this.Re}set comments(t){this.Re!==t&&(Util.i(t,"boolean",ForceDirectedLayout,"comments"),this.Re=t,this.invalidateLayout())}get maxPrelayoutIterations(){return this.bg}set maxPrelayoutIterations(t){this.bg!==t&&(Util.i(t,"number",ForceDirectedLayout,"maxPrelayoutIterations"),t>=0&&(this.bg=t,this.invalidateLayout()))}get maxIterations(){return this.kg}set maxIterations(t){this.kg!==t&&(Util.i(t,"number",ForceDirectedLayout,"maxIterations"),t>=0&&(this.kg=t,this.invalidateLayout()))}get epsilonDistance(){return this.Pg}set epsilonDistance(t){this.Pg!==t&&(Util.i(t,"number",ForceDirectedLayout,"epsilonDistance"),t>0&&(this.Pg=t,this.invalidateLayout()))}get infinityDistance(){return this.Bf}set infinityDistance(t){this.Bf!==t&&(Util.i(t,"number",ForceDirectedLayout,"infinityDistance"),t>1&&(this.Bf=t,this.invalidateLayout()))}get moveLimit(){return this.Mg}set moveLimit(t){this.Mg!==t&&(Util.i(t,"number",ForceDirectedLayout,"moveLimit"),this.Mg=t,this.invalidateLayout())}get randomNumberGenerator(){return this.Sg}set randomNumberGenerator(t){this.Sg!==t&&(t!==null&&typeof t.random!="function"&&Util.o('ForceDirectedLayout.randomNumberGenerator must have a "random()" function on it: '+t),this.Sg=t)}get defaultSpringStiffness(){return this.Vf}set defaultSpringStiffness(t){this.Vf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultSpringStiffness"),this.Vf=t,this.invalidateLayout())}get defaultSpringLength(){return this.zf}set defaultSpringLength(t){this.zf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultSpringLength"),this.zf=t,this.invalidateLayout())}get defaultElectricalCharge(){return this.Xf}set defaultElectricalCharge(t){this.Xf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultElectricalCharge"),this.Xf=t,this.invalidateLayout())}get defaultGravitationalMass(){return this.Kf}set defaultGravitationalMass(t){this.Kf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultGravitationalMass"),this.Kf=t,this.invalidateLayout())}get defaultCommentSpringLength(){return this.Ng}set defaultCommentSpringLength(t){this.Ng!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultCommentSpringLength"),this.Ng=t,this.invalidateLayout())}get defaultCommentElectricalCharge(){return this.Cg}set defaultCommentElectricalCharge(t){this.Cg!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultCommentElectricalCharge"),this.Cg=t,this.invalidateLayout())}get prelayoutQuality(){return this.Yf}set prelayoutQuality(t){this.Yf!==t&&(Util.i(t,"number",ForceDirectedLayout,"prelayoutQuality"),this.Yf=t,this.invalidateLayout())}get prelayoutSpread(){return this.Wa}set prelayoutSpread(t){this.Wa!==t&&(Util.i(t,"number",ForceDirectedLayout,"prelayoutSpread"),this.Wa=t,this.invalidateLayout())}}class ForceDirectedNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new ForceDirectedVertex(this)}createEdge(){return new ForceDirectedEdge(this)}}class ForceDirectedVertex extends LayoutVertex{K1;Y1;G1;j1;H1;hierarchicalVertexes;idInCluster;constructor(t){super(t),this.K1=!1,this.Y1=NaN,this.G1=NaN,this.j1=0,this.H1=0,this.hierarchicalVertexes=new List,this.idInCluster=-1}get isFixed(){return this.K1}set isFixed(t){this.K1!==t&&(Util.i(t,"boolean",ForceDirectedVertex,"isFixed"),this.K1=t)}get charge(){return this.Y1}set charge(t){this.Y1!==t&&(Util.i(t,"number",ForceDirectedVertex,"charge"),this.Y1=t)}get mass(){return this.G1}set mass(t){this.G1!==t&&(Util.i(t,"number",ForceDirectedVertex,"mass"),this.G1=t)}get forceX(){return this.j1}set forceX(t){this.j1!==t&&(Util.i(t,"number",ForceDirectedVertex,"forceX"),this.j1=t)}get forceY(){return this.H1}set forceY(t){this.H1!==t&&(Util.i(t,"number",ForceDirectedVertex,"forceY"),this.H1=t)}}class ForceDirectedEdge extends LayoutEdge{q1;W1;constructor(t){super(t),this.q1=NaN,this.W1=NaN}get stiffness(){return this.q1}set stiffness(t){this.q1!==t&&(Util.i(t,"number",ForceDirectedEdge,"stiffness"),this.q1=t)}get length(){return this.W1}set length(t){this.W1!==t&&(Util.i(t,"number",ForceDirectedEdge,"length"),this.W1=t)}}class RandomNumberGenerator{I;R;Q;M;A;seed;constructor(t){t===void 0&&(t=42),this.seed=t,this.A=48271,this.M=2147483647,this.Q=this.M/this.A,this.R=this.M%this.A,this.I=1/this.M,this.random()}random(){const t=this.seed/this.Q,i=this.seed%this.Q,e=this.A*i-this.R*t;return e>0?this.seed=e:this.seed=e+this.M,this.seed*this.I}}var LayeredDigraphCycleRemove=(w=>(w[w.DepthFirst=0]="DepthFirst",w[w.Greedy=1]="Greedy",w[w.FromLayers=2]="FromLayers",w))(LayeredDigraphCycleRemove||{}),LayeredDigraphLayering=(w=>(w[w.OptimalLinkLength=10]="OptimalLinkLength",w[w.LongestPathSink=11]="LongestPathSink",w[w.LongestPathSource=12]="LongestPathSource",w))(LayeredDigraphLayering||{}),LayeredDigraphInit=(w=>(w[w.DepthFirstOut=20]="DepthFirstOut",w[w.DepthFirstIn=21]="DepthFirstIn",w[w.Naive=22]="Naive",w))(LayeredDigraphInit||{}),LayeredDigraphAggressive=(w=>(w[w.None=30]="None",w[w.Less=31]="Less",w[w.More=32]="More",w))(LayeredDigraphAggressive||{}),LayeredDigraphPack=(w=>(w[w.None=0]="None",w[w.Expand=1]="Expand",w[w.Straighten=2]="Straighten",w[w.Median=4]="Median",w[w.MaybeExpand=8]="MaybeExpand",w[w.All=15]="All",w))(LayeredDigraphPack||{}),LayeredDigraphAlign=(w=>(w[w.None=0]="None",w[w.UpperLeft=1]="UpperLeft",w[w.UpperRight=2]="UpperRight",w[w.LowerLeft=4]="LowerLeft",w[w.LowerRight=8]="LowerRight",w[w.All=15]="All",w))(LayeredDigraphAlign||{});class LayeredDigraphLayout extends Layout{Ps;Wi;S;Gf;jf;Hf;Ja;qf;nr;Wf;Fn;Mt;Xy;Kt;Lg;Ms;ui;Qs;Ss;Ns;Bt;Ag;$a;Tg;_s;Jf;or;Rn;vn;EN;constructor(t){super(),this.Ps=25,this.Wi=25,this.S=0,this.Gf=0,this.jf=10,this.Hf=20,this.Ja=4,this.qf=31,this.nr=15,this.Wf=10,this.Fn=!0,this.Mt=-1,this.Xy=-1,this.Kt=-1,this.Lg=0,this.Ms=0,this.ui=null,this.Qs=null,this.Ss=null,this.Ns=null,this.Bt=null,this.Ag=0,this.$a=null,this.Tg=null,this._s=0,this.Jf=null,this.or=new Point,this.Rn=[],this.Rn.length=100,this.vn=15,this.EN=0,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Ps=this.Ps,t.Wi=this.Wi,t.S=this.S,t.Gf=this.Gf,t.jf=this.jf,t.Hf=this.Hf,t.Ja=this.Ja,t.qf=this.qf,t.nr=this.nr,t.Wf=this.Wf,t.Fn=this.Fn,t.vn=this.vn}ri(t){t in LayeredDigraphAggressive?this.aggressiveOption=t:t in LayeredDigraphCycleRemove?this.cycleRemoveOption=t:t in LayeredDigraphInit?this.initializeOption=t:t in LayeredDigraphLayering?this.layeringOption=t:super.ri(t)}createNetwork(){return new LayeredDigraphNetwork(this)}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin),this.GO(),this.network.vertexes.count>0&&(this.network.deleteSelfEdges(),this.cycleRemoveOption!==2&&this.removeCycles(),this.jO(),this.cycleRemoveOption===2&&this.removeCycles(),this.HO(),this.qO(),this.WO(),this.reduceCrossings(),this.straightenAndPack(),this.updateParts()),this.network=null,this.isValidLayout=!0}linkMinLength(t){return 1}linkLengthWeight(t){return 1}linkStraightenWeight(t){const i=t.fromVertex.node||t.fromVertex.data,e=t.toVertex.node||t.toVertex.data;return i===null&&e===null?8:i===null||e===null?4:1}nodeMinLayerSpace(t,i){return t.node===null&&t.data===null?0:this.S===90||this.S===270?i?t.focus.y+10:t.bounds.height-t.focus.y+10:i?t.focus.x+10:t.bounds.width-t.focus.x+10}nodeMinColumnSpace(t,i){if(t.node===null&&t.data===null)return 0;const e=i?t.J1:t.$1;if(e!==null)return e;const s=this.S;return s===90||s===270?i?t.J1=t.focus.x/this.Wi+1|0:t.$1=(t.bounds.width-t.focus.x)/this.Wi+1|0:i?t.J1=t.focus.y/this.Wi+1|0:t.$1=(t.bounds.height-t.focus.y)/this.Wi+1|0}Ji(){this.$a===null&&(this.$a=[]);let t=0;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;this.$a[t]=e.layer,t++,this.$a[t]=e.column,t++,this.$a[t]=e.index,t++}return this.$a}Ze(t){let i=0;const e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;s.layer=t[i],i++,s.column=t[i],i++,s.index=t[i],i++}}JT(t,i){const e=this.Dh(t),s=this.ui[t];(this.Tg===null||this.Tg.length=0){for(c=e[o].po,f=0;fk||d===k&&g>P)&&r++,bd||k===d&&P>g)&&r++)}if(i<=0){for(c=e[o].ir,f=0;fk||d===k&&m>b)&&r++,Pd||k===d&&b>m)&&r++)}for(n[o*s+o]=r,a=o+1;a=0){for(p=e[o].po,M=e[a].po,f=0;f=0&&(h=s[r].ir);let a,c=0,f=0;if(l!==null)for(let u=0;u=0&&(h=r.ir);let a=0,c=0;const f=r.near;f!==null&&f.layer===r.layer&&(a+=f.column-1,c++);let u;if(l!==null)for(let d=0;d=0&&(h=r.ir);let a=0;const c=[],f=r.near;f!==null&&f.layer===r.layer&&(c[a]=f.column-1,a++);let u;if(l!==null)for(let d=0;dm-g);const d=a>>1;a&1?n[o]=c[d]:n[o]=c[d-1]+c[d]>>1}}return this.Fh(t,e),n}Gy(t,i,e,s,n){if(t.component===e){t.component=i;let o=0,r=0;if(s){const l=t.destinationEdges;for(;l.next();){const h=l.value,a=h.toVertex;o=t.layer-a.layer,r=this.linkMinLength(h),o===r&&this.Gy(a,i,e,s,n)}}if(n){const l=t.sourceEdges;for(;l.next();){const h=l.value,a=h.fromVertex;o=a.layer-t.layer,r=this.linkMinLength(h),o===r&&this.Gy(a,i,e,s,n)}}}}UN(t,i,e,s,n){if(t.component===e){if(t.component=i,s){const o=t.destinationEdges;for(;o.next();){const l=o.value.toVertex;this.UN(l,i,e,s,n)}}if(n){const o=t.sourceEdges;for(;o.next();){const l=o.value.fromVertex;this.UN(l,i,e,s,n)}}}}removeCycles(){const t=this.network.edges.iterator;for(;t.next();){const i=t.value;i.rev=!1}switch(this.Gf){default:case 1:this.$O();break;case 0:this.ZO();break;case 2:this.QO();break}}QO(){const t=this.network,i=t.vertexes.iterator;let e=1/0;for(;i.next();){const s=i.value;e=Math.min(e,s.layer)}if(e<1/0){if(e<0)for(i.reset();i.next();){const r=i.value;r.layer-=e}const s=[];for(i.reset();i.next();){const r=i.value,l=s[r.layer];l===void 0?s[r.layer]=[r]:l.push(r)}let n=0;for(let r=0;r0)for(let h=0;hh.index&&(t.reverseEdge(r),r.rev=!0)}}_O(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.$i)return e}return null}ZT(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.$i){let s=!0;const n=e.destinationEdges;for(;n.next();)if(n.value.toVertex.$i){s=!1;break}if(s)return e}}return null}QT(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.$i){let s=!0;const n=e.sourceEdges;for(;n.next();)if(n.value.fromVertex.$i){s=!1;break}if(s)return e}}return null}tI(t){let i=null,e=0;const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;if(n.$i){let o=0;const r=n.destinationEdges;for(;r.next();)r.value.toVertex.$i&&o++;let l=0;const h=n.sourceEdges;for(;h.next();)h.value.fromVertex.$i&&l++;(i===null||ec&&this.Gy(h,e,-1,!0,!1)}for(this.Gy(t,s,-1,!0,!0);t.component!==e;){let r=0,l=1/0,h=0,a=null;const c=this.network.vertexes.iterator;for(;c.next();){const f=c.value;if(f.component===s){let u=0,d=!1;const m=f.po;o=m.length;for(let p=0;p0){for(i.reset();i.next();){const f=i.value;f.component===s&&(f.layer+=l)}t.component=e}else a.component=e}}nI(t){const i=this.network.vertexes.iterator;for(;i.next();){const n=i.value;n.component=-1}const e=0,s=1;for(this.Gy(t,s,-1,!0,!1);t.component!==e;){let n=0,o=1/0,r=0,l=null;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value;if(a.component===s){let c=0,f=!1;const u=a.po;let d=u.length;for(let g=0;gr)&&!f&&(l=a,r=c)}}if(n<0){for(i.reset();i.next();){const a=i.value;a.component===s&&(a.layer-=o)}t.component=e}else l.component=e}}HO(){const t=this.network,i=[],e=t.edges.iterator;for(;e.next();){const s=e.value;s.valid=!1,i.push(s)}for(let s=0;sb&&f>0){for(n.valid=!1,y=t.createVertex(),y.node=null,y.Q1=2,y.layer=f-1,x&&kb&&f>0;)y=t.createVertex(),y.node=null,y.Q1=3,y.layer=f-1,x&&kt[this.Ms]&&(this.Xy=t[e]-1,this.Ms=e),t[e]{o.index=this.ui[s],this.ui[s]++})}}hI(){let t=null;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;if(e.near&&(t===null&&(t=new Map),e.layer===e.near.layer)){const s=t.get(e.near)||[];s.push(e),t.set(e.near,s)}}for(let e=this.Mt;e>=0;e--)for(i.reset();i.next();){const s=i.value;s.layer===e&&s.index===-1&&this.oD(s,t)}}oD(t,i){if(t.near)return;const e=t.layer;if(t.index=this.ui[e],this.ui[e]++,i){const o=i.get(t);Array.isArray(o)&&o.forEach(r=>{r.index=this.ui[e],this.ui[e]++})}const s=t.ir;let n=!0;for(;n;){n=!1;for(let o=0;ol.portFromColOffset&&(n=!0,s[o]=l,s[o+1]=r)}}for(let o=0;o{a.index=this.ui[e],this.ui[e]++})}const s=t.po;let n=!0,o=0;for(;n;)for(n=!1,o=0;oa.portToColOffset&&(n=!0,s[o]=a,s[o+1]=h)}let r,l;for(o=0;o=0;s--)this.tk(s,-1),this.ls(s,-1,!1,-1);n=this.countCrossings(),n=0;s--)this.tk(s,0),this.ls(s,0,!1,0);n=this.countCrossings(),n=0;r--)for(l=0;l<=r;l++){for(o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,1,!1,1)||o;for(n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,-1,!1,-1)||o;for(n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,0,!1,0)||o;for(n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,0,!1,0)||o;n>=t?this.Ze(i):(t=n,i=this.Ji())}break;default:case 31:for(r=this.Mt,l=0,h=t+1;(a=this.countCrossings())=l;s--)o=this.ls(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,1,!1,1)||o;for(n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,-1,!1,-1)||o;for(n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,0,!1,0)||o;for(n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,0,!1,0)||o;n>=t?this.Ze(i):(t=n,i=this.Ji())}break}this.Ze(i)}tk(t,i){let e=0,s=!1;const n=this.Dh(t),o=this.ui[t],r=this.$T(t,i),l=this.Yy(t,i);for(e=0;e0)for(h=[],l=0;ll+1&&(m+=4*(v-l),g+=4*(v-(l+1)))}}const E=n[l].destinationEdges.iterator;if(e&&s>=0)for(;E.next();){const q=E.value;O=q.toVertex,q.valid&&O.layer!==t&&(N=this.linkStraightenWeight(q),T=q.portFromColOffset,A=q.portToColOffset,F=O.column,C+=(Math.abs(p+T-(F+A))+1)*N,S+=(Math.abs(L+T-(F+A))+1)*N)}for(E.reset();E.next();){const q=E.value;if(O=q.toVertex,q.valid&&O.layer===t){for(U=0;Ul+1&&(m+=4*(v-(l+1)),g+=4*(v-l))}}const B=n[l+1].destinationEdges.iterator;if(e&&s>=0)for(;B.next();){const q=B.value;O=q.toVertex,q.valid&&O.layer!==t&&(N=this.linkStraightenWeight(q),T=q.portFromColOffset,A=q.portToColOffset,F=O.column,C+=(Math.abs(y+T-(F+A))+1)*N,S+=(Math.abs(M+T-(F+A))+1)*N)}for(B.reset();B.next();){const q=B.value;if(O=q.toVertex,q.valid&&O.layer===t){for(U=0;U1e3&&s&&(e=!1),e){const n=[];let o=0;for(o=0;o<=this.Mt;o++)n[o]=0;let r=0;const l=this.network.vertexes.iterator;for(;l.next();){const a=l.value;t=a.layer,r=a.column;const c=this.nodeMinColumnSpace(a,!1);n[t]=Math.max(n[t],r+c)}const h=8;for(l.reset();l.next();){const a=l.value;t=a.layer,r=a.column,a.column=((this.Kt-n[t])*h>>1)+r*h}this.Kt*=h}if(this.nr&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Dg(t,-1)||i;i=this.Dg(this.Ms,0)||i,n++}}if(this.nr&4){for(t=this.Ms+1;t<=this.Mt;t++)this.VN(t,1);for(t=this.Ms-1;t>=0;t--)this.VN(t,-1);this.VN(this.Ms,0)}if(e&&(this.lD(-1),this.lD(1)),this.nr&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Dg(t,0)||i;n++}}}Dg(t,i){let e=!1;for(;this.fI(t,i);)e=!0;return e}fI(t,i){let e=0;const s=this.Dh(t),n=this.ui[t],o=this.Yy(t,-1);if(i>0)for(e=0;ec+this.nodeMinColumnSpace(s[e-1],!1)?u=a-1:u=a;let d=0;e+1>=n||s[e+1].column-a-1>f+this.nodeMinColumnSpace(s[e+1],!0)?d=a+1:d=a;let m=0,g=0,p=0,y=0,x=0,k=0;if(i<=0){const S=s[e].sourceEdges.iterator;for(;S.next();){const N=S.value,T=N.fromVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const A=T.column;m+=(Math.abs(a+k-(A+x))+1)*y,g+=(Math.abs(u+k-(A+x))+1)*y,p+=(Math.abs(d+k-(A+x))+1)*y}}}if(i>=0){const S=s[e].destinationEdges.iterator;for(;S.next();){const N=S.value,T=N.toVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const A=T.column;m+=(Math.abs(a+x-(A+k))+1)*y,g+=(Math.abs(u+x-(A+k))+1)*y,p+=(Math.abs(d+x-(A+k))+1)*y}}}let b=0,P=0,M=0;const L=o[s[e].index],C=r[s[e].index];L!==-1&&(b+=Math.abs(L-a),P+=Math.abs(L-u),M+=Math.abs(L-d)),C!==-1&&(b+=Math.abs(C-a),P+=Math.abs(C-u),M+=Math.abs(C-d)),g=r[e]?u=p:g<=r[e]&&(u=g)),u!==a&&(l=!0,h=!0,s[e].column=u)}return this.Fh(t,s),this.Ky(),l}uI(){for(let t=0;t<=this.Kt;t++)for(;this.dI(t,1););this.Ky()}dI(t,i){let e=!0;const s=this.network.vertexes.iterator;for(;s.next();){const o=s.value,r=this.nodeMinColumnSpace(o,!0),l=this.nodeMinColumnSpace(o,!1);if(o.column-r<=t&&o.column+l>=t){e=!1;break}}let n=!1;if(e){if(i>0)for(s.reset();s.next();){const o=s.value;o.column>t&&(o.column-=1,n=!0)}if(i<0)for(s.reset();s.next();){const o=s.value;o.column0&&(e=t+1),i<0&&(e=t-1);let s=0;const n=[],o=[];for(s=0;s<=this.Mt;s++)n[s]=!1,o[s]=!1;const r=this.network.vertexes.iterator;for(;r.next();){const a=r.value,c=a.column-this.nodeMinColumnSpace(a,!0),f=a.column+this.nodeMinColumnSpace(a,!1);c<=t&&f>=t&&(n[a.layer]=!0),c<=e&&f>=e&&(o[a.layer]=!0)}let l=!0,h=!1;for(s=0;s<=this.Mt;s++)l=l&&!(n[s]&&o[s]);if(l){if(i>0)for(r.reset();r.next();){const a=r.value;a.column>t&&(a.column-=1,h=!0)}if(i<0)for(r.reset();r.next();){const a=r.value;a.column0)for(i=0;i<=this.Kt;i++)for(e=this.Ji(),s=this.Z1(!0),n=s+1;ss?this.Ze(e):o=0;i--)for(e=this.Ji(),s=this.Z1(!0),n=s+1;ss?this.Ze(e):o0)for(e.reset();e.next();){const c=e.value;c.column-this.nodeMinColumnSpace(c,!0)<=t&&(c.component=this._s)}if(i<0)for(e.reset();e.next();){const c=e.value;c.column+this.nodeMinColumnSpace(c,!1)>=t&&(c.component=this._s)}for(this._s++,e.reset();e.next();){const c=e.value;c.component===-1&&(this.UN(c,this._s,-1,!0,!0),this._s++)}let s=0;const n=[];for(s=0;s0)for(let f=0;f0;f--)o[c*(this.Kt+1)+f]!==-1&&o[c*(this.Kt+1)+f-1]!==-1&&o[c*(this.Kt+1)+f]!==o[c*(this.Kt+1)+f-1]&&(n[o[c*(this.Kt+1)+f]*this._s+o[c*(this.Kt+1)+f-1]]=!0)}const r=[];for(s=0;s0)for(e.reset();e.next();){const c=e.value;r[c.component]&&(c.column-=1,a=!0)}if(i<0)for(e.reset();e.next();){const c=e.value;r[c.component]&&(c.column+=1,a=!0)}return a}cI(){const t=Util.ot(),i=this.Jf.length;for(let u=0;u<=i;u++)t[u]=[];const e=this.network.vertexes.iterator;for(;e.next();){const u=e.value,d=i-u.layer,m=t[d];m[u.index]=u}const s=new GSet;this.pI(t,s);let n=null,o=null,r=null,l=null;const h=(this.vn&1)!==0,a=(this.vn&2)!==0,c=(this.vn&4)!==0,f=(this.vn&8)!==0;h&&(this.sl(t,s,!0),n=this.ik(t,!0,!1)),t.reverse(),c&&(this.sl(t,s,!1),r=this.ik(t,!1,!1));for(const u of t)u.reverse();f&&(this.sl(t,s,!1),l=this.ik(t,!1,!0)),t.reverse(),a&&(this.sl(t,s,!0),o=this.ik(t,!0,!0)),Util.tt(t),this.yI(n,o,r,l),this.network.vertexes.each(u=>{const d=u,m=Util.ot();h&&m.push(n.get(d)),a&&m.push(o.get(d)),c&&m.push(r.get(d)),f&&m.push(l.get(d)),m.sort((k,b)=>k-b);const g=m.length,p=Math.floor((g-1)/2),y=Math.ceil((g-1)/2),x=(m[p]+m[y])/2;Util.tt(m),d.le=x})}pI(t,i){const e=t.length;for(let s=1;sf)&&i.add(m)}o++}n=f}}}}wI(t){if(t.node===null){const i=t.getProperSourceVertexes();if(i.length>0)return i[0].node===null}return!1}sl(t,i,e){this.xI(t);for(const s of t){let n=-1;for(const o of s){const r=e?o.getProperSourceVertexes():o.getProperDestinationVertexes(),l=r.length;if(l>0){r.sort((a,c)=>a.Rh-c.Rh);const h=(l-1)/2;for(let a=Math.floor(h),c=Math.ceil(h);a<=c;a++)if(o.On===o){const f=r[a];let u;e?u=f.getDestinationEdge(o):u=o.getDestinationEdge(f),!i.has(u)&&n0){const c=this.fD(a,t),f=s?c.width:c.height,u=a.Qe.Zf+a.le+a.In-(c.le+c.In+f+this.columnSpacing);c.Qe.Zf=Math.min(c.Qe.Zf,u)}h=a.Rh+1}while(l0){const s=this.fD(e,i),n=s.Za;this.cD(n,i),t.Qe===t&&(t.Qe=n.Qe);const o=this.S===90||this.S===270?s.width:s.height;if(t.Qe===n.Qe){const r=n.le+s.In+o-e.In+this.columnSpacing;t.le=Math.max(t.le,r)}}e=e.On}while(e!==t);for(;e.On!==t;)e=e.On,e.le=t.le,e.Qe=t.Qe}fD(t,i){const e=t.aD,s=t.Rh;return s<1&&Util.o("Could not determine previous vertex in layer"),i[e][s-1]}yI(...t){let i=-1;const e=Util.ot(),s=Util.ot();let n=1/0;for(let o=0;o<4;o++){if(!t[o])continue;const r=this.kI(t[o],e,s,o);r{r.set(h.key,h.value+l)})}Util.tt(e),Util.tt(s)}kI(t,i,e,s){if(!t||t.count===0)return i[s]=0,e[s]=0,1/0;let n=1/0,o=-1/0;return t.each(r=>{const l=r.key,h=r.value,a=this.S===90||this.S===270?l.width:l.height;ho&&(o=h+a)}),i[s]=n,e[s]=o,o-n}commitLayout(){this.zy(),this.commitNodes(),this.zN(),this.isRouting&&this.commitLinks()}zy(){if(!this.setsPortSpots)return;const t=this._1(!0),i=this._1(!1),e=this.network.edges.iterator;for(;e.next();){const n=e.value.link;n!==null&&(n.fromSpot=t,n.toSpot=i)}}_1(t){return this.S===270?t?Spot.MiddleTop:Spot.MiddleBottom:this.S===90?t?Spot.MiddleBottom:Spot.MiddleTop:this.S===180?t?Spot.MiddleLeft:Spot.MiddleRight:t?Spot.MiddleRight:Spot.MiddleLeft}commitNodes(){this.Qs=[],this.Ss=[],this.Ns=[],this.Bt=[];for(let d=0;d<=this.Mt;d++)this.Qs[d]=0,this.Ss[d]=0,this.Ns[d]=0,this.Bt[d]=0;const t=this.network.vertexes.iterator;for(;t.next();){const d=t.value,m=d.layer;this.Qs[m]=Math.max(this.Qs[m],this.nodeMinLayerSpace(d,!0)),this.Ss[m]=Math.max(this.Ss[m],this.nodeMinLayerSpace(d,!1))}let i=0;const e=this.Ps;for(let d=0;d<=this.Mt;d++){let m=e;this.Qs[d]+this.Ss[d]<=0&&(m=0),d>0&&(i+=m/2),this.S===90||this.S===0?(i+=this.Ss[d],this.Ns[d]=i,i+=this.Qs[d]):(i+=this.Qs[d],this.Ns[d]=i,i+=this.Ss[d]),d=0;n--)this.S===270?n===0?e.push(new Rect(0,0,s,Math.abs(this.Bt[0]))):e.push(new Rect(0,this.Bt[n-1],s,Math.abs(this.Bt[n-1]-this.Bt[n]))):this.S===90?n===0?e.push(new Rect(0,this.Bt[0],s,Math.abs(this.Bt[0]-t))):e.push(new Rect(0,this.Bt[n],s,Math.abs(this.Bt[n-1]-this.Bt[n]))):this.S===180?n===0?e.push(new Rect(0,0,Math.abs(this.Bt[0]),s)):e.push(new Rect(this.Bt[n-1],0,Math.abs(this.Bt[n-1]-this.Bt[n]),s)):n===0?e.push(new Rect(this.Bt[0],0,Math.abs(this.Bt[0]-t),s)):e.push(new Rect(this.Bt[n],0,Math.abs(this.Bt[n-1]-this.Bt[n]),s));this.commitLayers(e,this.or)}commitLayers(t,i){}commitLinks(){const t=this.network.edges.iterator;let i;for(;t.next();)i=t.value.link,i!==null&&(i.startRoute(),i.clearPoints(),i.commitRoute());for(t.reset();t.next();)i=t.value.link,i!==null&&i.updateRoute();for(t.reset();t.next();){const e=t.value;if(i=e.link,i===null||i.pointsCount===0)continue;i.startRoute();const s=i;let n=s.fromNode,o=s.toNode,r=s.fromPort,l=s.toPort;if(n!==null){const N=n.findVisibleNode();N!==null&&N!==n&&(n=N,r=N.port)}if(o!==null){const N=o.findVisibleNode();N!==null&&N!==o&&(o=N,l=N.port)}const h=i.computeSpot(!0,r),a=i.computeSpot(!1,l);let c=e.fromVertex,f=e.toVertex;if(e.valid){if(i.curve===9&&i.pointsCount===4)if(c.column===f.column&&this.alignOption===0){const N=i.getLinkPoint(n,r,h,!0,!1,o,l),T=i.getLinkPoint(o,l,a,!1,!1,n,r);N.isReal()||N.set(n.actualBounds.center),T.isReal()||T.set(o.actualBounds.center),i.clearPoints(),i.addPointAt(N.x,N.y),i.addPointAt((2*N.x+T.x)/3,(2*N.y+T.y)/3),i.addPointAt((N.x+2*T.x)/3,(N.y+2*T.y)/3),i.addPointAt(T.x,T.y)}else{let N=!1,T=!1;if(r!==null&&h===Spot.None&&(N=!0),l!==null&&a===Spot.None&&(T=!0),N||T){let A=null;N&&(A=i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0),A.isReal()||A.set(n.actualBounds.center),i.setPointAt(0,A.x,A.y));let D=null;if(T&&(D=i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(0),!1),D.isReal()||D.set(o.actualBounds.center),i.setPointAt(3,D.x,D.y)),A){const F=i.getPoint(2);i.setPointAt(1,(A.x*2+F.x)/3,(A.y*2+F.y)/3)}if(D){const F=i.getPoint(1);i.setPointAt(2,(D.x*2+F.x)/3,(D.y*2+F.y)/3)}}}i.commitRoute();continue}if(c.layer===f.layer){i.commitRoute();continue}let u=!1,d=!1;const m=this.Ps;let g=0,p=i.firstPickIndex+1;if(i.isOrthogonal)d=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3);else if(i.curve===9)u=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3),g===4&&(p=2);else{g=i.pointsCount;const N=h===Spot.None,T=a===Spot.None;g>2&&N&&T?i.points.removeRange(1,g-2):g>3&&N&&!T?i.points.removeRange(1,g-3):g>3&&!N&&T?i.points.removeRange(2,g-2):g>4&&!N&&!T&&i.points.removeRange(2,g-3)}let y,x,k=0,b=0,P=0,M=0,L=0,C=0,S=0;if(e.rev){let N=0;for(;f!==null&&c!==f;){y=null,x=null;const T=f.sourceEdges.iterator;for(;T.next();){const A=T.value;if(A.link===e.link&&(y=A.fromVertex,x=A.toVertex,y.node===null))break}if(y===null)break;if(y!==c)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=y.centerX,M=y.centerY,d)this.S===180||this.S===0?p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,k,M)):(x!==null?x.centerY:b)!==M&&(L=this.Bt[y.layer-1]+this.or.x,i.insertPointAt(p++,L,b),i.insertPointAt(p++,L,M)):p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,P,b)):(x!==null?x.centerX:k)!==P&&(L=this.Bt[y.layer-1]+this.or.y,i.insertPointAt(p++,k,L),i.insertPointAt(p++,P,L));else if(p===i.firstPickIndex+1)if(C=Math.max(10,this.Qs[f.layer]),S=Math.max(10,this.Ss[f.layer]),u)this.S===180?P<=f.bounds.x?(N=f.bounds.x,i.insertPointAt(p++,N-C,M),i.insertPointAt(p++,N,M),i.insertPointAt(p++,N+S,M)):(i.insertPointAt(p++,P-C,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P+S,M)):this.S===90?M>=f.bounds.bottom?(N=f.bounds.y+f.bounds.height,i.insertPointAt(p++,P,N+S),i.insertPointAt(p++,P,N),i.insertPointAt(p++,P,N-C)):(i.insertPointAt(p++,P,M+S),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M-C)):this.S===270?M<=f.bounds.y?(N=f.bounds.y,i.insertPointAt(p++,P,N-C),i.insertPointAt(p++,P,N),i.insertPointAt(p++,P,N+S)):(i.insertPointAt(p++,P,M-C),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M+S)):this.S===0&&(P>=f.bounds.right?(N=f.bounds.x+f.bounds.width,i.insertPointAt(p++,N+S,M),i.insertPointAt(p++,N,M),i.insertPointAt(p++,N-C,M)):(i.insertPointAt(p++,P+S,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P-C,M)));else{i.insertPointAt(p++,k,b);let A=0;this.S===180||this.S===0?((this.S===180?P>=f.bounds.right:P<=f.bounds.x)&&(A=(this.S===0?-C:S)/2),i.insertPointAt(p++,k+A,M)):((this.S===270?M>=f.bounds.bottom:M<=f.bounds.y)&&(A=(this.S===90?-C:S)/2),i.insertPointAt(p++,P,b+A)),i.insertPointAt(p++,P,M)}else C=Math.max(10,this.Qs[y.layer]),S=Math.max(10,this.Ss[y.layer]),u?this.S===180?(i.insertPointAt(p++,P-C-m,M),i.insertPointAt(p++,Math.min(P-C+m/2,P),M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,Math.max(P+S-m/2,P),M),i.insertPointAt(p++,P+S+m,M)):this.S===90?(i.insertPointAt(p++,P,M+S+m),i.insertPointAt(p++,P,Math.max(M+S-m/2,M)),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,Math.min(M-C+m/2,M)),i.insertPointAt(p++,P,M-C-m)):this.S===270?(i.insertPointAt(p++,P,M-C-m),i.insertPointAt(p++,P,Math.min(M-C+m/2,M)),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,Math.max(M+S-m/2,M)),i.insertPointAt(p++,P,M+S+m)):(i.insertPointAt(p++,P+S+m,M),i.insertPointAt(p++,Math.max(P+S-m/2,P),M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,Math.min(P-C+m/2,P),M),i.insertPointAt(p++,P-C-m,M)):(this.S===180||this.S===90||this.S,i.insertPointAt(p++,P,M));f=y}if(l===null||h!==Spot.None||d)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=i.getPoint(p).x,M=i.getPoint(p).y,d){const T=this.Ss[c.layer];let A=0;this.S===180||this.S===0?(A=b,A>=c.bounds.y&&A<=c.bounds.bottom&&(this.S===180?P>=c.bounds.x:P<=c.bounds.right)&&(N=c.centerX+(this.S===180?-T:T),A=c.bounds.x&&A<=c.bounds.right&&(this.S===270?M>=c.bounds.y:M<=c.bounds.bottom)&&(N=c.centerY+(this.S===270?-T:T),A=c.bounds.x?(N=c.bounds.x+c.bounds.width,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N+S,b)):this.S===90&&M<=c.bounds.bottom?(N=c.bounds.y,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N-C)):this.S===270&&M>=c.bounds.y?(N=c.bounds.y+c.bounds.height,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N+S)):this.S===0&&P<=c.bounds.right&&(N=c.bounds.x,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N-C,b));else{C=Math.max(10,this.Qs[c.layer]),S=Math.max(10,this.Ss[c.layer]);let T=0;this.S===180||this.S===0?((this.S===180?P<=c.bounds.x:P>=c.bounds.right)&&(T=(this.S===0?S:-C)/2),i.insertPointAt(p++,P+T,b)):((this.S===270?M<=c.bounds.y:M>=c.bounds.bottom)&&(T=(this.S===90?S:-C)/2),i.insertPointAt(p++,k,M+T)),i.insertPointAt(p++,P,M)}}else{for(;c!==null&&c!==f;){y=null,x=null;const N=c.destinationEdges.iterator;for(;N.next();){const T=N.value;if(T.link===e.link&&(y=T.toVertex,x=T.fromVertex,x.node!==null&&(x=null),y.node===null))break}if(y===null)break;y!==f&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=y.centerX,M=y.centerY,d?this.S===180||this.S===0?(x!==null?x.centerY:b)!==M&&(L=this.Bt[y.layer]+this.or.x,p===i.firstPickIndex+1&&(this.S===0?L=Math.max(L,k):L=Math.min(L,k)),i.insertPointAt(p++,L,b),i.insertPointAt(p++,L,M)):(x!==null?x.centerX:k)!==P&&(L=this.Bt[y.layer]+this.or.y,p===i.firstPickIndex+1&&(this.S===90?L=Math.max(L,b):L=Math.min(L,b)),i.insertPointAt(p++,k,L),i.insertPointAt(p++,P,L)):(C=Math.max(10,this.Qs[y.layer]),S=Math.max(10,this.Ss[y.layer]),u?this.S===180?(i.insertPointAt(p++,P+S+m,M),i.insertPointAt(p++,Math.max(P+S-m/2,P),M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,Math.min(P-C+m/2,P),M),i.insertPointAt(p++,P-C-m,M)):this.S===90?(i.insertPointAt(p++,P,M-C-m),i.insertPointAt(p++,P,Math.min(M-C+m/2,M)),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,Math.max(M+S-m/2,M)),i.insertPointAt(p++,P,M+S+m)):this.S===270?(i.insertPointAt(p++,P,M+S+m),i.insertPointAt(p++,P,Math.max(M+S-m/2,M)),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,Math.min(M-C+m/2,M)),i.insertPointAt(p++,P,M-C-m)):(i.insertPointAt(p++,P-C-m,M),i.insertPointAt(p++,Math.min(P-C+m/2,P),M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,Math.max(P+S-m/2,P),M),i.insertPointAt(p++,P+S+m,M)):this.S===180?(i.insertPointAt(p++,P+S,M),i.insertPointAt(p++,P-C,M)):this.S===90?(i.insertPointAt(p++,P,M-C),i.insertPointAt(p++,P,M+S)):this.S===270?(i.insertPointAt(p++,P,M+S),i.insertPointAt(p++,P,M-C)):(i.insertPointAt(p++,P-C,M),i.insertPointAt(p++,P+S,M)))),c=y}d&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=i.getPoint(p).x,M=i.getPoint(p).y,this.S===180||this.S===0?b!==M&&(this.S===0?L=Math.min(Math.max((P+k)/2,this.Bt[f.layer]+this.or.x),P):L=Math.max(Math.min((P+k)/2,this.Bt[f.layer]+this.or.x),P),i.insertPointAt(p++,L,b),i.insertPointAt(p++,L,M)):k!==P&&(this.S===90?L=Math.min(Math.max((M+b)/2,this.Bt[f.layer]+this.or.y),M):L=Math.max(Math.min((M+b)/2,this.Bt[f.layer]+this.or.y),M),i.insertPointAt(p++,k,L),i.insertPointAt(p++,P,L)))}if(s!==null&&u&&i.pointsCount>=4){if(r!==null){const N=h===Spot.None?i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0):i.getPoint(0);if(h===Spot.None){const T=i.getPoint(2),A=i.getPoint(3);this.direction===90||this.direction===270?(i.setPointAt(1,(N.x+T.x)/2,T.y),i.setPointAt(2,A.x,(T.y+A.y)/2)):(i.setPointAt(1,T.x,(N.y+T.y)/2),i.setPointAt(2,(T.x+A.x)/2,A.y))}N.isReal()||N.set(n.actualBounds.center),i.setPointAt(0,N.x,N.y)}if(l!==null){const N=a===Spot.None?i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(i.pointsCount-4),!1):i.getPoint(i.pointsCount-1);if(a===Spot.None){const T=i.getPoint(i.pointsCount-3),A=i.getPoint(i.pointsCount-4);this.direction===90||this.direction===270?(i.setPointAt(i.pointsCount-2,(N.x+T.x)/2,T.y),i.setPointAt(i.pointsCount-2,A.x,(T.y+A.y)/2)):(i.setPointAt(i.pointsCount-2,T.x,(N.y+T.y)/2),i.setPointAt(i.pointsCount-3,(T.x+A.x)/2,A.y))}N.isReal()||N.set(o.actualBounds.center),i.setPointAt(i.pointsCount-1,N.x,N.y)}}i.commitRoute(),e.commit()}}GO(){this.Xy=-1,this.Lg=0,this.Ms=0,this.$a=null,this.Tg=null,this.Jf=null;for(let t=0;t=this.Rn.length){const n=[];for(let o=0;o=0&&(this.Ps=t,this.invalidateLayout()))}get columnSpacing(){return this.Wi}set columnSpacing(t){this.Wi!==t&&(Util.i(t,"number",LayeredDigraphLayout,"columnSpacing"),t>0&&(this.Wi=t,this.invalidateLayout()))}get direction(){return this.S}set direction(t){this.S!==t&&(Util.i(t,"number",LayeredDigraphLayout,"direction"),t===0||t===90||t===180||t===270?(this.S=t,this.invalidateLayout()):Util.o("LayeredDigraphLayout.direction must be 0, 90, 180, or 270"))}get cycleRemoveOption(){return this.Gf}set cycleRemoveOption(t){this.Gf!==t&&(t===1||t===0||t===2)&&(this.Gf=t,this.invalidateLayout())}get layeringOption(){return this.jf}set layeringOption(t){this.jf!==t&&(t===10||t===11||t===12)&&(this.jf=t,this.invalidateLayout())}get initializeOption(){return this.Hf}set initializeOption(t){this.Hf!==t&&(t===20||t===21||t===22)&&(this.Hf=t,this.invalidateLayout())}get iterations(){return this.Ja}set iterations(t){this.Ja!==t&&t>=0&&(this.Ja=t,this.invalidateLayout())}get aggressiveOption(){return this.qf}set aggressiveOption(t){this.qf!==t&&(t===30||t===31||t===32)&&(this.qf=t,this.invalidateLayout())}get packOption(){return this.nr}set packOption(t){this.nr!==t&&(Util.i(t,"number",LayeredDigraphLayout,"packOption"),t>=0&&t<8&&(this.nr=t,this.invalidateLayout()))}get packIterations(){return this.Wf}set packIterations(t){this.Wf=t}get alignOption(){return this.vn}set alignOption(t){this.vn!==t&&(Util.i(t,"number",LayeredDigraphLayout,"align"),t>=0&&t<16&&(this.vn=t,this.invalidateLayout()))}get setsPortSpots(){return this.Fn}set setsPortSpots(t){this.Fn!==t&&(Util.i(t,"boolean",LayeredDigraphLayout,"setsPortSpots"),this.Fn=t,this.invalidateLayout())}get maxLayer(){return this.Mt}get maxIndex(){return this.Xy}get maxColumn(){return this.Kt}get minIndexLayer(){return this.Lg}get maxIndexLayer(){return this.Ms}static CycleDepthFirst=0;static CycleGreedy=1;static CycleFromLayers=2;static LayerOptimalLinkLength=10;static LayerLongestPathSink=11;static LayerLongestPathSource=12;static InitDepthFirstOut=20;static InitDepthFirstIn=21;static InitNaive=22;static AggressiveNone=30;static AggressiveLess=31;static AggressiveMore=32;static PackNone=0;static PackExpand=1;static PackStraighten=2;static PackMedian=4;static PackAll=15;static AlignNone=0;static AlignUpperLeft=1;static AlignUpperRight=2;static AlignLowerLeft=4;static AlignLowerRight=8;static AlignAll=15}class LayeredDigraphNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new LayeredDigraphVertex(this)}createEdge(){return new LayeredDigraphEdge(this)}}class LayeredDigraphVertex extends LayoutVertex{Wo;Bo;Dt;ek;sk;$i;$f;jn;Q1;J1;$1;Za;On;aD;Rh;Qe;Zf;le;In;jy=null;Hy=null;qy=null;Wy=null;constructor(t){super(t),this.Wo=-1,this.Bo=-1,this.Dt=-1,this.ek=NaN,this.sk=null,this.$i=!1,this.$f=NaN,this.jn=NaN,this.Q1=0,this.J1=null,this.$1=null}static uD(t,i){return t.index-i.index}getProperSourceEdges(){if(!this.qy){const t=[];for(const i of this.po){const e=i;e.valid&&t.push(e)}this.qy=t}return this.qy}getProperDestinationEdges(){if(!this.Wy){const t=[];for(const i of this.ir){const e=i;e.valid&&t.push(e)}this.Wy=t}return this.Wy}getDestinationEdge(t){const i=this.getProperDestinationEdges();for(const e of i)if(e.toVertex===t)return e;Util.o("Unable to find destination edge to given vertex")}getProperSourceVertexes(){if(!this.jy){const t=[];for(const i of this.po){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.fromVertex)}t.sort(LayeredDigraphVertex.uD),this.jy=t}return this.jy}getProperDestinationVertexes(){if(!this.Hy){const t=[];for(const i of this.ir){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.toVertex)}t.sort(LayeredDigraphVertex.uD),this.Hy=t}return this.Hy}addSourceEdge(t){super.addSourceEdge(t),this.jy=null,this.qy=null}deleteSourceEdge(t){super.deleteSourceEdge(t),this.jy=null,this.qy=null}addDestinationEdge(t){super.addDestinationEdge(t),this.Hy=null,this.Wy=null}deleteDestinationEdge(t){super.deleteDestinationEdge(t),this.Hy=null,this.Wy=null}get layer(){return this.Wo}set layer(t){this.Wo!==t&&(Util.i(t,"number",LayeredDigraphVertex,"layer"),this.Wo=t)}get column(){return this.Bo}set column(t){this.Bo!==t&&(Util.i(t,"number",LayeredDigraphVertex,"column"),this.Bo=t)}get index(){return this.Dt}set index(t){this.Dt!==t&&(Util.i(t,"number",LayeredDigraphVertex,"index"),this.Dt=t)}get component(){return this.ek}set component(t){this.ek!==t&&(Util.i(t,"number",LayeredDigraphVertex,"component"),this.ek=t)}get near(){return this.sk}set near(t){this.sk!==t&&(this.sk=t)}}class LayeredDigraphEdge extends LayoutEdge{$i;nk;ok;rk;lk;hk;ak;constructor(t){super(t),this.$i=!1,this.nk=!1,this.ok=!1,this.rk=NaN,this.lk=NaN,this.hk=0,this.ak=0}get fromVertex(){return this.We}set fromVertex(t){this.We!==t&&(this.We=t)}get toVertex(){return this.Je}set toVertex(t){this.Je!==t&&(this.Je=t)}get valid(){return this.$i}set valid(t){this.$i!==t&&(Util.i(t,"boolean",LayeredDigraphEdge,"valid"),this.$i=t)}get rev(){return this.nk}set rev(t){this.nk!==t&&(Util.i(t,"boolean",LayeredDigraphEdge,"rev"),this.nk=t)}get forest(){return this.ok}set forest(t){this.ok!==t&&(Util.i(t,"boolean",LayeredDigraphEdge,"forest"),this.ok=t)}get portFromPos(){return this.rk}set portFromPos(t){this.rk!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portFromPos"),this.rk=t)}get portToPos(){return this.lk}set portToPos(t){this.lk!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portToPos"),this.lk=t)}get portFromColOffset(){return this.hk}set portFromColOffset(t){this.hk!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portFromColOffset"),this.hk=t)}get portToColOffset(){return this.ak}set portToColOffset(t){this.ak!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portToColOffset"),this.ak=t)}}var TreePath=(w=>(w[w.Default=0]="Default",w[w.Destination=1]="Destination",w[w.Source=2]="Source",w))(TreePath||{}),TreeSorting=(w=>(w[w.Forwards=10]="Forwards",w[w.Reverse=11]="Reverse",w[w.Ascending=12]="Ascending",w[w.Descending=13]="Descending",w))(TreeSorting||{}),TreeAlignment=(w=>(w[w.CenterSubtrees=20]="CenterSubtrees",w[w.CenterChildren=21]="CenterChildren",w[w.Start=22]="Start",w[w.End=23]="End",w[w.Bus=24]="Bus",w[w.BusBranching=25]="BusBranching",w[w.TopLeftBus=26]="TopLeftBus",w[w.BottomRightBus=27]="BottomRightBus",w[w.Custom=28]="Custom",w))(TreeAlignment||{}),TreeCompaction=(w=>(w[w.None=30]="None",w[w.Block=31]="Block",w))(TreeCompaction||{}),TreeStyle=(w=>(w[w.Layered=40]="Layered",w[w.LastParents=41]="LastParents",w[w.Alternating=42]="Alternating",w[w.RootOnly=43]="RootOnly",w))(TreeStyle||{}),TreeArrangement=(w=>(w[w.Vertical=50]="Vertical",w[w.Horizontal=51]="Horizontal",w[w.FixedRoots=52]="FixedRoots",w))(TreeArrangement||{}),TreeLayerStyle=(w=>(w[w.Individual=60]="Individual",w[w.Siblings=61]="Siblings",w[w.Uniform=62]="Uniform",w))(TreeLayerStyle||{});class TreeLayout extends Layout{Fi;Ti;Qf;Fg;XN;Re;zi;ks;V;z;ck;hs;constructor(t){super(),this.Fi=new GSet,this.Ti=0,this.hs=1,this.Qf=40,this.Fg=60,this.XN=[],this.Re=!0,this.zi=50,this.ks=new Size(10,10).g();const i=new TreeNetwork(this);this.V=new TreeVertex(i),this.z=new TreeVertex(i),this.ck=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Ti=this.Ti,t.Qf=this.Qf,t.Fg=this.Fg,t.Re=this.Re,t.zi=this.zi,t.ks.a(this.ks),t.V.copyInheritedPropertiesFrom(this.V),t.z.copyInheritedPropertiesFrom(this.z)}ri(t){t in TreeAlignment?this.alignment=t:t in TreeArrangement?this.arrangement=t:t in TreeCompaction?this.compaction=t:t in TreePath?this.path=t:t in TreeSorting?this.sorting=t:t in TreeStyle?this.treeStyle=t:super.ri(t)}createNetwork(){return new TreeNetwork(this)}makeNetwork(t){const i=this.createNetwork(),e=s=>{if(s instanceof Node)return!s.isLinkLabel&&s.category!=="Comment";if(s instanceof Link){const n=s.fromNode;if(n===null||n.isLinkLabel||n.category==="Comment")return!1;const o=s.toNode;return!(o===null||o.isLinkLabel||o.category==="Comment")}return!1};return t instanceof Diagram?(i.addParts(t.nodes,!0,e),i.addParts(t.links,!0,e)):t instanceof Group?i.addParts(t.memberParts,!1,e):i.addParts(t.iterator,!1,e),i}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangement!==52&&(this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin));let i=this.diagram;i===null&&t instanceof Diagram&&(i=t),this.path===0&&i!==null?this.hs=i.isTreePathToChildren?1:2:this.hs=this.path===0?1:this.path,this.network.vertexes.count>0&&(this.LI(),this.AI(),this.TI(),this.DI(),this.ON(),this.FI(),this.arrangeTrees(),this.updateParts()),this.network=null,this.Fi=new GSet,this.isValidLayout=!0}LI(){this.network.deleteSelfEdges();const t=this.network.vertexes.iterator;for(;t.next();){const n=t.value;n.initialized=!1,n.level=0,n.parent=null,n.children=[]}if(this.Fi.count>0){const n=new GSet,o=this.Fi.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=this.network.findVertex(r);l!==null&&n.add(l)}else r instanceof TreeVertex&&n.add(r)}this.Fi=n}this.Fi.count===0&&this.findRoots();const i=this.Fi.copy().iterator;for(;i.next();){const n=i.value;n.initialized||(n.initialized=!0,this.KN(n))}let e=this.network.vertexes,s=null;for(;s=this.RI(e),s.count>0;){const n=this.dD(s);n!==null&&this.Fi.add(n),n.initialized=!0,this.KN(n),e=s}}RI(t){const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;s.initialized||i.add(s)}return i}findRoots(){const t=this.network.vertexes,i=t.iterator;for(;i.next();){const e=i.value;switch(this.hs){case 1:e.sourceEdges.count===0&&this.Fi.add(e);break;case 2:e.destinationEdges.count===0&&this.Fi.add(e);break;default:Util.o("Unhandled path value "+this.hs.toString())}}if(this.Fi.count===0){const e=this.dD(t);e!==null&&this.Fi.add(e)}}dD(t){let i=999999,e=null;const s=t.iterator;for(;s.next();){const n=s.value;switch(this.hs){case 1:n.sourceEdges.count0){const s=new List,n=t.destinationVertexes;for(;n.next();){const o=n.value;this.gD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;case 2:if(t.sourceEdges.count>0){const s=new List,n=t.sourceVertexes;for(;n.next();){const o=n.value;this.gD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;default:Util.o("Unhandled path value"+this.hs.toString())}const i=t.children,e=i.length;for(let s=0;st.level?!1:(this.OI(i.parent,i),!0):!0}vI(t,i){if(i===null)return!1;let e=i.parent;for(;e!==null&&e!==t;)e=e.parent;return e===t}OI(t,i){if(t===null||i===null)return;const e=t.children;let s=0;for(let n=0;n0){const n=new Array(e.length-s);let o=0;for(let r=0;r0?s+1:0}II(t){switch(this.Qf){default:case 40:return t.parent!==null?t.parent:this.V;case 43:return t.parent===null?this.V:t.parent.parent===null?this.z:t.parent;case 42:return t.parent!==null?t.parent.parent!==null?t.parent.parent:this.z:this.V;case 41:{let i=!0;if(t.childrenCount===0)i=!1;else{const e=t.children,s=e.length;for(let n=0;n0){i=!1;break}}return i&&t.parent!==null?this.z:t.parent!==null?t.parent:this.V}}}initializeTreeVertexValues(t){const i=this.II(t);if(t.copyInheritedPropertiesFrom(i),t.parent!==null&&t.parent.alignment===25){let e=t.angle;const s=t.parent.children;let n=0;for(;n135&&!l||a&&f)if(t.commentMargin>=0){g.e(t.bounds.x-t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleLeft,P.toSpot=Spot.MiddleRight}}else{g.e(t.bounds.x+t.focus.x*2-t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleRight,P.toSpot=Spot.MiddleLeft}}else if(t.commentMargin>=0){g.e(t.bounds.x+t.focus.x*2+t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleRight,P.toSpot=Spot.MiddleLeft}}else{g.e(t.bounds.x+t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleLeft,P.toSpot=Spot.MiddleRight}}t.commentSpacing>=0?u+=k.height+t.commentSpacing:u+=t.commentSpacing-k.height}else{if(o>135&&!l||!a&&f)if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y-t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleTop,P.toSpot=Spot.MiddleBottom}}else{g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2-t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleBottom,P.toSpot=Spot.MiddleTop}}else if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2+t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleBottom,P.toSpot=Spot.MiddleTop}}else{g.e(t.bounds.x+u,t.bounds.y+t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleTop,P.toSpot=Spot.MiddleBottom}}t.commentSpacing>=0?u+=k.width+t.commentSpacing:u+=t.commentSpacing-k.width}}Point.s(g);const p=u-t.commentSpacing-(h?e.height:e.width);if(this.hs===1){const y=t.destinationEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.fromEndSegmentLength=p>0?p:NaN)}}else{const y=t.sourceEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.toEndSegmentLength=p>0?p:NaN)}}}}FI(){if(this.layerStyle===62){const i=[];let e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;let n=s.parent;n===null&&(n=s);const o=n.angle===0||n.angle===180;let r=i[s.level];r===void 0&&(r=0),i[s.level]=Math.max(r,o?s.width:s.height)}for(let s=0;s=0)for(let o=0;o135&&n.reverse(),this.Jy(r))if(o>1)for(let R=0;R0&&S>0&&M+u+O.width>c&&(M135?-b-g:b+g);const U=S===0?m:u;this.fk(v,0,L),v.U.e(M+U,L),k=Math.max(k,M+U+O.width),b=Math.max(b,P+(C===0?0:g)+O.height),M+=U+O.width}else{c>0&&S>0&&L+u+O.height>c&&(L135?-k-g:k+g);const U=S===0?m:u;this.fk(v,M,0),v.U.e(M,L+U),b=Math.max(b,L+U+O.height),k=Math.max(k,P+(C===0?0:g)+O.width),L+=U+O.height}S++}C>0&&(e?(b+=Math.max(0,f),M0&&(h||this.iu(t,p,0,0,o-1),k+=p)):(k+=Math.max(0,f),L0&&(h||this.iu(t,0,p,0,o-1),b+=p)));let D=0,F=0;switch(r){case 20:e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;break;default:case 21:if(C>0)e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;else{const v=o;if(e){const O=n[0].U.x+n[0].et.x,U=n[v-1].U.x+n[v-1].et.x+n[v-1].focus.x*2;D+=O+(U-O)/2-t.focus.x-d/2}else{const O=n[0].U.y+n[0].et.y,U=n[v-1].U.y+n[v-1].et.y+n[v-1].focus.y*2;F+=O+(U-O)/2-t.focus.y-d/2}}break;case 22:e?(D-=d,k+=d):(F-=d,b+=d);break;case 23:e?(D+=k-t.width+d,k+=d):(F+=b-t.height+d,b+=d);break;case 24:case 25:e?o>1?D+=T+u/2-t.focus.x:D+=n[0].focus.x-t.focus.x+n[0].et.x:o>1?F+=T+u/2-t.focus.y:F+=n[0].focus.y-t.focus.y+n[0].et.y;break;case 26:e?D+=k+u/2-t.focus.x:F+=b+u/2-t.focus.y;break;case 27:break;case 28:const R=this.customAlignment(t,D,F,k,b);D=R[0],F=R[1],k=R[2],b=R[3];break}for(let R=0;R135?(a?-b:-v.mt.height)+v.et.y-f:x+f+v.et.y)):v.U.e(v.U.x+(i>135?(a?-k:-v.mt.width)+v.et.x-f:y+f+v.et.x),v.U.y+v.et.y-F)}e?(k=this.GN(t,k,D),D<0&&(D=0),i>135&&(F+=b+f),b=Math.max(Math.max(b,x),b+x+f)):(i>135&&(D+=k+f),k=Math.max(Math.max(k,y),k+y+f),b=this.jN(t,b,F),F<0&&(F=0)),t.et.e(D,F),t.mt.e(k,b)}customAlignment(t,i,e,s,n){return[i,e,s,n]}xD(t,i,e,s,n,o){const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.mt.width,o=p.mt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,c=this.orthoAngle(t)===90;let f=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.mt,k=f===0?0:h;if(c){const b=this.computeBusNodeSpacing(y)-l;y.U.e(e-(x.width+b),d+k),n=Math.max(n,x.width+b),o=Math.max(o,d+k+x.height),d+=k+x.height}else{const b=this.computeBusNodeSpacing(y)-l;y.U.e(u+k,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,u+k+x.width),u+=k+x.width}f++}f=0;const m=u,g=d;c?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.mt,x=this.computeBusLastRowSpacing(p,c?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(c){p.U.e(e+l/2-p.focus.x-p.et.x,o+x);const k=e+l/2-p.focus.x-p.et.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.max(g,d)+x+y.height),p.U.x<0&&(e=this.uk(t,p.U.x,!1,e,l))}else{p.U.e(n+x,e+l/2-p.focus.y-p.et.y),n=Math.max(n,Math.max(m,u)+x+y.width);const k=e+l/2-p.focus.y-p.et.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.U.y<0&&(e=this.uk(t,p.U.y,!0,e,l))}}return new Rect(e,0,n,o)}bD(t,i,e,s,n,o){const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.mt.width,o=p.mt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,c=this.orthoAngle(t)===270;let f=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.mt,k=f===0?0:h;if(c){const b=this.computeBusNodeSpacing(y)-l;d-=k+x.height,y.U.e(e-(x.width+b),d),n=Math.max(n,x.width+b),o=Math.max(o,Math.abs(d))}else{const b=this.computeBusNodeSpacing(y)-l;u-=k+x.width,y.U.e(u,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,Math.abs(u))}f++}f=0;const m=u,g=d;c?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.mt,x=this.computeBusLastRowSpacing(p,c?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(c){p.U.e(e+l/2-p.focus.x-p.et.x,-o-y.height-x);const k=e+l/2-p.focus.x-p.et.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.abs(Math.min(g,d))+x+y.height),p.U.x<0&&(e=this.uk(t,p.U.x,!1,e,l))}else{p.U.e(-n-y.width-x,e+l/2-p.focus.y-p.et.y),n=Math.max(n,Math.abs(Math.min(m,u))+x+y.width);const k=e+l/2-p.focus.y-p.et.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.U.y<0&&(e=this.uk(t,p.U.y,!0,e,l))}}for(let p=0;ps&&(s=e+t.width),e<0&&(s-=e),s;case 22:return t.width>i?t.width:i;case 23:return t.focus.x*2>i?t.width:i+t.width-t.focus.x*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.width);return Math.max(t.width,o-n);case 26:return t.width-t.focus.x+t.nodeSpacing/2+i;case 27:return Math.max(t.width,t.focus.x+t.nodeSpacing/2+i);default:return i}}jN(t,i,e){switch(t.alignment){case 21:case 20:let s=i;return e+t.height>s&&(s=e+t.height),e<0&&(s-=e),s;case 22:return t.height>i?t.height:i;case 23:return t.focus.y*2>i?t.height:i+t.height-t.focus.y*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.height);return Math.max(t.height,o-n);case 26:return t.height-t.focus.y+t.nodeSpacing/2+i;case 27:return Math.max(t.height,t.focus.y+t.nodeSpacing/2+i);default:return i}}HN(t,i,e){switch(t){case 20:i/=2,e/=2;break;case 21:i/=2,e/=2;break;case 22:i=0,e=0;break;case 23:break;default:Util.o("Unhandled alignment value "+t.toString())}return new Point(i,e)}Qa(t,i,e,s,n,o){const r=this.HN(i,e,s);this.iu(t,r.x,r.y,n,o)}iu(t,i,e,s,n){if(i===0&&e===0)return;const o=t.children;for(let r=s;r<=n;r++){const h=o[r].U;h.x+=i,h.y+=e}}fk(t,i,e){const s=t.parent;switch(this.hs){case 1:{const n=t.sourceEdges;for(;n.next();){const o=n.value;o.fromVertex===s&&o.relativePoint.e(i,e)}break}case 2:{const n=t.destinationEdges;for(;n.next();){const o=n.value;o.toVertex===s&&o.relativePoint.e(i,e)}break}default:Util.o("Unhandled path value "+this.hs.toString())}}EI(t){if(t.childrenCount===0){const B=t.parent;let Y=!1,G=0,H=21;B!==null&&(G=B.angle,H=B.alignment,Y=this.isBusAlignment(H));const J=this.YN(t);t.U.e(0,0),t.mt.e(t.width,t.height),t.parent!==null&&t.comments!==null&&((G===180||G===270)&&!Y||J)?G===180&&!Y||(G===90||G===270)&&J?t.et.e(t.width-t.focus.x*2,0):t.et.e(0,t.height-t.focus.y*2):t.et.e(0,0),t.Rg=null,t.vg=null;return}const i=this.orthoAngle(t),e=i===90||i===270;let s=0;const n=t.children,o=n.length;for(let B=0;B135&&n.reverse(),this.Jy(r))if(o>1)for(let B=0;B0&&A>0&&S+u+G.width>c&&(S135?-k-m:k+m),this.fk(Y,0,N);let H=0;if(A===0)P=Y.Rg,M=Y.vg,L=G.width,C=G.height,(P===null||M===null||i!==this.orthoAngle(Y))&&(P=this.he(2),M=this.he(2),P[0].e(0,0),P[1].e(0,C),M[0].e(L,0),M[1].e(L,C));else{const J=Util.ot(),z=this.kD(t,Y,P,M,L,C,J);H=z.x,P=J[0],M=J[1],L=z.width,C=z.height,Util.tt(J),S0&&A>0&&N+u+G.height>c&&(N135?-x-m:x+m),this.fk(Y,S,0);let H=0;if(A===0)P=Y.Rg,M=Y.vg,L=G.width,C=G.height,(P===null||M===null||i!==this.orthoAngle(Y))&&(P=this.he(2),M=this.he(2),P[0].e(0,0),P[1].e(L,0),M[0].e(0,C),M[1].e(L,C));else{const J=Util.ot(),z=this.kD(t,Y,P,M,L,C,J);H=z.x,P=J[0],M=J[1],L=z.width,C=z.height,Util.tt(J),N0&&(e?(k+=Math.max(0,f),S0&&(h||this.iu(t,g,0,0,o-1),x+=g)):(x+=Math.max(0,f),N0&&(h||this.iu(t,0,g,0,o-1),k+=g)));let v=0,O=0;switch(r){case 20:e?v+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;break;default:case 21:if(T>0)e?v+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;else{const Y=o;if(e){const G=n[0].U.x+n[0].et.x,H=n[Y-1].U.x+n[Y-1].et.x+n[Y-1].focus.x*2;v+=G+(H-G)/2-t.focus.x-d/2}else{const G=n[0].U.y+n[0].et.y,H=n[Y-1].U.y+n[Y-1].et.y+n[Y-1].focus.y*2;O+=G+(H-G)/2-t.focus.y-d/2}}break;case 22:e?(v-=d,x+=d):(O-=d,k+=d);break;case 23:e?(v+=x-t.width+d,x+=d):(O+=k-t.height+d,k+=d);break;case 24:e?o>1?v+=F+u/2-t.focus.x:v+=n[0].focus.x-t.focus.x+n[0].et.x:o>1?O+=F+u/2-t.focus.y:O+=n[0].focus.y-t.focus.y+n[0].et.y;break;case 26:e?v+=x+u/2-t.focus.x:O+=k+u/2-t.focus.y;break;case 27:break;case 28:const B=this.customAlignment(t,v,O,x,k);v=B[0],O=B[1],x=B[2],k=B[3];break}for(let B=0;B135?(a?-k:-Y.mt.height)+Y.et.y-f:y+f+Y.et.y)):Y.U.e(Y.U.x+(i>135?(a?-x:-Y.mt.width)+Y.et.x-f:p+f+Y.et.x),Y.U.y+Y.et.y-O)}let U=0,X=0;if(a)e?(x=this.GN(t,x,v),v<0&&(v=0),i>135&&(O+=k+f),k+=y+f,r===27&&(U+=u/2+t.focus.x),X+=y+f):(i>135&&(v+=x+f),x+=p+f,k=this.jN(t,k,O),O<0&&(O=0),r===27&&(X+=u/2+t.focus.y),U+=p+f);else if(e){if(t.comments===null){if(p>x){const B=this.HN(r,p-x,0);U=B.x,X=B.y,x=p,v=0}}else x=this.GN(t,x,v);v<0&&(U-=v,v=0),i>135&&(O+=k+f),k=Math.max(Math.max(k,y),k+y+f),X+=y+f}else{if(i>135&&(v+=x+f),x=Math.max(Math.max(x,p),x+p+f),t.comments===null){if(y>k){const B=this.HN(r,0,y-k);U=B.x,X=B.y,k=y,O=0}}else k=this.jN(t,k,O);O<0&&(X-=O,O=0),U+=p+f}let E,V;if(T>0)E=this.he(4),V=this.he(4),e?(E[2].e(0,y+f),E[3].e(E[2].x,k),V[2].e(x,E[2].y),V[3].e(V[2].x,E[3].y)):(E[2].e(p+f,0),E[3].e(x,E[2].y),V[2].e(E[2].x,k),V[3].e(E[3].x,V[2].y));else{E=this.he(P.length+2),V=this.he(M.length+2);for(let B=0;BE[0].x?E[2].a(E[1]):E[1].a(E[2])),E[3].yE[0].x?E[3].a(E[2]):E[2].a(E[3])),V[0].e(v+p,0),V[1].e(V[0].x,y),V[2].yE[0].y?E[2].a(E[1]):E[1].a(E[2])),E[3].xE[0].y?E[3].a(E[2]):E[2].a(E[3])),V[0].e(0,O+y),V[1].e(p,V[0].y),V[2].xl;){const a=i[o++];s[r++].e(a.x,a.y+e)}const h=this.he(r);for(n=0;nl;){const a=i[o++];s[r++].e(a.x+e,a.y)}const h=this.he(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.he(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.he(r);for(n=0;nh&&r.xr.x&&ha&&r.yr.y&&a0){const n=Math.min(1,t.layerSpacingParentOverlap);s-=e?t.height*n:t.width*n}return s<(e?-t.height:-t.width)&&(s=e?-t.height:-t.width),s}computeNodeIndent(t){const i=this.orthoAngle(t),e=i===90||i===270;let s=t.nodeIndent;if(t.nodeIndentPastParent>0){const n=Math.min(1,t.nodeIndentPastParent);s+=e?t.width*n:t.height*n}return s=Math.max(0,s),s}get roots(){return this.Fi}set roots(t){this.Fi!==t&&(this.Fi=t,this.invalidateLayout())}get path(){return this.Ti}set path(t){this.Ti!==t&&(this.Ti=t,this.invalidateLayout())}get treeStyle(){return this.Qf}set treeStyle(t){this.Qf!==t&&(t===40||t===42||t===41||t===43)&&(this.Qf=t,this.invalidateLayout())}get layerStyle(){return this.Fg}set layerStyle(t){this.Fg!==t&&(t===60||t===61||t===62)&&(this.Fg=t,this.invalidateLayout())}get comments(){return this.Re}set comments(t){this.Re!==t&&(Util.i(t,"boolean",TreeLayout,"comments"),this.Re=t,this.invalidateLayout())}get arrangement(){return this.zi}set arrangement(t){this.zi!==t&&(t===50||t===51||t===52)&&(this.zi=t,this.invalidateLayout())}get arrangementSpacing(){return this.ks}set arrangementSpacing(t){this.ks.equals(t)||(this.ks.a(t),this.invalidateLayout())}get rootDefaults(){return this.V}set rootDefaults(t){this.V!==t&&(this.V=t,this.invalidateLayout())}get alternateDefaults(){return this.z}set alternateDefaults(t){this.z!==t&&(this.z=t,this.invalidateLayout())}get sorting(){return this.V.sorting}set sorting(t){this.V.sorting!==t&&(this.V.sorting=t,this.invalidateLayout())}get comparer(){return this.V.comparer}set comparer(t){this.V.comparer!==t&&(Util.i(t,"function",TreeLayout,"comparer"),this.V.comparer=t,this.invalidateLayout())}get angle(){return this.V.angle}set angle(t){this.V.angle!==t&&(Util.i(t,"number",TreeLayout,"angle"),t===0||t===90||t===180||t===270?(this.V.angle=t,this.invalidateLayout()):Util.o("TreeLayout.angle must be 0, 90, 180, or 270"))}get alignment(){return this.V.alignment}set alignment(t){this.V.alignment!==t&&(this.V.alignment=t,this.invalidateLayout())}get nodeIndent(){return this.V.nodeIndent}set nodeIndent(t){this.V.nodeIndent!==t&&(Util.i(t,"number",TreeLayout,"nodeIndent"),t>=0&&(this.V.nodeIndent=t,this.invalidateLayout()))}get nodeIndentPastParent(){return this.V.nodeIndentPastParent}set nodeIndentPastParent(t){this.V.nodeIndentPastParent!==t&&(Util.i(t,"number",TreeLayout,"nodeIndentPastParent"),t>=0&&t<=1&&(this.V.nodeIndentPastParent=t,this.invalidateLayout()))}get nodeSpacing(){return this.V.nodeSpacing}set nodeSpacing(t){this.V.nodeSpacing!==t&&(Util.i(t,"number",TreeLayout,"nodeSpacing"),this.V.nodeSpacing=t,this.invalidateLayout())}get layerSpacing(){return this.V.layerSpacing}set layerSpacing(t){this.V.layerSpacing!==t&&(Util.i(t,"number",TreeLayout,"layerSpacing"),this.V.layerSpacing=t,this.invalidateLayout())}get layerSpacingParentOverlap(){return this.V.layerSpacingParentOverlap}set layerSpacingParentOverlap(t){this.V.layerSpacingParentOverlap!==t&&(Util.i(t,"number",TreeLayout,"layerSpacingParentOverlap"),t>=0&&t<=1&&(this.V.layerSpacingParentOverlap=t,this.invalidateLayout()))}get compaction(){return this.V.compaction}set compaction(t){this.V.compaction!==t&&(t===30||t===31)&&(this.V.compaction=t,this.invalidateLayout())}get breadthLimit(){return this.V.breadthLimit}set breadthLimit(t){this.V.breadthLimit!==t&&(Util.i(t,"number",TreeLayout,"breadthLimit"),t>=0&&(this.V.breadthLimit=t,this.invalidateLayout()))}get rowSpacing(){return this.V.rowSpacing}set rowSpacing(t){this.V.rowSpacing!==t&&(Util.i(t,"number",TreeLayout,"rowSpacing"),this.V.rowSpacing=t,this.invalidateLayout())}get rowIndent(){return this.V.rowIndent}set rowIndent(t){this.V.rowIndent!==t&&(Util.i(t,"number",TreeLayout,"rowIndent"),t>=0&&(this.V.rowIndent=t,this.invalidateLayout()))}get commentSpacing(){return this.V.commentSpacing}set commentSpacing(t){this.V.commentSpacing!==t&&(Util.i(t,"number",TreeLayout,"commentSpacing"),this.V.commentSpacing=t,this.invalidateLayout())}get commentMargin(){return this.V.commentMargin}set commentMargin(t){this.V.commentMargin!==t&&(Util.i(t,"number",TreeLayout,"commentMargin"),this.V.commentMargin=t,this.invalidateLayout())}get setsPortSpot(){return this.V.setsPortSpot}set setsPortSpot(t){this.V.setsPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"setsPortSpot"),this.V.setsPortSpot=t,this.invalidateLayout())}get portSpot(){return this.V.portSpot}set portSpot(t){this.V.portSpot.equals(t)||(this.V.portSpot=t,this.invalidateLayout())}get setsChildPortSpot(){return this.V.setsChildPortSpot}set setsChildPortSpot(t){this.V.setsChildPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"setsChildPortSpot"),this.V.setsChildPortSpot=t,this.invalidateLayout())}get childPortSpot(){return this.V.childPortSpot}set childPortSpot(t){this.V.childPortSpot.equals(t)||(this.V.childPortSpot=t,this.invalidateLayout())}get alternateSorting(){return this.z.sorting}set alternateSorting(t){this.z.sorting!==t&&(this.z.sorting=t,this.invalidateLayout())}get alternateComparer(){return this.z.comparer}set alternateComparer(t){this.z.comparer!==t&&(Util.i(t,"function",TreeLayout,"alternateComparer"),this.z.comparer=t,this.invalidateLayout())}get alternateAngle(){return this.z.angle}set alternateAngle(t){this.z.angle!==t&&(Util.i(t,"number",TreeLayout,"alternateAngle"),(t===0||t===90||t===180||t===270)&&(this.z.angle=t,this.invalidateLayout()))}get alternateAlignment(){return this.z.alignment}set alternateAlignment(t){this.z.alignment!==t&&(this.z.alignment=t,this.invalidateLayout())}get alternateNodeIndent(){return this.z.nodeIndent}set alternateNodeIndent(t){this.z.nodeIndent!==t&&(Util.i(t,"number",TreeLayout,"alternateNodeIndent"),t>=0&&(this.z.nodeIndent=t,this.invalidateLayout()))}get alternateNodeIndentPastParent(){return this.z.nodeIndentPastParent}set alternateNodeIndentPastParent(t){this.z.nodeIndentPastParent!==t&&(Util.i(t,"number",TreeLayout,"alternateNodeIndentPastParent"),t>=0&&t<=1&&(this.z.nodeIndentPastParent=t,this.invalidateLayout()))}get alternateNodeSpacing(){return this.z.nodeSpacing}set alternateNodeSpacing(t){this.z.nodeSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateNodeSpacing"),this.z.nodeSpacing=t,this.invalidateLayout())}get alternateLayerSpacing(){return this.z.layerSpacing}set alternateLayerSpacing(t){this.z.layerSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateLayerSpacing"),this.z.layerSpacing=t,this.invalidateLayout())}get alternateLayerSpacingParentOverlap(){return this.z.layerSpacingParentOverlap}set alternateLayerSpacingParentOverlap(t){this.z.layerSpacingParentOverlap!==t&&(Util.i(t,"number",TreeLayout,"alternateLayerSpacingParentOverlap"),t>=0&&t<=1&&(this.z.layerSpacingParentOverlap=t,this.invalidateLayout()))}get alternateCompaction(){return this.z.compaction}set alternateCompaction(t){this.z.compaction!==t&&(t===30||t===31)&&(this.z.compaction=t,this.invalidateLayout())}get alternateBreadthLimit(){return this.z.breadthLimit}set alternateBreadthLimit(t){this.z.breadthLimit!==t&&(Util.i(t,"number",TreeLayout,"alternateBreadthLimit"),t>=0&&(this.z.breadthLimit=t,this.invalidateLayout()))}get alternateRowSpacing(){return this.z.rowSpacing}set alternateRowSpacing(t){this.z.rowSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateRowSpacing"),this.z.rowSpacing=t,this.invalidateLayout())}get alternateRowIndent(){return this.z.rowIndent}set alternateRowIndent(t){this.z.rowIndent!==t&&(Util.i(t,"number",TreeLayout,"alternateRowIndent"),t>=0&&(this.z.rowIndent=t,this.invalidateLayout()))}get alternateCommentSpacing(){return this.z.commentSpacing}set alternateCommentSpacing(t){this.z.commentSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateCommentSpacing"),this.z.commentSpacing=t,this.invalidateLayout())}get alternateCommentMargin(){return this.z.commentMargin}set alternateCommentMargin(t){this.z.commentMargin!==t&&(Util.i(t,"number",TreeLayout,"alternateCommentMargin"),this.z.commentMargin=t,this.invalidateLayout())}get alternateSetsPortSpot(){return this.z.setsPortSpot}set alternateSetsPortSpot(t){this.z.setsPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"alternateSetsPortSpot"),this.z.setsPortSpot=t,this.invalidateLayout())}get alternatePortSpot(){return this.z.portSpot}set alternatePortSpot(t){this.z.portSpot.equals(t)||(this.z.portSpot=t,this.invalidateLayout())}get alternateSetsChildPortSpot(){return this.z.setsChildPortSpot}set alternateSetsChildPortSpot(t){this.z.setsChildPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"alternateSetsChildPortSpot"),this.z.setsChildPortSpot=t,this.invalidateLayout())}get alternateChildPortSpot(){return this.z.childPortSpot}set alternateChildPortSpot(t){this.z.childPortSpot.equals(t)||(this.z.childPortSpot=t,this.invalidateLayout())}static PathDefault=0;static PathDestination=1;static PathSource=2;static SortingForwards=10;static SortingReverse=11;static SortingAscending=12;static SortingDescending=13;static AlignmentCenterSubtrees=20;static AlignmentCenterChildren=21;static AlignmentStart=22;static AlignmentEnd=23;static AlignmentBus=24;static AlignmentBusBranching=25;static AlignmentTopLeftBus=26;static AlignmentBottomRightBus=27;static CompactionNone=30;static CompactionBlock=31;static StyleLayered=40;static StyleLastParents=41;static StyleAlternating=42;static StyleRootOnly=43;static ArrangementVertical=50;static ArrangementHorizontal=51;static ArrangementFixedRoots=52;static LayerIndividual=60;static LayerSiblings=61;static LayerUniform=62}class TreeNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new TreeVertex(this)}createEdge(){return new TreeEdge(this)}}class TreeVertex extends LayoutVertex{U;mt;et;gk;mk;pk;yk;wk;xk;bk;Re;MD;_f;tu;Rg;vg;pe;ye;Xt;ni;$y;Zy;Qy;Ps;_y;tw;iw;ew;sw;nw;ow;rw;lw;hw;aw;constructor(t){super(t),this.gk=!1,this.mk=null,this.pk=[],this.yk=0,this.wk=0,this.xk=0,this.bk=0,this.Re=null,this.U=new Point(0,0),this.mt=new Size(0,0),this.et=new Point(0,0),this.MD=!1,this._f=!1,this.tu=!1,this.Rg=null,this.vg=null,this.pe=10,this.ye=LayoutVertex.standardComparer,this.Xt=0,this.ni=21,this.$y=0,this.Zy=0,this.Qy=20,this.Ps=50,this._y=0,this.tw=31,this.iw=0,this.ew=25,this.sw=10,this.nw=10,this.ow=20,this.rw=!0,this.lw=Spot.Default,this.hw=!0,this.aw=Spot.Default}copyInheritedPropertiesFrom(t){t!==null&&(this.pe=t.sorting,this.ye=t.comparer,this.Xt=t.angle,this.ni=t.alignment,this.$y=t.nodeIndent,this.Zy=t.nodeIndentPastParent,this.Qy=t.nodeSpacing,this.Ps=t.layerSpacing,this._y=t.layerSpacingParentOverlap,this.tw=t.compaction,this.iw=t.breadthLimit,this.ew=t.rowSpacing,this.sw=t.rowIndent,this.nw=t.commentSpacing,this.ow=t.commentMargin,this.rw=t.setsPortSpot,this.lw=t.portSpot,this.hw=t.setsChildPortSpot,this.aw=t.childPortSpot)}get initialized(){return this.gk}set initialized(t){this.gk!==t&&(Util.i(t,"boolean",TreeVertex,"initialized"),this.gk=t)}get parent(){return this.mk}set parent(t){this.mk!==t&&(this.mk=t)}get children(){return this.pk}set children(t){if(this.pk!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",TreeVertex,"children:value"),t!==null){const i=t.length;for(let e=0;e4;)t.removePoint(2);u=t.getPoint(1),d=t.getPoint(2)}else{for(f=1;t.pointsCount>3;)t.removePoint(1);u=t.getPoint(0),d=t.getPoint(t.pointsCount-1)}const m=t.getPoint(t.pointsCount-1);let g=0;r===0?(e.alignment===23?(g=o.bottom+n.y,n.y===0&&u.y>m.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.xm.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.x{const i=t.matches?"dark":"light";i!==this.Og&&(this.Og=i,this.Mk==="system"&&this.cw())};constructor(t){t&&Object.assign(this,t),t?.themeMap||(this.eu.set("light",{colors:{...Themes.Light.colors},fonts:{...Themes.Light.fonts},numbers:{...Themes.Light.numbers},margins:{...Themes.Light.margins},arrowheads:{...Themes.Light.arrowheads}}),this.eu.set("dark",{colors:{...Themes.Dark.colors},fonts:{...Themes.Dark.fonts},numbers:{...Themes.Dark.numbers},margins:{...Themes.Dark.margins},arrowheads:{...Themes.Dark.arrowheads}})),root.matchMedia&&(this.Og=root.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}get themeMap(){return this.eu}set themeMap(t){this.eu!==t&&(this.eu=t,this.cw())}get defaultTheme(){return this.Pk}set defaultTheme(t){this.Pk!==t&&(Util.i(t,"string",ThemeManager,"defaultTheme"),this.Pk=t,this.cw())}get currentTheme(){return this.Mk}set currentTheme(t){this.Mk!==t&&(Util.i(t,"string",ThemeManager,"currentTheme"),this.Mk=t,this.cw())}get changesDivBackground(){return this.Sk}set changesDivBackground(t){if(this.Sk!==t&&(this.Sk=t,t))for(const e of this.es)e.setDivBackground(this.findValue("div","","fill")),e.v("ThemeChanged",this)}get preferredColorScheme(){return this.Og}addDiagram(t){return this.es.add(t),this.WN(t),this}removeDiagram(t){return this.es.delete(t),this.WN(t),this}zF(){this.es.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.addEventListener("change",this.SD)}XF(){this.es.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.removeEventListener("change",this.SD)}set(t,i){t===""&&(t=this.Pk),t==="system"&&(t=this.Og);let e=this.eu.get(t);return e?e=this.ND(e,i):e=i,this.eu.set(t,e),this.cw(),this}findValue(t,i,e){return this.getValue(this.findTheme(this.currentTheme),t,i,e)||this.getValue(this.findTheme(this.defaultTheme),t,i,e)}getValue(t,i,e,s){if(!t)return;e==null&&(e="");let n=t;const o=l=>{if(n===void 0||l==="")return;if(typeof l=="number"||!(Array.isArray(l)||l.includes(".")))return n[l];const h=Array.isArray(l)?l:l.split(".");for(let a=0;a{if(!(e!==""&&(n=o(e),n===void 0)))return Array.isArray(n)&&typeof i=="number"?n=n[i%n.length]:n=o(i),n};if(n=r(),n===void 0&&typeof s=="string"&&s.length>0){let l=t.targetPropertyMap?.get(s);if(l?n=t[l]:(l=ThemeManager.jI.get(s),n=l?t[l]:t.colors),n=r(),n!==void 0)return n}return n}findTheme(t){return this.themeMap.get(t==="system"?this.Og:t)}WN(t){const i=t.skipsUndoManager;t.skipsUndoManager=!0,t.updateAllThemeBindings(),this.Sk&&t.setDivBackground(this.findValue("div","","fill")),t.skipsUndoManager=i,t.v("ThemeChanged",this)}cw(){for(const t of this.es)this.WN(t)}ND(t,i){for(const e in i)if(Util.fw(i,e))try{i[e].constructor===Object?t[e]=this.ND(t[e]??{},i[e]):t[e]=i[e]}catch{delete t[e]}return t}static jI=new Map([["background","colors"],["defaultColumnSeparatorStroke","colors"],["defaultRowSeparatorStroke","colors"],["shadowColor","colors"],["fill","colors"],["stroke","colors"],["font","fonts"],["angle","numbers"],["fromEndSegmentLength","numbers"],["fromShortLength","numbers"],["height","numbers"],["opacity","numbers"],["scale","numbers"],["toEndSegmentLength","numbers"],["toShortLength","numbers"],["width","numbers"],["defaultColumnSeparatorStrokeWidth","numbers"],["defaultRowSeparatorStrokeWidth","numbers"],["shadowBlur","numbers"],["corner","numbers"],["curviness","numbers"],["smoothness","numbers"],["parameter1","numbers"],["parameter2","numbers"],["strokeWidth","numbers"],["strokeDashOffset","numbers"],["maxLines","numbers"],["spacingAbove","numbers"],["spacingBelow","numbers"],["position","points"],["shadowOffset","points"],["desiredSize","sizes"],["maxSize","sizes"],["minSize","sizes"],["margin","margins"],["defaultSeparatorPadding","margins"],["padding","margins"],["alignment","spots"],["alignmentFocus","spots"],["fromSpot","spots"],["toSpot","spots"],["defaultAlignment","spots"],["spot1","spots"],["spot2","spots"],["verticalAlignment","spots"],["imageAlignment","spots"],["fromArrow","arrowheads"],["toArrow","arrowheads"]])}class Router{St;p;Oi;ul;constructor(){this.p=Diagram.pm(),this.St="",this.Oi=!0,this.ul=!0}get name(){return this.St}set name(t){this.St=t}get isEnabled(){return this.Oi}set isEnabled(t){this.Oi=t}get isRealtime(){return this.ul}set isRealtime(t){this.ul=t}get diagram(){return this.p}set diagram(t){this.p!==t&&(this.p=t,t.bl=!0,t.requestUpdate())}invalidateRouter(){this.p!==null&&(this.p.bl=!0,this.p.requestUpdate())}canRoute(t){if(!this.isEnabled)return!1;const i=this.diagram;return!(i&&(!this.isRealtime&&i.yu||i.animationManager.isTicking))}routeLinks(t,i){}toString(){return this.name!==""?this.name+" Router":Util.sn(this.constructor)}}class AvoidsNodesRouter extends Router{constructor(t){super(),this.name="AvoidsNodes",t&&Object.assign(this,t)}canRoute(t){return(t instanceof Diagram?t.Gm:t.diagram.Gm)?super.canRoute(t):!1}routeLinks(t,i){const e=i instanceof Diagram?null:i,s=t.iterator,n=this.diagram.getPositions(!0,e,null);for(;s.next();){const o=s.value;if(!o.isAvoiding||i&&o.containingGroup!==e||o.toNode===null||o.fromNode===null||o.pointsCount<4)continue;o.startRoute();const r=o.pointsCount,l=o.getPoint(1),h=o.getPoint(r-2),a=o.fromNode.actualBounds.copy();a.inflate(Link.Ra,Link.Ra),a.unionPoint(o.getPoint(0));const c=o.toNode.actualBounds.copy();c.inflate(Link.Ra,Link.Ra),c.unionPoint(o.getPoint(r-1)),this.HI(o,a,c,n)&&this.qI(o,l,o.sN,h,o.nN,a,c,n),o.commitRoute()}}HI(t,i,e,s){const n=t.diagram,o=t.pointsCount;if(n===null||t.fromNode===t.toNode||t.layer.isTemporary||i.containsPoint(t.getPoint(o-1))&&!t.toNode.isMemberOf(t.fromNode)||e.containsPoint(t.getPoint(0))&&!t.fromNode.isMemberOf(t.toNode)||!t.isOrthogonal)return!1;if(t.segmentIndex===17)return!0;const r=t.getPoint(1),l=t.getPoint(o-2),h=t.getPoint(2);if(!s.isUnoccupied(Math.min(r.x,h.x),Math.min(r.y,h.y),Math.abs(r.x-h.x),Math.abs(r.y-h.y)))return!0;for(let c=2;c=PositionArray.Bd&&(l.XL(),d.inflate(l.cellWidth*l.vS,l.cellHeight*l.OS),l.rT(i,e,s,n,d,!1),m=l.fo(s.x,s.y)),!l.by&&mPositionArray.Ea&&i.fo(g,p)!==u-1&&(i.fo(d-c,m)===u-1?(n=180,g=d-c,p=m):i.fo(d+c,m)===u-1?(n=0,g=d+c,p=m):i.fo(d,m-f)===u-1?(n=270,g=d,p=m-f):i.fo(d,m+f)===u-1&&(n=90,g=d,p=m+f));u>PositionArray.Ea&&i.fo(g,p)===u-1;)d=g,m=p,n===0?g+=c:n===90?p+=f:n===180?g-=c:p-=f,u-=1;if(o?u>PositionArray.Ea&&(n===180||n===0?d=Math.floor(d/c)*c+c/2:(n===90||n===270)&&(m=Math.floor(m/f)*f+f/2)):(d=Math.floor(d/c)*c+c/2,m=Math.floor(m/f)*f+f/2),u>PositionArray.Ea){let y=n,x=d,k=m;if(n===0?(y=90,k+=f):n===90?(y=180,x-=c):n===180?(y=270,k-=f):n===270&&(y=0,x+=c),i.fo(x,k)===u-1)this.JN(t,i,x,k,y,!1);else{let P=d,M=m;n===0?(y=270,M-=f):n===90?(y=0,P+=c):n===180?(y=90,M+=f):n===270&&(y=180,P-=c),i.fo(P,M)===u-1&&this.JN(t,i,P,M,y,!1)}}t.insertPointAt(t.pointsCount-2,d,m)}}ToolManager.prototype.initializeStandardTools=function(){this.Jt("Action",new ActionTool,this.mouseDownTools),this.Jt("Relinking",new RelinkingTool,this.mouseDownTools),this.Jt("LinkReshaping",new LinkReshapingTool,this.mouseDownTools),this.Jt("Rotating",new RotatingTool,this.mouseDownTools),this.Jt("Resizing",new ResizingTool,this.mouseDownTools),this.Jt("Linking",new LinkingTool,this.mouseMoveTools),this.Jt("Dragging",new DraggingTool,this.mouseMoveTools),this.Jt("DragSelecting",new DragSelectingTool,this.mouseMoveTools),this.Jt("Panning",new PanningTool,this.mouseMoveTools),this.Jt("ContextMenu",new ContextMenuTool,this.mouseUpTools),this.Jt("TextEditing",new TextEditingTool,this.mouseUpTools),this.Jt("ClickCreating",new ClickCreatingTool,this.mouseUpTools),this.Jt("ClickSelecting",new ClickSelectingTool,this.mouseUpTools)};Diagram.gS("GraphLinksModel",GraphLinksPartManager);Diagram.gS("TreeModel",TreePartManager);const oldGo=root.go,go={get version(){return Diagram.version},Group,List,Set:GSet,Map:GMap,Point,Size,Rect,Margin,Spot,Geometry,PathFigure,PathSegment,InputEvent,DiagramEvent,ChangedEvent,Model,GraphLinksModel,TreeModel,Binding,ThemeBinding,Transaction,UndoManager,CommandHandler,Tool,DraggingTool,DraggingInfo,DraggingOptions,LinkingBaseTool,LinkingTool,RelinkingTool,LinkReshapingTool,ResizingTool,RotatingTool,ClickSelectingTool,ActionTool,ClickCreatingTool,HTMLInfo,ContextMenuTool,DragSelectingTool,PanningTool,TextEditingTool,ToolManager,Animation,AnimationManager,AnimationTrigger,Layer,Diagram,Palette,Overview,Brush,GraphObject,Panel,RowColumnDefinition,Shape,TextBlock,Picture,Part,Adornment,Node,Link,Placeholder,Layout,LayoutNetwork,LayoutVertex,LayoutEdge,GridLayout,PanelLayout,CircularLayout,CircularNetwork,CircularVertex,CircularEdge,ForceDirectedLayout,ForceDirectedNetwork,ForceDirectedVertex,ForceDirectedEdge,LayeredDigraphLayout,LayeredDigraphNetwork,LayeredDigraphVertex,LayeredDigraphEdge,TreeLayout,TreeNetwork,TreeVertex,TreeEdge,Themes,ThemeManager,Router,AnimationStyle,AutoScale,CycleMode,Flip,TextFormat,ImageStretch,LayoutConditions,LinkAdjusting,Curve,Routing,Orientation,TextOverflow,PortSpreading,ScrollMode,CollapsePolicy,Sizing,TriggerStart,Stretch,ViewboxStretch,Wrap,BrushType,ColorSpace,GeometryStretch,GeometryType,SegmentType,BindingMode,ChangeType,CircularArrangement,CircularDirection,CircularNodeDiameterFormula,CircularSorting,GridAlignment,GridArrangement,GridSorting,LayeredDigraphAggressive,LayeredDigraphAlign,LayeredDigraphCycleRemove,LayeredDigraphInit,LayeredDigraphLayering,LayeredDigraphPack,TreeAlignment,TreeArrangement,TreeCompaction,TreeLayerStyle,TreePath,TreeSorting,TreeStyle,GestureMode,LinkingDirection,ReshapingBehavior,TextEditingAccept,TextEditingStarting,TextEditingState,WheelMode};typeof oldGo=="object"&&oldGo.version&&Util.oi("WARNING: a `go` object on the root object is already defined. "+("Debug"in oldGo?"debug ":"")+"version: "+oldGo.version+", replaced with version: "+go.version);Diagram.prototype.go=go;root.go=go; + "removedLinkKeys": `;BT(t){const i=new GSet;for(let e=0;e{if(f.model===s){if(f.modelChange==="linkDataArray")f.change===3?n.add(f.newValue):f.change===4&&r.add(f.oldValue);else if(s.containsLinkData(f.object))o.add(f.object);else if(f.object!==null)if(f.object!==null&&l&&l.has(f.object))l.get(f.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(f.object instanceof Model||s.containsNodeData(f.object))return;s.BT(f.object).each(d=>o.add(d))}}});const h=this.og;h.clear(),n.each(f=>{h.add(s.getKeyForLinkData(f)),i||o.add(f)});const a=this.ng;a.clear(),r.each(f=>{a.add(s.getKeyForLinkData(f)),i&&o.add(f)});let c=e;return h.count>0&&(c+=(i?this.VT:this.UT)+this.Ch(h.toArray(),!0)),o.count>0&&(c+=this.DO+this.Ch(o.toArray(),!0)),a.count>0&&(c+=(i?this.UT:this.VT)+this.Ch(a.toArray(),!0)),a.clear(),h.clear(),c}Dy(t){(t.linkCategoryProperty!==void 0&&t.linkCategoryProperty!==this.linkCategoryProperty||t.linkKeyProperty!==void 0&&t.linkKeyProperty!==this.linkKeyProperty||t.linkFromKeyProperty!==void 0&&t.linkFromKeyProperty!==this.linkFromKeyProperty||t.linkToKeyProperty!==void 0&&t.linkToKeyProperty!==this.linkToKeyProperty||t.linkFromPortIdProperty!==void 0&&t.linkFromPortIdProperty!==this.linkFromPortIdProperty||t.linkToPortIdProperty!==void 0&&t.linkToPortIdProperty!==this.linkToPortIdProperty||t.linkLabelKeysProperty!==void 0&&t.linkLabelKeysProperty!==this.linkLabelKeysProperty||t.nodeIsGroupProperty!==void 0&&t.nodeIsGroupProperty!==this.nodeIsGroupProperty||t.nodeGroupKeyProperty!==void 0&&t.nodeGroupKeyProperty!==this.nodeGroupKeyProperty)&&Util.o("applyIncrementalJson cannot change Model properties"),super.Dy(t);const i=t.insertedLinkKeys;if(Array.isArray(i)){const n=i.length;for(let o=0;o=0&&s.splice(e,1)):s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue));return}}else if(t.change===4){let e=t.oldParam;if(t.modelChange==="linkDataArray"){const s=t.oldValue;if(Util.wt(s)&&typeof e=="number"){const n=this.getKeyForLinkData(s);i?(this.sr.add(s),this.$e[e]!==s&&this.$e.splice(e,0,s),n!==void 0&&this.fi.set(n,s)):(this.sr.delete(s),this.$e[e]===s&&this.$e.splice(e,1),n!==void 0&&this.fi.delete(n))}return}else if(t.modelChange==="linkLabelKeys"){const s=this.getLabelKeysForLinkData(t.object);Array.isArray(s)&&typeof e=="number"&&(i?s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue):(e=s.indexOf(t.newValue),e>=0&&s.splice(e,1)));return}}super.changeState(t,i)}}get archetypeNodeData(){return this.Ll}set archetypeNodeData(t){const i=this.Ll;i!==t&&(t!==null&&Util.i(t,"object",GraphLinksModel,"archetypeNodeData"),this.Ll=t,this.t("archetypeNodeData",i,t))}NN(t){if(t===void 0)return;const i=this.Ll;if(i!==null){let e=this.findNodeDataForKey(t);e===null&&(e=this.copyNodeData(i),Model.rt(e,this.nodeKeyProperty,t),this.addNodeData(e))}return t}get linkFromKeyProperty(){return this.wo}set linkFromKeyProperty(t){const i=this.wo;i!==t&&(this.An(t,GraphLinksModel,"linkFromKeyProperty"),this.wo=t,this.t("linkFromKeyProperty",i,t))}getFromKeyForLinkData(t){return this.Te(t,!0)}setFromKeyForLinkData(t,i){this.Zd(t,i,!0)}get linkToKeyProperty(){return this.xo}set linkToKeyProperty(t){const i=this.xo;i!==t&&(this.An(t,GraphLinksModel,"linkToKeyProperty"),this.xo=t,this.t("linkToKeyProperty",i,t))}getToKeyForLinkData(t){return this.Te(t,!1)}setToKeyForLinkData(t,i){this.Zd(t,i,!1)}Te(t,i){if(t===null)return;const e=i?this.wo:this.xo;if(e==="")return;const s=Model.vt(t,e);if(s!==void 0){if(this.isKeyType(s))return s;Util.o((i?"FromKey":"ToKey")+" value for link data "+t+" is not a number or a string: "+s)}}Zd(t,i,e){if(i===null&&(i=void 0),i!==void 0&&!this.isKeyType(i)&&Util.we(i,"number or string",GraphLinksModel,e?"setFromKeyForLinkData:key":"setToKeyForLinkData:key"),t===null)return;const s=e?this.wo:this.xo;if(s==="")return;if(i=this.NN(i),!this.containsLinkData(t)){Model.rt(t,s,i);return}const n=Model.vt(t,s);n!==i&&(this.Js(n,t),Model.rt(t,s,i),this.findNodeDataForKey(i)===null&&this.$s(i,t),this.Et(e?"linkFromKey":"linkToKey",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkFromPortIdProperty(){return this.Ya}set linkFromPortIdProperty(t){const i=this.Ya;i!==t&&(this.An(t,GraphLinksModel,"linkFromPortIdProperty"),this.Ya=t,this.t("linkFromPortIdProperty",i,t))}getFromPortIdForLinkData(t){return this.L1(t,!0)}setFromPortIdForLinkData(t,i){this.Qd(t,i,!0)}get linkToPortIdProperty(){return this.Ga}set linkToPortIdProperty(t){const i=this.Ga;i!==t&&(this.An(t,GraphLinksModel,"linkToPortIdProperty"),this.Ga=t,this.t("linkToPortIdProperty",i,t))}getToPortIdForLinkData(t){return this.L1(t,!1)}setToPortIdForLinkData(t,i){this.Qd(t,i,!1)}L1(t,i){if(t===null)return"";const e=i?this.Ya:this.Ga;if(e==="")return"";const s=Model.vt(t,e);return s===void 0?"":s}Qd(t,i,e){if(Util.i(i,"string",GraphLinksModel,e?"setFromPortIdForLinkData:portname":"setToPortIdForLinkData:portname"),t===null)return;const s=e?this.Ya:this.Ga;if(s==="")return;if(!this.containsLinkData(t)){Model.rt(t,s,i);return}let n=Model.vt(t,s);n===void 0&&(n=""),n!==i&&(Model.rt(t,s,i),this.Et(e?"linkFromPortId":"linkToPortId",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkLabelKeysProperty(){return this.Zs}set linkLabelKeysProperty(t){const i=this.Zs;i!==t&&(this.An(t,GraphLinksModel,"linkLabelKeysProperty"),this.Zs=t,this.t("linkLabelKeysProperty",i,t))}getLabelKeysForLinkData(t){if(t===null)return GraphLinksModel.EmptyArray;const i=this.Zs;if(i==="")return GraphLinksModel.EmptyArray;const e=Model.vt(t,i);return e===void 0?GraphLinksModel.EmptyArray:e}setLabelKeysForLinkData(t,i){if(t===null)return;const e=this.Zs;if(e==="")return;if(!this.containsLinkData(t)){Model.rt(t,e,i);return}let s=Model.vt(t,e);if(s===void 0&&(s=GraphLinksModel.EmptyArray),s!==i){if(Array.isArray(s)){const o=s.length;for(let r=0;r=0)return;n=s.length,s.push(i),this.containsLinkData(t)&&(this.findNodeDataForKey(i)===null&&this.$s(i,t),this.Et("linkLabelKeys",3,e,t,null,i,null,n))}else Util.o(e+" property is not an Array; cannot addLabelKeyForLinkData: "+t)}removeLabelKeyForLinkData(t,i){if(i==null||(this.isKeyType(i)||Util.we(i,"number or string",GraphLinksModel,"removeLabelKeyForLinkData:key"),t===null))return;const e=this.Zs;if(e==="")return;const s=Model.vt(t,e);if(Array.isArray(s)){const n=s.indexOf(i);if(n<0)return;s.splice(n,1),this.containsLinkData(t)&&(this.Js(i,t),this.Et("linkLabelKeys",4,e,t,i,null,n,null))}else s!==void 0&&Util.o(e+" property is not an Array; cannot removeLabelKeyforLinkData: "+t)}get linkDataArray(){return this.$e}set linkDataArray(t){const i=this.$e;if(i!==t){this.fi.clear();const e=t.length;for(let n=0;nnew GraphLinksModel;Model.initDiagramModel=Model.initDiagramModel=()=>new GraphLinksModel;class TreeModel extends Model{Dn;ug;Ha;constructor(t,i){if(super(),this.Dn="parent",this.ug=!1,this.Ha="parentLinkCategory",t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){super.cloneProtected(t),t.Dn=this.Dn,t.ug=this.ug,t.Ha=this.Ha}toString(t){if(t===void 0&&(t=0),t>=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" TreeModel";if(t>0){i+=` + node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n(w[w.ConstantSpacing=0]="ConstantSpacing",w[w.ConstantDistance=1]="ConstantDistance",w[w.ConstantAngle=2]="ConstantAngle",w[w.Packed=3]="Packed",w))(CircularArrangement||{}),CircularDirection=(w=>(w[w.Clockwise=10]="Clockwise",w[w.Counterclockwise=11]="Counterclockwise",w[w.BidirectionalLeft=12]="BidirectionalLeft",w[w.BidirectionalRight=13]="BidirectionalRight",w))(CircularDirection||{}),CircularSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w[w.Optimized=24]="Optimized",w))(CircularSorting||{}),CircularNodeDiameterFormula=(w=>(w[w.Pythagorean=30]="Pythagorean",w[w.Circular=31]="Circular",w))(CircularNodeDiameterFormula||{});class CircularLayout extends Layout{le;If;B1;dg;U1;Ah;AN;TN;DN;bs;vy;Oy;qa;Iy;XT;gg;mg;pg;Ef;zi;S;pe;ye;Ln;yg;constructor(t){super(),this.le=0,this.If=0,this.B1=0,this.dg=360,this.U1=0,this.Ah=0,this.AN=new Point,this.TN=30,this.DN=0,this.bs=0,this.vy=0,this.Oy=new VertexArrangement,this.qa=0,this.Iy=0,this.XT=600,this.gg=NaN,this.mg=1,this.pg=0,this.Ef=360,this.zi=0,this.S=10,this.pe=24,this.ye=LayoutVertex.standardComparer,this.Ln=6,this.yg=30,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.gg=this.gg,t.mg=this.mg,t.pg=this.pg,t.Ef=this.Ef,t.zi=this.zi,t.S=this.S,t.pe=this.pe,t.ye=this.ye,t.Ln=this.Ln,t.yg=this.yg}ri(t){t in CircularSorting?this.sorting=t:t in CircularDirection?this.direction=t:t in CircularArrangement?this.arrangement=t:t in CircularNodeDiameterFormula?this.nodeDiameterFormula=t:super.ri(t)}createNetwork(){return new CircularNetwork(this)}vO(t,i,e){t=this.OO(t);let s=this.U1,n=this.TN,o=this.le,r=this.If,l=this.B1,h=this.dg,a=this.Ah,c=this.DN,f=this.bs,u=this.vy;if(s=this.arrangement,n=this.nodeDiameterFormula,o=this.radius,(!isFinite(o)||o<=0)&&(o=NaN),r=this.aspectRatio,(!isFinite(r)||r<=0)&&(r=1),l=this.startAngle,isFinite(l)||(l=0),h=this.sweepAngle,(!isFinite(h)||h>360||h<1)&&(h=360),a=this.spacing,isFinite(a)||(a=NaN),s===3&&n===31?s=0:s===3&&n!==31&&(n=31,s=this.arrangement),(this.direction===12||this.direction===13)&&this.sorting!==24){for(let g=0;!(g>=t.length||(i.add(t.elt(g)),g+1>=t.length));g+=2)e.add(t.elt(g+1));this.direction===12?(this.arrangement===3&&i.reverse(),t=new List,t.addAll(i),t.addAll(e)):(this.arrangement===3&&e.reverse(),t=new List,t.addAll(e),t.addAll(i))}const d=t.length;c=0;let m=0;for(let g=0;g1?(o=y,f=o*r):(f=y,o=f)}else o=this.V1(u*(h>=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180)}else o=this.V1(c+(h>=360?d:d-1)*(s!==3?a:a*1.6),r,l*Math.PI/180,h*Math.PI/180);f=o*r}else{f=o*r;const g=this.FN(o,f,l*Math.PI/180,h*Math.PI/180);if(isNaN(a))s===0&&(a=(g-c)/(h>=360?d:d-1));else if(s===0){const p=(g-c)/(h>=360?d:d-1);p=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180),f=o*r):a=p}else{let p=-1/0;for(let k=0;k=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180);x>o?(o=x,f=o*r,u=y):u=g/(h>=360?d:d-1)}}return this.U1=s,this.TN=n,this.le=o,this.If=r,this.B1=l,this.dg=h,this.Ah=a,this.DN=c,this.bs=f,this.vy=u,t}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.network.vertexes;if(i.count<=1){if(i.count===1){const u=i.first();u.centerX=0,u.centerY=0}this.updateParts(),this.network=null,this.isValidLayout=!0;return}let e=new List;e.addAll(i.iterator);const s=new List,n=new List;e=this.vO(e,s,n);const o=this.U1,r=this.le,l=this.B1,h=this.dg,a=this.Ah,c=this.bs,f=this.vy;if((this.direction===12||this.direction===13)&&o===3)this.KT(e,h,l-h/2,10);else if(this.direction===12||this.direction===13){let u=0;switch(o){case 1:u=this.z1(r,c,l,f)*180/Math.PI;break;case 0:{let d=0,m=0;const g=s.first();g!==null&&(d=g.Th(Math.PI/2));const p=n.first();p!==null&&(m=p.Th(Math.PI/2)),u=this.z1(r,c,l,a+(d+m)/2)*180/Math.PI;break}case 2:u=h/e.length;break}if(this.direction===12){switch(o){case 1:this.Ey(s,h/2,l,11);break;case 0:this.By(s,h/2,l,11);break;case 2:this.Uy(s,h/2,l,11);break}switch(o){case 1:this.Ey(n,h/2,l+u,10);break;case 0:this.By(n,h/2,l+u,10);break;case 2:this.Uy(n,h/2,l+u,10);break}}else{switch(o){case 1:this.Ey(n,h/2,l,11);break;case 0:this.By(n,h/2,l,11);break;case 2:this.Uy(n,h/2,l,11);break}switch(o){case 1:this.Ey(s,h/2,l+u,10);break;case 0:this.By(s,h/2,l+u,10);break;case 2:this.Uy(s,h/2,l+u,10);break}}}else switch(o){case 1:this.Ey(e,h,l,this.direction);break;case 0:this.By(e,h,l,this.direction);break;case 2:this.Uy(e,h,l,this.direction);break;case 3:this.KT(e,h,l,this.direction);break}this.updateParts(),this.network=null,this.isValidLayout=!0}Uy(t,i,e,s){const n=this.dg,o=this.le,r=this.bs,l=e*Math.PI/180,h=i*Math.PI/180,a=t.length;for(let c=0;c=360?a:a-1):-(c*h)/a),u=t.elt(c),d=o*Math.tan(f)/r,m=Math.sqrt((o*o+r*r*d*d)/(1+d*d));u.centerX=m*Math.cos(f),u.centerY=m*Math.sin(f),u.actualAngle=f*180/Math.PI}}By(t,i,e,s){const n=this.le,o=this.bs,r=this.Ah;let l=e*Math.PI/180;const h=t.length;for(let a=0;a180&&(n-=360),n*=Math.PI/180,this.Iy=n,this.YT(t,i,e,s)}else this.GT(t,i,e,s);this.Oy.commit(t)}GT(t,i,e,s){const n=this.le,o=this.bs,r=this.Ah,l=this.If;let h=n*Math.cos(e*Math.PI/180),a=o*Math.sin(e*Math.PI/180);const c=t.toArray();if(c.length===3){c[0].centerX=n,c[0].centerY=0,c[1].centerX=c[0].centerX-c[0].width/2-c[1].width/2-r,c[1].y=c[0].y,c[2].centerX=(c[0].centerX+c[1].centerX)/2,c[2].y=c[0].y-c[2].height-r;return}else if(c.length===4){c[0].centerX=n,c[0].centerY=0,c[2].centerX=-c[0].centerX,c[2].centerY=c[0].centerY,c[1].centerX=0,c[1].y=Math.min(c[0].y,c[2].y)-c[1].height-r,c[3].centerX=0,c[3].y=Math.max(c[0].y+c[0].height+r,c[2].y+c[2].height+r);return}const f=Point.l();for(let b=0;b=c.length-1));b++)this.jT(h,a,c,b,s,f)||this.HT(h,a,c,b,s,f),h=f.x,a=f.y;if(Point.s(f),this.qa++,this.qa>23)return;const u=c[0].centerX,d=c[0].centerY,m=c[c.length-1].centerX,g=c[c.length-1].centerY;let p=Math.abs(u-m)-((c[0].width+c[c.length-1].width)/2+r);const y=Math.abs(d-g)-((c[0].height+c[c.length-1].height)/2+r);let x=0;if(Math.abs(y)<1){const b=Math.abs(u-m),P=(c[0].width+c[c.length-1].width)/2;b0?x=y:Math.abs(p)<1?x=0:x=p;let k=!1;Math.abs(m)>Math.abs(g)?k=m>0!=d>g:k=g>0!=u1&&(this.qa<8?this.le-=x/(2*Math.PI):c.length<5&&x>10?this.le/=2:this.le-=x>0?1.7:-2.3,this.bs=this.le*l,this.GT(t,i,e,s))}YT(t,i,e,s){const n=this.le,o=this.bs,r=this.If;let l=n*Math.cos(e*Math.PI/180),h=o*Math.sin(e*Math.PI/180);const a=Point.l(),c=t.toArray();for(let m=0;m=c.length-1));m++)this.jT(l,h,c,m,s,a)||this.HT(l,h,c,m,s,a),l=a.x,h=a.y;if(Point.s(a),this.qa++,this.qa>23)return;const f=Math.atan2(h,l);let u=s===10?this.Iy-f:f-this.Iy;u=Math.abs(u)1&&(this.qa<8?this.le-=d/(2*Math.PI):this.le-=d>0?1.7:-2.3,this.bs=this.le*r,this.YT(t,i,e,s))}jT(t,i,e,s,n,o){const r=this.Ah,l=this.le,h=this.bs;let a=0,c=0;const f=(e[s].width+e[s+1].width)/2+r;let u=!1;if(i>=0!=(n===10)){if(a=t+f,a>l){if(a=t-f,a<-l)return o.x=a,o.y=c,!1;u=!0}}else if(a=t-f,a<-l){if(a=t+f,a>l)return o.x=a,o.y=c,!1;u=!0}return c=Math.sqrt(1-Math.min(1,a*a/(l*l)))*h,i<0!==u&&(c=-c),Math.abs(i-c)>(e[s].height+e[s+1].height)/2?(o.x=a,o.y=c,!1):(o.x=a,o.y=c,!0)}HT(t,i,e,s,n,o){const r=this.Ah,l=this.le,h=this.bs;let a=0,c=0;const f=(e[s].height+e[s+1].height)/2+r;let u=!1;if(t>=0!=(n===10)){if(c=i-f,c<-h){if(c=i+f,c>h)return o.x=a,o.y=c,!1;u=!0}}else if(c=i+f,c>h){if(c=i-f,c<-h)return o.x=a,o.y=c,!1;u=!0}return a=Math.sqrt(1-Math.min(1,c*c/(h*h)))*l,t<0!==u&&(a=-a),Math.abs(t-a)>(e[s].width+e[s+1].width)/2?(o.x=a,o.y=c,!1):(o.x=a,o.y=c,!0)}commitLayout(){this.commitNodes(),this.isRouting&&this.commitLinks()}commitNodes(){const t=this.group!==null&&this.group.hasPlaceholder(),i=t?this.group.location.copy():null;let e=this.actualCenter;t?e=new Point(0,0):(e.x=this.arrangementOrigin.x+this.le,e.y=this.arrangementOrigin.y+this.bs);const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;n.x+=e.x,n.y+=e.y,n.commit()}if(t){this.group.ensureBounds();const n=this.group.position.copy(),o=this.group.location.copy(),r=i.subtract(o.subtract(n));this.group.move(r),this.AN=r.subtract(n)}}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}FN(t,i,e,s){const n=this.XT;if(Math.abs(this.If-1)<.001)return e!==void 0&&s!==void 0?s*t:2*Math.PI*t;const o=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let r=0,l=0;e!==void 0&&s!==void 0?l=s/(n+1):l=Math.PI/(2*(n+1));let h=0;for(let a=0;a<=n;a++){e!==void 0&&s!==void 0?h=e+a*s/n:h=a*Math.PI/(2*n);const c=Math.sin(h);r+=Math.sqrt(1-o*o*c*c)*l}return e!==void 0&&s!==void 0?(t>i?t:i)*r:4*(t>i?t:i)*r}V1(t,i,e,s){let n=0;return e!==void 0&&s!==void 0?n=this.FN(1,i,e,s):n=this.FN(1,i),t/n}z1(t,i,e,s){if(Math.abs(this.If-1)<.001)return s/t;const n=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let o=0;const r=2*Math.PI/(this.network.vertexes.count*700);t>i&&(e+=Math.PI/2);for(let l=0;;l++){const h=e+l*r,a=Math.sin(h);if(o+=(t>i?t:i)*Math.sqrt(1-n*n*a*a)*r,o>=s)return l*r}}OO(t){switch(this.sorting){case 20:break;case 21:t.reverse();break;case 22:t.sort(this.comparer);break;case 23:t.sort(this.comparer),t.reverse();break;case 24:return this.BO(this.UO(t));default:Util.o("Invalid sorting type.")}return t}UO(t){const i=[];for(let s=0;sn&&(n=u,o=c)}else for(let c=0;cn&&(n=f,o=c)}e.add(t.elt(o)),i[o]=-1;const r=t.elt(o);let l=0;const h=r.sourceEdges;for(;h.next();){const f=h.value.fromVertex;l=t.indexOf(f),!(l<0)&&i[l]>=0&&i[l]++}const a=r.destinationEdges;for(;a.next();){const f=a.value.toVertex;l=t.indexOf(f),!(l<0)&&i[l]>=0&&i[l]++}}return e}BO(t){const i=[];for(let f=0;f=0){const C=Math.abs(x-(L>=x?L+1:L));b+=C=x&&S++,L>=x&&L++,S>L){const C=L;L=S,S=C}L-S<(s.length+2)/2==(S=0&&(n.push(f),o.push(x))}h++}let a=!1;const c=s.length;for(;;){a=!0;for(let f=0;f=0){let g=0;for(let p=0;pm?x-m:m-x,b=c-k;g+=xb?1:-1}s.splice(g<0?m:m+1,0,u),r.splice(f,1),f--}else a=!1}if(a)break;s.push(r[0]),r.splice(0,1)}for(let f=0;f0||isNaN(t))&&(this.gg=t,this.invalidateLayout()))}get aspectRatio(){return this.mg}set aspectRatio(t){this.mg!==t&&(Util.i(t,"number",CircularLayout,"aspectRatio"),t>0&&(this.mg=t,this.invalidateLayout()))}get startAngle(){return this.pg}set startAngle(t){this.pg!==t&&(Util.i(t,"number",CircularLayout,"startAngle"),this.pg=t,this.invalidateLayout())}get sweepAngle(){return this.Ef}set sweepAngle(t){this.Ef!==t&&(Util.i(t,"number",CircularLayout,"sweepAngle"),t>0&&t<=360?this.Ef=t:this.Ef=360,this.invalidateLayout())}get arrangement(){return this.zi}set arrangement(t){this.zi!==t&&(t===3||t===0||t===1||t===2)&&(this.zi=t,this.invalidateLayout())}get direction(){return this.S}set direction(t){this.S!==t&&(t===10||t===11||t===12||t===13)&&(this.S=t,this.invalidateLayout())}get sorting(){return this.pe}set sorting(t){this.pe!==t&&(this.pe=t,this.invalidateLayout())}get comparer(){return this.ye}set comparer(t){this.ye!==t&&(Util.i(t,"function",CircularLayout,"comparer"),this.ye=t,this.invalidateLayout())}get spacing(){return this.Ln}set spacing(t){this.Ln!==t&&(Util.i(t,"number",CircularLayout,"spacing"),this.Ln=t,this.invalidateLayout())}get nodeDiameterFormula(){return this.yg}set nodeDiameterFormula(t){this.yg!==t&&(t===30||t===31)&&(this.yg=t,this.invalidateLayout())}get actualXRadius(){return this.le}get actualYRadius(){return this.bs}get actualSpacing(){return this.Ah}get actualCenter(){return this.AN}static ConstantSpacing=0;static ConstantDistance=1;static ConstantAngle=2;static Packed=3;static Clockwise=10;static Counterclockwise=11;static BidirectionalLeft=12;static BidirectionalRight=13;static Forwards=20;static Reverse=21;static Ascending=22;static Descending=23;static Optimized=24;static Pythagorean=30;static Circular=31}class VertexArrangement{Bf;Wa;Uf;constructor(){this.Bf=-1/0,this.Wa=null,this.Uf=null}IO(t,i){if(t>0&&this.Bf<0||Math.abs(t)0)){this.Bf=t,this.Wa=[],this.Uf=[];for(let e=0;e0){for(this.network.deleteSelfEdges(),i=this.network.vertexes.iterator;i.next();){const o=i.value;o.charge=this.electricalCharge(o),o.mass=this.gravitationalMass(o)}const s=this.network.edges.iterator;for(;s.next();){const o=s.value;o.stiffness=this.springStiffness(o),o.length=this.springLength(o)}if(this.RN(),this.Dh=0,this.needsPrelayout()){const o=this.network,r=o.splitIntoSubNetworks(!1);let l=r.iterator;for(;l.next();){const h=l.value;this.doConnectedSubnetLayout(h)}for(l=r.iterator,this.zO(l,o),l=r.iterator;l.next();){const h=l.value,a=h.vertexes.iterator;for(;a.next();){const f=a.value;o.addVertex(f)}const c=h.edges.iterator;for(;c.next();){const f=c.value;o.addEdge(f)}}}else this.qT(this.network,this.maxIterations);this.updateParts()}this.maxIterations=e,this.isValidLayout=!0}needsPrelayout(){if(this.network.vertexes.count<3)return!1;let t=0,i=0;const e=this.network.vertexes.first().bounds,s=this.network.vertexes.iterator;for(;s.next();){const n=s.value,o=n.bounds;if(isNaN(n.x)||isNaN(n.y)||o.intersectsRect(e)&&(t++,t>2))return!0;if(i>10)return!1;i++}return!1}doConnectedSubnetLayout(t){let i=t.vertexes.iterator;for(;i.next();){const l=i.value;l.hierarchicalVertexes.add(l)}let e=t,s=this.Gf;if(isNaN(s)&&(s=t.edges.count/t.vertexes.count),sMath.max(100,Math.sqrt(s*t.vertexes.count));)e=this.coarsenNetwork(e);let n=0;i=e.vertexes.iterator;let o=this.randomNumberGenerator;for(o===null&&(this.randomNumberGenerator=o=new RandomNumberGenerator(0));i.next();){i.value.idInCluster=n++;const l=10*(o.random()-.5),h=10*(o.random()-.5);this.isFixed(i.value)||(i.value.x=l,i.value.y=h);const a=i.value.hierarchicalVertexes.iterator;for(;a.next();)this.isFixed(a.value)||(a.value.x=l,a.value.y=h)}const r=this.computePairwiseDistances(e);this.XO(e,r,this.maxPrelayoutIterations,t.vertexes.count),this.qT(t,this.maxIterations)}computePairwiseDistances(t){const i=t.vertexes.count,e=new Array(i);for(let r=0;r0;){const l=o.shift(),h=l.vertexes.iterator;for(;h.next();){const a=h.value;n.has(a.idInCluster)||(n.set(a.idInCluster,n.get(l.idInCluster)+1),o.push(a))}}for(let l=0;l=0;m--)if(t[m].y>c.y&&t[m].x-c.xc.x&&t[m].y-c.ya+f){const u=s+o-h,d=n-a-f;return Geo.bw(u*u+d*d)}else if(n+rh+c)if(n>a+f){const u=s-h-c,d=n-a-f;return Geo.bw(u*u+d*d)}else if(n+ra+f?n-(a+f):n+rr-o;l?i.sort((m,g)=>m===null||g===null||m===g?0:m.centerX-g.centerX):i.sort((m,g)=>m===null||g===null||m===g?0:m.centerY-g.centerY);const h=this.Vf;let a=0,c=0,f=0;for(let m=0;mh||C-x>h){if(l)break;continue}if(k-M>h||M-k>h){if(!l)break;continue}const N=this.vN(g,P),T=2*g.charge,A=2*P.charge;if(N>1)a=T*A/(N*N),c=a*(x-C)/N,f=a*(k-M)/N;else{let D=this.randomNumberGenerator;D===null&&(this.randomNumberGenerator=D=new RandomNumberGenerator(0));const F=D.random(),R=D.random();if(x>C)c=Math.abs(P.bounds.right-g.bounds.x),c=T*A*(1+c)*F;else if(xM)f=Math.abs(P.bounds.bottom-g.bounds.y),f=T*A*(1+f)*R;else if(x1&&(a=.1*m.stiffness*(M-m.length),c=a*.5*(g.width+p.height)*(k-L)/M,f=a*.5*(g.width+p.height)*(b-C)/M),g.forceX-=c,g.forceY-=f,p.forceX+=c,p.forceY+=f}let d=0;for(let m=0;mthis.epsilonDistance*this.epsilonDistance}XO(t,i,e,s){const n=this.Dh+e,o=Math.sqrt(s);this.Vy=this.Ja*t.vertexes.count;const r=t.vertexes.toArray();let l=0,h=0,a=0;for(;this.Dh0){r[c].forceX=this.Vy*r[c].forceX/f,r[c].forceY=this.Vy*r[c].forceY/f,this.isFixed(r[c])||(r[c].x+=r[c].forceX,r[c].y+=r[c].forceY);const u=r[c].hierarchicalVertexes.iterator;for(;u.next();){const d=u.value;this.isFixed(d)||(d.centerX+=r[c].forceX,d.centerY+=r[c].forceY)}}l+=f*f}if(l>=h){if(a++,a>=5)break}else a=0;this.Vy*=.95}}moveVertex(t){let i=t.forceX,e=t.forceY;const s=this.moveLimit;return i<-s?i=-s:i>s&&(i=s),e<-s?e=-s:e>s&&(e=s),t.centerX+=i,t.centerY+=e,i*i+e*e}shouldInteract(t,i){return!0}moveFixedVertex(t){}commitLayout(){this.zy(),this.commitNodes(),this.isRouting&&this.commitLinks()}zy(){if(!this.setsPortSpots)return;const t=this.network.edges.iterator;for(;t.next();){const e=t.value.link;e!==null&&(e.fromSpot=Spot.Default,e.toSpot=Spot.Default)}}commitNodes(){let t=0,i=0;if(this.arrangesToOrigin){const n=Rect.l();this.Nw(this.network,n);const o=this.arrangementOrigin;t=o.x-n.x,i=o.y-n.y,Rect.s(n)}const e=Rect.l(),s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;(t!==0||i!==0)&&(e.a(n.bounds),e.x+=t,e.y+=i,n.bounds=e),n.commit()}Rect.s(e)}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}springStiffness(t){const i=t.stiffness;return isNaN(i)?this.zf:i}springLength(t){const i=t.length;return isNaN(i)?this.Xf:i}electricalCharge(t){const i=t.charge;return isNaN(i)?this.Kf:i}electricalFieldX(t,i){return 0}electricalFieldY(t,i){return 0}gravitationalMass(t){const i=t.mass;return isNaN(i)?this.Yf:i}gravitationalFieldX(t,i){return 0}gravitationalFieldY(t,i){return 0}isFixed(t){return t.isFixed}get currentIteration(){return this.Dh}get arrangementSpacing(){return this.ks}set arrangementSpacing(t){this.ks.equals(t)||(this.ks.a(t),this.invalidateLayout())}get arrangesToOrigin(){return this.wg}set arrangesToOrigin(t){this.wg!==t&&(Util.i(t,"boolean",ForceDirectedLayout,"arrangesToOrigin"),this.wg=t,this.invalidateLayout())}get setsPortSpots(){return this.Fn}set setsPortSpots(t){this.Fn!==t&&(Util.i(t,"boolean",ForceDirectedLayout,"setsPortSpots"),this.Fn=t,this.invalidateLayout())}get comments(){return this.Re}set comments(t){this.Re!==t&&(Util.i(t,"boolean",ForceDirectedLayout,"comments"),this.Re=t,this.invalidateLayout())}get maxPrelayoutIterations(){return this.xg}set maxPrelayoutIterations(t){this.xg!==t&&(Util.i(t,"number",ForceDirectedLayout,"maxPrelayoutIterations"),t>=0&&(this.xg=t,this.invalidateLayout()))}get maxIterations(){return this.bg}set maxIterations(t){this.bg!==t&&(Util.i(t,"number",ForceDirectedLayout,"maxIterations"),t>=0&&(this.bg=t,this.invalidateLayout()))}get epsilonDistance(){return this.kg}set epsilonDistance(t){this.kg!==t&&(Util.i(t,"number",ForceDirectedLayout,"epsilonDistance"),t>0&&(this.kg=t,this.invalidateLayout()))}get infinityDistance(){return this.Vf}set infinityDistance(t){this.Vf!==t&&(Util.i(t,"number",ForceDirectedLayout,"infinityDistance"),t>1&&(this.Vf=t,this.invalidateLayout()))}get moveLimit(){return this.Pg}set moveLimit(t){this.Pg!==t&&(Util.i(t,"number",ForceDirectedLayout,"moveLimit"),this.Pg=t,this.invalidateLayout())}get randomNumberGenerator(){return this.Sg}set randomNumberGenerator(t){this.Sg!==t&&(t!==null&&typeof t.random!="function"&&Util.o('ForceDirectedLayout.randomNumberGenerator must have a "random()" function on it: '+t),this.Sg=t)}get defaultSpringStiffness(){return this.zf}set defaultSpringStiffness(t){this.zf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultSpringStiffness"),this.zf=t,this.invalidateLayout())}get defaultSpringLength(){return this.Xf}set defaultSpringLength(t){this.Xf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultSpringLength"),this.Xf=t,this.invalidateLayout())}get defaultElectricalCharge(){return this.Kf}set defaultElectricalCharge(t){this.Kf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultElectricalCharge"),this.Kf=t,this.invalidateLayout())}get defaultGravitationalMass(){return this.Yf}set defaultGravitationalMass(t){this.Yf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultGravitationalMass"),this.Yf=t,this.invalidateLayout())}get defaultCommentSpringLength(){return this.Mg}set defaultCommentSpringLength(t){this.Mg!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultCommentSpringLength"),this.Mg=t,this.invalidateLayout())}get defaultCommentElectricalCharge(){return this.Ng}set defaultCommentElectricalCharge(t){this.Ng!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultCommentElectricalCharge"),this.Ng=t,this.invalidateLayout())}get prelayoutQuality(){return this.Gf}set prelayoutQuality(t){this.Gf!==t&&(Util.i(t,"number",ForceDirectedLayout,"prelayoutQuality"),this.Gf=t,this.invalidateLayout())}get prelayoutSpread(){return this.Ja}set prelayoutSpread(t){this.Ja!==t&&(Util.i(t,"number",ForceDirectedLayout,"prelayoutSpread"),this.Ja=t,this.invalidateLayout())}}class ForceDirectedNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new ForceDirectedVertex(this)}createEdge(){return new ForceDirectedEdge(this)}}class ForceDirectedVertex extends LayoutVertex{K1;Y1;G1;j1;H1;hierarchicalVertexes;idInCluster;constructor(t){super(t),this.K1=!1,this.Y1=NaN,this.G1=NaN,this.j1=0,this.H1=0,this.hierarchicalVertexes=new List,this.idInCluster=-1}get isFixed(){return this.K1}set isFixed(t){this.K1!==t&&(Util.i(t,"boolean",ForceDirectedVertex,"isFixed"),this.K1=t)}get charge(){return this.Y1}set charge(t){this.Y1!==t&&(Util.i(t,"number",ForceDirectedVertex,"charge"),this.Y1=t)}get mass(){return this.G1}set mass(t){this.G1!==t&&(Util.i(t,"number",ForceDirectedVertex,"mass"),this.G1=t)}get forceX(){return this.j1}set forceX(t){this.j1!==t&&(Util.i(t,"number",ForceDirectedVertex,"forceX"),this.j1=t)}get forceY(){return this.H1}set forceY(t){this.H1!==t&&(Util.i(t,"number",ForceDirectedVertex,"forceY"),this.H1=t)}}class ForceDirectedEdge extends LayoutEdge{q1;W1;constructor(t){super(t),this.q1=NaN,this.W1=NaN}get stiffness(){return this.q1}set stiffness(t){this.q1!==t&&(Util.i(t,"number",ForceDirectedEdge,"stiffness"),this.q1=t)}get length(){return this.W1}set length(t){this.W1!==t&&(Util.i(t,"number",ForceDirectedEdge,"length"),this.W1=t)}}class RandomNumberGenerator{I;R;Q;M;A;seed;constructor(t){t===void 0&&(t=42),this.seed=t,this.A=48271,this.M=2147483647,this.Q=this.M/this.A,this.R=this.M%this.A,this.I=1/this.M,this.random()}random(){const t=this.seed/this.Q,i=this.seed%this.Q,e=this.A*i-this.R*t;return e>0?this.seed=e:this.seed=e+this.M,this.seed*this.I}}var LayeredDigraphCycleRemove=(w=>(w[w.DepthFirst=0]="DepthFirst",w[w.Greedy=1]="Greedy",w[w.FromLayers=2]="FromLayers",w))(LayeredDigraphCycleRemove||{}),LayeredDigraphLayering=(w=>(w[w.OptimalLinkLength=10]="OptimalLinkLength",w[w.LongestPathSink=11]="LongestPathSink",w[w.LongestPathSource=12]="LongestPathSource",w))(LayeredDigraphLayering||{}),LayeredDigraphInit=(w=>(w[w.DepthFirstOut=20]="DepthFirstOut",w[w.DepthFirstIn=21]="DepthFirstIn",w[w.Naive=22]="Naive",w))(LayeredDigraphInit||{}),LayeredDigraphAggressive=(w=>(w[w.None=30]="None",w[w.Less=31]="Less",w[w.More=32]="More",w))(LayeredDigraphAggressive||{}),LayeredDigraphPack=(w=>(w[w.None=0]="None",w[w.Expand=1]="Expand",w[w.Straighten=2]="Straighten",w[w.Median=4]="Median",w[w.MaybeExpand=8]="MaybeExpand",w[w.All=15]="All",w))(LayeredDigraphPack||{}),LayeredDigraphAlign=(w=>(w[w.None=0]="None",w[w.UpperLeft=1]="UpperLeft",w[w.UpperRight=2]="UpperRight",w[w.LowerLeft=4]="LowerLeft",w[w.LowerRight=8]="LowerRight",w[w.All=15]="All",w))(LayeredDigraphAlign||{});class LayeredDigraphLayout extends Layout{Ps;Ji;S;jf;Hf;qf;$a;Wf;nr;Jf;Fn;St;Xy;Kt;Cg;Ss;ui;Qs;Ms;Ns;Ut;Lg;Za;Ag;_s;$f;or;Rn;vn;ON;constructor(t){super(),this.Ps=25,this.Ji=25,this.S=0,this.jf=0,this.Hf=10,this.qf=20,this.$a=4,this.Wf=31,this.nr=15,this.Jf=10,this.Fn=!0,this.St=-1,this.Xy=-1,this.Kt=-1,this.Cg=0,this.Ss=0,this.ui=null,this.Qs=null,this.Ms=null,this.Ns=null,this.Ut=null,this.Lg=0,this.Za=null,this.Ag=null,this._s=0,this.$f=null,this.or=new Point,this.Rn=[],this.Rn.length=100,this.vn=15,this.ON=0,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Ps=this.Ps,t.Ji=this.Ji,t.S=this.S,t.jf=this.jf,t.Hf=this.Hf,t.qf=this.qf,t.$a=this.$a,t.Wf=this.Wf,t.nr=this.nr,t.Jf=this.Jf,t.Fn=this.Fn,t.vn=this.vn}ri(t){t in LayeredDigraphAggressive?this.aggressiveOption=t:t in LayeredDigraphCycleRemove?this.cycleRemoveOption=t:t in LayeredDigraphInit?this.initializeOption=t:t in LayeredDigraphLayering?this.layeringOption=t:super.ri(t)}createNetwork(){return new LayeredDigraphNetwork(this)}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin),this.YO(),this.network.vertexes.count>0&&(this.network.deleteSelfEdges(),this.cycleRemoveOption!==2&&this.removeCycles(),this.GO(),this.cycleRemoveOption===2&&this.removeCycles(),this.jO(),this.HO(),this.qO(),this.reduceCrossings(),this.straightenAndPack(),this.updateParts()),this.network=null,this.isValidLayout=!0}linkMinLength(t){return 1}linkLengthWeight(t){return 1}linkStraightenWeight(t){const i=t.fromVertex.node||t.fromVertex.data,e=t.toVertex.node||t.toVertex.data;return i===null&&e===null?8:i===null||e===null?4:1}nodeMinLayerSpace(t,i){return t.node===null&&t.data===null?0:this.S===90||this.S===270?i?t.focus.y+10:t.bounds.height-t.focus.y+10:i?t.focus.x+10:t.bounds.width-t.focus.x+10}nodeMinColumnSpace(t,i){if(t.node===null&&t.data===null)return 0;const e=i?t.J1:t.$1;if(e!==null)return e;const s=this.S;return s===90||s===270?i?t.J1=t.focus.x/this.Ji+1|0:t.$1=(t.bounds.width-t.focus.x)/this.Ji+1|0:i?t.J1=t.focus.y/this.Ji+1|0:t.$1=(t.bounds.height-t.focus.y)/this.Ji+1|0}$i(){this.Za===null&&(this.Za=[]);let t=0;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;this.Za[t]=e.layer,t++,this.Za[t]=e.column,t++,this.Za[t]=e.index,t++}return this.Za}Ze(t){let i=0;const e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;s.layer=t[i],i++,s.column=t[i],i++,s.index=t[i],i++}}JT(t,i){const e=this.Fh(t),s=this.ui[t];(this.Ag===null||this.Ag.length=0){for(c=e[o].po,f=0;fk||d===k&&g>P)&&r++,bd||k===d&&P>g)&&r++)}if(i<=0){for(c=e[o].ir,f=0;fk||d===k&&m>b)&&r++,Pd||k===d&&b>m)&&r++)}for(n[o*s+o]=r,a=o+1;a=0){for(p=e[o].po,S=e[a].po,f=0;f=0&&(h=s[r].ir);let a,c=0,f=0;if(l!==null)for(let u=0;u=0&&(h=r.ir);let a=0,c=0;const f=r.near;f!==null&&f.layer===r.layer&&(a+=f.column-1,c++);let u;if(l!==null)for(let d=0;d=0&&(h=r.ir);let a=0;const c=[],f=r.near;f!==null&&f.layer===r.layer&&(c[a]=f.column-1,a++);let u;if(l!==null)for(let d=0;dm-g);const d=a>>1;a&1?n[o]=c[d]:n[o]=c[d-1]+c[d]>>1}}return this.Rh(t,e),n}Gy(t,i,e,s,n){if(t.component===e){t.component=i;let o=0,r=0;if(s){const l=t.destinationEdges;for(;l.next();){const h=l.value,a=h.toVertex;o=t.layer-a.layer,r=this.linkMinLength(h),o===r&&this.Gy(a,i,e,s,n)}}if(n){const l=t.sourceEdges;for(;l.next();){const h=l.value,a=h.fromVertex;o=a.layer-t.layer,r=this.linkMinLength(h),o===r&&this.Gy(a,i,e,s,n)}}}}IN(t,i,e,s,n){if(t.component===e){if(t.component=i,s){const o=t.destinationEdges;for(;o.next();){const l=o.value.toVertex;this.IN(l,i,e,s,n)}}if(n){const o=t.sourceEdges;for(;o.next();){const l=o.value.fromVertex;this.IN(l,i,e,s,n)}}}}removeCycles(){const t=this.network.edges.iterator;for(;t.next();){const i=t.value;i.rev=!1}switch(this.jf){default:case 1:this.JO();break;case 0:this.$O();break;case 2:this.ZO();break}}ZO(){const t=this.network,i=t.vertexes.iterator;let e=1/0;for(;i.next();){const s=i.value;e=Math.min(e,s.layer)}if(e<1/0){if(e<0)for(i.reset();i.next();){const r=i.value;r.layer-=e}const s=[];for(i.reset();i.next();){const r=i.value,l=s[r.layer];l===void 0?s[r.layer]=[r]:l.push(r)}let n=0;for(let r=0;r0)for(let h=0;hh.index&&(t.reverseEdge(r),r.rev=!0)}}QO(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.Zi)return e}return null}ZT(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.Zi){let s=!0;const n=e.destinationEdges;for(;n.next();)if(n.value.toVertex.Zi){s=!1;break}if(s)return e}}return null}QT(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.Zi){let s=!0;const n=e.sourceEdges;for(;n.next();)if(n.value.fromVertex.Zi){s=!1;break}if(s)return e}}return null}_O(t){let i=null,e=0;const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;if(n.Zi){let o=0;const r=n.destinationEdges;for(;r.next();)r.value.toVertex.Zi&&o++;let l=0;const h=n.sourceEdges;for(;h.next();)h.value.fromVertex.Zi&&l++;(i===null||ec&&this.Gy(h,e,-1,!0,!1)}for(this.Gy(t,s,-1,!0,!0);t.component!==e;){let r=0,l=1/0,h=0,a=null;const c=this.network.vertexes.iterator;for(;c.next();){const f=c.value;if(f.component===s){let u=0,d=!1;const m=f.po;o=m.length;for(let p=0;p0){for(i.reset();i.next();){const f=i.value;f.component===s&&(f.layer+=l)}t.component=e}else a.component=e}}sI(t){const i=this.network.vertexes.iterator;for(;i.next();){const n=i.value;n.component=-1}const e=0,s=1;for(this.Gy(t,s,-1,!0,!1);t.component!==e;){let n=0,o=1/0,r=0,l=null;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value;if(a.component===s){let c=0,f=!1;const u=a.po;let d=u.length;for(let g=0;gr)&&!f&&(l=a,r=c)}}if(n<0){for(i.reset();i.next();){const a=i.value;a.component===s&&(a.layer-=o)}t.component=e}else l.component=e}}jO(){const t=this.network,i=[],e=t.edges.iterator;for(;e.next();){const s=e.value;s.valid=!1,i.push(s)}for(let s=0;sb&&f>0){for(n.valid=!1,y=t.createVertex(),y.node=null,y.Q1=2,y.layer=f-1,x&&kb&&f>0;)y=t.createVertex(),y.node=null,y.Q1=3,y.layer=f-1,x&&kt[this.Ss]&&(this.Xy=t[e]-1,this.Ss=e),t[e]{o.index=this.ui[s],this.ui[s]++})}}lI(){let t=null;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;if(e.near&&(t===null&&(t=new Map),e.layer===e.near.layer)){const s=t.get(e.near)||[];s.push(e),t.set(e.near,s)}}for(let e=this.St;e>=0;e--)for(i.reset();i.next();){const s=i.value;s.layer===e&&s.index===-1&&this.oD(s,t)}}oD(t,i){if(t.near)return;const e=t.layer;if(t.index=this.ui[e],this.ui[e]++,i){const o=i.get(t);Array.isArray(o)&&o.forEach(r=>{r.index=this.ui[e],this.ui[e]++})}const s=t.ir;let n=!0;for(;n;){n=!1;for(let o=0;ol.portFromColOffset&&(n=!0,s[o]=l,s[o+1]=r)}}for(let o=0;o{a.index=this.ui[e],this.ui[e]++})}const s=t.po;let n=!0,o=0;for(;n;)for(n=!1,o=0;oa.portToColOffset&&(n=!0,s[o]=a,s[o+1]=h)}let r,l;for(o=0;o=0;s--)this.tk(s,-1),this.ls(s,-1,!1,-1);n=this.countCrossings(),n=0;s--)this.tk(s,0),this.ls(s,0,!1,0);n=this.countCrossings(),n=0;r--)for(l=0;l<=r;l++){for(o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,1,!1,1)||o;for(n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,-1,!1,-1)||o;for(n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,0,!1,0)||o;for(n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,0,!1,0)||o;n>=t?this.Ze(i):(t=n,i=this.$i())}break;default:case 31:for(r=this.St,l=0,h=t+1;(a=this.countCrossings())=l;s--)o=this.ls(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,1,!1,1)||o;for(n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,-1,!1,-1)||o;for(n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,0,!1,0)||o;for(n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,0,!1,0)||o;n>=t?this.Ze(i):(t=n,i=this.$i())}break}this.Ze(i)}tk(t,i){let e=0,s=!1;const n=this.Fh(t),o=this.ui[t],r=this.$T(t,i),l=this.Yy(t,i);for(e=0;e0)for(h=[],l=0;ll+1&&(m+=4*(v-l),g+=4*(v-(l+1)))}}const E=n[l].destinationEdges.iterator;if(e&&s>=0)for(;E.next();){const q=E.value;O=q.toVertex,q.valid&&O.layer!==t&&(N=this.linkStraightenWeight(q),T=q.portFromColOffset,A=q.portToColOffset,F=O.column,C+=(Math.abs(p+T-(F+A))+1)*N,M+=(Math.abs(L+T-(F+A))+1)*N)}for(E.reset();E.next();){const q=E.value;if(O=q.toVertex,q.valid&&O.layer===t){for(B=0;Bl+1&&(m+=4*(v-(l+1)),g+=4*(v-l))}}const U=n[l+1].destinationEdges.iterator;if(e&&s>=0)for(;U.next();){const q=U.value;O=q.toVertex,q.valid&&O.layer!==t&&(N=this.linkStraightenWeight(q),T=q.portFromColOffset,A=q.portToColOffset,F=O.column,C+=(Math.abs(y+T-(F+A))+1)*N,M+=(Math.abs(S+T-(F+A))+1)*N)}for(U.reset();U.next();){const q=U.value;if(O=q.toVertex,q.valid&&O.layer===t){for(B=0;B1e3&&s&&(e=!1),e){const n=[];let o=0;for(o=0;o<=this.St;o++)n[o]=0;let r=0;const l=this.network.vertexes.iterator;for(;l.next();){const a=l.value;t=a.layer,r=a.column;const c=this.nodeMinColumnSpace(a,!1);n[t]=Math.max(n[t],r+c)}const h=8;for(l.reset();l.next();){const a=l.value;t=a.layer,r=a.column,a.column=((this.Kt-n[t])*h>>1)+r*h}this.Kt*=h}if(this.nr&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Tg(t,-1)||i;i=this.Tg(this.Ss,0)||i,n++}}if(this.nr&4){for(t=this.Ss+1;t<=this.St;t++)this.BN(t,1);for(t=this.Ss-1;t>=0;t--)this.BN(t,-1);this.BN(this.Ss,0)}if(e&&(this.lD(-1),this.lD(1)),this.nr&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Tg(t,0)||i;n++}}}Tg(t,i){let e=!1;for(;this.cI(t,i);)e=!0;return e}cI(t,i){let e=0;const s=this.Fh(t),n=this.ui[t],o=this.Yy(t,-1);if(i>0)for(e=0;ec+this.nodeMinColumnSpace(s[e-1],!1)?u=a-1:u=a;let d=0;e+1>=n||s[e+1].column-a-1>f+this.nodeMinColumnSpace(s[e+1],!0)?d=a+1:d=a;let m=0,g=0,p=0,y=0,x=0,k=0;if(i<=0){const M=s[e].sourceEdges.iterator;for(;M.next();){const N=M.value,T=N.fromVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const A=T.column;m+=(Math.abs(a+k-(A+x))+1)*y,g+=(Math.abs(u+k-(A+x))+1)*y,p+=(Math.abs(d+k-(A+x))+1)*y}}}if(i>=0){const M=s[e].destinationEdges.iterator;for(;M.next();){const N=M.value,T=N.toVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const A=T.column;m+=(Math.abs(a+x-(A+k))+1)*y,g+=(Math.abs(u+x-(A+k))+1)*y,p+=(Math.abs(d+x-(A+k))+1)*y}}}let b=0,P=0,S=0;const L=o[s[e].index],C=r[s[e].index];L!==-1&&(b+=Math.abs(L-a),P+=Math.abs(L-u),S+=Math.abs(L-d)),C!==-1&&(b+=Math.abs(C-a),P+=Math.abs(C-u),S+=Math.abs(C-d)),g=r[e]?u=p:g<=r[e]&&(u=g)),u!==a&&(l=!0,h=!0,s[e].column=u)}return this.Rh(t,s),this.Ky(),l}fI(){for(let t=0;t<=this.Kt;t++)for(;this.uI(t,1););this.Ky()}uI(t,i){let e=!0;const s=this.network.vertexes.iterator;for(;s.next();){const o=s.value,r=this.nodeMinColumnSpace(o,!0),l=this.nodeMinColumnSpace(o,!1);if(o.column-r<=t&&o.column+l>=t){e=!1;break}}let n=!1;if(e){if(i>0)for(s.reset();s.next();){const o=s.value;o.column>t&&(o.column-=1,n=!0)}if(i<0)for(s.reset();s.next();){const o=s.value;o.column0&&(e=t+1),i<0&&(e=t-1);let s=0;const n=[],o=[];for(s=0;s<=this.St;s++)n[s]=!1,o[s]=!1;const r=this.network.vertexes.iterator;for(;r.next();){const a=r.value,c=a.column-this.nodeMinColumnSpace(a,!0),f=a.column+this.nodeMinColumnSpace(a,!1);c<=t&&f>=t&&(n[a.layer]=!0),c<=e&&f>=e&&(o[a.layer]=!0)}let l=!0,h=!1;for(s=0;s<=this.St;s++)l=l&&!(n[s]&&o[s]);if(l){if(i>0)for(r.reset();r.next();){const a=r.value;a.column>t&&(a.column-=1,h=!0)}if(i<0)for(r.reset();r.next();){const a=r.value;a.column0)for(i=0;i<=this.Kt;i++)for(e=this.$i(),s=this.Z1(!0),n=s+1;ss?this.Ze(e):o=0;i--)for(e=this.$i(),s=this.Z1(!0),n=s+1;ss?this.Ze(e):o0)for(e.reset();e.next();){const c=e.value;c.column-this.nodeMinColumnSpace(c,!0)<=t&&(c.component=this._s)}if(i<0)for(e.reset();e.next();){const c=e.value;c.column+this.nodeMinColumnSpace(c,!1)>=t&&(c.component=this._s)}for(this._s++,e.reset();e.next();){const c=e.value;c.component===-1&&(this.IN(c,this._s,-1,!0,!0),this._s++)}let s=0;const n=[];for(s=0;s0)for(let f=0;f0;f--)o[c*(this.Kt+1)+f]!==-1&&o[c*(this.Kt+1)+f-1]!==-1&&o[c*(this.Kt+1)+f]!==o[c*(this.Kt+1)+f-1]&&(n[o[c*(this.Kt+1)+f]*this._s+o[c*(this.Kt+1)+f-1]]=!0)}const r=[];for(s=0;s0)for(e.reset();e.next();){const c=e.value;r[c.component]&&(c.column-=1,a=!0)}if(i<0)for(e.reset();e.next();){const c=e.value;r[c.component]&&(c.column+=1,a=!0)}return a}aI(){const t=Util.nt(),i=this.$f.length;for(let u=0;u<=i;u++)t[u]=[];const e=this.network.vertexes.iterator;for(;e.next();){const u=e.value,d=i-u.layer,m=t[d];m[u.index]=u}const s=new GSet;this.mI(t,s);let n=null,o=null,r=null,l=null;const h=(this.vn&1)!==0,a=(this.vn&2)!==0,c=(this.vn&4)!==0,f=(this.vn&8)!==0;h&&(this.sl(t,s,!0),n=this.ik(t,!0,!1)),t.reverse(),c&&(this.sl(t,s,!1),r=this.ik(t,!1,!1));for(const u of t)u.reverse();f&&(this.sl(t,s,!1),l=this.ik(t,!1,!0)),t.reverse(),a&&(this.sl(t,s,!0),o=this.ik(t,!0,!0)),Util.tt(t),this.pI(n,o,r,l),this.network.vertexes.each(u=>{const d=u,m=Util.nt();h&&m.push(n.get(d)),a&&m.push(o.get(d)),c&&m.push(r.get(d)),f&&m.push(l.get(d)),m.sort((k,b)=>k-b);const g=m.length,p=Math.floor((g-1)/2),y=Math.ceil((g-1)/2),x=(m[p]+m[y])/2;Util.tt(m),d.he=x})}mI(t,i){const e=t.length;for(let s=1;sf)&&i.add(m)}o++}n=f}}}}yI(t){if(t.node===null){const i=t.getProperSourceVertexes();if(i.length>0)return i[0].node===null}return!1}sl(t,i,e){this.wI(t);for(const s of t){let n=-1;for(const o of s){const r=e?o.getProperSourceVertexes():o.getProperDestinationVertexes(),l=r.length;if(l>0){r.sort((a,c)=>a.vh-c.vh);const h=(l-1)/2;for(let a=Math.floor(h),c=Math.ceil(h);a<=c;a++)if(o.On===o){const f=r[a];let u;e?u=f.getDestinationEdge(o):u=o.getDestinationEdge(f),!i.has(u)&&n0){const c=this.fD(a,t),f=s?c.width:c.height,u=a.Qe.Qf+a.he+a.In-(c.he+c.In+f+this.columnSpacing);c.Qe.Qf=Math.min(c.Qe.Qf,u)}h=a.vh+1}while(l0){const s=this.fD(e,i),n=s.Qa;this.cD(n,i),t.Qe===t&&(t.Qe=n.Qe);const o=this.S===90||this.S===270?s.width:s.height;if(t.Qe===n.Qe){const r=n.he+s.In+o-e.In+this.columnSpacing;t.he=Math.max(t.he,r)}}e=e.On}while(e!==t);for(;e.On!==t;)e=e.On,e.he=t.he,e.Qe=t.Qe}fD(t,i){const e=t.aD,s=t.vh;return s<1&&Util.o("Could not determine previous vertex in layer"),i[e][s-1]}pI(...t){let i=-1;const e=Util.nt(),s=Util.nt();let n=1/0;for(let o=0;o<4;o++){if(!t[o])continue;const r=this.bI(t[o],e,s,o);r{r.set(h.key,h.value+l)})}Util.tt(e),Util.tt(s)}bI(t,i,e,s){if(!t||t.count===0)return i[s]=0,e[s]=0,1/0;let n=1/0,o=-1/0;return t.each(r=>{const l=r.key,h=r.value,a=this.S===90||this.S===270?l.width:l.height;ho&&(o=h+a)}),i[s]=n,e[s]=o,o-n}commitLayout(){this.zy(),this.commitNodes(),this.UN(),this.isRouting&&this.commitLinks()}zy(){if(!this.setsPortSpots)return;const t=this._1(!0),i=this._1(!1),e=this.network.edges.iterator;for(;e.next();){const n=e.value.link;n!==null&&(n.fromSpot=t,n.toSpot=i)}}_1(t){return this.S===270?t?Spot.MiddleTop:Spot.MiddleBottom:this.S===90?t?Spot.MiddleBottom:Spot.MiddleTop:this.S===180?t?Spot.MiddleLeft:Spot.MiddleRight:t?Spot.MiddleRight:Spot.MiddleLeft}commitNodes(){this.Qs=[],this.Ms=[],this.Ns=[],this.Ut=[];for(let d=0;d<=this.St;d++)this.Qs[d]=0,this.Ms[d]=0,this.Ns[d]=0,this.Ut[d]=0;const t=this.network.vertexes.iterator;for(;t.next();){const d=t.value,m=d.layer;this.Qs[m]=Math.max(this.Qs[m],this.nodeMinLayerSpace(d,!0)),this.Ms[m]=Math.max(this.Ms[m],this.nodeMinLayerSpace(d,!1))}let i=0;const e=this.Ps;for(let d=0;d<=this.St;d++){let m=e;this.Qs[d]+this.Ms[d]<=0&&(m=0),d>0&&(i+=m/2),this.S===90||this.S===0?(i+=this.Ms[d],this.Ns[d]=i,i+=this.Qs[d]):(i+=this.Qs[d],this.Ns[d]=i,i+=this.Ms[d]),d=0;n--)this.S===270?n===0?e.push(new Rect(0,0,s,Math.abs(this.Ut[0]))):e.push(new Rect(0,this.Ut[n-1],s,Math.abs(this.Ut[n-1]-this.Ut[n]))):this.S===90?n===0?e.push(new Rect(0,this.Ut[0],s,Math.abs(this.Ut[0]-t))):e.push(new Rect(0,this.Ut[n],s,Math.abs(this.Ut[n-1]-this.Ut[n]))):this.S===180?n===0?e.push(new Rect(0,0,Math.abs(this.Ut[0]),s)):e.push(new Rect(this.Ut[n-1],0,Math.abs(this.Ut[n-1]-this.Ut[n]),s)):n===0?e.push(new Rect(this.Ut[0],0,Math.abs(this.Ut[0]-t),s)):e.push(new Rect(this.Ut[n],0,Math.abs(this.Ut[n-1]-this.Ut[n]),s));this.commitLayers(e,this.or)}commitLayers(t,i){}commitLinks(){const t=this.network.edges.iterator;let i;for(;t.next();)i=t.value.link,i!==null&&(i.startRoute(),i.clearPoints(),i.commitRoute());for(t.reset();t.next();)i=t.value.link,i!==null&&i.updateRoute();for(t.reset();t.next();){const e=t.value;if(i=e.link,i===null||i.pointsCount===0)continue;i.startRoute();const s=i;let n=s.fromNode,o=s.toNode,r=s.fromPort,l=s.toPort;if(n!==null){const N=n.findVisibleNode();N!==null&&N!==n&&(n=N,r=N.port)}if(o!==null){const N=o.findVisibleNode();N!==null&&N!==o&&(o=N,l=N.port)}const h=i.computeSpot(!0,r),a=i.computeSpot(!1,l);let c=e.fromVertex,f=e.toVertex;if(e.valid){if(i.curve===9&&i.pointsCount===4)if(c.column===f.column&&this.alignOption===0){const N=i.getLinkPoint(n,r,h,!0,!1,o,l),T=i.getLinkPoint(o,l,a,!1,!1,n,r);N.isReal()||N.set(n.actualBounds.center),T.isReal()||T.set(o.actualBounds.center),i.clearPoints(),i.addPointAt(N.x,N.y),i.addPointAt((2*N.x+T.x)/3,(2*N.y+T.y)/3),i.addPointAt((N.x+2*T.x)/3,(N.y+2*T.y)/3),i.addPointAt(T.x,T.y)}else{let N=!1,T=!1;if(r!==null&&h===Spot.None&&(N=!0),l!==null&&a===Spot.None&&(T=!0),N||T){let A=null;N&&(A=i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0),A.isReal()||A.set(n.actualBounds.center),i.setPointAt(0,A.x,A.y));let D=null;if(T&&(D=i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(0),!1),D.isReal()||D.set(o.actualBounds.center),i.setPointAt(3,D.x,D.y)),A){const F=i.getPoint(2);i.setPointAt(1,(A.x*2+F.x)/3,(A.y*2+F.y)/3)}if(D){const F=i.getPoint(1);i.setPointAt(2,(D.x*2+F.x)/3,(D.y*2+F.y)/3)}}}i.commitRoute();continue}if(c.layer===f.layer){i.commitRoute();continue}let u=!1,d=!1;const m=this.Ps;let g=0,p=i.firstPickIndex+1;if(i.isOrthogonal)d=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3);else if(i.curve===9)u=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3),g===4&&(p=2);else{g=i.pointsCount;const N=h===Spot.None,T=a===Spot.None;g>2&&N&&T?i.points.removeRange(1,g-2):g>3&&N&&!T?i.points.removeRange(1,g-3):g>3&&!N&&T?i.points.removeRange(2,g-2):g>4&&!N&&!T&&i.points.removeRange(2,g-3)}let y,x,k=0,b=0,P=0,S=0,L=0,C=0,M=0;if(e.rev){let N=0;for(;f!==null&&c!==f;){y=null,x=null;const T=f.sourceEdges.iterator;for(;T.next();){const A=T.value;if(A.link===e.link&&(y=A.fromVertex,x=A.toVertex,y.node===null))break}if(y===null)break;if(y!==c)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=y.centerX,S=y.centerY,d)this.S===180||this.S===0?p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,k,S)):(x!==null?x.centerY:b)!==S&&(L=this.Ut[y.layer-1]+this.or.x,i.insertPointAt(p++,L,b),i.insertPointAt(p++,L,S)):p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,P,b)):(x!==null?x.centerX:k)!==P&&(L=this.Ut[y.layer-1]+this.or.y,i.insertPointAt(p++,k,L),i.insertPointAt(p++,P,L));else if(p===i.firstPickIndex+1)if(C=Math.max(10,this.Qs[f.layer]),M=Math.max(10,this.Ms[f.layer]),u)this.S===180?P<=f.bounds.x?(N=f.bounds.x,i.insertPointAt(p++,N-C,S),i.insertPointAt(p++,N,S),i.insertPointAt(p++,N+M,S)):(i.insertPointAt(p++,P-C,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P+M,S)):this.S===90?S>=f.bounds.bottom?(N=f.bounds.y+f.bounds.height,i.insertPointAt(p++,P,N+M),i.insertPointAt(p++,P,N),i.insertPointAt(p++,P,N-C)):(i.insertPointAt(p++,P,S+M),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S-C)):this.S===270?S<=f.bounds.y?(N=f.bounds.y,i.insertPointAt(p++,P,N-C),i.insertPointAt(p++,P,N),i.insertPointAt(p++,P,N+M)):(i.insertPointAt(p++,P,S-C),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S+M)):this.S===0&&(P>=f.bounds.right?(N=f.bounds.x+f.bounds.width,i.insertPointAt(p++,N+M,S),i.insertPointAt(p++,N,S),i.insertPointAt(p++,N-C,S)):(i.insertPointAt(p++,P+M,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P-C,S)));else{i.insertPointAt(p++,k,b);let A=0;this.S===180||this.S===0?((this.S===180?P>=f.bounds.right:P<=f.bounds.x)&&(A=(this.S===0?-C:M)/2),i.insertPointAt(p++,k+A,S)):((this.S===270?S>=f.bounds.bottom:S<=f.bounds.y)&&(A=(this.S===90?-C:M)/2),i.insertPointAt(p++,P,b+A)),i.insertPointAt(p++,P,S)}else C=Math.max(10,this.Qs[y.layer]),M=Math.max(10,this.Ms[y.layer]),u?this.S===180?(i.insertPointAt(p++,P-C-m,S),i.insertPointAt(p++,Math.min(P-C+m/2,P),S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,Math.max(P+M-m/2,P),S),i.insertPointAt(p++,P+M+m,S)):this.S===90?(i.insertPointAt(p++,P,S+M+m),i.insertPointAt(p++,P,Math.max(S+M-m/2,S)),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,Math.min(S-C+m/2,S)),i.insertPointAt(p++,P,S-C-m)):this.S===270?(i.insertPointAt(p++,P,S-C-m),i.insertPointAt(p++,P,Math.min(S-C+m/2,S)),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,Math.max(S+M-m/2,S)),i.insertPointAt(p++,P,S+M+m)):(i.insertPointAt(p++,P+M+m,S),i.insertPointAt(p++,Math.max(P+M-m/2,P),S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,Math.min(P-C+m/2,P),S),i.insertPointAt(p++,P-C-m,S)):(this.S===180||this.S===90||this.S,i.insertPointAt(p++,P,S));f=y}if(l===null||h!==Spot.None||d)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=i.getPoint(p).x,S=i.getPoint(p).y,d){const T=this.Ms[c.layer];let A=0;this.S===180||this.S===0?(A=b,A>=c.bounds.y&&A<=c.bounds.bottom&&(this.S===180?P>=c.bounds.x:P<=c.bounds.right)&&(N=c.centerX+(this.S===180?-T:T),A=c.bounds.x&&A<=c.bounds.right&&(this.S===270?S>=c.bounds.y:S<=c.bounds.bottom)&&(N=c.centerY+(this.S===270?-T:T),A=c.bounds.x?(N=c.bounds.x+c.bounds.width,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N+M,b)):this.S===90&&S<=c.bounds.bottom?(N=c.bounds.y,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N-C)):this.S===270&&S>=c.bounds.y?(N=c.bounds.y+c.bounds.height,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N+M)):this.S===0&&P<=c.bounds.right&&(N=c.bounds.x,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N-C,b));else{C=Math.max(10,this.Qs[c.layer]),M=Math.max(10,this.Ms[c.layer]);let T=0;this.S===180||this.S===0?((this.S===180?P<=c.bounds.x:P>=c.bounds.right)&&(T=(this.S===0?M:-C)/2),i.insertPointAt(p++,P+T,b)):((this.S===270?S<=c.bounds.y:S>=c.bounds.bottom)&&(T=(this.S===90?M:-C)/2),i.insertPointAt(p++,k,S+T)),i.insertPointAt(p++,P,S)}}else{for(;c!==null&&c!==f;){y=null,x=null;const N=c.destinationEdges.iterator;for(;N.next();){const T=N.value;if(T.link===e.link&&(y=T.toVertex,x=T.fromVertex,x.node!==null&&(x=null),y.node===null))break}if(y===null)break;y!==f&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=y.centerX,S=y.centerY,d?this.S===180||this.S===0?(x!==null?x.centerY:b)!==S&&(L=this.Ut[y.layer]+this.or.x,p===i.firstPickIndex+1&&(this.S===0?L=Math.max(L,k):L=Math.min(L,k)),i.insertPointAt(p++,L,b),i.insertPointAt(p++,L,S)):(x!==null?x.centerX:k)!==P&&(L=this.Ut[y.layer]+this.or.y,p===i.firstPickIndex+1&&(this.S===90?L=Math.max(L,b):L=Math.min(L,b)),i.insertPointAt(p++,k,L),i.insertPointAt(p++,P,L)):(C=Math.max(10,this.Qs[y.layer]),M=Math.max(10,this.Ms[y.layer]),u?this.S===180?(i.insertPointAt(p++,P+M+m,S),i.insertPointAt(p++,Math.max(P+M-m/2,P),S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,Math.min(P-C+m/2,P),S),i.insertPointAt(p++,P-C-m,S)):this.S===90?(i.insertPointAt(p++,P,S-C-m),i.insertPointAt(p++,P,Math.min(S-C+m/2,S)),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,Math.max(S+M-m/2,S)),i.insertPointAt(p++,P,S+M+m)):this.S===270?(i.insertPointAt(p++,P,S+M+m),i.insertPointAt(p++,P,Math.max(S+M-m/2,S)),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,Math.min(S-C+m/2,S)),i.insertPointAt(p++,P,S-C-m)):(i.insertPointAt(p++,P-C-m,S),i.insertPointAt(p++,Math.min(P-C+m/2,P),S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,Math.max(P+M-m/2,P),S),i.insertPointAt(p++,P+M+m,S)):this.S===180?(i.insertPointAt(p++,P+M,S),i.insertPointAt(p++,P-C,S)):this.S===90?(i.insertPointAt(p++,P,S-C),i.insertPointAt(p++,P,S+M)):this.S===270?(i.insertPointAt(p++,P,S+M),i.insertPointAt(p++,P,S-C)):(i.insertPointAt(p++,P-C,S),i.insertPointAt(p++,P+M,S)))),c=y}d&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=i.getPoint(p).x,S=i.getPoint(p).y,this.S===180||this.S===0?b!==S&&(this.S===0?L=Math.min(Math.max((P+k)/2,this.Ut[f.layer]+this.or.x),P):L=Math.max(Math.min((P+k)/2,this.Ut[f.layer]+this.or.x),P),i.insertPointAt(p++,L,b),i.insertPointAt(p++,L,S)):k!==P&&(this.S===90?L=Math.min(Math.max((S+b)/2,this.Ut[f.layer]+this.or.y),S):L=Math.max(Math.min((S+b)/2,this.Ut[f.layer]+this.or.y),S),i.insertPointAt(p++,k,L),i.insertPointAt(p++,P,L)))}if(s!==null&&u&&i.pointsCount>=4){if(r!==null){const N=h===Spot.None?i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0):i.getPoint(0);if(h===Spot.None){const T=i.getPoint(2),A=i.getPoint(3);this.direction===90||this.direction===270?(i.setPointAt(1,(N.x+T.x)/2,T.y),i.setPointAt(2,A.x,(T.y+A.y)/2)):(i.setPointAt(1,T.x,(N.y+T.y)/2),i.setPointAt(2,(T.x+A.x)/2,A.y))}N.isReal()||N.set(n.actualBounds.center),i.setPointAt(0,N.x,N.y)}if(l!==null){const N=a===Spot.None?i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(i.pointsCount-4),!1):i.getPoint(i.pointsCount-1);if(a===Spot.None){const T=i.getPoint(i.pointsCount-3),A=i.getPoint(i.pointsCount-4);this.direction===90||this.direction===270?(i.setPointAt(i.pointsCount-2,(N.x+T.x)/2,T.y),i.setPointAt(i.pointsCount-2,A.x,(T.y+A.y)/2)):(i.setPointAt(i.pointsCount-2,T.x,(N.y+T.y)/2),i.setPointAt(i.pointsCount-3,(T.x+A.x)/2,A.y))}N.isReal()||N.set(o.actualBounds.center),i.setPointAt(i.pointsCount-1,N.x,N.y)}}i.commitRoute(),e.commit()}}YO(){this.Xy=-1,this.Cg=0,this.Ss=0,this.Za=null,this.Ag=null,this.$f=null;for(let t=0;t=this.Rn.length){const n=[];for(let o=0;o=0&&(this.Ps=t,this.invalidateLayout()))}get columnSpacing(){return this.Ji}set columnSpacing(t){this.Ji!==t&&(Util.i(t,"number",LayeredDigraphLayout,"columnSpacing"),t>0&&(this.Ji=t,this.invalidateLayout()))}get direction(){return this.S}set direction(t){this.S!==t&&(Util.i(t,"number",LayeredDigraphLayout,"direction"),t===0||t===90||t===180||t===270?(this.S=t,this.invalidateLayout()):Util.o("LayeredDigraphLayout.direction must be 0, 90, 180, or 270"))}get cycleRemoveOption(){return this.jf}set cycleRemoveOption(t){this.jf!==t&&(t===1||t===0||t===2)&&(this.jf=t,this.invalidateLayout())}get layeringOption(){return this.Hf}set layeringOption(t){this.Hf!==t&&(t===10||t===11||t===12)&&(this.Hf=t,this.invalidateLayout())}get initializeOption(){return this.qf}set initializeOption(t){this.qf!==t&&(t===20||t===21||t===22)&&(this.qf=t,this.invalidateLayout())}get iterations(){return this.$a}set iterations(t){this.$a!==t&&t>=0&&(this.$a=t,this.invalidateLayout())}get aggressiveOption(){return this.Wf}set aggressiveOption(t){this.Wf!==t&&(t===30||t===31||t===32)&&(this.Wf=t,this.invalidateLayout())}get packOption(){return this.nr}set packOption(t){this.nr!==t&&(Util.i(t,"number",LayeredDigraphLayout,"packOption"),t>=0&&t<8&&(this.nr=t,this.invalidateLayout()))}get packIterations(){return this.Jf}set packIterations(t){this.Jf=t}get alignOption(){return this.vn}set alignOption(t){this.vn!==t&&(Util.i(t,"number",LayeredDigraphLayout,"align"),t>=0&&t<16&&(this.vn=t,this.invalidateLayout()))}get setsPortSpots(){return this.Fn}set setsPortSpots(t){this.Fn!==t&&(Util.i(t,"boolean",LayeredDigraphLayout,"setsPortSpots"),this.Fn=t,this.invalidateLayout())}get maxLayer(){return this.St}get maxIndex(){return this.Xy}get maxColumn(){return this.Kt}get minIndexLayer(){return this.Cg}get maxIndexLayer(){return this.Ss}static CycleDepthFirst=0;static CycleGreedy=1;static CycleFromLayers=2;static LayerOptimalLinkLength=10;static LayerLongestPathSink=11;static LayerLongestPathSource=12;static InitDepthFirstOut=20;static InitDepthFirstIn=21;static InitNaive=22;static AggressiveNone=30;static AggressiveLess=31;static AggressiveMore=32;static PackNone=0;static PackExpand=1;static PackStraighten=2;static PackMedian=4;static PackAll=15;static AlignNone=0;static AlignUpperLeft=1;static AlignUpperRight=2;static AlignLowerLeft=4;static AlignLowerRight=8;static AlignAll=15}class LayeredDigraphNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new LayeredDigraphVertex(this)}createEdge(){return new LayeredDigraphEdge(this)}}class LayeredDigraphVertex extends LayoutVertex{Wo;Uo;Dt;ek;sk;Zi;Zf;jn;Q1;J1;$1;Qa;On;aD;vh;Qe;Qf;he;In;jy=null;Hy=null;qy=null;Wy=null;constructor(t){super(t),this.Wo=-1,this.Uo=-1,this.Dt=-1,this.ek=NaN,this.sk=null,this.Zi=!1,this.Zf=NaN,this.jn=NaN,this.Q1=0,this.J1=null,this.$1=null}static uD(t,i){return t.index-i.index}getProperSourceEdges(){if(!this.qy){const t=[];for(const i of this.po){const e=i;e.valid&&t.push(e)}this.qy=t}return this.qy}getProperDestinationEdges(){if(!this.Wy){const t=[];for(const i of this.ir){const e=i;e.valid&&t.push(e)}this.Wy=t}return this.Wy}getDestinationEdge(t){const i=this.getProperDestinationEdges();for(const e of i)if(e.toVertex===t)return e;Util.o("Unable to find destination edge to given vertex")}getProperSourceVertexes(){if(!this.jy){const t=[];for(const i of this.po){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.fromVertex)}t.sort(LayeredDigraphVertex.uD),this.jy=t}return this.jy}getProperDestinationVertexes(){if(!this.Hy){const t=[];for(const i of this.ir){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.toVertex)}t.sort(LayeredDigraphVertex.uD),this.Hy=t}return this.Hy}addSourceEdge(t){super.addSourceEdge(t),this.jy=null,this.qy=null}deleteSourceEdge(t){super.deleteSourceEdge(t),this.jy=null,this.qy=null}addDestinationEdge(t){super.addDestinationEdge(t),this.Hy=null,this.Wy=null}deleteDestinationEdge(t){super.deleteDestinationEdge(t),this.Hy=null,this.Wy=null}get layer(){return this.Wo}set layer(t){this.Wo!==t&&(Util.i(t,"number",LayeredDigraphVertex,"layer"),this.Wo=t)}get column(){return this.Uo}set column(t){this.Uo!==t&&(Util.i(t,"number",LayeredDigraphVertex,"column"),this.Uo=t)}get index(){return this.Dt}set index(t){this.Dt!==t&&(Util.i(t,"number",LayeredDigraphVertex,"index"),this.Dt=t)}get component(){return this.ek}set component(t){this.ek!==t&&(Util.i(t,"number",LayeredDigraphVertex,"component"),this.ek=t)}get near(){return this.sk}set near(t){this.sk!==t&&(this.sk=t)}}class LayeredDigraphEdge extends LayoutEdge{Zi;nk;ok;rk;lk;hk;ak;constructor(t){super(t),this.Zi=!1,this.nk=!1,this.ok=!1,this.rk=NaN,this.lk=NaN,this.hk=0,this.ak=0}get fromVertex(){return this.We}set fromVertex(t){this.We!==t&&(this.We=t)}get toVertex(){return this.Je}set toVertex(t){this.Je!==t&&(this.Je=t)}get valid(){return this.Zi}set valid(t){this.Zi!==t&&(Util.i(t,"boolean",LayeredDigraphEdge,"valid"),this.Zi=t)}get rev(){return this.nk}set rev(t){this.nk!==t&&(Util.i(t,"boolean",LayeredDigraphEdge,"rev"),this.nk=t)}get forest(){return this.ok}set forest(t){this.ok!==t&&(Util.i(t,"boolean",LayeredDigraphEdge,"forest"),this.ok=t)}get portFromPos(){return this.rk}set portFromPos(t){this.rk!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portFromPos"),this.rk=t)}get portToPos(){return this.lk}set portToPos(t){this.lk!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portToPos"),this.lk=t)}get portFromColOffset(){return this.hk}set portFromColOffset(t){this.hk!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portFromColOffset"),this.hk=t)}get portToColOffset(){return this.ak}set portToColOffset(t){this.ak!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portToColOffset"),this.ak=t)}}var TreePath=(w=>(w[w.Default=0]="Default",w[w.Destination=1]="Destination",w[w.Source=2]="Source",w))(TreePath||{}),TreeSorting=(w=>(w[w.Forwards=10]="Forwards",w[w.Reverse=11]="Reverse",w[w.Ascending=12]="Ascending",w[w.Descending=13]="Descending",w))(TreeSorting||{}),TreeAlignment=(w=>(w[w.CenterSubtrees=20]="CenterSubtrees",w[w.CenterChildren=21]="CenterChildren",w[w.Start=22]="Start",w[w.End=23]="End",w[w.Bus=24]="Bus",w[w.BusBranching=25]="BusBranching",w[w.TopLeftBus=26]="TopLeftBus",w[w.BottomRightBus=27]="BottomRightBus",w[w.Custom=28]="Custom",w))(TreeAlignment||{}),TreeCompaction=(w=>(w[w.None=30]="None",w[w.Block=31]="Block",w))(TreeCompaction||{}),TreeStyle=(w=>(w[w.Layered=40]="Layered",w[w.LastParents=41]="LastParents",w[w.Alternating=42]="Alternating",w[w.RootOnly=43]="RootOnly",w))(TreeStyle||{}),TreeArrangement=(w=>(w[w.Vertical=50]="Vertical",w[w.Horizontal=51]="Horizontal",w[w.FixedRoots=52]="FixedRoots",w))(TreeArrangement||{}),TreeLayerStyle=(w=>(w[w.Individual=60]="Individual",w[w.Siblings=61]="Siblings",w[w.Uniform=62]="Uniform",w))(TreeLayerStyle||{});class TreeLayout extends Layout{Fi;Ti;_f;Dg;VN;Re;zi;ks;V;z;ck;hs;constructor(t){super(),this.Fi=new GSet,this.Ti=0,this.hs=1,this._f=40,this.Dg=60,this.VN=[],this.Re=!0,this.zi=50,this.ks=new Size(10,10).g();const i=new TreeNetwork(this);this.V=new TreeVertex(i),this.z=new TreeVertex(i),this.ck=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Ti=this.Ti,t._f=this._f,t.Dg=this.Dg,t.Re=this.Re,t.zi=this.zi,t.ks.a(this.ks),t.V.copyInheritedPropertiesFrom(this.V),t.z.copyInheritedPropertiesFrom(this.z)}ri(t){t in TreeAlignment?this.alignment=t:t in TreeArrangement?this.arrangement=t:t in TreeCompaction?this.compaction=t:t in TreePath?this.path=t:t in TreeSorting?this.sorting=t:t in TreeStyle?this.treeStyle=t:super.ri(t)}createNetwork(){return new TreeNetwork(this)}makeNetwork(t){const i=this.createNetwork(),e=s=>{if(s instanceof Node)return!s.isLinkLabel&&s.category!=="Comment";if(s instanceof Link){const n=s.fromNode;if(n===null||n.isLinkLabel||n.category==="Comment")return!1;const o=s.toNode;return!(o===null||o.isLinkLabel||o.category==="Comment")}return!1};return t instanceof Diagram?(i.addParts(t.nodes,!0,e),i.addParts(t.links,!0,e)):t instanceof Group?i.addParts(t.memberParts,!1,e):i.addParts(t.iterator,!1,e),i}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangement!==52&&(this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin));let i=this.diagram;i===null&&t instanceof Diagram&&(i=t),this.path===0&&i!==null?this.hs=i.isTreePathToChildren?1:2:this.hs=this.path===0?1:this.path,this.network.vertexes.count>0&&(this.CI(),this.LI(),this.AI(),this.TI(),this.RN(),this.DI(),this.arrangeTrees(),this.updateParts()),this.network=null,this.Fi=new GSet,this.isValidLayout=!0}CI(){this.network.deleteSelfEdges();const t=this.network.vertexes.iterator;for(;t.next();){const n=t.value;n.initialized=!1,n.level=0,n.parent=null,n.children=[]}if(this.Fi.count>0){const n=new GSet,o=this.Fi.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=this.network.findVertex(r);l!==null&&n.add(l)}else r instanceof TreeVertex&&n.add(r)}this.Fi=n}this.Fi.count===0&&this.findRoots();const i=this.Fi.copy().iterator;for(;i.next();){const n=i.value;n.initialized||(n.initialized=!0,this.zN(n))}let e=this.network.vertexes,s=null;for(;s=this.FI(e),s.count>0;){const n=this.dD(s);n!==null&&this.Fi.add(n),n.initialized=!0,this.zN(n),e=s}}FI(t){const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;s.initialized||i.add(s)}return i}findRoots(){const t=this.network.vertexes,i=t.iterator;for(;i.next();){const e=i.value;switch(this.hs){case 1:e.sourceEdges.count===0&&this.Fi.add(e);break;case 2:e.destinationEdges.count===0&&this.Fi.add(e);break;default:Util.o("Unhandled path value "+this.hs.toString())}}if(this.Fi.count===0){const e=this.dD(t);e!==null&&this.Fi.add(e)}}dD(t){let i=999999,e=null;const s=t.iterator;for(;s.next();){const n=s.value;switch(this.hs){case 1:n.sourceEdges.count0){const s=new List,n=t.destinationVertexes;for(;n.next();){const o=n.value;this.gD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;case 2:if(t.sourceEdges.count>0){const s=new List,n=t.sourceVertexes;for(;n.next();){const o=n.value;this.gD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;default:Util.o("Unhandled path value"+this.hs.toString())}const i=t.children,e=i.length;for(let s=0;st.level?!1:(this.vI(i.parent,i),!0):!0}RI(t,i){if(i===null)return!1;let e=i.parent;for(;e!==null&&e!==t;)e=e.parent;return e===t}vI(t,i){if(t===null||i===null)return;const e=t.children;let s=0;for(let n=0;n0){const n=new Array(e.length-s);let o=0;for(let r=0;r0?s+1:0}OI(t){switch(this._f){default:case 40:return t.parent!==null?t.parent:this.V;case 43:return t.parent===null?this.V:t.parent.parent===null?this.z:t.parent;case 42:return t.parent!==null?t.parent.parent!==null?t.parent.parent:this.z:this.V;case 41:{let i=!0;if(t.childrenCount===0)i=!1;else{const e=t.children,s=e.length;for(let n=0;n0){i=!1;break}}return i&&t.parent!==null?this.z:t.parent!==null?t.parent:this.V}}}initializeTreeVertexValues(t){const i=this.OI(t);if(t.copyInheritedPropertiesFrom(i),t.parent!==null&&t.parent.alignment===25){let e=t.angle;const s=t.parent.children;let n=0;for(;n135&&!l||a&&f)if(t.commentMargin>=0){g.e(t.bounds.x-t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleLeft,P.toSpot=Spot.MiddleRight}}else{g.e(t.bounds.x+t.focus.x*2-t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleRight,P.toSpot=Spot.MiddleLeft}}else if(t.commentMargin>=0){g.e(t.bounds.x+t.focus.x*2+t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleRight,P.toSpot=Spot.MiddleLeft}}else{g.e(t.bounds.x+t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleLeft,P.toSpot=Spot.MiddleRight}}t.commentSpacing>=0?u+=k.height+t.commentSpacing:u+=t.commentSpacing-k.height}else{if(o>135&&!l||!a&&f)if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y-t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleTop,P.toSpot=Spot.MiddleBottom}}else{g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2-t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleBottom,P.toSpot=Spot.MiddleTop}}else if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2+t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleBottom,P.toSpot=Spot.MiddleTop}}else{g.e(t.bounds.x+u,t.bounds.y+t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleTop,P.toSpot=Spot.MiddleBottom}}t.commentSpacing>=0?u+=k.width+t.commentSpacing:u+=t.commentSpacing-k.width}}Point.s(g);const p=u-t.commentSpacing-(h?e.height:e.width);if(this.hs===1){const y=t.destinationEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.fromEndSegmentLength=p>0?p:NaN)}}else{const y=t.sourceEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.toEndSegmentLength=p>0?p:NaN)}}}}DI(){if(this.layerStyle===62){const i=[];let e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;let n=s.parent;n===null&&(n=s);const o=n.angle===0||n.angle===180;let r=i[s.level];r===void 0&&(r=0),i[s.level]=Math.max(r,o?s.width:s.height)}for(let s=0;s=0)for(let o=0;o135&&n.reverse(),this.Jy(r))if(o>1)for(let R=0;R0&&M>0&&S+u+O.width>c&&(S135?-b-g:b+g);const B=M===0?m:u;this.fk(v,0,L),v.B.e(S+B,L),k=Math.max(k,S+B+O.width),b=Math.max(b,P+(C===0?0:g)+O.height),S+=B+O.width}else{c>0&&M>0&&L+u+O.height>c&&(L135?-k-g:k+g);const B=M===0?m:u;this.fk(v,S,0),v.B.e(S,L+B),b=Math.max(b,L+B+O.height),k=Math.max(k,P+(C===0?0:g)+O.width),L+=B+O.height}M++}C>0&&(e?(b+=Math.max(0,f),S0&&(h||this.tu(t,p,0,0,o-1),k+=p)):(k+=Math.max(0,f),L0&&(h||this.tu(t,0,p,0,o-1),b+=p)));let D=0,F=0;switch(r){case 20:e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;break;default:case 21:if(C>0)e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;else{const v=o;if(e){const O=n[0].B.x+n[0].ft.x,B=n[v-1].B.x+n[v-1].ft.x+n[v-1].focus.x*2;D+=O+(B-O)/2-t.focus.x-d/2}else{const O=n[0].B.y+n[0].ft.y,B=n[v-1].B.y+n[v-1].ft.y+n[v-1].focus.y*2;F+=O+(B-O)/2-t.focus.y-d/2}}break;case 22:e?(D-=d,k+=d):(F-=d,b+=d);break;case 23:e?(D+=k-t.width+d,k+=d):(F+=b-t.height+d,b+=d);break;case 24:case 25:e?o>1?D+=T+u/2-t.focus.x:D+=n[0].focus.x-t.focus.x+n[0].ft.x:o>1?F+=T+u/2-t.focus.y:F+=n[0].focus.y-t.focus.y+n[0].ft.y;break;case 26:e?D+=k+u/2-t.focus.x:F+=b+u/2-t.focus.y;break;case 27:break;case 28:const R=this.customAlignment(t,D,F,k,b);D=R[0],F=R[1],k=R[2],b=R[3];break}for(let R=0;R135?(a?-b:-v.mt.height)+v.ft.y-f:x+f+v.ft.y)):v.B.e(v.B.x+(i>135?(a?-k:-v.mt.width)+v.ft.x-f:y+f+v.ft.x),v.B.y+v.ft.y-F)}e?(k=this.KN(t,k,D),D<0&&(D=0),i>135&&(F+=b+f),b=Math.max(Math.max(b,x),b+x+f)):(i>135&&(D+=k+f),k=Math.max(Math.max(k,y),k+y+f),b=this.YN(t,b,F),F<0&&(F=0)),t.ft.e(D,F),t.mt.e(k,b)}customAlignment(t,i,e,s,n){return[i,e,s,n]}xD(t,i,e,s,n,o){const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.mt.width,o=p.mt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,c=this.orthoAngle(t)===90;let f=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.mt,k=f===0?0:h;if(c){const b=this.computeBusNodeSpacing(y)-l;y.B.e(e-(x.width+b),d+k),n=Math.max(n,x.width+b),o=Math.max(o,d+k+x.height),d+=k+x.height}else{const b=this.computeBusNodeSpacing(y)-l;y.B.e(u+k,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,u+k+x.width),u+=k+x.width}f++}f=0;const m=u,g=d;c?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.mt,x=this.computeBusLastRowSpacing(p,c?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(c){p.B.e(e+l/2-p.focus.x-p.ft.x,o+x);const k=e+l/2-p.focus.x-p.ft.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.max(g,d)+x+y.height),p.B.x<0&&(e=this.uk(t,p.B.x,!1,e,l))}else{p.B.e(n+x,e+l/2-p.focus.y-p.ft.y),n=Math.max(n,Math.max(m,u)+x+y.width);const k=e+l/2-p.focus.y-p.ft.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.B.y<0&&(e=this.uk(t,p.B.y,!0,e,l))}}return new Rect(e,0,n,o)}bD(t,i,e,s,n,o){const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.mt.width,o=p.mt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,c=this.orthoAngle(t)===270;let f=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.mt,k=f===0?0:h;if(c){const b=this.computeBusNodeSpacing(y)-l;d-=k+x.height,y.B.e(e-(x.width+b),d),n=Math.max(n,x.width+b),o=Math.max(o,Math.abs(d))}else{const b=this.computeBusNodeSpacing(y)-l;u-=k+x.width,y.B.e(u,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,Math.abs(u))}f++}f=0;const m=u,g=d;c?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.mt,x=this.computeBusLastRowSpacing(p,c?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(c){p.B.e(e+l/2-p.focus.x-p.ft.x,-o-y.height-x);const k=e+l/2-p.focus.x-p.ft.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.abs(Math.min(g,d))+x+y.height),p.B.x<0&&(e=this.uk(t,p.B.x,!1,e,l))}else{p.B.e(-n-y.width-x,e+l/2-p.focus.y-p.ft.y),n=Math.max(n,Math.abs(Math.min(m,u))+x+y.width);const k=e+l/2-p.focus.y-p.ft.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.B.y<0&&(e=this.uk(t,p.B.y,!0,e,l))}}for(let p=0;ps&&(s=e+t.width),e<0&&(s-=e),s;case 22:return t.width>i?t.width:i;case 23:return t.focus.x*2>i?t.width:i+t.width-t.focus.x*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.width);return Math.max(t.width,o-n);case 26:return t.width-t.focus.x+t.nodeSpacing/2+i;case 27:return Math.max(t.width,t.focus.x+t.nodeSpacing/2+i);default:return i}}YN(t,i,e){switch(t.alignment){case 21:case 20:let s=i;return e+t.height>s&&(s=e+t.height),e<0&&(s-=e),s;case 22:return t.height>i?t.height:i;case 23:return t.focus.y*2>i?t.height:i+t.height-t.focus.y*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.height);return Math.max(t.height,o-n);case 26:return t.height-t.focus.y+t.nodeSpacing/2+i;case 27:return Math.max(t.height,t.focus.y+t.nodeSpacing/2+i);default:return i}}GN(t,i,e){switch(t){case 20:i/=2,e/=2;break;case 21:i/=2,e/=2;break;case 22:i=0,e=0;break;case 23:break;default:Util.o("Unhandled alignment value "+t.toString())}return new Point(i,e)}_a(t,i,e,s,n,o){const r=this.GN(i,e,s);this.tu(t,r.x,r.y,n,o)}tu(t,i,e,s,n){if(i===0&&e===0)return;const o=t.children;for(let r=s;r<=n;r++){const h=o[r].B;h.x+=i,h.y+=e}}fk(t,i,e){const s=t.parent;switch(this.hs){case 1:{const n=t.sourceEdges;for(;n.next();){const o=n.value;o.fromVertex===s&&o.relativePoint.e(i,e)}break}case 2:{const n=t.destinationEdges;for(;n.next();){const o=n.value;o.toVertex===s&&o.relativePoint.e(i,e)}break}default:Util.o("Unhandled path value "+this.hs.toString())}}II(t){if(t.childrenCount===0){const U=t.parent;let Y=!1,G=0,H=21;U!==null&&(G=U.angle,H=U.alignment,Y=this.isBusAlignment(H));const J=this.XN(t);t.B.e(0,0),t.mt.e(t.width,t.height),t.parent!==null&&t.comments!==null&&((G===180||G===270)&&!Y||J)?G===180&&!Y||(G===90||G===270)&&J?t.ft.e(t.width-t.focus.x*2,0):t.ft.e(0,t.height-t.focus.y*2):t.ft.e(0,0),t.Fg=null,t.Rg=null;return}const i=this.orthoAngle(t),e=i===90||i===270;let s=0;const n=t.children,o=n.length;for(let U=0;U135&&n.reverse(),this.Jy(r))if(o>1)for(let U=0;U0&&A>0&&M+u+G.width>c&&(M135?-k-m:k+m),this.fk(Y,0,N);let H=0;if(A===0)P=Y.Fg,S=Y.Rg,L=G.width,C=G.height,(P===null||S===null||i!==this.orthoAngle(Y))&&(P=this.ae(2),S=this.ae(2),P[0].e(0,0),P[1].e(0,C),S[0].e(L,0),S[1].e(L,C));else{const J=Util.nt(),z=this.kD(t,Y,P,S,L,C,J);H=z.x,P=J[0],S=J[1],L=z.width,C=z.height,Util.tt(J),M0&&A>0&&N+u+G.height>c&&(N135?-x-m:x+m),this.fk(Y,M,0);let H=0;if(A===0)P=Y.Fg,S=Y.Rg,L=G.width,C=G.height,(P===null||S===null||i!==this.orthoAngle(Y))&&(P=this.ae(2),S=this.ae(2),P[0].e(0,0),P[1].e(L,0),S[0].e(0,C),S[1].e(L,C));else{const J=Util.nt(),z=this.kD(t,Y,P,S,L,C,J);H=z.x,P=J[0],S=J[1],L=z.width,C=z.height,Util.tt(J),N0&&(e?(k+=Math.max(0,f),M0&&(h||this.tu(t,g,0,0,o-1),x+=g)):(x+=Math.max(0,f),N0&&(h||this.tu(t,0,g,0,o-1),k+=g)));let v=0,O=0;switch(r){case 20:e?v+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;break;default:case 21:if(T>0)e?v+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;else{const Y=o;if(e){const G=n[0].B.x+n[0].ft.x,H=n[Y-1].B.x+n[Y-1].ft.x+n[Y-1].focus.x*2;v+=G+(H-G)/2-t.focus.x-d/2}else{const G=n[0].B.y+n[0].ft.y,H=n[Y-1].B.y+n[Y-1].ft.y+n[Y-1].focus.y*2;O+=G+(H-G)/2-t.focus.y-d/2}}break;case 22:e?(v-=d,x+=d):(O-=d,k+=d);break;case 23:e?(v+=x-t.width+d,x+=d):(O+=k-t.height+d,k+=d);break;case 24:e?o>1?v+=F+u/2-t.focus.x:v+=n[0].focus.x-t.focus.x+n[0].ft.x:o>1?O+=F+u/2-t.focus.y:O+=n[0].focus.y-t.focus.y+n[0].ft.y;break;case 26:e?v+=x+u/2-t.focus.x:O+=k+u/2-t.focus.y;break;case 27:break;case 28:const U=this.customAlignment(t,v,O,x,k);v=U[0],O=U[1],x=U[2],k=U[3];break}for(let U=0;U135?(a?-k:-Y.mt.height)+Y.ft.y-f:y+f+Y.ft.y)):Y.B.e(Y.B.x+(i>135?(a?-x:-Y.mt.width)+Y.ft.x-f:p+f+Y.ft.x),Y.B.y+Y.ft.y-O)}let B=0,X=0;if(a)e?(x=this.KN(t,x,v),v<0&&(v=0),i>135&&(O+=k+f),k+=y+f,r===27&&(B+=u/2+t.focus.x),X+=y+f):(i>135&&(v+=x+f),x+=p+f,k=this.YN(t,k,O),O<0&&(O=0),r===27&&(X+=u/2+t.focus.y),B+=p+f);else if(e){if(t.comments===null){if(p>x){const U=this.GN(r,p-x,0);B=U.x,X=U.y,x=p,v=0}}else x=this.KN(t,x,v);v<0&&(B-=v,v=0),i>135&&(O+=k+f),k=Math.max(Math.max(k,y),k+y+f),X+=y+f}else{if(i>135&&(v+=x+f),x=Math.max(Math.max(x,p),x+p+f),t.comments===null){if(y>k){const U=this.GN(r,0,y-k);B=U.x,X=U.y,k=y,O=0}}else k=this.YN(t,k,O);O<0&&(X-=O,O=0),B+=p+f}let E,V;if(T>0)E=this.ae(4),V=this.ae(4),e?(E[2].e(0,y+f),E[3].e(E[2].x,k),V[2].e(x,E[2].y),V[3].e(V[2].x,E[3].y)):(E[2].e(p+f,0),E[3].e(x,E[2].y),V[2].e(E[2].x,k),V[3].e(E[3].x,V[2].y));else{E=this.ae(P.length+2),V=this.ae(S.length+2);for(let U=0;UE[0].x?E[2].a(E[1]):E[1].a(E[2])),E[3].yE[0].x?E[3].a(E[2]):E[2].a(E[3])),V[0].e(v+p,0),V[1].e(V[0].x,y),V[2].yE[0].y?E[2].a(E[1]):E[1].a(E[2])),E[3].xE[0].y?E[3].a(E[2]):E[2].a(E[3])),V[0].e(0,O+y),V[1].e(p,V[0].y),V[2].xl;){const a=i[o++];s[r++].e(a.x,a.y+e)}const h=this.ae(r);for(n=0;nl;){const a=i[o++];s[r++].e(a.x+e,a.y)}const h=this.ae(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.ae(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.ae(r);for(n=0;nh&&r.xr.x&&ha&&r.yr.y&&a0){const n=Math.min(1,t.layerSpacingParentOverlap);s-=e?t.height*n:t.width*n}return s<(e?-t.height:-t.width)&&(s=e?-t.height:-t.width),s}computeNodeIndent(t){const i=this.orthoAngle(t),e=i===90||i===270;let s=t.nodeIndent;if(t.nodeIndentPastParent>0){const n=Math.min(1,t.nodeIndentPastParent);s+=e?t.width*n:t.height*n}return s=Math.max(0,s),s}get roots(){return this.Fi}set roots(t){this.Fi!==t&&(this.Fi=t,this.invalidateLayout())}get path(){return this.Ti}set path(t){this.Ti!==t&&(this.Ti=t,this.invalidateLayout())}get treeStyle(){return this._f}set treeStyle(t){this._f!==t&&(t===40||t===42||t===41||t===43)&&(this._f=t,this.invalidateLayout())}get layerStyle(){return this.Dg}set layerStyle(t){this.Dg!==t&&(t===60||t===61||t===62)&&(this.Dg=t,this.invalidateLayout())}get comments(){return this.Re}set comments(t){this.Re!==t&&(Util.i(t,"boolean",TreeLayout,"comments"),this.Re=t,this.invalidateLayout())}get arrangement(){return this.zi}set arrangement(t){this.zi!==t&&(t===50||t===51||t===52)&&(this.zi=t,this.invalidateLayout())}get arrangementSpacing(){return this.ks}set arrangementSpacing(t){this.ks.equals(t)||(this.ks.a(t),this.invalidateLayout())}get rootDefaults(){return this.V}set rootDefaults(t){this.V!==t&&(this.V=t,this.invalidateLayout())}get alternateDefaults(){return this.z}set alternateDefaults(t){this.z!==t&&(this.z=t,this.invalidateLayout())}get sorting(){return this.V.sorting}set sorting(t){this.V.sorting!==t&&(this.V.sorting=t,this.invalidateLayout())}get comparer(){return this.V.comparer}set comparer(t){this.V.comparer!==t&&(Util.i(t,"function",TreeLayout,"comparer"),this.V.comparer=t,this.invalidateLayout())}get angle(){return this.V.angle}set angle(t){this.V.angle!==t&&(Util.i(t,"number",TreeLayout,"angle"),t===0||t===90||t===180||t===270?(this.V.angle=t,this.invalidateLayout()):Util.o("TreeLayout.angle must be 0, 90, 180, or 270"))}get alignment(){return this.V.alignment}set alignment(t){this.V.alignment!==t&&(this.V.alignment=t,this.invalidateLayout())}get nodeIndent(){return this.V.nodeIndent}set nodeIndent(t){this.V.nodeIndent!==t&&(Util.i(t,"number",TreeLayout,"nodeIndent"),t>=0&&(this.V.nodeIndent=t,this.invalidateLayout()))}get nodeIndentPastParent(){return this.V.nodeIndentPastParent}set nodeIndentPastParent(t){this.V.nodeIndentPastParent!==t&&(Util.i(t,"number",TreeLayout,"nodeIndentPastParent"),t>=0&&t<=1&&(this.V.nodeIndentPastParent=t,this.invalidateLayout()))}get nodeSpacing(){return this.V.nodeSpacing}set nodeSpacing(t){this.V.nodeSpacing!==t&&(Util.i(t,"number",TreeLayout,"nodeSpacing"),this.V.nodeSpacing=t,this.invalidateLayout())}get layerSpacing(){return this.V.layerSpacing}set layerSpacing(t){this.V.layerSpacing!==t&&(Util.i(t,"number",TreeLayout,"layerSpacing"),this.V.layerSpacing=t,this.invalidateLayout())}get layerSpacingParentOverlap(){return this.V.layerSpacingParentOverlap}set layerSpacingParentOverlap(t){this.V.layerSpacingParentOverlap!==t&&(Util.i(t,"number",TreeLayout,"layerSpacingParentOverlap"),t>=0&&t<=1&&(this.V.layerSpacingParentOverlap=t,this.invalidateLayout()))}get compaction(){return this.V.compaction}set compaction(t){this.V.compaction!==t&&(t===30||t===31)&&(this.V.compaction=t,this.invalidateLayout())}get breadthLimit(){return this.V.breadthLimit}set breadthLimit(t){this.V.breadthLimit!==t&&(Util.i(t,"number",TreeLayout,"breadthLimit"),t>=0&&(this.V.breadthLimit=t,this.invalidateLayout()))}get rowSpacing(){return this.V.rowSpacing}set rowSpacing(t){this.V.rowSpacing!==t&&(Util.i(t,"number",TreeLayout,"rowSpacing"),this.V.rowSpacing=t,this.invalidateLayout())}get rowIndent(){return this.V.rowIndent}set rowIndent(t){this.V.rowIndent!==t&&(Util.i(t,"number",TreeLayout,"rowIndent"),t>=0&&(this.V.rowIndent=t,this.invalidateLayout()))}get commentSpacing(){return this.V.commentSpacing}set commentSpacing(t){this.V.commentSpacing!==t&&(Util.i(t,"number",TreeLayout,"commentSpacing"),this.V.commentSpacing=t,this.invalidateLayout())}get commentMargin(){return this.V.commentMargin}set commentMargin(t){this.V.commentMargin!==t&&(Util.i(t,"number",TreeLayout,"commentMargin"),this.V.commentMargin=t,this.invalidateLayout())}get setsPortSpot(){return this.V.setsPortSpot}set setsPortSpot(t){this.V.setsPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"setsPortSpot"),this.V.setsPortSpot=t,this.invalidateLayout())}get portSpot(){return this.V.portSpot}set portSpot(t){this.V.portSpot.equals(t)||(this.V.portSpot=t,this.invalidateLayout())}get setsChildPortSpot(){return this.V.setsChildPortSpot}set setsChildPortSpot(t){this.V.setsChildPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"setsChildPortSpot"),this.V.setsChildPortSpot=t,this.invalidateLayout())}get childPortSpot(){return this.V.childPortSpot}set childPortSpot(t){this.V.childPortSpot.equals(t)||(this.V.childPortSpot=t,this.invalidateLayout())}get alternateSorting(){return this.z.sorting}set alternateSorting(t){this.z.sorting!==t&&(this.z.sorting=t,this.invalidateLayout())}get alternateComparer(){return this.z.comparer}set alternateComparer(t){this.z.comparer!==t&&(Util.i(t,"function",TreeLayout,"alternateComparer"),this.z.comparer=t,this.invalidateLayout())}get alternateAngle(){return this.z.angle}set alternateAngle(t){this.z.angle!==t&&(Util.i(t,"number",TreeLayout,"alternateAngle"),(t===0||t===90||t===180||t===270)&&(this.z.angle=t,this.invalidateLayout()))}get alternateAlignment(){return this.z.alignment}set alternateAlignment(t){this.z.alignment!==t&&(this.z.alignment=t,this.invalidateLayout())}get alternateNodeIndent(){return this.z.nodeIndent}set alternateNodeIndent(t){this.z.nodeIndent!==t&&(Util.i(t,"number",TreeLayout,"alternateNodeIndent"),t>=0&&(this.z.nodeIndent=t,this.invalidateLayout()))}get alternateNodeIndentPastParent(){return this.z.nodeIndentPastParent}set alternateNodeIndentPastParent(t){this.z.nodeIndentPastParent!==t&&(Util.i(t,"number",TreeLayout,"alternateNodeIndentPastParent"),t>=0&&t<=1&&(this.z.nodeIndentPastParent=t,this.invalidateLayout()))}get alternateNodeSpacing(){return this.z.nodeSpacing}set alternateNodeSpacing(t){this.z.nodeSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateNodeSpacing"),this.z.nodeSpacing=t,this.invalidateLayout())}get alternateLayerSpacing(){return this.z.layerSpacing}set alternateLayerSpacing(t){this.z.layerSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateLayerSpacing"),this.z.layerSpacing=t,this.invalidateLayout())}get alternateLayerSpacingParentOverlap(){return this.z.layerSpacingParentOverlap}set alternateLayerSpacingParentOverlap(t){this.z.layerSpacingParentOverlap!==t&&(Util.i(t,"number",TreeLayout,"alternateLayerSpacingParentOverlap"),t>=0&&t<=1&&(this.z.layerSpacingParentOverlap=t,this.invalidateLayout()))}get alternateCompaction(){return this.z.compaction}set alternateCompaction(t){this.z.compaction!==t&&(t===30||t===31)&&(this.z.compaction=t,this.invalidateLayout())}get alternateBreadthLimit(){return this.z.breadthLimit}set alternateBreadthLimit(t){this.z.breadthLimit!==t&&(Util.i(t,"number",TreeLayout,"alternateBreadthLimit"),t>=0&&(this.z.breadthLimit=t,this.invalidateLayout()))}get alternateRowSpacing(){return this.z.rowSpacing}set alternateRowSpacing(t){this.z.rowSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateRowSpacing"),this.z.rowSpacing=t,this.invalidateLayout())}get alternateRowIndent(){return this.z.rowIndent}set alternateRowIndent(t){this.z.rowIndent!==t&&(Util.i(t,"number",TreeLayout,"alternateRowIndent"),t>=0&&(this.z.rowIndent=t,this.invalidateLayout()))}get alternateCommentSpacing(){return this.z.commentSpacing}set alternateCommentSpacing(t){this.z.commentSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateCommentSpacing"),this.z.commentSpacing=t,this.invalidateLayout())}get alternateCommentMargin(){return this.z.commentMargin}set alternateCommentMargin(t){this.z.commentMargin!==t&&(Util.i(t,"number",TreeLayout,"alternateCommentMargin"),this.z.commentMargin=t,this.invalidateLayout())}get alternateSetsPortSpot(){return this.z.setsPortSpot}set alternateSetsPortSpot(t){this.z.setsPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"alternateSetsPortSpot"),this.z.setsPortSpot=t,this.invalidateLayout())}get alternatePortSpot(){return this.z.portSpot}set alternatePortSpot(t){this.z.portSpot.equals(t)||(this.z.portSpot=t,this.invalidateLayout())}get alternateSetsChildPortSpot(){return this.z.setsChildPortSpot}set alternateSetsChildPortSpot(t){this.z.setsChildPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"alternateSetsChildPortSpot"),this.z.setsChildPortSpot=t,this.invalidateLayout())}get alternateChildPortSpot(){return this.z.childPortSpot}set alternateChildPortSpot(t){this.z.childPortSpot.equals(t)||(this.z.childPortSpot=t,this.invalidateLayout())}static PathDefault=0;static PathDestination=1;static PathSource=2;static SortingForwards=10;static SortingReverse=11;static SortingAscending=12;static SortingDescending=13;static AlignmentCenterSubtrees=20;static AlignmentCenterChildren=21;static AlignmentStart=22;static AlignmentEnd=23;static AlignmentBus=24;static AlignmentBusBranching=25;static AlignmentTopLeftBus=26;static AlignmentBottomRightBus=27;static CompactionNone=30;static CompactionBlock=31;static StyleLayered=40;static StyleLastParents=41;static StyleAlternating=42;static StyleRootOnly=43;static ArrangementVertical=50;static ArrangementHorizontal=51;static ArrangementFixedRoots=52;static LayerIndividual=60;static LayerSiblings=61;static LayerUniform=62}class TreeNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new TreeVertex(this)}createEdge(){return new TreeEdge(this)}}class TreeVertex extends LayoutVertex{B;mt;ft;gk;mk;pk;yk;wk;xk;bk;Re;Fg;Rg;pe;ye;Xt;oi;$y;Zy;Qy;Ps;_y;tw;iw;ew;sw;nw;ow;rw;lw;hw;aw;constructor(t){super(t),this.gk=!1,this.mk=null,this.pk=[],this.yk=0,this.wk=0,this.xk=0,this.bk=0,this.Re=null,this.B=new Point(0,0),this.mt=new Size(0,0),this.ft=new Point(0,0),this.Fg=null,this.Rg=null,this.pe=10,this.ye=LayoutVertex.standardComparer,this.Xt=0,this.oi=21,this.$y=0,this.Zy=0,this.Qy=20,this.Ps=50,this._y=0,this.tw=31,this.iw=0,this.ew=25,this.sw=10,this.nw=10,this.ow=20,this.rw=!0,this.lw=Spot.Default,this.hw=!0,this.aw=Spot.Default}copyInheritedPropertiesFrom(t){t!==null&&(this.pe=t.sorting,this.ye=t.comparer,this.Xt=t.angle,this.oi=t.alignment,this.$y=t.nodeIndent,this.Zy=t.nodeIndentPastParent,this.Qy=t.nodeSpacing,this.Ps=t.layerSpacing,this._y=t.layerSpacingParentOverlap,this.tw=t.compaction,this.iw=t.breadthLimit,this.ew=t.rowSpacing,this.sw=t.rowIndent,this.nw=t.commentSpacing,this.ow=t.commentMargin,this.rw=t.setsPortSpot,this.lw=t.portSpot,this.hw=t.setsChildPortSpot,this.aw=t.childPortSpot)}get initialized(){return this.gk}set initialized(t){this.gk!==t&&(Util.i(t,"boolean",TreeVertex,"initialized"),this.gk=t)}get parent(){return this.mk}set parent(t){this.mk!==t&&(this.mk=t)}get children(){return this.pk}set children(t){if(this.pk!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",TreeVertex,"children:value"),t!==null){const i=t.length;for(let e=0;e4;)t.removePoint(2);u=t.getPoint(1),d=t.getPoint(2)}else{for(f=1;t.pointsCount>3;)t.removePoint(1);u=t.getPoint(0),d=t.getPoint(t.pointsCount-1)}const m=t.getPoint(t.pointsCount-1);let g=0;r===0?(e.alignment===23?(g=o.bottom+n.y,n.y===0&&u.y>m.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.xm.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.x{const i=t.matches?"dark":"light";i!==this.vg&&(this.vg=i,this.Sk==="system"&&this.cw())};constructor(t){t&&Object.assign(this,t),t?.themeMap||(this.iu.set("light",{colors:{...Themes.Light.colors},fonts:{...Themes.Light.fonts},numbers:{...Themes.Light.numbers},margins:{...Themes.Light.margins},arrowheads:{...Themes.Light.arrowheads}}),this.iu.set("dark",{colors:{...Themes.Dark.colors},fonts:{...Themes.Dark.fonts},numbers:{...Themes.Dark.numbers},margins:{...Themes.Dark.margins},arrowheads:{...Themes.Dark.arrowheads}})),root.matchMedia&&(this.vg=root.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}get themeMap(){return this.iu}set themeMap(t){this.iu!==t&&(this.iu=t,this.cw())}get defaultTheme(){return this.Pk}set defaultTheme(t){this.Pk!==t&&(Util.i(t,"string",ThemeManager,"defaultTheme"),this.Pk=t,this.cw())}get currentTheme(){return this.Sk}set currentTheme(t){this.Sk!==t&&(Util.i(t,"string",ThemeManager,"currentTheme"),this.Sk=t,this.cw())}get changesDivBackground(){return this.Mk}set changesDivBackground(t){if(this.Mk!==t&&(this.Mk=t,t))for(const e of this.es)e.setDivBackground(this.findValue("div","","fill")),e.v("ThemeChanged",this)}get preferredColorScheme(){return this.vg}addDiagram(t){return this.es.add(t),this.HN(t),this}removeDiagram(t){return this.es.delete(t),this.HN(t),this}VF(){this.es.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.addEventListener("change",this.SD)}zF(){this.es.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.removeEventListener("change",this.SD)}set(t,i){t===""&&(t=this.Pk),t==="system"&&(t=this.vg);let e=this.iu.get(t);return e?e=this.MD(e,i):e=i,this.iu.set(t,e),this.cw(),this}findValue(t,i,e){return this.getValue(this.findTheme(this.currentTheme),t,i,e)||this.getValue(this.findTheme(this.defaultTheme),t,i,e)}getValue(t,i,e,s){if(!t)return;e==null&&(e="");let n=t;const o=l=>{if(n===void 0||l==="")return;if(typeof l=="number"||!(Array.isArray(l)||l.includes(".")))return n[l];const h=Array.isArray(l)?l:l.split(".");for(let a=0;a{if(!(e!==""&&(n=o(e),n===void 0)))return Array.isArray(n)&&typeof i=="number"?n=n[i%n.length]:n=o(i),n};if(n=r(),n===void 0&&typeof s=="string"&&s.length>0){let l=t.targetPropertyMap?.get(s);if(l?n=t[l]:(l=ThemeManager.GI.get(s),n=l?t[l]:t.colors),n=r(),n!==void 0)return n}return n}findTheme(t){return this.themeMap.get(t==="system"?this.vg:t)}HN(t){const i=t.skipsUndoManager;t.skipsUndoManager=!0,t.updateAllThemeBindings(),this.Mk&&t.setDivBackground(this.findValue("div","","fill")),t.skipsUndoManager=i,t.v("ThemeChanged",this)}cw(){for(const t of this.es)this.HN(t)}MD(t,i){for(const e in i)if(Util.fw(i,e))try{i[e].constructor===Object?t[e]=this.MD(t[e]??{},i[e]):t[e]=i[e]}catch{delete t[e]}return t}static GI=new Map([["background","colors"],["defaultColumnSeparatorStroke","colors"],["defaultRowSeparatorStroke","colors"],["shadowColor","colors"],["fill","colors"],["stroke","colors"],["font","fonts"],["angle","numbers"],["fromEndSegmentLength","numbers"],["fromShortLength","numbers"],["height","numbers"],["opacity","numbers"],["scale","numbers"],["toEndSegmentLength","numbers"],["toShortLength","numbers"],["width","numbers"],["defaultColumnSeparatorStrokeWidth","numbers"],["defaultRowSeparatorStrokeWidth","numbers"],["shadowBlur","numbers"],["corner","numbers"],["curviness","numbers"],["smoothness","numbers"],["parameter1","numbers"],["parameter2","numbers"],["strokeWidth","numbers"],["strokeDashOffset","numbers"],["maxLines","numbers"],["spacingAbove","numbers"],["spacingBelow","numbers"],["position","points"],["shadowOffset","points"],["desiredSize","sizes"],["maxSize","sizes"],["minSize","sizes"],["margin","margins"],["defaultSeparatorPadding","margins"],["padding","margins"],["alignment","spots"],["alignmentFocus","spots"],["fromSpot","spots"],["toSpot","spots"],["defaultAlignment","spots"],["spot1","spots"],["spot2","spots"],["verticalAlignment","spots"],["imageAlignment","spots"],["fromArrow","arrowheads"],["toArrow","arrowheads"]])}class Router{Mt;p;Oi;ul;constructor(){this.p=Diagram.mm(),this.Mt="",this.Oi=!0,this.ul=!0}get name(){return this.Mt}set name(t){this.Mt=t}get isEnabled(){return this.Oi}set isEnabled(t){this.Oi=t}get isRealtime(){return this.ul}set isRealtime(t){this.ul=t}get diagram(){return this.p}set diagram(t){this.p!==t&&(this.p=t,t.bl=!0,t.requestUpdate())}invalidateRouter(){this.p!==null&&(this.p.bl=!0,this.p.requestUpdate())}canRoute(t){if(!this.isEnabled)return!1;const i=this.diagram;return!(i&&(!this.isRealtime&&i.pu||i.animationManager.isTicking))}routeLinks(t,i){}toString(){return this.name!==""?this.name+" Router":Util.sn(this.constructor)}}class AvoidsNodesRouter extends Router{constructor(t){super(),this.name="AvoidsNodes",t&&Object.assign(this,t)}canRoute(t){return(t instanceof Diagram?t.Ym:t.diagram.Ym)?super.canRoute(t):!1}routeLinks(t,i){i=i instanceof Diagram?null:i;const e=t.iterator,s=this.diagram.getPositions(!0,i,null);for(;e.next();){const n=e.value;if(!n.isAvoiding||i&&n.containingGroup!==i||n.toNode===null||n.fromNode===null||n.pointsCount<4)continue;n.startRoute();const o=n.pointsCount,r=n.getPoint(1),l=n.getPoint(o-2),h=n.fromNode.actualBounds.copy();h.inflate(Link.va,Link.va),h.unionPoint(n.getPoint(0));const a=n.toNode.actualBounds.copy();a.inflate(Link.va,Link.va),a.unionPoint(n.getPoint(o-1)),this.jI(n,h,a,s)&&this.HI(n,r,n.iN,l,n.eN,h,a,s),n.commitRoute()}}jI(t,i,e,s){const n=t.diagram,o=t.pointsCount;if(n===null||t.fromNode===t.toNode||t.layer.isTemporary||i.containsPoint(t.getPoint(o-1))&&!t.toNode.isMemberOf(t.fromNode)||e.containsPoint(t.getPoint(0))&&!t.fromNode.isMemberOf(t.toNode)||!t.isOrthogonal)return!1;if(t.segmentIndex===17)return!0;const r=t.getPoint(1),l=t.getPoint(o-2),h=t.getPoint(2);if(!s.isUnoccupied(Math.min(r.x,h.x),Math.min(r.y,h.y),Math.abs(r.x-h.x),Math.abs(r.y-h.y)))return!0;for(let c=2;c=PositionArray.Bd&&(l.zL(),d.inflate(l.cellWidth*l.vM,l.cellHeight*l.OM),l.rT(i,e,s,n,d,!1),m=l.fo(s.x,s.y)),!l.by&&mPositionArray.Ba&&i.fo(g,p)!==u-1&&(i.fo(d-c,m)===u-1?(n=180,g=d-c,p=m):i.fo(d+c,m)===u-1?(n=0,g=d+c,p=m):i.fo(d,m-f)===u-1?(n=270,g=d,p=m-f):i.fo(d,m+f)===u-1&&(n=90,g=d,p=m+f));u>PositionArray.Ba&&i.fo(g,p)===u-1;)d=g,m=p,n===0?g+=c:n===90?p+=f:n===180?g-=c:p-=f,u-=1;if(o?u>PositionArray.Ba&&(n===180||n===0?d=Math.floor(d/c)*c+c/2:(n===90||n===270)&&(m=Math.floor(m/f)*f+f/2)):(d=Math.floor(d/c)*c+c/2,m=Math.floor(m/f)*f+f/2),u>PositionArray.Ba){let y=n,x=d,k=m;if(n===0?(y=90,k+=f):n===90?(y=180,x-=c):n===180?(y=270,k-=f):n===270&&(y=0,x+=c),i.fo(x,k)===u-1)this.qN(t,i,x,k,y,!1);else{let P=d,S=m;n===0?(y=270,S-=f):n===90?(y=0,P+=c):n===180?(y=90,S+=f):n===270&&(y=180,P-=c),i.fo(P,S)===u-1&&this.qN(t,i,P,S,y,!1)}}t.insertPointAt(t.pointsCount-2,d,m)}}ToolManager.prototype.initializeStandardTools=function(){this.Jt("Action",new ActionTool,this.mouseDownTools),this.Jt("Relinking",new RelinkingTool,this.mouseDownTools),this.Jt("LinkReshaping",new LinkReshapingTool,this.mouseDownTools),this.Jt("Rotating",new RotatingTool,this.mouseDownTools),this.Jt("Resizing",new ResizingTool,this.mouseDownTools),this.Jt("Linking",new LinkingTool,this.mouseMoveTools),this.Jt("Dragging",new DraggingTool,this.mouseMoveTools),this.Jt("DragSelecting",new DragSelectingTool,this.mouseMoveTools),this.Jt("Panning",new PanningTool,this.mouseMoveTools),this.Jt("ContextMenu",new ContextMenuTool,this.mouseUpTools),this.Jt("TextEditing",new TextEditingTool,this.mouseUpTools),this.Jt("ClickCreating",new ClickCreatingTool,this.mouseUpTools),this.Jt("ClickSelecting",new ClickSelectingTool,this.mouseUpTools)};Diagram.gM("GraphLinksModel",GraphLinksPartManager);Diagram.gM("TreeModel",TreePartManager);const oldGo=root.go,go={get version(){return Diagram.version},Group,List,Set:GSet,Map:GMap,Point,Size,Rect,Margin,Spot,Geometry,PathFigure,PathSegment,InputEvent,DiagramEvent,ChangedEvent,Model,GraphLinksModel,TreeModel,Binding,ThemeBinding,Transaction,UndoManager,CommandHandler,Tool,DraggingTool,DraggingInfo,DraggingOptions,LinkingBaseTool,LinkingTool,RelinkingTool,LinkReshapingTool,ResizingTool,RotatingTool,ClickSelectingTool,ActionTool,ClickCreatingTool,HTMLInfo,ContextMenuTool,DragSelectingTool,PanningTool,TextEditingTool,ToolManager,Animation,AnimationManager,AnimationTrigger,Layer,Diagram,Palette,Overview,Brush,GraphObject,Panel,RowColumnDefinition,Shape,TextBlock,Picture,Part,Adornment,Node,Link,Placeholder,Layout,LayoutNetwork,LayoutVertex,LayoutEdge,GridLayout,PanelLayout,CircularLayout,CircularNetwork,CircularVertex,CircularEdge,ForceDirectedLayout,ForceDirectedNetwork,ForceDirectedVertex,ForceDirectedEdge,LayeredDigraphLayout,LayeredDigraphNetwork,LayeredDigraphVertex,LayeredDigraphEdge,TreeLayout,TreeNetwork,TreeVertex,TreeEdge,Themes,ThemeManager,Router,AnimationStyle,AutoScale,CycleMode,Flip,TextFormat,ImageStretch,LayoutConditions,LinkAdjusting,Curve,Routing,Orientation,TextOverflow,PortSpreading,ScrollMode,CollapsePolicy,Sizing,TriggerStart,Stretch,ViewboxStretch,Wrap,BrushType,ColorSpace,GeometryStretch,GeometryType,SegmentType,BindingMode,ChangeType,CircularArrangement,CircularDirection,CircularNodeDiameterFormula,CircularSorting,GridAlignment,GridArrangement,GridSorting,LayeredDigraphAggressive,LayeredDigraphAlign,LayeredDigraphCycleRemove,LayeredDigraphInit,LayeredDigraphLayering,LayeredDigraphPack,TreeAlignment,TreeArrangement,TreeCompaction,TreeLayerStyle,TreePath,TreeSorting,TreeStyle,GestureMode,LinkingDirection,ReshapingBehavior,TextEditingAccept,TextEditingStarting,TextEditingState,WheelMode};typeof oldGo=="object"&&oldGo.version&&Util.ii("WARNING: a `go` object on the root object is already defined. "+("Debug"in oldGo?"debug ":"")+"version: "+oldGo.version+", replaced with version: "+go.version);Diagram.prototype.go=go;root.go=go; })(); "function"===typeof define&&define.amd&&define("undefined"!==typeof global?global.go:self.go); 'undefined'!==typeof module&&'object'===typeof module.exports&&(module.exports='undefined'!==typeof global?global.go:self.go); diff --git a/release/go.mjs b/release/go.mjs index 4006c3cd4..b58bdc8f2 100644 --- a/release/go.mjs +++ b/release/go.mjs @@ -1,25 +1,25 @@ /* - * GoJS v3.0.11 JavaScript Library for HTML Diagrams, https://gojs.net + * GoJS v3.0.12 JavaScript Library for HTML Diagrams, https://gojs.net * GoJS and Northwoods Software are registered trademarks of Northwoods Software Corporation, https://nwoods.com. * Copyright (C) 1998-2024 by Northwoods Software Corporation. All Rights Reserved. - * THIS SOFTWARE IS LICENSED. THE LICENSE AGREEMENT IS AT: https://gojs.net/3.0.11/license.html. + * THIS SOFTWARE IS LICENSED. THE LICENSE AGREEMENT IS AT: https://gojs.net/3.0.12/license.html. * DO NOT MODIFY THIS FILE. DO NOT DISTRIBUTE A MODIFIED COPY OF THE CONTENTS OF THIS FILE. */ -(function() {const root=typeof globalThis=="object"&&globalThis||typeof global=="object"&&global.global===global&&global||typeof self=="object"&&self.self===self&&self||{};root.requestAnimationFrame===void 0&&(root.setImmediate===void 0?root.requestAnimationFrame=w=>root.setTimeout(w,0):root.requestAnimationFrame=root.setImmediate);class Util{static rr=root.navigator!==void 0&&root.navigator.platform!==void 0&&root.navigator.platform.match(/(iPhone|iPod|iPad|Mac)/i)!==null;static Nk(t,i,e){let s=-1;return function(){const n=this,o=arguments;s!==-1&&Util.Ig(s),s=Util.vh(()=>{s=-1,e||t.apply(n,o)},i),e&&!s&&t.apply(n,o)}}static vh(t,i){return root.setTimeout(t,i)}static Ig(t){root.clearTimeout(t)}static en(t){return root.document.createElement(t)}static o(t){throw new Error(t)}static T(t,i){let e="The object is frozen, so its properties cannot be set: "+t.toString();i!==void 0&&(e+=" to value: "+i),Util.o(e)}static WI(t,i,e,s){}static i(t,i,e,s){}static JI(t,i,e){}static $I(t,i,e){}static we(t,i,e,s){}static _(t,i,e,s){let n=Util.CD(e);s!==void 0&&(n+="."+s),Util.o(n+" is not in the range "+i+": "+t)}static ve(t){}static lr(t,i){}static oi(t){root.console&&root.console.log(t)}static wt(t){return typeof t=="object"&&t!==null}static ZI(t,i,e){}static su(t,i,e){Array.isArray(t)?i>=t.length?t.push(e):t.splice(i,0,e):Util.o("Cannot insert an object into an HTMLCollection or NodeList: "+e+" at "+i)}static _a(t,i){Array.isArray(t)?i>=t.length?t.pop():t.splice(i,1):Util.o("Cannot remove an object from an HTMLCollection or NodeList at "+i)}static Ck=[];static ot(){const t=Util.Ck.pop();return t===void 0?[]:t}static tt(t){t.length=0,Util.Ck.push(t)}static QI=Object.freeze([]);static CD(t){return t===null?"*":typeof t=="string"?t:typeof t=="function"?t.name:""}static sn(t){return typeof t=="function"?t.className?t.className:t.name:Util.wt(t)&&t.constructor?Util.sn(t.constructor):typeof t}static Oh(t,i){return i==null||i===""?null:Util.wt(t)&&i in t||t[i]?t[i]:null}static toString(t){let i=t;return Util.wt(t)&&(t.text?i=t.text:t.name?i=t.name:t.key!==void 0?i=t.key:t.id!==void 0?i=t.id:t.constructor===Object&&(t.Text?i=t.Text:t.Name?i=t.Name:t.Key!==void 0?i=t.Key:t.Id!==void 0?i=t.Id:t.ID!==void 0&&(i=t.ID))),i===void 0?"undefined":i===null?"null":i.toString()}static fw(t,i){if(t.hasOwnProperty(i))return!0;let e=Object.getPrototypeOf(t);for(;e&&e!==Function;){if(e.hasOwnProperty(i))return!0;const s=e._I;if(s&&s[i])return!0;e=Object.getPrototypeOf(e)}return!1}static LD(t){const i=[];let e=0;for(e=0;e<256;e++)i[e]=e;let s=0,n=0;for(e=0;e<256;e++)s=(s+i[e]+119)%256,n=i[e],i[e]=i[s],i[s]=n;e=0,s=0;let o="";for(let r=0;r>4)+i.charAt(r&15)]=String.fromCharCode(r);t.length%2&&(t="0"+t);const s=[];let n=0;for(let r=0;r0){const n=i[0];return this.key=0,this.value=n,n}else return null}any(t){const i=this.qt;i.hr=null;const e=i.at;this.Dt=-1;const s=i.r,n=s.length,o=this.Ls;for(let r=0;r=0?(this.key=i,this.value=t.r[i],!0):(this.gl(),!1)}hasNext(){return this.next()}first(){const t=this.qt;this.Yt=t.at;const i=t.r,e=i.length-1;if(this.Dt=e,e>=0){const s=i[e];return this.key=e,this.value=s,s}else return null}any(t){const i=this.qt;i.ar=null;const e=i.at,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(t(r))return!0;i.at!==e&&Util.ve(i)}return!1}all(t){const i=this.qt;i.ar=null;const e=i.at,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(!t(r))return!1;i.at!==e&&Util.ve(i)}return!0}each(t){const i=this.qt;i.ar=null;const e=i.at,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];t(r),i.at!==e&&Util.ve(i)}return this}map(t){const i=this.qt;i.ar=null;const e=i.at,s=[],n=i.r,o=n.length;this.Dt=o;for(let l=o-1;l>=0;l--){const h=n[l];s.push(t(h)),i.at!==e&&Util.ve(i)}const r=new List;return r.r=s,r.Oe(),r.iterator}filter(t){const i=this.qt;i.ar=null;const e=i.at,s=[],n=i.r,o=n.length;this.Dt=o;for(let l=o-1;l>=0;l--){const h=n[l];t(h)&&s.push(h),i.at!==e&&Util.ve(i)}const r=new List;return r.r=s,r.Oe(),r.iterator}get count(){return this.qt.r.length}gl(){this.key=-1,this.value=null,this.Yt=-1,this.qt.ar=this}toString(){return"ListIteratorBackwards("+this.Dt+"/"+this.qt.count+")"}}class List{h;r;at;hr;ar;constructor(t){GSet.Yi(this),this.h=!1,this.r=[],this.at=0,this.hr=null,this.ar=null,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.r.values()}Oe(){let t=this.at;t++,t>999999999&&(t=0),this.at=t}g(){return this.h=!0,this}rt(){return this.h=!1,this}toString(){return"List()#"+GSet.as(this)}add(t){return this.h&&Util.T(this,t),this.r.push(t),this.Oe(),this}push(t){this.add(t)}addAll(t){if(t===null)return this;this.h&&Util.T(this);const i=this.r;if(Array.isArray(t)){const e=t.length;for(let s=0;s=i.length)&&Util._(t,"0 <= i < length",List,"elt:i"),i[t]}get(t){return this.elt(t)}setElt(t,i){const e=this.r;(t<0||t>=e.length)&&Util._(t,"0 <= i < length",List,"setElt:i"),this.h&&Util.T(this,t),e[t]=i}set(t,i){this.setElt(t,i)}first(){const t=this.r;return t.length===0?null:t[0]}last(){const t=this.r,i=t.length;return i>0?t[i-1]:null}pop(){this.h&&Util.T(this);const t=this.r;return t.length>0?t.pop():null}any(t){const i=this.r,e=this.at,s=i.length;for(let n=0;n= 0",List,"insertAt:i"),this.h&&Util.T(this,t);const e=this.r;t>=e.length?e.push(i):e.splice(t,0,i),this.Oe()}remove(t){return this.delete(t)}delete(t){if(t===null)return!1;this.h&&Util.T(this,t);const i=this.r,e=i.indexOf(t);return e===-1?!1:(e===i.length-1?i.pop():i.splice(e,1),this.Oe(),!0)}removeAt(t){const i=this.r;(t<0||t>=i.length)&&Util._(t,"0 <= i < length",List,"removeAt:i"),this.h&&Util.T(this,t),t===i.length-1?i.pop():i.splice(t,1),this.Oe()}removeRange(t,i){const e=this.r,s=e.length;if(t<0)t=0;else if(t>=s)return this;if(i<0)return this;if(i>=s&&(i=s-1),t>i)return this;this.h&&Util.T(this);let n=t,o=i+1;for(;o0&&(t.r=Array.prototype.slice.call(i)),t}toArray(){const t=this.r,i=this.count,e=new Array(i);for(let s=0;s=n-1)&&Util._(i,"0 <= from < length",List,"sortRange:from"),o===2){const r=s[i],l=s[i+1];return t(r,l)>0&&(s[i]=l,s[i+1]=r,this.Oe()),this}if(i===0)if(e>=n)s.sort(t);else{const r=s.slice(0,e);r.sort(t);for(let l=0;l=n){const r=s.slice(i);r.sort(t);for(let l=i;li.add(t(e))),i.iterator}filter(t){const i=new List;return this.ko.w.forEach(e=>{t(e)&&i.add(e)}),i.iterator}get count(){return this.ko.count}gl(){this.key=null,this.value=null,this.ii=null}toString(){return"SetIterator"}}class GSet{h;w;constructor(t){this.h=!1,this.w=new Set,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.w.values()}values(){return this.w.values()}g(){return this.h=!0,this}rt(){return this.h=!1,this}toString(){return"Set()#"+GSet.as(this)}add(t){return t===null?this:(this.w.add(t),this)}addAll(t){if(t===null)return this;if(Array.isArray(t)){const i=t.length;for(let e=0;et.add(i)),t}toArray(){return Array.from(this.w)}toList(){const t=new List;return this.w.forEach(i=>t.add(i)),t}get count(){return this.w.size}get size(){return this.w.size}get iterator(){return this.w.size<=0?EmptyIterator.instance:new SetIterator(this)}entries(){return this.w.entries()}keys(){return this.w.keys()}forEach(t,i){return this.w.forEach(t,i)}static nu=1;static Yi(t){t.__gohashid=GSet.nu++}static as(t){return t.__gohashid}}class MapKeySetIterator{$;ii;constructor(t){this.$=t,this.ii=t.w.keys()}[Symbol.iterator](){return this.$.w.keys()}key;value;get iterator(){return this}reset(){const t=this.$;this.ii=t.w.keys()}next(){const t=this.ii.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.$.w.size===0?null:(this.ii=this.$.w.keys(),this.ii.next().value)}any(t){for(const i of this.$.w)if(t(i[0]))return!0;return!1}all(t){for(const i of this.$.w)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.$.w)t(i[0]);return this}map(t){const i=this.$,e=new List;for(const s of i.w)e.add(t(s[0]));return e.iterator}filter(t){const i=this.$,e=new List;for(const s of i.w){const n=s[0];t(n)&&e.add(n)}return e.iterator}get count(){return this.$.size}gl(){this.key=null,this.value=null,this.ii=null}toString(){return"MapKeySetIterator"}}class MapKeySet extends GSet{$;constructor(t){super(),GSet.Yi(this),this.h=!0,this.$=t}[Symbol.iterator](){return this.w.keys()}values(){return this.w.keys()}g(){return this}rt(){return this}toString(){return"MapKeySet("+this.$.toString()+")"}add(t){Util.o("This Set is read-only: "+this.toString())}has(t){return this.$.has(t)}contains(t){return this.has(t)}delete(t){Util.o("This Set is read-only: "+this.toString())}remove(t){return this.delete(t)}clear(){Util.o("This Set is read-only: "+this.toString())}first(){return this.$.w.size===0?null:this.$.w.keys().next().value}any(t){for(const i of this.$.w)if(t(i[0]))return!0;return!1}all(t){for(const i of this.$.w)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.$.w)t(i[0]);return this}map(t){const i=new GSet;for(const e of this.$.w)i.add(t(e[0]));return i}filter(t){const i=new GSet;for(const e of this.$.w){const s=e[0];t(s)&&i.add(s)}return i}copy(){return new MapKeySet(this.$)}toSet(){const t=new GSet,i=this.$.w;for(const e of i)t.add(e[0]);return t}toArray(){const t=this.$.w,i=new Array(t.size);let e=0;for(const s of t)i[e]=s[0],e++;return i}toList(){const t=new List,i=this.$.w;for(const e of i)t.add(e[0]);return t}get count(){return this.$.size}get size(){return this.$.size}get iterator(){return this.$.size<=0?EmptyIterator.instance:new MapKeySetIterator(this.$)}}class MapValueSetIterator{$;ii;constructor(t){this.$=t,this.ii=t.w.values()}[Symbol.iterator](){return this.$.w.values()}key;value;get iterator(){return this}reset(){const t=this.$;this.ii=t.w.values()}next(){const t=this.ii.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.$.w.size===0?null:(this.ii=this.$.w.values(),this.ii.next().value)}any(t){for(const i of this.$.w)if(t(i[1]))return!0;return!1}all(t){for(const i of this.$.w)if(!t(i[1]))return!1;return!0}each(t){for(const i of this.$.w)t(i[1]);return this}map(t){const i=this.$,e=new List;for(const s of i.w)e.add(t(s[1]));return e.iterator}filter(t){const i=this.$,e=new List;for(const s of i.w){const n=s[1];t(n)&&e.add(n)}return e.iterator}get count(){return this.$.size}gl(){this.key=null,this.value=null,this.ii=null}toString(){return"MapValueSetIterator"}}class KeyValuePair{constructor(t,i){this.key=t,this.value=i}toString(){return"{"+this.key+":"+this.value+"}"}key;value}class MapIterator{$;ii;constructor(t){this.$=t,this.ii=t.w.entries()}[Symbol.iterator](){return this.$.w.entries()}key;value;get iterator(){return this}reset(){const t=this.$;this.ii=t.w.entries()}next(){const t=this.ii.next();return t.done?(this.key=null,this.value=null,!1):(this.key=t.value[0],this.value=t.value[1],!0)}hasNext(){return this.next()}first(){if(this.$.w.size===0)return null;this.ii=this.$.w.entries();const t=this.ii.next().value;return this.key=t[0],this.value=t[1],new KeyValuePair(t[0],t[1])}any(t){return this.$.any(t)}all(t){return this.$.all(t)}each(t){return this.$.each(t),this}map(t){const i=new List;let e=null;return this.$.w.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),i.add(t(e))}),i.iterator}filter(t){const i=new List;let e=null;return this.$.w.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),t(e)&&(i.add(e),e=null)}),i.iterator}get count(){return this.$.size}gl(){this.key=null,this.value=null,this.ii=null}toString(){return"MapIterator"}}class GMap{h;w;constructor(t){GSet.Yi(this),this.h=!1,this.w=new Map,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.w.entries()}entries(){return this.w.entries()}g(){return this.h=!0,this}rt(){return this.h=!1,this}toString(){return"Map()#"+GSet.as(this)}set(t,i){return this.h&&Util.T(this,t),this.w.set(t,i),this}add(t,i){return this.set(t,i)}addAll(t){if(t===null)return this;if(this.h&&Util.T(this),Array.isArray(t)){const i=t.length;for(let e=0;ei.x.toFixed(t)+" "+i.y.toFixed(t)}toString(){return"Point("+this.x+","+this.y+")"}equals(t){return t instanceof Point?this.b===t.x&&this.k===t.y:!1}equalTo(t,i){return this.b===t&&this.k===i}equalsApprox(t){return Geo.u(this.b,t.x)&&Geo.u(this.k,t.y)}add(t){return this.b+=t.x,this.k+=t.y,this}subtract(t){return this.b-=t.x,this.k-=t.y,this}offset(t,i){return this.b+=t,this.k+=i,this}rotate(t){if(t===0)return this;const i=this.b,e=this.k;if(i===0&&e===0)return this;let s=0,n=0;if(t>=360?t-=360:t<0&&(t+=360),t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const o=t*Math.PI/180;s=Math.cos(o),n=Math.sin(o)}return this.b=s*i-n*e,this.k=n*i+s*e,this}scale(t,i){return this.b*=t,this.k*=i,this}distanceSquaredPoint(t){const i=t.x-this.b,e=t.y-this.k;return i*i+e*e}distanceSquared(t,i){const e=t-this.b,s=i-this.k;return e*e+s*s}normalize(){const t=this.b,i=this.k,e=Math.sqrt(t*t+i*i);return e>0&&(this.b=t/e,this.k=i/e),this}directionPoint(t){return this.ZN(t.x-this.b,t.y-this.k)}direction(t,i){return this.ZN(t-this.b,i-this.k)}ZN(t,i){if(t===0)return i>0?90:i<0?270:0;if(i===0)return t>0?0:180;{if(isNaN(t)||isNaN(i))return 0;let e=Math.atan(Math.abs(i/t))*180/Math.PI;return t<0?i<0?e+=180:e=180-e:i<0&&(e=360-e),e}}static compareWithLineSegment(t,i,e,s,n,o){return Geo.ou(t,i,e,s,n,o)}compareWithLineSegmentPoint(t,i){return Geo.ou(t.x,t.y,i.x,i.y,this.x,this.y)}static intersectingLineSegments(t,i,e,s,n,o,r,l){return Geo.ru(t,i,e,s,n,o,r,l)}projectOntoLineSegment(t,i,e,s){return Geo.ml(t,i,e,s,this.b,this.k,this),this}projectOntoLineSegmentPoint(t,i){return Geo.ml(t.x,t.y,i.x,i.y,this.b,this.k,this),this}snapToGrid(t,i,e,s){return Geo.Eg(this.b,this.k,t,i,e,s,this),this}snapToGridPoint(t,i){return Geo.Eg(this.b,this.k,t.x,t.y,i.width,i.height,this),this}setRectSpot(t,i){return this.b=t.x+i.x*t.width+i.offsetX,this.k=t.y+i.y*t.height+i.offsetY,this}setSpot(t,i,e,s,n){return this.b=t+n.x*e+n.offsetX,this.k=i+n.y*s+n.offsetY,this}D(t){return t.xt(this),this}Ie(t){return t._e(this),this}static distanceLineSegmentSquared(t,i,e,s,n,o){let r=n-e,l=o-s;const h=r*r+l*l,a=e-t,c=s-i,f=-a*r-c*l;if(f<=0||f>=h)return r=n-t,l=o-i,Math.min(a*a+c*c,r*r+l*l);{const u=r*c-l*a;return u*u/h}}static distanceSquared(t,i,e,s){const n=e-t,o=s-i;return n*n+o*o}static direction(t,i,e,s){const n=e-t,o=s-i;if(n===0)return o>0?90:o<0?270:0;if(o===0)return n>0?0:180;{if(isNaN(n)||isNaN(o))return 0;let r=Math.atan(Math.abs(o/n))*180/Math.PI;return n<0?o<0?r+=180:r=180-r:o<0&&(r=360-r),r}}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}isReal(){return isFinite(this.x)&&isFinite(this.y)}static Po=new Point(0,0).it();static QN=new Point(-1/0,-1/0).it();static _N=new Point(1/0,1/0).it();static tC=new Point(6,6).it();static Ak=new Point(NaN,NaN).it();static Tk=[];static l(){const t=Point.Tk.pop();return t===void 0?new Point:t}static X(t,i){const e=Point.Tk.pop();return e===void 0?new Point(t,i):(e.x=t,e.y=i,e)}static s(t){Point.Tk.push(t)}}class Size{j;H;h;constructor(t,i){t===void 0?(this.j=0,this.H=0):typeof t=="number"&&(t>=0||isNaN(t))&&typeof i=="number"&&(i>=0||isNaN(i))?(this.j=t,this.H=i):Util.o("Invalid arguments to Size constructor: "+t+", "+i),this.h=!1}a(t){return this.j=t.j,this.H=t.H,this}e(t,i){return this.j=t,this.H=i,this}setTo(t,i){return this.j=t,this.H=i,this}set(t){return this.j=t.j,this.H=t.H,this}copy(){const t=new Size;return t.j=this.j,t.H=this.H,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}rt(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;return n=i[e++],n&&(o=parseFloat(n)),new Size(s,o)}else return new Size}static stringify(t){return t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.i(t,"number",Size,"stringifyFixed:digits"),i=>i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Size("+this.width+","+this.height+")"}equals(t){return t instanceof Size?this.j===t.width&&this.H===t.height:!1}equalTo(t,i){return this.j===t&&this.H===i}equalsApprox(t){return Geo.u(this.j,t.width)&&Geo.u(this.H,t.height)}inflate(t,i){const e=this.width+t;this.j=e>=0?e:0;const s=this.height+i;return this.H=s>=0?s:0,this}get width(){return this.j}set width(t){t<0&&Util._(t,">= 0",Size,"width"),this.j=t}get height(){return this.H}set height(t){t<0&&Util._(t,">= 0",Size,"height"),this.H=t}isReal(){return isFinite(this.width)&&isFinite(this.height)}static lu=new Size(0,0).it();static Dk=new Size(1,1).it();static iC=new Size(6,6).it();static hu=new Size(8,8).it();static eC=new Size(10,10).it();static sC=new Size(1/0,1/0).it();static gw=new Size(NaN,NaN).it();static nC=[];static l(){const t=Size.nC.pop();return t===void 0?new Size:t}static s(t){Size.nC.push(t)}}class Rect{b;k;j;H;h;constructor(t,i,e,s){if(t===void 0)this.b=0,this.k=0,this.j=0,this.H=0;else if(typeof t=="number"&&typeof i=="number"&&typeof e=="number"&&(e>=0||isNaN(e))&&typeof s=="number"&&(s>=0||isNaN(s)))this.b=t,this.k=i,this.j=e,this.H=s;else if(t instanceof Point){const n=t.x,o=t.y;if(i instanceof Point){const r=i.x,l=i.y;this.b=Math.min(n,r),this.k=Math.min(o,l),this.j=Math.abs(n-r),this.H=Math.abs(o-l)}else i instanceof Size?(this.b=n,this.k=o,this.j=i.width,this.H=i.height):Util.o("Incorrect second argument supplied to Rect constructor "+i)}else Util.o("Invalid arguments to Rect constructor: "+t+", "+i+", "+e+", "+s);this.h=!1}a(t){return this.b=t.b,this.k=t.k,this.j=t.j,this.H=t.H,this}e(t,i,e,s){return this.b=t,this.k=i,this.j=e,this.H=s,this}En(t,i){return this.j=t,this.H=i,this}setTo(t,i,e,s){return this.b=t,this.k=i,this.j=e,this.H=s,this}set(t){return this.b=t.b,this.k=t.k,this.j=t.j,this.H=t.H,this}setPoint(t){return this.b=t.x,this.k=t.y,this}setSize(t){return this.j=t.width,this.H=t.height,this}copy(){const t=new Rect;return t.b=this.b,t.k=this.k,t.j=this.j,t.H=this.H,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}rt(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),new Rect(s,o,r,l)}else return new Rect}static stringify(t){return t.x.toString()+" "+t.y.toString()+" "+t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.i(t,"number",Rect,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Rect("+this.x+","+this.y+","+this.width+","+this.height+")"}equals(t){return t instanceof Rect?this.b===t.x&&this.k===t.y&&this.j===t.width&&this.H===t.height:!1}equalTo(t,i,e,s){return this.b===t&&this.k===i&&this.j===e&&this.H===s}equalsApprox(t){return Geo.u(this.b,t.x)&&Geo.u(this.k,t.y)&&Geo.u(this.j,t.width)&&Geo.u(this.H,t.height)}equalsApproxTo(t,i,e,s){return Geo.u(this.b,t)&&Geo.u(this.k,i)&&Geo.u(this.j,e)&&Geo.u(this.H,s)}equalsApproxClose(t){return Geo.K(this.b,t.x)&&Geo.K(this.k,t.y)&&Geo.K(this.j,t.width)&&Geo.K(this.H,t.height)}containsPoint(t){return this.b<=t.x&&this.b+this.j>=t.x&&this.k<=t.y&&this.k+this.H>=t.y}containsRect(t){return this.b<=t.x&&t.x+t.width<=this.b+this.j&&this.k<=t.y&&t.y+t.height<=this.k+this.H}contains(t,i,e,s){return e===void 0&&(e=0),s===void 0&&(s=0),this.b<=t&&t+e<=this.b+this.j&&this.k<=i&&i+s<=this.k+this.H}offset(t,i){return this.b+=t,this.k+=i,this}inflate(t,i){return this.mw(i,t,i,t)}addMargin(t){return this.mw(t.top,t.right,t.bottom,t.left)}subtractMargin(t){return this.mw(-t.top,-t.right,-t.bottom,-t.left)}grow(t,i,e,s){return this.mw(t,i,e,s)}mw(t,i,e,s){const n=this.j;i+s<=-n?(this.b+=n/2,this.j=0):(this.b-=s,this.j+=i+s);const o=this.H;return t+e<=-o?(this.k+=o/2,this.H=0):(this.k-=t,this.H+=t+e),this}intersectRect(t){return this.oC(t.x,t.y,t.width,t.height)}intersect(t,i,e,s){return this.oC(t,i,e,s)}oC(t,i,e,s){const n=Math.max(this.b,t),o=Math.max(this.k,i),r=Math.min(this.b+this.j,t+e),l=Math.min(this.k+this.H,i+s);return this.b=n,this.k=o,this.j=Math.max(0,r-n),this.H=Math.max(0,l-o),this}intersectsRect(t){return this.intersects(t.x,t.y,t.width,t.height)}intersects(t,i,e,s){let n=this.j;const o=this.b;if(n!==1/0&&e!==1/0&&(n+=o,e+=t,isNaN(e)||isNaN(n)||o>e||t>n))return!1;let r=this.H;const l=this.k;return!(r!==1/0&&s!==1/0&&(r+=l,s+=i,isNaN(s)||isNaN(r)||l>s||i>r))}intersectsRectPlus(t,i){let e=this.j,s=t.width+i+i;const n=this.b,o=t.x-i;if(e+=n,s+=o,n>s||o>e)return!1;let r=this.H,l=t.height+i+i;const h=this.k,a=t.y-i;return r+=h,l+=a,!(h>l||a>r)}unionPoint(t){return this.unionNoCheck(t.x,t.y,0,0)}unionRect(t){return this.unionNoCheck(t.b,t.k,t.j,t.H)}union(t,i,e,s){return e===void 0&&(e=0),s===void 0&&(s=0),this.unionNoCheck(t,i,e,s)}unionNoCheck(t,i,e,s){const n=Math.min(this.b,t),o=Math.min(this.k,i),r=Math.max(this.b+this.j,t+e),l=Math.max(this.k+this.H,i+s);return this.b=n,this.k=o,this.j=r-n,this.H=l-o,this}setSpot(t,i,e){return this.b=t-e.offsetX-e.x*this.j,this.k=i-e.offsetY-e.y*this.H,this}static contains(t,i,e,s,n,o,r,l){return r===void 0&&(r=0),l===void 0&&(l=0),t<=n&&n+r<=t+e&&i<=o&&o+l<=i+s}static intersects(t,i,e,s,n,o,r,l){let h=e,a=r;const c=t,f=n;if(h+=c,a+=f,c>a||f>h)return!1;let u=s,d=l;const m=i,g=o;return u+=m,d+=g,!(m>d||g>u)}static intersectsLineSegment(t,i,e,s,n,o,r,l){return Geo.rC(t,i,e,s,n,o,r,l)}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}get width(){return this.j}set width(t){t<0&&Util._(t,">= 0",Rect,"width"),this.j=t}get height(){return this.H}set height(t){t<0&&Util._(t,">= 0",Rect,"height"),this.H=t}get left(){return this.b}set left(t){this.b=t}get top(){return this.k}set top(t){this.k=t}get right(){return this.b+this.j}set right(t){this.b+=t-(this.b+this.j)}get bottom(){return this.k+this.H}set bottom(t){this.k+=t-(this.k+this.H)}get position(){return new Point(this.b,this.k)}set position(t){this.b=t.x,this.k=t.y}get size(){return new Size(this.j,this.H)}set size(t){this.j=t.width,this.H=t.height}get center(){return new Point(this.b+this.j/2,this.k+this.H/2)}set center(t){this.b=t.x-this.j/2,this.k=t.y-this.H/2}get centerX(){return this.b+this.j/2}set centerX(t){this.b=t-this.j/2}get centerY(){return this.k+this.H/2}set centerY(t){this.k=t-this.H/2}isReal(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)}isEmpty(){return this.width===0&&this.height===0}static pw=new Rect(0,0,0,0).it();static TD=new Rect(NaN,NaN,NaN,NaN).it();static Fk=[];static l(){const t=Rect.Fk.pop();return t===void 0?new Rect:t}static X(t,i,e,s){const n=Rect.Fk.pop();return n===void 0?new Rect(t,i,e,s):n.e(t,i,e,s)}static s(t){Rect.Fk.push(t)}}class Margin{nn;on;rn;ln;h;constructor(t,i,e,s){t===void 0?(this.nn=0,this.on=0,this.rn=0,this.ln=0):i===void 0?(i=t,e=t,s=t,this.top=t,this.right=i,this.bottom=e,this.left=s):e===void 0?(e=t,s=i,this.top=t,this.right=i,this.bottom=e,this.left=s):s!==void 0?(this.top=t,this.right=i,this.bottom=e,this.left=s):Util.o("Invalid arguments to Margin constructor: "+t+", "+i+", "+e+", "+s),this.h=!1}a(t){return this.nn=t.nn,this.on=t.on,this.rn=t.rn,this.ln=t.ln,this}setTo(t,i,e,s){return this.nn=t,this.on=i,this.rn=e,this.ln=s,this}set(t){return this.nn=t.nn,this.on=t.on,this.rn=t.rn,this.ln=t.ln,this}copy(){const t=new Margin;return t.nn=this.nn,t.on=this.on,t.rn=this.rn,t.ln=this.ln,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}rt(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=NaN;for(;i[e]==="";)e++;let n=i[e++];if(n&&(s=parseFloat(n)),isNaN(s))return new Margin;let o=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(o=parseFloat(n)),isNaN(o))return new Margin(s);let r=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(r=parseFloat(n)),isNaN(r))return new Margin(s,o);let l=NaN;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),isNaN(l)?new Margin(s,o):new Margin(s,o,r,l)}else return new Margin}static stringify(t){return t.top.toString()+" "+t.right.toString()+" "+t.bottom.toString()+" "+t.left.toString()}static stringifyFixed(t){return Util.i(t,"number",Margin,"stringifyFixed:digits"),i=>i.top.toFixed(t)+" "+i.right.toFixed(t)+" "+i.bottom.toFixed(t)+" "+i.left.toFixed(t)}toString(){return"Margin("+this.top+","+this.right+","+this.bottom+","+this.left+")"}equals(t){return t instanceof Margin?this.nn===t.top&&this.on===t.right&&this.rn===t.bottom&&this.ln===t.left:!1}equalTo(t,i,e,s){return this.nn===t&&this.on===i&&this.rn===e&&this.ln===s}equalsApprox(t){return Geo.u(this.nn,t.top)&&Geo.u(this.on,t.right)&&Geo.u(this.rn,t.bottom)&&Geo.u(this.ln,t.left)}get top(){return this.nn}set top(t){this.nn=t}get right(){return this.on}set right(t){this.on=t}get bottom(){return this.rn}set bottom(t){this.rn=t}get left(){return this.ln}set left(t){this.ln=t}isReal(){return isFinite(this.top)&&isFinite(this.right)&&isFinite(this.bottom)&&isFinite(this.left)}static Ug=new Margin(0,0,0,0).it();static lC=new Margin(2,2,2,2).it();static hC=[];static l(){const t=Margin.hC.pop();return t===void 0?new Margin:t}static s(t){Margin.hC.push(t)}}class Spot{b;k;As;Ts;h;constructor(t,i,e,s){t===void 0?(this.b=0,this.k=0,this.As=0,this.Ts=0):(i===void 0&&(i=0),e===void 0&&(e=0),s===void 0&&(s=0),this.x=t,this.y=i,this.offsetX=e,this.offsetY=s),this.h=!1}a(t){return this.b=t.b,this.k=t.k,this.As=t.As,this.Ts=t.Ts,this}setTo(t,i,e,s){return this.b=t,this.k=i,this.As=e,this.Ts=s,this}set(t){return this.b=t.b,this.k=t.k,this.As=t.As,this.Ts=t.Ts,this}copy(){const t=new Spot;return t.b=this.b,t.k=this.k,t.As=this.As,t.Ts=this.Ts,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}rt(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}Ee(t){return this.b=NaN,this.k=NaN,this.As=t,this}tE(t,i){(isNaN(t)||t>1||t<0)&&Util._(t,"0 <= "+i+" <= 1",Spot,i)}iE(t,i){(isNaN(t)||t===1/0||t===-1/0)&&Util._(t,"real number, not NaN or Infinity",Spot,i)}static parse(t){if(typeof t=="string"){if(t=t.trim(),t==="None")return Spot.None;if(t==="TopLeft")return Spot.TopLeft;if(t==="Top"||t==="TopCenter"||t==="MiddleTop")return Spot.TopCenter;if(t==="TopRight")return Spot.TopRight;if(t==="Left"||t==="LeftCenter"||t==="MiddleLeft")return Spot.LeftCenter;if(t==="Center")return Spot.Center;if(t==="Right"||t==="RightCenter"||t==="MiddleRight")return Spot.RightCenter;if(t==="BottomLeft")return Spot.BottomLeft;if(t==="Bottom"||t==="BottomCenter"||t==="MiddleBottom")return Spot.BottomCenter;if(t==="BottomRight")return Spot.BottomRight;if(t==="TopSide")return Spot.TopSide;if(t==="LeftSide")return Spot.LeftSide;if(t==="RightSide")return Spot.RightSide;if(t==="BottomSide")return Spot.BottomSide;if(t==="TopBottomSides")return Spot.TopBottomSides;if(t==="LeftRightSides")return Spot.LeftRightSides;if(t==="TopLeftSides")return Spot.TopLeftSides;if(t==="TopRightSides")return Spot.TopRightSides;if(t==="BottomLeftSides")return Spot.BottomLeftSides;if(t==="BottomRightSides")return Spot.BottomRightSides;if(t==="NotTopSide")return Spot.NotTopSide;if(t==="NotLeftSide")return Spot.NotLeftSide;if(t==="NotRightSide")return Spot.NotRightSide;if(t==="NotBottomSide")return Spot.NotBottomSide;if(t==="AllSides")return Spot.AllSides;if(t==="Default")return Spot.Default;const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n!==void 0&&n.length>0&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n!==void 0&&n.length>0&&(l=parseFloat(n)),new Spot(s,o,r,l)}else return new Spot}static stringify(t){return t.isSpot()?t.x.toString()+" "+t.y.toString()+" "+t.offsetX.toString()+" "+t.offsetY.toString():t.toString()}static stringifyFixed(t){return Util.i(t,"number",Spot,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.offsetX.toFixed(t)+" "+i.offsetY.toFixed(t)}toString(){return this.isSpot()?this.As===0&&this.Ts===0?"Spot("+this.x+","+this.y+")":"Spot("+this.x+","+this.y+","+this.offsetX+","+this.offsetY+")":this.equals(Spot.None)?"None":this.equals(Spot.TopLeft)?"TopLeft":this.equals(Spot.TopCenter)?"Top":this.equals(Spot.TopRight)?"TopRight":this.equals(Spot.LeftCenter)?"Left":this.equals(Spot.Center)?"Center":this.equals(Spot.RightCenter)?"Right":this.equals(Spot.BottomLeft)?"BottomLeft":this.equals(Spot.BottomCenter)?"Bottom":this.equals(Spot.BottomRight)?"BottomRight":this.equals(Spot.TopSide)?"TopSide":this.equals(Spot.LeftSide)?"LeftSide":this.equals(Spot.RightSide)?"RightSide":this.equals(Spot.BottomSide)?"BottomSide":this.equals(Spot.TopBottomSides)?"TopBottomSides":this.equals(Spot.LeftRightSides)?"LeftRightSides":this.equals(Spot.TopLeftSides)?"TopLeftSides":this.equals(Spot.TopRightSides)?"TopRightSides":this.equals(Spot.BottomLeftSides)?"BottomLeftSides":this.equals(Spot.BottomRightSides)?"BottomRightSides":this.equals(Spot.NotTopSide)?"NotTopSide":this.equals(Spot.NotLeftSide)?"NotLeftSide":this.equals(Spot.NotRightSide)?"NotRightSide":this.equals(Spot.NotBottomSide)?"NotBottomSide":this.equals(Spot.AllSides)?"AllSides":this.equals(Spot.Default)?"Default":"None"}equals(t){return t instanceof Spot?(this.b===t.x||isNaN(this.b)&&isNaN(t.x))&&(this.k===t.y||isNaN(this.k)&&isNaN(t.y))&&this.As===t.offsetX&&this.Ts===t.offsetY:!1}opposite(){return new Spot(.5-(this.b-.5),.5-(this.k-.5),-this.As,-this.Ts)}includesSide(t){if(!this.isSide())return!1;if(!t.isSide())if(t.equals(Spot.Left))t=Spot.LeftSide;else if(t.equals(Spot.Right))t=Spot.RightSide;else if(t.equals(Spot.Top))t=Spot.TopSide;else if(t.equals(Spot.Bottom))t=Spot.BottomSide;else return!1;const i=this.Ts,e=t.offsetY;return(i&e)===e}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}get offsetX(){return this.As}set offsetX(t){this.As=t}get offsetY(){return this.Ts}set offsetY(t){this.Ts=t}isSpot(){return!isNaN(this.x)&&!isNaN(this.y)}isNoSpot(){return isNaN(this.x)||isNaN(this.y)}isSide(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===1&&this.offsetY!==0}isNone(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===0&&this.offsetY===0}isDefault(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===-1&&this.offsetY===0}static None=new Spot(0,0,0,0).Ee(0).it();static Default=new Spot(0,0,-1,0).Ee(-1).it();static TopLeft=new Spot(0,0,0,0).it();static TopCenter=new Spot(.5,0,0,0).it();static TopRight=new Spot(1,0,0,0).it();static LeftCenter=new Spot(0,.5,0,0).it();static Center=new Spot(.5,.5,0,0).it();static RightCenter=new Spot(1,.5,0,0).it();static BottomLeft=new Spot(0,1,0,0).it();static BottomCenter=new Spot(.5,1,0,0).it();static BottomRight=new Spot(1,1,0,0).it();static MiddleTop=Spot.TopCenter;static MiddleLeft=Spot.LeftCenter;static MiddleRight=Spot.RightCenter;static MiddleBottom=Spot.BottomCenter;static Top=Spot.TopCenter;static Left=Spot.LeftCenter;static Right=Spot.RightCenter;static Bottom=Spot.BottomCenter;static TopSide=new Spot(0,0,1,1).Ee(1).it();static LeftSide=new Spot(0,0,1,2).Ee(1).it();static RightSide=new Spot(0,0,1,4).Ee(1).it();static BottomSide=new Spot(0,0,1,8).Ee(1).it();static TopBottomSides=new Spot(0,0,1,9).Ee(1).it();static LeftRightSides=new Spot(0,0,1,6).Ee(1).it();static TopLeftSides=new Spot(0,0,1,3).Ee(1).it();static TopRightSides=new Spot(0,0,1,5).Ee(1).it();static BottomLeftSides=new Spot(0,0,1,10).Ee(1).it();static BottomRightSides=new Spot(0,0,1,12).Ee(1).it();static NotTopSide=new Spot(0,0,1,14).Ee(1).it();static NotLeftSide=new Spot(0,0,1,13).Ee(1).it();static NotRightSide=new Spot(0,0,1,11).Ee(1).it();static NotBottomSide=new Spot(0,0,1,7).Ee(1).it();static AllSides=new Spot(0,0,1,15).Ee(1).it();static Rk=new Spot(.156,.156).it();static vk=new Spot(.844,.844).it();static aC=[];static l(){const t=Spot.aC.pop();return t===void 0?new Spot:t}static s(t){Spot.aC.push(t)}}class Transform{m11;m12;m21;m22;dx;dy;constructor(){this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0}set(t){return this.m11=t.m11,this.m12=t.m12,this.m21=t.m21,this.m22=t.m22,this.dx=t.dx,this.dy=t.dy,this}setTo(t,i,e,s,n,o){return this.m11=t,this.m12=i,this.m21=e,this.m22=s,this.dx=n,this.dy=o,this}copy(){const t=new Transform;return t.m11=this.m11,t.m12=this.m12,t.m21=this.m21,t.m22=this.m22,t.dx=this.dx,t.dy=this.dy,t}toString(){return"Transform("+this.m11+","+this.m12+","+this.m21+","+this.m22+","+this.dx+","+this.dy+")"}equals(t){return this.m11===t.m11&&this.m12===t.m12&&this.m21===t.m21&&this.m22===t.m22&&this.dx===t.dx&&this.dy===t.dy}Ok(){return this.dx===0&&this.dy===0&&this.m11===1&&this.m12===0&&this.m21===0&&this.m22===1}Ri(){return this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0,this}tc(t){const i=this.m11*t.m11+this.m21*t.m12,e=this.m12*t.m11+this.m22*t.m12,s=this.m11*t.m21+this.m21*t.m22,n=this.m12*t.m21+this.m22*t.m22;return this.dx=this.m11*t.dx+this.m21*t.dy+this.dx,this.dy=this.m12*t.dx+this.m22*t.dy+this.dy,this.m11=i,this.m12=e,this.m21=s,this.m22=n,this}cC(t){const i=1/(t.m11*t.m22-t.m12*t.m21),e=t.m22*i,s=-t.m12*i,n=-t.m21*i,o=t.m11*i,r=i*(t.m21*t.dy-t.m22*t.dx),l=i*(t.m12*t.dx-t.m11*t.dy),h=this.m11*e+this.m21*s,a=this.m12*e+this.m22*s,c=this.m11*n+this.m21*o,f=this.m12*n+this.m22*o;return this.dx=this.m11*r+this.m21*l+this.dx,this.dy=this.m12*r+this.m22*l+this.dy,this.m11=h,this.m12=a,this.m21=c,this.m22=f,this}yw(){const t=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*t,e=-this.m12*t,s=-this.m21*t,n=this.m11*t,o=t*(this.m21*this.dy-this.m22*this.dx),r=t*(this.m12*this.dx-this.m11*this.dy);return this.m11=i,this.m12=e,this.m21=s,this.m22=n,this.dx=o,this.dy=r,this}cs(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return this;this.Ds(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m11*s+this.m21*n,r=this.m12*s+this.m22*n,l=this.m11*-n+this.m21*s,h=this.m12*-n+this.m22*s;return this.m11=o,this.m12=r,this.m21=l,this.m22=h,this.Ds(-i,-e),this}Ds(t,i){return this.dx+=this.m11*t+this.m21*i,this.dy+=this.m12*t+this.m22*i,this}st(t,i){return i===void 0&&(i=t),this.m11*=t,this.m12*=t,this.m21*=i,this.m22*=i,this}DD(){if(this.m11===1&&this.m12===0)return 0;let t=Math.atan2(this.m12,this.m11)*180/Math.PI;return t<0&&(t+=360),t}xt(t){const i=t.x,e=t.y;return t.e(i*this.m11+e*this.m21+this.dx,i*this.m12+e*this.m22+this.dy)}_e(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=t.x-this.dx,l=t.y-this.dy;return t.e(r*e+l*n,r*s+l*o)}ww(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=i*(this.m21*this.dy-this.m22*this.dx),l=i*(this.m12*this.dx-this.m11*this.dy),h=t.x*1.25,a=t.y*1.2;return t.e(h*e+a*n+r,h*s+a*o+l)}xw(t){const i=t.x,e=t.y,s=i+t.width,n=e+t.height,o=this.m11,r=this.m12,l=this.m21,h=this.m22,a=this.dx,c=this.dy,f=i*o+e*l+a,u=i*r+e*h+c,d=s*o+e*l+a,m=s*r+e*h+c,g=i*o+n*l+a,p=i*r+n*h+c,y=s*o+n*l+a,x=s*r+n*h+c;let k=f,b=f,P=u,M=u;return k=Math.min(k,d),b=Math.max(b,d),P=Math.min(P,m),M=Math.max(M,m),k=Math.min(k,g),b=Math.max(b,g),P=Math.min(P,p),M=Math.max(M,p),k=Math.min(k,y),b=Math.max(b,y),P=Math.min(P,x),M=Math.max(M,x),t.e(k,P,b-k,M-P),t}static fC=[];static l(){const t=Transform.fC.pop();return t===void 0?new Transform:t}static s(t){Transform.fC.push(t)}static Ik="54a702f3e53909c447824c6706603faf4c"}const Geo={FD:"7da71ca0ad381e90",Un:4*((Math.sqrt(2)-1)/3),uC:null,bw:w=>{if(w<=0)return 0;let t=Geo.uC;if(t===null){t=[];for(let i=0;i<=2e3;i++)t[i]=Math.sqrt(i);Geo.uC=t}if(w<1){const i=1/w;return i<=2e3?1/t[i|0]:Math.sqrt(w)}else return w<=2e3?t[w|0]:Math.sqrt(w)},u:(w,t)=>{const i=w-t;return i<.5&&i>-.5},K:(w,t)=>{const i=w-t;return i<5e-8&&i>-5e-8},vi:(w,t,i,e,s,n,o)=>{s<=0&&(s=1e-6);let r=0,l=0,h=0,a=0;if(wu-d)if(w-i>s||i-w>s){const g=(e-t)/(i-w)*(n-w)+t;if(g-s<=o&&o<=g+s)return!0}else return!0;else if(t-e>s||e-t>s){const g=(i-w)/(e-t)*(o-t)+w;if(g-s<=n&&n<=g+s)return!0}else return!0}return!1},kw:(w,t,i,e,s,n,o,r,l,h,a,c)=>{if(!Geo.vi(w,t,o,r,c,i,e)||!Geo.vi(w,t,o,r,c,s,n)){const f=(w+i)/2,u=(t+e)/2,d=(i+s)/2,m=(e+n)/2,g=(s+o)/2,p=(n+r)/2,y=(f+d)/2,x=(u+m)/2,k=(d+g)/2,b=(m+p)/2,P=(y+k)/2,M=(x+b)/2;return Geo.kw(w,t,f,u,y,x,P,M,l,h,a,c)||Geo.kw(P,M,k,b,g,p,o,r,l,h,a,c)}else return Geo.vi(w,t,o,r,c,h,a)},dC:(w,t,i,e,s,n,o,r,l)=>{const h=(w+i)/2,a=(t+e)/2,c=(i+s)/2,f=(e+n)/2,u=(s+o)/2,d=(n+r)/2,m=(h+c)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2;return l.e((m+p)/2,(g+y)/2),l},RD:(w,t,i,e,s,n,o,r)=>{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(s+o)/2,u=(n+r)/2,d=(l+a)/2,m=(h+c)/2,g=(a+f)/2,p=(c+u)/2;return Point.direction(d,m,g,p)},au:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.vi(w,t,o,r,l,i,e)||!Geo.vi(w,t,o,r,l,s,n)){const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.au(w,t,a,c,g,p,k,b,l,h),Geo.au(k,b,y,x,d,m,o,r,l,h)}else h.unionNoCheck(w,t,0,0),h.unionNoCheck(o,r,0,0);return h},Bn:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.vi(w,t,o,r,l,i,e)||!Geo.vi(w,t,o,r,l,s,n)){const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.Bn(w,t,a,c,g,p,k,b,l,h),Geo.Bn(k,b,y,x,d,m,o,r,l,h)}else h.length===0&&(h.push(w),h.push(t)),h.push(o),h.push(r);return h},Ek:(w,t,i,e,s,n,o,r,l,h)=>{if(Geo.vi(w,t,s,n,h,i,e))return Geo.vi(w,t,s,n,h,r,l);{const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(a+f)/2,m=(c+u)/2;return Geo.Ek(w,t,a,c,d,m,o,r,l,h)||Geo.Ek(d,m,f,u,s,n,o,r,l,h)}},eE:(w,t,i,e,s,n,o)=>{const r=(w+i)/2,l=(t+e)/2,h=(i+s)/2,a=(e+n)/2;return o.e((r+h)/2,(l+a)/2),o},Uk:(w,t,i,e,s,n,o,r)=>{if(Geo.vi(w,t,s,n,o,i,e))r.unionNoCheck(w,t,0,0),r.unionNoCheck(s,n,0,0);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(l+a)/2,u=(h+c)/2;Geo.Uk(w,t,l,h,f,u,o,r),Geo.Uk(f,u,a,c,s,n,o,r)}return r},Bg:(w,t,i,e,s,n,o,r)=>{if(Geo.vi(w,t,s,n,o,i,e))r.length===0&&(r.push(w),r.push(t)),r.push(s),r.push(n);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(l+a)/2,u=(h+c)/2;Geo.Bg(w,t,l,h,f,u,o,r),Geo.Bg(f,u,a,c,s,n,o,r)}return r},Vg:(w,t,i,e,s,n,o,r,l,h,a,c,f,u)=>{if(!Geo.vi(w,t,o,r,f,i,e)||!Geo.vi(w,t,o,r,f,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,P=(g+y)/2,M=(p+x)/2,L=(k+P)/2,C=(b+M)/2;let S=1/0,N=!1,T=0,A=0;if(Geo.Vg(w,t,d,m,k,b,L,C,l,h,a,c,f,u)){const D=(u.x-l)*(u.x-l)+(u.y-h)*(u.y-h);D{let u=0;if(!Geo.vi(w,t,o,r,f,i,e)||!Geo.vi(w,t,o,r,f,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,P=(g+y)/2,M=(p+x)/2,L=(k+P)/2,C=(b+M)/2;u+=Geo.zg(w,t,d,m,k,b,L,C,l,h,a,c,f),u+=Geo.zg(L,C,P,M,y,x,o,r,l,h,a,c,f)}else{const d=(w-o)*(h-c)-(t-r)*(l-a);if(d===0)return u;const m=((w*r-t*o)*(l-a)-(w-o)*(l*c-h*a))/d,g=((w*r-t*o)*(h-c)-(t-r)*(l*c-h*a))/d;if(m>=a)return u;let p=0,y=0;if((l>a?l-a:a-l)<(h>c?h-c:c-h)){if(ty)return u}else if(wy)return u;d>0?u++:d<0&&u--}return u},ml:(w,t,i,e,s,n,o)=>{if(Geo.K(w,i)){let r=0,l=0;tl?(o.e(w,l),!1):(o.e(w,h),!0)}else if(Geo.K(t,e)){let r=0,l=0;wl?(o.e(l,t),!1):(o.e(h,t),!0)}else{const r=(i-w)*(i-w)+(e-t)*(e-t),l=((w-s)*(w-i)+(t-n)*(t-e))/r;if(l<-5e-6)return o.e(w,t),!1;if(l>1.000005)return o.e(i,e),!1;{const h=w+l*(i-w),a=t+l*(e-t);return o.e(h,a),!0}}},Vn:(w,t,i,e,s,n,o,r,l)=>{if(Geo.u(w,i)&&Geo.u(t,e))return l.e(w,t),!1;if(Geo.K(s,o)){if(Geo.K(w,i))return Geo.ml(w,t,i,e,s,n,l),!1;{const a=(e-t)/(i-w)*(s-w)+t;return Geo.ml(w,t,i,e,s,a,l)}}else{const h=(r-n)/(o-s);if(Geo.K(w,i)){const a=h*(w-s)+n;let c=0,f=0;return tf?(l.e(w,f),!1):(l.e(w,a),!0)}else{const a=(e-t)/(i-w);if(Geo.K(h,a))return Geo.ml(w,t,i,e,s,n,l),!1;{const c=(a*w-h*s+n-t)/(a-h);if(Geo.K(a,0)){let f=0,u=0;return wu?(l.e(u,t),!1):(l.e(c,t),!0)}else{const f=a*(c-w)+t;return Geo.ml(w,t,i,e,c,f,l)}}}}},sE:(w,t,i,e,s)=>Geo.Vn(i.x,i.y,e.x,e.y,w.x,w.y,t.x,t.y,s),nE:(w,t,i,e,s,n,o,r,l,h)=>{let a=1/0;function c(P,M){const L=(P-w)*(P-w)+(M-t)*(M-t);Lw?i-w:w-i)<.5){const P=1-(i-k)*(i-k)/(y*y);if(P<0)return l;const M=Math.sqrt(P),L=x*M+b,C=-x*M+b;c(i,L),c(i,C)}else{const P=(e-t)/(i-w),M=1/(y*y)+P*P/(x*x),L=2*P*(t-P*w)/(x*x)-2*P*b/(x*x)-2*k/(y*y),C=2*P*w*b/(x*x)-2*t*b/(x*x)+b*b/(x*x)+k*k/(y*y)-1+(t-P*w)*(t-P*w)/(x*x),S=L*L-4*M*C;if(S<0)return l;const N=Math.sqrt(S),T=(-L+N)/(2*M);c(T,P*T-P*w+t);const A=(-L-N)/(2*M);c(A,P*A-P*w+t)}return l},pl:(w,t,i,e,s,n,o,r,l)=>{let h=1e21,a=w,c=t;if(Geo.Vn(w,t,w,e,s,n,o,r,l)){const f=(l.x-s)*(l.x-s)+(l.y-n)*(l.y-n);fGeo.rC(w.x,w.y,w.width,w.height,t.x,t.y,i.x,i.y),rC:(w,t,i,e,s,n,o,r)=>{const l=w,h=w+i,a=t,c=t+e;if(s===o){let f=0,u=0;return n=a}if(n===r){let f=0,u=0;return s=l}return!!(Rect.contains(w,t,i,e,s,n)||Rect.contains(w,t,i,e,o,r)||Geo.ru(l,a,h,a,s,n,o,r)||Geo.ru(h,a,h,c,s,n,o,r)||Geo.ru(h,c,l,c,s,n,o,r)||Geo.ru(l,c,l,a,s,n,o,r))},ru:(w,t,i,e,s,n,o,r)=>w===i&&t===e&&s===o&&n===r?w===s&&t===n:Geo.ou(w,t,i,e,s,n)*Geo.ou(w,t,i,e,o,r)<=0&&Geo.ou(s,n,o,r,w,t)*Geo.ou(s,n,o,r,i,e)<=0,ou:(w,t,i,e,s,n)=>{const o=i-w,r=e-t;let l=s-w,h=n-t,a=l*r-h*o;return a===0&&(a=l*o+h*r,a>0&&(l-=o,h-=r,a=l*o+h*r,a<0&&(a=0))),a},Xg:w=>(w<0&&(w+=360),w>=360&&(w-=360),w),gC:(w,t,i,e,s,n)=>{const o=Math.PI;n||(e=e*(o/180),s=s*(o/180));const r=e>s?-1:1,l=1e-5,h=o*2,a=[],c=o/2;let f=e,u=Math.min(h,Math.abs(s-e));if(ul;){const d=f+r*Math.min(u,c);a.push(Geo.vD(i,f,d,w,t)),u-=Math.abs(d-f),f=d}return a},vD:(w,t,i,e,s)=>{const n=(i-t)/2,o=w*Math.cos(n),r=w*Math.sin(n),l=o,h=-r,a=l*l+h*h,c=a+l*o+h*r,f=4/3*(Math.sqrt(2*a*c)-c)/(l*r-h*o),u=l-f*h,d=h+f*l,m=u,g=-d,p=n+t,y=Math.cos(p),x=Math.sin(p);return[e+w*Math.cos(t),s+w*Math.sin(t),e+u*y-d*x,s+u*x+d*y,e+m*y-g*x,s+m*x+g*y,e+w*Math.cos(i),s+w*Math.sin(i)]},Eg:(w,t,i,e,s,n,o)=>{const r=s,l=n,h=Math.floor((w-i)/r)*r+i,a=Math.floor((t-e)/l)*l+e;let c=h;h+r-w{let i=Math.max(w,t),e=Math.min(w,t),s=1,n=1;do s=i%e,n=e,i=e,e=s;while(s>0);return n},OD:(w,t,i,e)=>{const s=i<0,n=e<0;let o=0,r=0,l=0;w{let o=0;if(e>0)if(i>0){const r=w*w,l=t*t,h=w*i,a=t*e;let c=-l+a,f=-l+Math.sqrt(h*h+a*a),u=c;const d=9999999999;for(let p=0;p0)c=u;else if(k<0)f=u;else break}s=r*i/(u+r),n=l*e/(u+l);const m=s-i,g=n-e;o=Math.sqrt(m*m+g*g)}else s=0,n=t,o=Math.abs(e-t);else{const r=w*w-t*t,l=w*i;if(l(w[w.Line=1]="Line",w[w.Rectangle=2]="Rectangle",w[w.Ellipse=3]="Ellipse",w[w.Path=4]="Path",w))(GeometryType||{}),GeometryStretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w))(GeometryStretch||{});class Geometry{n;Gg;jg;ic;cu;fu;zn;Xn;Kn;Z;xe;be;Zi;Qi;Fs;ec;sc;constructor(t){GSet.Yi(this),this.n=2,t===void 0&&(t=4),this.Z=t,this.xe=0,this.be=0,this.Zi=0,this.Qi=0,t===4?this.Fs=new List:this.Fs=Geometry.Mw,this.Gg=this.Fs.at,this.jg=new Rect().g(),this.ic=null,this.cu=null,this.fu=NaN,this.zn=Spot.TopLeft,this.Xn=Spot.BottomRight,this.ec=NaN,this.sc=NaN,this.Kn=2}copy(){const t=new Geometry;if(t.n=this.n&-2,t.Z=this.Z,t.xe=this.xe,t.be=this.be,t.Zi=this.Zi,t.Qi=this.Qi,this.Z===4){const i=this.Fs.r,e=t.Fs;for(let s=0;si.toString(t)}ri(t){t in GeometryType?this.type=t:Util.lr(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e;switch(this.type){case 1:return t<0?"M"+this.startX.toString()+" "+this.startY.toString()+"L"+this.endX.toString()+" "+this.endY.toString():"M"+i(this.startX)+" "+i(this.startY)+"L"+i(this.endX)+" "+i(this.endY);case 2:return e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0?"M"+e.x.toString()+" "+e.y.toString()+"H"+e.right.toString()+"V"+e.bottom.toString()+"H"+e.left.toString()+"z":"M"+i(e.x)+" "+i(e.y)+"H"+i(e.right)+"V"+i(e.bottom)+"H"+i(e.left)+"z";case 3:if(e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0){const r=e.left.toString()+" "+(e.y+e.height/2).toString(),l=e.right.toString()+" "+(e.y+e.height/2).toString();return"M"+r+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+l+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+r}else{const r=i(e.left)+" "+i(e.y+e.height/2),l=i(e.right)+" "+i(e.y+e.height/2);return"M"+r+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+l+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+r}case 4:let s="";const n=this.figures.r,o=n.length;for(let r=0;r0&&(s+=" x "),l.isFilled&&(s+="F "),s+=l.toString(t)}return s;default:return GeometryType[this.type]}}static fillPath(t){typeof t!="string"&&Util.we(t,"string",Geometry,"fillPath:str");const i=t.split(/[Xx]/),e=i.length;let s="";for(let n=0;n=k-1||o[r+1].match(N)!==null?!0:(u=!1,!1)}function m(){return r++,o[r]}function g(A){let D=parseFloat(m()),F=parseFloat(m());l===l.toLowerCase()&&(D=f.x+D,F=f.y+F),A.e(D,F)}function p(){return g(f),f}function y(){return g(c),c}function x(){const A=h.toLowerCase();return A==="c"||A==="s"||A==="q"||A==="t"?new Point(2*f.x-c.x,2*f.y-c.y):new Point(f.x,f.y)}const k=o.length,b=GeoStream.yC(null);let P=!1,M=!1,L=!1,C=!0,S=null;const N=new RegExp("["+Geometry.Hg+"]");for(;!(r>=k-1);){if(h=l,l=m(),l==="")continue;u=!0;let A=!1;switch(l.toUpperCase()){case"X":C=!0,P=!1,M=!1;break;case"M":for(S=p(),b.Pi===null||C===!0?(b.uu(S.x,S.y,P,!1,!M,L),C=!1):b.ED(S.x,S.y),a.a(f);!d();)S=p(),b.ur(S.x,S.y);break;case"L":for(;!d();)S=p(),b.ur(S.x,S.y);u&&(A=!0);break;case"H":for(;!d();)f.e((l===l.toLowerCase()?f.x:0)+parseFloat(m()),f.y),b.ur(f.x,f.y);break;case"V":for(;!d();)f.e(f.x,(l===l.toLowerCase()?f.y:0)+parseFloat(m())),b.ur(f.x,f.y);u&&(A=!0);break;case"C":for(;!d();){const D=new Point;g(D);const F=y(),R=p();b.dr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(A=!0);break;case"S":for(;!d();){const D=x(),F=y(),R=p();b.dr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(A=!0);break;case"Q":for(;!d();){const D=y(),F=p();b.Sw(D.x,D.y,F.x,F.y)}u&&(A=!0);break;case"T":for(;!d();){const D=x();c.a(D);const F=p();b.Sw(D.x,D.y,F.x,F.y),c.a(F)}u&&(A=!0);break;case"B":for(;!d();){const D=parseFloat(m()),F=parseFloat(m());let R=parseFloat(m()),v=parseFloat(m());const O=parseFloat(m());let U=O,X=!1;d()||(U=parseFloat(m()),d()||(X=parseFloat(m())!==0)),l===l.toLowerCase()&&(R+=f.x,v+=f.y),b.UD(D,F,R,v,O,U,X)}u&&(A=!0);break;case"A":for(;!d();){const D=Math.abs(parseFloat(m())),F=Math.abs(parseFloat(m())),R=parseFloat(m());let v=!1,O=!1,U=0,X=0;const E=m();E.length===1?(v=!!parseFloat(E),O=!!parseFloat(m()),U=parseFloat(m()),X=parseFloat(m())):E.length===2?(v=!!parseFloat(E[0]),O=!!parseFloat(E[1]),U=parseFloat(m()),X=parseFloat(m())):(v=!!parseFloat(E[0]),O=!!parseFloat(E[1]),U=parseFloat(E.slice(2)),X=parseFloat(m())),l===l.toLowerCase()&&(U=f.x+U,X=f.y+X),f.e(U,X),b.BD(D,F,R,v,O,U,X)}u&&(A=!0);break;case"Z":b.VD(),f.a(a);break;case"F":{let D="",F=1;for(;o[r+F];){if(o[r+F]==="0"){L=!0,F++;continue}if(o[r+F].match(/[Uu]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?P=!0:b.zD();break}case"U":{let D="",F=1;for(;o[r+F];){if(o[r+F].match(/[Ff]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?M=!0:b.XD(!1);break}default:if(l==="0"||l==="1")break;Util.oi("Unknown geometry command: "+l);break}if(A){Util.oi(`Bad geometry command: ${l}, next token: ${m()}, -string: ${t}`);break}}const T=b.qg;if(GeoStream.wC(b),i){const A=T.figures.iterator;for(;A.next();){const D=A.value;D.isFilled=!0}}return T}static xC(t,i){const e=t.length,s=Point.l();for(let n=0;n=t)return 0;if((n>r?n-r:r-n)<(o>l?o-l:l-o)){if(ol)return 0}else if(co)return 0}else if(nr)return 0}else if(an)return 0;return h>0?1:-1}kC(t,i,e){const s=this.figures.r,n=s.length;for(let o=0;o1&&(t=1),i===void 0&&(i=new Point),this.type===1)return i.e(this.startX+t*(this.endX-this.startX),this.startY+t*(this.endY-this.startY)),i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[f*2],y=g[f*2+1],x=g[f*2+2],k=g[f*2+3];return i.e(p+(x-p)*m,y+(k-y)*m),i}l+=u}}return i}getAngleAlongPath(t){if(t<0?t=0:t>1&&(t=1),this.type===1)return Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI;const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=i.length,o=s*t;let r=0;for(let l=0;l=o){const u=i[l],d=u[c*2],m=u[c*2+1],g=u[c*2+2],p=u[c*2+3];return Math.abs(g-d)<1&&Math.abs(p-m)<1?0:Math.abs(g-d)<1?p-m>=0?90:270:Math.abs(p-m)<1?g-d>=0?0:180:Math.atan2(p-m,g-d)*180/Math.PI}r+=f}}return NaN}getPointAndAngleAlongPath(t,i){if(t<0?t=0:t>1&&(t=1),i===void 0&&(i=[]),i.length=3,this.type===1)return i[0]=this.startX+t*(this.endX-this.startX),i[1]=this.startY+t*(this.endY-this.startY),i[2]=Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI,i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[f*2],y=g[f*2+1],x=g[f*2+2],k=g[f*2+3];i[0]=p+(x-p)*m,i[1]=y+(k-y)*m;let b;return Math.abs(x-p)<1&&Math.abs(k-y)<1?b=0:Math.abs(x-p)<1?b=k-y>=0?90:270:Math.abs(k-y)<1?b=x-p>=0?0:180:b=Math.atan2(k-y,x-p)*180/Math.PI,i[2]=b,i}l+=u}}return i}getFractionForPoint(t){if(this.type===1){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=t.x,r=t.y;let l=0,h=0;if(i===s)return e=h?h===e?0:1:Math.abs(r-e)/(h-l);if(e===n)return i=h?h===i?0:1:Math.abs(o-i)/(h-l);{const a=(s-i)*(s-i)+(n-e)*(n-e),c=Point.l();Geo.ml(i,e,s,n,o,r,c);const f=c.x,u=c.y;return Point.s(c),Math.sqrt(((f-i)*(f-i)+(u-e)*(u-e))/a)}}}else if(this.type===2){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=s-i,r=n-e,l=o*2+r*2;let h=t.x,a=t.y;h=Math.min(Math.max(h,i),s),a=Math.min(Math.max(a,e),n);const c=Math.abs(h-i),f=Math.abs(h-s),u=Math.abs(a-e),d=Math.abs(a-n),m=Math.min(c,f,u,d);if(m===u)return h/l;if(m===f)return(o+a)/l;if(m===d)return(o*2+r-h)/l;if(m===c)return(o*2+r*2-a)/l}}else{const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=Point.l();let o=1/0,r=0,l=0;const h=i.length;let a=0,c=0;for(let u=0;u1?1:f}return 0}get flattenedSegments(){return this.PC(),this.ic}PC(){if(this.ic===null){const t=this.ic=[],i=this.cu=[];this.GD(t,i)}}get flattenedLengths(){return this.PC(),this.cu}get flattenedTotalLength(){let t=this.fu;if(isNaN(t)){if(this.type===1){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=Math.sqrt(i*i+e*e)}else if(this.type===2){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=i*2+e*2}else{const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=4&&(t.push(e),i.push(this.Xk(e))),e=[],e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY,h=r,a=l;break;case 2:e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY;break;case 3:Geo.Bn(r,l,d.point1X,d.point1Y,d.point2X,d.point2Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 4:Geo.Bg(r,l,d.point1X,d.point1Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 5:{const m=d.So(o),g=m.length;if(g===0){e.push(d.centerX),e.push(d.centerY),r=d.centerX,l=d.centerY;break}for(let p=0;p=4&&(t.push(e),i.push(this.Xk(e)))}}}get type(){return this.Z}set type(t){this.Z!==t&&(this.h&&Util.T(this,t),this.Z=t,t===4?this.Fs=new List:(Geometry.Mw===null&&(Geometry.Mw=new List().g()),this.Fs=Geometry.Mw),this.bt=!0)}get startX(){return this.xe}set startX(t){this.xe!==t&&(this.h&&Util.T(this,t),this.xe=t,this.bt=!0)}get startY(){return this.be}set startY(t){this.be!==t&&(this.h&&Util.T(this,t),this.be=t,this.bt=!0)}get endX(){return this.Zi}set endX(t){this.Zi!==t&&(this.h&&Util.T(this,t),this.Zi=t,this.bt=!0)}get endY(){return this.Qi}set endY(t){this.Qi!==t&&(this.h&&Util.T(this,t),this.Qi=t,this.bt=!0)}get figures(){return this.Fs}set figures(t){this.Fs!==t&&(this.h&&Util.T(this,t),this.Fs=t,this.bt=!0)}add(t){return this.Fs.add(t),this}setSpots(t,i,e,s,n,o,r,l){return this.h&&Util.T(this),this.zn=new Spot(t,i,n,o).g(),this.Xn=new Spot(e,s,r,l).g(),this}get spot1(){return this.zn}set spot1(t){this.h&&Util.T(this,t),this.zn=t.N()}get spot2(){return this.Xn}set spot2(t){this.h&&Util.T(this,t),this.Xn=t.N()}get defaultStretch(){return this.Kn}set defaultStretch(t){this.Kn=t}get bounds(){return this.Bk()&&this.Nw(),this.jg}}Geometry.stringify=Geometry.stringify;Geometry.stringifyFixed=Geometry.stringifyFixed;Geometry.fillPath=Geometry.fillPath;Geometry.parse=Geometry.parse;class PathFigure{n;xe;be;nc;Wg;Ue;constructor(t,i,e,s,n){e===void 0&&(e=!0),s===void 0&&(s=!0),n===void 0&&(n=!1),this.n=2|(e?4:0)|(s?8:0)|(n?16:0),t!==void 0?this.xe=t:this.xe=0,i!==void 0?this.be=i:this.be=0,this.nc=new List,this.Wg=this.nc.at,this.Ue=null}copy(){const t=new PathFigure;t.n=this.n&-2,t.xe=this.xe,t.be=this.be;const i=this.nc.r,e=i.length,s=t.nc;for(let n=0;no===0?"0":o.toFixed(t);i="M"+n(this.startX)+" "+n(this.startY)}const e=this.segments.r,s=e.length;for(let n=0;n(w[w.Move=1]="Move",w[w.Line=2]="Line",w[w.Bezier=3]="Bezier",w[w.QuadraticBezier=4]="QuadraticBezier",w[w.Arc=5]="Arc",w[w.SvgArc=6]="SvgArc",w))(SegmentType||{});class PathSegment{Z;n;Zi;Qi;hn;yl;wl;gr;Rs;constructor(t,i,e,s,n,o,r,l){if(GSet.Yi(this),t===void 0&&(t=2),this.Z=t,this.n=2,i!==void 0?this.Zi=i:this.Zi=0,e!==void 0?this.Qi=e:this.Qi=0,s===void 0&&(s=0),n===void 0&&(n=0),o===void 0&&(o=0),r===void 0&&(r=0),t===6){let h=o;h=h%360,h<0&&(h+=360),this.hn=h,this.yl=0,this.wl=Math.max(s,0),this.gr=Math.max(n,0),typeof r=="boolean"?r&&(this.isLargeArc=!0):typeof r=="number"&&r&&(this.isLargeArc=!0),l&&(this.isClockwiseArc=!0)}else this.hn=s,this.yl=n,t===5&&(o=Math.max(o,0)),this.wl=o,typeof r=="number"?(t===5&&(r=Math.max(r,0)),this.gr=r):this.gr=0;this.Rs=null}copy(){const t=new PathSegment;return t.Z=this.Z,t.n=this.n&-2,t.Zi=this.Zi,t.Qi=this.Qi,t.hn=this.hn,t.yl=this.yl,t.wl=this.wl,t.gr=this.gr,t}equalsApprox(t){if(!(t instanceof PathSegment)||this.type!==t.type||this.isClosed!==t.isClosed)return!1;switch(this.type){case 1:case 2:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY);case 3:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.point1X,t.point1X)&&Geo.u(this.point1Y,t.point1Y)&&Geo.u(this.point2X,t.point2X)&&Geo.u(this.point2Y,t.point2Y);case 4:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.point1X,t.point1X)&&Geo.u(this.point1Y,t.point1Y);case 5:return Geo.u(this.startAngle,t.startAngle)&&Geo.u(this.sweepAngle,t.sweepAngle)&&Geo.u(this.centerX,t.centerX)&&Geo.u(this.centerY,t.centerY)&&Geo.u(this.radiusX,t.radiusX)&&Geo.u(this.radiusY,t.radiusY);case 6:return this.isClockwiseArc===t.isClockwiseArc&&this.isLargeArc===t.isLargeArc&&Geo.u(this.xAxisRotation,t.xAxisRotation)&&Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.radiusX,t.radiusX)&&Geo.u(this.radiusY,t.radiusY);default:return!1}}ri(t){t in SegmentType?this.type=t:Util.lr(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e="";switch(this.type){case 1:t<0?e="M"+this.endX.toString()+" "+this.endY.toString():e="M"+i(this.endX)+" "+i(this.endY);break;case 2:t<0?e="L"+this.endX.toString()+" "+this.endY.toString():e="L"+i(this.endX)+" "+i(this.endY);break;case 3:t<0?e="C"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.point2X.toString()+" "+this.point2Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="C"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.point2X)+" "+i(this.point2Y)+" "+i(this.endX)+" "+i(this.endY);break;case 4:t<0?e="Q"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="Q"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.endX)+" "+i(this.endY);break;case 5:t<0?e="B"+this.startAngle.toString()+" "+this.sweepAngle.toString()+" "+this.centerX.toString()+" "+this.centerY.toString()+" "+this.radiusX.toString()+" "+this.radiusY.toString():e="B"+i(this.startAngle)+" "+i(this.sweepAngle)+" "+i(this.centerX)+" "+i(this.centerY)+" "+i(this.radiusX)+" "+i(this.radiusY);break;case 6:t<0?e="A"+this.radiusX.toString()+" "+this.radiusY.toString()+" "+this.xAxisRotation.toString()+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+this.endX.toString()+" "+this.endY.toString():e="A"+i(this.radiusX)+" "+i(this.radiusY)+" "+i(this.xAxisRotation)+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+i(this.endX)+" "+i(this.endY);break;default:e=SegmentType[this.type]}return e+(this.isClosed?"z":"")}static Move=1;static Line=2;static Bezier=3;static QuadraticBezier=4;static Arc=5;static SvgArc=6;get h(){return(this.n&1)!==0}set h(t){t?this.n|=1:this.n&=-2}get bt(){return(this.n&2)!==0}set bt(t){t?this.n|=2:this.n&=-3}g(){return this.h=!0,this}rt(){return this.h=!1,this}close(){return this.isClosed=!0,this}So(t){if(this.Rs!==null&&t.bt===!1)return this.Rs;const i=this.radiusX;let e=this.radiusY;if(e===void 0&&(e=i),i===0||e===0)return this.Rs=[],this.Rs;const s=this.hn,n=this.yl,o=Geo.gC(0,0,i1&&(o*=Math.sqrt(p),r*=Math.sqrt(p));let y=(h===a?-1:1)*Math.sqrt((o*o*r*r-o*o*g*g-r*r*m*m)/(o*o*g*g+r*r*m*m));isNaN(y)&&(y=0);let x=y*o*g/r,k=y*-r*m/o;isNaN(x)&&(x=0),isNaN(k)&&(k=0);const b=(s+c)/2+u*x-d*k,P=(n+f)/2+d*x+u*k,M=(V,B)=>Math.sqrt(V*V+B*B),L=(V,B,Y,G)=>(V*Y+B*G)/(M(V,B)*M(Y,G)),C=(V,B,Y,G)=>(V*G=1&&(F=0),!a&&F>0&&(F=F-2*Math.PI),a&&F<0&&(F=F+2*Math.PI);const v=o>r?o:r,O=o>r?1:o/r,U=o>r?r/o:1,X=Geo.gC(0,0,v,S,S+F,!0),E=Transform.l();return E.Ri(),E.Ds(b,P),E.cs(this.hn,0,0),E.st(O,U),Geometry.xC(X,E),Transform.s(E),this.Rs=X,this.Rs}get isClosed(){return(this.n&8)!==0}set isClosed(t){this.isClosed!==t&&(t?this.n|=8:this.n&=-9,this.bt=!0)}get type(){return this.Z}set type(t){this.h&&Util.T(this,t),this.Z=t,this.bt=!0}get endX(){return this.Zi}set endX(t){this.h&&Util.T(this,t),this.Zi=t,this.bt=!0}get endY(){return this.Qi}set endY(t){this.h&&Util.T(this,t),this.Qi=t,this.bt=!0}get point1X(){return this.hn}set point1X(t){this.h&&Util.T(this,t),this.hn=t,this.bt=!0}get point1Y(){return this.yl}set point1Y(t){this.h&&Util.T(this,t),this.yl=t,this.bt=!0}get point2X(){return this.wl}set point2X(t){this.h&&Util.T(this,t),this.wl=t,this.bt=!0}get point2Y(){return this.gr}set point2Y(t){this.h&&Util.T(this,t),this.gr=t,this.bt=!0}get centerX(){return this.hn}set centerX(t){this.h&&Util.T(this,t),this.hn=t,this.bt=!0}get centerY(){return this.yl}set centerY(t){this.h&&Util.T(this,t),this.yl=t,this.bt=!0}get radiusX(){return this.wl}set radiusX(t){t<0&&Util._(t,">= zero",PathSegment,"radiusX"),this.h&&Util.T(this,t),this.wl=t,this.bt=!0}get radiusY(){return this.gr}set radiusY(t){t<0&&Util._(t,">= zero",PathSegment,"radiusY"),this.h&&Util.T(this,t),this.gr=t,this.bt=!0}get startAngle(){return this.Zi}set startAngle(t){this.h&&Util.T(this,t),t=t%360,t<0&&(t+=360),this.Zi=t,this.bt=!0}get sweepAngle(){return this.Qi}set sweepAngle(t){this.h&&Util.T(this,t),t>360&&(t=360),t<-360&&(t=-360),this.Qi=t,this.bt=!0}get isClockwiseArc(){return(this.n&4)!==0}set isClockwiseArc(t){this.h&&Util.T(this,t),t?this.n|=4:this.n&=-5,this.bt=!0}get isLargeArc(){return(this.n&16)!==0}set isLargeArc(t){this.h&&Util.T(this,t),t?this.n|=16:this.n&=-17,this.bt=!0}get xAxisRotation(){return this.hn}set xAxisRotation(t){this.h&&Util.T(this,t),t=t%360,t<0&&(t+=360),this.hn=t,this.bt=!0}}class InputEvent{p;Lw;Aw;Jg;$g;Zg;Qg;_g;tm;im;em;sm;nm;om;No;rm;lm;hm;ke;constructor(){this.p=null,this.Lw=new Point(0,0).g(),this.Aw=new Point(0,0).g(),this.Jg=0,this.$g=0,this.Zg=1,this.Qg="",this._g="",this.tm=!1,this.im=!1,this.em=0,this.sm=0,this.nm=!1,this.om=!1,this.No=!1,this.rm=null,this.lm=0,this.hm=null,this.ke=null}copy(){const t=new InputEvent;return this.clone(t)}clone(t){return t.p=this.p,t.Lw.a(this.viewPoint),t.Aw.a(this.documentPoint),t.Jg=this.Jg,t.$g=this.$g,t.Zg=this.Zg,t.Qg=this.Qg,t._g=this._g,t.tm=this.tm,t.im=this.im,t.em=this.em,t.sm=this.sm,t.nm=this.nm,t.om=this.om,t.No=this.No,t.rm=this.rm,t.lm=this.lm,t.hm=this.hm,t.ke=this.ke,t}toString(){let t="^";return this.modifiers!==0&&(t+="M:"+this.modifiers),this.button!==0&&(t+="B:"+this.button),this.key!==""&&(t+="K:"+this.key),this.clickCount!==0&&(t+="C:"+this.clickCount),this.delta!==0&&(t+="D:"+this.delta),this.handled&&(t+="h"),this.bubbles&&(t+="b"),this.documentPoint!==null&&(t+="@"+this.documentPoint.toString()),t}get diagram(){return this.p}set diagram(t){this.p=t}get viewPoint(){return this.Lw}set viewPoint(t){this.Lw.a(t)}get documentPoint(){return this.Aw}set documentPoint(t){this.Aw.a(t)}getMultiTouchViewPoint(t,i){const e=this.diagram;return e===null||e.MC(this.event,t,i),i}getMultiTouchDocumentPoint(t,i){const e=this.diagram;return e===null||(e.MC(this.event,t,i),i.a(e.transformViewToDoc(i))),i}get modifiers(){return this.Jg}set modifiers(t){this.Jg=t}get button(){return this.$g}set button(t){if(this.$g=t,this.event===null)switch(t){case 0:this.buttons=1;return;case 1:this.buttons=4;return;case 2:this.buttons=2;return}}get buttons(){return this.Zg}set buttons(t){this.Zg=t}get key(){return this.Qg}set key(t){this.Qg=t}get code(){return this._g}set code(t){this._g=t}get down(){return this.tm}set down(t){this.tm=t}get up(){return this.im}set up(t){this.im=t}get clickCount(){return this.em}set clickCount(t){this.em=t}get delta(){return this.sm}set delta(t){this.sm=t}get isMultiTouch(){return this.nm}set isMultiTouch(t){this.nm=t}get handled(){return this.om}set handled(t){this.om=t}get bubbles(){return this.No}set bubbles(t){this.No=t}get event(){return this.rm}set event(t){this.rm=t}get isTouchEvent(){const t=this.event;return t===null?!1:t.pointerType==="touch"||t.pointerType==="pen"}get timestamp(){return this.lm}set timestamp(t){this.lm=t}get targetDiagram(){return this.hm}set targetDiagram(t){this.hm=t}get targetObject(){return this.ke}set targetObject(t){this.ke=t}get control(){return(this.modifiers&1)!==0}set control(t){this.modifiers=t?this.modifiers|1:this.modifiers&-2}get shift(){return(this.modifiers&4)!==0}set shift(t){this.modifiers=t?this.modifiers|4:this.modifiers&-5}get alt(){return(this.modifiers&2)!==0}set alt(t){this.modifiers=t?this.modifiers|2:this.modifiers&-3}get meta(){return(this.modifiers&8)!==0}set meta(t){this.modifiers=t?this.modifiers|8:this.modifiers&-9}get left(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===0:(this.buttons&1)!==0}set left(t){t?this.buttons|=1:this.buttons&=-2}get right(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===2:(this.buttons&2)!==0}set right(t){t?this.buttons|=2:this.buttons&=-3}get middle(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===1:(this.buttons&4)!==0}set middle(t){t?this.buttons|=4:this.buttons&=-5}get commandKey(){const t=this.code,i=this.key;return"cxvyzagCXVYZAG".includes(i)?i.toLowerCase():t==="KeyC"?"c":t==="KeyX"?"x":t==="KeyV"?"v":t==="KeyY"?"y":t==="KeyZ"?"z":t==="KeyA"?"a":t==="KeyG"?"g":t!==""?t:i}}class DiagramEvent{p;St;am;cm;constructor(){this.p=null,this.St="",this.am=null,this.cm=null}copy(){const t=new DiagramEvent;return t.p=this.p,t.St=this.St,t.am=this.am,t.cm=this.cm,t}toString(){let t="*"+this.name;return this.subject!==null&&(t+=":"+this.subject.toString()),this.parameter!==null&&(t+="("+this.parameter.toString()+")"),t}get diagram(){return this.p}set diagram(t){this.p=t}get name(){return this.St}set name(t){this.St=t}get subject(){return this.am}set subject(t){this.am=t}get parameter(){return this.cm}set parameter(t){this.cm=t}}var ChangeType=(w=>(w[w.Transaction=1]="Transaction",w[w.Property=2]="Property",w[w.Insert=3]="Insert",w[w.Remove=4]="Remove",w))(ChangeType||{});class ChangedEvent{du;fm;an;Mi;p;gu;oc;rc;lc;hc;constructor(){this.du=2,this.fm="",this.an="",this.Mi=null,this.p=null,this.gu=null,this.oc=null,this.rc=null,this.lc=null,this.hc=null}static Transaction=1;static Property=2;static Insert=3;static Remove=4;clear(){this.Mi=null,this.p=null,this.gu=null,this.oc=null,this.rc=null,this.lc=null,this.hc=null}copy(){const t=new ChangedEvent;t.du=this.du,t.fm=this.fm,t.an=this.an,t.Mi=this.Mi,t.p=this.p,t.gu=this.gu;let i=this.oc;return Util.wt(i)&&typeof i.copyFrozen=="function"?t.oc=i.copyFrozen():t.oc=i,i=this.rc,Util.wt(i)&&typeof i.copyFrozen=="function"?t.rc=i.copyFrozen():t.rc=i,i=this.lc,Util.wt(i)&&typeof i.copyFrozen=="function"?t.lc=i.copyFrozen():t.lc=i,i=this.hc,Util.wt(i)&&typeof i.copyFrozen=="function"?t.hc=i.copyFrozen():t.hc=i,t}ri(t){t in ChangeType?this.change=t:Util.lr(this,t)}toString(){let t="";return this.change===1?t+="* ":this.change===2?t+=this.model!==null?"!m":"!d":t+=(this.model!==null?"!m":"!d")+this.change,this.propertyName&&typeof this.propertyName=="string"&&(t+=" "+this.propertyName),this.modelChange&&this.modelChange!==this.propertyName&&(t+=" "+this.modelChange),t+=": ",this.change===1?this.oldValue!==null&&(t+=" "+this.oldValue):(this.object!==null&&(t+=Util.toString(this.object)),this.oldValue!==null&&(t+=" old: "+Util.toString(this.oldValue)),this.oldParam!==null&&(t+=" "+this.oldParam),this.newValue!==null&&(t+=" new: "+Util.toString(this.newValue)),this.newParam!==null&&(t+=" "+this.newParam)),t}getValue(t){return t?this.oldValue:this.newValue}getParam(t){return t?this.oldParam:this.newParam}canUndo(){return this.model!==null||this.diagram!==null}undo(){this.canUndo()&&(this.model!==null?this.model.changeState(this,!0):this.diagram!==null&&this.diagram.SC(this,!0))}canRedo(){return this.model!==null||this.diagram!==null}redo(){this.canRedo()&&(this.model!==null?this.model.changeState(this,!1):this.diagram!==null&&this.diagram.SC(this,!1))}get model(){return this.Mi}set model(t){this.Mi=t}get diagram(){return this.p}set diagram(t){this.p=t}get change(){return this.du}set change(t){this.du=t}get modelChange(){return this.fm}set modelChange(t){this.fm=t}get propertyName(){return this.an}set propertyName(t){this.an=t}get isTransactionFinished(){return this.du===1&&(this.an==="CommittedTransaction"||this.an==="FinishedUndo"||this.an==="FinishedRedo")}get object(){return this.gu}set object(t){this.gu=t}get oldValue(){return this.oc}set oldValue(t){this.oc=t}get oldParam(){return this.rc}set oldParam(t){this.rc=t}get newValue(){return this.lc}set newValue(t){this.lc=t}get newParam(){return this.hc}set newParam(t){this.hc=t}}class Transaction{NC;St;Kk;constructor(){this.NC=new List().g(),this.St="",this.Kk=!1}toString(t){let i="Transaction: "+this.name+" "+this.changes.count.toString()+(this.isComplete?"":", incomplete");if(t!==void 0&&t>0){const e=this.changes.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),t.g()}canUndo(){return this.isComplete}undo(){if(this.canUndo())for(let t=this.changes.count-1;t>=0;t--){const i=this.changes.elt(t);i!==null&&i.undo()}}canRedo(){return this.isComplete}redo(){if(!this.canRedo())return;const t=this.changes.count;for(let i=0;i=t;e--){const s=i.elt(e);s!==null&&s.undo(),i.rt(),i.removeAt(e)}i.g()}optimize(){if(!this.isComplete)return;const t=this.changes;t.rt();const i=new GMap;for(let s=0;s0&&t.setElt(r,null),o.set(n.propertyName,s))}let e=0;for(let s=0;se&&t.setElt(e,n),e++)}for(;t.length>e;)t.pop();t.g()}get changes(){return this.NC}get name(){return this.St}set name(t){this.St=t}get isComplete(){return this.Kk}set isComplete(t){this.Kk=t}}class UndoManager{Tw;Oi;CC;vs;Yk;um;Yn;Gk;jk;cn;ac;Dw;Os;Fw;Rw;dm;vw;constructor(t){this.Tw=new GSet,this.Oi=!1,this.CC=new List().g(),this.vs=-1,this.Yk=999,this.Os=!1,this.um=null,this.Yn=0,this.Gk=!1,this.jk=23,this.cn=new List().g(),this.ac=new List,this.Dw=!0,this.Fw=!1,this.Rw=!1,this.dm=!1,this.vw=!1,t&&Object.assign(this,t)}toString(t){let i="UndoManager "+this.historyIndex+"<"+this.history.count+"<="+this.maxHistoryLength;i+="[";let e=this.nestedTransactionNames.count;for(let s=0;s0&&(i+=" "),i+=this.nestedTransactionNames.elt(s);if(i+="]",t!==void 0&&t>0){e=this.history.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),this.vs=-1,t.g(),this.Os=!1,this.um=null,this.Yn=0,this.cn.rt(),this.cn.clear(),this.cn.g(),this.ac.clear(),this.Fw=!1,this.Rw=!1,this.dm=!1,this.vw=!1}copyProperties(t){this.isEnabled=t.isEnabled,this.maxHistoryLength=t.maxHistoryLength,this.gm=t.gm}addModel(t){this.Tw.add(t)}removeModel(t){this.Tw.delete(t)}startTransaction(t){if(t===void 0&&(t=""),t===null&&(t=""),this.isUndoingRedoing)return!1;this.Dw===!0&&(this.Dw=!1,this.Yn++,this.xl||this.t("StartingFirstTransaction",t,this.currentTransaction),this.Yn>0&&this.Yn--),this.isEnabled&&(this.cn.rt(),this.cn.add(t),this.cn.g(),this.currentTransaction===null?this.ac.add(0):this.ac.add(this.currentTransaction.changes.count)),this.Yn++;const i=this.transactionLevel===1;return i&&(this.xl||this.t("StartedTransaction",t,this.currentTransaction)),i}commitTransaction(t){return t===void 0&&(t=""),this.LC(!0,t)}rollbackTransaction(){return this.LC(!1,"")}LC(t,i){if(this.isUndoingRedoing)return!1;this.gm&&this.transactionLevel<1&&Util.oi("Ending transaction without having started a transaction: "+i);const e=this.transactionLevel===1;let s=this.currentTransaction;e&&t&&(this.xl||this.t("CommittingTransaction",i,s));let n=0;if(this.transactionLevel>0&&(this.Yn--,this.isEnabled)){const o=this.cn.count;o>0&&(i===""&&(i=this.cn.elt(0)),this.cn.rt(),this.cn.removeAt(o-1),this.cn.g());const r=this.ac.count;r>0&&(n=this.ac.elt(r-1),this.ac.removeAt(r-1))}if(e){if(t){if(this.dm=!1,s===null&&i!==""&&(s=this.currentTransaction),this.isEnabled&&s!==null){const o=s;o.isComplete||(o.isComplete=!0,o.name=i),this.discardHistoryAfterIndex();const r=this.history;r.rt();const l=this.maxHistoryLength;if(l>=0){if(l===0)r.clear();else if(r.count>=l){const h=r.elt(0);h!==null&&h.clear(),r.removeAt(0),this.vs--}}l!==0&&(r.count===0||r.get(r.count-1)!==o)&&(r.add(o),this.vs++),r.g(),s=o}this.xl||this.t("CommittedTransaction",i,s)}else{this.Os=!0;try{this.isEnabled&&s!==null&&(s.isComplete=!0,s.undo())}finally{this.xl||this.t("RolledBackTransaction",i,s),this.Os=!1}s!==null&&s.clear()}return this.um=null,this.Ow&&this.clear(),this.Ow=!1,this.Iw=!1,!0}else return this.isEnabled&&!t&&s!==null&&s.jD(n),!1}discardHistoryAfterIndex(){if(this.isUndoingRedoing||!this.canRedo())return;const t=this.history;t.rt();for(let i=t.count-1;i>this.historyIndex;i--){const e=t.elt(i);e!==null&&e.clear(),t.removeAt(i),this.dm=!0}t.g()}oE(t){this.Yn+=t,this.Yn<0&&(this.Yn=0)}canUndo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToUndo;return!!(t!==null&&t.canUndo())}undo(){if(!this.canUndo())return;const t=this.transactionToUndo;try{this.Os=!0,this.t("StartingUndo","Undo",t),this.vs--,t.undo()}catch(i){Util.oi("undo error: "+i.toString())}finally{this.t("FinishedUndo","Undo",t),this.Os=!1}}canRedo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToRedo;return!!(t!==null&&t.canRedo())}redo(){if(!this.canRedo())return;const t=this.transactionToRedo;try{this.Os=!0,this.t("StartingRedo","Redo",t),this.vs++,t.redo()}catch(i){Util.oi("redo error: "+i.toString())}finally{this.t("FinishedRedo","Redo",t),this.Os=!1}}t(t,i,e){e===void 0&&(e=null);const s=new ChangedEvent;s.change=1,s.propertyName=t,s.object=e,s.oldValue=i;const n=this.models;for(;n.next();){const o=n.value;s.model=o,o.Ew(s)}}handleChanged(t){if(this.isEnabled&&!this.isUndoingRedoing&&!this.skipsEvent(t)){let i=this.currentTransaction;i===null&&(i=new Transaction,this.um=i);const e=t.copy(),s=i.changes;if(s.rt(),s.add(e),s.g(),this.gm&&this.jk>0&&this.transactionLevel<=0&&!this.Dw){const n=t.diagram;if(n!==null&&n.Eh===!1)return;Util.oi("Change not within a transaction: "+e.toString()),this.jk--}}}skipsEvent(t){if(t===null||t.change===1)return!0;const i=t.object;if(i===null)return!1;if(i.layer!==void 0){const e=i.layer;if(e!==null&&e.isTemporary)return!0}else if(i.isTemporary)return!0;return!1}get models(){return this.Tw.iterator}get isEnabled(){return this.Oi}set isEnabled(t){this.Oi=t}get transactionToUndo(){return this.historyIndex>=0&&this.historyIndex<=this.history.count-1?this.history.elt(this.historyIndex):null}get transactionToRedo(){return this.historyIndex0}get gm(){return this.Gk}set gm(t){this.Gk=t}get nestedTransactionNames(){return this.cn}get Ow(){return this.Fw}set Ow(t){this.Fw=t}get Iw(){return this.Rw}set Iw(t){this.Rw=t}get xl(){return this.vw}set xl(t){this.vw=t}get isJustDiscarded(){return this.dm}}class Tool{p;St;Oi;Hk;qk;mm;AC;constructor(){GSet.Yi(this),this.p=Diagram.pm(),this.St="",this.Oi=!0,this.Hk=!1,this.qk=null,this.AC=new InputEvent,this.mm=-1}get diagram(){return this.p}set diagram(t){t instanceof Diagram&&(this.p=t)}toString(){return this.name!==""?this.name+" Tool":Util.sn(this.constructor)}updateAdornments(t){}canStart(){return this.isEnabled}doStart(){}doActivate(){this.isActive=!0}doDeactivate(){this.isActive=!1}doStop(){}doCancel(){this.transactionResult=null,this.stopTool()}stopTool(){const t=this.diagram;t.currentTool===this&&(t.currentTool=null,t.currentCursor="")}doMouseDown(){!this.isActive&&this.canStart()&&this.doActivate()}doMouseMove(){}doMouseUp(){this.stopTool()}doMouseWheel(){}canStartMultiTouch(){return!0}standardPinchZoomStart(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.X(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.X(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.s(e),Point.s(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){t.Wk=t.scale;const n=s.x-e.x,o=s.y-e.y,r=Math.sqrt(n*n+o*o);t.Jk=r,i.bubbles=!1}Point.s(e),Point.s(s)}standardPinchZoomMove(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.X(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.X(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.s(e),Point.s(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){const n=s.x-e.x,o=s.y-e.y,l=Math.sqrt(n*n+o*o)/t.Jk,h=new Point((Math.min(s.x,e.x)+Math.max(s.x,e.x))/2,(Math.min(s.y,e.y)+Math.max(s.y,e.y))/2),a=t.Wk*l,c=t.commandHandler;if(a!==t.scale&&c.canResetZoom(a)){const f=t.zoomPoint;t.zoomPoint=h,c.resetZoom(a),t.zoomPoint=f}i.bubbles=!1}Point.s(e),Point.s(s)}doKeyDown(){this.diagram.lastInput.code==="Escape"&&this.doCancel()}doKeyUp(){}startTransaction(t){return t===void 0&&(t=this.name),this.transactionResult=null,this.diagram.startTransaction(t)}stopTransaction(){const t=this.diagram;return this.transactionResult===null?t.rollbackTransaction():t.commitTransaction(this.transactionResult)}standardMouseSelect(){const t=this.diagram;if(!t.allowSelect)return;const i=t.lastInput,e=t.findPartAt(i.documentPoint,!1);if(e!==null){if(Util.rr?i.meta:i.control){t.v("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!s.isSelected),t.v("ChangedSelection",t.selection)}else if(i.shift){if(!e.isSelected){t.v("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!0),t.v("ChangedSelection",t.selection)}}else if(!e.isSelected){let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&t.select(s)}}else i.left&&!(Util.rr?i.meta:i.control)&&!i.shift&&t.clearSelection()}standardMouseClick(t,i){t===void 0&&(t=null),i===void 0&&(i=o=>!o.layer.isTemporary);const e=this.diagram,s=e.lastInput,n=e.findObjectAt(s.documentPoint,t,i);return s.targetObject=n,this.HD(n,s,e),s.handled}HD(t,i,e){if(i.handled=!1,t!==null&&!t.isEnabledObject())return;let s=0;i.left?i.clickCount===1?s=1:i.clickCount===2?s=2:s=1:i.right&&i.clickCount===1&&(s=3);let n="ObjectSingleClicked";if(t!==null){switch(s){case 1:n="ObjectSingleClicked";break;case 2:n="ObjectDoubleClicked";break;case 3:n="ObjectContextClicked";break}s!==0&&e.v(n,t)}else{switch(s){case 1:n="BackgroundSingleClicked";break;case 2:n="BackgroundDoubleClicked";break;case 3:n="BackgroundContextClicked";break}s!==0&&e.v(n)}if(t!==null)for(;t!==null;){let o=null;switch(s){case 1:o=t.click;break;case 2:o=t.doubleClick?t.doubleClick:t.click;break;case 3:o=t.contextClick;break}if(o!==null&&(o(i,t),i.handled))break;t=t.panel}else{let o=null;switch(s){case 1:o=e.click;break;case 2:o=e.doubleClick?e.doubleClick:e.click;break;case 3:o=e.contextClick;break}o!==null&&o(i)}}standardMouseOver(){const t=this.diagram,i=t.lastInput;if(t.animationManager.wi===!0)return;const e=t.skipsUndoManager;t.skipsUndoManager=!0;let s=t.viewportBounds.containsPoint(i.documentPoint)?t.findObjectAt(i.documentPoint,null,null):null;i.event&&(i.event.type==="pointercancel"||i.event.type==="pointerout")&&(s=null),i.targetObject=s;let n=!1;if(s!==t.cc){let o=t.cc;const r=o;for(t.cc=s,this.doCurrentObjectChanged(o,s),i.handled=!1;o!==null;){const l=o.mouseLeave;if(l!==null&&(s===o||s!==null&&s.isContainedBy(o)||(l(i,o,s),n=!0,i.handled)))break;o=o.panel}for(o=r,i.handled=!1;s!==null;){const l=s.mouseEnter;if(l!==null&&(o===s||o!==null&&o.isContainedBy(s)||(l(i,s,o),n=!0,i.handled)))break;s=s.panel}s=t.cc}if(s!==null){let o=s,r="";for(;o!==null&&(r=o.cursor,r==="");)o=o.panel;for(t.currentCursor=r,i.handled=!1,o=s;o!==null;){const l=o.mouseOver;if(l!==null&&(l(i,o),n=!0,i.handled))break;o=o.panel}}else{this.doUpdateCursor(null);const o=t.mouseOver;o!==null&&(o(i),n=!0)}n&&t.requestUpdate(),t.skipsUndoManager=e}doUpdateCursor(t){const i=this.diagram;i&&(i.currentCursor="")}doCurrentObjectChanged(t,i){}standardMouseWheel(){const t=this.diagram,i=t.lastInput;let e=i.delta;if(e===0||!t.documentBounds.isReal())return;const s=t.commandHandler,n=t.toolManager.mouseWheelBehavior;if(s!==null&&(n===2&&!i.shift||n===1&&i.control)){if(e>0?s.canIncreaseZoom():s.canDecreaseZoom()){const o=t.zoomPoint;t.zoomPoint=i.viewPoint,e>0?s.increaseZoom():s.decreaseZoom(),t.zoomPoint=o}i.bubbles=!1}else if(n===2&&i.shift||n===1&&!i.control){const o=t.position.copy(),r=i.event,l=r.deltaMode;let h=r.deltaX,a=r.deltaY,c="pixel";if((h!==0||a!==0)&&!i.shift){switch(l){case 0:c="pixel";break;case 1:c="line";break;case 2:c="page";break}if(h!==0&&t.allowHorizontalScroll){const f=t.scrollHorizontalLineChange;h=h*(f/16),t.scroll(c,h>0?"right":"left",Math.abs(h))}if(a!==0&&t.allowVerticalScroll){const f=t.scrollVerticalLineChange;a=a*(f/16),t.scroll(c,a>0?"down":"up",Math.abs(a))}}else!i.shift&&t.allowVerticalScroll?(e=e*3*t.scrollVerticalLineChange,t.scroll(c,e>0?"up":"down",Math.abs(e))):i.shift&&t.allowHorizontalScroll&&(e=e*3*t.scrollHorizontalLineChange,t.scroll(c,e>0?"left":"right",Math.abs(e)));this.doWheelChange(t,o,i)}}doWheelChange(t,i,e){(!t.position.equals(i)||e.event.wheelDeltaX!==0)&&(e.bubbles=!1)}standardWaitAfter(t,i){i===void 0&&(i=this.diagram.lastInput),this.cancelWaitAfter();const e=this,s=i.clone(this.AC);this.mm=Util.vh(()=>e.doWaitAfter(s),t)}cancelWaitAfter(){this.mm!==-1&&Util.Ig(this.mm),this.mm=-1}doWaitAfter(t){}findToolHandleAt(t,i){const s=this.diagram.findObjectAt(t,n=>{for(;n!==null&&!(n.panel instanceof Adornment);)n=n.panel;return n});return s===null?null:s.part.category===i?s:null}isBeyondDragSize(t,i){const e=this.diagram;t===void 0&&(t=e.firstInput.viewPoint),i===void 0&&(i=e.lastInput.viewPoint);const s=e.toolManager.dragSize;let n=s.width,o=s.height;return e.firstInput.isTouchEvent&&(n+=6,o+=6),Math.abs(i.x-t.x)>n||Math.abs(i.y-t.y)>o}get name(){return this.St}set name(t){Util.i(t,"string",Tool,"name"),this.St=t}get isEnabled(){return this.Oi}set isEnabled(t){Util.i(t,"boolean",Tool,"isEnabled"),this.Oi=t}get isActive(){return this.Hk}set isActive(t){Util.i(t,"boolean",Tool,"isActive"),this.Hk=t}get transactionResult(){return this.qk}set transactionResult(t){t!==null&&Util.i(t,"string",Tool,"transactionResult"),this.qk=t}}var WheelMode=(w=>(w[w.Scroll=1]="Scroll",w[w.Zoom=2]="Zoom",w[w.None=3]="None",w))(WheelMode||{}),GestureMode=(w=>(w[w.Zoom=1]="Zoom",w[w.Cancel=2]="Cancel",w[w.None=3]="None",w))(GestureMode||{});class ToolManager extends Tool{TC;DC;FC;$k;Zk;Qk;_k;tP;iP;eP;ym;Uh;constructor(t){super(),this.name="ToolManager",this.TC=new List,this.DC=new List,this.FC=new List,this.$k=850,this.Zk=850,this.Qk=new Size(2,2).it(),this._k=5e3,this.tP=1,this.iP=1,this.eP=null,this.ym=null,this.Uh=-1,t&&Object.assign(this,t)}static WheelScroll=1;static WheelZoom=2;static WheelNone=3;static GestureZoom=1;static GestureCancel=2;static GestureNone=3;get mouseWheelBehavior(){return this.tP}set mouseWheelBehavior(t){this.tP=t}get gestureBehavior(){return this.iP}set gestureBehavior(t){this.iP=t}initializeStandardTools(){}updateAdornments(t){const i=this.currentToolTip;if(i instanceof Adornment&&this.ym===t){const e=i.adornedObject;(t!==null?e.part===t:e===null)?this.showToolTip(i,e):this.hideToolTip()}}doMouseDown(){const t=this.diagram,i=t.lastInput;if(i.isTouchEvent&&this.gestureBehavior===2&&(i.bubbles=!1),i.isMultiTouch){if(this.cancelWaitAfter(),this.gestureBehavior===3){i.bubbles=!0;return}if(this.gestureBehavior===2)return;if(t.currentTool.canStartMultiTouch()){t.currentTool.standardPinchZoomStart();return}}const e=t.undoManager,s=this.mouseDownTools.length;for(let n=0;n0&&s!==1/0){const n=this;this.Uh=Util.vh(()=>n.hideToolTip(),s)}}positionToolTip(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom?n.y-=o.height+5/s.scale:n.y+=20/s.scale,n.y30&&t.Bw(),t.Vw(this.draggedParts),t.yu=!0,this.startTransaction("Drag"),this.startPoint=t.firstInput.documentPoint,t.isMouseCaptured=!0,t.allowDragOut&&this.WD()}mP(t){if(this.dragsLink){const i=this.diagram;if(!i.allowRelink)return;i.model.dc()&&t.count===1&&t.first()instanceof Link?(this.draggedLink=t.first(),this.draggedLink.canRelinkFrom()&&this.draggedLink.canRelinkTo()&&this.draggedLink.clearAdornments(),this.fn=i.toolManager.findTool("Relinking"),this.fn===null&&(this.fn=new RelinkingTool,this.fn.diagram=i),this.fn.originalLink=this.draggedLink):(this.draggedLink=null,this.fn=null)}}computeEffectiveCollection(t,i){return this.diagram.commandHandler.computeEffectiveCollection(t,i)}Is(t){return t===void 0?new DraggingInfo(Point.Po):this.isGridSnapEnabled?new DraggingInfo(new Point(Math.round(t.x*1e3)/1e3,Math.round(t.y*1e3)/1e3)):new DraggingInfo(t.copy())}doDeactivate(){this.isActive=!1;const t=this.diagram;this.diagram.layout.isRealtime=this.gP,t.yu=!1,t.bl=!0,t.cacheGroupExternalLinks(!1),t.stopAutoScroll(),this.pP(),t.xm(this.draggedParts),this.pu=null,this.currentPart=null,this.draggedParts=null,this.isDragOutStarted=!1,this.mu=!1,DraggingTool.JD(),this.vC(),this.fc.e(NaN,NaN),DraggingTool.Vh!==null&&(DraggingTool.Vh.currentCursor=""),DraggingTool.Vh=null,DraggingTool.yt=null,this.kl(),t.isMouseCaptured=!1,t.currentCursor="",t.uc=!1,this.stopTransaction(),t.yP(!0)}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}pP(){const t=this.diagram,i=t.skipsUndoManager;t.skipsUndoManager=!0;const e=t.lastInput;this.OC(e,null),t.skipsUndoManager=i,this.mr.length=0}IC(){this.kl(),this.wP();const t=this.diagram;this.fc.isReal()&&(t.position=this.fc),t.stopAutoScroll()}doCancel(){this.kl(),this.wP();const t=this.diagram;this.fc.isReal()&&(t.position=this.fc),this.stopTool()}doKeyDown(){const t=this.diagram,i=t.lastInput;this.isActive&&(i.code==="Escape"?this.doCancel():i.code!==t.previousInput.code&&this.doMouseMove())}doKeyUp(){this.isActive&&this.doMouseMove()}$D(t,i){let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=t.iterator;for(;r.next();){const l=r.value;if(!l.isVisible())continue;const h=l.location,a=h.x,c=h.y;isNaN(a)||isNaN(c)||(an&&(n=a),c>o&&(o=c))}return e===1/0?i.e(0,0,0,0):i.e(e,s,n-e,o-s),i}xP(t){if(this.copiedParts!==null)return;const i=this.diagram;if(t&&(i.isReadOnly||i.isModelReadOnly)||this.draggedParts===null)return;const e=i.undoManager;e.isEnabled&&e.isInTransaction?e.currentTransaction!==null&&e.currentTransaction.changes.count>0&&(i.undoManager.rollbackTransaction(),i.startTransaction("Drag")):this.wP(),i.skipsUndoManager=!t,i.partManager.addsToTemporaryLayer=!t,this.startPoint=i.firstInput.documentPoint;const s=this.copiesEffectiveCollection?this.draggedParts.toKeySet():i.selection,n=i.copyParts(s,i,!0),o=new GMap,r=this.draggedParts.iterator;for(;r.next();){const h=r.key;if(h.Pe()&&h.canCopy()){const a=n.get(h);if(a===null)continue;a.location=h.location,a.ensureBounds(),o.set(a,this.Is(a.location))}}const l=n.iterator;for(;l.next();){const h=l.value;h instanceof Link&&h.canCopy()&&o.set(h,this.Is())}if(this.copiedParts=o,this.mP(o.toKeySet()),this.draggedLink!==null){const h=this.draggedLink,a=h.routeBounds;h.pr(this.startPoint.x-(a.x+a.width/2),this.startPoint.y-(a.y+a.height/2))}this.doUpdateCursor(null)}kl(){const t=this.diagram;if(this.copiedParts!==null){if(t.removeParts(this.copiedParts.toKeySet(),!1),this.copiedParts=null,this.draggedParts!==null){const i=this.draggedParts.iterator;for(;i.next();)if(i.key instanceof Link){const s=i.value;s.point=new Point(0,0)}}this.doUpdateCursor(null)}t.skipsUndoManager=!1,t.partManager.addsToTemporaryLayer=!1,this.startPoint=t.firstInput.documentPoint}vC(){this.draggedLink!==null&&(this.dragsLink&&this.fn!==null&&(this.fn.stopDraggingMouseMove(),this.fn.originalLink=null),this.draggedLink=null,this.fn=null)}gc(t,i){const e=this.diagram,s=this.startPoint,n=Point.l();n.a(e.lastInput.documentPoint),this.moveParts(t,n.subtract(s),i),Point.s(n),e.getRenderingHint("temporaryPixelRatio")===!0&&e.Pl===null&&e.avgSpf>30&&(e.Bw(),e.wu())}moveParts(t,i,e){e===void 0&&(e=!1);const s=this.diagram;s!==null&&s.bP(t,i,this.dragOptions,e)}wP(){if(this.draggedParts===null)return;const t=this.diagram;let i=this.draggedParts.iterator;for(;i.next();){const e=i.key;e.Pe()&&(e.location=i.value.point)}for(i=this.draggedParts.iterator;i.next();){const e=i.key;if(e instanceof Link&&e.suspendsRouting){const s=i.value.point;this.draggedParts.set(e,this.Is()),e.pr(-s.x,-s.y)}}t.maybeUpdate()}ZD(t){if(t===null)return!0;const i=t.part;return!!(i===null||i instanceof Adornment||i.layer.isTemporary||this.draggedParts&&this.draggedParts.has(i)||this.copiedParts&&this.copiedParts.has(i))}kP(t){const i=this.diagram;this.dragsLink&&(this.draggedLink!==null&&(this.draggedLink.fromNode=null,this.draggedLink.toNode=null),this.EC(!1));const e=this.findDragOverObject(t),s=i.lastInput;s.targetObject=e,this.doUpdateCursor(e);const n=i.skipsUndoManager;let o=!1;try{if(i.skipsUndoManager=!0,o=this.OC(s,e),!this.isActive&&DraggingTool.yt===null)return;const r=e!==null?e.part:null;if(r===null||i.handlesDragDropForTopLevelParts&&r.isTopLevel&&!(r instanceof Group)){const l=i.mouseDragOver;l!==null&&(l(s),o=!0)}if(!this.isActive&&DraggingTool.yt===null||(this.doDragOver(t,e),!this.isActive&&DraggingTool.yt===null))return}finally{i.skipsUndoManager=n,o&&i.maybeUpdate()}this.pu=e,!i.isReadOnly&&(i.allowMove||i.allowCopy)&&(i.allowHorizontalScroll||i.allowVerticalScroll)&&i.doAutoScroll(s.viewPoint)}findDragOverObject(t){return this.diagram.PP(t,null,i=>!this.ZD(i))}doUpdateCursor(t){const i=this.diagram;(t===null||this.pu!==t)&&(!this.diagram.currentTool.isActive||this.mayCopy()?i.currentCursor=this.copyCursor:this.mayMove()?i.currentCursor=this.moveCursor:this.mayDragOut()&&(i.currentCursor=this.nodropCursor))}OC(t,i){let e=!1,s=this.mr.length;const n=s>0?this.mr[0]:null;if(i===n)return!1;t.handled=!1;for(let r=0;rs.findValidLinkablePort(a,i)),r=Point.l();let l=1/0,h=null;for(const a=o.iterator;a.next();){const c=a.value;if(c.part===null)continue;const u=c.getDocumentPoint(Spot.Center,r),d=t.distanceSquaredPoint(u);dh.suspendsRouting=!1)}if(this.doDropOnto(t,e),!this.isActive&&DraggingTool.yt===null)return;const o=Rect.l(),r=i.selection.iterator;for(;r.next();){const l=r.value;l instanceof Node&&this._D(i,l,o)}Rect.s(o)}QD(t,i){const e=this.diagram,s=i.part;if(e.handlesDragDropForTopLevelParts&&s.isTopLevel&&!(s instanceof Group)){const n=e.mouseDrop;n!==null&&n(t)}}_D(t,i,e){if(!i.canAvoid())return;let s=!1;e=i.getAvoidableRect(e),t.viewportBounds.containsRect(e)&&(s=!0);const n=this.copiedParts||this.draggedParts,o=t.NP(e,l=>l.part,l=>l instanceof Link,!0,l=>l instanceof Link,s);if(o.count===0)return;const r=o.iterator;for(;r.next();){const l=r.value;n.has(l)&&n.has(i)||!l.isMemberOf(i)&&l.isAvoiding&&l.invalidateRoute()}}doDropOnto(t,i){}doMouseMove(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseMove(i.event,i.documentPoint,i.targetDiagram))return;this.currentPart!==null&&this.draggedParts!==null&&(this.mayCopy()?(this.xP(!1),t.Vw(this.copiedParts),this.gc(this.copiedParts,!1),t.xm(this.copiedParts)):this.mayMove()?(this.kl(),this.gc(this.draggedParts,!0)):this.mayDragOut()?(this.xP(!1),this.gc(this.copiedParts,!1)):this.kl(),this.kP(t.lastInput.documentPoint))}doMouseUp(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseUp(i.event,i.documentPoint,i.targetDiagram))return;let e=!1;const s=this.mayCopy();if(s&&this.copiedParts!==null?(this.kl(),this.xP(!0),t.Vw(this.copiedParts),this.gc(this.copiedParts,!1),t.xm(this.copiedParts),this.copiedParts!==null&&(t.v("ChangingSelection",t.selection),t.clearSelection(!0),this.copiedParts.iteratorKeys.each(n=>{n.isSelected=!0}))):(e=!0,this.kl(),this.mayMove()&&(this.gc(this.draggedParts,!0),this.kP(t.lastInput.documentPoint))),this.mu=!0,this.VC(t.lastInput.documentPoint),this.isActive){const n=s?this.copiedParts.toKeySet():this.draggedParts.toKeySet();this.copiedParts=null,e&&this.tF(),t.invalidateDocumentBounds(),t.xm(this.draggedParts),this.transactionResult=s?"Copy":"Move",t.v(s?"SelectionCopied":"SelectionMoved",n)}this.stopTool(),s&&t.v("ChangedSelection",t.selection)}simulatedMouseMove(t,i,e){if(DraggingTool.yt===null)return!1;const s=DraggingTool.yt.diagram;e instanceof Diagram||(e=null);const n=DraggingTool.Vh;if(e!==n){if(n!==null&&n!==s){n.stopAutoScroll(),DraggingTool.yt.isDragOutStarted=!1;const r=n.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDragLeave()}if(DraggingTool.Vh=e,e!==null&&e!==s){DraggingTool.yt.IC();const r=e.toolManager.findTool("Dragging");r!==null&&(r.zC(),r.doSimulatedDragEnter())}this.doUpdateCursor(null)}if(e===null||e===s||!e.allowDrop||e.isReadOnly||!e.allowInsert)return!1;const o=e.toolManager.findTool("Dragging");if(o!==null){let r=i;t!==null&&(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),r=e.getMouse(t)),e.lastInput.documentPoint=r,e.lastInput.viewPoint=e.transformDocToView(r),e.lastInput.down=!1,e.lastInput.up=!1,o.doSimulatedDragOver()}return!0}simulatedMouseUp(t,i,e){if(DraggingTool.yt===null)return!1;const s=DraggingTool.Vh,n=DraggingTool.yt.diagram;if(e===null)return DraggingTool.yt.doCancel(),!0;if(e!==s){const o=s.toolManager.findTool("Dragging");if(s!==null&&s!==n&&o!==null)return s.stopAutoScroll(),DraggingTool.yt.isDragOutStarted=!1,o.doSimulatedDragLeave(),!1;DraggingTool.Vh=e;const r=e.toolManager.findTool("Dragging");r!==null&&(DraggingTool.yt.IC(),r.zC(),r.doSimulatedDragEnter())}if(e!==this.diagram){let o=i;t!==null?(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),o=e.getMouse(t)):o===null&&(o=new Point),e.lastInput.documentPoint=o,e.lastInput.viewPoint=e.transformDocToView(o),e.lastInput.down=!1,e.lastInput.up=!0;const r=e.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDrop();const l=DraggingTool.yt;if(l!==null){const h=l.mayCopy();l.transactionResult=h?"Copy":"Move",l.stopTool()}return!0}return!1}tF(){if(this.draggedParts===null)return;const t=this.draggedParts.iterator;for(;t.next();){const i=t.key;if(i instanceof Node){const e=i.containingGroup;e!==null&&e.hasPlaceholder()&&!this.draggedParts.has(e)&&e.placeholder.c()}}}mayCopy(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowCopy||!(Util.rr?t.lastInput.alt:t.lastInput.control))return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayDragOut(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(!t.allowDragOut||!t.allowCopy||t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayMove(){const t=this.diagram;if(t.isReadOnly||!t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canMove())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canMove())}zC(){DraggingTool.zw.has(this)||DraggingTool.zw.add(this)}static JD(){if(DraggingTool.zw.count>0){const t=DraggingTool.zw,i=t.length;for(let e=0;e{n.isSelected=!0,s.add(n)})),this.VC(t.lastInput.documentPoint),t.invalidateDocumentBounds(),this.copiedParts!==null&&(this.transactionResult="ExternalCopy"),this.copiedParts=null,t.doFocus(),t.uc=!1,t.v("ExternalObjectsDropped",s,e),this.stopTransaction(),t.v("ChangedSelection",t.selection)}t.animationManager.xu=!1}XC(t,i,e){if(this.copiedParts!==null)return;const s=this.diagram;if(s.isReadOnly||s.isModelReadOnly)return;s.skipsUndoManager=!i,s.partManager.addsToTemporaryLayer=!i,this.startPoint=e.documentPoint;const n=s.copyParts(t,s,!0),o=Rect.l();this.$D(t,o);const r=o.x+o.width/2,l=o.y+o.height/2;Rect.s(o);const h=this.wm,a=new GMap,c=Point.l(),f=t.iterator;for(;f.next();){const d=f.value;if(d instanceof Link&&d.canCopy()){const m=n.get(d);if(m===null)continue;m.points=d.points,m.pr(h.x-r,h.y-l),m.suspendsRouting=!0,a.set(m,this.Is())}}const u=t.iterator;for(;u.next();){const d=u.value;if(d.Pe()&&d.canCopy()){const m=n.get(d);if(m===null)continue;const g=d.location;c.e(h.x-(r-g.x),h.y-(l-g.y)),m.location=c,m.ensureBounds(),a.set(m,this.Is(c))}}if(Point.s(c),this.copiedParts=a,this.mP(a.toKeySet()),this.draggedLink!==null){const d=this.draggedLink,m=d.routeBounds;d.pr(this.startPoint.x-(m.x+m.width/2),this.startPoint.y-(m.y+m.height/2))}this.doUpdateCursor(null)}WD(){this.isDragOutStarted=!0,this.mu=!1,DraggingTool.yt=this,DraggingTool.Vh=this.diagram,this.doSimulatedDragOut()}doSimulatedDragOut(){const t=this.diagram;t.uc=!1,!this.mayCopy()&&!this.mayMove()?t.currentCursor=this.nodropCursor:t.currentCursor="",this.pu=null}computeMove(t,i,e,s){const n=this.diagram;return n!==null?n.computeMove(t,i,this.dragOptions,s):new Point}static zw=new List;static yt=null;static Vh=null}ToolManager.prototype.doCancel=function(){DraggingTool.yt!==null&&DraggingTool.yt.doCancel(),Tool.prototype.doCancel.call(this)};class LinkingBaseTool extends Tool{CP;LP;Ml;AP;TP;zh;DP;Xh;FP;RP;vP;OP;IP;EP;KC;UP;Sl;BP;constructor(){super(),this.CP=100,this.LP=!1,this.Ml="pointer",this.AP=new Link({layerName:"Tool"}).add(new Shape({isPanelMain:!0,stroke:"blue"}).theme("stroke","tempLink"),new Shape({toArrow:"Standard",fill:"blue",stroke:"blue"}).theme("fill","tempLink").theme("stroke","tempLink")).li(),this.zh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.Dk}).theme("stroke","tempPort"),this.TP=new Node({selectable:!1,layerName:"Tool"}).add(this.zh).li(),this.Xh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.Dk}).theme("stroke","tempPort"),this.DP=new Node({selectable:!1,layerName:"Tool"}).add(this.Xh).li(),this.FP=null,this.RP=null,this.vP=null,this.OP=null,this.IP=null,this.EP=!0,this.KC=new GMap,this.UP=null,this.Sl=null,this.BP=null}doStop(){this.diagram.stopAutoScroll(),this.originalLink=null,this.originalFromNode=null,this.originalFromPort=null,this.originalToNode=null,this.originalToPort=null,this.validPortsCache.clear(),this.targetPort=null}get portGravity(){return this.CP}set portGravity(t){Util.i(t,"number",LinkingBaseTool,"portGravity"),t>=0&&(this.CP=t)}get isUnconnectedLinkValid(){return this.LP}set isUnconnectedLinkValid(t){Util.i(t,"boolean",LinkingBaseTool,"isUnconnectedLinkValid"),this.LP=t}get linkingCursor(){return this.Ml}set linkingCursor(t){this.Ml=t}get temporaryLink(){return this.AP}set temporaryLink(t){t.li(),this.AP=t}get temporaryFromNode(){return this.TP}set temporaryFromNode(t){t.li(),this.TP=t,t&&(this.zh=t.port)}get temporaryFromPort(){return this.zh}set temporaryFromPort(t){if(this.zh!==null){const i=this.zh.panel;if(i!==null){const e=i.L.indexOf(this.zh);i.removeAt(e),i.insertAt(e,t)}}this.zh=t}get temporaryToNode(){return this.DP}set temporaryToNode(t){t.li(),this.DP=t,t&&(this.Xh=t.port)}get temporaryToPort(){return this.Xh}set temporaryToPort(t){if(this.Xh!==null){const i=this.Xh.panel;if(i!==null){const e=i.L.indexOf(this.Xh);i.removeAt(e),i.insertAt(e,t)}}this.Xh=t}get originalLink(){return this.FP}set originalLink(t){this.FP=t}get originalFromNode(){return this.RP}set originalFromNode(t){this.RP=t}get originalFromPort(){return this.vP}set originalFromPort(t){this.vP=t}get originalToNode(){return this.OP}set originalToNode(t){this.OP=t}get originalToPort(){return this.IP}set originalToPort(t){this.IP=t}get isForwards(){return this.EP}set isForwards(t){this.EP=t}get validPortsCache(){return this.KC}get targetPort(){return this.UP}set targetPort(t){this.UP=t}copyPortProperties(t,i,e,s,n){if(t===null||i===null||e===null||s===null)return;const o=i.getDocumentScale(),r=Size.l();r.width=i.naturalBounds.width*o,r.height=i.naturalBounds.height*o,s.desiredSize=r,Size.s(r),n?(s.toSpot=i.toSpot,s.toEndSegmentLength=i.toEndSegmentLength):(s.fromSpot=i.fromSpot,s.fromEndSegmentLength=i.fromEndSegmentLength),e.locationSpot=Spot.Center;const l=Point.l();e.location=i.getDocumentPoint(Spot.Center,l),Point.s(l),s.angle=i.getDocumentAngle(),this.portTargeted!==null&&this.portTargeted(t,i,e,s,n)}setNoTargetPortProperties(t,i,e){i!==null&&(i.desiredSize=Size.Dk,i.fromSpot=Spot.None,i.toSpot=Spot.None),t!==null&&(t.location=this.diagram.lastInput.documentPoint),this.portTargeted!==null&&this.portTargeted(null,null,t,i,e)}doMouseDown(){this.isActive&&this.doMouseMove()}doMouseMove(){if(this.isActive){const t=this.diagram;if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null&&this.targetPort.part instanceof Node){const i=this.targetPort.part;this.isForwards?this.copyPortProperties(i,this.targetPort,this.temporaryToNode,this.temporaryToPort,!0):this.copyPortProperties(i,this.targetPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else this.isForwards?this.setNoTargetPortProperties(this.temporaryToNode,this.temporaryToPort,!0):this.setNoTargetPortProperties(this.temporaryFromNode,this.temporaryFromPort,!1);(t.allowHorizontalScroll||t.allowVerticalScroll)&&t.doAutoScroll(t.lastInput.viewPoint)}}findValidLinkablePort(t,i){if(t===null)return null;const e=t.part;if(!(e instanceof Node))return null;for(;t!==null;){const s=i?t.toLinkable:t.fromLinkable;if(s===!0&&(t.portId!==null||t instanceof Node)&&(i?this.isValidTo(e,t):this.isValidFrom(e,t)))return t;if(s===!1)return null;t=t.panel}return null}findTargetPort(t){const i=this.diagram,e=i.lastInput.documentPoint;let s=this.portGravity;s<=0&&(s=.1);const n=this,o=i.findObjectsNear(e,s,a=>n.findValidLinkablePort(a,t),null,!0);let r=1/0,l=null;const h=o.iterator;for(;h.next();){const a=h.value,c=a.part;if(!(c instanceof Node))continue;const f=a.getDocumentPoint(Spot.Center,Point.l()),u=e.x-f.x,d=e.y-f.y;Point.s(f);const m=u*u+d*d;if(m=e)return!1}return!0}isValidTo(t,i){if(t===null||i===null)return this.isUnconnectedLinkValid;if(this.diagram.currentTool===this&&(t.layer!==null&&!t.layer.allowLink||i.toLinkable!==!0))return!1;const e=i.toMaxLinks;if(e<1/0){if(this.originalLink!==null&&t===this.originalToNode&&i===this.originalToPort)return!0;let s=i.portId;if(s===null&&(s=""),t.findLinksInto(s).count>=e)return!1}return!0}isInSameNode(t,i){if(t===null||i===null)return!1;if(t===i)return!0;const e=t.part,s=i.part;return e!==null&&e===s}isLinked(t,i){if(t===null||i===null)return!1;const e=t.part;if(!(e instanceof Node))return!1;let s=t.portId;s===null&&(s="");const n=i.part;if(!(n instanceof Node))return!1;let o=i.portId;o===null&&(o="");const r=n.findLinksInto(o);for(;r.next();){const l=r.value;if(l.fromNode===e&&l.fromPortId===s)return!0}return!1}isValidLink(t,i,e,s){if(!this.isValidFrom(t,i)||!this.isValidTo(e,s)||i!==null&&s!==null&&(!(i.fromLinkableSelfNode&&s.toLinkableSelfNode)&&this.isInSameNode(i,s)||!(i.fromLinkableDuplicates&&s.toLinkableDuplicates)&&this.isLinked(i,s))||this.originalLink!==null&&(t!==null&&this.isLabelDependentOnLink(t,this.originalLink)||e!==null&&this.isLabelDependentOnLink(e,this.originalLink))||t!==null&&e!==null&&(t.data===null&&e.data!==null||t.data!==null&&e.data===null)||!this.isValidCycle(t,e,this.originalLink))return!1;let n;return t!==null&&(n=t.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))||e!==null&&(n=e.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))?!1:(n=this.linkValidation,n!==null?n(t,i,e,s,this.originalLink):!0)}isLabelDependentOnLink(t,i){if(t===null)return!1;const e=t.labeledLink;if(e===null)return!1;if(e===i)return!0;const s=new GSet;return s.add(t),this.VP(e,i,s)}VP(t,i,e){if(t===i)return!0;const s=t.fromNode;if(s!==null&&s.isLinkLabel&&(e.add(s),this.VP(s.labeledLink,i,e)))return!0;const n=t.toNode;return!!(n!==null&&n.isLinkLabel&&(e.add(n),this.VP(n.labeledLink,i,e)))}isValidCycle(t,i,e){if(e===void 0&&(e=null),t===null||i===null)return this.isUnconnectedLinkValid;const s=this.diagram;let n=1;if(s&&(s.model.mc()?n=s.isTreePathToChildren?5:6:n=s.validCycle),n===1)return!0;if(n===5){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=i.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.toNode===i)return!1}return!this.bu(t,i,e,!0)}else if(n===6){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=t.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.fromNode===t)return!1}return!this.bu(t,i,e,!0)}else{if(n===2)return!this.iF(t,i,e);if(n===3)return!this.bu(t,i,e,!1);if(n===4)return!this.eF(t,i,e)}return!0}bu(t,i,e,s){if(t===i)return!0;if(t===null||i===null)return!1;const n=t.linksConnected;for(;n.next();){const o=n.value;if(o===e||s&&!o.isTreeLink||o.toNode!==t)continue;const r=o.fromNode;if(r!==t&&this.bu(r,i,e,s))return!0}return!1}iF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.YC(s,t,i,e)}YC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s||o.toNode!==i)continue;const r=o.fromNode;if(r!==i&&this.YC(t,r,e,s))return!0}return!1}eF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.GC(s,t,i,e)}GC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s)continue;const r=o.fromNode,l=o.toNode,h=r===i?l:r;if(h!==i&&this.GC(t,h,e,s))return!0}return!1}get linkValidation(){return this.Sl}set linkValidation(t){t!==null&&Util.i(t,"function",LinkingBaseTool,"linkValidation"),this.Sl=t}get portTargeted(){return this.BP}set portTargeted(t){t!==null&&Util.i(t,"function",LinkingBaseTool,"portTargeted"),this.BP=t}}var LinkingDirection=(w=>(w[w.Either=1]="Either",w[w.ForwardsOnly=2]="ForwardsOnly",w[w.BackwardsOnly=3]="BackwardsOnly",w))(LinkingDirection||{});class LinkingTool extends LinkingBaseTool{zP;XP;S;KP;constructor(t){super(),this.name="Linking",this.zP={},this.XP=null,this.S=1,this.KP=null,t&&Object.assign(this,t)}static Either=1;static ForwardsOnly=2;static BackwardsOnly=3;get archetypeLinkData(){return this.zP}set archetypeLinkData(t){t!==null&&Util.i(t,"object",LinkingTool,"archetypeLinkData"),this.zP=t}get archetypeLabelNodeData(){return this.XP}set archetypeLabelNodeData(t){t!==null&&Util.i(t,"object",LinkingTool,"archetypeLabelNodeData"),this.XP=t}get direction(){return this.S}set direction(t){this.S=t}get startObject(){return this.KP}set startObject(t){this.KP=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||t.isModelReadOnly||!t.allowLink||!t.model.Xw()||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize()?!1:this.findLinkablePort()!==null}findLinkablePort(){const t=this.diagram;let i=this.startObject;if(i===null&&(i=t.findObjectAt(t.firstInput.documentPoint,null,null)),i===null)return null;const e=i.part;if(!(e instanceof Node))return null;const s=this.direction;if(s===1||s===2){const n=this.findValidLinkablePort(i,!1);if(n!==null)return this.isForwards=!0,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!1))return this.isForwards=!0,o}}if(s===1||s===3){const n=this.findValidLinkablePort(i,!0);if(n!==null)return this.isForwards=!1,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!0))return this.isForwards=!1,o}}return null}doActivate(){const t=this.diagram,i=this.findLinkablePort();if(i===null){this.stopTool();return}if(this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.isForwards){this.temporaryToNode!==null&&(this.temporaryToNode.location=t.lastInput.documentPoint),this.originalFromPort=i;const e=this.originalFromPort.part;e instanceof Node&&(this.originalFromNode=e),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else{this.temporaryFromNode!==null&&(this.temporaryFromNode.location=t.lastInput.documentPoint),this.originalToPort=i;const e=this.originalToPort.part;e instanceof Node&&(this.originalToNode=e),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0)}t.add(this.temporaryFromNode),this.temporaryFromNode&&this.temporaryFromNode.ensureBounds(),t.add(this.temporaryToNode),this.temporaryToNode&&this.temporaryToNode.ensureBounds(),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.temporaryLink.isTreeLink=this.isNewTreeLink(),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.startObject=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=null,e=null,s=null,n=null,o=null;try{this.targetPort=this.findTargetPort(this.isForwards);const r=this.targetPort;if(r!==null){const l=r.part;l instanceof Node&&(this.isForwards?(this.originalFromNode!==null&&(i=this.originalFromNode,e=this.originalFromPort),s=l,n=r):(i=l,e=r,this.originalToNode!==null&&(s=this.originalToNode,n=this.originalToPort)))}else this.isForwards?this.originalFromNode!==null&&this.isUnconnectedLinkValid&&(i=this.originalFromNode,e=this.originalFromPort):this.originalToNode!==null&&this.isUnconnectedLinkValid&&(s=this.originalToNode,n=this.originalToPort);i!==null||s!==null?(o=this.insertLink(i,e,s,n),o!==null?(r===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint),t.allowSelect&&(t.v("ChangingSelection",t.selection),t.clearSelection(!0),o.isSelected=!0),this.transactionResult=this.name,t.v("LinkDrawn",o)):this.doNoLink(i,e,s,n)):this.isForwards?this.doNoLink(this.originalFromNode,this.originalFromPort,null,null):this.doNoLink(null,null,this.originalToNode,this.originalToPort)}finally{this.stopTool(),o&&t.allowSelect&&t.v("ChangedSelection",t.selection)}}}isNewTreeLink(){const t=this.archetypeLinkData;if(t===null)return!0;if(t instanceof Link)return t.isTreeLink;const i=this.diagram;if(i===null)return!0;const e=i.partManager.getLinkCategoryForData(t),s=i.partManager.findLinkTemplateForCategory(e);return s!==null?s.isTreeLink:!0}insertLink(t,i,e,s){return this.diagram.partManager.insertLink(t,i,e,s)}doNoLink(t,i,e,s){}}class RelinkingTool extends LinkingBaseTool{YP;GP;fs;jP;constructor(t){super(),this.name="Relinking",this.YP=new Shape("Diamond",{desiredSize:Size.hu,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:0}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.GP=new Shape("Diamond",{desiredSize:Size.hu,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:-1}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.fs=null,this.jP=new Rect,t&&Object.assign(this,t)}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i="RelinkFrom",e=null;if(t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkFrom()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null&&(e=this.makeAdornment(s,!1),t.addAdornment(i,e)))}if(e===null&&t.removeAdornment(i),i="RelinkTo",e=null,t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkTo()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null?(e=this.makeAdornment(s,!0),t.addAdornment(i,e)):e.c())}e===null&&t.removeAdornment(i)}makeAdornment(t,i){const e=new Adornment;e.type=Panel.Link;const s=i?this.toHandleArchetype:this.fromHandleArchetype;return s!==null&&e.add(s.copy().bm()),e.adornedObject=t,e}get fromHandleArchetype(){return this.YP}set fromHandleArchetype(t){this.YP=t}get toHandleArchetype(){return this.GP}set toHandleArchetype(t){this.GP=t}get handle(){return this.fs}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.fs=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowRelink||!t.model.Xw()||!t.lastInput.left)return!1;let e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom");return e===null&&(e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo")),e!==null}doActivate(){const t=this.diagram;if(this.originalLink===null){let i=this.handle;if(i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom"),i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo"))),i===null)return;const e=i.part;if(!(e instanceof Adornment)||!(e.adornedPart instanceof Link))return;this.handle=i,this.isForwards=e===null||e.category==="RelinkTo",this.originalLink=e.adornedPart}this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.originalFromPort=this.originalLink.fromPort,this.originalFromNode=this.originalLink.fromNode,this.originalToPort=this.originalLink.toPort,this.originalToNode=this.originalLink.toNode,this.jP.set(this.originalLink.actualBounds),this.originalLink!==null&&this.originalLink.pointsCount>0&&(this.originalLink.fromNode===null&&(this.temporaryFromPort!==null&&(this.temporaryFromPort.desiredSize=Size.lu),this.temporaryFromNode!==null&&(this.temporaryFromNode.location=this.originalLink.getPoint(0))),this.originalLink.toNode===null&&(this.temporaryToPort!==null&&(this.temporaryToPort.desiredSize=Size.lu),this.temporaryToNode!==null&&(this.temporaryToNode.location=this.originalLink.getPoint(this.originalLink.pointsCount-1)))),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0),t.add(this.temporaryFromNode),t.add(this.temporaryToNode),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.copyLinkProperties(this.originalLink,this.temporaryLink),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}copyLinkProperties(t,i){if(t===null||i===null)return;i.adjusting=t.adjusting,i.corner=t.corner;let e=t.curve;(e===11||e===10)&&(e=0),i.curve=e,i.curviness=t.curviness,i.isTreeLink=t.isTreeLink,i.points=t.points,i.routing=t.routing,i.smoothness=t.smoothness,i.fromSpot=t.fromSpot,i.fromEndSegmentLength=t.fromEndSegmentLength,i.fromShortLength=t.fromShortLength,i.toSpot=t.toSpot,i.toEndSegmentLength=t.toEndSegmentLength,i.toShortLength=t.toShortLength}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.handle=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=this.originalFromNode,e=this.originalFromPort,s=this.originalToNode,n=this.originalToPort,o=this.originalLink;try{if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null){const r=this.targetPort.part;r instanceof Node&&(this.isForwards?(s=r,n=this.targetPort):(i=r,e=this.targetPort))}else this.isUnconnectedLinkValid?this.isForwards?(s=null,n=null):(i=null,e=null):o=null;o!==null?(this.reconnectLink(o,this.isForwards?s:i,this.isForwards?n:e,this.isForwards),this.targetPort===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint,o.invalidateRoute()),this.transactionResult=this.name,t.v("LinkRelinked",o,this.isForwards?this.originalToPort:this.originalFromPort)):this.doNoRelink(this.originalLink,this.isForwards),this.originalLink.invalidateOtherJumpOvers(this.jP)}finally{this.stopTool()}}}reconnectLink(t,i,e,s){const n=e!==null&&e.portId!==null?e.portId:"";return s?(t.toNode=i,t.toPortId=n):(t.fromNode=i,t.fromPortId=n),!0}doNoRelink(t,i){}doDraggingMouseMove(t,i,e,s){t!==null?(this.copyPortProperties(t,i,this.temporaryFromNode,this.temporaryFromPort,!1),this.diagram.add(this.temporaryFromNode)):this.diagram.remove(this.temporaryFromNode),e!==null?(this.copyPortProperties(e,s,this.temporaryToNode,this.temporaryToPort,!0),this.diagram.add(this.temporaryToNode)):this.diagram.remove(this.temporaryToNode)}stopDraggingMouseMove(){this.diagram.remove(this.temporaryFromNode),this.diagram.remove(this.temporaryToNode)}}var ReshapingBehavior=(w=>(w[w.None=0]="None",w[w.Horizontal=1]="Horizontal",w[w.Vertical=2]="Vertical",w[w.All=3]="All",w))(ReshapingBehavior||{});class LinkReshapingTool extends Tool{Co;HP;qP;fs;Kw;WP;km;constructor(t){super(),this.name="LinkReshaping",this.Co=new Shape("Rectangle",{desiredSize:Size.iC,fill:"lightblue",stroke:"dodgerblue"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.HP=new Shape("Diamond",{desiredSize:Size.hu,fill:"lightblue",stroke:"dodgerblue",cursor:"move"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.qP=3,this.fs=null,this.Kw=null,this.WP=new Point,this.km=new List,t&&Object.assign(this,t)}static None=0;static Horizontal=1;static Vertical=2;static All=3;getReshapingBehavior(t){return t?t.wr:0}setReshapingBehavior(t,i){t.wr=i}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i=null;if(t.isSelected&&!this.diagram.isReadOnly){const e=t.path;e!==null&&t.canReshape()&&t.actualBounds.isReal()&&t.isVisible()&&e.actualBounds.isReal()&&e.isVisibleObject()&&(i=t.findAdornment(this.name),(i===null||i.JP!==t.pointsCount||i.$P!==t.resegmentable)&&(i=this.makeAdornment(e),i!==null&&(i.JP=t.pointsCount,i.$P=t.resegmentable,t.addAdornment(this.name,i))))}i===null&&t.removeAdornment(this.name)}makeAdornment(t){const i=t.part,e=i.points,s=i.pointsCount,n=i.isOrthogonal;let o=null;if(e!==null&&s>1){o=new Adornment,o.type=Panel.Link;const r=i.firstPickIndex,l=i.lastPickIndex,h=n?1:0;if(i.resegmentable&&i.computeCurve()!==9)for(let a=r+h;ae.firstPickIndex+1&&s0))this.sF(t,i);else if(t instanceof Panel){const e=t.elements;for(;e.next();){const s=e.value;this.updateResizeHandles(s,i)}}}}sF(t,i){let e=t.alignment;e.isNoSpot()&&(e=Spot.Center);let s=i;if(e.x<=0)e.y<=0?s+=225:e.y>=1?s+=135:s+=180;else if(e.x>=1)e.y<=0?s+=315:e.y>=1&&(s+=45);else if(e.y<=0)s+=270;else if(e.y>=1)s+=90;else return;s<0?s+=360:s>=360&&(s-=360),s<22.5?t.cursor="e-resize":s<67.5?t.cursor="se-resize":s<112.5?t.cursor="s-resize":s<157.5?t.cursor="sw-resize":s<202.5?t.cursor="w-resize":s<247.5?t.cursor="nw-resize":s<292.5?t.cursor="n-resize":s<337.5?t.cursor="ne-resize":t.cursor="e-resize"}get handleArchetype(){return this.Co}set handleArchetype(t){this.Co=t}get handle(){return this.fs}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.fs=t}get adornedObject(){return this.us}set adornedObject(t){if(t!==null&&t.part instanceof Adornment)throw new Error("new handle must not be in an Adornment: "+t);this.us=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowResize||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle!==null&&(this.adornedObject=this.handle.part.adornedObject,this.adornedObject!==null&&(t.isMouseCaptured=!0,t.animationManager.stopAnimation(),t.yu=!0,this.startTransaction(this.name),this.Pm.set(this.adornedObject.getDocumentPoint(this.handle.alignment.opposite())),this.yc.set(this.adornedObject.part.location),this.QP.set(this.adornedObject.desiredSize),this.jw=this.computeCellSize(),this.Yw=this.computeMinSize(),this.Gw=this.computeMaxSize(),this.isActive=!0))}doDeactivate(){const t=this.diagram;t.yu=!1,t.bl=!0,this.stopTransaction(),this.handle=null,this.us=null,t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){this.adornedObject!==null&&(this.adornedObject.desiredSize=this.originalDesiredSize,this.adornedObject.part.location=this.originalLocation),this.stopTool()}doMouseMove(){const t=this.diagram;if(!this.isActive)return;const i=this.Yw,e=this.Gw,s=this.jw,n=t.lastInput.documentPoint,o=this.adornedObject.getLocalPoint(n,Point.l()),r=this.computeReshape(),l=this.computeResize(o,this.handle.alignment,i,e,s,r);this.resize(l),t.maybeUpdate(),Point.s(o)}doMouseUp(){const t=this.diagram;if(this.isActive){const i=this.Yw,e=this.Gw,s=this.jw,n=this.adornedObject.getLocalPoint(t.lastInput.documentPoint,Point.l()),o=this.computeReshape(),r=this.computeResize(n,this.handle.alignment,i,e,s,o);this.resize(r),Point.s(n),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.v("PartResized",this.adornedObject,this.originalDesiredSize)}this.stopTool()}resize(t){const i=this.diagram,e=this.adornedObject;if(e===null)return;e.desiredSize=t.size;const s=e.part;s.ensureBounds();const n=e.getDocumentPoint(this.handle.alignment.opposite());if(s instanceof Group){const o=new List;o.add(s);let r;!this.dragsMembers&&!s.hasPlaceholder()&&(r=new DraggingOptions,r.dragsMembers=!1),i.moveParts(o,this.oppositePoint.copy().subtract(n),!0,r)}else s.location=s.location.copy().subtract(n).add(this.oppositePoint);i.maybeUpdate()}computeResize(t,i,e,s,n,o){i.isNoSpot()&&(i=Spot.Center);const r=this.adornedObject.naturalBounds,l=r.x,h=r.y,a=r.x+r.width,c=r.y+r.height;let f=1;if(!o){let m=r.width,g=r.height;m<=0&&(m=1),g<=0&&(g=1),f=g/m}const u=Point.l();Geo.Eg(t.x,t.y,l,h,n.width,n.height,u);const d=r.copy();return i.x<=0?i.y<=0?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=Math.max(c-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.x=a-d.width,d.y=c-d.height)):i.y>=1?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.x=a-d.width)):(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=a-d.x,o||(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f,d.y=h+.5*(c-h-d.height))):i.x>=1?i.y<=0?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=Math.max(c-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.y=c-d.height)):i.y>=1?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width))):(d.width=Math.max(Math.min(u.x-l,s.width),e.width),o||(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f,d.y=h+.5*(c-h-d.height))):i.y<=0?(d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=c-d.y,o||(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width,d.x=l+.5*(a-l-d.width))):i.y>=1&&(d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width,d.x=l+.5*(a-l-d.width))),Point.s(u),d}computeReshape(){let t=0;return this.adornedObject instanceof Shape&&(t=this.adornedObject._P()),!(t===6||this.diagram.lastInput.shift)}computeMinSize(){const t=this.adornedObject.minSize.copy(),i=this.minSize;return!isNaN(i.width)&&i.width>t.width&&(t.width=i.width),!isNaN(i.height)&&i.height>t.height&&(t.height=i.height),t}computeMaxSize(){const t=this.adornedObject.maxSize.copy(),i=this.maxSize;return!isNaN(i.width)&&i.width0&&(t.width=n.width),!isNaN(n.height)&&n.height>0&&(t.height=n.height)}let e=this.cellSize;isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height);const s=this.diagram;if((isNaN(t.width)||isNaN(t.height))&&s){const n=s.grid;n!==null&&n.visible&&this.isGridSnapEnabled&&(e=n.gridCellSize,isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height))}return(isNaN(t.width)||t.width===0||t.width===1/0)&&(t.width=1),(isNaN(t.height)||t.height===0||t.height===1/0)&&(t.height=1),t}get minSize(){return this.xr}set minSize(t){if(!this.xr.equals(t)){let e=t.width;isNaN(e)&&(e=0);let s=t.height;isNaN(s)&&(s=0),this.xr.e(e,s)}}get maxSize(){return this.br}set maxSize(t){if(!this.br.equals(t)){let e=t.width;isNaN(e)&&(e=1/0);let s=t.height;isNaN(s)&&(s=1/0),this.br.e(e,s)}}get cellSize(){return this.Lo}set cellSize(t){this.Lo.equals(t)||this.Lo.a(t)}get isGridSnapEnabled(){return this.pc}set isGridSnapEnabled(t){Util.i(t,"boolean",ResizingTool,"isGridSnapEnabled"),this.pc=t}get dragsMembers(){return this.ZP}set dragsMembers(t){Util.i(t,"boolean",ResizingTool,"dragsMembers"),this.ZP=t}get oppositePoint(){return this.Pm}set oppositePoint(t){this.Pm.equals(t)||this.Pm.a(t)}get originalDesiredSize(){return this.QP}get originalLocation(){return this.yc}}class RotatingTool extends Tool{tM;iM;us;Co;fs;eM;Mm;yc;sM;nM;constructor(t){super(),this.name="Rotating",this.tM=45,this.iM=2,this.yc=new Point,this.us=null,this.Co=new Shape("Ellipse",{desiredSize:Size.hu,fill:"lightblue",stroke:"dodgerblue",strokeWidth:1,cursor:"pointer"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.fs=null,this.eM=0,this.Mm=new Point(NaN,NaN),this.sM=0,this.nM=50,t&&Object.assign(this,t)}updateAdornments(t){if(t!==null){if(t.Cl()){const i=t.rotateObject;if(i===t||i===t.path||i.isPanelMain)return}if(t.isSelected&&!this.diagram.isReadOnly){const i=t.rotateObject;if(i!==null&&t.canRotate()&&t.actualBounds.isReal()&&t.isVisible()&&i.actualBounds.isReal()&&i.isVisibleObject()){let e=t.findAdornment(this.name);if((e===null||e.adornedObject!==i)&&(e=this.makeAdornment(i)),e!==null){e.angle=i.getDocumentAngle(),e.hasPlaceholder()||(e.location=this.computeAdornmentLocation(i)),t.addAdornment(this.name,e);return}}}t.removeAdornment(this.name)}}makeAdornment(t){let i=null;const e=t.part.rotateAdornmentTemplate;if(e===null){i=new Adornment,i.type=Panel.Position,i.locationSpot=Spot.Center;const s=this.handleArchetype;s!==null&&i.add(s.copy().bm())}else if(e.li(),i=e.copy(),i===null)return null;return i.adornedObject=t,i}get handleArchetype(){return this.Co}set handleArchetype(t){this.Co=t}get handle(){return this.fs}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.fs=t}get adornedObject(){return this.us}set adornedObject(t){if(t!==null&&t.part instanceof Adornment)throw new Error("new handle must not be in an Adornment: "+t);this.us=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowRotate||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;if(this.adornedObject===null){if(this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle===null)return;this.adornedObject=this.handle.part.adornedObject}this.adornedObject!==null&&(t.isMouseCaptured=!0,t.delaysLayout=!0,this.startTransaction(this.name),this.eM=this.adornedObject.angle,this.Mm=this.computeRotationPoint(this.adornedObject),this.yc=this.adornedObject.part.location.copy(),this.isActive=!0)}computeRotationPoint(t){const i=t.part,e=i.locationObject;return i.rotationSpot.isSpot()?t.getDocumentPoint(i.rotationSpot):t===i||t===e?e.getDocumentPoint(i.locationSpot):t.getDocumentPoint(Spot.Center)}computeAdornmentLocation(t){let i=this.rotationPoint;i.isReal()||(i=this.computeRotationPoint(t));const e=t.getLocalPoint(i);let s=this.handleAngle;s<0?s+=360:s>=360&&(s-=360),s=Math.round(Math.round(s/45)*45);const n=this.handleDistance;return s===0?e.x=t.naturalBounds.width+n:s===45?(e.x=t.naturalBounds.width+n,e.y=t.naturalBounds.height+n):s===90?e.y=t.naturalBounds.height+n:s===135?(e.x=-n,e.y=t.naturalBounds.height+n):s===180?e.x=-n:s===225?(e.x=-n,e.y=-n):s===270?e.y=-n:s===315&&(e.x=t.naturalBounds.width+n,e.y=-n),t.getDocumentPoint(e)}doDeactivate(){const t=this.diagram;this.stopTransaction(),this.handle=null,this.us=null,this.Mm=new Point(NaN,NaN),t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){const t=this.diagram;t.delaysLayout=!1,this.rotate(this.originalAngle),this.stopTool()}doMouseMove(){const t=this.diagram;if(this.isActive){const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i)}}doMouseUp(){const t=this.diagram;if(this.isActive){t.delaysLayout=!1;const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.v("PartRotated",this.adornedObject,this.originalAngle)}this.stopTool()}rotate(t){const i=this.adornedObject;if(i===null)return;i.angle=t;const e=i.part;e.ensureBounds();const s=e.locationObject,n=e.rotateObject;if(s===n||s.isContainedBy(n)){const o=this.yc.copy();e.location=o.subtract(this.rotationPoint).rotate(t-this.originalAngle).add(this.rotationPoint)}this.diagram.maybeUpdate()}computeRotate(t){let i=this.rotationPoint.directionPoint(t)-this.handleAngle;const e=this.adornedObject.panel;e!==null&&(i-=e.getDocumentAngle()),i>=360?i-=360:i<0&&(i+=360);const s=Math.min(Math.abs(this.snapAngleMultiple),180),n=Math.min(Math.abs(this.snapAngleEpsilon),s/2);return!this.diagram.lastInput.shift&&s>0&&n>0&&(i%ss-n&&(i=(Math.floor(i/s)+1)*s)),i>=360?i-=360:i<0&&(i+=360),i}get snapAngleMultiple(){return this.tM}set snapAngleMultiple(t){Util.i(t,"number",RotatingTool,"snapAngleMultiple"),this.tM=t}get snapAngleEpsilon(){return this.iM}set snapAngleEpsilon(t){Util.i(t,"number",RotatingTool,"snapAngleEpsilon"),this.iM=t}get originalAngle(){return this.eM}get rotationPoint(){return this.Mm}set rotationPoint(t){this.Mm=t.copy()}get handleAngle(){return this.sM}set handleAngle(t){Util.i(t,"number",RotatingTool,"handleAngle"),this.sM=t}get handleDistance(){return this.nM}set handleDistance(t){Util.i(t,"number",RotatingTool,"handleDistance"),this.nM=t}}class ClickSelectingTool extends Tool{constructor(t){super(),this.name="ClickSelecting",t&&Object.assign(this,t)}canStart(){return!(!this.isEnabled||this.isBeyondDragSize())}doMouseUp(){this.isActive&&(this.standardMouseSelect(),this.standardMouseClick()||this.diagram.lastInput.isTouchEvent&&this.diagram.toolManager.doToolTip()),this.stopTool()}}class ActionTool extends Tool{wc;constructor(t){super(),this.name="Action",this.wc=null,t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram,i=t.lastInput,e=t.findObjectAt(i.documentPoint,s=>{for(;s.panel!==null;){if(s.isActionable)return s;s=s.panel}return s});return e!==null&&e.isActionable?(this.wc=e,t.cc=t.findObjectAt(i.documentPoint,null,null),!0):!1}doMouseDown(){if(!this.isActive)this.canStart()&&this.doActivate();else{const i=this.diagram.lastInput,e=this.wc;if(e===null)return;i.targetObject=e,e.actionDown!==null&&e.actionDown(i,e)}}doMouseMove(){if(this.isActive){const i=this.diagram.lastInput,e=this.wc;if(e===null)return;i.targetObject=e,e.actionMove!==null&&e.actionMove(i,e)}}doMouseUp(){if(this.isActive){const i=this.diagram.lastInput,e=this.wc;if(e===null)return;i.targetObject=e,e.actionUp!==null&&e.actionUp(i,e),this.standardMouseClick(s=>{for(;s.panel!==null;){if(s.isActionable&&s===e)return s;s=s.panel}return s},s=>s===e)}this.stopTool()}doCancel(){const i=this.diagram.lastInput,e=this.wc;e!==null&&(i.targetObject=e,e.actionCancel!==null&&e.actionCancel(i,e),this.stopTool())}doStop(){this.wc=null}}class ClickCreatingTool extends Tool{Ll;oM;pc;rM;constructor(t){super(),this.name="ClickCreating",this.Ll=null,this.oM=!0,this.pc=!1,this.rM=new Point(0,0),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled||this.archetypeNodeData===null)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.lastInput.left||this.isBeyondDragSize())return!1;if(this.isDoubleClick){if(t.lastInput.clickCount===1&&(this.rM=t.lastInput.viewPoint.copy()),t.lastInput.clickCount!==2||this.isBeyondDragSize(this.rM))return!1}else if(t.lastInput.clickCount!==1)return!1;return!(t.currentTool!==this&&t.findPartAt(t.lastInput.documentPoint,!0)!==null)}doMouseUp(){const t=this.diagram;this.isActive&&this.insertPart(t.lastInput.documentPoint),this.stopTool()}insertPart(t){const i=this.diagram,e=this.archetypeNodeData;if(e===null)return null;let s=null;try{if(i.v("ChangingSelection",i.selection),this.startTransaction(this.name),e instanceof Part)e.Pe()&&(e.li(),s=e.copy(),s!==null&&i.add(s));else if(e!==null){const n=i.model.copyNodeData(e);Util.wt(n)&&(i.model.addNodeData(n),s=i.findPartForData(n))}if(s!==null){const n=Point.X(t.x,t.y);this.isGridSnapEnabled&&this.diagram.lM(s,t,n),s.location=n,i.allowSelect&&(i.clearSelection(!0),s.isSelected=!0),Point.s(n)}i.invalidateDocumentBounds(),this.transactionResult=this.name,i.v("PartCreated",s)}finally{this.stopTransaction(),i.v("ChangedSelection",i.selection)}return s}get archetypeNodeData(){return this.Ll}set archetypeNodeData(t){t!==null&&Util.i(t,"object",ClickCreatingTool,"archetypeNodeData"),this.Ll=t}get isDoubleClick(){return this.oM}set isDoubleClick(t){Util.i(t,"boolean",ClickCreatingTool,"isDoubleClick"),this.oM=t}get isGridSnapEnabled(){return this.pc}set isGridSnapEnabled(t){Util.i(t,"boolean",ClickCreatingTool,"isGridSnapEnabled"),this.pc=t}}class DragSelectingTool extends Tool{Bh;hM;Al;constructor(t){super(),this.name="DragSelecting",this.Bh=175,this.hM=!1,this.Al=new Part({layerName:"Tool",selectable:!1}).add(new Shape("Rectangle",{name:"SHAPE",fill:null,stroke:"magenta"}).theme("stroke","dragSelect")).li(),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(!t.allowSelect)return!1;const i=t.lastInput;return!(!i.left||t.currentTool!==this&&(!this.isBeyondDragSize()||i.timestamp-t.firstInput.timestamp{const e=i.diagram;e!==null&&e.Si(root.document,"scroll",i.aM,!1),i.stopTool()},t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return!(!t.allowHorizontalScroll&&!t.allowVerticalScroll||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize())}doActivate(){const t=this.diagram;this.No?(t.lastInput.bubbles=!0,t.Vt(root.document,"scroll",this.aM,!1)):(t.currentCursor="move",t.isMouseCaptured=!0,this.Hw.a(t.position)),this.isActive=!0}doDeactivate(){const t=this.diagram;t.currentCursor="",t.isMouseCaptured=!1,this.isActive=!1}doCancel(){const t=this.diagram;t.position=this.Hw,t.isMouseCaptured=!1,this.stopTool()}doMouseMove(){this.HC()}doMouseUp(){this.HC(),this.stopTool()}HC(){const t=this.diagram;if(this.isActive&&t){if(this.No){t.lastInput.bubbles=!0;return}const i=t.position,e=t.firstInput.documentPoint,s=t.lastInput.documentPoint;let n=i.x+e.x-s.x,o=i.y+e.y-s.y;t.allowHorizontalScroll||(n=i.x),t.allowVerticalScroll||(o=i.y),t.position=this.jC.e(n,o)}}get bubbles(){return this.No}set bubbles(t){Util.i(t,"boolean",PanningTool,"bubbles"),this.No=t}get originalPosition(){return this.Hw}}class HTMLInfo{qw;Ww;cM;fM;constructor(t){this.qw=null,this.Ww=null,this.cM=null,this.fM=null,t&&Object.assign(this,t)}get mainElement(){return this.cM}set mainElement(t){this.cM=t}get show(){return this.qw}set show(t){this.qw!==t&&(t!==null&&Util.i(t,"function",HTMLInfo,"show"),this.qw=t)}get hide(){return this.Ww}set hide(t){this.Ww!==t&&(t!==null&&Util.i(t,"function",HTMLInfo,"hide"),this.Ww=t)}get valueFunction(){return this.fM}set valueFunction(t){this.fM=t}}class ContextMenuButtonInfo{hi;Sm;bc;constructor(t,i,e){this.hi=t,this.Sm=i,this.bc=e}}class ContextMenuTool extends Tool{uM;Jw;dM;gM;$w;Zw;Nm;constructor(t){super(),this.name="ContextMenu",this.uM=null,this.Jw=null,this.dM=null,this.gM=new Point,this.$w=null,this.Nm=!1;const i=this;this.Zw=()=>i.stopTool(),t&&Object.assign(this,t)}nF(){const t=new HTMLInfo;t.show=(r,l,h)=>h.showDefaultContextMenu(),t.hide=(r,l)=>l.hideDefaultContextMenu(),ContextMenuTool.ku=t;const i=this;this.Zw=()=>i.stopTool();const e=Util.en("div"),s=Util.en("div");e.style.cssText="top: 0px;z-index:10002;position: fixed;display: none;text-align: center;left: 25%;width: 50%;background-color: #F5F5F5;padding: 16px;border: 16px solid #444;border-radius: 10px;margin-top: 10px",s.style.cssText="z-index:10001;position: fixed;display: none;top: 0;left: 0;width: 100%;height: 100%;background-color: black;opacity: 0.8;";const n=Util.en("style");root.document.getElementsByTagName("head")[0].appendChild(n),n.sheet.insertRule(".goCXul { list-style: none; }",0),n.sheet.insertRule(".goCXli {font:700 1.5em Helvetica, Arial, sans-serif;position: relative;min-width: 60px; }",0),n.sheet.insertRule(".goCXa {color: #444;display: inline-block;padding: 4px;text-decoration: none;margin: 2px;border: 1px solid gray;border-radius: 10px; }",0);const o=this.diagram;o!==null&&(o.Vt(e,"contextmenu",ContextMenuTool.Kh,!1),o.Vt(e,"selectstart",ContextMenuTool.Kh,!1),o.Vt(s,"contextmenu",ContextMenuTool.Kh,!1)),e.className="goCXforeground",s.className="goCXbackground",root.document.body&&(root.document.body.appendChild(e),root.document.body.appendChild(s)),ContextMenuTool.Cm=e,ContextMenuTool.Lm=s,ContextMenuTool.mM=!0}static ku=null;static mM=!1;static Lm=null;static Cm=null;static Kh(t){return t.preventDefault(),!1}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return this.isBeyondDragSize()||!t.lastInput.right||t.lastInput.clickCount>1?!1:!!(t.lastInput.isTouchEvent&&this.defaultTouchContextMenu!==null||this.findObjectWithContextMenu()!==null)}doStart(){const t=this.diagram;this.gM.set(t.firstInput.documentPoint)}doStop(){this.hideContextMenu(),this.currentObject=null,this.Nm=!1}findObjectWithContextMenu(t){t===void 0&&(t=null);const i=this.diagram,e=i.lastInput;let s=null;if(t instanceof Diagram||(t instanceof GraphObject?s=t:s=i.findObjectAt(e.documentPoint,null,n=>!n.layer.isTemporary)),s!==null){let n=s;for(;n!==null;){if(n.contextMenu!==null)return n;n=n.panel}if(i.lastInput.isTouchEvent&&this.defaultTouchContextMenu)return s.part}else if(i.contextMenu!==null)return i;return null}doActivate(){}doMouseDown(){if(super.doMouseDown(),this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doMouseDown(),t.doDeactivate())}this.diagram.toolManager.mouseDownTools.has(this)&&this.doContextClick()}doMouseUp(){if(this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doCancel(),t.doDeactivate())}this.doContextClick()}doContextClick(){const t=this.diagram;if(!this.isActive)this.canStart()&&(this.openMenu(!0),this.isActive||this.stopTool());else{const i=this.currentContextMenu;if(i===null)return;let e=null;i instanceof HTMLInfo||(e=t.findObjectAt(t.lastInput.documentPoint,null,null),e!==null&&e.isContainedBy(i)&&this.standardMouseClick(null,null)),this.maybeStopTool(e)}}maybeStopTool(t){this.stopTool(),this.canStart()&&(this.diagram.currentTool=this,this.doMouseUp())}openMenu(t,i){if(i===void 0&&(i=null),this.Nm)return;this.Nm=!0,t&&this.standardMouseSelect();const e=this.standardMouseClick();if(this.Nm=!1,!e){this.isActive=!0;const s=ContextMenuTool.ku;if(i===null&&(i=this.findObjectWithContextMenu()),i!==null){const n=i.contextMenu;n!==null?(this.currentObject=i instanceof GraphObject?i:null,this.showContextMenu(n,this.currentObject)):s!==null&&this.showContextMenu(s,this.currentObject)}else s!==null&&this.showContextMenu(s,null);this.currentContextMenu instanceof Adornment&&!this.currentContextMenu.visible&&this.stopTool()}}doMouseMove(){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.doMouseMove(),this.isActive&&this.diagram.toolManager.doMouseMove()}showContextMenu(t,i){const e=this.diagram;if(t!==this.currentContextMenu&&this.hideContextMenu(),t instanceof Adornment){const s=t;s.layerName="Tool",s.selectable=!1,s.scale=1/e.scale,s.category=this.name,s.hasPlaceholder()&&(s.placeholder.scale=e.scale);const n=s.diagram;n!==null&&n!==e&&n.remove(s),e.add(s),i!==null?s.adornedObject=i:s.data=e.model,s.ensureBounds(),this.positionContextMenu(s,i)}else t instanceof HTMLInfo&&t.show(i,e,this);this.currentContextMenu=t}positionContextMenu(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom&&(n.y-=o.height+5/s.scale),n.ye.commandHandler.copySelection(),e=>e.commandHandler.canCopySelection())),i.add(new ContextMenuButtonInfo("Cut",e=>e.commandHandler.cutSelection(),e=>e.commandHandler.canCutSelection())),i.add(new ContextMenuButtonInfo("Delete",e=>e.commandHandler.deleteSelection(),e=>e.commandHandler.canDeleteSelection())),i.add(new ContextMenuButtonInfo("Paste",e=>e.commandHandler.pasteSelection(t.mouseDownPoint),e=>e.commandHandler.canPasteSelection(t.mouseDownPoint))),i.add(new ContextMenuButtonInfo("Select All",e=>e.commandHandler.selectAll(),e=>e.commandHandler.canSelectAll())),i.add(new ContextMenuButtonInfo("Undo",e=>e.commandHandler.undo(),e=>e.commandHandler.canUndo())),i.add(new ContextMenuButtonInfo("Redo",e=>e.commandHandler.redo(),e=>e.commandHandler.canRedo())),i.add(new ContextMenuButtonInfo("Scroll To Part",e=>e.commandHandler.scrollToPart(),e=>e.commandHandler.canScrollToPart())),i.add(new ContextMenuButtonInfo("Zoom To Fit",e=>e.commandHandler.zoomToFit(),e=>e.commandHandler.canZoomToFit())),i.add(new ContextMenuButtonInfo("Reset Zoom",e=>e.commandHandler.resetZoom(),e=>e.commandHandler.canResetZoom())),i.add(new ContextMenuButtonInfo("Group Selection",e=>e.commandHandler.groupSelection(),e=>e.commandHandler.canGroupSelection())),i.add(new ContextMenuButtonInfo("Ungroup Selection",e=>e.commandHandler.ungroupSelection(),e=>e.commandHandler.canUngroupSelection())),i.add(new ContextMenuButtonInfo("Edit Text",e=>e.commandHandler.editTextBlock(),e=>e.commandHandler.canEditTextBlock())),i}showDefaultContextMenu(){const t=this.diagram;this.$w===null&&(this.$w=this.oF()),ContextMenuTool.Cm.innerHTML="",ContextMenuTool.Lm.addEventListener("pointerdown",this.Zw,!1);const i=this,e=Util.en("ul");e.className="goCXul",ContextMenuTool.Cm.appendChild(e),e.innerHTML="";const s=this.$w.iterator;for(;s.next();){const n=s.value,o=n.Sm,r=n.bc;if(typeof o!="function"||typeof r=="function"&&!r(t))continue;const l=Util.en("li");l.className="goCXli";const h=Util.en("a");h.className="goCXa",h.href="#",h.Sm=n.Sm,h.addEventListener("pointerdown",function(a){return this.Sm(t),i.stopTool(),a.preventDefault(),!1},!1),h.textContent=n.hi,l.appendChild(h),e.appendChild(l)}ContextMenuTool.Cm.style.display="block",ContextMenuTool.Lm.style.display="block"}hideDefaultContextMenu(){if(this.currentContextMenu===null||this.currentContextMenu!==ContextMenuTool.ku)return;ContextMenuTool.Cm.style.display="none",ContextMenuTool.Lm.style.display="none";const t=this.diagram;t!==null&&t.Si(ContextMenuTool.Lm,"pointerdown",this.Zw,!1),this.currentContextMenu=null}get currentContextMenu(){return this.uM}set currentContextMenu(t){this.uM=t,this.Jw=t instanceof Adornment?t.adornedPart:null}get defaultTouchContextMenu(){return ContextMenuTool.mM===!1&&ContextMenuTool.ku===null&&Diagram.isUsingDOM()&&this.nF(),ContextMenuTool.ku}set defaultTouchContextMenu(t){t===null&&(ContextMenuTool.mM=!0),ContextMenuTool.ku=t}get currentObject(){return this.dM}set currentObject(t){this.dM=t}get mouseDownPoint(){return this.gM}}var TextEditingAccept=(w=>(w[w.LostFocus=1]="LostFocus",w[w.MouseDown=2]="MouseDown",w[w.Tab=3]="Tab",w[w.Enter=4]="Enter",w))(TextEditingAccept||{}),TextEditingStarting=(w=>(w[w.SingleClick=1]="SingleClick",w[w.SingleClickSelected=2]="SingleClickSelected",w[w.DoubleClick=3]="DoubleClick",w))(TextEditingStarting||{}),TextEditingState=(w=>(w[w.None=1]="None",w[w.Active=2]="Active",w[w.Editing=3]="Editing",w[w.Validating=4]="Validating",w[w.Invalid=5]="Invalid",w[w.Validated=6]="Validated",w))(TextEditingState||{});class TextEditingTool extends Tool{Me;pM;yM;Tl;Yt;wM;xM;bM;Qw;_w;constructor(t){super(),this.name="TextEditing",this.Me=new TextBlock,this.pM=null,this.yM=2,this.Tl=null,this.Yt=1,this.wM=1,this.xM=!0,this.bM=null,this.Qw=new HTMLInfo,this._w=null,this.rF(this.Qw),t&&Object.assign(this,t)}static LostFocus=1;static MouseDown=2;static Tab=3;static Enter=4;static SingleClick=1;static SingleClickSelected=2;static DoubleClick=3;static StateNone=1;static StateActive=2;static StateEditing=3;static StateValidating=4;static StateInvalid=5;static StateValidated=6;rF(t){if(!Diagram.isUsingDOM())return;const i=Util.en("textarea");this._w=i;const e=this;i.addEventListener("input",function(s){if(e.textBlock===null)return;const n=e.measureTemporaryTextBlock(this.value),o=this.textScale;this.style.width=20+Math.max(e.textBlock.measuredBounds.width,n.measuredBounds.width)*o+"px",this.rows=Math.max(e.textBlock.lineCount,n.lineCount)},!1),i.addEventListener("keydown",function(s){if(s.isComposing||e.textBlock===null)return;const n=s.key;if(n==="Enter"){e.textBlock.isMultiline===!1&&s.preventDefault(),e.acceptText(4);return}else if(n==="Tab"){e.acceptText(3),s.preventDefault();return}else n==="Escape"&&(e.doCancel(),e.diagram!==null&&e.diagram.doFocus())},!1),i.addEventListener("focus",function(s){e.lF(s)},!1),i.addEventListener("blur",function(s){e.hF(s)},!1),t.valueFunction=()=>i.value,t.mainElement=i,t.show=(s,n,o)=>{if(!(s instanceof TextBlock&&o instanceof TextEditingTool))return;if(o.state===5){i.style.border="3px solid red",i.focus();return}const r=s.getDocumentPoint(Spot.Center),l=n.position,h=n.scale;let a=s.getDocumentScale()*h;a{s.div.removeChild(i)}}get textBlock(){return this.pM}set textBlock(t){this.pM=t}get currentTextEditor(){return this.bM}set currentTextEditor(t){this.bM=t}get defaultTextEditor(){return this.Qw}set defaultTextEditor(t){this.Qw=t}get starting(){return this.yM}set starting(t){this.yM=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t===null||t.isReadOnly||TextEditingTool.kc&&TextEditingTool.kc!==this&&(TextEditingTool.kc.acceptText(2),TextEditingTool.kc&&TextEditingTool.kc!==this)||!t.lastInput.left||this.isBeyondDragSize())return!1;const i=t.lastInput.documentPoint,e=t.findObjectAt(i);if(e===null||!(e instanceof TextBlock)||!e.editable||!e.part.canEdit())return!1;const s=e.part;return!(s===null||this.starting===2&&!s.isSelected||this.starting===3&&t.lastInput.clickCount<2)}doStart(){TextEditingTool.kc=this,this.textBlock!==null&&this.doActivate()}doActivate(){if(this.isActive)return;const t=this.diagram;if(t===null)return;let i=this.textBlock;if(i===null&&(i=t.findObjectAt(t.lastInput.documentPoint)),i===null||!(i instanceof TextBlock)||(this.textBlock=i,i.part===null))return;t.animationManager.stopAnimation(),this.isActive=!0,this.Yt=2;let s=this.defaultTextEditor;i.textEditor!==null&&(s=i.textEditor),this.Me=this.textBlock.copy();const n=new Rect(this.textBlock.getDocumentPoint(Spot.TopLeft),this.textBlock.getDocumentPoint(Spot.BottomRight));t.scrollToRect(n),s.show(i,t,this),this.currentTextEditor=s}doCancel(){this.stopTool()}doMouseUp(){this.canStart()&&this.doActivate()}doMouseDown(){this.isActive&&this.acceptText(2)}acceptText(t){switch(t){case 2:this.Yt===6?this.currentTextEditor instanceof HTMLElement&&this.currentTextEditor.focus():(this.Yt===2||this.Yt===5||this.Yt===3)&&(this.Yt=4,this.qC());break;case 1:case 4:case 3:if(t===4&&this.textBlock.isMultiline===!0)return;(this.Yt===2||this.Yt===5||this.Yt===3)&&(this.Yt=4,this.qC());break}}qC(){const t=this.textBlock,i=this.diagram,e=this.currentTextEditor;if(t!==null&&e!==null){const s=t.text;let n="";if(e.valueFunction!==null&&(n=e.valueFunction()),!this.isValidText(t,s,n)){this.Yt=5,this.doError(s,n);return}this.startTransaction(this.name),this.Yt=6,this.transactionResult=this.name,t.text=n,this.doSuccess(s,n),i!==null&&i.v("TextEdited",t,s),this.stopTransaction(),this.stopTool(),i!==null&&i.doFocus()}}doError(t,i){const e=this.textBlock;e.errorFunction!==null&&e.errorFunction(this,t,i);const s=this.currentTextEditor;s&&s.show(e,this.diagram,this)}doSuccess(t,i){const e=this.textBlock;e.textEdited!==null&&e.textEdited(e,t,i)}doDeactivate(){const t=this.diagram;t!==null&&(this.Yt=1,this.currentTextEditor!==null&&this.currentTextEditor.hide(t,this),this.textBlock=null,this.isActive=!1)}doStop(){TextEditingTool.kc=null}lF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this._w;this.Yt===2&&(this.Yt=3),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}hF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this._w;typeof i.focus=="function"&&i.focus(),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}isValidText(t,i,e){const s=this.textValidation;if(s!==null&&!s(t,i,e))return!1;const n=t.textValidation;return!(n!==null&&!n(t,i,e))}get textValidation(){return this.Tl}set textValidation(t){t!==null&&Util.i(t,"function",TextEditingTool,"textValidation"),this.Tl=t}get minimumEditorScale(){return this.wM}set minimumEditorScale(t){t!==null&&Util.i(t,"number",TextEditingTool,"minimumEditorScale"),this.wM=t}get selectsTextOnActivate(){return this.xM}set selectsTextOnActivate(t){t!==null&&Util.i(t,"boolean",TextEditingTool,"selectsTextOnActivate"),this.xM=t}get state(){return this.Yt}set state(t){this.Yt!==t&&(this.Yt=t)}measureTemporaryTextBlock(t){const i=this.Me;return i.text=t,i.ut(this.textBlock.Dl,1/0),i}static kc=null}var AnimationStyle=(w=>(w[w.Default=1]="Default",w[w.AnimateLocations=2]="AnimateLocations",w[w.None=3]="None",w))(AnimationStyle||{});class AnimationManager{p;Ni;Oi;kr;Gn;Ao;kM;PM;Am;wi;Pc;un;Tm;Yh;tx;Dm;ix;Mc;xu;Fm;constructor(t){this.p=Diagram.pm(),this.Ni=!1,this.Am=!1,this.wi=!1,this.Pc=!1,this.ix=!0,this.Mc=1,this.xu=!1,this.Oi=!0,this.kr=!0,this.Ao=600,this.kM=!1,this.PM=!1,this.Gn=new GSet,this.un=new Animation,this.Tm=new Animation,this.un.ds=this,this.Yh=new GSet,this.tx=new GSet,this.Dm=new GSet,this.Fm=new GSet,t&&Object.assign(this,t)}To(t){this.p=t}lE(){return this.p}canStart(t){return!0}Fl(t){return!this.Oi||!this.canStart(t)?!1:(this.Gn.add(t),this.defaultAnimation.isAnimating&&this.stopAnimation(),this.p.Ci(),this.wi=!0,!0)}getBundleAnimation(){return this.Tm}MM(){if(!this.Oi||(this.Tm.ae.count>0&&this.Tm.start(),!this.wi))return;const t=this.un,i=this.p,e=this.Gn.has("Model");if(e&&(this.Pc=!0,this.Mc===1?(t.isViewportUnconstrained=!0,t.ae.clear(),t.add(i,"position",i.position.copy().offset(0,-200),i.position),t.add(i,"opacity",0,1)):this.Mc===3&&t.ae.clear(),this.Mc===2&&i.ex.equals(i.ct)?this.ix=!0:this.ix=!1,i.v("InitialAnimationStarting",this)),e&&!this.kr||t.ae.count===0){this.Gn.clear(),this.wi=!1,t.ae.clear(),t.sx(i),this.Pc=!1,i.C();return}this.Gn.clear(),i.Pr=!1;const s=t.ae.get(i);i.autoScale!==1&&s!==null&&(delete s.ei.scale,delete s.gs.scale);const n=this;root.requestAnimationFrame(()=>{n.wi===!1||t.Ni||(i.getRenderingHint("temporaryPixelRatio")&&i.Bw(),i.SM(),n.wi=!1,t.start(),t.Ni&&(n.Pu(),i.invalidateDocumentBounds(),t.WC(0),i.yr(!0),n.Mu(),i.v("AnimationStarting",n)))})}NM(){return this.Gn.has("Trigger")&&this.Gn.count===1}JC(t,i,e,s){this.isTicking||this.NM()||t instanceof Link&&(t.fromNode!==null||t.toNode!==null)||this.un.add(t,"position",i,e,s)}nx(t){return this.un.nx(t)}CM(t){return this.un.CM(t)}aF(t){const i=this.Yh,e=this;function s(){if(e.Dm.count>0&&(i.addAll(e.Dm),e.Dm.clear(),e.Ni=!0),e.Ni===!1||i.count===0)return;e.tx.addAll(i);const n=e.tx.iterator;for(;n.next();){const o=n.value;o.Ni!==!1&&(o.cF()?o.$C(!1):o.Sc=!0)}if(e.tx.clear(),e.Ni===!1){root.requestAnimationFrame(s);return}e.Pu(),e.p.yr(),e.Mu(),root.requestAnimationFrame(s)}this.Ni?this.fF(t):(this.Ni=!0,i.add(t),root.requestAnimationFrame(()=>s()))}fF(t){this.Dm.add(t)}uF(){const t=this.Yh.iterator;for(;t.next();)t.value.Sc=!1}Pu(){if(this.Am)return;const t=this.p;this.kM=t.skipsUndoManager,this.PM=t.ce,t.skipsUndoManager=!0,t.ce=!0,this.Am=!0}Mu(){const t=this.p;t.skipsUndoManager=this.kM,t.ce=this.PM,this.Am=!1}stopAnimation(t){const i=this.un;if(this.wi===!0&&(this.wi=!1,this.Pc=!1,this.Gn.clear(),i.dF()&&this.p.requestUpdate()),!this.Ni){i.ae.clear(),i.sx(this.p);return}if(i.Su(!0),i.sx(null),t===!0){const e=this.Yh.toArray();for(let s=0;s{!i.isAnimating&&i.runCount===1/0&&i.start()})}get duration(){return this.Ao}set duration(t){Util.i(t,"number",AnimationManager,"duration"),t<1&&Util._(t,">= 1",AnimationManager,"duration"),this.Ao=t}get isAnimating(){return this.Ni}get isTicking(){return this.Am}get isInitial(){return this.kr}set isInitial(t){Util.i(t,"boolean",AnimationManager,"isInitial"),this.kr=t}get defaultAnimation(){return this.un}get activeAnimations(){return this.Yh}get initialAnimationStyle(){return this.Mc}set initialAnimationStyle(t){this.Mc=t}static ox=new GMap;static defineAnimationEffect(t,i){AnimationManager.ox.set(t,i)}static TM(t,i,e,s,n){t===null&&(t=[0,0,0,0]),i===null&&(i=[0,0,0,0]);let o=t[0],r=t[1];const l=t[2],h=t[3];let a=i[0],c=i[1];const f=i[2],u=i[3];l===0||l===100?(o=a,r=c):(f===0||f===100)&&(a=o,c=r),Math.abs(a-o)>180&&(a>o?o+=360:a+=360);const d=n(e,o,a-o,s)%360,m=n(e,r,c-r,s),g=n(e,l,f-l,s),p=n(e,h,u-h,s);return"hsla("+d+", "+m+"%, "+g+"%, "+p+")"}static{const t=AnimationManager.ox,i=(e,s,n,o,r,l)=>{e.position=new Point(o(r,s.x,n.x-s.x,l),o(r,s.y,n.y-s.y,l))};t.set("position:diagram",i),t.set("position",i),t.set("position:part",(e,s,n,o,r,l)=>{r{r{r{const h=e.actualBounds,a=n.actualBounds,c=a.x+a.width/2-h.width/2,f=a.y+a.height/2-h.height/2;r{e.desiredSize=new Size(o(r,s.width,n.width-s.width,l),o(r,s.height,n.height-s.height,l))}),t.set("width",(e,s,n,o,r,l)=>{e.width=o(r,s,n-s,l)}),t.set("height",(e,s,n,o,r,l)=>{e.height=o(r,s,n-s,l)}),t.set("fill",(e,s,n,o,r,l)=>{e.fill=AnimationManager.TM(s,n,r,l,o)}),t.set("stroke",(e,s,n,o,r,l)=>{e.stroke=AnimationManager.TM(s,n,r,l,o)}),t.set("strokeWidth",(e,s,n,o,r,l)=>{e.strokeWidth=o(r,s,n-s,l)}),t.set("strokeDashOffset",(e,s,n,o,r,l)=>{e.strokeDashOffset=o(r,s,n-s,l)}),t.set("background",(e,s,n,o,r,l)=>{e.background=AnimationManager.TM(s,n,r,l,o)}),t.set("opacity",(e,s,n,o,r,l)=>{e.opacity=o(r,s,n-s,l)}),t.set("scale",(e,s,n,o,r,l)=>{e.scale=o(r,s,n-s,l)}),t.set("angle",(e,s,n,o,r,l)=>{e.angle=o(r,s,n-s,l)})}static Default=1;static AnimateLocations=2;static None=3}class Animation{rx;Rm;Ni;Nu;Ao;ms;tL;Lc;ae;lx;ei;jn;Cu;Ac;hx;ax;Sc;DM;cx;ds;p;FM;RM;vM;constructor(t){this.p=null,this.ds=null,this.DM=null,this.cx=null,this.FM=!1,this.Ni=!1,this.Sc=!1,this.ei=0,this.jn=0,this.rx=Animation.EaseInOutQuad,this.Rm=Animation.EaseInOutQuad,this.Cu=!1,this.Ac=!1,this.hx=1,this.ax=0,this.Ao=NaN,this.ms=NaN,this.RM=0,this.Nu=null,this.tL=Point.Po,this.ae=new GMap,this.lx=new GMap,this.Lc=new GSet,this.vM=1,t&&Object.assign(this,t)}suspend(){this.Sc=!0}advanceTo(t,i){i&&(this.Sc=!1),this.Cu&&t>=this.ms&&(this.Ac=!0,t=t-this.ms),this.RM=t,this.$C(!0),this.ds.Pu(),this.p.yr(),this.ds.Mu(),this.p.redraw()}sx(t){if(this.lx.clear(),this.Ac=!1,this.ax=0,this.ms=NaN,this.Lc.count>0&&this.Lc.clear(),t!==null){const i=t.links;for(;i.next();)i.value.Mr=null}}dF(){return this.ae.count>0}start(){if(this.ae.count===0)return this;if(this.Ni)return this;let t=this.p;const i=this.ae.iterator;for(;i.next();){const s=i.key;t===null&&(s instanceof Diagram?t=s:s instanceof GraphObject&&(t=s.diagram))}if(t!==null)this.p=t,this.ds=t.animationManager;else return this;const e=this.ds;return e.isEnabled===!1?this:(this.ms=isNaN(this.Ao)?e.duration:this.Ao,this.Rm=this.rx,e.Pc&&e.Mc===1&&this===e.defaultAnimation&&(this.Rm=Animation.EaseOutExpo,this.ms=isNaN(this.Ao)?e.duration===600?900:e.duration:this.Ao),this.vM=t.scrollMode,this.isViewportUnconstrained&&(t.Gh=2),e.Pu(),this.Lc.each(s=>{s.data=null,t.add(s)}),e.Mu(),this.Ni=!0,this.ei=+new Date,this.jn=this.ei+this.ms,e.aF(this),this)}addTemporaryPart(t,i){return t.Pe()?(this.Lc.add(t),this.p=i,this):this}add(t,i,e,s,n){if(this.p===null&&(t instanceof Diagram?this.p=t:t instanceof GraphObject&&t.diagram!==null&&(this.p=t.diagram)),t instanceof Part){if(!t.isAnimated)return this;i==="position"&&(i="position:part")}return this.LM(t,i,e,s,n),this}LM(t,i,e,s,n){const o=this.ae;let r,l,h;if(t instanceof Diagram&&i==="position"&&(i="position:diagram"),(i==="fill"||i==="stroke"||i==="background")&&(Brush.Do(e),Brush.OM(),e=[Brush.Ii.n0,Brush.Ii.n1,Brush.Ii.n2,Brush.Ii.n3],Brush.Do(s),Brush.OM(),s=[Brush.Ii.n0,Brush.Ii.n1,Brush.Ii.n2,Brush.Ii.n3]),o.has(t))r=o.get(t),l=r.ei,h=r.gs,l[i]===void 0&&(l[i]=this.Lu(e)),h[i]=this.Lu(s);else{if(i==="position"&&e.equalsApprox(s))return;l={},h={},l[i]=this.Lu(e),h[i]=this.Lu(s),r=new AnimationState(l,h,n),o.set(t,r)}const a=l[i];a instanceof Point&&!a.isReal()&&a.a(this.tL),n&&i.indexOf("position:")===0&&t instanceof Part?r.fx.location=this.Lu(t.location):n&&(r.fx[i]=this.Lu(e))}Lu(t){return t instanceof Point||t instanceof Size?t.copy():t}gF(t){const i=this.ae;if(i.has(t)){const e=i.get(t);e.ux=!0}}nx(t){if(!this.Ni)return!1;const i=this.ae.get(t);return i!==null&&i.ux}CM(t){if(!this.Ni)return!1;const i=this.ae.get(t);return i!==null&&!!(i.ei.position||i.ei["position:part"]||i.ei.location)}cF(){if(this.Lc.count>0)return!0;const t=this.ae.iterator;for(;t.next();){const i=t.key;if(i instanceof GraphObject&&i.diagram!==null||i instanceof Diagram)return!0}return!1}$C(t){if(this.Sc&&!t)return;const i=this.ds;if(this.Ni===!1)return;const e=+new Date;let s=e>this.jn?this.ms:e-this.ei;t&&(s=this.RM,sthis.jn&&(this.Cu&&!this.Ac?(this.ei=+new Date,this.jn=this.ei+this.ms,this.Ac=!0):this.Su(!1))}WC(t){const i=this.ms,e=this.ae.iterator,s=this.Ac;for(;e.next();){const n=e.key;if(n instanceof GraphObject&&n.diagram===null)continue;const o=e.value,r=s?o.gs:o.ei,l=s?o.ei:o.gs,h=AnimationManager.ox;for(const a in l)a==="position"&&(l["position:placeholder"]||l["position:nodeCollapse"])||h.get(a)!==null&&h.get(a)(n,r[a],l[a],this.Rm,t,i,this)}}stop(){return this.Ni?(this.Su(!0),this):this}Su(t){if(this.cx!==null&&this.cx.mF(this.DM),!this.Ni)return;const i=this.p,e=this.ds;e.Pc=!1,this.Ni=!1,this.Sc=!1,e.Pu();const s=this.ae,n=this.Lc.iterator;for(;n.next();)i.remove(n.value);const o=this.Cu,r=s.iterator,l=AnimationManager.ox;for(;r.next();){const a=r.key,c=r.value,f=o?c.gs:c.ei,u=o?c.ei:c.gs,d=c.fx;for(const m in u)if(l.get(m)!==null){let g=m;c.gx&&(g==="position:nodeCollapse"||g==="position:placeholder")&&(g="position"),l.get(g)(a,f[m],d[m]!==void 0?d[m]:c.gx?f[m]:u[m],this.Rm,this.ms,this.ms,this)}c.gx&&d.location!==void 0&&a instanceof Part&&(a.location=d.location),c.ux&&a instanceof Part&&a.Ei(!1)}this.ax++;const h=!t&&this.hx>this.ax;if(!h&&(this===e.Tm||this===e.defaultAnimation)&&this.ae.clear(),i.mx.clear(),i.yP(!1),i.invalidateDocumentBounds(),i.C(),i.yr(!0),e.defaultAnimation===this){const a=e.Fm.iterator;for(;a.next();)a.value.pF();e.Fm.clear()}if(i.yr(!0),this.isViewportUnconstrained&&(i.scrollMode=this.vM),e.Mu(),h){this.Ac=!1,this.start();return}this.sx(null),e.Su(this),this.Nu&&this.Nu(this),i.requestUpdate()}Nc(t,i){const e=i.actualBounds;let s=null;if(i instanceof Group&&(s=i.placeholder),s!==null&&s.visible){const n=s.getDocumentPoint(Spot.TopLeft),o=s.padding;n.x+=o.left,n.y+=o.top,this.add(t,"position",n,t.position,!1)}else this.add(t,"position",new Point(e.x+e.width/2,e.y+e.height/2),t.position,!1);this.add(t,"scale",.01,t.scale,!1),t instanceof Group&&this.yF(t,i)}yF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Nc(s,i)}}Cc(t,i){if(!t.isVisible())return;let e=null;if(i instanceof Group&&(e=i.placeholder),e!==null&&e.visible){const s=e.getDocumentPoint(Spot.TopLeft),n=e.padding;s.x+=n.left,s.y+=n.top,this.add(t,"position:placeholder",t.position,s,!0)}else this.add(t,"position:nodeCollapse",t.position,i,!0);this.add(t,"scale",t.scale,.01,!0),this.gF(t),t instanceof Group&&this.wF(t,i)}wF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Cc(s,i)}}get duration(){return this.Ao}set duration(t){Util.i(t,"number",Animation,"duration"),t<1&&Util._(t,">= 1",Animation,"duration"),this.Ao=t}get reversible(){return this.Cu}set reversible(t){this.Cu=t}get runCount(){return this.hx}set runCount(t){t>0?this.hx=t:Util.o("Animation.runCount value must be a positive integer.")}get finished(){return this.Nu}set finished(t){this.Nu!==t&&(t!==null&&Util.i(t,"function",Animation,"finished"),this.Nu=t)}get easing(){return this.rx}set easing(t){this.rx=t}get isViewportUnconstrained(){return this.FM}set isViewportUnconstrained(t){this.FM=t}get isAnimating(){return this.Ni}getTemporaryState(t){let i=this.lx.get(t);return i===null&&(i={},this.lx.set(t,i)),i}static EaseLinear=(t,i,e,s)=>e*t/s+i;static EaseInOutQuad=(t,i,e,s)=>(t/=s/2,t<1?e/2*t*t+i:-e/2*(--t*(t-2)-1)+i);static EaseInQuad=(t,i,e,s)=>e*(t/=s)*t+i;static EaseOutQuad=(t,i,e,s)=>-e*(t/=s)*(t-2)+i;static EaseInExpo=(t,i,e,s)=>t===0?i:e*Math.pow(2,10*(t/s-1))+i;static EaseOutExpo=(t,i,e,s)=>t===s?i+e:e*(-Math.pow(2,-10*t/s)+1)+i}class AnimationState{ei;gs;fx;gx;ux;constructor(t,i,e){this.ei=t,this.gs=i,this.fx={},this.gx=e,this.ux=!1}}var TriggerStart=(w=>(w[w.Default=1]="Default",w[w.Immediate=2]="Immediate",w[w.Bundled=3]="Bundled",w))(TriggerStart||{});class AnimationTrigger{ke;an;Au;Tc;constructor(t,i,e){this.ke=null,this.an=t,this.Au=e||1,this.Tc=null,i!==void 0&&(this.Tc=i,e===void 0&&(this.Au=2))}copy(){const t=new AnimationTrigger(this.an);t.Au=this.Au;const i=this.Tc;if(i!==null){const e={};i.duration!==void 0&&(e.duration=i.duration),i.finished!==void 0&&(e.finished=i.finished),i.easing!==void 0&&(e.easing=i.easing),t.Tc=e}return t}get propertyName(){return this.an}set propertyName(t){this.an=t}get animationSettings(){return this.Tc}set animationSettings(t){this.Tc=t}xF(t){const i=this.Tc;i!==null&&(i.duration&&(t.duration=i.duration),i.finished&&(t.finished=i.finished),i.easing&&(t.easing=i.easing))}get startCondition(){return this.Au}set startCondition(t){this.Au=t}static Default=1;static Immediate=2;static Bundled=3}class Layer{p;St;Wt;Sr;Rl;vl;Ol;Il;El;Ul;Bl;Vl;zl;Xl;Kl;Yl;bc;Gl;px;vm;Tu;At;constructor(t){GSet.Yi(this),this.p=null,this.At=new List,this.St="",this.Wt=1,this.Sr=!1,this.Rl=!0,this.vl=!0,this.Ol=!0,this.Il=!0,this.El=!0,this.Ul=!0,this.Bl=!0,this.Vl=!0,this.zl=!0,this.Xl=!0,this.Kl=!0,this.Yl=!0,this.bc=!0,this.Gl=!0,this.px=!0,this.vm=!1,this.Tu=[],t&&Object.assign(this,t)}bF(){const t=this.At;for(let i=0;i0&&(h+=e+" Parts "),s>0&&(h+=s+" Nodes "),n>0&&(h+=n+" Groups "),o>0&&(h+=o+" Links "),r>0&&(h+=r+" Adornments "),t>1){const a=this.At.iterator;for(;a.next();){const c=a.value;h+=` - `+c.toString();const f=c.data;f!==null&&GSet.as(f)&&(h+=" #"+GSet.as(f)),c instanceof Node?h+=" "+Util.toString(f):c instanceof Link&&(h+=" "+Util.toString(c.fromNode)+" "+Util.toString(c.toNode))}}return i+" "+this.At.count+": "+h}findObjectAt(t,i,e){if(i===void 0&&(i=null),e===void 0&&(e=null),this.Gl===!1)return null;let s=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(s=!0);const n=Point.l(),o=this.At.r,r=o.length;for(let l=r;l--;){const h=o[l];if(s===!0&&h.Nl()===!1||!h.isVisible())continue;n.a(t),n.Ie(h.Es);let a=h.iL(n,i,e);if(a!==null&&(i!==null&&(a=i(a)),a!==null&&(e===null||e(a))))return Point.s(n),a}return Point.s(n),null}findObjectsAt(t,i,e,s){if(i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Gl===!1)return s;let n=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(n=!0);const o=Point.l(),r=this.At.r,l=r.length;for(let h=l;h--;){const a=r[h];if(n===!0&&a.Nl()===!1||!a.isVisible())continue;o.a(t),o.Ie(a.Es);let c=a;a.eL(o,i,e,s)&&(i!==null&&(c=i(c)),c!==null&&(e===null||e(c))&&s.add(c))}return Point.s(o),s}findObjectsIn(t,i,e,s,n){if(i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Gl===!1)return n;let o=!1;this.diagram!==null&&this.diagram.viewportBounds.containsRect(t)&&(o=!0);const r=this.At.r,l=r.length;for(let h=l;h--;){const a=r[h];if(o===!0&&a.Nl()===!1||!a.isVisible())continue;let c=a;a.Om(t,i,e,s,n)&&(i!==null&&(c=i(c)),c!==null&&(e===null||e(c))&&n.add(c))}return n}NP(t,i,e,s,n,o,r){if(this.Gl===!1)return n;const l=this.At.r,h=l.length;for(let a=h;a--;){const c=l[a];if(r===!0&&c.Nl()===!1||!o(c)||!c.isVisible())continue;let f=c;c.Om(t,i,e,s,n)&&(i!==null&&(f=i(f)),f!==null&&(e===null||e(f))&&n.add(f))}return n}findObjectsNear(t,i,e,s,n,o){if(e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Gl===!1)return o;let r=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(r=!0);const l=Point.l(),h=Point.l(),a=this.At.r,c=a.length;for(let f=c;f--;){const u=a[f];if(r===!0&&u.Nl()===!1||!u.isVisible())continue;l.a(t),l.Ie(u.Es),h.e(t.x+i,t.y),h.Ie(u.Es);let d=u;u.sL(l,h,e,s,n,o)&&(e!==null&&(d=e(d)),d!==null&&(s===null||s(d))&&o.add(d))}return Point.s(l),Point.s(h),o}EM(){return this.At.r}Us(t,i){if(!this.visible)return;const e=this.At.r,s=e.length;if(s===0)return;const n=Util.ot(),o=Util.ot();for(let r=0;r0&&o.push(l))}for(let r=0;re.Em||a.height*n>e.Em?i.Gi(t,e):this.SF(t,i),c&&(t.restore(),t.clearContextCache(!0))}SF(t,i){const e=i.actualBounds,s=i.naturalBounds;if(e.width===0||e.height===0||isNaN(e.x)||isNaN(e.y)||!i.isVisible())return;const n=i.D;if(i.background===null){i.dn(t,"rgba(0,0,0,0.3)",!0,!1,s,e),t.fillRect(e.x,e.y,e.width,e.height);return}if(t.transform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),i.dn(t,i.background,!0,!1,s,e),t.fillRect(0,0,s.width/2,s.height/2),!n.Ok()){const o=1/(n.m11*n.m22-n.m12*n.m21);t.transform(n.m22*o,-n.m12*o,-n.m21*o,n.m11*o,o*(n.m21*n.dy-n.m22*n.dx),o*(n.m12*n.dx-n.m11*n.dy))}}MF(t,i,e,s){const n=2/s,o=4/s;for(let r=0;r=s.count)t=s.count;else if(s.elt(t)===i)return-1;s.insertAt(t,i),i.Um(e);const n=this.diagram;return n!==null&&(e?n.C():n.Hh(i)),this.yx(t,i),t}_i(t,i,e){if(!e&&i.layer!==this&&i.layer!==null)return i.layer._i(t,i,e);const s=this.At;if(t<0||t>=s.length){if(t=s.indexOf(i),t<0)return-1}else if(s.elt(t)!==i&&(t=s.indexOf(i),t<0))return-1;i.Bm(e),s.removeAt(t);const n=this.diagram;return n!==null&&(e?n.C():n._i(i)),i.IM(null),t}yx(t,i){t=this.NF(t,i),i instanceof Group&&this.CF(t,i),i.svg!==null&&i.svg.remove()}NF(t,i){const e=i.zOrder;if(isNaN(e))return t;const s=this.At,n=s.count;if(n<=1)return t;if(t<0&&(t=s.indexOf(i)),t<0)return-1;let o=t-1,r=NaN;for(;o>=0&&(r=s.elt(o).zOrder,!!isNaN(r));)o--;let l=t+1,h=NaN;for(;le)for(;;){if(o===-1||r<=e)return o++,o===t?t:(s.removeAt(t),s.insertAt(o,i),o);for(r=NaN;--o>=0&&(r=s.elt(o).zOrder,!!isNaN(r)););}else if(!isNaN(h)&&h=e)return l--,l===t?t:(s.removeAt(t),s.insertAt(l,i),l);for(h=NaN;++l=0)||e<0&&r.containingGroup===i&&(e=o,t>=0))break}if(!(e<0)&&e1)&&Util._(t,"0 <= value <= 1",Layer,"opacity"),this.Wt=t;const e=this.diagram;e!==null&&e.C(),this.t("opacity",i,t)}}get isViewportAligned(){return this.vm}set isViewportAligned(t){const i=this.vm;i!==t&&(this.vm=t,this.diagram&&(this.oL(),this.diagram.C()),this.t("isViewportAligned",i,t),t&&(this.isInDocumentBounds=!1))}oL(){if(!this.vm)return;const t=this.diagram,i=this.At.r,e=i.length,s=t.kt,n=t.Pt;for(let o=0;o(w[w.None=1]="None",w[w.Uniform=2]="Uniform",w[w.UniformToFill=3]="UniformToFill",w))(AutoScale||{}),CycleMode=(w=>(w[w.All=1]="All",w[w.NotDirected=2]="NotDirected",w[w.NotDirectedFast=3]="NotDirectedFast",w[w.NotUndirected=4]="NotUndirected",w[w.DestinationTree=5]="DestinationTree",w[w.SourceTree=6]="SourceTree",w))(CycleMode||{}),ScrollMode=(w=>(w[w.Document=1]="Document",w[w.Infinite=2]="Infinite",w))(ScrollMode||{}),CollapsePolicy=(w=>(w[w.TreeParent=1]="TreeParent",w[w.AllParents=2]="AllParents",w[w.AnyParents=3]="AnyParents",w))(CollapsePolicy||{});class Diagram{ds;di;VM;wx;Nr;Ru;xx;bx;kx;Px;Mx;Sx;Dc;Gh;Nx;Cx;Lx;jl;Fc;Cr;Vm;Ax;Tx;vu;Hn;Lr;qh;Fo;zm;Rc;Xm;vc;Ou;Ar;qn;zM;XM;Dx;Fx;KM;Rx;YM;GM;jM;vx;Km;Tr;Dr;Fr;Rr;vr;Or;Ox;Ir;Ix;Er;Ur;Br;Vr;Ex;HM;Ro;qM;Ux;Bx;WM;Mi;JM;$M;ZM;vs;vo;Oi;Vx;Rl;vl;zx;Xx;Ol;Il;El;Kx;Ul;Bl;Vl;zl;Xl;Kl;Yl;Yx;Gx;QM;Iu;Eu;jx;Hx;qx;Wx;Ym;Jx;$x;Zx;$t;_M;Qx;tS;Uu;gn;Wn;te;Jn;rL;Hl;iS;eS;Gm;_x;Bu;jm;tb;zr;ql;Wh;sS;nS;Hm;ib;eb;ts;qm;Wm;Vu;Wl;Oc;Jm;Xr;Jh;oS;$m;Ht;D;Be;Pr;Ui;ps;rS;Jl;Kr;bl;Yr;$h;Ic;lS;zu;Zh;Xu;Gt;$l;ct;st;Ku;kt;Pt;dt;Ec;Uw;sb;Qh;Uc;nb;ob;rb;TF;DF;Bi;Pl;Em;Zm;hS;aS;lL;Qm;FF;RF;vF;lb;OF;IF;EF;_h;hL;Zl;ta;ia;ea;sa;wu;Kh;Zt;Tt;Bc;Wk;Jk;cc;Wt;static hb=null;static aL=new GMap;static cS;static fS=null;yu;ab;cb;fb;ub;db;_m;uS;t0;i0;e0;ex;dS;gb;Vc;constructor(t,i){if(Diagram.uw||(Diagram.Ik(),Diagram.uw=!0),GSet.Yi(this),Diagram.cL(this),this.Ht=!0,this.Tt=null,this.kt=0,this.Pt=0,this.dt=null,Diagram.isUsingDOM()){const s=this,n=()=>{s.Si(root.document,"DOMContentLoaded",n,!1),s.setRTL()};root.document.body!==null?this.setRTL():s.Vt(root.document,"DOMContentLoaded",n,!1)}this.Ec=null,Diagram.gS("Model",PartManager);const e=this;return this.JM=s=>e.partManager.doModelDataChanged(s),this.$M=s=>e.partManager.doModelChanged(s),this.nb=null,this.ob=null,this.fL(),this.model=Model.initDiagramModel(),this.gb=null,this.themeManager=new ThemeManager,this.Ro=!0,this.uL(),this.layout=new Layout,this.Ro=!1,this.FF=null,this.RF=null,this.vF=null,this.lb=null,this.OF=null,this.IF=null,this.EF=null,this._h=null,this.hL=null,this.Zl=null,this.ta=null,this.ia=null,this.ea=null,this.sa=null,this.wu=()=>{},this.Kh=null,this.Vu=!1,this.Bc=new DiagramHelper(this),t!==void 0&&(typeof t=="string"||root.Element&&t instanceof Element?this.mS(t):i=t),i&&this.setProperties(i),this.Ht=!1,this.requestUpdate(),this}qD(){return this.dt!==null}get renderer(){return this.Oc}set renderer(t){if(this instanceof Overview)return;t===""&&(t="default");const i=t.toLowerCase(),e=this.Oc;if(i===e)return;this.Oc=i;let s=null;i==="default"||i==="canvas"?(s=this.Wl.get("svg"),s!==null&&s.Ft.remove(),this.dt&&(this.Zt=this.dt.ai),this.Zt.clearContextCache(!0)):i==="svg"?(this.Wl.has("svg")?s=this.Wl.get("svg"):(s=new SVGSurface(this,root.document),this.addRenderer("svg",s)),this.div!==null&&this.div.appendChild(s.Ft),this.Zt=s.ai,this.dt&&(this.dt.ai.setTransform(this.Bi,0,0,this.Bi,0,0),this.dt.ai.clearRect(0,0,this.kt,this.Pt))):i==="debug"&&(this.Wl.has("SVG")||(s=new SVGSurface(this,root.document),this.addRenderer("SVG",s),s.Ft.style.backgroundColor="whitesmoke",this.div!==null&&this.div.after(s.Ft))),this.Ht||this.redraw()}fL(){this.Vc=new List,this.setupRouters(),this.ds=new AnimationManager,this.ds.To(this),this.di=17,this.VM=!1,this.Ku=!1,this.wx="default",this.Gt=new List,this.Wl=new GMap,this.Oc="default",this.resetRenderingHints(),this.UF(),this.Wt=1,this.ct=new Point(NaN,NaN).g(),this.ex=new Point(NaN,NaN),this.st=1,this.$m=1,this.xx=new Point(NaN,NaN).g(),this.bx=NaN,this.kx=1e-4,this.Px=100,this.D=new Transform,this.Mx=new Point(NaN,NaN).g(),this.Sx=new Rect(NaN,NaN,NaN,NaN).g(),this.Dc=new Margin(0,0,0,0).g(),this.Gh=1,this.Nx=!1,this.Cx=null,this.Lx=null,this.jl=1,this.Fc=Spot.Default,this.Cr=1,this.Vm=Spot.Default,this.Ax=Spot.None,this.Tx=Spot.None,this.Be=!0,this.vu=!1,this.Hn=new Set,this.Lr=new GSet,this.qh=new GSet,this.Fo=!1,this.$l=new GMap,this.zu=!0,this.zm=250,this.Rc=-1,this.Xm=new Margin(16,16,16,16).g(),this.Pr=!1,this.vc=!1,this.Ou=!0,this.Jm=new InputEvent,this.Jm.diagram=this,this.Xr=new InputEvent,this.Xr.diagram=this,this.Jh=new InputEvent,this.Jh.diagram=this,this.Ar=null,this.qn=null,this.Uw=!1,this.BF(),this.Yr=new GSet,this.Dx=!0,this.Fx=1,this.KM=!1,this.Rx=1,this.vx="auto",this.Km="auto",this.Tr=null,this.Dr=null,this.Fr=null,this.Rr=null,this.vr=null,this.Or=null,this.Ox=null,this.Ir=null,this.Ix=!1,this.Er=null,this.Ur=null,this.Br=null,this.Vr=null,this.Ex=!1,this.sb={},this.Qh=[null,null],this.Ro=!1,this.qM=!1,this.Ux=!1,this.Bx=!1,this.WM=!0,this.ps=!1,this.Zh=!1,this.ZM=!0,this.vs=-2,this.Jl=new GMap,this.Xu=new List,this.vo=!1,this.Oi=!0,this.Vx=!0,this.Rl=!0,this.vl=!0,this.zx=!1,this.Xx=!0,this.Ol=!0,this.Il=!0,this.El=!0,this.Kx=!0,this.Ul=!0,this.Bl=!0,this.Vl=!0,this.zl=!0,this.Xl=!0,this.Kl=!0,this.Yl=!0,this.Yx=!0,this.Gx=!0,this.QM=!1,this.Uc=!1,this.Iu=!0,this.Eu=!0,this.jx=!0,this.Hx=!0,this.qx=16,this.Wx=16,this.Ym=!1,this.Jx=!1,this.$x=0,this.Zx=0,this.$t=new Margin(5).g(),this._M=new GSet().g(),this.Qx=999999999,this.tS=new GSet().g(),this.$h=!0,this.Uu=!0,this.Ic=!0,this.gn=!1,this.Wn=!1,this.Kr=!0,this.bl=!1,this.Jn=!1,this.rL=new GSet,this.lS=new GSet,this.Hl=null,this.iS=new Size(8,8),this.eS=999,this.Gm=!1,this.Wk=1,this.Jk=0,this.Ui={scale:1,position:new Point,bounds:new Rect,canvasSize:new Size,newCanvasSize:new Size,isScroll:!1},this.Ui.canvasSize=this.Ui.canvasSize,this.Ui.newCanvasSize=this.Ui.newCanvasSize,this.Ui.isScroll=!1,this._x=new Rect(NaN,NaN,NaN,NaN).g(),this.Bu=new Size(NaN,NaN).g(),this.jm=new Rect(NaN,NaN,NaN,NaN).g(),this.tb=!1,this.VF(),this.ts=null,this.qm=!1,this.cc=null,this.partManager=new PartManager,this.toolManager=new ToolManager,this.toolManager.initializeStandardTools(),this.defaultTool=this.toolManager,this.currentTool=this.defaultTool,this.cb=null,this.fb=new DraggingOptions,this.ub=null,this.db=null,this.ab=!1,this.yu=!1,this.commandHandler=new CommandHandler,this.i0=null,this.e0=Point.Ak,this.dS=!1,this.Bi=1,this.Pl=null,this.Em=1,this._m=0,this.uS=[0,0,0,0,0],this.t0=0,this.Zm=1,this.hS=0,this.aS=new Point,this.lL=500,this.Wm=new Point,this.Qm=!1}static dL=root.document!==void 0;static isUsingDOM(){return Diagram.dL}static useDOM(t){Diagram.dL=t?root.document!==void 0:!1}static Ve=new WeakMap;clear(){this.animationManager.stopAnimation(),this.model.clear(),Diagram.gL(),this.mL(!1),this.Xu.clear(),this.pL(),this.Hl=null,this.invalidateDocumentBounds(),this.ensureBounds(),this.C()}mL(t){this.animationManager.stopAnimation(!0),this._M=new GSet().g(),this.tS=new GSet().g();const i=this.skipsUndoManager,e=this.Mi!==null&&this.Mi!==void 0;e&&(this.skipsUndoManager=!0);let s=null;this.ts!==null&&(s=this.ts.part,s!==null&&this.remove(s));const n=[],o=this.Gt.length;if(t){for(let r=0;rt?new Margin(t/2):1.5)),this.ib=this.Hm,this.eb=new Adornment(Panel.Link).add(new Shape({isPanelMain:!0,fill:null,stroke:"dodgerblue",strokeWidth:3}).theme("stroke","selection").theme("strokeWidth","selection"))}setRTL(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);const e=Util.en("div");e.dir="rtl",e.style.cssText="font-size: 14px; width: 1px; height: 1px; position: absolute; top: -1000px; overflow: scroll;",e.textContent="A",i.appendChild(e);let s="reverse";e.scrollLeft>0?s="default":(e.scrollLeft=1,e.scrollLeft===0&&(s="negative")),i.removeChild(e),this.wx=s}setScrollWidth(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);let e=0;if(Diagram.isUsingDOM()){let s=Diagram.fS,n=Diagram.cS;s===null&&(Diagram.fS=Util.en("p"),s=Diagram.fS,s.style.width="100%",s.style.height="200px",s.style.boxSizing="content-box",Diagram.cS=Util.en("div"),n=Diagram.cS,n.style.position="absolute",n.style.visibility="hidden",n.style.width="200px",n.style.height="150px",n.style.boxSizing="content-box",n.appendChild(s)),n.style.overflow="hidden",i.appendChild(n);const o=s.offsetWidth;n.style.overflow="scroll";let r=s.offsetWidth;o===r&&(r=n.clientWidth),i.removeChild(n),e=o-r,e===0&&!Util.rr&&(e=11)}this.di=e,this.VM=!0}ri(t){t in AutoScale?this.autoScale=t:Util.lr(this,t)}toString(t){t===void 0&&(t=0);let i="";this.div&&this.div.id&&(i=this.div.id);let e='Diagram "'+i+'"';if(t<=0)return e;const s=this.Gt.iterator;for(;s.next();){const n=s.value;e+=` - `+n.toString(t-1)}return e}static cL(t){Diagram.hb=t}static pm(){return Diagram.hb}static fromDiv(t){let i=t;if(typeof t=="string"&&(i=root.document.getElementById(t)),i instanceof HTMLDivElement){const e=Diagram.Ve.get(i);if(e)return e}return null}get div(){return this.Tt}set div(t){if(this.Tt!==t){const i=this.Tt;if(i!==null){if(Diagram.Ve.delete(i),i.goDiagram=void 0,i.go=void 0,i.innerHTML="",this.dt!==null){const s=this.dt.Ft;this.Si(s,"pointermove",this.ta,!1),this.Si(s,"pointerdown",this.Zl,!1),this.Si(s,"pointerup",this.ia,!1),this.Si(s,"pointerout",this.ea,!1),this.Si(s,"pointercancel",this.sa,!1),this.dt.dispose()}this.Ec&&(this.Ec.disconnect(),this.Ec=null);const e=this.toolManager;e!==null&&(e.mouseDownTools.each(s=>s.cancelWaitAfter()),e.mouseMoveTools.each(s=>s.cancelWaitAfter()),e.mouseUpTools.each(s=>s.cancelWaitAfter())),e.cancelWaitAfter(),this.currentTool.doCancel(),this.dt=null,this.Si(root,"resize",this.lb,!1),this.Si(root,"wheel",this._h,!0),Diagram.pm()===this&&Diagram.cL(null)}else this.Zl===null&&(this.Jn=!1);if(this.Tt=null,t!==null){const e=Diagram.Ve.get(t);e&&(e.div=null),this.mS(t),this.wu(),this.themeManager&&this.themeManager.zF()}else this.themeManager&&this.themeManager.XF()}}setupRouters(){this.Vc.push(new AvoidsNodesRouter)}mS(t){const i=this;if(!Diagram.isUsingDOM())return;t==null&&Util.o("Diagram setup requires an argument DIV."),i.Tt!==null&&Util.o("Diagram has already completed setup."),typeof t=="string"?i.Tt=root.document.getElementById(t):t instanceof HTMLDivElement?i.Tt=t:Util.o("No DIV or DIV id supplied: "+t),i.Tt===null&&Util.o("Invalid DIV id; could not get element with id: "+t);const e=Diagram.Ve.get(i.Tt);if(e&&e!==this&&Util.o("Invalid div id; div already has a Diagram associated with it."),!i.Ec&&root.ResizeObserver){const c=root.ResizeObserver,f=Util.Nk(()=>i.requestUpdate(),250,!1);i.Ec=new c(()=>f()),i.Ec.observe(i.Tt)}root.getComputedStyle(i.Tt,null).position==="static"&&(i.Tt.style.position="relative");let s=5;const n="rgba(2"+s+"5, 255, 255, 0)";s--,i.Tt.style["-webkit-tap-highlight-color"]=n,i.Tt.innerHTML="",Diagram.Ve.set(i.Tt,i),i.Tt.goDiagram=i,i.Tt.go=root.go;const o=new CanvasSurface(i);o.style!==void 0&&(o.style.position="absolute",o.style.top="0px",o.style.left="0px",root.getComputedStyle(i.Tt,null).getPropertyValue("direction")==="rtl"&&(i.Ku=!0),o.style.zIndex="2",o.style.userSelect="none",o.style.MozUserSelect="none",o.style.touchAction="none",o.style.letterSpacing="normal !important",o.style.wordSpacing="normal !important",o.style.lang="unknown"),i.dt=o,i.Zt=o.ai;const r=i.Zt;i.Bi=i.computePixelRatio(),i.viewSize.isReal()||(i.kt=i.Tt.clientWidth||1,i.Pt=i.Tt.clientHeight||1),i.yL(i.kt,i.Pt);const l=i;i.Tt.insertBefore(o.Ft,i.Tt.firstChild);const h=new CanvasSurface(null);if(h.width=1,h.height=1,i.TF=h,i.DF=h.ai,Diagram.isUsingDOM()){const c=Util.en("div"),f=Util.en("div");c.style.position="absolute",c.style.overflow="auto",c.style.width=i.kt+"px",c.style.height=i.Pt+"px",c.style.zIndex="1",f.style.position="absolute",f.style.width="1px",f.style.height="1px",i.Tt.appendChild(c),c.appendChild(f),c.onscroll=Diagram.KF,c.addEventListener("pointerdown",Diagram.YF),c.p=i,c.GF=!0,c.jF=!0,i.nb=c,i.ob=f}i.wu=Util.Nk(()=>{i.Pl=null,i.C()},300,!1),i.lb=Util.Nk(()=>{i.SM()},250,!1),i.Kh=c=>(c.preventDefault(),!1),i._h=c=>{if(!l.isEnabled)return;const f=l.zc(c,!0);f.bubbles=!0;let u=0,d=0;f.delta=0,c.deltaX!==void 0?(c.deltaX!==0&&(u=c.deltaX>0?1:-1),c.deltaY!==0&&(d=c.deltaY>0?1:-1),f.delta=Math.abs(c.deltaX)>Math.abs(c.deltaY)?-u:-d):c.wheelDeltaX!==void 0?(c.wheelDeltaX!==0&&(u=c.wheelDeltaX>0?-1:1),c.wheelDeltaY!==0&&(d=c.wheelDeltaY>0?-1:1),f.delta=Math.abs(c.wheelDeltaX)>Math.abs(c.wheelDeltaY)?-u:-d):c.wheelDelta!==void 0&&c.wheelDelta!==0&&(f.delta=c.wheelDelta>0?1:-1),l.doMouseWheel(),l.na(f,c)},i.hL=c=>{if(!l.isEnabled)return;i.Uc=!1,l.zc(c,!0);const f=l.currentTool;f.cancelWaitAfter(),f.standardMouseOver()},i.Zl=c=>{if(!l.isEnabled)return;i.Uc=!0;const f=l.sb;f[c.pointerId]===void 0&&(f[c.pointerId]=c);const u=l.Qh;let d=!1;if(u[0]!==null&&(u[0].pointerId===c.pointerId||u[0].pointerType!==c.pointerType))u[0]=c;else if(u[1]!==null&&u[1].pointerId===c.pointerId)u[1]=c,d=!0;else if(u[0]===null)u[0]=c;else if(u[1]===null)u[1]=c,d=!0;else{c.preventDefault();return}const m=c.pointerType==="touch"||c.pointerType==="pen";m&&(l.Uw=!1,l.Qm=!0);const g=l.HF(c,c,d),p=l.aS,y=m?25:10;if(c.timeStamp-l.hSy||Math.abs(p.y-c.screenY)>y)?l.Zm++:l.Zm=1,g.clickCount=l.Zm,l.hS=c.timeStamp,l.aS.setTo(c.screenX,c.screenY),l.doMouseDown(),c.button===1){c.preventDefault();return}l.na(g,c)},i.ta=c=>{if(!l.isEnabled)return;i.Uc=!0;const f=l.Qh;if(f[0]!==null&&(f[0].pointerId===c.pointerId||f[0].pointerType!==c.pointerType))f[0]=c;else if(f[1]!==null&&f[1].pointerId===c.pointerId){f[1]=c;return}else if(f[0]===null)f[0]=c;else return;if(f[0].pointerId!==c.pointerId)return;const u=l.qF(c,c,f[1]!==null);l.doMouseMove(),l.na(u,c)},i.ia=c=>{if(!l.isEnabled)return;i.Uc=!0;const f=c.pointerType==="touch"||c.pointerType==="pen",u=l.sb;if(f&&l.Uw){delete u[c.pointerId],c.preventDefault();return}const d=l.Qh;if(d[0]!==null&&(d[0].pointerId===c.pointerId||d[0].pointerType!==c.pointerType))d[0]=null;else if(d[1]!==null&&d[1].pointerId===c.pointerId){d[1]=null;return}else return;const m=l.pS(c,!1,!0,!1,!0,!1);let g=root.document.elementFromPoint(c.clientX,c.clientY)||null;g!==null&&g.shadowRoot!==void 0&&g.shadowRoot!==null&&(g=g.shadowRoot.elementFromPoint(c.clientX,c.clientY)),g!==null&&g.p instanceof Diagram&&g.p!==l&&g.p.o0(c,m),g===null&&(g=c.target),l.o0(c,m),m.clickCount=l.Zm,m.targetDiagram=l.yS(c,g),m.targetObject=null,l.doMouseUp(),l.na(m,c),f&&(l.Qm=!1)},i.ea=c=>{if(!l.isEnabled)return;i.Uc=!1;const f=l.sb;f[c.pointerId]&&delete f[c.pointerId];const u=l.Qh;if(u[0]!==null&&u[0].pointerId===c.pointerId&&(u[0]=null),u[1]!==null&&u[1].pointerId===c.pointerId&&(u[1]=null),c.pointerType==="touch"||c.pointerType==="pen")return;const d=l.currentTool;d.cancelWaitAfter(),d.standardMouseOver()},i.sa=c=>{const f=l.Qh;f[0]!==null&&f[0].pointerId===c.pointerId?(f[0]=null,l.Qm=!1):f[1]!==null&&f[1].pointerId===c.pointerId&&(f[1]=null)};const a=r;if(i.rb=a.B[Util.Cs("7eba17a4ca3b1a8346")][Util.Cs("78a118b7")](a.B,Diagram.Yu,s,s),r.clearContextCache(!0),i.WF(),this.Oc==="svg"){const c=this.Wl.get("svg");this.Tt.appendChild(c.Ft),this.Zt=c.ai}}addEventListener(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}Vt(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}removeEventListener(t,i,e,s){t.removeEventListener(i,e,{capture:s})}Si(t,i,e,s){t.removeEventListener(i,e,{capture:s})}WF(){const t=this;let i=this.dt.Ft;i instanceof HTMLCanvasElement||(i=t.div),this.Vt(i,"pointerdown",t.Zl,!1),this.Vt(i,"pointermove",t.ta,!1),this.Vt(i,"pointerup",t.ia,!1),this.Vt(i,"pointerout",t.ea,!1),this.Vt(i,"pointercancel",t.sa,!1),this.Vt(i,"pointerenter",t.JF,!1),this.Vt(i,"pointerleave",t.$F,!1),this.Vt(i,"wheel",t._h,!1),this.Vt(i,"keydown",t.ZF,!1),this.Vt(i,"keyup",t.QF,!1),this.Vt(i,"blur",t._F,!1),this.Vt(i,"focus",t.tR,!1),this.Vt(i,"selectstart",e=>(e.preventDefault(),!1),!1),this.Vt(i,"contextmenu",e=>(e.preventDefault(),!1),!1),this.Vt(root,"resize",t.lb,!1)}Bw(){this._m>30&&(this.Pl=1)}yP(t){this.Pl!==null&&(this.Pl=null,t&&this.wu(),this._m=0,this.uS=[0,0,0,0,0],this.t0=0)}computePixelRatio(){return this.Pl!==null?this.Pl:root.devicePixelRatio||1}get avgSpf(){return this._m}doMouseDown(){this.currentTool.doMouseDown()}doMouseMove(){this.currentTool.doMouseMove()}doMouseUp(){this.currentTool.doMouseUp()}doMouseWheel(){this.currentTool.doMouseWheel()}doKeyDown(){this.currentTool.doKeyDown()}doKeyUp(){this.currentTool.doKeyUp()}doFocus(){this.focus()}focus(){if(this.dt)if(this.scrollsPageOnFocus)this.dt.focus();else{const t=root.scrollX,i=root.scrollY;this.dt.focus(),root.scrollTo(t,i)}}tR(t){const i=Diagram.Ve.get(this);i&&i.v("GainedFocus")}_F(t){const i=Diagram.Ve.get(this);i&&i.v("LostFocus")}SM(){if(this.dt===null)return;const i=this.Tt;if(i===null||i.clientWidth===0||i.clientHeight===0)return;this.VM||this.setScrollWidth();const e=this.Wn?this.di:0,s=this.gn?this.di:0,n=this.Bi;if(this.Bi=this.computePixelRatio(),this.Bi!==n&&(this.vu=!0,this.requestUpdate()),i.clientWidth!==this.kt+e||i.clientHeight!==this.Pt+s){this.oa(),this.Be=!0;const o=this.layout;o!==null&&o.isViewportSized&&this.autoScale===1&&(this.vc=!0,o.invalidateLayout()),this.ps||this.requestUpdate()}}uL(){let t=0,i=new Layer;i.name="Grid",i.allowSelect=!1,i.pickable=!1,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="ViewportBackground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="Background",this.Gr(i,t++),i=new Layer,i.name="",this.Gr(i,t++),i=new Layer,i.name="Foreground",this.Gr(i,t++),i=new Layer,i.name="ViewportForeground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="Adornment",i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="Tool",i.isTemporary=!0,i.isInDocumentBounds=!0,this.Gr(i,t++)}wL(){const t=new Panel(Panel.Grid,{name:"GRID"}).add(new Shape("LineH",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineV",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineH",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineH",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor")),i=new Part({layerName:"Grid",zOrder:0,isInDocumentBounds:!1,isAnimated:!1,pickable:!1,locationObjectName:"GRID"}).add(t);return this.add(i),this.partManager.parts.delete(i),t.visible=!1,t}static KF(){const t=Diagram.Ve.get(this.parentElement||this);if(t){if(t.Jx){t.Jx=!1;return}if(!t.isEnabled){t.xL();return}t.diagramScroll(this)}}static YF(t){if(!this.p.isEnabled){this.p.updateScroll();return}this.p.$x=t.target.scrollTop,this.p.Zx=t.target.scrollLeft}diagramScroll(t){if(this.dt===null)return;const i=this.nb,e=this.ob;this.Ym=!0;let s=this.documentBounds,n=this.viewportBounds;const o=this.Dc;let r=s.x-o.left,l=s.y-o.top;const h=s.width+o.left+o.right,a=s.height+o.top+o.bottom;let c=s.right+o.right,f=s.bottom+o.bottom,u=n.x,d=n.y;const m=n.width,g=n.height;let p=n.right,y=n.bottom;const x=this.scale;let k,b=t.scrollLeft;if(this.Ku)switch(this.wx){case"negative":b=b+t.scrollWidth-t.clientWidth;break;case"reverse":b=t.scrollWidth-b-t.clientWidth;break}const P=b;if(mp)){const M=i.scrollWidth-this.kt;this.position=k.e(-M+P-this.kt/x+c,this.position.y)}if(t.jF&&this.allowVerticalScroll&&(ly)){const M=i.scrollHeight-this.Pt;this.position=k.e(this.position.x,-M+t.scrollTop-this.Pt/x+f)}Point.s(k),this._l(),this.Ym=!1,this.Uu=!1,s=this.documentBounds,n=this.viewportBounds,c=s.right,p=n.right,f=s.bottom,y=n.bottom,r=s.x,u=n.x,l=s.y,d=n.y,m>=h&&r>=u&&c<=p&&(e.style.width="1px"),g>=a&&l>=d&&f<=y&&(e.style.height="1px")}computeBounds(t){return t===void 0&&(t=new Rect),this.Ci(),this.bL(t)}bL(t){if(this.fixedBounds.isReal())return t.a(this.fixedBounds),t.addMargin(this.$t),t;let i=!0;const e=this.Gt.r,s=e.length;for(let n=0;ni&&(a=i),athis.maxScale&&(a=this.maxScale),a):t===3?(a=0,h>l?a=(r-this.di)/n:a=(o-this.di)/s,a>i&&(a=i),athis.maxScale&&(a=this.maxScale),a):this.scale}zoomToFit(){const t=this.Gh;this.Gh=1,this.scale=this.Gu(2),t!==1&&(this.Bs(!1),this.wS(this.documentBounds,this.kt/this.st,this.Pt/this.st,this.Fc,!1)),this.Gh=t}zoomToRect(t,i){i===void 0&&(i=2);const e=t.width,s=t.height;if(e===0||s===0||isNaN(e)&&isNaN(s))return;let n=1;if(i===2||i===3)if(isNaN(e))n=this.viewportBounds.height*this.scale/s;else if(isNaN(s))n=this.viewportBounds.width*this.scale/e;else{const o=this.kt,r=this.Pt;i===3?r/s>o/e?n=(r-(this.gn?this.di:0))/s:n=(o-(this.Wn?this.di:0))/e:n=Math.min(r/s,o/e)}this.scale=n,this.position=new Point(t.x,t.y)}get iR(){return this.Ht}set iR(t){this.Ht=t}alignDocument(t,i){this.ensureBounds();const e=this.documentBounds,s=this.viewportBounds;this.position=new Point(e.x+(t.x*e.width+t.offsetX)-(i.x*s.width-i.offsetX),e.y+(t.y*e.height+t.offsetY)-(i.y*s.height-i.offsetY))}focusObject(t){if(t instanceof GraphObject){this.i0=t;const i=Point.l();this.e0=this.transformDocToView(t.getDocumentPoint(Spot.TopLeft,i)),Point.s(i)}else this.i0=null,this.e0=Point.Ak}wS(t,i,e,s,n){const o=Point.X(this.ct.x,this.ct.y);let r=o.x,l=o.y;if(this.i0!==null){let h=Point.l();h=this.i0.getDocumentPoint(Spot.TopLeft,h),r=h.x-this.e0.x/this.scale,l=h.y-this.e0.y/this.scale,s=Spot.None,Point.s(h)}if(n||this.scrollMode===1){s.isSpot()&&(i>t.width&&(r=t.x+(s.x*t.width+s.offsetX)-(s.x*i-s.offsetX)),e>t.height&&(l=t.y+(s.y*t.height+s.offsetY)-(s.y*e-s.offsetY)));const h=this.Dc,a=i-t.width;if(it.left?r=t.left:rt.top?l=t.top:ls.part,s=>s.canSelect());if(e instanceof Part)return e}else{const e=this.PP(t,s=>s.part);if(e instanceof Part)return e}return null}findObjectAt(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Ci();const s=this.Gt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}PP(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Ci();const s=this.Gt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible||n.isTemporary)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}findPartsAt(t,i,e){return i===void 0&&(i=!0),this.sR(t,s=>s.part,i?s=>s instanceof Part&&s.canSelect():null,e)}sR(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Ci();const n=this.Gt.iteratorBackwards;for(;n.next();){const o=n.value;!o.visible||o.isTemporary||o.findObjectsAt(t,i,e,s)}return s}findObjectsAt(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Ci();const n=this.Gt.iteratorBackwards;for(;n.next();){const o=n.value;o.visible&&o.findObjectsAt(t,i,e,s)}return s}findPartsIn(t,i,e,s){return i===void 0&&(i=!1),e===void 0&&(e=!0),this.nR(t,null,n=>n instanceof Part&&(!e||n.canSelect()),i,s)}findObjectsIn(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Ci();const o=this.Gt.iteratorBackwards;for(;o.next();){const r=o.value;r.visible&&r.findObjectsIn(t,i,e,s,n)}return n}NP(t,i,e,s,n,o){const r=new GSet;this.Ci();const l=this.Gt.iteratorBackwards;for(;l.next();){const h=l.value;h.visible&&h.NP(t,i,e,s,r,n,o)}return r}nR(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Ci();const o=this.Gt.iteratorBackwards;for(;o.next();){const r=o.value;!r.visible||r.isTemporary||r.findObjectsIn(t,i,e,s,n)}return n}findPartsNear(t,i,e,s,n){return e===void 0&&(e=!0),s===void 0&&(s=!0),this.oR(t,i,null,o=>o instanceof Part&&(!s||o.canSelect()),e,n)}findObjectsNear(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Ci();const r=this.Gt.iteratorBackwards;for(;r.next();){const l=r.value;l.visible&&l.findObjectsNear(t,i,e,s,n,o)}return o}oR(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Ci();const r=this.Gt.iteratorBackwards;for(;r.next();){const l=r.value;!l.visible||l.isTemporary||l.findObjectsNear(t,i,e,s,n,o)}return o}acceptEvent(t){return this.zc(t,t instanceof MouseEvent)}zc(t,i){const e=this.Xr;this.Xr=this.Jh,this.Jh=e,e.diagram=this,e.event=t,i?this.o0(t,e):(e.viewPoint=this.Xr.viewPoint,e.documentPoint=this.Xr.documentPoint);let s=0;const n=t;return n.ctrlKey&&(s+=1),n.altKey&&(s+=2),n.shiftKey&&(s+=4),n.metaKey&&(s+=8),e.modifiers=s,e.button=n.button,n.buttons!==void 0&&(e.buttons=n.buttons),Util.rr&&n.button===0&&n.ctrlKey&&(e.button=2),e.down=!1,e.up=!1,e.clickCount=1,e.delta=0,e.handled=!1,e.bubbles=!1,e.timestamp=t.timeStamp,e.isMultiTouch=!1,e.targetDiagram=this.yS(t,t.target),e.targetObject=null,e}yS(t,i){if(i===null)return null;const e=Diagram.Ve.get(i);if(e)return e;let s=t.path;if(!s&&typeof t.composedPath=="function"&&(s=t.composedPath()),s&&s[0]){const n=Diagram.Ve.get(s[0]);if(n)return n}return null}HF(t,i,e){const s=this.pS(t,!0,!1,!1,!0,e);return this.o0(i,s),s.targetDiagram=this.yS(t,t.target),s.targetObject=null,e||s.clone(this.Jm),s}qF(t,i,e){const s=this.pS(t,!1,!1,!1,!1,e);let n=root.document.elementFromPoint(i.clientX,i.clientY)||null;n!==null&&n.shadowRoot!==void 0&&n.shadowRoot!==null&&(n=n.shadowRoot.elementFromPoint(i.clientX,i.clientY));let o=this,r=t;if(n){const l=Diagram.Ve.get(n);l&&(r=i,o=l)}return s.targetDiagram=o,this.o0(r,s),s.targetObject=null,s}pS(t,i,e,s,n,o){const r=this.Xr;this.Xr=this.Jh,this.Jh=r,r.diagram=this,r.clickCount=1,r.delta=0;let l=0;return t.ctrlKey&&(l+=1),t.altKey&&(l+=2),t.shiftKey&&(l+=4),t.metaKey&&(l+=8),r.modifiers=l,r.event=t,r.timestamp=t.timeStamp,r.button=e?this.firstInput.button:t.button,r.buttons=t.buttons,Util.rr&&t.button===0&&t.ctrlKey&&(r.button=2),r.down=i,r.up=e,r.handled=s,r.bubbles=n,r.isMultiTouch=o,r}na(t,i){return t.bubbles?!0:(i.stopPropagation!==void 0&&i.stopPropagation(),i.cancelable!==!1&&i.preventDefault(),i.cancelBubble=!0,!1)}ZF(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.zc(t,!1);return e.key=t.key,e.code=t.code,e.down=!0,i.doKeyDown(),i.na(e,t)}QF(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.zc(t,!1);return e.key=t.key,e.code=t.code,e.up=!0,i.doKeyUp(),i.na(e,t)}JF(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.zc(t,!0);return i.mouseEnter!==null&&i.mouseEnter(e),i.currentTool.standardMouseOver(),i.na(e,t)}$F(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.zc(t,!0);return i.mouseLeave!==null&&i.mouseLeave(e),i.na(e,t)}getMouse(t){const i=this.dt;if(i===null)return new Point(0,0);const e=i.getBoundingClientRect(),s=(t.clientX-e.left)*(this.kt/e.width),n=(t.clientY-e.top)*(this.Pt/e.height);return new Point(s,n).Ie(this.D)}o0(t,i){const e=this.dt;let s=0,n=0;if(e!==null){const r=e.getBoundingClientRect();s=(t.clientX-r.left)*(this.kt/r.width),n=(t.clientY-r.top)*(this.Pt/r.height)}i.viewPoint.e(s,n);const o=Point.X(s,n);this.D._e(o),i.documentPoint.a(o),Point.s(o)}MC(t,i,e){let s;if(this.Qh[0]!==null)s=this.Qh[i];else return;const n=this.dt;if(n!==null){const o=n.getBoundingClientRect();e.e((s.clientX-o.left)*(this.kt/o.width),(s.clientY-o.top)*(this.Pt/o.height))}}invalidateDocumentBounds(){this.$h||(this.$h=!0,this.requestUpdate(!1))}rR(){this.ps||this.Ci(),this.ensureBounds()}redraw(){this.Ht||this.ps||(this.C(),this.maybeUpdate())}isUpdateRequested(){return this.Pr}delayInitialization(t){t===void 0&&(t=null);const i=this.animationManager,e=i.isEnabled;i.stopAnimation(),i.isEnabled=!1,this.yr(),this.Jn=!1,this.ex=new Point(NaN,NaN),i.isEnabled=e,this.ps=!0;const s=this;t!==null&&Util.vh(()=>{s.ps=!1,i.Fl("Model"),t(s)},1)}requestUpdate(t){if(t===void 0&&(t=!1),this.Pr===!0||this.Ht||t===!1&&this.ps)return;this.Pr=!0;const i=this;root.requestAnimationFrame(()=>{i.Pr&&i.maybeUpdate()})}maybeUpdate(){this.Ou&&!this.Pr||(this.Ou&&(this.Ou=!1),this.yr())}xS(t,i){!this.Uu||this.Ht||this.animationManager.defaultAnimation.isAnimating||this.xL()||(t&&this.Ci(),i&&this.Bs(!1))}yr(t){if(this.ps||(this.Pr=!1,this.Tt===null&&!this.Bu.isReal()))return;this.ps=!0;const i=this.animationManager,e=this.Xu;if(!i.isAnimating&&e.length!==0){const c=e.r,f=c.length;for(let u=0;u0&&(s.each(c=>c.bS()),s.clear());let n=!1,o=!1;i.defaultAnimation.isAnimating&&(o=!0,n=this.skipsUndoManager,this.skipsUndoManager=!0),i.wi||this.SM(),t||this.xS(!1,!0);const r=!this.undoManager.isUndoingRedoing&&(this.bl||this.Vc.count!==0&&this.Lr.size!==0),l=!this.Jn||this.Kr;this.Ci(!0);let h=!1;(l||r)&&(this.Jn?this.kS(!this.vc,r):(this.startTransaction("Initial Layout"),i.isEnabled===!1&&i.stopAnimation(),this.kS(!1,r)),h=l),this.vc=!1,this.bl=!1,this.Ci(),this.ts!==null&&(this.ts.visible&&!this.qm&&(this.jr(),this.qm=!0),!this.ts.visible&&this.qm&&(this.qm=!1)),this.Ux||this.rR(),t||this.xS(!0,!1);let a=!1;if(h){const c=Rect.l();c.a(this.viewportBounds),this.Jn||(this.Jn=!0,a=!0,this.skipsUndoManager||(this.undoManager.Ow=!0),this.undoManager.Iw=!0,this.lR()),this.hR(),this.Ci(!1),t||this.xS(!0,!0),Rect.s(c)}else if(i.Pc&&i.ix){if(this.Cr!==1)this.scale=this.Gu(this.Cr);else if(this.jl!==1)this.scale=this.Gu(this.jl);else{const c=this.initialScale;isFinite(c)&&c>0&&(this.scale=c)}this.Bs(!0)}h&&a&&this.commitTransaction("Initial Layout"),t||this.Gi(this.Zt),o&&(this.skipsUndoManager=n),this.ps=!1}get Eh(){return this.Jn}lR(){if(this.Cr!==1)this.scale=this.Gu(this.Cr);else if(this.jl!==1)this.scale=this.Gu(this.jl);else{const i=this.initialScale;isFinite(i)&&i>0&&(this.scale=i)}this.Bs(!0);const t=this.Gt.r;this.Us(t,t.length,this,this.viewportBounds),this.v("InitialLayoutCompleted"),this.ex.a(this.ct),this.jr()}hR(){this.v("LayoutCompleted")}r0(t){this.Hn.add(t)}addInvalidRoute(t){this.Fo?this.qh.add(t):this.Lr.add(t)}Ci(t){if(this.Hn.size!==0&&!(!this.ps&&this.animationManager.isTicking)){if(this.ps||(this.bl=!0),t){this.kL(this.Hn);return}for(let i=0;i<23&&this.Hn.size!==0;i++){const e=new Set(this.Hn);this.Hn.clear(),this.bS(e,this.Hn)}this.nodes.each(i=>{i instanceof Group&&i.PL(!1)})}}kL(t,i){for(const e of t)!e.Pe()||e instanceof Group||(e.Hr()?(e.ut(1/0,1/0),e.zt()):i&&i.add(e));for(const e of t)if(e instanceof Group){if(!e.isVisible())continue;this.yb(e)}}bS(t,i){this.kL(t,i);for(const e of t){if(!(e instanceof Link))continue;const s=e;s.isVisible()&&(s.Hr()?(s.ut(1/0,1/0),s.zt()):i.add(s))}for(const e of t)e instanceof Adornment&&e.isVisible()&&(e.Hr()?(e.ut(1/0,1/0),e.zt()):i.add(e))}l0(t){const i=t instanceof Diagram,e=i?t.links:t.memberParts,s=this.Hn;if(i)this.Ci(!0);else{for(;e.next();){const n=e.value;s.has(n)&&(!n.Pe()||n instanceof Group||n.Hr()&&(n.ut(1/0,1/0),n.zt()))}for(e.reset();e.next();){const n=e.value;if(s.has(n)&&n instanceof Group){if(!n.isVisible())continue;this.yb(n)}}e.reset()}for(;e.next();){const n=e.value;n instanceof Link&&s.has(n)&&n.isVisible()&&n.Hr()&&(n.ut(1/0,1/0),n.zt())}}yb(t){const i=Util.ot(),e=Util.ot(),s=t.memberParts;for(;s.next();){const o=s.value;o.isVisible()&&(o instanceof Group?(o.Oo()||o.is()||o.th())&&this.yb(o):o instanceof Link?o.fromNode===t||o.toNode===t?e.push(o):i.push(o):(o.ut(1/0,1/0),o.zt()))}let n=i.length;for(let o=0;ob.Fu())}else for(let x=0;x0){const a=n.substring(0,h);e?o=t.findObject(a):(o=t[a],o==null&&(o=t.toolManager[a])),Util.wt(o)?r=n.substring(h+1):Util.o("Unable to find object named: "+a+" in "+t.toString()+" when trying to set property: "+n)}}if(r[0]!=="_"&&!Util.fw(o,r))if(s&&r==="ModelChanged"){t.addModelChangedListener(i[r]);continue}else if(s&&r==="Changed"){t.addChangedListener(i[r]);continue}else if(s&&Util.fw(t.toolManager,r))o=t.toolManager;else if(s&&t.ML(r)){t.addDiagramListener(r,i[r]);continue}else if(t instanceof Model&&r==="Changed"){t.addChangedListener(i[r]);continue}else Util.o('Trying to set undefined property "'+r+'" on object: '+o.toString());const l=i[n];o[r]=l,r[0]==="_"&&o instanceof GraphObject&&o.addCopyProperty(r)}}fR(){if(this.$l.count!==0&&!(this.undoManager.transactionLevel>1)){for(;this.$l.count>0;){const t=this.$l;this.$l=new GMap;const i=t.iterator;for(;i.next();){const e=i.key;e.invalidateOtherJumpOvers(i.value),e.ie()}}this.C()}}C(t){if(t===void 0)this.Be=!0,this.requestUpdate();else{const i=this.viewportBounds;t.isReal()&&i.intersectsRect(t)&&(this.Be=!0,this.requestUpdate())}this.v("InvalidateDraw")}invalidateViewport(t,i){if(this.Be===!0)return;if(this.Be=!0,this.Oc==="svg"){this.maybeUpdate();return}this.getRenderingHint("temporaryPixelRatio")===!0?(this.Bw(),this.maybeUpdate(),this.yP(!0)):this.maybeUpdate()}oa(){this.Uu=!0}_l(){this.Ic=!0}h0(){this.vu!==!1&&(this.vu=!1,this.yL(this.kt,this.Pt))}yL(t,i){this.Ql();const e=this.Bi,s=t*e,n=i*e;this.dt.resize(s,n,t,i)&&(this.Be=!0,this.Zt.clearContextCache(!0))}xL(){const t=this.dt;if(t===null||this.Bu.isReal())return!0;const i=this.kt,e=this.Pt,s=this.Tt;let n=!1,o=this.Wn?this.di:0,r=this.gn?this.di:0,l=s.clientWidth||i+o,h=s.clientHeight||e+r;const a=this.viewportBounds,c=a.x,f=a.y,u=a.width,d=a.height;if((l!==i+o||h!==e+r)&&(this.Wn=!1,this.gn=!1,o=0,r=0,this.kt=l,this.Pt=h,this.vu=!0,n=!0,this.Ql()),!this.Jn||!this.viewportBounds.isReal())return!0;const m=this.nb,g=this.ob;if(this.Uu=!1,!n&&!this.Wn&&!this.gn&&!this.Iu&&!this.Eu)return!0;const p=this.documentBounds;let y=0,x=0,k=0,b=0;const P=a.width,M=a.height,L=this.Dc;this.contentAlignment.isSpot()?(p.width>P&&(y=L.left,x=L.right),p.height>M&&(k=L.top,b=L.bottom)):(y=L.left,x=L.right,k=L.top,b=L.bottom);const C=p.width+y+x,S=p.height+k+b,N=this.scale,T=N;let A=C>l/N,D=S>h/N;if(!n&&!this.Wn&&!this.gn&&!A&&!D)return!0;const F=p.x-y,R=a.x,v=p.right+x;let O=a.right+o;const U=p.y-k,X=a.y,E=p.bottom+b;let V=a.bottom+r,B="1px",Y="1px";if(this.scrollMode===1&&(A||D)){if(A&&this.hasHorizontalScrollbar&&this.allowHorizontalScroll){let z=1;F+1O+1&&(z=Math.max((v-O)*N+this.kt,z)),P+o+1V+1&&(z=Math.max((E-V)*N+this.Pt,z)),M+r+1O+1&&(W=Math.max((v-O)*N+this.kt,W)),P+1V+1&&(W=Math.max((E-V)*N+z,W)),M+1O+1&&(J=this.position.x*N)),this.Ku)switch(this.wx){case"negative":J=-(m.scrollWidth-J-m.clientWidth);break;case"reverse":J=m.scrollWidth-J-m.clientWidth;break}if(m.scrollLeft=J,this.hasVerticalScrollbar&&this.allowVerticalScroll&&(M+1V+1&&(m.scrollTop=this.position.y*N)),l=this.kt,h=this.Pt,m.style.width=l+(this.Wn?this.di:0)+"px",m.style.height=h+(this.gn?this.di:0)+"px",i!==l||e!==h||this.animationManager.wi){const z=Rect.X(c,f,u,d);return this.onViewportBoundsChanged(z,this.viewportBounds,T,n),Rect.s(z),!1}return!0}add(t){const i=t.diagram;if(i===this)return;i!==null&&Util.o("Cannot add part "+t.toString()+" to "+this.toString()+". It is already a part of "+i.toString());let e=this.findLayer(t.layerName);if(e===null&&(e=this.findLayer("")),e===null&&Util.o('Cannot add a Part when unable find a Layer named "'+t.layerName+'" and there is no default Layer'),t.layer===e)return;const s=e.Hh(99999999,t,t.diagram===this);s>=0&&this.raiseChangedEvent(3,"parts",e,null,t,null,s),e.isTemporary||this.invalidateDocumentBounds(),t.invalidateLayout(1);const n=t.layerChanged;n!==null&&n(t,null,e)}Hh(t){this.partManager.Hh(t);const i=this;t.qr(s=>i.SL(s)),t.data||t.Io(),t.hasPlaceholder()&&t.c(),t.data!==null&&t.qr(s=>i.partManager.MS(s,null)),(t.is()===!0||t.th()===!0)&&this.r0(t),t.NL(!0,this),t.CL()?(t.actualBounds.isReal()&&this.C(t.jh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.C(t.jh(t.actualBounds)),this.requestUpdate()}_i(t){t.clearAdornments(),this.partManager._i(t);const i=this;t.data!==null&&t.qr(s=>i.partManager.SS(s,i)),this.Hn.delete(t),t instanceof Link&&this.Lr.delete(t),t.CL()?(t.actualBounds.isReal()&&this.C(t.jh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.C(t.jh(t.actualBounds)),this.requestUpdate()}remove(t){this.NS(t,!0)}NS(t,i){const e=t.layer;if(e===null||e.diagram!==this)return;t.isSelected=!1,t.isHighlighted=!1,t.invalidateLayout(2),i&&t.Xc();const s=e._i(-1,t,!1);s>=0&&this.raiseChangedEvent(4,"parts",e,t,null,s,null);const n=t.layerChanged;n!==null&&n(t,e,null)}removeParts(t,i){if(i===void 0&&(i=!1),Array.isArray(t)){const e=t.length;for(let s=0;s=0&&i.elt(e).isTemporary;)e--;return i.insertAt(e+1,t),this.Mi!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,e+1),this.C(),this.invalidateDocumentBounds(),this}addLayerBefore(t,i){this.CS(t,i),t.To(this);const e=this.Gt,s=e.indexOf(t);s>=0&&(e.delete(t),this.Mi!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;o=0&&(e.delete(t),this.Mi!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;othis.maxScale&&(i=this.maxScale);const c=Point.X(this.ct.x+l/t-l/i,this.ct.y+h/t-h/i);this.position=c,Point.s(c),this.st=i,this.Ql(),this.Ht=!1,this.onViewportBoundsChanged(n,this.viewportBounds,t,!1),this.Bs(!1),e._C(t,this.st),this.C()}eR(){const t=this.Gt.r;for(let i=0;i{r.isAvoiding&&r.actualBounds.intersectsRect(i)&&r.invalidateRoute()})}jr(t){const i=this.ts;if(i===null||!i.visible||i.layer===null)return;const e=t!==void 0?t:this._x;if(!e.isReal())return;const s=e.width,n=e.height;if(i.scale=1,i.angle=0,i.layer.isViewportAligned)i.width=s*this.scale,i.height=n*this.scale,i.part.alignment=Spot.TopLeft;else{i.xi===null&&(i.xi=new GridPanelSettings);const o=i.xi.Kc;if(!o.isReal())return;i.width=s+o.width*2,i.height=n+o.height*2;const r=Point.l();Geo.Eg(e.x,e.y,0,0,o.width,o.height,r),r.offset(-o.width,-o.height),i.part.location=r,Point.s(r)}}clearSelection(t){t===void 0&&(t=!1);const i=this.selection;if(i.count===0)return;t||this.v("ChangingSelection",i);const e=i.toArray(),s=e.length;for(let n=0;n1)&&(this.v("ChangingSelection",this.selection),this.clearSelection(!0),t.isSelected=!0,this.v("ChangedSelection",this.selection))}selectCollection(t){if(this.v("ChangingSelection",this.selection),this.clearSelection(!0),Array.isArray(t)){const i=t.length;for(let e=0;e0){const i=t.toArray(),e=i.length;for(let s=0;s1)&&(this.clearHighlighteds(),t.isHighlighted=!0)}highlightCollection(t){const i=new GSet().addAll(t),s=this.highlighteds.copy().removeAll(i).iterator;for(;s.next();){const o=s.value;o.isHighlighted=!1}const n=i.iterator;for(;n.next();){const o=n.value;o instanceof Part||Util.o("Diagram.highlightCollection given something that is not a Part: "+o),o.isHighlighted=!0}}scroll(t,i,e){e===void 0&&(e=1);const s=i==="up"||i==="down";let n=0;const o=Point.l();if(t==="pixel")n=e;else if(t==="line")n=e*(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange);else if(t==="page"){let l=s?this.viewportBounds.height:this.viewportBounds.width;if(l*=this.scale,l!==0){const h=Math.max(l-(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange),0);n=e*h}}else if(t==="document"){const l=this.documentBounds,h=this.viewportBounds;i==="up"?this.position=o.e(h.x,l.y):i==="left"?this.position=o.e(l.x,h.y):i==="down"?this.position=o.e(h.x,l.bottom-h.height):i==="right"&&(this.position=o.e(l.right-h.width,h.y)),Point.s(o);return}else Util.o("scrolling unit must be 'pixel', 'line', 'page', or 'document', not: "+t);n/=this.scale;const r=this.position;i==="up"?this.position=o.e(r.x,r.y-n):i==="down"?this.position=o.e(r.x,r.y+n):i==="left"?this.position=o.e(r.x-n,r.y):i==="right"?this.position=o.e(r.x+n,r.y):Util.o("scrolling direction must be 'up', 'down', 'left', or 'right', not: "+i),Point.s(o)}scrollToRect(t){const i=this.viewportBounds;if(i.containsRect(t))return;const e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}centerRect(t){const i=this.viewportBounds,e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}transformDocToView(t){return t.copy().D(this.D)}transformViewToDoc(t){return t.copy().Ie(this.D)}AF(t){return t.Ie(this.D)}static None=1;static Uniform=2;static UniformToFill=3;static CycleAll=1;static CycleNotDirected=2;static CycleNotDirectedFast=3;static CycleNotUndirected=4;static CycleDestinationTree=5;static CycleSourceTree=6;static DocumentScroll=1;static InfiniteScroll=2;static TreeParentCollapsed=1;static AllParentsCollapsed=2;static AnyParentsCollapsed=3;get opacity(){return this.Wt}set opacity(t){const i=this.Wt;i!==t&&(Util.i(t,"number",Diagram,"opacity"),(t<0||t>1)&&Util._(t,"0 <= value <= 1",Diagram,"opacity"),this.Wt=t,this.t("opacity",i,t),this.C())}get validCycle(){return this.Rx}set validCycle(t){const i=this.Rx;i!==t&&(this.Rx=t,this.t("validCycle",i,t))}get layers(){return this.Gt.iterator}get isModelReadOnly(){const t=this.Mi;return t===null?!1:t.isReadOnly}set isModelReadOnly(t){const i=this.Mi;i!==null&&(i.isReadOnly=t)}get isReadOnly(){return this.vo}set isReadOnly(t){const i=this.vo;i!==t&&(Util.i(t,"boolean",Diagram,"isReadOnly"),this.vo=t,this.t("isReadOnly",i,t))}get isEnabled(){return this.Oi}set isEnabled(t){const i=this.Oi;i!==t&&(Util.i(t,"boolean",Diagram,"isEnabled"),this.Oi=t,this.t("isEnabled",i,t))}get allowClipboard(){return this.Vx}set allowClipboard(t){const i=this.Vx;i!==t&&(Util.i(t,"boolean",Diagram,"allowClipboard"),this.Vx=t,this.t("allowClipboard",i,t))}get allowCopy(){return this.Rl}set allowCopy(t){const i=this.Rl;i!==t&&(Util.i(t,"boolean",Diagram,"allowCopy"),this.Rl=t,this.t("allowCopy",i,t))}get allowDelete(){return this.vl}set allowDelete(t){const i=this.vl;i!==t&&(Util.i(t,"boolean",Diagram,"allowDelete"),this.vl=t,this.t("allowDelete",i,t))}get allowDragOut(){return this.zx}set allowDragOut(t){const i=this.zx;i!==t&&(Util.i(t,"boolean",Diagram,"allowDragOut"),this.zx=t,this.t("allowDragOut",i,t))}get allowDrop(){return this.Xx}set allowDrop(t){const i=this.Xx;i!==t&&(Util.i(t,"boolean",Diagram,"allowDrop"),this.Xx=t,this.t("allowDrop",i,t))}get allowTextEdit(){return this.Ol}set allowTextEdit(t){const i=this.Ol;i!==t&&(Util.i(t,"boolean",Diagram,"allowTextEdit"),this.Ol=t,this.t("allowTextEdit",i,t))}get allowGroup(){return this.Il}set allowGroup(t){const i=this.Il;i!==t&&(Util.i(t,"boolean",Diagram,"allowGroup"),this.Il=t,this.t("allowGroup",i,t))}get allowUngroup(){return this.El}set allowUngroup(t){const i=this.El;i!==t&&(Util.i(t,"boolean",Diagram,"allowUngroup"),this.El=t,this.t("allowUngroup",i,t))}get allowInsert(){return this.Kx}set allowInsert(t){const i=this.Kx;i!==t&&(Util.i(t,"boolean",Diagram,"allowInsert"),this.Kx=t,this.t("allowInsert",i,t))}get allowLink(){return this.Ul}set allowLink(t){const i=this.Ul;i!==t&&(Util.i(t,"boolean",Diagram,"allowLink"),this.Ul=t,this.t("allowLink",i,t))}get allowRelink(){return this.Bl}set allowRelink(t){const i=this.Bl;i!==t&&(Util.i(t,"boolean",Diagram,"allowRelink"),this.Bl=t,this.t("allowRelink",i,t))}get allowMove(){return this.Vl}set allowMove(t){const i=this.Vl;i!==t&&(Util.i(t,"boolean",Diagram,"allowMove"),this.Vl=t,this.t("allowMove",i,t))}get allowReshape(){return this.zl}set allowReshape(t){const i=this.zl;i!==t&&(Util.i(t,"boolean",Diagram,"allowReshape"),this.zl=t,this.t("allowReshape",i,t))}get allowResize(){return this.Xl}set allowResize(t){const i=this.Xl;i!==t&&(Util.i(t,"boolean",Diagram,"allowResize"),this.Xl=t,this.t("allowResize",i,t))}get allowRotate(){return this.Kl}set allowRotate(t){const i=this.Kl;i!==t&&(Util.i(t,"boolean",Diagram,"allowRotate"),this.Kl=t,this.t("allowRotate",i,t))}get allowSelect(){return this.Yl}set allowSelect(t){const i=this.Yl;i!==t&&(Util.i(t,"boolean",Diagram,"allowSelect"),this.Yl=t,this.t("allowSelect",i,t))}get allowUndo(){return this.Yx}set allowUndo(t){const i=this.Yx;i!==t&&(Util.i(t,"boolean",Diagram,"allowUndo"),this.Yx=t,this.t("allowUndo",i,t))}get allowZoom(){return this.Gx}set allowZoom(t){const i=this.Gx;i!==t&&(Util.i(t,"boolean",Diagram,"allowZoom"),this.Gx=t,this.t("allowZoom",i,t))}get hasVerticalScrollbar(){return this.Eu}set hasVerticalScrollbar(t){const i=this.Eu;i!==t&&(Util.i(t,"boolean",Diagram,"hasVerticalScrollbar"),this.Eu=t,this.oa(),this.C(),this.t("hasVerticalScrollbar",i,t),this.Bs(!1))}get hasHorizontalScrollbar(){return this.Iu}set hasHorizontalScrollbar(t){const i=this.Iu;i!==t&&(Util.i(t,"boolean",Diagram,"hasHorizontalScrollbar"),this.Iu=t,this.oa(),this.C(),this.t("hasHorizontalScrollbar",i,t),this.Bs(!1))}get allowHorizontalScroll(){return this.jx}set allowHorizontalScroll(t){const i=this.jx;i!==t&&(Util.i(t,"boolean",Diagram,"allowHorizontalScroll"),this.jx=t,this.t("allowHorizontalScroll",i,t),this.Bs(!1))}get allowVerticalScroll(){return this.Hx}set allowVerticalScroll(t){const i=this.Hx;i!==t&&(Util.i(t,"boolean",Diagram,"allowVerticalScroll"),this.Hx=t,this.t("allowVerticalScroll",i,t),this.Bs(!1))}get scrollHorizontalLineChange(){return this.qx}set scrollHorizontalLineChange(t){const i=this.qx;i!==t&&(Util.i(t,"number",Diagram,"scrollHorizontalLineChange"),t<0&&Util._(t,">= 0",Diagram,"scrollHorizontalLineChange"),this.qx=t,this.t("scrollHorizontalLineChange",i,t))}get scrollVerticalLineChange(){return this.Wx}set scrollVerticalLineChange(t){const i=this.Wx;i!==t&&(Util.i(t,"number",Diagram,"scrollVerticalLineChange"),t<0&&Util._(t,">= 0",Diagram,"scrollVerticalLineChange"),this.Wx=t,this.t("scrollVerticalLineChange",i,t))}get lastInput(){return this.Jh}set lastInput(t){this.Jh=t}get previousInput(){return this.Xr}set previousInput(t){this.Xr=t}get firstInput(){return this.Jm}set firstInput(t){this.Jm=t}get currentCursor(){return this.vx}set currentCursor(t){if(t===""&&(t=this.Km),this.vx!==t){Util.i(t,"string",Diagram,"currentCursor");const e=this.dt,s=this.Tt;if(e===null||s===null)return;this.vx=t;const n=e.style.cursor;e.style.cursor=t,s.style.cursor=t,e.style.cursor===n&&(e.style.cursor="-webkit-"+t,s.style.cursor="-webkit-"+t,e.style.cursor===n&&(e.style.cursor="-moz-"+t,s.style.cursor="-moz-"+t,e.style.cursor===n&&(e.style.cursor=t,s.style.cursor=t)))}}get defaultCursor(){return this.Km}set defaultCursor(t){t===""&&(t="auto");const i=this.Km;i!==t&&(Util.i(t,"string",Diagram,"defaultCursor"),this.Km=t,this.t("defaultCursor",i,t))}get click(){return this.Tr}set click(t){const i=this.Tr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"click"),this.Tr=t,this.t("click",i,t))}get doubleClick(){return this.Dr}set doubleClick(t){const i=this.Dr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"doubleClick"),this.Dr=t,this.t("doubleClick",i,t))}get contextClick(){return this.Fr}set contextClick(t){const i=this.Fr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"contextClick"),this.Fr=t,this.t("contextClick",i,t))}get mouseOver(){return this.Rr}set mouseOver(t){const i=this.Rr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseOver"),this.Rr=t,this.t("mouseOver",i,t))}get mouseHover(){return this.vr}set mouseHover(t){const i=this.vr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseHover"),this.vr=t,this.t("mouseHover",i,t))}get mouseHold(){return this.Or}set mouseHold(t){const i=this.Or;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseHold"),this.Or=t,this.t("mouseHold",i,t))}get mouseDragOver(){return this.Ox}set mouseDragOver(t){const i=this.Ox;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseDragOver"),this.Ox=t,this.t("mouseDragOver",i,t))}get mouseDrop(){return this.Ir}set mouseDrop(t){const i=this.Ir;i!==t&&(this.Ir=t,this.t("mouseDrop",i,t))}get handlesDragDropForTopLevelParts(){return this.Ix}set handlesDragDropForTopLevelParts(t){const i=this.Ix;i!==t&&(Util.i(t,"boolean",Diagram,"handlesDragDropForTopLevelParts"),this.Ix=t,this.t("handlesDragDropForTopLevelParts",i,t))}get mouseEnter(){return this.Er}set mouseEnter(t){const i=this.Er;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseEnter"),this.Er=t,this.t("mouseEnter",i,t))}get mouseLeave(){return this.Ur}set mouseLeave(t){const i=this.Ur;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseLeave"),this.Ur=t,this.t("mouseLeave",i,t))}get toolTip(){return this.Br}set toolTip(t){const i=this.Br;i!==t&&(this.Br=t,this.t("toolTip",i,t))}get contextMenu(){return this.Vr}set contextMenu(t){const i=this.Vr;i!==t&&(this.Vr=t,this.t("contextMenu",i,t))}get commandHandler(){return this.HM}set commandHandler(t){this.HM!==t&&(this.HM=t,t.To(this))}get toolManager(){return this.YM}set toolManager(t){this.YM!==t&&(this.YM=t,t.diagram=this)}get defaultTool(){return this.GM}set defaultTool(t){const i=this.GM;i!==t&&(this.GM=t,t.diagram=this,this.currentTool===i&&(this.currentTool=t))}get currentTool(){return this.jM}set currentTool(t){const i=this.jM;i&&(i.isActive&&i.doDeactivate(),i.cancelWaitAfter(),i.doStop()),t===null&&(t=this.defaultTool),t!==null&&(this.jM=t,t.diagram=this,t.doStart())}get selection(){return this._M}get maxSelectionCount(){return this.Qx}set maxSelectionCount(t){const i=this.Qx;if(i!==t)if(Util.i(t,"number",Diagram,"maxSelectionCount"),t>=0&&!isNaN(t)){if(this.Qx=t,this.t("maxSelectionCount",i,t),!this.undoManager.isUndoingRedoing){const e=this.selection.count-t;if(e>0){this.v("ChangingSelection",this.selection);const s=this.selection.toArray();for(let n=0;n= 0",Diagram,"maxSelectionCount")}get nodeSelectionAdornmentTemplate(){return this.Hm}set nodeSelectionAdornmentTemplate(t){const i=this.Hm;i!==t&&(this.Hm=t,this.t("nodeSelectionAdornmentTemplate",i,t))}get groupSelectionAdornmentTemplate(){return this.ib}set groupSelectionAdornmentTemplate(t){const i=this.ib;i!==t&&(this.ib=t,this.t("groupSelectionAdornmentTemplate",i,t))}get linkSelectionAdornmentTemplate(){return this.eb}set linkSelectionAdornmentTemplate(t){const i=this.eb;i!==t&&(this.eb=t,this.t("linkSelectionAdornmentTemplate",i,t))}get highlighteds(){return this.tS}get isModified(){const t=this.undoManager;return t.isEnabled?t.currentTransaction!==null?!0:this.Vu&&this.vs!==t.historyIndex:this.Vu}set isModified(t){if(this.Vu!==t){Util.i(t,"boolean",Diagram,"isModified"),this.Vu=t;const e=this.undoManager;!t&&e.isEnabled&&(this.vs=e.historyIndex),t||this.OL()}}OL(){const t=this.isModified;this.ZM!==t&&(this.ZM=t,this.v("Modified"))}get model(){return this.Mi}set model(t){const i=this.Mi;if(i!==t){this.currentTool.doCancel(),i&&i.undoManager!==t.undoManager&&i.undoManager.isInTransaction&&Util.o("Do not replace a Diagram.model while a transaction is in progress."),this.animationManager.stopAnimation(!0);const e=this.mL(!0);this.Jn=!1,this.Ou=!0,this.vs=-2,this.Pr=!1;const s=this.Ht;this.Ht=!0,this.animationManager.Fl("Model"),i&&(this.qn!==null&&this.qn.each(n=>i.removeChangedListener(n)),i.removeChangedListener(this.$M)),this.Mi=t,this.partManager=this.uR(this.Mi.type),this.initializePartManager(this.partManager);for(let n=0;nt.addChangedListener(n)),this.Ht=s,this.invalidateDocumentBounds(),this.Ht||this.C(),i&&t.undoManager.copyProperties(i.undoManager)}}get themeManager(){return this.gb}set themeManager(t){const i=this.gb;i!==t&&(i!==null&&i.removeDiagram(this),this.gb=t,t!==null&&t.addDiagram(this))}initializePartManager(t){}static gS(t,i){Diagram.aL.set(t,i)}static get licenseKey(){return Diagram.AS.last()}static set licenseKey(t){Diagram.AS.add(t.replace(/\s/g,""))}static get version(){return Diagram.dR}static AS=new List;static dR="3.0.11";uR(t){const i=Diagram.aL.get(t);return i!==null?new i:new PartManager}get Y(){return this.WM}set Y(t){this.WM=t}get mx(){return this.rL}gR(t){if(t.model!==this.model)return;const i=t.change,e=t.propertyName;if(i===1&&e[0]==="S"){if(e==="StartingFirstTransaction"){const s=this,n=this.toolManager;n.mouseDownTools.each(o=>o.diagram=s),n.mouseMoveTools.each(o=>o.diagram=s),n.mouseUpTools.each(o=>o.diagram=s),this.routers.each(o=>o.diagram=s),!this.ps&&!this.Jn&&(this.vc=!0,this.Ou&&(this.Pr=!0))}else if(e==="StartingUndo"||e==="StartingRedo"){const s=this.animationManager;this.skipsUndoManager||(s.defaultAnimation.isAnimating&&s.stopAnimation(),s.getBundleAnimation().isAnimating&&s.getBundleAnimation().stop()),this.v("ChangingSelection",this.selection)}else if(e==="StartedTransaction"){const s=this.animationManager;s.defaultAnimation.isAnimating&&!this.skipsUndoManager&&s.stopAnimation()}return}if(this.Y){this.Y=!1;try{if(t.modelChange===""&&i===1){(e==="FinishedUndo"||e==="FinishedRedo")&&(this.v("ChangedSelection",this.selection),this.Ci());const s=this.animationManager;e==="RolledBackTransaction"&&s.stopAnimation(),this.fR(),this.vc=!0,this.maybeUpdate(),(this.undoManager.transactionLevel===0||this.undoManager.transactionLevel===1)&&s.MM(),e==="CommittedTransaction"&&this.undoManager.isJustDiscarded&&(this.vs=Math.min(this.vs,this.undoManager.historyIndex-1)),(e==="CommittedTransaction"||e==="RolledBackTransaction")&&this.undoManager.Iw&&setTimeout(()=>{this.isModified=!1},1);const n=t.isTransactionFinished;if(n&&(this.OL(),this.mx.clear(),this.animationManager.uF()),!this.Ex&&n&&this.lastInput.targetDiagram){this.Ex=!0;const o=this;Util.vh(()=>{o.currentTool.standardMouseOver(),o.Ex=!1},10)}}}finally{this.Y=!0}}}get ce(){return this.qM}set ce(t){this.qM=t}get uc(){return this.Ux}set uc(t){this.Ux=t}SL(t){const i=t.L.r;for(const e of i)e instanceof Picture&&this.TS(e)}TS(t){const i=t.element;if(i===null||!(i instanceof HTMLImageElement)||(i.es instanceof GSet&&i.es.add(this),t.mR(),!i.f0))return;const e=i.getAttribute("src")||"",s=this.Jl.get(e);if(s===null){Picture.IL(t,i);const n=[];n.push(t),this.Jl.set(e,n)}else{for(let n=0;n0?(this.kx=t,this.t("minScale",i,t),t>this.scale&&(this.scale=t)):Util._(t,"> 0",Diagram,"minScale"))}get maxScale(){return this.Px}set maxScale(t){const i=this.Px;i!==t&&(t>0?(this.Px=t,this.t("maxScale",i,t),t 0",Diagram,"maxScale"))}get zoomPoint(){return this.Mx}set zoomPoint(t){this.Mx.equals(t)||(t=t.N(),this.Mx=t)}get contentAlignment(){return this.Fc}set contentAlignment(t){const i=this.Fc;i.equals(t)||(t=t.N(),this.Fc=t,this.t("contentAlignment",i,t),this.Bs(!1))}get initialContentAlignment(){return this.Vm}set initialContentAlignment(t){const i=this.Vm;i.equals(t)||(t=t.N(),this.Vm=t,this.t("initialContentAlignment",i,t))}get padding(){return this.$t}set padding(t){typeof t=="number"&&(t=new Margin(t));const i=this.$t;i.equals(t)||(t=t.N(),this.$t=t,this.invalidateDocumentBounds(),this.t("padding",i,t))}get partManager(){return this.oS}set partManager(t){const i=this.oS;i!==t&&(t.diagram!==null&&Util.o("Cannot share PartManagers between Diagrams: "+t.toString()),i&&i.To(null),this.oS=t,t.To(this))}get nodes(){return this.partManager.nodes.iterator}get links(){return this.partManager.links.iterator}get parts(){return this.partManager.parts.iterator}findTopLevelNodesAndLinks(){const t=new GSet,i=this.nodes;for(;i.next();){const s=i.value;s.isTopLevel&&t.add(s)}const e=this.links;for(;e.next();){const s=e.value;s.isTopLevel&&t.add(s)}return t.iterator}findTopLevelGroups(){return this.Yr.iterator}get routers(){return this.Vc}doLinkRouting(t){this.Fo=!0;const i=this.Vc.r;for(let e=0;e0){const l=this.computePartsBounds(n.memberParts,!1);l.inflate(20,20),s.kb(l)}const o=Rect.l(),r=n.memberParts;for(;r.next();){const l=r.value;l instanceof Node&&this.IS(l,e,o)}Rect.s(o)}s.la=n,s.RS=e,s.Eo=!1}else t&&s.XL();return s}get avoidanceCellSize(){return this.iS}set avoidanceCellSize(t){this.Hl=null,this.iS=new Size(Math.max(1,t.width),Math.max(1,t.height))}get avoidanceLimit(){return this.eS}set avoidanceLimit(t){this.eS=Math.max(1,t)}zL(t){return t.canAvoid()?t:t.containingGroup!==null?this.zL(t.containingGroup):null}IS(t,i,e){if(t===i||!t.isVisible())return;const s=t.canAvoid();if(s){const n=t.getAvoidableRect(e);this.Hl.wR(n.x,n.y,n.width,n.height)}if(t instanceof Group&&(!s||t.avoidableMembers)){const n=t.memberParts;for(;n.next();){const o=n.value;o instanceof Node&&this.IS(o,i,e)}}}ES(t){this.Hl!==null&&!this.Hl.Eo&&(t===void 0||t.canAvoid())&&(this.Hl.Eo=!0)}get autoScrollInterval(){return this.zm}set autoScrollInterval(t){const i=this.zm;i!==t&&(this.zm=t,this.t("autoScrollInterval",i,t))}get autoScrollRegion(){return this.Xm}set autoScrollRegion(t){typeof t=="number"&&(t=new Margin(t));const i=this.Xm;i.equals(t)||(t=t.N(),this.Xm=t,this.invalidateDocumentBounds(),this.t("autoScrollRegion",i,t))}doAutoScroll(t){this.Wm.a(t),this.computeAutoScrollPosition(this.Wm).equalsApprox(this.position)?this.stopAutoScroll():this.KL()}KL(){if(this.Rc!==-1)return;const t=this.zm,i=this;this.Rc=Util.vh(()=>{if(i.Rc===-1||(i.stopAutoScroll(),i.lastInput.event===null))return;const s=i.computeAutoScrollPosition(i.Wm);if(s.equalsApprox(i.position))return;i.position=s,i.lastInput.documentPoint=i.transformViewToDoc(i.Wm),i.doMouseMove(),i.$h=!0;const n=Rect.l();i.computeBounds(n),n.unionRect(i.documentBounds),i.EL(n),Rect.s(n),i.Be=!0,i.maybeUpdate(),i.KL()},t)}stopAutoScroll(){this.Rc!==-1&&(Util.Ig(this.Rc),this.Rc=-1)}computeAutoScrollPosition(t){let i=this.position;const e=this.Xm;if(e.top<=0&&e.left<=0&&e.right<=0&&e.bottom<=0)return i;const s=this.viewportBounds,n=this.scale,o=Rect.X(0,0,s.width*n,s.height*n),r=Point.X(0,0);if(t.x>=o.x&&t.xo.x+o.width-e.right&&this.allowHorizontalScroll){let l=Math.max(this.scrollHorizontalLineChange,1);l=l|0,r.x+=l,t.x>o.x+o.width-e.right/2&&(r.x+=l),t.x>o.x+o.width-e.right/4&&(r.x+=4*l)}if(t.y>=o.y&&t.yo.y+o.height-e.bottom&&this.allowVerticalScroll){let l=Math.max(this.scrollVerticalLineChange,1);l=l|0,r.y+=l,t.y>o.y+o.height-e.bottom/2&&(r.y+=l),t.y>o.y+o.height-e.bottom/4&&(r.y+=4*l)}return r.equalsApprox(Point.Po)||(i=new Point(i.x+r.x/n,i.y+r.y/n)),Rect.s(o),Point.s(r),i}makeSvg(t){this.Wl.has("SVG")||this.addRenderer("SVG",new SVGSurface(this,root.document));const i=new SVGSurface(this,root.document,!0);t===void 0&&(t={});const e=this;function s(n,o){const r=e.YL(n,"SVG",i),l=r!==null?r.svg:null;return typeof o=="function"?(o(l),null):l}return this.GL(s,t)}makeSVG(t){return this.makeSvg(t)}addRenderer(t,i){this.Wl.set(t,i)}removeRenderer(t){this.Wl.delete(t)}cacheGroupExternalLinks(t){this.dS=t,t||this.nodes.each(i=>{i instanceof Group&&(i.d0=null)})}GL(t,i){const e=i.callback;let s=!0;const o=this.Jl.iterator;for(;o.next();)if(!o.value[0].mn){s=!1;break}if(typeof e!="function"||s)return t(i,e,this);const r=this;function l(){const c=+new Date;for(s=!0,o.reset();o.next();)if(!o.value[0].mn){s=!1;break}if(s||c-a>h){t(i,e,r);return}root.requestAnimationFrame(l)}const h=i.callbackTimeout||300,a=+new Date;return root.requestAnimationFrame(()=>l()),null}makeImage(t){return Diagram.isUsingDOM()?(t===void 0&&(t={}),t.returnType="Image",this.makeImageData(t)):null}makeImageData(t){return t===void 0&&(t={}),this.GL(this.xR,t)}static img="image";xR(t,i,e){const s=e.YL(t,"canvas",null);if(s===null)return null;const n=s.B.canvas;let o=null;if(n!==null){let r=t.returnType;switch(r===void 0?r="string":r=r.toLowerCase(),r){case Diagram.img+"data":o=s.getImageData(0,0,n.width,n.height);break;case Diagram.img:const h=(t.document||document).createElement("img");h.src=n.toDataURL(t.type,t.details),o=h;break;case"blob":{const a=n;return typeof i!="function"&&(o="",Util.o('Error: Diagram.makeImageData called with "returnType: toBlob", but no required "callback" function property defined.')),typeof a.toBlob=="function"?(a.toBlob(i,t.type,t.details),"toBlob"):(i(null),null)}case"string":default:o=n.toDataURL(t.type,t.details)}}return typeof i=="function"?(i(o),null):o}static bR=!1;YL(t,i,e){if(this.animationManager.stopAnimation(),this.maybeUpdate(),this.dt===null)return null;typeof t!="object"&&Util.o("properties argument must be an Object.");let n=!1,o=t.size||null,r=t.scale||null;t.scale!==void 0&&isNaN(t.scale)&&(r="NaN");let l=t.maxSize;t.maxSize===void 0&&(n=!0,i==="SVG"?l=new Size(1/0,1/0):l=new Size(2e3,2e3));const h=t.position||null;let a=t.parts||null;Array.isArray(a)&&(a=new List(a));let c=t.padding===void 0?1:t.padding;const f=t.background||null;let u=t.omitTemporary;u===void 0&&(u=!0);const d=t.document||document,m=t.elementFinished||null;let g=t.showTemporary;g===void 0&&(g=!u);let p=t.showGrid;p===void 0&&(p=g),o!==null&&isNaN(o.width)&&isNaN(o.height)&&(o=null),typeof c=="number"?c=new Margin(c):c instanceof Margin||Util.o("MakeImage padding must be a Margin or a number."),c.left=Math.max(c.left,0),c.right=Math.max(c.right,0),c.top=Math.max(c.top,0),c.bottom=Math.max(c.bottom,0),this.Zt.clearContextCache(!0);const y=new CanvasSurface(null,d,void 0,!0),x=y.ai;if(!(o||r||a||h))return y.width=this.kt+Math.ceil(c.left+c.right),y.height=this.Pt+Math.ceil(c.top+c.bottom),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.ha=d,e.ju=m,this.wb(e.ai,c,new Size(y.width,y.height),this.st,this.ct,a,f,g,p),e.ai):(this.zu=!1,this.wb(x,c,new Size(y.width,y.height),this.st,this.ct,a,f,g,p),this.zu=!0,y.ai);const k=this.$m,b=this.documentBounds.copy();if(b.subtractMargin(this.$t),g){const A=this.Gt.r,D=A.length;for(let F=0;Fk?(r=k,N=b.width,T=b.height):(N=l.width,T=l.height)):(N=b.width*r,T=b.height*r):(r=k,N=b.width,T=b.height),c!==null?(N+=M,T+=L):c=new Margin(0),l!==null){let A=l.width,D=l.height;i!=="SVG"&&n&&Diagram.bR,isNaN(A)&&(A=2e3),isNaN(D)&&(D=2e3),isFinite(A)&&(N=Math.min(N,A)),isFinite(D)&&(T=Math.min(T,D))}return y.width=Math.ceil(N),y.height=Math.ceil(T),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.ha=d,e.ju=m,this.wb(e.ai,c,new Size(Math.ceil(N),Math.ceil(T)),r,P,a,f,g,p),e.ai):(this.zu=!1,this.wb(x,c,new Size(Math.ceil(N),Math.ceil(T)),r,P,a,f,g,p),this.zu=!0,y.ai)}static Yu=null;static jL="5da73c80a36555d4038e4972187c3cae51fd22";static uw=!1;static Ik=()=>{if(Diagram.jL[5]===void 0&&(Transform.prototype._e=Transform.prototype.ww),!Diagram.isUsingDOM())return;const t=root.document.createElement("canvas"),i=t.getContext("2d"),e=Util.Cs("7ca11abfd022028846");i[e]=Util.Cs("398c3597c01238");const s="7ca11abfd7330390",n=[Diagram.jL,Util.uw+"4ae6247590da4bb21c324ba3a84e385776",Transform.Ik+"fb236cdfda5de14c134ba1a95a2d4c7cc6f93c1387",Geo.za],o=10,r=0;for(let l=1;l<5;l++)i[Util.Cs(s)](Util.Cs(n[l-1]),o,l*15+r);i[e]=Util.Cs("39f046ebb36e4b");for(let l=1;l<5;l++)i[Util.Cs(s)](Util.Cs(n[l-1]),o,l*15+r);(n.length!==4||n[0][0]!=="5"||n[3][0]!=="7")&&(Transform.prototype._e=Transform.prototype.ww),Diagram.Yu=t}}class DiagramHelper{HL;qL;US;Ne;constructor(t){if(this.HL=null,this.qL="63ad05bbe23a1786468a4c741b6d2",this.US="@onz",this.qL===this._tk){this.US=!0,this.Ne=this.US;return}this.Ne=null}kR(t,i){let e="f";const s=root[Util.Cs("76a715b2f73f148a")][Util.Cs("72ba13b5")]||"",n=Util.Cs;if(this.Ne=!0,!Diagram.isUsingDOM())return;let o=Diagram[n("76a115b6ed251eaf4692")];if(!o){const l=s[n("76ad18b4f73e")];for(let a=s[n("73a612b6fb191d")](n("35e7"))+2;a=0&&ha[0]||h[0]===a[0]&&h[1]>=a[1]))continue;const c="73a612b6fb191d",f=root[n("74a900bae4370f8b51")][n("6fbb13a1c2311e8a57")].toLowerCase(),u=f[n(c)](n("3aad1ab6e022098b4dc4")),d=n(l[2]);if(u>-1){const S=f[n(c)](d.toLowerCase()+"/");if(this.Ne=!(S>-1&&S=0&&g-1),!this.Ne))return;const p=root[Util.Cs("76a715b2f73f148a")][Util.Cs("69ad17a1e03e")],y=p[n(c)](n("7fb002b6ed25128b4da25b2e"));if(y>-1&&(this.Ne=!(p[n(c)](d)>y),!this.Ne))return;const x=d;if(x[0]!=="#")continue;const k=root.document.createElement("div");let b=l[0].replace(/[A-Za-z]/g,"");for(;b.length<4;)b+="9";const P=b;b=b.substring(b.length-4);let M="";const L=["gsh","gsf"],C=["Header","Background","Display","Feedback"];if(M+=L[parseInt(b.substring(0,1),10)%2],M+=C[parseInt(b.substring(0,1),10)%4],k[n("79a417a0f0181a8946")]=M,root.document[n("78a712aa")]){root.document[n("78a712aa")][n("7bb806b6ed32388c4a875b")](k);const S=root.getComputedStyle(k).getPropertyValue(n("78a704b7e62456904c9b12701b6532a8")),N=root.getComputedStyle(k).getPropertyValue(n("75b817b0ea2202"));if(root.document[n("78a712aa")][n("68ad1bbcf533388c4a875b")](k),!S)continue;const T=root[n("77a902b0eb1b1e804a8a")],A="0."+parseInt(P,10)%100;if(N===A||S.indexOf(parseInt(x[1]+x[2],16))!==-1&&S.indexOf(parseInt(x[3]+x[4],16))!==-1){this.Ne=!1;return}else if(T&&T(n("32ae19a1e0331fc94084537c067a67fa59f1386b89d006")).matches){M="."+M;for(let D=0;D{const s=this.observed;if(s===null)return;const n=s.viewportBounds,o=this.lastInput.documentPoint;s.position=new Point(o.x-n.width/2,o.y-n.height/2)},this.zS=s=>{this.invalidateDocumentBounds(),this.m0()},this.XS=s=>{this.observed!==null&&(this.invalidateDocumentBounds(),this.C())},this.Cb=s=>{this.updateDelay<1?this.C():this.g0||(this.g0=!0,setTimeout(()=>this.redraw(),this.updateDelay))},this.KS=s=>{this.observed!==null&&this.m0()},this.autoScale=2,this.Ht=!1,i&&Object.assign(this,i),this}setupRouters(){}computePixelRatio(){return 1}redraw(){this.g0&&this.updateDelay>=1&&(this.g0=!1,this.PR()),super.redraw()}Gi(){if(this.Tt===null&&Util.o("No div specified"),this.dt===null&&Util.o("No canvas specified"),this.dt instanceof SVGSurface||(this.box.BM(),!this.Be))return;const t=this.observed;if(t===null||t.animationManager.defaultAnimation.isAnimating||!t.Eh)return;this.h0();const i=this.dt,e=this.Zt;if(e.clearContextCache(!0),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,i.width,i.height),this.updateDelay<1)this.JL();else if(this.Gc!==null){e.drawImage(this.Gc.Ft,0,0);const o=this.D;e.scale(this.Bi,this.Bi),e.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),e.commitTransform()}const s=this.Gt.r,n=s.length;for(let o=0;on.canDelete())}t.removeParts(i,!0),t.v("SelectionDeleted",i)}finally{t.commitTransaction("Delete"),t.v("ChangedSelection",t.selection),t.currentCursor=""}}canDeleteSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowDelete||t.selection.count===0)}copySelection(){const t=this.diagram;try{const i=new GSet,e=t.selection.iterator;for(;e.next();){const s=e.value;Part.sh(i,s,!0,this.copiesTree?1/0:0,this.copiesConnectedLinks,n=>n.canCopy())}this.copyToClipboard(i)}finally{}}canCopySelection(){const t=this.diagram;return!(!t.allowCopy||!t.allowClipboard||t.selection.count===0)}cutSelection(){this.copySelection(),this.deleteSelection()}canCutSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowCopy||!t.allowDelete||!t.allowClipboard||t.selection.count===0)}copyToClipboard(t){const i=this.diagram;let e=null;if(t===null)Diagram.gL();else{const s=i.model;let n=!1,o=!1,r=null;try{s.mc()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.dc()||s.Hu())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=i.copyParts(t,null,!0)}finally{s.mc()&&(s.copiesParentKeyOfNodeData=n),(s.dc()||s.Hu())&&(s.copiesGroupKeyOfNodeData=o),e=new List,e.addAll(r.iteratorValues),Diagram.s0=e,Diagram.mb=i.model.dataFormat}}i.v("ClipboardChanged",e)}pasteFromClipboard(){const t=new GSet,i=Diagram.s0;if(i===null)return t;const e=this.diagram;if(Diagram.mb!==e.model.dataFormat)return t;const s=e.model;let n=!1,o=!1,r=null;try{s.mc()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.dc()||s.Hu())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=e.copyParts(i,e,!1)}finally{s.mc()&&(s.copiesParentKeyOfNodeData=n),(s.dc()||s.Hu())&&(s.copiesGroupKeyOfNodeData=o);const l=r.iterator;for(;l.next();){const h=l.value,a=l.key;h.location.isReal()||(a.location.isReal()?h.location=a.location:!h.position.isReal()&&a.position.isReal()&&(h.position=a.position)),t.add(h)}}return t}pasteSelection(t){t===void 0&&(t=null);const i=this.diagram;try{i.currentCursor="wait",i.v("ChangingSelection",i.selection),i.startTransaction("Paste");const e=this.pasteFromClipboard();e.count>0&&i.clearSelection(!0);const s=e.iterator;for(;s.next();){const n=s.value;n.isSelected=!0}if(t!==null){const n=i.computePartsBounds(i.selection);if(n.isReal()){const o=this.computeEffectiveCollection(i.selection,i.fb);i.bP(o,new Point(t.x-n.centerX,t.y-n.centerY),i.fb,!1)}}i.v("ClipboardPasted",e)}finally{i.commitTransaction("Paste"),i.v("ChangedSelection",i.selection),i.currentCursor=""}}canPasteSelection(t){const i=this.diagram;return!(i.isReadOnly||i.isModelReadOnly||!i.allowInsert||!i.allowClipboard||Diagram.s0===null||Diagram.s0.count===0||Diagram.mb!==i.model.dataFormat)}undo(){this.diagram.undoManager.undo()}canUndo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canUndo()}redo(){this.diagram.undoManager.redo()}canRedo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canRedo()}decreaseZoom(t){t===void 0&&(t=1/this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canDecreaseZoom(t){t===void 0&&(t=1/this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}increaseZoom(t){t===void 0&&(t=this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canIncreaseZoom(t){t===void 0&&(t=this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}resetZoom(t){t===void 0&&(t=this.defaultScale);const i=this.diagram;ti.maxScale||(i.scale=t)}canResetZoom(t){t===void 0&&(t=this.defaultScale);const i=this.diagram;return ti.maxScale?!1:i.allowZoom}zoomToFit(){const t=this.diagram,i=t.animationManager;i.stopAnimation(),t.redraw();const e=t.position,s=t.scale;i.Fl("Zoom To Fit"),this.isZoomToFitRestoreEnabled&&s===this.Ab&&!isNaN(this.Lb)&&t.documentBounds.equals(this.Tb)?(t.scale=this.Lb,t.position=this.QS,this.Ab=NaN,this.Tb=Rect.pw):(this.Lb=s,this.QS=e.copy(),t.zoomToFit(),this.Ab=t.scale,this.Tb=t.documentBounds.copy()),i.MM()}canZoomToFit(){return this.diagram.allowZoom}scrollToPart(t){t===void 0&&(t=null);const i=this.diagram;if(i.ensureBounds(),t===null){try{this.Uo!==null&&(this.Uo.next()?t=this.Uo.value:this.Uo=null)}catch{this.Uo=null}t===null&&(i.highlighteds.count>0?this.Uo=i.highlighteds.iterator:i.selection.count>0&&(this.Uo=i.selection.iterator),this.Uo!==null&&this.Uo.next()&&(t=this.Uo.value))}if(t!==null){const e=i.animationManager;e.Fl("Scroll To Part");const s=this.scrollToPartPause;if(s>0){const n=this.jc(t,[t]);if(n.length===1)i.startTransaction(),i.centerRect(t.actualBounds),i.commitTransaction("Scroll To Part");else{const o=()=>{i.startTransaction();let l=n.pop();for(;n.length>0&&l instanceof Node&&l.isTreeExpanded&&(!(l instanceof Group)||l.isSubGraphExpanded);)l=n.pop();n.length>0?(l instanceof Part&&i.scrollToRect(l.actualBounds),l instanceof Node&&!l.isTreeExpanded&&(l.isTreeExpanded=!0),l instanceof Group&&!l.isSubGraphExpanded&&(l.isSubGraphExpanded=!0)):(l instanceof Part&&i.centerRect(l.actualBounds),i.removeDiagramListener("LayoutCompleted",r)),i.commitTransaction("Scroll To Part")},r=()=>{Util.vh(o,(e.isEnabled?e.duration:0)+s)};i.addDiagramListener("LayoutCompleted",r),o()}}else{const n=i.position.copy();i.centerRect(t.actualBounds),n.equalsApprox(i.position)&&e.stopAnimation()}}}jc(t,i){if(t.isVisible())return i;if(t instanceof Adornment)this.jc(t.adornedPart,i);else if(t instanceof Link){const e=t.fromNode;e!==null&&this.jc(e,i);const s=t.toNode;s!==null&&this.jc(s,i)}else{if(t instanceof Node){const s=t.labeledLink;s!==null&&this.jc(s,i);const n=t.findTreeParentNode();n!==null&&(!n.isTreeExpanded&&!n.wasTreeExpanded&&i.push(n),this.jc(n,i))}const e=t.containingGroup;e!==null&&(!e.isSubGraphExpanded&&!e.wasSubGraphExpanded&&i.push(e),this.jc(e,i))}return i}canScrollToPart(t){if(t===void 0&&(t=null),t!==null&&!(t instanceof Part))return!1;const i=this.diagram;return i.selection.count===0&&i.highlighteds.count===0?!1:i.allowHorizontalScroll&&i.allowVerticalScroll}collapseTree(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse Tree";try{i.startTransaction(e),i.animationManager.Fl(e);const n=new List;if(t!==null&&t.isTreeExpanded)t.collapseTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&r.isTreeExpanded&&(r.collapseTree(),n.add(r))}}i.v("TreeCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||!t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(!s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}expandTree(t){t===void 0&&(t=null);const i=this.diagram,e="Expand Tree";try{i.startTransaction(e),i.animationManager.Fl(e);const n=new List;if(t!==null&&!t.isTreeExpanded)t.expandTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&(r.isTreeExpanded||(r.expandTree(),n.add(r)))}}i.v("TreeExpanded",n)}finally{i.commitTransaction(e)}}canExpandTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}groupSelection(){const t=this.diagram,i=t.model;if(!i.Hc())return;const e=this.archetypeGroupData;if(e===null)return;let s=null;try{t.currentCursor="wait",t.v("ChangingSelection",t.selection),t.startTransaction("Group");const n=new List,o=t.selection.iterator;for(;o.next();){const h=o.value;h.Pe()&&h.canGroup()&&n.add(h)}const r=new List,l=n.iterator;for(;l.next();){const h=l.value;let a=!1;const c=n.iterator;for(;c.next();){const f=c.value;if(h.isMemberOf(f)){a=!0;break}}a||r.add(h)}if(r.count>0){let h=r.first().containingGroup;if(h!==null)for(;h!==null;){let a=!1;const c=r.iterator;for(;c.next();)if(!c.value.isMemberOf(h)){a=!0;break}if(a)h=h.containingGroup;else break}if(e instanceof Group)e.li(),s=e.copy(),s!==null&&t.add(s);else if(i.isGroupForData(e)){const a=i.copyNodeData(e);Util.wt(a)&&(i.addNodeData(a),s=t.findNodeForData(a))}if(s!==null){h!==null&&this.isValidMember(h,s)&&(s.containingGroup=h);const a=r.iterator;for(;a.next();){const c=a.value;this.isValidMember(s,c)&&(c.containingGroup=s)}t.clearSelection(!0),s.isSelected=!0}}t.v("SelectionGrouped",s)}finally{t.commitTransaction("Group"),t.v("ChangedSelection",t.selection),t.currentCursor=""}}canGroupSelection(){const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowGroup||!t.model.Hc()||this.archetypeGroupData===null)return!1;const e=t.selection.iterator;for(;e.next();){const s=e.value;if(s.Pe()&&s.canGroup())return!0}return!1}i2(t){const i=Util.ot();if(Array.isArray(t))t.forEach(n=>{n instanceof Link||n instanceof Part&&i.push(n)});else{const n=t.iterator;for(;n.next();){const o=n.value;o instanceof Link||o instanceof Part&&i.push(o)}}const e=new GSet,s=i.length;for(let n=0;n0){i.clearSelection(!0);const o=s.iterator;for(;o.next();){const r=o.value;r.expandSubGraph();const l=r.containingGroup,h=l!==null&&l.data!==null?e.getKeyForNodeData(l.data):void 0;n.addAll(r.memberParts);const a=n.iterator;for(;a.next();){const c=a.value;if(c.isSelected=!0,c instanceof Link)continue;const f=c.data;f!==null?e.setGroupForData(f,h):c.containingGroup=l}i.remove(r)}}i.v("SelectionUngrouped",s,n)}finally{i.commitTransaction("Ungroup"),i.v("ChangedSelection",i.selection),i.currentCursor=""}}canUngroupSelection(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowDelete||!i.allowUngroup||!i.model.Hc())return!1;if(t!==null){if(!(t instanceof Group))return!1;if(t.canUngroup())return!0}else{const s=i.selection.iterator;for(;s.next();){const n=s.value;if(n instanceof Group&&n.canUngroup())return!0}}return!1}addTopLevelParts(t,i){const e=this.i2(t);let s=!0;const n=e.iterator;for(;n.next();){const o=n.value;o.containingGroup!==null&&(!i||this.isValidMember(null,o)?o.containingGroup=null:s=!1)}return s}collapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse SubGraph";try{i.startTransaction(e),i.animationManager.Fl(e);const n=new List;if(t!==null&&t.isSubGraphExpanded)t.collapseSubGraph(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&r.isSubGraphExpanded&&(r.collapseSubGraph(),n.add(r))}}i.v("SubGraphCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||!t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&s.isSubGraphExpanded)return!0}}return!1}expandSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Expand SubGraph",s=new List;try{if(i.startTransaction(e),i.animationManager.Fl(e),t!==null&&!t.isSubGraphExpanded)t.expandSubGraph(),s.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&(r.isSubGraphExpanded||(r.expandSubGraph(),s.add(r)))}}i.v("SubGraphExpanded",s)}finally{for(const n of s)this.$L(i,n);t&&this.$L(i,t),i.commitTransaction(e)}}$L(t,i){for(const e of i.memberParts)e instanceof Node&&t.Nc(e,i)}canExpandSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&!s.isSubGraphExpanded)return!0}}return!1}editTextBlock(t){t===void 0&&(t=null);const i=this.diagram,e=i.toolManager.findTool("TextEditing");if(e!==null){if(t===null){let s=null;const n=i.selection.iterator;for(;n.next();){const o=n.value;if(o.canEdit()){s=o;break}}if(s===null)return;t=s.findInVisualTree(o=>o instanceof TextBlock&&o.editable)}t!==null&&(i.currentTool=null,e.textBlock=t,i.currentTool=e)}}canEditTextBlock(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowTextEdit||i.toolManager.findTool("TextEditing")===null)return!1;if(t!==null){if(!(t instanceof TextBlock))return!1;const e=t.part;if(e!==null&&e.canEdit())return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s.canEdit()&&(t=s.findInVisualTree(n=>n instanceof TextBlock&&n.editable),t!==null))return!0}}return!1}showContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");if(e===null)return;t===void 0&&(i.selection.count>0?t=i.selection.first():t=i);const s=e.findObjectWithContextMenu(t);if(s!==null){const n=i.lastInput;let o=null;if(s instanceof GraphObject)o=s.getDocumentPoint(Spot.Center);else if(!i.viewportBounds.containsPoint(n.documentPoint)){const r=i.viewportBounds;o=new Point(r.x+r.width/2,r.y+r.height/2)}if(o!==null){const r=new InputEvent;r.diagram=i,r.viewPoint=i.transformDocToView(o),r.documentPoint=o,r.button=2,r.up=!0,i.lastInput=r}i.currentTool=e,e.openMenu(!1,s)}}canShowContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");return!(e===null||(t===void 0&&(i.selection.count>0?t=i.selection.first():t=i),e.findObjectWithContextMenu(t)===null))}get copiesClipboardData(){return this.YS}set copiesClipboardData(t){Util.i(t,"boolean",CommandHandler,"copiesClipboardData"),this.YS=t}get copiesConnectedLinks(){return this.GS}set copiesConnectedLinks(t){Util.i(t,"boolean",CommandHandler,"copiesConnectedLinks"),this.GS=t}get deletesConnectedLinks(){return this.jS}set deletesConnectedLinks(t){Util.i(t,"boolean",CommandHandler,"deletesConnectedLinks"),this.jS=t}get copiesTree(){return this.HS}set copiesTree(t){Util.i(t,"boolean",CommandHandler,"copiesTree"),this.HS=t}get deletesTree(){return this.qS}set deletesTree(t){Util.i(t,"boolean",CommandHandler,"deletesTree"),this.qS=t}get copiesParentKey(){return this.WS}set copiesParentKey(t){Util.i(t,"boolean",CommandHandler,"copiesParentKey"),this.WS=t}get copiesGroupKey(){return this.JS}set copiesGroupKey(t){Util.i(t,"boolean",CommandHandler,"copiesGroupKey"),this.JS=t}get archetypeGroupData(){return this.$S}set archetypeGroupData(t){t!==null&&Util.i(t,"object",CommandHandler,"archetypeGroupData");const i=this.diagram;this.$S=t}get memberValidation(){return this.eh}set memberValidation(t){t!==null&&Util.i(t,"function",CommandHandler,"memberValidation"),this.eh=t}get defaultScale(){return this.diagram.defaultScale}set defaultScale(t){this.diagram.defaultScale=t}get zoomFactor(){return this.ZS}set zoomFactor(t){t>1||Util.o("zoomFactor must be larger than 1.0, not: "+t),this.ZS=t}get isZoomToFitRestoreEnabled(){return this._S}set isZoomToFitRestoreEnabled(t){Util.i(t,"boolean",CommandHandler,"isZoomToFitRestoreEnabled"),this._S=t}get scrollToPartPause(){return this.t2}set scrollToPartPause(t){this.t2=t}computeEffectiveCollection(t,i){const e=this.diagram,s=e.toolManager.findTool("Dragging"),n=e.currentTool===s;i===void 0&&(i=e.c0());const o=new GMap;if(t===null)return o;let r=t.iterator;for(;r.next();){const l=r.value;e.Wr(o,l,n,i)}if(e.draggedLink!==null&&i.dragsLink)return o;for(r=t.iterator;r.next();){const l=r.value;if(l instanceof Link){const h=l.fromNode;if(h!==null&&!o.has(h))o.delete(l);else{const a=l.toNode;a!==null&&!o.has(a)&&o.delete(l)}}}return o}}var Stretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Vertical=4]="Vertical",w[w.Horizontal=5]="Horizontal",w[w.Fill=2]="Fill",w))(Stretch||{}),Orientation=(w=>(w[w.None=0]="None",w[w.Along=21]="Along",w[w.Plus90=22]="Plus90",w[w.Minus90=23]="Minus90",w[w.Opposite=24]="Opposite",w[w.Upright=25]="Upright",w[w.Plus90Upright=26]="Plus90Upright",w[w.Minus90Upright=27]="Minus90Upright",w[w.Upright45=28]="Upright45",w))(Orientation||{}),Flip=(w=>(w[w.None=0]="None",w[w.Vertical=1]="Vertical",w[w.Horizontal=2]="Horizontal",w[w.Both=3]="Both",w))(Flip||{});class GraphObject{n;qu;Wu;Bo;f;nh;q;ct;ee;Wt;Ju;Vs;Ct;ze;$r;oh;bi;aa;st;Xt;Zr;Li;Vi;$u;ni;qc;Ut;si;Qr;e2;Zu;constructor(){GSet.Yi(this),this.n=30723,this.Wt=1,this.Ju="",this.Vs=null,this.Ct=null,this.ct=new Point(NaN,NaN).g(),this.ze=Size.gw,this.$r=new Transform,this.oh=new Transform,this.bi=null,this.aa=1,this.st=1,this.Xt=0,this.Zr=Margin.Ug,this.ee=new Rect(NaN,NaN,NaN,NaN).g(),this.Li=new Rect(NaN,NaN,NaN,NaN).g(),this.Vi=new Rect(0,0,NaN,NaN).g(),this.$u=null,this.qu=null,this.q=null,this.ni=Spot.Default,this.qc=Spot.Default,this.Wu=0,this.Bo=0,this.Ut=null,this.f=null,this.nh=null,this.si=null,this.e2=null,this.Qr=null,this.Zu=null}cloneProtected(t){t.n=(this.n|2048|4096)&-32769,t.Wt=this.Wt,t.Ju=this.Ju,t.Ct=this.Ct,t.ct.a(this.ct),t.ze=this.ze.N(),this.bi!==null?t.bi=this.bi.copy():t.bi=null,t.st=this.st,t.Xt=this.Xt,t.Zr=this.Zr.N(),t.ee.a(this.ee),t.Li.a(this.Li),t.Vi.a(this.Vi),t.qu=this.qu,this.q!==null&&(t.q=this.q.copy()),t.ni=this.ni.N(),t.qc=this.qc.N(),t.Wu=this.Wu,t.Bo=this.Bo,this.Ut!==null&&(t.Ut=this.Ut.copy()),this.f!==null&&(this.f.gi?t.f=this.f:t.f=this.f.copy()),this.nh!==null&&(t.nh=this.nh.slice()),this.si!==null&&(t.si=this.si.copy())}addCopyProperty(t){let i=this.nh;if(!Array.isArray(i))i=[],this.nh=i;else for(let e=0;e{d.data!==null&&d.s2()&&d.updateTargetBindings(i)})}}}}mF(t){this.Zu.delete(t)}Io(){if(this.diagram===null)return;if(this.findBindingPanel()===null&&this.Ai!==null){const i=this.Ai.iterator;for(;i.next();){const e=i.value;if(!e.isToTheme)continue;let s=null;const n=e.sourceName;e.isToObject&&(s=this.ZL(n));let o=this;const r=e.targetId;r!==-1&&(o=this.p0(r),o===null)||(n==="/"?s=o.part:n==="."?s=o:n===".."&&(s=o.panel),e.updateTarget(o,s))}}}pa(t,i){const e=this.findBindingPanel();if(e!==null){const s=this.Ai.iterator;for(;s.next();){const n=s.value;let o=null;if(n.isToObject){if(o=n.QL(e,this),o===null)continue;n.updateSource(this,o,i,null)}else if(n.isToModel){const r=t.diagram;r!==null&&!r.ce&&n.updateSource(this,r.model.modelData,i,e)}else if(!n.isToTheme){const r=e.data;if(r===null)continue;const l=t.diagram;l!==null&&!l.ce&&n.updateSource(this,r,i,e)}if(o===this){const r=n.targetId,l=e.p0(r);l!==null&&n.updateTarget(l,o,i)}}}}p0(t){return this.$n===t?this:null}ZL(t){let i;return t===""?i=this:t==="/"?i=this:t==="."?i=this:t===".."?i=this:i=this.part.findObject(t),i}get $n(){return this.f!==null?this.f.$n:-1}set $n(t){this.$n!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.$n=t)}get Ai(){return this.f!==null?this.f.Ai:null}set Ai(t){this.Ai!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.Ai=t)}get Zn(){return this.f!==null?this.f.Zn:null}set Zn(t){this.Zn!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.Zn=t)}raiseChanged(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}t(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}Qn(t,i,e,s){const n=this.ee;if(n.e(t,i,e,s),this.st!==1||this.Xt!==0){this.bi===null&&(this.bi=new Transform);const o=this.bi;o.Ri(),this.y0(o,t,i,e,s),o.xw(n)}}_L(t,i,e){return this.pickable===!1?!1:(e.tc(this.D),i?this.intersectsRect(t,e):this.containedInRect(t,e))}tA(t,i,e){if(this.pickable===!1)return!1;const s=this.naturalBounds,n=t.distanceSquaredPoint(i);return e?Point.distanceLineSegmentSquared(t.x,t.y,0,0,0,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,0,s.height,s.width,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,s.height,s.width,0)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,0,0,0)<=n:t.distanceSquared(0,0)<=n&&t.distanceSquared(0,s.height)<=n&&t.distanceSquared(s.width,0)<=n&&t.distanceSquared(s.width,s.height)<=n}pn(){return!0}containsPoint(t){const i=Point.l();i.a(t),this.D.xt(i);const e=this.actualBounds;if(!e.isReal())return Point.s(i),!1;const s=this.diagram;if(s!==null&&s.Qm){const o=s.getInputOption("extraTouchThreshold"),r=s.getInputOption("extraTouchArea"),l=r/2,h=this.naturalBounds,a=this.getDocumentScale()*s.scale,c=1/a;if(h.width*ae&&(f=t),isFinite(i)&&i>s&&(u=i);break;case 5:isFinite(t)&&t>e&&(f=t),u=0,d&&(i=1/0);break;case 4:isFinite(i)&&i>s&&(u=i),f=0,d&&(t=1/0);break}const g=this.maxSize,p=this.minSize;f>g.width&&p.widthg.height&&p.heightu.height||this.mi>u.width)&&(r=!0)}}}r?this.n|=256:this.n&=-257,this.Li.isReal()||Util.o("Non-real actualBounds has been set. Object "+this+", actualBounds: "+this.Li.toString()),this.ed(o,this.Li),this._n(!1),Rect.s(o)}hh(t,i,e,s){}commonArrange(t,i,e,s){if(this.Li.e(t,i,e,s),this.desiredSize.isReal())return;const n=this.ee,o=this.Zr,r=o.right+o.left,l=o.top+o.bottom,h=n.width+r,a=n.height+l;e+=r,s+=l;let c=this.zs(!0);switch(h===e&&a===s&&(c=0),c){case 0:(h>e||a>s)&&(this.fe(!0),this.ut(h>e?e:h,a>s?s:a,0,0));break;case 2:this.fe(!0),this.ut(e,s,0,0);break;case 5:this.fe(!0),this.ut(e,a,0,0);break;case 4:this.fe(!0),this.ut(h,s,0,0);break}}ed(t,i){const e=this.part;e!==null&&e.diagram!==null&&((e.selectionObject===this||e.resizeObject===this||e.rotateObject===this)&&e.o2(!0),this.C(),!t.equalsApproxClose(i)&&(e.ah(),this.b0(e)))}b0(t){this.portId!==null&&(t.o2(!0),t instanceof Node&&t.iA(this))}get shadowVisible(){return this.f!==null?this.f.k0:null}set shadowVisible(t){const i=this.shadowVisible;i!==t&&(this.jt(),this.f.k0=t,this.ss(!0),this.C(),this.t("shadowVisible",i,t))}NR(t,i){const e=this.naturalBounds,s=this.oh,n=s.m11,o=s.m21,r=s.dx,l=s.m12,h=s.m22,a=s.dy;let c=0,f=0,u=c,d=f;c=u*n+d*o+r,f=u*l+d*h+a;let m=c,g=f,p=0,y=0;u=e.width+i,d=0,c=u*n+d*o+r,f=u*l+d*h+a;let x=Math.min(m,c),k=Math.min(g,f);p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-k,m=x,g=k,u=e.width+i,d=e.height+i,c=u*n+d*o+r,f=u*l+d*h+a,x=Math.min(m,c),k=Math.min(g,f),p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-k,m=x,g=k,u=0,d=e.height+i,c=u*n+d*o+r,f=u*l+d*h+a,x=Math.min(m,c),k=Math.min(g,f),p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-k,m=x,g=k;const b=t.viewportBounds,P=b.x,M=b.y,L=b.width,C=b.height;return m>L+P||P>p+m||g>C+M||M>y+g}Gi(t,i){if(this.CR(t,i)||!this.visible)return;const e=this.opacity;if(e===0)return;let s=1;e!==1&&(s=t.globalAlpha,t.globalAlpha=s*e);let n="";this.filter!==""&&(n=t.filter,t.filter=this.filter);const o=this.D,r=this.panel;this.w0()===!0&&this.Fb();const l=this.part;let h=!1,a=0;if(l&&i.getRenderingHint("drawShadows")&&(h=l.isShadowed,h)){const g=l.shadowOffset;a=Math.max(g.y,g.x)*i.scale*i.Bi}const c=this instanceof Panel&&this._r(),f=this.Li;if(c&&(this.eA(h,t,!1,r),this.LR(t,i),this.sA(h,t,!1,r),this.nA(h,t,!1)),c||!c&&(f.width===0||f.height===0||isNaN(f.x)||isNaN(f.y))){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}const u=this.Xs();if(!i.Zh&&u&&this.NR(i,a)){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}let d=(this.n&256)!==0;if(t.clipInsteadOfFill&&(d=!1),this instanceof TextBlock&&(t.font=this.font),d){const g=r.pn()?r.naturalBounds:r.actualBounds;let p=Math.max(f.x,g.x),y=Math.max(f.y,g.y),x=Math.min(f.right,g.right)-p,k=Math.min(f.bottom,g.bottom)-y;const b=this.si;if(b!==null&&(p=b.x,y=b.y,x=b.width,k=b.height),p>f.width+f.x||f.x>g.width+g.x){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}t.save(),t.beginPath(),t.rect(p,y,x,k),t.clip()}if(u){if(!l.isVisible()){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}if(h){const g=l.shadowOffset;t.shadowsSet(g.x*i.scale*this.scale*i.Bi,g.y*i.scale*this.scale*i.Bi,l.shadowBlur),t.shadowsOn(),t.shadowColor=l.shadowColor}}const m=this.naturalBounds;if(t.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.eA(h,t,u,r),this.Ct!==null&&(t.commitTransform(),this.Rb(t,m,f)),this.sA(h,t,u,r),this.ch(t,i),this.nA(h,t,u),d&&(t.restore(),t.clearContextCache(this instanceof Panel)),!o.Ok()){const g=1/(o.m11*o.m22-o.m12*o.m21);t.transform(o.m22*g,-o.m12*g,-o.m21*g,o.m11*g,g*(o.m21*o.dy-o.m22*o.dx),g*(o.m12*o.dx-o.m11*o.dy))}e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n)}eA(t,i,e,s){t&&this.shadowVisible===!0?i.shadowsOn():t&&this.shadowVisible===!1&&i.shadowsOff(),t&&this.vb(s)&&this.shadowVisible===null&&i.shadowsOff()}sA(t,i,e,s){t&&(this.Ct!==null||this.vb(s))?(this.Ob(!0),this.shadowVisible===null&&i.shadowsOff()):this.Ob(!1)}nA(t,i,e){t&&this.l2()===!0&&i.shadowsOn(),e&&t&&i.shadowsOff()}AR(t,i,e){const s=this.part;let n=!1;s&&t.getRenderingHint("drawShadows")&&(n=s.isShadowed),i.clipInsteadOfFill&&(n=!1),this.Xs()&&n&&i.shadowsOn(),n&&this.shadowVisible===!0?i.shadowsOn():n&&this.shadowVisible===!1&&i.shadowsOff();const o=this.panel;if(n&&this.vb(o)&&this.shadowVisible===null&&i.shadowsOff(),i.tl){const r=t.computePixelRatio(),l=`drop-shadow(${i.shadowOffsetX/r}px ${i.shadowOffsetY/r}px ${i.shadowBlur/r/2}px ${i.shadowColor})`;this.background!==null&&e.Ct.setAttributeNS(null,"filter",l)}return n&&(this.Ct!==null||this.vb(o))?(this.Ob(!0),this.shadowVisible===null&&i.shadowsOff()):this.Ob(!1),n}TR(t,i,e,s){if(e.tl){const n=i.computePixelRatio(),o=`drop-shadow(${e.shadowOffsetX/n}px ${e.shadowOffsetY/n}px ${e.shadowBlur/n/2}px ${e.shadowColor})`;this.h2(t,o)}s&&this.l2()===!0&&e.shadowsOn(),this.Xs()&&e.shadowsOff()}vb(t){return t===null?!1:(t._r()&&(t=t.panel),t.l2()||(t.type===Panel.Auto||t.type===Panel.Spot)&&t.findMainElement()!==this)}h2(t,i){}Rb(t,i,e){const s=this.Db(),n=i.x,o=i.y,r=i.width+s,l=i.height+s;this.dn(t,this.Ct,!0,!1,i,e),this.Ct instanceof Brush&&this.Ct.type===3?(t.beginPath(),t.rect(n-s/2,o-s/2,r,l),t.fillContext(this.Ct,!1,null)):t.fillRect(n-s/2,o-s/2,r,l)}oA(t,i){let e=t.DR(this);if(e!==-1)if(e===0)if(t.svg.Ct)t.svg.Ct.after(i);else if(t.type===Panel.Table){const s=t.svg.getElementsByClassName("gojs-ts"),n=s.length!==0?s[0]:null;n!==null&&n.after(i)}else t.svg.prepend(i);else{for(;e!==0&&!t.elt(e-1).isVisibleObject();)e--;if(e===0)t.svg.prepend(i);else{const s=t.elt(e-1).svg;s!==null?s.after(i):t.svg.appendChild(i)}}}CR(t,i){if(!(t instanceof SVGContext))return!1;if(!this.visible||this.opacity===0)return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;if(this.Xs()&&!this.isVisible())return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;const e=this.panel,s=this.sd(t);if(this.Zc(t,i,s))return this.rA(this.svg),this.svg.parentElement!==null?(this.Xs()&&(t.lastDrawnPart=this.svg),!0):(this.Xs()?(t.lastDrawnPart!==null?t.lastDrawnPart.after(this.svg):t.diagramGroup.prepend(this.svg),t.lastDrawnPart=this.svg):e&&this.oA(e,this.svg),!0);if(this.Xs()&&this.isShadowed){const m=this.shadowOffset;t.shadowsSet(m.x*i.scale*this.scale*i.Bi,m.y*i.scale*this.scale*i.Bi,this.shadowBlur),t.shadowsOn(),t.shadowColor=this.shadowColor}this instanceof TextBlock&&(t.font=this.font),t.currentElement=null;const n=this.D,o=this instanceof Panel,r=this instanceof Panel?this._r():!1,l=this.svg;this.w0()===!0&&this.Fb();const h=this.Li;t.setCurrentTransform(1,0,0,1,0,0),t.outerGroup=!1,s&&(t.outerGroup=!0,o&&r?(t.newGroup(1,0,0,1,0,0),this.svg=t.lastCreatedElement):o?(t.newGroup(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.svg=t.lastCreatedElement):t.newGroup(1,0,0,1,0,0));const a=this.naturalBounds;o||t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.background!==null&&(o?(r&&t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.Rb(t,a,h),r&&t.setCurrentTransform(1,0,0,1,0,0)):(t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.Rb(t,a,h)),t.currentElement.Ct=t.lastCreatedElement,t.currentElement.prepend(t.lastCreatedElement));const c=this.AR(i,t,t.currentElement);this.ch(t,i),o&&t.endGroup(),t.outerGroup&&t.endGroup();const f=t.surface.ju,u=o?this.svg:t.currentElement;if(!o&&l!==null&&u!==l&&l.parentNode===this.panel.svg){const m=this.svg.getAttribute("filter");return m!==null&&u.setAttribute("filter",m),this.svg.replaceWith(u),this.svg=u,u!==null&&this.P0(t,e,h,u),this.lA(t,l),!0}if(this.svg=u,f!==null&&u===null&&t.dummyGroup(),u===null)return!0;this.P0(t,e,h,u),this.TR(u,i,t,c);const d=this.Xs()?this.opacity*t.globalAlpha:this.opacity;if(d!==1&&u.setAttributeNS(null,"opacity",d.toString()),this.filter!==""&&u.setAttributeNS(null,"filter",this.filter),this.Xs()){if(l!==null&&u!==l&&l.parentNode===t.diagramGroup){const m=l.getAttribute("filter");m!==null&&u.setAttribute("filter",m),l.replaceWith(u)}else t.lastDrawnPart?t.lastDrawnPart.after(u):t.diagramGroup.prepend(u);t.lastDrawnPart=u}else e!==null&&this.oA(e,u);return f!==null&&f(this,u),this.rA(u),!0}rA(t){const i=this,e=t.dataset;i instanceof GraphObject&&(i.portId!==null&&(e.portId=i.portId),i instanceof Panel&&(isNaN(i.itemIndex)||(e.itemIndex=i.itemIndex.toString()),i instanceof Part&&(e.className=Util.sn(i),i.key!==void 0&&(e.key=i.key.toString()),i.containingGroup!==null&&(e.group=i.containingGroup.key.toString()),i instanceof Link&&(i.fromNode!==null&&i.fromNode.key!==void 0&&(e.fromKey=i.fromNode.key.toString()),i.fromPortId!==""&&(e.fromPortId=i.fromPortId),i.toNode!==null&&i.toNode.key!==void 0&&(e.toKey=i.toNode.key.toString()),i.toPortId!==""&&(e.toPortId=i.toPortId)))))}P0(t,i,e,s){let n=(this.n&256)!==0;if(t.clipInsteadOfFill&&(n=!1),!n){s.removeAttributeNS(null,"clip-path"),this.lA(t,s);return}const o=i.pn()?i.naturalBounds:i.actualBounds;let r=Math.max(e.x,o.x),l=Math.max(e.y,o.y),h=Math.min(e.right,o.right)-r,a=Math.min(e.bottom,o.bottom)-l;const c=this.si;c!==null&&(r=c.x,l=c.y,h=c.width,a=c.height);const f=s.getAttribute("clip-path");let u=null;if(f!==null&&(u=t.svg.getElementById(f.split("#")[1].slice(0,-1))),u===null){const d="CLIP"+GSet.nu++,m={id:d},g=t.makeElement("clipPath",m),p=t.makeElement("rect",{x:r,y:l,width:h,height:a});if(this instanceof Panel){const y=this.D.copy().yw();p.setAttribute("transform",`matrix(${y.m11}, ${y.m12}, ${y.m21}, ${y.m22}, ${y.dx}, ${y.dy})`)}g.appendChild(p),t.svg.appendChild(g),s.setAttributeNS(null,"clip-path","url(#"+d+")")}else{const d=u.firstElementChild;d.setAttribute("x",r.toString()),d.setAttribute("y",l.toString()),d.setAttribute("width",h.toString()),d.setAttribute("height",a.toString())}}lA(t,i){const e=i.getAttribute("clip-path");if(e===null)return;const s=t.svg.getElementById(e.split("#")[1].slice(0,-1));s!==null&&s.remove()}FR(){if(this.svg===null)return;const t=this.svg.innerHTML.match(/url\(#((CLIP|GRAD).+?)\)/g),i=this.svg.ownerDocument;if(t!==null)for(const e of t){const s=i.getElementById(e.split("#")[1].slice(0,-1));s!==null&&s.remove()}this.svg.remove()}LR(t,i){const e=this.Li,s=this.Vi,n=this.Ct;n!==null&&t.commitTransform(),n!==null&&(this.dn(t,n,!0,!1,s,e),n instanceof Brush&&n.type===3?(t.beginPath(),t.rect(e.x,e.y,e.width,e.height),t.fillContext(n,!1,null)):t.fillRect(e.x,e.y,e.width,e.height)),this.ch(t,i)}ch(t,i){}a2(){this.ss(!0)}Zc(t,i,e){const s=this.svg;if(this.RR()){if(this.a2(),this.ss(!1),s===null)return!1;const a=this.svg.getAttribute("clip-path");if(a!==null){const c=t.svg.getElementById(a.split("#")[1].slice(0,-1));c!==null&&c.remove()}return!1}if(s===null)return!1;if(!this.visible)return s.remove(),!1;if(s.nodeName!=="g"&&e||s.nodeName==="g"&&!e)return!1;const n=this.D,o="matrix("+n.m11+", "+n.m12+", "+n.m21+", "+n.m22+", "+n.dx+", "+n.dy+")",r=this instanceof Panel,l=this instanceof Panel?this._r():!1;if(!(r&&l))if(this instanceof Picture){const a=this.Ib;t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),a!==null&&t.amendImageTransform(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]),e?s.lastElementChild.setAttributeNS(null,"transform",t.getCurrentTransform()):s.setAttributeNS(null,"transform",t.getCurrentTransform())}else if(e&&!(this instanceof Panel))if(this instanceof Shape){const a=s.getElementsByTagName("path");for(let c=0;c=.1;){if(g){for(l=o[d++%h],l-=r;l<0;)l+=o[d++%h],m=!m;g=!1}else l=o[d++%h];l>u&&(l=u);let p=Math.sqrt(l*l/(1+f*f));a<0&&(p=-p),i+=p,e+=f*p,m?t.lineTo(i,e):t.moveTo(i,e),u-=l,m=!m}}dn(t,i,e,s,n,o){let r=1,l=1;if(typeof i=="string"){e?t.fillStyle=i:t.strokeStyle=i;return}else if(i.type===1){e?t.fillStyle=i.color:t.strokeStyle=i.color;return}let h;const a=this.Db();r=n.width,l=n.height,s?(r=o.width,l=o.height):e||(r+=a,l+=a);const c=t instanceof CanvasSurfaceContext;if(c&&i.yn&&(i.type===4||i.Qc===r&&i.Eb===l))h=i.yn;else{let f=0,u=0,d=0,m=0,g=0,p=0,y=0,x=0;if(s?(y=o.x,x=o.y):e||(y-=a/2,x-=a/2),f=i.start.x*r+i.start.offsetX+y,u=i.start.y*l+i.start.offsetY+x,d=i.end.x*r+i.end.offsetX+y,m=i.end.y*l+i.end.offsetY+x,i.type===2)h=t.createLinearGradient(f,u,d,m);else if(i.type===3)p=isNaN(i.endRadius)?Math.max(r,l)/2:i.endRadius,isNaN(i.startRadius)?(g=0,p=Math.max(r,l)/2):g=i.startRadius,h=t.createRadialGradient(f,u,g,d,m,p);else if(i.type===4)try{h=t.createPattern(i.pattern,"repeat")}catch{h=null}else Util.we(i.type,"Brush type");if(i.type!==4){const k=i.colorStops;if(k!==null){const b=k.iterator;for(;b.next();)h.addColorStop(b.key,b.value)}}if(c&&(i.yn=h,h!==null&&(i.Qc=r,i.Eb=l),h===null&&i.type===4&&i.Qc!==-1)){i.Qc=-1;const k=this.diagram;k!==null&&i.Qc===-1&&Util.vh(()=>{k.redraw()},600)}}e?t.fillStyle=h:t.strokeStyle=h}isContainedBy(t){return t instanceof Panel?this.vR(this,t):!1}vR(t,i){if(t===i||i===null)return!1;let e=t.panel;for(;e!==null;){if(e===i)return!0;e=e.panel}return!1}isVisibleObject(){if(!this.visible)return!1;const t=this.panel;return t!==null?t.isVisibleObject():!0}isEnabledObject(){let t=this instanceof Panel?this:this.panel;for(;t!==null&&t.isEnabled;)t=t.panel;return t===null}get enabledChanged(){return this.f!==null?this.f.M0:null}set enabledChanged(t){const i=this.enabledChanged;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"enabledChanged"),this.jt(),this.f.M0=t,this.t("enabledChanged",i,t))}Fb(){if(this.Ub()===!0){const t=this.$r;if(t.Ri(),!this.Li.isReal()||!this.ee.isReal()){this.nd(!1);return}if(t.Ds(this.Li.x-this.ee.x,this.Li.y-this.ee.y),this.scale!==1||this.angle!==0){const i=this.naturalBounds;this.y0(t,i.x,i.y,i.width,i.height)}this.nd(!1),this.ya(!0)}if(this.w0()===!0){const t=this.panel;if(t===null)this.oh.set(this.$r),this.aa=this.scale;else if(t.Es!==null){const i=this.oh;i.Ri(),t.pn()?i.tc(t.oh):t.panel!==null&&i.tc(t.panel.oh),i.tc(this.$r),this.aa=this.scale*t.aa}this.ya(!1)}}y0(t,i,e,s,n){if(this.st!==1&&t.st(this.st),this.Xt===0)return;const o=Point.l();o.setSpot(i,e,s,n,Spot.Center),t.cs(this.Xt,o.x,o.y),Point.s(o)}c(t){if(this.Oo())return;t===void 0&&(t=!1),this.fe(!0),this._n(!0);const i=this.panel;i!==null&&!t&&i.c()}_c(){this.Oo()||(this.fe(!0),this._n(!0))}tf(t){if(this.is())return;const i=this.panel;!t&&i!==null&&i.c(),this._n(!0)}td(){this.Ub()===!1&&(this.nd(!0),this.ya(!0))}c2(){this.ya(!0)}C(){const t=this.part;t!==null&&t.C()}zs(t){const i=this.stretch,e=this.panel;if(e===null)return this.zo(i===1?0:i,t);if(e.type===Panel.Table)return this.S0(e.getRowDefinition(this.row),e.getColumnDefinition(this.column),t);if(e.type===Panel.Auto&&e.findMainElement()===this)return this.zo(2,t);if(i===1){if(e.type===Panel.Spot&&e.findMainElement()===this)return this.zo(2,t);const s=e.defaultStretch;return s===1?this.zo(0,t):this.zo(s,t)}return this.zo(i,t)}S0(t,i,e){const s=this.stretch;if(s!==1)return this.zo(s,e);let n=null,o=null;switch(t.stretch){case 1:case 5:break;case 4:o=!0;break;case 2:o=!0;break}switch(i.stretch){case 1:case 4:break;case 5:n=!0;break;case 2:n=!0;break}const r=this.panel.defaultStretch;return n===null&&(n=r===5||r===2),o===null&&(o=r===4||r===2),n===!0&&o===!0?this.zo(2,e):n===!0?this.zo(5,e):o===!0?this.zo(4,e):this.zo(0,e)}zo(t,i){if(i)return t;if(t===0)return 0;const e=this.desiredSize;if(e.isReal())return 0;const s=!isNaN(e.width),n=!isNaN(e.height),o=this.angle;if(s)if(o!==90&&o!==270){if(t===5)return 0;if(t===2)return 4}else{if(t===4)return 0;if(t===2)return 5}if(n)if(o!==90&&o!==270){if(t===4)return 0;if(t===2)return 5}else{if(t===5)return 0;if(t===2)return 4}return t}get segmentOrientation(){return this.Ut!==null?this.Ut.N0:0}set segmentOrientation(t){const i=this.segmentOrientation;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.N0=t,this.c(),this.t("segmentOrientation",i,t),t===0&&(this.angle=0))}OR(){this.segmentOrientation=21}get segmentIndex(){return this.Ut!==null?this.Ut.C0:-1/0}set segmentIndex(t){t=Math.round(t);const i=this.segmentIndex;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.C0=t,this.c(),this.t("segmentIndex",i,t))}get segmentFraction(){return this.Ut!==null?this.Ut.L0:0}set segmentFraction(t){isNaN(t)||t<0?t=0:t>1&&(t=1);const i=this.segmentFraction;i!==t&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.L0=t,this.c(),this.t("segmentFraction",i,t))}get segmentOffset(){return this.Ut!==null?this.Ut.A0:Point.Po}set segmentOffset(t){const i=this.segmentOffset;i.equals(t)||(t=t.N(),this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.A0=t,this.c(),this.t("segmentOffset",i,t))}get stretch(){return this.f!==null?this.f.to:1}set stretch(t){const i=this.stretch;i!==t&&(this.jt(),this.f.to=t,this.c(),this.t("stretch",i,t))}get name(){return this.f!==null?this.f.St:""}set name(t){const i=this.name;i!==t&&(this.jt(),this.f.St=t,this.part!==null&&this.part.T0(),this.t("name",i,t))}get opacity(){return this.Wt}set opacity(t){const i=this.Wt;if(i!==t){Util.i(t,"number",GraphObject,"opacity"),(t<0||t>1)&&Util._(t,"0 <= value <= 1",GraphObject,"opacity"),this.Wt=t,this.t("opacity",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.C(s.jh(s.actualBounds))}}get filter(){return this.Ju}set filter(t){const i=this.Ju;if(i!==t){this.Ju=t,this.ss(!0),this.t("filter",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.C(s.jh(s.actualBounds))}}get visible(){return(this.n&1)!==0}set visible(t){const i=(this.n&1)!==0;if(i!==t){this.n=this.n^1,this.t("visible",i,t);const e=this.panel;e!==null?e.c():this.Xs()&&this.Ei(t),this.C(),this.hA()}}get pickable(){return(this.n&2)!==0}set pickable(t){const i=(this.n&2)!==0;i!==t&&(this.n=this.n^2,this.t("pickable",i,t))}get fromLinkableDuplicates(){return(this.n&4)!==0}set fromLinkableDuplicates(t){const i=(this.n&4)!==0;i!==t&&(this.n=this.n^4,this.t("fromLinkableDuplicates",i,t))}get fromLinkableSelfNode(){return(this.n&8)!==0}set fromLinkableSelfNode(t){const i=(this.n&8)!==0;i!==t&&(this.n=this.n^8,this.t("fromLinkableSelfNode",i,t))}get toLinkableDuplicates(){return(this.n&16)!==0}set toLinkableDuplicates(t){const i=(this.n&16)!==0;i!==t&&(this.n=this.n^16,this.t("toLinkableDuplicates",i,t))}get toLinkableSelfNode(){return(this.n&32)!==0}set toLinkableSelfNode(t){const i=(this.n&32)!==0;i!==t&&(this.n=this.n^32,this.t("toLinkableSelfNode",i,t))}get isPanelMain(){return(this.n&64)!==0}set isPanelMain(t){const i=(this.n&64)!==0;i!==t&&(this.n=this.n^64,this.c(),this.t("isPanelMain",i,t))}get isActionable(){return(this.n&128)!==0}set isActionable(t){const i=(this.n&128)!==0;i!==t&&(this.n=this.n^128,this.t("isActionable",i,t))}get background(){return this.Ct}set background(t){const i=this.Ct;i!==t&&(t!==null&&Brush.od(t,"GraphObject.background"),t instanceof Brush&&t.g(),this.Ct=t,this.C(),this.t("background",i,t))}l2(){return(this.n&512)!==0}Ob(t){t?this.n|=512:this.n&=-513}Jc(){return(this.n&1024)!==0}f2(t){t?this.n|=1024:this.n&=-1025}Ub(){return(this.n&2048)!==0}nd(t){t?this.n|=2048:this.n&=-2049}w0(){return(this.n&4096)!==0}ya(t){t?this.n|=4096:this.n&=-4097}Oo(){return(this.n&8192)!==0}fe(t){t?this.n|=8192:this.n&=-8193}is(){return(this.n&16384)!==0}_n(t){t?this.n|=16384:this.n&=-16385}RR(){return(this.n&32768)!==0}ss(t){t?this.n|=32768:this.n&=-32769}get part(){if(this.Xs())return this;if(this.Qr!==null)return this.Qr;let t=this;for(t=t.panel;t;){if(t instanceof Part)return this.Qr=t,t;t=t.panel}return null}get svg(){return this.e2}set svg(t){this.e2=t}Fu(){this.svg=null}get panel(){return this.Vs}wa(t){this.Vs=t,this.svg!==null&&this.svg.remove()}get layer(){const t=this.part;return t!==null?t.layer:null}get diagram(){const t=this.part;return t!==null?t.diagram:null}get position(){return this.ct}set position(t){const i=t.x,e=t.y,s=this.ct,n=s.x,o=s.y;n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e))?(t=t.copy(),this.u2(t,n,o)&&this.t("position",new Point(n,o),t)):this.d2()}d2(){}u2(t,i,e){return this.ct=t,this.tf(),!0}xc(t,i,e){this.ct.x===t&&this.ct.y===i||(this.ct.e(t,i),this.td())}get actualBounds(){return this.Li}get scale(){return this.st}set scale(t){const i=this.st;i!==t&&(t<=0&&Util.o("GraphObject.scale for "+this+" must be greater than zero, not: "+t),this.st=t,this.c(),this.t("scale",i,t))}get angle(){return this.Xt}set angle(t){const i=this.Xt;if(i!==t){if(t=t%360,t<0&&(t+=360),i===t)return;this.Xt=t,this.hA(),this.c(),this.t("angle",i,t)}}get desiredSize(){return this.ze}set desiredSize(t){const i=t.width,e=t.height,s=this.ze,n=s.width,o=s.height;if((n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e)))&&(t=t.N(),this.ze=t,this.c(),this instanceof Shape&&this.ie(),this.t("desiredSize",s,t),this.Jc())){const r=this.part;r!==null&&(this.pa(r,"width"),this.pa(r,"height"))}}get width(){return this.ze.width}set width(t){const i=this.ze.width;if(i!==t&&(!isNaN(i)||!isNaN(t))){const e=this.ze,s=new Size(t,this.ze.height).g();if(this.ze=s,this.c(),this instanceof Shape&&this.ie(),this.t("desiredSize",e,s),this.Jc()){const n=this.part;n!==null&&this.pa(n,"width")}}}get height(){return this.ze.height}set height(t){const i=this.ze.height;if(i!==t&&(!isNaN(i)||!isNaN(t))){const e=this.ze,s=new Size(this.ze.width,t).g();if(this.ze=s,this.c(),this instanceof Shape&&this.ie(),this.t("desiredSize",e,s),this.Jc()){const n=this.part;n!==null&&this.pa(n,"height")}}}get minSize(){return this.f!==null?this.f.xr:Size.lu}set minSize(t){const i=this.minSize;i.equals(t)||(t=t.copy(),isNaN(t.width)&&(t.width=0),isNaN(t.height)&&(t.height=0),t.g(),this.jt(),this.f.xr=t,this.c(),this.t("minSize",i,t))}get maxSize(){return this.f!==null?this.f.br:Size.sC}set maxSize(t){const i=this.maxSize;i.equals(t)||(t=t.copy(),isNaN(t.width)&&(t.width=1/0),isNaN(t.height)&&(t.height=1/0),t.g(),this.jt(),this.f.br=t,this.c(),this.t("maxSize",i,t))}get measuredBounds(){return this.ee}get naturalBounds(){return this.Vi}Db(){return 0}get margin(){return this.Zr}set margin(t){typeof t=="number"&&(t=new Margin(t));const i=this.Zr;i.equals(t)||(t=t.N(),this.Zr=t,this.c(),this.t("margin",i,t))}get D(){return this.Ub()===!0&&this.Fb(),this.$r}get Es(){return this.w0()===!0&&this.Fb(),this.oh}trigger(t,i,e){let s=null;return typeof t=="string"?s=new AnimationTrigger(t,i,e):s=t,s.ke=this,this.ys===null&&(this.ys=new GMap),this.ys.set(s.propertyName,s),this}get ys(){return this.f!==null?this.f.ys:null}set ys(t){this.ys!==t&&(this.jt(),this.f.ys=t)}get wr(){return this.f!==null?this.f.wr:0}set wr(t){this.wr!==t&&(this.jt(),this.f.wr=t)}get alignment(){return this.ni}set alignment(t){const i=this.ni;i.equals(t)||(t.isNoSpot()&&!t.isDefault()&&Util.o("GraphObject.alignment for "+this+" must be a real Spot or Spot.Default, not: "+t),t=t.N(),this.ni=t,this.tf(),this.t("alignment",i,t))}get column(){return this.Bo}set column(t){t=Math.round(t);const i=this.Bo;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"column"),this.Bo=t,this.c(),this.t("column",i,t),this.svg!==null&&this.svg.remove())}get columnSpan(){return this.f!==null?this.f.D0:1}set columnSpan(t){t=Math.round(t);const i=this.columnSpan;i!==t&&(t<1&&Util._(t,">= 1",GraphObject,"columnSpan"),this.jt(),this.f.D0=t,this.c(),this.t("columnSpan",i,t))}get row(){return this.Wu}set row(t){t=Math.round(t);const i=this.Wu;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"row"),this.Wu=t,this.c(),this.t("row",i,t),this.svg!==null&&this.svg.remove())}get rowSpan(){return this.f!==null?this.f.F0:1}set rowSpan(t){t=Math.round(t);const i=this.rowSpan;i!==t&&(t<1&&Util._(t,">= 1",GraphObject,"rowSpan"),this.jt(),this.f.F0=t,this.c(),this.t("rowSpan",i,t))}get spanAllocation(){return this.f!==null?this.f.R0:null}set spanAllocation(t){const i=this.spanAllocation;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"spanAllocation"),this.jt(),this.f.R0=t,this.c(),this.t("spanAllocation",i,t))}get alignmentFocus(){return this.qc}set alignmentFocus(t){const i=this.qc;i.equals(t)||(t=t.N(),this.qc=t,this.c(),this.t("alignmentFocus",i,t))}get portId(){return this.qu}set portId(t){const i=this.qu;if(i!==t){const e=this.part;e!==null&&!(e instanceof Node)&&Util.o("Cannot set portID on a Link: "+t);const s=e;i!==null&&s!==null&&s.g2(this),this.qu=t,t!==null&&s!==null&&(s.wn=!0,s.aA(this)),this.t("portId",i,t)}}xa(){const t=this.part;if(t instanceof Node&&(this.portId!==null||this===t.port)){const i=t.diagram;i!==null&&!i.undoManager.isUndoingRedoing&&t.iA(this)}}hA(){const t=this.diagram;t===null||t.undoManager.isUndoingRedoing||(this instanceof Panel?this instanceof Node?this.invalidateConnectedLinks():this.walkVisualTreeFrom(this,i=>{i.xa()}):this.xa())}get toSpot(){return this.q!==null?this.q.fa:Spot.None}set toSpot(t){const i=this.toSpot;i.equals(t)||(t=t.N(),this.Xe(),this.q.fa=t,this.t("toSpot",i,t),this.xa())}get toEndSegmentLength(){return this.q!==null?this.q.da:10}set toEndSegmentLength(t){const i=this.toEndSegmentLength;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"toEndSegmentLength"),this.Xe(),this.q.da=t,this.t("toEndSegmentLength",i,t),this.xa())}get toShortLength(){return this.q!==null?this.q.ma:0}set toShortLength(t){const i=this.toShortLength;i!==t&&(this.Xe(),this.q.ma=t,this.t("toShortLength",i,t),this.xa())}get toLinkable(){return this.q!==null?this.q.v0:null}set toLinkable(t){const i=this.toLinkable;i!==t&&(this.Xe(),this.q.v0=t,this.t("toLinkable",i,t))}get toMaxLinks(){return this.q!==null?this.q.O0:1/0}set toMaxLinks(t){const i=this.toMaxLinks;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"toMaxLinks"),this.Xe(),this.q.O0=t,this.t("toMaxLinks",i,t))}get fromSpot(){return this.q!==null?this.q.ca:Spot.None}set fromSpot(t){const i=this.fromSpot;i.equals(t)||(t=t.N(),this.Xe(),this.q.ca=t,this.t("fromSpot",i,t),this.xa())}get fromEndSegmentLength(){return this.q!==null?this.q.ua:10}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"fromEndSegmentLength"),this.Xe(),this.q.ua=t,this.t("fromEndSegmentLength",i,t),this.xa())}get fromShortLength(){return this.q!==null?this.q.ga:0}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(this.Xe(),this.q.ga=t,this.t("fromShortLength",i,t),this.xa())}get fromLinkable(){return this.q!==null?this.q.I0:null}set fromLinkable(t){const i=this.fromLinkable;i!==t&&(this.Xe(),this.q.I0=t,this.t("fromLinkable",i,t))}get fromMaxLinks(){return this.q!==null?this.q.E0:1/0}set fromMaxLinks(t){const i=this.fromMaxLinks;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"fromMaxLinks"),this.Xe(),this.q.E0=t,this.t("fromMaxLinks",i,t))}get cursor(){return this.f!==null?this.f.Ml:""}set cursor(t){const i=this.cursor;i!==t&&(Util.i(t,"string",GraphObject,"cursor"),this.jt(),this.f.Ml=t,this.t("cursor",i,t))}get click(){return this.f!==null?this.f.Tr:null}set click(t){const i=this.click;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"click"),this.jt(),this.f.Tr=t,this.t("click",i,t))}get doubleClick(){return this.f!==null?this.f.Dr:null}set doubleClick(t){const i=this.doubleClick;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"doubleClick"),this.jt(),this.f.Dr=t,this.t("doubleClick",i,t))}get contextClick(){return this.f!==null?this.f.Fr:null}set contextClick(t){const i=this.contextClick;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"contextClick"),this.jt(),this.f.Fr=t,this.t("contextClick",i,t))}get mouseEnter(){return this.f!==null?this.f.Er:null}set mouseEnter(t){const i=this.mouseEnter;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseEnter"),this.jt(),this.f.Er=t,this.t("mouseEnter",i,t))}get mouseLeave(){return this.f!==null?this.f.Ur:null}set mouseLeave(t){const i=this.mouseLeave;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseLeave"),this.jt(),this.f.Ur=t,this.t("mouseLeave",i,t))}get mouseOver(){return this.f!==null?this.f.Rr:null}set mouseOver(t){const i=this.mouseOver;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseOver"),this.jt(),this.f.Rr=t,this.t("mouseOver",i,t))}get mouseHover(){return this.f!==null?this.f.vr:null}set mouseHover(t){const i=this.mouseHover;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseHover"),this.jt(),this.f.vr=t,this.t("mouseHover",i,t))}get mouseHold(){return this.f!==null?this.f.Or:null}set mouseHold(t){const i=this.mouseHold;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseHold"),this.jt(),this.f.Or=t,this.t("mouseHold",i,t))}get mouseDragEnter(){return this.f!==null?this.f.U0:null}set mouseDragEnter(t){const i=this.mouseDragEnter;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDragEnter"),this.jt(),this.f.U0=t,this.t("mouseDragEnter",i,t))}get mouseDragLeave(){return this.f!==null?this.f.B0:null}set mouseDragLeave(t){const i=this.mouseDragLeave;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDragLeave"),this.jt(),this.f.B0=t,this.t("mouseDragLeave",i,t))}get mouseDrop(){return this.f!==null?this.f.Ir:null}set mouseDrop(t){const i=this.mouseDrop;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDrop"),this.jt(),this.f.Ir=t,this.t("mouseDrop",i,t))}get actionDown(){return this.f!==null?this.f.V0:null}set actionDown(t){const i=this.actionDown;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionDown"),this.jt(),this.f.V0=t,this.t("actionDown",i,t))}get actionMove(){return this.f!==null?this.f.z0:null}set actionMove(t){const i=this.actionMove;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionMove"),this.jt(),this.f.z0=t,this.t("actionMove",i,t))}get actionUp(){return this.f!==null?this.f.X0:null}set actionUp(t){const i=this.actionUp;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionUp"),this.jt(),this.f.X0=t,this.t("actionUp",i,t))}get actionCancel(){return this.f!==null?this.f.K0:null}set actionCancel(t){const i=this.actionCancel;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionCancel"),this.jt(),this.f.K0=t,this.t("actionCancel",i,t))}get toolTip(){return this.f!==null?this.f.Br:null}set toolTip(t){const i=this.toolTip;i!==t&&(this.jt(),this.f.Br=t,this.t("toolTip",i,t))}get contextMenu(){return this.f!==null?this.f.Vr:null}set contextMenu(t){const i=this.contextMenu;i!==t&&(this.jt(),this.f.Vr=t,this.t("contextMenu",i,t))}findBindingPanel(){let t=this instanceof Panel?this:this.panel;for(;t!==null;){if(t.m2())return t;t=t.panel}return null}bind(t,i,e,s){return this.ef(t,i,e,s),this}bindTwoWay(t,i,e,s){return this.ef(t,i,e,s).makeTwoWay(),this}bindModel(t,i,e,s){return this.ef(t,i,e,s).ofModel(),this}bindObject(t,i,e,s,n){return this.ef(t,i,e,s).ofObject(n),this}theme(t,i,e,s,n){return this.fh(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.fh(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.fh(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.fh(t,i,e,s,n).ofModel(),this}ef(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.Y0(n),n}fh(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.Y0(o),o}Y0(t){t.ke=this;const i=this.findBindingPanel();i!==null&&i.cA()&&Util.o("Cannot add a Binding to a template that has already been copied: "+t),this.Ai===null&&(this.Ai=new List),this.Ai.add(t)}set(t){return Object.assign(this,t),this}attach(t){return GraphObject.p2(this,t),this}apply(t){return t(this),this}setProperties(t){return Diagram.a0(this,t),this}static build(t,i,...e){const s=GraphObject.G0.get(t);if(typeof s=="function"){const n=s([t].concat(e));if(n instanceof GraphObject)return i&&n.setProperties(i),n}Util.o('GraphObject.build invoked object builder "'+t+'", but it did not return an Object')}static make(t,...i){let e=arguments,s=null,n=null;if(typeof t=="function")n=t;else if(typeof t=="string"){const r=GraphObject.G0.get(t);typeof r=="function"?(e=Array.prototype.slice.call(e),s=r(e),Util.wt(s)||Util.o('GraphObject.make invoked object builder "'+t+'", but it did not return an Object')):n=root.go[t]}s===null&&((n==null||!n.constructor)&&Util.o("GraphObject.make requires a class function or GoJS class name or name of an object builder, not: "+t),s=new n);let o=1;if(s instanceof Diagram&&e.length>1){const r=s,l=e[1];(typeof l=="string"||l instanceof HTMLDivElement)&&(r.mS(l),o++)}for(let r=o;r{const i="#f5f5f5",e="#737373",s="#d4d4d4",n="#737373",o="#a3a3a3",r=2.76142374915397,l=2.761423749153969,h=new Panel(Panel.Auto,{isActionable:!0,enabledChanged:(a,c)=>{if(a instanceof Panel){const f=a.findObject("ButtonBorder");f!==null&&(c?(a._buttonFillDisabled=f.fill,f.fill=a._buttonFillNormal):(a._buttonFillNormal=f.fill,f.fill=a._buttonFillDisabled))}},cursor:"pointer"}).attach({_buttonFillNormal:i,_buttonStrokeNormal:e,_buttonFillOver:s,_buttonStrokeOver:n,_buttonFillDisabled:o}).add(new Shape("RoundedRectangle",{name:"ButtonBorder",spot1:new Spot(0,0,r,l),spot2:new Spot(1,1,-r,-l),parameter1:2,fill:i,stroke:e}));return h.mouseEnter=(a,c,f)=>{if(!c.isEnabledObject()||!(c instanceof Panel))return;const u=c.findObject("ButtonBorder");u instanceof Shape&&(c._buttonFillNormal=u.fill,u.fill=c._buttonFillOver,c._buttonStrokeNormal=u.stroke,u.stroke=c._buttonStrokeOver)},h.mouseLeave=(a,c,f)=>{if(!c.isEnabledObject()||!(c instanceof Panel))return;const u=c.findObject("ButtonBorder");u instanceof Shape&&(u.fill=c._buttonFillNormal,u.stroke=c._buttonStrokeNormal)},h}),GraphObject.defineBuilder("TreeExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_treeExpandedFigure:"MinusLine",_treeCollapsedFigure:"PlusLine",visible:!1}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.hu}).bindObject("figure","isTreeExpanded",(e,s)=>{const n=s.panel;return e?n._treeExpandedFigure:n._treeCollapsedFigure})),i.bindObject("visible","isTreeLeaf",e=>!e),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Node))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isTreeExpanded){if(!r.canCollapseTree(n))return}else if(!r.canExpandTree(n))return;e.handled=!0,n.isTreeExpanded?r.collapseTree(n):r.expandTree(n)},i}),GraphObject.defineBuilder("SubGraphExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_subGraphExpandedFigure:"MinusLine",_subGraphCollapsedFigure:"PlusLine"}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.hu}).bindObject("figure","isSubGraphExpanded",(e,s)=>{const n=s.panel;return e?n._subGraphExpandedFigure:n._subGraphCollapsedFigure})),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Group))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isSubGraphExpanded){if(!r.canCollapseSubGraph(n))return}else if(!r.canExpandSubGraph(n))return;e.handled=!0,n.isSubGraphExpanded?r.collapseSubGraph(n):r.expandSubGraph(n)},i}),GraphObject.defineBuilder("ToolTip",t=>new Adornment(Panel.Auto,{isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).add(new Shape("RoundedRectangle",{name:"Border",parameter1:1,fill:"#f5f5f5",strokeWidth:0,spot1:new Spot(0,0,4,6),spot2:new Spot(1,1,-4,-4)}))),GraphObject.defineBuilder("ContextMenu",t=>new Adornment(Panel.Vertical,{background:"#f5f5f5",isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).bindObject("background","",i=>i.adornedPart!==null&&i.hasPlaceholder()?null:"#f5f5f5")),GraphObject.defineBuilder("ContextMenuButton",t=>{const i=GraphObject.build("Button");i.stretch=5;const e=i.findObject("ButtonBorder");return e instanceof Shape&&(e.figure="Rectangle",e.strokeWidth=0,e.spot1=new Spot(0,0,4,6),e.spot2=new Spot(1,1,-4,-4)),i}),GraphObject.defineBuilder("PanelExpanderButton",t=>{const i=GraphObject.takeBuilderArgument(t,"COLLAPSIBLE"),e=GraphObject.build("Button");e.attach({_buttonExpandedFigure:"M0 0 M0 6 L4 2 8 6 M8 8",_buttonCollapsedFigure:"M0 0 M0 2 L4 6 8 2 M8 8",_buttonFillNormal:"rgba(0, 0, 0, 0)",_buttonStrokeNormal:null,_buttonFillOver:"rgba(0, 0, 0, .2)",_buttonStrokeOver:null}),e.add(new Shape({name:"ButtonIcon",strokeWidth:2}).bindObject("geometryString","visible",n=>n?e._buttonExpandedFigure:e._buttonCollapsedFigure,void 0,i));const s=e.findObject("ButtonBorder");return s instanceof Shape&&(s.stroke=null,s.fill="rgba(0, 0, 0, 0)"),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=o.diagram;if(r===null||r.isReadOnly)return;let l=o.findBindingPanel();if(l===null&&(l=o.part),l!==null){const h=l.findObject(i);h!==null&&(n.handled=!0,r.startTransaction("Collapse/Expand Panel"),h.visible=!h.visible,r.commitTransaction("Collapse/Expand Panel"))}},e}),GraphObject.defineBuilder("CheckBoxButton",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("Button",{desiredSize:new Size(14,14)});e.attach({"ButtonBorder.spot1":new Spot(0,0,1,1),"ButtonBorder.spot2":new Spot(1,1,-1,-1)});const s=new Shape({name:"ButtonIcon",geometryString:"M0 0 M0 8.85 L4.9 13.75 16.2 2.45 M16.2 16.2",strokeWidth:2,stretch:2,geometryStretch:6,visible:!1});return i!==""&&s.bindTwoWay("visible",i),e.add(s),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=n.diagram;if(r===null||r.isReadOnly||i!==""&&r.model.isReadOnly)return;n.handled=!0;const l=o.findObject("ButtonIcon");r.startTransaction("checkbox"),l!==null&&(l.visible=!l.visible),typeof o._doClick=="function"&&o._doClick(n,o),r.commitTransaction("checkbox")},e}),GraphObject.defineBuilder("CheckBox",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("CheckBoxButton",{name:"Button",isActionable:!1,margin:new Margin(0,1,0,0)},i),s=new Panel("Horizontal",{isActionable:!0,cursor:e.cursor,margin:new Margin(1),mouseEnter:e.mouseEnter,mouseLeave:e.mouseLeave,click:e.click}).attach({_buttonFillNormal:e._buttonFillNormal,_buttonStrokeNormal:e._buttonStrokeNormal,_buttonFillOver:e._buttonFillOver,_buttonStrokeOver:e._buttonStrokeOver,_buttonFillDisabled:e._buttonFillDisabled,_buttonClick:e.click});return s.add(e),e.mouseEnter=null,e.mouseLeave=null,e.click=null,s})}}class GraphObjectTemplateSettings{gi;St;$n;Ai;Zn;Ks;Ml;Tr;Dr;Fr;Er;Ur;Rr;vr;Or;U0;B0;Ir;V0;z0;X0;K0;Br;Vr;M0;R0;ys;xr;br;to;F0;D0;wr;k0;j0;H0;constructor(){this.gi=!1,this.St="",this.$n=-1,this.Ai=null,this.Zn=null,this.Ks=null,this.Ml="",this.Tr=null,this.Dr=null,this.Fr=null,this.Er=null,this.Ur=null,this.Rr=null,this.vr=null,this.Or=null,this.U0=null,this.B0=null,this.Ir=null,this.V0=null,this.z0=null,this.X0=null,this.K0=null,this.Br=null,this.Vr=null,this.M0=null,this.R0=null,this.ys=null,this.xr=Size.lu,this.br=Size.sC,this.to=1,this.F0=1,this.D0=1,this.wr=0,this.k0=null,this.j0=null,this.H0="category"}copy(){const t=new GraphObjectTemplateSettings;return t.St=this.St,t.$n=this.$n,t.Ai=this.Ai,t.Ks=this.Ks,t.Ml=this.Ml,t.Tr=this.Tr,t.Dr=this.Dr,t.Fr=this.Fr,t.Er=this.Er,t.Ur=this.Ur,t.Rr=this.Rr,t.vr=this.vr,t.Or=this.Or,t.U0=this.U0,t.B0=this.B0,t.Ir=this.Ir,t.V0=this.V0,t.z0=this.z0,t.X0=this.X0,t.K0=this.K0,t.Br=this.Br,t.Vr=this.Vr,t.M0=this.M0,t.R0=this.R0,t.ys=this.ys,t.xr=this.xr.N(),t.br=this.br.N(),t.to=this.to,t.F0=this.F0,t.D0=this.D0,t.wr=this.wr,t.k0=this.k0,t.j0=this.j0,t.H0=this.H0,t}}class STransform{m;constructor(){this.m=[1,0,0,1,0,0]}copy(){const t=new STransform;return t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5],t}translate(t,i){this.m[4]+=this.m[0]*t+this.m[2]*i,this.m[5]+=this.m[1]*t+this.m[3]*i}scale(t,i){this.m[0]*=t,this.m[1]*=t,this.m[2]*=i,this.m[3]*=i}rotate(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return;this.translate(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m[0]*s+this.m[2]*n,r=this.m[1]*s+this.m[3]*n,l=this.m[0]*-n+this.m[2]*s,h=this.m[1]*-n+this.m[3]*s;this.m[0]=o,this.m[1]=r,this.m[2]=l,this.m[3]=h,this.translate(-i,-e)}}class SGradient{type;x1;y1;r1;x2;y2;r2;colors;pattern;constructor(t){this.type=t,this.x1=0,this.y1=0,this.r1=0,this.x2=0,this.y2=0,this.r2=0,this.colors=[],this.pattern=null}addColorStop(t,i){this.colors.push({offset:t,color:i})}}class SVGSurface{Ft;ai;ha;ju;w2;constructor(t,i,e){const s=i===void 0?root.document:i;this.ha=s,this.w2="http://www.w3.org/2000/svg";const n="http://www.w3.org/2000/xmlns/";s!==void 0&&(this.Ft=this.makeElement("svg",{width:"1px",height:"1px",viewBox:"0 0 1 1"}),this.style.display="block",this.style.letterSpacing="normal",this.style.wordSpacing="normal",e||(this.style.position="absolute"),this.Ft.setAttributeNS(n,"xmlns",this.w2),this.Ft.setAttributeNS(n,"xmlns:xlink","http://www.w3.org/1999/xlink")),this.ju=null,this.ai=new SVGContext(this,e)}resize(t,i,e,s){return this.width!==t||this.height!==i?(this.width=t,this.height=i,this.style.width=e+"px",this.style.height=s+"px",this.Ft.setAttributeNS(null,"width",e+"px"),this.Ft.setAttributeNS(null,"height",s+"px"),this.Ft.setAttributeNS(null,"viewBox","0 0 "+e+" "+s),this.ai.b2.firstElementChild.setAttributeNS(null,"width",e+"px"),this.ai.b2.firstElementChild.setAttributeNS(null,"height",s+"px"),!0):!1}makeElement(t,i,e){const s=this.ha.createElementNS(this.w2,t);if(Util.wt(i))for(const n in i)s.setAttributeNS(n==="href"?"http://www.w3.org/1999/xlink":"",n,i[n]);return e!==void 0&&(s.textContent=e),s}getBoundingClientRect(){return this.Ft.getBoundingClientRect()}focus(){this.Ft.focus()}get width(){return this.Ft.width.baseVal.value}set width(t){this.Ft.setAttribute("width",t+"px")}get height(){return this.Ft.height.baseVal.value}set height(t){this.Ft.setAttribute("height",t+"px")}dispose(){this.ha=null}get style(){return this.Ft.style}}class SVGContext{sf;nf;xn;Ti;Ke;fillStyle;font;globalAlpha;lineCap;lineDashOffset;lineJoin;lineWidth;miterLimit;shadowBlur;shadowColor;shadowOffsetX;shadowOffsetY;strokeStyle;textAlign;imageSmoothingEnabled;clipInsteadOfFill;lastCreatedElement;of;rf;surface;svg;b2;fA;Vb;Xo;uh;ba;currentElement;clipPathGroup;diagramGroup;lastDrawnPart;currentPath;outerGroup;pathAttributes;tl;Sr;filter;partClipRect;constructor(t,i){this.surface=t,this.svg=t.Ft,this.of=[],this.rf=[],this.fillStyle="#000000",this.font="10px sans-serif",this.globalAlpha=1,this.lineCap="butt",this.lineDashOffset=0,this.lineJoin="miter",this.lineWidth=1,this.miterLimit=10,this.shadowBlur=0,this.shadowColor="rgba(0, 0, 0, 0)",this.shadowOffsetX=0,this.shadowOffsetY=0,this.tl=!1,this.strokeStyle="#000000",this.textAlign="start",this.clipInsteadOfFill=!1,this.sf=0,this.nf=0,this.xn=0,this.lastCreatedElement=null,this.currentElement=null,this.Ti=[],this.pathAttributes={},this.Vb=!1,this.Xo=null,this.uh=0,this.Ke=new STransform,this.clipPathGroup=this.newGroup2(),this.diagramGroup=this.newGroup2("gojs-diagram"),this.lastDrawnPart=null,this.currentPath=null;const e=GSet.nu++,s=this.makeElement("clipPath",{id:"mainClip"+e}),n={x:0,y:0,width:t.width,height:t.height};s.appendChild(this.makeElement("rect",n)),this.b2=s,this.svg.appendChild(this.clipPathGroup),this.clipPathGroup.appendChild(this.diagramGroup),this.svg.appendChild(s),this.clipPathGroup.setAttributeNS(null,"clip-path","url(#mainClip"+e+")"),this.fA={},this.Sr=!!i,this.filter="",this.partClipRect=null}setDiagramPosScale(t,i,e,s,n,o){this.diagramGroup===void 0?this.newGroup(t,i,e,s,n,o):this.diagramGroup.setAttribute("transform","matrix("+t+", "+i+", "+e+", "+s+", "+n+", "+o+")")}resetInnerSVG(){this.diagramGroup!==null&&(this.diagramGroup.innerHTML="")}arc(t,i,e,s,n,o,r,l){const h=2*Math.PI,a=1e-6,c=h-a,f=e*Math.cos(s),u=e*Math.sin(s),d=t+f,m=i+u,g=o?0:1;let p=o?s-n:n-s;(Math.abs(r-d)>a||Math.abs(l-m)>a)&&this.Ti.push(["L",d,+m]),p<0&&(p=p%h+h),p>c?(this.Ti.push(["A",e,e,0,1,g,t-f,i-u]),this.Ti.push(["A",e,e,0,1,g,d,m])):p>a&&this.Ti.push(["A",e,e,0,+(p>=Math.PI),g,t+e*Math.cos(n),i+e*Math.sin(n)])}beginPath(){this.Ti=[],this.pathAttributes={stroke:"none",fill:"none"}}endPath(t){this.BR(this.Ti,this.Ke,t||0)}bezierCurveTo(t,i,e,s,n,o){this.Ti.push(["C",t,i,e,s,n,o])}clearRect(t,i,e,s){}clip(){this.pathAttributes.clipPath=!0}closePath(){this.Ti.push(["z"])}createLinearGradient(t,i,e,s){const n=new SGradient("linear");return n.x1=t,n.y1=i,n.x2=e,n.y2=s,n}createPattern(t,i){let e="";t instanceof HTMLCanvasElement&&(e=t.toDataURL()),t instanceof HTMLImageElement&&(e=t.getAttribute("src"));const s=this.fA;if(s[e])return"url(#"+s[e]+")";const n="PATTERN"+GSet.nu++,o={width:t.width,height:t.height,id:n,patternUnits:"userSpaceOnUse"},r={x:0,y:0,width:t.width,height:t.height,href:e},l=this.makeElement("pattern",o);return l.appendChild(this.makeElement(Diagram.img,r)),this.svg.appendChild(l),s[e]=n,"url(#"+n+")"}createRadialGradient(t,i,e,s,n,o){const r=new SGradient("radial");return r.x1=t,r.y1=i,r.r1=e,r.x2=s,r.y2=n,r.r2=o,r}amendImageTransform(t,i,e,s,n,o,r,l){const h=r/e,a=l/s;(n!==0||o!==0)&&this.Ke.translate(n,o),(h!==1||a!==1)&&this.Ke.scale(h,a),(t!==0||i!==0)&&this.Ke.translate(-t,-i)}drawImage(t,i,e,s,n,o,r,l,h){let a="";t instanceof HTMLCanvasElement&&(a=t.toDataURL()),t instanceof HTMLImageElement&&(a=t.getAttribute("src"));const c=t instanceof HTMLImageElement?t.naturalWidth:t.width,f=t instanceof HTMLImageElement?t.naturalHeight:t.height;s===void 0&&(o=i,r=e,l=s=c,h=n=f),s=s||0,n=n||0,o=o||0,r=r||0,l=l||0,h=h||0,this.amendImageTransform(i,e,s,n,o,r,l,h);const u={x:0,y:0,width:c||s,height:f||n,href:a};!Geo.K(s,l)||!Geo.K(n,h)?u.preserveAspectRatio="none":a.toLowerCase().indexOf(".svg")===-1&&a.toLowerCase().indexOf("data:image/svg")===-1&&(u.preserveAspectRatio="xMidYMid slice"),(i!==0||e!==0||s!==c||n!==f)&&(s+=i,n+=e,u["clip-path"]=`path('M ${i},${e} L ${s} ${e} L ${s} ${n} L ${i} ${n} z')`),this.processCommon(Diagram.img,u,this.Ke),this.rd(Diagram.img,u)}fill(t,i){t&&(this.pathAttributes["fill-rule"]="evenodd"),this.setFill(this.pathAttributes)}fillContext(t,i,e){this.clipInsteadOfFill?this.clip():this.fill(i,e)}fillRect(t,i,e,s){this.addRect("fill",[t,i,e,s],this.Ke)}fillBackground(t,i,e,s){const n={x:t,y:i,width:e,height:s};this.processCommon("fill",n,this.Ke),this.setFill(n),this.svg.prepend(this.makeElement("rect",n))}fillText(t,i,e){this.addText("fill",[t,i,e],this.Ke)}lineTo(t,i){this.Ti.push(["L",t,i])}moveTo(t,i){this.Ti.push(["M",t,i])}quadraticCurveTo(t,i,e,s){this.Ti.push(["Q",t,i,e,s])}rect(t,i,e,s){this.Ti.push(["M",t,i],["L",t+e,i],["L",t+e,i+s],["L",t,i+s],["z"])}restore(){this.Ke=this.of.pop(),this.Ti=this.of.pop();const t=this.of.pop();this.fillStyle=t.fillStyle,this.font=t.font,this.globalAlpha=t.globalAlpha,this.lineCap=t.lineCap,this.lineDashOffset=t.lineDashOffset,this.lineJoin=t.lineJoin,this.lineWidth=t.lineWidth,this.miterLimit=t.miterLimit,this.shadowBlur=t.shadowBlur,this.shadowColor=t.shadowColor,this.shadowOffsetX=t.shadowOffsetX,this.shadowOffsetY=t.shadowOffsetY,this.strokeStyle=t.strokeStyle,this.textAlign=t.textAlign,this.partClipRect=t.partClipRect}save(){const t={fillStyle:this.fillStyle,font:this.font,globalAlpha:this.globalAlpha,lineCap:this.lineCap,lineDashOffset:this.lineDashOffset,lineJoin:this.lineJoin,lineWidth:this.lineWidth,miterLimit:this.miterLimit,shadowBlur:this.shadowBlur,shadowColor:this.shadowColor,shadowOffsetX:this.shadowOffsetX,shadowOffsetY:this.shadowOffsetY,strokeStyle:this.strokeStyle,textAlign:this.textAlign,partClipRect:this.partClipRect};this.of.push(t);const i=[];for(let e=0;eh.offset>a.offset?1:-1);for(let h=0;h0&&this.rf[this.rf.length-1].setAttributeNS(null,"clip-path",'path("'+s+'")');return}if(n.d=s,this.processCommon("",n,i),this.currentPath!==null){const r=this.currentPath;if(r.nodeName!=="g")for(const l in n)l!=="transform"&&r.setAttributeNS(null,l,n[l]);else{const l=r.getElementsByTagName("path");for(const h in n)h!=="transform"&&l[e].setAttributeNS(null,h,n[h])}}else this.rd("path",n)}VR(t){const i=[];for(let e=0;es?(this.scale(s/n,1),this.translate((n-s)/2,0)):s>n&&(this.scale(1,n/s),this.translate(0,(s-n)/2)),this.fillOrClip(i,e),n>s?(this.translate(-(n-s)/2,0),this.scale(1/(s/n),1)):s>n&&(this.translate(0,-(s-n)/2),this.scale(1,1/(n/s))),!0}strokeContext(){this.q0||this.stroke()}fillOrClip(t,i){this.q0?this.clip(i):this.fill(t,i)}get clipInsteadOfFill(){return this.q0}set clipInsteadOfFill(t){this.q0=t}shadowsSet(t,i,e){this.sf=t,this.nf=i,this.xn=e}shadowsOff(){this.tl=!1,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0}shadowsOn(){this.tl=!0,this.shadowOffsetX=this.sf,this.shadowOffsetY=this.nf,this.shadowBlur=this.xn}enableDash(t,i){const e=this.B;e.setLineDash!==void 0&&(e.setLineDash(t),e.lineDashOffset=i)}disableDash(){const t=this.B;t.setLineDash!==void 0&&(t.setLineDash(CanvasSurfaceContext.EmptyArray),t.lineDashOffset=0)}clearContextCache(t){t&&(this.zb=""),this.Xb="",this.Kb=""}removePartFromView(t){}static EmptyArray=Object.freeze([])}var BrushType=(w=>(w[w.Solid=1]="Solid",w[w.Linear=2]="Linear",w[w.Radial=3]="Radial",w[w.Pattern=4]="Pattern",w))(BrushType||{}),ColorSpace=(w=>(w[w.Lab=1]="Lab",w[w.HSL=2]="HSL",w[w.Oklch=3]="Oklch",w))(ColorSpace||{});class ColorNumbers{n0;n1;n2;n3;constructor(){this.n0=0,this.n1=0,this.n2=0,this.n3=0}}class Brush{h;Z;ka;ei;gs;W0;J0;bn;$0;yn;Qc;Eb;constructor(t,i){if(GSet.Yi(this),this.h=!1,t===void 0)this.Z=1,this.ka="black";else if(typeof t=="string"){const s=Util.Oh(BrushType,t);s!==null?(this.Z=s,this.ka="black"):(this.Z=1,this.ka=t)}else this.Z=t,this.ka="black";const e=this.Z;if(e===2?(this.ei=Spot.TopCenter,this.gs=Spot.BottomCenter):e===3?(this.ei=Spot.Center,this.gs=Spot.Center):(this.ei=Spot.None,this.gs=Spot.None),this.W0=0,this.J0=NaN,this.bn=null,this.$0=null,this.yn=null,this.Qc=0,this.Eb=0,i){const s={};for(const n in i)isFinite(parseFloat(n))?this.addColorStop(parseFloat(n),i[n]):s[n]=i[n];Object.assign(this,s)}}copy(){const t=new Brush;return t.Z=this.Z,t.ka=this.ka,t.ei=this.ei.N(),t.gs=this.gs.N(),t.W0=this.W0,t.J0=this.J0,this.bn!==null&&(t.bn=this.bn.copy()),t.$0=this.$0,t}g(){return this.h=!0,this.bn!==null&&this.bn.g(),this}rt(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this.bn!==null&&this.bn.rt(),this}ri(t){t in BrushType?this.type=t:Util.lr(this,t)}toString(){let t="Brush(";if(this.type===1)t+=this.color;else if(this.type===2?t+="Linear ":this.type===3?t+="Radial ":this.type===4?t+="Pattern ":t+="(unknown) ",t+=this.start+" "+this.end,this.colorStops!==null){const i=this.colorStops.iterator;for(;i.next();){const e=i.key,s=i.value;t+=" "+e+":"+s}}return t+=")",t}addColorStop(t,i){return this.h&&Util.T(this),(typeof t!="number"||!isFinite(t)||t>1||t<0)&&Util._(t,"0 <= loc <= 1",Brush,"addColorStop:loc"),Util.i(i,"string",Brush,"addColorStop:color"),this.bn===null&&(this.bn=new GMap),this.bn.set(t,i),this.Z===1&&(this.type=2),this.yn=null,this}get type(){return this.Z}set type(t){this.h&&Util.T(this,t),this.Z=t,this.start.isNoSpot()&&(t===2?this.start=Spot.TopCenter:t===3&&(this.start=Spot.Center)),this.end.isNoSpot()&&(t===2?this.end=Spot.BottomCenter:t===3&&(this.end=Spot.Center)),this.yn=null}get color(){return this.ka}set color(t){this.h&&Util.T(this,t),this.ka=t,this.yn=null}get start(){return this.ei}set start(t){this.h&&Util.T(this,t),this.ei=t.N(),this.yn=null}get end(){return this.gs}set end(t){this.h&&Util.T(this,t),this.gs=t.N(),this.yn=null}get startRadius(){return this.W0}set startRadius(t){this.h&&Util.T(this,t),t<0&&Util._(t,">= zero",Brush,"startRadius"),this.W0=t,this.yn=null}get endRadius(){return this.J0}set endRadius(t){this.h&&Util.T(this,t),t<0&&Util._(t,">= zero",Brush,"endRadius"),this.J0=t,this.yn=null}get colorStops(){return this.bn}set colorStops(t){this.h&&Util.T(this,t),this.bn=t,this.yn=null}get pattern(){return this.$0}set pattern(t){this.h&&Util.T(this,t),this.$0=t,this.yn=null}static randomColor(t,i){t===void 0&&(t=128),i===void 0&&(i=Math.max(t,255));const e=Math.abs(i-t);let s=Math.floor(t+Math.random()*e).toString(16),n=Math.floor(t+Math.random()*e).toString(16),o=Math.floor(t+Math.random()*e).toString(16);return s.length<2&&(s="0"+s),n.length<2&&(n="0"+n),o.length<2&&(o="0"+o),"#"+s+n+o}static isValidColor(t){return root.CSS?root.CSS.supports("color",t):!0}static lighten(t){return Brush.lightenBy(t)}lightenBy(t,i){this.h&&Util.T(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Do(this.color),this.color=Brush.ld(e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Do(n.value),this.addColorStop(n.key,Brush.ld(e,s))}return this}static lightenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Do(t),Brush.ld(s,n)}static darken(t){return Brush.darkenBy(t)}darkenBy(t,i){this.h&&Util.T(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Do(this.color),this.color=Brush.ld(-e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Do(n.value),this.addColorStop(n.key,Brush.ld(-e,s))}return this}static darkenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Do(t),Brush.ld(-s,n)}static mix(t,i,e){Brush.Do(t);const s=Brush.G.n0,n=Brush.G.n1,o=Brush.G.n2,r=Brush.G.n3;Brush.Do(i),e===void 0&&(e=.5);const l=Math.round((Brush.G.n0-s)*e+s),h=Math.round((Brush.G.n1-n)*e+n),a=Math.round((Brush.G.n2-o)*e+o),c=Math.round((Brush.G.n3-r)*e+r);return`rgba(${l}, ${h}, ${a}, ${c})`}isDark(){if(this.type===1)return Brush.isDark(this.color);if((this.type===2||this.type===3)&&this.colorStops!==null){const t=this.colorStops;if(this.type===3)return Brush.isDark(t.first().value);if(t.get(.5)!==null)return Brush.isDark(t.get(.5));if(t.count===2){const l=t.toArray();return Brush.isDark(Brush.mix(l[0].value,l[1].value))}const i=t.iterator;let e=-1,s=-1,n=1,o=1;for(;i.next();){const l=i.key,h=Math.abs(.5-i.key);n>o&&h=n&&hs){let l=e;e=s,s=l,l=n,n=o,o=l}const r=s-e;return Brush.isDark(Brush.mix(t.get(e),t.get(s),1-o/r))}return!1}static isDark(t){return t?t instanceof Brush?t.isDark():(Brush.Do(t),(299*Brush.G.n0+587*Brush.G.n1+114*Brush.G.n2)/1e3<128):!1}static ld(t,i){switch(i){case 1:return Brush.zR(),Brush.io.n0=Math.min(100,Math.max(0,Brush.io.n0+100*t)),Brush.XR(),"rgba("+Brush.G.n0+", "+Brush.G.n1+", "+Brush.G.n2+", "+Brush.G.n3+")";case 2:return Brush.OM(),Brush.Ii.n2=Math.min(100,Math.max(0,Brush.Ii.n2+100*t)),"hsla("+Brush.Ii.n0+", "+Brush.Ii.n1+"%, "+Brush.Ii.n2+"%, "+Brush.Ii.n3+")";case 3:return Brush.KR(),Brush.eo.n0=Math.min(100,Math.max(0,Brush.eo.n0+100*t)),Brush.YR(),"rgba("+Brush.G.n0+", "+Brush.G.n1+", "+Brush.G.n2+", "+Brush.G.n3+")";default:Util.o("Unknown color space: "+i)}}static Do(t){const i=Brush.il;if(i===null)return;i.clearRect(0,0,1,1),i.fillStyle="#000000";const e=i.fillStyle;if(i.fillStyle=t,i.fillStyle!==e){i.fillRect(0,0,1,1);const s=i.getImageData(0,0,1,1).data;Brush.G.n0=s[0],Brush.G.n1=s[1],Brush.G.n2=s[2],Brush.G.n3=s[3]/255}else{i.fillStyle="#FFFFFF";const s=i.fillStyle;i.fillStyle=t,i.fillStyle,Brush.G.n0=0,Brush.G.n1=0,Brush.G.n2=0,Brush.G.n3=1}}static OM(){const t=Brush.G.n0/255,i=Brush.G.n1/255,e=Brush.G.n2/255,s=Math.max(t,i,e),n=Math.min(t,i,e),o=s-n;let r,l;const h=(s+n)/2;if(o===0)r=l=0;else{switch(s){case t:r=(i-e)/o%6;break;case i:r=(e-t)/o+2;break;case e:r=(t-i)/o+4;break}r*=60,r<0&&(r+=360),l=o/(1-Math.abs(2*h-1))}Brush.Ii.n0=Math.round(r),Brush.Ii.n1=Math.round(l*100),Brush.Ii.n2=Math.round(h*100),Brush.Ii.n3=Brush.G.n3}static dE(){const t=Brush.Ii.n0,i=Brush.Ii.n1/100,e=Brush.Ii.n2/100;let s,n,o;const r=(1-Math.abs(2*e-1))*i,l=t/60,h=r*(1-Math.abs(l%2-1));l>=0&&l<1?(s=r,n=h,o=0):l>=1&&l<2?(s=h,n=r,o=0):l>=2&&l<3?(s=0,n=r,o=h):l>=3&&l<4?(s=0,n=h,o=r):l>=4&&l<5?(s=h,n=0,o=r):l>=5&&l<6&&(s=r,n=0,o=h);const a=e-.5*r;s+=a,n+=a,o+=a,Brush.G.n0=Math.round(s*255),Brush.G.n1=Math.round(n*255),Brush.G.n2=Math.round(o*255),Brush.G.n3=Brush.Ii.n3}static zR(){Brush.uA(),Brush.GR()}static XR(){Brush.jR(),Brush.dA()}static k2(t){return t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}static P2(t){return t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055}static uA(){const t=Brush.k2(Brush.G.n0),i=Brush.k2(Brush.G.n1),e=Brush.k2(Brush.G.n2);Brush.Rt.n0=.4124564*t+.3575761*i+.1804375*e,Brush.Rt.n1=.2126729*t+.7151522*i+.072175*e,Brush.Rt.n2=.0193339*t+.119192*i+.9503041*e,Brush.Rt.n3=Brush.G.n3}static dA(){const t=3.2404542*Brush.Rt.n0+-1.5371385*Brush.Rt.n1+-.4985314*Brush.Rt.n2,i=-.969266*Brush.Rt.n0+1.8760108*Brush.Rt.n1+.041556*Brush.Rt.n2,e=.0556434*Brush.Rt.n0+-.2040259*Brush.Rt.n1+1.0572252*Brush.Rt.n2;Brush.G.n0=Brush.P2(t)*255,Brush.G.n1=Brush.P2(i)*255,Brush.G.n2=Brush.P2(e)*255,Brush.G.n3=Brush.Rt.n3,Brush.G.n0=Math.round(Brush.G.n0),Brush.G.n0>255?Brush.G.n0=255:Brush.G.n0<0&&(Brush.G.n0=0),Brush.G.n1=Math.round(Brush.G.n1),Brush.G.n1>255?Brush.G.n1=255:Brush.G.n1<0&&(Brush.G.n1=0),Brush.G.n2=Math.round(Brush.G.n2),Brush.G.n2>255?Brush.G.n2=255:Brush.G.n2<0&&(Brush.G.n2=0)}static M2=216/24389;static Yb=24389/27;static hd=[95.047,100,108.883];static S2(t){return t>Brush.M2?Math.pow(t,1/3):(Brush.Yb*t+16)/116}static GR(){const t=Brush.S2(Brush.Rt.n0*100/Brush.hd[0]),i=Brush.S2(Brush.Rt.n1*100/Brush.hd[1]),e=Brush.S2(Brush.Rt.n2*100/Brush.hd[2]);Brush.io.n0=116*i-16,Brush.io.n1=500*(t-i),Brush.io.n2=200*(i-e),Brush.io.n3=Brush.Rt.n3}static gA(t){const i=t*t*t;return i>Brush.M2?i:(116*t-16)/Brush.Yb}static jR(){const t=(Brush.io.n0+16)/116,i=Brush.io.n1/500+t,e=t-Brush.io.n2/200;Brush.Rt.n0=Brush.hd[0]/100*Brush.gA(i),Brush.Rt.n1=Brush.hd[1]/100*(Brush.io.n0>Brush.Yb*Brush.M2?Math.pow(t,3):Brush.io.n0/Brush.Yb),Brush.Rt.n2=Brush.hd[2]/100*Brush.gA(e),Brush.Rt.n3=Brush.io.n3}static HR(){let t=.8190224*Brush.Rt.n0+.3619062*Brush.Rt.n1+-.1288737*Brush.Rt.n2,i=.03298366*Brush.Rt.n0+.9292868*Brush.Rt.n1+.03614466*Brush.Rt.n2,e=.04817719*Brush.Rt.n0+.2642395*Brush.Rt.n1+.6335478*Brush.Rt.n2;t=Math.cbrt(t),i=Math.cbrt(i),e=Math.cbrt(e),Brush.ci.n0=.2104542*t+.7936177*i+-.004072046*e,Brush.ci.n1=1.977998*t+-2.428592*i+.4505937*e,Brush.ci.n2=.02590403*t+.7827717*i+-.8086757*e,Brush.ci.n3=Brush.Rt.n3,Brush.ci.n0*=100}static qR(){Brush.ci.n0/=100;let t=.9999999*Brush.ci.n0+.3963377*Brush.ci.n1+.2158037*Brush.ci.n2,i=1.000000009*Brush.ci.n0+-.1055613*Brush.ci.n1+-.06385417*Brush.ci.n2,e=1.00000005*Brush.ci.n0+-.08948418*Brush.ci.n1+-1.291485*Brush.ci.n2;t=t**3,i=i**3,e=e**3,Brush.Rt.n0=1.2268798*t+-.5578149*i+.281391*e,Brush.Rt.n1=-.04057576*t+1.112286*i+-.07171106*e,Brush.Rt.n2=-.07637294*t+-.4214933*i+1.586924*e,Brush.Rt.n3=Brush.ci.n3}static WR(){const t=Math.atan2(Brush.ci.n2,Brush.ci.n1)*180/Math.PI;Brush.eo.n0=Brush.ci.n0,Brush.eo.n1=Math.sqrt(Brush.ci.n1**2+Brush.ci.n2**2),Brush.eo.n2=t>=0?t:t+360,Brush.eo.n3=Brush.ci.n3}static JR(){Brush.ci.n0=Brush.eo.n0,Brush.ci.n1=Brush.eo.n1*Math.cos(Brush.eo.n2*Math.PI/180),Brush.ci.n2=Brush.eo.n1*Math.sin(Brush.eo.n2*Math.PI/180),Brush.ci.n3=Brush.eo.n3}static KR(){Brush.uA(),Brush.HR(),Brush.WR()}static YR(){Brush.JR(),Brush.qR(),Brush.dA()}static od(t,i){typeof t=="string"||t instanceof Brush||Util.o("Value for "+i+" must be a color string or a Brush, not "+t)}static Solid=1;static Linear=2;static Radial=3;static Pattern=4;static Lab=1;static HSL=2;static il=Diagram.isUsingDOM()?new CanvasSurface(null,void 0,{willReadFrequently:!0}).ai:null;static G=new ColorNumbers;static Ii=new ColorNumbers;static Rt=new ColorNumbers;static io=new ColorNumbers;static ci=new ColorNumbers;static eo=new ColorNumbers}class PanelLayout{St="Base";static Layouts=new GMap;static definePanelLayout(t,i){i.name=t,PanelLayout.Layouts.set(t,i)}get name(){return this.St}set name(t){this.St=t}constructor(){}get classType(){return Panel}measure(t,i,e,s,n,o,r){}measureElement(t,i,e,s,n){t.ut(i,e,s,n)}arrange(t,i,e){}arrangeElement(t,i,e,s,n,o){t.zt(i,e,s,n,o)}remeasureObject(t){t._c()}Gi(t,i,e){}}class PanelLayoutPosition extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=s.length,h=t.Ko();for(let a=0;a0&&(S=Math.max(Math.abs(k.x*o+k.offsetX-(M.x*o+M.offsetX))-g,0)),r>0&&(N=Math.max(Math.abs(k.y*r+k.offsetY-(M.y*r+M.offsetY))-g,0));const T=Size.l();T.e(0,0);const A=t.Ko();for(let v=0;v1,ot=it.columnSpan>1;(ct||ot)&&!(Ky&&(S=Math.max(y-dt,0)),b.ji=b.ji+S,b.actual=b.nt+S,y=Math.max(y-(S+(mt?dt:0)),0)}if(it.columnSpan===1&&(N===0||N===4)){b=t.getColumnDefinition(j);const dt=b.computeEffectiveSpacing(),mt=b.nt===0;S=Math.max(ut-b.actual,0),S+(mt?dt:0)>p&&(S=Math.max(p-dt,0)),b.ji=b.ji+S,b.actual=b.nt+S,p=Math.max(p-(S+(mt?dt:0)),0)}(ct||ot)&&it._c()}}}Util.tt(f);let A=0,D=0;l=t.columnCount;for(let K=0;K=t.rowCount);Z++)b=t.getRowDefinition(I.row+Z),S=0,N===2||N===4?S=Math.max(b.minimum,V[I.row+Z]===0?b.maximum:Math.min(V[I.row+Z],b.maximum)):S=Math.max(b.minimum,isNaN(b.de)?b.maximum:Math.min(b.de,b.maximum)),E.height+=S,_+=b.minimum;for(let Z=1;Z=t.columnCount);Z++)b=t.getColumnDefinition(I.column+Z),S=0,N===2||N===5?S=Math.max(b.minimum,B[I.column+Z]===0?b.maximum:Math.min(B[I.column+Z],b.maximum)):S=Math.max(b.minimum,isNaN(b.de)?b.maximum:Math.min(b.de,b.maximum)),E.width+=S,et+=b.minimum;X.width+=E.width,X.height+=E.height;const tt=I.margin,it=tt.right+tt.left,ct=tt.top+tt.bottom;I.ut(X.width,X.height,et,_);const ot=I.measuredBounds,lt=Math.max(ot.width+it,0),st=Math.max(ot.height+ct,0);let nt=0;for(let Z=0;Z=t.rowCount);Z++)b=t.getRowDefinition(I.row+Z),nt+=b.total||0;if(nt=t.rowCount);at++){b=t.getRowDefinition(I.row+at);const ut=b.nt||0,gt=rt(I,b,ft);b.actual=Math.min(b.maximum,ut+gt),b.nt!==ut&&(Z-=b.nt-ut)}}for(;Z>0;){const rt=b.nt||0;if(isNaN(b.height)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+Z),b.nt!==rt&&(Z-=b.nt-rt)),b.index===0)break;b=t.getRowDefinition(b.index-1)}}let ht=0;for(let Z=0;Z=t.columnCount);Z++)b=t.getColumnDefinition(I.column+Z),ht+=b.total||0;if(ht=t.columnCount);at++){b=t.getColumnDefinition(I.column+at);const ut=b.nt||0,gt=rt(I,b,ft);b.actual=Math.min(b.maximum,ut+gt),b.nt!==ut&&(Z-=b.nt-ut)}}for(;Z>0;){const rt=b.nt||0;if(isNaN(b.width)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+Z),b.nt!==rt&&(Z-=b.nt-rt)),b.index===0)break;b=t.getColumnDefinition(b.index-1)}}}Util.tt(u),Size.s(E),Size.s(X),V!==void 0&&Util.tt(V),B!==void 0&&Util.tt(B);let Y=0,G=0;const H=t.desiredSize,J=t.maxSize;N=t.zs(!0),A=0,D=0;let z=0,W=0;l=t.columnCount;for(let K=0;K0){for(;p!==c&&(u[p]===void 0||u[p].nt===0);)p++;p=Math.max(Math.min(p,c-1),0),m=-u[p].position}let y=Math.min(t.leftIndex,f-1);if(d.length>0){for(;y!==f&&(d[y]===void 0||d[y].nt===0);)y++;y=Math.max(Math.min(y,f-1),0),g=-d[y].position}let x=0,k=0;for(;x!==c&&u[x]===void 0;)x++;for(;k!==c&&d[k]===void 0;)k++;const b=t.part;let P=t.getRowDefinition(x),M=t.getColumnDefinition(k);for(let C=0;C=t.rowCount);st++){const nt=t.getRowDefinition(C+st);nt.nt!==0&&(L.height+=nt.total)}for(let st=1;st=t.columnCount);st++){const nt=t.getColumnDefinition(N+st);nt.nt!==0&&(L.width+=nt.total)}const O=T.nt+L.width,U=S.nt+L.height;let X=h,E=a;const V=O,B=U,Y=h,G=a;let H=O,J=U;h+O>e.width&&(H=Math.max(e.width-h,0)),a+U>e.height&&(J=Math.max(e.height-a,0));let z=R.alignment,W=0,q=0,Q=0,K=0;if(z.isDefault()){z=t.defaultAlignment,z.isSpot()||(z=Spot.Center),W=z.x,q=z.y,Q=z.offsetX,K=z.offsetY;const st=T.alignment,nt=S.alignment;st.isSpot()&&(W=st.x,Q=st.offsetX),nt.isSpot()&&(q=nt.y,K=nt.offsetY)}else W=z.x,q=z.y,Q=z.offsetX,K=z.offsetY;(isNaN(W)||isNaN(q))&&(W=.5,q=.5,Q=0,K=0);let I=v.width,j=v.height;const $=R.margin,et=$.left+$.right,_=$.top+$.bottom,tt=R.S0(S,T,!1);isNaN(R.desiredSize.width)&&(tt===2||tt===5)&&(I=Math.max(O-et,0)),isNaN(R.desiredSize.height)&&(tt===2||tt===4)&&(j=Math.max(U-_,0));const it=R.maxSize,ct=R.minSize;I=Math.min(it.width,I),j=Math.min(it.height,j),I=Math.max(ct.width,I),j=Math.max(ct.height,j);const ot=I+et,lt=j+_;X+=V*W-ot*W+Q+$.left,E+=B*q-lt*q+K+$.top,R.visible&&(Rect.contains(Y,G,H,J,X,E,v.width,v.height)?R.zt(X,E,I,j):R.zt(X,E,I,j,new Rect(Y,G,H,J)))}}}Size.s(L);for(let C=0;C0&&(b.figure==="LineV"||b.figure==="LineH")){if(i.lineWidth=b.strokeWidth,t.dn(i,b.stroke,!1,!1,l,h),i.beginPath(),b.figure==="LineV"){const D=Math.floor((m-o)/o);for(let F=D;F<=D+f;F++){const R=F*o+m;0<=R&&R<=a&&this.jb(F,P,L,N)&&(i.moveTo(R,0),i.lineTo(R,c))}}else if(b.figure==="LineH"){const D=Math.floor((g-r)/r);for(let F=D;F<=D+u;F++){const R=F*r+g;0<=R&&R<=c&&this.jb(F,P,L,N)&&(i.moveTo(0,R),i.lineTo(a,R))}}i.stroke(),i.endPath()}else if(b.fill!==null){if(t.dn(i,b.fill,!0,!1,l,h),b.figure==="BarV"){let D=b.width;isNaN(D)&&(D=o);const F=Math.floor((m-o)/o);for(let R=F;R<=F+f;R++){const v=R*o+m;0<=v+D&&v<=a&&this.jb(R,P,L,N)&&i.fillRect(v,0,D,c)}}else if(b.figure==="BarH"){let D=b.height;isNaN(D)&&(D=r);const F=Math.floor((g-r)/r);for(let R=F;R<=F+u;R++){const v=R*r+g;0<=v+D&&v<=c&&this.jb(R,P,L,N)&&i.fillRect(0,v,a,D)}}}T&&i.disableDash(),C!==1&&(i.globalAlpha=S)}}jb(t,i,e,s){if(i<0)return t%i===e;if(t%i!==e)return!1;const n=s.length;for(let o=0;ol&&r.push(d)}}t.xi.Z0=i}A2(t){return t==="LineV"||t==="BarV"}$R(t){let i=1,e=1;const s=t.L.r,n=s.length;for(let l=0;l=g){const z=Point.l();c.mA(z),O=c.midAngle,A!==0&&(v=c.computeAngle(L,A,O),L.Xt=v,L.fe(!0),L._n(!0)),F=z.x-u.x,R=z.y-u.y,Point.s(z)}else{let z,W,q=0;if(S>=0?(z=m.elt(S),W=S0?m.elt(q-1):z),O=0,z.equalsApprox(W)){let Q,K;S>=0?(Q=S>0?m.elt(S-1):z,K=S1?m.elt(q-2):W);const I=Q.distanceSquaredPoint(z),j=W.distanceSquaredPoint(K);I>j+10?O=S>=0?Q.directionPoint(z):z.directionPoint(Q):j>I+10?O=S>=0?W.directionPoint(K):K.directionPoint(W):O=S>=0?Q.directionPoint(K):K.directionPoint(Q)}else O=S>=0?z.directionPoint(W):W.directionPoint(z);A!==0&&(v=c.computeAngle(L,A,O),L.Xt=v,L.fe(!0),L._n(!0)),F=z.x+(W.x-z.x)*N-u.x,R=z.y+(W.y-z.y)*N-u.y}L.ut(1/0,1/0,0,0),C=L.measuredBounds;const U=L.naturalBounds;let X=0;L instanceof Shape&&(X=L.strokeWidth);const E=U.width+X,V=U.height+X;k.Ri(),k.Ds(-C.x,-C.y),k.st(L.scale,L.scale),k.cs(A===0?L.angle:O,E/2,V/2),(A===22||A===26)&&k.cs(90,E/2,V/2),(A===23||A===27)&&k.cs(-90,E/2,V/2),A===28&&(O>45&&O<135||O>225&&O<315)&&k.cs(-O,E/2,V/2);const B=new Rect(0,0,E,V);b.setRectSpot(B,T),k.xt(b);const Y=-b.x+X/2*L.scale,G=-b.y+X/2*L.scale;P.a(D);const H=isNaN(D.x),J=isNaN(D.y);if(H||J){const z=E/2+3,W=V/2+3,q=O>=45&&O<=135,Q=O>=225&&O<=315;A===0&&(q||Q)?(P.x=J?z:D.y,P.y=H?W:D.x,q?S>=0||isNaN(S)&&N<.5||H&&(P.y=-W):Q&&((S>=0||isNaN(S)&&N<.5)&&H&&(P.y=-W),J&&(P.x=-z))):(H&&(S>=0||isNaN(S)&&N<.5?P.x=z:P.x=-z),J&&(P.y=-W),P.rotate(O))}else P.rotate(O);F+=P.x,R+=P.y,B.e(F+Y,R+G,C.width,C.height),x.push(B),d.unionRect(B)}if(h!==null){const M=h.labelNodes;for(;M.next();)M.value.ut(1/0,1/0)}t.Yo=d,t.position.e(u.x+d.x,u.y+d.y),n.En(d.width||0,d.height||0),Transform.s(k),Point.s(b),Point.s(P)}arrange(t,i,e){const s=i.length;if(!(t instanceof Adornment||t instanceof Link))return;let n=t,o=null;t instanceof Adornment&&(o=t,n=o.adornedPart);const r=t,l=t instanceof Adornment?null:n.path,h=t.lf;if(h.length!==0){let u=0;if(l!==null&&u=2&&r instanceof Link){const u=r.labelNodes;for(;u.next();){const d=u.value;r._R(d,c,a)}}o!==null?o.ad(!1):n.ad(!1);const f=t.pA(Point.l());t.location.e(t.position.x+f.x,t.position.y+f.y),Point.s(f)}measureLinkPath(t,i,e,s){if(s.Oo()===!1)return;let n=s.strokeWidth;if(n===0&&t instanceof Adornment&&t.type===Panel.Link&&t.adornedObject instanceof Shape&&(n=t.adornedObject.strokeWidth),n=n*s.st,t instanceof Link&&t.ft!==null){const o=t.geometry.bounds;s.Qn(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else if(t instanceof Adornment&&t.adornedPart.ft!==null){const o=t.adornedPart.ft.bounds;s.Qn(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else s.Qn(-(n/2),-(n/2),i+n,e+n);s.tv(),s.fe(!1)}}PanelLayout.definePanelLayout("Link",new PanelLayoutLink);class PanelLayoutGraduated extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=t.findMainElement();t.je=[];const h=l.margin,a=h.right+h.left,c=h.top+h.bottom;l.ut(i,e,o,r);const f=l.measuredBounds,u=f.width,d=f.height,m=Math.max(u+a,0),g=Math.max(d+c,0),p=new Rect(-h.left,-h.top,m,g);t.je.push(p),n.a(p),this.determineGraduatedMarks(t,l);const y=t.ws;if(y===null)return;const x=s.length;for(let k=0;k45&&f<135||f>225&&f<315)&&P.cs(-f,k/2,b/2);const M=Rect.X(0,0,k,b),L=Point.l();L.setRectSpot(M,o),P.xt(L);const C=-L.x,S=-L.y,N=Point.l();N.a(l),isNaN(N.x)&&(N.x=k/2+3),isNaN(N.y)&&(N.y=-(b/2+3)),N.rotate(f),a+=N.x+C,c+=N.y+S;const T=new Rect(a,c,y.width,y.height),A=new Rect(y.x,y.y,y.width,y.height),D=new Rect(x.x,x.y,x.width,x.height);p.labelAngle=u,p.lineCount=n.lineCount,p.lines=n.getMetrics(),p.actualBounds=T,p.measuredBounds=A,p.naturalBounds=D,g===0?h.a(T):h.unionRect(T),Point.s(N),Point.s(L),Rect.s(M),Transform.s(P)}t.je!==null&&t.je.push(h),s.unionNoCheck(h.x,h.y,h.width,h.height)}determineGraduatedMarks(t,i){const e=i.geometry,s=i.strokeWidth,n=e.flattenedSegments,o=e.flattenedLengths,r=e.flattenedTotalLength,l=n.length;let h=0,a=0;const c=Util.ot();for(let x=0;xt.graduatedMin+S){const F=Math.floor((N-t.graduatedMin)/S);N-=F*S}const T=f[x],A=N,D=t.graduatedMax*1e-6;for(let F=1;N<=t.graduatedMax+D;F++){if(this.ev(t,N-t.graduatedTickBase,T)&&(N>t.graduatedMax&&(N=t.graduatedMax),(k.graduatedSkip===null||k instanceof TextBlock&&!k.graduatedSkip(N,k)||k instanceof Shape&&!k.graduatedSkip(N,k))&&(m=(N-t.graduatedMin)*r/t.graduatedRange,m>r&&(m=r),g<=m&&m<=p))){let R=c[L][C],v=o[L][C];for(;LM&&C.4995)return t;let o=t;if(i<.5?n>0?o=s[n-1]:Geo.K(e[0],e[e.length-2])&&Geo.K(e[1],e[e.length-1])&&(o=s[s.length-1]):i>.5&&(n+1180&&(t.9995)return(t+o)/2%360;if(r<10){const l=1-Math.abs(.5-i);return(t*l+o*(1-l))%360}}return t}iv(t){if(t.ns===null){const i=[],e=t.L.r,s=e.length;for(let n=0;nl&&r.push(c)}}t.ns=i}return t.ns}ev(t,i,e){const s=e.length;for(let n=0;n-l)return!1}return!0}Gi(t,i,e){const s=e.Zh;e.Zh=!0;const n=t.naturalBounds,o=n.width,r=n.height,l=i instanceof SVGContext;i.save(),i.beginPath(),i.rect(-1,-1,o+1,r+1),i.clip(),i.endPath();const h=t.findMainElement();h.Gi(i,e);let a=t.getDocumentScale()*e.scale;a<=0&&(a=1);const c=h.actualBounds,f=t.L.r,u=t.ws,d=f.length;for(let m=0;m(w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ViewboxStretch||{});class Panel extends GraphObject{Z;L;$t;cd;Kn;el;so;Yo;D2;O;fd;ht;xi;Qt;ud;gh;Ys;constructor(t,i){if(super(),this.Z=null,t===void 0)this.Z=Panel.Position;else if(typeof t=="string"){const e=PanelLayout.Layouts.get(t);e!==null&&(this.Z=e)}else t instanceof PanelLayout?this.Z=t:t&&(this.Z=Panel.Position,i=t);this.Z===null&&Util.o("Panel type not specified or PanelLayout not loaded: "+t),this.n|=4194304|(this.Z===Panel.Grid?1048576:0),this.L=new List,this.$t=Margin.Ug,this.cd=Spot.Default,this.Kn=1,this.el=null,this.so="",this.Yo=new Rect(NaN,NaN,NaN,NaN),this.D2=null,this.O=null,this.fd=6,this.xi=null,this.ht=null,this.Qt=null,this.ud=NaN,this.gh=null,this.Ys=null,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.Z=this.Z,t.$t=this.$t.N(),t.cd=this.cd.N(),t.Kn=this.Kn,t.so=this.so,t.Yo.a(this.Yo),this.O!==null&&(t.O=this.O.copy(t)),t.fd=this.fd,this.ht!==null&&(t.ht=this.ht.copy()),this.xi!==null&&(t.xi=this.xi.copy()),t.Qt=this.Qt,t.ud=this.ud,t.gh=this.gh}Vo(t){super.Vo(t),t.L=this.L;const i=t.L.r,e=i.length;for(let s=0;s= 0",Panel,"padding"),t=new Margin(t)):(t.left<0&&Util._(t.left,">= 0",Panel,"padding:value.left"),t.right<0&&Util._(t.right,">= 0",Panel,"padding:value.right"),t.top<0&&Util._(t.top,">= 0",Panel,"padding:value.top"),t.bottom<0&&Util._(t.bottom,">= 0",Panel,"padding:value.bottom"));const i=this.$t;i.equals(t)||(t=t.N(),this.$t=t,this.c(),this.t("padding",i,t))}get defaultAlignment(){return this.cd}set defaultAlignment(t){const i=this.cd;i.equals(t)||(t=t.N(),this.cd=t,this.c(),this.t("defaultAlignment",i,t))}get defaultStretch(){return this.Kn}set defaultStretch(t){const i=this.Kn;i!==t&&(this.Kn=t,this.c(),this.t("defaultStretch",i,t))}get defaultSeparatorPadding(){return this.O!==null?this.O.Q0:Margin.Ug}set defaultSeparatorPadding(t){typeof t=="number"&&(t=new Margin(t));const i=this.defaultSeparatorPadding;i.equals(t)||(t=t.N(),this.O===null&&(this.O=new TablePanelSettings),this.O.Q0=t,this.c(),this.t("defaultSeparatorPadding",i,t))}get defaultRowSeparatorStroke(){return this.O!==null?this.O._0:null}set defaultRowSeparatorStroke(t){const i=this.defaultRowSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.g(),this.O===null&&(this.O=new TablePanelSettings),this.O._0=t,this.C(),this.t("defaultRowSeparatorStroke",i,t))}get defaultRowSeparatorStrokeWidth(){return this.O!==null?this.O.tp:1}set defaultRowSeparatorStrokeWidth(t){const i=this.defaultRowSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.O===null&&(this.O=new TablePanelSettings),this.O.tp=t,this.c(),this.t("defaultRowSeparatorStrokeWidth",i,t))}get defaultRowSeparatorDashArray(){return this.O!==null?this.O.ip:null}set defaultRowSeparatorDashArray(t){const i=this.defaultRowSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",Panel,"defaultRowSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("defaultRowSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.O===null&&(this.O=new TablePanelSettings),this.O.ip=t,this.C(),this.t("defaultRowSeparatorDashArray",i,t)}}get defaultColumnSeparatorStroke(){return this.O!==null?this.O.ep:null}set defaultColumnSeparatorStroke(t){const i=this.defaultColumnSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.g(),this.O===null&&(this.O=new TablePanelSettings),this.O.ep=t,this.C(),this.t("defaultColumnSeparatorStroke",i,t))}get defaultColumnSeparatorStrokeWidth(){return this.O!==null?this.O.sp:1}set defaultColumnSeparatorStrokeWidth(t){const i=this.defaultColumnSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.O===null&&(this.O=new TablePanelSettings),this.O.sp=t,this.c(),this.t("defaultColumnSeparatorStrokeWidth",i,t))}get defaultColumnSeparatorDashArray(){return this.O!==null?this.O.np:null}set defaultColumnSeparatorDashArray(t){const i=this.defaultColumnSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",Panel,"defaultColumnSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("defaultColumnSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.O===null&&(this.O=new TablePanelSettings),this.O.np=t,this.C(),this.t("defaultColumnSeparatorDashArray",i,t)}}get dh(){return this.O!==null?this.O.dh:null}set dh(t){this.O===null&&(this.O=new TablePanelSettings),this.O.dh=t}get viewboxStretch(){return this.fd}set viewboxStretch(t){const i=this.fd;i!==t&&(this.fd=t,this.c(),this.t("viewboxStretch",i,t))}get gridCellSize(){return this.xi!==null?this.xi.dd:Size.eC}set gridCellSize(t){this.xi===null&&(this.xi=new GridPanelSettings);const i=this.xi.dd;if(!i.equals(t)){(!t.isReal()||t.width===0||t.height===0)&&Util.o("Invalid Panel.gridCellSize: "+t),this.xi.dd=t.N();const e=this.diagram;e!==null&&this===e.grid&&e.jr(),this.C(),this.t("gridCellSize",i,t)}}get gridOrigin(){return this.xi!==null?this.xi.gd:Point.Po}set gridOrigin(t){this.xi===null&&(this.xi=new GridPanelSettings);const i=this.xi.gd;if(!i.equals(t)){t.isReal()||Util.o("Invalid Panel.gridOrigin: "+t),this.xi.gd=t.N();const e=this.diagram;e!==null&&this===e.grid&&e.jr(),this.C(),this.t("gridOrigin",i,t)}}get graduatedMin(){return this.ht!==null?this.ht.op:0}set graduatedMin(t){const i=this.graduatedMin;if(i!==t&&(this.ht===null&&(this.ht=new GradPanelSettings),this.ht.op=t,this.c(),this.t("graduatedMin",i,t),this.Jc())){const e=this.part;e!==null&&this.pa(e,"graduatedRange")}}get graduatedMax(){return this.ht!==null?this.ht.rp:100}set graduatedMax(t){const i=this.graduatedMax;if(i!==t&&(this.ht===null&&(this.ht=new GradPanelSettings),this.ht.rp=t,this.c(),this.t("graduatedMax",i,t),this.Jc())){const e=this.part;e!==null&&this.pa(e,"graduatedRange")}}get graduatedRange(){return this.graduatedMax-this.graduatedMin}get graduatedTickUnit(){return this.ht!==null?this.ht.lp:10}set graduatedTickUnit(t){const i=this.graduatedTickUnit;i!==t&&t>0&&(this.ht===null&&(this.ht=new GradPanelSettings),this.ht.lp=t,this.c(),this.t("graduatedTickUnit",i,t))}get graduatedTickBase(){return this.ht!==null?this.ht.hp:0}set graduatedTickBase(t){const i=this.graduatedTickBase;i!==t&&(this.ht===null&&(this.ht=new GradPanelSettings),this.ht.hp=t,this.c(),this.t("graduatedTickBase",i,t))}get ws(){return this.ht!==null?this.ht.ws:null}set ws(t){this.ht!==null?this.ht.ws=t:t!==null&&(this.ht=new GradPanelSettings,this.ht.ws=t)}get je(){return this.ht!==null?this.ht.je:null}set je(t){this.ht!==null?this.ht.je=t:t!==null&&(this.ht=new GradPanelSettings,this.ht.je=t)}get ns(){return this.ht!==null?this.ht.ns:null}set ns(t){this.ht!==null?this.ht.ns=t:t!==null&&(this.ht=new GradPanelSettings,this.ht.ns=t)}get Me(){return this.ht!==null?this.ht.Me:null}set Me(t){this.ht!==null?this.ht.Me=t:t!==null&&(this.ht=new GradPanelSettings,this.ht.Me=t)}b0(t){super.b0(t);const i=this.L.r,e=i.length;for(let s=0;s0?this.Ye:null,s=this.columnCount>0?this.Ge:null;e!==null&&this.Hb(t,i,!0,e,!0),s!==null&&this.Hb(t,i,!1,s,!0),e!==null&&this.wA(t,!0,e),s!==null&&this.wA(t,!1,s),e!==null&&this.Hb(t,i,!0,e,!1),s!==null&&this.Hb(t,i,!1,s,!1)}wA(t,i,e){const s=e.length,n=this.actualBounds,o=this.naturalBounds;let r=!0;for(let l=0;lo.height)continue}else if(h.position>o.width)continue;let a=h.separatorStrokeWidth;isNaN(a)&&(a=i?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let c=h.separatorStroke;if(c===null&&(c=i?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),a===0||c===null)continue;this.dn(t,c,!1,!1,o,n);let f=!1,u=h.separatorDashArray;u===null&&(u=i?this.defaultRowSeparatorDashArray:this.defaultColumnSeparatorDashArray),u!==null&&(f=!0,t.enableDash(u,0)),t.beginPath();const d=h.position+a;i?d>o.height&&(a-=d-o.height):d>o.width&&(a-=d-o.width);let m=h.position+a/2;t.lineWidth=a;const g=this.$t;if(i){m+=g.top;const p=g.left,y=o.width-g.right;t.moveTo(p,m),t.lineTo(y,m)}else{m+=g.left;const p=g.top,y=o.height-g.bottom;t.moveTo(m,p),t.lineTo(m,y)}t.stroke(),t.endPath(),f&&t.disableDash()}}Hb(t,i,e,s,n){const o=s.length,r=this.actualBounds,l=this.naturalBounds,h=this.xA(!0),a=this.xA(!1);for(let c=0;cu)continue;let d=f.computeEffectiveSpacing(),m=f.separatorStrokeWidth;isNaN(m)&&(m=e?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let g=f.separatorStroke;g===null&&(g=e?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),(g===null||f.index===(e?h:a))&&(m=0),d-=m;const p=f.position+m;let y=d+f.actual;if(p+y>u&&(y=u-p),y<=0)continue;const x=this.$t;this.dn(t,f.background,!0,!1,l,r),e?t.fillRect(x.left,p+x.top,r.width-(x.left+x.right),y):t.fillRect(p+x.left,x.top,y,r.height-(x.top+x.bottom))}}xA(t){const i=t?this.rowCount:this.columnCount;for(let e=0;ex&&n.set(S),Point.s(S)),Point.s(M),o&&n.D(r),k}}Fu(){const t=this.L.r,i=t.length;for(let e=0;ee||h>s)&&(this.c(),this.ut(l>e?e:l,h>s?s:h,0,0));break;case 2:this.c(!0),this.ut(e+c,s+f,0,0);break;case 5:this.c(!0),this.ut(e+c,h+f,0,0);break;case 4:this.c(!0),this.ut(l+c,s+f,0,0);break}}this.Z.arrange(this,n,this.Yo)}lh(t){const i=this.naturalBounds,e=this.Ko();if(Rect.contains(0,0,i.width,i.height,t.x,t.y)){const s=this.L.r,n=s.length,o=Point.X(0,0);for(let r=n;r--;){const l=s[r];if(!(!l.visible&&l!==e)&&(o.set(t).Ie(l.D),l.containsPoint(o)))return Point.s(o),!0}return Point.s(o),this.Ct!==null}return!1}p0(t){if(this.$n===t)return this;const i=this.L.r,e=i.length;for(let s=0;sd.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;let m=f;const g=f instanceof Panel?f:null,p=Transform.l();p.set(r),(g!==null?g.Om(t,i,e,s,n,p):m._L(t,s,p))&&(i!==null&&(m=i(m)),m!==null&&(e===null||e(m))&&n.add(m)),Transform.s(p)}}return o===void 0&&Transform.s(r),s}return o===void 0&&Transform.s(r),!1}R2(t,i,e){const s=this.L.r,n=s.length;for(let o=n;o--;){const r=s[o];if(!r.visible)continue;const l=r.actualBounds,h=this.naturalBounds;if(l.x>h.width||l.y>h.height||l.x+l.width<0||l.y+l.height<0)continue;r instanceof Panel&&r.R2(t,i,e);let a=r;t!==null&&(a=t(a)),a!==null&&(i===null||i(a))&&e.add(a)}}sL(t,i,e,s,n,o){if(this.pickable===!1)return!1;e===void 0&&(e=null),s===void 0&&(s=null);const r=this.naturalBounds,l=this.pn(),h=l?t:Point.X(t.x,t.y).Ie(this.D),a=l?i:Point.X(i.x,i.y).Ie(this.D),c=h.distanceSquaredPoint(a),f=h.x>0&&h.x0&&h.yP.width||b.y>P.height||b.x+b.width<0||b.y+b.height<0))continue;if(k.pn()){const C=k.D;d.set(t).Ie(C),m.set(i).Ie(C)}else d.set(t),m.set(i);let M=k;const L=k instanceof Panel?k:null;(L!==null?L.sL(d,m,e,s,n,o):M.tA(d,m,n))&&(e!==null&&(M=e(M)),M!==null&&(s===null||s(M))&&o.add(M))}Point.s(d),Point.s(m)}return n?f:u}return!1}C2(t){let i=null;if(t instanceof Shape){i=t.spot1,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot1)}return i===null&&(i=Spot.TopLeft),i}L2(t){let i=null;if(t instanceof Shape){i=t.spot2,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot2)}return i===null&&(i=Spot.BottomRight),i}add(...t){for(let i=0;i=s.count&&t>=s.count)return;s.removeAt(r),n=r}else Util.o("element "+i.toString()+" has panel "+e.toString()+" but is not contained by it.")}(t<0||t>s.count)&&(t=s.count),s.insertAt(t,i),(t===0||i.isPanelMain)&&(this.el=null),this.Oo()||this.c(),i.c(!1),i.portId!==null?this.wn=!0:i instanceof Panel&&i.wn===!0&&(this.wn=!0),this.ns=null,this.isEnabledObject()||this.qb(i,!1);const o=this.part;if(o!==null){o.T0(),o.af(),this.wn&&o instanceof Node&&(o.wn=!0),o.wn&&o instanceof Node&&(o.se=null);const r=this.diagram;if(r!==null&&r.undoManager.isUndoingRedoing)return;n!==-1&&o.raiseChangedEvent(4,"elements",this,i,null,n,null),o.raiseChangedEvent(3,"elements",this,null,i,null,t)}}get wn(){return(this.n&8388608)!==0}set wn(t){(this.n&8388608)!==0!==t&&(this.n=this.n^8388608)}s2(){return(this.n&16777216)!==0}v2(t){t?this.n|=16777216:this.n&=-16777217}hv(t){t.wa(this),t.Qr=null;const i=this.L,e=i.count;i.insertAt(e,t);const s=this.part;if(s!==null){s.T0(),t.portId!==null&&s instanceof Node&&(s.wn=!0);const n=this.diagram;if(n!==null&&n.undoManager.isUndoingRedoing)return;s.raiseChangedEvent(3,"elements",this,null,t,null,e)}}DR(t){const i=this.L.r,e=i.length;let s=-1;for(let n=0;n=0&&this._i(t,!0)}_i(t,i){const e=this.L,s=e.elt(t);if(s.Qr=null,s.wa(null),this.Ys!==null){const o=s.data;typeof o=="object"&&this.Ys.delete(o)}e.removeAt(t),this.fe(!1),this.c(),this.el===s&&(this.el=null),this.ns=null;const n=this.part;if(n!==null){n.T0(),n.af(),n.invalidateAdornments(),n instanceof Node&&(s instanceof Panel?s.walkVisualTreeFrom(s,(r,l)=>n.g2(l,i)):n.g2(s,i));const o=this.diagram;if(o!==null&&o.undoManager.isUndoingRedoing)return;n.raiseChangedEvent(4,"elements",this,s,null,t,null)}}get Ye(){return this.O===null&&(this.O=new TablePanelSettings),this.O.Ye}get rowCount(){return this.O===null?0:this.Ye.length}getRowDefinition(t){t<0&&Util._(t,">= 0",Panel,"getRowDefinition:idx"),t=Math.round(t);const i=this.Ye;if(i[t]===void 0){const e=new RowColumnDefinition;e.wa(this),e.isRow=!0,e.index=t,i[t]=e,this.raiseChangedEvent(3,"rowdefs",this,null,e,null,t)}return i[t]}removeRowDefinition(t){if(t<0&&Util._(t,">= 0",Panel,"removeRowDefinition:idx"),this.rowCount===0)return;t=Math.round(t);const i=this.Ye,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"rowdefs",this,e,null,t,null),this.c()}}FL(t,i){const e=this.Ye;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.c()}}get Ge(){return this.O===null&&(this.O=new TablePanelSettings),this.O.Ge}get columnCount(){return this.O===null?0:this.Ge.length}getColumnDefinition(t){t<0&&Util._(t,">= 0",Panel,"getColumnDefinition:idx"),t=Math.round(t);const i=this.Ge;if(i[t]===void 0){const e=new RowColumnDefinition;e.wa(this),e.isRow=!1,e.index=t,i[t]=e,this.raiseChangedEvent(3,"coldefs",this,null,e,null,t)}return i[t]}removeColumnDefinition(t){if(t<0&&Util._(t,">= 0",Panel,"removeColumnDefinition:idx"),this.columnCount===0)return;t=Math.round(t);const i=this.Ge,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"coldefs",this,e,null,t,null),this.c()}}RL(t,i){const e=this.Ge;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.c()}}addRowColumnDefinition(t){let i=null;return t.isRow?i=this.getRowDefinition(t.index):t.isRow||(i=this.getColumnDefinition(t.index)),i&&i.Bb(t),this}addRowDefinition(t,i){const e=this.getRowDefinition(t);return e&&e.Bb(new RowColumnDefinition(i)),this}addColumnDefinition(t,i){const e=this.getColumnDefinition(t);return e&&e.Bb(new RowColumnDefinition(i)),this}get rowSizing(){return this.O!==null?this.O.cp:3}set rowSizing(t){const i=this.rowSizing;i!==t&&(this.O===null&&(this.O=new TablePanelSettings),this.O.cp=t,this.c(),this.t("rowSizing",i,t))}get columnSizing(){return this.O!==null?this.O.fp:3}set columnSizing(t){const i=this.columnSizing;i!==t&&(this.O===null&&(this.O=new TablePanelSettings),this.O.fp=t,this.c(),this.t("columnSizing",i,t))}get topIndex(){return this.O!==null?this.O.dp:0}set topIndex(t){const i=this.topIndex;i!==t&&((!isFinite(t)||t<0)&&Util.o("Panel.topIndex must be greater than zero and a real number, not: "+t),this.O===null&&(this.O=new TablePanelSettings),this.O.dp=t,this.c(),this.t("topIndex",i,t))}get leftIndex(){return this.O!==null?this.O.gp:0}set leftIndex(t){const i=this.leftIndex;i!==t&&((!isFinite(t)||t<0)&&Util.o("Panel.leftIndex must be greater than zero and a real number, not: "+t),this.O===null&&(this.O=new TablePanelSettings),this.O.gp=t,this.c(),this.t("leftIndex",i,t))}findRowForLocalY(t){if(t<0||this.type!==Panel.Table||this.rowCount===0)return-1;let i=0;const e=this.Ye,s=e.length;let n=this.topIndex;for(;n{o.rh();const r=o.Ai;if(r!==null){o.f2(!1);const l=r.iterator;for(;l.next();){const h=l.value;h.mode===2&&o.f2(!0);const a=h.sourceName;if(h.isToObject){a==="/"&&n.v2(!0);const c=h.QL(n,o);c!==null&&(i.add(c),c.Zn===null&&(c.Zn=new List),c.Zn.add(h))}t.add(h)}}if(o instanceof Panel&&o.type===Panel.Table){if(o.rowCount>0){const l=o.Ye,h=l.length;for(let a=0;a0){const l=o.Ge,h=l.length;for(let a=0;a0&&o instanceof Panel){const h=r.substring(0,l),a=r.substring(l+1),c=o.findObject(h);c!==null?(o=c,n.targetProperty=a):(Util.oi('Warning: unable to find GraphObject named "'+h+'" for Binding: '+n.toString()),o=null)}if(o instanceof RowColumnDefinition){const h=GSet.as(o.panel);n.targetId=h===void 0?-1:h,o.panel.$n=n.targetId}else if(o instanceof GraphObject){const h=GSet.as(o);n.targetId=h===void 0?-1:h,o.$n=n.targetId}else Util.o("Unknown type of binding target: "+o);n.check(o)}}return t.g(),this instanceof Part&&this.Pe()&&this.ensureBounds(),this}static gE=!1;copyTemplate(t){t===void 0&&(t=!1);const i=this.copy();return i.av(e=>{e instanceof Panel&&(e.Ks=null,e.Qt=null);const s=e.Ai;s!==null&&(e.Ai=null,s.each(o=>e.bind(o.copy())));const n=e.ys;n!==null&&(e.ys=null,n.each(o=>e.trigger(o.value.copy())))}),t&&i.li(),i}updateTargetBindings(t){const i=this.Ks;if(i===null)return;t===void 0&&(t="");const e=i.iterator;for(;e.next();){const s=e.value,n=this.SA(s,t);if(n===null)continue;const{data:o,elt:r}=n;s.isToTheme&&this.diagram===null||r!==void 0&&s.updateTarget(r,o)}}Io(){if(this.diagram!==null)if(this.m2()){const t=this.Ks.iterator;for(;t.next();){const i=t.value;if(!i.isToTheme)continue;const e=this.SA(i);if(e===null)continue;const{data:s,elt:n}=e;n!==void 0&&i.updateTarget(n,s)}}else{const t=this.L.r,i=t.length;for(let e=0;e0;let r=0;for(;n0){const i=this.L.elt(0);if(i.isPanelMain&&i instanceof Panel&&i._r())return 1}return 0}rebuildItemElements(){const t=this.ap();for(;this.L.length>t;)this._i(this.L.length-1,!1);this.NA(null,this.itemArray)}NA(t,i){const e=this.ap(),s=i;if(s===null||s.length===0){for(;this.L.length>e;)this._i(this.L.length-1,!1);return}if(this.L.length<=e){const n=s.length;for(let o=0;o(w[w.Default=1]="Default",w[w.None=2]="None",w[w.ProportionalExtra=3]="ProportionalExtra",w))(Sizing||{});class RowColumnDefinition{Vs;mp;Dt;Pa;Ma;ni;ct;pd;to;Go;yd;wd;Sa;Ct;xd;Gs;nt;ji;de;constructor(t){GSet.Yi(this),this.Vs=null,this.mp=!0,this.Dt=0,this.de=NaN,this.Pa=0,this.Ma=1/0,this.ni=Spot.Default,this.nt=0,this.ji=0,this.ct=0,this.Gs=null,this.pd=1,this.to=1,this.Go=null,this.yd=null,this.wd=NaN,this.Sa=null,this.Ct=null,this.xd=!1,t&&(Object.assign(this,t),t.column!==void 0?(this.isRow=!1,this.index=t.column):t.row!==void 0&&(this.isRow=!0,this.index=t.row))}copy(){const t=new RowColumnDefinition;return t.mp=this.mp,t.Dt=this.Dt,t.de=this.de,t.Pa=this.Pa,t.Ma=this.Ma,t.ni=this.ni,t.nt=this.nt,t.ji=this.ji,t.ct=this.ct,t.to=this.to,t.pd=this.pd,this.Go===null?t.Go=null:t.Go=this.Go.N(),t.yd=this.yd,t.wd=this.wd,t.Sa=null,this.Sa!==null&&(t.separatorDashArray=this.separatorDashArray.slice()),t.Ct=this.Ct,t.xd=this.xd,t.Gs=this.Gs,t}Bb(t){t.isRow?this.height=t.height:this.width=t.width,this.minimum=t.minimum,this.maximum=t.maximum,this.alignment=t.alignment,this.stretch=t.stretch,this.sizing=t.sizing,this.Go=t.separatorPadding===null?null:t.separatorPadding.N(),this.separatorStroke=t.separatorStroke,this.separatorStrokeWidth=t.separatorStrokeWidth,this.Sa=null,t.separatorDashArray&&(this.Sa=t.separatorDashArray.slice()),this.background=t.background,this.coversSeparators=t.coversSeparators,this.Gs=t.Gs}ri(t){t in Sizing?this.sizing=t:Util.lr(this,t)}toString(){return"RowColumnDefinition "+(this.isRow?"(Row ":"(Column ")+this.index+") #"+GSet.as(this)}static Default=1;static None=2;static ProportionalExtra=3;wa(t){this.Vs=t}computeEffectiveSpacingTop(t){let i=0;const e=this.Vs;if(this.index!==t){let n=this.separatorStroke;n===null&&e!==null&&(n=this.isRow?e.defaultRowSeparatorStroke:e.defaultColumnSeparatorStroke),n!==null&&(i=this.separatorStrokeWidth,isNaN(i)&&(e!==null?i=this.isRow?e.defaultRowSeparatorStrokeWidth:e.defaultColumnSeparatorStrokeWidth:i=0))}let s=this.Go;if(s===null)if(e!==null)s=e.defaultSeparatorPadding;else return i;return i+(this.isRow?s.top:s.left)}computeEffectiveSpacing(){let t=0;const i=this.Vs;let e=0;const s=this.isRow;if(i!==null&&i.type===Panel.Table){const o=s?i.Ye.length:i.Ge.length;for(let r=0;r= 0",RowColumnDefinition,"height"),this.de=t,this.actual=this.nt,this.panel!==null&&this.panel.c(),this.t("height",i,t))}get width(){return this.de}set width(t){const i=this.de;i!==t&&(t<0&&Util._(t,">= 0",RowColumnDefinition,"width"),this.de=t,this.actual=this.nt,this.panel!==null&&this.panel.c(),this.t("width",i,t))}get minimum(){return this.Pa}set minimum(t){const i=this.Pa;i!==t&&((t<0||!isFinite(t))&&Util._(t,">= 0",RowColumnDefinition,"minimum"),this.Pa=t,this.actual=this.nt,this.panel!==null&&this.panel.c(),this.t("minimum",i,t))}get maximum(){return this.Ma}set maximum(t){const i=this.Ma;i!==t&&(t<0&&Util._(t,">= 0",RowColumnDefinition,"maximum"),this.Ma=t,this.actual=this.nt,this.panel!==null&&this.panel.c(),this.t("maximum",i,t))}get alignment(){return this.ni}set alignment(t){const i=this.ni;i.equals(t)||(this.ni=t.N(),this.panel!==null&&this.panel.c(),this.t("alignment",i,t))}get stretch(){return this.to}set stretch(t){const i=this.to;i!==t&&(this.to=t,this.panel!==null&&this.panel.c(),this.t("stretch",i,t))}get separatorPadding(){return this.Go}set separatorPadding(t){typeof t=="number"&&(t=new Margin(t));const i=this.Go;(t===null||i===null||!i.equals(t))&&(t!==null&&(t=t.N()),this.Go=t,this.panel!==null&&this.panel.c(),this.t("separatorPadding",i,t))}get separatorStroke(){return this.yd}set separatorStroke(t){const i=this.yd;i!==t&&(t!==null&&Brush.od(t,"RowColumnDefinition.separatorStroke"),t instanceof Brush&&t.g(),this.yd=t,this.panel!==null&&this.panel.c(),this.t("separatorStroke",i,t))}get separatorStrokeWidth(){return this.wd}set separatorStrokeWidth(t){const i=this.wd;i!==t&&(this.wd=t,this.panel!==null&&this.panel.c(),this.t("separatorStrokeWidth",i,t))}get separatorDashArray(){return this.Sa}set separatorDashArray(t){const i=this.Sa;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",RowColumnDefinition,"separatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("separatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.Sa=t,this.panel!==null&&this.panel.C(),this.t("separatorDashArray",i,t)}}get background(){return this.Ct}set background(t){const i=this.Ct;i!==t&&(t!==null&&Brush.od(t,"RowColumnDefinition.background"),t instanceof Brush&&t.g(),this.Ct=t,this.panel!==null&&this.panel.C(),this.t("background",i,t))}get coversSeparators(){return this.xd}set coversSeparators(t){const i=this.xd;i!==t&&(Util.i(t,"boolean",RowColumnDefinition,"coversSeparators"),this.xd=t,this.panel!==null&&this.panel.C(),this.t("coversSeparators",i,t))}get sizing(){return this.pd}set sizing(t){const i=this.pd;i!==t&&(this.pd=t,this.panel!==null&&this.panel.c(),this.t("sizing",i,t))}Gb(){if(this.sizing===1){const t=this.Vs;return this.isRow?t.rowSizing:t.columnSizing}return this.sizing}get actual(){return this.nt}set actual(t){isNaN(this.de)?this.nt=Math.max(Math.min(this.Ma,t),this.Pa):this.nt=Math.max(Math.min(this.Ma,this.de),this.Pa)}get measured(){return this.ji}set measured(t){this.ji=t}get total(){return this.nt+this.computeEffectiveSpacing()}get position(){return this.ct}set position(t){this.ct=t}bind(t,i,e,s){return this.ef(t,i,e,s),this}bindTwoWay(t,i,e,s){const n=this.ef(t,i,e,s);return s===void 0&&n.makeTwoWay(),this}theme(t,i,e,s,n){return this.fh(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.fh(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.fh(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.fh(t,i,e,s,n).ofModel(),this}ef(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.Y0(n),n}fh(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.Y0(o),o}Y0(t){t.ke=this;const i=this.panel;if(i!==null){const e=i.findBindingPanel();e!==null&&e.cA()&&Util.o("Cannot add a Binding to a RowColumnDefinition that is already frozen: "+t+" on "+i)}this.Gs===null&&(this.Gs=new List),this.Gs.add(t)}}class Shape extends GraphObject{ft;xs;bd;Na;Hi;jo;Xo;Lt;kd;Pd;J;constructor(t,i){super(),this.ft=null,this.xs=null,this.bd="None",this.Na="black",this.Hi="black",this.jo=1,this.Xo=null,this.Lt=null,this.kd=NaN,this.Pd=NaN,this.J=null,typeof t=="string"?this.figure=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.ft=this.ft,t.xs=this.xs,t.bd=this.bd,t.Na=this.Na,t.Hi=this.Hi,t.jo=this.jo,this.Xo!==null&&(t.Xo=this.Xo.slice()),this.Lt!==null&&(this.Lt.gi?t.Lt=this.Lt:t.Lt=this.Lt.copy()),t.kd=this.kd,t.Pd=this.Pd,this.J!==null&&(t.J=this.J.copy())}Ca(){this.Lt===null?this.Lt=new ShapeTemplateSettings:this.Lt.gi&&(this.Lt=this.Lt.copy())}rh(){super.rh(),this.Lt!==null&&(this.Lt.gi=!0)}ri(t){t in GeometryStretch?this.geometryStretch=t:super.ri(t)}toString(){return"Shape("+(this.figure!=="None"?this.figure:this.toArrow!=="None"?this.toArrow:this.fromArrow)+")#"+GSet.as(this)}pv(t,i){const e=this.pathPattern;e.ut(1/0,1/0);const s=e.measuredBounds;e.zt(0,0,s.width,s.height);const n=this.geometry;t.save(),t.beginPath();const o=Util.ot();if(n.type===1)o.push(n.startX),o.push(n.startY),o.push(n.endX),o.push(n.endY),this.Md(t,i,o,e);else if(n.type===4){const r=n.figures.iterator;for(;r.next();){const l=r.value;o.length=0,o.push(l.startX),o.push(l.startY);let h=l.startX,a=l.startY,c=h,f=a;const u=l.segments.r,d=u.length;for(let m=0;m=.1;){if(S===0&&(M?(b=k,b-=P,y-=P,M=!1):b=k,b===0&&(b=1)),b>y){b=y,Util.tt(x);return}b>p?(S=b-p,b=p):S=0;let N=Math.sqrt(b*b/(1+m*m));if(u<0&&(N=-N),h+=N,a+=m*N,t.translate(h,a),t.rotate(g),t.translate(-(r/2),-(l/2)),S===0&&s.ch(t,i),t.translate(r/2,l/2),t.rotate(-g),t.translate(-h,-a),y-=b,p-=b,S!==0){if(L++,L===x.length){Util.tt(x);return}C=x[L],u=C[0],g=C[1],m=C[2],p=C[3],b=S}}Util.tt(x)}ch(t,i){const e=t instanceof SVGContext;let s=this.Hi;const n=this.Na;if(s===null&&n===null)return;const o=this.ft;if(o===null)return;t.commitTransform();const r=this.actualBounds,l=this.naturalBounds;n!==null&&this.dn(t,n,!0,!1,l,r);const h=this.part;let a=this.jo;s!==null&&a===0&&h!==null&&(this.isPanelMain||h.findMainElement()===this)&&(a=h.wv()),a===0&&(s=null),s!==null&&a!==0&&(this.dn(t,s,!1,!1,l,r),t.lineWidth=a,t.lineJoin=this.strokeJoin,t.lineCap=this.strokeCap,t.miterLimit=this.strokeMiterLimit);let c=!1;h&&i.getRenderingHint("drawShadows")&&(c=h.isShadowed),t.tl===!1&&(c=!1);let f=!0;s!==null&&(n===null||n==="transparent")&&(f=!1);let u=!1;const d=this.strokeDashArray;if(d!==null&&(u=!0,t.enableDash(d,this.strokeDashOffset)),o.type===1)t.beginPath(),t.moveTo(o.startX,o.startY),t.lineTo(o.endX,o.endY),s!==null&&t.strokeContext(),t.endPath();else if(o.type===2){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.min(m,p),k=Math.min(g,y),b=Math.abs(p-m),P=Math.abs(y-g);t.beginPath(),t.rect(x,k,b,P),n!==null&&t.fillContext(n,!1,null),s!==null&&(f&&c&&t.shadowsOff(),t.strokeContext(),f&&c&&t.shadowsOn()),t.endPath()}else if(o.type===3){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.abs(p-m)/2,k=Math.abs(y-g)/2,b=Math.min(m,p)+x,P=Math.min(g,y)+k;t.beginPath(),t.moveTo(b,P-k),t.bezierCurveTo(b+Geo.Un*x,P-k,b+x,P-Geo.Un*k,b+x,P),t.bezierCurveTo(b+x,P+Geo.Un*k,b+Geo.Un*x,P+k,b,P+k),t.bezierCurveTo(b-Geo.Un*x,P+k,b-x,P+Geo.Un*k,b-x,P),t.bezierCurveTo(b-x,P-Geo.Un*k,b-Geo.Un*x,P-k,b,P-k),t.closePath(),n!==null&&t.fillContext(n,!1,null),s!==null&&(f&&c&&t.shadowsOff(),t.strokeContext(),f&&c&&t.shadowsOn()),t.endPath()}else if(o.type===4){const m=o.figures,g=m.length;for(let p=0;p1||this.pathPattern!==null?!0:super.sd(t)}h2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("path");for(let s=0;s1,i);Util.o("Unknown Geometry type: "+e.type)}}_u(t,i,e,s){const n=this.desiredSize,o=this.jo;t=Math.max(t,0),i=Math.max(i,0);let r;if(this.xs!==null)r=this.geometry.bounds;else{const g=this.figure;let p=Shape.U2[g];if(p===void 0){let y=Geo.Mo[g];typeof y=="string"&&(y=Geo.Mo[y]),typeof y=="function"?(p=y(null,100,100),Shape.U2[g]=p):Util.o("Unsupported Figure: "+g)}r=p.bounds}let l=r.width,h=r.height,a=r.width,c=r.height;switch(this.zs(!0)){case 0:e=0,s=0;break;case 2:a=Math.max(t-o,0),c=Math.max(i-o,0);break;case 5:a=Math.max(t-o,0),s=0;break;case 4:e=0,c=Math.max(i-o,0);break}isFinite(n.width)&&(a=n.width),isFinite(n.height)&&(c=n.height);const u=this.maxSize,d=this.minSize;e=Math.max(e-o,d.width),s=Math.max(s-o,d.height),a=Math.min(u.width,a),c=Math.min(u.height,c),a=isFinite(a)?Math.max(e,a):Math.max(l,e),c=isFinite(c)?Math.max(s,c):Math.max(h,s);const m=this._P();switch(m){case 0:break;case 2:l=a,h=c;break;case 6:{let g=Math.min(a/l,c/h);isFinite(g)||(g=1),l=l*g,h=h*g;break}default:Util.o(m+" is not a valid geometryStretch.")}if(this.xs!==null){l===0&&(l=.001),h===0&&(h=.001);const p=(this.xs!==null?this.xs:this.ft).YD(l,h);this.ft=p}else(this.ft===null||!Geo.K(this.ft.ec,t-o)||!Geo.K(this.ft.sc,i-o))&&(this.ft=Shape.xv(this,l,h));r=this.ft.bounds,t===1/0||i===1/0?this.Qn(r.x-o/2,r.y-o/2,t===0&&l===0?0:r.width+o,i===0&&h===0?0:r.height+o):this.Qn(-(o/2),-(o/2),a+o,c+o),n.isReal()?(a=n.width,c=n.height,a=Math.min(u.width,a),c=Math.min(u.height,c),a=Math.max(d.width,a),c=Math.max(d.height,c),this.Vi.e(0,0,a,c)):this.Vi.a(r)}_P(){const t=this.geometryStretch;return this.xs!==null?t===1?2:t:t===1?Shape.U2[this.figure].defaultStretch:t}hh(t,i,e,s){this.commonArrange(t,i,e,s)}getNearestIntersectionPoint(t,i,e){return this.$c(t.x,t.y,i.x,i.y,e)}$c(t,i,e,s,n){const o=this.D,r=1/(o.m11*o.m22-o.m12*o.m21),l=o.m22*r,h=-o.m12*r,a=-o.m21*r,c=o.m11*r,f=r*(o.m21*o.dy-o.m22*o.dx),u=r*(o.m12*o.dx-o.m11*o.dy),d=t*l+i*a+f,m=t*h+i*c+u,g=e*l+s*a+f,p=e*h+s*c+u,y=this.jo/2;let x=this.ft;x===null&&(this.ut(1/0,1/0),x=this.ft);const k=x.bounds;let b=!1;if(x.type===1)if(this.strokeWidth<=1.5)b=Geo.Vn(x.startX,x.startY,x.endX,x.endY,d,m,g,p,n);else{let P=0,M=0;if(x.startX===x.endX)P=y,M=0;else{const T=(x.endY-x.startY)/(x.endX-x.startX);M=y/Math.sqrt(1+T*T),P=M*T}const L=Util.ot();let C=new Point;Geo.Vn(x.startX+P,x.startY+M,x.endX+P,x.endY+M,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Vn(x.startX-P,x.startY-M,x.endX-P,x.endY-M,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Vn(x.startX+P,x.startY+M,x.startX-P,x.startY-M,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Vn(x.endX+P,x.endY+M,x.endX-P,x.endY-M,d,m,g,p,C)&&L.push(C);const S=L.length;if(S===0)return Util.tt(L),!1;b=!0;let N=1/0;for(let T=0;T0&&k.contains(D,F)&&(S.x=D,S.y=F,this.containsPoint(S)))for(N!==0&&Math.abs(N)<.5?(T*=.5/N,N=.5):T!==0&&Math.abs(T)<.5&&(N*=.5/T,T=.5),D-=N,F-=T;k.contains(D,F);)D-=N,F-=T;const R=.6;n.x=g,n.y=p;for(let X=0;Xe?t-e:e-t)<(i>s?i-s:s-i)){const f=if||Geo.K(h.y,f))&&(h.yf||Geo.K(h.x,f))&&(h.x=a&&h<=c}else{let a=0,c=0;return s=a&&l<=c}}Pv(t,i){if(this.containedInRect(t,i)||i===void 0&&(i=this.D,t.containsRect(this.actualBounds)))return!0;const e=t.left,s=t.right,n=t.top,o=t.bottom,r=Point.l(),l=Point.l(),h=Point.l(),a=Transform.l();a.set(i),a.cC(this.D),a.yw(),l.x=s,l.y=n,l.D(a),r.x=e,r.y=n,r.D(a);let c=!1;return this.La(r,l,h)?c=!0:(r.x=s,r.y=o,r.D(a),this.La(r,l,h)?c=!0:(l.x=e,l.y=o,l.D(a),this.La(r,l,h)?c=!0:(r.x=e,r.y=n,r.D(a),this.La(r,l,h)&&(c=!0)))),Transform.s(a),Point.s(r),Point.s(l),Point.s(h),c}tA(t,i,e){if(e&&this.fill!==null&&this.lh(t,!0))return!0;let s=t.distanceSquaredPoint(i);const n=s;this.strokeWidth>1.5&&(s=this.strokeWidth/2+Math.sqrt(s),s*=s);let o=this.ft;if(o===null&&(this.ut(1/0,1/0),o=this.ft,o===null))return!1;if(!e){const f=o.bounds,u=f.x,d=f.y,m=f.x+f.width,g=f.y+f.height;if(Point.distanceSquared(t.x,t.y,u,d)<=s&&Point.distanceSquared(t.x,t.y,m,d)<=s&&Point.distanceSquared(t.x,t.y,u,g)<=s&&Point.distanceSquared(t.x,t.y,m,g)<=s)return!0}function r(f,u){const d=f.length;for(let m=0;ms)return!0;return!1}const l=o.startX,h=o.startY,a=o.endX,c=o.endY;if(o.type===1){const f=Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,c),u=(a-l)*(t.x-l)+(c-h)*(t.y-h),d=(l-a)*(t.x-a)+(h-c)*(t.y-c),m=u>=0&&d>=0?s:n;return f<=m}else if(o.type===2){let f=!1;return e&&(f=Point.distanceLineSegmentSquared(t.x,t.y,l,h,l,c)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,h)<=s||Point.distanceLineSegmentSquared(t.x,t.y,a,h,a,c)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,c,a,c)<=s),f}else if(o.type===3){const f=(l+a)/2,u=(h+c)/2,d=t.x-f,m=t.y-u,g=Math.abs(a-l)/2,p=Math.abs(c-h)/2;if(g===0||p===0)return Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,c)<=s;if(e){const y=Geo.OD(g,p,d,m);return y*y<=s}else return!(Point.distanceSquared(d,m,-g,0)>=s||Point.distanceSquared(d,m,0,-p)>=s||Point.distanceSquared(d,m,0,p)>=s||Point.distanceSquared(d,m,g,0)>=s)}else if(o.type===4){const f=o.bounds,u=f.x,d=f.y,m=f.x+f.width,g=f.y+f.height;if(t.x>m&&t.xg&&t.ys&&Point.distanceLineSegmentSquared(t.x,t.y,u,d,m,d)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,u,g)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,m,d)>s)return!1;const p=Math.sqrt(s);if(e){if(this.fill===null?o.kC(t.x,t.y,p):o.Vk(t,p,!0,!1))return!0}else{const y=o.figures;for(let x=0;xs)return!1;const M=k.segments.r,L=M.length;for(let C=0;Cs)return!1;break;case 3:{const N=Util.ot();Geo.Bn(b,P,S.point1X,S.point1Y,S.point2X,S.point2Y,S.endX,S.endY,.8,N);const T=r(N,t);if(Util.tt(N),T||(b=S.endX,P=S.endY,t.distanceSquared(b,P)>s))return!1;break}case 4:{const N=Util.ot();Geo.Bg(b,P,S.point1X,S.point1Y,S.endX,S.endY,.8,N);const T=r(N,t);if(Util.tt(N),T||(b=S.endX,P=S.endY,t.distanceSquared(b,P)>s))return!1;break}case 5:case 6:{const N=S.type===5?S.So(k):S.Ih(k,b,P),T=N.length;if(T===0){if(b=S.type===5?S.centerX:S.endX,P=S.type===5?S.centerY:S.endY,t.distanceSquared(b,P)>s)return!1;break}let A=null;const D=Util.ot();for(let F=0;F=0){this.jo=t,this.c();const e=this.part;e!==null&&e.af(),this.t("strokeWidth",i,t)}else Util._(t,"value >= 0",Shape,"strokeWidth:value")}Db(){return this.jo}get strokeCap(){return this.Lt!==null?this.Lt.pp:"butt"}set strokeCap(t){const i=this.strokeCap;i!==t&&(typeof t=="string"&&(t==="butt"||t==="round"||t==="square")?(this.Ca(),this.Lt.pp=t,this.C(),this.t("strokeCap",i,t)):Util._(t,'"butt", "round", or "square"',Shape,"strokeCap"))}get strokeJoin(){return this.Lt!==null?this.Lt.yp:"miter"}set strokeJoin(t){const i=this.strokeJoin;i!==t&&(typeof t=="string"&&(t==="miter"||t==="bevel"||t==="round")?(this.Ca(),this.Lt.yp=t,this.C(),this.t("strokeJoin",i,t)):Util._(t,'"miter", "bevel", or "round"',Shape,"strokeJoin"))}get strokeMiterLimit(){return this.Lt!==null?this.Lt.wp:10}set strokeMiterLimit(t){const i=this.strokeMiterLimit;if(i!==t&&t>=1){this.Ca(),this.Lt.wp=t,this.C();const e=this.part;e!==null&&e.af(),this.t("strokeMiterLimit",i,t)}}get strokeDashArray(){return this.Xo}set strokeDashArray(t){const i=this.Xo;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",Shape,"strokeDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("strokeDashArray:value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.Xo=t,this.C(),this.t("strokeDashArray",i,t)}}get strokeDashOffset(){return this.Lt!==null?this.Lt.uh:0}set strokeDashOffset(t){const i=this.strokeDashOffset;i!==t&&t>=0&&(this.Ca(),this.Lt.uh=t,this.C(),this.t("strokeDashOffset",i,t))}get figure(){return this.bd}set figure(t){const i=this.bd;if(i!==t){let e=Geo.Mo[t];if(typeof e=="function"?e=t:(e=Geo.Mo[t.toLowerCase()],e||Util.o("Unknown Shape.figure: "+t)),i!==e){const s=this.part;s!==null&&s.af(),this.bd=e,this.xs=null,this.ie(),this.c(),this.t("figure",i,e)}}}get toArrow(){return this.Ut!==null?this.Ut.xp:"None"}set toArrow(t){const i=this.toArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){const e=Shape.AA(t);e===null?Util.o("Unknown Shape.toArrow: "+t):i!==e&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.xp=e,this.xs=null,this.ie(),this.c(),this.TA(e),this.t("toArrow",i,e))}}get fromArrow(){return this.Ut!==null?this.Ut.bp:"None"}set fromArrow(t){const i=this.fromArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){const e=Shape.AA(t);e===null?Util.o("Unknown Shape.fromArrow: "+t):i!==e&&(this.Ut===null&&(this.Ut=new LinkElementSettings),this.Ut.bp=e,this.xs=null,this.ie(),this.c(),this.TA(e),this.t("fromArrow",i,e))}}TA(t){const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;this.OR();const e=Spot.MiddleRight;this.toArrow!=="None"?(this.segmentIndex=-1,this.alignmentFocus=e):this.fromArrow!=="None"&&(this.segmentIndex=0,this.alignmentFocus=new Spot(1-e.x,e.y))}get spot1(){return this.Lt!==null?this.Lt.zn:Spot.Default}set spot1(t){const i=this.spot1;i.equals(t)||(t=t.N(),this.Ca(),this.Lt.zn=t,this.c(),this.t("spot1",i,t))}get spot2(){return this.Lt!==null?this.Lt.Xn:Spot.Default}set spot2(t){const i=this.spot2;i.equals(t)||(t=t.N(),this.Ca(),this.Lt.Xn=t,this.c(),this.t("spot2",i,t))}get parameter1(){return this.kd}set parameter1(t){const i=this.kd;i!==t&&(this.kd=t,this.ie(),this.c(),this.t("parameter1",i,t))}get parameter2(){return this.Pd}set parameter2(t){const i=this.Pd;i!==t&&(this.Pd=t,this.ie(),this.c(),this.t("parameter2",i,t))}get naturalBounds(){return this.Vi}tv(){const t=this.desiredSize;if(!t.isReal()&&this.ft!==null){const i=this.ft.bounds;this.Vi.a(i)}else this.Vi.e(0,0,t.width,t.height)}get pathPattern(){return this.Lt!==null?this.Lt.kp:null}set pathPattern(t){const i=this.pathPattern;i!==t&&(this.Ca(),this.Lt.kp=t,this.C(),this.t("pathPattern",i,t))}get geometryStretch(){return this.Lt!==null?this.Lt.Pp:1}set geometryStretch(t){const i=this.geometryStretch;i!==t&&(this.Ca(),this.Lt.Pp=t,this.c(),this.t("geometryStretch",i,t))}get interval(){return this.J!==null?this.J.ff:1}set interval(t){const i=this.interval;if(t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this.J===null&&(this.J=new GradElementSettings),this.J.ff=t;const e=this.diagram;e!==null&&this.panel===e.grid&&e.jr(),this.c();const s=this.panel;s!==null&&(s.ns=null),this.t("interval",i,t)}}get graduatedStart(){return this.J!==null?this.J.uf:0}set graduatedStart(t){const i=this.graduatedStart;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.uf=t,this.c(),this.t("graduatedStart",i,t))}get graduatedEnd(){return this.J!==null?this.J.df:1}set graduatedEnd(t){const i=this.graduatedEnd;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.df=t,this.c(),this.t("graduatedEnd",i,t))}get graduatedSkip(){return this.J!==null?this.J.gf:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.i(t,"function",Shape,"graduatedSkip"),this.J===null&&(this.J=new GradElementSettings),this.J.gf=t,this.c(),this.t("graduatedSkip",i,t))}static xv(t,i,e){let n=null;if(t.toArrow!=="None")n=Shape.no[t.toArrow];else if(t.fromArrow!=="None")n=Shape.no[t.fromArrow];else{let o=Geo.Mo[t.figure];typeof o=="string"&&(o=Geo.Mo[o]),o===void 0&&Util.o("Unknown Shape.figure: "+t.figure),n=o(t,i,e),n.ec=i,n.sc=e}if(n===null){const o=Geo.Mo.Rectangle;typeof o=="function"&&(n=o(t,i,e))}return n}static getFigureGenerators(){const t=new GMap;for(const i in Geo.Mo){if(i===i.toLowerCase())continue;const e=Geo.Mo[i];t.set(i,e)}return t.g(),t}static defineFigureGenerator(t,i){Util.i(t,"string",Shape,"defineFigureGenerator:name"),typeof i=="string"||Util.i(i,"function",Shape,"defineFigureGenerator:func");const e=t.toLowerCase(),s=Geo.Mo;s[t]=i,s[e]=t}static getArrowheadGeometries(){const t=new GMap;for(const i in Geo.Kg)if(Shape.no[i]===void 0){const e=Geometry.parse(Geo.Kg[i],!1);Shape.no[i]=e;const s=i.toLowerCase();s!==i&&(Shape.no[s]=i)}for(const i in Shape.no){if(i===i.toLowerCase())continue;const e=Shape.no[i];e instanceof Geometry&&t.set(i,e)}return t.g(),t}static defineArrowheadGeometry(t,i){Util.i(t,"string",Shape,"defineArrowheadGeometry:name");let e=null;typeof i=="string"?(Util.i(i,"string",Shape,"defineArrowheadGeometry:pathstr"),e=Geometry.parse(i,!1)):e=i;const s=t.toLowerCase();(s==="none"||t===s)&&Util.o("Shape.defineArrowheadGeometry name must not be empty or None or all-lower-case: "+t);const n=Shape.no;n[t]=e,n[s]=t}static no=new PropertyCollection;static U2=new PropertyCollection;static AA(t){let i=Shape.no[t];if(i===void 0){const e=t.toLowerCase();if(e==="none")return"None";if(i=Shape.no[e],i===void 0){let s=null;for(const n in Geo.Kg)if(n.toLowerCase()===e){s=n;break}if(s!==null){const n=Geometry.parse(Geo.Kg[s],!1);return Shape.no[s]=n,e!==s&&(Shape.no[e]=s),s}}}return typeof i=="string"?i:i instanceof Geometry?t:null}}class ShapeTemplateSettings{gi;pp;yp;wp;uh;kp;Pp;zn;Xn;constructor(){this.gi=!1,this.pp="butt",this.yp="miter",this.wp=10,this.uh=0,this.kp=null,this.Pp=1,this.zn=Spot.Default,this.Xn=Spot.Default}copy(){const t=new ShapeTemplateSettings;return t.pp=this.pp,t.yp=this.yp,t.wp=this.wp,t.uh=this.uh,t.kp=this.kp,t.Pp=this.Pp,t.zn=this.zn.N(),t.Xn=this.Xn.N(),t}}var Wrap=(w=>(w[w.None=0]="None",w[w.Fit=1]="Fit",w[w.DesiredSize=2]="DesiredSize",w[w.BreakAll=3]="BreakAll",w))(Wrap||{}),TextOverflow=(w=>(w[w.Clip=0]="Clip",w[w.Ellipsis=1]="Ellipsis",w))(TextOverflow||{}),TextFormat=(w=>(w[w.Trim=0]="Trim",w[w.None=1]="None",w))(TextFormat||{});class TextBlock extends GraphObject{hi;Hi;kn;Ce;mi;x0;Sd;J;W;Dl;oo;Pn;Le;Di;Mn;constructor(t,i){return super(),this.n|=2097152,this.hi="",this.Hi="black",this.kn="13px sans-serif",this.Ce=0,this.mi=0,this.x0=0,this.Sd=null,this.J=null,this.W=null,this.Dl=0,this.oo=null,this.Pn=0,this.Le=null,this.Di=null,this.Mn=null,typeof t=="string"?this.text=t:t&&Object.assign(this,t),i&&Object.assign(this,i),this}cloneProtected(t){super.cloneProtected(t),t.hi=this.hi,t.Hi=this.Hi,t.kn=this.kn,t.Ce=this.Ce,t.mi=this.mi,t.x0=this.x0,t.Sd=this.Sd,this.J!==null&&(t.J=this.J.copy()),this.W!==null&&(this.W.gi?t.W=this.W:t.W=this.W.copy()),t.Dl=this.Dl,t.oo=this.oo,t.Pn=this.Pn,t.Le=this.Le,t.Di=this.Di,t.Mn=this.Mn}Sn(){this.W===null?this.W=new TextBlockTemplateSettings:this.W.gi&&(this.W=this.W.copy())}rh(){super.rh(),this.W!==null&&(this.W.gi=!0)}lv(t){this.n=t.n|2048|4096,this.Wt=t.opacity,this.Ct=t.background,this.ze=t.desiredSize.N(),this.minSize=t.minSize.N(),this.maxSize=t.maxSize.N(),t.bi!==null?this.bi=t.bi.copy():this.bi=null,this.st=t.scale,this.Xt=t.angle,this.stretch=t.stretch,this.Zr=t.margin.N(),this.ni=t.alignment.N(),this.qc=t.alignmentFocus.N(),this.segmentFraction=t.segmentFraction,this.segmentOffset=t.segmentOffset.N(),this.segmentOrientation=t.segmentOrientation,t.si!==null&&(this.si=t.si.copy()),this.shadowVisible=t.shadowVisible,this.hi=t.hi,this.Hi=t.Hi,this.kn=t.kn,this.J!==null&&(this.J=t.J.copy()),t.W!==null&&(t.W.gi?this.W=t.W:this.W=t.W.copy()),this.Dl=t.Dl}ov(t){if(this.hi=t.text||"",this.Xt=t.labelAngle||0,this.Ce=t.lineCount||0,this.Mv(t.lines),t.naturalBounds&&(this.Vi=t.naturalBounds),t.actualBounds){const i=t.actualBounds;this.zt(i.x,i.y,i.width,i.height)}}ri(t){t in Wrap?this.wrap=t:super.ri(t)}toString(){return this.hi.length>22?'TextBlock("'+this.hi.substring(0,20)+'"...)':'TextBlock("'+this.hi+'")'}static getEllipsis(){return TextBlock.Mp}static setEllipsis(t){TextBlock.Mp=t,TextBlock.Zb=new PropertyCollection,TextBlock.B2=0}static getBaseline(){return TextBlock.Qb}static setBaseline(t){TextBlock.Qb=t}static Qb=null;static getUnderline(){return TextBlock._b}static setUnderline(t){TextBlock._b=t}static _b=null;static None=0;static WrapFit=1;static WrapDesiredSize=2;static WrapBreakAll=3;static OverflowClip=0;static OverflowEllipsis=1;static FormatTrim=0;static FormatNone=1;c(){super.c()}get font(){return this.kn}set font(t){const i=this.kn;i!==t&&(this.kn=t,this.oo=null,this.c(),this.t("font",i,t))}static isValidFont(t){return root.CSS?root.CSS.supports("font",t):!0}get text(){return this.hi}set text(t){const i=this.hi;t!=null?t=t.toString():t="",i!==t&&(this.hi=t,this.c(),this.t("text",i,t),this.ss(!0))}get textAlign(){return this.W!==null?this.W.Sp:"start"}set textAlign(t){const i=this.textAlign;i!==t&&(t==="start"||t==="end"||t==="left"||t==="right"||t==="center")&&(this.Sn(),this.W.Sp=t,this.C(),this.t("textAlign",i,t))}get flip(){return this.W!==null?this.W.ro:0}set flip(t){const i=this.flip;i!==t&&(this.Sn(),this.W.ro=t,this.C(),this.t("flip",i,t))}get verticalAlignment(){return this.W!==null?this.W.sl:Spot.Top}set verticalAlignment(t){const i=this.verticalAlignment;i.equals(t)||(t=t.N(),this.Sn(),this.W.sl=t,this.tf(),this.t("verticalAlignment",i,t))}get naturalBounds(){if(!this.Vi.isReal()){const t=Size.l();this.V2(this.hi,999999,t);let i=t.width;Size.s(t);let e=this.DA(i);const s=this.desiredSize;isNaN(s.width)||(i=s.width),isNaN(s.height)||(e=s.height),this.Vi.En(i,e)}return this.Vi}get isMultiline(){return(this.n&2097152)!==0}set isMultiline(t){const i=(this.n&2097152)!==0;i!==t&&(this.n=this.n^2097152,this.c(),this.t("isMultiline",i,t))}get isUnderline(){return(this.n&4194304)!==0}set isUnderline(t){const i=(this.n&4194304)!==0;i!==t&&(this.n=this.n^4194304,this.ss(!0),this.C(),this.t("isUnderline",i,t))}get isStrikethrough(){return(this.n&8388608)!==0}set isStrikethrough(t){const i=(this.n&8388608)!==0;i!==t&&(this.n=this.n^8388608,this.ss(!0),this.C(),this.t("isStrikethrough",i,t))}get wrap(){return this.W!==null?this.W.Np:2}set wrap(t){const i=this.wrap;i!==t&&(this.Sn(),this.W.Np=t,this.c(),this.t("wrap",i,t))}get overflow(){return this.W!==null?this.W.Cp:0}set overflow(t){const i=this.overflow;i!==t&&(this.Sn(),this.W.Cp=t,this.c(),this.t("overflow",i,t))}get isOverflowed(){return(this.n&16777216)!==0}z2(t){t?this.n|=16777216:this.n&=-16777217}get stroke(){return this.Hi}set stroke(t){const i=this.Hi;i!==t&&(t!==null&&Brush.od(t,"TextBlock.stroke"),t instanceof Brush&&t.g(),this.Hi=t,this.C(),this.t("stroke",i,t))}get lineCount(){return this.Ce}get lineHeight(){return this.Lp()}get editable(){return(this.n&1048576)!==0}set editable(t){const i=(this.n&1048576)!==0;i!==t&&(this.n=this.n^1048576,this.t("editable",i,t))}get T2(){return(this.n&33554432)!==0}set T2(t){this.n=this.n^33554432}get textEditor(){return this.W!==null?this.W.Ap:null}set textEditor(t){const i=this.textEditor;i!==t&&(this.Sn(),this.W.Ap=t,this.t("textEditor",i,t))}get errorFunction(){return this.W!==null?this.W.os:null}set errorFunction(t){const i=this.errorFunction;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"errorFunction"),this.Sn(),this.W.os=t,this.t("errorFunction",i,t))}get interval(){return this.J!==null?this.J.ff:1}set interval(t){const i=this.interval;if(t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this.J===null&&(this.J=new GradElementSettings),this.J.ff=t,this.c();const e=this.panel;e!==null&&(e.ns=null),this.t("interval",i,t)}}get graduatedStart(){return this.J!==null?this.J.uf:0}set graduatedStart(t){const i=this.graduatedStart;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.uf=t,this.c(),this.t("graduatedStart",i,t))}get graduatedEnd(){return this.J!==null?this.J.df:1}set graduatedEnd(t){const i=this.graduatedEnd;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.df=t,this.c(),this.t("graduatedEnd",i,t))}get graduatedFunction(){return this.J!==null?this.J.Tp:null}set graduatedFunction(t){const i=this.graduatedFunction;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"graduatedFunction"),this.J===null&&(this.J=new GradElementSettings),this.J.Tp=t,this.c(),this.t("graduatedFunction",i,t))}get graduatedSkip(){return this.J!==null?this.J.gf:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"graduatedSkip"),this.J===null&&(this.J=new GradElementSettings),this.J.gf=t,this.c(),this.t("graduatedSkip",i,t))}ch(t,i){if(this.Hi===null||this.hi.length===0||this.kn===null)return;const e=this.naturalBounds,s=this.actualBounds,n=e.width,o=e.height,r=this.Lp();let l=t.textAlign=this.textAlign;const h=i.Ku;l==="start"?l=h?"right":"left":l==="end"&&(l=h?"left":"right");const a=this.isUnderline,c=this.isStrikethrough;this.dn(t,this.Hi,!0,!1,e,s),(a||c)&&this.dn(t,this.Hi,!1,!1,e,s);const f=0;let u=0;const d=n;let m=!1;i.Zt===t&&!(i.Zt instanceof SVGContext)&&!this.T2&&i.getRenderingHint("textGreeking")===!0&&r*this.aa*i.scale<3&&(m=!0);const g=this.spacingAbove,p=this.spacingBelow;switch(this.flip){case 0:break;case 2:t.translate(n,0),t.scale(-1,1);break;case 1:t.translate(0,o),t.scale(1,-1);break;case 3:t.translate(n,o),t.scale(-1,-1);break}t.commitTransform();const y=this.Ce,k=(g+r+p)*y;if(o>k){const b=this.verticalAlignment;u=b.y*o-b.y*k+b.offsetY}if(y===1&&this.Mn!==null){let b=this.mi;b>d&&(b=d),u+=g,this.FA(this.Mn,t,f,u,d,r,b,m,l,a,c)}else if(this.Le!==null&&this.Di!==null)for(let b=0;bd&&(P=d),u+=g,this.FA(this.Di[b],t,f,u,d,r,P,m,l,a,c),u+=r+p}switch(this.flip){case 0:break;case 2:t.scale(-1,1),t.translate(-n,0);break;case 1:t.scale(1,-1),t.translate(0,-o);break;case 3:t.scale(-1,-1),t.translate(-n,-o);break}}FA(t,i,e,s,n,o,r,l,h,a,c){let f=0;if(l){h==="left"?f=0:h==="right"?f=n-r:h==="center"&&(f=(n-r)/2);const m=i.globalAlpha;i.globalAlpha=m/2,i.fillRect(e+f,s+o/4,r,o/2),i.globalAlpha=m;return}h==="left"?f=0:h==="right"?f=n:h==="center"&&(f=n/2);const u=TextBlock.Qb!==null?TextBlock.Qb(this,o):o*.75;i.fillText(t,e+f,s+u);let d=o/20|0;if(d===0&&(d=1),h==="right"?f-=r:h==="center"&&(f-=r/2),a){const m=TextBlock._b!==null?TextBlock._b(this,o):o*.8;this.RA(e+f,s+m,e+f+r,s+m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}if(c){let m=s+o-o/2.2|0;d%2!==0&&(m+=.5),this.RA(e+f,m,e+f+r,m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}}RA(t,i,e,s,n,o){o.beginPath(),o.lineWidth=n,o.moveTo(t,i),o.lineTo(e,s),o.stroke(),o.endPath()}Zc(t,i,e){if(!super.Zc(t,i,e))return!1;if(this.dn(t,this.Hi,!0,!1,this.naturalBounds,this.actualBounds),e){if(this.svg.getElementsByTagName("text").length===0)return!0;const n=this.svg.getElementsByClassName("gojs-td");for(let o=0;o1||this.isUnderline||this.isStrikethrough?!0:super.sd(t)}h2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("text");for(let s=0;sthis.maxLines&&(this.n|=16777216))}V2(t,i,e){const s=this.formatting===0;s&&(t=t.trim());let n=0,o=0,r=0;const l=this.kn,h=this.spacingAbove+this.spacingBelow,a=Math.max(0,this.Lp()+h),c=this.overflow===1?this.OA(l):0;if(this.Ce>=this.maxLines){e!==null&&e.e(0,a);return}let f=t;if(this.wrap===0){if(this.Pn=1,o=this.getStringWidth(t),c===0||o<=i){this.mi=Math.max(this.mi,o),this.Nn(t,this.mi),e!==null&&e.e(o,a);return}let d=this.Nd(f);f=f.substring(d.length);let m=this.Nd(f);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,f=f.substring(m.length),m=this.Nd(f),r=o;let g=d+m;s&&(g=g.trim()),o=this.getStringWidth(g)}for(s&&(m=m.trim()),d+=m,i=Math.max(1,i-c);this.getStringWidth(d)>i&&d.length>1;)d=d.substring(0,d.length-1);this.z2(!0),d+=TextBlock.Mp,r=this.getStringWidth(d),this.mi=r,this.Nn(d,r),e!==null&&e.e(r,a);return}let u=0;for(f.length===0&&(u=1,this.Nn(f,0));f.length>0;){let d=this.Nd(f);for(f=f.substring(d.length);this.getStringWidth(d)>i;){let p=1;for(o=this.getStringWidth(d.substring(0,p)),r=0;o<=i;)p++,r=o,o=this.getStringWidth(d.substring(0,p));let y=0;p===1?(y=o,n=Math.max(n,o)):(y=r,n=Math.max(n,r)),p--,p<1&&(p=1);const x=d.substring(0,p);if(this.Nn(x,y),u++,d=d.substring(p),this.Ce+u>this.maxLines)break}let m=this.Nd(f);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,f=f.substring(m.length),m=this.Nd(f),r=o;let p=d+m;s&&(p=p.trim()),o=this.getStringWidth(p)}if(s&&(d=d.trim()),d==="")continue;d[d.length-1]==="\xAD"&&(d=d.substring(0,d.length-1)+"\u2010");let g=0;if(m.length===0?(g=o,n=Math.max(n,o)):(r=this.getStringWidth(d),g=r,n=Math.max(n,r)),this.Nn(d,g),u++,this.Ce+u>this.maxLines)break}this.Pn=Math.min(this.maxLines,u),this.mi=Math.max(this.mi,n),e!==null&&e.e(this.mi,a*this.Pn)}Lv(t,i){if(this.mi===0||this.Le===null||this.Di===null||this.overflow!==1)return;const e=this.kn,s=this.overflow===1?this.OA(e):0,n=this.spacingAbove+this.spacingBelow,o=Math.max(0,this.Lp()+n),r=Math.min(this.maxLines-1,Math.max(Math.floor(i/o+.01)-1,0));if(r+1>=this.Di.length)return;this.z2(!0);let l=this.Di[r];const h=Math.max(1,t-s);for(;this.getStringWidth(l)>h&&l.length>1;)l=l.substring(0,l.length-1);l+=TextBlock.Mp;const a=this.getStringWidth(l);this.Di[r]=l,this.Di=this.Di.slice(0,r+1),this.Le[r]=a,this.Le=this.Le.slice(0,r+1),this.Pn=this.Di.length,this.mi=Math.max(this.mi,a),this.Ce=this.Pn,this.Ce===1&&(this.Mn=this.Di[0])}Nd(t){if(this.wrap===3)return t.substring(0,1);let i=t.length,e=0;const s=TextBlock.Av;for(;e=t.length?t:t.substring(0,e)}getStringWidth(t){return TextBlock.il===null?t.length*8:TextBlock.il.measureText(t).width}Lp(){if(this.oo!==null)return this.oo;const t=this.kn;let i=0;return TextBlock.il===null?(i=16,this.oo=i,i):(TextBlock.X2[t]!==void 0&&TextBlock.IA<5e3?i=TextBlock.X2[t]:(i=TextBlock.il.measureText("M").width*1.3,TextBlock.X2[t]=i,TextBlock.IA++),this.oo=i,i)}OA(t){if(TextBlock.il===null)return 6;let i=0;return TextBlock.Zb[t]!==void 0&&TextBlock.B2<5e3?i=TextBlock.Zb[t]:(i=TextBlock.il.measureText(TextBlock.Mp).width,TextBlock.Zb[t]=i,TextBlock.B2++),i}t1(t,i){return t.indexOf(` +(function() {const root=typeof globalThis=="object"&&globalThis||typeof global=="object"&&global.global===global&&global||typeof self=="object"&&self.self===self&&self||{};root.requestAnimationFrame===void 0&&(root.setImmediate===void 0?root.requestAnimationFrame=w=>root.setTimeout(w,0):root.requestAnimationFrame=root.setImmediate);class Util{static rr=root.navigator!==void 0&&root.navigator.platform!==void 0&&root.navigator.platform.match(/(iPhone|iPod|iPad|Mac)/i)!==null;static Nk(t,i,e){let s=-1;return function(){const n=this,o=arguments;s!==-1&&Util.Og(s),s=Util.Oh(()=>{s=-1,e||t.apply(n,o)},i),e&&!s&&t.apply(n,o)}}static Oh(t,i){return root.setTimeout(t,i)}static Og(t){root.clearTimeout(t)}static en(t){return root.document.createElement(t)}static o(t){throw new Error(t)}static T(t,i){let e="The object is frozen, so its properties cannot be set: "+t.toString();i!==void 0&&(e+=" to value: "+i),Util.o(e)}static qI(t,i,e,s){}static i(t,i,e,s){}static WI(t,i,e){}static JI(t,i,e){}static we(t,i,e,s){}static _(t,i,e,s){let n=Util.ND(e);s!==void 0&&(n+="."+s),Util.o(n+" is not in the range "+i+": "+t)}static ve(t){}static lr(t,i){}static ii(t){root.console&&root.console.log(t)}static wt(t){return typeof t=="object"&&t!==null}static $I(t,i,e){}static eu(t,i,e){Array.isArray(t)?i>=t.length?t.push(e):t.splice(i,0,e):Util.o("Cannot insert an object into an HTMLCollection or NodeList: "+e+" at "+i)}static tc(t,i){Array.isArray(t)?i>=t.length?t.pop():t.splice(i,1):Util.o("Cannot remove an object from an HTMLCollection or NodeList at "+i)}static Ck=[];static nt(){const t=Util.Ck.pop();return t===void 0?[]:t}static tt(t){t.length=0,Util.Ck.push(t)}static ZI=Object.freeze([]);static ND(t){return t===null?"*":typeof t=="string"?t:typeof t=="function"?t.name:""}static sn(t){return typeof t=="function"?t.className?t.className:t.name:Util.wt(t)&&t.constructor?Util.sn(t.constructor):typeof t}static Ih(t,i){return i==null||i===""?null:Util.wt(t)&&i in t||t[i]?t[i]:null}static toString(t){let i=t;return Util.wt(t)&&(t.text?i=t.text:t.name?i=t.name:t.key!==void 0?i=t.key:t.id!==void 0?i=t.id:t.constructor===Object&&(t.Text?i=t.Text:t.Name?i=t.Name:t.Key!==void 0?i=t.Key:t.Id!==void 0?i=t.Id:t.ID!==void 0&&(i=t.ID))),i===void 0?"undefined":i===null?"null":i.toString()}static fw(t,i){if(t.hasOwnProperty(i))return!0;let e=Object.getPrototypeOf(t);for(;e&&e!==Function;){if(e.hasOwnProperty(i))return!0;const s=e.QI;if(s&&s[i])return!0;e=Object.getPrototypeOf(e)}return!1}static CD(t){const i=[];let e=0;for(e=0;e<256;e++)i[e]=e;let s=0,n=0;for(e=0;e<256;e++)s=(s+i[e]+119)%256,n=i[e],i[e]=i[s],i[s]=n;e=0,s=0;let o="";for(let r=0;r>4)+i.charAt(r&15)]=String.fromCharCode(r);t.length%2&&(t="0"+t);const s=[];let n=0;for(let r=0;r0){const n=i[0];return this.key=0,this.value=n,n}else return null}any(t){const i=this.qt;i.hr=null;const e=i.ht;this.Dt=-1;const s=i.r,n=s.length,o=this.Ls;for(let r=0;r=0?(this.key=i,this.value=t.r[i],!0):(this.gl(),!1)}hasNext(){return this.next()}first(){const t=this.qt;this.Yt=t.ht;const i=t.r,e=i.length-1;if(this.Dt=e,e>=0){const s=i[e];return this.key=e,this.value=s,s}else return null}any(t){const i=this.qt;i.ar=null;const e=i.ht,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(t(r))return!0;i.ht!==e&&Util.ve(i)}return!1}all(t){const i=this.qt;i.ar=null;const e=i.ht,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];if(!t(r))return!1;i.ht!==e&&Util.ve(i)}return!0}each(t){const i=this.qt;i.ar=null;const e=i.ht,s=i.r,n=s.length;this.Dt=n;for(let o=n-1;o>=0;o--){const r=s[o];t(r),i.ht!==e&&Util.ve(i)}return this}map(t){const i=this.qt;i.ar=null;const e=i.ht,s=[],n=i.r,o=n.length;this.Dt=o;for(let l=o-1;l>=0;l--){const h=n[l];s.push(t(h)),i.ht!==e&&Util.ve(i)}const r=new List;return r.r=s,r.Oe(),r.iterator}filter(t){const i=this.qt;i.ar=null;const e=i.ht,s=[],n=i.r,o=n.length;this.Dt=o;for(let l=o-1;l>=0;l--){const h=n[l];t(h)&&s.push(h),i.ht!==e&&Util.ve(i)}const r=new List;return r.r=s,r.Oe(),r.iterator}get count(){return this.qt.r.length}gl(){this.key=-1,this.value=null,this.Yt=-1,this.qt.ar=this}toString(){return"ListIteratorBackwards("+this.Dt+"/"+this.qt.count+")"}}class List{h;r;ht;hr;ar;constructor(t){GSet.Yi(this),this.h=!1,this.r=[],this.ht=0,this.hr=null,this.ar=null,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.r.values()}Oe(){let t=this.ht;t++,t>999999999&&(t=0),this.ht=t}g(){return this.h=!0,this}ot(){return this.h=!1,this}toString(){return"List()#"+GSet.as(this)}add(t){return this.h&&Util.T(this,t),this.r.push(t),this.Oe(),this}push(t){this.add(t)}addAll(t){if(t===null)return this;this.h&&Util.T(this);const i=this.r;if(Array.isArray(t)){const e=t.length;for(let s=0;s=i.length)&&Util._(t,"0 <= i < length",List,"elt:i"),i[t]}get(t){return this.elt(t)}setElt(t,i){const e=this.r;(t<0||t>=e.length)&&Util._(t,"0 <= i < length",List,"setElt:i"),this.h&&Util.T(this,t),e[t]=i}set(t,i){this.setElt(t,i)}first(){const t=this.r;return t.length===0?null:t[0]}last(){const t=this.r,i=t.length;return i>0?t[i-1]:null}pop(){this.h&&Util.T(this);const t=this.r;return t.length>0?t.pop():null}any(t){const i=this.r,e=this.ht,s=i.length;for(let n=0;n= 0",List,"insertAt:i"),this.h&&Util.T(this,t);const e=this.r;t>=e.length?e.push(i):e.splice(t,0,i),this.Oe()}remove(t){return this.delete(t)}delete(t){if(t===null)return!1;this.h&&Util.T(this,t);const i=this.r,e=i.indexOf(t);return e===-1?!1:(e===i.length-1?i.pop():i.splice(e,1),this.Oe(),!0)}removeAt(t){const i=this.r;(t<0||t>=i.length)&&Util._(t,"0 <= i < length",List,"removeAt:i"),this.h&&Util.T(this,t),t===i.length-1?i.pop():i.splice(t,1),this.Oe()}removeRange(t,i){const e=this.r,s=e.length;if(t<0)t=0;else if(t>=s)return this;if(i<0)return this;if(i>=s&&(i=s-1),t>i)return this;this.h&&Util.T(this);let n=t,o=i+1;for(;o0&&(t.r=Array.prototype.slice.call(i)),t}toArray(){const t=this.r,i=this.count,e=new Array(i);for(let s=0;s=n-1)&&Util._(i,"0 <= from < length",List,"sortRange:from"),o===2){const r=s[i],l=s[i+1];return t(r,l)>0&&(s[i]=l,s[i+1]=r,this.Oe()),this}if(i===0)if(e>=n)s.sort(t);else{const r=s.slice(0,e);r.sort(t);for(let l=0;l=n){const r=s.slice(i);r.sort(t);for(let l=i;li.add(t(e))),i.iterator}filter(t){const i=new List;return this.ko.w.forEach(e=>{t(e)&&i.add(e)}),i.iterator}get count(){return this.ko.count}gl(){this.key=null,this.value=null,this.ei=null}toString(){return"SetIterator"}}class GSet{h;w;constructor(t){this.h=!1,this.w=new Set,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.w.values()}values(){return this.w.values()}g(){return this.h=!0,this}ot(){return this.h=!1,this}toString(){return"Set()#"+GSet.as(this)}add(t){return t===null?this:(this.w.add(t),this)}addAll(t){if(t===null)return this;if(Array.isArray(t)){const i=t.length;for(let e=0;et.add(i)),t}toArray(){return Array.from(this.w)}toList(){const t=new List;return this.w.forEach(i=>t.add(i)),t}get count(){return this.w.size}get size(){return this.w.size}get iterator(){return this.w.size<=0?EmptyIterator.instance:new SetIterator(this)}entries(){return this.w.entries()}keys(){return this.w.keys()}forEach(t,i){return this.w.forEach(t,i)}static su=1;static Yi(t){t.__gohashid=GSet.su++}static as(t){return t.__gohashid}}class MapKeySetIterator{Z;ei;constructor(t){this.Z=t,this.ei=t.w.keys()}[Symbol.iterator](){return this.Z.w.keys()}key;value;get iterator(){return this}reset(){const t=this.Z;this.ei=t.w.keys()}next(){const t=this.ei.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.Z.w.size===0?null:(this.ei=this.Z.w.keys(),this.ei.next().value)}any(t){for(const i of this.Z.w)if(t(i[0]))return!0;return!1}all(t){for(const i of this.Z.w)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.Z.w)t(i[0]);return this}map(t){const i=this.Z,e=new List;for(const s of i.w)e.add(t(s[0]));return e.iterator}filter(t){const i=this.Z,e=new List;for(const s of i.w){const n=s[0];t(n)&&e.add(n)}return e.iterator}get count(){return this.Z.size}gl(){this.key=null,this.value=null,this.ei=null}toString(){return"MapKeySetIterator"}}class MapKeySet extends GSet{Z;constructor(t){super(),GSet.Yi(this),this.h=!0,this.Z=t}[Symbol.iterator](){return this.w.keys()}values(){return this.w.keys()}g(){return this}ot(){return this}toString(){return"MapKeySet("+this.Z.toString()+")"}add(t){Util.o("This Set is read-only: "+this.toString())}has(t){return this.Z.has(t)}contains(t){return this.has(t)}delete(t){Util.o("This Set is read-only: "+this.toString())}remove(t){return this.delete(t)}clear(){Util.o("This Set is read-only: "+this.toString())}first(){return this.Z.w.size===0?null:this.Z.w.keys().next().value}any(t){for(const i of this.Z.w)if(t(i[0]))return!0;return!1}all(t){for(const i of this.Z.w)if(!t(i[0]))return!1;return!0}each(t){for(const i of this.Z.w)t(i[0]);return this}map(t){const i=new GSet;for(const e of this.Z.w)i.add(t(e[0]));return i}filter(t){const i=new GSet;for(const e of this.Z.w){const s=e[0];t(s)&&i.add(s)}return i}copy(){return new MapKeySet(this.Z)}toSet(){const t=new GSet,i=this.Z.w;for(const e of i)t.add(e[0]);return t}toArray(){const t=this.Z.w,i=new Array(t.size);let e=0;for(const s of t)i[e]=s[0],e++;return i}toList(){const t=new List,i=this.Z.w;for(const e of i)t.add(e[0]);return t}get count(){return this.Z.size}get size(){return this.Z.size}get iterator(){return this.Z.size<=0?EmptyIterator.instance:new MapKeySetIterator(this.Z)}}class MapValueSetIterator{Z;ei;constructor(t){this.Z=t,this.ei=t.w.values()}[Symbol.iterator](){return this.Z.w.values()}key;value;get iterator(){return this}reset(){const t=this.Z;this.ei=t.w.values()}next(){const t=this.ei.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.Z.w.size===0?null:(this.ei=this.Z.w.values(),this.ei.next().value)}any(t){for(const i of this.Z.w)if(t(i[1]))return!0;return!1}all(t){for(const i of this.Z.w)if(!t(i[1]))return!1;return!0}each(t){for(const i of this.Z.w)t(i[1]);return this}map(t){const i=this.Z,e=new List;for(const s of i.w)e.add(t(s[1]));return e.iterator}filter(t){const i=this.Z,e=new List;for(const s of i.w){const n=s[1];t(n)&&e.add(n)}return e.iterator}get count(){return this.Z.size}gl(){this.key=null,this.value=null,this.ei=null}toString(){return"MapValueSetIterator"}}class KeyValuePair{constructor(t,i){this.key=t,this.value=i}toString(){return"{"+this.key+":"+this.value+"}"}key;value}class MapIterator{Z;ei;constructor(t){this.Z=t,this.ei=t.w.entries()}[Symbol.iterator](){return this.Z.w.entries()}key;value;get iterator(){return this}reset(){const t=this.Z;this.ei=t.w.entries()}next(){const t=this.ei.next();return t.done?(this.key=null,this.value=null,!1):(this.key=t.value[0],this.value=t.value[1],!0)}hasNext(){return this.next()}first(){if(this.Z.w.size===0)return null;this.ei=this.Z.w.entries();const t=this.ei.next().value;return this.key=t[0],this.value=t[1],new KeyValuePair(t[0],t[1])}any(t){return this.Z.any(t)}all(t){return this.Z.all(t)}each(t){return this.Z.each(t),this}map(t){const i=new List;let e=null;return this.Z.w.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),i.add(t(e))}),i.iterator}filter(t){const i=new List;let e=null;return this.Z.w.forEach((s,n)=>{e===null?e=new KeyValuePair(n,s):(e.key=n,e.value=s),t(e)&&(i.add(e),e=null)}),i.iterator}get count(){return this.Z.size}gl(){this.key=null,this.value=null,this.ei=null}toString(){return"MapIterator"}}class GMap{h;w;constructor(t){GSet.Yi(this),this.h=!1,this.w=new Map,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.w.entries()}entries(){return this.w.entries()}g(){return this.h=!0,this}ot(){return this.h=!1,this}toString(){return"Map()#"+GSet.as(this)}set(t,i){return this.h&&Util.T(this,t),this.w.set(t,i),this}add(t,i){return this.set(t,i)}addAll(t){if(t===null)return this;if(this.h&&Util.T(this),Array.isArray(t)){const i=t.length;for(let e=0;ei.x.toFixed(t)+" "+i.y.toFixed(t)}toString(){return"Point("+this.x+","+this.y+")"}equals(t){return t instanceof Point?this.b===t.x&&this.k===t.y:!1}equalTo(t,i){return this.b===t&&this.k===i}equalsApprox(t){return Geo.u(this.b,t.x)&&Geo.u(this.k,t.y)}add(t){return this.b+=t.x,this.k+=t.y,this}subtract(t){return this.b-=t.x,this.k-=t.y,this}offset(t,i){return this.b+=t,this.k+=i,this}rotate(t){if(t===0)return this;const i=this.b,e=this.k;if(i===0&&e===0)return this;let s=0,n=0;if(t>=360?t-=360:t<0&&(t+=360),t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const o=t*Math.PI/180;s=Math.cos(o),n=Math.sin(o)}return this.b=s*i-n*e,this.k=n*i+s*e,this}scale(t,i){return this.b*=t,this.k*=i,this}distanceSquaredPoint(t){const i=t.x-this.b,e=t.y-this.k;return i*i+e*e}distanceSquared(t,i){const e=t-this.b,s=i-this.k;return e*e+s*s}normalize(){const t=this.b,i=this.k,e=Math.sqrt(t*t+i*i);return e>0&&(this.b=t/e,this.k=i/e),this}directionPoint(t){return this.JN(t.x-this.b,t.y-this.k)}direction(t,i){return this.JN(t-this.b,i-this.k)}JN(t,i){if(t===0)return i>0?90:i<0?270:0;if(i===0)return t>0?0:180;{if(isNaN(t)||isNaN(i))return 0;let e=Math.atan(Math.abs(i/t))*180/Math.PI;return t<0?i<0?e+=180:e=180-e:i<0&&(e=360-e),e}}static compareWithLineSegment(t,i,e,s,n,o){return Geo.nu(t,i,e,s,n,o)}compareWithLineSegmentPoint(t,i){return Geo.nu(t.x,t.y,i.x,i.y,this.x,this.y)}static intersectingLineSegments(t,i,e,s,n,o,r,l){return Geo.ou(t,i,e,s,n,o,r,l)}projectOntoLineSegment(t,i,e,s){return Geo.ml(t,i,e,s,this.b,this.k,this),this}projectOntoLineSegmentPoint(t,i){return Geo.ml(t.x,t.y,i.x,i.y,this.b,this.k,this),this}snapToGrid(t,i,e,s){return Geo.Ig(this.b,this.k,t,i,e,s,this),this}snapToGridPoint(t,i){return Geo.Ig(this.b,this.k,t.x,t.y,i.width,i.height,this),this}setRectSpot(t,i){return this.b=t.x+i.x*t.width+i.offsetX,this.k=t.y+i.y*t.height+i.offsetY,this}setSpot(t,i,e,s,n){return this.b=t+n.x*e+n.offsetX,this.k=i+n.y*s+n.offsetY,this}D(t){return t.xt(this),this}Ie(t){return t._e(this),this}static distanceLineSegmentSquared(t,i,e,s,n,o){let r=n-e,l=o-s;const h=r*r+l*l,a=e-t,c=s-i,f=-a*r-c*l;if(f<=0||f>=h)return r=n-t,l=o-i,Math.min(a*a+c*c,r*r+l*l);{const u=r*c-l*a;return u*u/h}}static distanceSquared(t,i,e,s){const n=e-t,o=s-i;return n*n+o*o}static direction(t,i,e,s){const n=e-t,o=s-i;if(n===0)return o>0?90:o<0?270:0;if(o===0)return n>0?0:180;{if(isNaN(n)||isNaN(o))return 0;let r=Math.atan(Math.abs(o/n))*180/Math.PI;return n<0?o<0?r+=180:r=180-r:o<0&&(r=360-r),r}}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}isReal(){return isFinite(this.x)&&isFinite(this.y)}static Po=new Point(0,0).it();static $N=new Point(-1/0,-1/0).it();static ZN=new Point(1/0,1/0).it();static QN=new Point(6,6).it();static Ak=new Point(NaN,NaN).it();static Tk=[];static l(){const t=Point.Tk.pop();return t===void 0?new Point:t}static X(t,i){const e=Point.Tk.pop();return e===void 0?new Point(t,i):(e.x=t,e.y=i,e)}static s(t){Point.Tk.push(t)}}class Size{j;H;h;constructor(t,i){t===void 0?(this.j=0,this.H=0):typeof t=="number"&&(t>=0||isNaN(t))&&typeof i=="number"&&(i>=0||isNaN(i))?(this.j=t,this.H=i):Util.o("Invalid arguments to Size constructor: "+t+", "+i),this.h=!1}a(t){return this.j=t.j,this.H=t.H,this}e(t,i){return this.j=t,this.H=i,this}setTo(t,i){return this.j=t,this.H=i,this}set(t){return this.j=t.j,this.H=t.H,this}copy(){const t=new Size;return t.j=this.j,t.H=this.H,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}ot(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;return n=i[e++],n&&(o=parseFloat(n)),new Size(s,o)}else return new Size}static stringify(t){return t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.i(t,"number",Size,"stringifyFixed:digits"),i=>i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Size("+this.width+","+this.height+")"}equals(t){return t instanceof Size?this.j===t.width&&this.H===t.height:!1}equalTo(t,i){return this.j===t&&this.H===i}equalsApprox(t){return Geo.u(this.j,t.width)&&Geo.u(this.H,t.height)}inflate(t,i){const e=this.width+t;this.j=e>=0?e:0;const s=this.height+i;return this.H=s>=0?s:0,this}get width(){return this.j}set width(t){t<0&&Util._(t,">= 0",Size,"width"),this.j=t}get height(){return this.H}set height(t){t<0&&Util._(t,">= 0",Size,"height"),this.H=t}isReal(){return isFinite(this.width)&&isFinite(this.height)}static ru=new Size(0,0).it();static Dk=new Size(1,1).it();static _N=new Size(6,6).it();static lu=new Size(8,8).it();static tC=new Size(10,10).it();static iC=new Size(1/0,1/0).it();static gw=new Size(NaN,NaN).it();static eC=[];static l(){const t=Size.eC.pop();return t===void 0?new Size:t}static s(t){Size.eC.push(t)}}class Rect{b;k;j;H;h;constructor(t,i,e,s){if(t===void 0)this.b=0,this.k=0,this.j=0,this.H=0;else if(typeof t=="number"&&typeof i=="number"&&typeof e=="number"&&(e>=0||isNaN(e))&&typeof s=="number"&&(s>=0||isNaN(s)))this.b=t,this.k=i,this.j=e,this.H=s;else if(t instanceof Point){const n=t.x,o=t.y;if(i instanceof Point){const r=i.x,l=i.y;this.b=Math.min(n,r),this.k=Math.min(o,l),this.j=Math.abs(n-r),this.H=Math.abs(o-l)}else i instanceof Size?(this.b=n,this.k=o,this.j=i.width,this.H=i.height):Util.o("Incorrect second argument supplied to Rect constructor "+i)}else Util.o("Invalid arguments to Rect constructor: "+t+", "+i+", "+e+", "+s);this.h=!1}a(t){return this.b=t.b,this.k=t.k,this.j=t.j,this.H=t.H,this}e(t,i,e,s){return this.b=t,this.k=i,this.j=e,this.H=s,this}En(t,i){return this.j=t,this.H=i,this}setTo(t,i,e,s){return this.b=t,this.k=i,this.j=e,this.H=s,this}set(t){return this.b=t.b,this.k=t.k,this.j=t.j,this.H=t.H,this}setPoint(t){return this.b=t.x,this.k=t.y,this}setSize(t){return this.j=t.width,this.H=t.height,this}copy(){const t=new Rect;return t.b=this.b,t.k=this.k,t.j=this.j,t.H=this.H,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}ot(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),new Rect(s,o,r,l)}else return new Rect}static stringify(t){return t.x.toString()+" "+t.y.toString()+" "+t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return Util.i(t,"number",Rect,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.width.toFixed(t)+" "+i.height.toFixed(t)}toString(){return"Rect("+this.x+","+this.y+","+this.width+","+this.height+")"}equals(t){return t instanceof Rect?this.b===t.x&&this.k===t.y&&this.j===t.width&&this.H===t.height:!1}equalTo(t,i,e,s){return this.b===t&&this.k===i&&this.j===e&&this.H===s}equalsApprox(t){return Geo.u(this.b,t.x)&&Geo.u(this.k,t.y)&&Geo.u(this.j,t.width)&&Geo.u(this.H,t.height)}equalsApproxTo(t,i,e,s){return Geo.u(this.b,t)&&Geo.u(this.k,i)&&Geo.u(this.j,e)&&Geo.u(this.H,s)}equalsApproxClose(t){return Geo.K(this.b,t.x)&&Geo.K(this.k,t.y)&&Geo.K(this.j,t.width)&&Geo.K(this.H,t.height)}containsPoint(t){return this.b<=t.x&&this.b+this.j>=t.x&&this.k<=t.y&&this.k+this.H>=t.y}containsRect(t){return this.b<=t.x&&t.x+t.width<=this.b+this.j&&this.k<=t.y&&t.y+t.height<=this.k+this.H}contains(t,i,e,s){return e===void 0&&(e=0),s===void 0&&(s=0),this.b<=t&&t+e<=this.b+this.j&&this.k<=i&&i+s<=this.k+this.H}offset(t,i){return this.b+=t,this.k+=i,this}inflate(t,i){return this.mw(i,t,i,t)}addMargin(t){return this.mw(t.top,t.right,t.bottom,t.left)}subtractMargin(t){return this.mw(-t.top,-t.right,-t.bottom,-t.left)}grow(t,i,e,s){return this.mw(t,i,e,s)}mw(t,i,e,s){const n=this.j;i+s<=-n?(this.b+=n/2,this.j=0):(this.b-=s,this.j+=i+s);const o=this.H;return t+e<=-o?(this.k+=o/2,this.H=0):(this.k-=t,this.H+=t+e),this}intersectRect(t){return this.sC(t.x,t.y,t.width,t.height)}intersect(t,i,e,s){return this.sC(t,i,e,s)}sC(t,i,e,s){const n=Math.max(this.b,t),o=Math.max(this.k,i),r=Math.min(this.b+this.j,t+e),l=Math.min(this.k+this.H,i+s);return this.b=n,this.k=o,this.j=Math.max(0,r-n),this.H=Math.max(0,l-o),this}intersectsRect(t){return this.intersects(t.x,t.y,t.width,t.height)}intersects(t,i,e,s){let n=this.j;const o=this.b;if(n!==1/0&&e!==1/0&&(n+=o,e+=t,isNaN(e)||isNaN(n)||o>e||t>n))return!1;let r=this.H;const l=this.k;return!(r!==1/0&&s!==1/0&&(r+=l,s+=i,isNaN(s)||isNaN(r)||l>s||i>r))}intersectsRectPlus(t,i){let e=this.j,s=t.width+i+i;const n=this.b,o=t.x-i;if(e+=n,s+=o,n>s||o>e)return!1;let r=this.H,l=t.height+i+i;const h=this.k,a=t.y-i;return r+=h,l+=a,!(h>l||a>r)}unionPoint(t){return this.unionNoCheck(t.x,t.y,0,0)}unionRect(t){return this.unionNoCheck(t.b,t.k,t.j,t.H)}union(t,i,e,s){return e===void 0&&(e=0),s===void 0&&(s=0),this.unionNoCheck(t,i,e,s)}unionNoCheck(t,i,e,s){const n=Math.min(this.b,t),o=Math.min(this.k,i),r=Math.max(this.b+this.j,t+e),l=Math.max(this.k+this.H,i+s);return this.b=n,this.k=o,this.j=r-n,this.H=l-o,this}setSpot(t,i,e){return this.b=t-e.offsetX-e.x*this.j,this.k=i-e.offsetY-e.y*this.H,this}static contains(t,i,e,s,n,o,r,l){return r===void 0&&(r=0),l===void 0&&(l=0),t<=n&&n+r<=t+e&&i<=o&&o+l<=i+s}static intersects(t,i,e,s,n,o,r,l){let h=e,a=r;const c=t,f=n;if(h+=c,a+=f,c>a||f>h)return!1;let u=s,d=l;const m=i,g=o;return u+=m,d+=g,!(m>d||g>u)}static intersectsLineSegment(t,i,e,s,n,o,r,l){return Geo.nC(t,i,e,s,n,o,r,l)}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}get width(){return this.j}set width(t){t<0&&Util._(t,">= 0",Rect,"width"),this.j=t}get height(){return this.H}set height(t){t<0&&Util._(t,">= 0",Rect,"height"),this.H=t}get left(){return this.b}set left(t){this.b=t}get top(){return this.k}set top(t){this.k=t}get right(){return this.b+this.j}set right(t){this.b+=t-(this.b+this.j)}get bottom(){return this.k+this.H}set bottom(t){this.k+=t-(this.k+this.H)}get position(){return new Point(this.b,this.k)}set position(t){this.b=t.x,this.k=t.y}get size(){return new Size(this.j,this.H)}set size(t){this.j=t.width,this.H=t.height}get center(){return new Point(this.b+this.j/2,this.k+this.H/2)}set center(t){this.b=t.x-this.j/2,this.k=t.y-this.H/2}get centerX(){return this.b+this.j/2}set centerX(t){this.b=t-this.j/2}get centerY(){return this.k+this.H/2}set centerY(t){this.k=t-this.H/2}isReal(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)}isEmpty(){return this.width===0&&this.height===0}static pw=new Rect(0,0,0,0).it();static AD=new Rect(NaN,NaN,NaN,NaN).it();static Fk=[];static l(){const t=Rect.Fk.pop();return t===void 0?new Rect:t}static X(t,i,e,s){const n=Rect.Fk.pop();return n===void 0?new Rect(t,i,e,s):n.e(t,i,e,s)}static s(t){Rect.Fk.push(t)}}class Margin{nn;on;rn;ln;h;constructor(t,i,e,s){t===void 0?(this.nn=0,this.on=0,this.rn=0,this.ln=0):i===void 0?(i=t,e=t,s=t,this.top=t,this.right=i,this.bottom=e,this.left=s):e===void 0?(e=t,s=i,this.top=t,this.right=i,this.bottom=e,this.left=s):s!==void 0?(this.top=t,this.right=i,this.bottom=e,this.left=s):Util.o("Invalid arguments to Margin constructor: "+t+", "+i+", "+e+", "+s),this.h=!1}a(t){return this.nn=t.nn,this.on=t.on,this.rn=t.rn,this.ln=t.ln,this}setTo(t,i,e,s){return this.nn=t,this.on=i,this.rn=e,this.ln=s,this}set(t){return this.nn=t.nn,this.on=t.on,this.rn=t.rn,this.ln=t.ln,this}copy(){const t=new Margin;return t.nn=this.nn,t.on=this.on,t.rn=this.rn,t.ln=this.ln,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}ot(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}static parse(t){if(typeof t=="string"){const i=t.split(" ");let e=0,s=NaN;for(;i[e]==="";)e++;let n=i[e++];if(n&&(s=parseFloat(n)),isNaN(s))return new Margin;let o=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(o=parseFloat(n)),isNaN(o))return new Margin(s);let r=NaN;for(;i[e]==="";)e++;if(n=i[e++],n&&(r=parseFloat(n)),isNaN(r))return new Margin(s,o);let l=NaN;for(;i[e]==="";)e++;return n=i[e++],n&&(l=parseFloat(n)),isNaN(l)?new Margin(s,o):new Margin(s,o,r,l)}else return new Margin}static stringify(t){return t.top.toString()+" "+t.right.toString()+" "+t.bottom.toString()+" "+t.left.toString()}static stringifyFixed(t){return Util.i(t,"number",Margin,"stringifyFixed:digits"),i=>i.top.toFixed(t)+" "+i.right.toFixed(t)+" "+i.bottom.toFixed(t)+" "+i.left.toFixed(t)}toString(){return"Margin("+this.top+","+this.right+","+this.bottom+","+this.left+")"}equals(t){return t instanceof Margin?this.nn===t.top&&this.on===t.right&&this.rn===t.bottom&&this.ln===t.left:!1}equalTo(t,i,e,s){return this.nn===t&&this.on===i&&this.rn===e&&this.ln===s}equalsApprox(t){return Geo.u(this.nn,t.top)&&Geo.u(this.on,t.right)&&Geo.u(this.rn,t.bottom)&&Geo.u(this.ln,t.left)}get top(){return this.nn}set top(t){this.nn=t}get right(){return this.on}set right(t){this.on=t}get bottom(){return this.rn}set bottom(t){this.rn=t}get left(){return this.ln}set left(t){this.ln=t}isReal(){return isFinite(this.top)&&isFinite(this.right)&&isFinite(this.bottom)&&isFinite(this.left)}static Eg=new Margin(0,0,0,0).it();static oC=new Margin(2,2,2,2).it();static rC=[];static l(){const t=Margin.rC.pop();return t===void 0?new Margin:t}static s(t){Margin.rC.push(t)}}class Spot{b;k;As;Ts;h;constructor(t,i,e,s){t===void 0?(this.b=0,this.k=0,this.As=0,this.Ts=0):(i===void 0&&(i=0),e===void 0&&(e=0),s===void 0&&(s=0),this.x=t,this.y=i,this.offsetX=e,this.offsetY=s),this.h=!1}a(t){return this.b=t.b,this.k=t.k,this.As=t.As,this.Ts=t.Ts,this}setTo(t,i,e,s){return this.b=t,this.k=i,this.As=e,this.Ts=s,this}set(t){return this.b=t.b,this.k=t.k,this.As=t.As,this.Ts=t.Ts,this}copy(){const t=new Spot;return t.b=this.b,t.k=this.k,t.As=this.As,t.Ts=this.Ts,t}it(){return this.h=!0,Object.freeze(this),this}N(){return this.h||Object.isFrozen(this)?this:this.copy().g()}g(){return this.h=!0,this}ot(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this}dw(t){}Ee(t){return this.b=NaN,this.k=NaN,this.As=t,this}_I(t,i){(isNaN(t)||t>1||t<0)&&Util._(t,"0 <= "+i+" <= 1",Spot,i)}tE(t,i){(isNaN(t)||t===1/0||t===-1/0)&&Util._(t,"real number, not NaN or Infinity",Spot,i)}static parse(t){if(typeof t=="string"){if(t=t.trim(),t==="None")return Spot.None;if(t==="TopLeft")return Spot.TopLeft;if(t==="Top"||t==="TopCenter"||t==="MiddleTop")return Spot.TopCenter;if(t==="TopRight")return Spot.TopRight;if(t==="Left"||t==="LeftCenter"||t==="MiddleLeft")return Spot.LeftCenter;if(t==="Center")return Spot.Center;if(t==="Right"||t==="RightCenter"||t==="MiddleRight")return Spot.RightCenter;if(t==="BottomLeft")return Spot.BottomLeft;if(t==="Bottom"||t==="BottomCenter"||t==="MiddleBottom")return Spot.BottomCenter;if(t==="BottomRight")return Spot.BottomRight;if(t==="TopSide")return Spot.TopSide;if(t==="LeftSide")return Spot.LeftSide;if(t==="RightSide")return Spot.RightSide;if(t==="BottomSide")return Spot.BottomSide;if(t==="TopBottomSides")return Spot.TopBottomSides;if(t==="LeftRightSides")return Spot.LeftRightSides;if(t==="TopLeftSides")return Spot.TopLeftSides;if(t==="TopRightSides")return Spot.TopRightSides;if(t==="BottomLeftSides")return Spot.BottomLeftSides;if(t==="BottomRightSides")return Spot.BottomRightSides;if(t==="NotTopSide")return Spot.NotTopSide;if(t==="NotLeftSide")return Spot.NotLeftSide;if(t==="NotRightSide")return Spot.NotRightSide;if(t==="NotBottomSide")return Spot.NotBottomSide;if(t==="AllSides")return Spot.AllSides;if(t==="Default")return Spot.Default;const i=t.split(" ");let e=0,s=0;for(;i[e]==="";)e++;let n=i[e++];n!==void 0&&n.length>0&&(s=parseFloat(n));let o=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(o=parseFloat(n));let r=0;for(;i[e]==="";)e++;n=i[e++],n!==void 0&&n.length>0&&(r=parseFloat(n));let l=0;for(;i[e]==="";)e++;return n=i[e++],n!==void 0&&n.length>0&&(l=parseFloat(n)),new Spot(s,o,r,l)}else return new Spot}static stringify(t){return t.isSpot()?t.x.toString()+" "+t.y.toString()+" "+t.offsetX.toString()+" "+t.offsetY.toString():t.toString()}static stringifyFixed(t){return Util.i(t,"number",Spot,"stringifyFixed:digits"),i=>i.x.toFixed(t)+" "+i.y.toFixed(t)+" "+i.offsetX.toFixed(t)+" "+i.offsetY.toFixed(t)}toString(){return this.isSpot()?this.As===0&&this.Ts===0?"Spot("+this.x+","+this.y+")":"Spot("+this.x+","+this.y+","+this.offsetX+","+this.offsetY+")":this.equals(Spot.None)?"None":this.equals(Spot.TopLeft)?"TopLeft":this.equals(Spot.TopCenter)?"Top":this.equals(Spot.TopRight)?"TopRight":this.equals(Spot.LeftCenter)?"Left":this.equals(Spot.Center)?"Center":this.equals(Spot.RightCenter)?"Right":this.equals(Spot.BottomLeft)?"BottomLeft":this.equals(Spot.BottomCenter)?"Bottom":this.equals(Spot.BottomRight)?"BottomRight":this.equals(Spot.TopSide)?"TopSide":this.equals(Spot.LeftSide)?"LeftSide":this.equals(Spot.RightSide)?"RightSide":this.equals(Spot.BottomSide)?"BottomSide":this.equals(Spot.TopBottomSides)?"TopBottomSides":this.equals(Spot.LeftRightSides)?"LeftRightSides":this.equals(Spot.TopLeftSides)?"TopLeftSides":this.equals(Spot.TopRightSides)?"TopRightSides":this.equals(Spot.BottomLeftSides)?"BottomLeftSides":this.equals(Spot.BottomRightSides)?"BottomRightSides":this.equals(Spot.NotTopSide)?"NotTopSide":this.equals(Spot.NotLeftSide)?"NotLeftSide":this.equals(Spot.NotRightSide)?"NotRightSide":this.equals(Spot.NotBottomSide)?"NotBottomSide":this.equals(Spot.AllSides)?"AllSides":this.equals(Spot.Default)?"Default":"None"}equals(t){return t instanceof Spot?(this.b===t.x||isNaN(this.b)&&isNaN(t.x))&&(this.k===t.y||isNaN(this.k)&&isNaN(t.y))&&this.As===t.offsetX&&this.Ts===t.offsetY:!1}opposite(){return new Spot(.5-(this.b-.5),.5-(this.k-.5),-this.As,-this.Ts)}includesSide(t){if(!this.isSide())return!1;if(!t.isSide())if(t.equals(Spot.Left))t=Spot.LeftSide;else if(t.equals(Spot.Right))t=Spot.RightSide;else if(t.equals(Spot.Top))t=Spot.TopSide;else if(t.equals(Spot.Bottom))t=Spot.BottomSide;else return!1;const i=this.Ts,e=t.offsetY;return(i&e)===e}get x(){return this.b}set x(t){this.b=t}get y(){return this.k}set y(t){this.k=t}get offsetX(){return this.As}set offsetX(t){this.As=t}get offsetY(){return this.Ts}set offsetY(t){this.Ts=t}isSpot(){return!isNaN(this.x)&&!isNaN(this.y)}isNoSpot(){return isNaN(this.x)||isNaN(this.y)}isSide(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===1&&this.offsetY!==0}isNone(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===0&&this.offsetY===0}isDefault(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===-1&&this.offsetY===0}static None=new Spot(0,0,0,0).Ee(0).it();static Default=new Spot(0,0,-1,0).Ee(-1).it();static TopLeft=new Spot(0,0,0,0).it();static TopCenter=new Spot(.5,0,0,0).it();static TopRight=new Spot(1,0,0,0).it();static LeftCenter=new Spot(0,.5,0,0).it();static Center=new Spot(.5,.5,0,0).it();static RightCenter=new Spot(1,.5,0,0).it();static BottomLeft=new Spot(0,1,0,0).it();static BottomCenter=new Spot(.5,1,0,0).it();static BottomRight=new Spot(1,1,0,0).it();static MiddleTop=Spot.TopCenter;static MiddleLeft=Spot.LeftCenter;static MiddleRight=Spot.RightCenter;static MiddleBottom=Spot.BottomCenter;static Top=Spot.TopCenter;static Left=Spot.LeftCenter;static Right=Spot.RightCenter;static Bottom=Spot.BottomCenter;static TopSide=new Spot(0,0,1,1).Ee(1).it();static LeftSide=new Spot(0,0,1,2).Ee(1).it();static RightSide=new Spot(0,0,1,4).Ee(1).it();static BottomSide=new Spot(0,0,1,8).Ee(1).it();static TopBottomSides=new Spot(0,0,1,9).Ee(1).it();static LeftRightSides=new Spot(0,0,1,6).Ee(1).it();static TopLeftSides=new Spot(0,0,1,3).Ee(1).it();static TopRightSides=new Spot(0,0,1,5).Ee(1).it();static BottomLeftSides=new Spot(0,0,1,10).Ee(1).it();static BottomRightSides=new Spot(0,0,1,12).Ee(1).it();static NotTopSide=new Spot(0,0,1,14).Ee(1).it();static NotLeftSide=new Spot(0,0,1,13).Ee(1).it();static NotRightSide=new Spot(0,0,1,11).Ee(1).it();static NotBottomSide=new Spot(0,0,1,7).Ee(1).it();static AllSides=new Spot(0,0,1,15).Ee(1).it();static Rk=new Spot(.156,.156).it();static vk=new Spot(.844,.844).it();static lC=[];static l(){const t=Spot.lC.pop();return t===void 0?new Spot:t}static s(t){Spot.lC.push(t)}}class Transform{m11;m12;m21;m22;dx;dy;constructor(){this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0}set(t){return this.m11=t.m11,this.m12=t.m12,this.m21=t.m21,this.m22=t.m22,this.dx=t.dx,this.dy=t.dy,this}setTo(t,i,e,s,n,o){return this.m11=t,this.m12=i,this.m21=e,this.m22=s,this.dx=n,this.dy=o,this}copy(){const t=new Transform;return t.m11=this.m11,t.m12=this.m12,t.m21=this.m21,t.m22=this.m22,t.dx=this.dx,t.dy=this.dy,t}toString(){return"Transform("+this.m11+","+this.m12+","+this.m21+","+this.m22+","+this.dx+","+this.dy+")"}equals(t){return this.m11===t.m11&&this.m12===t.m12&&this.m21===t.m21&&this.m22===t.m22&&this.dx===t.dx&&this.dy===t.dy}Ok(){return this.dx===0&&this.dy===0&&this.m11===1&&this.m12===0&&this.m21===0&&this.m22===1}Ri(){return this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0,this}ic(t){const i=this.m11*t.m11+this.m21*t.m12,e=this.m12*t.m11+this.m22*t.m12,s=this.m11*t.m21+this.m21*t.m22,n=this.m12*t.m21+this.m22*t.m22;return this.dx=this.m11*t.dx+this.m21*t.dy+this.dx,this.dy=this.m12*t.dx+this.m22*t.dy+this.dy,this.m11=i,this.m12=e,this.m21=s,this.m22=n,this}hC(t){const i=1/(t.m11*t.m22-t.m12*t.m21),e=t.m22*i,s=-t.m12*i,n=-t.m21*i,o=t.m11*i,r=i*(t.m21*t.dy-t.m22*t.dx),l=i*(t.m12*t.dx-t.m11*t.dy),h=this.m11*e+this.m21*s,a=this.m12*e+this.m22*s,c=this.m11*n+this.m21*o,f=this.m12*n+this.m22*o;return this.dx=this.m11*r+this.m21*l+this.dx,this.dy=this.m12*r+this.m22*l+this.dy,this.m11=h,this.m12=a,this.m21=c,this.m22=f,this}yw(){const t=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*t,e=-this.m12*t,s=-this.m21*t,n=this.m11*t,o=t*(this.m21*this.dy-this.m22*this.dx),r=t*(this.m12*this.dx-this.m11*this.dy);return this.m11=i,this.m12=e,this.m21=s,this.m22=n,this.dx=o,this.dy=r,this}cs(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return this;this.Ds(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m11*s+this.m21*n,r=this.m12*s+this.m22*n,l=this.m11*-n+this.m21*s,h=this.m12*-n+this.m22*s;return this.m11=o,this.m12=r,this.m21=l,this.m22=h,this.Ds(-i,-e),this}Ds(t,i){return this.dx+=this.m11*t+this.m21*i,this.dy+=this.m12*t+this.m22*i,this}et(t,i){return i===void 0&&(i=t),this.m11*=t,this.m12*=t,this.m21*=i,this.m22*=i,this}TD(){if(this.m11===1&&this.m12===0)return 0;let t=Math.atan2(this.m12,this.m11)*180/Math.PI;return t<0&&(t+=360),t}xt(t){const i=t.x,e=t.y;return t.e(i*this.m11+e*this.m21+this.dx,i*this.m12+e*this.m22+this.dy)}_e(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=t.x-this.dx,l=t.y-this.dy;return t.e(r*e+l*n,r*s+l*o)}ww(t){const i=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*i,s=-this.m12*i,n=-this.m21*i,o=this.m11*i,r=i*(this.m21*this.dy-this.m22*this.dx),l=i*(this.m12*this.dx-this.m11*this.dy),h=t.x*1.25,a=t.y*1.2;return t.e(h*e+a*n+r,h*s+a*o+l)}xw(t){const i=t.x,e=t.y,s=i+t.width,n=e+t.height,o=this.m11,r=this.m12,l=this.m21,h=this.m22,a=this.dx,c=this.dy,f=i*o+e*l+a,u=i*r+e*h+c,d=s*o+e*l+a,m=s*r+e*h+c,g=i*o+n*l+a,p=i*r+n*h+c,y=s*o+n*l+a,x=s*r+n*h+c;let k=f,b=f,P=u,S=u;return k=Math.min(k,d),b=Math.max(b,d),P=Math.min(P,m),S=Math.max(S,m),k=Math.min(k,g),b=Math.max(b,g),P=Math.min(P,p),S=Math.max(S,p),k=Math.min(k,y),b=Math.max(b,y),P=Math.min(P,x),S=Math.max(S,x),t.e(k,P,b-k,S-P),t}static aC=[];static l(){const t=Transform.aC.pop();return t===void 0?new Transform:t}static s(t){Transform.aC.push(t)}static Ik="54a702f3e53909c447824c6706603faf4c"}const Geo={DD:"7da71ca0ad381e90",Bn:4*((Math.sqrt(2)-1)/3),cC:null,bw:w=>{if(w<=0)return 0;let t=Geo.cC;if(t===null){t=[];for(let i=0;i<=2e3;i++)t[i]=Math.sqrt(i);Geo.cC=t}if(w<1){const i=1/w;return i<=2e3?1/t[i|0]:Math.sqrt(w)}else return w<=2e3?t[w|0]:Math.sqrt(w)},u:(w,t)=>{const i=w-t;return i<.5&&i>-.5},K:(w,t)=>{const i=w-t;return i<5e-8&&i>-5e-8},vi:(w,t,i,e,s,n,o)=>{s<=0&&(s=1e-6);let r=0,l=0,h=0,a=0;if(wu-d)if(w-i>s||i-w>s){const g=(e-t)/(i-w)*(n-w)+t;if(g-s<=o&&o<=g+s)return!0}else return!0;else if(t-e>s||e-t>s){const g=(i-w)/(e-t)*(o-t)+w;if(g-s<=n&&n<=g+s)return!0}else return!0}return!1},kw:(w,t,i,e,s,n,o,r,l,h,a,c)=>{if(!Geo.vi(w,t,o,r,c,i,e)||!Geo.vi(w,t,o,r,c,s,n)){const f=(w+i)/2,u=(t+e)/2,d=(i+s)/2,m=(e+n)/2,g=(s+o)/2,p=(n+r)/2,y=(f+d)/2,x=(u+m)/2,k=(d+g)/2,b=(m+p)/2,P=(y+k)/2,S=(x+b)/2;return Geo.kw(w,t,f,u,y,x,P,S,l,h,a,c)||Geo.kw(P,S,k,b,g,p,o,r,l,h,a,c)}else return Geo.vi(w,t,o,r,c,h,a)},fC:(w,t,i,e,s,n,o,r,l)=>{const h=(w+i)/2,a=(t+e)/2,c=(i+s)/2,f=(e+n)/2,u=(s+o)/2,d=(n+r)/2,m=(h+c)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2;return l.e((m+p)/2,(g+y)/2),l},FD:(w,t,i,e,s,n,o,r)=>{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(s+o)/2,u=(n+r)/2,d=(l+a)/2,m=(h+c)/2,g=(a+f)/2,p=(c+u)/2;return Point.direction(d,m,g,p)},hu:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.vi(w,t,o,r,l,i,e)||!Geo.vi(w,t,o,r,l,s,n)){const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.hu(w,t,a,c,g,p,k,b,l,h),Geo.hu(k,b,y,x,d,m,o,r,l,h)}else h.unionNoCheck(w,t,0,0),h.unionNoCheck(o,r,0,0);return h},Un:(w,t,i,e,s,n,o,r,l,h)=>{if(!Geo.vi(w,t,o,r,l,i,e)||!Geo.vi(w,t,o,r,l,s,n)){const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(s+o)/2,m=(n+r)/2,g=(a+f)/2,p=(c+u)/2,y=(f+d)/2,x=(u+m)/2,k=(g+y)/2,b=(p+x)/2;Geo.Un(w,t,a,c,g,p,k,b,l,h),Geo.Un(k,b,y,x,d,m,o,r,l,h)}else h.length===0&&(h.push(w),h.push(t)),h.push(o),h.push(r);return h},Ek:(w,t,i,e,s,n,o,r,l,h)=>{if(Geo.vi(w,t,s,n,h,i,e))return Geo.vi(w,t,s,n,h,r,l);{const a=(w+i)/2,c=(t+e)/2,f=(i+s)/2,u=(e+n)/2,d=(a+f)/2,m=(c+u)/2;return Geo.Ek(w,t,a,c,d,m,o,r,l,h)||Geo.Ek(d,m,f,u,s,n,o,r,l,h)}},iE:(w,t,i,e,s,n,o)=>{const r=(w+i)/2,l=(t+e)/2,h=(i+s)/2,a=(e+n)/2;return o.e((r+h)/2,(l+a)/2),o},Bk:(w,t,i,e,s,n,o,r)=>{if(Geo.vi(w,t,s,n,o,i,e))r.unionNoCheck(w,t,0,0),r.unionNoCheck(s,n,0,0);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(l+a)/2,u=(h+c)/2;Geo.Bk(w,t,l,h,f,u,o,r),Geo.Bk(f,u,a,c,s,n,o,r)}return r},Bg:(w,t,i,e,s,n,o,r)=>{if(Geo.vi(w,t,s,n,o,i,e))r.length===0&&(r.push(w),r.push(t)),r.push(s),r.push(n);else{const l=(w+i)/2,h=(t+e)/2,a=(i+s)/2,c=(e+n)/2,f=(l+a)/2,u=(h+c)/2;Geo.Bg(w,t,l,h,f,u,o,r),Geo.Bg(f,u,a,c,s,n,o,r)}return r},Ug:(w,t,i,e,s,n,o,r,l,h,a,c,f,u)=>{if(!Geo.vi(w,t,o,r,f,i,e)||!Geo.vi(w,t,o,r,f,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,P=(g+y)/2,S=(p+x)/2,L=(k+P)/2,C=(b+S)/2;let M=1/0,N=!1,T=0,A=0;if(Geo.Ug(w,t,d,m,k,b,L,C,l,h,a,c,f,u)){const D=(u.x-l)*(u.x-l)+(u.y-h)*(u.y-h);D{let u=0;if(!Geo.vi(w,t,o,r,f,i,e)||!Geo.vi(w,t,o,r,f,s,n)){const d=(w+i)/2,m=(t+e)/2,g=(i+s)/2,p=(e+n)/2,y=(s+o)/2,x=(n+r)/2,k=(d+g)/2,b=(m+p)/2,P=(g+y)/2,S=(p+x)/2,L=(k+P)/2,C=(b+S)/2;u+=Geo.Vg(w,t,d,m,k,b,L,C,l,h,a,c,f),u+=Geo.Vg(L,C,P,S,y,x,o,r,l,h,a,c,f)}else{const d=(w-o)*(h-c)-(t-r)*(l-a);if(d===0)return u;const m=((w*r-t*o)*(l-a)-(w-o)*(l*c-h*a))/d,g=((w*r-t*o)*(h-c)-(t-r)*(l*c-h*a))/d;if(m>=a)return u;let p=0,y=0;if((l>a?l-a:a-l)<(h>c?h-c:c-h)){if(ty)return u}else if(wy)return u;d>0?u++:d<0&&u--}return u},ml:(w,t,i,e,s,n,o)=>{if(Geo.K(w,i)){let r=0,l=0;tl?(o.e(w,l),!1):(o.e(w,h),!0)}else if(Geo.K(t,e)){let r=0,l=0;wl?(o.e(l,t),!1):(o.e(h,t),!0)}else{const r=(i-w)*(i-w)+(e-t)*(e-t),l=((w-s)*(w-i)+(t-n)*(t-e))/r;if(l<-5e-6)return o.e(w,t),!1;if(l>1.000005)return o.e(i,e),!1;{const h=w+l*(i-w),a=t+l*(e-t);return o.e(h,a),!0}}},Vn:(w,t,i,e,s,n,o,r,l)=>{if(Geo.u(w,i)&&Geo.u(t,e))return l.e(w,t),!1;if(Geo.K(s,o)){if(Geo.K(w,i))return Geo.ml(w,t,i,e,s,n,l),!1;{const a=(e-t)/(i-w)*(s-w)+t;return Geo.ml(w,t,i,e,s,a,l)}}else{const h=(r-n)/(o-s);if(Geo.K(w,i)){const a=h*(w-s)+n;let c=0,f=0;return tf?(l.e(w,f),!1):(l.e(w,a),!0)}else{const a=(e-t)/(i-w);if(Geo.K(h,a))return Geo.ml(w,t,i,e,s,n,l),!1;{const c=(a*w-h*s+n-t)/(a-h);if(Geo.K(a,0)){let f=0,u=0;return wu?(l.e(u,t),!1):(l.e(c,t),!0)}else{const f=a*(c-w)+t;return Geo.ml(w,t,i,e,c,f,l)}}}}},eE:(w,t,i,e,s)=>Geo.Vn(i.x,i.y,e.x,e.y,w.x,w.y,t.x,t.y,s),sE:(w,t,i,e,s,n,o,r,l,h)=>{let a=1/0;function c(P,S){const L=(P-w)*(P-w)+(S-t)*(S-t);Lw?i-w:w-i)<.5){const P=1-(i-k)*(i-k)/(y*y);if(P<0)return l;const S=Math.sqrt(P),L=x*S+b,C=-x*S+b;c(i,L),c(i,C)}else{const P=(e-t)/(i-w),S=1/(y*y)+P*P/(x*x),L=2*P*(t-P*w)/(x*x)-2*P*b/(x*x)-2*k/(y*y),C=2*P*w*b/(x*x)-2*t*b/(x*x)+b*b/(x*x)+k*k/(y*y)-1+(t-P*w)*(t-P*w)/(x*x),M=L*L-4*S*C;if(M<0)return l;const N=Math.sqrt(M),T=(-L+N)/(2*S);c(T,P*T-P*w+t);const A=(-L-N)/(2*S);c(A,P*A-P*w+t)}return l},pl:(w,t,i,e,s,n,o,r,l)=>{let h=1e21,a=w,c=t;if(Geo.Vn(w,t,w,e,s,n,o,r,l)){const f=(l.x-s)*(l.x-s)+(l.y-n)*(l.y-n);fGeo.nC(w.x,w.y,w.width,w.height,t.x,t.y,i.x,i.y),nC:(w,t,i,e,s,n,o,r)=>{const l=w,h=w+i,a=t,c=t+e;if(s===o){let f=0,u=0;return n=a}if(n===r){let f=0,u=0;return s=l}return!!(Rect.contains(w,t,i,e,s,n)||Rect.contains(w,t,i,e,o,r)||Geo.ou(l,a,h,a,s,n,o,r)||Geo.ou(h,a,h,c,s,n,o,r)||Geo.ou(h,c,l,c,s,n,o,r)||Geo.ou(l,c,l,a,s,n,o,r))},ou:(w,t,i,e,s,n,o,r)=>w===i&&t===e&&s===o&&n===r?w===s&&t===n:Geo.nu(w,t,i,e,s,n)*Geo.nu(w,t,i,e,o,r)<=0&&Geo.nu(s,n,o,r,w,t)*Geo.nu(s,n,o,r,i,e)<=0,nu:(w,t,i,e,s,n)=>{const o=i-w,r=e-t;let l=s-w,h=n-t,a=l*r-h*o;return a===0&&(a=l*o+h*r,a>0&&(l-=o,h-=r,a=l*o+h*r,a<0&&(a=0))),a},zg:w=>(w<0&&(w+=360),w>=360&&(w-=360),w),uC:(w,t,i,e,s,n)=>{const o=Math.PI;n||(e=e*(o/180),s=s*(o/180));const r=e>s?-1:1,l=1e-5,h=o*2,a=[],c=o/2;let f=e,u=Math.min(h,Math.abs(s-e));if(ul;){const d=f+r*Math.min(u,c);a.push(Geo.RD(i,f,d,w,t)),u-=Math.abs(d-f),f=d}return a},RD:(w,t,i,e,s)=>{const n=(i-t)/2,o=w*Math.cos(n),r=w*Math.sin(n),l=o,h=-r,a=l*l+h*h,c=a+l*o+h*r,f=4/3*(Math.sqrt(2*a*c)-c)/(l*r-h*o),u=l-f*h,d=h+f*l,m=u,g=-d,p=n+t,y=Math.cos(p),x=Math.sin(p);return[e+w*Math.cos(t),s+w*Math.sin(t),e+u*y-d*x,s+u*x+d*y,e+m*y-g*x,s+m*x+g*y,e+w*Math.cos(i),s+w*Math.sin(i)]},Ig:(w,t,i,e,s,n,o)=>{const r=s,l=n,h=Math.floor((w-i)/r)*r+i,a=Math.floor((t-e)/l)*l+e;let c=h;h+r-w{let i=Math.max(w,t),e=Math.min(w,t),s=1,n=1;do s=i%e,n=e,i=e,e=s;while(s>0);return n},vD:(w,t,i,e)=>{const s=i<0,n=e<0;let o=0,r=0,l=0;w{let o=0;if(e>0)if(i>0){const r=w*w,l=t*t,h=w*i,a=t*e;let c=-l+a,f=-l+Math.sqrt(h*h+a*a),u=c;const d=9999999999;for(let p=0;p0)c=u;else if(k<0)f=u;else break}s=r*i/(u+r),n=l*e/(u+l);const m=s-i,g=n-e;o=Math.sqrt(m*m+g*g)}else s=0,n=t,o=Math.abs(e-t);else{const r=w*w-t*t,l=w*i;if(l(w[w.Line=1]="Line",w[w.Rectangle=2]="Rectangle",w[w.Ellipse=3]="Ellipse",w[w.Path=4]="Path",w))(GeometryType||{}),GeometryStretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w))(GeometryStretch||{});class Geometry{n;Yg;Gg;ec;au;cu;zn;Xn;Kn;$;xe;be;Qi;_i;Fs;sc;nc;constructor(t){GSet.Yi(this),this.n=2,t===void 0&&(t=4),this.$=t,this.xe=0,this.be=0,this.Qi=0,this._i=0,t===4?this.Fs=new List:this.Fs=Geometry.Sw,this.Yg=this.Fs.ht,this.Gg=new Rect().g(),this.ec=null,this.au=null,this.cu=NaN,this.zn=Spot.TopLeft,this.Xn=Spot.BottomRight,this.sc=NaN,this.nc=NaN,this.Kn=2}copy(){const t=new Geometry;if(t.n=this.n&-2,t.$=this.$,t.xe=this.xe,t.be=this.be,t.Qi=this.Qi,t._i=this._i,this.$===4){const i=this.Fs.r,e=t.Fs;for(let s=0;si.toString(t)}ri(t){t in GeometryType?this.type=t:Util.lr(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e;switch(this.type){case 1:return t<0?"M"+this.startX.toString()+" "+this.startY.toString()+"L"+this.endX.toString()+" "+this.endY.toString():"M"+i(this.startX)+" "+i(this.startY)+"L"+i(this.endX)+" "+i(this.endY);case 2:return e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0?"M"+e.x.toString()+" "+e.y.toString()+"H"+e.right.toString()+"V"+e.bottom.toString()+"H"+e.left.toString()+"z":"M"+i(e.x)+" "+i(e.y)+"H"+i(e.right)+"V"+i(e.bottom)+"H"+i(e.left)+"z";case 3:if(e=new Rect(this.startX,this.startY,0,0),e.union(this.endX,this.endY,0,0),t<0){const r=e.left.toString()+" "+(e.y+e.height/2).toString(),l=e.right.toString()+" "+(e.y+e.height/2).toString();return"M"+r+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+l+"A"+(e.width/2).toString()+" "+(e.height/2).toString()+" 0 0 1 "+r}else{const r=i(e.left)+" "+i(e.y+e.height/2),l=i(e.right)+" "+i(e.y+e.height/2);return"M"+r+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+l+"A"+i(e.width/2)+" "+i(e.height/2)+" 0 0 1 "+r}case 4:let s="";const n=this.figures.r,o=n.length;for(let r=0;r0&&(s+=" x "),l.isFilled&&(s+="F "),s+=l.toString(t)}return s;default:return GeometryType[this.type]}}static fillPath(t){typeof t!="string"&&Util.we(t,"string",Geometry,"fillPath:str");const i=t.split(/[Xx]/),e=i.length;let s="";for(let n=0;n=k-1||o[r+1].match(N)!==null?!0:(u=!1,!1)}function m(){return r++,o[r]}function g(A){let D=parseFloat(m()),F=parseFloat(m());l===l.toLowerCase()&&(D=f.x+D,F=f.y+F),A.e(D,F)}function p(){return g(f),f}function y(){return g(c),c}function x(){const A=h.toLowerCase();return A==="c"||A==="s"||A==="q"||A==="t"?new Point(2*f.x-c.x,2*f.y-c.y):new Point(f.x,f.y)}const k=o.length,b=GeoStream.mC(null);let P=!1,S=!1,L=!1,C=!0,M=null;const N=new RegExp("["+Geometry.jg+"]");for(;!(r>=k-1);){if(h=l,l=m(),l==="")continue;u=!0;let A=!1;switch(l.toUpperCase()){case"X":C=!0,P=!1,S=!1;break;case"M":for(M=p(),b.Pi===null||C===!0?(b.fu(M.x,M.y,P,!1,!S,L),C=!1):b.ID(M.x,M.y),a.a(f);!d();)M=p(),b.ur(M.x,M.y);break;case"L":for(;!d();)M=p(),b.ur(M.x,M.y);u&&(A=!0);break;case"H":for(;!d();)f.e((l===l.toLowerCase()?f.x:0)+parseFloat(m()),f.y),b.ur(f.x,f.y);break;case"V":for(;!d();)f.e(f.x,(l===l.toLowerCase()?f.y:0)+parseFloat(m())),b.ur(f.x,f.y);u&&(A=!0);break;case"C":for(;!d();){const D=new Point;g(D);const F=y(),R=p();b.dr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(A=!0);break;case"S":for(;!d();){const D=x(),F=y(),R=p();b.dr(D.x,D.y,F.x,F.y,R.x,R.y)}u&&(A=!0);break;case"Q":for(;!d();){const D=y(),F=p();b.Mw(D.x,D.y,F.x,F.y)}u&&(A=!0);break;case"T":for(;!d();){const D=x();c.a(D);const F=p();b.Mw(D.x,D.y,F.x,F.y),c.a(F)}u&&(A=!0);break;case"B":for(;!d();){const D=parseFloat(m()),F=parseFloat(m());let R=parseFloat(m()),v=parseFloat(m());const O=parseFloat(m());let B=O,X=!1;d()||(B=parseFloat(m()),d()||(X=parseFloat(m())!==0)),l===l.toLowerCase()&&(R+=f.x,v+=f.y),b.ED(D,F,R,v,O,B,X)}u&&(A=!0);break;case"A":for(;!d();){const D=Math.abs(parseFloat(m())),F=Math.abs(parseFloat(m())),R=parseFloat(m());let v=!1,O=!1,B=0,X=0;const E=m();E.length===1?(v=!!parseFloat(E),O=!!parseFloat(m()),B=parseFloat(m()),X=parseFloat(m())):E.length===2?(v=!!parseFloat(E[0]),O=!!parseFloat(E[1]),B=parseFloat(m()),X=parseFloat(m())):(v=!!parseFloat(E[0]),O=!!parseFloat(E[1]),B=parseFloat(E.slice(2)),X=parseFloat(m())),l===l.toLowerCase()&&(B=f.x+B,X=f.y+X),f.e(B,X),b.BD(D,F,R,v,O,B,X)}u&&(A=!0);break;case"Z":b.UD(),f.a(a);break;case"F":{let D="",F=1;for(;o[r+F];){if(o[r+F]==="0"){L=!0,F++;continue}if(o[r+F].match(/[Uu]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?P=!0:b.VD();break}case"U":{let D="",F=1;for(;o[r+F];){if(o[r+F].match(/[Ff]/)!==null){F++;continue}if(o[r+F].match(N)===null){F++;continue}D=o[r+F];break}D.match(/[Mm]/)?S=!0:b.zD(!1);break}default:if(l==="0"||l==="1")break;Util.ii("Unknown geometry command: "+l);break}if(A){Util.ii(`Bad geometry command: ${l}, next token: ${m()}, +string: ${t}`);break}}const T=b.Hg;if(GeoStream.pC(b),i){const A=T.figures.iterator;for(;A.next();){const D=A.value;D.isFilled=!0}}return T}static yC(t,i){const e=t.length,s=Point.l();for(let n=0;n=t)return 0;if((n>r?n-r:r-n)<(o>l?o-l:l-o)){if(ol)return 0}else if(co)return 0}else if(nr)return 0}else if(an)return 0;return h>0?1:-1}xC(t,i,e){const s=this.figures.r,n=s.length;for(let o=0;o1&&(t=1),i===void 0&&(i=new Point),this.type===1)return i.e(this.startX+t*(this.endX-this.startX),this.startY+t*(this.endY-this.startY)),i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[f*2],y=g[f*2+1],x=g[f*2+2],k=g[f*2+3];return i.e(p+(x-p)*m,y+(k-y)*m),i}l+=u}}return i}getAngleAlongPath(t){if(t<0?t=0:t>1&&(t=1),this.type===1)return Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI;const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=i.length,o=s*t;let r=0;for(let l=0;l=o){const u=i[l],d=u[c*2],m=u[c*2+1],g=u[c*2+2],p=u[c*2+3];return Math.abs(g-d)<1&&Math.abs(p-m)<1?0:Math.abs(g-d)<1?p-m>=0?90:270:Math.abs(p-m)<1?g-d>=0?0:180:Math.atan2(p-m,g-d)*180/Math.PI}r+=f}}return NaN}getPointAndAngleAlongPath(t,i){if(t<0?t=0:t>1&&(t=1),i===void 0&&(i=[]),i.length=3,this.type===1)return i[0]=this.startX+t*(this.endX-this.startX),i[1]=this.startY+t*(this.endY-this.startY),i[2]=Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI,i;const e=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=e.length,r=n*t;let l=0;for(let h=0;h=r){const d=r-l,m=u===0?0:d/u,g=e[h],p=g[f*2],y=g[f*2+1],x=g[f*2+2],k=g[f*2+3];i[0]=p+(x-p)*m,i[1]=y+(k-y)*m;let b;return Math.abs(x-p)<1&&Math.abs(k-y)<1?b=0:Math.abs(x-p)<1?b=k-y>=0?90:270:Math.abs(k-y)<1?b=x-p>=0?0:180:b=Math.atan2(k-y,x-p)*180/Math.PI,i[2]=b,i}l+=u}}return i}getFractionForPoint(t){if(this.type===1){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=t.x,r=t.y;let l=0,h=0;if(i===s)return e=h?h===e?0:1:Math.abs(r-e)/(h-l);if(e===n)return i=h?h===i?0:1:Math.abs(o-i)/(h-l);{const a=(s-i)*(s-i)+(n-e)*(n-e),c=Point.l();Geo.ml(i,e,s,n,o,r,c);const f=c.x,u=c.y;return Point.s(c),Math.sqrt(((f-i)*(f-i)+(u-e)*(u-e))/a)}}}else if(this.type===2){const i=this.startX,e=this.startY,s=this.endX,n=this.endY;if(i===s&&e===n)return 0;{const o=s-i,r=n-e,l=o*2+r*2;let h=t.x,a=t.y;h=Math.min(Math.max(h,i),s),a=Math.min(Math.max(a,e),n);const c=Math.abs(h-i),f=Math.abs(h-s),u=Math.abs(a-e),d=Math.abs(a-n),m=Math.min(c,f,u,d);if(m===u)return h/l;if(m===f)return(o+a)/l;if(m===d)return(o*2+r-h)/l;if(m===c)return(o*2+r*2-a)/l}}else{const i=this.flattenedSegments,e=this.flattenedLengths,s=this.flattenedTotalLength,n=Point.l();let o=1/0,r=0,l=0;const h=i.length;let a=0,c=0;for(let u=0;u1?1:f}return 0}get flattenedSegments(){return this.bC(),this.ec}bC(){if(this.ec===null){const t=this.ec=[],i=this.au=[];this.YD(t,i)}}get flattenedLengths(){return this.bC(),this.au}get flattenedTotalLength(){let t=this.cu;if(isNaN(t)){if(this.type===1){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=Math.sqrt(i*i+e*e)}else if(this.type===2){const i=Math.abs(this.endX-this.startX),e=Math.abs(this.endY-this.startY);t=i*2+e*2}else{const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=4&&(t.push(e),i.push(this.Xk(e))),e=[],e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY,h=r,a=l;break;case 2:e.push(d.endX),e.push(d.endY),r=d.endX,l=d.endY;break;case 3:Geo.Un(r,l,d.point1X,d.point1Y,d.point2X,d.point2Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 4:Geo.Bg(r,l,d.point1X,d.point1Y,d.endX,d.endY,.5,e),r=d.endX,l=d.endY;break;case 5:{const m=d.Mo(o),g=m.length;if(g===0){e.push(d.centerX),e.push(d.centerY),r=d.centerX,l=d.centerY;break}for(let p=0;p=4&&(t.push(e),i.push(this.Xk(e)))}}}get type(){return this.$}set type(t){this.$!==t&&(this.h&&Util.T(this,t),this.$=t,t===4?this.Fs=new List:(Geometry.Sw===null&&(Geometry.Sw=new List().g()),this.Fs=Geometry.Sw),this.bt=!0)}get startX(){return this.xe}set startX(t){this.xe!==t&&(this.h&&Util.T(this,t),this.xe=t,this.bt=!0)}get startY(){return this.be}set startY(t){this.be!==t&&(this.h&&Util.T(this,t),this.be=t,this.bt=!0)}get endX(){return this.Qi}set endX(t){this.Qi!==t&&(this.h&&Util.T(this,t),this.Qi=t,this.bt=!0)}get endY(){return this._i}set endY(t){this._i!==t&&(this.h&&Util.T(this,t),this._i=t,this.bt=!0)}get figures(){return this.Fs}set figures(t){this.Fs!==t&&(this.h&&Util.T(this,t),this.Fs=t,this.bt=!0)}add(t){return this.Fs.add(t),this}setSpots(t,i,e,s,n,o,r,l){return this.h&&Util.T(this),this.zn=new Spot(t,i,n,o).g(),this.Xn=new Spot(e,s,r,l).g(),this}get spot1(){return this.zn}set spot1(t){this.h&&Util.T(this,t),this.zn=t.N()}get spot2(){return this.Xn}set spot2(t){this.h&&Util.T(this,t),this.Xn=t.N()}get defaultStretch(){return this.Kn}set defaultStretch(t){this.Kn=t}get bounds(){return this.Uk()&&this.Nw(),this.Gg}}Geometry.stringify=Geometry.stringify;Geometry.stringifyFixed=Geometry.stringifyFixed;Geometry.fillPath=Geometry.fillPath;Geometry.parse=Geometry.parse;class PathFigure{n;xe;be;oc;qg;Be;constructor(t,i,e,s,n){e===void 0&&(e=!0),s===void 0&&(s=!0),n===void 0&&(n=!1),this.n=2|(e?4:0)|(s?8:0)|(n?16:0),t!==void 0?this.xe=t:this.xe=0,i!==void 0?this.be=i:this.be=0,this.oc=new List,this.qg=this.oc.ht,this.Be=null}copy(){const t=new PathFigure;t.n=this.n&-2,t.xe=this.xe,t.be=this.be;const i=this.oc.r,e=i.length,s=t.oc;for(let n=0;no===0?"0":o.toFixed(t);i="M"+n(this.startX)+" "+n(this.startY)}const e=this.segments.r,s=e.length;for(let n=0;n(w[w.Move=1]="Move",w[w.Line=2]="Line",w[w.Bezier=3]="Bezier",w[w.QuadraticBezier=4]="QuadraticBezier",w[w.Arc=5]="Arc",w[w.SvgArc=6]="SvgArc",w))(SegmentType||{});class PathSegment{$;n;Qi;_i;hn;yl;wl;gr;Rs;constructor(t,i,e,s,n,o,r,l){if(GSet.Yi(this),t===void 0&&(t=2),this.$=t,this.n=2,i!==void 0?this.Qi=i:this.Qi=0,e!==void 0?this._i=e:this._i=0,s===void 0&&(s=0),n===void 0&&(n=0),o===void 0&&(o=0),r===void 0&&(r=0),t===6){let h=o;h=h%360,h<0&&(h+=360),this.hn=h,this.yl=0,this.wl=Math.max(s,0),this.gr=Math.max(n,0),typeof r=="boolean"?r&&(this.isLargeArc=!0):typeof r=="number"&&r&&(this.isLargeArc=!0),l&&(this.isClockwiseArc=!0)}else this.hn=s,this.yl=n,t===5&&(o=Math.max(o,0)),this.wl=o,typeof r=="number"?(t===5&&(r=Math.max(r,0)),this.gr=r):this.gr=0;this.Rs=null}copy(){const t=new PathSegment;return t.$=this.$,t.n=this.n&-2,t.Qi=this.Qi,t._i=this._i,t.hn=this.hn,t.yl=this.yl,t.wl=this.wl,t.gr=this.gr,t}equalsApprox(t){if(!(t instanceof PathSegment)||this.type!==t.type||this.isClosed!==t.isClosed)return!1;switch(this.type){case 1:case 2:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY);case 3:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.point1X,t.point1X)&&Geo.u(this.point1Y,t.point1Y)&&Geo.u(this.point2X,t.point2X)&&Geo.u(this.point2Y,t.point2Y);case 4:return Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.point1X,t.point1X)&&Geo.u(this.point1Y,t.point1Y);case 5:return Geo.u(this.startAngle,t.startAngle)&&Geo.u(this.sweepAngle,t.sweepAngle)&&Geo.u(this.centerX,t.centerX)&&Geo.u(this.centerY,t.centerY)&&Geo.u(this.radiusX,t.radiusX)&&Geo.u(this.radiusY,t.radiusY);case 6:return this.isClockwiseArc===t.isClockwiseArc&&this.isLargeArc===t.isLargeArc&&Geo.u(this.xAxisRotation,t.xAxisRotation)&&Geo.u(this.endX,t.endX)&&Geo.u(this.endY,t.endY)&&Geo.u(this.radiusX,t.radiusX)&&Geo.u(this.radiusY,t.radiusY);default:return!1}}ri(t){t in SegmentType?this.type=t:Util.lr(this,t)}toString(t){t===void 0&&(t=-1);const i=s=>s===0?"0":s.toFixed(t);let e="";switch(this.type){case 1:t<0?e="M"+this.endX.toString()+" "+this.endY.toString():e="M"+i(this.endX)+" "+i(this.endY);break;case 2:t<0?e="L"+this.endX.toString()+" "+this.endY.toString():e="L"+i(this.endX)+" "+i(this.endY);break;case 3:t<0?e="C"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.point2X.toString()+" "+this.point2Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="C"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.point2X)+" "+i(this.point2Y)+" "+i(this.endX)+" "+i(this.endY);break;case 4:t<0?e="Q"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():e="Q"+i(this.point1X)+" "+i(this.point1Y)+" "+i(this.endX)+" "+i(this.endY);break;case 5:t<0?e="B"+this.startAngle.toString()+" "+this.sweepAngle.toString()+" "+this.centerX.toString()+" "+this.centerY.toString()+" "+this.radiusX.toString()+" "+this.radiusY.toString():e="B"+i(this.startAngle)+" "+i(this.sweepAngle)+" "+i(this.centerX)+" "+i(this.centerY)+" "+i(this.radiusX)+" "+i(this.radiusY);break;case 6:t<0?e="A"+this.radiusX.toString()+" "+this.radiusY.toString()+" "+this.xAxisRotation.toString()+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+this.endX.toString()+" "+this.endY.toString():e="A"+i(this.radiusX)+" "+i(this.radiusY)+" "+i(this.xAxisRotation)+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+i(this.endX)+" "+i(this.endY);break;default:e=SegmentType[this.type]}return e+(this.isClosed?"z":"")}static Move=1;static Line=2;static Bezier=3;static QuadraticBezier=4;static Arc=5;static SvgArc=6;get h(){return(this.n&1)!==0}set h(t){t?this.n|=1:this.n&=-2}get bt(){return(this.n&2)!==0}set bt(t){t?this.n|=2:this.n&=-3}g(){return this.h=!0,this}ot(){return this.h=!1,this}close(){return this.isClosed=!0,this}Mo(t){if(this.Rs!==null&&t.bt===!1)return this.Rs;const i=this.radiusX;let e=this.radiusY;if(e===void 0&&(e=i),i===0||e===0)return this.Rs=[],this.Rs;const s=this.hn,n=this.yl,o=Geo.uC(0,0,i1&&(o*=Math.sqrt(p),r*=Math.sqrt(p));let y=(h===a?-1:1)*Math.sqrt((o*o*r*r-o*o*g*g-r*r*m*m)/(o*o*g*g+r*r*m*m));isNaN(y)&&(y=0);let x=y*o*g/r,k=y*-r*m/o;isNaN(x)&&(x=0),isNaN(k)&&(k=0);const b=(s+c)/2+u*x-d*k,P=(n+f)/2+d*x+u*k,S=(V,U)=>Math.sqrt(V*V+U*U),L=(V,U,Y,G)=>(V*Y+U*G)/(S(V,U)*S(Y,G)),C=(V,U,Y,G)=>(V*G=1&&(F=0),!a&&F>0&&(F=F-2*Math.PI),a&&F<0&&(F=F+2*Math.PI);const v=o>r?o:r,O=o>r?1:o/r,B=o>r?r/o:1,X=Geo.uC(0,0,v,M,M+F,!0),E=Transform.l();return E.Ri(),E.Ds(b,P),E.cs(this.hn,0,0),E.et(O,B),Geometry.yC(X,E),Transform.s(E),this.Rs=X,this.Rs}get isClosed(){return(this.n&8)!==0}set isClosed(t){this.isClosed!==t&&(t?this.n|=8:this.n&=-9,this.bt=!0)}get type(){return this.$}set type(t){this.h&&Util.T(this,t),this.$=t,this.bt=!0}get endX(){return this.Qi}set endX(t){this.h&&Util.T(this,t),this.Qi=t,this.bt=!0}get endY(){return this._i}set endY(t){this.h&&Util.T(this,t),this._i=t,this.bt=!0}get point1X(){return this.hn}set point1X(t){this.h&&Util.T(this,t),this.hn=t,this.bt=!0}get point1Y(){return this.yl}set point1Y(t){this.h&&Util.T(this,t),this.yl=t,this.bt=!0}get point2X(){return this.wl}set point2X(t){this.h&&Util.T(this,t),this.wl=t,this.bt=!0}get point2Y(){return this.gr}set point2Y(t){this.h&&Util.T(this,t),this.gr=t,this.bt=!0}get centerX(){return this.hn}set centerX(t){this.h&&Util.T(this,t),this.hn=t,this.bt=!0}get centerY(){return this.yl}set centerY(t){this.h&&Util.T(this,t),this.yl=t,this.bt=!0}get radiusX(){return this.wl}set radiusX(t){t<0&&Util._(t,">= zero",PathSegment,"radiusX"),this.h&&Util.T(this,t),this.wl=t,this.bt=!0}get radiusY(){return this.gr}set radiusY(t){t<0&&Util._(t,">= zero",PathSegment,"radiusY"),this.h&&Util.T(this,t),this.gr=t,this.bt=!0}get startAngle(){return this.Qi}set startAngle(t){this.h&&Util.T(this,t),t=t%360,t<0&&(t+=360),this.Qi=t,this.bt=!0}get sweepAngle(){return this._i}set sweepAngle(t){this.h&&Util.T(this,t),t>360&&(t=360),t<-360&&(t=-360),this._i=t,this.bt=!0}get isClockwiseArc(){return(this.n&4)!==0}set isClockwiseArc(t){this.h&&Util.T(this,t),t?this.n|=4:this.n&=-5,this.bt=!0}get isLargeArc(){return(this.n&16)!==0}set isLargeArc(t){this.h&&Util.T(this,t),t?this.n|=16:this.n&=-17,this.bt=!0}get xAxisRotation(){return this.hn}set xAxisRotation(t){this.h&&Util.T(this,t),t=t%360,t<0&&(t+=360),this.hn=t,this.bt=!0}}class InputEvent{p;Lw;Aw;Wg;Jg;$g;Zg;Qg;_g;tm;im;em;sm;nm;No;om;rm;lm;ke;constructor(){this.p=null,this.Lw=new Point(0,0).g(),this.Aw=new Point(0,0).g(),this.Wg=0,this.Jg=0,this.$g=1,this.Zg="",this.Qg="",this._g=!1,this.tm=!1,this.im=0,this.em=0,this.sm=!1,this.nm=!1,this.No=!1,this.om=null,this.rm=0,this.lm=null,this.ke=null}copy(){const t=new InputEvent;return this.clone(t)}clone(t){return t.p=this.p,t.Lw.a(this.viewPoint),t.Aw.a(this.documentPoint),t.Wg=this.Wg,t.Jg=this.Jg,t.$g=this.$g,t.Zg=this.Zg,t.Qg=this.Qg,t._g=this._g,t.tm=this.tm,t.im=this.im,t.em=this.em,t.sm=this.sm,t.nm=this.nm,t.No=this.No,t.om=this.om,t.rm=this.rm,t.lm=this.lm,t.ke=this.ke,t}toString(){let t="^";return this.modifiers!==0&&(t+="M:"+this.modifiers),this.button!==0&&(t+="B:"+this.button),this.key!==""&&(t+="K:"+this.key),this.clickCount!==0&&(t+="C:"+this.clickCount),this.delta!==0&&(t+="D:"+this.delta),this.handled&&(t+="h"),this.bubbles&&(t+="b"),this.documentPoint!==null&&(t+="@"+this.documentPoint.toString()),t}get diagram(){return this.p}set diagram(t){this.p=t}get viewPoint(){return this.Lw}set viewPoint(t){this.Lw.a(t)}get documentPoint(){return this.Aw}set documentPoint(t){this.Aw.a(t)}getMultiTouchViewPoint(t,i){const e=this.diagram;return e===null||e.kC(this.event,t,i),i}getMultiTouchDocumentPoint(t,i){const e=this.diagram;return e===null||(e.kC(this.event,t,i),i.a(e.transformViewToDoc(i))),i}get modifiers(){return this.Wg}set modifiers(t){this.Wg=t}get button(){return this.Jg}set button(t){if(this.Jg=t,this.event===null)switch(t){case 0:this.buttons=1;return;case 1:this.buttons=4;return;case 2:this.buttons=2;return}}get buttons(){return this.$g}set buttons(t){this.$g=t}get key(){return this.Zg}set key(t){this.Zg=t}get code(){return this.Qg}set code(t){this.Qg=t}get down(){return this._g}set down(t){this._g=t}get up(){return this.tm}set up(t){this.tm=t}get clickCount(){return this.im}set clickCount(t){this.im=t}get delta(){return this.em}set delta(t){this.em=t}get isMultiTouch(){return this.sm}set isMultiTouch(t){this.sm=t}get handled(){return this.nm}set handled(t){this.nm=t}get bubbles(){return this.No}set bubbles(t){this.No=t}get event(){return this.om}set event(t){this.om=t}get isTouchEvent(){const t=this.event;return t===null?!1:t.pointerType==="touch"||t.pointerType==="pen"}get timestamp(){return this.rm}set timestamp(t){this.rm=t}get targetDiagram(){return this.lm}set targetDiagram(t){this.lm=t}get targetObject(){return this.ke}set targetObject(t){this.ke=t}get control(){return(this.modifiers&1)!==0}set control(t){this.modifiers=t?this.modifiers|1:this.modifiers&-2}get shift(){return(this.modifiers&4)!==0}set shift(t){this.modifiers=t?this.modifiers|4:this.modifiers&-5}get alt(){return(this.modifiers&2)!==0}set alt(t){this.modifiers=t?this.modifiers|2:this.modifiers&-3}get meta(){return(this.modifiers&8)!==0}set meta(t){this.modifiers=t?this.modifiers|8:this.modifiers&-9}get left(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===0:(this.buttons&1)!==0}set left(t){t?this.buttons|=1:this.buttons&=-2}get right(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===2:(this.buttons&2)!==0}set right(t){t?this.buttons|=2:this.buttons&=-3}get middle(){const t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===1:(this.buttons&4)!==0}set middle(t){t?this.buttons|=4:this.buttons&=-5}get commandKey(){const t=this.code,i=this.key;return"cxvyzagCXVYZAG".includes(i)?i.toLowerCase():t==="KeyC"?"c":t==="KeyX"?"x":t==="KeyV"?"v":t==="KeyY"?"y":t==="KeyZ"?"z":t==="KeyA"?"a":t==="KeyG"?"g":t!==""?t:i}}class DiagramEvent{p;Mt;hm;am;constructor(){this.p=null,this.Mt="",this.hm=null,this.am=null}copy(){const t=new DiagramEvent;return t.p=this.p,t.Mt=this.Mt,t.hm=this.hm,t.am=this.am,t}toString(){let t="*"+this.name;return this.subject!==null&&(t+=":"+this.subject.toString()),this.parameter!==null&&(t+="("+this.parameter.toString()+")"),t}get diagram(){return this.p}set diagram(t){this.p=t}get name(){return this.Mt}set name(t){this.Mt=t}get subject(){return this.hm}set subject(t){this.hm=t}get parameter(){return this.am}set parameter(t){this.am=t}}var ChangeType=(w=>(w[w.Transaction=1]="Transaction",w[w.Property=2]="Property",w[w.Insert=3]="Insert",w[w.Remove=4]="Remove",w))(ChangeType||{});class ChangedEvent{uu;cm;an;Si;p;du;rc;lc;hc;ac;constructor(){this.uu=2,this.cm="",this.an="",this.Si=null,this.p=null,this.du=null,this.rc=null,this.lc=null,this.hc=null,this.ac=null}static Transaction=1;static Property=2;static Insert=3;static Remove=4;clear(){this.Si=null,this.p=null,this.du=null,this.rc=null,this.lc=null,this.hc=null,this.ac=null}copy(){const t=new ChangedEvent;t.uu=this.uu,t.cm=this.cm,t.an=this.an,t.Si=this.Si,t.p=this.p,t.du=this.du;let i=this.rc;return Util.wt(i)&&typeof i.copyFrozen=="function"?t.rc=i.copyFrozen():t.rc=i,i=this.lc,Util.wt(i)&&typeof i.copyFrozen=="function"?t.lc=i.copyFrozen():t.lc=i,i=this.hc,Util.wt(i)&&typeof i.copyFrozen=="function"?t.hc=i.copyFrozen():t.hc=i,i=this.ac,Util.wt(i)&&typeof i.copyFrozen=="function"?t.ac=i.copyFrozen():t.ac=i,t}ri(t){t in ChangeType?this.change=t:Util.lr(this,t)}toString(){let t="";return this.change===1?t+="* ":this.change===2?t+=this.model!==null?"!m":"!d":t+=(this.model!==null?"!m":"!d")+this.change,this.propertyName&&typeof this.propertyName=="string"&&(t+=" "+this.propertyName),this.modelChange&&this.modelChange!==this.propertyName&&(t+=" "+this.modelChange),t+=": ",this.change===1?this.oldValue!==null&&(t+=" "+this.oldValue):(this.object!==null&&(t+=Util.toString(this.object)),this.oldValue!==null&&(t+=" old: "+Util.toString(this.oldValue)),this.oldParam!==null&&(t+=" "+this.oldParam),this.newValue!==null&&(t+=" new: "+Util.toString(this.newValue)),this.newParam!==null&&(t+=" "+this.newParam)),t}getValue(t){return t?this.oldValue:this.newValue}getParam(t){return t?this.oldParam:this.newParam}canUndo(){return this.model!==null||this.diagram!==null}undo(){this.canUndo()&&(this.model!==null?this.model.changeState(this,!0):this.diagram!==null&&this.diagram.PC(this,!0))}canRedo(){return this.model!==null||this.diagram!==null}redo(){this.canRedo()&&(this.model!==null?this.model.changeState(this,!1):this.diagram!==null&&this.diagram.PC(this,!1))}get model(){return this.Si}set model(t){this.Si=t}get diagram(){return this.p}set diagram(t){this.p=t}get change(){return this.uu}set change(t){this.uu=t}get modelChange(){return this.cm}set modelChange(t){this.cm=t}get propertyName(){return this.an}set propertyName(t){this.an=t}get isTransactionFinished(){return this.uu===1&&(this.an==="CommittedTransaction"||this.an==="FinishedUndo"||this.an==="FinishedRedo")}get object(){return this.du}set object(t){this.du=t}get oldValue(){return this.rc}set oldValue(t){this.rc=t}get oldParam(){return this.lc}set oldParam(t){this.lc=t}get newValue(){return this.hc}set newValue(t){this.hc=t}get newParam(){return this.ac}set newParam(t){this.ac=t}}class Transaction{SC;Mt;Kk;constructor(){this.SC=new List().g(),this.Mt="",this.Kk=!1}toString(t){let i="Transaction: "+this.name+" "+this.changes.count.toString()+(this.isComplete?"":", incomplete");if(t!==void 0&&t>0){const e=this.changes.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),t.g()}canUndo(){return this.isComplete}undo(){if(this.canUndo())for(let t=this.changes.count-1;t>=0;t--){const i=this.changes.elt(t);i!==null&&i.undo()}}canRedo(){return this.isComplete}redo(){if(!this.canRedo())return;const t=this.changes.count;for(let i=0;i=t;e--){const s=i.elt(e);s!==null&&s.undo(),i.ot(),i.removeAt(e)}i.g()}optimize(){if(!this.isComplete)return;const t=this.changes;t.ot();const i=new GMap;for(let s=0;s0&&t.setElt(r,null),o.set(n.propertyName,s))}let e=0;for(let s=0;se&&t.setElt(e,n),e++)}for(;t.length>e;)t.pop();t.g()}get changes(){return this.SC}get name(){return this.Mt}set name(t){this.Mt=t}get isComplete(){return this.Kk}set isComplete(t){this.Kk=t}}class UndoManager{Tw;Oi;MC;vs;Yk;fm;Yn;Gk;jk;cn;cc;Dw;Os;Fw;Rw;um;vw;constructor(t){this.Tw=new GSet,this.Oi=!1,this.MC=new List().g(),this.vs=-1,this.Yk=999,this.Os=!1,this.fm=null,this.Yn=0,this.Gk=!1,this.jk=23,this.cn=new List().g(),this.cc=new List,this.Dw=!0,this.Fw=!1,this.Rw=!1,this.um=!1,this.vw=!1,t&&Object.assign(this,t)}toString(t){let i="UndoManager "+this.historyIndex+"<"+this.history.count+"<="+this.maxHistoryLength;i+="[";let e=this.nestedTransactionNames.count;for(let s=0;s0&&(i+=" "),i+=this.nestedTransactionNames.elt(s);if(i+="]",t!==void 0&&t>0){e=this.history.count;for(let s=0;s=0;i--){const e=t.elt(i);e!==null&&e.clear()}t.clear(),this.vs=-1,t.g(),this.Os=!1,this.fm=null,this.Yn=0,this.cn.ot(),this.cn.clear(),this.cn.g(),this.cc.clear(),this.Fw=!1,this.Rw=!1,this.um=!1,this.vw=!1}copyProperties(t){this.isEnabled=t.isEnabled,this.maxHistoryLength=t.maxHistoryLength,this.dm=t.dm}addModel(t){this.Tw.add(t)}removeModel(t){this.Tw.delete(t)}startTransaction(t){if(t===void 0&&(t=""),t===null&&(t=""),this.isUndoingRedoing)return!1;this.Dw===!0&&(this.Dw=!1,this.Yn++,this.xl||this.t("StartingFirstTransaction",t,this.currentTransaction),this.Yn>0&&this.Yn--),this.isEnabled&&(this.cn.ot(),this.cn.add(t),this.cn.g(),this.currentTransaction===null?this.cc.add(0):this.cc.add(this.currentTransaction.changes.count)),this.Yn++;const i=this.transactionLevel===1;return i&&(this.xl||this.t("StartedTransaction",t,this.currentTransaction)),i}commitTransaction(t){return t===void 0&&(t=""),this.NC(!0,t)}rollbackTransaction(){return this.NC(!1,"")}NC(t,i){if(this.isUndoingRedoing)return!1;this.dm&&this.transactionLevel<1&&Util.ii("Ending transaction without having started a transaction: "+i);const e=this.transactionLevel===1;let s=this.currentTransaction;e&&t&&(this.xl||this.t("CommittingTransaction",i,s));let n=0;if(this.transactionLevel>0&&(this.Yn--,this.isEnabled)){const o=this.cn.count;o>0&&(i===""&&(i=this.cn.elt(0)),this.cn.ot(),this.cn.removeAt(o-1),this.cn.g());const r=this.cc.count;r>0&&(n=this.cc.elt(r-1),this.cc.removeAt(r-1))}if(e){if(t){if(this.um=!1,s===null&&i!==""&&(s=this.currentTransaction),this.isEnabled&&s!==null){const o=s;o.isComplete||(o.isComplete=!0,o.name=i),this.discardHistoryAfterIndex();const r=this.history;r.ot();const l=this.maxHistoryLength;if(l>=0){if(l===0)r.clear();else if(r.count>=l){const h=r.elt(0);h!==null&&h.clear(),r.removeAt(0),this.vs--}}l!==0&&(r.count===0||r.get(r.count-1)!==o)&&(r.add(o),this.vs++),r.g(),s=o}this.xl||this.t("CommittedTransaction",i,s)}else{this.Os=!0;try{this.isEnabled&&s!==null&&(s.isComplete=!0,s.undo())}finally{this.xl||this.t("RolledBackTransaction",i,s),this.Os=!1}s!==null&&s.clear()}return this.fm=null,this.Ow&&this.clear(),this.Ow=!1,this.Iw=!1,!0}else return this.isEnabled&&!t&&s!==null&&s.GD(n),!1}discardHistoryAfterIndex(){if(this.isUndoingRedoing||!this.canRedo())return;const t=this.history;t.ot();for(let i=t.count-1;i>this.historyIndex;i--){const e=t.elt(i);e!==null&&e.clear(),t.removeAt(i),this.um=!0}t.g()}nE(t){this.Yn+=t,this.Yn<0&&(this.Yn=0)}canUndo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToUndo;return!!(t!==null&&t.canUndo())}undo(){if(!this.canUndo())return;const t=this.transactionToUndo;try{this.Os=!0,this.t("StartingUndo","Undo",t),this.vs--,t.undo()}catch(i){Util.ii("undo error: "+i.toString())}finally{this.t("FinishedUndo","Undo",t),this.Os=!1}}canRedo(){if(!this.isEnabled||this.transactionLevel>0)return!1;const t=this.transactionToRedo;return!!(t!==null&&t.canRedo())}redo(){if(!this.canRedo())return;const t=this.transactionToRedo;try{this.Os=!0,this.t("StartingRedo","Redo",t),this.vs++,t.redo()}catch(i){Util.ii("redo error: "+i.toString())}finally{this.t("FinishedRedo","Redo",t),this.Os=!1}}t(t,i,e){e===void 0&&(e=null);const s=new ChangedEvent;s.change=1,s.propertyName=t,s.object=e,s.oldValue=i;const n=this.models;for(;n.next();){const o=n.value;s.model=o,o.Ew(s)}}handleChanged(t){if(this.isEnabled&&!this.isUndoingRedoing&&!this.skipsEvent(t)){let i=this.currentTransaction;i===null&&(i=new Transaction,this.fm=i);const e=t.copy(),s=i.changes;if(s.ot(),s.add(e),s.g(),this.dm&&this.jk>0&&this.transactionLevel<=0&&!this.Dw){const n=t.diagram;if(n!==null&&n.Bh===!1)return;Util.ii("Change not within a transaction: "+e.toString()),this.jk--}}}skipsEvent(t){if(t===null||t.change===1)return!0;const i=t.object;if(i===null)return!1;if(i.layer!==void 0){const e=i.layer;if(e!==null&&e.isTemporary)return!0}else if(i.isTemporary)return!0;return!1}get models(){return this.Tw.iterator}get isEnabled(){return this.Oi}set isEnabled(t){this.Oi=t}get transactionToUndo(){return this.historyIndex>=0&&this.historyIndex<=this.history.count-1?this.history.elt(this.historyIndex):null}get transactionToRedo(){return this.historyIndex0}get dm(){return this.Gk}set dm(t){this.Gk=t}get nestedTransactionNames(){return this.cn}get Ow(){return this.Fw}set Ow(t){this.Fw=t}get Iw(){return this.Rw}set Iw(t){this.Rw=t}get xl(){return this.vw}set xl(t){this.vw=t}get isJustDiscarded(){return this.um}}class Tool{p;Mt;Oi;Hk;qk;gm;CC;constructor(){GSet.Yi(this),this.p=Diagram.mm(),this.Mt="",this.Oi=!0,this.Hk=!1,this.qk=null,this.CC=new InputEvent,this.gm=-1}get diagram(){return this.p}set diagram(t){t instanceof Diagram&&(this.p=t)}toString(){return this.name!==""?this.name+" Tool":Util.sn(this.constructor)}updateAdornments(t){}canStart(){return this.isEnabled}doStart(){}doActivate(){this.isActive=!0}doDeactivate(){this.isActive=!1}doStop(){}doCancel(){this.transactionResult=null,this.stopTool()}stopTool(){const t=this.diagram;t.currentTool===this&&(t.currentTool=null,t.currentCursor="")}doMouseDown(){!this.isActive&&this.canStart()&&this.doActivate()}doMouseMove(){}doMouseUp(){this.stopTool()}doMouseWheel(){}canStartMultiTouch(){return!0}standardPinchZoomStart(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.X(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.X(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.s(e),Point.s(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){t.Wk=t.scale;const n=s.x-e.x,o=s.y-e.y,r=Math.sqrt(n*n+o*o);t.Jk=r,i.bubbles=!1}Point.s(e),Point.s(s)}standardPinchZoomMove(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.X(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.X(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.s(e),Point.s(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){const n=s.x-e.x,o=s.y-e.y,l=Math.sqrt(n*n+o*o)/t.Jk,h=new Point((Math.min(s.x,e.x)+Math.max(s.x,e.x))/2,(Math.min(s.y,e.y)+Math.max(s.y,e.y))/2),a=t.Wk*l,c=t.commandHandler;if(a!==t.scale&&c.canResetZoom(a)){const f=t.zoomPoint;t.zoomPoint=h,c.resetZoom(a),t.zoomPoint=f}i.bubbles=!1}Point.s(e),Point.s(s)}doKeyDown(){this.diagram.lastInput.code==="Escape"&&this.doCancel()}doKeyUp(){}startTransaction(t){return t===void 0&&(t=this.name),this.transactionResult=null,this.diagram.startTransaction(t)}stopTransaction(){const t=this.diagram;return this.transactionResult===null?t.rollbackTransaction():t.commitTransaction(this.transactionResult)}standardMouseSelect(){const t=this.diagram;if(!t.allowSelect)return;const i=t.lastInput,e=t.findPartAt(i.documentPoint,!1);if(e!==null){if(Util.rr?i.meta:i.control){t.v("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!s.isSelected),t.v("ChangedSelection",t.selection)}else if(i.shift){if(!e.isSelected){t.v("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!0),t.v("ChangedSelection",t.selection)}}else if(!e.isSelected){let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&t.select(s)}}else i.left&&!(Util.rr?i.meta:i.control)&&!i.shift&&t.clearSelection()}standardMouseClick(t,i){t===void 0&&(t=null),i===void 0&&(i=o=>!o.layer.isTemporary);const e=this.diagram,s=e.lastInput,n=e.findObjectAt(s.documentPoint,t,i);return s.targetObject=n,this.jD(n,s,e),s.handled}jD(t,i,e){if(i.handled=!1,t!==null&&!t.isEnabledObject())return;let s=0;i.left?i.clickCount===1?s=1:i.clickCount===2?s=2:s=1:i.right&&i.clickCount===1&&(s=3);let n="ObjectSingleClicked";if(t!==null){switch(s){case 1:n="ObjectSingleClicked";break;case 2:n="ObjectDoubleClicked";break;case 3:n="ObjectContextClicked";break}s!==0&&e.v(n,t)}else{switch(s){case 1:n="BackgroundSingleClicked";break;case 2:n="BackgroundDoubleClicked";break;case 3:n="BackgroundContextClicked";break}s!==0&&e.v(n)}if(t!==null)for(;t!==null;){let o=null;switch(s){case 1:o=t.click;break;case 2:o=t.doubleClick?t.doubleClick:t.click;break;case 3:o=t.contextClick;break}if(o!==null&&(o(i,t),i.handled))break;t=t.panel}else{let o=null;switch(s){case 1:o=e.click;break;case 2:o=e.doubleClick?e.doubleClick:e.click;break;case 3:o=e.contextClick;break}o!==null&&o(i)}}standardMouseOver(){const t=this.diagram,i=t.lastInput;if(t.animationManager.wi===!0)return;const e=t.skipsUndoManager;t.skipsUndoManager=!0;let s=t.viewportBounds.containsPoint(i.documentPoint)?t.findObjectAt(i.documentPoint,null,null):null;i.event&&(i.event.type==="pointercancel"||i.event.type==="pointerout")&&(s=null),i.targetObject=s;let n=!1;if(s!==t.fc){let o=t.fc;const r=o;for(t.fc=s,this.doCurrentObjectChanged(o,s),i.handled=!1;o!==null;){const l=o.mouseLeave;if(l!==null&&(s===o||s!==null&&s.isContainedBy(o)||(l(i,o,s),n=!0,i.handled)))break;o=o.panel}for(o=r,i.handled=!1;s!==null;){const l=s.mouseEnter;if(l!==null&&(o===s||o!==null&&o.isContainedBy(s)||(l(i,s,o),n=!0,i.handled)))break;s=s.panel}s=t.fc}if(s!==null){let o=s,r="";for(;o!==null&&(r=o.cursor,r==="");)o=o.panel;for(t.currentCursor=r,i.handled=!1,o=s;o!==null;){const l=o.mouseOver;if(l!==null&&(l(i,o),n=!0,i.handled))break;o=o.panel}}else{this.doUpdateCursor(null);const o=t.mouseOver;o!==null&&(o(i),n=!0)}n&&t.requestUpdate(),t.skipsUndoManager=e}doUpdateCursor(t){const i=this.diagram;i&&(i.currentCursor="")}doCurrentObjectChanged(t,i){}standardMouseWheel(){const t=this.diagram,i=t.lastInput;let e=i.delta;if(e===0||!t.documentBounds.isReal())return;const s=t.commandHandler,n=t.toolManager.mouseWheelBehavior;if(s!==null&&(n===2&&!i.shift||n===1&&i.control)){if(e>0?s.canIncreaseZoom():s.canDecreaseZoom()){const o=t.zoomPoint;t.zoomPoint=i.viewPoint,e>0?s.increaseZoom():s.decreaseZoom(),t.zoomPoint=o}i.bubbles=!1}else if(n===2&&i.shift||n===1&&!i.control){const o=t.position.copy(),r=i.event,l=r.deltaMode;let h=r.deltaX,a=r.deltaY,c="pixel";if((h!==0||a!==0)&&!i.shift){switch(l){case 0:c="pixel";break;case 1:c="line";break;case 2:c="page";break}if(h!==0&&t.allowHorizontalScroll){const f=t.scrollHorizontalLineChange;h=h*(f/16),t.scroll(c,h>0?"right":"left",Math.abs(h))}if(a!==0&&t.allowVerticalScroll){const f=t.scrollVerticalLineChange;a=a*(f/16),t.scroll(c,a>0?"down":"up",Math.abs(a))}}else!i.shift&&t.allowVerticalScroll?(e=e*3*t.scrollVerticalLineChange,t.scroll(c,e>0?"up":"down",Math.abs(e))):i.shift&&t.allowHorizontalScroll&&(e=e*3*t.scrollHorizontalLineChange,t.scroll(c,e>0?"left":"right",Math.abs(e)));this.doWheelChange(t,o,i)}}doWheelChange(t,i,e){(!t.position.equals(i)||e.event.wheelDeltaX!==0)&&(e.bubbles=!1)}standardWaitAfter(t,i){i===void 0&&(i=this.diagram.lastInput),this.cancelWaitAfter();const e=this,s=i.clone(this.CC);this.gm=Util.Oh(()=>e.doWaitAfter(s),t)}cancelWaitAfter(){this.gm!==-1&&Util.Og(this.gm),this.gm=-1}doWaitAfter(t){}findToolHandleAt(t,i){const s=this.diagram.findObjectAt(t,n=>{for(;n!==null&&!(n.panel instanceof Adornment);)n=n.panel;return n});return s===null?null:s.part.category===i?s:null}isBeyondDragSize(t,i){const e=this.diagram;t===void 0&&(t=e.firstInput.viewPoint),i===void 0&&(i=e.lastInput.viewPoint);const s=e.toolManager.dragSize;let n=s.width,o=s.height;return e.firstInput.isTouchEvent&&(n+=6,o+=6),Math.abs(i.x-t.x)>n||Math.abs(i.y-t.y)>o}get name(){return this.Mt}set name(t){Util.i(t,"string",Tool,"name"),this.Mt=t}get isEnabled(){return this.Oi}set isEnabled(t){Util.i(t,"boolean",Tool,"isEnabled"),this.Oi=t}get isActive(){return this.Hk}set isActive(t){Util.i(t,"boolean",Tool,"isActive"),this.Hk=t}get transactionResult(){return this.qk}set transactionResult(t){t!==null&&Util.i(t,"string",Tool,"transactionResult"),this.qk=t}}var WheelMode=(w=>(w[w.Scroll=1]="Scroll",w[w.Zoom=2]="Zoom",w[w.None=3]="None",w))(WheelMode||{}),GestureMode=(w=>(w[w.Zoom=1]="Zoom",w[w.Cancel=2]="Cancel",w[w.None=3]="None",w))(GestureMode||{});class ToolManager extends Tool{LC;AC;TC;$k;Zk;Qk;_k;tP;iP;eP;pm;Uh;constructor(t){super(),this.name="ToolManager",this.LC=new List,this.AC=new List,this.TC=new List,this.$k=850,this.Zk=850,this.Qk=new Size(2,2).it(),this._k=5e3,this.tP=1,this.iP=1,this.eP=null,this.pm=null,this.Uh=-1,t&&Object.assign(this,t)}static WheelScroll=1;static WheelZoom=2;static WheelNone=3;static GestureZoom=1;static GestureCancel=2;static GestureNone=3;get mouseWheelBehavior(){return this.tP}set mouseWheelBehavior(t){this.tP=t}get gestureBehavior(){return this.iP}set gestureBehavior(t){this.iP=t}initializeStandardTools(){}updateAdornments(t){const i=this.currentToolTip;if(i instanceof Adornment&&this.pm===t){const e=i.adornedObject;(t!==null?e.part===t:e===null)?this.showToolTip(i,e):this.hideToolTip()}}doMouseDown(){const t=this.diagram,i=t.lastInput;if(i.isTouchEvent&&this.gestureBehavior===2&&(i.bubbles=!1),i.isMultiTouch){if(this.cancelWaitAfter(),this.gestureBehavior===3){i.bubbles=!0;return}if(this.gestureBehavior===2)return;if(t.currentTool.canStartMultiTouch()){t.currentTool.standardPinchZoomStart();return}}const e=t.undoManager,s=this.mouseDownTools.length;for(let n=0;n0&&s!==1/0){const n=this;this.Uh=Util.Oh(()=>n.hideToolTip(),s)}}positionToolTip(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom?n.y-=o.height+5/s.scale:n.y+=20/s.scale,n.y30&&t.Uw(),t.Vw(this.draggedParts),t.pu=!0,this.startTransaction("Drag"),this.startPoint=t.firstInput.documentPoint,t.isMouseCaptured=!0,t.allowDragOut&&this.qD()}mP(t){if(this.dragsLink){const i=this.diagram;if(!i.allowRelink)return;i.model.gc()&&t.count===1&&t.first()instanceof Link?(this.draggedLink=t.first(),this.draggedLink.canRelinkFrom()&&this.draggedLink.canRelinkTo()&&this.draggedLink.clearAdornments(),this.fn=i.toolManager.findTool("Relinking"),this.fn===null&&(this.fn=new RelinkingTool,this.fn.diagram=i),this.fn.originalLink=this.draggedLink):(this.draggedLink=null,this.fn=null)}}computeEffectiveCollection(t,i){return this.diagram.commandHandler.computeEffectiveCollection(t,i)}Is(t){return t===void 0?new DraggingInfo(Point.Po):this.isGridSnapEnabled?new DraggingInfo(new Point(Math.round(t.x*1e3)/1e3,Math.round(t.y*1e3)/1e3)):new DraggingInfo(t.copy())}doDeactivate(){this.isActive=!1;const t=this.diagram;this.diagram.layout.isRealtime=this.gP,t.pu=!1,t.bl=!0,t.cacheGroupExternalLinks(!1),t.stopAutoScroll(),this.pP(),t.wm(this.draggedParts),this.mu=null,this.currentPart=null,this.draggedParts=null,this.isDragOutStarted=!1,this.gu=!1,DraggingTool.WD(),this.FC(),this.uc.e(NaN,NaN),DraggingTool.zh!==null&&(DraggingTool.zh.currentCursor=""),DraggingTool.zh=null,DraggingTool.yt=null,this.kl(),t.isMouseCaptured=!1,t.currentCursor="",t.dc=!1,this.stopTransaction(),t.yP(!0)}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}pP(){const t=this.diagram,i=t.skipsUndoManager;t.skipsUndoManager=!0;const e=t.lastInput;this.RC(e,null),t.skipsUndoManager=i,this.mr.length=0}vC(){this.kl(),this.wP();const t=this.diagram;this.uc.isReal()&&(t.position=this.uc),t.stopAutoScroll()}doCancel(){this.kl(),this.wP();const t=this.diagram;this.uc.isReal()&&(t.position=this.uc),this.stopTool()}doKeyDown(){const t=this.diagram,i=t.lastInput;this.isActive&&(i.code==="Escape"?this.doCancel():i.code!==t.previousInput.code&&this.doMouseMove())}doKeyUp(){this.isActive&&this.doMouseMove()}JD(t,i){let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=t.iterator;for(;r.next();){const l=r.value;if(!l.isVisible())continue;const h=l.location,a=h.x,c=h.y;isNaN(a)||isNaN(c)||(an&&(n=a),c>o&&(o=c))}return e===1/0?i.e(0,0,0,0):i.e(e,s,n-e,o-s),i}xP(t){if(this.copiedParts!==null)return;const i=this.diagram;if(t&&(i.isReadOnly||i.isModelReadOnly)||this.draggedParts===null)return;const e=i.undoManager;e.isEnabled&&e.isInTransaction?e.currentTransaction!==null&&e.currentTransaction.changes.count>0&&(i.undoManager.rollbackTransaction(),i.startTransaction("Drag")):this.wP(),i.skipsUndoManager=!t,i.partManager.addsToTemporaryLayer=!t,this.startPoint=i.firstInput.documentPoint;const s=this.copiesEffectiveCollection?this.draggedParts.toKeySet():i.selection,n=i.copyParts(s,i,!0),o=new GMap,r=this.draggedParts.iterator;for(;r.next();){const h=r.key;if(h.Pe()&&h.canCopy()){const a=n.get(h);if(a===null)continue;a.location=h.location,a.ensureBounds(),o.set(a,this.Is(a.location))}}const l=n.iterator;for(;l.next();){const h=l.value;h instanceof Link&&h.canCopy()&&o.set(h,this.Is())}if(this.copiedParts=o,this.mP(o.toKeySet()),this.draggedLink!==null){const h=this.draggedLink,a=h.routeBounds;h.pr(this.startPoint.x-(a.x+a.width/2),this.startPoint.y-(a.y+a.height/2))}this.doUpdateCursor(null)}kl(){const t=this.diagram;if(this.copiedParts!==null){if(t.removeParts(this.copiedParts.toKeySet(),!1),this.copiedParts=null,this.draggedParts!==null){const i=this.draggedParts.iterator;for(;i.next();)if(i.key instanceof Link){const s=i.value;s.point=new Point(0,0)}}this.doUpdateCursor(null)}t.skipsUndoManager=!1,t.partManager.addsToTemporaryLayer=!1,this.startPoint=t.firstInput.documentPoint}FC(){this.draggedLink!==null&&(this.dragsLink&&this.fn!==null&&(this.fn.stopDraggingMouseMove(),this.fn.originalLink=null),this.draggedLink=null,this.fn=null)}mc(t,i){const e=this.diagram,s=this.startPoint,n=Point.l();n.a(e.lastInput.documentPoint),this.moveParts(t,n.subtract(s),i),Point.s(n),e.getRenderingHint("temporaryPixelRatio")===!0&&e.Pl===null&&e.avgSpf>30&&(e.Uw(),e.yu())}moveParts(t,i,e){e===void 0&&(e=!1);const s=this.diagram;s!==null&&s.bP(t,i,this.dragOptions,e)}wP(){if(this.draggedParts===null)return;const t=this.diagram;let i=this.draggedParts.iterator;for(;i.next();){const e=i.key;e.Pe()&&(e.location=i.value.point)}for(i=this.draggedParts.iterator;i.next();){const e=i.key;if(e instanceof Link&&e.suspendsRouting){const s=i.value.point;this.draggedParts.set(e,this.Is()),e.pr(-s.x,-s.y)}}t.maybeUpdate()}$D(t){if(t===null)return!0;const i=t.part;return!!(i===null||i instanceof Adornment||i.layer.isTemporary||this.draggedParts&&this.draggedParts.has(i)||this.copiedParts&&this.copiedParts.has(i))}kP(t){const i=this.diagram;this.dragsLink&&(this.draggedLink!==null&&(this.draggedLink.fromNode=null,this.draggedLink.toNode=null),this.OC(!1));const e=this.findDragOverObject(t),s=i.lastInput;s.targetObject=e,this.doUpdateCursor(e);const n=i.skipsUndoManager;let o=!1;try{if(i.skipsUndoManager=!0,o=this.RC(s,e),!this.isActive&&DraggingTool.yt===null)return;const r=e!==null?e.part:null;if(r===null||i.handlesDragDropForTopLevelParts&&r.isTopLevel&&!(r instanceof Group)){const l=i.mouseDragOver;l!==null&&(l(s),o=!0)}if(!this.isActive&&DraggingTool.yt===null||(this.doDragOver(t,e),!this.isActive&&DraggingTool.yt===null))return}finally{i.skipsUndoManager=n,o&&i.maybeUpdate()}this.mu=e,!i.isReadOnly&&(i.allowMove||i.allowCopy)&&(i.allowHorizontalScroll||i.allowVerticalScroll)&&i.doAutoScroll(s.viewPoint)}findDragOverObject(t){return this.diagram.PP(t,null,i=>!this.$D(i))}doUpdateCursor(t){const i=this.diagram;(t===null||this.mu!==t)&&(!this.diagram.currentTool.isActive||this.mayCopy()?i.currentCursor=this.copyCursor:this.mayMove()?i.currentCursor=this.moveCursor:this.mayDragOut()&&(i.currentCursor=this.nodropCursor))}RC(t,i){let e=!1,s=this.mr.length;const n=s>0?this.mr[0]:null;if(i===n)return!1;t.handled=!1;for(let r=0;rs.findValidLinkablePort(a,i)),r=Point.l();let l=1/0,h=null;for(const a=o.iterator;a.next();){const c=a.value;if(c.part===null)continue;const u=c.getDocumentPoint(Spot.Center,r),d=t.distanceSquaredPoint(u);dh.suspendsRouting=!1)}if(this.doDropOnto(t,e),!this.isActive&&DraggingTool.yt===null)return;const o=Rect.l(),r=i.selection.iterator;for(;r.next();){const l=r.value;l instanceof Node&&this.QD(i,l,o)}Rect.s(o)}ZD(t,i){const e=this.diagram,s=i.part;if(e.handlesDragDropForTopLevelParts&&s.isTopLevel&&!(s instanceof Group)){const n=e.mouseDrop;n!==null&&n(t)}}QD(t,i,e){if(!i.canAvoid())return;let s=!1;e=i.getAvoidableRect(e),t.viewportBounds.containsRect(e)&&(s=!0);const n=this.copiedParts||this.draggedParts,o=t.NP(e,l=>l.part,l=>l instanceof Link,!0,l=>l instanceof Link,s);if(o.count===0)return;const r=o.iterator;for(;r.next();){const l=r.value;n.has(l)&&n.has(i)||!l.isMemberOf(i)&&l.isAvoiding&&l.invalidateRoute()}}doDropOnto(t,i){}doMouseMove(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseMove(i.event,i.documentPoint,i.targetDiagram))return;this.currentPart!==null&&this.draggedParts!==null&&(this.mayCopy()?(this.xP(!1),t.Vw(this.copiedParts),this.mc(this.copiedParts,!1),t.wm(this.copiedParts)):this.mayMove()?(this.kl(),this.mc(this.draggedParts,!0)):this.mayDragOut()?(this.xP(!1),this.mc(this.copiedParts,!1)):this.kl(),this.kP(t.lastInput.documentPoint))}doMouseUp(){if(!this.isActive)return;const t=this.diagram,i=t.lastInput;if(this.simulatedMouseUp(i.event,i.documentPoint,i.targetDiagram))return;let e=!1;const s=this.mayCopy();if(s&&this.copiedParts!==null?(this.kl(),this.xP(!0),t.Vw(this.copiedParts),this.mc(this.copiedParts,!1),t.wm(this.copiedParts),this.copiedParts!==null&&(t.v("ChangingSelection",t.selection),t.clearSelection(!0),this.copiedParts.iteratorKeys.each(n=>{n.isSelected=!0}))):(e=!0,this.kl(),this.mayMove()&&(this.mc(this.draggedParts,!0),this.kP(t.lastInput.documentPoint))),this.gu=!0,this.BC(t.lastInput.documentPoint),this.isActive){const n=s?this.copiedParts.toKeySet():this.draggedParts.toKeySet();this.copiedParts=null,e&&this._D(),t.invalidateDocumentBounds(),t.wm(this.draggedParts),this.transactionResult=s?"Copy":"Move",t.v(s?"SelectionCopied":"SelectionMoved",n)}this.stopTool(),s&&t.v("ChangedSelection",t.selection)}simulatedMouseMove(t,i,e){if(DraggingTool.yt===null)return!1;const s=DraggingTool.yt.diagram;e instanceof Diagram||(e=null);const n=DraggingTool.zh;if(e!==n){if(n!==null&&n!==s){n.stopAutoScroll(),DraggingTool.yt.isDragOutStarted=!1;const r=n.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDragLeave()}if(DraggingTool.zh=e,e!==null&&e!==s){DraggingTool.yt.vC();const r=e.toolManager.findTool("Dragging");r!==null&&(r.UC(),r.doSimulatedDragEnter())}this.doUpdateCursor(null)}if(e===null||e===s||!e.allowDrop||e.isReadOnly||!e.allowInsert)return!1;const o=e.toolManager.findTool("Dragging");if(o!==null){let r=i;t!==null&&(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),r=e.getMouse(t)),e.lastInput.documentPoint=r,e.lastInput.viewPoint=e.transformDocToView(r),e.lastInput.down=!1,e.lastInput.up=!1,o.doSimulatedDragOver()}return!0}simulatedMouseUp(t,i,e){if(DraggingTool.yt===null)return!1;const s=DraggingTool.zh,n=DraggingTool.yt.diagram;if(e===null)return DraggingTool.yt.doCancel(),!0;if(e!==s){const o=s.toolManager.findTool("Dragging");if(s!==null&&s!==n&&o!==null)return s.stopAutoScroll(),DraggingTool.yt.isDragOutStarted=!1,o.doSimulatedDragLeave(),!1;DraggingTool.zh=e;const r=e.toolManager.findTool("Dragging");r!==null&&(DraggingTool.yt.vC(),r.UC(),r.doSimulatedDragEnter())}if(e!==this.diagram){let o=i;t!==null?(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),o=e.getMouse(t)):o===null&&(o=new Point),e.lastInput.documentPoint=o,e.lastInput.viewPoint=e.transformDocToView(o),e.lastInput.down=!1,e.lastInput.up=!0;const r=e.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDrop();const l=DraggingTool.yt;if(l!==null){const h=l.mayCopy();l.transactionResult=h?"Copy":"Move",l.stopTool()}return!0}return!1}_D(){if(this.draggedParts===null)return;const t=this.draggedParts.iterator;for(;t.next();){const i=t.key;if(i instanceof Node){const e=i.containingGroup;e!==null&&e.hasPlaceholder()&&!this.draggedParts.has(e)&&e.placeholder.c()}}}mayCopy(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowCopy||!(Util.rr?t.lastInput.alt:t.lastInput.control))return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayDragOut(){if(!this.isCopyEnabled)return!1;const t=this.diagram;if(!t.allowDragOut||!t.allowCopy||t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayMove(){const t=this.diagram;if(t.isReadOnly||!t.allowMove)return!1;const i=t.selection.iterator;for(;i.next();)if(i.value.canMove())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canMove())}UC(){DraggingTool.zw.has(this)||DraggingTool.zw.add(this)}static WD(){if(DraggingTool.zw.count>0){const t=DraggingTool.zw,i=t.length;for(let e=0;e{n.isSelected=!0,s.add(n)})),this.BC(t.lastInput.documentPoint),t.invalidateDocumentBounds(),this.copiedParts!==null&&(this.transactionResult="ExternalCopy"),this.copiedParts=null,t.doFocus(),t.dc=!1,t.v("ExternalObjectsDropped",s,e),this.stopTransaction(),t.v("ChangedSelection",t.selection)}t.animationManager.wu=!1}VC(t,i,e){if(this.copiedParts!==null)return;const s=this.diagram;if(s.isReadOnly||s.isModelReadOnly)return;s.skipsUndoManager=!i,s.partManager.addsToTemporaryLayer=!i,this.startPoint=e.documentPoint;const n=s.copyParts(t,s,!0),o=Rect.l();this.JD(t,o);const r=o.x+o.width/2,l=o.y+o.height/2;Rect.s(o);const h=this.ym,a=new GMap,c=Point.l(),f=t.iterator;for(;f.next();){const d=f.value;if(d instanceof Link&&d.canCopy()){const m=n.get(d);if(m===null)continue;m.points=d.points,m.pr(h.x-r,h.y-l),m.suspendsRouting=!0,a.set(m,this.Is())}}const u=t.iterator;for(;u.next();){const d=u.value;if(d.Pe()&&d.canCopy()){const m=n.get(d);if(m===null)continue;const g=d.location;c.e(h.x-(r-g.x),h.y-(l-g.y)),m.location=c,m.ensureBounds(),a.set(m,this.Is(c))}}if(Point.s(c),this.copiedParts=a,this.mP(a.toKeySet()),this.draggedLink!==null){const d=this.draggedLink,m=d.routeBounds;d.pr(this.startPoint.x-(m.x+m.width/2),this.startPoint.y-(m.y+m.height/2))}this.doUpdateCursor(null)}qD(){this.isDragOutStarted=!0,this.gu=!1,DraggingTool.yt=this,DraggingTool.zh=this.diagram,this.doSimulatedDragOut()}doSimulatedDragOut(){const t=this.diagram;t.dc=!1,!this.mayCopy()&&!this.mayMove()?t.currentCursor=this.nodropCursor:t.currentCursor="",this.mu=null}computeMove(t,i,e,s){const n=this.diagram;return n!==null?n.computeMove(t,i,this.dragOptions,s):new Point}static zw=new List;static yt=null;static zh=null}ToolManager.prototype.doCancel=function(){DraggingTool.yt!==null&&DraggingTool.yt.doCancel(),Tool.prototype.doCancel.call(this)};class LinkingBaseTool extends Tool{CP;LP;Sl;AP;TP;Xh;DP;Kh;FP;RP;vP;OP;IP;EP;zC;BP;Ml;UP;constructor(){super(),this.CP=100,this.LP=!1,this.Sl="pointer",this.AP=new Link({layerName:"Tool"}).add(new Shape({isPanelMain:!0,stroke:"blue"}).theme("stroke","tempLink"),new Shape({toArrow:"Standard",fill:"blue",stroke:"blue"}).theme("fill","tempLink").theme("stroke","tempLink")).li(),this.Xh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.Dk}).theme("stroke","tempPort"),this.TP=new Node({selectable:!1,layerName:"Tool"}).add(this.Xh).li(),this.Kh=new Shape("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:Size.Dk}).theme("stroke","tempPort"),this.DP=new Node({selectable:!1,layerName:"Tool"}).add(this.Kh).li(),this.FP=null,this.RP=null,this.vP=null,this.OP=null,this.IP=null,this.EP=!0,this.zC=new GMap,this.BP=null,this.Ml=null,this.UP=null}doStop(){this.diagram.stopAutoScroll(),this.originalLink=null,this.originalFromNode=null,this.originalFromPort=null,this.originalToNode=null,this.originalToPort=null,this.validPortsCache.clear(),this.targetPort=null}get portGravity(){return this.CP}set portGravity(t){Util.i(t,"number",LinkingBaseTool,"portGravity"),t>=0&&(this.CP=t)}get isUnconnectedLinkValid(){return this.LP}set isUnconnectedLinkValid(t){Util.i(t,"boolean",LinkingBaseTool,"isUnconnectedLinkValid"),this.LP=t}get linkingCursor(){return this.Sl}set linkingCursor(t){this.Sl=t}get temporaryLink(){return this.AP}set temporaryLink(t){t.li(),this.AP=t}get temporaryFromNode(){return this.TP}set temporaryFromNode(t){t.li(),this.TP=t,t&&(this.Xh=t.port)}get temporaryFromPort(){return this.Xh}set temporaryFromPort(t){if(this.Xh!==null){const i=this.Xh.panel;if(i!==null){const e=i.L.indexOf(this.Xh);i.removeAt(e),i.insertAt(e,t)}}this.Xh=t}get temporaryToNode(){return this.DP}set temporaryToNode(t){t.li(),this.DP=t,t&&(this.Kh=t.port)}get temporaryToPort(){return this.Kh}set temporaryToPort(t){if(this.Kh!==null){const i=this.Kh.panel;if(i!==null){const e=i.L.indexOf(this.Kh);i.removeAt(e),i.insertAt(e,t)}}this.Kh=t}get originalLink(){return this.FP}set originalLink(t){this.FP=t}get originalFromNode(){return this.RP}set originalFromNode(t){this.RP=t}get originalFromPort(){return this.vP}set originalFromPort(t){this.vP=t}get originalToNode(){return this.OP}set originalToNode(t){this.OP=t}get originalToPort(){return this.IP}set originalToPort(t){this.IP=t}get isForwards(){return this.EP}set isForwards(t){this.EP=t}get validPortsCache(){return this.zC}get targetPort(){return this.BP}set targetPort(t){this.BP=t}copyPortProperties(t,i,e,s,n){if(t===null||i===null||e===null||s===null)return;const o=i.getDocumentScale(),r=Size.l();r.width=i.naturalBounds.width*o,r.height=i.naturalBounds.height*o,s.desiredSize=r,Size.s(r),n?(s.toSpot=i.toSpot,s.toEndSegmentLength=i.toEndSegmentLength):(s.fromSpot=i.fromSpot,s.fromEndSegmentLength=i.fromEndSegmentLength),e.locationSpot=Spot.Center;const l=Point.l();e.location=i.getDocumentPoint(Spot.Center,l),Point.s(l),s.angle=i.getDocumentAngle(),this.portTargeted!==null&&this.portTargeted(t,i,e,s,n)}setNoTargetPortProperties(t,i,e){i!==null&&(i.desiredSize=Size.Dk,i.fromSpot=Spot.None,i.toSpot=Spot.None),t!==null&&(t.location=this.diagram.lastInput.documentPoint),this.portTargeted!==null&&this.portTargeted(null,null,t,i,e)}doMouseDown(){this.isActive&&this.doMouseMove()}doMouseMove(){if(this.isActive){const t=this.diagram;if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null&&this.targetPort.part instanceof Node){const i=this.targetPort.part;this.isForwards?this.copyPortProperties(i,this.targetPort,this.temporaryToNode,this.temporaryToPort,!0):this.copyPortProperties(i,this.targetPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else this.isForwards?this.setNoTargetPortProperties(this.temporaryToNode,this.temporaryToPort,!0):this.setNoTargetPortProperties(this.temporaryFromNode,this.temporaryFromPort,!1);(t.allowHorizontalScroll||t.allowVerticalScroll)&&t.doAutoScroll(t.lastInput.viewPoint)}}findValidLinkablePort(t,i){if(t===null)return null;const e=t.part;if(!(e instanceof Node))return null;for(;t!==null;){const s=i?t.toLinkable:t.fromLinkable;if(s===!0&&(t.portId!==null||t instanceof Node)&&(i?this.isValidTo(e,t):this.isValidFrom(e,t)))return t;if(s===!1)return null;t=t.panel}return null}findTargetPort(t){const i=this.diagram,e=i.lastInput.documentPoint;let s=this.portGravity;s<=0&&(s=.1);const n=this,o=i.findObjectsNear(e,s,a=>n.findValidLinkablePort(a,t),null,!0);let r=1/0,l=null;const h=o.iterator;for(;h.next();){const a=h.value,c=a.part;if(!(c instanceof Node))continue;const f=a.getDocumentPoint(Spot.Center,Point.l()),u=e.x-f.x,d=e.y-f.y;Point.s(f);const m=u*u+d*d;if(m=e)return!1}return!0}isValidTo(t,i){if(t===null||i===null)return this.isUnconnectedLinkValid;if(this.diagram.currentTool===this&&(t.layer!==null&&!t.layer.allowLink||i.toLinkable!==!0))return!1;const e=i.toMaxLinks;if(e<1/0){if(this.originalLink!==null&&t===this.originalToNode&&i===this.originalToPort)return!0;let s=i.portId;if(s===null&&(s=""),t.findLinksInto(s).count>=e)return!1}return!0}isInSameNode(t,i){if(t===null||i===null)return!1;if(t===i)return!0;const e=t.part,s=i.part;return e!==null&&e===s}isLinked(t,i){if(t===null||i===null)return!1;const e=t.part;if(!(e instanceof Node))return!1;let s=t.portId;s===null&&(s="");const n=i.part;if(!(n instanceof Node))return!1;let o=i.portId;o===null&&(o="");const r=n.findLinksInto(o);for(;r.next();){const l=r.value;if(l.fromNode===e&&l.fromPortId===s)return!0}return!1}isValidLink(t,i,e,s){if(!this.isValidFrom(t,i)||!this.isValidTo(e,s)||i!==null&&s!==null&&(!(i.fromLinkableSelfNode&&s.toLinkableSelfNode)&&this.isInSameNode(i,s)||!(i.fromLinkableDuplicates&&s.toLinkableDuplicates)&&this.isLinked(i,s))||this.originalLink!==null&&(t!==null&&this.isLabelDependentOnLink(t,this.originalLink)||e!==null&&this.isLabelDependentOnLink(e,this.originalLink))||t!==null&&e!==null&&(t.data===null&&e.data!==null||t.data!==null&&e.data===null)||!this.isValidCycle(t,e,this.originalLink))return!1;let n;return t!==null&&(n=t.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))||e!==null&&(n=e.linkValidation,n!==null&&!n(t,i,e,s,this.originalLink))?!1:(n=this.linkValidation,n!==null?n(t,i,e,s,this.originalLink):!0)}isLabelDependentOnLink(t,i){if(t===null)return!1;const e=t.labeledLink;if(e===null)return!1;if(e===i)return!0;const s=new GSet;return s.add(t),this.VP(e,i,s)}VP(t,i,e){if(t===i)return!0;const s=t.fromNode;if(s!==null&&s.isLinkLabel&&(e.add(s),this.VP(s.labeledLink,i,e)))return!0;const n=t.toNode;return!!(n!==null&&n.isLinkLabel&&(e.add(n),this.VP(n.labeledLink,i,e)))}isValidCycle(t,i,e){if(e===void 0&&(e=null),t===null||i===null)return this.isUnconnectedLinkValid;const s=this.diagram;let n=1;if(s&&(s.model.pc()?n=s.isTreePathToChildren?5:6:n=s.validCycle),n===1)return!0;if(n===5){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=i.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.toNode===i)return!1}return!this.xu(t,i,e,!0)}else if(n===6){const o=e||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;const r=t.linksConnected;for(;r.next();){const l=r.value;if(l!==e&&l.isTreeLink&&l.fromNode===t)return!1}return!this.xu(t,i,e,!0)}else{if(n===2)return!this.tF(t,i,e);if(n===3)return!this.xu(t,i,e,!1);if(n===4)return!this.iF(t,i,e)}return!0}xu(t,i,e,s){if(t===i)return!0;if(t===null||i===null)return!1;const n=t.linksConnected;for(;n.next();){const o=n.value;if(o===e||s&&!o.isTreeLink||o.toNode!==t)continue;const r=o.fromNode;if(r!==t&&this.xu(r,i,e,s))return!0}return!1}tF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.XC(s,t,i,e)}XC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s||o.toNode!==i)continue;const r=o.fromNode;if(r!==i&&this.XC(t,r,e,s))return!0}return!1}iF(t,i,e){if(t===i)return!0;const s=new GSet;return s.add(i),this.KC(s,t,i,e)}KC(t,i,e,s){if(i===e)return!0;if(i===null||e===null||t.has(i))return!1;t.add(i);const n=i.linksConnected;for(;n.next();){const o=n.value;if(o===s)continue;const r=o.fromNode,l=o.toNode,h=r===i?l:r;if(h!==i&&this.KC(t,h,e,s))return!0}return!1}get linkValidation(){return this.Ml}set linkValidation(t){t!==null&&Util.i(t,"function",LinkingBaseTool,"linkValidation"),this.Ml=t}get portTargeted(){return this.UP}set portTargeted(t){t!==null&&Util.i(t,"function",LinkingBaseTool,"portTargeted"),this.UP=t}}var LinkingDirection=(w=>(w[w.Either=1]="Either",w[w.ForwardsOnly=2]="ForwardsOnly",w[w.BackwardsOnly=3]="BackwardsOnly",w))(LinkingDirection||{});class LinkingTool extends LinkingBaseTool{zP;XP;S;KP;constructor(t){super(),this.name="Linking",this.zP={},this.XP=null,this.S=1,this.KP=null,t&&Object.assign(this,t)}static Either=1;static ForwardsOnly=2;static BackwardsOnly=3;get archetypeLinkData(){return this.zP}set archetypeLinkData(t){t!==null&&Util.i(t,"object",LinkingTool,"archetypeLinkData"),this.zP=t}get archetypeLabelNodeData(){return this.XP}set archetypeLabelNodeData(t){t!==null&&Util.i(t,"object",LinkingTool,"archetypeLabelNodeData"),this.XP=t}get direction(){return this.S}set direction(t){this.S=t}get startObject(){return this.KP}set startObject(t){this.KP=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||t.isModelReadOnly||!t.allowLink||!t.model.Xw()||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize()?!1:this.findLinkablePort()!==null}findLinkablePort(){const t=this.diagram;let i=this.startObject;if(i===null&&(i=t.findObjectAt(t.firstInput.documentPoint,null,null)),i===null)return null;const e=i.part;if(!(e instanceof Node))return null;const s=this.direction;if(s===1||s===2){const n=this.findValidLinkablePort(i,!1);if(n!==null)return this.isForwards=!0,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!1))return this.isForwards=!0,o}}if(s===1||s===3){const n=this.findValidLinkablePort(i,!0);if(n!==null)return this.isForwards=!1,n;if(this.startObject===e){const o=e.port;if(this.findValidLinkablePort(o,!0))return this.isForwards=!1,o}}return null}doActivate(){const t=this.diagram,i=this.findLinkablePort();if(i===null){this.stopTool();return}if(this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.isForwards){this.temporaryToNode!==null&&(this.temporaryToNode.location=t.lastInput.documentPoint),this.originalFromPort=i;const e=this.originalFromPort.part;e instanceof Node&&(this.originalFromNode=e),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else{this.temporaryFromNode!==null&&(this.temporaryFromNode.location=t.lastInput.documentPoint),this.originalToPort=i;const e=this.originalToPort.part;e instanceof Node&&(this.originalToNode=e),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0)}t.add(this.temporaryFromNode),this.temporaryFromNode&&this.temporaryFromNode.ensureBounds(),t.add(this.temporaryToNode),this.temporaryToNode&&this.temporaryToNode.ensureBounds(),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.temporaryLink.isTreeLink=this.isNewTreeLink(),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.startObject=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=null,e=null,s=null,n=null,o=null;try{this.targetPort=this.findTargetPort(this.isForwards);const r=this.targetPort;if(r!==null){const l=r.part;l instanceof Node&&(this.isForwards?(this.originalFromNode!==null&&(i=this.originalFromNode,e=this.originalFromPort),s=l,n=r):(i=l,e=r,this.originalToNode!==null&&(s=this.originalToNode,n=this.originalToPort)))}else this.isForwards?this.originalFromNode!==null&&this.isUnconnectedLinkValid&&(i=this.originalFromNode,e=this.originalFromPort):this.originalToNode!==null&&this.isUnconnectedLinkValid&&(s=this.originalToNode,n=this.originalToPort);i!==null||s!==null?(o=this.insertLink(i,e,s,n),o!==null?(r===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint),t.allowSelect&&(t.v("ChangingSelection",t.selection),t.clearSelection(!0),o.isSelected=!0),this.transactionResult=this.name,t.v("LinkDrawn",o)):this.doNoLink(i,e,s,n)):this.isForwards?this.doNoLink(this.originalFromNode,this.originalFromPort,null,null):this.doNoLink(null,null,this.originalToNode,this.originalToPort)}finally{this.stopTool(),o&&t.allowSelect&&t.v("ChangedSelection",t.selection)}}}isNewTreeLink(){const t=this.archetypeLinkData;if(t===null)return!0;if(t instanceof Link)return t.isTreeLink;const i=this.diagram;if(i===null)return!0;const e=i.partManager.getLinkCategoryForData(t),s=i.partManager.findLinkTemplateForCategory(e);return s!==null?s.isTreeLink:!0}insertLink(t,i,e,s){return this.diagram.partManager.insertLink(t,i,e,s)}doNoLink(t,i,e,s){}}class RelinkingTool extends LinkingBaseTool{YP;GP;fs;jP;constructor(t){super(),this.name="Relinking",this.YP=new Shape("Diamond",{desiredSize:Size.lu,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:0}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.GP=new Shape("Diamond",{desiredSize:Size.lu,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:-1}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.fs=null,this.jP=new Rect,t&&Object.assign(this,t)}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i="RelinkFrom",e=null;if(t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkFrom()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null&&(e=this.makeAdornment(s,!1),t.addAdornment(i,e)))}if(e===null&&t.removeAdornment(i),i="RelinkTo",e=null,t.isSelected&&!this.diagram.isReadOnly){const s=t.selectionObject;s!==null&&t.canRelinkTo()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(e=t.findAdornment(i),e===null?(e=this.makeAdornment(s,!0),t.addAdornment(i,e)):e.c())}e===null&&t.removeAdornment(i)}makeAdornment(t,i){const e=new Adornment;e.type=Panel.Link;const s=i?this.toHandleArchetype:this.fromHandleArchetype;return s!==null&&e.add(s.copy().xm()),e.adornedObject=t,e}get fromHandleArchetype(){return this.YP}set fromHandleArchetype(t){this.YP=t}get toHandleArchetype(){return this.GP}set toHandleArchetype(t){this.GP=t}get handle(){return this.fs}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.fs=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowRelink||!t.model.Xw()||!t.lastInput.left)return!1;let e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom");return e===null&&(e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo")),e!==null}doActivate(){const t=this.diagram;if(this.originalLink===null){let i=this.handle;if(i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom"),i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo"))),i===null)return;const e=i.part;if(!(e instanceof Adornment)||!(e.adornedPart instanceof Link))return;this.handle=i,this.isForwards=e===null||e.category==="RelinkTo",this.originalLink=e.adornedPart}this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.originalFromPort=this.originalLink.fromPort,this.originalFromNode=this.originalLink.fromNode,this.originalToPort=this.originalLink.toPort,this.originalToNode=this.originalLink.toNode,this.jP.set(this.originalLink.actualBounds),this.originalLink!==null&&this.originalLink.pointsCount>0&&(this.originalLink.fromNode===null&&(this.temporaryFromPort!==null&&(this.temporaryFromPort.desiredSize=Size.ru),this.temporaryFromNode!==null&&(this.temporaryFromNode.location=this.originalLink.getPoint(0))),this.originalLink.toNode===null&&(this.temporaryToPort!==null&&(this.temporaryToPort.desiredSize=Size.ru),this.temporaryToNode!==null&&(this.temporaryToNode.location=this.originalLink.getPoint(this.originalLink.pointsCount-1)))),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0),t.add(this.temporaryFromNode),t.add(this.temporaryToNode),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.copyLinkProperties(this.originalLink,this.temporaryLink),this.temporaryLink.invalidateRoute(),t.add(this.temporaryLink)),this.isActive=!0}copyLinkProperties(t,i){if(t===null||i===null)return;i.adjusting=t.adjusting,i.corner=t.corner;let e=t.curve;(e===11||e===10)&&(e=0),i.curve=e,i.curviness=t.curviness,i.isTreeLink=t.isTreeLink,i.points=t.points,i.routing=t.routing,i.smoothness=t.smoothness,i.fromSpot=t.fromSpot,i.fromEndSegmentLength=t.fromEndSegmentLength,i.fromShortLength=t.fromShortLength,i.toSpot=t.toSpot,i.toEndSegmentLength=t.toEndSegmentLength,i.toShortLength=t.toShortLength}doDeactivate(){this.isActive=!1;const t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.handle=null}doMouseUp(){if(this.isActive){const t=this.diagram;this.transactionResult=null;let i=this.originalFromNode,e=this.originalFromPort,s=this.originalToNode,n=this.originalToPort,o=this.originalLink;try{if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null){const r=this.targetPort.part;r instanceof Node&&(this.isForwards?(s=r,n=this.targetPort):(i=r,e=this.targetPort))}else this.isUnconnectedLinkValid?this.isForwards?(s=null,n=null):(i=null,e=null):o=null;o!==null?(this.reconnectLink(o,this.isForwards?s:i,this.isForwards?n:e,this.isForwards),this.targetPort===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint,o.invalidateRoute()),this.transactionResult=this.name,t.v("LinkRelinked",o,this.isForwards?this.originalToPort:this.originalFromPort)):this.doNoRelink(this.originalLink,this.isForwards),this.originalLink.invalidateOtherJumpOvers(this.jP)}finally{this.stopTool()}}}reconnectLink(t,i,e,s){const n=e!==null&&e.portId!==null?e.portId:"";return s?(t.toNode=i,t.toPortId=n):(t.fromNode=i,t.fromPortId=n),!0}doNoRelink(t,i){}doDraggingMouseMove(t,i,e,s){t!==null?(this.copyPortProperties(t,i,this.temporaryFromNode,this.temporaryFromPort,!1),this.diagram.add(this.temporaryFromNode)):this.diagram.remove(this.temporaryFromNode),e!==null?(this.copyPortProperties(e,s,this.temporaryToNode,this.temporaryToPort,!0),this.diagram.add(this.temporaryToNode)):this.diagram.remove(this.temporaryToNode)}stopDraggingMouseMove(){this.diagram.remove(this.temporaryFromNode),this.diagram.remove(this.temporaryToNode)}}var ReshapingBehavior=(w=>(w[w.None=0]="None",w[w.Horizontal=1]="Horizontal",w[w.Vertical=2]="Vertical",w[w.All=3]="All",w))(ReshapingBehavior||{});class LinkReshapingTool extends Tool{Co;HP;qP;fs;Kw;WP;bm;constructor(t){super(),this.name="LinkReshaping",this.Co=new Shape("Rectangle",{desiredSize:Size._N,fill:"lightblue",stroke:"dodgerblue"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.HP=new Shape("Diamond",{desiredSize:Size.lu,fill:"lightblue",stroke:"dodgerblue",cursor:"move"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.qP=3,this.fs=null,this.Kw=null,this.WP=new Point,this.bm=new List,t&&Object.assign(this,t)}static None=0;static Horizontal=1;static Vertical=2;static All=3;getReshapingBehavior(t){return t?t.wr:0}setReshapingBehavior(t,i){t.wr=i}updateAdornments(t){if(t===null||!(t instanceof Link))return;let i=null;if(t.isSelected&&!this.diagram.isReadOnly){const e=t.path;e!==null&&t.canReshape()&&t.actualBounds.isReal()&&t.isVisible()&&e.actualBounds.isReal()&&e.isVisibleObject()&&(i=t.findAdornment(this.name),(i===null||i.JP!==t.pointsCount||i.$P!==t.resegmentable)&&(i=this.makeAdornment(e),i!==null&&(i.JP=t.pointsCount,i.$P=t.resegmentable,t.addAdornment(this.name,i))))}i===null&&t.removeAdornment(this.name)}makeAdornment(t){const i=t.part,e=i.points,s=i.pointsCount,n=i.isOrthogonal;let o=null;if(e!==null&&s>1){o=new Adornment,o.type=Panel.Link;const r=i.firstPickIndex,l=i.lastPickIndex,h=n?1:0;if(i.resegmentable&&i.computeCurve()!==9)for(let a=r+h;ae.firstPickIndex+1&&s0))this.eF(t,i);else if(t instanceof Panel){const e=t.elements;for(;e.next();){const s=e.value;this.updateResizeHandles(s,i)}}}}eF(t,i){let e=t.alignment;e.isNoSpot()&&(e=Spot.Center);let s=i;if(e.x<=0)e.y<=0?s+=225:e.y>=1?s+=135:s+=180;else if(e.x>=1)e.y<=0?s+=315:e.y>=1&&(s+=45);else if(e.y<=0)s+=270;else if(e.y>=1)s+=90;else return;s<0?s+=360:s>=360&&(s-=360),s<22.5?t.cursor="e-resize":s<67.5?t.cursor="se-resize":s<112.5?t.cursor="s-resize":s<157.5?t.cursor="sw-resize":s<202.5?t.cursor="w-resize":s<247.5?t.cursor="nw-resize":s<292.5?t.cursor="n-resize":s<337.5?t.cursor="ne-resize":t.cursor="e-resize"}get handleArchetype(){return this.Co}set handleArchetype(t){this.Co=t}get handle(){return this.fs}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.fs=t}get adornedObject(){return this.us}set adornedObject(t){if(t!==null&&t.part instanceof Adornment)throw new Error("new handle must not be in an Adornment: "+t);this.us=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowResize||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle!==null&&(this.adornedObject=this.handle.part.adornedObject,this.adornedObject!==null&&(t.isMouseCaptured=!0,t.animationManager.stopAnimation(),t.pu=!0,this.startTransaction(this.name),this.km.set(this.adornedObject.getDocumentPoint(this.handle.alignment.opposite())),this.wc.set(this.adornedObject.part.location),this.QP.set(this.adornedObject.desiredSize),this.jw=this.computeCellSize(),this.Yw=this.computeMinSize(),this.Gw=this.computeMaxSize(),this.isActive=!0))}doDeactivate(){const t=this.diagram;t.pu=!1,t.bl=!0,this.stopTransaction(),this.handle=null,this.us=null,t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){this.adornedObject!==null&&(this.adornedObject.desiredSize=this.originalDesiredSize,this.adornedObject.part.location=this.originalLocation),this.stopTool()}doMouseMove(){const t=this.diagram;if(!this.isActive)return;const i=this.Yw,e=this.Gw,s=this.jw,n=t.lastInput.documentPoint,o=this.adornedObject.getLocalPoint(n,Point.l()),r=this.computeReshape(),l=this.computeResize(o,this.handle.alignment,i,e,s,r);this.resize(l),t.maybeUpdate(),Point.s(o)}doMouseUp(){const t=this.diagram;if(this.isActive){const i=this.Yw,e=this.Gw,s=this.jw,n=this.adornedObject.getLocalPoint(t.lastInput.documentPoint,Point.l()),o=this.computeReshape(),r=this.computeResize(n,this.handle.alignment,i,e,s,o);this.resize(r),Point.s(n),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.v("PartResized",this.adornedObject,this.originalDesiredSize)}this.stopTool()}resize(t){const i=this.diagram,e=this.adornedObject;if(e===null)return;e.desiredSize=t.size;const s=e.part;s.ensureBounds();const n=e.getDocumentPoint(this.handle.alignment.opposite());if(s instanceof Group){const o=new List;o.add(s);let r;!this.dragsMembers&&!s.hasPlaceholder()&&(r=new DraggingOptions,r.dragsMembers=!1),i.moveParts(o,this.oppositePoint.copy().subtract(n),!0,r)}else s.location=s.location.copy().subtract(n).add(this.oppositePoint);i.maybeUpdate()}computeResize(t,i,e,s,n,o){i.isNoSpot()&&(i=Spot.Center);const r=this.adornedObject.naturalBounds,l=r.x,h=r.y,a=r.x+r.width,c=r.y+r.height;let f=1;if(!o){let m=r.width,g=r.height;m<=0&&(m=1),g<=0&&(g=1),f=g/m}const u=Point.l();Geo.Ig(t.x,t.y,l,h,n.width,n.height,u);const d=r.copy();return i.x<=0?i.y<=0?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=Math.max(c-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.x=a-d.width,d.y=c-d.height)):i.y>=1?(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=Math.max(a-d.x,e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.x=a-d.width)):(d.x=Math.max(u.x,a-s.width),d.x=Math.min(d.x,a-e.width),d.width=a-d.x,o||(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f,d.y=h+.5*(c-h-d.height))):i.x>=1?i.y<=0?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=Math.max(c-d.y,e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width),d.y=c-d.height)):i.y>=1?(d.width=Math.max(Math.min(u.x-l,s.width),e.width),d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.height/d.width>=1?(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f):(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width))):(d.width=Math.max(Math.min(u.x-l,s.width),e.width),o||(d.height=Math.max(Math.min(f*d.width,s.height),e.height),d.width=d.height/f,d.y=h+.5*(c-h-d.height))):i.y<=0?(d.y=Math.max(u.y,c-s.height),d.y=Math.min(d.y,c-e.height),d.height=c-d.y,o||(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width,d.x=l+.5*(a-l-d.width))):i.y>=1&&(d.height=Math.max(Math.min(u.y-h,s.height),e.height),o||(d.width=Math.max(Math.min(d.height/f,s.width),e.width),d.height=f*d.width,d.x=l+.5*(a-l-d.width))),Point.s(u),d}computeReshape(){let t=0;return this.adornedObject instanceof Shape&&(t=this.adornedObject._P()),!(t===6||this.diagram.lastInput.shift)}computeMinSize(){const t=this.adornedObject.minSize.copy(),i=this.minSize;return!isNaN(i.width)&&i.width>t.width&&(t.width=i.width),!isNaN(i.height)&&i.height>t.height&&(t.height=i.height),t}computeMaxSize(){const t=this.adornedObject.maxSize.copy(),i=this.maxSize;return!isNaN(i.width)&&i.width0&&(t.width=n.width),!isNaN(n.height)&&n.height>0&&(t.height=n.height)}let e=this.cellSize;isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height);const s=this.diagram;if((isNaN(t.width)||isNaN(t.height))&&s){const n=s.grid;n!==null&&n.visible&&this.isGridSnapEnabled&&(e=n.gridCellSize,isNaN(t.width)&&!isNaN(e.width)&&e.width>0&&(t.width=e.width),isNaN(t.height)&&!isNaN(e.height)&&e.height>0&&(t.height=e.height))}return(isNaN(t.width)||t.width===0||t.width===1/0)&&(t.width=1),(isNaN(t.height)||t.height===0||t.height===1/0)&&(t.height=1),t}get minSize(){return this.xr}set minSize(t){if(!this.xr.equals(t)){let e=t.width;isNaN(e)&&(e=0);let s=t.height;isNaN(s)&&(s=0),this.xr.e(e,s)}}get maxSize(){return this.br}set maxSize(t){if(!this.br.equals(t)){let e=t.width;isNaN(e)&&(e=1/0);let s=t.height;isNaN(s)&&(s=1/0),this.br.e(e,s)}}get cellSize(){return this.Lo}set cellSize(t){this.Lo.equals(t)||this.Lo.a(t)}get isGridSnapEnabled(){return this.yc}set isGridSnapEnabled(t){Util.i(t,"boolean",ResizingTool,"isGridSnapEnabled"),this.yc=t}get dragsMembers(){return this.ZP}set dragsMembers(t){Util.i(t,"boolean",ResizingTool,"dragsMembers"),this.ZP=t}get oppositePoint(){return this.km}set oppositePoint(t){this.km.equals(t)||this.km.a(t)}get originalDesiredSize(){return this.QP}get originalLocation(){return this.wc}}class RotatingTool extends Tool{tS;iS;us;Co;fs;eS;Pm;wc;sS;nS;constructor(t){super(),this.name="Rotating",this.tS=45,this.iS=2,this.wc=new Point,this.us=null,this.Co=new Shape("Ellipse",{desiredSize:Size.lu,fill:"lightblue",stroke:"dodgerblue",strokeWidth:1,cursor:"pointer"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.fs=null,this.eS=0,this.Pm=new Point(NaN,NaN),this.sS=0,this.nS=50,t&&Object.assign(this,t)}updateAdornments(t){if(t!==null){if(t.Cl()){const i=t.rotateObject;if(i===t||i===t.path||i.isPanelMain)return}if(t.isSelected&&!this.diagram.isReadOnly){const i=t.rotateObject;if(i!==null&&t.canRotate()&&t.actualBounds.isReal()&&t.isVisible()&&i.actualBounds.isReal()&&i.isVisibleObject()){let e=t.findAdornment(this.name);if((e===null||e.adornedObject!==i)&&(e=this.makeAdornment(i)),e!==null){e.angle=i.getDocumentAngle(),e.hasPlaceholder()||(e.location=this.computeAdornmentLocation(i)),t.addAdornment(this.name,e);return}}}t.removeAdornment(this.name)}}makeAdornment(t){let i=null;const e=t.part.rotateAdornmentTemplate;if(e===null){i=new Adornment,i.type=Panel.Position,i.locationSpot=Spot.Center;const s=this.handleArchetype;s!==null&&i.add(s.copy().xm())}else if(e.li(),i=e.copy(),i===null)return null;return i.adornedObject=t,i}get handleArchetype(){return this.Co}set handleArchetype(t){this.Co=t}get handle(){return this.fs}set handle(t){if(t!==null&&!(t.part instanceof Adornment))throw new Error("new handle is not in an Adornment: "+t);this.fs=t}get adornedObject(){return this.us}set adornedObject(t){if(t!==null&&t.part instanceof Adornment)throw new Error("new handle must not be in an Adornment: "+t);this.us=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return t.isReadOnly||!t.allowRotate||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){const t=this.diagram;if(this.adornedObject===null){if(this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle===null)return;this.adornedObject=this.handle.part.adornedObject}this.adornedObject!==null&&(t.isMouseCaptured=!0,t.delaysLayout=!0,this.startTransaction(this.name),this.eS=this.adornedObject.angle,this.Pm=this.computeRotationPoint(this.adornedObject),this.wc=this.adornedObject.part.location.copy(),this.isActive=!0)}computeRotationPoint(t){const i=t.part,e=i.locationObject;return i.rotationSpot.isSpot()?t.getDocumentPoint(i.rotationSpot):t===i||t===e?e.getDocumentPoint(i.locationSpot):t.getDocumentPoint(Spot.Center)}computeAdornmentLocation(t){let i=this.rotationPoint;i.isReal()||(i=this.computeRotationPoint(t));const e=t.getLocalPoint(i);let s=this.handleAngle;s<0?s+=360:s>=360&&(s-=360),s=Math.round(Math.round(s/45)*45);const n=this.handleDistance;return s===0?e.x=t.naturalBounds.width+n:s===45?(e.x=t.naturalBounds.width+n,e.y=t.naturalBounds.height+n):s===90?e.y=t.naturalBounds.height+n:s===135?(e.x=-n,e.y=t.naturalBounds.height+n):s===180?e.x=-n:s===225?(e.x=-n,e.y=-n):s===270?e.y=-n:s===315&&(e.x=t.naturalBounds.width+n,e.y=-n),t.getDocumentPoint(e)}doDeactivate(){const t=this.diagram;this.stopTransaction(),this.handle=null,this.us=null,this.Pm=new Point(NaN,NaN),t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){const t=this.diagram,i=super.stopTransaction();return i&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),i}doCancel(){const t=this.diagram;t.delaysLayout=!1,this.rotate(this.originalAngle),this.stopTool()}doMouseMove(){const t=this.diagram;if(this.isActive){const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i)}}doMouseUp(){const t=this.diagram;if(this.isActive){t.delaysLayout=!1;const i=this.computeRotate(t.lastInput.documentPoint);this.rotate(i),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.v("PartRotated",this.adornedObject,this.originalAngle)}this.stopTool()}rotate(t){const i=this.adornedObject;if(i===null)return;i.angle=t;const e=i.part;e.ensureBounds();const s=e.locationObject,n=e.rotateObject;if(s===n||s.isContainedBy(n)){const o=this.wc.copy();e.location=o.subtract(this.rotationPoint).rotate(t-this.originalAngle).add(this.rotationPoint)}this.diagram.maybeUpdate()}computeRotate(t){let i=this.rotationPoint.directionPoint(t)-this.handleAngle;const e=this.adornedObject.panel;e!==null&&(i-=e.getDocumentAngle()),i>=360?i-=360:i<0&&(i+=360);const s=Math.min(Math.abs(this.snapAngleMultiple),180),n=Math.min(Math.abs(this.snapAngleEpsilon),s/2);return!this.diagram.lastInput.shift&&s>0&&n>0&&(i%ss-n&&(i=(Math.floor(i/s)+1)*s)),i>=360?i-=360:i<0&&(i+=360),i}get snapAngleMultiple(){return this.tS}set snapAngleMultiple(t){Util.i(t,"number",RotatingTool,"snapAngleMultiple"),this.tS=t}get snapAngleEpsilon(){return this.iS}set snapAngleEpsilon(t){Util.i(t,"number",RotatingTool,"snapAngleEpsilon"),this.iS=t}get originalAngle(){return this.eS}get rotationPoint(){return this.Pm}set rotationPoint(t){this.Pm=t.copy()}get handleAngle(){return this.sS}set handleAngle(t){Util.i(t,"number",RotatingTool,"handleAngle"),this.sS=t}get handleDistance(){return this.nS}set handleDistance(t){Util.i(t,"number",RotatingTool,"handleDistance"),this.nS=t}}class ClickSelectingTool extends Tool{constructor(t){super(),this.name="ClickSelecting",t&&Object.assign(this,t)}canStart(){return!(!this.isEnabled||this.isBeyondDragSize())}doMouseUp(){this.isActive&&(this.standardMouseSelect(),this.standardMouseClick()||this.diagram.lastInput.isTouchEvent&&this.diagram.toolManager.doToolTip()),this.stopTool()}}class ActionTool extends Tool{xc;constructor(t){super(),this.name="Action",this.xc=null,t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram,i=t.lastInput,e=t.findObjectAt(i.documentPoint,s=>{for(;s.panel!==null;){if(s.isActionable)return s;s=s.panel}return s});return e!==null&&e.isActionable?(this.xc=e,t.fc=t.findObjectAt(i.documentPoint,null,null),!0):!1}doMouseDown(){if(!this.isActive)this.canStart()&&this.doActivate();else{const i=this.diagram.lastInput,e=this.xc;if(e===null)return;i.targetObject=e,e.actionDown!==null&&e.actionDown(i,e)}}doMouseMove(){if(this.isActive){const i=this.diagram.lastInput,e=this.xc;if(e===null)return;i.targetObject=e,e.actionMove!==null&&e.actionMove(i,e)}}doMouseUp(){if(this.isActive){const i=this.diagram.lastInput,e=this.xc;if(e===null)return;i.targetObject=e,e.actionUp!==null&&e.actionUp(i,e),this.standardMouseClick(s=>{for(;s.panel!==null;){if(s.isActionable&&s===e)return s;s=s.panel}return s},s=>s===e)}this.stopTool()}doCancel(){const i=this.diagram.lastInput,e=this.xc;e!==null&&(i.targetObject=e,e.actionCancel!==null&&e.actionCancel(i,e),this.stopTool())}doStop(){this.xc=null}}class ClickCreatingTool extends Tool{Ll;oS;yc;rS;constructor(t){super(),this.name="ClickCreating",this.Ll=null,this.oS=!0,this.yc=!1,this.rS=new Point(0,0),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled||this.archetypeNodeData===null)return!1;const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.lastInput.left||this.isBeyondDragSize())return!1;if(this.isDoubleClick){if(t.lastInput.clickCount===1&&(this.rS=t.lastInput.viewPoint.copy()),t.lastInput.clickCount!==2||this.isBeyondDragSize(this.rS))return!1}else if(t.lastInput.clickCount!==1)return!1;return!(t.currentTool!==this&&t.findPartAt(t.lastInput.documentPoint,!0)!==null)}doMouseUp(){const t=this.diagram;this.isActive&&this.insertPart(t.lastInput.documentPoint),this.stopTool()}insertPart(t){const i=this.diagram,e=this.archetypeNodeData;if(e===null)return null;let s=null;try{if(i.v("ChangingSelection",i.selection),this.startTransaction(this.name),e instanceof Part)e.Pe()&&(e.li(),s=e.copy(),s!==null&&i.add(s));else if(e!==null){const n=i.model.copyNodeData(e);Util.wt(n)&&(i.model.addNodeData(n),s=i.findPartForData(n))}if(s!==null){const n=Point.X(t.x,t.y);this.isGridSnapEnabled&&this.diagram.lS(s,t,n),s.location=n,i.allowSelect&&(i.clearSelection(!0),s.isSelected=!0),Point.s(n)}i.invalidateDocumentBounds(),this.transactionResult=this.name,i.v("PartCreated",s)}finally{this.stopTransaction(),i.v("ChangedSelection",i.selection)}return s}get archetypeNodeData(){return this.Ll}set archetypeNodeData(t){t!==null&&Util.i(t,"object",ClickCreatingTool,"archetypeNodeData"),this.Ll=t}get isDoubleClick(){return this.oS}set isDoubleClick(t){Util.i(t,"boolean",ClickCreatingTool,"isDoubleClick"),this.oS=t}get isGridSnapEnabled(){return this.yc}set isGridSnapEnabled(t){Util.i(t,"boolean",ClickCreatingTool,"isGridSnapEnabled"),this.yc=t}}class DragSelectingTool extends Tool{Vh;hS;Al;constructor(t){super(),this.name="DragSelecting",this.Vh=175,this.hS=!1,this.Al=new Part({layerName:"Tool",selectable:!1}).add(new Shape("Rectangle",{name:"SHAPE",fill:null,stroke:"magenta"}).theme("stroke","dragSelect")).li(),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(!t.allowSelect)return!1;const i=t.lastInput;return!(!i.left||t.currentTool!==this&&(!this.isBeyondDragSize()||i.timestamp-t.firstInput.timestamp{const e=i.diagram;e!==null&&e.Mi(root.document,"scroll",i.aS,!1),i.stopTool()},t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return!(!t.allowHorizontalScroll&&!t.allowVerticalScroll||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize())}doActivate(){const t=this.diagram;this.No?(t.lastInput.bubbles=!0,t.Vt(root.document,"scroll",this.aS,!1)):(t.currentCursor="move",t.isMouseCaptured=!0,this.Hw.a(t.position)),this.isActive=!0}doDeactivate(){const t=this.diagram;t.currentCursor="",t.isMouseCaptured=!1,this.isActive=!1}doCancel(){const t=this.diagram;t.position=this.Hw,t.isMouseCaptured=!1,this.stopTool()}doMouseMove(){this.GC()}doMouseUp(){this.GC(),this.stopTool()}GC(){const t=this.diagram;if(this.isActive&&t){if(this.No){t.lastInput.bubbles=!0;return}const i=t.position,e=t.firstInput.documentPoint,s=t.lastInput.documentPoint;let n=i.x+e.x-s.x,o=i.y+e.y-s.y;t.allowHorizontalScroll||(n=i.x),t.allowVerticalScroll||(o=i.y),t.position=this.YC.e(n,o)}}get bubbles(){return this.No}set bubbles(t){Util.i(t,"boolean",PanningTool,"bubbles"),this.No=t}get originalPosition(){return this.Hw}}class HTMLInfo{qw;Ww;cS;fS;constructor(t){this.qw=null,this.Ww=null,this.cS=null,this.fS=null,t&&Object.assign(this,t)}get mainElement(){return this.cS}set mainElement(t){this.cS=t}get show(){return this.qw}set show(t){this.qw!==t&&(t!==null&&Util.i(t,"function",HTMLInfo,"show"),this.qw=t)}get hide(){return this.Ww}set hide(t){this.Ww!==t&&(t!==null&&Util.i(t,"function",HTMLInfo,"hide"),this.Ww=t)}get valueFunction(){return this.fS}set valueFunction(t){this.fS=t}}class ContextMenuButtonInfo{hi;Sm;kc;constructor(t,i,e){this.hi=t,this.Sm=i,this.kc=e}}class ContextMenuTool extends Tool{uS;Jw;dS;gS;$w;Zw;Mm;constructor(t){super(),this.name="ContextMenu",this.uS=null,this.Jw=null,this.dS=null,this.gS=new Point,this.$w=null,this.Mm=!1;const i=this;this.Zw=()=>i.stopTool(),t&&Object.assign(this,t)}sF(){const t=new HTMLInfo;t.show=(r,l,h)=>h.showDefaultContextMenu(),t.hide=(r,l)=>l.hideDefaultContextMenu(),ContextMenuTool.bu=t;const i=this;this.Zw=()=>i.stopTool();const e=Util.en("div"),s=Util.en("div");e.style.cssText="top: 0px;z-index:10002;position: fixed;display: none;text-align: center;left: 25%;width: 50%;background-color: #F5F5F5;padding: 16px;border: 16px solid #444;border-radius: 10px;margin-top: 10px",s.style.cssText="z-index:10001;position: fixed;display: none;top: 0;left: 0;width: 100%;height: 100%;background-color: black;opacity: 0.8;";const n=Util.en("style");root.document.getElementsByTagName("head")[0].appendChild(n),n.sheet.insertRule(".goCXul { list-style: none; }",0),n.sheet.insertRule(".goCXli {font:700 1.5em Helvetica, Arial, sans-serif;position: relative;min-width: 60px; }",0),n.sheet.insertRule(".goCXa {color: #444;display: inline-block;padding: 4px;text-decoration: none;margin: 2px;border: 1px solid gray;border-radius: 10px; }",0);const o=this.diagram;o!==null&&(o.Vt(e,"contextmenu",ContextMenuTool.Yh,!1),o.Vt(e,"selectstart",ContextMenuTool.Yh,!1),o.Vt(s,"contextmenu",ContextMenuTool.Yh,!1)),e.className="goCXforeground",s.className="goCXbackground",root.document.body&&(root.document.body.appendChild(e),root.document.body.appendChild(s)),ContextMenuTool.Nm=e,ContextMenuTool.Cm=s,ContextMenuTool.mS=!0}static bu=null;static mS=!1;static Cm=null;static Nm=null;static Yh(t){return t.preventDefault(),!1}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;return this.isBeyondDragSize()||!t.lastInput.right||t.lastInput.clickCount>1?!1:!!(t.lastInput.isTouchEvent&&this.defaultTouchContextMenu!==null||this.findObjectWithContextMenu()!==null)}doStart(){const t=this.diagram;this.gS.set(t.firstInput.documentPoint)}doStop(){this.hideContextMenu(),this.currentObject=null,this.Mm=!1}findObjectWithContextMenu(t){t===void 0&&(t=null);const i=this.diagram,e=i.lastInput;let s=null;if(t instanceof Diagram||(t instanceof GraphObject?s=t:s=i.findObjectAt(e.documentPoint,null,n=>!n.layer.isTemporary)),s!==null){let n=s;for(;n!==null;){if(n.contextMenu!==null)return n;n=n.panel}if(i.lastInput.isTouchEvent&&this.defaultTouchContextMenu)return s.part}else if(i.contextMenu!==null)return i;return null}doActivate(){}doMouseDown(){if(super.doMouseDown(),this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doMouseDown(),t.doDeactivate())}this.diagram.toolManager.mouseDownTools.has(this)&&this.doContextClick()}doMouseUp(){if(this.isActive&&this.currentContextMenu instanceof Adornment){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doCancel(),t.doDeactivate())}this.doContextClick()}doContextClick(){const t=this.diagram;if(!this.isActive)this.canStart()&&(this.openMenu(!0),this.isActive||this.stopTool());else{const i=this.currentContextMenu;if(i===null)return;let e=null;i instanceof HTMLInfo||(e=t.findObjectAt(t.lastInput.documentPoint,null,null),e!==null&&e.isContainedBy(i)&&this.standardMouseClick(null,null)),this.maybeStopTool(e)}}maybeStopTool(t){this.stopTool(),this.canStart()&&(this.diagram.currentTool=this,this.doMouseUp())}openMenu(t,i){if(i===void 0&&(i=null),this.Mm)return;this.Mm=!0,t&&this.standardMouseSelect();const e=this.standardMouseClick();if(this.Mm=!1,!e){this.isActive=!0;const s=ContextMenuTool.bu;if(i===null&&(i=this.findObjectWithContextMenu()),i!==null){const n=i.contextMenu;n!==null?(this.currentObject=i instanceof GraphObject?i:null,this.showContextMenu(n,this.currentObject)):s!==null&&this.showContextMenu(s,this.currentObject)}else s!==null&&this.showContextMenu(s,null);this.currentContextMenu instanceof Adornment&&!this.currentContextMenu.visible&&this.stopTool()}}doMouseMove(){const t=this.diagram.toolManager.findTool("Action");t!==null&&t.doMouseMove(),this.isActive&&this.diagram.toolManager.doMouseMove()}showContextMenu(t,i){const e=this.diagram;if(t!==this.currentContextMenu&&this.hideContextMenu(),t instanceof Adornment){const s=t;s.layerName="Tool",s.selectable=!1,s.scale=1/e.scale,s.category=this.name,s.hasPlaceholder()&&(s.placeholder.scale=e.scale);const n=s.diagram;n!==null&&n!==e&&n.remove(s),e.add(s),i!==null?s.adornedObject=i:s.data=e.model,s.ensureBounds(),this.positionContextMenu(s,i)}else t instanceof HTMLInfo&&t.show(i,e,this);this.currentContextMenu=t}positionContextMenu(t,i){if(t.hasPlaceholder())return;const e=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=e.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.xr.bottom&&(n.y-=o.height+5/s.scale),n.ye.commandHandler.copySelection(),e=>e.commandHandler.canCopySelection())),i.add(new ContextMenuButtonInfo("Cut",e=>e.commandHandler.cutSelection(),e=>e.commandHandler.canCutSelection())),i.add(new ContextMenuButtonInfo("Delete",e=>e.commandHandler.deleteSelection(),e=>e.commandHandler.canDeleteSelection())),i.add(new ContextMenuButtonInfo("Paste",e=>e.commandHandler.pasteSelection(t.mouseDownPoint),e=>e.commandHandler.canPasteSelection(t.mouseDownPoint))),i.add(new ContextMenuButtonInfo("Select All",e=>e.commandHandler.selectAll(),e=>e.commandHandler.canSelectAll())),i.add(new ContextMenuButtonInfo("Undo",e=>e.commandHandler.undo(),e=>e.commandHandler.canUndo())),i.add(new ContextMenuButtonInfo("Redo",e=>e.commandHandler.redo(),e=>e.commandHandler.canRedo())),i.add(new ContextMenuButtonInfo("Scroll To Part",e=>e.commandHandler.scrollToPart(),e=>e.commandHandler.canScrollToPart())),i.add(new ContextMenuButtonInfo("Zoom To Fit",e=>e.commandHandler.zoomToFit(),e=>e.commandHandler.canZoomToFit())),i.add(new ContextMenuButtonInfo("Reset Zoom",e=>e.commandHandler.resetZoom(),e=>e.commandHandler.canResetZoom())),i.add(new ContextMenuButtonInfo("Group Selection",e=>e.commandHandler.groupSelection(),e=>e.commandHandler.canGroupSelection())),i.add(new ContextMenuButtonInfo("Ungroup Selection",e=>e.commandHandler.ungroupSelection(),e=>e.commandHandler.canUngroupSelection())),i.add(new ContextMenuButtonInfo("Edit Text",e=>e.commandHandler.editTextBlock(),e=>e.commandHandler.canEditTextBlock())),i}showDefaultContextMenu(){const t=this.diagram;this.$w===null&&(this.$w=this.nF()),ContextMenuTool.Nm.innerHTML="",ContextMenuTool.Cm.addEventListener("pointerdown",this.Zw,!1);const i=this,e=Util.en("ul");e.className="goCXul",ContextMenuTool.Nm.appendChild(e),e.innerHTML="";const s=this.$w.iterator;for(;s.next();){const n=s.value,o=n.Sm,r=n.kc;if(typeof o!="function"||typeof r=="function"&&!r(t))continue;const l=Util.en("li");l.className="goCXli";const h=Util.en("a");h.className="goCXa",h.href="#",h.Sm=n.Sm,h.addEventListener("pointerdown",function(a){return this.Sm(t),i.stopTool(),a.preventDefault(),!1},!1),h.textContent=n.hi,l.appendChild(h),e.appendChild(l)}ContextMenuTool.Nm.style.display="block",ContextMenuTool.Cm.style.display="block"}hideDefaultContextMenu(){if(this.currentContextMenu===null||this.currentContextMenu!==ContextMenuTool.bu)return;ContextMenuTool.Nm.style.display="none",ContextMenuTool.Cm.style.display="none";const t=this.diagram;t!==null&&t.Mi(ContextMenuTool.Cm,"pointerdown",this.Zw,!1),this.currentContextMenu=null}get currentContextMenu(){return this.uS}set currentContextMenu(t){this.uS=t,this.Jw=t instanceof Adornment?t.adornedPart:null}get defaultTouchContextMenu(){return ContextMenuTool.mS===!1&&ContextMenuTool.bu===null&&Diagram.isUsingDOM()&&this.sF(),ContextMenuTool.bu}set defaultTouchContextMenu(t){t===null&&(ContextMenuTool.mS=!0),ContextMenuTool.bu=t}get currentObject(){return this.dS}set currentObject(t){this.dS=t}get mouseDownPoint(){return this.gS}}var TextEditingAccept=(w=>(w[w.LostFocus=1]="LostFocus",w[w.MouseDown=2]="MouseDown",w[w.Tab=3]="Tab",w[w.Enter=4]="Enter",w))(TextEditingAccept||{}),TextEditingStarting=(w=>(w[w.SingleClick=1]="SingleClick",w[w.SingleClickSelected=2]="SingleClickSelected",w[w.DoubleClick=3]="DoubleClick",w))(TextEditingStarting||{}),TextEditingState=(w=>(w[w.None=1]="None",w[w.Active=2]="Active",w[w.Editing=3]="Editing",w[w.Validating=4]="Validating",w[w.Invalid=5]="Invalid",w[w.Validated=6]="Validated",w))(TextEditingState||{});class TextEditingTool extends Tool{Se;pS;yS;Tl;Yt;wS;xS;bS;Qw;_w;constructor(t){super(),this.name="TextEditing",this.Se=new TextBlock,this.pS=null,this.yS=2,this.Tl=null,this.Yt=1,this.wS=1,this.xS=!0,this.bS=null,this.Qw=new HTMLInfo,this._w=null,this.oF(this.Qw),t&&Object.assign(this,t)}static LostFocus=1;static MouseDown=2;static Tab=3;static Enter=4;static SingleClick=1;static SingleClickSelected=2;static DoubleClick=3;static StateNone=1;static StateActive=2;static StateEditing=3;static StateValidating=4;static StateInvalid=5;static StateValidated=6;oF(t){if(!Diagram.isUsingDOM())return;const i=Util.en("textarea");this._w=i;const e=this;i.addEventListener("input",function(s){if(e.textBlock===null)return;const n=e.measureTemporaryTextBlock(this.value),o=this.textScale;this.style.width=20+Math.max(e.textBlock.measuredBounds.width,n.measuredBounds.width)*o+"px",this.rows=Math.max(e.textBlock.lineCount,n.lineCount)},!1),i.addEventListener("keydown",function(s){if(s.isComposing||e.textBlock===null)return;const n=s.key;if(n==="Enter"){e.textBlock.isMultiline===!1&&s.preventDefault(),e.acceptText(4);return}else if(n==="Tab"){e.acceptText(3),s.preventDefault();return}else n==="Escape"&&(e.doCancel(),e.diagram!==null&&e.diagram.doFocus())},!1),i.addEventListener("focus",function(s){e.rF(s)},!1),i.addEventListener("blur",function(s){e.lF(s)},!1),t.valueFunction=()=>i.value,t.mainElement=i,t.show=(s,n,o)=>{if(!(s instanceof TextBlock&&o instanceof TextEditingTool))return;if(o.state===5){i.style.border="3px solid red",i.focus();return}const r=s.getDocumentPoint(Spot.Center),l=n.position,h=n.scale;let a=s.getDocumentScale()*h;a{s.div.removeChild(i)}}get textBlock(){return this.pS}set textBlock(t){this.pS=t}get currentTextEditor(){return this.bS}set currentTextEditor(t){this.bS=t}get defaultTextEditor(){return this.Qw}set defaultTextEditor(t){this.Qw=t}get starting(){return this.yS}set starting(t){this.yS=t}canStart(){if(!this.isEnabled)return!1;const t=this.diagram;if(t===null||t.isReadOnly||TextEditingTool.Pc&&TextEditingTool.Pc!==this&&(TextEditingTool.Pc.acceptText(2),TextEditingTool.Pc&&TextEditingTool.Pc!==this)||!t.lastInput.left||this.isBeyondDragSize())return!1;const i=t.lastInput.documentPoint,e=t.findObjectAt(i);if(e===null||!(e instanceof TextBlock)||!e.editable||!e.part.canEdit())return!1;const s=e.part;return!(s===null||this.starting===2&&!s.isSelected||this.starting===3&&t.lastInput.clickCount<2)}doStart(){TextEditingTool.Pc=this,this.textBlock!==null&&this.doActivate()}doActivate(){if(this.isActive)return;const t=this.diagram;if(t===null)return;let i=this.textBlock;if(i===null&&(i=t.findObjectAt(t.lastInput.documentPoint)),i===null||!(i instanceof TextBlock)||(this.textBlock=i,i.part===null))return;t.animationManager.stopAnimation(),this.isActive=!0,this.Yt=2;let s=this.defaultTextEditor;i.textEditor!==null&&(s=i.textEditor),this.Se=this.textBlock.copy();const n=new Rect(this.textBlock.getDocumentPoint(Spot.TopLeft),this.textBlock.getDocumentPoint(Spot.BottomRight));t.scrollToRect(n),s.show(i,t,this),this.currentTextEditor=s}doCancel(){this.stopTool()}doMouseUp(){this.canStart()&&this.doActivate()}doMouseDown(){this.isActive&&this.acceptText(2)}acceptText(t){switch(t){case 2:this.Yt===6?this.currentTextEditor instanceof HTMLElement&&this.currentTextEditor.focus():(this.Yt===2||this.Yt===5||this.Yt===3)&&(this.Yt=4,this.jC());break;case 1:case 4:case 3:if(t===4&&this.textBlock.isMultiline===!0)return;(this.Yt===2||this.Yt===5||this.Yt===3)&&(this.Yt=4,this.jC());break}}jC(){const t=this.textBlock,i=this.diagram,e=this.currentTextEditor;if(t!==null&&e!==null){const s=t.text;let n="";if(e.valueFunction!==null&&(n=e.valueFunction()),!this.isValidText(t,s,n)){this.Yt=5,this.doError(s,n);return}this.startTransaction(this.name),this.Yt=6,this.transactionResult=this.name,t.text=n,this.doSuccess(s,n),i!==null&&i.v("TextEdited",t,s),this.stopTransaction(),this.stopTool(),i!==null&&i.doFocus()}}doError(t,i){const e=this.textBlock;e.errorFunction!==null&&e.errorFunction(this,t,i);const s=this.currentTextEditor;s&&s.show(e,this.diagram,this)}doSuccess(t,i){const e=this.textBlock;e.textEdited!==null&&e.textEdited(e,t,i)}doDeactivate(){const t=this.diagram;t!==null&&(this.Yt=1,this.currentTextEditor!==null&&this.currentTextEditor.hide(t,this),this.textBlock=null,this.isActive=!1)}doStop(){TextEditingTool.Pc=null}rF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this._w;this.Yt===2&&(this.Yt=3),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}lF(t){if(this.currentTextEditor===null||this.state===1)return;const i=this._w;typeof i.focus=="function"&&i.focus(),typeof i.select=="function"&&this.selectsTextOnActivate&&(i.select(),i.setSelectionRange(0,9999))}isValidText(t,i,e){const s=this.textValidation;if(s!==null&&!s(t,i,e))return!1;const n=t.textValidation;return!(n!==null&&!n(t,i,e))}get textValidation(){return this.Tl}set textValidation(t){t!==null&&Util.i(t,"function",TextEditingTool,"textValidation"),this.Tl=t}get minimumEditorScale(){return this.wS}set minimumEditorScale(t){t!==null&&Util.i(t,"number",TextEditingTool,"minimumEditorScale"),this.wS=t}get selectsTextOnActivate(){return this.xS}set selectsTextOnActivate(t){t!==null&&Util.i(t,"boolean",TextEditingTool,"selectsTextOnActivate"),this.xS=t}get state(){return this.Yt}set state(t){this.Yt!==t&&(this.Yt=t)}measureTemporaryTextBlock(t){const i=this.Se;return i.text=t,i.ut(this.textBlock.Dl,1/0),i}static Pc=null}var AnimationStyle=(w=>(w[w.Default=1]="Default",w[w.AnimateLocations=2]="AnimateLocations",w[w.None=3]="None",w))(AnimationStyle||{});class AnimationManager{p;Ni;Oi;kr;Gn;Ao;kS;PS;Lm;wi;Sc;un;Am;Gh;tx;Tm;ix;Mc;wu;Dm;constructor(t){this.p=Diagram.mm(),this.Ni=!1,this.Lm=!1,this.wi=!1,this.Sc=!1,this.ix=!0,this.Mc=1,this.wu=!1,this.Oi=!0,this.kr=!0,this.Ao=600,this.kS=!1,this.PS=!1,this.Gn=new GSet,this.un=new Animation,this.Am=new Animation,this.un.ds=this,this.Gh=new GSet,this.tx=new GSet,this.Tm=new GSet,this.Dm=new GSet,t&&Object.assign(this,t)}To(t){this.p=t}rE(){return this.p}canStart(t){return!0}Fl(t){return!this.Oi||!this.canStart(t)?!1:(this.Gn.add(t),this.defaultAnimation.isAnimating&&this.stopAnimation(),this.p.Ci(),this.wi=!0,!0)}getBundleAnimation(){return this.Am}SS(){if(!this.Oi||(this.Am.ce.count>0&&this.Am.start(),!this.wi))return;const t=this.un,i=this.p,e=this.Gn.has("Model");if(e&&(this.Sc=!0,this.Mc===1?(t.isViewportUnconstrained=!0,t.ce.clear(),t.add(i,"position",i.position.copy().offset(0,-200),i.position),t.add(i,"opacity",0,1)):this.Mc===3&&t.ce.clear(),this.Mc===2&&i.ex.equals(i.at)?this.ix=!0:this.ix=!1,i.v("InitialAnimationStarting",this)),e&&!this.kr||t.ce.count===0){this.Gn.clear(),this.wi=!1,t.ce.clear(),t.sx(i),this.Sc=!1,i.C();return}this.Gn.clear(),i.Pr=!1;const s=t.ce.get(i);i.autoScale!==1&&s!==null&&(delete s.si.scale,delete s.gs.scale);const n=this;root.requestAnimationFrame(()=>{n.wi===!1||t.Ni||(i.getRenderingHint("temporaryPixelRatio")&&i.Uw(),i.MS(),n.wi=!1,t.start(),t.Ni&&(n.ku(),i.invalidateDocumentBounds(),t.HC(0),i.yr(!0),n.Pu(),i.v("AnimationStarting",n)))})}NS(){return this.Gn.has("Trigger")&&this.Gn.count===1}qC(t,i,e,s){this.isTicking||this.NS()||t instanceof Link&&(t.fromNode!==null||t.toNode!==null)||this.un.add(t,"position",i,e,s)}nx(t){return this.un.nx(t)}CS(t){return this.un.CS(t)}hF(t){const i=this.Gh,e=this;function s(){if(e.Tm.count>0&&(i.addAll(e.Tm),e.Tm.clear(),e.Ni=!0),e.Ni===!1||i.count===0)return;e.tx.addAll(i);const n=e.tx.iterator;for(;n.next();){const o=n.value;o.Ni!==!1&&(o.aF()?o.WC(!1):o.Nc=!0)}if(e.tx.clear(),e.Ni===!1){root.requestAnimationFrame(s);return}e.ku(),e.p.yr(),e.Pu(),root.requestAnimationFrame(s)}this.Ni?this.cF(t):(this.Ni=!0,i.add(t),root.requestAnimationFrame(()=>s()))}cF(t){this.Tm.add(t)}fF(){const t=this.Gh.iterator;for(;t.next();)t.value.Nc=!1}ku(){if(this.Lm)return;const t=this.p;this.kS=t.skipsUndoManager,this.PS=t.fe,t.skipsUndoManager=!0,t.fe=!0,this.Lm=!0}Pu(){const t=this.p;t.skipsUndoManager=this.kS,t.fe=this.PS,this.Lm=!1}stopAnimation(t){const i=this.un;if(this.wi===!0&&(this.wi=!1,this.Sc=!1,this.Gn.clear(),i.uF()&&this.p.requestUpdate()),!this.Ni){i.ce.clear(),i.sx(this.p);return}if(i.Su(!0),i.sx(null),t===!0){const e=this.Gh.toArray();for(let s=0;s{!i.isAnimating&&i.runCount===1/0&&i.start()})}get duration(){return this.Ao}set duration(t){Util.i(t,"number",AnimationManager,"duration"),t<1&&Util._(t,">= 1",AnimationManager,"duration"),this.Ao=t}get isAnimating(){return this.Ni}get isTicking(){return this.Lm}get isInitial(){return this.kr}set isInitial(t){Util.i(t,"boolean",AnimationManager,"isInitial"),this.kr=t}get defaultAnimation(){return this.un}get activeAnimations(){return this.Gh}get initialAnimationStyle(){return this.Mc}set initialAnimationStyle(t){this.Mc=t}static ox=new GMap;static defineAnimationEffect(t,i){AnimationManager.ox.set(t,i)}static TS(t,i,e,s,n){t===null&&(t=[0,0,0,0]),i===null&&(i=[0,0,0,0]);let o=t[0],r=t[1];const l=t[2],h=t[3];let a=i[0],c=i[1];const f=i[2],u=i[3];l===0||l===100?(o=a,r=c):(f===0||f===100)&&(a=o,c=r),Math.abs(a-o)>180&&(a>o?o+=360:a+=360);const d=n(e,o,a-o,s)%360,m=n(e,r,c-r,s),g=n(e,l,f-l,s),p=n(e,h,u-h,s);return"hsla("+d+", "+m+"%, "+g+"%, "+p+")"}static{const t=AnimationManager.ox,i=(e,s,n,o,r,l)=>{e.position=new Point(o(r,s.x,n.x-s.x,l),o(r,s.y,n.y-s.y,l))};t.set("position:diagram",i),t.set("position",i),t.set("position:part",(e,s,n,o,r,l)=>{r{r{r{const h=e.actualBounds,a=n.actualBounds,c=a.x+a.width/2-h.width/2,f=a.y+a.height/2-h.height/2;r{e.desiredSize=new Size(o(r,s.width,n.width-s.width,l),o(r,s.height,n.height-s.height,l))}),t.set("width",(e,s,n,o,r,l)=>{e.width=o(r,s,n-s,l)}),t.set("height",(e,s,n,o,r,l)=>{e.height=o(r,s,n-s,l)}),t.set("fill",(e,s,n,o,r,l)=>{e.fill=AnimationManager.TS(s,n,r,l,o)}),t.set("stroke",(e,s,n,o,r,l)=>{e.stroke=AnimationManager.TS(s,n,r,l,o)}),t.set("strokeWidth",(e,s,n,o,r,l)=>{e.strokeWidth=o(r,s,n-s,l)}),t.set("strokeDashOffset",(e,s,n,o,r,l)=>{e.strokeDashOffset=o(r,s,n-s,l)}),t.set("background",(e,s,n,o,r,l)=>{e.background=AnimationManager.TS(s,n,r,l,o)}),t.set("opacity",(e,s,n,o,r,l)=>{e.opacity=o(r,s,n-s,l)}),t.set("scale",(e,s,n,o,r,l)=>{e.scale=o(r,s,n-s,l)}),t.set("angle",(e,s,n,o,r,l)=>{e.angle=o(r,s,n-s,l)})}static Default=1;static AnimateLocations=2;static None=3}class Animation{rx;Fm;Ni;Mu;Ao;ms;QC;Ac;ce;lx;si;jn;Nu;Tc;hx;ax;Nc;DS;cx;ds;p;FS;RS;vS;constructor(t){this.p=null,this.ds=null,this.DS=null,this.cx=null,this.FS=!1,this.Ni=!1,this.Nc=!1,this.si=0,this.jn=0,this.rx=Animation.EaseInOutQuad,this.Fm=Animation.EaseInOutQuad,this.Nu=!1,this.Tc=!1,this.hx=1,this.ax=0,this.Ao=NaN,this.ms=NaN,this.RS=0,this.Mu=null,this.QC=Point.Po,this.ce=new GMap,this.lx=new GMap,this.Ac=new GSet,this.vS=1,t&&Object.assign(this,t)}suspend(){this.Nc=!0}advanceTo(t,i){i&&(this.Nc=!1),this.Nu&&t>=this.ms&&(this.Tc=!0,t=t-this.ms),this.RS=t,this.WC(!0),this.ds.ku(),this.p.yr(),this.ds.Pu(),this.p.redraw()}sx(t){if(this.lx.clear(),this.Tc=!1,this.ax=0,this.ms=NaN,this.Ac.count>0&&this.Ac.clear(),t!==null){const i=t.links;for(;i.next();)i.value.Sr=null}}uF(){return this.ce.count>0}start(){if(this.ce.count===0)return this;if(this.Ni)return this;let t=this.p;const i=this.ce.iterator;for(;i.next();){const s=i.key;t===null&&(s instanceof Diagram?t=s:s instanceof GraphObject&&(t=s.diagram))}if(t!==null)this.p=t,this.ds=t.animationManager;else return this;const e=this.ds;return e.isEnabled===!1?this:(this.ms=isNaN(this.Ao)?e.duration:this.Ao,this.Fm=this.rx,e.Sc&&e.Mc===1&&this===e.defaultAnimation&&(this.Fm=Animation.EaseOutExpo,this.ms=isNaN(this.Ao)?e.duration===600?900:e.duration:this.Ao),this.vS=t.scrollMode,this.isViewportUnconstrained&&(t.jh=2),e.ku(),this.Ac.each(s=>{s.data=null,t.add(s)}),e.Pu(),this.Ni=!0,this.si=+new Date,this.jn=this.si+this.ms,e.hF(this),this)}addTemporaryPart(t,i){return t.Pe()?(this.Ac.add(t),this.p=i,this):this}add(t,i,e,s,n){if(this.p===null&&(t instanceof Diagram?this.p=t:t instanceof GraphObject&&t.diagram!==null&&(this.p=t.diagram)),t instanceof Part){if(!t.isAnimated)return this;i==="position"&&(i="position:part")}return this.LS(t,i,e,s,n),this}LS(t,i,e,s,n){const o=this.ce;let r,l,h;if(t instanceof Diagram&&i==="position"&&(i="position:diagram"),(i==="fill"||i==="stroke"||i==="background")&&(Brush.Do(e),Brush.OS(),e=[Brush.Ii.n0,Brush.Ii.n1,Brush.Ii.n2,Brush.Ii.n3],Brush.Do(s),Brush.OS(),s=[Brush.Ii.n0,Brush.Ii.n1,Brush.Ii.n2,Brush.Ii.n3]),o.has(t))r=o.get(t),l=r.si,h=r.gs,l[i]===void 0&&(l[i]=this.Cu(e)),h[i]=this.Cu(s);else{if(i==="position"&&e.equalsApprox(s))return;l={},h={},l[i]=this.Cu(e),h[i]=this.Cu(s),r=new AnimationState(l,h,n),o.set(t,r)}const a=l[i];a instanceof Point&&!a.isReal()&&a.a(this.QC),n&&i.indexOf("position:")===0&&t instanceof Part?r.fx.location=this.Cu(t.location):n&&(r.fx[i]=this.Cu(e))}Cu(t){return t instanceof Point||t instanceof Size?t.copy():t}dF(t){const i=this.ce;if(i.has(t)){const e=i.get(t);e.ux=!0}}nx(t){if(!this.Ni)return!1;const i=this.ce.get(t);return i!==null&&i.ux}CS(t){if(!this.Ni)return!1;const i=this.ce.get(t);return i!==null&&!!(i.si.position||i.si["position:part"]||i.si.location)}aF(){if(this.Ac.count>0)return!0;const t=this.ce.iterator;for(;t.next();){const i=t.key;if(i instanceof GraphObject&&i.diagram!==null||i instanceof Diagram)return!0}return!1}WC(t){if(this.Nc&&!t)return;const i=this.ds;if(this.Ni===!1)return;const e=+new Date;let s=e>this.jn?this.ms:e-this.si;t&&(s=this.RS,sthis.jn&&(this.Nu&&!this.Tc?(this.si=+new Date,this.jn=this.si+this.ms,this.Tc=!0):this.Su(!1))}HC(t){const i=this.ms,e=this.ce.iterator,s=this.Tc;for(;e.next();){const n=e.key;if(n instanceof GraphObject&&n.diagram===null)continue;const o=e.value,r=s?o.gs:o.si,l=s?o.si:o.gs,h=AnimationManager.ox;for(const a in l)a==="position"&&(l["position:placeholder"]||l["position:nodeCollapse"])||h.get(a)!==null&&h.get(a)(n,r[a],l[a],this.Fm,t,i,this)}}stop(){return this.Ni?(this.Su(!0),this):this}Su(t){if(this.cx!==null&&this.cx.gF(this.DS),!this.Ni)return;const i=this.p,e=this.ds;e.Sc=!1,this.Ni=!1,this.Nc=!1,e.ku();const s=this.ce,n=this.Ac.iterator;for(;n.next();)i.remove(n.value);const o=this.Nu,r=s.iterator,l=AnimationManager.ox;for(;r.next();){const a=r.key,c=r.value,f=o?c.gs:c.si,u=o?c.si:c.gs,d=c.fx;for(const m in u)if(l.get(m)!==null){let g=m;c.gx&&(g==="position:nodeCollapse"||g==="position:placeholder")&&(g="position"),l.get(g)(a,f[m],d[m]!==void 0?d[m]:c.gx?f[m]:u[m],this.Fm,this.ms,this.ms,this)}c.gx&&d.location!==void 0&&a instanceof Part&&(a.location=d.location),c.ux&&a instanceof Part&&a.Ei(!1)}this.ax++;const h=!t&&this.hx>this.ax;if(!h&&(this===e.Am||this===e.defaultAnimation)&&this.ce.clear(),i.mx.clear(),i.yP(!1),i.invalidateDocumentBounds(),i.C(),i.yr(!0),e.defaultAnimation===this){const a=e.Dm.iterator;for(;a.next();)a.value.mF();e.Dm.clear()}if(i.yr(!0),this.isViewportUnconstrained&&(i.scrollMode=this.vS),e.Pu(),h){this.Tc=!1,this.start();return}this.sx(null),i._C(),e.Su(this),this.Mu&&this.Mu(this),i.requestUpdate()}Cc(t,i){const e=i.actualBounds;let s=null;if(i instanceof Group&&(s=i.placeholder),s!==null&&s.visible){const n=s.getDocumentPoint(Spot.TopLeft),o=s.padding;n.x+=o.left,n.y+=o.top,this.add(t,"position",n,t.position,!1)}else this.add(t,"position",new Point(e.x+e.width/2,e.y+e.height/2),t.position,!1);this.add(t,"scale",.01,t.scale,!1),t instanceof Group&&this.pF(t,i)}pF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Cc(s,i)}}Lc(t,i){if(!t.isVisible())return;let e=null;if(i instanceof Group&&(e=i.placeholder),e!==null&&e.visible){const s=e.getDocumentPoint(Spot.TopLeft),n=e.padding;s.x+=n.left,s.y+=n.top,this.add(t,"position:placeholder",t.position,s,!0)}else this.add(t,"position:nodeCollapse",t.position,i,!0);this.add(t,"scale",t.scale,.01,!0),this.dF(t),t instanceof Group&&this.yF(t,i)}yF(t,i){const e=t.memberParts;for(;e.next();){const s=e.value;s instanceof Node&&this.Lc(s,i)}}get duration(){return this.Ao}set duration(t){Util.i(t,"number",Animation,"duration"),t<1&&Util._(t,">= 1",Animation,"duration"),this.Ao=t}get reversible(){return this.Nu}set reversible(t){this.Nu=t}get runCount(){return this.hx}set runCount(t){t>0?this.hx=t:Util.o("Animation.runCount value must be a positive integer.")}get finished(){return this.Mu}set finished(t){this.Mu!==t&&(t!==null&&Util.i(t,"function",Animation,"finished"),this.Mu=t)}get easing(){return this.rx}set easing(t){this.rx=t}get isViewportUnconstrained(){return this.FS}set isViewportUnconstrained(t){this.FS=t}get isAnimating(){return this.Ni}getTemporaryState(t){let i=this.lx.get(t);return i===null&&(i={},this.lx.set(t,i)),i}static EaseLinear=(t,i,e,s)=>e*t/s+i;static EaseInOutQuad=(t,i,e,s)=>(t/=s/2,t<1?e/2*t*t+i:-e/2*(--t*(t-2)-1)+i);static EaseInQuad=(t,i,e,s)=>e*(t/=s)*t+i;static EaseOutQuad=(t,i,e,s)=>-e*(t/=s)*(t-2)+i;static EaseInExpo=(t,i,e,s)=>t===0?i:e*Math.pow(2,10*(t/s-1))+i;static EaseOutExpo=(t,i,e,s)=>t===s?i+e:e*(-Math.pow(2,-10*t/s)+1)+i}class AnimationState{si;gs;fx;gx;ux;constructor(t,i,e){this.si=t,this.gs=i,this.fx={},this.gx=e,this.ux=!1}}var TriggerStart=(w=>(w[w.Default=1]="Default",w[w.Immediate=2]="Immediate",w[w.Bundled=3]="Bundled",w))(TriggerStart||{});class AnimationTrigger{ke;an;Lu;Dc;constructor(t,i,e){this.ke=null,this.an=t,this.Lu=e||1,this.Dc=null,i!==void 0&&(this.Dc=i,e===void 0&&(this.Lu=2))}copy(){const t=new AnimationTrigger(this.an);t.Lu=this.Lu;const i=this.Dc;if(i!==null){const e={};i.duration!==void 0&&(e.duration=i.duration),i.finished!==void 0&&(e.finished=i.finished),i.easing!==void 0&&(e.easing=i.easing),t.Dc=e}return t}get propertyName(){return this.an}set propertyName(t){this.an=t}get animationSettings(){return this.Dc}set animationSettings(t){this.Dc=t}wF(t){const i=this.Dc;i!==null&&(i.duration&&(t.duration=i.duration),i.finished&&(t.finished=i.finished),i.easing&&(t.easing=i.easing))}get startCondition(){return this.Lu}set startCondition(t){this.Lu=t}static Default=1;static Immediate=2;static Bundled=3}class Layer{p;Mt;Wt;Mr;Rl;vl;Ol;Il;El;Bl;Ul;Vl;zl;Xl;Kl;Yl;kc;Gl;px;Rm;Au;At;constructor(t){GSet.Yi(this),this.p=null,this.At=new List,this.Mt="",this.Wt=1,this.Mr=!1,this.Rl=!0,this.vl=!0,this.Ol=!0,this.Il=!0,this.El=!0,this.Bl=!0,this.Ul=!0,this.Vl=!0,this.zl=!0,this.Xl=!0,this.Kl=!0,this.Yl=!0,this.kc=!0,this.Gl=!0,this.px=!0,this.Rm=!1,this.Au=[],t&&Object.assign(this,t)}xF(){const t=this.At;for(let i=0;i0&&(h+=e+" Parts "),s>0&&(h+=s+" Nodes "),n>0&&(h+=n+" Groups "),o>0&&(h+=o+" Links "),r>0&&(h+=r+" Adornments "),t>1){const a=this.At.iterator;for(;a.next();){const c=a.value;h+=` + `+c.toString();const f=c.data;f!==null&&GSet.as(f)&&(h+=" #"+GSet.as(f)),c instanceof Node?h+=" "+Util.toString(f):c instanceof Link&&(h+=" "+Util.toString(c.fromNode)+" "+Util.toString(c.toNode))}}return i+" "+this.At.count+": "+h}findObjectAt(t,i,e){if(i===void 0&&(i=null),e===void 0&&(e=null),this.Gl===!1)return null;let s=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(s=!0);const n=Point.l(),o=this.At.r,r=o.length;for(let l=r;l--;){const h=o[l];if(s===!0&&h.Nl()===!1||!h.isVisible())continue;n.a(t),n.Ie(h.Es);let a=h.tL(n,i,e);if(a!==null&&(i!==null&&(a=i(a)),a!==null&&(e===null||e(a))))return Point.s(n),a}return Point.s(n),null}findObjectsAt(t,i,e,s){if(i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Gl===!1)return s;let n=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(n=!0);const o=Point.l(),r=this.At.r,l=r.length;for(let h=l;h--;){const a=r[h];if(n===!0&&a.Nl()===!1||!a.isVisible())continue;o.a(t),o.Ie(a.Es);let c=a;a.iL(o,i,e,s)&&(i!==null&&(c=i(c)),c!==null&&(e===null||e(c))&&s.add(c))}return Point.s(o),s}findObjectsIn(t,i,e,s,n){if(i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Gl===!1)return n;let o=!1;this.diagram!==null&&this.diagram.viewportBounds.containsRect(t)&&(o=!0);const r=this.At.r,l=r.length;for(let h=l;h--;){const a=r[h];if(o===!0&&a.Nl()===!1||!a.isVisible())continue;let c=a;a.vm(t,i,e,s,n)&&(i!==null&&(c=i(c)),c!==null&&(e===null||e(c))&&n.add(c))}return n}NP(t,i,e,s,n,o,r){if(this.Gl===!1)return n;const l=this.At.r,h=l.length;for(let a=h;a--;){const c=l[a];if(r===!0&&c.Nl()===!1||!o(c)||!c.isVisible())continue;let f=c;c.vm(t,i,e,s,n)&&(i!==null&&(f=i(f)),f!==null&&(e===null||e(f))&&n.add(f))}return n}findObjectsNear(t,i,e,s,n,o){if(e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Gl===!1)return o;let r=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(r=!0);const l=Point.l(),h=Point.l(),a=this.At.r,c=a.length;for(let f=c;f--;){const u=a[f];if(r===!0&&u.Nl()===!1||!u.isVisible())continue;l.a(t),l.Ie(u.Es),h.e(t.x+i,t.y),h.Ie(u.Es);let d=u;u.eL(l,h,e,s,n,o)&&(e!==null&&(d=e(d)),d!==null&&(s===null||s(d))&&o.add(d))}return Point.s(l),Point.s(h),o}ES(){return this.At.r}Bs(t,i){if(!this.visible)return;const e=this.At.r,s=e.length;if(s===0)return;const n=Util.nt(),o=Util.nt();for(let r=0;r0&&o.push(l))}for(let r=0;re.Im||a.height*n>e.Im?i.Gi(t,e):this.SF(t,i),c&&(t.restore(),t.clearContextCache(!0))}SF(t,i){const e=i.actualBounds,s=i.naturalBounds;if(e.width===0||e.height===0||isNaN(e.x)||isNaN(e.y)||!i.isVisible())return;const n=i.D;if(i.background===null){i.dn(t,"rgba(0,0,0,0.3)",!0,!1,s,e),t.fillRect(e.x,e.y,e.width,e.height);return}if(t.transform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),i.dn(t,i.background,!0,!1,s,e),t.fillRect(0,0,s.width/2,s.height/2),!n.Ok()){const o=1/(n.m11*n.m22-n.m12*n.m21);t.transform(n.m22*o,-n.m12*o,-n.m21*o,n.m11*o,o*(n.m21*n.dy-n.m22*n.dx),o*(n.m12*n.dx-n.m11*n.dy))}}PF(t,i,e,s){const n=2/s,o=4/s;for(let r=0;r=s.count)t=s.count;else if(s.elt(t)===i)return-1;s.insertAt(t,i),i.Em(e);const n=this.diagram;return n!==null&&(e?n.C():n.qh(i)),this.yx(t,i),t}te(t,i,e){if(!e&&i.layer!==this&&i.layer!==null)return i.layer.te(t,i,e);const s=this.At;if(t<0||t>=s.length){if(t=s.indexOf(i),t<0)return-1}else if(s.elt(t)!==i&&(t=s.indexOf(i),t<0))return-1;i.Bm(e),s.removeAt(t);const n=this.diagram;return n!==null&&(e?n.C():n.te(i)),i.IS(null),t}yx(t,i){t=this.MF(t,i),i instanceof Group&&this.NF(t,i),i.svg!==null&&i.svg.remove()}MF(t,i){const e=i.zOrder;if(isNaN(e))return t;const s=this.At,n=s.count;if(n<=1)return t;if(t<0&&(t=s.indexOf(i)),t<0)return-1;let o=t-1,r=NaN;for(;o>=0&&(r=s.elt(o).zOrder,!!isNaN(r));)o--;let l=t+1,h=NaN;for(;le)for(;;){if(o===-1||r<=e)return o++,o===t?t:(s.removeAt(t),s.insertAt(o,i),o);for(r=NaN;--o>=0&&(r=s.elt(o).zOrder,!!isNaN(r)););}else if(!isNaN(h)&&h=e)return l--,l===t?t:(s.removeAt(t),s.insertAt(l,i),l);for(h=NaN;++l=0)||e<0&&r.containingGroup===i&&(e=o,t>=0))break}if(!(e<0)&&e1)&&Util._(t,"0 <= value <= 1",Layer,"opacity"),this.Wt=t;const e=this.diagram;e!==null&&e.C(),this.t("opacity",i,t)}}get isViewportAligned(){return this.Rm}set isViewportAligned(t){const i=this.Rm;i!==t&&(this.Rm=t,this.diagram&&(this.nL(),this.diagram.C()),this.t("isViewportAligned",i,t),t&&(this.isInDocumentBounds=!1))}nL(){if(!this.Rm)return;const t=this.diagram,i=this.At.r,e=i.length,s=t.kt,n=t.Pt;for(let o=0;o(w[w.None=1]="None",w[w.Uniform=2]="Uniform",w[w.UniformToFill=3]="UniformToFill",w))(AutoScale||{}),CycleMode=(w=>(w[w.All=1]="All",w[w.NotDirected=2]="NotDirected",w[w.NotDirectedFast=3]="NotDirectedFast",w[w.NotUndirected=4]="NotUndirected",w[w.DestinationTree=5]="DestinationTree",w[w.SourceTree=6]="SourceTree",w))(CycleMode||{}),ScrollMode=(w=>(w[w.Document=1]="Document",w[w.Infinite=2]="Infinite",w))(ScrollMode||{}),CollapsePolicy=(w=>(w[w.TreeParent=1]="TreeParent",w[w.AllParents=2]="AllParents",w[w.AnyParents=3]="AnyParents",w))(CollapsePolicy||{});class Diagram{ds;di;VS;wx;Nr;Fu;xx;bx;kx;Px;Sx;Mx;Fc;jh;Nx;Cx;Lx;jl;Rc;Cr;Um;Ax;Tx;Ru;Hn;Lr;Wh;Fo;Vm;vc;zm;Oc;vu;Ar;qn;zS;XS;Dx;Fx;KS;Rx;YS;GS;jS;vx;Xm;Tr;Dr;Fr;Rr;vr;Or;Ox;Ir;Ix;Er;Br;Ur;Vr;Ex;HS;Ro;qS;Bx;Ux;WS;Si;JS;$S;ZS;vs;vo;Oi;Vx;Rl;vl;zx;Xx;Ol;Il;El;Kx;Bl;Ul;Vl;zl;Xl;Kl;Yl;Yx;Gx;QS;Ou;Iu;jx;Hx;qx;Wx;Km;Jx;$x;Zx;$t;_S;Qx;tM;Eu;gn;Wn;ie;Jn;oL;Hl;iM;eM;Ym;_x;Bu;Gm;tb;zr;ql;Jh;sM;nM;jm;ib;eb;ts;Hm;qm;Uu;Wl;Ic;Wm;Xr;$h;oM;Jm;Ht;D;Ue;Pr;Bi;ps;rM;Jl;Kr;bl;Yr;Zh;Ec;lM;Vu;Qh;zu;Gt;$l;at;et;Xu;kt;Pt;dt;Bc;Bw;sb;_h;Uc;nb;ob;rb;AF;TF;Ui;Pl;Im;$m;hM;aM;rL;Zm;DF;FF;RF;lb;vF;OF;IF;ta;lL;Zl;ia;ea;sa;na;yu;Yh;Zt;Tt;Vc;Wk;Jk;fc;Wt;static hb=null;static hL=new GMap;static cM;static fM=null;pu;ab;cb;fb;ub;db;Qm;uM;_m;t0;i0;ex;dM;gb;zc;constructor(t,i){if(Diagram.uw||(Diagram.Ik(),Diagram.uw=!0),GSet.Yi(this),Diagram.aL(this),this.Ht=!0,this.Tt=null,this.kt=0,this.Pt=0,this.dt=null,Diagram.isUsingDOM()){const s=this,n=()=>{s.Mi(root.document,"DOMContentLoaded",n,!1),s.setRTL()};root.document.body!==null?this.setRTL():s.Vt(root.document,"DOMContentLoaded",n,!1)}this.Bc=null,Diagram.gM("Model",PartManager);const e=this;return this.JS=s=>e.partManager.doModelDataChanged(s),this.$S=s=>e.partManager.doModelChanged(s),this.nb=null,this.ob=null,this.cL(),this.model=Model.initDiagramModel(),this.gb=null,this.themeManager=new ThemeManager,this.Ro=!0,this.fL(),this.layout=new Layout,this.Ro=!1,this.DF=null,this.FF=null,this.RF=null,this.lb=null,this.vF=null,this.OF=null,this.IF=null,this.ta=null,this.lL=null,this.Zl=null,this.ia=null,this.ea=null,this.sa=null,this.na=null,this.yu=()=>{},this.Yh=null,this.Uu=!1,this.Vc=new DiagramHelper(this),t!==void 0&&(typeof t=="string"||root.Element&&t instanceof Element?this.mM(t):i=t),i&&this.setProperties(i),this.Ht=!1,this.requestUpdate(),this}HD(){return this.dt!==null}get renderer(){return this.Ic}set renderer(t){if(this instanceof Overview)return;t===""&&(t="default");const i=t.toLowerCase(),e=this.Ic;if(i===e)return;this.Ic=i;let s=null;i==="default"||i==="canvas"?(s=this.Wl.get("svg"),s!==null&&s.Ft.remove(),this.dt&&(this.Zt=this.dt.ai),this.Zt.clearContextCache(!0)):i==="svg"?(this.Wl.has("svg")?s=this.Wl.get("svg"):(s=new SVGSurface(this,root.document),this.addRenderer("svg",s)),this.div!==null&&this.div.appendChild(s.Ft),this.Zt=s.ai,this.dt&&(this.dt.ai.setTransform(this.Ui,0,0,this.Ui,0,0),this.dt.ai.clearRect(0,0,this.kt,this.Pt))):i==="debug"&&(this.Wl.has("SVG")||(s=new SVGSurface(this,root.document),this.addRenderer("SVG",s),s.Ft.style.backgroundColor="whitesmoke",this.div!==null&&this.div.after(s.Ft))),this.Ht||this.redraw()}cL(){this.zc=new List,this.setupRouters(),this.ds=new AnimationManager,this.ds.To(this),this.di=17,this.VS=!1,this.Xu=!1,this.wx="default",this.Gt=new List,this.Wl=new GMap,this.Ic="default",this.resetRenderingHints(),this.EF(),this.Wt=1,this.at=new Point(NaN,NaN).g(),this.ex=new Point(NaN,NaN),this.et=1,this.Jm=1,this.xx=new Point(NaN,NaN).g(),this.bx=NaN,this.kx=1e-4,this.Px=100,this.D=new Transform,this.Sx=new Point(NaN,NaN).g(),this.Mx=new Rect(NaN,NaN,NaN,NaN).g(),this.Fc=new Margin(0,0,0,0).g(),this.jh=1,this.Nx=!1,this.Cx=null,this.Lx=null,this.jl=1,this.Rc=Spot.Default,this.Cr=1,this.Um=Spot.Default,this.Ax=Spot.None,this.Tx=Spot.None,this.Ue=!0,this.Ru=!1,this.Hn=new Set,this.Lr=new GSet,this.Wh=new GSet,this.Fo=!1,this.$l=new GMap,this.Vu=!0,this.Vm=250,this.vc=-1,this.zm=new Margin(16,16,16,16).g(),this.Pr=!1,this.Oc=!1,this.vu=!0,this.Wm=new InputEvent,this.Wm.diagram=this,this.Xr=new InputEvent,this.Xr.diagram=this,this.$h=new InputEvent,this.$h.diagram=this,this.Ar=null,this.qn=null,this.Bw=!1,this.BF(),this.Yr=new GSet,this.Dx=!0,this.Fx=1,this.KS=!1,this.Rx=1,this.vx="auto",this.Xm="auto",this.Tr=null,this.Dr=null,this.Fr=null,this.Rr=null,this.vr=null,this.Or=null,this.Ox=null,this.Ir=null,this.Ix=!1,this.Er=null,this.Br=null,this.Ur=null,this.Vr=null,this.Ex=!1,this.sb={},this._h=[null,null],this.Ro=!1,this.qS=!1,this.Bx=!1,this.Ux=!1,this.WS=!0,this.ps=!1,this.Qh=!1,this.ZS=!0,this.vs=-2,this.Jl=new GMap,this.zu=new List,this.vo=!1,this.Oi=!0,this.Vx=!0,this.Rl=!0,this.vl=!0,this.zx=!1,this.Xx=!0,this.Ol=!0,this.Il=!0,this.El=!0,this.Kx=!0,this.Bl=!0,this.Ul=!0,this.Vl=!0,this.zl=!0,this.Xl=!0,this.Kl=!0,this.Yl=!0,this.Yx=!0,this.Gx=!0,this.QS=!1,this.Uc=!1,this.Ou=!0,this.Iu=!0,this.jx=!0,this.Hx=!0,this.qx=16,this.Wx=16,this.Km=!1,this.Jx=!1,this.$x=0,this.Zx=0,this.$t=new Margin(5).g(),this._S=new GSet().g(),this.Qx=999999999,this.tM=new GSet().g(),this.Zh=!0,this.Eu=!0,this.Ec=!0,this.gn=!1,this.Wn=!1,this.Kr=!0,this.bl=!1,this.Jn=!1,this.oL=new GSet,this.lM=new GSet,this.Hl=null,this.iM=new Size(8,8),this.eM=999,this.Ym=!1,this.Wk=1,this.Jk=0,this.Bi={scale:1,position:new Point,bounds:new Rect,canvasSize:new Size,newCanvasSize:new Size,isScroll:!1},this.Bi.canvasSize=this.Bi.canvasSize,this.Bi.newCanvasSize=this.Bi.newCanvasSize,this.Bi.isScroll=!1,this._x=new Rect(NaN,NaN,NaN,NaN).g(),this.Bu=new Size(NaN,NaN).g(),this.Gm=new Rect(NaN,NaN,NaN,NaN).g(),this.tb=!1,this.UF(),this.ts=null,this.Hm=!1,this.fc=null,this.partManager=new PartManager,this.toolManager=new ToolManager,this.toolManager.initializeStandardTools(),this.defaultTool=this.toolManager,this.currentTool=this.defaultTool,this.cb=null,this.fb=new DraggingOptions,this.ub=null,this.db=null,this.ab=!1,this.pu=!1,this.commandHandler=new CommandHandler,this.t0=null,this.i0=Point.Ak,this.dM=!1,this.Ui=1,this.Pl=null,this.Im=1,this.Qm=0,this.uM=[0,0,0,0,0],this._m=0,this.$m=1,this.hM=0,this.aM=new Point,this.rL=500,this.qm=new Point,this.Zm=!1}static uL=root.document!==void 0;static isUsingDOM(){return Diagram.uL}static useDOM(t){Diagram.uL=t?root.document!==void 0:!1}static Ve=new WeakMap;clear(){this.animationManager.stopAnimation(),this.model.clear(),Diagram.dL(),this.gL(!1),this.zu.clear(),this.mL(),this.Hl=null,this.invalidateDocumentBounds(),this.ensureBounds(),this.C()}gL(t){this.animationManager.stopAnimation(!0),this._S=new GSet().g(),this.tM=new GSet().g();const i=this.skipsUndoManager,e=this.Si!==null&&this.Si!==void 0;e&&(this.skipsUndoManager=!0);let s=null;this.ts!==null&&(s=this.ts.part,s!==null&&this.remove(s));const n=[],o=this.Gt.length;if(t){for(let r=0;rt?new Margin(t/2):1.5)),this.ib=this.jm,this.eb=new Adornment(Panel.Link).add(new Shape({isPanelMain:!0,fill:null,stroke:"dodgerblue",strokeWidth:3}).theme("stroke","selection").theme("strokeWidth","selection"))}setRTL(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);const e=Util.en("div");e.dir="rtl",e.style.cssText="font-size: 14px; width: 1px; height: 1px; position: absolute; top: -1000px; overflow: scroll;",e.textContent="A",i.appendChild(e);let s="reverse";e.scrollLeft>0?s="default":(e.scrollLeft=1,e.scrollLeft===0&&(s="negative")),i.removeChild(e),this.wx=s}setScrollWidth(t){let i=t===void 0?this.div:t;i===null&&(i=root.document.body);let e=0;if(Diagram.isUsingDOM()){let s=Diagram.fM,n=Diagram.cM;s===null&&(Diagram.fM=Util.en("p"),s=Diagram.fM,s.style.width="100%",s.style.height="200px",s.style.boxSizing="content-box",Diagram.cM=Util.en("div"),n=Diagram.cM,n.style.position="absolute",n.style.visibility="hidden",n.style.width="200px",n.style.height="150px",n.style.boxSizing="content-box",n.appendChild(s)),n.style.overflow="hidden",i.appendChild(n);const o=s.offsetWidth;n.style.overflow="scroll";let r=s.offsetWidth;o===r&&(r=n.clientWidth),i.removeChild(n),e=o-r,e===0&&!Util.rr&&(e=11)}this.di=e,this.VS=!0}ri(t){t in AutoScale?this.autoScale=t:Util.lr(this,t)}toString(t){t===void 0&&(t=0);let i="";this.div&&this.div.id&&(i=this.div.id);let e='Diagram "'+i+'"';if(t<=0)return e;const s=this.Gt.iterator;for(;s.next();){const n=s.value;e+=` + `+n.toString(t-1)}return e}static aL(t){Diagram.hb=t}static mm(){return Diagram.hb}static fromDiv(t){let i=t;if(typeof t=="string"&&(i=root.document.getElementById(t)),i instanceof HTMLDivElement){const e=Diagram.Ve.get(i);if(e)return e}return null}get div(){return this.Tt}set div(t){if(this.Tt!==t){const i=this.Tt;if(i!==null){if(Diagram.Ve.delete(i),i.goDiagram=void 0,i.go=void 0,i.innerHTML="",this.dt!==null){const s=this.dt.Ft;this.Mi(s,"pointermove",this.ia,!1),this.Mi(s,"pointerdown",this.Zl,!1),this.Mi(s,"pointerup",this.ea,!1),this.Mi(s,"pointerout",this.sa,!1),this.Mi(s,"pointercancel",this.na,!1),this.dt.dispose()}this.Bc&&(this.Bc.disconnect(),this.Bc=null);const e=this.toolManager;e!==null&&(e.mouseDownTools.each(s=>s.cancelWaitAfter()),e.mouseMoveTools.each(s=>s.cancelWaitAfter()),e.mouseUpTools.each(s=>s.cancelWaitAfter())),e.cancelWaitAfter(),this.currentTool.doCancel(),this.dt=null,this.Mi(root,"resize",this.lb,!1),this.Mi(root,"wheel",this.ta,!0),Diagram.mm()===this&&Diagram.aL(null)}else this.Zl===null&&(this.Jn=!1);if(this.Tt=null,t!==null){const e=Diagram.Ve.get(t);e&&(e.div=null),this.mM(t),this.yu(),this.themeManager&&this.themeManager.VF()}else this.themeManager&&this.themeManager.zF()}}setupRouters(){this.zc.push(new AvoidsNodesRouter)}mM(t){const i=this;if(!Diagram.isUsingDOM())return;t==null&&Util.o("Diagram setup requires an argument DIV."),i.Tt!==null&&Util.o("Diagram has already completed setup."),typeof t=="string"?i.Tt=root.document.getElementById(t):t instanceof HTMLDivElement?i.Tt=t:Util.o("No DIV or DIV id supplied: "+t),i.Tt===null&&Util.o("Invalid DIV id; could not get element with id: "+t);const e=Diagram.Ve.get(i.Tt);if(e&&e!==this&&Util.o("Invalid div id; div already has a Diagram associated with it."),!i.Bc&&root.ResizeObserver){const c=root.ResizeObserver,f=Util.Nk(()=>i.requestUpdate(),250,!1);i.Bc=new c(()=>f()),i.Bc.observe(i.Tt)}root.getComputedStyle(i.Tt,null).position==="static"&&(i.Tt.style.position="relative");let s=5;const n="rgba(2"+s+"5, 255, 255, 0)";s--,i.Tt.style["-webkit-tap-highlight-color"]=n,i.Tt.innerHTML="",Diagram.Ve.set(i.Tt,i),i.Tt.goDiagram=i,i.Tt.go=root.go;const o=new CanvasSurface(i);o.style!==void 0&&(o.style.position="absolute",o.style.top="0px",o.style.left="0px",root.getComputedStyle(i.Tt,null).getPropertyValue("direction")==="rtl"&&(i.Xu=!0),o.style.zIndex="2",o.style.userSelect="none",o.style.MozUserSelect="none",o.style.touchAction="none",o.style.letterSpacing="normal !important",o.style.wordSpacing="normal !important",o.style.lang="unknown"),i.dt=o,i.Zt=o.ai;const r=i.Zt;i.Ui=i.computePixelRatio(),i.viewSize.isReal()||(i.kt=i.Tt.clientWidth||1,i.Pt=i.Tt.clientHeight||1),i.pL(i.kt,i.Pt);const l=i;i.Tt.insertBefore(o.Ft,i.Tt.firstChild);const h=new CanvasSurface(null);if(h.width=1,h.height=1,i.AF=h,i.TF=h.ai,Diagram.isUsingDOM()){const c=Util.en("div"),f=Util.en("div");c.style.position="absolute",c.style.overflow="auto",c.style.width=i.kt+"px",c.style.height=i.Pt+"px",c.style.zIndex="1",f.style.position="absolute",f.style.width="1px",f.style.height="1px",i.Tt.appendChild(c),c.appendChild(f),c.onscroll=Diagram.XF,c.addEventListener("pointerdown",Diagram.KF),c.p=i,c.YF=!0,c.GF=!0,i.nb=c,i.ob=f}i.yu=Util.Nk(()=>{i.Pl=null,i.C()},300,!1),i.lb=Util.Nk(()=>{i.MS()},250,!1),i.Yh=c=>(c.preventDefault(),!1),i.ta=c=>{if(!l.isEnabled)return;const f=l.Xc(c,!0);f.bubbles=!0;let u=0,d=0;f.delta=0,c.deltaX!==void 0?(c.deltaX!==0&&(u=c.deltaX>0?1:-1),c.deltaY!==0&&(d=c.deltaY>0?1:-1),f.delta=Math.abs(c.deltaX)>Math.abs(c.deltaY)?-u:-d):c.wheelDeltaX!==void 0?(c.wheelDeltaX!==0&&(u=c.wheelDeltaX>0?-1:1),c.wheelDeltaY!==0&&(d=c.wheelDeltaY>0?-1:1),f.delta=Math.abs(c.wheelDeltaX)>Math.abs(c.wheelDeltaY)?-u:-d):c.wheelDelta!==void 0&&c.wheelDelta!==0&&(f.delta=c.wheelDelta>0?1:-1),l.doMouseWheel(),l.oa(f,c)},i.lL=c=>{if(!l.isEnabled)return;i.Uc=!1,l.Xc(c,!0);const f=l.currentTool;f.cancelWaitAfter(),f.standardMouseOver()},i.Zl=c=>{if(!l.isEnabled)return;i.Uc=!0;const f=l.sb;f[c.pointerId]===void 0&&(f[c.pointerId]=c);const u=l._h;let d=!1;if(u[0]!==null&&(u[0].pointerId===c.pointerId||u[0].pointerType!==c.pointerType))u[0]=c;else if(u[1]!==null&&u[1].pointerId===c.pointerId)u[1]=c,d=!0;else if(u[0]===null)u[0]=c;else if(u[1]===null)u[1]=c,d=!0;else{c.preventDefault();return}const m=c.pointerType==="touch"||c.pointerType==="pen";m&&(l.Bw=!1,l.Zm=!0);const g=l.jF(c,c,d),p=l.aM,y=m?25:10;if(c.timeStamp-l.hMy||Math.abs(p.y-c.screenY)>y)?l.$m++:l.$m=1,g.clickCount=l.$m,l.hM=c.timeStamp,l.aM.setTo(c.screenX,c.screenY),l.doMouseDown(),c.button===1){c.preventDefault();return}l.oa(g,c)},i.ia=c=>{if(!l.isEnabled)return;i.Uc=!0;const f=l._h;if(f[0]!==null&&(f[0].pointerId===c.pointerId||f[0].pointerType!==c.pointerType))f[0]=c;else if(f[1]!==null&&f[1].pointerId===c.pointerId){f[1]=c;return}else if(f[0]===null)f[0]=c;else return;if(f[0].pointerId!==c.pointerId)return;const u=l.HF(c,c,f[1]!==null);l.doMouseMove(),l.oa(u,c)},i.ea=c=>{if(!l.isEnabled)return;i.Uc=!0;const f=c.pointerType==="touch"||c.pointerType==="pen",u=l.sb;if(f&&l.Bw){delete u[c.pointerId],c.preventDefault();return}const d=l._h;if(d[0]!==null&&(d[0].pointerId===c.pointerId||d[0].pointerType!==c.pointerType))d[0]=null;else if(d[1]!==null&&d[1].pointerId===c.pointerId){d[1]=null;return}else return;const m=l.pM(c,!1,!0,!1,!0,!1);let g=root.document.elementFromPoint(c.clientX,c.clientY)||null;g!==null&&g.shadowRoot!==void 0&&g.shadowRoot!==null&&(g=g.shadowRoot.elementFromPoint(c.clientX,c.clientY)),g!==null&&g.p instanceof Diagram&&g.p!==l&&g.p.s0(c,m),g===null&&(g=c.target),l.s0(c,m),m.clickCount=l.$m,m.targetDiagram=l.yM(c,g),m.targetObject=null,l.doMouseUp(),l.oa(m,c),f&&(l.Zm=!1)},i.sa=c=>{if(!l.isEnabled)return;i.Uc=!1;const f=l.sb;f[c.pointerId]&&delete f[c.pointerId];const u=l._h;if(u[0]!==null&&u[0].pointerId===c.pointerId&&(u[0]=null),u[1]!==null&&u[1].pointerId===c.pointerId&&(u[1]=null),c.pointerType==="touch"||c.pointerType==="pen")return;const d=l.currentTool;d.cancelWaitAfter(),d.standardMouseOver()},i.na=c=>{const f=l._h;f[0]!==null&&f[0].pointerId===c.pointerId?(f[0]=null,l.Zm=!1):f[1]!==null&&f[1].pointerId===c.pointerId&&(f[1]=null)};const a=r;if(i.rb=a.U[Util.Cs("7eba17a4ca3b1a8346")][Util.Cs("78a118b7")](a.U,Diagram.Ku,s,s),r.clearContextCache(!0),i.qF(),this.Ic==="svg"){const c=this.Wl.get("svg");this.Tt.appendChild(c.Ft),this.Zt=c.ai}}addEventListener(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}Vt(t,i,e,s){t.addEventListener(i,e,{capture:s,passive:!1})}removeEventListener(t,i,e,s){t.removeEventListener(i,e,{capture:s})}Mi(t,i,e,s){t.removeEventListener(i,e,{capture:s})}qF(){const t=this;let i=this.dt.Ft;i instanceof HTMLCanvasElement||(i=t.div),this.Vt(i,"pointerdown",t.Zl,!1),this.Vt(i,"pointermove",t.ia,!1),this.Vt(i,"pointerup",t.ea,!1),this.Vt(i,"pointerout",t.sa,!1),this.Vt(i,"pointercancel",t.na,!1),this.Vt(i,"pointerenter",t.WF,!1),this.Vt(i,"pointerleave",t.JF,!1),this.Vt(i,"wheel",t.ta,!1),this.Vt(i,"keydown",t.$F,!1),this.Vt(i,"keyup",t.ZF,!1),this.Vt(i,"blur",t.QF,!1),this.Vt(i,"focus",t._F,!1),this.Vt(i,"selectstart",e=>(e.preventDefault(),!1),!1),this.Vt(i,"contextmenu",e=>(e.preventDefault(),!1),!1),this.Vt(root,"resize",t.lb,!1)}Uw(){this.Qm>30&&(this.Pl=1)}yP(t){this.Pl!==null&&(this.Pl=null,t&&this.yu(),this.Qm=0,this.uM=[0,0,0,0,0],this._m=0)}computePixelRatio(){return this.Pl!==null?this.Pl:root.devicePixelRatio||1}get avgSpf(){return this.Qm}doMouseDown(){this.currentTool.doMouseDown()}doMouseMove(){this.currentTool.doMouseMove()}doMouseUp(){this.currentTool.doMouseUp()}doMouseWheel(){this.currentTool.doMouseWheel()}doKeyDown(){this.currentTool.doKeyDown()}doKeyUp(){this.currentTool.doKeyUp()}doFocus(){this.focus()}focus(){if(this.dt)if(this.scrollsPageOnFocus)this.dt.focus();else{const t=root.scrollX,i=root.scrollY;this.dt.focus(),root.scrollTo(t,i)}}_F(t){const i=Diagram.Ve.get(this);i&&i.v("GainedFocus")}QF(t){const i=Diagram.Ve.get(this);i&&i.v("LostFocus")}MS(){if(this.dt===null)return;const i=this.Tt;if(i===null||i.clientWidth===0||i.clientHeight===0)return;this.VS||this.setScrollWidth();const e=this.Wn?this.di:0,s=this.gn?this.di:0,n=this.Ui;if(this.Ui=this.computePixelRatio(),this.Ui!==n&&(this.Ru=!0,this.requestUpdate()),i.clientWidth!==this.kt+e||i.clientHeight!==this.Pt+s){this.ra(),this.Ue=!0;const o=this.layout;o!==null&&o.isViewportSized&&this.autoScale===1&&(this.Oc=!0,o.invalidateLayout()),this.ps||this.requestUpdate()}}fL(){let t=0,i=new Layer;i.name="Grid",i.allowSelect=!1,i.pickable=!1,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="ViewportBackground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="Background",this.Gr(i,t++),i=new Layer,i.name="",this.Gr(i,t++),i=new Layer,i.name="Foreground",this.Gr(i,t++),i=new Layer,i.name="ViewportForeground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="Adornment",i.isTemporary=!0,i.isInDocumentBounds=!1,this.Gr(i,t++),i=new Layer,i.name="Tool",i.isTemporary=!0,i.isInDocumentBounds=!0,this.Gr(i,t++)}yL(){const t=new Panel(Panel.Grid,{name:"GRID"}).add(new Shape("LineH",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineV",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new Shape("LineH",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new Shape("LineH",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor"),new Shape("LineV",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor")),i=new Part({layerName:"Grid",zOrder:0,isInDocumentBounds:!1,isAnimated:!1,pickable:!1,locationObjectName:"GRID"}).add(t);return this.add(i),this.partManager.parts.delete(i),t.visible=!1,t}static XF(){const t=Diagram.Ve.get(this.parentElement||this);if(t){if(t.Jx){t.Jx=!1;return}if(!t.isEnabled){t.wL();return}t.diagramScroll(this)}}static KF(t){if(!this.p.isEnabled){this.p.updateScroll();return}this.p.$x=t.target.scrollTop,this.p.Zx=t.target.scrollLeft}diagramScroll(t){if(this.dt===null)return;const i=this.nb,e=this.ob;this.Km=!0;let s=this.documentBounds,n=this.viewportBounds;const o=this.Fc;let r=s.x-o.left,l=s.y-o.top;const h=s.width+o.left+o.right,a=s.height+o.top+o.bottom;let c=s.right+o.right,f=s.bottom+o.bottom,u=n.x,d=n.y;const m=n.width,g=n.height;let p=n.right,y=n.bottom;const x=this.scale;let k,b=t.scrollLeft;if(this.Xu)switch(this.wx){case"negative":b=b+t.scrollWidth-t.clientWidth;break;case"reverse":b=t.scrollWidth-b-t.clientWidth;break}const P=b;if(mp)){const S=i.scrollWidth-this.kt;this.position=k.e(-S+P-this.kt/x+c,this.position.y)}if(t.GF&&this.allowVerticalScroll&&(ly)){const S=i.scrollHeight-this.Pt;this.position=k.e(this.position.x,-S+t.scrollTop-this.Pt/x+f)}Point.s(k),this._l(),this.Km=!1,this.Eu=!1,s=this.documentBounds,n=this.viewportBounds,c=s.right,p=n.right,f=s.bottom,y=n.bottom,r=s.x,u=n.x,l=s.y,d=n.y,m>=h&&r>=u&&c<=p&&(e.style.width="1px"),g>=a&&l>=d&&f<=y&&(e.style.height="1px")}computeBounds(t){return t===void 0&&(t=new Rect),this.Ci(),this.xL(t)}xL(t){if(this.fixedBounds.isReal())return t.a(this.fixedBounds),t.addMargin(this.$t),t;let i=!0;const e=this.Gt.r,s=e.length;for(let n=0;ni&&(a=i),athis.maxScale&&(a=this.maxScale),a):t===3?(a=0,h>l?a=(r-this.di)/n:a=(o-this.di)/s,a>i&&(a=i),athis.maxScale&&(a=this.maxScale),a):this.scale}zoomToFit(){const t=this.jh;this.jh=1,this.scale=this.Yu(2),t!==1&&(this.Us(!1),this.wM(this.documentBounds,this.kt/this.et,this.Pt/this.et,this.Rc,!1)),this.jh=t}zoomToRect(t,i){i===void 0&&(i=2);const e=t.width,s=t.height;if(e===0||s===0||isNaN(e)&&isNaN(s))return;let n=1;if(i===2||i===3)if(isNaN(e))n=this.viewportBounds.height*this.scale/s;else if(isNaN(s))n=this.viewportBounds.width*this.scale/e;else{const o=this.kt,r=this.Pt;i===3?r/s>o/e?n=(r-(this.gn?this.di:0))/s:n=(o-(this.Wn?this.di:0))/e:n=Math.min(r/s,o/e)}this.scale=n,this.position=new Point(t.x,t.y)}get tR(){return this.Ht}set tR(t){this.Ht=t}alignDocument(t,i){this.ensureBounds();const e=this.documentBounds,s=this.viewportBounds;this.position=new Point(e.x+(t.x*e.width+t.offsetX)-(i.x*s.width-i.offsetX),e.y+(t.y*e.height+t.offsetY)-(i.y*s.height-i.offsetY))}focusObject(t){if(t instanceof GraphObject){this.t0=t;const i=Point.l();this.i0=this.transformDocToView(t.getDocumentPoint(Spot.TopLeft,i)),Point.s(i)}else this.t0=null,this.i0=Point.Ak}wM(t,i,e,s,n){const o=Point.X(this.at.x,this.at.y);let r=o.x,l=o.y;if(this.t0!==null){let h=Point.l();h=this.t0.getDocumentPoint(Spot.TopLeft,h),r=h.x-this.i0.x/this.scale,l=h.y-this.i0.y/this.scale,s=Spot.None,Point.s(h)}if(n||this.scrollMode===1){s.isSpot()&&(i>t.width&&(r=t.x+(s.x*t.width+s.offsetX)-(s.x*i-s.offsetX)),e>t.height&&(l=t.y+(s.y*t.height+s.offsetY)-(s.y*e-s.offsetY)));const h=this.Fc,a=i-t.width;if(it.left?r=t.left:rt.top?l=t.top:ls.part,s=>s.canSelect());if(e instanceof Part)return e}else{const e=this.PP(t,s=>s.part);if(e instanceof Part)return e}return null}findObjectAt(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Ci();const s=this.Gt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}PP(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null),this.Ci();const s=this.Gt.iteratorBackwards;for(;s.next();){const n=s.value;if(!n.visible||n.isTemporary)continue;const o=n.findObjectAt(t,i,e);if(o!==null)return o}return null}findPartsAt(t,i,e){return i===void 0&&(i=!0),this.eR(t,s=>s.part,i?s=>s instanceof Part&&s.canSelect():null,e)}eR(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Ci();const n=this.Gt.iteratorBackwards;for(;n.next();){const o=n.value;!o.visible||o.isTemporary||o.findObjectsAt(t,i,e,s)}return s}findObjectsAt(t,i,e,s){i===void 0&&(i=null),e===void 0&&(e=null),!(s instanceof List)&&!(s instanceof GSet)&&(s=new GSet),this.Ci();const n=this.Gt.iteratorBackwards;for(;n.next();){const o=n.value;o.visible&&o.findObjectsAt(t,i,e,s)}return s}findPartsIn(t,i,e,s){return i===void 0&&(i=!1),e===void 0&&(e=!0),this.sR(t,null,n=>n instanceof Part&&(!e||n.canSelect()),i,s)}findObjectsIn(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Ci();const o=this.Gt.iteratorBackwards;for(;o.next();){const r=o.value;r.visible&&r.findObjectsIn(t,i,e,s,n)}return n}NP(t,i,e,s,n,o){const r=new GSet;this.Ci();const l=this.Gt.iteratorBackwards;for(;l.next();){const h=l.value;h.visible&&h.NP(t,i,e,s,r,n,o)}return r}sR(t,i,e,s,n){i===void 0&&(i=null),e===void 0&&(e=null),s===void 0&&(s=!1),!(n instanceof List)&&!(n instanceof GSet)&&(n=new GSet),this.Ci();const o=this.Gt.iteratorBackwards;for(;o.next();){const r=o.value;!r.visible||r.isTemporary||r.findObjectsIn(t,i,e,s,n)}return n}findPartsNear(t,i,e,s,n){return e===void 0&&(e=!0),s===void 0&&(s=!0),this.nR(t,i,null,o=>o instanceof Part&&(!s||o.canSelect()),e,n)}findObjectsNear(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Ci();const r=this.Gt.iteratorBackwards;for(;r.next();){const l=r.value;l.visible&&l.findObjectsNear(t,i,e,s,n,o)}return o}nR(t,i,e,s,n,o){e===void 0&&(e=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof List||n instanceof GSet)&&(o=n),n=!0),!(o instanceof List)&&!(o instanceof GSet)&&(o=new GSet),this.Ci();const r=this.Gt.iteratorBackwards;for(;r.next();){const l=r.value;!l.visible||l.isTemporary||l.findObjectsNear(t,i,e,s,n,o)}return o}acceptEvent(t){return this.Xc(t,t instanceof MouseEvent)}Xc(t,i){const e=this.Xr;this.Xr=this.$h,this.$h=e,e.diagram=this,e.event=t,i?this.s0(t,e):(e.viewPoint=this.Xr.viewPoint,e.documentPoint=this.Xr.documentPoint);let s=0;const n=t;return n.ctrlKey&&(s+=1),n.altKey&&(s+=2),n.shiftKey&&(s+=4),n.metaKey&&(s+=8),e.modifiers=s,e.button=n.button,n.buttons!==void 0&&(e.buttons=n.buttons),Util.rr&&n.button===0&&n.ctrlKey&&(e.button=2),e.down=!1,e.up=!1,e.clickCount=1,e.delta=0,e.handled=!1,e.bubbles=!1,e.timestamp=t.timeStamp,e.isMultiTouch=!1,e.targetDiagram=this.yM(t,t.target),e.targetObject=null,e}yM(t,i){if(i===null)return null;const e=Diagram.Ve.get(i);if(e)return e;let s=t.path;if(!s&&typeof t.composedPath=="function"&&(s=t.composedPath()),s&&s[0]){const n=Diagram.Ve.get(s[0]);if(n)return n}return null}jF(t,i,e){const s=this.pM(t,!0,!1,!1,!0,e);return this.s0(i,s),s.targetDiagram=this.yM(t,t.target),s.targetObject=null,e||s.clone(this.Wm),s}HF(t,i,e){const s=this.pM(t,!1,!1,!1,!1,e);let n=root.document.elementFromPoint(i.clientX,i.clientY)||null;n!==null&&n.shadowRoot!==void 0&&n.shadowRoot!==null&&(n=n.shadowRoot.elementFromPoint(i.clientX,i.clientY));let o=this,r=t;if(n){const l=Diagram.Ve.get(n);l&&(r=i,o=l)}return s.targetDiagram=o,this.s0(r,s),s.targetObject=null,s}pM(t,i,e,s,n,o){const r=this.Xr;this.Xr=this.$h,this.$h=r,r.diagram=this,r.clickCount=1,r.delta=0;let l=0;return t.ctrlKey&&(l+=1),t.altKey&&(l+=2),t.shiftKey&&(l+=4),t.metaKey&&(l+=8),r.modifiers=l,r.event=t,r.timestamp=t.timeStamp,r.button=e?this.firstInput.button:t.button,r.buttons=t.buttons,Util.rr&&t.button===0&&t.ctrlKey&&(r.button=2),r.down=i,r.up=e,r.handled=s,r.bubbles=n,r.isMultiTouch=o,r}oa(t,i){return t.bubbles?!0:(i.stopPropagation!==void 0&&i.stopPropagation(),i.cancelable!==!1&&i.preventDefault(),i.cancelBubble=!0,!1)}$F(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.Xc(t,!1);return e.key=t.key,e.code=t.code,e.down=!0,i.doKeyDown(),i.oa(e,t)}ZF(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.Xc(t,!1);return e.key=t.key,e.code=t.code,e.up=!0,i.doKeyUp(),i.oa(e,t)}WF(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.Xc(t,!0);return i.mouseEnter!==null&&i.mouseEnter(e),i.currentTool.standardMouseOver(),i.oa(e,t)}JF(t){const i=Diagram.Ve.get(this);if(!i||!i.isEnabled)return!1;const e=i.Xc(t,!0);return i.mouseLeave!==null&&i.mouseLeave(e),i.oa(e,t)}getMouse(t){const i=this.dt;if(i===null)return new Point(0,0);const e=i.getBoundingClientRect(),s=(t.clientX-e.left)*(this.kt/e.width),n=(t.clientY-e.top)*(this.Pt/e.height);return new Point(s,n).Ie(this.D)}s0(t,i){const e=this.dt;let s=0,n=0;if(e!==null){const r=e.getBoundingClientRect();s=(t.clientX-r.left)*(this.kt/r.width),n=(t.clientY-r.top)*(this.Pt/r.height)}i.viewPoint.e(s,n);const o=Point.X(s,n);this.D._e(o),i.documentPoint.a(o),Point.s(o)}kC(t,i,e){let s;if(this._h[0]!==null)s=this._h[i];else return;const n=this.dt;if(n!==null){const o=n.getBoundingClientRect();e.e((s.clientX-o.left)*(this.kt/o.width),(s.clientY-o.top)*(this.Pt/o.height))}}invalidateDocumentBounds(){this.Zh||(this.Zh=!0,this.requestUpdate(!1))}oR(){this.ps||this.Ci(),this.ensureBounds()}redraw(){this.Ht||this.ps||(this.C(),this.maybeUpdate())}isUpdateRequested(){return this.Pr}delayInitialization(t){t===void 0&&(t=null);const i=this.animationManager,e=i.isEnabled;i.stopAnimation(),i.isEnabled=!1,this.yr(),this.Jn=!1,this.ex=new Point(NaN,NaN),i.isEnabled=e,this.ps=!0;const s=this;t!==null&&Util.Oh(()=>{s.ps=!1,i.Fl("Model"),t(s)},1)}requestUpdate(t){if(t===void 0&&(t=!1),this.Pr===!0||this.Ht||t===!1&&this.ps)return;this.Pr=!0;const i=this;root.requestAnimationFrame(()=>{i.Pr&&i.maybeUpdate()})}maybeUpdate(){this.vu&&!this.Pr||(this.vu&&(this.vu=!1),this.yr())}xM(t,i){!this.Eu||this.Ht||this.animationManager.defaultAnimation.isAnimating||this.wL()||(t&&this.Ci(),i&&this.Us(!1))}yr(t){if(this.ps||(this.Pr=!1,this.Tt===null&&!this.Bu.isReal()))return;this.ps=!0;const i=this.animationManager,e=this.zu;if(!i.isAnimating&&e.length!==0){const c=e.r,f=c.length;for(let u=0;u0&&(s.each(c=>c.bM()),s.clear());let n=!1,o=!1;i.defaultAnimation.isAnimating&&(o=!0,n=this.skipsUndoManager,this.skipsUndoManager=!0),i.wi||this.MS(),t||this.xM(!1,!0);const r=!this.undoManager.isUndoingRedoing&&(this.bl||this.zc.count!==0&&this.Lr.size!==0),l=!this.Jn||this.Kr;this.Ci(!0);let h=!1;(l||r)&&(this.Jn?this.kM(!this.Oc,r):(this.startTransaction("Initial Layout"),i.isEnabled===!1&&i.stopAnimation(),this.kM(!1,r)),h=l),this.Oc=!1,this.bl=!1,this.Ci(),this.ts!==null&&(this.ts.visible&&!this.Hm&&(this.jr(),this.Hm=!0),!this.ts.visible&&this.Hm&&(this.Hm=!1)),this.Bx||this.oR(),t||this.xM(!0,!1);let a=!1;if(h){const c=Rect.l();c.a(this.viewportBounds),this.Jn||(this.Jn=!0,a=!0,this.skipsUndoManager||(this.undoManager.Ow=!0),this.undoManager.Iw=!0,this.rR()),this.lR(),this.Ci(!1),t||this.xM(!0,!0),Rect.s(c)}else if(i.Sc&&i.ix){if(this.Cr!==1)this.scale=this.Yu(this.Cr);else if(this.jl!==1)this.scale=this.Yu(this.jl);else{const c=this.initialScale;isFinite(c)&&c>0&&(this.scale=c)}this.Us(!0)}h&&a&&this.commitTransaction("Initial Layout"),t||this.Gi(this.Zt),o&&(this.skipsUndoManager=n),this.ps=!1}get Bh(){return this.Jn}rR(){if(this.Cr!==1)this.scale=this.Yu(this.Cr);else if(this.jl!==1)this.scale=this.Yu(this.jl);else{const i=this.initialScale;isFinite(i)&&i>0&&(this.scale=i)}this.Us(!0);const t=this.Gt.r;this.Bs(t,t.length,this,this.viewportBounds),this.v("InitialLayoutCompleted"),this.ex.a(this.at),this.jr()}lR(){this.v("LayoutCompleted")}o0(t){this.Hn.add(t)}addInvalidRoute(t){this.Fo?this.Wh.add(t):this.Lr.add(t)}Ci(t){if(this.Hn.size!==0&&!(!this.ps&&this.animationManager.isTicking)){if(this.ps||(this.bl=!0),t){this.bL(this.Hn);return}for(let i=0;i<23&&this.Hn.size!==0;i++){const e=new Set(this.Hn);this.Hn.clear(),this.bM(e,this.Hn)}this.nodes.each(i=>{i instanceof Group&&i.kL(!1)})}}bL(t,i){for(const e of t)!e.Pe()||e instanceof Group||(e.Hr()?(e.ut(1/0,1/0),e.zt()):i&&i.add(e));for(const e of t)if(e instanceof Group){if(!e.isVisible())continue;this.yb(e)}}bM(t,i){this.bL(t,i);for(const e of t){if(!(e instanceof Link))continue;const s=e;s.isVisible()&&(s.Hr()?(s.ut(1/0,1/0),s.zt()):i.add(s))}for(const e of t)e instanceof Adornment&&e.isVisible()&&(e.Hr()?(e.ut(1/0,1/0),e.zt()):i.add(e))}r0(t){const i=t instanceof Diagram,e=i?t.links:t.memberParts,s=this.Hn;if(i)this.Ci(!0);else{for(;e.next();){const n=e.value;s.has(n)&&(!n.Pe()||n instanceof Group||n.Hr()&&(n.ut(1/0,1/0),n.zt()))}for(e.reset();e.next();){const n=e.value;if(s.has(n)&&n instanceof Group){if(!n.isVisible())continue;this.yb(n)}}e.reset()}for(;e.next();){const n=e.value;n instanceof Link&&s.has(n)&&n.isVisible()&&n.Hr()&&(n.ut(1/0,1/0),n.zt())}}yb(t){const i=Util.nt(),e=Util.nt(),s=t.memberParts;for(;s.next();){const o=s.value;o.isVisible()&&(o instanceof Group?(o.Oo()||o.is()||o.th())&&this.yb(o):o instanceof Link?o.fromNode===t||o.toNode===t?e.push(o):i.push(o):(o.ut(1/0,1/0),o.zt()))}let n=i.length;for(let o=0;ob.Du())}else for(let x=0;x0){const a=n.substring(0,h);e?o=t.findObject(a):(o=t[a],o==null&&(o=t.toolManager[a])),Util.wt(o)?r=n.substring(h+1):Util.o("Unable to find object named: "+a+" in "+t.toString()+" when trying to set property: "+n)}}if(r[0]!=="_"&&!Util.fw(o,r))if(s&&r==="ModelChanged"){t.addModelChangedListener(i[r]);continue}else if(s&&r==="Changed"){t.addChangedListener(i[r]);continue}else if(s&&Util.fw(t.toolManager,r))o=t.toolManager;else if(s&&t.PL(r)){t.addDiagramListener(r,i[r]);continue}else if(t instanceof Model&&r==="Changed"){t.addChangedListener(i[r]);continue}else Util.o('Trying to set undefined property "'+r+'" on object: '+o.toString());const l=i[n];o[r]=l,r[0]==="_"&&o instanceof GraphObject&&o.addCopyProperty(r)}}_C(){if(this.$l.count!==0&&!(this.undoManager.transactionLevel>1)){for(;this.$l.count>0;){const t=this.$l;this.$l=new GMap;const i=t.iterator;for(;i.next();){const e=i.key;e.invalidateOtherJumpOvers(i.value),e.ee()}}this.C()}}C(t){if(t===void 0)this.Ue=!0,this.requestUpdate();else{const i=this.viewportBounds;t.isReal()&&i.intersectsRect(t)&&(this.Ue=!0,this.requestUpdate())}this.v("InvalidateDraw")}invalidateViewport(t,i){if(this.Ue===!0)return;if(this.Ue=!0,this.Ic==="svg"){this.maybeUpdate();return}this.getRenderingHint("temporaryPixelRatio")===!0?(this.Uw(),this.maybeUpdate(),this.yP(!0)):this.maybeUpdate()}ra(){this.Eu=!0}_l(){this.Ec=!0}l0(){this.Ru!==!1&&(this.Ru=!1,this.pL(this.kt,this.Pt))}pL(t,i){this.Ql();const e=this.Ui,s=t*e,n=i*e;this.dt.resize(s,n,t,i)&&(this.Ue=!0,this.Zt.clearContextCache(!0))}wL(){const t=this.dt;if(t===null||this.Bu.isReal())return!0;const i=this.kt,e=this.Pt,s=this.Tt;let n=!1,o=this.Wn?this.di:0,r=this.gn?this.di:0,l=s.clientWidth||i+o,h=s.clientHeight||e+r;const a=this.viewportBounds,c=a.x,f=a.y,u=a.width,d=a.height;if((l!==i+o||h!==e+r)&&(this.Wn=!1,this.gn=!1,o=0,r=0,this.kt=l,this.Pt=h,this.Ru=!0,n=!0,this.Ql()),!this.Jn||!this.viewportBounds.isReal())return!0;const m=this.nb,g=this.ob;if(this.Eu=!1,!n&&!this.Wn&&!this.gn&&!this.Ou&&!this.Iu)return!0;const p=this.documentBounds;let y=0,x=0,k=0,b=0;const P=a.width,S=a.height,L=this.Fc;this.contentAlignment.isSpot()?(p.width>P&&(y=L.left,x=L.right),p.height>S&&(k=L.top,b=L.bottom)):(y=L.left,x=L.right,k=L.top,b=L.bottom);const C=p.width+y+x,M=p.height+k+b,N=this.scale,T=N;let A=C>l/N,D=M>h/N;if(!n&&!this.Wn&&!this.gn&&!A&&!D)return!0;const F=p.x-y,R=a.x,v=p.right+x;let O=a.right+o;const B=p.y-k,X=a.y,E=p.bottom+b;let V=a.bottom+r,U="1px",Y="1px";if(this.scrollMode===1&&(A||D)){if(A&&this.hasHorizontalScrollbar&&this.allowHorizontalScroll){let z=1;F+1O+1&&(z=Math.max((v-O)*N+this.kt,z)),P+o+1V+1&&(z=Math.max((E-V)*N+this.Pt,z)),S+r+1O+1&&(W=Math.max((v-O)*N+this.kt,W)),P+1V+1&&(W=Math.max((E-V)*N+z,W)),S+1O+1&&(J=this.position.x*N)),this.Xu)switch(this.wx){case"negative":J=-(m.scrollWidth-J-m.clientWidth);break;case"reverse":J=m.scrollWidth-J-m.clientWidth;break}if(m.scrollLeft=J,this.hasVerticalScrollbar&&this.allowVerticalScroll&&(S+1V+1&&(m.scrollTop=this.position.y*N)),l=this.kt,h=this.Pt,m.style.width=l+(this.Wn?this.di:0)+"px",m.style.height=h+(this.gn?this.di:0)+"px",i!==l||e!==h||this.animationManager.wi){const z=Rect.X(c,f,u,d);return this.onViewportBoundsChanged(z,this.viewportBounds,T,n),Rect.s(z),!1}return!0}add(t){const i=t.diagram;if(i===this)return;i!==null&&Util.o("Cannot add part "+t.toString()+" to "+this.toString()+". It is already a part of "+i.toString());let e=this.findLayer(t.layerName);if(e===null&&(e=this.findLayer("")),e===null&&Util.o('Cannot add a Part when unable find a Layer named "'+t.layerName+'" and there is no default Layer'),t.layer===e)return;const s=e.qh(99999999,t,t.diagram===this);s>=0&&this.raiseChangedEvent(3,"parts",e,null,t,null,s),e.isTemporary||this.invalidateDocumentBounds(),t.invalidateLayout(1);const n=t.layerChanged;n!==null&&n(t,null,e)}qh(t){this.partManager.qh(t);const i=this;t.qr(s=>i.SL(s)),t.data||t.Io(),t.hasPlaceholder()&&t.c(),t.data!==null&&t.qr(s=>i.partManager.SM(s,null)),(t.is()===!0||t.th()===!0)&&this.o0(t),t.ML(!0,this),t.NL()?(t.actualBounds.isReal()&&this.C(t.Hh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.C(t.Hh(t.actualBounds)),this.requestUpdate()}te(t){t.clearAdornments(),this.partManager.te(t);const i=this;t.data!==null&&t.qr(s=>i.partManager.MM(s,i)),this.Hn.delete(t),t instanceof Link&&this.Lr.delete(t),t.NL()?(t.actualBounds.isReal()&&this.C(t.Hh(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.C(t.Hh(t.actualBounds)),this.requestUpdate()}remove(t){this.NM(t,!0)}NM(t,i){const e=t.layer;if(e===null||e.diagram!==this)return;t.isSelected=!1,t.isHighlighted=!1,t.invalidateLayout(2),i&&t.Kc();const s=e.te(-1,t,!1);s>=0&&this.raiseChangedEvent(4,"parts",e,t,null,s,null);const n=t.layerChanged;n!==null&&n(t,e,null)}removeParts(t,i){if(i===void 0&&(i=!1),Array.isArray(t)){const e=t.length;for(let s=0;s=0&&i.elt(e).isTemporary;)e--;return i.insertAt(e+1,t),this.Si!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,e+1),this.C(),this.invalidateDocumentBounds(),this}addLayerBefore(t,i){this.CM(t,i),t.To(this);const e=this.Gt,s=e.indexOf(t);s>=0&&(e.delete(t),this.Si!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;o=0&&(e.delete(t),this.Si!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));const n=e.count;let o;for(o=0;othis.maxScale&&(i=this.maxScale);const c=Point.X(this.at.x+l/t-l/i,this.at.y+h/t-h/i);this.position=c,Point.s(c),this.et=i,this.Ql(),this.Ht=!1,this.onViewportBoundsChanged(n,this.viewportBounds,t,!1),this.Us(!1),e.ZC(t,this.et),this.C()}iR(){const t=this.Gt.r;for(let i=0;i{r.isAvoiding&&r.actualBounds.intersectsRect(i)&&r.invalidateRoute()})}jr(t){const i=this.ts;if(i===null||!i.visible||i.layer===null)return;const e=t!==void 0?t:this._x;if(!e.isReal())return;const s=e.width,n=e.height;if(i.scale=1,i.angle=0,i.layer.isViewportAligned)i.width=s*this.scale,i.height=n*this.scale,i.part.alignment=Spot.TopLeft;else{i.xi===null&&(i.xi=new GridPanelSettings);const o=i.xi.Yc;if(!o.isReal())return;i.width=s+o.width*2,i.height=n+o.height*2;const r=Point.l();Geo.Ig(e.x,e.y,0,0,o.width,o.height,r),r.offset(-o.width,-o.height),i.part.location=r,Point.s(r)}}clearSelection(t){t===void 0&&(t=!1);const i=this.selection;if(i.count===0)return;t||this.v("ChangingSelection",i);const e=i.toArray(),s=e.length;for(let n=0;n1)&&(this.v("ChangingSelection",this.selection),this.clearSelection(!0),t.isSelected=!0,this.v("ChangedSelection",this.selection))}selectCollection(t){if(this.v("ChangingSelection",this.selection),this.clearSelection(!0),Array.isArray(t)){const i=t.length;for(let e=0;e0){const i=t.toArray(),e=i.length;for(let s=0;s1)&&(this.clearHighlighteds(),t.isHighlighted=!0)}highlightCollection(t){const i=new GSet().addAll(t),s=this.highlighteds.copy().removeAll(i).iterator;for(;s.next();){const o=s.value;o.isHighlighted=!1}const n=i.iterator;for(;n.next();){const o=n.value;o instanceof Part||Util.o("Diagram.highlightCollection given something that is not a Part: "+o),o.isHighlighted=!0}}scroll(t,i,e){e===void 0&&(e=1);const s=i==="up"||i==="down";let n=0;const o=Point.l();if(t==="pixel")n=e;else if(t==="line")n=e*(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange);else if(t==="page"){let l=s?this.viewportBounds.height:this.viewportBounds.width;if(l*=this.scale,l!==0){const h=Math.max(l-(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange),0);n=e*h}}else if(t==="document"){const l=this.documentBounds,h=this.viewportBounds;i==="up"?this.position=o.e(h.x,l.y):i==="left"?this.position=o.e(l.x,h.y):i==="down"?this.position=o.e(h.x,l.bottom-h.height):i==="right"&&(this.position=o.e(l.right-h.width,h.y)),Point.s(o);return}else Util.o("scrolling unit must be 'pixel', 'line', 'page', or 'document', not: "+t);n/=this.scale;const r=this.position;i==="up"?this.position=o.e(r.x,r.y-n):i==="down"?this.position=o.e(r.x,r.y+n):i==="left"?this.position=o.e(r.x-n,r.y):i==="right"?this.position=o.e(r.x+n,r.y):Util.o("scrolling direction must be 'up', 'down', 'left', or 'right', not: "+i),Point.s(o)}scrollToRect(t){const i=this.viewportBounds;if(i.containsRect(t))return;const e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}centerRect(t){const i=this.viewportBounds,e=t.center;e.x-=i.width/2,e.y-=i.height/2,this.position=e}transformDocToView(t){return t.copy().D(this.D)}transformViewToDoc(t){return t.copy().Ie(this.D)}LF(t){return t.Ie(this.D)}static None=1;static Uniform=2;static UniformToFill=3;static CycleAll=1;static CycleNotDirected=2;static CycleNotDirectedFast=3;static CycleNotUndirected=4;static CycleDestinationTree=5;static CycleSourceTree=6;static DocumentScroll=1;static InfiniteScroll=2;static TreeParentCollapsed=1;static AllParentsCollapsed=2;static AnyParentsCollapsed=3;get opacity(){return this.Wt}set opacity(t){const i=this.Wt;i!==t&&(Util.i(t,"number",Diagram,"opacity"),(t<0||t>1)&&Util._(t,"0 <= value <= 1",Diagram,"opacity"),this.Wt=t,this.t("opacity",i,t),this.C())}get validCycle(){return this.Rx}set validCycle(t){const i=this.Rx;i!==t&&(this.Rx=t,this.t("validCycle",i,t))}get layers(){return this.Gt.iterator}get isModelReadOnly(){const t=this.Si;return t===null?!1:t.isReadOnly}set isModelReadOnly(t){const i=this.Si;i!==null&&(i.isReadOnly=t)}get isReadOnly(){return this.vo}set isReadOnly(t){const i=this.vo;i!==t&&(Util.i(t,"boolean",Diagram,"isReadOnly"),this.vo=t,this.t("isReadOnly",i,t))}get isEnabled(){return this.Oi}set isEnabled(t){const i=this.Oi;i!==t&&(Util.i(t,"boolean",Diagram,"isEnabled"),this.Oi=t,this.t("isEnabled",i,t))}get allowClipboard(){return this.Vx}set allowClipboard(t){const i=this.Vx;i!==t&&(Util.i(t,"boolean",Diagram,"allowClipboard"),this.Vx=t,this.t("allowClipboard",i,t))}get allowCopy(){return this.Rl}set allowCopy(t){const i=this.Rl;i!==t&&(Util.i(t,"boolean",Diagram,"allowCopy"),this.Rl=t,this.t("allowCopy",i,t))}get allowDelete(){return this.vl}set allowDelete(t){const i=this.vl;i!==t&&(Util.i(t,"boolean",Diagram,"allowDelete"),this.vl=t,this.t("allowDelete",i,t))}get allowDragOut(){return this.zx}set allowDragOut(t){const i=this.zx;i!==t&&(Util.i(t,"boolean",Diagram,"allowDragOut"),this.zx=t,this.t("allowDragOut",i,t))}get allowDrop(){return this.Xx}set allowDrop(t){const i=this.Xx;i!==t&&(Util.i(t,"boolean",Diagram,"allowDrop"),this.Xx=t,this.t("allowDrop",i,t))}get allowTextEdit(){return this.Ol}set allowTextEdit(t){const i=this.Ol;i!==t&&(Util.i(t,"boolean",Diagram,"allowTextEdit"),this.Ol=t,this.t("allowTextEdit",i,t))}get allowGroup(){return this.Il}set allowGroup(t){const i=this.Il;i!==t&&(Util.i(t,"boolean",Diagram,"allowGroup"),this.Il=t,this.t("allowGroup",i,t))}get allowUngroup(){return this.El}set allowUngroup(t){const i=this.El;i!==t&&(Util.i(t,"boolean",Diagram,"allowUngroup"),this.El=t,this.t("allowUngroup",i,t))}get allowInsert(){return this.Kx}set allowInsert(t){const i=this.Kx;i!==t&&(Util.i(t,"boolean",Diagram,"allowInsert"),this.Kx=t,this.t("allowInsert",i,t))}get allowLink(){return this.Bl}set allowLink(t){const i=this.Bl;i!==t&&(Util.i(t,"boolean",Diagram,"allowLink"),this.Bl=t,this.t("allowLink",i,t))}get allowRelink(){return this.Ul}set allowRelink(t){const i=this.Ul;i!==t&&(Util.i(t,"boolean",Diagram,"allowRelink"),this.Ul=t,this.t("allowRelink",i,t))}get allowMove(){return this.Vl}set allowMove(t){const i=this.Vl;i!==t&&(Util.i(t,"boolean",Diagram,"allowMove"),this.Vl=t,this.t("allowMove",i,t))}get allowReshape(){return this.zl}set allowReshape(t){const i=this.zl;i!==t&&(Util.i(t,"boolean",Diagram,"allowReshape"),this.zl=t,this.t("allowReshape",i,t))}get allowResize(){return this.Xl}set allowResize(t){const i=this.Xl;i!==t&&(Util.i(t,"boolean",Diagram,"allowResize"),this.Xl=t,this.t("allowResize",i,t))}get allowRotate(){return this.Kl}set allowRotate(t){const i=this.Kl;i!==t&&(Util.i(t,"boolean",Diagram,"allowRotate"),this.Kl=t,this.t("allowRotate",i,t))}get allowSelect(){return this.Yl}set allowSelect(t){const i=this.Yl;i!==t&&(Util.i(t,"boolean",Diagram,"allowSelect"),this.Yl=t,this.t("allowSelect",i,t))}get allowUndo(){return this.Yx}set allowUndo(t){const i=this.Yx;i!==t&&(Util.i(t,"boolean",Diagram,"allowUndo"),this.Yx=t,this.t("allowUndo",i,t))}get allowZoom(){return this.Gx}set allowZoom(t){const i=this.Gx;i!==t&&(Util.i(t,"boolean",Diagram,"allowZoom"),this.Gx=t,this.t("allowZoom",i,t))}get hasVerticalScrollbar(){return this.Iu}set hasVerticalScrollbar(t){const i=this.Iu;i!==t&&(Util.i(t,"boolean",Diagram,"hasVerticalScrollbar"),this.Iu=t,this.ra(),this.C(),this.t("hasVerticalScrollbar",i,t),this.Us(!1))}get hasHorizontalScrollbar(){return this.Ou}set hasHorizontalScrollbar(t){const i=this.Ou;i!==t&&(Util.i(t,"boolean",Diagram,"hasHorizontalScrollbar"),this.Ou=t,this.ra(),this.C(),this.t("hasHorizontalScrollbar",i,t),this.Us(!1))}get allowHorizontalScroll(){return this.jx}set allowHorizontalScroll(t){const i=this.jx;i!==t&&(Util.i(t,"boolean",Diagram,"allowHorizontalScroll"),this.jx=t,this.t("allowHorizontalScroll",i,t),this.Us(!1))}get allowVerticalScroll(){return this.Hx}set allowVerticalScroll(t){const i=this.Hx;i!==t&&(Util.i(t,"boolean",Diagram,"allowVerticalScroll"),this.Hx=t,this.t("allowVerticalScroll",i,t),this.Us(!1))}get scrollHorizontalLineChange(){return this.qx}set scrollHorizontalLineChange(t){const i=this.qx;i!==t&&(Util.i(t,"number",Diagram,"scrollHorizontalLineChange"),t<0&&Util._(t,">= 0",Diagram,"scrollHorizontalLineChange"),this.qx=t,this.t("scrollHorizontalLineChange",i,t))}get scrollVerticalLineChange(){return this.Wx}set scrollVerticalLineChange(t){const i=this.Wx;i!==t&&(Util.i(t,"number",Diagram,"scrollVerticalLineChange"),t<0&&Util._(t,">= 0",Diagram,"scrollVerticalLineChange"),this.Wx=t,this.t("scrollVerticalLineChange",i,t))}get lastInput(){return this.$h}set lastInput(t){this.$h=t}get previousInput(){return this.Xr}set previousInput(t){this.Xr=t}get firstInput(){return this.Wm}set firstInput(t){this.Wm=t}get currentCursor(){return this.vx}set currentCursor(t){if(t===""&&(t=this.Xm),this.vx!==t){Util.i(t,"string",Diagram,"currentCursor");const e=this.dt,s=this.Tt;if(e===null||s===null)return;this.vx=t;const n=e.style.cursor;e.style.cursor=t,s.style.cursor=t,e.style.cursor===n&&(e.style.cursor="-webkit-"+t,s.style.cursor="-webkit-"+t,e.style.cursor===n&&(e.style.cursor="-moz-"+t,s.style.cursor="-moz-"+t,e.style.cursor===n&&(e.style.cursor=t,s.style.cursor=t)))}}get defaultCursor(){return this.Xm}set defaultCursor(t){t===""&&(t="auto");const i=this.Xm;i!==t&&(Util.i(t,"string",Diagram,"defaultCursor"),this.Xm=t,this.t("defaultCursor",i,t))}get click(){return this.Tr}set click(t){const i=this.Tr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"click"),this.Tr=t,this.t("click",i,t))}get doubleClick(){return this.Dr}set doubleClick(t){const i=this.Dr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"doubleClick"),this.Dr=t,this.t("doubleClick",i,t))}get contextClick(){return this.Fr}set contextClick(t){const i=this.Fr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"contextClick"),this.Fr=t,this.t("contextClick",i,t))}get mouseOver(){return this.Rr}set mouseOver(t){const i=this.Rr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseOver"),this.Rr=t,this.t("mouseOver",i,t))}get mouseHover(){return this.vr}set mouseHover(t){const i=this.vr;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseHover"),this.vr=t,this.t("mouseHover",i,t))}get mouseHold(){return this.Or}set mouseHold(t){const i=this.Or;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseHold"),this.Or=t,this.t("mouseHold",i,t))}get mouseDragOver(){return this.Ox}set mouseDragOver(t){const i=this.Ox;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseDragOver"),this.Ox=t,this.t("mouseDragOver",i,t))}get mouseDrop(){return this.Ir}set mouseDrop(t){const i=this.Ir;i!==t&&(this.Ir=t,this.t("mouseDrop",i,t))}get handlesDragDropForTopLevelParts(){return this.Ix}set handlesDragDropForTopLevelParts(t){const i=this.Ix;i!==t&&(Util.i(t,"boolean",Diagram,"handlesDragDropForTopLevelParts"),this.Ix=t,this.t("handlesDragDropForTopLevelParts",i,t))}get mouseEnter(){return this.Er}set mouseEnter(t){const i=this.Er;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseEnter"),this.Er=t,this.t("mouseEnter",i,t))}get mouseLeave(){return this.Br}set mouseLeave(t){const i=this.Br;i!==t&&(t!==null&&Util.i(t,"function",Diagram,"mouseLeave"),this.Br=t,this.t("mouseLeave",i,t))}get toolTip(){return this.Ur}set toolTip(t){const i=this.Ur;i!==t&&(this.Ur=t,this.t("toolTip",i,t))}get contextMenu(){return this.Vr}set contextMenu(t){const i=this.Vr;i!==t&&(this.Vr=t,this.t("contextMenu",i,t))}get commandHandler(){return this.HS}set commandHandler(t){this.HS!==t&&(this.HS=t,t.To(this))}get toolManager(){return this.YS}set toolManager(t){this.YS!==t&&(this.YS=t,t.diagram=this)}get defaultTool(){return this.GS}set defaultTool(t){const i=this.GS;i!==t&&(this.GS=t,t.diagram=this,this.currentTool===i&&(this.currentTool=t))}get currentTool(){return this.jS}set currentTool(t){const i=this.jS;i&&(i.isActive&&i.doDeactivate(),i.cancelWaitAfter(),i.doStop()),t===null&&(t=this.defaultTool),t!==null&&(this.jS=t,t.diagram=this,t.doStart())}get selection(){return this._S}get maxSelectionCount(){return this.Qx}set maxSelectionCount(t){const i=this.Qx;if(i!==t)if(Util.i(t,"number",Diagram,"maxSelectionCount"),t>=0&&!isNaN(t)){if(this.Qx=t,this.t("maxSelectionCount",i,t),!this.undoManager.isUndoingRedoing){const e=this.selection.count-t;if(e>0){this.v("ChangingSelection",this.selection);const s=this.selection.toArray();for(let n=0;n= 0",Diagram,"maxSelectionCount")}get nodeSelectionAdornmentTemplate(){return this.jm}set nodeSelectionAdornmentTemplate(t){const i=this.jm;i!==t&&(this.jm=t,this.t("nodeSelectionAdornmentTemplate",i,t))}get groupSelectionAdornmentTemplate(){return this.ib}set groupSelectionAdornmentTemplate(t){const i=this.ib;i!==t&&(this.ib=t,this.t("groupSelectionAdornmentTemplate",i,t))}get linkSelectionAdornmentTemplate(){return this.eb}set linkSelectionAdornmentTemplate(t){const i=this.eb;i!==t&&(this.eb=t,this.t("linkSelectionAdornmentTemplate",i,t))}get highlighteds(){return this.tM}get isModified(){const t=this.undoManager;return t.isEnabled?t.currentTransaction!==null?!0:this.Uu&&this.vs!==t.historyIndex:this.Uu}set isModified(t){if(this.Uu!==t){Util.i(t,"boolean",Diagram,"isModified"),this.Uu=t;const e=this.undoManager;!t&&e.isEnabled&&(this.vs=e.historyIndex),t||this.vL()}}vL(){const t=this.isModified;this.ZS!==t&&(this.ZS=t,this.v("Modified"))}get model(){return this.Si}set model(t){const i=this.Si;if(i!==t){this.currentTool.doCancel(),i&&i.undoManager!==t.undoManager&&i.undoManager.isInTransaction&&Util.o("Do not replace a Diagram.model while a transaction is in progress."),this.animationManager.stopAnimation(!0);const e=this.gL(!0);this.Jn=!1,this.vu=!0,this.vs=-2,this.Pr=!1;const s=this.Ht;this.Ht=!0,this.animationManager.Fl("Model"),i&&(this.qn!==null&&this.qn.each(n=>i.removeChangedListener(n)),i.removeChangedListener(this.$S)),this.Si=t,this.partManager=this.cR(this.Si.type),this.initializePartManager(this.partManager);for(let n=0;nt.addChangedListener(n)),this.Ht=s,this.invalidateDocumentBounds(),this.Ht||this.C(),i&&t.undoManager.copyProperties(i.undoManager)}}get themeManager(){return this.gb}set themeManager(t){const i=this.gb;i!==t&&(i!==null&&i.removeDiagram(this),this.gb=t,t!==null&&t.addDiagram(this))}initializePartManager(t){}static gM(t,i){Diagram.hL.set(t,i)}static get licenseKey(){return Diagram.AM.last()}static set licenseKey(t){Diagram.AM.add(t.replace(/\s/g,""))}static get version(){return Diagram.fR}static AM=new List;static fR="3.0.12";cR(t){const i=Diagram.hL.get(t);return i!==null?new i:new PartManager}get Y(){return this.WS}set Y(t){this.WS=t}get mx(){return this.oL}uR(t){if(t.model!==this.model)return;const i=t.change,e=t.propertyName;if(i===1&&e[0]==="S"){if(e==="StartingFirstTransaction"){const s=this,n=this.toolManager;n.mouseDownTools.each(o=>o.diagram=s),n.mouseMoveTools.each(o=>o.diagram=s),n.mouseUpTools.each(o=>o.diagram=s),this.routers.each(o=>o.diagram=s),!this.ps&&!this.Jn&&(this.Oc=!0,this.vu&&(this.Pr=!0))}else if(e==="StartingUndo"||e==="StartingRedo"){const s=this.animationManager;this.skipsUndoManager||(s.defaultAnimation.isAnimating&&s.stopAnimation(),s.getBundleAnimation().isAnimating&&s.getBundleAnimation().stop()),this.v("ChangingSelection",this.selection)}else if(e==="StartedTransaction"){const s=this.animationManager;s.defaultAnimation.isAnimating&&!this.skipsUndoManager&&s.stopAnimation()}return}if(this.Y){this.Y=!1;try{if(t.modelChange===""&&i===1){(e==="FinishedUndo"||e==="FinishedRedo")&&(this.v("ChangedSelection",this.selection),this.Ci());const s=this.animationManager;e==="RolledBackTransaction"&&s.stopAnimation(),this._C(),this.Oc=!0,this.maybeUpdate(),(this.undoManager.transactionLevel===0||this.undoManager.transactionLevel===1)&&s.SS(),e==="CommittedTransaction"&&this.undoManager.isJustDiscarded&&(this.vs=Math.min(this.vs,this.undoManager.historyIndex-1)),(e==="CommittedTransaction"||e==="RolledBackTransaction")&&this.undoManager.Iw&&setTimeout(()=>{this.isModified=!1},1);const n=t.isTransactionFinished;if(n&&(this.vL(),this.mx.clear(),this.animationManager.fF()),!this.Ex&&n&&this.lastInput.targetDiagram){this.Ex=!0;const o=this;Util.Oh(()=>{o.currentTool.standardMouseOver(),o.Ex=!1},10)}}}finally{this.Y=!0}}}get fe(){return this.qS}set fe(t){this.qS=t}get dc(){return this.Bx}set dc(t){this.Bx=t}SL(t){const i=t.L.r;for(const e of i)e instanceof Picture&&this.TM(e)}TM(t){const i=t.element;if(i===null||!(i instanceof HTMLImageElement)||(i.es instanceof GSet&&i.es.add(this),t.dR(),!i.c0))return;const e=i.getAttribute("src")||"",s=this.Jl.get(e);if(s===null){Picture.OL(t,i);const n=[];n.push(t),this.Jl.set(e,n)}else{for(let n=0;n0?(this.kx=t,this.t("minScale",i,t),t>this.scale&&(this.scale=t)):Util._(t,"> 0",Diagram,"minScale"))}get maxScale(){return this.Px}set maxScale(t){const i=this.Px;i!==t&&(t>0?(this.Px=t,this.t("maxScale",i,t),t 0",Diagram,"maxScale"))}get zoomPoint(){return this.Sx}set zoomPoint(t){this.Sx.equals(t)||(t=t.N(),this.Sx=t)}get contentAlignment(){return this.Rc}set contentAlignment(t){const i=this.Rc;i.equals(t)||(t=t.N(),this.Rc=t,this.t("contentAlignment",i,t),this.Us(!1))}get initialContentAlignment(){return this.Um}set initialContentAlignment(t){const i=this.Um;i.equals(t)||(t=t.N(),this.Um=t,this.t("initialContentAlignment",i,t))}get padding(){return this.$t}set padding(t){typeof t=="number"&&(t=new Margin(t));const i=this.$t;i.equals(t)||(t=t.N(),this.$t=t,this.invalidateDocumentBounds(),this.t("padding",i,t))}get partManager(){return this.oM}set partManager(t){const i=this.oM;i!==t&&(t.diagram!==null&&Util.o("Cannot share PartManagers between Diagrams: "+t.toString()),i&&i.To(null),this.oM=t,t.To(this))}get nodes(){return this.partManager.nodes.iterator}get links(){return this.partManager.links.iterator}get parts(){return this.partManager.parts.iterator}findTopLevelNodesAndLinks(){const t=new GSet,i=this.nodes;for(;i.next();){const s=i.value;s.isTopLevel&&t.add(s)}const e=this.links;for(;e.next();){const s=e.value;s.isTopLevel&&t.add(s)}return t.iterator}findTopLevelGroups(){return this.Yr.iterator}get routers(){return this.zc}doLinkRouting(t){this.Fo=!0;const i=this.zc.r;for(let e=0;e0){const l=this.computePartsBounds(n.memberParts,!1);l.inflate(20,20),s.kb(l)}const o=Rect.l(),r=n.memberParts;for(;r.next();){const l=r.value;l instanceof Node&&this.IM(l,e,o)}Rect.s(o)}s.ha=n,s.RM=e,s.Eo=!1}else t&&s.zL();return s}get avoidanceCellSize(){return this.iM}set avoidanceCellSize(t){this.Hl=null,this.iM=new Size(Math.max(1,t.width),Math.max(1,t.height))}get avoidanceLimit(){return this.eM}set avoidanceLimit(t){this.eM=Math.max(1,t)}VL(t){return t.canAvoid()?t:t.containingGroup!==null?this.VL(t.containingGroup):null}IM(t,i,e){if(t===i||!t.isVisible())return;const s=t.canAvoid();if(s){const n=t.getAvoidableRect(e);this.Hl.pR(n.x,n.y,n.width,n.height)}if(t instanceof Group&&(!s||t.avoidableMembers)){const n=t.memberParts;for(;n.next();){const o=n.value;o instanceof Node&&this.IM(o,i,e)}}}EM(t){this.Hl!==null&&!this.Hl.Eo&&(t===void 0||t.canAvoid())&&(this.Hl.Eo=!0)}get autoScrollInterval(){return this.Vm}set autoScrollInterval(t){const i=this.Vm;i!==t&&(this.Vm=t,this.t("autoScrollInterval",i,t))}get autoScrollRegion(){return this.zm}set autoScrollRegion(t){typeof t=="number"&&(t=new Margin(t));const i=this.zm;i.equals(t)||(t=t.N(),this.zm=t,this.invalidateDocumentBounds(),this.t("autoScrollRegion",i,t))}doAutoScroll(t){this.qm.a(t),this.computeAutoScrollPosition(this.qm).equalsApprox(this.position)?this.stopAutoScroll():this.XL()}XL(){if(this.vc!==-1)return;const t=this.Vm,i=this;this.vc=Util.Oh(()=>{if(i.vc===-1||(i.stopAutoScroll(),i.lastInput.event===null))return;const s=i.computeAutoScrollPosition(i.qm);if(s.equalsApprox(i.position))return;i.position=s,i.lastInput.documentPoint=i.transformViewToDoc(i.qm),i.doMouseMove(),i.Zh=!0;const n=Rect.l();i.computeBounds(n),n.unionRect(i.documentBounds),i.IL(n),Rect.s(n),i.Ue=!0,i.maybeUpdate(),i.XL()},t)}stopAutoScroll(){this.vc!==-1&&(Util.Og(this.vc),this.vc=-1)}computeAutoScrollPosition(t){let i=this.position;const e=this.zm;if(e.top<=0&&e.left<=0&&e.right<=0&&e.bottom<=0)return i;const s=this.viewportBounds,n=this.scale,o=Rect.X(0,0,s.width*n,s.height*n),r=Point.X(0,0);if(t.x>=o.x&&t.xo.x+o.width-e.right&&this.allowHorizontalScroll){let l=Math.max(this.scrollHorizontalLineChange,1);l=l|0,r.x+=l,t.x>o.x+o.width-e.right/2&&(r.x+=l),t.x>o.x+o.width-e.right/4&&(r.x+=4*l)}if(t.y>=o.y&&t.yo.y+o.height-e.bottom&&this.allowVerticalScroll){let l=Math.max(this.scrollVerticalLineChange,1);l=l|0,r.y+=l,t.y>o.y+o.height-e.bottom/2&&(r.y+=l),t.y>o.y+o.height-e.bottom/4&&(r.y+=4*l)}return r.equalsApprox(Point.Po)||(i=new Point(i.x+r.x/n,i.y+r.y/n)),Rect.s(o),Point.s(r),i}makeSvg(t){this.Wl.has("SVG")||this.addRenderer("SVG",new SVGSurface(this,root.document));const i=new SVGSurface(this,root.document,!0);t===void 0&&(t={});const e=this;function s(n,o){const r=e.KL(n,"SVG",i),l=r!==null?r.svg:null;return typeof o=="function"?(o(l),null):l}return this.YL(s,t)}makeSVG(t){return this.makeSvg(t)}addRenderer(t,i){this.Wl.set(t,i)}removeRenderer(t){this.Wl.delete(t)}cacheGroupExternalLinks(t){this.dM=t,t||this.nodes.each(i=>{i instanceof Group&&(i.u0=null)})}YL(t,i){const e=i.callback;let s=!0;const o=this.Jl.iterator;for(;o.next();)if(!o.value[0].mn){s=!1;break}if(typeof e!="function"||s)return t(i,e,this);const r=this;function l(){const c=+new Date;for(s=!0,o.reset();o.next();)if(!o.value[0].mn){s=!1;break}if(s||c-a>h){t(i,e,r);return}root.requestAnimationFrame(l)}const h=i.callbackTimeout||300,a=+new Date;return root.requestAnimationFrame(()=>l()),null}makeImage(t){return Diagram.isUsingDOM()?(t===void 0&&(t={}),t.returnType="Image",this.makeImageData(t)):null}makeImageData(t){return t===void 0&&(t={}),this.YL(this.yR,t)}static img="image";yR(t,i,e){const s=e.KL(t,"canvas",null);if(s===null)return null;const n=s.U.canvas;let o=null;if(n!==null){let r=t.returnType;switch(r===void 0?r="string":r=r.toLowerCase(),r){case Diagram.img+"data":o=s.getImageData(0,0,n.width,n.height);break;case Diagram.img:const h=(t.document||document).createElement("img");h.src=n.toDataURL(t.type,t.details),o=h;break;case"blob":{const a=n;return typeof i!="function"&&(o="",Util.o('Error: Diagram.makeImageData called with "returnType: toBlob", but no required "callback" function property defined.')),typeof a.toBlob=="function"?(a.toBlob(i,t.type,t.details),"toBlob"):(i(null),null)}case"string":default:o=n.toDataURL(t.type,t.details)}}return typeof i=="function"?(i(o),null):o}static wR=!1;KL(t,i,e){if(this.animationManager.stopAnimation(),this.maybeUpdate(),this.dt===null)return null;typeof t!="object"&&Util.o("properties argument must be an Object.");let n=!1,o=t.size||null,r=t.scale||null;t.scale!==void 0&&isNaN(t.scale)&&(r="NaN");let l=t.maxSize;t.maxSize===void 0&&(n=!0,i==="SVG"?l=new Size(1/0,1/0):l=new Size(2e3,2e3));const h=t.position||null;let a=t.parts||null;Array.isArray(a)&&(a=new List(a));let c=t.padding===void 0?1:t.padding;const f=t.background||null;let u=t.omitTemporary;u===void 0&&(u=!0);const d=t.document||document,m=t.elementFinished||null;let g=t.showTemporary;g===void 0&&(g=!u);let p=t.showGrid;p===void 0&&(p=g),o!==null&&isNaN(o.width)&&isNaN(o.height)&&(o=null),typeof c=="number"?c=new Margin(c):c instanceof Margin||Util.o("MakeImage padding must be a Margin or a number."),c.left=Math.max(c.left,0),c.right=Math.max(c.right,0),c.top=Math.max(c.top,0),c.bottom=Math.max(c.bottom,0),this.Zt.clearContextCache(!0);const y=new CanvasSurface(null,d,void 0,!0),x=y.ai;if(!(o||r||a||h))return y.width=this.kt+Math.ceil(c.left+c.right),y.height=this.Pt+Math.ceil(c.top+c.bottom),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.aa=d,e.Gu=m,this.wb(e.ai,c,new Size(y.width,y.height),this.et,this.at,a,f,g,p),e.ai):(this.Vu=!1,this.wb(x,c,new Size(y.width,y.height),this.et,this.at,a,f,g,p),this.Vu=!0,y.ai);const k=this.Jm,b=this.documentBounds.copy();if(b.subtractMargin(this.$t),g){const A=this.Gt.r,D=A.length;for(let F=0;Fk?(r=k,N=b.width,T=b.height):(N=l.width,T=l.height)):(N=b.width*r,T=b.height*r):(r=k,N=b.width,T=b.height),c!==null?(N+=S,T+=L):c=new Margin(0),l!==null){let A=l.width,D=l.height;i!=="SVG"&&n&&Diagram.wR,isNaN(A)&&(A=2e3),isNaN(D)&&(D=2e3),isFinite(A)&&(N=Math.min(N,A)),isFinite(D)&&(T=Math.min(T,D))}return y.width=Math.ceil(N),y.height=Math.ceil(T),i==="SVG"?e===null?null:(e.resize(y.width,y.height,y.width,y.height),e.aa=d,e.Gu=m,this.wb(e.ai,c,new Size(Math.ceil(N),Math.ceil(T)),r,P,a,f,g,p),e.ai):(this.Vu=!1,this.wb(x,c,new Size(Math.ceil(N),Math.ceil(T)),r,P,a,f,g,p),this.Vu=!0,y.ai)}static Ku=null;static GL="5da73c80a36555d4038e4972187c3cae51fd22";static uw=!1;static Ik=()=>{if(Diagram.GL[5]===void 0&&(Transform.prototype._e=Transform.prototype.ww),!Diagram.isUsingDOM())return;const t=root.document.createElement("canvas"),i=t.getContext("2d"),e=Util.Cs("7ca11abfd022028846");i[e]=Util.Cs("398c3597c01238");const s="7ca11abfd7330390",n=[Diagram.GL,Util.uw+"4ae6247590da4bb21c324ba3a84e385776",Transform.Ik+"fb236cdfda5de14c134ba1a95a2d4c7cc6f93c1387",Geo.za],o=10,r=0;for(let l=1;l<5;l++)i[Util.Cs(s)](Util.Cs(n[l-1]),o,l*15+r);i[e]=Util.Cs("39f046ebb36e4b");for(let l=1;l<5;l++)i[Util.Cs(s)](Util.Cs(n[l-1]),o,l*15+r);(n.length!==4||n[0][0]!=="5"||n[3][0]!=="7")&&(Transform.prototype._e=Transform.prototype.ww),Diagram.Ku=t}}class DiagramHelper{jL;HL;BM;Ne;constructor(t){if(this.jL=null,this.HL="63ad05bbe23a1786468a4c741b6d2",this.BM="@onz",this.HL===this._tk){this.BM=!0,this.Ne=this.BM;return}this.Ne=null}xR(t,i){let e="f";const s=root[Util.Cs("76a715b2f73f148a")][Util.Cs("72ba13b5")]||"",n=Util.Cs;if(this.Ne=!0,!Diagram.isUsingDOM())return;let o=Diagram[n("76a115b6ed251eaf4692")];if(!o){const l=s[n("76ad18b4f73e")];for(let a=s[n("73a612b6fb191d")](n("35e7"))+2;a=0&&ha[0]||h[0]===a[0]&&h[1]>=a[1]))continue;const c="73a612b6fb191d",f=root[n("74a900bae4370f8b51")][n("6fbb13a1c2311e8a57")].toLowerCase(),u=f[n(c)](n("3aad1ab6e022098b4dc4")),d=n(l[2]);if(u>-1){const M=f[n(c)](d.toLowerCase()+"/");if(this.Ne=!(M>-1&&M=0&&g-1),!this.Ne))return;const p=root[Util.Cs("76a715b2f73f148a")][Util.Cs("69ad17a1e03e")],y=p[n(c)](n("7fb002b6ed25128b4da25b2e"));if(y>-1&&(this.Ne=!(p[n(c)](d)>y),!this.Ne))return;const x=d;if(x[0]!=="#")continue;const k=root.document.createElement("div");let b=l[0].replace(/[A-Za-z]/g,"");for(;b.length<4;)b+="9";const P=b;b=b.substring(b.length-4);let S="";const L=["gsh","gsf"],C=["Header","Background","Display","Feedback"];if(S+=L[parseInt(b.substring(0,1),10)%2],S+=C[parseInt(b.substring(0,1),10)%4],k[n("79a417a0f0181a8946")]=S,root.document[n("78a712aa")]){root.document[n("78a712aa")][n("7bb806b6ed32388c4a875b")](k);const M=root.getComputedStyle(k).getPropertyValue(n("78a704b7e62456904c9b12701b6532a8")),N=root.getComputedStyle(k).getPropertyValue(n("75b817b0ea2202"));if(root.document[n("78a712aa")][n("68ad1bbcf533388c4a875b")](k),!M)continue;const T=root[n("77a902b0eb1b1e804a8a")],A="0."+parseInt(P,10)%100;if(N===A||M.indexOf(parseInt(x[1]+x[2],16))!==-1&&M.indexOf(parseInt(x[3]+x[4],16))!==-1){this.Ne=!1;return}else if(T&&T(n("32ae19a1e0331fc94084537c067a67fa59f1386b89d006")).matches){S="."+S;for(let D=0;D{const s=this.observed;if(s===null)return;const n=s.viewportBounds,o=this.lastInput.documentPoint;s.position=new Point(o.x-n.width/2,o.y-n.height/2)},this.zM=s=>{this.invalidateDocumentBounds(),this.g0()},this.XM=s=>{this.observed!==null&&(this.invalidateDocumentBounds(),this.C())},this.Cb=s=>{this.updateDelay<1?this.C():this.d0||(this.d0=!0,setTimeout(()=>this.redraw(),this.updateDelay))},this.KM=s=>{this.observed!==null&&this.g0()},this.autoScale=2,this.Ht=!1,i&&Object.assign(this,i),this}setupRouters(){}computePixelRatio(){return 1}redraw(){this.d0&&this.updateDelay>=1&&(this.d0=!1,this.bR()),super.redraw()}Gi(){if(this.Tt===null&&Util.o("No div specified"),this.dt===null&&Util.o("No canvas specified"),this.dt instanceof SVGSurface||(this.box.US(),!this.Ue))return;const t=this.observed;if(t===null||t.animationManager.defaultAnimation.isAnimating||!t.Bh)return;this.l0();const i=this.dt,e=this.Zt;if(e.clearContextCache(!0),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,i.width,i.height),this.updateDelay<1)this.WL();else if(this.jc!==null){e.drawImage(this.jc.Ft,0,0);const o=this.D;e.scale(this.Ui,this.Ui),e.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),e.commitTransform()}const s=this.Gt.r,n=s.length;for(let o=0;on.canDelete())}t.removeParts(i,!0),t.v("SelectionDeleted",i)}finally{t.commitTransaction("Delete"),t.v("ChangedSelection",t.selection),t.currentCursor=""}}canDeleteSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowDelete||t.selection.count===0)}copySelection(){const t=this.diagram;try{const i=new GSet,e=t.selection.iterator;for(;e.next();){const s=e.value;Part.sh(i,s,!0,this.copiesTree?1/0:0,this.copiesConnectedLinks,n=>n.canCopy())}this.copyToClipboard(i)}finally{}}canCopySelection(){const t=this.diagram;return!(!t.allowCopy||!t.allowClipboard||t.selection.count===0)}cutSelection(){this.copySelection(),this.deleteSelection()}canCutSelection(){const t=this.diagram;return!(t.isReadOnly||t.isModelReadOnly||!t.allowCopy||!t.allowDelete||!t.allowClipboard||t.selection.count===0)}copyToClipboard(t){const i=this.diagram;let e=null;if(t===null)Diagram.dL();else{const s=i.model;let n=!1,o=!1,r=null;try{s.pc()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.gc()||s.ju())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=i.copyParts(t,null,!0)}finally{s.pc()&&(s.copiesParentKeyOfNodeData=n),(s.gc()||s.ju())&&(s.copiesGroupKeyOfNodeData=o),e=new List,e.addAll(r.iteratorValues),Diagram.e0=e,Diagram.mb=i.model.dataFormat}}i.v("ClipboardChanged",e)}pasteFromClipboard(){const t=new GSet,i=Diagram.e0;if(i===null)return t;const e=this.diagram;if(Diagram.mb!==e.model.dataFormat)return t;const s=e.model;let n=!1,o=!1,r=null;try{s.pc()&&(n=s.copiesParentKeyOfNodeData,s.copiesParentKeyOfNodeData=this.copiesParentKey),(s.gc()||s.ju())&&(o=s.copiesGroupKeyOfNodeData,s.copiesGroupKeyOfNodeData=this.copiesGroupKey),r=e.copyParts(i,e,!1)}finally{s.pc()&&(s.copiesParentKeyOfNodeData=n),(s.gc()||s.ju())&&(s.copiesGroupKeyOfNodeData=o);const l=r.iterator;for(;l.next();){const h=l.value,a=l.key;h.location.isReal()||(a.location.isReal()?h.location=a.location:!h.position.isReal()&&a.position.isReal()&&(h.position=a.position)),t.add(h)}}return t}pasteSelection(t){t===void 0&&(t=null);const i=this.diagram;try{i.currentCursor="wait",i.v("ChangingSelection",i.selection),i.startTransaction("Paste");const e=this.pasteFromClipboard();e.count>0&&i.clearSelection(!0);const s=e.iterator;for(;s.next();){const n=s.value;n.isSelected=!0}if(t!==null){const n=i.computePartsBounds(i.selection);if(n.isReal()){const o=this.computeEffectiveCollection(i.selection,i.fb);i.bP(o,new Point(t.x-n.centerX,t.y-n.centerY),i.fb,!1)}}i.v("ClipboardPasted",e)}finally{i.commitTransaction("Paste"),i.v("ChangedSelection",i.selection),i.currentCursor=""}}canPasteSelection(t){const i=this.diagram;return!(i.isReadOnly||i.isModelReadOnly||!i.allowInsert||!i.allowClipboard||Diagram.e0===null||Diagram.e0.count===0||Diagram.mb!==i.model.dataFormat)}undo(){this.diagram.undoManager.undo()}canUndo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canUndo()}redo(){this.diagram.undoManager.redo()}canRedo(){const t=this.diagram;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canRedo()}decreaseZoom(t){t===void 0&&(t=1/this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canDecreaseZoom(t){t===void 0&&(t=1/this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}increaseZoom(t){t===void 0&&(t=this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return;const e=i.scale*t;ei.maxScale||(i.scale=e)}canIncreaseZoom(t){t===void 0&&(t=this.zoomFactor);const i=this.diagram;if(i.autoScale!==1)return!1;const e=i.scale*t;return ei.maxScale?!1:i.allowZoom}resetZoom(t){t===void 0&&(t=this.defaultScale);const i=this.diagram;ti.maxScale||(i.scale=t)}canResetZoom(t){t===void 0&&(t=this.defaultScale);const i=this.diagram;return ti.maxScale?!1:i.allowZoom}zoomToFit(){const t=this.diagram,i=t.animationManager;i.stopAnimation(),t.redraw();const e=t.position,s=t.scale;i.Fl("Zoom To Fit"),this.isZoomToFitRestoreEnabled&&s===this.Ab&&!isNaN(this.Lb)&&t.documentBounds.equals(this.Tb)?(t.scale=this.Lb,t.position=this.QM,this.Ab=NaN,this.Tb=Rect.pw):(this.Lb=s,this.QM=e.copy(),t.zoomToFit(),this.Ab=t.scale,this.Tb=t.documentBounds.copy()),i.SS()}canZoomToFit(){return this.diagram.allowZoom}scrollToPart(t){t===void 0&&(t=null);const i=this.diagram;if(i.ensureBounds(),t===null){try{this.Bo!==null&&(this.Bo.next()?t=this.Bo.value:this.Bo=null)}catch{this.Bo=null}t===null&&(i.highlighteds.count>0?this.Bo=i.highlighteds.iterator:i.selection.count>0&&(this.Bo=i.selection.iterator),this.Bo!==null&&this.Bo.next()&&(t=this.Bo.value))}if(t!==null){const e=i.animationManager;e.Fl("Scroll To Part");const s=this.scrollToPartPause;if(s>0){const n=this.Hc(t,[t]);if(n.length===1)i.startTransaction(),i.centerRect(t.actualBounds),i.commitTransaction("Scroll To Part");else{const o=()=>{i.startTransaction();let l=n.pop();for(;n.length>0&&l instanceof Node&&l.isTreeExpanded&&(!(l instanceof Group)||l.isSubGraphExpanded);)l=n.pop();n.length>0?(l instanceof Part&&i.scrollToRect(l.actualBounds),l instanceof Node&&!l.isTreeExpanded&&(l.isTreeExpanded=!0),l instanceof Group&&!l.isSubGraphExpanded&&(l.isSubGraphExpanded=!0)):(l instanceof Part&&i.centerRect(l.actualBounds),i.removeDiagramListener("LayoutCompleted",r)),i.commitTransaction("Scroll To Part")},r=()=>{Util.Oh(o,(e.isEnabled?e.duration:0)+s)};i.addDiagramListener("LayoutCompleted",r),o()}}else{const n=i.position.copy();i.centerRect(t.actualBounds),n.equalsApprox(i.position)&&e.stopAnimation()}}}Hc(t,i){if(t.isVisible())return i;if(t instanceof Adornment)this.Hc(t.adornedPart,i);else if(t instanceof Link){const e=t.fromNode;e!==null&&this.Hc(e,i);const s=t.toNode;s!==null&&this.Hc(s,i)}else{if(t instanceof Node){const s=t.labeledLink;s!==null&&this.Hc(s,i);const n=t.findTreeParentNode();n!==null&&(!n.isTreeExpanded&&!n.wasTreeExpanded&&i.push(n),this.Hc(n,i))}const e=t.containingGroup;e!==null&&(!e.isSubGraphExpanded&&!e.wasSubGraphExpanded&&i.push(e),this.Hc(e,i))}return i}canScrollToPart(t){if(t===void 0&&(t=null),t!==null&&!(t instanceof Part))return!1;const i=this.diagram;return i.selection.count===0&&i.highlighteds.count===0?!1:i.allowHorizontalScroll&&i.allowVerticalScroll}collapseTree(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse Tree";try{i.startTransaction(e),i.animationManager.Fl(e);const n=new List;if(t!==null&&t.isTreeExpanded)t.collapseTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&r.isTreeExpanded&&(r.collapseTree(),n.add(r))}}i.v("TreeCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||!t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(!s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}expandTree(t){t===void 0&&(t=null);const i=this.diagram,e="Expand Tree";try{i.startTransaction(e),i.animationManager.Fl(e);const n=new List;if(t!==null&&!t.isTreeExpanded)t.expandTree(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Node&&(r.isTreeExpanded||(r.expandTree(),n.add(r)))}}i.v("TreeExpanded",n)}finally{i.commitTransaction(e)}}canExpandTree(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null){if(!(t instanceof Node)||t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Node){if(s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}groupSelection(){const t=this.diagram,i=t.model;if(!i.qc())return;const e=this.archetypeGroupData;if(e===null)return;let s=null;try{t.currentCursor="wait",t.v("ChangingSelection",t.selection),t.startTransaction("Group");const n=new List,o=t.selection.iterator;for(;o.next();){const h=o.value;h.Pe()&&h.canGroup()&&n.add(h)}const r=new List,l=n.iterator;for(;l.next();){const h=l.value;let a=!1;const c=n.iterator;for(;c.next();){const f=c.value;if(h.isMemberOf(f)){a=!0;break}}a||r.add(h)}if(r.count>0){let h=r.first().containingGroup;if(h!==null)for(;h!==null;){let a=!1;const c=r.iterator;for(;c.next();)if(!c.value.isMemberOf(h)){a=!0;break}if(a)h=h.containingGroup;else break}if(e instanceof Group)e.li(),s=e.copy(),s!==null&&t.add(s);else if(i.isGroupForData(e)){const a=i.copyNodeData(e);Util.wt(a)&&(i.addNodeData(a),s=t.findNodeForData(a))}if(s!==null){h!==null&&this.isValidMember(h,s)&&(s.containingGroup=h);const a=r.iterator;for(;a.next();){const c=a.value;this.isValidMember(s,c)&&(c.containingGroup=s)}t.clearSelection(!0),s.isSelected=!0}}t.v("SelectionGrouped",s)}finally{t.commitTransaction("Group"),t.v("ChangedSelection",t.selection),t.currentCursor=""}}canGroupSelection(){const t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowGroup||!t.model.qc()||this.archetypeGroupData===null)return!1;const e=t.selection.iterator;for(;e.next();){const s=e.value;if(s.Pe()&&s.canGroup())return!0}return!1}i2(t){const i=Util.nt();if(Array.isArray(t))t.forEach(n=>{n instanceof Link||n instanceof Part&&i.push(n)});else{const n=t.iterator;for(;n.next();){const o=n.value;o instanceof Link||o instanceof Part&&i.push(o)}}const e=new GSet,s=i.length;for(let n=0;n0){i.clearSelection(!0);const o=s.iterator;for(;o.next();){const r=o.value;r.expandSubGraph();const l=r.containingGroup,h=l!==null&&l.data!==null?e.getKeyForNodeData(l.data):void 0;n.addAll(r.memberParts);const a=n.iterator;for(;a.next();){const c=a.value;if(c.isSelected=!0,c instanceof Link)continue;const f=c.data;f!==null?e.setGroupForData(f,h):c.containingGroup=l}i.remove(r)}}i.v("SelectionUngrouped",s,n)}finally{i.commitTransaction("Ungroup"),i.v("ChangedSelection",i.selection),i.currentCursor=""}}canUngroupSelection(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowDelete||!i.allowUngroup||!i.model.qc())return!1;if(t!==null){if(!(t instanceof Group))return!1;if(t.canUngroup())return!0}else{const s=i.selection.iterator;for(;s.next();){const n=s.value;if(n instanceof Group&&n.canUngroup())return!0}}return!1}addTopLevelParts(t,i){const e=this.i2(t);let s=!0;const n=e.iterator;for(;n.next();){const o=n.value;o.containingGroup!==null&&(!i||this.isValidMember(null,o)?o.containingGroup=null:s=!1)}return s}collapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Collapse SubGraph";try{i.startTransaction(e),i.animationManager.Fl(e);const n=new List;if(t!==null&&t.isSubGraphExpanded)t.collapseSubGraph(),n.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&r.isSubGraphExpanded&&(r.collapseSubGraph(),n.add(r))}}i.v("SubGraphCollapsed",n)}finally{i.commitTransaction(e)}}canCollapseSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||!t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&s.isSubGraphExpanded)return!0}}return!1}expandSubGraph(t){t===void 0&&(t=null);const i=this.diagram,e="Expand SubGraph",s=new List;try{if(i.startTransaction(e),i.animationManager.Fl(e),t!==null&&!t.isSubGraphExpanded)t.expandSubGraph(),s.add(t);else if(t===null){const o=i.selection.iterator;for(;o.next();){const r=o.value;r instanceof Group&&(r.isSubGraphExpanded||(r.expandSubGraph(),s.add(r)))}}i.v("SubGraphExpanded",s)}finally{for(const n of s)this.JL(i,n);t&&this.JL(i,t),i.commitTransaction(e)}}JL(t,i){for(const e of i.memberParts)e instanceof Node&&t.Cc(e,i)}canExpandSubGraph(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly)return!1;if(t!==null)return!(!(t instanceof Group)||t.isSubGraphExpanded);{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s instanceof Group&&!s.isSubGraphExpanded)return!0}}return!1}editTextBlock(t){t===void 0&&(t=null);const i=this.diagram,e=i.toolManager.findTool("TextEditing");if(e!==null){if(t===null){let s=null;const n=i.selection.iterator;for(;n.next();){const o=n.value;if(o.canEdit()){s=o;break}}if(s===null)return;t=s.findInVisualTree(o=>o instanceof TextBlock&&o.editable)}t!==null&&(i.currentTool=null,e.textBlock=t,i.currentTool=e)}}canEditTextBlock(t){t===void 0&&(t=null);const i=this.diagram;if(i.isReadOnly||i.isModelReadOnly||!i.allowTextEdit||i.toolManager.findTool("TextEditing")===null)return!1;if(t!==null){if(!(t instanceof TextBlock))return!1;const e=t.part;if(e!==null&&e.canEdit())return!0}else{const e=i.selection.iterator;for(;e.next();){const s=e.value;if(s.canEdit()&&(t=s.findInVisualTree(n=>n instanceof TextBlock&&n.editable),t!==null))return!0}}return!1}showContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");if(e===null)return;t===void 0&&(i.selection.count>0?t=i.selection.first():t=i);const s=e.findObjectWithContextMenu(t);if(s!==null){const n=i.lastInput;let o=null;if(s instanceof GraphObject)o=s.getDocumentPoint(Spot.Center);else if(!i.viewportBounds.containsPoint(n.documentPoint)){const r=i.viewportBounds;o=new Point(r.x+r.width/2,r.y+r.height/2)}if(o!==null){const r=new InputEvent;r.diagram=i,r.viewPoint=i.transformDocToView(o),r.documentPoint=o,r.button=2,r.up=!0,i.lastInput=r}i.currentTool=e,e.openMenu(!1,s)}}canShowContextMenu(t){const i=this.diagram,e=i.toolManager.findTool("ContextMenu");return!(e===null||(t===void 0&&(i.selection.count>0?t=i.selection.first():t=i),e.findObjectWithContextMenu(t)===null))}get copiesClipboardData(){return this.YM}set copiesClipboardData(t){Util.i(t,"boolean",CommandHandler,"copiesClipboardData"),this.YM=t}get copiesConnectedLinks(){return this.GM}set copiesConnectedLinks(t){Util.i(t,"boolean",CommandHandler,"copiesConnectedLinks"),this.GM=t}get deletesConnectedLinks(){return this.jM}set deletesConnectedLinks(t){Util.i(t,"boolean",CommandHandler,"deletesConnectedLinks"),this.jM=t}get copiesTree(){return this.HM}set copiesTree(t){Util.i(t,"boolean",CommandHandler,"copiesTree"),this.HM=t}get deletesTree(){return this.qM}set deletesTree(t){Util.i(t,"boolean",CommandHandler,"deletesTree"),this.qM=t}get copiesParentKey(){return this.WM}set copiesParentKey(t){Util.i(t,"boolean",CommandHandler,"copiesParentKey"),this.WM=t}get copiesGroupKey(){return this.JM}set copiesGroupKey(t){Util.i(t,"boolean",CommandHandler,"copiesGroupKey"),this.JM=t}get archetypeGroupData(){return this.$M}set archetypeGroupData(t){t!==null&&Util.i(t,"object",CommandHandler,"archetypeGroupData");const i=this.diagram;this.$M=t}get memberValidation(){return this.eh}set memberValidation(t){t!==null&&Util.i(t,"function",CommandHandler,"memberValidation"),this.eh=t}get defaultScale(){return this.diagram.defaultScale}set defaultScale(t){this.diagram.defaultScale=t}get zoomFactor(){return this.ZM}set zoomFactor(t){t>1||Util.o("zoomFactor must be larger than 1.0, not: "+t),this.ZM=t}get isZoomToFitRestoreEnabled(){return this._M}set isZoomToFitRestoreEnabled(t){Util.i(t,"boolean",CommandHandler,"isZoomToFitRestoreEnabled"),this._M=t}get scrollToPartPause(){return this.t2}set scrollToPartPause(t){this.t2=t}computeEffectiveCollection(t,i){const e=this.diagram,s=e.toolManager.findTool("Dragging"),n=e.currentTool===s;i===void 0&&(i=e.a0());const o=new GMap;if(t===null)return o;let r=t.iterator;for(;r.next();){const l=r.value;e.Wr(o,l,n,i)}if(e.draggedLink!==null&&i.dragsLink)return o;for(r=t.iterator;r.next();){const l=r.value;if(l instanceof Link){const h=l.fromNode;if(h!==null&&!o.has(h))o.delete(l);else{const a=l.toNode;a!==null&&!o.has(a)&&o.delete(l)}}}return o}}var Stretch=(w=>(w[w.None=0]="None",w[w.Default=1]="Default",w[w.Vertical=4]="Vertical",w[w.Horizontal=5]="Horizontal",w[w.Fill=2]="Fill",w))(Stretch||{}),Orientation=(w=>(w[w.None=0]="None",w[w.Along=21]="Along",w[w.Plus90=22]="Plus90",w[w.Minus90=23]="Minus90",w[w.Opposite=24]="Opposite",w[w.Upright=25]="Upright",w[w.Plus90Upright=26]="Plus90Upright",w[w.Minus90Upright=27]="Minus90Upright",w[w.Upright45=28]="Upright45",w))(Orientation||{}),Flip=(w=>(w[w.None=0]="None",w[w.Vertical=1]="Vertical",w[w.Horizontal=2]="Horizontal",w[w.Both=3]="Both",w))(Flip||{});class GraphObject{n;Hu;qu;Uo;f;nh;q;at;se;Wt;Wu;Vs;Ct;ze;$r;oh;bi;ca;et;Xt;Zr;Li;Vi;Ju;oi;Wc;Bt;ni;Qr;Db;rh;$u;constructor(){GSet.Yi(this),this.n=30723,this.Wt=1,this.Wu="",this.Vs=null,this.Ct=null,this.at=new Point(NaN,NaN).g(),this.ze=Size.gw,this.$r=new Transform,this.oh=new Transform,this.bi=null,this.ca=1,this.et=1,this.Xt=0,this.Zr=Margin.Eg,this.se=new Rect(NaN,NaN,NaN,NaN).g(),this.Li=new Rect(NaN,NaN,NaN,NaN).g(),this.Vi=new Rect(0,0,NaN,NaN).g(),this.Ju=null,this.Hu=null,this.q=null,this.oi=Spot.Default,this.Wc=Spot.Default,this.qu=0,this.Uo=0,this.Bt=null,this.f=null,this.nh=null,this.ni=null,this.Db=null,this.rh=null,this.Qr=null,this.$u=null}cloneProtected(t){t.n=(this.n|2048|4096)&-32769,t.Wt=this.Wt,t.Wu=this.Wu,t.Ct=this.Ct,t.at.a(this.at),t.ze=this.ze.N(),this.bi!==null?t.bi=this.bi.copy():t.bi=null,t.et=this.et,t.Xt=this.Xt,t.Zr=this.Zr.N(),t.se.a(this.se),t.Li.a(this.Li),t.Vi.a(this.Vi),t.Hu=this.Hu,this.q!==null&&(t.q=this.q.copy()),t.oi=this.oi.N(),t.Wc=this.Wc.N(),t.qu=this.qu,t.Uo=this.Uo,this.Bt!==null&&(t.Bt=this.Bt.copy()),this.f!==null&&(this.f.gi?t.f=this.f:t.f=this.f.copy()),this.nh!==null&&(t.nh=this.nh.slice()),this.ni!==null&&(t.ni=this.ni.copy())}addCopyProperty(t){let i=this.nh;if(!Array.isArray(i))i=[],this.nh=i;else for(let e=0;e{d.data!==null&&d.e2()&&d.updateTargetBindings(i)})}}}}gF(t){this.$u.delete(t)}Io(){if(this.diagram===null)return;if(this.findBindingPanel()===null&&this.Ai!==null){const i=this.Ai.iterator;for(;i.next();){const e=i.value;if(!e.isToTheme)continue;let s=null;const n=e.sourceName;e.isToObject&&(s=this.$L(n));let o=this;const r=e.targetId;r!==-1&&(o=this.m0(r),o===null)||(n==="/"?s=o.part:n==="."?s=o:n===".."&&(s=o.panel),e.updateTarget(o,s))}}}ya(t,i){const e=this.findBindingPanel();if(e!==null){const s=this.Ai.iterator;for(;s.next();){const n=s.value;let o=null;if(n.isToObject){if(o=n.ZL(e,this),o===null)continue;n.updateSource(this,o,i,null)}else if(n.isToModel){const r=t.diagram;r!==null&&!r.fe&&n.updateSource(this,r.model.modelData,i,e)}else if(!n.isToTheme){const r=e.data;if(r===null)continue;const l=t.diagram;l!==null&&!l.fe&&n.updateSource(this,r,i,e)}if(o===this){const r=n.targetId,l=e.m0(r);l!==null&&n.updateTarget(l,o,i)}}}}m0(t){return this.$n===t?this:null}$L(t){let i;return t===""?i=this:t==="/"?i=this:t==="."?i=this:t===".."?i=this:i=this.part.findObject(t),i}get $n(){return this.f!==null?this.f.$n:-1}set $n(t){this.$n!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.$n=t)}get Ai(){return this.f!==null?this.f.Ai:null}set Ai(t){this.Ai!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.Ai=t)}get Zn(){return this.f!==null?this.f.Zn:null}set Zn(t){this.Zn!==t&&(this.f===null&&(this.f=new GraphObjectTemplateSettings),this.f.Zn=t)}raiseChanged(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}t(t,i,e){this.raiseChangedEvent(2,t,this,i,e)}Qn(t,i,e,s){const n=this.se;if(n.e(t,i,e,s),this.et!==1||this.Xt!==0){this.bi===null&&(this.bi=new Transform);const o=this.bi;o.Ri(),this.p0(o,t,i,e,s),o.xw(n)}}QL(t,i,e){return this.pickable===!1?!1:(e.ic(this.D),i?this.intersectsRect(t,e):this.containedInRect(t,e))}_L(t,i,e){if(this.pickable===!1)return!1;const s=this.naturalBounds,n=t.distanceSquaredPoint(i);return e?Point.distanceLineSegmentSquared(t.x,t.y,0,0,0,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,0,s.height,s.width,s.height)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,s.height,s.width,0)<=n||Point.distanceLineSegmentSquared(t.x,t.y,s.width,0,0,0)<=n:t.distanceSquared(0,0)<=n&&t.distanceSquared(0,s.height)<=n&&t.distanceSquared(s.width,0)<=n&&t.distanceSquared(s.width,s.height)<=n}pn(){return!0}containsPoint(t){const i=Point.l();i.a(t),this.D.xt(i);const e=this.actualBounds;if(!e.isReal())return Point.s(i),!1;const s=this.diagram;if(s!==null&&s.Zm){const o=s.getInputOption("extraTouchThreshold"),r=s.getInputOption("extraTouchArea"),l=r/2,h=this.naturalBounds,a=this.getDocumentScale()*s.scale,c=1/a;if(h.width*ae&&(f=t),isFinite(i)&&i>s&&(u=i);break;case 5:isFinite(t)&&t>e&&(f=t),u=0,d&&(i=1/0);break;case 4:isFinite(i)&&i>s&&(u=i),f=0,d&&(t=1/0);break}const g=this.maxSize,p=this.minSize;f>g.width&&p.widthg.height&&p.heightu.height||this.mi>u.width)&&(r=!0)}}}r?this.n|=256:this.n&=-257,this.Li.isReal()||Util.o("Non-real actualBounds has been set. Object "+this+", actualBounds: "+this.Li.toString()),this.td(o,this.Li),this._n(!1),Rect.s(o)}ah(t,i,e,s){}commonArrange(t,i,e,s){if(this.Li.e(t,i,e,s),this.desiredSize.isReal())return;const n=this.se,o=this.Zr,r=o.right+o.left,l=o.top+o.bottom,h=n.width+r,a=n.height+l;e+=r,s+=l;let c=this.zs(!0);switch(h===e&&a===s&&(c=0),c){case 0:(h>e||a>s)&&(this.ue(!0),this.ut(h>e?e:h,a>s?s:a,0,0));break;case 2:this.ue(!0),this.ut(e,s,0,0);break;case 5:this.ue(!0),this.ut(e,a,0,0);break;case 4:this.ue(!0),this.ut(h,s,0,0);break}}td(t,i){const e=this.part;e!==null&&e.diagram!==null&&((e.selectionObject===this||e.resizeObject===this||e.rotateObject===this)&&e.s2(!0),this.C(),!t.equalsApproxClose(i)&&(e.ch(),this.b0(e)))}b0(t){this.portId!==null&&(t.s2(!0),t instanceof Node&&t.tA(this))}get shadowVisible(){return this.f!==null?this.f.k0:null}set shadowVisible(t){const i=this.shadowVisible;i!==t&&(this.jt(),this.f.k0=t,this.ss(!0),this.C(),this.t("shadowVisible",i,t))}SR(t,i){const e=this.naturalBounds,s=this.oh,n=s.m11,o=s.m21,r=s.dx,l=s.m12,h=s.m22,a=s.dy;let c=0,f=0,u=c,d=f;c=u*n+d*o+r,f=u*l+d*h+a;let m=c,g=f,p=0,y=0;u=e.width+i,d=0,c=u*n+d*o+r,f=u*l+d*h+a;let x=Math.min(m,c),k=Math.min(g,f);p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-k,m=x,g=k,u=e.width+i,d=e.height+i,c=u*n+d*o+r,f=u*l+d*h+a,x=Math.min(m,c),k=Math.min(g,f),p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-k,m=x,g=k,u=0,d=e.height+i,c=u*n+d*o+r,f=u*l+d*h+a,x=Math.min(m,c),k=Math.min(g,f),p=Math.max(m+p,c)-x,y=Math.max(g+y,f)-k,m=x,g=k;const b=t.viewportBounds,P=b.x,S=b.y,L=b.width,C=b.height;return m>L+P||P>p+m||g>C+S||S>y+g}Gi(t,i){if(this.MR(t,i)||!this.visible)return;const e=this.opacity;if(e===0)return;let s=1;e!==1&&(s=t.globalAlpha,t.globalAlpha=s*e);let n="";this.filter!==""&&(n=t.filter,t.filter=this.filter);const o=this.D,r=this.panel;this.y0()===!0&&this.Fb();const l=this.part;let h=!1,a=0;if(l&&i.getRenderingHint("drawShadows")&&(h=l.isShadowed,h)){const g=l.shadowOffset;a=Math.max(g.y,g.x)*i.scale*i.Ui}const c=this instanceof Panel&&this._r(),f=this.Li;if(c&&(this.iA(h,t,!1,r),this.NR(t,i),this.eA(h,t,!1,r),this.sA(h,t,!1)),c||!c&&(f.width===0||f.height===0||isNaN(f.x)||isNaN(f.y))){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}const u=this.Xs();if(!i.Qh&&u&&this.SR(i,a)){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}let d=(this.n&256)!==0;if(t.clipInsteadOfFill&&(d=!1),this instanceof TextBlock&&(t.font=this.font),d){const g=r.pn()?r.naturalBounds:r.actualBounds;let p=Math.max(f.x,g.x),y=Math.max(f.y,g.y),x=Math.min(f.right,g.right)-p,k=Math.min(f.bottom,g.bottom)-y;const b=this.ni;if(b!==null&&(p=b.x,y=b.y,x=b.width,k=b.height),p>f.width+f.x||f.x>g.width+g.x){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}t.save(),t.beginPath(),t.rect(p,y,x,k),t.clip()}if(u){if(!l.isVisible()){e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}if(h){const g=l.shadowOffset;t.shadowsSet(g.x*i.scale*this.scale*i.Ui,g.y*i.scale*this.scale*i.Ui,l.shadowBlur),t.shadowsOn(),t.shadowColor=l.shadowColor}}const m=this.naturalBounds;if(t.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.iA(h,t,u,r),this.Ct!==null&&(t.commitTransform(),this.Rb(t,m,f)),this.eA(h,t,u,r),this.fh(t,i),this.sA(h,t,u),d&&(t.restore(),t.clearContextCache(this instanceof Panel)),!o.Ok()){const g=1/(o.m11*o.m22-o.m12*o.m21);t.transform(o.m22*g,-o.m12*g,-o.m21*g,o.m11*g,g*(o.m21*o.dy-o.m22*o.dx),g*(o.m12*o.dx-o.m11*o.dy))}e!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n)}iA(t,i,e,s){t&&this.shadowVisible===!0?i.shadowsOn():t&&this.shadowVisible===!1&&i.shadowsOff(),t&&this.vb(s)&&this.shadowVisible===null&&i.shadowsOff()}eA(t,i,e,s){t&&(this.Ct!==null||this.vb(s))?(this.Ob(!0),this.shadowVisible===null&&i.shadowsOff()):this.Ob(!1)}sA(t,i,e){t&&this.o2()===!0&&i.shadowsOn(),e&&t&&i.shadowsOff()}CR(t,i,e){const s=this.part;let n=!1;s&&t.getRenderingHint("drawShadows")&&(n=s.isShadowed),i.clipInsteadOfFill&&(n=!1),this.Xs()&&n&&i.shadowsOn(),n&&this.shadowVisible===!0?i.shadowsOn():n&&this.shadowVisible===!1&&i.shadowsOff();const o=this.panel;if(n&&this.vb(o)&&this.shadowVisible===null&&i.shadowsOff(),i.tl){const r=t.computePixelRatio(),l=`drop-shadow(${i.shadowOffsetX/r}px ${i.shadowOffsetY/r}px ${i.shadowBlur/r/2}px ${i.shadowColor})`;this.background!==null&&e.Ct.setAttributeNS(null,"filter",l)}return n&&(this.Ct!==null||this.vb(o))?(this.Ob(!0),this.shadowVisible===null&&i.shadowsOff()):this.Ob(!1),n}LR(t,i,e,s){if(e.tl){const n=i.computePixelRatio(),o=`drop-shadow(${e.shadowOffsetX/n}px ${e.shadowOffsetY/n}px ${e.shadowBlur/n/2}px ${e.shadowColor})`;this.l2(t,o)}s&&this.o2()===!0&&e.shadowsOn(),this.Xs()&&e.shadowsOff()}vb(t){return t===null?!1:(t._r()&&(t=t.panel),t.o2()||(t.type===Panel.Auto||t.type===Panel.Spot)&&t.findMainElement()!==this)}l2(t,i){}Rb(t,i,e){const s=this.w0(),n=i.x,o=i.y,r=i.width+s,l=i.height+s;this.dn(t,this.Ct,!0,!1,i,e),this.Ct instanceof Brush&&this.Ct.type===3?(t.beginPath(),t.rect(n-s/2,o-s/2,r,l),t.fillContext(this.Ct,!1,null)):t.fillRect(n-s/2,o-s/2,r,l)}nA(t,i){let e=t.AR(this);const s=t.rh!==null?t.rh:t.svg;if(e!==-1)if(e===0)if(s.Ct)s.Ct.after(i);else if(t.type===Panel.Table){const n=s.getElementsByClassName("gojs-ts"),o=n.length!==0?n[0]:null;o!==null&&o.after(i)}else s.prepend(i);else{for(;e!==0&&!t.elt(e-1).isVisibleObject();)e--;if(e===0)s.prepend(i);else{const n=t.elt(e-1).svg;n!==null?n.after(i):s.appendChild(i)}}}MR(t,i){if(!(t instanceof SVGContext))return!1;if(!this.visible||this.opacity===0)return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;if(this.Xs()&&!this.isVisible())return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;const e=this.panel,s=this.ed(t);if(this.Qc(t,i,s))return this.oA(this.svg),this.svg.parentElement!==null?(this.Xs()&&(t.lastDrawnPart=this.svg),!0):(this.Xs()?(t.lastDrawnPart!==null?t.lastDrawnPart.after(this.svg):t.diagramGroup.prepend(this.svg),t.lastDrawnPart=this.svg):e&&this.nA(e,this.svg),!0);if(this.Xs()&&this.isShadowed){const m=this.shadowOffset;t.shadowsSet(m.x*i.scale*this.scale*i.Ui,m.y*i.scale*this.scale*i.Ui,this.shadowBlur),t.shadowsOn(),t.shadowColor=this.shadowColor}this instanceof TextBlock&&(t.font=this.font),t.currentElement=null;const n=this.D,o=this instanceof Panel,r=this instanceof Panel?this._r():!1,l=this.svg;this.y0()===!0&&this.Fb();const h=this.Li;if(t.setCurrentTransform(1,0,0,1,0,0),t.outerGroup=!1,s)if(t.outerGroup=!0,o&&r)t.newGroup(1,0,0,1,0,0),this.svg=t.lastCreatedElement;else if(o&&this.isClipping){const m=this.findMainElement();let g=0,p=0;m!==null&&(g=m.actualBounds.x,p=m.actualBounds.y),t.newGroup(n.m11,n.m12,n.m21,n.m22,n.dx+g,n.dy+p),this.svg=t.lastCreatedElement,m!==null&&t.createOrUpdateClipGroup(this,m.actualBounds),t.currentElement=t.lastCreatedElement}else o?(t.newGroup(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.svg=t.lastCreatedElement):t.newGroup(1,0,0,1,0,0);const a=this.naturalBounds;o||t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.background!==null&&(o?(r&&t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.Rb(t,a,h),r&&t.setCurrentTransform(1,0,0,1,0,0)):(t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.Rb(t,a,h)),t.currentElement.Ct=t.lastCreatedElement,t.currentElement.prepend(t.lastCreatedElement));const c=this.CR(i,t,t.currentElement);this.fh(t,i),o&&t.endGroup(),t.outerGroup&&t.endGroup();const f=t.surface.Gu,u=o?this.svg:t.currentElement;if(!o&&l!==null&&u!==l&&l.parentNode===this.panel.svg){const m=this.svg.getAttribute("filter");return m!==null&&u.setAttribute("filter",m),this.svg.replaceWith(u),this.svg=u,u!==null&&this.P0(t,e,h,u),t.rA(l),!0}if(this.svg=u,f!==null&&u===null&&t.dummyGroup(),u===null)return!0;this.P0(t,e,h,u),this.LR(u,i,t,c);const d=this.Xs()?this.opacity*t.globalAlpha:this.opacity;if(d!==1&&u.setAttributeNS(null,"opacity",d.toString()),this.filter!==""&&u.setAttributeNS(null,"filter",this.filter),this.Xs()){if(l!==null&&u!==l&&l.parentNode===t.diagramGroup){const m=l.getAttribute("filter");m!==null&&u.setAttribute("filter",m),l.replaceWith(u)}else t.lastDrawnPart?t.lastDrawnPart.after(u):t.diagramGroup.prepend(u);t.lastDrawnPart=u}else e!==null&&this.nA(e,u);return f!==null&&f(this,u),this.oA(u),!0}oA(t){const i=this,e=t.dataset;i instanceof GraphObject&&(i.portId!==null&&(e.portId=i.portId),i instanceof Panel&&(isNaN(i.itemIndex)||(e.itemIndex=i.itemIndex.toString()),i instanceof Part&&(e.className=Util.sn(i),i.key!==void 0&&(e.key=i.key.toString()),i.containingGroup!==null&&(e.group=i.containingGroup.key.toString()),i instanceof Link&&(i.fromNode!==null&&i.fromNode.key!==void 0&&(e.fromKey=i.fromNode.key.toString()),i.fromPortId!==""&&(e.fromPortId=i.fromPortId),i.toNode!==null&&i.toNode.key!==void 0&&(e.toKey=i.toNode.key.toString()),i.toPortId!==""&&(e.toPortId=i.toPortId)))))}P0(t,i,e,s){let n=(this.n&256)!==0;if(t.clipInsteadOfFill&&(n=!1),!n){s.removeAttributeNS(null,"clip-path"),t.rA(s);return}const o=i.pn()?i.naturalBounds:i.actualBounds;let r=Math.max(e.x,o.x),l=Math.max(e.y,o.y),h=Math.min(e.right,o.right)-r,a=Math.min(e.bottom,o.bottom)-l;const c=this.ni;c!==null&&(r=c.x,l=c.y,h=c.width,a=c.height);const f=t.TR(s);if(f===null){const u="CLIP"+GSet.su++,d={id:u},m=t.makeElement("clipPath",d),g=t.makeElement("rect",{x:r,y:l,width:h,height:a});if(this instanceof Panel){const p=this.D.copy().yw();g.setAttribute("transform",`matrix(${p.m11}, ${p.m12}, ${p.m21}, ${p.m22}, ${p.dx}, ${p.dy})`)}m.appendChild(g),t.svg.appendChild(m),s.setAttributeNS(null,"clip-path","url(#"+u+")")}else{const u=f.firstElementChild;u.setAttribute("x",r.toString()),u.setAttribute("y",l.toString()),u.setAttribute("width",h.toString()),u.setAttribute("height",a.toString())}}DR(){if(this.svg===null)return;const t=this.svg.innerHTML.match(/url\(#((CLIP|GRAD).+?)\)/g),i=this.svg.ownerDocument;if(t!==null)for(const e of t){const s=i.getElementById(e.split("#")[1].slice(0,-1));s!==null&&s.remove()}this.svg.remove()}NR(t,i){const e=this.Li,s=this.Vi,n=this.Ct;n!==null&&t.commitTransform(),n!==null&&(this.dn(t,n,!0,!1,s,e),n instanceof Brush&&n.type===3?(t.beginPath(),t.rect(e.x,e.y,e.width,e.height),t.fillContext(n,!1,null)):t.fillRect(e.x,e.y,e.width,e.height)),this.fh(t,i)}fh(t,i){}S0(){this.ss(!0)}Qc(t,i,e){const s=this.svg;if(this.FR()){if(this.S0(),this.ss(!1),s===null)return!1;const c=this.svg.getAttribute("clip-path");if(c!==null&&c.includes("url")){const f=t.svg.getElementById(c.split("#")[1].slice(0,-1));f!==null&&f.remove()}return!1}if(s===null)return!1;if(!this.visible)return s.remove(),!1;if(s.nodeName!=="g"&&e||s.nodeName==="g"&&!e)return!1;const n=this.D,o="matrix("+n.m11+", "+n.m12+", "+n.m21+", "+n.m22+", "+n.dx+", "+n.dy+")",r=this instanceof Panel,l=r?this._r():!1;if(!(r&&l))if(this instanceof Picture){const c=this.Ib;t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),c!==null&&t.amendImageTransform(c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7]),e?s.lastElementChild.setAttributeNS(null,"transform",t.getCurrentTransform()):s.setAttributeNS(null,"transform",t.getCurrentTransform())}else if(e&&!r)if(this instanceof Shape){const c=s.getElementsByTagName("path");for(let f=0;f=.1;){if(g){for(l=o[d++%h],l-=r;l<0;)l+=o[d++%h],m=!m;g=!1}else l=o[d++%h];l>u&&(l=u);let p=Math.sqrt(l*l/(1+f*f));a<0&&(p=-p),i+=p,e+=f*p,m?t.lineTo(i,e):t.moveTo(i,e),u-=l,m=!m}}dn(t,i,e,s,n,o){let r=1,l=1;if(typeof i=="string"){e?t.fillStyle=i:t.strokeStyle=i;return}else if(i.type===1){e?t.fillStyle=i.color:t.strokeStyle=i.color;return}let h;const a=this.w0();r=n.width,l=n.height,s?(r=o.width,l=o.height):e||(r+=a,l+=a);const c=t instanceof CanvasSurfaceContext;if(c&&i.yn&&(i.type===4||i._c===r&&i.Eb===l))h=i.yn;else{let f=0,u=0,d=0,m=0,g=0,p=0,y=0,x=0;if(s?(y=o.x,x=o.y):e||(y-=a/2,x-=a/2),f=i.start.x*r+i.start.offsetX+y,u=i.start.y*l+i.start.offsetY+x,d=i.end.x*r+i.end.offsetX+y,m=i.end.y*l+i.end.offsetY+x,i.type===2)h=t.createLinearGradient(f,u,d,m);else if(i.type===3)p=isNaN(i.endRadius)?Math.max(r,l)/2:i.endRadius,isNaN(i.startRadius)?(g=0,p=Math.max(r,l)/2):g=i.startRadius,h=t.createRadialGradient(f,u,g,d,m,p);else if(i.type===4)try{h=t.createPattern(i.pattern,"repeat")}catch{h=null}else Util.we(i.type,"Brush type");if(i.type!==4){const k=i.colorStops;if(k!==null){const b=k.iterator;for(;b.next();)h.addColorStop(b.key,b.value)}}if(c&&(i.yn=h,h!==null&&(i._c=r,i.Eb=l),h===null&&i.type===4&&i._c!==-1)){i._c=-1;const k=this.diagram;k!==null&&i._c===-1&&Util.Oh(()=>{k.redraw()},600)}}e?t.fillStyle=h:t.strokeStyle=h}isContainedBy(t){return t instanceof Panel?this.RR(this,t):!1}RR(t,i){if(t===i||i===null)return!1;let e=t.panel;for(;e!==null;){if(e===i)return!0;e=e.panel}return!1}isVisibleObject(){if(!this.visible)return!1;const t=this.panel;return t!==null?t.isVisibleObject():!0}isEnabledObject(){let t=this instanceof Panel?this:this.panel;for(;t!==null&&t.isEnabled;)t=t.panel;return t===null}get enabledChanged(){return this.f!==null?this.f.M0:null}set enabledChanged(t){const i=this.enabledChanged;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"enabledChanged"),this.jt(),this.f.M0=t,this.t("enabledChanged",i,t))}Fb(){if(this.Bb()===!0){const t=this.$r;if(t.Ri(),!this.Li.isReal()||!this.se.isReal()){this.sd(!1);return}if(t.Ds(this.Li.x-this.se.x,this.Li.y-this.se.y),this.scale!==1||this.angle!==0){const i=this.naturalBounds;this.p0(t,i.x,i.y,i.width,i.height)}this.sd(!1),this.wa(!0)}if(this.y0()===!0){const t=this.panel;if(t===null)this.oh.set(this.$r),this.ca=this.scale;else if(t.Es!==null){const i=this.oh;i.Ri(),t.pn()?i.ic(t.oh):t.panel!==null&&i.ic(t.panel.oh),i.ic(this.$r),this.ca=this.scale*t.ca}this.wa(!1)}}p0(t,i,e,s,n){if(this.et!==1&&t.et(this.et),this.Xt===0)return;const o=Point.l();o.setSpot(i,e,s,n,Spot.Center),t.cs(this.Xt,o.x,o.y),Point.s(o)}c(t){if(this.Oo())return;t===void 0&&(t=!1),this.ue(!0),this._n(!0);const i=this.panel;i!==null&&!t&&i.c()}tf(){this.Oo()||(this.ue(!0),this._n(!0))}ef(t){if(this.is())return;const i=this.panel;!t&&i!==null&&i.c(),this._n(!0)}_u(){this.Bb()===!1&&(this.sd(!0),this.wa(!0))}h2(){this.wa(!0)}C(){const t=this.part;t!==null&&t.C()}zs(t){const i=this.stretch,e=this.panel;if(e===null)return this.zo(i===1?0:i,t);if(e.type===Panel.Table)return this.N0(e.getRowDefinition(this.row),e.getColumnDefinition(this.column),t);if(e.type===Panel.Auto&&e.findMainElement()===this)return this.zo(2,t);if(i===1){if(e.type===Panel.Spot&&e.findMainElement()===this)return this.zo(2,t);const s=e.defaultStretch;return s===1?this.zo(0,t):this.zo(s,t)}return this.zo(i,t)}N0(t,i,e){const s=this.stretch;if(s!==1)return this.zo(s,e);let n=null,o=null;switch(t.stretch){case 1:case 5:break;case 4:o=!0;break;case 2:o=!0;break}switch(i.stretch){case 1:case 4:break;case 5:n=!0;break;case 2:n=!0;break}const r=this.panel.defaultStretch;return n===null&&(n=r===5||r===2),o===null&&(o=r===4||r===2),n===!0&&o===!0?this.zo(2,e):n===!0?this.zo(5,e):o===!0?this.zo(4,e):this.zo(0,e)}zo(t,i){if(i)return t;if(t===0)return 0;const e=this.desiredSize;if(e.isReal())return 0;const s=!isNaN(e.width),n=!isNaN(e.height),o=this.angle;if(s)if(o!==90&&o!==270){if(t===5)return 0;if(t===2)return 4}else{if(t===4)return 0;if(t===2)return 5}if(n)if(o!==90&&o!==270){if(t===4)return 0;if(t===2)return 5}else{if(t===5)return 0;if(t===2)return 4}return t}get segmentOrientation(){return this.Bt!==null?this.Bt.C0:0}set segmentOrientation(t){const i=this.segmentOrientation;i!==t&&(this.Bt===null&&(this.Bt=new LinkElementSettings),this.Bt.C0=t,this.c(),this.t("segmentOrientation",i,t),t===0&&(this.angle=0))}vR(){this.segmentOrientation=21}get segmentIndex(){return this.Bt!==null?this.Bt.L0:-1/0}set segmentIndex(t){t=Math.round(t);const i=this.segmentIndex;i!==t&&(this.Bt===null&&(this.Bt=new LinkElementSettings),this.Bt.L0=t,this.c(),this.t("segmentIndex",i,t))}get segmentFraction(){return this.Bt!==null?this.Bt.A0:0}set segmentFraction(t){isNaN(t)||t<0?t=0:t>1&&(t=1);const i=this.segmentFraction;i!==t&&(this.Bt===null&&(this.Bt=new LinkElementSettings),this.Bt.A0=t,this.c(),this.t("segmentFraction",i,t))}get segmentOffset(){return this.Bt!==null?this.Bt.T0:Point.Po}set segmentOffset(t){const i=this.segmentOffset;i.equals(t)||(t=t.N(),this.Bt===null&&(this.Bt=new LinkElementSettings),this.Bt.T0=t,this.c(),this.t("segmentOffset",i,t))}get stretch(){return this.f!==null?this.f.to:1}set stretch(t){const i=this.stretch;i!==t&&(this.jt(),this.f.to=t,this.c(),this.t("stretch",i,t))}get name(){return this.f!==null?this.f.Mt:""}set name(t){const i=this.name;i!==t&&(this.jt(),this.f.Mt=t,this.part!==null&&this.part.D0(),this.t("name",i,t))}get opacity(){return this.Wt}set opacity(t){const i=this.Wt;if(i!==t){Util.i(t,"number",GraphObject,"opacity"),(t<0||t>1)&&Util._(t,"0 <= value <= 1",GraphObject,"opacity"),this.Wt=t,this.t("opacity",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.C(s.Hh(s.actualBounds))}}get filter(){return this.Wu}set filter(t){const i=this.Wu;if(i!==t){this.Wu=t,this.ss(!0),this.t("filter",i,t);const e=this.diagram,s=this.part;e!==null&&s!==null&&e.C(s.Hh(s.actualBounds))}}get visible(){return(this.n&1)!==0}set visible(t){const i=(this.n&1)!==0;if(i!==t){this.n=this.n^1,this.t("visible",i,t);const e=this.panel;e!==null?e.c():this.Xs()&&this.Ei(t),this.C(),this.lA()}}get pickable(){return(this.n&2)!==0}set pickable(t){const i=(this.n&2)!==0;i!==t&&(this.n=this.n^2,this.t("pickable",i,t))}get fromLinkableDuplicates(){return(this.n&4)!==0}set fromLinkableDuplicates(t){const i=(this.n&4)!==0;i!==t&&(this.n=this.n^4,this.t("fromLinkableDuplicates",i,t))}get fromLinkableSelfNode(){return(this.n&8)!==0}set fromLinkableSelfNode(t){const i=(this.n&8)!==0;i!==t&&(this.n=this.n^8,this.t("fromLinkableSelfNode",i,t))}get toLinkableDuplicates(){return(this.n&16)!==0}set toLinkableDuplicates(t){const i=(this.n&16)!==0;i!==t&&(this.n=this.n^16,this.t("toLinkableDuplicates",i,t))}get toLinkableSelfNode(){return(this.n&32)!==0}set toLinkableSelfNode(t){const i=(this.n&32)!==0;i!==t&&(this.n=this.n^32,this.t("toLinkableSelfNode",i,t))}get isPanelMain(){return(this.n&64)!==0}set isPanelMain(t){const i=(this.n&64)!==0;i!==t&&(this.n=this.n^64,this.c(),this.t("isPanelMain",i,t))}get isActionable(){return(this.n&128)!==0}set isActionable(t){const i=(this.n&128)!==0;i!==t&&(this.n=this.n^128,this.t("isActionable",i,t))}get background(){return this.Ct}set background(t){const i=this.Ct;i!==t&&(t!==null&&Brush.nd(t,"GraphObject.background"),t instanceof Brush&&t.g(),this.Ct=t,this.C(),this.t("background",i,t))}o2(){return(this.n&512)!==0}Ob(t){t?this.n|=512:this.n&=-513}$c(){return(this.n&1024)!==0}a2(t){t?this.n|=1024:this.n&=-1025}Bb(){return(this.n&2048)!==0}sd(t){t?this.n|=2048:this.n&=-2049}y0(){return(this.n&4096)!==0}wa(t){t?this.n|=4096:this.n&=-4097}Oo(){return(this.n&8192)!==0}ue(t){t?this.n|=8192:this.n&=-8193}is(){return(this.n&16384)!==0}_n(t){t?this.n|=16384:this.n&=-16385}FR(){return(this.n&32768)!==0}ss(t){t?this.n|=32768:this.n&=-32769}get part(){if(this.Xs())return this;if(this.Qr!==null)return this.Qr;let t=this;for(t=t.panel;t;){if(t instanceof Part)return this.Qr=t,t;t=t.panel}return null}get svg(){return this.Db}set svg(t){this.Db=t}Du(){this.svg=null}get panel(){return this.Vs}xa(t){this.Vs=t,this.svg!==null&&this.svg.remove()}get layer(){const t=this.part;return t!==null?t.layer:null}get diagram(){const t=this.part;return t!==null?t.diagram:null}get position(){return this.at}set position(t){const i=t.x,e=t.y,s=this.at,n=s.x,o=s.y;n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e))?(t=t.copy(),this.c2(t,n,o)&&this.t("position",new Point(n,o),t)):this.f2()}f2(){}c2(t,i,e){return this.at=t,this.ef(),!0}bc(t,i,e){this.at.x===t&&this.at.y===i||(this.at.e(t,i),this._u())}get actualBounds(){return this.Li}get scale(){return this.et}set scale(t){const i=this.et;i!==t&&(t<=0&&Util.o("GraphObject.scale for "+this+" must be greater than zero, not: "+t),this.et=t,this.c(),this.t("scale",i,t))}get angle(){return this.Xt}set angle(t){const i=this.Xt;if(i!==t){if(t=t%360,t<0&&(t+=360),i===t)return;this.Xt=t,this.lA(),this.c(),this.t("angle",i,t)}}get desiredSize(){return this.ze}set desiredSize(t){const i=t.width,e=t.height,s=this.ze,n=s.width,o=s.height;if((n!==i&&(!isNaN(n)||!isNaN(i))||o!==e&&(!isNaN(o)||!isNaN(e)))&&(t=t.N(),this.ze=t,this.c(),this instanceof Shape&&this.ee(),this.t("desiredSize",s,t),this.$c())){const r=this.part;r!==null&&(this.ya(r,"width"),this.ya(r,"height"))}}get width(){return this.ze.width}set width(t){const i=this.ze.width;if(i!==t&&(!isNaN(i)||!isNaN(t))){const e=this.ze,s=new Size(t,this.ze.height).g();if(this.ze=s,this.c(),this instanceof Shape&&this.ee(),this.t("desiredSize",e,s),this.$c()){const n=this.part;n!==null&&this.ya(n,"width")}}}get height(){return this.ze.height}set height(t){const i=this.ze.height;if(i!==t&&(!isNaN(i)||!isNaN(t))){const e=this.ze,s=new Size(this.ze.width,t).g();if(this.ze=s,this.c(),this instanceof Shape&&this.ee(),this.t("desiredSize",e,s),this.$c()){const n=this.part;n!==null&&this.ya(n,"height")}}}get minSize(){return this.f!==null?this.f.xr:Size.ru}set minSize(t){const i=this.minSize;i.equals(t)||(t=t.copy(),isNaN(t.width)&&(t.width=0),isNaN(t.height)&&(t.height=0),t.g(),this.jt(),this.f.xr=t,this.c(),this.t("minSize",i,t))}get maxSize(){return this.f!==null?this.f.br:Size.iC}set maxSize(t){const i=this.maxSize;i.equals(t)||(t=t.copy(),isNaN(t.width)&&(t.width=1/0),isNaN(t.height)&&(t.height=1/0),t.g(),this.jt(),this.f.br=t,this.c(),this.t("maxSize",i,t))}get measuredBounds(){return this.se}get naturalBounds(){return this.Vi}w0(){return 0}get margin(){return this.Zr}set margin(t){typeof t=="number"&&(t=new Margin(t));const i=this.Zr;i.equals(t)||(t=t.N(),this.Zr=t,this.c(),this.t("margin",i,t))}get D(){return this.Bb()===!0&&this.Fb(),this.$r}get Es(){return this.y0()===!0&&this.Fb(),this.oh}trigger(t,i,e){let s=null;return typeof t=="string"?s=new AnimationTrigger(t,i,e):s=t,s.ke=this,this.ys===null&&(this.ys=new GMap),this.ys.set(s.propertyName,s),this}get ys(){return this.f!==null?this.f.ys:null}set ys(t){this.ys!==t&&(this.jt(),this.f.ys=t)}get wr(){return this.f!==null?this.f.wr:0}set wr(t){this.wr!==t&&(this.jt(),this.f.wr=t)}get alignment(){return this.oi}set alignment(t){const i=this.oi;i.equals(t)||(t.isNoSpot()&&!t.isDefault()&&Util.o("GraphObject.alignment for "+this+" must be a real Spot or Spot.Default, not: "+t),t=t.N(),this.oi=t,this.ef(),this.t("alignment",i,t))}get column(){return this.Uo}set column(t){t=Math.round(t);const i=this.Uo;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"column"),this.Uo=t,this.c(),this.t("column",i,t),this.svg!==null&&this.svg.remove())}get columnSpan(){return this.f!==null?this.f.F0:1}set columnSpan(t){t=Math.round(t);const i=this.columnSpan;i!==t&&(t<1&&Util._(t,">= 1",GraphObject,"columnSpan"),this.jt(),this.f.F0=t,this.c(),this.t("columnSpan",i,t))}get row(){return this.qu}set row(t){t=Math.round(t);const i=this.qu;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"row"),this.qu=t,this.c(),this.t("row",i,t),this.svg!==null&&this.svg.remove())}get rowSpan(){return this.f!==null?this.f.R0:1}set rowSpan(t){t=Math.round(t);const i=this.rowSpan;i!==t&&(t<1&&Util._(t,">= 1",GraphObject,"rowSpan"),this.jt(),this.f.R0=t,this.c(),this.t("rowSpan",i,t))}get spanAllocation(){return this.f!==null?this.f.v0:null}set spanAllocation(t){const i=this.spanAllocation;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"spanAllocation"),this.jt(),this.f.v0=t,this.c(),this.t("spanAllocation",i,t))}get alignmentFocus(){return this.Wc}set alignmentFocus(t){const i=this.Wc;i.equals(t)||(t=t.N(),this.Wc=t,this.c(),this.t("alignmentFocus",i,t))}get portId(){return this.Hu}set portId(t){const i=this.Hu;if(i!==t){const e=this.part;e!==null&&!(e instanceof Node)&&Util.o("Cannot set portID on a Link: "+t);const s=e;i!==null&&s!==null&&s.u2(this),this.Hu=t,t!==null&&s!==null&&(s.wn=!0,s.hA(this)),this.t("portId",i,t)}}ba(){const t=this.part;if(t instanceof Node&&(this.portId!==null||this===t.port)){const i=t.diagram;i!==null&&!i.undoManager.isUndoingRedoing&&t.tA(this)}}lA(){const t=this.diagram;t===null||t.undoManager.isUndoingRedoing||(this instanceof Panel?this instanceof Node?this.invalidateConnectedLinks():this.walkVisualTreeFrom(this,i=>{i.ba()}):this.ba())}get toSpot(){return this.q!==null?this.q.ua:Spot.None}set toSpot(t){const i=this.toSpot;i.equals(t)||(t=t.N(),this.Xe(),this.q.ua=t,this.t("toSpot",i,t),this.ba())}get toEndSegmentLength(){return this.q!==null?this.q.ga:10}set toEndSegmentLength(t){const i=this.toEndSegmentLength;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"toEndSegmentLength"),this.Xe(),this.q.ga=t,this.t("toEndSegmentLength",i,t),this.ba())}get toShortLength(){return this.q!==null?this.q.pa:0}set toShortLength(t){const i=this.toShortLength;i!==t&&(this.Xe(),this.q.pa=t,this.t("toShortLength",i,t),this.ba())}get toLinkable(){return this.q!==null?this.q.O0:null}set toLinkable(t){const i=this.toLinkable;i!==t&&(this.Xe(),this.q.O0=t,this.t("toLinkable",i,t))}get toMaxLinks(){return this.q!==null?this.q.I0:1/0}set toMaxLinks(t){const i=this.toMaxLinks;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"toMaxLinks"),this.Xe(),this.q.I0=t,this.t("toMaxLinks",i,t))}get fromSpot(){return this.q!==null?this.q.fa:Spot.None}set fromSpot(t){const i=this.fromSpot;i.equals(t)||(t=t.N(),this.Xe(),this.q.fa=t,this.t("fromSpot",i,t),this.ba())}get fromEndSegmentLength(){return this.q!==null?this.q.da:10}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"fromEndSegmentLength"),this.Xe(),this.q.da=t,this.t("fromEndSegmentLength",i,t),this.ba())}get fromShortLength(){return this.q!==null?this.q.ma:0}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(this.Xe(),this.q.ma=t,this.t("fromShortLength",i,t),this.ba())}get fromLinkable(){return this.q!==null?this.q.E0:null}set fromLinkable(t){const i=this.fromLinkable;i!==t&&(this.Xe(),this.q.E0=t,this.t("fromLinkable",i,t))}get fromMaxLinks(){return this.q!==null?this.q.B0:1/0}set fromMaxLinks(t){const i=this.fromMaxLinks;i!==t&&(t<0&&Util._(t,">= 0",GraphObject,"fromMaxLinks"),this.Xe(),this.q.B0=t,this.t("fromMaxLinks",i,t))}get cursor(){return this.f!==null?this.f.Sl:""}set cursor(t){const i=this.cursor;i!==t&&(Util.i(t,"string",GraphObject,"cursor"),this.jt(),this.f.Sl=t,this.t("cursor",i,t))}get click(){return this.f!==null?this.f.Tr:null}set click(t){const i=this.click;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"click"),this.jt(),this.f.Tr=t,this.t("click",i,t))}get doubleClick(){return this.f!==null?this.f.Dr:null}set doubleClick(t){const i=this.doubleClick;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"doubleClick"),this.jt(),this.f.Dr=t,this.t("doubleClick",i,t))}get contextClick(){return this.f!==null?this.f.Fr:null}set contextClick(t){const i=this.contextClick;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"contextClick"),this.jt(),this.f.Fr=t,this.t("contextClick",i,t))}get mouseEnter(){return this.f!==null?this.f.Er:null}set mouseEnter(t){const i=this.mouseEnter;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseEnter"),this.jt(),this.f.Er=t,this.t("mouseEnter",i,t))}get mouseLeave(){return this.f!==null?this.f.Br:null}set mouseLeave(t){const i=this.mouseLeave;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseLeave"),this.jt(),this.f.Br=t,this.t("mouseLeave",i,t))}get mouseOver(){return this.f!==null?this.f.Rr:null}set mouseOver(t){const i=this.mouseOver;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseOver"),this.jt(),this.f.Rr=t,this.t("mouseOver",i,t))}get mouseHover(){return this.f!==null?this.f.vr:null}set mouseHover(t){const i=this.mouseHover;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseHover"),this.jt(),this.f.vr=t,this.t("mouseHover",i,t))}get mouseHold(){return this.f!==null?this.f.Or:null}set mouseHold(t){const i=this.mouseHold;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseHold"),this.jt(),this.f.Or=t,this.t("mouseHold",i,t))}get mouseDragEnter(){return this.f!==null?this.f.U0:null}set mouseDragEnter(t){const i=this.mouseDragEnter;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDragEnter"),this.jt(),this.f.U0=t,this.t("mouseDragEnter",i,t))}get mouseDragLeave(){return this.f!==null?this.f.V0:null}set mouseDragLeave(t){const i=this.mouseDragLeave;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDragLeave"),this.jt(),this.f.V0=t,this.t("mouseDragLeave",i,t))}get mouseDrop(){return this.f!==null?this.f.Ir:null}set mouseDrop(t){const i=this.mouseDrop;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"mouseDrop"),this.jt(),this.f.Ir=t,this.t("mouseDrop",i,t))}get actionDown(){return this.f!==null?this.f.z0:null}set actionDown(t){const i=this.actionDown;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionDown"),this.jt(),this.f.z0=t,this.t("actionDown",i,t))}get actionMove(){return this.f!==null?this.f.X0:null}set actionMove(t){const i=this.actionMove;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionMove"),this.jt(),this.f.X0=t,this.t("actionMove",i,t))}get actionUp(){return this.f!==null?this.f.K0:null}set actionUp(t){const i=this.actionUp;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionUp"),this.jt(),this.f.K0=t,this.t("actionUp",i,t))}get actionCancel(){return this.f!==null?this.f.Y0:null}set actionCancel(t){const i=this.actionCancel;i!==t&&(t!==null&&Util.i(t,"function",GraphObject,"actionCancel"),this.jt(),this.f.Y0=t,this.t("actionCancel",i,t))}get toolTip(){return this.f!==null?this.f.Ur:null}set toolTip(t){const i=this.toolTip;i!==t&&(this.jt(),this.f.Ur=t,this.t("toolTip",i,t))}get contextMenu(){return this.f!==null?this.f.Vr:null}set contextMenu(t){const i=this.contextMenu;i!==t&&(this.jt(),this.f.Vr=t,this.t("contextMenu",i,t))}findBindingPanel(){let t=this instanceof Panel?this:this.panel;for(;t!==null;){if(t.d2())return t;t=t.panel}return null}bind(t,i,e,s){return this.sf(t,i,e,s),this}bindTwoWay(t,i,e,s){return this.sf(t,i,e,s).makeTwoWay(),this}bindModel(t,i,e,s){return this.sf(t,i,e,s).ofModel(),this}bindObject(t,i,e,s,n){return this.sf(t,i,e,s).ofObject(n),this}theme(t,i,e,s,n){return this.uh(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.uh(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.uh(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.uh(t,i,e,s,n).ofModel(),this}sf(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.G0(n),n}uh(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.G0(o),o}G0(t){t.ke=this;const i=this.findBindingPanel();i!==null&&i.aA()&&Util.o("Cannot add a Binding to a template that has already been copied: "+t),this.Ai===null&&(this.Ai=new List),this.Ai.add(t)}set(t){return Object.assign(this,t),this}attach(t){return GraphObject.g2(this,t),this}apply(t){return t(this),this}setProperties(t){return Diagram.h0(this,t),this}static build(t,i,...e){const s=GraphObject.j0.get(t);if(typeof s=="function"){const n=s([t].concat(e));if(n instanceof GraphObject)return i&&n.setProperties(i),n}Util.o('GraphObject.build invoked object builder "'+t+'", but it did not return an Object')}static make(t,...i){let e=arguments,s=null,n=null;if(typeof t=="function")n=t;else if(typeof t=="string"){const r=GraphObject.j0.get(t);typeof r=="function"?(e=Array.prototype.slice.call(e),s=r(e),Util.wt(s)||Util.o('GraphObject.make invoked object builder "'+t+'", but it did not return an Object')):n=root.go[t]}s===null&&((n==null||!n.constructor)&&Util.o("GraphObject.make requires a class function or GoJS class name or name of an object builder, not: "+t),s=new n);let o=1;if(s instanceof Diagram&&e.length>1){const r=s,l=e[1];(typeof l=="string"||l instanceof HTMLDivElement)&&(r.mM(l),o++)}for(let r=o;r{const i="#f5f5f5",e="#737373",s="#d4d4d4",n="#737373",o="#a3a3a3",r=2.76142374915397,l=2.761423749153969,h=new Panel(Panel.Auto,{isActionable:!0,enabledChanged:(a,c)=>{if(a instanceof Panel){const f=a.findObject("ButtonBorder");f!==null&&(c?(a._buttonFillDisabled=f.fill,f.fill=a._buttonFillNormal):(a._buttonFillNormal=f.fill,f.fill=a._buttonFillDisabled))}},cursor:"pointer"}).attach({_buttonFillNormal:i,_buttonStrokeNormal:e,_buttonFillOver:s,_buttonStrokeOver:n,_buttonFillDisabled:o}).add(new Shape("RoundedRectangle",{name:"ButtonBorder",spot1:new Spot(0,0,r,l),spot2:new Spot(1,1,-r,-l),parameter1:2,fill:i,stroke:e}));return h.mouseEnter=(a,c,f)=>{if(!c.isEnabledObject()||!(c instanceof Panel))return;const u=c.findObject("ButtonBorder");u instanceof Shape&&(c._buttonFillNormal=u.fill,u.fill=c._buttonFillOver,c._buttonStrokeNormal=u.stroke,u.stroke=c._buttonStrokeOver)},h.mouseLeave=(a,c,f)=>{if(!c.isEnabledObject()||!(c instanceof Panel))return;const u=c.findObject("ButtonBorder");u instanceof Shape&&(u.fill=c._buttonFillNormal,u.stroke=c._buttonStrokeNormal)},h}),GraphObject.defineBuilder("TreeExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_treeExpandedFigure:"MinusLine",_treeCollapsedFigure:"PlusLine",visible:!1}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.lu}).bindObject("figure","isTreeExpanded",(e,s)=>{const n=s.panel;return e?n._treeExpandedFigure:n._treeCollapsedFigure})),i.bindObject("visible","isTreeLeaf",e=>!e),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Node))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isTreeExpanded){if(!r.canCollapseTree(n))return}else if(!r.canExpandTree(n))return;e.handled=!0,n.isTreeExpanded?r.collapseTree(n):r.expandTree(n)},i}),GraphObject.defineBuilder("SubGraphExpanderButton",t=>{const i=GraphObject.build("Button");return i.attach({_subGraphExpandedFigure:"MinusLine",_subGraphCollapsedFigure:"PlusLine"}),i.add(new Shape("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:Size.lu}).bindObject("figure","isSubGraphExpanded",(e,s)=>{const n=s.panel;return e?n._subGraphExpandedFigure:n._subGraphCollapsedFigure})),i.click=(e,s)=>{let n=s.part;if(n instanceof Adornment&&(n=n.adornedPart),!(n instanceof Group))return;const o=n.diagram;if(o===null)return;const r=o.commandHandler;if(n.isSubGraphExpanded){if(!r.canCollapseSubGraph(n))return}else if(!r.canExpandSubGraph(n))return;e.handled=!0,n.isSubGraphExpanded?r.collapseSubGraph(n):r.expandSubGraph(n)},i}),GraphObject.defineBuilder("ToolTip",t=>new Adornment(Panel.Auto,{isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).add(new Shape("RoundedRectangle",{name:"Border",parameter1:1,fill:"#f5f5f5",strokeWidth:0,spot1:new Spot(0,0,4,6),spot2:new Spot(1,1,-4,-4)}))),GraphObject.defineBuilder("ContextMenu",t=>new Adornment(Panel.Vertical,{background:"#f5f5f5",isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new Point(0,2)}).bindObject("background","",i=>i.adornedPart!==null&&i.hasPlaceholder()?null:"#f5f5f5")),GraphObject.defineBuilder("ContextMenuButton",t=>{const i=GraphObject.build("Button");i.stretch=5;const e=i.findObject("ButtonBorder");return e instanceof Shape&&(e.figure="Rectangle",e.strokeWidth=0,e.spot1=new Spot(0,0,4,6),e.spot2=new Spot(1,1,-4,-4)),i}),GraphObject.defineBuilder("PanelExpanderButton",t=>{const i=GraphObject.takeBuilderArgument(t,"COLLAPSIBLE"),e=GraphObject.build("Button");e.attach({_buttonExpandedFigure:"M0 0 M0 6 L4 2 8 6 M8 8",_buttonCollapsedFigure:"M0 0 M0 2 L4 6 8 2 M8 8",_buttonFillNormal:"rgba(0, 0, 0, 0)",_buttonStrokeNormal:null,_buttonFillOver:"rgba(0, 0, 0, .2)",_buttonStrokeOver:null}),e.add(new Shape({name:"ButtonIcon",strokeWidth:2}).bindObject("geometryString","visible",n=>n?e._buttonExpandedFigure:e._buttonCollapsedFigure,void 0,i));const s=e.findObject("ButtonBorder");return s instanceof Shape&&(s.stroke=null,s.fill="rgba(0, 0, 0, 0)"),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=o.diagram;if(r===null||r.isReadOnly)return;let l=o.findBindingPanel();if(l===null&&(l=o.part),l!==null){const h=l.findObject(i);h!==null&&(n.handled=!0,r.startTransaction("Collapse/Expand Panel"),h.visible=!h.visible,r.commitTransaction("Collapse/Expand Panel"))}},e}),GraphObject.defineBuilder("CheckBoxButton",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("Button",{desiredSize:new Size(14,14)});e.attach({"ButtonBorder.spot1":new Spot(0,0,1,1),"ButtonBorder.spot2":new Spot(1,1,-1,-1)});const s=new Shape({name:"ButtonIcon",geometryString:"M0 0 M0 8.85 L4.9 13.75 16.2 2.45 M16.2 16.2",strokeWidth:2,stretch:2,geometryStretch:6,visible:!1});return i!==""&&s.bindTwoWay("visible",i),e.add(s),e.click=(n,o)=>{if(!(o instanceof Panel))return;const r=n.diagram;if(r===null||r.isReadOnly||i!==""&&r.model.isReadOnly)return;n.handled=!0;const l=o.findObject("ButtonIcon");r.startTransaction("checkbox"),l!==null&&(l.visible=!l.visible),typeof o._doClick=="function"&&o._doClick(n,o),r.commitTransaction("checkbox")},e}),GraphObject.defineBuilder("CheckBox",t=>{const i=GraphObject.takeBuilderArgument(t),e=GraphObject.build("CheckBoxButton",{name:"Button",isActionable:!1,margin:new Margin(0,1,0,0)},i),s=new Panel("Horizontal",{isActionable:!0,cursor:e.cursor,margin:new Margin(1),mouseEnter:e.mouseEnter,mouseLeave:e.mouseLeave,click:e.click}).attach({_buttonFillNormal:e._buttonFillNormal,_buttonStrokeNormal:e._buttonStrokeNormal,_buttonFillOver:e._buttonFillOver,_buttonStrokeOver:e._buttonStrokeOver,_buttonFillDisabled:e._buttonFillDisabled,_buttonClick:e.click});return s.add(e),e.mouseEnter=null,e.mouseLeave=null,e.click=null,s})}}class GraphObjectTemplateSettings{gi;Mt;$n;Ai;Zn;Ks;Sl;Tr;Dr;Fr;Er;Br;Rr;vr;Or;U0;V0;Ir;z0;X0;K0;Y0;Ur;Vr;M0;v0;ys;xr;br;to;R0;F0;wr;k0;H0;q0;constructor(){this.gi=!1,this.Mt="",this.$n=-1,this.Ai=null,this.Zn=null,this.Ks=null,this.Sl="",this.Tr=null,this.Dr=null,this.Fr=null,this.Er=null,this.Br=null,this.Rr=null,this.vr=null,this.Or=null,this.U0=null,this.V0=null,this.Ir=null,this.z0=null,this.X0=null,this.K0=null,this.Y0=null,this.Ur=null,this.Vr=null,this.M0=null,this.v0=null,this.ys=null,this.xr=Size.ru,this.br=Size.iC,this.to=1,this.R0=1,this.F0=1,this.wr=0,this.k0=null,this.H0=null,this.q0="category"}copy(){const t=new GraphObjectTemplateSettings;return t.Mt=this.Mt,t.$n=this.$n,t.Ai=this.Ai,t.Ks=this.Ks,t.Sl=this.Sl,t.Tr=this.Tr,t.Dr=this.Dr,t.Fr=this.Fr,t.Er=this.Er,t.Br=this.Br,t.Rr=this.Rr,t.vr=this.vr,t.Or=this.Or,t.U0=this.U0,t.V0=this.V0,t.Ir=this.Ir,t.z0=this.z0,t.X0=this.X0,t.K0=this.K0,t.Y0=this.Y0,t.Ur=this.Ur,t.Vr=this.Vr,t.M0=this.M0,t.v0=this.v0,t.ys=this.ys,t.xr=this.xr.N(),t.br=this.br.N(),t.to=this.to,t.R0=this.R0,t.F0=this.F0,t.wr=this.wr,t.k0=this.k0,t.H0=this.H0,t.q0=this.q0,t}}class STransform{m;constructor(){this.m=[1,0,0,1,0,0]}copy(){const t=new STransform;return t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5],t}translate(t,i){this.m[4]+=this.m[0]*t+this.m[2]*i,this.m[5]+=this.m[1]*t+this.m[3]*i}scale(t,i){this.m[0]*=t,this.m[1]*=t,this.m[2]*=i,this.m[3]*=i}rotate(t,i,e){if(t>=360?t-=360:t<0&&(t+=360),t===0)return;this.translate(i,e);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{const a=t*Math.PI/180;s=Math.cos(a),n=Math.sin(a)}const o=this.m[0]*s+this.m[2]*n,r=this.m[1]*s+this.m[3]*n,l=this.m[0]*-n+this.m[2]*s,h=this.m[1]*-n+this.m[3]*s;this.m[0]=o,this.m[1]=r,this.m[2]=l,this.m[3]=h,this.translate(-i,-e)}}class SGradient{type;x1;y1;r1;x2;y2;r2;colors;pattern;constructor(t){this.type=t,this.x1=0,this.y1=0,this.r1=0,this.x2=0,this.y2=0,this.r2=0,this.colors=[],this.pattern=null}addColorStop(t,i){this.colors.push({offset:t,color:i})}}class SVGSurface{Ft;ai;aa;Gu;m2;constructor(t,i,e){const s=i===void 0?root.document:i;this.aa=s,this.m2="http://www.w3.org/2000/svg";const n="http://www.w3.org/2000/xmlns/";s!==void 0&&(this.Ft=this.makeElement("svg",{width:"1px",height:"1px",viewBox:"0 0 1 1"}),this.style.display="block",this.style.letterSpacing="normal",this.style.wordSpacing="normal",e||(this.style.position="absolute"),this.Ft.setAttributeNS(n,"xmlns",this.m2),this.Ft.setAttributeNS(n,"xmlns:xlink","http://www.w3.org/1999/xlink")),this.Gu=null,this.ai=new SVGContext(this,e)}resize(t,i,e,s){return this.width!==t||this.height!==i?(this.width=t,this.height=i,this.style.width=e+"px",this.style.height=s+"px",this.Ft.setAttributeNS(null,"width",e+"px"),this.Ft.setAttributeNS(null,"height",s+"px"),this.Ft.setAttributeNS(null,"viewBox","0 0 "+e+" "+s),this.ai.p2.firstElementChild.setAttributeNS(null,"width",e+"px"),this.ai.p2.firstElementChild.setAttributeNS(null,"height",s+"px"),!0):!1}makeElement(t,i,e){const s=this.aa.createElementNS(this.m2,t);if(Util.wt(i))for(const n in i)s.setAttributeNS(n==="href"?"http://www.w3.org/1999/xlink":"",n,i[n]);return e!==void 0&&(s.textContent=e),s}getBoundingClientRect(){return this.Ft.getBoundingClientRect()}focus(){this.Ft.focus()}get width(){return this.Ft.width.baseVal.value}set width(t){this.Ft.setAttribute("width",t+"px")}get height(){return this.Ft.height.baseVal.value}set height(t){this.Ft.setAttribute("height",t+"px")}dispose(){this.aa=null}get style(){return this.Ft.style}}class SVGContext{nf;of;xn;Ti;Ke;fillStyle;font;globalAlpha;lineCap;lineDashOffset;lineJoin;lineWidth;miterLimit;shadowBlur;shadowColor;shadowOffsetX;shadowOffsetY;strokeStyle;textAlign;imageSmoothingEnabled;clipInsteadOfFill;lastCreatedElement;rf;lf;surface;svg;p2;cA;Vb;Xo;dh;ka;currentElement;clipPathGroup;diagramGroup;lastDrawnPart;currentPath;outerGroup;pathAttributes;tl;Mr;filter;partClipRect;constructor(t,i){this.surface=t,this.svg=t.Ft,this.rf=[],this.lf=[],this.fillStyle="#000000",this.font="10px sans-serif",this.globalAlpha=1,this.lineCap="butt",this.lineDashOffset=0,this.lineJoin="miter",this.lineWidth=1,this.miterLimit=10,this.shadowBlur=0,this.shadowColor="rgba(0, 0, 0, 0)",this.shadowOffsetX=0,this.shadowOffsetY=0,this.tl=!1,this.strokeStyle="#000000",this.textAlign="start",this.clipInsteadOfFill=!1,this.nf=0,this.of=0,this.xn=0,this.lastCreatedElement=null,this.currentElement=null,this.Ti=[],this.pathAttributes={},this.Vb=!1,this.Xo=null,this.dh=0,this.Ke=new STransform,this.clipPathGroup=this.newGroup2(),this.diagramGroup=this.newGroup2("gojs-diagram"),this.lastDrawnPart=null,this.currentPath=null;const e=GSet.su++,s=this.makeElement("clipPath",{id:"mainClip"+e}),n={x:0,y:0,width:t.width,height:t.height};s.appendChild(this.makeElement("rect",n)),this.p2=s,this.svg.appendChild(this.clipPathGroup),this.clipPathGroup.appendChild(this.diagramGroup),this.svg.appendChild(s),this.clipPathGroup.setAttributeNS(null,"clip-path","url(#mainClip"+e+")"),this.cA={},this.Mr=!!i,this.filter="",this.partClipRect=null}setDiagramPosScale(t,i,e,s,n,o){this.diagramGroup===void 0?this.newGroup(t,i,e,s,n,o):this.diagramGroup.setAttribute("transform","matrix("+t+", "+i+", "+e+", "+s+", "+n+", "+o+")")}resetInnerSVG(){this.diagramGroup!==null&&(this.diagramGroup.innerHTML="")}arc(t,i,e,s,n,o,r,l){const h=2*Math.PI,a=1e-6,c=h-a,f=e*Math.cos(s),u=e*Math.sin(s),d=t+f,m=i+u,g=o?0:1;let p=o?s-n:n-s;(Math.abs(r-d)>a||Math.abs(l-m)>a)&&this.Ti.push(["L",d,+m]),p<0&&(p=p%h+h),p>c?(this.Ti.push(["A",e,e,0,1,g,t-f,i-u]),this.Ti.push(["A",e,e,0,1,g,d,m])):p>a&&this.Ti.push(["A",e,e,0,+(p>=Math.PI),g,t+e*Math.cos(n),i+e*Math.sin(n)])}beginPath(){this.Ti=[],this.pathAttributes={stroke:"none",fill:"none"}}endPath(t){this.BR(this.Ti,this.Ke,t||0)}bezierCurveTo(t,i,e,s,n,o){this.Ti.push(["C",t,i,e,s,n,o])}clearRect(t,i,e,s){}clip(){this.pathAttributes.clipPath=!0}closePath(){this.Ti.push(["z"])}createLinearGradient(t,i,e,s){const n=new SGradient("linear");return n.x1=t,n.y1=i,n.x2=e,n.y2=s,n}createPattern(t,i){let e="";t instanceof HTMLCanvasElement&&(e=t.toDataURL()),t instanceof HTMLImageElement&&(e=t.getAttribute("src"));const s=this.cA;if(s[e])return"url(#"+s[e]+")";const n="PATTERN"+GSet.su++,o={width:t.width,height:t.height,id:n,patternUnits:"userSpaceOnUse"},r={x:0,y:0,width:t.width,height:t.height,href:e},l=this.makeElement("pattern",o);return l.appendChild(this.makeElement(Diagram.img,r)),this.svg.appendChild(l),s[e]=n,"url(#"+n+")"}createRadialGradient(t,i,e,s,n,o){const r=new SGradient("radial");return r.x1=t,r.y1=i,r.r1=e,r.x2=s,r.y2=n,r.r2=o,r}amendImageTransform(t,i,e,s,n,o,r,l){const h=r/e,a=l/s;(n!==0||o!==0)&&this.Ke.translate(n,o),(h!==1||a!==1)&&this.Ke.scale(h,a),(t!==0||i!==0)&&this.Ke.translate(-t,-i)}drawImage(t,i,e,s,n,o,r,l,h){let a="";t instanceof HTMLCanvasElement&&(a=t.toDataURL()),t instanceof HTMLImageElement&&(a=t.getAttribute("src"));const c=t instanceof HTMLImageElement?t.naturalWidth:t.width,f=t instanceof HTMLImageElement?t.naturalHeight:t.height;s===void 0&&(o=i,r=e,l=s=c,h=n=f),s=s||0,n=n||0,o=o||0,r=r||0,l=l||0,h=h||0,this.amendImageTransform(i,e,s,n,o,r,l,h);const u={x:0,y:0,width:c||s,height:f||n,href:a};!Geo.K(s,l)||!Geo.K(n,h)?u.preserveAspectRatio="none":a.toLowerCase().indexOf(".svg")===-1&&a.toLowerCase().indexOf("data:image/svg")===-1&&(u.preserveAspectRatio="xMidYMid slice"),(i!==0||e!==0||s!==c||n!==f)&&(s+=i,n+=e,u["clip-path"]=`path('M ${i},${e} L ${s} ${e} L ${s} ${n} L ${i} ${n} z')`),this.processCommon(Diagram.img,u,this.Ke),this.od(Diagram.img,u)}fill(t,i){t&&(this.pathAttributes["fill-rule"]="evenodd"),this.setFill(this.pathAttributes)}fillContext(t,i,e){this.clipInsteadOfFill?this.clip():this.fill(i,e)}createOrUpdateClipGroup(t,i){const e=this.newGroup(1,0,0,1,-i.x,-i.y);e.setAttributeNS(null,"class","spotClip"),t.rh=e}fillRect(t,i,e,s){this.addRect("fill",[t,i,e,s],this.Ke)}fillBackground(t,i,e,s){const n={x:t,y:i,width:e,height:s};this.processCommon("fill",n,this.Ke),this.setFill(n),this.svg.prepend(this.makeElement("rect",n))}fillText(t,i,e){this.addText("fill",[t,i,e],this.Ke)}lineTo(t,i){this.Ti.push(["L",t,i])}moveTo(t,i){this.Ti.push(["M",t,i])}quadraticCurveTo(t,i,e,s){this.Ti.push(["Q",t,i,e,s])}rect(t,i,e,s){this.Ti.push(["M",t,i],["L",t+e,i],["L",t+e,i+s],["L",t,i+s],["z"])}restore(){this.Ke=this.rf.pop(),this.Ti=this.rf.pop();const t=this.rf.pop();this.fillStyle=t.fillStyle,this.font=t.font,this.globalAlpha=t.globalAlpha,this.lineCap=t.lineCap,this.lineDashOffset=t.lineDashOffset,this.lineJoin=t.lineJoin,this.lineWidth=t.lineWidth,this.miterLimit=t.miterLimit,this.shadowBlur=t.shadowBlur,this.shadowColor=t.shadowColor,this.shadowOffsetX=t.shadowOffsetX,this.shadowOffsetY=t.shadowOffsetY,this.strokeStyle=t.strokeStyle,this.textAlign=t.textAlign,this.partClipRect=t.partClipRect}save(){const t={fillStyle:this.fillStyle,font:this.font,globalAlpha:this.globalAlpha,lineCap:this.lineCap,lineDashOffset:this.lineDashOffset,lineJoin:this.lineJoin,lineWidth:this.lineWidth,miterLimit:this.miterLimit,shadowBlur:this.shadowBlur,shadowColor:this.shadowColor,shadowOffsetX:this.shadowOffsetX,shadowOffsetY:this.shadowOffsetY,strokeStyle:this.strokeStyle,textAlign:this.textAlign,partClipRect:this.partClipRect};this.rf.push(t);const i=[];for(let e=0;eh.offset>a.offset?1:-1);for(let h=0;h1&&this.lf[this.lf.length-2].setAttributeNS(null,"clip-path",'path("'+s+'") view-box');return}if(n.d=s,this.processCommon("",n,i),this.currentPath!==null){const r=this.currentPath;if(r.nodeName!=="g")for(const l in n)l!=="transform"&&r.setAttributeNS(null,l,n[l]);else{const l=r.getElementsByTagName("path");for(const h in n)h!=="transform"&&l[e].setAttributeNS(null,h,n[h])}}else this.od("path",n)}TR(t){const i=t.getAttribute("clip-path");return i===null?null:this.svg.getElementById(i.split("#")[1].slice(0,-1))}rA(t){const i=t.getAttribute("clip-path");if(i===null)return;const e=this.svg.getElementById(i.split("#")[1].slice(0,-1));e!==null&&e.remove()}UR(t){const i=[];for(let e=0;es?(this.scale(s/n,1),this.translate((n-s)/2,0)):s>n&&(this.scale(1,n/s),this.translate(0,(s-n)/2)),this.fillOrClip(i,e),n>s?(this.translate(-(n-s)/2,0),this.scale(1/(s/n),1)):s>n&&(this.translate(0,-(s-n)/2),this.scale(1,1/(n/s))),!0}strokeContext(){this.clipInsteadOfFill||this.stroke()}fillOrClip(t,i){this.clipInsteadOfFill?this.clip(i):this.fill(t,i)}shadowsSet(t,i,e){this.nf=t,this.of=i,this.xn=e}shadowsOff(){this.tl=!1,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0}shadowsOn(){this.tl=!0,this.shadowOffsetX=this.nf,this.shadowOffsetY=this.of,this.shadowBlur=this.xn}enableDash(t,i){const e=this.U;e.setLineDash!==void 0&&(e.setLineDash(t),e.lineDashOffset=i)}disableDash(){const t=this.U;t.setLineDash!==void 0&&(t.setLineDash(CanvasSurfaceContext.EmptyArray),t.lineDashOffset=0)}clearContextCache(t){t&&(this.zb=""),this.Xb="",this.Kb=""}removePartFromView(t){}static EmptyArray=Object.freeze([])}var BrushType=(w=>(w[w.Solid=1]="Solid",w[w.Linear=2]="Linear",w[w.Radial=3]="Radial",w[w.Pattern=4]="Pattern",w))(BrushType||{}),ColorSpace=(w=>(w[w.Lab=1]="Lab",w[w.HSL=2]="HSL",w[w.Oklch=3]="Oklch",w))(ColorSpace||{});class ColorNumbers{n0;n1;n2;n3;constructor(){this.n0=0,this.n1=0,this.n2=0,this.n3=0}}class Brush{h;$;Pa;si;gs;W0;J0;bn;$0;yn;_c;Eb;constructor(t,i){if(GSet.Yi(this),this.h=!1,t===void 0)this.$=1,this.Pa="black";else if(typeof t=="string"){const s=Util.Ih(BrushType,t);s!==null?(this.$=s,this.Pa="black"):(this.$=1,this.Pa=t)}else this.$=t,this.Pa="black";const e=this.$;if(e===2?(this.si=Spot.TopCenter,this.gs=Spot.BottomCenter):e===3?(this.si=Spot.Center,this.gs=Spot.Center):(this.si=Spot.None,this.gs=Spot.None),this.W0=0,this.J0=NaN,this.bn=null,this.$0=null,this.yn=null,this._c=0,this.Eb=0,i){const s={};for(const n in i)isFinite(parseFloat(n))?this.addColorStop(parseFloat(n),i[n]):s[n]=i[n];Object.assign(this,s)}}copy(){const t=new Brush;return t.$=this.$,t.Pa=this.Pa,t.si=this.si.N(),t.gs=this.gs.N(),t.W0=this.W0,t.J0=this.J0,this.bn!==null&&(t.bn=this.bn.copy()),t.$0=this.$0,t}g(){return this.h=!0,this.bn!==null&&this.bn.g(),this}ot(){return Object.isFrozen(this)&&Util.o("cannot thaw constant: "+this),this.h=!1,this.bn!==null&&this.bn.ot(),this}ri(t){t in BrushType?this.type=t:Util.lr(this,t)}toString(){let t="Brush(";if(this.type===1)t+=this.color;else if(this.type===2?t+="Linear ":this.type===3?t+="Radial ":this.type===4?t+="Pattern ":t+="(unknown) ",t+=this.start+" "+this.end,this.colorStops!==null){const i=this.colorStops.iterator;for(;i.next();){const e=i.key,s=i.value;t+=" "+e+":"+s}}return t+=")",t}addColorStop(t,i){return this.h&&Util.T(this),(typeof t!="number"||!isFinite(t)||t>1||t<0)&&Util._(t,"0 <= loc <= 1",Brush,"addColorStop:loc"),Util.i(i,"string",Brush,"addColorStop:color"),this.bn===null&&(this.bn=new GMap),this.bn.set(t,i),this.$===1&&(this.type=2),this.yn=null,this}get type(){return this.$}set type(t){this.h&&Util.T(this,t),this.$=t,this.start.isNoSpot()&&(t===2?this.start=Spot.TopCenter:t===3&&(this.start=Spot.Center)),this.end.isNoSpot()&&(t===2?this.end=Spot.BottomCenter:t===3&&(this.end=Spot.Center)),this.yn=null}get color(){return this.Pa}set color(t){this.h&&Util.T(this,t),this.Pa=t,this.yn=null}get start(){return this.si}set start(t){this.h&&Util.T(this,t),this.si=t.N(),this.yn=null}get end(){return this.gs}set end(t){this.h&&Util.T(this,t),this.gs=t.N(),this.yn=null}get startRadius(){return this.W0}set startRadius(t){this.h&&Util.T(this,t),t<0&&Util._(t,">= zero",Brush,"startRadius"),this.W0=t,this.yn=null}get endRadius(){return this.J0}set endRadius(t){this.h&&Util.T(this,t),t<0&&Util._(t,">= zero",Brush,"endRadius"),this.J0=t,this.yn=null}get colorStops(){return this.bn}set colorStops(t){this.h&&Util.T(this,t),this.bn=t,this.yn=null}get pattern(){return this.$0}set pattern(t){this.h&&Util.T(this,t),this.$0=t,this.yn=null}static randomColor(t,i){t===void 0&&(t=128),i===void 0&&(i=Math.max(t,255));const e=Math.abs(i-t);let s=Math.floor(t+Math.random()*e).toString(16),n=Math.floor(t+Math.random()*e).toString(16),o=Math.floor(t+Math.random()*e).toString(16);return s.length<2&&(s="0"+s),n.length<2&&(n="0"+n),o.length<2&&(o="0"+o),"#"+s+n+o}static isValidColor(t){return root.CSS?root.CSS.supports("color",t):!0}static lighten(t){return Brush.lightenBy(t)}lightenBy(t,i){this.h&&Util.T(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Do(this.color),this.color=Brush.rd(e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Do(n.value),this.addColorStop(n.key,Brush.rd(e,s))}return this}static lightenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Do(t),Brush.rd(s,n)}static darken(t){return Brush.darkenBy(t)}darkenBy(t,i){this.h&&Util.T(this);const e=t===void 0||typeof t!="number"?.2:t,s=i===void 0?3:i;if(this.type===1)Brush.Do(this.color),this.color=Brush.rd(-e,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){const n=this.colorStops.iterator;for(;n.next();)Brush.Do(n.value),this.addColorStop(n.key,Brush.rd(-e,s))}return this}static darkenBy(t,i,e){const s=i===void 0||typeof i!="number"?.2:i,n=e===void 0?3:e;return Brush.Do(t),Brush.rd(-s,n)}static mix(t,i,e){Brush.Do(t);const s=Brush.G.n0,n=Brush.G.n1,o=Brush.G.n2,r=Brush.G.n3;Brush.Do(i),e===void 0&&(e=.5);const l=Math.round((Brush.G.n0-s)*e+s),h=Math.round((Brush.G.n1-n)*e+n),a=Math.round((Brush.G.n2-o)*e+o),c=Math.round((Brush.G.n3-r)*e+r);return`rgba(${l}, ${h}, ${a}, ${c})`}isDark(){if(this.type===1)return Brush.isDark(this.color);if((this.type===2||this.type===3)&&this.colorStops!==null){const t=this.colorStops;if(this.type===3)return Brush.isDark(t.first().value);if(t.get(.5)!==null)return Brush.isDark(t.get(.5));if(t.count===2){const l=t.toArray();return Brush.isDark(Brush.mix(l[0].value,l[1].value))}const i=t.iterator;let e=-1,s=-1,n=1,o=1;for(;i.next();){const l=i.key,h=Math.abs(.5-i.key);n>o&&h=n&&hs){let l=e;e=s,s=l,l=n,n=o,o=l}const r=s-e;return Brush.isDark(Brush.mix(t.get(e),t.get(s),1-o/r))}return!1}static isDark(t){return t?t instanceof Brush?t.isDark():(Brush.Do(t),(299*Brush.G.n0+587*Brush.G.n1+114*Brush.G.n2)/1e3<128):!1}static rd(t,i){switch(i){case 1:return Brush.VR(),Brush.io.n0=Math.min(100,Math.max(0,Brush.io.n0+100*t)),Brush.zR(),"rgba("+Brush.G.n0+", "+Brush.G.n1+", "+Brush.G.n2+", "+Brush.G.n3+")";case 2:return Brush.OS(),Brush.Ii.n2=Math.min(100,Math.max(0,Brush.Ii.n2+100*t)),"hsla("+Brush.Ii.n0+", "+Brush.Ii.n1+"%, "+Brush.Ii.n2+"%, "+Brush.Ii.n3+")";case 3:return Brush.XR(),Brush.eo.n0=Math.min(100,Math.max(0,Brush.eo.n0+100*t)),Brush.KR(),"rgba("+Brush.G.n0+", "+Brush.G.n1+", "+Brush.G.n2+", "+Brush.G.n3+")";default:Util.o("Unknown color space: "+i)}}static Do(t){const i=Brush.il;if(i===null)return;i.clearRect(0,0,1,1),i.fillStyle="#000000";const e=i.fillStyle;if(i.fillStyle=t,i.fillStyle!==e){i.fillRect(0,0,1,1);const s=i.getImageData(0,0,1,1).data;Brush.G.n0=s[0],Brush.G.n1=s[1],Brush.G.n2=s[2],Brush.G.n3=s[3]/255}else{i.fillStyle="#FFFFFF";const s=i.fillStyle;i.fillStyle=t,i.fillStyle,Brush.G.n0=0,Brush.G.n1=0,Brush.G.n2=0,Brush.G.n3=1}}static OS(){const t=Brush.G.n0/255,i=Brush.G.n1/255,e=Brush.G.n2/255,s=Math.max(t,i,e),n=Math.min(t,i,e),o=s-n;let r,l;const h=(s+n)/2;if(o===0)r=l=0;else{switch(s){case t:r=(i-e)/o%6;break;case i:r=(e-t)/o+2;break;case e:r=(t-i)/o+4;break}r*=60,r<0&&(r+=360),l=o/(1-Math.abs(2*h-1))}Brush.Ii.n0=Math.round(r),Brush.Ii.n1=Math.round(l*100),Brush.Ii.n2=Math.round(h*100),Brush.Ii.n3=Brush.G.n3}static uE(){const t=Brush.Ii.n0,i=Brush.Ii.n1/100,e=Brush.Ii.n2/100;let s,n,o;const r=(1-Math.abs(2*e-1))*i,l=t/60,h=r*(1-Math.abs(l%2-1));l>=0&&l<1?(s=r,n=h,o=0):l>=1&&l<2?(s=h,n=r,o=0):l>=2&&l<3?(s=0,n=r,o=h):l>=3&&l<4?(s=0,n=h,o=r):l>=4&&l<5?(s=h,n=0,o=r):l>=5&&l<6&&(s=r,n=0,o=h);const a=e-.5*r;s+=a,n+=a,o+=a,Brush.G.n0=Math.round(s*255),Brush.G.n1=Math.round(n*255),Brush.G.n2=Math.round(o*255),Brush.G.n3=Brush.Ii.n3}static VR(){Brush.fA(),Brush.YR()}static zR(){Brush.GR(),Brush.uA()}static w2(t){return t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}static b2(t){return t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055}static fA(){const t=Brush.w2(Brush.G.n0),i=Brush.w2(Brush.G.n1),e=Brush.w2(Brush.G.n2);Brush.Rt.n0=.4124564*t+.3575761*i+.1804375*e,Brush.Rt.n1=.2126729*t+.7151522*i+.072175*e,Brush.Rt.n2=.0193339*t+.119192*i+.9503041*e,Brush.Rt.n3=Brush.G.n3}static uA(){const t=3.2404542*Brush.Rt.n0+-1.5371385*Brush.Rt.n1+-.4985314*Brush.Rt.n2,i=-.969266*Brush.Rt.n0+1.8760108*Brush.Rt.n1+.041556*Brush.Rt.n2,e=.0556434*Brush.Rt.n0+-.2040259*Brush.Rt.n1+1.0572252*Brush.Rt.n2;Brush.G.n0=Brush.b2(t)*255,Brush.G.n1=Brush.b2(i)*255,Brush.G.n2=Brush.b2(e)*255,Brush.G.n3=Brush.Rt.n3,Brush.G.n0=Math.round(Brush.G.n0),Brush.G.n0>255?Brush.G.n0=255:Brush.G.n0<0&&(Brush.G.n0=0),Brush.G.n1=Math.round(Brush.G.n1),Brush.G.n1>255?Brush.G.n1=255:Brush.G.n1<0&&(Brush.G.n1=0),Brush.G.n2=Math.round(Brush.G.n2),Brush.G.n2>255?Brush.G.n2=255:Brush.G.n2<0&&(Brush.G.n2=0)}static k2=216/24389;static Yb=24389/27;static ld=[95.047,100,108.883];static P2(t){return t>Brush.k2?Math.pow(t,1/3):(Brush.Yb*t+16)/116}static YR(){const t=Brush.P2(Brush.Rt.n0*100/Brush.ld[0]),i=Brush.P2(Brush.Rt.n1*100/Brush.ld[1]),e=Brush.P2(Brush.Rt.n2*100/Brush.ld[2]);Brush.io.n0=116*i-16,Brush.io.n1=500*(t-i),Brush.io.n2=200*(i-e),Brush.io.n3=Brush.Rt.n3}static dA(t){const i=t*t*t;return i>Brush.k2?i:(116*t-16)/Brush.Yb}static GR(){const t=(Brush.io.n0+16)/116,i=Brush.io.n1/500+t,e=t-Brush.io.n2/200;Brush.Rt.n0=Brush.ld[0]/100*Brush.dA(i),Brush.Rt.n1=Brush.ld[1]/100*(Brush.io.n0>Brush.Yb*Brush.k2?Math.pow(t,3):Brush.io.n0/Brush.Yb),Brush.Rt.n2=Brush.ld[2]/100*Brush.dA(e),Brush.Rt.n3=Brush.io.n3}static jR(){let t=.8190224*Brush.Rt.n0+.3619062*Brush.Rt.n1+-.1288737*Brush.Rt.n2,i=.03298366*Brush.Rt.n0+.9292868*Brush.Rt.n1+.03614466*Brush.Rt.n2,e=.04817719*Brush.Rt.n0+.2642395*Brush.Rt.n1+.6335478*Brush.Rt.n2;t=Math.cbrt(t),i=Math.cbrt(i),e=Math.cbrt(e),Brush.ci.n0=.2104542*t+.7936177*i+-.004072046*e,Brush.ci.n1=1.977998*t+-2.428592*i+.4505937*e,Brush.ci.n2=.02590403*t+.7827717*i+-.8086757*e,Brush.ci.n3=Brush.Rt.n3,Brush.ci.n0*=100}static HR(){Brush.ci.n0/=100;let t=.9999999*Brush.ci.n0+.3963377*Brush.ci.n1+.2158037*Brush.ci.n2,i=1.000000009*Brush.ci.n0+-.1055613*Brush.ci.n1+-.06385417*Brush.ci.n2,e=1.00000005*Brush.ci.n0+-.08948418*Brush.ci.n1+-1.291485*Brush.ci.n2;t=t**3,i=i**3,e=e**3,Brush.Rt.n0=1.2268798*t+-.5578149*i+.281391*e,Brush.Rt.n1=-.04057576*t+1.112286*i+-.07171106*e,Brush.Rt.n2=-.07637294*t+-.4214933*i+1.586924*e,Brush.Rt.n3=Brush.ci.n3}static qR(){const t=Math.atan2(Brush.ci.n2,Brush.ci.n1)*180/Math.PI;Brush.eo.n0=Brush.ci.n0,Brush.eo.n1=Math.sqrt(Brush.ci.n1**2+Brush.ci.n2**2),Brush.eo.n2=t>=0?t:t+360,Brush.eo.n3=Brush.ci.n3}static WR(){Brush.ci.n0=Brush.eo.n0,Brush.ci.n1=Brush.eo.n1*Math.cos(Brush.eo.n2*Math.PI/180),Brush.ci.n2=Brush.eo.n1*Math.sin(Brush.eo.n2*Math.PI/180),Brush.ci.n3=Brush.eo.n3}static XR(){Brush.fA(),Brush.jR(),Brush.qR()}static KR(){Brush.WR(),Brush.HR(),Brush.uA()}static nd(t,i){typeof t=="string"||t instanceof Brush||Util.o("Value for "+i+" must be a color string or a Brush, not "+t)}static Solid=1;static Linear=2;static Radial=3;static Pattern=4;static Lab=1;static HSL=2;static il=Diagram.isUsingDOM()?new CanvasSurface(null,void 0,{willReadFrequently:!0}).ai:null;static G=new ColorNumbers;static Ii=new ColorNumbers;static Rt=new ColorNumbers;static io=new ColorNumbers;static ci=new ColorNumbers;static eo=new ColorNumbers}class PanelLayout{Mt="Base";static Layouts=new GMap;static definePanelLayout(t,i){i.name=t,PanelLayout.Layouts.set(t,i)}get name(){return this.Mt}set name(t){this.Mt=t}constructor(){}get classType(){return Panel}measure(t,i,e,s,n,o,r){}measureElement(t,i,e,s,n){t.ut(i,e,s,n)}arrange(t,i,e){}arrangeElement(t,i,e,s,n,o){t.zt(i,e,s,n,o)}remeasureObject(t){t.tf()}Gi(t,i,e){}}class PanelLayoutPosition extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=s.length,h=t.Ko();for(let a=0;a0&&(M=Math.max(Math.abs(k.x*o+k.offsetX-(S.x*o+S.offsetX))-g,0)),r>0&&(N=Math.max(Math.abs(k.y*r+k.offsetY-(S.y*r+S.offsetY))-g,0));const T=Size.l();T.e(0,0);const A=t.Ko();for(let v=0;v1,ot=it.columnSpan>1;(ct||ot)&&!(Ky&&(M=Math.max(y-dt,0)),b.ji=b.ji+M,b.actual=b.st+M,y=Math.max(y-(M+(mt?dt:0)),0)}if(it.columnSpan===1&&(N===0||N===4)){b=t.getColumnDefinition(j);const dt=b.computeEffectiveSpacing(),mt=b.st===0;M=Math.max(ut-b.actual,0),M+(mt?dt:0)>p&&(M=Math.max(p-dt,0)),b.ji=b.ji+M,b.actual=b.st+M,p=Math.max(p-(M+(mt?dt:0)),0)}(ct||ot)&&it.tf()}}}Util.tt(f);let A=0,D=0;l=t.columnCount;for(let K=0;K=t.rowCount);Z++)b=t.getRowDefinition(I.row+Z),M=0,N===2||N===4?M=Math.max(b.minimum,V[I.row+Z]===0?b.maximum:Math.min(V[I.row+Z],b.maximum)):M=Math.max(b.minimum,isNaN(b.ge)?b.maximum:Math.min(b.ge,b.maximum)),E.height+=M,_+=b.minimum;for(let Z=1;Z=t.columnCount);Z++)b=t.getColumnDefinition(I.column+Z),M=0,N===2||N===5?M=Math.max(b.minimum,U[I.column+Z]===0?b.maximum:Math.min(U[I.column+Z],b.maximum)):M=Math.max(b.minimum,isNaN(b.ge)?b.maximum:Math.min(b.ge,b.maximum)),E.width+=M,et+=b.minimum;X.width+=E.width,X.height+=E.height;const tt=I.margin,it=tt.right+tt.left,ct=tt.top+tt.bottom;I.ut(X.width,X.height,et,_);const ot=I.measuredBounds,lt=Math.max(ot.width+it,0),st=Math.max(ot.height+ct,0);let nt=0;for(let Z=0;Z=t.rowCount);Z++)b=t.getRowDefinition(I.row+Z),nt+=b.total||0;if(nt=t.rowCount);at++){b=t.getRowDefinition(I.row+at);const ut=b.st||0,gt=rt(I,b,ft);b.actual=Math.min(b.maximum,ut+gt),b.st!==ut&&(Z-=b.st-ut)}}for(;Z>0;){const rt=b.st||0;if(isNaN(b.height)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+Z),b.st!==rt&&(Z-=b.st-rt)),b.index===0)break;b=t.getRowDefinition(b.index-1)}}let ht=0;for(let Z=0;Z=t.columnCount);Z++)b=t.getColumnDefinition(I.column+Z),ht+=b.total||0;if(ht=t.columnCount);at++){b=t.getColumnDefinition(I.column+at);const ut=b.st||0,gt=rt(I,b,ft);b.actual=Math.min(b.maximum,ut+gt),b.st!==ut&&(Z-=b.st-ut)}}for(;Z>0;){const rt=b.st||0;if(isNaN(b.width)&&b.maximum>rt&&(b.actual=Math.min(b.maximum,rt+Z),b.st!==rt&&(Z-=b.st-rt)),b.index===0)break;b=t.getColumnDefinition(b.index-1)}}}Util.tt(u),Size.s(E),Size.s(X),V!==void 0&&Util.tt(V),U!==void 0&&Util.tt(U);let Y=0,G=0;const H=t.desiredSize,J=t.maxSize;N=t.zs(!0),A=0,D=0;let z=0,W=0;l=t.columnCount;for(let K=0;K0){for(;p!==c&&(u[p]===void 0||u[p].st===0);)p++;p=Math.max(Math.min(p,c-1),0),m=-u[p].position}let y=Math.min(t.leftIndex,f-1);if(d.length>0){for(;y!==f&&(d[y]===void 0||d[y].st===0);)y++;y=Math.max(Math.min(y,f-1),0),g=-d[y].position}let x=0,k=0;for(;x!==c&&u[x]===void 0;)x++;for(;k!==c&&d[k]===void 0;)k++;const b=t.part;let P=t.getRowDefinition(x),S=t.getColumnDefinition(k);for(let C=0;C=t.rowCount);st++){const nt=t.getRowDefinition(C+st);nt.st!==0&&(L.height+=nt.total)}for(let st=1;st=t.columnCount);st++){const nt=t.getColumnDefinition(N+st);nt.st!==0&&(L.width+=nt.total)}const O=T.st+L.width,B=M.st+L.height;let X=h,E=a;const V=O,U=B,Y=h,G=a;let H=O,J=B;h+O>e.width&&(H=Math.max(e.width-h,0)),a+B>e.height&&(J=Math.max(e.height-a,0));let z=R.alignment,W=0,q=0,Q=0,K=0;if(z.isDefault()){z=t.defaultAlignment,z.isSpot()||(z=Spot.Center),W=z.x,q=z.y,Q=z.offsetX,K=z.offsetY;const st=T.alignment,nt=M.alignment;st.isSpot()&&(W=st.x,Q=st.offsetX),nt.isSpot()&&(q=nt.y,K=nt.offsetY)}else W=z.x,q=z.y,Q=z.offsetX,K=z.offsetY;(isNaN(W)||isNaN(q))&&(W=.5,q=.5,Q=0,K=0);let I=v.width,j=v.height;const $=R.margin,et=$.left+$.right,_=$.top+$.bottom,tt=R.N0(M,T,!1);isNaN(R.desiredSize.width)&&(tt===2||tt===5)&&(I=Math.max(O-et,0)),isNaN(R.desiredSize.height)&&(tt===2||tt===4)&&(j=Math.max(B-_,0));const it=R.maxSize,ct=R.minSize;I=Math.min(it.width,I),j=Math.min(it.height,j),I=Math.max(ct.width,I),j=Math.max(ct.height,j);const ot=I+et,lt=j+_;X+=V*W-ot*W+Q+$.left,E+=U*q-lt*q+K+$.top,R.visible&&(Rect.contains(Y,G,H,J,X,E,v.width,v.height)?R.zt(X,E,I,j):R.zt(X,E,I,j,new Rect(Y,G,H,J)))}}}Size.s(L);for(let C=0;C0&&(b.figure==="LineV"||b.figure==="LineH")){if(i.lineWidth=b.strokeWidth,t.dn(i,b.stroke,!1,!1,l,h),i.beginPath(),b.figure==="LineV"){const D=Math.floor((m-o)/o);for(let F=D;F<=D+f;F++){const R=F*o+m;0<=R&&R<=a&&this.jb(F,P,L,N)&&(i.moveTo(R,0),i.lineTo(R,c))}}else if(b.figure==="LineH"){const D=Math.floor((g-r)/r);for(let F=D;F<=D+u;F++){const R=F*r+g;0<=R&&R<=c&&this.jb(F,P,L,N)&&(i.moveTo(0,R),i.lineTo(a,R))}}i.stroke(),i.endPath()}else if(b.fill!==null){if(t.dn(i,b.fill,!0,!1,l,h),b.figure==="BarV"){let D=b.width;isNaN(D)&&(D=o);const F=Math.floor((m-o)/o);for(let R=F;R<=F+f;R++){const v=R*o+m;0<=v+D&&v<=a&&this.jb(R,P,L,N)&&i.fillRect(v,0,D,c)}}else if(b.figure==="BarH"){let D=b.height;isNaN(D)&&(D=r);const F=Math.floor((g-r)/r);for(let R=F;R<=F+u;R++){const v=R*r+g;0<=v+D&&v<=c&&this.jb(R,P,L,N)&&i.fillRect(0,v,a,D)}}}T&&i.disableDash(),C!==1&&(i.globalAlpha=M)}}jb(t,i,e,s){if(i<0)return t%i===e;if(t%i!==e)return!1;const n=s.length;for(let o=0;ol&&r.push(d)}}t.xi.Z0=i}C2(t){return t==="LineV"||t==="BarV"}JR(t){let i=1,e=1;const s=t.L.r,n=s.length;for(let l=0;l=g){const z=Point.l();c.mA(z),O=c.midAngle,A!==0&&(v=c.computeAngle(L,A,O),L.Xt=v,L.ue(!0),L._n(!0)),F=z.x-u.x,R=z.y-u.y,Point.s(z)}else{let z,W,q=0;if(M>=0?(z=m.elt(M),W=M0?m.elt(q-1):z),O=0,z.equalsApprox(W)){let Q,K;M>=0?(Q=M>0?m.elt(M-1):z,K=M1?m.elt(q-2):W);const I=Q.distanceSquaredPoint(z),j=W.distanceSquaredPoint(K);I>j+10?O=M>=0?Q.directionPoint(z):z.directionPoint(Q):j>I+10?O=M>=0?W.directionPoint(K):K.directionPoint(W):O=M>=0?Q.directionPoint(K):K.directionPoint(Q)}else O=M>=0?z.directionPoint(W):W.directionPoint(z);A!==0&&(v=c.computeAngle(L,A,O),L.Xt=v,L.ue(!0),L._n(!0)),F=z.x+(W.x-z.x)*N-u.x,R=z.y+(W.y-z.y)*N-u.y}L.ut(1/0,1/0,0,0),C=L.measuredBounds;const B=L.naturalBounds;let X=0;L instanceof Shape&&(X=L.strokeWidth);const E=B.width+X,V=B.height+X;k.Ri(),k.Ds(-C.x,-C.y),k.et(L.scale,L.scale),k.cs(A===0?L.angle:O,E/2,V/2),(A===22||A===26)&&k.cs(90,E/2,V/2),(A===23||A===27)&&k.cs(-90,E/2,V/2),A===28&&(O>45&&O<135||O>225&&O<315)&&k.cs(-O,E/2,V/2);const U=new Rect(0,0,E,V);b.setRectSpot(U,T),k.xt(b);const Y=-b.x+X/2*L.scale,G=-b.y+X/2*L.scale;P.a(D);const H=isNaN(D.x),J=isNaN(D.y);if(H||J){const z=E/2+3,W=V/2+3,q=O>=45&&O<=135,Q=O>=225&&O<=315;A===0&&(q||Q)?(P.x=J?z:D.y,P.y=H?W:D.x,q?M>=0||isNaN(M)&&N<.5||H&&(P.y=-W):Q&&((M>=0||isNaN(M)&&N<.5)&&H&&(P.y=-W),J&&(P.x=-z))):(H&&(M>=0||isNaN(M)&&N<.5?P.x=z:P.x=-z),J&&(P.y=-W),P.rotate(O))}else P.rotate(O);F+=P.x,R+=P.y,U.e(F+Y,R+G,C.width,C.height),x.push(U),d.unionRect(U)}if(h!==null){const S=h.labelNodes;for(;S.next();)S.value.ut(1/0,1/0)}t.Yo=d,t.position.e(u.x+d.x,u.y+d.y),n.En(d.width||0,d.height||0),Transform.s(k),Point.s(b),Point.s(P)}arrange(t,i,e){const s=i.length;if(!(t instanceof Adornment||t instanceof Link))return;let n=t,o=null;t instanceof Adornment&&(o=t,n=o.adornedPart);const r=t,l=t instanceof Adornment?null:n.path,h=t.hf;if(h.length!==0){let u=0;if(l!==null&&u=2&&r instanceof Link){const u=r.labelNodes;for(;u.next();){const d=u.value;r.QR(d,c,a)}}o!==null?o.hd(!1):n.hd(!1);const f=t.pA(Point.l());t.location.e(t.position.x+f.x,t.position.y+f.y),Point.s(f)}measureLinkPath(t,i,e,s){if(s.Oo()===!1)return;let n=s.strokeWidth;if(n===0&&t instanceof Adornment&&t.type===Panel.Link&&t.adornedObject instanceof Shape&&(n=t.adornedObject.strokeWidth),n=n*s.et,t instanceof Link&&t.ct!==null){const o=t.geometry.bounds;s.Qn(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else if(t instanceof Adornment&&t.adornedPart.ct!==null){const o=t.adornedPart.ct.bounds;s.Qn(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else s.Qn(-(n/2),-(n/2),i+n,e+n);s._R(),s.ue(!1)}}PanelLayout.definePanelLayout("Link",new PanelLayoutLink);class PanelLayoutGraduated extends PanelLayout{constructor(){super()}measure(t,i,e,s,n,o,r){const l=t.findMainElement();t.je=[];const h=l.margin,a=h.right+h.left,c=h.top+h.bottom;l.ut(i,e,o,r);const f=l.measuredBounds,u=f.width,d=f.height,m=Math.max(u+a,0),g=Math.max(d+c,0),p=new Rect(-h.left,-h.top,m,g);t.je.push(p),n.a(p),this.determineGraduatedMarks(t,l);const y=t.ws;if(y===null)return;const x=s.length;for(let k=0;k45&&f<135||f>225&&f<315)&&P.cs(-f,k/2,b/2);const S=Rect.X(0,0,k,b),L=Point.l();L.setRectSpot(S,o),P.xt(L);const C=-L.x,M=-L.y,N=Point.l();N.a(l),isNaN(N.x)&&(N.x=k/2+3),isNaN(N.y)&&(N.y=-(b/2+3)),N.rotate(f),a+=N.x+C,c+=N.y+M;const T=new Rect(a,c,y.width,y.height),A=new Rect(y.x,y.y,y.width,y.height),D=new Rect(x.x,x.y,x.width,x.height);p.labelAngle=u,p.lineCount=n.lineCount,p.lines=n.getMetrics(),p.actualBounds=T,p.measuredBounds=A,p.naturalBounds=D,g===0?h.a(T):h.unionRect(T),Point.s(N),Point.s(L),Rect.s(S),Transform.s(P)}t.je!==null&&t.je.push(h),s.unionNoCheck(h.x,h.y,h.width,h.height)}determineGraduatedMarks(t,i){const e=i.geometry,s=i.strokeWidth,n=e.flattenedSegments,o=e.flattenedLengths,r=e.flattenedTotalLength,l=n.length;let h=0,a=0;const c=Util.nt();for(let x=0;xt.graduatedMin+M){const F=Math.floor((N-t.graduatedMin)/M);N-=F*M}const T=f[x],A=N,D=t.graduatedMax*1e-6;for(let F=1;N<=t.graduatedMax+D;F++){if(this.iv(t,N-t.graduatedTickBase,T)&&(N>t.graduatedMax&&(N=t.graduatedMax),(k.graduatedSkip===null||k instanceof TextBlock&&!k.graduatedSkip(N,k)||k instanceof Shape&&!k.graduatedSkip(N,k))&&(m=(N-t.graduatedMin)*r/t.graduatedRange,m>r&&(m=r),g<=m&&m<=p))){let R=c[L][C],v=o[L][C];for(;LS&&C.4995)return t;let o=t;if(i<.5?n>0?o=s[n-1]:Geo.K(e[0],e[e.length-2])&&Geo.K(e[1],e[e.length-1])&&(o=s[s.length-1]):i>.5&&(n+1180&&(t.9995)return(t+o)/2%360;if(r<10){const l=1-Math.abs(.5-i);return(t*l+o*(1-l))%360}}return t}tv(t){if(t.ns===null){const i=[],e=t.L.r,s=e.length;for(let n=0;nl&&r.push(c)}}t.ns=i}return t.ns}iv(t,i,e){const s=e.length;for(let n=0;n-l)return!1}return!0}Gi(t,i,e){const s=e.Qh;e.Qh=!0;const n=t.naturalBounds,o=n.width,r=n.height,l=i instanceof SVGContext;i.save(),i.beginPath(),i.rect(-1,-1,o+1,r+1),i.clip(),i.endPath();const h=t.findMainElement();h.Gi(i,e);let a=t.getDocumentScale()*e.scale;a<=0&&(a=1);const c=h.actualBounds,f=t.L.r,u=t.ws,d=f.length;for(let m=0;m(w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ViewboxStretch||{});class Panel extends GraphObject{$;L;$t;ad;Kn;el;so;Yo;A2;O;cd;lt;xi;Qt;fd;mh;Ys;constructor(t,i){if(super(),this.$=null,t===void 0)this.$=Panel.Position;else if(typeof t=="string"){const e=PanelLayout.Layouts.get(t);e!==null&&(this.$=e)}else t instanceof PanelLayout?this.$=t:t&&(this.$=Panel.Position,i=t);this.$===null&&Util.o("Panel type not specified or PanelLayout not loaded: "+t),this.n|=4194304|(this.$===Panel.Grid?1048576:0),this.L=new List,this.$t=Margin.Eg,this.ad=Spot.Default,this.Kn=1,this.el=null,this.so="",this.Yo=new Rect(NaN,NaN,NaN,NaN),this.A2=null,this.O=null,this.cd=6,this.xi=null,this.lt=null,this.Qt=null,this.fd=NaN,this.mh=null,this.Ys=null,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.$=this.$,t.$t=this.$t.N(),t.ad=this.ad.N(),t.Kn=this.Kn,t.so=this.so,t.Yo.a(this.Yo),this.O!==null&&(t.O=this.O.copy(t)),t.cd=this.cd,this.lt!==null&&(t.lt=this.lt.copy()),this.xi!==null&&(t.xi=this.xi.copy()),t.Qt=this.Qt,t.fd=this.fd,t.mh=this.mh}Vo(t){super.Vo(t),t.L=this.L;const i=t.L.r,e=i.length;for(let s=0;s= 0",Panel,"padding"),t=new Margin(t)):(t.left<0&&Util._(t.left,">= 0",Panel,"padding:value.left"),t.right<0&&Util._(t.right,">= 0",Panel,"padding:value.right"),t.top<0&&Util._(t.top,">= 0",Panel,"padding:value.top"),t.bottom<0&&Util._(t.bottom,">= 0",Panel,"padding:value.bottom"));const i=this.$t;i.equals(t)||(t=t.N(),this.$t=t,this.c(),this.t("padding",i,t))}get defaultAlignment(){return this.ad}set defaultAlignment(t){const i=this.ad;i.equals(t)||(t=t.N(),this.ad=t,this.c(),this.t("defaultAlignment",i,t))}get defaultStretch(){return this.Kn}set defaultStretch(t){const i=this.Kn;i!==t&&(this.Kn=t,this.c(),this.t("defaultStretch",i,t))}get defaultSeparatorPadding(){return this.O!==null?this.O.Q0:Margin.Eg}set defaultSeparatorPadding(t){typeof t=="number"&&(t=new Margin(t));const i=this.defaultSeparatorPadding;i.equals(t)||(t=t.N(),this.O===null&&(this.O=new TablePanelSettings),this.O.Q0=t,this.c(),this.t("defaultSeparatorPadding",i,t))}get defaultRowSeparatorStroke(){return this.O!==null?this.O._0:null}set defaultRowSeparatorStroke(t){const i=this.defaultRowSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.g(),this.O===null&&(this.O=new TablePanelSettings),this.O._0=t,this.C(),this.t("defaultRowSeparatorStroke",i,t))}get defaultRowSeparatorStrokeWidth(){return this.O!==null?this.O.tp:1}set defaultRowSeparatorStrokeWidth(t){const i=this.defaultRowSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.O===null&&(this.O=new TablePanelSettings),this.O.tp=t,this.c(),this.t("defaultRowSeparatorStrokeWidth",i,t))}get defaultRowSeparatorDashArray(){return this.O!==null?this.O.ip:null}set defaultRowSeparatorDashArray(t){const i=this.defaultRowSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",Panel,"defaultRowSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("defaultRowSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.O===null&&(this.O=new TablePanelSettings),this.O.ip=t,this.C(),this.t("defaultRowSeparatorDashArray",i,t)}}get defaultColumnSeparatorStroke(){return this.O!==null?this.O.ep:null}set defaultColumnSeparatorStroke(t){const i=this.defaultColumnSeparatorStroke;i!==t&&(t===null||typeof t=="string"||t instanceof Brush)&&(t instanceof Brush&&t.g(),this.O===null&&(this.O=new TablePanelSettings),this.O.ep=t,this.C(),this.t("defaultColumnSeparatorStroke",i,t))}get defaultColumnSeparatorStrokeWidth(){return this.O!==null?this.O.sp:1}set defaultColumnSeparatorStrokeWidth(t){const i=this.defaultColumnSeparatorStrokeWidth;i!==t&&isFinite(t)&&t>=0&&(this.O===null&&(this.O=new TablePanelSettings),this.O.sp=t,this.c(),this.t("defaultColumnSeparatorStrokeWidth",i,t))}get defaultColumnSeparatorDashArray(){return this.O!==null?this.O.np:null}set defaultColumnSeparatorDashArray(t){const i=this.defaultColumnSeparatorDashArray;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",Panel,"defaultColumnSeparatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("defaultColumnSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.O===null&&(this.O=new TablePanelSettings),this.O.np=t,this.C(),this.t("defaultColumnSeparatorDashArray",i,t)}}get gh(){return this.O!==null?this.O.gh:null}set gh(t){this.O===null&&(this.O=new TablePanelSettings),this.O.gh=t}get viewboxStretch(){return this.cd}set viewboxStretch(t){const i=this.cd;i!==t&&(this.cd=t,this.c(),this.t("viewboxStretch",i,t))}get gridCellSize(){return this.xi!==null?this.xi.ud:Size.tC}set gridCellSize(t){this.xi===null&&(this.xi=new GridPanelSettings);const i=this.xi.ud;if(!i.equals(t)){(!t.isReal()||t.width===0||t.height===0)&&Util.o("Invalid Panel.gridCellSize: "+t),this.xi.ud=t.N();const e=this.diagram;e!==null&&this===e.grid&&e.jr(),this.C(),this.t("gridCellSize",i,t)}}get gridOrigin(){return this.xi!==null?this.xi.dd:Point.Po}set gridOrigin(t){this.xi===null&&(this.xi=new GridPanelSettings);const i=this.xi.dd;if(!i.equals(t)){t.isReal()||Util.o("Invalid Panel.gridOrigin: "+t),this.xi.dd=t.N();const e=this.diagram;e!==null&&this===e.grid&&e.jr(),this.C(),this.t("gridOrigin",i,t)}}get graduatedMin(){return this.lt!==null?this.lt.op:0}set graduatedMin(t){const i=this.graduatedMin;if(i!==t&&(this.lt===null&&(this.lt=new GradPanelSettings),this.lt.op=t,this.c(),this.t("graduatedMin",i,t),this.$c())){const e=this.part;e!==null&&this.ya(e,"graduatedRange")}}get graduatedMax(){return this.lt!==null?this.lt.rp:100}set graduatedMax(t){const i=this.graduatedMax;if(i!==t&&(this.lt===null&&(this.lt=new GradPanelSettings),this.lt.rp=t,this.c(),this.t("graduatedMax",i,t),this.$c())){const e=this.part;e!==null&&this.ya(e,"graduatedRange")}}get graduatedRange(){return this.graduatedMax-this.graduatedMin}get graduatedTickUnit(){return this.lt!==null?this.lt.lp:10}set graduatedTickUnit(t){const i=this.graduatedTickUnit;i!==t&&t>0&&(this.lt===null&&(this.lt=new GradPanelSettings),this.lt.lp=t,this.c(),this.t("graduatedTickUnit",i,t))}get graduatedTickBase(){return this.lt!==null?this.lt.hp:0}set graduatedTickBase(t){const i=this.graduatedTickBase;i!==t&&(this.lt===null&&(this.lt=new GradPanelSettings),this.lt.hp=t,this.c(),this.t("graduatedTickBase",i,t))}get ws(){return this.lt!==null?this.lt.ws:null}set ws(t){this.lt!==null?this.lt.ws=t:t!==null&&(this.lt=new GradPanelSettings,this.lt.ws=t)}get je(){return this.lt!==null?this.lt.je:null}set je(t){this.lt!==null?this.lt.je=t:t!==null&&(this.lt=new GradPanelSettings,this.lt.je=t)}get ns(){return this.lt!==null?this.lt.ns:null}set ns(t){this.lt!==null?this.lt.ns=t:t!==null&&(this.lt=new GradPanelSettings,this.lt.ns=t)}get Se(){return this.lt!==null?this.lt.Se:null}set Se(t){this.lt!==null?this.lt.Se=t:t!==null&&(this.lt=new GradPanelSettings,this.lt.Se=t)}b0(t){super.b0(t);const i=this.L.r,e=i.length;for(let s=0;s0?this.Ye:null,s=this.columnCount>0?this.Ge:null;e!==null&&this.Hb(t,i,!0,e,!0),s!==null&&this.Hb(t,i,!1,s,!0),e!==null&&this.wA(t,!0,e),s!==null&&this.wA(t,!1,s),e!==null&&this.Hb(t,i,!0,e,!1),s!==null&&this.Hb(t,i,!1,s,!1)}wA(t,i,e){const s=e.length,n=this.actualBounds,o=this.naturalBounds;let r=!0;for(let l=0;lo.height)continue}else if(h.position>o.width)continue;let a=h.separatorStrokeWidth;isNaN(a)&&(a=i?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let c=h.separatorStroke;if(c===null&&(c=i?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),a===0||c===null)continue;this.dn(t,c,!1,!1,o,n);let f=!1,u=h.separatorDashArray;u===null&&(u=i?this.defaultRowSeparatorDashArray:this.defaultColumnSeparatorDashArray),u!==null&&(f=!0,t.enableDash(u,0)),t.beginPath();const d=h.position+a;i?d>o.height&&(a-=d-o.height):d>o.width&&(a-=d-o.width);let m=h.position+a/2;t.lineWidth=a;const g=this.$t;if(i){m+=g.top;const p=g.left,y=o.width-g.right;t.moveTo(p,m),t.lineTo(y,m)}else{m+=g.left;const p=g.top,y=o.height-g.bottom;t.moveTo(m,p),t.lineTo(m,y)}t.stroke(),t.endPath(),f&&t.disableDash()}}Hb(t,i,e,s,n){const o=s.length,r=this.actualBounds,l=this.naturalBounds,h=this.xA(!0),a=this.xA(!1);for(let c=0;cu)continue;let d=f.computeEffectiveSpacing(),m=f.separatorStrokeWidth;isNaN(m)&&(m=e?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let g=f.separatorStroke;g===null&&(g=e?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),(g===null||f.index===(e?h:a))&&(m=0),d-=m;const p=f.position+m;let y=d+f.actual;if(p+y>u&&(y=u-p),y<=0)continue;const x=this.$t;this.dn(t,f.background,!0,!1,l,r),e?t.fillRect(x.left,p+x.top,r.width-(x.left+x.right),y):t.fillRect(p+x.left,x.top,y,r.height-(x.top+x.bottom))}}xA(t){const i=t?this.rowCount:this.columnCount;for(let e=0;ex&&n.set(M),Point.s(M)),Point.s(S),o&&n.D(r),k}}Du(){const t=this.L.r,i=t.length;for(let e=0;ee||h>s)&&(this.c(),this.ut(l>e?e:l,h>s?s:h,0,0));break;case 2:this.c(!0),this.ut(e+c,s+f,0,0);break;case 5:this.c(!0),this.ut(e+c,h+f,0,0);break;case 4:this.c(!0),this.ut(l+c,s+f,0,0);break}}this.$.arrange(this,n,this.Yo)}hh(t){const i=this.naturalBounds,e=this.Ko();if(Rect.contains(0,0,i.width,i.height,t.x,t.y)){const s=this.L.r,n=s.length,o=Point.X(0,0);for(let r=n;r--;){const l=s[r];if(!(!l.visible&&l!==e)&&(o.set(t).Ie(l.D),l.containsPoint(o)))return Point.s(o),!0}return Point.s(o),this.Ct!==null}return!1}m0(t){if(this.$n===t)return this;const i=this.L.r,e=i.length;for(let s=0;sd.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;let m=f;const g=f instanceof Panel?f:null,p=Transform.l();p.set(r),(g!==null?g.vm(t,i,e,s,n,p):m.QL(t,s,p))&&(i!==null&&(m=i(m)),m!==null&&(e===null||e(m))&&n.add(m)),Transform.s(p)}}return o===void 0&&Transform.s(r),s}return o===void 0&&Transform.s(r),!1}D2(t,i,e){const s=this.L.r,n=s.length;for(let o=n;o--;){const r=s[o];if(!r.visible)continue;const l=r.actualBounds,h=this.naturalBounds;if(l.x>h.width||l.y>h.height||l.x+l.width<0||l.y+l.height<0)continue;r instanceof Panel&&r.D2(t,i,e);let a=r;t!==null&&(a=t(a)),a!==null&&(i===null||i(a))&&e.add(a)}}eL(t,i,e,s,n,o){if(this.pickable===!1)return!1;e===void 0&&(e=null),s===void 0&&(s=null);const r=this.naturalBounds,l=this.pn(),h=l?t:Point.X(t.x,t.y).Ie(this.D),a=l?i:Point.X(i.x,i.y).Ie(this.D),c=h.distanceSquaredPoint(a),f=h.x>0&&h.x0&&h.yP.width||b.y>P.height||b.x+b.width<0||b.y+b.height<0))continue;if(k.pn()){const C=k.D;d.set(t).Ie(C),m.set(i).Ie(C)}else d.set(t),m.set(i);let S=k;const L=k instanceof Panel?k:null;(L!==null?L.eL(d,m,e,s,n,o):S._L(d,m,n))&&(e!==null&&(S=e(S)),S!==null&&(s===null||s(S))&&o.add(S))}Point.s(d),Point.s(m)}return n?f:u}return!1}M2(t){let i=null;if(t instanceof Shape){i=t.spot1,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot1)}return i===null&&(i=Spot.TopLeft),i}N2(t){let i=null;if(t instanceof Shape){i=t.spot2,i===Spot.Default&&(i=null);const e=t.geometry;e!==null&&i===null&&(i=e.spot2)}return i===null&&(i=Spot.BottomRight),i}add(...t){for(let i=0;i=s.count&&t>=s.count)return;s.removeAt(r),n=r}else Util.o("element "+i.toString()+" has panel "+e.toString()+" but is not contained by it.")}(t<0||t>s.count)&&(t=s.count),s.insertAt(t,i),(t===0||i.isPanelMain)&&(this.el=null),this.Oo()||this.c(),i.c(!1),i.portId!==null?this.wn=!0:i instanceof Panel&&i.wn===!0&&(this.wn=!0),this.ns=null,this.isEnabledObject()||this.qb(i,!1);const o=this.part;if(o!==null){o.D0(),o.cf(),this.wn&&o instanceof Node&&(o.wn=!0),o.wn&&o instanceof Node&&(o.ne=null);const r=this.diagram;if(r!==null&&r.undoManager.isUndoingRedoing)return;n!==-1&&o.raiseChangedEvent(4,"elements",this,i,null,n,null),o.raiseChangedEvent(3,"elements",this,null,i,null,t)}}get wn(){return(this.n&8388608)!==0}set wn(t){(this.n&8388608)!==0!==t&&(this.n=this.n^8388608)}e2(){return(this.n&16777216)!==0}F2(t){t?this.n|=16777216:this.n&=-16777217}lv(t){t.xa(this),t.Qr=null;const i=this.L,e=i.count;i.insertAt(e,t);const s=this.part;if(s!==null){s.D0(),t.portId!==null&&s instanceof Node&&(s.wn=!0);const n=this.diagram;if(n!==null&&n.undoManager.isUndoingRedoing)return;s.raiseChangedEvent(3,"elements",this,null,t,null,e)}}AR(t){const i=this.L.r,e=i.length;let s=-1;for(let n=0;n=0&&this.te(t,!0)}te(t,i){const e=this.L,s=e.elt(t);if(s.Qr=null,s.xa(null),this.Ys!==null){const o=s.data;typeof o=="object"&&this.Ys.delete(o)}e.removeAt(t),this.ue(!1),this.c(),this.el===s&&(this.el=null),this.ns=null;const n=this.part;if(n!==null){n.D0(),n.cf(),n.invalidateAdornments(),n instanceof Node&&(s instanceof Panel?s.walkVisualTreeFrom(s,(r,l)=>n.u2(l,i)):n.u2(s,i));const o=this.diagram;if(o!==null&&o.undoManager.isUndoingRedoing)return;n.raiseChangedEvent(4,"elements",this,s,null,t,null)}}get Ye(){return this.O===null&&(this.O=new TablePanelSettings),this.O.Ye}get rowCount(){return this.O===null?0:this.Ye.length}getRowDefinition(t){t<0&&Util._(t,">= 0",Panel,"getRowDefinition:idx"),t=Math.round(t);const i=this.Ye;if(i[t]===void 0){const e=new RowColumnDefinition;e.xa(this),e.isRow=!0,e.index=t,i[t]=e,this.raiseChangedEvent(3,"rowdefs",this,null,e,null,t)}return i[t]}removeRowDefinition(t){if(t<0&&Util._(t,">= 0",Panel,"removeRowDefinition:idx"),this.rowCount===0)return;t=Math.round(t);const i=this.Ye,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"rowdefs",this,e,null,t,null),this.c()}}DL(t,i){const e=this.Ye;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.c()}}get Ge(){return this.O===null&&(this.O=new TablePanelSettings),this.O.Ge}get columnCount(){return this.O===null?0:this.Ge.length}getColumnDefinition(t){t<0&&Util._(t,">= 0",Panel,"getColumnDefinition:idx"),t=Math.round(t);const i=this.Ge;if(i[t]===void 0){const e=new RowColumnDefinition;e.xa(this),e.isRow=!1,e.index=t,i[t]=e,this.raiseChangedEvent(3,"coldefs",this,null,e,null,t)}return i[t]}removeColumnDefinition(t){if(t<0&&Util._(t,">= 0",Panel,"removeColumnDefinition:idx"),this.columnCount===0)return;t=Math.round(t);const i=this.Ge,e=i[t];if(e){i[t]=void 0;let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--;this.raiseChangedEvent(4,"coldefs",this,e,null,t,null),this.c()}}FL(t,i){const e=this.Ge;if(!(t<0)){if(e[t]=i instanceof RowColumnDefinition?i:void 0,!i){let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--}this.c()}}addRowColumnDefinition(t){let i=null;return t.isRow?i=this.getRowDefinition(t.index):t.isRow||(i=this.getColumnDefinition(t.index)),i&&i.Ub(t),this}addRowDefinition(t,i){const e=this.getRowDefinition(t);return e&&e.Ub(new RowColumnDefinition(i)),this}addColumnDefinition(t,i){const e=this.getColumnDefinition(t);return e&&e.Ub(new RowColumnDefinition(i)),this}get rowSizing(){return this.O!==null?this.O.cp:3}set rowSizing(t){const i=this.rowSizing;i!==t&&(this.O===null&&(this.O=new TablePanelSettings),this.O.cp=t,this.c(),this.t("rowSizing",i,t))}get columnSizing(){return this.O!==null?this.O.fp:3}set columnSizing(t){const i=this.columnSizing;i!==t&&(this.O===null&&(this.O=new TablePanelSettings),this.O.fp=t,this.c(),this.t("columnSizing",i,t))}get topIndex(){return this.O!==null?this.O.dp:0}set topIndex(t){const i=this.topIndex;i!==t&&((!isFinite(t)||t<0)&&Util.o("Panel.topIndex must be greater than zero and a real number, not: "+t),this.O===null&&(this.O=new TablePanelSettings),this.O.dp=t,this.c(),this.t("topIndex",i,t))}get leftIndex(){return this.O!==null?this.O.gp:0}set leftIndex(t){const i=this.leftIndex;i!==t&&((!isFinite(t)||t<0)&&Util.o("Panel.leftIndex must be greater than zero and a real number, not: "+t),this.O===null&&(this.O=new TablePanelSettings),this.O.gp=t,this.c(),this.t("leftIndex",i,t))}findRowForLocalY(t){if(t<0||this.type!==Panel.Table||this.rowCount===0)return-1;let i=0;const e=this.Ye,s=e.length;let n=this.topIndex;for(;n{o.lh();const r=o.Ai;if(r!==null){o.a2(!1);const l=r.iterator;for(;l.next();){const h=l.value;h.mode===2&&o.a2(!0);const a=h.sourceName;if(h.isToObject){a==="/"&&n.F2(!0);const c=h.ZL(n,o);c!==null&&(i.add(c),c.Zn===null&&(c.Zn=new List),c.Zn.add(h))}t.add(h)}}if(o instanceof Panel&&o.type===Panel.Table){if(o.rowCount>0){const l=o.Ye,h=l.length;for(let a=0;a0){const l=o.Ge,h=l.length;for(let a=0;a0&&o instanceof Panel){const h=r.substring(0,l),a=r.substring(l+1),c=o.findObject(h);c!==null?(o=c,n.targetProperty=a):(Util.ii('Warning: unable to find GraphObject named "'+h+'" for Binding: '+n.toString()),o=null)}if(o instanceof RowColumnDefinition){const h=GSet.as(o.panel);n.targetId=h===void 0?-1:h,o.panel.$n=n.targetId}else if(o instanceof GraphObject){const h=GSet.as(o);n.targetId=h===void 0?-1:h,o.$n=n.targetId}else Util.o("Unknown type of binding target: "+o);n.check(o)}}return t.g(),this instanceof Part&&this.Pe()&&this.ensureBounds(),this}static dE=!1;copyTemplate(t){t===void 0&&(t=!1);const i=this.copy();return i.hv(e=>{e instanceof Panel&&(e.Ks=null,e.Qt=null);const s=e.Ai;s!==null&&(e.Ai=null,s.each(o=>e.bind(o.copy())));const n=e.ys;n!==null&&(e.ys=null,n.each(o=>e.trigger(o.value.copy())))}),t&&i.li(),i}updateTargetBindings(t){const i=this.Ks;if(i===null)return;t===void 0&&(t="");const e=i.iterator;for(;e.next();){const s=e.value,n=this.MA(s,t);if(n===null)continue;const{data:o,elt:r}=n;s.isToTheme&&this.diagram===null||r!==void 0&&s.updateTarget(r,o)}}Io(){if(this.diagram!==null)if(this.d2()){const t=this.Ks.iterator;for(;t.next();){const i=t.value;if(!i.isToTheme)continue;const e=this.MA(i);if(e===null)continue;const{data:s,elt:n}=e;n!==void 0&&i.updateTarget(n,s)}}else{const t=this.L.r,i=t.length;for(let e=0;e0;let r=0;for(;n0){const i=this.L.elt(0);if(i.isPanelMain&&i instanceof Panel&&i._r())return 1}return 0}rebuildItemElements(){const t=this.ap();for(;this.L.length>t;)this.te(this.L.length-1,!1);this.NA(null,this.itemArray)}NA(t,i){const e=this.ap(),s=i;if(s===null||s.length===0){for(;this.L.length>e;)this.te(this.L.length-1,!1);return}if(this.L.length<=e){const n=s.length;for(let o=0;o(w[w.Default=1]="Default",w[w.None=2]="None",w[w.ProportionalExtra=3]="ProportionalExtra",w))(Sizing||{});class RowColumnDefinition{Vs;mp;Dt;Sa;Ma;oi;at;md;to;Go;pd;yd;Na;Ct;wd;Gs;st;ji;ge;constructor(t){GSet.Yi(this),this.Vs=null,this.mp=!0,this.Dt=0,this.ge=NaN,this.Sa=0,this.Ma=1/0,this.oi=Spot.Default,this.st=0,this.ji=0,this.at=0,this.Gs=null,this.md=1,this.to=1,this.Go=null,this.pd=null,this.yd=NaN,this.Na=null,this.Ct=null,this.wd=!1,t&&(Object.assign(this,t),t.column!==void 0?(this.isRow=!1,this.index=t.column):t.row!==void 0&&(this.isRow=!0,this.index=t.row))}copy(){const t=new RowColumnDefinition;return t.mp=this.mp,t.Dt=this.Dt,t.ge=this.ge,t.Sa=this.Sa,t.Ma=this.Ma,t.oi=this.oi,t.st=this.st,t.ji=this.ji,t.at=this.at,t.to=this.to,t.md=this.md,this.Go===null?t.Go=null:t.Go=this.Go.N(),t.pd=this.pd,t.yd=this.yd,t.Na=null,this.Na!==null&&(t.separatorDashArray=this.separatorDashArray.slice()),t.Ct=this.Ct,t.wd=this.wd,t.Gs=this.Gs,t}Ub(t){t.isRow?this.height=t.height:this.width=t.width,this.minimum=t.minimum,this.maximum=t.maximum,this.alignment=t.alignment,this.stretch=t.stretch,this.sizing=t.sizing,this.Go=t.separatorPadding===null?null:t.separatorPadding.N(),this.separatorStroke=t.separatorStroke,this.separatorStrokeWidth=t.separatorStrokeWidth,this.Na=null,t.separatorDashArray&&(this.Na=t.separatorDashArray.slice()),this.background=t.background,this.coversSeparators=t.coversSeparators,this.Gs=t.Gs}ri(t){t in Sizing?this.sizing=t:Util.lr(this,t)}toString(){return"RowColumnDefinition "+(this.isRow?"(Row ":"(Column ")+this.index+") #"+GSet.as(this)}static Default=1;static None=2;static ProportionalExtra=3;xa(t){this.Vs=t}computeEffectiveSpacingTop(t){let i=0;const e=this.Vs;if(this.index!==t){let n=this.separatorStroke;n===null&&e!==null&&(n=this.isRow?e.defaultRowSeparatorStroke:e.defaultColumnSeparatorStroke),n!==null&&(i=this.separatorStrokeWidth,isNaN(i)&&(e!==null?i=this.isRow?e.defaultRowSeparatorStrokeWidth:e.defaultColumnSeparatorStrokeWidth:i=0))}let s=this.Go;if(s===null)if(e!==null)s=e.defaultSeparatorPadding;else return i;return i+(this.isRow?s.top:s.left)}computeEffectiveSpacing(){let t=0;const i=this.Vs;let e=0;const s=this.isRow;if(i!==null&&i.type===Panel.Table){const o=s?i.Ye.length:i.Ge.length;for(let r=0;r= 0",RowColumnDefinition,"height"),this.ge=t,this.actual=this.st,this.panel!==null&&this.panel.c(),this.t("height",i,t))}get width(){return this.ge}set width(t){const i=this.ge;i!==t&&(t<0&&Util._(t,">= 0",RowColumnDefinition,"width"),this.ge=t,this.actual=this.st,this.panel!==null&&this.panel.c(),this.t("width",i,t))}get minimum(){return this.Sa}set minimum(t){const i=this.Sa;i!==t&&((t<0||!isFinite(t))&&Util._(t,">= 0",RowColumnDefinition,"minimum"),this.Sa=t,this.actual=this.st,this.panel!==null&&this.panel.c(),this.t("minimum",i,t))}get maximum(){return this.Ma}set maximum(t){const i=this.Ma;i!==t&&(t<0&&Util._(t,">= 0",RowColumnDefinition,"maximum"),this.Ma=t,this.actual=this.st,this.panel!==null&&this.panel.c(),this.t("maximum",i,t))}get alignment(){return this.oi}set alignment(t){const i=this.oi;i.equals(t)||(this.oi=t.N(),this.panel!==null&&this.panel.c(),this.t("alignment",i,t))}get stretch(){return this.to}set stretch(t){const i=this.to;i!==t&&(this.to=t,this.panel!==null&&this.panel.c(),this.t("stretch",i,t))}get separatorPadding(){return this.Go}set separatorPadding(t){typeof t=="number"&&(t=new Margin(t));const i=this.Go;(t===null||i===null||!i.equals(t))&&(t!==null&&(t=t.N()),this.Go=t,this.panel!==null&&this.panel.c(),this.t("separatorPadding",i,t))}get separatorStroke(){return this.pd}set separatorStroke(t){const i=this.pd;i!==t&&(t!==null&&Brush.nd(t,"RowColumnDefinition.separatorStroke"),t instanceof Brush&&t.g(),this.pd=t,this.panel!==null&&this.panel.c(),this.t("separatorStroke",i,t))}get separatorStrokeWidth(){return this.yd}set separatorStrokeWidth(t){const i=this.yd;i!==t&&(this.yd=t,this.panel!==null&&this.panel.c(),this.t("separatorStrokeWidth",i,t))}get separatorDashArray(){return this.Na}set separatorDashArray(t){const i=this.Na;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",RowColumnDefinition,"separatorDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("separatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.Na=t,this.panel!==null&&this.panel.C(),this.t("separatorDashArray",i,t)}}get background(){return this.Ct}set background(t){const i=this.Ct;i!==t&&(t!==null&&Brush.nd(t,"RowColumnDefinition.background"),t instanceof Brush&&t.g(),this.Ct=t,this.panel!==null&&this.panel.C(),this.t("background",i,t))}get coversSeparators(){return this.wd}set coversSeparators(t){const i=this.wd;i!==t&&(Util.i(t,"boolean",RowColumnDefinition,"coversSeparators"),this.wd=t,this.panel!==null&&this.panel.C(),this.t("coversSeparators",i,t))}get sizing(){return this.md}set sizing(t){const i=this.md;i!==t&&(this.md=t,this.panel!==null&&this.panel.c(),this.t("sizing",i,t))}Gb(){if(this.sizing===1){const t=this.Vs;return this.isRow?t.rowSizing:t.columnSizing}return this.sizing}get actual(){return this.st}set actual(t){isNaN(this.ge)?this.st=Math.max(Math.min(this.Ma,t),this.Sa):this.st=Math.max(Math.min(this.Ma,this.ge),this.Sa)}get measured(){return this.ji}set measured(t){this.ji=t}get total(){return this.st+this.computeEffectiveSpacing()}get position(){return this.at}set position(t){this.at=t}bind(t,i,e,s){return this.sf(t,i,e,s),this}bindTwoWay(t,i,e,s){const n=this.sf(t,i,e,s);return s===void 0&&n.makeTwoWay(),this}theme(t,i,e,s,n){return this.uh(t,i,e,s,n),this}themeData(t,i,e,s,n){return this.uh(t,i,e,s,n).ofData(),this}themeObject(t,i,e,s,n,o){return this.uh(t,i,e,s,n).ofObject(o),this}themeModel(t,i,e,s,n){return this.uh(t,i,e,s,n).ofModel(),this}sf(t,i,e,s){let n=null;return typeof t=="string"?n=new Binding(t,i,e,s):n=t,this.G0(n),n}uh(t,i,e,s,n){let o=null;return typeof t=="string"?o=new ThemeBinding(t,i,e,s,n):o=t,this.G0(o),o}G0(t){t.ke=this;const i=this.panel;if(i!==null){const e=i.findBindingPanel();e!==null&&e.aA()&&Util.o("Cannot add a Binding to a RowColumnDefinition that is already frozen: "+t+" on "+i)}this.Gs===null&&(this.Gs=new List),this.Gs.add(t)}}class Shape extends GraphObject{ct;xs;xd;Ca;Hi;jo;Xo;Lt;bd;kd;J;constructor(t,i){super(),this.ct=null,this.xs=null,this.xd="None",this.Ca="black",this.Hi="black",this.jo=1,this.Xo=null,this.Lt=null,this.bd=NaN,this.kd=NaN,this.J=null,typeof t=="string"?this.figure=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.ct=this.ct,t.xs=this.xs,t.xd=this.xd,t.Ca=this.Ca,t.Hi=this.Hi,t.jo=this.jo,this.Xo!==null&&(t.Xo=this.Xo.slice()),this.Lt!==null&&(this.Lt.gi?t.Lt=this.Lt:t.Lt=this.Lt.copy()),t.bd=this.bd,t.kd=this.kd,this.J!==null&&(t.J=this.J.copy())}La(){this.Lt===null?this.Lt=new ShapeTemplateSettings:this.Lt.gi&&(this.Lt=this.Lt.copy())}lh(){super.lh(),this.Lt!==null&&(this.Lt.gi=!0)}ri(t){t in GeometryStretch?this.geometryStretch=t:super.ri(t)}toString(){return"Shape("+(this.figure!=="None"?this.figure:this.toArrow!=="None"?this.toArrow:this.fromArrow)+")#"+GSet.as(this)}mv(t,i){const e=this.pathPattern;e.ut(1/0,1/0);const s=e.measuredBounds;e.zt(0,0,s.width,s.height);const n=this.geometry;t.save(),t.beginPath();const o=Util.nt();if(n.type===1)o.push(n.startX),o.push(n.startY),o.push(n.endX),o.push(n.endY),this.Pd(t,i,o,e);else if(n.type===4){const r=n.figures.iterator;for(;r.next();){const l=r.value;o.length=0,o.push(l.startX),o.push(l.startY);let h=l.startX,a=l.startY,c=h,f=a;const u=l.segments.r,d=u.length;for(let m=0;m=.1;){if(M===0&&(S?(b=k,b-=P,y-=P,S=!1):b=k,b===0&&(b=1)),b>y){b=y,Util.tt(x);return}b>p?(M=b-p,b=p):M=0;let N=Math.sqrt(b*b/(1+m*m));if(u<0&&(N=-N),h+=N,a+=m*N,t.translate(h,a),t.rotate(g),t.translate(-(r/2),-(l/2)),M===0&&s.fh(t,i),t.translate(r/2,l/2),t.rotate(-g),t.translate(-h,-a),y-=b,p-=b,M!==0){if(L++,L===x.length){Util.tt(x);return}C=x[L],u=C[0],g=C[1],m=C[2],p=C[3],b=M}}Util.tt(x)}fh(t,i){const e=t instanceof SVGContext;let s=this.Hi;const n=this.Ca;if(s===null&&n===null)return;const o=this.ct;if(o===null)return;t.commitTransform();const r=this.actualBounds,l=this.naturalBounds;n!==null&&this.dn(t,n,!0,!1,l,r);const h=this.part;let a=this.jo;s!==null&&a===0&&h!==null&&(this.isPanelMain||h.findMainElement()===this)&&(a=h.yv()),a===0&&(s=null),s!==null&&a!==0&&(this.dn(t,s,!1,!1,l,r),t.lineWidth=a,t.lineJoin=this.strokeJoin,t.lineCap=this.strokeCap,t.miterLimit=this.strokeMiterLimit);let c=!1;h&&i.getRenderingHint("drawShadows")&&(c=h.isShadowed),t.tl===!1&&(c=!1);let f=!0;s!==null&&(n===null||n==="transparent")&&(f=!1);let u=!1;const d=this.strokeDashArray;if(d!==null&&(u=!0,t.enableDash(d,this.strokeDashOffset)),o.type===1)t.beginPath(),t.moveTo(o.startX,o.startY),t.lineTo(o.endX,o.endY),s!==null&&t.strokeContext(),t.endPath();else if(o.type===2){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.min(m,p),k=Math.min(g,y),b=Math.abs(p-m),P=Math.abs(y-g);t.beginPath(),t.rect(x,k,b,P),n!==null&&t.fillContext(n,!1,null),s!==null&&(f&&c&&t.shadowsOff(),t.strokeContext(),f&&c&&t.shadowsOn()),t.endPath()}else if(o.type===3){const m=o.startX,g=o.startY,p=o.endX,y=o.endY,x=Math.abs(p-m)/2,k=Math.abs(y-g)/2,b=Math.min(m,p)+x,P=Math.min(g,y)+k;t.beginPath(),t.moveTo(b,P-k),t.bezierCurveTo(b+Geo.Bn*x,P-k,b+x,P-Geo.Bn*k,b+x,P),t.bezierCurveTo(b+x,P+Geo.Bn*k,b+Geo.Bn*x,P+k,b,P+k),t.bezierCurveTo(b-Geo.Bn*x,P+k,b-x,P+Geo.Bn*k,b-x,P),t.bezierCurveTo(b-x,P-Geo.Bn*k,b-Geo.Bn*x,P-k,b,P-k),t.closePath(),n!==null&&t.fillContext(n,!1,null),s!==null&&(f&&c&&t.shadowsOff(),t.strokeContext(),f&&c&&t.shadowsOn()),t.endPath()}else if(o.type===4){const m=o.figures,g=m.length;for(let p=0;p1||this.pathPattern!==null?!0:super.ed(t)}l2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("path");for(let s=0;s1,i);Util.o("Unknown Geometry type: "+e.type)}}Qu(t,i,e,s){const n=this.desiredSize,o=this.jo;t=Math.max(t,0),i=Math.max(i,0);let r;if(this.xs!==null)r=this.geometry.bounds;else{const g=this.figure;let p=Shape.I2[g];if(p===void 0){let y=Geo.So[g];typeof y=="string"&&(y=Geo.So[y]),typeof y=="function"?(p=y(null,100,100),Shape.I2[g]=p):Util.o("Unsupported Figure: "+g)}r=p.bounds}let l=r.width,h=r.height,a=r.width,c=r.height;switch(this.zs(!0)){case 0:e=0,s=0;break;case 2:a=Math.max(t-o,0),c=Math.max(i-o,0);break;case 5:a=Math.max(t-o,0),s=0;break;case 4:e=0,c=Math.max(i-o,0);break}isFinite(n.width)&&(a=n.width),isFinite(n.height)&&(c=n.height);const u=this.maxSize,d=this.minSize;e=Math.max(e-o,d.width),s=Math.max(s-o,d.height),a=Math.min(u.width,a),c=Math.min(u.height,c),a=isFinite(a)?Math.max(e,a):Math.max(l,e),c=isFinite(c)?Math.max(s,c):Math.max(h,s);const m=this._P();switch(m){case 0:break;case 2:l=a,h=c;break;case 6:{let g=Math.min(a/l,c/h);isFinite(g)||(g=1),l=l*g,h=h*g;break}default:Util.o(m+" is not a valid geometryStretch.")}if(this.xs!==null){l===0&&(l=.001),h===0&&(h=.001);const p=(this.xs!==null?this.xs:this.ct).KD(l,h);this.ct=p}else(this.ct===null||!Geo.K(this.ct.sc,t-o)||!Geo.K(this.ct.nc,i-o))&&(this.ct=Shape.wv(this,l,h));r=this.ct.bounds,t===1/0||i===1/0?this.Qn(r.x-o/2,r.y-o/2,t===0&&l===0?0:r.width+o,i===0&&h===0?0:r.height+o):this.Qn(-(o/2),-(o/2),a+o,c+o),n.isReal()?(a=n.width,c=n.height,a=Math.min(u.width,a),c=Math.min(u.height,c),a=Math.max(d.width,a),c=Math.max(d.height,c),this.Vi.e(0,0,a,c)):this.Vi.a(r)}_P(){const t=this.geometryStretch;return this.xs!==null?t===1?2:t:t===1?Shape.I2[this.figure].defaultStretch:t}ah(t,i,e,s){this.commonArrange(t,i,e,s)}getNearestIntersectionPoint(t,i,e){return this.Zc(t.x,t.y,i.x,i.y,e)}Zc(t,i,e,s,n){const o=this.D,r=1/(o.m11*o.m22-o.m12*o.m21),l=o.m22*r,h=-o.m12*r,a=-o.m21*r,c=o.m11*r,f=r*(o.m21*o.dy-o.m22*o.dx),u=r*(o.m12*o.dx-o.m11*o.dy),d=t*l+i*a+f,m=t*h+i*c+u,g=e*l+s*a+f,p=e*h+s*c+u,y=this.jo/2;let x=this.ct;x===null&&(this.ut(1/0,1/0),x=this.ct);const k=x.bounds;let b=!1;if(x.type===1)if(this.strokeWidth<=1.5)b=Geo.Vn(x.startX,x.startY,x.endX,x.endY,d,m,g,p,n);else{let P=0,S=0;if(x.startX===x.endX)P=y,S=0;else{const T=(x.endY-x.startY)/(x.endX-x.startX);S=y/Math.sqrt(1+T*T),P=S*T}const L=Util.nt();let C=new Point;Geo.Vn(x.startX+P,x.startY+S,x.endX+P,x.endY+S,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Vn(x.startX-P,x.startY-S,x.endX-P,x.endY-S,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Vn(x.startX+P,x.startY+S,x.startX-P,x.startY-S,d,m,g,p,C)&&L.push(C),C=new Point,Geo.Vn(x.endX+P,x.endY+S,x.endX-P,x.endY-S,d,m,g,p,C)&&L.push(C);const M=L.length;if(M===0)return Util.tt(L),!1;b=!0;let N=1/0;for(let T=0;T0&&k.contains(D,F)&&(M.x=D,M.y=F,this.containsPoint(M)))for(N!==0&&Math.abs(N)<.5?(T*=.5/N,N=.5):T!==0&&Math.abs(T)<.5&&(N*=.5/T,T=.5),D-=N,F-=T;k.contains(D,F);)D-=N,F-=T;const R=.6;n.x=g,n.y=p;for(let X=0;Xe?t-e:e-t)<(i>s?i-s:s-i)){const f=if||Geo.K(h.y,f))&&(h.yf||Geo.K(h.x,f))&&(h.x=a&&h<=c}else{let a=0,c=0;return s=a&&l<=c}}kv(t,i){if(this.containedInRect(t,i)||i===void 0&&(i=this.D,t.containsRect(this.actualBounds)))return!0;const e=t.left,s=t.right,n=t.top,o=t.bottom,r=Point.l(),l=Point.l(),h=Point.l(),a=Transform.l();a.set(i),a.hC(this.D),a.yw(),l.x=s,l.y=n,l.D(a),r.x=e,r.y=n,r.D(a);let c=!1;return this.Aa(r,l,h)?c=!0:(r.x=s,r.y=o,r.D(a),this.Aa(r,l,h)?c=!0:(l.x=e,l.y=o,l.D(a),this.Aa(r,l,h)?c=!0:(r.x=e,r.y=n,r.D(a),this.Aa(r,l,h)&&(c=!0)))),Transform.s(a),Point.s(r),Point.s(l),Point.s(h),c}_L(t,i,e){if(e&&this.fill!==null&&this.hh(t,!0))return!0;let s=t.distanceSquaredPoint(i);const n=s;this.strokeWidth>1.5&&(s=this.strokeWidth/2+Math.sqrt(s),s*=s);let o=this.ct;if(o===null&&(this.ut(1/0,1/0),o=this.ct,o===null))return!1;if(!e){const f=o.bounds,u=f.x,d=f.y,m=f.x+f.width,g=f.y+f.height;if(Point.distanceSquared(t.x,t.y,u,d)<=s&&Point.distanceSquared(t.x,t.y,m,d)<=s&&Point.distanceSquared(t.x,t.y,u,g)<=s&&Point.distanceSquared(t.x,t.y,m,g)<=s)return!0}function r(f,u){const d=f.length;for(let m=0;ms)return!0;return!1}const l=o.startX,h=o.startY,a=o.endX,c=o.endY;if(o.type===1){const f=Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,c),u=(a-l)*(t.x-l)+(c-h)*(t.y-h),d=(l-a)*(t.x-a)+(h-c)*(t.y-c),m=u>=0&&d>=0?s:n;return f<=m}else if(o.type===2){let f=!1;return e&&(f=Point.distanceLineSegmentSquared(t.x,t.y,l,h,l,c)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,h)<=s||Point.distanceLineSegmentSquared(t.x,t.y,a,h,a,c)<=s||Point.distanceLineSegmentSquared(t.x,t.y,l,c,a,c)<=s),f}else if(o.type===3){const f=(l+a)/2,u=(h+c)/2,d=t.x-f,m=t.y-u,g=Math.abs(a-l)/2,p=Math.abs(c-h)/2;if(g===0||p===0)return Point.distanceLineSegmentSquared(t.x,t.y,l,h,a,c)<=s;if(e){const y=Geo.vD(g,p,d,m);return y*y<=s}else return!(Point.distanceSquared(d,m,-g,0)>=s||Point.distanceSquared(d,m,0,-p)>=s||Point.distanceSquared(d,m,0,p)>=s||Point.distanceSquared(d,m,g,0)>=s)}else if(o.type===4){const f=o.bounds,u=f.x,d=f.y,m=f.x+f.width,g=f.y+f.height;if(t.x>m&&t.xg&&t.ys&&Point.distanceLineSegmentSquared(t.x,t.y,u,d,m,d)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,u,g)>s&&Point.distanceLineSegmentSquared(t.x,t.y,m,g,m,d)>s)return!1;const p=Math.sqrt(s);if(e){if(this.fill===null?o.xC(t.x,t.y,p):o.Vk(t,p,!0,!1))return!0}else{const y=o.figures;for(let x=0;xs)return!1;const S=k.segments.r,L=S.length;for(let C=0;Cs)return!1;break;case 3:{const N=Util.nt();Geo.Un(b,P,M.point1X,M.point1Y,M.point2X,M.point2Y,M.endX,M.endY,.8,N);const T=r(N,t);if(Util.tt(N),T||(b=M.endX,P=M.endY,t.distanceSquared(b,P)>s))return!1;break}case 4:{const N=Util.nt();Geo.Bg(b,P,M.point1X,M.point1Y,M.endX,M.endY,.8,N);const T=r(N,t);if(Util.tt(N),T||(b=M.endX,P=M.endY,t.distanceSquared(b,P)>s))return!1;break}case 5:case 6:{const N=M.type===5?M.Mo(k):M.Eh(k,b,P),T=N.length;if(T===0){if(b=M.type===5?M.centerX:M.endX,P=M.type===5?M.centerY:M.endY,t.distanceSquared(b,P)>s)return!1;break}let A=null;const D=Util.nt();for(let F=0;F=0){this.jo=t,this.c();const e=this.part;e!==null&&e.cf(),this.t("strokeWidth",i,t)}else Util._(t,"value >= 0",Shape,"strokeWidth:value")}w0(){return this.jo}get strokeCap(){return this.Lt!==null?this.Lt.pp:"butt"}set strokeCap(t){const i=this.strokeCap;i!==t&&(typeof t=="string"&&(t==="butt"||t==="round"||t==="square")?(this.La(),this.Lt.pp=t,this.C(),this.t("strokeCap",i,t)):Util._(t,'"butt", "round", or "square"',Shape,"strokeCap"))}get strokeJoin(){return this.Lt!==null?this.Lt.yp:"miter"}set strokeJoin(t){const i=this.strokeJoin;i!==t&&(typeof t=="string"&&(t==="miter"||t==="bevel"||t==="round")?(this.La(),this.Lt.yp=t,this.C(),this.t("strokeJoin",i,t)):Util._(t,'"miter", "bevel", or "round"',Shape,"strokeJoin"))}get strokeMiterLimit(){return this.Lt!==null?this.Lt.wp:10}set strokeMiterLimit(t){const i=this.strokeMiterLimit;if(i!==t&&t>=1){this.La(),this.Lt.wp=t,this.C();const e=this.part;e!==null&&e.cf(),this.t("strokeMiterLimit",i,t)}}get strokeDashArray(){return this.Xo}set strokeDashArray(t){const i=this.Xo;if(i!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",Shape,"strokeDashArray:value"),t!==null){const e=t.length;let s=0;for(let n=0;n=0)||!isFinite(o))&&Util.o("strokeDashArray:value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(i===null)return;t=null}}this.Xo=t,this.C(),this.t("strokeDashArray",i,t)}}get strokeDashOffset(){return this.Lt!==null?this.Lt.dh:0}set strokeDashOffset(t){const i=this.strokeDashOffset;i!==t&&t>=0&&(this.La(),this.Lt.dh=t,this.C(),this.t("strokeDashOffset",i,t))}get figure(){return this.xd}set figure(t){const i=this.xd;if(i!==t){let e=Geo.So[t];if(typeof e=="function"?e=t:(e=Geo.So[t.toLowerCase()],e||Util.o("Unknown Shape.figure: "+t)),i!==e){const s=this.part;s!==null&&s.cf(),this.xd=e,this.xs=null,this.ee(),this.c(),this.t("figure",i,e)}}}get toArrow(){return this.Bt!==null?this.Bt.xp:"None"}set toArrow(t){const i=this.toArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){const e=Shape.AA(t);e===null?Util.o("Unknown Shape.toArrow: "+t):i!==e&&(this.Bt===null&&(this.Bt=new LinkElementSettings),this.Bt.xp=e,this.xs=null,this.ee(),this.c(),this.TA(e),this.t("toArrow",i,e))}}get fromArrow(){return this.Bt!==null?this.Bt.bp:"None"}set fromArrow(t){const i=this.fromArrow;if(t===!0?t="Standard":t===!1&&(t=""),i!==t){const e=Shape.AA(t);e===null?Util.o("Unknown Shape.fromArrow: "+t):i!==e&&(this.Bt===null&&(this.Bt=new LinkElementSettings),this.Bt.bp=e,this.xs=null,this.ee(),this.c(),this.TA(e),this.t("fromArrow",i,e))}}TA(t){const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;this.vR();const e=Spot.MiddleRight;this.toArrow!=="None"?(this.segmentIndex=-1,this.alignmentFocus=e):this.fromArrow!=="None"&&(this.segmentIndex=0,this.alignmentFocus=new Spot(1-e.x,e.y))}get spot1(){return this.Lt!==null?this.Lt.zn:Spot.Default}set spot1(t){const i=this.spot1;i.equals(t)||(t=t.N(),this.La(),this.Lt.zn=t,this.c(),this.t("spot1",i,t))}get spot2(){return this.Lt!==null?this.Lt.Xn:Spot.Default}set spot2(t){const i=this.spot2;i.equals(t)||(t=t.N(),this.La(),this.Lt.Xn=t,this.c(),this.t("spot2",i,t))}get parameter1(){return this.bd}set parameter1(t){const i=this.bd;i!==t&&(this.bd=t,this.ee(),this.c(),this.t("parameter1",i,t))}get parameter2(){return this.kd}set parameter2(t){const i=this.kd;i!==t&&(this.kd=t,this.ee(),this.c(),this.t("parameter2",i,t))}get naturalBounds(){return this.Vi}_R(){const t=this.desiredSize;if(!t.isReal()&&this.ct!==null){const i=this.ct.bounds;this.Vi.a(i)}else this.Vi.e(0,0,t.width,t.height)}get pathPattern(){return this.Lt!==null?this.Lt.kp:null}set pathPattern(t){const i=this.pathPattern;i!==t&&(this.La(),this.Lt.kp=t,this.C(),this.t("pathPattern",i,t))}get geometryStretch(){return this.Lt!==null?this.Lt.Pp:1}set geometryStretch(t){const i=this.geometryStretch;i!==t&&(this.La(),this.Lt.Pp=t,this.c(),this.t("geometryStretch",i,t))}get interval(){return this.J!==null?this.J.uf:1}set interval(t){const i=this.interval;if(t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this.J===null&&(this.J=new GradElementSettings),this.J.uf=t;const e=this.diagram;e!==null&&this.panel===e.grid&&e.jr(),this.c();const s=this.panel;s!==null&&(s.ns=null),this.t("interval",i,t)}}get graduatedStart(){return this.J!==null?this.J.df:0}set graduatedStart(t){const i=this.graduatedStart;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.df=t,this.c(),this.t("graduatedStart",i,t))}get graduatedEnd(){return this.J!==null?this.J.gf:1}set graduatedEnd(t){const i=this.graduatedEnd;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.gf=t,this.c(),this.t("graduatedEnd",i,t))}get graduatedSkip(){return this.J!==null?this.J.mf:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.i(t,"function",Shape,"graduatedSkip"),this.J===null&&(this.J=new GradElementSettings),this.J.mf=t,this.c(),this.t("graduatedSkip",i,t))}static wv(t,i,e){let n=null;if(t.toArrow!=="None")n=Shape.no[t.toArrow];else if(t.fromArrow!=="None")n=Shape.no[t.fromArrow];else{let o=Geo.So[t.figure];typeof o=="string"&&(o=Geo.So[o]),o===void 0&&Util.o("Unknown Shape.figure: "+t.figure),n=o(t,i,e),n.sc=i,n.nc=e}if(n===null){const o=Geo.So.Rectangle;typeof o=="function"&&(n=o(t,i,e))}return n}static getFigureGenerators(){const t=new GMap;for(const i in Geo.So){if(i===i.toLowerCase())continue;const e=Geo.So[i];t.set(i,e)}return t.g(),t}static defineFigureGenerator(t,i){Util.i(t,"string",Shape,"defineFigureGenerator:name"),typeof i=="string"||Util.i(i,"function",Shape,"defineFigureGenerator:func");const e=t.toLowerCase(),s=Geo.So;s[t]=i,s[e]=t}static getArrowheadGeometries(){const t=new GMap;for(const i in Geo.Xg)if(Shape.no[i]===void 0){const e=Geometry.parse(Geo.Xg[i],!1);Shape.no[i]=e;const s=i.toLowerCase();s!==i&&(Shape.no[s]=i)}for(const i in Shape.no){if(i===i.toLowerCase())continue;const e=Shape.no[i];e instanceof Geometry&&t.set(i,e)}return t.g(),t}static defineArrowheadGeometry(t,i){Util.i(t,"string",Shape,"defineArrowheadGeometry:name");let e=null;typeof i=="string"?(Util.i(i,"string",Shape,"defineArrowheadGeometry:pathstr"),e=Geometry.parse(i,!1)):e=i;const s=t.toLowerCase();(s==="none"||t===s)&&Util.o("Shape.defineArrowheadGeometry name must not be empty or None or all-lower-case: "+t);const n=Shape.no;n[t]=e,n[s]=t}static no=new PropertyCollection;static I2=new PropertyCollection;static AA(t){let i=Shape.no[t];if(i===void 0){const e=t.toLowerCase();if(e==="none")return"None";if(i=Shape.no[e],i===void 0){let s=null;for(const n in Geo.Xg)if(n.toLowerCase()===e){s=n;break}if(s!==null){const n=Geometry.parse(Geo.Xg[s],!1);return Shape.no[s]=n,e!==s&&(Shape.no[e]=s),s}}}return typeof i=="string"?i:i instanceof Geometry?t:null}}class ShapeTemplateSettings{gi;pp;yp;wp;dh;kp;Pp;zn;Xn;constructor(){this.gi=!1,this.pp="butt",this.yp="miter",this.wp=10,this.dh=0,this.kp=null,this.Pp=1,this.zn=Spot.Default,this.Xn=Spot.Default}copy(){const t=new ShapeTemplateSettings;return t.pp=this.pp,t.yp=this.yp,t.wp=this.wp,t.dh=this.dh,t.kp=this.kp,t.Pp=this.Pp,t.zn=this.zn.N(),t.Xn=this.Xn.N(),t}}var Wrap=(w=>(w[w.None=0]="None",w[w.Fit=1]="Fit",w[w.DesiredSize=2]="DesiredSize",w[w.BreakAll=3]="BreakAll",w))(Wrap||{}),TextOverflow=(w=>(w[w.Clip=0]="Clip",w[w.Ellipsis=1]="Ellipsis",w))(TextOverflow||{}),TextFormat=(w=>(w[w.Trim=0]="Trim",w[w.None=1]="None",w))(TextFormat||{});class TextBlock extends GraphObject{hi;Hi;kn;Ce;mi;x0;Sd;J;W;Dl;oo;Pn;Le;Di;Sn;constructor(t,i){return super(),this.n|=2097152,this.hi="",this.Hi="black",this.kn="13px sans-serif",this.Ce=0,this.mi=0,this.x0=0,this.Sd=null,this.J=null,this.W=null,this.Dl=0,this.oo=null,this.Pn=0,this.Le=null,this.Di=null,this.Sn=null,typeof t=="string"?this.text=t:t&&Object.assign(this,t),i&&Object.assign(this,i),this}cloneProtected(t){super.cloneProtected(t),t.hi=this.hi,t.Hi=this.Hi,t.kn=this.kn,t.Ce=this.Ce,t.mi=this.mi,t.x0=this.x0,t.Sd=this.Sd,this.J!==null&&(t.J=this.J.copy()),this.W!==null&&(this.W.gi?t.W=this.W:t.W=this.W.copy()),t.Dl=this.Dl,t.oo=this.oo,t.Pn=this.Pn,t.Le=this.Le,t.Di=this.Di,t.Sn=this.Sn}Mn(){this.W===null?this.W=new TextBlockTemplateSettings:this.W.gi&&(this.W=this.W.copy())}lh(){super.lh(),this.W!==null&&(this.W.gi=!0)}rv(t){this.n=t.n|2048|4096,this.Wt=t.opacity,this.Ct=t.background,this.ze=t.desiredSize.N(),this.minSize=t.minSize.N(),this.maxSize=t.maxSize.N(),t.bi!==null?this.bi=t.bi.copy():this.bi=null,this.et=t.scale,this.Xt=t.angle,this.stretch=t.stretch,this.Zr=t.margin.N(),this.oi=t.alignment.N(),this.Wc=t.alignmentFocus.N(),this.segmentFraction=t.segmentFraction,this.segmentOffset=t.segmentOffset.N(),this.segmentOrientation=t.segmentOrientation,t.ni!==null&&(this.ni=t.ni.copy()),this.shadowVisible=t.shadowVisible,this.hi=t.hi,this.Hi=t.Hi,this.kn=t.kn,this.J!==null&&(this.J=t.J.copy()),t.W!==null&&(t.W.gi?this.W=t.W:this.W=t.W.copy()),this.Dl=t.Dl}nv(t){if(this.hi=t.text||"",this.Xt=t.labelAngle||0,this.Ce=t.lineCount||0,this.Pv(t.lines),t.naturalBounds&&(this.Vi=t.naturalBounds),t.actualBounds){const i=t.actualBounds;this.zt(i.x,i.y,i.width,i.height)}}ri(t){t in Wrap?this.wrap=t:super.ri(t)}toString(){return this.hi.length>22?'TextBlock("'+this.hi.substring(0,20)+'"...)':'TextBlock("'+this.hi+'")'}static getEllipsis(){return TextBlock.Sp}static setEllipsis(t){TextBlock.Sp=t,TextBlock.Zb=new PropertyCollection,TextBlock.E2=0}static getBaseline(){return TextBlock.Qb}static setBaseline(t){TextBlock.Qb=t}static Qb=null;static getUnderline(){return TextBlock._b}static setUnderline(t){TextBlock._b=t}static _b=null;static None=0;static WrapFit=1;static WrapDesiredSize=2;static WrapBreakAll=3;static OverflowClip=0;static OverflowEllipsis=1;static FormatTrim=0;static FormatNone=1;c(){super.c()}get font(){return this.kn}set font(t){const i=this.kn;i!==t&&(this.kn=t,this.oo=null,this.c(),this.t("font",i,t))}static isValidFont(t){return root.CSS?root.CSS.supports("font",t):!0}get text(){return this.hi}set text(t){const i=this.hi;t!=null?t=t.toString():t="",i!==t&&(this.hi=t,this.c(),this.t("text",i,t),this.ss(!0))}get textAlign(){return this.W!==null?this.W.Mp:"start"}set textAlign(t){const i=this.textAlign;i!==t&&(t==="start"||t==="end"||t==="left"||t==="right"||t==="center")&&(this.Mn(),this.W.Mp=t,this.C(),this.t("textAlign",i,t))}get flip(){return this.W!==null?this.W.ro:0}set flip(t){const i=this.flip;i!==t&&(this.Mn(),this.W.ro=t,this.C(),this.t("flip",i,t))}get verticalAlignment(){return this.W!==null?this.W.sl:Spot.Top}set verticalAlignment(t){const i=this.verticalAlignment;i.equals(t)||(t=t.N(),this.Mn(),this.W.sl=t,this.ef(),this.t("verticalAlignment",i,t))}get naturalBounds(){if(!this.Vi.isReal()){const t=Size.l();this.B2(this.hi,999999,t);let i=t.width;Size.s(t);let e=this.DA(i);const s=this.desiredSize;isNaN(s.width)||(i=s.width),isNaN(s.height)||(e=s.height),this.Vi.En(i,e)}return this.Vi}get isMultiline(){return(this.n&2097152)!==0}set isMultiline(t){const i=(this.n&2097152)!==0;i!==t&&(this.n=this.n^2097152,this.c(),this.t("isMultiline",i,t))}get isUnderline(){return(this.n&4194304)!==0}set isUnderline(t){const i=(this.n&4194304)!==0;i!==t&&(this.n=this.n^4194304,this.ss(!0),this.C(),this.t("isUnderline",i,t))}get isStrikethrough(){return(this.n&8388608)!==0}set isStrikethrough(t){const i=(this.n&8388608)!==0;i!==t&&(this.n=this.n^8388608,this.ss(!0),this.C(),this.t("isStrikethrough",i,t))}get wrap(){return this.W!==null?this.W.Np:2}set wrap(t){const i=this.wrap;i!==t&&(this.Mn(),this.W.Np=t,this.c(),this.t("wrap",i,t))}get overflow(){return this.W!==null?this.W.Cp:0}set overflow(t){const i=this.overflow;i!==t&&(this.Mn(),this.W.Cp=t,this.c(),this.t("overflow",i,t))}get isOverflowed(){return(this.n&16777216)!==0}U2(t){t?this.n|=16777216:this.n&=-16777217}get stroke(){return this.Hi}set stroke(t){const i=this.Hi;i!==t&&(t!==null&&Brush.nd(t,"TextBlock.stroke"),t instanceof Brush&&t.g(),this.Hi=t,this.C(),this.t("stroke",i,t))}get lineCount(){return this.Ce}get lineHeight(){return this.Lp()}get editable(){return(this.n&1048576)!==0}set editable(t){const i=(this.n&1048576)!==0;i!==t&&(this.n=this.n^1048576,this.t("editable",i,t))}get L2(){return(this.n&33554432)!==0}set L2(t){this.n=this.n^33554432}get textEditor(){return this.W!==null?this.W.Ap:null}set textEditor(t){const i=this.textEditor;i!==t&&(this.Mn(),this.W.Ap=t,this.t("textEditor",i,t))}get errorFunction(){return this.W!==null?this.W.os:null}set errorFunction(t){const i=this.errorFunction;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"errorFunction"),this.Mn(),this.W.os=t,this.t("errorFunction",i,t))}get interval(){return this.J!==null?this.J.uf:1}set interval(t){const i=this.interval;if(t=Math.round(t),i!==t&&t!==0&&isFinite(t)){this.J===null&&(this.J=new GradElementSettings),this.J.uf=t,this.c();const e=this.panel;e!==null&&(e.ns=null),this.t("interval",i,t)}}get graduatedStart(){return this.J!==null?this.J.df:0}set graduatedStart(t){const i=this.graduatedStart;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.df=t,this.c(),this.t("graduatedStart",i,t))}get graduatedEnd(){return this.J!==null?this.J.gf:1}set graduatedEnd(t){const i=this.graduatedEnd;i!==t&&(t<0?t=0:t>1&&(t=1),this.J===null&&(this.J=new GradElementSettings),this.J.gf=t,this.c(),this.t("graduatedEnd",i,t))}get graduatedFunction(){return this.J!==null?this.J.Tp:null}set graduatedFunction(t){const i=this.graduatedFunction;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"graduatedFunction"),this.J===null&&(this.J=new GradElementSettings),this.J.Tp=t,this.c(),this.t("graduatedFunction",i,t))}get graduatedSkip(){return this.J!==null?this.J.mf:null}set graduatedSkip(t){const i=this.graduatedSkip;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"graduatedSkip"),this.J===null&&(this.J=new GradElementSettings),this.J.mf=t,this.c(),this.t("graduatedSkip",i,t))}fh(t,i){if(this.Hi===null||this.hi.length===0||this.kn===null)return;const e=this.naturalBounds,s=this.actualBounds,n=e.width,o=e.height,r=this.Lp();let l=t.textAlign=this.textAlign;const h=i.Xu;l==="start"?l=h?"right":"left":l==="end"&&(l=h?"left":"right");const a=this.isUnderline,c=this.isStrikethrough;this.dn(t,this.Hi,!0,!1,e,s),(a||c)&&this.dn(t,this.Hi,!1,!1,e,s);const f=0;let u=0;const d=n;let m=!1;i.Zt===t&&!(i.Zt instanceof SVGContext)&&!this.L2&&i.getRenderingHint("textGreeking")===!0&&r*this.ca*i.scale<3&&(m=!0);const g=this.spacingAbove,p=this.spacingBelow;switch(this.flip){case 0:break;case 2:t.translate(n,0),t.scale(-1,1);break;case 1:t.translate(0,o),t.scale(1,-1);break;case 3:t.translate(n,o),t.scale(-1,-1);break}t.commitTransform();const y=this.Ce,k=(g+r+p)*y;if(o>k){const b=this.verticalAlignment;u=b.y*o-b.y*k+b.offsetY}if(y===1&&this.Sn!==null){let b=this.mi;b>d&&(b=d),u+=g,this.FA(this.Sn,t,f,u,d,r,b,m,l,a,c)}else if(this.Le!==null&&this.Di!==null)for(let b=0;bd&&(P=d),u+=g,this.FA(this.Di[b],t,f,u,d,r,P,m,l,a,c),u+=r+p}switch(this.flip){case 0:break;case 2:t.scale(-1,1),t.translate(-n,0);break;case 1:t.scale(1,-1),t.translate(0,-o);break;case 3:t.scale(-1,-1),t.translate(-n,-o);break}}FA(t,i,e,s,n,o,r,l,h,a,c){let f=0;if(l){h==="left"?f=0:h==="right"?f=n-r:h==="center"&&(f=(n-r)/2);const m=i.globalAlpha;i.globalAlpha=m/2,i.fillRect(e+f,s+o/4,r,o/2),i.globalAlpha=m;return}h==="left"?f=0:h==="right"?f=n:h==="center"&&(f=n/2);const u=TextBlock.Qb!==null?TextBlock.Qb(this,o):o*.75;i.fillText(t,e+f,s+u);let d=o/20|0;if(d===0&&(d=1),h==="right"?f-=r:h==="center"&&(f-=r/2),a){const m=TextBlock._b!==null?TextBlock._b(this,o):o*.8;this.RA(e+f,s+m,e+f+r,s+m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}if(c){let m=s+o-o/2.2|0;d%2!==0&&(m+=.5),this.RA(e+f,m,e+f+r,m,d,i),i instanceof SVGContext&&i.lastCreatedElement.classList.add("gojs-td")}}RA(t,i,e,s,n,o){o.beginPath(),o.lineWidth=n,o.moveTo(t,i),o.lineTo(e,s),o.stroke(),o.endPath()}Qc(t,i,e){if(!super.Qc(t,i,e))return!1;if(this.dn(t,this.Hi,!0,!1,this.naturalBounds,this.actualBounds),e){if(this.svg.getElementsByTagName("text").length===0)return!0;const n=this.svg.getElementsByClassName("gojs-td");for(let o=0;o1||this.isUnderline||this.isStrikethrough?!0:super.ed(t)}l2(t,i){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",i);else{const e=t.getElementsByTagName("text");for(let s=0;sthis.maxLines&&(this.n|=16777216))}B2(t,i,e){const s=this.formatting===0;s&&(t=t.trim());let n=0,o=0,r=0;const l=this.kn,h=this.spacingAbove+this.spacingBelow,a=Math.max(0,this.Lp()+h),c=this.overflow===1?this.OA(l):0;if(this.Ce>=this.maxLines){e!==null&&e.e(0,a);return}let f=t;if(this.wrap===0){if(this.Pn=1,o=this.getStringWidth(t),c===0||o<=i){this.mi=Math.max(this.mi,o),this.Nn(t,this.mi),e!==null&&e.e(o,a);return}let d=this.Md(f);f=f.substring(d.length);let m=this.Md(f);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,f=f.substring(m.length),m=this.Md(f),r=o;let g=d+m;s&&(g=g.trim()),o=this.getStringWidth(g)}for(s&&(m=m.trim()),d+=m,i=Math.max(1,i-c);this.getStringWidth(d)>i&&d.length>1;)d=d.substring(0,d.length-1);this.U2(!0),d+=TextBlock.Sp,r=this.getStringWidth(d),this.mi=r,this.Nn(d,r),e!==null&&e.e(r,a);return}let u=0;for(f.length===0&&(u=1,this.Nn(f,0));f.length>0;){let d=this.Md(f);for(f=f.substring(d.length);this.getStringWidth(d)>i;){let p=1;for(o=this.getStringWidth(d.substring(0,p)),r=0;o<=i;)p++,r=o,o=this.getStringWidth(d.substring(0,p));let y=0;p===1?(y=o,n=Math.max(n,o)):(y=r,n=Math.max(n,r)),p--,p<1&&(p=1);const x=d.substring(0,p);if(this.Nn(x,y),u++,d=d.substring(p),this.Ce+u>this.maxLines)break}let m=this.Md(f);for(o=this.getStringWidth(d+m),r=0;m.length>0&&o<=i;){d+=m,f=f.substring(m.length),m=this.Md(f),r=o;let p=d+m;s&&(p=p.trim()),o=this.getStringWidth(p)}if(s&&(d=d.trim()),d==="")continue;d[d.length-1]==="\xAD"&&(d=d.substring(0,d.length-1)+"\u2010");let g=0;if(m.length===0?(g=o,n=Math.max(n,o)):(r=this.getStringWidth(d),g=r,n=Math.max(n,r)),this.Nn(d,g),u++,this.Ce+u>this.maxLines)break}this.Pn=Math.min(this.maxLines,u),this.mi=Math.max(this.mi,n),e!==null&&e.e(this.mi,a*this.Pn)}Cv(t,i){if(this.mi===0||this.Le===null||this.Di===null||this.overflow!==1)return;const e=this.kn,s=this.overflow===1?this.OA(e):0,n=this.spacingAbove+this.spacingBelow,o=Math.max(0,this.Lp()+n),r=Math.min(this.maxLines-1,Math.max(Math.floor(i/o+.01)-1,0));if(r+1>=this.Di.length)return;this.U2(!0);let l=this.Di[r];const h=Math.max(1,t-s);for(;this.getStringWidth(l)>h&&l.length>1;)l=l.substring(0,l.length-1);l+=TextBlock.Sp;const a=this.getStringWidth(l);this.Di[r]=l,this.Di=this.Di.slice(0,r+1),this.Le[r]=a,this.Le=this.Le.slice(0,r+1),this.Pn=this.Di.length,this.mi=Math.max(this.mi,a),this.Ce=this.Pn,this.Ce===1&&(this.Sn=this.Di[0])}Md(t){if(this.wrap===3)return t.substring(0,1);let i=t.length,e=0;const s=TextBlock.Lv;for(;e=t.length?t:t.substring(0,e)}getStringWidth(t){return TextBlock.il===null?t.length*8:TextBlock.il.measureText(t).width}Lp(){if(this.oo!==null)return this.oo;const t=this.kn;let i=0;return TextBlock.il===null?(i=16,this.oo=i,i):(TextBlock.V2[t]!==void 0&&TextBlock.IA<5e3?i=TextBlock.V2[t]:(i=TextBlock.il.measureText("M").width*1.3,TextBlock.V2[t]=i,TextBlock.IA++),this.oo=i,i)}OA(t){if(TextBlock.il===null)return 6;let i=0;return TextBlock.Zb[t]!==void 0&&TextBlock.E2<5e3?i=TextBlock.Zb[t]:(i=TextBlock.il.measureText(TextBlock.Sp).width,TextBlock.Zb[t]=i,TextBlock.E2++),i}t1(t,i){return t.indexOf(` `,i)}DA(t){let i=this.hi.replace(/\r\n/g,` `).replace(/\r/g,` -`);const e=this.spacingAbove+this.spacingBelow,s=Math.max(0,this.Lp()+e);if(i.length===0)return this.mi=0,this.Ce=1,s;if(!this.isMultiline){const h=this.t1(i,0);h>=0&&(i=i.substring(0,h))}let n=0;this.Ce=0;let o=0,r=-1,l=!1;for(;!l;){if(r=this.t1(i,o),r===-1&&(r=i.length,l=!0),o<=r){const h=i.substring(o,r);if(this.wrap!==0){this.Pn=0;const a=Size.l();this.V2(h,t,a),n+=a.height,Size.s(a),this.Ce+=this.Pn}else this.V2(h,t,null),n+=s,this.Ce++;this.Ce===this.maxLines&&(l=!0)}o=r+1}return this.x0=n,n}Cv(){let t=this.hi.replace(/\r\n/g,` +`);const e=this.spacingAbove+this.spacingBelow,s=Math.max(0,this.Lp()+e);if(i.length===0)return this.mi=0,this.Ce=1,s;if(!this.isMultiline){const h=this.t1(i,0);h>=0&&(i=i.substring(0,h))}let n=0;this.Ce=0;let o=0,r=-1,l=!1;for(;!l;){if(r=this.t1(i,o),r===-1&&(r=i.length,l=!0),o<=r){const h=i.substring(o,r);if(this.wrap!==0){this.Pn=0;const a=Size.l();this.B2(h,t,a),n+=a.height,Size.s(a),this.Ce+=this.Pn}else this.B2(h,t,null),n+=s,this.Ce++;this.Ce===this.maxLines&&(l=!0)}o=r+1}return this.x0=n,n}Nv(){let t=this.hi.replace(/\r\n/g,` `).replace(/\r/g,` -`);if(t.length===0)return 8;if(this.isMultiline){let i=0,e=0,s=!1;for(;!s;){let n=this.t1(t,e);n===-1&&(n=t.length,s=!0);let o=t.substring(e,n);this.formatting===0&&(o=o.trim()),i=Math.max(i,this.getStringWidth(o)),e=n+1}return i}else{const i=this.t1(t,0);return i>=0&&(t=t.substring(0,i)),this.getStringWidth(t)}}get textValidation(){return this.W!==null?this.W.Tl:null}set textValidation(t){const i=this.textValidation;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"textValidation"),this.Sn(),this.W.Tl=t,this.t("textValidation",i,t))}get textEdited(){return this.W!==null?this.W.Dp:null}set textEdited(t){const i=this.textEdited;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"textEdited"),this.Sn(),this.W.Dp=t,this.t("textEdited",i,t))}get spacingAbove(){return this.W!==null?this.W.Fp:0}set spacingAbove(t){const i=this.spacingAbove;i!==t&&(this.Sn(),this.W.Fp=t,this.c(),this.t("spacingAbove",i,t))}get spacingBelow(){return this.W!==null?this.W.Rp:0}set spacingBelow(t){const i=this.spacingBelow;i!==t&&(this.Sn(),this.W.Rp=t,this.c(),this.t("spacingBelow",i,t))}get formatting(){return this.W!==null?this.W.vp:0}set formatting(t){const i=this.formatting;i!==t&&(this.Sn(),this.W.vp=t,this.c(),this.t("formatting",i,t))}get maxLines(){return this.W!==null?this.W.Op:1/0}set maxLines(t){const i=this.maxLines;i!==t&&(t=Math.floor(t),t<=0&&Util._(t,"> 0",TextBlock,"maxLines"),this.Sn(),this.W.Op=t,this.c(),this.t("maxLines",i,t))}getMetrics(){return[this.mi,this.Dl,this.oo,this.Pn,this.Le,this.Di,this.Mn]}Mv(t){t!==void 0&&(this.mi=t[0],this.Dl=t[1],this.oo=t[2],this.Pn=t[3],this.Le=t[4],this.Di=t[5],this.Mn=t[6])}get metrics(){return{arrSize:this.Le!==null?this.Le:[this.mi],arrText:this.Di!==null?this.Di:[this.Mn],maxLineWidth:this.mi,fontHeight:this.oo}}get choices(){return this.Sd}set choices(t){const i=this.Sd;i!==t&&(this.Sd=t,this.t("choices",i,t))}static Av=new RegExp("[ \u200B\xAD]");static X2=new PropertyCollection;static IA=0;static Zb=new PropertyCollection;static B2=0;static Mp="...";static vA="";static il=Diagram.isUsingDOM()?new CanvasSurface(null).ai:null}class TextBlockTemplateSettings{gi;os;ro;vp;Op;Cp;Fp;Rp;Sp;Dp;Ap;Tl;sl;Np;constructor(){this.gi=!1,this.os=null,this.ro=0,this.vp=0,this.Op=1/0,this.Cp=0,this.Fp=0,this.Rp=0,this.Sp="start",this.Dp=null,this.Ap=null,this.Tl=null,this.sl=Spot.Top,this.Np=2}copy(){const t=new TextBlockTemplateSettings;return t.os=this.os,t.ro=this.ro,t.vp=this.vp,t.Op=this.Op,t.Cp=this.Cp,t.Fp=this.Fp,t.Rp=this.Rp,t.Sp=this.Sp,t.Dp=this.Dp,t.Ap=this.Ap,t.Tl=this.Tl,t.sl=this.sl,t.Np=this.Np,t}}class GradElementSettings{ff;uf;df;Tp;gf;constructor(){this.ff=1,this.uf=0,this.df=1,this.Tp=null,this.gf=null}copy(){const t=new GradElementSettings;return t.ff=this.ff,t.uf=this.uf,t.df=this.df,t.Tp=this.Tp,t.gf=this.gf,t}}var ImageStretch=(w=>(w[w.None=0]="None",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ImageStretch||{});class Picture extends GraphObject{nl;yt;ol;mf;os;rl;pf;ro;yf;wf;Ib;constructor(t,i){super(),this.n|=2097152,this.nl=null,this.yt="",this.ol=Rect.TD,this.mf=2,this.os=null,this.rl=null,this.pf=Spot.Center,this.ro=0,this.yf=null,this.wf=null,this.Ib=null,typeof t=="string"?this.source=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.yt=this.yt,t.element=this.nl,t.ol=this.ol.N(),t.mf=this.mf,t.ro=this.ro,t.os=this.os,t.rl=this.rl,t.pf=this.pf.N(),t.wf=this.wf}ri(t){t in ImageStretch?this.imageStretch=t:super.ri(t)}toString(){return"Picture("+this.source+")#"+GSet.as(this)}get xf(){return(this.n&1048576)!==0}set xf(t){this.xf!==t&&(this.n=this.n^1048576)}get Ip(){return(this.n&2097152)!==0}set Ip(t){this.Ip!==t&&(this.n=this.n^2097152)}get mn(){return(this.n&4194304)!==0}set mn(t){this.mn!==t&&(this.n=this.n^4194304)}static clearCache(t){t===void 0&&(t=""),Util.i(t,"string",Picture,"clearCache:url"),t!==""?Picture.Ep[t]&&(delete Picture.Ep[t],Picture.i1--):(Picture.Ep=new PropertyCollection,Picture.i1=0)}static IL(t,i){i.EA||(i.e1=e=>{Picture.Tv(i,e),t.desiredSize.isReal()||(t.fe(!1),t.c())},i.s1=e=>Picture.Dv(i,e),i.addEventListener("load",i.e1),i.addEventListener("error",i.s1),i.EA=!0)}static yR(t){t.e1&&t.removeEventListener("load",t.e1),t.s1&&t.removeEventListener("error",t.s1),delete t.e1,delete t.s1,delete t.EA}get element(){return this.nl}set element(t){const i=this.nl;if(this.ss(!0),i!==t){this.xf=t instanceof HTMLCanvasElement;const e=t instanceof HTMLImageElement;t!==null&&!(e||t instanceof HTMLVideoElement||this.xf)&&Util.o("Picture.element must be an instance of Image, Canvas, or Video, not: "+t);const s=this.diagram;s!==null&&s.DS(this),this.nl=t,t!==null&&e&&t.es===void 0&&(t.es=new GSet),s!==null&&e&&s.TS(this),this.t("element",i,t),this.C()}}mR(){const t=this.nl;if(t===null)return;const i=this.desiredSize.isReal();(this.xf||t.complete===!0)&&(t.f0&&(t.Up instanceof Event&&this.os!==null?this.os(this,t.Up):t.mn===!0&&!t.Up&&this.rl!==null&&t.K2&&this.rl(this,t.K2)),t.mn=!0),t.mn&&i&&this.diagram!==null&&this.diagram.Xu.add(this)}Fv(){if(this.nl===null){this.yf=!1;return}const t=new CanvasSurface(null).ai;try{t.drawImage(this.nl,0,0)}catch{this.Ip=!1}try{t.getImageData(0,0,1,1).data[3]&&(this.yf=!1),this.yf=!1}catch{this.yf=!0}}get source(){return this.yt}set source(t){const i=this.yt;if(i!==t){this.ss(!0),Util.i(t,"string",Picture,"source"),this.yt=t;let e=Picture.Ep;if(!Diagram.isUsingDOM()){this.t("source",i,t);return}let s=null;if(e[t]!==void 0)s=e[t];else if(t!==""){Picture.i1>30&&(Picture.clearCache(),e=Picture.Ep),s=Util.en("img"),s.f0=!0,Picture.IL(this,s);const n=this.wf;n!==null&&(s.crossOrigin=n(this)),s.src=t,e[t]=s,Picture.i1++}this.element=s,s!==null&&s.__goCache===void 0&&(s.__goCache=new PictureCacheArray),this.c(),this.C(),this.t("source",i,t)}}static Tv(t,i){t.mn=!0,t.Up=!1;let e;const s=t.es.copy();if(s==null)return;const n=s.iterator;for(;n.next();){const o=n.value;o.C();const r=t.getAttribute("src")||"",l=o.Jl.get(r);if(l===null)continue;const h=l.length;for(let a=0;a=o.width&&(r=r+p.offsetX+(d*p.x-o.width*p.x)),m>=o.height&&(l=l+p.offsetY+(m*p.y-o.height*p.y)),a=Math.min(o.width,d),c=Math.min(o.height,m);break;case 2:d=o.width,m=o.height;break;case 6:case 7:let A=0;g===6?(A=Math.min(o.height/m,o.width/d),d*=A,m*=A):g===7&&(A=Math.max(o.height/m,o.width/d),d*=A,m*=A,d>=o.width&&(r=(r+p.offsetX+(d*p.x-o.width*p.x)/d)*a),m>=o.height&&(l=(l+p.offsetY+(m*p.y-o.height*p.y)/m)*c),a*=1/(d/o.width),c*=1/(m/o.height),d=o.width,m=o.height);break}const y=a*c,x=this.getDocumentScale()*i.scale,k=d*x,b=m*x,P=k*b,M=y/P,L=e.__goCache;let C=null;const S=Picture.Rv;if(!n){if(e.mn&&L!==void 0&&P>4&&M>S*S){L.Ot===null&&(L.UA(4,f,u,e),L.UA(16,f,u,e));const A=L.Ot,D=A.length;for(let F=0;F0){const c=this.Ot[this.Ot.length-1];h=c.yt,a=c.Cd}o.setTransform(r*a,0,0,r*a,0,0),o.commitTransform(),o.drawImage(h,0,0),this.Ot.push(l)}}class PictureCacheInstance{yt;Cd;constructor(t,i){this.yt=t,this.Cd=i}}class GeoStream{Pi;qg;constructor(){this.qg=new Geometry,this.Pi=null}Ri(t){t!==null?(t.rt(),this.qg=t,t.figures.clear()):this.qg=new Geometry,this.Pi=null}uu(t,i,e,s,n,o){if(s!==void 0&&s===!0){const r=new PathSegment(1);r.endX=t,r.endY=i,this.Pi.segments.add(r)}else this.Pi=new PathFigure,this.Pi.startX=t,this.Pi.startY=i,this.Pi.isFilled=e,this.Pi.isEvenOdd=o||!1,this.qg.figures.add(this.Pi);n!==void 0&&(this.Pi.isShadowed=n)}VD(){const t=this.Pi.segments.length;t>0&&this.Pi.segments.elt(t-1).close()}zD(){this.Pi.segments.length>0&&(this.Pi.isFilled=!0)}XD(t){this.Pi.isShadowed=t}mE(t){this.Pi.isEvenOdd=t}ED(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(1);s.endX=t,s.endY=i,e&&s.close(),this.Pi.segments.add(s)}ur(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(2);s.endX=t,s.endY=i,e&&s.close(),this.Pi.segments.add(s)}dr(t,i,e,s,n,o,r){r===void 0&&(r=!1);const l=new PathSegment(3);l.point1X=t,l.point1Y=i,l.point2X=e,l.point2Y=s,l.endX=n,l.endY=o,r&&l.close(),this.Pi.segments.add(l)}Sw(t,i,e,s,n){n===void 0&&(n=!1);const o=new PathSegment(4);o.point1X=t,o.point1Y=i,o.endX=e,o.endY=s,n&&o.close(),this.Pi.segments.add(o)}UD(t,i,e,s,n,o,r){o===void 0&&(o=0),r===void 0&&(r=!1);const l=new PathSegment(5);l.startAngle=t,l.sweepAngle=i,l.centerX=e,l.centerY=s,l.radiusX=n,o!==0?l.radiusY=o:l.radiusY=n,r&&l.close(),this.Pi.segments.add(l)}BD(t,i,e,s,n,o,r,l){l===void 0&&(l=!1);const h=new PathSegment(6,o,r,t,i,e,s,n);l&&h.close(),this.Pi.segments.add(h)}static Y2=null;static yC(t){const i=GeoStream.Y2;if(i!==null)return GeoStream.Y2=null,i.Ri(t),i;{const e=new GeoStream;return e.Ri(t),e}}static wC(t){GeoStream.Y2=t}}{const w=function(n,o){const r=n.toLowerCase(),l=Geo.Mo;l[n]=o,l[r]=n};w("Rectangle",(n,o,r)=>{const l="r"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,Geo.fr{const l="s"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,h.defaultStretch=6,Geo.fr{(isNaN(l)||l<0)&&(l=5),isNaN(h)&&(h=15);const a="rr"+o+","+r+","+l+","+h;let c=Geo.cr[a];if(c!==void 0)return c;let f=l;(h&1)===1?(f=Math.min(f,(h&2)===2?o/3:o),f=Math.min(f,(h&8)===8?r/3:r)):f=0;const u=new PathFigure(f,0,!0);c=new Geometry().add(u);const d=Spot.TopLeft.copy(),m=Spot.BottomRight.copy();if((h&2)===2){let g=l;g=Math.min(g,(h&1)===1?o/3:o),g=Math.min(g,(h&4)===4?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,o-g,0)).add(new PathSegment(3,o,g,o-p,0,o,p)),d.offsetY=p,m.offsetX=-p}else u.add(new PathSegment(2,o,0));if((h&4)===4){let g=l;g=Math.min(g,(h&8)===8?o/3:o),g=Math.min(g,(h&2)===2?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,o,r-g)).add(new PathSegment(3,o-g,r,o,r-p,o-p,r)),m.offsetX=-p,m.offsetY=-p}else u.add(new PathSegment(2,o,r));if((h&8)===8){let g=l;g=Math.min(g,(h&4)===4?o/3:o),g=Math.min(g,(h&1)===1?r/3:r);const p=g*Geo.Un;u.add(new PathSegment(2,g,r)).add(new PathSegment(3,0,r-g,p,r,0,r-p)),d.offsetX=p,m.offsetY=-p}else u.add(new PathSegment(2,0,r));if((h&1)===1){const g=f*Geo.Un;u.add(new PathSegment(2,0,f)).add(new PathSegment(3,f,0,0,g,g,0).close()),d.offsetX=g,d.offsetY=g}else u.add(new PathSegment(2,0,0).close());return c.spot1=d,c.spot2=m,Geo.fr{const l=n?n.parameter1:NaN,h=n?n.parameter2:NaN;return t(n,o,r,l,h)}),w("Border","RoundedRectangle"),w("RoundedTopRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,3)}),w("RoundedBottomRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,12)}),w("RoundedLeftRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,9)}),w("RoundedRightRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,6)}),w("Ellipse",(n,o,r)=>{const l="e"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Rk,h.spot2=Spot.vk,Geo.fr{const l="c"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Rk,h.spot2=Spot.vk,h.defaultStretch=6,Geo.frnew Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,.5*r)).add(new PathSegment(2,0,r).close())).setSpots(0,.25,.5,.75)),w("TriangleDown",(n,o,r)=>new Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,0)).add(new PathSegment(2,.5*o,r).close())).setSpots(.25,0,.75,.5)),w("TriangleLeft",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,o,0).close())).setSpots(.5,.25,1,.75)),w("TriangleUp",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,r)).add(new PathSegment(2,.5*o,0).close())).setSpots(.25,.5,.75,1)),w("Triangle","TriangleUp"),w("Diamond",(n,o,r)=>new Geometry().add(new PathFigure(.5*o,0).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,.5*o,r)).add(new PathSegment(2,o,.5*r).close())).setSpots(.25,.25,.75,.75)),w("LineH",(n,o,r)=>{const l=new Geometry(1);return l.startX=0,l.startY=r/2,l.endX=o,l.endY=r/2,l}),w("LineV",(n,o,r)=>{const l=new Geometry(1);return l.startX=o/2,l.startY=0,l.endX=o/2,l.endY=r,l}),w("None","Rectangle"),w("BarH","Rectangle"),w("BarV","Rectangle"),w("MinusLine","LineH"),w("PlusLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r/2,!1).add(new PathSegment(2,o,r/2)).add(new PathSegment(1,o/2,0)).add(new PathSegment(2,o/2,r)))),w("XLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r,!1).add(new PathSegment(2,o,0)).add(new PathSegment(1,0,0)).add(new PathSegment(2,o,r)))),w("LineRight",(n,o,r)=>new Geometry().add(new PathFigure(.25*o,0,!1).add(new PathSegment(2,.75*o,.5*r)).add(new PathSegment(2,.25*o,r)))),w("LineDown",(n,o,r)=>new Geometry().add(new PathFigure(0,.25*r,!1).add(new PathSegment(2,.5*o,.75*r)).add(new PathSegment(2,o,.25*r)))),w("LineLeft",(n,o,r)=>new Geometry().add(new PathFigure(.75*o,0,!1).add(new PathSegment(2,.25*o,.5*r)).add(new PathSegment(2,.75*o,r)))),w("LineUp",(n,o,r)=>new Geometry().add(new PathFigure(0,.75*r,!1).add(new PathSegment(2,.5*o,.25*r)).add(new PathSegment(2,o,.75*r)))),w("Capsule",(n,o,r)=>{const l=new Geometry;if(or){const h=new PathFigure(r/2,0,!0);return l.add(h),h.add(new PathSegment(2,o-r/2,0)),h.add(new PathSegment(5,270,180,o-r/2,r/2,r/2,r/2)),h.add(new PathSegment(2,r/2,r)),h.add(new PathSegment(5,90,180,r/2,r/2,r/2,r/2)),l.spot1=new Spot(0,.156,r*.156,0),l.spot2=new Spot(1,.844,-r*.156,0),l}else return l.type=3,l.endX=o,l.endY=r,l.spot1=Spot.Rk,l.spot2=Spot.vk,l});const i=(n,o)=>new PathFigure(n,o,!1,!1),e=(n,o,r)=>n.add(new PathSegment(2,o,r)),s=(n,o,r)=>n.add(new PathSegment(1,o,r));w("Borders",(n,o,r)=>{let l=n?n.parameter1:NaN;isNaN(l)?l=10:l=l&15;const h=new Geometry;let a;return l===10?(a=i(o,0),e(a,o,r),s(a,0,r),e(a,0,0)):l===5?(a=i(0,0),e(a,o,0),s(a,o,r),e(a,0,r)):l===1?(a=i(0,0),e(a,o,0),s(a,o,r)):l===2?(a=i(o,0),e(a,o,r)):l===4?(a=i(o,r),e(a,0,r)):l===8?(a=i(0,r),e(a,0,0),s(a,o,r)):l===3?(a=i(0,0),e(a,o,0),e(a,o,r)):l===6?(a=i(o,0),e(a,o,r),e(a,0,r)):l===12?(a=i(o,r),e(a,0,r),e(a,0,0)):l===9?(a=i(0,r),e(a,0,0),e(a,o,0)):l===7?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r)):l===14?(a=i(o,0),e(a,o,r),e(a,0,r),e(a,0,0)):l===13?(a=i(o,r),e(a,0,r),e(a,0,0),e(a,o,0)):l===11?(a=i(0,r),e(a,0,0),e(a,o,0),e(a,o,r)):l===15?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r),a.add(new PathSegment(2,0,0).close())):(a=i(0,0),s(a,o,r)),h.add(a),h})}Geo.Kg={"":"",Standard:"F1 m 0,0 l 8,4 -8,4 2,-4 z",Backward:"F1 m 8,0 l -2,4 2,4 -8,-4 z",Triangle:"F1 m 0,0 l 8,4.62 -8,4.62 z",BackwardTriangle:"F1 m 8,4 l 0,4 -8,-4 8,-4 0,4 z",Boomerang:"F1 m 0,0 l 8,4 -8,4 4,-4 -4,-4 z",BackwardBoomerang:"F1 m 8,0 l -8,4 8,4 -4,-4 4,-4 z",SidewaysV:"m 0,0 l 8,4 -8,4 0,-1 6,-3 -6,-3 0,-1 z",BackwardV:"m 8,0 l -8,4 8,4 0,-1 -6,-3 6,-3 0,-1 z",OpenTriangle:"m 0,0 l 8,4 -8,4",BackwardOpenTriangle:"m 8,0 l -8,4 8,4",OpenTriangleLine:"m 0,0 l 8,4 -8,4 m 8.5,0 l 0,-8",BackwardOpenTriangleLine:"m 8,0 l -8,4 8,4 m -8.5,0 l 0,-8",OpenTriangleTop:"m 0,0 l 8,4 m 0,4",BackwardOpenTriangleTop:"m 8,0 l -8,4 m 0,4",OpenTriangleBottom:"m 0,8 l 8,-4",BackwardOpenTriangleBottom:"m 0,4 l 8,4",HalfTriangleTop:"F1 m 0,0 l 0,4 8,0 z m 0,8",BackwardHalfTriangleTop:"F1 m 8,0 l 0,4 -8,0 z m 0,8",HalfTriangleBottom:"F1 m 0,4 l 0,4 8,-4 z",BackwardHalfTriangleBottom:"F1 m 8,4 l 0,4 -8,-4 z",ForwardSemiCircle:"m 4,0 b 270 180 0 4 4",BackwardSemiCircle:"m 4,8 b 90 180 0 -4 4",Feather:"m 0,0 l 3,4 -3,4",BackwardFeather:"m 3,0 l -3,4 3,4",DoubleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardDoubleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4",TripleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardTripleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4 m 3,-8 l -3,4 3,4",ForwardSlash:"m 0,8 l 5,-8",BackSlash:"m 0,0 l 5,8",DoubleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8",DoubleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8",TripleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8 m -2,8 l 4,-8",TripleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8 m -2,-8 l 4,8",Fork:"m 0,4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4",LineFork:"m 0,0 l 0,8 m 0,-4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardLineFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4 m 8,-8 l 0,8",CircleFork:"F1 m 6,4 b 0 360 -3 0 3 z m 0,0 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 6,0 b 0 360 -3 0 3",CircleLineFork:"F1 m 6,4 b 0 360 -3 0 3 z m 1,-4 l 0,8 m 0,-4 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleLineFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 0,-4 l 0,8 m 7,-4 b 0 360 -3 0 3",Circle:"F1 m 8,4 b 0 360 -4 0 4 z",Block:"F1 m 0,0 l 0,8 8,0 0,-8 z",StretchedDiamond:"F1 m 0,3 l 5,-3 5,3 -5,3 -5,-3 z",Diamond:"F1 m 0,4 l 4,-4 4,4 -4,4 -4,-4 z",Chevron:"F1 m 0,0 l 5,0 3,4 -3,4 -5,0 3,-4 -3,-4 z",StretchedChevron:"F1 m 0,0 l 8,0 3,4 -3,4 -8,0 3,-4 -3,-4 z",NormalArrow:"F1 m 0,2 l 4,0 0,-2 4,4 -4,4 0,-2 -4,0 z",X:"m 0,0 l 8,8 m 0,-8 l -8,8",TailedNormalArrow:"F1 m 0,0 l 2,0 1,2 3,0 0,-2 2,4 -2,4 0,-2 -3,0 -1,2 -2,0 1,-4 -1,-4 z",DoubleTriangle:"F1 m 0,0 l 4,4 -4,4 0,-8 z m 4,0 l 4,4 -4,4 0,-8 z",BigEndArrow:"F1 m 0,0 l 5,2 0,-2 3,4 -3,4 0,-2 -5,2 0,-8 z",ConcaveTailArrow:"F1 m 0,2 h 4 v -2 l 4,4 -4,4 v -2 h -4 l 2,-2 -2,-2 z",RoundedTriangle:"F1 m 0,1 a 1,1 0 0 1 1,-1 l 7,3 a 0.5,1 0 0 1 0,2 l -7,3 a 1,1 0 0 1 -1,-1 l 0,-6 z",SimpleArrow:"F1 m 1,2 l -1,-2 2,0 1,2 -1,2 -2,0 1,-2 5,0 0,-2 2,2 -2,2 0,-2 z",AccelerationArrow:"F1 m 0,0 l 0,8 0.2,0 0,-8 -0.2,0 z m 2,0 l 0,8 1,0 0,-8 -1,0 z m 3,0 l 2,0 2,4 -2,4 -2,0 0,-8 z",BoxArrow:"F1 m 0,0 l 4,0 0,2 2,0 0,-2 2,4 -2,4 0,-2 -2,0 0,2 -4,0 0,-8 z",TriangleLine:"F1 m 8,4 l -8,-4 0,8 8,-4 z m 0.5,4 l 0,-8",CircleEndedArrow:"F1 m 10,4 l -2,-3 0,2 -2,0 0,2 2,0 0,2 2,-3 z m -4,0 b 0 360 -3 0 3 z",DynamicWidthArrow:"F1 m 0,3 l 2,0 2,-1 2,-2 2,4 -2,4 -2,-2 -2,-1 -2,0 0,-2 z",EquilibriumArrow:"m 0,3 l 8,0 -3,-3 m 3,5 l -8,0 3,3",FastForward:"F1 m 0,0 l 3.5,4 0,-4 3.5,4 0,-4 1,0 0,8 -1,0 0,-4 -3.5,4 0,-4 -3.5,4 0,-8 z",Kite:"F1 m 0,4 l 2,-4 6,4 -6,4 -2,-4 z",HalfArrowTop:"F1 m 0,0 l 4,4 4,0 -8,-4 z m 0,8",HalfArrowBottom:"F1 m 0,8 l 4,-4 4,0 -8,4 z",OpposingDirectionDoubleArrow:"F1 m 0,4 l 2,-4 0,2 4,0 0,-2 2,4 -2,4 0,-2 -4,0 0,2 -2,-4 z",PartialDoubleTriangle:"F1 m 0,0 4,3 0,-3 4,4 -4,4 0,-3 -4,3 0,-8 z",LineCircle:"F1 m 0,0 l 0,8 m 7 -4 b 0 360 -3 0 3 z",DoubleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",TripleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",CircleLine:"F1 m 6 4 b 0 360 -3 0 3 z m 1,-4 l 0,8",DiamondCircle:"F1 m 8,4 l -4,4 -4,-4 4,-4 4,4 m 8,0 b 0 360 -4 0 4 z",PlusCircle:"F1 m 8,4 b 0 360 -4 0 4 l -8 0 z m -4 -4 l 0 8",OpenRightTriangleTop:"m 8,0 l 0,4 -8,0 m 0,4",OpenRightTriangleBottom:"m 8,8 l 0,-4 -8,0",Line:"m 0,0 l 0,8",DoubleLine:"m 0,0 l 0,8 m 2,0 l 0,-8",TripleLine:"m 0,0 l 0,8 m 2,0 l 0,-8 m 2,0 l 0,8",PentagonArrow:"F1 m 8,4 l -4,-4 -4,0 0,8 4,0 4,-4 z"};var LayoutConditions=(w=>(w[w.None=0]="None",w[w.Added=1]="Added",w[w.Removed=2]="Removed",w[w.Shown=4]="Shown",w[w.Hidden=8]="Hidden",w[w.NodeSized=16]="NodeSized",w[w.GroupLayout=32]="GroupLayout",w[w.NodeReplaced=64]="NodeReplaced",w[w.Standard=127]="Standard",w[w.All=16777215]="All",w))(LayoutConditions||{});class Part extends Panel{P;Ho;F;ll;hl;qo;hi;Wo;mh;js;Jo;Ld;UM;BA;Bp;Vp;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.P=2408959,this.Ho="",this.F=null,this.ll="",this.hl=null,this.qo=null,this.hi="",this.Wo=null,this.mh=null,this.js=new Point(NaN,NaN).g(),this.Jo=null,this.Ld=NaN,this.UM=-1,this.BA=new Rect,this.Bp=null,this.Vp=NaN,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.P=this.P&-4097|16384|32768,t.Ho=this.Ho,this.F!==null&&(this.F.gi?t.F=this.F:t.F=this.F.copy()),t.ll=this.ll,t.qo=null,t.hi=this.hi,t.js.a(this.js),t.Ld=this.Ld}Vo(t){super.Vo(t),t.ah(),t.hl=null,t.Jo=null,t.Bp=null}toString(){let t=Util.sn(this.constructor)+"#"+GSet.as(this);return this.data!==null&&(t+="("+Util.toString(this.data)+")"),t}static LayoutNone=0;static LayoutAdded=1;static LayoutRemoved=2;static LayoutShown=4;static LayoutHidden=8;static LayoutNodeSized=16;static LayoutGroupLayout=32;static LayoutNodeReplaced=64;static LayoutStandard=127;static LayoutAll=16777215;qi(){this.F===null?this.F=new PartTemplateSettings:this.F.gi&&(this.F=this.F.copy())}rh(){super.rh(),this.F!==null&&(this.F.gi=!0)}Wc(t,i,e,s,n,o,r){const l=this.diagram;l!==null&&(t===3&&i==="elements"?n instanceof Panel?n.qr(h=>{l.partManager.MS(h,l)}):n instanceof Picture&&l.TS(n):t===4&&i==="elements"&&(n instanceof Panel?n.qr(h=>l.partManager.SS(h,l)):n instanceof Picture&&l.DS(n)),l.raiseChangedEvent(t,i,e,s,n,o,r))}updateTargetBindings(t){if(super.updateTargetBindings(t),this.data===null)return;const i=this.L.r,e=i.length;for(let n=0;n{r.data!==null&&r.updateTargetBindings()})}const s=this.adornments;for(;s.next();)s.value.updateTargetBindings(t)}Io(){if(super.Io(),this.m2()){const i=this.L.r,e=i.length;for(let s=0;so.Io())}}const t=this.adornments;for(;t.next();)t.value.Io()}updateRelationshipsFromData(){this.data!==null&&this.diagram?.partManager.updateRelationshipsFromData(this)}get key(){const t=this.diagram;if(t!==null)return t.model.getKeyForNodeData(this.data)}get adornments(){return this.qo===null?EmptyIterator.instance:this.qo.iteratorValues}findAdornment(t){const i=this.qo;return i===null?null:i.get(t)}addAdornment(t,i){if(i===null)return;let e=null,s=this.qo;if(s!==null&&(e=s.get(t)),e!==i){if(e!==null){const o=e.diagram;o!==null&&o.remove(e)}s===null&&(s=new GMap,this.qo=s),i.Ho!==t&&(i.category=t),s.set(t,i);const n=this.diagram;if(n!==null){n.add(i);const o=i.adornedObject;if(o!==null){const r=o.findBindingPanel();r!==null&&(i.data=r.data)}}}}removeAdornment(t){const i=this.qo;if(i===null)return;const e=i.get(t);if(e!==null){const s=e.diagram;s!==null&&(s.remove(e),e.data=null)}i.delete(t),i.count===0&&(this.qo=null)}clearAdornments(){const t=this.qo;if(t===null)return;const i=Util.ot(),e=t.iterator;for(;e.next();){const n=e.key;i.push(n)}const s=i.length;for(let n=0;n{e.isEnabled&&e.updateAdornments(i)}),t.toolManager.updateAdornments(i)}IM(t){this.Wo=t,t===null&&this.FR()}get layer(){return this.Wo}get diagram(){const t=this.Wo;return t==null?null:t.diagram}get layerName(){return this.ll}set layerName(t){const i=this.ll;if(i===t)return;Util.i(t,"string",Part,"layerName");let e=this.diagram;if(e!==null&&(e.findLayer(t)===null||e.partManager.addsToTemporaryLayer))return;this.ll=t,e!==null&&e.invalidateDocumentBounds(),this.t("layerName",i,t);const s=this.layer;if(s===null||s.name===t||(e=s.diagram,e===null))return;const n=e.findLayer(t);if(n===null||n===s)return;let o=s._i(-1,this,!0);o>=0&&e.raiseChangedEvent(4,"parts",s,this,null,o,!0),o=n.Hh(99999999,this,!0),s.visible!==n.visible&&this.Ei(n.visible),o>=0&&e.raiseChangedEvent(3,"parts",n,null,this,!0,o);const r=this.layerChanged;if(r===null)return;const l=e.Y;e.Y=!0,r(this,s,n),e.Y=l}get layerChanged(){return this.F!==null?this.F.zp:null}set layerChanged(t){const i=this.layerChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"layerChanged"),this.qi(),this.F.zp=t,this.t("layerChanged",i,t))}get zOrder(){return this.Ld}set zOrder(t){const i=this.Ld;if(i===t)return;Util.i(t,"number",Part,"zOrder"),this.Ld=t;const e=this.layer;e!==null&&e.yx(-1,this),this.t("zOrder",i,t);const s=this.diagram;s!==null&&s.C()}Iv(){const t=this.layer;t!==null&&t.yx(-1,this)}o1(){if(this.th()!==!1)return;this.G2(!0),this.td();const t=this.diagram;t!==null&&(t.r0(this),t.requestUpdate())}XA(){if(this.P|=2097152,this.th()===!1)return;const t=this.position,i=this.location;(!i.isReal()||!t.isReal())&&this.KA(t,i);const e=this.Li,s=Rect.l().a(e);e.rt(),e.x=t.x,e.y=t.y,e.g(),this.ed(s,e),Rect.s(s),this.G2(!1)}Qn(t,i,e,s){const n=this.ee;n.e(t,i,e,s),this.bi===null&&(this.bi=new Transform);const o=this.bi;o.Ri(),this.y0(o,t,i,e,s),this.bi=o,o.Ok()||o.xw(n)}y0(t,i,e,s,n){if(this.st!==1&&t.st(this.st),this.Xt===0)return;let o=Spot.Center;this.locationSpot.isSpot()&&(o=this.locationSpot);const r=Point.l();if(this.locationObject!==this){const l=this.locationObject,h=l.naturalBounds;r.setSpot(h.x,h.y,h.width,h.height,o),l.bi!==null&&l.bi.xt(r),r.offset(-l.measuredBounds.x,-l.measuredBounds.y);let a=l.panel;for(;a!==null&&a!==this;)a.bi!==null&&a.bi.xt(r),r.offset(-a.measuredBounds.x,-a.measuredBounds.y),a=a.panel}else r.setSpot(i,e,s,n,o);t.cs(this.Xt,r.x,r.y),Point.s(r)}get locationObject(){if(this.Jo===null)if(this instanceof Adornment&&this.type!==Panel.Link&&this.hasPlaceholder())this.Jo=this.placeholder;else{const t=this.locationObjectName;if(t!==""){const i=this.findObject(t);i!==null?this.Jo=i:this.Jo=this}else this.Jo=this}return this.Jo.visible?this.Jo:this}get minLocation(){return this.F!==null?this.F.Xp:Point.QN}set minLocation(t){const i=this.minLocation;i.equals(t)||(t=t.N(),this.qi(),this.F.Xp=t,this.t("minLocation",i,t))}get maxLocation(){return this.F!==null?this.F.Kp:Point._N}set maxLocation(t){const i=this.maxLocation;i.equals(t)||(t=t.N(),this.qi(),this.F.Kp=t,this.t("maxLocation",i,t))}get locationObjectName(){return this.F!==null?this.F.Yp:""}set locationObjectName(t){const i=this.locationObjectName;i!==t&&(this.qi(),this.F.Yp=t,this.Jo=null,this.c(),this.t("locationObjectName",i,t))}get locationSpot(){return this.F!==null?this.F.Gp:Spot.TopLeft}set locationSpot(t){const i=this.locationSpot;i.equals(t)||(t=t.N(),this.qi(),this.F.Gp=t,this.c(),this.t("locationSpot",i,t))}move(t,i){i===!0?this.location=t:this.position=t}moveTo(t,i,e){const s=Point.X(t,i);this.move(s,e),Point.s(s)}isVisible(){if(!this.visible)return!1;const t=this.layer;if(t!==null){if(!t.visible)return!1;const e=t.diagram;if(e!==null&&e.animationManager.nx(this))return!0}const i=this.containingGroup;return!(i!==null&&(!i.isSubGraphExpanded||!i.isVisible()))}Ei(t){const i=this.diagram;t?(this.invalidateLayout(4),this.invalidateAdornments(),i!==null&&i.r0(this)):(this.invalidateLayout(8),this.clearAdornments()),this.ah(),i!==null&&(i.invalidateDocumentBounds(),i.C())}findObject(t){if(this.name===t)return this;let i=this.Bp;if(i===null&&(this.Bp=i=new GMap),i.get(t)!==null)return i.get(t);const e=super.findObject(t);return e!==null?(i.set(t,e),e):(i.set(t,null),null)}T0(){this.Bp=null}getRelativePoint(t,i,e){e===void 0&&(e=new Point);const s=i.isNoSpot()?Spot.Center:i,n=t.naturalBounds;if(e.e(n.width*s.x+s.offsetX,n.height*s.y+s.offsetY),t===null||t===this)return e;t.D.xt(e);let o=t.panel;for(;o!==null&&o!==this;)o.D.xt(e),o=o.panel;return this.bi!==null&&this.bi.xt(e),e.offset(-this.ee.x,-this.ee.y),e}getDocumentBounds(t){return t===void 0&&(t=new Rect),t.a(this.actualBounds)}ensureBounds(){this.ut(1/0,1/0),this.zt()}pA(t){const i=this.locationSpot,e=this.locationObject;let s=e.naturalBounds;s.isReal()||(s=Rect.pw);const n=e instanceof Shape?e.strokeWidth:0;if(t.setSpot(0,0,s.width+n,s.height+n,i),e!==this){t.offset(-n/2,-n/2),e.D.xt(t);let o=e.panel;for(;o!==null&&o!==this;)o.D.xt(t),o=o.panel}return this.bi!==null&&this.bi.xt(t),t.offset(-this.ee.x,-this.ee.y),t}jh(t,i){const e=i===void 0?this.BA:i,s=this.Ev(),n=s*2;if(!this.isShadowed)return e.e(t.x-1-s,t.y-1-s,t.width+2+n,t.height+2+n),e;let o=t.x,r=t.y,l=t.width,h=t.height;const a=this.shadowBlur,c=this.shadowOffset;return l+=a,h+=a,o-=a/2,r-=a/2,c.x>0?l+=c.x:(o+=c.x,l-=c.x),c.y>0?h+=c.y:(r+=c.y,h-=c.y),e.e(o-1,r-1,l+2,h+2),e}wv(){return this.type===Panel.Link&&this instanceof Adornment&&this.category==="Selection"&&this.adornedObject instanceof Shape&&this.adornedPart.findMainElement()===this.adornedObject?this.adornedObject.strokeWidth:0}Ev(){return isNaN(this.Vp)&&(this.Vp=this.MA()),this.Vp}af(){this.Vp=NaN}zt(){if(this.is()===!1){this.XA();return}this._n(!1);const t=this.Li,i=Rect.l();i.a(t);const e=this.Nl();this.hh(0,0,this.ee.width,this.ee.height);const s=this.position;this.KA(s,this.location),t.rt(),t.x=s.x,t.y=s.y,t.g(),this.ed(i,t),i.equals(t)?this.Us(e):this.Pe()&&(!Geo.u(i.width,t.width)||!Geo.u(i.height,t.height))&&this.UM>=0&&this.invalidateLayout(16),Rect.s(i),this.G2(!1)}ed(t,i){const e=this.diagram;if(e===null)return;let s=!1;if(e.$h===!1&&t.isReal()){const n=Rect.l();n.a(e.documentBounds),n.subtractMargin(e.padding),t.x>n.x&&t.y>n.y&&t.rightn.x&&i.y>n.y&&i.right=o)return}}this.P=this.P^4096;let s=!1;if(e!==null){s=e.skipsUndoManager,e.skipsUndoManager=!0;const o=e.selection;o.rt(),t?o.add(this):o.delete(this),o.g()}this.t("isSelected",i,t),this.invalidateAdornments();const n=this.selectionChanged;n!==null&&n(this),e!==null&&(e.requestUpdate(),e.skipsUndoManager=s)}}get isHighlighted(){return(this.P&524288)!==0}set isHighlighted(t){const i=(this.P&524288)!==0;if(i!==t){this.P=this.P^524288;const e=this.diagram;if(e!==null){const n=e.highlighteds;n.rt(),t?n.add(this):n.delete(this),n.g()}this.t("isHighlighted",i,t),this.C();const s=this.highlightedChanged;s!==null&&s(this)}}get isShadowed(){return(this.P&8192)!==0}set isShadowed(t){const i=(this.P&8192)!==0;i!==t&&(this.P=this.P^8192,this.ss(!0),this.t("isShadowed",i,t),this.C())}VA(){return(this.P&16384)!==0}zA(t){t?this.P|=16384:this.P&=-16385}th(){return(this.P&32768)!==0}G2(t){t?this.P|=32768:this.P&=-32769}Uv(){return(this.P&65536)!==0}o2(t){t?this.P|=65536:this.P&=-65537}Nl(){return(this.P&131072)!==0}Us(t){t?this.P|=131072:this.P&=-131073}qA(){return(this.P&1048576)!==0}l1(t){t?this.P|=1048576:this.P&=-1048577}get isAnimated(){return(this.P&262144)!==0}set isAnimated(t){const i=(this.P&262144)!==0;i!==t&&(this.P=this.P^262144,this.t("isAnimated",i,t))}get highlightedChanged(){return this.F!==null?this.F.jp:null}set highlightedChanged(t){const i=this.highlightedChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"highlightedChanged"),this.qi(),this.F.jp=t,this.t("highlightedChanged",i,t))}get selectionObjectName(){return this.F!==null?this.F.Hp:""}set selectionObjectName(t){const i=this.selectionObjectName;i!==t&&(this.qi(),this.F.Hp=t,this.hl=null,this.t("selectionObjectName",i,t))}get selectionAdornmentTemplate(){return this.F!==null?this.F.qp:null}set selectionAdornmentTemplate(t){const i=this.selectionAdornmentTemplate;i!==t&&(this.qi(),this.F.qp=t,this.t("selectionAdornmentTemplate",i,t))}get selectionObject(){if(this.hl===null){const t=this.selectionObjectName;if(t!==null&&t!==""){const i=this.findObject(t);i!==null?this.hl=i:this.hl=this}else if(this instanceof Link){const i=this.path;i!==null?this.hl=i:this.hl=this}else this.hl=this}return this.hl}get selectionChanged(){return this.F!==null?this.F.Wp:null}set selectionChanged(t){const i=this.selectionChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"selectionChanged"),this.qi(),this.F.Wp=t,this.t("selectionChanged",i,t))}get resizeAdornmentTemplate(){return this.F!==null?this.F.Jp:null}set resizeAdornmentTemplate(t){const i=this.resizeAdornmentTemplate;i!==t&&(this.qi(),this.F.Jp=t,this.t("resizeAdornmentTemplate",i,t))}get resizeObjectName(){return this.F!==null?this.F.$p:""}set resizeObjectName(t){const i=this.resizeObjectName;i!==t&&(this.qi(),this.F.$p=t,this.t("resizeObjectName",i,t))}get resizeObject(){const t=this.resizeObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get resizeCellSize(){return this.F!==null?this.F.Zp:Size.gw}set resizeCellSize(t){const i=this.resizeCellSize;i.equals(t)||(t=t.N(),this.qi(),this.F.Zp=t,this.t("resizeCellSize",i,t))}get rotateAdornmentTemplate(){return this.F!==null?this.F.Qp:null}set rotateAdornmentTemplate(t){const i=this.rotateAdornmentTemplate;i!==t&&(this.qi(),this.F.Qp=t,this.t("rotateAdornmentTemplate",i,t))}get rotateObjectName(){return this.F!==null?this.F._p:""}set rotateObjectName(t){const i=this.rotateObjectName;i!==t&&(this.qi(),this.F._p=t,this.t("rotateObjectName",i,t))}get rotateObject(){const t=this.rotateObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get rotationSpot(){return this.F!==null?this.F.ty:Spot.Default}set rotationSpot(t){const i=this.rotationSpot;i.equals(t)||(t=t.N(),this.qi(),this.F.ty=t,this.t("rotationSpot",i,t))}get text(){return this.hi}set text(t){const i=this.hi;i!==t&&(this.hi=t,this.t("text",i,t))}get containingGroup(){return this.mh}set containingGroup(t){if(this.Pe()){const i=this.mh;if(i!==t){t!==null&&(this===t||t.isMemberOf(this))&&(this===t&&Util.o("Cannot make a Group a member of itself: "+this.toString()),Util.o("Cannot make a Group indirectly contain itself: "+this.toString()+" already contains "+t.toString())),this.invalidateLayout(2);const e=this.diagram;if(i!==null?i.H2(this):this instanceof Group&&e!==null&&e.Yr.delete(this),this.mh=t,t!==null?t.q2(this):this instanceof Group&&e!==null&&e.Yr.add(this),this.invalidateLayout(1),e!==null&&e.Y){const n=this.data,o=e.model;if(n!==null&&o.Hc()){const r=t!==null?t.data:null;o.setGroupForData(n,o.getKeyForNodeData(r))}}const s=this.containingGroupChanged;if(s!==null){let n=!0;e!==null&&(n=e.Y,e.Y=!0),s(this,i,t),e!==null&&(e.Y=n)}if(this instanceof Group){const n=new GSet;Part.sh(n,this,!0,0,!0);const o=n.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=r.linksConnected;for(;l.next();)l.value.Ad()}}}if(this instanceof Node){const n=this.linksConnected;for(;n.next();)n.value.Ad();const o=this.labeledLink;o!==null&&o.Ad()}this.t("containingGroup",i,t),t!==null&&t.Iv()}}else Util.o("cannot set the Part.containingGroup of a Link or Adornment")}ah(){const t=this.containingGroup;t!==null&&(t.hasPlaceholder()&&t.placeholder.c(),t.c(),t.invalidateConnectedLinks())}C(){const t=this.diagram;t!==null&&!this.is()&&!this.th()&&this.isVisible()&&this.Li.isReal()&&t.C(this.jh(this.Li))}c(){if(this.Oo())return;super.c();const t=this.diagram;t!==null&&(t.r0(this),this instanceof Node&&this.labeledLink!==null&&this.labeledLink.tf(),t.requestUpdate(!0))}tf(t){if(this.is())return;const i=this.diagram;i!==null&&(i.r0(this),this instanceof Node&&this.invalidateConnectedLinks(),i.requestUpdate()),this._n(!0)}Um(t){if(!t){const i=this.mh;i!==null&&i.q2(this)}}Bm(t){if(!t){const i=this.mh;i!==null&&i.H2(this)}}Xc(){const t=this.data;if(t!==null){const i=this.diagram;if(i!==null){const e=i.model;e!==null&&e.removeNodeData(t)}}}get containingGroupChanged(){return this.F!==null?this.F.iy:null}set containingGroupChanged(t){const i=this.containingGroupChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"containingGroupChanged"),this.qi(),this.F.iy=t,this.t("containingGroupChanged",i,t))}findSubGraphLevel(){return this.W2(this)}W2(t){const i=t.containingGroup;if(i!==null)return 1+this.W2(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.W2(e)}return 0}findTopLevelPart(){return this.J2(this)}J2(t){const i=t.containingGroup;if(i!==null)return this.J2(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.J2(e)}return t}get isTopLevel(){return!(this.containingGroup!==null||this instanceof Node&&this.labeledLink!==null)}isMemberOf(t){return t instanceof Group?this.$2(this,t):!1}$2(t,i){if(t===i||i===null)return!1;const e=t.containingGroup;if(e!==null&&(e===i||this.$2(e,i)))return!0;if(t instanceof Node){const s=t.labeledLink;if(s!==null)return this.$2(s,i)}return!1}findCommonContainingGroup(t){if(t===null)return null;if(this===t)return this.containingGroup;let i=this;for(;i!==null;){if(i instanceof Group&&i.l1(!0),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}let e=null;for(i=t;i!==null;){if(i.qA()){e=i;break}if(i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}for(i=this;i!==null;){if(i instanceof Group&&i.l1(!1),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}return e}get layoutConditions(){return this.F!==null?this.F.ey:127}set layoutConditions(t){const i=this.layoutConditions;i!==t&&(this.qi(),this.F.ey=t,this.t("layoutConditions",i,t))}canLayout(){if(!this.isLayoutPositioned||!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary||this instanceof Node&&this.isLinkLabel)}Vv(t){if(!this.isLayoutPositioned||!(t&this.layoutConditions))return!1;const i=this.layer;if(i!==null&&i.isTemporary||this instanceof Node&&this.isLinkLabel)return!1;const e=this.diagram;return!(e!==null&&e.undoManager.isUndoingRedoing)}invalidateLayout(t){if(t===void 0&&(t=16777215),!this.Vv(t))return;const i=this.mh;if(i!==null){const e=i.layout;e!==null?e.invalidateLayout():i.invalidateLayout(t)}else{const e=this.diagram;if(e!==null){const s=e.layout;s!==null&&s.invalidateLayout()}}}CL(){if(!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary)}static sh(t,i,e,s,n,o){if(o===void 0&&(o=null),!t.has(i)&&!(o!==null&&!o(i))&&!(i instanceof Adornment)){if(t.add(i),i instanceof Node){if(e&&i instanceof Group){const r=i.memberParts;for(;r.next();){const l=r.value;Part.sh(t,l,e,s,n,o)}}if(n!==!1){const r=i.linksConnected;for(;r.next();){const l=r.value;if(t.has(l))continue;const h=l.fromNode,a=l.toNode,c=h===null||t.has(h),f=a===null||t.has(a);(n?c&&f:c||f)&&Part.sh(t,l,e,s,n,o)}}if(s>1){const r=i.findTreeChildrenNodes();for(;r.next();){const l=r.value;Part.sh(t,l,e,s-1,n,o)}}}else if(i instanceof Link){const r=i.labelNodes;for(;r.next();){const l=r.value;Part.sh(t,l,e,s,n,o)}}}}get dragComputation(){return this.F!==null?this.F.sy:null}set dragComputation(t){const i=this.dragComputation;i!==t&&(t!==null&&Util.i(t,"function",Part,"dragComputation"),this.qi(),this.F.sy=t,this.t("dragComputation",i,t))}get shadowOffset(){return this.F!==null?this.F.ny:Point.tC}set shadowOffset(t){const i=this.shadowOffset;i.equals(t)||(t=t.N(),this.qi(),this.F.ny=t,this.C(),this.t("shadowOffset",i,t))}get shadowColor(){return this.F!==null?this.F.oy:"gray"}set shadowColor(t){const i=this.shadowColor;i!==t&&(this.qi(),this.F.oy=t,this.C(),this.t("shadowColor",i,t))}get shadowBlur(){return this.F!==null?this.F.xn:4}set shadowBlur(t){const i=this.shadowBlur;i!==t&&(this.qi(),this.F.xn=t,this.C(),this.t("shadowBlur",i,t))}}class PartTemplateSettings{gi;zp;iy;qp;Hp;Wp;jp;Jp;$p;Zp;Qp;_p;ty;Yp;Gp;Xp;Kp;sy;ey;ny;oy;xn;constructor(){this.gi=!1,this.zp=null,this.iy=null,this.qp=null,this.Hp="",this.Wp=null,this.jp=null,this.Jp=null,this.$p="",this.Zp=Size.gw,this.Qp=null,this._p="",this.ty=Spot.Default,this.Yp="",this.Gp=Spot.TopLeft,this.Xp=Point.QN,this.Kp=Point._N,this.sy=null,this.ey=127,this.ny=Point.tC,this.oy="gray",this.xn=4}copy(){const t=new PartTemplateSettings;return t.zp=this.zp,t.iy=this.iy,t.qp=this.qp,t.Hp=this.Hp,t.Wp=this.Wp,t.jp=this.jp,t.Jp=this.Jp,t.$p=this.$p,t.Zp=this.Zp.N(),t.Qp=this.Qp,t._p=this._p,t.ty=this.ty.N(),t.Yp=this.Yp,t.Gp=this.Gp.N(),t.Xp=this.Xp.N(),t.Kp=this.Kp.N(),t.sy=this.sy,t.ey=this.ey,t.ny=this.ny.N(),t.oy=this.oy,t.xn=this.xn,t}}class Adornment extends Part{us;It;JP;$P;lf;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.P&=-257,this.ll="Adornment",this.us=null,this.JP=0,this.$P=!1,this.It=null,this.lf=null,i&&Object.assign(this,i)}toString(){const t=this.adornedPart;return"Adornment("+this.category+")"+(t!==null?t.toString():"")}updateRelationshipsFromData(){}ad(t){const i=this.adornedObject,e=i?.part;if(!(e instanceof Link)||!(i instanceof Shape))return;const s=e.path;let n=s.geometry;e.ad(t),n=s.geometry;const o=this.L.r,r=o.length;for(let l=0;lh instanceof Placeholder);l instanceof Placeholder&&this.It===null&&(this.It=l)}}else t===4&&i==="elements"&&this.It!==null&&(s===this.It?this.It=null:s instanceof Panel&&this.It.isContainedBy(s)&&(this.It=null));super.Wc(t,i,e,s,n,o,r)}updateAdornments(){}Xc(){}}var PortSpreading=(w=>(w[w.None=0]="None",w[w.Evenly=1]="Evenly",w[w.Packed=2]="Packed",w))(PortSpreading||{});class Node extends Part{E;gt;bf;al;ph;se;_t;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.E=13,this.gt=null,this._t=new List,this.bf=null,this.al=null,this.se=null,this.ph=!1,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.E=this.E,this.gt!==null&&(this.gt.gi?t.gt=this.gt:t.gt=this.gt.copy())}Vo(t){super.Vo(t),t.invalidateConnectedLinks(),t.al=this.al,t.se=null}static SpreadingNone=0;static SpreadingEvenly=1;static SpreadingPacked=2;cl(){this.gt===null?this.gt=new NodeTemplateSettings:this.gt.gi&&(this.gt=this.gt.copy())}rh(){super.rh(),this.gt!==null&&(this.gt.gi=!0)}WA(t){t!==null&&(this.al===null&&(this.al=new GSet),this.al.add(t))}JA(t){t!==null&&this.al!==null&&this.al.delete(t)}$A(t,i,e){if(t===null||this.al===null)return null;const s=this.al.iterator;for(;s.next();){const n=s.value;if(n.ry===this&&n.h1===t&&n.Z2===i&&n.Q2===e||n.ry===t&&n.h1===this&&n.Z2===e&&n.Q2===i)return n}return null}invalidateLinkBundle(t,i,e){i==null&&(i=""),e==null&&(e="");const s=this.$A(t,i,e);s!==null&&s.Td()}Wc(t,i,e,s,n,o,r){t===3&&i==="elements"?this.se=null:t===4&&i==="elements"&&(this.se=null),super.Wc(t,i,e,s,n,o,r)}invalidateConnectedLinks(t){const i=this.linksConnected;for(;i.next();){const e=i.value;t!==void 0&&t.has(e)||(this.ge(e.fromPort),this.ge(e.toPort),e.invalidateRoute())}}iA(t){const i=this.linksConnected;for(;i.next();){const e=i.value;e.fromPort!==t&&e.toPort!==t||(this.ge(e.fromPort),this.ge(e.toPort),e.invalidateRoute())}}ge(t){if(t===null)return;const i=t.$u;i!==null&&i.Td();const e=t.part,s=e.containingGroup;s!==null&&!e.isVisible()&&s.ge(s.port)}Hr(){return!0}get portSpreading(){return this.gt!==null?this.gt.ly:1}set portSpreading(t){const i=this.portSpreading;if(i!==t){this.cl(),this.gt.ly=t,this.t("portSpreading",i,t);const e=this.diagram;if(e!==null&&e.undoManager.isUndoingRedoing)return;this.invalidateConnectedLinks()}}get avoidable(){return(this.E&8)!==0}set avoidable(t){const i=(this.E&8)!==0;if(i!==t){this.E=this.E^8;const e=this.diagram;e!==null&&e.ES(this),this.t("avoidable",i,t)}}get avoidableMargin(){return this.gt!==null?this.gt.hy:Margin.lC}set avoidableMargin(t){typeof t=="number"&&(t=new Margin(t));const i=this.avoidableMargin;if(!i.equals(t)){t=t.N(),this.cl(),this.gt.hy=t;const e=this.diagram;e!==null&&e.ES(this),this.t("avoidableMargin",i,t)}}canAvoid(){return this.avoidable&&!this.isLinkLabel}getAvoidableRect(t){return t.set(this.actualBounds),t.addMargin(this.avoidableMargin),t}findVisibleNode(){let t=this;for(;t!==null&&!t.isVisible();)t=t.containingGroup;return t}isVisible(){if(!super.isVisible())return!1;let t=!0,i=1;const e=this.diagram;if(e!==null){if(e.animationManager.nx(this))return!0;t=e.isTreePathToChildren,i=e.treeCollapsePolicy}if(i===1){const n=this.findTreeParentNode();if(n!==null&&!n.isTreeExpanded)return!1}else if(i===2){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&h.isTreeExpanded){r=!0;break}}}if(o&&!r)return!1}else if(i===3){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&!h.isTreeExpanded){r=!0;break}}}if(o&&r)return!1}const s=this.labeledLink;return s!==null?s.isVisible():!0}Ei(t){super.Ei(t);const i=this.linksConnected;for(;i.next();){const e=i.value;if(t&&this.containingGroup!==null){const s=e.getOtherNode(this);s!==null&&!s.isMemberOf(this.containingGroup)&&e.invalidateRoute()}e.Ei(t)}}get linksConnected(){return this._t.iterator}findExternalTreeLinksConnected(){const t=new GSet,i=new GSet;return this.ZA(this,t,i),i.iterator}ZA(t,i,e){if(t===null||i.has(t))return;i.add(t);let s=!0;const n=this.diagram;n!==null&&(s=n.isTreePathToChildren),t.linksConnected.each(o=>{o.isTreeLink?(s?o.fromNode===t:o.toNode===t)&&this.ZA(s?o.toNode:o.fromNode,i,e):e.add(o)})}findLinksConnected(t){if(t===void 0&&(t=null),t===null)return this._t.iterator;const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.fromNode===e&&s.fromPortId===t||s.toNode===e&&s.toPortId===t,i}findLinksOutOf(t){t===void 0&&(t=null);const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.fromNode!==e?!1:t===null?!0:s.fromPortId===t,i}findLinksInto(t){t===void 0&&(t=null);const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.toNode!==e?!1:t===null?!0:s.toPortId===t,i}findNodesConnected(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this){if(t===null||n.fromPortId===t){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}else if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesOutOf(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this&&(t===null||n.fromPortId===t)){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesInto(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findLinksBetween(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null);const s=new ListIterator(this._t),n=this;return s.predicate=o=>o.fromNode===n&&o.toNode===t&&(i===null||o.fromPortId===i)&&(e===null||o.toPortId===e)||o.fromNode===t&&o.toNode===n&&(e===null||o.fromPortId===e)&&(i===null||o.toPortId===i),s}findLinksTo(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null);const s=new ListIterator(this._t),n=this;return s.predicate=o=>!(o.fromNode!==n||o.toNode!==t||i!==null&&o.fromPortId!==i||e!==null&&o.toPortId!==e),s}get linkConnected(){return this.gt!==null?this.gt.ay:null}set linkConnected(t){const i=this.linkConnected;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkConnected"),this.cl(),this.gt.ay=t,this.t("linkConnected",i,t))}get linkDisconnected(){return this.gt!==null?this.gt.cy:null}set linkDisconnected(t){const i=this.linkDisconnected;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkDisconnected"),this.cl(),this.gt.cy=t,this.t("linkDisconnected",i,t))}get linkValidation(){return this.gt!==null?this.gt.Sl:null}set linkValidation(t){const i=this.linkValidation;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkValidation"),this.cl(),this.gt.Sl=t,this.t("linkValidation",i,t))}a1(t,i){this.ge(i);const e=this._t.has(t);if(e||this._t.add(t),!e||t.fromNode===t.toNode){const s=this.linkConnected;if(s!==null){let n=!0;const o=this.diagram;o!==null&&(n=o.Y,o.Y=!0),s(this,t,i),o!==null&&(o.Y=n)}}if(!e){if(!t.isTreeLink)return;const s=t.fromNode,n=t.toNode;if(s!==null&&n!==null&&s!==n){let o=!0;const r=this.diagram;r!==null&&(o=r.isTreePathToChildren);const l=o?n:s,h=o?s:n;if(l.ph||(l.ph=h),h.isTreeLeaf){if(r!==null&&r.undoManager.isUndoingRedoing)return;o?s===h&&(h.isTreeLeaf=!1):n===h&&(h.isTreeLeaf=!1)}}}}c1(t,i){this.ge(i);const e=this._t.delete(t);let s=null;if(e||t.toNode===t.fromNode){const n=this.linkDisconnected;if(s=this.diagram,n!==null){let o=!0;s!==null&&(o=s.Y,s.Y=!0),n(this,t,i),s!==null&&(s.Y=o)}}if(e){if(!t.isTreeLink)return;let n=!0;s!==null&&(n=s.isTreePathToChildren);const o=n?t.toNode:t.fromNode,r=n?t.fromNode:t.toNode;if(o!==null&&(o.ph=!1),r!==null&&!r.isTreeLeaf)if(r._t.count===0){if(r.ph=null,s!==null&&s.undoManager.isUndoingRedoing)return;r.isTreeLeaf=!0}else r.u0()}}u0(){if(this.ph=!1,this._t.count===0)return;let t=!0;const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;i!==null&&(t=i.isTreePathToChildren);const e=this._t.iterator;for(;e.next();){const s=e.value;if(s.isTreeLink){if(t){if(s.fromNode===this){this.isTreeLeaf=!1;return}}else if(s.toNode===this){this.isTreeLeaf=!1;return}}}this.isTreeLeaf=!0}updateRelationshipsFromData(){const t=this.diagram;t!==null&&t.partManager.updateRelationshipsFromData(this)}Um(t){if(super.Um(t),!t){this.u0();const i=this.bf;i!==null&&i.QA(this)}}Bm(t){if(super.Bm(t),!t){const i=this.bf;i!==null&&i._A(this)}}Xc(){if(this._t.count>0){const t=this.diagram;if(t!==null){const i=t.commandHandler!==null?t.commandHandler.deletesConnectedLinks:!0,s=this._t.copy().iterator;for(;s.next();){const n=s.value;i?t.remove(n):(n.fromNode===this&&(n.fromNode=null),n.toNode===this&&(n.toNode=null))}}}this.labeledLink=null,super.Xc()}get isLinkLabel(){return this.bf!==null}get labeledLink(){return this.bf}set labeledLink(t){const i=this.bf;if(i!==t){const e=this.diagram,s=this.data;if(i!==null){if(i._A(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=i.data,o=e.model;if(n!==null&&o.Aa()){const r=o.getKeyForNodeData(s);r!==void 0&&o.removeLabelKeyForLinkData(n,r)}}this.containingGroup=null}if(this.bf=t,t!==null){if(t.QA(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=t.data,o=e.model;if(n!==null&&o.Aa()){const r=o.getKeyForNodeData(s);r!==void 0&&o.addLabelKeyForLinkData(n,r)}}this.containingGroup=t.containingGroup}this.tf(),this.t("labeledLink",i,t)}}findVisiblePort(t){let i=t;for(;i!==null&&(!i.actualBounds.isReal()||!i.isVisibleObject());)i=i.panel;return i===null?this.port:i}findPort(t){if(this.se===null){if(t===""&&this.wn===!1)return this;this.tT()}let i=this.se.get(t);return i!==null||t!==""&&(i=this.se.get(""),i!==null)?i:this}get port(){return this.findPort("")}get ports(){return this.se===null&&this.tT(),this.se.iteratorValues}tT(){this.se===null?this.se=new GMap:this.se.clear(),this.walkVisualTreeFrom(this,(t,i)=>t.aA(i)),this.se.count===0&&this.se.set("",this)}aA(t){const i=t.portId;i!==null&&this.se!==null&&this.se.set(i,t)}g2(t,i){const e=t.portId;if(e!==null){this.se!==null&&this.se.delete(e);const s=this.diagram;if(s!==null&&i){let n=null;const o=this.findLinksConnected(e);for(;o.next();){const r=o.value;n===null&&(n=Util.ot()),n.push(r)}if(n!==null){for(let r=0;r!(!n.isTreeLink||n.fromNode!==s):e.predicate=n=>!(!n.isTreeLink||n.toNode!==s),e}findTreeChildrenNodes(){let t=!0;const i=this.diagram;i!==null&&(t=i.isTreePathToChildren);let e=null,s=null;const n=this._t.iterator;if(t)for(;n.next();){const o=n.value;if(o.isTreeLink&&o.fromNode===this){const r=o.toNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}else for(;n.next();){const o=n.value;if(o.isTreeLink&&o.toNode===this){const r=o.fromNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}return e!==null?e.iterator:s!==null?new SingletonIterator(s):EmptyIterator.instance}findTreeParts(t){t===void 0&&(t=1/0),Util.i(t,"number",Node,"findTreeParts:level");const i=new GSet;return Part.sh(i,this,!1,t,!0),i}collapseTree(t){t===void 0&&(t=1),t<1&&(t=1);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.iT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}iT(t,i,e,s,n,o){if(e>1){const r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);h!==null&&h!==this&&!t.has(h)&&(t.add(h),h.iT(t,i,e-1,s,n,o))}}else this.eT(t,i,s,n,o)}eT(t,i,e,s,n){const o=s===this?!0:this.isTreeExpanded,r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);if(h!==null&&h!==this){const a=t.has(h);if(a||t.add(h),o){const c=i?h.findNodesInto():h.findNodesOutOf(),f=this;c.all(u=>u===f||!u.isTreeExpanded)&&e.Cc(h,s),h.ah(),h.Ei(!1)}h.isTreeExpanded&&(h.wasTreeExpanded=h.isTreeExpanded,a||h.eT(t,i,e,s,n))}}this.isTreeExpanded=!1}expandTree(t){t===void 0&&(t=2),t<2&&(t=2);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.sT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}sT(t,i,e,s,n,o){const r=n===this?!1:this.isTreeExpanded,l=i?this.findLinksOutOf():this.findLinksInto();for(;l.next();){const h=l.value;if(!h.isTreeLink)continue;r||h.Se||h.invalidateRoute();const a=h.getOtherNode(this);if(a!==null&&a!==this&&!t.has(a)){if(t.add(a),!r){a.Ei(!0),a.ah();const c=i?a.findNodesInto():a.findNodesOutOf(),f=this;c.all(u=>u===f||!u.isTreeExpanded)&&s.Nc(a,n)}(e>2||a.wasTreeExpanded)&&(a.wasTreeExpanded=!1,a.sT(t,i,e-1,s,n,o))}}this.isTreeExpanded=!0}get isTreeExpanded(){return(this.E&1)!==0}set isTreeExpanded(t){const i=(this.E&1)!==0;if(i!==t){this.E=this.E^1;const e=this.diagram;this.t("isTreeExpanded",i,t);const s=this.treeExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.Y,e.Y=!0),s(this),e!==null&&(e.Y=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.Ei(t);return}t?this.expandTree():this.collapseTree()}}get wasTreeExpanded(){return(this.E&2)!==0}set wasTreeExpanded(t){const i=(this.E&2)!==0;i!==t&&(this.E=this.E^2,this.t("wasTreeExpanded",i,t))}get treeExpandedChanged(){return this.gt!==null?this.gt.fy:null}set treeExpandedChanged(t){const i=this.treeExpandedChanged;i!==t&&(t!==null&&Util.i(t,"function",Node,"treeExpandedChanged"),this.cl(),this.gt.fy=t,this.t("treeExpandedChanged",i,t))}get isTreeLeaf(){return(this.E&4)!==0}set isTreeLeaf(t){const i=(this.E&4)!==0;i!==t&&(this.E=this.E^4,this.t("isTreeLeaf",i,t))}get isTreeRoot(){return this.findTreeParentLink()===null}}class NodeTemplateSettings{gi;ay;cy;Sl;fy;hy;ly;uy;gy;eh;my;constructor(){this.gi=!1,this.ay=null,this.cy=null,this.Sl=null,this.fy=null,this.hy=Margin.lC,this.ly=1,this.uy=null,this.gy=null,this.eh=null,this.my=null}copy(){const t=new NodeTemplateSettings;return t.ay=this.ay,t.cy=this.cy,t.Sl=this.Sl,t.fy=this.fy,t.hy=this.hy.N(),t.ly=this.ly,t.uy=this.uy,t.gy=this.gy,t.eh=this.eh,t.my=this.my,t}}var LinkAdjusting=(w=>(w[w.None=0]="None",w[w.End=17]="End",w[w.Scale=18]="Scale",w[w.Stretch=19]="Stretch",w))(LinkAdjusting||{}),Routing=(w=>(w[w.Normal=1]="Normal",w[w.Orthogonal=2]="Orthogonal",w[w.AvoidsNodes=6]="AvoidsNodes",w[w.AvoidsNodesStraight=7]="AvoidsNodesStraight",w))(Routing||{}),Curve=(w=>(w[w.None=0]="None",w[w.Bezier=9]="Bezier",w[w.JumpGap=10]="JumpGap",w[w.JumpOver=11]="JumpOver",w))(Curve||{});class Link extends Part{Nt;lo;ho;Dd;ao;co;Fd;kf;Rd;vd;Od;Ta;Id;Hs;ki;fl;Mr;Pf;$o;_2;tN;f1;iN;eN;py;u1;ft;Zo;static Da=null;static Fa=null;lf;sN;nN;constructor(t){super(Panel.Link),this.Nt=8,this.lo=null,this.ho="",this.Dd=null,this.ao=null,this.co="",this.Fd=null,this.kf=0,this.Rd=0,this.vd=0,this.Od=NaN,this.Ta=1,this.Id=.5,this.Hs=null,this.ki=new List().g(),this.fl=null,this.Mr=null,this.Pf=new Rect,this.ft=new Geometry,this.$o=null,this.Zo=null,this._2=null,this.tN=null,this.sN=0,this.nN=0,this.f1=new Point,this.iN=null,this.eN=null,this.py=null,this.u1=NaN,this.q=null,this.lf=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Nt=this.Nt&-113,t.ho=this.ho,t.Dd=this.Dd,t.co=this.co,t.Fd=this.Fd,t.kf=this.kf,t.Rd=this.Rd,t.vd=this.vd,t.Od=this.Od,t.Ta=this.Ta,t.Id=this.Id,this.q!==null&&(t.q=this.q.copy())}Vo(t){super.Vo(t),this.ho=t.ho,this.co=t.co,t.fl=null,t.invalidateRoute(),t.Zo=this.Zo;const i=t.fromPort;i!==null&&t.fromNode.ge(i);const e=t.toPort;e!==null&&t.toNode.ge(e)}ri(t){t in Routing||t in Curve||t in LinkAdjusting?Link.oN(t)?this.routing=t:t===9||t===10||t===11?this.curve=t:t===17||t===18||t===19?this.adjusting=t:t===1||t===0||Util.o("Unknown Link enum value for a Link property: "+t):super.ri(t)}static Normal=1;static Orthogonal=2;static AvoidsNodes=6;static AvoidsNodesStraight=7;static None=0;static Bezier=9;static JumpGap=10;static JumpOver=11;static End=17;static Scale=18;static Stretch=19;static OrientAlong=21;static OrientPlus90=22;static OrientMinus90=23;static OrientOpposite=24;static OrientUpright=25;static OrientPlus90Upright=26;static OrientMinus90Upright=27;static OrientUpright45=28;static Xv=8;static Kv=16;static Yv=14;static Ra=8;Xe(){this.q===null&&(this.q=new LinkSettings)}_R(t,i,e){const s=t.segmentIndex,n=t.segmentFraction;let o=t.alignmentFocus;const r=t.segmentOrientation,l=t.segmentOffset;let h=0,a=0,c=0,f=0;if(isNaN(s)){const C=this.ft,S=Util.ot();C.getPointAndAngleAlongPath(n,S);const N=Point.X(S[0],S[1]);if(N.add(this.getPoint(0)),C.type===1)N.offset(-C.startX,-C.startY);else{const T=C.figures.first();N.offset(-T.startX,-T.startY)}f=S[2],r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=N.x,a=N.y,Point.s(N),Util.tt(S)}else if(s<-i||s>=i){const C=Point.l();this.mA(C),f=this.midAngle,r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=C.x,a=C.y,Point.s(C)}else{let C,S,N=0;if(s>=0?(C=e.r[s],S=s0?e.r[N-1]:C),C.equalsApprox(S)){let T,A;s>=0?(T=s>0?e.r[s-1]:C,A=s1?e.r[N-2]:S);const D=T.distanceSquaredPoint(C),F=S.distanceSquaredPoint(A);D>F+10?f=s>=0?T.directionPoint(C):C.directionPoint(T):F>D+10?f=s>=0?S.directionPoint(A):A.directionPoint(S):f=s>=0?T.directionPoint(A):A.directionPoint(T)}else f=s>=0?C.directionPoint(S):S.directionPoint(C);r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=C.x+(S.x-C.x)*n,a=C.y+(S.y-C.y)*n}if(o.isNone()){t.location=new Point(h,a);return}else o.isNoSpot()&&(o=Spot.Center);const u=Transform.l();u.Ri(),u.st(t.scale,t.scale),u.cs(t.angle,0,0);const d=t.naturalBounds,m=Rect.X(0,0,d.width,d.height),g=Point.l();g.setRectSpot(m,o),u.xt(g);let p=-g.x,y=-g.y;const x=d.width,k=d.height,b=Point.l();b.a(l);const P=isNaN(l.x),M=isNaN(l.y);if(P||M){const C=x/2+3,S=k/2+3,N=f>=45&&f<=135,T=f>=225&&f<=315;r===0&&(N||T)?(b.x=M?C:l.y,b.y=P?S:l.x,N?s>=0||isNaN(s)&&n<.5||P&&(b.y=-S):T&&((s>=0||isNaN(s)&&n<.5)&&P&&(b.y=-S),M&&(b.x=-C))):(P&&(s>=0||isNaN(s)&&n<.5?b.x=C:b.x=-C),M&&(b.y=-S),b.rotate(f))}else b.rotate(f);h+=b.x,a+=b.y,u.xw(m),p+=m.x,y+=m.y;const L=Point.X(h+p,a+y);t.move(L),Point.s(L),Point.s(b),Point.s(g),Rect.s(m),Transform.s(u)}Hr(){let t=this.fromNode;if(t!==null){const e=t.findVisibleNode();if(e!==null&&(t=e),t.is()||t.th())return!1}let i=this.toNode;if(i!==null){const e=i.findVisibleNode();if(e!==null&&(i=e),i.is()||i.th())return!1}return!0}u2(t,i,e){return!1}d2(){}Pe(){return!1}computeAngle(t,i,e){return Link.computeAngle(i,e)}static computeAngle(t,i){let e=0;switch(t){default:case 0:e=0;break;case 21:e=i;break;case 22:e=i+90;break;case 23:e=i-90;break;case 24:e=i+180;break;case 25:e=Geo.Xg(i),e>90&&e<270&&(e-=180);break;case 26:e=Geo.Xg(i+90),e>90&&e<270&&(e-=180);break;case 27:e=Geo.Xg(i-90),e>90&&e<270&&(e-=180);break;case 28:if(e=Geo.Xg(i),e>45&&e<135||e>225&&e<315)return 0;e>90&&e<270&&(e-=180);break}return Geo.Xg(e)}get fromNode(){return this.lo}set fromNode(t){const i=this.lo;if(i!==t){const e=this.fromPort;i!==null&&(this.ao!==i&&i.c1(this,e),this.yy(),this.invalidateLayout(2)),this.lo=t,t!==null&&this.Ei(t.isVisible()),this.$o=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.Y&&s.partManager.setFromNodeForLink(this,t,i);const n=this.fromPort,o=this.fromPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.Y,s.Y=!0),o(this,e,n),s!==null&&(s.Y=r)}t!==null&&(this.ao!==t&&t.a1(this,n),this.wy(),this.invalidateLayout(1)),this.t("fromNode",i,t),this.Ad()}}get fromPortId(){return this.ho}set fromPortId(t){const i=this.ho;if(i!==t){const e=this.fromPort;e!==null&&this.fromNode.ge(e),this.yy(),this.ho=t;const s=this.fromPort;s!==null&&this.fromNode.ge(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Aa()&&r.setFromPortIdForLinkData(o,t)}if(e!==s){this.$o=null,this.invalidateRoute();const o=this.fromPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.Y,n.Y=!0),o(this,e,s),n!==null&&(n.Y=r)}}this.wy(),this.t("fromPortId",i,t)}}get fromPort(){const t=this.lo;if(t===null)return null;const i=this.ho;return t.findPort(i)}get fromPortChanged(){return this.Dd}set fromPortChanged(t){const i=this.Dd;i!==t&&(t!==null&&Util.i(t,"function",Link,"fromPortChanged"),this.Dd=t,this.t("fromPortChanged",i,t))}get toNode(){return this.ao}set toNode(t){const i=this.ao;if(i!==t){const e=this.toPort;i!==null&&(this.lo!==i&&i.c1(this,e),this.yy(),this.invalidateLayout(2)),this.ao=t,t!==null&&this.Ei(t.isVisible()),this.$o=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.Y&&s.partManager.setToNodeForLink(this,t,i);const n=this.toPort,o=this.toPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.Y,s.Y=!0),o(this,e,n),s!==null&&(s.Y=r)}t!==null&&(this.lo!==t&&t.a1(this,n),this.wy(),this.invalidateLayout(1)),this.t("toNode",i,t),this.Ad()}}get toPortId(){return this.co}set toPortId(t){const i=this.co;if(i!==t){const e=this.toPort;e!==null&&this.toNode.ge(e),this.yy(),this.co=t;const s=this.toPort;s!==null&&this.toNode.ge(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Aa()&&r.setToPortIdForLinkData(o,t)}if(e!==s){this.$o=null,this.invalidateRoute();const o=this.toPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.Y,n.Y=!0),o(this,e,s),n!==null&&(n.Y=r)}}this.wy(),this.t("toPortId",i,t)}}get toPort(){const t=this.ao;if(t===null)return null;const i=this.co;return t.findPort(i)}get toPortChanged(){return this.Fd}set toPortChanged(t){const i=this.Fd;i!==t&&(t!==null&&Util.i(t,"function",Link,"toPortChanged"),this.Fd=t,this.t("toPortChanged",i,t))}get fromSpot(){return this.q!==null?this.q.ca:Spot.Default}set fromSpot(t){const i=this.fromSpot;if(!i.equals(t)){if(t=t.N(),this.Xe(),this.q.ca=t,this.t("fromSpot",i,t),i.isSide()||t.isSide()){const e=this.fromNode;e!==null&&e.ge(this.fromPort)}this.invalidateRoute()}}get fromEndSegmentLength(){return this.q!==null?this.q.ua:NaN}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;i!==t&&(t<0&&Util._(t,">= 0",Link,"fromEndSegmentLength"),this.Xe(),this.q.ua=t,this.t("fromEndSegmentLength",i,t),this.invalidateRoute())}get fromShortLength(){return this.q!==null?this.q.ga:NaN}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(this.Xe(),this.q.ga=t,this.ie(),this.t("fromShortLength",i,t))}get toSpot(){return this.q!==null?this.q.fa:Spot.Default}set toSpot(t){const i=this.toSpot;if(!i.equals(t)){if(t=t.N(),this.Xe(),this.q.fa=t,this.t("toSpot",i,t),i.isSide()||t.isSide()){const e=this.toNode;e!==null&&e.ge(this.toPort)}this.invalidateRoute()}}get toEndSegmentLength(){return this.q!==null?this.q.da:NaN}set toEndSegmentLength(t){const i=this.toEndSegmentLength;i!==t&&(t<0&&Util._(t,">= 0",Link,"toEndSegmentLength"),this.Xe(),this.q.da=t,this.t("toEndSegmentLength",i,t),this.invalidateRoute())}get toShortLength(){return this.q!==null?this.q.ma:NaN}set toShortLength(t){const i=this.toShortLength;i!==t&&(this.Xe(),this.q.ma=t,this.ie(),this.t("toShortLength",i,t))}Ad(){const t=this.fromNode,i=this.toNode;let e=null;if(t!==null?i!==null?e=t.findCommonContainingGroup(i):e=t.containingGroup:i!==null?e=i.containingGroup:e=null,this.Gv(e),this.isLabeledLink){const s=this.labelNodes;for(;s.next();){const n=s.value;n.containingGroup=e}}}Gv(t){const i=this.mh;if(i!==t){i!==null&&i.H2(this),this.mh=t,t!==null&&t.q2(this);const e=this.containingGroupChanged;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.Y,n.Y=!0),e(this,i,t),n!==null&&(n.Y=s)}this.Se&&(this.iN===i||this.eN===i)&&this.invalidateRoute()}}ah(){const t=this.containingGroup;t!==null&&this.fromNode!==t&&this.toNode!==t&&t.computesBoundsIncludingLinks&&super.ah()}getOtherNode(t){const i=this.fromNode;return t===i?this.toNode:i}getOtherPort(t){const i=this.fromPort;return t===i?this.toPort:i}get isLabeledLink(){return this.Hs===null?!1:this.Hs.count>0}get labelNodes(){return this.Hs===null?EmptyIterator.instance:this.Hs.iterator}QA(t){this.Hs===null&&(this.Hs=new GSet),this.Hs.add(t),this.c()}_A(t){this.Hs!==null&&(this.Hs.delete(t),this.c())}Um(t){if(super.Um(t),this.va()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.lo;let e=null;i!==null&&(e=this.fromPort,i.a1(this,e));const s=this.ao;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.a1(this,n)),this.wy()}}Bm(t){if(super.Bm(t),this.va()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.lo;let e=null;i!==null&&(e=this.fromPort,i.c1(this,e));const s=this.ao;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.c1(this,n)),this.yy()}}Xc(){if(this.Se=!0,this.Hs!==null){const i=this.diagram;if(i!==null){const s=this.Hs.copy().iterator;for(;s.next();){const n=s.value;i.remove(n)}}}if(this.data!==null){const i=this.diagram;i!==null&&i.partManager.rN(this)}}updateRelationshipsFromData(){if(this.data===null)return;const i=this.diagram;i!==null&&i.partManager.updateRelationshipsFromData(this)}move(t,i){const e=i?this.location:this.position;let s=e.x;isNaN(s)&&(s=0);let n=e.y;isNaN(n)&&(n=0);const o=t.x-s,r=t.y-n;if(i===!0)super.move(t,!1);else{const h=Point.X(e.x+o,e.y+r);super.move(h,!1),Point.s(h)}this.pr(o,r);const l=this.labelNodes;for(;l.next();){const h=l.value,a=h.position;h.moveTo(a.x+o,a.y+r)}}get relinkableFrom(){return(this.Nt&1)!==0}set relinkableFrom(t){const i=(this.Nt&1)!==0;i!==t&&(this.Nt=this.Nt^1,this.t("relinkableFrom",i,t),this.invalidateAdornments())}get relinkableTo(){return(this.Nt&2)!==0}set relinkableTo(t){const i=(this.Nt&2)!==0;i!==t&&(this.Nt=this.Nt^2,this.t("relinkableTo",i,t),this.invalidateAdornments())}canRelinkFrom(){if(!this.relinkableFrom)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}canRelinkTo(){if(!this.relinkableTo)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}get resegmentable(){return(this.Nt&4)!==0}set resegmentable(t){const i=(this.Nt&4)!==0;i!==t&&(this.Nt=this.Nt^4,this.t("resegmentable",i,t),this.invalidateAdornments())}get isTreeLink(){return(this.Nt&8)!==0}set isTreeLink(t){const i=(this.Nt&8)!==0;i!==t&&(this.Nt=this.Nt^8,this.t("isTreeLink",i,t),this.fromNode!==null&&this.fromNode.u0(),this.toNode!==null&&this.toNode.u0())}get path(){const t=this.findMainElement();return t instanceof Shape?t:null}get routeBounds(){return this.updateRoute(),this.jv(this.Pf)}jv(t){let i=1/0,e=1/0;const s=this.pointsCount;if(s===0)return t.e(NaN,NaN,0,0),t;if(s===1){const n=this.getPoint(0);i=Math.min(n.x,i),e=Math.min(n.y,e),t.e(n.x,n.y,0,0)}else if(s===2){const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o)}else if(this.computeCurve()===9&&s>=3&&!this.isOrthogonal){let n=this.getPoint(0);if(i=n.x,e=n.y,t.e(i,e,0,0),s===3){const o=this.getPoint(1);i=Math.min(o.x,i),e=Math.min(o.y,e);const r=this.getPoint(2);i=Math.min(r.x,i),e=Math.min(r.y,e),Geo.au(n.x,n.y,o.x,o.y,o.x,o.y,r.x,r.y,.5,t)}else for(let o=3;o=s&&(o=s-1);const l=this.getPoint(o-1),h=this.getPoint(o);Geo.au(n.x,n.y,r.x,r.y,l.x,l.y,h.x,h.y,.5,t),i=Math.min(h.x,i),e=Math.min(h.y,e),n=h}}else{const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o);for(let r=2;r=15||this.computeCurve()===9)){this.ft.getPointAlongPath(.5,t),t.add(this.getPoint(0));const a=this.ft.figures.first();return t.offset(-a.startX,-a.startY),t}if(this.computeCurve()===9){if(i===3){const f=this.getPoint(0),u=this.getPoint(1),d=this.getPoint(2);return Geo.dC(f.x,f.y,u.x,u.y,u.x,u.y,d.x,d.y,t),t}const a=(i-1)/3|0,c=(a/2|0)*3;if(a%2===1){const f=this.getPoint(c),u=this.getPoint(c+1),d=this.getPoint(c+2),m=this.getPoint(c+3);return Geo.dC(f.x,f.y,u.x,u.y,d.x,d.y,m.x,m.y,t),t}else return t.a(this.getPoint(c)),t}const e=this.flattenedLengths,s=this.flattenedTotalLength;let n=0,o=0,r=0;for(;ns/2));)n+=r,o++;const l=this.getPoint(o),h=this.getPoint(o+1);if(Math.abs(l.x-h.x)<1)l.y>h.y?t.e(l.x,l.y-(s/2-n)):t.e(l.x,l.y+(s/2-n));else if(Math.abs(l.y-h.y)<1)l.x>h.x?t.e(l.x-(s/2-n),l.y):t.e(l.x+(s/2-n),l.y);else{const a=(s/2-n)/r,c=a*(h.x-l.x),f=a*(h.y-l.y);t.e(l.x+c,l.y+f)}return t}get midAngle(){return this.updateRoute(),this.computeMidAngle()}computeMidAngle(){const t=this.pointsCount;if(t<2)return NaN;if(t===2){const h=this.getPoint(0),a=this.getPoint(1);return h.directionPoint(a)}if(this.isOrthogonal&&(this.computeCorner()>=15||this.computeCurve()===9))return this.ft.getAngleAlongPath(.5);if(this.computeCurve()===9&&t>=4){const h=(t-1)/3|0;let a=(h/2|0)*3;if(h%2===1){a=Math.floor(a);const c=this.getPoint(a),f=this.getPoint(a+1),u=this.getPoint(a+2),d=this.getPoint(a+3);return Geo.RD(c.x,c.y,f.x,f.y,u.x,u.y,d.x,d.y)}else if(a>0&&a+1e/2));)s+=o,n++;const r=this.getPoint(n),l=this.getPoint(n+1);if(Math.abs(r.x-l.x)<1&&Math.abs(r.y-l.y)<1){if(n>0&&n+2l.y?270:90;if(Math.abs(r.y-l.y)<1)return r.x>l.x?180:0}return r.directionPoint(l)}Hv(){if(this.py===null){this.Se||this.d1();const t=this.py=[];this.qv(t)}}get flattenedLengths(){return this.Hv(),this.py}get flattenedTotalLength(){let t=this.u1;if(isNaN(t)){const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=3){let g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e);m=this.adjustPoints(0,g,o-1,p),m&&(g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e),this.adjustPoints(0,g,o-1,p))}m||(this.clearPoints(),u?this.Wv(i,e,r,s,n,l):this.Jv(i,e,r,s,n,l))}else{const m=this.isAvoiding;d&&(f&&m||c)&&this.clearPoints();const g=c?this.computeCurviness():0,p=this.getLinkPoint(i,e,r,!0,f,s,n);let y=0,x=0,k=0;if(f||!h||c){let N=this.computeEndSegmentLength(i,e,r,!0);if(k=this.getLinkDirection(i,e,p,r,!0,f,s,n),c&&(h||r.equals(l)||!f&&r.x+l.x===1&&r.y+l.y===1)&&(k-=f?90:30,g<0&&(k-=180)),k<0?k+=360:k>=360&&(k-=360),c&&(N+=Math.abs(g)*(f?1:2)),k===0?y=N:k===90?x=N:k===180?y=-N:k===270?x=-N:(y=N*Math.cos(k*Math.PI/180),x=N*Math.sin(k*Math.PI/180)),r.isNoSpot()&&c){const T=e.getDocumentPoint(Spot.Center,Point.l()),A=Point.X(T.x+y*1e3,T.y+x*1e3);this.getLinkPointFromPoint(i,e,T,A,!0,p),Point.s(T),Point.s(A)}}const b=this.getLinkPoint(s,n,l,!1,f,i,e);let P=0,M=0,L=0;if(f||!a||c){let N=this.computeEndSegmentLength(s,n,l,!1);if(L=this.getLinkDirection(s,n,b,l,!1,f,i,e),c&&(a||r.equals(l)||!f&&r.x+l.x===1&&r.y+l.y===1)&&(L+=f?0:30,g<0&&(L+=180)),L<0?L+=360:L>=360&&(L-=360),c&&(N+=Math.abs(g)*(f?1:2)),L===0?P=N:L===90?M=N:L===180?P=-N:L===270?M=-N:(P=N*Math.cos(L*Math.PI/180),M=N*Math.sin(L*Math.PI/180)),l.isNoSpot()&&c){const T=n.getDocumentPoint(Spot.Center,Point.l()),A=Point.X(T.x+P*1e3,T.y+M*1e3);this.getLinkPointFromPoint(s,n,T,A,!1,b),Point.s(T),Point.s(A)}}let C=p;(f||!h||c)&&(C=new Point(p.x+y,p.y+x));let S=b;(f||!a||c)&&(S=new Point(b.x+P,b.y+M)),!d&&!f&&h&&o>3&&this.adjustPoints(0,p,o-2,S)?this.setPoint(o-1,b):!d&&!f&&a&&o>3&&this.adjustPoints(1,C,o-1,b)?this.setPoint(0,p):!d&&(f?o>=6:o>4)&&this.adjustPoints(1,C,o-2,S)?(this.setPoint(0,p),this.setPoint(o-1,b)):(this.clearPoints(),this.addPoint(p),(f||!h||c)&&this.addPoint(C),f&&this.addOrthoPoints(C,k,S,L,i,s),(f||!a||c)&&this.addPoint(S),this.addPoint(b))}return t.addInvalidRoute(this),!0}hN(t,i){return Math.abs(i.x-t.x)>Math.abs(i.y-t.y)?(i.x>=t.x?i.x=t.x+9e9:i.x=t.x-9e9,i.y=t.y):(i.y>=t.y?i.y=t.y+9e9:i.y=t.y-9e9,i.x=t.x),i}getLinkPointFromPoint(t,i,e,s,n,o){if(o===void 0&&(o=new Point),t===null||i===null)return o.a(e),o;if(!t.isVisible()){const u=t.findVisibleNode();u!==null&&u!==t&&(t=u,i=t.port)}let r=0,l=0,h=0,a=0,c=null,f=i.panel;if(f!==null&&!f.pn()&&(f=f.panel),f===null)r=s.x,l=s.y,h=e.x,a=e.y;else{c=f.Es;const u=1/(c.m11*c.m22-c.m12*c.m21),d=c.m22*u,m=-c.m12*u,g=-c.m21*u,p=c.m11*u,y=u*(c.m21*c.dy-c.m22*c.dx),x=u*(c.m12*c.dx-c.m11*c.dy);r=s.x*d+s.y*g+y,l=s.x*m+s.y*p+x,h=e.x*d+e.y*g+y,a=e.x*m+e.y*p+x}return i.$c(r,l,h,a,o),c!==null&&o.D(c),o}$v(t,i){const e=t.$u;return e!==null?e.nT(i):null}m1(t){let i=t.$u;return i===null&&(i=new Knot,i.Qo=t,i.ue=t.part,t.$u=i),i.nT(this)}getLinkPoint(t,i,e,s,n,o,r,l){if(l===void 0&&(l=new Point),e.isSpot()&&!this.Ed(e))return i.getDocumentPoint(e,l),l;if(e.isSide()){const c=this.m1(i);if(c!==null){const f=c.Ud;if(l.a(f),n&&this.routing===7){const u=this.m1(r);if(u!==null&&c.Mf=g.y&&y.y<=g.y+g.height?l.y=y.y:(e.includesSide(Spot.TopSide)||e.includesSide(Spot.BottomSide))&&y.x>=g.x&&y.x<=g.x+g.width&&(l.x=y.x),Point.s(d),Point.s(m)}}return l}}const h=i.getDocumentPoint(this.p1(e,s),Point.l());let a=null;if(this.pointsCount>(n?6:2))a=s?this.getPoint(1):this.getPoint(this.pointsCount-2),n&&(a=this.hN(h,a.copy()));else{const c=this.computeSpot(!s,r),f=Point.l();a=r.getDocumentPoint(this.p1(c,!s),f),n&&(a=this.hN(h,a)),Point.s(f)}return this.getLinkPointFromPoint(t,i,h,a,s,l),Point.s(h),l}getLinkDirection(t,i,e,s,n,o,r,l){let h=this.Zv(t,i,e,s,n,o,r,l);if(r&&s.isNoSpot()&&r.isMemberOf(t)&&(h+=180,h>=360&&(h-=360)),this.Ed(s))return h;const a=i.getDocumentAngle();return a===0||(45<=a&&a<135?h+=90:135<=a&&a<225?h+=180:225<=a&&a<315&&(h+=270),h>=360&&(h-=360)),h}Zv(t,i,e,s,n,o,r,l){if(s.isSpot())return s.x>s.y?s.x>1-s.y?0:s.x<1-s.y?270:315:s.x1-s.y?90:s.x<1-s.y?180:135:s.x<.5?225:s.x>.5?45:0;if(s.isSide()){const f=this.m1(i);if(f!==null)switch(f.me){case 1:return 270;case 2:return 180;default:case 4:return 0;case 8:return 90}}const h=i.getDocumentPoint(Spot.Center,Point.l());let a=null;if(this.pointsCount>(o?6:2))a=n?this.getPoint(1):this.getPoint(this.pointsCount-2),o?a=this.hN(h,a.copy()):a=e;else{const f=Point.l();a=l.getDocumentPoint(Spot.Center,f),Point.s(f)}let c=0;return Math.abs(a.x-h.x)>Math.abs(a.y-h.y)?a.x>=h.x?c=0:c=180:a.y>=h.y?c=90:c=270,Point.s(h),c}computeEndSegmentLength(t,i,e,s){if(i!==null&&e.isSide()){const o=this.m1(i);if(o!==null)return o.w1}let n=NaN;return s?n=this.fromEndSegmentLength:n=this.toEndSegmentLength,i!==null&&isNaN(n)&&(s?n=i.fromEndSegmentLength:n=i.toEndSegmentLength),isNaN(n)&&(n=10),n}computeSpot(t,i){return i===void 0&&(i=null),t?this.Qv(i||this.fromPort):this._v(i||this.toPort)}Qv(t){if(t===null)return Spot.Center;let i=this.fromSpot;return i.isDefault()&&(i=t.fromSpot),i===Spot.Default?Spot.None:i}_v(t){if(t===null)return Spot.Center;let i=this.toSpot;return i.isDefault()&&(i=t.toSpot),i===Spot.Default?Spot.None:i}Ed(t){return t===Spot.None||t.x===.5&&t.y===.5}p1(t,i){return t.x===.5&&t.y===.5?t:Spot.Center}computeOtherPoint(t,i){if(this.computeAdjusting()!==0&&this.pointsCount>4)return this.computeMidPoint(new Point);{const e=this.$v(i,this);return e!==null?e.Ud:i.getDocumentPoint(Spot.Center)}}computeShortLength(t){if(t){let i=this.fromShortLength;if(isNaN(i)){const e=this.fromPort;e!==null&&(i=e.fromShortLength)}return isNaN(i)?0:i}else{let i=this.toShortLength;if(isNaN(i)){const e=this.toPort;e!==null&&(i=e.toShortLength)}return isNaN(i)?0:i}}Om(t,i,e,s,n,o){if(this.pickable===!1)return!1;i===void 0&&(i=null),e===void 0&&(e=null);let r=o;if(o===void 0&&(r=Transform.l(),r.Ri()),r.tc(this.D),this.containedInRect(t,r))return this.R2(i,e,n),o===void 0&&Transform.s(r),!0;if(this.intersectsRect(t,r)){let l=!1;if(!this.hf){const h=this.L.r,a=h.length;for(let c=a;c--;){const f=h[c];if(!f.visible&&f!==this.locationObject)continue;const u=f.actualBounds,d=this.naturalBounds;if(u.x>d.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;const m=f,g=Transform.l();if(g.set(r),m instanceof Panel?l=m.Om(t,i,e,s,n,g):this.path===m?m instanceof Shape&&(l=m.kv(t,s,g)):l=m._L(t,s,g),l){let p=m;i!==null&&(p=i(m)),p&&(e===null||e(p))&&n.add(p)}Transform.s(g)}}return o===void 0&&Transform.s(r),l||this.background!==null}return o===void 0&&Transform.s(r),!1}get isOrthogonal(){return(this.Ta&2)===2}static oN(t){return(t&2)===2}get isAvoiding(){return(this.Ta&4)===4}computeCurve(){if(this.$o===null){const t=this.fromPort,i=t!==null&&t===this.toPort,e=this.isOrthogonal;this.$o=i&&!e}return this.$o?9:this.curve}computeCorner(){if(this.curve===9)return 0;let t=this.corner;return(isNaN(t)||t<0)&&(t=10),t}findMidLabel(){const t=this.path,i=this.L.r,e=i.length;for(let n=0;n0?g-=f:g+=f;else{const p=-h/a;let y=Math.sqrt(f*f/(p*p+1));c<0&&(y=-y),m=(a<0?-1:1)*y+u,g=p*(m-u)+d}this.addPoint(r),this.addPointAt(m,g),this.addPoint(l)}else{this.addPoint(r),this.addPoint(l);const h=Rect.l();i.getDocumentBounds(h);const a=h.containsPoint(l);n.getDocumentBounds(h);const c=h.containsPoint(r);if(a||c){const f=i.getDocumentPoint(this.p1(e,!0),new Point);this.setPoint(0,this.getLinkPointFromPoint(t,i,f,l,!0,f));const u=n.getDocumentPoint(this.p1(o,!1),new Point);this.setPoint(1,this.getLinkPointFromPoint(s,n,u,r,!1,u))}Rect.s(h)}}Wv(t,i,e,s,n,o){const r=this.getLinkPoint(t,i,e,!0,!1,s,n),l=this.getLinkPoint(s,n,o,!1,!1,t,i),h=l.x-r.x,a=l.y-r.y,c=this.computeCurviness();let f=0,u=0,d=r.x+h/3,m=r.y+a/3,g=d,p=m;Geo.u(a,0)?h>0?p-=c:p+=c:(f=-h/a,u=Math.sqrt(c*c/(f*f+1)),c<0&&(u=-u),g=(a<0?-1:1)*u+d,p=f*(g-d)+m),d=r.x+2*h/3,m=r.y+2*a/3;let y=d,x=m;Geo.u(a,0)?h>0?x-=c:x+=c:(y=(a<0?-1:1)*u+d,x=f*(y-d)+m),this.clearPoints(),this.addPoint(r),this.addPointAt(g,p),this.addPointAt(y,x),this.addPoint(l),this.setPoint(0,this.getLinkPoint(t,i,e,!0,!1,s,n)),this.setPoint(3,this.getLinkPoint(s,n,o,!1,!1,t,i))}adjustPoints(t,i,e,s){let n=this.computeAdjusting();if(this.isOrthogonal){if(n===18)return!1;n===19&&(n=17)}switch(n){case 18:return this.tO(t,i,e,s);case 19:return this.iO(t,i,e,s);case 17:return this.eO(t,i,e,s);default:return!1}}tO(t,i,e,s){const n=this.getPoint(t),o=this.getPoint(e);if(n.equalsApprox(i)&&o.equalsApprox(s))return!0;const r=n.x,l=n.y,h=o.x,a=o.y;let c=h-r,f=a-l;const u=Math.sqrt(c*c+f*f);if(Geo.K(u,0))return!0;let d=0;Geo.K(c,0)?f<0?d=-Math.PI/2:d=Math.PI/2:(d=Math.atan(f/Math.abs(c)),c<0&&(d=Math.PI-d));const m=i.x,g=i.y,p=s.x,y=s.y,x=p-m,k=y-g,b=Math.sqrt(x*x+k*k);let P=0;Geo.K(x,0)?k<0?P=-Math.PI/2:P=Math.PI/2:(P=Math.atan(k/Math.abs(x)),x<0&&(P=Math.PI-P));const M=b/u,L=P-d;this.setPoint(t,i);for(let C=t+1;C0&&(C=-C);const S=f+P*(d-f),N=u+P*(m-u);if(g!==0){const T=S+C/p,A=N-(T-S)/g;this.setPointAt(y,T,A)}else this.setPointAt(y,S,N+C)}return this.setPoint(e,s),!0}eO(t,i,e,s){if(this.isOrthogonal){let n=this.getPoint(t),o=this.getPoint(t+1),r=this.getPoint(t+2),l=o.x,h=o.y;const a=l,c=h;Geo.u(n.y,o.y)?Geo.u(o.x,r.x)?h=i.y:Geo.u(o.y,r.y)&&(l=i.x):Geo.u(n.x,o.x)&&(Geo.u(o.y,r.y)?l=i.x:Geo.u(o.x,r.x)&&(h=i.y)),this.setPointAt(t+1,l,h),n=this.getPoint(e),o=this.getPoint(e-1),r=this.getPoint(e-2);let f=o.x,u=o.y;const d=f,m=u;if(Geo.u(n.y,o.y)?Geo.u(o.x,r.x)?u=s.y:Geo.u(o.y,r.y)&&(f=s.x):Geo.u(n.x,o.x)&&(Geo.u(o.y,r.y)?f=s.x:Geo.u(o.x,r.x)&&(u=s.y)),this.setPointAt(e-1,f,u),this.TL())return this.setPointAt(t+1,a,c),this.setPointAt(e-1,d,m),!1}return this.setPoint(t,i),this.setPoint(e,s),!0}addOrthoPoints(t,i,e,s,n,o){i<0?i+=360:i>=360&&(i-=360),s<0?s+=360:s>=360&&(s-=360);const c=s;i>=315||i<45?i=0:45<=i&&i<135?i=90:135<=i&&i<225?i=180:i=270,s>=315||s<45?s=0:45<=s&&s<135?s=90:135<=s&&s<225?s=180:s=270;const f=t,u=e,d=n.actualBounds.copy(),m=o.actualBounds.copy();if(!d.isReal()||!m.isReal())return;d.inflate(Link.Ra,Link.Ra),m.inflate(Link.Ra,Link.Ra),d.unionPoint(t),m.unionPoint(e);const g=Point.l(),p=Point.l();i===0?u.x>f.x||s===270&&u.yf.x||s===90&&u.y>f.y&&m.right>f.x?(g.e(u.x,f.y),p.e(u.x,(f.y+u.y)/2),s===180?(g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1),p.x=g.x,p.y=u.y):s===270&&u.yf.y?(f.xm.bottom)?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):g.x=m.right,p.x=g.x,p.y=u.y):s===0&&f.xm.top&&f.yd.bottom)&&(s===180&&(m.containsPoint(f)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):u.yf.y&&(s===180||s===270)&&(g.y=this.computeMidOrthoPosition(f.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=d.left&&u.x<=f.x||f.x<=m.right&&f.x>=u.x?(s===90||s===270)&&(g.e(Math.max((f.x+u.x)/2,f.x),f.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yf.y&&m.leftf.y?(f.x>m.right?g.x=this.computeMidOrthoPosition(f.x,f.y,m.right,u.y,!1):f.x>m.left&&(s===270&&f.ym.bottom)?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):g.x=m.left,p.x=g.x,p.y=u.y):s===180&&f.x>m.right&&f.y>m.top&&f.yd.bottom)&&(s===0&&(m.containsPoint(f)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):u.yf.y&&(s===0||s===270)&&(g.y=this.computeMidOrthoPosition(f.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=f.x||f.x>=m.left&&f.x<=u.x?(s===90||s===270)&&(g.e(Math.min((f.x+u.x)/2,f.x),f.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yf.y||s===180&&u.xf.y||s===0&&u.x>f.x&&m.bottom>f.y?(g.e(f.x,u.y),p.e((f.x+u.x)/2,u.y),s===270?(g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0),p.x=u.x,p.y=g.y):s===180&&u.xf.x?(f.ym.right)?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):g.y=m.bottom,p.x=u.x,p.y=g.y):s===90&&f.ym.left&&f.xd.right)&&(s===270&&(m.containsPoint(f)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):u.xf.x&&(s===270||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,f.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=d.top&&u.y<=f.y||f.y<=m.bottom&&f.y>=u.y?(s===0||s===180)&&(g.e(f.x,Math.max((f.y+u.y)/2,f.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.xf.x&&m.top=f.x?(f.y>m.bottom?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,m.bottom,!0):f.y>m.top&&(s===180&&f.xm.right)?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):g.y=m.top,p.x=u.x,p.y=g.y):s===270&&f.y>m.bottom&&f.x>m.left&&f.xd.right)&&(s===90&&(m.containsPoint(f)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):u.xf.x&&(s===90||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,f.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=f.y||f.y>=m.top&&f.y<=u.y?(s===0||s===180)&&(g.e(f.x,Math.min((f.y+u.y)/2,f.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.x=3&&!Geo.K(this.smoothness,0))if(i===3){let c=this.getPoint(1);n=Math.min(r.x,c.x),o=Math.min(r.y,c.y),c=this.getPoint(2),n=Math.min(n,c.x),o=Math.min(o,c.y)}else if(this.isOrthogonal){for(let c=0;c=i&&(c=i-1);const f=this.getPoint(c);l.x=Math.min(f.x,l.x),l.y=Math.min(f.y,l.y)}n=l.x,o=l.y}else{for(let c=0;c=3&&!Geo.K(this.smoothness,0))if(i===3){const f=this.getPoint(1),u=f.x-n,d=f.y-o;let m=this.getPoint(2).copy();m.x-=n,m.y-=o,this.computeShortLength(!1)!==0&&(m=this.Sf(m,!1,l)),c.dr(u,d,u,d,m.x,m.y)}else if(this.isOrthogonal){const f=Point.X(n,o),u=Point.l();u.a(this.getPoint(1));const d=Point.X(n,o),m=Point.X(n,o);let g=this.getPoint(0),p=null;const y=this.smoothness/3;for(let P=1;P=i&&(f=i-1);const d=this.getPoint(f-1);let m=this.getPoint(f);f===i-1&&this.computeShortLength(!1)!==0&&(m=this.Sf(m.copy(),!1,Point.Po)),c.dr(u.x-n,u.y-o,d.x-n,d.y-o,m.x-n,m.y-o)}else{const f=Point.l();f.a(this.getPoint(0));const u=Point.l();u.a(f);const d=this.computeCorner();let m=1,g=0;for(;m1);let p=this.getPoint(m);if(m>=i-1){if(!f.equals(p))this.computeShortLength(!1)!==0&&(p=this.Sf(p.copy(),!1,Point.Po)),this.Nn(c,-n,-o,f,p,e);else if(g===0)for(m=1;mr?f>a?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):f>a?(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.K(r,h)&&Geo.K(a,f)&&(a>l?c>h?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):c>h?(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.K(r,h)&&Geo.K(h,c)||Geo.K(l,a)&&Geo.K(a,f)){const m=.5*(r+c),g=.5*(l+f);n.x=m,n.y=g,o.x=m,o.y=g}}Sf(t,i,e){const s=this.pointsCount;if(s<2)return t;if(i){const n=this.getPoint(1),o=n.x-e.x,r=n.y-e.y,l=this.b1(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!0);a>h&&(a=h);const c=a*(o-t.x)/l,f=a*(r-t.y)/l;t.x+=c,t.y+=f}else{const n=this.getPoint(s-2),o=n.x-e.x,r=n.y-e.y,l=this.b1(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!1);a>h&&(a=h);const c=a*(t.x-o)/l,f=a*(t.y-r)/l;t.x-=c,t.y-=f}return t}aN(t,i,e){const s=this.pointsCount;let n=t;for(;Geo.K(t.x,n.x)&&Geo.K(t.y,n.y);){if(i>=s)return s-1;n=this.getPoint(i++)}if(!Geo.K(t.x,n.x)&&!Geo.K(t.y,n.y))return i-1;let o=n;for(;Geo.K(t.x,n.x)&&Geo.K(n.x,o.x)&&(!e||(t.y>=n.y?n.y>=o.y:n.y<=o.y))||Geo.K(t.y,n.y)&&Geo.K(n.y,o.y)&&(!e||(t.x>=n.x?n.x>=o.x:n.x<=o.x));){if(i>=s)return s-1;o=this.getPoint(i++)}return i-2}oO(t,i,e,s,n,o,r,l,h,a){if(Geo.u(s.y,n.y)&&Geo.u(n.x,o.x)){let c=Math.min(h,Math.abs(n.x-l.x)/2);const f=Math.min(c,Math.abs(o.y-n.y)/2);if(c=f,Geo.u(c,0)){this.Nn(t,i,e,s,n,a),r.a(n);return}let u=n.x;const d=n.y,m=u;let g=d;n.x>s.x?(u=n.x-c,o.y>n.y?g=n.y+f:g=n.y-f):(u=n.x+c,o.y>n.y?g=n.y+f:g=n.y-f);const p=Point.X(u,d);this.Nn(t,i,e,s,p,a),Point.s(p),t.Sw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else if(Geo.u(s.x,n.x)&&Geo.u(n.y,o.y)){let c=Math.min(h,Math.abs(n.y-l.y)/2);const f=Math.min(c,Math.abs(o.x-n.x)/2);if(c=f,Geo.u(f,0)){this.Nn(t,i,e,s,n,a),r.a(n);return}const u=n.x;let d=n.y,m=u;const g=d;n.y>s.y?(d=n.y-c,o.x>n.x?m=n.x+f:m=n.x-f):(d=n.y+c,o.x>n.x?m=n.x+f:m=n.x-f);const p=Point.X(u,d);this.Nn(t,i,e,s,p,a),Point.s(p),t.Sw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else this.Nn(t,i,e,s,n,a),r.a(n)}computeJumpLength(){return 10}Nn(t,i,e,s,n,o){if(o||!this.va())t.ur(n.x+i,n.y+e);else{const r=this.computeJumpLength(),l=r/2,h=[];let a=0;this.isVisible()&&(a=this.rO(s,n,h));let c=s.x,f=s.y;if(a>0){if(Geo.u(s.y,n.y))if(s.x=0;){const d=Math.min(s.x,Math.max(h[u--]+l,n.x+r));t.ur(d+i,n.y+e),c=d+i,f=n.y+e;let m=Math.max(d-r,n.x);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.x);else break}const g=n.y-r+e,p=m+i,y=n.y+e;this.curve===10?t.uu(p,y,!1,!1):t.dr(c,g,p,g,p,y),c=p,f=y}}else if(Geo.u(s.x,n.x))if(s.y=0;){const d=Math.min(s.y,Math.max(h[u--]+l,n.y+r));t.ur(n.x+i,d+e),c=n.x+i,f=d+e;let m=Math.max(d-r,n.y);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.y);else break}const g=n.x-r+i,p=n.x+i,y=m+e;this.curve===10?t.uu(p,y,!1,!1):t.dr(g,f,g,y,p,y),c=p,f=y}}}t.ur(n.x+i,n.y+e)}}rO(t,i,e){const s=this.diagram;if(s===null||t.equals(i))return 0;const n=s.layers;for(;n.next();){const o=n.value;if(o!==null&&o.visible){const r=o.EM(),l=r.length;for(let h=0;h0&&e.sort((u,d)=>u-d),e.length;if(!a.isVisible()||!a.va())continue;const c=a.routeBounds;if(!c.isReal()||!this.routeBounds.intersectsRect(c)||this.usesSamePort(a))continue;const f=a.path;f!==null&&f.isVisibleObject()&&this.lO(t,i,e,a)}}}return e.length>0&&e.sort((o,r)=>o-r),e.length}lO(t,i,e,s){const n=Geo.u(t.y,i.y),o=s.pointsCount;let r=s.getPoint(0);const l=Point.l();for(let h=1;hr.x&&c.x>=a.x||a.xr.y&&c.y>=a.y||a.yc&&Math.min(a,f)o&&!Geo.u(a,f))return n.x=o,n.y=c,!0}else if(Geo.u(r,h)&&Geo.u(a,f)&&Math.min(o,l)a&&Math.min(c,u)r&&!Geo.u(c,u))return n.x=a,n.y=r,!0;return n.x=0,n.y=0,!1}get firstPickIndex(){return this.pointsCount<=2?0:this.isOrthogonal||!this.Ed(this.computeSpot(!0))?1:0}get lastPickIndex(){const t=this.pointsCount;return t===0?0:t<=2?t-1:this.isOrthogonal||!this.Ed(this.computeSpot(!1))?t-2:t-1}va(){const t=this.curve;return t===11||t===10}g1(t){if(t||this.va()){const i=this.diagram;i!==null&&!i.animationManager.isTicking&&!i.$l.has(this)&&(this.Pf.width!==0||this.Pf.height!==0)&&i.$l.set(this,this.Pf.copy())}}invalidateOtherJumpOvers(t){const i=this.layer;if(i===null||!i.visible||i.isTemporary)return;const e=i.diagram;if(e===null||e.animationManager.isTicking)return;let s=!1;const n=e.layers;for(;n.next();){const o=n.value;if(o.visible){if(o===i){s=!0;let r=!1;const l=o.EM(),h=l.length;for(let a=0;a0&&e>0){const s=this.getPoint(0),n=t.getPoint(0);if(s.equalsApprox(n))return!0;const o=this.getPoint(i-1),r=t.getPoint(e-1);if(o.equalsApprox(r)||s.equalsApprox(r)||o.equalsApprox(n))return!0}else if(this.fromNode===t.fromNode||this.toNode===t.toNode||this.fromNode===t.toNode||this.toNode===t.fromNode)return!0;return!1}isVisible(){if(!super.isVisible())return!1;const t=this.containingGroup;let i=!0;const e=this.diagram;e!==null&&(i=e.isTreePathToChildren);const s=this.fromNode;if(s!==null){if(this.isTreeLink&&i&&!s.isTreeExpanded)return!1;if(s===t)return!0;let o=s;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=s.findVisibleNode();if(r===null||r===t)return!1}const n=this.toNode;if(n!==null){if(this.isTreeLink&&!i&&!n.isTreeExpanded)return!1;if(n===t)return!0;let o=n;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=n.findVisibleNode();if(r===null||r===t)return!1}return!0}Ei(t){if(super.Ei(t),t&&this.g1(!1),this.Zo!==null&&this.Zo.Td(),this.Hs!==null){const e=this.Hs.iterator;for(;e.next();)e.value.Ei(t)}}get adjusting(){return this.kf}set adjusting(t){const i=this.kf;i!==t&&(this.kf=t,this.t("adjusting",i,t))}computeAdjusting(){return this.isAvoiding&&this.diagram!==null&&this.diagram.animationManager.defaultAnimation.isAnimating?17:this.kf}get corner(){return this.Rd}set corner(t){const i=this.Rd;i!==t&&(this.Rd=t,this.ie(),this.t("corner",i,t))}get curve(){return this.vd}set curve(t){const i=this.vd;i!==t&&(this.vd=t,this.invalidateRoute(),this.ie(),this.g1(i===10||i===11||t===10||t===11),this.t("curve",i,t))}get curviness(){return this.Od}set curviness(t){const i=this.Od;i!==t&&(this.Od=t,this.invalidateRoute(),this.ie(),this.t("curviness",i,t))}get routing(){return this.Ta}set routing(t){const i=this.Ta;i!==t&&(this.Ta=t,this.isAvoiding&&this.diagram!==null&&(this.diagram.Gm=!0),this.$o=null,this.invalidateRoute(),this.g1(Link.oN(i)||Link.oN(t)),this.t("routing",i,t))}get smoothness(){return this.Id}set smoothness(t){const i=this.Id;i!==t&&(this.Id=t,this.ie(),this.t("smoothness",i,t))}wy(){const t=this.lo;if(t===null)return;const i=this.ao;if(i===null||!isNaN(this.curviness))return;const e=this.ho,s=this.co;let n=null,o=null;const r=t._t.r,l=r.length;for(let h=0;h=0&&(Util._a(t.qs,i),t.Td())}}Cl(){return!0}get key(){const t=this.diagram;if(!(t===null||!t.model.Aa()))return t.model.getKeyForLinkData(this.data)}}class LinkBundle{Eo;Os;ry;Z2;h1;Q2;qs;constructor(t,i,e,s){GSet.Yi(this),this.Eo=!1,this.Os=!1,this.ry=t,this.Z2=i,this.h1=e,this.Q2=s,this.qs=[]}Td(){if(!this.Eo){const t=this.qs;if(t.length>0){const i=t[0].diagram;i!==null&&(i.lS.add(this),this.Os=i.undoManager.isUndoingRedoing)}}this.Eo=!0}bS(){if(this.Eo){this.Eo=!1;const t=this.qs;if(t.length>0){const i=t[0],e=i.diagram,s=e===null||e.Eh&&!this.Os;this.Os=!1,i.arrangeBundledLinks(t,s),t.length===1&&(i.Zo=null,t.length=0)}t.length===0&&(this.ry.JA(this),this.h1.JA(this))}}}class PositionArray{ne;oe;Oa;Ia;pi;yi;Ot;wh;xh;la;RS;Eo;by;Yc;vS;OS;constructor(t){GSet.Yi(this),this.la=null,this.RS=null,this.Eo=!0,this.by=!1,this.ne=1,this.oe=1,this.Oa=-1,this.Ia=-1,this.pi=t.width,this.yi=t.height,this.Ot=null,this.wh=0,this.xh=0,this.Yc=11,this.vS=this.Yc*2,this.OS=this.Yc*2}static Ws=0;static Ea=1;static Bd=999999;static cN=PositionArray.Bd+1;static fN=PositionArray.Bd+2;kb(t){if(t.width<=0||t.height<=0)return;const i=t.x,e=t.y,s=t.x+t.width,n=t.y+t.height;this.ne=Math.floor((i-this.pi)/this.pi)*this.pi,this.oe=Math.floor((e-this.yi)/this.yi)*this.yi,this.Oa=Math.ceil((s+2*this.pi)/this.pi)*this.pi,this.Ia=Math.ceil((n+2*this.yi)/this.yi)*this.yi;const o=1+(Math.ceil((this.Oa-this.ne)/this.pi)|0),r=1+(Math.ceil((this.Ia-this.oe)/this.yi)|0);if(this.Ot===null||this.wh0&&t!==this.pi&&(this.pi=t,this.kb(this.bounds))}get cellHeight(){return this.yi}set cellHeight(t){t>0&&t!==this.yi&&(this.yi=t,this.kb(this.bounds))}Vd(t,i){return this.ne<=t&&t<=this.Oa&&this.oe<=i&&i<=this.Ia}fo(t,i){if(!this.Vd(t,i))return PositionArray.cN;t-=this.ne,t/=this.pi,i-=this.oe,i/=this.yi;const e=t|0,s=i|0;return this.Ot[e][s]}wR(t,i,e,s){if(!this.Vd(t,i))return;const n=(t-this.ne)/this.pi|0,o=(i-this.oe)/this.yi|0,r=(t+e-this.ne)/this.pi|0,l=(i+s-this.oe)/this.yi|0,h=Math.min(r,this.wh),a=Math.min(l,this.xh);for(let c=n;c<=h;c++){const f=this.Ot[c];if(f.fill)f.fill(PositionArray.Ws,o,a+1);else for(let u=o;u<=a;u++)f[u]=PositionArray.Ws}}aO(t){if(this.Ot!==null)for(let i=0;i<=this.wh;i++){const e=this.Ot[i];if(e.fill)e.fill(t);else for(let s=0;s<=this.xh;s++)e[s]=t}}XL(){if(this.Ot!==null)for(let t=0;t<=this.wh;t++){const i=this.Ot[t];for(let e=0;e<=this.xh;e++)i[e]>=PositionArray.Ea&&(i[e]=PositionArray.cN)}}cO(t,i){return this.fo(t,i)===PositionArray.Ws}isUnoccupied(t,i,e,s){if(t>this.Oa||t+ethis.Ia||i+sthis.Oa||ithis.Ia||ethis.Ia||ithis.Oa||e=PositionArray.Ea&&h=a)break;this.Ot[t][i]=h,h+=1,s?i+=e:t+=e}return s?i:t}uo(t,i,e,s,n,o,r,l){if(to||il)return;const h=this.fO(t,i,e,s,n,o,r,l);if(s)if(e>0)for(let a=i+e;ah;a+=e)this.uo(t,a,1,!s,n,o,r,l),this.uo(t,a,-1,!s,n,o,r,l);else if(e>0)for(let a=t+e;ah;a+=e)this.uo(a,i,1,!s,n,o,r,l),this.uo(a,i,-1,!s,n,o,r,l)}k1(t,i,e,s,n,o,r,l,h,a){let c=t|0,f=i|0,u=PositionArray.Ws,d=PositionArray.Ea;for(this.Ot[c][f]=d;u===PositionArray.Ws&&c>r&&ch&&fr&&ch&&f=0;v-=2){F=A[v+2],R=A[v+3];const O=A[v],U=A[v+1];for(;O>F?F++:OR?R++:Us)d--;else break;else if(m>n)m--;else break;const g=c[d][m];if(g===0||g===PositionArray.fN)break;f=d,u=m}for(;;){let d=e,m=f,g=u;e===0?gn&&(d=270,g--):e===90?ms&&(d=180,m--):e===180?gn&&(d=270,g--):ms&&(d=180,m--);const p=c[m][g];if(d!==e&&p!==0&&p!==PositionArray.fN){if(o.push(f),o.push(u),this.lT(f,u,d,s,n,o))return!0;o.pop(),o.pop()}if(c[f][u]=PositionArray.fN,e===0){if(f===t)return!1;f--}else if(e===90){if(u===i)return!1;u--}else if(e===180){if(f===t)return!1;f++}else{if(u===i)return!1;u++}}}}class Knot{ue;Qo;rs;zd;constructor(){GSet.Yi(this),this.ue=null,this.Qo=null,this.rs=[],this.zd=!1}toString(){const t=this.rs;let i=this.ue.toString()+" "+t.length.toString()+":";for(let e=0;e180?270:90;case 6:return o>90&&o<=270?180:0}const r=Math.atan2(t.height,t.width)*180/Math.PI;switch(n){case 3:return o>r&&o<=180+r?180:270;case 5:return o>180-r&&o<=360-r?270:0;case 12:return o>r&&o<=180+r?90:0;case 10:return o>180-r&&o<=360-r?180:90;case 7:return o>90&&o<=180+r?180:o>180+r&&o<=360-r?270:0;case 13:return o>180&&o<=360-r?270:o>r&&o<=180?90:0;case 14:return o>r&&o<=180-r?90:o>180-r&&o<=270?180:0;case 11:return o>180-r&&o<=180+r?180:o>180+r?270:90}return s&&n!==15&&(o-=15,o<0&&(o+=360)),o>r&&o<180-r?90:o>=180-r&&o<=180+r?180:o>180+r&&o<360-r?270:0}Td(){this.rs.length=0}nT(t){let i=this.rs;i.length===0&&(this.dO(),i=this.rs);for(let e=0;e=360&&(M-=360);const L=this.uO(h,y,M,g.isOrthogonal);let C=0;L===0?(C=4,M>180&&(M-=360)):L===90?(C=8,M>270&&(M-=360)):L===180?C=2:(C=1,M<90&&(M+=360));let S=this.rs[o];S===void 0?(S=new LinkInfo(g,M,C),this.rs[o]=S):(S.He=g,S.Xt=M,S.me=C),S.M1.set(P),o++}Point.s(a),this.gO();const u=this.rs.length;let d=-1,m=0;for(o=0;o=0;o--){const g=this.rs[o];g!==void 0&&(g.me!==d&&(d=g.me,m=g.Xd+1),g.Mf=m)}this.mO(this.rs),this.pO(this.rs),this.zd=t,Rect.s(h)}return this.rs}yO(t,i){return t===i?0:t===null?-1:i===null?1:t.mei.me?1:t.Xti.Xt?1:0}gO(){this.rs.sort(Knot.prototype.yO)}mO(t){const i=this.Qo,e=this.ue.portSpreading,s=Point.l(),n=Point.l(),o=Point.l(),r=Point.l();i.getDocumentPoint(Spot.TopLeft,s),i.getDocumentPoint(Spot.TopRight,n),i.getDocumentPoint(Spot.BottomRight,o),i.getDocumentPoint(Spot.BottomLeft,r);let l=0,h=0,a=0,c=0;if(e===2)for(let x=0;xMath.abs(p)?(d=Math.abs(p)/a,a=Math.abs(p)):d=1;break;case 2:c>Math.abs(y)?(d=Math.abs(y)/c,c=Math.abs(y)):d=1;break;case 1:l>Math.abs(p)?(d=Math.abs(p)/l,l=Math.abs(p)):d=1;break;default:case 4:h>Math.abs(y)?(d=Math.abs(y)/h,h=Math.abs(y)):d=1;break}u=0}const b=k.Ud;if(e===2){let P=k.He.computeThickness();switch(P*=d,b.set(m),f){case 8:b.x=m.x+p/2+a/2-u-P/2;break;case 2:b.y=m.y+y/2+c/2-u-P/2;break;case 1:b.x=m.x+p/2-l/2+u+P/2;break;default:case 4:b.y=m.y+y/2-h/2+u+P/2;break}u+=P}else{let P=.5;e===1&&(P=(k.Xd+1)/(k.Mf+1)),b.x=m.x+p*P,b.y=m.y+y*P}}Point.s(s),Point.s(n),Point.s(o),Point.s(r)}pO(t){for(let i=0;ie instanceof Placeholder);i instanceof Placeholder?t.It=i:t.It=null,this.te!==null?(t.te=this.te.copy(),t.te.group=t):(t.te!==null&&(t.te.group=null),t.te=null),this.si!==null&&(t.si=this.si.copy())}Vo(t){super.Vo(t);const i=t.findSubGraphParts(),e=t.memberParts;for(;e.next();){const s=e.value;if(s.c(),s.invalidateLayout(8),s.clearAdornments(),s instanceof Node)s.invalidateConnectedLinks(i);else if(s instanceof Link){const n=s.labelNodes;for(;n.next();)n.value.invalidateConnectedLinks(i)}}}Wc(t,i,e,s,n,o,r){if(t===3&&i==="elements"){if(n instanceof Placeholder)this.It===null?this.It=n:this.It!==n&&Util.o("Cannot insert a second Placeholder into the visual tree of a Group.");else if(n instanceof Panel){const l=n.findInVisualTree(h=>h instanceof Placeholder);l instanceof Placeholder&&(this.It===null?this.It=l:this.It!==l&&Util.o("Cannot insert a second Placeholder into the visual tree of a Group."))}}else t===4&&i==="elements"&&this.It!==null&&(s===this.It?this.It=null:s instanceof Panel&&this.It.isContainedBy(s)&&(this.It=null));super.Wc(t,i,e,s,n,o,r)}ed(t,i){if(super.ed(t,i),this.isClipping&&this.type!==Panel.Spot&&this.isSubGraphExpanded){let e=this.resizeObject;e instanceof Panel&&(e=e.findMainElement()),this.si===null&&(this.si=new Rect),e.getDocumentBounds(this.si),e instanceof Shape&&this.si.inflate(-e.strokeWidth,-e.strokeWidth)}}hh(t,i,e,s){this.hasPlaceholder()&&(this.Jo=this.placeholder),super.hh(t,i,e,s)}ensureBounds(){this.isSubGraphExpanded&&this.memberParts.each(i=>{i.ensureBounds()}),super.ensureBounds()}Hr(){if(!super.Hr())return!1;const t=this.memberParts;for(;t.next();){const i=t.value;if(i instanceof Node){if(!i.isVisible())continue;if(i.is())return!1}else if(i instanceof Link){if(!i.isVisible())continue;if(i.is()&&i.fromNode!==this&&i.toNode!==this)return!1}}return!0}hasPlaceholder(){return this.It!==null&&this.It.isVisibleObject()&&this.isSubGraphExpanded}get placeholder(){return this.It}get computesBoundsAfterDrag(){return(this.E&2048)!==0}set computesBoundsAfterDrag(t){const i=(this.E&2048)!==0;i!==t&&(Util.i(t,"boolean",Group,"computesBoundsAfterDrag"),this.E=this.E^2048,this.t("computesBoundsAfterDrag",i,t))}get computesBoundsIncludingLinks(){return(this.E&4096)!==0}set computesBoundsIncludingLinks(t){Util.i(t,"boolean",Group,"computesBoundsIncludingLinks");const i=(this.E&4096)!==0;i!==t&&(this.E=this.E^4096,this.t("computesBoundsIncludingLinks",i,t))}get computesBoundsIncludingLocation(){return(this.E&8192)!==0}set computesBoundsIncludingLocation(t){Util.i(t,"boolean",Group,"computesBoundsIncludingLocation");const i=(this.E&8192)!==0;i!==t&&(this.E=this.E^8192,this.t("computesBoundsIncludingLocation",i,t))}get handlesDragDropForMembers(){return(this.E&16384)!==0}set handlesDragDropForMembers(t){Util.i(t,"boolean",Group,"handlesDragDropForMembers");const i=(this.E&16384)!==0;i!==t&&(this.E=this.E^16384,this.t("handlesDragDropForMembers",i,t))}get avoidableMembers(){return(this.E&131072)!==0}set avoidableMembers(t){Util.i(t,"boolean",Group,"avoidableMembers");const i=(this.E&131072)!==0;i!==t&&(this.E=this.E^131072,this.t("avoidableMembers",i,t))}get memberParts(){return this.Kd.iterator}q2(t){if(this.Kd.add(t)){t instanceof Group&&this.ra.add(t);const e=this.memberAdded;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.Y,n.Y=!0),e(this,t),n!==null&&(n.Y=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ei(!1)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.It;i===null&&(i=this),i.c()}H2(t){if(this.Kd.delete(t)){t instanceof Group&&this.ra.delete(t);const e=this.memberRemoved;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.Y,n.Y=!0),e(this,t),n!==null&&(n.Y=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ei(!0)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.It;i===null&&(i=this),i.c()}Xc(){if(this.Kd.count>0){const t=this.diagram;if(t!==null){const e=this.Kd.copy().iterator;for(;e.next();){const s=e.value;t.remove(s)}}}super.Xc()}get layout(){return this.te}set layout(t){const i=this.te;if(i!==t){t!==null&&t.diagram!==null&&t.diagram.layout===t&&Util.o("A layout cannot be both the Diagram.layout and a Group.layout: "+t),i!==null&&(i.diagram=null,i.group=null),this.te=t;const e=this.diagram;t!==null&&(t.diagram=e,t.group=this),e!==null&&(e.Kr=!0),this.t("layout",i,t),e!==null&&e.requestUpdate()}}get memberAdded(){return this.gt!==null?this.gt.uy:null}set memberAdded(t){const i=this.memberAdded;i!==t&&(t!==null&&Util.i(t,"function",Group,"memberAdded"),this.cl(),this.gt.uy=t,this.t("memberAdded",i,t))}get memberRemoved(){return this.gt!==null?this.gt.gy:null}set memberRemoved(t){const i=this.memberRemoved;i!==t&&(t!==null&&Util.i(t,"function",Group,"memberRemoved"),this.cl(),this.gt.gy=t,this.t("memberRemoved",i,t))}get memberValidation(){return this.gt!==null?this.gt.eh:null}set memberValidation(t){const i=this.memberValidation;i!==t&&(t!==null&&Util.i(t,"function",Group,"memberValidation"),this.cl(),this.gt.eh=t,this.t("memberValidation",i,t))}canAddMembers(t){const i=this.diagram;if(i===null)return!1;const e=i.commandHandler,n=e.i2(t).iterator;for(;n.next();){const o=n.value;if(!e.isValidMember(this,o))return!1}return!0}addMembers(t,i){const e=this.diagram;if(e===null)return!1;const s=e.commandHandler,n=s.i2(t);let o=!0;const r=n.iterator;for(;r.next();){const l=r.value;!i||s.isValidMember(this,l)?l.containingGroup=this:o=!1}return o}get ungroupable(){return(this.E&256)!==0}set ungroupable(t){const i=(this.E&256)!==0;i!==t&&(Util.i(t,"boolean",Group,"ungroupable"),this.E=this.E^256,this.t("ungroupable",i,t))}canUngroup(){if(!this.ungroupable)return!1;const t=this.layer;if(t===null||!t.allowUngroup)return!1;const i=t.diagram;return!(i!==null&&!i.allowUngroup)}invalidateConnectedLinks(t){const i=this.xO();if(super.invalidateConnectedLinks(t),i)return;this.PL(!0);const e=this.findExternalLinksConnected();for(;e.next();){const s=e.value;if(t!==void 0&&t.has(s))continue;const n=s.fromNode;if(n!==null&&n!==this&&n.isMemberOf(this)&&!n.isVisible())n.ge(s.fromPort),n.ge(s.toPort),s.invalidateRoute();else{const o=s.toNode;o!==null&&o!==this&&o.isMemberOf(this)&&!o.isVisible()&&(o.ge(s.fromPort),o.ge(s.toPort),s.invalidateRoute())}}}findExternalLinksConnected(){const t=this.diagram!==null&&this.diagram.dS;if(t&&this.d0!==null)return this.d0.iterator;const i=this.findSubGraphParts();i.add(this);const e=new GSet,s=i.iterator;for(;s.next();){const n=s.value;if(!(n instanceof Node))continue;const o=n.linksConnected;for(;o.next();){const r=o.value;i.has(r)||e.add(r)}}return t&&(this.d0=e),e.iterator}findExternalNodesConnected(){const t=this.findSubGraphParts();t.add(this);const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;if(!(s instanceof Node))continue;const n=s.linksConnected;for(;n.next();){const o=n.value,r=o.fromNode;r!==null&&(!t.has(r)||r===this)&&i.add(r);const l=o.toNode;l!==null&&(!t.has(l)||l===this)&&i.add(l)}}return i.iterator}pE(){function t(e,s){e!==null&&(s.add(e),t(e.containingGroup,s))}const i=new GSet;return t(this,i),i}findSubGraphParts(){const t=new GSet;return Part.sh(t,this,!0,0,!0),t.delete(this),t}Ei(t){super.Ei(t);const i=this.memberParts;for(;i.next();)i.value.Ei(t)}collapseSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.hT(i,t,this),t.isCollapsingExpanding=!1}hT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ei(!1),n instanceof Group&&n.isSubGraphExpanded&&(n.wasSubGraphExpanded=n.isSubGraphExpanded,n.hT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t),i.Cc(n,e);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!1}expandSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.aT(i,t,this),t.isCollapsingExpanding=!1}aT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ei(!0),n instanceof Group&&n.wasSubGraphExpanded&&(n.wasSubGraphExpanded=!1,n.aT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!0}get isSubGraphExpanded(){return(this.E&512)!==0}set isSubGraphExpanded(t){const i=(this.E&512)!==0;if(i!==t){Util.i(t,"boolean",Group,"isSubGraphExpanded"),this.E=this.E^512;const e=this.diagram;this.t("isSubGraphExpanded",i,t);const s=this.subGraphExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.Y,e.Y=!0),s(this),e!==null&&(e.Y=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.It!==null&&this.It.c(),this.memberParts.each(n=>n.updateAdornments());return}t?this.expandSubGraph():this.collapseSubGraph()}}get wasSubGraphExpanded(){return(this.E&1024)!==0}set wasSubGraphExpanded(t){const i=(this.E&1024)!==0;i!==t&&(Util.i(t,"boolean",Group,"wasSubGraphExpanded"),this.E=this.E^1024,this.t("wasSubGraphExpanded",i,t))}get subGraphExpandedChanged(){return this.gt!==null?this.gt.my:null}set subGraphExpandedChanged(t){const i=this.subGraphExpandedChanged;i!==t&&(t!==null&&Util.i(t,"function",Group,"subGraphExpandedChanged"),this.cl(),this.gt.my=t,this.t("subGraphExpandedChanged",i,t))}move(t,i){i===void 0&&(i=!1);const e=i?this.location:this.position,s=e.x,n=e.y,o=t.x,r=t.y;if((s===o||isNaN(s)&&isNaN(o))&&(n===r||isNaN(n)&&isNaN(r)))return;const l=o-(isNaN(s)?0:s),h=r-(isNaN(n)?0:n),a=Point.l();super.move(t,i);const c=new GSet,u=this.findSubGraphParts().iterator;for(;u.next();){const d=u.value;d instanceof Link&&(d.suspendsRouting&&c.add(d),!(!d.Se&&(d.fromNode===this||d.toNode===this))&&(d.suspendsRouting=!0))}for(u.reset();u.next();){const d=u.value;if(d.Cl()||d instanceof Node&&d.isLinkLabel)continue;const m=d.position,g=d.location;m.isReal()?(a.x=m.x+l,a.y=m.y+h,d.position=a):g.isReal()&&(a.x=g.x+l,a.y=g.y+h,d.location=a)}for(u.reset();u.next();){const d=u.value;if(!(d instanceof Link)||(d.suspendsRouting=c.has(d),!d.Se&&(d.fromNode===this||d.toNode===this)))continue;const m=d.position;a.x=m.x+l,a.y=m.y+h,a.isReal()?d.move(a):d.invalidateRoute()}Point.s(a)}xO(){return(this.E&65536)!==0}PL(t){(this.E&65536)!==0!==t&&(this.E=this.E^65536)}get Jr(){return(this.E&32768)!==0}set Jr(t){(this.E&32768)!==0!==t&&(this.E=this.E^32768)}}class Placeholder extends GraphObject{$t;Yd;constructor(t){super(),this.$t=Margin.Ug,this.Yd=new Rect(NaN,NaN,NaN,NaN),t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.$t=this.$t.N(),t.Yd=this.Yd.copy()}lh(t){if(this.background===null)return!1;const i=this.naturalBounds;return Rect.contains(0,0,i.width,i.height,t.x,t.y)}_u(t,i,e,s){const n=this.part;if((n===null||!(n instanceof Group)&&!(n instanceof Adornment))&&Util.o("Placeholder is not inside a Group or Adornment."),n instanceof Group){const o=this.computeBorder(this.Yd),r=this.minSize,l=isFinite(r.width)?Math.max(r.width,o.width):o.width,h=isFinite(r.height)?Math.max(r.height,o.height):o.height,a=this.Vi;a.En(l||0,h||0),this.Qn(0,0,a.width,a.height);const c=n.memberParts;let f=!1;for(;c.next();)if(c.value.isVisible()){f=!0;break}const u=n.diagram;if(f&&u!==null&&!u.animationManager.CM(n)&&!isNaN(o.x)&&!isNaN(o.y)){const d=Point.l();d.setRectSpot(o,n.locationSpot),n.location=d,Point.s(d)}}else{const o=n,r=this.Vi,l=this.$t,h=l.left+l.right,a=l.top+l.bottom,c=o.adornedObject,f=c.getDocumentAngle();o.angle=f;let u=0;c instanceof Shape&&(u=c.strokeWidth);const d=c.getDocumentScale(),m=c.naturalBounds,g=(m.width+u)*d,p=(m.height+u)*d;if(o.type!==Panel.Link){const y=o.category==="Selection"?Spot.TopLeft:o.locationSpot,x=c.getDocumentPoint(y,Point.l());o.location=x,Point.s(x)}if(!isNaN(g)&&!isNaN(p))r.En(g+h||0,p+a||0),this.Qn(-l.left,-l.top,r.width,r.height);else{const y=c.getDocumentPoint(Spot.TopLeft,Point.l()),x=Rect.X(y.x,y.y,0,0);x.unionPoint(c.getDocumentPoint(Spot.BottomRight,y)),x.unionPoint(c.getDocumentPoint(Spot.TopRight,y)),x.unionPoint(c.getDocumentPoint(Spot.BottomLeft,y)),r.En(x.width+h||0,x.height+a||0),this.Qn(-l.left,-l.top,r.width,r.height),Point.s(y),Rect.s(x)}}}hh(t,i,e,s){this.actualBounds.e(t,i,e,s)}computeBorder(t){const i=this.part,e=i.diagram,s=e===null||!e.animationManager.isAnimating;if(e!==null&&i instanceof Group&&!i.layer.isTemporary&&i.computesBoundsAfterDrag&&this.Yd.isReal()){const l=e.toolManager.findTool("Dragging");if(l===e.currentTool){const h=l.computeBorder(i,this.Yd,t);if(h!==null)return h}}const n=Rect.l(),o=this.computeMemberBounds(n),r=this.$t;return i instanceof Group&&!i.isSubGraphExpanded?t.e(o.x-r.left,o.y-r.top,0,0):t.e(o.x-r.left,o.y-r.top,Math.max(o.width+r.left+r.right,0),Math.max(o.height+r.top+r.bottom,0)),Rect.s(n),s&&i instanceof Group&&i.computesBoundsIncludingLocation&&i.location.isReal()&&t.unionPoint(i.location),t}computeMemberBounds(t){if(!(this.part instanceof Group))return t.e(0,0,0,0),t;const i=this.part;let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=i.memberParts;for(;r.next();){const l=r.value;if(!l.isVisible()||l instanceof Link&&(!i.computesBoundsIncludingLinks||l.Oo()||l.fromNode===i||l.toNode===i))continue;const h=l.actualBounds;h.leftn&&(n=h.right),h.bottom>o&&(o=h.bottom)}if(!isFinite(e)||!isFinite(s)){const l=i.location;t.e(l.x,l.y,0,0)}else t.e(e,s,n-e,o-s);return t}get padding(){return this.$t}set padding(t){typeof t=="number"&&(t=new Margin(t));const i=this.$t;i.equals(t)||(t=t.N(),this.$t=t,this.t("padding",i,t),this.c())}}class Layout{p;la;Gd;kr;jd;Hd;Fo;ul;qd;Wd;go;constructor(t){GSet.Yi(this),this.p=null,this.la=null,this.Gd=!0,this.kr=!0,this.jd=!1,this.Hd=new Point(0,0).g(),this.Fo=!0,this.ul=null,this.qd=null,this.Wd=!1,this.go=null,t&&Object.assign(this,t)}cloneProtected(t){t.Gd=this.Gd,t.kr=this.kr,t.jd=this.jd,t.Hd.a(this.Hd),t.Fo=this.Fo,t.ul=this.ul,t.qd=this.qd,t.Wd=!0}copy(){const t=new this.constructor;return this.cloneProtected(t),t}ri(t){Util.lr(this,t)}toString(){let t=Util.sn(this.constructor);return t+="(",this.group!==null&&(t+=" in "+this.group),this.diagram!==null&&(t+=" for "+this.diagram),t+=")",t}get diagram(){return this.p}set diagram(t){this.p=t}get group(){return this.la}set group(t){this.la!==t&&(this.la=t,t!==null&&(this.p=t.diagram))}get isOngoing(){return this.Gd}set isOngoing(t){this.Gd!==t&&(Util.i(t,"boolean",Layout,"isOngoing"),this.Gd=t)}get isInitial(){return this.kr}set isInitial(t){Util.i(t,"boolean",Layout,"isInitial"),this.kr=t,t||(this.Wd=!0)}get isViewportSized(){return this.jd}set isViewportSized(t){this.jd!==t&&(Util.i(t,"boolean",Layout,"isViewportSized"),this.jd=t,t&&this.invalidateLayout())}get isRouting(){return this.Fo}set isRouting(t){this.Fo!==t&&(Util.i(t,"boolean",Layout,"isRouting"),this.Fo=t)}get isRealtime(){return this.ul}set isRealtime(t){this.ul!==t&&(t!==null&&Util.i(t,"boolean",Layout,"isRealtime"),this.ul=t)}get isValidLayout(){return this.Wd}set isValidLayout(t){if(this.Wd!==t&&(Util.i(t,"boolean",Layout,"isValidLayout"),this.Wd=t,!t)){const i=this.diagram;i!==null&&(i.Kr=!0)}}invalidateLayout(){if(this.isValidLayout){const t=this.diagram;if(t===null||t.undoManager.isUndoingRedoing)return;const i=t.animationManager;if(i.isTicking)return;i.defaultAnimation.isAnimating&&i.stopAnimation(),(this.isOngoing&&t.Eh||this.isInitial&&!t.Eh)&&(this.isValidLayout=!1,t.requestUpdate())}}get network(){return this.go}set network(t){this.go!==t&&(this.go=t,t!==null&&(t.layout=this))}createNetwork(){return new LayoutNetwork(this)}makeNetwork(t){const i=this.createNetwork();return t instanceof Diagram?(i.addParts(t.nodes,!0),i.addParts(t.links,!0)):t instanceof Group?i.addParts(t.memberParts):i.addParts(t.iterator),i}updateParts(){this.isValidLayout=!0;let t=this.diagram;if(t===null&&this.network!==null){const i=this.network.vertexes.iterator;for(;i.next();){const s=i.value.node;if(s!==null&&(t=s.diagram,t!==null))break}}try{t!==null&&t.startTransaction("Layout"),this.commitLayout()}finally{t!==null&&t.commitTransaction("Layout")}}commitLayout(){if(this.network===null)return;const t=this.network.vertexes.iterator;for(;t.next();)t.value.commit();if(this.isRouting){const i=this.network.edges.iterator;for(;i.next();)i.value.commit()}}doLayout(t){const i=new GSet;if(t instanceof Diagram?(this.bh(i,t.nodes,!0,this.Jr,!0,!1,!0),this.bh(i,t.parts,!0,this.Jr,!0,!1,!0)):t instanceof Group?this.bh(i,t.memberParts,!1,this.Jr,!0,!1,!0):i.addAll(t.iterator),i.count>0){const s=this.diagram;s!==null&&s.startTransaction("Layout"),this.doMinimalNoNetworkLayout(i),s!==null&&s.commitTransaction("Layout")}this.isValidLayout=!0}doMinimalNoNetworkLayout(t){const i=t.count,e=Math.ceil(Math.sqrt(i));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const s=this.arrangementOrigin.x,n=this.arrangementOrigin.y;let o=s,r=n,l=0,h=0;const a=t.iterator;for(;a.next();){const c=a.value;c.ensureBounds();const f=c.measuredBounds,u=f.width,d=f.height;c.moveTo(o,r),c instanceof Group&&(c.Jr=!1),o+=Math.max(u,50)+20,h=Math.max(h,Math.max(d,50)),l>=e-1?(l=0,o=s,r+=h+20,h=0):l++}}doMinimalNetworkLayout(){const t=this.network.vertexes.count,i=Math.ceil(Math.sqrt(t));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const e=this.arrangementOrigin.x,s=this.arrangementOrigin.y;let n=e,o=s,r=0,l=0;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value.node;if(a===null||a instanceof Link||(a.ensureBounds(),!this.Jr(a)))continue;const c=a.measuredBounds,f=c.width,u=c.height;a.moveTo(n,o),a instanceof Group&&(a.Jr=!1),n+=Math.max(f,50)+20,l=Math.max(l,Math.max(u,50)),r>=i-1?(r=0,n=e,o+=l+20,l=0):r++}}Jr(t){return!!(!t.location.isReal()&&!t.position.isReal()||t instanceof Group&&t.Jr)}bh(t,i,e,s,n,o,r){const l=i.iterator;for(;l.next();){const h=l.value;if(!(e&&!h.isTopLevel)&&!(s!==null&&!s(h))&&h.canLayout())if(n&&h instanceof Node){if(h.isLinkLabel)continue;h instanceof Group&&h.layout===null?this.bh(t,h.memberParts,!1,s,n,o,r):(h.ensureBounds(),t.add(h))}else o&&h instanceof Link?t.add(h):r&&h.Pe()&&!(h instanceof Node)&&(h.ensureBounds(),t.add(h))}}getLayoutBounds(t,i){const e=this.boundsComputation;return e!==null?(i||(i=new Rect),e(t,this,i)):!i&&t.margin.equalTo(0,0,0,0)?t.actualBounds:(i||(i=new Rect),i.set(t.actualBounds),i.addMargin(t.margin),i)}get boundsComputation(){return this.qd}set boundsComputation(t){this.qd!==t&&(t!==null&&Util.i(t,"function",Layout,"boundsComputation"),this.qd=t,this.invalidateLayout())}collectParts(t){const i=new GSet;return t instanceof Diagram?(this.bh(i,t.nodes,!0,null,!0,!0,!0),this.bh(i,t.links,!0,null,!0,!0,!0),this.bh(i,t.parts,!0,null,!0,!0,!0)):t instanceof Group?this.bh(i,t.memberParts,!1,null,!0,!0,!0):this.bh(i,t.iterator,!1,null,!0,!0,!0),i}get arrangementOrigin(){return this.Hd}set arrangementOrigin(t){this.Hd.equals(t)||(this.Hd.a(t),this.invalidateLayout())}initialOrigin(t){const i=this.group;if(i!==null)if(i.hasPlaceholder()){const e=i.placeholder,s=e.getDocumentPoint(Spot.TopLeft);(isNaN(s.x)||isNaN(s.y))&&s.set(t);const n=e.padding;return s.x+=n.left,s.y+=n.top,s}else{const e=i.position.copy();return(isNaN(e.x)||isNaN(e.y))&&e.set(t),e}return t}}class LayoutNetwork{te;mo;Cn;ky;Py;constructor(t){GSet.Yi(this),this.te=t,this.mo=new GSet,this.Cn=new GSet,this.ky=new GMap,this.Py=new GMap}clear(){if(this.mo){const t=this.mo.iterator;for(;t.next();)t.value.clear()}if(this.Cn){const t=this.Cn.iterator;for(;t.next();)t.value.clear()}this.mo=new GSet,this.Cn=new GSet,this.ky=new GMap,this.Py=new GMap}toString(t){t===void 0&&(t=0);let i="LayoutNetwork"+(this.layout!==null?"("+this.layout.toString()+")":"");if(t<=0)return i;if(i+=" vertexes: "+this.mo.count+" edges: "+this.Cn.count,t>1){const e=this.mo.iterator;for(;e.next();){const n=e.value;i+=` +`);if(t.length===0)return 8;if(this.isMultiline){let i=0,e=0,s=!1;for(;!s;){let n=this.t1(t,e);n===-1&&(n=t.length,s=!0);let o=t.substring(e,n);this.formatting===0&&(o=o.trim()),i=Math.max(i,this.getStringWidth(o)),e=n+1}return i}else{const i=this.t1(t,0);return i>=0&&(t=t.substring(0,i)),this.getStringWidth(t)}}get textValidation(){return this.W!==null?this.W.Tl:null}set textValidation(t){const i=this.textValidation;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"textValidation"),this.Mn(),this.W.Tl=t,this.t("textValidation",i,t))}get textEdited(){return this.W!==null?this.W.Dp:null}set textEdited(t){const i=this.textEdited;i!==t&&(t!==null&&Util.i(t,"function",TextBlock,"textEdited"),this.Mn(),this.W.Dp=t,this.t("textEdited",i,t))}get spacingAbove(){return this.W!==null?this.W.Fp:0}set spacingAbove(t){const i=this.spacingAbove;i!==t&&(this.Mn(),this.W.Fp=t,this.c(),this.t("spacingAbove",i,t))}get spacingBelow(){return this.W!==null?this.W.Rp:0}set spacingBelow(t){const i=this.spacingBelow;i!==t&&(this.Mn(),this.W.Rp=t,this.c(),this.t("spacingBelow",i,t))}get formatting(){return this.W!==null?this.W.vp:0}set formatting(t){const i=this.formatting;i!==t&&(this.Mn(),this.W.vp=t,this.c(),this.t("formatting",i,t))}get maxLines(){return this.W!==null?this.W.Op:1/0}set maxLines(t){const i=this.maxLines;i!==t&&(t=Math.floor(t),t<=0&&Util._(t,"> 0",TextBlock,"maxLines"),this.Mn(),this.W.Op=t,this.c(),this.t("maxLines",i,t))}getMetrics(){return[this.mi,this.Dl,this.oo,this.Pn,this.Le,this.Di,this.Sn]}Pv(t){t!==void 0&&(this.mi=t[0],this.Dl=t[1],this.oo=t[2],this.Pn=t[3],this.Le=t[4],this.Di=t[5],this.Sn=t[6])}get metrics(){return{arrSize:this.Le!==null?this.Le:[this.mi],arrText:this.Di!==null?this.Di:[this.Sn],maxLineWidth:this.mi,fontHeight:this.oo}}get choices(){return this.Sd}set choices(t){const i=this.Sd;i!==t&&(this.Sd=t,this.t("choices",i,t))}static Lv=new RegExp("[ \u200B\xAD]");static V2=new PropertyCollection;static IA=0;static Zb=new PropertyCollection;static E2=0;static Sp="...";static vA="";static il=Diagram.isUsingDOM()?new CanvasSurface(null).ai:null}class TextBlockTemplateSettings{gi;os;ro;vp;Op;Cp;Fp;Rp;Mp;Dp;Ap;Tl;sl;Np;constructor(){this.gi=!1,this.os=null,this.ro=0,this.vp=0,this.Op=1/0,this.Cp=0,this.Fp=0,this.Rp=0,this.Mp="start",this.Dp=null,this.Ap=null,this.Tl=null,this.sl=Spot.Top,this.Np=2}copy(){const t=new TextBlockTemplateSettings;return t.os=this.os,t.ro=this.ro,t.vp=this.vp,t.Op=this.Op,t.Cp=this.Cp,t.Fp=this.Fp,t.Rp=this.Rp,t.Mp=this.Mp,t.Dp=this.Dp,t.Ap=this.Ap,t.Tl=this.Tl,t.sl=this.sl,t.Np=this.Np,t}}class GradElementSettings{uf;df;gf;Tp;mf;constructor(){this.uf=1,this.df=0,this.gf=1,this.Tp=null,this.mf=null}copy(){const t=new GradElementSettings;return t.uf=this.uf,t.df=this.df,t.gf=this.gf,t.Tp=this.Tp,t.mf=this.mf,t}}var ImageStretch=(w=>(w[w.None=0]="None",w[w.Fill=2]="Fill",w[w.Uniform=6]="Uniform",w[w.UniformToFill=7]="UniformToFill",w))(ImageStretch||{});class Picture extends GraphObject{nl;yt;ol;pf;os;rl;yf;ro;wf;xf;Ib;constructor(t,i){super(),this.n|=2097152,this.nl=null,this.yt="",this.ol=Rect.AD,this.pf=2,this.os=null,this.rl=null,this.yf=Spot.Center,this.ro=0,this.wf=null,this.xf=null,this.Ib=null,typeof t=="string"?this.source=t:t&&Object.assign(this,t),i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.yt=this.yt,t.element=this.nl,t.ol=this.ol.N(),t.pf=this.pf,t.ro=this.ro,t.os=this.os,t.rl=this.rl,t.yf=this.yf.N(),t.xf=this.xf}ri(t){t in ImageStretch?this.imageStretch=t:super.ri(t)}toString(){return"Picture("+this.source+")#"+GSet.as(this)}get bf(){return(this.n&1048576)!==0}set bf(t){this.bf!==t&&(this.n=this.n^1048576)}get Ip(){return(this.n&2097152)!==0}set Ip(t){this.Ip!==t&&(this.n=this.n^2097152)}get mn(){return(this.n&4194304)!==0}set mn(t){this.mn!==t&&(this.n=this.n^4194304)}static clearCache(t){t===void 0&&(t=""),Util.i(t,"string",Picture,"clearCache:url"),t!==""?Picture.Ep[t]&&(delete Picture.Ep[t],Picture.i1--):(Picture.Ep=new PropertyCollection,Picture.i1=0)}static OL(t,i){i.EA||(i.e1=e=>{Picture.Av(i,e),t.desiredSize.isReal()||(t.ue(!1),t.c())},i.s1=e=>Picture.Tv(i,e),i.addEventListener("load",i.e1),i.addEventListener("error",i.s1),i.EA=!0)}static mR(t){t.e1&&t.removeEventListener("load",t.e1),t.s1&&t.removeEventListener("error",t.s1),delete t.e1,delete t.s1,delete t.EA}get element(){return this.nl}set element(t){const i=this.nl;if(this.ss(!0),i!==t){this.bf=t instanceof HTMLCanvasElement;const e=t instanceof HTMLImageElement;t!==null&&!(e||t instanceof HTMLVideoElement||this.bf)&&Util.o("Picture.element must be an instance of Image, Canvas, or Video, not: "+t);const s=this.diagram;s!==null&&s.DM(this),this.nl=t,t!==null&&e&&t.es===void 0&&(t.es=new GSet),s!==null&&e&&s.TM(this),this.t("element",i,t),this.C()}}dR(){const t=this.nl;if(t===null)return;const i=this.desiredSize.isReal();(this.bf||t.complete===!0)&&(t.c0&&(t.Bp instanceof Event&&this.os!==null?this.os(this,t.Bp):t.mn===!0&&!t.Bp&&this.rl!==null&&t.z2&&this.rl(this,t.z2)),t.mn=!0),t.mn&&i&&this.diagram!==null&&this.diagram.zu.add(this)}Dv(){if(this.nl===null){this.wf=!1;return}const t=new CanvasSurface(null).ai;try{t.drawImage(this.nl,0,0)}catch{this.Ip=!1}try{t.getImageData(0,0,1,1).data[3]&&(this.wf=!1),this.wf=!1}catch{this.wf=!0}}get source(){return this.yt}set source(t){const i=this.yt;if(i!==t){this.ss(!0),Util.i(t,"string",Picture,"source"),this.yt=t;let e=Picture.Ep;if(!Diagram.isUsingDOM()){this.t("source",i,t);return}let s=null;if(e[t]!==void 0)s=e[t];else if(t!==""){Picture.i1>30&&(Picture.clearCache(),e=Picture.Ep),s=Util.en("img"),s.c0=!0,Picture.OL(this,s);const n=this.xf;n!==null&&(s.crossOrigin=n(this)),s.src=t,e[t]=s,Picture.i1++}this.element=s,s!==null&&s.__goCache===void 0&&(s.__goCache=new PictureCacheArray),this.c(),this.C(),this.t("source",i,t)}}static Av(t,i){t.mn=!0,t.Bp=!1;let e;const s=t.es.copy();if(s==null)return;const n=s.iterator;for(;n.next();){const o=n.value;o.C();const r=t.getAttribute("src")||"",l=o.Jl.get(r);if(l===null)continue;const h=l.length;for(let a=0;a=o.width&&(r=r+p.offsetX+(d*p.x-o.width*p.x)),m>=o.height&&(l=l+p.offsetY+(m*p.y-o.height*p.y)),a=Math.min(o.width,d),c=Math.min(o.height,m);break;case 2:d=o.width,m=o.height;break;case 6:case 7:let A=0;g===6?(A=Math.min(o.height/m,o.width/d),d*=A,m*=A):g===7&&(A=Math.max(o.height/m,o.width/d),d*=A,m*=A,d>=o.width&&(r=(r+p.offsetX+(d*p.x-o.width*p.x)/d)*a),m>=o.height&&(l=(l+p.offsetY+(m*p.y-o.height*p.y)/m)*c),a*=1/(d/o.width),c*=1/(m/o.height),d=o.width,m=o.height);break}const y=a*c,x=this.getDocumentScale()*i.scale,k=d*x,b=m*x,P=k*b,S=y/P,L=e.__goCache;let C=null;const M=Picture.Fv;if(!n){if(e.mn&&L!==void 0&&P>4&&S>M*M){L.Ot===null&&(L.BA(4,f,u,e),L.BA(16,f,u,e));const A=L.Ot,D=A.length;for(let F=0;F0){const c=this.Ot[this.Ot.length-1];h=c.yt,a=c.Nd}o.setTransform(r*a,0,0,r*a,0,0),o.commitTransform(),o.drawImage(h,0,0),this.Ot.push(l)}}class PictureCacheInstance{yt;Nd;constructor(t,i){this.yt=t,this.Nd=i}}class GeoStream{Pi;Hg;constructor(){this.Hg=new Geometry,this.Pi=null}Ri(t){t!==null?(t.ot(),this.Hg=t,t.figures.clear()):this.Hg=new Geometry,this.Pi=null}fu(t,i,e,s,n,o){if(s!==void 0&&s===!0){const r=new PathSegment(1);r.endX=t,r.endY=i,this.Pi.segments.add(r)}else this.Pi=new PathFigure,this.Pi.startX=t,this.Pi.startY=i,this.Pi.isFilled=e,this.Pi.isEvenOdd=o||!1,this.Hg.figures.add(this.Pi);n!==void 0&&(this.Pi.isShadowed=n)}UD(){const t=this.Pi.segments.length;t>0&&this.Pi.segments.elt(t-1).close()}VD(){this.Pi.segments.length>0&&(this.Pi.isFilled=!0)}zD(t){this.Pi.isShadowed=t}gE(t){this.Pi.isEvenOdd=t}ID(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(1);s.endX=t,s.endY=i,e&&s.close(),this.Pi.segments.add(s)}ur(t,i,e){e===void 0&&(e=!1);const s=new PathSegment(2);s.endX=t,s.endY=i,e&&s.close(),this.Pi.segments.add(s)}dr(t,i,e,s,n,o,r){r===void 0&&(r=!1);const l=new PathSegment(3);l.point1X=t,l.point1Y=i,l.point2X=e,l.point2Y=s,l.endX=n,l.endY=o,r&&l.close(),this.Pi.segments.add(l)}Mw(t,i,e,s,n){n===void 0&&(n=!1);const o=new PathSegment(4);o.point1X=t,o.point1Y=i,o.endX=e,o.endY=s,n&&o.close(),this.Pi.segments.add(o)}ED(t,i,e,s,n,o,r){o===void 0&&(o=0),r===void 0&&(r=!1);const l=new PathSegment(5);l.startAngle=t,l.sweepAngle=i,l.centerX=e,l.centerY=s,l.radiusX=n,o!==0?l.radiusY=o:l.radiusY=n,r&&l.close(),this.Pi.segments.add(l)}BD(t,i,e,s,n,o,r,l){l===void 0&&(l=!1);const h=new PathSegment(6,o,r,t,i,e,s,n);l&&h.close(),this.Pi.segments.add(h)}static X2=null;static mC(t){const i=GeoStream.X2;if(i!==null)return GeoStream.X2=null,i.Ri(t),i;{const e=new GeoStream;return e.Ri(t),e}}static pC(t){GeoStream.X2=t}}{const w=function(n,o){const r=n.toLowerCase(),l=Geo.So;l[n]=o,l[r]=n};w("Rectangle",(n,o,r)=>{const l="r"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,Geo.fr{const l="s"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(2),h.endX=o,h.endY=r,h.defaultStretch=6,Geo.fr{(isNaN(l)||l<0)&&(l=5),isNaN(h)&&(h=15);const a="rr"+o+","+r+","+l+","+h;let c=Geo.cr[a];if(c!==void 0)return c;let f=l;(h&1)===1?(f=Math.min(f,(h&2)===2?o/3:o),f=Math.min(f,(h&8)===8?r/3:r)):f=0;const u=new PathFigure(f,0,!0);c=new Geometry().add(u);const d=Spot.TopLeft.copy(),m=Spot.BottomRight.copy();if((h&2)===2){let g=l;g=Math.min(g,(h&1)===1?o/3:o),g=Math.min(g,(h&4)===4?r/3:r);const p=g*Geo.Bn;u.add(new PathSegment(2,o-g,0)).add(new PathSegment(3,o,g,o-p,0,o,p)),d.offsetY=p,m.offsetX=-p}else u.add(new PathSegment(2,o,0));if((h&4)===4){let g=l;g=Math.min(g,(h&8)===8?o/3:o),g=Math.min(g,(h&2)===2?r/3:r);const p=g*Geo.Bn;u.add(new PathSegment(2,o,r-g)).add(new PathSegment(3,o-g,r,o,r-p,o-p,r)),m.offsetX=-p,m.offsetY=-p}else u.add(new PathSegment(2,o,r));if((h&8)===8){let g=l;g=Math.min(g,(h&4)===4?o/3:o),g=Math.min(g,(h&1)===1?r/3:r);const p=g*Geo.Bn;u.add(new PathSegment(2,g,r)).add(new PathSegment(3,0,r-g,p,r,0,r-p)),d.offsetX=p,m.offsetY=-p}else u.add(new PathSegment(2,0,r));if((h&1)===1){const g=f*Geo.Bn;u.add(new PathSegment(2,0,f)).add(new PathSegment(3,f,0,0,g,g,0).close()),d.offsetX=g,d.offsetY=g}else u.add(new PathSegment(2,0,0).close());return c.spot1=d,c.spot2=m,Geo.fr{const l=n?n.parameter1:NaN,h=n?n.parameter2:NaN;return t(n,o,r,l,h)}),w("Border","RoundedRectangle"),w("RoundedTopRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,3)}),w("RoundedBottomRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,12)}),w("RoundedLeftRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,9)}),w("RoundedRightRectangle",(n,o,r)=>{const l=n?n.parameter1:NaN;return t(n,o,r,l,6)}),w("Ellipse",(n,o,r)=>{const l="e"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Rk,h.spot2=Spot.vk,Geo.fr{const l="c"+o+","+r;let h=Geo.cr[l];return h!==void 0||(h=new Geometry(3),h.endX=o,h.endY=r,h.spot1=Spot.Rk,h.spot2=Spot.vk,h.defaultStretch=6,Geo.frnew Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,.5*r)).add(new PathSegment(2,0,r).close())).setSpots(0,.25,.5,.75)),w("TriangleDown",(n,o,r)=>new Geometry().add(new PathFigure(0,0).add(new PathSegment(2,o,0)).add(new PathSegment(2,.5*o,r).close())).setSpots(.25,0,.75,.5)),w("TriangleLeft",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,o,0).close())).setSpots(.5,.25,1,.75)),w("TriangleUp",(n,o,r)=>new Geometry().add(new PathFigure(o,r).add(new PathSegment(2,0,r)).add(new PathSegment(2,.5*o,0).close())).setSpots(.25,.5,.75,1)),w("Triangle","TriangleUp"),w("Diamond",(n,o,r)=>new Geometry().add(new PathFigure(.5*o,0).add(new PathSegment(2,0,.5*r)).add(new PathSegment(2,.5*o,r)).add(new PathSegment(2,o,.5*r).close())).setSpots(.25,.25,.75,.75)),w("LineH",(n,o,r)=>{const l=new Geometry(1);return l.startX=0,l.startY=r/2,l.endX=o,l.endY=r/2,l}),w("LineV",(n,o,r)=>{const l=new Geometry(1);return l.startX=o/2,l.startY=0,l.endX=o/2,l.endY=r,l}),w("None","Rectangle"),w("BarH","Rectangle"),w("BarV","Rectangle"),w("MinusLine","LineH"),w("PlusLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r/2,!1).add(new PathSegment(2,o,r/2)).add(new PathSegment(1,o/2,0)).add(new PathSegment(2,o/2,r)))),w("XLine",(n,o,r)=>new Geometry().add(new PathFigure(0,r,!1).add(new PathSegment(2,o,0)).add(new PathSegment(1,0,0)).add(new PathSegment(2,o,r)))),w("LineRight",(n,o,r)=>new Geometry().add(new PathFigure(.25*o,0,!1).add(new PathSegment(2,.75*o,.5*r)).add(new PathSegment(2,.25*o,r)))),w("LineDown",(n,o,r)=>new Geometry().add(new PathFigure(0,.25*r,!1).add(new PathSegment(2,.5*o,.75*r)).add(new PathSegment(2,o,.25*r)))),w("LineLeft",(n,o,r)=>new Geometry().add(new PathFigure(.75*o,0,!1).add(new PathSegment(2,.25*o,.5*r)).add(new PathSegment(2,.75*o,r)))),w("LineUp",(n,o,r)=>new Geometry().add(new PathFigure(0,.75*r,!1).add(new PathSegment(2,.5*o,.25*r)).add(new PathSegment(2,o,.75*r)))),w("Capsule",(n,o,r)=>{const l=new Geometry;if(or){const h=r/2,a=new PathFigure(h,0,!0);l.add(a),a.add(new PathSegment(2,o-h,0)),a.add(new PathSegment(5,270,180,o-h,h,h,h)),a.add(new PathSegment(2,h,r)),a.add(new PathSegment(5,90,180,h,h,h,h));const c=isFinite(n.parameter1)?n.parameter1:r*.156;return l.spot1=new Spot(0,0,c,0),l.spot2=new Spot(1,1,-c,0),l}else return l.type=3,l.endX=o,l.endY=r,l.spot1=Spot.Rk,l.spot2=Spot.vk,l});const i=(n,o)=>new PathFigure(n,o,!1,!1),e=(n,o,r)=>n.add(new PathSegment(2,o,r)),s=(n,o,r)=>n.add(new PathSegment(1,o,r));w("Borders",(n,o,r)=>{let l=n?n.parameter1:NaN;isNaN(l)?l=10:l=l&15;const h=new Geometry;let a;return l===10?(a=i(o,0),e(a,o,r),s(a,0,r),e(a,0,0)):l===5?(a=i(0,0),e(a,o,0),s(a,o,r),e(a,0,r)):l===1?(a=i(0,0),e(a,o,0),s(a,o,r)):l===2?(a=i(o,0),e(a,o,r)):l===4?(a=i(o,r),e(a,0,r)):l===8?(a=i(0,r),e(a,0,0),s(a,o,r)):l===3?(a=i(0,0),e(a,o,0),e(a,o,r)):l===6?(a=i(o,0),e(a,o,r),e(a,0,r)):l===12?(a=i(o,r),e(a,0,r),e(a,0,0)):l===9?(a=i(0,r),e(a,0,0),e(a,o,0)):l===7?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r)):l===14?(a=i(o,0),e(a,o,r),e(a,0,r),e(a,0,0)):l===13?(a=i(o,r),e(a,0,r),e(a,0,0),e(a,o,0)):l===11?(a=i(0,r),e(a,0,0),e(a,o,0),e(a,o,r)):l===15?(a=i(0,0),e(a,o,0),e(a,o,r),e(a,0,r),a.add(new PathSegment(2,0,0).close())):(a=i(0,0),s(a,o,r)),h.add(a),h})}Geo.Xg={"":"",Standard:"F1 m 0,0 l 8,4 -8,4 2,-4 z",Backward:"F1 m 8,0 l -2,4 2,4 -8,-4 z",Triangle:"F1 m 0,0 l 8,4.62 -8,4.62 z",BackwardTriangle:"F1 m 8,4 l 0,4 -8,-4 8,-4 0,4 z",Boomerang:"F1 m 0,0 l 8,4 -8,4 4,-4 -4,-4 z",BackwardBoomerang:"F1 m 8,0 l -8,4 8,4 -4,-4 4,-4 z",SidewaysV:"m 0,0 l 8,4 -8,4 0,-1 6,-3 -6,-3 0,-1 z",BackwardV:"m 8,0 l -8,4 8,4 0,-1 -6,-3 6,-3 0,-1 z",OpenTriangle:"m 0,0 l 8,4 -8,4",BackwardOpenTriangle:"m 8,0 l -8,4 8,4",OpenTriangleLine:"m 0,0 l 8,4 -8,4 m 8.5,0 l 0,-8",BackwardOpenTriangleLine:"m 8,0 l -8,4 8,4 m -8.5,0 l 0,-8",OpenTriangleTop:"m 0,0 l 8,4 m 0,4",BackwardOpenTriangleTop:"m 8,0 l -8,4 m 0,4",OpenTriangleBottom:"m 0,8 l 8,-4",BackwardOpenTriangleBottom:"m 0,4 l 8,4",HalfTriangleTop:"F1 m 0,0 l 0,4 8,0 z m 0,8",BackwardHalfTriangleTop:"F1 m 8,0 l 0,4 -8,0 z m 0,8",HalfTriangleBottom:"F1 m 0,4 l 0,4 8,-4 z",BackwardHalfTriangleBottom:"F1 m 8,4 l 0,4 -8,-4 z",ForwardSemiCircle:"m 4,0 b 270 180 0 4 4",BackwardSemiCircle:"m 4,8 b 90 180 0 -4 4",Feather:"m 0,0 l 3,4 -3,4",BackwardFeather:"m 3,0 l -3,4 3,4",DoubleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardDoubleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4",TripleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardTripleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4 m 3,-8 l -3,4 3,4",ForwardSlash:"m 0,8 l 5,-8",BackSlash:"m 0,0 l 5,8",DoubleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8",DoubleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8",TripleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8 m -2,8 l 4,-8",TripleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8 m -2,-8 l 4,8",Fork:"m 0,4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4",LineFork:"m 0,0 l 0,8 m 0,-4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardLineFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4 m 8,-8 l 0,8",CircleFork:"F1 m 6,4 b 0 360 -3 0 3 z m 0,0 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 6,0 b 0 360 -3 0 3",CircleLineFork:"F1 m 6,4 b 0 360 -3 0 3 z m 1,-4 l 0,8 m 0,-4 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleLineFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 0,-4 l 0,8 m 7,-4 b 0 360 -3 0 3",Circle:"F1 m 8,4 b 0 360 -4 0 4 z",Block:"F1 m 0,0 l 0,8 8,0 0,-8 z",StretchedDiamond:"F1 m 0,3 l 5,-3 5,3 -5,3 -5,-3 z",Diamond:"F1 m 0,4 l 4,-4 4,4 -4,4 -4,-4 z",Chevron:"F1 m 0,0 l 5,0 3,4 -3,4 -5,0 3,-4 -3,-4 z",StretchedChevron:"F1 m 0,0 l 8,0 3,4 -3,4 -8,0 3,-4 -3,-4 z",NormalArrow:"F1 m 0,2 l 4,0 0,-2 4,4 -4,4 0,-2 -4,0 z",X:"m 0,0 l 8,8 m 0,-8 l -8,8",TailedNormalArrow:"F1 m 0,0 l 2,0 1,2 3,0 0,-2 2,4 -2,4 0,-2 -3,0 -1,2 -2,0 1,-4 -1,-4 z",DoubleTriangle:"F1 m 0,0 l 4,4 -4,4 0,-8 z m 4,0 l 4,4 -4,4 0,-8 z",BigEndArrow:"F1 m 0,0 l 5,2 0,-2 3,4 -3,4 0,-2 -5,2 0,-8 z",ConcaveTailArrow:"F1 m 0,2 h 4 v -2 l 4,4 -4,4 v -2 h -4 l 2,-2 -2,-2 z",RoundedTriangle:"F1 m 0,1 a 1,1 0 0 1 1,-1 l 7,3 a 0.5,1 0 0 1 0,2 l -7,3 a 1,1 0 0 1 -1,-1 l 0,-6 z",SimpleArrow:"F1 m 1,2 l -1,-2 2,0 1,2 -1,2 -2,0 1,-2 5,0 0,-2 2,2 -2,2 0,-2 z",AccelerationArrow:"F1 m 0,0 l 0,8 0.2,0 0,-8 -0.2,0 z m 2,0 l 0,8 1,0 0,-8 -1,0 z m 3,0 l 2,0 2,4 -2,4 -2,0 0,-8 z",BoxArrow:"F1 m 0,0 l 4,0 0,2 2,0 0,-2 2,4 -2,4 0,-2 -2,0 0,2 -4,0 0,-8 z",TriangleLine:"F1 m 8,4 l -8,-4 0,8 8,-4 z m 0.5,4 l 0,-8",CircleEndedArrow:"F1 m 10,4 l -2,-3 0,2 -2,0 0,2 2,0 0,2 2,-3 z m -4,0 b 0 360 -3 0 3 z",DynamicWidthArrow:"F1 m 0,3 l 2,0 2,-1 2,-2 2,4 -2,4 -2,-2 -2,-1 -2,0 0,-2 z",EquilibriumArrow:"m 0,3 l 8,0 -3,-3 m 3,5 l -8,0 3,3",FastForward:"F1 m 0,0 l 3.5,4 0,-4 3.5,4 0,-4 1,0 0,8 -1,0 0,-4 -3.5,4 0,-4 -3.5,4 0,-8 z",Kite:"F1 m 0,4 l 2,-4 6,4 -6,4 -2,-4 z",HalfArrowTop:"F1 m 0,0 l 4,4 4,0 -8,-4 z m 0,8",HalfArrowBottom:"F1 m 0,8 l 4,-4 4,0 -8,4 z",OpposingDirectionDoubleArrow:"F1 m 0,4 l 2,-4 0,2 4,0 0,-2 2,4 -2,4 0,-2 -4,0 0,2 -2,-4 z",PartialDoubleTriangle:"F1 m 0,0 4,3 0,-3 4,4 -4,4 0,-3 -4,3 0,-8 z",LineCircle:"F1 m 0,0 l 0,8 m 7 -4 b 0 360 -3 0 3 z",DoubleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",TripleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",CircleLine:"F1 m 6 4 b 0 360 -3 0 3 z m 1,-4 l 0,8",DiamondCircle:"F1 m 8,4 l -4,4 -4,-4 4,-4 4,4 m 8,0 b 0 360 -4 0 4 z",PlusCircle:"F1 m 8,4 b 0 360 -4 0 4 l -8 0 z m -4 -4 l 0 8",OpenRightTriangleTop:"m 8,0 l 0,4 -8,0 m 0,4",OpenRightTriangleBottom:"m 8,8 l 0,-4 -8,0",Line:"m 0,0 l 0,8",DoubleLine:"m 0,0 l 0,8 m 2,0 l 0,-8",TripleLine:"m 0,0 l 0,8 m 2,0 l 0,-8 m 2,0 l 0,8",PentagonArrow:"F1 m 8,4 l -4,-4 -4,0 0,8 4,0 4,-4 z"};var LayoutConditions=(w=>(w[w.None=0]="None",w[w.Added=1]="Added",w[w.Removed=2]="Removed",w[w.Shown=4]="Shown",w[w.Hidden=8]="Hidden",w[w.NodeSized=16]="NodeSized",w[w.GroupLayout=32]="GroupLayout",w[w.NodeReplaced=64]="NodeReplaced",w[w.Standard=127]="Standard",w[w.All=16777215]="All",w))(LayoutConditions||{});class Part extends Panel{P;Ho;F;ll;hl;qo;hi;Wo;ph;js;Jo;Cd;BS;UA;Up;Vp;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.P=2408959,this.Ho="",this.F=null,this.ll="",this.hl=null,this.qo=null,this.hi="",this.Wo=null,this.ph=null,this.js=new Point(NaN,NaN).g(),this.Jo=null,this.Cd=NaN,this.BS=-1,this.UA=new Rect,this.Up=null,this.Vp=NaN,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.P=this.P&-4097|16384|32768,t.Ho=this.Ho,this.F!==null&&(this.F.gi?t.F=this.F:t.F=this.F.copy()),t.ll=this.ll,t.qo=null,t.hi=this.hi,t.js.a(this.js),t.Cd=this.Cd}Vo(t){super.Vo(t),t.ch(),t.hl=null,t.Jo=null,t.Up=null}toString(){let t=Util.sn(this.constructor)+"#"+GSet.as(this);return this.data!==null&&(t+="("+Util.toString(this.data)+")"),t}static LayoutNone=0;static LayoutAdded=1;static LayoutRemoved=2;static LayoutShown=4;static LayoutHidden=8;static LayoutNodeSized=16;static LayoutGroupLayout=32;static LayoutNodeReplaced=64;static LayoutStandard=127;static LayoutAll=16777215;qi(){this.F===null?this.F=new PartTemplateSettings:this.F.gi&&(this.F=this.F.copy())}lh(){super.lh(),this.F!==null&&(this.F.gi=!0)}Jc(t,i,e,s,n,o,r){const l=this.diagram;l!==null&&(t===3&&i==="elements"?n instanceof Panel?n.qr(h=>{l.partManager.SM(h,l)}):n instanceof Picture&&l.TM(n):t===4&&i==="elements"&&(n instanceof Panel?n.qr(h=>l.partManager.MM(h,l)):n instanceof Picture&&l.DM(n)),l.raiseChangedEvent(t,i,e,s,n,o,r))}updateTargetBindings(t){if(super.updateTargetBindings(t),this.data===null)return;const i=this.L.r,e=i.length;for(let n=0;n{r.data!==null&&r.updateTargetBindings()})}const s=this.adornments;for(;s.next();)s.value.updateTargetBindings(t)}Io(){if(super.Io(),this.d2()){const i=this.L.r,e=i.length;for(let s=0;so.Io())}}const t=this.adornments;for(;t.next();)t.value.Io()}updateRelationshipsFromData(){this.data!==null&&this.diagram?.partManager.updateRelationshipsFromData(this)}get key(){const t=this.diagram;if(t!==null)return t.model.getKeyForNodeData(this.data)}get adornments(){return this.qo===null?EmptyIterator.instance:this.qo.iteratorValues}findAdornment(t){const i=this.qo;return i===null?null:i.get(t)}addAdornment(t,i){if(i===null)return;let e=null,s=this.qo;if(s!==null&&(e=s.get(t)),e!==i){if(e!==null){const o=e.diagram;o!==null&&o.remove(e)}s===null&&(s=new GMap,this.qo=s),i.Ho!==t&&(i.category=t),s.set(t,i);const n=this.diagram;if(n!==null){n.add(i);const o=i.adornedObject;if(o!==null){const r=o.findBindingPanel();r!==null&&(i.data=r.data)}}}}removeAdornment(t){const i=this.qo;if(i===null)return;const e=i.get(t);if(e!==null){const s=e.diagram;s!==null&&(s.remove(e),e.data=null)}i.delete(t),i.count===0&&(this.qo=null)}clearAdornments(){const t=this.qo;if(t===null)return;const i=Util.nt(),e=t.iterator;for(;e.next();){const n=e.key;i.push(n)}const s=i.length;for(let n=0;n{e.isEnabled&&e.updateAdornments(i)}),t.toolManager.updateAdornments(i)}IS(t){this.Wo=t,t===null&&this.DR()}get layer(){return this.Wo}get diagram(){const t=this.Wo;return t==null?null:t.diagram}get layerName(){return this.ll}set layerName(t){const i=this.ll;if(i===t)return;Util.i(t,"string",Part,"layerName");let e=this.diagram;if(e!==null&&(e.findLayer(t)===null||e.partManager.addsToTemporaryLayer))return;this.ll=t,e!==null&&e.invalidateDocumentBounds(),this.t("layerName",i,t);const s=this.layer;if(s===null||s.name===t||(e=s.diagram,e===null))return;const n=e.findLayer(t);if(n===null||n===s)return;let o=s.te(-1,this,!0);o>=0&&e.raiseChangedEvent(4,"parts",s,this,null,o,!0),o=n.qh(99999999,this,!0),s.visible!==n.visible&&this.Ei(n.visible),o>=0&&e.raiseChangedEvent(3,"parts",n,null,this,!0,o);const r=this.layerChanged;if(r===null)return;const l=e.Y;e.Y=!0,r(this,s,n),e.Y=l}get layerChanged(){return this.F!==null?this.F.zp:null}set layerChanged(t){const i=this.layerChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"layerChanged"),this.qi(),this.F.zp=t,this.t("layerChanged",i,t))}get zOrder(){return this.Cd}set zOrder(t){const i=this.Cd;if(i===t)return;Util.i(t,"number",Part,"zOrder"),this.Cd=t;const e=this.layer;e!==null&&e.yx(-1,this),this.t("zOrder",i,t);const s=this.diagram;s!==null&&s.C()}Ov(){const t=this.layer;t!==null&&t.yx(-1,this)}o1(){if(this.th()!==!1)return;this.K2(!0),this._u();const t=this.diagram;t!==null&&(t.o0(this),t.requestUpdate())}XA(){if(this.P|=2097152,this.th()===!1)return;const t=this.position,i=this.location;(!i.isReal()||!t.isReal())&&this.KA(t,i);const e=this.Li,s=Rect.l().a(e);e.ot(),e.x=t.x,e.y=t.y,e.g(),this.td(s,e),Rect.s(s),this.K2(!1)}Qn(t,i,e,s){const n=this.se;n.e(t,i,e,s),this.bi===null&&(this.bi=new Transform);const o=this.bi;o.Ri(),this.p0(o,t,i,e,s),this.bi=o,o.Ok()||o.xw(n)}p0(t,i,e,s,n){if(this.et!==1&&t.et(this.et),this.Xt===0)return;let o=Spot.Center;this.locationSpot.isSpot()&&(o=this.locationSpot);const r=Point.l();if(this.locationObject!==this){const l=this.locationObject,h=l.naturalBounds;r.setSpot(h.x,h.y,h.width,h.height,o),l.bi!==null&&l.bi.xt(r),r.offset(-l.measuredBounds.x,-l.measuredBounds.y);let a=l.panel;for(;a!==null&&a!==this;)a.bi!==null&&a.bi.xt(r),r.offset(-a.measuredBounds.x,-a.measuredBounds.y),a=a.panel}else r.setSpot(i,e,s,n,o);t.cs(this.Xt,r.x,r.y),Point.s(r)}get locationObject(){if(this.Jo===null)if(this instanceof Adornment&&this.type!==Panel.Link&&this.hasPlaceholder())this.Jo=this.placeholder;else{const t=this.locationObjectName;if(t!==""){const i=this.findObject(t);i!==null?this.Jo=i:this.Jo=this}else this.Jo=this}return this.Jo.visible?this.Jo:this}get minLocation(){return this.F!==null?this.F.Xp:Point.$N}set minLocation(t){const i=this.minLocation;i.equals(t)||(t=t.N(),this.qi(),this.F.Xp=t,this.t("minLocation",i,t))}get maxLocation(){return this.F!==null?this.F.Kp:Point.ZN}set maxLocation(t){const i=this.maxLocation;i.equals(t)||(t=t.N(),this.qi(),this.F.Kp=t,this.t("maxLocation",i,t))}get locationObjectName(){return this.F!==null?this.F.Yp:""}set locationObjectName(t){const i=this.locationObjectName;i!==t&&(this.qi(),this.F.Yp=t,this.Jo=null,this.c(),this.t("locationObjectName",i,t))}get locationSpot(){return this.F!==null?this.F.Gp:Spot.TopLeft}set locationSpot(t){const i=this.locationSpot;i.equals(t)||(t=t.N(),this.qi(),this.F.Gp=t,this.c(),this.t("locationSpot",i,t))}move(t,i){i===!0?this.location=t:this.position=t}moveTo(t,i,e){const s=Point.X(t,i);this.move(s,e),Point.s(s)}isVisible(){if(!this.visible)return!1;const t=this.layer;if(t!==null){if(!t.visible)return!1;const e=t.diagram;if(e!==null&&e.animationManager.nx(this))return!0}const i=this.containingGroup;return!(i!==null&&(!i.isSubGraphExpanded||!i.isVisible()))}Ei(t){const i=this.diagram;t?(this.invalidateLayout(4),this.invalidateAdornments(),i!==null&&i.o0(this)):(this.invalidateLayout(8),this.clearAdornments()),this.ch(),i!==null&&(i.invalidateDocumentBounds(),i.C())}findObject(t){if(this.name===t)return this;let i=this.Up;if(i===null&&(this.Up=i=new GMap),i.get(t)!==null)return i.get(t);const e=super.findObject(t);return e!==null?(i.set(t,e),e):(i.set(t,null),null)}D0(){this.Up=null}getRelativePoint(t,i,e){e===void 0&&(e=new Point);const s=i.isNoSpot()?Spot.Center:i,n=t.naturalBounds;if(e.e(n.width*s.x+s.offsetX,n.height*s.y+s.offsetY),t===null||t===this)return e;t.D.xt(e);let o=t.panel;for(;o!==null&&o!==this;)o.D.xt(e),o=o.panel;return this.bi!==null&&this.bi.xt(e),e.offset(-this.se.x,-this.se.y),e}getDocumentBounds(t){return t===void 0&&(t=new Rect),t.a(this.actualBounds)}ensureBounds(){this.ut(1/0,1/0),this.zt()}pA(t){const i=this.locationSpot,e=this.locationObject;let s=e.naturalBounds;s.isReal()||(s=Rect.pw);const n=e instanceof Shape?e.strokeWidth:0;if(t.setSpot(0,0,s.width+n,s.height+n,i),e!==this){t.offset(-n/2,-n/2),e.D.xt(t);let o=e.panel;for(;o!==null&&o!==this;)o.D.xt(t),o=o.panel}return this.bi!==null&&this.bi.xt(t),t.offset(-this.se.x,-this.se.y),t}Hh(t,i){const e=i===void 0?this.UA:i,s=this.Iv(),n=s*2;if(!this.isShadowed)return e.e(t.x-1-s,t.y-1-s,t.width+2+n,t.height+2+n),e;let o=t.x,r=t.y,l=t.width,h=t.height;const a=this.shadowBlur,c=this.shadowOffset;return l+=a,h+=a,o-=a/2,r-=a/2,c.x>0?l+=c.x:(o+=c.x,l-=c.x),c.y>0?h+=c.y:(r+=c.y,h-=c.y),e.e(o-1,r-1,l+2,h+2),e}yv(){return this.type===Panel.Link&&this instanceof Adornment&&this.category==="Selection"&&this.adornedObject instanceof Shape&&this.adornedPart.findMainElement()===this.adornedObject?this.adornedObject.strokeWidth:0}Iv(){return isNaN(this.Vp)&&(this.Vp=this.SA()),this.Vp}cf(){this.Vp=NaN}zt(){if(this.is()===!1){this.XA();return}this._n(!1);const t=this.Li,i=Rect.l();i.a(t);const e=this.Nl();this.ah(0,0,this.se.width,this.se.height);const s=this.position;this.KA(s,this.location),t.ot(),t.x=s.x,t.y=s.y,t.g(),this.td(i,t),i.equals(t)?this.Bs(e):this.Pe()&&(!Geo.u(i.width,t.width)||!Geo.u(i.height,t.height))&&this.BS>=0&&this.invalidateLayout(16),Rect.s(i),this.K2(!1)}td(t,i){const e=this.diagram;if(e===null)return;let s=!1;if(e.Zh===!1&&t.isReal()){const n=Rect.l();n.a(e.documentBounds),n.subtractMargin(e.padding),t.x>n.x&&t.y>n.y&&t.rightn.x&&i.y>n.y&&i.right=o)return}}this.P=this.P^4096;let s=!1;if(e!==null){s=e.skipsUndoManager,e.skipsUndoManager=!0;const o=e.selection;o.ot(),t?o.add(this):o.delete(this),o.g()}this.t("isSelected",i,t),this.invalidateAdornments();const n=this.selectionChanged;n!==null&&n(this),e!==null&&(e.requestUpdate(),e.skipsUndoManager=s)}}get isHighlighted(){return(this.P&524288)!==0}set isHighlighted(t){const i=(this.P&524288)!==0;if(i!==t){this.P=this.P^524288;const e=this.diagram;if(e!==null){const n=e.highlighteds;n.ot(),t?n.add(this):n.delete(this),n.g()}this.t("isHighlighted",i,t),this.C();const s=this.highlightedChanged;s!==null&&s(this)}}get isShadowed(){return(this.P&8192)!==0}set isShadowed(t){const i=(this.P&8192)!==0;i!==t&&(this.P=this.P^8192,this.ss(!0),this.t("isShadowed",i,t),this.C())}VA(){return(this.P&16384)!==0}zA(t){t?this.P|=16384:this.P&=-16385}th(){return(this.P&32768)!==0}K2(t){t?this.P|=32768:this.P&=-32769}Ev(){return(this.P&65536)!==0}s2(t){t?this.P|=65536:this.P&=-65537}Nl(){return(this.P&131072)!==0}Bs(t){t?this.P|=131072:this.P&=-131073}qA(){return(this.P&1048576)!==0}l1(t){t?this.P|=1048576:this.P&=-1048577}get isAnimated(){return(this.P&262144)!==0}set isAnimated(t){const i=(this.P&262144)!==0;i!==t&&(this.P=this.P^262144,this.t("isAnimated",i,t))}get highlightedChanged(){return this.F!==null?this.F.jp:null}set highlightedChanged(t){const i=this.highlightedChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"highlightedChanged"),this.qi(),this.F.jp=t,this.t("highlightedChanged",i,t))}get selectionObjectName(){return this.F!==null?this.F.Hp:""}set selectionObjectName(t){const i=this.selectionObjectName;i!==t&&(this.qi(),this.F.Hp=t,this.hl=null,this.t("selectionObjectName",i,t))}get selectionAdornmentTemplate(){return this.F!==null?this.F.qp:null}set selectionAdornmentTemplate(t){const i=this.selectionAdornmentTemplate;i!==t&&(this.qi(),this.F.qp=t,this.t("selectionAdornmentTemplate",i,t))}get selectionObject(){if(this.hl===null){const t=this.selectionObjectName;if(t!==null&&t!==""){const i=this.findObject(t);i!==null?this.hl=i:this.hl=this}else if(this instanceof Link){const i=this.path;i!==null?this.hl=i:this.hl=this}else this.hl=this}return this.hl}get selectionChanged(){return this.F!==null?this.F.Wp:null}set selectionChanged(t){const i=this.selectionChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"selectionChanged"),this.qi(),this.F.Wp=t,this.t("selectionChanged",i,t))}get resizeAdornmentTemplate(){return this.F!==null?this.F.Jp:null}set resizeAdornmentTemplate(t){const i=this.resizeAdornmentTemplate;i!==t&&(this.qi(),this.F.Jp=t,this.t("resizeAdornmentTemplate",i,t))}get resizeObjectName(){return this.F!==null?this.F.$p:""}set resizeObjectName(t){const i=this.resizeObjectName;i!==t&&(this.qi(),this.F.$p=t,this.t("resizeObjectName",i,t))}get resizeObject(){const t=this.resizeObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get resizeCellSize(){return this.F!==null?this.F.Zp:Size.gw}set resizeCellSize(t){const i=this.resizeCellSize;i.equals(t)||(t=t.N(),this.qi(),this.F.Zp=t,this.t("resizeCellSize",i,t))}get rotateAdornmentTemplate(){return this.F!==null?this.F.Qp:null}set rotateAdornmentTemplate(t){const i=this.rotateAdornmentTemplate;i!==t&&(this.qi(),this.F.Qp=t,this.t("rotateAdornmentTemplate",i,t))}get rotateObjectName(){return this.F!==null?this.F._p:""}set rotateObjectName(t){const i=this.rotateObjectName;i!==t&&(this.qi(),this.F._p=t,this.t("rotateObjectName",i,t))}get rotateObject(){const t=this.rotateObjectName;if(t!==""){const i=this.findObject(t);if(i!==null)return i}return this}get rotationSpot(){return this.F!==null?this.F.ty:Spot.Default}set rotationSpot(t){const i=this.rotationSpot;i.equals(t)||(t=t.N(),this.qi(),this.F.ty=t,this.t("rotationSpot",i,t))}get text(){return this.hi}set text(t){const i=this.hi;i!==t&&(this.hi=t,this.t("text",i,t))}get containingGroup(){return this.ph}set containingGroup(t){if(this.Pe()){const i=this.ph;if(i!==t){t!==null&&(this===t||t.isMemberOf(this))&&(this===t&&Util.o("Cannot make a Group a member of itself: "+this.toString()),Util.o("Cannot make a Group indirectly contain itself: "+this.toString()+" already contains "+t.toString())),this.invalidateLayout(2);const e=this.diagram;if(i!==null?i.G2(this):this instanceof Group&&e!==null&&e.Yr.delete(this),this.ph=t,t!==null?t.j2(this):this instanceof Group&&e!==null&&e.Yr.add(this),this.invalidateLayout(1),e!==null&&e.Y){const n=this.data,o=e.model;if(n!==null&&o.qc()){const r=t!==null?t.data:null;o.setGroupForData(n,o.getKeyForNodeData(r))}}const s=this.containingGroupChanged;if(s!==null){let n=!0;e!==null&&(n=e.Y,e.Y=!0),s(this,i,t),e!==null&&(e.Y=n)}if(this instanceof Group){const n=new GSet;Part.sh(n,this,!0,0,!0);const o=n.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=r.linksConnected;for(;l.next();)l.value.Ld()}}}if(this instanceof Node){const n=this.linksConnected;for(;n.next();)n.value.Ld();const o=this.labeledLink;o!==null&&o.Ld()}this.t("containingGroup",i,t),t!==null&&t.Ov()}}else Util.o("cannot set the Part.containingGroup of a Link or Adornment")}ch(){const t=this.containingGroup;t!==null&&(t.hasPlaceholder()&&t.placeholder.c(),t.c(),t.invalidateConnectedLinks())}C(){const t=this.diagram;t!==null&&!this.is()&&!this.th()&&this.isVisible()&&this.Li.isReal()&&t.C(this.Hh(this.Li))}c(){if(this.Oo())return;super.c();const t=this.diagram;t!==null&&(t.o0(this),this instanceof Node&&this.labeledLink!==null&&this.labeledLink.ef(),t.requestUpdate(!0))}ef(t){if(this.is())return;const i=this.diagram;i!==null&&(i.o0(this),this instanceof Node&&this.invalidateConnectedLinks(),i.requestUpdate()),this._n(!0)}Em(t){if(!t){const i=this.ph;i!==null&&i.j2(this)}}Bm(t){if(!t){const i=this.ph;i!==null&&i.G2(this)}}Kc(){const t=this.data;if(t!==null){const i=this.diagram;if(i!==null){const e=i.model;e!==null&&e.removeNodeData(t)}}}get containingGroupChanged(){return this.F!==null?this.F.iy:null}set containingGroupChanged(t){const i=this.containingGroupChanged;i!==t&&(t!==null&&Util.i(t,"function",Part,"containingGroupChanged"),this.qi(),this.F.iy=t,this.t("containingGroupChanged",i,t))}findSubGraphLevel(){return this.H2(this)}H2(t){const i=t.containingGroup;if(i!==null)return 1+this.H2(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.H2(e)}return 0}findTopLevelPart(){return this.q2(this)}q2(t){const i=t.containingGroup;if(i!==null)return this.q2(i);if(t instanceof Node){const e=t.labeledLink;if(e!==null)return this.q2(e)}return t}get isTopLevel(){return!(this.containingGroup!==null||this instanceof Node&&this.labeledLink!==null)}isMemberOf(t){return t instanceof Group?this.W2(this,t):!1}W2(t,i){if(t===i||i===null)return!1;const e=t.containingGroup;if(e!==null&&(e===i||this.W2(e,i)))return!0;if(t instanceof Node){const s=t.labeledLink;if(s!==null)return this.W2(s,i)}return!1}findCommonContainingGroup(t){if(t===null)return null;if(this===t)return this.containingGroup;let i=this;for(;i!==null;){if(i instanceof Group&&i.l1(!0),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}let e=null;for(i=t;i!==null;){if(i.qA()){e=i;break}if(i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}for(i=this;i!==null;){if(i instanceof Group&&i.l1(!1),i instanceof Node){const s=i.labeledLink;s!==null&&(i=s)}i=i.containingGroup}return e}get layoutConditions(){return this.F!==null?this.F.ey:127}set layoutConditions(t){const i=this.layoutConditions;i!==t&&(this.qi(),this.F.ey=t,this.t("layoutConditions",i,t))}canLayout(){if(!this.isLayoutPositioned||!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary||this instanceof Node&&this.isLinkLabel)}Uv(t){if(!this.isLayoutPositioned||!(t&this.layoutConditions))return!1;const i=this.layer;if(i!==null&&i.isTemporary||this instanceof Node&&this.isLinkLabel)return!1;const e=this.diagram;return!(e!==null&&e.undoManager.isUndoingRedoing)}invalidateLayout(t){if(t===void 0&&(t=16777215),!this.Uv(t))return;const i=this.ph;if(i!==null){const e=i.layout;e!==null?e.invalidateLayout():i.invalidateLayout(t)}else{const e=this.diagram;if(e!==null){const s=e.layout;s!==null&&s.invalidateLayout()}}}NL(){if(!this.isVisible())return!1;const t=this.layer;return!(t!==null&&t.isTemporary)}static sh(t,i,e,s,n,o){if(o===void 0&&(o=null),!t.has(i)&&!(o!==null&&!o(i))&&!(i instanceof Adornment)){if(t.add(i),i instanceof Node){if(e&&i instanceof Group){const r=i.memberParts;for(;r.next();){const l=r.value;Part.sh(t,l,e,s,n,o)}}if(n!==!1){const r=i.linksConnected;for(;r.next();){const l=r.value;if(t.has(l))continue;const h=l.fromNode,a=l.toNode,c=h===null||t.has(h),f=a===null||t.has(a);(n?c&&f:c||f)&&Part.sh(t,l,e,s,n,o)}}if(s>1){const r=i.findTreeChildrenNodes();for(;r.next();){const l=r.value;Part.sh(t,l,e,s-1,n,o)}}}else if(i instanceof Link){const r=i.labelNodes;for(;r.next();){const l=r.value;Part.sh(t,l,e,s,n,o)}}}}get dragComputation(){return this.F!==null?this.F.sy:null}set dragComputation(t){const i=this.dragComputation;i!==t&&(t!==null&&Util.i(t,"function",Part,"dragComputation"),this.qi(),this.F.sy=t,this.t("dragComputation",i,t))}get shadowOffset(){return this.F!==null?this.F.ny:Point.QN}set shadowOffset(t){const i=this.shadowOffset;i.equals(t)||(t=t.N(),this.qi(),this.F.ny=t,this.C(),this.t("shadowOffset",i,t))}get shadowColor(){return this.F!==null?this.F.oy:"gray"}set shadowColor(t){const i=this.shadowColor;i!==t&&(this.qi(),this.F.oy=t,this.C(),this.t("shadowColor",i,t))}get shadowBlur(){return this.F!==null?this.F.xn:4}set shadowBlur(t){const i=this.shadowBlur;i!==t&&(this.qi(),this.F.xn=t,this.C(),this.t("shadowBlur",i,t))}}class PartTemplateSettings{gi;zp;iy;qp;Hp;Wp;jp;Jp;$p;Zp;Qp;_p;ty;Yp;Gp;Xp;Kp;sy;ey;ny;oy;xn;constructor(){this.gi=!1,this.zp=null,this.iy=null,this.qp=null,this.Hp="",this.Wp=null,this.jp=null,this.Jp=null,this.$p="",this.Zp=Size.gw,this.Qp=null,this._p="",this.ty=Spot.Default,this.Yp="",this.Gp=Spot.TopLeft,this.Xp=Point.$N,this.Kp=Point.ZN,this.sy=null,this.ey=127,this.ny=Point.QN,this.oy="gray",this.xn=4}copy(){const t=new PartTemplateSettings;return t.zp=this.zp,t.iy=this.iy,t.qp=this.qp,t.Hp=this.Hp,t.Wp=this.Wp,t.jp=this.jp,t.Jp=this.Jp,t.$p=this.$p,t.Zp=this.Zp.N(),t.Qp=this.Qp,t._p=this._p,t.ty=this.ty.N(),t.Yp=this.Yp,t.Gp=this.Gp.N(),t.Xp=this.Xp.N(),t.Kp=this.Kp.N(),t.sy=this.sy,t.ey=this.ey,t.ny=this.ny.N(),t.oy=this.oy,t.xn=this.xn,t}}class Adornment extends Part{us;It;JP;$P;hf;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.P&=-257,this.ll="Adornment",this.us=null,this.JP=0,this.$P=!1,this.It=null,this.hf=null,i&&Object.assign(this,i)}toString(){const t=this.adornedPart;return"Adornment("+this.category+")"+(t!==null?t.toString():"")}updateRelationshipsFromData(){}hd(t){const i=this.adornedObject,e=i?.part;if(!(e instanceof Link)||!(i instanceof Shape))return;const s=e.path;let n=s.geometry;e.hd(t),n=s.geometry;const o=this.L.r,r=o.length;for(let l=0;lh instanceof Placeholder);l instanceof Placeholder&&this.It===null&&(this.It=l)}}else t===4&&i==="elements"&&this.It!==null&&(s===this.It?this.It=null:s instanceof Panel&&this.It.isContainedBy(s)&&(this.It=null));super.Jc(t,i,e,s,n,o,r)}updateAdornments(){}Kc(){}}var PortSpreading=(w=>(w[w.None=0]="None",w[w.Evenly=1]="Evenly",w[w.Packed=2]="Packed",w))(PortSpreading||{});class Node extends Part{E;gt;kf;al;yh;ne;_t;constructor(t,i){let e;t===void 0||t instanceof PanelLayout||typeof t=="string"?e=t:t&&(i=t),super(e),this.E=13,this.gt=null,this._t=new List,this.kf=null,this.al=null,this.ne=null,this.yh=!1,i&&Object.assign(this,i)}cloneProtected(t){super.cloneProtected(t),t.E=this.E,this.gt!==null&&(this.gt.gi?t.gt=this.gt:t.gt=this.gt.copy())}Vo(t){super.Vo(t),t.invalidateConnectedLinks(),t.al=this.al,t.ne=null}static SpreadingNone=0;static SpreadingEvenly=1;static SpreadingPacked=2;cl(){this.gt===null?this.gt=new NodeTemplateSettings:this.gt.gi&&(this.gt=this.gt.copy())}lh(){super.lh(),this.gt!==null&&(this.gt.gi=!0)}WA(t){t!==null&&(this.al===null&&(this.al=new GSet),this.al.add(t))}JA(t){t!==null&&this.al!==null&&this.al.delete(t)}$A(t,i,e){if(t===null||this.al===null)return null;const s=this.al.iterator;for(;s.next();){const n=s.value;if(n.ry===this&&n.h1===t&&n.J2===i&&n.$2===e||n.ry===t&&n.h1===this&&n.J2===e&&n.$2===i)return n}return null}invalidateLinkBundle(t,i,e){i==null&&(i=""),e==null&&(e="");const s=this.$A(t,i,e);s!==null&&s.Ad()}Jc(t,i,e,s,n,o,r){t===3&&i==="elements"?this.ne=null:t===4&&i==="elements"&&(this.ne=null),super.Jc(t,i,e,s,n,o,r)}invalidateConnectedLinks(t){const i=this.linksConnected;for(;i.next();){const e=i.value;t!==void 0&&t.has(e)||(this.Wi(e.fromPort),this.Wi(e.toPort),e.invalidateRoute())}}tA(t){const i=this.linksConnected;for(;i.next();){const e=i.value;e.fromPort!==t&&e.toPort!==t||(this.Wi(e.fromPort),this.Wi(e.toPort),e.invalidateRoute())}}Wi(t){if(t===null)return;const i=t.Ju;i!==null&&i.Ad();const e=t.part,s=e.containingGroup;s!==null&&!e.isVisible()&&s.Wi(s.port)}Hr(){return!0}get portSpreading(){return this.gt!==null?this.gt.ly:1}set portSpreading(t){const i=this.portSpreading;if(i!==t){this.cl(),this.gt.ly=t,this.t("portSpreading",i,t);const e=this.diagram;if(e!==null&&e.undoManager.isUndoingRedoing)return;this.invalidateConnectedLinks()}}get avoidable(){return(this.E&8)!==0}set avoidable(t){const i=(this.E&8)!==0;if(i!==t){this.E=this.E^8;const e=this.diagram;e!==null&&e.EM(this),this.t("avoidable",i,t)}}get avoidableMargin(){return this.gt!==null?this.gt.hy:Margin.oC}set avoidableMargin(t){typeof t=="number"&&(t=new Margin(t));const i=this.avoidableMargin;if(!i.equals(t)){t=t.N(),this.cl(),this.gt.hy=t;const e=this.diagram;e!==null&&e.EM(this),this.t("avoidableMargin",i,t)}}canAvoid(){return this.avoidable&&!this.isLinkLabel}getAvoidableRect(t){return t.set(this.actualBounds),t.addMargin(this.avoidableMargin),t}findVisibleNode(){let t=this;for(;t!==null&&!t.isVisible();)t=t.containingGroup;return t}isVisible(){if(!super.isVisible())return!1;let t=!0,i=1;const e=this.diagram;if(e!==null){if(e.animationManager.nx(this))return!0;t=e.isTreePathToChildren,i=e.treeCollapsePolicy}if(i===1){const n=this.findTreeParentNode();if(n!==null&&!n.isTreeExpanded)return!1}else if(i===2){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&h.isTreeExpanded){r=!0;break}}}if(o&&!r)return!1}else if(i===3){const n=t?this.findLinksInto():this.findLinksOutOf();let o=!1,r=!1;for(;n.next();){const l=n.value;if(l.isTreeLink){o=!0;const h=t?l.fromNode:l.toNode;if(h&&!h.isTreeExpanded){r=!0;break}}}if(o&&r)return!1}const s=this.labeledLink;return s!==null?s.isVisible():!0}Ei(t){super.Ei(t);const i=this.linksConnected;for(;i.next();){const e=i.value;if(t&&this.containingGroup!==null){const s=e.getOtherNode(this);s!==null&&!s.isMemberOf(this.containingGroup)&&e.invalidateRoute()}e.Ei(t)}}get linksConnected(){return this._t.iterator}findExternalTreeLinksConnected(){const t=new GSet,i=new GSet;return this.ZA(this,t,i),i.iterator}ZA(t,i,e){if(t===null||i.has(t))return;i.add(t);let s=!0;const n=this.diagram;n!==null&&(s=n.isTreePathToChildren),t.linksConnected.each(o=>{o.isTreeLink?(s?o.fromNode===t:o.toNode===t)&&this.ZA(s?o.toNode:o.fromNode,i,e):e.add(o)})}findLinksConnected(t){if(t===void 0&&(t=null),t===null)return this._t.iterator;const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.fromNode===e&&s.fromPortId===t||s.toNode===e&&s.toPortId===t,i}findLinksOutOf(t){t===void 0&&(t=null);const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.fromNode!==e?!1:t===null?!0:s.fromPortId===t,i}findLinksInto(t){t===void 0&&(t=null);const i=new ListIterator(this._t),e=this;return i.predicate=s=>s.toNode!==e?!1:t===null?!0:s.toPortId===t,i}findNodesConnected(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this){if(t===null||n.fromPortId===t){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}else if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesOutOf(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.fromNode===this&&(t===null||n.fromPortId===t)){const o=n.toNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findNodesInto(t){t===void 0&&(t=null);let i=null,e=null;const s=this._t.iterator;for(;s.next();){const n=s.value;if(n.toNode===this&&(t===null||n.toPortId===t)){const o=n.fromNode;i!==null?i.add(o):e!==null&&e!==o?(i=new GSet,i.add(e),i.add(o)):e=o}}return i!==null?i.iterator:e!==null?new SingletonIterator(e):EmptyIterator.instance}findLinksBetween(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null);const s=new ListIterator(this._t),n=this;return s.predicate=o=>o.fromNode===n&&o.toNode===t&&(i===null||o.fromPortId===i)&&(e===null||o.toPortId===e)||o.fromNode===t&&o.toNode===n&&(e===null||o.fromPortId===e)&&(i===null||o.toPortId===i),s}findLinksTo(t,i,e){i===void 0&&(i=null),e===void 0&&(e=null);const s=new ListIterator(this._t),n=this;return s.predicate=o=>!(o.fromNode!==n||o.toNode!==t||i!==null&&o.fromPortId!==i||e!==null&&o.toPortId!==e),s}get linkConnected(){return this.gt!==null?this.gt.ay:null}set linkConnected(t){const i=this.linkConnected;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkConnected"),this.cl(),this.gt.ay=t,this.t("linkConnected",i,t))}get linkDisconnected(){return this.gt!==null?this.gt.cy:null}set linkDisconnected(t){const i=this.linkDisconnected;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkDisconnected"),this.cl(),this.gt.cy=t,this.t("linkDisconnected",i,t))}get linkValidation(){return this.gt!==null?this.gt.Ml:null}set linkValidation(t){const i=this.linkValidation;i!==t&&(t!==null&&Util.i(t,"function",Node,"linkValidation"),this.cl(),this.gt.Ml=t,this.t("linkValidation",i,t))}a1(t,i){this.Wi(i);const e=this._t.has(t);if(e||this._t.add(t),!e||t.fromNode===t.toNode){const s=this.linkConnected;if(s!==null){let n=!0;const o=this.diagram;o!==null&&(n=o.Y,o.Y=!0),s(this,t,i),o!==null&&(o.Y=n)}}if(!e){if(!t.isTreeLink)return;const s=t.fromNode,n=t.toNode;if(s!==null&&n!==null&&s!==n){let o=!0;const r=this.diagram;r!==null&&(o=r.isTreePathToChildren);const l=o?n:s,h=o?s:n;if(l.yh||(l.yh=h),h.isTreeLeaf){if(r!==null&&r.undoManager.isUndoingRedoing)return;o?s===h&&(h.isTreeLeaf=!1):n===h&&(h.isTreeLeaf=!1)}}}}c1(t,i){this.Wi(i);const e=this._t.delete(t);let s=null;if(e||t.toNode===t.fromNode){const n=this.linkDisconnected;if(s=this.diagram,n!==null){let o=!0;s!==null&&(o=s.Y,s.Y=!0),n(this,t,i),s!==null&&(s.Y=o)}}if(e){if(!t.isTreeLink)return;let n=!0;s!==null&&(n=s.isTreePathToChildren);const o=n?t.toNode:t.fromNode,r=n?t.fromNode:t.toNode;if(o!==null&&(o.yh=!1),r!==null&&!r.isTreeLeaf)if(r._t.count===0){if(r.yh=null,s!==null&&s.undoManager.isUndoingRedoing)return;r.isTreeLeaf=!0}else r.f0()}}f0(){if(this.yh=!1,this._t.count===0)return;let t=!0;const i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;i!==null&&(t=i.isTreePathToChildren);const e=this._t.iterator;for(;e.next();){const s=e.value;if(s.isTreeLink){if(t){if(s.fromNode===this){this.isTreeLeaf=!1;return}}else if(s.toNode===this){this.isTreeLeaf=!1;return}}}this.isTreeLeaf=!0}updateRelationshipsFromData(){const t=this.diagram;t!==null&&t.partManager.updateRelationshipsFromData(this)}Em(t){if(super.Em(t),!t){this.f0();const i=this.kf;i!==null&&i.QA(this)}}Bm(t){if(super.Bm(t),!t){const i=this.kf;i!==null&&i._A(this)}}Kc(){if(this._t.count>0){const t=this.diagram;if(t!==null){const i=t.commandHandler!==null?t.commandHandler.deletesConnectedLinks:!0,s=this._t.copy().iterator;for(;s.next();){const n=s.value;i?t.remove(n):(n.fromNode===this&&(n.fromNode=null),n.toNode===this&&(n.toNode=null))}}}this.labeledLink=null,super.Kc()}get isLinkLabel(){return this.kf!==null}get labeledLink(){return this.kf}set labeledLink(t){const i=this.kf;if(i!==t){const e=this.diagram,s=this.data;if(i!==null){if(i._A(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=i.data,o=e.model;if(n!==null&&o.Ta()){const r=o.getKeyForNodeData(s);r!==void 0&&o.removeLabelKeyForLinkData(n,r)}}this.containingGroup=null}if(this.kf=t,t!==null){if(t.QA(this),e!==null&&s!==null&&!e.undoManager.isUndoingRedoing){const n=t.data,o=e.model;if(n!==null&&o.Ta()){const r=o.getKeyForNodeData(s);r!==void 0&&o.addLabelKeyForLinkData(n,r)}}this.containingGroup=t.containingGroup}this.ef(),this.t("labeledLink",i,t)}}findVisiblePort(t){let i=t;for(;i!==null&&(!i.actualBounds.isReal()||!i.isVisibleObject());)i=i.panel;return i===null?this.port:i}findPort(t){if(this.ne===null){if(t===""&&this.wn===!1)return this;this.tT()}let i=this.ne.get(t);return i!==null||t!==""&&(i=this.ne.get(""),i!==null)?i:this}get port(){return this.findPort("")}get ports(){return this.ne===null&&this.tT(),this.ne.iteratorValues}tT(){this.ne===null?this.ne=new GMap:this.ne.clear(),this.walkVisualTreeFrom(this,(t,i)=>t.hA(i)),this.ne.count===0&&this.ne.set("",this)}hA(t){const i=t.portId;i!==null&&this.ne!==null&&this.ne.set(i,t)}u2(t,i){const e=t.portId;if(e!==null){this.ne!==null&&this.ne.delete(e);const s=this.diagram;if(s!==null&&i){let n=null;const o=this.findLinksConnected(e);for(;o.next();){const r=o.value;n===null&&(n=Util.nt()),n.push(r)}if(n!==null){for(let r=0;r!(!n.isTreeLink||n.fromNode!==s):e.predicate=n=>!(!n.isTreeLink||n.toNode!==s),e}findTreeChildrenNodes(){let t=!0;const i=this.diagram;i!==null&&(t=i.isTreePathToChildren);let e=null,s=null;const n=this._t.iterator;if(t)for(;n.next();){const o=n.value;if(o.isTreeLink&&o.fromNode===this){const r=o.toNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}else for(;n.next();){const o=n.value;if(o.isTreeLink&&o.toNode===this){const r=o.fromNode;e!==null?e.add(r):s!==null&&s!==r?(e=new List,e.add(s),e.add(r)):s=r}}return e!==null?e.iterator:s!==null?new SingletonIterator(s):EmptyIterator.instance}findTreeParts(t){t===void 0&&(t=1/0),Util.i(t,"number",Node,"findTreeParts:level");const i=new GSet;return Part.sh(i,this,!1,t,!0),i}collapseTree(t){t===void 0&&(t=1),t<1&&(t=1);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.iT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}iT(t,i,e,s,n,o){if(e>1){const r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);h!==null&&h!==this&&!t.has(h)&&(t.add(h),h.iT(t,i,e-1,s,n,o))}}else this.eT(t,i,s,n,o)}eT(t,i,e,s,n){const o=s===this?!0:this.isTreeExpanded,r=i?this.findLinksOutOf():this.findLinksInto();for(;r.next();){const l=r.value;if(!l.isTreeLink)continue;const h=l.getOtherNode(this);if(h!==null&&h!==this){const a=t.has(h);if(a||t.add(h),o){const c=i?h.findNodesInto():h.findNodesOutOf(),f=this;c.all(u=>u===f||!u.isTreeExpanded)&&e.Lc(h,s),h.ch(),h.Ei(!1)}h.isTreeExpanded&&(h.wasTreeExpanded=h.isTreeExpanded,a||h.eT(t,i,e,s,n))}}this.isTreeExpanded=!1}expandTree(t){t===void 0&&(t=2),t<2&&(t=2);const i=this.diagram;if(i===null||i.isCollapsingExpanding)return;i.isCollapsingExpanding=!0;const e=new GSet;e.add(this),this.sT(e,i.isTreePathToChildren,t,i,this,i.treeCollapsePolicy===1),i.isCollapsingExpanding=!1}sT(t,i,e,s,n,o){const r=n===this?!1:this.isTreeExpanded,l=i?this.findLinksOutOf():this.findLinksInto();for(;l.next();){const h=l.value;if(!h.isTreeLink)continue;r||h.Me||h.invalidateRoute();const a=h.getOtherNode(this);if(a!==null&&a!==this&&!t.has(a)){if(t.add(a),!r){a.Ei(!0),a.ch();const c=i?a.findNodesInto():a.findNodesOutOf(),f=this;c.all(u=>u===f||!u.isTreeExpanded)&&s.Cc(a,n)}(e>2||a.wasTreeExpanded)&&(a.wasTreeExpanded=!1,a.sT(t,i,e-1,s,n,o))}}this.isTreeExpanded=!0}get isTreeExpanded(){return(this.E&1)!==0}set isTreeExpanded(t){const i=(this.E&1)!==0;if(i!==t){this.E=this.E^1;const e=this.diagram;this.t("isTreeExpanded",i,t);const s=this.treeExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.Y,e.Y=!0),s(this),e!==null&&(e.Y=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.Ei(t);return}t?this.expandTree():this.collapseTree()}}get wasTreeExpanded(){return(this.E&2)!==0}set wasTreeExpanded(t){const i=(this.E&2)!==0;i!==t&&(this.E=this.E^2,this.t("wasTreeExpanded",i,t))}get treeExpandedChanged(){return this.gt!==null?this.gt.fy:null}set treeExpandedChanged(t){const i=this.treeExpandedChanged;i!==t&&(t!==null&&Util.i(t,"function",Node,"treeExpandedChanged"),this.cl(),this.gt.fy=t,this.t("treeExpandedChanged",i,t))}get isTreeLeaf(){return(this.E&4)!==0}set isTreeLeaf(t){const i=(this.E&4)!==0;i!==t&&(this.E=this.E^4,this.t("isTreeLeaf",i,t))}get isTreeRoot(){return this.findTreeParentLink()===null}}class NodeTemplateSettings{gi;ay;cy;Ml;fy;hy;ly;uy;gy;eh;my;constructor(){this.gi=!1,this.ay=null,this.cy=null,this.Ml=null,this.fy=null,this.hy=Margin.oC,this.ly=1,this.uy=null,this.gy=null,this.eh=null,this.my=null}copy(){const t=new NodeTemplateSettings;return t.ay=this.ay,t.cy=this.cy,t.Ml=this.Ml,t.fy=this.fy,t.hy=this.hy.N(),t.ly=this.ly,t.uy=this.uy,t.gy=this.gy,t.eh=this.eh,t.my=this.my,t}}var LinkAdjusting=(w=>(w[w.None=0]="None",w[w.End=17]="End",w[w.Scale=18]="Scale",w[w.Stretch=19]="Stretch",w))(LinkAdjusting||{}),Routing=(w=>(w[w.Normal=1]="Normal",w[w.Orthogonal=2]="Orthogonal",w[w.AvoidsNodes=6]="AvoidsNodes",w[w.AvoidsNodesStraight=7]="AvoidsNodesStraight",w))(Routing||{}),Curve=(w=>(w[w.None=0]="None",w[w.Bezier=9]="Bezier",w[w.JumpGap=10]="JumpGap",w[w.JumpOver=11]="JumpOver",w))(Curve||{});class Link extends Part{Nt;lo;ho;Td;ao;co;Dd;Pf;Fd;Rd;vd;Da;Od;Hs;ki;fl;Sr;Sf;$o;Z2;Q2;f1;_2;tN;py;u1;ct;Zo;static Fa=null;static Ra=null;hf;iN;eN;constructor(t){super(Panel.Link),this.Nt=8,this.lo=null,this.ho="",this.Td=null,this.ao=null,this.co="",this.Dd=null,this.Pf=0,this.Fd=0,this.Rd=0,this.vd=NaN,this.Da=1,this.Od=.5,this.Hs=null,this.ki=new List().g(),this.fl=null,this.Sr=null,this.Sf=new Rect,this.ct=new Geometry,this.$o=null,this.Zo=null,this.Z2=null,this.Q2=null,this.iN=0,this.eN=0,this.f1=new Point,this._2=null,this.tN=null,this.py=null,this.u1=NaN,this.q=null,this.hf=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Nt=this.Nt&-113,t.ho=this.ho,t.Td=this.Td,t.co=this.co,t.Dd=this.Dd,t.Pf=this.Pf,t.Fd=this.Fd,t.Rd=this.Rd,t.vd=this.vd,t.Da=this.Da,t.Od=this.Od,this.q!==null&&(t.q=this.q.copy())}Vo(t){super.Vo(t),this.ho=t.ho,this.co=t.co,t.fl=null,t.invalidateRoute(),t.Zo=this.Zo;const i=t.fromPort;i!==null&&t.fromNode.Wi(i);const e=t.toPort;e!==null&&t.toNode.Wi(e)}ri(t){t in Routing||t in Curve||t in LinkAdjusting?Link.sN(t)?this.routing=t:t===9||t===10||t===11?this.curve=t:t===17||t===18||t===19?this.adjusting=t:t===1||t===0||Util.o("Unknown Link enum value for a Link property: "+t):super.ri(t)}static Normal=1;static Orthogonal=2;static AvoidsNodes=6;static AvoidsNodesStraight=7;static None=0;static Bezier=9;static JumpGap=10;static JumpOver=11;static End=17;static Scale=18;static Stretch=19;static OrientAlong=21;static OrientPlus90=22;static OrientMinus90=23;static OrientOpposite=24;static OrientUpright=25;static OrientPlus90Upright=26;static OrientMinus90Upright=27;static OrientUpright45=28;static zv=8;static Xv=16;static Kv=14;static va=8;Xe(){this.q===null&&(this.q=new LinkSettings)}QR(t,i,e){const s=t.segmentIndex,n=t.segmentFraction;let o=t.alignmentFocus;const r=t.segmentOrientation,l=t.segmentOffset;let h=0,a=0,c=0,f=0;if(isNaN(s)){const C=this.ct,M=Util.nt();C.getPointAndAngleAlongPath(n,M);const N=Point.X(M[0],M[1]);if(N.add(this.getPoint(0)),C.type===1)N.offset(-C.startX,-C.startY);else{const T=C.figures.first();N.offset(-T.startX,-T.startY)}f=M[2],r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=N.x,a=N.y,Point.s(N),Util.tt(M)}else if(s<-i||s>=i){const C=Point.l();this.mA(C),f=this.midAngle,r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=C.x,a=C.y,Point.s(C)}else{let C,M,N=0;if(s>=0?(C=e.r[s],M=s0?e.r[N-1]:C),C.equalsApprox(M)){let T,A;s>=0?(T=s>0?e.r[s-1]:C,A=s1?e.r[N-2]:M);const D=T.distanceSquaredPoint(C),F=M.distanceSquaredPoint(A);D>F+10?f=s>=0?T.directionPoint(C):C.directionPoint(T):F>D+10?f=s>=0?M.directionPoint(A):A.directionPoint(M):f=s>=0?T.directionPoint(A):A.directionPoint(T)}else f=s>=0?C.directionPoint(M):M.directionPoint(C);r!==0&&(c=this.computeAngle(t,r,f),t.angle=c),h=C.x+(M.x-C.x)*n,a=C.y+(M.y-C.y)*n}if(o.isNone()){t.location=new Point(h,a);return}else o.isNoSpot()&&(o=Spot.Center);const u=Transform.l();u.Ri(),u.et(t.scale,t.scale),u.cs(t.angle,0,0);const d=t.naturalBounds,m=Rect.X(0,0,d.width,d.height),g=Point.l();g.setRectSpot(m,o),u.xt(g);let p=-g.x,y=-g.y;const x=d.width,k=d.height,b=Point.l();b.a(l);const P=isNaN(l.x),S=isNaN(l.y);if(P||S){const C=x/2+3,M=k/2+3,N=f>=45&&f<=135,T=f>=225&&f<=315;r===0&&(N||T)?(b.x=S?C:l.y,b.y=P?M:l.x,N?s>=0||isNaN(s)&&n<.5||P&&(b.y=-M):T&&((s>=0||isNaN(s)&&n<.5)&&P&&(b.y=-M),S&&(b.x=-C))):(P&&(s>=0||isNaN(s)&&n<.5?b.x=C:b.x=-C),S&&(b.y=-M),b.rotate(f))}else b.rotate(f);h+=b.x,a+=b.y,u.xw(m),p+=m.x,y+=m.y;const L=Point.X(h+p,a+y);t.move(L),Point.s(L),Point.s(b),Point.s(g),Rect.s(m),Transform.s(u)}Hr(){let t=this.fromNode;if(t!==null){const e=t.findVisibleNode();if(e!==null&&(t=e),t.is()||t.th())return!1}let i=this.toNode;if(i!==null){const e=i.findVisibleNode();if(e!==null&&(i=e),i.is()||i.th())return!1}return!0}c2(t,i,e){return!1}f2(){}Pe(){return!1}computeAngle(t,i,e){return Link.computeAngle(i,e)}static computeAngle(t,i){let e=0;switch(t){default:case 0:e=0;break;case 21:e=i;break;case 22:e=i+90;break;case 23:e=i-90;break;case 24:e=i+180;break;case 25:e=Geo.zg(i),e>90&&e<270&&(e-=180);break;case 26:e=Geo.zg(i+90),e>90&&e<270&&(e-=180);break;case 27:e=Geo.zg(i-90),e>90&&e<270&&(e-=180);break;case 28:if(e=Geo.zg(i),e>45&&e<135||e>225&&e<315)return 0;e>90&&e<270&&(e-=180);break}return Geo.zg(e)}get fromNode(){return this.lo}set fromNode(t){const i=this.lo;if(i!==t){const e=this.fromPort;i!==null&&(this.ao!==i&&i.c1(this,e),this.yy(),this.invalidateLayout(2)),this.lo=t,t!==null&&this.Ei(t.isVisible()),this.$o=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.Y&&s.partManager.setFromNodeForLink(this,t,i);const n=this.fromPort,o=this.fromPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.Y,s.Y=!0),o(this,e,n),s!==null&&(s.Y=r)}t!==null&&(this.ao!==t&&t.a1(this,n),this.wy(),this.invalidateLayout(1)),this.t("fromNode",i,t),this.Ld()}}get fromPortId(){return this.ho}set fromPortId(t){const i=this.ho;if(i!==t){const e=this.fromPort;e!==null&&this.fromNode.Wi(e),this.yy(),this.ho=t;const s=this.fromPort;s!==null&&this.fromNode.Wi(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Ta()&&r.setFromPortIdForLinkData(o,t)}if(e!==s){this.$o=null,this.invalidateRoute();const o=this.fromPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.Y,n.Y=!0),o(this,e,s),n!==null&&(n.Y=r)}}this.wy(),this.t("fromPortId",i,t)}}get fromPort(){const t=this.lo;if(t===null)return null;const i=this.ho;return t.findPort(i)}get fromPortChanged(){return this.Td}set fromPortChanged(t){const i=this.Td;i!==t&&(t!==null&&Util.i(t,"function",Link,"fromPortChanged"),this.Td=t,this.t("fromPortChanged",i,t))}get toNode(){return this.ao}set toNode(t){const i=this.ao;if(i!==t){const e=this.toPort;i!==null&&(this.lo!==i&&i.c1(this,e),this.yy(),this.invalidateLayout(2)),this.ao=t,t!==null&&this.Ei(t.isVisible()),this.$o=null,this.invalidateRoute();const s=this.diagram;s!==null&&s.Y&&s.partManager.setToNodeForLink(this,t,i);const n=this.toPort,o=this.toPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.Y,s.Y=!0),o(this,e,n),s!==null&&(s.Y=r)}t!==null&&(this.lo!==t&&t.a1(this,n),this.wy(),this.invalidateLayout(1)),this.t("toNode",i,t),this.Ld()}}get toPortId(){return this.co}set toPortId(t){const i=this.co;if(i!==t){const e=this.toPort;e!==null&&this.toNode.Wi(e),this.yy(),this.co=t;const s=this.toPort;s!==null&&this.toNode.Wi(s);const n=this.diagram;if(n!==null){const o=this.data,r=n.model;o!==null&&r.Ta()&&r.setToPortIdForLinkData(o,t)}if(e!==s){this.$o=null,this.invalidateRoute();const o=this.toPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.Y,n.Y=!0),o(this,e,s),n!==null&&(n.Y=r)}}this.wy(),this.t("toPortId",i,t)}}get toPort(){const t=this.ao;if(t===null)return null;const i=this.co;return t.findPort(i)}get toPortChanged(){return this.Dd}set toPortChanged(t){const i=this.Dd;i!==t&&(t!==null&&Util.i(t,"function",Link,"toPortChanged"),this.Dd=t,this.t("toPortChanged",i,t))}get fromSpot(){return this.q!==null?this.q.fa:Spot.Default}set fromSpot(t){const i=this.fromSpot;if(!i.equals(t)){if(t=t.N(),this.Xe(),this.q.fa=t,this.t("fromSpot",i,t),i.isSide()||t.isSide()){const e=this.fromNode;e!==null&&e.Wi(this.fromPort)}this.invalidateRoute()}}get fromEndSegmentLength(){return this.q!==null?this.q.da:NaN}set fromEndSegmentLength(t){const i=this.fromEndSegmentLength;if(i!==t){if(t<0&&Util._(t,">= 0",Link,"fromEndSegmentLength"),this.Xe(),this.q.da=t,this.t("fromEndSegmentLength",i,t),this.computeSpot(!0,this.fromPort).isSide()){const e=this.fromNode;e!==null&&e.Wi(this.fromPort)}this.invalidateRoute()}}get fromShortLength(){return this.q!==null?this.q.ma:NaN}set fromShortLength(t){const i=this.fromShortLength;i!==t&&(this.Xe(),this.q.ma=t,this.ee(),this.t("fromShortLength",i,t))}get toSpot(){return this.q!==null?this.q.ua:Spot.Default}set toSpot(t){const i=this.toSpot;if(!i.equals(t)){if(t=t.N(),this.Xe(),this.q.ua=t,this.t("toSpot",i,t),i.isSide()||t.isSide()){const e=this.toNode;e!==null&&e.Wi(this.toPort)}this.invalidateRoute()}}get toEndSegmentLength(){return this.q!==null?this.q.ga:NaN}set toEndSegmentLength(t){const i=this.toEndSegmentLength;if(i!==t){if(t<0&&Util._(t,">= 0",Link,"toEndSegmentLength"),this.Xe(),this.q.ga=t,this.t("toEndSegmentLength",i,t),this.computeSpot(!1,this.toPort).isSide()){const e=this.toNode;e!==null&&e.Wi(this.toPort)}this.invalidateRoute()}}get toShortLength(){return this.q!==null?this.q.pa:NaN}set toShortLength(t){const i=this.toShortLength;i!==t&&(this.Xe(),this.q.pa=t,this.ee(),this.t("toShortLength",i,t))}Ld(){const t=this.fromNode,i=this.toNode;let e=null;if(t!==null?i!==null?e=t.findCommonContainingGroup(i):e=t.containingGroup:i!==null?e=i.containingGroup:e=null,this.Yv(e),this.isLabeledLink){const s=this.labelNodes;for(;s.next();){const n=s.value;n.containingGroup=e}}}Yv(t){const i=this.ph;if(i!==t){i!==null&&i.G2(this),this.ph=t,t!==null&&t.j2(this);const e=this.containingGroupChanged;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.Y,n.Y=!0),e(this,i,t),n!==null&&(n.Y=s)}this.Me&&(this._2===i||this.tN===i)&&this.invalidateRoute()}}ch(){const t=this.containingGroup;t!==null&&this.fromNode!==t&&this.toNode!==t&&t.computesBoundsIncludingLinks&&super.ch()}getOtherNode(t){const i=this.fromNode;return t===i?this.toNode:i}getOtherPort(t){const i=this.fromPort;return t===i?this.toPort:i}get isLabeledLink(){return this.Hs===null?!1:this.Hs.count>0}get labelNodes(){return this.Hs===null?EmptyIterator.instance:this.Hs.iterator}QA(t){this.Hs===null&&(this.Hs=new GSet),this.Hs.add(t),this.c()}_A(t){this.Hs!==null&&(this.Hs.delete(t),this.c())}Em(t){if(super.Em(t),this.Oa()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.lo;let e=null;i!==null&&(e=this.fromPort,i.a1(this,e));const s=this.ao;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.a1(this,n)),this.wy()}}Bm(t){if(super.Bm(t),this.Oa()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){const i=this.lo;let e=null;i!==null&&(e=this.fromPort,i.c1(this,e));const s=this.ao;let n=null;s!==null&&(n=this.toPort,(s!==i||n!==e)&&s.c1(this,n)),this.yy()}}Kc(){if(this.Me=!0,this.Hs!==null){const i=this.diagram;if(i!==null){const s=this.Hs.copy().iterator;for(;s.next();){const n=s.value;i.remove(n)}}}if(this.data!==null){const i=this.diagram;i!==null&&i.partManager.nN(this)}}updateRelationshipsFromData(){if(this.data===null)return;const i=this.diagram;i!==null&&i.partManager.updateRelationshipsFromData(this)}move(t,i){const e=i?this.location:this.position;let s=e.x;isNaN(s)&&(s=0);let n=e.y;isNaN(n)&&(n=0);const o=t.x-s,r=t.y-n;if(i===!0)super.move(t,!1);else{const h=Point.X(e.x+o,e.y+r);super.move(h,!1),Point.s(h)}this.pr(o,r);const l=this.labelNodes;for(;l.next();){const h=l.value,a=h.position;h.moveTo(a.x+o,a.y+r)}}get relinkableFrom(){return(this.Nt&1)!==0}set relinkableFrom(t){const i=(this.Nt&1)!==0;i!==t&&(this.Nt=this.Nt^1,this.t("relinkableFrom",i,t),this.invalidateAdornments())}get relinkableTo(){return(this.Nt&2)!==0}set relinkableTo(t){const i=(this.Nt&2)!==0;i!==t&&(this.Nt=this.Nt^2,this.t("relinkableTo",i,t),this.invalidateAdornments())}canRelinkFrom(){if(!this.relinkableFrom)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}canRelinkTo(){if(!this.relinkableTo)return!1;const t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;const i=t.diagram;return!(i!==null&&!i.allowRelink)}get resegmentable(){return(this.Nt&4)!==0}set resegmentable(t){const i=(this.Nt&4)!==0;i!==t&&(this.Nt=this.Nt^4,this.t("resegmentable",i,t),this.invalidateAdornments())}get isTreeLink(){return(this.Nt&8)!==0}set isTreeLink(t){const i=(this.Nt&8)!==0;i!==t&&(this.Nt=this.Nt^8,this.t("isTreeLink",i,t),this.fromNode!==null&&this.fromNode.f0(),this.toNode!==null&&this.toNode.f0())}get path(){const t=this.findMainElement();return t instanceof Shape?t:null}get routeBounds(){return this.updateRoute(),this.Gv(this.Sf)}Gv(t){let i=1/0,e=1/0;const s=this.pointsCount;if(s===0)return t.e(NaN,NaN,0,0),t;if(s===1){const n=this.getPoint(0);i=Math.min(n.x,i),e=Math.min(n.y,e),t.e(n.x,n.y,0,0)}else if(s===2){const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o)}else if(this.computeCurve()===9&&s>=3&&!this.isOrthogonal){let n=this.getPoint(0);if(i=n.x,e=n.y,t.e(i,e,0,0),s===3){const o=this.getPoint(1);i=Math.min(o.x,i),e=Math.min(o.y,e);const r=this.getPoint(2);i=Math.min(r.x,i),e=Math.min(r.y,e),Geo.hu(n.x,n.y,o.x,o.y,o.x,o.y,r.x,r.y,.5,t)}else for(let o=3;o=s&&(o=s-1);const l=this.getPoint(o-1),h=this.getPoint(o);Geo.hu(n.x,n.y,r.x,r.y,l.x,l.y,h.x,h.y,.5,t),i=Math.min(h.x,i),e=Math.min(h.y,e),n=h}}else{const n=this.getPoint(0),o=this.getPoint(1);i=Math.min(n.x,o.x),e=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o);for(let r=2;r=15||this.computeCurve()===9)){this.ct.getPointAlongPath(.5,t),t.add(this.getPoint(0));const a=this.ct.figures.first();return t.offset(-a.startX,-a.startY),t}if(this.computeCurve()===9){if(i===3){const f=this.getPoint(0),u=this.getPoint(1),d=this.getPoint(2);return Geo.fC(f.x,f.y,u.x,u.y,u.x,u.y,d.x,d.y,t),t}const a=(i-1)/3|0,c=(a/2|0)*3;if(a%2===1){const f=this.getPoint(c),u=this.getPoint(c+1),d=this.getPoint(c+2),m=this.getPoint(c+3);return Geo.fC(f.x,f.y,u.x,u.y,d.x,d.y,m.x,m.y,t),t}else return t.a(this.getPoint(c)),t}const e=this.flattenedLengths,s=this.flattenedTotalLength;let n=0,o=0,r=0;for(;ns/2));)n+=r,o++;const l=this.getPoint(o),h=this.getPoint(o+1);if(Math.abs(l.x-h.x)<1)l.y>h.y?t.e(l.x,l.y-(s/2-n)):t.e(l.x,l.y+(s/2-n));else if(Math.abs(l.y-h.y)<1)l.x>h.x?t.e(l.x-(s/2-n),l.y):t.e(l.x+(s/2-n),l.y);else{const a=(s/2-n)/r,c=a*(h.x-l.x),f=a*(h.y-l.y);t.e(l.x+c,l.y+f)}return t}get midAngle(){return this.updateRoute(),this.computeMidAngle()}computeMidAngle(){const t=this.pointsCount;if(t<2)return NaN;if(t===2){const h=this.getPoint(0),a=this.getPoint(1);return h.directionPoint(a)}if(this.isOrthogonal&&(this.computeCorner()>=15||this.computeCurve()===9))return this.ct.getAngleAlongPath(.5);if(this.computeCurve()===9&&t>=4){const h=(t-1)/3|0;let a=(h/2|0)*3;if(h%2===1){a=Math.floor(a);const c=this.getPoint(a),f=this.getPoint(a+1),u=this.getPoint(a+2),d=this.getPoint(a+3);return Geo.FD(c.x,c.y,f.x,f.y,u.x,u.y,d.x,d.y)}else if(a>0&&a+1e/2));)s+=o,n++;const r=this.getPoint(n),l=this.getPoint(n+1);if(Math.abs(r.x-l.x)<1&&Math.abs(r.y-l.y)<1){if(n>0&&n+2l.y?270:90;if(Math.abs(r.y-l.y)<1)return r.x>l.x?180:0}return r.directionPoint(l)}jv(){if(this.py===null){this.Me||this.d1();const t=this.py=[];this.Hv(t)}}get flattenedLengths(){return this.jv(),this.py}get flattenedTotalLength(){let t=this.u1;if(isNaN(t)){const i=this.flattenedLengths,e=i.length;t=0;for(let s=0;s=3){let g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e);m=this.adjustPoints(0,g,o-1,p),m&&(g=this.getLinkPoint(i,e,r,!0,!1,s,n),p=this.getLinkPoint(s,n,l,!1,!1,i,e),this.adjustPoints(0,g,o-1,p))}m||(this.clearPoints(),u?this.qv(i,e,r,s,n,l):this.Wv(i,e,r,s,n,l))}else{const m=this.isAvoiding;d&&(f&&m||c)&&this.clearPoints();const g=c?this.computeCurviness():0,p=this.getLinkPoint(i,e,r,!0,f,s,n);let y=0,x=0,k=0;if(f||!h||c){let N=this.computeEndSegmentLength(i,e,r,!0);if(k=this.getLinkDirection(i,e,p,r,!0,f,s,n),c&&(h||r.equals(l)||!f&&r.x+l.x===1&&r.y+l.y===1)&&(k-=f?90:30,g<0&&(k-=180)),k<0?k+=360:k>=360&&(k-=360),c&&(N+=Math.abs(g)*(f?1:2)),k===0?y=N:k===90?x=N:k===180?y=-N:k===270?x=-N:(y=N*Math.cos(k*Math.PI/180),x=N*Math.sin(k*Math.PI/180)),r.isNoSpot()&&c){const T=e.getDocumentPoint(Spot.Center,Point.l()),A=Point.X(T.x+y*1e3,T.y+x*1e3);this.getLinkPointFromPoint(i,e,T,A,!0,p),Point.s(T),Point.s(A)}}const b=this.getLinkPoint(s,n,l,!1,f,i,e);let P=0,S=0,L=0;if(f||!a||c){let N=this.computeEndSegmentLength(s,n,l,!1);if(L=this.getLinkDirection(s,n,b,l,!1,f,i,e),c&&(a||r.equals(l)||!f&&r.x+l.x===1&&r.y+l.y===1)&&(L+=f?0:30,g<0&&(L+=180)),L<0?L+=360:L>=360&&(L-=360),c&&(N+=Math.abs(g)*(f?1:2)),L===0?P=N:L===90?S=N:L===180?P=-N:L===270?S=-N:(P=N*Math.cos(L*Math.PI/180),S=N*Math.sin(L*Math.PI/180)),l.isNoSpot()&&c){const T=n.getDocumentPoint(Spot.Center,Point.l()),A=Point.X(T.x+P*1e3,T.y+S*1e3);this.getLinkPointFromPoint(s,n,T,A,!1,b),Point.s(T),Point.s(A)}}let C=p;(f||!h||c)&&(C=new Point(p.x+y,p.y+x));let M=b;(f||!a||c)&&(M=new Point(b.x+P,b.y+S)),!d&&!f&&h&&o>3&&this.adjustPoints(0,p,o-2,M)?this.setPoint(o-1,b):!d&&!f&&a&&o>3&&this.adjustPoints(1,C,o-1,b)?this.setPoint(0,p):!d&&(f?o>=6:o>4)&&this.adjustPoints(1,C,o-2,M)?(this.setPoint(0,p),this.setPoint(o-1,b)):(this.clearPoints(),this.addPoint(p),(f||!h||c)&&this.addPoint(C),f&&this.addOrthoPoints(C,k,M,L,i,s),(f||!a||c)&&this.addPoint(M),this.addPoint(b))}return t.addInvalidRoute(this),!0}rN(t,i){return Math.abs(i.x-t.x)>Math.abs(i.y-t.y)?(i.x>=t.x?i.x=t.x+9e9:i.x=t.x-9e9,i.y=t.y):(i.y>=t.y?i.y=t.y+9e9:i.y=t.y-9e9,i.x=t.x),i}getLinkPointFromPoint(t,i,e,s,n,o){if(o===void 0&&(o=new Point),t===null||i===null)return o.a(e),o;if(!t.isVisible()){const u=t.findVisibleNode();u!==null&&u!==t&&(t=u,i=t.port)}let r=0,l=0,h=0,a=0,c=null,f=i.panel;if(f!==null&&!f.pn()&&(f=f.panel),f===null)r=s.x,l=s.y,h=e.x,a=e.y;else{c=f.Es;const u=1/(c.m11*c.m22-c.m12*c.m21),d=c.m22*u,m=-c.m12*u,g=-c.m21*u,p=c.m11*u,y=u*(c.m21*c.dy-c.m22*c.dx),x=u*(c.m12*c.dx-c.m11*c.dy);r=s.x*d+s.y*g+y,l=s.x*m+s.y*p+x,h=e.x*d+e.y*g+y,a=e.x*m+e.y*p+x}return i.Zc(r,l,h,a,o),c!==null&&o.D(c),o}Jv(t,i){const e=t.Ju;return e!==null?e.nT(i):null}m1(t){let i=t.Ju;return i===null&&(i=new Knot,i.Qo=t,i.de=t.part,t.Ju=i),i.nT(this)}getLinkPoint(t,i,e,s,n,o,r,l){if(l===void 0&&(l=new Point),e.isSpot()&&!this.Id(e))return i.getDocumentPoint(e,l),l;if(e.isSide()){const c=this.m1(i);if(c!==null){const f=c.Ed;if(l.a(f),n&&this.routing===7){const u=this.m1(r);if(u!==null&&c.Mf=g.y&&y.y<=g.y+g.height?l.y=y.y:(e.includesSide(Spot.TopSide)||e.includesSide(Spot.BottomSide))&&y.x>=g.x&&y.x<=g.x+g.width&&(l.x=y.x),Point.s(d),Point.s(m)}}return l}}const h=i.getDocumentPoint(this.p1(e,s),Point.l());let a=null;if(this.pointsCount>(n?6:2))a=s?this.getPoint(1):this.getPoint(this.pointsCount-2),n&&(a=this.rN(h,a.copy()));else{const c=this.computeSpot(!s,r),f=Point.l();a=r.getDocumentPoint(this.p1(c,!s),f),n&&(a=this.rN(h,a)),Point.s(f)}return this.getLinkPointFromPoint(t,i,h,a,s,l),Point.s(h),l}getLinkDirection(t,i,e,s,n,o,r,l){let h=this.$v(t,i,e,s,n,o,r,l);if(r&&s.isNoSpot()&&r.isMemberOf(t)&&(h+=180,h>=360&&(h-=360)),this.Id(s))return h;const a=i.getDocumentAngle();return a===0||(45<=a&&a<135?h+=90:135<=a&&a<225?h+=180:225<=a&&a<315&&(h+=270),h>=360&&(h-=360)),h}$v(t,i,e,s,n,o,r,l){if(s.isSpot())return s.x>s.y?s.x>1-s.y?0:s.x<1-s.y?270:315:s.x1-s.y?90:s.x<1-s.y?180:135:s.x<.5?225:s.x>.5?45:0;if(s.isSide()){const f=this.m1(i);if(f!==null)switch(f.me){case 1:return 270;case 2:return 180;default:case 4:return 0;case 8:return 90}}const h=i.getDocumentPoint(Spot.Center,Point.l());let a=null;if(this.pointsCount>(o?6:2))a=n?this.getPoint(1):this.getPoint(this.pointsCount-2),o?a=this.rN(h,a.copy()):a=e;else{const f=Point.l();a=l.getDocumentPoint(Spot.Center,f),Point.s(f)}let c=0;return Math.abs(a.x-h.x)>Math.abs(a.y-h.y)?a.x>=h.x?c=0:c=180:a.y>=h.y?c=90:c=270,Point.s(h),c}computeEndSegmentLength(t,i,e,s){if(i!==null&&e.isSide()){const o=this.m1(i);if(o!==null)return o.w1}let n=NaN;return s?n=this.fromEndSegmentLength:n=this.toEndSegmentLength,i!==null&&isNaN(n)&&(s?n=i.fromEndSegmentLength:n=i.toEndSegmentLength),isNaN(n)&&(n=10),n}computeSpot(t,i){return i===void 0&&(i=null),t?this.Zv(i||this.fromPort):this.Qv(i||this.toPort)}Zv(t){if(t===null)return Spot.Center;let i=this.fromSpot;return i.isDefault()&&(i=t.fromSpot),i===Spot.Default?Spot.None:i}Qv(t){if(t===null)return Spot.Center;let i=this.toSpot;return i.isDefault()&&(i=t.toSpot),i===Spot.Default?Spot.None:i}Id(t){return t===Spot.None||t.x===.5&&t.y===.5}p1(t,i){return t.x===.5&&t.y===.5?t:Spot.Center}computeOtherPoint(t,i){if(this.computeAdjusting()!==0&&this.pointsCount>4)return this.computeMidPoint(new Point);{const e=this.Jv(i,this);return e!==null?e.Ed:i.getDocumentPoint(Spot.Center)}}computeShortLength(t){if(t){let i=this.fromShortLength;if(isNaN(i)){const e=this.fromPort;e!==null&&(i=e.fromShortLength)}return isNaN(i)?0:i}else{let i=this.toShortLength;if(isNaN(i)){const e=this.toPort;e!==null&&(i=e.toShortLength)}return isNaN(i)?0:i}}vm(t,i,e,s,n,o){if(this.pickable===!1)return!1;i===void 0&&(i=null),e===void 0&&(e=null);let r=o;if(o===void 0&&(r=Transform.l(),r.Ri()),r.ic(this.D),this.containedInRect(t,r))return this.D2(i,e,n),o===void 0&&Transform.s(r),!0;if(this.intersectsRect(t,r)){let l=!1;if(!this.af){const h=this.L.r,a=h.length;for(let c=a;c--;){const f=h[c];if(!f.visible&&f!==this.locationObject)continue;const u=f.actualBounds,d=this.naturalBounds;if(u.x>d.width||u.y>d.height||u.x+u.width<0||u.y+u.height<0)continue;const m=f,g=Transform.l();if(g.set(r),m instanceof Panel?l=m.vm(t,i,e,s,n,g):this.path===m?m instanceof Shape&&(l=m.bv(t,s,g)):l=m.QL(t,s,g),l){let p=m;i!==null&&(p=i(m)),p&&(e===null||e(p))&&n.add(p)}Transform.s(g)}}return o===void 0&&Transform.s(r),l||this.background!==null}return o===void 0&&Transform.s(r),!1}get isOrthogonal(){return(this.Da&2)===2}static sN(t){return(t&2)===2}get isAvoiding(){return(this.Da&4)===4}computeCurve(){if(this.$o===null){const t=this.fromPort,i=t!==null&&t===this.toPort,e=this.isOrthogonal;this.$o=i&&!e}return this.$o?9:this.curve}computeCorner(){if(this.curve===9)return 0;let t=this.corner;return(isNaN(t)||t<0)&&(t=10),t}findMidLabel(){const t=this.path,i=this.L.r,e=i.length;for(let n=0;n0?g-=f:g+=f;else{const p=-h/a;let y=Math.sqrt(f*f/(p*p+1));c<0&&(y=-y),m=(a<0?-1:1)*y+u,g=p*(m-u)+d}this.addPoint(r),this.addPointAt(m,g),this.addPoint(l)}else{this.addPoint(r),this.addPoint(l);const h=Rect.l();i.getDocumentBounds(h);const a=h.containsPoint(l);n.getDocumentBounds(h);const c=h.containsPoint(r);if(a||c){const f=i.getDocumentPoint(this.p1(e,!0),new Point);this.setPoint(0,this.getLinkPointFromPoint(t,i,f,l,!0,f));const u=n.getDocumentPoint(this.p1(o,!1),new Point);this.setPoint(1,this.getLinkPointFromPoint(s,n,u,r,!1,u))}Rect.s(h)}}qv(t,i,e,s,n,o){const r=this.getLinkPoint(t,i,e,!0,!1,s,n),l=this.getLinkPoint(s,n,o,!1,!1,t,i),h=l.x-r.x,a=l.y-r.y,c=this.computeCurviness();let f=0,u=0,d=r.x+h/3,m=r.y+a/3,g=d,p=m;Geo.u(a,0)?h>0?p-=c:p+=c:(f=-h/a,u=Math.sqrt(c*c/(f*f+1)),c<0&&(u=-u),g=(a<0?-1:1)*u+d,p=f*(g-d)+m),d=r.x+2*h/3,m=r.y+2*a/3;let y=d,x=m;Geo.u(a,0)?h>0?x-=c:x+=c:(y=(a<0?-1:1)*u+d,x=f*(y-d)+m),this.clearPoints(),this.addPoint(r),this.addPointAt(g,p),this.addPointAt(y,x),this.addPoint(l),this.setPoint(0,this.getLinkPoint(t,i,e,!0,!1,s,n)),this.setPoint(3,this.getLinkPoint(s,n,o,!1,!1,t,i))}adjustPoints(t,i,e,s){let n=this.computeAdjusting();if(this.isOrthogonal){if(n===18)return!1;n===19&&(n=17)}switch(n){case 18:return this._v(t,i,e,s);case 19:return this.tO(t,i,e,s);case 17:return this.iO(t,i,e,s);default:return!1}}_v(t,i,e,s){const n=this.getPoint(t),o=this.getPoint(e);if(n.equalsApprox(i)&&o.equalsApprox(s))return!0;const r=n.x,l=n.y,h=o.x,a=o.y;let c=h-r,f=a-l;const u=Math.sqrt(c*c+f*f);if(Geo.K(u,0))return!0;let d=0;Geo.K(c,0)?f<0?d=-Math.PI/2:d=Math.PI/2:(d=Math.atan(f/Math.abs(c)),c<0&&(d=Math.PI-d));const m=i.x,g=i.y,p=s.x,y=s.y,x=p-m,k=y-g,b=Math.sqrt(x*x+k*k);let P=0;Geo.K(x,0)?k<0?P=-Math.PI/2:P=Math.PI/2:(P=Math.atan(k/Math.abs(x)),x<0&&(P=Math.PI-P));const S=b/u,L=P-d;this.setPoint(t,i);for(let C=t+1;C0&&(C=-C);const M=f+P*(d-f),N=u+P*(m-u);if(g!==0){const T=M+C/p,A=N-(T-M)/g;this.setPointAt(y,T,A)}else this.setPointAt(y,M,N+C)}return this.setPoint(e,s),!0}iO(t,i,e,s){if(this.isOrthogonal){let n=this.getPoint(t),o=this.getPoint(t+1),r=this.getPoint(t+2),l=o.x,h=o.y;const a=l,c=h;Geo.u(n.y,o.y)?Geo.u(o.x,r.x)?h=i.y:Geo.u(o.y,r.y)&&(l=i.x):Geo.u(n.x,o.x)&&(Geo.u(o.y,r.y)?l=i.x:Geo.u(o.x,r.x)&&(h=i.y)),this.setPointAt(t+1,l,h),n=this.getPoint(e),o=this.getPoint(e-1),r=this.getPoint(e-2);let f=o.x,u=o.y;const d=f,m=u;if(Geo.u(n.y,o.y)?Geo.u(o.x,r.x)?u=s.y:Geo.u(o.y,r.y)&&(f=s.x):Geo.u(n.x,o.x)&&(Geo.u(o.y,r.y)?f=s.x:Geo.u(o.x,r.x)&&(u=s.y)),this.setPointAt(e-1,f,u),this.AL())return this.setPointAt(t+1,a,c),this.setPointAt(e-1,d,m),!1}return this.setPoint(t,i),this.setPoint(e,s),!0}addOrthoPoints(t,i,e,s,n,o){i<0?i+=360:i>=360&&(i-=360),s<0?s+=360:s>=360&&(s-=360);const c=s;i>=315||i<45?i=0:45<=i&&i<135?i=90:135<=i&&i<225?i=180:i=270,s>=315||s<45?s=0:45<=s&&s<135?s=90:135<=s&&s<225?s=180:s=270;const f=t,u=e,d=n.actualBounds.copy(),m=o.actualBounds.copy();if(!d.isReal()||!m.isReal())return;d.inflate(Link.va,Link.va),m.inflate(Link.va,Link.va),d.unionPoint(t),m.unionPoint(e);const g=Point.l(),p=Point.l();i===0?u.x>f.x||s===270&&u.yf.x||s===90&&u.y>f.y&&m.right>f.x?(g.e(u.x,f.y),p.e(u.x,(f.y+u.y)/2),s===180?(g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1),p.x=g.x,p.y=u.y):s===270&&u.yf.y?(f.xm.bottom)?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):g.x=m.right,p.x=g.x,p.y=u.y):s===0&&f.xm.top&&f.yd.bottom)&&(s===180&&(m.containsPoint(f)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):u.yf.y&&(s===180||s===270)&&(g.y=this.computeMidOrthoPosition(f.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=d.left&&u.x<=f.x||f.x<=m.right&&f.x>=u.x?(s===90||s===270)&&(g.e(Math.max((f.x+u.x)/2,f.x),f.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yf.y&&m.leftf.y?(f.x>m.right?g.x=this.computeMidOrthoPosition(f.x,f.y,m.right,u.y,!1):f.x>m.left&&(s===270&&f.ym.bottom)?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):g.x=m.left,p.x=g.x,p.y=u.y):s===180&&f.x>m.right&&f.y>m.top&&f.yd.bottom)&&(s===0&&(m.containsPoint(f)||d.containsPoint(u))?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):u.yf.y&&(s===0||s===270)&&(g.y=this.computeMidOrthoPosition(f.x,d.bottom,u.x,Math.min(u.y,m.top),!0)),p.x=u.x,p.y=g.y),g.y>d.top&&g.y=f.x||f.x>=m.left&&f.x<=u.x?(s===90||s===270)&&(g.e(Math.min((f.x+u.x)/2,f.x),f.y),p.e(g.x,u.y)):(s===270||(s===0||s===180)&&u.yf.y||s===180&&u.xf.y||s===0&&u.x>f.x&&m.bottom>f.y?(g.e(f.x,u.y),p.e((f.x+u.x)/2,u.y),s===270?(g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0),p.x=u.x,p.y=g.y):s===180&&u.xf.x?(f.ym.right)?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):g.y=m.bottom,p.x=u.x,p.y=g.y):s===90&&f.ym.left&&f.xd.right)&&(s===270&&(m.containsPoint(f)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):u.xf.x&&(s===270||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,f.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=d.top&&u.y<=f.y||f.y<=m.bottom&&f.y>=u.y?(s===0||s===180)&&(g.e(f.x,Math.max((f.y+u.y)/2,f.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.xf.x&&m.top=f.x?(f.y>m.bottom?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,m.bottom,!0):f.y>m.top&&(s===180&&f.xm.right)?g.y=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!0):g.y=m.top,p.x=u.x,p.y=g.y):s===270&&f.y>m.bottom&&f.x>m.left&&f.xd.right)&&(s===90&&(m.containsPoint(f)||d.containsPoint(u))?g.x=this.computeMidOrthoPosition(f.x,f.y,u.x,u.y,!1):u.xf.x&&(s===90||s===180)&&(g.x=this.computeMidOrthoPosition(d.right,f.y,Math.min(u.x,m.left),u.y,!1)),p.x=g.x,p.y=u.y),g.x>d.left&&g.x=f.y||f.y>=m.top&&f.y<=u.y?(s===0||s===180)&&(g.e(f.x,Math.min((f.y+u.y)/2,f.y)),p.e(u.x,g.y)):(s===180||(s===90||s===270)&&u.x=3&&!Geo.K(this.smoothness,0))if(i===3){let c=this.getPoint(1);n=Math.min(r.x,c.x),o=Math.min(r.y,c.y),c=this.getPoint(2),n=Math.min(n,c.x),o=Math.min(o,c.y)}else if(this.isOrthogonal){for(let c=0;c=i&&(c=i-1);const f=this.getPoint(c);l.x=Math.min(f.x,l.x),l.y=Math.min(f.y,l.y)}n=l.x,o=l.y}else{for(let c=0;c=3&&!Geo.K(this.smoothness,0))if(i===3){const f=this.getPoint(1),u=f.x-n,d=f.y-o;let m=this.getPoint(2).copy();m.x-=n,m.y-=o,this.computeShortLength(!1)!==0&&(m=this.Nf(m,!1,l)),c.dr(u,d,u,d,m.x,m.y)}else if(this.isOrthogonal){const f=Point.X(n,o),u=Point.l();u.a(this.getPoint(1));const d=Point.X(n,o),m=Point.X(n,o);let g=this.getPoint(0),p=null;const y=this.smoothness/3;for(let P=1;P=i&&(f=i-1);const d=this.getPoint(f-1);let m=this.getPoint(f);f===i-1&&this.computeShortLength(!1)!==0&&(m=this.Nf(m.copy(),!1,Point.Po)),c.dr(u.x-n,u.y-o,d.x-n,d.y-o,m.x-n,m.y-o)}else{const f=Point.l();f.a(this.getPoint(0));const u=Point.l();u.a(f);const d=this.computeCorner();let m=1,g=0;for(;m1);let p=this.getPoint(m);if(m>=i-1){if(!f.equals(p))this.computeShortLength(!1)!==0&&(p=this.Nf(p.copy(),!1,Point.Po)),this.Nn(c,-n,-o,f,p,e);else if(g===0)for(m=1;mr?f>a?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):f>a?(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.K(r,h)&&Geo.K(a,f)&&(a>l?c>h?(n.x=h-u,n.y=a-u,o.x=h+d,o.y=a+d):(n.x=h+u,n.y=a-u,o.x=h-d,o.y=a+d):c>h?(n.x=h-u,n.y=a+u,o.x=h+d,o.y=a-d):(n.x=h+u,n.y=a+u,o.x=h-d,o.y=a-d)),Geo.K(r,h)&&Geo.K(h,c)||Geo.K(l,a)&&Geo.K(a,f)){const m=.5*(r+c),g=.5*(l+f);n.x=m,n.y=g,o.x=m,o.y=g}}Nf(t,i,e){const s=this.pointsCount;if(s<2)return t;if(i){const n=this.getPoint(1),o=n.x-e.x,r=n.y-e.y,l=this.b1(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!0);a>h&&(a=h);const c=a*(o-t.x)/l,f=a*(r-t.y)/l;t.x+=c,t.y+=f}else{const n=this.getPoint(s-2),o=n.x-e.x,r=n.y-e.y,l=this.b1(t.x,t.y,o,r);if(l===0)return t;const h=s===2?l*.5:l;let a=this.computeShortLength(!1);a>h&&(a=h);const c=a*(t.x-o)/l,f=a*(t.y-r)/l;t.x-=c,t.y-=f}return t}lN(t,i,e){const s=this.pointsCount;let n=t;for(;Geo.K(t.x,n.x)&&Geo.K(t.y,n.y);){if(i>=s)return s-1;n=this.getPoint(i++)}if(!Geo.K(t.x,n.x)&&!Geo.K(t.y,n.y))return i-1;let o=n;for(;Geo.K(t.x,n.x)&&Geo.K(n.x,o.x)&&(!e||(t.y>=n.y?n.y>=o.y:n.y<=o.y))||Geo.K(t.y,n.y)&&Geo.K(n.y,o.y)&&(!e||(t.x>=n.x?n.x>=o.x:n.x<=o.x));){if(i>=s)return s-1;o=this.getPoint(i++)}return i-2}nO(t,i,e,s,n,o,r,l,h,a){if(Geo.u(s.y,n.y)&&Geo.u(n.x,o.x)){let c=Math.min(h,Math.abs(n.x-l.x)/2);const f=Math.min(c,Math.abs(o.y-n.y)/2);if(c=f,Geo.u(c,0)){this.Nn(t,i,e,s,n,a),r.a(n);return}let u=n.x;const d=n.y,m=u;let g=d;n.x>s.x?(u=n.x-c,o.y>n.y?g=n.y+f:g=n.y-f):(u=n.x+c,o.y>n.y?g=n.y+f:g=n.y-f);const p=Point.X(u,d);this.Nn(t,i,e,s,p,a),Point.s(p),t.Mw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else if(Geo.u(s.x,n.x)&&Geo.u(n.y,o.y)){let c=Math.min(h,Math.abs(n.y-l.y)/2);const f=Math.min(c,Math.abs(o.x-n.x)/2);if(c=f,Geo.u(f,0)){this.Nn(t,i,e,s,n,a),r.a(n);return}const u=n.x;let d=n.y,m=u;const g=d;n.y>s.y?(d=n.y-c,o.x>n.x?m=n.x+f:m=n.x-f):(d=n.y+c,o.x>n.x?m=n.x+f:m=n.x-f);const p=Point.X(u,d);this.Nn(t,i,e,s,p,a),Point.s(p),t.Mw(n.x+i,n.y+e,m+i,g+e),r.e(m,g)}else this.Nn(t,i,e,s,n,a),r.a(n)}computeJumpLength(){return 10}Nn(t,i,e,s,n,o){if(o||!this.Oa())t.ur(n.x+i,n.y+e);else{const r=this.computeJumpLength(),l=r/2,h=[];let a=0;this.isVisible()&&(a=this.oO(s,n,h));let c=s.x,f=s.y;if(a>0){if(Geo.u(s.y,n.y))if(s.x=0;){const d=Math.min(s.x,Math.max(h[u--]+l,n.x+r));t.ur(d+i,n.y+e),c=d+i,f=n.y+e;let m=Math.max(d-r,n.x);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.x);else break}const g=n.y-r+e,p=m+i,y=n.y+e;this.curve===10?t.fu(p,y,!1,!1):t.dr(c,g,p,g,p,y),c=p,f=y}}else if(Geo.u(s.x,n.x))if(s.y=0;){const d=Math.min(s.y,Math.max(h[u--]+l,n.y+r));t.ur(n.x+i,d+e),c=n.x+i,f=d+e;let m=Math.max(d-r,n.y);for(;u>=0;){const x=h[u];if(x>m-r)u--,m=Math.max(x-l,n.y);else break}const g=n.x-r+i,p=n.x+i,y=m+e;this.curve===10?t.fu(p,y,!1,!1):t.dr(g,f,g,y,p,y),c=p,f=y}}}t.ur(n.x+i,n.y+e)}}oO(t,i,e){const s=this.diagram;if(s===null||t.equals(i))return 0;const n=s.layers;for(;n.next();){const o=n.value;if(o!==null&&o.visible){const r=o.ES(),l=r.length;for(let h=0;h0&&e.sort((u,d)=>u-d),e.length;if(!a.isVisible()||!a.Oa())continue;const c=a.routeBounds;if(!c.isReal()||!this.routeBounds.intersectsRect(c)||this.usesSamePort(a))continue;const f=a.path;f!==null&&f.isVisibleObject()&&this.rO(t,i,e,a)}}}return e.length>0&&e.sort((o,r)=>o-r),e.length}rO(t,i,e,s){const n=Geo.u(t.y,i.y),o=s.pointsCount;let r=s.getPoint(0);const l=Point.l();for(let h=1;hr.x&&c.x>=a.x||a.xr.y&&c.y>=a.y||a.yc&&Math.min(a,f)o&&!Geo.u(a,f))return n.x=o,n.y=c,!0}else if(Geo.u(r,h)&&Geo.u(a,f)&&Math.min(o,l)a&&Math.min(c,u)r&&!Geo.u(c,u))return n.x=a,n.y=r,!0;return n.x=0,n.y=0,!1}get firstPickIndex(){return this.pointsCount<=2?0:this.isOrthogonal||!this.Id(this.computeSpot(!0))?1:0}get lastPickIndex(){const t=this.pointsCount;return t===0?0:t<=2?t-1:this.isOrthogonal||!this.Id(this.computeSpot(!1))?t-2:t-1}Oa(){const t=this.curve;return t===11||t===10}g1(t){if(t||this.Oa()){const i=this.diagram;i!==null&&!i.animationManager.isTicking&&!i.$l.has(this)&&(this.Sf.width!==0||this.Sf.height!==0)&&i.$l.set(this,this.Sf.copy())}}invalidateOtherJumpOvers(t){const i=this.layer;if(i===null||!i.visible||i.isTemporary)return;const e=i.diagram;if(e===null||e.animationManager.isTicking)return;let s=!1;const n=e.layers;for(;n.next();){const o=n.value;if(o.visible){if(o===i){s=!0;let r=!1;const l=o.ES(),h=l.length;for(let a=0;a0&&e>0){const s=this.getPoint(0),n=t.getPoint(0);if(s.equalsApprox(n))return!0;const o=this.getPoint(i-1),r=t.getPoint(e-1);if(o.equalsApprox(r)||s.equalsApprox(r)||o.equalsApprox(n))return!0}else if(this.fromNode===t.fromNode||this.toNode===t.toNode||this.fromNode===t.toNode||this.toNode===t.fromNode)return!0;return!1}isVisible(){if(!super.isVisible())return!1;const t=this.containingGroup;let i=!0;const e=this.diagram;e!==null&&(i=e.isTreePathToChildren);const s=this.fromNode;if(s!==null){if(this.isTreeLink&&i&&!s.isTreeExpanded)return!1;if(s===t)return!0;let o=s;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=s.findVisibleNode();if(r===null||r===t)return!1}const n=this.toNode;if(n!==null){if(this.isTreeLink&&!i&&!n.isTreeExpanded)return!1;if(n===t)return!0;let o=n;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}const r=n.findVisibleNode();if(r===null||r===t)return!1}return!0}Ei(t){if(super.Ei(t),t&&this.g1(!1),this.Zo!==null&&this.Zo.Ad(),this.Hs!==null){const e=this.Hs.iterator;for(;e.next();)e.value.Ei(t)}}get adjusting(){return this.Pf}set adjusting(t){const i=this.Pf;i!==t&&(this.Pf=t,this.t("adjusting",i,t))}computeAdjusting(){return this.isAvoiding&&this.diagram!==null&&this.diagram.animationManager.defaultAnimation.isAnimating?17:this.Pf}get corner(){return this.Fd}set corner(t){const i=this.Fd;i!==t&&(this.Fd=t,this.ee(),this.t("corner",i,t))}get curve(){return this.Rd}set curve(t){const i=this.Rd;i!==t&&(this.Rd=t,this.invalidateRoute(),this.ee(),this.g1(i===10||i===11||t===10||t===11),this.t("curve",i,t))}get curviness(){return this.vd}set curviness(t){const i=this.vd;i!==t&&(this.vd=t,this.invalidateRoute(),this.ee(),this.t("curviness",i,t))}get routing(){return this.Da}set routing(t){const i=this.Da;i!==t&&(this.Da=t,this.isAvoiding&&this.diagram!==null&&(this.diagram.Ym=!0),this.$o=null,this.invalidateRoute(),this.g1(Link.sN(i)||Link.sN(t)),this.t("routing",i,t))}get smoothness(){return this.Od}set smoothness(t){const i=this.Od;i!==t&&(this.Od=t,this.ee(),this.t("smoothness",i,t))}wy(){const t=this.lo;if(t===null)return;const i=this.ao;if(i===null||!isNaN(this.curviness))return;const e=this.ho,s=this.co;let n=null,o=null;const r=t._t.r,l=r.length;for(let h=0;h=0&&(Util.tc(t.qs,i),t.Ad())}}Cl(){return!0}get key(){const t=this.diagram;if(!(t===null||!t.model.Ta()))return t.model.getKeyForLinkData(this.data)}}class LinkBundle{Eo;Os;ry;J2;h1;$2;qs;constructor(t,i,e,s){GSet.Yi(this),this.Eo=!1,this.Os=!1,this.ry=t,this.J2=i,this.h1=e,this.$2=s,this.qs=[]}Ad(){if(!this.Eo){const t=this.qs;if(t.length>0){const i=t[0].diagram;i!==null&&(i.lM.add(this),this.Os=i.undoManager.isUndoingRedoing)}}this.Eo=!0}bM(){if(this.Eo){this.Eo=!1;const t=this.qs;if(t.length>0){const i=t[0],e=i.diagram,s=e===null||e.Bh&&!this.Os;this.Os=!1,i.arrangeBundledLinks(t,s),t.length===1&&(i.Zo=null,t.length=0)}t.length===0&&(this.ry.JA(this),this.h1.JA(this))}}}class PositionArray{oe;re;Ia;Ea;pi;yi;Ot;xh;bh;ha;RM;Eo;by;Gc;vM;OM;constructor(t){GSet.Yi(this),this.ha=null,this.RM=null,this.Eo=!0,this.by=!1,this.oe=1,this.re=1,this.Ia=-1,this.Ea=-1,this.pi=t.width,this.yi=t.height,this.Ot=null,this.xh=0,this.bh=0,this.Gc=11,this.vM=this.Gc*2,this.OM=this.Gc*2}static Ws=0;static Ba=1;static Bd=999999;static hN=PositionArray.Bd+1;static aN=PositionArray.Bd+2;kb(t){if(t.width<=0||t.height<=0)return;const i=t.x,e=t.y,s=t.x+t.width,n=t.y+t.height;this.oe=Math.floor((i-this.pi)/this.pi)*this.pi,this.re=Math.floor((e-this.yi)/this.yi)*this.yi,this.Ia=Math.ceil((s+2*this.pi)/this.pi)*this.pi,this.Ea=Math.ceil((n+2*this.yi)/this.yi)*this.yi;const o=1+(Math.ceil((this.Ia-this.oe)/this.pi)|0),r=1+(Math.ceil((this.Ea-this.re)/this.yi)|0);if(this.Ot===null||this.xh0&&t!==this.pi&&(this.pi=t,this.kb(this.bounds))}get cellHeight(){return this.yi}set cellHeight(t){t>0&&t!==this.yi&&(this.yi=t,this.kb(this.bounds))}Ud(t,i){return this.oe<=t&&t<=this.Ia&&this.re<=i&&i<=this.Ea}fo(t,i){if(!this.Ud(t,i))return PositionArray.hN;t-=this.oe,t/=this.pi,i-=this.re,i/=this.yi;const e=t|0,s=i|0;return this.Ot[e][s]}pR(t,i,e,s){if(!this.Ud(t,i))return;const n=(t-this.oe)/this.pi|0,o=(i-this.re)/this.yi|0,r=(t+e-this.oe)/this.pi|0,l=(i+s-this.re)/this.yi|0,h=Math.min(r,this.xh),a=Math.min(l,this.bh);for(let c=n;c<=h;c++){const f=this.Ot[c];if(f.fill)f.fill(PositionArray.Ws,o,a+1);else for(let u=o;u<=a;u++)f[u]=PositionArray.Ws}}hO(t){if(this.Ot!==null)for(let i=0;i<=this.xh;i++){const e=this.Ot[i];if(e.fill)e.fill(t);else for(let s=0;s<=this.bh;s++)e[s]=t}}zL(){if(this.Ot!==null)for(let t=0;t<=this.xh;t++){const i=this.Ot[t];for(let e=0;e<=this.bh;e++)i[e]>=PositionArray.Ba&&(i[e]=PositionArray.hN)}}aO(t,i){return this.fo(t,i)===PositionArray.Ws}isUnoccupied(t,i,e,s){if(t>this.Ia||t+ethis.Ea||i+sthis.Ia||ithis.Ea||ethis.Ea||ithis.Ia||e=PositionArray.Ba&&h=a)break;this.Ot[t][i]=h,h+=1,s?i+=e:t+=e}return s?i:t}uo(t,i,e,s,n,o,r,l){if(to||il)return;const h=this.cO(t,i,e,s,n,o,r,l);if(s)if(e>0)for(let a=i+e;ah;a+=e)this.uo(t,a,1,!s,n,o,r,l),this.uo(t,a,-1,!s,n,o,r,l);else if(e>0)for(let a=t+e;ah;a+=e)this.uo(a,i,1,!s,n,o,r,l),this.uo(a,i,-1,!s,n,o,r,l)}k1(t,i,e,s,n,o,r,l,h,a){let c=t|0,f=i|0,u=PositionArray.Ws,d=PositionArray.Ba;for(this.Ot[c][f]=d;u===PositionArray.Ws&&c>r&&ch&&fr&&ch&&f=0;v-=2){F=A[v+2],R=A[v+3];const O=A[v],B=A[v+1];for(;O>F?F++:OR?R++:Bs)d--;else break;else if(m>n)m--;else break;const g=c[d][m];if(g===0||g===PositionArray.aN)break;f=d,u=m}for(;;){let d=e,m=f,g=u;e===0?gn&&(d=270,g--):e===90?ms&&(d=180,m--):e===180?gn&&(d=270,g--):ms&&(d=180,m--);const p=c[m][g];if(d!==e&&p!==0&&p!==PositionArray.aN){if(o.push(f),o.push(u),this.lT(f,u,d,s,n,o))return!0;o.pop(),o.pop()}if(c[f][u]=PositionArray.aN,e===0){if(f===t)return!1;f--}else if(e===90){if(u===i)return!1;u--}else if(e===180){if(f===t)return!1;f++}else{if(u===i)return!1;u++}}}}class Knot{de;Qo;rs;Vd;constructor(){GSet.Yi(this),this.de=null,this.Qo=null,this.rs=[],this.Vd=!1}toString(){const t=this.rs;let i=this.de.toString()+" "+t.length.toString()+":";for(let e=0;e180?270:90;case 6:return o>90&&o<=270?180:0}const r=Math.atan2(t.height,t.width)*180/Math.PI;switch(n){case 3:return o>r&&o<=180+r?180:270;case 5:return o>180-r&&o<=360-r?270:0;case 12:return o>r&&o<=180+r?90:0;case 10:return o>180-r&&o<=360-r?180:90;case 7:return o>90&&o<=180+r?180:o>180+r&&o<=360-r?270:0;case 13:return o>180&&o<=360-r?270:o>r&&o<=180?90:0;case 14:return o>r&&o<=180-r?90:o>180-r&&o<=270?180:0;case 11:return o>180-r&&o<=180+r?180:o>180+r?270:90}return s&&n!==15&&(o-=15,o<0&&(o+=360)),o>r&&o<180-r?90:o>=180-r&&o<=180+r?180:o>180+r&&o<360-r?270:0}Ad(){this.rs.length=0}nT(t){let i=this.rs;i.length===0&&(this.uO(),i=this.rs);for(let e=0;e=360&&(S-=360);const L=this.fO(h,y,S,g.isOrthogonal);let C=0;L===0?(C=4,S>180&&(S-=360)):L===90?(C=8,S>270&&(S-=360)):L===180?C=2:(C=1,S<90&&(S+=360));let M=this.rs[o];M===void 0?(M=new LinkInfo(g,S,C),this.rs[o]=M):(M.He=g,M.Xt=S,M.me=C),M.S1.set(P),o++}Point.s(a),this.dO();const u=this.rs.length;let d=-1,m=0;for(o=0;o=0;o--){const g=this.rs[o];g!==void 0&&(g.me!==d&&(d=g.me,m=g.zd+1),g.Mf=m)}this.gO(this.rs),this.mO(this.rs),this.Vd=t,Rect.s(h)}return this.rs}pO(t,i){return t===i?0:t===null?-1:i===null?1:t.mei.me?1:t.Xti.Xt?1:0}dO(){this.rs.sort(Knot.prototype.pO)}gO(t){const i=this.Qo,e=this.de.portSpreading,s=Point.l(),n=Point.l(),o=Point.l(),r=Point.l();i.getDocumentPoint(Spot.TopLeft,s),i.getDocumentPoint(Spot.TopRight,n),i.getDocumentPoint(Spot.BottomRight,o),i.getDocumentPoint(Spot.BottomLeft,r);let l=0,h=0,a=0,c=0;if(e===2)for(let x=0;xMath.abs(p)?(d=Math.abs(p)/a,a=Math.abs(p)):d=1;break;case 2:c>Math.abs(y)?(d=Math.abs(y)/c,c=Math.abs(y)):d=1;break;case 1:l>Math.abs(p)?(d=Math.abs(p)/l,l=Math.abs(p)):d=1;break;default:case 4:h>Math.abs(y)?(d=Math.abs(y)/h,h=Math.abs(y)):d=1;break}u=0}const b=k.Ed;if(e===2){let P=k.He.computeThickness();switch(P*=d,b.set(m),f){case 8:b.x=m.x+p/2+a/2-u-P/2;break;case 2:b.y=m.y+y/2+c/2-u-P/2;break;case 1:b.x=m.x+p/2-l/2+u+P/2;break;default:case 4:b.y=m.y+y/2-h/2+u+P/2;break}u+=P}else{let P=.5;e===1&&(P=(k.zd+1)/(k.Mf+1)),b.x=m.x+p*P,b.y=m.y+y*P}}Point.s(s),Point.s(n),Point.s(o),Point.s(r)}mO(t){for(let i=0;ie instanceof Placeholder);i instanceof Placeholder?t.It=i:t.It=null,this.ie!==null?(t.ie=this.ie.copy(),t.ie.group=t):(t.ie!==null&&(t.ie.group=null),t.ie=null),this.ni!==null&&(t.ni=this.ni.copy())}Vo(t){super.Vo(t);const i=t.findSubGraphParts(),e=t.memberParts;for(;e.next();){const s=e.value;if(s.c(),s.invalidateLayout(8),s.clearAdornments(),s instanceof Node)s.invalidateConnectedLinks(i);else if(s instanceof Link){const n=s.labelNodes;for(;n.next();)n.value.invalidateConnectedLinks(i)}}}Jc(t,i,e,s,n,o,r){if(t===3&&i==="elements"){if(n instanceof Placeholder)this.It===null?this.It=n:this.It!==n&&Util.o("Cannot insert a second Placeholder into the visual tree of a Group.");else if(n instanceof Panel){const l=n.findInVisualTree(h=>h instanceof Placeholder);l instanceof Placeholder&&(this.It===null?this.It=l:this.It!==l&&Util.o("Cannot insert a second Placeholder into the visual tree of a Group."))}}else t===4&&i==="elements"&&this.It!==null&&(s===this.It?this.It=null:s instanceof Panel&&this.It.isContainedBy(s)&&(this.It=null));super.Jc(t,i,e,s,n,o,r)}td(t,i){if(super.td(t,i),this.isClipping&&this.type!==Panel.Spot&&this.isSubGraphExpanded){let e=this.resizeObject;e instanceof Panel&&(e=e.findMainElement()),this.ni===null&&(this.ni=new Rect),e.getDocumentBounds(this.ni),e instanceof Shape&&this.ni.inflate(-e.strokeWidth,-e.strokeWidth)}}ah(t,i,e,s){this.hasPlaceholder()&&(this.Jo=this.placeholder),super.ah(t,i,e,s)}ensureBounds(){this.isSubGraphExpanded&&this.memberParts.each(i=>{i.ensureBounds()}),super.ensureBounds()}Hr(){if(!super.Hr())return!1;const t=this.memberParts;for(;t.next();){const i=t.value;if(i instanceof Node){if(!i.isVisible())continue;if(i.is())return!1}else if(i instanceof Link){if(!i.isVisible())continue;if(i.is()&&i.fromNode!==this&&i.toNode!==this)return!1}}return!0}hasPlaceholder(){return this.It!==null&&this.It.isVisibleObject()&&this.isSubGraphExpanded}get placeholder(){return this.It}get computesBoundsAfterDrag(){return(this.E&2048)!==0}set computesBoundsAfterDrag(t){const i=(this.E&2048)!==0;i!==t&&(Util.i(t,"boolean",Group,"computesBoundsAfterDrag"),this.E=this.E^2048,this.t("computesBoundsAfterDrag",i,t))}get computesBoundsIncludingLinks(){return(this.E&4096)!==0}set computesBoundsIncludingLinks(t){Util.i(t,"boolean",Group,"computesBoundsIncludingLinks");const i=(this.E&4096)!==0;i!==t&&(this.E=this.E^4096,this.t("computesBoundsIncludingLinks",i,t))}get computesBoundsIncludingLocation(){return(this.E&8192)!==0}set computesBoundsIncludingLocation(t){Util.i(t,"boolean",Group,"computesBoundsIncludingLocation");const i=(this.E&8192)!==0;i!==t&&(this.E=this.E^8192,this.t("computesBoundsIncludingLocation",i,t))}get handlesDragDropForMembers(){return(this.E&16384)!==0}set handlesDragDropForMembers(t){Util.i(t,"boolean",Group,"handlesDragDropForMembers");const i=(this.E&16384)!==0;i!==t&&(this.E=this.E^16384,this.t("handlesDragDropForMembers",i,t))}get avoidableMembers(){return(this.E&131072)!==0}set avoidableMembers(t){Util.i(t,"boolean",Group,"avoidableMembers");const i=(this.E&131072)!==0;i!==t&&(this.E=this.E^131072,this.t("avoidableMembers",i,t))}get memberParts(){return this.Xd.iterator}j2(t){if(this.Xd.add(t)){t instanceof Group&&this.la.add(t);const e=this.memberAdded;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.Y,n.Y=!0),e(this,t),n!==null&&(n.Y=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ei(!1)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.It;i===null&&(i=this),i.c()}G2(t){if(this.Xd.delete(t)){t instanceof Group&&this.la.delete(t);const e=this.memberRemoved;if(e!==null){let s=!0;const n=this.diagram;n!==null&&(s=n.Y,n.Y=!0),e(this,t),n!==null&&(n.Y=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Ei(!0)}if(t instanceof Link&&!this.computesBoundsIncludingLinks)return;let i=this.It;i===null&&(i=this),i.c()}Kc(){if(this.Xd.count>0){const t=this.diagram;if(t!==null){const e=this.Xd.copy().iterator;for(;e.next();){const s=e.value;t.remove(s)}}}super.Kc()}get layout(){return this.ie}set layout(t){const i=this.ie;if(i!==t){t!==null&&t.diagram!==null&&t.diagram.layout===t&&Util.o("A layout cannot be both the Diagram.layout and a Group.layout: "+t),i!==null&&(i.diagram=null,i.group=null),this.ie=t;const e=this.diagram;t!==null&&(t.diagram=e,t.group=this),e!==null&&(e.Kr=!0),this.t("layout",i,t),e!==null&&e.requestUpdate()}}get memberAdded(){return this.gt!==null?this.gt.uy:null}set memberAdded(t){const i=this.memberAdded;i!==t&&(t!==null&&Util.i(t,"function",Group,"memberAdded"),this.cl(),this.gt.uy=t,this.t("memberAdded",i,t))}get memberRemoved(){return this.gt!==null?this.gt.gy:null}set memberRemoved(t){const i=this.memberRemoved;i!==t&&(t!==null&&Util.i(t,"function",Group,"memberRemoved"),this.cl(),this.gt.gy=t,this.t("memberRemoved",i,t))}get memberValidation(){return this.gt!==null?this.gt.eh:null}set memberValidation(t){const i=this.memberValidation;i!==t&&(t!==null&&Util.i(t,"function",Group,"memberValidation"),this.cl(),this.gt.eh=t,this.t("memberValidation",i,t))}canAddMembers(t){const i=this.diagram;if(i===null)return!1;const e=i.commandHandler,n=e.i2(t).iterator;for(;n.next();){const o=n.value;if(!e.isValidMember(this,o))return!1}return!0}addMembers(t,i){const e=this.diagram;if(e===null)return!1;const s=e.commandHandler,n=s.i2(t);let o=!0;const r=n.iterator;for(;r.next();){const l=r.value;!i||s.isValidMember(this,l)?l.containingGroup=this:o=!1}return o}get ungroupable(){return(this.E&256)!==0}set ungroupable(t){const i=(this.E&256)!==0;i!==t&&(Util.i(t,"boolean",Group,"ungroupable"),this.E=this.E^256,this.t("ungroupable",i,t))}canUngroup(){if(!this.ungroupable)return!1;const t=this.layer;if(t===null||!t.allowUngroup)return!1;const i=t.diagram;return!(i!==null&&!i.allowUngroup)}invalidateConnectedLinks(t){const i=this.wO();if(super.invalidateConnectedLinks(t),i)return;this.kL(!0);const e=this.findExternalLinksConnected();for(;e.next();){const s=e.value;if(t!==void 0&&t.has(s))continue;const n=s.fromNode;if(n!==null&&n!==this&&n.isMemberOf(this)&&!n.isVisible())n.Wi(s.fromPort),n.Wi(s.toPort),s.invalidateRoute();else{const o=s.toNode;o!==null&&o!==this&&o.isMemberOf(this)&&!o.isVisible()&&(o.Wi(s.fromPort),o.Wi(s.toPort),s.invalidateRoute())}}}findExternalLinksConnected(){const t=this.diagram!==null&&this.diagram.dM;if(t&&this.u0!==null)return this.u0.iterator;const i=this.findSubGraphParts();i.add(this);const e=new GSet,s=i.iterator;for(;s.next();){const n=s.value;if(!(n instanceof Node))continue;const o=n.linksConnected;for(;o.next();){const r=o.value;i.has(r)||e.add(r)}}return t&&(this.u0=e),e.iterator}findExternalNodesConnected(){const t=this.findSubGraphParts();t.add(this);const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;if(!(s instanceof Node))continue;const n=s.linksConnected;for(;n.next();){const o=n.value,r=o.fromNode;r!==null&&(!t.has(r)||r===this)&&i.add(r);const l=o.toNode;l!==null&&(!t.has(l)||l===this)&&i.add(l)}}return i.iterator}mE(){function t(e,s){e!==null&&(s.add(e),t(e.containingGroup,s))}const i=new GSet;return t(this,i),i}findSubGraphParts(){const t=new GSet;return Part.sh(t,this,!0,0,!0),t.delete(this),t}Ei(t){super.Ei(t);const i=this.memberParts;for(;i.next();)i.value.Ei(t)}collapseSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.hT(i,t,this),t.isCollapsingExpanding=!1}hT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ei(!1),n instanceof Group&&n.isSubGraphExpanded&&(n.wasSubGraphExpanded=n.isSubGraphExpanded,n.hT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t),i.Lc(n,e);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!1}expandSubGraph(){const t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;const i=this.findSubGraphParts();this.aT(i,t,this),t.isCollapsingExpanding=!1}aT(t,i,e){const s=this.memberParts;for(;s.next();){const n=s.value;if(n.Ei(!0),n instanceof Group&&n.wasSubGraphExpanded&&(n.wasSubGraphExpanded=!1,n.aT(t,i,e)),n instanceof Node)n.invalidateConnectedLinks(t);else if(n instanceof Link){const o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!0}get isSubGraphExpanded(){return(this.E&512)!==0}set isSubGraphExpanded(t){const i=(this.E&512)!==0;if(i!==t){Util.i(t,"boolean",Group,"isSubGraphExpanded"),this.E=this.E^512;const e=this.diagram;this.t("isSubGraphExpanded",i,t);const s=this.subGraphExpandedChanged;if(s!==null){let n=!0;e!==null&&(n=e.Y,e.Y=!0),s(this),e!==null&&(e.Y=n)}if(e!==null&&e.undoManager.isUndoingRedoing){this.It!==null&&this.It.c(),this.memberParts.each(n=>n.updateAdornments());return}t?this.expandSubGraph():this.collapseSubGraph()}}get wasSubGraphExpanded(){return(this.E&1024)!==0}set wasSubGraphExpanded(t){const i=(this.E&1024)!==0;i!==t&&(Util.i(t,"boolean",Group,"wasSubGraphExpanded"),this.E=this.E^1024,this.t("wasSubGraphExpanded",i,t))}get subGraphExpandedChanged(){return this.gt!==null?this.gt.my:null}set subGraphExpandedChanged(t){const i=this.subGraphExpandedChanged;i!==t&&(t!==null&&Util.i(t,"function",Group,"subGraphExpandedChanged"),this.cl(),this.gt.my=t,this.t("subGraphExpandedChanged",i,t))}move(t,i){i===void 0&&(i=!1);const e=i?this.location:this.position,s=e.x,n=e.y,o=t.x,r=t.y;if((s===o||isNaN(s)&&isNaN(o))&&(n===r||isNaN(n)&&isNaN(r)))return;const l=o-(isNaN(s)?0:s),h=r-(isNaN(n)?0:n),a=Point.l();super.move(t,i);const c=new GSet,u=this.findSubGraphParts().iterator;for(;u.next();){const d=u.value;d instanceof Link&&(d.suspendsRouting&&c.add(d),!(!d.Me&&(d.fromNode===this||d.toNode===this))&&(d.suspendsRouting=!0))}for(u.reset();u.next();){const d=u.value;if(d.Cl()||d instanceof Node&&d.isLinkLabel)continue;const m=d.position,g=d.location;m.isReal()?(a.x=m.x+l,a.y=m.y+h,d.position=a):g.isReal()&&(a.x=g.x+l,a.y=g.y+h,d.location=a)}for(u.reset();u.next();){const d=u.value;if(!(d instanceof Link)||(d.suspendsRouting=c.has(d),!d.Me&&(d.fromNode===this||d.toNode===this)))continue;const m=d.position;a.x=m.x+l,a.y=m.y+h,a.isReal()?d.move(a):d.invalidateRoute()}Point.s(a)}wO(){return(this.E&65536)!==0}kL(t){(this.E&65536)!==0!==t&&(this.E=this.E^65536)}get Jr(){return(this.E&32768)!==0}set Jr(t){(this.E&32768)!==0!==t&&(this.E=this.E^32768)}}class Placeholder extends GraphObject{$t;Kd;constructor(t){super(),this.$t=Margin.Eg,this.Kd=new Rect(NaN,NaN,NaN,NaN),t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.$t=this.$t.N(),t.Kd=this.Kd.copy()}hh(t){if(this.background===null)return!1;const i=this.naturalBounds;return Rect.contains(0,0,i.width,i.height,t.x,t.y)}Qu(t,i,e,s){const n=this.part;if((n===null||!(n instanceof Group)&&!(n instanceof Adornment))&&Util.o("Placeholder is not inside a Group or Adornment."),n instanceof Group){const o=this.computeBorder(this.Kd),r=this.minSize,l=isFinite(r.width)?Math.max(r.width,o.width):o.width,h=isFinite(r.height)?Math.max(r.height,o.height):o.height,a=this.Vi;a.En(l||0,h||0),this.Qn(0,0,a.width,a.height);const c=n.memberParts;let f=!1;for(;c.next();)if(c.value.isVisible()){f=!0;break}const u=n.diagram;if(f&&u!==null&&!u.animationManager.CS(n)&&!isNaN(o.x)&&!isNaN(o.y)){const d=Point.l();d.setRectSpot(o,n.locationSpot),n.location=d,Point.s(d)}}else{const o=n,r=this.Vi,l=this.$t,h=l.left+l.right,a=l.top+l.bottom,c=o.adornedObject,f=c.getDocumentAngle();o.angle=f;let u=0;c instanceof Shape&&(u=c.strokeWidth);const d=c.getDocumentScale(),m=c.naturalBounds,g=(m.width+u)*d,p=(m.height+u)*d;if(o.type!==Panel.Link){const y=o.category==="Selection"?Spot.TopLeft:o.locationSpot,x=c.getDocumentPoint(y,Point.l());o.location=x,Point.s(x)}if(!isNaN(g)&&!isNaN(p))r.En(g+h||0,p+a||0),this.Qn(-l.left,-l.top,r.width,r.height);else{const y=c.getDocumentPoint(Spot.TopLeft,Point.l()),x=Rect.X(y.x,y.y,0,0);x.unionPoint(c.getDocumentPoint(Spot.BottomRight,y)),x.unionPoint(c.getDocumentPoint(Spot.TopRight,y)),x.unionPoint(c.getDocumentPoint(Spot.BottomLeft,y)),r.En(x.width+h||0,x.height+a||0),this.Qn(-l.left,-l.top,r.width,r.height),Point.s(y),Rect.s(x)}}}ah(t,i,e,s){this.actualBounds.e(t,i,e,s)}computeBorder(t){const i=this.part,e=i.diagram,s=e===null||!e.animationManager.isAnimating;if(e!==null&&i instanceof Group&&!i.layer.isTemporary&&i.computesBoundsAfterDrag&&this.Kd.isReal()){const l=e.toolManager.findTool("Dragging");if(l===e.currentTool){const h=l.computeBorder(i,this.Kd,t);if(h!==null)return h}}const n=Rect.l(),o=this.computeMemberBounds(n),r=this.$t;return i instanceof Group&&!i.isSubGraphExpanded?t.e(o.x-r.left,o.y-r.top,0,0):t.e(o.x-r.left,o.y-r.top,Math.max(o.width+r.left+r.right,0),Math.max(o.height+r.top+r.bottom,0)),Rect.s(n),s&&i instanceof Group&&i.computesBoundsIncludingLocation&&i.location.isReal()&&t.unionPoint(i.location),t}computeMemberBounds(t){if(!(this.part instanceof Group))return t.e(0,0,0,0),t;const i=this.part;let e=1/0,s=1/0,n=-1/0,o=-1/0;const r=i.memberParts;for(;r.next();){const l=r.value;if(!l.isVisible()||l instanceof Link&&(!i.computesBoundsIncludingLinks||l.Oo()||l.fromNode===i||l.toNode===i))continue;const h=l.actualBounds;h.leftn&&(n=h.right),h.bottom>o&&(o=h.bottom)}if(!isFinite(e)||!isFinite(s)){const l=i.location;t.e(l.x,l.y,0,0)}else t.e(e,s,n-e,o-s);return t}get padding(){return this.$t}set padding(t){typeof t=="number"&&(t=new Margin(t));const i=this.$t;i.equals(t)||(t=t.N(),this.$t=t,this.t("padding",i,t),this.c())}}class Layout{p;ha;Yd;kr;Gd;jd;Fo;ul;Hd;qd;go;constructor(t){GSet.Yi(this),this.p=null,this.ha=null,this.Yd=!0,this.kr=!0,this.Gd=!1,this.jd=new Point(0,0).g(),this.Fo=!0,this.ul=null,this.Hd=null,this.qd=!1,this.go=null,t&&Object.assign(this,t)}cloneProtected(t){t.Yd=this.Yd,t.kr=this.kr,t.Gd=this.Gd,t.jd.a(this.jd),t.Fo=this.Fo,t.ul=this.ul,t.Hd=this.Hd,t.qd=!0}copy(){const t=new this.constructor;return this.cloneProtected(t),t}ri(t){Util.lr(this,t)}toString(){let t=Util.sn(this.constructor);return t+="(",this.group!==null&&(t+=" in "+this.group),this.diagram!==null&&(t+=" for "+this.diagram),t+=")",t}get diagram(){return this.p}set diagram(t){this.p=t}get group(){return this.ha}set group(t){this.ha!==t&&(this.ha=t,t!==null&&(this.p=t.diagram))}get isOngoing(){return this.Yd}set isOngoing(t){this.Yd!==t&&(Util.i(t,"boolean",Layout,"isOngoing"),this.Yd=t)}get isInitial(){return this.kr}set isInitial(t){Util.i(t,"boolean",Layout,"isInitial"),this.kr=t,t||(this.qd=!0)}get isViewportSized(){return this.Gd}set isViewportSized(t){this.Gd!==t&&(Util.i(t,"boolean",Layout,"isViewportSized"),this.Gd=t,t&&this.invalidateLayout())}get isRouting(){return this.Fo}set isRouting(t){this.Fo!==t&&(Util.i(t,"boolean",Layout,"isRouting"),this.Fo=t)}get isRealtime(){return this.ul}set isRealtime(t){this.ul!==t&&(t!==null&&Util.i(t,"boolean",Layout,"isRealtime"),this.ul=t)}get isValidLayout(){return this.qd}set isValidLayout(t){if(this.qd!==t&&(Util.i(t,"boolean",Layout,"isValidLayout"),this.qd=t,!t)){const i=this.diagram;i!==null&&(i.Kr=!0)}}invalidateLayout(){if(this.isValidLayout){const t=this.diagram;if(t===null||t.undoManager.isUndoingRedoing)return;const i=t.animationManager;if(i.isTicking)return;i.defaultAnimation.isAnimating&&i.stopAnimation(),(this.isOngoing&&t.Bh||this.isInitial&&!t.Bh)&&(this.isValidLayout=!1,t.requestUpdate())}}get network(){return this.go}set network(t){this.go!==t&&(this.go=t,t!==null&&(t.layout=this))}createNetwork(){return new LayoutNetwork(this)}makeNetwork(t){const i=this.createNetwork();return t instanceof Diagram?(i.addParts(t.nodes,!0),i.addParts(t.links,!0)):t instanceof Group?i.addParts(t.memberParts):i.addParts(t.iterator),i}updateParts(){this.isValidLayout=!0;let t=this.diagram;if(t===null&&this.network!==null){const i=this.network.vertexes.iterator;for(;i.next();){const s=i.value.node;if(s!==null&&(t=s.diagram,t!==null))break}}try{t!==null&&t.startTransaction("Layout"),this.commitLayout()}finally{t!==null&&t.commitTransaction("Layout")}}commitLayout(){if(this.network===null)return;const t=this.network.vertexes.iterator;for(;t.next();)t.value.commit();if(this.isRouting){const i=this.network.edges.iterator;for(;i.next();)i.value.commit()}}doLayout(t){const i=new GSet;if(t instanceof Diagram?(this.kh(i,t.nodes,!0,this.Jr,!0,!1,!0),this.kh(i,t.parts,!0,this.Jr,!0,!1,!0)):t instanceof Group?this.kh(i,t.memberParts,!1,this.Jr,!0,!1,!0):i.addAll(t.iterator),i.count>0){const s=this.diagram;s!==null&&s.startTransaction("Layout"),this.doMinimalNoNetworkLayout(i),s!==null&&s.commitTransaction("Layout")}this.isValidLayout=!0}doMinimalNoNetworkLayout(t){const i=t.count,e=Math.ceil(Math.sqrt(i));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const s=this.arrangementOrigin.x,n=this.arrangementOrigin.y;let o=s,r=n,l=0,h=0;const a=t.iterator;for(;a.next();){const c=a.value;c.ensureBounds();const f=c.measuredBounds,u=f.width,d=f.height;c.moveTo(o,r),c instanceof Group&&(c.Jr=!1),o+=Math.max(u,50)+20,h=Math.max(h,Math.max(d,50)),l>=e-1?(l=0,o=s,r+=h+20,h=0):l++}}doMinimalNetworkLayout(){const t=this.network.vertexes.count,i=Math.ceil(Math.sqrt(t));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const e=this.arrangementOrigin.x,s=this.arrangementOrigin.y;let n=e,o=s,r=0,l=0;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value.node;if(a===null||a instanceof Link||(a.ensureBounds(),!this.Jr(a)))continue;const c=a.measuredBounds,f=c.width,u=c.height;a.moveTo(n,o),a instanceof Group&&(a.Jr=!1),n+=Math.max(f,50)+20,l=Math.max(l,Math.max(u,50)),r>=i-1?(r=0,n=e,o+=l+20,l=0):r++}}Jr(t){return!!(!t.location.isReal()&&!t.position.isReal()||t instanceof Group&&t.Jr)}kh(t,i,e,s,n,o,r){const l=i.iterator;for(;l.next();){const h=l.value;if(!(e&&!h.isTopLevel)&&!(s!==null&&!s(h))&&h.canLayout())if(n&&h instanceof Node){if(h.isLinkLabel)continue;h instanceof Group&&h.layout===null?this.kh(t,h.memberParts,!1,s,n,o,r):(h.ensureBounds(),t.add(h))}else o&&h instanceof Link?t.add(h):r&&h.Pe()&&!(h instanceof Node)&&(h.ensureBounds(),t.add(h))}}getLayoutBounds(t,i){const e=this.boundsComputation;return e!==null?(i||(i=new Rect),e(t,this,i)):!i&&t.margin.equalTo(0,0,0,0)?t.actualBounds:(i||(i=new Rect),i.set(t.actualBounds),i.addMargin(t.margin),i)}get boundsComputation(){return this.Hd}set boundsComputation(t){this.Hd!==t&&(t!==null&&Util.i(t,"function",Layout,"boundsComputation"),this.Hd=t,this.invalidateLayout())}collectParts(t){const i=new GSet;return t instanceof Diagram?(this.kh(i,t.nodes,!0,null,!0,!0,!0),this.kh(i,t.links,!0,null,!0,!0,!0),this.kh(i,t.parts,!0,null,!0,!0,!0)):t instanceof Group?this.kh(i,t.memberParts,!1,null,!0,!0,!0):this.kh(i,t.iterator,!1,null,!0,!0,!0),i}get arrangementOrigin(){return this.jd}set arrangementOrigin(t){this.jd.equals(t)||(this.jd.a(t),this.invalidateLayout())}initialOrigin(t){const i=this.group;if(i!==null)if(i.hasPlaceholder()){const e=i.placeholder,s=e.getDocumentPoint(Spot.TopLeft);(isNaN(s.x)||isNaN(s.y))&&s.set(t);const n=e.padding;return s.x+=n.left,s.y+=n.top,s}else{const e=i.position.copy();return(isNaN(e.x)||isNaN(e.y))&&e.set(t),e}return t}}class LayoutNetwork{ie;mo;Cn;ky;Py;constructor(t){GSet.Yi(this),this.ie=t,this.mo=new GSet,this.Cn=new GSet,this.ky=new GMap,this.Py=new GMap}clear(){if(this.mo){const t=this.mo.iterator;for(;t.next();)t.value.clear()}if(this.Cn){const t=this.Cn.iterator;for(;t.next();)t.value.clear()}this.mo=new GSet,this.Cn=new GSet,this.ky=new GMap,this.Py=new GMap}toString(t){t===void 0&&(t=0);let i="LayoutNetwork"+(this.layout!==null?"("+this.layout.toString()+")":"");if(t<=0)return i;if(i+=" vertexes: "+this.mo.count+" edges: "+this.Cn.count,t>1){const e=this.mo.iterator;for(;e.next();){const n=e.value;i+=` `+n.toString(t-1)}const s=this.Cn.iterator;for(;s.next();){const n=s.value;i+=` - `+n.toString(t-1)}}return i}get layout(){return this.te}set layout(t){t!==null&&(this.te=t)}get vertexes(){return this.mo}get edges(){return this.Cn}createVertex(){return new LayoutVertex(this)}createEdge(){return new LayoutEdge(this)}addParts(t,i,e){if(t===null)return;i===void 0&&(i=!1),Util.i(i,"boolean",LayoutNetwork,"addParts:toplevelonly"),e===void 0&&(e=null),e===null&&(e=n=>{if(n instanceof Node)return!n.isLinkLabel;if(n instanceof Link){const o=n.fromNode;if(o===null||o.isLinkLabel)return!1;const r=n.toNode;return!(r===null||r.isLinkLabel)}return!1});const s=t.iterator;for(;s.next();){const n=s.value;if(n instanceof Node&&!(i&&!n.isTopLevel)&&n.canLayout()&&e(n))if(n instanceof Group&&n.layout===null)this.addParts(n.memberParts,!1);else{if(this.findVertex(n)!==null)continue;const o=this.createVertex();o.node=n,this.addVertex(o)}}for(s.reset();s.next();){const n=s.value;if(!(n instanceof Link)||i&&!n.isTopLevel||!n.canLayout()||!e(n)||this.findEdge(n)!==null)continue;const o=n.fromNode,r=n.toNode;if(o===null||r===null||o===r)continue;const l=this.findGroupVertex(o),h=this.findGroupVertex(r);this.linkVertexes(l,h,n)}}findGroupVertex(t){if(t===null)return null;const i=t.findVisibleNode();if(i===null)return null;let e=this.findVertex(i);if(e!==null)return e;let s=i.containingGroup;for(;s!==null;){if(e=this.findVertex(s),e!==null)return e;s=s.containingGroup}return null}addVertex(t){if(t===null)return;this.mo.add(t);const i=t.node;i!==null&&this.ky.set(i,t),t.network=this}addNode(t){if(t===null)return null;let i=this.findVertex(t);return i===null&&(i=this.createVertex(),i.node=t,this.addVertex(i)),i}deleteVertex(t){if(t!==null&&this.cT(t)){let i=t._o;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}i=t.tr;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}}}cT(t){if(t===null)return!1;const i=this.mo.delete(t);if(i){const e=t.node;e!==null&&this.ky.delete(e)}return i}deleteNode(t){if(t===null)return;const i=this.findVertex(t);i!==null&&this.deleteVertex(i)}findVertex(t){return t===null?null:this.ky.get(t)}addEdge(t){if(t===null)return;this.uN(t);const i=t.toVertex;i!==null&&i.addSourceEdge(t);const e=t.fromVertex;e!==null&&e.addDestinationEdge(t)}uN(t){if(t===null)return;this.Cn.add(t);const i=t.link;i!==null&&this.findEdge(i)===null&&this.Py.set(i,t),t.network=this}addLink(t){if(t===null)return null;const i=t.fromNode,e=t.toNode;let s=this.findEdge(t);return s===null?(s=this.createEdge(),s.link=t,i!==null&&(s.fromVertex=this.addNode(i)),e!==null&&(s.toVertex=this.addNode(e)),this.addEdge(s)):(i!==null?s.fromVertex=this.addNode(i):s.fromVertex=null,e!==null?s.toVertex=this.addNode(e):s.toVertex=null),s}deleteEdge(t){if(t===null)return;const i=t.toVertex;i!==null&&i.deleteSourceEdge(t);const e=t.fromVertex;e!==null&&e.deleteDestinationEdge(t),this.dN(t)}dN(t){if(t===null)return!1;const i=this.Cn.delete(t);if(i){const e=t.link;e!==null&&this.Py.delete(e)}return i}deleteLink(t){if(t===null)return;const i=this.findEdge(t);i!==null&&this.deleteEdge(i)}findEdge(t){return t===null?null:this.Py.get(t)}linkVertexes(t,i,e){if(t===null||i===null)return null;if(t.network===this&&i.network===this){const s=this.createEdge();return s.link=e,s.fromVertex=t,s.toVertex=i,this.addEdge(s),s}return null}reverseEdge(t){if(t===null)return;const i=t.fromVertex,e=t.toVertex;i===null||e===null||(i.deleteDestinationEdge(t),e.deleteSourceEdge(t),t.reverseEdge(),i.addSourceEdge(t),e.addDestinationEdge(t))}deleteSelfEdges(){const t=Util.ot(),i=this.Cn.iterator;for(;i.next();){const s=i.value;s.fromVertex===s.toVertex&&t.push(s)}const e=t.length;for(let s=0;s0||t.tr.count>0)}splitIntoSubNetworks(t){t===void 0&&(t=!0),t&&(this.deleteArtificialVertexes(),this.deleteUselessEdges(),this.deleteSelfEdges());const i=new List;let e=!0;for(;e;){e=!1;const s=this.mo.iterator;for(;s.next();){const n=s.value;if(this.isSingleton(n))continue;const o=this.layout.createNetwork();i.add(o),this.bO(o,n),e=!0;break}}return i.sort((s,n)=>s===null||n===null||s===n?0:n.vertexes.count-s.vertexes.count),i}bO(t,i){if(i===null)return;const e=new List;for(e.add(i);e.count>0;){const s=e.first();if(e.removeAt(0),s.network===t)continue;this.cT(s),t.addVertex(s);let n=s.sourceEdges;for(;n.next();){const o=n.value;o.network!==t&&(this.dN(o),t.uN(o),e.add(o.fromVertex))}for(n=s.destinationEdges;n.next();){const o=n.value;o.network!==t&&(this.dN(o),t.uN(o),e.add(o.toVertex))}}}findAllParts(){const t=new GSet,i=this.mo.iterator;for(;i.next();){const s=i.value;t.add(s.node)}const e=this.Cn.iterator;for(;e.next();){const s=e.value;t.add(s.link)}return t}}class LayoutVertex{go;Qt;ue;Ae;qe;_o;tr;constructor(t){GSet.Yi(this),this.go=t,this.Ae=new Rect(0,0,10,10).g(),this.qe=new Point(5,5).g(),this.Qt=null,this.ue=null,this._o=new List,this.tr=new List}clear(){this.Qt=null,this.ue=null,this._o=new List,this.tr=new List}toString(t){t===void 0&&(t=0);let i="LayoutVertex#"+GSet.as(this);if(t>0&&(i+=this.node!==null?"("+this.node.toString()+")":"",t>1)){let e="",s=!0,n=this._o.iterator;for(;n.next();){const r=n.value;s?s=!1:e+=",",e+=r.toString(0)}let o="";for(s=!0,n=this.tr.iterator;n.next();){const r=n.value;s?s=!1:o+=",",o+=r.toString(0)}i+=" sources: "+e+" destinations: "+o}return i}get po(){return this._o.$N}get ir(){return this.tr.$N}get data(){return this.Qt}set data(t){if(this.Qt=t,t!==null&&t.bounds){const i=t.bounds,e=i.x,s=i.y,n=i.width,o=i.height;this.qe.e(n/2,o/2),this.Ae.e(e,s,n,o)}}get node(){return this.ue}set node(t){if(this.ue!==t){this.ue=t,t.ensureBounds();const i=this.network.layout,e=Rect.l(),s=i.getLayoutBounds(t,e);let n=s.x,o=s.y;const r=s.width,l=s.height;if(isNaN(n)&&(n=0),isNaN(o)&&(o=0),this.Ae.e(n,o,r,l),Rect.s(e),!(t instanceof Group)){const h=t.locationObject.getDocumentPoint(Spot.Center);if(h.isReal()){this.qe.e(h.x-n,h.y-o);return}}this.qe.e(r/2,l/2)}}get bounds(){return this.Ae}set bounds(t){this.Ae.equals(t)||this.Ae.a(t)}get focus(){return this.qe}set focus(t){this.qe.equals(t)||this.qe.a(t)}get centerX(){return this.Ae.x+this.qe.x}set centerX(t){const i=this.Ae;i.x+this.qe.x!==t&&(i.rt(),i.x=t-this.qe.x,i.g())}get centerY(){return this.Ae.y+this.qe.y}set centerY(t){const i=this.Ae;i.y+this.qe.y!==t&&(i.rt(),i.y=t-this.qe.y,i.g())}get focusX(){return this.qe.x}set focusX(t){const i=this.qe;i.x!==t&&(i.rt(),i.x=t,i.g())}get focusY(){return this.qe.y}set focusY(t){const i=this.qe;i.y!==t&&(i.rt(),i.y=t,i.g())}get x(){return this.Ae.x}set x(t){const i=this.Ae;i.x!==t&&(i.rt(),i.x=t,i.g())}get y(){return this.Ae.y}set y(t){const i=this.Ae;i.y!==t&&(i.rt(),i.y=t,i.g())}get width(){return this.Ae.width}set width(t){const i=this.Ae;i.width!==t&&(i.rt(),i.width=t,i.g())}get height(){return this.Ae.height}set height(t){const i=this.Ae;i.height!==t&&(i.rt(),i.height=t,i.g())}commit(){const t=this.Qt;if(t!==null){const e=this.bounds,s=t.bounds;Util.wt(s)?(s.x=e.x,s.y=e.y,s.width=e.width,s.height=e.height):t.bounds=e.copy();return}const i=this.node;if(i!==null){const e=this.bounds;if(!(i instanceof Group)){const s=Rect.l();i.ensureBounds();const n=this.network.layout.getLayoutBounds(i,s),o=i.locationObject.getDocumentPoint(Spot.Center);if(n.isReal()&&o.isReal()){i.moveTo(e.x+this.focusX-(o.x-n.x)+i.margin.left,e.y+this.focusY-(o.y-n.y+i.margin.top)),Rect.s(s);return}Rect.s(s)}i.moveTo(e.x+i.margin.left,e.y+i.margin.top)}}addSourceEdge(t){t!==null&&(this._o.has(t)||this._o.add(t))}deleteSourceEdge(t){t!==null&&this._o.delete(t)}addDestinationEdge(t){t!==null&&(this.tr.has(t)||this.tr.add(t))}deleteDestinationEdge(t){t!==null&&this.tr.delete(t)}get network(){return this.go}set network(t){this.go=t}get sourceVertexes(){const t=new GSet,i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}return t.iterator}get destinationVertexes(){const t=new GSet,i=this.destinationEdges;for(;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get vertexes(){const t=new GSet;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get sourceEdges(){return this._o.iterator}get destinationEdges(){return this.tr.iterator}get edges(){const t=new List;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e)}return t.iterator}get edgesCount(){return this._o.count+this.tr.count}static standardComparer(t,i){const e=t.ue,s=i.ue;if(e)if(s){const n=e.text,o=s.text;return no?1:0}else return 1;else return s!==null?-1:0}static smartComparer(t,i){if(t!==null)if(i!==null){const e=t.ue,s=i.ue;if(e!==null)if(s!==null){const n=e.text.toLocaleLowerCase(),o=s.text.toLocaleLowerCase(),r=n.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),l=o.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let h=0;for(;h0&&(i+=this.He!==null?"("+this.He.toString()+")":"",t>1&&(i+=" "+(this.We?this.We.toString():"null")+" --> "+(this.Je?this.Je.toString():"null"))),i}reverseEdge(){const t=this.We;this.We=this.Je,this.Je=t}commit(){}getOtherVertex(t){return this.Je===t?this.We:this.We===t?this.Je:null}get network(){return this.go}set network(t){this.go=t}get data(){return this.Qt}set data(t){this.Qt!==t&&(this.Qt=t)}get link(){return this.He}set link(t){this.He!==t&&(this.He=t)}get fromVertex(){return this.We}set fromVertex(t){this.We!==t&&(this.We=t)}get toVertex(){return this.Je}set toVertex(t){this.Je!==t&&(this.Je=t)}}var GridAlignment=(w=>(w[w.Position=0]="Position",w[w.Location=1]="Location",w))(GridAlignment||{}),GridArrangement=(w=>(w[w.LeftToRight=10]="LeftToRight",w[w.RightToLeft=11]="RightToLeft",w))(GridArrangement||{}),GridSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w))(GridSorting||{});class GridLayout extends Layout{Jd;$d;Lo;Ln;ni;zi;pe;ye;constructor(t){super(),this.isViewportSized=!0,this.Jd=NaN,this.$d=NaN,this.Lo=new Size(NaN,NaN).g(),this.Ln=new Size(10,10).g(),this.ni=1,this.zi=10,this.pe=22,this.ye=GridLayout.standardComparer,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Jd=this.Jd,t.$d=this.$d,t.Lo.a(this.Lo),t.Ln.a(this.Ln),t.ni=this.ni,t.zi=this.zi,t.pe=this.pe,t.ye=this.ye}ri(t){t in GridSorting?this.sorting=t:t in GridArrangement?this.arrangement=t:t in GridAlignment?this.alignment=t:super.ri(t)}doLayout(t){this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.collectParts(t),e=this.diagram,n=i.copy().iterator;for(;n.next();){const m=n.value;if(m.Cl()&&(m.fromNode!==null||m.toNode!==null)){i.delete(m);continue}if(m.ensureBounds(),m instanceof Group){const g=m.memberParts;for(;g.next();){const p=g.value;i.delete(p)}}}const o=i.toArray();if(o.length===0)return;switch(this.sorting){case 20:break;case 21:o.reverse();break;case 22:o.sort(this.comparer);break;case 23:o.sort(this.comparer),o.reverse();break}let r=this.wrappingColumn;isNaN(r)&&(r=0);let l=this.wrappingWidth;if(isNaN(l)&&e!==null){const m=e.viewportBounds,g=e.padding;l=Math.max(m.width-g.left-g.right,0)}else l=Math.max(this.wrappingWidth,0);r<=0&&l<=0&&(r=1);let h=this.spacing.width;isFinite(h)||(h=0);let a=this.spacing.height;isFinite(a)||(a=0),e!==null&&e.startTransaction("Layout");const c=[];switch(this.alignment){case 0:this.kO(o,l,r,h,a,c);break;case 1:this.PO(o,l,r,h,a,c);break}let f=0,u=0,d=0;for(let m=0;m0&&m>e-1||i>0&&m>0&&L-c>i)&&(o.push(new Rect(0,d,i+s,g)),m=0,u=c,d+=g,g=0),g=Math.max(g,M);let C=0;switch(a){case 11:C=-x.width;break;default:C=0;break}switch(y.moveTo(u+C+y.margin.left,d+y.margin.top),a){case 11:u-=P;break;default:u+=P;break}m++}o.push(new Rect(0,d,i+s,g)),Rect.s(r)}PO(t,i,e,s,n,o){const r=Rect.l();let l=Math.max(this.cellSize.width,1),h=0,a=0,c=0;const f=Point.l();for(let C=0;C=h&&(i-=h);let x=0,k=0;const b=Math.max(this.cellSize.height,1);c=0;let P=0,M=!0;const L=Point.l();for(let C=0;C0)switch(u){case 11:{let D=(g-d-(N.width-T.x))/l;Geo.K(Math.round(D),D)?D=Math.round(D):D=Math.floor(D),g=D*l+d;break}default:{let D=(g-d+T.x)/l;Geo.K(Math.round(D),D)?D=Math.round(D):D=Math.ceil(D),g=D*l+d;break}}else switch(u){case 11:x=g+T.x+N.width;break;default:x=g-T.x;break}let A=0;switch(u){case 11:A=-(g+T.x)+x;break;default:A=g+N.width-T.x-x;break}if(e>0&&y>e-1||i>0&&y>0&&A>i){o.push(new Rect(0,M?p-c:p,i+s,P+c+n));for(let D=0;Dk&&(S.width+=S.x-k,S.x=k)}Rect.s(r)}commitLayers(t,i){}get wrappingWidth(){return this.Jd}set wrappingWidth(t){this.Jd!==t&&(Util.i(t,"number",GridLayout,"wrappingWidth"),(t>0||isNaN(t))&&(this.Jd=t,this.isViewportSized=isNaN(t),this.invalidateLayout()))}get wrappingColumn(){return this.$d}set wrappingColumn(t){this.$d!==t&&(Util.i(t,"number",GridLayout,"wrappingColumn"),(t>0||isNaN(t))&&(this.$d=t,this.invalidateLayout()))}get cellSize(){return this.Lo}set cellSize(t){this.Lo.equals(t)||(this.Lo.a(t),this.invalidateLayout())}get spacing(){return this.Ln}set spacing(t){this.Ln.equals(t)||(this.Ln.a(t),this.invalidateLayout())}get alignment(){return this.ni}set alignment(t){this.ni!==t&&(t===1||t===0)&&(this.ni=t,this.invalidateLayout())}get arrangement(){return this.zi}set arrangement(t){this.zi!==t&&(t===10||t===11)&&(this.zi=t,this.invalidateLayout())}get sorting(){return this.pe}set sorting(t){this.pe!==t&&(t===20||t===21||t===22||t===23)&&(this.pe=t,this.invalidateLayout())}get comparer(){return this.ye}set comparer(t){this.ye!==t&&(Util.i(t,"function",GridLayout,"comparer"),this.ye=t,this.invalidateLayout())}static standardComparer(t,i){const e=t.text,s=i.text;return es?1:0}static smartComparer(t,i){if(t!==null)if(i!==null){const e=t.text.toLocaleLowerCase(),s=i.text.toLocaleLowerCase(),n=e.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),o=s.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let r=0;for(;r{e.containsNodeData(s)&&this.gT(s,!1)}),t.forEach(s=>{e.containsNodeData(s)&&this.S1(s)}),i!==!1&&this.diagram.bb(!1)}gT(t,i){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.yo.has(t))return null;i===void 0&&(i=!0);const e=this.MO(t);return e!==null&&i&&this.S1(t),e}MO(t){if(t==null||this.p.undoManager.isUndoingRedoing||this.yo.has(t))return null;const i=this.SO(t),e=this.findTemplateForNodeData(t,i);if(e!==null){e.li();const s=e.copy();if(s!==null){const n=this.diagram.ce;return this.diagram.ce=!0,s.Ho=i,s.Qt=t,this.My&&(s.ll="Tool"),this.diagram.add(s),s.Qt=null,s.data=t,this.diagram.ce=n,s}}return null}insertLink(t,i,e,s){return null}S1(t){}SO(t){return this.p.model.getCategoryForNodeData(t)}static mT=!1;static pT=!1;findTemplateForNodeData(t,i){const e=this.p,s=e.model,n=s.Hc()&&s.isGroupForData(t);let o=null;return n?(o=e.groupTemplateMap.get(i),o===null&&(o=e.groupTemplateMap.get(""),o===null&&(PartManager.pT||(PartManager.pT=!0,Util.oi('No Group template found for category "'+i+'"'),Util.oi(" Using default group template")),o=e.rS))):(o=e.nodeTemplateMap.get(i),o===null&&(o=e.nodeTemplateMap.get(""),o===null&&(PartManager.mT||(PartManager.mT=!0,Util.oi('No Node template found for category "'+i+'"'),Util.oi(" Using default node template")),o=e.sS))),o}getLinkCategoryForData(t){return""}setLinkCategoryForData(t,i){}setFromNodeForLink(t,i,e){}setToNodeForLink(t,i,e){}static yT=!1;findLinkTemplateForCategory(t){const i=this.p;let e=i.linkTemplateMap.get(t);return e===null&&(e=i.linkTemplateMap.get(""),e===null&&(PartManager.yT||(PartManager.yT=!0,Util.oi('No Link template found for category "'+t+'"'),Util.oi(" Using default link template")),e=i.nS)),e}uv(t,i,e){t instanceof Link?(i!==null&&this.uT(i,t),e!==null&&this.fT(e,t)):t instanceof Part&&(i!==null&&this.yo.delete(i),e!==null&&this.yo.set(e,t))}dT(){const t=this.diagram.model;this.mN(t.nodeDataArray)}mN(t){t.forEach(i=>{this.N1(i)})}N1(t){const i=this.findPartForData(t);i!==null&&(this.diagram.NS(i,!1),this.pN(i))}pN(t){}rN(t){}findPartForKey(t){if(t==null)return null;const i=this.p.model.findNodeDataForKey(t);return i!==null?this.yo.get(i):null}findNodeForKey(t){if(t==null)return null;const i=this.p.model.findNodeDataForKey(t);if(i===null)return null;const e=this.yo.get(i);return e instanceof Node?e:null}findLinkForKey(t){return null}findPartForData(t){if(t===null)return null;let i=this.yo.get(t);return i!==null||(i=this.dl.get(t)),i}findNodeForData(t){if(t===null)return null;const i=this.yo.get(t);return i instanceof Node?i:null}findLinkForData(t,i){return t===null?null:this.dl.get(t)}findNodesByExample(...t){const i=new GSet,e=this.Zd.iterator;for(;e.next();){const s=e.value,n=s.data;if(n!==null)for(let o=0;o{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),this.parts.each(o=>{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),s.forEach(o=>t.xT(o,!1));for(let o=0;o0){for(let o=0;oi.SL(s));const e=t.gh;if(Array.isArray(e)){const s=this.Ua.get(e);if(s===null){const n=[];n.push(t),this.Ua.set(e,n)}else{for(let n=0;ni.pR(s));const e=t.gh;if(Array.isArray(e)){const s=this.Ua.get(e);if(s!==null){for(let n=0;n0&&i.removeParts(l,!1),h.count>0){const c=h.iterator;for(;c.next();){const f=c.key,u=c.value;s.set(f,u)}}}if(i!==null&&this.p!==null){const o=i.model,r=o.afterCopyFunction;if(r!==null){const l=new GMap;s.each(a=>{a.key.data!==null&&l.set(a.key.data,a.value.data)});const h=this.p.model;r(l,o,h)}}const n=s.iterator;for(;n.next();)n.value.updateTargetBindings();return s}C1(t,i,e,s){if(t===null||s&&!t.canCopy())return null;if(e.has(t))return e.get(t);const n=this.wN(t,i);if(!(n instanceof Part))return null;if(n.isSelected=!1,n.isHighlighted=!1,e.set(t,n),t instanceof Node){const o=t.linksConnected;for(;o.next();){const r=o.value;if(r.fromNode===t){const l=e.get(r);l!==null&&(l.fromNode=n)}if(r.toNode===t){const l=e.get(r);l!==null&&(l.toNode=n)}}if(t instanceof Group&&n instanceof Group){const r=t.memberParts;for(;r.next();){const l=r.value,h=this.C1(l,i,e,s);h instanceof Link||h!==null&&(h.containingGroup=n)}}}else if(t instanceof Link&&n instanceof Link){const o=t.fromNode;if(o!==null){const h=e.get(o);h!==null&&(n.fromNode=h)}const r=t.toNode;if(r!==null){const h=e.get(r);h!==null&&(n.toNode=h)}const l=t.labelNodes;for(;l.next();){const h=l.value,a=this.C1(h,i,e,s);a!==null&&a instanceof Node&&(a.labeledLink=n)}}return n}wN(t,i){let e=null;const s=t.data;if(s!==null&&i!==null){const n=i.model;if(!(t instanceof Link)){const o=n.copyNodeData(s);Util.wt(o)&&(n.addNodeData(o),e=i.findPartForData(o))}}else if(t.li(),e=t.copy(),e!==null){const n=this.p;if(i!==null)i.add(e);else if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const o=n.model;let r=null;e instanceof Link||(r=o.copyNodeData(s)),Util.wt(r)&&(e.data=r)}}return e}get nodes(){return this.Zd}get links(){return this.qs}get parts(){return this.At}get diagram(){return this.p}get addsToTemporaryLayer(){return this.My}set addsToTemporaryLayer(t){this.My=t}get preservesRebuildLocations(){return this.gN}set preservesRebuildLocations(t){this.gN=t}}class GraphLinksPartManager extends PartManager{LS(){const t=this.diagram.model;this.Sy(t.nodeDataArray),this.PT(t.linkDataArray)}Sy(t){super.Sy(t,!1);const i=this.links.iterator;for(;i.next();)i.value.Ad();this.diagram.bb(!1)}PT(t){t.forEach(i=>{this.MT(i)}),this.diagram.bb(!1)}MT(t){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.dl.has(t))return null;const i=this.getLinkCategoryForData(t),e=this.findLinkTemplateForCategory(i);if(e!==null){e.li();const s=e.copy();if(s!==null){const n=this.diagram.ce;this.diagram.ce=!0,s.Ho=i,s.Qt=t;const o=this.diagram.model,r=o.L1(t,!0);r!==""&&(s.fromPortId=r);const l=o.Te(t,!0);if(l!==void 0){const f=this.findNodeForKey(l);f instanceof Node&&(s.fromNode=f)}const h=o.L1(t,!1);h!==""&&(s.toPortId=h);const a=o.Te(t,!1);if(a!==void 0){const f=this.findNodeForKey(a);f instanceof Node&&(s.toNode=f)}const c=o.getLabelKeysForLinkData(t);return Array.isArray(c)&&c.forEach(f=>{const u=this.findNodeForKey(f);u!==null&&(u.labeledLink=s)}),this.My&&(s.ll="Tool"),this.diagram.add(s),s.Qt=null,s.data=t,this.diagram.ce=n,s}}return null}dT(){const t=this.diagram.model;this.ST(t.linkDataArray),this.mN(t.nodeDataArray)}ST(t){t.forEach(i=>{this.N1(i)})}getLinkCategoryForData(t){return this.diagram.model.getCategoryForLinkData(t)}setLinkCategoryForData(t,i){return this.diagram.model.setCategoryForLinkData(t,i)}setFromNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setFromKeyForLinkData(t.data,e.getKeyForNodeData(s))}setToNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setToKeyForLinkData(t.data,e.getKeyForNodeData(s))}rN(t){this.diagram.model.removeLinkData(t.data)}findPartForKey(t){const i=super.findPartForKey(t);if(i===null){const s=this.diagram.model.findLinkDataForKey(t);if(s!==null)return this.dl.get(s)}return i}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findLinkDataForKey(t);return e!==null?this.dl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.Y){i.Y=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="linkFromKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.fromNode=l}}else if(s==="linkToKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.toNode=l}}else if(s==="linkFromPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.fromPortId=r)}}else if(s==="linkToPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.toPortId=r)}}else if(s==="nodeGroupKey"){const n=t.object,o=this.findPartForData(n);if(o!==null){const r=t.newValue;if(r!==void 0){const l=this.findNodeForKey(r);l instanceof Group?o.containingGroup=l:o.containingGroup=null}else o.containingGroup=null}}else if(s==="linkLabelKeys"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.oldValue,l=t.newValue;Array.isArray(r)&&r.forEach(h=>{if(l.indexOf(h)>=0)return;const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=null)}),Array.isArray(l)&&l.forEach(h=>{const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=o)})}}else if(s==="linkCategory"){const n=t.object,o=this.findLinkForData(n),r=t.newValue;o!==null&&typeof r=="string"&&(o.category=r)}else if(s==="linkDataArray"){const n=t.oldValue;this.ST(n);const o=t.newValue;this.PT(o)}i.isModified=!0}else if(e===3){const n=t.newValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.MT(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=t.object,r=this.findLinkForData(o),l=this.findNodeForKey(n);r!==null&&l!==null&&(l.labeledLink=r)}i.isModified=!0}else if(e===4){const n=t.oldValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.N1(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=this.findNodeForKey(n);o!==null&&(o.labeledLink=null)}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&(n==="linkFromKeyProperty"||n==="linkToKeyProperty"||n==="linkFromPortIdProperty"||n==="linkToPortIdProperty"||n==="linkLabelKeysProperty"||n==="nodeIsGroupProperty"||n==="nodeGroupKeyProperty"||n==="linkCategoryProperty")&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.Y=!0}}}kT(){const t=this.diagram.model,i=new GSet,e=t.linkDataArray;e.forEach(n=>{i.add(n)});const s=[];this.links.each(n=>{n.data!==null&&!i.has(n.data)&&s.push(n.data)}),s.forEach(n=>{t.NT(n,!1)}),e.forEach(n=>{this.findLinkForData(n)===null&&t.CT(n,!1)})}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Link){let n=s.Te(i,!0),o=e.findNodeForKey(n);t.fromNode=o,n=s.Te(i,!1),o=e.findNodeForKey(n),t.toNode=o;const r=s.getLabelKeysForLinkData(i);if(r.length>0||t.labelNodes.count>0){if(r.length===1&&t.labelNodes.count===1){const f=r[0],u=t.labelNodes.first();if(s.getKeyForNodeData(u.data)===f)return}const l=new GSet().addAll(r),h=new GSet;t.labelNodes.each(f=>{if(f.data!==null){const u=s.getKeyForNodeData(f.data);u!==void 0&&h.add(u)}});const a=h.copy();a.removeAll(l);const c=l.copy();if(c.removeAll(h),a.count>0||c.count>0){const f=t;a.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink===f&&(d.labeledLink=null)}),c.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink!==f&&(d.labeledLink=f)})}}}else if(!(t instanceof Adornment)){const n=s.getGroupKeyForNodeData(i),o=e.findPartForKey(n);(o===null||o instanceof Group)&&(t.containingGroup=o)}}S1(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Cy(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)){if(n instanceof Group&&i.getGroupKeyForNodeData(l)===e){const h=this.findPartForData(l);h!==null&&(h.containingGroup=n)}}else{const h=this.findLinkForData(l);if(h!==null&&n instanceof Node){i.Te(l,!0)===e&&(h.fromNode=n),i.Te(l,!1)===e&&(h.toNode=n);const a=i.getLabelKeysForLinkData(l);Array.isArray(a)&&a.some(c=>c===e?(n.labeledLink=h,!0):!1)}}}i.Js(e)}const o=i.getGroupKeyForNodeData(t);if(o!==void 0){const r=this.findNodeForKey(o);r instanceof Group&&(n.containingGroup=r)}}}pN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data);if(e!==void 0){const s=t.linksConnected;for(;s.next();){const n=s.value;i.$s(e,n.data)}if(t.isLinkLabel){const n=t.labeledLink;n!==null&&i.$s(e,n.data)}if(t instanceof Group){const n=t.memberParts;for(;n.next();){const r=n.value.data;i.containsNodeData(r)&&i.$s(e,r)}}}}}wN(t,i){let e=super.wN(t,i);if(t instanceof Link){const s=t.data;if(s!==null&&i!==null){const n=i.model,o=n.copyLinkData(s);typeof o=="object"&&o!==null&&(n.addLinkData(o),e=i.findLinkForData(o))}else if(e!==null){const n=this.diagram;if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const r=n.model.copyLinkData(s);typeof r=="object"&&r!==null&&(e.data=r)}}}return e}insertLink(t,i,e,s){const n=this.diagram,o=n.model,r=n.toolManager.findTool("Linking");let l="";t!==null&&(i===null&&(i=t),l=i.portId,l===null&&(l=""));let h="";e!==null&&(s===null&&(s=e),h=s.portId,h===null&&(h=""));const a=r.archetypeLinkData;if(a instanceof Link){a.li();const c=a.copy();if(c!==null){c.fromNode=t,c.fromPortId=l,c.toNode=e,c.toPortId=h,n.add(c);const f=r.archetypeLabelNodeData;if(f instanceof Node){f.li();const u=f.copy();u!==null&&(u.labeledLink=c,n.add(u))}return c}}else if(a!==null){const c=o.copyLinkData(a);if(typeof c=="object"&&c!==null){t!==null&&o.Qd(c,o.getKeyForNodeData(t.data),!0),o._d(c,l,!0),e!==null&&o.Qd(c,o.getKeyForNodeData(e.data),!1),o._d(c,h,!1),o.addLinkData(c);const f=r.archetypeLabelNodeData;if(f!==null&&!(f instanceof Node)){const d=o.copyNodeData(f);if(typeof d=="object"&&d!==null){o.addNodeData(d);const m=o.getKeyForNodeData(d);m!==void 0&&o.addLabelKeyForLinkData(c,m)}}return n.findLinkForData(c)}}return null}}class TreePartManager extends PartManager{kh=null;A1(t,i){if(t===null||i===null||i.findTreeParentLink()!==null)return null;const e=this.diagram.toolManager.findTool("Linking");let s=t,n=i;if(this.diagram.isTreePathToChildren){if(e!==null&&e.bu(s,n,null,!0))return null}else if(s=i,n=t,e!==null&&e.bu(s,n,null,!0))return null;const o=this.getLinkCategoryForData(i.data),r=this.findLinkTemplateForCategory(o);if(r!==null){r.li();const l=r.copy();if(l!==null){const h=this.diagram.ce;return this.diagram.ce=!0,l.Ho=o,l.Qt=i.data,l.fromNode=s,l.toNode=n,this.diagram.add(l),l.Qt=null,l.data=i.data,this.diagram.ce=h,l}}return null}getLinkCategoryForData(t){return this.diagram.model.getParentLinkCategoryForNodeData(t)}setLinkCategoryForData(t,i){this.diagram.model.setParentLinkCategoryForNodeData(t,i)}setFromNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren)s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n));else{const o=this.kh;this.kh=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.toNode!==null?t.toNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.kh=o}}setToNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren){const o=this.kh;this.kh=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.fromNode!==null?t.fromNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.kh=o}else s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n))}rN(t){this.diagram.model.setParentKeyForNodeData(t.data,void 0)}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findNodeDataForKey(t);return e!==null?this.dl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.Y){i.Y=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="nodeParentKey"){const n=t.object,o=t.newValue,r=this.findNodeForKey(o),l=this.findNodeForData(n);if(this.kh!==null)r!==null&&(this.kh.data=n,this.kh.category=this.getLinkCategoryForData(n));else if(l!==null){const h=l.findTreeParentLink();h!==null?r===null?i.remove(h):i.isTreePathToChildren?h.fromNode=r:h.toNode=r:this.A1(r,l)}}else if(s==="parentLinkCategory"){const n=t.object,o=this.findNodeForData(n),r=t.newValue;if(o!==null&&typeof r=="string"){const l=o.findTreeParentLink();l!==null&&(l.category=r)}}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&n==="nodeParentKeyProperty"&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.Y=!0}}}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Node){const n=s.getParentKeyForNodeData(i),o=e.findNodeForKey(n),r=t.findTreeParentNode();if(o!==r){const l=t.findTreeParentLink();o!==null?l!==null?e.isTreePathToChildren?l.fromNode=o:l.toNode=o:this.A1(o,t):l!==null&&e.NS(l,!1)}}}Ny(t,i){if(super.Ny(t,i),typeof i=="string"&&this.findPartForData(t)!==null){const s=this.findLinkForData(t);s!==null&&s.updateTargetBindings(i)}}S1(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Cy(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)&&n instanceof Node&&i.getParentKeyForNodeData(l)===e){const h=this.findNodeForData(l);this.A1(n,h)}}i.Js(e)}const o=i.getParentKeyForNodeData(t);if(o!==void 0&&n instanceof Node){const r=this.findNodeForKey(o);this.A1(r,n)}}}pN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data),s=this.findLinkForData(t.data);if(s!==null){s.isSelected=!1,s.isHighlighted=!1;const r=s.layer;if(r!==null){const l=r._i(-1,s,!1);l>=0&&this.diagram.raiseChangedEvent(4,"parts",r,s,null,l,null);const h=s.layerChanged;h!==null&&h(s,r,null)}}const n=this.diagram.isTreePathToChildren,o=t.linksConnected;for(;o.next();){const r=o.value,h=(n?r.toNode:r.fromNode).data;i.containsNodeData(h)&&i.$s(e,h)}}}insertLink(t,i,e,s){const n=this.diagram.model;let o=t,r=e;if(this.diagram.isTreePathToChildren||(o=e,r=t),o!==null&&r!==null){const l=o.data,h=r.data;return n.setParentKeyForNodeData(h,n.getKeyForNodeData(l)),r.findTreeParentLink()}return null}}var BindingMode=(w=>(w[w.OneWay=1]="OneWay",w[w.TwoWay=2]="TwoWay",w))(BindingMode||{});class Binding{n;xN;Ba;Nf;Ph;Cf;Lf;Af;T1;ke;md;cf;constructor(t,i,e,s){GSet.Yi(this),t===void 0?t="":Util.i(t,"string",Binding,"constructor:targetprop"),i===void 0?i=t:Util.i(i,"string",Binding,"constructor:sourceprop"),e===void 0?e=null:e!==null&&Util.i(e,"function",Binding,"constructor:conv"),this.xN=-1,this.ke=null,this.Ba=t,this.md=0,this.cf=0,this.Nf=null,this.Ph=i,this.Cf=e,s===void 0?(this.Lf=1,this.Af=null):(this.Lf=2,this.Af=s),this.T1=new GSet,this.n=2}copy(){const t=new this.constructor;return this.cloneProtected(t),t}cloneProtected(t){t.Ba=this.Ba,t.md=this.md,t.cf=this.cf,t.Nf=this.Nf,t.Ph=this.Ph,t.Cf=this.Cf,t.Lf=this.Lf,t.Af=this.Af,t.n=this.n&-2}static OneWay=1;static TwoWay=2;static parseEnum(t,i){return Util.i(t,"function",Binding,"parseEnum:ctor"),e=>{let s=parseInt(e);return isNaN(s)&&(s=Util.Oh(t,e),s===null)?i:s}}ri(t){t in BindingMode?this.mode=t:Util.lr(this,t)}static toString(t){return Util.toString(t)}toString(){return"Binding("+this.targetProperty+":"+this.sourceProperty+(this.targetId!==-1?" "+this.targetId:"")+" "+BindingMode[this.mode]+")"}g(){return this.n=this.n|1,this}rt(){return this.n=this.n&-2,this}get targetId(){return this.xN}set targetId(t){this.h&&Util.T(this),Util.i(t,"number",Binding,"targetId"),this.xN=t}get targetProperty(){return this.Ba}set targetProperty(t){this.h&&Util.T(this),Util.i(t,"string",Binding,"targetProperty"),this.Ba=t}get sourceProperty(){return this.Ph}set sourceProperty(t){this.h&&Util.T(this),Util.i(t,"string",Binding,"sourceProperty"),this.Ph=t}get h(){return(this.n&1)!==0}get isToData(){return(this.n&2)!==0}get isToObject(){return(this.n&4)!==0}get isToModel(){return(this.n&8)!==0}get isToTheme(){return(this.n&16)!==0}get bN(){return this.isToTheme&&!(this.isToData||this.isToObject||this.isToModel)}Qu(){return!1}get sourceName(){return this.Nf}set sourceName(t){this.h&&Util.T(this),t!==null&&Util.i(t,"string",Binding,"sourceName"),this.Nf=t,t!==null?this.n=this.n&-3|4:this.n=this.n|2}get converter(){return this.Cf}set converter(t){this.h&&Util.T(this),t!==null&&Util.i(t,"function",Binding,"converter"),this.Cf=t}get backConverter(){return this.Af}set backConverter(t){this.h&&Util.T(this),t!==null&&Util.i(t,"function",Binding,"backConverter"),this.Af=t}get mode(){return this.Lf}set mode(t){this.h&&Util.T(this),this.isToTheme&&t===2&&Util.o("Theme Bindings cannot be TwoWay."),this.Lf=t}makeTwoWay(t){return this.isToTheme&&Util.o("Theme Bindings cannot be TwoWay."),this.mode=2,t&&(Util.i(t,"function",Binding,"makeTwoWay"),this.backConverter=t),this}ofObject(t){return this.h&&Util.T(this),t===void 0&&(t=""),this.sourceName=t,this}ofModel(){return this.h&&Util.T(this),this.n=this.n&-3&-5|8,this.Nf=null,this}QL(t,i){const e=this.sourceName;let s=null;return e===null||e===""?s=t:e==="/"?s=i.part:e==="."?s=i:e===".."?s=i.panel:s=t.findObject(e),s}check(t){const i=this.Ba,e=this.Ph,s=this.Cf;(this.Qu()&&s===null&&this.Mh===null&&i===""||s===null&&i==="")&&Util.oi("Binding error: target property is the empty string: "+this.toString()),this.Qu()&&this.bN&&e===""&&s===null&&this.Mh===null&&Util.oi("Binding error: theme bindings require a source property when not using a converter: "+this.toString()),t&&typeof i=="string"&&(typeof t.setAttribute!="function"&&i.length>0&&i[0]!=="_"&&!Util.fw(t,i)?Util.oi("Binding error: undefined target property: "+i+" on "+t.toString()):i==="name"&&t instanceof GraphObject&&Util.oi("Binding error: cannot modify GraphObject.name on "+t.toString()))}updateTarget(t,i,e){const s=this.Ph;if(e!==void 0&&s!==""&&s!==e)return;const n=this.Ba,o=this.Cf;let r=i;if(s!==""&&!this.bN&&(r=Model.vt(i,s)),r===void 0)return;const l=t.diagram?.themeManager??t.panel?.diagram?.themeManager;if(o===null){if(n!==""){if(this.Qu()&&(r=this.LT(l,r,t,n),r===void 0))return;Model.lt(t,n,r)}}else try{if(n!==""){let h=o(r,t);if(this.Qu()&&(h=this.LT(l,h,t,n),h===void 0))return;Model.lt(t,n,h)}else o(r,t)}catch{}}updateSource(t,i,e,s){if(this.Lf!==2)return;const n=this.Ba;if(e!==void 0&&n!==e)return;const o=this.Ph,r=this.Af;let l=t;if(n!==""&&(l=Model.vt(t,n)),l!==void 0&&!this.T1.has(t))try{this.T1.add(t);const h=s!==null?s.diagram:null,a=h!==null?h.model:null;if(r===null){if(o!=="")a!==null?a.setDataProperty(i,o,l):Model.lt(i,o,l);else if(a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const c=s.itemIndex,f=s.panel.itemArray;a.removeArrayItem(f,c),a.insertArrayItem(f,c,l)}}else try{if(o!==""){const c=r(l,i,a);a!==null?a.setDataProperty(i,o,c):Model.lt(i,o,c)}else{const c=r(l,i,a);if(c!==void 0&&a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const f=s.itemIndex,u=s.panel.itemArray;a.removeArrayItem(u,f),a.insertArrayItem(u,f,c)}}}catch{}}finally{this.T1.delete(t)}}}class ThemeBinding extends Binding{Ly;Mh;Va;constructor(t,i,e,s,n){super(t,i,s),e==null&&(e=""),n===void 0&&(n=null),this.Ly=e,this.Mh=n,this.Va=null,this.n=16}cloneProtected(t){super.cloneProtected(t),t.Ly=this.Ly,t.Mh=this.Mh,t.Va=this.Va}Qu(){return!0}get themeSource(){return this.Ly}set themeSource(t){this.h&&Util.T(this),t!==null&&Util.i(t,"string",ThemeBinding,"themeSource"),this.Ly=t,this.Va=null,t!==null?this.n=this.n|16:this.n=this.n&-17}get themeConverter(){return this.Mh}set themeConverter(t){this.h&&Util.T(this),t!==null&&Util.i(t,"function",ThemeBinding,"themeConverter"),this.Mh=t}ofData(){return this.h&&Util.T(this),this.n=this.n|2,this.Nf=null,this}LT(t,i,e,s){if(!t||(this.bN&&(i=this.Ph),!i&&i!==0))return;let n=this.themeSource;this.Va!==null?n=this.Va:typeof n=="string"&&n.includes(".")&&(this.Va=n.split("."),n=this.Va);let o=t.findValue(i,n,s);return o===void 0&&Util.oi(`Theme warning: ${i} could not be found when setting target property ${s}.`),typeof this.Mh=="function"&&(o=this.Mh(o,e)),o}}class Model{St;tg;vo;D1;De;Tf;Df;ig;eg;sg;ng;za;er;F1;Ro;R1;ti;Sh;og=new GSet;rg=new GSet;Ay;constructor(t,i){if(GSet.Yi(this),this.St="",this.tg="",this.vo=!1,this.D1={},this.De=[],this.ti=new GMap,this.Sh="key",this.Tf=null,this.Df=null,this.ig=!1,this.eg=!1,this.sg=!1,this.ng=null,this.za="category",this.er=new GMap,this.Ay=100,this.F1=new List,this.Ro=!1,this.R1=null,this.undoManager=new UndoManager,t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){t.St=this.St,t.tg=this.tg,t.vo=this.vo,t.Sh=this.Sh,t.Tf=this.Tf,t.Df=this.Df,t.ig=this.ig,t.eg=this.eg,t.sg=this.sg,t.Ay=this.Ay,t.ng=this.ng,t.za=this.za}copy(){const t=new this.constructor;return this.cloneProtected(t),t}clear(){this.De=[],this.ti.clear(),this.er.clear(),this.undoManager.clear()}toString(t){if(t===void 0&&(t=0),t>1)return this.toJson();{let i=(this.name!==""?this.name:"")+" Model";if(t>0){i+=` - node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n{if(u.model===e){if(u.modelChange==="nodeDataArray")u.change===3?n.add(u.newValue):u.change===4&&r.add(u.oldValue);else if(e.containsNodeData(u.object))o.add(u.object);else if(u.change===2&&(e.modelData===u.object||u.propertyName==="modelData"))s=!0;else if(u.object!==null)if(l&&l.has(u.object))l.get(u.object).each(m=>{e.containsNodeData(m)&&o.add(m)});else{if(u.object instanceof Model||e.Aa()&&e.containsLinkData(u.object))return;e.TT(u.object).each(m=>{o.add(m)})}}});const h=this.rg;h.clear(),n.each(u=>{h.add(e.getKeyForNodeData(u)),i||o.add(u)});const a=this.og;a.clear(),r.each(u=>{a.add(e.getKeyForNodeData(u)),i&&o.add(u)});const c=e.cloneDeep(o.toArray());let f=null;return s&&(f===null&&(f={}),f.modelData=this.cloneDeep(this.modelData)),h.count>0&&(f===null&&(f={}),i?f.removedNodeKeys=h.toArray():f.insertedNodeKeys=h.toArray()),c.length>0&&(f===null&&(f={}),f.modifiedNodeData=c),a.count>0&&(f===null&&(f={}),i?f.insertedNodeKeys=a.toArray():f.removedNodeKeys=a.toArray()),a.clear(),h.clear(),f}cloneDeep(t){return this.lg(t,!0)}lg(t,i,e,s,n){if(!Util.wt(t))return t;n||(n=[]);const o=Object.isExtensible(t);if(e||(e=new GMap),o){const h=e.get(t);if(h)return h}else{s||(s=new GMap);const h=s.iterator;for(;h.next();){const a=h.key;if(h.value===t){const f=e.get(a);if(f)return f}}}function r(h,a){if(o)h.__gohashid===void 0&&n.push(h),e.set(h,a);else{const c=GSet.nu++;e.set(c,a),s.set(c,t)}}let l;if(Array.isArray(t)){l=[],r(t,l);for(let h=0;h{delete h.__gohashid}),l}Fe(t){return JSON.stringify(t).replace(/[\u007F-\uFFFF]/g,e=>{const s="0000"+e.charCodeAt(0).toString(16);return"\\u"+s.substring(s.length-4)})}hg(){let t="";return this.name!==""&&(t+=`, + `+n.toString(t-1)}}return i}get layout(){return this.ie}set layout(t){t!==null&&(this.ie=t)}get vertexes(){return this.mo}get edges(){return this.Cn}createVertex(){return new LayoutVertex(this)}createEdge(){return new LayoutEdge(this)}addParts(t,i,e){if(t===null)return;i===void 0&&(i=!1),Util.i(i,"boolean",LayoutNetwork,"addParts:toplevelonly"),e===void 0&&(e=null),e===null&&(e=n=>{if(n instanceof Node)return!n.isLinkLabel;if(n instanceof Link){const o=n.fromNode;if(o===null||o.isLinkLabel)return!1;const r=n.toNode;return!(r===null||r.isLinkLabel)}return!1});const s=t.iterator;for(;s.next();){const n=s.value;if(n instanceof Node&&!(i&&!n.isTopLevel)&&n.canLayout()&&e(n))if(n instanceof Group&&n.layout===null)this.addParts(n.memberParts,!1);else{if(this.findVertex(n)!==null)continue;const o=this.createVertex();o.node=n,this.addVertex(o)}}for(s.reset();s.next();){const n=s.value;if(!(n instanceof Link)||i&&!n.isTopLevel||!n.canLayout()||!e(n)||this.findEdge(n)!==null)continue;const o=n.fromNode,r=n.toNode;if(o===null||r===null||o===r)continue;const l=this.findGroupVertex(o),h=this.findGroupVertex(r);this.linkVertexes(l,h,n)}}findGroupVertex(t){if(t===null)return null;const i=t.findVisibleNode();if(i===null)return null;let e=this.findVertex(i);if(e!==null)return e;let s=i.containingGroup;for(;s!==null;){if(e=this.findVertex(s),e!==null)return e;s=s.containingGroup}return null}addVertex(t){if(t===null)return;this.mo.add(t);const i=t.node;i!==null&&this.ky.set(i,t),t.network=this}addNode(t){if(t===null)return null;let i=this.findVertex(t);return i===null&&(i=this.createVertex(),i.node=t,this.addVertex(i)),i}deleteVertex(t){if(t!==null&&this.cT(t)){let i=t._o;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}i=t.tr;for(let e=i.count-1;e>=0;e--){const s=i.elt(e);this.deleteEdge(s)}}}cT(t){if(t===null)return!1;const i=this.mo.delete(t);if(i){const e=t.node;e!==null&&this.ky.delete(e)}return i}deleteNode(t){if(t===null)return;const i=this.findVertex(t);i!==null&&this.deleteVertex(i)}findVertex(t){return t===null?null:this.ky.get(t)}addEdge(t){if(t===null)return;this.cN(t);const i=t.toVertex;i!==null&&i.addSourceEdge(t);const e=t.fromVertex;e!==null&&e.addDestinationEdge(t)}cN(t){if(t===null)return;this.Cn.add(t);const i=t.link;i!==null&&this.findEdge(i)===null&&this.Py.set(i,t),t.network=this}addLink(t){if(t===null)return null;const i=t.fromNode,e=t.toNode;let s=this.findEdge(t);return s===null?(s=this.createEdge(),s.link=t,i!==null&&(s.fromVertex=this.addNode(i)),e!==null&&(s.toVertex=this.addNode(e)),this.addEdge(s)):(i!==null?s.fromVertex=this.addNode(i):s.fromVertex=null,e!==null?s.toVertex=this.addNode(e):s.toVertex=null),s}deleteEdge(t){if(t===null)return;const i=t.toVertex;i!==null&&i.deleteSourceEdge(t);const e=t.fromVertex;e!==null&&e.deleteDestinationEdge(t),this.fN(t)}fN(t){if(t===null)return!1;const i=this.Cn.delete(t);if(i){const e=t.link;e!==null&&this.Py.delete(e)}return i}deleteLink(t){if(t===null)return;const i=this.findEdge(t);i!==null&&this.deleteEdge(i)}findEdge(t){return t===null?null:this.Py.get(t)}linkVertexes(t,i,e){if(t===null||i===null)return null;if(t.network===this&&i.network===this){const s=this.createEdge();return s.link=e,s.fromVertex=t,s.toVertex=i,this.addEdge(s),s}return null}reverseEdge(t){if(t===null)return;const i=t.fromVertex,e=t.toVertex;i===null||e===null||(i.deleteDestinationEdge(t),e.deleteSourceEdge(t),t.reverseEdge(),i.addSourceEdge(t),e.addDestinationEdge(t))}deleteSelfEdges(){const t=Util.nt(),i=this.Cn.iterator;for(;i.next();){const s=i.value;s.fromVertex===s.toVertex&&t.push(s)}const e=t.length;for(let s=0;s0||t.tr.count>0)}splitIntoSubNetworks(t){t===void 0&&(t=!0),t&&(this.deleteArtificialVertexes(),this.deleteUselessEdges(),this.deleteSelfEdges());const i=new List;let e=!0;for(;e;){e=!1;const s=this.mo.iterator;for(;s.next();){const n=s.value;if(this.isSingleton(n))continue;const o=this.layout.createNetwork();i.add(o),this.xO(o,n),e=!0;break}}return i.sort((s,n)=>s===null||n===null||s===n?0:n.vertexes.count-s.vertexes.count),i}xO(t,i){if(i===null)return;const e=new List;for(e.add(i);e.count>0;){const s=e.first();if(e.removeAt(0),s.network===t)continue;this.cT(s),t.addVertex(s);let n=s.sourceEdges;for(;n.next();){const o=n.value;o.network!==t&&(this.fN(o),t.cN(o),e.add(o.fromVertex))}for(n=s.destinationEdges;n.next();){const o=n.value;o.network!==t&&(this.fN(o),t.cN(o),e.add(o.toVertex))}}}findAllParts(){const t=new GSet,i=this.mo.iterator;for(;i.next();){const s=i.value;t.add(s.node)}const e=this.Cn.iterator;for(;e.next();){const s=e.value;t.add(s.link)}return t}}class LayoutVertex{go;Qt;de;Ae;qe;_o;tr;constructor(t){GSet.Yi(this),this.go=t,this.Ae=new Rect(0,0,10,10).g(),this.qe=new Point(5,5).g(),this.Qt=null,this.de=null,this._o=new List,this.tr=new List}clear(){this.Qt=null,this.de=null,this._o=new List,this.tr=new List}toString(t){t===void 0&&(t=0);let i="LayoutVertex#"+GSet.as(this);if(t>0&&(i+=this.node!==null?"("+this.node.toString()+")":"",t>1)){let e="",s=!0,n=this._o.iterator;for(;n.next();){const r=n.value;s?s=!1:e+=",",e+=r.toString(0)}let o="";for(s=!0,n=this.tr.iterator;n.next();){const r=n.value;s?s=!1:o+=",",o+=r.toString(0)}i+=" sources: "+e+" destinations: "+o}return i}get po(){return this._o.WN}get ir(){return this.tr.WN}get data(){return this.Qt}set data(t){if(this.Qt=t,t!==null&&t.bounds){const i=t.bounds,e=i.x,s=i.y,n=i.width,o=i.height;this.qe.e(n/2,o/2),this.Ae.e(e,s,n,o)}}get node(){return this.de}set node(t){if(this.de!==t){this.de=t,t.ensureBounds();const i=this.network.layout,e=Rect.l(),s=i.getLayoutBounds(t,e);let n=s.x,o=s.y;const r=s.width,l=s.height;if(isNaN(n)&&(n=0),isNaN(o)&&(o=0),this.Ae.e(n,o,r,l),Rect.s(e),!(t instanceof Group)){const h=t.locationObject.getDocumentPoint(Spot.Center);if(h.isReal()){this.qe.e(h.x-n,h.y-o);return}}this.qe.e(r/2,l/2)}}get bounds(){return this.Ae}set bounds(t){this.Ae.equals(t)||this.Ae.a(t)}get focus(){return this.qe}set focus(t){this.qe.equals(t)||this.qe.a(t)}get centerX(){return this.Ae.x+this.qe.x}set centerX(t){const i=this.Ae;i.x+this.qe.x!==t&&(i.ot(),i.x=t-this.qe.x,i.g())}get centerY(){return this.Ae.y+this.qe.y}set centerY(t){const i=this.Ae;i.y+this.qe.y!==t&&(i.ot(),i.y=t-this.qe.y,i.g())}get focusX(){return this.qe.x}set focusX(t){const i=this.qe;i.x!==t&&(i.ot(),i.x=t,i.g())}get focusY(){return this.qe.y}set focusY(t){const i=this.qe;i.y!==t&&(i.ot(),i.y=t,i.g())}get x(){return this.Ae.x}set x(t){const i=this.Ae;i.x!==t&&(i.ot(),i.x=t,i.g())}get y(){return this.Ae.y}set y(t){const i=this.Ae;i.y!==t&&(i.ot(),i.y=t,i.g())}get width(){return this.Ae.width}set width(t){const i=this.Ae;i.width!==t&&(i.ot(),i.width=t,i.g())}get height(){return this.Ae.height}set height(t){const i=this.Ae;i.height!==t&&(i.ot(),i.height=t,i.g())}commit(){const t=this.Qt;if(t!==null){const e=this.bounds,s=t.bounds;Util.wt(s)?(s.x=e.x,s.y=e.y,s.width=e.width,s.height=e.height):t.bounds=e.copy();return}const i=this.node;if(i!==null){const e=this.bounds;if(!(i instanceof Group)){const s=Rect.l();i.ensureBounds();const n=this.network.layout.getLayoutBounds(i,s),o=i.locationObject.getDocumentPoint(Spot.Center);if(n.isReal()&&o.isReal()){i.moveTo(e.x+this.focusX-(o.x-n.x)+i.margin.left,e.y+this.focusY-(o.y-n.y+i.margin.top)),Rect.s(s);return}Rect.s(s)}i.moveTo(e.x+i.margin.left,e.y+i.margin.top)}}addSourceEdge(t){t!==null&&(this._o.has(t)||this._o.add(t))}deleteSourceEdge(t){t!==null&&this._o.delete(t)}addDestinationEdge(t){t!==null&&(this.tr.has(t)||this.tr.add(t))}deleteDestinationEdge(t){t!==null&&this.tr.delete(t)}get network(){return this.go}set network(t){this.go=t}get sourceVertexes(){const t=new GSet,i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}return t.iterator}get destinationVertexes(){const t=new GSet,i=this.destinationEdges;for(;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get vertexes(){const t=new GSet;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e.fromVertex)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e.toVertex)}return t.iterator}get sourceEdges(){return this._o.iterator}get destinationEdges(){return this.tr.iterator}get edges(){const t=new List;let i=this.sourceEdges;for(;i.next();){const e=i.value;t.add(e)}for(i=this.destinationEdges;i.next();){const e=i.value;t.add(e)}return t.iterator}get edgesCount(){return this._o.count+this.tr.count}static standardComparer(t,i){const e=t.de,s=i.de;if(e)if(s){const n=e.text,o=s.text;return no?1:0}else return 1;else return s!==null?-1:0}static smartComparer(t,i){if(t!==null)if(i!==null){const e=t.de,s=i.de;if(e!==null)if(s!==null){const n=e.text.toLocaleLowerCase(),o=s.text.toLocaleLowerCase(),r=n.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),l=o.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let h=0;for(;h0&&(i+=this.He!==null?"("+this.He.toString()+")":"",t>1&&(i+=" "+(this.We?this.We.toString():"null")+" --> "+(this.Je?this.Je.toString():"null"))),i}reverseEdge(){const t=this.We;this.We=this.Je,this.Je=t}commit(){}getOtherVertex(t){return this.Je===t?this.We:this.We===t?this.Je:null}get network(){return this.go}set network(t){this.go=t}get data(){return this.Qt}set data(t){this.Qt!==t&&(this.Qt=t)}get link(){return this.He}set link(t){this.He!==t&&(this.He=t)}get fromVertex(){return this.We}set fromVertex(t){this.We!==t&&(this.We=t)}get toVertex(){return this.Je}set toVertex(t){this.Je!==t&&(this.Je=t)}}var GridAlignment=(w=>(w[w.Position=0]="Position",w[w.Location=1]="Location",w))(GridAlignment||{}),GridArrangement=(w=>(w[w.LeftToRight=10]="LeftToRight",w[w.RightToLeft=11]="RightToLeft",w))(GridArrangement||{}),GridSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w))(GridSorting||{});class GridLayout extends Layout{Wd;Jd;Lo;Ln;oi;zi;pe;ye;constructor(t){super(),this.isViewportSized=!0,this.Wd=NaN,this.Jd=NaN,this.Lo=new Size(NaN,NaN).g(),this.Ln=new Size(10,10).g(),this.oi=1,this.zi=10,this.pe=22,this.ye=GridLayout.standardComparer,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Wd=this.Wd,t.Jd=this.Jd,t.Lo.a(this.Lo),t.Ln.a(this.Ln),t.oi=this.oi,t.zi=this.zi,t.pe=this.pe,t.ye=this.ye}ri(t){t in GridSorting?this.sorting=t:t in GridArrangement?this.arrangement=t:t in GridAlignment?this.alignment=t:super.ri(t)}doLayout(t){this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.collectParts(t),e=this.diagram,n=i.copy().iterator;for(;n.next();){const m=n.value;if(m.Cl()&&(m.fromNode!==null||m.toNode!==null)){i.delete(m);continue}if(m.ensureBounds(),m instanceof Group){const g=m.memberParts;for(;g.next();){const p=g.value;i.delete(p)}}}const o=i.toArray();if(o.length===0)return;switch(this.sorting){case 20:break;case 21:o.reverse();break;case 22:o.sort(this.comparer);break;case 23:o.sort(this.comparer),o.reverse();break}let r=this.wrappingColumn;isNaN(r)&&(r=0);let l=this.wrappingWidth;if(isNaN(l)&&e!==null){const m=e.viewportBounds,g=e.padding;l=Math.max(m.width-g.left-g.right,0)}else l=Math.max(this.wrappingWidth,0);r<=0&&l<=0&&(r=1);let h=this.spacing.width;isFinite(h)||(h=0);let a=this.spacing.height;isFinite(a)||(a=0),e!==null&&e.startTransaction("Layout");const c=[];switch(this.alignment){case 0:this.bO(o,l,r,h,a,c);break;case 1:this.kO(o,l,r,h,a,c);break}let f=0,u=0,d=0;for(let m=0;m0&&m>e-1||i>0&&m>0&&L-c>i)&&(o.push(new Rect(0,d,i+s,g)),m=0,u=c,d+=g,g=0),g=Math.max(g,S);let C=0;switch(a){case 11:C=-x.width;break;default:C=0;break}switch(y.moveTo(u+C+y.margin.left,d+y.margin.top),a){case 11:u-=P;break;default:u+=P;break}m++}o.push(new Rect(0,d,i+s,g)),Rect.s(r)}kO(t,i,e,s,n,o){const r=Rect.l();let l=Math.max(this.cellSize.width,1),h=0,a=0,c=0;const f=Point.l();for(let C=0;C=h&&(i-=h);let x=0,k=0;const b=Math.max(this.cellSize.height,1);c=0;let P=0,S=!0;const L=Point.l();for(let C=0;C0)switch(u){case 11:{let D=(g-d-(N.width-T.x))/l;Geo.K(Math.round(D),D)?D=Math.round(D):D=Math.floor(D),g=D*l+d;break}default:{let D=(g-d+T.x)/l;Geo.K(Math.round(D),D)?D=Math.round(D):D=Math.ceil(D),g=D*l+d;break}}else switch(u){case 11:x=g+T.x+N.width;break;default:x=g-T.x;break}let A=0;switch(u){case 11:A=-(g+T.x)+x;break;default:A=g+N.width-T.x-x;break}if(e>0&&y>e-1||i>0&&y>0&&A>i){o.push(new Rect(0,S?p-c:p,i+s,P+c+n));for(let D=0;Dk&&(M.width+=M.x-k,M.x=k)}Rect.s(r)}commitLayers(t,i){}get wrappingWidth(){return this.Wd}set wrappingWidth(t){this.Wd!==t&&(Util.i(t,"number",GridLayout,"wrappingWidth"),(t>0||isNaN(t))&&(this.Wd=t,this.isViewportSized=isNaN(t),this.invalidateLayout()))}get wrappingColumn(){return this.Jd}set wrappingColumn(t){this.Jd!==t&&(Util.i(t,"number",GridLayout,"wrappingColumn"),(t>0||isNaN(t))&&(this.Jd=t,this.invalidateLayout()))}get cellSize(){return this.Lo}set cellSize(t){this.Lo.equals(t)||(this.Lo.a(t),this.invalidateLayout())}get spacing(){return this.Ln}set spacing(t){this.Ln.equals(t)||(this.Ln.a(t),this.invalidateLayout())}get alignment(){return this.oi}set alignment(t){this.oi!==t&&(t===1||t===0)&&(this.oi=t,this.invalidateLayout())}get arrangement(){return this.zi}set arrangement(t){this.zi!==t&&(t===10||t===11)&&(this.zi=t,this.invalidateLayout())}get sorting(){return this.pe}set sorting(t){this.pe!==t&&(t===20||t===21||t===22||t===23)&&(this.pe=t,this.invalidateLayout())}get comparer(){return this.ye}set comparer(t){this.ye!==t&&(Util.i(t,"function",GridLayout,"comparer"),this.ye=t,this.invalidateLayout())}static standardComparer(t,i){const e=t.text,s=i.text;return es?1:0}static smartComparer(t,i){if(t!==null)if(i!==null){const e=t.text.toLocaleLowerCase(),s=i.text.toLocaleLowerCase(),n=e.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),o=s.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/);let r=0;for(;r{e.containsNodeData(s)&&this.gT(s,!1)}),t.forEach(s=>{e.containsNodeData(s)&&this.M1(s)}),i!==!1&&this.diagram.bb(!1)}gT(t,i){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.yo.has(t))return null;i===void 0&&(i=!0);const e=this.PO(t);return e!==null&&i&&this.M1(t),e}PO(t){if(t==null||this.p.undoManager.isUndoingRedoing||this.yo.has(t))return null;const i=this.SO(t),e=this.findTemplateForNodeData(t,i);if(e!==null){e.li();const s=e.copy();if(s!==null){const n=this.diagram.fe;return this.diagram.fe=!0,s.Ho=i,s.Qt=t,this.Sy&&(s.ll="Tool"),this.diagram.add(s),s.Qt=null,s.data=t,this.diagram.fe=n,s}}return null}insertLink(t,i,e,s){return null}M1(t){}SO(t){return this.p.model.getCategoryForNodeData(t)}static mT=!1;static pT=!1;findTemplateForNodeData(t,i){const e=this.p,s=e.model,n=s.qc()&&s.isGroupForData(t);let o=null;return n?(o=e.groupTemplateMap.get(i),o===null&&(o=e.groupTemplateMap.get(""),o===null&&(PartManager.pT||(PartManager.pT=!0,Util.ii('No Group template found for category "'+i+'"'),Util.ii(" Using default group template")),o=e.rM))):(o=e.nodeTemplateMap.get(i),o===null&&(o=e.nodeTemplateMap.get(""),o===null&&(PartManager.mT||(PartManager.mT=!0,Util.ii('No Node template found for category "'+i+'"'),Util.ii(" Using default node template")),o=e.sM))),o}getLinkCategoryForData(t){return""}setLinkCategoryForData(t,i){}setFromNodeForLink(t,i,e){}setToNodeForLink(t,i,e){}static yT=!1;findLinkTemplateForCategory(t){const i=this.p;let e=i.linkTemplateMap.get(t);return e===null&&(e=i.linkTemplateMap.get(""),e===null&&(PartManager.yT||(PartManager.yT=!0,Util.ii('No Link template found for category "'+t+'"'),Util.ii(" Using default link template")),e=i.nM)),e}fv(t,i,e){t instanceof Link?(i!==null&&this.uT(i,t),e!==null&&this.fT(e,t)):t instanceof Part&&(i!==null&&this.yo.delete(i),e!==null&&this.yo.set(e,t))}dT(){const t=this.diagram.model;this.dN(t.nodeDataArray)}dN(t){t.forEach(i=>{this.N1(i)})}N1(t){const i=this.findPartForData(t);i!==null&&(this.diagram.NM(i,!1),this.gN(i))}gN(t){}nN(t){}findPartForKey(t){if(t==null)return null;const i=this.p.model.findNodeDataForKey(t);return i!==null?this.yo.get(i):null}findNodeForKey(t){if(t==null)return null;const i=this.p.model.findNodeDataForKey(t);if(i===null)return null;const e=this.yo.get(i);return e instanceof Node?e:null}findLinkForKey(t){return null}findPartForData(t){if(t===null)return null;let i=this.yo.get(t);return i!==null||(i=this.dl.get(t)),i}findNodeForData(t){if(t===null)return null;const i=this.yo.get(t);return i instanceof Node?i:null}findLinkForData(t,i){return t===null?null:this.dl.get(t)}findNodesByExample(...t){const i=new GSet,e=this.$d.iterator;for(;e.next();){const s=e.value,n=s.data;if(n!==null)for(let o=0;o{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),this.parts.each(o=>{o.data!==null&&!i.has(o.data)&&s.push(o.data)}),s.forEach(o=>t.xT(o,!1));for(let o=0;o0){for(let o=0;oi.SL(s));const e=t.mh;if(Array.isArray(e)){const s=this.Ua.get(e);if(s===null){const n=[];n.push(t),this.Ua.set(e,n)}else{for(let n=0;ni.gR(s));const e=t.mh;if(Array.isArray(e)){const s=this.Ua.get(e);if(s!==null){for(let n=0;n0&&i.removeParts(l,!1),h.count>0){const c=h.iterator;for(;c.next();){const f=c.key,u=c.value;s.set(f,u)}}}if(i!==null&&this.p!==null){const o=i.model,r=o.afterCopyFunction;if(r!==null){const l=new GMap;s.each(a=>{a.key.data!==null&&l.set(a.key.data,a.value.data)});const h=this.p.model;r(l,o,h)}}const n=s.iterator;for(;n.next();)n.value.updateTargetBindings();return s}C1(t,i,e,s){if(t===null||s&&!t.canCopy())return null;if(e.has(t))return e.get(t);const n=this.pN(t,i);if(!(n instanceof Part))return null;if(n.isSelected=!1,n.isHighlighted=!1,e.set(t,n),t instanceof Node){const o=t.linksConnected;for(;o.next();){const r=o.value;if(r.fromNode===t){const l=e.get(r);l!==null&&(l.fromNode=n)}if(r.toNode===t){const l=e.get(r);l!==null&&(l.toNode=n)}}if(t instanceof Group&&n instanceof Group){const r=t.memberParts;for(;r.next();){const l=r.value,h=this.C1(l,i,e,s);h instanceof Link||h!==null&&(h.containingGroup=n)}}}else if(t instanceof Link&&n instanceof Link){const o=t.fromNode;if(o!==null){const h=e.get(o);h!==null&&(n.fromNode=h)}const r=t.toNode;if(r!==null){const h=e.get(r);h!==null&&(n.toNode=h)}const l=t.labelNodes;for(;l.next();){const h=l.value,a=this.C1(h,i,e,s);a!==null&&a instanceof Node&&(a.labeledLink=n)}}return n}pN(t,i){let e=null;const s=t.data;if(s!==null&&i!==null){const n=i.model;if(!(t instanceof Link)){const o=n.copyNodeData(s);Util.wt(o)&&(n.addNodeData(o),e=i.findPartForData(o))}}else if(t.li(),e=t.copy(),e!==null){const n=this.p;if(i!==null)i.add(e);else if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const o=n.model;let r=null;e instanceof Link||(r=o.copyNodeData(s)),Util.wt(r)&&(e.data=r)}}return e}get nodes(){return this.$d}get links(){return this.qs}get parts(){return this.At}get diagram(){return this.p}get addsToTemporaryLayer(){return this.Sy}set addsToTemporaryLayer(t){this.Sy=t}get preservesRebuildLocations(){return this.uN}set preservesRebuildLocations(t){this.uN=t}}class GraphLinksPartManager extends PartManager{LM(){const t=this.diagram.model;this.My(t.nodeDataArray),this.PT(t.linkDataArray)}My(t){super.My(t,!1);const i=this.links.iterator;for(;i.next();)i.value.Ld();this.diagram.bb(!1)}PT(t){t.forEach(i=>{this.ST(i)}),this.diagram.bb(!1)}ST(t){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.dl.has(t))return null;const i=this.getLinkCategoryForData(t),e=this.findLinkTemplateForCategory(i);if(e!==null){e.li();const s=e.copy();if(s!==null){const n=this.diagram.fe;this.diagram.fe=!0,s.Ho=i,s.Qt=t;const o=this.diagram.model,r=o.L1(t,!0);r!==""&&(s.fromPortId=r);const l=o.Te(t,!0);if(l!==void 0){const f=this.findNodeForKey(l);f instanceof Node&&(s.fromNode=f)}const h=o.L1(t,!1);h!==""&&(s.toPortId=h);const a=o.Te(t,!1);if(a!==void 0){const f=this.findNodeForKey(a);f instanceof Node&&(s.toNode=f)}const c=o.getLabelKeysForLinkData(t);return Array.isArray(c)&&c.forEach(f=>{const u=this.findNodeForKey(f);u!==null&&(u.labeledLink=s)}),this.Sy&&(s.ll="Tool"),this.diagram.add(s),s.Qt=null,s.data=t,this.diagram.fe=n,s}}return null}dT(){const t=this.diagram.model;this.MT(t.linkDataArray),this.dN(t.nodeDataArray)}MT(t){t.forEach(i=>{this.N1(i)})}getLinkCategoryForData(t){return this.diagram.model.getCategoryForLinkData(t)}setLinkCategoryForData(t,i){return this.diagram.model.setCategoryForLinkData(t,i)}setFromNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setFromKeyForLinkData(t.data,e.getKeyForNodeData(s))}setToNodeForLink(t,i){const e=this.diagram.model,s=i!==null?i.data:null;e.setToKeyForLinkData(t.data,e.getKeyForNodeData(s))}nN(t){this.diagram.model.removeLinkData(t.data)}findPartForKey(t){const i=super.findPartForKey(t);if(i===null){const s=this.diagram.model.findLinkDataForKey(t);if(s!==null)return this.dl.get(s)}return i}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findLinkDataForKey(t);return e!==null?this.dl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.Y){i.Y=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="linkFromKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.fromNode=l}}else if(s==="linkToKey"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue,l=this.findNodeForKey(r);o.toNode=l}}else if(s==="linkFromPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.fromPortId=r)}}else if(s==="linkToPortId"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.newValue;typeof r=="string"&&(o.toPortId=r)}}else if(s==="nodeGroupKey"){const n=t.object,o=this.findPartForData(n);if(o!==null){const r=t.newValue;if(r!==void 0){const l=this.findNodeForKey(r);l instanceof Group?o.containingGroup=l:o.containingGroup=null}else o.containingGroup=null}}else if(s==="linkLabelKeys"){const n=t.object,o=this.findLinkForData(n);if(o!==null){const r=t.oldValue,l=t.newValue;Array.isArray(r)&&r.forEach(h=>{if(l.indexOf(h)>=0)return;const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=null)}),Array.isArray(l)&&l.forEach(h=>{const a=this.findNodeForKey(h);a!==null&&(a.labeledLink=o)})}}else if(s==="linkCategory"){const n=t.object,o=this.findLinkForData(n),r=t.newValue;o!==null&&typeof r=="string"&&(o.category=r)}else if(s==="linkDataArray"){const n=t.oldValue;this.MT(n);const o=t.newValue;this.PT(o)}i.isModified=!0}else if(e===3){const n=t.newValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.ST(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=t.object,r=this.findLinkForData(o),l=this.findNodeForKey(n);r!==null&&l!==null&&(l.labeledLink=r)}i.isModified=!0}else if(e===4){const n=t.oldValue;if(s==="linkDataArray"&&typeof n=="object"&&n!==null)this.N1(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){const o=this.findNodeForKey(n);o!==null&&(o.labeledLink=null)}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&(n==="linkFromKeyProperty"||n==="linkToKeyProperty"||n==="linkFromPortIdProperty"||n==="linkToPortIdProperty"||n==="linkLabelKeysProperty"||n==="nodeIsGroupProperty"||n==="nodeGroupKeyProperty"||n==="linkCategoryProperty")&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.Y=!0}}}kT(){const t=this.diagram.model,i=new GSet,e=t.linkDataArray;e.forEach(n=>{i.add(n)});const s=[];this.links.each(n=>{n.data!==null&&!i.has(n.data)&&s.push(n.data)}),s.forEach(n=>{t.NT(n,!1)}),e.forEach(n=>{this.findLinkForData(n)===null&&t.CT(n,!1)})}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Link){let n=s.Te(i,!0),o=e.findNodeForKey(n);t.fromNode=o,n=s.Te(i,!1),o=e.findNodeForKey(n),t.toNode=o;const r=s.getLabelKeysForLinkData(i);if(r.length>0||t.labelNodes.count>0){if(r.length===1&&t.labelNodes.count===1){const f=r[0],u=t.labelNodes.first();if(s.getKeyForNodeData(u.data)===f)return}const l=new GSet().addAll(r),h=new GSet;t.labelNodes.each(f=>{if(f.data!==null){const u=s.getKeyForNodeData(f.data);u!==void 0&&h.add(u)}});const a=h.copy();a.removeAll(l);const c=l.copy();if(c.removeAll(h),a.count>0||c.count>0){const f=t;a.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink===f&&(d.labeledLink=null)}),c.each(u=>{const d=e.findNodeForKey(u);d!==null&&d.labeledLink!==f&&(d.labeledLink=f)})}}}else if(!(t instanceof Adornment)){const n=s.getGroupKeyForNodeData(i),o=e.findPartForKey(n);(o===null||o instanceof Group)&&(t.containingGroup=o)}}M1(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Cy(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)){if(n instanceof Group&&i.getGroupKeyForNodeData(l)===e){const h=this.findPartForData(l);h!==null&&(h.containingGroup=n)}}else{const h=this.findLinkForData(l);if(h!==null&&n instanceof Node){i.Te(l,!0)===e&&(h.fromNode=n),i.Te(l,!1)===e&&(h.toNode=n);const a=i.getLabelKeysForLinkData(l);Array.isArray(a)&&a.some(c=>c===e?(n.labeledLink=h,!0):!1)}}}i.Js(e)}const o=i.getGroupKeyForNodeData(t);if(o!==void 0){const r=this.findNodeForKey(o);r instanceof Group&&(n.containingGroup=r)}}}gN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data);if(e!==void 0){const s=t.linksConnected;for(;s.next();){const n=s.value;i.$s(e,n.data)}if(t.isLinkLabel){const n=t.labeledLink;n!==null&&i.$s(e,n.data)}if(t instanceof Group){const n=t.memberParts;for(;n.next();){const r=n.value.data;i.containsNodeData(r)&&i.$s(e,r)}}}}}pN(t,i){let e=super.pN(t,i);if(t instanceof Link){const s=t.data;if(s!==null&&i!==null){const n=i.model,o=n.copyLinkData(s);typeof o=="object"&&o!==null&&(n.addLinkData(o),e=i.findLinkForData(o))}else if(e!==null){const n=this.diagram;if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){const r=n.model.copyLinkData(s);typeof r=="object"&&r!==null&&(e.data=r)}}}return e}insertLink(t,i,e,s){const n=this.diagram,o=n.model,r=n.toolManager.findTool("Linking");let l="";t!==null&&(i===null&&(i=t),l=i.portId,l===null&&(l=""));let h="";e!==null&&(s===null&&(s=e),h=s.portId,h===null&&(h=""));const a=r.archetypeLinkData;if(a instanceof Link){a.li();const c=a.copy();if(c!==null){c.fromNode=t,c.fromPortId=l,c.toNode=e,c.toPortId=h,n.add(c);const f=r.archetypeLabelNodeData;if(f instanceof Node){f.li();const u=f.copy();u!==null&&(u.labeledLink=c,n.add(u))}return c}}else if(a!==null){const c=o.copyLinkData(a);if(typeof c=="object"&&c!==null){t!==null&&o.Zd(c,o.getKeyForNodeData(t.data),!0),o.Qd(c,l,!0),e!==null&&o.Zd(c,o.getKeyForNodeData(e.data),!1),o.Qd(c,h,!1),o.addLinkData(c);const f=r.archetypeLabelNodeData;if(f!==null&&!(f instanceof Node)){const d=o.copyNodeData(f);if(typeof d=="object"&&d!==null){o.addNodeData(d);const m=o.getKeyForNodeData(d);m!==void 0&&o.addLabelKeyForLinkData(c,m)}}return n.findLinkForData(c)}}return null}}class TreePartManager extends PartManager{Ph=null;A1(t,i){if(t===null||i===null||i.findTreeParentLink()!==null)return null;const e=this.diagram.toolManager.findTool("Linking");let s=t,n=i;if(this.diagram.isTreePathToChildren){if(e!==null&&e.xu(s,n,null,!0))return null}else if(s=i,n=t,e!==null&&e.xu(s,n,null,!0))return null;const o=this.getLinkCategoryForData(i.data),r=this.findLinkTemplateForCategory(o);if(r!==null){r.li();const l=r.copy();if(l!==null){const h=this.diagram.fe;return this.diagram.fe=!0,l.Ho=o,l.Qt=i.data,l.fromNode=s,l.toNode=n,this.diagram.add(l),l.Qt=null,l.data=i.data,this.diagram.fe=h,l}}return null}getLinkCategoryForData(t){return this.diagram.model.getParentLinkCategoryForNodeData(t)}setLinkCategoryForData(t,i){this.diagram.model.setParentLinkCategoryForNodeData(t,i)}setFromNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren)s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n));else{const o=this.Ph;this.Ph=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.toNode!==null?t.toNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Ph=o}}setToNodeForLink(t,i,e){const s=this.diagram.model;e===void 0&&(e=null);const n=i!==null?i.data:null;if(this.diagram.isTreePathToChildren){const o=this.Ph;this.Ph=t,e!==null&&s.setParentKeyForNodeData(e.data,void 0);const r=t.fromNode!==null?t.fromNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Ph=o}else s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n))}nN(t){this.diagram.model.setParentKeyForNodeData(t.data,void 0)}findLinkForKey(t){if(t==null)return null;const e=this.diagram.model.findNodeDataForKey(t);return e!==null?this.dl.get(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;const i=this.diagram;if(t.model!==i.model)return;const e=t.change;if(i.Y){i.Y=!1;try{const s=t.modelChange;if(s!==""){if(e===2){if(s==="nodeParentKey"){const n=t.object,o=t.newValue,r=this.findNodeForKey(o),l=this.findNodeForData(n);if(this.Ph!==null)r!==null&&(this.Ph.data=n,this.Ph.category=this.getLinkCategoryForData(n));else if(l!==null){const h=l.findTreeParentLink();h!==null?r===null?i.remove(h):i.isTreePathToChildren?h.fromNode=r:h.toNode=r:this.A1(r,l)}}else if(s==="parentLinkCategory"){const n=t.object,o=this.findNodeForData(n),r=t.newValue;if(o!==null&&typeof r=="string"){const l=o.findTreeParentLink();l!==null&&(l.category=r)}}i.isModified=!0}}else if(e===2){const n=t.propertyName,o=t.object,r=i.model;o===r&&n==="nodeParentKeyProperty"&&(i.undoManager.isUndoingRedoing||this.rebuildParts()),i.isModified=!0}}finally{i.Y=!0}}}updateRelationshipsFromData(t){const i=t.data;if(i===null)return;const e=t.diagram;if(e===null)return;const s=e.model;if(t instanceof Node){const n=s.getParentKeyForNodeData(i),o=e.findNodeForKey(n),r=t.findTreeParentNode();if(o!==r){const l=t.findTreeParentLink();o!==null?l!==null?e.isTreePathToChildren?l.fromNode=o:l.toNode=o:this.A1(o,t):l!==null&&e.NM(l,!1)}}}Ny(t,i){if(super.Ny(t,i),typeof i=="string"&&this.findPartForData(t)!==null){const s=this.findLinkForData(t);s!==null&&s.updateTargetBindings(i)}}M1(t){const i=this.diagram.model,e=i.getKeyForNodeData(t);if(e!==void 0){const s=i.Cy(e),n=this.findPartForData(t);if(s!==null&&n!==null){const r=s.iterator;for(;r.next();){const l=r.value;if(i.containsNodeData(l)&&n instanceof Node&&i.getParentKeyForNodeData(l)===e){const h=this.findNodeForData(l);this.A1(n,h)}}i.Js(e)}const o=i.getParentKeyForNodeData(t);if(o!==void 0&&n instanceof Node){const r=this.findNodeForKey(o);this.A1(r,n)}}}gN(t){const i=this.diagram.model;if(t instanceof Node){const e=i.getKeyForNodeData(t.data),s=this.findLinkForData(t.data);if(s!==null){s.isSelected=!1,s.isHighlighted=!1;const r=s.layer;if(r!==null){const l=r.te(-1,s,!1);l>=0&&this.diagram.raiseChangedEvent(4,"parts",r,s,null,l,null);const h=s.layerChanged;h!==null&&h(s,r,null)}}const n=this.diagram.isTreePathToChildren,o=t.linksConnected;for(;o.next();){const r=o.value,h=(n?r.toNode:r.fromNode).data;i.containsNodeData(h)&&i.$s(e,h)}}}insertLink(t,i,e,s){const n=this.diagram.model;let o=t,r=e;if(this.diagram.isTreePathToChildren||(o=e,r=t),o!==null&&r!==null){const l=o.data,h=r.data;return n.setParentKeyForNodeData(h,n.getKeyForNodeData(l)),r.findTreeParentLink()}return null}}var BindingMode=(w=>(w[w.OneWay=1]="OneWay",w[w.TwoWay=2]="TwoWay",w))(BindingMode||{});class Binding{n;yN;Va;Cf;Sh;Lf;Af;Tf;T1;ke;gd;ff;constructor(t,i,e,s){GSet.Yi(this),t===void 0?t="":Util.i(t,"string",Binding,"constructor:targetprop"),i===void 0?i=t:Util.i(i,"string",Binding,"constructor:sourceprop"),e===void 0?e=null:e!==null&&Util.i(e,"function",Binding,"constructor:conv"),this.yN=-1,this.ke=null,this.Va=t,this.gd=0,this.ff=0,this.Cf=null,this.Sh=i,this.Lf=e,s===void 0?(this.Af=1,this.Tf=null):(this.Af=2,this.Tf=s),this.T1=new GSet,this.n=2}copy(){const t=new this.constructor;return this.cloneProtected(t),t}cloneProtected(t){t.Va=this.Va,t.gd=this.gd,t.ff=this.ff,t.Cf=this.Cf,t.Sh=this.Sh,t.Lf=this.Lf,t.Af=this.Af,t.Tf=this.Tf,t.n=this.n&-2}static OneWay=1;static TwoWay=2;static parseEnum(t,i){return Util.i(t,"function",Binding,"parseEnum:ctor"),e=>{let s=parseInt(e);return isNaN(s)&&(s=Util.Ih(t,e),s===null)?i:s}}ri(t){t in BindingMode?this.mode=t:Util.lr(this,t)}static toString(t){return Util.toString(t)}toString(){return"Binding("+this.targetProperty+":"+this.sourceProperty+(this.targetId!==-1?" "+this.targetId:"")+" "+BindingMode[this.mode]+")"}g(){return this.n=this.n|1,this}ot(){return this.n=this.n&-2,this}get targetId(){return this.yN}set targetId(t){this.h&&Util.T(this),Util.i(t,"number",Binding,"targetId"),this.yN=t}get targetProperty(){return this.Va}set targetProperty(t){this.h&&Util.T(this),Util.i(t,"string",Binding,"targetProperty"),this.Va=t}get sourceProperty(){return this.Sh}set sourceProperty(t){this.h&&Util.T(this),Util.i(t,"string",Binding,"sourceProperty"),this.Sh=t}get h(){return(this.n&1)!==0}get isToData(){return(this.n&2)!==0}get isToObject(){return(this.n&4)!==0}get isToModel(){return(this.n&8)!==0}get isToTheme(){return(this.n&16)!==0}get wN(){return this.isToTheme&&!(this.isToData||this.isToObject||this.isToModel)}Zu(){return!1}get sourceName(){return this.Cf}set sourceName(t){this.h&&Util.T(this),t!==null&&Util.i(t,"string",Binding,"sourceName"),this.Cf=t,t!==null?this.n=this.n&-3|4:this.n=this.n|2}get converter(){return this.Lf}set converter(t){this.h&&Util.T(this),t!==null&&Util.i(t,"function",Binding,"converter"),this.Lf=t}get backConverter(){return this.Tf}set backConverter(t){this.h&&Util.T(this),t!==null&&Util.i(t,"function",Binding,"backConverter"),this.Tf=t}get mode(){return this.Af}set mode(t){this.h&&Util.T(this),this.isToTheme&&t===2&&Util.o("Theme Bindings cannot be TwoWay."),this.Af=t}makeTwoWay(t){return this.isToTheme&&Util.o("Theme Bindings cannot be TwoWay."),this.mode=2,t&&(Util.i(t,"function",Binding,"makeTwoWay"),this.backConverter=t),this}ofObject(t){return this.h&&Util.T(this),t===void 0&&(t=""),this.sourceName=t,this}ofModel(){return this.h&&Util.T(this),this.n=this.n&-3&-5|8,this.Cf=null,this}ZL(t,i){const e=this.sourceName;let s=null;return e===null||e===""?s=t:e==="/"?s=i.part:e==="."?s=i:e===".."?s=i.panel:s=t.findObject(e),s}check(t){const i=this.Va,e=this.Sh,s=this.Lf;(this.Zu()&&s===null&&this.Mh===null&&i===""||s===null&&i==="")&&Util.ii("Binding error: target property is the empty string: "+this.toString()),this.Zu()&&this.wN&&e===""&&s===null&&this.Mh===null&&Util.ii("Binding error: theme bindings require a source property when not using a converter: "+this.toString()),t&&typeof i=="string"&&(typeof t.setAttribute!="function"&&i.length>0&&i[0]!=="_"&&!Util.fw(t,i)?Util.ii("Binding error: undefined target property: "+i+" on "+t.toString()):i==="name"&&t instanceof GraphObject&&Util.ii("Binding error: cannot modify GraphObject.name on "+t.toString()))}updateTarget(t,i,e){const s=this.Sh;if(e!==void 0&&s!==""&&s!==e)return;const n=this.Va,o=this.Lf;let r=i;if(s!==""&&!this.wN&&(r=Model.vt(i,s)),r===void 0)return;const l=t.diagram?.themeManager??t.panel?.diagram?.themeManager;if(o===null){if(n!==""){if(this.Zu()&&(r=this.LT(l,r,t,n),r===void 0))return;Model.rt(t,n,r)}}else try{if(n!==""){let h=o(r,t);if(this.Zu()&&(h=this.LT(l,h,t,n),h===void 0))return;Model.rt(t,n,h)}else o(r,t)}catch{}}updateSource(t,i,e,s){if(this.Af!==2)return;const n=this.Va;if(e!==void 0&&n!==e)return;const o=this.Sh,r=this.Tf;let l=t;if(n!==""&&(l=Model.vt(t,n)),l!==void 0&&!this.T1.has(t))try{this.T1.add(t);const h=s!==null?s.diagram:null,a=h!==null?h.model:null;if(r===null){if(o!=="")a!==null?a.setDataProperty(i,o,l):Model.rt(i,o,l);else if(a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const c=s.itemIndex,f=s.panel.itemArray;a.removeArrayItem(f,c),a.insertArrayItem(f,c,l)}}else try{if(o!==""){const c=r(l,i,a);a!==null?a.setDataProperty(i,o,c):Model.rt(i,o,c)}else{const c=r(l,i,a);if(c!==void 0&&a!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){const f=s.itemIndex,u=s.panel.itemArray;a.removeArrayItem(u,f),a.insertArrayItem(u,f,c)}}}catch{}}finally{this.T1.delete(t)}}}class ThemeBinding extends Binding{Ly;Mh;za;constructor(t,i,e,s,n){super(t,i,s),e==null&&(e=""),n===void 0&&(n=null),this.Ly=e,this.Mh=n,this.za=null,this.n=16}cloneProtected(t){super.cloneProtected(t),t.Ly=this.Ly,t.Mh=this.Mh,t.za=this.za}Zu(){return!0}get themeSource(){return this.Ly}set themeSource(t){this.h&&Util.T(this),t!==null&&Util.i(t,"string",ThemeBinding,"themeSource"),this.Ly=t,this.za=null,t!==null?this.n=this.n|16:this.n=this.n&-17}get themeConverter(){return this.Mh}set themeConverter(t){this.h&&Util.T(this),t!==null&&Util.i(t,"function",ThemeBinding,"themeConverter"),this.Mh=t}ofData(){return this.h&&Util.T(this),this.n=this.n|2,this.Cf=null,this}LT(t,i,e,s){if(!t||(this.wN&&(i=this.Sh),!i&&i!==0))return;let n=this.themeSource;this.za!==null?n=this.za:typeof n=="string"&&n.includes(".")&&(this.za=n.split("."),n=this.za);let o=t.findValue(i,n,s);return o===void 0&&Util.ii(`Theme warning: ${i} could not be found when setting target property ${s}.`),typeof this.Mh=="function"&&(o=this.Mh(o,e)),o}}class Model{Mt;_d;vo;D1;De;Df;Ff;tg;ig;eg;sg;Xa;er;F1;Ro;R1;ti;Nh;ng=new GSet;og=new GSet;Ay;constructor(t,i){if(GSet.Yi(this),this.Mt="",this._d="",this.vo=!1,this.D1={},this.De=[],this.ti=new GMap,this.Nh="key",this.Df=null,this.Ff=null,this.tg=!1,this.ig=!1,this.eg=!1,this.sg=null,this.Xa="category",this.er=new GMap,this.Ay=100,this.F1=new List,this.Ro=!1,this.R1=null,this.undoManager=new UndoManager,t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){t.Mt=this.Mt,t._d=this._d,t.vo=this.vo,t.Nh=this.Nh,t.Df=this.Df,t.Ff=this.Ff,t.tg=this.tg,t.ig=this.ig,t.eg=this.eg,t.Ay=this.Ay,t.sg=this.sg,t.Xa=this.Xa}copy(){const t=new this.constructor;return this.cloneProtected(t),t}clear(){this.De=[],this.ti.clear(),this.er.clear(),this.undoManager.clear()}toString(t){if(t===void 0&&(t=0),t>1)return this.toJson();{let i=(this.name!==""?this.name:"")+" Model";if(t>0){i+=` + node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n{if(u.model===e){if(u.modelChange==="nodeDataArray")u.change===3?n.add(u.newValue):u.change===4&&r.add(u.oldValue);else if(e.containsNodeData(u.object))o.add(u.object);else if(u.change===2&&(e.modelData===u.object||u.propertyName==="modelData"))s=!0;else if(u.object!==null)if(l&&l.has(u.object))l.get(u.object).each(m=>{e.containsNodeData(m)&&o.add(m)});else{if(u.object instanceof Model||e.Ta()&&e.containsLinkData(u.object))return;e.TT(u.object).each(m=>{o.add(m)})}}});const h=this.og;h.clear(),n.each(u=>{h.add(e.getKeyForNodeData(u)),i||o.add(u)});const a=this.ng;a.clear(),r.each(u=>{a.add(e.getKeyForNodeData(u)),i&&o.add(u)});const c=e.cloneDeep(o.toArray());let f=null;return s&&(f===null&&(f={}),f.modelData=this.cloneDeep(this.modelData)),h.count>0&&(f===null&&(f={}),i?f.removedNodeKeys=h.toArray():f.insertedNodeKeys=h.toArray()),c.length>0&&(f===null&&(f={}),f.modifiedNodeData=c),a.count>0&&(f===null&&(f={}),i?f.insertedNodeKeys=a.toArray():f.removedNodeKeys=a.toArray()),a.clear(),h.clear(),f}cloneDeep(t){return this.rg(t,!0)}rg(t,i,e,s,n){if(!Util.wt(t))return t;n||(n=[]);const o=Object.isExtensible(t);if(e||(e=new GMap),o){const h=e.get(t);if(h)return h}else{s||(s=new GMap);const h=s.iterator;for(;h.next();){const a=h.key;if(h.value===t){const f=e.get(a);if(f)return f}}}function r(h,a){if(o)h.__gohashid===void 0&&n.push(h),e.set(h,a);else{const c=GSet.su++;e.set(c,a),s.set(c,t)}}let l;if(Array.isArray(t)){l=[],r(t,l);for(let h=0;h{delete h.__gohashid}),l}Fe(t){return JSON.stringify(t).replace(/[\u007F-\uFFFF]/g,e=>{const s="0000"+e.charCodeAt(0).toString(16);return"\\u"+s.substring(s.length-4)})}lg(){let t="";return this.name!==""&&(t+=`, "name": `+this.Fe(this.name)),this.dataFormat!==""&&(t+=`, "dataFormat": `+this.Fe(this.dataFormat)),this.isReadOnly&&(t+=`, "isReadOnly": `+this.isReadOnly),this.nodeKeyProperty!=="key"&&typeof this.nodeKeyProperty=="string"&&(t+=`, @@ -29,16 +29,16 @@ string: ${t}`);break}}const T=b.qg;if(GeoStream.wC(b),i){const A=T.figures.itera "copiesKey": true`),this.pointsDigits!==100&&(t+=`, "pointsDigits": `+this.pointsDigits.toString()),this.nodeCategoryProperty!=="category"&&typeof this.nodeCategoryProperty=="string"&&(t+=`, "nodeCategoryProperty": `+this.Fe(this.nodeCategoryProperty)),t}Ty(t){t.name&&(this.name=t.name),t.dataFormat&&(this.dataFormat=t.dataFormat),t.isReadOnly&&(this.isReadOnly=!0),t.nodeKeyProperty&&(this.nodeKeyProperty=t.nodeKeyProperty),t.copiesArrays&&(this.copiesArrays=!0),t.copiesArrayObjects&&(this.copiesArrayObjects=!0),t.copiesKey!==void 0&&(this.copiesKey=t.copiesKey),t.pointsDigits!==void 0&&(this.pointsDigits=parseInt(t.pointsDigits)),t.nodeCategoryProperty&&(this.nodeCategoryProperty=t.nodeCategoryProperty)}DT(){const t=this.modelData;return`, - "modelData": `+this.FT(t)}RT(t){const i=t.modelData;Util.wt(i)&&(this.replaceJsonObjects(i),this.modelData=i)}PN(){const t=this.modelData;let i=!1;for(const s in t)if(!this.v1(t,s,t[s])){i=!0;break}let e="";return i&&(e=this.DT()),e+`, - "nodeDataArray": `+this.Nh(this.nodeDataArray,!0)}MN(t){this.RT(t);const i=t.nodeDataArray;Array.isArray(i)&&(this.replaceJsonObjects(i),this.nodeDataArray=i)}SN(t,i,e){if(t===i)return!0;if(typeof t!=typeof i||typeof t=="function"||typeof i=="function")return!1;if(Array.isArray(t)&&Array.isArray(i)){if(e.get(t)===i)return!0;if(e.set(t,i),t.length!==i.length)return!1;for(let s=0;s{const o=n.part;if(!o)return;const r=o.data;if(s===r)return;let l=i.get(s);l===null?(l=new GSet,l.add(r),i.set(s,l)):l.add(r)};i===null&&(i=new GMap,t.changes.each(s=>{if(s.diagram!==null){const n=s.change;if(n===2){const o=s.object.panel;if(o){const r=o.data;r&&e(r,o)}}else if(n===3||n===4){const o=s.object,r=o.itemArray;r&&e(r,o)}}}),this.Xa=i)}TT(t){const i=new GSet;for(let e=0;e{if(f.model===e){if(f.modelChange==="nodeDataArray")f.change===3?n.add(f.newValue):f.change===4&&r.add(f.oldValue);else if(e.containsNodeData(f.object))o.add(f.object);else if(f.change===2&&(e.modelData===f.object||f.propertyName==="modelData"))s=!0;else if(f.object!==null)if(l&&l.has(f.object))l.get(f.object).each(d=>{e.containsNodeData(d)&&o.add(d)});else{if(f.object instanceof Model||e.Aa()&&e.containsLinkData(f.object))return;e.TT(f.object).each(d=>{o.add(d)})}}});const h=this.rg;h.clear(),n.each(f=>{h.add(e.getKeyForNodeData(f)),i||o.add(f)});const a=this.og;a.clear(),r.each(f=>{a.add(e.getKeyForNodeData(f)),i&&o.add(f)});let c="";return s&&(c+=this.DT()),h.count>0&&(c+=(i?this.OT:this.vT)+this.Nh(h.toArray(),!0)),o.count>0&&(c+=this.LO+this.Nh(o.toArray(),!0)),a.count>0&&(c+=(i?this.vT:this.OT)+this.Nh(a.toArray(),!0)),a.clear(),h.clear(),c}Dy(t){(t.name!==void 0&&t.name!==this.name||t.dataFormat!==void 0&&t.dataFormat!==this.dataFormat||t.isReadOnly!==void 0&&t.isReadOnly!==this.isReadOnly||t.nodeKeyProperty!==void 0&&t.nodeKeyProperty!==this.nodeKeyProperty||t.copiesArrays!==void 0&&t.copiesArrays!==this.copiesArrays||t.copiesArrayObjects!==void 0&&t.copiesArrayObjects!==this.copiesArrayObjects||t.copiesKey!==void 0&&t.copiesKey!==this.copiesKey||t.nodeCategoryProperty!==void 0&&t.nodeCategoryProperty!==this.nodeCategoryProperty)&&Util.o("applyIncrementalJson cannot change Model properties"),this.RT(t);const i=t.insertedNodeKeys,e=t.modifiedNodeData,s=new GMap;if(Array.isArray(e))for(let o=0;o1&&s.add(` + "removedNodeKeys": `;Ka=null;AT(t){let i=this.Ka;const e=(s,n)=>{const o=n.part;if(!o)return;const r=o.data;if(s===r)return;let l=i.get(s);l===null?(l=new GSet,l.add(r),i.set(s,l)):l.add(r)};i===null&&(i=new GMap,t.changes.each(s=>{if(s.diagram!==null){const n=s.change;if(n===2){const o=s.object.panel;if(o){const r=o.data;r&&e(r,o)}}else if(n===3||n===4){const o=s.object,r=o.itemArray;r&&e(r,o)}}}),this.Ka=i)}TT(t){const i=new GSet;for(let e=0;e{if(f.model===e){if(f.modelChange==="nodeDataArray")f.change===3?n.add(f.newValue):f.change===4&&r.add(f.oldValue);else if(e.containsNodeData(f.object))o.add(f.object);else if(f.change===2&&(e.modelData===f.object||f.propertyName==="modelData"))s=!0;else if(f.object!==null)if(l&&l.has(f.object))l.get(f.object).each(d=>{e.containsNodeData(d)&&o.add(d)});else{if(f.object instanceof Model||e.Ta()&&e.containsLinkData(f.object))return;e.TT(f.object).each(d=>{o.add(d)})}}});const h=this.og;h.clear(),n.each(f=>{h.add(e.getKeyForNodeData(f)),i||o.add(f)});const a=this.ng;a.clear(),r.each(f=>{a.add(e.getKeyForNodeData(f)),i&&o.add(f)});let c="";return s&&(c+=this.DT()),h.count>0&&(c+=(i?this.OT:this.vT)+this.Ch(h.toArray(),!0)),o.count>0&&(c+=this.CO+this.Ch(o.toArray(),!0)),a.count>0&&(c+=(i?this.vT:this.OT)+this.Ch(a.toArray(),!0)),a.clear(),h.clear(),c}Dy(t){(t.name!==void 0&&t.name!==this.name||t.dataFormat!==void 0&&t.dataFormat!==this.dataFormat||t.isReadOnly!==void 0&&t.isReadOnly!==this.isReadOnly||t.nodeKeyProperty!==void 0&&t.nodeKeyProperty!==this.nodeKeyProperty||t.copiesArrays!==void 0&&t.copiesArrays!==this.copiesArrays||t.copiesArrayObjects!==void 0&&t.copiesArrayObjects!==this.copiesArrayObjects||t.copiesKey!==void 0&&t.copiesKey!==this.copiesKey||t.nodeCategoryProperty!==void 0&&t.nodeCategoryProperty!==this.nodeCategoryProperty)&&Util.o("applyIncrementalJson cannot change Model properties"),this.RT(t);const i=t.insertedNodeKeys,e=t.modifiedNodeData,s=new GMap;if(Array.isArray(e))for(let o=0;o1&&s.add(` `);for(let n=0;n0&&(s.add(","),i&&s.add(` `)),s.add(this.writeJsonValue(o)))}return i&&e>1&&s.add(` -`),s.add("]"),s.toString()}v1(t,i,e){return e===void 0||i==="__gohashid"||i[0]==="_"||typeof e=="function"}Xi(t){return isNaN(t)?"NaN":t===1/0?"9e9999":t===-1/0?"-9e9999":t}FT(t){const i=t;if(i instanceof Point)t={class:"go.Point",x:this.Xi(i.x),y:this.Xi(i.y)};else if(i instanceof Size)t={class:"go.Size",width:this.Xi(i.width),height:this.Xi(i.height)};else if(i instanceof Rect)t={class:"go.Rect",x:this.Xi(i.x),y:this.Xi(i.y),width:this.Xi(i.width),height:this.Xi(i.height)};else if(i instanceof Margin)t={class:"go.Margin",top:this.Xi(i.top),right:this.Xi(i.right),bottom:this.Xi(i.bottom),left:this.Xi(i.left)};else if(i instanceof Spot)i.isSpot()?t={class:"go.Spot",x:this.Xi(i.x),y:this.Xi(i.y),offsetX:this.Xi(i.offsetX),offsetY:this.Xi(i.offsetY)}:t={class:"go.Spot",enum:i.toString()};else if(i instanceof Brush){if(t={class:"go.Brush",type:BrushType[i.type]},i.type===1?t.color=i.color:(i.type===2||i.type===3)&&(t.start=i.start,t.end=i.end,i.type===3&&(i.startRadius!==0&&(t.startRadius=this.Xi(i.startRadius)),isNaN(i.endRadius)||(t.endRadius=this.Xi(i.endRadius)))),i.colorStops!==null){const n={},o=i.colorStops.iterator;for(;o.next();){const r=o.key,l=o.value;n[r]=l}t.colorStops=n}}else if(i instanceof Geometry)t={class:"go.Geometry",type:GeometryType[i.type]},i.startX!==0&&(t.startX=this.Xi(i.startX)),i.startY!==0&&(t.startY=this.Xi(i.startY)),i.endX!==0&&(t.endX=this.Xi(i.endX)),i.endY!==0&&(t.endY=this.Xi(i.endY)),i.spot1.equals(Spot.TopLeft)||(t.spot1=i.spot1),i.spot2.equals(Spot.BottomRight)||(t.spot2=i.spot2),i.type===4&&(t.path=Geometry.stringify(i));else if(Model.I1(Util.sn(i))!==null)return Util.oi("ERROR: trying to convert a GraphObject or Diagram or Model or Tool or Layout or UndoManager or other unknown data type into JSON text: "+i.toString()),"{}";let e="{",s=!0;for(const n in t){const o=Model.vt(t,n);if(!this.v1(t,n,o))if(s?s=!1:e+=",",e+=this.Fe(n)+":",n==="points"&&o instanceof List){const r=o;let l="[";const h=r.iterator;for(;h.next();){const a=h.value;l.length>1&&(l+=","),l+=this.IT(a.x),l+=",",l+=this.IT(a.y)}l+="]",e+=l}else e+=this.writeJsonValue(o)}return e+="}",e}IT(t){if(t===1/0)return"9e9999";if(t===-1/0)return"-9e9999";if(isNaN(t))return"0";const i=this.pointsDigits;return i>16?t.toString():t.toFixed(i)}get pointsDigits(){return this.Ay}set pointsDigits(t){t<0?t=0:t>100&&(t=100),this.Ay=t}Ki(t){return typeof t=="number"?t:t==="NaN"?NaN:t==="9e9999"?1/0:t==="-9e9999"?-1/0:parseFloat(t)}TO(t){if(typeof t!="object")return t;let i=t.class||"";if(typeof i!="string"||i==="")return t;if(i==="NaN")return NaN;if(i==="Date")return new Date(t.value);if(i.indexOf("go.")!==0)return t;i=i.substring(3);let e=t;if(i==="Point")e=new Point(this.Ki(t.x),this.Ki(t.y));else if(i==="Size")e=new Size(this.Ki(t.width),this.Ki(t.height));else if(i==="Rect")e=new Rect(this.Ki(t.x),this.Ki(t.y),this.Ki(t.width),this.Ki(t.height));else if(i==="Margin")e=new Margin(this.Ki(t.top),this.Ki(t.right),this.Ki(t.bottom),this.Ki(t.left));else if(i==="Spot")typeof t.enum=="string"?e=Spot.parse(t.enum):e=new Spot(this.Ki(t.x),this.Ki(t.y),this.Ki(t.offsetX),this.Ki(t.offsetY));else if(i==="Brush"){const s=new Brush;s.type=Util.Oh(BrushType,t.type)??1,typeof t.color=="string"&&(s.color=t.color),t.start instanceof Spot&&(s.start=t.start),t.end instanceof Spot&&(s.end=t.end),typeof t.startRadius=="number"&&(s.startRadius=this.Ki(t.startRadius)),typeof t.endRadius=="number"&&(s.endRadius=this.Ki(t.endRadius));const n=t.colorStops;if(Util.wt(n))for(const o in n){const r=parseFloat(o);s.addColorStop(r,n[o])}e=s}else if(i==="Geometry"){let s=null;typeof t.path=="string"?s=Geometry.parse(t.path):s=new Geometry,s.type=Util.Oh(GeometryType,t.type)??1,typeof t.startX=="number"&&(s.startX=this.Ki(t.startX)),typeof t.startY=="number"&&(s.startY=this.Ki(t.startY)),typeof t.endX=="number"&&(s.endX=this.Ki(t.endX)),typeof t.endY=="number"&&(s.endY=this.Ki(t.endY)),t.spot1 instanceof Spot&&(s.spot1=t.spot1),t.spot2 instanceof Spot&&(s.spot2=t.spot2),e=s}else if(i==="EnumValue"){let s=t.classType;s.indexOf("go.")===0&&(s=s.substring(3));const n=Model.I1(s);typeof n=="function"&&(e=Util.Oh(n,t.name))}return e}get name(){return this.St}set name(t){const i=this.St;i!==t&&(Util.i(t,"string",Model,"name"),this.St=t,this.t("name",i,t))}get dataFormat(){return this.tg}set dataFormat(t){const i=this.tg;i!==t&&(Util.i(t,"string",Model,"dataFormat"),this.tg=t,this.t("dataFormat",i,t))}get isReadOnly(){return this.vo}set isReadOnly(t){const i=this.vo;i!==t&&(Util.i(t,"boolean",Model,"isReadOnly"),this.vo=t,this.t("isReadOnly",i,t))}get modelData(){return this.D1}set modelData(t){const i=this.D1;i!==t&&(Util.i(t,"object",Model,"modelData"),this.D1=t,this.t("modelData",i,t),this.updateTargetBindings(t))}addChangedListener(t){return Util.i(t,"function",Model,"addChangedListener:listener"),this.F1.add(t),this}removeChangedListener(t){Util.i(t,"function",Model,"removeChangedListener:listener"),this.F1.delete(t)}Ew(t){this.skipsUndoManager||this.undoManager.handleChanged(t);const i=this.F1,e=i.length;for(let s=0;s0&&Util.o("Cannot set Model.nodeKeyProperty when there is existing node data"),this.Sh=t,this.t("nodeKeyProperty",i,t))}An(t,i,e){typeof t!="string"&&typeof t!="function"&&Util.we(t,"string or function",i,e)}getKeyForNodeData(t){if(t===null)return;const i=this.Sh;if(i==="")return;const e=Model.vt(t,i);if(e!==void 0){if(this.isKeyType(e))return e;Util.o("Key value for node data "+t+" is not a number or a string: "+e)}}setKeyForNodeData(t,i){if((i==null||!this.isKeyType(i))&&Util.we(i,"number or string",Model,"setKeyForNodeData:key"),t===null)return;const e=this.Sh;if(e==="")return;if(!this.containsNodeData(t)){Model.lt(t,e,i);return}const s=Model.vt(t,e);if(s!==i){if(this.findNodeDataForKey(i)!==null)return;Model.lt(t,e,i),s!==void 0&&this.ti.delete(s),this.ti.set(i,t),this.Et("nodeKey",2,e,t,s,i),typeof e=="string"&&this.updateTargetBindings(t,e),this.Fy(s,i)}}get makeUniqueKeyFunction(){return this.Tf}set makeUniqueKeyFunction(t){const i=this.Tf;i!==t&&(t!==null&&Util.i(t,"function",Model,"makeUniqueKeyFunction"),this.Tf=t,this.t("makeUniqueKeyFunction",i,t))}isKeyType(t){return typeof t=="number"||typeof t=="string"}containsNodeData(t){if(t===null)return!1;const i=this.getKeyForNodeData(t);return i===void 0?!1:this.ti.get(i)===t}findNodeDataForKey(t){return t===null&&Util.o("Model.findNodeDataForKey:key must not be null"),t===void 0||!this.isKeyType(t)?null:this.ti.get(t)}get nodeDataArray(){return this.De}set nodeDataArray(t){const i=this.De;if(i!==t){this.ti.clear(),this.CN();const e=t.length;for(let o=0;o=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" GraphLinksModel";if(t>0){i+=` +`),s.add("]"),s.toString()}v1(t,i,e){return e===void 0||i==="__gohashid"||i[0]==="_"||typeof e=="function"}Xi(t){return isNaN(t)?"NaN":t===1/0?"9e9999":t===-1/0?"-9e9999":t}FT(t){const i=t;if(i instanceof Point)t={class:"go.Point",x:this.Xi(i.x),y:this.Xi(i.y)};else if(i instanceof Size)t={class:"go.Size",width:this.Xi(i.width),height:this.Xi(i.height)};else if(i instanceof Rect)t={class:"go.Rect",x:this.Xi(i.x),y:this.Xi(i.y),width:this.Xi(i.width),height:this.Xi(i.height)};else if(i instanceof Margin)t={class:"go.Margin",top:this.Xi(i.top),right:this.Xi(i.right),bottom:this.Xi(i.bottom),left:this.Xi(i.left)};else if(i instanceof Spot)i.isSpot()?t={class:"go.Spot",x:this.Xi(i.x),y:this.Xi(i.y),offsetX:this.Xi(i.offsetX),offsetY:this.Xi(i.offsetY)}:t={class:"go.Spot",enum:i.toString()};else if(i instanceof Brush){if(t={class:"go.Brush",type:BrushType[i.type]},i.type===1?t.color=i.color:(i.type===2||i.type===3)&&(t.start=i.start,t.end=i.end,i.type===3&&(i.startRadius!==0&&(t.startRadius=this.Xi(i.startRadius)),isNaN(i.endRadius)||(t.endRadius=this.Xi(i.endRadius)))),i.colorStops!==null){const n={},o=i.colorStops.iterator;for(;o.next();){const r=o.key,l=o.value;n[r]=l}t.colorStops=n}}else if(i instanceof Geometry)t={class:"go.Geometry",type:GeometryType[i.type]},i.startX!==0&&(t.startX=this.Xi(i.startX)),i.startY!==0&&(t.startY=this.Xi(i.startY)),i.endX!==0&&(t.endX=this.Xi(i.endX)),i.endY!==0&&(t.endY=this.Xi(i.endY)),i.spot1.equals(Spot.TopLeft)||(t.spot1=i.spot1),i.spot2.equals(Spot.BottomRight)||(t.spot2=i.spot2),i.type===4&&(t.path=Geometry.stringify(i));else if(Model.I1(Util.sn(i))!==null)return Util.ii("ERROR: trying to convert a GraphObject or Diagram or Model or Tool or Layout or UndoManager or other unknown data type into JSON text: "+i.toString()),"{}";let e="{",s=!0;for(const n in t){const o=Model.vt(t,n);if(!this.v1(t,n,o))if(s?s=!1:e+=",",e+=this.Fe(n)+":",n==="points"&&o instanceof List){const r=o;let l="[";const h=r.iterator;for(;h.next();){const a=h.value;l.length>1&&(l+=","),l+=this.IT(a.x),l+=",",l+=this.IT(a.y)}l+="]",e+=l}else e+=this.writeJsonValue(o)}return e+="}",e}IT(t){if(t===1/0)return"9e9999";if(t===-1/0)return"-9e9999";if(isNaN(t))return"0";const i=this.pointsDigits;return i>16?t.toString():t.toFixed(i)}get pointsDigits(){return this.Ay}set pointsDigits(t){t<0?t=0:t>100&&(t=100),this.Ay=t}Ki(t){return typeof t=="number"?t:t==="NaN"?NaN:t==="9e9999"?1/0:t==="-9e9999"?-1/0:parseFloat(t)}AO(t){if(typeof t!="object")return t;let i=t.class||"";if(typeof i!="string"||i==="")return t;if(i==="NaN")return NaN;if(i==="Date")return new Date(t.value);if(i.indexOf("go.")!==0)return t;i=i.substring(3);let e=t;if(i==="Point")e=new Point(this.Ki(t.x),this.Ki(t.y));else if(i==="Size")e=new Size(this.Ki(t.width),this.Ki(t.height));else if(i==="Rect")e=new Rect(this.Ki(t.x),this.Ki(t.y),this.Ki(t.width),this.Ki(t.height));else if(i==="Margin")e=new Margin(this.Ki(t.top),this.Ki(t.right),this.Ki(t.bottom),this.Ki(t.left));else if(i==="Spot")typeof t.enum=="string"?e=Spot.parse(t.enum):e=new Spot(this.Ki(t.x),this.Ki(t.y),this.Ki(t.offsetX),this.Ki(t.offsetY));else if(i==="Brush"){const s=new Brush;s.type=Util.Ih(BrushType,t.type)??1,typeof t.color=="string"&&(s.color=t.color),t.start instanceof Spot&&(s.start=t.start),t.end instanceof Spot&&(s.end=t.end),typeof t.startRadius=="number"&&(s.startRadius=this.Ki(t.startRadius)),typeof t.endRadius=="number"&&(s.endRadius=this.Ki(t.endRadius));const n=t.colorStops;if(Util.wt(n))for(const o in n){const r=parseFloat(o);s.addColorStop(r,n[o])}e=s}else if(i==="Geometry"){let s=null;typeof t.path=="string"?s=Geometry.parse(t.path):s=new Geometry,s.type=Util.Ih(GeometryType,t.type)??1,typeof t.startX=="number"&&(s.startX=this.Ki(t.startX)),typeof t.startY=="number"&&(s.startY=this.Ki(t.startY)),typeof t.endX=="number"&&(s.endX=this.Ki(t.endX)),typeof t.endY=="number"&&(s.endY=this.Ki(t.endY)),t.spot1 instanceof Spot&&(s.spot1=t.spot1),t.spot2 instanceof Spot&&(s.spot2=t.spot2),e=s}else if(i==="EnumValue"){let s=t.classType;s.indexOf("go.")===0&&(s=s.substring(3));const n=Model.I1(s);typeof n=="function"&&(e=Util.Ih(n,t.name))}return e}get name(){return this.Mt}set name(t){const i=this.Mt;i!==t&&(Util.i(t,"string",Model,"name"),this.Mt=t,this.t("name",i,t))}get dataFormat(){return this._d}set dataFormat(t){const i=this._d;i!==t&&(Util.i(t,"string",Model,"dataFormat"),this._d=t,this.t("dataFormat",i,t))}get isReadOnly(){return this.vo}set isReadOnly(t){const i=this.vo;i!==t&&(Util.i(t,"boolean",Model,"isReadOnly"),this.vo=t,this.t("isReadOnly",i,t))}get modelData(){return this.D1}set modelData(t){const i=this.D1;i!==t&&(Util.i(t,"object",Model,"modelData"),this.D1=t,this.t("modelData",i,t),this.updateTargetBindings(t))}addChangedListener(t){return Util.i(t,"function",Model,"addChangedListener:listener"),this.F1.add(t),this}removeChangedListener(t){Util.i(t,"function",Model,"removeChangedListener:listener"),this.F1.delete(t)}Ew(t){this.skipsUndoManager||this.undoManager.handleChanged(t);const i=this.F1,e=i.length;for(let s=0;s0&&Util.o("Cannot set Model.nodeKeyProperty when there is existing node data"),this.Nh=t,this.t("nodeKeyProperty",i,t))}An(t,i,e){typeof t!="string"&&typeof t!="function"&&Util.we(t,"string or function",i,e)}getKeyForNodeData(t){if(t===null)return;const i=this.Nh;if(i==="")return;const e=Model.vt(t,i);if(e!==void 0){if(this.isKeyType(e))return e;Util.o("Key value for node data "+t+" is not a number or a string: "+e)}}setKeyForNodeData(t,i){if((i==null||!this.isKeyType(i))&&Util.we(i,"number or string",Model,"setKeyForNodeData:key"),t===null)return;const e=this.Nh;if(e==="")return;if(!this.containsNodeData(t)){Model.rt(t,e,i);return}const s=Model.vt(t,e);if(s!==i){if(this.findNodeDataForKey(i)!==null)return;Model.rt(t,e,i),s!==void 0&&this.ti.delete(s),this.ti.set(i,t),this.Et("nodeKey",2,e,t,s,i),typeof e=="string"&&this.updateTargetBindings(t,e),this.Fy(s,i)}}get makeUniqueKeyFunction(){return this.Df}set makeUniqueKeyFunction(t){const i=this.Df;i!==t&&(t!==null&&Util.i(t,"function",Model,"makeUniqueKeyFunction"),this.Df=t,this.t("makeUniqueKeyFunction",i,t))}isKeyType(t){return typeof t=="number"||typeof t=="string"}containsNodeData(t){if(t===null)return!1;const i=this.getKeyForNodeData(t);return i===void 0?!1:this.ti.get(i)===t}findNodeDataForKey(t){return t===null&&Util.o("Model.findNodeDataForKey:key must not be null"),t===void 0||!this.isKeyType(t)?null:this.ti.get(t)}get nodeDataArray(){return this.De}set nodeDataArray(t){const i=this.De;if(i!==t){this.ti.clear(),this.MN();const e=t.length;for(let o=0;o=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" GraphLinksModel";if(t>0){i+=` node data:`;let e=this.nodeDataArray,s=e.length,n=0;for(n=0;n"+this.Te(o,!1)}}return i}}kN(t,i){if(this.linkKeyProperty===""){const f=this.skipsUndoManager;this.skipsUndoManager=!0,this.linkKeyProperty="key",this.skipsUndoManager=f}let e=super.kN(t,i);const s=this,n=new GSet,o=new GSet,r=new GSet,l=this.Xa;t.changes.each(f=>{if(f.model===s){if(f.modelChange==="linkDataArray")f.change===3?n.add(f.newValue):f.change===4&&r.add(f.oldValue);else if(s.containsLinkData(f.object))o.add(f.object);else if(f.object!==null)if(f.object!==null&&l&&l.has(f.object))l.get(f.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(f.object instanceof Model||s.containsNodeData(f.object))return;s.UT(f.object).each(d=>o.add(d))}}});const h=this.rg;h.clear(),n.each(f=>{h.add(s.getKeyForLinkData(f)),i||o.add(f)});const a=this.og;a.clear(),r.each(f=>{a.add(s.getKeyForLinkData(f)),i&&o.add(f)});const c=s.cloneDeep(o.toArray());return h.count>0&&(e===null&&(e={}),i?e.removedLinkKeys=h.toArray():e.insertedLinkKeys=h.toArray()),c.length>0&&(e===null&&(e={}),e.modifiedLinkData=c),a.count>0&&(e===null&&(e={}),i?e.insertedLinkKeys=a.toArray():e.removedLinkKeys=a.toArray()),a.clear(),h.clear(),e}hg(){const t=super.hg();let i="";return this.linkCategoryProperty!=="category"&&typeof this.linkCategoryProperty=="string"&&(i+=`, + link data:`,e=this.linkDataArray,s=e.length,n=0;n"+this.Te(o,!1)}}return i}}xN(t,i){if(this.linkKeyProperty===""){const f=this.skipsUndoManager;this.skipsUndoManager=!0,this.linkKeyProperty="key",this.skipsUndoManager=f}let e=super.xN(t,i);const s=this,n=new GSet,o=new GSet,r=new GSet,l=this.Ka;t.changes.each(f=>{if(f.model===s){if(f.modelChange==="linkDataArray")f.change===3?n.add(f.newValue):f.change===4&&r.add(f.oldValue);else if(s.containsLinkData(f.object))o.add(f.object);else if(f.object!==null)if(f.object!==null&&l&&l.has(f.object))l.get(f.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(f.object instanceof Model||s.containsNodeData(f.object))return;s.BT(f.object).each(d=>o.add(d))}}});const h=this.og;h.clear(),n.each(f=>{h.add(s.getKeyForLinkData(f)),i||o.add(f)});const a=this.ng;a.clear(),r.each(f=>{a.add(s.getKeyForLinkData(f)),i&&o.add(f)});const c=s.cloneDeep(o.toArray());return h.count>0&&(e===null&&(e={}),i?e.removedLinkKeys=h.toArray():e.insertedLinkKeys=h.toArray()),c.length>0&&(e===null&&(e={}),e.modifiedLinkData=c),a.count>0&&(e===null&&(e={}),i?e.insertedLinkKeys=a.toArray():e.removedLinkKeys=a.toArray()),a.clear(),h.clear(),e}lg(){const t=super.lg();let i="";return this.linkCategoryProperty!=="category"&&typeof this.linkCategoryProperty=="string"&&(i+=`, "linkCategoryProperty": `+this.Fe(this.linkCategoryProperty)),this.linkKeyProperty!==""&&typeof this.linkKeyProperty=="string"&&(i+=`, "linkKeyProperty": `+this.Fe(this.linkKeyProperty)),this.linkFromKeyProperty!=="from"&&typeof this.linkFromKeyProperty=="string"&&(i+=`, "linkFromKeyProperty": `+this.Fe(this.linkFromKeyProperty)),this.linkToKeyProperty!=="to"&&typeof this.linkToKeyProperty=="string"&&(i+=`, @@ -47,13 +47,13 @@ string: ${t}`);break}}const T=b.qg;if(GeoStream.wC(b),i){const A=T.figures.itera "linkToPortIdProperty": `+this.Fe(this.linkToPortIdProperty)),this.linkLabelKeysProperty!==""&&typeof this.linkLabelKeysProperty=="string"&&(i+=`, "linkLabelKeysProperty": `+this.Fe(this.linkLabelKeysProperty)),this.nodeIsGroupProperty!=="isGroup"&&typeof this.nodeIsGroupProperty=="string"&&(i+=`, "nodeIsGroupProperty": `+this.Fe(this.nodeIsGroupProperty)),this.nodeGroupKeyProperty!=="group"&&typeof this.nodeGroupKeyProperty=="string"&&(i+=`, - "nodeGroupKeyProperty": `+this.Fe(this.nodeGroupKeyProperty)),t+i}Ty(t){super.Ty(t),t.linkKeyProperty&&(this.linkKeyProperty=t.linkKeyProperty),t.linkFromKeyProperty&&(this.linkFromKeyProperty=t.linkFromKeyProperty),t.linkToKeyProperty&&(this.linkToKeyProperty=t.linkToKeyProperty),t.linkFromPortIdProperty&&(this.linkFromPortIdProperty=t.linkFromPortIdProperty),t.linkToPortIdProperty&&(this.linkToPortIdProperty=t.linkToPortIdProperty),t.linkCategoryProperty&&(this.linkCategoryProperty=t.linkCategoryProperty),t.linkLabelKeysProperty&&(this.linkLabelKeysProperty=t.linkLabelKeysProperty),t.nodeIsGroupProperty&&(this.nodeIsGroupProperty=t.nodeIsGroupProperty),t.nodeGroupKeyProperty&&(this.nodeGroupKeyProperty=t.nodeGroupKeyProperty)}PN(){const t=super.PN(),i=`, - "linkDataArray": `+this.Nh(this.linkDataArray,!0);return t+i}MN(t){super.MN(t);const i=t.linkDataArray;Array.isArray(i)&&(this.replaceJsonObjects(i),this.linkDataArray=i)}BT=`, - "insertedLinkKeys": `;FO=`, + "nodeGroupKeyProperty": `+this.Fe(this.nodeGroupKeyProperty)),t+i}Ty(t){super.Ty(t),t.linkKeyProperty&&(this.linkKeyProperty=t.linkKeyProperty),t.linkFromKeyProperty&&(this.linkFromKeyProperty=t.linkFromKeyProperty),t.linkToKeyProperty&&(this.linkToKeyProperty=t.linkToKeyProperty),t.linkFromPortIdProperty&&(this.linkFromPortIdProperty=t.linkFromPortIdProperty),t.linkToPortIdProperty&&(this.linkToPortIdProperty=t.linkToPortIdProperty),t.linkCategoryProperty&&(this.linkCategoryProperty=t.linkCategoryProperty),t.linkLabelKeysProperty&&(this.linkLabelKeysProperty=t.linkLabelKeysProperty),t.nodeIsGroupProperty&&(this.nodeIsGroupProperty=t.nodeIsGroupProperty),t.nodeGroupKeyProperty&&(this.nodeGroupKeyProperty=t.nodeGroupKeyProperty)}bN(){const t=super.bN(),i=`, + "linkDataArray": `+this.Ch(this.linkDataArray,!0);return t+i}kN(t){super.kN(t);const i=t.linkDataArray;Array.isArray(i)&&(this.replaceJsonObjects(i),this.linkDataArray=i)}UT=`, + "insertedLinkKeys": `;DO=`, "modifiedLinkData": `;VT=`, - "removedLinkKeys": `;UT(t){const i=new GSet;for(let e=0;e{if(f.model===s){if(f.modelChange==="linkDataArray")f.change===3?n.add(f.newValue):f.change===4&&r.add(f.oldValue);else if(s.containsLinkData(f.object))o.add(f.object);else if(f.object!==null)if(f.object!==null&&l&&l.has(f.object))l.get(f.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(f.object instanceof Model||s.containsNodeData(f.object))return;s.UT(f.object).each(d=>o.add(d))}}});const h=this.rg;h.clear(),n.each(f=>{h.add(s.getKeyForLinkData(f)),i||o.add(f)});const a=this.og;a.clear(),r.each(f=>{a.add(s.getKeyForLinkData(f)),i&&o.add(f)});let c=e;return h.count>0&&(c+=(i?this.VT:this.BT)+this.Nh(h.toArray(),!0)),o.count>0&&(c+=this.FO+this.Nh(o.toArray(),!0)),a.count>0&&(c+=(i?this.BT:this.VT)+this.Nh(a.toArray(),!0)),a.clear(),h.clear(),c}Dy(t){(t.linkCategoryProperty!==void 0&&t.linkCategoryProperty!==this.linkCategoryProperty||t.linkKeyProperty!==void 0&&t.linkKeyProperty!==this.linkKeyProperty||t.linkFromKeyProperty!==void 0&&t.linkFromKeyProperty!==this.linkFromKeyProperty||t.linkToKeyProperty!==void 0&&t.linkToKeyProperty!==this.linkToKeyProperty||t.linkFromPortIdProperty!==void 0&&t.linkFromPortIdProperty!==this.linkFromPortIdProperty||t.linkToPortIdProperty!==void 0&&t.linkToPortIdProperty!==this.linkToPortIdProperty||t.linkLabelKeysProperty!==void 0&&t.linkLabelKeysProperty!==this.linkLabelKeysProperty||t.nodeIsGroupProperty!==void 0&&t.nodeIsGroupProperty!==this.nodeIsGroupProperty||t.nodeGroupKeyProperty!==void 0&&t.nodeGroupKeyProperty!==this.nodeGroupKeyProperty)&&Util.o("applyIncrementalJson cannot change Model properties"),super.Dy(t);const i=t.insertedLinkKeys;if(Array.isArray(i)){const n=i.length;for(let o=0;o=0&&s.splice(e,1)):s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue));return}}else if(t.change===4){let e=t.oldParam;if(t.modelChange==="linkDataArray"){const s=t.oldValue;if(Util.wt(s)&&typeof e=="number"){const n=this.getKeyForLinkData(s);i?(this.sr.add(s),this.$e[e]!==s&&this.$e.splice(e,0,s),n!==void 0&&this.fi.set(n,s)):(this.sr.delete(s),this.$e[e]===s&&this.$e.splice(e,1),n!==void 0&&this.fi.delete(n))}return}else if(t.modelChange==="linkLabelKeys"){const s=this.getLabelKeysForLinkData(t.object);Array.isArray(s)&&typeof e=="number"&&(i?s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue):(e=s.indexOf(t.newValue),e>=0&&s.splice(e,1)));return}}super.changeState(t,i)}}get archetypeNodeData(){return this.Ll}set archetypeNodeData(t){const i=this.Ll;i!==t&&(t!==null&&Util.i(t,"object",GraphLinksModel,"archetypeNodeData"),this.Ll=t,this.t("archetypeNodeData",i,t))}LN(t){if(t===void 0)return;const i=this.Ll;if(i!==null){let e=this.findNodeDataForKey(t);e===null&&(e=this.copyNodeData(i),Model.lt(e,this.nodeKeyProperty,t),this.addNodeData(e))}return t}get linkFromKeyProperty(){return this.wo}set linkFromKeyProperty(t){const i=this.wo;i!==t&&(this.An(t,GraphLinksModel,"linkFromKeyProperty"),this.wo=t,this.t("linkFromKeyProperty",i,t))}getFromKeyForLinkData(t){return this.Te(t,!0)}setFromKeyForLinkData(t,i){this.Qd(t,i,!0)}get linkToKeyProperty(){return this.xo}set linkToKeyProperty(t){const i=this.xo;i!==t&&(this.An(t,GraphLinksModel,"linkToKeyProperty"),this.xo=t,this.t("linkToKeyProperty",i,t))}getToKeyForLinkData(t){return this.Te(t,!1)}setToKeyForLinkData(t,i){this.Qd(t,i,!1)}Te(t,i){if(t===null)return;const e=i?this.wo:this.xo;if(e==="")return;const s=Model.vt(t,e);if(s!==void 0){if(this.isKeyType(s))return s;Util.o((i?"FromKey":"ToKey")+" value for link data "+t+" is not a number or a string: "+s)}}Qd(t,i,e){if(i===null&&(i=void 0),i!==void 0&&!this.isKeyType(i)&&Util.we(i,"number or string",GraphLinksModel,e?"setFromKeyForLinkData:key":"setToKeyForLinkData:key"),t===null)return;const s=e?this.wo:this.xo;if(s==="")return;if(i=this.LN(i),!this.containsLinkData(t)){Model.lt(t,s,i);return}const n=Model.vt(t,s);n!==i&&(this.Js(n,t),Model.lt(t,s,i),this.findNodeDataForKey(i)===null&&this.$s(i,t),this.Et(e?"linkFromKey":"linkToKey",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkFromPortIdProperty(){return this.Ka}set linkFromPortIdProperty(t){const i=this.Ka;i!==t&&(this.An(t,GraphLinksModel,"linkFromPortIdProperty"),this.Ka=t,this.t("linkFromPortIdProperty",i,t))}getFromPortIdForLinkData(t){return this.L1(t,!0)}setFromPortIdForLinkData(t,i){this._d(t,i,!0)}get linkToPortIdProperty(){return this.Ya}set linkToPortIdProperty(t){const i=this.Ya;i!==t&&(this.An(t,GraphLinksModel,"linkToPortIdProperty"),this.Ya=t,this.t("linkToPortIdProperty",i,t))}getToPortIdForLinkData(t){return this.L1(t,!1)}setToPortIdForLinkData(t,i){this._d(t,i,!1)}L1(t,i){if(t===null)return"";const e=i?this.Ka:this.Ya;if(e==="")return"";const s=Model.vt(t,e);return s===void 0?"":s}_d(t,i,e){if(Util.i(i,"string",GraphLinksModel,e?"setFromPortIdForLinkData:portname":"setToPortIdForLinkData:portname"),t===null)return;const s=e?this.Ka:this.Ya;if(s==="")return;if(!this.containsLinkData(t)){Model.lt(t,s,i);return}let n=Model.vt(t,s);n===void 0&&(n=""),n!==i&&(Model.lt(t,s,i),this.Et(e?"linkFromPortId":"linkToPortId",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkLabelKeysProperty(){return this.Zs}set linkLabelKeysProperty(t){const i=this.Zs;i!==t&&(this.An(t,GraphLinksModel,"linkLabelKeysProperty"),this.Zs=t,this.t("linkLabelKeysProperty",i,t))}getLabelKeysForLinkData(t){if(t===null)return GraphLinksModel.EmptyArray;const i=this.Zs;if(i==="")return GraphLinksModel.EmptyArray;const e=Model.vt(t,i);return e===void 0?GraphLinksModel.EmptyArray:e}setLabelKeysForLinkData(t,i){if(t===null)return;const e=this.Zs;if(e==="")return;if(!this.containsLinkData(t)){Model.lt(t,e,i);return}let s=Model.vt(t,e);if(s===void 0&&(s=GraphLinksModel.EmptyArray),s!==i){if(Array.isArray(s)){const o=s.length;for(let r=0;r=0)return;n=s.length,s.push(i),this.containsLinkData(t)&&(this.findNodeDataForKey(i)===null&&this.$s(i,t),this.Et("linkLabelKeys",3,e,t,null,i,null,n))}else Util.o(e+" property is not an Array; cannot addLabelKeyForLinkData: "+t)}removeLabelKeyForLinkData(t,i){if(i==null||(this.isKeyType(i)||Util.we(i,"number or string",GraphLinksModel,"removeLabelKeyForLinkData:key"),t===null))return;const e=this.Zs;if(e==="")return;const s=Model.vt(t,e);if(Array.isArray(s)){const n=s.indexOf(i);if(n<0)return;s.splice(n,1),this.containsLinkData(t)&&(this.Js(i,t),this.Et("linkLabelKeys",4,e,t,i,null,n,null))}else s!==void 0&&Util.o(e+" property is not an Array; cannot removeLabelKeyforLinkData: "+t)}get linkDataArray(){return this.$e}set linkDataArray(t){const i=this.$e;if(i!==t){this.fi.clear();const e=t.length;for(let n=0;nnew GraphLinksModel;Model.initDiagramModel=Model.initDiagramModel=()=>new GraphLinksModel;class TreeModel extends Model{Dn;dg;ja;constructor(t,i){if(super(),this.Dn="parent",this.dg=!1,this.ja="parentLinkCategory",t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){super.cloneProtected(t),t.Dn=this.Dn,t.dg=this.dg,t.ja=this.ja}toString(t){if(t===void 0&&(t=0),t>=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" TreeModel";if(t>0){i+=` - node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n(w[w.ConstantSpacing=0]="ConstantSpacing",w[w.ConstantDistance=1]="ConstantDistance",w[w.ConstantAngle=2]="ConstantAngle",w[w.Packed=3]="Packed",w))(CircularArrangement||{}),CircularDirection=(w=>(w[w.Clockwise=10]="Clockwise",w[w.Counterclockwise=11]="Counterclockwise",w[w.BidirectionalLeft=12]="BidirectionalLeft",w[w.BidirectionalRight=13]="BidirectionalRight",w))(CircularDirection||{}),CircularSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w[w.Optimized=24]="Optimized",w))(CircularSorting||{}),CircularNodeDiameterFormula=(w=>(w[w.Pythagorean=30]="Pythagorean",w[w.Circular=31]="Circular",w))(CircularNodeDiameterFormula||{});class CircularLayout extends Layout{re;Of;U1;gg;B1;Lh;DN;FN;RN;bs;vy;Oy;Ha;Iy;XT;mg;pg;yg;If;zi;S;pe;ye;Ln;wg;constructor(t){super(),this.re=0,this.Of=0,this.U1=0,this.gg=360,this.B1=0,this.Lh=0,this.DN=new Point,this.FN=30,this.RN=0,this.bs=0,this.vy=0,this.Oy=new VertexArrangement,this.Ha=0,this.Iy=0,this.XT=600,this.mg=NaN,this.pg=1,this.yg=0,this.If=360,this.zi=0,this.S=10,this.pe=24,this.ye=LayoutVertex.standardComparer,this.Ln=6,this.wg=30,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.mg=this.mg,t.pg=this.pg,t.yg=this.yg,t.If=this.If,t.zi=this.zi,t.S=this.S,t.pe=this.pe,t.ye=this.ye,t.Ln=this.Ln,t.wg=this.wg}ri(t){t in CircularSorting?this.sorting=t:t in CircularDirection?this.direction=t:t in CircularArrangement?this.arrangement=t:t in CircularNodeDiameterFormula?this.nodeDiameterFormula=t:super.ri(t)}createNetwork(){return new CircularNetwork(this)}OO(t,i,e){t=this.IO(t);let s=this.B1,n=this.FN,o=this.re,r=this.Of,l=this.U1,h=this.gg,a=this.Lh,c=this.RN,f=this.bs,u=this.vy;if(s=this.arrangement,n=this.nodeDiameterFormula,o=this.radius,(!isFinite(o)||o<=0)&&(o=NaN),r=this.aspectRatio,(!isFinite(r)||r<=0)&&(r=1),l=this.startAngle,isFinite(l)||(l=0),h=this.sweepAngle,(!isFinite(h)||h>360||h<1)&&(h=360),a=this.spacing,isFinite(a)||(a=NaN),s===3&&n===31?s=0:s===3&&n!==31&&(n=31,s=this.arrangement),(this.direction===12||this.direction===13)&&this.sorting!==24){for(let g=0;!(g>=t.length||(i.add(t.elt(g)),g+1>=t.length));g+=2)e.add(t.elt(g+1));this.direction===12?(this.arrangement===3&&i.reverse(),t=new List,t.addAll(i),t.addAll(e)):(this.arrangement===3&&e.reverse(),t=new List,t.addAll(e),t.addAll(i))}const d=t.length;c=0;let m=0;for(let g=0;g1?(o=y,f=o*r):(f=y,o=f)}else o=this.V1(u*(h>=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180)}else o=this.V1(c+(h>=360?d:d-1)*(s!==3?a:a*1.6),r,l*Math.PI/180,h*Math.PI/180);f=o*r}else{f=o*r;const g=this.vN(o,f,l*Math.PI/180,h*Math.PI/180);if(isNaN(a))s===0&&(a=(g-c)/(h>=360?d:d-1));else if(s===0){const p=(g-c)/(h>=360?d:d-1);p=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180),f=o*r):a=p}else{let p=-1/0;for(let k=0;k=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180);x>o?(o=x,f=o*r,u=y):u=g/(h>=360?d:d-1)}}return this.B1=s,this.FN=n,this.re=o,this.Of=r,this.U1=l,this.gg=h,this.Lh=a,this.RN=c,this.bs=f,this.vy=u,t}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.network.vertexes;if(i.count<=1){if(i.count===1){const u=i.first();u.centerX=0,u.centerY=0}this.updateParts(),this.network=null,this.isValidLayout=!0;return}let e=new List;e.addAll(i.iterator);const s=new List,n=new List;e=this.OO(e,s,n);const o=this.B1,r=this.re,l=this.U1,h=this.gg,a=this.Lh,c=this.bs,f=this.vy;if((this.direction===12||this.direction===13)&&o===3)this.KT(e,h,l-h/2,10);else if(this.direction===12||this.direction===13){let u=0;switch(o){case 1:u=this.z1(r,c,l,f)*180/Math.PI;break;case 0:{let d=0,m=0;const g=s.first();g!==null&&(d=g.Ah(Math.PI/2));const p=n.first();p!==null&&(m=p.Ah(Math.PI/2)),u=this.z1(r,c,l,a+(d+m)/2)*180/Math.PI;break}case 2:u=h/e.length;break}if(this.direction===12){switch(o){case 1:this.Ey(s,h/2,l,11);break;case 0:this.Uy(s,h/2,l,11);break;case 2:this.By(s,h/2,l,11);break}switch(o){case 1:this.Ey(n,h/2,l+u,10);break;case 0:this.Uy(n,h/2,l+u,10);break;case 2:this.By(n,h/2,l+u,10);break}}else{switch(o){case 1:this.Ey(n,h/2,l,11);break;case 0:this.Uy(n,h/2,l,11);break;case 2:this.By(n,h/2,l,11);break}switch(o){case 1:this.Ey(s,h/2,l+u,10);break;case 0:this.Uy(s,h/2,l+u,10);break;case 2:this.By(s,h/2,l+u,10);break}}}else switch(o){case 1:this.Ey(e,h,l,this.direction);break;case 0:this.Uy(e,h,l,this.direction);break;case 2:this.By(e,h,l,this.direction);break;case 3:this.KT(e,h,l,this.direction);break}this.updateParts(),this.network=null,this.isValidLayout=!0}By(t,i,e,s){const n=this.gg,o=this.re,r=this.bs,l=e*Math.PI/180,h=i*Math.PI/180,a=t.length;for(let c=0;c=360?a:a-1):-(c*h)/a),u=t.elt(c),d=o*Math.tan(f)/r,m=Math.sqrt((o*o+r*r*d*d)/(1+d*d));u.centerX=m*Math.cos(f),u.centerY=m*Math.sin(f),u.actualAngle=f*180/Math.PI}}Uy(t,i,e,s){const n=this.re,o=this.bs,r=this.Lh;let l=e*Math.PI/180;const h=t.length;for(let a=0;a180&&(n-=360),n*=Math.PI/180,this.Iy=n,this.YT(t,i,e,s)}else this.GT(t,i,e,s);this.Oy.commit(t)}GT(t,i,e,s){const n=this.re,o=this.bs,r=this.Lh,l=this.Of;let h=n*Math.cos(e*Math.PI/180),a=o*Math.sin(e*Math.PI/180);const c=t.toArray();if(c.length===3){c[0].centerX=n,c[0].centerY=0,c[1].centerX=c[0].centerX-c[0].width/2-c[1].width/2-r,c[1].y=c[0].y,c[2].centerX=(c[0].centerX+c[1].centerX)/2,c[2].y=c[0].y-c[2].height-r;return}else if(c.length===4){c[0].centerX=n,c[0].centerY=0,c[2].centerX=-c[0].centerX,c[2].centerY=c[0].centerY,c[1].centerX=0,c[1].y=Math.min(c[0].y,c[2].y)-c[1].height-r,c[3].centerX=0,c[3].y=Math.max(c[0].y+c[0].height+r,c[2].y+c[2].height+r);return}const f=Point.l();for(let b=0;b=c.length-1));b++)this.jT(h,a,c,b,s,f)||this.HT(h,a,c,b,s,f),h=f.x,a=f.y;if(Point.s(f),this.Ha++,this.Ha>23)return;const u=c[0].centerX,d=c[0].centerY,m=c[c.length-1].centerX,g=c[c.length-1].centerY;let p=Math.abs(u-m)-((c[0].width+c[c.length-1].width)/2+r);const y=Math.abs(d-g)-((c[0].height+c[c.length-1].height)/2+r);let x=0;if(Math.abs(y)<1){const b=Math.abs(u-m),P=(c[0].width+c[c.length-1].width)/2;b0?x=y:Math.abs(p)<1?x=0:x=p;let k=!1;Math.abs(m)>Math.abs(g)?k=m>0!=d>g:k=g>0!=u1&&(this.Ha<8?this.re-=x/(2*Math.PI):c.length<5&&x>10?this.re/=2:this.re-=x>0?1.7:-2.3,this.bs=this.re*l,this.GT(t,i,e,s))}YT(t,i,e,s){const n=this.re,o=this.bs,r=this.Of;let l=n*Math.cos(e*Math.PI/180),h=o*Math.sin(e*Math.PI/180);const a=Point.l(),c=t.toArray();for(let m=0;m=c.length-1));m++)this.jT(l,h,c,m,s,a)||this.HT(l,h,c,m,s,a),l=a.x,h=a.y;if(Point.s(a),this.Ha++,this.Ha>23)return;const f=Math.atan2(h,l);let u=s===10?this.Iy-f:f-this.Iy;u=Math.abs(u)1&&(this.Ha<8?this.re-=d/(2*Math.PI):this.re-=d>0?1.7:-2.3,this.bs=this.re*r,this.YT(t,i,e,s))}jT(t,i,e,s,n,o){const r=this.Lh,l=this.re,h=this.bs;let a=0,c=0;const f=(e[s].width+e[s+1].width)/2+r;let u=!1;if(i>=0!=(n===10)){if(a=t+f,a>l){if(a=t-f,a<-l)return o.x=a,o.y=c,!1;u=!0}}else if(a=t-f,a<-l){if(a=t+f,a>l)return o.x=a,o.y=c,!1;u=!0}return c=Math.sqrt(1-Math.min(1,a*a/(l*l)))*h,i<0!==u&&(c=-c),Math.abs(i-c)>(e[s].height+e[s+1].height)/2?(o.x=a,o.y=c,!1):(o.x=a,o.y=c,!0)}HT(t,i,e,s,n,o){const r=this.Lh,l=this.re,h=this.bs;let a=0,c=0;const f=(e[s].height+e[s+1].height)/2+r;let u=!1;if(t>=0!=(n===10)){if(c=i-f,c<-h){if(c=i+f,c>h)return o.x=a,o.y=c,!1;u=!0}}else if(c=i+f,c>h){if(c=i-f,c<-h)return o.x=a,o.y=c,!1;u=!0}return a=Math.sqrt(1-Math.min(1,c*c/(h*h)))*l,t<0!==u&&(a=-a),Math.abs(t-a)>(e[s].width+e[s+1].width)/2?(o.x=a,o.y=c,!1):(o.x=a,o.y=c,!0)}commitLayout(){this.commitNodes(),this.isRouting&&this.commitLinks()}commitNodes(){const t=this.group!==null&&this.group.hasPlaceholder(),i=t?this.group.location.copy():null;let e=this.actualCenter;t?e=new Point(0,0):(e.x=this.arrangementOrigin.x+this.re,e.y=this.arrangementOrigin.y+this.bs);const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;n.x+=e.x,n.y+=e.y,n.commit()}if(t){this.group.ensureBounds();const n=this.group.position.copy(),o=this.group.location.copy(),r=i.subtract(o.subtract(n));this.group.move(r),this.DN=r.subtract(n)}}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}vN(t,i,e,s){const n=this.XT;if(Math.abs(this.Of-1)<.001)return e!==void 0&&s!==void 0?s*t:2*Math.PI*t;const o=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let r=0,l=0;e!==void 0&&s!==void 0?l=s/(n+1):l=Math.PI/(2*(n+1));let h=0;for(let a=0;a<=n;a++){e!==void 0&&s!==void 0?h=e+a*s/n:h=a*Math.PI/(2*n);const c=Math.sin(h);r+=Math.sqrt(1-o*o*c*c)*l}return e!==void 0&&s!==void 0?(t>i?t:i)*r:4*(t>i?t:i)*r}V1(t,i,e,s){let n=0;return e!==void 0&&s!==void 0?n=this.vN(1,i,e,s):n=this.vN(1,i),t/n}z1(t,i,e,s){if(Math.abs(this.Of-1)<.001)return s/t;const n=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let o=0;const r=2*Math.PI/(this.network.vertexes.count*700);t>i&&(e+=Math.PI/2);for(let l=0;;l++){const h=e+l*r,a=Math.sin(h);if(o+=(t>i?t:i)*Math.sqrt(1-n*n*a*a)*r,o>=s)return l*r}}IO(t){switch(this.sorting){case 20:break;case 21:t.reverse();break;case 22:t.sort(this.comparer);break;case 23:t.sort(this.comparer),t.reverse();break;case 24:return this.BO(this.VO(t));default:Util.o("Invalid sorting type.")}return t}VO(t){const i=[];for(let s=0;sn&&(n=u,o=c)}else for(let c=0;cn&&(n=f,o=c)}e.add(t.elt(o)),i[o]=-1;const r=t.elt(o);let l=0;const h=r.sourceEdges;for(;h.next();){const f=h.value.fromVertex;l=t.indexOf(f),!(l<0)&&i[l]>=0&&i[l]++}const a=r.destinationEdges;for(;a.next();){const f=a.value.toVertex;l=t.indexOf(f),!(l<0)&&i[l]>=0&&i[l]++}}return e}BO(t){const i=[];for(let f=0;f=0){const C=Math.abs(x-(L>=x?L+1:L));b+=C=x&&M++,L>=x&&L++,M>L){const C=L;L=M,M=C}L-M<(s.length+2)/2==(M=0&&(n.push(f),o.push(x))}h++}let a=!1;const c=s.length;for(;;){a=!0;for(let f=0;f=0){let g=0;for(let p=0;pm?x-m:m-x,b=c-k;g+=xb?1:-1}s.splice(g<0?m:m+1,0,u),r.splice(f,1),f--}else a=!1}if(a)break;s.push(r[0]),r.splice(0,1)}for(let f=0;f0||isNaN(t))&&(this.mg=t,this.invalidateLayout()))}get aspectRatio(){return this.pg}set aspectRatio(t){this.pg!==t&&(Util.i(t,"number",CircularLayout,"aspectRatio"),t>0&&(this.pg=t,this.invalidateLayout()))}get startAngle(){return this.yg}set startAngle(t){this.yg!==t&&(Util.i(t,"number",CircularLayout,"startAngle"),this.yg=t,this.invalidateLayout())}get sweepAngle(){return this.If}set sweepAngle(t){this.If!==t&&(Util.i(t,"number",CircularLayout,"sweepAngle"),t>0&&t<=360?this.If=t:this.If=360,this.invalidateLayout())}get arrangement(){return this.zi}set arrangement(t){this.zi!==t&&(t===3||t===0||t===1||t===2)&&(this.zi=t,this.invalidateLayout())}get direction(){return this.S}set direction(t){this.S!==t&&(t===10||t===11||t===12||t===13)&&(this.S=t,this.invalidateLayout())}get sorting(){return this.pe}set sorting(t){this.pe!==t&&(this.pe=t,this.invalidateLayout())}get comparer(){return this.ye}set comparer(t){this.ye!==t&&(Util.i(t,"function",CircularLayout,"comparer"),this.ye=t,this.invalidateLayout())}get spacing(){return this.Ln}set spacing(t){this.Ln!==t&&(Util.i(t,"number",CircularLayout,"spacing"),this.Ln=t,this.invalidateLayout())}get nodeDiameterFormula(){return this.wg}set nodeDiameterFormula(t){this.wg!==t&&(t===30||t===31)&&(this.wg=t,this.invalidateLayout())}get actualXRadius(){return this.re}get actualYRadius(){return this.bs}get actualSpacing(){return this.Lh}get actualCenter(){return this.DN}static ConstantSpacing=0;static ConstantDistance=1;static ConstantAngle=2;static Packed=3;static Clockwise=10;static Counterclockwise=11;static BidirectionalLeft=12;static BidirectionalRight=13;static Forwards=20;static Reverse=21;static Ascending=22;static Descending=23;static Optimized=24;static Pythagorean=30;static Circular=31}class VertexArrangement{Ef;qa;Uf;constructor(){this.Ef=-1/0,this.qa=null,this.Uf=null}EO(t,i){if(t>0&&this.Ef<0||Math.abs(t)0)){this.Ef=t,this.qa=[],this.Uf=[];for(let e=0;e0){for(this.network.deleteSelfEdges(),i=this.network.vertexes.iterator;i.next();){const o=i.value;o.charge=this.electricalCharge(o),o.mass=this.gravitationalMass(o)}const s=this.network.edges.iterator;for(;s.next();){const o=s.value;o.stiffness=this.springStiffness(o),o.length=this.springLength(o)}if(this.ON(),this.Th=0,this.needsPrelayout()){const o=this.network,r=o.splitIntoSubNetworks(!1);let l=r.iterator;for(;l.next();){const h=l.value;this.doConnectedSubnetLayout(h)}for(l=r.iterator,this.XO(l,o),l=r.iterator;l.next();){const h=l.value,a=h.vertexes.iterator;for(;a.next();){const f=a.value;o.addVertex(f)}const c=h.edges.iterator;for(;c.next();){const f=c.value;o.addEdge(f)}}}else this.qT(this.network,this.maxIterations);this.updateParts()}this.maxIterations=e,this.isValidLayout=!0}needsPrelayout(){if(this.network.vertexes.count<3)return!1;let t=0,i=0;const e=this.network.vertexes.first().bounds,s=this.network.vertexes.iterator;for(;s.next();){const n=s.value,o=n.bounds;if(isNaN(n.x)||isNaN(n.y)||o.intersectsRect(e)&&(t++,t>2))return!0;if(i>10)return!1;i++}return!1}doConnectedSubnetLayout(t){let i=t.vertexes.iterator;for(;i.next();){const l=i.value;l.hierarchicalVertexes.add(l)}let e=t,s=this.Yf;if(isNaN(s)&&(s=t.edges.count/t.vertexes.count),sMath.max(100,Math.sqrt(s*t.vertexes.count));)e=this.coarsenNetwork(e);let n=0;i=e.vertexes.iterator;let o=this.randomNumberGenerator;for(o===null&&(this.randomNumberGenerator=o=new RandomNumberGenerator(0));i.next();){i.value.idInCluster=n++;const l=10*(o.random()-.5),h=10*(o.random()-.5);this.isFixed(i.value)||(i.value.x=l,i.value.y=h);const a=i.value.hierarchicalVertexes.iterator;for(;a.next();)this.isFixed(a.value)||(a.value.x=l,a.value.y=h)}const r=this.computePairwiseDistances(e);this.KO(e,r,this.maxPrelayoutIterations,t.vertexes.count),this.qT(t,this.maxIterations)}computePairwiseDistances(t){const i=t.vertexes.count,e=new Array(i);for(let r=0;r0;){const l=o.shift(),h=l.vertexes.iterator;for(;h.next();){const a=h.value;n.has(a.idInCluster)||(n.set(a.idInCluster,n.get(l.idInCluster)+1),o.push(a))}}for(let l=0;l=0;m--)if(t[m].y>c.y&&t[m].x-c.xc.x&&t[m].y-c.ya+f){const u=s+o-h,d=n-a-f;return Geo.bw(u*u+d*d)}else if(n+rh+c)if(n>a+f){const u=s-h-c,d=n-a-f;return Geo.bw(u*u+d*d)}else if(n+ra+f?n-(a+f):n+rr-o;l?i.sort((m,g)=>m===null||g===null||m===g?0:m.centerX-g.centerX):i.sort((m,g)=>m===null||g===null||m===g?0:m.centerY-g.centerY);const h=this.Bf;let a=0,c=0,f=0;for(let m=0;mh||C-x>h){if(l)break;continue}if(k-S>h||S-k>h){if(!l)break;continue}const N=this.IN(g,P),T=2*g.charge,A=2*P.charge;if(N>1)a=T*A/(N*N),c=a*(x-C)/N,f=a*(k-S)/N;else{let D=this.randomNumberGenerator;D===null&&(this.randomNumberGenerator=D=new RandomNumberGenerator(0));const F=D.random(),R=D.random();if(x>C)c=Math.abs(P.bounds.right-g.bounds.x),c=T*A*(1+c)*F;else if(xS)f=Math.abs(P.bounds.bottom-g.bounds.y),f=T*A*(1+f)*R;else if(x1&&(a=.1*m.stiffness*(S-m.length),c=a*.5*(g.width+p.height)*(k-L)/S,f=a*.5*(g.width+p.height)*(b-C)/S),g.forceX-=c,g.forceY-=f,p.forceX+=c,p.forceY+=f}let d=0;for(let m=0;mthis.epsilonDistance*this.epsilonDistance}KO(t,i,e,s){const n=this.Th+e,o=Math.sqrt(s);this.Vy=this.Wa*t.vertexes.count;const r=t.vertexes.toArray();let l=0,h=0,a=0;for(;this.Th0){r[c].forceX=this.Vy*r[c].forceX/f,r[c].forceY=this.Vy*r[c].forceY/f,this.isFixed(r[c])||(r[c].x+=r[c].forceX,r[c].y+=r[c].forceY);const u=r[c].hierarchicalVertexes.iterator;for(;u.next();){const d=u.value;this.isFixed(d)||(d.centerX+=r[c].forceX,d.centerY+=r[c].forceY)}}l+=f*f}if(l>=h){if(a++,a>=5)break}else a=0;this.Vy*=.95}}moveVertex(t){let i=t.forceX,e=t.forceY;const s=this.moveLimit;return i<-s?i=-s:i>s&&(i=s),e<-s?e=-s:e>s&&(e=s),t.centerX+=i,t.centerY+=e,i*i+e*e}shouldInteract(t,i){return!0}moveFixedVertex(t){}commitLayout(){this.zy(),this.commitNodes(),this.isRouting&&this.commitLinks()}zy(){if(!this.setsPortSpots)return;const t=this.network.edges.iterator;for(;t.next();){const e=t.value.link;e!==null&&(e.fromSpot=Spot.Default,e.toSpot=Spot.Default)}}commitNodes(){let t=0,i=0;if(this.arrangesToOrigin){const n=Rect.l();this.Nw(this.network,n);const o=this.arrangementOrigin;t=o.x-n.x,i=o.y-n.y,Rect.s(n)}const e=Rect.l(),s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;(t!==0||i!==0)&&(e.a(n.bounds),e.x+=t,e.y+=i,n.bounds=e),n.commit()}Rect.s(e)}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}springStiffness(t){const i=t.stiffness;return isNaN(i)?this.Vf:i}springLength(t){const i=t.length;return isNaN(i)?this.zf:i}electricalCharge(t){const i=t.charge;return isNaN(i)?this.Xf:i}electricalFieldX(t,i){return 0}electricalFieldY(t,i){return 0}gravitationalMass(t){const i=t.mass;return isNaN(i)?this.Kf:i}gravitationalFieldX(t,i){return 0}gravitationalFieldY(t,i){return 0}isFixed(t){return t.isFixed}get currentIteration(){return this.Th}get arrangementSpacing(){return this.ks}set arrangementSpacing(t){this.ks.equals(t)||(this.ks.a(t),this.invalidateLayout())}get arrangesToOrigin(){return this.xg}set arrangesToOrigin(t){this.xg!==t&&(Util.i(t,"boolean",ForceDirectedLayout,"arrangesToOrigin"),this.xg=t,this.invalidateLayout())}get setsPortSpots(){return this.Fn}set setsPortSpots(t){this.Fn!==t&&(Util.i(t,"boolean",ForceDirectedLayout,"setsPortSpots"),this.Fn=t,this.invalidateLayout())}get comments(){return this.Re}set comments(t){this.Re!==t&&(Util.i(t,"boolean",ForceDirectedLayout,"comments"),this.Re=t,this.invalidateLayout())}get maxPrelayoutIterations(){return this.bg}set maxPrelayoutIterations(t){this.bg!==t&&(Util.i(t,"number",ForceDirectedLayout,"maxPrelayoutIterations"),t>=0&&(this.bg=t,this.invalidateLayout()))}get maxIterations(){return this.kg}set maxIterations(t){this.kg!==t&&(Util.i(t,"number",ForceDirectedLayout,"maxIterations"),t>=0&&(this.kg=t,this.invalidateLayout()))}get epsilonDistance(){return this.Pg}set epsilonDistance(t){this.Pg!==t&&(Util.i(t,"number",ForceDirectedLayout,"epsilonDistance"),t>0&&(this.Pg=t,this.invalidateLayout()))}get infinityDistance(){return this.Bf}set infinityDistance(t){this.Bf!==t&&(Util.i(t,"number",ForceDirectedLayout,"infinityDistance"),t>1&&(this.Bf=t,this.invalidateLayout()))}get moveLimit(){return this.Mg}set moveLimit(t){this.Mg!==t&&(Util.i(t,"number",ForceDirectedLayout,"moveLimit"),this.Mg=t,this.invalidateLayout())}get randomNumberGenerator(){return this.Sg}set randomNumberGenerator(t){this.Sg!==t&&(t!==null&&typeof t.random!="function"&&Util.o('ForceDirectedLayout.randomNumberGenerator must have a "random()" function on it: '+t),this.Sg=t)}get defaultSpringStiffness(){return this.Vf}set defaultSpringStiffness(t){this.Vf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultSpringStiffness"),this.Vf=t,this.invalidateLayout())}get defaultSpringLength(){return this.zf}set defaultSpringLength(t){this.zf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultSpringLength"),this.zf=t,this.invalidateLayout())}get defaultElectricalCharge(){return this.Xf}set defaultElectricalCharge(t){this.Xf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultElectricalCharge"),this.Xf=t,this.invalidateLayout())}get defaultGravitationalMass(){return this.Kf}set defaultGravitationalMass(t){this.Kf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultGravitationalMass"),this.Kf=t,this.invalidateLayout())}get defaultCommentSpringLength(){return this.Ng}set defaultCommentSpringLength(t){this.Ng!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultCommentSpringLength"),this.Ng=t,this.invalidateLayout())}get defaultCommentElectricalCharge(){return this.Cg}set defaultCommentElectricalCharge(t){this.Cg!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultCommentElectricalCharge"),this.Cg=t,this.invalidateLayout())}get prelayoutQuality(){return this.Yf}set prelayoutQuality(t){this.Yf!==t&&(Util.i(t,"number",ForceDirectedLayout,"prelayoutQuality"),this.Yf=t,this.invalidateLayout())}get prelayoutSpread(){return this.Wa}set prelayoutSpread(t){this.Wa!==t&&(Util.i(t,"number",ForceDirectedLayout,"prelayoutSpread"),this.Wa=t,this.invalidateLayout())}}class ForceDirectedNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new ForceDirectedVertex(this)}createEdge(){return new ForceDirectedEdge(this)}}class ForceDirectedVertex extends LayoutVertex{K1;Y1;G1;j1;H1;hierarchicalVertexes;idInCluster;constructor(t){super(t),this.K1=!1,this.Y1=NaN,this.G1=NaN,this.j1=0,this.H1=0,this.hierarchicalVertexes=new List,this.idInCluster=-1}get isFixed(){return this.K1}set isFixed(t){this.K1!==t&&(Util.i(t,"boolean",ForceDirectedVertex,"isFixed"),this.K1=t)}get charge(){return this.Y1}set charge(t){this.Y1!==t&&(Util.i(t,"number",ForceDirectedVertex,"charge"),this.Y1=t)}get mass(){return this.G1}set mass(t){this.G1!==t&&(Util.i(t,"number",ForceDirectedVertex,"mass"),this.G1=t)}get forceX(){return this.j1}set forceX(t){this.j1!==t&&(Util.i(t,"number",ForceDirectedVertex,"forceX"),this.j1=t)}get forceY(){return this.H1}set forceY(t){this.H1!==t&&(Util.i(t,"number",ForceDirectedVertex,"forceY"),this.H1=t)}}class ForceDirectedEdge extends LayoutEdge{q1;W1;constructor(t){super(t),this.q1=NaN,this.W1=NaN}get stiffness(){return this.q1}set stiffness(t){this.q1!==t&&(Util.i(t,"number",ForceDirectedEdge,"stiffness"),this.q1=t)}get length(){return this.W1}set length(t){this.W1!==t&&(Util.i(t,"number",ForceDirectedEdge,"length"),this.W1=t)}}class RandomNumberGenerator{I;R;Q;M;A;seed;constructor(t){t===void 0&&(t=42),this.seed=t,this.A=48271,this.M=2147483647,this.Q=this.M/this.A,this.R=this.M%this.A,this.I=1/this.M,this.random()}random(){const t=this.seed/this.Q,i=this.seed%this.Q,e=this.A*i-this.R*t;return e>0?this.seed=e:this.seed=e+this.M,this.seed*this.I}}var LayeredDigraphCycleRemove=(w=>(w[w.DepthFirst=0]="DepthFirst",w[w.Greedy=1]="Greedy",w[w.FromLayers=2]="FromLayers",w))(LayeredDigraphCycleRemove||{}),LayeredDigraphLayering=(w=>(w[w.OptimalLinkLength=10]="OptimalLinkLength",w[w.LongestPathSink=11]="LongestPathSink",w[w.LongestPathSource=12]="LongestPathSource",w))(LayeredDigraphLayering||{}),LayeredDigraphInit=(w=>(w[w.DepthFirstOut=20]="DepthFirstOut",w[w.DepthFirstIn=21]="DepthFirstIn",w[w.Naive=22]="Naive",w))(LayeredDigraphInit||{}),LayeredDigraphAggressive=(w=>(w[w.None=30]="None",w[w.Less=31]="Less",w[w.More=32]="More",w))(LayeredDigraphAggressive||{}),LayeredDigraphPack=(w=>(w[w.None=0]="None",w[w.Expand=1]="Expand",w[w.Straighten=2]="Straighten",w[w.Median=4]="Median",w[w.MaybeExpand=8]="MaybeExpand",w[w.All=15]="All",w))(LayeredDigraphPack||{}),LayeredDigraphAlign=(w=>(w[w.None=0]="None",w[w.UpperLeft=1]="UpperLeft",w[w.UpperRight=2]="UpperRight",w[w.LowerLeft=4]="LowerLeft",w[w.LowerRight=8]="LowerRight",w[w.All=15]="All",w))(LayeredDigraphAlign||{});class LayeredDigraphLayout extends Layout{Ps;Wi;S;Gf;jf;Hf;Ja;qf;nr;Wf;Fn;Mt;Xy;Kt;Lg;Ms;ui;Qs;Ss;Ns;Bt;Ag;$a;Tg;_s;Jf;or;Rn;vn;EN;constructor(t){super(),this.Ps=25,this.Wi=25,this.S=0,this.Gf=0,this.jf=10,this.Hf=20,this.Ja=4,this.qf=31,this.nr=15,this.Wf=10,this.Fn=!0,this.Mt=-1,this.Xy=-1,this.Kt=-1,this.Lg=0,this.Ms=0,this.ui=null,this.Qs=null,this.Ss=null,this.Ns=null,this.Bt=null,this.Ag=0,this.$a=null,this.Tg=null,this._s=0,this.Jf=null,this.or=new Point,this.Rn=[],this.Rn.length=100,this.vn=15,this.EN=0,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Ps=this.Ps,t.Wi=this.Wi,t.S=this.S,t.Gf=this.Gf,t.jf=this.jf,t.Hf=this.Hf,t.Ja=this.Ja,t.qf=this.qf,t.nr=this.nr,t.Wf=this.Wf,t.Fn=this.Fn,t.vn=this.vn}ri(t){t in LayeredDigraphAggressive?this.aggressiveOption=t:t in LayeredDigraphCycleRemove?this.cycleRemoveOption=t:t in LayeredDigraphInit?this.initializeOption=t:t in LayeredDigraphLayering?this.layeringOption=t:super.ri(t)}createNetwork(){return new LayeredDigraphNetwork(this)}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin),this.GO(),this.network.vertexes.count>0&&(this.network.deleteSelfEdges(),this.cycleRemoveOption!==2&&this.removeCycles(),this.jO(),this.cycleRemoveOption===2&&this.removeCycles(),this.HO(),this.qO(),this.WO(),this.reduceCrossings(),this.straightenAndPack(),this.updateParts()),this.network=null,this.isValidLayout=!0}linkMinLength(t){return 1}linkLengthWeight(t){return 1}linkStraightenWeight(t){const i=t.fromVertex.node||t.fromVertex.data,e=t.toVertex.node||t.toVertex.data;return i===null&&e===null?8:i===null||e===null?4:1}nodeMinLayerSpace(t,i){return t.node===null&&t.data===null?0:this.S===90||this.S===270?i?t.focus.y+10:t.bounds.height-t.focus.y+10:i?t.focus.x+10:t.bounds.width-t.focus.x+10}nodeMinColumnSpace(t,i){if(t.node===null&&t.data===null)return 0;const e=i?t.J1:t.$1;if(e!==null)return e;const s=this.S;return s===90||s===270?i?t.J1=t.focus.x/this.Wi+1|0:t.$1=(t.bounds.width-t.focus.x)/this.Wi+1|0:i?t.J1=t.focus.y/this.Wi+1|0:t.$1=(t.bounds.height-t.focus.y)/this.Wi+1|0}Ji(){this.$a===null&&(this.$a=[]);let t=0;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;this.$a[t]=e.layer,t++,this.$a[t]=e.column,t++,this.$a[t]=e.index,t++}return this.$a}Ze(t){let i=0;const e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;s.layer=t[i],i++,s.column=t[i],i++,s.index=t[i],i++}}JT(t,i){const e=this.Dh(t),s=this.ui[t];(this.Tg===null||this.Tg.length=0){for(c=e[o].po,f=0;fk||d===k&&g>P)&&r++,bd||k===d&&P>g)&&r++)}if(i<=0){for(c=e[o].ir,f=0;fk||d===k&&m>b)&&r++,Pd||k===d&&b>m)&&r++)}for(n[o*s+o]=r,a=o+1;a=0){for(p=e[o].po,M=e[a].po,f=0;f=0&&(h=s[r].ir);let a,c=0,f=0;if(l!==null)for(let u=0;u=0&&(h=r.ir);let a=0,c=0;const f=r.near;f!==null&&f.layer===r.layer&&(a+=f.column-1,c++);let u;if(l!==null)for(let d=0;d=0&&(h=r.ir);let a=0;const c=[],f=r.near;f!==null&&f.layer===r.layer&&(c[a]=f.column-1,a++);let u;if(l!==null)for(let d=0;dm-g);const d=a>>1;a&1?n[o]=c[d]:n[o]=c[d-1]+c[d]>>1}}return this.Fh(t,e),n}Gy(t,i,e,s,n){if(t.component===e){t.component=i;let o=0,r=0;if(s){const l=t.destinationEdges;for(;l.next();){const h=l.value,a=h.toVertex;o=t.layer-a.layer,r=this.linkMinLength(h),o===r&&this.Gy(a,i,e,s,n)}}if(n){const l=t.sourceEdges;for(;l.next();){const h=l.value,a=h.fromVertex;o=a.layer-t.layer,r=this.linkMinLength(h),o===r&&this.Gy(a,i,e,s,n)}}}}UN(t,i,e,s,n){if(t.component===e){if(t.component=i,s){const o=t.destinationEdges;for(;o.next();){const l=o.value.toVertex;this.UN(l,i,e,s,n)}}if(n){const o=t.sourceEdges;for(;o.next();){const l=o.value.fromVertex;this.UN(l,i,e,s,n)}}}}removeCycles(){const t=this.network.edges.iterator;for(;t.next();){const i=t.value;i.rev=!1}switch(this.Gf){default:case 1:this.$O();break;case 0:this.ZO();break;case 2:this.QO();break}}QO(){const t=this.network,i=t.vertexes.iterator;let e=1/0;for(;i.next();){const s=i.value;e=Math.min(e,s.layer)}if(e<1/0){if(e<0)for(i.reset();i.next();){const r=i.value;r.layer-=e}const s=[];for(i.reset();i.next();){const r=i.value,l=s[r.layer];l===void 0?s[r.layer]=[r]:l.push(r)}let n=0;for(let r=0;r0)for(let h=0;hh.index&&(t.reverseEdge(r),r.rev=!0)}}_O(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.$i)return e}return null}ZT(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.$i){let s=!0;const n=e.destinationEdges;for(;n.next();)if(n.value.toVertex.$i){s=!1;break}if(s)return e}}return null}QT(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.$i){let s=!0;const n=e.sourceEdges;for(;n.next();)if(n.value.fromVertex.$i){s=!1;break}if(s)return e}}return null}tI(t){let i=null,e=0;const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;if(n.$i){let o=0;const r=n.destinationEdges;for(;r.next();)r.value.toVertex.$i&&o++;let l=0;const h=n.sourceEdges;for(;h.next();)h.value.fromVertex.$i&&l++;(i===null||ec&&this.Gy(h,e,-1,!0,!1)}for(this.Gy(t,s,-1,!0,!0);t.component!==e;){let r=0,l=1/0,h=0,a=null;const c=this.network.vertexes.iterator;for(;c.next();){const f=c.value;if(f.component===s){let u=0,d=!1;const m=f.po;o=m.length;for(let p=0;p0){for(i.reset();i.next();){const f=i.value;f.component===s&&(f.layer+=l)}t.component=e}else a.component=e}}nI(t){const i=this.network.vertexes.iterator;for(;i.next();){const n=i.value;n.component=-1}const e=0,s=1;for(this.Gy(t,s,-1,!0,!1);t.component!==e;){let n=0,o=1/0,r=0,l=null;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value;if(a.component===s){let c=0,f=!1;const u=a.po;let d=u.length;for(let g=0;gr)&&!f&&(l=a,r=c)}}if(n<0){for(i.reset();i.next();){const a=i.value;a.component===s&&(a.layer-=o)}t.component=e}else l.component=e}}HO(){const t=this.network,i=[],e=t.edges.iterator;for(;e.next();){const s=e.value;s.valid=!1,i.push(s)}for(let s=0;sb&&f>0){for(n.valid=!1,y=t.createVertex(),y.node=null,y.Q1=2,y.layer=f-1,x&&kb&&f>0;)y=t.createVertex(),y.node=null,y.Q1=3,y.layer=f-1,x&&kt[this.Ms]&&(this.Xy=t[e]-1,this.Ms=e),t[e]{o.index=this.ui[s],this.ui[s]++})}}hI(){let t=null;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;if(e.near&&(t===null&&(t=new Map),e.layer===e.near.layer)){const s=t.get(e.near)||[];s.push(e),t.set(e.near,s)}}for(let e=this.Mt;e>=0;e--)for(i.reset();i.next();){const s=i.value;s.layer===e&&s.index===-1&&this.oD(s,t)}}oD(t,i){if(t.near)return;const e=t.layer;if(t.index=this.ui[e],this.ui[e]++,i){const o=i.get(t);Array.isArray(o)&&o.forEach(r=>{r.index=this.ui[e],this.ui[e]++})}const s=t.ir;let n=!0;for(;n;){n=!1;for(let o=0;ol.portFromColOffset&&(n=!0,s[o]=l,s[o+1]=r)}}for(let o=0;o{a.index=this.ui[e],this.ui[e]++})}const s=t.po;let n=!0,o=0;for(;n;)for(n=!1,o=0;oa.portToColOffset&&(n=!0,s[o]=a,s[o+1]=h)}let r,l;for(o=0;o=0;s--)this.tk(s,-1),this.ls(s,-1,!1,-1);n=this.countCrossings(),n=0;s--)this.tk(s,0),this.ls(s,0,!1,0);n=this.countCrossings(),n=0;r--)for(l=0;l<=r;l++){for(o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,1,!1,1)||o;for(n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,-1,!1,-1)||o;for(n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,0,!1,0)||o;for(n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,0,!1,0)||o;n>=t?this.Ze(i):(t=n,i=this.Ji())}break;default:case 31:for(r=this.Mt,l=0,h=t+1;(a=this.countCrossings())=l;s--)o=this.ls(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,1,!1,1)||o;for(n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,-1,!1,-1)||o;for(n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,0,!1,0)||o;for(n>=t?this.Ze(i):(t=n,i=this.Ji()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,0,!1,0)||o;n>=t?this.Ze(i):(t=n,i=this.Ji())}break}this.Ze(i)}tk(t,i){let e=0,s=!1;const n=this.Dh(t),o=this.ui[t],r=this.$T(t,i),l=this.Yy(t,i);for(e=0;e0)for(h=[],l=0;ll+1&&(m+=4*(v-l),g+=4*(v-(l+1)))}}const E=n[l].destinationEdges.iterator;if(e&&s>=0)for(;E.next();){const q=E.value;O=q.toVertex,q.valid&&O.layer!==t&&(N=this.linkStraightenWeight(q),T=q.portFromColOffset,A=q.portToColOffset,F=O.column,C+=(Math.abs(p+T-(F+A))+1)*N,S+=(Math.abs(L+T-(F+A))+1)*N)}for(E.reset();E.next();){const q=E.value;if(O=q.toVertex,q.valid&&O.layer===t){for(U=0;Ul+1&&(m+=4*(v-(l+1)),g+=4*(v-l))}}const B=n[l+1].destinationEdges.iterator;if(e&&s>=0)for(;B.next();){const q=B.value;O=q.toVertex,q.valid&&O.layer!==t&&(N=this.linkStraightenWeight(q),T=q.portFromColOffset,A=q.portToColOffset,F=O.column,C+=(Math.abs(y+T-(F+A))+1)*N,S+=(Math.abs(M+T-(F+A))+1)*N)}for(B.reset();B.next();){const q=B.value;if(O=q.toVertex,q.valid&&O.layer===t){for(U=0;U1e3&&s&&(e=!1),e){const n=[];let o=0;for(o=0;o<=this.Mt;o++)n[o]=0;let r=0;const l=this.network.vertexes.iterator;for(;l.next();){const a=l.value;t=a.layer,r=a.column;const c=this.nodeMinColumnSpace(a,!1);n[t]=Math.max(n[t],r+c)}const h=8;for(l.reset();l.next();){const a=l.value;t=a.layer,r=a.column,a.column=((this.Kt-n[t])*h>>1)+r*h}this.Kt*=h}if(this.nr&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Dg(t,-1)||i;i=this.Dg(this.Ms,0)||i,n++}}if(this.nr&4){for(t=this.Ms+1;t<=this.Mt;t++)this.VN(t,1);for(t=this.Ms-1;t>=0;t--)this.VN(t,-1);this.VN(this.Ms,0)}if(e&&(this.lD(-1),this.lD(1)),this.nr&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Dg(t,0)||i;n++}}}Dg(t,i){let e=!1;for(;this.fI(t,i);)e=!0;return e}fI(t,i){let e=0;const s=this.Dh(t),n=this.ui[t],o=this.Yy(t,-1);if(i>0)for(e=0;ec+this.nodeMinColumnSpace(s[e-1],!1)?u=a-1:u=a;let d=0;e+1>=n||s[e+1].column-a-1>f+this.nodeMinColumnSpace(s[e+1],!0)?d=a+1:d=a;let m=0,g=0,p=0,y=0,x=0,k=0;if(i<=0){const S=s[e].sourceEdges.iterator;for(;S.next();){const N=S.value,T=N.fromVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const A=T.column;m+=(Math.abs(a+k-(A+x))+1)*y,g+=(Math.abs(u+k-(A+x))+1)*y,p+=(Math.abs(d+k-(A+x))+1)*y}}}if(i>=0){const S=s[e].destinationEdges.iterator;for(;S.next();){const N=S.value,T=N.toVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const A=T.column;m+=(Math.abs(a+x-(A+k))+1)*y,g+=(Math.abs(u+x-(A+k))+1)*y,p+=(Math.abs(d+x-(A+k))+1)*y}}}let b=0,P=0,M=0;const L=o[s[e].index],C=r[s[e].index];L!==-1&&(b+=Math.abs(L-a),P+=Math.abs(L-u),M+=Math.abs(L-d)),C!==-1&&(b+=Math.abs(C-a),P+=Math.abs(C-u),M+=Math.abs(C-d)),g=r[e]?u=p:g<=r[e]&&(u=g)),u!==a&&(l=!0,h=!0,s[e].column=u)}return this.Fh(t,s),this.Ky(),l}uI(){for(let t=0;t<=this.Kt;t++)for(;this.dI(t,1););this.Ky()}dI(t,i){let e=!0;const s=this.network.vertexes.iterator;for(;s.next();){const o=s.value,r=this.nodeMinColumnSpace(o,!0),l=this.nodeMinColumnSpace(o,!1);if(o.column-r<=t&&o.column+l>=t){e=!1;break}}let n=!1;if(e){if(i>0)for(s.reset();s.next();){const o=s.value;o.column>t&&(o.column-=1,n=!0)}if(i<0)for(s.reset();s.next();){const o=s.value;o.column0&&(e=t+1),i<0&&(e=t-1);let s=0;const n=[],o=[];for(s=0;s<=this.Mt;s++)n[s]=!1,o[s]=!1;const r=this.network.vertexes.iterator;for(;r.next();){const a=r.value,c=a.column-this.nodeMinColumnSpace(a,!0),f=a.column+this.nodeMinColumnSpace(a,!1);c<=t&&f>=t&&(n[a.layer]=!0),c<=e&&f>=e&&(o[a.layer]=!0)}let l=!0,h=!1;for(s=0;s<=this.Mt;s++)l=l&&!(n[s]&&o[s]);if(l){if(i>0)for(r.reset();r.next();){const a=r.value;a.column>t&&(a.column-=1,h=!0)}if(i<0)for(r.reset();r.next();){const a=r.value;a.column0)for(i=0;i<=this.Kt;i++)for(e=this.Ji(),s=this.Z1(!0),n=s+1;ss?this.Ze(e):o=0;i--)for(e=this.Ji(),s=this.Z1(!0),n=s+1;ss?this.Ze(e):o0)for(e.reset();e.next();){const c=e.value;c.column-this.nodeMinColumnSpace(c,!0)<=t&&(c.component=this._s)}if(i<0)for(e.reset();e.next();){const c=e.value;c.column+this.nodeMinColumnSpace(c,!1)>=t&&(c.component=this._s)}for(this._s++,e.reset();e.next();){const c=e.value;c.component===-1&&(this.UN(c,this._s,-1,!0,!0),this._s++)}let s=0;const n=[];for(s=0;s0)for(let f=0;f0;f--)o[c*(this.Kt+1)+f]!==-1&&o[c*(this.Kt+1)+f-1]!==-1&&o[c*(this.Kt+1)+f]!==o[c*(this.Kt+1)+f-1]&&(n[o[c*(this.Kt+1)+f]*this._s+o[c*(this.Kt+1)+f-1]]=!0)}const r=[];for(s=0;s0)for(e.reset();e.next();){const c=e.value;r[c.component]&&(c.column-=1,a=!0)}if(i<0)for(e.reset();e.next();){const c=e.value;r[c.component]&&(c.column+=1,a=!0)}return a}cI(){const t=Util.ot(),i=this.Jf.length;for(let u=0;u<=i;u++)t[u]=[];const e=this.network.vertexes.iterator;for(;e.next();){const u=e.value,d=i-u.layer,m=t[d];m[u.index]=u}const s=new GSet;this.pI(t,s);let n=null,o=null,r=null,l=null;const h=(this.vn&1)!==0,a=(this.vn&2)!==0,c=(this.vn&4)!==0,f=(this.vn&8)!==0;h&&(this.sl(t,s,!0),n=this.ik(t,!0,!1)),t.reverse(),c&&(this.sl(t,s,!1),r=this.ik(t,!1,!1));for(const u of t)u.reverse();f&&(this.sl(t,s,!1),l=this.ik(t,!1,!0)),t.reverse(),a&&(this.sl(t,s,!0),o=this.ik(t,!0,!0)),Util.tt(t),this.yI(n,o,r,l),this.network.vertexes.each(u=>{const d=u,m=Util.ot();h&&m.push(n.get(d)),a&&m.push(o.get(d)),c&&m.push(r.get(d)),f&&m.push(l.get(d)),m.sort((k,b)=>k-b);const g=m.length,p=Math.floor((g-1)/2),y=Math.ceil((g-1)/2),x=(m[p]+m[y])/2;Util.tt(m),d.le=x})}pI(t,i){const e=t.length;for(let s=1;sf)&&i.add(m)}o++}n=f}}}}wI(t){if(t.node===null){const i=t.getProperSourceVertexes();if(i.length>0)return i[0].node===null}return!1}sl(t,i,e){this.xI(t);for(const s of t){let n=-1;for(const o of s){const r=e?o.getProperSourceVertexes():o.getProperDestinationVertexes(),l=r.length;if(l>0){r.sort((a,c)=>a.Rh-c.Rh);const h=(l-1)/2;for(let a=Math.floor(h),c=Math.ceil(h);a<=c;a++)if(o.On===o){const f=r[a];let u;e?u=f.getDestinationEdge(o):u=o.getDestinationEdge(f),!i.has(u)&&n0){const c=this.fD(a,t),f=s?c.width:c.height,u=a.Qe.Zf+a.le+a.In-(c.le+c.In+f+this.columnSpacing);c.Qe.Zf=Math.min(c.Qe.Zf,u)}h=a.Rh+1}while(l0){const s=this.fD(e,i),n=s.Za;this.cD(n,i),t.Qe===t&&(t.Qe=n.Qe);const o=this.S===90||this.S===270?s.width:s.height;if(t.Qe===n.Qe){const r=n.le+s.In+o-e.In+this.columnSpacing;t.le=Math.max(t.le,r)}}e=e.On}while(e!==t);for(;e.On!==t;)e=e.On,e.le=t.le,e.Qe=t.Qe}fD(t,i){const e=t.aD,s=t.Rh;return s<1&&Util.o("Could not determine previous vertex in layer"),i[e][s-1]}yI(...t){let i=-1;const e=Util.ot(),s=Util.ot();let n=1/0;for(let o=0;o<4;o++){if(!t[o])continue;const r=this.kI(t[o],e,s,o);r{r.set(h.key,h.value+l)})}Util.tt(e),Util.tt(s)}kI(t,i,e,s){if(!t||t.count===0)return i[s]=0,e[s]=0,1/0;let n=1/0,o=-1/0;return t.each(r=>{const l=r.key,h=r.value,a=this.S===90||this.S===270?l.width:l.height;ho&&(o=h+a)}),i[s]=n,e[s]=o,o-n}commitLayout(){this.zy(),this.commitNodes(),this.zN(),this.isRouting&&this.commitLinks()}zy(){if(!this.setsPortSpots)return;const t=this._1(!0),i=this._1(!1),e=this.network.edges.iterator;for(;e.next();){const n=e.value.link;n!==null&&(n.fromSpot=t,n.toSpot=i)}}_1(t){return this.S===270?t?Spot.MiddleTop:Spot.MiddleBottom:this.S===90?t?Spot.MiddleBottom:Spot.MiddleTop:this.S===180?t?Spot.MiddleLeft:Spot.MiddleRight:t?Spot.MiddleRight:Spot.MiddleLeft}commitNodes(){this.Qs=[],this.Ss=[],this.Ns=[],this.Bt=[];for(let d=0;d<=this.Mt;d++)this.Qs[d]=0,this.Ss[d]=0,this.Ns[d]=0,this.Bt[d]=0;const t=this.network.vertexes.iterator;for(;t.next();){const d=t.value,m=d.layer;this.Qs[m]=Math.max(this.Qs[m],this.nodeMinLayerSpace(d,!0)),this.Ss[m]=Math.max(this.Ss[m],this.nodeMinLayerSpace(d,!1))}let i=0;const e=this.Ps;for(let d=0;d<=this.Mt;d++){let m=e;this.Qs[d]+this.Ss[d]<=0&&(m=0),d>0&&(i+=m/2),this.S===90||this.S===0?(i+=this.Ss[d],this.Ns[d]=i,i+=this.Qs[d]):(i+=this.Qs[d],this.Ns[d]=i,i+=this.Ss[d]),d=0;n--)this.S===270?n===0?e.push(new Rect(0,0,s,Math.abs(this.Bt[0]))):e.push(new Rect(0,this.Bt[n-1],s,Math.abs(this.Bt[n-1]-this.Bt[n]))):this.S===90?n===0?e.push(new Rect(0,this.Bt[0],s,Math.abs(this.Bt[0]-t))):e.push(new Rect(0,this.Bt[n],s,Math.abs(this.Bt[n-1]-this.Bt[n]))):this.S===180?n===0?e.push(new Rect(0,0,Math.abs(this.Bt[0]),s)):e.push(new Rect(this.Bt[n-1],0,Math.abs(this.Bt[n-1]-this.Bt[n]),s)):n===0?e.push(new Rect(this.Bt[0],0,Math.abs(this.Bt[0]-t),s)):e.push(new Rect(this.Bt[n],0,Math.abs(this.Bt[n-1]-this.Bt[n]),s));this.commitLayers(e,this.or)}commitLayers(t,i){}commitLinks(){const t=this.network.edges.iterator;let i;for(;t.next();)i=t.value.link,i!==null&&(i.startRoute(),i.clearPoints(),i.commitRoute());for(t.reset();t.next();)i=t.value.link,i!==null&&i.updateRoute();for(t.reset();t.next();){const e=t.value;if(i=e.link,i===null||i.pointsCount===0)continue;i.startRoute();const s=i;let n=s.fromNode,o=s.toNode,r=s.fromPort,l=s.toPort;if(n!==null){const N=n.findVisibleNode();N!==null&&N!==n&&(n=N,r=N.port)}if(o!==null){const N=o.findVisibleNode();N!==null&&N!==o&&(o=N,l=N.port)}const h=i.computeSpot(!0,r),a=i.computeSpot(!1,l);let c=e.fromVertex,f=e.toVertex;if(e.valid){if(i.curve===9&&i.pointsCount===4)if(c.column===f.column&&this.alignOption===0){const N=i.getLinkPoint(n,r,h,!0,!1,o,l),T=i.getLinkPoint(o,l,a,!1,!1,n,r);N.isReal()||N.set(n.actualBounds.center),T.isReal()||T.set(o.actualBounds.center),i.clearPoints(),i.addPointAt(N.x,N.y),i.addPointAt((2*N.x+T.x)/3,(2*N.y+T.y)/3),i.addPointAt((N.x+2*T.x)/3,(N.y+2*T.y)/3),i.addPointAt(T.x,T.y)}else{let N=!1,T=!1;if(r!==null&&h===Spot.None&&(N=!0),l!==null&&a===Spot.None&&(T=!0),N||T){let A=null;N&&(A=i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0),A.isReal()||A.set(n.actualBounds.center),i.setPointAt(0,A.x,A.y));let D=null;if(T&&(D=i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(0),!1),D.isReal()||D.set(o.actualBounds.center),i.setPointAt(3,D.x,D.y)),A){const F=i.getPoint(2);i.setPointAt(1,(A.x*2+F.x)/3,(A.y*2+F.y)/3)}if(D){const F=i.getPoint(1);i.setPointAt(2,(D.x*2+F.x)/3,(D.y*2+F.y)/3)}}}i.commitRoute();continue}if(c.layer===f.layer){i.commitRoute();continue}let u=!1,d=!1;const m=this.Ps;let g=0,p=i.firstPickIndex+1;if(i.isOrthogonal)d=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3);else if(i.curve===9)u=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3),g===4&&(p=2);else{g=i.pointsCount;const N=h===Spot.None,T=a===Spot.None;g>2&&N&&T?i.points.removeRange(1,g-2):g>3&&N&&!T?i.points.removeRange(1,g-3):g>3&&!N&&T?i.points.removeRange(2,g-2):g>4&&!N&&!T&&i.points.removeRange(2,g-3)}let y,x,k=0,b=0,P=0,M=0,L=0,C=0,S=0;if(e.rev){let N=0;for(;f!==null&&c!==f;){y=null,x=null;const T=f.sourceEdges.iterator;for(;T.next();){const A=T.value;if(A.link===e.link&&(y=A.fromVertex,x=A.toVertex,y.node===null))break}if(y===null)break;if(y!==c)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=y.centerX,M=y.centerY,d)this.S===180||this.S===0?p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,k,M)):(x!==null?x.centerY:b)!==M&&(L=this.Bt[y.layer-1]+this.or.x,i.insertPointAt(p++,L,b),i.insertPointAt(p++,L,M)):p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,P,b)):(x!==null?x.centerX:k)!==P&&(L=this.Bt[y.layer-1]+this.or.y,i.insertPointAt(p++,k,L),i.insertPointAt(p++,P,L));else if(p===i.firstPickIndex+1)if(C=Math.max(10,this.Qs[f.layer]),S=Math.max(10,this.Ss[f.layer]),u)this.S===180?P<=f.bounds.x?(N=f.bounds.x,i.insertPointAt(p++,N-C,M),i.insertPointAt(p++,N,M),i.insertPointAt(p++,N+S,M)):(i.insertPointAt(p++,P-C,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P+S,M)):this.S===90?M>=f.bounds.bottom?(N=f.bounds.y+f.bounds.height,i.insertPointAt(p++,P,N+S),i.insertPointAt(p++,P,N),i.insertPointAt(p++,P,N-C)):(i.insertPointAt(p++,P,M+S),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M-C)):this.S===270?M<=f.bounds.y?(N=f.bounds.y,i.insertPointAt(p++,P,N-C),i.insertPointAt(p++,P,N),i.insertPointAt(p++,P,N+S)):(i.insertPointAt(p++,P,M-C),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M+S)):this.S===0&&(P>=f.bounds.right?(N=f.bounds.x+f.bounds.width,i.insertPointAt(p++,N+S,M),i.insertPointAt(p++,N,M),i.insertPointAt(p++,N-C,M)):(i.insertPointAt(p++,P+S,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P-C,M)));else{i.insertPointAt(p++,k,b);let A=0;this.S===180||this.S===0?((this.S===180?P>=f.bounds.right:P<=f.bounds.x)&&(A=(this.S===0?-C:S)/2),i.insertPointAt(p++,k+A,M)):((this.S===270?M>=f.bounds.bottom:M<=f.bounds.y)&&(A=(this.S===90?-C:S)/2),i.insertPointAt(p++,P,b+A)),i.insertPointAt(p++,P,M)}else C=Math.max(10,this.Qs[y.layer]),S=Math.max(10,this.Ss[y.layer]),u?this.S===180?(i.insertPointAt(p++,P-C-m,M),i.insertPointAt(p++,Math.min(P-C+m/2,P),M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,Math.max(P+S-m/2,P),M),i.insertPointAt(p++,P+S+m,M)):this.S===90?(i.insertPointAt(p++,P,M+S+m),i.insertPointAt(p++,P,Math.max(M+S-m/2,M)),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,Math.min(M-C+m/2,M)),i.insertPointAt(p++,P,M-C-m)):this.S===270?(i.insertPointAt(p++,P,M-C-m),i.insertPointAt(p++,P,Math.min(M-C+m/2,M)),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,Math.max(M+S-m/2,M)),i.insertPointAt(p++,P,M+S+m)):(i.insertPointAt(p++,P+S+m,M),i.insertPointAt(p++,Math.max(P+S-m/2,P),M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,Math.min(P-C+m/2,P),M),i.insertPointAt(p++,P-C-m,M)):(this.S===180||this.S===90||this.S,i.insertPointAt(p++,P,M));f=y}if(l===null||h!==Spot.None||d)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=i.getPoint(p).x,M=i.getPoint(p).y,d){const T=this.Ss[c.layer];let A=0;this.S===180||this.S===0?(A=b,A>=c.bounds.y&&A<=c.bounds.bottom&&(this.S===180?P>=c.bounds.x:P<=c.bounds.right)&&(N=c.centerX+(this.S===180?-T:T),A=c.bounds.x&&A<=c.bounds.right&&(this.S===270?M>=c.bounds.y:M<=c.bounds.bottom)&&(N=c.centerY+(this.S===270?-T:T),A=c.bounds.x?(N=c.bounds.x+c.bounds.width,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N+S,b)):this.S===90&&M<=c.bounds.bottom?(N=c.bounds.y,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N-C)):this.S===270&&M>=c.bounds.y?(N=c.bounds.y+c.bounds.height,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N+S)):this.S===0&&P<=c.bounds.right&&(N=c.bounds.x,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N-C,b));else{C=Math.max(10,this.Qs[c.layer]),S=Math.max(10,this.Ss[c.layer]);let T=0;this.S===180||this.S===0?((this.S===180?P<=c.bounds.x:P>=c.bounds.right)&&(T=(this.S===0?S:-C)/2),i.insertPointAt(p++,P+T,b)):((this.S===270?M<=c.bounds.y:M>=c.bounds.bottom)&&(T=(this.S===90?S:-C)/2),i.insertPointAt(p++,k,M+T)),i.insertPointAt(p++,P,M)}}else{for(;c!==null&&c!==f;){y=null,x=null;const N=c.destinationEdges.iterator;for(;N.next();){const T=N.value;if(T.link===e.link&&(y=T.toVertex,x=T.fromVertex,x.node!==null&&(x=null),y.node===null))break}if(y===null)break;y!==f&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=y.centerX,M=y.centerY,d?this.S===180||this.S===0?(x!==null?x.centerY:b)!==M&&(L=this.Bt[y.layer]+this.or.x,p===i.firstPickIndex+1&&(this.S===0?L=Math.max(L,k):L=Math.min(L,k)),i.insertPointAt(p++,L,b),i.insertPointAt(p++,L,M)):(x!==null?x.centerX:k)!==P&&(L=this.Bt[y.layer]+this.or.y,p===i.firstPickIndex+1&&(this.S===90?L=Math.max(L,b):L=Math.min(L,b)),i.insertPointAt(p++,k,L),i.insertPointAt(p++,P,L)):(C=Math.max(10,this.Qs[y.layer]),S=Math.max(10,this.Ss[y.layer]),u?this.S===180?(i.insertPointAt(p++,P+S+m,M),i.insertPointAt(p++,Math.max(P+S-m/2,P),M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,Math.min(P-C+m/2,P),M),i.insertPointAt(p++,P-C-m,M)):this.S===90?(i.insertPointAt(p++,P,M-C-m),i.insertPointAt(p++,P,Math.min(M-C+m/2,M)),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,Math.max(M+S-m/2,M)),i.insertPointAt(p++,P,M+S+m)):this.S===270?(i.insertPointAt(p++,P,M+S+m),i.insertPointAt(p++,P,Math.max(M+S-m/2,M)),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,Math.min(M-C+m/2,M)),i.insertPointAt(p++,P,M-C-m)):(i.insertPointAt(p++,P-C-m,M),i.insertPointAt(p++,Math.min(P-C+m/2,P),M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,P,M),i.insertPointAt(p++,Math.max(P+S-m/2,P),M),i.insertPointAt(p++,P+S+m,M)):this.S===180?(i.insertPointAt(p++,P+S,M),i.insertPointAt(p++,P-C,M)):this.S===90?(i.insertPointAt(p++,P,M-C),i.insertPointAt(p++,P,M+S)):this.S===270?(i.insertPointAt(p++,P,M+S),i.insertPointAt(p++,P,M-C)):(i.insertPointAt(p++,P-C,M),i.insertPointAt(p++,P+S,M)))),c=y}d&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=i.getPoint(p).x,M=i.getPoint(p).y,this.S===180||this.S===0?b!==M&&(this.S===0?L=Math.min(Math.max((P+k)/2,this.Bt[f.layer]+this.or.x),P):L=Math.max(Math.min((P+k)/2,this.Bt[f.layer]+this.or.x),P),i.insertPointAt(p++,L,b),i.insertPointAt(p++,L,M)):k!==P&&(this.S===90?L=Math.min(Math.max((M+b)/2,this.Bt[f.layer]+this.or.y),M):L=Math.max(Math.min((M+b)/2,this.Bt[f.layer]+this.or.y),M),i.insertPointAt(p++,k,L),i.insertPointAt(p++,P,L)))}if(s!==null&&u&&i.pointsCount>=4){if(r!==null){const N=h===Spot.None?i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0):i.getPoint(0);if(h===Spot.None){const T=i.getPoint(2),A=i.getPoint(3);this.direction===90||this.direction===270?(i.setPointAt(1,(N.x+T.x)/2,T.y),i.setPointAt(2,A.x,(T.y+A.y)/2)):(i.setPointAt(1,T.x,(N.y+T.y)/2),i.setPointAt(2,(T.x+A.x)/2,A.y))}N.isReal()||N.set(n.actualBounds.center),i.setPointAt(0,N.x,N.y)}if(l!==null){const N=a===Spot.None?i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(i.pointsCount-4),!1):i.getPoint(i.pointsCount-1);if(a===Spot.None){const T=i.getPoint(i.pointsCount-3),A=i.getPoint(i.pointsCount-4);this.direction===90||this.direction===270?(i.setPointAt(i.pointsCount-2,(N.x+T.x)/2,T.y),i.setPointAt(i.pointsCount-2,A.x,(T.y+A.y)/2)):(i.setPointAt(i.pointsCount-2,T.x,(N.y+T.y)/2),i.setPointAt(i.pointsCount-3,(T.x+A.x)/2,A.y))}N.isReal()||N.set(o.actualBounds.center),i.setPointAt(i.pointsCount-1,N.x,N.y)}}i.commitRoute(),e.commit()}}GO(){this.Xy=-1,this.Lg=0,this.Ms=0,this.$a=null,this.Tg=null,this.Jf=null;for(let t=0;t=this.Rn.length){const n=[];for(let o=0;o=0&&(this.Ps=t,this.invalidateLayout()))}get columnSpacing(){return this.Wi}set columnSpacing(t){this.Wi!==t&&(Util.i(t,"number",LayeredDigraphLayout,"columnSpacing"),t>0&&(this.Wi=t,this.invalidateLayout()))}get direction(){return this.S}set direction(t){this.S!==t&&(Util.i(t,"number",LayeredDigraphLayout,"direction"),t===0||t===90||t===180||t===270?(this.S=t,this.invalidateLayout()):Util.o("LayeredDigraphLayout.direction must be 0, 90, 180, or 270"))}get cycleRemoveOption(){return this.Gf}set cycleRemoveOption(t){this.Gf!==t&&(t===1||t===0||t===2)&&(this.Gf=t,this.invalidateLayout())}get layeringOption(){return this.jf}set layeringOption(t){this.jf!==t&&(t===10||t===11||t===12)&&(this.jf=t,this.invalidateLayout())}get initializeOption(){return this.Hf}set initializeOption(t){this.Hf!==t&&(t===20||t===21||t===22)&&(this.Hf=t,this.invalidateLayout())}get iterations(){return this.Ja}set iterations(t){this.Ja!==t&&t>=0&&(this.Ja=t,this.invalidateLayout())}get aggressiveOption(){return this.qf}set aggressiveOption(t){this.qf!==t&&(t===30||t===31||t===32)&&(this.qf=t,this.invalidateLayout())}get packOption(){return this.nr}set packOption(t){this.nr!==t&&(Util.i(t,"number",LayeredDigraphLayout,"packOption"),t>=0&&t<8&&(this.nr=t,this.invalidateLayout()))}get packIterations(){return this.Wf}set packIterations(t){this.Wf=t}get alignOption(){return this.vn}set alignOption(t){this.vn!==t&&(Util.i(t,"number",LayeredDigraphLayout,"align"),t>=0&&t<16&&(this.vn=t,this.invalidateLayout()))}get setsPortSpots(){return this.Fn}set setsPortSpots(t){this.Fn!==t&&(Util.i(t,"boolean",LayeredDigraphLayout,"setsPortSpots"),this.Fn=t,this.invalidateLayout())}get maxLayer(){return this.Mt}get maxIndex(){return this.Xy}get maxColumn(){return this.Kt}get minIndexLayer(){return this.Lg}get maxIndexLayer(){return this.Ms}static CycleDepthFirst=0;static CycleGreedy=1;static CycleFromLayers=2;static LayerOptimalLinkLength=10;static LayerLongestPathSink=11;static LayerLongestPathSource=12;static InitDepthFirstOut=20;static InitDepthFirstIn=21;static InitNaive=22;static AggressiveNone=30;static AggressiveLess=31;static AggressiveMore=32;static PackNone=0;static PackExpand=1;static PackStraighten=2;static PackMedian=4;static PackAll=15;static AlignNone=0;static AlignUpperLeft=1;static AlignUpperRight=2;static AlignLowerLeft=4;static AlignLowerRight=8;static AlignAll=15}class LayeredDigraphNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new LayeredDigraphVertex(this)}createEdge(){return new LayeredDigraphEdge(this)}}class LayeredDigraphVertex extends LayoutVertex{Wo;Bo;Dt;ek;sk;$i;$f;jn;Q1;J1;$1;Za;On;aD;Rh;Qe;Zf;le;In;jy=null;Hy=null;qy=null;Wy=null;constructor(t){super(t),this.Wo=-1,this.Bo=-1,this.Dt=-1,this.ek=NaN,this.sk=null,this.$i=!1,this.$f=NaN,this.jn=NaN,this.Q1=0,this.J1=null,this.$1=null}static uD(t,i){return t.index-i.index}getProperSourceEdges(){if(!this.qy){const t=[];for(const i of this.po){const e=i;e.valid&&t.push(e)}this.qy=t}return this.qy}getProperDestinationEdges(){if(!this.Wy){const t=[];for(const i of this.ir){const e=i;e.valid&&t.push(e)}this.Wy=t}return this.Wy}getDestinationEdge(t){const i=this.getProperDestinationEdges();for(const e of i)if(e.toVertex===t)return e;Util.o("Unable to find destination edge to given vertex")}getProperSourceVertexes(){if(!this.jy){const t=[];for(const i of this.po){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.fromVertex)}t.sort(LayeredDigraphVertex.uD),this.jy=t}return this.jy}getProperDestinationVertexes(){if(!this.Hy){const t=[];for(const i of this.ir){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.toVertex)}t.sort(LayeredDigraphVertex.uD),this.Hy=t}return this.Hy}addSourceEdge(t){super.addSourceEdge(t),this.jy=null,this.qy=null}deleteSourceEdge(t){super.deleteSourceEdge(t),this.jy=null,this.qy=null}addDestinationEdge(t){super.addDestinationEdge(t),this.Hy=null,this.Wy=null}deleteDestinationEdge(t){super.deleteDestinationEdge(t),this.Hy=null,this.Wy=null}get layer(){return this.Wo}set layer(t){this.Wo!==t&&(Util.i(t,"number",LayeredDigraphVertex,"layer"),this.Wo=t)}get column(){return this.Bo}set column(t){this.Bo!==t&&(Util.i(t,"number",LayeredDigraphVertex,"column"),this.Bo=t)}get index(){return this.Dt}set index(t){this.Dt!==t&&(Util.i(t,"number",LayeredDigraphVertex,"index"),this.Dt=t)}get component(){return this.ek}set component(t){this.ek!==t&&(Util.i(t,"number",LayeredDigraphVertex,"component"),this.ek=t)}get near(){return this.sk}set near(t){this.sk!==t&&(this.sk=t)}}class LayeredDigraphEdge extends LayoutEdge{$i;nk;ok;rk;lk;hk;ak;constructor(t){super(t),this.$i=!1,this.nk=!1,this.ok=!1,this.rk=NaN,this.lk=NaN,this.hk=0,this.ak=0}get fromVertex(){return this.We}set fromVertex(t){this.We!==t&&(this.We=t)}get toVertex(){return this.Je}set toVertex(t){this.Je!==t&&(this.Je=t)}get valid(){return this.$i}set valid(t){this.$i!==t&&(Util.i(t,"boolean",LayeredDigraphEdge,"valid"),this.$i=t)}get rev(){return this.nk}set rev(t){this.nk!==t&&(Util.i(t,"boolean",LayeredDigraphEdge,"rev"),this.nk=t)}get forest(){return this.ok}set forest(t){this.ok!==t&&(Util.i(t,"boolean",LayeredDigraphEdge,"forest"),this.ok=t)}get portFromPos(){return this.rk}set portFromPos(t){this.rk!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portFromPos"),this.rk=t)}get portToPos(){return this.lk}set portToPos(t){this.lk!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portToPos"),this.lk=t)}get portFromColOffset(){return this.hk}set portFromColOffset(t){this.hk!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portFromColOffset"),this.hk=t)}get portToColOffset(){return this.ak}set portToColOffset(t){this.ak!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portToColOffset"),this.ak=t)}}var TreePath=(w=>(w[w.Default=0]="Default",w[w.Destination=1]="Destination",w[w.Source=2]="Source",w))(TreePath||{}),TreeSorting=(w=>(w[w.Forwards=10]="Forwards",w[w.Reverse=11]="Reverse",w[w.Ascending=12]="Ascending",w[w.Descending=13]="Descending",w))(TreeSorting||{}),TreeAlignment=(w=>(w[w.CenterSubtrees=20]="CenterSubtrees",w[w.CenterChildren=21]="CenterChildren",w[w.Start=22]="Start",w[w.End=23]="End",w[w.Bus=24]="Bus",w[w.BusBranching=25]="BusBranching",w[w.TopLeftBus=26]="TopLeftBus",w[w.BottomRightBus=27]="BottomRightBus",w[w.Custom=28]="Custom",w))(TreeAlignment||{}),TreeCompaction=(w=>(w[w.None=30]="None",w[w.Block=31]="Block",w))(TreeCompaction||{}),TreeStyle=(w=>(w[w.Layered=40]="Layered",w[w.LastParents=41]="LastParents",w[w.Alternating=42]="Alternating",w[w.RootOnly=43]="RootOnly",w))(TreeStyle||{}),TreeArrangement=(w=>(w[w.Vertical=50]="Vertical",w[w.Horizontal=51]="Horizontal",w[w.FixedRoots=52]="FixedRoots",w))(TreeArrangement||{}),TreeLayerStyle=(w=>(w[w.Individual=60]="Individual",w[w.Siblings=61]="Siblings",w[w.Uniform=62]="Uniform",w))(TreeLayerStyle||{});class TreeLayout extends Layout{Fi;Ti;Qf;Fg;XN;Re;zi;ks;V;z;ck;hs;constructor(t){super(),this.Fi=new GSet,this.Ti=0,this.hs=1,this.Qf=40,this.Fg=60,this.XN=[],this.Re=!0,this.zi=50,this.ks=new Size(10,10).g();const i=new TreeNetwork(this);this.V=new TreeVertex(i),this.z=new TreeVertex(i),this.ck=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Ti=this.Ti,t.Qf=this.Qf,t.Fg=this.Fg,t.Re=this.Re,t.zi=this.zi,t.ks.a(this.ks),t.V.copyInheritedPropertiesFrom(this.V),t.z.copyInheritedPropertiesFrom(this.z)}ri(t){t in TreeAlignment?this.alignment=t:t in TreeArrangement?this.arrangement=t:t in TreeCompaction?this.compaction=t:t in TreePath?this.path=t:t in TreeSorting?this.sorting=t:t in TreeStyle?this.treeStyle=t:super.ri(t)}createNetwork(){return new TreeNetwork(this)}makeNetwork(t){const i=this.createNetwork(),e=s=>{if(s instanceof Node)return!s.isLinkLabel&&s.category!=="Comment";if(s instanceof Link){const n=s.fromNode;if(n===null||n.isLinkLabel||n.category==="Comment")return!1;const o=s.toNode;return!(o===null||o.isLinkLabel||o.category==="Comment")}return!1};return t instanceof Diagram?(i.addParts(t.nodes,!0,e),i.addParts(t.links,!0,e)):t instanceof Group?i.addParts(t.memberParts,!1,e):i.addParts(t.iterator,!1,e),i}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangement!==52&&(this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin));let i=this.diagram;i===null&&t instanceof Diagram&&(i=t),this.path===0&&i!==null?this.hs=i.isTreePathToChildren?1:2:this.hs=this.path===0?1:this.path,this.network.vertexes.count>0&&(this.LI(),this.AI(),this.TI(),this.DI(),this.ON(),this.FI(),this.arrangeTrees(),this.updateParts()),this.network=null,this.Fi=new GSet,this.isValidLayout=!0}LI(){this.network.deleteSelfEdges();const t=this.network.vertexes.iterator;for(;t.next();){const n=t.value;n.initialized=!1,n.level=0,n.parent=null,n.children=[]}if(this.Fi.count>0){const n=new GSet,o=this.Fi.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=this.network.findVertex(r);l!==null&&n.add(l)}else r instanceof TreeVertex&&n.add(r)}this.Fi=n}this.Fi.count===0&&this.findRoots();const i=this.Fi.copy().iterator;for(;i.next();){const n=i.value;n.initialized||(n.initialized=!0,this.KN(n))}let e=this.network.vertexes,s=null;for(;s=this.RI(e),s.count>0;){const n=this.dD(s);n!==null&&this.Fi.add(n),n.initialized=!0,this.KN(n),e=s}}RI(t){const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;s.initialized||i.add(s)}return i}findRoots(){const t=this.network.vertexes,i=t.iterator;for(;i.next();){const e=i.value;switch(this.hs){case 1:e.sourceEdges.count===0&&this.Fi.add(e);break;case 2:e.destinationEdges.count===0&&this.Fi.add(e);break;default:Util.o("Unhandled path value "+this.hs.toString())}}if(this.Fi.count===0){const e=this.dD(t);e!==null&&this.Fi.add(e)}}dD(t){let i=999999,e=null;const s=t.iterator;for(;s.next();){const n=s.value;switch(this.hs){case 1:n.sourceEdges.count0){const s=new List,n=t.destinationVertexes;for(;n.next();){const o=n.value;this.gD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;case 2:if(t.sourceEdges.count>0){const s=new List,n=t.sourceVertexes;for(;n.next();){const o=n.value;this.gD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;default:Util.o("Unhandled path value"+this.hs.toString())}const i=t.children,e=i.length;for(let s=0;st.level?!1:(this.OI(i.parent,i),!0):!0}vI(t,i){if(i===null)return!1;let e=i.parent;for(;e!==null&&e!==t;)e=e.parent;return e===t}OI(t,i){if(t===null||i===null)return;const e=t.children;let s=0;for(let n=0;n0){const n=new Array(e.length-s);let o=0;for(let r=0;r0?s+1:0}II(t){switch(this.Qf){default:case 40:return t.parent!==null?t.parent:this.V;case 43:return t.parent===null?this.V:t.parent.parent===null?this.z:t.parent;case 42:return t.parent!==null?t.parent.parent!==null?t.parent.parent:this.z:this.V;case 41:{let i=!0;if(t.childrenCount===0)i=!1;else{const e=t.children,s=e.length;for(let n=0;n0){i=!1;break}}return i&&t.parent!==null?this.z:t.parent!==null?t.parent:this.V}}}initializeTreeVertexValues(t){const i=this.II(t);if(t.copyInheritedPropertiesFrom(i),t.parent!==null&&t.parent.alignment===25){let e=t.angle;const s=t.parent.children;let n=0;for(;n135&&!l||a&&f)if(t.commentMargin>=0){g.e(t.bounds.x-t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleLeft,P.toSpot=Spot.MiddleRight}}else{g.e(t.bounds.x+t.focus.x*2-t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleRight,P.toSpot=Spot.MiddleLeft}}else if(t.commentMargin>=0){g.e(t.bounds.x+t.focus.x*2+t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleRight,P.toSpot=Spot.MiddleLeft}}else{g.e(t.bounds.x+t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleLeft,P.toSpot=Spot.MiddleRight}}t.commentSpacing>=0?u+=k.height+t.commentSpacing:u+=t.commentSpacing-k.height}else{if(o>135&&!l||!a&&f)if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y-t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleTop,P.toSpot=Spot.MiddleBottom}}else{g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2-t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleBottom,P.toSpot=Spot.MiddleTop}}else if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2+t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleBottom,P.toSpot=Spot.MiddleTop}}else{g.e(t.bounds.x+u,t.bounds.y+t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleTop,P.toSpot=Spot.MiddleBottom}}t.commentSpacing>=0?u+=k.width+t.commentSpacing:u+=t.commentSpacing-k.width}}Point.s(g);const p=u-t.commentSpacing-(h?e.height:e.width);if(this.hs===1){const y=t.destinationEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.fromEndSegmentLength=p>0?p:NaN)}}else{const y=t.sourceEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.toEndSegmentLength=p>0?p:NaN)}}}}FI(){if(this.layerStyle===62){const i=[];let e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;let n=s.parent;n===null&&(n=s);const o=n.angle===0||n.angle===180;let r=i[s.level];r===void 0&&(r=0),i[s.level]=Math.max(r,o?s.width:s.height)}for(let s=0;s=0)for(let o=0;o135&&n.reverse(),this.Jy(r))if(o>1)for(let R=0;R0&&S>0&&M+u+O.width>c&&(M135?-b-g:b+g);const U=S===0?m:u;this.fk(v,0,L),v.U.e(M+U,L),k=Math.max(k,M+U+O.width),b=Math.max(b,P+(C===0?0:g)+O.height),M+=U+O.width}else{c>0&&S>0&&L+u+O.height>c&&(L135?-k-g:k+g);const U=S===0?m:u;this.fk(v,M,0),v.U.e(M,L+U),b=Math.max(b,L+U+O.height),k=Math.max(k,P+(C===0?0:g)+O.width),L+=U+O.height}S++}C>0&&(e?(b+=Math.max(0,f),M0&&(h||this.iu(t,p,0,0,o-1),k+=p)):(k+=Math.max(0,f),L0&&(h||this.iu(t,0,p,0,o-1),b+=p)));let D=0,F=0;switch(r){case 20:e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;break;default:case 21:if(C>0)e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;else{const v=o;if(e){const O=n[0].U.x+n[0].et.x,U=n[v-1].U.x+n[v-1].et.x+n[v-1].focus.x*2;D+=O+(U-O)/2-t.focus.x-d/2}else{const O=n[0].U.y+n[0].et.y,U=n[v-1].U.y+n[v-1].et.y+n[v-1].focus.y*2;F+=O+(U-O)/2-t.focus.y-d/2}}break;case 22:e?(D-=d,k+=d):(F-=d,b+=d);break;case 23:e?(D+=k-t.width+d,k+=d):(F+=b-t.height+d,b+=d);break;case 24:case 25:e?o>1?D+=T+u/2-t.focus.x:D+=n[0].focus.x-t.focus.x+n[0].et.x:o>1?F+=T+u/2-t.focus.y:F+=n[0].focus.y-t.focus.y+n[0].et.y;break;case 26:e?D+=k+u/2-t.focus.x:F+=b+u/2-t.focus.y;break;case 27:break;case 28:const R=this.customAlignment(t,D,F,k,b);D=R[0],F=R[1],k=R[2],b=R[3];break}for(let R=0;R135?(a?-b:-v.mt.height)+v.et.y-f:x+f+v.et.y)):v.U.e(v.U.x+(i>135?(a?-k:-v.mt.width)+v.et.x-f:y+f+v.et.x),v.U.y+v.et.y-F)}e?(k=this.GN(t,k,D),D<0&&(D=0),i>135&&(F+=b+f),b=Math.max(Math.max(b,x),b+x+f)):(i>135&&(D+=k+f),k=Math.max(Math.max(k,y),k+y+f),b=this.jN(t,b,F),F<0&&(F=0)),t.et.e(D,F),t.mt.e(k,b)}customAlignment(t,i,e,s,n){return[i,e,s,n]}xD(t,i,e,s,n,o){const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.mt.width,o=p.mt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,c=this.orthoAngle(t)===90;let f=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.mt,k=f===0?0:h;if(c){const b=this.computeBusNodeSpacing(y)-l;y.U.e(e-(x.width+b),d+k),n=Math.max(n,x.width+b),o=Math.max(o,d+k+x.height),d+=k+x.height}else{const b=this.computeBusNodeSpacing(y)-l;y.U.e(u+k,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,u+k+x.width),u+=k+x.width}f++}f=0;const m=u,g=d;c?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.mt,x=this.computeBusLastRowSpacing(p,c?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(c){p.U.e(e+l/2-p.focus.x-p.et.x,o+x);const k=e+l/2-p.focus.x-p.et.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.max(g,d)+x+y.height),p.U.x<0&&(e=this.uk(t,p.U.x,!1,e,l))}else{p.U.e(n+x,e+l/2-p.focus.y-p.et.y),n=Math.max(n,Math.max(m,u)+x+y.width);const k=e+l/2-p.focus.y-p.et.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.U.y<0&&(e=this.uk(t,p.U.y,!0,e,l))}}return new Rect(e,0,n,o)}bD(t,i,e,s,n,o){const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.mt.width,o=p.mt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,c=this.orthoAngle(t)===270;let f=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.mt,k=f===0?0:h;if(c){const b=this.computeBusNodeSpacing(y)-l;d-=k+x.height,y.U.e(e-(x.width+b),d),n=Math.max(n,x.width+b),o=Math.max(o,Math.abs(d))}else{const b=this.computeBusNodeSpacing(y)-l;u-=k+x.width,y.U.e(u,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,Math.abs(u))}f++}f=0;const m=u,g=d;c?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.mt,x=this.computeBusLastRowSpacing(p,c?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(c){p.U.e(e+l/2-p.focus.x-p.et.x,-o-y.height-x);const k=e+l/2-p.focus.x-p.et.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.abs(Math.min(g,d))+x+y.height),p.U.x<0&&(e=this.uk(t,p.U.x,!1,e,l))}else{p.U.e(-n-y.width-x,e+l/2-p.focus.y-p.et.y),n=Math.max(n,Math.abs(Math.min(m,u))+x+y.width);const k=e+l/2-p.focus.y-p.et.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.U.y<0&&(e=this.uk(t,p.U.y,!0,e,l))}}for(let p=0;ps&&(s=e+t.width),e<0&&(s-=e),s;case 22:return t.width>i?t.width:i;case 23:return t.focus.x*2>i?t.width:i+t.width-t.focus.x*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.width);return Math.max(t.width,o-n);case 26:return t.width-t.focus.x+t.nodeSpacing/2+i;case 27:return Math.max(t.width,t.focus.x+t.nodeSpacing/2+i);default:return i}}jN(t,i,e){switch(t.alignment){case 21:case 20:let s=i;return e+t.height>s&&(s=e+t.height),e<0&&(s-=e),s;case 22:return t.height>i?t.height:i;case 23:return t.focus.y*2>i?t.height:i+t.height-t.focus.y*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.height);return Math.max(t.height,o-n);case 26:return t.height-t.focus.y+t.nodeSpacing/2+i;case 27:return Math.max(t.height,t.focus.y+t.nodeSpacing/2+i);default:return i}}HN(t,i,e){switch(t){case 20:i/=2,e/=2;break;case 21:i/=2,e/=2;break;case 22:i=0,e=0;break;case 23:break;default:Util.o("Unhandled alignment value "+t.toString())}return new Point(i,e)}Qa(t,i,e,s,n,o){const r=this.HN(i,e,s);this.iu(t,r.x,r.y,n,o)}iu(t,i,e,s,n){if(i===0&&e===0)return;const o=t.children;for(let r=s;r<=n;r++){const h=o[r].U;h.x+=i,h.y+=e}}fk(t,i,e){const s=t.parent;switch(this.hs){case 1:{const n=t.sourceEdges;for(;n.next();){const o=n.value;o.fromVertex===s&&o.relativePoint.e(i,e)}break}case 2:{const n=t.destinationEdges;for(;n.next();){const o=n.value;o.toVertex===s&&o.relativePoint.e(i,e)}break}default:Util.o("Unhandled path value "+this.hs.toString())}}EI(t){if(t.childrenCount===0){const B=t.parent;let Y=!1,G=0,H=21;B!==null&&(G=B.angle,H=B.alignment,Y=this.isBusAlignment(H));const J=this.YN(t);t.U.e(0,0),t.mt.e(t.width,t.height),t.parent!==null&&t.comments!==null&&((G===180||G===270)&&!Y||J)?G===180&&!Y||(G===90||G===270)&&J?t.et.e(t.width-t.focus.x*2,0):t.et.e(0,t.height-t.focus.y*2):t.et.e(0,0),t.Rg=null,t.vg=null;return}const i=this.orthoAngle(t),e=i===90||i===270;let s=0;const n=t.children,o=n.length;for(let B=0;B135&&n.reverse(),this.Jy(r))if(o>1)for(let B=0;B0&&A>0&&S+u+G.width>c&&(S135?-k-m:k+m),this.fk(Y,0,N);let H=0;if(A===0)P=Y.Rg,M=Y.vg,L=G.width,C=G.height,(P===null||M===null||i!==this.orthoAngle(Y))&&(P=this.he(2),M=this.he(2),P[0].e(0,0),P[1].e(0,C),M[0].e(L,0),M[1].e(L,C));else{const J=Util.ot(),z=this.kD(t,Y,P,M,L,C,J);H=z.x,P=J[0],M=J[1],L=z.width,C=z.height,Util.tt(J),S0&&A>0&&N+u+G.height>c&&(N135?-x-m:x+m),this.fk(Y,S,0);let H=0;if(A===0)P=Y.Rg,M=Y.vg,L=G.width,C=G.height,(P===null||M===null||i!==this.orthoAngle(Y))&&(P=this.he(2),M=this.he(2),P[0].e(0,0),P[1].e(L,0),M[0].e(0,C),M[1].e(L,C));else{const J=Util.ot(),z=this.kD(t,Y,P,M,L,C,J);H=z.x,P=J[0],M=J[1],L=z.width,C=z.height,Util.tt(J),N0&&(e?(k+=Math.max(0,f),S0&&(h||this.iu(t,g,0,0,o-1),x+=g)):(x+=Math.max(0,f),N0&&(h||this.iu(t,0,g,0,o-1),k+=g)));let v=0,O=0;switch(r){case 20:e?v+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;break;default:case 21:if(T>0)e?v+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;else{const Y=o;if(e){const G=n[0].U.x+n[0].et.x,H=n[Y-1].U.x+n[Y-1].et.x+n[Y-1].focus.x*2;v+=G+(H-G)/2-t.focus.x-d/2}else{const G=n[0].U.y+n[0].et.y,H=n[Y-1].U.y+n[Y-1].et.y+n[Y-1].focus.y*2;O+=G+(H-G)/2-t.focus.y-d/2}}break;case 22:e?(v-=d,x+=d):(O-=d,k+=d);break;case 23:e?(v+=x-t.width+d,x+=d):(O+=k-t.height+d,k+=d);break;case 24:e?o>1?v+=F+u/2-t.focus.x:v+=n[0].focus.x-t.focus.x+n[0].et.x:o>1?O+=F+u/2-t.focus.y:O+=n[0].focus.y-t.focus.y+n[0].et.y;break;case 26:e?v+=x+u/2-t.focus.x:O+=k+u/2-t.focus.y;break;case 27:break;case 28:const B=this.customAlignment(t,v,O,x,k);v=B[0],O=B[1],x=B[2],k=B[3];break}for(let B=0;B135?(a?-k:-Y.mt.height)+Y.et.y-f:y+f+Y.et.y)):Y.U.e(Y.U.x+(i>135?(a?-x:-Y.mt.width)+Y.et.x-f:p+f+Y.et.x),Y.U.y+Y.et.y-O)}let U=0,X=0;if(a)e?(x=this.GN(t,x,v),v<0&&(v=0),i>135&&(O+=k+f),k+=y+f,r===27&&(U+=u/2+t.focus.x),X+=y+f):(i>135&&(v+=x+f),x+=p+f,k=this.jN(t,k,O),O<0&&(O=0),r===27&&(X+=u/2+t.focus.y),U+=p+f);else if(e){if(t.comments===null){if(p>x){const B=this.HN(r,p-x,0);U=B.x,X=B.y,x=p,v=0}}else x=this.GN(t,x,v);v<0&&(U-=v,v=0),i>135&&(O+=k+f),k=Math.max(Math.max(k,y),k+y+f),X+=y+f}else{if(i>135&&(v+=x+f),x=Math.max(Math.max(x,p),x+p+f),t.comments===null){if(y>k){const B=this.HN(r,0,y-k);U=B.x,X=B.y,k=y,O=0}}else k=this.jN(t,k,O);O<0&&(X-=O,O=0),U+=p+f}let E,V;if(T>0)E=this.he(4),V=this.he(4),e?(E[2].e(0,y+f),E[3].e(E[2].x,k),V[2].e(x,E[2].y),V[3].e(V[2].x,E[3].y)):(E[2].e(p+f,0),E[3].e(x,E[2].y),V[2].e(E[2].x,k),V[3].e(E[3].x,V[2].y));else{E=this.he(P.length+2),V=this.he(M.length+2);for(let B=0;BE[0].x?E[2].a(E[1]):E[1].a(E[2])),E[3].yE[0].x?E[3].a(E[2]):E[2].a(E[3])),V[0].e(v+p,0),V[1].e(V[0].x,y),V[2].yE[0].y?E[2].a(E[1]):E[1].a(E[2])),E[3].xE[0].y?E[3].a(E[2]):E[2].a(E[3])),V[0].e(0,O+y),V[1].e(p,V[0].y),V[2].xl;){const a=i[o++];s[r++].e(a.x,a.y+e)}const h=this.he(r);for(n=0;nl;){const a=i[o++];s[r++].e(a.x+e,a.y)}const h=this.he(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.he(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.he(r);for(n=0;nh&&r.xr.x&&ha&&r.yr.y&&a0){const n=Math.min(1,t.layerSpacingParentOverlap);s-=e?t.height*n:t.width*n}return s<(e?-t.height:-t.width)&&(s=e?-t.height:-t.width),s}computeNodeIndent(t){const i=this.orthoAngle(t),e=i===90||i===270;let s=t.nodeIndent;if(t.nodeIndentPastParent>0){const n=Math.min(1,t.nodeIndentPastParent);s+=e?t.width*n:t.height*n}return s=Math.max(0,s),s}get roots(){return this.Fi}set roots(t){this.Fi!==t&&(this.Fi=t,this.invalidateLayout())}get path(){return this.Ti}set path(t){this.Ti!==t&&(this.Ti=t,this.invalidateLayout())}get treeStyle(){return this.Qf}set treeStyle(t){this.Qf!==t&&(t===40||t===42||t===41||t===43)&&(this.Qf=t,this.invalidateLayout())}get layerStyle(){return this.Fg}set layerStyle(t){this.Fg!==t&&(t===60||t===61||t===62)&&(this.Fg=t,this.invalidateLayout())}get comments(){return this.Re}set comments(t){this.Re!==t&&(Util.i(t,"boolean",TreeLayout,"comments"),this.Re=t,this.invalidateLayout())}get arrangement(){return this.zi}set arrangement(t){this.zi!==t&&(t===50||t===51||t===52)&&(this.zi=t,this.invalidateLayout())}get arrangementSpacing(){return this.ks}set arrangementSpacing(t){this.ks.equals(t)||(this.ks.a(t),this.invalidateLayout())}get rootDefaults(){return this.V}set rootDefaults(t){this.V!==t&&(this.V=t,this.invalidateLayout())}get alternateDefaults(){return this.z}set alternateDefaults(t){this.z!==t&&(this.z=t,this.invalidateLayout())}get sorting(){return this.V.sorting}set sorting(t){this.V.sorting!==t&&(this.V.sorting=t,this.invalidateLayout())}get comparer(){return this.V.comparer}set comparer(t){this.V.comparer!==t&&(Util.i(t,"function",TreeLayout,"comparer"),this.V.comparer=t,this.invalidateLayout())}get angle(){return this.V.angle}set angle(t){this.V.angle!==t&&(Util.i(t,"number",TreeLayout,"angle"),t===0||t===90||t===180||t===270?(this.V.angle=t,this.invalidateLayout()):Util.o("TreeLayout.angle must be 0, 90, 180, or 270"))}get alignment(){return this.V.alignment}set alignment(t){this.V.alignment!==t&&(this.V.alignment=t,this.invalidateLayout())}get nodeIndent(){return this.V.nodeIndent}set nodeIndent(t){this.V.nodeIndent!==t&&(Util.i(t,"number",TreeLayout,"nodeIndent"),t>=0&&(this.V.nodeIndent=t,this.invalidateLayout()))}get nodeIndentPastParent(){return this.V.nodeIndentPastParent}set nodeIndentPastParent(t){this.V.nodeIndentPastParent!==t&&(Util.i(t,"number",TreeLayout,"nodeIndentPastParent"),t>=0&&t<=1&&(this.V.nodeIndentPastParent=t,this.invalidateLayout()))}get nodeSpacing(){return this.V.nodeSpacing}set nodeSpacing(t){this.V.nodeSpacing!==t&&(Util.i(t,"number",TreeLayout,"nodeSpacing"),this.V.nodeSpacing=t,this.invalidateLayout())}get layerSpacing(){return this.V.layerSpacing}set layerSpacing(t){this.V.layerSpacing!==t&&(Util.i(t,"number",TreeLayout,"layerSpacing"),this.V.layerSpacing=t,this.invalidateLayout())}get layerSpacingParentOverlap(){return this.V.layerSpacingParentOverlap}set layerSpacingParentOverlap(t){this.V.layerSpacingParentOverlap!==t&&(Util.i(t,"number",TreeLayout,"layerSpacingParentOverlap"),t>=0&&t<=1&&(this.V.layerSpacingParentOverlap=t,this.invalidateLayout()))}get compaction(){return this.V.compaction}set compaction(t){this.V.compaction!==t&&(t===30||t===31)&&(this.V.compaction=t,this.invalidateLayout())}get breadthLimit(){return this.V.breadthLimit}set breadthLimit(t){this.V.breadthLimit!==t&&(Util.i(t,"number",TreeLayout,"breadthLimit"),t>=0&&(this.V.breadthLimit=t,this.invalidateLayout()))}get rowSpacing(){return this.V.rowSpacing}set rowSpacing(t){this.V.rowSpacing!==t&&(Util.i(t,"number",TreeLayout,"rowSpacing"),this.V.rowSpacing=t,this.invalidateLayout())}get rowIndent(){return this.V.rowIndent}set rowIndent(t){this.V.rowIndent!==t&&(Util.i(t,"number",TreeLayout,"rowIndent"),t>=0&&(this.V.rowIndent=t,this.invalidateLayout()))}get commentSpacing(){return this.V.commentSpacing}set commentSpacing(t){this.V.commentSpacing!==t&&(Util.i(t,"number",TreeLayout,"commentSpacing"),this.V.commentSpacing=t,this.invalidateLayout())}get commentMargin(){return this.V.commentMargin}set commentMargin(t){this.V.commentMargin!==t&&(Util.i(t,"number",TreeLayout,"commentMargin"),this.V.commentMargin=t,this.invalidateLayout())}get setsPortSpot(){return this.V.setsPortSpot}set setsPortSpot(t){this.V.setsPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"setsPortSpot"),this.V.setsPortSpot=t,this.invalidateLayout())}get portSpot(){return this.V.portSpot}set portSpot(t){this.V.portSpot.equals(t)||(this.V.portSpot=t,this.invalidateLayout())}get setsChildPortSpot(){return this.V.setsChildPortSpot}set setsChildPortSpot(t){this.V.setsChildPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"setsChildPortSpot"),this.V.setsChildPortSpot=t,this.invalidateLayout())}get childPortSpot(){return this.V.childPortSpot}set childPortSpot(t){this.V.childPortSpot.equals(t)||(this.V.childPortSpot=t,this.invalidateLayout())}get alternateSorting(){return this.z.sorting}set alternateSorting(t){this.z.sorting!==t&&(this.z.sorting=t,this.invalidateLayout())}get alternateComparer(){return this.z.comparer}set alternateComparer(t){this.z.comparer!==t&&(Util.i(t,"function",TreeLayout,"alternateComparer"),this.z.comparer=t,this.invalidateLayout())}get alternateAngle(){return this.z.angle}set alternateAngle(t){this.z.angle!==t&&(Util.i(t,"number",TreeLayout,"alternateAngle"),(t===0||t===90||t===180||t===270)&&(this.z.angle=t,this.invalidateLayout()))}get alternateAlignment(){return this.z.alignment}set alternateAlignment(t){this.z.alignment!==t&&(this.z.alignment=t,this.invalidateLayout())}get alternateNodeIndent(){return this.z.nodeIndent}set alternateNodeIndent(t){this.z.nodeIndent!==t&&(Util.i(t,"number",TreeLayout,"alternateNodeIndent"),t>=0&&(this.z.nodeIndent=t,this.invalidateLayout()))}get alternateNodeIndentPastParent(){return this.z.nodeIndentPastParent}set alternateNodeIndentPastParent(t){this.z.nodeIndentPastParent!==t&&(Util.i(t,"number",TreeLayout,"alternateNodeIndentPastParent"),t>=0&&t<=1&&(this.z.nodeIndentPastParent=t,this.invalidateLayout()))}get alternateNodeSpacing(){return this.z.nodeSpacing}set alternateNodeSpacing(t){this.z.nodeSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateNodeSpacing"),this.z.nodeSpacing=t,this.invalidateLayout())}get alternateLayerSpacing(){return this.z.layerSpacing}set alternateLayerSpacing(t){this.z.layerSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateLayerSpacing"),this.z.layerSpacing=t,this.invalidateLayout())}get alternateLayerSpacingParentOverlap(){return this.z.layerSpacingParentOverlap}set alternateLayerSpacingParentOverlap(t){this.z.layerSpacingParentOverlap!==t&&(Util.i(t,"number",TreeLayout,"alternateLayerSpacingParentOverlap"),t>=0&&t<=1&&(this.z.layerSpacingParentOverlap=t,this.invalidateLayout()))}get alternateCompaction(){return this.z.compaction}set alternateCompaction(t){this.z.compaction!==t&&(t===30||t===31)&&(this.z.compaction=t,this.invalidateLayout())}get alternateBreadthLimit(){return this.z.breadthLimit}set alternateBreadthLimit(t){this.z.breadthLimit!==t&&(Util.i(t,"number",TreeLayout,"alternateBreadthLimit"),t>=0&&(this.z.breadthLimit=t,this.invalidateLayout()))}get alternateRowSpacing(){return this.z.rowSpacing}set alternateRowSpacing(t){this.z.rowSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateRowSpacing"),this.z.rowSpacing=t,this.invalidateLayout())}get alternateRowIndent(){return this.z.rowIndent}set alternateRowIndent(t){this.z.rowIndent!==t&&(Util.i(t,"number",TreeLayout,"alternateRowIndent"),t>=0&&(this.z.rowIndent=t,this.invalidateLayout()))}get alternateCommentSpacing(){return this.z.commentSpacing}set alternateCommentSpacing(t){this.z.commentSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateCommentSpacing"),this.z.commentSpacing=t,this.invalidateLayout())}get alternateCommentMargin(){return this.z.commentMargin}set alternateCommentMargin(t){this.z.commentMargin!==t&&(Util.i(t,"number",TreeLayout,"alternateCommentMargin"),this.z.commentMargin=t,this.invalidateLayout())}get alternateSetsPortSpot(){return this.z.setsPortSpot}set alternateSetsPortSpot(t){this.z.setsPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"alternateSetsPortSpot"),this.z.setsPortSpot=t,this.invalidateLayout())}get alternatePortSpot(){return this.z.portSpot}set alternatePortSpot(t){this.z.portSpot.equals(t)||(this.z.portSpot=t,this.invalidateLayout())}get alternateSetsChildPortSpot(){return this.z.setsChildPortSpot}set alternateSetsChildPortSpot(t){this.z.setsChildPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"alternateSetsChildPortSpot"),this.z.setsChildPortSpot=t,this.invalidateLayout())}get alternateChildPortSpot(){return this.z.childPortSpot}set alternateChildPortSpot(t){this.z.childPortSpot.equals(t)||(this.z.childPortSpot=t,this.invalidateLayout())}static PathDefault=0;static PathDestination=1;static PathSource=2;static SortingForwards=10;static SortingReverse=11;static SortingAscending=12;static SortingDescending=13;static AlignmentCenterSubtrees=20;static AlignmentCenterChildren=21;static AlignmentStart=22;static AlignmentEnd=23;static AlignmentBus=24;static AlignmentBusBranching=25;static AlignmentTopLeftBus=26;static AlignmentBottomRightBus=27;static CompactionNone=30;static CompactionBlock=31;static StyleLayered=40;static StyleLastParents=41;static StyleAlternating=42;static StyleRootOnly=43;static ArrangementVertical=50;static ArrangementHorizontal=51;static ArrangementFixedRoots=52;static LayerIndividual=60;static LayerSiblings=61;static LayerUniform=62}class TreeNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new TreeVertex(this)}createEdge(){return new TreeEdge(this)}}class TreeVertex extends LayoutVertex{U;mt;et;gk;mk;pk;yk;wk;xk;bk;Re;MD;_f;tu;Rg;vg;pe;ye;Xt;ni;$y;Zy;Qy;Ps;_y;tw;iw;ew;sw;nw;ow;rw;lw;hw;aw;constructor(t){super(t),this.gk=!1,this.mk=null,this.pk=[],this.yk=0,this.wk=0,this.xk=0,this.bk=0,this.Re=null,this.U=new Point(0,0),this.mt=new Size(0,0),this.et=new Point(0,0),this.MD=!1,this._f=!1,this.tu=!1,this.Rg=null,this.vg=null,this.pe=10,this.ye=LayoutVertex.standardComparer,this.Xt=0,this.ni=21,this.$y=0,this.Zy=0,this.Qy=20,this.Ps=50,this._y=0,this.tw=31,this.iw=0,this.ew=25,this.sw=10,this.nw=10,this.ow=20,this.rw=!0,this.lw=Spot.Default,this.hw=!0,this.aw=Spot.Default}copyInheritedPropertiesFrom(t){t!==null&&(this.pe=t.sorting,this.ye=t.comparer,this.Xt=t.angle,this.ni=t.alignment,this.$y=t.nodeIndent,this.Zy=t.nodeIndentPastParent,this.Qy=t.nodeSpacing,this.Ps=t.layerSpacing,this._y=t.layerSpacingParentOverlap,this.tw=t.compaction,this.iw=t.breadthLimit,this.ew=t.rowSpacing,this.sw=t.rowIndent,this.nw=t.commentSpacing,this.ow=t.commentMargin,this.rw=t.setsPortSpot,this.lw=t.portSpot,this.hw=t.setsChildPortSpot,this.aw=t.childPortSpot)}get initialized(){return this.gk}set initialized(t){this.gk!==t&&(Util.i(t,"boolean",TreeVertex,"initialized"),this.gk=t)}get parent(){return this.mk}set parent(t){this.mk!==t&&(this.mk=t)}get children(){return this.pk}set children(t){if(this.pk!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",TreeVertex,"children:value"),t!==null){const i=t.length;for(let e=0;e4;)t.removePoint(2);u=t.getPoint(1),d=t.getPoint(2)}else{for(f=1;t.pointsCount>3;)t.removePoint(1);u=t.getPoint(0),d=t.getPoint(t.pointsCount-1)}const m=t.getPoint(t.pointsCount-1);let g=0;r===0?(e.alignment===23?(g=o.bottom+n.y,n.y===0&&u.y>m.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.xm.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.x{const i=t.matches?"dark":"light";i!==this.Og&&(this.Og=i,this.Mk==="system"&&this.cw())};constructor(t){t&&Object.assign(this,t),t?.themeMap||(this.eu.set("light",{colors:{...Themes.Light.colors},fonts:{...Themes.Light.fonts},numbers:{...Themes.Light.numbers},margins:{...Themes.Light.margins},arrowheads:{...Themes.Light.arrowheads}}),this.eu.set("dark",{colors:{...Themes.Dark.colors},fonts:{...Themes.Dark.fonts},numbers:{...Themes.Dark.numbers},margins:{...Themes.Dark.margins},arrowheads:{...Themes.Dark.arrowheads}})),root.matchMedia&&(this.Og=root.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}get themeMap(){return this.eu}set themeMap(t){this.eu!==t&&(this.eu=t,this.cw())}get defaultTheme(){return this.Pk}set defaultTheme(t){this.Pk!==t&&(Util.i(t,"string",ThemeManager,"defaultTheme"),this.Pk=t,this.cw())}get currentTheme(){return this.Mk}set currentTheme(t){this.Mk!==t&&(Util.i(t,"string",ThemeManager,"currentTheme"),this.Mk=t,this.cw())}get changesDivBackground(){return this.Sk}set changesDivBackground(t){if(this.Sk!==t&&(this.Sk=t,t))for(const e of this.es)e.setDivBackground(this.findValue("div","","fill")),e.v("ThemeChanged",this)}get preferredColorScheme(){return this.Og}addDiagram(t){return this.es.add(t),this.WN(t),this}removeDiagram(t){return this.es.delete(t),this.WN(t),this}zF(){this.es.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.addEventListener("change",this.SD)}XF(){this.es.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.removeEventListener("change",this.SD)}set(t,i){t===""&&(t=this.Pk),t==="system"&&(t=this.Og);let e=this.eu.get(t);return e?e=this.ND(e,i):e=i,this.eu.set(t,e),this.cw(),this}findValue(t,i,e){return this.getValue(this.findTheme(this.currentTheme),t,i,e)||this.getValue(this.findTheme(this.defaultTheme),t,i,e)}getValue(t,i,e,s){if(!t)return;e==null&&(e="");let n=t;const o=l=>{if(n===void 0||l==="")return;if(typeof l=="number"||!(Array.isArray(l)||l.includes(".")))return n[l];const h=Array.isArray(l)?l:l.split(".");for(let a=0;a{if(!(e!==""&&(n=o(e),n===void 0)))return Array.isArray(n)&&typeof i=="number"?n=n[i%n.length]:n=o(i),n};if(n=r(),n===void 0&&typeof s=="string"&&s.length>0){let l=t.targetPropertyMap?.get(s);if(l?n=t[l]:(l=ThemeManager.jI.get(s),n=l?t[l]:t.colors),n=r(),n!==void 0)return n}return n}findTheme(t){return this.themeMap.get(t==="system"?this.Og:t)}WN(t){const i=t.skipsUndoManager;t.skipsUndoManager=!0,t.updateAllThemeBindings(),this.Sk&&t.setDivBackground(this.findValue("div","","fill")),t.skipsUndoManager=i,t.v("ThemeChanged",this)}cw(){for(const t of this.es)this.WN(t)}ND(t,i){for(const e in i)if(Util.fw(i,e))try{i[e].constructor===Object?t[e]=this.ND(t[e]??{},i[e]):t[e]=i[e]}catch{delete t[e]}return t}static jI=new Map([["background","colors"],["defaultColumnSeparatorStroke","colors"],["defaultRowSeparatorStroke","colors"],["shadowColor","colors"],["fill","colors"],["stroke","colors"],["font","fonts"],["angle","numbers"],["fromEndSegmentLength","numbers"],["fromShortLength","numbers"],["height","numbers"],["opacity","numbers"],["scale","numbers"],["toEndSegmentLength","numbers"],["toShortLength","numbers"],["width","numbers"],["defaultColumnSeparatorStrokeWidth","numbers"],["defaultRowSeparatorStrokeWidth","numbers"],["shadowBlur","numbers"],["corner","numbers"],["curviness","numbers"],["smoothness","numbers"],["parameter1","numbers"],["parameter2","numbers"],["strokeWidth","numbers"],["strokeDashOffset","numbers"],["maxLines","numbers"],["spacingAbove","numbers"],["spacingBelow","numbers"],["position","points"],["shadowOffset","points"],["desiredSize","sizes"],["maxSize","sizes"],["minSize","sizes"],["margin","margins"],["defaultSeparatorPadding","margins"],["padding","margins"],["alignment","spots"],["alignmentFocus","spots"],["fromSpot","spots"],["toSpot","spots"],["defaultAlignment","spots"],["spot1","spots"],["spot2","spots"],["verticalAlignment","spots"],["imageAlignment","spots"],["fromArrow","arrowheads"],["toArrow","arrowheads"]])}class Router{St;p;Oi;ul;constructor(){this.p=Diagram.pm(),this.St="",this.Oi=!0,this.ul=!0}get name(){return this.St}set name(t){this.St=t}get isEnabled(){return this.Oi}set isEnabled(t){this.Oi=t}get isRealtime(){return this.ul}set isRealtime(t){this.ul=t}get diagram(){return this.p}set diagram(t){this.p!==t&&(this.p=t,t.bl=!0,t.requestUpdate())}invalidateRouter(){this.p!==null&&(this.p.bl=!0,this.p.requestUpdate())}canRoute(t){if(!this.isEnabled)return!1;const i=this.diagram;return!(i&&(!this.isRealtime&&i.yu||i.animationManager.isTicking))}routeLinks(t,i){}toString(){return this.name!==""?this.name+" Router":Util.sn(this.constructor)}}class AvoidsNodesRouter extends Router{constructor(t){super(),this.name="AvoidsNodes",t&&Object.assign(this,t)}canRoute(t){return(t instanceof Diagram?t.Gm:t.diagram.Gm)?super.canRoute(t):!1}routeLinks(t,i){const e=i instanceof Diagram?null:i,s=t.iterator,n=this.diagram.getPositions(!0,e,null);for(;s.next();){const o=s.value;if(!o.isAvoiding||i&&o.containingGroup!==e||o.toNode===null||o.fromNode===null||o.pointsCount<4)continue;o.startRoute();const r=o.pointsCount,l=o.getPoint(1),h=o.getPoint(r-2),a=o.fromNode.actualBounds.copy();a.inflate(Link.Ra,Link.Ra),a.unionPoint(o.getPoint(0));const c=o.toNode.actualBounds.copy();c.inflate(Link.Ra,Link.Ra),c.unionPoint(o.getPoint(r-1)),this.HI(o,a,c,n)&&this.qI(o,l,o.sN,h,o.nN,a,c,n),o.commitRoute()}}HI(t,i,e,s){const n=t.diagram,o=t.pointsCount;if(n===null||t.fromNode===t.toNode||t.layer.isTemporary||i.containsPoint(t.getPoint(o-1))&&!t.toNode.isMemberOf(t.fromNode)||e.containsPoint(t.getPoint(0))&&!t.fromNode.isMemberOf(t.toNode)||!t.isOrthogonal)return!1;if(t.segmentIndex===17)return!0;const r=t.getPoint(1),l=t.getPoint(o-2),h=t.getPoint(2);if(!s.isUnoccupied(Math.min(r.x,h.x),Math.min(r.y,h.y),Math.abs(r.x-h.x),Math.abs(r.y-h.y)))return!0;for(let c=2;c=PositionArray.Bd&&(l.XL(),d.inflate(l.cellWidth*l.vS,l.cellHeight*l.OS),l.rT(i,e,s,n,d,!1),m=l.fo(s.x,s.y)),!l.by&&mPositionArray.Ea&&i.fo(g,p)!==u-1&&(i.fo(d-c,m)===u-1?(n=180,g=d-c,p=m):i.fo(d+c,m)===u-1?(n=0,g=d+c,p=m):i.fo(d,m-f)===u-1?(n=270,g=d,p=m-f):i.fo(d,m+f)===u-1&&(n=90,g=d,p=m+f));u>PositionArray.Ea&&i.fo(g,p)===u-1;)d=g,m=p,n===0?g+=c:n===90?p+=f:n===180?g-=c:p-=f,u-=1;if(o?u>PositionArray.Ea&&(n===180||n===0?d=Math.floor(d/c)*c+c/2:(n===90||n===270)&&(m=Math.floor(m/f)*f+f/2)):(d=Math.floor(d/c)*c+c/2,m=Math.floor(m/f)*f+f/2),u>PositionArray.Ea){let y=n,x=d,k=m;if(n===0?(y=90,k+=f):n===90?(y=180,x-=c):n===180?(y=270,k-=f):n===270&&(y=0,x+=c),i.fo(x,k)===u-1)this.JN(t,i,x,k,y,!1);else{let P=d,M=m;n===0?(y=270,M-=f):n===90?(y=0,P+=c):n===180?(y=90,M+=f):n===270&&(y=180,P-=c),i.fo(P,M)===u-1&&this.JN(t,i,P,M,y,!1)}}t.insertPointAt(t.pointsCount-2,d,m)}}ToolManager.prototype.initializeStandardTools=function(){this.Jt("Action",new ActionTool,this.mouseDownTools),this.Jt("Relinking",new RelinkingTool,this.mouseDownTools),this.Jt("LinkReshaping",new LinkReshapingTool,this.mouseDownTools),this.Jt("Rotating",new RotatingTool,this.mouseDownTools),this.Jt("Resizing",new ResizingTool,this.mouseDownTools),this.Jt("Linking",new LinkingTool,this.mouseMoveTools),this.Jt("Dragging",new DraggingTool,this.mouseMoveTools),this.Jt("DragSelecting",new DragSelectingTool,this.mouseMoveTools),this.Jt("Panning",new PanningTool,this.mouseMoveTools),this.Jt("ContextMenu",new ContextMenuTool,this.mouseUpTools),this.Jt("TextEditing",new TextEditingTool,this.mouseUpTools),this.Jt("ClickCreating",new ClickCreatingTool,this.mouseUpTools),this.Jt("ClickSelecting",new ClickSelectingTool,this.mouseUpTools)};Diagram.gS("GraphLinksModel",GraphLinksPartManager);Diagram.gS("TreeModel",TreePartManager);const oldGo=root.go,go={get version(){return Diagram.version},Group,List,Set:GSet,Map:GMap,Point,Size,Rect,Margin,Spot,Geometry,PathFigure,PathSegment,InputEvent,DiagramEvent,ChangedEvent,Model,GraphLinksModel,TreeModel,Binding,ThemeBinding,Transaction,UndoManager,CommandHandler,Tool,DraggingTool,DraggingInfo,DraggingOptions,LinkingBaseTool,LinkingTool,RelinkingTool,LinkReshapingTool,ResizingTool,RotatingTool,ClickSelectingTool,ActionTool,ClickCreatingTool,HTMLInfo,ContextMenuTool,DragSelectingTool,PanningTool,TextEditingTool,ToolManager,Animation,AnimationManager,AnimationTrigger,Layer,Diagram,Palette,Overview,Brush,GraphObject,Panel,RowColumnDefinition,Shape,TextBlock,Picture,Part,Adornment,Node,Link,Placeholder,Layout,LayoutNetwork,LayoutVertex,LayoutEdge,GridLayout,PanelLayout,CircularLayout,CircularNetwork,CircularVertex,CircularEdge,ForceDirectedLayout,ForceDirectedNetwork,ForceDirectedVertex,ForceDirectedEdge,LayeredDigraphLayout,LayeredDigraphNetwork,LayeredDigraphVertex,LayeredDigraphEdge,TreeLayout,TreeNetwork,TreeVertex,TreeEdge,Themes,ThemeManager,Router,AnimationStyle,AutoScale,CycleMode,Flip,TextFormat,ImageStretch,LayoutConditions,LinkAdjusting,Curve,Routing,Orientation,TextOverflow,PortSpreading,ScrollMode,CollapsePolicy,Sizing,TriggerStart,Stretch,ViewboxStretch,Wrap,BrushType,ColorSpace,GeometryStretch,GeometryType,SegmentType,BindingMode,ChangeType,CircularArrangement,CircularDirection,CircularNodeDiameterFormula,CircularSorting,GridAlignment,GridArrangement,GridSorting,LayeredDigraphAggressive,LayeredDigraphAlign,LayeredDigraphCycleRemove,LayeredDigraphInit,LayeredDigraphLayering,LayeredDigraphPack,TreeAlignment,TreeArrangement,TreeCompaction,TreeLayerStyle,TreePath,TreeSorting,TreeStyle,GestureMode,LinkingDirection,ReshapingBehavior,TextEditingAccept,TextEditingStarting,TextEditingState,WheelMode};typeof oldGo=="object"&&oldGo.version&&Util.oi("WARNING: a `go` object on the root object is already defined. "+("Debug"in oldGo?"debug ":"")+"version: "+oldGo.version+", replaced with version: "+go.version);Diagram.prototype.go=go;root.go=go; + "removedLinkKeys": `;BT(t){const i=new GSet;for(let e=0;e{if(f.model===s){if(f.modelChange==="linkDataArray")f.change===3?n.add(f.newValue):f.change===4&&r.add(f.oldValue);else if(s.containsLinkData(f.object))o.add(f.object);else if(f.object!==null)if(f.object!==null&&l&&l.has(f.object))l.get(f.object).each(d=>{s.containsLinkData(d)&&o.add(d)});else{if(f.object instanceof Model||s.containsNodeData(f.object))return;s.BT(f.object).each(d=>o.add(d))}}});const h=this.og;h.clear(),n.each(f=>{h.add(s.getKeyForLinkData(f)),i||o.add(f)});const a=this.ng;a.clear(),r.each(f=>{a.add(s.getKeyForLinkData(f)),i&&o.add(f)});let c=e;return h.count>0&&(c+=(i?this.VT:this.UT)+this.Ch(h.toArray(),!0)),o.count>0&&(c+=this.DO+this.Ch(o.toArray(),!0)),a.count>0&&(c+=(i?this.UT:this.VT)+this.Ch(a.toArray(),!0)),a.clear(),h.clear(),c}Dy(t){(t.linkCategoryProperty!==void 0&&t.linkCategoryProperty!==this.linkCategoryProperty||t.linkKeyProperty!==void 0&&t.linkKeyProperty!==this.linkKeyProperty||t.linkFromKeyProperty!==void 0&&t.linkFromKeyProperty!==this.linkFromKeyProperty||t.linkToKeyProperty!==void 0&&t.linkToKeyProperty!==this.linkToKeyProperty||t.linkFromPortIdProperty!==void 0&&t.linkFromPortIdProperty!==this.linkFromPortIdProperty||t.linkToPortIdProperty!==void 0&&t.linkToPortIdProperty!==this.linkToPortIdProperty||t.linkLabelKeysProperty!==void 0&&t.linkLabelKeysProperty!==this.linkLabelKeysProperty||t.nodeIsGroupProperty!==void 0&&t.nodeIsGroupProperty!==this.nodeIsGroupProperty||t.nodeGroupKeyProperty!==void 0&&t.nodeGroupKeyProperty!==this.nodeGroupKeyProperty)&&Util.o("applyIncrementalJson cannot change Model properties"),super.Dy(t);const i=t.insertedLinkKeys;if(Array.isArray(i)){const n=i.length;for(let o=0;o=0&&s.splice(e,1)):s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue));return}}else if(t.change===4){let e=t.oldParam;if(t.modelChange==="linkDataArray"){const s=t.oldValue;if(Util.wt(s)&&typeof e=="number"){const n=this.getKeyForLinkData(s);i?(this.sr.add(s),this.$e[e]!==s&&this.$e.splice(e,0,s),n!==void 0&&this.fi.set(n,s)):(this.sr.delete(s),this.$e[e]===s&&this.$e.splice(e,1),n!==void 0&&this.fi.delete(n))}return}else if(t.modelChange==="linkLabelKeys"){const s=this.getLabelKeysForLinkData(t.object);Array.isArray(s)&&typeof e=="number"&&(i?s.indexOf(t.newValue)<0&&s.splice(e,0,t.newValue):(e=s.indexOf(t.newValue),e>=0&&s.splice(e,1)));return}}super.changeState(t,i)}}get archetypeNodeData(){return this.Ll}set archetypeNodeData(t){const i=this.Ll;i!==t&&(t!==null&&Util.i(t,"object",GraphLinksModel,"archetypeNodeData"),this.Ll=t,this.t("archetypeNodeData",i,t))}NN(t){if(t===void 0)return;const i=this.Ll;if(i!==null){let e=this.findNodeDataForKey(t);e===null&&(e=this.copyNodeData(i),Model.rt(e,this.nodeKeyProperty,t),this.addNodeData(e))}return t}get linkFromKeyProperty(){return this.wo}set linkFromKeyProperty(t){const i=this.wo;i!==t&&(this.An(t,GraphLinksModel,"linkFromKeyProperty"),this.wo=t,this.t("linkFromKeyProperty",i,t))}getFromKeyForLinkData(t){return this.Te(t,!0)}setFromKeyForLinkData(t,i){this.Zd(t,i,!0)}get linkToKeyProperty(){return this.xo}set linkToKeyProperty(t){const i=this.xo;i!==t&&(this.An(t,GraphLinksModel,"linkToKeyProperty"),this.xo=t,this.t("linkToKeyProperty",i,t))}getToKeyForLinkData(t){return this.Te(t,!1)}setToKeyForLinkData(t,i){this.Zd(t,i,!1)}Te(t,i){if(t===null)return;const e=i?this.wo:this.xo;if(e==="")return;const s=Model.vt(t,e);if(s!==void 0){if(this.isKeyType(s))return s;Util.o((i?"FromKey":"ToKey")+" value for link data "+t+" is not a number or a string: "+s)}}Zd(t,i,e){if(i===null&&(i=void 0),i!==void 0&&!this.isKeyType(i)&&Util.we(i,"number or string",GraphLinksModel,e?"setFromKeyForLinkData:key":"setToKeyForLinkData:key"),t===null)return;const s=e?this.wo:this.xo;if(s==="")return;if(i=this.NN(i),!this.containsLinkData(t)){Model.rt(t,s,i);return}const n=Model.vt(t,s);n!==i&&(this.Js(n,t),Model.rt(t,s,i),this.findNodeDataForKey(i)===null&&this.$s(i,t),this.Et(e?"linkFromKey":"linkToKey",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkFromPortIdProperty(){return this.Ya}set linkFromPortIdProperty(t){const i=this.Ya;i!==t&&(this.An(t,GraphLinksModel,"linkFromPortIdProperty"),this.Ya=t,this.t("linkFromPortIdProperty",i,t))}getFromPortIdForLinkData(t){return this.L1(t,!0)}setFromPortIdForLinkData(t,i){this.Qd(t,i,!0)}get linkToPortIdProperty(){return this.Ga}set linkToPortIdProperty(t){const i=this.Ga;i!==t&&(this.An(t,GraphLinksModel,"linkToPortIdProperty"),this.Ga=t,this.t("linkToPortIdProperty",i,t))}getToPortIdForLinkData(t){return this.L1(t,!1)}setToPortIdForLinkData(t,i){this.Qd(t,i,!1)}L1(t,i){if(t===null)return"";const e=i?this.Ya:this.Ga;if(e==="")return"";const s=Model.vt(t,e);return s===void 0?"":s}Qd(t,i,e){if(Util.i(i,"string",GraphLinksModel,e?"setFromPortIdForLinkData:portname":"setToPortIdForLinkData:portname"),t===null)return;const s=e?this.Ya:this.Ga;if(s==="")return;if(!this.containsLinkData(t)){Model.rt(t,s,i);return}let n=Model.vt(t,s);n===void 0&&(n=""),n!==i&&(Model.rt(t,s,i),this.Et(e?"linkFromPortId":"linkToPortId",2,s,t,n,i),typeof s=="string"&&this.updateTargetBindings(t,s))}get linkLabelKeysProperty(){return this.Zs}set linkLabelKeysProperty(t){const i=this.Zs;i!==t&&(this.An(t,GraphLinksModel,"linkLabelKeysProperty"),this.Zs=t,this.t("linkLabelKeysProperty",i,t))}getLabelKeysForLinkData(t){if(t===null)return GraphLinksModel.EmptyArray;const i=this.Zs;if(i==="")return GraphLinksModel.EmptyArray;const e=Model.vt(t,i);return e===void 0?GraphLinksModel.EmptyArray:e}setLabelKeysForLinkData(t,i){if(t===null)return;const e=this.Zs;if(e==="")return;if(!this.containsLinkData(t)){Model.rt(t,e,i);return}let s=Model.vt(t,e);if(s===void 0&&(s=GraphLinksModel.EmptyArray),s!==i){if(Array.isArray(s)){const o=s.length;for(let r=0;r=0)return;n=s.length,s.push(i),this.containsLinkData(t)&&(this.findNodeDataForKey(i)===null&&this.$s(i,t),this.Et("linkLabelKeys",3,e,t,null,i,null,n))}else Util.o(e+" property is not an Array; cannot addLabelKeyForLinkData: "+t)}removeLabelKeyForLinkData(t,i){if(i==null||(this.isKeyType(i)||Util.we(i,"number or string",GraphLinksModel,"removeLabelKeyForLinkData:key"),t===null))return;const e=this.Zs;if(e==="")return;const s=Model.vt(t,e);if(Array.isArray(s)){const n=s.indexOf(i);if(n<0)return;s.splice(n,1),this.containsLinkData(t)&&(this.Js(i,t),this.Et("linkLabelKeys",4,e,t,i,null,n,null))}else s!==void 0&&Util.o(e+" property is not an Array; cannot removeLabelKeyforLinkData: "+t)}get linkDataArray(){return this.$e}set linkDataArray(t){const i=this.$e;if(i!==t){this.fi.clear();const e=t.length;for(let n=0;nnew GraphLinksModel;Model.initDiagramModel=Model.initDiagramModel=()=>new GraphLinksModel;class TreeModel extends Model{Dn;ug;Ha;constructor(t,i){if(super(),this.Dn="parent",this.ug=!1,this.Ha="parentLinkCategory",t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:i=t),i){Object.assign(this,i);const e=i.Changed;e&&(delete this.Changed,this.addChangedListener(e))}}cloneProtected(t){super.cloneProtected(t),t.Dn=this.Dn,t.ug=this.ug,t.Ha=this.Ha}toString(t){if(t===void 0&&(t=0),t>=2)return this.toJson();{let i=(this.name!==""?this.name:"")+" TreeModel";if(t>0){i+=` + node data:`;const e=this.nodeDataArray,s=e.length;for(let n=0;n(w[w.ConstantSpacing=0]="ConstantSpacing",w[w.ConstantDistance=1]="ConstantDistance",w[w.ConstantAngle=2]="ConstantAngle",w[w.Packed=3]="Packed",w))(CircularArrangement||{}),CircularDirection=(w=>(w[w.Clockwise=10]="Clockwise",w[w.Counterclockwise=11]="Counterclockwise",w[w.BidirectionalLeft=12]="BidirectionalLeft",w[w.BidirectionalRight=13]="BidirectionalRight",w))(CircularDirection||{}),CircularSorting=(w=>(w[w.Forwards=20]="Forwards",w[w.Reverse=21]="Reverse",w[w.Ascending=22]="Ascending",w[w.Descending=23]="Descending",w[w.Optimized=24]="Optimized",w))(CircularSorting||{}),CircularNodeDiameterFormula=(w=>(w[w.Pythagorean=30]="Pythagorean",w[w.Circular=31]="Circular",w))(CircularNodeDiameterFormula||{});class CircularLayout extends Layout{le;If;B1;dg;U1;Ah;AN;TN;DN;bs;vy;Oy;qa;Iy;XT;gg;mg;pg;Ef;zi;S;pe;ye;Ln;yg;constructor(t){super(),this.le=0,this.If=0,this.B1=0,this.dg=360,this.U1=0,this.Ah=0,this.AN=new Point,this.TN=30,this.DN=0,this.bs=0,this.vy=0,this.Oy=new VertexArrangement,this.qa=0,this.Iy=0,this.XT=600,this.gg=NaN,this.mg=1,this.pg=0,this.Ef=360,this.zi=0,this.S=10,this.pe=24,this.ye=LayoutVertex.standardComparer,this.Ln=6,this.yg=30,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.gg=this.gg,t.mg=this.mg,t.pg=this.pg,t.Ef=this.Ef,t.zi=this.zi,t.S=this.S,t.pe=this.pe,t.ye=this.ye,t.Ln=this.Ln,t.yg=this.yg}ri(t){t in CircularSorting?this.sorting=t:t in CircularDirection?this.direction=t:t in CircularArrangement?this.arrangement=t:t in CircularNodeDiameterFormula?this.nodeDiameterFormula=t:super.ri(t)}createNetwork(){return new CircularNetwork(this)}vO(t,i,e){t=this.OO(t);let s=this.U1,n=this.TN,o=this.le,r=this.If,l=this.B1,h=this.dg,a=this.Ah,c=this.DN,f=this.bs,u=this.vy;if(s=this.arrangement,n=this.nodeDiameterFormula,o=this.radius,(!isFinite(o)||o<=0)&&(o=NaN),r=this.aspectRatio,(!isFinite(r)||r<=0)&&(r=1),l=this.startAngle,isFinite(l)||(l=0),h=this.sweepAngle,(!isFinite(h)||h>360||h<1)&&(h=360),a=this.spacing,isFinite(a)||(a=NaN),s===3&&n===31?s=0:s===3&&n!==31&&(n=31,s=this.arrangement),(this.direction===12||this.direction===13)&&this.sorting!==24){for(let g=0;!(g>=t.length||(i.add(t.elt(g)),g+1>=t.length));g+=2)e.add(t.elt(g+1));this.direction===12?(this.arrangement===3&&i.reverse(),t=new List,t.addAll(i),t.addAll(e)):(this.arrangement===3&&e.reverse(),t=new List,t.addAll(e),t.addAll(i))}const d=t.length;c=0;let m=0;for(let g=0;g1?(o=y,f=o*r):(f=y,o=f)}else o=this.V1(u*(h>=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180)}else o=this.V1(c+(h>=360?d:d-1)*(s!==3?a:a*1.6),r,l*Math.PI/180,h*Math.PI/180);f=o*r}else{f=o*r;const g=this.FN(o,f,l*Math.PI/180,h*Math.PI/180);if(isNaN(a))s===0&&(a=(g-c)/(h>=360?d:d-1));else if(s===0){const p=(g-c)/(h>=360?d:d-1);p=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180),f=o*r):a=p}else{let p=-1/0;for(let k=0;k=360?d:d-1),r,l*Math.PI/180,h*Math.PI/180);x>o?(o=x,f=o*r,u=y):u=g/(h>=360?d:d-1)}}return this.U1=s,this.TN=n,this.le=o,this.If=r,this.B1=l,this.dg=h,this.Ah=a,this.DN=c,this.bs=f,this.vy=u,t}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);const i=this.network.vertexes;if(i.count<=1){if(i.count===1){const u=i.first();u.centerX=0,u.centerY=0}this.updateParts(),this.network=null,this.isValidLayout=!0;return}let e=new List;e.addAll(i.iterator);const s=new List,n=new List;e=this.vO(e,s,n);const o=this.U1,r=this.le,l=this.B1,h=this.dg,a=this.Ah,c=this.bs,f=this.vy;if((this.direction===12||this.direction===13)&&o===3)this.KT(e,h,l-h/2,10);else if(this.direction===12||this.direction===13){let u=0;switch(o){case 1:u=this.z1(r,c,l,f)*180/Math.PI;break;case 0:{let d=0,m=0;const g=s.first();g!==null&&(d=g.Th(Math.PI/2));const p=n.first();p!==null&&(m=p.Th(Math.PI/2)),u=this.z1(r,c,l,a+(d+m)/2)*180/Math.PI;break}case 2:u=h/e.length;break}if(this.direction===12){switch(o){case 1:this.Ey(s,h/2,l,11);break;case 0:this.By(s,h/2,l,11);break;case 2:this.Uy(s,h/2,l,11);break}switch(o){case 1:this.Ey(n,h/2,l+u,10);break;case 0:this.By(n,h/2,l+u,10);break;case 2:this.Uy(n,h/2,l+u,10);break}}else{switch(o){case 1:this.Ey(n,h/2,l,11);break;case 0:this.By(n,h/2,l,11);break;case 2:this.Uy(n,h/2,l,11);break}switch(o){case 1:this.Ey(s,h/2,l+u,10);break;case 0:this.By(s,h/2,l+u,10);break;case 2:this.Uy(s,h/2,l+u,10);break}}}else switch(o){case 1:this.Ey(e,h,l,this.direction);break;case 0:this.By(e,h,l,this.direction);break;case 2:this.Uy(e,h,l,this.direction);break;case 3:this.KT(e,h,l,this.direction);break}this.updateParts(),this.network=null,this.isValidLayout=!0}Uy(t,i,e,s){const n=this.dg,o=this.le,r=this.bs,l=e*Math.PI/180,h=i*Math.PI/180,a=t.length;for(let c=0;c=360?a:a-1):-(c*h)/a),u=t.elt(c),d=o*Math.tan(f)/r,m=Math.sqrt((o*o+r*r*d*d)/(1+d*d));u.centerX=m*Math.cos(f),u.centerY=m*Math.sin(f),u.actualAngle=f*180/Math.PI}}By(t,i,e,s){const n=this.le,o=this.bs,r=this.Ah;let l=e*Math.PI/180;const h=t.length;for(let a=0;a180&&(n-=360),n*=Math.PI/180,this.Iy=n,this.YT(t,i,e,s)}else this.GT(t,i,e,s);this.Oy.commit(t)}GT(t,i,e,s){const n=this.le,o=this.bs,r=this.Ah,l=this.If;let h=n*Math.cos(e*Math.PI/180),a=o*Math.sin(e*Math.PI/180);const c=t.toArray();if(c.length===3){c[0].centerX=n,c[0].centerY=0,c[1].centerX=c[0].centerX-c[0].width/2-c[1].width/2-r,c[1].y=c[0].y,c[2].centerX=(c[0].centerX+c[1].centerX)/2,c[2].y=c[0].y-c[2].height-r;return}else if(c.length===4){c[0].centerX=n,c[0].centerY=0,c[2].centerX=-c[0].centerX,c[2].centerY=c[0].centerY,c[1].centerX=0,c[1].y=Math.min(c[0].y,c[2].y)-c[1].height-r,c[3].centerX=0,c[3].y=Math.max(c[0].y+c[0].height+r,c[2].y+c[2].height+r);return}const f=Point.l();for(let b=0;b=c.length-1));b++)this.jT(h,a,c,b,s,f)||this.HT(h,a,c,b,s,f),h=f.x,a=f.y;if(Point.s(f),this.qa++,this.qa>23)return;const u=c[0].centerX,d=c[0].centerY,m=c[c.length-1].centerX,g=c[c.length-1].centerY;let p=Math.abs(u-m)-((c[0].width+c[c.length-1].width)/2+r);const y=Math.abs(d-g)-((c[0].height+c[c.length-1].height)/2+r);let x=0;if(Math.abs(y)<1){const b=Math.abs(u-m),P=(c[0].width+c[c.length-1].width)/2;b0?x=y:Math.abs(p)<1?x=0:x=p;let k=!1;Math.abs(m)>Math.abs(g)?k=m>0!=d>g:k=g>0!=u1&&(this.qa<8?this.le-=x/(2*Math.PI):c.length<5&&x>10?this.le/=2:this.le-=x>0?1.7:-2.3,this.bs=this.le*l,this.GT(t,i,e,s))}YT(t,i,e,s){const n=this.le,o=this.bs,r=this.If;let l=n*Math.cos(e*Math.PI/180),h=o*Math.sin(e*Math.PI/180);const a=Point.l(),c=t.toArray();for(let m=0;m=c.length-1));m++)this.jT(l,h,c,m,s,a)||this.HT(l,h,c,m,s,a),l=a.x,h=a.y;if(Point.s(a),this.qa++,this.qa>23)return;const f=Math.atan2(h,l);let u=s===10?this.Iy-f:f-this.Iy;u=Math.abs(u)1&&(this.qa<8?this.le-=d/(2*Math.PI):this.le-=d>0?1.7:-2.3,this.bs=this.le*r,this.YT(t,i,e,s))}jT(t,i,e,s,n,o){const r=this.Ah,l=this.le,h=this.bs;let a=0,c=0;const f=(e[s].width+e[s+1].width)/2+r;let u=!1;if(i>=0!=(n===10)){if(a=t+f,a>l){if(a=t-f,a<-l)return o.x=a,o.y=c,!1;u=!0}}else if(a=t-f,a<-l){if(a=t+f,a>l)return o.x=a,o.y=c,!1;u=!0}return c=Math.sqrt(1-Math.min(1,a*a/(l*l)))*h,i<0!==u&&(c=-c),Math.abs(i-c)>(e[s].height+e[s+1].height)/2?(o.x=a,o.y=c,!1):(o.x=a,o.y=c,!0)}HT(t,i,e,s,n,o){const r=this.Ah,l=this.le,h=this.bs;let a=0,c=0;const f=(e[s].height+e[s+1].height)/2+r;let u=!1;if(t>=0!=(n===10)){if(c=i-f,c<-h){if(c=i+f,c>h)return o.x=a,o.y=c,!1;u=!0}}else if(c=i+f,c>h){if(c=i-f,c<-h)return o.x=a,o.y=c,!1;u=!0}return a=Math.sqrt(1-Math.min(1,c*c/(h*h)))*l,t<0!==u&&(a=-a),Math.abs(t-a)>(e[s].width+e[s+1].width)/2?(o.x=a,o.y=c,!1):(o.x=a,o.y=c,!0)}commitLayout(){this.commitNodes(),this.isRouting&&this.commitLinks()}commitNodes(){const t=this.group!==null&&this.group.hasPlaceholder(),i=t?this.group.location.copy():null;let e=this.actualCenter;t?e=new Point(0,0):(e.x=this.arrangementOrigin.x+this.le,e.y=this.arrangementOrigin.y+this.bs);const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;n.x+=e.x,n.y+=e.y,n.commit()}if(t){this.group.ensureBounds();const n=this.group.position.copy(),o=this.group.location.copy(),r=i.subtract(o.subtract(n));this.group.move(r),this.AN=r.subtract(n)}}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}FN(t,i,e,s){const n=this.XT;if(Math.abs(this.If-1)<.001)return e!==void 0&&s!==void 0?s*t:2*Math.PI*t;const o=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let r=0,l=0;e!==void 0&&s!==void 0?l=s/(n+1):l=Math.PI/(2*(n+1));let h=0;for(let a=0;a<=n;a++){e!==void 0&&s!==void 0?h=e+a*s/n:h=a*Math.PI/(2*n);const c=Math.sin(h);r+=Math.sqrt(1-o*o*c*c)*l}return e!==void 0&&s!==void 0?(t>i?t:i)*r:4*(t>i?t:i)*r}V1(t,i,e,s){let n=0;return e!==void 0&&s!==void 0?n=this.FN(1,i,e,s):n=this.FN(1,i),t/n}z1(t,i,e,s){if(Math.abs(this.If-1)<.001)return s/t;const n=t>i?Math.sqrt(t*t-i*i)/t:Math.sqrt(i*i-t*t)/i;let o=0;const r=2*Math.PI/(this.network.vertexes.count*700);t>i&&(e+=Math.PI/2);for(let l=0;;l++){const h=e+l*r,a=Math.sin(h);if(o+=(t>i?t:i)*Math.sqrt(1-n*n*a*a)*r,o>=s)return l*r}}OO(t){switch(this.sorting){case 20:break;case 21:t.reverse();break;case 22:t.sort(this.comparer);break;case 23:t.sort(this.comparer),t.reverse();break;case 24:return this.BO(this.UO(t));default:Util.o("Invalid sorting type.")}return t}UO(t){const i=[];for(let s=0;sn&&(n=u,o=c)}else for(let c=0;cn&&(n=f,o=c)}e.add(t.elt(o)),i[o]=-1;const r=t.elt(o);let l=0;const h=r.sourceEdges;for(;h.next();){const f=h.value.fromVertex;l=t.indexOf(f),!(l<0)&&i[l]>=0&&i[l]++}const a=r.destinationEdges;for(;a.next();){const f=a.value.toVertex;l=t.indexOf(f),!(l<0)&&i[l]>=0&&i[l]++}}return e}BO(t){const i=[];for(let f=0;f=0){const C=Math.abs(x-(L>=x?L+1:L));b+=C=x&&S++,L>=x&&L++,S>L){const C=L;L=S,S=C}L-S<(s.length+2)/2==(S=0&&(n.push(f),o.push(x))}h++}let a=!1;const c=s.length;for(;;){a=!0;for(let f=0;f=0){let g=0;for(let p=0;pm?x-m:m-x,b=c-k;g+=xb?1:-1}s.splice(g<0?m:m+1,0,u),r.splice(f,1),f--}else a=!1}if(a)break;s.push(r[0]),r.splice(0,1)}for(let f=0;f0||isNaN(t))&&(this.gg=t,this.invalidateLayout()))}get aspectRatio(){return this.mg}set aspectRatio(t){this.mg!==t&&(Util.i(t,"number",CircularLayout,"aspectRatio"),t>0&&(this.mg=t,this.invalidateLayout()))}get startAngle(){return this.pg}set startAngle(t){this.pg!==t&&(Util.i(t,"number",CircularLayout,"startAngle"),this.pg=t,this.invalidateLayout())}get sweepAngle(){return this.Ef}set sweepAngle(t){this.Ef!==t&&(Util.i(t,"number",CircularLayout,"sweepAngle"),t>0&&t<=360?this.Ef=t:this.Ef=360,this.invalidateLayout())}get arrangement(){return this.zi}set arrangement(t){this.zi!==t&&(t===3||t===0||t===1||t===2)&&(this.zi=t,this.invalidateLayout())}get direction(){return this.S}set direction(t){this.S!==t&&(t===10||t===11||t===12||t===13)&&(this.S=t,this.invalidateLayout())}get sorting(){return this.pe}set sorting(t){this.pe!==t&&(this.pe=t,this.invalidateLayout())}get comparer(){return this.ye}set comparer(t){this.ye!==t&&(Util.i(t,"function",CircularLayout,"comparer"),this.ye=t,this.invalidateLayout())}get spacing(){return this.Ln}set spacing(t){this.Ln!==t&&(Util.i(t,"number",CircularLayout,"spacing"),this.Ln=t,this.invalidateLayout())}get nodeDiameterFormula(){return this.yg}set nodeDiameterFormula(t){this.yg!==t&&(t===30||t===31)&&(this.yg=t,this.invalidateLayout())}get actualXRadius(){return this.le}get actualYRadius(){return this.bs}get actualSpacing(){return this.Ah}get actualCenter(){return this.AN}static ConstantSpacing=0;static ConstantDistance=1;static ConstantAngle=2;static Packed=3;static Clockwise=10;static Counterclockwise=11;static BidirectionalLeft=12;static BidirectionalRight=13;static Forwards=20;static Reverse=21;static Ascending=22;static Descending=23;static Optimized=24;static Pythagorean=30;static Circular=31}class VertexArrangement{Bf;Wa;Uf;constructor(){this.Bf=-1/0,this.Wa=null,this.Uf=null}IO(t,i){if(t>0&&this.Bf<0||Math.abs(t)0)){this.Bf=t,this.Wa=[],this.Uf=[];for(let e=0;e0){for(this.network.deleteSelfEdges(),i=this.network.vertexes.iterator;i.next();){const o=i.value;o.charge=this.electricalCharge(o),o.mass=this.gravitationalMass(o)}const s=this.network.edges.iterator;for(;s.next();){const o=s.value;o.stiffness=this.springStiffness(o),o.length=this.springLength(o)}if(this.RN(),this.Dh=0,this.needsPrelayout()){const o=this.network,r=o.splitIntoSubNetworks(!1);let l=r.iterator;for(;l.next();){const h=l.value;this.doConnectedSubnetLayout(h)}for(l=r.iterator,this.zO(l,o),l=r.iterator;l.next();){const h=l.value,a=h.vertexes.iterator;for(;a.next();){const f=a.value;o.addVertex(f)}const c=h.edges.iterator;for(;c.next();){const f=c.value;o.addEdge(f)}}}else this.qT(this.network,this.maxIterations);this.updateParts()}this.maxIterations=e,this.isValidLayout=!0}needsPrelayout(){if(this.network.vertexes.count<3)return!1;let t=0,i=0;const e=this.network.vertexes.first().bounds,s=this.network.vertexes.iterator;for(;s.next();){const n=s.value,o=n.bounds;if(isNaN(n.x)||isNaN(n.y)||o.intersectsRect(e)&&(t++,t>2))return!0;if(i>10)return!1;i++}return!1}doConnectedSubnetLayout(t){let i=t.vertexes.iterator;for(;i.next();){const l=i.value;l.hierarchicalVertexes.add(l)}let e=t,s=this.Gf;if(isNaN(s)&&(s=t.edges.count/t.vertexes.count),sMath.max(100,Math.sqrt(s*t.vertexes.count));)e=this.coarsenNetwork(e);let n=0;i=e.vertexes.iterator;let o=this.randomNumberGenerator;for(o===null&&(this.randomNumberGenerator=o=new RandomNumberGenerator(0));i.next();){i.value.idInCluster=n++;const l=10*(o.random()-.5),h=10*(o.random()-.5);this.isFixed(i.value)||(i.value.x=l,i.value.y=h);const a=i.value.hierarchicalVertexes.iterator;for(;a.next();)this.isFixed(a.value)||(a.value.x=l,a.value.y=h)}const r=this.computePairwiseDistances(e);this.XO(e,r,this.maxPrelayoutIterations,t.vertexes.count),this.qT(t,this.maxIterations)}computePairwiseDistances(t){const i=t.vertexes.count,e=new Array(i);for(let r=0;r0;){const l=o.shift(),h=l.vertexes.iterator;for(;h.next();){const a=h.value;n.has(a.idInCluster)||(n.set(a.idInCluster,n.get(l.idInCluster)+1),o.push(a))}}for(let l=0;l=0;m--)if(t[m].y>c.y&&t[m].x-c.xc.x&&t[m].y-c.ya+f){const u=s+o-h,d=n-a-f;return Geo.bw(u*u+d*d)}else if(n+rh+c)if(n>a+f){const u=s-h-c,d=n-a-f;return Geo.bw(u*u+d*d)}else if(n+ra+f?n-(a+f):n+rr-o;l?i.sort((m,g)=>m===null||g===null||m===g?0:m.centerX-g.centerX):i.sort((m,g)=>m===null||g===null||m===g?0:m.centerY-g.centerY);const h=this.Vf;let a=0,c=0,f=0;for(let m=0;mh||C-x>h){if(l)break;continue}if(k-M>h||M-k>h){if(!l)break;continue}const N=this.vN(g,P),T=2*g.charge,A=2*P.charge;if(N>1)a=T*A/(N*N),c=a*(x-C)/N,f=a*(k-M)/N;else{let D=this.randomNumberGenerator;D===null&&(this.randomNumberGenerator=D=new RandomNumberGenerator(0));const F=D.random(),R=D.random();if(x>C)c=Math.abs(P.bounds.right-g.bounds.x),c=T*A*(1+c)*F;else if(xM)f=Math.abs(P.bounds.bottom-g.bounds.y),f=T*A*(1+f)*R;else if(x1&&(a=.1*m.stiffness*(M-m.length),c=a*.5*(g.width+p.height)*(k-L)/M,f=a*.5*(g.width+p.height)*(b-C)/M),g.forceX-=c,g.forceY-=f,p.forceX+=c,p.forceY+=f}let d=0;for(let m=0;mthis.epsilonDistance*this.epsilonDistance}XO(t,i,e,s){const n=this.Dh+e,o=Math.sqrt(s);this.Vy=this.Ja*t.vertexes.count;const r=t.vertexes.toArray();let l=0,h=0,a=0;for(;this.Dh0){r[c].forceX=this.Vy*r[c].forceX/f,r[c].forceY=this.Vy*r[c].forceY/f,this.isFixed(r[c])||(r[c].x+=r[c].forceX,r[c].y+=r[c].forceY);const u=r[c].hierarchicalVertexes.iterator;for(;u.next();){const d=u.value;this.isFixed(d)||(d.centerX+=r[c].forceX,d.centerY+=r[c].forceY)}}l+=f*f}if(l>=h){if(a++,a>=5)break}else a=0;this.Vy*=.95}}moveVertex(t){let i=t.forceX,e=t.forceY;const s=this.moveLimit;return i<-s?i=-s:i>s&&(i=s),e<-s?e=-s:e>s&&(e=s),t.centerX+=i,t.centerY+=e,i*i+e*e}shouldInteract(t,i){return!0}moveFixedVertex(t){}commitLayout(){this.zy(),this.commitNodes(),this.isRouting&&this.commitLinks()}zy(){if(!this.setsPortSpots)return;const t=this.network.edges.iterator;for(;t.next();){const e=t.value.link;e!==null&&(e.fromSpot=Spot.Default,e.toSpot=Spot.Default)}}commitNodes(){let t=0,i=0;if(this.arrangesToOrigin){const n=Rect.l();this.Nw(this.network,n);const o=this.arrangementOrigin;t=o.x-n.x,i=o.y-n.y,Rect.s(n)}const e=Rect.l(),s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;(t!==0||i!==0)&&(e.a(n.bounds),e.x+=t,e.y+=i,n.bounds=e),n.commit()}Rect.s(e)}commitLinks(){const t=this.network.edges.iterator;for(;t.next();)t.value.commit()}springStiffness(t){const i=t.stiffness;return isNaN(i)?this.zf:i}springLength(t){const i=t.length;return isNaN(i)?this.Xf:i}electricalCharge(t){const i=t.charge;return isNaN(i)?this.Kf:i}electricalFieldX(t,i){return 0}electricalFieldY(t,i){return 0}gravitationalMass(t){const i=t.mass;return isNaN(i)?this.Yf:i}gravitationalFieldX(t,i){return 0}gravitationalFieldY(t,i){return 0}isFixed(t){return t.isFixed}get currentIteration(){return this.Dh}get arrangementSpacing(){return this.ks}set arrangementSpacing(t){this.ks.equals(t)||(this.ks.a(t),this.invalidateLayout())}get arrangesToOrigin(){return this.wg}set arrangesToOrigin(t){this.wg!==t&&(Util.i(t,"boolean",ForceDirectedLayout,"arrangesToOrigin"),this.wg=t,this.invalidateLayout())}get setsPortSpots(){return this.Fn}set setsPortSpots(t){this.Fn!==t&&(Util.i(t,"boolean",ForceDirectedLayout,"setsPortSpots"),this.Fn=t,this.invalidateLayout())}get comments(){return this.Re}set comments(t){this.Re!==t&&(Util.i(t,"boolean",ForceDirectedLayout,"comments"),this.Re=t,this.invalidateLayout())}get maxPrelayoutIterations(){return this.xg}set maxPrelayoutIterations(t){this.xg!==t&&(Util.i(t,"number",ForceDirectedLayout,"maxPrelayoutIterations"),t>=0&&(this.xg=t,this.invalidateLayout()))}get maxIterations(){return this.bg}set maxIterations(t){this.bg!==t&&(Util.i(t,"number",ForceDirectedLayout,"maxIterations"),t>=0&&(this.bg=t,this.invalidateLayout()))}get epsilonDistance(){return this.kg}set epsilonDistance(t){this.kg!==t&&(Util.i(t,"number",ForceDirectedLayout,"epsilonDistance"),t>0&&(this.kg=t,this.invalidateLayout()))}get infinityDistance(){return this.Vf}set infinityDistance(t){this.Vf!==t&&(Util.i(t,"number",ForceDirectedLayout,"infinityDistance"),t>1&&(this.Vf=t,this.invalidateLayout()))}get moveLimit(){return this.Pg}set moveLimit(t){this.Pg!==t&&(Util.i(t,"number",ForceDirectedLayout,"moveLimit"),this.Pg=t,this.invalidateLayout())}get randomNumberGenerator(){return this.Sg}set randomNumberGenerator(t){this.Sg!==t&&(t!==null&&typeof t.random!="function"&&Util.o('ForceDirectedLayout.randomNumberGenerator must have a "random()" function on it: '+t),this.Sg=t)}get defaultSpringStiffness(){return this.zf}set defaultSpringStiffness(t){this.zf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultSpringStiffness"),this.zf=t,this.invalidateLayout())}get defaultSpringLength(){return this.Xf}set defaultSpringLength(t){this.Xf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultSpringLength"),this.Xf=t,this.invalidateLayout())}get defaultElectricalCharge(){return this.Kf}set defaultElectricalCharge(t){this.Kf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultElectricalCharge"),this.Kf=t,this.invalidateLayout())}get defaultGravitationalMass(){return this.Yf}set defaultGravitationalMass(t){this.Yf!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultGravitationalMass"),this.Yf=t,this.invalidateLayout())}get defaultCommentSpringLength(){return this.Mg}set defaultCommentSpringLength(t){this.Mg!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultCommentSpringLength"),this.Mg=t,this.invalidateLayout())}get defaultCommentElectricalCharge(){return this.Ng}set defaultCommentElectricalCharge(t){this.Ng!==t&&(Util.i(t,"number",ForceDirectedLayout,"defaultCommentElectricalCharge"),this.Ng=t,this.invalidateLayout())}get prelayoutQuality(){return this.Gf}set prelayoutQuality(t){this.Gf!==t&&(Util.i(t,"number",ForceDirectedLayout,"prelayoutQuality"),this.Gf=t,this.invalidateLayout())}get prelayoutSpread(){return this.Ja}set prelayoutSpread(t){this.Ja!==t&&(Util.i(t,"number",ForceDirectedLayout,"prelayoutSpread"),this.Ja=t,this.invalidateLayout())}}class ForceDirectedNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new ForceDirectedVertex(this)}createEdge(){return new ForceDirectedEdge(this)}}class ForceDirectedVertex extends LayoutVertex{K1;Y1;G1;j1;H1;hierarchicalVertexes;idInCluster;constructor(t){super(t),this.K1=!1,this.Y1=NaN,this.G1=NaN,this.j1=0,this.H1=0,this.hierarchicalVertexes=new List,this.idInCluster=-1}get isFixed(){return this.K1}set isFixed(t){this.K1!==t&&(Util.i(t,"boolean",ForceDirectedVertex,"isFixed"),this.K1=t)}get charge(){return this.Y1}set charge(t){this.Y1!==t&&(Util.i(t,"number",ForceDirectedVertex,"charge"),this.Y1=t)}get mass(){return this.G1}set mass(t){this.G1!==t&&(Util.i(t,"number",ForceDirectedVertex,"mass"),this.G1=t)}get forceX(){return this.j1}set forceX(t){this.j1!==t&&(Util.i(t,"number",ForceDirectedVertex,"forceX"),this.j1=t)}get forceY(){return this.H1}set forceY(t){this.H1!==t&&(Util.i(t,"number",ForceDirectedVertex,"forceY"),this.H1=t)}}class ForceDirectedEdge extends LayoutEdge{q1;W1;constructor(t){super(t),this.q1=NaN,this.W1=NaN}get stiffness(){return this.q1}set stiffness(t){this.q1!==t&&(Util.i(t,"number",ForceDirectedEdge,"stiffness"),this.q1=t)}get length(){return this.W1}set length(t){this.W1!==t&&(Util.i(t,"number",ForceDirectedEdge,"length"),this.W1=t)}}class RandomNumberGenerator{I;R;Q;M;A;seed;constructor(t){t===void 0&&(t=42),this.seed=t,this.A=48271,this.M=2147483647,this.Q=this.M/this.A,this.R=this.M%this.A,this.I=1/this.M,this.random()}random(){const t=this.seed/this.Q,i=this.seed%this.Q,e=this.A*i-this.R*t;return e>0?this.seed=e:this.seed=e+this.M,this.seed*this.I}}var LayeredDigraphCycleRemove=(w=>(w[w.DepthFirst=0]="DepthFirst",w[w.Greedy=1]="Greedy",w[w.FromLayers=2]="FromLayers",w))(LayeredDigraphCycleRemove||{}),LayeredDigraphLayering=(w=>(w[w.OptimalLinkLength=10]="OptimalLinkLength",w[w.LongestPathSink=11]="LongestPathSink",w[w.LongestPathSource=12]="LongestPathSource",w))(LayeredDigraphLayering||{}),LayeredDigraphInit=(w=>(w[w.DepthFirstOut=20]="DepthFirstOut",w[w.DepthFirstIn=21]="DepthFirstIn",w[w.Naive=22]="Naive",w))(LayeredDigraphInit||{}),LayeredDigraphAggressive=(w=>(w[w.None=30]="None",w[w.Less=31]="Less",w[w.More=32]="More",w))(LayeredDigraphAggressive||{}),LayeredDigraphPack=(w=>(w[w.None=0]="None",w[w.Expand=1]="Expand",w[w.Straighten=2]="Straighten",w[w.Median=4]="Median",w[w.MaybeExpand=8]="MaybeExpand",w[w.All=15]="All",w))(LayeredDigraphPack||{}),LayeredDigraphAlign=(w=>(w[w.None=0]="None",w[w.UpperLeft=1]="UpperLeft",w[w.UpperRight=2]="UpperRight",w[w.LowerLeft=4]="LowerLeft",w[w.LowerRight=8]="LowerRight",w[w.All=15]="All",w))(LayeredDigraphAlign||{});class LayeredDigraphLayout extends Layout{Ps;Ji;S;jf;Hf;qf;$a;Wf;nr;Jf;Fn;St;Xy;Kt;Cg;Ss;ui;Qs;Ms;Ns;Ut;Lg;Za;Ag;_s;$f;or;Rn;vn;ON;constructor(t){super(),this.Ps=25,this.Ji=25,this.S=0,this.jf=0,this.Hf=10,this.qf=20,this.$a=4,this.Wf=31,this.nr=15,this.Jf=10,this.Fn=!0,this.St=-1,this.Xy=-1,this.Kt=-1,this.Cg=0,this.Ss=0,this.ui=null,this.Qs=null,this.Ms=null,this.Ns=null,this.Ut=null,this.Lg=0,this.Za=null,this.Ag=null,this._s=0,this.$f=null,this.or=new Point,this.Rn=[],this.Rn.length=100,this.vn=15,this.ON=0,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Ps=this.Ps,t.Ji=this.Ji,t.S=this.S,t.jf=this.jf,t.Hf=this.Hf,t.qf=this.qf,t.$a=this.$a,t.Wf=this.Wf,t.nr=this.nr,t.Jf=this.Jf,t.Fn=this.Fn,t.vn=this.vn}ri(t){t in LayeredDigraphAggressive?this.aggressiveOption=t:t in LayeredDigraphCycleRemove?this.cycleRemoveOption=t:t in LayeredDigraphInit?this.initializeOption=t:t in LayeredDigraphLayering?this.layeringOption=t:super.ri(t)}createNetwork(){return new LayeredDigraphNetwork(this)}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin),this.YO(),this.network.vertexes.count>0&&(this.network.deleteSelfEdges(),this.cycleRemoveOption!==2&&this.removeCycles(),this.GO(),this.cycleRemoveOption===2&&this.removeCycles(),this.jO(),this.HO(),this.qO(),this.reduceCrossings(),this.straightenAndPack(),this.updateParts()),this.network=null,this.isValidLayout=!0}linkMinLength(t){return 1}linkLengthWeight(t){return 1}linkStraightenWeight(t){const i=t.fromVertex.node||t.fromVertex.data,e=t.toVertex.node||t.toVertex.data;return i===null&&e===null?8:i===null||e===null?4:1}nodeMinLayerSpace(t,i){return t.node===null&&t.data===null?0:this.S===90||this.S===270?i?t.focus.y+10:t.bounds.height-t.focus.y+10:i?t.focus.x+10:t.bounds.width-t.focus.x+10}nodeMinColumnSpace(t,i){if(t.node===null&&t.data===null)return 0;const e=i?t.J1:t.$1;if(e!==null)return e;const s=this.S;return s===90||s===270?i?t.J1=t.focus.x/this.Ji+1|0:t.$1=(t.bounds.width-t.focus.x)/this.Ji+1|0:i?t.J1=t.focus.y/this.Ji+1|0:t.$1=(t.bounds.height-t.focus.y)/this.Ji+1|0}$i(){this.Za===null&&(this.Za=[]);let t=0;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;this.Za[t]=e.layer,t++,this.Za[t]=e.column,t++,this.Za[t]=e.index,t++}return this.Za}Ze(t){let i=0;const e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;s.layer=t[i],i++,s.column=t[i],i++,s.index=t[i],i++}}JT(t,i){const e=this.Fh(t),s=this.ui[t];(this.Ag===null||this.Ag.length=0){for(c=e[o].po,f=0;fk||d===k&&g>P)&&r++,bd||k===d&&P>g)&&r++)}if(i<=0){for(c=e[o].ir,f=0;fk||d===k&&m>b)&&r++,Pd||k===d&&b>m)&&r++)}for(n[o*s+o]=r,a=o+1;a=0){for(p=e[o].po,S=e[a].po,f=0;f=0&&(h=s[r].ir);let a,c=0,f=0;if(l!==null)for(let u=0;u=0&&(h=r.ir);let a=0,c=0;const f=r.near;f!==null&&f.layer===r.layer&&(a+=f.column-1,c++);let u;if(l!==null)for(let d=0;d=0&&(h=r.ir);let a=0;const c=[],f=r.near;f!==null&&f.layer===r.layer&&(c[a]=f.column-1,a++);let u;if(l!==null)for(let d=0;dm-g);const d=a>>1;a&1?n[o]=c[d]:n[o]=c[d-1]+c[d]>>1}}return this.Rh(t,e),n}Gy(t,i,e,s,n){if(t.component===e){t.component=i;let o=0,r=0;if(s){const l=t.destinationEdges;for(;l.next();){const h=l.value,a=h.toVertex;o=t.layer-a.layer,r=this.linkMinLength(h),o===r&&this.Gy(a,i,e,s,n)}}if(n){const l=t.sourceEdges;for(;l.next();){const h=l.value,a=h.fromVertex;o=a.layer-t.layer,r=this.linkMinLength(h),o===r&&this.Gy(a,i,e,s,n)}}}}IN(t,i,e,s,n){if(t.component===e){if(t.component=i,s){const o=t.destinationEdges;for(;o.next();){const l=o.value.toVertex;this.IN(l,i,e,s,n)}}if(n){const o=t.sourceEdges;for(;o.next();){const l=o.value.fromVertex;this.IN(l,i,e,s,n)}}}}removeCycles(){const t=this.network.edges.iterator;for(;t.next();){const i=t.value;i.rev=!1}switch(this.jf){default:case 1:this.JO();break;case 0:this.$O();break;case 2:this.ZO();break}}ZO(){const t=this.network,i=t.vertexes.iterator;let e=1/0;for(;i.next();){const s=i.value;e=Math.min(e,s.layer)}if(e<1/0){if(e<0)for(i.reset();i.next();){const r=i.value;r.layer-=e}const s=[];for(i.reset();i.next();){const r=i.value,l=s[r.layer];l===void 0?s[r.layer]=[r]:l.push(r)}let n=0;for(let r=0;r0)for(let h=0;hh.index&&(t.reverseEdge(r),r.rev=!0)}}QO(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.Zi)return e}return null}ZT(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.Zi){let s=!0;const n=e.destinationEdges;for(;n.next();)if(n.value.toVertex.Zi){s=!1;break}if(s)return e}}return null}QT(t){const i=t.vertexes.iterator;for(;i.next();){const e=i.value;if(e.Zi){let s=!0;const n=e.sourceEdges;for(;n.next();)if(n.value.fromVertex.Zi){s=!1;break}if(s)return e}}return null}_O(t){let i=null,e=0;const s=this.network.vertexes.iterator;for(;s.next();){const n=s.value;if(n.Zi){let o=0;const r=n.destinationEdges;for(;r.next();)r.value.toVertex.Zi&&o++;let l=0;const h=n.sourceEdges;for(;h.next();)h.value.fromVertex.Zi&&l++;(i===null||ec&&this.Gy(h,e,-1,!0,!1)}for(this.Gy(t,s,-1,!0,!0);t.component!==e;){let r=0,l=1/0,h=0,a=null;const c=this.network.vertexes.iterator;for(;c.next();){const f=c.value;if(f.component===s){let u=0,d=!1;const m=f.po;o=m.length;for(let p=0;p0){for(i.reset();i.next();){const f=i.value;f.component===s&&(f.layer+=l)}t.component=e}else a.component=e}}sI(t){const i=this.network.vertexes.iterator;for(;i.next();){const n=i.value;n.component=-1}const e=0,s=1;for(this.Gy(t,s,-1,!0,!1);t.component!==e;){let n=0,o=1/0,r=0,l=null;const h=this.network.vertexes.iterator;for(;h.next();){const a=h.value;if(a.component===s){let c=0,f=!1;const u=a.po;let d=u.length;for(let g=0;gr)&&!f&&(l=a,r=c)}}if(n<0){for(i.reset();i.next();){const a=i.value;a.component===s&&(a.layer-=o)}t.component=e}else l.component=e}}jO(){const t=this.network,i=[],e=t.edges.iterator;for(;e.next();){const s=e.value;s.valid=!1,i.push(s)}for(let s=0;sb&&f>0){for(n.valid=!1,y=t.createVertex(),y.node=null,y.Q1=2,y.layer=f-1,x&&kb&&f>0;)y=t.createVertex(),y.node=null,y.Q1=3,y.layer=f-1,x&&kt[this.Ss]&&(this.Xy=t[e]-1,this.Ss=e),t[e]{o.index=this.ui[s],this.ui[s]++})}}lI(){let t=null;const i=this.network.vertexes.iterator;for(;i.next();){const e=i.value;if(e.near&&(t===null&&(t=new Map),e.layer===e.near.layer)){const s=t.get(e.near)||[];s.push(e),t.set(e.near,s)}}for(let e=this.St;e>=0;e--)for(i.reset();i.next();){const s=i.value;s.layer===e&&s.index===-1&&this.oD(s,t)}}oD(t,i){if(t.near)return;const e=t.layer;if(t.index=this.ui[e],this.ui[e]++,i){const o=i.get(t);Array.isArray(o)&&o.forEach(r=>{r.index=this.ui[e],this.ui[e]++})}const s=t.ir;let n=!0;for(;n;){n=!1;for(let o=0;ol.portFromColOffset&&(n=!0,s[o]=l,s[o+1]=r)}}for(let o=0;o{a.index=this.ui[e],this.ui[e]++})}const s=t.po;let n=!0,o=0;for(;n;)for(n=!1,o=0;oa.portToColOffset&&(n=!0,s[o]=a,s[o+1]=h)}let r,l;for(o=0;o=0;s--)this.tk(s,-1),this.ls(s,-1,!1,-1);n=this.countCrossings(),n=0;s--)this.tk(s,0),this.ls(s,0,!1,0);n=this.countCrossings(),n=0;r--)for(l=0;l<=r;l++){for(o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,1,!1,1)||o;for(n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,-1,!1,-1)||o;for(n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,0,!1,0)||o;for(n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,0,!1,0)||o;n>=t?this.Ze(i):(t=n,i=this.$i())}break;default:case 31:for(r=this.St,l=0,h=t+1;(a=this.countCrossings())=l;s--)o=this.ls(s,-1,!1,-1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,1,!1,1)||o;for(n=this.countCrossings(),n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,1,!1,1)||o;for(n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,-1,!1,-1)||o;for(n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=r;s>=l;s--)o=this.ls(s,0,!1,0)||o;for(n>=t?this.Ze(i):(t=n,i=this.$i()),o=!0;o;)for(o=!1,s=l;s<=r;s++)o=this.ls(s,0,!1,0)||o;n>=t?this.Ze(i):(t=n,i=this.$i())}break}this.Ze(i)}tk(t,i){let e=0,s=!1;const n=this.Fh(t),o=this.ui[t],r=this.$T(t,i),l=this.Yy(t,i);for(e=0;e0)for(h=[],l=0;ll+1&&(m+=4*(v-l),g+=4*(v-(l+1)))}}const E=n[l].destinationEdges.iterator;if(e&&s>=0)for(;E.next();){const q=E.value;O=q.toVertex,q.valid&&O.layer!==t&&(N=this.linkStraightenWeight(q),T=q.portFromColOffset,A=q.portToColOffset,F=O.column,C+=(Math.abs(p+T-(F+A))+1)*N,M+=(Math.abs(L+T-(F+A))+1)*N)}for(E.reset();E.next();){const q=E.value;if(O=q.toVertex,q.valid&&O.layer===t){for(B=0;Bl+1&&(m+=4*(v-(l+1)),g+=4*(v-l))}}const U=n[l+1].destinationEdges.iterator;if(e&&s>=0)for(;U.next();){const q=U.value;O=q.toVertex,q.valid&&O.layer!==t&&(N=this.linkStraightenWeight(q),T=q.portFromColOffset,A=q.portToColOffset,F=O.column,C+=(Math.abs(y+T-(F+A))+1)*N,M+=(Math.abs(S+T-(F+A))+1)*N)}for(U.reset();U.next();){const q=U.value;if(O=q.toVertex,q.valid&&O.layer===t){for(B=0;B1e3&&s&&(e=!1),e){const n=[];let o=0;for(o=0;o<=this.St;o++)n[o]=0;let r=0;const l=this.network.vertexes.iterator;for(;l.next();){const a=l.value;t=a.layer,r=a.column;const c=this.nodeMinColumnSpace(a,!1);n[t]=Math.max(n[t],r+c)}const h=8;for(l.reset();l.next();){const a=l.value;t=a.layer,r=a.column,a.column=((this.Kt-n[t])*h>>1)+r*h}this.Kt*=h}if(this.nr&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Tg(t,-1)||i;i=this.Tg(this.Ss,0)||i,n++}}if(this.nr&4){for(t=this.Ss+1;t<=this.St;t++)this.BN(t,1);for(t=this.Ss-1;t>=0;t--)this.BN(t,-1);this.BN(this.Ss,0)}if(e&&(this.lD(-1),this.lD(1)),this.nr&2){i=!0;let n=0;for(;i&&n=0;t--)i=this.Tg(t,0)||i;n++}}}Tg(t,i){let e=!1;for(;this.cI(t,i);)e=!0;return e}cI(t,i){let e=0;const s=this.Fh(t),n=this.ui[t],o=this.Yy(t,-1);if(i>0)for(e=0;ec+this.nodeMinColumnSpace(s[e-1],!1)?u=a-1:u=a;let d=0;e+1>=n||s[e+1].column-a-1>f+this.nodeMinColumnSpace(s[e+1],!0)?d=a+1:d=a;let m=0,g=0,p=0,y=0,x=0,k=0;if(i<=0){const M=s[e].sourceEdges.iterator;for(;M.next();){const N=M.value,T=N.fromVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const A=T.column;m+=(Math.abs(a+k-(A+x))+1)*y,g+=(Math.abs(u+k-(A+x))+1)*y,p+=(Math.abs(d+k-(A+x))+1)*y}}}if(i>=0){const M=s[e].destinationEdges.iterator;for(;M.next();){const N=M.value,T=N.toVertex;if(N.valid&&T.layer!==t){y=this.linkStraightenWeight(N),x=N.portFromColOffset,k=N.portToColOffset;const A=T.column;m+=(Math.abs(a+x-(A+k))+1)*y,g+=(Math.abs(u+x-(A+k))+1)*y,p+=(Math.abs(d+x-(A+k))+1)*y}}}let b=0,P=0,S=0;const L=o[s[e].index],C=r[s[e].index];L!==-1&&(b+=Math.abs(L-a),P+=Math.abs(L-u),S+=Math.abs(L-d)),C!==-1&&(b+=Math.abs(C-a),P+=Math.abs(C-u),S+=Math.abs(C-d)),g=r[e]?u=p:g<=r[e]&&(u=g)),u!==a&&(l=!0,h=!0,s[e].column=u)}return this.Rh(t,s),this.Ky(),l}fI(){for(let t=0;t<=this.Kt;t++)for(;this.uI(t,1););this.Ky()}uI(t,i){let e=!0;const s=this.network.vertexes.iterator;for(;s.next();){const o=s.value,r=this.nodeMinColumnSpace(o,!0),l=this.nodeMinColumnSpace(o,!1);if(o.column-r<=t&&o.column+l>=t){e=!1;break}}let n=!1;if(e){if(i>0)for(s.reset();s.next();){const o=s.value;o.column>t&&(o.column-=1,n=!0)}if(i<0)for(s.reset();s.next();){const o=s.value;o.column0&&(e=t+1),i<0&&(e=t-1);let s=0;const n=[],o=[];for(s=0;s<=this.St;s++)n[s]=!1,o[s]=!1;const r=this.network.vertexes.iterator;for(;r.next();){const a=r.value,c=a.column-this.nodeMinColumnSpace(a,!0),f=a.column+this.nodeMinColumnSpace(a,!1);c<=t&&f>=t&&(n[a.layer]=!0),c<=e&&f>=e&&(o[a.layer]=!0)}let l=!0,h=!1;for(s=0;s<=this.St;s++)l=l&&!(n[s]&&o[s]);if(l){if(i>0)for(r.reset();r.next();){const a=r.value;a.column>t&&(a.column-=1,h=!0)}if(i<0)for(r.reset();r.next();){const a=r.value;a.column0)for(i=0;i<=this.Kt;i++)for(e=this.$i(),s=this.Z1(!0),n=s+1;ss?this.Ze(e):o=0;i--)for(e=this.$i(),s=this.Z1(!0),n=s+1;ss?this.Ze(e):o0)for(e.reset();e.next();){const c=e.value;c.column-this.nodeMinColumnSpace(c,!0)<=t&&(c.component=this._s)}if(i<0)for(e.reset();e.next();){const c=e.value;c.column+this.nodeMinColumnSpace(c,!1)>=t&&(c.component=this._s)}for(this._s++,e.reset();e.next();){const c=e.value;c.component===-1&&(this.IN(c,this._s,-1,!0,!0),this._s++)}let s=0;const n=[];for(s=0;s0)for(let f=0;f0;f--)o[c*(this.Kt+1)+f]!==-1&&o[c*(this.Kt+1)+f-1]!==-1&&o[c*(this.Kt+1)+f]!==o[c*(this.Kt+1)+f-1]&&(n[o[c*(this.Kt+1)+f]*this._s+o[c*(this.Kt+1)+f-1]]=!0)}const r=[];for(s=0;s0)for(e.reset();e.next();){const c=e.value;r[c.component]&&(c.column-=1,a=!0)}if(i<0)for(e.reset();e.next();){const c=e.value;r[c.component]&&(c.column+=1,a=!0)}return a}aI(){const t=Util.nt(),i=this.$f.length;for(let u=0;u<=i;u++)t[u]=[];const e=this.network.vertexes.iterator;for(;e.next();){const u=e.value,d=i-u.layer,m=t[d];m[u.index]=u}const s=new GSet;this.mI(t,s);let n=null,o=null,r=null,l=null;const h=(this.vn&1)!==0,a=(this.vn&2)!==0,c=(this.vn&4)!==0,f=(this.vn&8)!==0;h&&(this.sl(t,s,!0),n=this.ik(t,!0,!1)),t.reverse(),c&&(this.sl(t,s,!1),r=this.ik(t,!1,!1));for(const u of t)u.reverse();f&&(this.sl(t,s,!1),l=this.ik(t,!1,!0)),t.reverse(),a&&(this.sl(t,s,!0),o=this.ik(t,!0,!0)),Util.tt(t),this.pI(n,o,r,l),this.network.vertexes.each(u=>{const d=u,m=Util.nt();h&&m.push(n.get(d)),a&&m.push(o.get(d)),c&&m.push(r.get(d)),f&&m.push(l.get(d)),m.sort((k,b)=>k-b);const g=m.length,p=Math.floor((g-1)/2),y=Math.ceil((g-1)/2),x=(m[p]+m[y])/2;Util.tt(m),d.he=x})}mI(t,i){const e=t.length;for(let s=1;sf)&&i.add(m)}o++}n=f}}}}yI(t){if(t.node===null){const i=t.getProperSourceVertexes();if(i.length>0)return i[0].node===null}return!1}sl(t,i,e){this.wI(t);for(const s of t){let n=-1;for(const o of s){const r=e?o.getProperSourceVertexes():o.getProperDestinationVertexes(),l=r.length;if(l>0){r.sort((a,c)=>a.vh-c.vh);const h=(l-1)/2;for(let a=Math.floor(h),c=Math.ceil(h);a<=c;a++)if(o.On===o){const f=r[a];let u;e?u=f.getDestinationEdge(o):u=o.getDestinationEdge(f),!i.has(u)&&n0){const c=this.fD(a,t),f=s?c.width:c.height,u=a.Qe.Qf+a.he+a.In-(c.he+c.In+f+this.columnSpacing);c.Qe.Qf=Math.min(c.Qe.Qf,u)}h=a.vh+1}while(l0){const s=this.fD(e,i),n=s.Qa;this.cD(n,i),t.Qe===t&&(t.Qe=n.Qe);const o=this.S===90||this.S===270?s.width:s.height;if(t.Qe===n.Qe){const r=n.he+s.In+o-e.In+this.columnSpacing;t.he=Math.max(t.he,r)}}e=e.On}while(e!==t);for(;e.On!==t;)e=e.On,e.he=t.he,e.Qe=t.Qe}fD(t,i){const e=t.aD,s=t.vh;return s<1&&Util.o("Could not determine previous vertex in layer"),i[e][s-1]}pI(...t){let i=-1;const e=Util.nt(),s=Util.nt();let n=1/0;for(let o=0;o<4;o++){if(!t[o])continue;const r=this.bI(t[o],e,s,o);r{r.set(h.key,h.value+l)})}Util.tt(e),Util.tt(s)}bI(t,i,e,s){if(!t||t.count===0)return i[s]=0,e[s]=0,1/0;let n=1/0,o=-1/0;return t.each(r=>{const l=r.key,h=r.value,a=this.S===90||this.S===270?l.width:l.height;ho&&(o=h+a)}),i[s]=n,e[s]=o,o-n}commitLayout(){this.zy(),this.commitNodes(),this.UN(),this.isRouting&&this.commitLinks()}zy(){if(!this.setsPortSpots)return;const t=this._1(!0),i=this._1(!1),e=this.network.edges.iterator;for(;e.next();){const n=e.value.link;n!==null&&(n.fromSpot=t,n.toSpot=i)}}_1(t){return this.S===270?t?Spot.MiddleTop:Spot.MiddleBottom:this.S===90?t?Spot.MiddleBottom:Spot.MiddleTop:this.S===180?t?Spot.MiddleLeft:Spot.MiddleRight:t?Spot.MiddleRight:Spot.MiddleLeft}commitNodes(){this.Qs=[],this.Ms=[],this.Ns=[],this.Ut=[];for(let d=0;d<=this.St;d++)this.Qs[d]=0,this.Ms[d]=0,this.Ns[d]=0,this.Ut[d]=0;const t=this.network.vertexes.iterator;for(;t.next();){const d=t.value,m=d.layer;this.Qs[m]=Math.max(this.Qs[m],this.nodeMinLayerSpace(d,!0)),this.Ms[m]=Math.max(this.Ms[m],this.nodeMinLayerSpace(d,!1))}let i=0;const e=this.Ps;for(let d=0;d<=this.St;d++){let m=e;this.Qs[d]+this.Ms[d]<=0&&(m=0),d>0&&(i+=m/2),this.S===90||this.S===0?(i+=this.Ms[d],this.Ns[d]=i,i+=this.Qs[d]):(i+=this.Qs[d],this.Ns[d]=i,i+=this.Ms[d]),d=0;n--)this.S===270?n===0?e.push(new Rect(0,0,s,Math.abs(this.Ut[0]))):e.push(new Rect(0,this.Ut[n-1],s,Math.abs(this.Ut[n-1]-this.Ut[n]))):this.S===90?n===0?e.push(new Rect(0,this.Ut[0],s,Math.abs(this.Ut[0]-t))):e.push(new Rect(0,this.Ut[n],s,Math.abs(this.Ut[n-1]-this.Ut[n]))):this.S===180?n===0?e.push(new Rect(0,0,Math.abs(this.Ut[0]),s)):e.push(new Rect(this.Ut[n-1],0,Math.abs(this.Ut[n-1]-this.Ut[n]),s)):n===0?e.push(new Rect(this.Ut[0],0,Math.abs(this.Ut[0]-t),s)):e.push(new Rect(this.Ut[n],0,Math.abs(this.Ut[n-1]-this.Ut[n]),s));this.commitLayers(e,this.or)}commitLayers(t,i){}commitLinks(){const t=this.network.edges.iterator;let i;for(;t.next();)i=t.value.link,i!==null&&(i.startRoute(),i.clearPoints(),i.commitRoute());for(t.reset();t.next();)i=t.value.link,i!==null&&i.updateRoute();for(t.reset();t.next();){const e=t.value;if(i=e.link,i===null||i.pointsCount===0)continue;i.startRoute();const s=i;let n=s.fromNode,o=s.toNode,r=s.fromPort,l=s.toPort;if(n!==null){const N=n.findVisibleNode();N!==null&&N!==n&&(n=N,r=N.port)}if(o!==null){const N=o.findVisibleNode();N!==null&&N!==o&&(o=N,l=N.port)}const h=i.computeSpot(!0,r),a=i.computeSpot(!1,l);let c=e.fromVertex,f=e.toVertex;if(e.valid){if(i.curve===9&&i.pointsCount===4)if(c.column===f.column&&this.alignOption===0){const N=i.getLinkPoint(n,r,h,!0,!1,o,l),T=i.getLinkPoint(o,l,a,!1,!1,n,r);N.isReal()||N.set(n.actualBounds.center),T.isReal()||T.set(o.actualBounds.center),i.clearPoints(),i.addPointAt(N.x,N.y),i.addPointAt((2*N.x+T.x)/3,(2*N.y+T.y)/3),i.addPointAt((N.x+2*T.x)/3,(N.y+2*T.y)/3),i.addPointAt(T.x,T.y)}else{let N=!1,T=!1;if(r!==null&&h===Spot.None&&(N=!0),l!==null&&a===Spot.None&&(T=!0),N||T){let A=null;N&&(A=i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0),A.isReal()||A.set(n.actualBounds.center),i.setPointAt(0,A.x,A.y));let D=null;if(T&&(D=i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(0),!1),D.isReal()||D.set(o.actualBounds.center),i.setPointAt(3,D.x,D.y)),A){const F=i.getPoint(2);i.setPointAt(1,(A.x*2+F.x)/3,(A.y*2+F.y)/3)}if(D){const F=i.getPoint(1);i.setPointAt(2,(D.x*2+F.x)/3,(D.y*2+F.y)/3)}}}i.commitRoute();continue}if(c.layer===f.layer){i.commitRoute();continue}let u=!1,d=!1;const m=this.Ps;let g=0,p=i.firstPickIndex+1;if(i.isOrthogonal)d=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3);else if(i.curve===9)u=!0,g=i.pointsCount,g>4&&i.points.removeRange(2,g-3),g===4&&(p=2);else{g=i.pointsCount;const N=h===Spot.None,T=a===Spot.None;g>2&&N&&T?i.points.removeRange(1,g-2):g>3&&N&&!T?i.points.removeRange(1,g-3):g>3&&!N&&T?i.points.removeRange(2,g-2):g>4&&!N&&!T&&i.points.removeRange(2,g-3)}let y,x,k=0,b=0,P=0,S=0,L=0,C=0,M=0;if(e.rev){let N=0;for(;f!==null&&c!==f;){y=null,x=null;const T=f.sourceEdges.iterator;for(;T.next();){const A=T.value;if(A.link===e.link&&(y=A.fromVertex,x=A.toVertex,y.node===null))break}if(y===null)break;if(y!==c)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=y.centerX,S=y.centerY,d)this.S===180||this.S===0?p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,k,S)):(x!==null?x.centerY:b)!==S&&(L=this.Ut[y.layer-1]+this.or.x,i.insertPointAt(p++,L,b),i.insertPointAt(p++,L,S)):p===i.firstPickIndex+1?(i.insertPointAt(p++,k,b),i.insertPointAt(p++,P,b)):(x!==null?x.centerX:k)!==P&&(L=this.Ut[y.layer-1]+this.or.y,i.insertPointAt(p++,k,L),i.insertPointAt(p++,P,L));else if(p===i.firstPickIndex+1)if(C=Math.max(10,this.Qs[f.layer]),M=Math.max(10,this.Ms[f.layer]),u)this.S===180?P<=f.bounds.x?(N=f.bounds.x,i.insertPointAt(p++,N-C,S),i.insertPointAt(p++,N,S),i.insertPointAt(p++,N+M,S)):(i.insertPointAt(p++,P-C,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P+M,S)):this.S===90?S>=f.bounds.bottom?(N=f.bounds.y+f.bounds.height,i.insertPointAt(p++,P,N+M),i.insertPointAt(p++,P,N),i.insertPointAt(p++,P,N-C)):(i.insertPointAt(p++,P,S+M),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S-C)):this.S===270?S<=f.bounds.y?(N=f.bounds.y,i.insertPointAt(p++,P,N-C),i.insertPointAt(p++,P,N),i.insertPointAt(p++,P,N+M)):(i.insertPointAt(p++,P,S-C),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S+M)):this.S===0&&(P>=f.bounds.right?(N=f.bounds.x+f.bounds.width,i.insertPointAt(p++,N+M,S),i.insertPointAt(p++,N,S),i.insertPointAt(p++,N-C,S)):(i.insertPointAt(p++,P+M,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P-C,S)));else{i.insertPointAt(p++,k,b);let A=0;this.S===180||this.S===0?((this.S===180?P>=f.bounds.right:P<=f.bounds.x)&&(A=(this.S===0?-C:M)/2),i.insertPointAt(p++,k+A,S)):((this.S===270?S>=f.bounds.bottom:S<=f.bounds.y)&&(A=(this.S===90?-C:M)/2),i.insertPointAt(p++,P,b+A)),i.insertPointAt(p++,P,S)}else C=Math.max(10,this.Qs[y.layer]),M=Math.max(10,this.Ms[y.layer]),u?this.S===180?(i.insertPointAt(p++,P-C-m,S),i.insertPointAt(p++,Math.min(P-C+m/2,P),S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,Math.max(P+M-m/2,P),S),i.insertPointAt(p++,P+M+m,S)):this.S===90?(i.insertPointAt(p++,P,S+M+m),i.insertPointAt(p++,P,Math.max(S+M-m/2,S)),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,Math.min(S-C+m/2,S)),i.insertPointAt(p++,P,S-C-m)):this.S===270?(i.insertPointAt(p++,P,S-C-m),i.insertPointAt(p++,P,Math.min(S-C+m/2,S)),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,Math.max(S+M-m/2,S)),i.insertPointAt(p++,P,S+M+m)):(i.insertPointAt(p++,P+M+m,S),i.insertPointAt(p++,Math.max(P+M-m/2,P),S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,Math.min(P-C+m/2,P),S),i.insertPointAt(p++,P-C-m,S)):(this.S===180||this.S===90||this.S,i.insertPointAt(p++,P,S));f=y}if(l===null||h!==Spot.None||d)if(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=i.getPoint(p).x,S=i.getPoint(p).y,d){const T=this.Ms[c.layer];let A=0;this.S===180||this.S===0?(A=b,A>=c.bounds.y&&A<=c.bounds.bottom&&(this.S===180?P>=c.bounds.x:P<=c.bounds.right)&&(N=c.centerX+(this.S===180?-T:T),A=c.bounds.x&&A<=c.bounds.right&&(this.S===270?S>=c.bounds.y:S<=c.bounds.bottom)&&(N=c.centerY+(this.S===270?-T:T),A=c.bounds.x?(N=c.bounds.x+c.bounds.width,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N+M,b)):this.S===90&&S<=c.bounds.bottom?(N=c.bounds.y,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N-C)):this.S===270&&S>=c.bounds.y?(N=c.bounds.y+c.bounds.height,i.setPointAt(p-2,k,N),i.setPointAt(p-1,k,N+M)):this.S===0&&P<=c.bounds.right&&(N=c.bounds.x,i.setPointAt(p-2,N,b),i.setPointAt(p-1,N-C,b));else{C=Math.max(10,this.Qs[c.layer]),M=Math.max(10,this.Ms[c.layer]);let T=0;this.S===180||this.S===0?((this.S===180?P<=c.bounds.x:P>=c.bounds.right)&&(T=(this.S===0?M:-C)/2),i.insertPointAt(p++,P+T,b)):((this.S===270?S<=c.bounds.y:S>=c.bounds.bottom)&&(T=(this.S===90?M:-C)/2),i.insertPointAt(p++,k,S+T)),i.insertPointAt(p++,P,S)}}else{for(;c!==null&&c!==f;){y=null,x=null;const N=c.destinationEdges.iterator;for(;N.next();){const T=N.value;if(T.link===e.link&&(y=T.toVertex,x=T.fromVertex,x.node!==null&&(x=null),y.node===null))break}if(y===null)break;y!==f&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=y.centerX,S=y.centerY,d?this.S===180||this.S===0?(x!==null?x.centerY:b)!==S&&(L=this.Ut[y.layer]+this.or.x,p===i.firstPickIndex+1&&(this.S===0?L=Math.max(L,k):L=Math.min(L,k)),i.insertPointAt(p++,L,b),i.insertPointAt(p++,L,S)):(x!==null?x.centerX:k)!==P&&(L=this.Ut[y.layer]+this.or.y,p===i.firstPickIndex+1&&(this.S===90?L=Math.max(L,b):L=Math.min(L,b)),i.insertPointAt(p++,k,L),i.insertPointAt(p++,P,L)):(C=Math.max(10,this.Qs[y.layer]),M=Math.max(10,this.Ms[y.layer]),u?this.S===180?(i.insertPointAt(p++,P+M+m,S),i.insertPointAt(p++,Math.max(P+M-m/2,P),S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,Math.min(P-C+m/2,P),S),i.insertPointAt(p++,P-C-m,S)):this.S===90?(i.insertPointAt(p++,P,S-C-m),i.insertPointAt(p++,P,Math.min(S-C+m/2,S)),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,Math.max(S+M-m/2,S)),i.insertPointAt(p++,P,S+M+m)):this.S===270?(i.insertPointAt(p++,P,S+M+m),i.insertPointAt(p++,P,Math.max(S+M-m/2,S)),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,Math.min(S-C+m/2,S)),i.insertPointAt(p++,P,S-C-m)):(i.insertPointAt(p++,P-C-m,S),i.insertPointAt(p++,Math.min(P-C+m/2,P),S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,P,S),i.insertPointAt(p++,Math.max(P+M-m/2,P),S),i.insertPointAt(p++,P+M+m,S)):this.S===180?(i.insertPointAt(p++,P+M,S),i.insertPointAt(p++,P-C,S)):this.S===90?(i.insertPointAt(p++,P,S-C),i.insertPointAt(p++,P,S+M)):this.S===270?(i.insertPointAt(p++,P,S+M),i.insertPointAt(p++,P,S-C)):(i.insertPointAt(p++,P-C,S),i.insertPointAt(p++,P+M,S)))),c=y}d&&(k=i.getPoint(p-1).x,b=i.getPoint(p-1).y,P=i.getPoint(p).x,S=i.getPoint(p).y,this.S===180||this.S===0?b!==S&&(this.S===0?L=Math.min(Math.max((P+k)/2,this.Ut[f.layer]+this.or.x),P):L=Math.max(Math.min((P+k)/2,this.Ut[f.layer]+this.or.x),P),i.insertPointAt(p++,L,b),i.insertPointAt(p++,L,S)):k!==P&&(this.S===90?L=Math.min(Math.max((S+b)/2,this.Ut[f.layer]+this.or.y),S):L=Math.max(Math.min((S+b)/2,this.Ut[f.layer]+this.or.y),S),i.insertPointAt(p++,k,L),i.insertPointAt(p++,P,L)))}if(s!==null&&u&&i.pointsCount>=4){if(r!==null){const N=h===Spot.None?i.getLinkPointFromPoint(n,r,r.getDocumentPoint(Spot.Center),i.getPoint(3),!0):i.getPoint(0);if(h===Spot.None){const T=i.getPoint(2),A=i.getPoint(3);this.direction===90||this.direction===270?(i.setPointAt(1,(N.x+T.x)/2,T.y),i.setPointAt(2,A.x,(T.y+A.y)/2)):(i.setPointAt(1,T.x,(N.y+T.y)/2),i.setPointAt(2,(T.x+A.x)/2,A.y))}N.isReal()||N.set(n.actualBounds.center),i.setPointAt(0,N.x,N.y)}if(l!==null){const N=a===Spot.None?i.getLinkPointFromPoint(o,l,l.getDocumentPoint(Spot.Center),i.getPoint(i.pointsCount-4),!1):i.getPoint(i.pointsCount-1);if(a===Spot.None){const T=i.getPoint(i.pointsCount-3),A=i.getPoint(i.pointsCount-4);this.direction===90||this.direction===270?(i.setPointAt(i.pointsCount-2,(N.x+T.x)/2,T.y),i.setPointAt(i.pointsCount-2,A.x,(T.y+A.y)/2)):(i.setPointAt(i.pointsCount-2,T.x,(N.y+T.y)/2),i.setPointAt(i.pointsCount-3,(T.x+A.x)/2,A.y))}N.isReal()||N.set(o.actualBounds.center),i.setPointAt(i.pointsCount-1,N.x,N.y)}}i.commitRoute(),e.commit()}}YO(){this.Xy=-1,this.Cg=0,this.Ss=0,this.Za=null,this.Ag=null,this.$f=null;for(let t=0;t=this.Rn.length){const n=[];for(let o=0;o=0&&(this.Ps=t,this.invalidateLayout()))}get columnSpacing(){return this.Ji}set columnSpacing(t){this.Ji!==t&&(Util.i(t,"number",LayeredDigraphLayout,"columnSpacing"),t>0&&(this.Ji=t,this.invalidateLayout()))}get direction(){return this.S}set direction(t){this.S!==t&&(Util.i(t,"number",LayeredDigraphLayout,"direction"),t===0||t===90||t===180||t===270?(this.S=t,this.invalidateLayout()):Util.o("LayeredDigraphLayout.direction must be 0, 90, 180, or 270"))}get cycleRemoveOption(){return this.jf}set cycleRemoveOption(t){this.jf!==t&&(t===1||t===0||t===2)&&(this.jf=t,this.invalidateLayout())}get layeringOption(){return this.Hf}set layeringOption(t){this.Hf!==t&&(t===10||t===11||t===12)&&(this.Hf=t,this.invalidateLayout())}get initializeOption(){return this.qf}set initializeOption(t){this.qf!==t&&(t===20||t===21||t===22)&&(this.qf=t,this.invalidateLayout())}get iterations(){return this.$a}set iterations(t){this.$a!==t&&t>=0&&(this.$a=t,this.invalidateLayout())}get aggressiveOption(){return this.Wf}set aggressiveOption(t){this.Wf!==t&&(t===30||t===31||t===32)&&(this.Wf=t,this.invalidateLayout())}get packOption(){return this.nr}set packOption(t){this.nr!==t&&(Util.i(t,"number",LayeredDigraphLayout,"packOption"),t>=0&&t<8&&(this.nr=t,this.invalidateLayout()))}get packIterations(){return this.Jf}set packIterations(t){this.Jf=t}get alignOption(){return this.vn}set alignOption(t){this.vn!==t&&(Util.i(t,"number",LayeredDigraphLayout,"align"),t>=0&&t<16&&(this.vn=t,this.invalidateLayout()))}get setsPortSpots(){return this.Fn}set setsPortSpots(t){this.Fn!==t&&(Util.i(t,"boolean",LayeredDigraphLayout,"setsPortSpots"),this.Fn=t,this.invalidateLayout())}get maxLayer(){return this.St}get maxIndex(){return this.Xy}get maxColumn(){return this.Kt}get minIndexLayer(){return this.Cg}get maxIndexLayer(){return this.Ss}static CycleDepthFirst=0;static CycleGreedy=1;static CycleFromLayers=2;static LayerOptimalLinkLength=10;static LayerLongestPathSink=11;static LayerLongestPathSource=12;static InitDepthFirstOut=20;static InitDepthFirstIn=21;static InitNaive=22;static AggressiveNone=30;static AggressiveLess=31;static AggressiveMore=32;static PackNone=0;static PackExpand=1;static PackStraighten=2;static PackMedian=4;static PackAll=15;static AlignNone=0;static AlignUpperLeft=1;static AlignUpperRight=2;static AlignLowerLeft=4;static AlignLowerRight=8;static AlignAll=15}class LayeredDigraphNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new LayeredDigraphVertex(this)}createEdge(){return new LayeredDigraphEdge(this)}}class LayeredDigraphVertex extends LayoutVertex{Wo;Uo;Dt;ek;sk;Zi;Zf;jn;Q1;J1;$1;Qa;On;aD;vh;Qe;Qf;he;In;jy=null;Hy=null;qy=null;Wy=null;constructor(t){super(t),this.Wo=-1,this.Uo=-1,this.Dt=-1,this.ek=NaN,this.sk=null,this.Zi=!1,this.Zf=NaN,this.jn=NaN,this.Q1=0,this.J1=null,this.$1=null}static uD(t,i){return t.index-i.index}getProperSourceEdges(){if(!this.qy){const t=[];for(const i of this.po){const e=i;e.valid&&t.push(e)}this.qy=t}return this.qy}getProperDestinationEdges(){if(!this.Wy){const t=[];for(const i of this.ir){const e=i;e.valid&&t.push(e)}this.Wy=t}return this.Wy}getDestinationEdge(t){const i=this.getProperDestinationEdges();for(const e of i)if(e.toVertex===t)return e;Util.o("Unable to find destination edge to given vertex")}getProperSourceVertexes(){if(!this.jy){const t=[];for(const i of this.po){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.fromVertex)}t.sort(LayeredDigraphVertex.uD),this.jy=t}return this.jy}getProperDestinationVertexes(){if(!this.Hy){const t=[];for(const i of this.ir){const e=i;!e.valid||e.fromVertex.layer<=e.toVertex.layer||t.push(e.toVertex)}t.sort(LayeredDigraphVertex.uD),this.Hy=t}return this.Hy}addSourceEdge(t){super.addSourceEdge(t),this.jy=null,this.qy=null}deleteSourceEdge(t){super.deleteSourceEdge(t),this.jy=null,this.qy=null}addDestinationEdge(t){super.addDestinationEdge(t),this.Hy=null,this.Wy=null}deleteDestinationEdge(t){super.deleteDestinationEdge(t),this.Hy=null,this.Wy=null}get layer(){return this.Wo}set layer(t){this.Wo!==t&&(Util.i(t,"number",LayeredDigraphVertex,"layer"),this.Wo=t)}get column(){return this.Uo}set column(t){this.Uo!==t&&(Util.i(t,"number",LayeredDigraphVertex,"column"),this.Uo=t)}get index(){return this.Dt}set index(t){this.Dt!==t&&(Util.i(t,"number",LayeredDigraphVertex,"index"),this.Dt=t)}get component(){return this.ek}set component(t){this.ek!==t&&(Util.i(t,"number",LayeredDigraphVertex,"component"),this.ek=t)}get near(){return this.sk}set near(t){this.sk!==t&&(this.sk=t)}}class LayeredDigraphEdge extends LayoutEdge{Zi;nk;ok;rk;lk;hk;ak;constructor(t){super(t),this.Zi=!1,this.nk=!1,this.ok=!1,this.rk=NaN,this.lk=NaN,this.hk=0,this.ak=0}get fromVertex(){return this.We}set fromVertex(t){this.We!==t&&(this.We=t)}get toVertex(){return this.Je}set toVertex(t){this.Je!==t&&(this.Je=t)}get valid(){return this.Zi}set valid(t){this.Zi!==t&&(Util.i(t,"boolean",LayeredDigraphEdge,"valid"),this.Zi=t)}get rev(){return this.nk}set rev(t){this.nk!==t&&(Util.i(t,"boolean",LayeredDigraphEdge,"rev"),this.nk=t)}get forest(){return this.ok}set forest(t){this.ok!==t&&(Util.i(t,"boolean",LayeredDigraphEdge,"forest"),this.ok=t)}get portFromPos(){return this.rk}set portFromPos(t){this.rk!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portFromPos"),this.rk=t)}get portToPos(){return this.lk}set portToPos(t){this.lk!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portToPos"),this.lk=t)}get portFromColOffset(){return this.hk}set portFromColOffset(t){this.hk!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portFromColOffset"),this.hk=t)}get portToColOffset(){return this.ak}set portToColOffset(t){this.ak!==t&&(Util.i(t,"number",LayeredDigraphEdge,"portToColOffset"),this.ak=t)}}var TreePath=(w=>(w[w.Default=0]="Default",w[w.Destination=1]="Destination",w[w.Source=2]="Source",w))(TreePath||{}),TreeSorting=(w=>(w[w.Forwards=10]="Forwards",w[w.Reverse=11]="Reverse",w[w.Ascending=12]="Ascending",w[w.Descending=13]="Descending",w))(TreeSorting||{}),TreeAlignment=(w=>(w[w.CenterSubtrees=20]="CenterSubtrees",w[w.CenterChildren=21]="CenterChildren",w[w.Start=22]="Start",w[w.End=23]="End",w[w.Bus=24]="Bus",w[w.BusBranching=25]="BusBranching",w[w.TopLeftBus=26]="TopLeftBus",w[w.BottomRightBus=27]="BottomRightBus",w[w.Custom=28]="Custom",w))(TreeAlignment||{}),TreeCompaction=(w=>(w[w.None=30]="None",w[w.Block=31]="Block",w))(TreeCompaction||{}),TreeStyle=(w=>(w[w.Layered=40]="Layered",w[w.LastParents=41]="LastParents",w[w.Alternating=42]="Alternating",w[w.RootOnly=43]="RootOnly",w))(TreeStyle||{}),TreeArrangement=(w=>(w[w.Vertical=50]="Vertical",w[w.Horizontal=51]="Horizontal",w[w.FixedRoots=52]="FixedRoots",w))(TreeArrangement||{}),TreeLayerStyle=(w=>(w[w.Individual=60]="Individual",w[w.Siblings=61]="Siblings",w[w.Uniform=62]="Uniform",w))(TreeLayerStyle||{});class TreeLayout extends Layout{Fi;Ti;_f;Dg;VN;Re;zi;ks;V;z;ck;hs;constructor(t){super(),this.Fi=new GSet,this.Ti=0,this.hs=1,this._f=40,this.Dg=60,this.VN=[],this.Re=!0,this.zi=50,this.ks=new Size(10,10).g();const i=new TreeNetwork(this);this.V=new TreeVertex(i),this.z=new TreeVertex(i),this.ck=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Ti=this.Ti,t._f=this._f,t.Dg=this.Dg,t.Re=this.Re,t.zi=this.zi,t.ks.a(this.ks),t.V.copyInheritedPropertiesFrom(this.V),t.z.copyInheritedPropertiesFrom(this.z)}ri(t){t in TreeAlignment?this.alignment=t:t in TreeArrangement?this.arrangement=t:t in TreeCompaction?this.compaction=t:t in TreePath?this.path=t:t in TreeSorting?this.sorting=t:t in TreeStyle?this.treeStyle=t:super.ri(t)}createNetwork(){return new TreeNetwork(this)}makeNetwork(t){const i=this.createNetwork(),e=s=>{if(s instanceof Node)return!s.isLinkLabel&&s.category!=="Comment";if(s instanceof Link){const n=s.fromNode;if(n===null||n.isLinkLabel||n.category==="Comment")return!1;const o=s.toNode;return!(o===null||o.isLinkLabel||o.category==="Comment")}return!1};return t instanceof Diagram?(i.addParts(t.nodes,!0,e),i.addParts(t.links,!0,e)):t instanceof Group?i.addParts(t.memberParts,!1,e):i.addParts(t.iterator,!1,e),i}doLayout(t){this.network===null&&(this.network=this.makeNetwork(t)),this.arrangement!==52&&(this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin));let i=this.diagram;i===null&&t instanceof Diagram&&(i=t),this.path===0&&i!==null?this.hs=i.isTreePathToChildren?1:2:this.hs=this.path===0?1:this.path,this.network.vertexes.count>0&&(this.CI(),this.LI(),this.AI(),this.TI(),this.RN(),this.DI(),this.arrangeTrees(),this.updateParts()),this.network=null,this.Fi=new GSet,this.isValidLayout=!0}CI(){this.network.deleteSelfEdges();const t=this.network.vertexes.iterator;for(;t.next();){const n=t.value;n.initialized=!1,n.level=0,n.parent=null,n.children=[]}if(this.Fi.count>0){const n=new GSet,o=this.Fi.iterator;for(;o.next();){const r=o.value;if(r instanceof Node){const l=this.network.findVertex(r);l!==null&&n.add(l)}else r instanceof TreeVertex&&n.add(r)}this.Fi=n}this.Fi.count===0&&this.findRoots();const i=this.Fi.copy().iterator;for(;i.next();){const n=i.value;n.initialized||(n.initialized=!0,this.zN(n))}let e=this.network.vertexes,s=null;for(;s=this.FI(e),s.count>0;){const n=this.dD(s);n!==null&&this.Fi.add(n),n.initialized=!0,this.zN(n),e=s}}FI(t){const i=new GSet,e=t.iterator;for(;e.next();){const s=e.value;s.initialized||i.add(s)}return i}findRoots(){const t=this.network.vertexes,i=t.iterator;for(;i.next();){const e=i.value;switch(this.hs){case 1:e.sourceEdges.count===0&&this.Fi.add(e);break;case 2:e.destinationEdges.count===0&&this.Fi.add(e);break;default:Util.o("Unhandled path value "+this.hs.toString())}}if(this.Fi.count===0){const e=this.dD(t);e!==null&&this.Fi.add(e)}}dD(t){let i=999999,e=null;const s=t.iterator;for(;s.next();){const n=s.value;switch(this.hs){case 1:n.sourceEdges.count0){const s=new List,n=t.destinationVertexes;for(;n.next();){const o=n.value;this.gD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;case 2:if(t.sourceEdges.count>0){const s=new List,n=t.sourceVertexes;for(;n.next();){const o=n.value;this.gD(t,o)&&s.add(o)}s.count>0&&(t.children=s.toArray())}break;default:Util.o("Unhandled path value"+this.hs.toString())}const i=t.children,e=i.length;for(let s=0;st.level?!1:(this.vI(i.parent,i),!0):!0}RI(t,i){if(i===null)return!1;let e=i.parent;for(;e!==null&&e!==t;)e=e.parent;return e===t}vI(t,i){if(t===null||i===null)return;const e=t.children;let s=0;for(let n=0;n0){const n=new Array(e.length-s);let o=0;for(let r=0;r0?s+1:0}OI(t){switch(this._f){default:case 40:return t.parent!==null?t.parent:this.V;case 43:return t.parent===null?this.V:t.parent.parent===null?this.z:t.parent;case 42:return t.parent!==null?t.parent.parent!==null?t.parent.parent:this.z:this.V;case 41:{let i=!0;if(t.childrenCount===0)i=!1;else{const e=t.children,s=e.length;for(let n=0;n0){i=!1;break}}return i&&t.parent!==null?this.z:t.parent!==null?t.parent:this.V}}}initializeTreeVertexValues(t){const i=this.OI(t);if(t.copyInheritedPropertiesFrom(i),t.parent!==null&&t.parent.alignment===25){let e=t.angle;const s=t.parent.children;let n=0;for(;n135&&!l||a&&f)if(t.commentMargin>=0){g.e(t.bounds.x-t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleLeft,P.toSpot=Spot.MiddleRight}}else{g.e(t.bounds.x+t.focus.x*2-t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleRight,P.toSpot=Spot.MiddleLeft}}else if(t.commentMargin>=0){g.e(t.bounds.x+t.focus.x*2+t.commentMargin,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleRight,P.toSpot=Spot.MiddleLeft}}else{g.e(t.bounds.x+t.commentMargin-k.width,t.bounds.y+u),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleLeft,P.toSpot=Spot.MiddleRight}}t.commentSpacing>=0?u+=k.height+t.commentSpacing:u+=t.commentSpacing-k.height}else{if(o>135&&!l||!a&&f)if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y-t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleTop,P.toSpot=Spot.MiddleBottom}}else{g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2-t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleBottom,P.toSpot=Spot.MiddleTop}}else if(t.commentMargin>=0){g.e(t.bounds.x+u,t.bounds.y+t.focus.y*2+t.commentMargin),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleBottom,P.toSpot=Spot.MiddleTop}}else{g.e(t.bounds.x+u,t.bounds.y+t.commentMargin-k.height),x.move(g);const b=x.findLinksInto();for(;b.next();){const P=b.value;P.fromSpot=Spot.MiddleTop,P.toSpot=Spot.MiddleBottom}}t.commentSpacing>=0?u+=k.width+t.commentSpacing:u+=t.commentSpacing-k.width}}Point.s(g);const p=u-t.commentSpacing-(h?e.height:e.width);if(this.hs===1){const y=t.destinationEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.fromEndSegmentLength=p>0?p:NaN)}}else{const y=t.sourceEdges;for(;y.next();){const k=y.value.link;k!==null&&!k.isAvoiding&&(k.toEndSegmentLength=p>0?p:NaN)}}}}DI(){if(this.layerStyle===62){const i=[];let e=this.network.vertexes.iterator;for(;e.next();){const s=e.value;let n=s.parent;n===null&&(n=s);const o=n.angle===0||n.angle===180;let r=i[s.level];r===void 0&&(r=0),i[s.level]=Math.max(r,o?s.width:s.height)}for(let s=0;s=0)for(let o=0;o135&&n.reverse(),this.Jy(r))if(o>1)for(let R=0;R0&&M>0&&S+u+O.width>c&&(S135?-b-g:b+g);const B=M===0?m:u;this.fk(v,0,L),v.B.e(S+B,L),k=Math.max(k,S+B+O.width),b=Math.max(b,P+(C===0?0:g)+O.height),S+=B+O.width}else{c>0&&M>0&&L+u+O.height>c&&(L135?-k-g:k+g);const B=M===0?m:u;this.fk(v,S,0),v.B.e(S,L+B),b=Math.max(b,L+B+O.height),k=Math.max(k,P+(C===0?0:g)+O.width),L+=B+O.height}M++}C>0&&(e?(b+=Math.max(0,f),S0&&(h||this.tu(t,p,0,0,o-1),k+=p)):(k+=Math.max(0,f),L0&&(h||this.tu(t,0,p,0,o-1),b+=p)));let D=0,F=0;switch(r){case 20:e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;break;default:case 21:if(C>0)e?D+=k/2-t.focus.x-d/2:F+=b/2-t.focus.y-d/2;else{const v=o;if(e){const O=n[0].B.x+n[0].ft.x,B=n[v-1].B.x+n[v-1].ft.x+n[v-1].focus.x*2;D+=O+(B-O)/2-t.focus.x-d/2}else{const O=n[0].B.y+n[0].ft.y,B=n[v-1].B.y+n[v-1].ft.y+n[v-1].focus.y*2;F+=O+(B-O)/2-t.focus.y-d/2}}break;case 22:e?(D-=d,k+=d):(F-=d,b+=d);break;case 23:e?(D+=k-t.width+d,k+=d):(F+=b-t.height+d,b+=d);break;case 24:case 25:e?o>1?D+=T+u/2-t.focus.x:D+=n[0].focus.x-t.focus.x+n[0].ft.x:o>1?F+=T+u/2-t.focus.y:F+=n[0].focus.y-t.focus.y+n[0].ft.y;break;case 26:e?D+=k+u/2-t.focus.x:F+=b+u/2-t.focus.y;break;case 27:break;case 28:const R=this.customAlignment(t,D,F,k,b);D=R[0],F=R[1],k=R[2],b=R[3];break}for(let R=0;R135?(a?-b:-v.mt.height)+v.ft.y-f:x+f+v.ft.y)):v.B.e(v.B.x+(i>135?(a?-k:-v.mt.width)+v.ft.x-f:y+f+v.ft.x),v.B.y+v.ft.y-F)}e?(k=this.KN(t,k,D),D<0&&(D=0),i>135&&(F+=b+f),b=Math.max(Math.max(b,x),b+x+f)):(i>135&&(D+=k+f),k=Math.max(Math.max(k,y),k+y+f),b=this.YN(t,b,F),F<0&&(F=0)),t.ft.e(D,F),t.mt.e(k,b)}customAlignment(t,i,e,s,n){return[i,e,s,n]}xD(t,i,e,s,n,o){const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.mt.width,o=p.mt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,c=this.orthoAngle(t)===90;let f=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.mt,k=f===0?0:h;if(c){const b=this.computeBusNodeSpacing(y)-l;y.B.e(e-(x.width+b),d+k),n=Math.max(n,x.width+b),o=Math.max(o,d+k+x.height),d+=k+x.height}else{const b=this.computeBusNodeSpacing(y)-l;y.B.e(u+k,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,u+k+x.width),u+=k+x.width}f++}f=0;const m=u,g=d;c?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.mt,x=this.computeBusLastRowSpacing(p,c?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(c){p.B.e(e+l/2-p.focus.x-p.ft.x,o+x);const k=e+l/2-p.focus.x-p.ft.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.max(g,d)+x+y.height),p.B.x<0&&(e=this.uk(t,p.B.x,!1,e,l))}else{p.B.e(n+x,e+l/2-p.focus.y-p.ft.y),n=Math.max(n,Math.max(m,u)+x+y.width);const k=e+l/2-p.focus.y-p.ft.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.B.y<0&&(e=this.uk(t,p.B.y,!0,e,l))}}return new Rect(e,0,n,o)}bD(t,i,e,s,n,o){const r=i.length;if(r===0)return new Rect(e,0,n,o);if(r===1){const p=i[0];return n=p.mt.width,o=p.mt.height,new Rect(e,0,n,o)}const l=t.nodeSpacing,h=t.rowSpacing,c=this.orthoAngle(t)===270;let f=0,u=0,d=0;for(let p=0;p1&&p===r-1)continue;const y=i[p],x=y.mt,k=f===0?0:h;if(c){const b=this.computeBusNodeSpacing(y)-l;d-=k+x.height,y.B.e(e-(x.width+b),d),n=Math.max(n,x.width+b),o=Math.max(o,Math.abs(d))}else{const b=this.computeBusNodeSpacing(y)-l;u-=k+x.width,y.B.e(u,e-(x.height+b)),o=Math.max(o,x.height+b),n=Math.max(n,Math.abs(u))}f++}f=0;const m=u,g=d;c?(u=e+l,d=0):(u=0,d=e+l);for(let p=0;p1&&r%2===1){const p=i[r-1],y=p.mt,x=this.computeBusLastRowSpacing(p,c?Math.max(Math.abs(g),Math.abs(d)):Math.max(Math.abs(m),Math.abs(u)));if(c){p.B.e(e+l/2-p.focus.x-p.ft.x,-o-y.height-x);const k=e+l/2-p.focus.x-p.ft.x;n=Math.max(n,k+y.width),k<0&&(n-=k),o=Math.max(o,Math.abs(Math.min(g,d))+x+y.height),p.B.x<0&&(e=this.uk(t,p.B.x,!1,e,l))}else{p.B.e(-n-y.width-x,e+l/2-p.focus.y-p.ft.y),n=Math.max(n,Math.abs(Math.min(m,u))+x+y.width);const k=e+l/2-p.focus.y-p.ft.y;o=Math.max(o,k+y.height),k<0&&(o-=k),p.B.y<0&&(e=this.uk(t,p.B.y,!0,e,l))}}for(let p=0;ps&&(s=e+t.width),e<0&&(s-=e),s;case 22:return t.width>i?t.width:i;case 23:return t.focus.x*2>i?t.width:i+t.width-t.focus.x*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.width);return Math.max(t.width,o-n);case 26:return t.width-t.focus.x+t.nodeSpacing/2+i;case 27:return Math.max(t.width,t.focus.x+t.nodeSpacing/2+i);default:return i}}YN(t,i,e){switch(t.alignment){case 21:case 20:let s=i;return e+t.height>s&&(s=e+t.height),e<0&&(s-=e),s;case 22:return t.height>i?t.height:i;case 23:return t.focus.y*2>i?t.height:i+t.height-t.focus.y*2;case 24:case 25:const n=Math.min(0,e),o=Math.max(i,e+t.height);return Math.max(t.height,o-n);case 26:return t.height-t.focus.y+t.nodeSpacing/2+i;case 27:return Math.max(t.height,t.focus.y+t.nodeSpacing/2+i);default:return i}}GN(t,i,e){switch(t){case 20:i/=2,e/=2;break;case 21:i/=2,e/=2;break;case 22:i=0,e=0;break;case 23:break;default:Util.o("Unhandled alignment value "+t.toString())}return new Point(i,e)}_a(t,i,e,s,n,o){const r=this.GN(i,e,s);this.tu(t,r.x,r.y,n,o)}tu(t,i,e,s,n){if(i===0&&e===0)return;const o=t.children;for(let r=s;r<=n;r++){const h=o[r].B;h.x+=i,h.y+=e}}fk(t,i,e){const s=t.parent;switch(this.hs){case 1:{const n=t.sourceEdges;for(;n.next();){const o=n.value;o.fromVertex===s&&o.relativePoint.e(i,e)}break}case 2:{const n=t.destinationEdges;for(;n.next();){const o=n.value;o.toVertex===s&&o.relativePoint.e(i,e)}break}default:Util.o("Unhandled path value "+this.hs.toString())}}II(t){if(t.childrenCount===0){const U=t.parent;let Y=!1,G=0,H=21;U!==null&&(G=U.angle,H=U.alignment,Y=this.isBusAlignment(H));const J=this.XN(t);t.B.e(0,0),t.mt.e(t.width,t.height),t.parent!==null&&t.comments!==null&&((G===180||G===270)&&!Y||J)?G===180&&!Y||(G===90||G===270)&&J?t.ft.e(t.width-t.focus.x*2,0):t.ft.e(0,t.height-t.focus.y*2):t.ft.e(0,0),t.Fg=null,t.Rg=null;return}const i=this.orthoAngle(t),e=i===90||i===270;let s=0;const n=t.children,o=n.length;for(let U=0;U135&&n.reverse(),this.Jy(r))if(o>1)for(let U=0;U0&&A>0&&M+u+G.width>c&&(M135?-k-m:k+m),this.fk(Y,0,N);let H=0;if(A===0)P=Y.Fg,S=Y.Rg,L=G.width,C=G.height,(P===null||S===null||i!==this.orthoAngle(Y))&&(P=this.ae(2),S=this.ae(2),P[0].e(0,0),P[1].e(0,C),S[0].e(L,0),S[1].e(L,C));else{const J=Util.nt(),z=this.kD(t,Y,P,S,L,C,J);H=z.x,P=J[0],S=J[1],L=z.width,C=z.height,Util.tt(J),M0&&A>0&&N+u+G.height>c&&(N135?-x-m:x+m),this.fk(Y,M,0);let H=0;if(A===0)P=Y.Fg,S=Y.Rg,L=G.width,C=G.height,(P===null||S===null||i!==this.orthoAngle(Y))&&(P=this.ae(2),S=this.ae(2),P[0].e(0,0),P[1].e(L,0),S[0].e(0,C),S[1].e(L,C));else{const J=Util.nt(),z=this.kD(t,Y,P,S,L,C,J);H=z.x,P=J[0],S=J[1],L=z.width,C=z.height,Util.tt(J),N0&&(e?(k+=Math.max(0,f),M0&&(h||this.tu(t,g,0,0,o-1),x+=g)):(x+=Math.max(0,f),N0&&(h||this.tu(t,0,g,0,o-1),k+=g)));let v=0,O=0;switch(r){case 20:e?v+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;break;default:case 21:if(T>0)e?v+=x/2-t.focus.x-d/2:O+=k/2-t.focus.y-d/2;else{const Y=o;if(e){const G=n[0].B.x+n[0].ft.x,H=n[Y-1].B.x+n[Y-1].ft.x+n[Y-1].focus.x*2;v+=G+(H-G)/2-t.focus.x-d/2}else{const G=n[0].B.y+n[0].ft.y,H=n[Y-1].B.y+n[Y-1].ft.y+n[Y-1].focus.y*2;O+=G+(H-G)/2-t.focus.y-d/2}}break;case 22:e?(v-=d,x+=d):(O-=d,k+=d);break;case 23:e?(v+=x-t.width+d,x+=d):(O+=k-t.height+d,k+=d);break;case 24:e?o>1?v+=F+u/2-t.focus.x:v+=n[0].focus.x-t.focus.x+n[0].ft.x:o>1?O+=F+u/2-t.focus.y:O+=n[0].focus.y-t.focus.y+n[0].ft.y;break;case 26:e?v+=x+u/2-t.focus.x:O+=k+u/2-t.focus.y;break;case 27:break;case 28:const U=this.customAlignment(t,v,O,x,k);v=U[0],O=U[1],x=U[2],k=U[3];break}for(let U=0;U135?(a?-k:-Y.mt.height)+Y.ft.y-f:y+f+Y.ft.y)):Y.B.e(Y.B.x+(i>135?(a?-x:-Y.mt.width)+Y.ft.x-f:p+f+Y.ft.x),Y.B.y+Y.ft.y-O)}let B=0,X=0;if(a)e?(x=this.KN(t,x,v),v<0&&(v=0),i>135&&(O+=k+f),k+=y+f,r===27&&(B+=u/2+t.focus.x),X+=y+f):(i>135&&(v+=x+f),x+=p+f,k=this.YN(t,k,O),O<0&&(O=0),r===27&&(X+=u/2+t.focus.y),B+=p+f);else if(e){if(t.comments===null){if(p>x){const U=this.GN(r,p-x,0);B=U.x,X=U.y,x=p,v=0}}else x=this.KN(t,x,v);v<0&&(B-=v,v=0),i>135&&(O+=k+f),k=Math.max(Math.max(k,y),k+y+f),X+=y+f}else{if(i>135&&(v+=x+f),x=Math.max(Math.max(x,p),x+p+f),t.comments===null){if(y>k){const U=this.GN(r,0,y-k);B=U.x,X=U.y,k=y,O=0}}else k=this.YN(t,k,O);O<0&&(X-=O,O=0),B+=p+f}let E,V;if(T>0)E=this.ae(4),V=this.ae(4),e?(E[2].e(0,y+f),E[3].e(E[2].x,k),V[2].e(x,E[2].y),V[3].e(V[2].x,E[3].y)):(E[2].e(p+f,0),E[3].e(x,E[2].y),V[2].e(E[2].x,k),V[3].e(E[3].x,V[2].y));else{E=this.ae(P.length+2),V=this.ae(S.length+2);for(let U=0;UE[0].x?E[2].a(E[1]):E[1].a(E[2])),E[3].yE[0].x?E[3].a(E[2]):E[2].a(E[3])),V[0].e(v+p,0),V[1].e(V[0].x,y),V[2].yE[0].y?E[2].a(E[1]):E[1].a(E[2])),E[3].xE[0].y?E[3].a(E[2]):E[2].a(E[3])),V[0].e(0,O+y),V[1].e(p,V[0].y),V[2].xl;){const a=i[o++];s[r++].e(a.x,a.y+e)}const h=this.ae(r);for(n=0;nl;){const a=i[o++];s[r++].e(a.x+e,a.y)}const h=this.ae(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.ae(r);for(n=0;nl;){const a=t[n++];s[r++].e(a.x,a.y)}const h=this.ae(r);for(n=0;nh&&r.xr.x&&ha&&r.yr.y&&a0){const n=Math.min(1,t.layerSpacingParentOverlap);s-=e?t.height*n:t.width*n}return s<(e?-t.height:-t.width)&&(s=e?-t.height:-t.width),s}computeNodeIndent(t){const i=this.orthoAngle(t),e=i===90||i===270;let s=t.nodeIndent;if(t.nodeIndentPastParent>0){const n=Math.min(1,t.nodeIndentPastParent);s+=e?t.width*n:t.height*n}return s=Math.max(0,s),s}get roots(){return this.Fi}set roots(t){this.Fi!==t&&(this.Fi=t,this.invalidateLayout())}get path(){return this.Ti}set path(t){this.Ti!==t&&(this.Ti=t,this.invalidateLayout())}get treeStyle(){return this._f}set treeStyle(t){this._f!==t&&(t===40||t===42||t===41||t===43)&&(this._f=t,this.invalidateLayout())}get layerStyle(){return this.Dg}set layerStyle(t){this.Dg!==t&&(t===60||t===61||t===62)&&(this.Dg=t,this.invalidateLayout())}get comments(){return this.Re}set comments(t){this.Re!==t&&(Util.i(t,"boolean",TreeLayout,"comments"),this.Re=t,this.invalidateLayout())}get arrangement(){return this.zi}set arrangement(t){this.zi!==t&&(t===50||t===51||t===52)&&(this.zi=t,this.invalidateLayout())}get arrangementSpacing(){return this.ks}set arrangementSpacing(t){this.ks.equals(t)||(this.ks.a(t),this.invalidateLayout())}get rootDefaults(){return this.V}set rootDefaults(t){this.V!==t&&(this.V=t,this.invalidateLayout())}get alternateDefaults(){return this.z}set alternateDefaults(t){this.z!==t&&(this.z=t,this.invalidateLayout())}get sorting(){return this.V.sorting}set sorting(t){this.V.sorting!==t&&(this.V.sorting=t,this.invalidateLayout())}get comparer(){return this.V.comparer}set comparer(t){this.V.comparer!==t&&(Util.i(t,"function",TreeLayout,"comparer"),this.V.comparer=t,this.invalidateLayout())}get angle(){return this.V.angle}set angle(t){this.V.angle!==t&&(Util.i(t,"number",TreeLayout,"angle"),t===0||t===90||t===180||t===270?(this.V.angle=t,this.invalidateLayout()):Util.o("TreeLayout.angle must be 0, 90, 180, or 270"))}get alignment(){return this.V.alignment}set alignment(t){this.V.alignment!==t&&(this.V.alignment=t,this.invalidateLayout())}get nodeIndent(){return this.V.nodeIndent}set nodeIndent(t){this.V.nodeIndent!==t&&(Util.i(t,"number",TreeLayout,"nodeIndent"),t>=0&&(this.V.nodeIndent=t,this.invalidateLayout()))}get nodeIndentPastParent(){return this.V.nodeIndentPastParent}set nodeIndentPastParent(t){this.V.nodeIndentPastParent!==t&&(Util.i(t,"number",TreeLayout,"nodeIndentPastParent"),t>=0&&t<=1&&(this.V.nodeIndentPastParent=t,this.invalidateLayout()))}get nodeSpacing(){return this.V.nodeSpacing}set nodeSpacing(t){this.V.nodeSpacing!==t&&(Util.i(t,"number",TreeLayout,"nodeSpacing"),this.V.nodeSpacing=t,this.invalidateLayout())}get layerSpacing(){return this.V.layerSpacing}set layerSpacing(t){this.V.layerSpacing!==t&&(Util.i(t,"number",TreeLayout,"layerSpacing"),this.V.layerSpacing=t,this.invalidateLayout())}get layerSpacingParentOverlap(){return this.V.layerSpacingParentOverlap}set layerSpacingParentOverlap(t){this.V.layerSpacingParentOverlap!==t&&(Util.i(t,"number",TreeLayout,"layerSpacingParentOverlap"),t>=0&&t<=1&&(this.V.layerSpacingParentOverlap=t,this.invalidateLayout()))}get compaction(){return this.V.compaction}set compaction(t){this.V.compaction!==t&&(t===30||t===31)&&(this.V.compaction=t,this.invalidateLayout())}get breadthLimit(){return this.V.breadthLimit}set breadthLimit(t){this.V.breadthLimit!==t&&(Util.i(t,"number",TreeLayout,"breadthLimit"),t>=0&&(this.V.breadthLimit=t,this.invalidateLayout()))}get rowSpacing(){return this.V.rowSpacing}set rowSpacing(t){this.V.rowSpacing!==t&&(Util.i(t,"number",TreeLayout,"rowSpacing"),this.V.rowSpacing=t,this.invalidateLayout())}get rowIndent(){return this.V.rowIndent}set rowIndent(t){this.V.rowIndent!==t&&(Util.i(t,"number",TreeLayout,"rowIndent"),t>=0&&(this.V.rowIndent=t,this.invalidateLayout()))}get commentSpacing(){return this.V.commentSpacing}set commentSpacing(t){this.V.commentSpacing!==t&&(Util.i(t,"number",TreeLayout,"commentSpacing"),this.V.commentSpacing=t,this.invalidateLayout())}get commentMargin(){return this.V.commentMargin}set commentMargin(t){this.V.commentMargin!==t&&(Util.i(t,"number",TreeLayout,"commentMargin"),this.V.commentMargin=t,this.invalidateLayout())}get setsPortSpot(){return this.V.setsPortSpot}set setsPortSpot(t){this.V.setsPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"setsPortSpot"),this.V.setsPortSpot=t,this.invalidateLayout())}get portSpot(){return this.V.portSpot}set portSpot(t){this.V.portSpot.equals(t)||(this.V.portSpot=t,this.invalidateLayout())}get setsChildPortSpot(){return this.V.setsChildPortSpot}set setsChildPortSpot(t){this.V.setsChildPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"setsChildPortSpot"),this.V.setsChildPortSpot=t,this.invalidateLayout())}get childPortSpot(){return this.V.childPortSpot}set childPortSpot(t){this.V.childPortSpot.equals(t)||(this.V.childPortSpot=t,this.invalidateLayout())}get alternateSorting(){return this.z.sorting}set alternateSorting(t){this.z.sorting!==t&&(this.z.sorting=t,this.invalidateLayout())}get alternateComparer(){return this.z.comparer}set alternateComparer(t){this.z.comparer!==t&&(Util.i(t,"function",TreeLayout,"alternateComparer"),this.z.comparer=t,this.invalidateLayout())}get alternateAngle(){return this.z.angle}set alternateAngle(t){this.z.angle!==t&&(Util.i(t,"number",TreeLayout,"alternateAngle"),(t===0||t===90||t===180||t===270)&&(this.z.angle=t,this.invalidateLayout()))}get alternateAlignment(){return this.z.alignment}set alternateAlignment(t){this.z.alignment!==t&&(this.z.alignment=t,this.invalidateLayout())}get alternateNodeIndent(){return this.z.nodeIndent}set alternateNodeIndent(t){this.z.nodeIndent!==t&&(Util.i(t,"number",TreeLayout,"alternateNodeIndent"),t>=0&&(this.z.nodeIndent=t,this.invalidateLayout()))}get alternateNodeIndentPastParent(){return this.z.nodeIndentPastParent}set alternateNodeIndentPastParent(t){this.z.nodeIndentPastParent!==t&&(Util.i(t,"number",TreeLayout,"alternateNodeIndentPastParent"),t>=0&&t<=1&&(this.z.nodeIndentPastParent=t,this.invalidateLayout()))}get alternateNodeSpacing(){return this.z.nodeSpacing}set alternateNodeSpacing(t){this.z.nodeSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateNodeSpacing"),this.z.nodeSpacing=t,this.invalidateLayout())}get alternateLayerSpacing(){return this.z.layerSpacing}set alternateLayerSpacing(t){this.z.layerSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateLayerSpacing"),this.z.layerSpacing=t,this.invalidateLayout())}get alternateLayerSpacingParentOverlap(){return this.z.layerSpacingParentOverlap}set alternateLayerSpacingParentOverlap(t){this.z.layerSpacingParentOverlap!==t&&(Util.i(t,"number",TreeLayout,"alternateLayerSpacingParentOverlap"),t>=0&&t<=1&&(this.z.layerSpacingParentOverlap=t,this.invalidateLayout()))}get alternateCompaction(){return this.z.compaction}set alternateCompaction(t){this.z.compaction!==t&&(t===30||t===31)&&(this.z.compaction=t,this.invalidateLayout())}get alternateBreadthLimit(){return this.z.breadthLimit}set alternateBreadthLimit(t){this.z.breadthLimit!==t&&(Util.i(t,"number",TreeLayout,"alternateBreadthLimit"),t>=0&&(this.z.breadthLimit=t,this.invalidateLayout()))}get alternateRowSpacing(){return this.z.rowSpacing}set alternateRowSpacing(t){this.z.rowSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateRowSpacing"),this.z.rowSpacing=t,this.invalidateLayout())}get alternateRowIndent(){return this.z.rowIndent}set alternateRowIndent(t){this.z.rowIndent!==t&&(Util.i(t,"number",TreeLayout,"alternateRowIndent"),t>=0&&(this.z.rowIndent=t,this.invalidateLayout()))}get alternateCommentSpacing(){return this.z.commentSpacing}set alternateCommentSpacing(t){this.z.commentSpacing!==t&&(Util.i(t,"number",TreeLayout,"alternateCommentSpacing"),this.z.commentSpacing=t,this.invalidateLayout())}get alternateCommentMargin(){return this.z.commentMargin}set alternateCommentMargin(t){this.z.commentMargin!==t&&(Util.i(t,"number",TreeLayout,"alternateCommentMargin"),this.z.commentMargin=t,this.invalidateLayout())}get alternateSetsPortSpot(){return this.z.setsPortSpot}set alternateSetsPortSpot(t){this.z.setsPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"alternateSetsPortSpot"),this.z.setsPortSpot=t,this.invalidateLayout())}get alternatePortSpot(){return this.z.portSpot}set alternatePortSpot(t){this.z.portSpot.equals(t)||(this.z.portSpot=t,this.invalidateLayout())}get alternateSetsChildPortSpot(){return this.z.setsChildPortSpot}set alternateSetsChildPortSpot(t){this.z.setsChildPortSpot!==t&&(Util.i(t,"boolean",TreeLayout,"alternateSetsChildPortSpot"),this.z.setsChildPortSpot=t,this.invalidateLayout())}get alternateChildPortSpot(){return this.z.childPortSpot}set alternateChildPortSpot(t){this.z.childPortSpot.equals(t)||(this.z.childPortSpot=t,this.invalidateLayout())}static PathDefault=0;static PathDestination=1;static PathSource=2;static SortingForwards=10;static SortingReverse=11;static SortingAscending=12;static SortingDescending=13;static AlignmentCenterSubtrees=20;static AlignmentCenterChildren=21;static AlignmentStart=22;static AlignmentEnd=23;static AlignmentBus=24;static AlignmentBusBranching=25;static AlignmentTopLeftBus=26;static AlignmentBottomRightBus=27;static CompactionNone=30;static CompactionBlock=31;static StyleLayered=40;static StyleLastParents=41;static StyleAlternating=42;static StyleRootOnly=43;static ArrangementVertical=50;static ArrangementHorizontal=51;static ArrangementFixedRoots=52;static LayerIndividual=60;static LayerSiblings=61;static LayerUniform=62}class TreeNetwork extends LayoutNetwork{constructor(t){super(t)}createVertex(){return new TreeVertex(this)}createEdge(){return new TreeEdge(this)}}class TreeVertex extends LayoutVertex{B;mt;ft;gk;mk;pk;yk;wk;xk;bk;Re;Fg;Rg;pe;ye;Xt;oi;$y;Zy;Qy;Ps;_y;tw;iw;ew;sw;nw;ow;rw;lw;hw;aw;constructor(t){super(t),this.gk=!1,this.mk=null,this.pk=[],this.yk=0,this.wk=0,this.xk=0,this.bk=0,this.Re=null,this.B=new Point(0,0),this.mt=new Size(0,0),this.ft=new Point(0,0),this.Fg=null,this.Rg=null,this.pe=10,this.ye=LayoutVertex.standardComparer,this.Xt=0,this.oi=21,this.$y=0,this.Zy=0,this.Qy=20,this.Ps=50,this._y=0,this.tw=31,this.iw=0,this.ew=25,this.sw=10,this.nw=10,this.ow=20,this.rw=!0,this.lw=Spot.Default,this.hw=!0,this.aw=Spot.Default}copyInheritedPropertiesFrom(t){t!==null&&(this.pe=t.sorting,this.ye=t.comparer,this.Xt=t.angle,this.oi=t.alignment,this.$y=t.nodeIndent,this.Zy=t.nodeIndentPastParent,this.Qy=t.nodeSpacing,this.Ps=t.layerSpacing,this._y=t.layerSpacingParentOverlap,this.tw=t.compaction,this.iw=t.breadthLimit,this.ew=t.rowSpacing,this.sw=t.rowIndent,this.nw=t.commentSpacing,this.ow=t.commentMargin,this.rw=t.setsPortSpot,this.lw=t.portSpot,this.hw=t.setsChildPortSpot,this.aw=t.childPortSpot)}get initialized(){return this.gk}set initialized(t){this.gk!==t&&(Util.i(t,"boolean",TreeVertex,"initialized"),this.gk=t)}get parent(){return this.mk}set parent(t){this.mk!==t&&(this.mk=t)}get children(){return this.pk}set children(t){if(this.pk!==t){if(t!==null&&!Array.isArray(t)&&Util.we(t,"Array",TreeVertex,"children:value"),t!==null){const i=t.length;for(let e=0;e4;)t.removePoint(2);u=t.getPoint(1),d=t.getPoint(2)}else{for(f=1;t.pointsCount>3;)t.removePoint(1);u=t.getPoint(0),d=t.getPoint(t.pointsCount-1)}const m=t.getPoint(t.pointsCount-1);let g=0;r===0?(e.alignment===23?(g=o.bottom+n.y,n.y===0&&u.y>m.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.xm.y+e.rowIndent&&(g=Math.min(g,Math.max(u.y,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.top+n.y,n.y===0&&u.ym.x+e.rowIndent&&(g=Math.min(g,Math.max(u.x,g-i.computeNodeIndent(e))))):e.alignment===22?(g=o.left+n.x,n.x===0&&u.x{const i=t.matches?"dark":"light";i!==this.vg&&(this.vg=i,this.Sk==="system"&&this.cw())};constructor(t){t&&Object.assign(this,t),t?.themeMap||(this.iu.set("light",{colors:{...Themes.Light.colors},fonts:{...Themes.Light.fonts},numbers:{...Themes.Light.numbers},margins:{...Themes.Light.margins},arrowheads:{...Themes.Light.arrowheads}}),this.iu.set("dark",{colors:{...Themes.Dark.colors},fonts:{...Themes.Dark.fonts},numbers:{...Themes.Dark.numbers},margins:{...Themes.Dark.margins},arrowheads:{...Themes.Dark.arrowheads}})),root.matchMedia&&(this.vg=root.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}get themeMap(){return this.iu}set themeMap(t){this.iu!==t&&(this.iu=t,this.cw())}get defaultTheme(){return this.Pk}set defaultTheme(t){this.Pk!==t&&(Util.i(t,"string",ThemeManager,"defaultTheme"),this.Pk=t,this.cw())}get currentTheme(){return this.Sk}set currentTheme(t){this.Sk!==t&&(Util.i(t,"string",ThemeManager,"currentTheme"),this.Sk=t,this.cw())}get changesDivBackground(){return this.Mk}set changesDivBackground(t){if(this.Mk!==t&&(this.Mk=t,t))for(const e of this.es)e.setDivBackground(this.findValue("div","","fill")),e.v("ThemeChanged",this)}get preferredColorScheme(){return this.vg}addDiagram(t){return this.es.add(t),this.HN(t),this}removeDiagram(t){return this.es.delete(t),this.HN(t),this}VF(){this.es.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.addEventListener("change",this.SD)}zF(){this.es.size===0&&root.matchMedia&&root.matchMedia("(prefers-color-scheme: dark)")?.removeEventListener("change",this.SD)}set(t,i){t===""&&(t=this.Pk),t==="system"&&(t=this.vg);let e=this.iu.get(t);return e?e=this.MD(e,i):e=i,this.iu.set(t,e),this.cw(),this}findValue(t,i,e){return this.getValue(this.findTheme(this.currentTheme),t,i,e)||this.getValue(this.findTheme(this.defaultTheme),t,i,e)}getValue(t,i,e,s){if(!t)return;e==null&&(e="");let n=t;const o=l=>{if(n===void 0||l==="")return;if(typeof l=="number"||!(Array.isArray(l)||l.includes(".")))return n[l];const h=Array.isArray(l)?l:l.split(".");for(let a=0;a{if(!(e!==""&&(n=o(e),n===void 0)))return Array.isArray(n)&&typeof i=="number"?n=n[i%n.length]:n=o(i),n};if(n=r(),n===void 0&&typeof s=="string"&&s.length>0){let l=t.targetPropertyMap?.get(s);if(l?n=t[l]:(l=ThemeManager.GI.get(s),n=l?t[l]:t.colors),n=r(),n!==void 0)return n}return n}findTheme(t){return this.themeMap.get(t==="system"?this.vg:t)}HN(t){const i=t.skipsUndoManager;t.skipsUndoManager=!0,t.updateAllThemeBindings(),this.Mk&&t.setDivBackground(this.findValue("div","","fill")),t.skipsUndoManager=i,t.v("ThemeChanged",this)}cw(){for(const t of this.es)this.HN(t)}MD(t,i){for(const e in i)if(Util.fw(i,e))try{i[e].constructor===Object?t[e]=this.MD(t[e]??{},i[e]):t[e]=i[e]}catch{delete t[e]}return t}static GI=new Map([["background","colors"],["defaultColumnSeparatorStroke","colors"],["defaultRowSeparatorStroke","colors"],["shadowColor","colors"],["fill","colors"],["stroke","colors"],["font","fonts"],["angle","numbers"],["fromEndSegmentLength","numbers"],["fromShortLength","numbers"],["height","numbers"],["opacity","numbers"],["scale","numbers"],["toEndSegmentLength","numbers"],["toShortLength","numbers"],["width","numbers"],["defaultColumnSeparatorStrokeWidth","numbers"],["defaultRowSeparatorStrokeWidth","numbers"],["shadowBlur","numbers"],["corner","numbers"],["curviness","numbers"],["smoothness","numbers"],["parameter1","numbers"],["parameter2","numbers"],["strokeWidth","numbers"],["strokeDashOffset","numbers"],["maxLines","numbers"],["spacingAbove","numbers"],["spacingBelow","numbers"],["position","points"],["shadowOffset","points"],["desiredSize","sizes"],["maxSize","sizes"],["minSize","sizes"],["margin","margins"],["defaultSeparatorPadding","margins"],["padding","margins"],["alignment","spots"],["alignmentFocus","spots"],["fromSpot","spots"],["toSpot","spots"],["defaultAlignment","spots"],["spot1","spots"],["spot2","spots"],["verticalAlignment","spots"],["imageAlignment","spots"],["fromArrow","arrowheads"],["toArrow","arrowheads"]])}class Router{Mt;p;Oi;ul;constructor(){this.p=Diagram.mm(),this.Mt="",this.Oi=!0,this.ul=!0}get name(){return this.Mt}set name(t){this.Mt=t}get isEnabled(){return this.Oi}set isEnabled(t){this.Oi=t}get isRealtime(){return this.ul}set isRealtime(t){this.ul=t}get diagram(){return this.p}set diagram(t){this.p!==t&&(this.p=t,t.bl=!0,t.requestUpdate())}invalidateRouter(){this.p!==null&&(this.p.bl=!0,this.p.requestUpdate())}canRoute(t){if(!this.isEnabled)return!1;const i=this.diagram;return!(i&&(!this.isRealtime&&i.pu||i.animationManager.isTicking))}routeLinks(t,i){}toString(){return this.name!==""?this.name+" Router":Util.sn(this.constructor)}}class AvoidsNodesRouter extends Router{constructor(t){super(),this.name="AvoidsNodes",t&&Object.assign(this,t)}canRoute(t){return(t instanceof Diagram?t.Ym:t.diagram.Ym)?super.canRoute(t):!1}routeLinks(t,i){i=i instanceof Diagram?null:i;const e=t.iterator,s=this.diagram.getPositions(!0,i,null);for(;e.next();){const n=e.value;if(!n.isAvoiding||i&&n.containingGroup!==i||n.toNode===null||n.fromNode===null||n.pointsCount<4)continue;n.startRoute();const o=n.pointsCount,r=n.getPoint(1),l=n.getPoint(o-2),h=n.fromNode.actualBounds.copy();h.inflate(Link.va,Link.va),h.unionPoint(n.getPoint(0));const a=n.toNode.actualBounds.copy();a.inflate(Link.va,Link.va),a.unionPoint(n.getPoint(o-1)),this.jI(n,h,a,s)&&this.HI(n,r,n.iN,l,n.eN,h,a,s),n.commitRoute()}}jI(t,i,e,s){const n=t.diagram,o=t.pointsCount;if(n===null||t.fromNode===t.toNode||t.layer.isTemporary||i.containsPoint(t.getPoint(o-1))&&!t.toNode.isMemberOf(t.fromNode)||e.containsPoint(t.getPoint(0))&&!t.fromNode.isMemberOf(t.toNode)||!t.isOrthogonal)return!1;if(t.segmentIndex===17)return!0;const r=t.getPoint(1),l=t.getPoint(o-2),h=t.getPoint(2);if(!s.isUnoccupied(Math.min(r.x,h.x),Math.min(r.y,h.y),Math.abs(r.x-h.x),Math.abs(r.y-h.y)))return!0;for(let c=2;c=PositionArray.Bd&&(l.zL(),d.inflate(l.cellWidth*l.vM,l.cellHeight*l.OM),l.rT(i,e,s,n,d,!1),m=l.fo(s.x,s.y)),!l.by&&mPositionArray.Ba&&i.fo(g,p)!==u-1&&(i.fo(d-c,m)===u-1?(n=180,g=d-c,p=m):i.fo(d+c,m)===u-1?(n=0,g=d+c,p=m):i.fo(d,m-f)===u-1?(n=270,g=d,p=m-f):i.fo(d,m+f)===u-1&&(n=90,g=d,p=m+f));u>PositionArray.Ba&&i.fo(g,p)===u-1;)d=g,m=p,n===0?g+=c:n===90?p+=f:n===180?g-=c:p-=f,u-=1;if(o?u>PositionArray.Ba&&(n===180||n===0?d=Math.floor(d/c)*c+c/2:(n===90||n===270)&&(m=Math.floor(m/f)*f+f/2)):(d=Math.floor(d/c)*c+c/2,m=Math.floor(m/f)*f+f/2),u>PositionArray.Ba){let y=n,x=d,k=m;if(n===0?(y=90,k+=f):n===90?(y=180,x-=c):n===180?(y=270,k-=f):n===270&&(y=0,x+=c),i.fo(x,k)===u-1)this.qN(t,i,x,k,y,!1);else{let P=d,S=m;n===0?(y=270,S-=f):n===90?(y=0,P+=c):n===180?(y=90,S+=f):n===270&&(y=180,P-=c),i.fo(P,S)===u-1&&this.qN(t,i,P,S,y,!1)}}t.insertPointAt(t.pointsCount-2,d,m)}}ToolManager.prototype.initializeStandardTools=function(){this.Jt("Action",new ActionTool,this.mouseDownTools),this.Jt("Relinking",new RelinkingTool,this.mouseDownTools),this.Jt("LinkReshaping",new LinkReshapingTool,this.mouseDownTools),this.Jt("Rotating",new RotatingTool,this.mouseDownTools),this.Jt("Resizing",new ResizingTool,this.mouseDownTools),this.Jt("Linking",new LinkingTool,this.mouseMoveTools),this.Jt("Dragging",new DraggingTool,this.mouseMoveTools),this.Jt("DragSelecting",new DragSelectingTool,this.mouseMoveTools),this.Jt("Panning",new PanningTool,this.mouseMoveTools),this.Jt("ContextMenu",new ContextMenuTool,this.mouseUpTools),this.Jt("TextEditing",new TextEditingTool,this.mouseUpTools),this.Jt("ClickCreating",new ClickCreatingTool,this.mouseUpTools),this.Jt("ClickSelecting",new ClickSelectingTool,this.mouseUpTools)};Diagram.gM("GraphLinksModel",GraphLinksPartManager);Diagram.gM("TreeModel",TreePartManager);const oldGo=root.go,go={get version(){return Diagram.version},Group,List,Set:GSet,Map:GMap,Point,Size,Rect,Margin,Spot,Geometry,PathFigure,PathSegment,InputEvent,DiagramEvent,ChangedEvent,Model,GraphLinksModel,TreeModel,Binding,ThemeBinding,Transaction,UndoManager,CommandHandler,Tool,DraggingTool,DraggingInfo,DraggingOptions,LinkingBaseTool,LinkingTool,RelinkingTool,LinkReshapingTool,ResizingTool,RotatingTool,ClickSelectingTool,ActionTool,ClickCreatingTool,HTMLInfo,ContextMenuTool,DragSelectingTool,PanningTool,TextEditingTool,ToolManager,Animation,AnimationManager,AnimationTrigger,Layer,Diagram,Palette,Overview,Brush,GraphObject,Panel,RowColumnDefinition,Shape,TextBlock,Picture,Part,Adornment,Node,Link,Placeholder,Layout,LayoutNetwork,LayoutVertex,LayoutEdge,GridLayout,PanelLayout,CircularLayout,CircularNetwork,CircularVertex,CircularEdge,ForceDirectedLayout,ForceDirectedNetwork,ForceDirectedVertex,ForceDirectedEdge,LayeredDigraphLayout,LayeredDigraphNetwork,LayeredDigraphVertex,LayeredDigraphEdge,TreeLayout,TreeNetwork,TreeVertex,TreeEdge,Themes,ThemeManager,Router,AnimationStyle,AutoScale,CycleMode,Flip,TextFormat,ImageStretch,LayoutConditions,LinkAdjusting,Curve,Routing,Orientation,TextOverflow,PortSpreading,ScrollMode,CollapsePolicy,Sizing,TriggerStart,Stretch,ViewboxStretch,Wrap,BrushType,ColorSpace,GeometryStretch,GeometryType,SegmentType,BindingMode,ChangeType,CircularArrangement,CircularDirection,CircularNodeDiameterFormula,CircularSorting,GridAlignment,GridArrangement,GridSorting,LayeredDigraphAggressive,LayeredDigraphAlign,LayeredDigraphCycleRemove,LayeredDigraphInit,LayeredDigraphLayering,LayeredDigraphPack,TreeAlignment,TreeArrangement,TreeCompaction,TreeLayerStyle,TreePath,TreeSorting,TreeStyle,GestureMode,LinkingDirection,ReshapingBehavior,TextEditingAccept,TextEditingStarting,TextEditingState,WheelMode};typeof oldGo=="object"&&oldGo.version&&Util.ii("WARNING: a `go` object on the root object is already defined. "+("Debug"in oldGo?"debug ":"")+"version: "+oldGo.version+", replaced with version: "+go.version);Diagram.prototype.go=go;root.go=go; })(); diff --git a/samples/Accessibility.html b/samples/Accessibility.html index 62edfd122..40b1edf43 100644 --- a/samples/Accessibility.html +++ b/samples/Accessibility.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Accessibility with AriaCommandHandler | GoJS Diagramming Library + Accessibility in Diagrams with AriaCommandHandler | GoJS Diagramming Library diff --git a/samples/Arranging.html b/samples/Arranging.html index a7981bc14..09339b357 100644 --- a/samples/Arranging.html +++ b/samples/Arranging.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Arranging Layout | GoJS Diagramming Library + Arranging Layout, Layout of Layouts, plus Layout on the Side | GoJS Diagramming Library diff --git a/samples/AvoidsLinksRouter.html b/samples/AvoidsLinksRouter.html index 09f01488a..677955cef 100644 --- a/samples/AvoidsLinksRouter.html +++ b/samples/AvoidsLinksRouter.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Avoids Links Router | GoJS Diagramming Library + Avoids Links Router for Reducing Overlapping Link Segments | GoJS Diagramming Library diff --git a/samples/BalloonLink.html b/samples/BalloonLink.html index f7c598f2b..e04aa6146 100644 --- a/samples/BalloonLink.html +++ b/samples/BalloonLink.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Balloon Links | GoJS Diagramming Library + Balloon Links for Creating Speech Bubbles or Comments for Nodes | GoJS Diagramming Library diff --git a/samples/CheckBoxes.html b/samples/CheckBoxes.html index 0a5b5b79b..011ca626c 100644 --- a/samples/CheckBoxes.html +++ b/samples/CheckBoxes.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Checkboxes | GoJS Diagramming Library + Various Styles of CheckBoxes in Nodes | GoJS Diagramming Library diff --git a/samples/ColumnResizing.html b/samples/ColumnResizing.html index baa58ab77..2f8fb3c5f 100644 --- a/samples/ColumnResizing.html +++ b/samples/ColumnResizing.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Column Resizing | GoJS Diagramming Library + Resizing Rows and Columns in Table Panels in Nodes | GoJS Diagramming Library diff --git a/samples/CurvedLinkReshaping.html b/samples/CurvedLinkReshaping.html index 1ac41c137..9ae75cf4d 100644 --- a/samples/CurvedLinkReshaping.html +++ b/samples/CurvedLinkReshaping.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Curved Link Reshaping | GoJS Diagramming Library + Curved Link Reshaping Using Single Handle | GoJS Diagramming Library diff --git a/samples/DOMTree.html b/samples/DOMTree.html index 5b16217b4..a9a809aec 100644 --- a/samples/DOMTree.html +++ b/samples/DOMTree.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - DOM Tree | GoJS Diagramming Library + Showing HTML DOM Tree as Nodes and Links with TreeLayout | GoJS Diagramming Library diff --git a/samples/DataInspector.html b/samples/DataInspector.html index 7186c60be..aeb4806b7 100644 --- a/samples/DataInspector.html +++ b/samples/DataInspector.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Data Inspector | GoJS Diagramming Library + Data Inspector, Expedient Way to Implement HTML Editor of Data Properties of Selected Node | GoJS Diagramming Library diff --git a/samples/Dimensioning.html b/samples/Dimensioning.html index 2442910ef..d7461d55e 100644 --- a/samples/Dimensioning.html +++ b/samples/Dimensioning.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Dimensioning | GoJS Diagramming Library + Dimensioning Links Showing Distances Between Spots on Two Nodes | GoJS Diagramming Library diff --git a/samples/DragCreating.html b/samples/DragCreating.html index c135633bc..cfffa96a2 100644 --- a/samples/DragCreating.html +++ b/samples/DragCreating.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - DragCreating | GoJS Diagramming Library + Drag Creating Tool Lets Users Draw Box where New Node will be Created | GoJS Diagramming Library diff --git a/samples/DragZooming.html b/samples/DragZooming.html index f6a6fcc56..53bec872a 100644 --- a/samples/DragZooming.html +++ b/samples/DragZooming.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Drag Zooming | GoJS Diagramming Library + Drag Zooming Tool Lets User Draw Box for What Will Be Shown in Viewport | GoJS Diagramming Library diff --git a/samples/DrawCommandHandler.html b/samples/DrawCommandHandler.html index 170ab323c..8914a92ee 100644 --- a/samples/DrawCommandHandler.html +++ b/samples/DrawCommandHandler.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Drawing Commands | GoJS Diagramming Library + Drawing Commands for Aligning, Spacing, Rotating, Z-Ordering, and Arrow Keys | GoJS Diagramming Library diff --git a/samples/Fishbone.html b/samples/Fishbone.html index 665d8eb0c..253fdf1b8 100644 --- a/samples/Fishbone.html +++ b/samples/Fishbone.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Fishbone Layout | GoJS Diagramming Library + Fishbone Layout of Cause-and-Effect Diagrams for Root Cause Analysis | GoJS Diagramming Library diff --git a/samples/FreehandDrawing.html b/samples/FreehandDrawing.html index ade4f8ace..278eb9fc8 100644 --- a/samples/FreehandDrawing.html +++ b/samples/FreehandDrawing.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Freehand Drawing | GoJS Diagramming Library + Freehand Drawing Tool to Draw Lines with Mouse or Finger or Stylus, Supporting Resizing, Reshaping, and Rotating | GoJS Diagramming Library diff --git a/samples/GeometryReshaping.html b/samples/GeometryReshaping.html index ee1537db1..2a0594ac7 100644 --- a/samples/GeometryReshaping.html +++ b/samples/GeometryReshaping.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Geometry Reshaping | GoJS Diagramming Library + Geometry Reshaping Tool for Interactive Reshaping of Shape Geometries | GoJS Diagramming Library diff --git a/samples/GuidedDragging.html b/samples/GuidedDragging.html index 80f7fbee5..a9dbc6bf4 100644 --- a/samples/GuidedDragging.html +++ b/samples/GuidedDragging.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Guided Dragging | GoJS Diagramming Library + Guided Dragging Shows Guidelines During Dragging for Aligning Nodes to other Nodes | GoJS Diagramming Library diff --git a/samples/Hyperlink.html b/samples/Hyperlink.html index 3cd205898..55f3ed13f 100644 --- a/samples/Hyperlink.html +++ b/samples/Hyperlink.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Hyperlinks | GoJS Diagramming Library + Hyperlinks: Underlined Text When Clicked Opens a URL | GoJS Diagramming Library diff --git a/samples/IVRtree.html b/samples/IVRtree.html index 4ed2cc956..09ad8d8a9 100644 --- a/samples/IVRtree.html +++ b/samples/IVRtree.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - IVR Tree | GoJS Diagramming Library + Interactive Voice Response Tree Diagram with Collapsible List of Details | GoJS Diagramming Library diff --git a/samples/LinkLabelDragging.html b/samples/LinkLabelDragging.html index 5a28a71d5..fe5b70bf0 100644 --- a/samples/LinkLabelDragging.html +++ b/samples/LinkLabelDragging.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Link Label Dragging | GoJS Diagramming Library + Dragging Link Label | GoJS Diagramming Library @@ -299,6 +299,7 @@

              diff --git a/samples/cLayout.html b/samples/cLayout.html index 508093133..2213bde52 100644 --- a/samples/cLayout.html +++ b/samples/cLayout.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Circular Layout | GoJS Diagramming Library + Circular Layout Demonstration of CircularLayout options | GoJS Diagramming Library diff --git a/samples/candlestickCharts.html b/samples/candlestickCharts.html index 685ef37a0..59f0f79e5 100644 --- a/samples/candlestickCharts.html +++ b/samples/candlestickCharts.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Candlestick Charts | GoJS Diagramming Library + Candlestick Charts or Range Charts in Nodes | GoJS Diagramming Library diff --git a/samples/canvases.html b/samples/canvases.html index 35ab60313..21184471d 100644 --- a/samples/canvases.html +++ b/samples/canvases.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Charts in Nodes | GoJS Diagramming Library + Charts drawn by Chart.js in Nodes | GoJS Diagramming Library diff --git a/samples/classHierarchy.html b/samples/classHierarchy.html index 835e718e6..a508e9637 100644 --- a/samples/classHierarchy.html +++ b/samples/classHierarchy.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Class Hierarchy | GoJS Diagramming Library + Class Hierarchy Diagram Showing All GoJS Classes | GoJS Diagramming Library diff --git a/samples/comments.html b/samples/comments.html index b3d1d23d2..612292f3d 100644 --- a/samples/comments.html +++ b/samples/comments.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Comments | GoJS Diagramming Library + Comment Nodes Laid out by Tree Layout | GoJS Diagramming Library diff --git a/samples/conceptMap.html b/samples/conceptMap.html index 0ef2bc75a..d74e93ed8 100644 --- a/samples/conceptMap.html +++ b/samples/conceptMap.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Concept Map | GoJS Diagramming Library + Concept Map Showing Idea Nodes Connected by Relationship Links Laid out by Force Directed Layout | GoJS Diagramming Library diff --git a/samples/connectionBoxNode.html b/samples/connectionBoxNode.html index 9d3223145..d3fddfa33 100644 --- a/samples/connectionBoxNode.html +++ b/samples/connectionBoxNode.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Connection Box | GoJS Diagramming Library + Connection Box Editor with Custom Link Validation | GoJS Diagramming Library diff --git a/samples/constantSize.html b/samples/constantSize.html index ccbed578a..19485baf3 100644 --- a/samples/constantSize.html +++ b/samples/constantSize.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Constant Size | GoJS Diagramming Library + Constant Size Nodes While Zooming in or out | GoJS Diagramming Library diff --git a/samples/contentAlign.html b/samples/contentAlign.html index 6523b67db..2bb63c54e 100644 --- a/samples/contentAlign.html +++ b/samples/contentAlign.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Content Alignment | GoJS Diagramming Library + Content Alignment Demonstration | GoJS Diagramming Library diff --git a/samples/controlGauges.html b/samples/controlGauges.html index fe9e80039..a55fb936c 100644 --- a/samples/controlGauges.html +++ b/samples/controlGauges.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Meter and Gauge Controls | GoJS Diagramming Library + Meter and Gauge Controls Drawn in Nodes Connected by Flows | GoJS Diagramming Library diff --git a/samples/customAnimations.html b/samples/customAnimations.html index e05edab5c..d8404e8a6 100644 --- a/samples/customAnimations.html +++ b/samples/customAnimations.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Custom Animations | GoJS Diagramming Library + Custom Node Animations Demonstration | GoJS Diagramming Library diff --git a/samples/customContextMenu.html b/samples/customContextMenu.html index 5e19028ac..64d8ab5ac 100644 --- a/samples/customContextMenu.html +++ b/samples/customContextMenu.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Context Menu | GoJS Diagramming Library + Custom HTML Context Menu for Nodes and Diagram | GoJS Diagramming Library diff --git a/samples/customExpandCollapse.html b/samples/customExpandCollapse.html index 4aabd284e..c8706e56b 100644 --- a/samples/customExpandCollapse.html +++ b/samples/customExpandCollapse.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Custom Expand and Collapse | GoJS Diagramming Library + Custom Expand and Collapse Buttons for Non-Tree Graphs | GoJS Diagramming Library diff --git a/samples/customTextEditingTool.html b/samples/customTextEditingTool.html index 51f615afd..983a4b389 100644 --- a/samples/customTextEditingTool.html +++ b/samples/customTextEditingTool.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Custom Text Editor | GoJS Diagramming Library + Custom Select Box and Radio Button Text Editors for In-Place Editing of Text | GoJS Diagramming Library @@ -134,9 +134,7 @@ 'undoManager.isEnabled': true }); - var brush = new go.Brush(go.BrushType.Linear); - brush.addColorStop(0, 'rgb(255, 211, 89)'); - brush.addColorStop(1, 'rgb(255, 239, 113)'); + var brush = new go.Brush(go.BrushType.Linear, { 0: 'rgb(255, 211, 89)', 1: 'rgb(255, 239, 113)' }); myDiagram.nodeTemplate = new go.Node('Vertical', { resizable: true, diff --git a/samples/dataFlow.html b/samples/dataFlow.html index e69c06e76..7c1a724c7 100644 --- a/samples/dataFlow.html +++ b/samples/dataFlow.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Data Flow | GoJS Diagramming Library + Data Flow Diagram of SQL Operation Nodes with Multiple Labeled Input and Output Ports | GoJS Diagramming Library diff --git a/samples/dataFlowVertical.html b/samples/dataFlowVertical.html index bd3cd73fb..393fb0e6c 100644 --- a/samples/dataFlowVertical.html +++ b/samples/dataFlowVertical.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Data Flow Vertical | GoJS Diagramming Library + Vertical Data Flow Diagram of SQL Operation Nodes with Multiple Labeled Input and Output Ports | GoJS Diagramming Library diff --git a/samples/dataVisualization.html b/samples/dataVisualization.html index a62153fed..5c0364e12 100644 --- a/samples/dataVisualization.html +++ b/samples/dataVisualization.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Data Visualization | GoJS Diagramming Library + Data Visualization of Multi-Dimensional Data using Nodes and ToolTips | GoJS Diagramming Library diff --git a/samples/decisionTree.html b/samples/decisionTree.html index 5cc016300..722ccd128 100644 --- a/samples/decisionTree.html +++ b/samples/decisionTree.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Decision Tree | GoJS Diagramming Library + Interactive Decision Tree Diagram Incrementally User-Expanded | GoJS Diagramming Library diff --git a/samples/distances.html b/samples/distances.html index 0df5be205..e995293af 100644 --- a/samples/distances.html +++ b/samples/distances.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Distances & Paths | GoJS Diagramming Library + Finding and Highlighting Node-Link Paths in Graphs | GoJS Diagramming Library diff --git a/samples/donutCharts.html b/samples/donutCharts.html index 05015ce09..ab96b12c1 100644 --- a/samples/donutCharts.html +++ b/samples/donutCharts.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Donut Charts | GoJS Diagramming Library + Donut Charts Implemented as Shapes in Nodes | GoJS Diagramming Library diff --git a/samples/doubleCircle.html b/samples/doubleCircle.html index 96e601458..540a6a115 100644 --- a/samples/doubleCircle.html +++ b/samples/doubleCircle.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Double Circle | GoJS Diagramming Library + Multiple Concentric Circles of Nodes Laid out by Circular Layout | GoJS Diagramming Library diff --git a/samples/doubleTree.html b/samples/doubleTree.html index 4bd6790cf..2fa64360e 100644 --- a/samples/doubleTree.html +++ b/samples/doubleTree.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Double Tree | GoJS Diagramming Library + Double Tree of Nodes and Links Laid out by TreeLayout in Two Opposite Directions from Root Node | GoJS Diagramming Library diff --git a/samples/dragDropFields.html b/samples/dragDropFields.html index 31e6b1406..0ce915e3a 100644 --- a/samples/dragDropFields.html +++ b/samples/dragDropFields.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Drag and Drop Fields | GoJS Diagramming Library + Drag and Drop Fields Between Nodes | GoJS Diagramming Library @@ -129,10 +129,11 @@ // Custom DraggingTool for dragging fields instead of whole Parts. // FieldDraggingTool.fieldTemplate needs to be set to a template of the field that you want shown while dragging. class FieldDraggingTool extends go.DraggingTool { - constructor() { + constructor(init) { super(); this.fieldTemplate = null; // THIS NEEDS TO BE SET before a drag starts this.temporaryPart = null; + if (init) Object.assign(this, init); } // override this method diff --git a/samples/dragOutFields.html b/samples/dragOutFields.html index bfce085db..11e5086d1 100644 --- a/samples/dragOutFields.html +++ b/samples/dragOutFields.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Drag Out Fields | GoJS Diagramming Library + Drag Fields Out of Diagram to HTML Element | GoJS Diagramming Library @@ -126,11 +126,12 @@ // Custom DraggingTool for dragging fields instead of whole Parts. // FieldDraggingTool.fieldTemplate needs to be set to a template of the field that you want shown while dragging. class FieldDraggingTool extends go.DraggingTool { - constructor() { + constructor(init) { super(); this.fieldTemplate = null; // THIS NEEDS TO BE SET before a drag starts this.temporaryPart = null; this.temporaryImage = null; + if (init) Object.assign(this, init); } // override this method diff --git a/samples/dragUnoccupied.html b/samples/dragUnoccupied.html index d8fbe5a07..7123b8657 100644 --- a/samples/dragUnoccupied.html +++ b/samples/dragUnoccupied.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Drag Unoccupied | GoJS Diagramming Library + Limit Dragging of Nodes to Unoccupied Areas in Diagram | GoJS Diagramming Library diff --git a/samples/draggableLink.html b/samples/draggableLink.html index 58aba3824..dc1430206 100644 --- a/samples/draggableLink.html +++ b/samples/draggableLink.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Draggable Link | GoJS Diagramming Library + Allow Users to Drag Links and Reconnect Them on Drop | GoJS Diagramming Library @@ -447,6 +447,7 @@ { "class": "go.GraphLinksModel", "linkFromPortIdProperty": "fromPort", "linkToPortIdProperty": "toPort", + "pointsDigits": 1, "nodeDataArray": [ ], "linkDataArray": [ diff --git a/samples/dynamicPieChart.html b/samples/dynamicPieChart.html index fa51dedac..7ab662416 100644 --- a/samples/dynamicPieChart.html +++ b/samples/dynamicPieChart.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Dynamic Pie Chart | GoJS Diagramming Library + Pie Chart Supporting Selection of Slices and Dynamically Changing Values | GoJS Diagramming Library diff --git a/samples/dynamicPorts.html b/samples/dynamicPorts.html index 1bd902fe6..0fa0d3783 100644 --- a/samples/dynamicPorts.html +++ b/samples/dynamicPorts.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Dynamic Ports | GoJS Diagramming Library + Add/Remove/Modify Ports Dynamically on Nodes | GoJS Diagramming Library @@ -519,6 +519,7 @@ "copiesArrayObjects": true, "linkFromPortIdProperty": "fromPort", "linkToPortIdProperty": "toPort", + "pointsDigits": 1, "nodeDataArray": [ {"key":1, "name":"Unit One", "loc":"101 204", "leftArray":[ {"portColor":0, "portId":"left0"} ], diff --git a/samples/entityRelationship.html b/samples/entityRelationship.html index 704d9d7a7..b0d9424c6 100644 --- a/samples/entityRelationship.html +++ b/samples/entityRelationship.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Entity Relationship | GoJS Diagramming Library + Entity Relationship Diagram Nodes have Collapsible Lists of Attributes | GoJS Diagramming Library diff --git a/samples/euler.html b/samples/euler.html index c5895f551..e545f03c6 100644 --- a/samples/euler.html +++ b/samples/euler.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Euler Diagram | GoJS Diagramming Library + Euler Diagrams Show Sets and Varied Relationships | GoJS Diagramming Library @@ -150,19 +150,19 @@ .add( new go.Shape('Circle', { fill: 'rgba(128,128,128,0.1)', - stroke: null, + stroke: 'lightgray', width: 550, height: 550 }), new go.Shape('Circle', { - fill: 'rgba(128,128,128,0.05)', - stroke: null, + fill: 'rgba(128,128,128,0.1)', + stroke: 'lightgray', width: 400, height: 400 }), new go.Shape('Circle', { - fill: 'rgba(128,128,128,0.033)', - stroke: null, + fill: 'rgba(128,128,128,0.1)', + stroke: 'lightgray', width: 250, height: 250 }), diff --git a/samples/familyTree.html b/samples/familyTree.html index bbcbda0f2..7b4c4541b 100644 --- a/samples/familyTree.html +++ b/samples/familyTree.html @@ -6,10 +6,10 @@ - - - - + + + + @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Family Tree Diagram | GoJS Diagramming Library + Family Tree Diagram of British Nobility | GoJS Diagramming Library @@ -934,7 +934,7 @@

              This GoJS sample was designed by Synergy Codes, our consultant partner with over a decade of experience and cooperation with the GoJS team.

              -

              This family tree diagram shows several generations of British royalty beginning with George V (1865-1936).

              +

              This family tree diagram shows several generations of British nobility beginning with George V (1865-1936).

              Node data contains information about gender, and a data binding assigns a corresponding color.

              For a more rudimentary family tree, see the Japanese family tree sample.

              For a more complex family tree see the genogram sample.

              diff --git a/samples/familyTreeJP.html b/samples/familyTreeJP.html index b9a561b8e..cc125b1de 100644 --- a/samples/familyTreeJP.html +++ b/samples/familyTreeJP.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Family Tree (Japanese) | GoJS Diagramming Library + Family Tree Diagram, Japanese | GoJS Diagramming Library @@ -790,6 +790,35 @@

              ToolTips


              + + +

              Legend

              +

              + A Legend can be created for a Diagram using a simple Part. + Typically that is added directly to the Diagram as an unmodeled Part, not as a template with data in the Model. + However you may want to define a template and add a legend data object to the model so that + you can parameterize the legend with information persisted with the model. +

              +

              + Usually a legend will be created as an "Auto" Panel for a border around a "Table" Panel + holding information about the types of nodes and/or links that are in the diagram. +

              +

              + It probably will want to be in the "ViewportBackground" or "ViewportForeground" Layer so that it is always + visible in the viewport despite scrolling or zooming. + Set the GraphObject.alignment property to position it where you want it to be; + by default it will be in the lower right corner. + However you may want to treat the legend Part as a regular Part in the Diagram, possibly laid out by + the diagram's Diagram.layout. +

              +

              + More information can be found in the GoJS Intro. +

              +

              + Related samples +

              +
              +
              diff --git a/samples/faultTree.html b/samples/faultTree.html index 929312e15..a4105cfdd 100644 --- a/samples/faultTree.html +++ b/samples/faultTree.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Fault Tree | GoJS Diagramming Library + Fault Tree Analysis Diagram Where Gate-Figure Shapes Describe Relationships of Contributing Conditions to Subsystem Nodes | GoJS Diagramming Library @@ -154,29 +154,13 @@ switch (figure) { case 'AndGate': // right to left so when it's rotated, it goes from top to bottom - return new go.Brush('Linear', { - 0: '#EA8100', - 1: '#C66D00', - start: go.Spot.Right, - end: go.Spot.Left - }); + return new go.Brush('Linear', { 0: '#EA8100', 1: '#C66D00', start: go.Spot.Right, end: go.Spot.Left }); case 'OrGate': - return new go.Brush('Linear', { - 0: '#0058D3', - 1: '#004FB7', - start: go.Spot.Right, - end: go.Spot.Left - }); + return new go.Brush('Linear', { 0: '#0058D3', 1: '#004FB7', start: go.Spot.Right, end: go.Spot.Left }); case 'Circle': - return new go.Brush('Linear', { - 0: '#009620', - 1: '#007717' - }); + return new go.Brush('Linear', { 0: '#009620', 1: '#007717' }); case 'Triangle': - return new go.Brush('Linear', { - 0: '#7A0099', - 1: '#63007F' - }); + return new go.Brush('Linear', { 0: '#7A0099', 1: '#63007F' }); default: return 'whitesmoke'; } diff --git a/samples/fdLayout.html b/samples/fdLayout.html index ad2e72f98..9e7a91149 100644 --- a/samples/fdLayout.html +++ b/samples/fdLayout.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Force Directed | GoJS Diagramming Library + Force Directed Layout Demonstration of ForceDirectedLayout Options | GoJS Diagramming Library @@ -128,6 +128,11 @@
              -
              +
              +
              + +
              +
              + + + +

              A genogram or pedigree chart is an extended family tree diagram that displays information about - each person or each relationship.

              + each person or each relationship. + The proband is the person about whom the genetic study is focused -- that node is highlighted with an arrow. + In this case we focus on "Bill". +

              +

              + There is support for twins or triplets, both fraternal and identical. +

              +

              + When the mouse passes over a node, all other nodes representing people who are direct ancestors or descendants are highlighted. +

              Note that the term "marriage" here does not refer to a legal or cultural kind of relationship, but simply one representing the female and male genetic sources for any children.

              There are functions that convert an attribute value into a brush color or Shape geometry, - to be added to the Node representing the person. + to be added to the Node representing the person. These can be adapted for your app's specific purposes. +

              +

              + Although this uses an Inspector to show the values of the data properties for the first selected node, nothing can be changed in this sample. + We also have a version of this sample that supports editing the graph.

              A custom LayeredDigraphLayout does the layout, assuming there is a central person whose mother and father - each have their own ancestors. In this case we focus on "Bill", but any of the children of "Alice" and "Aaron" would - work. - The overridden add function allows husband/wife pairs to be represented by a single - LayeredDigraphVertex. + each have their own ancestors. + Husband/wife node pairs are represented by a single LayeredDigraphVertex.

              For a simpler family tree, see the family tree sample or Japanese family tree sample.

              -

              - The node data representing the people, processed by the setupDiagram function is below. - The properties are: -

                -
              • key, the unique ID of the person
              • -
              • n, the person's name
              • -
              • s, the person's sex
              • -
              • m, the person's mother's key
              • -
              • f, the person's father's key
              • -
              • ux, the person's wife
              • -
              • vir, the person's husband
              • -
              • a, an Array of the attributes or markers that the person has
              • -
              -

              -
              + + Diagram model saved in JSON format: +
              diff --git a/samples/gestureBehavior.html b/samples/gestureBehavior.html index 1e77dbe84..afc28e4ab 100644 --- a/samples/gestureBehavior.html +++ b/samples/gestureBehavior.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Gesture Behavior | GoJS Diagramming Library + Various Gesture Behaviors Demonstration | GoJS Diagramming Library diff --git a/samples/grafcet.html b/samples/grafcet.html index 953dfe8e6..a6551c2d8 100644 --- a/samples/grafcet.html +++ b/samples/grafcet.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Grafcet Diagrams | GoJS Diagramming Library + Grafcet Diagram Editor, Type of Sequential Function Chart for Automation Design | GoJS Diagramming Library @@ -476,7 +476,7 @@ stroke: 'red', width: 200 }) - .bind('desiredSize', 'size', go.Size.parse, go.Size.stringify) + .bindTwoWay('desiredSize', 'size', go.Size.parse, go.Size.stringify) ) ) ); @@ -500,7 +500,7 @@ stroke: 'red', width: 200 }) - .bind('desiredSize', 'size', go.Size.parse, go.Size.stringify) + .bindTwoWay('desiredSize', 'size', go.Size.parse, go.Size.stringify) ) ) ); @@ -592,6 +592,11 @@ // This custom LinkingTool just turns on Diagram.allowLink when it starts, // and turns it off again when it stops so that users cannot draw new links modelessly. class CustomLinkingTool extends go.LinkingTool { + constructor(init) { + super(); + if (init) Object.assign(this, init); + } + // user-drawn linking is normally disabled, // but needs to be turned on when using this tool doStart() { @@ -609,6 +614,11 @@ // This custom Link class is smart about computing the link point and direction // at "Parallel" and "Exclusive" nodes. class BarLink extends go.Link { + constructor(init) { + super(); + if (init) Object.assign(this, init); + } + getLinkPoint(node, port, spot, from, ortho, othernode, otherport) { const r = port.getDocumentBounds(); const op = otherport.getDocumentBounds(); diff --git a/samples/grouping.html b/samples/grouping.html index b2709a0ee..fac8f883a 100644 --- a/samples/grouping.html +++ b/samples/grouping.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Grouping | GoJS Diagramming Library + Creating SubGraphs only when Expanding a Group the First Time | GoJS Diagramming Library diff --git a/samples/hoverButtons.html b/samples/hoverButtons.html index 5b78456cc..14c8a67d0 100644 --- a/samples/hoverButtons.html +++ b/samples/hoverButtons.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Hover Buttons | GoJS Diagramming Library + Buttons Shown on Hover over Node | GoJS Diagramming Library diff --git a/samples/htmlDragDrop.html b/samples/htmlDragDrop.html index e9ee1d000..748718a93 100644 --- a/samples/htmlDragDrop.html +++ b/samples/htmlDragDrop.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - HTML Drag and Drop | GoJS Diagramming Library + Drag and Drop From HTML Element to Diagram | GoJS Diagramming Library diff --git a/samples/htmlInteraction.html b/samples/htmlInteraction.html index e741e8524..056e18646 100644 --- a/samples/htmlInteraction.html +++ b/samples/htmlInteraction.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - HTML Interaction | GoJS Diagramming Library + HTML Interaction Showing Draggable Palette and Draggable Inspector | GoJS Diagramming Library diff --git a/samples/htmlLightBoxContextMenu.html b/samples/htmlLightBoxContextMenu.html index 739907636..b0ab43d9c 100644 --- a/samples/htmlLightBoxContextMenu.html +++ b/samples/htmlLightBoxContextMenu.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - HTML LightBox Context Menu | GoJS Diagramming Library + LightBox Style HTML Context Menu | GoJS Diagramming Library diff --git a/samples/icons.html b/samples/icons.html index 83da0187a..17ff4b40a 100644 --- a/samples/icons.html +++ b/samples/icons.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - SVG Icons | GoJS Diagramming Library + SVG Icons: Using SVG Path Strings as Shapes in Nodes | GoJS Diagramming Library diff --git a/samples/incrementalTree.html b/samples/incrementalTree.html index c7b2a3d56..9d87cbc93 100644 --- a/samples/incrementalTree.html +++ b/samples/incrementalTree.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Incremental Tree | GoJS Diagramming Library + Expanding SubTree First Time Incrementally Adds Nodes | GoJS Diagramming Library diff --git a/samples/index.html b/samples/index.html index 5939ef644..e57622006 100644 --- a/samples/index.html +++ b/samples/index.html @@ -229,6 +229,10 @@ layered-digraph (0) + + + legend + (0) links @@ -352,7 +356,7 @@

              GoJS Samples

              data-tags="palette,svg,process,theme">
              A flowchart and palette, showing different node templates and data bindings. Each node has 3 or 4 port elements. Links are orthogonal and automatically avoidnodes. + alt="A flowchart and palette, showing different node templates and data bindings. Each node has only one port element. Links are orthogonal and automatically route to avoid nodes." class="absolute inset-0 h-full w-full" />

              @@ -365,7 +369,7 @@

              -

              A flowchart and palette, showing different node templates and data bindings. Each node has 3 or 4 port elements. Links are orthogonal and automatically avoidnodes.

              +

              A flowchart and palette, showing different node templates and data bindings. Each node has only one port element. Links are orthogonal and automatically route to avoid nodes.

              - State Chart Diagram + State Chart Editor @@ -420,7 +424,7 @@

              - Family Tree Diagram + Family Tree @@ -440,7 +444,7 @@

              - Organizational Chart Diagram with Overview + Org Chart with Overview @@ -460,7 +464,7 @@

              - Genogram Family Tree Diagram + Genogram Family Tree @@ -480,7 +484,7 @@

              - Industrial Monitor SCADA diagram + SCADA Industrial Monitor @@ -500,7 +504,7 @@

              - Network Configuration Diagram + Network Editor @@ -520,7 +524,7 @@

              - Process Flow SCADA Diagram + Process Flow @@ -540,7 +544,7 @@

              - Security Monitor Diagram + Security Monitor @@ -560,7 +564,7 @@

              - Warehouse Design Diagram + Warehouse Designer @@ -609,43 +613,43 @@

              + data-tags="tables,gridlayout,layered-digraph,customlayout,groups,tools,buttons">
              - A Kanban board editor, allowing the categorization of editable tasks. + Demonstrates collapsible, resizable, re-orderable swimlanes, a kind of process-flow diagram, with custom dragging rules that disallow nodes from leaving their lane.

              - + - Interactive Kanban Board Diagram + Swim Lanes

              -

              A Kanban board editor, allowing the categorization of editable tasks.

              +

              Demonstrates collapsible, resizable, re-orderable swimlanes, a kind of process-flow diagram, with custom dragging rules that disallow nodes from leaving their lane.

              + data-tags="tables,gridlayout,customlayout,groups,buttons,process,legend">
              - Layer Bands are automatically created for each 'layer' of a TreeLayout, and run perpendicular to the layout. + A Kanban board editor, allowing the categorization of editable tasks.

              - + - Layer Bands + Kanban Board Editor

              -

              Layer Bands are automatically created for each 'layer' of a TreeLayout, and run perpendicular to the layout.

              +

              A Kanban board editor, allowing the categorization of editable tasks.

              - Logic Circuit Diagram + Logic Circuit

              A functioning logic circuit diagram, which allows the user to make circuits using gates and wires.

              +
              +
              + Layer Bands are automatically created for each 'layer' of a TreeLayout, and run perpendicular to the layout. +
              +
              +

              + + + + + Layer Bands + + + +

              +

              Layer Bands are automatically created for each 'layer' of a TreeLayout, and run perpendicular to the layout.

              +
              @@ -680,7 +704,7 @@

              - Pipes Diagram + Pipes Diagram Editor @@ -700,7 +724,7 @@

              - Process Editor Diagram + Production Process Editor @@ -720,7 +744,7 @@

              - Production Process Diagram + Production Process @@ -740,7 +764,7 @@

              - Record Mapper Diagram + Record Mapper @@ -761,7 +785,7 @@

              - Regrouping Diagram + Regrouping Editor @@ -782,33 +806,13 @@

              - Seating Chart Diagram + Seating Chart

              This sample demonstrates custom logic in a GoJS diagram - a 'Person' node can be dropped onto a 'Table' node, causing the person to be assigned a position at the closest empty seat at that table.

              -
              -
              - Demonstrates collapsible, resizable, re-orderable swimlanes, a kind of process-flow diagram, with custom dragging rules that disallow nodes from leaving their lane. -
              -
              -

              - - - - - Swim Lanes - - - -

              -

              Demonstrates collapsible, resizable, re-orderable swimlanes, a kind of process-flow diagram, with custom dragging rules that disallow nodes from leaving their lane.

              -
              @@ -854,7 +858,7 @@

              data-tags="gridlayout,geometries">
              Showcases all pre-defined GoJS figures. You can define your own named Shape figures. + alt="Showcases all GoJS figures. You can define your own named Shape figures." class="absolute inset-0 h-full w-full" />

              @@ -862,12 +866,12 @@

              - Shapes + Shape Figures

              -

              Showcases all pre-defined GoJS figures. You can define your own named Shape figures.

              +

              Showcases all GoJS figures. You can define your own named Shape figures.

              - Dimensioning + Dimensioning Links @@ -963,7 +967,7 @@

              - Block Diagram + Block Diagram Editor @@ -984,7 +988,7 @@

              - Meter and Gauge Controls + Meters and Gauges @@ -1044,7 +1048,7 @@

              - Accessibility with AriaCommandHandler + ARIA Accessibility @@ -1056,7 +1060,7 @@

              data-tags="tables,itemarrays,html">
              Demonstrates adding and removing columns of a Table Panel. + alt="Demonstrates adding and removing and swapping columns of a Table Panel." class="absolute inset-0 h-full w-full" />

              @@ -1064,12 +1068,12 @@

              - Add/Remove Table Columns + Add/Remove/Swap Columns in Table Panels

              -

              Demonstrates adding and removing columns of a Table Panel.

              +

              Demonstrates adding and removing and swapping columns of a Table Panel.

              - Adding Nodes to the Palette + Adding Node to Palette @@ -1093,23 +1097,43 @@

              + data-tags="links,circularlayout,tooltips,geometries,circle-like">
              - Selected nodes show a row of buttons that execute commands or start tools. + Showcases all pre-defined Link arrowheads. You can define your own named arrowhead geometries.

              - + - Adornment Buttons + All Predefined Arrowheads for Links

              -

              Selected nodes show a row of buttons that execute commands or start tools.

              +

              Showcases all pre-defined Link arrowheads. You can define your own named arrowhead geometries.

              +
              +
              +
              + Showcases draggable disconnectable links that can be connected by dropping one or both ends at a valid port. +
              +
              +

              + + + + + Draggable Link + + + +

              +

              Showcases draggable disconnectable links that can be connected by dropping one or both ends at a valid port.

              - Animated Scroll and Attention + Animated Node Attention @@ -1133,43 +1157,43 @@

              + data-tags="collections,force-directed,animation">
              - The Arranging layout is a layout of layouts, plus a third layout for arranging left-overs. + Animation of diagram parts (tokens) along link paths.

              - + - Arranging Layout + Animation of Tokens along Link Paths

              -

              The Arranging layout is a layout of layouts, plus a third layout for arranging left-overs.

              +

              Animation of diagram parts (tokens) along link paths.

              + data-tags="gridlayout,customlayout,extensions">
              - Showcases all pre-defined Link arrowheads. You can define your own named arrowhead geometries. + The Arranging layout is a layout of layouts, plus a third layout for arranging left-overs.

              - + - Arrowheads + Arranging Layout

              -

              Showcases all pre-defined Link arrowheads. You can define your own named arrowhead geometries.

              +

              The Arranging layout is a layout of layouts, plus a third layout for arranging left-overs.

              - Balloon Links + Ballon Links @@ -1224,7 +1248,7 @@

              - Bar Charts + Bar Charts in Nodes @@ -1244,7 +1268,7 @@

              - Basic + Basic with ToolTips and Context Menus @@ -1313,63 +1337,63 @@

              + data-tags="buttons">
              - Simple candlestick or range charts within nodes. + Shows buttons in an Adornment upon hover over a node.

              - + - Candlestick Charts + Buttons Shown on Hover

              -

              Simple candlestick or range charts within nodes.

              +

              Shows buttons in an Adornment upon hover over a node.

              + data-tags="tables,itemarrays,geometries,charts">
              - Shows how to render a data-driven chart within each Node using the Chart.js library. + Simple candlestick or range charts within nodes.

              - + - Charts in Nodes + Candlestick Charts

              -

              Shows how to render a data-driven chart within each Node using the Chart.js library.

              +

              Simple candlestick or range charts within nodes.

              + data-tags="charts,html,frameworks">
              - Demonstrates simple uses of CheckBoxButtons. + Shows how to render a data-driven chart within each Node using the Chart.js library.

              - + - Checkboxes + Chart.js Charts in Nodes

              -

              Demonstrates simple uses of CheckBoxButtons.

              +

              Shows how to render a data-driven chart within each Node using the Chart.js library.

              - Circular Layout + Circular Layout Demo @@ -1404,7 +1428,7 @@

              - Class Hierarchy + Class Hierarchy Diagram @@ -1413,23 +1437,23 @@

          + data-tags="extensions,storage">
          - Two custom Tools that let the user resize the width of columns or the height of rows in a Table Panel of a Node. + Demonstrates custom CommandHandler which uses localStorage as the repository for the clipboard, rather than an in-memory global variable, allowing for copying between tabs and windows.

          - + - Column Resizing + Local Storage Clipboard

          -

          Two custom Tools that let the user resize the width of columns or the height of rows in a Table Panel of a Node.

          +

          Demonstrates custom CommandHandler which uses localStorage as the repository for the clipboard, rather than an in-memory global variable, allowing for copying between tabs and windows.

          - Comments + Comment Nodes @@ -1471,6 +1495,26 @@

          A web of interlinked concepts displayed with a ForceDirected Layout, showcasing link labels.

          +
          +
          + Demonstrates the ability for a Link to appear to connect with another Link, using label nodes that belong to links. +
          +
          +

          + + + + + Connecting Links to Links Using Link Label Nodes + + + +

          +

          Demonstrates the ability for a Link to appear to connect with another Link, using label nodes that belong to links.

          +
          @@ -1484,7 +1528,7 @@

          - Connection Box + Connection Box Editor @@ -1504,7 +1548,7 @@

          - Constant Size + Constant Size Nodes While Zooming in or out @@ -1524,7 +1568,7 @@

          - Content Alignment + Content Alignment Demo @@ -1533,23 +1577,23 @@

          + data-tags="treelayout,groups,buttons">
          - Demonstrates the implementation of a custom HTML context menu. + Demonstrates subgraphs that are created only as groups are expanded.

          - + - Context Menu + Grouping

          -

          Demonstrates the implementation of a custom HTML context menu.

          +

          Demonstrates subgraphs that are created only as groups are expanded.

          - Curved Link Reshaping + Curved Link Reshaping Using Single Handle @@ -1573,243 +1617,283 @@

          + data-tags="collections,links">
          - Shows how to create several custom Node animations. + Demonstrates custom routing for Links running through other Nodes.

          - + - Custom Animations + Curved Multi-Node Path Link Routes

          -

          Shows how to create several custom Node animations.

          +

          Demonstrates custom routing for Links running through other Nodes.

          + data-tags="animation">
          - Shows how to create Buttons with custom behavior for expanding/collapsing of a graph. + Shows how to create a custom Diagram loading animation.

          - + - Custom Expand and Collapse + Custom Animations Loading Tree

          -

          Shows how to create Buttons with custom behavior for expanding/collapsing of a graph.

          +

          Shows how to create a custom Diagram loading animation.

          + data-tags="layered-digraph,buttons">
          - Demonstrates using a custom HTML element for in-place editing of a TextBlock. + Shows how to create Buttons with custom behavior for expanding/collapsing of a graph.

          - + - Custom Text Editor + Custom Expand/Collapse

          -

          Demonstrates using a custom HTML element for in-place editing of a TextBlock.

          +

          Shows how to create Buttons with custom behavior for expanding/collapsing of a graph.

          + data-tags="contextmenus,html">
          - Show the processing steps involved in a database transformation or query, with labeled ports. + Demonstrates the implementation of a custom HTML context menu.

          - + - Data Flow + HTML Context Menu

          -

          Show the processing steps involved in a database transformation or query, with labeled ports.

          +

          Demonstrates the implementation of a custom HTML context menu.

          + data-tags="links,geometries,extensions">
          - Same as Data Flow, but vertically oriented, and with slightly different styling. + Demonstrates custom Links that route parallel to other Links between the same two ports.

          - + - Data Flow Vertical + Parallel Routing

          -

          Same as Data Flow, but vertically oriented, and with slightly different styling.

          +

          Demonstrates custom Links that route parallel to other Links between the same two ports.

          + data-tags="animation">
          - A simple drop-in for inspecting and editing Part data. + Shows how to create several custom Node animations.

          - + - Data Inspector + Custom Node Animations

          -

          A simple drop-in for inspecting and editing Part data.

          +

          Shows how to create several custom Node animations.

          + data-tags="">
          - A data-visualization demonstration that showcases GoJS interacting with other elements on the page. + Shows how to create a custom PaneLayout.

          - + - Data Visualization + Custom Panel Layout: Cascading Elements

          -

          A data-visualization demonstration that showcases GoJS interacting with other elements on the page.

          +

          Shows how to create a custom PaneLayout.

          + data-tags="html">
          - Allows a user to make progressive decisions. + Demonstrates using a custom HTML element for in-place editing of a TextBlock.

          - + - Decision Tree + Custom Text Editors

          -

          Allows a user to make progressive decisions.

          +

          Demonstrates using a custom HTML element for in-place editing of a TextBlock.

          + data-tags="tables,layered-digraph,ports,process">
          - Show distances between two nodes and highlights one of all possible paths between the nodes. + Show the processing steps involved in a database transformation or query, with labeled ports.

          - + - Distances & Paths + Data Flow Diagram

          -

          Show distances between two nodes and highlights one of all possible paths between the nodes.

          +

          Show the processing steps involved in a database transformation or query, with labeled ports.

          + data-tags="groups,extensions,inspector,html">
          - Shows the DOM of this page displayed as a tree. Selection highlights the DOM element in the page. + A simple drop-in for inspecting and editing Part data.

          - + - DOM Tree + Data Inspector

          -

          Shows the DOM of this page displayed as a tree. Selection highlights the DOM element in the page.

          +

          A simple drop-in for inspecting and editing Part data.

          + data-tags="tooltips,html,animation">
          - Ring-shaped pie charts within nodes. + A data-visualization demonstration that showcases GoJS interacting with other elements on the page.

          - + - Donut Charts + Data Visualization

          -

          Ring-shaped pie charts within nodes.

          +

          A data-visualization demonstration that showcases GoJS interacting with other elements on the page.

          + data-tags="grid">
          - Multiple circles using repeated CircularLayouts. + Shows infinite scrolling and positionComputation.

          - + - Double Circle + Diagram Scroll Modes

          -

          Multiple circles using repeated CircularLayouts.

          +

          Shows infinite scrolling and positionComputation.

          +
          +
          +
          + A diagram with Graduated Panels at the edges acting as rulers. +
          +
          +

          + + + + + Diagram with Rulers + + + +

          +

          A diagram with Graduated Panels at the edges acting as rulers.

          +
          +
          +
          + Ring-shaped pie charts within nodes. +
          +
          +

          + + + + + Donut Charts in Nodes + + + +

          +

          Ring-shaped pie charts within nodes.

          - Drag and Drop Fields + Drag and Drop Fields Between Nodes @@ -1853,43 +1937,63 @@

          + data-tags="palette,html">
          - Drag out fields from record Nodes to an HTML element. + Demonstrates dragging and dropping from HTML, and pasting from the external clipboard.

          - + - Drag Out Fields + Drag and Drop From HTML Element to Diagram

          -

          Drag out fields from record Nodes to an HTML element.

          +

          Demonstrates dragging and dropping from HTML, and pasting from the external clipboard.

          + data-tags="tools,extensions">
          - Demonstrates a function to avoid any overlapping of nodes during dragging. + A custom Tool that lets a user draw a box showing where and how large a new node should be.

          - + - Drag Unoccupied + Drag Creating Tool

          -

          Demonstrates a function to avoid any overlapping of nodes during dragging.

          +

          A custom Tool that lets a user draw a box showing where and how large a new node should be.

          +
          +
          +
          + Drag out fields from record Nodes to an HTML element. +
          +
          +

          + + + + + Drag Fields Out of Diagram to HTML Element + + + +

          +

          Drag out fields from record Nodes to an HTML element.

          A custom Tool that lets a user draw a box showing what to zoom in to.

          +
          +
          + Demonstrates drag and drop between two different diagrams using a shared UndoManager. +
          +
          +

          + + + + + Two Diagrams Drag-and-Drop + + + +

          +

          Demonstrates drag and drop between two different diagrams using a shared UndoManager.

          +
          - A custom Tool that lets a user draw a box showing where and how large a new node should be. + A custom DraggingTool that lets the user drag a translucent image of the Nodes and Links to be moved, leaving them in place until the mouse up.

          - + - DragCreating + NonRealtime Dragging

          -

          A custom Tool that lets a user draw a box showing where and how large a new node should be.

          +

          A custom DraggingTool that lets the user drag a translucent image of the Nodes and Links to be moved, leaving them in place until the mouse up.

          + data-tags="tools,extensions">
          - Showcases draggable disconnectable links that can be connected by dropping one or both ends at a valid port. + A custom Tool that lets the user drag a label in a Spot Panel of a Node.

          - + - Draggable Link + Dragging Node Label

          -

          Showcases draggable disconnectable links that can be connected by dropping one or both ends at a valid port.

          +

          A custom Tool that lets the user drag a label in a Spot Panel of a Node.

          + data-tags="tools,extensions">
          - Demonstrates custom CommandHandler which provides alignment commands and additional behaviors for the arrow keys. + A custom Tool that lets the user drag a label on a Link and that keeps its relative position to the link.

          - + - Drawing Commands + Dragging Link Label

          -

          Demonstrates custom CommandHandler which provides alignment commands and additional behaviors for the arrow keys.

          +

          A custom Tool that lets the user drag a label on a Link and that keeps its relative position to the link.

          + data-tags="tools,extensions">
          - Dynamic pie chart with selectable slices that can change size. + A custom Tool that lets the user drag a label on a Link and that keeps the label along the path of the link.

          - + - Dynamic Pie Chart + Dragging Link Label along Path

          -

          Dynamic pie chart with selectable slices that can change size.

          +

          A custom Tool that lets the user drag a label on a Link and that keeps the label along the path of the link.

          +
          +
          +
          + Demonstrates custom CommandHandler which provides alignment commands and additional behaviors for the arrow keys. +
          +
          +

          + + + + + Draw Command Handler + + + +

          +

          Demonstrates custom CommandHandler which provides alignment commands and additional behaviors for the arrow keys.

          - Entity Relationship + Entity Relationship Diagram @@ -2033,7 +2177,27 @@

          + data-tags="force-directed,buttons"> +
          + Demonstrates the expansion of a tree where nodes are only created 'on-demand', when the user clicks on the 'expand' Button. +
          +
          +

          + + + + + Incremental Tree + + + +

          +

          Demonstrates the expansion of a tree where nodes are only created 'on-demand', when the user clicks on the 'expand' Button.

          +
          +
          Shows a standard family tree. @@ -2044,7 +2208,7 @@

          - Family Tree (Japanese) + Family Tree Diagram, Japanese @@ -2064,13 +2228,33 @@

          - Fault Tree + Fault Tree Analysis

          A fault tree diagram with collapsing/expanding subtrees and gates at each non-root node.

          +
          +
          + Show distances between two nodes and highlights one of all possible paths between the nodes. +
          +
          +

          + + + + + Distances and Paths + + + +

          +

          Show distances between two nodes and highlights one of all possible paths between the nodes.

          +
          @@ -2104,7 +2288,7 @@

          - Flow Builder + Flow Builder for Building Acyclic Graphs @@ -2124,33 +2308,13 @@

          - Flow PanelLayout + Flow Layout in Panels

          A custom PanelLayout that arranges panel elements into rows or columns.

          -
          -
          - Demonstrates a flow-chart-like editor of a restricted syntax language.  Uses the ParallelLayout extension. -
          -
          -

          - - - - - Flowgrammer - - - -

          -

          Demonstrates a flow-chart-like editor of a restricted syntax language. Uses the ParallelLayout extension.

          -
          @@ -2164,7 +2328,7 @@

          - Force Directed + Force Directed Layout Demo @@ -2213,83 +2377,83 @@

          + data-tags="treelayout">
          - A cellular automation simulation. + Two diagrams, the one on top showing a full tree and the one below focusing on a specific node in the tree and those nodes that are logically 'near' it.

          - + - Game of Life + Diagram and Local View

          -

          A cellular automation simulation.

          +

          Two diagrams, the one on top showing a full tree and the one below focusing on a specific node in the tree and those nodes that are logically 'near' it.

          + data-tags="">
          - A custom Tool that supports interactive reshaping of Geometries. + A cellular automation simulation.

          - + - Geometry Reshaping + Game of Life Cellular Automation

          -

          A custom Tool that supports interactive reshaping of Geometries.

          +

          A cellular automation simulation.

          + data-tags="tooltips,tools">
          - Shows different options for ToolManager's gestureBehavior. + A GoJS diagram atop a Leaflet.js map, with nodes placed at latitude and longitude based locations.

          - + - Gesture Behavior + Diagrams and Leaflet.js

          -

          Shows different options for ToolManager's gestureBehavior.

          +

          A GoJS diagram atop a Leaflet.js map, with nodes placed at latitude and longitude based locations.

          + data-tags="tools,extensions,geometries">
          - A GoJS diagram atop a Leaflet.js map, with nodes placed at latitude and longitude based locations. + A custom Tool that supports interactive reshaping of Geometries.

          - + - GoJS and Leaflet Map + Geometry Reshaping

          -

          A GoJS diagram atop a Leaflet.js map, with nodes placed at latitude and longitude based locations.

          +

          A custom Tool that supports interactive reshaping of Geometries.

          - Grafcet Diagrams + Grafcet Diagram Editor @@ -2324,7 +2488,7 @@

          - Grid Layout + Grid Layout Demo @@ -2333,23 +2497,23 @@

          + data-tags="groups,geometries">
          - Demonstrates subgraphs that are created only as groups are expanded. + Groups consisting of a RoundedTopRectangle and a RoundedBottomRectangle figure surrounding the Group's Placeholder.

          - + - Grouping + Groups with Rounded Headers and Footers

          -

          Demonstrates subgraphs that are created only as groups are expanded.

          +

          Groups consisting of a RoundedTopRectangle and a RoundedBottomRectangle figure surrounding the Group's Placeholder.

          -
          - Shows buttons in an Adornment upon hover over a node. -
          -
          -

          - - - - - Hover Buttons - - - -

          -

          Shows buttons in an Adornment upon hover over a node.

          -
          -
          + data-tags="tables,itemarrays,links,customlayout">
          - Demonstrates dragging and dropping from HTML, and pasting from the external clipboard. + A simple timeline with events arranged along a line.

          - + - HTML Drag and Drop + Timeline

          -

          Demonstrates dragging and dropping from HTML, and pasting from the external clipboard.

          +

          A simple timeline with events arranged along a line.

          + data-tags="extensions,html">
          - Shows a LightBox style HTML Context Menu. + Demonstrates use of the ZoomSlider class to zoom in/out using a control.

          - + - HTML LightBox Context Menu + HTML Zoom Slider for Zooming

          -

          Shows a LightBox style HTML Context Menu.

          +

          Demonstrates use of the ZoomSlider class to zoom in/out using a control.

          + data-tags="extensions">
          - Demonstrates using an HTMLInfo that acts as a re-implementation of the default text editor. + Demonstrates usage of the HyperlinkText extension.

          - + - HTMLInfo Text Editor + Hyperlink Text

          -

          Demonstrates using an HTMLInfo that acts as a re-implementation of the default text editor.

          +

          Demonstrates usage of the HyperlinkText extension.

          + data-tags="gauges,geometries">
          - Demonstrates usage of the HyperlinkText extension. + A gauge using a scale made with a Graduated Panel.

          - + - Hyperlinks + Instrument Gauges

          -

          Demonstrates usage of the HyperlinkText extension.

          +

          A gauge using a scale made with a Graduated Panel.

          + data-tags="collections,layered-digraph,palette,overview">
          - State Chart using incremental JSON. + Demonstrates a flow-chart-like editor of a restricted syntax language.  Uses the ParallelLayout extension.

          - + - Incremental State Chart + Flowgrammer Visual Editor

          -

          State Chart using incremental JSON.

          +

          Demonstrates a flow-chart-like editor of a restricted syntax language. Uses the ParallelLayout extension.

          + data-tags="treelayout,tooltips,buttons">
          - Demonstrates the expansion of a tree where nodes are only created 'on-demand', when the user clicks on the 'expand' Button. + Allows a user to make progressive decisions.

          - + - Incremental Tree + Decision Tree

          -

          Demonstrates the expansion of a tree where nodes are only created 'on-demand', when the user clicks on the 'expand' Button.

          +

          Allows a user to make progressive decisions.

          + data-tags="tools,extensions,geometries">
          - A gauge using a scale made with a Graduated Panel. + A custom Tool that lets the user interactively draw polygons and polyline Shapes.

          - + - Instrument Gauge + Interactive Drawing of Polygons or Polylines

          -

          A gauge using a scale made with a Graduated Panel.

          +

          A custom Tool that lets the user interactively draw polygons and polyline Shapes.

          - Interactive Force + Continuous Interactive Force Layout @@ -2576,7 +2720,7 @@

          data-tags="grid">
          Demonstrates a simple Gantt chart. + alt="Demonstrates a Gantt chart with a collapsible tree of tasks" class="absolute inset-0 h-full w-full" />

          @@ -2584,12 +2728,12 @@

          - Interactive Gantt Chart + Gantt Chart

          -

          Demonstrates a simple Gantt chart.

          +

          Demonstrates a Gantt chart with a collapsible tree of tasks

          - Interactive Mind Map Diagram + Mind Map Editor @@ -2615,181 +2759,121 @@

          class="group relative before:absolute before:-inset-2.5 before:rounded-lg before:bg-gray-50 before:opacity-0 hover:before:opacity-100" data-tags="tables,itemarrays,treelayout,buttons,theme">
          - Diagram representation of an Interactive Voice Response Tree (IVR tree). Nodes may have a collapsible list of details. -
          -
          -

          - - - - - IVR Tree - - - -

          -

          Diagram representation of an Interactive Voice Response Tree (IVR tree). Nodes may have a collapsible list of details.

          -
          -

          -
          - Shows LayeredDigraphLayout and options. Arranges nodes of directed graphs into layers (rows or columns). -
          -
          -

          - - - - - Layered Digraph - - - -

          -

          Shows LayeredDigraphLayout and options. Arranges nodes of directed graphs into layers (rows or columns).

          -
          -
          -
          - A custom Tool that lets the user drag a label on a Link and that keeps its relative position to the link. -
          -
          -

          - - - - - Link Label Dragging - - - -

          -

          A custom Tool that lets the user drag a label on a Link and that keeps its relative position to the link.

          -
          -
          -
          - A custom Tool that lets the user drag a label on a Link and that keeps the label along the path of the link. + Diagram representation of an Interactive Voice Response Tree (IVR tree). Nodes may have a collapsible list of details.

          - + - Link Label On Path Dragging + IVR Tree Diagram

          -

          A custom Tool that lets the user drag a label on a Link and that keeps the label along the path of the link.

          +

          Diagram representation of an Interactive Voice Response Tree (IVR tree). Nodes may have a collapsible list of details.

          + data-tags="collections,layered-digraph,html">
          - A demonstration of the LinkLabelRouter extension based on the Dynamic Ports sample. Move Nodes or create new links to demonstrate that link labels will automatically move to a nearby location to avoid overlapping. + Shows LayeredDigraphLayout and options. Arranges nodes of directed graphs into layers (rows or columns).

          - + - Link Label Router + Layered Digraph Layout Demo

          -

          A demonstration of the LinkLabelRouter extension based on the Dynamic Ports sample. Move Nodes or create new links to demonstrate that link labels will automatically move to a nearby location to avoid overlapping.

          +

          Shows LayeredDigraphLayout and options. Arranges nodes of directed graphs into layers (rows or columns).

          + data-tags="treelayout,customlayout,groups,buttons,extensions">
          - A custom Tool that adds handles on Links to allow the user to shift the end point of the Link along the sides of the port without disconnecting it. + A custom Layout that assumes there is a single split and a single merge node with parallel lines of nodes connecting them.

          - + - Link Shifting + Parallel Layout

          -

          A custom Tool that adds handles on Links to allow the user to shift the end point of the Link along the sides of the port without disconnecting it.

          +

          A custom Layout that assumes there is a single split and a single merge node with parallel lines of nodes connecting them.

          + data-tags="contextmenus,html">
          - Demonstrates the ability for a Link to appear to connect with another Link, using label nodes that belong to links. + Shows a LightBox style HTML Context Menu.

          - + - Links to Links + LightBox Style HTML Context Menu

          -

          Demonstrates the ability for a Link to appear to connect with another Link, using label nodes that belong to links.

          +

          Shows a LightBox style HTML Context Menu.

          + data-tags="">
          - Demonstrates custom CommandHandler which uses localStorage as the repository for the clipboard, rather than an in-memory global variable, allowing for copying between tabs and windows. + Demonstrates a function to avoid any overlapping of nodes during dragging.

          - + - Local Storage Commands + Drag Unoccupied

          -

          Demonstrates custom CommandHandler which uses localStorage as the repository for the clipboard, rather than an in-memory global variable, allowing for copying between tabs and windows.

          +

          Demonstrates a function to avoid any overlapping of nodes during dragging.

          + data-tags="links,tools,extensions">
          - Two diagrams, the one on top showing a full tree and the one below focusing on a specific node in the tree and those nodes that are logically 'near' it. + A custom LinkingTool that lets the user determine the route of a new Link by clicking.

          - + - Local View + Polyline Linking

          -

          Two diagrams, the one on top showing a full tree and the one below focusing on a specific node in the tree and those nodes that are logically 'near' it.

          +

          A custom LinkingTool that lets the user determine the route of a new Link by clicking.

          - Macros + Macros from Palette @@ -2824,7 +2908,7 @@

          - Magnifier + Magnifier View @@ -2864,7 +2948,7 @@

          - Minimal Image Download + Download Image Blob @@ -2884,7 +2968,7 @@

          - Minimal SVG Download + Download SVG @@ -2904,7 +2988,7 @@

          - Minimal Vue.js + Minimal Vue.js Sample @@ -2924,33 +3008,13 @@

          - Multi-color Links + Multi-color Link Paths

          Demonstrates a custom Link that can be stroked with multiple consecutive colors.

          -
          -
          - Demonstrates custom routing for Links running through other Nodes. -
          -
          -

          - - - - - Multi-Node Path Links - - - -

          -

          Demonstrates custom routing for Links running through other Nodes.

          -
          @@ -2964,7 +3028,7 @@

          - Multiple Arrowheads + Multiple Arrowheads Along Link Path @@ -2973,63 +3037,23 @@

          -
          - Displays relationships between different parts of a diagram. -
          -
          -

          - - - - - Navigation - - - -

          -

          Displays relationships between different parts of a diagram.

          -
          -
          -
          - A custom Tool that lets the user drag a label in a Spot Panel of a Node. -
          -
          -

          - - - - - Node Label Dragging - - - -

          -

          A custom Tool that lets the user drag a label in a Spot Panel of a Node.

          -
          -
          + data-tags="collections,circularlayout,circle-like">
          - A custom DraggingTool that lets the user drag a translucent image of the Nodes and Links to be moved, leaving them in place until the mouse up. + Multiple circles using repeated CircularLayouts.

          - + - Non Realtime Dragging + Double Circle

          -

          A custom DraggingTool that lets the user drag a translucent image of the Nodes and Links to be moved, leaving them in place until the mouse up.

          +

          Multiple circles using repeated CircularLayouts.

          - Org Chart Assistants + Org Chart with Assistants on the Side @@ -3064,53 +3088,13 @@

          - Org Chart Extras + Org Chart With Extra Relationships

          Shows an org chart with extra links and expand/collapse functionality.

          -
          -
          - A custom Tool that lets the user reshape orthogonal links by dragging entire segments. -
          -
          -

          - - - - - Orthogonal Link Reshaping - - - -

          -

          A custom Tool that lets the user reshape orthogonal links by dragging entire segments.

          -
          -
          -
          - A custom Tool which allows the user to resize the overview box. -
          -
          -

          - - - - - Overview Resizing - - - -

          -

          A custom Tool which allows the user to resize the overview box.

          -
          @@ -3124,7 +3108,7 @@

          - Packed Hierarchy + Packed Hierarchy of Groups @@ -3144,7 +3128,7 @@

          - Packed Layout + Packed Layout Demo @@ -3164,73 +3148,13 @@

          - Page Flow + Page Flow Diagram Editor

          A diagram representation of webpage flow.

          -
          -
          - Shows how to create a custom PaneLayout. -
          -
          -

          - - - - - Panel Layout - - - -

          -

          Shows how to create a custom PaneLayout.

          -
          -
          -
          - A custom Layout that assumes there is a single split and a single merge node with parallel lines of nodes connecting them. -
          -
          -

          - - - - - Parallel Layout - - - -

          -

          A custom Layout that assumes there is a single split and a single merge node with parallel lines of nodes connecting them.

          -
          -
          -
          - Demonstrates custom Links that route parallel to other Links between the same two ports. -
          -
          -

          - - - - - Parallel Route Links - - - -

          -

          Demonstrates custom Links that route parallel to other Links between the same two ports.

          -
          @@ -3251,26 +3175,6 @@

          A Parse tree representing the syntactic structure of a sentence. The leaf nodes are shown in a horizontal line.

          -
          -
          - Animation of diagram parts (tokens) along link paths. -
          -
          -

          - - - - - Path Animation - - - -

          -

          Animation of diagram parts (tokens) along link paths.

          -
          @@ -3293,7 +3197,7 @@

          + data-tags="tables,layered-digraph,legend">
          A simple PERT chart, showcasing GoJS table panels and RowColumnDefinition properties. @@ -3304,7 +3208,7 @@

          - PERT + PERT Chart with Legend @@ -3313,43 +3217,43 @@

          + data-tags="tables,itemarrays,collections,tooltips,buttons,geometries,charts">
          - Simple pie charts within nodes. + Dynamic pie chart with selectable slices that can change size.

          - + - Pie Charts + Dynamic Pie Chart

          -

          Simple pie charts within nodes.

          +

          Dynamic pie chart with selectable slices that can change size.

          + data-tags="itemarrays,tooltips,geometries,charts">
          - Demonstrates customization of pinch-zooming to scale a node. + Simple pie charts within nodes.

          - + - Pinch Zooming + Pie Charts

          -

          Demonstrates customization of pinch-zooming to scale a node.

          +

          Simple pie charts within nodes.

          + data-tags="collections,groups,tooltips">
          - A custom Tool that lets the user interactively draw polygons and polyline Shapes. + Displays relationships between different parts of a diagram.

          - + - Polygon Drawing + Navigation

          -

          A custom Tool that lets the user interactively draw polygons and polyline Shapes.

          +

          Displays relationships between different parts of a diagram.

          + data-tags="buttons,geometries">
          - A custom LinkingTool that lets the user determine the route of a new Link by clicking. + An adornment showing buttons in a circle on one selected node.

          - + - Polyline Linking + Radial Adornment

          -

          A custom LinkingTool that lets the user determine the route of a new Link by clicking.

          +

          An adornment showing buttons in a circle on one selected node.

          + data-tags="collections,treelayout,tools,extensions">
          - A custom Tool that lets the user drag a port in a Spot Panel of a Node. + A custom Tool that lets a user drag and create a box to select nodes and links.

          - + - Port Shifting + Realtime Selection

          -

          A custom Tool that lets the user drag a port in a Spot Panel of a Node.

          +

          A custom Tool that lets a user drag and create a box to select nodes and links.

          + data-tags="collections,tooltips,circle-like,customlayout,extensions">
          - An adornment showing buttons in a circle on one selected node. + Arrange people in circles around a central person, in layers according to distance from the central person.

          - + - Radial Adornment Buttons + Radial Layout

          -

          An adornment showing buttons in a circle on one selected node.

          +

          Arrange people in circles around a central person, in layers according to distance from the central person.

          + data-tags="collections,gridlayout,treelayout,groups,buttons">
          - A custom Tool that lets a user drag and create a box to select nodes and links. + Regrouping with tree view of grouping hierarchy.

          - + - Realtime Drag Selecting + Regrouping Editor and Simultaneous Tree View

          -

          A custom Tool that lets a user drag and create a box to select nodes and links.

          +

          Regrouping with tree view of grouping hierarchy.

          + data-tags="svg,export">
          - Arrange people in circles around a central person, in layers according to distance from the central person. + In makeSvg, replace image sources with Base64

          - + - Recentering Radial + Rendering SVG to Data URL with Inline Images

          -

          Arrange people in circles around a central person, in layers according to distance from the central person.

          +

          In makeSvg, replace image sources with Base64

          + data-tags="tools,extensions">
          - Regrouping with tree view of grouping hierarchy. + A custom Tool that lets a user change the scale of an object.

          - + - Regrouping Tree View + Rescaling by Dragging Handle

          -

          Regrouping with tree view of grouping hierarchy.

          +

          A custom Tool that lets a user change the scale of an object.

          + data-tags="tools,extensions,geometries">
          - Shows how you can create custom renderings for Links by repeatedly drawing GraphObjects along the route. + A custom Tool that supports interactive reshaping of pie-shaped sectors of circles.

          - + - Relationships + Reshaping and Rotating Sectors of Circles

          -

          Shows how you can create custom renderings for Links by repeatedly drawing GraphObjects along the route.

          +

          A custom Tool that supports interactive reshaping of pie-shaped sectors of circles.

          + data-tags="links,tools,palette,extensions,grid">
          - A custom Tool that lets a user change the scale of an object. + A custom Tool that allows reshaping links with grid snapping.

          - + - Rescaling + Reshaping Links Snaps to Grid

          -

          A custom Tool that lets a user change the scale of an object.

          +

          A custom Tool that allows reshaping links with grid snapping.

          +
          +
          +
          + A custom Tool that lets the user reshape orthogonal links by dragging entire segments. +
          +
          +

          + + + + + Orthogonal Link Reshaping + + + +

          +

          A custom Tool that lets the user reshape orthogonal links by dragging entire segments.

          - Resize Multiple + Resizing Multiple @@ -3613,123 +3537,143 @@

          + data-tags="tools,overview,extensions">
          - A custom RotatingTool that lets the user rotate many selected objects at once. + A custom Tool which allows the user to resize the overview box.

          - + - Rotate Multiple + Resizing of Overview Box

          -

          A custom RotatingTool that lets the user rotate many selected objects at once.

          +

          A custom Tool which allows the user to resize the overview box.

          + data-tags="tables,itemarrays,tools,extensions,geometries">
          - Groups consisting of a RoundedTopRectangle and a RoundedBottomRectangle figure surrounding the Group's Placeholder. + Two custom Tools that let the user resize the width of columns or the height of rows in a Table Panel of a Node.

          - + - Rounded Groups + Table Row and Column Resizing

          -

          Groups consisting of a RoundedTopRectangle and a RoundedBottomRectangle figure surrounding the Group's Placeholder.

          +

          Two custom Tools that let the user resize the width of columns or the height of rows in a Table Panel of a Node.

          + data-tags="tools">
          - A diagram with Graduated Panels at the edges acting as rulers. + Demonstrates customization of pinch-zooming to scale a node.

          - + - Rulered Diagram + Resizing via Pinch Zooming

          -

          A diagram with Graduated Panels at the edges acting as rulers.

          +

          Demonstrates customization of pinch-zooming to scale a node.

          + data-tags="tools,extensions">
          - Shows infinite scrolling and positionComputation. + A custom RotatingTool that lets the user rotate many selected objects at once.

          - + - Scroll Modes + Rotate Multiple

          -

          Shows infinite scrolling and positionComputation.

          +

          A custom RotatingTool that lets the user rotate many selected objects at once.

          + data-tags="tools,extensions">
          - Demonstrates a custom Table Panel with a scrollbar implemented in GoJS, including two AutoRepeatButtons. + A custom RotatingTool that lets the user shift the rotation point.

          - + - Scrolling Table + Rotating Node about Movable Rotation Spot

          -

          Demonstrates a custom Table Panel with a scrollbar implemented in GoJS, including two AutoRepeatButtons.

          +

          A custom RotatingTool that lets the user shift the rotation point.

          + data-tags="routers,extensions">
          - A custom Tool that supports interactive reshaping of pie-shaped sectors of circles. + A demonstration of the LinkLabelRouter extension based on the Dynamic Ports sample. Move Nodes or create new links to demonstrate that link labels will automatically move to a nearby location to avoid overlapping.

          - + - Sector Reshaping + Link Label Router

          -

          A custom Tool that supports interactive reshaping of pie-shaped sectors of circles.

          +

          A demonstration of the LinkLabelRouter extension based on the Dynamic Ports sample. Move Nodes or create new links to demonstrate that link labels will automatically move to a nearby location to avoid overlapping.

          +
          +
          +
          + Demonstrates a custom Table Panel with a scrollbar implemented in GoJS, including two AutoRepeatButtons. +
          +
          +

          + + + + + Scrolling Table Panels with ScrollBars + + + +

          +

          Demonstrates a custom Table Panel with a scrollbar implemented in GoJS, including two AutoRepeatButtons.

          - Selectable Fields + Selectable Fields in Record Nodes @@ -3764,13 +3708,33 @@

          - Selectable Ports + Selectable, Deletable Ports in Nodes

          A Node with ports that can be selected and deleted.

          +
          +
          + Selected nodes show a row of buttons that execute commands or start tools. +
          +
          +

          + + + + + Adornment Buttons + + + +

          +

          Selected nodes show a row of buttons that execute commands or start tools.

          +
          @@ -3804,7 +3768,7 @@

          - Sequential Function + Sequential Function Chart @@ -3844,7 +3808,7 @@

          - Shared States + Shared States not using Groups @@ -3853,103 +3817,123 @@

          + data-tags="links,tools,extensions,geometries">
          - Shows the continuously updating state of a number of stations on an imaginary shop floor. + A custom Tool that adds handles on Links to allow the user to shift the end point of the Link along the sides of the port without disconnecting it.

          - + - Shop Floor Monitor + Shifting Link Connections + + + +

          +

          A custom Tool that adds handles on Links to allow the user to shift the end point of the Link along the sides of the port without disconnecting it.

          +
          +
          +
          + A custom Tool that lets the user drag a port in a Spot Panel of a Node. +
          +
          +

          + + + + + Shifting Ports in Nodes

          -

          Shows the continuously updating state of a number of stations on an imaginary shop floor.

          +

          A custom Tool that lets the user drag a port in a Spot Panel of a Node.

          + data-tags="monitoring,animation">
          - Demonstrates use of the Robot class to simulate mouse events. + Shows the continuously updating state of a number of stations on an imaginary shop floor.

          - + - Simulating Input + Shop Floor Monitor

          -

          Demonstrates use of the Robot class to simulate mouse events.

          +

          Shows the continuously updating state of a number of stations on an imaginary shop floor.

          + data-tags="treelayout,buttons">
          - Show a diagram on a sheet of paper, limiting dragging and resizing to stay within the page minus margins. + Shows the DOM of this page displayed as a tree. Selection highlights the DOM element in the page.

          - + - Single Page View + DOM Tree

          -

          Show a diagram on a sheet of paper, limiting dragging and resizing to stay within the page minus margins.

          +

          Shows the DOM of this page displayed as a tree. Selection highlights the DOM element in the page.

          + data-tags="collections,contextmenus,palette,buttons,extensions,html">
          - A custom Tool that allows reshaping links with grid snapping. + Demonstrates use of the Robot class to simulate mouse events.

          - + - Snap Link Reshaping + Simulating Input using Robot

          -

          A custom Tool that allows reshaping links with grid snapping.

          +

          Demonstrates use of the Robot class to simulate mouse events.

          + data-tags="grid,legend">
          - When zooming, change the spacing of the Nodes, not the Diagram.scale. + Show a diagram on a sheet of paper, limiting dragging and resizing to stay within the page minus margins.

          - + - Spacing Zoom + Single Page Diagram Editor with Legend

          -

          When zooming, change the spacing of the Nodes, not the Diagram.scale.

          +

          Show a diagram on a sheet of paper, limiting dragging and resizing to stay within the page minus margins.

          - Sparkline Graphs + Sparkline Charts in Nodes @@ -3984,33 +3968,13 @@

          - Spiral Layout + Spiral Layout of Node Chains

          A custom Layout that positions a chain of nodes in a spiral.

          -
          -
          - A custom RotatingTool that lets the user shift the rotation point. -
          -
          -

          - - - - - Spot Rotating - - - -

          -

          A custom RotatingTool that lets the user shift the rotation point.

          -
          @@ -4024,7 +3988,7 @@

          - Spreadsheet + Spreadsheet-like Nested Table Panels @@ -4033,43 +3997,43 @@

          + data-tags="html,extensions">
          - In makeSvg, replace image sources with Base64 + Demonstrates using an HTMLInfo that acts as a re-implementation of the default text editor.

          - + - SVG Data URL + Standard HTMLInfo Text Editor

          -

          In makeSvg, replace image sources with Base64

          +

          Demonstrates using an HTMLInfo that acts as a re-implementation of the default text editor.

          + data-tags="buttons,process">
          - Shows a tiger rendered in SVG without using a Picture + State Chart using incremental JSON.

          - + - SVG Tiger + State Chart Editor Saving Incremental JSON

          -

          Shows a tiger rendered in SVG without using a Picture

          +

          State Chart using incremental JSON.

          - Swim Lane Layout + Swim Lane Layout Keeps Nodes in their Lanes

          A custom Layout that puts nodes into swimlanes with dependencies that cross lanes.

          -
          -
          - Demonstrates collapsible, resizable, re-orderable swimlanes, a kind of process-flow diagram, with custom dragging rules that disallow nodes from leaving their lane. -
          -
          -

          - - - - - Swim Lanes Vertical - - - -

          -

          Demonstrates collapsible, resizable, re-orderable swimlanes, a kind of process-flow diagram, with custom dragging rules that disallow nodes from leaving their lane.

          -
          @@ -4124,7 +4068,7 @@

          - Table Layout + Table Layout of Nodes in Rows and Columns @@ -4164,7 +4108,7 @@

          - Thermometer + Thermometer Nodes using Graduated Panels @@ -4173,23 +4117,23 @@

          + data-tags="geometries,svg">
          - A simple timeline with events arranged along a line. + Shows a tiger rendered in SVG without using a Picture

          - + - Timeline + SVG Tiger using Shapes

          -

          A simple timeline with events arranged along a line.

          +

          Shows a tiger rendered in SVG without using a Picture

          - Tournament + Tournament Bracket @@ -4224,7 +4168,7 @@

          - Tree Layout + Tree Layout Demo @@ -4233,143 +4177,203 @@

          + data-tags="collections,customlayout,groups,tooltips,extensions,html">
          - Shows how to create a custom Diagram loading animation. + A custom Layout that renders nested Groups into the viewport with each Node having an area proportional to its declared 'size'.

          - + - Tree Load Animation + Tree Map of Nested Groups

          -

          Shows how to create a custom Diagram loading animation.

          +

          A custom Layout that renders nested Groups into the viewport with each Node having an area proportional to its declared 'size'.

          + data-tags="treelayout,buttons">
          - A custom Layout that renders nested Groups into the viewport with each Node having an area proportional to its declared 'size'. + Demonstrates a traditional 'Tree View' in a GoJS diagram, where each item has a checkbox with three states.

          - + - Tree Map Layout + Tri-state CheckBox Tree

          -

          A custom Layout that renders nested Groups into the viewport with each Node having an area proportional to its declared 'size'.

          +

          Demonstrates a traditional 'Tree View' in a GoJS diagram, where each item has a checkbox with three states.

          + data-tags="geometries">
          - Demonstrates a traditional 'Tree View' in a GoJS diagram, where each item has a checkbox with three states. + Nodes consisting of two Panels, using a RoundedTopRectangle and a RoundedBottomRectangle figure.

          - + - Tri-state CheckBox Tree + Two Rounded Halves

          -

          Demonstrates a traditional 'Tree View' in a GoJS diagram, where each item has a checkbox with three states.

          +

          Nodes consisting of two Panels, using a RoundedTopRectangle and a RoundedBottomRectangle figure.

          + data-tags="tables,itemarrays,treelayout,buttons"> +
          + A UML Class diagram shows software classes and their properties and methods, and the relationships between them. +
          +
          +

          + + + + + UML Class Diagram Editor + + + +

          +

          A UML Class diagram shows software classes and their properties and methods, and the relationships between them.

          +
          +
          +
          + Showcases two Diagrams observing the same Model. Modifying positions in one Diagram will modify them in the model, updating the other Diagram as well. +
          +
          +

          + + + + + Update Demo + + + +

          +

          Showcases two Diagrams observing the same Model. Modifying positions in one Diagram will modify them in the model, updating the other Diagram as well.

          +
          +
          Demonstrates drag and drop between two different diagrams using a shared UndoManager. + alt="Shows different options for ToolManager's gestureBehavior." class="absolute inset-0 h-full w-full" />

          - + - Two Diagrams + Various Gestures Demo

          -

          Demonstrates drag and drop between two different diagrams using a shared UndoManager.

          +

          Shows different options for ToolManager's gestureBehavior.

          + data-tags="tables,itemarrays,buttons,extensions">
          - Nodes consisting of two Panels, using a RoundedTopRectangle and a RoundedBottomRectangle figure. + Demonstrates simple uses of CheckBoxButtons.

          - + - Two Halves + CheckBox Styles

          -

          Nodes consisting of two Panels, using a RoundedTopRectangle and a RoundedBottomRectangle figure.

          +

          Demonstrates simple uses of CheckBoxButtons.

          + data-tags="collections,links,treelayout,geometries">
          - A UML Class diagram shows software classes and their properties and methods, and the relationships between them. + Shows how you can create custom renderings for Links by repeatedly drawing GraphObjects along the route.

          - + - UML Class + Visual Relationships

          -

          A UML Class diagram shows software classes and their properties and methods, and the relationships between them.

          +

          Shows how you can create custom renderings for Links by repeatedly drawing GraphObjects along the route.

          + data-tags="tables,layered-digraph,ports,process">
          - Showcases two Diagrams observing the same Model. Modifying positions in one Diagram will modify them in the model, updating the other Diagram as well. + Same as Data Flow, but vertically oriented, and with slightly different styling.

          - + - Update Demo + Data Flow Diagram (Vertical)

          -

          Showcases two Diagrams observing the same Model. Modifying positions in one Diagram will modify them in the model, updating the other Diagram as well.

          +

          Same as Data Flow, but vertically oriented, and with slightly different styling.

          +
          +
          +
          + Demonstrates collapsible, resizable, re-orderable swimlanes, a kind of process-flow diagram, with custom dragging rules that disallow nodes from leaving their lane. +
          +
          +

          + + + + + Swim Lanes (Vertical) + + + +

          +

          Demonstrates collapsible, resizable, re-orderable swimlanes, a kind of process-flow diagram, with custom dragging rules that disallow nodes from leaving their lane.

          - Virtualized + Virtualized Diagram no Layout @@ -4404,7 +4408,7 @@

          - Virtualized ForceDirected Layout + Virtualized Diagram with Force Directed Layout @@ -4424,7 +4428,7 @@

          - Virtualized Packed Layout + Virtualized Diagram with Packed Layout @@ -4464,7 +4468,7 @@

          - Virtualized TreeLayout + Virtualized Tree with TreeLayout @@ -4484,7 +4488,7 @@

          - Visual Tree + Visual Tree of another Diagram @@ -4504,7 +4508,7 @@

          - Visual Tree Using Groups + Visual Tree using Groups @@ -4524,7 +4528,7 @@

          - Word Cloud + Word Cloud using PackedLayout @@ -4533,23 +4537,23 @@

          + data-tags="">
          - Demonstrates use of the ZoomSlider class to zoom in/out using a control. + When zooming, change the spacing of the Nodes, not the Diagram.scale.

          - + - Zoom Slider + Spacing Zoom

          -

          Demonstrates use of the ZoomSlider class to zoom in/out using a control.

          +

          When zooming, change the spacing of the Nodes, not the Diagram.scale.

          - Kitten Monitor + Monitor with Background @@ -4606,7 +4610,7 @@

          - Network + Network Editor with Bars @@ -4721,7 +4725,14 @@

          Company

          let a = params.get('a'); if (a) localStorage.setItem('a', a); a = localStorage.getItem('a'); - document.getElementById('tc').href += `?a=${a}`; - document.getElementById('tb').href += `?a=${a}`; + if (a) { + const links = [...document.body.getElementsByTagName("a")].filter((l) => l.href.includes('nwoods.com')); + for (const l of links) { + const url = new URL(l.href); + url.searchParams.set('a', a); + l.href = url; + } + } + \ No newline at end of file diff --git a/samples/industrialDiagram.html b/samples/industrialDiagram.html index 76043c24c..87e38f7d9 100644 --- a/samples/industrialDiagram.html +++ b/samples/industrialDiagram.html @@ -131,6 +131,11 @@ // See "BarLink" in the Network Configuration sample for a similar class for connecting to horizontal Nodes. class TowerLink extends go.Link { + constructor(init) { + super(); + if (init) Object.assign(this, init); + } + getLinkPoint(node, port, spot, from, ortho, othernode, otherport) { if (!from && node.category === 'Tower' && spot !== Spot.Bottom && spot !== Spot.Top) { var op = super.getLinkPoint(othernode, otherport, this.computeSpot(!from), !from, ortho, node, port); diff --git a/samples/industrialMonitor.html b/samples/industrialMonitor.html index a349c1278..b23ac63d3 100644 --- a/samples/industrialMonitor.html +++ b/samples/industrialMonitor.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Industrial Monitor SCADA diagram | GoJS Diagramming Library + Industrial Monitor SCADA Diagram | GoJS Diagramming Library @@ -187,7 +187,7 @@ new go.Node('Spot', { itemTemplate: tankPort }) - .bind("location", "pos", go.Point.parse, go.Point.stringify) + .bindTwoWay("location", "pos", go.Point.parse, go.Point.stringify) .bind('itemArray', 'ports') .add( // Inner spot panel holding Shape and Text label @@ -208,7 +208,8 @@ end: go.Spot.Right }) }) - .bind('width').bind('height') + .bind('width') + .bind('height') .bind('geometryString', 'tankType'), // tank label new go.TextBlock({ @@ -220,7 +221,8 @@ ); myDiagram.nodeTemplateMap.add('label', - new go.Node('Auto').bind("location", "pos", go.Point.parse, go.Point.stringify) + new go.Node('Auto') + .bindTwoWay("location", "pos", go.Point.parse, go.Point.stringify) .add( new go.Shape({ portId: '', @@ -252,7 +254,7 @@ selectionObjectName: "SHAPE", rotatable: true }) .bindTwoWay("angle") - .bind("location", "pos", go.Point.parse, go.Point.stringify) + .bindTwoWay("location", "pos", go.Point.parse, go.Point.stringify) .add( new go.TextBlock({ background: colors.black, @@ -270,7 +272,9 @@ geometryString: valve, strokeWidth: 2, portId: "", fromSpot: new go.Spot(1, 0.35), toSpot: new go.Spot(0, 0.35) - }).bind('fill', 'color').bind('stroke', 'color', (c) => go.Brush.darkenBy(c, 0.3)) + }) + .bind('fill', 'color') + .bind('stroke', 'color', (c) => go.Brush.darkenBy(c, 0.3)) ) ); @@ -280,7 +284,7 @@ selectionObjectName: "SHAPE", rotatable: true }) .bindTwoWay("angle") - .bind("location", "pos", go.Point.parse, go.Point.stringify) + .bindTwoWay("location", "pos", go.Point.parse, go.Point.stringify) .add( new go.TextBlock({ background: colors.black, @@ -299,7 +303,9 @@ width: 45, height: 40, strokeWidth: 2, portId: "", fromSpot: new go.Spot(1, 0.25), toSpot: new go.Spot(0, 0.5) - }).bind('fill', 'color').bind('stroke', 'color', (c) => Brush.darkenBy(c, 0.3)) + }) + .bind('fill', 'color') + .bind('stroke', 'color', (c) => Brush.darkenBy(c, 0.3)) ) ); @@ -332,7 +338,7 @@ // Monitor node for monitoring values, linked to a pump or valve myDiagram.nodeTemplateMap.add("monitor", new go.Node("Auto") - .bind("location", "pos", go.Point.parse, go.Point.stringify) + .bindTwoWay("location", "pos", go.Point.parse, go.Point.stringify) .add( new go.Shape({ fill: colors.black, stroke: colors.white, strokeWidth: 2 }), new go.Panel("Vertical", { margin: 4 }) @@ -350,7 +356,7 @@ // Sensor node, linked to a tank myDiagram.nodeTemplateMap.add("sensor", new go.Node("Vertical") - .bind("location", "pos", go.Point.parse, go.Point.stringify) + .bindTwoWay("location", "pos", go.Point.parse, go.Point.stringify) .add( new go.Panel("Horizontal", { margin: 4 }) .add( @@ -381,7 +387,9 @@ new go.Shape({ strokeWidth: 8, stroke: colors.black, isPanelMain: true }), new go.Shape({ strokeWidth: 3.5, stroke: colors.green, isPanelMain: true }) .bind('stroke', 'color'), - new go.Shape({ stroke: colors.green, fill: colors.green, toArrow: 'Triangle' }).bind('stroke', 'color').bind('fill', 'color'), + new go.Shape({ stroke: colors.green, fill: colors.green, toArrow: 'Triangle' }) + .bind('stroke', 'color') + .bind('fill', 'color'), // Link label, invisible unless text is specified new go.Panel('Auto', { visible: false }) .bind('visible', 'text', (t) => true) diff --git a/samples/instrumentGauge.html b/samples/instrumentGauge.html index 22598e5e5..bb5f4bc6a 100644 --- a/samples/instrumentGauge.html +++ b/samples/instrumentGauge.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Instrument Gauge | GoJS Diagramming Library + Instrument Gauge Using Graduated Panel | GoJS Diagramming Library diff --git a/samples/interactiveForce.html b/samples/interactiveForce.html index 5cbfb7d67..968a2dcfa 100644 --- a/samples/interactiveForce.html +++ b/samples/interactiveForce.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Interactive Force | GoJS Diagramming Library + Interactive Force Directed Layout During Dragging | GoJS Diagramming Library @@ -127,7 +127,8 @@ // but does move all other nodes (vertexes). class ContinuousForceDirectedLayout extends go.ForceDirectedLayout { constructor(init) { - super(init); + super(); + if (init) Object.assign(this, init); } isFixed(v) { diff --git a/samples/kanban.html b/samples/kanban.html index bef9d3693..e4f2b005c 100644 --- a/samples/kanban.html +++ b/samples/kanban.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Interactive Kanban Board Diagram | GoJS Diagramming Library + Interactive Kanban Board Diagram Using Collapsible Groups as Task Lists | GoJS Diagramming Library @@ -130,7 +130,7 @@ // define a custom grid layout that makes sure the length of each lane is the same // and that each lane is broad enough to hold its subgraph class PoolLayout extends go.GridLayout { - constructor() { + constructor(init) { super(); this.MINLENGTH = 200; // this controls the minimum length of any swimlane this.MINBREADTH = 100; // this controls the minimum breadth of any non-collapsed swimlane @@ -139,6 +139,7 @@ this.wrappingWidth = Infinity; this.spacing = new go.Size(0, 0); this.alignment = go.GridAlignment.Position; + if (init) Object.assign(this, init); } doLayout(coll) { @@ -640,6 +641,35 @@

          Buttons

          + + +

          Legend

          +

          + A Legend can be created for a Diagram using a simple Part. + Typically that is added directly to the Diagram as an unmodeled Part, not as a template with data in the Model. + However you may want to define a template and add a legend data object to the model so that + you can parameterize the legend with information persisted with the model. +

          +

          + Usually a legend will be created as an "Auto" Panel for a border around a "Table" Panel + holding information about the types of nodes and/or links that are in the diagram. +

          +

          + It probably will want to be in the "ViewportBackground" or "ViewportForeground" Layer so that it is always + visible in the viewport despite scrolling or zooming. + Set the GraphObject.alignment property to position it where you want it to be; + by default it will be in the lower right corner. + However you may want to treat the legend Part as a regular Part in the Diagram, possibly laid out by + the diagram's Diagram.layout. +

          +

          + More information can be found in the GoJS Intro. +

          +

          + Related samples +

          +
          +
          diff --git a/samples/kittenMonitor.html b/samples/kittenMonitor.html index f8a1192ae..c37ea87e5 100644 --- a/samples/kittenMonitor.html +++ b/samples/kittenMonitor.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Kitten Monitor | GoJS Diagramming Library + Kitten Monitor Using Background Image | GoJS Diagramming Library @@ -123,140 +123,139 @@
          diff --git a/samples/ldLayout.html b/samples/ldLayout.html index 338c059de..9d42927fd 100644 --- a/samples/ldLayout.html +++ b/samples/ldLayout.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Layered Digraph | GoJS Diagramming Library + Layered Digraph Demonstration of LayeredDigraphLayout Options | GoJS Diagramming Library @@ -325,8 +325,8 @@ function buildSettingsMenu(){ // Calls to build each setting to the respective builder - Default Properties buildButtonRow('layerSpacing', 5, 25, 'Layer Spacing', 'table1', 0); - buildButtonRow('columnSpacing', 5, 25, 'Height Spacing', 'table1', 0); - buildSwitch('setsPortSpots', 'Sets Port Spot', 'table1', 'checked'); + buildButtonRow('columnSpacing', 5, 25, 'Column Spacing', 'table1', 0); + buildSwitch('setsPortSpots', 'Sets Port Spots', 'table1', 'checked'); buildDropdown('cycleRemoveOption', 'Cycle Remove', 'table1', ['Depth First', 'Greedy']); buildDropdown('direction', 'Direction', 'table2', ['Right', 'Down', 'Left', 'Up']); diff --git a/samples/leaflet.html b/samples/leaflet.html index 5a4bed603..f43b6efaa 100644 --- a/samples/leaflet.html +++ b/samples/leaflet.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - GoJS and Leaflet Map | GoJS Diagramming Library + Geographic Diagram in Front of Leaflet.js Map | GoJS Diagramming Library @@ -330,9 +330,11 @@

          This diagram displays a few train stations and routes in France, Belgium, and the UK. The data is only meant as an example of using GoJS and is not meant to - be accurate. + be accurate. We also have a separate sample that demonstrates the ability to reshape routes between points, instead of only having a simple point-to-point curve. +

          +

          + Note that the map is fetched through the Mapbox API. Access tokens can expire, and you'll need to get your own token.

          -

          Note that the map is fetched through the Mapbox API. Access tokens can expire, and you'll need to get your own token.

          diff --git a/samples/linksToLinks.html b/samples/linksToLinks.html index feb61240f..732c01a26 100644 --- a/samples/linksToLinks.html +++ b/samples/linksToLinks.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Links to Links | GoJS Diagramming Library + Connecting Links to Links Using Link Label Nodes | GoJS Diagramming Library diff --git a/samples/localView.html b/samples/localView.html index 3e9998158..3dd642fdf 100644 --- a/samples/localView.html +++ b/samples/localView.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Local View | GoJS Diagramming Library + Full Diagram and its Local View | GoJS Diagramming Library diff --git a/samples/logicCircuit.html b/samples/logicCircuit.html index dee3f5009..cbe7d0c8a 100644 --- a/samples/logicCircuit.html +++ b/samples/logicCircuit.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Logic Circuit Diagram | GoJS Diagramming Library + Logic Circuit Diagram with Simple Simulation | GoJS Diagramming Library diff --git a/samples/macros.html b/samples/macros.html index 07f2f81d0..cd4da8e73 100644 --- a/samples/macros.html +++ b/samples/macros.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Macros | GoJS Diagramming Library + Macros -- Automatic Ungrouping of Dropped Elements | GoJS Diagramming Library diff --git a/samples/magnifier.html b/samples/magnifier.html index e449efe77..9192d7729 100644 --- a/samples/magnifier.html +++ b/samples/magnifier.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Magnifier | GoJS Diagramming Library + Magnified View of Portion of Diagram Using Overview | GoJS Diagramming Library diff --git a/samples/minimal.html b/samples/minimal.html index c9e4aaa82..bcd4e3423 100644 --- a/samples/minimal.html +++ b/samples/minimal.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Minimal | GoJS Diagramming Library + Minimal Diagram Showing Built-in Operations | GoJS Diagramming Library diff --git a/samples/minimalBlob.html b/samples/minimalBlob.html index 8afa3ce9e..320754e77 100644 --- a/samples/minimalBlob.html +++ b/samples/minimalBlob.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Minimal Image Download | GoJS Diagramming Library + Minimal Image Download Using MakeImageData and Blobs | GoJS Diagramming Library diff --git a/samples/minimalSvg.html b/samples/minimalSvg.html index 98ef1b5f8..fa3d6cf91 100644 --- a/samples/minimalSvg.html +++ b/samples/minimalSvg.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Minimal SVG Download | GoJS Diagramming Library + Minimal SVG Download Using MakeSvg | GoJS Diagramming Library diff --git a/samples/multiArrow.html b/samples/multiArrow.html index 086077fa9..88fcc4bb7 100644 --- a/samples/multiArrow.html +++ b/samples/multiArrow.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Multiple Arrowheads | GoJS Diagramming Library + Multiple Arrowheads Along Link Path | GoJS Diagramming Library @@ -187,9 +187,10 @@ // Produce a Geometry that includes an arrowhead at the end of each segment. // This only works with orthogonal non-Bezier routing. class MultiArrowLink extends go.Link { - constructor(...args) { - super(...args); + constructor(init) { + super(); this.routing = go.Routing.Orthogonal; + if (init) Object.assign(this, init); } // produce a Geometry from the Link's route diff --git a/samples/multiColorLinks.html b/samples/multiColorLinks.html index 4123630f8..df87981b7 100644 --- a/samples/multiColorLinks.html +++ b/samples/multiColorLinks.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Multi-color Links | GoJS Diagramming Library + Multi-color Link Paths | GoJS Diagramming Library @@ -127,6 +127,11 @@ // Also assume that each Link has as many Shapes in it that are marked with isPanelMain: true // as you want to get a color from the linkdata.colors Array, because each Shape can only show one color. class MultiColorLink extends go.Link { + constructor(init) { + super(); + if (init) Object.assign(this, init); + } + makeGeometry() { const geo = super.makeGeometry(); const colors = this.data.colors; diff --git a/samples/multiNodePathLinks.html b/samples/multiNodePathLinks.html index 82002ff24..f831c6c97 100644 --- a/samples/multiNodePathLinks.html +++ b/samples/multiNodePathLinks.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Multi-Node Path Links | GoJS Diagramming Library + Curved Multi-Node Path Link Routes | GoJS Diagramming Library @@ -217,6 +217,11 @@ } class MultiNodePathLink extends go.Link { + constructor(init) { + super(); + if (init) Object.assign(this, init); + } + // ignores this.routing, this.adjusting, this.corner, this.smoothness, this.curviness computePoints() { // get the list of Nodes that should be along the path diff --git a/samples/navigation.html b/samples/navigation.html index fd845f1ff..46a7a34da 100644 --- a/samples/navigation.html +++ b/samples/navigation.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Navigation | GoJS Diagramming Library + Programmatic Navigation Through Related Nodes/Links/Groups | GoJS Diagramming Library diff --git a/samples/network.html b/samples/network.html index 18ff07ea9..e5e1eeb33 100644 --- a/samples/network.html +++ b/samples/network.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Network | GoJS Diagramming Library + Network Configuration Diagram Editor With Bars | GoJS Diagramming Library @@ -253,7 +253,7 @@ portId: '', toLinkable: true }) - .bind('desiredSize', 'size', go.Size.parse, go.Size.stringify) + .bindTwoWay('desiredSize', 'size', go.Size.parse, go.Size.stringify) .bind('fill'), new go.TextBlock({ alignment: go.Spot.Right, alignmentFocus: go.Spot.Left, editable: true }).bindTwoWay('text') ) @@ -309,6 +309,11 @@ // If the regular node is too far to the left or right of the "HBar" node, the link connects // with the closest end of the "HBar" node. class BarLink extends go.Link { + constructor(init) { + super(); + if (init) Object.assign(this, init); + } + computeSpot(from, port) { if (from && this.toNode && this.toNode.category === 'HBar') return go.Spot.TopBottomSides; if (!from && this.fromNode && this.fromNode.category === 'HBar') return go.Spot.TopBottomSides; diff --git a/samples/networkConfig.html b/samples/networkConfig.html index 1115efb0e..ca6c5bc18 100644 --- a/samples/networkConfig.html +++ b/samples/networkConfig.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Network Configuration Diagram | GoJS Diagramming Library + Network Configuration Diagram Editor With Groups | GoJS Diagramming Library diff --git a/samples/orgChartAssistants.html b/samples/orgChartAssistants.html index 39ecc0e17..975548f12 100644 --- a/samples/orgChartAssistants.html +++ b/samples/orgChartAssistants.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Org Chart Assistants | GoJS Diagramming Library + Org Chart with Assistants on the Side | GoJS Diagramming Library @@ -319,6 +319,11 @@ // An assistant node may be the root of its own subtree. // An assistant node may have its own assistant nodes. class SideTreeLayout extends go.TreeLayout { + constructor(init) { + super(); + if (init) Object.assign(this, init); + } + makeNetwork(coll) { const net = super.makeNetwork(coll); // copy the collection of TreeVertexes, because we will modify the network diff --git a/samples/orgChartEditor.html b/samples/orgChartEditor.html index 90f0b4f3e..1eff369d9 100644 --- a/samples/orgChartEditor.html +++ b/samples/orgChartEditor.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Interactive Organizational Chart Editor Diagram | GoJS Diagramming Library + Interactive Organizational Chart Diagram Editor | GoJS Diagramming Library diff --git a/samples/orgChartExtras.html b/samples/orgChartExtras.html index 92b80a9f9..ad2024596 100644 --- a/samples/orgChartExtras.html +++ b/samples/orgChartExtras.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Org Chart Extras | GoJS Diagramming Library + Org Chart With Extra Relationships | GoJS Diagramming Library diff --git a/samples/orgChartStatic.html b/samples/orgChartStatic.html index f6076208f..b9f934159 100644 --- a/samples/orgChartStatic.html +++ b/samples/orgChartStatic.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Organizational Chart Diagram with Overview | GoJS Diagramming Library + Organizational Chart Diagram with Overview and Search | GoJS Diagramming Library diff --git a/samples/pageFlow.html b/samples/pageFlow.html index 4ac032309..ed2b1d937 100644 --- a/samples/pageFlow.html +++ b/samples/pageFlow.html @@ -17,9 +17,9 @@ - - - + + + @@ -34,7 +34,7 @@ - Page Flow | GoJS Diagramming Library + Page Flow Diagram Editor | GoJS Diagramming Library diff --git a/samples/panelLayout.html b/samples/panelLayout.html index ce12c0e7b..fbd2a138d 100644 --- a/samples/panelLayout.html +++ b/samples/panelLayout.html @@ -17,14 +17,14 @@ - - - + + + - - - + + + @@ -34,7 +34,7 @@ - Panel Layout | GoJS Diagramming Library + Custom Panel Layout: Cascading Elements | GoJS Diagramming Library @@ -124,9 +124,10 @@